(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=ampThemes,n=window.wp.i18n,i=window.wp.domReady;var s=e.n(i);const a=wp.themes.view.Theme,r=a.extend({isAmpCompatibleTab:()=>new URLSearchParams(window.location.search.substr(1)).get("browse")===t.AMP_COMPATIBLE,render(...e){if(a.prototype.render.apply(this,e),0>=this.$el?.length||!this.$el[0])return;const t=this.$el[0],i=this.model.toJSON();let s=i?.slug;if(s||(s=i?.id),s&&this.isAmpTheme(s)&&setTimeout((()=>{if(this.isAmpCompatibleTab())return;const e=document.createElement("div"),i=document.createElement("span"),s=document.createElement("span");e.classList.add("amp-extension-card-message"),i.classList.add("amp-logo-icon"),s.classList.add("tooltiptext"),s.append((0,n.__)("This is known to work well with the AMP plugin.","amp")),e.append(i,s),t.appendChild(e)})),s&&!this.isWPORGTheme(s)){const e=document.createElement("span");e.classList.add("dashicons","dashicons-external"),e.setAttribute("aria-hidden","true");const s=document.createElement("span");s.classList.add("screen-reader-text"),s.append((0,n.__)("(opens in a new tab)","amp"));const a=document.createElement("a");a.classList.add("button","button-primary"),a.append((0,n.__)("Visit Site","amp"),s,e),a.href=i?.preview_url?i.preview_url:i.homepage,a.target="_blank",a.rel="noopener noreferrer",a.setAttribute("aria-label",(0,n.sprintf)(/* translators: %s: theme name. */
(0,n.__)("Visit site of %s theme","amp"),i.name));const r=t.querySelector(".theme-actions");r&&(r.textContent="",r.append(a));const o=t.querySelector(".more-details");o&&(o.textContent="",o.append((0,n.__)("Visit Site","amp"),e.cloneNode(!0)))}},preview(...e){const t=this.model.toJSON();this.isWPORGTheme(t.slug)?a.prototype.preview.apply(this,e):t?.preview_url&&window.open(t.preview_url,"_blank","noopener,noreferrer")},isAmpTheme:e=>t.AMP_THEMES.includes(e),isWPORGTheme:e=>!t.NONE_WPORG_THEMES.includes(e)}),o={init(){this.addTab(),this.overrideViews()},addTab(){const e=document.querySelector(".filter-links");if(!e)return;const i=document.createElement("li"),s=document.createElement("a");s.setAttribute("href","#"),s.setAttribute("data-sort",t.AMP_COMPATIBLE),s.append((0,n.__)("AMP Compatible","amp")),i.appendChild(s),e.appendChild(i)},overrideViews(){wp.themes.view.Theme=r}};s()((()=>{o.init()}))})();