OwlCyberSecurity - MANAGER
Edit File: table-of-contents.min.js
let scrollData=!0,scrollOffset=30,scrolltoTop=!1,scrollElement=null;UAGBTableOfContents={_getDocumentElement(){let e=document;var t=document.querySelectorAll('iframe[name="editor-canvas"]');return!t?.length||(t=t?.[0]?.contentWindow?.document||t?.[0]?.contentDocument)&&(e=t),e},init(n,e){const t=UAGBTableOfContents._getDocumentElement();if(null!==document.querySelector(".uagb-toc__list")&&document.querySelector(".uagb-toc__list").addEventListener("click",UAGBTableOfContents._scroll),null!==document.querySelector(".uagb-toc__scroll-top")&&document.querySelector(".uagb-toc__scroll-top").addEventListener("click",UAGBTableOfContents._scrollTop),e?.makeCollapsible){const s=t.querySelector(n);t.addEventListener("click",function(e){const t=e.target,o="path"===t?.tagName||"svg"===t?.tagName||"DIV"===t?.tagName,l="uagb-toc__title"===t?.className||"uagb-toc__title"===t?.parentNode?.className||"svg"===t?.parentNode?.tagName;if(o&&l){const r=t?.closest(".wp-block-uagb-table-of-contents"+n);e=s?.querySelector(".wp-block-uagb-table-of-contents .uagb-toc__list-wrap");e&&(r?.classList?.contains("uagb-toc__collapse")?(r?.classList?.remove("uagb-toc__collapse"),UAGBTableOfContents._slideDown(e,500)):(r?.classList?.add("uagb-toc__collapse"),UAGBTableOfContents._slideUp(e,500)))}})}document.addEventListener("scroll",UAGBTableOfContents._showHideScroll)},_slideUp(e,t){e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.boxSizing="border-box",e.style.height=e.offsetHeight+"px",e.offsetHeight,e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,window.setTimeout(()=>{e.style.display="none",e.style.removeProperty("height"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")},t)},_slideDown(e,t){e.style?.removeProperty("display");let o=window?.getComputedStyle(e).display;"none"===o&&(o="block"),e.style.display=o;var l=e.offsetHeight;e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,e.offsetHeight,e.style.boxSizing="border-box",e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.height=l+"px",e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),window.setTimeout(()=>{e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")},t)},hyperLinks(){const e=window.location.hash.substring(0);if(""!==e&&!/[^a-z0-9_-]$/.test(e)){var t=encodeURI(e.substring(0));if(null!==document?.querySelector(t)){const o=document.querySelector(".wp-block-uagb-table-of-contents");scrollOffset=o.getAttribute("data-offset");t=document.querySelector(e).offsetTop;null!==t&&scroll({top:t-scrollOffset,behavior:"smooth"})}}},_showHideScroll(){null!==(scrollElement=document.querySelector(".uagb-toc__scroll-top"))&&(300<window.scrollY&&scrolltoTop?scrollElement.classList.add("uagb-toc__show-scroll"):scrollElement.classList.remove("uagb-toc__show-scroll"))},_scrollTop(){window.scrollTo({top:0,behavior:"smooth"})},_scroll(e){e.preventDefault();let t=e.target.getAttribute("href");if(!t&&"A"!==e.target.tagName){const o=e.target.closest("a");t=o.getAttribute("href")}if(t){const l=document.querySelector(".wp-block-uagb-table-of-contents");scrollData=l.getAttribute("data-scroll"),scrollOffset=l.getAttribute("data-offset");let e=null;t=t.substring(1),document?.querySelector("[id='"+t+"']")&&(e=document.querySelector("[id='"+t+"']")?.getBoundingClientRect().top+window.scrollY),scrollData?null!==e&&scroll({top:e-scrollOffset,behavior:"smooth"}):scroll({top:e,behavior:"auto"})}},selectDomElement(e){const t=document.querySelector(e+":not(.script-init)");return t?(t.classList.add("script-init"),t):null},parseTocSlug(e){if(!e)return e;e=e.toString().toLowerCase().replace(/\…+/g,"").replace(/\u2013|\u2014/g,"").replace(/&(amp;)/g,"").replace(/[&]nbsp[;]/gi,"-").replace(/[^a-zA-Z0-9\u00C0-\u017F _-]/g,"").replace(/&(mdash;)/g,"").replace(/\s+/g,"-").replace(/[&\/\\#,^!+()$~%.\[\]'":*?;-_<>{}@‘’”“|]/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");return decodeURI(encodeURIComponent(e))},mapTocAnchorsForHref(e){for(const o of e){var t=o.textContent,t=UAGBTableOfContents.parseTocSlug(t);o.setAttribute("href","#"+t)}},_run(e,t){setTimeout(function(){UAGBTableOfContents._runWithTimeOut(e,t)},500)},_runWithTimeOut(t,p){const o=UAGBTableOfContents.selectDomElement(p);if(o){null!==o.querySelector(".uag-toc__collapsible-wrap")&&0<o.querySelector(".uag-toc__collapsible-wrap").length&&o.querySelector(".uagb-toc__title-wrap").classList.add("uagb-toc__is-collapsible");const l=[];let e;void 0!==t.mappingHeaders&&(t.mappingHeaders.forEach(function(e,t){!0===e&&l.push("h"+(t+1))}),e=null!==l?l.join(","):"");var d=void 0!==e&&""!==e?document.body.querySelectorAll(e):document.body.querySelectorAll("h1, h2, h3, h4, h5, h6");if(0!==d.length){const r=o.querySelector(".uagb-toc__list-wrap");if(!r)return;const n=Array.from(d),s=r.getElementsByTagName("a");UAGBTableOfContents.mapTocAnchorsForHref(s);function g(e=[]){const o=[];return e.reduce((e,t)=>((e.some(e=>e.innerText===t.innerText)?o:e).push(t),e),[]),o}const a=g(n);for(let e=0;e<n.length;e++){let t=UAGBTableOfContents.parseTocSlug(n[e].innerText);if(""!==n[e].innerText&&t.length<1){var m=n[e].innerText;for(let e=0;e<s.length;e++)if(s[e].textContent===m){const i="#toc_"+Math.random();s[e].setAttribute("href",i),t=i.substring(1)}}const c=document.createElement("span");c.id=t,c.className="uag-toc__heading-anchor",n[e].prepend(c);for(let t=0;t<a.length;t++){const y="#toc_"+Math.random();a[t]?.querySelector(".uag-toc__heading-anchor")?.setAttribute("id",y.substring(1));const b=g(Array.from(r.getElementsByTagName("a")));for(let e=0;e<b.length;e++)b[t]?.setAttribute("href",y)}}}scrolltoTop=t.scrollToTop;if(null===(scrollElement=document.querySelector(".uagb-toc__scroll-top"))){const u=document.createElement("div");u.classList.add("uagb-toc__scroll-top"),u.innerHTML='<svg xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" width="26px" height="16.043px" viewBox="57 35.171 26 16.043" enable-background="new 57 35.171 26 16.043" xml:space="preserve"><path d="M57.5,38.193l12.5,12.5l12.5-12.5l-2.5-2.5l-10,10l-10-10L57.5,38.193z"/></svg>',document.body.appendChild(u)}null!==scrollElement&&scrollElement.classList.add("uagb-toc__show-scroll"),UAGBTableOfContents._showHideScroll(),UAGBTableOfContents.hyperLinks(),UAGBTableOfContents.init(p,t)}}};