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 506 kB
var Se=class{context;SETTLE_THRESHOLD_SQ=.01;smoothingFactor;lastMouseX=0;lastMouseY=0;lastMouseTime=0;_lerpStepXArgs={from:0,to:0,progress:0};_lerpStepYArgs={from:0,to:0,progress:0};constructor(t=.1,e){this.smoothingFactor=t,this.context=e,this.onSettingsChange({isDesktop:e.data.viewport.windowWidth>1024,isForceRebuild:!1,widthChanged:!0,heightChanged:!0,scrollHeightChanged:!0})}onMouseMove(t){let e=this.context.data.cursor;e.targetX=t.clientX,e.targetY=t.clientY;let r=performance.now(),i=Math.max(1,r-this.lastMouseTime);e.velocityX=(t.clientX-this.lastMouseX)/i,e.velocityY=(t.clientY-this.lastMouseY)/i,this.lastMouseX=t.clientX,this.lastMouseY=t.clientY,this.lastMouseTime=r}onFrame(){let t=this.context.data.cursor,e=t.targetX,r=t.targetY,i=t.smoothedX,n=t.smoothedY;this._lerpStepXArgs.from=i,this._lerpStepXArgs.to=e,this._lerpStepXArgs.progress=this.smoothingFactor,this._lerpStepYArgs.from=n,this._lerpStepYArgs.to=r,this._lerpStepYArgs.progress=this.smoothingFactor;let s=this.context.tools.lerp.process(this._lerpStepXArgs),o=this.context.tools.lerp.process(this._lerpStepYArgs);s*s+o*o<this.SETTLE_THRESHOLD_SQ?(t.smoothedX=e,t.smoothedY=r,t.stepX=0,t.stepY=0):(t.smoothedX+=s,t.smoothedY+=o,t.stepX=s,t.stepY=o)}onSettingsChange(t){let e=Number(this.context.settings["cursor-lerp"]);this.setLerpFactor(e)}setLerpFactor(t){this.smoothingFactor=this.context.tools.adaptiveLerp.process({value:t,inMin:.1,inMax:1,outMin:.05,outMax:.65})}};var At=class{listeners={};stateEvents=new Set;lastPayloads={};constructor(){this.stateEvents.add("screen:mobile"),this.stateEvents.add("screen:tablet"),this.stateEvents.add("screen:laptop"),this.stateEvents.add("screen:desktop"),this.stateEvents.add("start")}registerStateEvent(t,e){this.stateEvents.add(t),e!==void 0&&(this.lastPayloads[t]=e)}on(t,e,r){let i=r?`${t}:${r}`:t;this.listeners[i]||(this.listeners[i]=new Set),this.listeners[i].add(e),this.stateEvents.has(i)&&this.lastPayloads[i]!==void 0&&e(this.lastPayloads[i])}off(t,e,r){let i=r?`${t}:${r}`:t;this.listeners[i]&&this.listeners[i].delete(e)}emit(t,e){this.stateEvents.has(t)&&(this.lastPayloads[t]=e);let r=this.listeners[t];if(r)for(let i of r)i(e)}onProgress(t,e){this.on(`progress:${t}`,e)}emitProgress(t,e){this.emit(`progress:${t}`,e)}onInview(t,e){this.on(`object:inview:${t}`,e)}emitInview(t,e){this.emit(`object:inview:${t}`,e)}onScroll(t){this.on("scroll",t)}emitScroll(t){this.emit("scroll",t)}onUpdate(t){this.on("update",t)}emitUpdate(){this.emit("update")}clear(t){delete this.listeners[t]}clearAll(){this.listeners={}}};var Le=class{constructor(t){this.data=t}modules=[];uiModules=[];allModules=[];register(t){if(t.type===1?this.modules.push(t):t.type===2&&this.uiModules.push(t),t.cssProperties&&t.cssProperties.length>0&&typeof window.CSS<"u"&&"registerProperty"in window.CSS)for(let e=0;e<t.cssProperties.length;e++)try{window.CSS.registerProperty(t.cssProperties[e])}catch{}t.onSubscribe(),this.rebuildAllModules()}find(t){for(let e=0;e<this.allModules.length;e++){let r=this.allModules[e];if(r instanceof t)return r}}onInit(){this.callAll("onInit")}onFrame(){this.callAll("onFrame")}onMutate(){this.callAll("onMutate")}onScrollMeasure(){this.callAll("onScrollMeasure")}onMouseMoveMeasure(){this.callAll("onMouseMoveMeasure")}onScroll(){this.callAll("onScroll")}onResizeWidth(){this.callAll("onResizeWidth")}onResize(){this.callAll("onResize")}onRebuild(){this.callAll("onRebuild")}onMouseMove(t){this.callAll("onMouseMove",t)}onWheel(t){this.callAll("onWheel",t)}onDirectionChange(){this.callAll("onDirectionChange")}onScrollStart(){this.callAll("onScrollStart")}onScrollStop(){this.callAll("onScrollStop")}onAxisChange(){this.callAll("onAxisChange")}onDeviceChange(){this.callAll("onDeviceChange")}onScrollConfigChange(){this.callAll("onScrollConfigChange")}onSettingsChange(t){this.callAll("onSettingsChange")}onDOMMutate(t,e){this.callAll("onDOMMutate",t,e)}destroy(){this.callAll("onUnsubscribe"),this.callAll("destroy"),this.modules=[],this.uiModules=[],this.allModules=[]}get all(){return this.allModules}get core(){return this.modules}get ui(){return this.uiModules}callAll(t,e,r){this.modules.length>0&&this.callLifecycleStrict(this.modules,t,e,r),this.uiModules.length>0&&this.callLifecycleStrict(this.uiModules,t,e,r)}callLifecycleStrict(t,e,r,i){let n=t.length;switch(e){case"onFrame":case"onMutate":case"onScrollMeasure":case"onMouseMoveMeasure":case"onScroll":for(let s=0;s<n;s++){let o=t[s];o&&o[e](this.data)}break;case"onDOMMutate":for(let s=0;s<n;s++){let o=t[s];o&&o[e](r,i)}break;case"onMouseMove":case"onWheel":for(let s=0;s<n;s++){let o=t[s];o&&o[e](r)}break;default:for(let s=0;s<n;s++){let o=t[s];o&&o[e]()}break}}rebuildAllModules(){this.allModules.length=0;for(let t=0;t<this.modules.length;t++)this.allModules.push(this.modules[t]);for(let t=0;t<this.uiModules.length;t++)this.allModules.push(this.uiModules[t])}};var Ee=class{constructor(t,e,r){this.parent=r;this.id=t,this.htmlElement=e}id;htmlElement;properties=new Map;easingFn;get parentObject(){return this.parent}setProperty(t,e){this.properties.set(t,e)}getProperty(t){return this.properties.get(t)??null}setEasing(t){this.easingFn=t??void 0}getEasing(){return this.easingFn}applyProgress(t,e){let r=this.easingFn??e;return r?r(t):t}};var Gt=class{htmlElement;id="";keys=[];tokens=[];mirrors=new Map;_cachedMirrorObjects=[];_cachedConnects=[];_mirrorsDirty=!1;properties=new Map;modules=[];events=new At;eventNameCache=new Map;eventNameSuffixCache=new Map;constructor(t,e){this.htmlElement=e,this.id=t}getScopedEventName(t,e){if(e==null){let s=this.eventNameCache.get(t);if(s)return s;let o=`${t}:${this.id}`;return this.eventNameCache.set(t,o),o}let r=this.eventNameSuffixCache.get(t);r||(r=new Map,this.eventNameSuffixCache.set(t,r));let i=r.get(e);if(i)return i;let n=`${t}:${this.id}:${e}`;return r.set(e,n),n}setProperty(t,e){this.properties.set(t,e)}getProperty(t){return this.properties.get(t)??null}enter(){this.events.emit("enter",this),this.setProperty("is-entered",!0),this.modules.forEach(t=>{t.enterObject(this.id,this)})}leave(){this.events.emit("leave",this),this.setProperty("is-entered",!1),this.modules.forEach(t=>{t.exitObject(this.id)})}remove(){this.modules.forEach(t=>{t.removeObject(this.id)})}setInviewAutoBlocked(t){this.setProperty("inview-auto-blocked",t)}isInviewAutoBlocked(){return this.getProperty("inview-auto-blocked")===!0}setInviewManualActive(t){this.setProperty("inview-manual-active",t)}isInviewManualActive(){return this.getProperty("inview-manual-active")===!0}syncInviewClass(){if(this.isInviewAutoBlocked()){this.htmlElement.classList.remove("-inview");return}if(this.isInviewManualActive()){this.htmlElement.classList.add("-inview");return}if(this.getProperty("is-inview")===!0){this.htmlElement.classList.add("-inview");return}this.getProperty("repeat")&&this.htmlElement.classList.remove("-inview")}show(){this.isInviewAutoBlocked()||this.htmlElement.classList.add("-inview")}hide(){if(this.isInviewAutoBlocked()){this.htmlElement.classList.remove("-inview");return}if(this.isInviewManualActive())return;this.getProperty("repeat")&&this.htmlElement.classList.remove("-inview")}connect(t){return this.modules.includes(t)?!1:(this.modules.push(t),!0)}disconnect(t){let e=this.modules.indexOf(t);return e===-1?!1:(this.modules.splice(e,1),!0)}isConnectedTo(t){return this.modules.includes(t)}setTokens(t){this.tokens=t,this.keys=t.map(e=>e.key)}getToken(t){for(let e=0;e<this.tokens.length;e++)if(this.tokens[e].key===t)return this.tokens[e];return null}updateMirrorsCache(){if(this._mirrorsDirty){this._cachedMirrorObjects=Array.from(this.mirrors.values());let t=this._cachedMirrorObjects.length;this._cachedConnects=new Array(t);for(let e=0;e<t;e++)this._cachedConnects[e]=this._cachedMirrorObjects[e].htmlElement;this._mirrorsDirty=!1}}addMirror(t){this.mirrors.has(t.id)||(this.mirrors.set(t.id,t),this._mirrorsDirty=!0)}removeMirror(t){this.mirrors.delete(t)&&(this._mirrorsDirty=!0)}get mirrorObjects(){return this.updateMirrorsCache(),this._cachedMirrorObjects}get connects(){return this.updateMirrorsCache(),this._cachedConnects}};var $t=class{readQueue=[];writeQueue=[];computeQueue=[];isProcessing=!1;pendingFrame=null;rectCache=new WeakMap;dimensionCache=new WeakMap;scheduleRead(t,e=0){this.readQueue.push({priority:e,execute:t}),this.scheduleFlush()}scheduleCompute(t,e=0){this.computeQueue.push({priority:e,execute:t}),this.scheduleFlush()}scheduleWrite(t,e=0){this.writeQueue.push({priority:e,execute:t}),this.scheduleFlush()}batchModuleInitialization(t){t.forEach(({module:e,object:r,element:i,attributes:n,globalId:s})=>{this.scheduleRead(()=>{let o=i.getBoundingClientRect();this.rectCache.set(i,o),this.dimensionCache.set(i,{width:i.offsetWidth||i.clientWidth||o.width,height:i.offsetHeight||i.clientHeight||o.height}),e.initializeObject(s,r,i,n)},1)}),t.forEach(({module:e,object:r,windowSize:i})=>{this.scheduleCompute(()=>{e.calculatePositions(r,i)},2)}),t.forEach(({module:e,object:r})=>{this.scheduleWrite(()=>{e.connectObject(r),e.addObject(r.id,r)},3)})}getCachedRect(t){return this.rectCache.get(t)}getCachedDimensions(t){return this.dimensionCache.get(t)}scheduleFlush(){this.pendingFrame!==null||this.isProcessing||(this.pendingFrame=requestAnimationFrame(()=>{this.flush()}))}flush(){this.isProcessing=!0,this.pendingFrame=null;let t=(e,r)=>r.priority-e.priority;try{[...this.readQueue].sort(t).forEach(n=>{try{n.execute()}catch(s){console.error("[DOMBatcher] Read task error:",s)}}),this.readQueue=[],[...this.computeQueue].sort(t).forEach(n=>{try{n.execute()}catch(s){console.error("[DOMBatcher] Compute task error:",s)}}),this.computeQueue=[],[...this.writeQueue].sort(t).forEach(n=>{try{n.execute()}catch(s){console.error("[DOMBatcher] Write task error:",s)}}),this.writeQueue=[]}finally{this.rectCache=new WeakMap,this.dimensionCache=new WeakMap,this.isProcessing=!1}}flushSync(){this.pendingFrame!==null&&(cancelAnimationFrame(this.pendingFrame),this.pendingFrame=null),this.flush()}clear(){this.pendingFrame!==null&&(cancelAnimationFrame(this.pendingFrame),this.pendingFrame=null),this.readQueue=[],this.writeQueue=[],this.computeQueue=[],this.rectCache=new WeakMap,this.dimensionCache=new WeakMap}};var Me=class{desktop={rebuild:{width:!0,height:!0,scrollHeight:!0}};mobile={rebuild:{width:!0,height:!0,scrollHeight:!0}}};var ss=Object.freeze({}),x=class{attributesToMap;cssProperties=[];objectMapOnPage=new Map;allObjectMapOnPage=new Map;objectsOnPage=[];allObjectsOnPage=[];objectMap=new Map;allObjectMap=new Map;objects=[];allObjects=[];activeObjects=new Set;wake(t){this.activeObjects.add(t)}sleep(t){this.activeObjects.delete(t)}htmlKey="";defaultModeScope="all";_type=1;get type(){return this._type}get key(){return this.htmlKey}tools;data;settings;events;centers;hover;objectManager;signals;scrollScopes;permissions=new Me;constructor(t){this.tools=t.tools,this.data=t.data,this.settings=t.settings,this.events=t.events,this.centers=t.centers,this.hover=t.hover,this.objectManager=t.objectManager,this.signals=t.signals,this.scrollScopes=t.scrollScopes,this.attributesToMap=[{key:"active",type:"boolean",fallback:this.settings.active},{key:"fixed",type:"boolean",fallback:this.settings.fixed},{key:"outside-container",type:"boolean",fallback:this.settings["outside-container"]},{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:"offset-enter",type:"dimension",fallback:this.settings["offset-enter"]},{key:"offset-exit",type:"dimension",fallback:this.settings["offset-exit"]},{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:(e,r,i)=>{let n=i.top;return Math.floor(n)+this.data.scroll.transformedCurrent}},{key:"end",type:"number",fallback:(e,r,i)=>{let n=i.top,s=i.height;return n+s-this.data.scroll.transformedCurrent}},{key:"size",type:"number",fallback:(e,r,i)=>i.height},{key:"half-width",type:"number",fallback:(e,r,i)=>i.width/2},{key:"half-height",type:"number",fallback:(e,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"]}]}initializeObject(t,e,r,i){let n=this.tools.boundingClientRect.process({element:r});for(let{key:s,type:o,fallback:a,transform:l}of this.attributesToMap){let c=typeof a=="function"?a(r,e,n):a,u=i[s]??i[`string-${s}`]??i[`data-string-${s}`],p=this.tools.domAttribute.process({element:r,key:s,fallback:u??this.settings[s]??c}),g=this.parseAttribute(p,o,{element:r,boundingRect:n,viewportHeight:this.data.viewport.windowHeight,baseRem:this.data.viewport.baseRem});l&&(g=l(g)),e.setProperty(s,g)}this.cacheLayoutSnapshot(e,r)}cacheLayoutSnapshot(t,e){let r=this.data.scroll.container??document.body??document.documentElement,i=this.data.scroll.elementContainer??document.documentElement,n=this.tools.transformNullify.process({element:e}),s=window.getComputedStyle(e),o=this.getOffsetSize(e,s),a=0,l=0,c=n.width,u=n.height;if((!Number.isFinite(c)||c<=0)&&(c=o.width),(!Number.isFinite(u)||u<=0)&&(u=o.height),Number.isFinite(n.left)&&Number.isFinite(n.top)&&n.width>0&&n.height>0)if(r===document.body||r===document.documentElement)a=n.left+i.scrollLeft,l=n.top+i.scrollTop;else{let p=r.getBoundingClientRect();a=n.left-p.left+r.scrollLeft,l=n.top-p.top+r.scrollTop}else{let p=this.getOffsetChainPosition(e);if(r===document.body||r===document.documentElement)a=p.left,l=p.top;else{let g=this.getOffsetChainPosition(r);a=p.left-g.left+r.scrollLeft,l=p.top-g.top+r.scrollTop}}t.setProperty("layout-doc-left",a),t.setProperty("layout-doc-top",l),t.setProperty("layout-width",c),t.setProperty("layout-height",u),t.setProperty("layout-border-radius",s.borderRadius||"0px")}getOffsetSize(t,e){let r=parseFloat(e.width),i=parseFloat(e.height);return{width:t.offsetWidth||t.clientWidth||(Number.isFinite(r)?r:0),height:t.offsetHeight||t.clientHeight||(Number.isFinite(i)?i:0)}}getOffsetChainPosition(t){let e=0,r=0,i=t;for(;i;)e+=i.offsetLeft||0,r+=i.offsetTop||0,i=i.offsetParent;return{left:e,top:r}}calculatePositions(t,e){let r=t.getProperty("start"),i=t.getProperty("size"),n=t.getProperty("offset-enter")??t.getProperty("offset-bottom"),s=t.getProperty("offset-exit")??t.getProperty("offset-top"),o=t.getProperty("enter-el"),a=t.getProperty("enter-vp"),l=t.getProperty("exit-el"),c=t.getProperty("exit-vp"),u=-0,p=-0,g=-0,m=-0;o==="top"&&a==="top"||o==="left"&&a==="left"?(g=-e+1,u=r-n):o==="top"&&a==="bottom"||o==="left"&&a==="right"?u=r-e-n:o==="bottom"&&a==="top"||o==="right"&&a==="left"?(g=-e-i+1,u=r+i-n):(o==="bottom"&&a==="bottom"||o==="right"&&a==="right")&&(g=-i+1,u=r-e+i-n),l==="top"&&c==="top"||l==="left"&&c==="left"?(m=-i+1,p=r+s):l==="top"&&c==="bottom"||l==="left"&&c==="right"?(m=-e-i+1,p=r-e+s):l==="bottom"&&c==="top"||l==="right"&&c==="left"?p=r+i+s:(l==="bottom"&&c==="bottom"||l==="right"&&c==="right")&&(m=-e+1,p=r-e+i+s),t.setProperty("start-bias",g),t.setProperty("end-bias",m),t.setProperty("start-position",u-this.data.scroll.topPosition),t.setProperty("end-position",p-this.data.scroll.topPosition),t.setProperty("difference-position",p-u);let h=t.getProperty("inview-top")??-0,f=t.getProperty("inview-bottom")??-0;t.setProperty("inview-start-position",t.getProperty("start-position")+h),t.setProperty("inview-end-position",t.getProperty("end-position")+f)}parseAttribute(t,e,r=ss){if(t==null)return null;let i=typeof t=="string"?t:String(t);if(typeof e=="object"&&e.type==="enum")return e.values.includes(i)?i:e.values[0];switch(e){case"number":return typeof t=="string"?+t||parseFloat(t):t;case"boolean":return i===""||i==="true";case"json":try{return JSON.parse(i)}catch{return null}case"tuple":return i.trim().split(/\s+/);case"easing":return this.tools.easingFunction.process({easing:i});case"color":return this.tools.colorParser.process({value:i});case"dimension":return t===0||t=="0"?0:r.element!=null&&r.viewportHeight!=null&&r.baseRem!=null&&r.boundingRect!=null?this.tools.unitParser.process({value:t,element:r.element,viewportHeight:r.viewportHeight,boundingRect:r.boundingRect,baseRem:r.baseRem}):0;case"breakpoint-dimension":if(r.element!=null&&r.viewportHeight!=null&&r.baseRem!=null&&r.boundingRect!=null){let n=i.trim().split("|"),s=[];for(let o of n)if(o.includes(":")){let[a,l]=o.split(":");s.push({breakpoint:parseInt(a),value:this.tools.unitParser.process({value:`${l}|`,element:r.element,viewportHeight:r.viewportHeight,boundingRect:r.boundingRect,baseRem:r.baseRem})})}else s.push({breakpoint:0,value:this.tools.unitParser.process({value:o,element:r.element,viewportHeight:r.viewportHeight,boundingRect:r.boundingRect,baseRem:r.baseRem})});return s}default:return t}}canConnect(t){return t.keys.includes(this.htmlKey)}isTokenEnabledInCurrentMode(t){let e=this.data.scroll.mode;return t.modeSpec.kind==="all"?!0:t.modeSpec.kind==="include"?t.modeSpec.values.includes(e):this.defaultModeScope==="all"?!0:this.defaultModeScope.includes(e)}isObjectEnabledInCurrentMode(t){let e=t.getToken(this.htmlKey);return e?this.isTokenEnabledInCurrentMode(e):!1}disconnectObject(t){t.disconnect(this)}connectObject(t){t.connect(this)&&this.onObjectConnected(t)}enterObject(t,e){this.allObjectMap.has(t)||(this.allObjectMap.set(t,e),this.allObjects.push(e)),this.isObjectEnabledInCurrentMode(e)&&!this.objectMap.has(t)&&(this.objectMap.set(t,e),this.objects.push(e))}fastRemoveFromArray(t,e){if(e===-1)return;let r=t.length-1;e!==r&&(t[e]=t[r]),t.pop()}exitObject(t){let e=this.objectMap.get(t);if(e){this.objectMap.delete(t);let n=this.objects.indexOf(e);this.fastRemoveFromArray(this.objects,n)}let r=this.allObjectMap.get(t);if(!r)return;this.allObjectMap.delete(t);let i=this.allObjects.indexOf(r);this.fastRemoveFromArray(this.allObjects,i)}addObject(t,e){this.allObjectMapOnPage.has(t)||(this.allObjectMapOnPage.set(t,e),this.allObjectsOnPage.push(e)),this.isObjectEnabledInCurrentMode(e)&&!this.objectMapOnPage.has(t)&&(this.objectMapOnPage.set(t,e),this.objectsOnPage.push(e))}removeObject(t){let e=this.objectMapOnPage.get(t);if(e){this.objectMapOnPage.delete(t);let n=this.objectsOnPage.indexOf(e);this.fastRemoveFromArray(this.objectsOnPage,n)}let r=this.allObjectMapOnPage.get(t);if(!r)return;this.allObjectMapOnPage.delete(t);let i=this.allObjectsOnPage.indexOf(r);this.fastRemoveFromArray(this.allObjectsOnPage,i),this.exitObject(t),this.sleep(r),this.onObjectDisconnected(r)}onObjectConnected(t){}onObjectDisconnected(t){}get respectSelfDisable(){return!0}isPrimaryElementEnabled(t){return!this.respectSelfDisable||t.getProperty("self-disable")!==!0}applyToElementAndConnects(t,e,r=e){this.isPrimaryElementEnabled(t)&&e(t.htmlElement),t.mirrorObjects.forEach(i=>r(i.htmlElement,i))}applyVarToElement(t,e,r){this.isPrimaryElementEnabled(t)&&this.tools.styleTxn.setVar(t.htmlElement,e,r)}applyPropToElement(t,e,r){this.isPrimaryElementEnabled(t)&&this.tools.styleTxn.setProp(t.htmlElement,e,r)}applyVarToConnects(t,e,r){for(let i of t.mirrorObjects)this.tools.styleTxn.setVar(i.htmlElement,e,r)}applyPropToConnects(t,e,r){for(let i of t.mirrorObjects)this.tools.styleTxn.setProp(i.htmlElement,e,r)}getObjectEventName(t,e,r){return t.getScopedEventName(e,r)}emitSignal(t,e,r){t.setProperty(`signal:${e}`,r),this.signals.publish(t.id,e,r)}getSignal(t,e){return this.signals.get(t,e)}clearManagedStyles(t){let e=i=>{for(let s=0;s<this.cssProperties.length;s++)i.style.removeProperty(this.cssProperties[s].name);let n=t.getProperty("key");typeof n=="string"&&n.length>0&&i.style.removeProperty(n)};e(t.htmlElement);let r=t.mirrorObjects;for(let i=0;i<r.length;i++)e(r[i].htmlElement)}onObjectModeActivated(t){}onObjectModeDeactivated(t){this.clearManagedStyles(t)}rebuildActiveObjectsForCurrentMode(){let t=new Map(this.objectMapOnPage);this.objectMapOnPage=new Map,this.objectsOnPage=[];for(let e=0;e<this.allObjectsOnPage.length;e++){let r=this.allObjectsOnPage[e];this.isObjectEnabledInCurrentMode(r)&&(this.objectMapOnPage.set(r.id,r),this.objectsOnPage.push(r))}this.objectMap=new Map,this.objects=[];for(let e=0;e<this.allObjects.length;e++){let r=this.allObjects[e];this.isObjectEnabledInCurrentMode(r)&&(this.objectMap.set(r.id,r),this.objects.push(r))}t.forEach((e,r)=>{this.objectMapOnPage.has(r)||this.onObjectModeDeactivated(e)}),this.objectMapOnPage.forEach((e,r)=>{t.has(r)||this.onObjectModeActivated(e)})}destroy(){this.objects=[],this.allObjects=[],this.objectMap=new Map,this.allObjectMap=new Map,this.objectsOnPage=[],this.allObjectsOnPage=[],this.objectMapOnPage=new Map,this.allObjectMapOnPage=new Map,this.activeObjects=new Set}onInit(){}onSubscribe(){}onUnsubscribe(){}onFrame(t){}onMutate(t){}onScrollMeasure(t){}onMouseMoveMeasure(t){}onResize(){}onResizeWidth(){}onRebuild(){}onScroll(t){}onDirectionChange(){}onScrollStart(){}onScrollStop(){}onScrollDirectionChange(){}onAxisChange(){}onDeviceChange(){}onScrollConfigChange(){this.rebuildActiveObjectsForCurrentMode()}onSettingsChange(){}onDOMRebuild(){}onMouseMove(t){}onWheel(t){}onDOMMutate(t,e){}};var we=class d{constructor(t,e,r,i){this.data=t;this.modules=e;this.events=r;this.tools=i}objects=new Map;connectQueue=[];connectableModulesBuffer=[];mirrors=new Map;mirrorId=1;globalId=1;domBatcher=new $t;domBatcherEnabled=!1;inviewStarts=[];inviewEnds=[];inviewActive=new Set;inviewStartIdx=0;inviewEndIdx=0;inviewIndexDirty=!0;lastInviewScrollPos=0;intersectionObserverEnabled=!0;domObserver=null;static DEVTOOLS_ARTIFACT_SELECTOR="[data-stdg],[data-string-dev-viewport-layer],[data-string-dev-viewport-world]";get all(){return this.objects}add(t){let e=`string-${this.globalId++}`,r="string-id";t.getAttribute("string-id")&&(e=t.getAttribute("string-id"),r="string-id"),t.getAttribute("data-string-id")&&(e=t.getAttribute("data-string-id"),r="data-string-id");let i=e&&this.objects.has(e)?this.objects.get(e):new Gt(e,t);t.setAttribute(r,i.id);let n=t.getAttribute("string")??t.getAttribute("data-string");n&&i.setTokens(this.parseStringTokens(n)),t.setAttribute("string-inited",""),this.objects.set(i.id,i);let s=this.getAllAttributes(t),o=this.modules.core;for(let u=0;u<o.length;u++){let p=o[u];"setupCoreProperties"in p&&typeof p.setupCoreProperties=="function"&&p.setupCoreProperties(i,t,s)}let a=this.connectableModulesBuffer;a.length=0;let l=this.modules.all,c=null;for(let u=0;u<l.length;u++){let p=l[u];p instanceof x&&p.key===""&&(c=p),p instanceof x&&p.canConnect(i)&&a.push(p)}if(a.length===0&&c&&(i.setProperty("inview-fallback",!0),a.push(c)),this.domBatcherEnabled&&a.length>0){let u=new Array(a.length);for(let p=0;p<a.length;p++)u[p]={module:a[p],object:i,element:t,attributes:s,globalId:this.globalId,windowSize:this.data.viewport.windowHeight};this.domBatcher.batchModuleInitialization(u),this.domBatcher.scheduleWrite(()=>{this.initObservers(i,t),this.checkInviewForObject(i)})}else{for(let u=0;u<a.length;u++){let p=a[u];p.initializeObject(this.globalId,i,t,s),p.calculatePositions(i,this.data.viewport.windowHeight),p.connectObject(i),p.addObject(i.id,i)}this.initObservers(i,t),this.checkInviewForObject(i)}if(this.connectQueue.length>0){let u=0;for(let p=0;p<this.connectQueue.length;p++){let g=this.connectQueue[p];if(g.id===i.id){this.attachMirrorToObject(i,g.element);continue}this.connectQueue[u++]=g}this.connectQueue.length=u}a.length=0,this.inviewIndexDirty=!0}setDOMBatcherEnabled(t){this.domBatcherEnabled=t,t||this.domBatcher.flushSync()}setIntersectionObserverEnabled(t){if(this.intersectionObserverEnabled!==t){this.intersectionObserverEnabled=t;for(let e of this.objects.values())e.getProperty("observer-progress")?.disconnect(),t&&this.initObservers(e,e.htmlElement)}}refreshObservers(){if(this.intersectionObserverEnabled)for(let t of this.objects.values()){let e=t.htmlElement;!e||!e.isConnected||this.initObservers(t,e)}}attachModule(t){this.objects.forEach(e=>{if(!t.canConnect(e))return;let r=e.htmlElement,i=this.getAllAttributes(r);t.initializeObject(this.globalId,e,r,i),t.calculatePositions(e,this.data.viewport.windowHeight),t.connectObject(e),t.addObject(e.id,e),e.getProperty("is-entered")===!0&&t.enterObject(e.id,e)})}refreshModuleConnectionsForCurrentMode(){let t=this.modules.all;for(let e of this.objects.values()){let r=e.htmlElement;if(!r||!r.isConnected)continue;let i=null;for(let n=0;n<t.length;n++){let s=t[n];if(!(s instanceof x)||!e.keys.includes(s.key))continue;let o=s.canConnect(e),a=e.isConnectedTo(s);if(o&&!a){i==null&&(i=this.getAllAttributes(r)),s.initializeObject(this.globalId,e,r,i),s.calculatePositions(e,this.data.viewport.windowHeight),s.connectObject(e),s.addObject(e.id,e),e.getProperty("is-entered")===!0&&s.enterObject(e.id,e);continue}!o&&a&&(s.exitObject(e.id),s.removeObject(e.id),s.disconnectObject(e))}}}invalidateInviewIndex(){this.inviewIndexDirty=!0}refreshLayoutForRoot(t){if(!t)return;let e=new Set,r=n=>{let s=n.getAttribute("string-id")??n.getAttribute("data-string-id");if(!s)return;let o=this.objects.get(s);o&&e.add(o)};if(t instanceof HTMLElement){r(t);let n=t.querySelectorAll("[string-id],[data-string-id]");for(let s=0;s<n.length;s++)r(n[s])}if(e.size===0)return;let i=this.data.viewport.windowHeight;for(let n of e){let s=n.htmlElement;if(!s||!s.isConnected)continue;let o=this.getAllAttributes(s),a=this.modules.all;for(let l=0;l<a.length;l++){let c=a[l];c instanceof x&&c.canConnect(n)&&(c.initializeObject(this.globalId,n,s,o),c.calculatePositions(n,i))}}this.inviewIndexDirty=!0,this.checkInview()}remove(t){let e=this.objects.get(t);e&&(e.events.clearAll(),e.getProperty("observer-progress")?.disconnect(),e.getProperty("observer-inview")?.disconnect(),e.htmlElement.removeAttribute("string-inited"),e.leave(),e.remove(),e.mirrorObjects.forEach(r=>{let i=this.getMirrorIds(r.htmlElement);this.setMirrorIds(r.htmlElement,i.filter(s=>s!==r.id)),this.mirrors.delete(r.id);let n=r.htmlElement.getAttribute("string-copy-from")??r.htmlElement.getAttribute("data-string-copy-from");n&&this.enqueueConnection(n,r.htmlElement)}),this.objects.delete(t),this.inviewActive.delete(e),this.inviewIndexDirty=!0)}enqueueConnection(t,e){let r=this.splitPipeAndTrim(t);for(let i=0;i<r.length;i++){let n=r[i];this.connectQueue.some(s=>s.id===n&&s.element===e)||this.connectQueue.push({id:n,element:e})}}linkMirror(t,e){let r=this.splitPipeAndTrim(t);for(let i=0;i<r.length;i++){let n=r[i],s=this.objects.get(n);s?this.attachMirrorToObject(s,e):this.enqueueConnection(n,e)}}attachMirrorToObject(t,e){let r=this.getMirrorIds(e);for(let c of r){let u=this.mirrors.get(c);if(u&&u.parentObject===t)return u}let i=`string-mirror-${this.mirrorId++}`,n=new Ee(i,e,t);this.setMirrorIds(e,[...r,i]),t.addMirror(n),this.mirrors.set(i,n);let s=e.getAttribute("string-easing")??e.getAttribute("data-string-easing");s&&s.trim().length>0&&(n.setEasing(this.tools.easingFunction.process({easing:s})),n.setProperty("easing",s));let o=t.getProperty("key"),a=t.getProperty("progress-raw"),l=t.getProperty("progress-value");if(typeof a=="number"){let c=t.getProperty("easing")??void 0,u=n.applyProgress(a,c);n.setProperty("progress",u),o&&this.tools.styleTxn.setVarDirect(n.htmlElement,o,u)}else typeof l=="number"&&(n.setProperty("progress",l),o&&this.tools.styleTxn.setVarDirect(n.htmlElement,o,l));return n}detachMirrorByElement(t){let e=this.getMirrorIds(t);e.length!==0&&(e.forEach(r=>this.detachMirrorById(r)),this.clearMirrorIds(t))}detachMirrorById(t){let e=this.mirrors.get(t);e&&(e.parentObject.removeMirror(t),this.mirrors.delete(t))}getMirrorIds(t){let e=t.getAttribute("string-mirror-id")??t.getAttribute("data-string-mirror-id");return e?this.splitPipeAndTrim(e):[]}setMirrorIds(t,e){if(e.length===0){this.clearMirrorIds(t);return}t.setAttribute("string-mirror-id",e.join("|"))}clearMirrorIds(t){t.removeAttribute("string-mirror-id"),t.removeAttribute("data-string-mirror-id")}getAllAttributes(t){let e={},r=t.attributes;for(let i=0;i<r.length;i++){let n=r[i];e[n.name]=n.value}return e}initObservers(t,e){if(!this.intersectionObserverEnabled)return;let r=t.getProperty("offset-exit")??t.getProperty("offset-top")??0,i=t.getProperty("offset-enter")??t.getProperty("offset-bottom")??0;t.getProperty("observer-progress")?.disconnect();let n=g=>{g.forEach(m=>{this.events.emit(t.getScopedEventName("object:activate"),m.isIntersecting),m.isIntersecting?t.enter():t.leave()})},s=t.getProperty("outside-container"),o=e.getAttribute("string-outside-container")??e.getAttribute("data-string-outside-container"),a=o!=null?o.trim().toLowerCase():null,l=a===""||a==="true"||a==="1",c=s!=null?s===!0:l,u=this.data.scroll.container===document.body||c?null:this.data.scroll.container,p=new IntersectionObserver(n,{root:u,rootMargin:`${i+this.data.viewport.windowHeight}px 0px ${r+this.data.viewport.windowHeight}px 0px`,threshold:0});p.observe(e),t.setProperty("observer-progress",p)}observeDOM(){this.domObserver?.disconnect();let t=new MutationObserver(e=>{let r=!1,i=!1;for(let n=0;n<e.length;n++){let s=e[n];if(s.type==="childList"){let o=!1;for(let a=0;a<s.removedNodes.length;a++){let l=s.removedNodes[a];if(l.nodeType!==Node.ELEMENT_NODE)continue;let c=l;if(this.isDevtoolsArtifact(c)||(o=!0,this.detachMirrorByElement(c),this.isFixed(c)))continue;(c.hasAttribute("string")||c.hasAttribute("data-string"))&&(this.handleRemoved(c),i=!0);let u=c.querySelectorAll("[string],[data-string]");for(let g=0;g<u.length;g++){let m=u[g];this.isFixed(m)||(this.handleRemoved(m),i=!0)}let p=c.querySelectorAll("[string-copy-from],[data-string-copy-from]");for(let g=0;g<p.length;g++)this.detachMirrorByElement(p[g])}for(let a=0;a<s.addedNodes.length;a++){let l=s.addedNodes[a];if(l.nodeType!==Node.ELEMENT_NODE)continue;let c=l;if(this.isDevtoolsArtifact(c)||(o=!0,this.isFixed(c)))continue;c.hasAttribute("string")&&!c.hasAttribute("string-inited")&&(this.add(c),i=!0);let u=c.querySelectorAll("[string]:not([string-inited]),[data-string]:not([string-inited])");for(let m=0;m<u.length;m++)this.add(u[m]),i=!0;let p=c.getAttribute("string-copy-from")??c.getAttribute("data-string-copy-from");p&&this.linkMirror(p,c);let g=c.querySelectorAll("[string-copy-from],[data-string-copy-from]");for(let m=0;m<g.length;m++){let h=g[m],f=h.getAttribute("string-copy-from")??h.getAttribute("data-string-copy-from");f&&this.linkMirror(f,h)}}o&&(this.modules.onDOMMutate(s.addedNodes,s.removedNodes),r=!0)}}if(r){let n=this.modules.all;for(let s=0;s<n.length;s++)n[s].onDOMRebuild();this.events.emit("dom:changed",{stringElementChanged:i})}});t.observe(document.body,{childList:!0,subtree:!0}),this.domObserver=t}handleRemoved(t){let e=t.getAttribute("string-id")??t.getAttribute("data-string-id");if(!e)return;let r=t.getAttribute("string-copy-from")??t.getAttribute("data-string-copy-from");r&&(this.connectQueue=this.connectQueue.filter(i=>i.id!==r)),this.remove(e)}onSettingsChange(t){for(let e of this.objects.values()){if(!e.htmlElement||!e.htmlElement.isConnected)continue;let r=null,i=this.modules.all;for(let n=0;n<i.length;n++){let s=i[n],o=!1;t.isDesktop?(s.permissions.desktop.rebuild.scrollHeight&&t.scrollHeightChanged&&(o=!0),s.permissions.desktop.rebuild.width&&t.widthChanged&&(o=!0),s.permissions.desktop.rebuild.height&&t.heightChanged&&(o=!0)):(s.permissions.mobile.rebuild.scrollHeight&&t.scrollHeightChanged&&(o=!0),s.permissions.mobile.rebuild.width&&t.widthChanged&&(o=!0),s.permissions.mobile.rebuild.height&&t.heightChanged&&(o=!0)),(o||t.isForceRebuild)&&s.canConnect(e)&&(r==null&&(r=this.getAllAttributes(e.htmlElement)),s.initializeObject(this.globalId,e,e.htmlElement,r),s.calculatePositions(e,this.data.viewport.windowHeight),s.connectObject(e))}}this.inviewIndexDirty=!0}isFixed(t){return t.hasAttribute("string-fixed")}isDevtoolsArtifact(t){return t.closest(d.DEVTOOLS_ARTIFACT_SELECTOR)!=null}checkInview(){let t=this.data.scroll.transformedCurrent;this.updateInviewWindow(t);for(let e of this.inviewActive)this.checkInviewForObject(e)}checkInviewForObject(t){let e=this.data.scroll.transformedCurrent;if(!this.intersectionObserverEnabled){let c=t.getProperty("start-position"),u=t.getProperty("end-position");if(c!=null&&u!=null){let p=Math.min(c,u),g=Math.max(c,u),m=t.getProperty("is-active")??!1,h=e>=p&&e<=g;h!==m&&(t.setProperty("is-active",h),this.events.emit(t.getScopedEventName("object:activate"),h),h?t.enter():t.leave())}}let r=t.getProperty("inview-start-position"),i=t.getProperty("inview-end-position"),n=t.getProperty("is-inview")??!1,s=Math.min(r,i),o=Math.max(r,i),a=e>=s&&e<=o,l=null;if(!n&&a){let c=Math.abs(e-s),u=Math.abs(o-e);l=c<=u?"enter-top":"enter-bottom"}else n&&!a&&(l=e<s?"exit-top":"exit-bottom");a!==n&&(t.setProperty("is-inview",a),t.setInviewAutoBlocked(!1),t.setInviewManualActive(!1),a?t.show():t.hide(),this.events.emit(t.getScopedEventName("object:inview"),{inView:a,direction:l}))}updateInviewWindow(t){let e=this.data.viewport.windowHeight,r=t-e,i=t+this.data.viewport.windowHeight+e;for(this.inviewIndexDirty?this.rebuildInviewIndex(r,i):t<this.lastInviewScrollPos&&this.repositionInviewIndex(r,i);this.inviewStartIdx<this.inviewStarts.length&&this.inviewStarts[this.inviewStartIdx].pos<=i;)this.inviewActive.add(this.inviewStarts[this.inviewStartIdx].object),this.inviewStartIdx++;for(;this.inviewEndIdx<this.inviewEnds.length&&this.inviewEnds[this.inviewEndIdx].pos<r;)this.inviewActive.delete(this.inviewEnds[this.inviewEndIdx].object),this.inviewEndIdx++;this.lastInviewScrollPos=t}rebuildInviewIndex(t,e){this.inviewStarts=[],this.inviewEnds=[];for(let r of this.objects.values()){let i=r.getProperty("inview-start-position"),n=r.getProperty("inview-end-position");i==null||n==null||(this.inviewStarts.push({pos:Math.min(i,n),object:r}),this.inviewEnds.push({pos:Math.max(i,n),object:r}))}this.inviewStarts.sort((r,i)=>r.pos-i.pos),this.inviewEnds.sort((r,i)=>r.pos-i.pos),this.repositionInviewIndex(t,e),this.inviewIndexDirty=!1}repositionInviewIndex(t,e){this.inviewActive.clear(),this.inviewStartIdx=this.upperBound(this.inviewStarts,e),this.inviewEndIdx=this.upperBound(this.inviewEnds,t-1);for(let r=0;r<this.inviewStartIdx;r++)this.inviewActive.add(this.inviewStarts[r].object);for(let r=0;r<this.inviewEndIdx;r++)this.inviewActive.delete(this.inviewEnds[r].object)}upperBound(t,e){let r=0,i=t.length;for(;r<i;){let n=r+i>>>1;t[n].pos<=e?r=n+1:i=n}return r}splitPipeAndTrim(t){let e=t.split("|"),r=[];for(let i=0;i<e.length;i++){let n=e[i].trim();n.length>0&&r.push(n)}return r}parseStringTokens(t){let e=this.splitTopLevelPipe(t),r=[];for(let i=0;i<e.length;i++){let n=e[i].trim();if(n.length===0)continue;let s=n.match(/^([^\[\]]+?)(?:\[([^\]]*)\])?$/);if(!s){r.push({raw:n,key:n,modeSpec:{kind:"default",values:[]}});continue}let o=s[1].trim(),a=s[2];if(!o)continue;if(a==null){r.push({raw:n,key:o,modeSpec:{kind:"default",values:[]}});continue}let l=a.trim();if(l.length===0){r.push({raw:n,key:o,modeSpec:{kind:"all",values:[]}});continue}let c=this.splitTopLevelPipe(l).map(u=>u.trim()).filter(u=>u.length>0);r.push({raw:n,key:o,modeSpec:c.length>0?{kind:"include",values:c}:{kind:"all",values:[]}})}return r}splitTopLevelPipe(t){let e=[],r="",i=0;for(let n=0;n<t.length;n++){let s=t[n];if(s==="["){i++,r+=s;continue}if(s==="]"){i=Math.max(0,i-1),r+=s;continue}if(s==="|"&&i===0){e.push(r),r="";continue}r+=s}return r.length>0&&e.push(r),e}destroy(){this.domObserver?.disconnect(),this.domObserver=null,this.domBatcher.clear()}};var q={SCROLL_FORWARD:"-scroll-forward",SCROLL_BACKWARD:"-scroll-backward",SCROLLING_FORWARD:"-scrolling-forward",SCROLLING_BACKWARD:"-scrolling-backward"};var it=class{context;document;name="";isProg=!1;isParallaxEnabled=!1;_isVertical=!0;_scrollDirState=-1;_lastAppliedDirState=-1;isLastBottomScrollDirection=!0;scrollTriggerRules=[];isActive=!1;set scrollDirection(t){this._isVertical=t==="vertical"}constructor(t){this.document=document,this.context=t}onChangeDirection=()=>{};onScrollStart=()=>{};onScrollStop=()=>{};onCalcUpdate(){if(!this.isActive)return;let t=this.context.data.scroll.scrollContainer,e=this.context.data.scroll.current;t&&(this._isVertical?t.scrollTo({top:e,left:0,behavior:"auto"}):t.scrollTo({left:e,top:0,behavior:"auto"})),this._isVertical&&this.triggerScrollRules()}onFrame(){}onWheel(t){}onScroll(t){}onTouchStart(t){}onTouchMove(t){}onTouchEnd(t){}disableScrollEvents(){}enableScrollEvents(){}activate(){this.isActive||(this.isActive=!0,this.enableScrollEvents())}deactivate(){if(!this.isActive)return;this.isActive=!1,this.disableScrollEvents(),this.isProg=!1;let t=this.context.data.scroll;t.target=t.current,t.delta=0,t.lerped=0,t.displacement=0,this.clearScrollingClasses(),this._scrollDirState=-1,this._lastAppliedDirState=-1,this.onScrollStop()}destroy(){}updateScrollDirection(t){this.isLastBottomScrollDirection=t;let e=t?1:0;if(this._scrollDirState===-1){this._scrollDirState=e;return}if(this._scrollDirState=e,this.context.data.scroll.isScrollingDown=t,this.onChangeDirection(),this.context.events.emit("scroll:direction:change",t),this.context.settings["global-class"]&&this._lastAppliedDirState!==e){let r=document.documentElement.classList;t?(r.remove(q.SCROLLING_BACKWARD,q.SCROLL_BACKWARD),r.add(q.SCROLLING_FORWARD,q.SCROLL_FORWARD)):(r.remove(q.SCROLLING_FORWARD,q.SCROLL_FORWARD),r.add(q.SCROLLING_BACKWARD,q.SCROLL_BACKWARD)),this._lastAppliedDirState=e}}clearScrollingClasses(){document.documentElement.classList.remove(q.SCROLLING_BACKWARD,q.SCROLLING_FORWARD,q.SCROLL_BACKWARD,q.SCROLL_FORWARD)}triggerScrollRules(){let t=this.scrollTriggerRules,e=t.length,r=this.context.data.scroll.current,i=this.isLastBottomScrollDirection;for(let n=0;n<e;n++){let s=t[n],a=(s.direction==="any"||i&&s.direction==="forward"||!i&&s.direction==="backward")&&r>=s.offset;a&&!s.isActive?(s.isActive=!0,s.onEnter?.(),s.toggleClass&&s.toggleClass.target.classList.add(s.toggleClass.className)):!a&&s.isActive&&(s.isActive=!1,s.onLeave?.(),s.toggleClass&&s.toggleClass.target.classList.remove(s.toggleClass.className))}}addScrollMark(t){this.scrollTriggerRules.push(t)}removeScrollMark(t){let e=this.scrollTriggerRules;for(let r=0;r<e.length;r++)if(e[r].id===t){e.splice(r,1);break}}scrollTo(t,e){}};var xe=class extends it{name="default";previousScrollTop=0;previousScrollTime=0;_logScrollCount=0;isScrolling=!1;lastScrollEventTime=0;nativeVelocity=0;nativeVelocityTarget=0;scrollStopDelay=120;nativeVelocityFollow=.2;nativeVelocityDecay=.84;nativeVelocityBoost=2;nativeVelocityDeadzone=.25;constructor(t){super(t)}onFrame(){let t=0;if(this.context.data.scroll.delta!==0){let r=this.context.data.scroll.delta*this.context.data.scroll.speedAccelerate;this.context.data.scroll.delta-=r,t=r,Math.abs(t)<.1&&(this.context.data.scroll.delta=0,t=0)}let e=performance.now();this.nativeVelocityTarget*=this.nativeVelocityDecay,Math.abs(this.nativeVelocityTarget)<this.nativeVelocityDeadzone&&(this.nativeVelocityTarget=0),this.nativeVelocity+=(this.nativeVelocityTarget-this.nativeVelocity)*this.nativeVelocityFollow,Math.abs(this.nativeVelocity)<this.nativeVelocityDeadzone&&(this.nativeVelocity=0),Math.abs(this.nativeVelocity)>Math.abs(t)&&(t=this.nativeVelocity),this.context.data.scroll.lerped=t,this.isScrolling&&!(this.context.data.scroll.delta!==0||this.nativeVelocityTarget!==0||this.nativeVelocity!==0)&&e-this.lastScrollEventTime>this.scrollStopDelay&&(this.isScrolling=!1,this.onScrollStop(),this.clearScrollingClasses())}onScroll(t){let e=performance.now(),r=this.context.data.scroll.elementContainer.scrollTop,i=r-this.previousScrollTop;if(this._logScrollCount<8&&this._logScrollCount++,this.context.data.scroll.current=r,this.context.data.scroll.target=r,this.context.data.scroll.transformedCurrent=r*this.context.data.viewport.transformScale,i!==0){this.updateScrollDirection(i>0);let n=this.previousScrollTime===0?16.6667:e-this.previousScrollTime,s=i*(16.6667/Math.max(8,n))*this.nativeVelocityBoost;this.nativeVelocityTarget=s,this.previousScrollTop=r,this.previousScrollTime=e}this.triggerScrollRules(),this.lastScrollEventTime=e,this.isScrolling||(this.isScrolling=!0,this.onScrollStart())}onWheel(t){t.deltaY!==0&&(this.context.data.scroll.delta===0&&!this.isScrolling&&(this.isScrolling=!0,this.onScrollStart()),this.context.data.scroll.delta+=t.deltaY,this.lastScrollEventTime=performance.now())}deactivate(){super.deactivate(),this.isScrolling=!1,this.lastScrollEventTime=0,this.previousScrollTop=this.context.data.scroll.current,this.previousScrollTime=0,this.nativeVelocity=0,this.nativeVelocityTarget=0}scrollTo(t,e){let r=this.context.data.scroll.elementContainer.scrollTop,i=this.context.data.scroll;i.target=t,i.delta=0,i.lerped=0,this.nativeVelocity=0,this.nativeVelocityTarget=0,this.previousScrollTop=r,this.previousScrollTime=0,this._logScrollCount=0;let n=this.context.data.scroll.scrollContainer;e?(i.current=t,i.transformedCurrent=t*this.context.data.viewport.transformScale,this.triggerScrollRules(),this._isVertical?n?.scrollTo({top:t,left:0,behavior:"auto"}):n?.scrollTo({left:t,top:0,behavior:"auto"})):(i.current=r,i.transformedCurrent=r*this.context.data.viewport.transformScale,requestAnimationFrame(()=>{this._isVertical?n?.scrollTo({top:t,left:0,behavior:"smooth"}):n?.scrollTo({left:t,top:0,behavior:"smooth"})}))}};var Ce=class extends it{name="disable";preventScroll=t=>{t.preventDefault()};preventKeyScroll=t=>{["ArrowUp","ArrowDown","PageUp","PageDown"," ","Home","End"].includes(t.key)&&t.preventDefault()};onPreventScroll=this.preventScroll.bind(this);onPreventKeyScroll=this.preventKeyScroll.bind(this);constructor(t){super(t)}enableScrollEvents(){window.addEventListener("touchmove",this.onPreventScroll,{passive:!1}),window.addEventListener("keydown",this.onPreventKeyScroll)}disableScrollEvents(){window.removeEventListener("touchmove",this.onPreventScroll),window.removeEventListener("keydown",this.onPreventKeyScroll)}onFrame(){}onWheel(t){t.preventDefault()}onScroll(t){t.preventDefault()}};var Te=class extends it{name="smooth";scrollForce=0;wheelImpulse=0;previousCurrent=0;scrollToSequence=0;activeScrollToId=null;stepResult={current:.1,target:.1,delta:.1,lerped:.1,scrollForce:.1,absVelocity:.1};constructor(t){super(t),this.stepResult.current=0,this.stepResult.target=0,this.stepResult.delta=0,this.stepResult.lerped=0,this.stepResult.scrollForce=0,this.stepResult.absVelocity=0}stopScroll(){let t=this.context.data.scroll;t.lerped=0,t.delta=0,t.target=t.current,this.onCalcUpdate(),this.isProg=!1,this.clearScrollingClasses(),this._scrollDirState=-1,this._lastAppliedDirState=-1,this.activeScrollToId=null}onFrame(){let t=this.context.data.scroll;if(t.delta!==0){this.computeStep(t.current,t.target,t.delta,t.speed,t.speedAccelerate,t.decelerationCoefficient,t.maxDelta,t.bottomPosition,this.stepResult),this.scrollForce=this.stepResult.scrollForce,t.target=this.stepResult.target,t.delta=this.stepResult.delta,t.lerped=this.stepResult.lerped,t.current=this.stepResult.current;let e=this.context.data.viewport.transformScale;t.transformedCurrent=e!==1?t.current*e:t.current,this.updateScrollDirection(t.lerped>0),this.stepResult.absVelocity<t.stopThreshold?(t.current=Math.round(t.target),this.previousCurrent=t.current,this.onCalcUpdate(),this.stopScroll(),this.onScrollStop()):(this.isProg=!0,this.previousCurrent!==t.current&&(this.previousCurrent=t.current,this.onCalcUpdate()))}}onWheel(t){if(t.deltaY!==0&&t.preventDefault(),this.wheelImpulse=t.deltaY,this.wheelImpulse===0)return;let e=this.context.data.scroll;e.delta===0&&this.onScrollStart();let r=this.wheelImpulse<0,i=e.target===0&&r,n=e.target===e.bottomPosition&&!r;!i&&!n&&(e.delta+=this.wheelImpulse*e.multiplier)}onScroll(t){if(!this.isProg){let e=this.context.data.scroll,r=e.elementContainer.scrollTop,i=r-e.current;e.current=r,e.target=r,e.delta=0,e.lerped=i,e.displacement=0;let n=this.context.data.viewport.transformScale;e.transformedCurrent=n!==1?r*n:r,this.scrollForce=0,this.wheelImpulse=0,this.isProg=!1,this.previousCurrent=r,this.activeScrollToId=null,i!==0&&(this.updateScrollDirection(i>0),this.triggerScrollRules())}}deactivate(){super.deactivate(),this.scrollForce=0,this.wheelImpulse=0,this.previousCurrent=this.context.data.scroll.current}scrollTo(t,e){let r=this.context.data.scroll,i=++this.scrollToSequence;if(this.activeScrollToId=i,e){r.current=t,r.target=t,r.delta=0,r.lerped=0;let n=this.context.data.viewport.transformScale;r.transformedCurrent=n!==1?t*n:t,this.onCalcUpdate();return}r.target=t,r.delta=1}computeStep(t,e,r,i,n,s,o,a,l){let c=this.clamp(r,-o,o),u=c*n,p=Math.pow(1-n,s),g=Math.min(Math.max(0,e+u),a),m=(g-t)*i,h=c*p,f=t+m;l.current=f,l.target=g,l.delta=h,l.lerped=m,l.scrollForce=u,l.absVelocity=Math.abs(m)}clamp(t,e,r){return Math.min(Math.max(t,e),r)}};var Pe=class{constructor(t){this.context=t;this.registerMode("smooth",new Te(t)),this.registerMode("default",new xe(t)),this.registerMode("disable",new Ce(t)),this.updateResponsiveMode()}modes=new Map;boundEvents=null;scrollMarks=[];registerMode(t,e){let r=this.context.data.scroll.mode===t,i=this.modes.get(t);i&&(r&&i.deactivate(),i.destroy()),e.name||(e.name=String(t)),this.modes.set(t,e),this.boundEvents&&(e.onScrollStart=this.boundEvents.onScrollStart,e.onScrollStop=this.boundEvents.onScrollStop,e.onChangeDirection=this.boundEvents.onDirectionChange),this.scrollMarks.length>0&&this.scrollMarks.forEach(n=>e.addScrollMark(n)),r&&e.activate()}setMobileMode(t){this.context.data.scroll.modeMobile=t,this.updateResponsiveMode()}setDesktopMode(t){this.context.data.scroll.modeDesktop=t,this.updateResponsiveMode()}updateResponsiveMode(){let e=window.innerWidth<1024?this.context.data.scroll.modeMobile:this.context.data.scroll.modeDesktop;this.setMode(e)}updatePosition(){this.get().onCalcUpdate()}lockPageScroll(){this.setMode("disable")}unlockPageScroll(){this.updateResponsiveMode()}setMode(t){if(!this.modes.has(t)){console.warn(`[ScrollManager] Unknown scroll mode: ${t}`);return}if(this.context.data.scroll.mode===t){this.get().activate();return}this.get().deactivate(),this.context.data.scroll.mode=t,this.get().activate(),this.boundEvents?.onModeChange()}get(){return this.modes.get(this.context.data.scroll.mode)}getEngines(){return this.modes}onFrame(){this.get().onFrame()}onScroll(t){this.get().onScroll(t)}onWheel(t){this.get().onWheel(t)}onTouchStart(t){this.get().onTouchStart(t)}onTouchMove(t){this.get().onTouchMove(t)}onTouchEnd(t){this.get().onTouchEnd(t)}bindEvents(t){this.boundEvents=t,this.modes.forEach(e=>{e.onScrollStart=t.onScrollStart,e.onScrollStop=t.onScrollStop,e.onChangeDirection=t.onDirectionChange})}addScrollMark(t){this.scrollMarks.push(t),this.modes.forEach(e=>{e.addScrollMark(t)})}removeScrollMark(t){this.scrollMarks=this.scrollMarks.filter(e=>e.id!==t),this.modes.forEach(e=>{e.removeScrollMark(t)})}destroy(){this.modes.forEach(t=>{t.deactivate(),t.destroy()})}};var ke=class{targetX=0;targetY=0;smoothedX=0;smoothedY=0;stepX=0;stepY=0;velocityX=0;velocityY=0};var Ae=class{threeInstance=null};var Oe=class{target=0;current=0;transformedCurrent=0;delta=0;lerped=0;displacement=0;isScrollingDown=!1;topPosition=0;bottomPosition=0;direction="vertical";elementContainer=document.documentElement;scrollContainer=window;container=document.body;mode="smooth";modeMobile="default";modeDesktop="smooth";speed=.09;acceleration=.8;speedAccelerate=.42;smoothness=.5;multiplier=1.1;maxDelta=2400;stopThreshold=.08;decelerationCoefficient=1};var De=class{fpsTracker=!1;positionTracker=!1;suppressMasonryResize=!1};var Ie=class{now=0;previous=0;delta=0;elapsed=0};var Re=class{windowWidth=0;windowHeight=0;contentWidth=0;contentHeight=0;scaleWidth=1;scaleHeight=1;transformScale=1;baseRem=16};var He=class{scroll=new Oe;viewport=new Re;cursor=new ke;render=new Ae;time=new Ie;system=new De};var Ut=class{process({element:t}){return t.getBoundingClientRect()}};var jt=class{process({element:t,key:e,fallback:r=null}){return t.getAttribute(`string-${e}`)??t.getAttribute(`data-string-${e}`)??r}};var Yt=class{process({record:t,name:e,fallback:r=null}){return t[e]??t[`data-${e}`]??r}};var lt=class{process({element:t}){let e=t.getBoundingClientRect(),i=getComputedStyle(t).transform.match(/-?[\d.]+/g)?.map(parseFloat)??[];if(i.length===6){let[n,s,o,a,l,c]=i,u=n*a-s*o;return{width:e.width/(n||1),height:e.height/(a||1),left:(e.left*a-e.top*o+o*c-l*a)/u,top:(-e.left*s+e.top*n+l*s-n*c)/u}}return e}};var Xt=class{constructor(t=new lt){this.transformTool=t}process({element:t,container:e=document.body}){let r;try{r=e.getBoundingClientRect()}catch{r=document.body.getBoundingClientRect()}let i=this.transformTool.process({element:t});return{top:i.top-r.top,left:i.left-r.left}}};var qt=class{process({from:t,to:e,progress:r}){return(e-t)*r}};var Kt=class{process({value:t,element:e,viewportHeight:r,baseRem:i,boundingRect:n}){let o=(typeof t=="number"?String(t):t).split("|").map(l=>l.trim()).filter(Boolean),a=0;for(let l of o){let c=l,u=!1;c.startsWith("-")&&(u=!0,c=c.slice(1));let p=0;c==="selfHeight"?p=e.offsetHeight:c.endsWith("px")?p=parseFloat(c):c.endsWith("%")?p=parseFloat(c)/100*r:c.endsWith("rem")?p=parseFloat(c)*i:c.endsWith("sh")?p=parseFloat(c)*n.height/100:p=parseFloat(c),a+=u?-p:p}return a}};var Zt=class{process({value:t,inMin:e=.1,inMax:r=1,outMin:i=.05,outMax:n=.65}){if(t<e)return n;if(t>1&&(t=1),t<=r){let s=(t-e)/(r-e);return n-s*(n-i)}return i}};var mt={left:0,center:.5,right:1},ft={top:0,center:.5,bottom:1},Qt=class{process({value:t}){if(!t)return"center";let e=t.trim();if(e.startsWith("random(")&&e.endsWith(")")){let r=e.slice(7,-1).split(",").map(n=>n.trim()).filter(Boolean),i=Math.floor(Math.random()*r.length);return r[i]}return e}toNormalized({value:t}){let r=this.process({value:t}).toLowerCase().split(/\s+/).filter(Boolean);