class LiquidLocalScrollBehavior extends LiquidBehavior{static behaviorName="liquidLocalScroll";static domEvents={"click @links":"onLinkClicked"};options(){return{ease:"power2.inOut",duration:null,offset:null}}get ui(){return{links:"[data-lqd-local-scroll-el]"}}initialize(){super.initialize(),this.watchers=[],this.initWatcher(),typeof elementorFrontend<"u"&&(elementorFrontend?.config?.experimentalFeatures?.e_css_smooth_scroll?elementorFrontend?.utils?.anchor_scroll_margin?.setSettings("selectors.targets",".to-disabled-el-local"):elementorFrontend?.utils?.anchors?.setSettings("selectors.targets",".to-disabled-el-local"))}toggleLinkActive(i){this.getUI("links").forEach(l=>l.classList.remove("lqd-is-active")),i.classList.add("lqd-is-active")}initWatcher(){this.getUI("links").forEach((s,l)=>{const n=s.getAttribute("href");if(!n||n==="")return;const o=new URL(n,window.location.href).hash;if(!o)return;const r=document.querySelector(o);if(!r)return;if(!r.closest(".elementor-widget-lqd-stack")){const a=ScrollTrigger.create({trigger:r,start:"top center",end:"bottom center+=10px",onToggle:c=>{c.isActive&&this.toggleLinkActive(s)}});this.watchers.push(a)}})}onLinkClicked(i){const s=i.currentTarget,l=s?.getAttribute("href");if(!l||l==="")return;const n=new URL(l,window.location.href).hash;if(!n)return;const o=document.querySelector(n);if(!o)return;i.preventDefault(),i.stopPropagation();const r=this.getOption("offset")||this.liquidApp.globalOptions.localScroll?.offset,g=this.getOption("duration")||this.liquidApp.globalOptions.localScroll?.duration||1,a=this.getOption("ease"),c=this.view.model.get("behaviors")?.filter(t=>t.behaviorName==="liquidToggle"),d=this.view.model.get("parentsCollection")?.find(t=>t.get("behaviors")?.find(e=>e.behaviorName==="liquidToggle")),u=o.closest(".elementor-widget-lqd-stack");if(!u)window.document.documentElement.style.scrollBehavior="auto",this.scrollTween=gsap.to(window,{duration:g,ease:a,scrollTo:{y:o,offsetY:r,autoKill:!this.liquidApp.touchMatchMedia.matches},onComplete:()=>{window.document.documentElement.style.scrollBehavior=""}});else{const t=this.liquidApp.elementsCollection.get(u.getAttribute("data-lqd-model-cid"))?.get("behaviors")?.find(e=>e.behaviorName==="liquidStack");if(t){const e=o.closest(".lqd-stack-item"),h=parseInt(e.getAttribute("data-stack-index"),10);t.setCurrentIndex({index:h}),this.toggleLinkActive(s)}}d&&d.get("behaviors")?.filter(e=>e.behaviorName==="liquidToggle")?.forEach(e=>{const h=e.getChangeProp();d.set({[h]:[-1]})}),this.liquidApp.touchMatchMedia.matches&&c?.forEach(t=>{const e=t.getChangeProp();this.view.model.set({[e]:[-1]})})}destroy(){this.scrollTween?.kill(),this.watchers?.forEach(i=>i.kill()),super.destroy()}}typeof window<"u"&&(window.liquid?.app?window.liquid?.app?.model?.set("loadedBehaviors",[...window.liquid.app.model.get("loadedBehaviors"),LiquidLocalScrollBehavior]):window.liquid?.loadedBehaviors?.push(LiquidLocalScrollBehavior));
