scrollcraft 2.0.8 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,8 +32,8 @@ You can also import the pipeline into your own React apps or dashboard:
32
32
  ```javascript
33
33
  import { AssetPipeline } from 'scrollcraft/pipeline';
34
34
 
35
- const pipeline = new AssetPipeline({
36
- apiKey: process.env.FAL_KEY,
35
+ const pipeline = new AssetPipeline({
36
+ apiKey: process.env.FAL_KEY,
37
37
  onProgress: (p) => console.log(`${p.step}: ${p.percent}%`)
38
38
  });
39
39
 
@@ -56,7 +56,7 @@ import { ScrollCraftProvider, ScrollCraftCanvas, SubjectLayer } from 'scrollcraf
56
56
  const App = () => (
57
57
  <ScrollCraftProvider
58
58
  project={project}
59
- scrub={0.1} // Smooth interpolation (0 = instant, 1 = heavy lag)
59
+ scrub={0.1} // Smooth interpolation (0 = instant, 1 = 1 second lag)
60
60
  >
61
61
  <div style={{ height: '400vh' }}>
62
62
  <ScrollCraftCanvas />
@@ -77,13 +77,13 @@ const App = () => (
77
77
  Choose your path based on your role:
78
78
 
79
79
  ### 👤 For Humans
80
- - [**Core Architecture**](https://github.com/aleskozelsky/scrollcraft/blob/main/packages/docs/app/architecture/page.md): Understand the state-snapshot engine.
81
- - [**Asset Pipeline**](https://github.com/aleskozelsky/scrollcraft/blob/main/packages/docs/app/asset-pipeline/page.md): Learn how to use the CLI and AI tracking.
82
- - [**React Hooks**](https://github.com/aleskozelsky/scrollcraft/blob/main/packages/docs/app/react-integration/page.md): Build custom interactive components.
80
+ - [**Core Architecture**](https://github.com/aleskozelsky/scrollcraft/blob/main/packages/docs/content/architecture.md): Understand the state-snapshot engine.
81
+ - [**Asset Pipeline**](https://github.com/aleskozelsky/scrollcraft/blob/main/packages/docs/content/asset-pipeline.md): Learn how to use the CLI and AI tracking.
82
+ - [**React Hooks**](https://github.com/aleskozelsky/scrollcraft/blob/main/packages/docs/content/react-integration.md): Build custom interactive components.
83
83
 
84
84
  ### 🤖 For AI Agents
85
85
  - [**AGENTS.md**](https://github.com/aleskozelsky/scrollcraft/blob/main/AGENTS.md): Technical standard operating procedures for the repository.
86
- - [**AI Integration Protocol**](https://github.com/aleskozelsky/scrollcraft/blob/main/packages/docs/app/ai-integration/page.md): How to prompt agents to build scenes for you.
86
+ - [**AI Integration Protocol**](https://github.com/aleskozelsky/scrollcraft/blob/main/packages/docs/content/ai-integration.md): How to prompt agents to build scenes for you.
87
87
 
88
88
  ---
89
89
 
@@ -14,6 +14,7 @@ export declare class CoreEngine {
14
14
  private renderer;
15
15
  basePath: string;
16
16
  scrub: number;
17
+ depthTilt: number;
17
18
  private targetProgress;
18
19
  private currentProgress;
19
20
  private rafId;
@@ -23,9 +24,11 @@ export declare class CoreEngine {
23
24
  private scrollTimeout;
24
25
  private trackingDataCache;
25
26
  onFrameChange?: (frame: number, progress: number) => void;
27
+ onProgressUpdate?: (progress: number) => void;
26
28
  private boundResize;
27
29
  constructor(config: ProjectConfiguration, options?: {
28
30
  scrub?: number;
31
+ depthTilt?: number;
29
32
  });
30
33
  destroy(): void;
31
34
  static init(container: HTMLElement, configUrl: string): Promise<CoreEngine>;
@@ -48,6 +51,7 @@ export declare class CoreEngine {
48
51
  * Sets the target scroll progress. Actual rendering interpolates to this value.
49
52
  */
50
53
  update(progress: number): void;
54
+ setDepthTilt(tilt: number): void;
51
55
  private updateLoop;
52
56
  private calculateFrame;
53
57
  /**
@@ -0,0 +1,39 @@
1
+ import { CoreEngine } from './CoreEngine';
2
+ export interface CoreOrchestratorOptions {
3
+ scrub?: number;
4
+ depthTilt?: number;
5
+ }
6
+ /**
7
+ * CORE ORCHESTRATOR
8
+ *
9
+ * Bridges the DOM (React or Vanilla HTML) with the ScrollCraft CoreEngine.
10
+ * Parses `data-scft-*` attributes, initializes the WebGL canvas,
11
+ * and sets up `motion.dev` scroll synchronization.
12
+ */
13
+ export declare class CoreOrchestrator {
14
+ private container;
15
+ private options;
16
+ private engine;
17
+ private motionScrollCancel?;
18
+ private syncedAnimations;
19
+ private destroyed;
20
+ onFrameChange?: (frame: number, scrubbedProgress: number) => void;
21
+ constructor(container: HTMLElement, options?: CoreOrchestratorOptions);
22
+ private static stylesInjected;
23
+ private injectStyles;
24
+ /**
25
+ * Helper to auto-initialize all .scft-container elements on a page
26
+ */
27
+ static initAll(): Promise<CoreOrchestrator[]>;
28
+ /**
29
+ * Initializes the engine by scanning the container's DOM.
30
+ */
31
+ init(): Promise<void>;
32
+ private loadEngine;
33
+ private setupScrollTracking;
34
+ private parseAnimatedElements;
35
+ private syncAnimations;
36
+ private syncTrackingLayers;
37
+ getEngine(): CoreEngine | null;
38
+ destroy(): void;
39
+ }
@@ -7,7 +7,11 @@ export declare class WebGLRenderer {
7
7
  private targetMouse;
8
8
  private currentMouse;
9
9
  private animationFrameId;
10
- constructor(canvas: HTMLCanvasElement);
10
+ private depthTilt;
11
+ constructor(canvas: HTMLCanvasElement, options?: {
12
+ depthTilt?: number;
13
+ });
14
+ setDepthTilt(tilt: number): void;
11
15
  private createProgram;
12
16
  private animate;
13
17
  render(img: HTMLImageElement, depthImg: HTMLImageElement | null, width: number, height: number): void;
@@ -1,4 +1,10 @@
1
+ import { CoreEngine } from './CoreEngine';
2
+ import { CoreOrchestrator } from './CoreOrchestrator';
1
3
  export * from './types';
2
4
  export { CoreEngine } from './CoreEngine';
3
- import { CoreEngine } from './CoreEngine';
4
- export default CoreEngine;
5
+ export * from './WebGLRenderer';
6
+ export { CoreOrchestrator } from './CoreOrchestrator';
7
+ declare const ScrollCraft: typeof CoreEngine & {
8
+ CoreOrchestrator: typeof CoreOrchestrator;
9
+ };
10
+ export default ScrollCraft;
@@ -11,4 +11,4 @@
11
11
  */
12
12
 
13
13
 
14
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ScrollCraft=e():t.ScrollCraft=e()}(this,()=>(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>a});class i{constructor(t){if(this.targetMouse={x:0,y:0},this.currentMouse={x:0,y:0},this.animationFrameId=0,this.animate=()=>{if(this.currentMouse.x+=.1*(this.targetMouse.x-this.currentMouse.x),this.currentMouse.y+=.1*(this.targetMouse.y-this.currentMouse.y),this.gl&&this.program){this.gl.useProgram(this.program);const t=this.gl.getUniformLocation(this.program,"u_mouse");this.gl.uniform2f(t,this.currentMouse.x,this.currentMouse.y),this.draw()}this.animationFrameId=requestAnimationFrame(this.animate)},this.gl=t.getContext("webgl",{alpha:!1,antialias:!1}),!this.gl)throw new Error("WebGL not supported");this.program=this.createProgram("\n attribute vec2 a_position;\n varying vec2 v_texCoord;\n void main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n // Convert -1 -> 1 to 0 -> 1 for UVs\n v_texCoord = a_position * 0.5 + 0.5;\n v_texCoord.y = 1.0 - v_texCoord.y;\n }\n ","\n precision mediump float;\n uniform sampler2D u_image;\n uniform sampler2D u_depthMap;\n uniform vec2 u_resolution;\n uniform vec2 u_imageResolution;\n uniform vec2 u_mouse;\n uniform bool u_hasDepth;\n varying vec2 v_texCoord;\n\n void main() {\n // object-fit: cover math\n vec2 ratio = vec2(\n min((u_resolution.x / u_resolution.y) / (u_imageResolution.x / u_imageResolution.y), 1.0),\n min((u_resolution.y / u_resolution.x) / (u_imageResolution.y / u_imageResolution.x), 1.0)\n );\n vec2 uv = vec2(\n v_texCoord.x * ratio.x + (1.0 - ratio.x) * 0.5,\n v_texCoord.y * ratio.y + (1.0 - ratio.y) * 0.5\n );\n\n if (u_hasDepth) {\n float depth = texture2D(u_depthMap, uv).r;\n // White is close (1), Black is far (0). We move close objects more.\n vec2 parallax = u_mouse * depth * 0.04;\n uv += parallax;\n }\n \n gl_FragColor = texture2D(u_image, uv);\n }\n "),this.gl.useProgram(this.program),this.positionBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),this.gl.STATIC_DRAW),this.texture=this.gl.createTexture(),this.depthTexture=this.gl.createTexture(),window.addEventListener("mousemove",t=>{this.targetMouse.x=t.clientX/window.innerWidth*2-1,this.targetMouse.y=-t.clientY/window.innerHeight*2+1}),this.animate()}createProgram(t,e){const i=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(i,t),this.gl.compileShader(i);const s=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(s,e),this.gl.compileShader(s);const r=this.gl.createProgram();return this.gl.attachShader(r,i),this.gl.attachShader(r,s),this.gl.linkProgram(r),r}render(t,e,i,s){this.gl.useProgram(this.program),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.texture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this.depthTexture),e&&(this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR)),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_image"),0),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_depthMap"),1),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_hasDepth"),e?1:0),this.gl.uniform2f(this.gl.getUniformLocation(this.program,"u_resolution"),i,s),this.gl.uniform2f(this.gl.getUniformLocation(this.program,"u_imageResolution"),t.naturalWidth,t.naturalHeight);const r=this.gl.getAttribLocation(this.program,"a_position");this.gl.enableVertexAttribArray(r),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),this.gl.vertexAttribPointer(r,2,this.gl.FLOAT,!1,0,0),this.gl.viewport(0,0,i,s),this.draw()}draw(){this.gl.drawArrays(this.gl.TRIANGLES,0,6)}destroy(){cancelAnimationFrame(this.animationFrameId)}}var s=function(t,e,i,s){return new(i||(i=Promise))(function(r,a){function n(t){try{h(s.next(t))}catch(t){a(t)}}function o(t){try{h(s.throw(t))}catch(t){a(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(n,o)}h((s=s.apply(t,e||[])).next())})};class r{constructor(t,e={}){this.currentFrame=-1,this.activeVariant=null,this.canvas=null,this.ctx=null,this.renderer=null,this.basePath="",this.scrub=0,this.targetProgress=0,this.currentProgress=0,this.rafId=0,this.destroyed=!1,this.imageCache=new Map,this.depthCache=new Map,this.scrollTimeout=null,this.trackingDataCache=new Map,this.config=t,this.basePath=t.settings.basePath||"",this.scrub=e.scrub||0,this.detectBestVariant(),this.boundResize=()=>{this.detectBestVariant(),this.resizeCanvas(),this.render()},window.addEventListener("resize",this.boundResize),this.updateLoop=this.updateLoop.bind(this),this.rafId=requestAnimationFrame(this.updateLoop)}destroy(){this.destroyed=!0,this.rafId&&cancelAnimationFrame(this.rafId),window.removeEventListener("resize",this.boundResize),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.clearCache(),this.trackingDataCache.clear(),this.canvas=null,this.ctx=null,this.renderer=null,this.onFrameChange=void 0}static init(t,e){return s(this,void 0,void 0,function*(){const i=yield fetch(e);if(!i.ok)throw new Error(`Failed to load config: ${i.statusText}`);const s=yield i.json(),a=e.substring(0,e.lastIndexOf("/"));s.settings||(s.settings={baseResolution:{width:1920,height:1080},scrollMode:"vh"}),s.settings.basePath=s.settings.basePath||a;const n=new r(s,{scrub:"object"==typeof s.settings?s.settings.scrub:0});let o=t.querySelector("canvas");return o||(o=document.createElement("canvas"),o.style.width="100%",o.style.height="100%",o.style.display="block",o.style.objectFit="cover",t.appendChild(o)),n.attachCanvas(o),n})}attachCanvas(t){this.canvas=t;try{this.renderer=new i(t)}catch(e){console.warn("WebGL failed, falling back to 2D",e),this.ctx=t.getContext("2d",{alpha:!1})}this.resizeCanvas(),this.render()}resizeCanvas(){if(!this.canvas)return;const t=window.innerWidth,e=window.innerHeight,i=window.devicePixelRatio||1;this.canvas.width=t*i,this.canvas.height=e*i,this.ctx&&this.ctx.scale(i,i)}detectBestVariant(){var t;const e=this.config.assets[0];if(!e)return;const i=this.canvas?this.canvas.getBoundingClientRect():{width:window.innerWidth,height:window.innerHeight},s=i.height>i.width,r=i.width*(window.devicePixelRatio||1),a=e.variants.filter(t=>{const e="portrait"===t.orientation||parseInt(t.aspectRatio.split(":")[1])>parseInt(t.aspectRatio.split(":")[0]);return s===e});a.sort((t,e)=>t.frameCount-e.frameCount);const n=a.find(t=>t.width>=r)||a[a.length-1];n?(null===(t=this.activeVariant)||void 0===t?void 0:t.id)!==n.id&&(console.log(`🎯 Variant Switched: ${n.id} (${s?"Portrait":"Landscape"})`),this.activeVariant=n,this.clearCache(),this.preloadInitial()):console.warn("[CoreEngine] No suitable variant found")}clearCache(){this.imageCache.clear(),this.depthCache.clear()}preloadInitial(){for(let t=0;t<15;t++)this.getImage(t)}update(t){this.targetProgress=Math.max(0,Math.min(1,t))}updateLoop(){if(this.destroyed)return;this.rafId=requestAnimationFrame(this.updateLoop);const t=this.scrub;if(t>0){const e=Math.max(.01,1-t);this.currentProgress+=(this.targetProgress-this.currentProgress)*e}else this.currentProgress=this.targetProgress;Math.abs(this.targetProgress-this.currentProgress)<1e-4&&(this.currentProgress=this.targetProgress),this.calculateFrame(this.currentProgress)}calculateFrame(t){const e=this.config.timeline.scenes[0];if(!e)return;const i=e.assetRange[1]-e.assetRange[0],s=Math.floor(e.assetRange[0]+t*i),r=Math.max(0,Math.min(s,e.assetRange[1]));r!==this.currentFrame&&(this.currentFrame=r,this.render(),this.getImage(this.currentFrame+5),this.getImage(this.currentFrame+10),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{this.loadDepthMap(this.currentFrame)},100),this.onFrameChange&&this.onFrameChange(this.currentFrame,t))}loadTrackingData(t){return s(this,void 0,void 0,function*(){var e;if(!this.activeVariant)return;if(!(null===(e=this.activeVariant.subjects)||void 0===e?void 0:e.includes(t)))return void console.warn(`[CoreEngine] Subject ${t} not found in active variant ${this.activeVariant.id}`);const i=`${this.activeVariant.id}_${t}`;if(!this.trackingDataCache.has(i))try{const e=`${this.basePath?`${this.basePath}/`:""}${this.activeVariant.path}/000_tracking-${t}.json`;console.log(`[CoreEngine] Fetching tracking data: ${e}`);const s=yield fetch(e);if(!s.ok)throw new Error(s.statusText);const r=yield s.json();this.trackingDataCache.set(i,r)}catch(e){console.error(`[CoreEngine] Failed to load tracking data for ${t}`,e)}})}getTrackedCoords(t,e){if(!this.activeVariant)return{x:.5,y:.5};const i=`${this.activeVariant.id}_${t}`,s=this.trackingDataCache.get(i);if(!s)return{x:.5,y:.5};const r=s.find(t=>t.frame===e);return r?{x:r.x,y:r.y,scale:r.scale}:{x:.5,y:.5}}render(){var t;if(!this.canvas||-1===this.currentFrame)return;const e=this.getImage(this.currentFrame);if(!e||!e.complete)return;const i=window.innerWidth,s=window.innerHeight;let r=null;if((null===(t=this.activeVariant)||void 0===t?void 0:t.hasDepthMap)&&(r=this.getDepthImage(this.currentFrame),r&&!r.complete&&(r=null)),this.renderer)this.renderer.render(e,r,i*(window.devicePixelRatio||1),s*(window.devicePixelRatio||1));else if(this.ctx){const t=e.naturalWidth/e.naturalHeight;let r,a,n,o;t>i/s?(a=s,r=s*t,n=(i-r)/2,o=0):(r=i,a=i/t,n=0,o=(s-a)/2),this.ctx.clearRect(0,0,i,s),this.ctx.drawImage(e,n,o,r,a)}}getImage(t){if(!this.activeVariant)return null;if(t<0||t>=this.activeVariant.frameCount)return null;const e=`${this.activeVariant.id}_${t}`;if(this.imageCache.has(e))return this.imageCache.get(e);const i=this.basePath?`${this.basePath}/`:"",s=new Image;return s.crossOrigin="anonymous",s.src=`${i}${this.activeVariant.path}/index_${t}.webp`,s.onload=()=>{this.currentFrame===t&&this.render()},this.imageCache.set(e,s),s}loadDepthMap(t){var e;if(!(null===(e=this.activeVariant)||void 0===e?void 0:e.hasDepthMap))return void console.log("[CoreEngine] activeVariant does not define hasDepthMap=true");console.log(`[CoreEngine] Lazy requesting depth map for frame: ${t}`);this.getDepthImage(t)}getDepthImage(t){var e;if(!(null===(e=this.activeVariant)||void 0===e?void 0:e.hasDepthMap))return null;if(t<0||t>=this.activeVariant.frameCount)return null;const i=`${this.activeVariant.id}_depth_${t}`;if(this.depthCache.has(i))return this.depthCache.get(i);const s=this.basePath?`${this.basePath}/`:"";console.log(`[CoreEngine] Downloading: ${s}${this.activeVariant.path}/index_${t}_depth.webp`);const r=new Image;return r.crossOrigin="anonymous",r.src=`${s}${this.activeVariant.path}/index_${t}_depth.webp`,r.onload=()=>{console.log(`[CoreEngine] Depth map loaded for frame: ${t}`),this.currentFrame===t&&this.render()},r.onerror=e=>{console.error(`[CoreEngine] Depth map failed to load for frame: ${t}`,e)},this.depthCache.set(i,r),r}}const a=r;return e=e.default})());
14
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ScrollCraft=e():t.ScrollCraft=e()}(this,()=>(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>Zs});class n{constructor(t,e={}){if(this.targetMouse={x:0,y:0},this.currentMouse={x:0,y:0},this.animationFrameId=0,this.depthTilt=.04,this.animate=()=>{if(this.currentMouse.x+=.1*(this.targetMouse.x-this.currentMouse.x),this.currentMouse.y+=.1*(this.targetMouse.y-this.currentMouse.y),this.gl&&this.program){this.gl.useProgram(this.program);const t=this.gl.getUniformLocation(this.program,"u_mouse");this.gl.uniform2f(t,this.currentMouse.x,this.currentMouse.y);const e=this.gl.getUniformLocation(this.program,"u_depthTilt");this.gl.uniform1f(e,this.depthTilt),this.draw()}this.animationFrameId=requestAnimationFrame(this.animate)},this.depthTilt=void 0!==e.depthTilt?e.depthTilt:4,this.gl=t.getContext("webgl",{alpha:!1,antialias:!1}),!this.gl)throw new Error("WebGL not supported");this.program=this.createProgram("\n attribute vec2 a_position;\n varying vec2 v_texCoord;\n void main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n // Convert -1 -> 1 to 0 -> 1 for UVs\n v_texCoord = a_position * 0.5 + 0.5;\n v_texCoord.y = 1.0 - v_texCoord.y;\n }\n ","\n precision mediump float;\n uniform sampler2D u_image;\n uniform sampler2D u_depthMap;\n uniform vec2 u_resolution;\n uniform vec2 u_imageResolution;\n uniform vec2 u_mouse;\n uniform float u_depthTilt;\n uniform bool u_hasDepth;\n varying vec2 v_texCoord;\n\n void main() {\n // object-fit: cover math\n vec2 ratio = vec2(\n min((u_resolution.x / u_resolution.y) / (u_imageResolution.x / u_imageResolution.y), 1.0),\n min((u_resolution.y / u_resolution.x) / (u_imageResolution.y / u_imageResolution.x), 1.0)\n );\n vec2 uv = vec2(\n v_texCoord.x * ratio.x + (1.0 - ratio.x) * 0.5,\n v_texCoord.y * ratio.y + (1.0 - ratio.y) * 0.5\n );\n\n if (u_hasDepth) {\n float depth = texture2D(u_depthMap, uv).r;\n // White is close (1), Black is far (0).\n // By making the background move and the foreground stay still (using 1.0 - depth)\n // and subtracting the parallax, the background pulls the foreground over itself,\n // expanding the edges and creating proper occlusion, instead of collapsing/tearing.\n // depthTilt is scaled by 0.01 internally (so 100 = 1.0 peak displacement)\n vec2 parallax = u_mouse * (1.0 - depth) * (u_depthTilt * 0.01);\n uv -= parallax;\n }\n \n gl_FragColor = texture2D(u_image, uv);\n }\n "),this.gl.useProgram(this.program),this.positionBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),this.gl.STATIC_DRAW),this.texture=this.gl.createTexture(),this.depthTexture=this.gl.createTexture(),window.addEventListener("mousemove",t=>{this.targetMouse.x=t.clientX/window.innerWidth*2-1,this.targetMouse.y=t.clientY/window.innerHeight*2-1}),this.animate()}setDepthTilt(t){this.depthTilt=t}createProgram(t,e){const n=this.gl.createShader(this.gl.VERTEX_SHADER);this.gl.shaderSource(n,t),this.gl.compileShader(n);const i=this.gl.createShader(this.gl.FRAGMENT_SHADER);this.gl.shaderSource(i,e),this.gl.compileShader(i);const s=this.gl.createProgram();return this.gl.attachShader(s,n),this.gl.attachShader(s,i),this.gl.linkProgram(s),s}render(t,e,n,i){this.gl.useProgram(this.program),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.texture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this.depthTexture),e&&(this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR)),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_image"),0),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_depthMap"),1),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_hasDepth"),e?1:0),this.gl.uniform2f(this.gl.getUniformLocation(this.program,"u_resolution"),n,i),this.gl.uniform2f(this.gl.getUniformLocation(this.program,"u_imageResolution"),t.naturalWidth,t.naturalHeight);const s=this.gl.getAttribLocation(this.program,"a_position");this.gl.enableVertexAttribArray(s),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer),this.gl.vertexAttribPointer(s,2,this.gl.FLOAT,!1,0,0),this.gl.viewport(0,0,n,i),this.draw()}draw(){this.gl.drawArrays(this.gl.TRIANGLES,0,6)}destroy(){cancelAnimationFrame(this.animationFrameId)}}var i=function(t,e,n,i){return new(n||(n=Promise))(function(s,r){function a(t){try{h(i.next(t))}catch(t){r(t)}}function o(t){try{h(i.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,o)}h((i=i.apply(t,e||[])).next())})};class s{constructor(t,e={}){this.currentFrame=-1,this.activeVariant=null,this.canvas=null,this.ctx=null,this.renderer=null,this.basePath="",this.scrub=0,this.depthTilt=4,this.targetProgress=0,this.currentProgress=0,this.rafId=0,this.destroyed=!1,this.imageCache=new Map,this.depthCache=new Map,this.scrollTimeout=null,this.trackingDataCache=new Map,this.config=t,this.basePath=t.settings.basePath||"",this.scrub=void 0!==e.scrub?e.scrub:0,this.depthTilt=void 0!==e.depthTilt?e.depthTilt:4,this.detectBestVariant(),this.boundResize=()=>{this.detectBestVariant(),this.resizeCanvas(),this.render()},window.addEventListener("resize",this.boundResize),this.updateLoop=this.updateLoop.bind(this),this.rafId=requestAnimationFrame(this.updateLoop)}destroy(){this.destroyed=!0,this.rafId&&cancelAnimationFrame(this.rafId),window.removeEventListener("resize",this.boundResize),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.clearCache(),this.trackingDataCache.clear(),this.canvas=null,this.ctx=null,this.renderer=null,this.onFrameChange=void 0}static init(t,e){return i(this,void 0,void 0,function*(){const n=yield fetch(e);if(!n.ok)throw new Error(`Failed to load config: ${n.statusText}`);const i=yield n.json(),r=e.substring(0,e.lastIndexOf("/"));i.settings||(i.settings={baseResolution:{width:1920,height:1080},scrollMode:"vh"}),i.settings.basePath=i.settings.basePath||r;const a=new s(i,{scrub:"object"==typeof i.settings?i.settings.scrub:0});let o=t.querySelector("canvas");return o||(o=document.createElement("canvas"),o.style.width="100%",o.style.height="100%",o.style.display="block",o.style.objectFit="cover",t.appendChild(o)),a.attachCanvas(o),a})}attachCanvas(t){this.canvas=t;try{this.renderer=new n(t,{depthTilt:this.depthTilt})}catch(e){console.warn("WebGL failed, falling back to 2D",e),this.ctx=t.getContext("2d",{alpha:!1})}this.resizeCanvas(),this.render()}resizeCanvas(){if(!this.canvas)return;const t=this.canvas.getBoundingClientRect(),e=t.width,n=t.height,i=window.devicePixelRatio||1;this.canvas.width=e*i,this.canvas.height=n*i,this.ctx&&this.ctx.scale(i,i)}detectBestVariant(){var t;const e=this.config.assets[0];if(!e)return;const n=this.canvas?this.canvas.getBoundingClientRect():{width:window.innerWidth,height:window.innerHeight},i=n.height>n.width,s=n.width*(window.devicePixelRatio||1),r=e.variants.filter(t=>{const e="portrait"===t.orientation||parseInt(t.aspectRatio.split(":")[1])>parseInt(t.aspectRatio.split(":")[0]);return i===e});r.sort((t,e)=>t.frameCount-e.frameCount);const a=r.find(t=>t.width>=s)||r[r.length-1];a?(null===(t=this.activeVariant)||void 0===t?void 0:t.id)!==a.id&&(console.log(`🎯 Variant Switched: ${a.id} (${i?"Portrait":"Landscape"})`),this.activeVariant=a,this.clearCache(),this.preloadInitial()):console.warn("[CoreEngine] No suitable variant found")}clearCache(){this.imageCache.clear(),this.depthCache.clear()}preloadInitial(){for(let t=0;t<15;t++)this.getImage(t)}update(t){this.targetProgress=Math.max(0,Math.min(1,t))}setDepthTilt(t){this.depthTilt=t,this.renderer&&this.renderer.setDepthTilt(t)}updateLoop(){if(this.destroyed)return;this.rafId=requestAnimationFrame(this.updateLoop);const t=this.scrub;if(t>0){const e=Math.max(.01,1-t);this.currentProgress+=(this.targetProgress-this.currentProgress)*e}else this.currentProgress=this.targetProgress;Math.abs(this.targetProgress-this.currentProgress)<1e-4&&(this.currentProgress=this.targetProgress),this.onProgressUpdate&&this.onProgressUpdate(this.currentProgress),this.calculateFrame(this.currentProgress)}calculateFrame(t){const e=this.config.timeline.scenes[0];if(!e)return;const n=e.assetRange[1]-e.assetRange[0],i=Math.floor(e.assetRange[0]+t*n),s=Math.max(0,Math.min(i,e.assetRange[1]));s!==this.currentFrame&&(this.currentFrame=s,this.render(),this.getImage(this.currentFrame+5),this.getImage(this.currentFrame+10),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{this.loadDepthMap(this.currentFrame)},100),this.onFrameChange&&this.onFrameChange(this.currentFrame,t))}loadTrackingData(t){return i(this,void 0,void 0,function*(){var e;if(!this.activeVariant)return;if(!(null===(e=this.activeVariant.subjects)||void 0===e?void 0:e.includes(t)))return void console.warn(`[CoreEngine] Subject ${t} not found in active variant ${this.activeVariant.id}`);const n=`${this.activeVariant.id}_${t}`;if(!this.trackingDataCache.has(n))try{const e=`${this.basePath?`${this.basePath}/`:""}${this.activeVariant.path}/000_tracking-${t}.json`;console.log(`[CoreEngine] Fetching tracking data: ${e}`);const i=yield fetch(e);if(!i.ok)throw new Error(i.statusText);const s=yield i.json();this.trackingDataCache.set(n,s)}catch(e){console.error(`[CoreEngine] Failed to load tracking data for ${t}`,e)}})}getTrackedCoords(t,e){if(!this.activeVariant||!this.canvas)return{x:.5,y:.5};const n=`${this.activeVariant.id}_${t}`,i=this.trackingDataCache.get(n);if(!i)return{x:.5,y:.5};const s=i.find(t=>t.frame===e);if(!s)return{x:.5,y:.5};const r=this.canvas.clientWidth/this.canvas.clientHeight,a=this.activeVariant.width/this.activeVariant.height,o=Math.min(r/a,1),h=Math.min(1/r/(1/a),1);return{x:(s.x-.5)/o+.5,y:(s.y-.5)/h+.5,scale:s.scale}}render(){var t;if(!this.canvas||-1===this.currentFrame)return;const e=this.getImage(this.currentFrame);if(!e||!e.complete)return;const n=this.canvas.clientWidth,i=this.canvas.clientHeight;let s=null;if((null===(t=this.activeVariant)||void 0===t?void 0:t.hasDepthMap)&&(s=this.getDepthImage(this.currentFrame),s&&!s.complete&&(s=null)),this.renderer)this.renderer.render(e,s,n*(window.devicePixelRatio||1),i*(window.devicePixelRatio||1));else if(this.ctx){const t=e.naturalWidth/e.naturalHeight;let s,r,a,o;t>n/i?(r=i,s=i*t,a=(n-s)/2,o=0):(s=n,r=n/t,a=0,o=(i-r)/2),this.ctx.clearRect(0,0,n,i),this.ctx.drawImage(e,a,o,s,r)}}getImage(t){if(!this.activeVariant)return null;if(t<0||t>=this.activeVariant.frameCount)return null;const e=`${this.activeVariant.id}_${t}`;if(this.imageCache.has(e))return this.imageCache.get(e);const n=this.basePath?`${this.basePath}/`:"",i=new Image;return i.crossOrigin="anonymous",i.src=`${n}${this.activeVariant.path}/index_${t}.webp`,i.onload=()=>{this.currentFrame===t&&this.render()},this.imageCache.set(e,i),i}loadDepthMap(t){var e;if(!(null===(e=this.activeVariant)||void 0===e?void 0:e.hasDepthMap))return void console.log("[CoreEngine] activeVariant does not define hasDepthMap=true");console.log(`[CoreEngine] Lazy requesting depth map for frame: ${t}`);this.getDepthImage(t)}getDepthImage(t){var e;if(!(null===(e=this.activeVariant)||void 0===e?void 0:e.hasDepthMap))return null;if(t<0||t>=this.activeVariant.frameCount)return null;const n=`${this.activeVariant.id}_depth_${t}`;if(this.depthCache.has(n))return this.depthCache.get(n);const i=this.basePath?`${this.basePath}/`:"";console.log(`[CoreEngine] Downloading: ${i}${this.activeVariant.path}/index_${t}_depth.webp`);const s=new Image;return s.crossOrigin="anonymous",s.src=`${i}${this.activeVariant.path}/index_${t}_depth.webp`,s.onload=()=>{console.log(`[CoreEngine] Depth map loaded for frame: ${t}`),this.currentFrame===t&&this.render()},s.onerror=e=>{console.error(`[CoreEngine] Depth map failed to load for frame: ${t}`,e)},this.depthCache.set(n,s),s}}const r=t=>t,a={},o=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],h={value:null,addProjectionMetrics:null};function l(t,e){let n=!1,i=!0;const s={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,l=o.reduce((t,n)=>(t[n]=function(t,e){let n=new Set,i=new Set,s=!1,r=!1;const a=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1},l=0;function c(e){a.has(e)&&(u.schedule(e),t()),l++,e(o)}const u={schedule:(t,e=!1,r=!1)=>{const o=r&&s?n:i;return e&&a.add(t),o.add(t),t},cancel:t=>{i.delete(t),a.delete(t)},process:t=>{if(o=t,s)return void(r=!0);s=!0;const a=n;n=i,i=a,n.forEach(c),e&&h.value&&h.value.frameloop[e].push(l),l=0,n.clear(),s=!1,r&&(r=!1,u.process(t))}};return u}(r,e?n:void 0),t),{}),{setup:c,read:u,resolveKeyframes:d,preUpdate:p,update:f,preRender:m,render:g,postRender:y}=l,v=()=>{const r=a.useManualTiming,o=r?s.timestamp:performance.now();n=!1,r||(s.delta=i?1e3/60:Math.max(Math.min(o-s.timestamp,40),1)),s.timestamp=o,s.isProcessing=!0,c.process(s),u.process(s),d.process(s),p.process(s),f.process(s),m.process(s),g.process(s),y.process(s),s.isProcessing=!1,n&&e&&(i=!1,t(v))};return{schedule:o.reduce((e,r)=>{const a=l[r];return e[r]=(e,r=!1,o=!1)=>(n||(n=!0,i=!0,s.isProcessing||t(v)),a.schedule(e,r,o)),e},{}),cancel:t=>{for(let e=0;e<o.length;e++)l[o[e]].cancel(t)},state:s,steps:l}}const{schedule:c,cancel:u,state:d,steps:p}=l("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:r,!0);function f(t,e){let n;const i=()=>{const{currentTime:i}=e,s=(null===i?0:i.value)/100;n!==s&&t(s),n=s};return c.preUpdate(i,!0),()=>u(i)}function m(t){let e;return()=>(void 0===e&&(e=t()),e)}const g={};function y(t,e){const n=m(t);return()=>g[e]??n()}const v=y(()=>void 0!==window.ScrollTimeline,"scrollTimeline"),b=y(()=>void 0!==window.ViewTimeline,"viewTimeline");function w(t){return"undefined"!=typeof window&&(t?b():v())}function T(t){return"object"==typeof t&&null!==t}function x(t){return T(t)&&"ownerSVGElement"in t}function M(t,e,n){if(null==t)return[];if(t instanceof EventTarget)return[t];if("string"==typeof t){let i=document;e&&(i=e.current);const s=n?.[t]??i.querySelectorAll(t);return s?Array.from(s):[]}return Array.from(t).filter(t=>null!=t)}const A=new WeakMap;let S;const E=(t,e,n)=>(i,s)=>s&&s[0]?s[0][t+"Size"]:x(i)&&"getBBox"in i?i.getBBox()[e]:i[n],C=E("inline","width","offsetWidth"),V=E("block","height","offsetHeight");function k({target:t,borderBoxSize:e}){A.get(t)?.forEach(n=>{n(t,{get width(){return C(t,e)},get height(){return V(t,e)}})})}function P(t){t.forEach(k)}function R(t,e){S||"undefined"!=typeof ResizeObserver&&(S=new ResizeObserver(P));const n=M(t);return n.forEach(t=>{let n=A.get(t);n||(n=new Set,A.set(t,n)),n.add(e),S?.observe(t)}),()=>{n.forEach(t=>{const n=A.get(t);n?.delete(e),n?.size||S?.unobserve(t)})}}const F=new Set;let D;function _(t){return F.add(t),D||(D=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};F.forEach(e=>e(t))},window.addEventListener("resize",D)),()=>{F.delete(t),F.size||"function"!=typeof D||(window.removeEventListener("resize",D),D=void 0)}}const B=(t,e,n)=>{const i=e-t;return 0===i?1:(n-t)/i};function I(t,e){return e?t*(1e3/e):0}const O={x:{length:"Width",position:"Left"},y:{length:"Height",position:"Top"}};function L(t,e,n,i){const s=n[e],{length:r,position:a}=O[e],o=s.current,h=n.time;s.current=Math.abs(t[`scroll${a}`]),s.scrollLength=t[`scroll${r}`]-t[`client${r}`],s.offset.length=0,s.offset[0]=0,s.offset[1]=s.scrollLength,s.progress=B(0,s.scrollLength,s.current);const l=i-h;s.velocity=l>50?0:I(s.current-o,l)}const W=(t,e)=>n=>e(t(n)),$=(...t)=>t.reduce(W);const j=(t,e,n)=>n>e?e:n<t?t:n,N=t=>e=>"string"==typeof e&&e.startsWith(t),U=N("--"),X=N("var(--"),z=t=>!!X(t)&&K.test(t.split("/*")[0].trim()),K=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Y(t){return"string"==typeof t&&t.split("/*")[0].includes("var(--")}const H={test:t=>"number"==typeof t,parse:parseFloat,transform:t=>t},q={...H,transform:t=>j(0,1,t)},G={...H,default:1},Z=t=>Math.round(1e5*t)/1e5,J=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;const Q=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,tt=(t,e)=>n=>Boolean("string"==typeof n&&Q.test(n)&&n.startsWith(t)||e&&!function(t){return null==t}(n)&&Object.prototype.hasOwnProperty.call(n,e)),et=(t,e,n)=>i=>{if("string"!=typeof i)return i;const[s,r,a,o]=i.match(J);return{[t]:parseFloat(s),[e]:parseFloat(r),[n]:parseFloat(a),alpha:void 0!==o?parseFloat(o):1}},nt={...H,transform:t=>Math.round((t=>j(0,255,t))(t))},it={test:tt("rgb","red"),parse:et("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:i=1})=>"rgba("+nt.transform(t)+", "+nt.transform(e)+", "+nt.transform(n)+", "+Z(q.transform(i))+")"};const st={test:tt("#"),parse:function(t){let e="",n="",i="",s="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),i=t.substring(5,7),s=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),i=t.substring(3,4),s=t.substring(4,5),e+=e,n+=n,i+=i,s+=s),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:s?parseInt(s,16)/255:1}},transform:it.transform},rt=t=>({test:e=>"string"==typeof e&&e.endsWith(t)&&1===e.split(" ").length,parse:parseFloat,transform:e=>`${e}${t}`}),at=rt("deg"),ot=rt("%"),ht=rt("px"),lt=rt("vh"),ct=rt("vw"),ut=(()=>({...ot,parse:t=>ot.parse(t)/100,transform:t=>ot.transform(100*t)}))(),dt={test:tt("hsl","hue"),parse:et("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:i=1})=>"hsla("+Math.round(t)+", "+ot.transform(Z(e))+", "+ot.transform(Z(n))+", "+Z(q.transform(i))+")"},pt={test:t=>it.test(t)||st.test(t)||dt.test(t),parse:t=>it.test(t)?it.parse(t):dt.test(t)?dt.parse(t):st.parse(t),transform:t=>"string"==typeof t?t:t.hasOwnProperty("red")?it.transform(t):dt.transform(t),getAnimatableNone:t=>{const e=pt.parse(t);return e.alpha=0,pt.transform(e)}},ft=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;const mt="number",gt="color",yt=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function vt(t){const e=t.toString(),n=[],i={color:[],number:[],var:[]},s=[];let r=0;const a=e.replace(yt,t=>(pt.test(t)?(i.color.push(r),s.push(gt),n.push(pt.parse(t))):t.startsWith("var(")?(i.var.push(r),s.push("var"),n.push(t)):(i.number.push(r),s.push(mt),n.push(parseFloat(t))),++r,"${}")).split("${}");return{values:n,split:a,indexes:i,types:s}}function bt({split:t,types:e}){const n=t.length;return i=>{let s="";for(let r=0;r<n;r++)if(s+=t[r],void 0!==i[r]){const t=e[r];s+=t===mt?Z(i[r]):t===gt?pt.transform(i[r]):i[r]}return s}}const wt=(t,e)=>{return"number"==typeof t?e?.trim().endsWith("/")?t:0:"number"==typeof(n=t)?0:pt.test(n)?pt.getAnimatableNone(n):n;var n};const Tt={test:function(t){return isNaN(t)&&"string"==typeof t&&(t.match(J)?.length||0)+(t.match(ft)?.length||0)>0},parse:function(t){return vt(t).values},createTransformer:function(t){return bt(vt(t))},getAnimatableNone:function(t){const e=vt(t);return bt(e)(e.values.map((t,n)=>wt(t,e.split[n])))}};function xt(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function Mt(t,e){return n=>n>0?e:t}const At=(t,e,n)=>t+(e-t)*n,St=(t,e,n)=>{const i=t*t,s=n*(e*e-i)+i;return s<0?0:Math.sqrt(s)},Et=[st,it,dt];function Ct(t){const e=(n=t,Et.find(t=>t.test(n)));var n;if(Boolean(e),!Boolean(e))return!1;let i=e.parse(t);return e===dt&&(i=function({hue:t,saturation:e,lightness:n,alpha:i}){t/=360,n/=100;let s=0,r=0,a=0;if(e/=100){const i=n<.5?n*(1+e):n+e-n*e,o=2*n-i;s=xt(o,i,t+1/3),r=xt(o,i,t),a=xt(o,i,t-1/3)}else s=r=a=n;return{red:Math.round(255*s),green:Math.round(255*r),blue:Math.round(255*a),alpha:i}}(i)),i}const Vt=(t,e)=>{const n=Ct(t),i=Ct(e);if(!n||!i)return Mt(t,e);const s={...n};return t=>(s.red=St(n.red,i.red,t),s.green=St(n.green,i.green,t),s.blue=St(n.blue,i.blue,t),s.alpha=At(n.alpha,i.alpha,t),it.transform(s))},kt=new Set(["none","hidden"]);function Pt(t,e){return n=>At(t,e,n)}function Rt(t){return"number"==typeof t?Pt:"string"==typeof t?z(t)?Mt:pt.test(t)?Vt:_t:Array.isArray(t)?Ft:"object"==typeof t?pt.test(t)?Vt:Dt:Mt}function Ft(t,e){const n=[...t],i=n.length,s=t.map((t,n)=>Rt(t)(t,e[n]));return t=>{for(let e=0;e<i;e++)n[e]=s[e](t);return n}}function Dt(t,e){const n={...t,...e},i={};for(const s in n)void 0!==t[s]&&void 0!==e[s]&&(i[s]=Rt(t[s])(t[s],e[s]));return t=>{for(const e in i)n[e]=i[e](t);return n}}const _t=(t,e)=>{const n=Tt.createTransformer(e),i=vt(t),s=vt(e);return i.indexes.var.length===s.indexes.var.length&&i.indexes.color.length===s.indexes.color.length&&i.indexes.number.length>=s.indexes.number.length?kt.has(t)&&!s.values.length||kt.has(e)&&!i.values.length?function(t,e){return kt.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}(t,e):$(Ft(function(t,e){const n=[],i={color:0,var:0,number:0};for(let s=0;s<e.values.length;s++){const r=e.types[s],a=t.indexes[r][i[r]],o=t.values[a]??0;n[s]=o,i[r]++}return n}(i,s),s.values),n):Mt(t,e)};function Bt(t,e,n){if("number"==typeof t&&"number"==typeof e&&"number"==typeof n)return At(t,e,n);return Rt(t)(t,e)}function It(t,e,{clamp:n=!0,ease:i,mixer:s}={}){const o=t.length;if(e.length,1===o)return()=>e[0];if(2===o&&e[0]===e[1])return()=>e[1];const h=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const l=function(t,e,n){const i=[],s=n||a.mix||Bt,o=t.length-1;for(let n=0;n<o;n++){let a=s(t[n],t[n+1]);if(e){const t=Array.isArray(e)?e[n]||r:e;a=$(t,a)}i.push(a)}return i}(e,i,s),c=l.length,u=n=>{if(h&&n<t[0])return e[0];let i=0;if(c>1)for(;i<t.length-2&&!(n<t[i+1]);i++);const s=B(t[i],t[i+1],n);return l[i](s)};return n?e=>u(j(t[0],t[o-1],e)):u}function Ot(t,e){const n=t[t.length-1];for(let i=1;i<=e;i++){const s=B(0,e,i);t.push(At(n,1,s))}}function Lt(t){const e=[0];return Ot(e,t.length-1),e}function Wt(t){return T(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const $t={start:0,center:.5,end:1};function jt(t,e,n=0){let i=0;if(t in $t&&(t=$t[t]),"string"==typeof t){const e=parseFloat(t);t.endsWith("px")?i=e:t.endsWith("%")?t=e/100:t.endsWith("vw")?i=e/100*document.documentElement.clientWidth:t.endsWith("vh")?i=e/100*document.documentElement.clientHeight:t=e}return"number"==typeof t&&(i=e*t),n+i}const Nt=[0,0];function Ut(t,e,n,i){let s=Array.isArray(t)?t:Nt,r=0,a=0;return"number"==typeof t?s=[t,t]:"string"==typeof t&&(s=(t=t.trim()).includes(" ")?t.split(" "):[t,$t[t]?t:"0"]),r=jt(s[0],n,i),a=jt(s[1],e),r-a}const Xt={Enter:[[0,1],[1,1]],Exit:[[0,0],[1,0]],Any:[[1,0],[0,1]],All:[[0,0],[1,1]]},zt={x:0,y:0};function Kt(t,e,n){const{offset:i=Xt.All}=n,{target:s=t,axis:r="y"}=n,a="y"===r?"height":"width",o=s!==t?function(t,e){const n={x:0,y:0};let i=t;for(;i&&i!==e;)if(Wt(i))n.x+=i.offsetLeft,n.y+=i.offsetTop,i=i.offsetParent;else if("svg"===i.tagName){const t=i.getBoundingClientRect();i=i.parentElement;const e=i.getBoundingClientRect();n.x+=t.left-e.left,n.y+=t.top-e.top}else{if(!(i instanceof SVGGraphicsElement))break;{const{x:t,y:e}=i.getBBox();n.x+=t,n.y+=e;let s=null,r=i.parentNode;for(;!s;)"svg"===r.tagName&&(s=r),r=i.parentNode;i=s}}return n}(s,t):zt,h=s===t?{width:t.scrollWidth,height:t.scrollHeight}:function(t){return"getBBox"in t&&"svg"!==t.tagName?t.getBBox():{width:t.clientWidth,height:t.clientHeight}}(s),l={width:t.clientWidth,height:t.clientHeight};e[r].offset.length=0;let c=!e[r].interpolate;const u=i.length;for(let t=0;t<u;t++){const n=Ut(i[t],l[a],h[a],o[r]);c||n===e[r].interpolatorOffsets[t]||(c=!0),e[r].offset[t]=n}c&&(e[r].interpolate=It(e[r].offset,Lt(i),{clamp:!1}),e[r].interpolatorOffsets=[...e[r].offset]),e[r].progress=j(0,1,e[r].interpolate(e[r].current))}function Yt(t,e,n,i={}){return{measure:e=>{!function(t,e=t,n){if(n.x.targetOffset=0,n.y.targetOffset=0,e!==t){let i=e;for(;i&&i!==t;)n.x.targetOffset+=i.offsetLeft,n.y.targetOffset+=i.offsetTop,i=i.offsetParent}n.x.targetLength=e===t?e.scrollWidth:e.clientWidth,n.y.targetLength=e===t?e.scrollHeight:e.clientHeight,n.x.containerLength=t.clientWidth,n.y.containerLength=t.clientHeight}(t,i.target,n),function(t,e,n){L(t,"x",e,n),L(t,"y",e,n),e.time=n}(t,n,e),(i.offset||i.target)&&Kt(t,n,i)},notify:()=>e(n)}}const Ht=new WeakMap,qt=new WeakMap,Gt=new WeakMap,Zt=new WeakMap,Jt=new WeakMap,Qt=t=>t===document.scrollingElement?window:t;function te(t,{container:e=document.scrollingElement,trackContentSize:n=!1,...i}={}){if(!e)return r;let s=Gt.get(e);s||(s=new Set,Gt.set(e,s));const a=Yt(e,t,{time:0,x:{current:0,offset:[],progress:0,scrollLength:0,targetOffset:0,targetLength:0,containerLength:0,velocity:0},y:{current:0,offset:[],progress:0,scrollLength:0,targetOffset:0,targetLength:0,containerLength:0,velocity:0}},i);if(s.add(a),!Ht.has(e)){const t=()=>{for(const t of s)t.measure(d.timestamp);c.preUpdate(n)},n=()=>{for(const t of s)t.notify()},i=()=>c.read(t);Ht.set(e,i);const r=Qt(e);window.addEventListener("resize",i),e!==document.documentElement&&qt.set(e,(h=i,"function"==typeof(o=e)?_(o):R(o,h))),r.addEventListener("scroll",i),i()}var o,h;if(n&&!Jt.has(e)){const t=Ht.get(e),n={width:e.scrollWidth,height:e.scrollHeight};Zt.set(e,n);const i=()=>{const i=e.scrollWidth,s=e.scrollHeight;n.width===i&&n.height===s||(t(),n.width=i,n.height=s)},s=c.read(i,!0);Jt.set(e,s)}const l=Ht.get(e);return c.read(l,!1,!0),()=>{u(l);const t=Gt.get(e);if(!t)return;if(t.delete(a),t.size)return;const n=Ht.get(e);Ht.delete(e),n&&(Qt(e).removeEventListener("scroll",n),qt.get(e)?.(),window.removeEventListener("resize",n));const i=Jt.get(e);i&&(u(i),Jt.delete(e)),Zt.delete(e)}}const ee=[[Xt.Enter,"entry"],[Xt.Exit,"exit"],[Xt.Any,"cover"],[Xt.All,"contain"]];function ne(t,e){if(2!==t.length)return!1;for(let n=0;n<2;n++){const i=t[n],s=e[n];if(!Array.isArray(i)||2!==i.length||i[0]!==s[0]||i[1]!==s[1])return!1}return!0}function ie(t){if(!t)return{rangeStart:"contain 0%",rangeEnd:"contain 100%"};for(const[e,n]of ee)if(ne(t,e))return{rangeStart:`${n} 0%`,rangeEnd:`${n} 100%`}}const se=new Map;function re(t){const e={value:0},n=te(n=>{e.value=100*n[t.axis].progress},t);return{currentTime:e,cancel:n}}function ae({source:t,container:e,...n}){const{axis:i}=n;t&&(e=t);let s=se.get(e);s||(s=new Map,se.set(e,s));const r=n.target??"self";let a=s.get(r);a||(a={},s.set(r,a));const o=i+(n.offset??[]).join(",");if(!a[o])if(n.target&&w(n.target)){const t=ie(n.offset);a[o]=t?new ViewTimeline({subject:n.target,axis:i}):re({container:e,...n})}else w()?a[o]=new ScrollTimeline({source:e,axis:i}):a[o]=re({container:e,...n});return a[o]}function oe(t,{axis:e="y",container:n=document.scrollingElement,...i}={}){if(!n)return r;const s={axis:e,container:n,...i};return"function"==typeof t?function(t,e){return function(t){return 2===t.length}(t)?te(n=>{t(n[e.axis].progress,n)},e):f(t,ae(e))}(t,s):function(t,e){const n=ae(e),i=e.target?ie(e.offset):void 0,s=e.target?w(e.target)&&!!i:w();return t.attachTimeline({timeline:s?n:void 0,...i&&s&&{rangeStart:i.rangeStart,rangeEnd:i.rangeEnd},observe:t=>(t.pause(),f(e=>{t.time=t.iterationDuration*e},n))})}(t,s)}class he{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>t.finished))}getAll(t){return this.animations[0][t]}setAll(t,e){for(let n=0;n<this.animations.length;n++)this.animations[n][t]=e}attachTimeline(t){const e=this.animations.map(e=>e.attachTimeline(t));return()=>{e.forEach((t,e)=>{t&&t(),this.animations[e].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return le(this.animations,"duration")}get iterationDuration(){return le(this.animations,"iterationDuration")}runAll(t){this.animations.forEach(e=>e[t]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function le(t,e){let n=0;for(let i=0;i<t.length;i++){const s=t[i][e];null!==s&&s>n&&(n=s)}return n}class ce extends he{then(t,e){return this.finished.finally(t).then(()=>{})}}function ue(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}class de{constructor(){this.subscriptions=[]}add(t){var e,n;return e=this.subscriptions,n=t,-1===e.indexOf(n)&&e.push(n),()=>ue(this.subscriptions,t)}notify(t,e,n){const i=this.subscriptions.length;if(i)if(1===i)this.subscriptions[0](t,e,n);else for(let s=0;s<i;s++){const i=this.subscriptions[s];i&&i(t,e,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}let pe;function fe(){pe=void 0}const me={now:()=>(void 0===pe&&me.set(d.isProcessing||a.useManualTiming?d.timestamp:performance.now()),pe),set:t=>{pe=t,queueMicrotask(fe)}},ge={current:void 0};class ye{constructor(t,e={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=t=>{const e=me.now();if(this.updatedAt!==e&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(t),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const t of this.dependents)t.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=e.owner}setCurrent(t){var e;this.current=t,this.updatedAt=me.now(),null===this.canTrackVelocity&&void 0!==t&&(this.canTrackVelocity=(e=this.current,!isNaN(parseFloat(e))))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,e){this.events[t]||(this.events[t]=new de);const n=this.events[t].add(e);return"change"===t?()=>{n(),c.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,e){this.passiveEffect=t,this.stopPassiveEffect=e}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,e,n){this.set(e),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-n}jump(t,e=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,e&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return ge.current&&ge.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const t=me.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const e=Math.min(this.updatedAt-this.prevUpdatedAt,30);return I(parseFloat(this.current)-parseFloat(this.prevFrameValue),e)}start(t){return this.stop(),new Promise(e=>{this.hasAnimated=!0,this.animation=t(e),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function ve(t,e){return new ye(t,e)}const be=t=>1e3*t,we=t=>t/1e3,Te=(t,e,n=10)=>{let i="";const s=Math.max(Math.round(e/n),2);for(let e=0;e<s;e++)i+=Math.round(1e4*t(e/(s-1)))/1e4+", ";return`linear(${i.substring(0,i.length-2)})`},xe=2e4;function Me(t){let e=0;let n=t.next(e);for(;!n.done&&e<xe;)e+=50,n=t.next(e);return e>=xe?1/0:e}function Ae(t,e=100,n){const i=n({...t,keyframes:[0,e]}),s=Math.min(Me(i),xe);return{type:"keyframes",ease:t=>i.next(s*t).value/e,duration:we(s)}}const Se=100,Ee=10,Ce=1,Ve=0,ke=800,Pe=.3,Re=.3,Fe={granular:.01,default:2},De={granular:.005,default:.5},_e=.01,Be=10,Ie=.05,Oe=1;function Le(t,e){return t*Math.sqrt(1-e*e)}const We=.001;const $e=["duration","bounce"],je=["stiffness","damping","mass"];function Ne(t,e){return e.some(e=>void 0!==t[e])}function Ue(t){let e={velocity:Ve,stiffness:Se,damping:Ee,mass:Ce,isResolvedFromDuration:!1,...t};if(!Ne(t,je)&&Ne(t,$e))if(e.velocity=0,t.visualDuration){const n=t.visualDuration,i=2*Math.PI/(1.2*n),s=i*i,r=2*j(.05,1,1-(t.bounce||0))*Math.sqrt(s);e={...e,mass:Ce,stiffness:s,damping:r}}else{const n=function({duration:t=ke,bounce:e=Pe,velocity:n=Ve,mass:i=Ce}){let s,r;be(Be);let a=1-e;a=j(Ie,Oe,a),t=j(_e,Be,we(t)),a<1?(s=e=>{const i=e*a,s=i*t,r=i-n,o=Le(e,a),h=Math.exp(-s);return We-r/o*h},r=e=>{const i=e*a*t,r=i*n+n,o=Math.pow(a,2)*Math.pow(e,2)*t,h=Math.exp(-i),l=Le(Math.pow(e,2),a);return(-s(e)+We>0?-1:1)*((r-o)*h)/l}):(s=e=>Math.exp(-e*t)*((e-n)*t+1)-.001,r=e=>Math.exp(-e*t)*(t*t*(n-e)));const o=function(t,e,n){let i=n;for(let n=1;n<12;n++)i-=t(i)/e(i);return i}(s,r,5/t);if(t=be(t),isNaN(o))return{stiffness:Se,damping:Ee,duration:t};{const e=Math.pow(o,2)*i;return{stiffness:e,damping:2*a*Math.sqrt(i*e),duration:t}}}({...t,velocity:0});e={...e,...n,mass:Ce},e.isResolvedFromDuration=!0}return e}function Xe(t=Re,e=Pe){const n="object"!=typeof t?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:i,restDelta:s}=n;const r=n.keyframes[0],a=n.keyframes[n.keyframes.length-1],o={done:!1,value:r},{stiffness:h,damping:l,mass:c,duration:u,velocity:d,isResolvedFromDuration:p}=Ue({...n,velocity:-we(n.velocity||0)}),f=d||0,m=l/(2*Math.sqrt(h*c)),g=a-r,y=we(Math.sqrt(h/c)),v=Math.abs(g)<5;let b,w,T,x,M,A;if(i||(i=v?Fe.granular:Fe.default),s||(s=v?De.granular:De.default),m<1)T=Le(y,m),x=(f+m*y*g)/T,b=t=>{const e=Math.exp(-m*y*t);return a-e*(x*Math.sin(T*t)+g*Math.cos(T*t))},M=m*y*x+g*T,A=m*y*g-x*T,w=t=>Math.exp(-m*y*t)*(M*Math.sin(T*t)+A*Math.cos(T*t));else if(1===m){b=t=>a-Math.exp(-y*t)*(g+(f+y*g)*t);const t=f+y*g;w=e=>Math.exp(-y*e)*(y*t*e-f)}else{const t=y*Math.sqrt(m*m-1);b=e=>{const n=Math.exp(-m*y*e),i=Math.min(t*e,300);return a-n*((f+m*y*g)*Math.sinh(i)+t*g*Math.cosh(i))/t};const e=(f+m*y*g)/t,n=m*y*e-g*t,i=m*y*g-e*t;w=e=>{const s=Math.exp(-m*y*e),r=Math.min(t*e,300);return s*(n*Math.sinh(r)+i*Math.cosh(r))}}const S={calculatedDuration:p&&u||null,velocity:t=>be(w(t)),next:t=>{if(!p&&m<1){const e=Math.exp(-m*y*t),n=Math.sin(T*t),r=Math.cos(T*t),h=a-e*(x*n+g*r),l=be(e*(M*n+A*r));return o.done=Math.abs(l)<=i&&Math.abs(a-h)<=s,o.value=o.done?a:h,o}const e=b(t);if(p)o.done=t>=u;else{const n=be(w(t));o.done=Math.abs(n)<=i&&Math.abs(a-e)<=s}return o.value=o.done?a:e,o},toString:()=>{const t=Math.min(Me(S),xe),e=Te(e=>S.next(t*e).value,t,30);return t+"ms "+e},toTransition:()=>{}};return S}function ze(t){return"function"==typeof t&&"applyToOptions"in t}Xe.applyToOptions=t=>{const e=Ae(t,100,Xe);return t.ease=e.ease,t.duration=be(e.duration),t.type="keyframes",t};const Ke=t=>Boolean(t&&t.getVelocity),Ye=t=>Array.isArray(t)&&"number"!=typeof t[0];function He(t,e){return Ye(t)?t[((t,e,n)=>{const i=e-t;return((n-t)%i+i)%i+t})(0,t.length,e)]:t}function qe(t){return"object"==typeof t&&!Array.isArray(t)}function Ge(t,e,n,i){return null==t?[]:"string"==typeof t&&qe(e)?M(t,n,i):t instanceof NodeList?Array.from(t):Array.isArray(t)?t.filter(t=>null!=t):[t]}function Ze(t,e,n){return t*(e+1)}function Je(t,e,n,i){return"number"==typeof e?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:e.startsWith("<")?Math.max(0,n+parseFloat(e.slice(1))):i.get(e)??t}function Qe(t,e,n,i,s,r){!function(t,e,n){for(let i=0;i<t.length;i++){const s=t[i];s.at>e&&s.at<n&&(ue(t,s),i--)}}(t,s,r);for(let a=0;a<e.length;a++)t.push({value:e[a],at:At(s,r,i[a]),easing:He(n,a)})}function tn(t,e){for(let n=0;n<t.length;n++)t[n]=t[n]/(e+1)}function en(t,e){return t.at===e.at?null===t.value?1:null===e.value?-1:0:t.at-e.at}function nn(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function sn(t,e){return e[t]||(e[t]=[]),e[t]}function rn(t){return Array.isArray(t)?t:[t]}function an(t,e){return t&&t[e]?{...t,...t[e]}:{...t}}const on=t=>"number"==typeof t,hn=t=>t.every(on),ln={layout:0,mainThread:0,waapi:0},cn=t=>{const e=({timestamp:e})=>t(e);return{start:(t=!0)=>c.update(e,t),stop:()=>u(e),now:()=>d.isProcessing?d.timestamp:me.now()}};function un(t,e,n){const i=Math.max(e-5,0);return I(n-t(i),e-i)}function dn({keyframes:t,velocity:e=0,power:n=.8,timeConstant:i=325,bounceDamping:s=10,bounceStiffness:r=500,modifyTarget:a,min:o,max:h,restDelta:l=.5,restSpeed:c}){const u=t[0],d={done:!1,value:u},p=t=>void 0===o?h:void 0===h||Math.abs(o-t)<Math.abs(h-t)?o:h;let f=n*e;const m=u+f,g=void 0===a?m:a(m);g!==m&&(f=g-u);const y=t=>-f*Math.exp(-t/i),v=t=>g+y(t),b=t=>{const e=y(t),n=v(t);d.done=Math.abs(e)<=l,d.value=d.done?g:n};let w,T;const x=t=>{var e;(e=d.value,void 0!==o&&e<o||void 0!==h&&e>h)&&(w=t,T=Xe({keyframes:[d.value,p(d.value)],velocity:un(v,t,d.value),damping:s,stiffness:r,restDelta:l,restSpeed:c}))};return x(0),{calculatedDuration:null,next:t=>{let e=!1;return T||void 0!==w||(e=!0,b(t),x(t)),void 0!==w&&t>=w?T.next(t-w):(!e&&b(t),d)}}}const pn=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function fn(t,e,n,i){if(t===e&&n===i)return r;const s=e=>function(t,e,n,i,s){let r,a,o=0;do{a=e+(n-e)/2,r=pn(a,i,s)-t,r>0?n=a:e=a}while(Math.abs(r)>1e-7&&++o<12);return a}(e,0,1,t,n);return t=>0===t||1===t?t:pn(s(t),e,i)}const mn=fn(.42,0,1,1),gn=fn(0,0,.58,1),yn=fn(.42,0,.58,1),vn=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,bn=t=>e=>1-t(1-e),wn=fn(.33,1.53,.69,.99),Tn=bn(wn),xn=vn(Tn),Mn=t=>t>=1?1:(t*=2)<1?.5*Tn(t):.5*(2-Math.pow(2,-10*(t-1))),An=t=>1-Math.sin(Math.acos(t)),Sn=bn(An),En=vn(An),Cn=t=>Array.isArray(t)&&"number"==typeof t[0],Vn={linear:r,easeIn:mn,easeInOut:yn,easeOut:gn,circIn:An,circInOut:En,circOut:Sn,backIn:Tn,backInOut:xn,backOut:wn,anticipate:Mn},kn=t=>{if(Cn(t)){t.length;const[e,n,i,s]=t;return fn(e,n,i,s)}return"string"==typeof t?Vn[t]:t};function Pn({duration:t=300,keyframes:e,times:n,ease:i="easeInOut"}){const s=Ye(i)?i.map(kn):kn(i),r={done:!1,value:e[0]},a=function(t,e){return t.map(t=>t*e)}(n&&n.length===e.length?n:Lt(e),t),o=It(a,e,{ease:Array.isArray(s)?s:(h=e,l=s,h.map(()=>l||yn).splice(0,h.length-1))});var h,l;return{calculatedDuration:t,next:e=>(r.value=o(e),r.done=e>=t,r)}}const Rn=t=>null!==t;function Fn(t,{repeat:e,repeatType:n="loop"},i,s=1){const r=t.filter(Rn),a=s<0||e&&"loop"!==n&&e%2==1?0:r.length-1;return a&&void 0!==i?i:r[a]}const Dn={decay:dn,inertia:dn,tween:Pn,keyframes:Pn,spring:Xe};function _n(t){"string"==typeof t.type&&(t.type=Dn[t.type])}class Bn{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,e){return this.finished.then(t,e)}}const In=t=>t/100;class On extends Bn{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:t}=this.options;t&&t.updatedAt!==me.now()&&this.tick(me.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),this.options.onStop?.())},ln.mainThread++,this.options=t,this.initAnimation(),this.play(),!1===t.autoplay&&this.pause()}initAnimation(){const{options:t}=this;_n(t);const{type:e=Pn,repeat:n=0,repeatDelay:i=0,repeatType:s,velocity:r=0}=t;let{keyframes:a}=t;const o=e||Pn;o!==Pn&&"number"!=typeof a[0]&&(this.mixKeyframes=$(In,Bt(a[0],a[1])),a=[0,100]);const h=o({...t,keyframes:a});"mirror"===s&&(this.mirroredGenerator=o({...t,keyframes:[...a].reverse(),velocity:-r})),null===h.calculatedDuration&&(h.calculatedDuration=Me(h));const{calculatedDuration:l}=h;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(n+1)-i,this.generator=h}updateTime(t){const e=Math.round(t-this.startTime)*this.playbackSpeed;null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=e}tick(t,e=!1){const{generator:n,totalDuration:i,mixKeyframes:s,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:o}=this;if(null===this.startTime)return n.next(0);const{delay:h=0,keyframes:l,repeat:c,repeatType:u,repeatDelay:d,type:p,onUpdate:f,finalKeyframe:m}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),e?this.currentTime=t:this.updateTime(t);const g=this.currentTime-h*(this.playbackSpeed>=0?1:-1),y=this.playbackSpeed>=0?g<0:g>i;this.currentTime=Math.max(g,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=i);let v=this.currentTime,b=n;if(c){const t=Math.min(this.currentTime,i)/a;let e=Math.floor(t),n=t%1;!n&&t>=1&&(n=1),1===n&&e--,e=Math.min(e,c+1);Boolean(e%2)&&("reverse"===u?(n=1-n,d&&(n-=d/a)):"mirror"===u&&(b=r)),v=j(0,1,n)*a}const w=y?{done:!1,value:l[0]}:b.next(v);s&&!y&&(w.value=s(w.value));let{done:T}=w;y||null===o||(T=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const x=null===this.holdTime&&("finished"===this.state||"running"===this.state&&T);return x&&p!==dn&&(w.value=Fn(l,this.options,m,this.speed)),f&&f(w.value),x&&this.finish(),w}then(t,e){return this.finished.then(t,e)}get duration(){return we(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+we(t)}get time(){return we(this.currentTime)}set time(t){t=be(t),this.currentTime=t,null===this.startTime||null!==this.holdTime||0===this.playbackSpeed?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);return un(t=>this.generator.next(t).value,t,this.generator.next(t).value)}get speed(){return this.playbackSpeed}set speed(t){const e=this.playbackSpeed!==t;e&&this.driver&&this.updateTime(me.now()),this.playbackSpeed=t,e&&this.driver&&(this.time=we(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=cn,startTime:e}=this.options;this.driver||(this.driver=t(t=>this.tick(t))),this.options.onPlay?.();const n=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=n):null!==this.holdTime?this.startTime=n-this.holdTime:this.startTime||(this.startTime=e??n),"finished"===this.state&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(me.now()),this.holdTime=this.currentTime}complete(){"running"!==this.state&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null,ln.mainThread--}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}const Ln=t=>180*t/Math.PI,Wn=t=>{const e=Ln(Math.atan2(t[1],t[0]));return jn(e)},$n={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Wn,rotateZ:Wn,skewX:t=>Ln(Math.atan(t[1])),skewY:t=>Ln(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},jn=t=>((t%=360)<0&&(t+=360),t),Nn=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Un=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Xn={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Nn,scaleY:Un,scale:t=>(Nn(t)+Un(t))/2,rotateX:t=>jn(Ln(Math.atan2(t[6],t[5]))),rotateY:t=>jn(Ln(Math.atan2(-t[2],t[0]))),rotateZ:Wn,rotate:Wn,skewX:t=>Ln(Math.atan(t[4])),skewY:t=>Ln(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function zn(t){return t.includes("scale")?1:0}function Kn(t,e){if(!t||"none"===t)return zn(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,s;if(n)i=Xn,s=n;else{const e=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=$n,s=e}if(!s)return zn(e);const r=i[e],a=s[1].split(",").map(Yn);return"function"==typeof r?r(a):a[r]}function Yn(t){return parseFloat(t.trim())}const Hn=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],qn=(()=>new Set(Hn))(),Gn=t=>t===H||t===ht,Zn=new Set(["x","y","z"]),Jn=Hn.filter(t=>!Zn.has(t));const Qn={width:({x:t},{paddingLeft:e="0",paddingRight:n="0",boxSizing:i})=>{const s=t.max-t.min;return"border-box"===i?s:s-parseFloat(e)-parseFloat(n)},height:({y:t},{paddingTop:e="0",paddingBottom:n="0",boxSizing:i})=>{const s=t.max-t.min;return"border-box"===i?s:s-parseFloat(e)-parseFloat(n)},top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>Kn(e,"x"),y:(t,{transform:e})=>Kn(e,"y")};Qn.translateX=Qn.x,Qn.translateY=Qn.y;const ti=new Set;let ei=!1,ni=!1,ii=!1;function si(){if(ni){const t=Array.from(ti).filter(t=>t.needsMeasurement),e=new Set(t.map(t=>t.element)),n=new Map;e.forEach(t=>{const e=function(t){const e=[];return Jn.forEach(n=>{const i=t.getValue(n);void 0!==i&&(e.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),e}(t);e.length&&(n.set(t,e),t.render())}),t.forEach(t=>t.measureInitialState()),e.forEach(t=>{t.render();const e=n.get(t);e&&e.forEach(([e,n])=>{t.getValue(e)?.set(n)})}),t.forEach(t=>t.measureEndState()),t.forEach(t=>{void 0!==t.suspendedScrollY&&window.scrollTo(0,t.suspendedScrollY)})}ni=!1,ei=!1,ti.forEach(t=>t.complete(ii)),ti.clear()}function ri(){ti.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ni=!0)})}class ai{constructor(t,e,n,i,s,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=e,this.name=n,this.motionValue=i,this.element=s,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(ti.add(this),ei||(ei=!0,c.read(ri),c.resolveKeyframes(si))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:e,element:n,motionValue:i}=this;if(null===t[0]){const s=i?.get(),r=t[t.length-1];if(void 0!==s)t[0]=s;else if(n&&e){const i=n.readValue(e,r);null!=i&&(t[0]=i)}void 0===t[0]&&(t[0]=r),i&&void 0===s&&i.set(t[0])}!function(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),ti.delete(this)}cancel(){"scheduled"===this.state&&(ti.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}function oi(t,e,n){(t=>t.startsWith("--"))(e)?t.style.setProperty(e,n):t.style[e]=n}const hi=y(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch(t){return!1}return!0},"linearEasing"),li=([t,e,n,i])=>`cubic-bezier(${t}, ${e}, ${n}, ${i})`,ci={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:li([0,.65,.55,1]),circOut:li([.55,0,1,.45]),backIn:li([.31,.01,.66,-.59]),backOut:li([.33,1.53,.69,.99])};function ui(t,e){return t?"function"==typeof t?hi()?Te(t,e):"ease-out":Cn(t)?li(t):Array.isArray(t)?t.map(t=>ui(t,e)||ci.easeOut):ci[t]:void 0}function di(t,e,n,{delay:i=0,duration:s=300,repeat:r=0,repeatType:a="loop",ease:o="easeOut",times:l}={},c=void 0){const u={[e]:n};l&&(u.offset=l);const d=ui(o,s);Array.isArray(d)&&(u.easing=d),h.value&&ln.waapi++;const p={delay:i,duration:s,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:r+1,direction:"reverse"===a?"alternate":"normal"};c&&(p.pseudoElement=c);const f=t.animate(u,p);return h.value&&f.finished.finally(()=>{ln.waapi--}),f}class pi extends Bn{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:e,name:n,keyframes:i,pseudoElement:s,allowFlatten:r=!1,finalKeyframe:a,onComplete:o}=t;this.isPseudoElement=Boolean(s),this.allowFlatten=r,this.options=t,t.type;const h=function({type:t,...e}){return ze(t)&&hi()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}(t);this.animation=di(e,n,i,h,s),!1===h.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!s){const t=Fn(i,this.options,a,this.speed);this.updateMotionValue&&this.updateMotionValue(t),oi(e,n,t),this.animation.cancel()}o?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch(t){}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;"idle"!==t&&"finished"!==t&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){const t=this.options?.element;!this.isPseudoElement&&t?.isConnected&&this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return we(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+we(t)}get time(){return we(Number(this.animation.currentTime)||0)}set time(t){const e=null!==this.finishedTime;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=be(t),e&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return null!==this.finishedTime?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:e,rangeEnd:n,observe:i}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&v()?(this.animation.timeline=t,e&&(this.animation.rangeStart=e),n&&(this.animation.rangeEnd=n),r):i(this)}}const fi={anticipate:Mn,backInOut:xn,circInOut:En};function mi(t){"string"==typeof t.ease&&t.ease in fi&&(t.ease=fi[t.ease])}class gi extends pi{constructor(t){mi(t),_n(t),super(t),void 0!==t.startTime&&!1!==t.autoplay&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:e,onUpdate:n,onComplete:i,element:s,...r}=this.options;if(!e)return;if(void 0!==t)return void e.set(t);const a=new On({...r,autoplay:!1}),o=Math.max(10,me.now()-this.startTime),h=j(0,10,o-10),l=a.sample(o).value,{name:c}=this.options;s&&c&&oi(s,c,l),e.setWithVelocity(a.sample(Math.max(0,o-h)).value,l,h),a.stop()}}const yi=(t,e)=>"zIndex"!==e&&(!("number"!=typeof t&&!Array.isArray(t))||!("string"!=typeof t||!Tt.test(t)&&"0"!==t||t.startsWith("url(")));function vi(t){t.duration=0,t.type="keyframes"}const bi=new Set(["opacity","clipPath","filter","transform"]),wi=m(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));class Ti extends Bn{constructor({autoplay:t=!0,delay:e=0,type:n="keyframes",repeat:i=0,repeatDelay:s=0,repeatType:r="loop",keyframes:a,name:o,motionValue:h,element:l,...c}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=me.now();const u={autoplay:t,delay:e,type:n,repeat:i,repeatDelay:s,repeatType:r,name:o,motionValue:h,element:l,...c},d=l?.KeyframeResolver||ai;this.keyframeResolver=new d(a,(t,e,n)=>this.onKeyframesResolved(t,e,u,!n),o,h,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,e,n,i){this.keyframeResolver=void 0;const{name:s,type:o,velocity:h,delay:l,isHandoff:c,onUpdate:u}=n;this.resolvedAt=me.now();let d=!0;(function(t,e,n,i){const s=t[0];if(null===s)return!1;if("display"===e||"visibility"===e)return!0;const r=t[t.length-1],a=yi(s,e),o=yi(r,e);return!(!a||!o)&&(function(t){const e=t[0];if(1===t.length)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}(t)||("spring"===n||ze(n))&&i)})(t,s,o,h)||(d=!1,!a.instantAnimations&&l||u?.(Fn(t,n,e)),t[0]=t[t.length-1],vi(n),n.repeat=0);const p={startTime:i?this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt:void 0,finalKeyframe:e,...n,keyframes:t},f=d&&!c&&function(t){const{motionValue:e,name:n,repeatDelay:i,repeatType:s,damping:r,type:a}=t,o=e?.owner?.current;if(!(o instanceof HTMLElement))return!1;const{onUpdate:h,transformTemplate:l}=e.owner.getProps();return wi()&&n&&bi.has(n)&&("transform"!==n||!l)&&!h&&!i&&"mirror"!==s&&0!==r&&"inertia"!==a}(p),m=p.motionValue?.owner?.current,g=f?new gi({...p,element:m}):new On(p);g.finished.then(()=>{this.notifyFinished()}).catch(r),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(t,e){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),ii=!0,ri(),si(),ii=!1),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}function xi(t,e){if(t?.inherit&&e){const{inherit:n,...i}=t;return{...e,...i}}return t}function Mi(t,e){const n=t?.[e]??t?.default??t;return n!==t?xi(n,t):n}const Ai={type:"spring",stiffness:500,damping:25,restSpeed:10},Si={type:"keyframes",duration:.8},Ei={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Ci=(t,{keyframes:e})=>e.length>2?Si:qn.has(t)?t.startsWith("scale")?{type:"spring",stiffness:550,damping:0===e[1]?2*Math.sqrt(550):30,restSpeed:10}:Ai:Ei,Vi=t=>null!==t;const ki=(t,e,n,i={},s,r)=>o=>{const h=Mi(i,t)||{},l=h.delay||i.delay||0;let{elapsed:u=0}=i;u-=be(l);const d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...h,delay:-u,onUpdate:t=>{e.set(t),h.onUpdate&&h.onUpdate(t)},onComplete:()=>{o(),h.onComplete&&h.onComplete()},name:t,motionValue:e,element:r?void 0:s};(function({when:t,delay:e,delayChildren:n,staggerChildren:i,staggerDirection:s,repeat:r,repeatType:a,repeatDelay:o,from:h,elapsed:l,...c}){return!!Object.keys(c).length})(h)||Object.assign(d,Ci(t,d)),d.duration&&(d.duration=be(d.duration)),d.repeatDelay&&(d.repeatDelay=be(d.repeatDelay)),void 0!==d.from&&(d.keyframes[0]=d.from);let p=!1;if((!1===d.type||0===d.duration&&!d.repeatDelay)&&(vi(d),0===d.delay&&(p=!0)),(a.instantAnimations||a.skipAnimations||s?.shouldSkipAnimations)&&(p=!0,vi(d),d.delay=0),d.allowFlatten=!h.type&&!h.ease,p&&!r&&void 0!==e.get()){const t=function(t,{repeat:e,repeatType:n="loop"},i){const s=t.filter(Vi),r=e&&"loop"!==n&&e%2==1?0:s.length-1;return r&&void 0!==i?i:s[r]}(d.keyframes,h);if(void 0!==t)return void c.update(()=>{d.onUpdate(t),d.onComplete()})}return h.isSync?new On(d):new Ti(d)};const Pi=new WeakMap,Ri=new Set(["width","height","top","left","right","bottom",...Hn]);function Fi(t){const e=[{},{}];return t?.values.forEach((t,n)=>{e[0][n]=t.get(),e[1][n]=t.getVelocity()}),e}function Di(t,e,n,i){if("function"==typeof e){const[s,r]=Fi(i);e=e(void 0!==n?n:t.custom,s,r)}if("string"==typeof e&&(e=t.variants&&t.variants[e]),"function"==typeof e){const[s,r]=Fi(i);e=e(void 0!==n?n:t.custom,s,r)}return e}function _i(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,ve(n))}function Bi(t){return(t=>Array.isArray(t))(t)?t[t.length-1]||0:t}function Ii(t,e){const n=function(t,e,n){const i=t.getProps();return Di(i,e,void 0!==n?n:i.custom,t)}(t,e);let{transitionEnd:i={},transition:s={},...r}=n||{};r={...r,...i};for(const e in r){_i(t,e,Bi(r[e]))}}function Oi(t,e){const n=t.getValue("willChange");if(i=n,Boolean(Ke(i)&&i.add))return n.add(e);if(!n&&a.WillChange){const n=new a.WillChange("auto");t.addValue("willChange",n),n.add(e)}var i}function Li(t){return t.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const Wi="data-"+Li("framerAppearId");function $i(t){return t.props[Wi]}function ji({protectedKeys:t,needsAnimating:e},n){const i=t.hasOwnProperty(n)&&!0!==e[n];return e[n]=!1,i}function Ni(t,e,{delay:n=0,transitionOverride:i,type:s}={}){let{transition:r,transitionEnd:a,...o}=e;const h=t.getDefaultTransition();r=r?xi(r,h):h;const l=r?.reduceMotion;i&&(r=i);const u=[],d=s&&t.animationState&&t.animationState.getState()[s];for(const e in o){const i=t.getValue(e,t.latestValues[e]??null),s=o[e];if(void 0===s||d&&ji(d,e))continue;const a={delay:n,...Mi(r||{},e)},h=i.get();if(void 0!==h&&!i.isAnimating&&!Array.isArray(s)&&s===h&&!a.velocity)continue;let p=!1;if(window.MotionHandoffAnimation){const n=$i(t);if(n){const t=window.MotionHandoffAnimation(n,e,c);null!==t&&(a.startTime=t,p=!0)}}Oi(t,e);const f=l??t.shouldReduceMotion;i.start(ki(e,i,s,f&&Ri.has(e)?{type:!1}:a,t,p));const m=i.animation;m&&u.push(m)}if(a){const e=()=>c.update(()=>{a&&Ii(t,a)});u.length?Promise.all(u).then(e):e()}return u}const Ui=new Set(["brightness","contrast","saturate","opacity"]);function Xi(t){const[e,n]=t.slice(0,-1).split("(");if("drop-shadow"===e)return t;const[i]=n.match(J)||[];if(!i)return t;const s=n.replace(i,"");let r=Ui.has(e)?1:0;return i!==n&&(r*=100),e+"("+r+s+")"}const zi=/\b([a-z-]*)\(.*?\)/gu,Ki={...Tt,getAnimatableNone:t=>{const e=t.match(zi);return e?e.map(Xi).join(" "):t}},Yi={...Tt,getAnimatableNone:t=>{const e=Tt.parse(t);return Tt.createTransformer(t)(e.map(t=>"number"==typeof t?0:"object"==typeof t?{...t,alpha:1}:t))}},Hi={...H,transform:Math.round},qi={borderWidth:ht,borderTopWidth:ht,borderRightWidth:ht,borderBottomWidth:ht,borderLeftWidth:ht,borderRadius:ht,borderTopLeftRadius:ht,borderTopRightRadius:ht,borderBottomRightRadius:ht,borderBottomLeftRadius:ht,width:ht,maxWidth:ht,height:ht,maxHeight:ht,top:ht,right:ht,bottom:ht,left:ht,inset:ht,insetBlock:ht,insetBlockStart:ht,insetBlockEnd:ht,insetInline:ht,insetInlineStart:ht,insetInlineEnd:ht,padding:ht,paddingTop:ht,paddingRight:ht,paddingBottom:ht,paddingLeft:ht,paddingBlock:ht,paddingBlockStart:ht,paddingBlockEnd:ht,paddingInline:ht,paddingInlineStart:ht,paddingInlineEnd:ht,margin:ht,marginTop:ht,marginRight:ht,marginBottom:ht,marginLeft:ht,marginBlock:ht,marginBlockStart:ht,marginBlockEnd:ht,marginInline:ht,marginInlineStart:ht,marginInlineEnd:ht,fontSize:ht,backgroundPositionX:ht,backgroundPositionY:ht,...{rotate:at,rotateX:at,rotateY:at,rotateZ:at,scale:G,scaleX:G,scaleY:G,scaleZ:G,skew:at,skewX:at,skewY:at,distance:ht,translateX:ht,translateY:ht,translateZ:ht,x:ht,y:ht,z:ht,perspective:ht,transformPerspective:ht,opacity:q,originX:ut,originY:ut,originZ:ht},zIndex:Hi,fillOpacity:q,strokeOpacity:q,numOctaves:Hi},Gi={...qi,color:pt,backgroundColor:pt,outlineColor:pt,fill:pt,stroke:pt,borderColor:pt,borderTopColor:pt,borderRightColor:pt,borderBottomColor:pt,borderLeftColor:pt,filter:Ki,WebkitFilter:Ki,mask:Yi,WebkitMask:Yi},Zi=t=>Gi[t],Ji=()=>({x:{min:0,max:0},y:{min:0,max:0}}),Qi=t=>e=>e.test(t),ts=[H,ht,ot,at,ct,lt,{test:t=>"auto"===t,parse:t=>t}],es=t=>ts.find(Qi(t)),ns=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t),is=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ss(t,e,n=1){const[i,s]=function(t){const e=is.exec(t);if(!e)return[,];const[,n,i,s]=e;return[`--${n??i}`,s]}(t);if(!i)return;const r=window.getComputedStyle(e).getPropertyValue(i);if(r){const t=r.trim();return ns(t)?parseFloat(t):t}return z(s)?ss(s,e,n+1):s}const rs=t=>/^0[^.\s]+$/u.test(t);function as(t){return"number"==typeof t?0===t:null===t||("none"===t||"0"===t||rs(t))}const os=new Set([Ki,Yi]);function hs(t,e){let n=Zi(t);return os.has(n)||(n=Tt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const ls=new Set(["auto","none","0"]);class cs extends ai{constructor(t,e,n,i,s){super(t,e,n,i,s,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:e,name:n}=this;if(!e||!e.current)return;super.readKeyframes();for(let n=0;n<t.length;n++){let i=t[n];if("string"==typeof i&&(i=i.trim(),z(i))){const s=ss(i,e.current);void 0!==s&&(t[n]=s),n===t.length-1&&(this.finalKeyframe=i)}}if(this.resolveNoneKeyframes(),!Ri.has(n)||2!==t.length)return;const[i,s]=t,r=es(i),a=es(s);if(Y(i)!==Y(s)&&Qn[n])this.needsMeasurement=!0;else if(r!==a)if(Gn(r)&&Gn(a))for(let e=0;e<t.length;e++){const n=t[e];"string"==typeof n&&(t[e]=parseFloat(n))}else Qn[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:e}=this,n=[];for(let e=0;e<t.length;e++)(null===t[e]||as(t[e]))&&n.push(e);n.length&&function(t,e,n){let i,s=0;for(;s<t.length&&!i;){const e=t[s];"string"==typeof e&&!ls.has(e)&&vt(e).values.length&&(i=t[s]),s++}if(i&&n)for(const s of e)t[s]=hs(n,i)}(t,n,e)}measureInitialState(){const{element:t,unresolvedKeyframes:e,name:n}=this;if(!t||!t.current)return;"height"===n&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Qn[n](t.measureViewportBox(),window.getComputedStyle(t.current)),e[0]=this.measuredOrigin;const i=e[e.length-1];void 0!==i&&t.getValue(n,i).jump(i,!1)}measureEndState(){const{element:t,name:e,unresolvedKeyframes:n}=this;if(!t||!t.current)return;const i=t.getValue(e);i&&i.jump(this.measuredOrigin,!1);const s=n.length-1,r=n[s];n[s]=Qn[e](t.measureViewportBox(),window.getComputedStyle(t.current)),null!==r&&void 0===this.finalKeyframe&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([e,n])=>{t.getValue(e).set(n)}),this.resolveNoneKeyframes()}}const us=new Set(["opacity","clipPath","filter","transform"]),{schedule:ds,cancel:ps}=l(queueMicrotask,!1),fs=[...ts,pt,Tt];const ms=["initial","animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"];function gs(t){return null!==(e=t.animate)&&"object"==typeof e&&"function"==typeof e.start||ms.some(e=>function(t){return"string"==typeof t||Array.isArray(t)}(t[e]));var e}const ys={current:null},vs={current:!1},bs="undefined"!=typeof window;const ws=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Ts={};class xs{scrapeMotionValuesFromProps(t,e,n){return{}}constructor({parent:t,props:e,presenceContext:n,reducedMotionConfig:i,skipAnimations:s,blockInitialAnimation:r,visualState:a},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=ai,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const t=me.now();this.renderScheduledAt<t&&(this.renderScheduledAt=t,c.render(this.render,!1,!0))};const{latestValues:h,renderState:l}=a;this.latestValues=h,this.baseTarget={...h},this.initialValues=e.initial?{...h}:{},this.renderState=l,this.parent=t,this.props=e,this.presenceContext=n,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.skipAnimationsConfig=s,this.options=o,this.blockInitialAnimation=Boolean(r),this.isControllingVariants=gs(e),this.isVariantNode=function(t){return Boolean(gs(t)||t.variants)}(e),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=Boolean(t&&t.current);const{willChange:u,...d}=this.scrapeMotionValuesFromProps(e,{},this);for(const t in d){const e=d[t];void 0!==h[t]&&Ke(e)&&e.set(h[t])}}mount(t){if(this.hasBeenMounted)for(const t in this.initialValues)this.values.get(t)?.jump(this.initialValues[t]),this.latestValues[t]=this.initialValues[t];this.current=t,Pi.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((t,e)=>this.bindToMotionValue(e,t)),"never"===this.reducedMotionConfig?this.shouldReduceMotion=!1:"always"===this.reducedMotionConfig?this.shouldReduceMotion=!0:(vs.current||function(){if(vs.current=!0,bs)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>ys.current=t.matches;t.addEventListener("change",e),e()}else ys.current=!1}(),this.shouldReduceMotion=ys.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),u(this.notifyUpdate),u(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const e=this.features[t];e&&(e.unmount(),e.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,e){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),e.accelerate&&us.has(t)&&this.current instanceof HTMLElement){const{factory:n,keyframes:i,times:s,ease:r,duration:a}=e.accelerate,o=new pi({element:this.current,name:t,keyframes:i,times:s,ease:r,duration:be(a)}),h=n(o);return void this.valueSubscriptions.set(t,()=>{h(),o.cancel()})}const n=qn.has(t);n&&this.onBindTransform&&this.onBindTransform();const i=e.on("change",e=>{this.latestValues[t]=e,this.props.onUpdate&&c.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let s;"undefined"!=typeof window&&window.MotionCheckAppearSync&&(s=window.MotionCheckAppearSync(this,t,e)),this.valueSubscriptions.set(t,()=>{i(),s&&s(),e.owner&&e.stop()})}sortNodePosition(t){return this.current&&this.sortInstanceNodePosition&&this.type===t.type?this.sortInstanceNodePosition(this.current,t.current):0}updateFeatures(){let t="animation";for(t in Ts){const e=Ts[t];if(!e)continue;const{isEnabled:n,Feature:i}=e;if(!this.features[t]&&i&&n(this.props)&&(this.features[t]=new i(this)),this.features[t]){const e=this.features[t];e.isMounted?e.update():(e.mount(),e.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):{x:{min:0,max:0},y:{min:0,max:0}}}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,e){this.latestValues[t]=e}update(t,e){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=e;for(let e=0;e<ws.length;e++){const n=ws[e];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);const i=t["on"+n];i&&(this.propEventSubscriptions[n]=this.on(n,i))}this.prevMotionValues=function(t,e,n){for(const i in e){const s=e[i],r=n[i];if(Ke(s))t.addValue(i,s);else if(Ke(r))t.addValue(i,ve(s,{owner:t}));else if(r!==s)if(t.hasValue(i)){const e=t.getValue(i);!0===e.liveStyle?e.jump(s):e.hasAnimated||e.set(s)}else{const e=t.getStaticValue(i);t.addValue(i,ve(void 0!==e?e:s,{owner:t}))}}for(const i in n)void 0===e[i]&&t.removeValue(i);return e}(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const e=this.getClosestVariantNode();if(e)return e.variantChildren&&e.variantChildren.add(t),()=>e.variantChildren.delete(t)}addValue(t,e){const n=this.values.get(t);e!==n&&(n&&this.removeValue(t),this.bindToMotionValue(t,e),this.values.set(t,e),this.latestValues[t]=e.get())}removeValue(t){this.values.delete(t);const e=this.valueSubscriptions.get(t);e&&(e(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,e){if(this.props.values&&this.props.values[t])return this.props.values[t];let n=this.values.get(t);return void 0===n&&void 0!==e&&(n=ve(null===e?void 0:e,{owner:this}),this.addValue(t,n)),n}readValue(t,e){let n=void 0===this.latestValues[t]&&this.current?this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options):this.latestValues[t];var i;return null!=n&&("string"==typeof n&&(ns(n)||rs(n))?n=parseFloat(n):(i=n,!fs.find(Qi(i))&&Tt.test(e)&&(n=hs(t,e))),this.setBaseTarget(t,Ke(n)?n.get():n)),Ke(n)?n.get():n}setBaseTarget(t,e){this.baseTarget[t]=e}getBaseTarget(t){const{initial:e}=this.props;let n;if("string"==typeof e||"object"==typeof e){const i=Di(this.props,e,this.presenceContext?.custom);i&&(n=i[t])}if(e&&void 0!==n)return n;const i=this.getBaseTargetFromProps(this.props,t);return void 0===i||Ke(i)?void 0!==this.initialValues[t]&&void 0===n?void 0:this.baseTarget[t]:i}on(t,e){return this.events[t]||(this.events[t]=new de),this.events[t].add(e)}notify(t,...e){this.events[t]&&this.events[t].notify(...e)}scheduleRenderMicrotask(){ds.render(this.render)}}class Ms extends xs{constructor(){super(...arguments),this.KeyframeResolver=cs}sortInstanceNodePosition(t,e){return 2&t.compareDocumentPosition(e)?1:-1}getBaseTargetFromProps(t,e){const n=t.style;return n?n[e]:void 0}removeValueFromRenderState(t,{vars:e,style:n}){delete e[t],delete n[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Ke(t)&&(this.childSubscription=t.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}}const As=(t,e)=>e&&"number"==typeof t?e.transform(t):t,Ss={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Es=Hn.length;function Cs(t,e,n){const{style:i,vars:s,transformOrigin:r}=t;let a=!1,o=!1;for(const t in e){const n=e[t];if(qn.has(t))a=!0;else if(U(t))s[t]=n;else{const e=As(n,qi[t]);t.startsWith("origin")?(o=!0,r[t]=e):i[t]=e}}if(e.transform||(a||n?i.transform=function(t,e,n){let i="",s=!0;for(let r=0;r<Es;r++){const a=Hn[r],o=t[a];if(void 0===o)continue;let h=!0;if("number"==typeof o)h=o===(a.startsWith("scale")?1:0);else{const t=parseFloat(o);h=a.startsWith("scale")?1===t:0===t}if(!h||n){const t=As(o,qi[a]);h||(s=!1,i+=`${Ss[a]||a}(${t}) `),n&&(e[a]=t)}}return i=i.trim(),n?i=n(e,s?"":i):s&&(i="none"),i}(e,t.transform,n):i.transform&&(i.transform="none")),o){const{originX:t="50%",originY:e="50%",originZ:n=0}=r;i.transformOrigin=`${t} ${e} ${n}`}}const Vs={offset:"stroke-dashoffset",array:"stroke-dasharray"},ks={offset:"strokeDashoffset",array:"strokeDasharray"};const Ps=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function Rs(t,{attrX:e,attrY:n,attrScale:i,pathLength:s,pathSpacing:r=1,pathOffset:a=0,...o},h,l,c){if(Cs(t,o,l),h)return void(t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox));t.attrs=t.style,t.style={};const{attrs:u,style:d}=t;u.transform&&(d.transform=u.transform,delete u.transform),(d.transform||u.transformOrigin)&&(d.transformOrigin=u.transformOrigin??"50% 50%",delete u.transformOrigin),d.transform&&(d.transformBox=c?.transformBox??"fill-box",delete u.transformBox);for(const t of Ps)void 0!==u[t]&&(d[t]=u[t],delete u[t]);void 0!==e&&(u.x=e),void 0!==n&&(u.y=n),void 0!==i&&(u.scale=i),void 0!==s&&function(t,e,n=1,i=0,s=!0){t.pathLength=1;const r=s?Vs:ks;t[r.offset]=""+-i,t[r.array]=`${e} ${n}`}(u,s,r,a,!1)}const Fs=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Ds(t,{style:e,vars:n},i,s){const r=t.style;let a;for(a in e)r[a]=e[a];for(a in s?.applyProjectionStyles(r,i),n)r.setProperty(a,n[a])}function _s(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Bs={correct:(t,e)=>{if(!e.target)return t;if("string"==typeof t){if(!ht.test(t))return t;t=parseFloat(t)}return`${_s(t,e.target.x)}% ${_s(t,e.target.y)}%`}},Is={correct:(t,{treeScale:e,projectionDelta:n})=>{const i=t,s=Tt.parse(t);if(s.length>5)return i;const r=Tt.createTransformer(t),a="number"!=typeof s[0]?1:0,o=n.x.scale*e.x,h=n.y.scale*e.y;s[0+a]/=o,s[1+a]/=h;const l=At(o,h,.5);return"number"==typeof s[2+a]&&(s[2+a]/=l),"number"==typeof s[3+a]&&(s[3+a]/=l),r(s)}};const Os={borderRadius:{...Bs,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Bs,borderTopRightRadius:Bs,borderBottomLeftRadius:Bs,borderBottomRightRadius:Bs,boxShadow:Is};function Ls(t,{layout:e,layoutId:n}){return qn.has(t)||t.startsWith("origin")||(e||void 0!==n)&&(!!Os[t]||"opacity"===t)}function Ws(t,e,n){const i=t.style,s=e?.style,r={};if(!i)return r;for(const e in i)(Ke(i[e])||s&&Ke(s[e])||Ls(e,t)||void 0!==n?.getValue(e)?.liveStyle)&&(r[e]=i[e]);return r}class $s extends Ms{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Ji}getBaseTargetFromProps(t,e){return t[e]}readValueFromInstance(t,e){if(qn.has(e)){const t=Zi(e);return t&&t.default||0}return e=Fs.has(e)?e:Li(e),t.getAttribute(e)}scrapeMotionValuesFromProps(t,e,n){return function(t,e,n){const i=Ws(t,e,n);for(const n in t)(Ke(t[n])||Ke(e[n]))&&(i[-1!==Hn.indexOf(n)?"attr"+n.charAt(0).toUpperCase()+n.substring(1):n]=t[n]);return i}(t,e,n)}build(t,e,n){Rs(t,e,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(t,e,n,i){!function(t,e,n,i){Ds(t,e,void 0,i);for(const n in e.attrs)t.setAttribute(Fs.has(n)?n:Li(n),e.attrs[n])}(t,e,0,i)}mount(t){var e;this.isSVGTag="string"==typeof(e=t.tagName)&&"svg"===e.toLowerCase(),super.mount(t)}}function js(t,e){return function({top:t,left:e,right:n,bottom:i}){return{x:{min:e,max:n},y:{min:t,max:i}}}(function(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),i=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}(t.getBoundingClientRect(),e))}class Ns extends Ms{constructor(){super(...arguments),this.type="html",this.renderInstance=Ds}readValueFromInstance(t,e){if(qn.has(e))return this.projection?.isProjecting?zn(e):((t,e)=>{const{transform:n="none"}=getComputedStyle(t);return Kn(n,e)})(t,e);{const i=(n=t,window.getComputedStyle(n)),s=(U(e)?i.getPropertyValue(e):i[e])||0;return"string"==typeof s?s.trim():s}var n}measureInstanceViewportBox(t,{transformPagePoint:e}){return js(t,e)}build(t,e,n){Cs(t,e,n.transformTemplate)}scrapeMotionValuesFromProps(t,e,n){return Ws(t,e,n)}}class Us extends xs{constructor(){super(...arguments),this.type="object"}readValueFromInstance(t,e){if(function(t,e){return t in e}(e,t)){const n=t[e];if("string"==typeof n||"number"==typeof n)return n}}getBaseTargetFromProps(){}removeValueFromRenderState(t,e){delete e.output[t]}measureInstanceViewportBox(){return{x:{min:0,max:0},y:{min:0,max:0}}}build(t,e){Object.assign(t.output,e)}renderInstance(t,{output:e}){Object.assign(t,e)}sortInstanceNodePosition(){return 0}}function Xs(t){const e={presenceContext:null,props:{},visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},n=x(t)&&!function(t){return x(t)&&"svg"===t.tagName}(t)?new $s(e):new Ns(e);n.mount(t),Pi.set(t,n)}function zs(t){const e=new Us({presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}});e.mount(t),Pi.set(t,e)}function Ks(t,e,n,i){const s=[];if(function(t,e){return Ke(t)||"number"==typeof t||"string"==typeof t&&!qe(e)}(t,e))s.push(function(t,e,n){const i=Ke(t)?t:ve(t);return i.start(ki("",i,e,n)),i.animation}(t,qe(e)&&e.default||e,n&&n.default||n));else{if(null==t)return s;const r=Ge(t,e,i),a=r.length;Boolean(a);for(let t=0;t<a;t++){const i=r[t],o=i instanceof Element?Xs:zs;Pi.has(i)||o(i);const h=Pi.get(i),l={...n};"delay"in l&&"function"==typeof l.delay&&(l.delay=l.delay(t,a)),s.push(...Ni(h,{...e,transition:l},{}))}}return s}function Ys(t,e,n){const i=[],s=function(t,{defaultTransition:e={},...n}={},i,s){const r=e.duration||.3,a=new Map,o=new Map,h={},l=new Map;let c=0,u=0,d=0;for(let n=0;n<t.length;n++){const a=t[n];if("string"==typeof a){l.set(a,u);continue}if(!Array.isArray(a)){l.set(a.name,Je(u,a.at,c,l));continue}let[p,f,m={}]=a;void 0!==m.at&&(u=Je(u,m.at,c,l));let g=0;const y=(t,n,i,a=0,o=0)=>{const h=rn(t),{delay:l=0,times:c=Lt(h),type:p=e.type||"keyframes",repeat:f,repeatType:m,repeatDelay:y=0,...v}=n;let{ease:b=e.ease||"easeOut",duration:w}=n;const T="function"==typeof l?l(a,o):l,x=h.length,M=ze(p)?p:s?.[p||"keyframes"];if(x<=2&&M){let t=100;if(2===x&&hn(h)){const e=h[1]-h[0];t=Math.abs(e)}const n={...e,...v};void 0!==w&&(n.duration=be(w));const i=Ae(n,t,M);b=i.ease,w=i.duration}w??(w=r);const A=u+T;1===c.length&&0===c[0]&&(c[1]=1);const S=c.length-h.length;if(S>0&&Ot(c,S),1===h.length&&h.unshift(null),f){w=Ze(w,f);const t=[...h],e=[...c];b=Array.isArray(b)?[...b]:[b];const n=[...b];for(let i=0;i<f;i++){h.push(...t);for(let s=0;s<t.length;s++)c.push(e[s]+(i+1)),b.push(0===s?"linear":He(n,s-1))}tn(c,f)}const E=A+w;Qe(i,h,b,c,A,E),g=Math.max(T+w,g),d=Math.max(E,d)};if(Ke(p))y(f,m,sn("default",nn(p,o)));else{const t=Ge(p,f,i,h),e=t.length;for(let n=0;n<e;n++){const i=nn(t[n],o);for(const t in f)y(f[t],an(m,t),sn(t,i),n,e)}}c=u,u+=g}return o.forEach((t,i)=>{for(const s in t){const r=t[s];r.sort(en);const o=[],h=[],l=[];for(let t=0;t<r.length;t++){const{at:e,value:n,easing:i}=r[t];o.push(n),h.push(B(0,d,e)),l.push(i||"easeOut")}0!==h[0]&&(h.unshift(0),o.unshift(o[0]),l.unshift("easeInOut")),1!==h[h.length-1]&&(h.push(1),o.push(null)),a.has(i)||a.set(i,{keyframes:{},transition:{}});const c=a.get(i);c.keyframes[s]=o;const{type:u,...p}=e;c.transition[s]={...p,duration:d,ease:l,times:h,...n}}}),a}(t.map(t=>{if(Array.isArray(t)&&"function"==typeof t[0]){const e=t[0],n=ve(0);return n.on("change",e),1===t.length?[n,[0,1]]:2===t.length?[n,[0,1],t[1]]:[n,t[1],t[2]]}return t}),e,n,{spring:Xe});return s.forEach(({keyframes:t,transition:e},n)=>{i.push(...Ks(n,t,e))}),i}const Hs=function(t={}){const{scope:e,reduceMotion:n}=t;return function(t,i,s){let r,a=[];if(o=t,Array.isArray(o)&&o.some(Array.isArray)){const{onComplete:s,...o}=i||{};"function"==typeof s&&(r=s),a=Ys(t,void 0!==n?{reduceMotion:n,...o}:o,e)}else{const{onComplete:o,...h}=s||{};"function"==typeof o&&(r=o),a=Ks(t,i,void 0!==n?{reduceMotion:n,...h}:h,e)}var o;const h=new ce(a);return r&&h.finished.then(r),e&&(e.animations.push(h),h.finished.then(()=>{ue(e.animations,h)})),h}}();var qs=function(t,e,n,i){return new(n||(n=Promise))(function(s,r){function a(t){try{h(i.next(t))}catch(t){r(t)}}function o(t){try{h(i.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,o)}h((i=i.apply(t,e||[])).next())})};class Gs{constructor(t,e={}){this.engine=null,this.syncedAnimations=[],this.destroyed=!1,this.container=t,this.options=Object.assign({scrub:0},e),this.injectStyles()}injectStyles(){if(Gs.stylesInjected)return;const t=document.createElement("style");t.id="scft-base-styles",t.innerHTML='\n .scft-layer {\n position: absolute;\n inset: 0;\n pointer-events: none;\n display: grid;\n grid-template-areas: "content";\n }\n .scft-layer > * {\n grid-area: content;\n pointer-events: auto;\n }\n /* Alignment Mappings */\n .scft-layer[data-scft-align^="top"] { align-items: start; }\n .scft-layer[data-scft-align^="center"] { align-items: center; }\n .scft-layer[data-scft-align^="bottom"] { align-items: end; }\n \n .scft-layer[data-scft-align$="left"] { justify-items: start; }\n .scft-layer[data-scft-align$="center"] { justify-items: center; }\n .scft-layer[data-scft-align$="right"] { justify-items: end; }\n ',document.head.appendChild(t),Gs.stylesInjected=!0}static initAll(){return qs(this,void 0,void 0,function*(){const t=document.querySelectorAll(".scft-container"),e=[];for(let n=0;n<t.length;n++){const i=t[n],s=new Gs(i,{scrub:.5});yield s.init(),e.push(s)}return e})}init(){return qs(this,void 0,void 0,function*(){if(this.destroyed)return;const t=this.container.querySelector(".scft-canvas");if(!t)return void console.warn("[CoreOrchestrator] No .scft-canvas found inside container.");const e=t.dataset.scftCanvas||t.getAttribute("data-project");if(!e)return void console.warn('[CoreOrchestrator] No project URL found on .scft-canvas. Use data-scft-canvas="url"');const n=t.dataset.scftDepthtilt||t.getAttribute("data-scft-depthtilt");null!=n&&(this.options.depthTilt=parseFloat(n)),this.engine=yield this.loadEngine(e,t),this.destroyed||(this.parseAnimatedElements(),this.setupScrollTracking(),this.engine.onFrameChange=(t,e)=>{this.syncTrackingLayers(t),this.onFrameChange&&this.onFrameChange(t,e)},this.engine.onProgressUpdate=t=>{this.syncAnimations(t)})})}loadEngine(t,e){return qs(this,void 0,void 0,function*(){let n;try{if(t.trim().startsWith("{"))n=JSON.parse(t);else{const e=yield fetch(t);if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);n=yield e.json()}}catch(t){throw console.error("[CoreOrchestrator] Failed to load configuration:",t),t}n.settings||(n.settings={baseResolution:{width:1920,height:1080},scrollMode:"vh"}),n.settings.basePath||t.trim().startsWith("{")||(n.settings.basePath=t.substring(0,t.lastIndexOf("/")));const i=new s(n,{scrub:this.options.scrub,depthTilt:this.options.depthTilt});let r=e.querySelector("canvas");return r||(r=document.createElement("canvas"),r.style.width="100%",r.style.height="100%",r.style.display="block",r.style.objectFit="cover",e.appendChild(r)),i.attachCanvas(r),i})}setupScrollTracking(){if(!this.engine)return;const t=this.container.dataset.scftOffset;let e=["start end","end start"];try{t&&(e=JSON.parse(t))}catch(t){}this.motionScrollCancel=oe(t=>{this.engine&&this.engine.update(t)},{target:this.container,offset:e})}parseAnimatedElements(){this.container.querySelectorAll("[data-scft-animate]").forEach(t=>{try{const e=t.getAttribute("data-scft-animate");if(!e)return;const n=JSON.parse(e),i=Hs(t,n,{duration:1,ease:"linear"});i.pause(),i.time=0,this.syncedAnimations.push(i)}catch(e){console.warn("[CoreOrchestrator] Failed to parse data-scft-animate on element",t,e)}})}syncAnimations(t){for(const e of this.syncedAnimations)e.time=t}syncTrackingLayers(t){if(!this.engine)return;this.container.querySelectorAll("[data-scft-layer-tracking]").forEach(e=>qs(this,void 0,void 0,function*(){const n=e.dataset.scftLayerTracking;if(!n)return;yield this.engine.loadTrackingData(n);const i=this.engine.getTrackedCoords(n,t);e.style.left=100*i.x+"%",e.style.top=100*i.y+"%"}))}getEngine(){return this.engine}destroy(){this.destroyed=!0,this.motionScrollCancel&&(this.motionScrollCancel(),this.motionScrollCancel=void 0);for(const t of this.syncedAnimations)t.stop();this.syncedAnimations=[],this.engine&&(this.engine.destroy(),this.engine=null),this.onFrameChange=void 0}}Gs.stylesInjected=!1;const Zs=Object.assign(s,{CoreOrchestrator:Gs});return e=e.default})());
@@ -1,22 +1,40 @@
1
1
  import React from 'react';
2
- import { CoreEngine } from '../core/CoreEngine';
3
- import { ProjectConfiguration } from '../core/types';
2
+ import { CoreEngine } from '../core';
4
3
  interface SCFTContext {
5
4
  progress: number;
6
5
  frame: number;
7
6
  engine: CoreEngine | null;
8
7
  }
9
8
  export interface ScrollCraftProviderProps {
10
- project: ProjectConfiguration | string;
11
- children: React.ReactNode;
9
+ type?: string;
12
10
  containerHeight?: string;
13
- canvasHeight?: string;
11
+ sceneHeight?: string;
12
+ sceneTop?: string | 0;
14
13
  offset?: any;
15
14
  scrub?: number;
15
+ children: React.ReactNode;
16
16
  }
17
17
  export declare const ScrollCraftProvider: React.FC<ScrollCraftProviderProps>;
18
18
  export declare const ScrollCraftCanvas: React.FC<{
19
+ project: string;
20
+ depthtilt?: number | string;
21
+ width?: string;
22
+ height?: string;
23
+ style?: React.CSSProperties;
24
+ }>;
25
+ export declare const ScrollCraftLayer: React.FC<{
26
+ align?: string;
27
+ style?: React.CSSProperties;
28
+ children: React.ReactNode;
29
+ }>;
30
+ export declare const ScrollCraftLayerTracking: React.FC<{
31
+ id?: string;
32
+ offset?: {
33
+ x: number;
34
+ y: number;
35
+ };
19
36
  style?: React.CSSProperties;
37
+ children: React.ReactNode;
20
38
  }>;
21
39
  export declare const SubjectLayer: React.FC<{
22
40
  id?: string;
@@ -24,6 +42,7 @@ export declare const SubjectLayer: React.FC<{
24
42
  x: number;
25
43
  y: number;
26
44
  };
45
+ style?: React.CSSProperties;
27
46
  children: React.ReactNode;
28
47
  }>;
29
48
  export declare const useScrollCraft: () => SCFTContext;
@@ -1 +1 @@
1
- export { ScrollCraftProvider, ScrollCraftCanvas, SubjectLayer, useScrollCraft } from './ScrollCraftProvider';
1
+ export { ScrollCraftProvider, ScrollCraftCanvas, ScrollCraftLayer, ScrollCraftLayerTracking, SubjectLayer, useScrollCraft } from './ScrollCraftProvider';