cineview 0.0.1-beta → 1.0.1
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 +74 -56
- package/README.zh-CN.md +74 -56
- package/dist/cineview-drag.umd.js +1 -1
- package/dist/cineview-scroll.umd.js +1 -1
- package/dist/cineview.es.mjs +1 -1
- package/dist/cineview.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&typeof module<"u"?t(exports,require("react"),require("react/jsx-runtime"),require("framer-motion"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react/jsx-runtime","framer-motion","react-dom"],t):t((e=typeof globalThis<"u"?globalThis:e||self).Cineview={},e.React,e.ReactJSXRuntime,e.FramerMotion,e.ReactDOM)}(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var a,o,s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,m=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},g=(e,t)=>{let n={};for(var r in e)c(n,r,{get:e[r],enumerable:!0});return t||c(n,Symbol.toStringTag,{value:"Module"}),n};o=null!=(a=t)?s(d(a)):{},t=((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var i,a=u(t),o=0,s=a.length;o<s;o++)i=a[o],!f.call(e,i)&&void 0!==i&&c(e,i,{get:(e=>t[e]).bind(null,i),enumerable:!(r=l(t,i))||r.enumerable});return e})(a&&a.__esModule&&f.call(a,"default")?o:c(o,"default",{value:a,enumerable:!0}),a);var p=(0,t.createContext)(null),h=({designSize:e,children:r})=>{const i=function(e){return void 0===e?750:Number.isFinite(e)&&e>0?e:(String(e),750)}(e),[a,o]=(0,t.useState)(typeof window<"u"?window.innerWidth:750),s=(0,t.useMemo)(()=>a/i,[a,i]),c=(0,t.useCallback)(e=>e*s,[s]);(0,t.useEffect)(()=>{if(typeof window>"u")return;const{debounced:e,cancel:t}=function(){let e=null;return{debounced:function(...t){e&&clearTimeout(e),e=setTimeout(()=>{(()=>{o(window.innerWidth)})(...t),e=null},150)},cancel:()=>{e&&(clearTimeout(e),e=null)}}}();return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),t()}},[]);const l=(0,t.useMemo)(()=>({scale:s,convert:c}),[s,c]),u=(0,t.useMemo)(()=>({"--cineview-unit":`${s}px`}),[s]);return(0,n.jsx)(p.Provider,{value:l,children:(0,n.jsx)("div",{className:"cineview-responsive-container",style:u,children:r})})},v=()=>(0,t.useContext)(p),y=new Set,x=new Set;function S(e){if(!e)return;const t=y.has(e);y.add(e),t||x.forEach(t=>t(e))}var b=new Map,w=new Set,M=new Map,R=new Set,E=new Map,k=0,P=/\.(mp4|webm|mov|m4v|ogv|ogg)(\?|#|$)/i;function I(e){return P.test(e)?"video":null}function C(e){const t=b.get(e);if(t)return A(e),t.objectUrl}function A(e){const t=b.get(e);t&&(b.delete(e),b.set(e,t))}function D(e){typeof URL<"u"&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function T(e){for(const[t,n]of b){if(k<=134217728)break;t===e||(E.get(t)??0)>0||(b.delete(t),w.delete(t),k-=n.bytes,D(n.objectUrl))}}function L(e,t){if(!e||w.has(e))return Promise.resolve();const n=M.get(e);if(n)return n;if(typeof fetch>"u")return Promise.reject(new Error("preloadMedia requires fetch (client-side only)"));if(!(t??I(e)))return Promise.reject(new Error(`Cannot determine media type: ${e} (pass explicit kind)`));const r=async function(e){const t=typeof AbortController<"u"?new AbortController:null,n=t?setTimeout(()=>t.abort(),3e4):null;try{const n=await fetch(e,t?{signal:t.signal}:void 0);if(!n.ok)throw new Error(`Failed to preload media: ${e} (HTTP ${n.status})`);const r=await n.blob();if(!r)throw new Error(`Invalid blob response for media: ${e}`);(function(e,t){const n=b.get(e);n&&(k-=n.bytes,D(n.objectUrl)),b.set(e,t),k+=t.bytes,T(e)})(e,{kind:"video",objectUrl:URL.createObjectURL(r),bytes:r.size}),function(e){const t=w.has(e);w.add(e),t||R.forEach(t=>t(e))}(e)}catch(n){if(t?.signal.aborted){const t=new Error(`Media preload timed out after 30000ms: ${e}`);throw t.cause=n,t}throw n}finally{null!==n&&clearTimeout(n)}}(e).finally(()=>{M.delete(e)});return M.set(e,r),r}function O(e){return Array.from(new Set(e.filter(e=>e.length>0)))}function V(e,t,n,r){const i=O(e).filter(e=>!n.has(e)&&!r.has(e)),a=new Set(i);return{priorityBatch:i,backgroundBatch:O(t).filter(e=>!n.has(e)&&!r.has(e)&&!a.has(e))}}var j="(prefers-reduced-motion: reduce)";function z(){return typeof window<"u"&&"function"==typeof window.matchMedia&&window.matchMedia(j).matches}function N(e){if(typeof window>"u"||"function"!=typeof window.matchMedia)return()=>{};const t=window.matchMedia(j);return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}var F=new class{constructor(){this.frameCount=0,this.lastTime=performance.now(),this.frameTimes=[],this.memorySamples=[],this.lastMemorySampleTime=0,this.cachedMemoryUsage=void 0,this.cachedBundleSizeKb=0,this.rafId=null,this.isMonitoring=!1,this.measure=()=>{if(!this.isMonitoring)return;const e=performance.now(),t=e-this.lastTime;this.frameCount++,this.frameTimes.push(t),this.frameTimes.length>60&&this.frameTimes.shift(),this.sampleMemory(e),this.lastTime=e,this.rafId=requestAnimationFrame(this.measure)}}start(){this.isMonitoring||(this.isMonitoring=!0,this.frameCount=0,this.lastTime=performance.now(),this.frameTimes=[],this.memorySamples=[],this.lastMemorySampleTime=0,this.cachedMemoryUsage=void 0,this.cachedBundleSizeKb=this.estimateBundleSizeKb(),this.measure())}stop(){this.isMonitoring=!1,null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)}getMetrics(){const e=this.calculateAvgFrameTime();if(0===this.frameTimes.length)return{fps:0,avgFrameTime:0,memoryUsage:this.getMemoryUsage(),bundleSize:this.getBundleSizeKb()};const t=1e3/Math.max(e,1);return{fps:Math.round(10*Math.min(Math.max(t,0),60))/10,avgFrameTime:Math.round(100*e)/100,memoryUsage:this.getMemoryUsage(),bundleSize:this.getBundleSizeKb()}}calculateAvgFrameTime(){return 0===this.frameTimes.length?0:this.frameTimes.reduce((e,t)=>e+t,0)/this.frameTimes.length}getMemoryUsage(){return this.sampleMemory(performance.now(),void 0===this.cachedMemoryUsage),this.cachedMemoryUsage}sampleMemory(e,t=!1){if(!performance.memory)return this.cachedMemoryUsage=void 0,void(this.memorySamples=[]);if(!t&&e-this.lastMemorySampleTime<1e3)return;const n=performance.memory.usedJSHeapSize/1048576;this.memorySamples.push(n),this.memorySamples.length>8&&this.memorySamples.shift();const r=[...this.memorySamples].sort((e,t)=>e-t),i=Math.floor(r.length/2),a=r.length%2==0?(r[i-1]+r[i])/2:r[i];this.cachedMemoryUsage=Math.round(10*a)/10,this.lastMemorySampleTime=e}getBundleSizeKb(){return this.cachedBundleSizeKb>0||(this.cachedBundleSizeKb=this.estimateBundleSizeKb()),this.cachedBundleSizeKb}estimateBundleSizeKb(){if(typeof performance>"u"||"function"!=typeof performance.getEntriesByType)return 0;const e=performance.getEntriesByType("resource");if(0===e.length)return 0;const t=e.reduce((e,t)=>{const n=t.name.toLowerCase();return n.endsWith(".js")||n.endsWith(".mjs")||n.endsWith(".css")||n.includes(".js?")||n.includes(".mjs?")||n.includes(".css?")?e+Math.max(t.decodedBodySize||0,t.transferSize||0):e},0);return Math.round(t/1024*10)/10}},$=0,B=F;function q(e){return e.assets?.preloadImages??[]}function H(e,t,n){return Math.min(n,Math.max(t,e))}function W(e,t,n,r){if(!(e instanceof Element)||0===r)return!1;const i="x"===n?"overflowX":"overflowY";let a=e;for(;a&&a!==t;){if(a instanceof HTMLElement){const e=window.getComputedStyle(a)[i],t="auto"===e||"scroll"===e||"overlay"===e,o="x"===n?a.scrollLeft:a.scrollTop,s=Math.max(("x"===n?a.scrollWidth:a.scrollHeight)-("x"===n?a.clientWidth:a.clientHeight),0);if(t&&s>1&&(r>0&&o<s-1||r<0&&o>1))return!0}a=a.parentElement}return!1}function Y(e,t,n){const r=Math.max(.86*n,1);switch(e){case"PageDown":return r;case"PageUp":return-r;case" ":case"Spacebar":return t?-r:r;case"ArrowDown":return 80;case"ArrowUp":return-80;case"Home":return Number.NEGATIVE_INFINITY;case"End":return Number.POSITIVE_INFINITY;default:return 0}}function U(e,t){if(!(e instanceof Element))return!1;const n=e.tagName.toLowerCase();return!(" "!==t||!("button"===n||"summary"===n||"a"===n&&e.hasAttribute("href")||"button"===e.getAttribute("role")||"link"===e.getAttribute("role")))||"input"===n||"textarea"===n||"select"===n||!!(e instanceof HTMLElement&&e.isContentEditable)}function X(e){if(!(0,t.isValidElement)(e)||"string"==typeof e.type)return!1;let n=e.type;for(let e=0;e<6&&n;e+=1){if(("function"==typeof n||"object"==typeof n)&&null!==n&&!0===n.cineViewScene)return!0;if("object"==typeof n&&null!==n&&"type"in n)n=n.type;else{if("object"!=typeof n||null===n||!("render"in n))break;n=n.render}}return!1}function K(e){return e.layout?.overlap??"cover"}function Z(e,t,n,r){const i="takeover"===r,a=e=>i?Math.max(e,1):e;if("number"==typeof e&&Number.isFinite(e)&&e>0)return i?null:e;if("string"!=typeof e)return null;const o=e.trim().toLowerCase();if(!o||"auto"===o)return null;const s=Number.parseFloat(o);return!Number.isFinite(s)||s<=0?null:o.endsWith("px")?i?null:s:o.endsWith("vh")?a(n*s/100):o.endsWith("vw")?a(t*s/100):null}function _(e,t,n){return Z(e,t,n,"takeover")}function G(e,t,n){const r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a="x"===n?t.scrollLeft:t.scrollTop;return"x"===n?r.left-i.left+a:r.top-i.top+a}function J({direction:e,viewportSpan:r,scrollContentSpan:i,scrollOffset:a,scrollOffsetStore:o,isScrolling:s,config:c,onScrollToOffset:l}){const u=c.autoHide??!0,d=c.ariaLabel??"CineView scroll position",f=Math.max(c.width??6,4),m=Math.max(c.radius??999,0),g=Math.max(c.inset??0,0),p=c.trackColor??"transparent",h=c.thumbColor??"rgba(255, 255, 255, 0.28)",v=c.thumbHoverColor??h,[y,x]=(0,t.useState)(!1),[S,b]=(0,t.useState)(!1),w=(0,t.useRef)(null),M=(0,t.useRef)(null),R=Math.max(i-r,0),E=H(o?.getSnapshot()??a,0,R),k=(0,t.useRef)(E);k.current=E;const P=R+r,I=R>1,C=Math.max(r-2*g,1),A=R>0?H(r/Math.max(P,r)*C,Math.min(40,C),C):C,D=Math.max(C-A,0),T=R>0?H(E/R*D,0,D):0;(0,t.useEffect)(()=>{const t=()=>{const t=H(o?.getSnapshot()??a,0,R);if(k.current=t,w.current?.setAttribute("aria-valuenow",String(Math.round(t))),!M.current)return;const n=R>0?H(t/R*D,0,D):0;"x"===e?M.current.style.left=`${n}px`:M.current.style.top=`${n}px`};return t(),o?.subscribe(t)},[e,a,R,o,D]);const L=(0,t.useRef)(null);(0,t.useEffect)(()=>{L.current?.()},[e,R,l,C,A]);const O=(0,t.useCallback)(e=>{const t=Y(e.key,e.shiftKey,r);0!==t&&(l(t===Number.POSITIVE_INFINITY?R:t===Number.NEGATIVE_INFINITY?0:H(k.current+t,0,R)),e.preventDefault())},[R,l,r]),V=(0,t.useCallback)(t=>{if(R<=0||typeof window>"u"||"mouse"===t.pointerType&&0!==t.button||!1===t.isPrimary||(t.preventDefault(),L.current))return;const n=t.currentTarget.getBoundingClientRect(),r="x"===e?n.width:n.height,i="x"===e?n.left:n.top,a="x"===e?t.clientX:t.clientY,o=R>0?H(k.current/R*Math.max(r-A,0),0,Math.max(r-A,0)):0,s=a-i,c=s>=o&&s<=o+A,u=c?s-o:A/2,d=e=>{const t=Math.max(r-A,0),n=H(e-i-u,0,t);l((t>0?n/t:0)*R)};if(d(a),!c)return;const f=t.pointerId,m=t=>{t.pointerId===f&&(t.preventDefault(),d("x"===e?t.clientX:t.clientY))},g=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),L.current===g&&(L.current=null)};function p(e){e.pointerId===f&&g()}L.current=g,window.addEventListener("pointermove",m,{passive:!1}),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p)},[e,R,l,A]);return(0,t.useEffect)(()=>()=>{L.current?.()},[]),I?(0,n.jsx)("div",{"data-cineview-scrollbar-overlay":"true",style:{position:"absolute",inset:0,zIndex:80,pointerEvents:"none",opacity:u?s||y?1:0:1,transition:u?s?"opacity 0.08s ease-out":"opacity 0.5s ease-in 0.15s":"none"},children:(0,n.jsx)("div",{ref:w,role:"scrollbar","aria-label":d,"aria-orientation":"x"===e?"horizontal":"vertical","aria-valuemin":0,"aria-valuemax":Math.round(R),"aria-valuenow":Math.round(E),tabIndex:0,"data-cineview-scrollbar-rail":"true",onPointerDown:V,onKeyDown:O,onFocus:()=>x(!0),onBlur:()=>x(!1),style:"x"===e?{position:"absolute",left:g,bottom:g,width:C,height:f,borderRadius:m,background:p,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.14)",pointerEvents:"auto",touchAction:"none",cursor:"pointer",outline:y?"2px solid rgba(24, 119, 242, 0.95)":"none",outlineOffset:2}:{position:"absolute",top:g,right:g,width:f,height:C,borderRadius:m,background:p,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.14)",pointerEvents:"auto",touchAction:"none",cursor:"pointer",outline:y?"2px solid rgba(24, 119, 242, 0.95)":"none",outlineOffset:2},children:(0,n.jsx)("div",{ref:M,"data-cineview-scrollbar-thumb":"true",onPointerEnter:()=>b(!0),onPointerLeave:()=>b(!1),style:"x"===e?{position:"absolute",left:T,top:0,width:A,height:f,borderRadius:m,background:S?v:h,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.16)",cursor:"grab"}:{position:"absolute",top:T,left:0,width:f,height:A,borderRadius:m,background:S?v:h,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.16)",cursor:"grab"}})})}):null}function Q(e,t){let n=e;const r=new Map;return{getSnapshot:()=>n,getKeySnapshot:e=>t(n,e),subscribeKey:(e,t)=>{const n=r.get(e)??new Set;return n.add(t),r.set(e,n),()=>{n.delete(t),0===n.size&&r.delete(e)}},setSnapshot:e=>{if(Object.is(n,e))return;const i=n;n=e,r.forEach((n,r)=>{Object.is(t(i,r),t(e,r))||n.forEach(e=>e())})}}}J.displayName="ScrollbarOverlay";var ee=typeof document<"u"?t.useLayoutEffect:t.useEffect,te={sceneLayout:null,sceneZoneState:null,sceneTimelineState:null,isCurrent:!1,isBackdropActive:!1,visualViewportOffset:0,isScrolling:!1,scrollDirection:null,activeSceneIndex:0,viewportWidth:0,viewportHeight:0,firstSceneEnterGateKnown:!1,firstSceneEnterActive:!1,firstSceneEnterReady:!1,direction:"y",sceneCount:0,sceneSizing:"content",exposeTakeoverDebugData:!1,takeoverSceneSpan:null},ne=(0,t.memo)(function({child:e,store:r,frameStore:i,sceneIndex:a,setWrapperRef:o,scrollCallbacks:s}){const c=(0,t.useCallback)(e=>r.subscribeKey(a,e),[a,r]),l=(0,t.useCallback)(()=>r.getKeySnapshot(a)??te,[a,r]),{sceneLayout:u,sceneZoneState:d,sceneTimelineState:f,isCurrent:m,isBackdropActive:g,visualViewportOffset:p,isScrolling:h,scrollDirection:v,activeSceneIndex:y,viewportWidth:x,viewportHeight:S,firstSceneEnterGateKnown:b,firstSceneEnterActive:w,firstSceneEnterReady:M,direction:R,sceneCount:E,sceneSizing:k,exposeTakeoverDebugData:P,takeoverSceneSpan:I}=(0,t.useSyncExternalStore)(c,l,l),C=!!e.props.scroll,A=(0,t.useRef)(null);ee(()=>{const e=A.current;if(!e)return;if(!P||!C||!i)return e.removeAttribute("data-cineview-takeover-progress-px"),void e.removeAttribute("data-cineview-takeover-viewport-offset");const t=()=>{const t=i.getKeySnapshot(a);e.setAttribute("data-cineview-takeover-progress-px",null==t?.zoneProgressPx?"":String(t.zoneProgressPx)),e.setAttribute("data-cineview-takeover-viewport-offset",t?String(t.visualViewportOffset):"")};return t(),i.subscribeKey(a,t)},[P,i,C,a]);const D=Math.max("x"===R?x:S,1),T="screen"===k&&!C,L=u?.flowSpan,O=u?.visualSpan??I??D,V=e.props.layout?.width??e.props.sceneWidth??"100vw",j=C?Math.max((O-D)/2,0):0,z=C?Math.max((D-O)/2,0):0,N=(0,t.useCallback)(e=>o(a,e),[a,o]),F=t.default.useRef(e.props.callbacks);F.current=e.props.callbacks;const $=t.default.useMemo(()=>({get onVisibilityChange(){const e=F.current?.onVisibilityChange,t=s?.onSceneVisibilityChange;return n=>{e?.(n),t?.(n)}}}),[s?.onSceneVisibilityChange]),B=t.default.useRef(e.props.layout);B.current=e.props.layout;const q=t.default.useMemo(()=>{const e=B.current;return C&&null!==I?{...e,..."x"===R?{width:I}:{height:I}}:"x"!==R||C?e:{...e,width:"auto"===V?"auto":"100%"}},[C,I,R,V]),H=t.default.useMemo(()=>({mode:"scroll",direction:R,isActive:m,sceneIndex:a,totalScenes:E,currentSceneIndex:y,transitionDirection:v,isSceneAnimating:h,sharedElapsedMs:0,sharedTimelineDurationMs:0,viewportWidth:x,viewportHeight:S,firstSceneEnterGateKnown:b,firstSceneEnterActive:w,firstSceneEnterReady:M}),[R,m,a,E,y,v,h,x,S,b,w,M]),W=t.default.useMemo(()=>({progress:f?.sceneProgress??0,isScrolling:h,direction:v,transitionSnapshot:null,backdropActive:g,timelineState:f,activeSceneIndex:y,viewportOffset:p,onProgressChange:void 0,onDirectionChange:void 0,onScrollingChange:void 0,onCommit:void 0,onReset:void 0,frameStore:i,sceneIndex:a}),[f,h,v,g,y,p,i,a]),Y=t.default.cloneElement(e,{layout:q,callbacks:$,sceneRuntime:H,scrollRuntime:W});return(0,n.jsx)("div",{ref:N,"data-scene-index":a,style:{position:"relative",width:"x"===R?C&&"number"==typeof L?L:C?"100vw":V:"100%",flex:"x"===R?"0 0 auto":void 0,minHeight:"y"===R&&T?"100vh":void 0,minWidth:"x"===R&&T?"100vw":void 0,...C&&"number"==typeof L?"x"===R?{boxSizing:"border-box",paddingLeft:j}:{boxSizing:"border-box",paddingTop:j,height:L}:{}},children:C?(0,n.jsx)("div",{ref:A,"data-cineview-takeover-shell":a,...P?{"data-cineview-takeover-active-zone":d?.active?d.zoneId:"","data-cineview-takeover-total-distance-px":d?.totalBudgetPx??"","data-cineview-takeover-center-lock-offset":u?.centerLockOffset??"","data-cineview-takeover-segment-start":u?.segmentStart??"","data-cineview-takeover-segment-end":u?.segmentEnd??""}:{},style:"x"===R?{position:"sticky",left:z,width:O,maxWidth:"100vw",height:"100%",overflow:"hidden",zIndex:d?.active?30:void 0}:{position:"sticky",top:z,width:"100%",height:O,maxHeight:"100vh",overflow:"hidden",zIndex:d?.active?30:void 0},children:(0,n.jsx)("div",{"data-cineview-takeover-content":a,style:"x"===R?{width:O,height:"100%",transform:`translateX(${-j}px)`}:{width:"100%",height:O,transform:`translateY(${-j}px)`},children:Y})}):Y},e.key??`scene-${a}`)});function re({childrenArray:e,store:r,frameStore:i,setWrapperRef:a,scrollCallbacks:o}){let s=0;return(0,n.jsx)(n.Fragment,{children:e.map((e,c)=>{if(!X(e))return(0,n.jsx)(t.default.Fragment,{children:e},`flow-${c}`);const l=s++;return(0,n.jsx)(ne,{child:e,store:r,frameStore:i,sceneIndex:l,setWrapperRef:a,scrollCallbacks:o},e.key??`scene-${l}`)})})}var ie=(0,t.createContext)(null),ae=(0,t.createContext)(null),oe=(0,t.createContext)(null);function se(e){return Number.isFinite(e)?Math.max(0,e):0}function ce(e,t,n){return Math.min(n,Math.max(t,e))}function le(e,t,n,r){return void 0===e?t:n+(r-n)*ce(e,0,1)}function ue(e,t,n,r,i,a){const o=n.get(e);if(o)return o;const s=t.get(e);if(!s){const t={animateId:e,startMs:0,enterStartMs:0,enterEndMs:0,exitStartMs:null,exitEndMs:null,totalEndMs:0,hasExit:!1};return n.set(e,t),t}if(r.has(e)){const t=[...r],a=t.indexOf(e);t.slice(a).forEach(e=>i.add(e));const o={animateId:e,startMs:se(s.delay),enterStartMs:se(s.delay),enterEndMs:se(s.delay)+se(s.enterDuration),exitStartMs:null,exitEndMs:null,totalEndMs:se(s.delay)+se(s.enterDuration),hasExit:!1};return n.set(e,o),o}r.add(e);let c=0;if(s.after){const o=ue(s.after,t,n,r,i,a);i.has(e)||(c=a.get(s.after)??o.enterEndMs)}const l=c+se(s.delay),u=Math.max(se(s.enterDuration),1),d=se(s.exitDuration),f=l+u,m=d>0,g=m?f+d:null,p={animateId:e,startMs:l,enterStartMs:l,enterEndMs:f,exitStartMs:m?f:null,exitEndMs:g,totalEndMs:g??f,hasExit:m};return n.set(e,p),r.delete(e),p}function de(e){const t=new Map,n=new Set;let r=new Map,i=e;const a=[...e.values()].some(e=>void 0!==e.phase?.start||void 0!==e.phase?.end),o=()=>{i.forEach((e,a)=>{ue(a,i,t,new Set,n,r)})};o();let s,c=0;if(a){const a=function(e,t){const n=new Set;e.forEach((e,t)=>{[e.phase?.start,e.phase?.end].some(e=>void 0!==e&&!Number.isFinite(e))&&n.add(t)});const r=(e,t)=>e.map(e=>({...e,offset:e.offset+t})),i=(...e)=>{const t=new Map;return e.flat().forEach(e=>{(!t.has(e.fraction)||t.get(e.fraction).offset<e.offset)&&t.set(e.fraction,e)}),[...t.values()]};for(;;){const a=new Map,o=[],s=c=>{const l=a.get(c);if(l)return l;const u=e.get(c);if(!u)return[{fraction:0,offset:0}];const d=!!u.after&&!t.has(c),f=d?s(u.after):[{fraction:0,offset:0}],m=r(f,se(u.delay)),g=r(m,Math.max(se(u.enterDuration),1));o.push(...r(g,se(u.exitDuration)));const p=n.has(c)?void 0:u.phase;let h=g;if(void 0!==p?.start||void 0!==p?.end){const e=void 0===p.start?m:i([{fraction:ce(p.start,0,1),offset:0,phaseId:c}],d?m:[]);h=i(void 0===p.end?g:[{fraction:ce(p.end,0,1),offset:0,phaseId:c}],r(e,1)),o.push(...r(h,u.exitDuration>0?1:0))}return a.set(c,h),h};e.forEach((e,t)=>s(t));let c=0;const l=n.size;if(o.forEach(e=>{const t=e.fraction<1?e.offset/(1-e.fraction):0===e.offset?0:1/0;!Number.isFinite(t)&&e.phaseId?n.add(e.phaseId):c=Math.max(c,t)}),n.size!==l)continue;const u=new Map;return a.forEach((e,t)=>{u.set(t,e.reduce((e,t)=>Math.max(e,t.fraction*c+t.offset),0))}),{enterEnds:u,totalDurationMs:c,invalidPhaseIds:n}}}(e,n);c=a.totalDurationMs,r=a.enterEnds,s=a.invalidPhaseIds,s.size>0&&(i=new Map(e),s.forEach(t=>{i.set(t,{...e.get(t),phase:void 0})})),t.clear(),n.clear(),o()}t.forEach(e=>{c=Math.max(c,e.totalEndMs)});const l=c>0?Math.max(1*c,1):0,u={};return t.forEach((e,t)=>{const r=i.get(t),a=void 0!==r?.phase?.start||void 0!==r?.phase?.end,o={...e,startPx:1*e.startMs,enterStartPx:1*e.enterStartMs,enterEndPx:1*e.enterEndMs,exitStartPx:null===e.exitStartMs?null:1*e.exitStartMs,exitEndPx:null===e.exitEndMs?null:1*e.exitEndMs,totalEndPx:1*e.totalEndMs,phaseStartPx:0,phaseEndPx:0},s=o.enterStartPx,c=Math.max(o.enterEndPx,s+1),d=a?0:s,f=a?l:c,m=Math.max(le(r?.phase?.start,s,d,f),r?.after&&!n.has(t)?s:0),g=Math.max(le(r?.phase?.end,c,d,f),m+1);if(o.phaseStartPx=m,o.phaseEndPx=g,a)if(o.hasExit){const t=se((e.exitEndMs??e.totalEndMs)-(e.exitStartMs??e.enterEndMs)),n=1*Math.max(t,1);o.exitEndPx=l,o.exitStartPx=Math.max(g,l-n),o.totalEndPx=o.exitEndPx}else o.totalEndPx=g;u[t]=o}),{budgets:u,totalDurationMs:c,totalBudgetPx:l,...s?.size?{invalidPhaseIds:[...s]}:{}}}var fe=(0,t.createContext)(null);function me(){return(0,t.useContext)(fe)}var ge=(0,t.forwardRef)(function({children:e,designWidth:r,direction:i,sceneSizing:a="content",enterMargin:o,exitMargin:s,scrollbar:c,callbacks:l,monitor:u,debug:d},f){const{designSize:m}=function(e){const t=e;return"number"==typeof t&&Number.isFinite(t)&&t>0?{designSize:t}:{designSize:750}}(r),g=(0,t.useMemo)(()=>{const e=function(e){return e?{common:{onReady:e.onReady,onLoadProgress:e.onLoadProgress,onSceneEnter:e.onSceneEnter,onSceneLeave:e.onSceneLeave,onError:e.onError},drag:{onDragStart:e.onDragStart,onDragProgress:e.onDragProgress,onDragBlocked:e.onDragBlocked,onDragEnd:e.onDragEnd,onDragCancel:e.onDragCancel},scroll:{onZoneEnter:e.onZoneEnter,onZoneLeave:e.onZoneLeave,onZoneProgress:e.onZoneProgress,onSceneVisibilityChange:e.onSceneVisibilityChange}}:{common:{},drag:{},scroll:{}}}(l);return{common:e.common,drag:e.drag,scroll:e.scroll}},[l?.onReady,l?.onLoadProgress,l?.onSceneEnter,l?.onSceneLeave,l?.onError,l?.onDragStart,l?.onDragProgress,l?.onDragBlocked,l?.onDragEnd,l?.onDragCancel,l?.onZoneEnter,l?.onZoneLeave,l?.onZoneProgress,l?.onSceneVisibilityChange]),p=i??"y",v=(0,t.useRef)(null),y=(0,t.useRef)(0),x=(0,t.useRef)(function(){let e=0;const t=new Set;return{getSnapshot:()=>e,subscribe:e=>(t.add(e),()=>t.delete(e)),setSnapshot:n=>{Object.is(e,n)||(e=n,t.forEach(e=>e()))}}}()),b=(0,t.useRef)(null),w=(0,t.useRef)(()=>{}),M=(0,t.useRef)(0),R=(0,t.useRef)(null),E=(0,t.useRef)([]),[k,P,C,A]=(0,t.useMemo)(()=>{const n=new Map,r=[],i=[];let a=!1;return[t.Children.toArray(e).map(e=>{if(a||(a=!1),!X(e))return e;const o=i.length,s=e;let c=s;if(s.props.scroll){const e=s.props.scroll.zoneId??s.props.sceneId;if(void 0!==e){const i=n.get(e);void 0===i?n.set(e,o):(r[o]=[e,i],c=t.default.cloneElement(s,{scroll:void 0}))}}return i.push(c),c}),i,r,a]},[e]);E.current=P;const{viewportSize:D,viewportSizeRef:T,getViewportSpan:j,updateViewportMetrics:ne}=function({rootRef:e,direction:n}){const[r,i]=(0,t.useState)({width:0,height:0}),a=(0,t.useRef)({width:0,height:0});return{viewportSize:r,viewportSizeRef:a,getViewportSpan:(0,t.useCallback)(()=>{const t=e.current;return Math.max("x"===n?t?.clientWidth??a.current.width:t?.clientHeight??a.current.height,1)},[n,e]),updateViewportMetrics:(0,t.useCallback)(()=>{const t=e.current;if(!t)return;const n=t.clientWidth,r=t.clientHeight;a.current={width:n,height:r},i(e=>e.width===n&&e.height===r?e:{width:n,height:r})},[e])}}({rootRef:v,direction:p}),{zoneRegistryRef:oe,zoneStatesRef:se,timelineStoreRef:ce,zoneRuntimeVersion:le,getZoneIdForScene:ue,getZoneDistance:me,zoneRuntimeValue:ge,zoneTimelineValue:pe}=function({scrollOffsetRef:e,measureSceneLayoutsRef:n,updateSceneRenderSnapshotsRef:r,onError:i}){const a=(0,t.useRef)(i);a.current=i;const o=(0,t.useRef)(new WeakSet),s=(0,t.useRef)(new Map),c=(0,t.useRef)(new Map),l=(0,t.useRef)({}),u=(0,t.useRef)(Q({},(e,t)=>e[t])),[d,f]=(0,t.useState)(0),m=(0,t.useCallback)(e=>{for(const[t,n]of s.current.entries())if(n.sceneIndex===e)return t;return null},[]),g=(0,t.useCallback)(e=>{const t=m(e);return t?l.current[t]?.totalBudgetPx??0:0},[m]),p=(0,t.useCallback)((t,n)=>{const i=l.current,a=n(i[t]);if(a){const e=i[t];if(e&&e.sceneIndex===a.sceneIndex&&e.progressPx===a.progressPx&&e.totalBudgetPx===a.totalBudgetPx&&e.active===a.active&&e.direction===a.direction&&e.approach===a.approach&&function(e,t){if(e.totalDurationMs!==t.totalDurationMs||e.totalBudgetPx!==t.totalBudgetPx||(e.invalidPhaseIds??[]).join("\0")!==(t.invalidPhaseIds??[]).join("\0"))return!1;const n=Object.keys(e.budgets);return n.length===Object.keys(t.budgets).length&&n.every(n=>{const r=e.budgets[n],i=t.budgets[n];return!!(r&&i&&function(e,t){return e.animateId===t.animateId&&e.startMs===t.startMs&&e.enterStartMs===t.enterStartMs&&e.enterEndMs===t.enterEndMs&&e.exitStartMs===t.exitStartMs&&e.exitEndMs===t.exitEndMs&&e.totalEndMs===t.totalEndMs&&e.startPx===t.startPx&&e.enterStartPx===t.enterStartPx&&e.enterEndPx===t.enterEndPx&&e.exitStartPx===t.exitStartPx&&e.exitEndPx===t.exitEndPx&&e.totalEndPx===t.totalEndPx&&e.phaseStartPx===t.phaseStartPx&&e.phaseEndPx===t.phaseEndPx&&e.hasExit===t.hasExit}(r,i))})}(e.sequence,a.sequence))return;l.current={...i,[t]:a}}else{if(!(t in i))return;const e={...i};delete e[t],l.current=e}u.current.setSnapshot(l.current),r.current(e.current)},[e,r]),h=(0,t.useCallback)(e=>{const t=s.current.get(e);if(!t)return void p(e,()=>null);const n=c.current.get(e)??new Map,r=de(n);r.invalidPhaseIds?.forEach(t=>{const r=n.get(t);if(!r||o.current.has(r))return;o.current.add(r);const i=`Animate "${t}" has an invalid timeline.phase in zone "${e}". Its phase cannot fit reachable entrance and exit intervals in a finite zone budget; using duration, delay and after instead.`;a.current?.({code:"INVALID_ANIMATION",message:i,context:{zoneId:e,animateId:t,field:"timeline.phase"}})}),p(e,n=>({zoneId:e,sceneIndex:t.sceneIndex,progressPx:Math.min(r.totalBudgetPx,Math.max(n?.progressPx??0,0)),totalBudgetPx:r.totalBudgetPx,active:n?.active??!1,direction:n?.direction??null,sequence:r,approach:n?.approach??"near"})),f(e=>e+1)},[p]);(0,t.useRef)(new Set);const v=(0,t.useCallback)((e,t)=>{const n=s.current.get(e);if(!n||n.sceneIndex===t.sceneIndex){if(n)return void h(e);s.current.set(e,{...t,element:null}),h(e)}},[h]),y=(0,t.useCallback)((e,t)=>{s.current.get(e)?.sceneIndex===t&&(s.current.delete(e),c.current.delete(e),p(e,()=>null),f(e=>e+1))},[p]),x=(0,t.useCallback)((e,t,r)=>{const i=s.current.get(e);!i||i.sceneIndex!==t||(i.element=r,n.current?.())},[n]),S=(0,t.useCallback)((e,t)=>{const n=c.current.get(e)??new Map;return n.set(t.animateId,t),c.current.set(e,n),h(e),t},[h]),b=(0,t.useCallback)((e,t,n)=>{const r=c.current.get(e);!r||r.get(t)!==n||(r.delete(t),h(e))},[h]);return{zoneRegistryRef:s,zoneAnimationsRef:c,zoneStatesRef:l,timelineStoreRef:u,zoneRuntimeVersion:d,getZoneIdForScene:m,getZoneDistance:g,syncZoneState:p,recomputeZoneSequence:h,zoneRuntimeValue:(0,t.useMemo)(()=>({registerZone:v,unregisterZone:y,setZoneElement:x,registerZoneAnimation:S,unregisterZoneAnimation:b}),[v,y,x,S,b]),zoneTimelineValue:(0,t.useMemo)(()=>({store:u.current}),[])}}({scrollOffsetRef:y,measureSceneLayoutsRef:b,updateSceneRenderSnapshotsRef:w,onError:g.common?.onError}),{sceneLayoutsRef:he,sceneWrapperRefs:ve,measureSceneLayouts:ye,setSceneWrapperRef:xe}=function({rootRef:e,direction:n,scenes:r,sceneSizing:i,getViewportSpan:a,getZoneIdForScene:o,getZoneDistance:s,zoneRegistryRef:c,scrollOffsetRef:l,updateSceneRenderSnapshotsRef:u}){const d=(0,t.useRef)([]),f=(0,t.useRef)([]);return{sceneLayoutsRef:d,sceneWrapperRefs:f,measureSceneLayouts:(0,t.useCallback)(()=>{const t=e.current;if(!t)return d.current;const m=a(),g=r.map((e,a)=>{const l=f.current[a],u=e.props,d=function(e){return{enterAnimation:e.transition?.enterAnimation??e.enterAnimation,exitAnimation:e.transition?.exitAnimation??e.exitAnimation,transitionDurationMs:e.sceneTransitionDuration??800,scrollEnterLength:e.scrollEnterLength,scrollExitLength:e.scrollExitLength}}(u),g=!!u.scroll,p=g?_("x"===n?u.layout?.width??u.sceneWidth:u.layout?.height??u.sceneHeight,t.clientWidth,t.clientHeight):null,h=o(a),v=h?c.current.get(h)?.element:null,y=g?p:function(e,t,n,r){return Z("x"===t?e.layout?.width??e.sceneWidth:e.layout?.height??e.sceneHeight,n,r,"declared")}(u,n,t.clientWidth,t.clientHeight),x="x"===n?Math.max(g?v?.offsetWidth??0:l?.offsetWidth??0,g?v?.clientWidth??0:l?.clientWidth??0,0):Math.max(g?v?.offsetHeight??0:l?.offsetHeight??0,g?v?.clientHeight??0:l?.clientHeight??0,0),S=g?Math.max(p??x,1):"screen"===i?Math.max(x,y??0,m,1):Math.max(x,y??0,1),b=g?s(a):0,w=g?Math.max(S,m)+b:S,M=l?G(l,t,n):0,R=M+w,E=Math.max(M+S/2-m/2,0),k=!!(d.enterAnimation&&a>0),P=!!(d.exitAnimation&&a<r.length-1),I=Math.max(0,d.scrollEnterLength??(k?d.transitionDurationMs:0)),C=Math.max(0,d.scrollExitLength??(P?d.transitionDurationMs:0)),A=Math.max(Math.min(w,m),1);return{sceneStart:M,sceneEnd:R,visualSpan:S,flowSpan:w,timelineDistancePx:b,centerLockOffset:E,segmentStart:E,segmentEnd:E+b,enterLength:Math.min(I,A),exitLength:Math.min(C,A),stackMode:K(u)}});return d.current=function(e,t){return e.length===t.length&&t.every((t,n)=>{const r=e[n];return r.sceneStart===t.sceneStart&&r.sceneEnd===t.sceneEnd&&r.visualSpan===t.visualSpan&&r.flowSpan===t.flowSpan&&r.timelineDistancePx===t.timelineDistancePx&&r.centerLockOffset===t.centerLockOffset&&r.segmentStart===t.segmentStart&&r.segmentEnd===t.segmentEnd&&r.enterLength===t.enterLength&&r.exitLength===t.exitLength&&r.stackMode===t.stackMode})}(d.current,g)?d.current:g,u.current(l.current),d.current},[n,a,s,o,e,i,r,l,u,c]),setSceneWrapperRef:(0,t.useCallback)((e,t)=>{f.current[e]=t},[])}}({rootRef:v,direction:p,scenes:P,sceneSizing:a,getViewportSpan:j,getZoneIdForScene:ue,getZoneDistance:me,zoneRegistryRef:oe,scrollOffsetRef:y,updateSceneRenderSnapshotsRef:w}),Se=(0,t.useRef)(!1),be=function(e){return void 0!==e?e:!(typeof window>"u"||!window.__CINEVIEW_SCROLL_DEBUG__)}(d),we=(0,t.useMemo)(()=>{const e=q(P[0]?.props??{}),t=new Set(e);return{priorityImages:e,backgroundImages:Array.from(new Set(P.flatMap(e=>q(e.props).filter(e=>!t.has(e)))))}},[P]),[Me,Re]=((e={})=>{const{priorityUrls:n=[],backgroundUrls:r=[],onProgress:i,onComplete:a,onError:o}=e,[s,c]=(0,t.useState)(!1),[l,u]=(0,t.useState)(0),[d,f]=(0,t.useState)(0),[m,g]=(0,t.useState)(n.length+r.length),[p,h]=(0,t.useState)([]),[v,y]=(0,t.useState)(new Map),[x,b]=(0,t.useState)(!1),w=(0,t.useRef)([...n]),M=(0,t.useRef)([...r]),R=(0,t.useRef)(!1),E=(0,t.useRef)(new Map),k=(0,t.useRef)(0),P=(0,t.useRef)(null),C=(0,t.useRef)(new Set),A=(0,t.useRef)(new Set),D=(0,t.useRef)(0),T=(0,t.useRef)(0),j=(0,t.useRef)(i),z=(0,t.useRef)(a),N=(0,t.useRef)(o);(0,t.useEffect)(()=>{j.current=i,z.current=a,N.current=o},[i,a,o]);const F=(0,t.useCallback)((e,t)=>{const n=O(e).filter(e=>!C.current.has(e));if(0===n.length)return;const r=new Set(w.current),i=new Set(M.current),a=n.filter(e=>!r.has(e)&&!i.has(e));0!==a.length&&(t?w.current=[...w.current,...a]:M.current=[...M.current,...a])},[]);(0,t.useEffect)(()=>{F(n,!0),F(r,!1),R.current||g(w.current.length+M.current.length)},[n,r,F]);const $=(0,t.useCallback)((e,t)=>{const n=I(e);return n?L(e,n).then(()=>(S(e),{url:e,success:!0})).catch(n=>{const r=n instanceof Error?n:new Error(String(n));return k.current===t&&N.current?.(e,r),{url:e,success:!1,error:r}}):new Promise(n=>{const r=new Image,i=new AbortController;E.current.set(e,i);let a=!1,o=null;const s=t=>{a||(a=!0,null!==o&&(clearTimeout(o),o=null),E.current.delete(e),n(t))};r.onload=()=>{S(e),s({url:e,success:!0})},r.onerror=()=>{const n=new Error(`Failed to load image: ${e}`);k.current===t&&N.current?.(e,n),s({url:e,success:!1,error:n})},i.signal.addEventListener("abort",()=>{r.src="",s({url:e,success:!1,error:new Error("Image load aborted")})}),o=setTimeout(()=>{o=null,r.onload=null,r.onerror=null,r.src="";const n=new Error(`Image load timed out after 15000ms: ${e}`);k.current===t&&N.current?.(e,n),s({url:e,success:!1,error:n})},15e3),r.src=e})},[]),B=(0,t.useCallback)((e,t)=>{const n=Math.max(t,0),r=n>0?Math.min(Math.max(e,0),n):0,i=n>0?Math.round(r/n*100):100;u(i),f(r),j.current?.(i)},[]),q=(0,t.useCallback)(()=>{if(R.current)return P.current??Promise.resolve();const e=(async()=>{const e=k.current+1;k.current=e,R.current=!0,c(!0),u(0),f(0),h([]),y(new Map),b(!1),A.current=new Set,D.current=0,T.current=0;const t=V(w.current,M.current,C.current,A.current),n=t.priorityBatch.length+t.backgroundBatch.length;if(T.current=n,g(n),0===n)return B(0,0),k.current===e&&(c(!1),b(!0)),R.current=!1,void z.current?.([]);const r=new Set(t.priorityBatch);let i=0===r.size;i&&b(!0);const a=[],o=new Map,s=()=>{const e=V(w.current,M.current,C.current,A.current);return T.current=D.current+e.priorityBatch.length+e.backgroundBatch.length,g(T.current),e},l=(e,t)=>{a.push(t),A.current.add(e),D.current+=1,!t.success&&t.error?o.set(e,t.error):t.success&&C.current.add(e),B(D.current,T.current),i||(r.delete(e),0===r.size&&(i=!0,b(!0)))};for(;;){const{priorityBatch:t,backgroundBatch:n}=s();if(0===t.length&&0===n.length)break;if(await Promise.all(t.map(async t=>{const n=await $(t,e);k.current===e&&l(t,n)})),k.current!==e)return;const r=await Promise.all(n.map(async t=>({url:t,result:await $(t,e)})));if(k.current!==e)return;r.forEach(({url:e,result:t})=>{l(e,t)})}h(a),y(o),c(!1),R.current=!1,g(w.current.length+M.current.length),z.current?.(a)})();return P.current=e.finally(()=>{P.current===e&&(P.current=null)}),P.current},[$,B]),H=(0,t.useCallback)(()=>{k.current+=1,E.current.forEach(e=>{e.abort()}),E.current.clear(),c(!1),u(0),f(0),g(w.current.length+M.current.length),h([]),y(new Map),b(!1),C.current.clear(),A.current.clear(),D.current=0,T.current=0,R.current=!1,P.current=null},[]),W=(0,t.useCallback)((e,t=!1)=>{F(e,t);const{priorityBatch:n,backgroundBatch:r}=V(w.current,M.current,C.current,A.current),i=R.current?D.current+n.length+r.length:n.length+r.length;R.current&&(T.current=i),g(i)},[F]);return(0,t.useEffect)(()=>{const e=E.current;return()=>{k.current+=1,R.current=!1,P.current=null,e.forEach(e=>{e.abort()}),e.clear()}},[]),[{isLoading:s,progress:l,loadedCount:d,totalCount:m,results:p,errors:v,priorityComplete:x},{startPreload:q,reset:H,addUrls:W}]})({priorityUrls:we.priorityImages,backgroundUrls:we.backgroundImages,onProgress:g.common?.onLoadProgress}),Ee=Re.startPreload,ke=(0,t.useRef)({loadedCount:0,totalCount:0});ke.current={loadedCount:Me.loadedCount,totalCount:Me.totalCount};const Pe=(0,t.useCallback)((e,t,n)=>{let r=!1;return g.common?.onError?.({code:e,message:t,context:n,preventDefault:()=>{r=!0}}),r},[g.common]),Ie=(0,t.useSyncExternalStore)(N,z,()=>!1),Ce=P.length;(0,t.useEffect)(()=>{0===Ce&&Pe("EMPTY_SCENES","Cineview requires at least one Scene child.",{mode:"scroll"})},[Pe,Ce]);const Ae=(0,t.useRef)(void 0);(0,t.useEffect)(()=>{Ae.current!==C&&(Ae.current=C,C.forEach(([e,t],n)=>{Pe("INVALID_COMPONENT_HIERARCHY",`Duplicate scroll zone id "${e}".`,{reason:"duplicate-scroll-zone",zoneId:e,ownerSceneIndex:t,rejectedSceneIndex:n})}))},[C,Pe]);const De=(0,t.useCallback)(()=>({loadedCount:ke.current.loadedCount,totalCount:ke.current.totalCount}),[]),{firstSceneEnterActive:Te,firstSceneEnterReady:Le}=function({enabled:e,hasFirstScene:n,priorityComplete:r,timeoutMs:i,preemptSignal:a=!1,emitRecoverableError:o,getPreloadCounts:s}){const[c,l]=(0,t.useState)(()=>e),[u,d]=(0,t.useState)(!1),[f,m]=(0,t.useState)(0),[g,p]=(0,t.useState)(null),h=(0,t.useRef)(!1),v=(0,t.useRef)(null),y=Math.max(0,i),x=(0,t.useRef)(o);x.current=o;const S=(0,t.useRef)(s);return S.current=s,(0,t.useEffect)(()=>{if(!e||h.current||!n)return;const t=e=>{p(e),m(e=>e+1)};return r?(h.current=!0,d(!0),void t("ready")):(null===v.current&&(v.current=setTimeout(()=>{v.current=null,h.current=!0;const e=S.current();x.current("FIRST_SCENE_TIMEOUT",`First scene priority assets did not load within ${y}ms.`,{sceneIndex:0,timeoutMs:y,loadedCount:e.loadedCount,totalCount:e.totalCount})||(h.current=!0,d(!1),l(!1),t("static"))},y)),()=>{v.current&&(clearTimeout(v.current),v.current=null)})},[e,n,r,y]),(0,t.useEffect)(()=>{a&&(h.current=!0,v.current&&(clearTimeout(v.current),v.current=null),d(!1),l(!1))},[a]),{firstSceneEnterActive:c,firstSceneEnterReady:u,firstSceneActivationToken:f,firstSceneActivationKind:g,handleComplete:(0,t.useCallback)(()=>{l(!1)},[])}}({enabled:P.length>0,hasFirstScene:!!P[0],priorityComplete:Me.priorityComplete,timeoutMs:3e3,emitRecoverableError:Pe,getPreloadCounts:De}),Oe=(0,t.useCallback)(e=>function(e,t,n={}){if(!t||0===t.length)return[];const r=n.includeZoneIds??!1,i=new Set,a=[],o=e=>{e&&q(e.props).forEach(e=>{!e||i.has(e)||(i.add(e),a.push(e))})};return t.forEach(t=>{"number"!=typeof t?t&&e.forEach(e=>{e.props.sceneId!==t?r&&e.props.scroll?.zoneId===t&&o(e):o(e)}):Number.isInteger(t)&&t>=0&&t<e.length&&o(e[t])}),a}(P,e,{includeZoneIds:!0}),[P]);(0,t.useEffect)(()=>{Ee()},[we,Ee]);const{store:Ve,frameStore:je}=function({scenes:e,sceneLayoutsRef:n,timelineStoreRef:r,viewportSizeRef:i,activeSceneIndexRef:a,scrollDirectionRef:o,isScrollingStateRef:s,direction:c,sceneSizing:l,firstSceneEnterActive:u,firstSceneEnterReady:d,exposeTakeoverDebugData:f,scrollOffsetRef:m,updateSceneRenderSnapshotsRef:g}){const p=(0,t.useRef)(Q([],(e,t)=>e[t])),h=(0,t.useRef)(function(){let e=[];const t=new Map,n=e=>{t.get(e)?.forEach(e=>e())};return{setSnapshot:t=>{const r=e;e=Array.from(t);const i=Math.max(r.length,e.length);for(let t=0;t<i;t+=1)Object.is(r[t],e[t])||n(t)},setKeySnapshot:(t,r)=>{Object.is(e[t],r)||(e[t]=r,n(t))},clearFrom:t=>{if(e.length<=t)return;const r=e.length;e.length=t;for(let e=t;e<r;e+=1)n(e)},getKeySnapshot:t=>e[t],subscribeKey:(e,n)=>{const r=t.get(e)??new Set;return r.add(n),t.set(e,r),()=>{r.delete(n),0===r.size&&t.delete(e)}}}}()),v=(0,t.useRef)(null),[y,x]=(0,t.useState)(0),S=(0,t.useRef)(null),b=(0,t.useRef)([]),w=(0,t.useCallback)(t=>{const m=r.current.getSnapshot(),g=n.current,y=i.current,w=Math.max("x"===c?y.width:y.height,1),M=a.current,R="cover"===g[M]?.stackMode&&M>0?M-1:null,E=p.current.getSnapshot(),k=S.current,P=s.current,I=o.current,C=null===k||k[0]!==e||k[1]!==g||k[6]!==y.width||k[7]!==y.height||k[10]!==c||k[11]!==l||k[12]!==f,A=new Set,D=t=>{null!==t&&t>=0&&t<e.length&&A.add(t)},T=e=>{D(e-1),D(e),D(e+1)};if(C){b.current.length=0;for(const e in m){const t=m[e];b.current[t.sceneIndex]=t}for(let t=0;t<e.length;t+=1)A.add(t)}else{const[,,e,n,r,i,a,o,s,l]=k;for(const t in m){const n=m[t],r=e[t];n!==r&&(r&&r.sceneIndex!==n.sceneIndex&&b.current[r.sceneIndex]===r&&(b.current[r.sceneIndex]=void 0),b.current[n.sceneIndex]=n,D(r?.sceneIndex??null),D(n.sceneIndex))}for(const t in e){if(t in m)continue;const n=e[t];b.current[n.sceneIndex]===n&&(b.current[n.sceneIndex]=void 0),D(n.sceneIndex)}const f=Math.max("x"===c?a:o,1);for(let e=0;e<g.length;e+=1){const r=g[e],i=t<r.sceneEnd&&t+w>r.sceneStart,a=n<r.sceneEnd&&n+f>r.sceneStart;(i||a)&&D(e)}T(r),T(M),D(i),D(R),(s!==u||l!==d)&&D(0)}const L=C?[]:E.slice();let O=C;const V=C?new Array(e.length):null;A.forEach(n=>{const r=e[n];if(!r)return;const i=g[n]??null,a=b.current[n]??null,o=!!r.props.scroll,s=n===M||!!a?.active,m=R===n,p=o&&a?.active&&i?i.centerLockOffset:t,v=o&&i?i.centerLockOffset:t,x=i?function(e,t,n){if(!e)return null;const r=Math.max(n,1),i=t,a=t+r,o=i+r/2,s=e.sceneStart+e.enterLength,c=e.sceneEnd-Math.max(e.exitLength,0);let l,u=0,d=0;a<=e.sceneStart?l="before":i>=e.sceneEnd?(l="after",u=e.enterLength>0?1:0,d=e.exitLength>0?1:0):e.enterLength>0&&i<s?(l="enter",u=H((a-e.sceneStart)/Math.max(e.enterLength,1),0,1)):e.exitLength>0&&i>=c?(l="exit",d=H((i-c)/Math.max(e.exitLength,1),0,1),u=e.enterLength>0?1:0):(l="hold",u=e.enterLength>0?1:0);const f=Math.max(e.sceneEnd-e.sceneStart,1);return{phase:l,enterProgress:u,exitProgress:d,sceneProgress:H((o-e.sceneStart)/f,0,1),rangeStart:e.sceneStart,rangeEnd:e.sceneEnd,rangeLength:f,enterLength:e.enterLength,exitLength:e.exitLength}}(i,p,w):null,S=o?_("x"===c?r.props.layout?.width??r.props.sceneWidth:r.props.layout?.height??r.props.sceneHeight,y.width,y.height):null,k=s||m||"enter"===x?.phase||"hold"===x?.phase||"exit"===x?.phase,C={timelineState:x,progress:x?.sceneProgress??0,zoneProgressPx:a?.progressPx??null,visualViewportOffset:v,isCurrent:s,isBackdropActive:m,isScrolling:k&&P,scrollDirection:k&&P?I:null},A=h.current.getKeySnapshot(n),D=void 0!==A&&(A?.timelineState===C.timelineState||null!=A?.timelineState&&null!==C.timelineState&&A.timelineState.phase===C.timelineState.phase&&A.timelineState.enterProgress===C.timelineState.enterProgress&&A.timelineState.exitProgress===C.timelineState.exitProgress&&A.timelineState.sceneProgress===C.timelineState.sceneProgress&&A.timelineState.rangeStart===C.timelineState.rangeStart&&A.timelineState.rangeEnd===C.timelineState.rangeEnd&&A.timelineState.enterLength===C.timelineState.enterLength&&A.timelineState.exitLength===C.timelineState.exitLength)&&A.progress===C.progress&&A.zoneProgressPx===C.zoneProgressPx&&A.visualViewportOffset===C.visualViewportOffset&&A.isCurrent===C.isCurrent&&A.isBackdropActive===C.isBackdropActive&&A.isScrolling===C.isScrolling&&A.scrollDirection===C.scrollDirection;V?V[n]=C:D||h.current.setKeySnapshot(n,C);const T={sceneLayout:i,sceneZoneState:a,sceneTimelineState:x,isCurrent:s,isBackdropActive:m,visualViewportOffset:v,isScrolling:k&&P,scrollDirection:k&&P?I:null,activeSceneIndex:M,viewportWidth:y.width,viewportHeight:y.height,firstSceneEnterGateKnown:!0,firstSceneEnterActive:0===n&&u,firstSceneEnterReady:0===n&&d,direction:c,sceneCount:e.length,sceneSizing:l,exposeTakeoverDebugData:f,takeoverSceneSpan:S},j=E[n]??te;!function(e,t){const n=e.sceneTimelineState,r=t.sceneTimelineState,i=n===r||null!==n&&null!==r&&n.phase===r.phase&&n.rangeStart===r.rangeStart&&n.rangeEnd===r.rangeEnd&&n.rangeLength===r.rangeLength&&n.enterLength===r.enterLength&&n.exitLength===r.exitLength,a=e.sceneZoneState,o=t.sceneZoneState;return e.sceneLayout===t.sceneLayout&&(a===o||null!==a&&null!==o&&a.zoneId===o.zoneId&&a.sceneIndex===o.sceneIndex&&a.totalBudgetPx===o.totalBudgetPx&&a.active===o.active&&a.direction===o.direction&&a.approach===o.approach&&a.sequence===o.sequence)&&i&&e.isCurrent===t.isCurrent&&e.isBackdropActive===t.isBackdropActive&&e.isScrolling===t.isScrolling&&e.scrollDirection===t.scrollDirection&&e.activeSceneIndex===t.activeSceneIndex&&e.viewportWidth===t.viewportWidth&&e.viewportHeight===t.viewportHeight&&e.firstSceneEnterGateKnown===t.firstSceneEnterGateKnown&&e.firstSceneEnterActive===t.firstSceneEnterActive&&e.firstSceneEnterReady===t.firstSceneEnterReady&&e.direction===t.direction&&e.sceneCount===t.sceneCount&&e.sceneSizing===t.sceneSizing&&e.exposeTakeoverDebugData===t.exposeTakeoverDebugData&&e.takeoverSceneSpan===t.takeoverSceneSpan}(j,T)?(L[n]=T,O=!0):L[n]=j}),L.length=e.length,O&&p.current.setSnapshot(L),V?(v.current=V,x(e=>e+1)):h.current.clearFrom(e.length),S.current=[e,g,m,t,M,R,y.width,y.height,u,d,c,l,f]},[a,c,f,u,d,s,n,l,e,o,r,i]);return g.current=w,ee(()=>{const e=v.current;e&&(v.current=null,h.current.setSnapshot(e))},[y]),(0,t.useEffect)(()=>{w(m.current)},[m,w]),{store:p.current,frameStore:h.current,updateSceneRenderSnapshots:w}}({scenes:P,sceneLayoutsRef:he,timelineStoreRef:ce,viewportSizeRef:T,activeSceneIndexRef:M,scrollDirectionRef:R,isScrollingStateRef:Se,direction:p,sceneSizing:a,firstSceneEnterActive:Te,firstSceneEnterReady:Le,exposeTakeoverDebugData:be,scrollOffsetRef:y,updateSceneRenderSnapshotsRef:w});b.current=ye;const{isScrolling:ze,scrollContentSpan:Ne,syncNativeScrollState:Fe,applyNativeScrollDelta:$e,applyNativeScrollbarOffset:Be,goToScrollZone:qe,beginProgrammaticScroll:He}=function({rootRef:e,direction:n,getViewportSpan:r,updateViewportMetrics:i,measureSceneLayouts:a,sceneLayoutsRef:o,zoneRegistryRef:s,zoneStatesRef:c,timelineStoreRef:l,scrollOffsetRef:u,scrollOffsetStore:d,activeSceneIndexRef:f,scrollDirectionRef:m,isScrollingStateRef:g,updateSceneRenderSnapshotsRef:p,callbacks:h,zoneRuntimeVersion:v}){const y=(0,t.useRef)(null),x=(0,t.useRef)(!1),S=(0,t.useRef)(0),b=(0,t.useRef)(null),w=(0,t.useRef)({}),M=(0,t.useRef)({}),R=(0,t.useRef)(0),[E,k]=(0,t.useState)(!1),[P,I]=(0,t.useState)(1),C=(0,t.useRef)(1),A=(0,t.useCallback)(()=>{const t=e.current;return t?Math.max(("x"===n?t.scrollWidth:t.scrollHeight)-r(),0):0},[n,r,e]),D=(0,t.useCallback)(()=>o.current.filter(e=>e.segmentEnd-e.segmentStart>.5).map(e=>({segmentStart:e.segmentStart,segmentEnd:e.segmentEnd})).sort((e,t)=>e.segmentStart-t.segmentStart),[o]),T=(0,t.useCallback)((e,t)=>function({currentOffset:e,deltaPx:t,maxNativeOffset:n,segments:r=[]}){if(0===t)return H(e,0,n);const i=H(e,0,n),a=t===Number.POSITIVE_INFINITY?n:t===Number.NEGATIVE_INFINITY?0:H(i+t,0,n);if(0===r.length||Math.abs(a-i)<=.5)return a;if(a>i){const e=r.find(e=>i<e.segmentStart+.5&&a>e.segmentEnd+.5);if(e)return Math.min(e.segmentStart+1,e.segmentEnd);const t=r.find(e=>i>=e.segmentStart-.5&&i<e.segmentEnd-.5);return t&&a>t.segmentEnd+.5?t.segmentEnd:a}const o=[...r].reverse().find(e=>i>e.segmentEnd-.5&&a<e.segmentStart-.5);if(o)return Math.max(o.segmentEnd-1,o.segmentStart);const s=[...r].reverse().find(e=>i>e.segmentStart+.5&&i<=e.segmentEnd+.5);return s&&a<s.segmentStart-.5?s.segmentStart:a}({currentOffset:e,deltaPx:t,maxNativeOffset:A(),segments:D()}),[D,A]),L=(0,t.useCallback)(t=>{const r=e.current;if(!r)return;const i=H(t,0,A());"x"!==n?"function"==typeof r.scrollTo?r.scrollTo({top:i,behavior:"auto"}):r.scrollTop=i:"function"==typeof r.scrollTo?r.scrollTo({left:i,behavior:"auto"}):r.scrollLeft=i},[n,A,e]),O=(0,t.useCallback)(e=>{b.current=H(e,0,A())},[A]),V=(0,t.useCallback)(()=>{if(null===b.current)return;b.current=null;const t=e.current;if(!t)return;const r=H("x"===n?t.scrollLeft:t.scrollTop,0,A());L(r),S.current=r},[n,A,e,L]),j=(0,t.useCallback)((e,t=r())=>{const n=o.current;if(0===n.length)return;const i=e+t/2;let a=0,s=Number.POSITIVE_INFINITY;for(let e=0;e<n.length;e+=1){const t=n[e];if(i>=t.sceneStart&&i<t.sceneEnd){a=e;break}const r=i<t.sceneStart?t.sceneStart-i:i-t.sceneEnd;r<s&&(s=r,a=e)}if(f.current===a)return;const c=R.current;if(f.current=a,p.current(e),c===a)return;const l=a>=c?"forward":"backward";h.common?.onSceneEnter?.({fromIndex:c,toIndex:a,direction:l}),h.common?.onSceneLeave?.({fromIndex:c,toIndex:a,direction:l}),R.current=a},[f,h.common,r,o,p]),z=(0,t.useCallback)((e,t,n=r())=>{const i=w.current,a=c.current,u=n,d={};Object.entries(a).forEach(([n,r])=>{const i=o.current[r.sceneIndex];if(!i||r.totalBudgetPx<=0)return void(d[n]=0!==r.progressPx||r.active||null!==r.direction?{...r,progressPx:0,active:!1,direction:null}:r);const a=H(e-i.segmentStart,0,r.totalBudgetPx),s=a<=.01?0:r.totalBudgetPx-a<=.01?r.totalBudgetPx:a,c=e>i.segmentStart+.5&&e<i.segmentEnd-.5&&s>.5&&s<r.totalBudgetPx-.5,l=function(e,t,n){return e<=0?"inside":"far"===n?e<=1*t?"near":"far":e>1.5*t?"far":"near"}(Math.max(i.segmentStart-e,e-i.segmentEnd,0),u,r.approach),f={...r,progressPx:s,active:c,direction:c?t:null,approach:l};d[n]=r.progressPx===f.progressPx&&r.active===f.active&&r.direction===f.direction&&r.approach===f.approach?r:f});const f=Object.entries(d);Object.keys(a).length===f.length&&f.every(([e,t])=>a[e]===t)||(c.current=d,l.current.setSnapshot(d)),p.current(e),w.current=d,Object.entries(d).forEach(([e,t])=>{const n=i[e],r=s.current.get(e);if(!r)return;const a=M.current[e],o=0===t.progressPx||t.progressPx===t.totalBudgetPx;(void 0===a||Math.abs(a-t.progressPx)>.5||o&&a!==t.progressPx)&&(M.current[e]=t.progressPx,h.scroll?.onZoneProgress?.({zoneId:e,sceneIndex:r.sceneIndex,progress:t.totalBudgetPx>0?H(t.progressPx/t.totalBudgetPx,0,1):0})),!n?.active&&t.active?h.scroll?.onZoneEnter?.({zoneId:e,sceneIndex:r.sceneIndex}):n?.active&&!t.active&&h.scroll?.onZoneLeave?.({zoneId:e,sceneIndex:r.sceneIndex})})},[h.scroll,r,o,l,p,s,c]),N=(0,t.useCallback)((t=!1)=>{const o=e.current;if(!o)return;const s="x"===n?o.scrollLeft:o.scrollTop;if(t&&x.current&&null===b.current&&Math.abs(s-S.current)<=.01)return;t&&(x.current||(i(),a()),x.current=!0);const c=S.current,l=b.current;let f;null!==l?(f=H(s,0,A()),Math.abs(f-l)<=1&&(b.current=null)):(f=T(c,s-c),Math.abs(f-s)>.5&&L(f));const h=Math.abs(f-c)<=.5?m.current:f>c?"forward":"backward";S.current=f,u.current=f,d.setSnapshot(f),m.current=h,t&&(g.current=!0,k(e=>e||!0),null!==y.current&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>{g.current=!1,k(!1),x.current=!1,y.current=null,p.current(u.current)},120));const v=r(),w=Math.max("x"===n?o.scrollWidth:o.scrollHeight,v);z(f,h,v),j(f,v),Math.abs(C.current-w)>.5&&(C.current=w,I(w))},[n,A,r,g,a,T,e,m,u,d,L,z,j,p,i]),F=(0,t.useCallback)(t=>{const r=e.current;if(!r||0===t)return!1;V();const i="x"===n?r.scrollLeft:r.scrollTop,a=T(i,t);return!(Math.abs(a-i)<=.5||(L(a),N(!0),0))},[V,n,T,e,L,N]),$=(0,t.useCallback)(t=>{V();const r=e.current,i=r?"x"===n?r.scrollLeft:r.scrollTop:u.current;L(T(i,t-i)),N(!0)},[V,n,T,e,u,L,N]),B=(0,t.useCallback)((t,r)=>{const i=e.current,a=c.current[t],s=a?o.current[a.sceneIndex]:null;if(i&&s){if(!1!==r?.animated)return O(s.centerLockOffset),void i.scrollTo({top:"x"===n?void 0:s.centerLockOffset,left:"x"===n?s.centerLockOffset:void 0,behavior:"smooth"});i.scrollTo({top:"x"===n?void 0:s.centerLockOffset,left:"x"===n?s.centerLockOffset:void 0,behavior:"auto"}),S.current=s.centerLockOffset,u.current=s.centerLockOffset,d.setSnapshot(s.centerLockOffset),z(s.centerLockOffset,null),j(s.centerLockOffset)}},[O,n,e,o,u,d,z,j,c]);return function({rootRef:e,direction:n,getViewportSpan:r,applyNativeScrollDelta:i}){const a=(0,t.useRef)(null);(0,t.useEffect)(()=>{const t=e.current;if(!t)return;const o=e=>e instanceof Element&&e.closest('[data-cineview-container="true"]')===t,s=e=>{if(e.defaultPrevented||!o(e.target))return;const a=function(e,t,n){return Number.isFinite(e)&&0!==e?1===t?18*e:2===t?e*Math.max(n,1):e:0}("x"===n?e.deltaX:e.deltaY,e.deltaMode,r());0!==a&&(W(e.target,t,n,a)||i(a)&&e.cancelable&&e.preventDefault())},c=e=>{if(!o(e.target))return;const t=e.touches[0];t&&(a.current={x:t.clientX,y:t.clientY})},l=e=>{const r=e.touches[0];if(!r||!a.current)return;if(e.defaultPrevented||!o(e.target))return void(a.current={x:r.clientX,y:r.clientY});const s=function(e){return Number.isFinite(e)?e:0}("x"===n?a.current.x-r.clientX:a.current.y-r.clientY);if(W(e.target,t,n,s))a.current={x:r.clientX,y:r.clientY};else if(0!==s){const t=i(s);a.current={x:r.clientX,y:r.clientY},t&&e.cancelable&&e.preventDefault()}},u=()=>{a.current=null};return t.addEventListener("wheel",s,{capture:!0,passive:!1}),t.addEventListener("touchstart",c,{passive:!0}),t.addEventListener("touchmove",l,{passive:!1}),t.addEventListener("touchend",u),t.addEventListener("touchcancel",u),()=>{t.removeEventListener("wheel",s,{capture:!0}),t.removeEventListener("touchstart",c),t.removeEventListener("touchmove",l),t.removeEventListener("touchend",u),t.removeEventListener("touchcancel",u),a.current=null}},[i,n,r,e]),(0,t.useEffect)(()=>{if(typeof window>"u")return;const e=e=>{if(e.defaultPrevented||function(e){return U(e.target,e.key)}(e))return;const t=Y(e.key,e.shiftKey,r());if(0===t)return;const n=document.activeElement;(n===document.body||n===document.documentElement)&&i(t)&&e.cancelable&&e.preventDefault()};return window.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0)}},[i,r])}({rootRef:e,direction:n,getViewportSpan:r,applyNativeScrollDelta:F}),(0,t.useEffect)(()=>()=>{null!==y.current&&(window.clearTimeout(y.current),y.current=null),b.current=null},[]),(0,t.useEffect)(()=>{i(),a(),N()},[a,N,i,v]),(0,t.useEffect)(()=>{if(typeof window>"u")return;const e=()=>{i(),a(),N()};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a,N,i]),{isScrolling:E,scrollContentSpan:P,syncNativeScrollState:N,applyNativeScrollDelta:F,applyNativeScrollbarOffset:$,goToScrollZone:B,beginProgrammaticScroll:O}}({rootRef:v,direction:p,getViewportSpan:j,updateViewportMetrics:ne,measureSceneLayouts:ye,sceneLayoutsRef:he,zoneRegistryRef:oe,zoneStatesRef:se,timelineStoreRef:ce,scrollOffsetRef:y,scrollOffsetStore:x.current,activeSceneIndexRef:M,scrollDirectionRef:R,isScrollingStateRef:Se,updateSceneRenderSnapshotsRef:w,callbacks:g,zoneRuntimeVersion:le}),We=(0,t.useRef)(!1),Ye=(0,t.useRef)(null),Ue=(0,t.useCallback)(()=>{We.current=!1,ne(),ye(),Fe()},[ye,Fe,ne]);(0,t.useEffect)(()=>{if(typeof ResizeObserver>"u")return;const e=new ResizeObserver(()=>{null===Ye.current&&(Ye.current=window.requestAnimationFrame(()=>{Ye.current=null,Se.current?We.current=!0:Ue()}))});return ve.current.forEach(t=>{t&&e.observe(t)}),()=>{null!==Ye.current&&(window.cancelAnimationFrame(Ye.current),Ye.current=null),e.disconnect()}},[Ue,ve,P]),(0,t.useEffect)(()=>{ze||!We.current||Ue()},[ze,Ue]),(0,t.useEffect)(()=>{if(u)return(()=>{1===($+=1)&&F.start();let e=!1;return()=>{e||(e=!0,0===($=Math.max($-1,0))&&F.stop())}})()},[u]),(0,t.useEffect)(()=>{},[A]);const Xe=(0,t.useRef)(null),Ke=(0,t.useCallback)((e,t=!0)=>{if(e<0||e>=E.current.length)return;const n=v.current,r=ve.current[e];if(!n||!r)return;const i=G(r,n,p);He(i),n.scrollTo({top:"x"===p?void 0:i,left:"x"===p?i:void 0,behavior:t?"smooth":"auto"})},[He,p,ve]),Ze=(0,t.useCallback)(()=>{ne(),ye(),Fe()},[ye,Fe,ne]),_e=(0,t.useCallback)(async e=>{const t=Oe(e);t.length>0&&Re.addUrls(t,!0),await Ee()},[Re,Oe,Ee]);Xe.current||(Xe.current={goToScene:(e,t=!0)=>Ke(e,t),goToZone:(e,t)=>qe(e,t),refreshLayout:()=>Ze(),preload:e=>_e(e),getCurrentIndex:()=>M.current,getPerformanceMetrics:()=>B.getMetrics()});const Ge=Xe.current,Je=(0,t.useRef)(!1);(0,t.useEffect)(()=>{Je.current||(Je.current=!0,g.common?.onReady?.(Ge))},[g.common,Ge]),(0,t.useImperativeHandle)(f,()=>Ge,[Ge]);const Qe="object"==typeof c?c:{},et=Qe.autoHide??!0,tt="object"==typeof c&&!1!==c.enabled,nt={position:"relative",width:"100%",height:"100vh",minHeight:"100vh",overflowX:"x"===p?"scroll":"hidden",overflowY:"x"===p?"hidden":"scroll",overscrollBehavior:"contain",WebkitOverflowScrolling:"touch",scrollbarGutter:tt?"auto":"stable",background:"#ffffff"},rt=(0,t.useMemo)(()=>({mode:"scroll",scrollEnterMargin:o,scrollExitMargin:s,prefersReducedMotion:Ie,reportError:e=>{g.common?.onError?.({...e,code:e.code})}}),[o,s,g.common,Ie]);return(0,n.jsx)(h,{designSize:m,children:(0,n.jsx)(fe.Provider,{value:rt,children:(0,n.jsx)(ie.Provider,{value:ge,children:(0,n.jsxs)(ae.Provider,{value:pe,children:[tt&&(0,n.jsx)("style",{children:'\n [data-cineview-container="true"] {\n scrollbar-width: none;\n -ms-overflow-style: none;\n }\n [data-cineview-container="true"]::-webkit-scrollbar {\n width: 0;\n height: 0;\n display: none;\n }\n '}),"x"===p&&(0,n.jsx)("style",{children:'[data-cineview-scroll-stream="x"] > * { flex-shrink: 0; }'}),(0,n.jsxs)("div",{style:{position:"relative",width:"100%",height:"100vh",minHeight:"100vh"},children:[(0,n.jsx)("div",{ref:v,style:nt,className:"cineview-container","data-cineview-container":"true","data-cineview-scrollbar-autohide":String(et),tabIndex:0,onScroll:()=>Fe(!0),onKeyDownCapture:e=>{if(e.defaultPrevented||!(e.target instanceof Element)||e.target.closest('[data-cineview-container="true"]')!==e.currentTarget||U(e.target,e.key))return;const t=Y(e.key,e.shiftKey,j());0!==t&&!W(e.target,e.currentTarget,p,t)&&$e(t)&&e.preventDefault()},children:(0,n.jsx)("div",{"data-cineview-scroll-stream":p,style:"x"===p?{display:"flex",flexDirection:"row",alignItems:"stretch",width:"100%"}:void 0,children:(0,n.jsx)(re,{childrenArray:k,store:Ve,frameStore:je,setWrapperRef:xe,scrollCallbacks:g.scroll})})}),tt&&(0,n.jsx)(J,{direction:p,scrollContentSpan:Ne,viewportSpan:Math.max("x"===p?D.width:D.height,1),scrollOffset:y.current,scrollOffsetStore:x.current,isScrolling:ze,config:Qe,onScrollToOffset:Be})]})]})})})})});ge.displayName="DirectScrollCineview";var pe,he,ve,ye,xe,Se,be,we,Me,Re,Ee,ke=ge,Pe=g({fadeAnimations:()=>pe}),Ie=m(()=>{pe={fade:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},"fade-in":{initial:{opacity:0},animate:{opacity:1},exit:{opacity:1}},"fade-out":{initial:{opacity:1},animate:{opacity:1},exit:{opacity:0}}}}),Ce=g({slideAnimations:()=>he}),Ae=m(()=>{he={"slide-up":{initial:{y:"100%",opacity:0},animate:{y:0,opacity:1},exit:{y:"-100%",opacity:0}},"slide-down":{initial:{y:"-100%",opacity:0},animate:{y:0,opacity:1},exit:{y:"100%",opacity:0}},"slide-left":{initial:{x:"100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"-100%",opacity:0}},"slide-right":{initial:{x:"-100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"100%",opacity:0}}}}),De=g({zoomAnimations:()=>ve}),Te=m(()=>{ve={"zoom-in":{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0}},"zoom-out":{initial:{scale:1.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:1.5,opacity:0}},"scale-up":{initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:1.5,opacity:0}},"scale-down":{initial:{scale:1.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.5,opacity:0}}}}),Le=g({rotateAnimations:()=>ye}),Oe=m(()=>{ye={rotate:{initial:{rotate:-180,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:180,opacity:0}},"rotate-in":{initial:{rotate:-180,scale:0,opacity:0},animate:{rotate:0,scale:1,opacity:1},exit:{rotate:0,scale:1,opacity:1}},"rotate-out":{initial:{rotate:0,scale:1,opacity:1},animate:{rotate:0,scale:1,opacity:1},exit:{rotate:180,scale:0,opacity:0}},spin:{initial:{rotate:0,opacity:0},animate:{rotate:360,opacity:1},exit:{rotate:720,opacity:0}}}}),Ve=g({flipAnimations:()=>xe}),je=m(()=>{xe={flip:{initial:{rotateY:-180,opacity:0},animate:{rotateY:0,opacity:1},exit:{rotateY:180,opacity:0}},"flip-x":{initial:{rotateX:-180,opacity:0},animate:{rotateX:0,opacity:1},exit:{rotateX:180,opacity:0}},"flip-y":{initial:{rotateY:-180,opacity:0},animate:{rotateY:0,opacity:1},exit:{rotateY:180,opacity:0}}}}),ze=g({bounceAnimations:()=>Se}),Ne=m(()=>{Se={bounce:{initial:{y:-100,opacity:0},animate:{y:0,opacity:1,transition:{type:"spring",bounce:.5,duration:.8}},exit:{y:100,opacity:0}},"bounce-in":{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,transition:{type:"spring",bounce:.6,duration:.8}},exit:{scale:1,opacity:1}},"bounce-out":{initial:{scale:1,opacity:1},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0,transition:{type:"spring",bounce:.6,duration:.6}}}}}),Fe=g({blinkAnimations:()=>be}),$e=m(()=>{be={blink:{initial:{opacity:1},animate:{opacity:[1,0,1,0,1],transition:{duration:1,times:[0,.25,.5,.75,1]}},exit:{opacity:0}},flash:{initial:{opacity:0},animate:{opacity:[0,1,0,1],transition:{duration:.8,times:[0,.25,.5,1]}},exit:{opacity:0}},pulse:{initial:{scale:1,opacity:1},animate:{scale:[1,1.05,1],opacity:[1,.8,1],transition:{duration:1,times:[0,.5,1]}},exit:{scale:1,opacity:0}}}}),Be=g({shakeAnimations:()=>we}),qe=m(()=>{we={shake:{initial:{x:0},animate:{x:[0,-10,10,-10,10,0],transition:{duration:.6,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,opacity:0}},"shake-x":{initial:{x:0},animate:{x:[0,-15,15,-15,15,0],transition:{duration:.8,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,opacity:0}},"shake-y":{initial:{y:0},animate:{y:[0,-15,15,-15,15,0],transition:{duration:.8,times:[0,.2,.4,.6,.8,1]}},exit:{y:0,opacity:0}},vibrate:{initial:{x:0,y:0},animate:{x:[0,-2,2,-2,2,0],y:[0,-2,2,-2,2,0],transition:{duration:.4,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,y:0,opacity:0}},jello:{initial:{skewX:0,skewY:0},animate:{skewX:[0,-12.5,6.25,-3.125,1.5625,0],skewY:[0,-12.5,6.25,-3.125,1.5625,0],transition:{duration:1,times:[0,.222,.444,.666,.888,1]}},exit:{skewX:0,skewY:0,opacity:0}}}}),He=g({blurAnimations:()=>Me}),We=m(()=>{Me={"blur-in":{initial:{filter:"blur(10px)",opacity:0},animate:{filter:"blur(0px)",opacity:1},exit:{filter:"blur(0px)",opacity:1}},"blur-out":{initial:{filter:"blur(0px)",opacity:1},animate:{filter:"blur(0px)",opacity:1},exit:{filter:"blur(10px)",opacity:0}},"focus-in":{initial:{filter:"blur(20px)",scale:.8,opacity:0},animate:{filter:"blur(0px)",scale:1,opacity:1},exit:{filter:"blur(0px)",scale:1,opacity:1}}}}),Ye=g({elasticAnimations:()=>Re}),Ue=m(()=>{Re={elastic:{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,transition:{type:"spring",stiffness:300,damping:10}},exit:{scale:0,opacity:0}},"rubber-band":{initial:{scale:1},animate:{scale:[1,1.25,.75,1.15,.95,1],transition:{duration:1,times:[0,.3,.4,.5,.65,1]}},exit:{scale:0,opacity:0}},wobble:{initial:{x:0,rotate:0},animate:{x:[0,-25,20,-15,10,-5,0],rotate:[0,-5,3,-3,2,-1,0],transition:{duration:1,times:[0,.15,.3,.45,.6,.75,1]}},exit:{x:0,rotate:0,opacity:0}},swing:{initial:{rotate:0,transformOrigin:"top center"},animate:{rotate:[0,15,-10,5,-5,0],transformOrigin:"top center",transition:{duration:1,times:[0,.2,.4,.6,.8,1]}},exit:{rotate:0,opacity:0}}}}),Xe=g({specialAnimations:()=>Ee}),Ke=m(()=>{Ee={heartbeat:{initial:{scale:1},animate:{scale:[1,1.3,1,1.3,1],transition:{duration:1.3,times:[0,.14,.28,.42,1]}},exit:{scale:0,opacity:0}},tada:{initial:{scale:1,rotate:0},animate:{scale:[1,.9,.9,1.1,1.1,1.1,1.1,1.1,1.1,1],rotate:[0,-3,-3,3,-3,3,-3,3,-3,0],transition:{duration:1,times:[0,.1,.2,.3,.4,.5,.6,.7,.8,1]}},exit:{scale:0,rotate:0,opacity:0}},wave:{initial:{rotate:0,transformOrigin:"bottom center"},animate:{rotate:[0,14,-8,14,-4,10,0],transformOrigin:"bottom center",transition:{duration:1,times:[0,.1,.2,.3,.4,.5,1]}},exit:{rotate:0,opacity:0}},"roll-in":{initial:{x:"-100%",rotate:-120,opacity:0},animate:{x:0,rotate:0,opacity:1},exit:{x:0,rotate:0,opacity:1}},"roll-out":{initial:{x:0,rotate:0,opacity:1},animate:{x:0,rotate:0,opacity:1},exit:{x:"100%",rotate:120,opacity:0}},hinge:{initial:{rotate:0,transformOrigin:"top left"},animate:{rotate:0,transformOrigin:"top left"},exit:{rotate:[0,80,60,80,60,60],y:[0,0,0,0,0,700],opacity:[1,1,1,1,1,0],transformOrigin:"top left",transition:{duration:2,times:[0,.2,.4,.6,.8,1]}}},"jack-in-the-box":{initial:{scale:.1,rotate:30,transformOrigin:"center bottom",opacity:0},animate:{scale:1,rotate:0,transformOrigin:"center bottom",opacity:1,transition:{type:"spring",stiffness:500,damping:15}},exit:{scale:0,opacity:0}}}}),Ze=class extends Error{constructor(e,t,n){super(t),this.code=e,this.permanent=n.permanent,this.category=n.category,this.presetName=n.presetName,this.cause=n.cause,this.name="PresetLoadError"}};function _e(e){return e instanceof Ze}var Ge={fade:"fade","fade-in":"fade","fade-out":"fade","slide-up":"slide","slide-down":"slide","slide-left":"slide","slide-right":"slide","zoom-in":"zoom","zoom-out":"zoom","scale-up":"zoom","scale-down":"zoom",rotate:"rotate","rotate-in":"rotate","rotate-out":"rotate",spin:"rotate",flip:"flip","flip-x":"flip","flip-y":"flip",bounce:"bounce","bounce-in":"bounce","bounce-out":"bounce",blink:"blink",flash:"blink",pulse:"blink",shake:"shake","shake-x":"shake","shake-y":"shake",vibrate:"shake",jello:"shake","blur-in":"blur","blur-out":"blur","focus-in":"blur",elastic:"elastic","rubber-band":"elastic",wobble:"elastic",swing:"elastic",heartbeat:"special",tada:"special",wave:"special","roll-in":"special","roll-out":"special",hinge:"special","jack-in-the-box":"special"},Je=["fade","slide","zoom","rotate","flip","bounce","blink","shake","blur","elastic","special"],Qe=new Map,et=new Map,tt=new Map,nt=new Map,rt=new Map,it={left:"0%",center:"50%",right:"100%"},at={top:"0%",center:"50%",bottom:"100%"},ot={center:"50% 50%","top center":"50% 0%","center top":"50% 0%","bottom center":"50% 100%","center bottom":"50% 100%","top left":"0% 0%","left top":"0% 0%","top right":"100% 0%","right top":"100% 0%","bottom left":"0% 100%","left bottom":"0% 100%","bottom right":"100% 100%","right bottom":"100% 100%","center left":"0% 50%","left center":"0% 50%","center right":"100% 50%","right center":"100% 50%"};function st(e,t){return Array.isArray(t)?t.map(t=>st(e,t)):t&&"object"==typeof t?ct(t):"transformOrigin"===e&&"string"==typeof t?function(e){const t=e.trim().toLowerCase().replace(/\s+/g," "),n=ot[t];if(n)return n;const r=t.split(" ");if(1===r.length){const t=it[r[0]],n=at[r[0]];return t&&n?`${t} ${n}`:t?`${t} 50%`:n?`50% ${n}`:e}if(2===r.length){const[e,t]=r,n=it[e]??it[t],i=at[e]??at[t];if(n&&i)return`${n} ${i}`}return e}(t):t}function ct(e){const t={};return Object.entries(e).forEach(([e,n])=>{t[e]=st(e,n)}),t}function lt(e){return{initial:ct(e.initial||{}),animate:ct(e.animate||{}),exit:ct(e.exit||{})}}var ut=async e=>"string"==typeof e?await(async e=>lt(await async function(e){const t=rt.get(e);if(t)throw t;const n=Ge[e];if(!n){const t=new Ze("INVALID_ANIMATION",`Unknown preset animation: ${e}`,{permanent:!0,presetName:e});throw rt.set(e,t),t}const r=(await function(e){const t=Qe.get(e);if(t)return Promise.resolve(t);const n=nt.get(e);if(n)return Promise.reject(n);if(!function(e){return Je.includes(e)}(e)){const t=new Ze("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e});return nt.set(e,t),tt.set(e,"failed-permanent"),Promise.reject(t)}const r=et.get(e);if(r)return r;tt.set(e,"pending");const i=function(e,t){return new Promise((n,r)=>{const i=setTimeout(()=>{r(new Ze("ANIMATION_ASSET_LOAD_FAILED",`Timed out loading animation category "${t}".`,{permanent:!1,category:t}))},3e3);e.then(e=>{clearTimeout(i),n(e)},e=>{clearTimeout(i),r(e)})})}(async function(e){switch(e){case"fade":return(await Promise.resolve().then(()=>(Ie(),Pe))).fadeAnimations;case"slide":return(await Promise.resolve().then(()=>(Ae(),Ce))).slideAnimations;case"zoom":return(await Promise.resolve().then(()=>(Te(),De))).zoomAnimations;case"rotate":return(await Promise.resolve().then(()=>(Oe(),Le))).rotateAnimations;case"flip":return(await Promise.resolve().then(()=>(je(),Ve))).flipAnimations;case"bounce":return(await Promise.resolve().then(()=>(Ne(),ze))).bounceAnimations;case"blink":return(await Promise.resolve().then(()=>($e(),Fe))).blinkAnimations;case"shake":return(await Promise.resolve().then(()=>(qe(),Be))).shakeAnimations;case"blur":return(await Promise.resolve().then(()=>(We(),He))).blurAnimations;case"elastic":return(await Promise.resolve().then(()=>(Ue(),Ye))).elasticAnimations;case"special":return(await Promise.resolve().then(()=>(Ke(),Xe))).specialAnimations;default:throw new Ze("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e})}}(e),e).then(t=>(Qe.set(e,t),tt.set(e,"success"),t)).catch(t=>{const n=function(e,t){return _e(t)?t:new Ze("ANIMATION_ASSET_LOAD_FAILED",`Failed to load animation category "${e}".`,{permanent:!1,category:e,cause:t})}(e,t);throw tt.set(e,n.permanent?"failed-permanent":"failed-transient"),n.permanent&&nt.set(e,n),n}).finally(()=>{et.get(e)===i&&et.delete(e)});return et.set(e,i),i}(n))[e];if(r)return r;const i=new Ze("INVALID_ANIMATION",`Preset animation "${e}" is missing from category "${n}".`,{permanent:!0,category:n,presetName:e});throw rt.set(e,i),i}(e)))(e):"object"==typeof e?(e=>{if(!(e=>{if(!e||"object"!=typeof e)return!1;const t=new Set(["initial","animate","exit"]),n=Object.entries(e);return 0!==n.length&&!n.some(([e])=>!t.has(e))&&n.some(([,e])=>null!=e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length>0)})(e))return null;try{return(e=>lt({initial:e.initial??{},animate:e.animate??{},exit:e.exit??{}}))(e)}catch(e){return null}})(e):null,dt=e=>{const t={};return e.forEach(e=>{Object.assign(t,e)}),t},ft=async e=>{const t=[];for(let n=0;n<e.length;n++){const r=await ut(e[n]);r&&t.push({variant:r,sourceIndex:n})}return t},mt=e=>{const{transition:t,...n}=e.animate;return{values:n,transition:t||{}}},gt=e=>{const t={},n={};return e.forEach(({values:e,transition:r})=>{Object.entries(e).forEach(([e,i])=>{t[e]=i,n[e]=r})}),t.transition=n,t};async function pt(e,t,n,r){if(!e)return null;try{const i=await(async e=>"object"==typeof e&&"mode"in e&&"animations"in e?await(async e=>{if(!(e=>!!(e&&"object"==typeof e&&e.mode&&["sequential","parallel"].includes(e.mode)&&Array.isArray(e.animations)&&0!==e.animations.length))(e))return null;try{const{mode:t,animations:n,delays:r=[]}=e;return"sequential"===t?await(async(e,t=[])=>{const n=await ft(e);if(0===n.length)throw new Error("No valid animations in sequential composition");const r=n[0].variant.initial,i=n[n.length-1].variant.exit;let a=0;const o=n.map(({variant:e,sourceIndex:n})=>{const r=t[n]||0,{values:i,transition:o}=mt(e),s={...o,delay:a+r/1e3};return a+=("number"==typeof o.duration?o.duration:1)+r/1e3,{values:i,transition:s}});return{initial:r,animate:gt(o),exit:i}})(n,r):"parallel"===t?await(async(e,t=[])=>{const n=await ft(e);if(0===n.length)throw new Error("No valid animations in parallel composition");const r=n.map(({variant:e})=>e.initial),i=n.map(({variant:e,sourceIndex:n})=>{const r=t[n]||0,{values:i,transition:a}=mt(e);return{values:i,transition:{...a,delay:r/1e3}}}),a=n.map(({variant:e})=>e.exit);return{initial:dt(r),animate:gt(i),exit:dt(a)}})(n,r):null}catch(e){if(_e(e))throw e;return null}})(e):await ut(e))(e);if(i)return i;const a=`Failed to parse ${n} animation for "${t}".`;r?.({code:"INVALID_ANIMATION",message:a,context:{componentId:t,animationType:n,animation:e}})}catch(i){const a=_e(i)?{code:i.code,message:i.message,context:{componentId:t,animationType:n,animation:e,category:i.category,presetName:i.presetName}}:{code:"INVALID_ANIMATION",message:`Error parsing ${n} animation for "${t}".`,context:{componentId:t,animationType:n,animation:e}};r?.(a)}return null}function ht(e){return"string"==typeof e&&!e.includes("(")&&e.trim().includes(" ")}function vt(e,t,n){const r={};return new Set([...Object.keys(e),...Object.keys(t)]).forEach(i=>{if("transition"===i)return;const a=e[i],o=t[i];if(void 0===o)return void(r[i]=a);if(a===o)return void(r[i]=o);const s=void 0!==a?a:"opacity"===i?1:"number"==typeof o?0:"0";if(ht(s)||ht(o))r[i]=n>.5?o:s;else if("number"!=typeof o||"number"!=typeof s){if("number"==typeof s&&"string"==typeof o){if(o.includes("px"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}px`);if(o.includes("%"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}%`);if(o.includes("deg"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}deg`)}if("string"==typeof s&&"number"==typeof o){if(s.includes("px")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}px`)}if(s.includes("%")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}%`)}if(s.includes("deg")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}deg`)}}if("string"==typeof o&&"string"==typeof s){if(o.includes("px")||s.includes("px")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}px`)}if(o.includes("%")||s.includes("%")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}%`)}if(o.includes("deg")||s.includes("deg")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}deg`)}if(o.includes("(")&&o.includes(")")||s.includes("(")&&s.includes(")")){const e=String(s).match(/([a-zA-Z]+)\(([^)]+)\)/),t=o.match(/([a-zA-Z]+)\(([^)]+)\)/);if(e&&t&&e[1]===t[1]){const a=e[1],o=e[2],s=t[2];if(!isNaN(parseFloat(o))&&!isNaN(parseFloat(s))){const e=parseFloat(o),t=e+(parseFloat(s)-e)*n;return void(r[i]=`${a}(${t})`)}}}}r[i]=n>.5?o:s}else r[i]=s+(o-s)*n}),r}function yt(e,t,n){for(let n=t;n>=0;n-=1){const t=e[n];if("number"==typeof t||"string"==typeof t)return t}return n}function xt(e,t,n){return Math.min(n,Math.max(t,e))}function St(e,t,n){return e+(t-e)*n}function bt(e,t,n){if("number"==typeof e&&"number"==typeof t)return St(e,t,n);const r=String(e),i=String(t),a=r.match(/^([-\d.]+)(.*)$/),o=i.match(/^([-\d.]+)(.*)$/);if(a&&o){const e=parseFloat(a[1]),t=parseFloat(o[1]),r=o[2]||a[2]||"",i=St(e,t,n);return r?`${i}${r}`:i}const s=r.match(/^([a-zA-Z]+)\(([-\d.]+)(.*)\)$/),c=i.match(/^([a-zA-Z]+)\(([-\d.]+)(.*)\)$/);if(s&&c&&s[1]===c[1]){const e=parseFloat(s[2]),t=parseFloat(c[2]),r=c[3]||s[3]||"",i=St(e,t,n);return`${c[1]}(${i}${r})`}return n>=1?t:e}function wt(e,t,n,r,i){const a=t[n]??r,o=xt(i,0,1);if(!Array.isArray(a))return bt(e,a,o);if(0===a.length)return e;const s=function(e,t,n){const r=e.transition,i=r?.[t],a=(i&&!Array.isArray(i)?i.times:null)??r?.times;return Array.isArray(a)&&a.length===n?a:null}(t,n,a.length);if(1===a.length||o<=(s?.[0]??0))return yt(a,0,e);for(let t=1;t<a.length;t+=1){const n=s?.[t]??t/(a.length-1);if(o>n)continue;const r=s?.[t-1]??(t-1)/(a.length-1),i=n-r,c=i<=0?1:(o-r)/i;return bt(yt(a,t-1,e),yt(a,t,e),c)}return yt(a,a.length-1,e)}function Mt(e,t,n){const r=e[t]??n;return Array.isArray(r)?yt(r,r.length-1,n):r}function Rt(e,t){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){const t=parseFloat(e);if(Number.isFinite(t))return t}return t}function Et(e,t){switch(e){case"opacity":return"initial"===t||"exit"===t?0:1;case"scale":return 1;case"filter":return"none";default:return 0}}function kt(e,t,n){const r=e[t];return void 0===r?n:r}function Pt(e,t,n,i){return(0,r.useTransform)(e,e=>i(e,t.current,n))}function It(e,t,n,i,a){return(0,r.useTransform)(e,e=>{const r=Rt(Et(n,"animate"),0);return Rt((a??i)(e,t.current,n),r)})}function Ct(e,t,n,r){const i=It(e,t,"opacity",n,r),a=Pt(e,t,"x",n),o=Pt(e,t,"y",n),s=It(e,t,"scale",n,r),c=Pt(e,t,"rotate",n),l=Pt(e,t,"rotateX",n),u=Pt(e,t,"rotateY",n),d=Pt(e,t,"skewX",n),f=Pt(e,t,"skewY",n),m=Pt(e,t,"filter",n);return{style:{opacity:i,x:a,y:o,scale:s,rotate:c,rotateX:l,rotateY:u,skewX:d,skewY:f,filter:m},opacity:i,x:a,y:o,scale:s,rotate:c,rotateX:l,rotateY:u,skewX:d,skewY:f,filter:m}}var At=.001;function Dt(e){return e.renderProgressMotion?.get()??e.renderProgress??0}function Tt(e){return e.dragTransaction?e.dragTransaction:!0===e.firstSceneEnterActive?e.preparedSnapshot??null:null}function Lt(e){return Tt(e)?.registrySnapshot.timelineDuration??e.getTimelineDuration?.()??e.sceneTransitionDuration}function Ot(e,t,n,r,i,a){const o=function(e,t,n,r){const i=function(e){return Dt(e)>=0?"forward":"backward"}(e),a=function(e){return Math.max(0,e.sharedElapsedMotion?.get()??0)}(e),o=function(e){const t=e.dragTimelineProgress;return xt("number"==typeof t?t:Math.abs(Dt(e)),0,1)}(e),s=function(e){const t=Lt(e);if(Tt(e))return t;const n=e.sharedTimelineDurationMs??0;return n>0?n:t}(e),c=Lt(e),l=Math.abs(Dt(e)),u=function(e,t,n){return n<=0?e>=t-At?1:0:e<=t?0:xt((e-t)/n,0,1)}(a,t,n),d={direction:i,transitionProgress:o,sharedElapsedMs:a,projectedSceneElapsedMs:a,sharedTimelineDurationMs:s,sceneTimelineDurationMs:c,sceneOffset:e.sceneOffset};if(0===e.sceneOffset&&e.isActive){const t=!0===e.firstSceneEnterActive||"settle"===e.dragRelease?.mode||"enter"===e.dragRelease?.mode;if(e.isDragging||l>At){if(l<=At&&t)return{...d,mode:"enter",localProgress:u};const n=Math.max(r,1),i=l*e.sceneTransitionDuration;return{...d,mode:"outgoing",localProgress:xt(i/n,0,1)}}return t?{...d,mode:"enter",localProgress:u}:{...d,mode:"rest",projectedSceneElapsedMs:c,localProgress:1}}return("forward"===i&&1===e.sceneOffset||"backward"===i&&-1===e.sceneOffset)&&(e.isDragging||l>At)?{...d,mode:"enter",localProgress:u}:{...d,mode:"hidden",projectedSceneElapsedMs:0,localProgress:0}}(e,t,n,r);return a?{...o,mode:"hidden",localProgress:0,projectedSceneElapsedMs:0}:i?{...o,mode:"rest",localProgress:1,projectedSceneElapsedMs:o.sceneTimelineDurationMs}:o}function Vt(e,t,n){return e?function(e,t,n){const r=Mt(t.enterInitial,n,Et(n,"initial")),i=Mt(t.enterAnimate,n,Et(n,"animate"));switch(e.mode){case"rest":default:return i;case"hidden":return r;case"enter":return wt(r,t.enterAnimate,n,Et(n,"animate"),e.localProgress);case"outgoing":return 0===Object.keys(t.exitTarget).length?i:"forward"===e.direction?wt(i,t.exitTarget,n,Et(n,"exit"),e.localProgress):wt(r,t.enterAnimate,n,Et(n,"animate"),1-e.localProgress)}}(e,t,n):Mt(t.enterAnimate,n,Et(n,"animate"))}var jt=new WeakMap,zt=new WeakMap;function Nt(e,t){return"entered"===e&&t}function Ft(e,t,n,r){return void 0===e?t:n+(r-n)*xt(e,0,1)}function $t(e,t,n){return bt(kt(t.initial,n,Et(n,"initial")),kt(t.animate,n,Et(n,"animate")),e)}function Bt(e,t,n){const r=Rt(Et(n,"animate"),0),i=Rt(kt(t.initial,n,Et(n,"initial")),r);return i+(Rt(kt(t.animate,n,Et(n,"animate")),r)-i)*e}function qt(e,t){switch(e){case"hidden":default:return"idle";case"outgoing":return"exiting";case"rest":return"entered";case"enter":return t>=.999?"entered":"entering"}}function Ht(e){return e<=0?0:e>=1?1:e}function Wt(e,t){return{enterProgress:Ht(t),phase:e}}function Yt(e,t){const n=t<=0?0:t>=1?1:t;return{enterProgress:n,phase:qt(e,n)}}var Ut={enterProgress:0,phase:"idle"};function Xt({signedVisual:e,phaseMotion:i,render:a}){const[o,s]=(0,t.useState)(()=>Wt(i.get(),e.get()));return(0,r.useMotionValueEvent)(e,"change",e=>{s(Wt(i.get(),e))}),(0,r.useMotionValueEvent)(i,"change",t=>{s(Wt(t,e.get()))}),(0,n.jsx)(n.Fragment,{children:a(o)})}function Kt({visualState:e,render:i}){const[a,o]=(0,t.useState)(()=>{const t=e.get();return t?Yt(t.mode,t.localProgress):Ut});return(0,r.useMotionValueEvent)(e,"change",e=>{o(e?Yt(e.mode,e.localProgress):Ut)}),(0,n.jsx)(n.Fragment,{children:i(a)})}function Zt(e){if("string"==typeof e){const t=r.motion[e];if(t)return t}return r.motion.div}function _t(e,t,n){return"last"===n?t-1-e:"center"===n?Math.abs(e-(t-1)/2):e}function Gt(e){return t.Children.toArray(e.props.children).filter(t.isValidElement)}function Jt(e){return Gt(e).length}function Qt(e,t,n,r,i,a="animate"){const o=e[a]?.transition?.duration,s="number"==typeof o&&Number.isFinite(o)?Math.max(1e3*o,0):Math.max(t,0),c=Math.max(n,0);let l=0;for(let e=0;e<i;e+=1)l=Math.max(l,_t(e,i,r));const u=l*c;return{itemDurationMs:s,tailDurationMs:u,effectiveDurationMs:Math.max(t,u+s)}}function en(e,t,n,r,i){return Qt(e,t??0,n,r,Jt(i)).effectiveDurationMs}function tn(e,n){const i=n(e.get()),a=(0,t.useRef)(i),[o,s]=(0,t.useState)(()=>({phase:i,revision:0}));return(0,r.useMotionValueEvent)(e,"change",e=>{const t=n(e);t!==a.current&&(a.current=t,s(e=>({phase:t,revision:e.revision+1})))}),[o.phase,o.revision]}function nn(e,n,r=0){const i=(0,t.useRef)(Math.max(n,0)),[a,o]=(0,t.useState)(null);return(0,t.useEffect)(()=>{i.current=Math.max(n,0)},[n]),(0,t.useEffect)(()=>{if("animate"!==e)return;const t=i.current;if(0===t)return void o(r);const n=window.setTimeout(()=>o(r),t);return()=>window.clearTimeout(n)},[e,r]),"animate"===e&&a===r}function rn(e,r,i,a,o,s,c,l,u=!1){const d=t.Children.toArray(e.props.children),f=Gt(e).length,m=Math.max(i,0)/1e3,g="boolean"==typeof o?o?"animate":"initial":o,p=r.animate.transition??{},h={initial:r.initial,animate:e=>({...r.animate,transition:u?{...p,duration:0,delay:0}:{...p,...void 0===p.duration&&void 0!==s?{duration:Math.max(s,0)/1e3}:{},delay:_t(e,f,a)*m}}),exit:e=>{const t=c?.exit??r.initial,n=t.transition??{};return{...t,transition:{...n,...void 0===n.duration&&void 0!==l?{duration:Math.max(l,0)/1e3}:{},delay:_t(e,f,a)*m}}}};let v=0;const y=d.map((e,r)=>{if(!(0,t.isValidElement)(e))return e;const i=v;v+=1;const a=Zt(e.type);return(0,n.jsx)(a,{custom:i,variants:h,className:e.props.className,style:e.props.style,children:e.props.children},e.key??r)}),x=Zt(e.type),{children:S,...b}=e.props;return(0,n.jsx)(x,{...b,initial:"initial",animate:g,variants:{initial:{},animate:{},exit:{}},children:y})}function an({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,signedVisual:c}){const[l,u]=tn(c,e=>e>0?"animate":e<0&&o?"exit":"initial");return rn(e,t,n,r,l,i,o,s,nn(l,a??en(t,i,n,r,e),u))}function on({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,phaseMotion:o,staticReveal:s}){const[c,l]=tn(o,e=>"entering"===e||"entered"===e?"animate":"initial"),u=nn(c,a??en(t,i,n,r,e),l);return rn(e,t,n,r,c,i,void 0,void 0,s||u)}function sn({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,visualState:c}){const[l,u]=tn(c,e=>"outgoing"===e?.mode&&o?"exit":e&&("enter"===e.mode&&e.localProgress>0||"rest"===e.mode)?"animate":"initial");return rn(e,t,n,r,l,i,o,s,nn(l,a??en(t,i,n,r,e),u))}var cn=(0,t.createContext)(null);function ln({value:e,children:t}){return(0,n.jsx)(cn.Provider,{value:e,children:t})}function un(){const e=(0,t.useContext)(cn);if(!e)throw new Error("useAnimateTimeline must be used inside an <Animate> child.");return e}var dn=Object.freeze({progress:0,signedProgress:0,phase:"idle",source:"idle"});function fn(e,t){if(!t)return"idle";switch(e?.dragTransaction?.phase){case"driving":return"gesture";case"settling":case"bouncing":return"continuation";case"programmatic":return"programmatic"}return"settle"===e?.dragRelease?.mode||"bounce"===e?.dragRelease?.mode?"continuation":"enter"===e?.dragRelease?.mode||e?.firstSceneEnterActive?"programmatic":"idle"}function mn(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function gn(e,t,n,r){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1}else if(!mn(e)||!mn(t))return!1;const i=e,a=t,o=n.get(i),s=r.get(a);if(o||s)return o===a&&s===i;n.set(i,a),r.set(a,i);try{if(Array.isArray(e)&&Array.isArray(t))return e.every((e,i)=>gn(e,t[i],n,r));const i=e,a=t,o=Object.keys(i).sort(),s=Object.keys(a).sort();if(o.length!==s.length)return!1;for(let e=0;e<o.length;e+=1){const t=o[e];if(t!==s[e]||!gn(i[t],a[t],n,r))return!1}return!0}finally{n.delete(i),r.delete(a)}}function pn(e){const n=(0,t.useRef)(e);return gn(n.current,e,new WeakMap,new WeakMap)||(n.current=e),n.current}var hn=(0,t.createContext)(null),vn=Object.freeze({opacity:1}),yn=0,xn=({enterAnimation:e,exitAnimation:i,loopAnimation:a,animateId:o,duration:s,timeline:c,visibility:l,stagger:u,enterRef:d,exitRef:f,children:m})=>{const g=(0,t.useRef)(o||"animate-"+ ++yn).current,p=(0,t.useContext)(hn),h=me(),y=h?.reportError,x=!0===h?.prefersReducedMotion,S=(0,t.useContext)(ie),b=(0,t.useContext)(oe),[w,M]=(0,t.useState)(null),[R,E]=(0,t.useState)(null),[k,P]=(0,t.useState)(null),[I,C]=(0,t.useState)(0),A=(0,t.useRef)(0),D=(0,t.useRef)(null),T=(0,t.useRef)(new Set),L=(0,t.useRef)(null),O=(0,t.useRef)(new Set),V=pn(e),j=pn(i),z=pn(a),N=(0,r.useAnimation)(),F=(0,r.useAnimation)(),$=(0,t.useMemo)(()=>function({duration:e,timeline:t,visibility:n}){return{duration:{enter:e?.enter??600,exit:e?.exit??600},timeline:{driver:t?.driver??"scene",delay:t?.delay??0,after:t?.after,phase:{start:t?.phase?.start,end:t?.phase?.end}},visibility:{replay:n?.replay??!0,enterMargin:n?.enterMargin,exitMargin:n?.exitMargin}}}({duration:s,timeline:c,visibility:l}),[s,c,l]),B=p?.mode??h?.mode??"drag",q="drag"===B&&"clock"===$.timeline.driver,H=(0,t.useRef)(null),W="drag"===B&&p?.isActive?p.activationToken??0:0;(null===H.current||H.current.mode!==B||H.current.token!==W||0===W&&H.current.arrival!==q)&&(H.current={token:W,mode:B,arrival:q});const Y="drag"===B&&H.current.arrival,U=p?.beginPreparation,X=p?.declareAnimateLane,K=(0,t.useMemo)(()=>{const{driver:e,...t}=$.timeline;return{...t,lane:"scroll"===B&&"scene"===e&&b?"scroll":"visibility"}},[b,B,$.timeline]),Z=$.duration.enter,_=$.duration.exit,G=K.delay,J=K.after,Q=(0,t.useContext)(ae),ee=Y&&p?.isActive?p.activationToken??0:0,te=I>0&&D.current?.enterAnimation===V&&D.current?.exitAnimation===j&&D.current?.loopAnimation===z,ne=(0,t.useRef)(null),re=ne.current;Y&&(0===ee||null===re||re.token!==ee)&&(ne.current={token:ee,ready:te,enterVariant:te?w:null,exitVariant:te?R:null,infiniteVariant:te?k:null,hasAuthoredEnterAnimation:!!V,enterDuration:Z,exitDuration:_,delay:G,stagger:u,enterAnimation:V,exitAnimation:j,loopAnimation:z});const se=Y?ne.current:null;se&&!se.ready&&I>0&&D.current?.enterAnimation===se.enterAnimation&&D.current?.exitAnimation===se.exitAnimation&&D.current?.loopAnimation===se.loopAnimation&&(se.ready=!0,se.enterVariant=w,se.exitVariant=R,se.infiniteVariant=k);const ce=se?se.enterAnimation:V,le=se?se.exitAnimation:j,ue=se?se.loopAnimation:z,de=se?.ready?se.enterVariant:Y?null:w,fe=se?.ready?se.exitVariant:Y?null:R,ge=se?.ready?se.infiniteVariant:Y?null:k,pe=se?.enterDuration??Z,he=se?.exitDuration??_,ve=se?.delay??G,ye=se?se.stagger:u;(0,t.useEffect)(()=>{if(!Y)return;const e=X?.(g,"visibility");return()=>e?.dispose()},[X,g,Y]),(0,t.useEffect)(()=>{if(!Y)return;const e=(e,t)=>{const n=`${g}:${e}`;T.current.has(n)||(T.current.add(n),y?.({code:"INVALID_ANIMATION",message:t,context:{componentId:g,field:e,lane:"visibility",mode:"drag"}}))};J&&e("after",`Animate "${g}" ignores after in drag mode when timeline.driver is 'clock'.`),j&&e("exitAnimation",`Animate "${g}" ignores exitAnimation in drag mode when timeline.driver is 'clock'.`)},[g,Y,J,y,j]);const xe="function"==typeof m,Se=!(!ce&&!ue||(Y?se?.ready??te:te)||de||fe||ge),be="drag"===B?!Y:"scroll"===K.lane,we="scroll"===B&&!be,Me=(0,t.useRef)(new Set);(0,t.useEffect)(()=>{if(!d&&!f)return;const e=(e,t)=>{const n=`${g}:${e}`;Me.current.has(n)||(Me.current.add(n),y?.({code:"INVALID_ANIMATION",message:t,context:{componentId:g,field:e,mode:B,scrub:be}}))};if(be){const t="drag"===B?"the Scene element track (drag)":"the zone scroll budget (scroll takeover)";return d&&e("enterRef",`Animate "${g}" ignores enterRef: this element is driven by ${t}, whose progress has a single owner. Use timeline.driver:'clock' (drag) or move it outside the takeover zone (scroll) for manual control.`),void(f&&e("exitRef",`Animate "${g}" ignores exitRef: this element is driven by ${t}, whose progress has a single owner. Use timeline.driver:'clock' (drag) or move it outside the takeover zone (scroll) for manual control.`))}Y&&f&&e("exitRef",`Animate "${g}" ignores exitRef in drag mode when timeline.driver is 'clock': this lane has no exit pass (it also ignores exitAnimation).`)},[d,f,g,Y,be,B,y]);const Re=Y?ye:u,Ee=Re&&!xe&&de&&(0,t.isValidElement)(m)?m:null,ke=!!Ee,Pe=Re?.each??40,Ie=Re?.from??"first",Ce=(0,t.useMemo)(()=>Ee&&de?Qt(de,pe,Pe,Ie,Jt(Ee)):null,[pe,de,Ee,Pe,Ie]),Ae=(0,t.useMemo)(()=>Ee&&fe?Qt(fe,he,Pe,Ie,Jt(Ee),"exit"):null,[he,fe,Ee,Pe,Ie]),De=Ce?.effectiveDurationMs??pe,Te=Ae?.effectiveDurationMs??he,Le=(0,t.useMemo)(()=>S?{...S,zoneStates:Q?.zoneStates??{},store:Q?.store}:null,[S,Q?.store,Q?.zoneStates]);(0,t.useEffect)(()=>{const e=O.current,t=++A.current,n=()=>A.current===t;L.current?.lease.cancel(),L.current=null;const r="drag"!==B||Y?void 0:U?.();r&&e.add(r),L.current=r?{generation:t,lease:r}:null;const i=e=>{n()&&y?.(e)};return M(null),E(null),P(null),C(0),ce||ue?((async()=>{const[e,n,r]=await Promise.all([pt(ce,g,"enter",i),pt(le,g,"exit",i),pt(ue,g,"loop",i)]);A.current===t&&(D.current={enterAnimation:ce,exitAnimation:le,loopAnimation:ue},M(e??null),E(n??null),P(r??null),C(t))})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(A.current+=1)}):(y?.({code:"INVALID_ANIMATION",message:`Animate "${g}" requires enterAnimation or loopAnimation.`,context:{componentId:g,hasExitAnimation:!!le}}),(()=>{const n=L.current;!n||n.generation!==t||(n.lease.complete(),e.delete(n.lease),L.current=null)})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(A.current+=1)})},[g,B,Y,y,U,ce,le,ue]),(0,t.useEffect)(()=>{!Y||0===ee||!se||(se.enterAnimation!==V||se.exitAnimation!==j||se.loopAnimation!==z)&&Promise.all([pt(V,g,"enter"),pt(j,g,"exit"),pt(z,g,"loop")])},[se,ee,g,Y,V,j,z]);const Oe=function({sceneContext:e,enterVariant:n,exitVariant:i,componentId:a,delay:o,enterDuration:s,exitDuration:c,after:l,variantsPending:u=!1}){const d=e?Tt(e):null,f=d?.registrySnapshot.registrations.get(a),m=d?.enterVariantsByAnimateId.get(a)??null,g=!(!d||f&&m),p=f?.duration??s,h=d?.registrySnapshot.calculatedDelays.get(a)??0,v=m??n,y=(0,t.useRef)(h),x=(0,t.useRef)(d);x.current=d;const S=(0,t.useRef)({enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}}),b=e?Ot(e,y.current,p,c,g,u):null,w=b?"outgoing"===b.mode?("forward"===b.direction?1:-1)*b.localProgress:b.localProgress:0,M=(0,r.useMotionValue)(w),R=(0,r.useMotionValue)(b),[E,k]=(0,t.useState)(!1),P=((0,t.useRef)(null),(0,t.useRef)(null)),I=(0,t.useRef)(null);(0,t.useRef)({identity:null,categories:new Set}),(0,t.useEffect)(()=>{},[a,o,s,n,m,f,g,d,e?.isActive,e?.sceneOffset,l]),(0,t.useEffect)(()=>{S.current={enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}},d&&(y.current=h)},[i,h,d,v]),(0,t.useEffect)(()=>{const t=e?.registerAnimate,r=e?.unregisterAnimate,i=e?.getCalculatedDelay;if(!t||!i||!n)return;const c=t(a,{delay:o,duration:s,after:l,lane:"drag"});return c?.setEnterVariant?.(n),x.current||(y.current=c?.getCalculatedDelay?.()??i(a)),()=>{c?.dispose?c.dispose():r?.(a)}},[e?.registerAnimate,e?.unregisterAnimate,e?.getCalculatedDelay,n,a,o,s,l]),(0,t.useEffect)(()=>{if(!e)return;const t=()=>{if(d)y.current=h;else{const t=e.getCalculatedDelay?.(a);"number"==typeof t&&(y.current=t)}const t=Ot(e,y.current,p,c,g,u),n="outgoing"===t.mode?("forward"===t.direction?1:-1)*t.localProgress:t.localProgress,r=[t.mode,t.direction,e.sceneOffset,e.isActive?"active":"inactive",e.isDragging?"dragging":"idle"].join(":"),i=P.current!==r;if(M.set(n),R.set(t),P.current=r,i&&(t.mode,t.direction,e.sceneOffset,e.isActive,e.isDragging,e.sceneState,Dt(e).toFixed(3),t.transitionProgress.toFixed(3),t.sharedElapsedMs.toFixed(1),t.projectedSceneElapsedMs.toFixed(1),t.sharedTimelineDurationMs,t.sceneTimelineDurationMs,t.localProgress.toFixed(3),y.current),"enter"===t.mode){const n=t.localProgress<=.001?"before-delay":t.localProgress>=.999?"enter-complete":"enter-active";I.current!==`${t.mode}:${n}`&&(t.mode,t.sharedElapsedMs.toFixed(1),t.projectedSceneElapsedMs.toFixed(1),t.sharedTimelineDurationMs,t.sceneTimelineDurationMs,t.transitionProgress.toFixed(3),y.current,t.localProgress.toFixed(3),Dt(e).toFixed(3),e.sceneOffset,I.current=`${t.mode}:${n}`)}};t();const n=[e.sharedElapsedMotion?.on("change",t),e.renderProgressMotion?.on("change",t)].filter(e=>"function"==typeof e);return()=>{n.forEach(e=>e())}},[e,M,R,a,s,c,g,u,h,p,d,e?.renderProgressMotion,e?.renderProgress,e?.isDragging,e?.isActive,e?.sceneOffset,e?.sceneState,e?.dragRelease,e?.firstSceneEnterActive]);const C=Ct(R,S,Vt);return(0,t.useEffect)(()=>{if(!e)return void k(!1);const t=()=>{const t=Ot(e,y.current,p,c,g,u);k(e.isActive&&0===e.sceneOffset&&!e.isDragging&&("rest"===t.mode||"enter"===t.mode)&&t.localProgress>=.999)};t();const n=[e.sharedElapsedMotion?.on("change",t),e.renderProgressMotion?.on("change",t)].filter(e=>"function"==typeof e);return()=>{n.forEach(e=>e())}},[e,p,g,u,c,e?.isActive,e?.sceneOffset,e?.isDragging,e?.renderProgressMotion,e?.renderProgress,e?.dragRelease,e?.firstSceneEnterActive]),{style:C.style,opacity:C.opacity,x:C.x,y:C.y,scale:C.scale,rotate:C.rotate,useInteractiveStyles:!0,shouldRunInfinite:E,visualState:R}}({sceneContext:"drag"!==B||Y?null:p,enterVariant:w,exitVariant:R,componentId:g,delay:G,enterDuration:De,exitDuration:Te,after:J,variantsPending:Se}),Ve=function({enabled:e,sceneContext:n,enterVariant:i,hasAuthoredEnterAnimation:a,parseReady:o,delay:s,enterDuration:c,enterRef:l}){const u=(0,t.useRef)({initial:{},animate:{}}),d=!!l&&s<=0,f=(0,t.useRef)({delay:s,enterDuration:c,hasAuthoredEnterAnimation:a,parseReady:o,enterVariant:i,autoEnterSuppressed:d});f.current={delay:s,enterDuration:c,hasAuthoredEnterAnimation:a,parseReady:o,enterVariant:i,autoEnterSuppressed:d};const m=(0,r.useMotionValue)(a?0:1),g=(0,r.useMotionValue)(a?"idle":"entered"),[p,h]=(0,t.useState)(!1),[v,y]=(0,t.useState)(!1),x=(0,t.useRef)(null),S=(0,t.useRef)(null),b=(0,t.useRef)(0),w=(0,t.useRef)(0),M=(0,t.useRef)(null),R=(0,t.useRef)(!1),E=(0,t.useRef)(0===(n?.activationToken??0)),k=(0,t.useRef)(n);k.current=n;const P=(0,t.useCallback)(()=>{x.current?.stop(),x.current=null,null!==S.current&&(clearTimeout(S.current),S.current=null)},[]),I=(0,t.useCallback)(()=>{const e=f.current;P(),b.current=0,w.current=0,M.current=null,R.current=!1,h(!1),y(!1),g.set(e.hasAuthoredEnterAnimation?"idle":"entered"),m.set(e.hasAuthoredEnterAnimation?0:1)},[g,P,m]),C=(0,t.useCallback)((e,t)=>{const n=k.current,i=f.current;if(!n?.isActive||(n.activationToken??0)!==e||e<=0)return;if(i.hasAuthoredEnterAnimation&&!i.parseReady)return void(w.current=e);if(b.current===e)return;w.current=0,b.current=e,P(),M.current=null,h(!1),u.current={initial:i.enterVariant?.initial??{},animate:i.enterVariant?.animate??{}};const a="static"===t&&E.current;y(a);const o=()=>{const t=k.current;return!(!t?.isActive||(t.activationToken??0)!==e)},s=()=>{o()&&h(!0)};if(!i.hasAuthoredEnterAnimation||null===i.enterVariant||a)return g.set("entered"),m.set(1),void(()=>{const e=Math.max(i.delay,0);e<=0?s():S.current=setTimeout(()=>{S.current=null,s()},e)})();g.set("waiting"),m.set(0);const c=()=>{if(S.current=null,!o())return;g.set("entering");const e=Math.max(i.enterDuration,0);if(e<=0)return g.set("entered"),m.set(1),void h(!0);x.current=(0,r.animate)(m,1,{duration:e/1e3,ease:"easeInOut",onComplete:()=>{x.current=null,o()&&(g.set("entered"),m.set(1),h(!0))}})},l=Math.max(i.delay,0);if(i.autoEnterSuppressed)return M.current=c,void(R.current&&(R.current=!1,M.current=null,c()));l>0?S.current=setTimeout(c,l):c()},[g,P,m]),A=e&&n?.isActive?n.activationToken??0:0,D=n?.activationKind??null;(0,t.useEffect)(()=>{A<=0?I():C(A,D)},[D,A,I,C]),(0,t.useEffect)(()=>{const e=w.current;e<=0||!o||C(e,k.current?.activationKind??null)},[i,o,C]),(0,t.useEffect)(()=>()=>{P(),b.current=0,w.current=0},[P]);const T=(0,t.useCallback)(()=>{const e=M.current;e?(M.current=null,R.current=!1,null!==S.current&&(clearTimeout(S.current),S.current=null),e()):R.current=!0},[]);return(0,t.useEffect)(()=>{if(l&&e)return l.current=T,()=>{l.current===T&&(l.current=null)}},[e,l,T]),{style:Ct(m,u,$t,Bt).style,visualMotion:m,phaseMotion:g,shouldRunInfinite:p,staticReveal:v}}({enabled:Y,sceneContext:"drag"===B?p:null,enterVariant:de,hasAuthoredEnterAnimation:se?.hasAuthoredEnterAnimation??!!e,parseReady:se?.ready??I>0,delay:ve,enterDuration:De,enterRef:Y?d:void 0}),je=function({sceneContext:e,zoneRuntime:n,zoneId:i,enterVariant:a,exitVariant:o,hasAuthoredEnterAnimation:s,hasAuthoredExitAnimation:c,hasInfiniteAnimation:l=!1,componentId:u,duration:d,timeline:f,visibility:m,globalEnterMargin:g,globalExitMargin:p,enterRef:h,exitRef:y,variantsPending:x=!1}){const S=d.enter,b=d.exit,w=!0===me()?.prefersReducedMotion,M=w?0:S,R=w?0:b,E=f.delay,k=f.after,P="scroll"===f.lane,I=f.phase?.start,C=f.phase?.end,A=m.replay,D=v()?.scale??1,T=m.enterMargin??g??50,L=m.exitMargin??p??50,O=Math.max(0,T*D),V=Math.max(0,L*D),j=(0,t.useRef)({enterInitial:{},enterAnimate:{},exitTarget:{}}),z=(0,r.useMotionValue)(0),N=(0,r.useMotionValue)(i&&n?n.store?.getKeySnapshot(i)??n.zoneStates[i]??null:null),[F,$]=(0,t.useState)(!1),B=(0,t.useRef)(null),[q,H]=(0,t.useState)(0),W=n?.registerZoneAnimation,Y=n?.unregisterZoneAnimation,U=!!(a?.animate&&Object.keys(a.animate).length>0)||!!s,X=function(e,t){return!!(t>0&&e?.exit&&Object.keys(e.exit).length>0)}(o,b)||!!c;(0,t.useEffect)(()=>{j.current={enterInitial:a?.initial||{},enterAnimate:a?.animate||{},exitTarget:o?.exit||{}}},[a,o]);const K=(0,t.useRef)("idle"),Z=(0,r.useMotionValue)("idle"),_=(0,t.useCallback)(e=>{K.current=e,Z.set(e)},[Z]),G=(0,t.useRef)(null),J=(0,t.useRef)(null),Q=(0,t.useRef)(0),ee=(0,t.useRef)(!1),te=(0,t.useRef)(null),ne=(0,t.useRef)(null),re=(0,t.useRef)(null),ie=(0,t.useRef)(()=>{}),ae=(0,t.useRef)(0),oe=(0,t.useRef)(null),se=(0,t.useRef)(!1),ce=(0,t.useRef)(!1),le=(0,t.useRef)(!1),ue=(0,t.useCallback)(()=>n&&i?n.store?.getKeySnapshot(i)??n.zoneStates[i]??null:null,[i,n]);(0,t.useEffect)(()=>{if(!P||!n||!i)return void N.set(null);const e=()=>{N.set(ue())};return e(),n.store?.subscribeKey(i,e)},[P,ue,i,n,N]);const de=!!h&&!P&&!(k||E>0),fe=!!y&&!P,ge=(0,t.useRef)(!1),pe=(0,t.useRef)(!1),he=(0,t.useCallback)(e=>{e?.publishEnterCompleted()},[]),ve=(0,t.useCallback)(()=>{ae.current+=1,oe.current=null,te.current&&(clearTimeout(te.current),te.current=null),ne.current&&(ne.current(),ne.current=null),re.current&&(re.current(),re.current=null)},[]),ye=(0,t.useCallback)(()=>{Q.current+=1,J.current&&(J.current.stop(),J.current=null),ve()},[ve]),xe=(0,t.useCallback)(()=>{const e=B.current?.ownerDocument?.defaultView;e&&(re.current?.(),re.current=function(e,t){let n=zt.get(e);if(!n){const t=e.requestAnimationFrame?.bind(e)??(t=>e.setTimeout(()=>t(Date.now()),16)),r=e.cancelAnimationFrame?.bind(e)??(t=>e.clearTimeout(t));n={callbacks:new Map,frame:null,requestFrame:t,cancelFrame:r},zt.set(e,n)}const r=n,i=r.callbacks.get(t)??{callback:t,cancelled:!1};return r.callbacks.set(t,i),null===r.frame&&(r.frame=r.requestFrame(()=>{r.frame=null;const t=[...r.callbacks.values()];r.callbacks.clear(),t.forEach(e=>{e.cancelled||e.callback()}),0===r.callbacks.size&&null===r.frame&&zt.get(e)===r&&zt.delete(e)})),()=>{i.cancelled=!0,r.callbacks.get(t)===i&&r.callbacks.delete(t),0===r.callbacks.size&&null!==r.frame&&(r.cancelFrame(r.frame),r.frame=null,zt.get(e)===r&&zt.delete(e))}}(e,()=>{re.current=null,ie.current()}))},[]),Se=(0,t.useCallback)(()=>{ve(),_("entering"),z.get()<0&&z.set(0);const e=G.current,t=++Q.current,n=(0,r.animate)(z,1,{duration:Math.max(M,0)/1e3,ease:"easeInOut",onComplete:()=>{Q.current===t&&(J.current=null,_("entered"),he(e),xe())}});J.current=n},[ve,M,he,xe,_,z]),be=(0,t.useCallback)((e=!1)=>{const t=K.current,n="exited"===t?"exited":"exiting"===t?"exiting":"idle";ye();const r={token:++ae.current,origin:n,dependencyReady:!k,delayStarted:!1,delayReady:!1,coldStartBypass:e};oe.current=r,_("waiting"),$(!1);const i=e=>{oe.current?.token!==r.token||"pending"===e.kind||(r.dependencyReady=!0,ne.current=null,xe())};if(!k)return;const a=G.current;a?ne.current=a.observeAfter(i):i({kind:"invalid",leaderId:k,reason:"missing"})},[xe,_,ye,k]),we=(0,t.useCallback)(()=>{const e=oe.current;if(e&&e.dependencyReady){if(!e.delayStarted){if(e.delayStarted=!0,E>0){const t=e.token;return void(te.current=setTimeout(()=>{te.current=null,oe.current?.token===t&&(e.delayReady=!0,xe())},E))}e.delayReady=!0}e.delayReady&&Se()}},[E,Se,xe]),Me=(0,t.useCallback)(()=>{ye(),_("exiting"),$(!1),z.get()>=0&&z.set(-1e-6);const e=++Q.current,t=(0,r.animate)(z,-1,{duration:Math.max(R,0)/1e3,ease:"easeInOut",onComplete:()=>{Q.current===e&&(J.current=null,_("exited"))}});J.current=t},[R,ye,_,z]),Re=(0,t.useCallback)(t=>{if(P||x)return;const n=B.current;if(!(n instanceof HTMLElement))return;const r=e?.firstSceneEnterGateKnown,i=e?.firstSceneEnterReady,a=e?.firstSceneEnterActive;if(!1===r)return ye(),_("idle"),z.set(0),void $(!1);if(!1===i&&!0===a)return ce.current=!1,ye(),_("idle"),z.set(0),void $(!1);const o=!1===i&&!1===a&&!ce.current&&!de;o&&(ce.current=!0,se.current=!0,ye(),_("entered"),z.set(1),he(G.current));const s=n.getBoundingClientRect();if(!(s.width>0||s.height>0||s.bottom!==s.top))return;const c=n.closest('[data-cineview-container="true"]'),l=t?.top??(c?c.getBoundingClientRect().top:0),u=(t?.height??c?.clientHeight??0)||window.innerHeight||1,d=s.top-l,f=s.bottom-l,m=Math.max(s.height,f-d,0)>u-O,g=m?d<=u/2:d>=0&&f<=u-O,p=m?f<=.7*u:d<=V||f>=u-V,h=m?g&&!p:g,v=f<=0,y=f>0&&d<u;if(o)return v&&(le.current=!1),void $(Nt("entered",y));if(!se.current){if(se.current=!0,de)return void $(!1);if(v)return ye(),_("entered"),z.set(1),he(G.current),$(Nt("entered",!1)),void(le.current=!1);if(!0===i&&!m&&d>=0&&f<=u)return be(!0),void we()}if("waiting"===K.current){const e=oe.current;if(e&&(!0===e?.coldStartBypass&&!0===i&&!m&&d>=0&&f<=u||h&&!p))we();else{const t=e?.origin??"idle";ve(),_(t)}}else{const e=function(e,t,n,r){switch(e){case"idle":return t&&!n?"enter":null;case"entering":case"entered":return n&&!t&&r.hasExplicitExit?"exit":null;case"exiting":case"exited":return t&&!n&&r.replay?"enter":null;default:return null}}(K.current,h,p,{hasExplicitExit:X,replay:A});y&&!le.current&&(le.current=!0),"enter"!==e||de||ge.current||pe.current?"exit"===e&&!fe&&(!le.current&&v||Me()):(be(),we())}$(Nt(K.current,y))},[we,de,fe,be,ve,O,V,X,P,he,A,Me,e?.firstSceneEnterGateKnown,e?.firstSceneEnterActive,e?.firstSceneEnterReady,_,ye,x,z]);ie.current=Re;const Ee=(0,t.useCallback)(()=>{ge.current=!0,pe.current=!1,se.current=!0,ce.current=!0,Se()},[Se]),ke=(0,t.useCallback)(()=>{pe.current=!0,Me()},[Me]);(0,t.useEffect)(()=>{if(h&&!P)return h.current=Ee,()=>{h.current===Ee&&(h.current=null)}},[h,P,Ee]),(0,t.useEffect)(()=>{if(y&&!P)return y.current=ke,()=>{y.current===ke&&(y.current=null)}},[y,P,ke]),(0,t.useEffect)(()=>{const t=e?.registerAnimate,n=e?.unregisterAnimate;if(!t||!U&&!X)return;const r=t(u,{delay:E,duration:U?S:b,after:k,lane:P?"scroll":"visibility"});return G.current=r??null,ee.current=!1,()=>{ve(),G.current===r&&(G.current=null),r?.dispose?r.dispose():n?.(u)}},[e?.registerAnimate,e?.unregisterAnimate,ve,u,E,S,b,k,U,X,P]),(0,t.useEffect)(()=>{if(typeof document>"u"||x||B.current?.isConnected)return;const e=document.querySelector(`[data-cineview-animate-host="${u}"]`)??document.querySelector(`[data-cineview-animate-id="${u}"]`);e instanceof HTMLElement&&B.current!==e&&(B.current=e,H(e=>e+1))},[u,a,o,x]),(0,t.useEffect)(()=>{if(!(P&&W&&Y&&i&&(U||X)))return;const e=W(i,{animateId:u,delay:E,enterDuration:S,exitDuration:X?b:0,after:k,...void 0!==I||void 0!==C?{phase:{start:I,end:C}}:{}});return()=>{Y(i,u,e)}},[u,E,S,b,X,U,P,C,I,i,k,W,Y]);const Pe=(0,t.useCallback)(e=>{if(!U&&!X)return"entered"!==K.current&&_("entered"),void(1!==z.get()&&z.set(1));if(!n||!i)return void(0!==z.get()&&z.set(0));const t=e?.sequence.budgets[u];if(!e||!t)return void(0!==z.get()&&z.set(0));const r=xt(e.progressPx,0,e.totalBudgetPx),a=t.enterStartPx,o=Math.max(t.enterEndPx,t.enterStartPx+1),s="number"==typeof t.phaseStartPx?t.phaseStartPx:Ft(I,a,a,o),c=Math.max("number"==typeof t.phaseEndPx?t.phaseEndPx:Ft(C,o,a,o),s+1);if(r>=c&&!ee.current&&(ee.current=!0,he(G.current)),r<=s)return void(0!==z.get()&&z.set(0));if(!t.hasExit)return r>=c?void(1!==z.get()&&z.set(1)):void z.set(xt((r-s)/Math.max(c-s,1),0,1));const l=t.exitStartPx??c,d=t.exitEndPx??l+1;r<=c?z.set(xt((r-s)/Math.max(c-s,1),0,1)):r<=l?1!==z.get()&&z.set(1):r>=d?-1!==z.get()&&z.set(-1):z.set(-xt((r-l)/Math.max(d-l,1),0,1))},[u,U,X,C,I,he,_,z,i,n]);(0,t.useEffect)(()=>{if(!P)return;const e=()=>Pe(N.get());return e(),U||X?N.on("change",e):void 0},[Pe,U,X,P,N]),(0,t.useEffect)(()=>{P||Re()},[q,P,Re,e?.scrollProgress,e?.scrollTimelineState]),(0,t.useEffect)(()=>{if(P)return;const e=B.current;return e instanceof HTMLElement&&!(typeof window>"u")?function(e,t){const n=function(e){const t=jt.get(e);if(t)return t;const n=function(e){return typeof window<"u"&&e===window||typeof Window<"u"&&e instanceof Window}(e),r=n?e:e.ownerDocument?.defaultView??window,i=r.requestAnimationFrame?.bind(r)??(e=>r.setTimeout(()=>e(Date.now()),16)),a=r.cancelAnimationFrame?.bind(r)??(e=>r.clearTimeout(e)),o={subscribers:new Set,frame:null,requestFrame:i,cancelFrame:a,schedule:()=>{null===o.frame&&(o.frame=o.requestFrame(()=>{o.frame=null;const t=n?{top:0,height:e.innerHeight||1}:{top:e.getBoundingClientRect().top,height:e.clientHeight||r.innerHeight||1};[...o.subscribers].forEach(e=>e(t))}))},cleanup:()=>{e.removeEventListener("scroll",o.schedule),n||r.removeEventListener("resize",o.schedule),null!==o.frame&&(o.cancelFrame(o.frame),o.frame=null)}};return e.addEventListener("scroll",o.schedule,{passive:!0}),n||r.addEventListener("resize",o.schedule,{passive:!0}),jt.set(e,o),o}(e);return n.subscribers.add(t),n.schedule(),()=>{n.subscribers.delete(t),0===n.subscribers.size&&(n.cleanup(),jt.delete(e))}}(e.closest('[data-cineview-container="true"]')??window,Re):void 0},[q,P,Re]),(0,t.useEffect)(()=>ye,[ye]);const Ie=(0,t.useRef)(!1),Ce=(0,t.useCallback)(t=>{if(!(l&&P&&n&&i))return void(Ie.current&&(Ie.current=!1,$(!1)));const r=e?.runtimeState,a=void 0===r||"covered"!==r&&"inactive"!==r&&"parked"!==r&&"exiting"!==r;if(!U&&!X)return void(Ie.current!==a&&(Ie.current=a,$(a)));const o=t?.sequence.budgets[u];if(!t||!o||!a)return void(Ie.current&&(Ie.current=!1,$(!1)));const s=xt(t.progressPx,0,t.totalBudgetPx),c=o.enterStartPx,d=Math.max(o.enterEndPx,o.enterStartPx+1),f="number"==typeof o.phaseStartPx?o.phaseStartPx:Ft(I,c,c,d),m=Math.max("number"==typeof o.phaseEndPx?o.phaseEndPx:Ft(C,d,c,d),f+1),g=U?s>=m-.5:s>.5,p=!o.hasExit||null===o.exitStartPx||s<=o.exitStartPx+.5,h=g&&p;Ie.current!==h&&(Ie.current=h,$(h))},[u,U,X,l,P,C,I,e?.runtimeState,$,i,n]);return(0,t.useEffect)(()=>{if(P&&l)return Ce(N.get()),U||X?N.on("change",Ce):void 0;Ce(null)},[U,X,l,P,Ce,N]),{style:Ct(z,j,(e,t,n)=>function(e,t,n){const r=n>=0,i=r?e.enterAnimate:e.exitTarget;return wt(Mt(r?e.enterInitial:e.enterAnimate,t,Et(t,r?"initial":"animate")),i,t,Et(t,r?"animate":"exit"),r?n:Math.abs(n))}(t,n,e)).style,shouldRunInfinite:F,visualMotion:z,phaseMotion:Z}}({sceneContext:"scroll"===B?p:null,zoneRuntime:"scroll"===B?Le:null,zoneId:b,enterVariant:w,exitVariant:R,hasAuthoredEnterAnimation:!!e,hasAuthoredExitAnimation:!!i,hasInfiniteAnimation:!!k,componentId:g,duration:{enter:De,exit:Te},timeline:K,visibility:$.visibility,globalEnterMargin:h?.scrollEnterMargin,globalExitMargin:h?.scrollExitMargin,enterRef:we?d:void 0,exitRef:we?f:void 0,variantsPending:Se});(0,t.useEffect)(()=>{if("drag"!==B||0===I)return;const e=L.current;!e||e.generation!==I||(e.lease.complete(),L.current=null)},[B,I]);const ze=function({mode:e,isDragArrival:n,timelineLane:i,sceneContext:a,arrivalVisualMotion:o,arrivalPhaseMotion:s,scrollVisualMotion:c,scrollPhaseMotion:l,dragVisualState:u}){const d=(0,r.useMotionValue)(0),f=(0,r.useMotionValue)(0),m=(0,r.useMotionValue)("idle"),g=(0,r.useMotionValue)(dn);return(0,t.useEffect)(()=>{const t="scroll"===e||n?i:"drag",r=e=>{d.set(e.progress),f.set(e.signedProgress),m.set(e.phase),g.set(e)};if("scroll"===e||n){const e=n?o:c,i=n?s:l,a=()=>{const n=e.get();r({progress:Ht(n),signedProgress:n,phase:i.get(),source:"scroll"===t?"scroll":"visibility"})};a();const u=e.on("change",a),d=i.on("change",a);return()=>{u(),d()}}const p=e=>{if(!e)return void r(dn);const t=Math.max(0,Math.min(1,e.localProgress)),n="outgoing"===e.mode?("forward"===e.direction?1:-1)*t:t;r({progress:t,signedProgress:n,phase:qt(e.mode,t),source:fn(a,e)})};return p(u.get()),u.on("change",p)},[s,o,u,n,e,g,m,d,f,i,a,l,c]),(0,t.useMemo)(()=>({mode:e,lane:"scroll"===e||n?i:"drag",progress:d,signedProgress:f,phase:m,frame:g}),[n,e,g,m,d,f,i])}({mode:B,isDragArrival:Y,timelineLane:"scroll"===B||Y?K.lane:"drag",sceneContext:p,arrivalVisualMotion:Ve.visualMotion,arrivalPhaseMotion:Ve.phaseMotion,scrollVisualMotion:je.visualMotion,scrollPhaseMotion:je.phaseMotion,dragVisualState:Oe.visualState});(0,t.useEffect)(()=>{const e=Y?ge:k;if("drag"===B&&e){if(x||!(Y?Ve.shouldRunInfinite:Oe.shouldRunInfinite))return void N.stop();N.start({...e.animate,transition:{...e.animate.transition||{},repeat:1/0}})}},[Ve.shouldRunInfinite,N,Oe.shouldRunInfinite,k,Y,B,x,ge]),(0,t.useEffect)(()=>{if("scroll"===B&&k){if(x||!je.shouldRunInfinite)return void F.stop();F.start({...k.animate,transition:{...k.animate.transition||{},repeat:1/0}})}},[B,k,x,je.shouldRunInfinite,F]);const Ne=xe?m:void 0,Fe=xe?null:m,$e=(0,n.jsx)(ln,{value:ze,children:ke?Ee&&de?"scroll"===B?(0,n.jsx)(an,{container:Ee,variant:de,each:Pe,from:Ie,itemDurationMs:Ce?.itemDurationMs,effectiveDurationMs:Ce?.effectiveDurationMs,exitVariant:fe,exitItemDurationMs:Ae?.itemDurationMs,signedVisual:je.visualMotion}):Y?(0,n.jsx)(on,{container:Ee,variant:de,each:Pe,from:Ie,itemDurationMs:Ce?.itemDurationMs,effectiveDurationMs:Ce?.effectiveDurationMs,phaseMotion:Ve.phaseMotion,staticReveal:Ve.staticReveal}):(0,n.jsx)(sn,{container:Ee,variant:de,each:Pe,from:Ie,itemDurationMs:Ce?.itemDurationMs,effectiveDurationMs:Ce?.effectiveDurationMs,exitVariant:fe,exitItemDurationMs:Ae?.itemDurationMs,visualState:Oe.visualState}):null:Ne?"scroll"===B||Y?(0,n.jsx)(Xt,{signedVisual:Y?Ve.visualMotion:je.visualMotion,phaseMotion:Y?Ve.phaseMotion:je.phaseMotion,render:Ne}):(0,n.jsx)(Kt,{visualState:Oe.visualState,render:Ne}):Fe}),Be=ke?vn:je.style,qe=ke?vn:Y?Ve.style:Oe.style;return de||fe||ge||Se?"scroll"===B?ge?(0,n.jsx)("div",{"data-cineview-animate-host":g,children:(0,n.jsx)(r.motion.div,{style:Be,className:"cineview-animate","data-cineview-animate-id":g,children:(0,n.jsx)(r.motion.div,{animate:F,children:$e})})}):(0,n.jsx)("div",{"data-cineview-animate-host":g,children:(0,n.jsx)(r.motion.div,{style:Be,className:"cineview-animate","data-cineview-animate-id":g,children:$e})}):ge?(0,n.jsx)(r.motion.div,{style:qe,className:"cineview-animate","data-cineview-animate-id":g,children:(0,n.jsx)(r.motion.div,{animate:N,children:$e})}):(0,n.jsx)(r.motion.div,{style:qe,className:"cineview-animate","data-cineview-animate-id":g,children:$e}):(0,n.jsx)(ln,{value:ze,children:Ne?Ne(Ut):Fe})};xn.displayName="Animate";var Sn=(0,t.createContext)({lastX:0,lastY:0}),bn=(0,t.createContext)(null),wn=(0,t.forwardRef)(function({at:e,x:r,y:a,offsetX:o,offsetY:s,fixed:c=!1,children:l,style:u,className:d,...f},m){const g=v(),p=me(),h=(0,t.useContext)(Sn),y=(0,t.useContext)(bn),x=e?.x??r,S=e?.y??a,b=e?.offsetX??o,w=e?.offsetY??s,M=c,R=e?.anchor,E="center"===R||"center-x"===R,k="center"===R||"center-y"===R,P=M&&"scroll"===p?.mode&&!y,{finalLeft:I,finalTop:C,finalX:A,finalY:D}=(0,t.useMemo)(()=>{const e=g?.convert??(e=>e);if(void 0!==x||void 0!==S){const t=void 0!==x?x:0,n=void 0!==S?S:0;return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}if(void 0!==b||void 0!==w){const t=h.lastX+(void 0!==b?b:0),n=h.lastY+(void 0!==w?w:0);return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}return{finalLeft:0,finalTop:0,finalX:0,finalY:0}},[g,h,b,w,x,S]),{leftStyle:T,topStyle:L,centerTransform:O}=(0,t.useMemo)(()=>{const e=g?.convert??(e=>e),t=[];let n=I;if(E){const r=e(x??0);n=0===r?"50%":`calc(50% + ${r}px)`,t.push("translateX(-50%)")}let r=C;if(k){const n=e(S??0);r=0===n?"50%":`calc(50% + ${n}px)`,t.push("translateY(-50%)")}return{leftStyle:n,topStyle:r,centerTransform:t.length>0?t.join(" "):void 0}},[g,E,k,x,S,I,C]),V=(0,t.useMemo)(()=>({lastX:A,lastY:D}),[A,D]),j=(0,t.useMemo)(()=>{const e=[O,u?.transform].filter(Boolean).join(" ")||void 0;return{...u,position:P?"sticky":"absolute",left:T,top:L,pointerEvents:M?u?.pointerEvents??"auto":u?.pointerEvents,transform:e}},[P,M,T,L,O,u]),z=(0,n.jsx)(Sn.Provider,{value:V,children:(0,n.jsx)("div",{ref:m,style:j,className:d,...f,children:l})});return M&&y&&!P?(0,i.createPortal)(z,y):z});wn.displayName="Position";var Mn={opacity:1,x:0,y:0,scale:1,rotate:0};function Rn(e,t){return function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(e)?{...t,...e}:t}function En(e){return Math.max(0,Math.min(e,1))}var kn="time",Pn={time:10,percent:1},In={unit:kn,scale:Pn[kn]};function Cn(e,t,n){const r=Math.max(0,Number.isFinite(t)?t:0),i=Number.isFinite(n)?n:0,a="time"===e.unit?e.scale:r*e.scale/100;return Math.min(r,Math.max(0,i*a))}function An(e,t){return"drag"!==e?"auto":"y"===t?"pan-x pinch-zoom":"pan-y pinch-zoom"}function Dn({effectiveMode:e,isActive:t,globalScrollTimelineState:n,hasExitAnimation:r}){if("scroll"!==e||!n)return t?1:0;switch(n.phase){case"before":default:return 0;case"enter":return n.enterProgress;case"hold":return 1;case"exit":return r?1-n.exitProgress:1;case"after":return r?0:1}}function Tn({onVisibilityChange:e,sceneVisibilityCallback:t,sceneIndex:n,visible:r,progress:i}){e?.(r,i),t?.({sceneIndex:n,visible:r,progress:i})}function Ln({effectiveMode:e,effectiveDirection:t,globalScrollTimelineState:n,globalScrollViewportOffset:r,globalViewportWidth:i,globalViewportHeight:a}){if("scroll"!==e)return{visible:!1,isHorizontal:!1,hostOffset:0,hostSpan:0,clipWidth:0,clipHeight:0};const o=n?.rangeStart??0,s=n?.rangeEnd??o,c="x"===t,l=Math.max(s-o,0),u=Math.max(c?i:a,0),d=o-r,f=s-r,m=Math.max(Math.min(u,Math.max(l,1)),1),g=function(e,t,n){return Math.min(n,Math.max(0,e))}(r-o,0,Math.max(l-m,0));return{visible:l>0&&f>0&&d<u,isHorizontal:c,hostOffset:g,hostSpan:m,clipWidth:c?l:0,clipHeight:c?0:l}}function On({sceneIndex:e,metrics:r,setHostRef:i,frameStore:a,direction:o="y",viewportWidth:s=0,viewportHeight:c=0}){const l=(0,t.useRef)(null),u=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(!a||"number"!=typeof e)return;const t=()=>{const t=a.getKeySnapshot(e);if(!t)return;const n=Ln({effectiveMode:"scroll",effectiveDirection:o,globalScrollTimelineState:t.timelineState,globalScrollViewportOffset:t.visualViewportOffset,globalViewportWidth:s,globalViewportHeight:c}),r=l.current,i=u.current;!r||!i||(r.style.width=n.clipWidth>0?`${n.clipWidth}px`:"100%",r.style.height=n.clipHeight>0?`${n.clipHeight}px`:"100%",r.style.opacity=n.visible?"1":"0",r.style.visibility=n.visible?"visible":"hidden",i.style.top=n.isHorizontal?"0px":`${n.hostOffset}px`,i.style.left=n.isHorizontal?`${n.hostOffset}px`:"0px",i.style.width=n.isHorizontal&&n.hostSpan>0?`${n.hostSpan}px`:"100%",i.style.height=n.isHorizontal?"100%":n.hostSpan>0?`${n.hostSpan}px`:"100%")};return t(),a.subscribeKey(e,t)},[o,a,e,c,s]),(0,n.jsx)("div",{ref:l,"data-scene-fixed-layer":e,"data-scene-fixed-role":"clip",style:{position:"absolute",inset:0,width:r.clipWidth>0?r.clipWidth:"100%",height:r.clipHeight>0?r.clipHeight:"100%",overflow:"hidden",pointerEvents:"none",opacity:r.visible?1:0,visibility:r.visible?"visible":"hidden",zIndex:20},children:(0,n.jsx)("div",{ref:u,"data-scene-fixed-layer":e,"data-scene-fixed-role":"frame",style:{position:"absolute",top:r.isHorizontal?0:r.hostOffset,left:r.isHorizontal?r.hostOffset:0,width:r.isHorizontal&&r.hostSpan>0?r.hostSpan:"100%",height:r.isHorizontal?"100%":r.hostSpan>0?r.hostSpan:"100%",pointerEvents:"none"},children:(0,n.jsx)("div",{ref:i,"data-scene-fixed-layer":e,"data-scene-fixed-host":e,"data-scene-fixed-role":"host",style:{position:"relative",width:"100%",height:"100%",pointerEvents:"none"}})})})}function Vn(e,t){return e===t||"visibility"===e&&"scroll"===t}var jn=class{constructor(e){this.source=new Map(e),Object.freeze(this)}get size(){return this.source.size}get(e){return this.source.get(e)}has(e){return this.source.has(e)}forEach(e,t){this.source.forEach((n,r)=>e.call(t,n,r,this))}entries(){return this.source.entries()}keys(){return this.source.keys()}values(){return this.source.values()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"ImmutableMapView"}};function zn(e){return new jn(e)}function Nn(e){switch(e.type){case"missing-dependency":return`${e.type}:${e.animateId}:${e.after}`;case"circular-dependency":return`${e.type}:${e.animateId}:${e.cycle.join(">")}`;case"duplicate-id":return`${e.type}:${e.animateId}`;case"incompatible-lane":return`${e.type}:${e.animateId}:${e.after}:${e.followerLane}:${e.leaderLane}`}}function Fn(e,t){const n=Nn(t);e.some(e=>Nn(e)===n)||e.push(t)}function $n({baseDuration:e,registrations:t,declaredLanes:n=new Map,duplicateIds:r=[]}){const i=new Map,a=[],o=new Set,s=new Set;Array.from(r).forEach(e=>{Fn(a,{type:"duplicate-id",animateId:e})});const c=(e,r)=>{const l=i.get(e);if(void 0!==l)return l;const u=t.get(e);if(o.has(e)){const t=r.indexOf(e),n=function(e){const t=e.slice(0,-1);let n=0;for(let e=1;e<t.length;e+=1)t[e]<t[n]&&(n=e);const r=t.slice(n).concat(t.slice(0,n));return r.concat(r[0])}(r.slice(t).concat(e));return n.slice(0,-1).forEach(e=>s.add(e)),Fn(a,{type:"circular-dependency",animateId:n[0],cycle:n}),i.set(e,u.delay),u.delay}o.add(e);let d=u.delay;if(u.after){const i=t.get(u.after),o=n.get(u.after);if(i)if(void 0===u.lane||void 0===i.lane||Vn(u.lane,i.lane)){const t=c(u.after,r.concat(e));("visibility"!==u.lane||"scroll"!==i.lane)&&!s.has(e)&&(d+=t+i.duration)}else Fn(a,{type:"incompatible-lane",animateId:e,after:u.after,followerLane:u.lane,leaderLane:i.lane});else void 0===u.lane||void 0===o||Vn(u.lane,o)?Fn(a,{type:"missing-dependency",animateId:e,after:u.after}):Fn(a,{type:"incompatible-lane",animateId:e,after:u.after,followerLane:u.lane,leaderLane:o})}return o.delete(e),i.set(e,d),d};t.forEach((e,t)=>{c(t,[])});let l=Math.max(e,0);return t.forEach((e,t)=>{const n=i.get(t);l=Math.max(l,n+e.duration)}),{registrations:new Map(t),calculatedDelays:i,issues:a,timelineDuration:l}}function Bn(e){switch(e.type){case"missing-dependency":return`${e.type}:${e.animateId}:${e.after}`;case"circular-dependency":return`${e.type}:${e.animateId}:${e.cycle.join(">")}`;case"duplicate-id":return`${e.type}:${e.animateId}`;case"incompatible-lane":return`${e.type}:${e.animateId}:${e.after}:${e.followerLane}:${e.leaderLane}`}}function qn(e){let t;return e.forEach(e=>{t=e}),t}function Hn(e,t,n=Object.is){if(e.size!==t.size)return!1;for(const[r,i]of e){const e=t.get(r);if(void 0===e||!n(i,e))return!1}return!0}function Wn(){return typeof performance<"u"?performance.now():Date.now()}function Yn(e,t,n){const r=e.panInfo??{point:{x:0,y:0},delta:{x:0,y:0},offset:{x:0,y:0},velocity:{x:0,y:0}};return r.point.x=t,r.point.y=n,r.delta.x=t-e.lastX,r.delta.y=n-e.lastY,r.offset.x=t-e.startX,r.offset.y=n-e.startY,r.velocity.x=e.velocityX,r.velocity.y=e.velocityY,e.panInfo=r,r}var Un=t.default.createContext(null),Xn=new Set(["children","sceneId","layout","stack","transition","assets","drag","scroll","callbacks","runtimeMode","runtimeDirection","isActive","sceneIndex","totalScenes","currentSceneIndex","sceneRuntime","dragRuntime","scrollRuntime","onDragGestureEnd","onDragReset","onActivationComplete","onDragProgressChange","onRenderProgressChange","onDragTimelineProgressChange","onSharedElapsedMsChange","onDraggingChange","onSharedTimelineDurationChange","onDragRelease","onScrollProgressChange","onScrollDirectionChange","onScrollingChange","onScrollCommit","onScrollReset","onSceneChange","mode","slideDirection","slideDuration","sceneTransitionDuration","enterAnimation","exitAnimation","exitDuration","sceneWidth","sceneHeight","sceneAnchor","sceneZIndex","sceneOverflow","sceneStackMode","scrollSpeed","scrollControlled","scrollCommitThreshold","scrollReleaseDuration","scrollLockToSingleScene","scrollEnterLength","scrollHoldLength","scrollExitLength","onVisibilityChange","preloadImages"]),Kn=t.default.forwardRef(function(e,i){const{children:a,className:o,style:s,onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:d}=e,{effectiveMode:f,effectiveDirection:m,isActive:g,sceneIndex:p,totalScenes:h,currentSceneIndex:y,globalDirection:x,globalSharedTimelineDurationMs:S,globalActivationToken:b,globalActivationKind:w,globalFirstSceneEnterGateKnown:M,globalFirstSceneEnterActive:R,globalFirstSceneEnterReady:E,globalViewportWidth:k,globalViewportHeight:P,globalDragProgress:I,globalRenderProgress:C,globalDragTimelineProgress:A,globalIsDragging:D,globalDragRelease:T,globalScrollProgress:L,globalIsScrolling:O,globalScrollDirection:V,globalScrollTransitionSnapshot:j,globalScrollBackdropActive:z,globalScrollTimelineState:N,globalScrollViewportOffset:F,resolvedSceneWidth:$,resolvedSceneHeight:B,resolvedSceneAnchor:q,resolvedSceneOverflow:H,resolvedSceneZIndex:W,effectiveSceneStackMode:Y,resolvedSceneTransitionDuration:U,resolvedEnterAnimation:X,resolvedExitAnimation:K,sceneVisibilityCallback:Z,onVisibilityChange:_,onSceneChange:G,dragRuntime:J,onActivationComplete:Q,onDragProgressChange:ee,onRenderProgressChange:te,onDragTimelineProgressChange:ne,onDraggingChange:re,onSharedTimelineDurationChange:ae,onDragRelease:se,onDragGestureEnd:ce,onDragReset:le,slideDuration:ue,compatFields:de}=function(e){const t=e.sceneRuntime?.mode??e.runtimeMode??e.mode??"drag";return{effectiveMode:t,effectiveDirection:e.sceneRuntime?.direction??e.runtimeDirection??e.slideDirection??"y",isActive:e.sceneRuntime?.isActive??e.isActive??!1,sceneIndex:e.sceneRuntime?.sceneIndex??e.sceneIndex??0,totalScenes:e.sceneRuntime?.totalScenes??e.totalScenes??1,currentSceneIndex:e.sceneRuntime?.currentSceneIndex??e.currentSceneIndex??0,globalDirection:e.sceneRuntime?.transitionDirection??null,globalIsSceneAnimating:e.sceneRuntime?.isSceneAnimating??!1,globalSharedTimelineDurationMs:e.sceneRuntime?.sharedTimelineDurationMs??0,globalActivationToken:e.sceneRuntime?.activationToken??0,globalActivationKind:e.sceneRuntime?.activationKind??null,globalFirstSceneEnterGateKnown:e.sceneRuntime?.firstSceneEnterGateKnown??!0,globalFirstSceneEnterActive:e.sceneRuntime?.firstSceneEnterActive??!1,globalFirstSceneEnterReady:e.sceneRuntime?.firstSceneEnterReady??!1,globalViewportWidth:e.sceneRuntime?.viewportWidth??0,globalViewportHeight:e.sceneRuntime?.viewportHeight??0,globalDragProgress:e.dragRuntime?.progress??0,globalRenderProgress:e.dragRuntime?.renderProgress??0,globalDragTimelineProgress:e.dragRuntime?.timelineProgress??0,globalIsDragging:e.dragRuntime?.isDragging??!1,globalDragRelease:e.dragRuntime?.release??null,globalScrollProgress:e.scrollRuntime?.progress??0,globalIsScrolling:e.scrollRuntime?.isScrolling??!1,globalScrollDirection:e.scrollRuntime?.direction??null,globalScrollTransitionSnapshot:e.scrollRuntime?.transitionSnapshot??null,globalScrollBackdropActive:e.scrollRuntime?.backdropActive??!1,globalScrollTimelineState:e.scrollRuntime?.timelineState??null,globalScrollActiveSceneIndex:e.scrollRuntime?.activeSceneIndex??0,globalScrollViewportOffset:e.scrollRuntime?.viewportOffset??0,resolvedSceneWidth:e.layout?.width??e.sceneWidth??"100vw",resolvedSceneHeight:e.layout?.height??e.sceneHeight??("scroll"===t?"auto":"100vh"),resolvedSceneAnchor:e.layout?.anchor??e.sceneAnchor??"top-left",resolvedSceneOverflow:e.layout?.overflow??e.sceneOverflow??"hidden",resolvedSceneZIndex:e.layout?.zIndex??e.sceneZIndex,effectiveSceneStackMode:e.layout?.overlap??e.sceneStackMode??("scroll"===t?"cover":"replace"),resolvedSceneTransitionDuration:e.sceneTransitionDuration??e.transition?.exitDuration??e.exitDuration??800,resolvedEnterAnimation:e.transition?.enterAnimation??e.enterAnimation,resolvedExitAnimation:e.transition?.exitAnimation??e.exitAnimation,sceneVisibilityCallback:e.callbacks?.onVisibilityChange,onVisibilityChange:e.onVisibilityChange,onSceneChange:e.onSceneChange,scrollCommitThreshold:e.scrollCommitThreshold??.42,scrollReleaseDuration:e.scrollReleaseDuration??220,scrollLockToSingleScene:e.scrollLockToSingleScene??!0,scrollRuntime:e.scrollRuntime,dragRuntime:e.dragRuntime,onActivationComplete:e.onActivationComplete,onDragProgressChange:e.onDragProgressChange,onRenderProgressChange:e.onRenderProgressChange,onDragTimelineProgressChange:e.onDragTimelineProgressChange,onSharedElapsedMsChange:e.onSharedElapsedMsChange,onDraggingChange:e.onDraggingChange,onSharedTimelineDurationChange:e.onSharedTimelineDurationChange,onDragRelease:e.onDragRelease,onDragGestureEnd:e.onDragGestureEnd,onDragReset:e.onDragReset,onScrollProgressChange:e.onScrollProgressChange,onScrollDirectionChange:e.onScrollDirectionChange,onScrollingChange:e.onScrollingChange,onScrollCommit:e.onScrollCommit,onScrollReset:e.onScrollReset,slideDuration:e.slideDuration??800,compatFields:[e.mode,e.slideDirection,e.scrollSpeed,e.scrollControlled,e.scrollCommitThreshold,e.scrollReleaseDuration,e.scrollLockToSingleScene,e.runtimeMode,e.runtimeDirection,e.isActive,e.sceneIndex,e.totalScenes,e.currentSceneIndex,e.onActivationComplete,e.onDragProgressChange,e.onRenderProgressChange,e.onDragTimelineProgressChange,e.onSharedElapsedMsChange,e.onDraggingChange,e.onSharedTimelineDurationChange,e.onDragGestureEnd,e.onDragReset,e.onScrollProgressChange,e.onScrollDirectionChange,e.onScrollingChange,e.onScrollCommit,e.onScrollReset,e.scrollRuntime,e.dragRuntime,e.sceneRuntime]}}(e),fe=e.scrollRuntime?.frameStore,ge=e.scrollRuntime?.sceneIndex??p,pe=v(),he=me(),ve=he?.reportError,ye=(0,r.useAnimation)(),[xe,Se]=(0,t.useState)(null),[be,we]=(0,t.useState)(null),Me=(0,t.useRef)(0);(0,t.useRef)(null);const Re=pn(X),Ee=pn(K),ke=!!(J||e.onDragProgressChange||e.onRenderProgressChange||e.onDragTimelineProgressChange||e.onDraggingChange||e.onSharedTimelineDurationChange||e.onDragGestureEnd||e.onDragReset),[Pe,Ie]=(0,t.useState)(I),[Ce,Ae]=(0,t.useState)(C),[De,Te]=(0,t.useState)(A),[Le,Oe]=(0,t.useState)(D),[Ve,je]=(0,t.useState)(S),[ze,Ne]=(0,t.useState)(T),Fe=(0,t.useRef)(0),$e=(0,t.useCallback)(e=>{null!==e?(Fe.current+=1,Ne({...e,token:Fe.current})):Ne(null)},[]),Be=ke?I:Pe,qe=ke?C:Ce,He=ke?A:De,We=ke?D:Le,Ye=ke?S:Ve,Ue=ke?T:ze,Xe=We,Ke=(0,r.useMotionValue)(Be),Ze=J?.renderProgressMotion??Ke,_e=(0,r.useMotionValue)(He),Ge=J?.timelineProgressMotion??_e,Je=(0,r.useMotionValue)(0),[Qe,et]=(0,t.useState)("initial"),tt=p-y,[nt,rt]=(0,t.useState)(!1),it=(0,t.useRef)(Symbol(`scene:${p}`)),at=(0,t.useRef)(null),ot=(0,t.useRef)(J?.onPreparedInvalidated);ot.current=J?.onPreparedInvalidated;const[st,ct]=(0,t.useState)(null),lt=(0,t.useMemo)(()=>J?.dragMappingConfig??function(e,t,n){const r=function(e){return void 0!==e?.unit||void 0!==e?.scale}(t)?t:void 0,i=r?.unit;if(void 0!==i&&!function(e){return"time"===e||"percent"===e}(i))return n?.({field:"unit",value:i}),{unit:kn,scale:Pn.time};const a=i??"time",o=r?.scale;return void 0!==o&&("number"!=typeof o||!Number.isFinite(o)||o<0)?(n?.({field:"scale",value:o}),{unit:a,scale:Pn[a]}):{unit:a,scale:o??Pn[a]}}(0,e.drag),[J?.dragMappingConfig,e.drag]),ut=(0,t.useCallback)((t,n,r)=>{if("drag"!==f)return;const i=function(e){return Object.freeze({...e,mapping:Object.freeze({...e.mapping}),enterVariantsByAnimateId:zn(e.enterVariantsByAnimateId)})}({sceneIndex:p,instanceId:it.current,revision:n,enabled:!1!==e.drag?.enabled,mapping:lt,registrySnapshot:t,enterVariantsByAnimateId:r});at.current=i,ct(i),J?.onPrepared?.(i)},[J,f,lt,e.drag?.enabled,p]),{timelineDuration:dt,beginPreparation:ft,registerAnimate:mt,declareAnimateLane:gt,unregisterAnimate:ht,getCalculatedDelay:yt,getTimelineDuration:xt}=function({sceneIndex:e,baseDuration:n,reportError:r,onStableSnapshot:i}){const a=(0,t.useRef)(new Map),o=(0,t.useRef)(new Map),s=(0,t.useRef)(new Map),c=(0,t.useRef)(new Map),l=(0,t.useRef)(new Set),u=(0,t.useRef)($n({baseDuration:n,registrations:s.current})),d=(0,t.useRef)(new Set),f=(0,t.useRef)(null),m=(0,t.useRef)(new Map),g=(0,t.useRef)(0),p=(0,t.useRef)(0),h=(0,t.useRef)(0),v=(0,t.useRef)(null),y=(0,t.useRef)(null),x=(0,t.useRef)(!0),S=(0,t.useRef)(r);S.current=r;const b=(0,t.useRef)(i);b.current=i;const w=(0,t.useRef)(n),[M,R]=(0,t.useState)(n),[E,k]=(0,t.useState)(!1),P=(0,t.useCallback)(()=>{x.current&&k(!1)},[]),I=(0,t.useCallback)(t=>{t.forEach(t=>{const n=Bn(t);if(d.current.has(n))return;let r,i;d.current.add(n),"missing-dependency"===t.type?(r="INVALID_ANIMATION",i=`Animate "${t.animateId}" references non-existent component "${t.after}" via after in Scene ${e}.`):"circular-dependency"===t.type?(r="CIRCULAR_DEPENDENCY",i=`Animate after chain contains a cycle in Scene ${e}: ${t.cycle.join(" -> ")}.`):"duplicate-id"===t.type?(r="INVALID_COMPONENT_HIERARCHY",i=`More than one Animate component registered animateId "${t.animateId}" in Scene ${e}.`):(r="INVALID_ANIMATION",i=`Animate "${t.animateId}" uses ${t.followerLane} after "${t.after}" driven by ${t.leaderLane} in Scene ${e}; this dependency direction is incompatible.`),S.current?.({code:r,message:i,context:{sceneIndex:e}})})},[e]),C=(0,t.useCallback)(()=>{s.current.clear(),c.current.clear(),l.current.clear(),a.current.forEach((e,t)=>{const n=qn(e);n&&s.current.set(t,n.info),e.size>1&&l.current.add(t)}),o.current.forEach((e,t)=>{let n;e.forEach(e=>{e.disposed||(n=e)}),n&&c.current.set(t,n.lane)})},[]),A=(0,t.useCallback)(()=>{C();const e=$n({baseDuration:n,registrations:s.current,declaredLanes:c.current,duplicateIds:l.current});return u.current=e,w.current=e.timelineDuration,x.current&&R(t=>t===e.timelineDuration?t:e.timelineDuration),e},[n,C]),D=(0,t.useCallback)(e=>u.current.issues.some(t=>"circular-dependency"===t.type&&t.cycle.includes(e)),[]),T=(0,t.useCallback)((e,t)=>{const{follower:n,leaderId:r}=e,i=a.current.get(r),o=c.current.get(r);if(!i||0===i.size)return t&&void 0!==o&&void 0!==n.info.lane&&!Vn(n.info.lane,o)?(e.sawLeader=!0,{kind:"invalid",leaderId:r,reason:"incompatible-lane"}):t?{kind:"invalid",leaderId:r,reason:e.sawLeader?"leader-unregistered":"missing"}:{kind:"pending",leaderId:r};e.sawLeader=!0;const s=qn(i);return t&&D(n.id)?{kind:"invalid",leaderId:r,reason:"cycle"}:t&&i.size>1?{kind:"invalid",leaderId:r,reason:"duplicate"}:t&&void 0!==n.info.lane&&void 0!==s.info.lane&&!Vn(n.info.lane,s.info.lane)?{kind:"invalid",leaderId:r,reason:"incompatible-lane"}:s.enterCompleted?{kind:"satisfied",source:"completed",leaderId:r,generation:s.generation}:{kind:"pending",leaderId:r,generation:s.generation}},[D]),L=(0,t.useCallback)((e,t)=>{if(e.terminal)return;const n=function(e){return"invalid"===e.kind?`${e.kind}:${e.leaderId}:${e.reason}`:`${e.kind}:${e.leaderId??""}:${e.generation??""}:${"satisfied"===e.kind?e.source:""}`}(t);e.lastSignature!==n&&(e.lastSignature=n,e.listener(t),"pending"!==t.kind&&(e.terminal=!0))},[]),O=(0,t.useCallback)(e=>{m.current.forEach(t=>{[...t].forEach(n=>{n.follower.disposed||n.terminal?t.delete(n):(L(n,T(n,e)),n.terminal&&t.delete(n))})}),m.current.forEach((e,t)=>{0===e.size&&m.current.delete(t)})},[L,T]),V=(0,t.useCallback)(e=>{if(0!==p.current||!x.current)return;const t=new Map;a.current.forEach((e,n)=>{const r=qn(e);r?.enterVariant&&t.set(n,r.enterVariant)});const n=v.current,r=y.current,i=null!==n&&null!==r&&function(e,t){return e.timelineDuration===t.timelineDuration&&Hn(e.registrations,t.registrations,(e,t)=>e.delay===t.delay&&e.duration===t.duration&&e.after===t.after&&e.lane===t.lane)&&Hn(e.calculatedDelays,t.calculatedDelays)&&e.issues.length===t.issues.length&&e.issues.every((e,n)=>Bn(e)===Bn(t.issues[n]))}(n,e)&&Hn(r,t);k(!0),!i&&(h.current+=1,v.current=e,y.current=new Map(t),b.current?.(function(e){const t=[];return e.registrations.forEach((e,n)=>{t.push([n,Object.freeze({...e})])}),Object.freeze({registrations:zn(t),calculatedDelays:zn(e.calculatedDelays),issues:Object.freeze([...e.issues]),timelineDuration:e.timelineDuration})}(e),h.current,t))},[]),j=(0,t.useCallback)(()=>{if(0!==p.current||!x.current)return;null!==f.current&&(clearTimeout(f.current),f.current=null);const e=A();I(e.issues),O(!0),V(e)},[V,A,O,I]),z=(0,t.useCallback)(()=>{P(),null!==f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,j()},0)},[j,P]),N=(0,t.useCallback)(()=>{p.current+=1,P();let e=!1;const t=()=>!e&&(e=!0,p.current=Math.max(0,p.current-1),0===p.current);return{complete:()=>{t()&&j()},cancel:()=>{t()&&z()}}},[j,P,z]),F=(0,t.useCallback)(e=>{m.current.forEach((t,n)=>{t.forEach(n=>{n.follower.token===e.token&&t.delete(n)}),0===t.size&&m.current.delete(n)})},[]),$=(0,t.useCallback)(e=>{if(e.disposed)return;e.disposed=!0,F(e);const t=a.current.get(e.id);t?.delete(e.token),0===t?.size&&a.current.delete(e.id),A(),z()},[A,F,z]),B=(0,t.useCallback)((e,t)=>{const n={token:Symbol(e),id:e,generation:++g.current,info:t,enterVariant:null,enterCompleted:!1,disposed:!1};let r=a.current.get(e);return r||(r=new Map,a.current.set(e,r)),r.set(n.token,n),A(),z(),s.current.size>100&&s.current.size,{animateId:e,generation:n.generation,getCalculatedDelay:()=>u.current.calculatedDelays.get(e)??n.info.delay,setEnterVariant:t=>{n.disposed||a.current.get(e)?.has(n.token)&&(n.enterVariant=t,z())},observeAfter:e=>{if(!n.info.after)return e({kind:"satisfied",source:"none"}),()=>{};const t={follower:n,listener:e,leaderId:n.info.after,sawLeader:!1,lastSignature:null,terminal:!1};let r=m.current.get(t.leaderId);return r||(r=new Set,m.current.set(t.leaderId,r)),r.add(t),L(t,T(t,0===p.current&&null===f.current)),()=>{t.terminal=!0,r?.delete(t),0===r?.size&&m.current.delete(t.leaderId)}},publishEnterCompleted:()=>{n.disposed||n.enterCompleted||a.current.get(e)?.has(n.token)&&(n.enterCompleted=!0,O(!1))},dispose:()=>$(n)}},[$,L,T,A,O,e,z]),q=(0,t.useCallback)((e,t)=>{const n={token:Symbol(e),id:e,lane:t,disposed:!1};let r=o.current.get(e);return r||(r=new Map,o.current.set(e,r)),r.set(n.token,n),A(),z(),{dispose:()=>{if(n.disposed)return;n.disposed=!0;const t=o.current.get(e);t?.delete(n.token),0===t?.size&&o.current.delete(e),A(),z()}}},[A,z]),H=(0,t.useCallback)(e=>{const t=a.current.get(e),n=t?qn(t):void 0;n&&$(n)},[$]),W=(0,t.useCallback)(e=>u.current.calculatedDelays.get(e)??s.current.get(e)?.delay??0,[]),Y=(0,t.useCallback)(()=>w.current,[]);return(0,t.useEffect)(()=>{z()},[n,z]),(0,t.useEffect)(()=>{x.current=!0;const e=a.current,t=o.current,n=s.current,r=c.current,i=l.current,u=d.current,g=m.current;return()=>{x.current=!1,null!==f.current&&(clearTimeout(f.current),f.current=null),p.current=0,e.clear(),t.clear(),n.clear(),r.clear(),i.clear(),u.clear(),g.clear()}},[]),{timelineDuration:M,isStable:E,beginPreparation:N,registerAnimate:B,declareAnimateLane:q,unregisterAnimate:H,getCalculatedDelay:W,getTimelineDuration:Y}}({sceneIndex:p,baseDuration:"drag"===f?0:U,reportError:he?.reportError,onStableSnapshot:ut}),St=(0,t.useRef)(!1);(0,t.useEffect)(()=>{St.current||t.default.Children.count(a)>0||(St.current=!0,ve?.({code:"EMPTY_SCENES",message:`Scene ${p} has no children; it renders an empty full-screen layer.`,context:{scope:"scene",sceneIndex:p}}))},[a,ve,p]),(0,t.useEffect)(()=>()=>{const e=at.current;e&&ot.current?.({sceneIndex:e.sceneIndex,instanceId:e.instanceId,revision:e.revision})},[]);const bt=(0,t.useRef)(null),wt=(0,t.useCallback)(e=>{bt.current=e,"function"==typeof i?i(e):i&&(i.current=e)},[i]),[Mt,Rt]=(0,t.useState)(null),Et=(0,t.useCallback)(e=>{Rt(t=>t===e?t:e)},[]),kt=function({sceneId:e,sceneIndex:n,mode:r,scroll:i,elementRef:a}){const o=(0,t.useContext)(ie),s=(0,t.useId)(),c=i?.zoneId??e??`scene-zone-${s}`,l=o?.registerZone,u=o?.unregisterZone,d=o?.setZoneElement,f=!!i;return(0,t.useEffect)(()=>{if("scroll"===r&&f&&l&&u)return l(c,{sceneIndex:n}),()=>{u(c,n)}},[r,f,l,u,c,n]),(0,t.useEffect)(()=>{if("scroll"===r&&f&&d)return d(c,n,a.current),()=>{d(c,n,null)}},[a,r,f,n,d,c]),"scroll"===r&&i?c:null}({sceneId:e.sceneId,sceneIndex:p,mode:f,scroll:e.scroll,elementRef:bt});(0,t.useEffect)(()=>{J?.renderProgressMotion||Ke.set(Be)},[Be,J?.renderProgressMotion,Ke]),(0,t.useEffect)(()=>{J?.timelineProgressMotion||_e.set(He)},[He,J?.timelineProgressMotion,_e]),(0,t.useEffect)(()=>{ke&&(Ie(I),Ae(C),Te(A),Oe(D),je(S),Ne(T))},[ke,I,C,A,D,S,T]);const Pt=(0,t.useCallback)(e=>"drag"!==f?0:!ke&&h<=1?Math.max(-1,Math.min(1,e)):0===y&&e<0||y===h-1&&e>0?0:Math.max(-1,Math.min(1,e)),[f,ke,y,h]);(0,t.useEffect)(()=>{},[pe,p]),(0,t.useEffect)(()=>{"scroll"!==f&&Rt(null)},[f]),(0,t.useEffect)(()=>{const e=++Me.current,t=()=>Me.current===e,n=e=>{t()&&ve?.(e)};return Se(null),we(null),"scroll"!==f?((Re||Ee)&&[Re?"enterAnimation":null,Ee?"exitAnimation":null].filter(Boolean).join(","),()=>{t()&&(Me.current+=1)}):Re||Ee?((async()=>{const[e,r]=await Promise.all([pt(Re,`Scene ${p}`,"enter",n),pt(Ee,`Scene ${p}`,"exit",n)]);t()&&(Se(e??null),we(r??null))})(),()=>{t()&&(Me.current+=1)}):()=>{t()&&(Me.current+=1)}},[f,ve,p,Re,Ee]);const It=function({slideMode:e,sceneState:n,isActive:r,sceneOffset:i,globalScrollProgress:a,globalScrollDirection:o,globalIsScrolling:s,globalScrollBackdropActive:c,hasExitAnimation:l,scrollTimelineState:u}){return(0,t.useMemo)(()=>"drag"===e?"exiting"===n?"exiting":"entering"===n?"entering":r?"active":0===i?"inactive":"parked":"scroll"===e?u?"enter"===u.phase?"entering":"exit"===u.phase?l?"exiting":"covered":"hold"===u.phase?r?"active":"covered":"after"===u.phase?l?"parked":"covered":r?"active":c?"covered":0===i?"inactive":"parked":r&&s&&a>.001?l?"exiting":"covered":c?"covered":("forward"===o&&1===i||"backward"===o&&-1===i)&&a>.001?"entering":r?"active":0===i?"inactive":"parked":r?"active":"inactive",[e,n,r,i,a,o,s,c,l,u])}({slideMode:f,sceneState:Qe,isActive:g,sceneOffset:tt,globalScrollProgress:L,globalScrollDirection:V,globalIsScrolling:O,globalScrollBackdropActive:z,hasExitAnimation:!!K,scrollTimelineState:N}),Ct=(0,t.useMemo)(()=>Dn({effectiveMode:f,isActive:g,globalScrollTimelineState:N,hasExitAnimation:!!K}),[f,g,N,K]),At=Ct>.001,Dt=(0,t.useRef)(_),Tt=(0,t.useRef)(Z);(0,t.useEffect)(()=>{Dt.current=_,Tt.current=Z},[_,Z]),(0,t.useEffect)(()=>{"scroll"===f&&fe||Tn({onVisibilityChange:Dt.current,sceneVisibilityCallback:Tt.current,sceneIndex:p,visible:At,progress:Ct})},[f,p,At,Ct,fe]),(0,t.useEffect)(()=>{if("scroll"!==f||!fe)return;const e=()=>{const e=fe.getKeySnapshot(ge)??null,t=Dn({effectiveMode:f,isActive:e?.isCurrent??g,globalScrollTimelineState:e?.timelineState??null,hasExitAnimation:!!K});Tn({onVisibilityChange:Dt.current,sceneVisibilityCallback:Tt.current,sceneIndex:p,visible:t>.001,progress:t})};return e(),fe.subscribeKey(ge,e)},[f,fe,g,K,p,Z,ge]),(0,t.useEffect)(()=>{"drag"!==f||!g||((J?.onSharedTimelineDurationChange??ae)?.(xt()),ke||je(xt()))},[f,g,xt,dt,J,ae,Qe,ke]);const Lt="drag"===f?E&&null!==st:E,Ot=(0,t.useMemo)(()=>({mode:f,isActive:g,isDragging:!1,dragProgressMotion:Ze,runtimeState:It,sceneState:Qe,sceneOffset:tt,activationToken:b,activationKind:w,firstSceneEnterGateKnown:0===p?M:void 0,firstSceneEnterActive:0===p?R:void 0,firstSceneEnterReady:0===p?Lt:void 0,sceneTransitionDuration:U,getTimelineDuration:xt,beginPreparation:ft,registerAnimate:mt,declareAnimateLane:gt,unregisterAnimate:ht,getCalculatedDelay:yt,enterDuration:ue}),[ft,gt,f,Lt,yt,w,b,R,M,xt,g,Ze,mt,U,p,tt,Qe,ue,ht,It]),Vt=(0,t.useMemo)(()=>({...Ot,isDragging:Xe,dragProgressMotion:Ze,renderProgressMotion:Ze,dragTransaction:J?.transaction??null,preparedSnapshot:st,dragTimelineProgress:He,sharedElapsedMotion:Je,renderProgress:qe,dragRelease:Ue,sharedTimelineDurationMs:Ye,firstSceneEnterActive:R}),[Ue,He,qe,Ye,Ze,J?.transaction,Je,R,Xe,st,Ot]),jt="drag"===f?Vt:Ot;!function({slideMode:e,isActive:n,sceneOffset:r,sceneStackMode:i,controls:a,enterVariant:o,exitVariant:s,globalIsScrolling:c,globalScrollProgress:l,globalScrollDirection:u,globalScrollTransitionSnapshot:d,globalScrollBackdropActive:f,globalScrollTimelineState:m,scrollFrameStore:g,scrollFrameSceneIndex:p,setSceneState:h}){const v=(0,t.useRef)(null);v.current={slideMode:e,isActive:n,sceneOffset:r,sceneStackMode:i,controls:a,enterVariant:o,exitVariant:s,globalIsScrolling:c,globalScrollProgress:l,globalScrollDirection:u,globalScrollTransitionSnapshot:d,globalScrollBackdropActive:f,globalScrollTimelineState:m,setSceneState:h};const y=(0,t.useRef)(null),x=(0,t.useRef)(null),S=(0,t.useCallback)(e=>{const t=v.current;if(!t||"scroll"!==t.slideMode)return;const n=null!==e,r=n?e.timelineState:t.globalScrollTimelineState,i=n?e.isCurrent:t.isActive,a=n?e.isScrolling:t.globalIsScrolling,o=n?e.isBackdropActive:t.globalScrollBackdropActive,s=n?e.scrollDirection:t.globalScrollDirection,c=n?e.progress:t.globalScrollProgress,l=t.globalScrollTransitionSnapshot?.direction??s,u="forward"===l&&1===t.sceneOffset||"backward"===l&&-1===t.sceneOffset,d=i&&a&&c>.001,f=!i&&"cover"===t.sceneStackMode&&o&&(0===t.sceneOffset||-1===t.sceneOffset),m=Rn(t.enterVariant?.animate,Mn),g=Rn(t.enterVariant?.initial,m),p=Rn(t.exitVariant?.exit,m),h=e=>{y.current!==e&&(y.current=e,t.setSceneState(e))},S=(e,n,r)=>{const i=x.current;i&&i.kind===e&&i.progress===n&&i.enterVariant===t.enterVariant&&i.exitVariant===t.exitVariant&&i.controls===t.controls||(x.current={kind:e,progress:n,enterVariant:t.enterVariant,exitVariant:t.exitVariant,controls:t.controls},t.controls.set(r))};if(r){if("before"===r.phase)return h("initial"),void S("before",0,g);if("enter"===r.phase){const e=En(r.enterProgress);return h("entering"),void S("enter",e,vt(g,m,e))}if("hold"===r.phase)return h("active"),void S("hold",1,m);if("exit"===r.phase){const e=En(r.exitProgress);return h(t.exitVariant?.exit?"exiting":"active"),void S("exit",e,t.exitVariant?.exit?vt(m,p,e):m)}h(f?t.exitVariant?.exit?"exiting":"active":t.exitVariant?.exit?"exiting":i?"active":"initial"),S("after",1,t.exitVariant?.exit?p:m)}else if(u){h("entering");const e=En(c);S("fallback-enter",e,vt(g,m,e))}else if(d||f){h(t.exitVariant?.exit?"exiting":"active");const e=En(c);S("fallback-exit",e,t.exitVariant?.exit?vt(m,p,e):m)}else h(i?"active":"initial"),S(i?"fallback-active":"fallback-initial",i?1:0,i?m:g)},[]);(0,t.useEffect)(()=>{if("scroll"===e){if(g&&"number"==typeof p){const e=()=>{S(g.getKeySnapshot(p)??null)};return e(),g.subscribeKey(p,e)}S(null)}},[S,o,s,f,u,l,m,d,c,n,r,i,p,g,e])}({slideMode:f,isActive:g,sceneOffset:tt,sceneStackMode:Y,controls:ye,enterVariant:xe,exitVariant:be,globalIsScrolling:O,globalScrollProgress:L,globalScrollDirection:V,globalScrollTransitionSnapshot:j,globalScrollBackdropActive:z,globalScrollTimelineState:N,scrollFrameStore:fe,scrollFrameSceneIndex:ge,setSceneState:et});const zt=function({slideMode:e,isActive:n,sceneIndex:i,sceneOffset:a,globalDirection:o,globalIsDragging:s,candidateSuspended:c=!1,globalRenderProgress:l,globalDragTimelineProgress:u,renderProgressMotion:d,dragTimelineProgressMotion:f,dragRelease:m,firstSceneEnterReady:g,elementElapsedMotion:p,getTimelineDuration:h,timelineDurationState:v,dragTransaction:y,preparedSnapshot:x,requirePreparedSnapshot:S=!1,dragMappingConfig:b,takeoverSnapshot:w,onElementContinuationChange:M,onSettleComplete:R,onColdStartComplete:E}){const k=(0,t.useRef)(null),P=(0,t.useRef)(null),I=(0,t.useRef)(0),C=(0,t.useRef)(null),A=(0,t.useRef)(null),D=(0,t.useRef)(!1),T=(0,t.useRef)(0),L=(0,t.useRef)(!1),O=(0,t.useRef)(h);O.current=h;const V=(0,t.useRef)(y);V.current=y;const j=(0,t.useRef)(x);j.current=x;const z=(0,t.useRef)(S);z.current=S;const N=(0,t.useRef)(null),F=()=>V.current||(z.current?null:j.current??null),$=e=>e?.registrySnapshot.timelineDuration??O.current(),B=e=>e?.mapping??J.current,q=(0,t.useRef)(R);q.current=R;const H=(0,t.useRef)(E);H.current=E;const W=(0,t.useRef)(M);W.current=M;const Y=(0,t.useRef)(!1),U=e=>{Y.current!==e&&(Y.current=e,W.current?.(e))},X=(0,t.useRef)(p);X.current=p;const K=(0,t.useRef)(null),Z=(0,t.useRef)(null),_=(0,t.useRef)(null),G=(0,t.useRef)(null),J=(0,t.useRef)(b??In);J.current=b??In;const Q=(0,t.useRef)(f?.get()??u);return Q.current=f?.get()??u,(0,t.useEffect)(()=>{if("drag"===e&&c&&k.current){if(Y.current){K.current=Math.max(0,X.current.get());const e=w?.current,t=e?.sceneIndices.includes(i)??!1;_.current=t?e.token:null,Z.current=t?e.baseRatio:null,G.current=null}I.current+=1,k.current.stop(),k.current=null,P.current=null}},[c,i,e,w]),(0,t.useEffect)(()=>{if(c||s)return;const e=_.current,t=w?.current;null!==e&&t?.token===e&&null!==t.baseRatio||(K.current=null,Z.current=null,_.current=null,G.current=null)},[c,s,w]),(0,t.useEffect)(()=>{if("drag"!==e||!s)return;k.current&&(k.current.stop(),k.current=null,P.current=null),U(!1),D.current=!0,L.current=!1;const t=e=>{Q.current=e;const t=d?.get()??l,n=t>1e-4?"forward":t<-1e-4?"backward":o;if(!("forward"===n&&1===a||"backward"===n&&-1===a))return;const r=F();if(z.current&&!r)return;const s=$(r),c=Math.max(0,Math.min(e,1)),u=B(r),f=K.current;if(null!==f){const e=w?.current,n=_.current;if(null!==n&&e?.token===n&&e.sceneIndices.includes(i)&&null!==e.baseRatio){const r=e.baseRatio;if(Z.current=r,G.current!==n&&Math.abs(Math.abs(t)-r)<=1e-6&&Math.abs(c-e.staleRatio)<=1e-6&&Math.abs(c-r)>1e-6)return void(G.current=n);const i=Cn(u,s,100*r),a=Cn(u,s,100*c);return void X.current.set(Math.max(0,Math.min(s,f+a-i)))}const r=Z.current;if(null===r)return void(Z.current=c);const a=Cn(u,s,100*r),o=Cn(u,s,100*c);return void X.current.set(Math.max(0,Math.min(s,f+o-a)))}X.current.set(Cn(u,s,100*c))};return t(f?.get()??u),f?f.on("change",t):void 0},[e,s,u,l,f,d,o,a,i,w,y?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c)return;const t=m;if(!t||t.targetSceneIndex!==i)return;const n=F();if(z.current&&!n||C.current===t.token)return;C.current=t.token;const a=++I.current;k.current?.stop(),k.current=null,U(!1);const o=X.current,s=$(n),l="number"==typeof t.progressRatio?t.progressRatio:Q.current,u=n&&"releaseSeed"in n?n.releaseSeed.elapsedMs:Cn(B(n),s,100*Math.max(0,Math.min(l,1))),d=Math.max(0,o.get(),u);if(d>o.get()&&o.set(d),"enter"===t.mode){if(o.set(0),s<=.001)return void o.set(s);P.current="cold-start",k.current=(0,r.animate)(o,s,{duration:s/1e3,ease:"linear",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,o.set(s))}})}else if("settle"===t.mode){const e=s-d;if(e<=.001)return U(!1),o.set(s),A.current=t.token,void q.current?.();P.current="settle",U(!0),k.current=(0,r.animate)(o,s,{duration:e/1e3,ease:"linear",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,U(!1),o.set(s),A.current=t.token,q.current?.())}})}else{if(d<=.001)return U(!1),void o.set(0);const e=Math.min(.5*Math.max(d,0),300);P.current="bounce",U(!0),k.current=(0,r.animate)(o,0,{duration:e/1e3,ease:"easeOut",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,U(!1),o.set(0))}})}},[e,m?.token,i,y?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c||s)return;const t=m;if(!t||"enter"===t.mode||t.targetSceneIndex!==i||C.current!==t.token||"settle"===t.mode&&A.current===t.token||k.current)return;const n=F();if(z.current&&!n)return;const a=X.current,o=Math.max(0,a.get());if("bounce"===t.mode){if(o<=.001)return U(!1),void a.set(0);const e=++I.current;return P.current="bounce",U(!0),void(k.current=(0,r.animate)(a,0,{duration:Math.min(.5*o,300)/1e3,ease:"easeOut",onUpdate:t=>{I.current===e&&a.set(t)},onComplete:()=>{I.current===e&&(k.current=null,P.current=null,U(!1),a.set(0))}}))}const l=$(n),u=l-o;if(u<=.001)return U(!1),a.set(l),A.current=t.token,void q.current?.();const d=++I.current;P.current="settle",U(!0),k.current=(0,r.animate)(a,l,{duration:u/1e3,ease:"linear",onUpdate:e=>{I.current===d&&a.set(e)},onComplete:()=>{I.current===d&&(k.current=null,P.current=null,U(!1),a.set(l),A.current=t.token,q.current?.())}})},[e,c,s,m?.token,i]),(0,t.useEffect)(()=>{if("drag"!==e||0!==i||!g||s)return;const t=X.current;if(!D.current){const e=j.current??null;if(z.current&&!e)return;N.current=e;const n=$(e);D.current=!0,L.current=null===e,T.current=n;const i=n-Math.max(0,t.get());if(i<=.001)return t.set(n),void H.current?.();const a=++I.current;return P.current="cold-start",void(k.current=(0,r.animate)(t,n,{duration:i/1e3,ease:"linear",onUpdate:e=>{I.current===a&&t.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,t.set(T.current),H.current?.())}}))}if(!L.current||N.current)return;const n=O.current();if(n<=T.current+.001)return;k.current?.stop(),T.current=n;const a=n-Math.max(0,t.get());if(a<=.001)return t.set(n),k.current=null,P.current=null,void H.current?.();const o=++I.current;P.current="cold-start",k.current=(0,r.animate)(t,n,{duration:a/1e3,ease:"linear",onUpdate:e=>{I.current===o&&t.set(e)},onComplete:()=>{I.current===o&&(k.current=null,P.current=null,t.set(T.current),H.current?.())}})},[e,i,g,s,v,x?.revision]),(0,t.useEffect)(()=>()=>{k.current?.stop(),k.current=null,U(!1)},[]),{completeImmediately:(0,t.useCallback)(()=>{I.current+=1,k.current?.stop(),k.current=null,P.current=null,U(!1),X.current.set(O.current())},[]),resetImmediately:(0,t.useCallback)(()=>{I.current+=1,k.current?.stop(),k.current=null,P.current=null,U(!1),X.current.set(0)},[])}}({slideMode:f,isActive:g,sceneIndex:p,sceneOffset:tt,globalDirection:x,globalRenderProgress:qe,renderProgressMotion:Ze,globalIsDragging:We,candidateSuspended:J?.candidateSuspended??!1,globalDragTimelineProgress:He,dragTimelineProgressMotion:Ge,dragRelease:Ue,firstSceneEnterReady:E,elementElapsedMotion:Je,getTimelineDuration:xt,timelineDurationState:dt,dragTransaction:J?.transaction??null,preparedSnapshot:st,requirePreparedSnapshot:ke,dragMappingConfig:J?.dragMappingConfig,takeoverSnapshot:J?.takeoverSnapshot,onElementContinuationChange:J?.onElementContinuationChange,onSettleComplete:J?.onActivationComplete??Q,onColdStartComplete:J?.onActivationComplete??Q}),{handleCandidateSuspend:Nt,handleCandidateResume:Ft,handleDragStart:$t,handlePan:Bt,handlePanEnd:qt}=function({slideMode:e,isActive:n,sceneIndex:i,currentSceneIndex:a,totalScenes:o,slideDirection:s,slideDuration:c,sceneTransitionDuration:l,sceneOffset:u,sceneState:d,globalDirection:f,globalRenderProgress:m,globalIsDragging:g,globalDragProgress:p,globalDragTimelineProgress:h,controls:v,dragProgressMotion:y,setSceneState:x,setIsAnimating:S,resolveDragProgress:b,getTimelineDuration:w,onDragProgressChange:M,onRenderProgressChange:R,onDragTimelineProgressChange:E,onOwnershipRequest:k,onCandidateSuspensionChange:P,takeoverSnapshot:I,onDraggingChange:C,onDragRelease:A,renderLaneRef:D,completeReleaseImmediately:T=!1,onDragEnd:L,onDragReset:O,thresholdConfig:V}){(0,t.useRef)(null);const j=(0,t.useRef)(null),z=(0,t.useRef)(0),N=(0,t.useRef)(null),F=D??N,$=(0,t.useRef)(!1),B=(0,t.useRef)(0),q=(0,t.useRef)(!1),H=(0,t.useRef)(!1);return(0,t.useEffect)(()=>{if("drag"!==e)return;v.set({opacity:1,x:0,y:0,scale:1,rotate:0});const t=m,r=g||Math.abs(t)>.001,i=t>0?"forward":t<0?"backward":f,a=n?r?"exiting":"active":"forward"===i&&1===u||"backward"===i&&-1===u?"entering":"initial";d!==a&&x(a)},[e,v,n,d,i,m,g,u,f,x]),(0,t.useEffect)(()=>()=>{z.current+=1;const e=F.current;e&&e.ownerSceneIndex===i&&(e.stop(),F.current=null),$.current=!1,q.current=!1},[F,i]),{handleCandidateSuspend:(0,t.useCallback)(()=>{if("drag"!==e)return!1;const t=F.current,n=!!t?.suspend;q.current=n,t?.suspend?.();const r=P?.(!0)??!1;return n||r},[F,P,e]),handleCandidateResume:(0,t.useCallback)(()=>{F.current?.resume?.(),q.current=!1,P?.(!1)},[F,P]),handleDragStart:(0,t.useCallback)(t=>{if("drag"!==e)return!1;const r=F.current;if(!n&&!r||k&&!k(t))return!1;const i=r&&q.current?r.getCurrent?.()??m:m,a=I?.current;return a&&null===a.baseRatio&&(I.current={...a,baseRatio:Math.abs(i)}),P?.(!1),r?(r.preempt?r.preempt():r.stop(),F.current=null,q.current=!1,B.current=i,H.current=!0,y.set(i),M?.(i),E?.(Math.abs(i)),r.kind,i.toFixed(3)):(B.current=0,H.current=!1),$.current=!0,p.toFixed(3),h.toFixed(3),C?.(!0),!0},[e,n,F,k,y,M,E,C,i,a,o,p,h,m,P,I]),handlePan:(0,t.useCallback)((t,r)=>{if("drag"!==e||!n&&!$.current)return;const i="y"===s?r.offset.y:r.offset.x,a=b(B.current-i/("y"===s?window.innerHeight:window.innerWidth)),o=Math.abs(a);y.set(a),M?.(a),E?.(o),R?.(a)},[e,n,s,i,M,E,R,y,b]),handlePanEnd:(0,t.useCallback)((t,o)=>{if("drag"!==e||!n&&!$.current)return;$.current=!1;const l="pointercancel"===t.type;z.current+=1,F.current?.stop(),F.current=null;const u=y.get(),d=w(),f=function(e,t){const n="y"===e?t.velocity.y:t.velocity.x;return Number.isFinite(n)?-n:0}(s,o),m=Math.abs(f),g=Math.abs(u),p=(e,t)=>{let n=null,a=y.get(),o=0,s=!1,c=!1;const l=e/Math.max(Math.abs(a),1e-6),u=()=>{c||s||F.current!==m||(F.current=null,n?.stop(),a=0,y.set(0),M?.(0),E?.(0),R?.(0),t())},d=()=>{if(c||s||F.current!==m)return;const e=Math.abs(a)*l;if(e<=1e-6)return void u();const t=++o;n=(0,r.animate)(y,0,{duration:e,ease:"easeOut",onUpdate:e=>{t!==o||c||s||(a=e,y.set(e),M?.(e),E?.(Math.abs(e)),R?.(e))},onComplete:()=>{t===o&&(a=0,u())}})},f=()=>{c=!0,s=!1,o+=1,n?.stop()},m={kind:"bounce",ownerSceneIndex:i,stop:f,suspend:()=>{c||s||(a=y.get(),s=!0,o+=1,n?.stop())},resume:()=>{c||!s||(a=y.get(),s=!1,d())},preempt:f,getCurrent:()=>a};F.current=m,d()};if(g<.001){if(u.toFixed(3),O?.(),H.current){const e=B.current>=0?"forward":"backward";A?.({mode:"bounce",direction:e,targetSceneIndex:"forward"===e?a+1:a-1})}return C?.(!1),void(n&&x("active"))}const h=u>0?"forward":"backward",v="forward"===h?a+1:a-1;if(0===b(u)&&0!==u)return S(!0),u.toFixed(3),m.toFixed(1),C?.(!1),A?.({mode:"bounce",direction:h,targetSceneIndex:v}),void p(.15,()=>{O?.(),x("active"),S(!1)});const k=T?.5:function(e,t){const n=t?.minVelocity??0,r=t?.maxVelocity??1e3,i=t?.minRatio??.15,a=t?.maxRatio??.3;if(!Number.isFinite(e))return a;const o=r-n;return o<=0?a:a-(Math.max(n,Math.min(r,e))-n)/o*(a-i)}(m,V);m.toFixed(1),k.toFixed(3),g.toFixed(3);const P=!l&&g>k&&(T||!(g>.001&&u*f<0&&m>600));if(u.toFixed(3),g.toFixed(3),k.toFixed(3),m.toFixed(1),f.toFixed(1),P){if(S(!0),C?.(!1),T)return L?.(h,1,d,d),void S(!1);const e=++z.current,t="forward"===h?1:-1,n=Math.abs(t-u),a=Math.max(n*(c/1e3),0),o=Math.min(g,1);A?.({mode:"settle",direction:h,targetSceneIndex:v,progressRatio:g});let s=null,l=u,f=0,m=!1,p=!1;const x=()=>{p||m||F.current!==M||(F.current=null,s?.stop(),o.toFixed(3),(1e3*a).toFixed(1),L?.(h,o,o*d,d),R?.(0),S(!1))},b=()=>{if(p||m||F.current!==M)return;const n=Math.abs(t-l)*(c/1e3);if(n<=1e-6)return void x();const i=++f;s=(0,r.animate)(l,t,{duration:n,ease:"easeOut",onUpdate:n=>{if(i===f&&!p&&!m&&z.current===e&&(l=n,Math.abs(n-t)>1e-6&&y.set(n),R?.(n),0)){const e=Math.round(10*Math.abs(n))/10;j.current!==e&&(j.current=e)}},onComplete:()=>{i===f&&(l=t,x())}})},w=()=>{p=!0,m=!1,f+=1,s?.stop()},M={kind:"settle",ownerSceneIndex:i,stop:w,suspend:()=>{p||m||(m=!0,f+=1,s?.stop())},resume:()=>{p||!m||(m=!1,b())},preempt:w,getCurrent:()=>l};u.toFixed(3),(1e3*a).toFixed(1),o.toFixed(3),F.current=M,b()}else{S(!0);const e=Math.min(g*c,300)/1e3;u.toFixed(3),(1e3*e).toFixed(1),C?.(!1),A?.({mode:"bounce",direction:h,targetSceneIndex:v}),p(e,()=>{O?.(),S(!1)})}},[e,n,F,s,i,a,c,y,M,E,R,A,L,O,C,b,w,l,S,x,T,V])}}({slideMode:f,isActive:g,sceneIndex:p,currentSceneIndex:y,totalScenes:h,slideDirection:m,slideDuration:ue,sceneTransitionDuration:U,sceneOffset:tt,sceneState:Qe,globalDirection:x,globalRenderProgress:qe,globalIsDragging:We,globalDragProgress:Be,globalDragTimelineProgress:He,controls:ye,dragProgressMotion:Ze,setSceneState:et,setIsAnimating:rt,resolveDragProgress:Pt,getTimelineDuration:xt,onOwnershipRequest:J?.onOwnershipRequest,onCandidateSuspensionChange:J?.onCandidateSuspensionChange,takeoverSnapshot:J?.takeoverSnapshot,onDragProgressChange:J?.onProgressChange??ee,onRenderProgressChange:J?.onRenderProgressChange??te,onDragTimelineProgressChange:J?.onTimelineProgressChange??ne??(ke?void 0:e=>_e.set(e)),onDraggingChange:J?.onDraggingChange??re??(ke?void 0:Oe),onDragRelease:J?.onRelease??se??(ke?void 0:$e),renderLaneRef:J?.renderLane,completeReleaseImmediately:!ke,thresholdConfig:J?.threshold,onDragEnd:J?.onCommit??ce??(ke?void 0:(e,t,n,r)=>{Ie(0),Ae(0),Te(0),Oe(!1),je(r??0),Ne(null),zt.completeImmediately(),G?.(e)}),onDragReset:J?.onReset??le??(ke?void 0:()=>{Ie(0),Ae(0),Te(0),Oe(!1),Ne(null),zt.resetImmediately()})}),Ht="drag"===f&&(g||!!J?.renderLane?.current||!!Ue),{onPointerDown:Wt,onPointerMove:Yt,onPointerUp:Ut,onPointerCancel:Xt,onFramerPanStart:Kt,onFramerPan:Zt,onFramerPanEnd:_t}=function({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onDragStart:o,onPan:s,onPanEnd:c,authoredPointerDown:l,authoredPointerMove:u,authoredPointerUp:d,authoredPointerCancel:f}){const m=function({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onStart:o,onPan:s,onEnd:c}){const l=(0,t.useRef)(null),u=(0,t.useRef)(!1),d=(0,t.useRef)(0),f=(0,t.useRef)(null),m=(0,t.useRef)(null),g=(0,t.useRef)(r);g.current=r;const p=(0,t.useRef)(i);p.current=i;const h=(0,t.useRef)(a);h.current=a;const v=(0,t.useRef)(o);v.current=o;const y=(0,t.useRef)(s);y.current=s;const x=(0,t.useRef)(c);x.current=c;const S=(0,t.useCallback)(()=>{m.current?.(),m.current=null},[]),b=(0,t.useCallback)(()=>{null!==f.current&&(window.clearTimeout(f.current),f.current=null)},[]),w=(0,t.useCallback)(e=>{const t=l.current;if(!t||t.pointerId!==e.pointerId)return;const n=t.target;S(),l.current=null,t.ownsGesture?(Wn()-t.lastTime>100&&(t.velocityX=0,t.velocityY=0),n.releasePointerCapture?.(t.pointerId),x.current(e,Yn(t,e.clientX,e.clientY))):t.candidateSuspended&&p.current?.(),b();const r=d.current;u.current=!0;const i=window.setTimeout(()=>{f.current===i&&(f.current=null,d.current===r&&(u.current=!1))},0);f.current=i},[S,b]),M=(0,t.useCallback)(t=>{if(!e||!1===t.isPrimary||void 0!==t.button&&0!==t.button||function(e){return e instanceof Element&&!!e.closest('a,button,input,textarea,select,option,summary,[contenteditable="true"],[data-cineview-ignore-drag]')}(t.target))return;const n=l.current;n&&(n.target.releasePointerCapture?.(n.pointerId),!n.ownsGesture&&n.candidateSuspended&&p.current?.()),S(),b(),d.current+=1;const r=t.currentTarget;h.current?.();const i=g.current?.()??!1;l.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,lastTime:Wn(),velocityX:0,velocityY:0,target:r,ownsGesture:!1,candidateSuspended:i,rejectedDirections:new Set,panInfo:null},u.current=!0;const a=e=>{w(e)};window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a),document.addEventListener("pointerup",a),document.addEventListener("pointercancel",a),m.current=()=>{window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a),document.removeEventListener("pointerup",a),document.removeEventListener("pointercancel",a)}},[S,b,e,w]),R=(0,t.useCallback)(e=>{const t=l.current;if(!t||t.pointerId!==e.pointerId)return;const r=Wn();if(!t.ownsGesture){const i="y"===n?e.clientY-t.startY:e.clientX-t.startX,a="y"===n?e.clientX-t.startX:e.clientY-t.startY;if(Math.abs(i)<1||Math.abs(i)<=Math.abs(a))return;const o=i<0?"forward":"backward";if(t.rejectedDirections.has(o))return;return t.candidateSuspended||(t.candidateSuspended=g.current?.()??!1),v.current(o)?(t.ownsGesture=!0,t.startX=e.clientX,t.startY=e.clientY,t.lastX=e.clientX,t.lastY=e.clientY,t.lastTime=r,t.velocityX=0,t.velocityY=0,t.target.setPointerCapture?.(t.pointerId),void(e.cancelable&&e.preventDefault())):(t.rejectedDirections.add(o),void(t.candidateSuspended&&(p.current?.(),t.candidateSuspended=!1)))}const i=Math.max(r-t.lastTime,1);t.velocityX=(e.clientX-t.lastX)/i*1e3,t.velocityY=(e.clientY-t.lastY)/i*1e3,y.current(e.nativeEvent,Yn(t,e.clientX,e.clientY)),t.lastX=e.clientX,t.lastY=e.clientY,t.lastTime=r,e.cancelable&&e.preventDefault()},[n]),E=(0,t.useCallback)(e=>w(e.nativeEvent),[w]);return(0,t.useEffect)(()=>()=>{const e=l.current;e&&!e.ownsGesture&&e.candidateSuspended&&p.current?.(),S(),b(),d.current+=1,l.current=null,u.current=!1},[S,b]),{onPointerDown:M,onPointerMove:R,onPointerUp:E,onPointerCancel:E,isActiveRef:u}}({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onStart:o,onPan:s,onEnd:c}),{onPointerDown:g,onPointerMove:p,onPointerUp:h,onPointerCancel:v}=m,y=(0,t.useCallback)(e=>{l?.(e),e.defaultPrevented||g(e)},[l,g]),x=(0,t.useCallback)(e=>{u?.(e),e.defaultPrevented||p(e)},[u,p]),S=(0,t.useCallback)(e=>{d?.(e),h(e)},[d,h]),b=(0,t.useCallback)(e=>{f?.(e),v(e)},[f,v]),w=(0,t.useRef)({ownsGesture:!1,candidateSuspended:!1,baseline:0,rejectedDirections:new Set}),M=(0,t.useRef)(i);M.current=i;const R=(0,t.useCallback)(e=>{const t=w.current;e&&!t.ownsGesture&&t.candidateSuspended&&M.current?.(),w.current={ownsGesture:!1,candidateSuspended:!1,baseline:0,rejectedDirections:new Set}},[]),E=(0,t.useCallback)(()=>{m.isActiveRef.current?R(!0):(R(!0),a?.(),w.current={ownsGesture:!1,candidateSuspended:r?.()??!1,baseline:0,rejectedDirections:new Set})},[R,m.isActiveRef,r,a]),k=(0,t.useCallback)((e,t)=>{if(m.isActiveRef.current)return void R(!0);const a=w.current,c="y"===n?t.offset.y:t.offset.x,l="y"===n?t.offset.x:t.offset.y;if(!a.ownsGesture){if(Math.abs(c)<1||Math.abs(c)<=Math.abs(l))return;const e=c<0?"forward":"backward";if(a.rejectedDirections.has(e))return;return a.candidateSuspended||(a.candidateSuspended=r?.()??!1),o(e)?(a.ownsGesture=!0,void(a.baseline=c)):(a.rejectedDirections.add(e),void(a.candidateSuspended&&(i?.(),a.candidateSuspended=!1)))}const u=c-a.baseline;s(e,{...t,offset:"y"===n?{x:t.offset.x,y:u}:{x:u,y:t.offset.y}})},[n,R,m.isActiveRef,i,r,o,s]),P=(0,t.useCallback)((e,t)=>{if(m.isActiveRef.current)return void R(!0);const r=w.current;if(!r.ownsGesture)return void R(!0);const i=("y"===n?t.offset.y:t.offset.x)-r.baseline;c(e,{...t,offset:"y"===n?{x:t.offset.x,y:i}:{x:i,y:t.offset.y}}),R(!1)},[n,R,m.isActiveRef,c]);return(0,t.useEffect)(()=>()=>R(!0),[R]),{onPointerDown:y,onPointerMove:x,onPointerUp:S,onPointerCancel:b,onFramerPanStart:E,onFramerPan:k,onFramerPanEnd:P}}({axis:m,enabled:Ht,onCandidateStart:Nt,onCandidateEnd:Ft,onPointerSessionStart:J?.onPointerSessionStart,onDragStart:$t,onPan:Bt,onPanEnd:qt,authoredPointerDown:c,authoredPointerMove:l,authoredPointerUp:u,authoredPointerCancel:d}),Gt=(0,t.useMemo)(()=>"drag"===f?{opacity:1}:xe?xe.initial:{opacity:1},[xe,f]),Jt=(0,t.useMemo)(()=>"drag"===f?"none":"translateZ(0)",[f]),Qt=(0,t.useMemo)(()=>function(e){switch(e){case"top-left":default:return{top:0,left:0};case"top-center":return{top:0,left:"50%",transform:"translateX(-50%)"};case"top-right":return{top:0,right:0};case"center-left":return{top:"50%",left:0,transform:"translateY(-50%)"};case"center":return{top:"50%",left:"50%",transform:"translate(-50%, -50%)"};case"center-right":return{top:"50%",right:0,transform:"translateY(-50%)"};case"bottom-left":return{bottom:0,left:0};case"bottom-center":return{bottom:0,left:"50%",transform:"translateX(-50%)"};case"bottom-right":return{bottom:0,right:0}}}(q),[q]),en=(0,t.useMemo)(()=>function(e){switch(e){case"top-right":case"center-right":case"bottom-right":return{marginLeft:"auto",marginRight:0};case"top-center":case"center":case"bottom-center":return{marginLeft:"auto",marginRight:"auto"};default:return{marginLeft:0,marginRight:"auto"}}}(q),[q]),tn=(0,t.useMemo)(()=>Ln({effectiveMode:f,effectiveDirection:m,globalScrollTimelineState:N,globalScrollViewportOffset:F,globalViewportWidth:k,globalViewportHeight:P}),[f,m,N,F,k,P]),nn=!Ht&&("covered"===It||"parked"===It||"inactive"===It),rn=nn?{"aria-hidden":!0}:void 0,an=nn||!0===e.inert;(0,t.useEffect)(()=>{const e=bt.current;e&&(e.inert=an)},[an]);const on=(0,t.useMemo)(()=>({width:$,height:B,position:"scroll"===f?"relative":"absolute",overflow:H,willChange:nt||Xe||O?"transform, opacity":"auto",contain:"drag"===f?"layout style":"layout style paint",transform:Jt,userSelect:"drag"===f&&Xe?"none":void 0,WebkitUserSelect:"drag"===f&&Xe?"none":void 0,touchAction:An(f,m),zIndex:W,pointerEvents:Ht||"covered"!==It&&"parked"!==It&&"inactive"!==It?"auto":"none",..."scroll"===f?en:Qt}),[nt,Xe,O,Ht,Jt,f,m,$,B,H,W,It,en,Qt]);return(0,n.jsx)(Un.Provider,{value:p,children:(0,n.jsx)(hn.Provider,{value:jt,children:(0,n.jsx)(bn.Provider,{value:"scroll"===f?Mt:null,children:(0,n.jsx)(oe.Provider,{value:"scroll"===f?kt:null,children:(0,n.jsxs)(r.motion.div,{ref:wt,"data-cineview-scroll-zone":"scroll"===f?kt??e.sceneId??void 0:void 0,initial:Gt,animate:ye,...Object.fromEntries(Object.entries(e).filter(([e])=>!Xn.has(e))),className:o,style:{...s,...on},...rn,inert:an,onPanStart:"drag"===f?Kt:void 0,onPan:"drag"===f?Zt:void 0,onPanEnd:"drag"===f?_t:void 0,onPointerDown:"drag"===f?Wt:c,onPointerMove:"drag"===f?Yt:l,onPointerUp:"drag"===f?Ut:u,onPointerCancel:"drag"===f?Xt:d,children:["scroll"===f?(0,n.jsx)(On,{sceneIndex:p,metrics:tn,setHostRef:Et,frameStore:fe,direction:m,viewportWidth:k,viewportHeight:P}):null,a]})})})})})}),Zn=Object.assign(Kn,{cineViewScene:!0});Zn.displayName="Scene";var _n=new Set(["width","minWidth","maxWidth","height","minHeight","maxHeight","top","bottom","left","right","inset","insetInline","insetInlineStart","insetInlineEnd","insetBlock","insetBlockStart","insetBlockEnd","margin","marginTop","marginBottom","marginLeft","marginRight","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd","borderWidth","borderTopWidth","borderBottomWidth","borderLeftWidth","borderRightWidth","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","gap","columnGap","rowGap","fontSize","letterSpacing","outlineWidth","outlineOffset"]),Gn=(e,t)=>{if(!e||!t)return e;let n=!1;const r={};return Object.entries(e).forEach(([e,i])=>{const a=((e,t,n)=>n&&"number"==typeof t&&Number.isFinite(t)&&!e.startsWith("--")&&_n.has(e)?n.convert(t):t)(e,i,t);r[e]=a,n||(n=a!==i)}),n?r:e},Jn=(0,t.forwardRef)(function({width:e,height:r,children:i,style:a,className:o,...s},c){const l=v(),u=(0,t.useMemo)(()=>{if(!l)return a;const t=Gn(a,l),n=void 0!==e?l.convert(e):void 0,i=void 0!==r?l.convert(r):void 0;return{...t,...void 0!==e?{width:n}:{},...void 0!==r?{height:i}:{}}},[l,e,r,a]);return(0,n.jsx)("div",{ref:c,style:u,className:o,...s,children:i})});Jn.displayName="Container";var Qn=(0,t.forwardRef)(function({src:e,alt:r,width:i,height:a,style:o,loading:s,preload:c,...l},u){const d=v(),f=(0,t.useMemo)(()=>"number"!=typeof i?i:d?.convert(i)??i,[d,i]),m=(0,t.useMemo)(()=>"number"!=typeof a?a:d?.convert(a)??a,[d,a]),g=(0,t.useMemo)(()=>Gn(o,d),[d,o]),p="lazy"!==s&&(c??!0),h=s??(p?"eager":"lazy");return(0,t.useEffect)(()=>{if(!p||!e||typeof window>"u"||function(e){return e.length>0&&y.has(e)}(e))return;const t=new window.Image,n=()=>{S(e)};return t.addEventListener("load",n),t.src=e,()=>{t.removeEventListener("load",n)}},[p,e]),(0,n.jsx)("img",{ref:u,...l,src:e,alt:r,width:f,height:m,style:g,loading:h})});Qn.displayName="Image";var er=1e-4;function tr(e,t,n){return Math.min(n,Math.max(t,e))}function nr(e,t){return function(e){return Number.isFinite(e)&&e>0}(e)?t?[Number.isFinite(t[0])?tr(t[0],0,e):0,Number.isFinite(t[1])?tr(t[1],0,e):e]:[0,e]:null}function rr(e){return{activationId:e,status:"framework-scrub",activePlayRequestId:null,settledPlayRequestId:null,nextPlayRequestId:1,lastSeekTime:null,endpointLatched:!1,outgoingLatched:!1,frameworkPlayBlocked:!1,frameworkPausePending:!1}}function ir(e,t=[]){return{state:e,commands:t}}function ar(e,t){return{...rr(t),nextPlayRequestId:e.nextPlayRequestId}}function or(e,t){switch(t.type){case"timeline-frame":return function(e,t){const{frame:n}=t;if("exiting"===n.phase||"exited"===n.phase){if(e.outgoingLatched)return ir(e);const t="native-playback"===e.status||"play-pending"===e.status,n=null!==e.activePlayRequestId||null!==e.settledPlayRequestId;return ir({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:null,outgoingLatched:!0,frameworkPlayBlocked:e.frameworkPlayBlocked||t||n,frameworkPausePending:t},t?[{type:"pause"}]:[])}if(!e.outgoingLatched&&!function(e){return"gesture"===e||"continuation"===e||"programmatic"===e||"scroll"===e||"visibility"===e}(n.source)||!function(e,t){return"ended"!==e.status&&"play-rejected"!==e.status||("gesture"===t.source||"scroll"===t.source||"visibility"===t.source)&&t.progress<.98}(e,n))return ir(e);const r=function(e,t,n){const r=nr(t,n);if(!r)return null;const i=tr(Number.isFinite(e)?e:0,0,1);return r[0]+i*(r[1]-r[0])}(n.progress,t.duration,t.scrubRange);if(null===r)return ir(e);if(function(e){return"native-playback"===e||"native-paused"===e||"play-pending"===e}(e.status)){if(!function(e,t){return!(e.endpointLatched&&t.progress>=.98)&&("scroll"===t.source||"visibility"===t.source||"gesture"===t.source&&t.progress<.98)}(e,n))return ir(e);const t=[],i="native-playback"===e.status||"play-pending"===e.status;return i&&t.push({type:"pause"}),(null===e.lastSeekTime||Math.abs(e.lastSeekTime-r)>er)&&t.push({type:"seek",time:r}),ir({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:r,endpointLatched:!1,outgoingLatched:!1,frameworkPlayBlocked:!0,frameworkPausePending:i},t)}const i=[];if((null===e.lastSeekTime||Math.abs(e.lastSeekTime-r)>er)&&i.push({type:"seek",time:r}),function(e,t){if(!e.scrubRange||t||e.frame.progress<.999)return!1;const n=nr(e.duration,e.scrubRange);return!!n&&n[1]<e.duration-er}(t,e.endpointLatched)){const t=e.nextPlayRequestId;return i.push({type:"play",requestId:t}),ir({...e,status:"play-pending",activePlayRequestId:t,settledPlayRequestId:null,nextPlayRequestId:t+1,lastSeekTime:r,endpointLatched:!0,outgoingLatched:!1,frameworkPlayBlocked:!1},i)}const a=!!(t.scrubRange&&n.progress>=.999),o=n.progress<.98;return ir({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:r,endpointLatched:!!a||!o&&e.endpointLatched,outgoingLatched:!1},i)}(e,t);case"media-play":return t.activationId!==e.activationId?ir(e):void 0!==t.requestId?e.activePlayRequestId===t.requestId||"native-playback"===e.status&&!e.frameworkPlayBlocked&&e.settledPlayRequestId===t.requestId?ir({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPausePending:!1,frameworkPlayBlocked:!1}):ir({...e,frameworkPausePending:!0,frameworkPlayBlocked:!0},[{type:"pause"}]):e.frameworkPlayBlocked?ir({...e,frameworkPausePending:!0},[{type:"pause"}]):ir({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:null,frameworkPausePending:!1,frameworkPlayBlocked:!1});case"media-pause":return t.activationId!==e.activationId?ir(e):e.frameworkPausePending?ir({...e,frameworkPausePending:!1}):ir({...e,status:"ended"===e.status?"ended":"native-paused",activePlayRequestId:null,settledPlayRequestId:"ended"===e.status?e.settledPlayRequestId:null,frameworkPlayBlocked:"ended"===e.status&&e.frameworkPlayBlocked});case"media-ended":return t.activationId!==e.activationId?ir(e):ir({...e,status:"ended",activePlayRequestId:null,endpointLatched:!0,frameworkPausePending:!1});case"play-resolved":return e.activePlayRequestId!==t.requestId?ir(e):ir({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"play-rejected":return e.activePlayRequestId!==t.requestId?ir(e):ir({...e,status:"play-rejected",activePlayRequestId:null,settledPlayRequestId:null,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"activate":return e.activationId===t.activationId?ir(e):ir(ar(e,t.activationId));case"reset":return ir(ar(e,t.activationId))}}var sr=!0,cr=(0,t.forwardRef)(function({src:e,progress:r,timelineFrame:i,scrubRange:a,width:o,height:s,style:c,"aria-label":l,preload:u=!0,poster:d,playbackRate:f,onEnded:m,onPlay:g,onPause:p,onTimeUpdate:h,onError:y,controlRef:x},S){const M=v(),k=(0,t.useRef)(null),[P,I]=(0,t.useState)(()=>({src:e,url:C(e)??null})),D=P.src===e?P.url:null,O=(0,t.useRef)([]),V=(0,t.useRef)(rr(0)),j=(0,t.useRef)(0),z=(0,t.useRef)(void 0),N=(0,t.useRef)(0),F=(0,t.useRef)({src:e,objectUrl:D}),$=(0,t.useRef)(null),B=(0,t.useRef)(()=>{}),q=(0,t.useRef)(new WeakMap),H=(0,t.useRef)(null),W=(0,t.useRef)(null),Y=(0,t.useCallback)((e,t)=>{const n=$.current,r=N.current;if(n&&(n.video!==e||n.activationId!==t||n.generation!==r)&&(n.video.removeEventListener("loadstart",n.loadStart,sr),n.video.removeEventListener("play",n.play,sr),n.video.removeEventListener("pause",n.pause,sr),n.video.removeEventListener("ended",n.ended,sr),$.current=null),!e||$.current)return;const i=()=>j.current===t&&N.current===r,a=()=>i()&&H.current===r,o=()=>{i()&&(H.current=r)},s=e=>{q.current.set(e,{generation:r,activationId:t})},c=e=>{if(!a())return;const n=z.current,i=n?.generation===r&&n.activationId===t?n.requestId:void 0,o=V.current,c=void 0!==i&&(!o.frameworkPlayBlocked&&o.activePlayRequestId===i||"native-playback"===o.status&&!o.frameworkPlayBlocked&&o.settledPlayRequestId===i),l=void 0===i&&!o.frameworkPlayBlocked;void 0!==i&&(z.current=void 0),c||l?(s(e),B.current({type:"media-play",requestId:i,activationId:t})):B.current({type:"media-play",requestId:i,activationId:t})},l=e=>{a()&&(V.current.frameworkPausePending||(z.current=void 0),s(e),B.current({type:"media-pause",activationId:t}))},u=e=>{a()&&(s(e),B.current({type:"media-ended",activationId:t}))};e.addEventListener("loadstart",o,sr),e.addEventListener("play",c,sr),e.addEventListener("pause",l,sr),e.addEventListener("ended",u,sr),$.current={video:e,generation:r,activationId:t,loadStart:o,play:c,pause:l,ended:u}},[]),[U,X]=(0,t.useState)(!1),[K,Z]=(0,t.useState)(0),[_,G]=(0,t.useState)(0),J=(0,t.useCallback)((e=!0)=>{j.current+=1,V.current=or(V.current,{type:"reset",activationId:j.current}).state,z.current=void 0,O.current=[],Y(e?k.current:null,j.current)},[Y]);(0,t.useEffect)(()=>{const e={release:()=>{const e=k.current;X(!0),e&&(e.pause(),W.current=e.getAttribute("src"),e.removeAttribute("src"),e.load()),J(!1)},warmUp:()=>{const e=k.current;if(e&&!e.getAttribute("src")){const t=W.current;t&&(e.src=t,W.current=null)}X(!1),Z(e=>e+1),J(!1)}};return x&&(x.current=e),()=>{x&&(x.current=null)}},[x,J]);const Q=(0,t.useCallback)(e=>{e||Y(null,j.current),k.current=e,e&&Y(e,j.current),function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(S,e)},[Y,S]),te=(0,t.useMemo)(()=>"number"==typeof o?M?.convert(o)??o:o,[M,o]),ne=(0,t.useMemo)(()=>"number"==typeof s?M?.convert(s)??s:s,[M,s]),re=(0,t.useMemo)(()=>Gn(c,M??null),[M,c]);(0,t.useEffect)(()=>{if(typeof window>"u"||!e)return void I({src:e,url:null});let t=!0,n=!1;const r=()=>{const t=function(e){const t=b.get(e);if(t)return A(e),E.set(e,(E.get(e)??0)+1),t.objectUrl}(e);return!!t&&(n=!0,I({src:e,url:t}),!0)};let i=()=>{};return r()||(I({src:e,url:null}),i=function(e){return R.add(e),()=>{R.delete(e)}}(i=>{i===e&&t&&!n&&r()})),()=>{t=!1,i(),n&&function(e){const t=E.get(e)??0;t<=1?E.delete(e):E.set(e,t-1),T("")}(e)}},[e]),(0,t.useEffect)(()=>{typeof window>"u"||!e||!u||function(e){return e.length>0&&w.has(e)}(e)||L(e,"video").catch(()=>{})},[u,e]),(0,t.useEffect)(()=>{X(!1),Z(e=>e+1)},[e]),ee(()=>{const e=k.current;e&&(e.playbackRate=f??1)},[_,D,f,U,e]);const ie=(0,t.useCallback)((e,t)=>{e.currentTime=t},[e]),ae=(0,t.useCallback)(e=>{const t=k.current;if(!t)return;const n=or(V.current,e);V.current=n.state,n.commands.forEach(e=>{switch(e.type){case"pause":return void t.pause();case"seek":return void ie(t,e.time);case"play":{const n={requestId:e.requestId,generation:N.current,activationId:V.current.activationId,settled:!1};z.current=n;const r=t=>{if(z.current===n&&!n.settled){if(n.settled=!0,"play-rejected"===t&&(z.current=void 0),N.current!==n.generation||V.current.activationId!==n.activationId)return void(z.current=void 0);ae({type:t,requestId:e.requestId})}};let i;try{i=t.play()}catch{return void r("play-rejected")}return void Promise.resolve(i).then(()=>r("play-resolved"),()=>r("play-rejected"))}}})},[ie]);ee(()=>{B.current=ae;const t=F.current;let n=!1;(t.src!==e||t.objectUrl!==D)&&(F.current={src:e,objectUrl:D},N.current+=1,H.current=null,J(),n=!0),!n&&k.current&&k.current.readyState>=1&&(H.current=N.current),Y(k.current,j.current)},[Y,ae,K,D,J,e]),(0,t.useEffect)(()=>()=>Y(null,j.current),[Y]),(0,t.useEffect)(()=>{if(!i)return;const e=k.current;if(!e||typeof window>"u")return;let t=i.get();const n=n=>{t=n;const r=V.current;if("entering"===n.phase&&("ended"===r.status||r.outgoingLatched))return j.current+=1,Y(null,j.current),ae({type:"activate",activationId:j.current}),void G(e=>e+1);!Number.isFinite(e.duration)||e.duration<=0||ae({type:"timeline-frame",frame:n,duration:e.duration,scrubRange:a})},r=()=>n(t),o=i.on("change",n);return e.readyState>=1?r():e.addEventListener("loadedmetadata",r,{once:!0}),()=>{o(),e.removeEventListener("loadedmetadata",r)}},[Y,ae,K,_,D,a,i]),(0,t.useEffect)(()=>{if(i)return;const e=k.current;if(!e||typeof window>"u")return;const t="object"==typeof r?r:null,n=t=>{const n=e.duration;!Number.isFinite(n)||n<=0||ie(e,(t<0?0:t>1?1:t)*n)},a=()=>n(t?.get()??r),o=t?.on("change",n);return e.readyState>=1?a():e.addEventListener("loadedmetadata",a,{once:!0}),()=>{o?.(),e.removeEventListener("loadedmetadata",a)}},[K,D,r,ie,i]);const oe=e=>{const t=q.current.get(e);return q.current.delete(e),!(!t||t.generation!==N.current||t.activationId!==j.current)},se=U&&P.src===e,ce=JSON.stringify([e,D,_,se?"released":"active"]);return(0,n.jsx)("video",{ref:Q,src:(se?void 0:D??e)||void 0,muted:!0,playsInline:!0,preload:se?"none":u?"auto":D?"metadata":"none","aria-label":l,width:te,height:ne,style:re,poster:d||void 0,onPlay:e=>{oe(e.nativeEvent)&&g?.(e)},onPause:e=>{oe(e.nativeEvent)&&p?.(e)},onEnded:e=>{oe(e.nativeEvent)&&m?.(e)},onTimeUpdate:h,onError:y},ce)});cr.displayName="VideoFrameRenderer";var lr={initial:{opacity:1},animate:{opacity:1}},ur=(0,t.forwardRef)(function({src:e,"aria-label":r,width:i,height:a,style:o,preload:s,poster:c,playbackRate:l,scrubRange:u,releaseOnLeave:d,onEnded:f,onPlay:m,onPause:g,onTimeUpdate:p,onError:h},v){const y=un(),x=function(e,n){const r=(0,t.useRef)(null),i=un(),a=(0,t.useContext)(oe),o=function(e,n=!0){return function(e,n,r){const i=(0,t.useContext)(ae),a=r(e?i?.zoneStates?.[e]??null:null),o=n&&e?i?.store:void 0,s=(0,t.useCallback)(t=>o&&e?o.subscribeKey(e,t):()=>{},[o,e]),c=(0,t.useCallback)(()=>r(o&&e?o.getKeySnapshot(e)??null:e?i?.zoneStates?.[e]??null:null),[r,o,i?.zoneStates,e]);return(0,t.useSyncExternalStore)(s,c,()=>a)}(e,n,(0,t.useCallback)(e=>e?.approach??null,[]))}(e?a:null,!0===e),s=(0,t.useRef)(!1),c=(0,t.useRef)(!!e),l=i.progress;return(0,t.useEffect)(()=>{s.current=!1},[n]),(0,t.useEffect)(()=>{if(!e)return;const t=e=>{Math.abs(e)>1e-4&&(s.current=!0)};return t(l.get()),l.on("change",t)},[l,e]),(0,t.useEffect)(()=>{const t=c.current;if(c.current=!!e,e){if(o){if("far"===o)return void(s.current&&r.current?.release());r.current?.warmUp()}}else t&&r.current?.warmUp()},[o,e]),r}(d,e);return(0,n.jsx)(cr,{ref:v,controlRef:x,src:e,progress:y.progress,timelineFrame:y.frame,"aria-label":r,width:i,height:a,style:o,preload:s,poster:c,playbackRate:l,scrubRange:u,onEnded:f,onPlay:m,onPause:g,onTimeUpdate:p,onError:h})}),dr=(0,t.forwardRef)(function({src:e,"aria-label":t,width:r,height:i,style:a,preload:o,poster:s,playbackRate:c,scrubRange:l,animateId:u,duration:d,enterAnimation:f,exitAnimation:m,timeline:g,visibility:p,releaseOnLeave:h,onEnded:v,onPlay:y,onPause:x,onTimeUpdate:S,onError:b},w){return(0,n.jsx)(xn,{animateId:u,enterAnimation:f??lr,exitAnimation:m,duration:{enter:d?.enter,exit:d?.exit},timeline:g,visibility:p,children:(0,n.jsx)(ur,{ref:w,src:e,"aria-label":t,width:r,height:i,style:a,preload:o,poster:s,playbackRate:c,scrubRange:l,releaseOnLeave:h,onEnded:v,onPlay:y,onPause:x,onTimeUpdate:S,onError:b})})});dr.displayName="AnimateVideo";var fr=xn,mr=wn,gr=Zn,pr=ke;e.Animate=fr,e.AnimateVideo=dr,e.Cineview=pr,e.Container=Jn,e.Image=Qn,e.Position=mr,e.Scene=gr,e.useAnimateTimeline=un});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&typeof module<"u"?t(exports,require("react"),require("react/jsx-runtime"),require("framer-motion"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react/jsx-runtime","framer-motion","react-dom"],t):t((e=typeof globalThis<"u"?globalThis:e||self).Cineview={},e.React,e.ReactJSXRuntime,e.FramerMotion,e.ReactDOM)}(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var a,o,s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,m=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},g=(e,t)=>{let n={};for(var r in e)c(n,r,{get:e[r],enumerable:!0});return t||c(n,Symbol.toStringTag,{value:"Module"}),n};o=null!=(a=t)?s(d(a)):{},t=((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var i,a=u(t),o=0,s=a.length;o<s;o++)i=a[o],!f.call(e,i)&&void 0!==i&&c(e,i,{get:(e=>t[e]).bind(null,i),enumerable:!(r=l(t,i))||r.enumerable});return e})(a&&a.__esModule&&f.call(a,"default")?o:c(o,"default",{value:a,enumerable:!0}),a);var p=(0,t.createContext)(null),h=({designSize:e,children:r})=>{const i=function(e){return void 0===e?750:Number.isFinite(e)&&e>0?e:(String(e),750)}(e),[a,o]=(0,t.useState)(typeof window<"u"?window.innerWidth:750),s=(0,t.useMemo)(()=>a/i,[a,i]),c=(0,t.useCallback)(e=>e*s,[s]);(0,t.useEffect)(()=>{if(typeof window>"u")return;const{debounced:e,cancel:t}=function(){let e=null;return{debounced:function(...t){e&&clearTimeout(e),e=setTimeout(()=>{(()=>{o(window.innerWidth)})(...t),e=null},150)},cancel:()=>{e&&(clearTimeout(e),e=null)}}}();return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),t()}},[]);const l=(0,t.useMemo)(()=>({scale:s,convert:c}),[s,c]),u=(0,t.useMemo)(()=>({"--cineview-unit":`${s}px`}),[s]);return(0,n.jsx)(p.Provider,{value:l,children:(0,n.jsx)("div",{className:"cineview-responsive-container",style:u,children:r})})},v=()=>(0,t.useContext)(p),y=new Set,x=new Set;function S(e){if(!e)return;const t=y.has(e);y.add(e),t||x.forEach(t=>t(e))}var b=new Map,w=new Set,E=new Map,M=new Set,R=new Map,k=0,P=/\.(mp4|webm|mov|m4v|ogv|ogg)(\?|#|$)/i;function I(e){return P.test(e)?"video":null}function C(e){const t=b.get(e);if(t)return A(e),t.objectUrl}function A(e){const t=b.get(e);t&&(b.delete(e),b.set(e,t))}function D(e){typeof URL<"u"&&URL.revokeObjectURL&&URL.revokeObjectURL(e)}function T(e){for(const[t,n]of b){if(k<=134217728)break;t===e||(R.get(t)??0)>0||(b.delete(t),w.delete(t),k-=n.bytes,D(n.objectUrl))}}function L(e,t){if(!e||w.has(e))return Promise.resolve();const n=E.get(e);if(n)return n;if(typeof fetch>"u")return Promise.reject(new Error("preloadMedia requires fetch (client-side only)"));if(!(t??I(e)))return Promise.reject(new Error(`Cannot determine media type: ${e} (pass explicit kind)`));const r=async function(e){const t=typeof AbortController<"u"?new AbortController:null,n=t?setTimeout(()=>t.abort(),3e4):null;try{const n=await fetch(e,t?{signal:t.signal}:void 0);if(!n.ok)throw new Error(`Failed to preload media: ${e} (HTTP ${n.status})`);const r=await n.blob();if(!r)throw new Error(`Invalid blob response for media: ${e}`);(function(e,t){const n=b.get(e);n&&(k-=n.bytes,D(n.objectUrl)),b.set(e,t),k+=t.bytes,T(e)})(e,{kind:"video",objectUrl:URL.createObjectURL(r),bytes:r.size}),function(e){const t=w.has(e);w.add(e),t||M.forEach(t=>t(e))}(e)}catch(n){if(t?.signal.aborted){const t=new Error(`Media preload timed out after 30000ms: ${e}`);throw t.cause=n,t}throw n}finally{null!==n&&clearTimeout(n)}}(e).finally(()=>{E.delete(e)});return E.set(e,r),r}function O(e){return Array.from(new Set(e.filter(e=>e.length>0)))}function V(e,t,n,r){const i=O(e).filter(e=>!n.has(e)&&!r.has(e)),a=new Set(i);return{priorityBatch:i,backgroundBatch:O(t).filter(e=>!n.has(e)&&!r.has(e)&&!a.has(e))}}var j="(prefers-reduced-motion: reduce)";function z(){return typeof window<"u"&&"function"==typeof window.matchMedia&&window.matchMedia(j).matches}function N(e){if(typeof window>"u"||"function"!=typeof window.matchMedia)return()=>{};const t=window.matchMedia(j);return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}var F=new class{constructor(){this.frameCount=0,this.lastTime=performance.now(),this.frameTimes=[],this.memorySamples=[],this.lastMemorySampleTime=0,this.cachedMemoryUsage=void 0,this.cachedBundleSizeKb=0,this.rafId=null,this.isMonitoring=!1,this.measure=()=>{if(!this.isMonitoring)return;const e=performance.now(),t=e-this.lastTime;this.frameCount++,this.frameTimes.push(t),this.frameTimes.length>60&&this.frameTimes.shift(),this.sampleMemory(e),this.lastTime=e,this.rafId=requestAnimationFrame(this.measure)}}start(){this.isMonitoring||(this.isMonitoring=!0,this.frameCount=0,this.lastTime=performance.now(),this.frameTimes=[],this.memorySamples=[],this.lastMemorySampleTime=0,this.cachedMemoryUsage=void 0,this.cachedBundleSizeKb=this.estimateBundleSizeKb(),this.measure())}stop(){this.isMonitoring=!1,null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null)}getMetrics(){const e=this.calculateAvgFrameTime();if(0===this.frameTimes.length)return{fps:0,avgFrameTime:0,memoryUsage:this.getMemoryUsage(),bundleSize:this.getBundleSizeKb()};const t=1e3/Math.max(e,1);return{fps:Math.round(10*Math.min(Math.max(t,0),60))/10,avgFrameTime:Math.round(100*e)/100,memoryUsage:this.getMemoryUsage(),bundleSize:this.getBundleSizeKb()}}calculateAvgFrameTime(){return 0===this.frameTimes.length?0:this.frameTimes.reduce((e,t)=>e+t,0)/this.frameTimes.length}getMemoryUsage(){return this.sampleMemory(performance.now(),void 0===this.cachedMemoryUsage),this.cachedMemoryUsage}sampleMemory(e,t=!1){if(!performance.memory)return this.cachedMemoryUsage=void 0,void(this.memorySamples=[]);if(!t&&e-this.lastMemorySampleTime<1e3)return;const n=performance.memory.usedJSHeapSize/1048576;this.memorySamples.push(n),this.memorySamples.length>8&&this.memorySamples.shift();const r=[...this.memorySamples].sort((e,t)=>e-t),i=Math.floor(r.length/2),a=r.length%2==0?(r[i-1]+r[i])/2:r[i];this.cachedMemoryUsage=Math.round(10*a)/10,this.lastMemorySampleTime=e}getBundleSizeKb(){return this.cachedBundleSizeKb>0||(this.cachedBundleSizeKb=this.estimateBundleSizeKb()),this.cachedBundleSizeKb}estimateBundleSizeKb(){if(typeof performance>"u"||"function"!=typeof performance.getEntriesByType)return 0;const e=performance.getEntriesByType("resource");if(0===e.length)return 0;const t=e.reduce((e,t)=>{const n=t.name.toLowerCase();return n.endsWith(".js")||n.endsWith(".mjs")||n.endsWith(".css")||n.includes(".js?")||n.includes(".mjs?")||n.includes(".css?")?e+Math.max(t.decodedBodySize||0,t.transferSize||0):e},0);return Math.round(t/1024*10)/10}},$=0,B=F;function q(e){return e.assets?.preloadImages??[]}function H(e,t,n){return Math.min(n,Math.max(t,e))}function W(e,t,n,r){if(!(e instanceof Element)||0===r)return!1;const i="x"===n?"overflowX":"overflowY";let a=e;for(;a&&a!==t;){if(a instanceof HTMLElement){const e=window.getComputedStyle(a)[i],t="auto"===e||"scroll"===e||"overlay"===e,o="x"===n?a.scrollLeft:a.scrollTop,s=Math.max(("x"===n?a.scrollWidth:a.scrollHeight)-("x"===n?a.clientWidth:a.clientHeight),0);if(t&&s>1&&(r>0&&o<s-1||r<0&&o>1))return!0}a=a.parentElement}return!1}function Y(e,t,n){const r=Math.max(.86*n,1);switch(e){case"PageDown":return r;case"PageUp":return-r;case" ":case"Spacebar":return t?-r:r;case"ArrowDown":return 80;case"ArrowUp":return-80;case"Home":return Number.NEGATIVE_INFINITY;case"End":return Number.POSITIVE_INFINITY;default:return 0}}function U(e,t){if(!(e instanceof Element))return!1;const n=e.tagName.toLowerCase();return!(" "!==t||!("button"===n||"summary"===n||"a"===n&&e.hasAttribute("href")||"button"===e.getAttribute("role")||"link"===e.getAttribute("role")))||"input"===n||"textarea"===n||"select"===n||!!(e instanceof HTMLElement&&e.isContentEditable)}function X(e){if(!(0,t.isValidElement)(e)||"string"==typeof e.type)return!1;let n=e.type;for(let e=0;e<6&&n;e+=1){if(("function"==typeof n||"object"==typeof n)&&null!==n&&!0===n.cineViewScene)return!0;if("object"==typeof n&&null!==n&&"type"in n)n=n.type;else{if("object"!=typeof n||null===n||!("render"in n))break;n=n.render}}return!1}function K(e){return e.layout?.overlap??"cover"}function Z(e,t,n,r){const i="takeover"===r,a=e=>i?Math.max(e,1):e;if("number"==typeof e&&Number.isFinite(e)&&e>0)return i?null:e;if("string"!=typeof e)return null;const o=e.trim().toLowerCase();if(!o||"auto"===o)return null;const s=Number.parseFloat(o);return!Number.isFinite(s)||s<=0?null:o.endsWith("px")?i?null:s:o.endsWith("vh")?a(n*s/100):o.endsWith("vw")?a(t*s/100):null}function _(e,t,n){return Z(e,t,n,"takeover")}function G(e,t,n){const r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a="x"===n?t.scrollLeft:t.scrollTop;return"x"===n?r.left-i.left+a:r.top-i.top+a}function J({direction:e,viewportSpan:r,scrollContentSpan:i,scrollOffset:a,scrollOffsetStore:o,isScrolling:s,config:c,onScrollToOffset:l}){const u=c.autoHide??!0,d=c.ariaLabel??"CineView scroll position",f=Math.max(c.width??6,4),m=Math.max(c.radius??999,0),g=Math.max(c.inset??0,0),p=c.trackColor??"transparent",h=c.thumbColor??"rgba(255, 255, 255, 0.28)",v=c.thumbHoverColor??h,[y,x]=(0,t.useState)(!1),[S,b]=(0,t.useState)(!1),w=(0,t.useRef)(null),E=(0,t.useRef)(null),M=Math.max(i-r,0),R=H(o?.getSnapshot()??a,0,M),k=(0,t.useRef)(R);k.current=R;const P=M+r,I=M>1,C=Math.max(r-2*g,1),A=M>0?H(r/Math.max(P,r)*C,Math.min(40,C),C):C,D=Math.max(C-A,0),T=M>0?H(R/M*D,0,D):0;(0,t.useEffect)(()=>{const t=()=>{const t=H(o?.getSnapshot()??a,0,M);if(k.current=t,w.current?.setAttribute("aria-valuenow",String(Math.round(t))),!E.current)return;const n=M>0?H(t/M*D,0,D):0;"x"===e?E.current.style.left=`${n}px`:E.current.style.top=`${n}px`};return t(),o?.subscribe(t)},[e,a,M,o,D]);const L=(0,t.useRef)(null);(0,t.useEffect)(()=>{L.current?.()},[e,M,l,C,A]);const O=(0,t.useCallback)(e=>{const t=Y(e.key,e.shiftKey,r);0!==t&&(l(t===Number.POSITIVE_INFINITY?M:t===Number.NEGATIVE_INFINITY?0:H(k.current+t,0,M)),e.preventDefault())},[M,l,r]),V=(0,t.useCallback)(t=>{if(M<=0||typeof window>"u"||"mouse"===t.pointerType&&0!==t.button||!1===t.isPrimary||(t.preventDefault(),L.current))return;const n=t.currentTarget.getBoundingClientRect(),r="x"===e?n.width:n.height,i="x"===e?n.left:n.top,a="x"===e?t.clientX:t.clientY,o=M>0?H(k.current/M*Math.max(r-A,0),0,Math.max(r-A,0)):0,s=a-i,c=s>=o&&s<=o+A,u=c?s-o:A/2,d=e=>{const t=Math.max(r-A,0),n=H(e-i-u,0,t);l((t>0?n/t:0)*M)};if(d(a),!c)return;const f=t.pointerId,m=t=>{t.pointerId===f&&(t.preventDefault(),d("x"===e?t.clientX:t.clientY))},g=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",p),L.current===g&&(L.current=null)};function p(e){e.pointerId===f&&g()}L.current=g,window.addEventListener("pointermove",m,{passive:!1}),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",p)},[e,M,l,A]);return(0,t.useEffect)(()=>()=>{L.current?.()},[]),I?(0,n.jsx)("div",{"data-cineview-scrollbar-overlay":"true",style:{position:"absolute",inset:0,zIndex:80,pointerEvents:"none",opacity:u?s||y?1:0:1,transition:u?s?"opacity 0.08s ease-out":"opacity 0.5s ease-in 0.15s":"none"},children:(0,n.jsx)("div",{ref:w,role:"scrollbar","aria-label":d,"aria-orientation":"x"===e?"horizontal":"vertical","aria-valuemin":0,"aria-valuemax":Math.round(M),"aria-valuenow":Math.round(R),tabIndex:0,"data-cineview-scrollbar-rail":"true",onPointerDown:V,onKeyDown:O,onFocus:()=>x(!0),onBlur:()=>x(!1),style:"x"===e?{position:"absolute",left:g,bottom:g,width:C,height:f,borderRadius:m,background:p,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.14)",pointerEvents:"auto",touchAction:"none",cursor:"pointer",outline:y?"2px solid rgba(24, 119, 242, 0.95)":"none",outlineOffset:2}:{position:"absolute",top:g,right:g,width:f,height:C,borderRadius:m,background:p,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.14)",pointerEvents:"auto",touchAction:"none",cursor:"pointer",outline:y?"2px solid rgba(24, 119, 242, 0.95)":"none",outlineOffset:2},children:(0,n.jsx)("div",{ref:E,"data-cineview-scrollbar-thumb":"true",onPointerEnter:()=>b(!0),onPointerLeave:()=>b(!1),style:"x"===e?{position:"absolute",left:T,top:0,width:A,height:f,borderRadius:m,background:S?v:h,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.16)",cursor:"grab"}:{position:"absolute",top:T,left:0,width:f,height:A,borderRadius:m,background:S?v:h,boxShadow:"0 10px 24px rgba(53, 74, 116, 0.16)",cursor:"grab"}})})}):null}function Q(e,t){let n=e;const r=new Map;return{getSnapshot:()=>n,getKeySnapshot:e=>t(n,e),subscribeKey:(e,t)=>{const n=r.get(e)??new Set;return n.add(t),r.set(e,n),()=>{n.delete(t),0===n.size&&r.delete(e)}},setSnapshot:e=>{if(Object.is(n,e))return;const i=n;n=e,r.forEach((n,r)=>{Object.is(t(i,r),t(e,r))||n.forEach(e=>e())})}}}J.displayName="ScrollbarOverlay";var ee=typeof document<"u"?t.useLayoutEffect:t.useEffect,te={sceneLayout:null,sceneZoneState:null,sceneTimelineState:null,isCurrent:!1,isBackdropActive:!1,visualViewportOffset:0,isScrolling:!1,scrollDirection:null,activeSceneIndex:0,viewportWidth:0,viewportHeight:0,firstSceneEnterGateKnown:!1,firstSceneEnterActive:!1,firstSceneEnterReady:!1,direction:"y",sceneCount:0,sceneSizing:"content",exposeTakeoverDebugData:!1,takeoverSceneSpan:null},ne=(0,t.memo)(function({child:e,store:r,frameStore:i,sceneIndex:a,setWrapperRef:o,scrollCallbacks:s}){const c=(0,t.useCallback)(e=>r.subscribeKey(a,e),[a,r]),l=(0,t.useCallback)(()=>r.getKeySnapshot(a)??te,[a,r]),{sceneLayout:u,sceneZoneState:d,sceneTimelineState:f,isCurrent:m,isBackdropActive:g,visualViewportOffset:p,isScrolling:h,scrollDirection:v,activeSceneIndex:y,viewportWidth:x,viewportHeight:S,firstSceneEnterGateKnown:b,firstSceneEnterActive:w,firstSceneEnterReady:E,direction:M,sceneCount:R,sceneSizing:k,exposeTakeoverDebugData:P,takeoverSceneSpan:I}=(0,t.useSyncExternalStore)(c,l,l),C=!!e.props.scroll,A=(0,t.useRef)(null);ee(()=>{const e=A.current;if(!e)return;if(!P||!C||!i)return e.removeAttribute("data-cineview-takeover-progress-px"),void e.removeAttribute("data-cineview-takeover-viewport-offset");const t=()=>{const t=i.getKeySnapshot(a);e.setAttribute("data-cineview-takeover-progress-px",null==t?.zoneProgressPx?"":String(t.zoneProgressPx)),e.setAttribute("data-cineview-takeover-viewport-offset",t?String(t.visualViewportOffset):"")};return t(),i.subscribeKey(a,t)},[P,i,C,a]);const D=Math.max("x"===M?x:S,1),T="screen"===k&&!C,L=u?.flowSpan,O=u?.visualSpan??I??D,V=e.props.layout?.width??e.props.sceneWidth??"100vw",j=C?Math.max((O-D)/2,0):0,z=C?Math.max((D-O)/2,0):0,N=(0,t.useCallback)(e=>o(a,e),[a,o]),F=t.default.useRef(e.props.callbacks);F.current=e.props.callbacks;const $=t.default.useMemo(()=>({get onVisibilityChange(){const e=F.current?.onVisibilityChange,t=s?.onSceneVisibilityChange;return n=>{e?.(n),t?.(n)}}}),[s?.onSceneVisibilityChange]),B=t.default.useRef(e.props.layout);B.current=e.props.layout;const q=t.default.useMemo(()=>{const e=B.current;return C&&null!==I?{...e,..."x"===M?{width:I}:{height:I}}:"x"!==M||C?e:{...e,width:"auto"===V?"auto":"100%"}},[C,I,M,V]),H=t.default.useMemo(()=>({mode:"scroll",direction:M,isActive:m,sceneIndex:a,totalScenes:R,currentSceneIndex:y,transitionDirection:v,isSceneAnimating:h,sharedElapsedMs:0,sharedTimelineDurationMs:0,viewportWidth:x,viewportHeight:S,firstSceneEnterGateKnown:b,firstSceneEnterActive:w,firstSceneEnterReady:E}),[M,m,a,R,y,v,h,x,S,b,w,E]),W=t.default.useMemo(()=>({progress:f?.sceneProgress??0,isScrolling:h,direction:v,transitionSnapshot:null,backdropActive:g,timelineState:f,activeSceneIndex:y,viewportOffset:p,onProgressChange:void 0,onDirectionChange:void 0,onScrollingChange:void 0,onCommit:void 0,onReset:void 0,frameStore:i,sceneIndex:a}),[f,h,v,g,y,p,i,a]),Y=t.default.cloneElement(e,{layout:q,callbacks:$,sceneRuntime:H,scrollRuntime:W});return(0,n.jsx)("div",{ref:N,"data-scene-index":a,style:{position:"relative",width:"x"===M?C&&"number"==typeof L?L:C?"100vw":V:"100%",flex:"x"===M?"0 0 auto":void 0,minHeight:"y"===M&&T?"100vh":void 0,minWidth:"x"===M&&T?"100vw":void 0,...C&&"number"==typeof L?"x"===M?{boxSizing:"border-box",paddingLeft:j}:{boxSizing:"border-box",paddingTop:j,height:L}:{}},children:C?(0,n.jsx)("div",{ref:A,"data-cineview-takeover-shell":a,...P?{"data-cineview-takeover-active-zone":d?.active?d.zoneId:"","data-cineview-takeover-total-distance-px":d?.totalBudgetPx??"","data-cineview-takeover-center-lock-offset":u?.centerLockOffset??"","data-cineview-takeover-segment-start":u?.segmentStart??"","data-cineview-takeover-segment-end":u?.segmentEnd??""}:{},style:"x"===M?{position:"sticky",left:z,width:O,maxWidth:"100vw",height:"100%",overflow:"hidden",zIndex:d?.active?30:void 0}:{position:"sticky",top:z,width:"100%",height:O,maxHeight:"100vh",overflow:"hidden",zIndex:d?.active?30:void 0},children:(0,n.jsx)("div",{"data-cineview-takeover-content":a,style:"x"===M?{width:O,height:"100%",transform:`translateX(${-j}px)`}:{width:"100%",height:O,transform:`translateY(${-j}px)`},children:Y})}):Y},e.key??`scene-${a}`)});function re({childrenArray:e,store:r,frameStore:i,setWrapperRef:a,scrollCallbacks:o}){let s=0;return(0,n.jsx)(n.Fragment,{children:e.map((e,c)=>{if(!X(e))return(0,n.jsx)(t.default.Fragment,{children:e},`flow-${c}`);const l=s++;return(0,n.jsx)(ne,{child:e,store:r,frameStore:i,sceneIndex:l,setWrapperRef:a,scrollCallbacks:o},e.key??`scene-${l}`)})})}var ie=(0,t.createContext)(null),ae=(0,t.createContext)(null),oe=(0,t.createContext)(null);function se(e){return Number.isFinite(e)?Math.max(0,e):0}function ce(e,t,n){return Math.min(n,Math.max(t,e))}function le(e,t,n,r){return void 0===e?t:n+(r-n)*ce(e,0,1)}function ue(e,t,n,r,i,a){const o=n.get(e);if(o)return o;const s=t.get(e);if(!s){const t={animateId:e,startMs:0,enterStartMs:0,enterEndMs:0,exitStartMs:null,exitEndMs:null,totalEndMs:0,hasExit:!1};return n.set(e,t),t}if(r.has(e)){const t=[...r],a=t.indexOf(e);t.slice(a).forEach(e=>i.add(e));const o={animateId:e,startMs:se(s.delay),enterStartMs:se(s.delay),enterEndMs:se(s.delay)+se(s.enterDuration),exitStartMs:null,exitEndMs:null,totalEndMs:se(s.delay)+se(s.enterDuration),hasExit:!1};return n.set(e,o),o}r.add(e);let c=0;if(s.after){const o=ue(s.after,t,n,r,i,a);i.has(e)||(c=a.get(s.after)??o.enterEndMs)}const l=c+se(s.delay),u=Math.max(se(s.enterDuration),1),d=se(s.exitDuration),f=l+u,m=d>0,g=m?f+d:null,p={animateId:e,startMs:l,enterStartMs:l,enterEndMs:f,exitStartMs:m?f:null,exitEndMs:g,totalEndMs:g??f,hasExit:m};return n.set(e,p),r.delete(e),p}function de(e){const t=new Map,n=new Set;let r=new Map,i=e;const a=[...e.values()].some(e=>void 0!==e.phase?.start||void 0!==e.phase?.end),o=()=>{i.forEach((e,a)=>{ue(a,i,t,new Set,n,r)})};o();let s,c=0;if(a){const a=function(e,t){const n=new Set;e.forEach((e,t)=>{[e.phase?.start,e.phase?.end].some(e=>void 0!==e&&!Number.isFinite(e))&&n.add(t)});const r=(e,t)=>e.map(e=>({...e,offset:e.offset+t})),i=(...e)=>{const t=new Map;return e.flat().forEach(e=>{(!t.has(e.fraction)||t.get(e.fraction).offset<e.offset)&&t.set(e.fraction,e)}),[...t.values()]};for(;;){const a=new Map,o=[],s=c=>{const l=a.get(c);if(l)return l;const u=e.get(c);if(!u)return[{fraction:0,offset:0}];const d=!!u.after&&!t.has(c),f=d?s(u.after):[{fraction:0,offset:0}],m=r(f,se(u.delay)),g=r(m,Math.max(se(u.enterDuration),1));o.push(...r(g,se(u.exitDuration)));const p=n.has(c)?void 0:u.phase;let h=g;if(void 0!==p?.start||void 0!==p?.end){const e=void 0===p.start?m:i([{fraction:ce(p.start,0,1),offset:0,phaseId:c}],d?m:[]);h=i(void 0===p.end?g:[{fraction:ce(p.end,0,1),offset:0,phaseId:c}],r(e,1)),o.push(...r(h,u.exitDuration>0?1:0))}return a.set(c,h),h};e.forEach((e,t)=>s(t));let c=0;const l=n.size;if(o.forEach(e=>{const t=e.fraction<1?e.offset/(1-e.fraction):0===e.offset?0:1/0;!Number.isFinite(t)&&e.phaseId?n.add(e.phaseId):c=Math.max(c,t)}),n.size!==l)continue;const u=new Map;return a.forEach((e,t)=>{u.set(t,e.reduce((e,t)=>Math.max(e,t.fraction*c+t.offset),0))}),{enterEnds:u,totalDurationMs:c,invalidPhaseIds:n}}}(e,n);c=a.totalDurationMs,r=a.enterEnds,s=a.invalidPhaseIds,s.size>0&&(i=new Map(e),s.forEach(t=>{i.set(t,{...e.get(t),phase:void 0})})),t.clear(),n.clear(),o()}t.forEach(e=>{c=Math.max(c,e.totalEndMs)});const l=c>0?Math.max(1*c,1):0,u={};return t.forEach((e,t)=>{const r=i.get(t),a=void 0!==r?.phase?.start||void 0!==r?.phase?.end,o={...e,startPx:1*e.startMs,enterStartPx:1*e.enterStartMs,enterEndPx:1*e.enterEndMs,exitStartPx:null===e.exitStartMs?null:1*e.exitStartMs,exitEndPx:null===e.exitEndMs?null:1*e.exitEndMs,totalEndPx:1*e.totalEndMs,phaseStartPx:0,phaseEndPx:0},s=o.enterStartPx,c=Math.max(o.enterEndPx,s+1),d=a?0:s,f=a?l:c,m=Math.max(le(r?.phase?.start,s,d,f),r?.after&&!n.has(t)?s:0),g=Math.max(le(r?.phase?.end,c,d,f),m+1);if(o.phaseStartPx=m,o.phaseEndPx=g,a)if(o.hasExit){const t=se((e.exitEndMs??e.totalEndMs)-(e.exitStartMs??e.enterEndMs)),n=1*Math.max(t,1);o.exitEndPx=l,o.exitStartPx=Math.max(g,l-n),o.totalEndPx=o.exitEndPx}else o.totalEndPx=g;u[t]=o}),{budgets:u,totalDurationMs:c,totalBudgetPx:l,...s?.size?{invalidPhaseIds:[...s]}:{}}}var fe=(0,t.createContext)(null);function me(){return(0,t.useContext)(fe)}var ge=(0,t.forwardRef)(function({children:e,designWidth:r,direction:i,sceneSizing:a="content",enterMargin:o,exitMargin:s,scrollbar:c,callbacks:l,monitor:u,debug:d},f){const{designSize:m}=function(e){const t=e;return"number"==typeof t&&Number.isFinite(t)&&t>0?{designSize:t}:{designSize:750}}(r),g=(0,t.useMemo)(()=>function(e){return e?{common:{onReady:e.onReady,onLoadProgress:e.onLoadProgress,onSceneEnter:e.onSceneEnter,onSceneLeave:e.onSceneLeave,onError:e.onError},drag:{onDragStart:e.onDragStart,onDragProgress:e.onDragProgress,onDragBlocked:e.onDragBlocked,onDragEnd:e.onDragEnd,onDragCancel:e.onDragCancel},scroll:{onZoneEnter:e.onZoneEnter,onZoneLeave:e.onZoneLeave,onZoneProgress:e.onZoneProgress,onSceneVisibilityChange:e.onSceneVisibilityChange}}:{common:{},drag:{},scroll:{}}}({onReady:l?.onReady,onLoadProgress:l?.onLoadProgress,onSceneEnter:l?.onSceneEnter,onSceneLeave:l?.onSceneLeave,onError:l?.onError,onDragStart:l?.onDragStart,onDragProgress:l?.onDragProgress,onDragBlocked:l?.onDragBlocked,onDragEnd:l?.onDragEnd,onDragCancel:l?.onDragCancel,onZoneEnter:l?.onZoneEnter,onZoneLeave:l?.onZoneLeave,onZoneProgress:l?.onZoneProgress,onSceneVisibilityChange:l?.onSceneVisibilityChange}),[l?.onReady,l?.onLoadProgress,l?.onSceneEnter,l?.onSceneLeave,l?.onError,l?.onDragStart,l?.onDragProgress,l?.onDragBlocked,l?.onDragEnd,l?.onDragCancel,l?.onZoneEnter,l?.onZoneLeave,l?.onZoneProgress,l?.onSceneVisibilityChange]),p=i??"y",v=(0,t.useRef)(null),y=(0,t.useRef)(0),x=(0,t.useRef)(function(){let e=0;const t=new Set;return{getSnapshot:()=>e,subscribe:e=>(t.add(e),()=>t.delete(e)),setSnapshot:n=>{Object.is(e,n)||(e=n,t.forEach(e=>e()))}}}()),b=(0,t.useRef)(null),w=(0,t.useRef)(()=>{}),E=(0,t.useRef)(0),M=(0,t.useRef)(null),R=(0,t.useRef)([]),[k,P,C,A]=(0,t.useMemo)(()=>{const n=new Map,r=[],i=[];let a=!1;return[t.Children.toArray(e).map(e=>{if(a||(a=!1),!X(e))return e;const o=i.length,s=e;let c=s;if(s.props.scroll){const e=s.props.scroll.zoneId??s.props.sceneId;if(void 0!==e){const i=n.get(e);void 0===i?n.set(e,o):(r[o]=[e,i],c=t.default.cloneElement(s,{scroll:void 0}))}}return i.push(c),c}),i,r,a]},[e]);R.current=P;const{viewportSize:D,viewportSizeRef:T,getViewportSpan:j,updateViewportMetrics:ne}=function({rootRef:e,direction:n}){const[r,i]=(0,t.useState)({width:0,height:0}),a=(0,t.useRef)({width:0,height:0});return{viewportSize:r,viewportSizeRef:a,getViewportSpan:(0,t.useCallback)(()=>{const t=e.current;return Math.max("x"===n?t?.clientWidth??a.current.width:t?.clientHeight??a.current.height,1)},[n,e]),updateViewportMetrics:(0,t.useCallback)(()=>{const t=e.current;if(!t)return;const n=t.clientWidth,r=t.clientHeight;a.current={width:n,height:r},i(e=>e.width===n&&e.height===r?e:{width:n,height:r})},[e])}}({rootRef:v,direction:p}),{zoneRegistryRef:oe,zoneStatesRef:se,timelineStoreRef:ce,zoneRuntimeVersion:le,getZoneIdForScene:ue,getZoneDistance:me,zoneRuntimeValue:ge,zoneTimelineValue:pe}=function({scrollOffsetRef:e,measureSceneLayoutsRef:n,updateSceneRenderSnapshotsRef:r,onError:i}){const a=(0,t.useRef)(i);a.current=i;const o=(0,t.useRef)(new WeakSet),s=(0,t.useRef)(new Map),c=(0,t.useRef)(new Map),l=(0,t.useRef)({}),u=(0,t.useRef)(Q({},(e,t)=>e[t])),[d,f]=(0,t.useState)(0),m=(0,t.useCallback)(e=>{for(const[t,n]of s.current.entries())if(n.sceneIndex===e)return t;return null},[]),g=(0,t.useCallback)(e=>{const t=m(e);return t?l.current[t]?.totalBudgetPx??0:0},[m]),p=(0,t.useCallback)((t,n)=>{const i=l.current,a=n(i[t]);if(a){const e=i[t];if(e&&e.sceneIndex===a.sceneIndex&&e.progressPx===a.progressPx&&e.totalBudgetPx===a.totalBudgetPx&&e.active===a.active&&e.direction===a.direction&&e.approach===a.approach&&function(e,t){if(e.totalDurationMs!==t.totalDurationMs||e.totalBudgetPx!==t.totalBudgetPx||(e.invalidPhaseIds??[]).join("\0")!==(t.invalidPhaseIds??[]).join("\0"))return!1;const n=Object.keys(e.budgets);return n.length===Object.keys(t.budgets).length&&n.every(n=>{const r=e.budgets[n],i=t.budgets[n];return!!(r&&i&&function(e,t){return e.animateId===t.animateId&&e.startMs===t.startMs&&e.enterStartMs===t.enterStartMs&&e.enterEndMs===t.enterEndMs&&e.exitStartMs===t.exitStartMs&&e.exitEndMs===t.exitEndMs&&e.totalEndMs===t.totalEndMs&&e.startPx===t.startPx&&e.enterStartPx===t.enterStartPx&&e.enterEndPx===t.enterEndPx&&e.exitStartPx===t.exitStartPx&&e.exitEndPx===t.exitEndPx&&e.totalEndPx===t.totalEndPx&&e.phaseStartPx===t.phaseStartPx&&e.phaseEndPx===t.phaseEndPx&&e.hasExit===t.hasExit}(r,i))})}(e.sequence,a.sequence))return;l.current={...i,[t]:a}}else{if(!(t in i))return;const e={...i};delete e[t],l.current=e}u.current.setSnapshot(l.current),r.current(e.current)},[e,r]),h=(0,t.useCallback)(e=>{const t=s.current.get(e);if(!t)return void p(e,()=>null);const n=c.current.get(e)??new Map,r=de(n);r.invalidPhaseIds?.forEach(t=>{const r=n.get(t);if(!r||o.current.has(r))return;o.current.add(r);const i=`Animate "${t}" has an invalid timeline.phase in zone "${e}". Its phase cannot fit reachable entrance and exit intervals in a finite zone budget; using duration, delay and after instead.`;a.current?.({code:"INVALID_ANIMATION",message:i,context:{zoneId:e,animateId:t,field:"timeline.phase"}})}),p(e,n=>({zoneId:e,sceneIndex:t.sceneIndex,progressPx:Math.min(r.totalBudgetPx,Math.max(n?.progressPx??0,0)),totalBudgetPx:r.totalBudgetPx,active:n?.active??!1,direction:n?.direction??null,sequence:r,approach:n?.approach??"near"})),f(e=>e+1)},[p]);(0,t.useRef)(new Set);const v=(0,t.useCallback)((e,t)=>{const n=s.current.get(e);if(!n||n.sceneIndex===t.sceneIndex){if(n)return void h(e);s.current.set(e,{...t,element:null}),h(e)}},[h]),y=(0,t.useCallback)((e,t)=>{s.current.get(e)?.sceneIndex===t&&(s.current.delete(e),c.current.delete(e),p(e,()=>null),f(e=>e+1))},[p]),x=(0,t.useCallback)((e,t,r)=>{const i=s.current.get(e);!i||i.sceneIndex!==t||(i.element=r,n.current?.())},[n]),S=(0,t.useCallback)((e,t)=>{const n=c.current.get(e)??new Map;return n.set(t.animateId,t),c.current.set(e,n),h(e),t},[h]),b=(0,t.useCallback)((e,t,n)=>{const r=c.current.get(e);!r||r.get(t)!==n||(r.delete(t),h(e))},[h]);return{zoneRegistryRef:s,zoneAnimationsRef:c,zoneStatesRef:l,timelineStoreRef:u,zoneRuntimeVersion:d,getZoneIdForScene:m,getZoneDistance:g,syncZoneState:p,recomputeZoneSequence:h,zoneRuntimeValue:(0,t.useMemo)(()=>({registerZone:v,unregisterZone:y,setZoneElement:x,registerZoneAnimation:S,unregisterZoneAnimation:b}),[v,y,x,S,b]),zoneTimelineValue:(0,t.useMemo)(()=>({store:u.current}),[])}}({scrollOffsetRef:y,measureSceneLayoutsRef:b,updateSceneRenderSnapshotsRef:w,onError:g.common?.onError}),{sceneLayoutsRef:he,sceneWrapperRefs:ve,measureSceneLayouts:ye,setSceneWrapperRef:xe}=function({rootRef:e,direction:n,scenes:r,sceneSizing:i,getViewportSpan:a,getZoneIdForScene:o,getZoneDistance:s,zoneRegistryRef:c,scrollOffsetRef:l,updateSceneRenderSnapshotsRef:u}){const d=(0,t.useRef)([]),f=(0,t.useRef)([]);return{sceneLayoutsRef:d,sceneWrapperRefs:f,measureSceneLayouts:(0,t.useCallback)(()=>{const t=e.current;if(!t)return d.current;const m=a(),g=r.map((e,a)=>{const l=f.current[a],u=e.props,d=function(e){return{enterAnimation:e.transition?.enterAnimation??e.enterAnimation,exitAnimation:e.transition?.exitAnimation??e.exitAnimation,transitionDurationMs:e.sceneTransitionDuration??800,scrollEnterLength:e.scrollEnterLength,scrollExitLength:e.scrollExitLength}}(u),g=!!u.scroll,p=g?_("x"===n?u.layout?.width??u.sceneWidth:u.layout?.height??u.sceneHeight,t.clientWidth,t.clientHeight):null,h=o(a),v=h?c.current.get(h)?.element:null,y=g?p:function(e,t,n,r){return Z("x"===t?e.layout?.width??e.sceneWidth:e.layout?.height??e.sceneHeight,n,r,"declared")}(u,n,t.clientWidth,t.clientHeight),x="x"===n?Math.max(g?v?.offsetWidth??0:l?.offsetWidth??0,g?v?.clientWidth??0:l?.clientWidth??0,0):Math.max(g?v?.offsetHeight??0:l?.offsetHeight??0,g?v?.clientHeight??0:l?.clientHeight??0,0),S=g?Math.max(p??x,1):"screen"===i?Math.max(x,y??0,m,1):Math.max(x,y??0,1),b=g?s(a):0,w=g?Math.max(S,m)+b:S,E=l?G(l,t,n):0,M=E+w,R=Math.max(E+S/2-m/2,0),k=!!(d.enterAnimation&&a>0),P=!!(d.exitAnimation&&a<r.length-1),I=Math.max(0,d.scrollEnterLength??(k?d.transitionDurationMs:0)),C=Math.max(0,d.scrollExitLength??(P?d.transitionDurationMs:0)),A=Math.max(Math.min(w,m),1);return{sceneStart:E,sceneEnd:M,visualSpan:S,flowSpan:w,timelineDistancePx:b,centerLockOffset:R,segmentStart:R,segmentEnd:R+b,enterLength:Math.min(I,A),exitLength:Math.min(C,A),stackMode:K(u)}});return d.current=function(e,t){return e.length===t.length&&t.every((t,n)=>{const r=e[n];return r.sceneStart===t.sceneStart&&r.sceneEnd===t.sceneEnd&&r.visualSpan===t.visualSpan&&r.flowSpan===t.flowSpan&&r.timelineDistancePx===t.timelineDistancePx&&r.centerLockOffset===t.centerLockOffset&&r.segmentStart===t.segmentStart&&r.segmentEnd===t.segmentEnd&&r.enterLength===t.enterLength&&r.exitLength===t.exitLength&&r.stackMode===t.stackMode})}(d.current,g)?d.current:g,u.current(l.current),d.current},[n,a,s,o,e,i,r,l,u,c]),setSceneWrapperRef:(0,t.useCallback)((e,t)=>{f.current[e]=t},[])}}({rootRef:v,direction:p,scenes:P,sceneSizing:a,getViewportSpan:j,getZoneIdForScene:ue,getZoneDistance:me,zoneRegistryRef:oe,scrollOffsetRef:y,updateSceneRenderSnapshotsRef:w}),Se=(0,t.useRef)(!1),be=function(e){return void 0!==e?e:!(typeof window>"u"||!window.__CINEVIEW_SCROLL_DEBUG__)}(d),we=(0,t.useMemo)(()=>{const e=q(P[0]?.props??{}),t=new Set(e);return{priorityImages:e,backgroundImages:Array.from(new Set(P.flatMap(e=>q(e.props).filter(e=>!t.has(e)))))}},[P]),[Ee,Me]=((e={})=>{const{priorityUrls:n=[],backgroundUrls:r=[],onProgress:i,onComplete:a,onError:o}=e,[s,c]=(0,t.useState)(!1),[l,u]=(0,t.useState)(0),[d,f]=(0,t.useState)(0),[m,g]=(0,t.useState)(n.length+r.length),[p,h]=(0,t.useState)([]),[v,y]=(0,t.useState)(new Map),[x,b]=(0,t.useState)(!1),w=(0,t.useRef)([...n]),E=(0,t.useRef)([...r]),M=(0,t.useRef)(!1),R=(0,t.useRef)(new Map),k=(0,t.useRef)(0),P=(0,t.useRef)(null),C=(0,t.useRef)(new Set),A=(0,t.useRef)(new Set),D=(0,t.useRef)(0),T=(0,t.useRef)(0),j=(0,t.useRef)(i),z=(0,t.useRef)(a),N=(0,t.useRef)(o);(0,t.useEffect)(()=>{j.current=i,z.current=a,N.current=o},[i,a,o]);const F=(0,t.useCallback)((e,t)=>{const n=O(e).filter(e=>!C.current.has(e));if(0===n.length)return;const r=new Set(w.current),i=new Set(E.current),a=n.filter(e=>!r.has(e)&&!i.has(e));0!==a.length&&(t?w.current=[...w.current,...a]:E.current=[...E.current,...a])},[]);(0,t.useEffect)(()=>{F(n,!0),F(r,!1),M.current||g(w.current.length+E.current.length)},[n,r,F]);const $=(0,t.useCallback)((e,t)=>{const n=I(e);return n?L(e,n).then(()=>(S(e),{url:e,success:!0})).catch(n=>{const r=n instanceof Error?n:new Error(String(n));return k.current===t&&N.current?.(e,r),{url:e,success:!1,error:r}}):new Promise(n=>{const r=new Image,i=new AbortController;R.current.set(e,i);let a=!1,o=null;const s=t=>{a||(a=!0,null!==o&&(clearTimeout(o),o=null),R.current.delete(e),n(t))};r.onload=()=>{S(e),s({url:e,success:!0})},r.onerror=()=>{const n=new Error(`Failed to load image: ${e}`);k.current===t&&N.current?.(e,n),s({url:e,success:!1,error:n})},i.signal.addEventListener("abort",()=>{r.src="",s({url:e,success:!1,error:new Error("Image load aborted")})}),o=setTimeout(()=>{o=null,r.onload=null,r.onerror=null,r.src="";const n=new Error(`Image load timed out after 15000ms: ${e}`);k.current===t&&N.current?.(e,n),s({url:e,success:!1,error:n})},15e3),r.src=e})},[]),B=(0,t.useCallback)((e,t)=>{const n=Math.max(t,0),r=n>0?Math.min(Math.max(e,0),n):0,i=n>0?Math.round(r/n*100):100;u(i),f(r),j.current?.(i)},[]),q=(0,t.useCallback)(()=>{if(M.current)return P.current??Promise.resolve();const e=(async()=>{const e=k.current+1;k.current=e,M.current=!0,c(!0),u(0),f(0),h([]),y(new Map),b(!1),A.current=new Set,D.current=0,T.current=0;const t=V(w.current,E.current,C.current,A.current),n=t.priorityBatch.length+t.backgroundBatch.length;if(T.current=n,g(n),0===n)return B(0,0),k.current===e&&(c(!1),b(!0)),M.current=!1,void z.current?.([]);const r=new Set(t.priorityBatch);let i=0===r.size;i&&b(!0);const a=[],o=new Map,s=()=>{const e=V(w.current,E.current,C.current,A.current);return T.current=D.current+e.priorityBatch.length+e.backgroundBatch.length,g(T.current),e},l=(e,t)=>{a.push(t),A.current.add(e),D.current+=1,!t.success&&t.error?o.set(e,t.error):t.success&&C.current.add(e),B(D.current,T.current),i||(r.delete(e),0===r.size&&(i=!0,b(!0)))};for(;;){const{priorityBatch:t,backgroundBatch:n}=s();if(0===t.length&&0===n.length)break;if(await Promise.all(t.map(async t=>{const n=await $(t,e);k.current===e&&l(t,n)})),k.current!==e)return;const r=await Promise.all(n.map(async t=>({url:t,result:await $(t,e)})));if(k.current!==e)return;r.forEach(({url:e,result:t})=>{l(e,t)})}h(a),y(o),c(!1),M.current=!1,g(w.current.length+E.current.length),z.current?.(a)})();return P.current=e.finally(()=>{P.current===e&&(P.current=null)}),P.current},[$,B]),H=(0,t.useCallback)(()=>{k.current+=1,R.current.forEach(e=>{e.abort()}),R.current.clear(),c(!1),u(0),f(0),g(w.current.length+E.current.length),h([]),y(new Map),b(!1),C.current.clear(),A.current.clear(),D.current=0,T.current=0,M.current=!1,P.current=null},[]),W=(0,t.useCallback)((e,t=!1)=>{F(e,t);const{priorityBatch:n,backgroundBatch:r}=V(w.current,E.current,C.current,A.current),i=M.current?D.current+n.length+r.length:n.length+r.length;M.current&&(T.current=i),g(i)},[F]);return(0,t.useEffect)(()=>{const e=R.current;return()=>{k.current+=1,M.current=!1,P.current=null,e.forEach(e=>{e.abort()}),e.clear()}},[]),[{isLoading:s,progress:l,loadedCount:d,totalCount:m,results:p,errors:v,priorityComplete:x},{startPreload:q,reset:H,addUrls:W}]})({priorityUrls:we.priorityImages,backgroundUrls:we.backgroundImages,onProgress:g.common?.onLoadProgress}),Re=Me.startPreload,ke=(0,t.useRef)({loadedCount:0,totalCount:0});ke.current={loadedCount:Ee.loadedCount,totalCount:Ee.totalCount};const Pe=(0,t.useCallback)((e,t,n)=>{let r=!1;return g.common?.onError?.({code:e,message:t,context:n,preventDefault:()=>{r=!0}}),r},[g.common]),Ie=(0,t.useSyncExternalStore)(N,z,()=>!1),Ce=P.length;(0,t.useEffect)(()=>{0===Ce&&Pe("EMPTY_SCENES","Cineview requires at least one Scene child.",{mode:"scroll"})},[Pe,Ce]);const Ae=(0,t.useRef)(void 0);(0,t.useEffect)(()=>{Ae.current!==C&&(Ae.current=C,C.forEach(([e,t],n)=>{Pe("INVALID_COMPONENT_HIERARCHY",`Duplicate scroll zone id "${e}".`,{reason:"duplicate-scroll-zone",zoneId:e,ownerSceneIndex:t,rejectedSceneIndex:n})}))},[C,Pe]);const De=(0,t.useCallback)(()=>({loadedCount:ke.current.loadedCount,totalCount:ke.current.totalCount}),[]),{firstSceneEnterActive:Te,firstSceneEnterReady:Le}=function({enabled:e,hasFirstScene:n,priorityComplete:r,timeoutMs:i,preemptSignal:a=!1,emitRecoverableError:o,getPreloadCounts:s}){const[c,l]=(0,t.useState)(()=>e),[u,d]=(0,t.useState)(!1),[f,m]=(0,t.useState)(0),[g,p]=(0,t.useState)(null),h=(0,t.useRef)(!1),v=(0,t.useRef)(null),y=Math.max(0,i),x=(0,t.useRef)(o);x.current=o;const S=(0,t.useRef)(s);return S.current=s,(0,t.useEffect)(()=>{if(!e||h.current||!n)return;const t=e=>{p(e),m(e=>e+1)};return r?(h.current=!0,d(!0),void t("ready")):(null===v.current&&(v.current=setTimeout(()=>{v.current=null,h.current=!0;const e=S.current();x.current("FIRST_SCENE_TIMEOUT",`First scene priority assets did not load within ${y}ms.`,{sceneIndex:0,timeoutMs:y,loadedCount:e.loadedCount,totalCount:e.totalCount})||(h.current=!0,d(!1),l(!1),t("static"))},y)),()=>{v.current&&(clearTimeout(v.current),v.current=null)})},[e,n,r,y]),(0,t.useEffect)(()=>{a&&(h.current=!0,v.current&&(clearTimeout(v.current),v.current=null),d(!1),l(!1))},[a]),{firstSceneEnterActive:c,firstSceneEnterReady:u,firstSceneActivationToken:f,firstSceneActivationKind:g,handleComplete:(0,t.useCallback)(()=>{l(!1)},[])}}({enabled:P.length>0,hasFirstScene:!!P[0],priorityComplete:Ee.priorityComplete,timeoutMs:3e3,emitRecoverableError:Pe,getPreloadCounts:De}),Oe=(0,t.useCallback)(e=>function(e,t,n={}){if(!t||0===t.length)return[];const r=n.includeZoneIds??!1,i=new Set,a=[],o=e=>{e&&q(e.props).forEach(e=>{!e||i.has(e)||(i.add(e),a.push(e))})};return t.forEach(t=>{"number"!=typeof t?t&&e.forEach(e=>{e.props.sceneId!==t?r&&e.props.scroll?.zoneId===t&&o(e):o(e)}):Number.isInteger(t)&&t>=0&&t<e.length&&o(e[t])}),a}(P,e,{includeZoneIds:!0}),[P]);(0,t.useEffect)(()=>{Re()},[we,Re]);const{store:Ve,frameStore:je}=function({scenes:e,sceneLayoutsRef:n,timelineStoreRef:r,viewportSizeRef:i,activeSceneIndexRef:a,scrollDirectionRef:o,isScrollingStateRef:s,direction:c,sceneSizing:l,firstSceneEnterActive:u,firstSceneEnterReady:d,exposeTakeoverDebugData:f,scrollOffsetRef:m,updateSceneRenderSnapshotsRef:g}){const p=(0,t.useRef)(Q([],(e,t)=>e[t])),h=(0,t.useRef)(function(){let e=[];const t=new Map,n=e=>{t.get(e)?.forEach(e=>e())};return{setSnapshot:t=>{const r=e;e=Array.from(t);const i=Math.max(r.length,e.length);for(let t=0;t<i;t+=1)Object.is(r[t],e[t])||n(t)},setKeySnapshot:(t,r)=>{Object.is(e[t],r)||(e[t]=r,n(t))},clearFrom:t=>{if(e.length<=t)return;const r=e.length;e.length=t;for(let e=t;e<r;e+=1)n(e)},getKeySnapshot:t=>e[t],subscribeKey:(e,n)=>{const r=t.get(e)??new Set;return r.add(n),t.set(e,r),()=>{r.delete(n),0===r.size&&t.delete(e)}}}}()),v=(0,t.useRef)(null),[y,x]=(0,t.useState)(0),S=(0,t.useRef)(null),b=(0,t.useRef)([]),w=(0,t.useCallback)(t=>{const m=r.current.getSnapshot(),g=n.current,y=i.current,w=Math.max("x"===c?y.width:y.height,1),E=a.current,M="cover"===g[E]?.stackMode&&E>0?E-1:null,R=p.current.getSnapshot(),k=S.current,P=s.current,I=o.current,C=null===k||k[0]!==e||k[1]!==g||k[6]!==y.width||k[7]!==y.height||k[10]!==c||k[11]!==l||k[12]!==f,A=new Set,D=t=>{null!==t&&t>=0&&t<e.length&&A.add(t)},T=e=>{D(e-1),D(e),D(e+1)};if(C){b.current.length=0;for(const e in m){const t=m[e];b.current[t.sceneIndex]=t}for(let t=0;t<e.length;t+=1)A.add(t)}else{const[,,e,n,r,i,a,o,s,l]=k;for(const t in m){const n=m[t],r=e[t];n!==r&&(r&&r.sceneIndex!==n.sceneIndex&&b.current[r.sceneIndex]===r&&(b.current[r.sceneIndex]=void 0),b.current[n.sceneIndex]=n,D(r?.sceneIndex??null),D(n.sceneIndex))}for(const t in e){if(t in m)continue;const n=e[t];b.current[n.sceneIndex]===n&&(b.current[n.sceneIndex]=void 0),D(n.sceneIndex)}const f=Math.max("x"===c?a:o,1);for(let e=0;e<g.length;e+=1){const r=g[e],i=t<r.sceneEnd&&t+w>r.sceneStart,a=n<r.sceneEnd&&n+f>r.sceneStart;(i||a)&&D(e)}T(r),T(E),D(i),D(M),(s!==u||l!==d)&&D(0)}const L=C?[]:R.slice();let O=C;const V=C?new Array(e.length):null;A.forEach(n=>{const r=e[n];if(!r)return;const i=g[n]??null,a=b.current[n]??null,o=!!r.props.scroll,s=n===E||!!a?.active,m=M===n,p=o&&a?.active&&i?i.centerLockOffset:t,v=o&&i?i.centerLockOffset:t,x=i?function(e,t,n){if(!e)return null;const r=Math.max(n,1),i=t,a=t+r,o=i+r/2,s=e.sceneStart+e.enterLength,c=e.sceneEnd-Math.max(e.exitLength,0);let l,u=0,d=0;a<=e.sceneStart?l="before":i>=e.sceneEnd?(l="after",u=e.enterLength>0?1:0,d=e.exitLength>0?1:0):e.enterLength>0&&i<s?(l="enter",u=H((a-e.sceneStart)/Math.max(e.enterLength,1),0,1)):e.exitLength>0&&i>=c?(l="exit",d=H((i-c)/Math.max(e.exitLength,1),0,1),u=e.enterLength>0?1:0):(l="hold",u=e.enterLength>0?1:0);const f=Math.max(e.sceneEnd-e.sceneStart,1);return{phase:l,enterProgress:u,exitProgress:d,sceneProgress:H((o-e.sceneStart)/f,0,1),rangeStart:e.sceneStart,rangeEnd:e.sceneEnd,rangeLength:f,enterLength:e.enterLength,exitLength:e.exitLength}}(i,p,w):null,S=o?_("x"===c?r.props.layout?.width??r.props.sceneWidth:r.props.layout?.height??r.props.sceneHeight,y.width,y.height):null,k=s||m||"enter"===x?.phase||"hold"===x?.phase||"exit"===x?.phase,C={timelineState:x,progress:x?.sceneProgress??0,zoneProgressPx:a?.progressPx??null,visualViewportOffset:v,isCurrent:s,isBackdropActive:m,isScrolling:k&&P,scrollDirection:k&&P?I:null},A=h.current.getKeySnapshot(n),D=void 0!==A&&(A?.timelineState===C.timelineState||null!=A?.timelineState&&null!==C.timelineState&&A.timelineState.phase===C.timelineState.phase&&A.timelineState.enterProgress===C.timelineState.enterProgress&&A.timelineState.exitProgress===C.timelineState.exitProgress&&A.timelineState.sceneProgress===C.timelineState.sceneProgress&&A.timelineState.rangeStart===C.timelineState.rangeStart&&A.timelineState.rangeEnd===C.timelineState.rangeEnd&&A.timelineState.enterLength===C.timelineState.enterLength&&A.timelineState.exitLength===C.timelineState.exitLength)&&A.progress===C.progress&&A.zoneProgressPx===C.zoneProgressPx&&A.visualViewportOffset===C.visualViewportOffset&&A.isCurrent===C.isCurrent&&A.isBackdropActive===C.isBackdropActive&&A.isScrolling===C.isScrolling&&A.scrollDirection===C.scrollDirection;V?V[n]=C:D||h.current.setKeySnapshot(n,C);const T={sceneLayout:i,sceneZoneState:a,sceneTimelineState:x,isCurrent:s,isBackdropActive:m,visualViewportOffset:v,isScrolling:k&&P,scrollDirection:k&&P?I:null,activeSceneIndex:E,viewportWidth:y.width,viewportHeight:y.height,firstSceneEnterGateKnown:!0,firstSceneEnterActive:0===n&&u,firstSceneEnterReady:0===n&&d,direction:c,sceneCount:e.length,sceneSizing:l,exposeTakeoverDebugData:f,takeoverSceneSpan:S},j=R[n]??te;!function(e,t){const n=e.sceneTimelineState,r=t.sceneTimelineState,i=n===r||null!==n&&null!==r&&n.phase===r.phase&&n.rangeStart===r.rangeStart&&n.rangeEnd===r.rangeEnd&&n.rangeLength===r.rangeLength&&n.enterLength===r.enterLength&&n.exitLength===r.exitLength,a=e.sceneZoneState,o=t.sceneZoneState;return e.sceneLayout===t.sceneLayout&&(a===o||null!==a&&null!==o&&a.zoneId===o.zoneId&&a.sceneIndex===o.sceneIndex&&a.totalBudgetPx===o.totalBudgetPx&&a.active===o.active&&a.direction===o.direction&&a.approach===o.approach&&a.sequence===o.sequence)&&i&&e.isCurrent===t.isCurrent&&e.isBackdropActive===t.isBackdropActive&&e.isScrolling===t.isScrolling&&e.scrollDirection===t.scrollDirection&&e.activeSceneIndex===t.activeSceneIndex&&e.viewportWidth===t.viewportWidth&&e.viewportHeight===t.viewportHeight&&e.firstSceneEnterGateKnown===t.firstSceneEnterGateKnown&&e.firstSceneEnterActive===t.firstSceneEnterActive&&e.firstSceneEnterReady===t.firstSceneEnterReady&&e.direction===t.direction&&e.sceneCount===t.sceneCount&&e.sceneSizing===t.sceneSizing&&e.exposeTakeoverDebugData===t.exposeTakeoverDebugData&&e.takeoverSceneSpan===t.takeoverSceneSpan}(j,T)?(L[n]=T,O=!0):L[n]=j}),L.length=e.length,O&&p.current.setSnapshot(L),V?(v.current=V,x(e=>e+1)):h.current.clearFrom(e.length),S.current=[e,g,m,t,E,M,y.width,y.height,u,d,c,l,f]},[a,c,f,u,d,s,n,l,e,o,r,i]);return g.current=w,ee(()=>{const e=v.current;e&&(v.current=null,h.current.setSnapshot(e))},[y]),(0,t.useEffect)(()=>{w(m.current)},[m,w]),{store:p.current,frameStore:h.current,updateSceneRenderSnapshots:w}}({scenes:P,sceneLayoutsRef:he,timelineStoreRef:ce,viewportSizeRef:T,activeSceneIndexRef:E,scrollDirectionRef:M,isScrollingStateRef:Se,direction:p,sceneSizing:a,firstSceneEnterActive:Te,firstSceneEnterReady:Le,exposeTakeoverDebugData:be,scrollOffsetRef:y,updateSceneRenderSnapshotsRef:w});b.current=ye;const{isScrolling:ze,scrollContentSpan:Ne,syncNativeScrollState:Fe,applyNativeScrollDelta:$e,applyNativeScrollbarOffset:Be,goToScrollZone:qe,beginProgrammaticScroll:He}=function({rootRef:e,direction:n,getViewportSpan:r,updateViewportMetrics:i,measureSceneLayouts:a,sceneLayoutsRef:o,zoneRegistryRef:s,zoneStatesRef:c,timelineStoreRef:l,scrollOffsetRef:u,scrollOffsetStore:d,activeSceneIndexRef:f,scrollDirectionRef:m,isScrollingStateRef:g,updateSceneRenderSnapshotsRef:p,callbacks:h,zoneRuntimeVersion:v}){const y=(0,t.useRef)(null),x=(0,t.useRef)(!1),S=(0,t.useRef)(0),b=(0,t.useRef)(null),w=(0,t.useRef)({}),E=(0,t.useRef)({}),M=(0,t.useRef)(0),[R,k]=(0,t.useState)(!1),[P,I]=(0,t.useState)(1),C=(0,t.useRef)(1),A=(0,t.useCallback)(()=>{const t=e.current;return t?Math.max(("x"===n?t.scrollWidth:t.scrollHeight)-r(),0):0},[n,r,e]),D=(0,t.useCallback)(()=>o.current.filter(e=>e.segmentEnd-e.segmentStart>.5).map(e=>({segmentStart:e.segmentStart,segmentEnd:e.segmentEnd})).sort((e,t)=>e.segmentStart-t.segmentStart),[o]),T=(0,t.useCallback)((e,t)=>function({currentOffset:e,deltaPx:t,maxNativeOffset:n,segments:r=[]}){if(0===t)return H(e,0,n);const i=H(e,0,n),a=t===Number.POSITIVE_INFINITY?n:t===Number.NEGATIVE_INFINITY?0:H(i+t,0,n);if(0===r.length||Math.abs(a-i)<=.5)return a;if(a>i){const e=r.find(e=>i<e.segmentStart+.5&&a>e.segmentEnd+.5);if(e)return Math.min(e.segmentStart+1,e.segmentEnd);const t=r.find(e=>i>=e.segmentStart-.5&&i<e.segmentEnd-.5);return t&&a>t.segmentEnd+.5?t.segmentEnd:a}const o=[...r].reverse().find(e=>i>e.segmentEnd-.5&&a<e.segmentStart-.5);if(o)return Math.max(o.segmentEnd-1,o.segmentStart);const s=[...r].reverse().find(e=>i>e.segmentStart+.5&&i<=e.segmentEnd+.5);return s&&a<s.segmentStart-.5?s.segmentStart:a}({currentOffset:e,deltaPx:t,maxNativeOffset:A(),segments:D()}),[D,A]),L=(0,t.useCallback)(t=>{const r=e.current;if(!r)return;const i=H(t,0,A());"x"!==n?"function"==typeof r.scrollTo?r.scrollTo({top:i,behavior:"auto"}):r.scrollTop=i:"function"==typeof r.scrollTo?r.scrollTo({left:i,behavior:"auto"}):r.scrollLeft=i},[n,A,e]),O=(0,t.useCallback)(e=>{b.current=H(e,0,A())},[A]),V=(0,t.useCallback)(()=>{if(null===b.current)return;b.current=null;const t=e.current;if(!t)return;const r=H("x"===n?t.scrollLeft:t.scrollTop,0,A());L(r),S.current=r},[n,A,e,L]),j=(0,t.useCallback)((e,t=r())=>{const n=o.current;if(0===n.length)return;const i=e+t/2;let a=0,s=Number.POSITIVE_INFINITY;for(let e=0;e<n.length;e+=1){const t=n[e];if(i>=t.sceneStart&&i<t.sceneEnd){a=e;break}const r=i<t.sceneStart?t.sceneStart-i:i-t.sceneEnd;r<s&&(s=r,a=e)}if(f.current===a)return;const c=M.current;if(f.current=a,p.current(e),c===a)return;const l=a>=c?"forward":"backward";h.common?.onSceneEnter?.({fromIndex:c,toIndex:a,direction:l}),h.common?.onSceneLeave?.({fromIndex:c,toIndex:a,direction:l}),M.current=a},[f,h.common,r,o,p]),z=(0,t.useCallback)((e,t,n=r())=>{const i=w.current,a=c.current,u=n,d={};Object.entries(a).forEach(([n,r])=>{const i=o.current[r.sceneIndex];if(!i||r.totalBudgetPx<=0)return void(d[n]=0!==r.progressPx||r.active||null!==r.direction?{...r,progressPx:0,active:!1,direction:null}:r);const a=H(e-i.segmentStart,0,r.totalBudgetPx),s=a<=.01?0:r.totalBudgetPx-a<=.01?r.totalBudgetPx:a,c=e>i.segmentStart+.5&&e<i.segmentEnd-.5&&s>.5&&s<r.totalBudgetPx-.5,l=function(e,t,n){return e<=0?"inside":"far"===n?e<=1*t?"near":"far":e>1.5*t?"far":"near"}(Math.max(i.segmentStart-e,e-i.segmentEnd,0),u,r.approach),f={...r,progressPx:s,active:c,direction:c?t:null,approach:l};d[n]=r.progressPx===f.progressPx&&r.active===f.active&&r.direction===f.direction&&r.approach===f.approach?r:f});const f=Object.entries(d);Object.keys(a).length===f.length&&f.every(([e,t])=>a[e]===t)||(c.current=d,l.current.setSnapshot(d)),p.current(e),w.current=d,Object.entries(d).forEach(([e,t])=>{const n=i[e],r=s.current.get(e);if(!r)return;const a=E.current[e],o=0===t.progressPx||t.progressPx===t.totalBudgetPx;(void 0===a||Math.abs(a-t.progressPx)>.5||o&&a!==t.progressPx)&&(E.current[e]=t.progressPx,h.scroll?.onZoneProgress?.({zoneId:e,sceneIndex:r.sceneIndex,progress:t.totalBudgetPx>0?H(t.progressPx/t.totalBudgetPx,0,1):0})),!n?.active&&t.active?h.scroll?.onZoneEnter?.({zoneId:e,sceneIndex:r.sceneIndex}):n?.active&&!t.active&&h.scroll?.onZoneLeave?.({zoneId:e,sceneIndex:r.sceneIndex})})},[h.scroll,r,o,l,p,s,c]),N=(0,t.useCallback)((t=!1)=>{const o=e.current;if(!o)return;const s="x"===n?o.scrollLeft:o.scrollTop;if(t&&x.current&&null===b.current&&Math.abs(s-S.current)<=.01)return;t&&(x.current||(i(),a()),x.current=!0);const c=S.current,l=b.current;let f;null!==l?(f=H(s,0,A()),Math.abs(f-l)<=1&&(b.current=null)):(f=T(c,s-c),Math.abs(f-s)>.5&&L(f));const h=Math.abs(f-c)<=.5?m.current:f>c?"forward":"backward";S.current=f,u.current=f,d.setSnapshot(f),m.current=h,t&&(g.current=!0,k(e=>e||!0),null!==y.current&&window.clearTimeout(y.current),y.current=window.setTimeout(()=>{g.current=!1,k(!1),x.current=!1,y.current=null,p.current(u.current)},120));const v=r(),w=Math.max("x"===n?o.scrollWidth:o.scrollHeight,v);z(f,h,v),j(f,v),Math.abs(C.current-w)>.5&&(C.current=w,I(w))},[n,A,r,g,a,T,e,m,u,d,L,z,j,p,i]),F=(0,t.useCallback)(t=>{const r=e.current;if(!r||0===t)return!1;V();const i="x"===n?r.scrollLeft:r.scrollTop,a=T(i,t);return!(Math.abs(a-i)<=.5||(L(a),N(!0),0))},[V,n,T,e,L,N]),$=(0,t.useCallback)(t=>{V();const r=e.current,i=r?"x"===n?r.scrollLeft:r.scrollTop:u.current;L(T(i,t-i)),N(!0)},[V,n,T,e,u,L,N]),B=(0,t.useCallback)((t,r)=>{const i=e.current,a=c.current[t],s=a?o.current[a.sceneIndex]:null;if(i&&s){if(!1!==r?.animated)return O(s.centerLockOffset),void i.scrollTo({top:"x"===n?void 0:s.centerLockOffset,left:"x"===n?s.centerLockOffset:void 0,behavior:"smooth"});i.scrollTo({top:"x"===n?void 0:s.centerLockOffset,left:"x"===n?s.centerLockOffset:void 0,behavior:"auto"}),S.current=s.centerLockOffset,u.current=s.centerLockOffset,d.setSnapshot(s.centerLockOffset),z(s.centerLockOffset,null),j(s.centerLockOffset)}},[O,n,e,o,u,d,z,j,c]);return function({rootRef:e,direction:n,getViewportSpan:r,applyNativeScrollDelta:i}){const a=(0,t.useRef)(null);(0,t.useEffect)(()=>{const t=e.current;if(!t)return;const o=e=>e instanceof Element&&e.closest('[data-cineview-container="true"]')===t,s=e=>{if(e.defaultPrevented||!o(e.target))return;const a=function(e,t,n){return Number.isFinite(e)&&0!==e?1===t?18*e:2===t?e*Math.max(n,1):e:0}("x"===n?e.deltaX:e.deltaY,e.deltaMode,r());0!==a&&(W(e.target,t,n,a)||i(a)&&e.cancelable&&e.preventDefault())},c=e=>{if(!o(e.target))return;const t=e.touches[0];t&&(a.current={x:t.clientX,y:t.clientY})},l=e=>{const r=e.touches[0];if(!r||!a.current)return;if(e.defaultPrevented||!o(e.target))return void(a.current={x:r.clientX,y:r.clientY});const s=function(e){return Number.isFinite(e)?e:0}("x"===n?a.current.x-r.clientX:a.current.y-r.clientY);if(W(e.target,t,n,s))a.current={x:r.clientX,y:r.clientY};else if(0!==s){const t=i(s);a.current={x:r.clientX,y:r.clientY},t&&e.cancelable&&e.preventDefault()}},u=()=>{a.current=null};return t.addEventListener("wheel",s,{capture:!0,passive:!1}),t.addEventListener("touchstart",c,{passive:!0}),t.addEventListener("touchmove",l,{passive:!1}),t.addEventListener("touchend",u),t.addEventListener("touchcancel",u),()=>{t.removeEventListener("wheel",s,{capture:!0}),t.removeEventListener("touchstart",c),t.removeEventListener("touchmove",l),t.removeEventListener("touchend",u),t.removeEventListener("touchcancel",u),a.current=null}},[i,n,r,e]),(0,t.useEffect)(()=>{if(typeof window>"u")return;const e=e=>{if(e.defaultPrevented||function(e){return U(e.target,e.key)}(e))return;const t=Y(e.key,e.shiftKey,r());if(0===t)return;const n=document.activeElement;(n===document.body||n===document.documentElement)&&i(t)&&e.cancelable&&e.preventDefault()};return window.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0)}},[i,r])}({rootRef:e,direction:n,getViewportSpan:r,applyNativeScrollDelta:F}),(0,t.useEffect)(()=>()=>{null!==y.current&&(window.clearTimeout(y.current),y.current=null),b.current=null},[]),(0,t.useEffect)(()=>{i(),a(),N()},[a,N,i,v]),(0,t.useEffect)(()=>{if(typeof window>"u")return;const e=()=>{i(),a(),N()};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[a,N,i]),{isScrolling:R,scrollContentSpan:P,syncNativeScrollState:N,applyNativeScrollDelta:F,applyNativeScrollbarOffset:$,goToScrollZone:B,beginProgrammaticScroll:O}}({rootRef:v,direction:p,getViewportSpan:j,updateViewportMetrics:ne,measureSceneLayouts:ye,sceneLayoutsRef:he,zoneRegistryRef:oe,zoneStatesRef:se,timelineStoreRef:ce,scrollOffsetRef:y,scrollOffsetStore:x.current,activeSceneIndexRef:E,scrollDirectionRef:M,isScrollingStateRef:Se,updateSceneRenderSnapshotsRef:w,callbacks:g,zoneRuntimeVersion:le}),We=(0,t.useRef)(!1),Ye=(0,t.useRef)(null),Ue=(0,t.useCallback)(()=>{We.current=!1,ne(),ye(),Fe()},[ye,Fe,ne]);(0,t.useEffect)(()=>{if(typeof ResizeObserver>"u")return;const e=new ResizeObserver(()=>{null===Ye.current&&(Ye.current=window.requestAnimationFrame(()=>{Ye.current=null,Se.current?We.current=!0:Ue()}))});return ve.current.forEach(t=>{t&&e.observe(t)}),()=>{null!==Ye.current&&(window.cancelAnimationFrame(Ye.current),Ye.current=null),e.disconnect()}},[Ue,ve,P]),(0,t.useEffect)(()=>{ze||!We.current||Ue()},[ze,Ue]),(0,t.useEffect)(()=>{if(u)return(()=>{1===($+=1)&&F.start();let e=!1;return()=>{e||(e=!0,0===($=Math.max($-1,0))&&F.stop())}})()},[u]),(0,t.useEffect)(()=>{},[A]);const Xe=(0,t.useRef)(null),Ke=(0,t.useCallback)((e,t=!0)=>{if(e<0||e>=R.current.length)return;const n=v.current,r=ve.current[e];if(!n||!r)return;const i=G(r,n,p);He(i),n.scrollTo({top:"x"===p?void 0:i,left:"x"===p?i:void 0,behavior:t?"smooth":"auto"})},[He,p,ve]),Ze=(0,t.useCallback)(()=>{ne(),ye(),Fe()},[ye,Fe,ne]),_e=(0,t.useCallback)(async e=>{const t=Oe(e);t.length>0&&Me.addUrls(t,!0),await Re()},[Me,Oe,Re]);Xe.current||(Xe.current={goToScene:(e,t=!0)=>Ke(e,t),goToZone:(e,t)=>qe(e,t),refreshLayout:()=>Ze(),preload:e=>_e(e),getCurrentIndex:()=>E.current,getPerformanceMetrics:()=>B.getMetrics()});const Ge=Xe.current,Je=(0,t.useRef)(!1);(0,t.useEffect)(()=>{Je.current||(Je.current=!0,g.common?.onReady?.(Ge))},[g.common,Ge]),(0,t.useImperativeHandle)(f,()=>Ge,[Ge]);const Qe="object"==typeof c?c:{},et=Qe.autoHide??!0,tt="object"==typeof c&&!1!==c.enabled,nt={position:"relative",width:"100%",height:"100vh",minHeight:"100vh",overflowX:"x"===p?"scroll":"hidden",overflowY:"x"===p?"hidden":"scroll",overscrollBehavior:"contain",WebkitOverflowScrolling:"touch",scrollbarGutter:tt?"auto":"stable",background:"#ffffff"},rt=(0,t.useMemo)(()=>({mode:"scroll",scrollEnterMargin:o,scrollExitMargin:s,prefersReducedMotion:Ie,reportError:e=>{g.common?.onError?.({...e,code:e.code})}}),[o,s,g.common,Ie]);return(0,n.jsx)(h,{designSize:m,children:(0,n.jsx)(fe.Provider,{value:rt,children:(0,n.jsx)(ie.Provider,{value:ge,children:(0,n.jsxs)(ae.Provider,{value:pe,children:[tt&&(0,n.jsx)("style",{children:'\n [data-cineview-container="true"] {\n scrollbar-width: none;\n -ms-overflow-style: none;\n }\n [data-cineview-container="true"]::-webkit-scrollbar {\n width: 0;\n height: 0;\n display: none;\n }\n '}),"x"===p&&(0,n.jsx)("style",{children:'[data-cineview-scroll-stream="x"] > * { flex-shrink: 0; }'}),(0,n.jsxs)("div",{style:{position:"relative",width:"100%",height:"100vh",minHeight:"100vh"},children:[(0,n.jsx)("div",{ref:v,style:nt,className:"cineview-container","data-cineview-container":"true","data-cineview-scrollbar-autohide":String(et),tabIndex:0,onScroll:()=>Fe(!0),onKeyDownCapture:e=>{if(e.defaultPrevented||!(e.target instanceof Element)||e.target.closest('[data-cineview-container="true"]')!==e.currentTarget||U(e.target,e.key))return;const t=Y(e.key,e.shiftKey,j());0!==t&&!W(e.target,e.currentTarget,p,t)&&$e(t)&&e.preventDefault()},children:(0,n.jsx)("div",{"data-cineview-scroll-stream":p,style:"x"===p?{display:"flex",flexDirection:"row",alignItems:"stretch",width:"100%"}:void 0,children:(0,n.jsx)(re,{childrenArray:k,store:Ve,frameStore:je,setWrapperRef:xe,scrollCallbacks:g.scroll})})}),tt&&(0,n.jsx)(J,{direction:p,scrollContentSpan:Ne,viewportSpan:Math.max("x"===p?D.width:D.height,1),scrollOffset:y.current,scrollOffsetStore:x.current,isScrolling:ze,config:Qe,onScrollToOffset:Be})]})]})})})})});ge.displayName="DirectScrollCineview";var pe,he,ve,ye,xe,Se,be,we,Ee,Me,Re,ke=ge,Pe=g({fadeAnimations:()=>pe}),Ie=m(()=>{pe={fade:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}},"fade-in":{initial:{opacity:0},animate:{opacity:1},exit:{opacity:1}},"fade-out":{initial:{opacity:1},animate:{opacity:1},exit:{opacity:0}}}}),Ce=g({slideAnimations:()=>he}),Ae=m(()=>{he={"slide-up":{initial:{y:"100%",opacity:0},animate:{y:0,opacity:1},exit:{y:"-100%",opacity:0}},"slide-down":{initial:{y:"-100%",opacity:0},animate:{y:0,opacity:1},exit:{y:"100%",opacity:0}},"slide-left":{initial:{x:"100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"-100%",opacity:0}},"slide-right":{initial:{x:"-100%",opacity:0},animate:{x:0,opacity:1},exit:{x:"100%",opacity:0}}}}),De=g({zoomAnimations:()=>ve}),Te=m(()=>{ve={"zoom-in":{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0}},"zoom-out":{initial:{scale:1.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:1.5,opacity:0}},"scale-up":{initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:1.5,opacity:0}},"scale-down":{initial:{scale:1.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.5,opacity:0}}}}),Le=g({rotateAnimations:()=>ye}),Oe=m(()=>{ye={rotate:{initial:{rotate:-180,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:180,opacity:0}},"rotate-in":{initial:{rotate:-180,scale:0,opacity:0},animate:{rotate:0,scale:1,opacity:1},exit:{rotate:0,scale:1,opacity:1}},"rotate-out":{initial:{rotate:0,scale:1,opacity:1},animate:{rotate:0,scale:1,opacity:1},exit:{rotate:180,scale:0,opacity:0}},spin:{initial:{rotate:0,opacity:0},animate:{rotate:360,opacity:1},exit:{rotate:720,opacity:0}}}}),Ve=g({flipAnimations:()=>xe}),je=m(()=>{xe={flip:{initial:{rotateY:-180,opacity:0},animate:{rotateY:0,opacity:1},exit:{rotateY:180,opacity:0}},"flip-x":{initial:{rotateX:-180,opacity:0},animate:{rotateX:0,opacity:1},exit:{rotateX:180,opacity:0}},"flip-y":{initial:{rotateY:-180,opacity:0},animate:{rotateY:0,opacity:1},exit:{rotateY:180,opacity:0}}}}),ze=g({bounceAnimations:()=>Se}),Ne=m(()=>{Se={bounce:{initial:{y:-100,opacity:0},animate:{y:0,opacity:1,transition:{type:"spring",bounce:.5,duration:.8}},exit:{y:100,opacity:0}},"bounce-in":{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,transition:{type:"spring",bounce:.6,duration:.8}},exit:{scale:1,opacity:1}},"bounce-out":{initial:{scale:1,opacity:1},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0,transition:{type:"spring",bounce:.6,duration:.6}}}}}),Fe=g({blinkAnimations:()=>be}),$e=m(()=>{be={blink:{initial:{opacity:1},animate:{opacity:[1,0,1,0,1],transition:{duration:1,times:[0,.25,.5,.75,1]}},exit:{opacity:0}},flash:{initial:{opacity:0},animate:{opacity:[0,1,0,1],transition:{duration:.8,times:[0,.25,.5,1]}},exit:{opacity:0}},pulse:{initial:{scale:1,opacity:1},animate:{scale:[1,1.05,1],opacity:[1,.8,1],transition:{duration:1,times:[0,.5,1]}},exit:{scale:1,opacity:0}}}}),Be=g({shakeAnimations:()=>we}),qe=m(()=>{we={shake:{initial:{x:0},animate:{x:[0,-10,10,-10,10,0],transition:{duration:.6,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,opacity:0}},"shake-x":{initial:{x:0},animate:{x:[0,-15,15,-15,15,0],transition:{duration:.8,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,opacity:0}},"shake-y":{initial:{y:0},animate:{y:[0,-15,15,-15,15,0],transition:{duration:.8,times:[0,.2,.4,.6,.8,1]}},exit:{y:0,opacity:0}},vibrate:{initial:{x:0,y:0},animate:{x:[0,-2,2,-2,2,0],y:[0,-2,2,-2,2,0],transition:{duration:.4,times:[0,.2,.4,.6,.8,1]}},exit:{x:0,y:0,opacity:0}},jello:{initial:{skewX:0,skewY:0},animate:{skewX:[0,-12.5,6.25,-3.125,1.5625,0],skewY:[0,-12.5,6.25,-3.125,1.5625,0],transition:{duration:1,times:[0,.222,.444,.666,.888,1]}},exit:{skewX:0,skewY:0,opacity:0}}}}),He=g({blurAnimations:()=>Ee}),We=m(()=>{Ee={"blur-in":{initial:{filter:"blur(10px)",opacity:0},animate:{filter:"blur(0px)",opacity:1},exit:{filter:"blur(0px)",opacity:1}},"blur-out":{initial:{filter:"blur(0px)",opacity:1},animate:{filter:"blur(0px)",opacity:1},exit:{filter:"blur(10px)",opacity:0}},"focus-in":{initial:{filter:"blur(20px)",scale:.8,opacity:0},animate:{filter:"blur(0px)",scale:1,opacity:1},exit:{filter:"blur(0px)",scale:1,opacity:1}}}}),Ye=g({elasticAnimations:()=>Me}),Ue=m(()=>{Me={elastic:{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,transition:{type:"spring",stiffness:300,damping:10}},exit:{scale:0,opacity:0}},"rubber-band":{initial:{scale:1},animate:{scale:[1,1.25,.75,1.15,.95,1],transition:{duration:1,times:[0,.3,.4,.5,.65,1]}},exit:{scale:0,opacity:0}},wobble:{initial:{x:0,rotate:0},animate:{x:[0,-25,20,-15,10,-5,0],rotate:[0,-5,3,-3,2,-1,0],transition:{duration:1,times:[0,.15,.3,.45,.6,.75,1]}},exit:{x:0,rotate:0,opacity:0}},swing:{initial:{rotate:0,transformOrigin:"top center"},animate:{rotate:[0,15,-10,5,-5,0],transformOrigin:"top center",transition:{duration:1,times:[0,.2,.4,.6,.8,1]}},exit:{rotate:0,opacity:0}}}}),Xe=g({specialAnimations:()=>Re}),Ke=m(()=>{Re={heartbeat:{initial:{scale:1},animate:{scale:[1,1.3,1,1.3,1],transition:{duration:1.3,times:[0,.14,.28,.42,1]}},exit:{scale:0,opacity:0}},tada:{initial:{scale:1,rotate:0},animate:{scale:[1,.9,.9,1.1,1.1,1.1,1.1,1.1,1.1,1],rotate:[0,-3,-3,3,-3,3,-3,3,-3,0],transition:{duration:1,times:[0,.1,.2,.3,.4,.5,.6,.7,.8,1]}},exit:{scale:0,rotate:0,opacity:0}},wave:{initial:{rotate:0,transformOrigin:"bottom center"},animate:{rotate:[0,14,-8,14,-4,10,0],transformOrigin:"bottom center",transition:{duration:1,times:[0,.1,.2,.3,.4,.5,1]}},exit:{rotate:0,opacity:0}},"roll-in":{initial:{x:"-100%",rotate:-120,opacity:0},animate:{x:0,rotate:0,opacity:1},exit:{x:0,rotate:0,opacity:1}},"roll-out":{initial:{x:0,rotate:0,opacity:1},animate:{x:0,rotate:0,opacity:1},exit:{x:"100%",rotate:120,opacity:0}},hinge:{initial:{rotate:0,transformOrigin:"top left"},animate:{rotate:0,transformOrigin:"top left"},exit:{rotate:[0,80,60,80,60,60],y:[0,0,0,0,0,700],opacity:[1,1,1,1,1,0],transformOrigin:"top left",transition:{duration:2,times:[0,.2,.4,.6,.8,1]}}},"jack-in-the-box":{initial:{scale:.1,rotate:30,transformOrigin:"center bottom",opacity:0},animate:{scale:1,rotate:0,transformOrigin:"center bottom",opacity:1,transition:{type:"spring",stiffness:500,damping:15}},exit:{scale:0,opacity:0}}}}),Ze=class extends Error{constructor(e,t,n){super(t),this.code=e,this.permanent=n.permanent,this.category=n.category,this.presetName=n.presetName,this.cause=n.cause,this.name="PresetLoadError"}};function _e(e){return e instanceof Ze}var Ge={fade:"fade","fade-in":"fade","fade-out":"fade","slide-up":"slide","slide-down":"slide","slide-left":"slide","slide-right":"slide","zoom-in":"zoom","zoom-out":"zoom","scale-up":"zoom","scale-down":"zoom",rotate:"rotate","rotate-in":"rotate","rotate-out":"rotate",spin:"rotate",flip:"flip","flip-x":"flip","flip-y":"flip",bounce:"bounce","bounce-in":"bounce","bounce-out":"bounce",blink:"blink",flash:"blink",pulse:"blink",shake:"shake","shake-x":"shake","shake-y":"shake",vibrate:"shake",jello:"shake","blur-in":"blur","blur-out":"blur","focus-in":"blur",elastic:"elastic","rubber-band":"elastic",wobble:"elastic",swing:"elastic",heartbeat:"special",tada:"special",wave:"special","roll-in":"special","roll-out":"special",hinge:"special","jack-in-the-box":"special"},Je=["fade","slide","zoom","rotate","flip","bounce","blink","shake","blur","elastic","special"],Qe=new Map,et=new Map,tt=new Map,nt=new Map,rt=new Map,it={left:"0%",center:"50%",right:"100%"},at={top:"0%",center:"50%",bottom:"100%"},ot={center:"50% 50%","top center":"50% 0%","center top":"50% 0%","bottom center":"50% 100%","center bottom":"50% 100%","top left":"0% 0%","left top":"0% 0%","top right":"100% 0%","right top":"100% 0%","bottom left":"0% 100%","left bottom":"0% 100%","bottom right":"100% 100%","right bottom":"100% 100%","center left":"0% 50%","left center":"0% 50%","center right":"100% 50%","right center":"100% 50%"};function st(e,t){return Array.isArray(t)?t.map(t=>st(e,t)):t&&"object"==typeof t?ct(t):"transformOrigin"===e&&"string"==typeof t?function(e){const t=e.trim().toLowerCase().replace(/\s+/g," "),n=ot[t];if(n)return n;const r=t.split(" ");if(1===r.length){const t=it[r[0]],n=at[r[0]];return t&&n?`${t} ${n}`:t?`${t} 50%`:n?`50% ${n}`:e}if(2===r.length){const[e,t]=r,n=it[e]??it[t],i=at[e]??at[t];if(n&&i)return`${n} ${i}`}return e}(t):t}function ct(e){const t={};return Object.entries(e).forEach(([e,n])=>{t[e]=st(e,n)}),t}function lt(e){return{initial:ct(e.initial||{}),animate:ct(e.animate||{}),exit:ct(e.exit||{})}}var ut=async e=>"string"==typeof e?await(async e=>lt(await async function(e){const t=rt.get(e);if(t)throw t;const n=Ge[e];if(!n){const t=new Ze("INVALID_ANIMATION",`Unknown preset animation: ${e}`,{permanent:!0,presetName:e});throw rt.set(e,t),t}const r=(await function(e){const t=Qe.get(e);if(t)return Promise.resolve(t);const n=nt.get(e);if(n)return Promise.reject(n);if(!function(e){return Je.includes(e)}(e)){const t=new Ze("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e});return nt.set(e,t),tt.set(e,"failed-permanent"),Promise.reject(t)}const r=et.get(e);if(r)return r;tt.set(e,"pending");const i=function(e,t){return new Promise((n,r)=>{const i=setTimeout(()=>{r(new Ze("ANIMATION_ASSET_LOAD_FAILED",`Timed out loading animation category "${t}".`,{permanent:!1,category:t}))},3e3);e.then(e=>{clearTimeout(i),n(e)},e=>{clearTimeout(i),r(e)})})}(async function(e){switch(e){case"fade":return(await Promise.resolve().then(()=>(Ie(),Pe))).fadeAnimations;case"slide":return(await Promise.resolve().then(()=>(Ae(),Ce))).slideAnimations;case"zoom":return(await Promise.resolve().then(()=>(Te(),De))).zoomAnimations;case"rotate":return(await Promise.resolve().then(()=>(Oe(),Le))).rotateAnimations;case"flip":return(await Promise.resolve().then(()=>(je(),Ve))).flipAnimations;case"bounce":return(await Promise.resolve().then(()=>(Ne(),ze))).bounceAnimations;case"blink":return(await Promise.resolve().then(()=>($e(),Fe))).blinkAnimations;case"shake":return(await Promise.resolve().then(()=>(qe(),Be))).shakeAnimations;case"blur":return(await Promise.resolve().then(()=>(We(),He))).blurAnimations;case"elastic":return(await Promise.resolve().then(()=>(Ue(),Ye))).elasticAnimations;case"special":return(await Promise.resolve().then(()=>(Ke(),Xe))).specialAnimations;default:throw new Ze("INVALID_ANIMATION",`Unknown animation category: ${e}`,{permanent:!0,category:e})}}(e),e).then(t=>(Qe.set(e,t),tt.set(e,"success"),t)).catch(t=>{const n=function(e,t){return _e(t)?t:new Ze("ANIMATION_ASSET_LOAD_FAILED",`Failed to load animation category "${e}".`,{permanent:!1,category:e,cause:t})}(e,t);throw tt.set(e,n.permanent?"failed-permanent":"failed-transient"),n.permanent&&nt.set(e,n),n}).finally(()=>{et.get(e)===i&&et.delete(e)});return et.set(e,i),i}(n))[e];if(r)return r;const i=new Ze("INVALID_ANIMATION",`Preset animation "${e}" is missing from category "${n}".`,{permanent:!0,category:n,presetName:e});throw rt.set(e,i),i}(e)))(e):"object"==typeof e?(e=>{if(!(e=>{if(!e||"object"!=typeof e)return!1;const t=new Set(["initial","animate","exit"]),n=Object.entries(e);return 0!==n.length&&!n.some(([e])=>!t.has(e))&&n.some(([,e])=>null!=e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length>0)})(e))return null;try{return(e=>lt({initial:e.initial??{},animate:e.animate??{},exit:e.exit??{}}))(e)}catch(e){return null}})(e):null,dt=e=>{const t={};return e.forEach(e=>{Object.assign(t,e)}),t},ft=async e=>{const t=[];for(let n=0;n<e.length;n++){const r=await ut(e[n]);r&&t.push({variant:r,sourceIndex:n})}return t},mt=e=>{const{transition:t,...n}=e.animate;return{values:n,transition:t||{}}},gt=e=>{const t={},n={};return e.forEach(({values:e,transition:r})=>{Object.entries(e).forEach(([e,i])=>{t[e]=i,n[e]=r})}),t.transition=n,t};async function pt(e,t,n,r){if(!e)return null;try{const i=await(async e=>"object"==typeof e&&"mode"in e&&"animations"in e?await(async e=>{if(!(e=>!!(e&&"object"==typeof e&&e.mode&&["sequential","parallel"].includes(e.mode)&&Array.isArray(e.animations)&&0!==e.animations.length))(e))return null;try{const{mode:t,animations:n,delays:r=[]}=e;return"sequential"===t?await(async(e,t=[])=>{const n=await ft(e);if(0===n.length)throw new Error("No valid animations in sequential composition");const r=n[0].variant.initial,i=n[n.length-1].variant.exit;let a=0;const o=n.map(({variant:e,sourceIndex:n})=>{const r=t[n]||0,{values:i,transition:o}=mt(e),s={...o,delay:a+r/1e3};return a+=("number"==typeof o.duration?o.duration:1)+r/1e3,{values:i,transition:s}});return{initial:r,animate:gt(o),exit:i}})(n,r):"parallel"===t?await(async(e,t=[])=>{const n=await ft(e);if(0===n.length)throw new Error("No valid animations in parallel composition");const r=n.map(({variant:e})=>e.initial),i=n.map(({variant:e,sourceIndex:n})=>{const r=t[n]||0,{values:i,transition:a}=mt(e);return{values:i,transition:{...a,delay:r/1e3}}}),a=n.map(({variant:e})=>e.exit);return{initial:dt(r),animate:gt(i),exit:dt(a)}})(n,r):null}catch(e){if(_e(e))throw e;return null}})(e):await ut(e))(e);if(i)return i;const a=`Failed to parse ${n} animation for "${t}".`;r?.({code:"INVALID_ANIMATION",message:a,context:{componentId:t,animationType:n,animation:e}})}catch(i){const a=_e(i)?{code:i.code,message:i.message,context:{componentId:t,animationType:n,animation:e,category:i.category,presetName:i.presetName}}:{code:"INVALID_ANIMATION",message:`Error parsing ${n} animation for "${t}".`,context:{componentId:t,animationType:n,animation:e}};r?.(a)}return null}function ht(e){return"string"==typeof e&&!e.includes("(")&&e.trim().includes(" ")}function vt(e,t,n){const r={};return new Set([...Object.keys(e),...Object.keys(t)]).forEach(i=>{if("transition"===i)return;const a=e[i],o=t[i];if(void 0===o)return void(r[i]=a);if(a===o)return void(r[i]=o);const s=void 0!==a?a:"opacity"===i?1:"number"==typeof o?0:"0";if(ht(s)||ht(o))r[i]=n>.5?o:s;else if("number"!=typeof o||"number"!=typeof s){if("number"==typeof s&&"string"==typeof o){if(o.includes("px"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}px`);if(o.includes("%"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}%`);if(o.includes("deg"))return void(r[i]=`${s+((parseFloat(o)||0)-s)*n}deg`)}if("string"==typeof s&&"number"==typeof o){if(s.includes("px")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}px`)}if(s.includes("%")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}%`)}if(s.includes("deg")){const e=parseFloat(s)||0;return void(r[i]=`${e+(o-e)*n}deg`)}}if("string"==typeof o&&"string"==typeof s){if(o.includes("px")||s.includes("px")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}px`)}if(o.includes("%")||s.includes("%")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}%`)}if(o.includes("deg")||s.includes("deg")){const e=parseFloat(s)||0;return void(r[i]=`${e+((parseFloat(o)||0)-e)*n}deg`)}if(o.includes("(")&&o.includes(")")||s.includes("(")&&s.includes(")")){const e=String(s).match(/([a-zA-Z]+)\(([^)]+)\)/),t=o.match(/([a-zA-Z]+)\(([^)]+)\)/);if(e&&t&&e[1]===t[1]){const a=e[1],o=e[2],s=t[2];if(!isNaN(parseFloat(o))&&!isNaN(parseFloat(s))){const e=parseFloat(o),t=e+(parseFloat(s)-e)*n;return void(r[i]=`${a}(${t})`)}}}}r[i]=n>.5?o:s}else r[i]=s+(o-s)*n}),r}function yt(e,t,n){for(let n=t;n>=0;n-=1){const t=e[n];if("number"==typeof t||"string"==typeof t)return t}return n}function xt(e,t,n){return Math.min(n,Math.max(t,e))}function St(e,t,n){return e+(t-e)*n}function bt(e,t,n){if("number"==typeof e&&"number"==typeof t)return St(e,t,n);const r=String(e),i=String(t),a=r.match(/^([-\d.]+)(.*)$/),o=i.match(/^([-\d.]+)(.*)$/);if(a&&o){const e=parseFloat(a[1]),t=parseFloat(o[1]),r=o[2]||a[2]||"",i=St(e,t,n);return r?`${i}${r}`:i}const s=r.match(/^([a-zA-Z]+)\(([-\d.]+)(.*)\)$/),c=i.match(/^([a-zA-Z]+)\(([-\d.]+)(.*)\)$/);if(s&&c&&s[1]===c[1]){const e=parseFloat(s[2]),t=parseFloat(c[2]),r=c[3]||s[3]||"",i=St(e,t,n);return`${c[1]}(${i}${r})`}return n>=1?t:e}function wt(e,t,n,r,i){const a=t[n]??r,o=xt(i,0,1);if(!Array.isArray(a))return bt(e,a,o);if(0===a.length)return e;const s=function(e,t,n){const r=e.transition,i=r?.[t],a=(i&&!Array.isArray(i)?i.times:null)??r?.times;return Array.isArray(a)&&a.length===n?a:null}(t,n,a.length);if(1===a.length||o<=(s?.[0]??0))return yt(a,0,e);for(let t=1;t<a.length;t+=1){const n=s?.[t]??t/(a.length-1);if(o>n)continue;const r=s?.[t-1]??(t-1)/(a.length-1),i=n-r,c=i<=0?1:(o-r)/i;return bt(yt(a,t-1,e),yt(a,t,e),c)}return yt(a,a.length-1,e)}function Et(e,t,n){const r=e[t]??n;return Array.isArray(r)?yt(r,r.length-1,n):r}function Mt(e,t){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){const t=parseFloat(e);if(Number.isFinite(t))return t}return t}function Rt(e,t){switch(e){case"opacity":return"initial"===t||"exit"===t?0:1;case"scale":return 1;case"filter":return"none";default:return 0}}function kt(e,t,n){const r=e[t];return void 0===r?n:r}function Pt(e,t,n,i){return(0,r.useTransform)(e,e=>i(e,t.current,n))}function It(e,t,n,i,a){return(0,r.useTransform)(e,e=>{const r=Mt(Rt(n,"animate"),0);return Mt((a??i)(e,t.current,n),r)})}function Ct(e,t,n,r){const i=It(e,t,"opacity",n,r),a=Pt(e,t,"x",n),o=Pt(e,t,"y",n),s=It(e,t,"scale",n,r),c=Pt(e,t,"rotate",n),l=Pt(e,t,"rotateX",n),u=Pt(e,t,"rotateY",n),d=Pt(e,t,"skewX",n),f=Pt(e,t,"skewY",n),m=Pt(e,t,"filter",n);return{style:{opacity:i,x:a,y:o,scale:s,rotate:c,rotateX:l,rotateY:u,skewX:d,skewY:f,filter:m},opacity:i,x:a,y:o,scale:s,rotate:c,rotateX:l,rotateY:u,skewX:d,skewY:f,filter:m}}var At=.001;function Dt(e){return e.renderProgressMotion?.get()??e.renderProgress??0}function Tt(e){return e.dragTransaction?e.dragTransaction:!0===e.firstSceneEnterActive?e.preparedSnapshot??null:null}function Lt(e){return Tt(e)?.registrySnapshot.timelineDuration??e.getTimelineDuration?.()??e.sceneTransitionDuration}function Ot(e,t,n,r,i,a){const o=function(e,t,n,r){const i=function(e){return Dt(e)>=0?"forward":"backward"}(e),a=function(e){return Math.max(0,e.sharedElapsedMotion?.get()??0)}(e),o=function(e){const t=e.dragTimelineProgress;return xt("number"==typeof t?t:Math.abs(Dt(e)),0,1)}(e),s=function(e){const t=Lt(e);if(Tt(e))return t;const n=e.sharedTimelineDurationMs??0;return n>0?n:t}(e),c=Lt(e),l=Math.abs(Dt(e)),u=function(e,t,n){return n<=0?e>=t-At?1:0:e<=t?0:xt((e-t)/n,0,1)}(a,t,n),d={direction:i,transitionProgress:o,sharedElapsedMs:a,projectedSceneElapsedMs:a,sharedTimelineDurationMs:s,sceneTimelineDurationMs:c,sceneOffset:e.sceneOffset};if(0===e.sceneOffset&&e.isActive){const t=!0===e.firstSceneEnterActive||"settle"===e.dragRelease?.mode||"enter"===e.dragRelease?.mode;if(e.isDragging||l>At){if(l<=At&&t)return{...d,mode:"enter",localProgress:u};const n=Math.max(r,1),i=l*e.sceneTransitionDuration;return{...d,mode:"outgoing",localProgress:xt(i/n,0,1)}}return t?{...d,mode:"enter",localProgress:u}:{...d,mode:"rest",projectedSceneElapsedMs:c,localProgress:1}}return("forward"===i&&1===e.sceneOffset||"backward"===i&&-1===e.sceneOffset)&&(e.isDragging||l>At)?{...d,mode:"enter",localProgress:u}:{...d,mode:"hidden",projectedSceneElapsedMs:0,localProgress:0}}(e,t,n,r);return a?{...o,mode:"hidden",localProgress:0,projectedSceneElapsedMs:0}:i?{...o,mode:"rest",localProgress:1,projectedSceneElapsedMs:o.sceneTimelineDurationMs}:o}function Vt(e,t,n){return e?function(e,t,n){const r=Et(t.enterInitial,n,Rt(n,"initial")),i=Et(t.enterAnimate,n,Rt(n,"animate"));switch(e.mode){case"rest":default:return i;case"hidden":return r;case"enter":return wt(r,t.enterAnimate,n,Rt(n,"animate"),e.localProgress);case"outgoing":return 0===Object.keys(t.exitTarget).length?i:"forward"===e.direction?wt(i,t.exitTarget,n,Rt(n,"exit"),e.localProgress):wt(r,t.enterAnimate,n,Rt(n,"animate"),1-e.localProgress)}}(e,t,n):Et(t.enterAnimate,n,Rt(n,"animate"))}var jt=new WeakMap,zt=new WeakMap;function Nt(e,t){return"entered"===e&&t}function Ft(e,t,n,r){return void 0===e?t:n+(r-n)*xt(e,0,1)}function $t(e,t,n){return bt(kt(t.initial,n,Rt(n,"initial")),kt(t.animate,n,Rt(n,"animate")),e)}function Bt(e,t,n){const r=Mt(Rt(n,"animate"),0),i=Mt(kt(t.initial,n,Rt(n,"initial")),r);return i+(Mt(kt(t.animate,n,Rt(n,"animate")),r)-i)*e}function qt(e,t){switch(e){case"hidden":default:return"idle";case"outgoing":return"exiting";case"rest":return"entered";case"enter":return t>=.999?"entered":"entering"}}function Ht(e){return e<=0?0:e>=1?1:e}function Wt(e,t){return{enterProgress:Ht(t),phase:e}}function Yt(e,t){const n=t<=0?0:t>=1?1:t;return{enterProgress:n,phase:qt(e,n)}}var Ut={enterProgress:0,phase:"idle"};function Xt({signedVisual:e,phaseMotion:i,render:a}){const[o,s]=(0,t.useState)(()=>Wt(i.get(),e.get()));return(0,r.useMotionValueEvent)(e,"change",e=>{s(Wt(i.get(),e))}),(0,r.useMotionValueEvent)(i,"change",t=>{s(Wt(t,e.get()))}),(0,n.jsx)(n.Fragment,{children:a(o)})}function Kt({visualState:e,render:i}){const[a,o]=(0,t.useState)(()=>{const t=e.get();return t?Yt(t.mode,t.localProgress):Ut});return(0,r.useMotionValueEvent)(e,"change",e=>{o(e?Yt(e.mode,e.localProgress):Ut)}),(0,n.jsx)(n.Fragment,{children:i(a)})}function Zt(e){if("string"==typeof e){const t=r.motion[e];if(t)return t}return r.motion.div}function _t(e,t,n){return"last"===n?t-1-e:"center"===n?Math.abs(e-(t-1)/2):e}function Gt(e){return t.Children.toArray(e.props.children).filter(t.isValidElement)}function Jt(e){return Gt(e).length}function Qt(e,t,n,r,i,a="animate"){const o=e[a]?.transition?.duration,s="number"==typeof o&&Number.isFinite(o)?Math.max(1e3*o,0):Math.max(t,0),c=Math.max(n,0);let l=0;for(let e=0;e<i;e+=1)l=Math.max(l,_t(e,i,r));const u=l*c;return{itemDurationMs:s,tailDurationMs:u,effectiveDurationMs:Math.max(t,u+s)}}function en(e,t,n,r,i){return Qt(e,t??0,n,r,Jt(i)).effectiveDurationMs}function tn(e,n){const i=n(e.get()),a=(0,t.useRef)(i),[o,s]=(0,t.useState)(()=>({phase:i,revision:0}));return(0,r.useMotionValueEvent)(e,"change",e=>{const t=n(e);t!==a.current&&(a.current=t,s(e=>({phase:t,revision:e.revision+1})))}),[o.phase,o.revision]}function nn(e,n,r=0){const i=(0,t.useRef)(Math.max(n,0)),[a,o]=(0,t.useState)(null);return(0,t.useEffect)(()=>{i.current=Math.max(n,0)},[n]),(0,t.useEffect)(()=>{if("animate"!==e)return;const t=i.current;if(0===t)return void o(r);const n=window.setTimeout(()=>o(r),t);return()=>window.clearTimeout(n)},[e,r]),"animate"===e&&a===r}function rn(e,r,i,a,o,s,c,l,u=!1){const d=t.Children.toArray(e.props.children),f=Gt(e).length,m=Math.max(i,0)/1e3,g="boolean"==typeof o?o?"animate":"initial":o,p=r.animate.transition??{},h={initial:r.initial,animate:e=>({...r.animate,transition:u?{...p,duration:0,delay:0}:{...p,...void 0===p.duration&&void 0!==s?{duration:Math.max(s,0)/1e3}:{},delay:_t(e,f,a)*m}}),exit:e=>{const t=c?.exit??r.initial,n=t.transition??{};return{...t,transition:{...n,...void 0===n.duration&&void 0!==l?{duration:Math.max(l,0)/1e3}:{},delay:_t(e,f,a)*m}}}};let v=0;const y=d.map((e,r)=>{if(!(0,t.isValidElement)(e))return e;const i=v;v+=1;const a=Zt(e.type);return(0,n.jsx)(a,{custom:i,variants:h,className:e.props.className,style:e.props.style,children:e.props.children},e.key??r)}),x=Zt(e.type),{children:S,...b}=e.props;return(0,n.jsx)(x,{...b,initial:"initial",animate:g,variants:{initial:{},animate:{},exit:{}},children:y})}function an({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,signedVisual:c}){const[l,u]=tn(c,e=>e>0?"animate":e<0&&o?"exit":"initial");return rn(e,t,n,r,l,i,o,s,nn(l,a??en(t,i,n,r,e),u))}function on({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,phaseMotion:o,staticReveal:s}){const[c,l]=tn(o,e=>"entering"===e||"entered"===e?"animate":"initial"),u=nn(c,a??en(t,i,n,r,e),l);return rn(e,t,n,r,c,i,void 0,void 0,s||u)}function sn({container:e,variant:t,each:n,from:r,itemDurationMs:i,effectiveDurationMs:a,exitVariant:o,exitItemDurationMs:s,visualState:c}){const[l,u]=tn(c,e=>"outgoing"===e?.mode&&o?"exit":e&&("enter"===e.mode&&e.localProgress>0||"rest"===e.mode)?"animate":"initial");return rn(e,t,n,r,l,i,o,s,nn(l,a??en(t,i,n,r,e),u))}var cn=(0,t.createContext)(null);function ln({value:e,children:t}){return(0,n.jsx)(cn.Provider,{value:e,children:t})}function un(){const e=(0,t.useContext)(cn);if(!e)throw new Error("useAnimateTimeline must be used inside an <Animate> child.");return e}var dn=Object.freeze({progress:0,signedProgress:0,phase:"idle",source:"idle"});function fn(e,t){if(!t)return"idle";switch(e?.dragTransaction?.phase){case"driving":return"gesture";case"settling":case"bouncing":return"continuation";case"programmatic":return"programmatic"}return"settle"===e?.dragRelease?.mode||"bounce"===e?.dragRelease?.mode?"continuation":"enter"===e?.dragRelease?.mode||e?.firstSceneEnterActive?"programmatic":"idle"}function mn(e){if(null===e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function gn(e,t,n,r){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1}else if(!mn(e)||!mn(t))return!1;const i=e,a=t,o=n.get(i),s=r.get(a);if(o||s)return o===a&&s===i;n.set(i,a),r.set(a,i);try{if(Array.isArray(e)&&Array.isArray(t))return e.every((e,i)=>gn(e,t[i],n,r));const i=e,a=t,o=Object.keys(i).sort(),s=Object.keys(a).sort();if(o.length!==s.length)return!1;for(let e=0;e<o.length;e+=1){const t=o[e];if(t!==s[e]||!gn(i[t],a[t],n,r))return!1}return!0}finally{n.delete(i),r.delete(a)}}function pn(e){const n=(0,t.useRef)(e);return gn(n.current,e,new WeakMap,new WeakMap)||(n.current=e),n.current}var hn=(0,t.createContext)(null),vn=Object.freeze({opacity:1}),yn=0,xn=({enterAnimation:e,exitAnimation:i,loopAnimation:a,animateId:o,duration:s,timeline:c,visibility:l,stagger:u,enterRef:d,exitRef:f,children:m})=>{const g=(0,t.useRef)(o||"animate-"+ ++yn).current,p=(0,t.useContext)(hn),h=me(),y=h?.reportError,x=!0===h?.prefersReducedMotion,S=(0,t.useContext)(ie),b=(0,t.useContext)(oe),[w,E]=(0,t.useState)(null),[M,R]=(0,t.useState)(null),[k,P]=(0,t.useState)(null),[I,C]=(0,t.useState)(0),A=(0,t.useRef)(0),D=(0,t.useRef)(null),T=(0,t.useRef)(new Set),L=(0,t.useRef)(null),O=(0,t.useRef)(new Set),V=pn(e),j=pn(i),z=pn(a),N=(0,r.useAnimation)(),F=(0,r.useAnimation)(),$=(0,t.useMemo)(()=>function({duration:e,timeline:t,visibility:n}){return{duration:{enter:e?.enter??600,exit:e?.exit??600},timeline:{driver:t?.driver??"scene",delay:t?.delay??0,after:t?.after,phase:{start:t?.phase?.start,end:t?.phase?.end}},visibility:{replay:n?.replay??!0,enterMargin:n?.enterMargin,exitMargin:n?.exitMargin}}}({duration:s,timeline:c,visibility:l}),[s,c,l]),B=p?.mode??h?.mode??"drag",q="drag"===B&&"clock"===$.timeline.driver,H=(0,t.useRef)(null),W="drag"===B&&p?.isActive?p.activationToken??0:0;(null===H.current||H.current.mode!==B||H.current.token!==W||0===W&&H.current.arrival!==q)&&(H.current={token:W,mode:B,arrival:q});const Y="drag"===B&&H.current.arrival,U=p?.beginPreparation,X=p?.declareAnimateLane,K=(0,t.useMemo)(()=>{const{driver:e,...t}=$.timeline;return{...t,lane:"scroll"===B&&"scene"===e&&b?"scroll":"visibility"}},[b,B,$.timeline]),Z=$.duration.enter,_=$.duration.exit,G=K.delay,J=K.after,Q=(0,t.useContext)(ae),ee=Y&&p?.isActive?p.activationToken??0:0,te=I>0&&D.current?.enterAnimation===V&&D.current?.exitAnimation===j&&D.current?.loopAnimation===z,ne=(0,t.useRef)(null),re=ne.current;Y&&(0===ee||null===re||re.token!==ee)&&(ne.current={token:ee,ready:te,enterVariant:te?w:null,exitVariant:te?M:null,infiniteVariant:te?k:null,hasAuthoredEnterAnimation:!!V,enterDuration:Z,exitDuration:_,delay:G,stagger:u,enterAnimation:V,exitAnimation:j,loopAnimation:z});const se=Y?ne.current:null;se&&!se.ready&&I>0&&D.current?.enterAnimation===se.enterAnimation&&D.current?.exitAnimation===se.exitAnimation&&D.current?.loopAnimation===se.loopAnimation&&(se.ready=!0,se.enterVariant=w,se.exitVariant=M,se.infiniteVariant=k);const ce=se?se.enterAnimation:V,le=se?se.exitAnimation:j,ue=se?se.loopAnimation:z,de=se?.ready?se.enterVariant:Y?null:w,fe=se?.ready?se.exitVariant:Y?null:M,ge=se?.ready?se.infiniteVariant:Y?null:k,pe=se?.enterDuration??Z,he=se?.exitDuration??_,ve=se?.delay??G,ye=se?se.stagger:u;(0,t.useEffect)(()=>{if(!Y)return;const e=X?.(g,"visibility");return()=>e?.dispose()},[X,g,Y]),(0,t.useEffect)(()=>{if(!Y)return;const e=(e,t)=>{const n=`${g}:${e}`;T.current.has(n)||(T.current.add(n),y?.({code:"INVALID_ANIMATION",message:t,context:{componentId:g,field:e,lane:"visibility",mode:"drag"}}))};J&&e("after",`Animate "${g}" ignores after in drag mode when timeline.driver is 'clock'.`),j&&e("exitAnimation",`Animate "${g}" ignores exitAnimation in drag mode when timeline.driver is 'clock'.`)},[g,Y,J,y,j]);const xe="function"==typeof m,Se=!(!ce&&!ue||(Y?se?.ready??te:te)||de||fe||ge),be="drag"===B?!Y:"scroll"===K.lane,we="scroll"===B&&!be,Ee=(0,t.useRef)(new Set);(0,t.useEffect)(()=>{if(!d&&!f)return;const e=(e,t)=>{const n=`${g}:${e}`;Ee.current.has(n)||(Ee.current.add(n),y?.({code:"INVALID_ANIMATION",message:t,context:{componentId:g,field:e,mode:B,scrub:be}}))};if(be){const t="drag"===B?"the Scene element track (drag)":"the zone scroll budget (scroll takeover)";return d&&e("enterRef",`Animate "${g}" ignores enterRef: this element is driven by ${t}, whose progress has a single owner. Use timeline.driver:'clock' (drag) or move it outside the takeover zone (scroll) for manual control.`),void(f&&e("exitRef",`Animate "${g}" ignores exitRef: this element is driven by ${t}, whose progress has a single owner. Use timeline.driver:'clock' (drag) or move it outside the takeover zone (scroll) for manual control.`))}Y&&f&&e("exitRef",`Animate "${g}" ignores exitRef in drag mode when timeline.driver is 'clock': this lane has no exit pass (it also ignores exitAnimation).`)},[d,f,g,Y,be,B,y]);const Me=Y?ye:u,Re=Me&&!xe&&de&&(0,t.isValidElement)(m)?m:null,ke=!!Re,Pe=Me?.each??40,Ie=Me?.from??"first",Ce=(0,t.useMemo)(()=>Re&&de?Qt(de,pe,Pe,Ie,Jt(Re)):null,[pe,de,Re,Pe,Ie]),Ae=(0,t.useMemo)(()=>Re&&fe?Qt(fe,he,Pe,Ie,Jt(Re),"exit"):null,[he,fe,Re,Pe,Ie]),De=Ce?.effectiveDurationMs??pe,Te=Ae?.effectiveDurationMs??he,Le=(0,t.useMemo)(()=>S?{...S,zoneStates:Q?.zoneStates??{},store:Q?.store}:null,[S,Q?.store,Q?.zoneStates]);(0,t.useEffect)(()=>{const e=O.current,t=++A.current,n=()=>A.current===t;L.current?.lease.cancel(),L.current=null;const r="drag"!==B||Y?void 0:U?.();r&&e.add(r),L.current=r?{generation:t,lease:r}:null;const i=e=>{n()&&y?.(e)};return E(null),R(null),P(null),C(0),ce||ue?((async()=>{const[e,n,r]=await Promise.all([pt(ce,g,"enter",i),pt(le,g,"exit",i),pt(ue,g,"loop",i)]);A.current===t&&(D.current={enterAnimation:ce,exitAnimation:le,loopAnimation:ue},E(e??null),R(n??null),P(r??null),C(t))})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(A.current+=1)}):(y?.({code:"INVALID_ANIMATION",message:`Animate "${g}" requires enterAnimation or loopAnimation.`,context:{componentId:g,hasExitAnimation:!!le}}),(()=>{const n=L.current;!n||n.generation!==t||(n.lease.complete(),e.delete(n.lease),L.current=null)})(),()=>{e.forEach(e=>e.cancel()),e.clear(),n()&&(A.current+=1)})},[g,B,Y,y,U,ce,le,ue]),(0,t.useEffect)(()=>{!Y||0===ee||!se||(se.enterAnimation!==V||se.exitAnimation!==j||se.loopAnimation!==z)&&Promise.all([pt(V,g,"enter"),pt(j,g,"exit"),pt(z,g,"loop")])},[se,ee,g,Y,V,j,z]);const Oe=function({sceneContext:e,enterVariant:n,exitVariant:i,componentId:a,delay:o,enterDuration:s,exitDuration:c,after:l,variantsPending:u=!1}){const d=e?Tt(e):null,f=d?.registrySnapshot.registrations.get(a),m=d?.enterVariantsByAnimateId.get(a)??null,g=!(!d||f&&m),p=f?.duration??s,h=d?.registrySnapshot.calculatedDelays.get(a)??0,v=m??n,y=(0,t.useRef)(h),x=(0,t.useRef)(d);x.current=d;const S=(0,t.useRef)({enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}}),b=e?Ot(e,y.current,p,c,g,u):null,w=b?"outgoing"===b.mode?("forward"===b.direction?1:-1)*b.localProgress:b.localProgress:0,E=(0,r.useMotionValue)(w),M=(0,r.useMotionValue)(b),[R,k]=(0,t.useState)(!1),P=((0,t.useRef)(null),(0,t.useRef)(null)),I=(0,t.useRef)(null);(0,t.useRef)({identity:null,categories:new Set}),(0,t.useEffect)(()=>{},[a,o,s,n,m,f,g,d,e?.isActive,e?.sceneOffset,l]),(0,t.useEffect)(()=>{S.current={enterInitial:v?.initial||{},enterAnimate:v?.animate||{},exitTarget:i?.exit||{}},d&&(y.current=h)},[i,h,d,v]),(0,t.useEffect)(()=>{const t=e?.registerAnimate,r=e?.unregisterAnimate,i=e?.getCalculatedDelay;if(!t||!i||!n)return;const c=t(a,{delay:o,duration:s,after:l,lane:"drag"});return c?.setEnterVariant?.(n),x.current||(y.current=c?.getCalculatedDelay?.()??i(a)),()=>{c?.dispose?c.dispose():r?.(a)}},[e?.registerAnimate,e?.unregisterAnimate,e?.getCalculatedDelay,n,a,o,s,l]),(0,t.useEffect)(()=>{if(!e)return;const t=()=>{if(d)y.current=h;else{const t=e.getCalculatedDelay?.(a);"number"==typeof t&&(y.current=t)}const t=Ot(e,y.current,p,c,g,u),n="outgoing"===t.mode?("forward"===t.direction?1:-1)*t.localProgress:t.localProgress,r=[t.mode,t.direction,e.sceneOffset,e.isActive?"active":"inactive",e.isDragging?"dragging":"idle"].join(":"),i=P.current!==r;if(E.set(n),M.set(t),P.current=r,i&&(t.mode,t.direction,e.sceneOffset,e.isActive,e.isDragging,e.sceneState,Dt(e).toFixed(3),t.transitionProgress.toFixed(3),t.sharedElapsedMs.toFixed(1),t.projectedSceneElapsedMs.toFixed(1),t.sharedTimelineDurationMs,t.sceneTimelineDurationMs,t.localProgress.toFixed(3),y.current),"enter"===t.mode){const n=t.localProgress<=.001?"before-delay":t.localProgress>=.999?"enter-complete":"enter-active";I.current!==`${t.mode}:${n}`&&(t.mode,t.sharedElapsedMs.toFixed(1),t.projectedSceneElapsedMs.toFixed(1),t.sharedTimelineDurationMs,t.sceneTimelineDurationMs,t.transitionProgress.toFixed(3),y.current,t.localProgress.toFixed(3),Dt(e).toFixed(3),e.sceneOffset,I.current=`${t.mode}:${n}`)}};t();const n=[e.sharedElapsedMotion?.on("change",t),e.renderProgressMotion?.on("change",t)].filter(e=>"function"==typeof e);return()=>{n.forEach(e=>e())}},[e,E,M,a,s,c,g,u,h,p,d,e?.renderProgressMotion,e?.renderProgress,e?.isDragging,e?.isActive,e?.sceneOffset,e?.sceneState,e?.dragRelease,e?.firstSceneEnterActive]);const C=Ct(M,S,Vt);return(0,t.useEffect)(()=>{if(!e)return void k(!1);const t=()=>{const t=Ot(e,y.current,p,c,g,u);k(e.isActive&&0===e.sceneOffset&&!e.isDragging&&("rest"===t.mode||"enter"===t.mode)&&t.localProgress>=.999)};t();const n=[e.sharedElapsedMotion?.on("change",t),e.renderProgressMotion?.on("change",t)].filter(e=>"function"==typeof e);return()=>{n.forEach(e=>e())}},[e,p,g,u,c,e?.isActive,e?.sceneOffset,e?.isDragging,e?.renderProgressMotion,e?.renderProgress,e?.dragRelease,e?.firstSceneEnterActive]),{style:C.style,opacity:C.opacity,x:C.x,y:C.y,scale:C.scale,rotate:C.rotate,useInteractiveStyles:!0,shouldRunInfinite:R,visualState:M}}({sceneContext:"drag"!==B||Y?null:p,enterVariant:w,exitVariant:M,componentId:g,delay:G,enterDuration:De,exitDuration:Te,after:J,variantsPending:Se}),Ve=function({enabled:e,sceneContext:n,enterVariant:i,hasAuthoredEnterAnimation:a,parseReady:o,delay:s,enterDuration:c,enterRef:l}){const u=(0,t.useRef)({initial:{},animate:{}}),d=!!l&&s<=0,f=(0,t.useRef)({delay:s,enterDuration:c,hasAuthoredEnterAnimation:a,parseReady:o,enterVariant:i,autoEnterSuppressed:d});f.current={delay:s,enterDuration:c,hasAuthoredEnterAnimation:a,parseReady:o,enterVariant:i,autoEnterSuppressed:d};const m=(0,r.useMotionValue)(a?0:1),g=(0,r.useMotionValue)(a?"idle":"entered"),[p,h]=(0,t.useState)(!1),[v,y]=(0,t.useState)(!1),x=(0,t.useRef)(null),S=(0,t.useRef)(null),b=(0,t.useRef)(0),w=(0,t.useRef)(0),E=(0,t.useRef)(null),M=(0,t.useRef)(!1),R=(0,t.useRef)(0===(n?.activationToken??0)),k=(0,t.useRef)(n);k.current=n;const P=(0,t.useCallback)(()=>{x.current?.stop(),x.current=null,null!==S.current&&(clearTimeout(S.current),S.current=null)},[]),I=(0,t.useCallback)(()=>{const e=f.current;P(),b.current=0,w.current=0,E.current=null,M.current=!1,h(!1),y(!1),g.set(e.hasAuthoredEnterAnimation?"idle":"entered"),m.set(e.hasAuthoredEnterAnimation?0:1)},[g,P,m]),C=(0,t.useCallback)((e,t)=>{const n=k.current,i=f.current;if(!n?.isActive||(n.activationToken??0)!==e||e<=0)return;if(i.hasAuthoredEnterAnimation&&!i.parseReady)return void(w.current=e);if(b.current===e)return;w.current=0,b.current=e,P(),E.current=null,h(!1),u.current={initial:i.enterVariant?.initial??{},animate:i.enterVariant?.animate??{}};const a="static"===t&&R.current;y(a);const o=()=>{const t=k.current;return!(!t?.isActive||(t.activationToken??0)!==e)},s=()=>{o()&&h(!0)};if(!i.hasAuthoredEnterAnimation||null===i.enterVariant||a)return g.set("entered"),m.set(1),void(()=>{const e=Math.max(i.delay,0);e<=0?s():S.current=setTimeout(()=>{S.current=null,s()},e)})();g.set("waiting"),m.set(0);const c=()=>{if(S.current=null,!o())return;g.set("entering");const e=Math.max(i.enterDuration,0);if(e<=0)return g.set("entered"),m.set(1),void h(!0);x.current=(0,r.animate)(m,1,{duration:e/1e3,ease:"easeInOut",onComplete:()=>{x.current=null,o()&&(g.set("entered"),m.set(1),h(!0))}})},l=Math.max(i.delay,0);if(i.autoEnterSuppressed)return E.current=c,void(M.current&&(M.current=!1,E.current=null,c()));l>0?S.current=setTimeout(c,l):c()},[g,P,m]),A=e&&n?.isActive?n.activationToken??0:0,D=n?.activationKind??null;(0,t.useEffect)(()=>{A<=0?I():C(A,D)},[D,A,I,C]),(0,t.useEffect)(()=>{const e=w.current;e<=0||!o||C(e,k.current?.activationKind??null)},[i,o,C]),(0,t.useEffect)(()=>()=>{P(),b.current=0,w.current=0},[P]);const T=(0,t.useCallback)(()=>{const e=E.current;e?(E.current=null,M.current=!1,null!==S.current&&(clearTimeout(S.current),S.current=null),e()):M.current=!0},[]);return(0,t.useEffect)(()=>{if(l&&e)return l.current=T,()=>{l.current===T&&(l.current=null)}},[e,l,T]),{style:Ct(m,u,$t,Bt).style,visualMotion:m,phaseMotion:g,shouldRunInfinite:p,staticReveal:v}}({enabled:Y,sceneContext:"drag"===B?p:null,enterVariant:de,hasAuthoredEnterAnimation:se?.hasAuthoredEnterAnimation??!!e,parseReady:se?.ready??I>0,delay:ve,enterDuration:De,enterRef:Y?d:void 0}),je=function({sceneContext:e,zoneRuntime:n,zoneId:i,enterVariant:a,exitVariant:o,hasAuthoredEnterAnimation:s,hasAuthoredExitAnimation:c,hasInfiniteAnimation:l=!1,componentId:u,duration:d,timeline:f,visibility:m,globalEnterMargin:g,globalExitMargin:p,enterRef:h,exitRef:y,variantsPending:x=!1}){const S=d.enter,b=d.exit,w=!0===me()?.prefersReducedMotion,E=w?0:S,M=w?0:b,R=f.delay,k=f.after,P="scroll"===f.lane,I=f.phase?.start,C=f.phase?.end,A=m.replay,D=v()?.scale??1,T=m.enterMargin??g??50,L=m.exitMargin??p??50,O=Math.max(0,T*D),V=Math.max(0,L*D),j=(0,t.useRef)({enterInitial:{},enterAnimate:{},exitTarget:{}}),z=(0,r.useMotionValue)(0),N=(0,r.useMotionValue)(i&&n?n.store?.getKeySnapshot(i)??n.zoneStates[i]??null:null),[F,$]=(0,t.useState)(!1),B=(0,t.useRef)(null),[q,H]=(0,t.useState)(0),W=n?.registerZoneAnimation,Y=n?.unregisterZoneAnimation,U=!!(a?.animate&&Object.keys(a.animate).length>0)||!!s,X=function(e,t){return!!(t>0&&e?.exit&&Object.keys(e.exit).length>0)}(o,b)||!!c;(0,t.useEffect)(()=>{j.current={enterInitial:a?.initial||{},enterAnimate:a?.animate||{},exitTarget:o?.exit||{}}},[a,o]);const K=(0,t.useRef)("idle"),Z=(0,r.useMotionValue)("idle"),_=(0,t.useCallback)(e=>{K.current=e,Z.set(e)},[Z]),G=(0,t.useRef)(null),J=(0,t.useRef)(null),Q=(0,t.useRef)(0),ee=(0,t.useRef)(!1),te=(0,t.useRef)(null),ne=(0,t.useRef)(null),re=(0,t.useRef)(null),ie=(0,t.useRef)(()=>{}),ae=(0,t.useRef)(0),oe=(0,t.useRef)(null),se=(0,t.useRef)(!1),ce=(0,t.useRef)(!1),le=(0,t.useRef)(!1),ue=(0,t.useCallback)(()=>n&&i?n.store?.getKeySnapshot(i)??n.zoneStates[i]??null:null,[i,n]);(0,t.useEffect)(()=>{if(!P||!n||!i)return void N.set(null);const e=()=>{N.set(ue())};return e(),n.store?.subscribeKey(i,e)},[P,ue,i,n,N]);const de=!!h&&!P&&!(k||R>0),fe=!!y&&!P,ge=(0,t.useRef)(!1),pe=(0,t.useRef)(!1),he=(0,t.useCallback)(e=>{e?.publishEnterCompleted()},[]),ve=(0,t.useCallback)(()=>{ae.current+=1,oe.current=null,te.current&&(clearTimeout(te.current),te.current=null),ne.current&&(ne.current(),ne.current=null),re.current&&(re.current(),re.current=null)},[]),ye=(0,t.useCallback)(()=>{Q.current+=1,J.current&&(J.current.stop(),J.current=null),ve()},[ve]),xe=(0,t.useCallback)(()=>{const e=B.current?.ownerDocument?.defaultView;e&&(re.current?.(),re.current=function(e,t){let n=zt.get(e);if(!n){const t=e.requestAnimationFrame?.bind(e)??(t=>e.setTimeout(()=>t(Date.now()),16)),r=e.cancelAnimationFrame?.bind(e)??(t=>e.clearTimeout(t));n={callbacks:new Map,frame:null,requestFrame:t,cancelFrame:r},zt.set(e,n)}const r=n,i=r.callbacks.get(t)??{callback:t,cancelled:!1};return r.callbacks.set(t,i),null===r.frame&&(r.frame=r.requestFrame(()=>{r.frame=null;const t=[...r.callbacks.values()];r.callbacks.clear(),t.forEach(e=>{e.cancelled||e.callback()}),0===r.callbacks.size&&null===r.frame&&zt.get(e)===r&&zt.delete(e)})),()=>{i.cancelled=!0,r.callbacks.get(t)===i&&r.callbacks.delete(t),0===r.callbacks.size&&null!==r.frame&&(r.cancelFrame(r.frame),r.frame=null,zt.get(e)===r&&zt.delete(e))}}(e,()=>{re.current=null,ie.current()}))},[]),Se=(0,t.useCallback)(()=>{ve(),_("entering"),z.get()<0&&z.set(0);const e=G.current,t=++Q.current,n=(0,r.animate)(z,1,{duration:Math.max(E,0)/1e3,ease:"easeInOut",onComplete:()=>{Q.current===t&&(J.current=null,_("entered"),he(e),xe())}});J.current=n},[ve,E,he,xe,_,z]),be=(0,t.useCallback)((e=!1)=>{const t=K.current,n="exited"===t?"exited":"exiting"===t?"exiting":"idle";ye();const r={token:++ae.current,origin:n,dependencyReady:!k,delayStarted:!1,delayReady:!1,coldStartBypass:e};oe.current=r,_("waiting"),$(!1);const i=e=>{oe.current?.token!==r.token||"pending"===e.kind||(r.dependencyReady=!0,ne.current=null,xe())};if(!k)return;const a=G.current;a?ne.current=a.observeAfter(i):i({kind:"invalid",leaderId:k,reason:"missing"})},[xe,_,ye,k]),we=(0,t.useCallback)(()=>{const e=oe.current;if(e&&e.dependencyReady){if(!e.delayStarted){if(e.delayStarted=!0,R>0){const t=e.token;return void(te.current=setTimeout(()=>{te.current=null,oe.current?.token===t&&(e.delayReady=!0,xe())},R))}e.delayReady=!0}e.delayReady&&Se()}},[R,Se,xe]),Ee=(0,t.useCallback)(()=>{ye(),_("exiting"),$(!1),z.get()>=0&&z.set(-1e-6);const e=++Q.current,t=(0,r.animate)(z,-1,{duration:Math.max(M,0)/1e3,ease:"easeInOut",onComplete:()=>{Q.current===e&&(J.current=null,_("exited"))}});J.current=t},[M,ye,_,z]),Me=(0,t.useCallback)(t=>{if(P||x)return;const n=B.current;if(!(n instanceof HTMLElement))return;const r=e?.firstSceneEnterGateKnown,i=e?.firstSceneEnterReady,a=e?.firstSceneEnterActive;if(!1===r)return ye(),_("idle"),z.set(0),void $(!1);if(!1===i&&!0===a)return ce.current=!1,ye(),_("idle"),z.set(0),void $(!1);const o=!1===i&&!1===a&&!ce.current&&!de;o&&(ce.current=!0,se.current=!0,ye(),_("entered"),z.set(1),he(G.current));const s=n.getBoundingClientRect();if(!(s.width>0||s.height>0||s.bottom!==s.top))return;const c=n.closest('[data-cineview-container="true"]'),l=t?.top??(c?c.getBoundingClientRect().top:0),u=(t?.height??c?.clientHeight??0)||window.innerHeight||1,d=s.top-l,f=s.bottom-l,m=Math.max(s.height,f-d,0)>u-O,g=m?d<=u/2:d>=0&&f<=u-O,p=m?f<=.7*u:d<=V||f>=u-V,h=m?g&&!p:g,v=f<=0,y=f>0&&d<u;if(o)return v&&(le.current=!1),void $(Nt("entered",y));if(!se.current){if(se.current=!0,de)return void $(!1);if(v)return ye(),_("entered"),z.set(1),he(G.current),$(Nt("entered",!1)),void(le.current=!1);if(!0===i&&!m&&d>=0&&f<=u)return be(!0),void we()}if("waiting"===K.current){const e=oe.current;if(e&&(!0===e?.coldStartBypass&&!0===i&&!m&&d>=0&&f<=u||h&&!p))we();else{const t=e?.origin??"idle";ve(),_(t)}}else{const e=function(e,t,n,r){switch(e){case"idle":return t&&!n?"enter":null;case"entering":case"entered":return n&&!t&&r.hasExplicitExit?"exit":null;case"exiting":case"exited":return t&&!n&&r.replay?"enter":null;default:return null}}(K.current,h,p,{hasExplicitExit:X,replay:A});y&&!le.current&&(le.current=!0),"enter"!==e||de||ge.current||pe.current?"exit"===e&&!fe&&(!le.current&&v||Ee()):(be(),we())}$(Nt(K.current,y))},[we,de,fe,be,ve,O,V,X,P,he,A,Ee,e?.firstSceneEnterGateKnown,e?.firstSceneEnterActive,e?.firstSceneEnterReady,_,ye,x,z]);ie.current=Me;const Re=(0,t.useCallback)(()=>{ge.current=!0,pe.current=!1,se.current=!0,ce.current=!0,Se()},[Se]),ke=(0,t.useCallback)(()=>{pe.current=!0,Ee()},[Ee]);(0,t.useEffect)(()=>{if(h&&!P)return h.current=Re,()=>{h.current===Re&&(h.current=null)}},[h,P,Re]),(0,t.useEffect)(()=>{if(y&&!P)return y.current=ke,()=>{y.current===ke&&(y.current=null)}},[y,P,ke]),(0,t.useEffect)(()=>{const t=e?.registerAnimate,n=e?.unregisterAnimate;if(!t||!U&&!X)return;const r=t(u,{delay:R,duration:U?S:b,after:k,lane:P?"scroll":"visibility"});return G.current=r??null,ee.current=!1,()=>{ve(),G.current===r&&(G.current=null),r?.dispose?r.dispose():n?.(u)}},[e?.registerAnimate,e?.unregisterAnimate,ve,u,R,S,b,k,U,X,P]),(0,t.useEffect)(()=>{if(typeof document>"u"||x||B.current?.isConnected)return;const e=document.querySelector(`[data-cineview-animate-host="${u}"]`)??document.querySelector(`[data-cineview-animate-id="${u}"]`);e instanceof HTMLElement&&B.current!==e&&(B.current=e,H(e=>e+1))},[u,a,o,x]),(0,t.useEffect)(()=>{if(!(P&&W&&Y&&i&&(U||X)))return;const e=W(i,{animateId:u,delay:R,enterDuration:S,exitDuration:X?b:0,after:k,...void 0!==I||void 0!==C?{phase:{start:I,end:C}}:{}});return()=>{Y(i,u,e)}},[u,R,S,b,X,U,P,C,I,i,k,W,Y]);const Pe=(0,t.useCallback)(e=>{if(!U&&!X)return"entered"!==K.current&&_("entered"),void(1!==z.get()&&z.set(1));if(!n||!i)return void(0!==z.get()&&z.set(0));const t=e?.sequence.budgets[u];if(!e||!t)return void(0!==z.get()&&z.set(0));const r=xt(e.progressPx,0,e.totalBudgetPx),a=t.enterStartPx,o=Math.max(t.enterEndPx,t.enterStartPx+1),s="number"==typeof t.phaseStartPx?t.phaseStartPx:Ft(I,a,a,o),c=Math.max("number"==typeof t.phaseEndPx?t.phaseEndPx:Ft(C,o,a,o),s+1);if(r>=c&&!ee.current&&(ee.current=!0,he(G.current)),r<=s)return void(0!==z.get()&&z.set(0));if(!t.hasExit)return r>=c?void(1!==z.get()&&z.set(1)):void z.set(xt((r-s)/Math.max(c-s,1),0,1));const l=t.exitStartPx??c,d=t.exitEndPx??l+1;r<=c?z.set(xt((r-s)/Math.max(c-s,1),0,1)):r<=l?1!==z.get()&&z.set(1):r>=d?-1!==z.get()&&z.set(-1):z.set(-xt((r-l)/Math.max(d-l,1),0,1))},[u,U,X,C,I,he,_,z,i,n]);(0,t.useEffect)(()=>{if(!P)return;const e=()=>Pe(N.get());return e(),U||X?N.on("change",e):void 0},[Pe,U,X,P,N]),(0,t.useEffect)(()=>{P||Me()},[q,P,Me,e?.scrollProgress,e?.scrollTimelineState]),(0,t.useEffect)(()=>{if(P)return;const e=B.current;return e instanceof HTMLElement&&!(typeof window>"u")?function(e,t){const n=function(e){const t=jt.get(e);if(t)return t;const n=function(e){return typeof window<"u"&&e===window||typeof Window<"u"&&e instanceof Window}(e),r=n?e:e.ownerDocument?.defaultView??window,i=r.requestAnimationFrame?.bind(r)??(e=>r.setTimeout(()=>e(Date.now()),16)),a=r.cancelAnimationFrame?.bind(r)??(e=>r.clearTimeout(e)),o={subscribers:new Set,frame:null,requestFrame:i,cancelFrame:a,schedule:()=>{null===o.frame&&(o.frame=o.requestFrame(()=>{o.frame=null;const t=n?{top:0,height:e.innerHeight||1}:{top:e.getBoundingClientRect().top,height:e.clientHeight||r.innerHeight||1};[...o.subscribers].forEach(e=>e(t))}))},cleanup:()=>{e.removeEventListener("scroll",o.schedule),n||r.removeEventListener("resize",o.schedule),null!==o.frame&&(o.cancelFrame(o.frame),o.frame=null)}};return e.addEventListener("scroll",o.schedule,{passive:!0}),n||r.addEventListener("resize",o.schedule,{passive:!0}),jt.set(e,o),o}(e);return n.subscribers.add(t),n.schedule(),()=>{n.subscribers.delete(t),0===n.subscribers.size&&(n.cleanup(),jt.delete(e))}}(e.closest('[data-cineview-container="true"]')??window,Me):void 0},[q,P,Me]),(0,t.useEffect)(()=>ye,[ye]);const Ie=(0,t.useRef)(!1),Ce=(0,t.useCallback)(t=>{if(!(l&&P&&n&&i))return void(Ie.current&&(Ie.current=!1,$(!1)));const r=e?.runtimeState,a=void 0===r||"covered"!==r&&"inactive"!==r&&"parked"!==r&&"exiting"!==r;if(!U&&!X)return void(Ie.current!==a&&(Ie.current=a,$(a)));const o=t?.sequence.budgets[u];if(!t||!o||!a)return void(Ie.current&&(Ie.current=!1,$(!1)));const s=xt(t.progressPx,0,t.totalBudgetPx),c=o.enterStartPx,d=Math.max(o.enterEndPx,o.enterStartPx+1),f="number"==typeof o.phaseStartPx?o.phaseStartPx:Ft(I,c,c,d),m=Math.max("number"==typeof o.phaseEndPx?o.phaseEndPx:Ft(C,d,c,d),f+1),g=U?s>=m-.5:s>.5,p=!o.hasExit||null===o.exitStartPx||s<=o.exitStartPx+.5,h=g&&p;Ie.current!==h&&(Ie.current=h,$(h))},[u,U,X,l,P,C,I,e?.runtimeState,$,i,n]);return(0,t.useEffect)(()=>{if(P&&l)return Ce(N.get()),U||X?N.on("change",Ce):void 0;Ce(null)},[U,X,l,P,Ce,N]),{style:Ct(z,j,(e,t,n)=>function(e,t,n){const r=n>=0,i=r?e.enterAnimate:e.exitTarget;return wt(Et(r?e.enterInitial:e.enterAnimate,t,Rt(t,r?"initial":"animate")),i,t,Rt(t,r?"animate":"exit"),r?n:Math.abs(n))}(t,n,e)).style,shouldRunInfinite:F,visualMotion:z,phaseMotion:Z}}({sceneContext:"scroll"===B?p:null,zoneRuntime:"scroll"===B?Le:null,zoneId:b,enterVariant:w,exitVariant:M,hasAuthoredEnterAnimation:!!e,hasAuthoredExitAnimation:!!i,hasInfiniteAnimation:!!k,componentId:g,duration:{enter:De,exit:Te},timeline:K,visibility:$.visibility,globalEnterMargin:h?.scrollEnterMargin,globalExitMargin:h?.scrollExitMargin,enterRef:we?d:void 0,exitRef:we?f:void 0,variantsPending:Se});(0,t.useEffect)(()=>{if("drag"!==B||0===I)return;const e=L.current;!e||e.generation!==I||(e.lease.complete(),L.current=null)},[B,I]);const ze=function({mode:e,isDragArrival:n,timelineLane:i,sceneContext:a,arrivalVisualMotion:o,arrivalPhaseMotion:s,scrollVisualMotion:c,scrollPhaseMotion:l,dragVisualState:u}){const d=(0,r.useMotionValue)(0),f=(0,r.useMotionValue)(0),m=(0,r.useMotionValue)("idle"),g=(0,r.useMotionValue)(dn);return(0,t.useEffect)(()=>{const t="scroll"===e||n?i:"drag",r=e=>{d.set(e.progress),f.set(e.signedProgress),m.set(e.phase),g.set(e)};if("scroll"===e||n){const e=n?o:c,i=n?s:l,a=()=>{const n=e.get();r({progress:Ht(n),signedProgress:n,phase:i.get(),source:"scroll"===t?"scroll":"visibility"})};a();const u=e.on("change",a),d=i.on("change",a);return()=>{u(),d()}}const p=e=>{if(!e)return void r(dn);const t=Math.max(0,Math.min(1,e.localProgress)),n="outgoing"===e.mode?("forward"===e.direction?1:-1)*t:t;r({progress:t,signedProgress:n,phase:qt(e.mode,t),source:fn(a,e)})};return p(u.get()),u.on("change",p)},[s,o,u,n,e,g,m,d,f,i,a,l,c]),(0,t.useMemo)(()=>({mode:e,lane:"scroll"===e||n?i:"drag",progress:d,signedProgress:f,phase:m,frame:g}),[n,e,g,m,d,f,i])}({mode:B,isDragArrival:Y,timelineLane:"scroll"===B||Y?K.lane:"drag",sceneContext:p,arrivalVisualMotion:Ve.visualMotion,arrivalPhaseMotion:Ve.phaseMotion,scrollVisualMotion:je.visualMotion,scrollPhaseMotion:je.phaseMotion,dragVisualState:Oe.visualState});(0,t.useEffect)(()=>{const e=Y?ge:k;if("drag"===B&&e){if(x||!(Y?Ve.shouldRunInfinite:Oe.shouldRunInfinite))return void N.stop();N.start({...e.animate,transition:{...e.animate.transition||{},repeat:1/0}})}},[Ve.shouldRunInfinite,N,Oe.shouldRunInfinite,k,Y,B,x,ge]),(0,t.useEffect)(()=>{if("scroll"===B&&k){if(x||!je.shouldRunInfinite)return void F.stop();F.start({...k.animate,transition:{...k.animate.transition||{},repeat:1/0}})}},[B,k,x,je.shouldRunInfinite,F]);const Ne=xe?m:void 0,Fe=xe?null:m,$e=(0,n.jsx)(ln,{value:ze,children:ke?Re&&de?"scroll"===B?(0,n.jsx)(an,{container:Re,variant:de,each:Pe,from:Ie,itemDurationMs:Ce?.itemDurationMs,effectiveDurationMs:Ce?.effectiveDurationMs,exitVariant:fe,exitItemDurationMs:Ae?.itemDurationMs,signedVisual:je.visualMotion}):Y?(0,n.jsx)(on,{container:Re,variant:de,each:Pe,from:Ie,itemDurationMs:Ce?.itemDurationMs,effectiveDurationMs:Ce?.effectiveDurationMs,phaseMotion:Ve.phaseMotion,staticReveal:Ve.staticReveal}):(0,n.jsx)(sn,{container:Re,variant:de,each:Pe,from:Ie,itemDurationMs:Ce?.itemDurationMs,effectiveDurationMs:Ce?.effectiveDurationMs,exitVariant:fe,exitItemDurationMs:Ae?.itemDurationMs,visualState:Oe.visualState}):null:Ne?"scroll"===B||Y?(0,n.jsx)(Xt,{signedVisual:Y?Ve.visualMotion:je.visualMotion,phaseMotion:Y?Ve.phaseMotion:je.phaseMotion,render:Ne}):(0,n.jsx)(Kt,{visualState:Oe.visualState,render:Ne}):Fe}),Be=ke?vn:je.style,qe=ke?vn:Y?Ve.style:Oe.style;return de||fe||ge||Se?"scroll"===B?ge?(0,n.jsx)("div",{"data-cineview-animate-host":g,children:(0,n.jsx)(r.motion.div,{style:Be,className:"cineview-animate","data-cineview-animate-id":g,children:(0,n.jsx)(r.motion.div,{animate:F,children:$e})})}):(0,n.jsx)("div",{"data-cineview-animate-host":g,children:(0,n.jsx)(r.motion.div,{style:Be,className:"cineview-animate","data-cineview-animate-id":g,children:$e})}):ge?(0,n.jsx)(r.motion.div,{style:qe,className:"cineview-animate","data-cineview-animate-id":g,children:(0,n.jsx)(r.motion.div,{animate:N,children:$e})}):(0,n.jsx)(r.motion.div,{style:qe,className:"cineview-animate","data-cineview-animate-id":g,children:$e}):(0,n.jsx)(ln,{value:ze,children:Ne?Ne(Ut):Fe})};xn.displayName="Animate";var Sn=(0,t.createContext)({lastX:0,lastY:0}),bn=(0,t.createContext)(null),wn=(0,t.forwardRef)(function({at:e,x:r,y:a,offsetX:o,offsetY:s,fixed:c=!1,children:l,style:u,className:d,...f},m){const g=v(),p=me(),h=(0,t.useContext)(Sn),y=(0,t.useContext)(bn),x=e?.x??r,S=e?.y??a,b=e?.offsetX??o,w=e?.offsetY??s,E=c,M=e?.anchor,R="center"===M||"center-x"===M,k="center"===M||"center-y"===M,P=E&&"scroll"===p?.mode&&!y,{finalLeft:I,finalTop:C,finalX:A,finalY:D}=(0,t.useMemo)(()=>{const e=g?.convert??(e=>e);if(void 0!==x||void 0!==S){const t=void 0!==x?x:0,n=void 0!==S?S:0;return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}if(void 0!==b||void 0!==w){const t=h.lastX+(void 0!==b?b:0),n=h.lastY+(void 0!==w?w:0);return{finalLeft:e(t),finalTop:e(n),finalX:t,finalY:n}}return{finalLeft:0,finalTop:0,finalX:0,finalY:0}},[g,h,b,w,x,S]),{leftStyle:T,topStyle:L,centerTransform:O}=(0,t.useMemo)(()=>{const e=g?.convert??(e=>e),t=[];let n=I;if(R){const r=e(x??0);n=0===r?"50%":`calc(50% + ${r}px)`,t.push("translateX(-50%)")}let r=C;if(k){const n=e(S??0);r=0===n?"50%":`calc(50% + ${n}px)`,t.push("translateY(-50%)")}return{leftStyle:n,topStyle:r,centerTransform:t.length>0?t.join(" "):void 0}},[g,R,k,x,S,I,C]),V=(0,t.useMemo)(()=>({lastX:A,lastY:D}),[A,D]),j=(0,t.useMemo)(()=>{const e=[O,u?.transform].filter(Boolean).join(" ")||void 0;return{...u,position:P?"sticky":"absolute",left:T,top:L,pointerEvents:E?u?.pointerEvents??"auto":u?.pointerEvents,transform:e}},[P,E,T,L,O,u]),z=(0,n.jsx)(Sn.Provider,{value:V,children:(0,n.jsx)("div",{ref:m,style:j,className:d,...f,children:l})});return E&&y&&!P?(0,i.createPortal)(z,y):z});wn.displayName="Position";var En={opacity:1,x:0,y:0,scale:1,rotate:0};function Mn(e,t){return function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(e)?{...t,...e}:t}function Rn(e){return Math.max(0,Math.min(e,1))}var kn="time",Pn={time:10,percent:1},In={unit:kn,scale:Pn[kn]};function Cn(e,t,n){const r=Math.max(0,Number.isFinite(t)?t:0),i=Number.isFinite(n)?n:0,a="time"===e.unit?e.scale:r*e.scale/100;return Math.min(r,Math.max(0,i*a))}function An(e,t){return"drag"!==e?"auto":"y"===t?"pan-x pinch-zoom":"pan-y pinch-zoom"}function Dn({effectiveMode:e,isActive:t,globalScrollTimelineState:n,hasExitAnimation:r}){if("scroll"!==e||!n)return t?1:0;switch(n.phase){case"before":default:return 0;case"enter":return n.enterProgress;case"hold":return 1;case"exit":return r?1-n.exitProgress:1;case"after":return r?0:1}}function Tn({onVisibilityChange:e,sceneVisibilityCallback:t,sceneIndex:n,visible:r,progress:i}){e?.(r,i),t?.({sceneIndex:n,visible:r,progress:i})}function Ln({effectiveMode:e,effectiveDirection:t,globalScrollTimelineState:n,globalScrollViewportOffset:r,globalViewportWidth:i,globalViewportHeight:a}){if("scroll"!==e)return{visible:!1,isHorizontal:!1,hostOffset:0,hostSpan:0,clipWidth:0,clipHeight:0};const o=n?.rangeStart??0,s=n?.rangeEnd??o,c="x"===t,l=Math.max(s-o,0),u=Math.max(c?i:a,0),d=o-r,f=s-r,m=Math.max(Math.min(u,Math.max(l,1)),1),g=function(e,t,n){return Math.min(n,Math.max(0,e))}(r-o,0,Math.max(l-m,0));return{visible:l>0&&f>0&&d<u,isHorizontal:c,hostOffset:g,hostSpan:m,clipWidth:c?l:0,clipHeight:c?0:l}}function On({sceneIndex:e,metrics:r,setHostRef:i,frameStore:a,direction:o="y",viewportWidth:s=0,viewportHeight:c=0}){const l=(0,t.useRef)(null),u=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(!a||"number"!=typeof e)return;const t=()=>{const t=a.getKeySnapshot(e);if(!t)return;const n=Ln({effectiveMode:"scroll",effectiveDirection:o,globalScrollTimelineState:t.timelineState,globalScrollViewportOffset:t.visualViewportOffset,globalViewportWidth:s,globalViewportHeight:c}),r=l.current,i=u.current;!r||!i||(r.style.width=n.clipWidth>0?`${n.clipWidth}px`:"100%",r.style.height=n.clipHeight>0?`${n.clipHeight}px`:"100%",r.style.opacity=n.visible?"1":"0",r.style.visibility=n.visible?"visible":"hidden",i.style.top=n.isHorizontal?"0px":`${n.hostOffset}px`,i.style.left=n.isHorizontal?`${n.hostOffset}px`:"0px",i.style.width=n.isHorizontal&&n.hostSpan>0?`${n.hostSpan}px`:"100%",i.style.height=n.isHorizontal?"100%":n.hostSpan>0?`${n.hostSpan}px`:"100%")};return t(),a.subscribeKey(e,t)},[o,a,e,c,s]),(0,n.jsx)("div",{ref:l,"data-scene-fixed-layer":e,"data-scene-fixed-role":"clip",style:{position:"absolute",inset:0,width:r.clipWidth>0?r.clipWidth:"100%",height:r.clipHeight>0?r.clipHeight:"100%",overflow:"hidden",pointerEvents:"none",opacity:r.visible?1:0,visibility:r.visible?"visible":"hidden",zIndex:20},children:(0,n.jsx)("div",{ref:u,"data-scene-fixed-layer":e,"data-scene-fixed-role":"frame",style:{position:"absolute",top:r.isHorizontal?0:r.hostOffset,left:r.isHorizontal?r.hostOffset:0,width:r.isHorizontal&&r.hostSpan>0?r.hostSpan:"100%",height:r.isHorizontal?"100%":r.hostSpan>0?r.hostSpan:"100%",pointerEvents:"none"},children:(0,n.jsx)("div",{ref:i,"data-scene-fixed-layer":e,"data-scene-fixed-host":e,"data-scene-fixed-role":"host",style:{position:"relative",width:"100%",height:"100%",pointerEvents:"none"}})})})}function Vn(e,t){return e===t||"visibility"===e&&"scroll"===t}var jn=class{constructor(e){this.source=new Map(e),Object.freeze(this)}get size(){return this.source.size}get(e){return this.source.get(e)}has(e){return this.source.has(e)}forEach(e,t){this.source.forEach((n,r)=>e.call(t,n,r,this))}entries(){return this.source.entries()}keys(){return this.source.keys()}values(){return this.source.values()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"ImmutableMapView"}};function zn(e){return new jn(e)}function Nn(e){switch(e.type){case"missing-dependency":return`${e.type}:${e.animateId}:${e.after}`;case"circular-dependency":return`${e.type}:${e.animateId}:${e.cycle.join(">")}`;case"duplicate-id":return`${e.type}:${e.animateId}`;case"incompatible-lane":return`${e.type}:${e.animateId}:${e.after}:${e.followerLane}:${e.leaderLane}`}}function Fn(e,t){const n=Nn(t);e.some(e=>Nn(e)===n)||e.push(t)}function $n({baseDuration:e,registrations:t,declaredLanes:n=new Map,duplicateIds:r=[]}){const i=new Map,a=[],o=new Set,s=new Set;Array.from(r).forEach(e=>{Fn(a,{type:"duplicate-id",animateId:e})});const c=(e,r)=>{const l=i.get(e);if(void 0!==l)return l;const u=t.get(e);if(o.has(e)){const t=r.indexOf(e),n=function(e){const t=e.slice(0,-1);let n=0;for(let e=1;e<t.length;e+=1)t[e]<t[n]&&(n=e);const r=t.slice(n).concat(t.slice(0,n));return r.concat(r[0])}(r.slice(t).concat(e));return n.slice(0,-1).forEach(e=>s.add(e)),Fn(a,{type:"circular-dependency",animateId:n[0],cycle:n}),i.set(e,u.delay),u.delay}o.add(e);let d=u.delay;if(u.after){const i=t.get(u.after),o=n.get(u.after);if(i)if(void 0===u.lane||void 0===i.lane||Vn(u.lane,i.lane)){const t=c(u.after,r.concat(e));("visibility"!==u.lane||"scroll"!==i.lane)&&!s.has(e)&&(d+=t+i.duration)}else Fn(a,{type:"incompatible-lane",animateId:e,after:u.after,followerLane:u.lane,leaderLane:i.lane});else void 0===u.lane||void 0===o||Vn(u.lane,o)?Fn(a,{type:"missing-dependency",animateId:e,after:u.after}):Fn(a,{type:"incompatible-lane",animateId:e,after:u.after,followerLane:u.lane,leaderLane:o})}return o.delete(e),i.set(e,d),d};t.forEach((e,t)=>{c(t,[])});let l=Math.max(e,0);return t.forEach((e,t)=>{const n=i.get(t);l=Math.max(l,n+e.duration)}),{registrations:new Map(t),calculatedDelays:i,issues:a,timelineDuration:l}}function Bn(e){switch(e.type){case"missing-dependency":return`${e.type}:${e.animateId}:${e.after}`;case"circular-dependency":return`${e.type}:${e.animateId}:${e.cycle.join(">")}`;case"duplicate-id":return`${e.type}:${e.animateId}`;case"incompatible-lane":return`${e.type}:${e.animateId}:${e.after}:${e.followerLane}:${e.leaderLane}`}}function qn(e){let t;return e.forEach(e=>{t=e}),t}function Hn(e,t,n=Object.is){if(e.size!==t.size)return!1;for(const[r,i]of e){const e=t.get(r);if(void 0===e||!n(i,e))return!1}return!0}function Wn(){return typeof performance<"u"?performance.now():Date.now()}function Yn(e,t,n){const r=e.panInfo??{point:{x:0,y:0},delta:{x:0,y:0},offset:{x:0,y:0},velocity:{x:0,y:0}};return r.point.x=t,r.point.y=n,r.delta.x=t-e.lastX,r.delta.y=n-e.lastY,r.offset.x=t-e.startX,r.offset.y=n-e.startY,r.velocity.x=e.velocityX,r.velocity.y=e.velocityY,e.panInfo=r,r}var Un=t.default.createContext(null),Xn=new Set(["children","sceneId","layout","stack","transition","assets","drag","scroll","callbacks","runtimeMode","runtimeDirection","isActive","sceneIndex","totalScenes","currentSceneIndex","sceneRuntime","dragRuntime","scrollRuntime","onDragGestureEnd","onDragReset","onActivationComplete","onDragProgressChange","onRenderProgressChange","onDragTimelineProgressChange","onSharedElapsedMsChange","onDraggingChange","onSharedTimelineDurationChange","onDragRelease","onScrollProgressChange","onScrollDirectionChange","onScrollingChange","onScrollCommit","onScrollReset","onSceneChange","mode","slideDirection","slideDuration","sceneTransitionDuration","enterAnimation","exitAnimation","exitDuration","sceneWidth","sceneHeight","sceneAnchor","sceneZIndex","sceneOverflow","sceneStackMode","scrollSpeed","scrollControlled","scrollCommitThreshold","scrollReleaseDuration","scrollLockToSingleScene","scrollEnterLength","scrollHoldLength","scrollExitLength","onVisibilityChange","preloadImages"]),Kn=t.default.forwardRef(function(e,i){const{children:a,className:o,style:s,onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:d}=e,{effectiveMode:f,effectiveDirection:m,isActive:g,sceneIndex:p,totalScenes:h,currentSceneIndex:y,globalDirection:x,globalSharedTimelineDurationMs:S,globalActivationToken:b,globalActivationKind:w,globalFirstSceneEnterGateKnown:E,globalFirstSceneEnterActive:M,globalFirstSceneEnterReady:R,globalViewportWidth:k,globalViewportHeight:P,globalDragProgress:I,globalRenderProgress:C,globalDragTimelineProgress:A,globalIsDragging:D,globalDragRelease:T,globalScrollProgress:L,globalIsScrolling:O,globalScrollDirection:V,globalScrollTransitionSnapshot:j,globalScrollBackdropActive:z,globalScrollTimelineState:N,globalScrollViewportOffset:F,resolvedSceneWidth:$,resolvedSceneHeight:B,resolvedSceneAnchor:q,resolvedSceneOverflow:H,resolvedSceneZIndex:W,effectiveSceneStackMode:Y,resolvedSceneTransitionDuration:U,resolvedEnterAnimation:X,resolvedExitAnimation:K,sceneVisibilityCallback:Z,onVisibilityChange:_,onSceneChange:G,dragRuntime:J,onActivationComplete:Q,onDragProgressChange:ee,onRenderProgressChange:te,onDragTimelineProgressChange:ne,onDraggingChange:re,onSharedTimelineDurationChange:ae,onDragRelease:se,onDragGestureEnd:ce,onDragReset:le,slideDuration:ue,compatFields:de}=function(e){const t=e.sceneRuntime?.mode??e.runtimeMode??e.mode??"drag";return{effectiveMode:t,effectiveDirection:e.sceneRuntime?.direction??e.runtimeDirection??e.slideDirection??"y",isActive:e.sceneRuntime?.isActive??e.isActive??!1,sceneIndex:e.sceneRuntime?.sceneIndex??e.sceneIndex??0,totalScenes:e.sceneRuntime?.totalScenes??e.totalScenes??1,currentSceneIndex:e.sceneRuntime?.currentSceneIndex??e.currentSceneIndex??0,globalDirection:e.sceneRuntime?.transitionDirection??null,globalIsSceneAnimating:e.sceneRuntime?.isSceneAnimating??!1,globalSharedTimelineDurationMs:e.sceneRuntime?.sharedTimelineDurationMs??0,globalActivationToken:e.sceneRuntime?.activationToken??0,globalActivationKind:e.sceneRuntime?.activationKind??null,globalFirstSceneEnterGateKnown:e.sceneRuntime?.firstSceneEnterGateKnown??!0,globalFirstSceneEnterActive:e.sceneRuntime?.firstSceneEnterActive??!1,globalFirstSceneEnterReady:e.sceneRuntime?.firstSceneEnterReady??!1,globalViewportWidth:e.sceneRuntime?.viewportWidth??0,globalViewportHeight:e.sceneRuntime?.viewportHeight??0,globalDragProgress:e.dragRuntime?.progress??0,globalRenderProgress:e.dragRuntime?.renderProgress??0,globalDragTimelineProgress:e.dragRuntime?.timelineProgress??0,globalIsDragging:e.dragRuntime?.isDragging??!1,globalDragRelease:e.dragRuntime?.release??null,globalScrollProgress:e.scrollRuntime?.progress??0,globalIsScrolling:e.scrollRuntime?.isScrolling??!1,globalScrollDirection:e.scrollRuntime?.direction??null,globalScrollTransitionSnapshot:e.scrollRuntime?.transitionSnapshot??null,globalScrollBackdropActive:e.scrollRuntime?.backdropActive??!1,globalScrollTimelineState:e.scrollRuntime?.timelineState??null,globalScrollActiveSceneIndex:e.scrollRuntime?.activeSceneIndex??0,globalScrollViewportOffset:e.scrollRuntime?.viewportOffset??0,resolvedSceneWidth:e.layout?.width??e.sceneWidth??"100vw",resolvedSceneHeight:e.layout?.height??e.sceneHeight??("scroll"===t?"auto":"100vh"),resolvedSceneAnchor:e.layout?.anchor??e.sceneAnchor??"top-left",resolvedSceneOverflow:e.layout?.overflow??e.sceneOverflow??"hidden",resolvedSceneZIndex:e.layout?.zIndex??e.sceneZIndex,effectiveSceneStackMode:e.layout?.overlap??e.sceneStackMode??("scroll"===t?"cover":"replace"),resolvedSceneTransitionDuration:e.sceneTransitionDuration??e.transition?.exitDuration??e.exitDuration??800,resolvedEnterAnimation:e.transition?.enterAnimation??e.enterAnimation,resolvedExitAnimation:e.transition?.exitAnimation??e.exitAnimation,sceneVisibilityCallback:e.callbacks?.onVisibilityChange,onVisibilityChange:e.onVisibilityChange,onSceneChange:e.onSceneChange,scrollCommitThreshold:e.scrollCommitThreshold??.42,scrollReleaseDuration:e.scrollReleaseDuration??220,scrollLockToSingleScene:e.scrollLockToSingleScene??!0,scrollRuntime:e.scrollRuntime,dragRuntime:e.dragRuntime,onActivationComplete:e.onActivationComplete,onDragProgressChange:e.onDragProgressChange,onRenderProgressChange:e.onRenderProgressChange,onDragTimelineProgressChange:e.onDragTimelineProgressChange,onSharedElapsedMsChange:e.onSharedElapsedMsChange,onDraggingChange:e.onDraggingChange,onSharedTimelineDurationChange:e.onSharedTimelineDurationChange,onDragRelease:e.onDragRelease,onDragGestureEnd:e.onDragGestureEnd,onDragReset:e.onDragReset,onScrollProgressChange:e.onScrollProgressChange,onScrollDirectionChange:e.onScrollDirectionChange,onScrollingChange:e.onScrollingChange,onScrollCommit:e.onScrollCommit,onScrollReset:e.onScrollReset,slideDuration:e.slideDuration??800,compatFields:[e.mode,e.slideDirection,e.scrollSpeed,e.scrollControlled,e.scrollCommitThreshold,e.scrollReleaseDuration,e.scrollLockToSingleScene,e.runtimeMode,e.runtimeDirection,e.isActive,e.sceneIndex,e.totalScenes,e.currentSceneIndex,e.onActivationComplete,e.onDragProgressChange,e.onRenderProgressChange,e.onDragTimelineProgressChange,e.onSharedElapsedMsChange,e.onDraggingChange,e.onSharedTimelineDurationChange,e.onDragGestureEnd,e.onDragReset,e.onScrollProgressChange,e.onScrollDirectionChange,e.onScrollingChange,e.onScrollCommit,e.onScrollReset,e.scrollRuntime,e.dragRuntime,e.sceneRuntime]}}(e),fe=e.scrollRuntime?.frameStore,ge=e.scrollRuntime?.sceneIndex??p,pe=v(),he=me(),ve=he?.reportError,ye=(0,r.useAnimation)(),[xe,Se]=(0,t.useState)(null),[be,we]=(0,t.useState)(null),Ee=(0,t.useRef)(0);(0,t.useRef)(null);const Me=pn(X),Re=pn(K),ke=!!(J||e.onDragProgressChange||e.onRenderProgressChange||e.onDragTimelineProgressChange||e.onDraggingChange||e.onSharedTimelineDurationChange||e.onDragGestureEnd||e.onDragReset),[Pe,Ie]=(0,t.useState)(I),[Ce,Ae]=(0,t.useState)(C),[De,Te]=(0,t.useState)(A),[Le,Oe]=(0,t.useState)(D),[Ve,je]=(0,t.useState)(S),[ze,Ne]=(0,t.useState)(T),Fe=(0,t.useRef)(0),$e=(0,t.useCallback)(e=>{null!==e?(Fe.current+=1,Ne({...e,token:Fe.current})):Ne(null)},[]),Be=ke?I:Pe,qe=ke?C:Ce,He=ke?A:De,We=ke?D:Le,Ye=ke?S:Ve,Ue=ke?T:ze,Xe=We,Ke=(0,r.useMotionValue)(Be),Ze=J?.renderProgressMotion??Ke,_e=(0,r.useMotionValue)(He),Ge=J?.timelineProgressMotion??_e,Je=(0,r.useMotionValue)(0),[Qe,et]=(0,t.useState)("initial"),tt=p-y,[nt,rt]=(0,t.useState)(!1),it=(0,t.useRef)(Symbol(`scene:${p}`)),at=(0,t.useRef)(null),ot=(0,t.useRef)(J?.onPreparedInvalidated);ot.current=J?.onPreparedInvalidated;const[st,ct]=(0,t.useState)(null),lt=(0,t.useMemo)(()=>J?.dragMappingConfig??function(e,t,n){const r=function(e){return void 0!==e?.unit||void 0!==e?.scale}(t)?t:void 0,i=r?.unit;if(void 0!==i&&!function(e){return"time"===e||"percent"===e}(i))return n?.({field:"unit",value:i}),{unit:kn,scale:Pn.time};const a=i??"time",o=r?.scale;return void 0!==o&&("number"!=typeof o||!Number.isFinite(o)||o<0)?(n?.({field:"scale",value:o}),{unit:a,scale:Pn[a]}):{unit:a,scale:o??Pn[a]}}(0,e.drag),[J?.dragMappingConfig,e.drag]),ut=(0,t.useCallback)((t,n,r)=>{if("drag"!==f)return;const i=function(e){return Object.freeze({...e,mapping:Object.freeze({...e.mapping}),enterVariantsByAnimateId:zn(e.enterVariantsByAnimateId)})}({sceneIndex:p,instanceId:it.current,revision:n,enabled:!1!==e.drag?.enabled,mapping:lt,registrySnapshot:t,enterVariantsByAnimateId:r});at.current=i,ct(i),J?.onPrepared?.(i)},[J,f,lt,e.drag?.enabled,p]),{timelineDuration:dt,beginPreparation:ft,registerAnimate:mt,declareAnimateLane:gt,unregisterAnimate:ht,getCalculatedDelay:yt,getTimelineDuration:xt}=function({sceneIndex:e,baseDuration:n,reportError:r,onStableSnapshot:i}){const a=(0,t.useRef)(new Map),o=(0,t.useRef)(new Map),s=(0,t.useRef)(new Map),c=(0,t.useRef)(new Map),l=(0,t.useRef)(new Set),u=(0,t.useRef)($n({baseDuration:n,registrations:s.current})),d=(0,t.useRef)(new Set),f=(0,t.useRef)(null),m=(0,t.useRef)(new Map),g=(0,t.useRef)(0),p=(0,t.useRef)(0),h=(0,t.useRef)(0),v=(0,t.useRef)(null),y=(0,t.useRef)(null),x=(0,t.useRef)(!0),S=(0,t.useRef)(r);S.current=r;const b=(0,t.useRef)(i);b.current=i;const w=(0,t.useRef)(n),[E,M]=(0,t.useState)(n),[R,k]=(0,t.useState)(!1),P=(0,t.useCallback)(()=>{x.current&&k(!1)},[]),I=(0,t.useCallback)(t=>{t.forEach(t=>{const n=Bn(t);if(d.current.has(n))return;let r,i;d.current.add(n),"missing-dependency"===t.type?(r="INVALID_ANIMATION",i=`Animate "${t.animateId}" references non-existent component "${t.after}" via after in Scene ${e}.`):"circular-dependency"===t.type?(r="CIRCULAR_DEPENDENCY",i=`Animate after chain contains a cycle in Scene ${e}: ${t.cycle.join(" -> ")}.`):"duplicate-id"===t.type?(r="INVALID_COMPONENT_HIERARCHY",i=`More than one Animate component registered animateId "${t.animateId}" in Scene ${e}.`):(r="INVALID_ANIMATION",i=`Animate "${t.animateId}" uses ${t.followerLane} after "${t.after}" driven by ${t.leaderLane} in Scene ${e}; this dependency direction is incompatible.`),S.current?.({code:r,message:i,context:{sceneIndex:e}})})},[e]),C=(0,t.useCallback)(()=>{s.current.clear(),c.current.clear(),l.current.clear(),a.current.forEach((e,t)=>{const n=qn(e);n&&s.current.set(t,n.info),e.size>1&&l.current.add(t)}),o.current.forEach((e,t)=>{let n;e.forEach(e=>{e.disposed||(n=e)}),n&&c.current.set(t,n.lane)})},[]),A=(0,t.useCallback)(()=>{C();const e=$n({baseDuration:n,registrations:s.current,declaredLanes:c.current,duplicateIds:l.current});return u.current=e,w.current=e.timelineDuration,x.current&&M(t=>t===e.timelineDuration?t:e.timelineDuration),e},[n,C]),D=(0,t.useCallback)(e=>u.current.issues.some(t=>"circular-dependency"===t.type&&t.cycle.includes(e)),[]),T=(0,t.useCallback)((e,t)=>{const{follower:n,leaderId:r}=e,i=a.current.get(r),o=c.current.get(r);if(!i||0===i.size)return t&&void 0!==o&&void 0!==n.info.lane&&!Vn(n.info.lane,o)?(e.sawLeader=!0,{kind:"invalid",leaderId:r,reason:"incompatible-lane"}):t?{kind:"invalid",leaderId:r,reason:e.sawLeader?"leader-unregistered":"missing"}:{kind:"pending",leaderId:r};e.sawLeader=!0;const s=qn(i);return t&&D(n.id)?{kind:"invalid",leaderId:r,reason:"cycle"}:t&&i.size>1?{kind:"invalid",leaderId:r,reason:"duplicate"}:t&&void 0!==n.info.lane&&void 0!==s.info.lane&&!Vn(n.info.lane,s.info.lane)?{kind:"invalid",leaderId:r,reason:"incompatible-lane"}:s.enterCompleted?{kind:"satisfied",source:"completed",leaderId:r,generation:s.generation}:{kind:"pending",leaderId:r,generation:s.generation}},[D]),L=(0,t.useCallback)((e,t)=>{if(e.terminal)return;const n=function(e){return"invalid"===e.kind?`${e.kind}:${e.leaderId}:${e.reason}`:`${e.kind}:${e.leaderId??""}:${e.generation??""}:${"satisfied"===e.kind?e.source:""}`}(t);e.lastSignature!==n&&(e.lastSignature=n,e.listener(t),"pending"!==t.kind&&(e.terminal=!0))},[]),O=(0,t.useCallback)(e=>{m.current.forEach(t=>{[...t].forEach(n=>{n.follower.disposed||n.terminal?t.delete(n):(L(n,T(n,e)),n.terminal&&t.delete(n))})}),m.current.forEach((e,t)=>{0===e.size&&m.current.delete(t)})},[L,T]),V=(0,t.useCallback)(e=>{if(0!==p.current||!x.current)return;const t=new Map;a.current.forEach((e,n)=>{const r=qn(e);r?.enterVariant&&t.set(n,r.enterVariant)});const n=v.current,r=y.current,i=null!==n&&null!==r&&function(e,t){return e.timelineDuration===t.timelineDuration&&Hn(e.registrations,t.registrations,(e,t)=>e.delay===t.delay&&e.duration===t.duration&&e.after===t.after&&e.lane===t.lane)&&Hn(e.calculatedDelays,t.calculatedDelays)&&e.issues.length===t.issues.length&&e.issues.every((e,n)=>Bn(e)===Bn(t.issues[n]))}(n,e)&&Hn(r,t);k(!0),!i&&(h.current+=1,v.current=e,y.current=new Map(t),b.current?.(function(e){const t=[];return e.registrations.forEach((e,n)=>{t.push([n,Object.freeze({...e})])}),Object.freeze({registrations:zn(t),calculatedDelays:zn(e.calculatedDelays),issues:Object.freeze([...e.issues]),timelineDuration:e.timelineDuration})}(e),h.current,t))},[]),j=(0,t.useCallback)(()=>{if(0!==p.current||!x.current)return;null!==f.current&&(clearTimeout(f.current),f.current=null);const e=A();I(e.issues),O(!0),V(e)},[V,A,O,I]),z=(0,t.useCallback)(()=>{P(),null!==f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,j()},0)},[j,P]),N=(0,t.useCallback)(()=>{p.current+=1,P();let e=!1;const t=()=>!e&&(e=!0,p.current=Math.max(0,p.current-1),0===p.current);return{complete:()=>{t()&&j()},cancel:()=>{t()&&z()}}},[j,P,z]),F=(0,t.useCallback)(e=>{m.current.forEach((t,n)=>{t.forEach(n=>{n.follower.token===e.token&&t.delete(n)}),0===t.size&&m.current.delete(n)})},[]),$=(0,t.useCallback)(e=>{if(e.disposed)return;e.disposed=!0,F(e);const t=a.current.get(e.id);t?.delete(e.token),0===t?.size&&a.current.delete(e.id),A(),z()},[A,F,z]),B=(0,t.useCallback)((e,t)=>{const n={token:Symbol(e),id:e,generation:++g.current,info:t,enterVariant:null,enterCompleted:!1,disposed:!1};let r=a.current.get(e);return r||(r=new Map,a.current.set(e,r)),r.set(n.token,n),A(),z(),s.current.size>100&&s.current.size,{animateId:e,generation:n.generation,getCalculatedDelay:()=>u.current.calculatedDelays.get(e)??n.info.delay,setEnterVariant:t=>{n.disposed||a.current.get(e)?.has(n.token)&&(n.enterVariant=t,z())},observeAfter:e=>{if(!n.info.after)return e({kind:"satisfied",source:"none"}),()=>{};const t={follower:n,listener:e,leaderId:n.info.after,sawLeader:!1,lastSignature:null,terminal:!1};let r=m.current.get(t.leaderId);return r||(r=new Set,m.current.set(t.leaderId,r)),r.add(t),L(t,T(t,0===p.current&&null===f.current)),()=>{t.terminal=!0,r?.delete(t),0===r?.size&&m.current.delete(t.leaderId)}},publishEnterCompleted:()=>{n.disposed||n.enterCompleted||a.current.get(e)?.has(n.token)&&(n.enterCompleted=!0,O(!1))},dispose:()=>$(n)}},[$,L,T,A,O,e,z]),q=(0,t.useCallback)((e,t)=>{const n={token:Symbol(e),id:e,lane:t,disposed:!1};let r=o.current.get(e);return r||(r=new Map,o.current.set(e,r)),r.set(n.token,n),A(),z(),{dispose:()=>{if(n.disposed)return;n.disposed=!0;const t=o.current.get(e);t?.delete(n.token),0===t?.size&&o.current.delete(e),A(),z()}}},[A,z]),H=(0,t.useCallback)(e=>{const t=a.current.get(e),n=t?qn(t):void 0;n&&$(n)},[$]),W=(0,t.useCallback)(e=>u.current.calculatedDelays.get(e)??s.current.get(e)?.delay??0,[]),Y=(0,t.useCallback)(()=>w.current,[]);return(0,t.useEffect)(()=>{z()},[n,z]),(0,t.useEffect)(()=>{x.current=!0;const e=a.current,t=o.current,n=s.current,r=c.current,i=l.current,u=d.current,g=m.current;return()=>{x.current=!1,null!==f.current&&(clearTimeout(f.current),f.current=null),p.current=0,e.clear(),t.clear(),n.clear(),r.clear(),i.clear(),u.clear(),g.clear()}},[]),{timelineDuration:E,isStable:R,beginPreparation:N,registerAnimate:B,declareAnimateLane:q,unregisterAnimate:H,getCalculatedDelay:W,getTimelineDuration:Y}}({sceneIndex:p,baseDuration:"drag"===f?0:U,reportError:he?.reportError,onStableSnapshot:ut}),St=(0,t.useRef)(!1);(0,t.useEffect)(()=>{St.current||t.default.Children.count(a)>0||(St.current=!0,ve?.({code:"EMPTY_SCENES",message:`Scene ${p} has no children; it renders an empty full-screen layer.`,context:{scope:"scene",sceneIndex:p}}))},[a,ve,p]),(0,t.useEffect)(()=>()=>{const e=at.current;e&&ot.current?.({sceneIndex:e.sceneIndex,instanceId:e.instanceId,revision:e.revision})},[]);const bt=(0,t.useRef)(null),wt=(0,t.useCallback)(e=>{bt.current=e,"function"==typeof i?i(e):i&&(i.current=e)},[i]),[Et,Mt]=(0,t.useState)(null),Rt=(0,t.useCallback)(e=>{Mt(t=>t===e?t:e)},[]),kt=function({sceneId:e,sceneIndex:n,mode:r,scroll:i,elementRef:a}){const o=(0,t.useContext)(ie),s=(0,t.useId)(),c=i?.zoneId??e??`scene-zone-${s}`,l=o?.registerZone,u=o?.unregisterZone,d=o?.setZoneElement,f=!!i;return(0,t.useEffect)(()=>{if("scroll"===r&&f&&l&&u)return l(c,{sceneIndex:n}),()=>{u(c,n)}},[r,f,l,u,c,n]),(0,t.useEffect)(()=>{if("scroll"===r&&f&&d)return d(c,n,a.current),()=>{d(c,n,null)}},[a,r,f,n,d,c]),"scroll"===r&&i?c:null}({sceneId:e.sceneId,sceneIndex:p,mode:f,scroll:e.scroll,elementRef:bt});(0,t.useEffect)(()=>{J?.renderProgressMotion||Ke.set(Be)},[Be,J?.renderProgressMotion,Ke]),(0,t.useEffect)(()=>{J?.timelineProgressMotion||_e.set(He)},[He,J?.timelineProgressMotion,_e]),(0,t.useEffect)(()=>{ke&&(Ie(I),Ae(C),Te(A),Oe(D),je(S),Ne(T))},[ke,I,C,A,D,S,T]);const Pt=(0,t.useCallback)(e=>"drag"!==f?0:!ke&&h<=1?Math.max(-1,Math.min(1,e)):0===y&&e<0||y===h-1&&e>0?0:Math.max(-1,Math.min(1,e)),[f,ke,y,h]);(0,t.useEffect)(()=>{},[pe,p]),(0,t.useEffect)(()=>{"scroll"!==f&&Mt(null)},[f]),(0,t.useEffect)(()=>{const e=++Ee.current,t=()=>Ee.current===e,n=e=>{t()&&ve?.(e)};return Se(null),we(null),"scroll"!==f?((Me||Re)&&[Me?"enterAnimation":null,Re?"exitAnimation":null].filter(Boolean).join(","),()=>{t()&&(Ee.current+=1)}):Me||Re?((async()=>{const[e,r]=await Promise.all([pt(Me,`Scene ${p}`,"enter",n),pt(Re,`Scene ${p}`,"exit",n)]);t()&&(Se(e??null),we(r??null))})(),()=>{t()&&(Ee.current+=1)}):()=>{t()&&(Ee.current+=1)}},[f,ve,p,Me,Re]);const It=function({slideMode:e,sceneState:n,isActive:r,sceneOffset:i,globalScrollProgress:a,globalScrollDirection:o,globalIsScrolling:s,globalScrollBackdropActive:c,hasExitAnimation:l,scrollTimelineState:u}){return(0,t.useMemo)(()=>"drag"===e?"exiting"===n?"exiting":"entering"===n?"entering":r?"active":0===i?"inactive":"parked":"scroll"===e?u?"enter"===u.phase?"entering":"exit"===u.phase?l?"exiting":"covered":"hold"===u.phase?r?"active":"covered":"after"===u.phase?l?"parked":"covered":r?"active":c?"covered":0===i?"inactive":"parked":r&&s&&a>.001?l?"exiting":"covered":c?"covered":("forward"===o&&1===i||"backward"===o&&-1===i)&&a>.001?"entering":r?"active":0===i?"inactive":"parked":r?"active":"inactive",[e,n,r,i,a,o,s,c,l,u])}({slideMode:f,sceneState:Qe,isActive:g,sceneOffset:tt,globalScrollProgress:L,globalScrollDirection:V,globalIsScrolling:O,globalScrollBackdropActive:z,hasExitAnimation:!!K,scrollTimelineState:N}),Ct=(0,t.useMemo)(()=>Dn({effectiveMode:f,isActive:g,globalScrollTimelineState:N,hasExitAnimation:!!K}),[f,g,N,K]),At=Ct>.001,Dt=(0,t.useRef)(_),Tt=(0,t.useRef)(Z);(0,t.useEffect)(()=>{Dt.current=_,Tt.current=Z},[_,Z]),(0,t.useEffect)(()=>{"scroll"===f&&fe||Tn({onVisibilityChange:Dt.current,sceneVisibilityCallback:Tt.current,sceneIndex:p,visible:At,progress:Ct})},[f,p,At,Ct,fe]),(0,t.useEffect)(()=>{if("scroll"!==f||!fe)return;const e=()=>{const e=fe.getKeySnapshot(ge)??null,t=Dn({effectiveMode:f,isActive:e?.isCurrent??g,globalScrollTimelineState:e?.timelineState??null,hasExitAnimation:!!K});Tn({onVisibilityChange:Dt.current,sceneVisibilityCallback:Tt.current,sceneIndex:p,visible:t>.001,progress:t})};return e(),fe.subscribeKey(ge,e)},[f,fe,g,K,p,Z,ge]),(0,t.useEffect)(()=>{"drag"!==f||!g||((J?.onSharedTimelineDurationChange??ae)?.(xt()),ke||je(xt()))},[f,g,xt,dt,J,ae,Qe,ke]);const Lt="drag"===f?R&&null!==st:R,Ot=(0,t.useMemo)(()=>({mode:f,isActive:g,isDragging:!1,dragProgressMotion:Ze,runtimeState:It,sceneState:Qe,sceneOffset:tt,activationToken:b,activationKind:w,firstSceneEnterGateKnown:0===p?E:void 0,firstSceneEnterActive:0===p?M:void 0,firstSceneEnterReady:0===p?Lt:void 0,sceneTransitionDuration:U,getTimelineDuration:xt,beginPreparation:ft,registerAnimate:mt,declareAnimateLane:gt,unregisterAnimate:ht,getCalculatedDelay:yt,enterDuration:ue}),[ft,gt,f,Lt,yt,w,b,M,E,xt,g,Ze,mt,U,p,tt,Qe,ue,ht,It]),Vt=(0,t.useMemo)(()=>({...Ot,isDragging:Xe,dragProgressMotion:Ze,renderProgressMotion:Ze,dragTransaction:J?.transaction??null,preparedSnapshot:st,dragTimelineProgress:He,sharedElapsedMotion:Je,renderProgress:qe,dragRelease:Ue,sharedTimelineDurationMs:Ye,firstSceneEnterActive:M}),[Ue,He,qe,Ye,Ze,J?.transaction,Je,M,Xe,st,Ot]),jt="drag"===f?Vt:Ot;!function({slideMode:e,isActive:n,sceneOffset:r,sceneStackMode:i,controls:a,enterVariant:o,exitVariant:s,globalIsScrolling:c,globalScrollProgress:l,globalScrollDirection:u,globalScrollTransitionSnapshot:d,globalScrollBackdropActive:f,globalScrollTimelineState:m,scrollFrameStore:g,scrollFrameSceneIndex:p,setSceneState:h}){const v=(0,t.useRef)(null);v.current={slideMode:e,isActive:n,sceneOffset:r,sceneStackMode:i,controls:a,enterVariant:o,exitVariant:s,globalIsScrolling:c,globalScrollProgress:l,globalScrollDirection:u,globalScrollTransitionSnapshot:d,globalScrollBackdropActive:f,globalScrollTimelineState:m,setSceneState:h};const y=(0,t.useRef)(null),x=(0,t.useRef)(null),S=(0,t.useCallback)(e=>{const t=v.current;if(!t||"scroll"!==t.slideMode)return;const n=null!==e,r=n?e.timelineState:t.globalScrollTimelineState,i=n?e.isCurrent:t.isActive,a=n?e.isScrolling:t.globalIsScrolling,o=n?e.isBackdropActive:t.globalScrollBackdropActive,s=n?e.scrollDirection:t.globalScrollDirection,c=n?e.progress:t.globalScrollProgress,l=t.globalScrollTransitionSnapshot?.direction??s,u="forward"===l&&1===t.sceneOffset||"backward"===l&&-1===t.sceneOffset,d=i&&a&&c>.001,f=!i&&"cover"===t.sceneStackMode&&o&&(0===t.sceneOffset||-1===t.sceneOffset),m=Mn(t.enterVariant?.animate,En),g=Mn(t.enterVariant?.initial,m),p=Mn(t.exitVariant?.exit,m),h=e=>{y.current!==e&&(y.current=e,t.setSceneState(e))},S=(e,n,r)=>{const i=x.current;i&&i.kind===e&&i.progress===n&&i.enterVariant===t.enterVariant&&i.exitVariant===t.exitVariant&&i.controls===t.controls||(x.current={kind:e,progress:n,enterVariant:t.enterVariant,exitVariant:t.exitVariant,controls:t.controls},t.controls.set(r))};if(r){if("before"===r.phase)return h("initial"),void S("before",0,g);if("enter"===r.phase){const e=Rn(r.enterProgress);return h("entering"),void S("enter",e,vt(g,m,e))}if("hold"===r.phase)return h("active"),void S("hold",1,m);if("exit"===r.phase){const e=Rn(r.exitProgress);return h(t.exitVariant?.exit?"exiting":"active"),void S("exit",e,t.exitVariant?.exit?vt(m,p,e):m)}h(f?t.exitVariant?.exit?"exiting":"active":t.exitVariant?.exit?"exiting":i?"active":"initial"),S("after",1,t.exitVariant?.exit?p:m)}else if(u){h("entering");const e=Rn(c);S("fallback-enter",e,vt(g,m,e))}else if(d||f){h(t.exitVariant?.exit?"exiting":"active");const e=Rn(c);S("fallback-exit",e,t.exitVariant?.exit?vt(m,p,e):m)}else h(i?"active":"initial"),S(i?"fallback-active":"fallback-initial",i?1:0,i?m:g)},[]);(0,t.useEffect)(()=>{if("scroll"===e){if(g&&"number"==typeof p){const e=()=>{S(g.getKeySnapshot(p)??null)};return e(),g.subscribeKey(p,e)}S(null)}},[S,o,s,f,u,l,m,d,c,n,r,i,p,g,e])}({slideMode:f,isActive:g,sceneOffset:tt,sceneStackMode:Y,controls:ye,enterVariant:xe,exitVariant:be,globalIsScrolling:O,globalScrollProgress:L,globalScrollDirection:V,globalScrollTransitionSnapshot:j,globalScrollBackdropActive:z,globalScrollTimelineState:N,scrollFrameStore:fe,scrollFrameSceneIndex:ge,setSceneState:et});const zt=function({slideMode:e,isActive:n,sceneIndex:i,sceneOffset:a,globalDirection:o,globalIsDragging:s,candidateSuspended:c=!1,globalRenderProgress:l,globalDragTimelineProgress:u,renderProgressMotion:d,dragTimelineProgressMotion:f,dragRelease:m,firstSceneEnterReady:g,elementElapsedMotion:p,getTimelineDuration:h,timelineDurationState:v,dragTransaction:y,preparedSnapshot:x,requirePreparedSnapshot:S=!1,dragMappingConfig:b,takeoverSnapshot:w,onElementContinuationChange:E,onSettleComplete:M,onColdStartComplete:R}){const k=(0,t.useRef)(null),P=(0,t.useRef)(null),I=(0,t.useRef)(0),C=(0,t.useRef)(null),A=(0,t.useRef)(null),D=(0,t.useRef)(!1),T=(0,t.useRef)(0),L=(0,t.useRef)(!1),O=(0,t.useRef)(h);O.current=h;const V=(0,t.useRef)(y);V.current=y;const j=(0,t.useRef)(x);j.current=x;const z=(0,t.useRef)(S);z.current=S;const N=(0,t.useRef)(null),F=()=>V.current||(z.current?null:j.current??null),$=e=>e?.registrySnapshot.timelineDuration??O.current(),B=e=>e?.mapping??J.current,q=(0,t.useRef)(M);q.current=M;const H=(0,t.useRef)(R);H.current=R;const W=(0,t.useRef)(E);W.current=E;const Y=(0,t.useRef)(!1),U=e=>{Y.current!==e&&(Y.current=e,W.current?.(e))},X=(0,t.useRef)(p);X.current=p;const K=(0,t.useRef)(null),Z=(0,t.useRef)(null),_=(0,t.useRef)(null),G=(0,t.useRef)(null),J=(0,t.useRef)(b??In);J.current=b??In;const Q=(0,t.useRef)(f?.get()??u);return Q.current=f?.get()??u,(0,t.useEffect)(()=>{if("drag"===e&&c&&k.current){if(Y.current){K.current=Math.max(0,X.current.get());const e=w?.current,t=e?.sceneIndices.includes(i)??!1;_.current=t?e.token:null,Z.current=t?e.baseRatio:null,G.current=null}I.current+=1,k.current.stop(),k.current=null,P.current=null}},[c,i,e,w]),(0,t.useEffect)(()=>{if(c||s)return;const e=_.current,t=w?.current;null!==e&&t?.token===e&&null!==t.baseRatio||(K.current=null,Z.current=null,_.current=null,G.current=null)},[c,s,w]),(0,t.useEffect)(()=>{if("drag"!==e||!s)return;k.current&&(k.current.stop(),k.current=null,P.current=null),U(!1),D.current=!0,L.current=!1;const t=e=>{Q.current=e;const t=d?.get()??l,n=t>1e-4?"forward":t<-1e-4?"backward":o;if(!("forward"===n&&1===a||"backward"===n&&-1===a))return;const r=F();if(z.current&&!r)return;const s=$(r),c=Math.max(0,Math.min(e,1)),u=B(r),f=K.current;if(null!==f){const e=w?.current,n=_.current;if(null!==n&&e?.token===n&&e.sceneIndices.includes(i)&&null!==e.baseRatio){const r=e.baseRatio;if(Z.current=r,G.current!==n&&Math.abs(Math.abs(t)-r)<=1e-6&&Math.abs(c-e.staleRatio)<=1e-6&&Math.abs(c-r)>1e-6)return void(G.current=n);const i=Cn(u,s,100*r),a=Cn(u,s,100*c);return void X.current.set(Math.max(0,Math.min(s,f+a-i)))}const r=Z.current;if(null===r)return void(Z.current=c);const a=Cn(u,s,100*r),o=Cn(u,s,100*c);return void X.current.set(Math.max(0,Math.min(s,f+o-a)))}X.current.set(Cn(u,s,100*c))};return t(f?.get()??u),f?f.on("change",t):void 0},[e,s,u,l,f,d,o,a,i,w,y?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c)return;const t=m;if(!t||t.targetSceneIndex!==i)return;const n=F();if(z.current&&!n||C.current===t.token)return;C.current=t.token;const a=++I.current;k.current?.stop(),k.current=null,U(!1);const o=X.current,s=$(n),l="number"==typeof t.progressRatio?t.progressRatio:Q.current,u=n&&"releaseSeed"in n?n.releaseSeed.elapsedMs:Cn(B(n),s,100*Math.max(0,Math.min(l,1))),d=Math.max(0,o.get(),u);if(d>o.get()&&o.set(d),"enter"===t.mode){if(o.set(0),s<=.001)return void o.set(s);P.current="cold-start",k.current=(0,r.animate)(o,s,{duration:s/1e3,ease:"linear",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,o.set(s))}})}else if("settle"===t.mode){const e=s-d;if(e<=.001)return U(!1),o.set(s),A.current=t.token,void q.current?.();P.current="settle",U(!0),k.current=(0,r.animate)(o,s,{duration:e/1e3,ease:"linear",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,U(!1),o.set(s),A.current=t.token,q.current?.())}})}else{if(d<=.001)return U(!1),void o.set(0);const e=Math.min(.5*Math.max(d,0),300);P.current="bounce",U(!0),k.current=(0,r.animate)(o,0,{duration:e/1e3,ease:"easeOut",onUpdate:e=>{I.current===a&&o.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,U(!1),o.set(0))}})}},[e,m?.token,i,y?.transactionId]),(0,t.useEffect)(()=>{if("drag"!==e||c||s)return;const t=m;if(!t||"enter"===t.mode||t.targetSceneIndex!==i||C.current!==t.token||"settle"===t.mode&&A.current===t.token||k.current)return;const n=F();if(z.current&&!n)return;const a=X.current,o=Math.max(0,a.get());if("bounce"===t.mode){if(o<=.001)return U(!1),void a.set(0);const e=++I.current;return P.current="bounce",U(!0),void(k.current=(0,r.animate)(a,0,{duration:Math.min(.5*o,300)/1e3,ease:"easeOut",onUpdate:t=>{I.current===e&&a.set(t)},onComplete:()=>{I.current===e&&(k.current=null,P.current=null,U(!1),a.set(0))}}))}const l=$(n),u=l-o;if(u<=.001)return U(!1),a.set(l),A.current=t.token,void q.current?.();const d=++I.current;P.current="settle",U(!0),k.current=(0,r.animate)(a,l,{duration:u/1e3,ease:"linear",onUpdate:e=>{I.current===d&&a.set(e)},onComplete:()=>{I.current===d&&(k.current=null,P.current=null,U(!1),a.set(l),A.current=t.token,q.current?.())}})},[e,c,s,m?.token,i]),(0,t.useEffect)(()=>{if("drag"!==e||0!==i||!g||s)return;const t=X.current;if(!D.current){const e=j.current??null;if(z.current&&!e)return;N.current=e;const n=$(e);D.current=!0,L.current=null===e,T.current=n;const i=n-Math.max(0,t.get());if(i<=.001)return t.set(n),void H.current?.();const a=++I.current;return P.current="cold-start",void(k.current=(0,r.animate)(t,n,{duration:i/1e3,ease:"linear",onUpdate:e=>{I.current===a&&t.set(e)},onComplete:()=>{I.current===a&&(k.current=null,P.current=null,t.set(T.current),H.current?.())}}))}if(!L.current||N.current)return;const n=O.current();if(n<=T.current+.001)return;k.current?.stop(),T.current=n;const a=n-Math.max(0,t.get());if(a<=.001)return t.set(n),k.current=null,P.current=null,void H.current?.();const o=++I.current;P.current="cold-start",k.current=(0,r.animate)(t,n,{duration:a/1e3,ease:"linear",onUpdate:e=>{I.current===o&&t.set(e)},onComplete:()=>{I.current===o&&(k.current=null,P.current=null,t.set(T.current),H.current?.())}})},[e,i,g,s,v,x?.revision]),(0,t.useEffect)(()=>()=>{k.current?.stop(),k.current=null,U(!1)},[]),{completeImmediately:(0,t.useCallback)(()=>{I.current+=1,k.current?.stop(),k.current=null,P.current=null,U(!1),X.current.set(O.current())},[]),resetImmediately:(0,t.useCallback)(()=>{I.current+=1,k.current?.stop(),k.current=null,P.current=null,U(!1),X.current.set(0)},[])}}({slideMode:f,isActive:g,sceneIndex:p,sceneOffset:tt,globalDirection:x,globalRenderProgress:qe,renderProgressMotion:Ze,globalIsDragging:We,candidateSuspended:J?.candidateSuspended??!1,globalDragTimelineProgress:He,dragTimelineProgressMotion:Ge,dragRelease:Ue,firstSceneEnterReady:R,elementElapsedMotion:Je,getTimelineDuration:xt,timelineDurationState:dt,dragTransaction:J?.transaction??null,preparedSnapshot:st,requirePreparedSnapshot:ke,dragMappingConfig:J?.dragMappingConfig,takeoverSnapshot:J?.takeoverSnapshot,onElementContinuationChange:J?.onElementContinuationChange,onSettleComplete:J?.onActivationComplete??Q,onColdStartComplete:J?.onActivationComplete??Q}),{handleCandidateSuspend:Nt,handleCandidateResume:Ft,handleDragStart:$t,handlePan:Bt,handlePanEnd:qt}=function({slideMode:e,isActive:n,sceneIndex:i,currentSceneIndex:a,totalScenes:o,slideDirection:s,slideDuration:c,sceneTransitionDuration:l,sceneOffset:u,sceneState:d,globalDirection:f,globalRenderProgress:m,globalIsDragging:g,globalDragProgress:p,globalDragTimelineProgress:h,controls:v,dragProgressMotion:y,setSceneState:x,setIsAnimating:S,resolveDragProgress:b,getTimelineDuration:w,onDragProgressChange:E,onRenderProgressChange:M,onDragTimelineProgressChange:R,onOwnershipRequest:k,onCandidateSuspensionChange:P,takeoverSnapshot:I,onDraggingChange:C,onDragRelease:A,renderLaneRef:D,completeReleaseImmediately:T=!1,onDragEnd:L,onDragReset:O,thresholdConfig:V}){(0,t.useRef)(null);const j=(0,t.useRef)(null),z=(0,t.useRef)(0),N=(0,t.useRef)(null),F=D??N,$=(0,t.useRef)(!1),B=(0,t.useRef)(0),q=(0,t.useRef)(!1),H=(0,t.useRef)(!1);return(0,t.useEffect)(()=>{if("drag"!==e)return;v.set({opacity:1,x:0,y:0,scale:1,rotate:0});const t=m,r=g||Math.abs(t)>.001,i=t>0?"forward":t<0?"backward":f,a=n?r?"exiting":"active":"forward"===i&&1===u||"backward"===i&&-1===u?"entering":"initial";d!==a&&x(a)},[e,v,n,d,i,m,g,u,f,x]),(0,t.useEffect)(()=>()=>{z.current+=1;const e=F.current;e&&e.ownerSceneIndex===i&&(e.stop(),F.current=null),$.current=!1,q.current=!1},[F,i]),{handleCandidateSuspend:(0,t.useCallback)(()=>{if("drag"!==e)return!1;const t=F.current,n=!!t?.suspend;q.current=n,t?.suspend?.();const r=P?.(!0)??!1;return n||r},[F,P,e]),handleCandidateResume:(0,t.useCallback)(()=>{F.current?.resume?.(),q.current=!1,P?.(!1)},[F,P]),handleDragStart:(0,t.useCallback)(t=>{if("drag"!==e)return!1;const r=F.current;if(!n&&!r||k&&!k(t))return!1;const i=r&&q.current?r.getCurrent?.()??m:m,a=I?.current;return a&&null===a.baseRatio&&(I.current={...a,baseRatio:Math.abs(i)}),P?.(!1),r?(r.preempt?r.preempt():r.stop(),F.current=null,q.current=!1,B.current=i,H.current=!0,y.set(i),E?.(i),R?.(Math.abs(i)),r.kind,i.toFixed(3)):(B.current=0,H.current=!1),$.current=!0,p.toFixed(3),h.toFixed(3),C?.(!0),!0},[e,n,F,k,y,E,R,C,i,a,o,p,h,m,P,I]),handlePan:(0,t.useCallback)((t,r)=>{if("drag"!==e||!n&&!$.current)return;const i="y"===s?r.offset.y:r.offset.x,a=b(B.current-i/("y"===s?window.innerHeight:window.innerWidth)),o=Math.abs(a);y.set(a),E?.(a),R?.(o),M?.(a)},[e,n,s,i,E,R,M,y,b]),handlePanEnd:(0,t.useCallback)((t,o)=>{if("drag"!==e||!n&&!$.current)return;$.current=!1;const l="pointercancel"===t.type;z.current+=1,F.current?.stop(),F.current=null;const u=y.get(),d=w(),f=function(e,t){const n="y"===e?t.velocity.y:t.velocity.x;return Number.isFinite(n)?-n:0}(s,o),m=Math.abs(f),g=Math.abs(u),p=(e,t)=>{let n=null,a=y.get(),o=0,s=!1,c=!1;const l=e/Math.max(Math.abs(a),1e-6),u=()=>{c||s||F.current!==m||(F.current=null,n?.stop(),a=0,y.set(0),E?.(0),R?.(0),M?.(0),t())},d=()=>{if(c||s||F.current!==m)return;const e=Math.abs(a)*l;if(e<=1e-6)return void u();const t=++o;n=(0,r.animate)(y,0,{duration:e,ease:"easeOut",onUpdate:e=>{t!==o||c||s||(a=e,y.set(e),E?.(e),R?.(Math.abs(e)),M?.(e))},onComplete:()=>{t===o&&(a=0,u())}})},f=()=>{c=!0,s=!1,o+=1,n?.stop()},m={kind:"bounce",ownerSceneIndex:i,stop:f,suspend:()=>{c||s||(a=y.get(),s=!0,o+=1,n?.stop())},resume:()=>{c||!s||(a=y.get(),s=!1,d())},preempt:f,getCurrent:()=>a};F.current=m,d()};if(g<.001){if(u.toFixed(3),O?.(),H.current){const e=B.current>=0?"forward":"backward";A?.({mode:"bounce",direction:e,targetSceneIndex:"forward"===e?a+1:a-1})}return C?.(!1),void(n&&x("active"))}const h=u>0?"forward":"backward",v="forward"===h?a+1:a-1;if(0===b(u)&&0!==u)return S(!0),u.toFixed(3),m.toFixed(1),C?.(!1),A?.({mode:"bounce",direction:h,targetSceneIndex:v}),void p(.15,()=>{O?.(),x("active"),S(!1)});const k=T?.5:function(e,t){const n=t?.minVelocity??0,r=t?.maxVelocity??1e3,i=t?.minRatio??.15,a=t?.maxRatio??.3;if(!Number.isFinite(e))return a;const o=r-n;return o<=0?a:a-(Math.max(n,Math.min(r,e))-n)/o*(a-i)}(m,V);m.toFixed(1),k.toFixed(3),g.toFixed(3);const P=!l&&g>k&&(T||!(g>.001&&u*f<0&&m>600));if(u.toFixed(3),g.toFixed(3),k.toFixed(3),m.toFixed(1),f.toFixed(1),P){if(S(!0),C?.(!1),T)return L?.(h,1,d,d),void S(!1);const e=++z.current,t="forward"===h?1:-1,n=Math.abs(t-u),a=Math.max(n*(c/1e3),0),o=Math.min(g,1);A?.({mode:"settle",direction:h,targetSceneIndex:v,progressRatio:g});let s=null,l=u,f=0,m=!1,p=!1;const x=()=>{p||m||F.current!==E||(F.current=null,s?.stop(),o.toFixed(3),(1e3*a).toFixed(1),L?.(h,o,o*d,d),M?.(0),S(!1))},b=()=>{if(p||m||F.current!==E)return;const n=Math.abs(t-l)*(c/1e3);if(n<=1e-6)return void x();const i=++f;s=(0,r.animate)(l,t,{duration:n,ease:"easeOut",onUpdate:n=>{if(i===f&&!p&&!m&&z.current===e&&(l=n,Math.abs(n-t)>1e-6&&y.set(n),M?.(n),0)){const e=Math.round(10*Math.abs(n))/10;j.current!==e&&(j.current=e)}},onComplete:()=>{i===f&&(l=t,x())}})},w=()=>{p=!0,m=!1,f+=1,s?.stop()},E={kind:"settle",ownerSceneIndex:i,stop:w,suspend:()=>{p||m||(m=!0,f+=1,s?.stop())},resume:()=>{p||!m||(m=!1,b())},preempt:w,getCurrent:()=>l};u.toFixed(3),(1e3*a).toFixed(1),o.toFixed(3),F.current=E,b()}else{S(!0);const e=Math.min(g*c,300)/1e3;u.toFixed(3),(1e3*e).toFixed(1),C?.(!1),A?.({mode:"bounce",direction:h,targetSceneIndex:v}),p(e,()=>{O?.(),S(!1)})}},[e,n,F,s,i,a,c,y,E,R,M,A,L,O,C,b,w,l,S,x,T,V])}}({slideMode:f,isActive:g,sceneIndex:p,currentSceneIndex:y,totalScenes:h,slideDirection:m,slideDuration:ue,sceneTransitionDuration:U,sceneOffset:tt,sceneState:Qe,globalDirection:x,globalRenderProgress:qe,globalIsDragging:We,globalDragProgress:Be,globalDragTimelineProgress:He,controls:ye,dragProgressMotion:Ze,setSceneState:et,setIsAnimating:rt,resolveDragProgress:Pt,getTimelineDuration:xt,onOwnershipRequest:J?.onOwnershipRequest,onCandidateSuspensionChange:J?.onCandidateSuspensionChange,takeoverSnapshot:J?.takeoverSnapshot,onDragProgressChange:J?.onProgressChange??ee,onRenderProgressChange:J?.onRenderProgressChange??te,onDragTimelineProgressChange:J?.onTimelineProgressChange??ne??(ke?void 0:e=>_e.set(e)),onDraggingChange:J?.onDraggingChange??re??(ke?void 0:Oe),onDragRelease:J?.onRelease??se??(ke?void 0:$e),renderLaneRef:J?.renderLane,completeReleaseImmediately:!ke,thresholdConfig:J?.threshold,onDragEnd:J?.onCommit??ce??(ke?void 0:(e,t,n,r)=>{Ie(0),Ae(0),Te(0),Oe(!1),je(r??0),Ne(null),zt.completeImmediately(),G?.(e)}),onDragReset:J?.onReset??le??(ke?void 0:()=>{Ie(0),Ae(0),Te(0),Oe(!1),Ne(null),zt.resetImmediately()})}),Ht="drag"===f&&(g||!!J?.renderLane?.current||!!Ue),{onPointerDown:Wt,onPointerMove:Yt,onPointerUp:Ut,onPointerCancel:Xt,onFramerPanStart:Kt,onFramerPan:Zt,onFramerPanEnd:_t}=function({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onDragStart:o,onPan:s,onPanEnd:c,authoredPointerDown:l,authoredPointerMove:u,authoredPointerUp:d,authoredPointerCancel:f}){const m=function({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onStart:o,onPan:s,onEnd:c}){const l=(0,t.useRef)(null),u=(0,t.useRef)(!1),d=(0,t.useRef)(0),f=(0,t.useRef)(null),m=(0,t.useRef)(null),g=(0,t.useRef)(r);g.current=r;const p=(0,t.useRef)(i);p.current=i;const h=(0,t.useRef)(a);h.current=a;const v=(0,t.useRef)(o);v.current=o;const y=(0,t.useRef)(s);y.current=s;const x=(0,t.useRef)(c);x.current=c;const S=(0,t.useCallback)(()=>{m.current?.(),m.current=null},[]),b=(0,t.useCallback)(()=>{null!==f.current&&(window.clearTimeout(f.current),f.current=null)},[]),w=(0,t.useCallback)(e=>{const t=l.current;if(!t||t.pointerId!==e.pointerId)return;const n=t.target;S(),l.current=null,t.ownsGesture?(Wn()-t.lastTime>100&&(t.velocityX=0,t.velocityY=0),n.releasePointerCapture?.(t.pointerId),x.current(e,Yn(t,e.clientX,e.clientY))):t.candidateSuspended&&p.current?.(),b();const r=d.current;u.current=!0;const i=window.setTimeout(()=>{f.current===i&&(f.current=null,d.current===r&&(u.current=!1))},0);f.current=i},[S,b]),E=(0,t.useCallback)(t=>{if(!e||!1===t.isPrimary||void 0!==t.button&&0!==t.button||function(e){return e instanceof Element&&!!e.closest('a,button,input,textarea,select,option,summary,[contenteditable="true"],[data-cineview-ignore-drag]')}(t.target))return;const n=l.current;n&&(n.target.releasePointerCapture?.(n.pointerId),!n.ownsGesture&&n.candidateSuspended&&p.current?.()),S(),b(),d.current+=1;const r=t.currentTarget;h.current?.();const i=g.current?.()??!1;l.current={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,lastX:t.clientX,lastY:t.clientY,lastTime:Wn(),velocityX:0,velocityY:0,target:r,ownsGesture:!1,candidateSuspended:i,rejectedDirections:new Set,panInfo:null},u.current=!0;const a=e=>{w(e)};window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a),document.addEventListener("pointerup",a),document.addEventListener("pointercancel",a),m.current=()=>{window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a),document.removeEventListener("pointerup",a),document.removeEventListener("pointercancel",a)}},[S,b,e,w]),M=(0,t.useCallback)(e=>{const t=l.current;if(!t||t.pointerId!==e.pointerId)return;const r=Wn();if(!t.ownsGesture){const i="y"===n?e.clientY-t.startY:e.clientX-t.startX,a="y"===n?e.clientX-t.startX:e.clientY-t.startY;if(Math.abs(i)<1||Math.abs(i)<=Math.abs(a))return;const o=i<0?"forward":"backward";if(t.rejectedDirections.has(o))return;return t.candidateSuspended||(t.candidateSuspended=g.current?.()??!1),v.current(o)?(t.ownsGesture=!0,t.startX=e.clientX,t.startY=e.clientY,t.lastX=e.clientX,t.lastY=e.clientY,t.lastTime=r,t.velocityX=0,t.velocityY=0,t.target.setPointerCapture?.(t.pointerId),void(e.cancelable&&e.preventDefault())):(t.rejectedDirections.add(o),void(t.candidateSuspended&&(p.current?.(),t.candidateSuspended=!1)))}const i=Math.max(r-t.lastTime,1);t.velocityX=(e.clientX-t.lastX)/i*1e3,t.velocityY=(e.clientY-t.lastY)/i*1e3,y.current(e.nativeEvent,Yn(t,e.clientX,e.clientY)),t.lastX=e.clientX,t.lastY=e.clientY,t.lastTime=r,e.cancelable&&e.preventDefault()},[n]),R=(0,t.useCallback)(e=>w(e.nativeEvent),[w]);return(0,t.useEffect)(()=>()=>{const e=l.current;e&&!e.ownsGesture&&e.candidateSuspended&&p.current?.(),S(),b(),d.current+=1,l.current=null,u.current=!1},[S,b]),{onPointerDown:E,onPointerMove:M,onPointerUp:R,onPointerCancel:R,isActiveRef:u}}({enabled:e,axis:n,onCandidateStart:r,onCandidateEnd:i,onPointerSessionStart:a,onStart:o,onPan:s,onEnd:c}),{onPointerDown:g,onPointerMove:p,onPointerUp:h,onPointerCancel:v}=m,y=(0,t.useCallback)(e=>{l?.(e),e.defaultPrevented||g(e)},[l,g]),x=(0,t.useCallback)(e=>{u?.(e),e.defaultPrevented||p(e)},[u,p]),S=(0,t.useCallback)(e=>{d?.(e),h(e)},[d,h]),b=(0,t.useCallback)(e=>{f?.(e),v(e)},[f,v]),w=(0,t.useRef)({ownsGesture:!1,candidateSuspended:!1,baseline:0,rejectedDirections:new Set}),E=(0,t.useRef)(i);E.current=i;const M=(0,t.useCallback)(e=>{const t=w.current;e&&!t.ownsGesture&&t.candidateSuspended&&E.current?.(),w.current={ownsGesture:!1,candidateSuspended:!1,baseline:0,rejectedDirections:new Set}},[]),R=(0,t.useCallback)(()=>{m.isActiveRef.current?M(!0):(M(!0),a?.(),w.current={ownsGesture:!1,candidateSuspended:r?.()??!1,baseline:0,rejectedDirections:new Set})},[M,m.isActiveRef,r,a]),k=(0,t.useCallback)((e,t)=>{if(m.isActiveRef.current)return void M(!0);const a=w.current,c="y"===n?t.offset.y:t.offset.x,l="y"===n?t.offset.x:t.offset.y;if(!a.ownsGesture){if(Math.abs(c)<1||Math.abs(c)<=Math.abs(l))return;const e=c<0?"forward":"backward";if(a.rejectedDirections.has(e))return;return a.candidateSuspended||(a.candidateSuspended=r?.()??!1),o(e)?(a.ownsGesture=!0,void(a.baseline=c)):(a.rejectedDirections.add(e),void(a.candidateSuspended&&(i?.(),a.candidateSuspended=!1)))}const u=c-a.baseline;s(e,{...t,offset:"y"===n?{x:t.offset.x,y:u}:{x:u,y:t.offset.y}})},[n,M,m.isActiveRef,i,r,o,s]),P=(0,t.useCallback)((e,t)=>{if(m.isActiveRef.current)return void M(!0);const r=w.current;if(!r.ownsGesture)return void M(!0);const i=("y"===n?t.offset.y:t.offset.x)-r.baseline;c(e,{...t,offset:"y"===n?{x:t.offset.x,y:i}:{x:i,y:t.offset.y}}),M(!1)},[n,M,m.isActiveRef,c]);return(0,t.useEffect)(()=>()=>M(!0),[M]),{onPointerDown:y,onPointerMove:x,onPointerUp:S,onPointerCancel:b,onFramerPanStart:R,onFramerPan:k,onFramerPanEnd:P}}({axis:m,enabled:Ht,onCandidateStart:Nt,onCandidateEnd:Ft,onPointerSessionStart:J?.onPointerSessionStart,onDragStart:$t,onPan:Bt,onPanEnd:qt,authoredPointerDown:c,authoredPointerMove:l,authoredPointerUp:u,authoredPointerCancel:d}),Gt=(0,t.useMemo)(()=>"drag"===f?{opacity:1}:xe?xe.initial:{opacity:1},[xe,f]),Jt=(0,t.useMemo)(()=>"drag"===f?"none":"translateZ(0)",[f]),Qt=(0,t.useMemo)(()=>function(e){switch(e){case"top-left":default:return{top:0,left:0};case"top-center":return{top:0,left:"50%",transform:"translateX(-50%)"};case"top-right":return{top:0,right:0};case"center-left":return{top:"50%",left:0,transform:"translateY(-50%)"};case"center":return{top:"50%",left:"50%",transform:"translate(-50%, -50%)"};case"center-right":return{top:"50%",right:0,transform:"translateY(-50%)"};case"bottom-left":return{bottom:0,left:0};case"bottom-center":return{bottom:0,left:"50%",transform:"translateX(-50%)"};case"bottom-right":return{bottom:0,right:0}}}(q),[q]),en=(0,t.useMemo)(()=>function(e){switch(e){case"top-right":case"center-right":case"bottom-right":return{marginLeft:"auto",marginRight:0};case"top-center":case"center":case"bottom-center":return{marginLeft:"auto",marginRight:"auto"};default:return{marginLeft:0,marginRight:"auto"}}}(q),[q]),tn=(0,t.useMemo)(()=>Ln({effectiveMode:f,effectiveDirection:m,globalScrollTimelineState:N,globalScrollViewportOffset:F,globalViewportWidth:k,globalViewportHeight:P}),[f,m,N,F,k,P]),nn=!Ht&&("covered"===It||"parked"===It||"inactive"===It),rn=nn?{"aria-hidden":!0}:void 0,an=nn||!0===e.inert;(0,t.useEffect)(()=>{const e=bt.current;e&&(e.inert=an)},[an]);const on=(0,t.useMemo)(()=>({width:$,height:B,position:"scroll"===f?"relative":"absolute",overflow:H,willChange:nt||Xe||O?"transform, opacity":"auto",contain:"drag"===f?"layout style":"layout style paint",transform:Jt,userSelect:"drag"===f&&Xe?"none":void 0,WebkitUserSelect:"drag"===f&&Xe?"none":void 0,touchAction:An(f,m),zIndex:W,pointerEvents:Ht||"covered"!==It&&"parked"!==It&&"inactive"!==It?"auto":"none",..."scroll"===f?en:Qt}),[nt,Xe,O,Ht,Jt,f,m,$,B,H,W,It,en,Qt]);return(0,n.jsx)(Un.Provider,{value:p,children:(0,n.jsx)(hn.Provider,{value:jt,children:(0,n.jsx)(bn.Provider,{value:"scroll"===f?Et:null,children:(0,n.jsx)(oe.Provider,{value:"scroll"===f?kt:null,children:(0,n.jsxs)(r.motion.div,{ref:wt,"data-cineview-scroll-zone":"scroll"===f?kt??e.sceneId??void 0:void 0,initial:Gt,animate:ye,...Object.fromEntries(Object.entries(e).filter(([e])=>!Xn.has(e))),className:o,style:{...s,...on},...rn,inert:an,onPanStart:"drag"===f?Kt:void 0,onPan:"drag"===f?Zt:void 0,onPanEnd:"drag"===f?_t:void 0,onPointerDown:"drag"===f?Wt:c,onPointerMove:"drag"===f?Yt:l,onPointerUp:"drag"===f?Ut:u,onPointerCancel:"drag"===f?Xt:d,children:["scroll"===f?(0,n.jsx)(On,{sceneIndex:p,metrics:tn,setHostRef:Rt,frameStore:fe,direction:m,viewportWidth:k,viewportHeight:P}):null,a]})})})})})}),Zn=Object.assign(Kn,{cineViewScene:!0});Zn.displayName="Scene";var _n=new Set(["width","minWidth","maxWidth","height","minHeight","maxHeight","top","bottom","left","right","inset","insetInline","insetInlineStart","insetInlineEnd","insetBlock","insetBlockStart","insetBlockEnd","margin","marginTop","marginBottom","marginLeft","marginRight","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd","borderWidth","borderTopWidth","borderBottomWidth","borderLeftWidth","borderRightWidth","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","gap","columnGap","rowGap","fontSize","letterSpacing","outlineWidth","outlineOffset"]),Gn=(e,t)=>{if(!e||!t)return e;let n=!1;const r={};return Object.entries(e).forEach(([e,i])=>{const a=((e,t,n)=>n&&"number"==typeof t&&Number.isFinite(t)&&!e.startsWith("--")&&_n.has(e)?n.convert(t):t)(e,i,t);r[e]=a,n||(n=a!==i)}),n?r:e},Jn=(0,t.forwardRef)(function({width:e,height:r,children:i,style:a,className:o,...s},c){const l=v(),u=(0,t.useMemo)(()=>{if(!l)return a;const t=Gn(a,l),n=void 0!==e?l.convert(e):void 0,i=void 0!==r?l.convert(r):void 0;return{...t,...void 0!==e?{width:n}:{},...void 0!==r?{height:i}:{}}},[l,e,r,a]);return(0,n.jsx)("div",{ref:c,style:u,className:o,...s,children:i})});Jn.displayName="Container";var Qn=(0,t.forwardRef)(function({src:e,alt:r,width:i,height:a,style:o,loading:s,preload:c,...l},u){const d=v(),f=(0,t.useMemo)(()=>"number"!=typeof i?i:d?.convert(i)??i,[d,i]),m=(0,t.useMemo)(()=>"number"!=typeof a?a:d?.convert(a)??a,[d,a]),g=(0,t.useMemo)(()=>Gn(o,d),[d,o]),p="lazy"!==s&&(c??!0),h=s??(p?"eager":"lazy");return(0,t.useEffect)(()=>{if(!p||!e||typeof window>"u"||function(e){return e.length>0&&y.has(e)}(e))return;const t=new window.Image,n=()=>{S(e)};return t.addEventListener("load",n),t.src=e,()=>{t.removeEventListener("load",n)}},[p,e]),(0,n.jsx)("img",{ref:u,...l,src:e,alt:r,width:f,height:m,style:g,loading:h})});Qn.displayName="Image";var er=1e-4;function tr(e,t,n){return Math.min(n,Math.max(t,e))}function nr(e,t){return function(e){return Number.isFinite(e)&&e>0}(e)?t?[Number.isFinite(t[0])?tr(t[0],0,e):0,Number.isFinite(t[1])?tr(t[1],0,e):e]:[0,e]:null}function rr(e){return{activationId:e,status:"framework-scrub",activePlayRequestId:null,settledPlayRequestId:null,nextPlayRequestId:1,lastSeekTime:null,endpointLatched:!1,outgoingLatched:!1,frameworkPlayBlocked:!1,frameworkPausePending:!1}}function ir(e,t=[]){return{state:e,commands:t}}function ar(e,t){return{...rr(t),nextPlayRequestId:e.nextPlayRequestId}}function or(e,t){switch(t.type){case"timeline-frame":return function(e,t){const{frame:n}=t;if("exiting"===n.phase||"exited"===n.phase){if(e.outgoingLatched)return ir(e);const t="native-playback"===e.status||"play-pending"===e.status,n=null!==e.activePlayRequestId||null!==e.settledPlayRequestId;return ir({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:null,outgoingLatched:!0,frameworkPlayBlocked:e.frameworkPlayBlocked||t||n,frameworkPausePending:t},t?[{type:"pause"}]:[])}if(!e.outgoingLatched&&!function(e){return"gesture"===e||"continuation"===e||"programmatic"===e||"scroll"===e||"visibility"===e}(n.source)||!function(e,t){return"ended"!==e.status&&"play-rejected"!==e.status||("gesture"===t.source||"scroll"===t.source||"visibility"===t.source)&&t.progress<.98}(e,n))return ir(e);const r=function(e,t,n){const r=nr(t,n);if(!r)return null;const i=tr(Number.isFinite(e)?e:0,0,1);return r[0]+i*(r[1]-r[0])}(n.progress,t.duration,t.scrubRange);if(null===r)return ir(e);if(function(e){return"native-playback"===e||"native-paused"===e||"play-pending"===e}(e.status)){if(!function(e,t){return!(e.endpointLatched&&t.progress>=.98)&&("scroll"===t.source||"visibility"===t.source||"gesture"===t.source&&t.progress<.98)}(e,n))return ir(e);const t=[],i="native-playback"===e.status||"play-pending"===e.status;return i&&t.push({type:"pause"}),(null===e.lastSeekTime||Math.abs(e.lastSeekTime-r)>er)&&t.push({type:"seek",time:r}),ir({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:r,endpointLatched:!1,outgoingLatched:!1,frameworkPlayBlocked:!0,frameworkPausePending:i},t)}const i=[];if((null===e.lastSeekTime||Math.abs(e.lastSeekTime-r)>er)&&i.push({type:"seek",time:r}),function(e,t){if(!e.scrubRange||t||e.frame.progress<.999)return!1;const n=nr(e.duration,e.scrubRange);return!!n&&n[1]<e.duration-er}(t,e.endpointLatched)){const t=e.nextPlayRequestId;return i.push({type:"play",requestId:t}),ir({...e,status:"play-pending",activePlayRequestId:t,settledPlayRequestId:null,nextPlayRequestId:t+1,lastSeekTime:r,endpointLatched:!0,outgoingLatched:!1,frameworkPlayBlocked:!1},i)}const a=!!(t.scrubRange&&n.progress>=.999),o=n.progress<.98;return ir({...e,status:"framework-scrub",activePlayRequestId:null,lastSeekTime:r,endpointLatched:!!a||!o&&e.endpointLatched,outgoingLatched:!1},i)}(e,t);case"media-play":return t.activationId!==e.activationId?ir(e):void 0!==t.requestId?e.activePlayRequestId===t.requestId||"native-playback"===e.status&&!e.frameworkPlayBlocked&&e.settledPlayRequestId===t.requestId?ir({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPausePending:!1,frameworkPlayBlocked:!1}):ir({...e,frameworkPausePending:!0,frameworkPlayBlocked:!0},[{type:"pause"}]):e.frameworkPlayBlocked?ir({...e,frameworkPausePending:!0},[{type:"pause"}]):ir({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:null,frameworkPausePending:!1,frameworkPlayBlocked:!1});case"media-pause":return t.activationId!==e.activationId?ir(e):e.frameworkPausePending?ir({...e,frameworkPausePending:!1}):ir({...e,status:"ended"===e.status?"ended":"native-paused",activePlayRequestId:null,settledPlayRequestId:"ended"===e.status?e.settledPlayRequestId:null,frameworkPlayBlocked:"ended"===e.status&&e.frameworkPlayBlocked});case"media-ended":return t.activationId!==e.activationId?ir(e):ir({...e,status:"ended",activePlayRequestId:null,endpointLatched:!0,frameworkPausePending:!1});case"play-resolved":return e.activePlayRequestId!==t.requestId?ir(e):ir({...e,status:"native-playback",activePlayRequestId:null,settledPlayRequestId:t.requestId,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"play-rejected":return e.activePlayRequestId!==t.requestId?ir(e):ir({...e,status:"play-rejected",activePlayRequestId:null,settledPlayRequestId:null,frameworkPlayBlocked:!1,frameworkPausePending:!1});case"activate":return e.activationId===t.activationId?ir(e):ir(ar(e,t.activationId));case"reset":return ir(ar(e,t.activationId))}}var sr=!0,cr=(0,t.forwardRef)(function({src:e,progress:r,timelineFrame:i,scrubRange:a,width:o,height:s,style:c,"aria-label":l,preload:u=!0,poster:d,playbackRate:f,onEnded:m,onPlay:g,onPause:p,onTimeUpdate:h,onError:y,controlRef:x},S){const E=v(),k=(0,t.useRef)(null),[P,I]=(0,t.useState)(()=>({src:e,url:C(e)??null})),D=P.src===e?P.url:null,O=(0,t.useRef)([]),V=(0,t.useRef)(rr(0)),j=(0,t.useRef)(0),z=(0,t.useRef)(void 0),N=(0,t.useRef)(0),F=(0,t.useRef)({src:e,objectUrl:D}),$=(0,t.useRef)(null),B=(0,t.useRef)(()=>{}),q=(0,t.useRef)(new WeakMap),H=(0,t.useRef)(null),W=(0,t.useRef)(null),Y=(0,t.useCallback)((e,t)=>{const n=$.current,r=N.current;if(n&&(n.video!==e||n.activationId!==t||n.generation!==r)&&(n.video.removeEventListener("loadstart",n.loadStart,sr),n.video.removeEventListener("play",n.play,sr),n.video.removeEventListener("pause",n.pause,sr),n.video.removeEventListener("ended",n.ended,sr),$.current=null),!e||$.current)return;const i=()=>j.current===t&&N.current===r,a=()=>i()&&H.current===r,o=()=>{i()&&(H.current=r)},s=e=>{q.current.set(e,{generation:r,activationId:t})},c=e=>{if(!a())return;const n=z.current,i=n?.generation===r&&n.activationId===t?n.requestId:void 0,o=V.current,c=void 0!==i&&(!o.frameworkPlayBlocked&&o.activePlayRequestId===i||"native-playback"===o.status&&!o.frameworkPlayBlocked&&o.settledPlayRequestId===i),l=void 0===i&&!o.frameworkPlayBlocked;void 0!==i&&(z.current=void 0),c||l?(s(e),B.current({type:"media-play",requestId:i,activationId:t})):B.current({type:"media-play",requestId:i,activationId:t})},l=e=>{a()&&(V.current.frameworkPausePending||(z.current=void 0),s(e),B.current({type:"media-pause",activationId:t}))},u=e=>{a()&&(s(e),B.current({type:"media-ended",activationId:t}))};e.addEventListener("loadstart",o,sr),e.addEventListener("play",c,sr),e.addEventListener("pause",l,sr),e.addEventListener("ended",u,sr),$.current={video:e,generation:r,activationId:t,loadStart:o,play:c,pause:l,ended:u}},[]),[U,X]=(0,t.useState)(!1),[K,Z]=(0,t.useState)(0),[_,G]=(0,t.useState)(0),J=(0,t.useCallback)((e=!0)=>{j.current+=1,V.current=or(V.current,{type:"reset",activationId:j.current}).state,z.current=void 0,O.current=[],Y(e?k.current:null,j.current)},[Y]);(0,t.useEffect)(()=>{const e={release:()=>{const e=k.current;X(!0),e&&(e.pause(),W.current=e.getAttribute("src"),e.removeAttribute("src"),e.load()),J(!1)},warmUp:()=>{const e=k.current;if(e&&!e.getAttribute("src")){const t=W.current;t&&(e.src=t,W.current=null)}X(!1),Z(e=>e+1),J(!1)}};return x&&(x.current=e),()=>{x&&(x.current=null)}},[x,J]);const Q=(0,t.useCallback)(e=>{e||Y(null,j.current),k.current=e,e&&Y(e,j.current),function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(S,e)},[Y,S]),te=(0,t.useMemo)(()=>"number"==typeof o?E?.convert(o)??o:o,[E,o]),ne=(0,t.useMemo)(()=>"number"==typeof s?E?.convert(s)??s:s,[E,s]),re=(0,t.useMemo)(()=>Gn(c,E??null),[E,c]);(0,t.useEffect)(()=>{if(typeof window>"u"||!e)return void I({src:e,url:null});let t=!0,n=!1;const r=()=>{const t=function(e){const t=b.get(e);if(t)return A(e),R.set(e,(R.get(e)??0)+1),t.objectUrl}(e);return!!t&&(n=!0,I({src:e,url:t}),!0)};let i=()=>{};return r()||(I({src:e,url:null}),i=function(e){return M.add(e),()=>{M.delete(e)}}(i=>{i===e&&t&&!n&&r()})),()=>{t=!1,i(),n&&function(e){const t=R.get(e)??0;t<=1?R.delete(e):R.set(e,t-1),T("")}(e)}},[e]),(0,t.useEffect)(()=>{typeof window>"u"||!e||!u||function(e){return e.length>0&&w.has(e)}(e)||L(e,"video").catch(()=>{})},[u,e]),(0,t.useEffect)(()=>{X(!1),Z(e=>e+1)},[e]),ee(()=>{const e=k.current;e&&(e.playbackRate=f??1)},[_,D,f,U,e]);const ie=(0,t.useCallback)((e,t)=>{e.currentTime=t},[e]),ae=(0,t.useCallback)(e=>{const t=k.current;if(!t)return;const n=or(V.current,e);V.current=n.state,n.commands.forEach(e=>{switch(e.type){case"pause":return void t.pause();case"seek":return void ie(t,e.time);case"play":{const n={requestId:e.requestId,generation:N.current,activationId:V.current.activationId,settled:!1};z.current=n;const r=t=>{if(z.current===n&&!n.settled){if(n.settled=!0,"play-rejected"===t&&(z.current=void 0),N.current!==n.generation||V.current.activationId!==n.activationId)return void(z.current=void 0);ae({type:t,requestId:e.requestId})}};let i;try{i=t.play()}catch{return void r("play-rejected")}return void Promise.resolve(i).then(()=>r("play-resolved"),()=>r("play-rejected"))}}})},[ie]);ee(()=>{B.current=ae;const t=F.current;let n=!1;(t.src!==e||t.objectUrl!==D)&&(F.current={src:e,objectUrl:D},N.current+=1,H.current=null,J(),n=!0),!n&&k.current&&k.current.readyState>=1&&(H.current=N.current),Y(k.current,j.current)},[Y,ae,K,D,J,e]),(0,t.useEffect)(()=>()=>Y(null,j.current),[Y]),(0,t.useEffect)(()=>{if(!i)return;const e=k.current;if(!e||typeof window>"u")return;let t=i.get();const n=n=>{t=n;const r=V.current;if("entering"===n.phase&&("ended"===r.status||r.outgoingLatched))return j.current+=1,Y(null,j.current),ae({type:"activate",activationId:j.current}),void G(e=>e+1);!Number.isFinite(e.duration)||e.duration<=0||ae({type:"timeline-frame",frame:n,duration:e.duration,scrubRange:a})},r=()=>n(t),o=i.on("change",n);return e.readyState>=1?r():e.addEventListener("loadedmetadata",r,{once:!0}),()=>{o(),e.removeEventListener("loadedmetadata",r)}},[Y,ae,K,_,D,a,i]),(0,t.useEffect)(()=>{if(i)return;const e=k.current;if(!e||typeof window>"u")return;const t="object"==typeof r?r:null,n=t=>{const n=e.duration;!Number.isFinite(n)||n<=0||ie(e,(t<0?0:t>1?1:t)*n)},a=()=>n(t?.get()??r),o=t?.on("change",n);return e.readyState>=1?a():e.addEventListener("loadedmetadata",a,{once:!0}),()=>{o?.(),e.removeEventListener("loadedmetadata",a)}},[K,D,r,ie,i]);const oe=e=>{const t=q.current.get(e);return q.current.delete(e),!(!t||t.generation!==N.current||t.activationId!==j.current)},se=U&&P.src===e,ce=JSON.stringify([e,D,_,se?"released":"active"]);return(0,n.jsx)("video",{ref:Q,src:(se?void 0:D??e)||void 0,muted:!0,playsInline:!0,preload:se?"none":u?"auto":D?"metadata":"none","aria-label":l,width:te,height:ne,style:re,poster:d||void 0,onPlay:e=>{oe(e.nativeEvent)&&g?.(e)},onPause:e=>{oe(e.nativeEvent)&&p?.(e)},onEnded:e=>{oe(e.nativeEvent)&&m?.(e)},onTimeUpdate:h,onError:y},ce)});cr.displayName="VideoFrameRenderer";var lr={initial:{opacity:1},animate:{opacity:1}},ur=(0,t.forwardRef)(function({src:e,"aria-label":r,width:i,height:a,style:o,preload:s,poster:c,playbackRate:l,scrubRange:u,releaseOnLeave:d,onEnded:f,onPlay:m,onPause:g,onTimeUpdate:p,onError:h},v){const y=un(),x=function(e,n){const r=(0,t.useRef)(null),i=un(),a=(0,t.useContext)(oe),o=function(e,n=!0){return function(e,n,r){const i=(0,t.useContext)(ae),a=r(e?i?.zoneStates?.[e]??null:null),o=n&&e?i?.store:void 0,s=(0,t.useCallback)(t=>o&&e?o.subscribeKey(e,t):()=>{},[o,e]),c=(0,t.useCallback)(()=>r(o&&e?o.getKeySnapshot(e)??null:e?i?.zoneStates?.[e]??null:null),[r,o,i?.zoneStates,e]);return(0,t.useSyncExternalStore)(s,c,()=>a)}(e,n,(0,t.useCallback)(e=>e?.approach??null,[]))}(e?a:null,!0===e),s=(0,t.useRef)(!1),c=(0,t.useRef)(!!e),l=i.progress;return(0,t.useEffect)(()=>{s.current=!1},[n]),(0,t.useEffect)(()=>{if(!e)return;const t=e=>{Math.abs(e)>1e-4&&(s.current=!0)};return t(l.get()),l.on("change",t)},[l,e]),(0,t.useEffect)(()=>{const t=c.current;if(c.current=!!e,e){if(o){if("far"===o)return void(s.current&&r.current?.release());r.current?.warmUp()}}else t&&r.current?.warmUp()},[o,e]),r}(d,e);return(0,n.jsx)(cr,{ref:v,controlRef:x,src:e,progress:y.progress,timelineFrame:y.frame,"aria-label":r,width:i,height:a,style:o,preload:s,poster:c,playbackRate:l,scrubRange:u,onEnded:f,onPlay:m,onPause:g,onTimeUpdate:p,onError:h})}),dr=(0,t.forwardRef)(function({src:e,"aria-label":t,width:r,height:i,style:a,preload:o,poster:s,playbackRate:c,scrubRange:l,animateId:u,duration:d,enterAnimation:f,exitAnimation:m,timeline:g,visibility:p,releaseOnLeave:h,onEnded:v,onPlay:y,onPause:x,onTimeUpdate:S,onError:b},w){return(0,n.jsx)(xn,{animateId:u,enterAnimation:f??lr,exitAnimation:m,duration:{enter:d?.enter,exit:d?.exit},timeline:g,visibility:p,children:(0,n.jsx)(ur,{ref:w,src:e,"aria-label":t,width:r,height:i,style:a,preload:o,poster:s,playbackRate:c,scrubRange:l,releaseOnLeave:h,onEnded:v,onPlay:y,onPause:x,onTimeUpdate:S,onError:b})})});dr.displayName="AnimateVideo";var fr=xn,mr=wn,gr=Zn,pr=ke;e.Animate=fr,e.AnimateVideo=dr,e.Cineview=pr,e.Container=Jn,e.Image=Qn,e.Position=mr,e.Scene=gr,e.useAnimateTimeline=un});
|
|
2
2
|
//# sourceMappingURL=cineview-scroll.umd.js.map
|