UNPKG

@fiddle-digital/string-tune

Version:

StringTune is a cutting-edge JavaScript library designed to deliver high-performance, modular web effects. Whether you're looking to add smooth parallax scrolling, dynamic cursor interactions, progress tracking, or autoplay videos, StringTune empowers dev

1 lines 82.6 kB
"use strict";var Vt=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ee=(c,e)=>{for(var t in e)Vt(c,t,{get:e[t],enumerable:!0})},re=(c,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Jt(e))!te.call(c,i)&&i!==t&&Vt(c,i,{get:()=>e[i],enumerable:!(r=Zt(e,i))||r.enumerable});return c};var ie=c=>re(Vt({},"__esModule",{value:!0}),c);var de={};ee(de,{StringAnchor:()=>xt,StringCursor:()=>ft,StringData:()=>N,StringDelayLerpTracker:()=>Ot,StringFPSTracker:()=>kt,StringForm:()=>Nt,StringGlide:()=>Et,StringLazy:()=>vt,StringLerp:()=>Ct,StringLerpTracker:()=>Dt,StringLoading:()=>yt,StringMagnetic:()=>bt,StringModule:()=>g,StringObject:()=>R,StringParallax:()=>Tt,StringPositionTracker:()=>Rt,StringProgress:()=>H,StringResponsive:()=>Mt,StringScrollbar:()=>Pt,StringSequence:()=>Ft,StringSplit:()=>It,StringTune:()=>qt,StringVideoAutoplay:()=>Ht,default:()=>qt});module.exports=ie(de);var tt=class{constructor(e=.1,t){this.SETTLE_THRESHOLD=.1;this.smoothingFactor=e,this.context=t,this.onSettingsChange({isDesktop:t.data.viewport.windowWidth>1080,widthChanged:!0,heightChanged:!0,scrollHeightChanged:!0})}onMouseMove(e){this.context.data.cursor.targetX=e.clientX,this.context.data.cursor.targetY=e.clientY}onFrame(){let{targetX:e,targetY:t,smoothedX:r,smoothedY:i}=this.context.data.cursor,o=this.context.tools.lerp.process({from:r,to:e,progress:this.smoothingFactor}),s=this.context.tools.lerp.process({from:i,to:t,progress:this.smoothingFactor}),n=this.getStepDistance(o,s);this.isSettled(n)?this.snapToTarget():this.applyStep(o,s)}onSettingsChange(e){let t=Number(this.context.settings.lerp);this.setLerpFactor(t)}setLerpFactor(e){this.smoothingFactor=this.context.tools.adaptiveLerp.process({value:e,inMin:.1,inMax:1,outMin:.05,outMax:.65})}getStepDistance(e,t){return Math.hypot(e,t)}isSettled(e){return e<this.SETTLE_THRESHOLD}snapToTarget(){this.context.data.cursor.smoothedX=this.context.data.cursor.targetX,this.context.data.cursor.smoothedY=this.context.data.cursor.targetY,this.context.data.cursor.stepX=0,this.context.data.cursor.stepY=0}applyStep(e,t){this.context.data.cursor.smoothedX+=e,this.context.data.cursor.smoothedY+=t,this.context.data.cursor.stepX=e,this.context.data.cursor.stepY=t}};var D=class{constructor(){this.listeners={};this.stateEvents=new Set;this.lastPayloads={};this.stateEvents.add("screen:mobile"),this.stateEvents.add("screen:tablet"),this.stateEvents.add("screen:laptop"),this.stateEvents.add("screen:desktop"),this.stateEvents.add("start")}on(e,t,r){let i=r?`${e}:${r}`:e;this.listeners[i]||(this.listeners[i]=new Set),this.listeners[i].add(t),this.stateEvents.has(i)&&this.lastPayloads[i]!==void 0&&t(this.lastPayloads[i])}off(e,t,r){let i=r?`${e}:${r}`:e;this.listeners[i]&&this.listeners[i].delete(t)}emit(e,t){this.stateEvents.has(e)&&(this.lastPayloads[e]=t);let r=this.listeners[e];if(r)for(let i of r)i(t)}onProgress(e,t){this.on(`progress:${e}`,t)}emitProgress(e,t){this.emit(`progress:${e}`,t)}onInview(e,t){this.on(`object:inview:${e}`,t)}emitInview(e,t){this.emit(`object:inview:${e}`,t)}onScroll(e){this.on("scroll",e)}emitScroll(e){this.emit("scroll",e)}onUpdate(e){this.on("update",e)}emitUpdate(){this.emit("update")}clear(e){delete this.listeners[e]}clearAll(){this.listeners={}}};var et=class{constructor(e){this.data=e;this.modules=[];this.uiModules=[]}register(e){e.type===1&&this.modules.push(e),e.type===2&&this.uiModules.push(e)}find(e){return this.modules.find(t=>t instanceof e)}onInit(){[...this.modules,...this.uiModules].forEach(e=>e.onInit())}onFrame(){[...this.modules,...this.uiModules].forEach(e=>e.onFrame(this.data))}onScroll(){[...this.modules,...this.uiModules].forEach(e=>e.onScroll(this.data))}onResizeWidth(){[...this.modules,...this.uiModules].forEach(e=>e.onResizeWidth())}onResize(){[...this.modules,...this.uiModules].forEach(e=>e.onResize())}onMouseMove(e){[...this.modules,...this.uiModules].forEach(t=>t.onMouseMove(e))}onWheel(e){[...this.modules,...this.uiModules].forEach(t=>t.onWheel(e))}onDirectionChange(){[...this.modules,...this.uiModules].forEach(e=>e.onDirectionChange())}onScrollStart(){[...this.modules,...this.uiModules].forEach(e=>e.onScrollStart())}onScrollStop(){[...this.modules,...this.uiModules].forEach(e=>e.onScrollStop())}onAxisChange(){[...this.modules,...this.uiModules].forEach(e=>e.onAxisChange())}onDeviceChange(){[...this.modules,...this.uiModules].forEach(e=>e.onDeviceChange())}onScrollConfigChange(){[...this.modules,...this.uiModules].forEach(e=>e.onScrollConfigChange())}onSettingsChange(e){[...this.modules,...this.uiModules].forEach(t=>t.onSettingsChange())}onDOMMutate(e,t){[...this.modules,...this.uiModules].forEach(r=>r.onDOMMutate(e,t))}destroy(){[...this.modules,...this.uiModules].forEach(e=>e.destroy()),this.modules=[],this.uiModules=[]}get all(){return[...this.modules,...this.uiModules]}get core(){return this.modules}get ui(){return this.uiModules}};var R=class{constructor(e,t){this.id="";this.keys=[];this.connects=[];this.properties=new Map;this.modules=[];this.events=new D;this.htmlElement=t,this.id=e}setProperty(e,t){this.properties.set(e,t)}getProperty(e){return this.properties.get(e)??null}enter(){this.events.emit("enter",this),this.setProperty("active",!0),this.modules.forEach(e=>{e.enterObject(this.id,this)})}leave(){this.events.emit("leave",this),this.setProperty("active",!1),this.modules.forEach(e=>{e.exitObject(this.id)})}remove(){this.modules.forEach(e=>{e.removeObject(this.id)})}show(){this.htmlElement.classList.add("-inview")}hide(){this.getProperty("repeat")&&this.htmlElement.classList.remove("-inview")}connect(e){this.modules.includes(e)||this.modules.push(e)}};var rt=class{constructor(e,t,r){this.data=e;this.modules=t;this.events=r;this.objects=new Map;this.connectQueue=[];this.globalId=1}get all(){return this.objects}add(e){let t=`string-${this.globalId++}`,r="string-id";e.getAttribute("string-id")&&(t=e.getAttribute("string-id"),r="string-id"),e.getAttribute("data-string-id")&&(t=e.getAttribute("data-string-id"),r="data-string-id");let i=t&&this.objects.has(t)?this.objects.get(t):new R(t,e);e.setAttribute(r,i.id);let o=e.getAttribute("string")??e.getAttribute("data-string");o&&(i.keys=(o??"").split("|")),e.setAttribute("string-inited",""),this.objects.set(i.id,i);let s=this.getAllAttributes(e);this.modules.core.forEach(a=>{"setupCoreProperties"in a&&typeof a.setupCoreProperties=="function"&&a.setupCoreProperties(i,e,s)}),this.modules.core.forEach(a=>{a.canConnect(i)&&(a.initializeObject(this.globalId,i,e,s),a.calculatePositions(i,this.data.viewport.windowHeight),a.connectObject(i),a.addObject(i.id,i))}),this.connectQueue.filter(a=>a.id===i.id).forEach(a=>i.connects.push(a.element)),this.connectQueue=this.connectQueue.filter(a=>a.id!==i.id),this.initObservers(i,e),this.checkInviewForObject(i)}remove(e){let t=this.objects.get(e);t&&(t.events.clearAll(),t.getProperty("observer-progress")?.disconnect(),t.getProperty("observer-inview")?.disconnect(),t.htmlElement.removeAttribute("string-inited"),t.leave(),t.remove(),this.objects.delete(e))}enqueueConnection(e,t){this.connectQueue.push({id:e,element:t})}getAllAttributes(e){let t={};return Array.from(e.attributes).forEach(r=>{t[r.name]=r.value}),t}initObservers(e,t){let r=e.getProperty("offset-top")??0,i=e.getProperty("offset-bottom")??0;e.getProperty("observer-progress")?.disconnect();let o=n=>{n.forEach(a=>{this.events.emit(`object:activate:${e.id}`,a.isIntersecting),a.isIntersecting?e.enter():e.leave()})},s=new IntersectionObserver(o,{root:null,rootMargin:`${i+this.data.viewport.windowHeight}px 0px ${r+this.data.viewport.windowHeight}px 0px`,threshold:0});s.observe(t),e.setProperty("observer-progress",s)}observeDOM(){new MutationObserver(t=>{t.forEach(r=>{r.type==="childList"&&(r.removedNodes.forEach(i=>{if(i.nodeType!==Node.ELEMENT_NODE)return;let o=i;this.isFixed(o)||(o.hasAttribute("string")&&this.handleRemoved(o),o.querySelectorAll("[string],[data-string]").forEach(s=>{this.isFixed(s)||this.handleRemoved(s)}))}),r.addedNodes.forEach(i=>{if(i.nodeType!==Node.ELEMENT_NODE)return;let o=i;if(this.isFixed(o))return;o.hasAttribute("string")&&!o.hasAttribute("string-inited")&&this.add(o),o.querySelectorAll("[string]:not([string-inited]),[data-string]:not([string-inited])").forEach(n=>this.add(n));let s=o.getAttribute("string-copy-from")??o.getAttribute("data-string-copy-from");s&&(this.objects.has(s)?this.objects.get(s).connects.push(o):this.enqueueConnection(s,o))}),this.modules.all.forEach(i=>i.onDOMRebuild()))})}).observe(document.body,{childList:!0,subtree:!0})}handleRemoved(e){let t=e.getAttribute("string-id")??e.getAttribute("data-string-id");if(!t)return;let r=e.getAttribute("string-copy-from")??e.getAttribute("data-string-copy-from");r&&(this.connectQueue=this.connectQueue.filter(i=>i.id!==r)),this.remove(t)}onSettingsChange(e){this.objects.forEach(t=>{this.modules.core.forEach(r=>{let i=!1;if(e.isDesktop?(r.permissions.desktop.rebuild.scrollHeight&&e.scrollHeightChanged&&(i=!0),r.permissions.desktop.rebuild.width&&e.widthChanged&&(i=!0),r.permissions.desktop.rebuild.height&&e.heightChanged&&(i=!0)):(r.permissions.mobile.rebuild.scrollHeight&&e.scrollHeightChanged&&(i=!0),r.permissions.mobile.rebuild.width&&e.widthChanged&&(i=!0),r.permissions.mobile.rebuild.height&&e.heightChanged&&(i=!0)),i&&r.canConnect(t)){let o=this.getAllAttributes(t.htmlElement);r.initializeObject(this.globalId,t,t.htmlElement,o),r.calculatePositions(t,this.data.viewport.windowHeight),r.connectObject(t)}})})}isFixed(e){return e.hasAttribute("string-fixed")}checkInview(){this.objects.forEach(e=>{this.checkInviewForObject(e)})}checkInviewForObject(e){let t=this.data.scroll.transformedCurrent,r=e.getProperty("inview-start-position"),i=e.getProperty("inview-end-position"),o=e.getProperty("is-inview")??!1,s=t>=r&&t<=i,n=null;!o&&s?n=t<r?"enter-bottom":"enter-top":o&&!s&&(n=t<r?"exit-top":"exit-bottom"),s!==o&&(e.setProperty("is-inview",s),this.events.emit(`object:inview:${e.id}`,{inView:s,direction:n}),s?e.show():e.hide())}};var L=class{constructor(e){this.name="";this.isProg=!1;this.isParallaxEnabled=!1;this._scrollDirection="vertical";this.isBottomScrollDirection=null;this.isLastBottomScrollDirection=!0;this.scrollTriggerRules=[];this.onChangeDirection=()=>{};this.onScrollStart=()=>{};this.onScrollStop=()=>{};this.onCalcUpdate=()=>{this.context.data.scroll.scrollContainer?.scrollTo(0,this.context.data.scroll.current),this.triggerScrollRules()};this.document=document,this.context=e}set scrollDirection(e){this._scrollDirection=e,this._scrollDirection==="vertical"?this.onCalcUpdate=()=>{this.context.data.scroll.scrollContainer?.scrollTo(0,this.context.data.scroll.current),this.triggerScrollRules()}:this._scrollDirection==="horizontal"&&(this.onCalcUpdate=()=>{this.context.data.scroll.scrollContainer?.scrollTo(this.context.data.scroll.current,0)})}onFrame(){}onWheel(e){}onScroll(e){}disableScrollEvents(){}enableScrollEvents(){}triggerScrollRules(){this.scrollTriggerRules.forEach(e=>{(e.direction==="any"||this.isLastBottomScrollDirection&&e.direction==="forward")&&this.context.data.scroll.current>=e.offset?(e.onEnter?.(),e.toggleClass&&e.toggleClass.target.classList.add(e.toggleClass.className)):(e.onLeave?.(),e.toggleClass&&e.toggleClass.target.classList.remove(e.toggleClass.className))})}addScrollMark(e){this.scrollTriggerRules.push(e)}removeScrollMark(e){this.scrollTriggerRules=this.scrollTriggerRules.filter(t=>t.id!==e)}};var it=class extends L{constructor(t){super(t);this.name="default"}onFrame(){if(this.context.data.scroll.delta!==0){let t=this.context.data.scroll.delta*this.context.data.scroll.speedAccelerate;this.context.data.scroll.delta-=t,this.context.data.scroll.lerped=t,Math.abs(this.context.data.scroll.lerped)<.1&&(this.context.data.scroll.delta=0,this.context.data.scroll.lerped=0,this.onScrollStop())}}onScroll(t){let r=this.context.data.scroll.elementContainer.scrollTop;this.context.data.scroll.current=r,this.context.data.scroll.target=r,this.context.data.scroll.transformedCurrent=r}onWheel(t){if(t.deltaY!==0){this.context.data.scroll.delta===0&&this.onScrollStart();let r=t.deltaY;this.context.data.scroll.target===0&&(this.context.data.scroll.delta+=Math.max(0,t.deltaY)),this.context.data.scroll.delta+=r}}};var ot=class extends L{constructor(t){super(t);this.name="disable";this.preventScroll=t=>{t.preventDefault()};this.preventKeyScroll=t=>{["ArrowUp","ArrowDown","PageUp","PageDown"," ","Home","End"].includes(t.key)&&t.preventDefault()};this.onPreventScroll=this.preventScroll.bind(this);this.onPreventKeyScroll=this.preventKeyScroll.bind(this)}disableScrollEvents(){window.addEventListener("touchmove",this.onPreventScroll,{passive:!1}),window.addEventListener("keydown",this.onPreventKeyScroll)}enableScrollEvents(){window.removeEventListener("touchmove",this.onPreventScroll),window.removeEventListener("keydown",this.onPreventKeyScroll)}onFrame(){}onWheel(t){t.preventDefault()}onScroll(t){t.preventDefault()}};var I={SCROLL_FORWARD:"-scroll-forward",SCROLL_BACKWARD:"-scroll-backward",SCROLLING_FORWARD:"-scrolling-forward",SCROLLING_BACKWARD:"-scrolling-backward"};var st=class extends L{constructor(t){super(t);this.name="smooth";this.isScrollbarManipulation=!1;this.scrollForce=0;this.wheelImpulse=0;this.previousCurrent=0;this.velocityThreshold=.1}updateScrollDirection(t){if(this.isLastBottomScrollDirection=t,this.isBottomScrollDirection===null){this.isBottomScrollDirection=t;return}this.context.data.scroll.isScrollingDown=t,this.onChangeDirection(),document.documentElement.classList.toggle(I.SCROLLING_FORWARD,t),document.documentElement.classList.toggle(I.SCROLLING_BACKWARD,!t),document.documentElement.classList.toggle(I.SCROLL_FORWARD,t),document.documentElement.classList.toggle(I.SCROLL_BACKWARD,!t)}stopScroll(){this.context.data.scroll.lerped=0,this.context.data.scroll.delta=0,this.context.data.scroll.target=this.context.data.scroll.current,this.isProg=!1,this.onCalcUpdate(),document.documentElement.classList.remove(I.SCROLLING_BACKWARD,I.SCROLLING_FORWARD),this.isBottomScrollDirection=null}onFrame(){if(this.isScrollbarManipulation){this.isScrollbarManipulation=!1,this.context.data.scroll.current=this.context.data.scroll.elementContainer.scrollTop,this.context.data.scroll.target=this.context.data.scroll.elementContainer.scrollTop,this.context.data.scroll.transformedCurrent=this.context.data.scroll.current*this.context.data.viewport.transformScale;return}if(this.context.data.scroll.delta!==0){this.scrollForce=this.context.data.scroll.delta*this.context.data.scroll.speedAccelerate,this.context.data.scroll.target=Math.min(Math.max(0,this.context.data.scroll.target+this.scrollForce),this.context.data.scroll.bottomPosition),this.context.data.scroll.delta-=this.scrollForce,this.context.data.scroll.lerped=(this.context.data.scroll.target-this.context.data.scroll.current)*this.context.data.scroll.speed;let t=Math.abs(this.context.data.scroll.lerped);this.context.data.scroll.lerped>0?this.context.data.scroll.current=Math.ceil(this.context.data.scroll.current+this.context.data.scroll.lerped):this.context.data.scroll.current=Math.floor(this.context.data.scroll.current+this.context.data.scroll.lerped),this.context.data.scroll.transformedCurrent=this.context.data.scroll.current*this.context.data.viewport.transformScale,this.updateScrollDirection(this.context.data.scroll.lerped>0),t<this.velocityThreshold?(this.stopScroll(),this.onScrollStop()):(this.isProg=!0,this.previousCurrent!==this.context.data.scroll.current&&(this.previousCurrent=this.context.data.scroll.current,this.onCalcUpdate()))}}onWheel(t){if(t.deltaY!==0&&t.preventDefault(),this.wheelImpulse=t.deltaY,this.wheelImpulse===0)return;this.context.data.scroll.delta===0&&this.onScrollStart();let r=Math.sign(this.wheelImpulse),i=this.context.data.scroll.target===0&&r<0,o=this.context.data.scroll.target===this.context.data.scroll.bottomPosition&&r>0;i||o||(this.context.data.scroll.delta+=this.wheelImpulse)}onScroll(t){this.isProg||(this.isScrollbarManipulation=!0)}};var nt=class{constructor(e){this.context=e;this.modes=new Map;this.modes.set("smooth",new st(e)),this.modes.set("default",new it(e)),this.modes.set("disable",new ot(e)),this.updateResponsiveMode()}setMobileMode(e){this.context.data.scroll.modeMobile=e,this.updateResponsiveMode()}setDesktopMode(e){this.context.data.scroll.modeDesktop=e,this.updateResponsiveMode()}updateResponsiveMode(){let t=window.innerWidth<1080?this.context.data.scroll.modeMobile:this.context.data.scroll.modeDesktop;this.setMode(t)}updatePosition(){this.modes.forEach(e=>{e.onCalcUpdate()})}setMode(e){if(!this.modes.has(e)){console.warn(`[ScrollManager] Unknown scroll mode: ${e}`);return}this.get().enableScrollEvents(),this.context.data.scroll.mode=e,this.get().disableScrollEvents()}get(){return this.modes.get(this.context.data.scroll.mode)}getEngines(){return this.modes}onFrame(){this.get().onFrame()}onScroll(e){this.get().onScroll(e)}onWheel(e){this.get().onWheel(e)}bindEvents(e){this.modes.forEach(t=>{t.onScrollStart=e.onScrollStart,t.onScrollStop=e.onScrollStop,t.onChangeDirection=e.onDirectionChange})}addScrollMark(e){this.modes.forEach(t=>{t.addScrollMark(e)})}removeScrollMark(e){this.modes.forEach(t=>{t.removeScrollMark(e)})}};var at=class{constructor(){this.targetX=0;this.targetY=0;this.smoothedX=0;this.smoothedY=0;this.stepX=0;this.stepY=0}};var lt=class{constructor(){this.threeInstance=null}};var ct=class{constructor(){this.target=0;this.current=0;this.transformedCurrent=0;this.delta=0;this.lerped=0;this.displacement=0;this.isScrollingDown=!1;this.topPosition=0;this.bottomPosition=0;this.direction="vertical";this.elementContainer=document.documentElement;this.scrollContainer=window;this.container=document.body;this.mode="smooth";this.modeMobile="smooth";this.modeDesktop="smooth";this.speed=.1;this.speedAccelerate=.25}};var pt=class{constructor(){this.now=0;this.previous=0;this.delta=0;this.elapsed=0}};var dt=class{constructor(){this.windowWidth=0;this.windowHeight=0;this.contentWidth=0;this.contentHeight=0;this.scaleWidth=1;this.scaleHeight=1;this.transformScale=1;this.baseRem=16}};var N=class{constructor(){this.scroll=new ct;this.viewport=new dt;this.cursor=new at;this.render=new lt;this.time=new pt}};var ut=class{constructor(){this.desktop={rebuild:{width:!0,height:!0,scrollHeight:!0}};this.mobile={rebuild:{width:!0,height:!0,scrollHeight:!0}}}};var g=class{constructor(e){this.objectMapOnPage=new Map;this.objectsOnPage=[];this.objectMap=new Map;this.objects=[];this.htmlKey="";this._type=1;this.permissions=new ut;this.tools=e.tools,this.data=e.data,this.settings=e.settings,this.events=e.events,this.attributesToMap=[{key:"active",type:"boolean",fallback:this.settings.active},{key:"fixed",type:"boolean",fallback:this.settings.fixed},{key:"repeat",type:"boolean",fallback:this.settings.repeat},{key:"self-disable",type:"boolean",fallback:this.settings["self-disable"]},{key:"abs",type:"boolean",fallback:this.settings.abs},{key:"key",type:"string",fallback:this.settings.key},{key:"offset-top",type:"dimension",fallback:this.settings["offset-top"]},{key:"offset-bottom",type:"dimension",fallback:this.settings["offset-bottom"]},{key:"inview-top",type:"dimension",fallback:this.settings["inview-top"]},{key:"inview-bottom",type:"dimension",fallback:this.settings["inview-bottom"]},{key:"start",type:"number",fallback:(t,r,i)=>{let o=i.top;return Math.floor(o)+this.data.scroll.container.scrollTop*this.data.viewport.transformScale}},{key:"end",type:"number",fallback:(t,r,i)=>{let o=i.top,s=i.height;return o+s-this.data.scroll.transformedCurrent}},{key:"size",type:"number",fallback:(t,r,i)=>i.height},{key:"half-width",type:"number",fallback:(t,r,i)=>i.width/2},{key:"half-height",type:"number",fallback:(t,r,i)=>i.height/2},{key:"enter-el",type:"string",fallback:this.settings["enter-el"]},{key:"enter-vp",type:"string",fallback:this.settings["enter-vp"]},{key:"exit-el",type:"string",fallback:this.settings["exit-el"]},{key:"exit-vp",type:"string",fallback:this.settings["exit-vp"]}]}get type(){return this._type}initializeObject(e,t,r,i){let o=this.tools.boundingClientRect.process({element:r});for(let{key:s,type:n,fallback:a,transform:l}of this.attributesToMap){let u=typeof a=="function"?a(r,t,o):a,d=this.tools.domAttribute.process({element:r,key:s,fallback:i[s]??this.settings[s]??u}),p=this.parseAttribute(d,n,{element:r,boundingRect:o,viewportHeight:this.data.viewport.windowHeight,baseRem:this.data.viewport.baseRem});l&&(p=l(p)),t.setProperty(s,p)}}calculatePositions(e,t){let r=e.getProperty("start"),i=e.getProperty("size"),o=e.getProperty("offset-bottom"),s=e.getProperty("offset-top"),n=e.getProperty("enter-el"),a=e.getProperty("enter-vp"),l=e.getProperty("exit-el"),u=e.getProperty("exit-vp"),d=0,p=0,h=0,f=0;n==="top"&&a==="top"||n==="left"&&a==="left"?(h=-t+1,d=r-o):n==="top"&&a==="bottom"||n==="left"&&a==="right"?d=r-t-o:n==="bottom"&&a==="top"||n==="right"&&a==="left"?(h=-t-i+1,d=r+i-o):(n==="bottom"&&a==="bottom"||n==="right"&&a==="right")&&(h=-i+1,d=r-t+i-o),l==="top"&&u==="top"||l==="left"&&u==="left"?(f=-i+1,p=r+s):l==="top"&&u==="bottom"||l==="left"&&u==="right"?(f=-t-i+1,p=r-t+s):l==="bottom"&&u==="top"||l==="right"&&u==="left"?p=r+i+s:(l==="bottom"&&u==="bottom"||l==="right"&&u==="right")&&(f=-t+1,p=r-t+i+s),e.setProperty("start-bias",h),e.setProperty("end-bias",f),e.setProperty("start-position",d-this.data.scroll.topPosition),e.setProperty("end-position",p-this.data.scroll.topPosition),e.setProperty("difference-position",p-d);let m=e.getProperty("inview-top")??0,b=e.getProperty("inview-bottom")??0;e.setProperty("inview-start-position",e.getProperty("start-position")+m),e.setProperty("inview-end-position",e.getProperty("end-position")+b)}parseAttribute(e,t,r={}){if(e==null)return null;if(typeof t=="object"&&t.type==="enum")return t.values.includes(e)?e:t.values[0];switch(t){case"number":return parseFloat(e);case"boolean":return e===""||e==="true";case"json":try{return JSON.parse(e)}catch{return null}case"tuple":return e.trim().split(/\s+/);case"easing":return this.tools.easingFunction.process({easing:e});case"color":return this.tools.colorParser.process({value:e});case"dimension":return e=="0"?0:r.element!=null&&r.viewportHeight!=null&&r.baseRem!=null&&r.boundingRect!=null?this.tools.unitParser.process({value:e,element:r.element,viewportHeight:r.viewportHeight,boundingRect:r.boundingRect,baseRem:r.baseRem}):0;default:return e}}canConnect(e){return e.keys.includes(this.htmlKey)}connectObject(e){e.connect(this),this.onObjectConnected(e)}enterObject(e,t){this.objectMap.has(e)||(this.objectMap.set(e,t),this.objects.push(t))}exitObject(e){let t=this.objectMap.get(e);if(!t)return;this.objectMap.delete(e);let r=this.objects.indexOf(t);r!==-1&&this.objects.splice(r,1)}addObject(e,t){this.objectMapOnPage.has(e)||(this.objectMapOnPage.set(e,t),this.objectsOnPage.push(t))}removeObject(e){let t=this.objectMapOnPage.get(e);if(!t)return;this.objectMapOnPage.delete(e);let r=this.objectsOnPage.indexOf(t);r!==-1&&this.objectsOnPage.splice(r,1)}onObjectConnected(e){}applyToElementAndConnects(e,t){e.getProperty("self-disable")==!1&&t(e.htmlElement),e.connects.forEach(t)}destroy(){this.objects=[],this.objectMap=new Map}onInit(){}onFrame(e){}onResize(){}onResizeWidth(){}onScroll(e){}onDirectionChange(){}onScrollStart(){}onScrollStop(){}onScrollDirectionChange(){}onAxisChange(){}onDeviceChange(){}onScrollConfigChange(){}onSettingsChange(){}onDOMRebuild(){}onMouseMove(e){}onWheel(e){}onDOMMutate(e,t){}};var W=class{process({element:e}){return e.getBoundingClientRect()}};var B=class{process({element:e,key:t,fallback:r=null}){return e.getAttribute(`string-${t}`)??e.getAttribute(`data-string-${t}`)??r}};var V=class{process({record:e,name:t,fallback:r=null}){return e[t]??e[`data-${t}`]??r}};var O=class{process({element:e}){let t=e.getBoundingClientRect(),i=getComputedStyle(e).transform.match(/-?[\d.]+/g)?.map(parseFloat)??[];if(i.length===6){let[o,s,n,a,l,u]=i,d=o*a-s*n;return{width:t.width/(o||1),height:t.height/(a||1),left:(t.left*a-t.top*n+n*u-l*a)/d,top:(-t.left*s+t.top*o+l*s-o*u)/d}}return t}};var $=class{constructor(e=new O){this.transformTool=e}process({element:e,container:t=document.body}){let r;try{r=t.getBoundingClientRect()}catch{r=document.body.getBoundingClientRect()}let i=this.transformTool.process({element:e});return{top:i.top-r.top,left:i.left-r.left}}};var z=class{process({from:e,to:t,progress:r}){return(t-e)*r}};var q=class{process({value:e,element:t,viewportHeight:r,baseRem:i,boundingRect:o}){let s=e.split("|").map(a=>a.trim()).filter(Boolean),n=0;for(let a of s){let l=a,u=!1;l.startsWith("-")&&(u=!0,l=l.slice(1));let d=0;if(l==="selfHeight")d=t.offsetHeight;else if(l.endsWith("px"))d=parseFloat(l);else if(l.endsWith("%"))d=parseFloat(l)/100*r;else if(l.endsWith("rem"))d=parseFloat(l)*i;else if(l.endsWith("sh"))d=parseFloat(l)*o.height/100;else continue;n+=u?-d:d}return n}};var _=class{process({value:e,inMin:t=.1,inMax:r=1,outMin:i=.05,outMax:o=.65}){if(e<t)return o;if(e>1&&(e=1),e<=r){let s=(e-t)/(r-t);return o-s*(o-i)}return i}};var Y=class{process({value:e}){let t=e.trim();if(t.startsWith("random(")&&t.endsWith(")")){let r=t.slice(7,-1).split(",").map(o=>o.trim()).filter(Boolean),i=Math.floor(Math.random()*r.length);return r[i]}return t}};var X=class{process({value:e}){let t=e.trim().toLowerCase();if(t.startsWith("#")){let o=t.slice(1);o.length===3&&(o=o.split("").map(u=>u+u).join(""));let s=parseInt(o.slice(0,2),16),n=parseInt(o.slice(2,4),16),a=parseInt(o.slice(4,6),16),l=o.length===8?parseInt(o.slice(6,8),16)/255:1;return{r:s,g:n,b:a,a:l}}let r=t.match(/rgba?\(([^)]+)\)/);if(r){let[o,s,n,a=1]=r[1].split(",").map(l=>parseFloat(l.trim()));return{r:o,g:s,b:n,a}}let i=t.match(/hsla?\(([^)]+)\)/);if(i){let[o,s,n,a="1"]=i[1].split(",").map(p=>p.trim()),[l,u,d]=this.hslToRgb(parseFloat(o),parseFloat(s),parseFloat(n));return{r:l,g:u,b:d,a:parseFloat(a)}}return{r:0,g:0,b:0,a:0}}hslToRgb(e,t,r){e=e/360,t=parseFloat(t.toString())/100,r=parseFloat(r.toString())/100;let i=(u,d,p)=>(p<0&&(p+=1),p>1&&(p-=1),p<1/6?u+(d-u)*6*p:p<1/2?d:p<2/3?u+(d-u)*(2/3-p)*6:u),o=r<.5?r*(1+t):r+t-r*t,s=2*r-o,n=Math.round(i(s,o,e+1/3)*255),a=Math.round(i(s,o,e)*255),l=Math.round(i(s,o,e-1/3)*255);return[n,a,l]}};var U=class{constructor(){this.namedCurves={linear:[0,0,1,1],ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]}}process({easing:e}){let t=e.trim();if(this.namedCurves[t])return this.cubicBezier(...this.namedCurves[t]);let r=t.match(/^cubic-bezier\s*\(\s*([-+]?\d*\.?\d+)\s*,\s*([-+]?\d*\.?\d+)\s*,\s*([-+]?\d*\.?\d+)\s*,\s*([-+]?\d*\.?\d+)\s*\)$/);if(r){let[i,o,s,n]=r.slice(1).map(Number);return this.cubicBezier(i,o,s,n)}return i=>i}cubicBezier(e,t,r,i){let o=3*e,s=3*(r-e)-o,n=1-o-s,a=3*t,l=3*(i-t)-a,u=1-a-l;function d(m){return((n*m+s)*m+o)*m}function p(m){return((u*m+l)*m+a)*m}function h(m){return(3*n*m+2*s)*m+o}function f(m,b=1e-5){let y,M,v=m,x,S,E;for(E=0;E<8;E++){if(x=d(v)-m,Math.abs(x)<b)return v;if(S=h(v),Math.abs(S)<1e-6)break;v=v-x/S}for(y=0,M=1,v=m;y<M;){if(x=d(v)-m,Math.abs(x)<b)return v;x>0?M=v:y=v,v=(M+y)/2}return v}return function(m){return p(f(m))}}};var K=class{process({distance:e,radius:t,strength:r}){if(e>=t)return 0;let i=(t-e)/t;return r*i}};var j=class{process({from:e,to:t,progress:r}){return{r:e.r+(t.r-e.r)*r,g:e.g+(t.g-e.g)*r,b:e.b+(t.b-e.b)*r,a:e.a+(t.a-e.a)*r}}};var Q=class{process({from:e,to:t,progress:r}){return{x:(t.x-e.x)*r,y:(t.y-e.y)*r}}};var G=class{process({value:e}){let r=e?.trim();if(!r||r==="none")return 1;try{if(r.startsWith("matrix(")){let i=r.match(/matrix\(([^)]+)\)/);if(i&&i[1]){let o=i[1].split(",").map(s=>parseFloat(s.trim()));if(o.length>=1&&!isNaN(o[0]))return o[0]}}if(r.startsWith("scale(")){let i=r.match(/scale\(([^)]+)\)/);if(i&&i[1]){let o=i[1].split(",").map(s=>parseFloat(s.trim()));if(o.length>=1&&!isNaN(o[0]))return o[0]}}if(r.startsWith("scaleX(")){let i=r.match(/scaleX\(([^)]+)\)/);if(i&&i[1]){let o=parseFloat(i[1].trim());if(!isNaN(o))return o}}if(r.startsWith("scale3d(")){let i=r.match(/scale3d\(([^)]+)\)/);if(i&&i[1]){let o=i[1].split(",").map(s=>parseFloat(s.trim()));if(o.length>=1&&!isNaN(o[0]))return o[0]}}if(r.startsWith("matrix3d(")){let i=r.match(/matrix3d\(([^)]+)\)/);if(i&&i[1]){let o=i[1].split(",").map(s=>parseFloat(s.trim()));if(o.length>=1&&!isNaN(o[0]))return o[0]}}}catch(i){return console.error(`Error parsing transform string "${r}":`,i),1}return 1}};var mt=class{process({attributeValue:e}){let t={line:[],word:[],char:[],charLine:[],charWord:[],wordLine:[]};return e&&e.split("|").forEach(i=>{let o=i.trim();if(!o)return;let s=o.match(/^(\w+-)?(\w+)(\[(.*?)\])?$/);if(s){let n=s[1]||"",a=s[2],l=n+a,d=(s[4]||"").split(";").map(h=>h.trim()).filter(h=>h.length>0),p=this.parseParamsArray(d);switch(l){case"line":t.line.push(p);break;case"word":t.word.push(p);break;case"char":t.char.push(p);break;case"charLine":t.charLine.push(p);break;case"charWord":t.charWord.push(p);break;case"wordLine":t.wordLine.push(p);break;default:console.warn(`SplitOptionsParserTool: Unrecognized option type "${l}" in part "${o}"`);break}}else console.warn(`SplitOptionsParserTool: Could not parse part format "${o}"`)}),t}parseParamsArray(e){let t={align:"start"};return e.forEach(r=>{if(r==="abs")t.abs=!0;else if(r.startsWith("random")){t.align="random";let i=r.match(/random\(\s*(\d+)\s*,\s*(\d+)\s*\)/);i&&(t.random={min:parseInt(i[1],10),max:parseInt(i[2],10)})}else["start","center","end"].includes(r)&&(t.align=r)}),t}};var Z=class{process({value:e}){let t=[],r="",i=0;for(let o=0;o<e.length;o++){let s=e[o];s==="("&&i++,s===")"&&i--,s==="|"&&i===0?(r.trim()&&t.push(r.trim()),r=""):r+=s}return r.trim()&&t.push(r.trim()),t.map(o=>{let s=o.match(/^(\w+)(?:\((.*)\))?$/);if(!s)return{key:o};let[,n,a]=s;return a?{key:n,params:a.split(",").map(l=>l.trim())}:{key:n}})}};var ht=class{constructor(){this.inputValidators={required:e=>e!=null&&String(e).trim()!=="",min:(e,t)=>typeof e=="string"&&e.length>=Number(t),checked:e=>e===!0||e==="true"||e===1||e==="1",email:e=>typeof e=="string"&&/^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e),max:(e,t)=>typeof e=="string"&&e.length<=Number(t),phone:e=>typeof e=="string"&&/^(\+?\d{1,3}[-.\s]?)?(\(?\d{1,4}\)?[-.\s]?)?[\d\-.\s]{5,15}$/.test(e),number:e=>typeof e=="string"&&/^-?\d+(\.\d+)?$/.test(e),url:e=>typeof e=="string"&&/^(https?:\/\/)?([\w\-]+\.)+[\w\-]+(\/[\w\-._~:/?#[\]@!$&'()*+,;=]*)?$/.test(e)};this.beforeInputValidators={number:e=>/^-?\d*\.?\d*$/.test(e),integer:e=>/^-?\d*$/.test(e),email:e=>/^[\w@.\-+]*$/.test(e),phone:e=>/^(\+)?[\d\-() ]*$/.test(e)&&(e.match(/\+/g)?.length??0)<=1&&(!e.includes("+")||e.indexOf("+")===0),letters:e=>/^[a-zA-Z]*$/.test(e),lettersSpaces:e=>/^[a-zA-Z\s]*$/.test(e),lettersNumbers:e=>/^[a-zA-Z0-9]*$/.test(e),url:e=>/^[a-zA-Z0-9\-._~:/?#\[\]@!$&'()*+,;=%]*$/.test(e),pattern:(e,t)=>{try{return new RegExp(t||"").test(e)}catch{return!0}}}}process({rules:e,value:t,type:r="input"}){let i=[];for(let l of e){var o=null,s=null,n=!0,a=!0;r=="input"&&(s=this.inputValidators[l.key],!s)||r=="beforeinput"&&(o=this.beforeInputValidators[l.key],!o)||(s&&(n=s(t,...l.params||[])),o&&(a=o(t,...l.params||[])),a||i.push(this.getErrorMessage(l.key,l.params)),n||i.push(this.getErrorMessage(l.key,l.params)))}return{valid:i.length===0,errors:i}}getErrorMessage(e,t){switch(e){case"required":return"This field is required";case"email":return"Invalid email address";case"min":return`Minimum ${t?.[0]} characters`;case"max":return`Maximum ${t?.[0]} characters`;case"phone":return"Invalid phone number";case"number":return"Only numbers are allowed";case"url":return"Invalid URL address";case"checked":return"You must accept";default:return"Invalid value"}}};var gt=class{constructor(){this.domAttribute=new B;this.recordAttribute=new V;this.transformNullify=new O;this.boundingClientRect=new W;this.relativePosition=new $(this.transformNullify);this.unitParser=new q;this.lerp=new z;this.adaptiveLerp=new _;this.originParser=new Y;this.colorParser=new X;this.validation=new ht;this.easingFunction=new U;this.magneticPull=new K;this.lerpColor=new j;this.lerpVector=new Q;this.transformScaleParser=new G;this.optionsParser=new mt;this.ruleParser=new Z}};var ft=class extends g{constructor(t){super(t);this.enterObjectsMap=new Map;this.enterObjects=new Array;this.overCount=0;this.htmlKey="cursor",this.permissions.mobile.rebuild.height=!1,this.permissions.mobile.rebuild.width=!1,this.permissions.mobile.rebuild.scrollHeight=!1,this.cursor=document.querySelector("[string-cursor],[data-string-cursor]"),this.cursorContent=document.querySelector("[string-cursor-content],[data-string-cursor-content]"),this.attributesToMap=[...this.attributesToMap,{key:"target-disable",type:"boolean",fallback:this.settings["target-disable"]},{key:"target-style-disable",type:"boolean",fallback:this.settings["target-style-disable"]},{key:"target-class",type:"string",fallback:this.settings["target-class"]},{key:"cursor-class",type:"string",fallback:this.settings["cursor-class"]},{key:"alignment",type:{type:"enum",values:["start","center","end"]},fallback:this.settings.alignment},{key:"lerp",type:"number",fallback:this.settings.lerp,transform:r=>this.tools.adaptiveLerp.process({value:r,inMin:.1,inMax:1,outMin:.05,outMax:.65})}]}initializeObject(t,r,i,o){super.initializeObject(t,r,i,o),r.setProperty("mouse-x",0),r.setProperty("mouse-y",0),r.setProperty("mouse-pixel-x",0),r.setProperty("mouse-pixel-y",0),r.setProperty("is-mouse-over",!1),r.setProperty("is-mouse-move",!1)}onFrame(t){requestAnimationFrame(()=>{this.objects.forEach(n=>{let a=n.getProperty("is-mouse-over"),l=n.getProperty("cursor-target-disable"),u=n.getProperty("lerp")??.15;if(a&&!l){let d=n.htmlElement.getBoundingClientRect(),p=this.data.cursor.targetX,h=this.data.cursor.targetY,f=p-d.left,m=h-d.top,b=n.getProperty("mouse-pixel-x")??0,y=n.getProperty("mouse-pixel-y")??0,M=b-f,v=y-m;if(M*M+v*v>1e-4){(n.getProperty("is-mouse-move")??!1)||(n.setProperty("is-mouse-move",!0),n.setProperty("mouse-pixel-x",f),n.setProperty("mouse-pixel-y",m),n.setProperty("mouse-x",f),n.setProperty("mouse-y",m),b=f,y=m,this.events.emit(`cursor:start:${n.id}`,null));let E=this.tools.lerp.process({from:b,to:f,progress:u}),T=this.tools.lerp.process({from:y,to:m,progress:u}),C=b+E,P=y+T;n.setProperty("mouse-pixel-x",C),n.setProperty("mouse-pixel-y",P);let F=n.getProperty("alignment")??"center",Wt=this.calculateOffset(F,C,d.width),Bt=this.calculateOffset(F,P,d.height);n.setProperty("mouse-x",Wt),n.setProperty("mouse-y",Bt),this.setMouseCoordinates(n,Wt,Bt),this.events.emit(`cursor:move:${n.id}`,{x:Wt,y:Bt}),this.events.emit(`cursor:pixel:${n.id}`,{x:C,y:P})}else n.setProperty("mouse-pixel-x",f),n.setProperty("mouse-pixel-y",m),this.events.emit(`cursor:end:${n.id}`,null)}else{let d=n.getProperty("mouse-x")??0,p=n.getProperty("mouse-y")??0;if(d!==0||p!==0){n.setProperty("is-mouse-move",!1);let h=n.htmlElement.getBoundingClientRect(),f=n.getProperty("half-width")??h.width/2,m=n.getProperty("half-height")??h.height/2,b=this.calculateOffset("center",f,h.width),y=this.calculateOffset("center",m,h.height),M=d+this.tools.lerp.process({from:d,to:b,progress:u}),v=p+this.tools.lerp.process({from:p,to:y,progress:u});n.setProperty("mouse-x",M),n.setProperty("mouse-y",v),Math.abs(M)<.001&&Math.abs(v)<.001&&(n.setProperty("mouse-x",0),n.setProperty("mouse-y",0),n.setProperty("mouse-pixel-x",0),n.setProperty("mouse-pixel-y",0)),this.setMouseCoordinates(n,M,v)}}});let{stepX:r,stepY:i,smoothedX:o,smoothedY:s}=this.data.cursor;(r!==0||i!==0)&&(this.events.emit("cursor",{stepX:r,stepY:i,x:o,y:s}),this.cursor.style.setProperty("--x",o.toString()),this.cursor.style.setProperty("--y",s.toString()),this.cursor.style.setProperty("--x-lerp",r.toString()),this.cursor.style.setProperty("--y-lerp",i.toString()))})}onObjectConnected(t){let r=t.htmlElement;t.setProperty("timeoutId",null),t.setProperty("mouseleave",()=>{this.onMouseLeave(t)}),t.setProperty("mouseenter",()=>{this.onMouseEnter(t)}),t.setProperty("onEnterEvent",this.onEnterObject.bind(this)),t.events.on("enter",t.getProperty("onEnterEvent")),t.setProperty("onLeaveEvent",this.onLeaveObject.bind(this)),t.events.on("leave",t.getProperty("onLeaveEvent"))}getCursorClass(t){let r=t.getProperty("cursor-class");return r!=null&&r.length>0?r:null}onMouseEnter(t){this.overCount++,t.setProperty("is-mouse-over",!0);let r=this.getCursorClass(t);r&&this.cursor.classList.add(r),this.cursor.classList.add("-showing"),t.setProperty("timeoutId",setTimeout(()=>{this.cursor.classList.remove("-showing"),this.cursor.classList.add("-show")},1200)),t.htmlElement.addEventListener("mouseleave",t.getProperty("mouseleave"))}onMouseLeave(t){this.overCount--,t.setProperty("is-mouse-over",!1),t.getProperty("timeoutId")&&(clearTimeout(t.getProperty("timeoutId")),t.setProperty("timeoutId",null));let r=this.getCursorClass(t);r&&this.cursor.classList.remove(r),this.cursor.classList.remove("-showing"),this.cursor.classList.remove("-show"),t.htmlElement.removeEventListener("mouseleave",t.getProperty("mouseleave"))}onEnterObject(t){t.htmlElement.addEventListener("mouseenter",t.getProperty("mouseenter"))}onLeaveObject(t){t.htmlElement.removeEventListener("mouseenter",t.getProperty("mouseenter")),t.htmlElement.removeEventListener("mouseleave",t.getProperty("mouseleave"))}setMouseCoordinates(t,r,i){t.getProperty("cursor-target-style-disable")||this.applyToElementAndConnects(t,o=>{o.style.setProperty("--x",r.toFixed(2)),o.style.setProperty("--y",i.toFixed(2))})}calculateOffset(t,r,i){switch(t){case"start":return r/i;case"end":return(r-i)/i;case"center":default:return(r-i/2)/(i/2)}}};var bt=class extends g{constructor(e){super(e),this.htmlKey="magnetic",this.permissions.mobile.rebuild.height=!1,this.permissions.mobile.rebuild.width=!1,this.permissions.mobile.rebuild.scrollHeight=!1,this.attributesToMap=[...this.attributesToMap,{key:"strength",type:"number",fallback:this.settings.strength},{key:"radius",type:"number",fallback:this.settings.radius}]}initializeObject(e,t,r,i){super.initializeObject(e,t,r,i),t.setProperty("is-magneting",!1),t.setProperty("magnetic-target-x",0),t.setProperty("magnetic-target-y",0),t.setProperty("magnetic-x",0),t.setProperty("magnetic-y",0),t.setProperty("lerp",.1)}onMouseMove(e){this.objects.forEach(t=>{let i=t.htmlElement.getBoundingClientRect(),o=i.left+(t.getProperty("half-width")??0),s=i.top+(t.getProperty("half-height")??0),n=e.clientX-o,a=e.clientY-s,l=Math.sqrt(n**2+a**2),u=t.getProperty("radius")??0,d=t.getProperty("strength")??0,p=this.tools.magneticPull.process({distance:l,radius:u,strength:d});t.setProperty("magnetic-target-x",n*p),t.setProperty("magnetic-target-y",a*p),p>0&&t.setProperty("is-magneting",!0)})}onFrame(e){this.objects.forEach(t=>{if(t.getProperty("is-magneting")){let r=t.getProperty("magnetic-x")??0,i=t.getProperty("magnetic-y")??0,o=t.getProperty("lerp")??0,s=t.getProperty("magnetic-target-x")??0,n=t.getProperty("magnetic-target-y")??0,a=this.tools.lerp.process({from:r,to:s,progress:o}),l=this.tools.lerp.process({from:i,to:n,progress:o});a>-.01&&a<.01&&(a=0,t.setProperty("magnetic-x",t.getProperty("magnetic-target-x"))),l>-.01&&l<.01&&(l=0,t.setProperty("magnetic-y",t.getProperty("magnetic-target-y"))),r+=a,i+=l,t.setProperty("magnetic-x",r),t.setProperty("magnetic-y",i),this.events.emit(`magnetic:move:${t.id}`,{x:r,y:i}),this.applyToElementAndConnects(t,u=>{u.style.setProperty("--magnetic-x",r.toString()),u.style.setProperty("--magnetic-y",i.toString())}),(t.getProperty("magnetic-target-x")==r||t.getProperty("magnetic-target-y")==i)&&t.setProperty("is-magneting",!1)}})}};var vt=class extends g{constructor(t){super(t);this.isStartLoaded=!1;this.loadingCount=0;this.htmlKey="lazy"}onInit(){document.querySelectorAll("img[string-lazy], img[data-string-lazy]").forEach(r=>this.loadImage(r)),this.isStartLoaded=!0}onObjectConnected(t){if(this.isStartLoaded){let r=t.htmlElement;this.loadImage(r)}}loadImage(t){if(t.dataset.lazyStatus==="loading"||t.dataset.lazyStatus==="loaded")return;let r=this.tools.domAttribute.process({element:t,key:this.htmlKey,fallback:""});if(!r)return;t.dataset.lazyStatus="loading",t.classList.add("lazyLoad"),this.loadingCount++;let i=new Image;i.onload=()=>{t.style.aspectRatio=`${i.width} / ${i.height}`,t.src=r,t.classList.add("-loaded"),t.dataset.lazyStatus="loaded",this.handleLoadingCompletion()},i.onerror=()=>{console.warn("Failed to load image:",r),t.dataset.lazyStatus="error",this.handleLoadingCompletion()},i.src=r}handleLoadingCompletion(){this.loadingCount--,this.loadingCount<=0&&(this.events.emit("image:load:all",null),this.loadingCount=0)}};var yt=class extends g{constructor(t){super(t);this.loadingTimeout=0;this._type=2,this.loadingTimeout=this.settings.timeout}onInit(){setTimeout(()=>{document.documentElement.classList.add("-loaded")},this.loadingTimeout)}};var St=class extends g{constructor(e){super(e),this.htmlKey=""}canConnect(e){return e.keys[0]==null}};var A=class{constructor(e){this.min=void 0;this.max=void 0;this.enable=!0;this.min=e?.min,this.max=e?.max,this.enable=e?.enable??!0}setEnable(e=!0){this.enable=e}setRange(e,t){this.min=e??void 0,this.max=t??void 0}get mediaQuery(){let e="screen";return this.min&&(e+=` and (min-width: ${this.min}px)`),this.max&&(e+=` and (max-width: ${this.max}px)`),e}},Mt=class extends g{constructor(t){super(t);this.queries={0:new A({max:359}),1:new A({min:360,max:1079}),2:new A({min:1080,max:1365}),3:new A({min:1366})};this.isMobileMedia=!1;this.isTabletMedia=!1;this.isLaptopMedia=!1;this.isDesktopMedia=!1;this.matchMedias={0:window.matchMedia(this.queries[0].mediaQuery),1:window.matchMedia(this.queries[1].mediaQuery),2:window.matchMedia(this.queries[2].mediaQuery),3:window.matchMedia(this.queries[3].mediaQuery)};this._type=2}onConnect(){}onInit(){if(this.settings!=null&&this.settings.settings!=null){let t=this.settings.settings;t.mobile?(this.queries[0].enable=!0,this.queries[0].setRange(t.mobile.min==null?null:t.mobile.min,t.mobile.max??null),this.matchMedias[0]=window.matchMedia(this.queries[0].mediaQuery)):this.queries[0].enable=!1,t.tablet?(this.queries[1].enable=!0,this.queries[1].setRange(t.tablet.min==null?null:t.tablet.min,t.tablet.max??null),this.matchMedias[1]=window.matchMedia(this.queries[1].mediaQuery)):this.queries[1].enable=!1,t.laptop?(this.queries[2].enable=!0,this.queries[2].setRange(t.laptop.min==null?null:t.laptop.min,t.laptop.max??null),this.matchMedias[2]=window.matchMedia(this.queries[2].mediaQuery)):this.queries[2].enable=!1,t.desktop?(this.queries[3].enable=!0,this.queries[3].setRange(t.desktop.min==null?null:t.desktop.min,t.desktop.max??null),this.matchMedias[3]=window.matchMedia(this.queries[3].mediaQuery)):this.queries[3].enable=!1}this.updateElements()}onResize(){this.updateElements()}updateElements(){let t=this.matchMedias[0].matches&&this.queries[0].enable,r=this.matchMedias[1].matches&&this.queries[1].enable,i=this.matchMedias[2].matches&&this.queries[2].enable,o=this.matchMedias[3].matches&&this.queries[3].enable;this.isMobileMedia!=t&&this.events.emit("screen:mobile",t),this.isTabletMedia!=r&&this.events.emit("screen:tablet",r),this.isLaptopMedia!=i&&this.events.emit("screen:laptop",i),this.isDesktopMedia!=o&&this.events.emit("screen:desktop",o),this.isMobileMedia=t,this.isTabletMedia=r,this.isLaptopMedia=i,this.isDesktopMedia=o,document.querySelectorAll("[string-mobile], [string-tablet], [string-laptop], [string-desktop]").forEach(n=>{let a=!1;n.hasAttribute("string-mobile")&&t&&(a=!0),n.hasAttribute("string-tablet")&&r&&(a=!0),n.hasAttribute("string-laptop")&&i&&(a=!0),n.hasAttribute("string-desktop")&&o&&(a=!0),a?n.style.display=null:n.style.display="none"})}};var xt=class extends g{constructor(e){super(e),this.htmlKey="anchor",this.attributesToMap=[...this.attributesToMap,{key:"anchor",type:"tuple",fallback:this.settings.anchor,transform:t=>{let[r,i]=t,o=this.tools.originParser.process({value:r}),s=this.tools.originParser.process({value:i});return{x:o,y:s}}}]}onObjectConnected(e){super.onObjectConnected(e);let t=e.getProperty("anchor");t&&this.applyToElementAndConnects(e,r=>{r.style.transformOrigin=`${t.x} ${t.y}`})}};var oe=.05,se=.01,_t=1,ne=-1,ae=1,Et=class extends g{constructor(t){super(t);this.previousLerp=0;this.displacement=0;this.acceleration=0;this.velocityMultiplier=.00125;this.isInitialScroll=!0;this.baseVelocityMultiplier=.00125;this.reducedVelocityMultiplier=this.baseVelocityMultiplier/20;this.negativeVelocityMultiplier=-1e-4;this.maxDisplacementValue=0;this.setupItem=t=>{let r=t.getProperty("glide")??0,i=-this.data.scroll.displacement*this.maxDisplacementValue*r;this.events.emit(`object:glide:${t.id}`,i);let o=`translate3d(0, ${i}px, 0)`;t.htmlElement.style.transform=o};this.onUpdateDesktopEvent=()=>{for(let t=0;t<this.objects.length;t++){let r=this.objects[t];this.setupItem(r)}};this.onUpdateMobileEvent=()=>{};this.onUpdateEvent=this.onUpdateDesktopEvent;this.htmlKey="glide",this.baseVelocityMultiplier=this.settings["glide-base-velocity"]??this.baseVelocityMultiplier,this.reducedVelocityMultiplier=this.settings["glide-reduce-velocity"]??this.reducedVelocityMultiplier,this.negativeVelocityMultiplier=this.settings["glide-negative-velocity"]??this.negativeVelocityMultiplier,this.attributesToMap=[...this.attributesToMap,{key:"glide",type:"number",fallback:this.settings.glide}]}calcExpanderFactor(t){let r=t?this.data.scroll.lerped<this.previousLerp:this.data.scroll.lerped>this.previousLerp;this.velocityMultiplier=r?this.isInitialScroll?this.baseVelocityMultiplier:this.reducedVelocityMultiplier:this.negativeVelocityMultiplier,r||(this.isInitialScroll=!1)}onStart(){this.maxDisplacementValue=this.data.viewport.windowHeight*.1}onResize(){window.innerWidth>1080?(this.maxDisplacementValue=this.data.viewport.windowHeight*.1,this.onUpdateEvent=this.onUpdateDesktopEvent):(this.onUpdateEvent=this.onUpdateMobileEvent,this.resetState(),this.objects.forEach(t=>{this.setupItem(t)}))}resetState(){this.displacement=0,this.acceleration=0,this.isInitialScroll=!0,this.velocityMultiplier=this.baseVelocityMultiplier}onScrollStart(){this.resetState()}onScrollStop(){this.resetState(),this.previousLerp=0;for(let t=0;t<this.objects.length;t++){let r=this.objects[t],i="translate3d(0, 0px, 0)";r.htmlElement.style.transform=i,r.htmlElement.style.setProperty("--glide",this.data.scroll.displacement.toString())}}onFrame(t){this.calcExpanderFactor(this.data.scroll.isScrollingDown===!1),this.acceleration=Math.min(_t,this.acceleration+oe),this.displacement=Math.max(se,Math.min(_t,this.displacement+this.velocityMultiplier)),this.data.scroll.displacement=Math.min(ae,Math.max(ne,this.data.scroll.lerped*this.displacement*this.acceleration)),this.objects.forEach(r=>{this.applyToElementAndConnects(r,i=>{i.style.setProperty("--glide",this.data.scroll.displacement.toString())})}),this.previousLerp=this.data.scroll.lerped,this.onUpdateEvent()}};var Ct=class extends g{constructor(e){super(e),this.htmlKey="lerp"}onScrollStop(){this.objects.forEach(e=>{this.setLerpValue(e,0)})}onFrame(e){let t=e.scroll.lerped;this.objects.forEach(r=>{this.setLerpValue(r,t)})}setLerpValue(e,t){this.events.emit(`object:lerp:${e.id}`,t),e.htmlElement.style.setProperty("--lerp",t.toString())}};var H=class extends g{constructor(e){super(e),this.htmlKey="progress",this.attributesToMap=[...this.attributesToMap,{key:"easing",type:"easing",fallback:this.settings.easing}]}initializeObject(e,t,r,i){super.initializeObject(e,t,r,i)}onScroll(e){super.onScroll(e),this.objects.forEach(t=>{this.setUpObject(t)})}onObjectConnected(e){super.onObjectConnected(e),e.setProperty("setUpObject",this.setUpObject.bind(this)),e.events.on("enter",e.getProperty("setUpObject"))}setUpObject(e){let t=e.getProperty("start-position"),r=e.getProperty("difference-position"),i=e.getProperty("key"),o=e.getProperty("easing")(Math.min(1,Math.max(0,(this.data.scroll.transformedCurrent-t)/r)));if(e.getProperty("progress")!==o){this.events.emit(`object:progress:${e.id}`,o),e.setProperty("progress",o);let s=o.toString();this.applyToElementAndConnects(e,n=>{n.style.setProperty(i,s)})}}};var Tt=class extends H{constructor(t){super(t);this.handleScrollDesktop=()=>{this.objects.forEach(t=>{let r=t.getProperty("progress")??0,i=t.getProperty("parallax")??0,o=t.getProperty("parallax-position-start")??0,s=t.getProperty("parallax-position-end")??1,n=t.getProperty("parallax-sign")??1,a=this.data.viewport.windowHeight,l=n*i*(a*o+r*a*s);this.events.emit(`object:parallax:${t.id}`,l);let u=`translate3d(0, ${l}px, 0)`;this.applyToElementAndConnects(t,d=>{d.style.transform=u})})};this.handleScrollMobile=()=>{};this.scrollHandler=this.handleScrollDesktop;this.htmlKey="parallax",this.attributesToMap=[...this.attributesToMap,{key:"parallax",type:"number",fallback:this.settings.parallax},{key:"parallax-bias",type:"number",fallback:this.settings["parallax-bias"]}]}initializeObject(t,r,i,o){super.initializeObject(t,r,i,o);let s=r.getProperty("parallax-bias")??0,n=Math.abs(r.getProperty("parallax")??.2);r.setProperty("parallax-sign",Math.sign(r.getProperty("parallax"))),r.setProperty("parallax",n),r.setProperty("parallax-position-start",-.5+.5*s),r.setProperty("parallax-position-end",.5+.5*(1-s));let a=this.data.viewport.windowHeight;r.setProperty("offset-top",n*a),r.setProperty("offset-bottom",n*a)}onScroll(t){super.onScroll(t),this.scrollHandler()}onResize(){let t=window.innerWidth>1080;this.scrollHandler=t?this.handleScrollDesktop:this.handleScrollMobile,this.objects.forEach(r=>{let i="translate3d(0, 0px, 0)";this.applyToElementAndConnects(r,o=>{o.style.transform=i})})}};var wt=class{constructor(e,t,r){this.isDragging=!1;this.startY=0;this.startScrollPosition=0;this.data=e,this.scrollbar=t,this.thumb=r}onResize(){let e=this.data.viewport.contentWidth,t=this.data.viewport.windowWidth,r=t/e*t;this.thumb.style.setProperty("--size",r+"px"),e<=t?this.scrollbar.classList.add("-