(()=>{"use strict";var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=jQuery;var n=t.n(e);function i(t=document){try{if("editor-canvas"===window.frameElement?.getAttribute?.("name"))return!0}catch(t){}const e=t?.body;return!!e&&(!!e.classList.contains("wp-admin")||(!!e.classList.contains("block-editor-iframe__body")||!!e.classList.contains("editor-styles-wrapper")))}document.addEventListener("DOMContentLoaded",function(){r.init()});const r={init:function(){this.holder=document.querySelectorAll(".qi-block-table-of-contents"),this.holder.length&&[...this.holder].map(t=>{r.initItem(t)})},getRealCurrentItem:function(t){return"string"==typeof t&&""!==t&&(t=qiBlocksEditor.qodefGetCurrentBlockElement.get(t)),t},initItem:function(t,e){if(!(t=r.getRealCurrentItem(t)))return;let i,o=["h1","h2","h3","h4","h5","h6"],a=t.querySelector(".qodef-m-table-content"),l=void 0!==a.getAttribute("data-excluded-tags")?a.getAttribute("data-excluded-tags"):"",c=void 0!==a.getAttribute("data-excluded-cids")?a.getAttribute("data-excluded-cids"):"",d=void 0!==a.getAttribute("data-type")?a.getAttribute("data-type"):"ul",s=n()(t.querySelector(".qodef-m-table-content > "+d)),u="",f={},p={},h=[".qodef-e-number",".qodef-e-mark"],g=0;e&&(g=200,o=o.map(function(t){return".block-editor-block-list__layout.is-root-container "+t}),o.push(".editor-post-title.editor-post-title__block .editor-post-title__input")),setTimeout(()=>{i=r.prepareHeadings(l,c,o,e),e&&s.empty(),i.length&&(i.forEach((t,e)=>{let i,o=n()(t),a=o.clone();if(i=r.prepareId(h,a,u),u+=i.id+";",f[e]={id:i.finalID,tag:o.prop("tagName").replace("H","")},e>0){const t=o.prop("tagName").replace("H",""),n=f[e-1].tag;if(t>n){const t=s.find("a[href=#"+f[e-1].id+"]").parent();t.append("<"+d+">"),s=t.find(d).first()}else if(t<n){const n=r.findSiblings(t,e,f),i=s.parents(".qodef-m-table-content").find("a[href=#"+n+"]").parent();s=i.parents(d).first()}}o.attr("id",i.finalID);var l=n()("<li>");n()("<a>").attr("href","#"+i.finalID).text(a.text()).appendTo(l),l.appendTo(s)}),p=a.querySelectorAll("li > a"),p.forEach(t=>{t.addEventListener("click",function(e){e.preventDefault(),r.animateAnchor(t,t.getAttribute("href"))})}))},g)},prepareHeadings:function(t,e,r,o){let a,l,c,d=[],s="";if(0<t.length){l=t.split(","),o&&(l=l.map(function(t){return".block-editor-block-list__layout.is-root-container "+t}));for(let t=0;t<l.length;t++)-1!==r.indexOf(l[t])&&r.splice(r.indexOf(l[t]),1)}if(0<e.length){c=e.split(",");for(let t=0;t<c.length;t++)[".","#"].includes(c[t])||(s+=":not("+c[t]+")")}r=r.join(s+", ")+s;let u=document;i()&&(u=qiBlocksEditor.qodefGetCurrentBlockElement.getCurrentDocument()),a=u.querySelectorAll(r),Array.isArray(a)||(a=Array.from(a)),a.length&&a.forEach((t,e)=>{const i=n()(t);for(let t=0;t<c.length;t++)if(![".","#"].includes(c[t])){if(i.parents(c[t]).length)return void d.push(e)}});for(let t=d.length-1;t>=0;t--)a.splice(d[t],1);return a},prepareId:function(t,e,n){let i={};if(t.forEach(function(t){e.find(t).remove()}),i.id=e.text().trim().replaceAll(" ","_").replaceAll(/[^a-zA-Z_]+/g,""),0!==n.length){let t=new RegExp(i.id+";","g"),e=n.match(t),r=0;null!==e&&(r=e.length),0!==r?(r+=1,i.finalID=i.id+"____"+r):i.finalID=i.id}else i.finalID=i.id;return i},findSiblings:function(t,e,n){if(0===e)return n[0].id;{const i=e-1;return n[i].tag>t?r.findSiblings(t,i,n):n[i].id}},animateAnchor:function(t,e){let i,o=window.scrollY,a=n()(e).offset().top,l=o>a?-1:1,c=50,d=n()("#wpadminbar");d.length&&(a-=d.height());const s=function(){if(o===a)return;Math.abs(o-a)<=100&&(c=8),(-1===l&&o<a||1===l&&o>a)&&(o=a);const t=r.easingFunction((o-a)/o);n()("html, body").scrollTop(o-(o-a)*t),o+=l*c,i=requestAnimationFrame(s)};s(),n()(window).one("wheel touchstart",function(){cancelAnimationFrame(i)})},easingFunction:function(t){return 0===t?0:Math.pow(1024,t-1)}}})();