(()=>{"use strict";var e,t={631:()=>{const e=window.wp.blocks,t=JSON.parse('{"UU":"wpseopress/table-of-contents"}'),l=window.React,n=window.wp.blockEditor,r=window.wp.components,s=window.wp.data,a=window.wp.element,o=window.wp.i18n,i=e=>{let t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||""},c=({headings:e,listTag:t})=>{const n="ul"===t?"ul":"ol";return e.length?(0,l.createElement)(n,null,e.map((e=>(0,l.createElement)("li",{key:e.clientId},e.attributes.anchor&&(0,l.createElement)("a",{href:"#"+e.attributes.anchor},e.content)||(0,l.createElement)("span",null,e.content),e.children?.length>0&&(0,l.createElement)(c,{headings:e.children,listTag:t}))))):""},p=c,u=({attributes:e,setAttributes:t})=>{const{listTag:s,levels:a}=e;return(0,l.createElement)(n.InspectorControls,null,(0,l.createElement)(r.PanelBody,{title:(0,o.__)("Block settings","wp-seopress-pro")},(0,l.createElement)(r.PanelRow,null,(0,l.createElement)(r.CheckboxControl,{label:(0,o.__)("Display as unordered list.","wp-seopress-pro"),checked:"ul"===s,onChange:e=>t({listTag:e?"ul":"ol"})})),(0,l.createElement)(r.PanelRow,{className:"panel-row-headings"},(0,l.createElement)("h3",null,(0,o.__)("Headings to include","wp-seopress-pro")),[1,2,3,4,5,6].map((e=>(0,l.createElement)(r.CheckboxControl,{key:`heading-${e}`,label:(0,o.__)(`Heading ${e}`,"wp-seopress-pro"),checked:a.includes(e),value:e,onChange:l=>((e,l)=>{let n=[...a];l?n.includes(e)||n.push(e):n=n.filter((t=>t!==e)),t({levels:n.sort()})})(e,l)}))))))},h=(e=[])=>e.flatMap(((e={})=>"core/heading"===e.name&&e.attributes.content?{...e,level:e.attributes.level,content:i(e.attributes.content)}:h(e.innerBlocks||[]))),d=(e=[])=>{const t=[];return e.forEach(((l,n)=>{const r=!(l?.attributes?.className||"").includes("seopress-toc-hidden");if(l.level<=e[0].level)if(e[n+1]?.level>e[0].level){let s=e.length;for(let t=n+1;t<e.length;t++)if(e[t].level<=e[0].level){s=t;break}r&&t.push({...l,children:d(e.slice(n+1,s))})}else r&&t.push({...l,children:[]})})),t},g=(0,s.withSelect)((e=>{const{getBlocks:t}=e("core/block-editor");return{blocks:t()}}))((({attributes:e,setAttributes:t,blocks:i})=>{const{updateBlockAttributes:c}=(0,s.dispatch)("core/block-editor"),g=h(i).filter((t=>t.content&&t.level&&e.levels.includes(t.level)))||[],v=d(g);return(0,a.useEffect)((()=>{JSON.stringify(e.headings)!==JSON.stringify(v)&&t({headings:v})}),[v]),(0,l.createElement)(l.Fragment,null,(0,l.createElement)(u,{attributes:e,setAttributes:t}),(0,l.createElement)("nav",{...(0,n.useBlockProps)()},!e.headings.length&&(0,l.createElement)(r.Notice,{status:"warning",isDismissible:!1},(0,o.__)("The headings chosen from the block panel will appear here.","wp-seopress-pro")),(0,l.createElement)(p,{headings:e.headings,listTag:e.listTag})))}));(0,e.registerBlockType)(t.UU,{edit:g,save:function({attributes:e}){const t=parseInt(e.titleLevel)?`h${e.titleLevel}`:e.titleLevel;return(0,l.createElement)("div",{...n.useBlockProps.save()},e.title&&(0,l.createElement)(n.RichText.Content,{tagName:t,value:e.title}),(0,l.createElement)("nav",null,(0,l.createElement)(p,{headings:e.headings,listTag:e.listTag})))}})}},l={};function n(e){var r=l[e];if(void 0!==r)return r.exports;var s=l[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.m=t,e=[],n.O=(t,l,r,s)=>{if(!l){var a=1/0;for(p=0;p<e.length;p++){for(var[l,r,s]=e[p],o=!0,i=0;i<l.length;i++)(!1&s||a>=s)&&Object.keys(n.O).every((e=>n.O[e](l[i])))?l.splice(i--,1):(o=!1,s<a&&(a=s));if(o){e.splice(p--,1);var c=r();void 0!==c&&(t=c)}}return t}s=s||0;for(var p=e.length;p>0&&e[p-1][2]>s;p--)e[p]=e[p-1];e[p]=[l,r,s]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={237:0,361:0};n.O.j=t=>0===e[t];var t=(t,l)=>{var r,s,[a,o,i]=l,c=0;if(a.some((t=>0!==e[t]))){for(r in o)n.o(o,r)&&(n.m[r]=o[r]);if(i)var p=i(n)}for(t&&t(l);c<a.length;c++)s=a[c],n.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return n.O(p)},l=globalThis.webpackChunkwp_seopress_pro=globalThis.webpackChunkwp_seopress_pro||[];l.forEach(t.bind(null,0)),l.push=t.bind(null,l.push.bind(l))})();var r=n.O(void 0,[361],(()=>n(631)));r=n.O(r)})();