import{d as a}from"./index.e0fdfdc6.js";const u={STANDALONE:"standalone",SYNCED:"synced"},c=t=>{const e=t.find(s=>{var n;return 0<((n=s.headings)==null?void 0:n.length)});return!!(e&&Object.keys(e).length)},l=(t,e=0)=>{var o;if(!c([...t]))return t;const s=[],n=[...t];for(;n.length&&!(e&&s.length===e);){const{...r}=n.shift();(o=r.headings)!=null&&o.length&&n.unshift(...r.headings),r.headings=[],s.push(r)}return s},f=(t,e=0)=>(t=l([...t]),t.forEach((s,n)=>{const o=e+n+1;s.editedOrder=o}),t.sort((s,n)=>s.editedOrder-n.editedOrder)),h=a("TableOfContentsStore",{state:()=>({clientIds:[]}),getters:{headings:t=>{var s,n;if(!((n=(s=window.wp)==null?void 0:s.data)!=null&&n.select))return[];const e=[];return t.clientIds.forEach(o=>{var i;const r=(i=window.wp.data.select("core/block-editor"))==null?void 0:i.getBlockAttributes(o);r!=null&&r.headings&&e.push(...r.headings)}),e}},actions:{addClientId(t){this.clientIds.includes(t)||this.clientIds.push(t)},removeClientId(t){this.clientIds=this.clientIds.filter(e=>e!==t)}}});export{u as M,l as f,f as o,h as u};
