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