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