import{l,a as m,n as p}from"./index.4b887428.js";const d={getTerms:async e=>{const{apiFetch:t}=window.wp,{addQueryArgs:o}=window.wp.url,n=a(e);return await t({path:o(`/wp/v2/${n.restBase}`,{per_page:-1,orderby:"count",order:"desc",_fields:"id,name"})})},getSelectedTerms:(e,t=!1)=>{const o=a(e,t);return window.wp.data.select("core/editor").getEditedPostAttribute(o.restBase)||[]}},y={getTerms:async e=>{var s;const t=[],o=a(e);return(((s=document.getElementById(`${o.name}checklist`))==null?void 0:s.querySelectorAll("li"))||[]).forEach(r=>{const c=r.querySelector("input").value,i=r.querySelector("label").innerText;t.push({id:parseInt(c,10),name:i.trim()})}),new Promise(r=>{r(t)})},getSelectedTerms:(e,t=!1)=>{var r;const o=[],n=a(e,t);return(((r=document.getElementById(`${n.name}checklist`))==null?void 0:r.querySelectorAll("input:checked"))||[]).forEach(c=>{o.push(parseInt(c.value,10))}),o}},u=(e=!1)=>{var n;l();const o=((n=m().aioseo.postData)==null?void 0:n.taxonomies)||[];return e?o:o.filter(s=>s.primaryTermSupport===!0)},g=e=>u().some(t=>e===t.name),a=(e,t=!1)=>{const o=u(t).filter(n=>e===n.name);return o.length?o[0]:{}},x=(e,t=!1)=>p()?d.getSelectedTerms(e,t):y.getSelectedTerms(e,t);export{u as a,x as g,g as t};
