(()=>{"use strict";var e={n:a=>{var d=a&&a.__esModule?()=>a.default:()=>a;return e.d(d,{a:d}),d},d:(a,d)=>{for(var n in d)e.o(d,n)&&!e.o(a,n)&&Object.defineProperty(a,n,{enumerable:!0,get:d[n]})},o:(e,a)=>Object.prototype.hasOwnProperty.call(e,a)};const a=window.wp.domReady;var d=e.n(a);const n=window.wp.url,t=window.wp.commands,o=window.wp.data,c=window.wp.components,r=window.wp.coreData,s=window.wp.element,i=["advanced_ads_groups"],p=["advanced_ads","advanced_ads_plcmnt"],m={advanced_ads:"Ads",advanced_ads_plcmnt:"Placement",advanced_ads_groups:"Group"},l={advanced_ads:"format-video",advanced_ads_plcmnt:"welcome-widgets-menus",advanced_ads_groups:"category"},u=(e,a)=>"advanced_ads_plcmnt"===e?(0,n.addQueryArgs)(`edit.php#modal-placement-edit-${a.id}`,{post_status:"all",s:a.title?.rendered,post_type:e}):(0,n.addQueryArgs)("post.php",{action:"edit",post:a.id});function w({search:e}){const{records:a,isLoading:d}=(0,o.useSelect)(a=>{const{getEntityRecords:d,hasFinishedResolution:t}=a(r.store),o={search:e,per_page:10},w=p.flatMap(e=>{const a=d("postType",e,o);return a?a.map(a=>({name:`edit-${e}-${a.id}`,label:`${m[e]}: ${a.title?.rendered}`,category:"edit",icon:(0,s.createElement)(c.Dashicon,{icon:l[e]}),editUrl:u(e,a)})):[]}),_=i.flatMap(e=>{const a=d("taxonomy",e,o);return a?a.map(a=>({name:`edit-${e}-${a.id}`,label:`${m[e]}: ${a.name}`,category:"edit",icon:(0,s.createElement)(c.Dashicon,{icon:l[e]}),editUrl:(0,n.addQueryArgs)(`admin.php#modal-group-edit-${a.id}`,{page:"advanced-ads-groups",s:a.name})})):[]}),g=p.every(e=>t("getEntityRecords",["postType",e,o])),v=i.every(e=>t("getEntityRecords",["taxonomy",e,o]));return{records:[...w,..._],isLoading:!g||!v}},[e]);return{commands:(0,s.useMemo)(()=>(a??[]).slice(0,10).map(e=>({...e,callback:({close:a})=>{document.location=e.editUrl,a()}})),[a]),isLoading:d}}function _(){return(0,t.useCommandLoader)({name:"advanced-ads/commands/search",hook:w}),null}d()(function(){!function(){const e=document.createElement("div");e.id="advanced-ads-commands-root",document.body.appendChild(e),wp.element.createRoot(e).render((0,s.createElement)(_))}()})})();