svg-scroll-draw 2.2.0 → 2.7.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 (57) hide show
  1. package/README.md +7 -7
  2. package/dist/angular/index.cjs +3 -3
  3. package/dist/angular/index.d.mts +194 -9
  4. package/dist/angular/index.d.ts +194 -9
  5. package/dist/angular/index.mjs +3 -3
  6. package/dist/astro/index.cjs +3 -3
  7. package/dist/astro/index.d.mts +78 -1
  8. package/dist/astro/index.d.ts +78 -1
  9. package/dist/astro/index.mjs +3 -3
  10. package/dist/cdn/svg-scroll-draw.global.js +3 -3
  11. package/dist/devtools/index.cjs +1 -1
  12. package/dist/devtools/index.d.mts +12 -0
  13. package/dist/devtools/index.d.ts +12 -0
  14. package/dist/devtools/index.mjs +1 -1
  15. package/dist/group/index.cjs +3 -3
  16. package/dist/group/index.d.mts +88 -1
  17. package/dist/group/index.d.ts +88 -1
  18. package/dist/group/index.mjs +3 -3
  19. package/dist/index.cjs +4 -4
  20. package/dist/index.d.mts +16 -0
  21. package/dist/index.d.ts +16 -0
  22. package/dist/index.mjs +4 -4
  23. package/dist/lenis/index.cjs +1 -0
  24. package/dist/lenis/index.d.mts +51 -0
  25. package/dist/lenis/index.d.ts +51 -0
  26. package/dist/lenis/index.mjs +1 -0
  27. package/dist/nuxt/index.cjs +3 -3
  28. package/dist/nuxt/index.d.mts +286 -5
  29. package/dist/nuxt/index.d.ts +286 -5
  30. package/dist/nuxt/index.mjs +3 -3
  31. package/dist/pin/index.cjs +1 -0
  32. package/dist/pin/index.d.mts +29 -0
  33. package/dist/pin/index.d.ts +29 -0
  34. package/dist/pin/index.mjs +1 -0
  35. package/dist/react/index.cjs +3 -3
  36. package/dist/react/index.d.mts +16 -0
  37. package/dist/react/index.d.ts +16 -0
  38. package/dist/react/index.mjs +3 -3
  39. package/dist/snap/index.cjs +1 -0
  40. package/dist/snap/index.d.mts +30 -0
  41. package/dist/snap/index.d.ts +30 -0
  42. package/dist/snap/index.mjs +1 -0
  43. package/dist/solid/index.cjs +3 -3
  44. package/dist/solid/index.d.mts +171 -1
  45. package/dist/solid/index.d.ts +171 -1
  46. package/dist/solid/index.mjs +3 -3
  47. package/dist/svelte/index.cjs +3 -3
  48. package/dist/svelte/index.d.mts +183 -10
  49. package/dist/svelte/index.d.ts +183 -10
  50. package/dist/svelte/index.mjs +3 -3
  51. package/dist/vue/index.cjs +3 -3
  52. package/dist/vue/index.d.mts +278 -1
  53. package/dist/vue/index.d.ts +278 -1
  54. package/dist/vue/index.mjs +3 -3
  55. package/dist/web-component/index.cjs +3 -3
  56. package/dist/web-component/index.mjs +3 -3
  57. package/package.json +16 -1
@@ -1,3 +1,3 @@
1
- function rt({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),s=Math.max(.01,Math.min(.99,r)),m=Math.sqrt(s),u=0,S=[];for(let y=0;y<n;y++){let $=Math.pow(m,y);S.push($),u+=$;}let w=[0],p=0;for(let y=0;y<n;y++)p+=S[y]/u,w.push(p);return y=>{if(y<=0)return 0;if(y>=1)return 1;for(let $=0;$<n;$++)if(y<=w[$+1]){let V=(y-w[$])/(w[$+1]-w[$]);if($===0)return V*(2-V);let h=1-Math.pow(s,$);return h+(1-h)*(2*V-1)*(2*V-1)}return 1}}function nt({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),s=Math.max(.1,r),m=n<=1?s/4:s/(2*Math.PI)*Math.asin(1/n);return u=>u<=0?0:u>=1?1:n*Math.pow(2,-10*u)*Math.sin((u-m)*(2*Math.PI)/s)+1}var Pe={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:rt(),elastic:nt()};function De(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",s="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:s}}function ze(e,r,n,s){switch(s){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function Ge(e,r){if(/^\d+(\.\d+)?%$/.test(e))return r*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return r/2;case "bottom":return r;default:return r}}function Ee(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),s=parseFloat(e.getAttribute("height")??"0");return 2*(n+s)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function st(e,r,n){return Math.min(n,Math.max(r,e))}function ae(e,r,n,s){return n===r?0:st((e-r)/(n-r)*s,0,1)}function Le(e,r,n,s,m){let u=ze(e.top,e.height,r,s.element)-Ge(s.viewport,n),S=ze(e.top,e.height,r,m.element)-Ge(m.viewport,n);return {tStart:u,tEnd:S}}function Ve(e){let r=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(r)return [parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16)];let n=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(n)return [parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)];let s=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return s?[parseInt(s[1]),parseInt(s[2]),parseInt(s[3])]:null}function xe(e,r,n){let s=Ve(e),m=Ve(r);return !s||!m?e:`rgb(${Math.round(s[0]+(m[0]-s[0])*n)},${Math.round(s[1]+(m[1]-s[1])*n)},${Math.round(s[2]+(m[2]-s[2])*n)})`}var Be={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 _e(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Xe={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},ot=0;function at(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function it(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?_e("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&_e("Element has a fill \u2014 it may obscure the stroke animation.",e);}function lt(e,r,n){let s=document.createElement("div");s.setAttribute("data-svg-scroll-draw-debug",""),s.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 u=n==="x"?window.scrollX:window.scrollY,S=e-u,w=r-u,p=n==="x";s.innerHTML=`
2
- <div style="position:absolute;${p?`left:${S}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${S}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;${p?`left:${w}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${w}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(s),window.addEventListener("scroll",m,{passive:true}),m(),s}function Ie(e,r,n){let s=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),m=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,u=>{let S=parseFloat(u),w=s[m++]??S;return String(+(S+(w-S)*n).toFixed(4))})}function Oe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:n,...s}=r,m=n?{...Be[n],...s}:s,u=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:S="path, polyline, line, polygon, rect, circle",speed:w=1,fade:p=false,easing:y="linear",trigger:$={},stagger:V=0,direction:h="forward",once:K=false,debug:je=false,axis:N="y",scrollContainer:$e,autoReverse:me=false,delay:ue=0,strokeColor:Q,strokeWidth:Y,fillOpacity:Z,waypoints:ee,velocityScale:pe=false,threshold:Fe=0,rootMargin:Ce="0px",repeat:te=0,repeatDelay:Se=0,morphTo:W,clip:ke,autoplay:Je=false,duration:Ke=1e3,native:Qe=true,onProgress:ce,onStart:de,onComplete:ie}=m,_=ke===true?"left":typeof ke=="string"?ke:false,re=typeof y=="function"?y:Pe[y]??Pe.linear,Re=De($.start??"top bottom"),Ne=De($.end??"bottom top"),I=typeof $e=="string"?document.querySelector($e):$e??null,q=Array.isArray(Q)?Q[0]:null,A=Array.isArray(Q)?Q[1]:typeof Q=="string"?Q:null,O=Array.isArray(Y)?Y[0]:null,T=Array.isArray(Y)?Y[1]:typeof Y=="number"?Y:null,F=Array.isArray(Z)?Z[0]:null,P=Array.isArray(Z)?Z[1]:typeof Z=="number"?Z:null;function ne(t){let o=t*100;switch(_){case "right":return `inset(0 0 0 ${100-o}%)`;case "top":return `inset(0 0 ${100-o}% 0)`;case "bottom":return `inset(${100-o}% 0 0 0)`;case "center":return `circle(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-o}% 0 0)`}}let k=_?[]:Array.from(e.querySelectorAll(S)),E=[],H=[],X=0,U=0,M=false,R=false,x=0,ye=false,z=-1,ge=-1,D=false,se=0,B=0,j,Me=null,J=new Set,he=-1,We=performance.now();function fe(){return I?N==="x"?I.scrollLeft:I.scrollTop:N==="x"?window.scrollX:window.scrollY}function qe(){return I?N==="x"?I.clientWidth:I.clientHeight:N==="x"?window.innerWidth:window.innerHeight}function He(){let t=e.getBoundingClientRect(),o,l,b;if(I){let L=I.getBoundingClientRect();o=N==="x"?t.left-L.left+I.scrollLeft:t.top-L.top+I.scrollTop,l=N==="x"?t.width:t.height,b=fe();}else o=N==="x"?t.left:t.top,l=N==="x"?t.width:t.height,b=fe();let C=Le({top:o,height:l},b,qe(),Re,Ne);X=C.tStart,U=C.tEnd,je&&process.env.NODE_ENV!=="production"&&(Me?.remove(),Me=lt(X,U,N));}function Ye(t,o){if(e.style.setProperty("--scroll-draw-progress",String(t)),_){let l=o==="reverse"?1-t:t;e.style.clipPath=ne(l);return}k.forEach((l,b)=>{l.style.strokeDashoffset=o==="reverse"?`${E[b]*t}`:`${E[b]*(1-t)}`,p&&(l.style.opacity=o==="reverse"?`${1-t}`:`${t}`),q&&A?l.style.stroke=xe(q,A,t):A&&(l.style.stroke=A),O!==null&&T!==null?l.style.strokeWidth=`${O+(T-O)*t}`:T!==null&&(l.style.strokeWidth=`${T}`),F!==null&&P!==null?l.style.fillOpacity=`${F+(P-F)*t}`:P!==null&&(l.style.fillOpacity=`${P}`),W&&l.tagName.toLowerCase()==="path"&&H[b]&&l.setAttribute("d",Ie(H[b],W,t));});}function be(){if(e.style.setProperty("--scroll-draw-progress","0"),_){e.style.clipPath=ne(0);return}k.forEach((t,o)=>{t.style.strokeDasharray=`${E[o]}`,t.style.strokeDashoffset=h==="reverse"?"0":`${E[o]}`,p?t.style.opacity=h==="reverse"?"1":"0":t.style.opacity="",q&&(t.style.stroke=q),O!==null&&(t.style.strokeWidth=`${O}`),F!==null&&(t.style.fillOpacity=`${F}`),W&&t.tagName.toLowerCase()==="path"&&H[o]&&t.setAttribute("d",H[o]);});}if(k.forEach(t=>{it(t);let o=Ee(t);E.push(o),t.tagName.toLowerCase()==="path"?H.push(t.getAttribute("d")??""):H.push(""),u?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=h==="reverse"?`${o}`:"0",p&&(t.style.opacity="1"),A&&(t.style.stroke=A),T!==null&&(t.style.strokeWidth=`${T}`),P!==null&&(t.style.fillOpacity=`${P}`),W&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",W)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=h==="reverse"?"0":`${o}`,p?t.style.opacity=h==="reverse"?"1":"0":t.style.opacity="",q&&(t.style.stroke=q),O!==null&&(t.style.strokeWidth=`${O}`),F!==null&&(t.style.fillOpacity=`${F}`));}),_){if(u)return e.style.clipPath=ne(1),ie?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ne(0);}else if(u)return ie?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function Ze(){return !(Qe===false||!at()||!k.length||typeof y!="string"||!(y in Xe)||_||N!=="y"||I||w!==1||V!==0||K||me||pe!==false||W||ee||te||ue>0||ce||de||ie||Q!=null||Y!=null||Z!=null||($.start??"top bottom").trim()!=="top bottom"||($.end??"bottom top").trim()!=="bottom top")}function et(){let t=`svg-scroll-draw-${++ot}`,o=h==="reverse"?"0":"var(--ssd-len)",l=h==="reverse"?"var(--ssd-len)":"0",b=`stroke-dashoffset:${o};`,C=`stroke-dashoffset:${l};`;p&&(b+=`opacity:${h==="reverse"?1:0};`,C+=`opacity:${h==="reverse"?0:1};`);let L=document.createElement("style");L.setAttribute("data-svg-scroll-draw",""),L.textContent=`@keyframes ${t}{from{${b}}to{${C}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Xe[y]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(L);function i(a,f){a.style.setProperty("--ssd-len",String(E[f])),a.style.strokeDasharray=`${E[f]}`,a.style.strokeDashoffset="",a.style.opacity="",a.style.animationPlayState="",a.classList.add(t);}k.forEach(i);let d=false,v=-1;function c(){if(v>=0)return v;let a=e.getBoundingClientRect(),{tStart:f,tEnd:g}=Le({top:a.top,height:a.height},fe(),qe(),Re,Ne);return re(ae(fe(),f,g,w))}return {destroy(){k.forEach(a=>{a.classList.remove(t),a.style.removeProperty("--ssd-len"),a.style.animationPlayState="";}),L.remove();},replay(){d=false,v=-1,k.forEach(i);},pause(){d=true,k.forEach(a=>{a.style.animationPlayState="paused";});},resume(){d&&(d=false,k.forEach(a=>{a.style.animationPlayState="running";}));},seek(a){let f=Math.min(1,Math.max(0,a));v=f,d=true,k.forEach((g,oe)=>{g.classList.remove(t),g.style.strokeDashoffset=h==="reverse"?`${E[oe]*f}`:`${E[oe]*(1-f)}`,p&&(g.style.opacity=h==="reverse"?`${1-f}`:`${f}`);});},getProgress(){return c()}}}if(Ze())return et();function tt(){let t=Math.max(1,Ke),o=0,l=0;function b(c){let a=true;if(_){let f=Math.min(1,Math.max(0,c/t)),g=re(f);se=g,e.style.setProperty("--scroll-draw-progress",String(g)),e.style.clipPath=ne(h==="reverse"?1-g:g),ce?.(g),f<1&&(a=false);}else k.forEach((f,g)=>{let oe=g*V*t,le=Math.min(1,Math.max(0,(c-oe)/t)),G=re(le);f.style.strokeDashoffset=h==="reverse"?`${E[g]*G}`:`${E[g]*(1-G)}`,p&&(f.style.opacity=h==="reverse"?`${1-G}`:`${G}`),q&&A?f.style.stroke=xe(q,A,G):A&&(f.style.stroke=A),O!==null&&T!==null?f.style.strokeWidth=`${O+(T-O)*G}`:T!==null&&(f.style.strokeWidth=`${T}`),F!==null&&P!==null?f.style.fillOpacity=`${F+(P-F)*G}`:P!==null&&(f.style.fillOpacity=`${P}`),W&&f.tagName.toLowerCase()==="path"&&H[g]&&f.setAttribute("d",Ie(H[g],W,G)),g===0&&(ce?.(G),e.style.setProperty("--scroll-draw-progress",String(G))),le<1&&(a=false);});if(ee){let f=Math.min(1,Math.max(0,c/t)),g=re(f);for(let oe in ee){let le=parseFloat(oe);g>=le&&!J.has(le)&&(J.add(le),ee[oe]?.());}}return a}function C(c){if(D)return;let a=c-o;R||(R=true,de?.());let f=b(a);if(f&&!M){M=true,b(t*(1+Math.max(0,k.length-1)*V)),ie?.(),B<(te==="infinite"?1/0:te??0)&&(B++,j=setTimeout(()=>{o=performance.now(),R=false,M=false,J.clear(),be(),x=requestAnimationFrame(C);},Se));return}f||(x=requestAnimationFrame(C));}function L(){cancelAnimationFrame(x),clearTimeout(j),o=performance.now(),l=0,D=false,R=false,M=false,B=0,J.clear(),be(),x=requestAnimationFrame(C);}let i=new IntersectionObserver(c=>{c.forEach(a=>{a.isIntersecting&&!(K&&M)?L():!a.isIntersecting&&!K&&!M&&(cancelAnimationFrame(x),clearTimeout(j),o=null);});},{root:I??null,threshold:Fe,rootMargin:Ce}),d;function v(){clearTimeout(d),d=setTimeout(()=>{k.forEach((c,a)=>{E[a]=Ee(c),c.style.strokeDasharray=`${E[a]}`;});},150);}return window.addEventListener("resize",v),window.addEventListener("orientationchange",v),ue>0?setTimeout(()=>i.observe(e),ue):i.observe(e),{destroy(){cancelAnimationFrame(x),clearTimeout(j),i.disconnect(),window.removeEventListener("resize",v),window.removeEventListener("orientationchange",v),clearTimeout(d);},replay(){B=0,L();},pause(){D||(D=true,l=performance.now()-o,cancelAnimationFrame(x));},resume(){D&&(D=false,o=performance.now()-l,x=requestAnimationFrame(C));},seek(c){let a=Math.min(1,Math.max(0,c));se=a,D=true,l=a*t,o=performance.now()-l,cancelAnimationFrame(x),b(l);},getProgress(){return se}}}if(Je)return tt();He();function we(){if(!ye||D)return;let t=performance.now(),o=fe(),l=w;if(pe!==false){let i=t-We,d=i>0?Math.abs(o-(he<0?o:he))/i:0;l=w*Math.max(.2,1+d*(typeof pe=="number"?pe:1)*.04);}he=o,We=t;let b=me?ge===-1||o>=ge?"forward":"reverse":h;ge=o;let C=U-X,L=true;if(_){let i=re(ae(o,X,U,l));K&&!me&&(z=Math.max(z,i),i=z),se=i,e.style.setProperty("--scroll-draw-progress",String(i));let d=b==="reverse"?1-i:i;e.style.clipPath=ne(d),ce?.(i),!R&&ae(o,X,U,l)>0&&(R=true,de?.()),i>=1&&!M?(M=true,ie?.(),B<(te==="infinite"?1/0:te??0)&&(B++,j=setTimeout(()=>{z=-1,R=false,M=false,e.style.clipPath=ne(0);},Se))):i<1&&!K&&(M=false),x=requestAnimationFrame(we);return}if(k.forEach((i,d)=>{let v=d*V*C,c=re(ae(o,X+v,U+v,l));K&&!me&&(z=Math.max(z,c),c=z),se=c,i.style.strokeDashoffset=b==="reverse"?`${E[d]*c}`:`${E[d]*(1-c)}`,p&&(i.style.opacity=b==="reverse"?`${1-c}`:`${c}`),q&&A?i.style.stroke=xe(q,A,c):A&&(i.style.stroke=A),O!==null&&T!==null?i.style.strokeWidth=`${O+(T-O)*c}`:T!==null&&(i.style.strokeWidth=`${T}`),F!==null&&P!==null?i.style.fillOpacity=`${F+(P-F)*c}`:P!==null&&(i.style.fillOpacity=`${P}`),W&&i.tagName.toLowerCase()==="path"&&H[d]&&i.setAttribute("d",Ie(H[d],W,c)),d===0&&(ce?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(L=false);}),ee){let i=re(ae(o,X,U,l));for(let d in ee){let v=parseFloat(d);i>=v&&!J.has(v)&&(J.add(v),ee[d]?.());}}!R&&ae(o,X,U,l)>0&&(R=true,de?.()),L&&!M?(M=true,ie?.(),B<(te==="infinite"?1/0:te??0)&&(B++,j=setTimeout(()=>{z=-1,R=false,M=false,J.clear(),be();},Se))):!L&&!K&&(M=false),x=requestAnimationFrame(we);}let Ae=new IntersectionObserver(t=>{t.forEach(o=>{ye=o.isIntersecting,ye&&!D?x=requestAnimationFrame(we):cancelAnimationFrame(x);});},{root:I??null,threshold:Fe,rootMargin:Ce}),Te;function ve(){clearTimeout(Te),Te=setTimeout(()=>{k.forEach((t,o)=>{E[o]=Ee(t),t.style.strokeDasharray=`${E[o]}`;}),He();},150);}return window.addEventListener("resize",ve),window.addEventListener("orientationchange",ve),ue>0?setTimeout(()=>Ae.observe(e),ue):Ae.observe(e),{destroy(){cancelAnimationFrame(x),clearTimeout(j),Ae.disconnect(),window.removeEventListener("resize",ve),window.removeEventListener("orientationchange",ve),clearTimeout(Te),Me?.remove();},replay(){z=-1,ge=-1,he=-1,R=false,M=false,B=0,D=false,J.clear(),clearTimeout(j),be();},pause(){D=true,cancelAnimationFrame(x);},resume(){D&&(D=false,ye&&(x=requestAnimationFrame(we)));},seek(t){let o=Math.min(1,Math.max(0,t));se=o,z=o,D=true,cancelAnimationFrame(x),Ye(o,h);},getProgress(){return se}}}function Ue(e){return e.map(r=>typeof r=="string"?document.querySelector(r):r).filter(r=>r!==null)}function yt(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let n=Ue(e).map(s=>Oe(s,r));return {destroy(){n.forEach(s=>s.destroy());},replay(){n.forEach(s=>s.replay());},pause(){n.forEach(s=>s.pause());},resume(){n.forEach(s=>s.resume());},seek(s){n.forEach(m=>m.seek(s));},getProgress(){return n[0]?.getProgress()??0}}}function gt(e,r={}){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let s=Ue(e);if(s.length===0)return n;let m=0,u=[];function S(p){return Oe(s[p],{...r,once:true,onComplete(){r.onComplete?.(),m=p+1,u[m]?.resume();}})}function w(){s.forEach((p,y)=>{u[y]=S(y);});for(let p=1;p<u.length;p++)u[p].pause();}return w(),{destroy(){u.forEach(p=>p.destroy()),u.length=0;},replay(){u.forEach(p=>p.destroy()),u.length=0,m=0,w();},pause(){u[m]?.pause();},resume(){u[m]?.resume();},seek(p){u[m]?.seek(p);},getProgress(){return u[m]?.getProgress()??0}}}export{yt as scrollDrawGroup,gt as scrollDrawSequence};
1
+ function ht({bounces:e=3,decay:n=.5}={}){let r=Math.max(1,Math.round(e)),t=Math.max(.01,Math.min(.99,n)),o=Math.sqrt(t),f=0,d=[];for(let g=0;g<r;g++){let x=Math.pow(o,g);d.push(x),f+=x;}let i=[0],u=0;for(let g=0;g<r;g++)u+=d[g]/f,i.push(u);return g=>{if(g<=0)return 0;if(g>=1)return 1;for(let x=0;x<r;x++)if(g<=i[x+1]){let B=(g-i[x])/(i[x+1]-i[x]);if(x===0)return B*(2-B);let b=1-Math.pow(t,x);return b+(1-b)*(2*B-1)*(2*B-1)}return 1}}function bt({amplitude:e=1,period:n=.4}={}){let r=Math.max(1,e),t=Math.max(.1,n),o=r<=1?t/4:t/(2*Math.PI)*Math.asin(1/r);return f=>f<=0?0:f>=1?1:r*Math.pow(2,-10*f)*Math.sin((f-o)*(2*Math.PI)/t)+1}var Ae={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:ht(),elastic:bt()};function Te(e="top bottom"){let n=e.trim();if(/^\d+(\.\d+)?%$/.test(n))return {element:"top",viewport:n};let[r="top",t="bottom"]=n.split(/\s+/).filter(Boolean);return {element:r,viewport:t}}function Qe(e,n,r,t){switch(t){case "top":return e+r;case "center":return e+r+n/2;case "bottom":return e+r+n;default:return e+r}}function et(e,n){if(/^\d+(\.\d+)?%$/.test(e))return n*(parseFloat(e)/100);switch(e){case "top":return 0;case "center":return n/2;case "bottom":return n;default:return n}}function Ve(e){let n=e.tagName.toLowerCase();if(n==="rect"){let r=parseFloat(e.getAttribute("width")??"0"),t=parseFloat(e.getAttribute("height")??"0");return 2*(r+t)}if(n==="circle"){let r=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*r}return e.getTotalLength()}function wt(e,n,r){return Math.min(r,Math.max(n,e))}function J(e,n,r,t){return r===n?0:wt((e-n)/(r-n)*t,0,1)}function Pe(e,n,r,t,o){let f=Qe(e.top,e.height,n,t.element)-et(t.viewport,r),d=Qe(e.top,e.height,n,o.element)-et(o.viewport,r);return {tStart:f,tEnd:d}}function tt(e){let n=/^#([a-f\d])([a-f\d])([a-f\d])$/i.exec(e);if(n)return [parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[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 t=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return t?[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]:null}function Me(e,n,r){let t=tt(e),o=tt(n);return !t||!o?e:`rgb(${Math.round(t[0]+(o[0]-t[0])*r)},${Math.round(t[1]+(o[1]-t[1])*r)},${Math.round(t[2]+(o[2]-t[2])*r)})`}var rt={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 nt(e,n){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,n);}var st={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Et=0;function vt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function St(e){let n=e.getAttribute("stroke"),r=e.getAttribute("fill");!n||n==="none"?nt("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&nt("Element has a fill \u2014 it may obscure the stroke animation.",e);}function xt(e,n,r){let t=document.createElement("div");t.setAttribute("data-svg-scroll-draw-debug",""),t.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 o(){let f=r==="x"?window.scrollX:window.scrollY,d=e-f,i=n-f,u=r==="x";t.innerHTML=`
2
+ <div style="position:absolute;${u?`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;${u?`left:${i}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${i}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(t),window.addEventListener("scroll",o,{passive:true}),o(),t}function Ye(e,n,r){let t=(n.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),o=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,f=>{let d=parseFloat(f),i=t[o++]??d;return String(+(d+(i-d)*r).toFixed(4))})}function Ue(e,n={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...t}=n,o=r?{...rt[r],...t}:t,f=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:d="path, polyline, line, polygon, rect, circle",speed:i=1,fade:u=false,easing:g="linear",trigger:x={},stagger:B=0,direction:b="forward",once:K=false,debug:Ce=false,axis:q="y",scrollContainer:be,autoReverse:we=false,delay:se=0,strokeColor:Q,strokeWidth:ee,fillOpacity:A,waypoints:N,velocityScale:Ee=false,threshold:Oe=0,rootMargin:Ne="0px",repeat:oe=0,repeatDelay:j=0,morphTo:I,clip:X,autoplay:ve=false,duration:ie=1e3,native:ue=true,onProgress:V,onStart:ae,onComplete:R,onEnter:pe,onLeave:Fe,onEnterBack:ke,onLeaveBack:de}=o,te=X===true?"left":typeof X=="string"?X:false,Y=typeof g=="function"?g:Ae[g]??Ae.linear,Le=Te(x.start??"top bottom"),Se=Te(x.end??"bottom top"),k=typeof be=="string"?document.querySelector(be):be??null,a=Array.isArray(Q)?Q[0]:null,m=Array.isArray(Q)?Q[1]:typeof Q=="string"?Q:null,P=Array.isArray(ee)?ee[0]:null,S=Array.isArray(ee)?ee[1]:typeof ee=="number"?ee:null,L=Array.isArray(A)?A[0]:null,O=Array.isArray(A)?A[1]:typeof A=="number"?A:null;function D(s){let l=s*100;switch(te){case "right":return `inset(0 0 0 ${100-l}%)`;case "top":return `inset(0 0 ${100-l}% 0)`;case "bottom":return `inset(${100-l}% 0 0 0)`;case "center":return `circle(${s*150}% at 50% 50%)`;default:return `inset(0 ${100-l}% 0 0)`}}let T=te?[]:Array.from(e.querySelectorAll(d)),w=[],_=[],U=0,ce=0,F=false,Z=false,C=0,Re=false,re=-1,He=-1,H=false,ge=0,le=0,fe,Ge=null,me=new Set,ze=-1,Ze=performance.now(),xe=NaN;function De(){return k?q==="x"?k.scrollLeft:k.scrollTop:q==="x"?window.scrollX:window.scrollY}function Je(){return k?q==="x"?k.clientWidth:k.clientHeight:q==="x"?window.innerWidth:window.innerHeight}function Ke(){let s=e.getBoundingClientRect(),l,y,M;if(k){let W=k.getBoundingClientRect();l=q==="x"?s.left-W.left+k.scrollLeft:s.top-W.top+k.scrollTop,y=q==="x"?s.width:s.height,M=De();}else l=q==="x"?s.left:s.top,y=q==="x"?s.width:s.height,M=De();let z=Pe({top:l,height:y},M,Je(),Le,Se);U=z.tStart,ce=z.tEnd,Ce&&process.env.NODE_ENV!=="production"&&(Ge?.remove(),Ge=xt(U,ce,q));}function pt(s,l){if(e.style.setProperty("--scroll-draw-progress",String(s)),te){let y=l==="reverse"?1-s:s;e.style.clipPath=D(y);return}T.forEach((y,M)=>{y.style.strokeDashoffset=l==="reverse"?`${w[M]*s}`:`${w[M]*(1-s)}`,u&&(y.style.opacity=l==="reverse"?`${1-s}`:`${s}`),a&&m?y.style.stroke=Me(a,m,s):m&&(y.style.stroke=m),P!==null&&S!==null?y.style.strokeWidth=`${P+(S-P)*s}`:S!==null&&(y.style.strokeWidth=`${S}`),L!==null&&O!==null?y.style.fillOpacity=`${L+(O-L)*s}`:O!==null&&(y.style.fillOpacity=`${O}`),I&&y.tagName.toLowerCase()==="path"&&_[M]&&y.setAttribute("d",Ye(_[M],I,s));});}function We(){if(e.style.setProperty("--scroll-draw-progress","0"),te){e.style.clipPath=D(0);return}T.forEach((s,l)=>{s.style.strokeDasharray=`${w[l]}`,s.style.strokeDashoffset=b==="reverse"?"0":`${w[l]}`,u?s.style.opacity=b==="reverse"?"1":"0":s.style.opacity="",a&&(s.style.stroke=a),P!==null&&(s.style.strokeWidth=`${P}`),L!==null&&(s.style.fillOpacity=`${L}`),I&&s.tagName.toLowerCase()==="path"&&_[l]&&s.setAttribute("d",_[l]);});}if(T.forEach(s=>{St(s);let l=Ve(s);w.push(l),s.tagName.toLowerCase()==="path"?_.push(s.getAttribute("d")??""):_.push(""),f?(s.style.strokeDasharray=`${l}`,s.style.strokeDashoffset=b==="reverse"?`${l}`:"0",u&&(s.style.opacity="1"),m&&(s.style.stroke=m),S!==null&&(s.style.strokeWidth=`${S}`),O!==null&&(s.style.fillOpacity=`${O}`),I&&s.tagName.toLowerCase()==="path"&&s.setAttribute("d",I)):(s.style.strokeDasharray=`${l}`,s.style.strokeDashoffset=b==="reverse"?"0":`${l}`,u?s.style.opacity=b==="reverse"?"1":"0":s.style.opacity="",a&&(s.style.stroke=a),P!==null&&(s.style.strokeWidth=`${P}`),L!==null&&(s.style.fillOpacity=`${L}`));}),te){if(f)return e.style.clipPath=D(1),R?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=D(0);}else if(f)return R?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function dt(){return !(ue===false||!vt()||!T.length||typeof g!="string"||!(g in st)||te||q!=="y"||k||i!==1||B!==0||K||we||Ee!==false||I||N||oe||se>0||V||ae||R||pe||Fe||ke||de||Q!=null||ee!=null||A!=null||(x.start??"top bottom").trim()!=="top bottom"||(x.end??"bottom top").trim()!=="bottom top")}function gt(){let s=`svg-scroll-draw-${++Et}`,l=b==="reverse"?"0":"var(--ssd-len)",y=b==="reverse"?"var(--ssd-len)":"0",M=`stroke-dashoffset:${l};`,z=`stroke-dashoffset:${y};`;u&&(M+=`opacity:${b==="reverse"?1:0};`,z+=`opacity:${b==="reverse"?0:1};`);let W=document.createElement("style");W.setAttribute("data-svg-scroll-draw",""),W.textContent=`@keyframes ${s}{from{${M}}to{${z}}}.${s}{animation-name:${s};animation-duration:auto;animation-timing-function:${st[g]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(W);function G(c,h){c.style.setProperty("--ssd-len",String(w[h])),c.style.strokeDasharray=`${w[h]}`,c.style.strokeDashoffset="",c.style.opacity="",c.style.animationPlayState="",c.classList.add(s);}T.forEach(G);let p=false,E=-1;function v(){if(E>=0)return E;let c=e.getBoundingClientRect(),{tStart:h,tEnd:$}=Pe({top:c.top,height:c.height},De(),Je(),Le,Se);return Y(J(De(),h,$,i))}return {destroy(){T.forEach(c=>{c.classList.remove(s),c.style.removeProperty("--ssd-len"),c.style.animationPlayState="";}),W.remove();},replay(){p=false,E=-1,T.forEach(G);},pause(){p=true,T.forEach(c=>{c.style.animationPlayState="paused";});},resume(){p&&(p=false,T.forEach(c=>{c.style.animationPlayState="running";}));},seek(c){let h=Math.min(1,Math.max(0,c));E=h,p=true,T.forEach(($,ye)=>{$.classList.remove(s),$.style.strokeDashoffset=b==="reverse"?`${w[ye]*h}`:`${w[ye]*(1-h)}`,u&&($.style.opacity=b==="reverse"?`${1-h}`:`${h}`);});},getProgress(){return v()}}}if(dt())return gt();function yt(){let s=Math.max(1,ie),l=0,y=0;function M(v){let c=true;if(te){let h=Math.min(1,Math.max(0,v/s)),$=Y(h);ge=$,e.style.setProperty("--scroll-draw-progress",String($)),e.style.clipPath=D(b==="reverse"?1-$:$),V?.($),h<1&&(c=false);}else T.forEach((h,$)=>{let ye=$*B*s,$e=Math.min(1,Math.max(0,(v-ye)/s)),ne=Y($e);h.style.strokeDashoffset=b==="reverse"?`${w[$]*ne}`:`${w[$]*(1-ne)}`,u&&(h.style.opacity=b==="reverse"?`${1-ne}`:`${ne}`),a&&m?h.style.stroke=Me(a,m,ne):m&&(h.style.stroke=m),P!==null&&S!==null?h.style.strokeWidth=`${P+(S-P)*ne}`:S!==null&&(h.style.strokeWidth=`${S}`),L!==null&&O!==null?h.style.fillOpacity=`${L+(O-L)*ne}`:O!==null&&(h.style.fillOpacity=`${O}`),I&&h.tagName.toLowerCase()==="path"&&_[$]&&h.setAttribute("d",Ye(_[$],I,ne)),$===0&&(V?.(ne),e.style.setProperty("--scroll-draw-progress",String(ne))),$e<1&&(c=false);});if(N){let h=Math.min(1,Math.max(0,v/s)),$=Y(h);for(let ye in N){let $e=parseFloat(ye);$>=$e&&!me.has($e)&&(me.add($e),N[ye]?.());}}return c}function z(v){if(H)return;let c=v-l;Z||(Z=true,ae?.());let h=M(c);if(h&&!F){F=true,M(s*(1+Math.max(0,T.length-1)*B)),R?.(),le<(oe==="infinite"?1/0:oe??0)&&(le++,fe=setTimeout(()=>{l=performance.now(),Z=false,F=false,me.clear(),We(),C=requestAnimationFrame(z);},j));return}h||(C=requestAnimationFrame(z));}function W(){cancelAnimationFrame(C),clearTimeout(fe),l=performance.now(),y=0,H=false,Z=false,F=false,le=0,me.clear(),We(),C=requestAnimationFrame(z);}let G=new IntersectionObserver(v=>{v.forEach(c=>{c.isIntersecting&&!(K&&F)?W():!c.isIntersecting&&!K&&!F&&(cancelAnimationFrame(C),clearTimeout(fe),l=null);});},{root:k??null,threshold:Oe,rootMargin:Ne}),p;function E(){clearTimeout(p),p=setTimeout(()=>{T.forEach((v,c)=>{w[c]=Ve(v),v.style.strokeDasharray=`${w[c]}`;});},150);}return window.addEventListener("resize",E),window.addEventListener("orientationchange",E),se>0?setTimeout(()=>G.observe(e),se):G.observe(e),{destroy(){cancelAnimationFrame(C),clearTimeout(fe),G.disconnect(),window.removeEventListener("resize",E),window.removeEventListener("orientationchange",E),clearTimeout(p);},replay(){le=0,W();},pause(){H||(H=true,y=performance.now()-l,cancelAnimationFrame(C));},resume(){H&&(H=false,l=performance.now()-y,C=requestAnimationFrame(z));},seek(v){let c=Math.min(1,Math.max(0,v));ge=c,H=true,y=c*s,l=performance.now()-y,cancelAnimationFrame(C),M(y);},getProgress(){return ge}}}if(ve)return yt();Ke();function qe(){if(!Re||H)return;let s=performance.now(),l=De(),y=i;if(Ee!==false){let p=s-Ze,E=p>0?Math.abs(l-(ze<0?l:ze))/p:0;y=i*Math.max(.2,1+E*(typeof Ee=="number"?Ee:1)*.04);}ze=l,Ze=s;let M=we?He===-1||l>=He?"forward":"reverse":b;He=l;let z=ce-U,W=true,G=z===0?0:(l-U)/z;if(isNaN(xe)||(xe<=0&&G>0?pe?.():xe>0&&G<=0&&de?.(),xe<1&&G>=1?Fe?.():xe>=1&&G<1&&ke?.()),xe=G,te){let p=Y(J(l,U,ce,y));K&&!we&&(re=Math.max(re,p),p=re),ge=p,e.style.setProperty("--scroll-draw-progress",String(p));let E=M==="reverse"?1-p:p;e.style.clipPath=D(E),V?.(p),!Z&&J(l,U,ce,y)>0&&(Z=true,ae?.()),p>=1&&!F?(F=true,R?.(),le<(oe==="infinite"?1/0:oe??0)&&(le++,fe=setTimeout(()=>{re=-1,Z=false,F=false,e.style.clipPath=D(0);},j))):p<1&&!K&&(F=false),C=requestAnimationFrame(qe);return}if(T.forEach((p,E)=>{let v=E*B*z,c=Y(J(l,U+v,ce+v,y));K&&!we&&(re=Math.max(re,c),c=re),ge=c,p.style.strokeDashoffset=M==="reverse"?`${w[E]*c}`:`${w[E]*(1-c)}`,u&&(p.style.opacity=M==="reverse"?`${1-c}`:`${c}`),a&&m?p.style.stroke=Me(a,m,c):m&&(p.style.stroke=m),P!==null&&S!==null?p.style.strokeWidth=`${P+(S-P)*c}`:S!==null&&(p.style.strokeWidth=`${S}`),L!==null&&O!==null?p.style.fillOpacity=`${L+(O-L)*c}`:O!==null&&(p.style.fillOpacity=`${O}`),I&&p.tagName.toLowerCase()==="path"&&_[E]&&p.setAttribute("d",Ye(_[E],I,c)),E===0&&(V?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(W=false);}),N){let p=Y(J(l,U,ce,y));for(let E in N){let v=parseFloat(E);p>=v&&!me.has(v)&&(me.add(v),N[E]?.());}}!Z&&J(l,U,ce,y)>0&&(Z=true,ae?.()),W&&!F?(F=true,R?.(),le<(oe==="infinite"?1/0:oe??0)&&(le++,fe=setTimeout(()=>{re=-1,Z=false,F=false,me.clear(),We();},j))):!W&&!K&&(F=false),C=requestAnimationFrame(qe);}let je=new IntersectionObserver(s=>{s.forEach(l=>{Re=l.isIntersecting,Re&&!H?C=requestAnimationFrame(qe):cancelAnimationFrame(C);});},{root:k??null,threshold:Oe,rootMargin:Ne}),Xe;function Be(){clearTimeout(Xe),Xe=setTimeout(()=>{T.forEach((s,l)=>{w[l]=Ve(s),s.style.strokeDasharray=`${w[l]}`;}),Ke();},150);}return window.addEventListener("resize",Be),window.addEventListener("orientationchange",Be),se>0?setTimeout(()=>je.observe(e),se):je.observe(e),{destroy(){cancelAnimationFrame(C),clearTimeout(fe),je.disconnect(),window.removeEventListener("resize",Be),window.removeEventListener("orientationchange",Be),clearTimeout(Xe),Ge?.remove();},replay(){re=-1,He=-1,ze=-1,Z=false,F=false,le=0,H=false,me.clear(),clearTimeout(fe),We();},pause(){H=true,cancelAnimationFrame(C);},resume(){H&&(H=false,Re&&(C=requestAnimationFrame(qe)));},seek(s){let l=Math.min(1,Math.max(0,s));ge=l,re=l,H=true,cancelAnimationFrame(C),pt(l,b);},getProgress(){return ge}}}var ot=new Map;function it(e,n){ot.set(e,n);}function at(e){ot.delete(e);}function $t(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function lt(e){let n=[],r=/([\w]+)\(([^)]*)\)/g,t;for(;(t=r.exec(e))!==null;){let o=[],f=[],d=t[2].trim();if(d)for(let i of d.split(/[\s,]+/)){let u=i.match(/^([-+]?[\d.eE]+)(.*)$/);o.push(u?parseFloat(u[1]):0),f.push(u?u[2]:"");}n.push({fn:t[1],nums:o,units:f});}return n}function At(e,n,r){let t=lt(e),o=lt(n);return t.length===0||t.length!==o.length?r<1?e:n:t.map((f,d)=>{let i=o[d];return f.fn!==i.fn||f.nums.length!==i.nums.length?r<1?`${f.fn}(${f.nums.map((u,g)=>`${u}${f.units[g]}`).join(", ")})`:`${i.fn}(${i.nums.map((u,g)=>`${u}${i.units[g]}`).join(", ")})`:`${f.fn}(${f.nums.map((u,g)=>`${u+(i.nums[g]-u)*r}${f.units[g]}`).join(", ")})`}).join(" ")}function ut(e,n,r){if(typeof e=="number"&&typeof n=="number")return String(e+(n-e)*r);let t=String(e),o=String(n);if($t(t))return Me(t,o,r);if(t.includes("("))return At(t,o,r);let f=t.match(/^([-+]?[\d.]+)(.*)$/),d=o.match(/^([-+]?[\d.]+)(.*)$/);if(f&&d){let i=parseFloat(f[1]),u=parseFloat(d[1]);return `${i+(u-i)*r}${f[2]||d[2]}`}return r<1?t:o}function Tt(e){return e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`)}var ct={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Pt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Mt=0;function kt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function _e(e,n){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:t,trigger:o={},easing:f="ease-out",speed:d=1,once:i=false,axis:u="y",scrollContainer:g,native:x=true,onProgress:B,onComplete:b,onEnter:K,onLeave:Ce,onEnterBack:q,onLeaveBack:be}=n,we=window.matchMedia("(prefers-reduced-motion: reduce)").matches,se=typeof f=="function"?f:Ae[f]??Ae["ease-out"],Q=Te(o.start??"top bottom"),ee=Te(o.end??"bottom top"),A=typeof g=="string"?document.querySelector(g):g??null,N=Object.entries(t).map(([a,m])=>({prop:Tt(a),from:Array.isArray(m)?m[0]:"",to:Array.isArray(m)?m[1]:m}));function Ee(){let a=window.getComputedStyle(e);for(let m of N)m.from===""&&(m.from=a.getPropertyValue(m.prop).trim()||"0");}function Oe(){for(let a of N)e.style.setProperty(a.prop,String(a.to));}if(we)return Oe(),b?.(),r;Ee();function Ne(){if(!x||!kt()||typeof f!="string"||!(f in ct)||u!=="y"||A||i||d!==1||B||b||K||Ce||q||be||(o.start??"top bottom").trim()!=="top bottom"||(o.end??"bottom top").trim()!=="bottom top")return false;for(let a of N)if(!Pt.has(a.prop))return false;return true}function oe(){let a=`ssd-a-${++Mt}`,m=N.map(D=>`${D.prop}:${D.from}`).join(";"),P=N.map(D=>`${D.prop}:${D.to}`).join(";"),S=document.createElement("style");S.setAttribute("data-ssd-animate",""),S.textContent=`@keyframes ${a}{from{${m}}to{${P}}}.${a}{animation-name:${a};animation-duration:auto;animation-timing-function:${ct[f]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(S),e.classList.add(a);let L=()=>u==="x"?window.scrollX:window.scrollY,O=()=>u==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(a),S.remove();},replay(){e.classList.remove(a),e.offsetWidth,e.classList.add(a);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(D){let T=Math.min(1,Math.max(0,D));e.classList.remove(a);for(let w of N)e.style.setProperty(w.prop,ut(w.from,w.to,T));},getProgress(){let D=e.getBoundingClientRect(),T=L(),w=O(),{tStart:_,tEnd:U}=Pe({top:D.top,height:D.height},T,w,Q,ee);return se(J(T,_,U,d))}}}if(Ne())return oe();let j=0,I=0,X=0,ve=false,ie=false,ue=-1,V=0,ae=false,R=NaN,pe=()=>A?u==="x"?A.scrollLeft:A.scrollTop:u==="x"?window.scrollX:window.scrollY,Fe=()=>A?u==="x"?A.clientWidth:A.clientHeight:u==="x"?window.innerWidth:window.innerHeight;function ke(){let a=e.getBoundingClientRect(),m,P;if(A){let L=A.getBoundingClientRect();m=u==="x"?a.left-L.left+A.scrollLeft:a.top-L.top+A.scrollTop,P=u==="x"?a.width:a.height;}else m=u==="x"?a.left:a.top,P=u==="x"?a.width:a.height;let S=Pe({top:m,height:P},pe(),Fe(),Q,ee);j=S.tStart,I=S.tEnd;}function de(a){e.style.setProperty("--scroll-draw-progress",String(a));for(let m of N)e.style.setProperty(m.prop,ut(m.from,m.to,a));B?.(a);}function te(a){if(isNaN(R)){R=a;return}R<=0&&a>0?K?.():R>0&&a<=0&&be?.(),R<1&&a>=1?Ce?.():R>=1&&a<1&&q?.(),R=a;}function Y(){if(!ve||ie)return;let a=I===j?0:(pe()-j)/(I-j);te(a);let m=se(J(pe(),j,I,d));i&&(ue=Math.max(ue,m),m=ue),V=m,de(m),m>=1&&!ae?(ae=true,b?.()):m<1&&!i&&(ae=false),X=requestAnimationFrame(Y);}ke();{let a=se(J(pe(),j,I,d));i&&a>0&&(ue=a),V=a,de(a);}let Le=new IntersectionObserver(a=>{a.forEach(m=>{ve=m.isIntersecting,ve&&!ie?X=requestAnimationFrame(Y):cancelAnimationFrame(X);});},{root:A??null}),Se;function k(){clearTimeout(Se),Se=setTimeout(ke,150);}return window.addEventListener("resize",k),window.addEventListener("orientationchange",k),Le.observe(e),it(e,{type:"animate",getProgress:()=>V,getTrigger:()=>({tStart:j,tEnd:I})}),{destroy(){cancelAnimationFrame(X),Le.disconnect(),window.removeEventListener("resize",k),window.removeEventListener("orientationchange",k),clearTimeout(Se),at(e);},replay(){ue=-1,ae=false,V=0,ie=false,de(0);},pause(){ie=true,cancelAnimationFrame(X);},resume(){ie&&(ie=false,ve&&(X=requestAnimationFrame(Y)));},seek(a){let m=Math.min(1,Math.max(0,a));V=m,ue=m,ie=true,cancelAnimationFrame(X),de(m);},getProgress(){return V}}}var ft={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function mt(e,n={}){if(typeof window>"u")return ft;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),ft;let{speed:t=.3,axis:o="y",easing:f="linear",trigger:d,onProgress:i}=n,u=r.getBoundingClientRect(),g=o==="x"?u.width:u.height,x=t*g;return _e(r,{props:o==="x"?{transform:["translateX(0px)",`translateX(${-x}px)`]}:{transform:["translateY(0px)",`translateY(${-x}px)`]},trigger:d??{start:"top bottom",end:"bottom top"},easing:f,native:false,onProgress:i})}function Ie(e){return e.map(n=>typeof n=="string"?document.querySelector(n):n).filter(n=>n!==null)}var he={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function qt(e,n={}){if(typeof window>"u")return he;let r=Ie(e).map(t=>Ue(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}function Bt(e,n={}){if(typeof window>"u")return he;let r=Ie(e);if(r.length===0)return he;let t=0,o=[];function f(i){return Ue(r[i],{...n,once:true,onComplete(){n.onComplete?.(),t=i+1,o[t]?.resume();}})}function d(){r.forEach((i,u)=>{o[u]=f(u);});for(let i=1;i<o.length;i++)o[i].pause();}return d(),{destroy(){o.forEach(i=>i.destroy()),o.length=0;},replay(){o.forEach(i=>i.destroy()),o.length=0,t=0,d();},pause(){o[t]?.pause();},resume(){o[t]?.resume();},seek(i){o[t]?.seek(i);},getProgress(){return o[t]?.getProgress()??0}}}function Vt(e,n){if(typeof window>"u")return he;let r=Ie(e).map(t=>_e(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}function _t(e,n){if(typeof window>"u")return he;let r=Ie(e);if(r.length===0)return he;let t=0,o=[];function f(i){return _e(r[i],{...n,once:true,onComplete(){n.onComplete?.(),t=i+1,o[t]?.resume();}})}function d(){r.forEach((i,u)=>{o[u]=f(u);});for(let i=1;i<o.length;i++)o[i].pause();}return d(),{destroy(){o.forEach(i=>i.destroy()),o.length=0;},replay(){o.forEach(i=>i.destroy()),o.length=0,t=0,d();},pause(){o[t]?.pause();},resume(){o[t]?.resume();},seek(i){o[t]?.seek(i);},getProgress(){return o[t]?.getProgress()??0}}}function Gt(e,n={}){if(typeof window>"u")return he;let r=Ie(e).map(t=>mt(t,n));return {destroy(){r.forEach(t=>t.destroy());},replay(){r.forEach(t=>t.replay());},pause(){r.forEach(t=>t.pause());},resume(){r.forEach(t=>t.resume());},seek(t){r.forEach(o=>o.seek(t));},getProgress(){return r[0]?.getProgress()??0}}}export{Vt as scrollAnimateGroup,_t as scrollAnimateSequence,qt as scrollDrawGroup,Bt as scrollDrawSequence,Gt as scrollParallaxGroup};
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';function yt({tension:e=2.5,friction:t=2.2}={}){return r=>1-Math.cos(r*Math.PI*e)*Math.pow(1-r,t)}function tt({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,t)),u=Math.sqrt(n),i=0,d=[];for(let f=0;f<r;f++){let T=Math.pow(u,f);d.push(T),i+=T;}let m=[0],a=0;for(let f=0;f<r;f++)a+=d[f]/i,m.push(a);return f=>{if(f<=0)return 0;if(f>=1)return 1;for(let T=0;T<r;T++)if(f<=m[T+1]){let F=(f-m[T])/(m[T+1]-m[T]);if(T===0)return F*(2-F);let E=1-Math.pow(n,T);return E+(1-E)*(2*F-1)*(2*F-1)}return 1}}function rt({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),n=Math.max(.1,t),u=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-u)*(2*Math.PI)/n)+1}var te={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:tt(),elastic:rt()};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 Ke(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 Qe(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 Ne(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 ht(e,t,r){return Math.min(r,Math.max(t,e))}function re(e,t,r,n){return r===t?0:ht((e-t)/(r-t)*n,0,1)}function xe(e,t,r,n,u){let i=Ke(e.top,e.height,t,n.element)-Qe(n.viewport,r),d=Ke(e.top,e.height,t,u.element)-Qe(u.viewport,r);return {tStart:i,tEnd:d}}function et(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=et(e),u=et(t);return !n||!u?e:`rgb(${Math.round(n[0]+(u[0]-n[0])*r)},${Math.round(n[1]+(u[1]-n[1])*r)},${Math.round(n[2]+(u[2]-n[2])*r)})`}var Be={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 nt(e,t){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,t);}var ot={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},bt=0;function wt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function vt(e){let t=e.getAttribute("stroke"),r=e.getAttribute("fill");!t||t==="none"?nt("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&nt("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Et(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 u(){let i=r==="x"?window.scrollX:window.scrollY,d=e-i,m=t-i,a=r==="x";n.innerHTML=`
2
- <div style="position:absolute;${a?`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;${a?`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",u,{passive:true}),u(),n}function Ge(e,t,r){let n=(t.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),u=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,i=>{let d=parseFloat(i),m=n[u++]??d;return String(+(d+(m-d)*r).toFixed(4))})}function st(e,t={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...n}=t,u=r?{...Be[r],...n}:n,i=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:d="path, polyline, line, polygon, rect, circle",speed:m=1,fade:a=false,easing:f="linear",trigger:T={},stagger:F=0,direction:E="forward",once:X=false,debug:ce=false,axis:A="y",scrollContainer:$,autoReverse:c=false,delay:h=0,strokeColor:b,strokeWidth:N,fillOpacity:z,waypoints:_,velocityScale:B=false,threshold:oe=0,rootMargin:U="0px",repeat:Z=0,repeatDelay:J=0,morphTo:k,clip:K,autoplay:de=false,duration:ge=1e3,native:be=true,onProgress:g,onStart:R,onComplete:ue}=u,ie=K===true?"left":typeof K=="string"?K:false,ae=typeof f=="function"?f:te[f]??te.linear,Ae=he(T.start??"top bottom"),l=he(T.end??"bottom top"),p=typeof $=="string"?document.querySelector($):$??null,G=Array.isArray(b)?b[0]:null,C=Array.isArray(b)?b[1]:typeof b=="string"?b:null,H=Array.isArray(N)?N[0]:null,j=Array.isArray(N)?N[1]:typeof N=="number"?N:null,M=Array.isArray(z)?z[0]:null,I=Array.isArray(z)?z[1]:typeof z=="number"?z:null;function ne(o){let s=o*100;switch(ie){case "right":return `inset(0 0 0 ${100-s}%)`;case "top":return `inset(0 0 ${100-s}% 0)`;case "bottom":return `inset(${100-s}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let V=ie?[]:Array.from(e.querySelectorAll(d)),D=[],me=[],we=0,ve=0,Y=false,le=false,W=0,Ce=false,fe=-1,Le=-1,Q=false,Te=0,ye=0,Ee,Ve=null,Se=new Set,Ie=-1,Ue=performance.now();function ke(){return p?A==="x"?p.scrollLeft:p.scrollTop:A==="x"?window.scrollX:window.scrollY}function Ze(){return p?A==="x"?p.clientWidth:p.clientHeight:A==="x"?window.innerWidth:window.innerHeight}function Je(){let o=e.getBoundingClientRect(),s,v,O;if(p){let ee=p.getBoundingClientRect();s=A==="x"?o.left-ee.left+p.scrollLeft:o.top-ee.top+p.scrollTop,v=A==="x"?o.width:o.height,O=ke();}else s=A==="x"?o.left:o.top,v=A==="x"?o.width:o.height,O=ke();let se=xe({top:s,height:v},O,Ze(),Ae,l);we=se.tStart,ve=se.tEnd,ce&&process.env.NODE_ENV!=="production"&&(Ve?.remove(),Ve=Et(we,ve,A));}function ft(o,s){if(e.style.setProperty("--scroll-draw-progress",String(o)),ie){let v=s==="reverse"?1-o:o;e.style.clipPath=ne(v);return}V.forEach((v,O)=>{v.style.strokeDashoffset=s==="reverse"?`${D[O]*o}`:`${D[O]*(1-o)}`,a&&(v.style.opacity=s==="reverse"?`${1-o}`:`${o}`),G&&C?v.style.stroke=Pe(G,C,o):C&&(v.style.stroke=C),H!==null&&j!==null?v.style.strokeWidth=`${H+(j-H)*o}`:j!==null&&(v.style.strokeWidth=`${j}`),M!==null&&I!==null?v.style.fillOpacity=`${M+(I-M)*o}`:I!==null&&(v.style.fillOpacity=`${I}`),k&&v.tagName.toLowerCase()==="path"&&me[O]&&v.setAttribute("d",Ge(me[O],k,o));});}function De(){if(e.style.setProperty("--scroll-draw-progress","0"),ie){e.style.clipPath=ne(0);return}V.forEach((o,s)=>{o.style.strokeDasharray=`${D[s]}`,o.style.strokeDashoffset=E==="reverse"?"0":`${D[s]}`,a?o.style.opacity=E==="reverse"?"1":"0":o.style.opacity="",G&&(o.style.stroke=G),H!==null&&(o.style.strokeWidth=`${H}`),M!==null&&(o.style.fillOpacity=`${M}`),k&&o.tagName.toLowerCase()==="path"&&me[s]&&o.setAttribute("d",me[s]);});}if(V.forEach(o=>{vt(o);let s=Ne(o);D.push(s),o.tagName.toLowerCase()==="path"?me.push(o.getAttribute("d")??""):me.push(""),i?(o.style.strokeDasharray=`${s}`,o.style.strokeDashoffset=E==="reverse"?`${s}`:"0",a&&(o.style.opacity="1"),C&&(o.style.stroke=C),j!==null&&(o.style.strokeWidth=`${j}`),I!==null&&(o.style.fillOpacity=`${I}`),k&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",k)):(o.style.strokeDasharray=`${s}`,o.style.strokeDashoffset=E==="reverse"?"0":`${s}`,a?o.style.opacity=E==="reverse"?"1":"0":o.style.opacity="",G&&(o.style.stroke=G),H!==null&&(o.style.strokeWidth=`${H}`),M!==null&&(o.style.fillOpacity=`${M}`));}),ie){if(i)return e.style.clipPath=ne(1),ue?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ne(0);}else if(i)return ue?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function pt(){return !(be===false||!wt()||!V.length||typeof f!="string"||!(f in ot)||ie||A!=="y"||p||m!==1||F!==0||X||c||B!==false||k||_||Z||h>0||g||R||ue||b!=null||N!=null||z!=null||(T.start??"top bottom").trim()!=="top bottom"||(T.end??"bottom top").trim()!=="bottom top")}function dt(){let o=`svg-scroll-draw-${++bt}`,s=E==="reverse"?"0":"var(--ssd-len)",v=E==="reverse"?"var(--ssd-len)":"0",O=`stroke-dashoffset:${s};`,se=`stroke-dashoffset:${v};`;a&&(O+=`opacity:${E==="reverse"?1:0};`,se+=`opacity:${E==="reverse"?0:1};`);let ee=document.createElement("style");ee.setAttribute("data-svg-scroll-draw",""),ee.textContent=`@keyframes ${o}{from{${O}}to{${se}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${ot[f]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(ee);function w(y,x){y.style.setProperty("--ssd-len",String(D[x])),y.style.strokeDasharray=`${D[x]}`,y.style.strokeDashoffset="",y.style.opacity="",y.style.animationPlayState="",y.classList.add(o);}V.forEach(w);let P=false,q=-1;function S(){if(q>=0)return q;let y=e.getBoundingClientRect(),{tStart:x,tEnd:L}=xe({top:y.top,height:y.height},ke(),Ze(),Ae,l);return ae(re(ke(),x,L,m))}return {destroy(){V.forEach(y=>{y.classList.remove(o),y.style.removeProperty("--ssd-len"),y.style.animationPlayState="";}),ee.remove();},replay(){P=false,q=-1,V.forEach(w);},pause(){P=true,V.forEach(y=>{y.style.animationPlayState="paused";});},resume(){P&&(P=false,V.forEach(y=>{y.style.animationPlayState="running";}));},seek(y){let x=Math.min(1,Math.max(0,y));q=x,P=true,V.forEach((L,$e)=>{L.classList.remove(o),L.style.strokeDashoffset=E==="reverse"?`${D[$e]*x}`:`${D[$e]*(1-x)}`,a&&(L.style.opacity=E==="reverse"?`${1-x}`:`${x}`);});},getProgress(){return S()}}}if(pt())return dt();function gt(){let o=Math.max(1,ge),s=0,v=0;function O(S){let y=true;if(ie){let x=Math.min(1,Math.max(0,S/o)),L=ae(x);Te=L,e.style.setProperty("--scroll-draw-progress",String(L)),e.style.clipPath=ne(E==="reverse"?1-L:L),g?.(L),x<1&&(y=false);}else V.forEach((x,L)=>{let $e=L*F*o,Me=Math.min(1,Math.max(0,(S-$e)/o)),pe=ae(Me);x.style.strokeDashoffset=E==="reverse"?`${D[L]*pe}`:`${D[L]*(1-pe)}`,a&&(x.style.opacity=E==="reverse"?`${1-pe}`:`${pe}`),G&&C?x.style.stroke=Pe(G,C,pe):C&&(x.style.stroke=C),H!==null&&j!==null?x.style.strokeWidth=`${H+(j-H)*pe}`:j!==null&&(x.style.strokeWidth=`${j}`),M!==null&&I!==null?x.style.fillOpacity=`${M+(I-M)*pe}`:I!==null&&(x.style.fillOpacity=`${I}`),k&&x.tagName.toLowerCase()==="path"&&me[L]&&x.setAttribute("d",Ge(me[L],k,pe)),L===0&&(g?.(pe),e.style.setProperty("--scroll-draw-progress",String(pe))),Me<1&&(y=false);});if(_){let x=Math.min(1,Math.max(0,S/o)),L=ae(x);for(let $e in _){let Me=parseFloat($e);L>=Me&&!Se.has(Me)&&(Se.add(Me),_[$e]?.());}}return y}function se(S){if(Q)return;let y=S-s;le||(le=true,R?.());let x=O(y);if(x&&!Y){Y=true,O(o*(1+Math.max(0,V.length-1)*F)),ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{s=performance.now(),le=false,Y=false,Se.clear(),De(),W=requestAnimationFrame(se);},J));return}x||(W=requestAnimationFrame(se));}function ee(){cancelAnimationFrame(W),clearTimeout(Ee),s=performance.now(),v=0,Q=false,le=false,Y=false,ye=0,Se.clear(),De(),W=requestAnimationFrame(se);}let w=new IntersectionObserver(S=>{S.forEach(y=>{y.isIntersecting&&!(X&&Y)?ee():!y.isIntersecting&&!X&&!Y&&(cancelAnimationFrame(W),clearTimeout(Ee),s=null);});},{root:p??null,threshold:oe,rootMargin:U}),P;function q(){clearTimeout(P),P=setTimeout(()=>{V.forEach((S,y)=>{D[y]=Ne(S),S.style.strokeDasharray=`${D[y]}`;});},150);}return window.addEventListener("resize",q),window.addEventListener("orientationchange",q),h>0?setTimeout(()=>w.observe(e),h):w.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(Ee),w.disconnect(),window.removeEventListener("resize",q),window.removeEventListener("orientationchange",q),clearTimeout(P);},replay(){ye=0,ee();},pause(){Q||(Q=true,v=performance.now()-s,cancelAnimationFrame(W));},resume(){Q&&(Q=false,s=performance.now()-v,W=requestAnimationFrame(se));},seek(S){let y=Math.min(1,Math.max(0,S));Te=y,Q=true,v=y*o,s=performance.now()-v,cancelAnimationFrame(W),O(v);},getProgress(){return Te}}}if(de)return gt();Je();function Oe(){if(!Ce||Q)return;let o=performance.now(),s=ke(),v=m;if(B!==false){let w=o-Ue,P=w>0?Math.abs(s-(Ie<0?s:Ie))/w:0;v=m*Math.max(.2,1+P*(typeof B=="number"?B:1)*.04);}Ie=s,Ue=o;let O=c?Le===-1||s>=Le?"forward":"reverse":E;Le=s;let se=ve-we,ee=true;if(ie){let w=ae(re(s,we,ve,v));X&&!c&&(fe=Math.max(fe,w),w=fe),Te=w,e.style.setProperty("--scroll-draw-progress",String(w));let P=O==="reverse"?1-w:w;e.style.clipPath=ne(P),g?.(w),!le&&re(s,we,ve,v)>0&&(le=true,R?.()),w>=1&&!Y?(Y=true,ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{fe=-1,le=false,Y=false,e.style.clipPath=ne(0);},J))):w<1&&!X&&(Y=false),W=requestAnimationFrame(Oe);return}if(V.forEach((w,P)=>{let q=P*F*se,S=ae(re(s,we+q,ve+q,v));X&&!c&&(fe=Math.max(fe,S),S=fe),Te=S,w.style.strokeDashoffset=O==="reverse"?`${D[P]*S}`:`${D[P]*(1-S)}`,a&&(w.style.opacity=O==="reverse"?`${1-S}`:`${S}`),G&&C?w.style.stroke=Pe(G,C,S):C&&(w.style.stroke=C),H!==null&&j!==null?w.style.strokeWidth=`${H+(j-H)*S}`:j!==null&&(w.style.strokeWidth=`${j}`),M!==null&&I!==null?w.style.fillOpacity=`${M+(I-M)*S}`:I!==null&&(w.style.fillOpacity=`${I}`),k&&w.tagName.toLowerCase()==="path"&&me[P]&&w.setAttribute("d",Ge(me[P],k,S)),P===0&&(g?.(S),e.style.setProperty("--scroll-draw-progress",String(S))),S<1&&(ee=false);}),_){let w=ae(re(s,we,ve,v));for(let P in _){let q=parseFloat(P);w>=q&&!Se.has(q)&&(Se.add(q),_[P]?.());}}!le&&re(s,we,ve,v)>0&&(le=true,R?.()),ee&&!Y?(Y=true,ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{fe=-1,le=false,Y=false,Se.clear(),De();},J))):!ee&&!X&&(Y=false),W=requestAnimationFrame(Oe);}let We=new IntersectionObserver(o=>{o.forEach(s=>{Ce=s.isIntersecting,Ce&&!Q?W=requestAnimationFrame(Oe):cancelAnimationFrame(W);});},{root:p??null,threshold:oe,rootMargin:U}),_e;function Fe(){clearTimeout(_e),_e=setTimeout(()=>{V.forEach((o,s)=>{D[s]=Ne(o),o.style.strokeDasharray=`${D[s]}`;}),Je();},150);}return window.addEventListener("resize",Fe),window.addEventListener("orientationchange",Fe),h>0?setTimeout(()=>We.observe(e),h):We.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(Ee),We.disconnect(),window.removeEventListener("resize",Fe),window.removeEventListener("orientationchange",Fe),clearTimeout(_e),Ve?.remove();},replay(){fe=-1,Le=-1,Ie=-1,le=false,Y=false,ye=0,Q=false,Se.clear(),clearTimeout(Ee),De();},pause(){Q=true,cancelAnimationFrame(W);},resume(){Q&&(Q=false,Ce&&(W=requestAnimationFrame(Oe)));},seek(o){let s=Math.min(1,Math.max(0,o));Te=s,fe=s,Q=true,cancelAnimationFrame(W),ft(s,E);},getProgress(){return Te}}}var it=new Map;function Re(e,t){it.set(e,t);}function He(e){it.delete(e);}function St(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function at(e){let t=[],r=/([\w]+)\(([^)]*)\)/g,n;for(;(n=r.exec(e))!==null;){let u=[],i=[],d=n[2].trim();if(d)for(let m of d.split(/[\s,]+/)){let a=m.match(/^([-+]?[\d.eE]+)(.*)$/);u.push(a?parseFloat(a[1]):0),i.push(a?a[2]:"");}t.push({fn:n[1],nums:u,units:i});}return t}function xt(e,t,r){let n=at(e),u=at(t);return n.length===0||n.length!==u.length?r<1?e:t:n.map((i,d)=>{let m=u[d];return i.fn!==m.fn||i.nums.length!==m.nums.length?r<1?`${i.fn}(${i.nums.map((a,f)=>`${a}${i.units[f]}`).join(", ")})`:`${m.fn}(${m.nums.map((a,f)=>`${a}${m.units[f]}`).join(", ")})`:`${i.fn}(${i.nums.map((a,f)=>`${a+(m.nums[f]-a)*r}${i.units[f]}`).join(", ")})`}).join(" ")}function lt(e,t,r){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*r);let n=String(e),u=String(t);if(St(n))return Pe(n,u,r);if(n.includes("("))return xt(n,u,r);let i=n.match(/^([-+]?[\d.]+)(.*)$/),d=u.match(/^([-+]?[\d.]+)(.*)$/);if(i&&d){let m=parseFloat(i[1]),a=parseFloat(d[1]);return `${m+(a-m)*r}${i[2]||d[2]}`}return r<1?n:u}function At(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var ct={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Tt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),$t=0;function Mt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function ut(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:n,trigger:u={},easing:i="ease-out",speed:d=1,once:m=false,axis:a="y",scrollContainer:f,native:T=true,onProgress:F,onComplete:E}=t,X=window.matchMedia("(prefers-reduced-motion: reduce)").matches,ce=typeof i=="function"?i:te[i]??te["ease-out"],A=he(u.start??"top bottom"),$=he(u.end??"bottom top"),c=typeof f=="string"?document.querySelector(f):f??null,h=Object.entries(n).map(([l,p])=>({prop:At(l),from:Array.isArray(p)?p[0]:"",to:Array.isArray(p)?p[1]:p}));function b(){let l=window.getComputedStyle(e);for(let p of h)p.from===""&&(p.from=l.getPropertyValue(p.prop).trim()||"0");}function N(){for(let l of h)e.style.setProperty(l.prop,String(l.to));}if(X)return N(),E?.(),r;b();function z(){if(!T||!Mt()||typeof i!="string"||!(i in ct)||a!=="y"||c||m||d!==1||F||E||(u.start??"top bottom").trim()!=="top bottom"||(u.end??"bottom top").trim()!=="bottom top")return false;for(let l of h)if(!Tt.has(l.prop))return false;return true}function _(){let l=`ssd-a-${++$t}`,p=h.map(M=>`${M.prop}:${M.from}`).join(";"),G=h.map(M=>`${M.prop}:${M.to}`).join(";"),C=document.createElement("style");C.setAttribute("data-ssd-animate",""),C.textContent=`@keyframes ${l}{from{${p}}to{${G}}}.${l}{animation-name:${l};animation-duration:auto;animation-timing-function:${ct[i]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(C),e.classList.add(l);let H=()=>a==="x"?window.scrollX:window.scrollY,j=()=>a==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(l),C.remove();},replay(){e.classList.remove(l),e.offsetWidth,e.classList.add(l);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(M){let I=Math.min(1,Math.max(0,M));e.classList.remove(l);for(let ne of h)e.style.setProperty(ne.prop,lt(ne.from,ne.to,I));},getProgress(){let M=e.getBoundingClientRect(),I=H(),ne=j(),{tStart:V,tEnd:D}=xe({top:M.top,height:M.height},I,ne,A,$);return ce(re(I,V,D,d))}}}if(z())return _();let B=0,oe=0,U=0,Z=false,J=false,k=-1,K=0,de=false,ge=()=>c?a==="x"?c.scrollLeft:c.scrollTop:a==="x"?window.scrollX:window.scrollY,be=()=>c?a==="x"?c.clientWidth:c.clientHeight:a==="x"?window.innerWidth:window.innerHeight;function g(){let l=e.getBoundingClientRect(),p,G;if(c){let H=c.getBoundingClientRect();p=a==="x"?l.left-H.left+c.scrollLeft:l.top-H.top+c.scrollTop,G=a==="x"?l.width:l.height;}else p=a==="x"?l.left:l.top,G=a==="x"?l.width:l.height;let C=xe({top:p,height:G},ge(),be(),A,$);B=C.tStart,oe=C.tEnd;}function R(l){e.style.setProperty("--scroll-draw-progress",String(l));for(let p of h)e.style.setProperty(p.prop,lt(p.from,p.to,l));F?.(l);}function ue(){if(!Z||J)return;let l=ce(re(ge(),B,oe,d));m&&(k=Math.max(k,l),l=k),K=l,R(l),l>=1&&!de?(de=true,E?.()):l<1&&!m&&(de=false),U=requestAnimationFrame(ue);}g();{let l=ce(re(ge(),B,oe,d));m&&l>0&&(k=l),K=l,R(l);}let ie=new IntersectionObserver(l=>{l.forEach(p=>{Z=p.isIntersecting,Z&&!J?U=requestAnimationFrame(ue):cancelAnimationFrame(U);});},{root:c??null}),ae;function Ae(){clearTimeout(ae),ae=setTimeout(g,150);}return window.addEventListener("resize",Ae),window.addEventListener("orientationchange",Ae),ie.observe(e),Re(e,{type:"animate",getProgress:()=>K,getTrigger:()=>({tStart:B,tEnd:oe})}),{destroy(){cancelAnimationFrame(U),ie.disconnect(),window.removeEventListener("resize",Ae),window.removeEventListener("orientationchange",Ae),clearTimeout(ae),He(e);},replay(){k=-1,de=false,K=0,J=false,R(0);},pause(){J=true,cancelAnimationFrame(U);},resume(){J&&(J=false,Z&&(U=requestAnimationFrame(ue)));},seek(l){let p=Math.min(1,Math.max(0,l));K=p,k=p,J=true,cancelAnimationFrame(U),R(p);},getProgress(){return K}}}var qe={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Pt(e,t){if(typeof window>"u")return qe;let r=typeof e=="string"?document.querySelector(e):e;return r?ut(r,t):(process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollAnimate: element not found:",e),qe)}function kt(e,t={}){if(typeof window>"u")return qe;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),qe;let{speed:n=.3,axis:u="y",easing:i="linear",trigger:d,onProgress:m}=t,a=r.getBoundingClientRect(),f=u==="x"?a.width:a.height,T=n*f;return ut(r,{props:u==="x"?{transform:["translateX(0px)",`translateX(${-T}px)`]}:{transform:["translateY(0px)",`translateY(${-T}px)`]},trigger:d??{start:"top bottom",end:"bottom top"},easing:i,native:false,onProgress:m})}var je={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ct(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:u=0,to:i,format:d,easing:m="ease-out",trigger:a={},once:f=true,decimals:T,onComplete:F}=t,E=T!==void 0?g=>g.toFixed(T):d??(g=>String(Math.round(g))),X=typeof m=="function"?m:te[m]??te["ease-out"],ce=he(a.start??"top 80%"),A=he(a.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=E(i),F?.(),je;n.textContent=E(u);let c=0,h=0,b=0,N=false,z=false,_=-1,B=0,oe=false,U=()=>window.scrollY,Z=()=>window.innerHeight;function J(){let g=n.getBoundingClientRect(),R=xe({top:g.top,height:g.height},U(),Z(),ce,A);c=R.tStart,h=R.tEnd;}function k(g){n.textContent=E(u+(i-u)*g),n.style.setProperty("--scroll-draw-progress",String(g));}function K(){if(!N||z)return;let g=X(re(U(),c,h,1));f&&(_=Math.max(_,g),g=_),B=g,k(g),g>=1&&!oe?(oe=true,F?.()):g<1&&!f&&(oe=false),b=requestAnimationFrame(K);}J();{let g=X(re(U(),c,h,1));f&&g>0&&(_=g),B=g,k(g);}let de=new IntersectionObserver(g=>{g.forEach(R=>{N=R.isIntersecting,N&&!z?b=requestAnimationFrame(K):cancelAnimationFrame(b);});}),ge;function be(){clearTimeout(ge),ge=setTimeout(J,150);}return window.addEventListener("resize",be),window.addEventListener("orientationchange",be),de.observe(n),Re(n,{type:"counter",getProgress:()=>B,getTrigger:()=>({tStart:c,tEnd:h})}),{destroy(){cancelAnimationFrame(b),de.disconnect(),window.removeEventListener("resize",be),window.removeEventListener("orientationchange",be),clearTimeout(ge),He(n);},replay(){_=-1,oe=false,B=0,z=false,k(0);},pause(){z=true,cancelAnimationFrame(b);},resume(){z&&(z=false,N&&(b=requestAnimationFrame(K)));},seek(g){let R=Math.min(1,Math.max(0,g));B=R,_=R,z=true,cancelAnimationFrame(b),k(R);},getProgress(){return B}}}var mt="http://www.w3.org/2000/svg",Lt="cinematic-photo",Xe=e=>e<0?0:e>1?1:e;function ze(e){let t=parseFloat(e);return Number.isFinite(t)?Xe(t/100):0}function It(e){return te[e]??te.linear}var Dt={destroy:()=>{},getProgress:()=>0},Ye=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 Dt;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 u=[];for(let A of t.scenes){if(A.background){let c=document.createElement("img");c.id=Lt,c.src=A.background,c.alt="",c.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(c);}let $=A.animations.filter(c=>c.type==="draw");if($.length){let c=document.createElementNS(mt,"svg");c.setAttribute("viewBox",`0 0 ${t.canvas.width} ${t.canvas.height}`),c.setAttribute("preserveAspectRatio","xMidYMid meet"),c.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(c);for(let h of $){let b=document.createElementNS(mt,"path");b.id=h.target.replace(/^#/,""),b.setAttribute("d",h.d),b.setAttribute("fill","none"),b.setAttribute("stroke",h.stroke),b.setAttribute("stroke-width",String(h.strokeWidth)),b.setAttribute("stroke-linecap","round"),b.setAttribute("stroke-linejoin","round");let N=h.length||b.getTotalLength?.()||0;b.style.strokeDasharray=String(N),b.style.strokeDashoffset=String(N),c.appendChild(b),u.push({kind:"draw",el:b,start:ze(h.start),end:ze(h.end),ease:It(h.easing),length:N});}}for(let c of A.animations){if(c.type!=="fade")continue;let h=n.querySelector(c.target)??document.querySelector(c.target);h&&(h.style.opacity=String(c.from),u.push({kind:"fade",el:h,start:ze(c.start),end:ze(c.end),ease:te["ease-in-out"]??te.linear,from:c.from,to:c.to}));}}let i=0,d=()=>{let A=r.offsetHeight-window.innerHeight;return A<=0?r.getBoundingClientRect().top<=0?1:0:Xe(-r.getBoundingClientRect().top/A)},m=A=>{for(let $ of u){let c=$.end-$.start,h=c<=0?A>=$.end?1:0:Xe((A-$.start)/c),b=$.ease(h);$.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 m(1),{destroy:()=>{},getProgress:()=>1};let a=0,f=false,T=false,F=()=>{i=d(),m(i),f&&(a=requestAnimationFrame(F));},E=()=>{f||(f=true,a=requestAnimationFrame(F));},X=()=>{f=false,cancelAnimationFrame(a);},ce=new IntersectionObserver(A=>{for(let $ of A)T=$.isIntersecting,T?E():X();},{threshold:0});return ce.observe(n),i=d(),m(i),{destroy(){X(),ce.disconnect();},getProgress:()=>i}}};function Ut(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?st(n,t):(console.warn("[svg-scroll-draw] Container not found:",e),r)}
4
- exports.Cinematic=Ye;exports.PRESETS=Be;exports.createBounce=tt;exports.createElastic=rt;exports.createSpring=yt;exports.scrollAnimate=Pt;exports.scrollCounter=Ct;exports.scrollDraw=Ut;exports.scrollParallax=kt;
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;
package/dist/index.d.mts CHANGED
@@ -71,6 +71,14 @@ interface ScrollDrawOptions {
71
71
  onProgress?: (alpha: number) => void;
72
72
  onStart?: () => void;
73
73
  onComplete?: () => void;
74
+ /** Fires when scroll position enters the trigger zone (scrolling forward). */
75
+ onEnter?: () => void;
76
+ /** Fires when scroll position exits the trigger zone at the end (scrolling forward). */
77
+ onLeave?: () => void;
78
+ /** Fires when scroll position re-enters the trigger zone from the end (scrolling back). */
79
+ onEnterBack?: () => void;
80
+ /** Fires when scroll position exits the trigger zone at the start (scrolling back). */
81
+ onLeaveBack?: () => void;
74
82
  /**
75
83
  * Trigger the animation when the element enters the viewport instead of
76
84
  * tying it to scroll position. The draw runs over `duration` milliseconds,
@@ -183,6 +191,14 @@ interface ScrollAnimateOptions {
183
191
  native?: boolean;
184
192
  onProgress?: (alpha: number) => void;
185
193
  onComplete?: () => void;
194
+ /** Fires when scroll enters the trigger zone (scrolling forward). */
195
+ onEnter?: () => void;
196
+ /** Fires when scroll exits the trigger zone at the end (scrolling forward). */
197
+ onLeave?: () => void;
198
+ /** Fires when scroll re-enters the trigger zone from the end (scrolling back). */
199
+ onEnterBack?: () => void;
200
+ /** Fires when scroll exits the trigger zone at the start (scrolling back). */
201
+ onLeaveBack?: () => void;
186
202
  }
187
203
  interface ScrollParallaxOptions {
188
204
  speed?: number;
package/dist/index.d.ts CHANGED
@@ -71,6 +71,14 @@ interface ScrollDrawOptions {
71
71
  onProgress?: (alpha: number) => void;
72
72
  onStart?: () => void;
73
73
  onComplete?: () => void;
74
+ /** Fires when scroll position enters the trigger zone (scrolling forward). */
75
+ onEnter?: () => void;
76
+ /** Fires when scroll position exits the trigger zone at the end (scrolling forward). */
77
+ onLeave?: () => void;
78
+ /** Fires when scroll position re-enters the trigger zone from the end (scrolling back). */
79
+ onEnterBack?: () => void;
80
+ /** Fires when scroll position exits the trigger zone at the start (scrolling back). */
81
+ onLeaveBack?: () => void;
74
82
  /**
75
83
  * Trigger the animation when the element enters the viewport instead of
76
84
  * tying it to scroll position. The draw runs over `duration` milliseconds,
@@ -183,6 +191,14 @@ interface ScrollAnimateOptions {
183
191
  native?: boolean;
184
192
  onProgress?: (alpha: number) => void;
185
193
  onComplete?: () => void;
194
+ /** Fires when scroll enters the trigger zone (scrolling forward). */
195
+ onEnter?: () => void;
196
+ /** Fires when scroll exits the trigger zone at the end (scrolling forward). */
197
+ onLeave?: () => void;
198
+ /** Fires when scroll re-enters the trigger zone from the end (scrolling back). */
199
+ onEnterBack?: () => void;
200
+ /** Fires when scroll exits the trigger zone at the start (scrolling back). */
201
+ onLeaveBack?: () => void;
186
202
  }
187
203
  interface ScrollParallaxOptions {
188
204
  speed?: number;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- function yt({tension:e=2.5,friction:t=2.2}={}){return r=>1-Math.cos(r*Math.PI*e)*Math.pow(1-r,t)}function tt({bounces:e=3,decay:t=.5}={}){let r=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,t)),u=Math.sqrt(n),i=0,d=[];for(let f=0;f<r;f++){let T=Math.pow(u,f);d.push(T),i+=T;}let m=[0],a=0;for(let f=0;f<r;f++)a+=d[f]/i,m.push(a);return f=>{if(f<=0)return 0;if(f>=1)return 1;for(let T=0;T<r;T++)if(f<=m[T+1]){let F=(f-m[T])/(m[T+1]-m[T]);if(T===0)return F*(2-F);let E=1-Math.pow(n,T);return E+(1-E)*(2*F-1)*(2*F-1)}return 1}}function rt({amplitude:e=1,period:t=.4}={}){let r=Math.max(1,e),n=Math.max(.1,t),u=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-u)*(2*Math.PI)/n)+1}var te={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:tt(),elastic:rt()};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 Ke(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 Qe(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 Ne(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 ht(e,t,r){return Math.min(r,Math.max(t,e))}function re(e,t,r,n){return r===t?0:ht((e-t)/(r-t)*n,0,1)}function xe(e,t,r,n,u){let i=Ke(e.top,e.height,t,n.element)-Qe(n.viewport,r),d=Ke(e.top,e.height,t,u.element)-Qe(u.viewport,r);return {tStart:i,tEnd:d}}function et(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=et(e),u=et(t);return !n||!u?e:`rgb(${Math.round(n[0]+(u[0]-n[0])*r)},${Math.round(n[1]+(u[1]-n[1])*r)},${Math.round(n[2]+(u[2]-n[2])*r)})`}var Be={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 nt(e,t){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,t);}var ot={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},bt=0;function wt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function vt(e){let t=e.getAttribute("stroke"),r=e.getAttribute("fill");!t||t==="none"?nt("Element has no stroke \u2014 path will not be visible.",e):r&&r!=="none"&&r!=="transparent"&&nt("Element has a fill \u2014 it may obscure the stroke animation.",e);}function Et(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 u(){let i=r==="x"?window.scrollX:window.scrollY,d=e-i,m=t-i,a=r==="x";n.innerHTML=`
2
- <div style="position:absolute;${a?`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;${a?`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",u,{passive:true}),u(),n}function Ge(e,t,r){let n=(t.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),u=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,i=>{let d=parseFloat(i),m=n[u++]??d;return String(+(d+(m-d)*r).toFixed(4))})}function st(e,t={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:r,...n}=t,u=r?{...Be[r],...n}:n,i=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:d="path, polyline, line, polygon, rect, circle",speed:m=1,fade:a=false,easing:f="linear",trigger:T={},stagger:F=0,direction:E="forward",once:X=false,debug:ce=false,axis:A="y",scrollContainer:$,autoReverse:c=false,delay:h=0,strokeColor:b,strokeWidth:N,fillOpacity:z,waypoints:_,velocityScale:B=false,threshold:oe=0,rootMargin:U="0px",repeat:Z=0,repeatDelay:J=0,morphTo:k,clip:K,autoplay:de=false,duration:ge=1e3,native:be=true,onProgress:g,onStart:R,onComplete:ue}=u,ie=K===true?"left":typeof K=="string"?K:false,ae=typeof f=="function"?f:te[f]??te.linear,Ae=he(T.start??"top bottom"),l=he(T.end??"bottom top"),p=typeof $=="string"?document.querySelector($):$??null,G=Array.isArray(b)?b[0]:null,C=Array.isArray(b)?b[1]:typeof b=="string"?b:null,H=Array.isArray(N)?N[0]:null,j=Array.isArray(N)?N[1]:typeof N=="number"?N:null,M=Array.isArray(z)?z[0]:null,I=Array.isArray(z)?z[1]:typeof z=="number"?z:null;function ne(o){let s=o*100;switch(ie){case "right":return `inset(0 0 0 ${100-s}%)`;case "top":return `inset(0 0 ${100-s}% 0)`;case "bottom":return `inset(${100-s}% 0 0 0)`;case "center":return `circle(${o*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let V=ie?[]:Array.from(e.querySelectorAll(d)),D=[],me=[],we=0,ve=0,Y=false,le=false,W=0,Ce=false,fe=-1,Le=-1,Q=false,Te=0,ye=0,Ee,Ve=null,Se=new Set,Ie=-1,Ue=performance.now();function ke(){return p?A==="x"?p.scrollLeft:p.scrollTop:A==="x"?window.scrollX:window.scrollY}function Ze(){return p?A==="x"?p.clientWidth:p.clientHeight:A==="x"?window.innerWidth:window.innerHeight}function Je(){let o=e.getBoundingClientRect(),s,v,O;if(p){let ee=p.getBoundingClientRect();s=A==="x"?o.left-ee.left+p.scrollLeft:o.top-ee.top+p.scrollTop,v=A==="x"?o.width:o.height,O=ke();}else s=A==="x"?o.left:o.top,v=A==="x"?o.width:o.height,O=ke();let se=xe({top:s,height:v},O,Ze(),Ae,l);we=se.tStart,ve=se.tEnd,ce&&process.env.NODE_ENV!=="production"&&(Ve?.remove(),Ve=Et(we,ve,A));}function ft(o,s){if(e.style.setProperty("--scroll-draw-progress",String(o)),ie){let v=s==="reverse"?1-o:o;e.style.clipPath=ne(v);return}V.forEach((v,O)=>{v.style.strokeDashoffset=s==="reverse"?`${D[O]*o}`:`${D[O]*(1-o)}`,a&&(v.style.opacity=s==="reverse"?`${1-o}`:`${o}`),G&&C?v.style.stroke=Pe(G,C,o):C&&(v.style.stroke=C),H!==null&&j!==null?v.style.strokeWidth=`${H+(j-H)*o}`:j!==null&&(v.style.strokeWidth=`${j}`),M!==null&&I!==null?v.style.fillOpacity=`${M+(I-M)*o}`:I!==null&&(v.style.fillOpacity=`${I}`),k&&v.tagName.toLowerCase()==="path"&&me[O]&&v.setAttribute("d",Ge(me[O],k,o));});}function De(){if(e.style.setProperty("--scroll-draw-progress","0"),ie){e.style.clipPath=ne(0);return}V.forEach((o,s)=>{o.style.strokeDasharray=`${D[s]}`,o.style.strokeDashoffset=E==="reverse"?"0":`${D[s]}`,a?o.style.opacity=E==="reverse"?"1":"0":o.style.opacity="",G&&(o.style.stroke=G),H!==null&&(o.style.strokeWidth=`${H}`),M!==null&&(o.style.fillOpacity=`${M}`),k&&o.tagName.toLowerCase()==="path"&&me[s]&&o.setAttribute("d",me[s]);});}if(V.forEach(o=>{vt(o);let s=Ne(o);D.push(s),o.tagName.toLowerCase()==="path"?me.push(o.getAttribute("d")??""):me.push(""),i?(o.style.strokeDasharray=`${s}`,o.style.strokeDashoffset=E==="reverse"?`${s}`:"0",a&&(o.style.opacity="1"),C&&(o.style.stroke=C),j!==null&&(o.style.strokeWidth=`${j}`),I!==null&&(o.style.fillOpacity=`${I}`),k&&o.tagName.toLowerCase()==="path"&&o.setAttribute("d",k)):(o.style.strokeDasharray=`${s}`,o.style.strokeDashoffset=E==="reverse"?"0":`${s}`,a?o.style.opacity=E==="reverse"?"1":"0":o.style.opacity="",G&&(o.style.stroke=G),H!==null&&(o.style.strokeWidth=`${H}`),M!==null&&(o.style.fillOpacity=`${M}`));}),ie){if(i)return e.style.clipPath=ne(1),ue?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ne(0);}else if(i)return ue?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function pt(){return !(be===false||!wt()||!V.length||typeof f!="string"||!(f in ot)||ie||A!=="y"||p||m!==1||F!==0||X||c||B!==false||k||_||Z||h>0||g||R||ue||b!=null||N!=null||z!=null||(T.start??"top bottom").trim()!=="top bottom"||(T.end??"bottom top").trim()!=="bottom top")}function dt(){let o=`svg-scroll-draw-${++bt}`,s=E==="reverse"?"0":"var(--ssd-len)",v=E==="reverse"?"var(--ssd-len)":"0",O=`stroke-dashoffset:${s};`,se=`stroke-dashoffset:${v};`;a&&(O+=`opacity:${E==="reverse"?1:0};`,se+=`opacity:${E==="reverse"?0:1};`);let ee=document.createElement("style");ee.setAttribute("data-svg-scroll-draw",""),ee.textContent=`@keyframes ${o}{from{${O}}to{${se}}}.${o}{animation-name:${o};animation-duration:auto;animation-timing-function:${ot[f]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(ee);function w(y,x){y.style.setProperty("--ssd-len",String(D[x])),y.style.strokeDasharray=`${D[x]}`,y.style.strokeDashoffset="",y.style.opacity="",y.style.animationPlayState="",y.classList.add(o);}V.forEach(w);let P=false,q=-1;function S(){if(q>=0)return q;let y=e.getBoundingClientRect(),{tStart:x,tEnd:L}=xe({top:y.top,height:y.height},ke(),Ze(),Ae,l);return ae(re(ke(),x,L,m))}return {destroy(){V.forEach(y=>{y.classList.remove(o),y.style.removeProperty("--ssd-len"),y.style.animationPlayState="";}),ee.remove();},replay(){P=false,q=-1,V.forEach(w);},pause(){P=true,V.forEach(y=>{y.style.animationPlayState="paused";});},resume(){P&&(P=false,V.forEach(y=>{y.style.animationPlayState="running";}));},seek(y){let x=Math.min(1,Math.max(0,y));q=x,P=true,V.forEach((L,$e)=>{L.classList.remove(o),L.style.strokeDashoffset=E==="reverse"?`${D[$e]*x}`:`${D[$e]*(1-x)}`,a&&(L.style.opacity=E==="reverse"?`${1-x}`:`${x}`);});},getProgress(){return S()}}}if(pt())return dt();function gt(){let o=Math.max(1,ge),s=0,v=0;function O(S){let y=true;if(ie){let x=Math.min(1,Math.max(0,S/o)),L=ae(x);Te=L,e.style.setProperty("--scroll-draw-progress",String(L)),e.style.clipPath=ne(E==="reverse"?1-L:L),g?.(L),x<1&&(y=false);}else V.forEach((x,L)=>{let $e=L*F*o,Me=Math.min(1,Math.max(0,(S-$e)/o)),pe=ae(Me);x.style.strokeDashoffset=E==="reverse"?`${D[L]*pe}`:`${D[L]*(1-pe)}`,a&&(x.style.opacity=E==="reverse"?`${1-pe}`:`${pe}`),G&&C?x.style.stroke=Pe(G,C,pe):C&&(x.style.stroke=C),H!==null&&j!==null?x.style.strokeWidth=`${H+(j-H)*pe}`:j!==null&&(x.style.strokeWidth=`${j}`),M!==null&&I!==null?x.style.fillOpacity=`${M+(I-M)*pe}`:I!==null&&(x.style.fillOpacity=`${I}`),k&&x.tagName.toLowerCase()==="path"&&me[L]&&x.setAttribute("d",Ge(me[L],k,pe)),L===0&&(g?.(pe),e.style.setProperty("--scroll-draw-progress",String(pe))),Me<1&&(y=false);});if(_){let x=Math.min(1,Math.max(0,S/o)),L=ae(x);for(let $e in _){let Me=parseFloat($e);L>=Me&&!Se.has(Me)&&(Se.add(Me),_[$e]?.());}}return y}function se(S){if(Q)return;let y=S-s;le||(le=true,R?.());let x=O(y);if(x&&!Y){Y=true,O(o*(1+Math.max(0,V.length-1)*F)),ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{s=performance.now(),le=false,Y=false,Se.clear(),De(),W=requestAnimationFrame(se);},J));return}x||(W=requestAnimationFrame(se));}function ee(){cancelAnimationFrame(W),clearTimeout(Ee),s=performance.now(),v=0,Q=false,le=false,Y=false,ye=0,Se.clear(),De(),W=requestAnimationFrame(se);}let w=new IntersectionObserver(S=>{S.forEach(y=>{y.isIntersecting&&!(X&&Y)?ee():!y.isIntersecting&&!X&&!Y&&(cancelAnimationFrame(W),clearTimeout(Ee),s=null);});},{root:p??null,threshold:oe,rootMargin:U}),P;function q(){clearTimeout(P),P=setTimeout(()=>{V.forEach((S,y)=>{D[y]=Ne(S),S.style.strokeDasharray=`${D[y]}`;});},150);}return window.addEventListener("resize",q),window.addEventListener("orientationchange",q),h>0?setTimeout(()=>w.observe(e),h):w.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(Ee),w.disconnect(),window.removeEventListener("resize",q),window.removeEventListener("orientationchange",q),clearTimeout(P);},replay(){ye=0,ee();},pause(){Q||(Q=true,v=performance.now()-s,cancelAnimationFrame(W));},resume(){Q&&(Q=false,s=performance.now()-v,W=requestAnimationFrame(se));},seek(S){let y=Math.min(1,Math.max(0,S));Te=y,Q=true,v=y*o,s=performance.now()-v,cancelAnimationFrame(W),O(v);},getProgress(){return Te}}}if(de)return gt();Je();function Oe(){if(!Ce||Q)return;let o=performance.now(),s=ke(),v=m;if(B!==false){let w=o-Ue,P=w>0?Math.abs(s-(Ie<0?s:Ie))/w:0;v=m*Math.max(.2,1+P*(typeof B=="number"?B:1)*.04);}Ie=s,Ue=o;let O=c?Le===-1||s>=Le?"forward":"reverse":E;Le=s;let se=ve-we,ee=true;if(ie){let w=ae(re(s,we,ve,v));X&&!c&&(fe=Math.max(fe,w),w=fe),Te=w,e.style.setProperty("--scroll-draw-progress",String(w));let P=O==="reverse"?1-w:w;e.style.clipPath=ne(P),g?.(w),!le&&re(s,we,ve,v)>0&&(le=true,R?.()),w>=1&&!Y?(Y=true,ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{fe=-1,le=false,Y=false,e.style.clipPath=ne(0);},J))):w<1&&!X&&(Y=false),W=requestAnimationFrame(Oe);return}if(V.forEach((w,P)=>{let q=P*F*se,S=ae(re(s,we+q,ve+q,v));X&&!c&&(fe=Math.max(fe,S),S=fe),Te=S,w.style.strokeDashoffset=O==="reverse"?`${D[P]*S}`:`${D[P]*(1-S)}`,a&&(w.style.opacity=O==="reverse"?`${1-S}`:`${S}`),G&&C?w.style.stroke=Pe(G,C,S):C&&(w.style.stroke=C),H!==null&&j!==null?w.style.strokeWidth=`${H+(j-H)*S}`:j!==null&&(w.style.strokeWidth=`${j}`),M!==null&&I!==null?w.style.fillOpacity=`${M+(I-M)*S}`:I!==null&&(w.style.fillOpacity=`${I}`),k&&w.tagName.toLowerCase()==="path"&&me[P]&&w.setAttribute("d",Ge(me[P],k,S)),P===0&&(g?.(S),e.style.setProperty("--scroll-draw-progress",String(S))),S<1&&(ee=false);}),_){let w=ae(re(s,we,ve,v));for(let P in _){let q=parseFloat(P);w>=q&&!Se.has(q)&&(Se.add(q),_[P]?.());}}!le&&re(s,we,ve,v)>0&&(le=true,R?.()),ee&&!Y?(Y=true,ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{fe=-1,le=false,Y=false,Se.clear(),De();},J))):!ee&&!X&&(Y=false),W=requestAnimationFrame(Oe);}let We=new IntersectionObserver(o=>{o.forEach(s=>{Ce=s.isIntersecting,Ce&&!Q?W=requestAnimationFrame(Oe):cancelAnimationFrame(W);});},{root:p??null,threshold:oe,rootMargin:U}),_e;function Fe(){clearTimeout(_e),_e=setTimeout(()=>{V.forEach((o,s)=>{D[s]=Ne(o),o.style.strokeDasharray=`${D[s]}`;}),Je();},150);}return window.addEventListener("resize",Fe),window.addEventListener("orientationchange",Fe),h>0?setTimeout(()=>We.observe(e),h):We.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(Ee),We.disconnect(),window.removeEventListener("resize",Fe),window.removeEventListener("orientationchange",Fe),clearTimeout(_e),Ve?.remove();},replay(){fe=-1,Le=-1,Ie=-1,le=false,Y=false,ye=0,Q=false,Se.clear(),clearTimeout(Ee),De();},pause(){Q=true,cancelAnimationFrame(W);},resume(){Q&&(Q=false,Ce&&(W=requestAnimationFrame(Oe)));},seek(o){let s=Math.min(1,Math.max(0,o));Te=s,fe=s,Q=true,cancelAnimationFrame(W),ft(s,E);},getProgress(){return Te}}}var it=new Map;function Re(e,t){it.set(e,t);}function He(e){it.delete(e);}function St(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function at(e){let t=[],r=/([\w]+)\(([^)]*)\)/g,n;for(;(n=r.exec(e))!==null;){let u=[],i=[],d=n[2].trim();if(d)for(let m of d.split(/[\s,]+/)){let a=m.match(/^([-+]?[\d.eE]+)(.*)$/);u.push(a?parseFloat(a[1]):0),i.push(a?a[2]:"");}t.push({fn:n[1],nums:u,units:i});}return t}function xt(e,t,r){let n=at(e),u=at(t);return n.length===0||n.length!==u.length?r<1?e:t:n.map((i,d)=>{let m=u[d];return i.fn!==m.fn||i.nums.length!==m.nums.length?r<1?`${i.fn}(${i.nums.map((a,f)=>`${a}${i.units[f]}`).join(", ")})`:`${m.fn}(${m.nums.map((a,f)=>`${a}${m.units[f]}`).join(", ")})`:`${i.fn}(${i.nums.map((a,f)=>`${a+(m.nums[f]-a)*r}${i.units[f]}`).join(", ")})`}).join(" ")}function lt(e,t,r){if(typeof e=="number"&&typeof t=="number")return String(e+(t-e)*r);let n=String(e),u=String(t);if(St(n))return Pe(n,u,r);if(n.includes("("))return xt(n,u,r);let i=n.match(/^([-+]?[\d.]+)(.*)$/),d=u.match(/^([-+]?[\d.]+)(.*)$/);if(i&&d){let m=parseFloat(i[1]),a=parseFloat(d[1]);return `${m+(a-m)*r}${i[2]||d[2]}`}return r<1?n:u}function At(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var ct={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Tt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),$t=0;function Mt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function ut(e,t){let r={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return r;let{props:n,trigger:u={},easing:i="ease-out",speed:d=1,once:m=false,axis:a="y",scrollContainer:f,native:T=true,onProgress:F,onComplete:E}=t,X=window.matchMedia("(prefers-reduced-motion: reduce)").matches,ce=typeof i=="function"?i:te[i]??te["ease-out"],A=he(u.start??"top bottom"),$=he(u.end??"bottom top"),c=typeof f=="string"?document.querySelector(f):f??null,h=Object.entries(n).map(([l,p])=>({prop:At(l),from:Array.isArray(p)?p[0]:"",to:Array.isArray(p)?p[1]:p}));function b(){let l=window.getComputedStyle(e);for(let p of h)p.from===""&&(p.from=l.getPropertyValue(p.prop).trim()||"0");}function N(){for(let l of h)e.style.setProperty(l.prop,String(l.to));}if(X)return N(),E?.(),r;b();function z(){if(!T||!Mt()||typeof i!="string"||!(i in ct)||a!=="y"||c||m||d!==1||F||E||(u.start??"top bottom").trim()!=="top bottom"||(u.end??"bottom top").trim()!=="bottom top")return false;for(let l of h)if(!Tt.has(l.prop))return false;return true}function _(){let l=`ssd-a-${++$t}`,p=h.map(M=>`${M.prop}:${M.from}`).join(";"),G=h.map(M=>`${M.prop}:${M.to}`).join(";"),C=document.createElement("style");C.setAttribute("data-ssd-animate",""),C.textContent=`@keyframes ${l}{from{${p}}to{${G}}}.${l}{animation-name:${l};animation-duration:auto;animation-timing-function:${ct[i]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(C),e.classList.add(l);let H=()=>a==="x"?window.scrollX:window.scrollY,j=()=>a==="x"?window.innerWidth:window.innerHeight;return {destroy(){e.classList.remove(l),C.remove();},replay(){e.classList.remove(l),e.offsetWidth,e.classList.add(l);},pause(){e.style.animationPlayState="paused";},resume(){e.style.animationPlayState="";},seek(M){let I=Math.min(1,Math.max(0,M));e.classList.remove(l);for(let ne of h)e.style.setProperty(ne.prop,lt(ne.from,ne.to,I));},getProgress(){let M=e.getBoundingClientRect(),I=H(),ne=j(),{tStart:V,tEnd:D}=xe({top:M.top,height:M.height},I,ne,A,$);return ce(re(I,V,D,d))}}}if(z())return _();let B=0,oe=0,U=0,Z=false,J=false,k=-1,K=0,de=false,ge=()=>c?a==="x"?c.scrollLeft:c.scrollTop:a==="x"?window.scrollX:window.scrollY,be=()=>c?a==="x"?c.clientWidth:c.clientHeight:a==="x"?window.innerWidth:window.innerHeight;function g(){let l=e.getBoundingClientRect(),p,G;if(c){let H=c.getBoundingClientRect();p=a==="x"?l.left-H.left+c.scrollLeft:l.top-H.top+c.scrollTop,G=a==="x"?l.width:l.height;}else p=a==="x"?l.left:l.top,G=a==="x"?l.width:l.height;let C=xe({top:p,height:G},ge(),be(),A,$);B=C.tStart,oe=C.tEnd;}function R(l){e.style.setProperty("--scroll-draw-progress",String(l));for(let p of h)e.style.setProperty(p.prop,lt(p.from,p.to,l));F?.(l);}function ue(){if(!Z||J)return;let l=ce(re(ge(),B,oe,d));m&&(k=Math.max(k,l),l=k),K=l,R(l),l>=1&&!de?(de=true,E?.()):l<1&&!m&&(de=false),U=requestAnimationFrame(ue);}g();{let l=ce(re(ge(),B,oe,d));m&&l>0&&(k=l),K=l,R(l);}let ie=new IntersectionObserver(l=>{l.forEach(p=>{Z=p.isIntersecting,Z&&!J?U=requestAnimationFrame(ue):cancelAnimationFrame(U);});},{root:c??null}),ae;function Ae(){clearTimeout(ae),ae=setTimeout(g,150);}return window.addEventListener("resize",Ae),window.addEventListener("orientationchange",Ae),ie.observe(e),Re(e,{type:"animate",getProgress:()=>K,getTrigger:()=>({tStart:B,tEnd:oe})}),{destroy(){cancelAnimationFrame(U),ie.disconnect(),window.removeEventListener("resize",Ae),window.removeEventListener("orientationchange",Ae),clearTimeout(ae),He(e);},replay(){k=-1,de=false,K=0,J=false,R(0);},pause(){J=true,cancelAnimationFrame(U);},resume(){J&&(J=false,Z&&(U=requestAnimationFrame(ue)));},seek(l){let p=Math.min(1,Math.max(0,l));K=p,k=p,J=true,cancelAnimationFrame(U),R(p);},getProgress(){return K}}}var qe={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Pt(e,t){if(typeof window>"u")return qe;let r=typeof e=="string"?document.querySelector(e):e;return r?ut(r,t):(process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollAnimate: element not found:",e),qe)}function kt(e,t={}){if(typeof window>"u")return qe;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),qe;let{speed:n=.3,axis:u="y",easing:i="linear",trigger:d,onProgress:m}=t,a=r.getBoundingClientRect(),f=u==="x"?a.width:a.height,T=n*f;return ut(r,{props:u==="x"?{transform:["translateX(0px)",`translateX(${-T}px)`]}:{transform:["translateY(0px)",`translateY(${-T}px)`]},trigger:d??{start:"top bottom",end:"bottom top"},easing:i,native:false,onProgress:m})}var je={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function Ct(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:u=0,to:i,format:d,easing:m="ease-out",trigger:a={},once:f=true,decimals:T,onComplete:F}=t,E=T!==void 0?g=>g.toFixed(T):d??(g=>String(Math.round(g))),X=typeof m=="function"?m:te[m]??te["ease-out"],ce=he(a.start??"top 80%"),A=he(a.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=E(i),F?.(),je;n.textContent=E(u);let c=0,h=0,b=0,N=false,z=false,_=-1,B=0,oe=false,U=()=>window.scrollY,Z=()=>window.innerHeight;function J(){let g=n.getBoundingClientRect(),R=xe({top:g.top,height:g.height},U(),Z(),ce,A);c=R.tStart,h=R.tEnd;}function k(g){n.textContent=E(u+(i-u)*g),n.style.setProperty("--scroll-draw-progress",String(g));}function K(){if(!N||z)return;let g=X(re(U(),c,h,1));f&&(_=Math.max(_,g),g=_),B=g,k(g),g>=1&&!oe?(oe=true,F?.()):g<1&&!f&&(oe=false),b=requestAnimationFrame(K);}J();{let g=X(re(U(),c,h,1));f&&g>0&&(_=g),B=g,k(g);}let de=new IntersectionObserver(g=>{g.forEach(R=>{N=R.isIntersecting,N&&!z?b=requestAnimationFrame(K):cancelAnimationFrame(b);});}),ge;function be(){clearTimeout(ge),ge=setTimeout(J,150);}return window.addEventListener("resize",be),window.addEventListener("orientationchange",be),de.observe(n),Re(n,{type:"counter",getProgress:()=>B,getTrigger:()=>({tStart:c,tEnd:h})}),{destroy(){cancelAnimationFrame(b),de.disconnect(),window.removeEventListener("resize",be),window.removeEventListener("orientationchange",be),clearTimeout(ge),He(n);},replay(){_=-1,oe=false,B=0,z=false,k(0);},pause(){z=true,cancelAnimationFrame(b);},resume(){z&&(z=false,N&&(b=requestAnimationFrame(K)));},seek(g){let R=Math.min(1,Math.max(0,g));B=R,_=R,z=true,cancelAnimationFrame(b),k(R);},getProgress(){return B}}}var mt="http://www.w3.org/2000/svg",Lt="cinematic-photo",Xe=e=>e<0?0:e>1?1:e;function ze(e){let t=parseFloat(e);return Number.isFinite(t)?Xe(t/100):0}function It(e){return te[e]??te.linear}var Dt={destroy:()=>{},getProgress:()=>0},Ye=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 Dt;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 u=[];for(let A of t.scenes){if(A.background){let c=document.createElement("img");c.id=Lt,c.src=A.background,c.alt="",c.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(c);}let $=A.animations.filter(c=>c.type==="draw");if($.length){let c=document.createElementNS(mt,"svg");c.setAttribute("viewBox",`0 0 ${t.canvas.width} ${t.canvas.height}`),c.setAttribute("preserveAspectRatio","xMidYMid meet"),c.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(c);for(let h of $){let b=document.createElementNS(mt,"path");b.id=h.target.replace(/^#/,""),b.setAttribute("d",h.d),b.setAttribute("fill","none"),b.setAttribute("stroke",h.stroke),b.setAttribute("stroke-width",String(h.strokeWidth)),b.setAttribute("stroke-linecap","round"),b.setAttribute("stroke-linejoin","round");let N=h.length||b.getTotalLength?.()||0;b.style.strokeDasharray=String(N),b.style.strokeDashoffset=String(N),c.appendChild(b),u.push({kind:"draw",el:b,start:ze(h.start),end:ze(h.end),ease:It(h.easing),length:N});}}for(let c of A.animations){if(c.type!=="fade")continue;let h=n.querySelector(c.target)??document.querySelector(c.target);h&&(h.style.opacity=String(c.from),u.push({kind:"fade",el:h,start:ze(c.start),end:ze(c.end),ease:te["ease-in-out"]??te.linear,from:c.from,to:c.to}));}}let i=0,d=()=>{let A=r.offsetHeight-window.innerHeight;return A<=0?r.getBoundingClientRect().top<=0?1:0:Xe(-r.getBoundingClientRect().top/A)},m=A=>{for(let $ of u){let c=$.end-$.start,h=c<=0?A>=$.end?1:0:Xe((A-$.start)/c),b=$.ease(h);$.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 m(1),{destroy:()=>{},getProgress:()=>1};let a=0,f=false,T=false,F=()=>{i=d(),m(i),f&&(a=requestAnimationFrame(F));},E=()=>{f||(f=true,a=requestAnimationFrame(F));},X=()=>{f=false,cancelAnimationFrame(a);},ce=new IntersectionObserver(A=>{for(let $ of A)T=$.isIntersecting,T?E():X();},{threshold:0});return ce.observe(n),i=d(),m(i),{destroy(){X(),ce.disconnect();},getProgress:()=>i}}};function Ut(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?st(n,t):(console.warn("[svg-scroll-draw] Container not found:",e),r)}
4
- export{Ye as Cinematic,Be as PRESETS,tt as createBounce,rt as createElastic,yt as createSpring,Pt as scrollAnimate,Ct as scrollCounter,Ut as scrollDraw,kt as scrollParallax};
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};
@@ -0,0 +1 @@
1
+ 'use strict';var t={destroy:()=>{},getScrollY:()=>0};function l(n){if(typeof window>"u")return t;let e=window.scrollY,r=o=>{e=o.scroll;try{Object.defineProperty(window,"scrollY",{get:()=>e,configurable:!0}),Object.defineProperty(window,"pageYOffset",{get:()=>e,configurable:!0});}catch{}};return n.on("scroll",r),{destroy(){n.off("scroll",r);try{delete window.scrollY,delete window.pageYOffset;}catch{}},getScrollY(){return e}}}exports.createLenisAdapter=l;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Lenis smooth-scroll adapter for svg-scroll-draw.
3
+ *
4
+ * Lenis v2+ patches `window.scrollY` natively — no adapter needed.
5
+ * This adapter targets Lenis v1, which uses a virtual scroll value
6
+ * and does NOT update `window.scrollY`. It patches `window.scrollY` /
7
+ * `window.pageYOffset` so all svg-scroll-draw engines read the correct value.
8
+ *
9
+ * Usage:
10
+ * import Lenis from '@studio-freight/lenis'
11
+ * import { createLenisAdapter } from 'svg-scroll-draw/lenis'
12
+ *
13
+ * const lenis = new Lenis()
14
+ * const adapter = createLenisAdapter(lenis)
15
+ *
16
+ * // RAF loop — let Lenis drive the tick
17
+ * function raf(time: number) {
18
+ * lenis.raf(time)
19
+ * requestAnimationFrame(raf)
20
+ * }
21
+ * requestAnimationFrame(raf)
22
+ *
23
+ * // On cleanup:
24
+ * adapter.destroy()
25
+ */
26
+ interface LenisScrollEvent {
27
+ scroll: number;
28
+ velocity: number;
29
+ direction: number;
30
+ progress: number;
31
+ }
32
+ interface LenisLike {
33
+ on(event: 'scroll', callback: (e: LenisScrollEvent) => void): void;
34
+ off(event: 'scroll', callback: (e: LenisScrollEvent) => void): void;
35
+ }
36
+ interface LenisAdapterInstance {
37
+ /** Restore native `window.scrollY` and remove the Lenis listener. */
38
+ destroy: () => void;
39
+ /** Returns the current virtual scroll Y value Lenis last reported. */
40
+ getScrollY: () => number;
41
+ }
42
+ /**
43
+ * Patches `window.scrollY` and `window.pageYOffset` to return Lenis's
44
+ * virtual scroll position so all svg-scroll-draw engines stay in sync
45
+ * with smooth scroll.
46
+ *
47
+ * Only needed for Lenis v1. Lenis v2+ patches scrollY itself.
48
+ */
49
+ declare function createLenisAdapter(lenis: LenisLike): LenisAdapterInstance;
50
+
51
+ export { type LenisAdapterInstance, type LenisLike, type LenisScrollEvent, createLenisAdapter };