svg-scroll-draw 2.7.0 → 2.10.0

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.
Files changed (76) hide show
  1. package/dist/angular/index.cjs +3 -3
  2. package/dist/angular/index.d.mts +48 -0
  3. package/dist/angular/index.d.ts +48 -0
  4. package/dist/angular/index.mjs +3 -3
  5. package/dist/astro/index.cjs +3 -3
  6. package/dist/astro/index.d.mts +20 -5
  7. package/dist/astro/index.d.ts +20 -5
  8. package/dist/astro/index.mjs +3 -3
  9. package/dist/cdn/svg-scroll-draw.dev.global.js +1878 -0
  10. package/dist/cdn/svg-scroll-draw.global.js +3 -3
  11. package/dist/cinematic/index.cjs +2 -2
  12. package/dist/cinematic/index.mjs +2 -2
  13. package/dist/cli/init.js +104 -101
  14. package/dist/devtools/index.cjs +1 -1
  15. package/dist/devtools/index.mjs +1 -1
  16. package/dist/group/index.cjs +3 -3
  17. package/dist/group/index.d.mts +48 -0
  18. package/dist/group/index.d.ts +48 -0
  19. package/dist/group/index.mjs +3 -3
  20. package/dist/horizontal/index.cjs +1 -0
  21. package/dist/horizontal/index.d.mts +108 -0
  22. package/dist/horizontal/index.d.ts +108 -0
  23. package/dist/horizontal/index.mjs +1 -0
  24. package/dist/index.cjs +4 -4
  25. package/dist/index.d.mts +48 -0
  26. package/dist/index.d.ts +48 -0
  27. package/dist/index.mjs +4 -4
  28. package/dist/nuxt/index.cjs +3 -3
  29. package/dist/nuxt/index.d.mts +33 -0
  30. package/dist/nuxt/index.d.ts +33 -0
  31. package/dist/nuxt/index.mjs +3 -3
  32. package/dist/pin/index.cjs +1 -1
  33. package/dist/pin/index.mjs +1 -1
  34. package/dist/progress/index.cjs +1 -0
  35. package/dist/progress/index.d.mts +74 -0
  36. package/dist/progress/index.d.ts +74 -0
  37. package/dist/progress/index.mjs +1 -0
  38. package/dist/react/index.cjs +3 -3
  39. package/dist/react/index.d.mts +33 -0
  40. package/dist/react/index.d.ts +33 -0
  41. package/dist/react/index.mjs +3 -3
  42. package/dist/reveal/index.cjs +1 -0
  43. package/dist/reveal/index.d.mts +80 -0
  44. package/dist/reveal/index.d.ts +80 -0
  45. package/dist/reveal/index.mjs +1 -0
  46. package/dist/snap/index.cjs +1 -1
  47. package/dist/snap/index.d.mts +8 -0
  48. package/dist/snap/index.d.ts +8 -0
  49. package/dist/snap/index.mjs +1 -1
  50. package/dist/solid/index.cjs +3 -3
  51. package/dist/solid/index.d.mts +48 -0
  52. package/dist/solid/index.d.ts +48 -0
  53. package/dist/solid/index.mjs +3 -3
  54. package/dist/svelte/index.cjs +3 -3
  55. package/dist/svelte/index.d.mts +48 -0
  56. package/dist/svelte/index.d.ts +48 -0
  57. package/dist/svelte/index.mjs +3 -3
  58. package/dist/text/index.cjs +1 -1
  59. package/dist/text/index.d.mts +15 -0
  60. package/dist/text/index.d.ts +15 -0
  61. package/dist/text/index.mjs +1 -1
  62. package/dist/timeline/index.cjs +8 -8
  63. package/dist/timeline/index.d.mts +31 -0
  64. package/dist/timeline/index.d.ts +31 -0
  65. package/dist/timeline/index.mjs +8 -8
  66. package/dist/video/index.cjs +1 -1
  67. package/dist/video/index.d.mts +15 -0
  68. package/dist/video/index.d.ts +15 -0
  69. package/dist/video/index.mjs +1 -1
  70. package/dist/vue/index.cjs +3 -3
  71. package/dist/vue/index.d.mts +33 -0
  72. package/dist/vue/index.d.ts +33 -0
  73. package/dist/vue/index.mjs +3 -3
  74. package/dist/web-component/index.cjs +3 -3
  75. package/dist/web-component/index.mjs +3 -3
  76. package/package.json +37 -5
@@ -0,0 +1,108 @@
1
+ type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
2
+ interface TriggerConfig {
3
+ start?: string;
4
+ end?: string;
5
+ }
6
+ interface ScrollDrawInstance {
7
+ destroy: () => void;
8
+ /** Reset and replay the animation from the beginning. */
9
+ replay: () => void;
10
+ /** Pause the animation at the current progress. */
11
+ pause: () => void;
12
+ /** Resume a paused animation. */
13
+ resume: () => void;
14
+ /** Jump to a specific progress value (0–1) and pause. */
15
+ seek: (progress: number) => void;
16
+ /** Returns current draw progress (0–1). */
17
+ getProgress: () => number;
18
+ /**
19
+ * Re-measure after a layout change: path lengths, and the scroll trigger window.
20
+ *
21
+ * The engine already re-measures on `resize`, on `orientationchange`, and via a
22
+ * `ResizeObserver` on the document element — but none of those fire for a layout
23
+ * change that leaves the document height alone, such as a tab switching, a
24
+ * sibling collapsing, or a font swapping inside a fixed-height box. Call this
25
+ * after one of those.
26
+ *
27
+ * Optional on this shared type because several instances here are fan-outs over
28
+ * other instances or SSR no-op stubs. `scrollDraw`, `scrollPin`,
29
+ * `scrollHorizontal`, `scrollDrawTimeline` and the group APIs all provide it;
30
+ * use `instance.refresh?.()` if you hold an instance of unknown origin.
31
+ */
32
+ refresh?: () => void;
33
+ }
34
+
35
+ interface ScrollHorizontalOptions {
36
+ /**
37
+ * Total horizontal travel distance in pixels.
38
+ *
39
+ * Default: `track.scrollWidth` minus the width it is seen through — the
40
+ * viewport, or the `scrollContainer`'s client width when one is given.
41
+ */
42
+ distance?: number;
43
+ /**
44
+ * Trigger window for the scroll → horizontal mapping.
45
+ * Default: `{ start: 'top top', end: 'bottom bottom' }` — full container height.
46
+ */
47
+ trigger?: TriggerConfig;
48
+ /** Easing for the horizontal movement. Default: `'linear'` (scrub feel). */
49
+ easing?: EasingName | ((t: number) => number);
50
+ /** Custom scroll container. Default: window. */
51
+ scrollContainer?: string | Element;
52
+ /**
53
+ * Element whose height defines the scroll window for the scrub.
54
+ *
55
+ * Default: the container of the track's nearest `position: sticky` ancestor —
56
+ * the `.outer` element in the CSS setup below, which is where the scroll room
57
+ * actually lives. Falls back to the track itself when there is no sticky
58
+ * ancestor.
59
+ *
60
+ * Why this is not the track: a sticky stage pins the track at exactly one
61
+ * viewport tall, so measuring `top top` → `bottom bottom` against it gives
62
+ * tStart === tEnd — a zero-length window, and a track that never moves.
63
+ */
64
+ triggerElement?: string | Element;
65
+ /**
66
+ * Honour `prefers-reduced-motion: reduce` by holding the track at its final
67
+ * position instead of scrubbing. Default: **`false`** — unlike every other
68
+ * API here, which defaults to `true`.
69
+ *
70
+ * The reasoning: this transform is scroll-linked scrubbing, not autonomous
71
+ * motion. It advances only as the user scrolls, 1:1 with their input, so it is
72
+ * direct manipulation rather than something that plays at them. And the
73
+ * alternative is worse than the motion — the panels are only reachable *via*
74
+ * the transform, inside a sticky `overflow: hidden` container, so applying a
75
+ * final state (or none at all) silently hides all of the content except one
76
+ * panel from exactly the users who asked for less motion.
77
+ *
78
+ * Set to `true` if your layout has an accessible non-transform fallback and you
79
+ * would rather drop the movement.
80
+ */
81
+ respectReducedMotion?: boolean;
82
+ onProgress?: (progress: number) => void;
83
+ }
84
+ interface ScrollHorizontalInstance extends ScrollDrawInstance {
85
+ /** Recalculate travel distance after layout change. */
86
+ refresh: () => void;
87
+ }
88
+ /**
89
+ * Drive horizontal movement (translateX) from vertical scroll.
90
+ *
91
+ * The Apple / Stripe "scroll to reveal horizontal sections" pattern.
92
+ * You handle the sticky + overflow CSS; `scrollHorizontal` drives the translateX.
93
+ *
94
+ * Minimal CSS setup:
95
+ * .outer { height: 400vh; }
96
+ * .sticky { position: sticky; top: 0; height: 100vh; overflow: hidden; }
97
+ * .track { display: flex; width: max-content; }
98
+ *
99
+ * @example
100
+ * scrollHorizontal('.track', {
101
+ * distance: 3 * window.innerWidth,
102
+ * trigger: { start: 'top top', end: 'bottom bottom' },
103
+ * easing: 'linear',
104
+ * });
105
+ */
106
+ declare function scrollHorizontal(track: string | Element, options?: ScrollHorizontalOptions): ScrollHorizontalInstance;
107
+
108
+ export { type ScrollHorizontalInstance, type ScrollHorizontalOptions, scrollHorizontal };
@@ -0,0 +1 @@
1
+ function Ce({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,t)),a=Math.sqrt(n),i=0,l=[];for(let c=0;c<r;c++){let f=Math.pow(a,c);l.push(f),i+=f;}let m=[0],u=0;for(let c=0;c<r;c++)u+=l[c]/i,m.push(u);return c=>{if(c<=0)return 0;if(c>=1)return 1;for(let f=0;f<r;f++)if(c<=m[f+1]){let g=(c-m[f])/(m[f+1]-m[f]);if(f===0)return g*(2-g);let h=1-Math.pow(n,f);return h+(1-h)*(2*g-1)*(2*g-1)}return 1}}function _e({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),n=Math.max(.1,t),a=r<=1?n/4:n/(2*Math.PI)*Math.asin(1/r);return i=>i<=0?0:i>=1?1:r*Math.pow(2,-10*i)*Math.sin((i-a)*(2*Math.PI)/n)+1}var N={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:Ce(),elastic:_e()};function U(e="top bottom"){let t=e.trim();if(/^\d+(\.\d+)?%$/.test(t))return {element:"top",viewport:t};let[r="top",n="bottom"]=t.split(/\s+/).filter(Boolean);return {element:r,viewport:n}}function ue(e,t,r,n){switch(n){case "top":return e+r;case "center":return e+r+t/2;case "bottom":return e+r+t;default:return e+r}}function le(e,t){if(/^\d+(\.\d+)?%$/.test(e))return t*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return t/2;case "bottom":return t;default:return t}}function Re(e,t,r){return Math.min(r,Math.max(t,e))}function k(e,t,r,n){return r===t?0:Re((e-t)/(r-t)*n,0,1)}function me(e,t,r){let n=e.getBoundingClientRect(),a=r==="x"?n.width:n.height;return t?{top:r==="x"?n.left-t.getBoundingClientRect().left+t.scrollLeft:n.top-t.getBoundingClientRect().top+t.scrollTop,height:a,scroll:0}:{top:r==="x"?n.left:n.top,height:a,scroll:r==="x"?window.scrollX:window.scrollY}}function Y(e,t,r,n,a){let i=ue(e.top,e.height,t,n.element)-le(n.viewport,r),l=ue(e.top,e.height,t,a.element)-le(a.viewport,r);return {tStart:i,tEnd:l}}function ce(e){let t=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(t)return [parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let n=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return n?[parseInt(n[1]),parseInt(n[2]),parseInt(n[3])]:null}function pe(e,t,r){let n=ce(e),a=ce(t);return !n||!a?e:`rgb(${Math.round(n[0]+(a[0]-n[0])*r)},${Math.round(n[1]+(a[1]-n[1])*r)},${Math.round(n[2]+(a[2]-n[2])*r)})`}var Ne="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",He="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",fe=33;function Oe(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function Fe(e){let t=[];for(let r=0;r<fe;r++){let n=r/(fe-1);t.push(String(Math.round(e(n)*1e5)/1e5));}return `linear(${t.join(",")})`}function ge(e){switch(e){case "linear":return "linear";case "ease-in":return Ne;case "ease-out":return He;case "ease-in-out":return Oe()?Fe(N["ease-in-out"]):null;default:return null}}var de=new Map;function be(e,t){de.set(e,t);}function ye(e){de.delete(e);}var De=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function H(e,...t){De&&console.warn(`[svg-scroll-draw] ${e}`,...t);}function ze(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function he(e){let t=[],r=/([\w]+)\(([^)]*)\)/g,n;for(;(n=r.exec(e))!==null;){let a=[],i=[],l=n[2].trim();if(l)for(let m of l.split(/[\s,]+/)){let u=m.match(/^([-+]?[\d.eE]+)(.*)$/);a.push(u?parseFloat(u[1]):0),i.push(u?u[2]:"");}t.push({fn:n[1],nums:a,units:i});}return t}function Ve(e,t,r){let n=he(e),a=he(t);return n.length===0||n.length!==a.length?r<1?e:t:n.map((i,l)=>{let m=a[l];return i.fn!==m.fn||i.nums.length!==m.nums.length?r<1?`${i.fn}(${i.nums.map((u,c)=>`${u}${i.units[c]}`).join(", ")})`:`${m.fn}(${m.nums.map((u,c)=>`${u}${m.units[c]}`).join(", ")})`:`${i.fn}(${i.nums.map((u,c)=>`${u+(m.nums[c]-u)*r}${i.units[c]}`).join(", ")})`}).join(" ")}function Ee(e,t,r){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*r);let n=String(e),a=String(t);if(ze(n))return pe(n,a,r);if(n.includes("("))return Ve(n,a,r);let i=n.match(/^([-+]?[\d.]+)(.*)$/),l=a.match(/^([-+]?[\d.]+)(.*)$/);if(i&&l){let m=parseFloat(i[1]),u=parseFloat(l[1]);return `${m+(u-m)*r}${i[2]||l[2]}`}return r<1?n:a}function We(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var ke=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Be=0,we="--scroll-draw-progress";function qe(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Q(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:n,trigger:a={},easing:i="ease-out",speed:l=1,once:m=false,axis:u="y",scrollContainer:c,native:f=true,velocityScale:g=false,respectReducedMotion:h=true,triggerElement:I,onProgress:b,onComplete:P,onEnter:p,onLeave:C,onEnterBack:Z,onLeaveBack:J}=t,ve=h&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,B=typeof i=="function"?i:N[i]??N["ease-out"],K=U(a.start??"top bottom"),ee=U(a.end??"bottom top"),te=I??e,y=typeof c=="string"?document.querySelector(c):c??null,E=Object.entries(n).map(([o,s])=>({prop:We(o),from:Array.isArray(s)?s[0]:"",to:Array.isArray(s)?s[1]:s}));function xe(){let o=window.getComputedStyle(e);for(let s of E)s.from===""&&(s.from=o.getPropertyValue(s.prop).trim()||"0");}function Me(){for(let o of E)e.style.setProperty(o.prop,String(o.to));}let ne=new Map;for(let o of [...E.map(s=>s.prop),we])ne.set(o,e.style.getPropertyValue(o));function q(){for(let[o,s]of ne)s?e.style.setProperty(o,s):e.style.removeProperty(o);}if(ve)return Me(),P?.(),{...r,destroy:q,getProgress:()=>1};xe();let re=typeof i=="string"?ge(i):null;function Te(){if(!f||!qe()||!re||u!=="y"||y||te!==e||m||l!==1||b||P||p||C||Z||J||g!==false||(a.start??"top bottom").trim()!=="top bottom"||(a.end??"bottom top").trim()!=="bottom top")return false;for(let o of E)if(!ke.has(o.prop))return false;return true}function Pe(){let o=`ssd-a-${++Be}`,s=E.map(d=>`${d.prop}:${d.from}`).join(";"),V=E.map(d=>`${d.prop}:${d.to}`).join(";"),$=document.createElement("style");$.setAttribute("data-ssd-animate",""),$.textContent=`@keyframes ${o}{from{${s}}to{${V}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${re};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild($),e.classList.add(o);let S=()=>u==="x"?window.scrollX:window.scrollY,W=()=>u==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(o),$.remove(),e.style.animationPlayState="",q();},replay(){e.classList.remove(o),e.offsetWidth,e.classList.add(o);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(d){let _=Math.min(1,Math.max(0,d));e.classList.remove(o);for(let R of E)e.style.setProperty(R.prop,Ee(R.from,R.to,_));},getProgress(){let d=e.getBoundingClientRect(),_=S(),R=W(),{tStart:$e,tEnd:Ie}=Y({top:d.top,height:d.height},_,R,K,ee);return B(k(_,$e,Ie,l))}}}if(Te())return Pe();let w=0,v=0,x=0,O=false,M=false,A=-1,L=0,F=false,T=NaN,G=-1,oe=0,se=()=>y?u==="x"?y.scrollLeft:y.scrollTop:u==="x"?window.scrollX:window.scrollY,Ae=()=>y?u==="x"?y.clientWidth:y.clientHeight:u==="x"?window.innerWidth:window.innerHeight;function ie(){let o=me(te,y,u),s=Y(o,o.scroll,Ae(),K,ee);w=s.tStart,v=s.tEnd;}function D(o){e.style.setProperty(we,String(o));for(let s of E)e.style.setProperty(s.prop,Ee(s.from,s.to,o));b?.(o);}function Le(o){if(isNaN(T)){T=o;return}T<=0&&o>0?p?.():T>0&&o<=0&&J?.(),T<1&&o>=1?C?.():T>=1&&o<1&&Z?.(),T=o;}function j(){if(!O||M)return;let o=performance.now(),s=se(),V=l;if(g!==false){let W=o-oe,d=W>0?Math.abs(s-(G<0?s:G))/W:0;V=l*Math.max(.2,1+d*(typeof g=="number"?g:1)*.04);}G=s,oe=o;let $=v===w?0:(s-w)/(v-w);Le($);let S=B(k(s,w,v,V));m&&(A=Math.max(A,S),S=A),L=S,D(S),S>=1&&!F?(F=true,P?.()):S<1&&!m&&(F=false),x=requestAnimationFrame(j);}ie(),v===w&&H("scrollAnimate: the trigger window has zero length (start and end resolve to the same scroll position), so this element will never animate. If the target is inside a position:sticky stage, measure the trigger from the container that holds the scroll room via `triggerElement`.",e);{let o=B(k(se(),w,v,l));m&&o>0&&(A=o),L=o,D(o);}let ae=new IntersectionObserver(o=>{o.forEach(s=>{O=s.isIntersecting,O&&!M?x=requestAnimationFrame(j):cancelAnimationFrame(x);});},{root:y??null}),X;function z(){clearTimeout(X),X=setTimeout(ie,150);}return window.addEventListener("resize",z),window.addEventListener("orientationchange",z),ae.observe(e),be(e,{type:"animate",getProgress:()=>L,getTrigger:()=>({tStart:w,tEnd:v})}),{destroy(){cancelAnimationFrame(x),ae.disconnect(),window.removeEventListener("resize",z),window.removeEventListener("orientationchange",z),clearTimeout(X),q(),ye(e);},replay(){A=-1,F=false,L=0,M=false,D(0);},pause(){M=true,cancelAnimationFrame(x);},resume(){M&&(M=false,O&&(x=requestAnimationFrame(j)));},seek(o){let s=Math.min(1,Math.max(0,o));L=s,A=s,M=true,cancelAnimationFrame(x),D(s);},getProgress(){return L}}}var Se={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0,refresh:()=>{}};function rt(e,t={}){if(typeof window>"u")return Se;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return H("scrollHorizontal: track element not found:",e),Se;let n=r,{easing:a="linear",trigger:i={start:"top top",end:"bottom bottom"},scrollContainer:l,respectReducedMotion:m=false,onProgress:u}=t;function c(){let p=typeof l=="string"?document.querySelector(l):l??null;return p?p.clientWidth:window.innerWidth}function f(){return t.distance??n.scrollWidth-c()}function g(){if(t.triggerElement!==void 0){let p=typeof t.triggerElement=="string"?document.querySelector(t.triggerElement):t.triggerElement;if(p)return p;H("scrollHorizontal: triggerElement not found:",t.triggerElement);}for(let p=n.parentElement;p;p=p.parentElement)if(window.getComputedStyle(p).position==="sticky")return p.parentElement??p;return n}let h=f(),I=g(),b=Q(n,P(h,I));function P(p,C){return {props:{transform:["translateX(0px)",`translateX(${-p}px)`]},trigger:i,easing:a,native:false,respectReducedMotion:m,...C!==n&&{triggerElement:C},...l!==void 0&&{scrollContainer:l},...u!==void 0&&{onProgress:u}}}return {destroy(){b.destroy();},replay(){b.replay();},pause(){b.pause();},resume(){b.resume();},seek(p){b.seek(p);},getProgress(){return b.getProgress()},refresh(){b.destroy(),h=f(),I=g(),b=Q(n,P(h,I));}}}export{rt as scrollHorizontal};
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';function Et({tension:e=2.5,friction:t=2.2}={}){return r=>1-Math.cos(r*Math.PI*e)*Math.pow(1-r,t)}function it({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,t)),m=Math.sqrt(n),a=0,h=[];for(let p=0;p<r;p++){let T=Math.pow(m,p);h.push(T),a+=T;}let f=[0],l=0;for(let p=0;p<r;p++)l+=h[p]/a,f.push(l);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let T=0;T<r;T++)if(p<=f[T+1]){let H=(p-f[T])/(f[T+1]-f[T]);if(T===0)return H*(2-H);let v=1-Math.pow(n,T);return v+(1-v)*(2*H-1)*(2*H-1)}return 1}}function at({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),n=Math.max(.1,t),m=r<=1?n/4:n/(2*Math.PI)*Math.asin(1/r);return a=>a<=0?0:a>=1?1:r*Math.pow(2,-10*a)*Math.sin((a-m)*(2*Math.PI)/n)+1}var Q={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:it(),elastic:at()};function he(e="top bottom"){let t=e.trim();if(/^\d+(\.\d+)?%$/.test(t))return {element:"top",viewport:t};let[r="top",n="bottom"]=t.split(/\s+/).filter(Boolean);return {element:r,viewport:n}}function nt(e,t,r,n){switch(n){case "top":return e+r;case "center":return e+r+t/2;case "bottom":return e+r+t;default:return e+r}}function ot(e,t){if(/^\d+(\.\d+)?%$/.test(e))return t*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return t/2;case "bottom":return t;default:return t}}function Ve(e){let t=e.tagName.toLowerCase();if(t==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),n=parseFloat(e.getAttribute("height")??"0");return 2*(r+n)}if(t==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function St(e,t,r){return Math.min(r,Math.max(t,e))}function ee(e,t,r,n){return r===t?0:St((e-t)/(r-t)*n,0,1)}function Se(e,t,r,n,m){let a=nt(e.top,e.height,t,n.element)-ot(n.viewport,r),h=nt(e.top,e.height,t,m.element)-ot(m.viewport,r);return {tStart:a,tEnd:h}}function st(e){let t=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(t)return [parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let n=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return n?[parseInt(n[1]),parseInt(n[2]),parseInt(n[3])]:null}function Ce(e,t,r){let n=st(e),m=st(t);return !n||!m?e:`rgb(${Math.round(n[0]+(m[0]-n[0])*r)},${Math.round(n[1]+(m[1]-n[1])*r)},${Math.round(n[2]+(m[2]-n[2])*r)})`}var Ue={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:false},reveal:{easing:"ease-out",fade:true,speed:1.2,once:true},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:true,speed:.75},spring:{easing:"spring",speed:1.1}};function lt(e,t){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,t);}var ct={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},xt=0;function At(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Tt(e){let t=e.getAttribute("stroke"),r=e.getAttribute("fill");!t||t==="none"?lt("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&lt("Element has a fill \u2014 it may obscure the stroke animation.",e);}function $t(e,t,r){let n=document.createElement("div");n.setAttribute("data-svg-scroll-draw-debug",""),n.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function m(){let a=r==="x"?window.scrollX:window.scrollY,h=e-a,f=t-a,l=r==="x";n.innerHTML=`
2
- <div style="position:absolute;${l?`left:${h}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${h}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
- <div style="position:absolute;${l?`left:${f}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${f}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(n),window.addEventListener("scroll",m,{passive:true}),m(),n}function Ze(e,t,r){let n=(t.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),m=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,a=>{let h=parseFloat(a),f=n[m++]??h;return String(+(h+(f-h)*r).toFixed(4))})}function ut(e,t={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...n}=t,m=r?{...Ue[r],...n}:n,a=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:h="path, polyline, line, polygon, rect, circle",speed:f=1,fade:l=false,easing:p="linear",trigger:T={},stagger:H=0,direction:v="forward",once:_=false,debug:pe=false,axis:x="y",scrollContainer:$,autoReverse:g=false,delay:E=0,strokeColor:b,strokeWidth:F,fillOpacity:A,waypoints:C,velocityScale:te=false,threshold:de=0,rootMargin:be="0px",repeat:ie=0,repeatDelay:Y=0,morphTo:L,clip:j,autoplay:ge=false,duration:re=1e3,native:ne=true,onProgress:d,onStart:q,onComplete:U,onEnter:xe,onLeave:Oe,onEnterBack:Le,onLeaveBack:Ae}=m,ue=j===true?"left":typeof j=="string"?j:false,ae=typeof p=="function"?p:Q[p]??Q.linear,Ie=he(T.start??"top bottom"),Me=he(T.end??"bottom top"),z=typeof $=="string"?document.querySelector($):$??null,s=Array.isArray(b)?b[0]:null,u=Array.isArray(b)?b[1]:typeof b=="string"?b:null,N=Array.isArray(F)?F[0]:null,I=Array.isArray(F)?F[1]:typeof F=="number"?F:null,V=Array.isArray(A)?A[0]:null,G=Array.isArray(A)?A[1]:typeof A=="number"?A:null;function B(o){let i=o*100;switch(ue){case "right":return `inset(0 0 0 ${100-i}%)`;case "top":return `inset(0 0 ${100-i}% 0)`;case "bottom":return `inset(${100-i}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-i}% 0 0)`}}let O=ue?[]:Array.from(e.querySelectorAll(h)),M=[],oe=[],le=0,we=0,X=false,ce=false,W=0,Fe=false,me=-1,Ne=-1,Z=false,Te=0,ye=0,ve,je=null,Ee=new Set,Re=-1,et=performance.now(),Pe=NaN;function De(){return z?x==="x"?z.scrollLeft:z.scrollTop:x==="x"?window.scrollX:window.scrollY}function tt(){return z?x==="x"?z.clientWidth:z.clientHeight:x==="x"?window.innerWidth:window.innerHeight}function rt(){let o=e.getBoundingClientRect(),i,w,R;if(z){let K=z.getBoundingClientRect();i=x==="x"?o.left-K.left+z.scrollLeft:o.top-K.top+z.scrollTop,w=x==="x"?o.width:o.height,R=De();}else i=x==="x"?o.left:o.top,w=x==="x"?o.width:o.height,R=De();let J=Se({top:i,height:w},R,tt(),Ie,Me);le=J.tStart,we=J.tEnd,pe&&process.env.NODE_ENV!=="production"&&(je?.remove(),je=$t(le,we,x));}function ht(o,i){if(e.style.setProperty("--scroll-draw-progress",String(o)),ue){let w=i==="reverse"?1-o:o;e.style.clipPath=B(w);return}O.forEach((w,R)=>{w.style.strokeDashoffset=i==="reverse"?`${M[R]*o}`:`${M[R]*(1-o)}`,l&&(w.style.opacity=i==="reverse"?`${1-o}`:`${o}`),s&&u?w.style.stroke=Ce(s,u,o):u&&(w.style.stroke=u),N!==null&&I!==null?w.style.strokeWidth=`${N+(I-N)*o}`:I!==null&&(w.style.strokeWidth=`${I}`),V!==null&&G!==null?w.style.fillOpacity=`${V+(G-V)*o}`:G!==null&&(w.style.fillOpacity=`${G}`),L&&w.tagName.toLowerCase()==="path"&&oe[R]&&w.setAttribute("d",Ze(oe[R],L,o));});}function He(){if(e.style.setProperty("--scroll-draw-progress","0"),ue){e.style.clipPath=B(0);return}O.forEach((o,i)=>{o.style.strokeDasharray=`${M[i]}`,o.style.strokeDashoffset=v==="reverse"?"0":`${M[i]}`,l?o.style.opacity=v==="reverse"?"1":"0":o.style.opacity="",s&&(o.style.stroke=s),N!==null&&(o.style.strokeWidth=`${N}`),V!==null&&(o.style.fillOpacity=`${V}`),L&&o.tagName.toLowerCase()==="path"&&oe[i]&&o.setAttribute("d",oe[i]);});}if(O.forEach(o=>{Tt(o);let i=Ve(o);M.push(i),o.tagName.toLowerCase()==="path"?oe.push(o.getAttribute("d")??""):oe.push(""),a?(o.style.strokeDasharray=`${i}`,o.style.strokeDashoffset=v==="reverse"?`${i}`:"0",l&&(o.style.opacity="1"),u&&(o.style.stroke=u),I!==null&&(o.style.strokeWidth=`${I}`),G!==null&&(o.style.fillOpacity=`${G}`),L&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",L)):(o.style.strokeDasharray=`${i}`,o.style.strokeDashoffset=v==="reverse"?"0":`${i}`,l?o.style.opacity=v==="reverse"?"1":"0":o.style.opacity="",s&&(o.style.stroke=s),N!==null&&(o.style.strokeWidth=`${N}`),V!==null&&(o.style.fillOpacity=`${V}`));}),ue){if(a)return e.style.clipPath=B(1),U?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=B(0);}else if(a)return U?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function bt(){return !(ne===false||!At()||!O.length||typeof p!="string"||!(p in ct)||ue||x!=="y"||z||f!==1||H!==0||_||g||te!==false||L||C||ie||E>0||d||q||U||xe||Oe||Le||Ae||b!=null||F!=null||A!=null||(T.start??"top bottom").trim()!=="top bottom"||(T.end??"bottom top").trim()!=="bottom top")}function wt(){let o=`svg-scroll-draw-${++xt}`,i=v==="reverse"?"0":"var(--ssd-len)",w=v==="reverse"?"var(--ssd-len)":"0",R=`stroke-dashoffset:${i};`,J=`stroke-dashoffset:${w};`;l&&(R+=`opacity:${v==="reverse"?1:0};`,J+=`opacity:${v==="reverse"?0:1};`);let K=document.createElement("style");K.setAttribute("data-svg-scroll-draw",""),K.textContent=`@keyframes ${o}{from{${R}}to{${J}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${ct[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(K);function se(c,S){c.style.setProperty("--ssd-len",String(M[S])),c.style.strokeDasharray=`${M[S]}`,c.style.strokeDashoffset="",c.style.opacity="",c.style.animationPlayState="",c.classList.add(o);}O.forEach(se);let y=false,P=-1;function k(){if(P>=0)return P;let c=e.getBoundingClientRect(),{tStart:S,tEnd:D}=Se({top:c.top,height:c.height},De(),tt(),Ie,Me);return ae(ee(De(),S,D,f))}return {destroy(){O.forEach(c=>{c.classList.remove(o),c.style.removeProperty("--ssd-len"),c.style.animationPlayState="";}),K.remove();},replay(){y=false,P=-1,O.forEach(se);},pause(){y=true,O.forEach(c=>{c.style.animationPlayState="paused";});},resume(){y&&(y=false,O.forEach(c=>{c.style.animationPlayState="running";}));},seek(c){let S=Math.min(1,Math.max(0,c));P=S,y=true,O.forEach((D,$e)=>{D.classList.remove(o),D.style.strokeDashoffset=v==="reverse"?`${M[$e]*S}`:`${M[$e]*(1-S)}`,l&&(D.style.opacity=v==="reverse"?`${1-S}`:`${S}`);});},getProgress(){return k()}}}if(bt())return wt();function vt(){let o=Math.max(1,re),i=0,w=0;function R(k){let c=true;if(ue){let S=Math.min(1,Math.max(0,k/o)),D=ae(S);Te=D,e.style.setProperty("--scroll-draw-progress",String(D)),e.style.clipPath=B(v==="reverse"?1-D:D),d?.(D),S<1&&(c=false);}else O.forEach((S,D)=>{let $e=D*H*o,ke=Math.min(1,Math.max(0,(k-$e)/o)),fe=ae(ke);S.style.strokeDashoffset=v==="reverse"?`${M[D]*fe}`:`${M[D]*(1-fe)}`,l&&(S.style.opacity=v==="reverse"?`${1-fe}`:`${fe}`),s&&u?S.style.stroke=Ce(s,u,fe):u&&(S.style.stroke=u),N!==null&&I!==null?S.style.strokeWidth=`${N+(I-N)*fe}`:I!==null&&(S.style.strokeWidth=`${I}`),V!==null&&G!==null?S.style.fillOpacity=`${V+(G-V)*fe}`:G!==null&&(S.style.fillOpacity=`${G}`),L&&S.tagName.toLowerCase()==="path"&&oe[D]&&S.setAttribute("d",Ze(oe[D],L,fe)),D===0&&(d?.(fe),e.style.setProperty("--scroll-draw-progress",String(fe))),ke<1&&(c=false);});if(C){let S=Math.min(1,Math.max(0,k/o)),D=ae(S);for(let $e in C){let ke=parseFloat($e);D>=ke&&!Ee.has(ke)&&(Ee.add(ke),C[$e]?.());}}return c}function J(k){if(Z)return;let c=k-i;ce||(ce=true,q?.());let S=R(c);if(S&&!X){X=true,R(o*(1+Math.max(0,O.length-1)*H)),U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{i=performance.now(),ce=false,X=false,Ee.clear(),He(),W=requestAnimationFrame(J);},Y));return}S||(W=requestAnimationFrame(J));}function K(){cancelAnimationFrame(W),clearTimeout(ve),i=performance.now(),w=0,Z=false,ce=false,X=false,ye=0,Ee.clear(),He(),W=requestAnimationFrame(J);}let se=new IntersectionObserver(k=>{k.forEach(c=>{c.isIntersecting&&!(_&&X)?K():!c.isIntersecting&&!_&&!X&&(cancelAnimationFrame(W),clearTimeout(ve),i=null);});},{root:z??null,threshold:de,rootMargin:be}),y;function P(){clearTimeout(y),y=setTimeout(()=>{O.forEach((k,c)=>{M[c]=Ve(k),k.style.strokeDasharray=`${M[c]}`;});},150);}return window.addEventListener("resize",P),window.addEventListener("orientationchange",P),E>0?setTimeout(()=>se.observe(e),E):se.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ve),se.disconnect(),window.removeEventListener("resize",P),window.removeEventListener("orientationchange",P),clearTimeout(y);},replay(){ye=0,K();},pause(){Z||(Z=true,w=performance.now()-i,cancelAnimationFrame(W));},resume(){Z&&(Z=false,i=performance.now()-w,W=requestAnimationFrame(J));},seek(k){let c=Math.min(1,Math.max(0,k));Te=c,Z=true,w=c*o,i=performance.now()-w,cancelAnimationFrame(W),R(w);},getProgress(){return Te}}}if(ge)return vt();rt();function qe(){if(!Fe||Z)return;let o=performance.now(),i=De(),w=f;if(te!==false){let y=o-et,P=y>0?Math.abs(i-(Re<0?i:Re))/y:0;w=f*Math.max(.2,1+P*(typeof te=="number"?te:1)*.04);}Re=i,et=o;let R=g?Ne===-1||i>=Ne?"forward":"reverse":v;Ne=i;let J=we-le,K=true,se=J===0?0:(i-le)/J;if(isNaN(Pe)||(Pe<=0&&se>0?xe?.():Pe>0&&se<=0&&Ae?.(),Pe<1&&se>=1?Oe?.():Pe>=1&&se<1&&Le?.()),Pe=se,ue){let y=ae(ee(i,le,we,w));_&&!g&&(me=Math.max(me,y),y=me),Te=y,e.style.setProperty("--scroll-draw-progress",String(y));let P=R==="reverse"?1-y:y;e.style.clipPath=B(P),d?.(y),!ce&&ee(i,le,we,w)>0&&(ce=true,q?.()),y>=1&&!X?(X=true,U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{me=-1,ce=false,X=false,e.style.clipPath=B(0);},Y))):y<1&&!_&&(X=false),W=requestAnimationFrame(qe);return}if(O.forEach((y,P)=>{let k=P*H*J,c=ae(ee(i,le+k,we+k,w));_&&!g&&(me=Math.max(me,c),c=me),Te=c,y.style.strokeDashoffset=R==="reverse"?`${M[P]*c}`:`${M[P]*(1-c)}`,l&&(y.style.opacity=R==="reverse"?`${1-c}`:`${c}`),s&&u?y.style.stroke=Ce(s,u,c):u&&(y.style.stroke=u),N!==null&&I!==null?y.style.strokeWidth=`${N+(I-N)*c}`:I!==null&&(y.style.strokeWidth=`${I}`),V!==null&&G!==null?y.style.fillOpacity=`${V+(G-V)*c}`:G!==null&&(y.style.fillOpacity=`${G}`),L&&y.tagName.toLowerCase()==="path"&&oe[P]&&y.setAttribute("d",Ze(oe[P],L,c)),P===0&&(d?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(K=false);}),C){let y=ae(ee(i,le,we,w));for(let P in C){let k=parseFloat(P);y>=k&&!Ee.has(k)&&(Ee.add(k),C[P]?.());}}!ce&&ee(i,le,we,w)>0&&(ce=true,q?.()),K&&!X?(X=true,U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{me=-1,ce=false,X=false,Ee.clear(),He();},Y))):!K&&!_&&(X=false),W=requestAnimationFrame(qe);}let Xe=new IntersectionObserver(o=>{o.forEach(i=>{Fe=i.isIntersecting,Fe&&!Z?W=requestAnimationFrame(qe):cancelAnimationFrame(W);});},{root:z??null,threshold:de,rootMargin:be}),Ye;function ze(){clearTimeout(Ye),Ye=setTimeout(()=>{O.forEach((o,i)=>{M[i]=Ve(o),o.style.strokeDasharray=`${M[i]}`;}),rt();},150);}return window.addEventListener("resize",ze),window.addEventListener("orientationchange",ze),E>0?setTimeout(()=>Xe.observe(e),E):Xe.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ve),Xe.disconnect(),window.removeEventListener("resize",ze),window.removeEventListener("orientationchange",ze),clearTimeout(Ye),je?.remove();},replay(){me=-1,Ne=-1,Re=-1,ce=false,X=false,ye=0,Z=false,Ee.clear(),clearTimeout(ve),He();},pause(){Z=true,cancelAnimationFrame(W);},resume(){Z&&(Z=false,Fe&&(W=requestAnimationFrame(qe)));},seek(o){let i=Math.min(1,Math.max(0,o));Te=i,me=i,Z=true,cancelAnimationFrame(W),ht(i,v);},getProgress(){return Te}}}var mt=new Map;function Be(e,t){mt.set(e,t);}function We(e){mt.delete(e);}function Mt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function ft(e){let t=[],r=/([\w]+)\(([^)]*)\)/g,n;for(;(n=r.exec(e))!==null;){let m=[],a=[],h=n[2].trim();if(h)for(let f of h.split(/[\s,]+/)){let l=f.match(/^([-+]?[\d.eE]+)(.*)$/);m.push(l?parseFloat(l[1]):0),a.push(l?l[2]:"");}t.push({fn:n[1],nums:m,units:a});}return t}function Pt(e,t,r){let n=ft(e),m=ft(t);return n.length===0||n.length!==m.length?r<1?e:t:n.map((a,h)=>{let f=m[h];return a.fn!==f.fn||a.nums.length!==f.nums.length?r<1?`${a.fn}(${a.nums.map((l,p)=>`${l}${a.units[p]}`).join(", ")})`:`${f.fn}(${f.nums.map((l,p)=>`${l}${f.units[p]}`).join(", ")})`:`${a.fn}(${a.nums.map((l,p)=>`${l+(f.nums[p]-l)*r}${a.units[p]}`).join(", ")})`}).join(" ")}function pt(e,t,r){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*r);let n=String(e),m=String(t);if(Mt(n))return Ce(n,m,r);if(n.includes("("))return Pt(n,m,r);let a=n.match(/^([-+]?[\d.]+)(.*)$/),h=m.match(/^([-+]?[\d.]+)(.*)$/);if(a&&h){let f=parseFloat(a[1]),l=parseFloat(h[1]);return `${f+(l-f)*r}${a[2]||h[2]}`}return r<1?n:m}function kt(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var dt={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ct=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Lt=0;function It(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function gt(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:n,trigger:m={},easing:a="ease-out",speed:h=1,once:f=false,axis:l="y",scrollContainer:p,native:T=true,onProgress:H,onComplete:v,onEnter:_,onLeave:pe,onEnterBack:x,onLeaveBack:$}=t,g=window.matchMedia("(prefers-reduced-motion: reduce)").matches,E=typeof a=="function"?a:Q[a]??Q["ease-out"],b=he(m.start??"top bottom"),F=he(m.end??"bottom top"),A=typeof p=="string"?document.querySelector(p):p??null,C=Object.entries(n).map(([s,u])=>({prop:kt(s),from:Array.isArray(u)?u[0]:"",to:Array.isArray(u)?u[1]:u}));function te(){let s=window.getComputedStyle(e);for(let u of C)u.from===""&&(u.from=s.getPropertyValue(u.prop).trim()||"0");}function de(){for(let s of C)e.style.setProperty(s.prop,String(s.to));}if(g)return de(),v?.(),r;te();function be(){if(!T||!It()||typeof a!="string"||!(a in dt)||l!=="y"||A||f||h!==1||H||v||_||pe||x||$||(m.start??"top bottom").trim()!=="top bottom"||(m.end??"bottom top").trim()!=="bottom top")return false;for(let s of C)if(!Ct.has(s.prop))return false;return true}function ie(){let s=`ssd-a-${++Lt}`,u=C.map(B=>`${B.prop}:${B.from}`).join(";"),N=C.map(B=>`${B.prop}:${B.to}`).join(";"),I=document.createElement("style");I.setAttribute("data-ssd-animate",""),I.textContent=`@keyframes ${s}{from{${u}}to{${N}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${dt[a]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(I),e.classList.add(s);let V=()=>l==="x"?window.scrollX:window.scrollY,G=()=>l==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(s),I.remove();},replay(){e.classList.remove(s),e.offsetWidth,e.classList.add(s);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(B){let O=Math.min(1,Math.max(0,B));e.classList.remove(s);for(let M of C)e.style.setProperty(M.prop,pt(M.from,M.to,O));},getProgress(){let B=e.getBoundingClientRect(),O=V(),M=G(),{tStart:oe,tEnd:le}=Se({top:B.top,height:B.height},O,M,b,F);return E(ee(O,oe,le,h))}}}if(be())return ie();let Y=0,L=0,j=0,ge=false,re=false,ne=-1,d=0,q=false,U=NaN,xe=()=>A?l==="x"?A.scrollLeft:A.scrollTop:l==="x"?window.scrollX:window.scrollY,Oe=()=>A?l==="x"?A.clientWidth:A.clientHeight:l==="x"?window.innerWidth:window.innerHeight;function Le(){let s=e.getBoundingClientRect(),u,N;if(A){let V=A.getBoundingClientRect();u=l==="x"?s.left-V.left+A.scrollLeft:s.top-V.top+A.scrollTop,N=l==="x"?s.width:s.height;}else u=l==="x"?s.left:s.top,N=l==="x"?s.width:s.height;let I=Se({top:u,height:N},xe(),Oe(),b,F);Y=I.tStart,L=I.tEnd;}function Ae(s){e.style.setProperty("--scroll-draw-progress",String(s));for(let u of C)e.style.setProperty(u.prop,pt(u.from,u.to,s));H?.(s);}function ue(s){if(isNaN(U)){U=s;return}U<=0&&s>0?_?.():U>0&&s<=0&&$?.(),U<1&&s>=1?pe?.():U>=1&&s<1&&x?.(),U=s;}function ae(){if(!ge||re)return;let s=L===Y?0:(xe()-Y)/(L-Y);ue(s);let u=E(ee(xe(),Y,L,h));f&&(ne=Math.max(ne,u),u=ne),d=u,Ae(u),u>=1&&!q?(q=true,v?.()):u<1&&!f&&(q=false),j=requestAnimationFrame(ae);}Le();{let s=E(ee(xe(),Y,L,h));f&&s>0&&(ne=s),d=s,Ae(s);}let Ie=new IntersectionObserver(s=>{s.forEach(u=>{ge=u.isIntersecting,ge&&!re?j=requestAnimationFrame(ae):cancelAnimationFrame(j);});},{root:A??null}),Me;function z(){clearTimeout(Me),Me=setTimeout(Le,150);}return window.addEventListener("resize",z),window.addEventListener("orientationchange",z),Ie.observe(e),Be(e,{type:"animate",getProgress:()=>d,getTrigger:()=>({tStart:Y,tEnd:L})}),{destroy(){cancelAnimationFrame(j),Ie.disconnect(),window.removeEventListener("resize",z),window.removeEventListener("orientationchange",z),clearTimeout(Me),We(e);},replay(){ne=-1,q=false,d=0,re=false,Ae(0);},pause(){re=true,cancelAnimationFrame(j);},resume(){re&&(re=false,ge&&(j=requestAnimationFrame(ae)));},seek(s){let u=Math.min(1,Math.max(0,s));d=u,ne=u,re=true,cancelAnimationFrame(j),Ae(u);},getProgress(){return d}}}var _e={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Dt(e,t){if(typeof window>"u")return _e;let r=typeof e=="string"?document.querySelector(e):e;return r?gt(r,t):(process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollAnimate: element not found:",e),_e)}function Ot(e,t={}){if(typeof window>"u")return _e;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollParallax: element not found:",e),_e;let{speed:n=.3,axis:m="y",easing:a="linear",trigger:h,onProgress:f}=t,l=r.getBoundingClientRect(),p=m==="x"?l.width:l.height,T=n*p;return gt(r,{props:m==="x"?{transform:["translateX(0px)",`translateX(${-T}px)`]}:{transform:["translateY(0px)",`translateY(${-T}px)`]},trigger:h??{start:"top bottom",end:"bottom top"},easing:a,native:false,onProgress:f})}var Je={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ft(e,t){if(typeof window>"u")return Je;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollCounter: element not found:",e),Je;let n=r,{from:m=0,to:a,format:h,easing:f="ease-out",trigger:l={},once:p=true,decimals:T,onComplete:H}=t,v=T!==void 0?d=>d.toFixed(T):h??(d=>String(Math.round(d))),_=typeof f=="function"?f:Q[f]??Q["ease-out"],pe=he(l.start??"top 80%"),x=he(l.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=v(a),H?.(),Je;n.textContent=v(m);let g=0,E=0,b=0,F=false,A=false,C=-1,te=0,de=false,be=()=>window.scrollY,ie=()=>window.innerHeight;function Y(){let d=n.getBoundingClientRect(),q=Se({top:d.top,height:d.height},be(),ie(),pe,x);g=q.tStart,E=q.tEnd;}function L(d){n.textContent=v(m+(a-m)*d),n.style.setProperty("--scroll-draw-progress",String(d));}function j(){if(!F||A)return;let d=_(ee(be(),g,E,1));p&&(C=Math.max(C,d),d=C),te=d,L(d),d>=1&&!de?(de=true,H?.()):d<1&&!p&&(de=false),b=requestAnimationFrame(j);}Y();{let d=_(ee(be(),g,E,1));p&&d>0&&(C=d),te=d,L(d);}let ge=new IntersectionObserver(d=>{d.forEach(q=>{F=q.isIntersecting,F&&!A?b=requestAnimationFrame(j):cancelAnimationFrame(b);});}),re;function ne(){clearTimeout(re),re=setTimeout(Y,150);}return window.addEventListener("resize",ne),window.addEventListener("orientationchange",ne),ge.observe(n),Be(n,{type:"counter",getProgress:()=>te,getTrigger:()=>({tStart:g,tEnd:E})}),{destroy(){cancelAnimationFrame(b),ge.disconnect(),window.removeEventListener("resize",ne),window.removeEventListener("orientationchange",ne),clearTimeout(re),We(n);},replay(){C=-1,de=false,te=0,A=false,L(0);},pause(){A=true,cancelAnimationFrame(b);},resume(){A&&(A=false,F&&(b=requestAnimationFrame(j)));},seek(d){let q=Math.min(1,Math.max(0,d));te=q,C=q,A=true,cancelAnimationFrame(b),L(q);},getProgress(){return te}}}var yt="http://www.w3.org/2000/svg",Nt="cinematic-photo",Ke=e=>e<0?0:e>1?1:e;function Ge(e){let t=parseFloat(e);return Number.isFinite(t)?Ke(t/100):0}function Rt(e){return Q[e]??Q.linear}var Ht={destroy:()=>{},getProgress:()=>0},Qe=class{constructor(t){if(typeof document>"u"){this.mount=null;return}this.mount=typeof t.wrapper=="string"?document.querySelector(t.wrapper):t.wrapper,!this.mount&&process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] Cinematic: wrapper not found:",t.wrapper);}loadStory(t){let r=this.mount;if(typeof window>"u"||!r)return Ht;r.style.position="relative",r.style.height=t.totalHeight,r.style.display="block";let n=document.createElement("div");n.setAttribute("data-cinematic-stage",""),n.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",r.appendChild(n);let m=[];for(let x of t.scenes){if(x.background){let g=document.createElement("img");g.id=Nt,g.src=x.background,g.alt="",g.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(g);}let $=x.animations.filter(g=>g.type==="draw");if($.length){let g=document.createElementNS(yt,"svg");g.setAttribute("viewBox",`0 0 ${t.canvas.width} ${t.canvas.height}`),g.setAttribute("preserveAspectRatio","xMidYMid meet"),g.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(g);for(let E of $){let b=document.createElementNS(yt,"path");b.id=E.target.replace(/^#/,""),b.setAttribute("d",E.d),b.setAttribute("fill","none"),b.setAttribute("stroke",E.stroke),b.setAttribute("stroke-width",String(E.strokeWidth)),b.setAttribute("stroke-linecap","round"),b.setAttribute("stroke-linejoin","round");let F=E.length||b.getTotalLength?.()||0;b.style.strokeDasharray=String(F),b.style.strokeDashoffset=String(F),g.appendChild(b),m.push({kind:"draw",el:b,start:Ge(E.start),end:Ge(E.end),ease:Rt(E.easing),length:F});}}for(let g of x.animations){if(g.type!=="fade")continue;let E=n.querySelector(g.target)??document.querySelector(g.target);E&&(E.style.opacity=String(g.from),m.push({kind:"fade",el:E,start:Ge(g.start),end:Ge(g.end),ease:Q["ease-in-out"]??Q.linear,from:g.from,to:g.to}));}}let a=0,h=()=>{let x=r.offsetHeight-window.innerHeight;return x<=0?r.getBoundingClientRect().top<=0?1:0:Ke(-r.getBoundingClientRect().top/x)},f=x=>{for(let $ of m){let g=$.end-$.start,E=g<=0?x>=$.end?1:0:Ke((x-$.start)/g),b=$.ease(E);$.kind==="draw"?$.el.style.strokeDashoffset=String($.length*(1-b)):$.el.style.opacity=String($.from+($.to-$.from)*b);}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return f(1),{destroy:()=>{},getProgress:()=>1};let l=0,p=false,T=false,H=()=>{a=h(),f(a),p&&(l=requestAnimationFrame(H));},v=()=>{p||(p=true,l=requestAnimationFrame(H));},_=()=>{p=false,cancelAnimationFrame(l);},pe=new IntersectionObserver(x=>{for(let $ of x)T=$.isIntersecting,T?v():_();},{threshold:0});return pe.observe(n),a=h(),f(a),{destroy(){_(),pe.disconnect();},getProgress:()=>a}}};function er(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let n=typeof e=="string"?document.querySelector(e):e;return n?ut(n,t):(console.warn("[svg-scroll-draw] Container not found:",e),r)}
4
- exports.Cinematic=Qe;exports.PRESETS=Ue;exports.createBounce=it;exports.createElastic=at;exports.createSpring=Et;exports.scrollAnimate=Dt;exports.scrollCounter=Ft;exports.scrollDraw=er;exports.scrollParallax=Ot;
1
+ 'use strict';function Ft({tension:e=2.5,friction:t=2.2}={}){return r=>1-Math.cos(r*Math.PI*e)*Math.pow(1-r,t)}function vt({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,t)),l=Math.sqrt(n),a=0,d=[];for(let f=0;f<r;f++){let E=Math.pow(l,f);d.push(E),a+=E;}let m=[0],c=0;for(let f=0;f<r;f++)c+=d[f]/a,m.push(c);return f=>{if(f<=0)return 0;if(f>=1)return 1;for(let E=0;E<r;E++)if(f<=m[E+1]){let I=(f-m[E])/(m[E+1]-m[E]);if(E===0)return I*(2-I);let T=1-Math.pow(n,E);return T+(1-T)*(2*I-1)*(2*I-1)}return 1}}function St({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),n=Math.max(.1,t),l=r<=1?n/4:n/(2*Math.PI)*Math.asin(1/r);return a=>a<=0?0:a>=1?1:r*Math.pow(2,-10*a)*Math.sin((a-l)*(2*Math.PI)/n)+1}var J={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:vt(),elastic:St()};function $e(e="top bottom"){let t=e.trim();if(/^\d+(\.\d+)?%$/.test(t))return {element:"top",viewport:t};let[r="top",n="bottom"]=t.split(/\s+/).filter(Boolean);return {element:r,viewport:n}}function ht(e,t,r,n){switch(n){case "top":return e+r;case "center":return e+r+t/2;case "bottom":return e+r+t;default:return e+r}}function bt(e,t){if(/^\d+(\.\d+)?%$/.test(e))return t*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return t/2;case "bottom":return t;default:return t}}function He(e){let t=e.tagName.toLowerCase();if(t==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),n=parseFloat(e.getAttribute("height")??"0");return 2*(r+n)}if(t==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function Nt(e,t,r){return Math.min(r,Math.max(t,e))}function ie(e,t,r,n){return r===t?0:Nt((e-t)/(r-t)*n,0,1)}function Xe(e,t,r){let n=e.getBoundingClientRect(),l=r==="x"?n.width:n.height;return t?{top:r==="x"?n.left-t.getBoundingClientRect().left+t.scrollLeft:n.top-t.getBoundingClientRect().top+t.scrollTop,height:l,scroll:0}:{top:r==="x"?n.left:n.top,height:l,scroll:r==="x"?window.scrollX:window.scrollY}}function Oe(e,t,r,n,l){let a=ht(e.top,e.height,t,n.element)-bt(n.viewport,r),d=ht(e.top,e.height,t,l.element)-bt(l.viewport,r);return {tStart:a,tEnd:d}}function wt(e){let t=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(t)return [parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let n=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return n?[parseInt(n[1]),parseInt(n[2]),parseInt(n[3])]:null}function _e(e,t,r){let n=wt(e),l=wt(t);return !n||!l?e:`rgb(${Math.round(n[0]+(l[0]-n[0])*r)},${Math.round(n[1]+(l[1]-n[1])*r)},${Math.round(n[2]+(l[2]-n[2])*r)})`}var st={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:false},reveal:{easing:"ease-out",fade:true,speed:1.2,once:true},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:true,speed:.75},spring:{easing:"spring",speed:1.1}};var Ye=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function K(e,...t){Ye&&console.warn(`[svg-scroll-draw] ${e}`,...t);}var Ht="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",_t="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",Et=33;function zt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function Vt(e){let t=[];for(let r=0;r<Et;r++){let n=r/(Et-1);t.push(String(Math.round(e(n)*1e5)/1e5));}return `linear(${t.join(",")})`}function Qe(e){switch(e){case "linear":return "linear";case "ease-in":return Ht;case "ease-out":return _t;case "ease-in-out":return zt()?Vt(J["ease-in-out"]):null;default:return null}}var qt=0;function Wt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")&&CSS.supports("view-timeline-name: --x")}function Bt(e){let t=e.getAttribute("stroke"),r=e.getAttribute("fill");!t||t==="none"?K("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&K("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Gt(e,t,r){let n=document.createElement("div");n.setAttribute("data-svg-scroll-draw-debug",""),n.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function l(){let a=r==="x"?window.scrollX:window.scrollY,d=e-a,m=t-a,c=r==="x";n.innerHTML=`
2
+ <div style="position:absolute;${c?`left:${d}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${d}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
+ <div style="position:absolute;${c?`left:${m}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${m}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(n),window.addEventListener("scroll",l,{passive:true}),l(),{el:n,destroy(){window.removeEventListener("scroll",l),n.remove();}}}var xt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,Tt=/[MmLlHhVvCcSsQqTtAaZz]/g;function jt(e,t,r){if(!Ye)return;let n=(e.match(Tt)??[]).join("").toUpperCase(),l=(t.match(Tt)??[]).join("").toUpperCase(),a=(e.match(xt)??[]).length,d=(t.match(xt)??[]).length;if(n!==l){K(`morphTo: command sequence differs (${n||"\u2205"} \u2192 ${l||"\u2205"}). Interpolation is coordinate-for-coordinate, so the result will not reach the target shape. Redraw both paths with the same commands.`,r);return}a!==d&&K(`morphTo: coordinate count differs (${a} \u2192 ${d}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,r);}function it(e,t,r){let n=(t.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),l=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,a=>{let d=parseFloat(a),m=n[l++]??d;return String(+(d+(m-d)*r).toFixed(4))})}function At(e,t={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...n}=t,l=r?{...st[r],...n}:n,a=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:d="path, polyline, line, polygon, rect, circle",speed:m=1,fade:c=false,easing:f="linear",trigger:E={},stagger:I=0,direction:T="forward",once:ee=false,debug:Ee=false,axis:A="y",scrollContainer:$,autoReverse:g=false,delay:S=0,strokeColor:h,strokeWidth:V,fillOpacity:F,waypoints:B,velocityScale:te=false,threshold:de=0,rootMargin:j="0px",repeat:q=0,repeatDelay:Me=0,morphTo:N,clip:ge,autoplay:Pe=false,duration:ke=1e3,native:Le=true,onProgress:b,onStart:P,onComplete:oe,onEnter:ye,onLeave:Re,onEnterBack:he,onLeaveBack:xe}=l,re=ge===true?"left":typeof ge=="string"?ge:false,ue=typeof f=="function"?f:J[f]??J.linear,be=$e(E.start??"top bottom"),Fe=$e(E.end??"bottom top"),ae=typeof $=="string"?document.querySelector($):$??null,le=Array.isArray(h)?h[0]:null,U=Array.isArray(h)?h[1]:typeof h=="string"?h:null,X=Array.isArray(V)?V[0]:null,H=Array.isArray(V)?V[1]:typeof V=="number"?V:null,ne=Array.isArray(F)?F[0]:null,W=Array.isArray(F)?F[1]:typeof F=="number"?F:null;function we(o){let i=o*100;switch(re){case "right":return `inset(0 0 0 ${100-i}%)`;case "top":return `inset(0 0 ${100-i}% 0)`;case "bottom":return `inset(${100-i}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-i}% 0 0)`}}let C=re?[]:Array.from(e.querySelectorAll(d)),x=[],s=[],u=0,ce=0,k=false,D=false,O=0,_=false,Y=-1,ve=-1,G=false,me=0,Te=0,Ce,tt=null;function ut(){tt?.destroy(),tt=null;}let Ie=new Set,mt=NaN,De=true,qe=-1,ft=performance.now(),Ne=NaN;function rt(){return ae?A==="x"?ae.scrollLeft:ae.scrollTop:A==="x"?window.scrollX:window.scrollY}function pt(){return ae?A==="x"?ae.clientWidth:ae.clientHeight:A==="x"?window.innerWidth:window.innerHeight}function dt(){let o=Xe(e,ae,A),i=Oe(o,o.scroll,pt(),be,Fe);u=i.tStart,ce=i.tEnd,Ee&&Ye&&(ut(),tt=Gt(u,ce,A));}function It(o,i){if(e.style.setProperty("--scroll-draw-progress",String(o)),re){let w=i==="reverse"?1-o:o;e.style.clipPath=we(w);return}C.forEach((w,Q)=>{w.style.strokeDashoffset=i==="reverse"?`${x[Q]*o}`:`${x[Q]*(1-o)}`,c&&(w.style.opacity=i==="reverse"?`${1-o}`:`${o}`),le&&U?w.style.stroke=_e(le,U,o):U&&(w.style.stroke=U),X!==null&&H!==null?w.style.strokeWidth=`${X+(H-X)*o}`:H!==null&&(w.style.strokeWidth=`${H}`),ne!==null&&W!==null?w.style.fillOpacity=`${ne+(W-ne)*o}`:W!==null&&(w.style.fillOpacity=`${W}`),N&&w.tagName.toLowerCase()==="path"&&s[Q]&&w.setAttribute("d",it(s[Q],N,o));});}function We(){if(e.style.setProperty("--scroll-draw-progress","0"),re){e.style.clipPath=we(0);return}C.forEach((o,i)=>{o.style.strokeDasharray=`${x[i]}`,o.style.strokeDashoffset=T==="reverse"?"0":`${x[i]}`,c?o.style.opacity=T==="reverse"?"1":"0":o.style.opacity="",le&&(o.style.stroke=le),X!==null&&(o.style.strokeWidth=`${X}`),ne!==null&&(o.style.fillOpacity=`${ne}`),N&&o.tagName.toLowerCase()==="path"&&s[i]&&o.setAttribute("d",s[i]);});}if(C.forEach(o=>{Bt(o);let i=He(o);x.push(i);let w=o.tagName.toLowerCase()==="path";w?s.push(o.getAttribute("d")??""):s.push(""),N&&(w?jt(s[s.length-1],N,o):K(`morphTo only applies to <path> elements \u2014 ignored on <${o.tagName}>.`,o)),a?(o.style.strokeDasharray=`${i}`,o.style.strokeDashoffset=T==="reverse"?`${i}`:"0",c&&(o.style.opacity="1"),U&&(o.style.stroke=U),H!==null&&(o.style.strokeWidth=`${H}`),W!==null&&(o.style.fillOpacity=`${W}`),N&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",N)):(o.style.strokeDasharray=`${i}`,o.style.strokeDashoffset=T==="reverse"?"0":`${i}`,c?o.style.opacity=T==="reverse"?"1":"0":o.style.opacity="",le&&(o.style.stroke=le),X!==null&&(o.style.strokeWidth=`${X}`),ne!==null&&(o.style.fillOpacity=`${ne}`));}),re){if(a)return e.style.clipPath=we(1),oe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=we(0);}else if(a)return oe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};let gt=typeof f=="string"?Qe(f):null;function Dt(){return !(Le===false||!Wt()||!C.length||!gt||re||A!=="y"||ae||m!==1||I!==0||ee||g||te!==false||N||B||q||S>0||b||P||oe||ye||Re||he||xe||h!=null||V!=null||F!=null||(E.start??"top bottom").trim()!=="top bottom"||(E.end??"bottom top").trim()!=="bottom top")}function Ot(){let o=++qt,i=`svg-scroll-draw-${o}`,w=`svg-scroll-draw-host-${o}`,Q=`--svg-scroll-draw-${o}`,Ae=T==="reverse"?"0":"var(--ssd-len)",Se=T==="reverse"?"var(--ssd-len)":"0",pe=`stroke-dashoffset:${Ae};`,v=`stroke-dashoffset:${Se};`;c&&(pe+=`opacity:${T==="reverse"?1:0};`,v+=`opacity:${T==="reverse"?0:1};`);let M=document.createElement("style");M.setAttribute("data-svg-scroll-draw",""),M.textContent=`@keyframes ${i}{from{${pe}}to{${v}}}.${w}{view-timeline-name:${Q};view-timeline-axis:block;}.${i}{animation-name:${i};animation-duration:auto;animation-timing-function:${gt};animation-fill-mode:both;animation-timeline:${Q};animation-range:cover 0% cover 100%;}`,document.head.appendChild(M),e.classList.add(w);function Z(p,z){p.style.setProperty("--ssd-len",String(x[z])),p.style.strokeDasharray=`${x[z]}`,p.style.strokeDashoffset="",p.style.opacity="",p.style.animationPlayState="",p.classList.add(i);}C.forEach(Z);let y=false,L=-1;function R(){if(L>=0)return L;let p=e.getBoundingClientRect(),{tStart:z,tEnd:fe}=Oe({top:p.top,height:p.height},rt(),pt(),be,Fe);return ue(ie(rt(),z,fe,m))}return {destroy(){e.classList.remove(w),C.forEach(p=>{p.classList.remove(i),p.style.removeProperty("--ssd-len"),p.style.animationPlayState="";}),M.remove();},replay(){y=false,L=-1,C.forEach(Z);},pause(){y=true,C.forEach(p=>{p.style.animationPlayState="paused";});},resume(){y&&(y=false,C.forEach(p=>{p.style.animationPlayState="running";}));},seek(p){let z=Math.min(1,Math.max(0,p));L=z,y=true,C.forEach((fe,se)=>{fe.classList.remove(i),fe.style.strokeDashoffset=T==="reverse"?`${x[se]*z}`:`${x[se]*(1-z)}`,c&&(fe.style.opacity=T==="reverse"?`${1-z}`:`${z}`);});},getProgress(){return R()},refresh(){C.forEach((p,z)=>{x[z]=He(p),p.style.setProperty("--ssd-len",String(x[z])),p.style.strokeDasharray=`${x[z]}`;});}}}if(Dt())return Ot();function Rt(){let o=Math.max(1,ke),i=0,w=0,Q=false;function Ae(y){let L=true;if(re){let R=Math.min(1,Math.max(0,y/o)),p=ue(R);me=p,e.style.setProperty("--scroll-draw-progress",String(p)),e.style.clipPath=we(T==="reverse"?1-p:p),b?.(p),R<1&&(L=false);}else C.forEach((R,p)=>{let z=p*I*o,fe=Math.min(1,Math.max(0,(y-z)/o)),se=ue(fe);R.style.strokeDashoffset=T==="reverse"?`${x[p]*se}`:`${x[p]*(1-se)}`,c&&(R.style.opacity=T==="reverse"?`${1-se}`:`${se}`),le&&U?R.style.stroke=_e(le,U,se):U&&(R.style.stroke=U),X!==null&&H!==null?R.style.strokeWidth=`${X+(H-X)*se}`:H!==null&&(R.style.strokeWidth=`${H}`),ne!==null&&W!==null?R.style.fillOpacity=`${ne+(W-ne)*se}`:W!==null&&(R.style.fillOpacity=`${W}`),N&&R.tagName.toLowerCase()==="path"&&s[p]&&R.setAttribute("d",it(s[p],N,se)),p===0&&(me=se,b?.(se),e.style.setProperty("--scroll-draw-progress",String(se))),fe<1&&(L=false);});if(B){let R=Math.min(1,Math.max(0,y/o)),p=ue(R);for(let z in B){let fe=parseFloat(z);p>=fe&&!Ie.has(fe)&&(Ie.add(fe),B[z]?.());}}return L}function Se(y){if(G)return;let L=y-i;D||(D=true,P?.());let R=Ae(L);if(R&&!k){k=true,Ae(o*(1+Math.max(0,C.length-1)*I)),oe?.(),Te<(q==="infinite"?1/0:q??0)&&(Te++,Ce=setTimeout(()=>{i=performance.now(),D=false,k=false,Ie.clear(),We(),O=requestAnimationFrame(Se);},Me));return}R||(O=requestAnimationFrame(Se));}function pe(){cancelAnimationFrame(O),clearTimeout(Ce),i=performance.now(),w=0,G=false,D=false,k=false,Te=0,Q=true,me=0,Ie.clear(),We(),O=requestAnimationFrame(Se);}let v=new IntersectionObserver(y=>{y.forEach(L=>{L.isIntersecting&&!(ee&&k)?pe():!L.isIntersecting&&!ee&&!k&&(cancelAnimationFrame(O),clearTimeout(Ce),Q=false);});},{root:ae??null,threshold:de,rootMargin:j}),M;function Z(){clearTimeout(M),M=setTimeout(()=>{C.forEach((y,L)=>{x[L]=He(y),y.style.strokeDasharray=`${x[L]}`;});},150);}return window.addEventListener("resize",Z),window.addEventListener("orientationchange",Z),S>0?setTimeout(()=>v.observe(e),S):v.observe(e),{destroy(){cancelAnimationFrame(O),clearTimeout(Ce),v.disconnect(),window.removeEventListener("resize",Z),window.removeEventListener("orientationchange",Z),clearTimeout(M);},replay(){Te=0,pe();},pause(){G||!Q||(G=true,w=performance.now()-i,cancelAnimationFrame(O));},resume(){G&&(G=false,Q=true,i=performance.now()-w,O=requestAnimationFrame(Se));},seek(y){let L=Math.min(1,Math.max(0,y));me=L,G=true,w=L*o,i=performance.now()-w,cancelAnimationFrame(O),Ae(w);},getProgress(){return me},refresh(){clearTimeout(M),C.forEach((y,L)=>{x[L]=He(y),y.style.strokeDasharray=`${x[L]}`;});}}}if(Pe)return Rt();dt();function Be(){if(!_||G)return;let o=performance.now(),i=rt();if(!De&&te===false&&i===mt){O=requestAnimationFrame(Be);return}De=false,mt=i;let w=m;if(te!==false){let v=o-ft,M=v>0?Math.abs(i-(qe<0?i:qe))/v:0;w=m*Math.max(.2,1+M*(typeof te=="number"?te:1)*.04);}qe=i,ft=o;let Q=g?ve===-1||i>=ve?"forward":"reverse":T;ve=i;let Ae=ce-u,Se=true,pe=Ae===0?0:(i-u)/Ae;if(isNaN(Ne)||(Ne<=0&&pe>0?ye?.():Ne>0&&pe<=0&&xe?.(),Ne<1&&pe>=1?Re?.():Ne>=1&&pe<1&&he?.()),Ne=pe,re){let v=ue(ie(i,u,ce,w));ee&&!g&&(Y=Math.max(Y,v),v=Y),me=v,e.style.setProperty("--scroll-draw-progress",String(v));let M=Q==="reverse"?1-v:v;e.style.clipPath=we(M),b?.(v),!D&&ie(i,u,ce,w)>0&&(D=true,P?.()),v>=1&&!k?(k=true,oe?.(),Te<(q==="infinite"?1/0:q??0)&&(Te++,Ce=setTimeout(()=>{Y=-1,D=false,k=false,e.style.clipPath=we(0);},Me))):v<1&&!ee&&(k=false),O=requestAnimationFrame(Be);return}if(C.forEach((v,M)=>{let Z=M*I*Ae,y=ue(ie(i,u+Z,ce+Z,w));ee&&!g&&(Y=Math.max(Y,y),y=Y),me=y,v.style.strokeDashoffset=Q==="reverse"?`${x[M]*y}`:`${x[M]*(1-y)}`,c&&(v.style.opacity=Q==="reverse"?`${1-y}`:`${y}`),le&&U?v.style.stroke=_e(le,U,y):U&&(v.style.stroke=U),X!==null&&H!==null?v.style.strokeWidth=`${X+(H-X)*y}`:H!==null&&(v.style.strokeWidth=`${H}`),ne!==null&&W!==null?v.style.fillOpacity=`${ne+(W-ne)*y}`:W!==null&&(v.style.fillOpacity=`${W}`),N&&v.tagName.toLowerCase()==="path"&&s[M]&&v.setAttribute("d",it(s[M],N,y)),M===0&&(b?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&(Se=false);}),B){let v=ue(ie(i,u,ce,w));for(let M in B){let Z=parseFloat(M);v>=Z&&!Ie.has(Z)&&(Ie.add(Z),B[M]?.());}}!D&&ie(i,u,ce,w)>0&&(D=true,P?.()),Se&&!k?(k=true,oe?.(),Te<(q==="infinite"?1/0:q??0)&&(Te++,Ce=setTimeout(()=>{Y=-1,D=false,k=false,Ie.clear(),We(),De=true;},Me))):!Se&&!ee&&(k=false),O=requestAnimationFrame(Be);}let nt=false;function Ge(){nt||(nt=true,O=requestAnimationFrame(function(){Be();}));}function je(){nt=false,cancelAnimationFrame(O);}let ot=new IntersectionObserver(o=>{o.forEach(i=>{_=i.isIntersecting,_&&!G?(De=true,Ge()):je();});},{root:ae??null,threshold:de,rootMargin:j});function yt(){C.forEach((o,i)=>{x[i]=He(o),o.style.strokeDasharray=`${x[i]}`;}),dt(),De=true;}let Ue;function ze(){clearTimeout(Ue),Ue=setTimeout(yt,150);}window.addEventListener("resize",ze),window.addEventListener("orientationchange",ze);let Ve;return typeof ResizeObserver<"u"&&(Ve=new ResizeObserver(()=>ze()),Ve.observe(document.body),Ve.observe(document.documentElement),Ve.observe(e)),S>0?setTimeout(()=>ot.observe(e),S):ot.observe(e),{destroy(){cancelAnimationFrame(O),clearTimeout(Ce),je(),ot.disconnect(),Ve?.disconnect(),window.removeEventListener("resize",ze),window.removeEventListener("orientationchange",ze),clearTimeout(Ue),ut();},replay(){Y=-1,ve=-1,qe=-1,D=false,k=false,Te=0,G=false,me=0,Ie.clear(),clearTimeout(Ce),We(),De=true,_&&Ge();},pause(){G=true,je();},resume(){G&&(G=false,De=true,_&&Ge());},seek(o){let i=Math.min(1,Math.max(0,o));me=i,Y=i,G=true,je(),It(i,T),De=true;},getProgress(){return me},refresh(){clearTimeout(Ue),yt(),_&&!G&&Ge();}}}var $t=new Map;function Ze(e,t){$t.set(e,t);}function Je(e){$t.delete(e);}function Ut(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function Mt(e){let t=[],r=/([\w]+)\(([^)]*)\)/g,n;for(;(n=r.exec(e))!==null;){let l=[],a=[],d=n[2].trim();if(d)for(let m of d.split(/[\s,]+/)){let c=m.match(/^([-+]?[\d.eE]+)(.*)$/);l.push(c?parseFloat(c[1]):0),a.push(c?c[2]:"");}t.push({fn:n[1],nums:l,units:a});}return t}function Xt(e,t,r){let n=Mt(e),l=Mt(t);return n.length===0||n.length!==l.length?r<1?e:t:n.map((a,d)=>{let m=l[d];return a.fn!==m.fn||a.nums.length!==m.nums.length?r<1?`${a.fn}(${a.nums.map((c,f)=>`${c}${a.units[f]}`).join(", ")})`:`${m.fn}(${m.nums.map((c,f)=>`${c}${m.units[f]}`).join(", ")})`:`${a.fn}(${a.nums.map((c,f)=>`${c+(m.nums[f]-c)*r}${a.units[f]}`).join(", ")})`}).join(" ")}function Pt(e,t,r){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*r);let n=String(e),l=String(t);if(Ut(n))return _e(n,l,r);if(n.includes("("))return Xt(n,l,r);let a=n.match(/^([-+]?[\d.]+)(.*)$/),d=l.match(/^([-+]?[\d.]+)(.*)$/);if(a&&d){let m=parseFloat(a[1]),c=parseFloat(d[1]);return `${m+(c-m)*r}${a[2]||d[2]}`}return r<1?n:l}function Yt(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var Qt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Zt=0,kt="--scroll-draw-progress";function Jt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Lt(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:n,trigger:l={},easing:a="ease-out",speed:d=1,once:m=false,axis:c="y",scrollContainer:f,native:E=true,velocityScale:I=false,respectReducedMotion:T=true,triggerElement:ee,onProgress:Ee,onComplete:A,onEnter:$,onLeave:g,onEnterBack:S,onLeaveBack:h}=t,V=T&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,F=typeof a=="function"?a:J[a]??J["ease-out"],B=$e(l.start??"top bottom"),te=$e(l.end??"bottom top"),de=ee??e,j=typeof f=="string"?document.querySelector(f):f??null,q=Object.entries(n).map(([s,u])=>({prop:Yt(s),from:Array.isArray(u)?u[0]:"",to:Array.isArray(u)?u[1]:u}));function Me(){let s=window.getComputedStyle(e);for(let u of q)u.from===""&&(u.from=s.getPropertyValue(u.prop).trim()||"0");}function N(){for(let s of q)e.style.setProperty(s.prop,String(s.to));}let ge=new Map;for(let s of [...q.map(u=>u.prop),kt])ge.set(s,e.style.getPropertyValue(s));function Pe(){for(let[s,u]of ge)u?e.style.setProperty(s,u):e.style.removeProperty(s);}if(V)return N(),A?.(),{...r,destroy:Pe,getProgress:()=>1};Me();let ke=typeof a=="string"?Qe(a):null;function Le(){if(!E||!Jt()||!ke||c!=="y"||j||de!==e||m||d!==1||Ee||A||$||g||S||h||I!==false||(l.start??"top bottom").trim()!=="top bottom"||(l.end??"bottom top").trim()!=="bottom top")return false;for(let s of q)if(!Qt.has(s.prop))return false;return true}function b(){let s=`ssd-a-${++Zt}`,u=q.map(_=>`${_.prop}:${_.from}`).join(";"),ce=q.map(_=>`${_.prop}:${_.to}`).join(";"),k=document.createElement("style");k.setAttribute("data-ssd-animate",""),k.textContent=`@keyframes ${s}{from{${u}}to{${ce}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${ke};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(k),e.classList.add(s);let D=()=>c==="x"?window.scrollX:window.scrollY,O=()=>c==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(s),k.remove(),e.style.animationPlayState="",Pe();},replay(){e.classList.remove(s),e.offsetWidth,e.classList.add(s);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(_){let Y=Math.min(1,Math.max(0,_));e.classList.remove(s);for(let ve of q)e.style.setProperty(ve.prop,Pt(ve.from,ve.to,Y));},getProgress(){let _=e.getBoundingClientRect(),Y=D(),ve=O(),{tStart:G,tEnd:me}=Oe({top:_.top,height:_.height},Y,ve,B,te);return F(ie(Y,G,me,d))}}}if(Le())return b();let P=0,oe=0,ye=0,Re=false,he=false,xe=-1,re=0,ue=false,be=NaN,Fe=-1,ae=0,le=()=>j?c==="x"?j.scrollLeft:j.scrollTop:c==="x"?window.scrollX:window.scrollY,U=()=>j?c==="x"?j.clientWidth:j.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function X(){let s=Xe(de,j,c),u=Oe(s,s.scroll,U(),B,te);P=u.tStart,oe=u.tEnd;}function H(s){e.style.setProperty(kt,String(s));for(let u of q)e.style.setProperty(u.prop,Pt(u.from,u.to,s));Ee?.(s);}function ne(s){if(isNaN(be)){be=s;return}be<=0&&s>0?$?.():be>0&&s<=0&&h?.(),be<1&&s>=1?g?.():be>=1&&s<1&&S?.(),be=s;}function W(){if(!Re||he)return;let s=performance.now(),u=le(),ce=d;if(I!==false){let O=s-ae,_=O>0?Math.abs(u-(Fe<0?u:Fe))/O:0;ce=d*Math.max(.2,1+_*(typeof I=="number"?I:1)*.04);}Fe=u,ae=s;let k=oe===P?0:(u-P)/(oe-P);ne(k);let D=F(ie(u,P,oe,ce));m&&(xe=Math.max(xe,D),D=xe),re=D,H(D),D>=1&&!ue?(ue=true,A?.()):D<1&&!m&&(ue=false),ye=requestAnimationFrame(W);}X(),oe===P&&K("scrollAnimate: the trigger window has zero length (start and end resolve to the same scroll position), so this element will never animate. If the target is inside a position:sticky stage, measure the trigger from the container that holds the scroll room via `triggerElement`.",e);{let s=F(ie(le(),P,oe,d));m&&s>0&&(xe=s),re=s,H(s);}let we=new IntersectionObserver(s=>{s.forEach(u=>{Re=u.isIntersecting,Re&&!he?ye=requestAnimationFrame(W):cancelAnimationFrame(ye);});},{root:j??null}),C;function x(){clearTimeout(C),C=setTimeout(X,150);}return window.addEventListener("resize",x),window.addEventListener("orientationchange",x),we.observe(e),Ze(e,{type:"animate",getProgress:()=>re,getTrigger:()=>({tStart:P,tEnd:oe})}),{destroy(){cancelAnimationFrame(ye),we.disconnect(),window.removeEventListener("resize",x),window.removeEventListener("orientationchange",x),clearTimeout(C),Pe(),Je(e);},replay(){xe=-1,ue=false,re=0,he=false,H(0);},pause(){he=true,cancelAnimationFrame(ye);},resume(){he&&(he=false,Re&&(ye=requestAnimationFrame(W)));},seek(s){let u=Math.min(1,Math.max(0,s));re=u,xe=u,he=true,cancelAnimationFrame(ye),H(u);},getProgress(){return re}}}var Ke={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Kt(e,t){if(typeof window>"u")return Ke;let r=typeof e=="string"?document.querySelector(e):e;return r?Lt(r,t):(K("scrollAnimate: element not found:",e),Ke)}function er(e,t={}){if(typeof window>"u")return Ke;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return K("scrollParallax: element not found:",e),Ke;let{speed:n=.3,axis:l="y",easing:a="linear",trigger:d,onProgress:m}=t,c=r.getBoundingClientRect(),f=l==="x"?c.width:c.height,E=n*f;return Lt(r,{props:l==="x"?{transform:["translateX(0px)",`translateX(${-E}px)`]}:{transform:["translateY(0px)",`translateY(${-E}px)`]},trigger:d??{start:"top bottom",end:"bottom top"},easing:a,native:false,onProgress:m})}var at={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function tr(e,t){if(typeof window>"u")return at;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return K("scrollCounter: element not found:",e),at;let n=r,{from:l=0,to:a,format:d,easing:m="ease-out",trigger:c={},once:f=true,decimals:E,onComplete:I}=t,T=E!==void 0?b=>b.toFixed(E):d??(b=>String(Math.round(b))),ee=typeof m=="function"?m:J[m]??J["ease-out"],Ee=$e(c.start??"top 80%"),A=$e(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=T(a),I?.(),at;let g=0,S=0,h=0,V=false,F=false,B=-1,te=0,de=false,j=()=>window.scrollY,q=()=>window.innerHeight;function Me(){let b=n.getBoundingClientRect(),P=Oe({top:b.top,height:b.height},j(),q(),Ee,A);g=P.tStart,S=P.tEnd;}function N(b){n.textContent=T(l+(a-l)*b),n.style.setProperty("--scroll-draw-progress",String(b));}function ge(){if(!V||F)return;let b=ee(ie(j(),g,S,1));f&&(B=Math.max(B,b),b=B),te=b,N(b),b>=1&&!de?(de=true,I?.()):b<1&&!f&&(de=false),h=requestAnimationFrame(ge);}Me();{let b=ee(ie(j(),g,S,1));f&&b>0&&(B=b),te=b,N(b);}let Pe=new IntersectionObserver(b=>{b.forEach(P=>{V=P.isIntersecting,V&&!F?h=requestAnimationFrame(ge):cancelAnimationFrame(h);});}),ke;function Le(){clearTimeout(ke),ke=setTimeout(Me,150);}return window.addEventListener("resize",Le),window.addEventListener("orientationchange",Le),Pe.observe(n),Ze(n,{type:"counter",getProgress:()=>te,getTrigger:()=>({tStart:g,tEnd:S})}),{destroy(){cancelAnimationFrame(h),Pe.disconnect(),window.removeEventListener("resize",Le),window.removeEventListener("orientationchange",Le),clearTimeout(ke),Je(n);},replay(){B=-1,de=false,te=0,F=false,N(0);},pause(){F=true,cancelAnimationFrame(h);},resume(){F&&(F=false,V&&(h=requestAnimationFrame(ge)));},seek(b){let P=Math.min(1,Math.max(0,b));te=P,B=P,F=true,cancelAnimationFrame(h),N(P);},getProgress(){return te}}}var Ct="http://www.w3.org/2000/svg",rr="cinematic-photo",lt=e=>e<0?0:e>1?1:e;function et(e){let t=parseFloat(e);return Number.isFinite(t)?lt(t/100):0}function nr(e){return J[e]??J.linear}var or={destroy:()=>{},getProgress:()=>0},ct=class{constructor(t){if(typeof document>"u"){this.mount=null;return}this.mount=typeof t.wrapper=="string"?document.querySelector(t.wrapper):t.wrapper,this.mount||K("Cinematic: wrapper not found:",t.wrapper);}loadStory(t){let r=this.mount;if(typeof window>"u"||!r)return or;r.style.position="relative",r.style.height=t.totalHeight,r.style.display="block";let n=document.createElement("div");n.setAttribute("data-cinematic-stage",""),n.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",r.appendChild(n);let l=[];for(let A of t.scenes){if(A.background){let g=document.createElement("img");g.id=rr,g.src=A.background,g.alt="",g.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(g);}let $=A.animations.filter(g=>g.type==="draw");if($.length){let g=document.createElementNS(Ct,"svg");g.setAttribute("viewBox",`0 0 ${t.canvas.width} ${t.canvas.height}`),g.setAttribute("preserveAspectRatio","xMidYMid meet"),g.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(g);for(let S of $){let h=document.createElementNS(Ct,"path");h.id=S.target.replace(/^#/,""),h.setAttribute("d",S.d),h.setAttribute("fill","none"),h.setAttribute("stroke",S.stroke),h.setAttribute("stroke-width",String(S.strokeWidth)),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round");let V=S.length||h.getTotalLength?.()||0;h.style.strokeDasharray=String(V),h.style.strokeDashoffset=String(V),g.appendChild(h),l.push({kind:"draw",el:h,start:et(S.start),end:et(S.end),ease:nr(S.easing),length:V});}}for(let g of A.animations){if(g.type!=="fade")continue;let S=n.querySelector(g.target)??document.querySelector(g.target);S&&(S.style.opacity=String(g.from),l.push({kind:"fade",el:S,start:et(g.start),end:et(g.end),ease:J["ease-in-out"]??J.linear,from:g.from,to:g.to}));}}let a=0,d=()=>{let A=r.offsetHeight-window.innerHeight;return A<=0?r.getBoundingClientRect().top<=0?1:0:lt(-r.getBoundingClientRect().top/A)},m=A=>{for(let $ of l){let g=$.end-$.start,S=g<=0?A>=$.end?1:0:lt((A-$.start)/g),h=$.ease(S);$.kind==="draw"?$.el.style.strokeDashoffset=String($.length*(1-h)):$.el.style.opacity=String($.from+($.to-$.from)*h);}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(1),{destroy:()=>{},getProgress:()=>1};let c=0,f=false,E=false,I=()=>{a=d(),m(a),f&&(c=requestAnimationFrame(I));},T=()=>{f||(f=true,c=requestAnimationFrame(I));},ee=()=>{f=false,cancelAnimationFrame(c);},Ee=new IntersectionObserver(A=>{for(let $ of A)E=$.isIntersecting,E?T():ee();},{threshold:0});return Ee.observe(n),a=d(),m(a),{destroy(){ee(),Ee.disconnect();},getProgress:()=>a}}};function Lr(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let n=typeof e=="string"?document.querySelector(e):e;return n?At(n,t):(K("Container not found:",e),r)}
4
+ exports.Cinematic=ct;exports.PRESETS=st;exports.createBounce=vt;exports.createElastic=St;exports.createSpring=Ft;exports.scrollAnimate=Kt;exports.scrollCounter=tr;exports.scrollDraw=Lr;exports.scrollParallax=er;
package/dist/index.d.mts CHANGED
@@ -125,6 +125,21 @@ interface ScrollDrawInstance {
125
125
  seek: (progress: number) => void;
126
126
  /** Returns current draw progress (0–1). */
127
127
  getProgress: () => number;
128
+ /**
129
+ * Re-measure after a layout change: path lengths, and the scroll trigger window.
130
+ *
131
+ * The engine already re-measures on `resize`, on `orientationchange`, and via a
132
+ * `ResizeObserver` on the document element — but none of those fire for a layout
133
+ * change that leaves the document height alone, such as a tab switching, a
134
+ * sibling collapsing, or a font swapping inside a fixed-height box. Call this
135
+ * after one of those.
136
+ *
137
+ * Optional on this shared type because several instances here are fan-outs over
138
+ * other instances or SSR no-op stubs. `scrollDraw`, `scrollPin`,
139
+ * `scrollHorizontal`, `scrollDrawTimeline` and the group APIs all provide it;
140
+ * use `instance.refresh?.()` if you hold an instance of unknown origin.
141
+ */
142
+ refresh?: () => void;
128
143
  }
129
144
 
130
145
  type PresetName = 'sketch' | 'reveal' | 'typewriter' | 'cinematic' | 'spring';
@@ -189,6 +204,39 @@ interface ScrollAnimateOptions {
189
204
  axis?: 'x' | 'y';
190
205
  scrollContainer?: string | Element;
191
206
  native?: boolean;
207
+ /**
208
+ * Scale animation speed by scroll velocity — faster scrolling = faster animation.
209
+ * Pass `true` for default sensitivity (1) or a number to control it.
210
+ * Higher values = more dramatic speed-up. Default sensitivity: 1.
211
+ */
212
+ velocityScale?: boolean | number;
213
+ /**
214
+ * Honour `prefers-reduced-motion: reduce` by applying the final state and not
215
+ * animating. Default: `true`.
216
+ *
217
+ * Set to `false` only when the movement is *scroll-linked scrubbing* rather
218
+ * than autonomous motion — it advances solely as the user scrolls, 1:1 with
219
+ * their input, so it is direct manipulation rather than something that plays at
220
+ * them. `scrollHorizontal` sets this, because jumping to the final state there
221
+ * would leave every panel but the last unreachable inside the sticky
222
+ * `overflow: hidden` container.
223
+ */
224
+ respectReducedMotion?: boolean;
225
+ /**
226
+ * Element whose geometry defines the trigger window, when that is not the
227
+ * element being animated. Defaults to the animated element.
228
+ *
229
+ * Needed whenever the animated element cannot supply the scroll length itself —
230
+ * the case that matters is a `position: sticky` stage, where the pinned element
231
+ * is exactly one viewport tall and all of the scroll room belongs to its
232
+ * container. Resolving `top top` → `bottom bottom` against the pinned element
233
+ * there yields tStart === tEnd, a zero-length window, and no movement at all.
234
+ *
235
+ * Setting this disables the native CSS fast path: `animation-timeline: view()`
236
+ * always measures the element the animation is attached to, so it cannot express
237
+ * a separate subject.
238
+ */
239
+ triggerElement?: Element;
192
240
  onProgress?: (alpha: number) => void;
193
241
  onComplete?: () => void;
194
242
  /** Fires when scroll enters the trigger zone (scrolling forward). */
package/dist/index.d.ts CHANGED
@@ -125,6 +125,21 @@ interface ScrollDrawInstance {
125
125
  seek: (progress: number) => void;
126
126
  /** Returns current draw progress (0–1). */
127
127
  getProgress: () => number;
128
+ /**
129
+ * Re-measure after a layout change: path lengths, and the scroll trigger window.
130
+ *
131
+ * The engine already re-measures on `resize`, on `orientationchange`, and via a
132
+ * `ResizeObserver` on the document element — but none of those fire for a layout
133
+ * change that leaves the document height alone, such as a tab switching, a
134
+ * sibling collapsing, or a font swapping inside a fixed-height box. Call this
135
+ * after one of those.
136
+ *
137
+ * Optional on this shared type because several instances here are fan-outs over
138
+ * other instances or SSR no-op stubs. `scrollDraw`, `scrollPin`,
139
+ * `scrollHorizontal`, `scrollDrawTimeline` and the group APIs all provide it;
140
+ * use `instance.refresh?.()` if you hold an instance of unknown origin.
141
+ */
142
+ refresh?: () => void;
128
143
  }
129
144
 
130
145
  type PresetName = 'sketch' | 'reveal' | 'typewriter' | 'cinematic' | 'spring';
@@ -189,6 +204,39 @@ interface ScrollAnimateOptions {
189
204
  axis?: 'x' | 'y';
190
205
  scrollContainer?: string | Element;
191
206
  native?: boolean;
207
+ /**
208
+ * Scale animation speed by scroll velocity — faster scrolling = faster animation.
209
+ * Pass `true` for default sensitivity (1) or a number to control it.
210
+ * Higher values = more dramatic speed-up. Default sensitivity: 1.
211
+ */
212
+ velocityScale?: boolean | number;
213
+ /**
214
+ * Honour `prefers-reduced-motion: reduce` by applying the final state and not
215
+ * animating. Default: `true`.
216
+ *
217
+ * Set to `false` only when the movement is *scroll-linked scrubbing* rather
218
+ * than autonomous motion — it advances solely as the user scrolls, 1:1 with
219
+ * their input, so it is direct manipulation rather than something that plays at
220
+ * them. `scrollHorizontal` sets this, because jumping to the final state there
221
+ * would leave every panel but the last unreachable inside the sticky
222
+ * `overflow: hidden` container.
223
+ */
224
+ respectReducedMotion?: boolean;
225
+ /**
226
+ * Element whose geometry defines the trigger window, when that is not the
227
+ * element being animated. Defaults to the animated element.
228
+ *
229
+ * Needed whenever the animated element cannot supply the scroll length itself —
230
+ * the case that matters is a `position: sticky` stage, where the pinned element
231
+ * is exactly one viewport tall and all of the scroll room belongs to its
232
+ * container. Resolving `top top` → `bottom bottom` against the pinned element
233
+ * there yields tStart === tEnd, a zero-length window, and no movement at all.
234
+ *
235
+ * Setting this disables the native CSS fast path: `animation-timeline: view()`
236
+ * always measures the element the animation is attached to, so it cannot express
237
+ * a separate subject.
238
+ */
239
+ triggerElement?: Element;
192
240
  onProgress?: (alpha: number) => void;
193
241
  onComplete?: () => void;
194
242
  /** Fires when scroll enters the trigger zone (scrolling forward). */
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- function Et({tension:e=2.5,friction:t=2.2}={}){return r=>1-Math.cos(r*Math.PI*e)*Math.pow(1-r,t)}function it({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,t)),m=Math.sqrt(n),a=0,h=[];for(let p=0;p<r;p++){let T=Math.pow(m,p);h.push(T),a+=T;}let f=[0],l=0;for(let p=0;p<r;p++)l+=h[p]/a,f.push(l);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let T=0;T<r;T++)if(p<=f[T+1]){let H=(p-f[T])/(f[T+1]-f[T]);if(T===0)return H*(2-H);let v=1-Math.pow(n,T);return v+(1-v)*(2*H-1)*(2*H-1)}return 1}}function at({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),n=Math.max(.1,t),m=r<=1?n/4:n/(2*Math.PI)*Math.asin(1/r);return a=>a<=0?0:a>=1?1:r*Math.pow(2,-10*a)*Math.sin((a-m)*(2*Math.PI)/n)+1}var Q={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:it(),elastic:at()};function he(e="top bottom"){let t=e.trim();if(/^\d+(\.\d+)?%$/.test(t))return {element:"top",viewport:t};let[r="top",n="bottom"]=t.split(/\s+/).filter(Boolean);return {element:r,viewport:n}}function nt(e,t,r,n){switch(n){case "top":return e+r;case "center":return e+r+t/2;case "bottom":return e+r+t;default:return e+r}}function ot(e,t){if(/^\d+(\.\d+)?%$/.test(e))return t*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return t/2;case "bottom":return t;default:return t}}function Ve(e){let t=e.tagName.toLowerCase();if(t==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),n=parseFloat(e.getAttribute("height")??"0");return 2*(r+n)}if(t==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function St(e,t,r){return Math.min(r,Math.max(t,e))}function ee(e,t,r,n){return r===t?0:St((e-t)/(r-t)*n,0,1)}function Se(e,t,r,n,m){let a=nt(e.top,e.height,t,n.element)-ot(n.viewport,r),h=nt(e.top,e.height,t,m.element)-ot(m.viewport,r);return {tStart:a,tEnd:h}}function st(e){let t=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(t)return [parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let n=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return n?[parseInt(n[1]),parseInt(n[2]),parseInt(n[3])]:null}function Ce(e,t,r){let n=st(e),m=st(t);return !n||!m?e:`rgb(${Math.round(n[0]+(m[0]-n[0])*r)},${Math.round(n[1]+(m[1]-n[1])*r)},${Math.round(n[2]+(m[2]-n[2])*r)})`}var Ue={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:false},reveal:{easing:"ease-out",fade:true,speed:1.2,once:true},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:true,speed:.75},spring:{easing:"spring",speed:1.1}};function lt(e,t){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,t);}var ct={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},xt=0;function At(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Tt(e){let t=e.getAttribute("stroke"),r=e.getAttribute("fill");!t||t==="none"?lt("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&lt("Element has a fill \u2014 it may obscure the stroke animation.",e);}function $t(e,t,r){let n=document.createElement("div");n.setAttribute("data-svg-scroll-draw-debug",""),n.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function m(){let a=r==="x"?window.scrollX:window.scrollY,h=e-a,f=t-a,l=r==="x";n.innerHTML=`
2
- <div style="position:absolute;${l?`left:${h}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${h}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
- <div style="position:absolute;${l?`left:${f}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${f}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(n),window.addEventListener("scroll",m,{passive:true}),m(),n}function Ze(e,t,r){let n=(t.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),m=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,a=>{let h=parseFloat(a),f=n[m++]??h;return String(+(h+(f-h)*r).toFixed(4))})}function ut(e,t={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...n}=t,m=r?{...Ue[r],...n}:n,a=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:h="path, polyline, line, polygon, rect, circle",speed:f=1,fade:l=false,easing:p="linear",trigger:T={},stagger:H=0,direction:v="forward",once:_=false,debug:pe=false,axis:x="y",scrollContainer:$,autoReverse:g=false,delay:E=0,strokeColor:b,strokeWidth:F,fillOpacity:A,waypoints:C,velocityScale:te=false,threshold:de=0,rootMargin:be="0px",repeat:ie=0,repeatDelay:Y=0,morphTo:L,clip:j,autoplay:ge=false,duration:re=1e3,native:ne=true,onProgress:d,onStart:q,onComplete:U,onEnter:xe,onLeave:Oe,onEnterBack:Le,onLeaveBack:Ae}=m,ue=j===true?"left":typeof j=="string"?j:false,ae=typeof p=="function"?p:Q[p]??Q.linear,Ie=he(T.start??"top bottom"),Me=he(T.end??"bottom top"),z=typeof $=="string"?document.querySelector($):$??null,s=Array.isArray(b)?b[0]:null,u=Array.isArray(b)?b[1]:typeof b=="string"?b:null,N=Array.isArray(F)?F[0]:null,I=Array.isArray(F)?F[1]:typeof F=="number"?F:null,V=Array.isArray(A)?A[0]:null,G=Array.isArray(A)?A[1]:typeof A=="number"?A:null;function B(o){let i=o*100;switch(ue){case "right":return `inset(0 0 0 ${100-i}%)`;case "top":return `inset(0 0 ${100-i}% 0)`;case "bottom":return `inset(${100-i}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-i}% 0 0)`}}let O=ue?[]:Array.from(e.querySelectorAll(h)),M=[],oe=[],le=0,we=0,X=false,ce=false,W=0,Fe=false,me=-1,Ne=-1,Z=false,Te=0,ye=0,ve,je=null,Ee=new Set,Re=-1,et=performance.now(),Pe=NaN;function De(){return z?x==="x"?z.scrollLeft:z.scrollTop:x==="x"?window.scrollX:window.scrollY}function tt(){return z?x==="x"?z.clientWidth:z.clientHeight:x==="x"?window.innerWidth:window.innerHeight}function rt(){let o=e.getBoundingClientRect(),i,w,R;if(z){let K=z.getBoundingClientRect();i=x==="x"?o.left-K.left+z.scrollLeft:o.top-K.top+z.scrollTop,w=x==="x"?o.width:o.height,R=De();}else i=x==="x"?o.left:o.top,w=x==="x"?o.width:o.height,R=De();let J=Se({top:i,height:w},R,tt(),Ie,Me);le=J.tStart,we=J.tEnd,pe&&process.env.NODE_ENV!=="production"&&(je?.remove(),je=$t(le,we,x));}function ht(o,i){if(e.style.setProperty("--scroll-draw-progress",String(o)),ue){let w=i==="reverse"?1-o:o;e.style.clipPath=B(w);return}O.forEach((w,R)=>{w.style.strokeDashoffset=i==="reverse"?`${M[R]*o}`:`${M[R]*(1-o)}`,l&&(w.style.opacity=i==="reverse"?`${1-o}`:`${o}`),s&&u?w.style.stroke=Ce(s,u,o):u&&(w.style.stroke=u),N!==null&&I!==null?w.style.strokeWidth=`${N+(I-N)*o}`:I!==null&&(w.style.strokeWidth=`${I}`),V!==null&&G!==null?w.style.fillOpacity=`${V+(G-V)*o}`:G!==null&&(w.style.fillOpacity=`${G}`),L&&w.tagName.toLowerCase()==="path"&&oe[R]&&w.setAttribute("d",Ze(oe[R],L,o));});}function He(){if(e.style.setProperty("--scroll-draw-progress","0"),ue){e.style.clipPath=B(0);return}O.forEach((o,i)=>{o.style.strokeDasharray=`${M[i]}`,o.style.strokeDashoffset=v==="reverse"?"0":`${M[i]}`,l?o.style.opacity=v==="reverse"?"1":"0":o.style.opacity="",s&&(o.style.stroke=s),N!==null&&(o.style.strokeWidth=`${N}`),V!==null&&(o.style.fillOpacity=`${V}`),L&&o.tagName.toLowerCase()==="path"&&oe[i]&&o.setAttribute("d",oe[i]);});}if(O.forEach(o=>{Tt(o);let i=Ve(o);M.push(i),o.tagName.toLowerCase()==="path"?oe.push(o.getAttribute("d")??""):oe.push(""),a?(o.style.strokeDasharray=`${i}`,o.style.strokeDashoffset=v==="reverse"?`${i}`:"0",l&&(o.style.opacity="1"),u&&(o.style.stroke=u),I!==null&&(o.style.strokeWidth=`${I}`),G!==null&&(o.style.fillOpacity=`${G}`),L&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",L)):(o.style.strokeDasharray=`${i}`,o.style.strokeDashoffset=v==="reverse"?"0":`${i}`,l?o.style.opacity=v==="reverse"?"1":"0":o.style.opacity="",s&&(o.style.stroke=s),N!==null&&(o.style.strokeWidth=`${N}`),V!==null&&(o.style.fillOpacity=`${V}`));}),ue){if(a)return e.style.clipPath=B(1),U?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=B(0);}else if(a)return U?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function bt(){return !(ne===false||!At()||!O.length||typeof p!="string"||!(p in ct)||ue||x!=="y"||z||f!==1||H!==0||_||g||te!==false||L||C||ie||E>0||d||q||U||xe||Oe||Le||Ae||b!=null||F!=null||A!=null||(T.start??"top bottom").trim()!=="top bottom"||(T.end??"bottom top").trim()!=="bottom top")}function wt(){let o=`svg-scroll-draw-${++xt}`,i=v==="reverse"?"0":"var(--ssd-len)",w=v==="reverse"?"var(--ssd-len)":"0",R=`stroke-dashoffset:${i};`,J=`stroke-dashoffset:${w};`;l&&(R+=`opacity:${v==="reverse"?1:0};`,J+=`opacity:${v==="reverse"?0:1};`);let K=document.createElement("style");K.setAttribute("data-svg-scroll-draw",""),K.textContent=`@keyframes ${o}{from{${R}}to{${J}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${ct[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(K);function se(c,S){c.style.setProperty("--ssd-len",String(M[S])),c.style.strokeDasharray=`${M[S]}`,c.style.strokeDashoffset="",c.style.opacity="",c.style.animationPlayState="",c.classList.add(o);}O.forEach(se);let y=false,P=-1;function k(){if(P>=0)return P;let c=e.getBoundingClientRect(),{tStart:S,tEnd:D}=Se({top:c.top,height:c.height},De(),tt(),Ie,Me);return ae(ee(De(),S,D,f))}return {destroy(){O.forEach(c=>{c.classList.remove(o),c.style.removeProperty("--ssd-len"),c.style.animationPlayState="";}),K.remove();},replay(){y=false,P=-1,O.forEach(se);},pause(){y=true,O.forEach(c=>{c.style.animationPlayState="paused";});},resume(){y&&(y=false,O.forEach(c=>{c.style.animationPlayState="running";}));},seek(c){let S=Math.min(1,Math.max(0,c));P=S,y=true,O.forEach((D,$e)=>{D.classList.remove(o),D.style.strokeDashoffset=v==="reverse"?`${M[$e]*S}`:`${M[$e]*(1-S)}`,l&&(D.style.opacity=v==="reverse"?`${1-S}`:`${S}`);});},getProgress(){return k()}}}if(bt())return wt();function vt(){let o=Math.max(1,re),i=0,w=0;function R(k){let c=true;if(ue){let S=Math.min(1,Math.max(0,k/o)),D=ae(S);Te=D,e.style.setProperty("--scroll-draw-progress",String(D)),e.style.clipPath=B(v==="reverse"?1-D:D),d?.(D),S<1&&(c=false);}else O.forEach((S,D)=>{let $e=D*H*o,ke=Math.min(1,Math.max(0,(k-$e)/o)),fe=ae(ke);S.style.strokeDashoffset=v==="reverse"?`${M[D]*fe}`:`${M[D]*(1-fe)}`,l&&(S.style.opacity=v==="reverse"?`${1-fe}`:`${fe}`),s&&u?S.style.stroke=Ce(s,u,fe):u&&(S.style.stroke=u),N!==null&&I!==null?S.style.strokeWidth=`${N+(I-N)*fe}`:I!==null&&(S.style.strokeWidth=`${I}`),V!==null&&G!==null?S.style.fillOpacity=`${V+(G-V)*fe}`:G!==null&&(S.style.fillOpacity=`${G}`),L&&S.tagName.toLowerCase()==="path"&&oe[D]&&S.setAttribute("d",Ze(oe[D],L,fe)),D===0&&(d?.(fe),e.style.setProperty("--scroll-draw-progress",String(fe))),ke<1&&(c=false);});if(C){let S=Math.min(1,Math.max(0,k/o)),D=ae(S);for(let $e in C){let ke=parseFloat($e);D>=ke&&!Ee.has(ke)&&(Ee.add(ke),C[$e]?.());}}return c}function J(k){if(Z)return;let c=k-i;ce||(ce=true,q?.());let S=R(c);if(S&&!X){X=true,R(o*(1+Math.max(0,O.length-1)*H)),U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{i=performance.now(),ce=false,X=false,Ee.clear(),He(),W=requestAnimationFrame(J);},Y));return}S||(W=requestAnimationFrame(J));}function K(){cancelAnimationFrame(W),clearTimeout(ve),i=performance.now(),w=0,Z=false,ce=false,X=false,ye=0,Ee.clear(),He(),W=requestAnimationFrame(J);}let se=new IntersectionObserver(k=>{k.forEach(c=>{c.isIntersecting&&!(_&&X)?K():!c.isIntersecting&&!_&&!X&&(cancelAnimationFrame(W),clearTimeout(ve),i=null);});},{root:z??null,threshold:de,rootMargin:be}),y;function P(){clearTimeout(y),y=setTimeout(()=>{O.forEach((k,c)=>{M[c]=Ve(k),k.style.strokeDasharray=`${M[c]}`;});},150);}return window.addEventListener("resize",P),window.addEventListener("orientationchange",P),E>0?setTimeout(()=>se.observe(e),E):se.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ve),se.disconnect(),window.removeEventListener("resize",P),window.removeEventListener("orientationchange",P),clearTimeout(y);},replay(){ye=0,K();},pause(){Z||(Z=true,w=performance.now()-i,cancelAnimationFrame(W));},resume(){Z&&(Z=false,i=performance.now()-w,W=requestAnimationFrame(J));},seek(k){let c=Math.min(1,Math.max(0,k));Te=c,Z=true,w=c*o,i=performance.now()-w,cancelAnimationFrame(W),R(w);},getProgress(){return Te}}}if(ge)return vt();rt();function qe(){if(!Fe||Z)return;let o=performance.now(),i=De(),w=f;if(te!==false){let y=o-et,P=y>0?Math.abs(i-(Re<0?i:Re))/y:0;w=f*Math.max(.2,1+P*(typeof te=="number"?te:1)*.04);}Re=i,et=o;let R=g?Ne===-1||i>=Ne?"forward":"reverse":v;Ne=i;let J=we-le,K=true,se=J===0?0:(i-le)/J;if(isNaN(Pe)||(Pe<=0&&se>0?xe?.():Pe>0&&se<=0&&Ae?.(),Pe<1&&se>=1?Oe?.():Pe>=1&&se<1&&Le?.()),Pe=se,ue){let y=ae(ee(i,le,we,w));_&&!g&&(me=Math.max(me,y),y=me),Te=y,e.style.setProperty("--scroll-draw-progress",String(y));let P=R==="reverse"?1-y:y;e.style.clipPath=B(P),d?.(y),!ce&&ee(i,le,we,w)>0&&(ce=true,q?.()),y>=1&&!X?(X=true,U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{me=-1,ce=false,X=false,e.style.clipPath=B(0);},Y))):y<1&&!_&&(X=false),W=requestAnimationFrame(qe);return}if(O.forEach((y,P)=>{let k=P*H*J,c=ae(ee(i,le+k,we+k,w));_&&!g&&(me=Math.max(me,c),c=me),Te=c,y.style.strokeDashoffset=R==="reverse"?`${M[P]*c}`:`${M[P]*(1-c)}`,l&&(y.style.opacity=R==="reverse"?`${1-c}`:`${c}`),s&&u?y.style.stroke=Ce(s,u,c):u&&(y.style.stroke=u),N!==null&&I!==null?y.style.strokeWidth=`${N+(I-N)*c}`:I!==null&&(y.style.strokeWidth=`${I}`),V!==null&&G!==null?y.style.fillOpacity=`${V+(G-V)*c}`:G!==null&&(y.style.fillOpacity=`${G}`),L&&y.tagName.toLowerCase()==="path"&&oe[P]&&y.setAttribute("d",Ze(oe[P],L,c)),P===0&&(d?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(K=false);}),C){let y=ae(ee(i,le,we,w));for(let P in C){let k=parseFloat(P);y>=k&&!Ee.has(k)&&(Ee.add(k),C[P]?.());}}!ce&&ee(i,le,we,w)>0&&(ce=true,q?.()),K&&!X?(X=true,U?.(),ye<(ie==="infinite"?1/0:ie??0)&&(ye++,ve=setTimeout(()=>{me=-1,ce=false,X=false,Ee.clear(),He();},Y))):!K&&!_&&(X=false),W=requestAnimationFrame(qe);}let Xe=new IntersectionObserver(o=>{o.forEach(i=>{Fe=i.isIntersecting,Fe&&!Z?W=requestAnimationFrame(qe):cancelAnimationFrame(W);});},{root:z??null,threshold:de,rootMargin:be}),Ye;function ze(){clearTimeout(Ye),Ye=setTimeout(()=>{O.forEach((o,i)=>{M[i]=Ve(o),o.style.strokeDasharray=`${M[i]}`;}),rt();},150);}return window.addEventListener("resize",ze),window.addEventListener("orientationchange",ze),E>0?setTimeout(()=>Xe.observe(e),E):Xe.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(ve),Xe.disconnect(),window.removeEventListener("resize",ze),window.removeEventListener("orientationchange",ze),clearTimeout(Ye),je?.remove();},replay(){me=-1,Ne=-1,Re=-1,ce=false,X=false,ye=0,Z=false,Ee.clear(),clearTimeout(ve),He();},pause(){Z=true,cancelAnimationFrame(W);},resume(){Z&&(Z=false,Fe&&(W=requestAnimationFrame(qe)));},seek(o){let i=Math.min(1,Math.max(0,o));Te=i,me=i,Z=true,cancelAnimationFrame(W),ht(i,v);},getProgress(){return Te}}}var mt=new Map;function Be(e,t){mt.set(e,t);}function We(e){mt.delete(e);}function Mt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function ft(e){let t=[],r=/([\w]+)\(([^)]*)\)/g,n;for(;(n=r.exec(e))!==null;){let m=[],a=[],h=n[2].trim();if(h)for(let f of h.split(/[\s,]+/)){let l=f.match(/^([-+]?[\d.eE]+)(.*)$/);m.push(l?parseFloat(l[1]):0),a.push(l?l[2]:"");}t.push({fn:n[1],nums:m,units:a});}return t}function Pt(e,t,r){let n=ft(e),m=ft(t);return n.length===0||n.length!==m.length?r<1?e:t:n.map((a,h)=>{let f=m[h];return a.fn!==f.fn||a.nums.length!==f.nums.length?r<1?`${a.fn}(${a.nums.map((l,p)=>`${l}${a.units[p]}`).join(", ")})`:`${f.fn}(${f.nums.map((l,p)=>`${l}${f.units[p]}`).join(", ")})`:`${a.fn}(${a.nums.map((l,p)=>`${l+(f.nums[p]-l)*r}${a.units[p]}`).join(", ")})`}).join(" ")}function pt(e,t,r){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*r);let n=String(e),m=String(t);if(Mt(n))return Ce(n,m,r);if(n.includes("("))return Pt(n,m,r);let a=n.match(/^([-+]?[\d.]+)(.*)$/),h=m.match(/^([-+]?[\d.]+)(.*)$/);if(a&&h){let f=parseFloat(a[1]),l=parseFloat(h[1]);return `${f+(l-f)*r}${a[2]||h[2]}`}return r<1?n:m}function kt(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var dt={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Ct=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Lt=0;function It(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function gt(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:n,trigger:m={},easing:a="ease-out",speed:h=1,once:f=false,axis:l="y",scrollContainer:p,native:T=true,onProgress:H,onComplete:v,onEnter:_,onLeave:pe,onEnterBack:x,onLeaveBack:$}=t,g=window.matchMedia("(prefers-reduced-motion: reduce)").matches,E=typeof a=="function"?a:Q[a]??Q["ease-out"],b=he(m.start??"top bottom"),F=he(m.end??"bottom top"),A=typeof p=="string"?document.querySelector(p):p??null,C=Object.entries(n).map(([s,u])=>({prop:kt(s),from:Array.isArray(u)?u[0]:"",to:Array.isArray(u)?u[1]:u}));function te(){let s=window.getComputedStyle(e);for(let u of C)u.from===""&&(u.from=s.getPropertyValue(u.prop).trim()||"0");}function de(){for(let s of C)e.style.setProperty(s.prop,String(s.to));}if(g)return de(),v?.(),r;te();function be(){if(!T||!It()||typeof a!="string"||!(a in dt)||l!=="y"||A||f||h!==1||H||v||_||pe||x||$||(m.start??"top bottom").trim()!=="top bottom"||(m.end??"bottom top").trim()!=="bottom top")return false;for(let s of C)if(!Ct.has(s.prop))return false;return true}function ie(){let s=`ssd-a-${++Lt}`,u=C.map(B=>`${B.prop}:${B.from}`).join(";"),N=C.map(B=>`${B.prop}:${B.to}`).join(";"),I=document.createElement("style");I.setAttribute("data-ssd-animate",""),I.textContent=`@keyframes ${s}{from{${u}}to{${N}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${dt[a]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(I),e.classList.add(s);let V=()=>l==="x"?window.scrollX:window.scrollY,G=()=>l==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(s),I.remove();},replay(){e.classList.remove(s),e.offsetWidth,e.classList.add(s);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(B){let O=Math.min(1,Math.max(0,B));e.classList.remove(s);for(let M of C)e.style.setProperty(M.prop,pt(M.from,M.to,O));},getProgress(){let B=e.getBoundingClientRect(),O=V(),M=G(),{tStart:oe,tEnd:le}=Se({top:B.top,height:B.height},O,M,b,F);return E(ee(O,oe,le,h))}}}if(be())return ie();let Y=0,L=0,j=0,ge=false,re=false,ne=-1,d=0,q=false,U=NaN,xe=()=>A?l==="x"?A.scrollLeft:A.scrollTop:l==="x"?window.scrollX:window.scrollY,Oe=()=>A?l==="x"?A.clientWidth:A.clientHeight:l==="x"?window.innerWidth:window.innerHeight;function Le(){let s=e.getBoundingClientRect(),u,N;if(A){let V=A.getBoundingClientRect();u=l==="x"?s.left-V.left+A.scrollLeft:s.top-V.top+A.scrollTop,N=l==="x"?s.width:s.height;}else u=l==="x"?s.left:s.top,N=l==="x"?s.width:s.height;let I=Se({top:u,height:N},xe(),Oe(),b,F);Y=I.tStart,L=I.tEnd;}function Ae(s){e.style.setProperty("--scroll-draw-progress",String(s));for(let u of C)e.style.setProperty(u.prop,pt(u.from,u.to,s));H?.(s);}function ue(s){if(isNaN(U)){U=s;return}U<=0&&s>0?_?.():U>0&&s<=0&&$?.(),U<1&&s>=1?pe?.():U>=1&&s<1&&x?.(),U=s;}function ae(){if(!ge||re)return;let s=L===Y?0:(xe()-Y)/(L-Y);ue(s);let u=E(ee(xe(),Y,L,h));f&&(ne=Math.max(ne,u),u=ne),d=u,Ae(u),u>=1&&!q?(q=true,v?.()):u<1&&!f&&(q=false),j=requestAnimationFrame(ae);}Le();{let s=E(ee(xe(),Y,L,h));f&&s>0&&(ne=s),d=s,Ae(s);}let Ie=new IntersectionObserver(s=>{s.forEach(u=>{ge=u.isIntersecting,ge&&!re?j=requestAnimationFrame(ae):cancelAnimationFrame(j);});},{root:A??null}),Me;function z(){clearTimeout(Me),Me=setTimeout(Le,150);}return window.addEventListener("resize",z),window.addEventListener("orientationchange",z),Ie.observe(e),Be(e,{type:"animate",getProgress:()=>d,getTrigger:()=>({tStart:Y,tEnd:L})}),{destroy(){cancelAnimationFrame(j),Ie.disconnect(),window.removeEventListener("resize",z),window.removeEventListener("orientationchange",z),clearTimeout(Me),We(e);},replay(){ne=-1,q=false,d=0,re=false,Ae(0);},pause(){re=true,cancelAnimationFrame(j);},resume(){re&&(re=false,ge&&(j=requestAnimationFrame(ae)));},seek(s){let u=Math.min(1,Math.max(0,s));d=u,ne=u,re=true,cancelAnimationFrame(j),Ae(u);},getProgress(){return d}}}var _e={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Dt(e,t){if(typeof window>"u")return _e;let r=typeof e=="string"?document.querySelector(e):e;return r?gt(r,t):(process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollAnimate: element not found:",e),_e)}function Ot(e,t={}){if(typeof window>"u")return _e;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollParallax: element not found:",e),_e;let{speed:n=.3,axis:m="y",easing:a="linear",trigger:h,onProgress:f}=t,l=r.getBoundingClientRect(),p=m==="x"?l.width:l.height,T=n*p;return gt(r,{props:m==="x"?{transform:["translateX(0px)",`translateX(${-T}px)`]}:{transform:["translateY(0px)",`translateY(${-T}px)`]},trigger:h??{start:"top bottom",end:"bottom top"},easing:a,native:false,onProgress:f})}var Je={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ft(e,t){if(typeof window>"u")return Je;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollCounter: element not found:",e),Je;let n=r,{from:m=0,to:a,format:h,easing:f="ease-out",trigger:l={},once:p=true,decimals:T,onComplete:H}=t,v=T!==void 0?d=>d.toFixed(T):h??(d=>String(Math.round(d))),_=typeof f=="function"?f:Q[f]??Q["ease-out"],pe=he(l.start??"top 80%"),x=he(l.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=v(a),H?.(),Je;n.textContent=v(m);let g=0,E=0,b=0,F=false,A=false,C=-1,te=0,de=false,be=()=>window.scrollY,ie=()=>window.innerHeight;function Y(){let d=n.getBoundingClientRect(),q=Se({top:d.top,height:d.height},be(),ie(),pe,x);g=q.tStart,E=q.tEnd;}function L(d){n.textContent=v(m+(a-m)*d),n.style.setProperty("--scroll-draw-progress",String(d));}function j(){if(!F||A)return;let d=_(ee(be(),g,E,1));p&&(C=Math.max(C,d),d=C),te=d,L(d),d>=1&&!de?(de=true,H?.()):d<1&&!p&&(de=false),b=requestAnimationFrame(j);}Y();{let d=_(ee(be(),g,E,1));p&&d>0&&(C=d),te=d,L(d);}let ge=new IntersectionObserver(d=>{d.forEach(q=>{F=q.isIntersecting,F&&!A?b=requestAnimationFrame(j):cancelAnimationFrame(b);});}),re;function ne(){clearTimeout(re),re=setTimeout(Y,150);}return window.addEventListener("resize",ne),window.addEventListener("orientationchange",ne),ge.observe(n),Be(n,{type:"counter",getProgress:()=>te,getTrigger:()=>({tStart:g,tEnd:E})}),{destroy(){cancelAnimationFrame(b),ge.disconnect(),window.removeEventListener("resize",ne),window.removeEventListener("orientationchange",ne),clearTimeout(re),We(n);},replay(){C=-1,de=false,te=0,A=false,L(0);},pause(){A=true,cancelAnimationFrame(b);},resume(){A&&(A=false,F&&(b=requestAnimationFrame(j)));},seek(d){let q=Math.min(1,Math.max(0,d));te=q,C=q,A=true,cancelAnimationFrame(b),L(q);},getProgress(){return te}}}var yt="http://www.w3.org/2000/svg",Nt="cinematic-photo",Ke=e=>e<0?0:e>1?1:e;function Ge(e){let t=parseFloat(e);return Number.isFinite(t)?Ke(t/100):0}function Rt(e){return Q[e]??Q.linear}var Ht={destroy:()=>{},getProgress:()=>0},Qe=class{constructor(t){if(typeof document>"u"){this.mount=null;return}this.mount=typeof t.wrapper=="string"?document.querySelector(t.wrapper):t.wrapper,!this.mount&&process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] Cinematic: wrapper not found:",t.wrapper);}loadStory(t){let r=this.mount;if(typeof window>"u"||!r)return Ht;r.style.position="relative",r.style.height=t.totalHeight,r.style.display="block";let n=document.createElement("div");n.setAttribute("data-cinematic-stage",""),n.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",r.appendChild(n);let m=[];for(let x of t.scenes){if(x.background){let g=document.createElement("img");g.id=Nt,g.src=x.background,g.alt="",g.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(g);}let $=x.animations.filter(g=>g.type==="draw");if($.length){let g=document.createElementNS(yt,"svg");g.setAttribute("viewBox",`0 0 ${t.canvas.width} ${t.canvas.height}`),g.setAttribute("preserveAspectRatio","xMidYMid meet"),g.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(g);for(let E of $){let b=document.createElementNS(yt,"path");b.id=E.target.replace(/^#/,""),b.setAttribute("d",E.d),b.setAttribute("fill","none"),b.setAttribute("stroke",E.stroke),b.setAttribute("stroke-width",String(E.strokeWidth)),b.setAttribute("stroke-linecap","round"),b.setAttribute("stroke-linejoin","round");let F=E.length||b.getTotalLength?.()||0;b.style.strokeDasharray=String(F),b.style.strokeDashoffset=String(F),g.appendChild(b),m.push({kind:"draw",el:b,start:Ge(E.start),end:Ge(E.end),ease:Rt(E.easing),length:F});}}for(let g of x.animations){if(g.type!=="fade")continue;let E=n.querySelector(g.target)??document.querySelector(g.target);E&&(E.style.opacity=String(g.from),m.push({kind:"fade",el:E,start:Ge(g.start),end:Ge(g.end),ease:Q["ease-in-out"]??Q.linear,from:g.from,to:g.to}));}}let a=0,h=()=>{let x=r.offsetHeight-window.innerHeight;return x<=0?r.getBoundingClientRect().top<=0?1:0:Ke(-r.getBoundingClientRect().top/x)},f=x=>{for(let $ of m){let g=$.end-$.start,E=g<=0?x>=$.end?1:0:Ke((x-$.start)/g),b=$.ease(E);$.kind==="draw"?$.el.style.strokeDashoffset=String($.length*(1-b)):$.el.style.opacity=String($.from+($.to-$.from)*b);}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return f(1),{destroy:()=>{},getProgress:()=>1};let l=0,p=false,T=false,H=()=>{a=h(),f(a),p&&(l=requestAnimationFrame(H));},v=()=>{p||(p=true,l=requestAnimationFrame(H));},_=()=>{p=false,cancelAnimationFrame(l);},pe=new IntersectionObserver(x=>{for(let $ of x)T=$.isIntersecting,T?v():_();},{threshold:0});return pe.observe(n),a=h(),f(a),{destroy(){_(),pe.disconnect();},getProgress:()=>a}}};function er(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let n=typeof e=="string"?document.querySelector(e):e;return n?ut(n,t):(console.warn("[svg-scroll-draw] Container not found:",e),r)}
4
- export{Qe as Cinematic,Ue as PRESETS,it as createBounce,at as createElastic,Et as createSpring,Dt as scrollAnimate,Ft as scrollCounter,er as scrollDraw,Ot as scrollParallax};
1
+ function Ft({tension:e=2.5,friction:t=2.2}={}){return r=>1-Math.cos(r*Math.PI*e)*Math.pow(1-r,t)}function vt({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,t)),l=Math.sqrt(n),a=0,d=[];for(let f=0;f<r;f++){let E=Math.pow(l,f);d.push(E),a+=E;}let m=[0],c=0;for(let f=0;f<r;f++)c+=d[f]/a,m.push(c);return f=>{if(f<=0)return 0;if(f>=1)return 1;for(let E=0;E<r;E++)if(f<=m[E+1]){let I=(f-m[E])/(m[E+1]-m[E]);if(E===0)return I*(2-I);let T=1-Math.pow(n,E);return T+(1-T)*(2*I-1)*(2*I-1)}return 1}}function St({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),n=Math.max(.1,t),l=r<=1?n/4:n/(2*Math.PI)*Math.asin(1/r);return a=>a<=0?0:a>=1?1:r*Math.pow(2,-10*a)*Math.sin((a-l)*(2*Math.PI)/n)+1}var J={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,spring:e=>1-Math.cos(e*Math.PI*2.5)*Math.pow(1-e,2.2),bounce:vt(),elastic:St()};function $e(e="top bottom"){let t=e.trim();if(/^\d+(\.\d+)?%$/.test(t))return {element:"top",viewport:t};let[r="top",n="bottom"]=t.split(/\s+/).filter(Boolean);return {element:r,viewport:n}}function ht(e,t,r,n){switch(n){case "top":return e+r;case "center":return e+r+t/2;case "bottom":return e+r+t;default:return e+r}}function bt(e,t){if(/^\d+(\.\d+)?%$/.test(e))return t*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return t/2;case "bottom":return t;default:return t}}function He(e){let t=e.tagName.toLowerCase();if(t==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),n=parseFloat(e.getAttribute("height")??"0");return 2*(r+n)}if(t==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function Nt(e,t,r){return Math.min(r,Math.max(t,e))}function ie(e,t,r,n){return r===t?0:Nt((e-t)/(r-t)*n,0,1)}function Xe(e,t,r){let n=e.getBoundingClientRect(),l=r==="x"?n.width:n.height;return t?{top:r==="x"?n.left-t.getBoundingClientRect().left+t.scrollLeft:n.top-t.getBoundingClientRect().top+t.scrollTop,height:l,scroll:0}:{top:r==="x"?n.left:n.top,height:l,scroll:r==="x"?window.scrollX:window.scrollY}}function Oe(e,t,r,n,l){let a=ht(e.top,e.height,t,n.element)-bt(n.viewport,r),d=ht(e.top,e.height,t,l.element)-bt(l.viewport,r);return {tStart:a,tEnd:d}}function wt(e){let t=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(t)return [parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];let r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(r)return [parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)];let n=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return n?[parseInt(n[1]),parseInt(n[2]),parseInt(n[3])]:null}function _e(e,t,r){let n=wt(e),l=wt(t);return !n||!l?e:`rgb(${Math.round(n[0]+(l[0]-n[0])*r)},${Math.round(n[1]+(l[1]-n[1])*r)},${Math.round(n[2]+(l[2]-n[2])*r)})`}var st={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:false},reveal:{easing:"ease-out",fade:true,speed:1.2,once:true},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:true,speed:.75},spring:{easing:"spring",speed:1.1}};var Ye=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function K(e,...t){Ye&&console.warn(`[svg-scroll-draw] ${e}`,...t);}var Ht="cubic-bezier(0.333333, 0, 0.666667, 0.333333)",_t="cubic-bezier(0.333333, 0.666667, 0.666667, 1)",Et=33;function zt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function: linear(0, 1)")}function Vt(e){let t=[];for(let r=0;r<Et;r++){let n=r/(Et-1);t.push(String(Math.round(e(n)*1e5)/1e5));}return `linear(${t.join(",")})`}function Qe(e){switch(e){case "linear":return "linear";case "ease-in":return Ht;case "ease-out":return _t;case "ease-in-out":return zt()?Vt(J["ease-in-out"]):null;default:return null}}var qt=0;function Wt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")&&CSS.supports("view-timeline-name: --x")}function Bt(e){let t=e.getAttribute("stroke"),r=e.getAttribute("fill");!t||t==="none"?K("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&K("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Gt(e,t,r){let n=document.createElement("div");n.setAttribute("data-svg-scroll-draw-debug",""),n.style.cssText="position:fixed;pointer-events:none;z-index:9999;font-family:monospace;font-size:11px;top:0;left:0;right:0;bottom:0;";function l(){let a=r==="x"?window.scrollX:window.scrollY,d=e-a,m=t-a,c=r==="x";n.innerHTML=`
2
+ <div style="position:absolute;${c?`left:${d}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${d}px;left:0;right:0;border-top:2px dashed #22c55e;`}padding:2px 6px;color:#22c55e;background:rgba(0,0,0,.6)">\u25B6 start</div>
3
+ <div style="position:absolute;${c?`left:${m}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${m}px;left:0;right:0;border-top:2px dashed #ef4444;`}padding:2px 6px;color:#ef4444;background:rgba(0,0,0,.6)">\u25A0 end</div>`;}return document.body.appendChild(n),window.addEventListener("scroll",l,{passive:true}),l(),{el:n,destroy(){window.removeEventListener("scroll",l),n.remove();}}}var xt=/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,Tt=/[MmLlHhVvCcSsQqTtAaZz]/g;function jt(e,t,r){if(!Ye)return;let n=(e.match(Tt)??[]).join("").toUpperCase(),l=(t.match(Tt)??[]).join("").toUpperCase(),a=(e.match(xt)??[]).length,d=(t.match(xt)??[]).length;if(n!==l){K(`morphTo: command sequence differs (${n||"\u2205"} \u2192 ${l||"\u2205"}). Interpolation is coordinate-for-coordinate, so the result will not reach the target shape. Redraw both paths with the same commands.`,r);return}a!==d&&K(`morphTo: coordinate count differs (${a} \u2192 ${d}). Extra coordinates are ignored and missing ones hold their start value, so the result will not reach the target shape.`,r);}function it(e,t,r){let n=(t.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),l=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,a=>{let d=parseFloat(a),m=n[l++]??d;return String(+(d+(m-d)*r).toFixed(4))})}function At(e,t={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...n}=t,l=r?{...st[r],...n}:n,a=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:d="path, polyline, line, polygon, rect, circle",speed:m=1,fade:c=false,easing:f="linear",trigger:E={},stagger:I=0,direction:T="forward",once:ee=false,debug:Ee=false,axis:A="y",scrollContainer:$,autoReverse:g=false,delay:S=0,strokeColor:h,strokeWidth:V,fillOpacity:F,waypoints:B,velocityScale:te=false,threshold:de=0,rootMargin:j="0px",repeat:q=0,repeatDelay:Me=0,morphTo:N,clip:ge,autoplay:Pe=false,duration:ke=1e3,native:Le=true,onProgress:b,onStart:P,onComplete:oe,onEnter:ye,onLeave:Re,onEnterBack:he,onLeaveBack:xe}=l,re=ge===true?"left":typeof ge=="string"?ge:false,ue=typeof f=="function"?f:J[f]??J.linear,be=$e(E.start??"top bottom"),Fe=$e(E.end??"bottom top"),ae=typeof $=="string"?document.querySelector($):$??null,le=Array.isArray(h)?h[0]:null,U=Array.isArray(h)?h[1]:typeof h=="string"?h:null,X=Array.isArray(V)?V[0]:null,H=Array.isArray(V)?V[1]:typeof V=="number"?V:null,ne=Array.isArray(F)?F[0]:null,W=Array.isArray(F)?F[1]:typeof F=="number"?F:null;function we(o){let i=o*100;switch(re){case "right":return `inset(0 0 0 ${100-i}%)`;case "top":return `inset(0 0 ${100-i}% 0)`;case "bottom":return `inset(${100-i}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-i}% 0 0)`}}let C=re?[]:Array.from(e.querySelectorAll(d)),x=[],s=[],u=0,ce=0,k=false,D=false,O=0,_=false,Y=-1,ve=-1,G=false,me=0,Te=0,Ce,tt=null;function ut(){tt?.destroy(),tt=null;}let Ie=new Set,mt=NaN,De=true,qe=-1,ft=performance.now(),Ne=NaN;function rt(){return ae?A==="x"?ae.scrollLeft:ae.scrollTop:A==="x"?window.scrollX:window.scrollY}function pt(){return ae?A==="x"?ae.clientWidth:ae.clientHeight:A==="x"?window.innerWidth:window.innerHeight}function dt(){let o=Xe(e,ae,A),i=Oe(o,o.scroll,pt(),be,Fe);u=i.tStart,ce=i.tEnd,Ee&&Ye&&(ut(),tt=Gt(u,ce,A));}function It(o,i){if(e.style.setProperty("--scroll-draw-progress",String(o)),re){let w=i==="reverse"?1-o:o;e.style.clipPath=we(w);return}C.forEach((w,Q)=>{w.style.strokeDashoffset=i==="reverse"?`${x[Q]*o}`:`${x[Q]*(1-o)}`,c&&(w.style.opacity=i==="reverse"?`${1-o}`:`${o}`),le&&U?w.style.stroke=_e(le,U,o):U&&(w.style.stroke=U),X!==null&&H!==null?w.style.strokeWidth=`${X+(H-X)*o}`:H!==null&&(w.style.strokeWidth=`${H}`),ne!==null&&W!==null?w.style.fillOpacity=`${ne+(W-ne)*o}`:W!==null&&(w.style.fillOpacity=`${W}`),N&&w.tagName.toLowerCase()==="path"&&s[Q]&&w.setAttribute("d",it(s[Q],N,o));});}function We(){if(e.style.setProperty("--scroll-draw-progress","0"),re){e.style.clipPath=we(0);return}C.forEach((o,i)=>{o.style.strokeDasharray=`${x[i]}`,o.style.strokeDashoffset=T==="reverse"?"0":`${x[i]}`,c?o.style.opacity=T==="reverse"?"1":"0":o.style.opacity="",le&&(o.style.stroke=le),X!==null&&(o.style.strokeWidth=`${X}`),ne!==null&&(o.style.fillOpacity=`${ne}`),N&&o.tagName.toLowerCase()==="path"&&s[i]&&o.setAttribute("d",s[i]);});}if(C.forEach(o=>{Bt(o);let i=He(o);x.push(i);let w=o.tagName.toLowerCase()==="path";w?s.push(o.getAttribute("d")??""):s.push(""),N&&(w?jt(s[s.length-1],N,o):K(`morphTo only applies to <path> elements \u2014 ignored on <${o.tagName}>.`,o)),a?(o.style.strokeDasharray=`${i}`,o.style.strokeDashoffset=T==="reverse"?`${i}`:"0",c&&(o.style.opacity="1"),U&&(o.style.stroke=U),H!==null&&(o.style.strokeWidth=`${H}`),W!==null&&(o.style.fillOpacity=`${W}`),N&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",N)):(o.style.strokeDasharray=`${i}`,o.style.strokeDashoffset=T==="reverse"?"0":`${i}`,c?o.style.opacity=T==="reverse"?"1":"0":o.style.opacity="",le&&(o.style.stroke=le),X!==null&&(o.style.strokeWidth=`${X}`),ne!==null&&(o.style.fillOpacity=`${ne}`));}),re){if(a)return e.style.clipPath=we(1),oe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=we(0);}else if(a)return oe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};let gt=typeof f=="string"?Qe(f):null;function Dt(){return !(Le===false||!Wt()||!C.length||!gt||re||A!=="y"||ae||m!==1||I!==0||ee||g||te!==false||N||B||q||S>0||b||P||oe||ye||Re||he||xe||h!=null||V!=null||F!=null||(E.start??"top bottom").trim()!=="top bottom"||(E.end??"bottom top").trim()!=="bottom top")}function Ot(){let o=++qt,i=`svg-scroll-draw-${o}`,w=`svg-scroll-draw-host-${o}`,Q=`--svg-scroll-draw-${o}`,Ae=T==="reverse"?"0":"var(--ssd-len)",Se=T==="reverse"?"var(--ssd-len)":"0",pe=`stroke-dashoffset:${Ae};`,v=`stroke-dashoffset:${Se};`;c&&(pe+=`opacity:${T==="reverse"?1:0};`,v+=`opacity:${T==="reverse"?0:1};`);let M=document.createElement("style");M.setAttribute("data-svg-scroll-draw",""),M.textContent=`@keyframes ${i}{from{${pe}}to{${v}}}.${w}{view-timeline-name:${Q};view-timeline-axis:block;}.${i}{animation-name:${i};animation-duration:auto;animation-timing-function:${gt};animation-fill-mode:both;animation-timeline:${Q};animation-range:cover 0% cover 100%;}`,document.head.appendChild(M),e.classList.add(w);function Z(p,z){p.style.setProperty("--ssd-len",String(x[z])),p.style.strokeDasharray=`${x[z]}`,p.style.strokeDashoffset="",p.style.opacity="",p.style.animationPlayState="",p.classList.add(i);}C.forEach(Z);let y=false,L=-1;function R(){if(L>=0)return L;let p=e.getBoundingClientRect(),{tStart:z,tEnd:fe}=Oe({top:p.top,height:p.height},rt(),pt(),be,Fe);return ue(ie(rt(),z,fe,m))}return {destroy(){e.classList.remove(w),C.forEach(p=>{p.classList.remove(i),p.style.removeProperty("--ssd-len"),p.style.animationPlayState="";}),M.remove();},replay(){y=false,L=-1,C.forEach(Z);},pause(){y=true,C.forEach(p=>{p.style.animationPlayState="paused";});},resume(){y&&(y=false,C.forEach(p=>{p.style.animationPlayState="running";}));},seek(p){let z=Math.min(1,Math.max(0,p));L=z,y=true,C.forEach((fe,se)=>{fe.classList.remove(i),fe.style.strokeDashoffset=T==="reverse"?`${x[se]*z}`:`${x[se]*(1-z)}`,c&&(fe.style.opacity=T==="reverse"?`${1-z}`:`${z}`);});},getProgress(){return R()},refresh(){C.forEach((p,z)=>{x[z]=He(p),p.style.setProperty("--ssd-len",String(x[z])),p.style.strokeDasharray=`${x[z]}`;});}}}if(Dt())return Ot();function Rt(){let o=Math.max(1,ke),i=0,w=0,Q=false;function Ae(y){let L=true;if(re){let R=Math.min(1,Math.max(0,y/o)),p=ue(R);me=p,e.style.setProperty("--scroll-draw-progress",String(p)),e.style.clipPath=we(T==="reverse"?1-p:p),b?.(p),R<1&&(L=false);}else C.forEach((R,p)=>{let z=p*I*o,fe=Math.min(1,Math.max(0,(y-z)/o)),se=ue(fe);R.style.strokeDashoffset=T==="reverse"?`${x[p]*se}`:`${x[p]*(1-se)}`,c&&(R.style.opacity=T==="reverse"?`${1-se}`:`${se}`),le&&U?R.style.stroke=_e(le,U,se):U&&(R.style.stroke=U),X!==null&&H!==null?R.style.strokeWidth=`${X+(H-X)*se}`:H!==null&&(R.style.strokeWidth=`${H}`),ne!==null&&W!==null?R.style.fillOpacity=`${ne+(W-ne)*se}`:W!==null&&(R.style.fillOpacity=`${W}`),N&&R.tagName.toLowerCase()==="path"&&s[p]&&R.setAttribute("d",it(s[p],N,se)),p===0&&(me=se,b?.(se),e.style.setProperty("--scroll-draw-progress",String(se))),fe<1&&(L=false);});if(B){let R=Math.min(1,Math.max(0,y/o)),p=ue(R);for(let z in B){let fe=parseFloat(z);p>=fe&&!Ie.has(fe)&&(Ie.add(fe),B[z]?.());}}return L}function Se(y){if(G)return;let L=y-i;D||(D=true,P?.());let R=Ae(L);if(R&&!k){k=true,Ae(o*(1+Math.max(0,C.length-1)*I)),oe?.(),Te<(q==="infinite"?1/0:q??0)&&(Te++,Ce=setTimeout(()=>{i=performance.now(),D=false,k=false,Ie.clear(),We(),O=requestAnimationFrame(Se);},Me));return}R||(O=requestAnimationFrame(Se));}function pe(){cancelAnimationFrame(O),clearTimeout(Ce),i=performance.now(),w=0,G=false,D=false,k=false,Te=0,Q=true,me=0,Ie.clear(),We(),O=requestAnimationFrame(Se);}let v=new IntersectionObserver(y=>{y.forEach(L=>{L.isIntersecting&&!(ee&&k)?pe():!L.isIntersecting&&!ee&&!k&&(cancelAnimationFrame(O),clearTimeout(Ce),Q=false);});},{root:ae??null,threshold:de,rootMargin:j}),M;function Z(){clearTimeout(M),M=setTimeout(()=>{C.forEach((y,L)=>{x[L]=He(y),y.style.strokeDasharray=`${x[L]}`;});},150);}return window.addEventListener("resize",Z),window.addEventListener("orientationchange",Z),S>0?setTimeout(()=>v.observe(e),S):v.observe(e),{destroy(){cancelAnimationFrame(O),clearTimeout(Ce),v.disconnect(),window.removeEventListener("resize",Z),window.removeEventListener("orientationchange",Z),clearTimeout(M);},replay(){Te=0,pe();},pause(){G||!Q||(G=true,w=performance.now()-i,cancelAnimationFrame(O));},resume(){G&&(G=false,Q=true,i=performance.now()-w,O=requestAnimationFrame(Se));},seek(y){let L=Math.min(1,Math.max(0,y));me=L,G=true,w=L*o,i=performance.now()-w,cancelAnimationFrame(O),Ae(w);},getProgress(){return me},refresh(){clearTimeout(M),C.forEach((y,L)=>{x[L]=He(y),y.style.strokeDasharray=`${x[L]}`;});}}}if(Pe)return Rt();dt();function Be(){if(!_||G)return;let o=performance.now(),i=rt();if(!De&&te===false&&i===mt){O=requestAnimationFrame(Be);return}De=false,mt=i;let w=m;if(te!==false){let v=o-ft,M=v>0?Math.abs(i-(qe<0?i:qe))/v:0;w=m*Math.max(.2,1+M*(typeof te=="number"?te:1)*.04);}qe=i,ft=o;let Q=g?ve===-1||i>=ve?"forward":"reverse":T;ve=i;let Ae=ce-u,Se=true,pe=Ae===0?0:(i-u)/Ae;if(isNaN(Ne)||(Ne<=0&&pe>0?ye?.():Ne>0&&pe<=0&&xe?.(),Ne<1&&pe>=1?Re?.():Ne>=1&&pe<1&&he?.()),Ne=pe,re){let v=ue(ie(i,u,ce,w));ee&&!g&&(Y=Math.max(Y,v),v=Y),me=v,e.style.setProperty("--scroll-draw-progress",String(v));let M=Q==="reverse"?1-v:v;e.style.clipPath=we(M),b?.(v),!D&&ie(i,u,ce,w)>0&&(D=true,P?.()),v>=1&&!k?(k=true,oe?.(),Te<(q==="infinite"?1/0:q??0)&&(Te++,Ce=setTimeout(()=>{Y=-1,D=false,k=false,e.style.clipPath=we(0);},Me))):v<1&&!ee&&(k=false),O=requestAnimationFrame(Be);return}if(C.forEach((v,M)=>{let Z=M*I*Ae,y=ue(ie(i,u+Z,ce+Z,w));ee&&!g&&(Y=Math.max(Y,y),y=Y),me=y,v.style.strokeDashoffset=Q==="reverse"?`${x[M]*y}`:`${x[M]*(1-y)}`,c&&(v.style.opacity=Q==="reverse"?`${1-y}`:`${y}`),le&&U?v.style.stroke=_e(le,U,y):U&&(v.style.stroke=U),X!==null&&H!==null?v.style.strokeWidth=`${X+(H-X)*y}`:H!==null&&(v.style.strokeWidth=`${H}`),ne!==null&&W!==null?v.style.fillOpacity=`${ne+(W-ne)*y}`:W!==null&&(v.style.fillOpacity=`${W}`),N&&v.tagName.toLowerCase()==="path"&&s[M]&&v.setAttribute("d",it(s[M],N,y)),M===0&&(b?.(y),e.style.setProperty("--scroll-draw-progress",String(y))),y<1&&(Se=false);}),B){let v=ue(ie(i,u,ce,w));for(let M in B){let Z=parseFloat(M);v>=Z&&!Ie.has(Z)&&(Ie.add(Z),B[M]?.());}}!D&&ie(i,u,ce,w)>0&&(D=true,P?.()),Se&&!k?(k=true,oe?.(),Te<(q==="infinite"?1/0:q??0)&&(Te++,Ce=setTimeout(()=>{Y=-1,D=false,k=false,Ie.clear(),We(),De=true;},Me))):!Se&&!ee&&(k=false),O=requestAnimationFrame(Be);}let nt=false;function Ge(){nt||(nt=true,O=requestAnimationFrame(function(){Be();}));}function je(){nt=false,cancelAnimationFrame(O);}let ot=new IntersectionObserver(o=>{o.forEach(i=>{_=i.isIntersecting,_&&!G?(De=true,Ge()):je();});},{root:ae??null,threshold:de,rootMargin:j});function yt(){C.forEach((o,i)=>{x[i]=He(o),o.style.strokeDasharray=`${x[i]}`;}),dt(),De=true;}let Ue;function ze(){clearTimeout(Ue),Ue=setTimeout(yt,150);}window.addEventListener("resize",ze),window.addEventListener("orientationchange",ze);let Ve;return typeof ResizeObserver<"u"&&(Ve=new ResizeObserver(()=>ze()),Ve.observe(document.body),Ve.observe(document.documentElement),Ve.observe(e)),S>0?setTimeout(()=>ot.observe(e),S):ot.observe(e),{destroy(){cancelAnimationFrame(O),clearTimeout(Ce),je(),ot.disconnect(),Ve?.disconnect(),window.removeEventListener("resize",ze),window.removeEventListener("orientationchange",ze),clearTimeout(Ue),ut();},replay(){Y=-1,ve=-1,qe=-1,D=false,k=false,Te=0,G=false,me=0,Ie.clear(),clearTimeout(Ce),We(),De=true,_&&Ge();},pause(){G=true,je();},resume(){G&&(G=false,De=true,_&&Ge());},seek(o){let i=Math.min(1,Math.max(0,o));me=i,Y=i,G=true,je(),It(i,T),De=true;},getProgress(){return me},refresh(){clearTimeout(Ue),yt(),_&&!G&&Ge();}}}var $t=new Map;function Ze(e,t){$t.set(e,t);}function Je(e){$t.delete(e);}function Ut(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function Mt(e){let t=[],r=/([\w]+)\(([^)]*)\)/g,n;for(;(n=r.exec(e))!==null;){let l=[],a=[],d=n[2].trim();if(d)for(let m of d.split(/[\s,]+/)){let c=m.match(/^([-+]?[\d.eE]+)(.*)$/);l.push(c?parseFloat(c[1]):0),a.push(c?c[2]:"");}t.push({fn:n[1],nums:l,units:a});}return t}function Xt(e,t,r){let n=Mt(e),l=Mt(t);return n.length===0||n.length!==l.length?r<1?e:t:n.map((a,d)=>{let m=l[d];return a.fn!==m.fn||a.nums.length!==m.nums.length?r<1?`${a.fn}(${a.nums.map((c,f)=>`${c}${a.units[f]}`).join(", ")})`:`${m.fn}(${m.nums.map((c,f)=>`${c}${m.units[f]}`).join(", ")})`:`${a.fn}(${a.nums.map((c,f)=>`${c+(m.nums[f]-c)*r}${a.units[f]}`).join(", ")})`}).join(" ")}function Pt(e,t,r){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*r);let n=String(e),l=String(t);if(Ut(n))return _e(n,l,r);if(n.includes("("))return Xt(n,l,r);let a=n.match(/^([-+]?[\d.]+)(.*)$/),d=l.match(/^([-+]?[\d.]+)(.*)$/);if(a&&d){let m=parseFloat(a[1]),c=parseFloat(d[1]);return `${m+(c-m)*r}${a[2]||d[2]}`}return r<1?n:l}function Yt(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var Qt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Zt=0,kt="--scroll-draw-progress";function Jt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Lt(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:n,trigger:l={},easing:a="ease-out",speed:d=1,once:m=false,axis:c="y",scrollContainer:f,native:E=true,velocityScale:I=false,respectReducedMotion:T=true,triggerElement:ee,onProgress:Ee,onComplete:A,onEnter:$,onLeave:g,onEnterBack:S,onLeaveBack:h}=t,V=T&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,F=typeof a=="function"?a:J[a]??J["ease-out"],B=$e(l.start??"top bottom"),te=$e(l.end??"bottom top"),de=ee??e,j=typeof f=="string"?document.querySelector(f):f??null,q=Object.entries(n).map(([s,u])=>({prop:Yt(s),from:Array.isArray(u)?u[0]:"",to:Array.isArray(u)?u[1]:u}));function Me(){let s=window.getComputedStyle(e);for(let u of q)u.from===""&&(u.from=s.getPropertyValue(u.prop).trim()||"0");}function N(){for(let s of q)e.style.setProperty(s.prop,String(s.to));}let ge=new Map;for(let s of [...q.map(u=>u.prop),kt])ge.set(s,e.style.getPropertyValue(s));function Pe(){for(let[s,u]of ge)u?e.style.setProperty(s,u):e.style.removeProperty(s);}if(V)return N(),A?.(),{...r,destroy:Pe,getProgress:()=>1};Me();let ke=typeof a=="string"?Qe(a):null;function Le(){if(!E||!Jt()||!ke||c!=="y"||j||de!==e||m||d!==1||Ee||A||$||g||S||h||I!==false||(l.start??"top bottom").trim()!=="top bottom"||(l.end??"bottom top").trim()!=="bottom top")return false;for(let s of q)if(!Qt.has(s.prop))return false;return true}function b(){let s=`ssd-a-${++Zt}`,u=q.map(_=>`${_.prop}:${_.from}`).join(";"),ce=q.map(_=>`${_.prop}:${_.to}`).join(";"),k=document.createElement("style");k.setAttribute("data-ssd-animate",""),k.textContent=`@keyframes ${s}{from{${u}}to{${ce}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${ke};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(k),e.classList.add(s);let D=()=>c==="x"?window.scrollX:window.scrollY,O=()=>c==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(s),k.remove(),e.style.animationPlayState="",Pe();},replay(){e.classList.remove(s),e.offsetWidth,e.classList.add(s);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(_){let Y=Math.min(1,Math.max(0,_));e.classList.remove(s);for(let ve of q)e.style.setProperty(ve.prop,Pt(ve.from,ve.to,Y));},getProgress(){let _=e.getBoundingClientRect(),Y=D(),ve=O(),{tStart:G,tEnd:me}=Oe({top:_.top,height:_.height},Y,ve,B,te);return F(ie(Y,G,me,d))}}}if(Le())return b();let P=0,oe=0,ye=0,Re=false,he=false,xe=-1,re=0,ue=false,be=NaN,Fe=-1,ae=0,le=()=>j?c==="x"?j.scrollLeft:j.scrollTop:c==="x"?window.scrollX:window.scrollY,U=()=>j?c==="x"?j.clientWidth:j.clientHeight:c==="x"?window.innerWidth:window.innerHeight;function X(){let s=Xe(de,j,c),u=Oe(s,s.scroll,U(),B,te);P=u.tStart,oe=u.tEnd;}function H(s){e.style.setProperty(kt,String(s));for(let u of q)e.style.setProperty(u.prop,Pt(u.from,u.to,s));Ee?.(s);}function ne(s){if(isNaN(be)){be=s;return}be<=0&&s>0?$?.():be>0&&s<=0&&h?.(),be<1&&s>=1?g?.():be>=1&&s<1&&S?.(),be=s;}function W(){if(!Re||he)return;let s=performance.now(),u=le(),ce=d;if(I!==false){let O=s-ae,_=O>0?Math.abs(u-(Fe<0?u:Fe))/O:0;ce=d*Math.max(.2,1+_*(typeof I=="number"?I:1)*.04);}Fe=u,ae=s;let k=oe===P?0:(u-P)/(oe-P);ne(k);let D=F(ie(u,P,oe,ce));m&&(xe=Math.max(xe,D),D=xe),re=D,H(D),D>=1&&!ue?(ue=true,A?.()):D<1&&!m&&(ue=false),ye=requestAnimationFrame(W);}X(),oe===P&&K("scrollAnimate: the trigger window has zero length (start and end resolve to the same scroll position), so this element will never animate. If the target is inside a position:sticky stage, measure the trigger from the container that holds the scroll room via `triggerElement`.",e);{let s=F(ie(le(),P,oe,d));m&&s>0&&(xe=s),re=s,H(s);}let we=new IntersectionObserver(s=>{s.forEach(u=>{Re=u.isIntersecting,Re&&!he?ye=requestAnimationFrame(W):cancelAnimationFrame(ye);});},{root:j??null}),C;function x(){clearTimeout(C),C=setTimeout(X,150);}return window.addEventListener("resize",x),window.addEventListener("orientationchange",x),we.observe(e),Ze(e,{type:"animate",getProgress:()=>re,getTrigger:()=>({tStart:P,tEnd:oe})}),{destroy(){cancelAnimationFrame(ye),we.disconnect(),window.removeEventListener("resize",x),window.removeEventListener("orientationchange",x),clearTimeout(C),Pe(),Je(e);},replay(){xe=-1,ue=false,re=0,he=false,H(0);},pause(){he=true,cancelAnimationFrame(ye);},resume(){he&&(he=false,Re&&(ye=requestAnimationFrame(W)));},seek(s){let u=Math.min(1,Math.max(0,s));re=u,xe=u,he=true,cancelAnimationFrame(ye),H(u);},getProgress(){return re}}}var Ke={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Kt(e,t){if(typeof window>"u")return Ke;let r=typeof e=="string"?document.querySelector(e):e;return r?Lt(r,t):(K("scrollAnimate: element not found:",e),Ke)}function er(e,t={}){if(typeof window>"u")return Ke;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return K("scrollParallax: element not found:",e),Ke;let{speed:n=.3,axis:l="y",easing:a="linear",trigger:d,onProgress:m}=t,c=r.getBoundingClientRect(),f=l==="x"?c.width:c.height,E=n*f;return Lt(r,{props:l==="x"?{transform:["translateX(0px)",`translateX(${-E}px)`]}:{transform:["translateY(0px)",`translateY(${-E}px)`]},trigger:d??{start:"top bottom",end:"bottom top"},easing:a,native:false,onProgress:m})}var at={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function tr(e,t){if(typeof window>"u")return at;let r=typeof e=="string"?document.querySelector(e):e;if(!r)return K("scrollCounter: element not found:",e),at;let n=r,{from:l=0,to:a,format:d,easing:m="ease-out",trigger:c={},once:f=true,decimals:E,onComplete:I}=t,T=E!==void 0?b=>b.toFixed(E):d??(b=>String(Math.round(b))),ee=typeof m=="function"?m:J[m]??J["ease-out"],Ee=$e(c.start??"top 80%"),A=$e(c.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=T(a),I?.(),at;let g=0,S=0,h=0,V=false,F=false,B=-1,te=0,de=false,j=()=>window.scrollY,q=()=>window.innerHeight;function Me(){let b=n.getBoundingClientRect(),P=Oe({top:b.top,height:b.height},j(),q(),Ee,A);g=P.tStart,S=P.tEnd;}function N(b){n.textContent=T(l+(a-l)*b),n.style.setProperty("--scroll-draw-progress",String(b));}function ge(){if(!V||F)return;let b=ee(ie(j(),g,S,1));f&&(B=Math.max(B,b),b=B),te=b,N(b),b>=1&&!de?(de=true,I?.()):b<1&&!f&&(de=false),h=requestAnimationFrame(ge);}Me();{let b=ee(ie(j(),g,S,1));f&&b>0&&(B=b),te=b,N(b);}let Pe=new IntersectionObserver(b=>{b.forEach(P=>{V=P.isIntersecting,V&&!F?h=requestAnimationFrame(ge):cancelAnimationFrame(h);});}),ke;function Le(){clearTimeout(ke),ke=setTimeout(Me,150);}return window.addEventListener("resize",Le),window.addEventListener("orientationchange",Le),Pe.observe(n),Ze(n,{type:"counter",getProgress:()=>te,getTrigger:()=>({tStart:g,tEnd:S})}),{destroy(){cancelAnimationFrame(h),Pe.disconnect(),window.removeEventListener("resize",Le),window.removeEventListener("orientationchange",Le),clearTimeout(ke),Je(n);},replay(){B=-1,de=false,te=0,F=false,N(0);},pause(){F=true,cancelAnimationFrame(h);},resume(){F&&(F=false,V&&(h=requestAnimationFrame(ge)));},seek(b){let P=Math.min(1,Math.max(0,b));te=P,B=P,F=true,cancelAnimationFrame(h),N(P);},getProgress(){return te}}}var Ct="http://www.w3.org/2000/svg",rr="cinematic-photo",lt=e=>e<0?0:e>1?1:e;function et(e){let t=parseFloat(e);return Number.isFinite(t)?lt(t/100):0}function nr(e){return J[e]??J.linear}var or={destroy:()=>{},getProgress:()=>0},ct=class{constructor(t){if(typeof document>"u"){this.mount=null;return}this.mount=typeof t.wrapper=="string"?document.querySelector(t.wrapper):t.wrapper,this.mount||K("Cinematic: wrapper not found:",t.wrapper);}loadStory(t){let r=this.mount;if(typeof window>"u"||!r)return or;r.style.position="relative",r.style.height=t.totalHeight,r.style.display="block";let n=document.createElement("div");n.setAttribute("data-cinematic-stage",""),n.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",r.appendChild(n);let l=[];for(let A of t.scenes){if(A.background){let g=document.createElement("img");g.id=rr,g.src=A.background,g.alt="",g.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(g);}let $=A.animations.filter(g=>g.type==="draw");if($.length){let g=document.createElementNS(Ct,"svg");g.setAttribute("viewBox",`0 0 ${t.canvas.width} ${t.canvas.height}`),g.setAttribute("preserveAspectRatio","xMidYMid meet"),g.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(g);for(let S of $){let h=document.createElementNS(Ct,"path");h.id=S.target.replace(/^#/,""),h.setAttribute("d",S.d),h.setAttribute("fill","none"),h.setAttribute("stroke",S.stroke),h.setAttribute("stroke-width",String(S.strokeWidth)),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round");let V=S.length||h.getTotalLength?.()||0;h.style.strokeDasharray=String(V),h.style.strokeDashoffset=String(V),g.appendChild(h),l.push({kind:"draw",el:h,start:et(S.start),end:et(S.end),ease:nr(S.easing),length:V});}}for(let g of A.animations){if(g.type!=="fade")continue;let S=n.querySelector(g.target)??document.querySelector(g.target);S&&(S.style.opacity=String(g.from),l.push({kind:"fade",el:S,start:et(g.start),end:et(g.end),ease:J["ease-in-out"]??J.linear,from:g.from,to:g.to}));}}let a=0,d=()=>{let A=r.offsetHeight-window.innerHeight;return A<=0?r.getBoundingClientRect().top<=0?1:0:lt(-r.getBoundingClientRect().top/A)},m=A=>{for(let $ of l){let g=$.end-$.start,S=g<=0?A>=$.end?1:0:lt((A-$.start)/g),h=$.ease(S);$.kind==="draw"?$.el.style.strokeDashoffset=String($.length*(1-h)):$.el.style.opacity=String($.from+($.to-$.from)*h);}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return m(1),{destroy:()=>{},getProgress:()=>1};let c=0,f=false,E=false,I=()=>{a=d(),m(a),f&&(c=requestAnimationFrame(I));},T=()=>{f||(f=true,c=requestAnimationFrame(I));},ee=()=>{f=false,cancelAnimationFrame(c);},Ee=new IntersectionObserver(A=>{for(let $ of A)E=$.isIntersecting,E?T():ee();},{threshold:0});return Ee.observe(n),a=d(),m(a),{destroy(){ee(),Ee.disconnect();},getProgress:()=>a}}};function Lr(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let n=typeof e=="string"?document.querySelector(e):e;return n?At(n,t):(K("Container not found:",e),r)}
4
+ export{ct as Cinematic,st as PRESETS,vt as createBounce,St as createElastic,Ft as createSpring,Kt as scrollAnimate,tr as scrollCounter,Lr as scrollDraw,er as scrollParallax};