(()=>{"use strict";var e={n:s=>{var o=s&&s.__esModule?()=>s.default:()=>s;return e.d(o,{a:o}),o},d:(s,o)=>{for(var t in o)e.o(o,t)&&!e.o(s,t)&&Object.defineProperty(s,t,{enumerable:!0,get:o[t]})},o:(e,s)=>Object.prototype.hasOwnProperty.call(e,s)};const s=window.React,o=window.wp.element,t=window.wp.components,r=window.wp.data,a=window.wp.notices,n=window.wp.hooks,c=window.wp.apiFetch;var p=e.n(c);const i=window.wp.i18n,l=()=>window.SEOPRESS_PRO_COMMAND_PALETTE||{};function d(){const e=(0,r.useSelect)((e=>e(a.store).getNotices().filter((e=>"snackbar"===e.type))),[]),{removeNotice:o}=(0,r.useDispatch)(a.store);return(0,s.createElement)(t.SnackbarList,{className:"seopress-command-palette-snackbars",notices:e,onRemove:o})}function w(){if(!window.wp?.element||document.body.classList.contains("block-editor-page"))return;const e=document.createElement("div");e.id="seopress-pro-command-palette-notices",document.body.appendChild(e),(0,o.createRoot)(e).render((0,s.createElement)(d,null))}function _(e,s){const o=window.wp?.data?.dispatch?.("core/notices");o?"error"===s?o.createErrorNotice(e,{type:"snackbar"}):o.createSuccessNotice(e,{type:"snackbar"}):window.alert(e)}function m(){const e=l(),s=(e.HOME_URL||"/").replace(/\/$/,""),o=e.NEWS_SITEMAP_URL||`${s}/news.xml`,t=e.VIDEO_SITEMAP_URL||`${s}/video1.xml`,r=[];e.IS_BOT_ENABLED&&(r.push({namePart:"pro-action/scan-broken-links",label:(0,i.__)("Scan for broken links","wp-seopress-pro"),keywords:["broken links","scan","links","crawl","check"],callback:async({close:e})=>{e();try{await p()({path:"/seopress/v1/broken-links/scan",method:"POST"}),_((0,i.__)("Broken links scan started.","wp-seopress-pro"))}catch(e){_(e?.message||(0,i.__)("Failed to start broken links scan.","wp-seopress-pro"),"error")}}}),r.push({namePart:"pro-action/run-site-audit",label:(0,i.__)("Run site audit scan","wp-seopress-pro"),keywords:["site audit","scan","crawl","audit"],callback:async({close:e})=>{e();try{await p()({path:"/seopress/v1/site-audit/scan?action=start",method:"POST"}),_((0,i.__)("Site audit started.","wp-seopress-pro"))}catch(e){_(e?.message||(0,i.__)("Failed to start site audit.","wp-seopress-pro"),"error")}}})),e.IS_ALERTS_ENABLED&&r.push({namePart:"pro-action/check-alerts",label:(0,i.__)("Check SEO alerts now","wp-seopress-pro"),keywords:["alerts","check","monitoring","health"],callback:async({close:e})=>{e();try{const e=await p()({path:"/seopress/v1/alerts?force=true"}),s=[e?.homepage_noindex,e?.robots_txt,e?.xml_sitemap].filter((e=>e&&"error"===e.status)).length;0===s?_((0,i.__)("All SEO checks passed.","wp-seopress-pro")):_((0,i.sprintf)(/* translators: %d: number of SEO alerts detected. */ /* translators: %d: number of SEO alerts detected. */
(0,i._n)("%d SEO alert detected.","%d SEO alerts detected.",s,"wp-seopress-pro"),s),"error")}catch(e){_(e?.message||(0,i.__)("Failed to check SEO alerts.","wp-seopress-pro"),"error")}}}),e.IS_NEWS_ENABLED&&r.push({namePart:"pro-action/open-news-sitemap",label:(0,i.__)("Open Google News sitemap (new tab)","wp-seopress-pro"),keywords:["news","google news","sitemap","open","view"],callback:({close:e})=>{e(),window.open(o,"_blank","noopener,noreferrer")}}),e.IS_VIDEO_SITEMAP_ENABLED&&r.push({namePart:"pro-action/open-video-sitemap",label:(0,i.__)("Open XML video sitemap (new tab)","wp-seopress-pro"),keywords:["video","sitemap","open","view","xml"],callback:({close:e})=>{e(),window.open(t,"_blank","noopener,noreferrer")}});const a=(0,i.__)("Quick action","wp-seopress-pro");return r.map((e=>({name:`seopress/${e.namePart}`,label:e.label,keywords:e.keywords,context:a,callback:e.callback})))}!function(){const e=l();e.REST_NONCE&&p().use(p().createNonceMiddleware(e.REST_NONCE))}(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",w):w(),(0,n.addFilter)("seopress.commands.register","seopress-pro/quick-actions",(e=>Array.isArray(e)?[...e,...m()]:e))})();