svg-scroll-draw 1.6.0 → 2.2.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.
@@ -1,3 +1,3 @@
1
- 'use strict';function _e({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,r)),g=Math.sqrt(o),h=0,L=[];for(let p=0;p<n;p++){let S=Math.pow(g,p);L.push(S),h+=S;}let E=[0],k=0;for(let p=0;p<n;p++)k+=L[p]/h,E.push(k);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let S=0;S<n;S++)if(p<=E[S+1]){let z=(p-E[S])/(E[S+1]-E[S]);if(S===0)return z*(2-z);let d=1-Math.pow(o,S);return d+(1-d)*(2*z-1)*(2*z-1)}return 1}}function je({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),o=Math.max(.1,r),g=n<=1?o/4:o/(2*Math.PI)*Math.asin(1/n);return h=>h<=0?0:h>=1?1:n*Math.pow(2,-10*h)*Math.sin((h-g)*(2*Math.PI)/o)+1}var Se={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:_e(),elastic:je()};function Le(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function Ge(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function ze(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"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function nt(e,r,n){return Math.min(n,Math.max(r,e))}function ie(e,r,n,o){return n===r?0:nt((e-r)/(n-r)*o,0,1)}function Ie(e,r,n,o,g){let h=Ge(e.top,e.height,r,o.element)-ze(o.viewport,n),L=Ge(e.top,e.height,r,g.element)-ze(g.viewport,n);return {tStart:h,tEnd:L}}function Be(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 o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function xe(e,r,n){let o=Be(e),g=Be(r);return !o||!g?e:`rgb(${Math.round(o[0]+(g[0]-o[0])*n)},${Math.round(o[1]+(g[1]-o[1])*n)},${Math.round(o[2]+(g[2]-o[2])*n)})`}var Oe={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 Xe(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Je={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},st=0;function ot(){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"?Xe("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Xe("Element has a fill \u2014 it may obscure the stroke animation.",e);}function at(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.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 g(){let h=n==="x"?window.scrollX:window.scrollY,L=e-h,E=r-h,k=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${k?`left:${L}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${L}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;${k?`left:${E}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${E}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(o),window.addEventListener("scroll",g,{passive:true}),g(),o}function Ce(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),g=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,h=>{let L=parseFloat(h),E=o[g++]??L;return String(+(L+(E-L)*n).toFixed(4))})}function Ae(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:n,...o}=r,g=n?{...Oe[n],...o}:o,h=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:L="path, polyline, line, polygon, rect, circle",speed:E=1,fade:k=false,easing:p="linear",trigger:S={},stagger:z=0,direction:d="forward",once:Y=false,debug:Ue=false,axis:R="y",scrollContainer:ke,autoReverse:me=false,delay:ce=0,strokeColor:K,strokeWidth:Q,fillOpacity:Z,waypoints:ee,velocityScale:pe=false,threshold:Fe=0,rootMargin:Ne="0px",repeat:te=0,repeatDelay:$e=0,morphTo:H,clip:Me,autoplay:Ye=false,duration:Ke=1e3,native:Qe=true,onProgress:ue,onStart:de,onComplete:ae}=g,_=Me===true?"left":typeof Me=="string"?Me:false,re=typeof p=="function"?p:Se[p]??Se.linear,Re=Le(S.start??"top bottom"),He=Le(S.end??"bottom top"),I=typeof ke=="string"?document.querySelector(ke):ke??null,q=Array.isArray(K)?K[0]:null,$=Array.isArray(K)?K[1]:typeof K=="string"?K:null,O=Array.isArray(Q)?Q[0]:null,M=Array.isArray(Q)?Q[1]:typeof Q=="number"?Q:null,C=Array.isArray(Z)?Z[0]:null,T=Array.isArray(Z)?Z[1]:typeof Z=="number"?Z:null;function ne(t){let s=t*100;switch(_){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(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let x=_?[]:Array.from(e.querySelectorAll(L)),w=[],W=[],j=0,X=0,A=false,N=false,v=0,ye=false,V=-1,ge=-1,D=false,se=0,B=0,J,Te=null,U=new Set,he=-1,qe=performance.now();function fe(){return I?R==="x"?I.scrollLeft:I.scrollTop:R==="x"?window.scrollX:window.scrollY}function We(){return I?R==="x"?I.clientWidth:I.clientHeight:R==="x"?window.innerWidth:window.innerHeight}function Ve(){let t=e.getBoundingClientRect(),s,l,y;if(I){let P=I.getBoundingClientRect();s=R==="x"?t.left-P.left+I.scrollLeft:t.top-P.top+I.scrollTop,l=R==="x"?t.width:t.height,y=fe();}else s=R==="x"?t.left:t.top,l=R==="x"?t.width:t.height,y=fe();let F=Ie({top:s,height:l},y,We(),Re,He);j=F.tStart,X=F.tEnd,Ue&&process.env.NODE_ENV!=="production"&&(Te?.remove(),Te=at(j,X,R));}function Ze(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),_){let l=s==="reverse"?1-t:t;e.style.clipPath=ne(l);return}x.forEach((l,y)=>{l.style.strokeDashoffset=s==="reverse"?`${w[y]*t}`:`${w[y]*(1-t)}`,k&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),q&&$?l.style.stroke=xe(q,$,t):$&&(l.style.stroke=$),O!==null&&M!==null?l.style.strokeWidth=`${O+(M-O)*t}`:M!==null&&(l.style.strokeWidth=`${M}`),C!==null&&T!==null?l.style.fillOpacity=`${C+(T-C)*t}`:T!==null&&(l.style.fillOpacity=`${T}`),H&&l.tagName.toLowerCase()==="path"&&W[y]&&l.setAttribute("d",Ce(W[y],H,t));});}function be(){if(e.style.setProperty("--scroll-draw-progress","0"),_){e.style.clipPath=ne(0);return}x.forEach((t,s)=>{t.style.strokeDasharray=`${w[s]}`,t.style.strokeDashoffset=d==="reverse"?"0":`${w[s]}`,k?t.style.opacity=d==="reverse"?"1":"0":t.style.opacity="",q&&(t.style.stroke=q),O!==null&&(t.style.strokeWidth=`${O}`),C!==null&&(t.style.fillOpacity=`${C}`),H&&t.tagName.toLowerCase()==="path"&&W[s]&&t.setAttribute("d",W[s]);});}if(x.forEach(t=>{it(t);let s=Ee(t);w.push(s),t.tagName.toLowerCase()==="path"?W.push(t.getAttribute("d")??""):W.push(""),h?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=d==="reverse"?`${s}`:"0",k&&(t.style.opacity="1"),$&&(t.style.stroke=$),M!==null&&(t.style.strokeWidth=`${M}`),T!==null&&(t.style.fillOpacity=`${T}`),H&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",H)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=d==="reverse"?"0":`${s}`,k?t.style.opacity=d==="reverse"?"1":"0":t.style.opacity="",q&&(t.style.stroke=q),O!==null&&(t.style.strokeWidth=`${O}`),C!==null&&(t.style.fillOpacity=`${C}`));}),_){if(h)return e.style.clipPath=ne(1),ae?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ne(0);}else if(h)return ae?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function et(){return !(Qe===false||!ot()||!x.length||typeof p!="string"||!(p in Je)||_||R!=="y"||I||E!==1||z!==0||Y||me||pe!==false||H||ee||te||ce>0||ue||de||ae||K!=null||Q!=null||Z!=null||(S.start??"top bottom").trim()!=="top bottom"||(S.end??"bottom top").trim()!=="bottom top")}function tt(){let t=`svg-scroll-draw-${++st}`,s=d==="reverse"?"0":"var(--ssd-len)",l=d==="reverse"?"var(--ssd-len)":"0",y=`stroke-dashoffset:${s};`,F=`stroke-dashoffset:${l};`;k&&(y+=`opacity:${d==="reverse"?1:0};`,F+=`opacity:${d==="reverse"?0:1};`);let P=document.createElement("style");P.setAttribute("data-svg-scroll-draw",""),P.textContent=`@keyframes ${t}{from{${y}}to{${F}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Je[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(P);function a(i,u){i.style.setProperty("--ssd-len",String(w[u])),i.style.strokeDasharray=`${w[u]}`,i.style.strokeDashoffset="",i.style.opacity="",i.style.animationPlayState="",i.classList.add(t);}x.forEach(a);let f=false,b=-1;function c(){if(b>=0)return b;let i=e.getBoundingClientRect(),{tStart:u,tEnd:m}=Ie({top:i.top,height:i.height},fe(),We(),Re,He);return re(ie(fe(),u,m,E))}return {destroy(){x.forEach(i=>{i.classList.remove(t),i.style.removeProperty("--ssd-len"),i.style.animationPlayState="";}),P.remove();},replay(){f=false,b=-1,x.forEach(a);},pause(){f=true,x.forEach(i=>{i.style.animationPlayState="paused";});},resume(){f&&(f=false,x.forEach(i=>{i.style.animationPlayState="running";}));},seek(i){let u=Math.min(1,Math.max(0,i));b=u,f=true,x.forEach((m,oe)=>{m.classList.remove(t),m.style.strokeDashoffset=d==="reverse"?`${w[oe]*u}`:`${w[oe]*(1-u)}`,k&&(m.style.opacity=d==="reverse"?`${1-u}`:`${u}`);});},getProgress(){return c()}}}if(et())return tt();function rt(){let t=Math.max(1,Ke),s=0,l=0;function y(c){let i=true;if(_){let u=Math.min(1,Math.max(0,c/t)),m=re(u);se=m,e.style.setProperty("--scroll-draw-progress",String(m)),e.style.clipPath=ne(d==="reverse"?1-m:m),ue?.(m),u<1&&(i=false);}else x.forEach((u,m)=>{let oe=m*z*t,le=Math.min(1,Math.max(0,(c-oe)/t)),G=re(le);u.style.strokeDashoffset=d==="reverse"?`${w[m]*G}`:`${w[m]*(1-G)}`,k&&(u.style.opacity=d==="reverse"?`${1-G}`:`${G}`),q&&$?u.style.stroke=xe(q,$,G):$&&(u.style.stroke=$),O!==null&&M!==null?u.style.strokeWidth=`${O+(M-O)*G}`:M!==null&&(u.style.strokeWidth=`${M}`),C!==null&&T!==null?u.style.fillOpacity=`${C+(T-C)*G}`:T!==null&&(u.style.fillOpacity=`${T}`),H&&u.tagName.toLowerCase()==="path"&&W[m]&&u.setAttribute("d",Ce(W[m],H,G)),m===0&&(ue?.(G),e.style.setProperty("--scroll-draw-progress",String(G))),le<1&&(i=false);});if(ee){let u=Math.min(1,Math.max(0,c/t)),m=re(u);for(let oe in ee){let le=parseFloat(oe);m>=le&&!U.has(le)&&(U.add(le),ee[oe]?.());}}return i}function F(c){if(D)return;let i=c-s;N||(N=true,de?.());let u=y(i);if(u&&!A){A=true,y(t*(1+Math.max(0,x.length-1)*z)),ae?.(),B<(te==="infinite"?1/0:te??0)&&(B++,J=setTimeout(()=>{s=performance.now(),N=false,A=false,U.clear(),be(),v=requestAnimationFrame(F);},$e));return}u||(v=requestAnimationFrame(F));}function P(){cancelAnimationFrame(v),clearTimeout(J),s=performance.now(),l=0,D=false,N=false,A=false,B=0,U.clear(),be(),v=requestAnimationFrame(F);}let a=new IntersectionObserver(c=>{c.forEach(i=>{i.isIntersecting&&!(Y&&A)?P():!i.isIntersecting&&!Y&&!A&&(cancelAnimationFrame(v),clearTimeout(J),s=null);});},{root:I??null,threshold:Fe,rootMargin:Ne}),f;function b(){clearTimeout(f),f=setTimeout(()=>{x.forEach((c,i)=>{w[i]=Ee(c),c.style.strokeDasharray=`${w[i]}`;});},150);}return window.addEventListener("resize",b),window.addEventListener("orientationchange",b),ce>0?setTimeout(()=>a.observe(e),ce):a.observe(e),{destroy(){cancelAnimationFrame(v),clearTimeout(J),a.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),clearTimeout(f);},replay(){B=0,P();},pause(){D||(D=true,l=performance.now()-s,cancelAnimationFrame(v));},resume(){D&&(D=false,s=performance.now()-l,v=requestAnimationFrame(F));},seek(c){let i=Math.min(1,Math.max(0,c));se=i,D=true,l=i*t,s=performance.now()-l,cancelAnimationFrame(v),y(l);},getProgress(){return se}}}if(Ye)return rt();Ve();function we(){if(!ye||D)return;let t=performance.now(),s=fe(),l=E;if(pe!==false){let a=t-qe,f=a>0?Math.abs(s-(he<0?s:he))/a:0;l=E*Math.max(.2,1+f*(typeof pe=="number"?pe:1)*.04);}he=s,qe=t;let y=me?ge===-1||s>=ge?"forward":"reverse":d;ge=s;let F=X-j,P=true;if(_){let a=re(ie(s,j,X,l));Y&&!me&&(V=Math.max(V,a),a=V),se=a,e.style.setProperty("--scroll-draw-progress",String(a));let f=y==="reverse"?1-a:a;e.style.clipPath=ne(f),ue?.(a),!N&&ie(s,j,X,l)>0&&(N=true,de?.()),a>=1&&!A?(A=true,ae?.(),B<(te==="infinite"?1/0:te??0)&&(B++,J=setTimeout(()=>{V=-1,N=false,A=false,e.style.clipPath=ne(0);},$e))):a<1&&!Y&&(A=false),v=requestAnimationFrame(we);return}if(x.forEach((a,f)=>{let b=f*z*F,c=re(ie(s,j+b,X+b,l));Y&&!me&&(V=Math.max(V,c),c=V),se=c,a.style.strokeDashoffset=y==="reverse"?`${w[f]*c}`:`${w[f]*(1-c)}`,k&&(a.style.opacity=y==="reverse"?`${1-c}`:`${c}`),q&&$?a.style.stroke=xe(q,$,c):$&&(a.style.stroke=$),O!==null&&M!==null?a.style.strokeWidth=`${O+(M-O)*c}`:M!==null&&(a.style.strokeWidth=`${M}`),C!==null&&T!==null?a.style.fillOpacity=`${C+(T-C)*c}`:T!==null&&(a.style.fillOpacity=`${T}`),H&&a.tagName.toLowerCase()==="path"&&W[f]&&a.setAttribute("d",Ce(W[f],H,c)),f===0&&(ue?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(P=false);}),ee){let a=re(ie(s,j,X,l));for(let f in ee){let b=parseFloat(f);a>=b&&!U.has(b)&&(U.add(b),ee[f]?.());}}!N&&ie(s,j,X,l)>0&&(N=true,de?.()),P&&!A?(A=true,ae?.(),B<(te==="infinite"?1/0:te??0)&&(B++,J=setTimeout(()=>{V=-1,N=false,A=false,U.clear(),be();},$e))):!P&&!Y&&(A=false),v=requestAnimationFrame(we);}let De=new IntersectionObserver(t=>{t.forEach(s=>{ye=s.isIntersecting,ye&&!D?v=requestAnimationFrame(we):cancelAnimationFrame(v);});},{root:I??null,threshold:Fe,rootMargin:Ne}),Pe;function ve(){clearTimeout(Pe),Pe=setTimeout(()=>{x.forEach((t,s)=>{w[s]=Ee(t),t.style.strokeDasharray=`${w[s]}`;}),Ve();},150);}return window.addEventListener("resize",ve),window.addEventListener("orientationchange",ve),ce>0?setTimeout(()=>De.observe(e),ce):De.observe(e),{destroy(){cancelAnimationFrame(v),clearTimeout(J),De.disconnect(),window.removeEventListener("resize",ve),window.removeEventListener("orientationchange",ve),clearTimeout(Pe),Te?.remove();},replay(){V=-1,ge=-1,he=-1,N=false,A=false,B=0,D=false,U.clear(),clearTimeout(J),be();},pause(){D=true,cancelAnimationFrame(v);},resume(){D&&(D=false,ye&&(v=requestAnimationFrame(we)));},seek(t){let s=Math.min(1,Math.max(0,t));se=s,V=s,D=true,cancelAnimationFrame(v),Ze(s,d);},getProgress(){return se}}}function lt(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let o=typeof e=="string"?document.querySelector(e):e;return o?Ae(o,r):(console.warn("[svg-scroll-draw] Container not found:",e),n)}function At(e=document){return Array.from(e.querySelectorAll("[data-scroll-draw]")).map(r=>{let n={};try{let o=r.dataset.scrollDrawOptions??r.dataset.scrollDrawoptions??"";o&&(n=JSON.parse(o));}catch{}return Ae(r,n)})}exports.initScrollDraw=At;exports.scrollDraw=lt;
1
+ 'use strict';function Ge({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),s=Math.max(.01,Math.min(.99,r)),y=Math.sqrt(s),h=0,L=[];for(let p=0;p<n;p++){let S=Math.pow(y,p);L.push(S),h+=S;}let E=[0],T=0;for(let p=0;p<n;p++)T+=L[p]/h,E.push(T);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let S=0;S<n;S++)if(p<=E[S+1]){let _=(p-E[S])/(E[S+1]-E[S]);if(S===0)return _*(2-_);let d=1-Math.pow(s,S);return d+(1-d)*(2*_-1)*(2*_-1)}return 1}}function je({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),s=Math.max(.1,r),y=n<=1?s/4:s/(2*Math.PI)*Math.asin(1/n);return h=>h<=0?0:h>=1?1:n*Math.pow(2,-10*h)*Math.sin((h-y)*(2*Math.PI)/s)+1}var ce={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:Ge(),elastic:je()};function pe(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 We(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 _e(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 Te(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 nt(e,r,n){return Math.min(n,Math.max(r,e))}function G(e,r,n,s){return n===r?0:nt((e-r)/(n-r)*s,0,1)}function de(e,r,n,s,y){let h=We(e.top,e.height,r,s.element)-_e(s.viewport,n),L=We(e.top,e.height,r,y.element)-_e(y.viewport,n);return {tStart:h,tEnd:L}}function Be(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 ge(e,r,n){let s=Be(e),y=Be(r);return !s||!y?e:`rgb(${Math.round(s[0]+(y[0]-s[0])*n)},${Math.round(s[1]+(y[1]-s[1])*n)},${Math.round(s[2]+(y[2]-s[2])*n)})`}var Ie={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 Xe(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Ye={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},ot=0;function st(){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"?Xe("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Xe("Element has a fill \u2014 it may obscure the stroke animation.",e);}function at(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 y(){let h=n==="x"?window.scrollX:window.scrollY,L=e-h,E=r-h,T=n==="x";s.innerHTML=`
2
+ <div style="position:absolute;${T?`left:${L}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${L}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;${T?`left:${E}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${E}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",y,{passive:true}),y(),s}function Oe(e,r,n){let s=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),y=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,h=>{let L=parseFloat(h),E=s[y++]??L;return String(+(L+(E-L)*n).toFixed(4))})}function $e(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:n,...s}=r,y=n?{...Ie[n],...s}:s,h=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:L="path, polyline, line, polygon, rect, circle",speed:E=1,fade:T=false,easing:p="linear",trigger:S={},stagger:_=0,direction:d="forward",once:Z=false,debug:Ue=false,axis:R="y",scrollContainer:Me,autoReverse:ye=false,delay:ue=0,strokeColor:K,strokeWidth:Q,fillOpacity:ee,waypoints:te,velocityScale:he=false,threshold:Fe=0,rootMargin:Ne="0px",repeat:re=0,repeatDelay:Pe=0,morphTo:H,clip:ke,autoplay:Je=false,duration:Ze=1e3,native:Ke=true,onProgress:me,onStart:be,onComplete:ae}=y,j=ke===true?"left":typeof ke=="string"?ke:false,ne=typeof p=="function"?p:ce[p]??ce.linear,Re=pe(S.start??"top bottom"),He=pe(S.end??"bottom top"),D=typeof Me=="string"?document.querySelector(Me):Me??null,q=Array.isArray(K)?K[0]:null,$=Array.isArray(K)?K[1]:typeof K=="string"?K:null,I=Array.isArray(Q)?Q[0]:null,M=Array.isArray(Q)?Q[1]:typeof Q=="number"?Q:null,O=Array.isArray(ee)?ee[0]:null,P=Array.isArray(ee)?ee[1]:typeof ee=="number"?ee:null;function oe(t){let o=t*100;switch(j){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 x=j?[]:Array.from(e.querySelectorAll(L)),w=[],z=[],X=0,Y=0,A=false,N=false,v=0,we=false,V=-1,ve=-1,k=false,se=0,B=0,U,Ce=null,J=new Set,Se=-1,qe=performance.now();function fe(){return D?R==="x"?D.scrollLeft:D.scrollTop:R==="x"?window.scrollX:window.scrollY}function ze(){return D?R==="x"?D.clientWidth:D.clientHeight:R==="x"?window.innerWidth:window.innerHeight}function Ve(){let t=e.getBoundingClientRect(),o,l,g;if(D){let C=D.getBoundingClientRect();o=R==="x"?t.left-C.left+D.scrollLeft:t.top-C.top+D.scrollTop,l=R==="x"?t.width:t.height,g=fe();}else o=R==="x"?t.left:t.top,l=R==="x"?t.width:t.height,g=fe();let F=de({top:o,height:l},g,ze(),Re,He);X=F.tStart,Y=F.tEnd,Ue&&process.env.NODE_ENV!=="production"&&(Ce?.remove(),Ce=at(X,Y,R));}function Qe(t,o){if(e.style.setProperty("--scroll-draw-progress",String(t)),j){let l=o==="reverse"?1-t:t;e.style.clipPath=oe(l);return}x.forEach((l,g)=>{l.style.strokeDashoffset=o==="reverse"?`${w[g]*t}`:`${w[g]*(1-t)}`,T&&(l.style.opacity=o==="reverse"?`${1-t}`:`${t}`),q&&$?l.style.stroke=ge(q,$,t):$&&(l.style.stroke=$),I!==null&&M!==null?l.style.strokeWidth=`${I+(M-I)*t}`:M!==null&&(l.style.strokeWidth=`${M}`),O!==null&&P!==null?l.style.fillOpacity=`${O+(P-O)*t}`:P!==null&&(l.style.fillOpacity=`${P}`),H&&l.tagName.toLowerCase()==="path"&&z[g]&&l.setAttribute("d",Oe(z[g],H,t));});}function Ee(){if(e.style.setProperty("--scroll-draw-progress","0"),j){e.style.clipPath=oe(0);return}x.forEach((t,o)=>{t.style.strokeDasharray=`${w[o]}`,t.style.strokeDashoffset=d==="reverse"?"0":`${w[o]}`,T?t.style.opacity=d==="reverse"?"1":"0":t.style.opacity="",q&&(t.style.stroke=q),I!==null&&(t.style.strokeWidth=`${I}`),O!==null&&(t.style.fillOpacity=`${O}`),H&&t.tagName.toLowerCase()==="path"&&z[o]&&t.setAttribute("d",z[o]);});}if(x.forEach(t=>{it(t);let o=Te(t);w.push(o),t.tagName.toLowerCase()==="path"?z.push(t.getAttribute("d")??""):z.push(""),h?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=d==="reverse"?`${o}`:"0",T&&(t.style.opacity="1"),$&&(t.style.stroke=$),M!==null&&(t.style.strokeWidth=`${M}`),P!==null&&(t.style.fillOpacity=`${P}`),H&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",H)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=d==="reverse"?"0":`${o}`,T?t.style.opacity=d==="reverse"?"1":"0":t.style.opacity="",q&&(t.style.stroke=q),I!==null&&(t.style.strokeWidth=`${I}`),O!==null&&(t.style.fillOpacity=`${O}`));}),j){if(h)return e.style.clipPath=oe(1),ae?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=oe(0);}else if(h)return ae?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function et(){return !(Ke===false||!st()||!x.length||typeof p!="string"||!(p in Ye)||j||R!=="y"||D||E!==1||_!==0||Z||ye||he!==false||H||te||re||ue>0||me||be||ae||K!=null||Q!=null||ee!=null||(S.start??"top bottom").trim()!=="top bottom"||(S.end??"bottom top").trim()!=="bottom top")}function tt(){let t=`svg-scroll-draw-${++ot}`,o=d==="reverse"?"0":"var(--ssd-len)",l=d==="reverse"?"var(--ssd-len)":"0",g=`stroke-dashoffset:${o};`,F=`stroke-dashoffset:${l};`;T&&(g+=`opacity:${d==="reverse"?1:0};`,F+=`opacity:${d==="reverse"?0:1};`);let C=document.createElement("style");C.setAttribute("data-svg-scroll-draw",""),C.textContent=`@keyframes ${t}{from{${g}}to{${F}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Ye[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(C);function a(i,u){i.style.setProperty("--ssd-len",String(w[u])),i.style.strokeDasharray=`${w[u]}`,i.style.strokeDashoffset="",i.style.opacity="",i.style.animationPlayState="",i.classList.add(t);}x.forEach(a);let m=false,b=-1;function c(){if(b>=0)return b;let i=e.getBoundingClientRect(),{tStart:u,tEnd:f}=de({top:i.top,height:i.height},fe(),ze(),Re,He);return ne(G(fe(),u,f,E))}return {destroy(){x.forEach(i=>{i.classList.remove(t),i.style.removeProperty("--ssd-len"),i.style.animationPlayState="";}),C.remove();},replay(){m=false,b=-1,x.forEach(a);},pause(){m=true,x.forEach(i=>{i.style.animationPlayState="paused";});},resume(){m&&(m=false,x.forEach(i=>{i.style.animationPlayState="running";}));},seek(i){let u=Math.min(1,Math.max(0,i));b=u,m=true,x.forEach((f,ie)=>{f.classList.remove(t),f.style.strokeDashoffset=d==="reverse"?`${w[ie]*u}`:`${w[ie]*(1-u)}`,T&&(f.style.opacity=d==="reverse"?`${1-u}`:`${u}`);});},getProgress(){return c()}}}if(et())return tt();function rt(){let t=Math.max(1,Ze),o=0,l=0;function g(c){let i=true;if(j){let u=Math.min(1,Math.max(0,c/t)),f=ne(u);se=f,e.style.setProperty("--scroll-draw-progress",String(f)),e.style.clipPath=oe(d==="reverse"?1-f:f),me?.(f),u<1&&(i=false);}else x.forEach((u,f)=>{let ie=f*_*t,le=Math.min(1,Math.max(0,(c-ie)/t)),W=ne(le);u.style.strokeDashoffset=d==="reverse"?`${w[f]*W}`:`${w[f]*(1-W)}`,T&&(u.style.opacity=d==="reverse"?`${1-W}`:`${W}`),q&&$?u.style.stroke=ge(q,$,W):$&&(u.style.stroke=$),I!==null&&M!==null?u.style.strokeWidth=`${I+(M-I)*W}`:M!==null&&(u.style.strokeWidth=`${M}`),O!==null&&P!==null?u.style.fillOpacity=`${O+(P-O)*W}`:P!==null&&(u.style.fillOpacity=`${P}`),H&&u.tagName.toLowerCase()==="path"&&z[f]&&u.setAttribute("d",Oe(z[f],H,W)),f===0&&(me?.(W),e.style.setProperty("--scroll-draw-progress",String(W))),le<1&&(i=false);});if(te){let u=Math.min(1,Math.max(0,c/t)),f=ne(u);for(let ie in te){let le=parseFloat(ie);f>=le&&!J.has(le)&&(J.add(le),te[ie]?.());}}return i}function F(c){if(k)return;let i=c-o;N||(N=true,be?.());let u=g(i);if(u&&!A){A=true,g(t*(1+Math.max(0,x.length-1)*_)),ae?.(),B<(re==="infinite"?1/0:re??0)&&(B++,U=setTimeout(()=>{o=performance.now(),N=false,A=false,J.clear(),Ee(),v=requestAnimationFrame(F);},Pe));return}u||(v=requestAnimationFrame(F));}function C(){cancelAnimationFrame(v),clearTimeout(U),o=performance.now(),l=0,k=false,N=false,A=false,B=0,J.clear(),Ee(),v=requestAnimationFrame(F);}let a=new IntersectionObserver(c=>{c.forEach(i=>{i.isIntersecting&&!(Z&&A)?C():!i.isIntersecting&&!Z&&!A&&(cancelAnimationFrame(v),clearTimeout(U),o=null);});},{root:D??null,threshold:Fe,rootMargin:Ne}),m;function b(){clearTimeout(m),m=setTimeout(()=>{x.forEach((c,i)=>{w[i]=Te(c),c.style.strokeDasharray=`${w[i]}`;});},150);}return window.addEventListener("resize",b),window.addEventListener("orientationchange",b),ue>0?setTimeout(()=>a.observe(e),ue):a.observe(e),{destroy(){cancelAnimationFrame(v),clearTimeout(U),a.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),clearTimeout(m);},replay(){B=0,C();},pause(){k||(k=true,l=performance.now()-o,cancelAnimationFrame(v));},resume(){k&&(k=false,o=performance.now()-l,v=requestAnimationFrame(F));},seek(c){let i=Math.min(1,Math.max(0,c));se=i,k=true,l=i*t,o=performance.now()-l,cancelAnimationFrame(v),g(l);},getProgress(){return se}}}if(Je)return rt();Ve();function xe(){if(!we||k)return;let t=performance.now(),o=fe(),l=E;if(he!==false){let a=t-qe,m=a>0?Math.abs(o-(Se<0?o:Se))/a:0;l=E*Math.max(.2,1+m*(typeof he=="number"?he:1)*.04);}Se=o,qe=t;let g=ye?ve===-1||o>=ve?"forward":"reverse":d;ve=o;let F=Y-X,C=true;if(j){let a=ne(G(o,X,Y,l));Z&&!ye&&(V=Math.max(V,a),a=V),se=a,e.style.setProperty("--scroll-draw-progress",String(a));let m=g==="reverse"?1-a:a;e.style.clipPath=oe(m),me?.(a),!N&&G(o,X,Y,l)>0&&(N=true,be?.()),a>=1&&!A?(A=true,ae?.(),B<(re==="infinite"?1/0:re??0)&&(B++,U=setTimeout(()=>{V=-1,N=false,A=false,e.style.clipPath=oe(0);},Pe))):a<1&&!Z&&(A=false),v=requestAnimationFrame(xe);return}if(x.forEach((a,m)=>{let b=m*_*F,c=ne(G(o,X+b,Y+b,l));Z&&!ye&&(V=Math.max(V,c),c=V),se=c,a.style.strokeDashoffset=g==="reverse"?`${w[m]*c}`:`${w[m]*(1-c)}`,T&&(a.style.opacity=g==="reverse"?`${1-c}`:`${c}`),q&&$?a.style.stroke=ge(q,$,c):$&&(a.style.stroke=$),I!==null&&M!==null?a.style.strokeWidth=`${I+(M-I)*c}`:M!==null&&(a.style.strokeWidth=`${M}`),O!==null&&P!==null?a.style.fillOpacity=`${O+(P-O)*c}`:P!==null&&(a.style.fillOpacity=`${P}`),H&&a.tagName.toLowerCase()==="path"&&z[m]&&a.setAttribute("d",Oe(z[m],H,c)),m===0&&(me?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(C=false);}),te){let a=ne(G(o,X,Y,l));for(let m in te){let b=parseFloat(m);a>=b&&!J.has(b)&&(J.add(b),te[m]?.());}}!N&&G(o,X,Y,l)>0&&(N=true,be?.()),C&&!A?(A=true,ae?.(),B<(re==="infinite"?1/0:re??0)&&(B++,U=setTimeout(()=>{V=-1,N=false,A=false,J.clear(),Ee();},Pe))):!C&&!Z&&(A=false),v=requestAnimationFrame(xe);}let Le=new IntersectionObserver(t=>{t.forEach(o=>{we=o.isIntersecting,we&&!k?v=requestAnimationFrame(xe):cancelAnimationFrame(v);});},{root:D??null,threshold:Fe,rootMargin:Ne}),De;function Ae(){clearTimeout(De),De=setTimeout(()=>{x.forEach((t,o)=>{w[o]=Te(t),t.style.strokeDasharray=`${w[o]}`;}),Ve();},150);}return window.addEventListener("resize",Ae),window.addEventListener("orientationchange",Ae),ue>0?setTimeout(()=>Le.observe(e),ue):Le.observe(e),{destroy(){cancelAnimationFrame(v),clearTimeout(U),Le.disconnect(),window.removeEventListener("resize",Ae),window.removeEventListener("orientationchange",Ae),clearTimeout(De),Ce?.remove();},replay(){V=-1,ve=-1,Se=-1,N=false,A=false,B=0,k=false,J.clear(),clearTimeout(U),Ee();},pause(){k=true,cancelAnimationFrame(v);},resume(){k&&(k=false,we&&(v=requestAnimationFrame(xe)));},seek(t){let o=Math.min(1,Math.max(0,t));se=o,V=o,k=true,cancelAnimationFrame(v),Qe(o,d);},getProgress(){return se}}}function ut(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let s=typeof e=="string"?document.querySelector(e):e;return s?$e(s,r):(console.warn("[svg-scroll-draw] Container not found:",e),n)}function Ht(e=document){return Array.from(e.querySelectorAll("[data-scroll-draw]")).map(r=>{let n={};try{let s=r.dataset.scrollDrawOptions??r.dataset.scrollDrawoptions??"";s&&(n=JSON.parse(s));}catch{}return $e(r,n)})}exports.initScrollDraw=Ht;exports.scrollDraw=ut;
@@ -1,3 +1,3 @@
1
- function _e({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,r)),g=Math.sqrt(o),h=0,L=[];for(let p=0;p<n;p++){let S=Math.pow(g,p);L.push(S),h+=S;}let E=[0],k=0;for(let p=0;p<n;p++)k+=L[p]/h,E.push(k);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let S=0;S<n;S++)if(p<=E[S+1]){let z=(p-E[S])/(E[S+1]-E[S]);if(S===0)return z*(2-z);let d=1-Math.pow(o,S);return d+(1-d)*(2*z-1)*(2*z-1)}return 1}}function je({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),o=Math.max(.1,r),g=n<=1?o/4:o/(2*Math.PI)*Math.asin(1/n);return h=>h<=0?0:h>=1?1:n*Math.pow(2,-10*h)*Math.sin((h-g)*(2*Math.PI)/o)+1}var Se={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:_e(),elastic:je()};function Le(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function Ge(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function ze(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"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function nt(e,r,n){return Math.min(n,Math.max(r,e))}function ie(e,r,n,o){return n===r?0:nt((e-r)/(n-r)*o,0,1)}function Ie(e,r,n,o,g){let h=Ge(e.top,e.height,r,o.element)-ze(o.viewport,n),L=Ge(e.top,e.height,r,g.element)-ze(g.viewport,n);return {tStart:h,tEnd:L}}function Be(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 o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function xe(e,r,n){let o=Be(e),g=Be(r);return !o||!g?e:`rgb(${Math.round(o[0]+(g[0]-o[0])*n)},${Math.round(o[1]+(g[1]-o[1])*n)},${Math.round(o[2]+(g[2]-o[2])*n)})`}var Oe={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 Xe(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Je={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},st=0;function ot(){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"?Xe("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Xe("Element has a fill \u2014 it may obscure the stroke animation.",e);}function at(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.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 g(){let h=n==="x"?window.scrollX:window.scrollY,L=e-h,E=r-h,k=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${k?`left:${L}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${L}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;${k?`left:${E}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${E}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(o),window.addEventListener("scroll",g,{passive:true}),g(),o}function Ce(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),g=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,h=>{let L=parseFloat(h),E=o[g++]??L;return String(+(L+(E-L)*n).toFixed(4))})}function Ae(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:n,...o}=r,g=n?{...Oe[n],...o}:o,h=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:L="path, polyline, line, polygon, rect, circle",speed:E=1,fade:k=false,easing:p="linear",trigger:S={},stagger:z=0,direction:d="forward",once:Y=false,debug:Ue=false,axis:R="y",scrollContainer:ke,autoReverse:me=false,delay:ce=0,strokeColor:K,strokeWidth:Q,fillOpacity:Z,waypoints:ee,velocityScale:pe=false,threshold:Fe=0,rootMargin:Ne="0px",repeat:te=0,repeatDelay:$e=0,morphTo:H,clip:Me,autoplay:Ye=false,duration:Ke=1e3,native:Qe=true,onProgress:ue,onStart:de,onComplete:ae}=g,_=Me===true?"left":typeof Me=="string"?Me:false,re=typeof p=="function"?p:Se[p]??Se.linear,Re=Le(S.start??"top bottom"),He=Le(S.end??"bottom top"),I=typeof ke=="string"?document.querySelector(ke):ke??null,q=Array.isArray(K)?K[0]:null,$=Array.isArray(K)?K[1]:typeof K=="string"?K:null,O=Array.isArray(Q)?Q[0]:null,M=Array.isArray(Q)?Q[1]:typeof Q=="number"?Q:null,C=Array.isArray(Z)?Z[0]:null,T=Array.isArray(Z)?Z[1]:typeof Z=="number"?Z:null;function ne(t){let s=t*100;switch(_){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(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let x=_?[]:Array.from(e.querySelectorAll(L)),w=[],W=[],j=0,X=0,A=false,N=false,v=0,ye=false,V=-1,ge=-1,D=false,se=0,B=0,J,Te=null,U=new Set,he=-1,qe=performance.now();function fe(){return I?R==="x"?I.scrollLeft:I.scrollTop:R==="x"?window.scrollX:window.scrollY}function We(){return I?R==="x"?I.clientWidth:I.clientHeight:R==="x"?window.innerWidth:window.innerHeight}function Ve(){let t=e.getBoundingClientRect(),s,l,y;if(I){let P=I.getBoundingClientRect();s=R==="x"?t.left-P.left+I.scrollLeft:t.top-P.top+I.scrollTop,l=R==="x"?t.width:t.height,y=fe();}else s=R==="x"?t.left:t.top,l=R==="x"?t.width:t.height,y=fe();let F=Ie({top:s,height:l},y,We(),Re,He);j=F.tStart,X=F.tEnd,Ue&&process.env.NODE_ENV!=="production"&&(Te?.remove(),Te=at(j,X,R));}function Ze(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),_){let l=s==="reverse"?1-t:t;e.style.clipPath=ne(l);return}x.forEach((l,y)=>{l.style.strokeDashoffset=s==="reverse"?`${w[y]*t}`:`${w[y]*(1-t)}`,k&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),q&&$?l.style.stroke=xe(q,$,t):$&&(l.style.stroke=$),O!==null&&M!==null?l.style.strokeWidth=`${O+(M-O)*t}`:M!==null&&(l.style.strokeWidth=`${M}`),C!==null&&T!==null?l.style.fillOpacity=`${C+(T-C)*t}`:T!==null&&(l.style.fillOpacity=`${T}`),H&&l.tagName.toLowerCase()==="path"&&W[y]&&l.setAttribute("d",Ce(W[y],H,t));});}function be(){if(e.style.setProperty("--scroll-draw-progress","0"),_){e.style.clipPath=ne(0);return}x.forEach((t,s)=>{t.style.strokeDasharray=`${w[s]}`,t.style.strokeDashoffset=d==="reverse"?"0":`${w[s]}`,k?t.style.opacity=d==="reverse"?"1":"0":t.style.opacity="",q&&(t.style.stroke=q),O!==null&&(t.style.strokeWidth=`${O}`),C!==null&&(t.style.fillOpacity=`${C}`),H&&t.tagName.toLowerCase()==="path"&&W[s]&&t.setAttribute("d",W[s]);});}if(x.forEach(t=>{it(t);let s=Ee(t);w.push(s),t.tagName.toLowerCase()==="path"?W.push(t.getAttribute("d")??""):W.push(""),h?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=d==="reverse"?`${s}`:"0",k&&(t.style.opacity="1"),$&&(t.style.stroke=$),M!==null&&(t.style.strokeWidth=`${M}`),T!==null&&(t.style.fillOpacity=`${T}`),H&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",H)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=d==="reverse"?"0":`${s}`,k?t.style.opacity=d==="reverse"?"1":"0":t.style.opacity="",q&&(t.style.stroke=q),O!==null&&(t.style.strokeWidth=`${O}`),C!==null&&(t.style.fillOpacity=`${C}`));}),_){if(h)return e.style.clipPath=ne(1),ae?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ne(0);}else if(h)return ae?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function et(){return !(Qe===false||!ot()||!x.length||typeof p!="string"||!(p in Je)||_||R!=="y"||I||E!==1||z!==0||Y||me||pe!==false||H||ee||te||ce>0||ue||de||ae||K!=null||Q!=null||Z!=null||(S.start??"top bottom").trim()!=="top bottom"||(S.end??"bottom top").trim()!=="bottom top")}function tt(){let t=`svg-scroll-draw-${++st}`,s=d==="reverse"?"0":"var(--ssd-len)",l=d==="reverse"?"var(--ssd-len)":"0",y=`stroke-dashoffset:${s};`,F=`stroke-dashoffset:${l};`;k&&(y+=`opacity:${d==="reverse"?1:0};`,F+=`opacity:${d==="reverse"?0:1};`);let P=document.createElement("style");P.setAttribute("data-svg-scroll-draw",""),P.textContent=`@keyframes ${t}{from{${y}}to{${F}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Je[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(P);function a(i,u){i.style.setProperty("--ssd-len",String(w[u])),i.style.strokeDasharray=`${w[u]}`,i.style.strokeDashoffset="",i.style.opacity="",i.style.animationPlayState="",i.classList.add(t);}x.forEach(a);let f=false,b=-1;function c(){if(b>=0)return b;let i=e.getBoundingClientRect(),{tStart:u,tEnd:m}=Ie({top:i.top,height:i.height},fe(),We(),Re,He);return re(ie(fe(),u,m,E))}return {destroy(){x.forEach(i=>{i.classList.remove(t),i.style.removeProperty("--ssd-len"),i.style.animationPlayState="";}),P.remove();},replay(){f=false,b=-1,x.forEach(a);},pause(){f=true,x.forEach(i=>{i.style.animationPlayState="paused";});},resume(){f&&(f=false,x.forEach(i=>{i.style.animationPlayState="running";}));},seek(i){let u=Math.min(1,Math.max(0,i));b=u,f=true,x.forEach((m,oe)=>{m.classList.remove(t),m.style.strokeDashoffset=d==="reverse"?`${w[oe]*u}`:`${w[oe]*(1-u)}`,k&&(m.style.opacity=d==="reverse"?`${1-u}`:`${u}`);});},getProgress(){return c()}}}if(et())return tt();function rt(){let t=Math.max(1,Ke),s=0,l=0;function y(c){let i=true;if(_){let u=Math.min(1,Math.max(0,c/t)),m=re(u);se=m,e.style.setProperty("--scroll-draw-progress",String(m)),e.style.clipPath=ne(d==="reverse"?1-m:m),ue?.(m),u<1&&(i=false);}else x.forEach((u,m)=>{let oe=m*z*t,le=Math.min(1,Math.max(0,(c-oe)/t)),G=re(le);u.style.strokeDashoffset=d==="reverse"?`${w[m]*G}`:`${w[m]*(1-G)}`,k&&(u.style.opacity=d==="reverse"?`${1-G}`:`${G}`),q&&$?u.style.stroke=xe(q,$,G):$&&(u.style.stroke=$),O!==null&&M!==null?u.style.strokeWidth=`${O+(M-O)*G}`:M!==null&&(u.style.strokeWidth=`${M}`),C!==null&&T!==null?u.style.fillOpacity=`${C+(T-C)*G}`:T!==null&&(u.style.fillOpacity=`${T}`),H&&u.tagName.toLowerCase()==="path"&&W[m]&&u.setAttribute("d",Ce(W[m],H,G)),m===0&&(ue?.(G),e.style.setProperty("--scroll-draw-progress",String(G))),le<1&&(i=false);});if(ee){let u=Math.min(1,Math.max(0,c/t)),m=re(u);for(let oe in ee){let le=parseFloat(oe);m>=le&&!U.has(le)&&(U.add(le),ee[oe]?.());}}return i}function F(c){if(D)return;let i=c-s;N||(N=true,de?.());let u=y(i);if(u&&!A){A=true,y(t*(1+Math.max(0,x.length-1)*z)),ae?.(),B<(te==="infinite"?1/0:te??0)&&(B++,J=setTimeout(()=>{s=performance.now(),N=false,A=false,U.clear(),be(),v=requestAnimationFrame(F);},$e));return}u||(v=requestAnimationFrame(F));}function P(){cancelAnimationFrame(v),clearTimeout(J),s=performance.now(),l=0,D=false,N=false,A=false,B=0,U.clear(),be(),v=requestAnimationFrame(F);}let a=new IntersectionObserver(c=>{c.forEach(i=>{i.isIntersecting&&!(Y&&A)?P():!i.isIntersecting&&!Y&&!A&&(cancelAnimationFrame(v),clearTimeout(J),s=null);});},{root:I??null,threshold:Fe,rootMargin:Ne}),f;function b(){clearTimeout(f),f=setTimeout(()=>{x.forEach((c,i)=>{w[i]=Ee(c),c.style.strokeDasharray=`${w[i]}`;});},150);}return window.addEventListener("resize",b),window.addEventListener("orientationchange",b),ce>0?setTimeout(()=>a.observe(e),ce):a.observe(e),{destroy(){cancelAnimationFrame(v),clearTimeout(J),a.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),clearTimeout(f);},replay(){B=0,P();},pause(){D||(D=true,l=performance.now()-s,cancelAnimationFrame(v));},resume(){D&&(D=false,s=performance.now()-l,v=requestAnimationFrame(F));},seek(c){let i=Math.min(1,Math.max(0,c));se=i,D=true,l=i*t,s=performance.now()-l,cancelAnimationFrame(v),y(l);},getProgress(){return se}}}if(Ye)return rt();Ve();function we(){if(!ye||D)return;let t=performance.now(),s=fe(),l=E;if(pe!==false){let a=t-qe,f=a>0?Math.abs(s-(he<0?s:he))/a:0;l=E*Math.max(.2,1+f*(typeof pe=="number"?pe:1)*.04);}he=s,qe=t;let y=me?ge===-1||s>=ge?"forward":"reverse":d;ge=s;let F=X-j,P=true;if(_){let a=re(ie(s,j,X,l));Y&&!me&&(V=Math.max(V,a),a=V),se=a,e.style.setProperty("--scroll-draw-progress",String(a));let f=y==="reverse"?1-a:a;e.style.clipPath=ne(f),ue?.(a),!N&&ie(s,j,X,l)>0&&(N=true,de?.()),a>=1&&!A?(A=true,ae?.(),B<(te==="infinite"?1/0:te??0)&&(B++,J=setTimeout(()=>{V=-1,N=false,A=false,e.style.clipPath=ne(0);},$e))):a<1&&!Y&&(A=false),v=requestAnimationFrame(we);return}if(x.forEach((a,f)=>{let b=f*z*F,c=re(ie(s,j+b,X+b,l));Y&&!me&&(V=Math.max(V,c),c=V),se=c,a.style.strokeDashoffset=y==="reverse"?`${w[f]*c}`:`${w[f]*(1-c)}`,k&&(a.style.opacity=y==="reverse"?`${1-c}`:`${c}`),q&&$?a.style.stroke=xe(q,$,c):$&&(a.style.stroke=$),O!==null&&M!==null?a.style.strokeWidth=`${O+(M-O)*c}`:M!==null&&(a.style.strokeWidth=`${M}`),C!==null&&T!==null?a.style.fillOpacity=`${C+(T-C)*c}`:T!==null&&(a.style.fillOpacity=`${T}`),H&&a.tagName.toLowerCase()==="path"&&W[f]&&a.setAttribute("d",Ce(W[f],H,c)),f===0&&(ue?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(P=false);}),ee){let a=re(ie(s,j,X,l));for(let f in ee){let b=parseFloat(f);a>=b&&!U.has(b)&&(U.add(b),ee[f]?.());}}!N&&ie(s,j,X,l)>0&&(N=true,de?.()),P&&!A?(A=true,ae?.(),B<(te==="infinite"?1/0:te??0)&&(B++,J=setTimeout(()=>{V=-1,N=false,A=false,U.clear(),be();},$e))):!P&&!Y&&(A=false),v=requestAnimationFrame(we);}let De=new IntersectionObserver(t=>{t.forEach(s=>{ye=s.isIntersecting,ye&&!D?v=requestAnimationFrame(we):cancelAnimationFrame(v);});},{root:I??null,threshold:Fe,rootMargin:Ne}),Pe;function ve(){clearTimeout(Pe),Pe=setTimeout(()=>{x.forEach((t,s)=>{w[s]=Ee(t),t.style.strokeDasharray=`${w[s]}`;}),Ve();},150);}return window.addEventListener("resize",ve),window.addEventListener("orientationchange",ve),ce>0?setTimeout(()=>De.observe(e),ce):De.observe(e),{destroy(){cancelAnimationFrame(v),clearTimeout(J),De.disconnect(),window.removeEventListener("resize",ve),window.removeEventListener("orientationchange",ve),clearTimeout(Pe),Te?.remove();},replay(){V=-1,ge=-1,he=-1,N=false,A=false,B=0,D=false,U.clear(),clearTimeout(J),be();},pause(){D=true,cancelAnimationFrame(v);},resume(){D&&(D=false,ye&&(v=requestAnimationFrame(we)));},seek(t){let s=Math.min(1,Math.max(0,t));se=s,V=s,D=true,cancelAnimationFrame(v),Ze(s,d);},getProgress(){return se}}}function lt(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let o=typeof e=="string"?document.querySelector(e):e;return o?Ae(o,r):(console.warn("[svg-scroll-draw] Container not found:",e),n)}function At(e=document){return Array.from(e.querySelectorAll("[data-scroll-draw]")).map(r=>{let n={};try{let o=r.dataset.scrollDrawOptions??r.dataset.scrollDrawoptions??"";o&&(n=JSON.parse(o));}catch{}return Ae(r,n)})}export{At as initScrollDraw,lt as scrollDraw};
1
+ function Ge({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),s=Math.max(.01,Math.min(.99,r)),y=Math.sqrt(s),h=0,L=[];for(let p=0;p<n;p++){let S=Math.pow(y,p);L.push(S),h+=S;}let E=[0],T=0;for(let p=0;p<n;p++)T+=L[p]/h,E.push(T);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let S=0;S<n;S++)if(p<=E[S+1]){let _=(p-E[S])/(E[S+1]-E[S]);if(S===0)return _*(2-_);let d=1-Math.pow(s,S);return d+(1-d)*(2*_-1)*(2*_-1)}return 1}}function je({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),s=Math.max(.1,r),y=n<=1?s/4:s/(2*Math.PI)*Math.asin(1/n);return h=>h<=0?0:h>=1?1:n*Math.pow(2,-10*h)*Math.sin((h-y)*(2*Math.PI)/s)+1}var ce={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:Ge(),elastic:je()};function pe(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 We(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 _e(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 Te(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 nt(e,r,n){return Math.min(n,Math.max(r,e))}function G(e,r,n,s){return n===r?0:nt((e-r)/(n-r)*s,0,1)}function de(e,r,n,s,y){let h=We(e.top,e.height,r,s.element)-_e(s.viewport,n),L=We(e.top,e.height,r,y.element)-_e(y.viewport,n);return {tStart:h,tEnd:L}}function Be(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 ge(e,r,n){let s=Be(e),y=Be(r);return !s||!y?e:`rgb(${Math.round(s[0]+(y[0]-s[0])*n)},${Math.round(s[1]+(y[1]-s[1])*n)},${Math.round(s[2]+(y[2]-s[2])*n)})`}var Ie={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 Xe(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Ye={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},ot=0;function st(){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"?Xe("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Xe("Element has a fill \u2014 it may obscure the stroke animation.",e);}function at(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 y(){let h=n==="x"?window.scrollX:window.scrollY,L=e-h,E=r-h,T=n==="x";s.innerHTML=`
2
+ <div style="position:absolute;${T?`left:${L}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${L}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;${T?`left:${E}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${E}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",y,{passive:true}),y(),s}function Oe(e,r,n){let s=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),y=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,h=>{let L=parseFloat(h),E=s[y++]??L;return String(+(L+(E-L)*n).toFixed(4))})}function $e(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:n,...s}=r,y=n?{...Ie[n],...s}:s,h=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:L="path, polyline, line, polygon, rect, circle",speed:E=1,fade:T=false,easing:p="linear",trigger:S={},stagger:_=0,direction:d="forward",once:Z=false,debug:Ue=false,axis:R="y",scrollContainer:Me,autoReverse:ye=false,delay:ue=0,strokeColor:K,strokeWidth:Q,fillOpacity:ee,waypoints:te,velocityScale:he=false,threshold:Fe=0,rootMargin:Ne="0px",repeat:re=0,repeatDelay:Pe=0,morphTo:H,clip:ke,autoplay:Je=false,duration:Ze=1e3,native:Ke=true,onProgress:me,onStart:be,onComplete:ae}=y,j=ke===true?"left":typeof ke=="string"?ke:false,ne=typeof p=="function"?p:ce[p]??ce.linear,Re=pe(S.start??"top bottom"),He=pe(S.end??"bottom top"),D=typeof Me=="string"?document.querySelector(Me):Me??null,q=Array.isArray(K)?K[0]:null,$=Array.isArray(K)?K[1]:typeof K=="string"?K:null,I=Array.isArray(Q)?Q[0]:null,M=Array.isArray(Q)?Q[1]:typeof Q=="number"?Q:null,O=Array.isArray(ee)?ee[0]:null,P=Array.isArray(ee)?ee[1]:typeof ee=="number"?ee:null;function oe(t){let o=t*100;switch(j){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 x=j?[]:Array.from(e.querySelectorAll(L)),w=[],z=[],X=0,Y=0,A=false,N=false,v=0,we=false,V=-1,ve=-1,k=false,se=0,B=0,U,Ce=null,J=new Set,Se=-1,qe=performance.now();function fe(){return D?R==="x"?D.scrollLeft:D.scrollTop:R==="x"?window.scrollX:window.scrollY}function ze(){return D?R==="x"?D.clientWidth:D.clientHeight:R==="x"?window.innerWidth:window.innerHeight}function Ve(){let t=e.getBoundingClientRect(),o,l,g;if(D){let C=D.getBoundingClientRect();o=R==="x"?t.left-C.left+D.scrollLeft:t.top-C.top+D.scrollTop,l=R==="x"?t.width:t.height,g=fe();}else o=R==="x"?t.left:t.top,l=R==="x"?t.width:t.height,g=fe();let F=de({top:o,height:l},g,ze(),Re,He);X=F.tStart,Y=F.tEnd,Ue&&process.env.NODE_ENV!=="production"&&(Ce?.remove(),Ce=at(X,Y,R));}function Qe(t,o){if(e.style.setProperty("--scroll-draw-progress",String(t)),j){let l=o==="reverse"?1-t:t;e.style.clipPath=oe(l);return}x.forEach((l,g)=>{l.style.strokeDashoffset=o==="reverse"?`${w[g]*t}`:`${w[g]*(1-t)}`,T&&(l.style.opacity=o==="reverse"?`${1-t}`:`${t}`),q&&$?l.style.stroke=ge(q,$,t):$&&(l.style.stroke=$),I!==null&&M!==null?l.style.strokeWidth=`${I+(M-I)*t}`:M!==null&&(l.style.strokeWidth=`${M}`),O!==null&&P!==null?l.style.fillOpacity=`${O+(P-O)*t}`:P!==null&&(l.style.fillOpacity=`${P}`),H&&l.tagName.toLowerCase()==="path"&&z[g]&&l.setAttribute("d",Oe(z[g],H,t));});}function Ee(){if(e.style.setProperty("--scroll-draw-progress","0"),j){e.style.clipPath=oe(0);return}x.forEach((t,o)=>{t.style.strokeDasharray=`${w[o]}`,t.style.strokeDashoffset=d==="reverse"?"0":`${w[o]}`,T?t.style.opacity=d==="reverse"?"1":"0":t.style.opacity="",q&&(t.style.stroke=q),I!==null&&(t.style.strokeWidth=`${I}`),O!==null&&(t.style.fillOpacity=`${O}`),H&&t.tagName.toLowerCase()==="path"&&z[o]&&t.setAttribute("d",z[o]);});}if(x.forEach(t=>{it(t);let o=Te(t);w.push(o),t.tagName.toLowerCase()==="path"?z.push(t.getAttribute("d")??""):z.push(""),h?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=d==="reverse"?`${o}`:"0",T&&(t.style.opacity="1"),$&&(t.style.stroke=$),M!==null&&(t.style.strokeWidth=`${M}`),P!==null&&(t.style.fillOpacity=`${P}`),H&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",H)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=d==="reverse"?"0":`${o}`,T?t.style.opacity=d==="reverse"?"1":"0":t.style.opacity="",q&&(t.style.stroke=q),I!==null&&(t.style.strokeWidth=`${I}`),O!==null&&(t.style.fillOpacity=`${O}`));}),j){if(h)return e.style.clipPath=oe(1),ae?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=oe(0);}else if(h)return ae?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function et(){return !(Ke===false||!st()||!x.length||typeof p!="string"||!(p in Ye)||j||R!=="y"||D||E!==1||_!==0||Z||ye||he!==false||H||te||re||ue>0||me||be||ae||K!=null||Q!=null||ee!=null||(S.start??"top bottom").trim()!=="top bottom"||(S.end??"bottom top").trim()!=="bottom top")}function tt(){let t=`svg-scroll-draw-${++ot}`,o=d==="reverse"?"0":"var(--ssd-len)",l=d==="reverse"?"var(--ssd-len)":"0",g=`stroke-dashoffset:${o};`,F=`stroke-dashoffset:${l};`;T&&(g+=`opacity:${d==="reverse"?1:0};`,F+=`opacity:${d==="reverse"?0:1};`);let C=document.createElement("style");C.setAttribute("data-svg-scroll-draw",""),C.textContent=`@keyframes ${t}{from{${g}}to{${F}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Ye[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(C);function a(i,u){i.style.setProperty("--ssd-len",String(w[u])),i.style.strokeDasharray=`${w[u]}`,i.style.strokeDashoffset="",i.style.opacity="",i.style.animationPlayState="",i.classList.add(t);}x.forEach(a);let m=false,b=-1;function c(){if(b>=0)return b;let i=e.getBoundingClientRect(),{tStart:u,tEnd:f}=de({top:i.top,height:i.height},fe(),ze(),Re,He);return ne(G(fe(),u,f,E))}return {destroy(){x.forEach(i=>{i.classList.remove(t),i.style.removeProperty("--ssd-len"),i.style.animationPlayState="";}),C.remove();},replay(){m=false,b=-1,x.forEach(a);},pause(){m=true,x.forEach(i=>{i.style.animationPlayState="paused";});},resume(){m&&(m=false,x.forEach(i=>{i.style.animationPlayState="running";}));},seek(i){let u=Math.min(1,Math.max(0,i));b=u,m=true,x.forEach((f,ie)=>{f.classList.remove(t),f.style.strokeDashoffset=d==="reverse"?`${w[ie]*u}`:`${w[ie]*(1-u)}`,T&&(f.style.opacity=d==="reverse"?`${1-u}`:`${u}`);});},getProgress(){return c()}}}if(et())return tt();function rt(){let t=Math.max(1,Ze),o=0,l=0;function g(c){let i=true;if(j){let u=Math.min(1,Math.max(0,c/t)),f=ne(u);se=f,e.style.setProperty("--scroll-draw-progress",String(f)),e.style.clipPath=oe(d==="reverse"?1-f:f),me?.(f),u<1&&(i=false);}else x.forEach((u,f)=>{let ie=f*_*t,le=Math.min(1,Math.max(0,(c-ie)/t)),W=ne(le);u.style.strokeDashoffset=d==="reverse"?`${w[f]*W}`:`${w[f]*(1-W)}`,T&&(u.style.opacity=d==="reverse"?`${1-W}`:`${W}`),q&&$?u.style.stroke=ge(q,$,W):$&&(u.style.stroke=$),I!==null&&M!==null?u.style.strokeWidth=`${I+(M-I)*W}`:M!==null&&(u.style.strokeWidth=`${M}`),O!==null&&P!==null?u.style.fillOpacity=`${O+(P-O)*W}`:P!==null&&(u.style.fillOpacity=`${P}`),H&&u.tagName.toLowerCase()==="path"&&z[f]&&u.setAttribute("d",Oe(z[f],H,W)),f===0&&(me?.(W),e.style.setProperty("--scroll-draw-progress",String(W))),le<1&&(i=false);});if(te){let u=Math.min(1,Math.max(0,c/t)),f=ne(u);for(let ie in te){let le=parseFloat(ie);f>=le&&!J.has(le)&&(J.add(le),te[ie]?.());}}return i}function F(c){if(k)return;let i=c-o;N||(N=true,be?.());let u=g(i);if(u&&!A){A=true,g(t*(1+Math.max(0,x.length-1)*_)),ae?.(),B<(re==="infinite"?1/0:re??0)&&(B++,U=setTimeout(()=>{o=performance.now(),N=false,A=false,J.clear(),Ee(),v=requestAnimationFrame(F);},Pe));return}u||(v=requestAnimationFrame(F));}function C(){cancelAnimationFrame(v),clearTimeout(U),o=performance.now(),l=0,k=false,N=false,A=false,B=0,J.clear(),Ee(),v=requestAnimationFrame(F);}let a=new IntersectionObserver(c=>{c.forEach(i=>{i.isIntersecting&&!(Z&&A)?C():!i.isIntersecting&&!Z&&!A&&(cancelAnimationFrame(v),clearTimeout(U),o=null);});},{root:D??null,threshold:Fe,rootMargin:Ne}),m;function b(){clearTimeout(m),m=setTimeout(()=>{x.forEach((c,i)=>{w[i]=Te(c),c.style.strokeDasharray=`${w[i]}`;});},150);}return window.addEventListener("resize",b),window.addEventListener("orientationchange",b),ue>0?setTimeout(()=>a.observe(e),ue):a.observe(e),{destroy(){cancelAnimationFrame(v),clearTimeout(U),a.disconnect(),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),clearTimeout(m);},replay(){B=0,C();},pause(){k||(k=true,l=performance.now()-o,cancelAnimationFrame(v));},resume(){k&&(k=false,o=performance.now()-l,v=requestAnimationFrame(F));},seek(c){let i=Math.min(1,Math.max(0,c));se=i,k=true,l=i*t,o=performance.now()-l,cancelAnimationFrame(v),g(l);},getProgress(){return se}}}if(Je)return rt();Ve();function xe(){if(!we||k)return;let t=performance.now(),o=fe(),l=E;if(he!==false){let a=t-qe,m=a>0?Math.abs(o-(Se<0?o:Se))/a:0;l=E*Math.max(.2,1+m*(typeof he=="number"?he:1)*.04);}Se=o,qe=t;let g=ye?ve===-1||o>=ve?"forward":"reverse":d;ve=o;let F=Y-X,C=true;if(j){let a=ne(G(o,X,Y,l));Z&&!ye&&(V=Math.max(V,a),a=V),se=a,e.style.setProperty("--scroll-draw-progress",String(a));let m=g==="reverse"?1-a:a;e.style.clipPath=oe(m),me?.(a),!N&&G(o,X,Y,l)>0&&(N=true,be?.()),a>=1&&!A?(A=true,ae?.(),B<(re==="infinite"?1/0:re??0)&&(B++,U=setTimeout(()=>{V=-1,N=false,A=false,e.style.clipPath=oe(0);},Pe))):a<1&&!Z&&(A=false),v=requestAnimationFrame(xe);return}if(x.forEach((a,m)=>{let b=m*_*F,c=ne(G(o,X+b,Y+b,l));Z&&!ye&&(V=Math.max(V,c),c=V),se=c,a.style.strokeDashoffset=g==="reverse"?`${w[m]*c}`:`${w[m]*(1-c)}`,T&&(a.style.opacity=g==="reverse"?`${1-c}`:`${c}`),q&&$?a.style.stroke=ge(q,$,c):$&&(a.style.stroke=$),I!==null&&M!==null?a.style.strokeWidth=`${I+(M-I)*c}`:M!==null&&(a.style.strokeWidth=`${M}`),O!==null&&P!==null?a.style.fillOpacity=`${O+(P-O)*c}`:P!==null&&(a.style.fillOpacity=`${P}`),H&&a.tagName.toLowerCase()==="path"&&z[m]&&a.setAttribute("d",Oe(z[m],H,c)),m===0&&(me?.(c),e.style.setProperty("--scroll-draw-progress",String(c))),c<1&&(C=false);}),te){let a=ne(G(o,X,Y,l));for(let m in te){let b=parseFloat(m);a>=b&&!J.has(b)&&(J.add(b),te[m]?.());}}!N&&G(o,X,Y,l)>0&&(N=true,be?.()),C&&!A?(A=true,ae?.(),B<(re==="infinite"?1/0:re??0)&&(B++,U=setTimeout(()=>{V=-1,N=false,A=false,J.clear(),Ee();},Pe))):!C&&!Z&&(A=false),v=requestAnimationFrame(xe);}let Le=new IntersectionObserver(t=>{t.forEach(o=>{we=o.isIntersecting,we&&!k?v=requestAnimationFrame(xe):cancelAnimationFrame(v);});},{root:D??null,threshold:Fe,rootMargin:Ne}),De;function Ae(){clearTimeout(De),De=setTimeout(()=>{x.forEach((t,o)=>{w[o]=Te(t),t.style.strokeDasharray=`${w[o]}`;}),Ve();},150);}return window.addEventListener("resize",Ae),window.addEventListener("orientationchange",Ae),ue>0?setTimeout(()=>Le.observe(e),ue):Le.observe(e),{destroy(){cancelAnimationFrame(v),clearTimeout(U),Le.disconnect(),window.removeEventListener("resize",Ae),window.removeEventListener("orientationchange",Ae),clearTimeout(De),Ce?.remove();},replay(){V=-1,ve=-1,Se=-1,N=false,A=false,B=0,k=false,J.clear(),clearTimeout(U),Ee();},pause(){k=true,cancelAnimationFrame(v);},resume(){k&&(k=false,we&&(v=requestAnimationFrame(xe)));},seek(t){let o=Math.min(1,Math.max(0,t));se=o,V=o,k=true,cancelAnimationFrame(v),Qe(o,d);},getProgress(){return se}}}function ut(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let s=typeof e=="string"?document.querySelector(e):e;return s?$e(s,r):(console.warn("[svg-scroll-draw] Container not found:",e),n)}function Ht(e=document){return Array.from(e.querySelectorAll("[data-scroll-draw]")).map(r=>{let n={};try{let s=r.dataset.scrollDrawOptions??r.dataset.scrollDrawoptions??"";s&&(n=JSON.parse(s));}catch{}return $e(r,n)})}export{Ht as initScrollDraw,ut as scrollDraw};
@@ -1,3 +1,3 @@
1
- "use strict";var SvgScrollDraw=(()=>{var Fe=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var mt=Object.prototype.hasOwnProperty;var pt=(e,r)=>{for(var n in r)Fe(e,n,{get:r[n],enumerable:!0})},dt=(e,r,n,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let c of ft(r))!mt.call(e,c)&&c!==n&&Fe(e,c,{get:()=>r[c],enumerable:!(s=ut(r,c))||s.enumerable});return e};var yt=e=>dt(Fe({},"__esModule",{value:!0}),e);var kt={};pt(kt,{Cinematic:()=>De,PRESETS:()=>$e,createBounce:()=>Ne,createElastic:()=>Re,createSpring:()=>Ze,scrollDraw:()=>At});function Ze({tension:e=2.5,friction:r=2.2}={}){return n=>1-Math.cos(n*Math.PI*e)*Math.pow(1-n,r)}function Ne({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),s=Math.max(.01,Math.min(.99,r)),c=Math.sqrt(s),p=0,x=[];for(let d=0;d<n;d++){let A=Math.pow(c,d);x.push(A),p+=A}let b=[0],$=0;for(let d=0;d<n;d++)$+=x[d]/p,b.push($);return d=>{if(d<=0)return 0;if(d>=1)return 1;for(let A=0;A<n;A++)if(d<=b[A+1]){let W=(d-b[A])/(b[A+1]-b[A]);if(A===0)return W*(2-W);let w=1-Math.pow(s,A);return w+(1-w)*(2*W-1)*(2*W-1)}return 1}}function Re({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),s=Math.max(.1,r),c=n<=1?s/4:s/(2*Math.PI)*Math.asin(1/n);return p=>p<=0?0:p>=1?1:n*Math.pow(2,-10*p)*Math.sin((p-c)*(2*Math.PI)/s)+1}var re={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:Ne(),elastic:Re()};function He(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 Je(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 Ke(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 Ae(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 gt(e,r,n){return Math.min(n,Math.max(r,e))}function ue(e,r,n,s){return n===r?0:gt((e-r)/(n-r)*s,0,1)}function qe(e,r,n,s,c){let p=Je(e.top,e.height,r,s.element)-Ke(s.viewport,n),x=Je(e.top,e.height,r,c.element)-Ke(c.viewport,n);return{tStart:p,tEnd:x}}function Qe(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 ke(e,r,n){let s=Qe(e),c=Qe(r);return!s||!c?e:`rgb(${Math.round(s[0]+(c[0]-s[0])*n)},${Math.round(s[1]+(c[1]-s[1])*n)},${Math.round(s[2]+(c[2]-s[2])*n)})`}var $e={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:!1},reveal:{easing:"ease-out",fade:!0,speed:1.2,once:!0},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:!0,speed:.75},spring:{easing:"spring",speed:1.1}};function et(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r)}var tt={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},ht=0;function bt(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function wt(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?et("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&et("Element has a fill \u2014 it may obscure the stroke animation.",e)}function vt(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 c(){let p=n==="x"?window.scrollX:window.scrollY,x=e-p,b=r-p,$=n==="x";s.innerHTML=`
2
- <div style="position:absolute;${$?`left:${x}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${x}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;${$?`left:${b}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${b}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",c,{passive:!0}),c(),s}function We(e,r,n){let s=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),c=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,p=>{let x=parseFloat(p),b=s[c++]??x;return String(+(x+(b-x)*n).toFixed(4))})}function Me(e,r={}){if(typeof window>"u")return{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:n,...s}=r,c=n?{...$e[n],...s}:s,p=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:x="path, polyline, line, polygon, rect, circle",speed:b=1,fade:$=!1,easing:d="linear",trigger:A={},stagger:W=0,direction:w="forward",once:B=!1,debug:ye=!1,axis:y="y",scrollContainer:v,autoReverse:u=!1,delay:E=0,strokeColor:g,strokeWidth:G,fillOpacity:ne,waypoints:se,velocityScale:ge=!1,threshold:ze=0,rootMargin:Be="0px",repeat:oe=0,repeatDelay:Pe=0,morphTo:_,clip:Le,autoplay:nt=!1,duration:st=1e3,native:ot=!0,onProgress:pe,onStart:he,onComplete:fe}=c,K=Le===!0?"left":typeof Le=="string"?Le:!1,ie=typeof d=="function"?d:re[d]??re.linear,_e=He(A.start??"top bottom"),je=He(A.end??"bottom top"),R=typeof v=="string"?document.querySelector(v):v??null,j=Array.isArray(g)?g[0]:null,I=Array.isArray(g)?g[1]:typeof g=="string"?g:null,H=Array.isArray(G)?G[0]:null,C=Array.isArray(G)?G[1]:typeof G=="number"?G:null,q=Array.isArray(ne)?ne[0]:null,O=Array.isArray(ne)?ne[1]:typeof ne=="number"?ne:null;function ae(t){let o=t*100;switch(K){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 P=K?[]:Array.from(e.querySelectorAll(x)),T=[],X=[],Q=0,Z=0,L=!1,z=!1,D=0,be=!1,U=-1,we=-1,F=!1,le=0,J=0,ee,Ie=null,te=new Set,ve=-1,Xe=performance.now();function de(){return R?y==="x"?R.scrollLeft:R.scrollTop:y==="x"?window.scrollX:window.scrollY}function Ue(){return R?y==="x"?R.clientWidth:R.clientHeight:y==="x"?window.innerWidth:window.innerHeight}function Ye(){let t=e.getBoundingClientRect(),o,l,k;if(R){let N=R.getBoundingClientRect();o=y==="x"?t.left-N.left+R.scrollLeft:t.top-N.top+R.scrollTop,l=y==="x"?t.width:t.height,k=de()}else o=y==="x"?t.left:t.top,l=y==="x"?t.width:t.height,k=de();let V=qe({top:o,height:l},k,Ue(),_e,je);Q=V.tStart,Z=V.tEnd,ye&&process.env.NODE_ENV!=="production"&&(Ie?.remove(),Ie=vt(Q,Z,y))}function it(t,o){if(e.style.setProperty("--scroll-draw-progress",String(t)),K){let l=o==="reverse"?1-t:t;e.style.clipPath=ae(l);return}P.forEach((l,k)=>{l.style.strokeDashoffset=o==="reverse"?`${T[k]*t}`:`${T[k]*(1-t)}`,$&&(l.style.opacity=o==="reverse"?`${1-t}`:`${t}`),j&&I?l.style.stroke=ke(j,I,t):I&&(l.style.stroke=I),H!==null&&C!==null?l.style.strokeWidth=`${H+(C-H)*t}`:C!==null&&(l.style.strokeWidth=`${C}`),q!==null&&O!==null?l.style.fillOpacity=`${q+(O-q)*t}`:O!==null&&(l.style.fillOpacity=`${O}`),_&&l.tagName.toLowerCase()==="path"&&X[k]&&l.setAttribute("d",We(X[k],_,t))})}function Se(){if(e.style.setProperty("--scroll-draw-progress","0"),K){e.style.clipPath=ae(0);return}P.forEach((t,o)=>{t.style.strokeDasharray=`${T[o]}`,t.style.strokeDashoffset=w==="reverse"?"0":`${T[o]}`,$?t.style.opacity=w==="reverse"?"1":"0":t.style.opacity="",j&&(t.style.stroke=j),H!==null&&(t.style.strokeWidth=`${H}`),q!==null&&(t.style.fillOpacity=`${q}`),_&&t.tagName.toLowerCase()==="path"&&X[o]&&t.setAttribute("d",X[o])})}if(P.forEach(t=>{wt(t);let o=Ae(t);T.push(o),t.tagName.toLowerCase()==="path"?X.push(t.getAttribute("d")??""):X.push(""),p?(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=w==="reverse"?`${o}`:"0",$&&(t.style.opacity="1"),I&&(t.style.stroke=I),C!==null&&(t.style.strokeWidth=`${C}`),O!==null&&(t.style.fillOpacity=`${O}`),_&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",_)):(t.style.strokeDasharray=`${o}`,t.style.strokeDashoffset=w==="reverse"?"0":`${o}`,$?t.style.opacity=w==="reverse"?"1":"0":t.style.opacity="",j&&(t.style.stroke=j),H!==null&&(t.style.strokeWidth=`${H}`),q!==null&&(t.style.fillOpacity=`${q}`))}),K){if(p)return e.style.clipPath=ae(1),fe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ae(0)}else if(p)return fe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function at(){return!(ot===!1||!bt()||!P.length||typeof d!="string"||!(d in tt)||K||y!=="y"||R||b!==1||W!==0||B||u||ge!==!1||_||se||oe||E>0||pe||he||fe||g!=null||G!=null||ne!=null||(A.start??"top bottom").trim()!=="top bottom"||(A.end??"bottom top").trim()!=="bottom top")}function lt(){let t=`svg-scroll-draw-${++ht}`,o=w==="reverse"?"0":"var(--ssd-len)",l=w==="reverse"?"var(--ssd-len)":"0",k=`stroke-dashoffset:${o};`,V=`stroke-dashoffset:${l};`;$&&(k+=`opacity:${w==="reverse"?1:0};`,V+=`opacity:${w==="reverse"?0:1};`);let N=document.createElement("style");N.setAttribute("data-svg-scroll-draw",""),N.textContent=`@keyframes ${t}{from{${k}}to{${V}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${tt[d]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(N);function a(i,m){i.style.setProperty("--ssd-len",String(T[m])),i.style.strokeDasharray=`${T[m]}`,i.style.strokeDashoffset="",i.style.opacity="",i.style.animationPlayState="",i.classList.add(t)}P.forEach(a);let h=!1,M=-1;function f(){if(M>=0)return M;let i=e.getBoundingClientRect(),{tStart:m,tEnd:S}=qe({top:i.top,height:i.height},de(),Ue(),_e,je);return ie(ue(de(),m,S,b))}return{destroy(){P.forEach(i=>{i.classList.remove(t),i.style.removeProperty("--ssd-len"),i.style.animationPlayState=""}),N.remove()},replay(){h=!1,M=-1,P.forEach(a)},pause(){h=!0,P.forEach(i=>{i.style.animationPlayState="paused"})},resume(){h&&(h=!1,P.forEach(i=>{i.style.animationPlayState="running"}))},seek(i){let m=Math.min(1,Math.max(0,i));M=m,h=!0,P.forEach((S,ce)=>{S.classList.remove(t),S.style.strokeDashoffset=w==="reverse"?`${T[ce]*m}`:`${T[ce]*(1-m)}`,$&&(S.style.opacity=w==="reverse"?`${1-m}`:`${m}`)})},getProgress(){return f()}}}if(at())return lt();function ct(){let t=Math.max(1,st),o=0,l=0;function k(f){let i=!0;if(K){let m=Math.min(1,Math.max(0,f/t)),S=ie(m);le=S,e.style.setProperty("--scroll-draw-progress",String(S)),e.style.clipPath=ae(w==="reverse"?1-S:S),pe?.(S),m<1&&(i=!1)}else P.forEach((m,S)=>{let ce=S*W*t,me=Math.min(1,Math.max(0,(f-ce)/t)),Y=ie(me);m.style.strokeDashoffset=w==="reverse"?`${T[S]*Y}`:`${T[S]*(1-Y)}`,$&&(m.style.opacity=w==="reverse"?`${1-Y}`:`${Y}`),j&&I?m.style.stroke=ke(j,I,Y):I&&(m.style.stroke=I),H!==null&&C!==null?m.style.strokeWidth=`${H+(C-H)*Y}`:C!==null&&(m.style.strokeWidth=`${C}`),q!==null&&O!==null?m.style.fillOpacity=`${q+(O-q)*Y}`:O!==null&&(m.style.fillOpacity=`${O}`),_&&m.tagName.toLowerCase()==="path"&&X[S]&&m.setAttribute("d",We(X[S],_,Y)),S===0&&(pe?.(Y),e.style.setProperty("--scroll-draw-progress",String(Y))),me<1&&(i=!1)});if(se){let m=Math.min(1,Math.max(0,f/t)),S=ie(m);for(let ce in se){let me=parseFloat(ce);S>=me&&!te.has(me)&&(te.add(me),se[ce]?.())}}return i}function V(f){if(F)return;let i=f-o;z||(z=!0,he?.());let m=k(i);if(m&&!L){L=!0,k(t*(1+Math.max(0,P.length-1)*W)),fe?.(),J<(oe==="infinite"?1/0:oe??0)&&(J++,ee=setTimeout(()=>{o=performance.now(),z=!1,L=!1,te.clear(),Se(),D=requestAnimationFrame(V)},Pe));return}m||(D=requestAnimationFrame(V))}function N(){cancelAnimationFrame(D),clearTimeout(ee),o=performance.now(),l=0,F=!1,z=!1,L=!1,J=0,te.clear(),Se(),D=requestAnimationFrame(V)}let a=new IntersectionObserver(f=>{f.forEach(i=>{i.isIntersecting&&!(B&&L)?N():!i.isIntersecting&&!B&&!L&&(cancelAnimationFrame(D),clearTimeout(ee),o=null)})},{root:R??null,threshold:ze,rootMargin:Be}),h;function M(){clearTimeout(h),h=setTimeout(()=>{P.forEach((f,i)=>{T[i]=Ae(f),f.style.strokeDasharray=`${T[i]}`})},150)}return window.addEventListener("resize",M),window.addEventListener("orientationchange",M),E>0?setTimeout(()=>a.observe(e),E):a.observe(e),{destroy(){cancelAnimationFrame(D),clearTimeout(ee),a.disconnect(),window.removeEventListener("resize",M),window.removeEventListener("orientationchange",M),clearTimeout(h)},replay(){J=0,N()},pause(){F||(F=!0,l=performance.now()-o,cancelAnimationFrame(D))},resume(){F&&(F=!1,o=performance.now()-l,D=requestAnimationFrame(V))},seek(f){let i=Math.min(1,Math.max(0,f));le=i,F=!0,l=i*t,o=performance.now()-l,cancelAnimationFrame(D),k(l)},getProgress(){return le}}}if(nt)return ct();Ye();function Ee(){if(!be||F)return;let t=performance.now(),o=de(),l=b;if(ge!==!1){let a=t-Xe,h=a>0?Math.abs(o-(ve<0?o:ve))/a:0;l=b*Math.max(.2,1+h*(typeof ge=="number"?ge:1)*.04)}ve=o,Xe=t;let k=u?we===-1||o>=we?"forward":"reverse":w;we=o;let V=Z-Q,N=!0;if(K){let a=ie(ue(o,Q,Z,l));B&&!u&&(U=Math.max(U,a),a=U),le=a,e.style.setProperty("--scroll-draw-progress",String(a));let h=k==="reverse"?1-a:a;e.style.clipPath=ae(h),pe?.(a),!z&&ue(o,Q,Z,l)>0&&(z=!0,he?.()),a>=1&&!L?(L=!0,fe?.(),J<(oe==="infinite"?1/0:oe??0)&&(J++,ee=setTimeout(()=>{U=-1,z=!1,L=!1,e.style.clipPath=ae(0)},Pe))):a<1&&!B&&(L=!1),D=requestAnimationFrame(Ee);return}if(P.forEach((a,h)=>{let M=h*W*V,f=ie(ue(o,Q+M,Z+M,l));B&&!u&&(U=Math.max(U,f),f=U),le=f,a.style.strokeDashoffset=k==="reverse"?`${T[h]*f}`:`${T[h]*(1-f)}`,$&&(a.style.opacity=k==="reverse"?`${1-f}`:`${f}`),j&&I?a.style.stroke=ke(j,I,f):I&&(a.style.stroke=I),H!==null&&C!==null?a.style.strokeWidth=`${H+(C-H)*f}`:C!==null&&(a.style.strokeWidth=`${C}`),q!==null&&O!==null?a.style.fillOpacity=`${q+(O-q)*f}`:O!==null&&(a.style.fillOpacity=`${O}`),_&&a.tagName.toLowerCase()==="path"&&X[h]&&a.setAttribute("d",We(X[h],_,f)),h===0&&(pe?.(f),e.style.setProperty("--scroll-draw-progress",String(f))),f<1&&(N=!1)}),se){let a=ie(ue(o,Q,Z,l));for(let h in se){let M=parseFloat(h);a>=M&&!te.has(M)&&(te.add(M),se[h]?.())}}!z&&ue(o,Q,Z,l)>0&&(z=!0,he?.()),N&&!L?(L=!0,fe?.(),J<(oe==="infinite"?1/0:oe??0)&&(J++,ee=setTimeout(()=>{U=-1,z=!1,L=!1,te.clear(),Se()},Pe))):!N&&!B&&(L=!1),D=requestAnimationFrame(Ee)}let Ce=new IntersectionObserver(t=>{t.forEach(o=>{be=o.isIntersecting,be&&!F?D=requestAnimationFrame(Ee):cancelAnimationFrame(D)})},{root:R??null,threshold:ze,rootMargin:Be}),Oe;function xe(){clearTimeout(Oe),Oe=setTimeout(()=>{P.forEach((t,o)=>{T[o]=Ae(t),t.style.strokeDasharray=`${T[o]}`}),Ye()},150)}return window.addEventListener("resize",xe),window.addEventListener("orientationchange",xe),E>0?setTimeout(()=>Ce.observe(e),E):Ce.observe(e),{destroy(){cancelAnimationFrame(D),clearTimeout(ee),Ce.disconnect(),window.removeEventListener("resize",xe),window.removeEventListener("orientationchange",xe),clearTimeout(Oe),Ie?.remove()},replay(){U=-1,we=-1,ve=-1,z=!1,L=!1,J=0,F=!1,te.clear(),clearTimeout(ee),Se()},pause(){F=!0,cancelAnimationFrame(D)},resume(){F&&(F=!1,be&&(D=requestAnimationFrame(Ee)))},seek(t){let o=Math.min(1,Math.max(0,t));le=o,U=o,F=!0,cancelAnimationFrame(D),it(o,w)},getProgress(){return le}}}var rt="http://www.w3.org/2000/svg",St="cinematic-photo",Ve=e=>e<0?0:e>1?1:e;function Te(e){let r=parseFloat(e);return Number.isFinite(r)?Ve(r/100):0}function Et(e){return re[e]??re.linear}var xt={destroy:()=>{},getProgress:()=>0},De=class{constructor(r){if(typeof document>"u"){this.mount=null;return}this.mount=typeof r.wrapper=="string"?document.querySelector(r.wrapper):r.wrapper,!this.mount&&process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] Cinematic: wrapper not found:",r.wrapper)}loadStory(r){let n=this.mount;if(typeof window>"u"||!n)return xt;n.style.position="relative",n.style.height=r.totalHeight,n.style.display="block";let s=document.createElement("div");s.setAttribute("data-cinematic-stage",""),s.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",n.appendChild(s);let c=[];for(let y of r.scenes){if(y.background){let u=document.createElement("img");u.id=St,u.src=y.background,u.alt="",u.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",s.appendChild(u)}let v=y.animations.filter(u=>u.type==="draw");if(v.length){let u=document.createElementNS(rt,"svg");u.setAttribute("viewBox",`0 0 ${r.canvas.width} ${r.canvas.height}`),u.setAttribute("preserveAspectRatio","xMidYMid meet"),u.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",s.appendChild(u);for(let E of v){let g=document.createElementNS(rt,"path");g.id=E.target.replace(/^#/,""),g.setAttribute("d",E.d),g.setAttribute("fill","none"),g.setAttribute("stroke",E.stroke),g.setAttribute("stroke-width",String(E.strokeWidth)),g.setAttribute("stroke-linecap","round"),g.setAttribute("stroke-linejoin","round");let G=E.length||g.getTotalLength?.()||0;g.style.strokeDasharray=String(G),g.style.strokeDashoffset=String(G),u.appendChild(g),c.push({kind:"draw",el:g,start:Te(E.start),end:Te(E.end),ease:Et(E.easing),length:G})}}for(let u of y.animations){if(u.type!=="fade")continue;let E=s.querySelector(u.target)??document.querySelector(u.target);E&&(E.style.opacity=String(u.from),c.push({kind:"fade",el:E,start:Te(u.start),end:Te(u.end),ease:re["ease-in-out"]??re.linear,from:u.from,to:u.to}))}}let p=0,x=()=>{let y=n.offsetHeight-window.innerHeight;return y<=0?n.getBoundingClientRect().top<=0?1:0:Ve(-n.getBoundingClientRect().top/y)},b=y=>{for(let v of c){let u=v.end-v.start,E=u<=0?y>=v.end?1:0:Ve((y-v.start)/u),g=v.ease(E);v.kind==="draw"?v.el.style.strokeDashoffset=String(v.length*(1-g)):v.el.style.opacity=String(v.from+(v.to-v.from)*g)}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return b(1),{destroy:()=>{},getProgress:()=>1};let $=0,d=!1,A=!1,W=()=>{p=x(),b(p),d&&($=requestAnimationFrame(W))},w=()=>{d||(d=!0,$=requestAnimationFrame(W))},B=()=>{d=!1,cancelAnimationFrame($)},ye=new IntersectionObserver(y=>{for(let v of y)A=v.isIntersecting,A?w():B()},{threshold:0});return ye.observe(s),p=x(),b(p),{destroy(){B(),ye.disconnect()},getProgress:()=>p}}};function At(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let s=typeof e=="string"?document.querySelector(e):e;return s?Me(s,r):(console.warn("[svg-scroll-draw] Container not found:",e),n)}var Ge=class extends HTMLElement{constructor(){super(...arguments);this.instance=null}connectedCallback(){let n={},s=this.getAttribute("speed"),c=this.getAttribute("easing"),p=this.getAttribute("stagger"),x=this.getAttribute("direction"),b=this.getAttribute("selector");s&&(n.speed=parseFloat(s)),c&&(n.easing=c),p&&(n.stagger=parseFloat(p)),x&&(n.direction=x),b&&(n.selector=b),this.hasAttribute("fade")&&(n.fade=this.getAttribute("fade")!=="false"),this.instance=Me(this,n)}disconnectedCallback(){this.instance?.destroy(),this.instance=null}};typeof customElements<"u"&&!customElements.get("scroll-draw")&&customElements.define("scroll-draw",Ge);return yt(kt);})();
1
+ "use strict";var SvgScrollDraw=(()=>{var Xe=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var At=Object.prototype.hasOwnProperty;var Tt=(e,r)=>{for(var t in r)Xe(e,t,{get:r[t],enumerable:!0})},$t=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of xt(r))!At.call(e,i)&&i!==t&&Xe(e,i,{get:()=>r[i],enumerable:!(n=St(r,i))||n.enumerable});return e};var Mt=e=>$t(Xe({},"__esModule",{value:!0}),e);var _t={};Tt(_t,{Cinematic:()=>_e,PRESETS:()=>Re,createBounce:()=>Ye,createElastic:()=>Ue,createSpring:()=>it,scrollAnimate:()=>dt,scrollCounter:()=>yt,scrollDraw:()=>Wt,scrollParallax:()=>gt});function it({tension:e=2.5,friction:r=2.2}={}){return t=>1-Math.cos(t*Math.PI*e)*Math.pow(1-t,r)}function Ye({bounces:e=3,decay:r=.5}={}){let t=Math.max(1,Math.round(e)),n=Math.max(.01,Math.min(.99,r)),i=Math.sqrt(n),s=0,d=[];for(let f=0;f<t;f++){let T=Math.pow(i,f);d.push(T),s+=T}let m=[0],l=0;for(let f=0;f<t;f++)l+=d[f]/s,m.push(l);return f=>{if(f<=0)return 0;if(f>=1)return 1;for(let T=0;T<t;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 Ue({amplitude:e=1,period:r=.4}={}){let t=Math.max(1,e),n=Math.max(.1,r),i=t<=1?n/4:n/(2*Math.PI)*Math.asin(1/t);return s=>s<=0?0:s>=1?1:t*Math.pow(2,-10*s)*Math.sin((s-i)*(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:Ye(),elastic:Ue()};function he(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return{element:"top",viewport:r};let[t="top",n="bottom"]=r.split(/\s+/).filter(Boolean);return{element:t,viewport:n}}function nt(e,r,t,n){switch(n){case"top":return e+t;case"center":return e+t+r/2;case"bottom":return e+t+r;default:return e+t}}function ot(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 Ne(e){let r=e.tagName.toLowerCase();if(r==="rect"){let t=parseFloat(e.getAttribute("width")??"0"),n=parseFloat(e.getAttribute("height")??"0");return 2*(t+n)}if(r==="circle"){let t=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*t}return e.getTotalLength()}function Pt(e,r,t){return Math.min(t,Math.max(r,e))}function re(e,r,t,n){return t===r?0:Pt((e-r)/(t-r)*n,0,1)}function xe(e,r,t,n,i){let s=nt(e.top,e.height,r,n.element)-ot(n.viewport,t),d=nt(e.top,e.height,r,i.element)-ot(i.viewport,t);return{tStart:s,tEnd:d}}function st(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 t=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t)return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[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,r,t){let n=st(e),i=st(r);return!n||!i?e:`rgb(${Math.round(n[0]+(i[0]-n[0])*t)},${Math.round(n[1]+(i[1]-n[1])*t)},${Math.round(n[2]+(i[2]-n[2])*t)})`}var Re={sketch:{easing:"ease-in",stagger:.1,speed:.9,fade:!1},reveal:{easing:"ease-out",fade:!0,speed:1.2,once:!0},typewriter:{easing:"linear",stagger:.05,speed:1.5},cinematic:{easing:"ease-in-out",fade:!0,speed:.75},spring:{easing:"spring",speed:1.1}};function at(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r)}var lt={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},kt=0;function Ct(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function Lt(e){let r=e.getAttribute("stroke"),t=e.getAttribute("fill");!r||r==="none"?at("Element has no stroke \u2014 path will not be visible.",e):t&&t!=="none"&&t!=="transparent"&&at("Element has a fill \u2014 it may obscure the stroke animation.",e)}function It(e,r,t){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 i(){let s=t==="x"?window.scrollX:window.scrollY,d=e-s,m=r-s,l=t==="x";n.innerHTML=`
2
+ <div style="position:absolute;${l?`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;${l?`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",i,{passive:!0}),i(),n}function Ze(e,r,t){let n=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),i=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,s=>{let d=parseFloat(s),m=n[i++]??d;return String(+(d+(m-d)*t).toFixed(4))})}function He(e,r={}){if(typeof window>"u")return{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:t,...n}=r,i=t?{...Re[t],...n}:n,s=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:d="path, polyline, line, polygon, rect, circle",speed:m=1,fade:l=!1,easing:f="linear",trigger:T={},stagger:F=0,direction:E="forward",once:X=!1,debug:ce=!1,axis:A="y",scrollContainer:$,autoReverse:u=!1,delay:h=0,strokeColor:b,strokeWidth:N,fillOpacity:z,waypoints:_,velocityScale:B=!1,threshold:oe=0,rootMargin:U="0px",repeat:Z=0,repeatDelay:J=0,morphTo:k,clip:K,autoplay:de=!1,duration:ge=1e3,native:be=!0,onProgress:g,onStart:R,onComplete:ue}=i,ie=K===!0?"left":typeof K=="string"?K:!1,ae=typeof f=="function"?f:te[f]??te.linear,Ae=he(T.start??"top bottom"),c=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 a=o*100;switch(ie){case"right":return`inset(0 0 0 ${100-a}%)`;case"top":return`inset(0 0 ${100-a}% 0)`;case"bottom":return`inset(${100-a}% 0 0 0)`;case"center":return`circle(${o*150}% at 50% 50%)`;default:return`inset(0 ${100-a}% 0 0)`}}let V=ie?[]:Array.from(e.querySelectorAll(d)),D=[],me=[],we=0,ve=0,Y=!1,le=!1,W=0,Ce=!1,fe=-1,Le=-1,Q=!1,Te=0,ye=0,Ee,Be=null,Se=new Set,Ie=-1,et=performance.now();function ke(){return p?A==="x"?p.scrollLeft:p.scrollTop:A==="x"?window.scrollX:window.scrollY}function tt(){return p?A==="x"?p.clientWidth:p.clientHeight:A==="x"?window.innerWidth:window.innerHeight}function rt(){let o=e.getBoundingClientRect(),a,v,O;if(p){let ee=p.getBoundingClientRect();a=A==="x"?o.left-ee.left+p.scrollLeft:o.top-ee.top+p.scrollTop,v=A==="x"?o.width:o.height,O=ke()}else a=A==="x"?o.left:o.top,v=A==="x"?o.width:o.height,O=ke();let se=xe({top:a,height:v},O,tt(),Ae,c);we=se.tStart,ve=se.tEnd,ce&&process.env.NODE_ENV!=="production"&&(Be?.remove(),Be=It(we,ve,A))}function bt(o,a){if(e.style.setProperty("--scroll-draw-progress",String(o)),ie){let v=a==="reverse"?1-o:o;e.style.clipPath=ne(v);return}V.forEach((v,O)=>{v.style.strokeDashoffset=a==="reverse"?`${D[O]*o}`:`${D[O]*(1-o)}`,l&&(v.style.opacity=a==="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",Ze(me[O],k,o))})}function De(){if(e.style.setProperty("--scroll-draw-progress","0"),ie){e.style.clipPath=ne(0);return}V.forEach((o,a)=>{o.style.strokeDasharray=`${D[a]}`,o.style.strokeDashoffset=E==="reverse"?"0":`${D[a]}`,l?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[a]&&o.setAttribute("d",me[a])})}if(V.forEach(o=>{Lt(o);let a=Ne(o);D.push(a),o.tagName.toLowerCase()==="path"?me.push(o.getAttribute("d")??""):me.push(""),s?(o.style.strokeDasharray=`${a}`,o.style.strokeDashoffset=E==="reverse"?`${a}`:"0",l&&(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=`${a}`,o.style.strokeDashoffset=E==="reverse"?"0":`${a}`,l?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(s)return e.style.clipPath=ne(1),ue?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ne(0)}else if(s)return ue?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function wt(){return!(be===!1||!Ct()||!V.length||typeof f!="string"||!(f in lt)||ie||A!=="y"||p||m!==1||F!==0||X||u||B!==!1||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 vt(){let o=`svg-scroll-draw-${++kt}`,a=E==="reverse"?"0":"var(--ssd-len)",v=E==="reverse"?"var(--ssd-len)":"0",O=`stroke-dashoffset:${a};`,se=`stroke-dashoffset:${v};`;l&&(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:${lt[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=!1,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(),tt(),Ae,c);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=!1,q=-1,V.forEach(w)},pause(){P=!0,V.forEach(y=>{y.style.animationPlayState="paused"})},resume(){P&&(P=!1,V.forEach(y=>{y.style.animationPlayState="running"}))},seek(y){let x=Math.min(1,Math.max(0,y));q=x,P=!0,V.forEach((L,$e)=>{L.classList.remove(o),L.style.strokeDashoffset=E==="reverse"?`${D[$e]*x}`:`${D[$e]*(1-x)}`,l&&(L.style.opacity=E==="reverse"?`${1-x}`:`${x}`)})},getProgress(){return S()}}}if(wt())return vt();function Et(){let o=Math.max(1,ge),a=0,v=0;function O(S){let y=!0;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=!1)}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)}`,l&&(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",Ze(me[L],k,pe)),L===0&&(g?.(pe),e.style.setProperty("--scroll-draw-progress",String(pe))),Me<1&&(y=!1)});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-a;le||(le=!0,R?.());let x=O(y);if(x&&!Y){Y=!0,O(o*(1+Math.max(0,V.length-1)*F)),ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{a=performance.now(),le=!1,Y=!1,Se.clear(),De(),W=requestAnimationFrame(se)},J));return}x||(W=requestAnimationFrame(se))}function ee(){cancelAnimationFrame(W),clearTimeout(Ee),a=performance.now(),v=0,Q=!1,le=!1,Y=!1,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),a=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=!0,v=performance.now()-a,cancelAnimationFrame(W))},resume(){Q&&(Q=!1,a=performance.now()-v,W=requestAnimationFrame(se))},seek(S){let y=Math.min(1,Math.max(0,S));Te=y,Q=!0,v=y*o,a=performance.now()-v,cancelAnimationFrame(W),O(v)},getProgress(){return Te}}}if(de)return Et();rt();function Oe(){if(!Ce||Q)return;let o=performance.now(),a=ke(),v=m;if(B!==!1){let w=o-et,P=w>0?Math.abs(a-(Ie<0?a:Ie))/w:0;v=m*Math.max(.2,1+P*(typeof B=="number"?B:1)*.04)}Ie=a,et=o;let O=u?Le===-1||a>=Le?"forward":"reverse":E;Le=a;let se=ve-we,ee=!0;if(ie){let w=ae(re(a,we,ve,v));X&&!u&&(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(a,we,ve,v)>0&&(le=!0,R?.()),w>=1&&!Y?(Y=!0,ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{fe=-1,le=!1,Y=!1,e.style.clipPath=ne(0)},J))):w<1&&!X&&(Y=!1),W=requestAnimationFrame(Oe);return}if(V.forEach((w,P)=>{let q=P*F*se,S=ae(re(a,we+q,ve+q,v));X&&!u&&(fe=Math.max(fe,S),S=fe),Te=S,w.style.strokeDashoffset=O==="reverse"?`${D[P]*S}`:`${D[P]*(1-S)}`,l&&(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",Ze(me[P],k,S)),P===0&&(g?.(S),e.style.setProperty("--scroll-draw-progress",String(S))),S<1&&(ee=!1)}),_){let w=ae(re(a,we,ve,v));for(let P in _){let q=parseFloat(P);w>=q&&!Se.has(q)&&(Se.add(q),_[P]?.())}}!le&&re(a,we,ve,v)>0&&(le=!0,R?.()),ee&&!Y?(Y=!0,ue?.(),ye<(Z==="infinite"?1/0:Z??0)&&(ye++,Ee=setTimeout(()=>{fe=-1,le=!1,Y=!1,Se.clear(),De()},J))):!ee&&!X&&(Y=!1),W=requestAnimationFrame(Oe)}let Ge=new IntersectionObserver(o=>{o.forEach(a=>{Ce=a.isIntersecting,Ce&&!Q?W=requestAnimationFrame(Oe):cancelAnimationFrame(W)})},{root:p??null,threshold:oe,rootMargin:U}),je;function Fe(){clearTimeout(je),je=setTimeout(()=>{V.forEach((o,a)=>{D[a]=Ne(o),o.style.strokeDasharray=`${D[a]}`}),rt()},150)}return window.addEventListener("resize",Fe),window.addEventListener("orientationchange",Fe),h>0?setTimeout(()=>Ge.observe(e),h):Ge.observe(e),{destroy(){cancelAnimationFrame(W),clearTimeout(Ee),Ge.disconnect(),window.removeEventListener("resize",Fe),window.removeEventListener("orientationchange",Fe),clearTimeout(je),Be?.remove()},replay(){fe=-1,Le=-1,Ie=-1,le=!1,Y=!1,ye=0,Q=!1,Se.clear(),clearTimeout(Ee),De()},pause(){Q=!0,cancelAnimationFrame(W)},resume(){Q&&(Q=!1,Ce&&(W=requestAnimationFrame(Oe)))},seek(o){let a=Math.min(1,Math.max(0,o));Te=a,fe=a,Q=!0,cancelAnimationFrame(W),bt(a,E)},getProgress(){return Te}}}var ct=new Map;function qe(e,r){ct.set(e,r)}function ze(e){ct.delete(e)}function Dt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function ut(e){let r=[],t=/([\w]+)\(([^)]*)\)/g,n;for(;(n=t.exec(e))!==null;){let i=[],s=[],d=n[2].trim();if(d)for(let m of d.split(/[\s,]+/)){let l=m.match(/^([-+]?[\d.eE]+)(.*)$/);i.push(l?parseFloat(l[1]):0),s.push(l?l[2]:"")}r.push({fn:n[1],nums:i,units:s})}return r}function Ot(e,r,t){let n=ut(e),i=ut(r);return n.length===0||n.length!==i.length?t<1?e:r:n.map((s,d)=>{let m=i[d];return s.fn!==m.fn||s.nums.length!==m.nums.length?t<1?`${s.fn}(${s.nums.map((l,f)=>`${l}${s.units[f]}`).join(", ")})`:`${m.fn}(${m.nums.map((l,f)=>`${l}${m.units[f]}`).join(", ")})`:`${s.fn}(${s.nums.map((l,f)=>`${l+(m.nums[f]-l)*t}${s.units[f]}`).join(", ")})`}).join(" ")}function mt(e,r,t){if(typeof e=="number"&&typeof r=="number")return String(e+(r-e)*t);let n=String(e),i=String(r);if(Dt(n))return Pe(n,i,t);if(n.includes("("))return Ot(n,i,t);let s=n.match(/^([-+]?[\d.]+)(.*)$/),d=i.match(/^([-+]?[\d.]+)(.*)$/);if(s&&d){let m=parseFloat(s[1]),l=parseFloat(d[1]);return`${m+(l-m)*t}${s[2]||d[2]}`}return t<1?n:i}function Ft(e){return e.replace(/([A-Z])/g,r=>`-${r.toLowerCase()}`)}var ft={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},Nt=new Set(["opacity","transform","background-color","color","filter","scale","translate","rotate"]),Rt=0;function Ht(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function pt(e,r){let t={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return t;let{props:n,trigger:i={},easing:s="ease-out",speed:d=1,once:m=!1,axis:l="y",scrollContainer:f,native:T=!0,onProgress:F,onComplete:E}=r,X=window.matchMedia("(prefers-reduced-motion: reduce)").matches,ce=typeof s=="function"?s:te[s]??te["ease-out"],A=he(i.start??"top bottom"),$=he(i.end??"bottom top"),u=typeof f=="string"?document.querySelector(f):f??null,h=Object.entries(n).map(([c,p])=>({prop:Ft(c),from:Array.isArray(p)?p[0]:"",to:Array.isArray(p)?p[1]:p}));function b(){let c=window.getComputedStyle(e);for(let p of h)p.from===""&&(p.from=c.getPropertyValue(p.prop).trim()||"0")}function N(){for(let c of h)e.style.setProperty(c.prop,String(c.to))}if(X)return N(),E?.(),t;b();function z(){if(!T||!Ht()||typeof s!="string"||!(s in ft)||l!=="y"||u||m||d!==1||F||E||(i.start??"top bottom").trim()!=="top bottom"||(i.end??"bottom top").trim()!=="bottom top")return!1;for(let c of h)if(!Nt.has(c.prop))return!1;return!0}function _(){let c=`ssd-a-${++Rt}`,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 ${c}{from{${p}}to{${G}}}.${c}{animation-name:${c};animation-duration:auto;animation-timing-function:${ft[s]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(C),e.classList.add(c);let H=()=>l==="x"?window.scrollX:window.scrollY,j=()=>l==="x"?window.innerWidth:window.innerHeight;return{destroy(){e.classList.remove(c),C.remove()},replay(){e.classList.remove(c),e.offsetWidth,e.classList.add(c)},pause(){e.style.animationPlayState="paused"},resume(){e.style.animationPlayState=""},seek(M){let I=Math.min(1,Math.max(0,M));e.classList.remove(c);for(let ne of h)e.style.setProperty(ne.prop,mt(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=!1,J=!1,k=-1,K=0,de=!1,ge=()=>u?l==="x"?u.scrollLeft:u.scrollTop:l==="x"?window.scrollX:window.scrollY,be=()=>u?l==="x"?u.clientWidth:u.clientHeight:l==="x"?window.innerWidth:window.innerHeight;function g(){let c=e.getBoundingClientRect(),p,G;if(u){let H=u.getBoundingClientRect();p=l==="x"?c.left-H.left+u.scrollLeft:c.top-H.top+u.scrollTop,G=l==="x"?c.width:c.height}else p=l==="x"?c.left:c.top,G=l==="x"?c.width:c.height;let C=xe({top:p,height:G},ge(),be(),A,$);B=C.tStart,oe=C.tEnd}function R(c){e.style.setProperty("--scroll-draw-progress",String(c));for(let p of h)e.style.setProperty(p.prop,mt(p.from,p.to,c));F?.(c)}function ue(){if(!Z||J)return;let c=ce(re(ge(),B,oe,d));m&&(k=Math.max(k,c),c=k),K=c,R(c),c>=1&&!de?(de=!0,E?.()):c<1&&!m&&(de=!1),U=requestAnimationFrame(ue)}g();{let c=ce(re(ge(),B,oe,d));m&&c>0&&(k=c),K=c,R(c)}let ie=new IntersectionObserver(c=>{c.forEach(p=>{Z=p.isIntersecting,Z&&!J?U=requestAnimationFrame(ue):cancelAnimationFrame(U)})},{root:u??null}),ae;function Ae(){clearTimeout(ae),ae=setTimeout(g,150)}return window.addEventListener("resize",Ae),window.addEventListener("orientationchange",Ae),ie.observe(e),qe(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),ze(e)},replay(){k=-1,de=!1,K=0,J=!1,R(0)},pause(){J=!0,cancelAnimationFrame(U)},resume(){J&&(J=!1,Z&&(U=requestAnimationFrame(ue)))},seek(c){let p=Math.min(1,Math.max(0,c));K=p,k=p,J=!0,cancelAnimationFrame(U),R(p)},getProgress(){return K}}}var Ve={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function dt(e,r){if(typeof window>"u")return Ve;let t=typeof e=="string"?document.querySelector(e):e;return t?pt(t,r):(process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollAnimate: element not found:",e),Ve)}function gt(e,r={}){if(typeof window>"u")return Ve;let t=typeof e=="string"?document.querySelector(e):e;if(!t)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollParallax: element not found:",e),Ve;let{speed:n=.3,axis:i="y",easing:s="linear",trigger:d,onProgress:m}=r,l=t.getBoundingClientRect(),f=i==="x"?l.width:l.height,T=n*f;return pt(t,{props:i==="x"?{transform:["translateX(0px)",`translateX(${-T}px)`]}:{transform:["translateY(0px)",`translateY(${-T}px)`]},trigger:d??{start:"top bottom",end:"bottom top"},easing:s,native:!1,onProgress:m})}var Je={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};function yt(e,r){if(typeof window>"u")return Je;let t=typeof e=="string"?document.querySelector(e):e;if(!t)return process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] scrollCounter: element not found:",e),Je;let n=t,{from:i=0,to:s,format:d,easing:m="ease-out",trigger:l={},once:f=!0,decimals:T,onComplete:F}=r,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(l.start??"top 80%"),A=he(l.end??"top 20%");if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return n.textContent=E(s),F?.(),Je;n.textContent=E(i);let u=0,h=0,b=0,N=!1,z=!1,_=-1,B=0,oe=!1,U=()=>window.scrollY,Z=()=>window.innerHeight;function J(){let g=n.getBoundingClientRect(),R=xe({top:g.top,height:g.height},U(),Z(),ce,A);u=R.tStart,h=R.tEnd}function k(g){n.textContent=E(i+(s-i)*g),n.style.setProperty("--scroll-draw-progress",String(g))}function K(){if(!N||z)return;let g=X(re(U(),u,h,1));f&&(_=Math.max(_,g),g=_),B=g,k(g),g>=1&&!oe?(oe=!0,F?.()):g<1&&!f&&(oe=!1),b=requestAnimationFrame(K)}J();{let g=X(re(U(),u,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),qe(n,{type:"counter",getProgress:()=>B,getTrigger:()=>({tStart:u,tEnd:h})}),{destroy(){cancelAnimationFrame(b),de.disconnect(),window.removeEventListener("resize",be),window.removeEventListener("orientationchange",be),clearTimeout(ge),ze(n)},replay(){_=-1,oe=!1,B=0,z=!1,k(0)},pause(){z=!0,cancelAnimationFrame(b)},resume(){z&&(z=!1,N&&(b=requestAnimationFrame(K)))},seek(g){let R=Math.min(1,Math.max(0,g));B=R,_=R,z=!0,cancelAnimationFrame(b),k(R)},getProgress(){return B}}}var ht="http://www.w3.org/2000/svg",qt="cinematic-photo",Ke=e=>e<0?0:e>1?1:e;function We(e){let r=parseFloat(e);return Number.isFinite(r)?Ke(r/100):0}function zt(e){return te[e]??te.linear}var Vt={destroy:()=>{},getProgress:()=>0},_e=class{constructor(r){if(typeof document>"u"){this.mount=null;return}this.mount=typeof r.wrapper=="string"?document.querySelector(r.wrapper):r.wrapper,!this.mount&&process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] Cinematic: wrapper not found:",r.wrapper)}loadStory(r){let t=this.mount;if(typeof window>"u"||!t)return Vt;t.style.position="relative",t.style.height=r.totalHeight,t.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;",t.appendChild(n);let i=[];for(let A of r.scenes){if(A.background){let u=document.createElement("img");u.id=qt,u.src=A.background,u.alt="",u.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",n.appendChild(u)}let $=A.animations.filter(u=>u.type==="draw");if($.length){let u=document.createElementNS(ht,"svg");u.setAttribute("viewBox",`0 0 ${r.canvas.width} ${r.canvas.height}`),u.setAttribute("preserveAspectRatio","xMidYMid meet"),u.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",n.appendChild(u);for(let h of $){let b=document.createElementNS(ht,"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),u.appendChild(b),i.push({kind:"draw",el:b,start:We(h.start),end:We(h.end),ease:zt(h.easing),length:N})}}for(let u of A.animations){if(u.type!=="fade")continue;let h=n.querySelector(u.target)??document.querySelector(u.target);h&&(h.style.opacity=String(u.from),i.push({kind:"fade",el:h,start:We(u.start),end:We(u.end),ease:te["ease-in-out"]??te.linear,from:u.from,to:u.to}))}}let s=0,d=()=>{let A=t.offsetHeight-window.innerHeight;return A<=0?t.getBoundingClientRect().top<=0?1:0:Ke(-t.getBoundingClientRect().top/A)},m=A=>{for(let $ of i){let u=$.end-$.start,h=u<=0?A>=$.end?1:0:Ke((A-$.start)/u),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 l=0,f=!1,T=!1,F=()=>{s=d(),m(s),f&&(l=requestAnimationFrame(F))},E=()=>{f||(f=!0,l=requestAnimationFrame(F))},X=()=>{f=!1,cancelAnimationFrame(l)},ce=new IntersectionObserver(A=>{for(let $ of A)T=$.isIntersecting,T?E():X()},{threshold:0});return ce.observe(n),s=d(),m(s),{destroy(){X(),ce.disconnect()},getProgress:()=>s}}};function Wt(e,r){let t={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return t;let n=typeof e=="string"?document.querySelector(e):e;return n?He(n,r):(console.warn("[svg-scroll-draw] Container not found:",e),t)}var Qe=class extends HTMLElement{constructor(){super(...arguments);this.instance=null}connectedCallback(){let t={},n=this.getAttribute("speed"),i=this.getAttribute("easing"),s=this.getAttribute("stagger"),d=this.getAttribute("direction"),m=this.getAttribute("selector");n&&(t.speed=parseFloat(n)),i&&(t.easing=i),s&&(t.stagger=parseFloat(s)),d&&(t.direction=d),m&&(t.selector=m),this.hasAttribute("fade")&&(t.fade=this.getAttribute("fade")!=="false"),this.instance=He(this,t)}disconnectedCallback(){this.instance?.destroy(),this.instance=null}};typeof customElements<"u"&&!customElements.get("scroll-draw")&&customElements.define("scroll-draw",Qe);return Mt(_t);})();
@@ -0,0 +1 @@
1
+ 'use strict';var C=new Map;function x(){return C}var v={draw:"#60a5fa",animate:"#4ade80",counter:"#fbbf24",video:"#c084fc",text:"#fb923c"},n=null,o=null,b=0,p=false,m=null;function L(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function $(){if(!o)return;o.innerHTML="";let e=window.scrollY,l=window.innerHeight;for(let[,t]of x()){let{tStart:i,tEnd:r}=t.getTrigger(),d=v[t.type]??"#60a5fa",f=i-e,s=r-e;if(s<-100||f>l+100)continue;let c=(u,y)=>{let a=document.createElement("div");a.style.cssText=`position:absolute;left:0;right:0;top:${u}px;height:2px;background:${d};opacity:0.85;`;let g=document.createElement("span");return g.textContent=y,g.style.cssText=`position:absolute;right:8px;top:-18px;font:bold 9px/1 monospace;color:#fff;background:${d};padding:2px 5px;border-radius:3px;white-space:nowrap;`,a.appendChild(g),a};o.appendChild(c(f,`\u25B6 ${t.type}:start`)),o.appendChild(c(s,`\u25A0 ${t.type}:end`));}}function M(){n?.remove(),n=document.createElement("div"),n.setAttribute("data-ssd-devtools-panel",""),n.style.cssText="position:fixed;bottom:12px;right:12px;z-index:99999;background:rgba(10,10,10,0.92);color:#e8e8e3;border-radius:10px;border:1px solid #333;font:12px/1.5 monospace;padding:10px 14px;min-width:220px;max-width:280px;pointer-events:none;backdrop-filter:blur(4px);";let e=document.createElement("div");e.style.cssText="font-weight:bold;font-size:11px;letter-spacing:0.1em;text-transform:uppercase;color:#888;margin-bottom:8px;",e.textContent="\u26A1 svg-scroll-draw devtools",n.appendChild(e),document.body.appendChild(n);}function k(){if(!n)return;for(;n.children.length>1;)n.removeChild(n.lastChild);let e=x();if(e.size===0){let t=document.createElement("div");t.style.cssText="color:#555;font-size:11px;",t.textContent="No active instances.",n.appendChild(t);return}for(let[t,i]of e){let r=i.getProgress(),d=v[i.type]??"#60a5fa",f=t.id?`#${t.id}`:t.className?`.${t.className.split(" ")[0]}`:i.type,s=document.createElement("div");s.style.cssText="margin-bottom:6px;";let c=document.createElement("div");c.style.cssText=`font-size:10px;color:${d};margin-bottom:2px;`,c.textContent=`${i.type} ${f}`;let u=document.createElement("div");u.style.cssText="height:6px;background:#222;border-radius:3px;overflow:hidden;";let y=document.createElement("div");y.style.cssText=`height:100%;width:${Math.round(r*100)}%;background:${d};border-radius:3px;transition:width 0.1s;`,u.appendChild(y),s.appendChild(c),s.appendChild(u);let a=document.createElement("div");a.style.cssText="font-size:9px;color:#555;text-align:right;margin-top:1px;",a.textContent=`${Math.round(r*100)}%`,s.appendChild(a),n.appendChild(s);}}function h(){$(),k(),b=requestAnimationFrame(h);}function E(){process.env.NODE_ENV!=="production"&&(p||(p=true,L(),M(),b=requestAnimationFrame(h),m=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()==="s"&&(e.preventDefault(),w());},window.addEventListener("keydown",m)));}function T(){p&&(p=false,cancelAnimationFrame(b),n?.remove(),n=null,o?.remove(),o=null,m&&(window.removeEventListener("keydown",m),m=null));}function w(){p?T():E();}function H(e){if(!p)return;let l=typeof e=="string"?document.querySelector(e):e;if(!l)return;let t=x().get(l);if(!t)return;let i=v[t.type]??"#60a5fa",r=l,d=r.style.outline;r.style.outline=`2px solid ${i}`,r.style.outlineOffset="2px",setTimeout(()=>{r.style.outline=d,r.style.outlineOffset="";},2e3);}var _={enable:E,disable:T,toggle:w,highlight:H};exports.devtools=_;
@@ -0,0 +1 @@
1
+ var C=new Map;function x(){return C}var v={draw:"#60a5fa",animate:"#4ade80",counter:"#fbbf24",video:"#c084fc",text:"#fb923c"},n=null,o=null,b=0,p=false,m=null;function L(){o?.remove(),o=document.createElement("div"),o.setAttribute("data-ssd-devtools-overlay",""),o.style.cssText="position:fixed;pointer-events:none;z-index:99998;inset:0;overflow:hidden;",document.body.appendChild(o);}function $(){if(!o)return;o.innerHTML="";let e=window.scrollY,l=window.innerHeight;for(let[,t]of x()){let{tStart:i,tEnd:r}=t.getTrigger(),d=v[t.type]??"#60a5fa",f=i-e,s=r-e;if(s<-100||f>l+100)continue;let c=(u,y)=>{let a=document.createElement("div");a.style.cssText=`position:absolute;left:0;right:0;top:${u}px;height:2px;background:${d};opacity:0.85;`;let g=document.createElement("span");return g.textContent=y,g.style.cssText=`position:absolute;right:8px;top:-18px;font:bold 9px/1 monospace;color:#fff;background:${d};padding:2px 5px;border-radius:3px;white-space:nowrap;`,a.appendChild(g),a};o.appendChild(c(f,`\u25B6 ${t.type}:start`)),o.appendChild(c(s,`\u25A0 ${t.type}:end`));}}function M(){n?.remove(),n=document.createElement("div"),n.setAttribute("data-ssd-devtools-panel",""),n.style.cssText="position:fixed;bottom:12px;right:12px;z-index:99999;background:rgba(10,10,10,0.92);color:#e8e8e3;border-radius:10px;border:1px solid #333;font:12px/1.5 monospace;padding:10px 14px;min-width:220px;max-width:280px;pointer-events:none;backdrop-filter:blur(4px);";let e=document.createElement("div");e.style.cssText="font-weight:bold;font-size:11px;letter-spacing:0.1em;text-transform:uppercase;color:#888;margin-bottom:8px;",e.textContent="\u26A1 svg-scroll-draw devtools",n.appendChild(e),document.body.appendChild(n);}function k(){if(!n)return;for(;n.children.length>1;)n.removeChild(n.lastChild);let e=x();if(e.size===0){let t=document.createElement("div");t.style.cssText="color:#555;font-size:11px;",t.textContent="No active instances.",n.appendChild(t);return}for(let[t,i]of e){let r=i.getProgress(),d=v[i.type]??"#60a5fa",f=t.id?`#${t.id}`:t.className?`.${t.className.split(" ")[0]}`:i.type,s=document.createElement("div");s.style.cssText="margin-bottom:6px;";let c=document.createElement("div");c.style.cssText=`font-size:10px;color:${d};margin-bottom:2px;`,c.textContent=`${i.type} ${f}`;let u=document.createElement("div");u.style.cssText="height:6px;background:#222;border-radius:3px;overflow:hidden;";let y=document.createElement("div");y.style.cssText=`height:100%;width:${Math.round(r*100)}%;background:${d};border-radius:3px;transition:width 0.1s;`,u.appendChild(y),s.appendChild(c),s.appendChild(u);let a=document.createElement("div");a.style.cssText="font-size:9px;color:#555;text-align:right;margin-top:1px;",a.textContent=`${Math.round(r*100)}%`,s.appendChild(a),n.appendChild(s);}}function h(){$(),k(),b=requestAnimationFrame(h);}function E(){process.env.NODE_ENV!=="production"&&(p||(p=true,L(),M(),b=requestAnimationFrame(h),m=e=>{(e.metaKey||e.ctrlKey)&&e.shiftKey&&e.key.toLowerCase()==="s"&&(e.preventDefault(),w());},window.addEventListener("keydown",m)));}function T(){p&&(p=false,cancelAnimationFrame(b),n?.remove(),n=null,o?.remove(),o=null,m&&(window.removeEventListener("keydown",m),m=null));}function w(){p?T():E();}function H(e){if(!p)return;let l=typeof e=="string"?document.querySelector(e):e;if(!l)return;let t=x().get(l);if(!t)return;let i=v[t.type]??"#60a5fa",r=l,d=r.style.outline;r.style.outline=`2px solid ${i}`,r.style.outlineOffset="2px",setTimeout(()=>{r.style.outline=d,r.style.outlineOffset="";},2e3);}var _={enable:E,disable:T,toggle:w,highlight:H};export{_ as devtools};
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';function at({tension:e=2.5,friction:r=2.2}={}){return n=>1-Math.cos(n*Math.PI*e)*Math.pow(1-n,r)}function Ue({bounces:e=3,decay:r=.5}={}){let n=Math.max(1,Math.round(e)),o=Math.max(.01,Math.min(.99,r)),h=Math.sqrt(o),m=0,P=[];for(let p=0;p<n;p++){let x=Math.pow(h,p);P.push(x),m+=x;}let E=[0],k=0;for(let p=0;p<n;p++)k+=P[p]/m,E.push(k);return p=>{if(p<=0)return 0;if(p>=1)return 1;for(let x=0;x<n;x++)if(p<=E[x+1]){let W=(p-E[x])/(E[x+1]-E[x]);if(x===0)return W*(2-W);let b=1-Math.pow(o,x);return b+(1-b)*(2*W-1)*(2*W-1)}return 1}}function Ye({amplitude:e=1,period:r=.4}={}){let n=Math.max(1,e),o=Math.max(.1,r),h=n<=1?o/4:o/(2*Math.PI)*Math.asin(1/n);return m=>m<=0?0:m>=1?1:n*Math.pow(2,-10*m)*Math.sin((m-h)*(2*Math.PI)/o)+1}var re={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:Ue(),elastic:Ye()};function Ie(e="top bottom"){let r=e.trim();if(/^\d+(\.\d+)?%$/.test(r))return {element:"top",viewport:r};let[n="top",o="bottom"]=r.split(/\s+/).filter(Boolean);return {element:n,viewport:o}}function _e(e,r,n,o){switch(o){case "top":return e+n;case "center":return e+n+r/2;case "bottom":return e+n+r;default:return e+n}}function je(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 Ae(e){let r=e.tagName.toLowerCase();if(r==="rect"){let n=parseFloat(e.getAttribute("width")??"0"),o=parseFloat(e.getAttribute("height")??"0");return 2*(n+o)}if(r==="circle"){let n=parseFloat(e.getAttribute("r")??"0");return 2*Math.PI*n}return e.getTotalLength()}function lt(e,r,n){return Math.min(n,Math.max(r,e))}function ue(e,r,n,o){return n===r?0:lt((e-r)/(n-r)*o,0,1)}function Ce(e,r,n,o,h){let m=_e(e.top,e.height,r,o.element)-je(o.viewport,n),P=_e(e.top,e.height,r,h.element)-je(h.viewport,n);return {tStart:m,tEnd:P}}function Xe(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 o=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i.exec(e);return o?[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]:null}function ke(e,r,n){let o=Xe(e),h=Xe(r);return !o||!h?e:`rgb(${Math.round(o[0]+(h[0]-o[0])*n)},${Math.round(o[1]+(h[1]-o[1])*n)},${Math.round(o[2]+(h[2]-o[2])*n)})`}var Oe={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 Je(e,r){process.env.NODE_ENV!=="production"&&console.warn(`[svg-scroll-draw] ${e}`,r);}var Ke={linear:"linear","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out"},ct=0;function ut(){return typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timeline: view()")}function ft(e){let r=e.getAttribute("stroke"),n=e.getAttribute("fill");!r||r==="none"?Je("Element has no stroke \u2014 path will not be visible.",e):n&&n!=="none"&&n!=="transparent"&&Je("Element has a fill \u2014 it may obscure the stroke animation.",e);}function mt(e,r,n){let o=document.createElement("div");o.setAttribute("data-svg-scroll-draw-debug",""),o.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 h(){let m=n==="x"?window.scrollX:window.scrollY,P=e-m,E=r-m,k=n==="x";o.innerHTML=`
2
- <div style="position:absolute;${k?`left:${P}px;top:0;bottom:0;border-left:2px dashed #22c55e;`:`top:${P}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;${k?`left:${E}px;top:0;bottom:0;border-left:2px dashed #ef4444;`:`top:${E}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(o),window.addEventListener("scroll",h,{passive:true}),h(),o}function Fe(e,r,n){let o=(r.match(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g)??[]).map(Number),h=0;return e.replace(/[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g,m=>{let P=parseFloat(m),E=o[h++]??P;return String(+(P+(E-P)*n).toFixed(4))})}function Qe(e,r={}){if(typeof window>"u")return {destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};let{preset:n,...o}=r,h=n?{...Oe[n],...o}:o,m=window.matchMedia("(prefers-reduced-motion: reduce)").matches,{selector:P="path, polyline, line, polygon, rect, circle",speed:E=1,fade:k=false,easing:p="linear",trigger:x={},stagger:W=0,direction:b="forward",once:B=false,debug:ye=false,axis:d="y",scrollContainer:w,autoReverse:c=false,delay:S=0,strokeColor:y,strokeWidth:G,fillOpacity:ne,waypoints:se,velocityScale:ge=false,threshold:He=0,rootMargin:qe="0px",repeat:oe=0,repeatDelay:Me=0,morphTo:_,clip:Te,autoplay:et=false,duration:tt=1e3,native:rt=true,onProgress:pe,onStart:he,onComplete:fe}=h,K=Te===true?"left":typeof Te=="string"?Te:false,ie=typeof p=="function"?p:re[p]??re.linear,We=Ie(x.start??"top bottom"),Ve=Ie(x.end??"bottom top"),R=typeof w=="string"?document.querySelector(w):w??null,j=Array.isArray(y)?y[0]:null,I=Array.isArray(y)?y[1]:typeof y=="string"?y:null,H=Array.isArray(G)?G[0]:null,C=Array.isArray(G)?G[1]:typeof G=="number"?G:null,q=Array.isArray(ne)?ne[0]:null,O=Array.isArray(ne)?ne[1]:typeof ne=="number"?ne:null;function ae(t){let s=t*100;switch(K){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(${t*150}% at 50% 50%)`;default:return `inset(0 ${100-s}% 0 0)`}}let D=K?[]:Array.from(e.querySelectorAll(P)),M=[],X=[],Q=0,Z=0,L=false,z=false,T=0,be=false,U=-1,we=-1,F=false,le=0,J=0,ee,Pe=null,te=new Set,ve=-1,Ge=performance.now();function de(){return R?d==="x"?R.scrollLeft:R.scrollTop:d==="x"?window.scrollX:window.scrollY}function ze(){return R?d==="x"?R.clientWidth:R.clientHeight:d==="x"?window.innerWidth:window.innerHeight}function Be(){let t=e.getBoundingClientRect(),s,l,A;if(R){let N=R.getBoundingClientRect();s=d==="x"?t.left-N.left+R.scrollLeft:t.top-N.top+R.scrollTop,l=d==="x"?t.width:t.height,A=de();}else s=d==="x"?t.left:t.top,l=d==="x"?t.width:t.height,A=de();let V=Ce({top:s,height:l},A,ze(),We,Ve);Q=V.tStart,Z=V.tEnd,ye&&process.env.NODE_ENV!=="production"&&(Pe?.remove(),Pe=mt(Q,Z,d));}function nt(t,s){if(e.style.setProperty("--scroll-draw-progress",String(t)),K){let l=s==="reverse"?1-t:t;e.style.clipPath=ae(l);return}D.forEach((l,A)=>{l.style.strokeDashoffset=s==="reverse"?`${M[A]*t}`:`${M[A]*(1-t)}`,k&&(l.style.opacity=s==="reverse"?`${1-t}`:`${t}`),j&&I?l.style.stroke=ke(j,I,t):I&&(l.style.stroke=I),H!==null&&C!==null?l.style.strokeWidth=`${H+(C-H)*t}`:C!==null&&(l.style.strokeWidth=`${C}`),q!==null&&O!==null?l.style.fillOpacity=`${q+(O-q)*t}`:O!==null&&(l.style.fillOpacity=`${O}`),_&&l.tagName.toLowerCase()==="path"&&X[A]&&l.setAttribute("d",Fe(X[A],_,t));});}function Se(){if(e.style.setProperty("--scroll-draw-progress","0"),K){e.style.clipPath=ae(0);return}D.forEach((t,s)=>{t.style.strokeDasharray=`${M[s]}`,t.style.strokeDashoffset=b==="reverse"?"0":`${M[s]}`,k?t.style.opacity=b==="reverse"?"1":"0":t.style.opacity="",j&&(t.style.stroke=j),H!==null&&(t.style.strokeWidth=`${H}`),q!==null&&(t.style.fillOpacity=`${q}`),_&&t.tagName.toLowerCase()==="path"&&X[s]&&t.setAttribute("d",X[s]);});}if(D.forEach(t=>{ft(t);let s=Ae(t);M.push(s),t.tagName.toLowerCase()==="path"?X.push(t.getAttribute("d")??""):X.push(""),m?(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=b==="reverse"?`${s}`:"0",k&&(t.style.opacity="1"),I&&(t.style.stroke=I),C!==null&&(t.style.strokeWidth=`${C}`),O!==null&&(t.style.fillOpacity=`${O}`),_&&t.tagName.toLowerCase()==="path"&&t.setAttribute("d",_)):(t.style.strokeDasharray=`${s}`,t.style.strokeDashoffset=b==="reverse"?"0":`${s}`,k?t.style.opacity=b==="reverse"?"1":"0":t.style.opacity="",j&&(t.style.stroke=j),H!==null&&(t.style.strokeWidth=`${H}`),q!==null&&(t.style.fillOpacity=`${q}`));}),K){if(m)return e.style.clipPath=ae(1),fe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};e.style.clipPath=ae(0);}else if(m)return fe?.(),{destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>1};function st(){return !(rt===false||!ut()||!D.length||typeof p!="string"||!(p in Ke)||K||d!=="y"||R||E!==1||W!==0||B||c||ge!==false||_||se||oe||S>0||pe||he||fe||y!=null||G!=null||ne!=null||(x.start??"top bottom").trim()!=="top bottom"||(x.end??"bottom top").trim()!=="bottom top")}function ot(){let t=`svg-scroll-draw-${++ct}`,s=b==="reverse"?"0":"var(--ssd-len)",l=b==="reverse"?"var(--ssd-len)":"0",A=`stroke-dashoffset:${s};`,V=`stroke-dashoffset:${l};`;k&&(A+=`opacity:${b==="reverse"?1:0};`,V+=`opacity:${b==="reverse"?0:1};`);let N=document.createElement("style");N.setAttribute("data-svg-scroll-draw",""),N.textContent=`@keyframes ${t}{from{${A}}to{${V}}}.${t}{animation-name:${t};animation-duration:auto;animation-timing-function:${Ke[p]};animation-fill-mode:both;animation-timeline:view();animation-range:cover 0% cover 100%;}`,document.head.appendChild(N);function a(i,f){i.style.setProperty("--ssd-len",String(M[f])),i.style.strokeDasharray=`${M[f]}`,i.style.strokeDashoffset="",i.style.opacity="",i.style.animationPlayState="",i.classList.add(t);}D.forEach(a);let g=false,$=-1;function u(){if($>=0)return $;let i=e.getBoundingClientRect(),{tStart:f,tEnd:v}=Ce({top:i.top,height:i.height},de(),ze(),We,Ve);return ie(ue(de(),f,v,E))}return {destroy(){D.forEach(i=>{i.classList.remove(t),i.style.removeProperty("--ssd-len"),i.style.animationPlayState="";}),N.remove();},replay(){g=false,$=-1,D.forEach(a);},pause(){g=true,D.forEach(i=>{i.style.animationPlayState="paused";});},resume(){g&&(g=false,D.forEach(i=>{i.style.animationPlayState="running";}));},seek(i){let f=Math.min(1,Math.max(0,i));$=f,g=true,D.forEach((v,ce)=>{v.classList.remove(t),v.style.strokeDashoffset=b==="reverse"?`${M[ce]*f}`:`${M[ce]*(1-f)}`,k&&(v.style.opacity=b==="reverse"?`${1-f}`:`${f}`);});},getProgress(){return u()}}}if(st())return ot();function it(){let t=Math.max(1,tt),s=0,l=0;function A(u){let i=true;if(K){let f=Math.min(1,Math.max(0,u/t)),v=ie(f);le=v,e.style.setProperty("--scroll-draw-progress",String(v)),e.style.clipPath=ae(b==="reverse"?1-v:v),pe?.(v),f<1&&(i=false);}else D.forEach((f,v)=>{let ce=v*W*t,me=Math.min(1,Math.max(0,(u-ce)/t)),Y=ie(me);f.style.strokeDashoffset=b==="reverse"?`${M[v]*Y}`:`${M[v]*(1-Y)}`,k&&(f.style.opacity=b==="reverse"?`${1-Y}`:`${Y}`),j&&I?f.style.stroke=ke(j,I,Y):I&&(f.style.stroke=I),H!==null&&C!==null?f.style.strokeWidth=`${H+(C-H)*Y}`:C!==null&&(f.style.strokeWidth=`${C}`),q!==null&&O!==null?f.style.fillOpacity=`${q+(O-q)*Y}`:O!==null&&(f.style.fillOpacity=`${O}`),_&&f.tagName.toLowerCase()==="path"&&X[v]&&f.setAttribute("d",Fe(X[v],_,Y)),v===0&&(pe?.(Y),e.style.setProperty("--scroll-draw-progress",String(Y))),me<1&&(i=false);});if(se){let f=Math.min(1,Math.max(0,u/t)),v=ie(f);for(let ce in se){let me=parseFloat(ce);v>=me&&!te.has(me)&&(te.add(me),se[ce]?.());}}return i}function V(u){if(F)return;let i=u-s;z||(z=true,he?.());let f=A(i);if(f&&!L){L=true,A(t*(1+Math.max(0,D.length-1)*W)),fe?.(),J<(oe==="infinite"?1/0:oe??0)&&(J++,ee=setTimeout(()=>{s=performance.now(),z=false,L=false,te.clear(),Se(),T=requestAnimationFrame(V);},Me));return}f||(T=requestAnimationFrame(V));}function N(){cancelAnimationFrame(T),clearTimeout(ee),s=performance.now(),l=0,F=false,z=false,L=false,J=0,te.clear(),Se(),T=requestAnimationFrame(V);}let a=new IntersectionObserver(u=>{u.forEach(i=>{i.isIntersecting&&!(B&&L)?N():!i.isIntersecting&&!B&&!L&&(cancelAnimationFrame(T),clearTimeout(ee),s=null);});},{root:R??null,threshold:He,rootMargin:qe}),g;function $(){clearTimeout(g),g=setTimeout(()=>{D.forEach((u,i)=>{M[i]=Ae(u),u.style.strokeDasharray=`${M[i]}`;});},150);}return window.addEventListener("resize",$),window.addEventListener("orientationchange",$),S>0?setTimeout(()=>a.observe(e),S):a.observe(e),{destroy(){cancelAnimationFrame(T),clearTimeout(ee),a.disconnect(),window.removeEventListener("resize",$),window.removeEventListener("orientationchange",$),clearTimeout(g);},replay(){J=0,N();},pause(){F||(F=true,l=performance.now()-s,cancelAnimationFrame(T));},resume(){F&&(F=false,s=performance.now()-l,T=requestAnimationFrame(V));},seek(u){let i=Math.min(1,Math.max(0,u));le=i,F=true,l=i*t,s=performance.now()-l,cancelAnimationFrame(T),A(l);},getProgress(){return le}}}if(et)return it();Be();function Ee(){if(!be||F)return;let t=performance.now(),s=de(),l=E;if(ge!==false){let a=t-Ge,g=a>0?Math.abs(s-(ve<0?s:ve))/a:0;l=E*Math.max(.2,1+g*(typeof ge=="number"?ge:1)*.04);}ve=s,Ge=t;let A=c?we===-1||s>=we?"forward":"reverse":b;we=s;let V=Z-Q,N=true;if(K){let a=ie(ue(s,Q,Z,l));B&&!c&&(U=Math.max(U,a),a=U),le=a,e.style.setProperty("--scroll-draw-progress",String(a));let g=A==="reverse"?1-a:a;e.style.clipPath=ae(g),pe?.(a),!z&&ue(s,Q,Z,l)>0&&(z=true,he?.()),a>=1&&!L?(L=true,fe?.(),J<(oe==="infinite"?1/0:oe??0)&&(J++,ee=setTimeout(()=>{U=-1,z=false,L=false,e.style.clipPath=ae(0);},Me))):a<1&&!B&&(L=false),T=requestAnimationFrame(Ee);return}if(D.forEach((a,g)=>{let $=g*W*V,u=ie(ue(s,Q+$,Z+$,l));B&&!c&&(U=Math.max(U,u),u=U),le=u,a.style.strokeDashoffset=A==="reverse"?`${M[g]*u}`:`${M[g]*(1-u)}`,k&&(a.style.opacity=A==="reverse"?`${1-u}`:`${u}`),j&&I?a.style.stroke=ke(j,I,u):I&&(a.style.stroke=I),H!==null&&C!==null?a.style.strokeWidth=`${H+(C-H)*u}`:C!==null&&(a.style.strokeWidth=`${C}`),q!==null&&O!==null?a.style.fillOpacity=`${q+(O-q)*u}`:O!==null&&(a.style.fillOpacity=`${O}`),_&&a.tagName.toLowerCase()==="path"&&X[g]&&a.setAttribute("d",Fe(X[g],_,u)),g===0&&(pe?.(u),e.style.setProperty("--scroll-draw-progress",String(u))),u<1&&(N=false);}),se){let a=ie(ue(s,Q,Z,l));for(let g in se){let $=parseFloat(g);a>=$&&!te.has($)&&(te.add($),se[g]?.());}}!z&&ue(s,Q,Z,l)>0&&(z=true,he?.()),N&&!L?(L=true,fe?.(),J<(oe==="infinite"?1/0:oe??0)&&(J++,ee=setTimeout(()=>{U=-1,z=false,L=false,te.clear(),Se();},Me))):!N&&!B&&(L=false),T=requestAnimationFrame(Ee);}let De=new IntersectionObserver(t=>{t.forEach(s=>{be=s.isIntersecting,be&&!F?T=requestAnimationFrame(Ee):cancelAnimationFrame(T);});},{root:R??null,threshold:He,rootMargin:qe}),Le;function xe(){clearTimeout(Le),Le=setTimeout(()=>{D.forEach((t,s)=>{M[s]=Ae(t),t.style.strokeDasharray=`${M[s]}`;}),Be();},150);}return window.addEventListener("resize",xe),window.addEventListener("orientationchange",xe),S>0?setTimeout(()=>De.observe(e),S):De.observe(e),{destroy(){cancelAnimationFrame(T),clearTimeout(ee),De.disconnect(),window.removeEventListener("resize",xe),window.removeEventListener("orientationchange",xe),clearTimeout(Le),Pe?.remove();},replay(){U=-1,we=-1,ve=-1,z=false,L=false,J=0,F=false,te.clear(),clearTimeout(ee),Se();},pause(){F=true,cancelAnimationFrame(T);},resume(){F&&(F=false,be&&(T=requestAnimationFrame(Ee)));},seek(t){let s=Math.min(1,Math.max(0,t));le=s,U=s,F=true,cancelAnimationFrame(T),nt(s,b);},getProgress(){return le}}}var Ze="http://www.w3.org/2000/svg",pt="cinematic-photo",Ne=e=>e<0?0:e>1?1:e;function $e(e){let r=parseFloat(e);return Number.isFinite(r)?Ne(r/100):0}function dt(e){return re[e]??re.linear}var yt={destroy:()=>{},getProgress:()=>0},Re=class{constructor(r){if(typeof document>"u"){this.mount=null;return}this.mount=typeof r.wrapper=="string"?document.querySelector(r.wrapper):r.wrapper,!this.mount&&process.env.NODE_ENV!=="production"&&console.warn("[svg-scroll-draw] Cinematic: wrapper not found:",r.wrapper);}loadStory(r){let n=this.mount;if(typeof window>"u"||!n)return yt;n.style.position="relative",n.style.height=r.totalHeight,n.style.display="block";let o=document.createElement("div");o.setAttribute("data-cinematic-stage",""),o.style.cssText="position:sticky;top:0;height:100vh;width:100%;overflow:hidden;display:block;",n.appendChild(o);let h=[];for(let d of r.scenes){if(d.background){let c=document.createElement("img");c.id=pt,c.src=d.background,c.alt="",c.style.cssText="position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;pointer-events:none;",o.appendChild(c);}let w=d.animations.filter(c=>c.type==="draw");if(w.length){let c=document.createElementNS(Ze,"svg");c.setAttribute("viewBox",`0 0 ${r.canvas.width} ${r.canvas.height}`),c.setAttribute("preserveAspectRatio","xMidYMid meet"),c.style.cssText="position:absolute;inset:0;width:100%;height:100%;overflow:visible;",o.appendChild(c);for(let S of w){let y=document.createElementNS(Ze,"path");y.id=S.target.replace(/^#/,""),y.setAttribute("d",S.d),y.setAttribute("fill","none"),y.setAttribute("stroke",S.stroke),y.setAttribute("stroke-width",String(S.strokeWidth)),y.setAttribute("stroke-linecap","round"),y.setAttribute("stroke-linejoin","round");let G=S.length||y.getTotalLength?.()||0;y.style.strokeDasharray=String(G),y.style.strokeDashoffset=String(G),c.appendChild(y),h.push({kind:"draw",el:y,start:$e(S.start),end:$e(S.end),ease:dt(S.easing),length:G});}}for(let c of d.animations){if(c.type!=="fade")continue;let S=o.querySelector(c.target)??document.querySelector(c.target);S&&(S.style.opacity=String(c.from),h.push({kind:"fade",el:S,start:$e(c.start),end:$e(c.end),ease:re["ease-in-out"]??re.linear,from:c.from,to:c.to}));}}let m=0,P=()=>{let d=n.offsetHeight-window.innerHeight;return d<=0?n.getBoundingClientRect().top<=0?1:0:Ne(-n.getBoundingClientRect().top/d)},E=d=>{for(let w of h){let c=w.end-w.start,S=c<=0?d>=w.end?1:0:Ne((d-w.start)/c),y=w.ease(S);w.kind==="draw"?w.el.style.strokeDashoffset=String(w.length*(1-y)):w.el.style.opacity=String(w.from+(w.to-w.from)*y);}};if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return E(1),{destroy:()=>{},getProgress:()=>1};let k=0,p=false,x=false,W=()=>{m=P(),E(m),p&&(k=requestAnimationFrame(W));},b=()=>{p||(p=true,k=requestAnimationFrame(W));},B=()=>{p=false,cancelAnimationFrame(k);},ye=new IntersectionObserver(d=>{for(let w of d)x=w.isIntersecting,x?b():B();},{threshold:0});return ye.observe(o),m=P(),E(m),{destroy(){B(),ye.disconnect();},getProgress:()=>m}}};function At(e,r){let n={destroy:()=>{},replay:()=>{},pause:()=>{},resume:()=>{},seek:()=>{},getProgress:()=>0};if(typeof window>"u")return n;let o=typeof e=="string"?document.querySelector(e):e;return o?Qe(o,r):(console.warn("[svg-scroll-draw] Container not found:",e),n)}
4
- exports.Cinematic=Re;exports.PRESETS=Oe;exports.createBounce=Ue;exports.createElastic=Ye;exports.createSpring=at;exports.scrollDraw=At;
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;
package/dist/index.d.mts CHANGED
@@ -172,6 +172,40 @@ declare function createElastic({ amplitude, period, }?: {
172
172
  period?: number;
173
173
  }): (t: number) => number;
174
174
 
175
+ interface ScrollAnimateOptions {
176
+ props: Record<string, string | number | [string | number, string | number]>;
177
+ trigger?: TriggerConfig;
178
+ easing?: EasingName | ((t: number) => number);
179
+ speed?: number;
180
+ once?: boolean;
181
+ axis?: 'x' | 'y';
182
+ scrollContainer?: string | Element;
183
+ native?: boolean;
184
+ onProgress?: (alpha: number) => void;
185
+ onComplete?: () => void;
186
+ }
187
+ interface ScrollParallaxOptions {
188
+ speed?: number;
189
+ axis?: 'x' | 'y';
190
+ easing?: EasingName | ((t: number) => number);
191
+ trigger?: TriggerConfig;
192
+ onProgress?: (alpha: number) => void;
193
+ }
194
+ declare function scrollAnimate(target: string | Element, options: ScrollAnimateOptions): ScrollDrawInstance;
195
+ declare function scrollParallax(target: string | Element, options?: ScrollParallaxOptions): ScrollDrawInstance;
196
+
197
+ interface ScrollCounterOptions {
198
+ from?: number;
199
+ to: number;
200
+ format?: (value: number) => string;
201
+ easing?: EasingName | ((t: number) => number);
202
+ trigger?: TriggerConfig;
203
+ once?: boolean;
204
+ decimals?: number;
205
+ onComplete?: () => void;
206
+ }
207
+ declare function scrollCounter(target: string | Element, options: ScrollCounterOptions): ScrollDrawInstance;
208
+
175
209
  type StoryEasing = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
176
210
  /** A traced path that strokes itself on across a scroll range. */
177
211
  interface DrawAnimation {
@@ -245,4 +279,4 @@ declare class Cinematic {
245
279
 
246
280
  declare function scrollDraw(target: string | Element, options?: ScrollDrawOptions): ScrollDrawInstance;
247
281
 
248
- export { Cinematic, type CinematicInstance, type CinematicOptions, type DrawAnimation, type FadeAnimation, PRESETS, type PresetName$1 as PresetName, type ScrollDrawInstance, type ScrollDrawOptions, type Story, type StoryAnimation, type StoryEasing, type StoryScene, createBounce, createElastic, createSpring, scrollDraw };
282
+ export { Cinematic, type CinematicInstance, type CinematicOptions, type DrawAnimation, type FadeAnimation, PRESETS, type PresetName$1 as PresetName, type ScrollAnimateOptions, type ScrollCounterOptions, type ScrollDrawInstance, type ScrollDrawOptions, type ScrollParallaxOptions, type Story, type StoryAnimation, type StoryEasing, type StoryScene, createBounce, createElastic, createSpring, scrollAnimate, scrollCounter, scrollDraw, scrollParallax };
package/dist/index.d.ts CHANGED
@@ -172,6 +172,40 @@ declare function createElastic({ amplitude, period, }?: {
172
172
  period?: number;
173
173
  }): (t: number) => number;
174
174
 
175
+ interface ScrollAnimateOptions {
176
+ props: Record<string, string | number | [string | number, string | number]>;
177
+ trigger?: TriggerConfig;
178
+ easing?: EasingName | ((t: number) => number);
179
+ speed?: number;
180
+ once?: boolean;
181
+ axis?: 'x' | 'y';
182
+ scrollContainer?: string | Element;
183
+ native?: boolean;
184
+ onProgress?: (alpha: number) => void;
185
+ onComplete?: () => void;
186
+ }
187
+ interface ScrollParallaxOptions {
188
+ speed?: number;
189
+ axis?: 'x' | 'y';
190
+ easing?: EasingName | ((t: number) => number);
191
+ trigger?: TriggerConfig;
192
+ onProgress?: (alpha: number) => void;
193
+ }
194
+ declare function scrollAnimate(target: string | Element, options: ScrollAnimateOptions): ScrollDrawInstance;
195
+ declare function scrollParallax(target: string | Element, options?: ScrollParallaxOptions): ScrollDrawInstance;
196
+
197
+ interface ScrollCounterOptions {
198
+ from?: number;
199
+ to: number;
200
+ format?: (value: number) => string;
201
+ easing?: EasingName | ((t: number) => number);
202
+ trigger?: TriggerConfig;
203
+ once?: boolean;
204
+ decimals?: number;
205
+ onComplete?: () => void;
206
+ }
207
+ declare function scrollCounter(target: string | Element, options: ScrollCounterOptions): ScrollDrawInstance;
208
+
175
209
  type StoryEasing = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
176
210
  /** A traced path that strokes itself on across a scroll range. */
177
211
  interface DrawAnimation {
@@ -245,4 +279,4 @@ declare class Cinematic {
245
279
 
246
280
  declare function scrollDraw(target: string | Element, options?: ScrollDrawOptions): ScrollDrawInstance;
247
281
 
248
- export { Cinematic, type CinematicInstance, type CinematicOptions, type DrawAnimation, type FadeAnimation, PRESETS, type PresetName$1 as PresetName, type ScrollDrawInstance, type ScrollDrawOptions, type Story, type StoryAnimation, type StoryEasing, type StoryScene, createBounce, createElastic, createSpring, scrollDraw };
282
+ export { Cinematic, type CinematicInstance, type CinematicOptions, type DrawAnimation, type FadeAnimation, PRESETS, type PresetName$1 as PresetName, type ScrollAnimateOptions, type ScrollCounterOptions, type ScrollDrawInstance, type ScrollDrawOptions, type ScrollParallaxOptions, type Story, type StoryAnimation, type StoryEasing, type StoryScene, createBounce, createElastic, createSpring, scrollAnimate, scrollCounter, scrollDraw, scrollParallax };