@algorisys/tinyfly 0.90.0 → 0.92.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,5 +1,5 @@
1
- (function(b,Ft){typeof exports=="object"&&typeof module<"u"?Ft(exports):typeof define=="function"&&define.amd?define(["exports"],Ft):(b=typeof globalThis<"u"?globalThis:b||self,Ft(b.tinyfly=b.tinyfly||{}))})(this,(function(b){"use strict";function Ft(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function ae(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const Wn=2;function Kn(e){return e.some(t=>t.interpolation!==void 0)?2:1}function Be(e){return e.property==="text"&&"textConfig"in e}function dt(e){return e.kind==="inertia"&&"inertia"in e}function pt(e){return e.kind==="spring"&&"spring"in e}function Yn(e){return e.property==="motionPath"&&"motionPathConfig"in e}function Ll(e){return typeof e=="object"&&e!==null&&"x"in e&&"y"in e&&"angle"in e}function As(e){return"keyframes"in e}class Fl{_currentTime=0;_isRunning=!1;onTick=null;get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}start(){this._isRunning=!0}stop(){this._isRunning=!1}tick(t){this._currentTime+=t,this.onTick?.(t,this._currentTime)}reset(){this._currentTime=0}seek(t){this._currentTime=t}}class Dl{_currentTime=0;_isRunning=!1;_lastFrameTime=null;_rafId=null;_speed;onTick=null;constructor(t={}){this._speed=t.speed??1}get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}get speed(){return this._speed}set speed(t){this._speed=t}start(){this._isRunning||(this._isRunning=!0,this._lastFrameTime=null,this._scheduleFrame())}stop(){this._isRunning=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}reset(){this._currentTime=0,this._lastFrameTime=null}seek(t){this._currentTime=t}_scheduleFrame(){this._rafId=requestAnimationFrame(this._onFrame.bind(this))}_onFrame(t){if(this._isRunning){if(this._lastFrameTime!==null){const i=(t-this._lastFrameTime)*this._speed;this._currentTime+=i,this.onTick?.(i,this._currentTime)}this._lastFrameTime=t,this._scheduleFrame()}}}function Bl(e,t){if(!(t>0))return e;const n=1e3/t;return Math.floor(e/n+1e-9)*n}function Xn(e,t,n="start"){if(t<=1)return 0;if(typeof n=="number"){const i=Math.max(0,Math.min(t-1,n));return Math.abs(e-i)}switch(n){case"end":return t-1-e;case"center":return Math.abs(e-(t-1)/2);case"edges":return(t-1)/2-Math.abs(e-(t-1)/2);default:return e}}function qn(e,t="start"){if(e<=1)return 0;let n=0;for(let i=0;i<e;i++)n=Math.max(n,Xn(i,e,t));return n}function Ne(e,t,n){if(n.offsets)return n.offsets[e]??0;const i=n.from??"start",s=Xn(e,t,i);if(n.amount!==void 0){const r=qn(t,i);return r===0?0:n.amount*s/r}return n.each!==void 0?n.each*s:0}function We(e,t){return Array.from({length:e},(n,i)=>Ne(i,e,t))}function le(e,t){return e<=1?0:Math.max(...We(e,t))}const Dt=1,Vn=6e4,Ke=Vn/Dt,et={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},Ye={gentle:{stiffness:120,damping:18,mass:1},default:{stiffness:180,damping:12,mass:1},snappy:{stiffness:280,damping:20,mass:1},bouncy:{stiffness:220,damping:8,mass:1},wobbly:{stiffness:180,damping:5,mass:1},stiff:{stiffness:400,damping:30,mass:1}};class ce{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(t){this.from=t.from,this.to=t.to,this.stiffness=t.stiffness??et.stiffness,this.damping=t.damping??et.damping,this.mass=t.mass??et.mass,this.restDelta=t.restDelta??et.restDelta,this.restSpeed=t.restSpeed??et.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??et.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(t){return Math.abs(t-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(t){if(t<=0)return this.from;const n=Math.floor(t/Dt);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const i=this.samples[Math.min(n,this.samples.length-1)],s=this.samples[Math.min(n+1,this.samples.length-1)],r=t/Dt-n;return i+(s-i)*r}settleTime(){return this.simulateTo(Ke+1),this.settledStep!==null?this.settledStep*Dt:Vn}simulateTo(t){if(this.settledStep!==null)return;const n=Math.min(t,Ke+1),i=Dt/1e3;for(;this.samples.length<n;){const s=this.samples[this.samples.length-1],r=s-this.to,o=-this.stiffness*r,a=-this.damping*this.velocity,l=(o+a)/this.mass;this.velocity+=l*i;const c=s+this.velocity*i;if(this.samples.push(c),this.isAtRest(c)){this.settledStep=this.samples.length-1;return}}this.samples.length>Ke&&(this.settledStep=Ke)}}function Nl(e,t){return new ce(e).valueAt(t)}function xs(e){return new ce(e).settleTime()}function Wl(e){const t=e.stiffness??et.stiffness,n=e.damping??et.damping,i=e.mass??et.mass;return n<2*Math.sqrt(t*i)}function Kl(e){const t=e.stiffness??et.stiffness,n=e.mass??et.mass;return 2*Math.sqrt(t*n)}const Un=4,Yl=.002,Xl=1e-4,Ps=6e4;function Xe(e){const t=e.friction??Un;return t>0?t:Un}function he(e){return e.from+e.velocity/Xe(e)}function ql(e,t){if(t===void 0)return e;if(typeof t=="number")return t>0?Math.round(e/t)*t:e;if(t.length===0)return e;let n=t[0];for(const i of t)Math.abs(i-e)<Math.abs(n-e)&&(n=i);return n}function Bt(e){let t=ql(he(e),e.end);return e.min!==void 0&&(t=Math.max(e.min,t)),e.max!==void 0&&(t=Math.min(e.max,t)),t}function Nt(e){const t=Math.abs(Bt(e)-e.from);if(t===0)return 0;const n=e.restDelta??Math.max(Xl,t*Yl);if(n>=t)return 0;const i=Math.log(t/n)/Xe(e);return Math.min(Ps,i*1e3)}function qe(e,t){if(t<=0)return e.from;const n=Bt(e);if(t>=Nt(e))return n;const i=Xe(e);return e.from+(n-e.from)*(1-Math.exp(-i*t/1e3))}function Vl(e,t){const n=Xe(e),i=Bt(e);return t>=Nt(e)?0:(i-e.from)*n*Math.exp(-n*Math.max(0,t)/1e3)}const Ve=e=>e,_s=e=>e*e,Is=e=>1-(1-e)*(1-e),Cs=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,zn=e=>e*e*e,jn=e=>1-Math.pow(1-e,3),ue=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Hs=zn,$s=jn,Os=ue,Ul={linear:Ve,"ease-in":Hs,"ease-out":$s,"ease-in-out":Os,"ease-in-quad":_s,"ease-out-quad":Is,"ease-in-out-quad":Cs,"ease-in-cubic":zn,"ease-out-cubic":jn,"ease-in-out-cubic":ue};function Rs(e){const[t,n,i,s]=e,r=3*t,o=3*(i-t)-r,a=1-r-o,l=3*n,c=3*(s-n)-l,h=1-l-c,u=p=>((a*p+o)*p+r)*p,f=p=>((h*p+c)*p+l)*p,d=p=>(3*a*p+2*o)*p+r,m=p=>{let g=p;for(let v=0;v<8;v++){const M=u(g)-p;if(Math.abs(M)<1e-7)return g;const S=d(g);if(Math.abs(S)<1e-7)break;g-=M/S}let y=0,w=1;for(g=p;y<w;){const v=u(g);if(Math.abs(v-p)<1e-7)return g;p>v?y=g:w=g,g=(y+w)/2}return g};return p=>{if(p<=0)return 0;if(p>=1)return 1;const g=m(p);return f(g)}}function Gn(e,t="out"){if(t==="out")return e;const n=i=>1-e(1-i);return t==="in"?n:i=>i<.5?n(i*2)/2:e(i*2-1)/2+.5}function Ls(e=1,t=.3){const n=Math.max(1,e),i=t/(2*Math.PI)*Math.asin(1/n);return s=>s<=0?0:s>=1?1:n*Math.pow(2,-10*s)*Math.sin((s-i)*(2*Math.PI)/t)+1}const Fs=e=>{if(e<=0)return 0;if(e>=1)return 1;if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const s=e-.5454545454545454;return 7.5625*s*s+.75}if(e<2.5/2.75){const s=e-.8181818181818182;return 7.5625*s*s+.9375}const i=e-2.625/2.75;return 7.5625*i*i+.984375};function Ds(e=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const n=t-1;return n*n*((e+1)*n+e)+1}}function Bs(e,t="end"){const n=Math.max(1,Math.floor(e));return i=>{if(i>=1)return 1;if(i<=0)return t==="start"||t==="both"?t==="start"?1/n:1/(n+1):0;const s=Math.floor(i*n);switch(t){case"start":return Math.min(1,(s+1)/n);case"both":return(s+1)/(n+1);case"none":return n===1?0:Math.min(1,s/(n-1));default:return s/n}}}function Ns(e){switch(e.type){case"steps":return Bs(e.count,e.position);case"elastic":return Gn(Ls(e.amplitude,e.period),e.mode);case"bounce":return Gn(Fs,e.mode);case"back":return Gn(Ds(e.overshoot),e.mode)}}function G(e){return e===void 0?Ve:Ft(e)?Rs(e.points):ae(e)?Ns(e):Ul[e]??Ve}const Ws=32,zl=256,Wt=new Map,jl=/[MmLlHhVvCcSsQqTtAaZz]/,Gl=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Jl={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Zl(e){const t=[];let n=0,i=null;const s=()=>{for(;n<e.length&&/[\s,]/.test(e[n]);)n++};for(;n<e.length&&(s(),!(n>=e.length));){const r=e[n];if(jl.test(r)){i={type:r,args:[]},t.push(i),n++;continue}if(!i)break;const o=i.type==="A"||i.type==="a",a=i.args.length%7;if(o&&(a===3||a===4)){if(r!=="0"&&r!=="1")break;i.args.push(r==="1"?1:0),n++;continue}const l=Gl.exec(e.slice(n));if(!l)break;i.args.push(parseFloat(l[0])),n+=l[0].length}return t}function Ql(e,t,n,i,s,r,o,a,l){if(e===a&&t===l)return[];let c=Math.abs(n),h=Math.abs(i);if(c===0||h===0)return[[e,t,a,l,a,l]];const u=s*Math.PI/180,f=Math.cos(u),d=Math.sin(u),m=(e-a)/2,p=(t-l)/2,g=f*m+d*p,y=-d*m+f*p,w=g*g/(c*c)+y*y/(h*h);if(w>1){const $=Math.sqrt(w);c*=$,h*=$}const v=r===o?-1:1,M=c*c*h*h-c*c*y*y-h*h*g*g,S=c*c*y*y+h*h*g*g,E=v*Math.sqrt(Math.max(0,M/S)),k=E*c*y/h,x=-E*h*g/c,T=f*k-d*x+(e+a)/2,P=d*k+f*x+(t+l)/2,A=($,F,D,W)=>{const Z=$*D+F*W,Et=Math.sqrt(($*$+F*F)*(D*D+W*W)),Lt=Math.acos(Math.max(-1,Math.min(1,Z/Et)));return $*W-F*D<0?-Lt:Lt},_=A(1,0,(g-k)/c,(y-x)/h);let I=A((g-k)/c,(y-x)/h,(-g-k)/c,(-y-x)/h);!o&&I>0&&(I-=2*Math.PI),o&&I<0&&(I+=2*Math.PI);const C=Math.max(1,Math.ceil(Math.abs(I)/(Math.PI/2))),H=I/C,R=4/3*Math.tan(H/4),B=$=>{const F=c*Math.cos($),D=h*Math.sin($);return[f*F-d*D+T,d*F+f*D+P]},O=$=>{const F=-c*Math.sin($),D=h*Math.cos($);return[f*F-d*D,d*F+f*D]},L=[];for(let $=0;$<C;$++){const F=_+$*H,D=F+H,[W,Z]=B(F),[Et,Lt]=$===C-1?[a,l]:B(D),[Lp,Fp]=O(F),[Dp,Bp]=O(D);L.push([W+R*Lp,Z+R*Fp,Et-R*Dp,Lt-R*Bp,Et,Lt])}return L}function mt(e,t,n,i,s){const r=1-s;return r*r*r*e+3*r*r*s*t+3*r*s*s*n+s*s*s*i}function Ks(e,t,n,i,s){const r=1-s;return 3*r*r*(t-e)+6*r*s*(n-t)+3*s*s*(i-n)}function fe(e,t,n,i){return{subpath:0,type:"L",points:[n,i],startX:e,startY:t,endX:n,endY:i,length:Math.hypot(n-e,i-t)}}function Ue(e,t,n){const[i,s,r,o,a,l]=n,c=[0];let h=e,u=t,f=0;for(let d=1;d<=Ws;d++){const m=d/Ws,p=mt(e,i,r,a,m),g=mt(t,s,o,l,m);f+=Math.hypot(p-h,g-u),c.push(f),h=p,u=g}return{subpath:0,type:"C",points:[i,s,r,o,a,l],startX:e,startY:t,endX:a,endY:l,length:f,lengths:c}}function At(e){const t=Wt.get(e);if(t)return t;const n=[];let i=0,s=0,r=0,o=0,a=null,l=null,c=-1;const h=new Set,u=p=>{c<0&&(c=0),p.subpath=c,n.push(p)};for(const{type:p,args:g}of Zl(e)){const y=p.toUpperCase(),w=p!==y,v=Jl[y];if(y==="Z"){(i!==r||s!==o)&&u(fe(i,s,r,o)),c>=0&&h.add(c),i=r,s=o,a=l=null;continue}for(let M=0;M+v<=g.length;M+=v){const S=g.slice(M,M+v),E=w?i:0,k=w?s:0;let x=null,T=null;switch(y){case"M":M===0?(i=S[0]+E,s=S[1]+k,r=i,o=s,(c<0||n[n.length-1]?.subpath===c)&&c++):(u(fe(i,s,S[0]+E,S[1]+k)),i=S[0]+E,s=S[1]+k);break;case"L":u(fe(i,s,S[0]+E,S[1]+k)),i=S[0]+E,s=S[1]+k;break;case"H":u(fe(i,s,S[0]+E,s)),i=S[0]+E;break;case"V":u(fe(i,s,i,S[0]+k)),s=S[0]+k;break;case"C":{const P=[S[0]+E,S[1]+k,S[2]+E,S[3]+k,S[4]+E,S[5]+k];u(Ue(i,s,P)),x=[P[2],P[3]],i=P[4],s=P[5];break}case"S":{const[P,A]=a?[2*i-a[0],2*s-a[1]]:[i,s],_=[P,A,S[0]+E,S[1]+k,S[2]+E,S[3]+k];u(Ue(i,s,_)),x=[_[2],_[3]],i=_[4],s=_[5];break}case"Q":case"T":{let P=i,A=s;y==="Q"?(P=S[0]+E,A=S[1]+k):l&&(P=2*i-l[0],A=2*s-l[1]);const _=y==="Q"?S[2]+E:S[0]+E,I=y==="Q"?S[3]+k:S[1]+k;u(Ue(i,s,[i+2/3*(P-i),s+2/3*(A-s),_+2/3*(P-_),I+2/3*(A-I),_,I])),T=[P,A],i=_,s=I;break}case"A":{const P=S[5]+E,A=S[6]+k;let _=i,I=s;for(const C of Ql(i,s,S[0],S[1],S[2],S[3],S[4],P,A))u(Ue(_,I,C)),_=C[4],I=C[5];i=P,s=A;break}}a=x,l=T}}const f=n.reduce((p,g)=>p+g.length,0),d=[];for(let p=0;p<n.length;){const g=n[p].subpath;let y=p,w=0;for(;y<n.length&&n[y].subpath===g;)w+=n[y++].length;const v=n[p],M=n[y-1],S=h.has(g)||Math.abs(M.endX-v.startX)<1e-9&&Math.abs(M.endY-v.startY)<1e-9;d.push({start:p,end:y,length:w,closed:S}),p=y}const m={segments:n,totalLength:f,subpaths:d};return Wt.size>=zl&&Wt.delete(Wt.keys().next().value),Wt.set(e,m),m}function tc(e,t){const n=e.lengths;if(t<=0)return 0;if(t>=e.length)return 1;let i=0,s=n.length-1;for(;i<s-1;){const a=i+s>>1;n[a]<t?i=a:s=a}const r=n[s]-n[i],o=r>0?(t-n[i])/r:0;return(i+o)/(n.length-1)}function ec(e,t){if(e.type==="L"){const u=e.length>0?Math.max(0,Math.min(1,t/e.length)):0;return{x:e.startX+(e.endX-e.startX)*u,y:e.startY+(e.endY-e.startY)*u,angle:Math.atan2(e.endY-e.startY,e.endX-e.startX)*180/Math.PI}}const[n,i,s,r,o,a]=e.points,l=tc(e,t);let c=Ks(e.startX,n,s,o,l),h=Ks(e.startY,i,r,a,l);if(Math.hypot(c,h)<1e-9){const u=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),f=mt(e.startX,n,s,o,u),d=mt(e.startY,i,r,a,u),m=mt(e.startX,n,s,o,l),p=mt(e.startY,i,r,a,l);c=l<.5?f-m:m-f,h=l<.5?d-p:p-d}return{x:mt(e.startX,n,s,o,l),y:mt(e.startY,i,r,a,l),angle:Math.atan2(h,c)*180/Math.PI}}function Jn(e,t,n=0,i=e.length){if(i<=n)return{x:0,y:0,angle:0};let s=0;for(let r=n;r<i;r++){const o=e[r];if(s+o.length>=t||r===i-1)return ec(o,t-s);s+=o.length}return{x:0,y:0,angle:0}}function Ys(e,t){const{segments:n,totalLength:i}=At(e);return Jn(n,Math.max(0,Math.min(1,t))*i)}function nc(){Wt.clear()}function ic(e){return At(e).totalLength}const sc=24,rc=320,oc=2.5,de=72,ac=64,lc=.2,cc=128,pe=new Map;let ze=0,gt;const Xs=e=>Math.round(e*100)/100;function qs(e,t){const{segments:n,subpaths:i,totalLength:s}=At(e);if(n.length===0)return[];if(t){const r=i.every(o=>o.closed);return[{segments:n,start:0,end:n.length,length:s,closed:r}]}return i.filter(r=>r.length>0).map(r=>({segments:n,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function Zn(e,t){const n=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),i=Jn(e.segments,n*e.length,e.start,e.end);return[i.x,i.y]}function Vs(e){const t=[];let n=0;for(let i=e.start;i<e.end;i++)n+=e.segments[i].length,e.length>0&&t.push(n/e.length);return t}function Us(e,t){const n=[];for(let i=0;i<t;i++)n.push(Zn(e,e.closed?i/t:i/(t-1)));return n}function zs(e){let t=0,n=0;for(const[i,s]of e)t+=i,n+=s;return t/=e.length,n/=e.length,e.map(([i,s])=>[i-t,s-n])}function hc(e,t,n){const i=e.closed&&t.closed;if(n!==void 0)return{offset:i?Math.abs(n)%de/de:0,reversed:n<0};const s=zs(Us(e,de)),r=zs(Us(t,de)),o=de;let a={offset:0,reversed:!1},l=1/0;for(const c of[!1,!0]){const h=i?o:1;for(let u=0;u<h;u++){let f=0;for(let d=0;d<o&&f<l;d++){const m=i?c?(u-d+o)%o:(d+u)%o:c?o-1-d:d,p=s[d][0]-r[m][0],g=s[d][1]-r[m][1];f+=p*p+g*g}f<l&&(l=f,a={offset:i?u/o:0,reversed:c})}}return a}function uc(e,t,n){return n?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function fc(e,t,n){return n?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function dc(e,t,n){const i=e.closed&&t.closed,s=hc(e,t,n.shapeIndex),r=Math.max(sc,Math.min(rc,Math.ceil(Math.max(e.length,t.length)/oc))),o=new Set,a=u=>o.add(Math.round(u*1e7)/1e7);for(let u=0;u<=r;u++)a(u/r);for(const u of Vs(e))a(u);for(const u of Vs(t))a(fc(u,s,i));let l=[...o].sort((u,f)=>u-f);i&&(l=l.filter(u=>u<1));const c=[],h=[];for(const u of l)c.push(...Zn(e,u)),h.push(...Zn(t,uc(u,s,i)));return pc({from:c,to:h,closed:i})}function pc(e){const t=e.from.length/2;if(t<=3)return e;const n=new Uint8Array(t);n[0]=1,n[t-1]=1;const i=[[0,t-1]];for(;i.length>0;){const[o,a]=i.pop();let l=-1,c=lc;for(let h=o+1;h<a;h++){const u=Math.max(js(e.from,o,a,h),js(e.to,o,a,h));u>c&&(c=u,l=h)}l!==-1&&(n[l]=1,i.push([o,l],[l,a]))}const s=[],r=[];for(let o=0;o<t;o++)n[o]&&(s.push(e.from[o*2],e.from[o*2+1]),r.push(e.to[o*2],e.to[o*2+1]));return{from:s,to:r,closed:e.closed}}function js(e,t,n,i){const s=e[t*2],r=e[t*2+1],o=e[n*2]-s,a=e[n*2+1]-r,l=e[i*2]-s,c=e[i*2+1]-r,h=o*o+a*a,u=h===0?0:Math.max(0,Math.min(1,(l*o+c*a)/h));return Math.hypot(l-u*o,c-u*a)}function mc(e,t,n){const i=n.shapeIndex;if(gt&&gt.from===e&&gt.to===t&&gt.shapeIndex===i)return gt.plan;const r=pe.get(String(i??"auto"))?.get(e)?.get(t);if(r)return gt={from:e,to:t,shapeIndex:i,plan:r},r;const o=At(e).subpaths.filter(d=>d.length>0).length===At(t).subpaths.filter(d=>d.length>0).length,a=qs(e,!o),l=qs(t,!o),c={pairs:a.map((d,m)=>dc(d,l[m],n))};ze>=cc&&(pe.clear(),ze=0);const h=String(i??"auto"),u=pe.get(h)??new Map;pe.set(h,u);const f=u.get(e)??new Map;return u.set(e,f),f.set(t,c),ze++,gt={from:e,to:t,shapeIndex:i,plan:c},c}function Gs(e,t,n,i={}){if(!e)return t;if(!t)return e;const s=Math.max(0,Math.min(1,n));if(s===0)return e;if(s===1)return t;const r=mc(e,t,i);if(r.pairs.length===0)return s<.5?e:t;let o="";for(const a of r.pairs){for(let l=0;l<a.from.length;l+=2){const c=Xs(a.from[l]+(a.to[l]-a.from[l])*s),h=Xs(a.from[l+1]+(a.to[l+1]-a.from[l+1])*s);o+=`${l===0?o?" M":"M":" L"}${c} ${h}`}a.closed&&(o+=" Z")}return o}function gc(){pe.clear(),ze=0,gt=void 0}function Kt(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const Yt=Math.PI/180,yc=.9995;function Qn(){return[0,0,0,1]}function Xt(e,t){const n=Math.hypot(e[0],e[1],e[2]);if(n===0)return Qn();const i=t*Yt/2,s=Math.sin(i)/n;return[e[0]*s,e[1]*s,e[2]*s,Math.cos(i)]}function bc(e,t,n){return ti(ti(Xt([0,1,0],t),Xt([1,0,0],e)),Xt([0,0,1],n))}function wc(e){const[t,n,i,s]=yt(e),r=2*(t*i+n*s),o=2*(t*n+i*s),a=1-2*(t*t+i*i),l=2*(n*i-t*s),c=1-2*(n*n+i*i),h=2*(t*i-n*s),u=1-2*(t*t+n*n),f=Math.asin(Math.max(-1,Math.min(1,-l)));return Math.abs(l)<.9999999?[f/Yt,Math.atan2(r,u)/Yt,Math.atan2(o,a)/Yt]:[f/Yt,Math.atan2(-h,c)/Yt,0]}function ti(e,t){const[n,i,s,r]=e,[o,a,l,c]=t;return[r*o+n*c+i*l-s*a,r*a-n*l+i*c+s*o,r*l+n*a-i*o+s*c,r*c-n*o-i*a-s*l]}function Js(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function Zs(e){return Math.hypot(e[0],e[1],e[2],e[3])}function yt(e){const t=Zs(e);return t===0?Qn():[e[0]/t,e[1]/t,e[2]/t,e[3]/t]}function vc(e){return[-e[0],-e[1],-e[2],e[3]]}function Qs(e,t,n){const i=yt(e);let s=yt(t),r=Js(i,s);if(r<0&&(s=[-s[0],-s[1],-s[2],-s[3]],r=-r),r>yc)return yt([i[0]+(s[0]-i[0])*n,i[1]+(s[1]-i[1])*n,i[2]+(s[2]-i[2])*n,i[3]+(s[3]-i[3])*n]);const o=Math.acos(r),a=Math.sin(o),l=Math.sin((1-n)*o)/a,c=Math.sin(n*o)/a;return yt([i[0]*l+s[0]*c,i[1]*l+s[1]*c,i[2]*l+s[2]*c,i[3]*l+s[3]*c])}function kc(e,t){const[n,i,s,r]=yt(e),o=2*(i*t[2]-s*t[1]),a=2*(s*t[0]-n*t[2]),l=2*(n*t[1]-i*t[0]);return[t[0]+r*o+(i*l-s*a),t[1]+r*a+(s*o-n*l),t[2]+r*l+(n*a-i*o)]}const Sc=Object.freeze(Object.defineProperty({__proto__:null,conjugate:vc,dot:Js,fromAxisAngle:Xt,fromEuler:bc,identity:Qn,length:Zs,multiply:ti,normalize:yt,rotateVec3:kc,slerp:Qs,toEuler:wc},Symbol.toStringTag,{value:"Module"})),ot=(e,t,n)=>e+(t-e)*n,tr=512,ei=new Map,ni=new Map;function er(e){const t=ei.get(e);if(t)return t;const n=e.replace("#",""),i=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return ei.size<tr&&ei.set(e,i),i}const nr=e=>e.charCodeAt(0)===35,ir=e=>e.startsWith("rgb"),sr=e=>e.startsWith("rgba"),Mc=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,ii=e=>Math.round(e).toString(16).padStart(2,"0");function Tc(e,t,n){return`#${ii(e)}${ii(t)}${ii(n)}`}function rr(e){const t=ni.get(e);if(t)return t;const n=e.match(Mc);if(!n)throw new Error(`Invalid rgb color: ${e}`);const i=parseInt(n[1],10),s=parseInt(n[2],10),r=parseInt(n[3],10),o=n[4]!==void 0?[i,s,r,parseFloat(n[4])]:[i,s,r];return ni.size<tr&&ni.set(e,o),o}const or=(e,t,n)=>{if(nr(e)&&nr(t)){const[i,s,r]=er(e),[o,a,l]=er(t),c=ot(i,o,n),h=ot(s,a,n),u=ot(r,l,n);return Tc(c,h,u)}if((ir(e)||sr(e))&&(ir(t)||sr(t))){const i=rr(e),s=rr(t),r=Math.round(ot(i[0],s[0],n)),o=Math.round(ot(i[1],s[1],n)),a=Math.round(ot(i[2],s[2],n));if(i.length===4||s.length===4){const l=i[3]??1,c=s[3]??1,h=ot(l,c,n);return`rgba(${r}, ${o}, ${a}, ${h})`}return`rgb(${r}, ${o}, ${a})`}return n<1?e:t},ar=(e,t,n)=>{const i=Math.min(e.length,t.length),s=[];for(let r=0;r<i;r++)s.push(ot(e[r],t[r],n));return s},lr=(e,t,n)=>Qs(e,t,n),si=(e,t,n)=>n<1?e:t,cr=(e,t,n)=>Gs(e,t,n);function me(e,t){return t==="slerp"?lr:typeof e=="number"?ot:Array.isArray(e)?ar:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?or:Kt(e)?cr:si:si}const ri=1e3/60;function oi(e,t={}){if(!pt(e))throw new Error(`bakeSpringTrack: track "${e.id}" is not a spring track`);const n=new ce(e.spring);return hr(e,i=>n.valueAt(i),n.settleTime(),e.spring.from,e.spring.to,t)}function ai(e,t={}){if(!dt(e))throw new Error(`bakeInertiaTrack: track "${e.id}" is not an inertia track`);const n=e.inertia;return hr(e,i=>qe(n,i),Nt(n),n.from,Bt(n),t)}function hr(e,t,n,i,s,r){const o=r.intervalMs??ri,a=r.tolerance??.01,l=e.delay??0,c=[];for(let u=0;u<=n;u+=o)c.push({time:u+l,value:t(u),easing:"linear"});const h=c[c.length-1];return!h||h.time<n+l?c.push({time:n+l,value:s,easing:"linear"}):h.value=s,l>0&&c.unshift({time:0,value:i,easing:"linear"}),{id:e.id,target:e.target,property:e.property,keyframes:a>0?fr(c,a):c,...e.targets&&{targets:[...e.targets]},...e.stagger&&{stagger:{...e.stagger}}}}function li(e,t,n,i={}){const s=i.intervalMs??ri,r=typeof n=="function"?n:G(n),o=me(e.value,i.interpolation),a=t.time-e.time;if(a<=0)return[t];const l=[];for(let h=s;h<a;h+=s){const u=h/a;l.push({time:e.time+h,value:o(e.value,t.value,r(u)),easing:"linear"})}const c=r(1);return l.push({...t,...c!==1&&{value:o(e.value,t.value,c)},easing:"linear"}),l}function Ec(e,t){return pt(e)?oi(e,t):dt(e)?ai(e,t):e}function ur(e,t={}){const n=e.keyframes;if(!n.some(r=>ae(r.easing)))return e;const i=n.length>0?[n[0]]:[],s={...t,interpolation:e.interpolation??t.interpolation};for(let r=1;r<n.length;r++){const o=n[r];ae(o.easing)?i.push(...li(n[r-1],o,o.easing,s)):i.push(o)}return{...e,keyframes:i}}function Ac(e,t){return e.filter(As).map(n=>ur(n,t)).concat(e.filter(pt).map(n=>oi(n,t)),e.filter(dt).map(n=>ai(n,t)))}function fr(e,t){if(e.length<=2)return e;const n=[e[0]];for(let i=1;i<e.length-1;i++){const s=n[n.length-1],r=e[i],o=e[i+1],a=o.time-s.time;if(a<=0)continue;const l=(r.time-s.time)/a,c=s.value+(o.value-s.value)*l;Math.abs(r.value-c)>t&&n.push(r)}return n.push(e[e.length-1]),n}function je(e){const t=[...e.keyframes].sort((n,i)=>n.time-i.time);return{...e,keyframes:t}}function bt(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function qt(e,t,n,i){const s=n??0;return!i||t<=1?s:s+Ne(e,t,i)}class Ge{track;targets;constructor(t){this.track=t,this.targets=bt(t)}getValueAtTime(t){return this.valueForOffset(t-qt(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=qt(s,n,this.track.delay,this.track.stagger),o=this.valueForOffset(t-r);o!==void 0&&i.push({target:this.targets[s],value:o,start:r+this.track.keyframes[0].time})}return i}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const n=t[t.length-1].time,i=this.track.stagger?le(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+i+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:n}=this.track;if(n.length===0)return;if(n.length===1||t<=n[0].time)return n[0].value;if(t>=n[n.length-1].time)return n[n.length-1].value;const{from:i,to:s}=this.findSurroundingKeyframes(t);if(!i||!s)return;if(i.time===t)return i.value;const r=s.time-i.time,o=(t-i.time)/r,l=G(s.easing)(o);return me(i.value,this.track.interpolation)(i.value,s.value,l)}findSurroundingKeyframes(t){const{keyframes:n}=this.track;for(let i=0;i<n.length-1;i++)if(t>=n[i].time&&t<=n[i+1].time)return{from:n[i],to:n[i+1]};return{from:null,to:null}}}class dr{track;targets;sampler;constructor(t){this.track=t,this.targets=bt(t),this.sampler=new ce(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-qt(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=qt(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:this.sampler.valueAt(t-r),start:r})}return i}getDuration(){const t=this.track.stagger?le(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class pr{track;targets;duration;constructor(t){this.track=t,this.targets=bt(t),this.duration=Nt(t.inertia)}getValueAtTime(t){return qe(this.track.inertia,t-qt(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=qt(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:qe(this.track.inertia,t-r),start:r})}return i}getDuration(){const t=this.track.stagger?le(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function ci(e,t){const n={...Ys(e.pathData,t)};if(e.matrix){const[i,s,r,o,a,l]=e.matrix,{x:c,y:h}=n;n.x=i*c+r*h+a,n.y=s*c+o*h+l;const u=n.angle*Math.PI/180,f=Math.cos(u),d=Math.sin(u);n.angle=Math.atan2(s*f+o*d,i*f+r*d)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(n.angle+=e.rotateOffset),n}function xc(e,t,n,i){const s=t+(n-t)*i;return ci(e,s)}const hi={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},Pc=20;function mr(e){const t=hi[e??"upperCase"]??e??hi.upperCase,n=Array.from(t);return n.length>0?n:Array.from(hi.upperCase)}function _c(e,t,n){let i=(e|0)^Math.imul(t+1,2654435761)^Math.imul(n+1,2246822507);return i=Math.imul(i^i>>>16,2146121005),i=Math.imul(i^i>>>15,2221713035),(i^i>>>16)>>>0}function gr(e,t,n=0){const i=e.from??"",s=e.to,r=Math.max(0,Math.min(1,t));if(r<=0)return i;if(r>=1)return s;const o=Array.from(i),a=Array.from(s),l=e.rightToLeft??!1;if(e.mode==="type"){const w=Math.round(r*Math.max(o.length,a.length));return l?o.slice(0,Math.max(0,o.length-w)).join("")+a.slice(Math.max(0,a.length-w)).join(""):a.slice(0,w).join("")+o.slice(w).join("")}const c=Math.max(0,Math.min(.999,e.revealDelay??0)),h=Math.max(0,(r-c)/(1-c)),u=Math.floor(h*a.length),f=e.tweenLength===!1?a.length:Math.round(o.length+(a.length-o.length)*r),d=mr(e.chars),m=e.refreshRate??Pc,p=m>0?Math.floor(n*m/1e3):0,g=e.seed??1;let y="";for(let w=0;w<f;w++){const v=l?w>=f-u:w<u,M=l?a[a.length-(f-w)]:a[w];v&&M!==void 0||M===" "||M===`
2
- `?y+=M:y+=d[_c(g,w,p)%d.length]}return y}class ge{id;name;_captions;_tracks=[];_trackPlayers=new Map;_motionPathTracks=new Map;_springTracks=new Map;_textTracks=new Map;_config;_currentTime=0;_playbackState="idle";_direction="forward";_loopIteration=0;_explicitDuration;_repeatDelayRemaining=0;_wrapAfterDelay=!1;onUpdate=null;onComplete=null;constructor(t){if(this.id=t.id,this.name=t.name,this._captions=t.captions,this._config=t.config??{},this._explicitDuration=t.config?.duration,t.tracks)for(const n of t.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(t){if(this._explicitDuration=t,t!==void 0)this._config={...this._config,duration:t};else if(this._config.duration!==void 0){const n={...this._config};delete n.duration,this._config=n}}get currentTime(){return this._currentTime}get playbackState(){return this._playbackState}get direction(){return this._direction}get loopIteration(){return this._loopIteration}get repeatDelayRemaining(){return this._repeatDelayRemaining}get speed(){return this._config.speed??1}set speed(t){this._config.speed=t}play(){const t=this.duration;this._direction==="forward"&&this._currentTime>=t&&t>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&t>0&&(this._currentTime=t,this._loopIteration=0),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="idle",this._repeatDelayRemaining=0,this._wrapAfterDelay=!1,this._currentTime=0,this._loopIteration=0,this._direction="forward"}seek(t){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let s=t*this.speed;if(this._repeatDelayRemaining>0){const a=Math.min(this._repeatDelayRemaining,s);if(this._repeatDelayRemaining-=a,s-=a,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const r=1e3;for(let a=0;a<r&&s>0&&this._playbackState==="playing";a++)if(this._direction==="forward"){const l=n-this._currentTime;if(s>=l){if(s-=l,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=s,s=0}else{const l=this._currentTime;if(s>=l){if(s-=l,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=s,s=0}const o=this.getStateAtTime(this._currentTime);this.onUpdate?.(o)}getStateAtTime(t){const n=new Map;if(this._hasSharedWrites())this._resolveShared(t,n);else for(const[i,s]of this._trackPlayers){const r=s.getTrack().property;for(const{target:o,value:a,start:l}of s.getTargetValues(t))this._write(n,i,o,r,a,t-l)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,n){const i=new Map;for(const[s,r]of this._trackPlayers){const o=r.getTrack().property;for(const{target:a,value:l,start:c}of r.getTargetValues(t)){const h=`${a}\0${o}`,u=c<=t,f=i.get(h);(!f||(u!==f.started?u:u?c>=f.start:c<=f.start))&&i.set(h,{trackId:s,target:a,property:o,value:l,start:c,started:u})}}for(const{trackId:s,target:r,property:o,value:a,start:l}of i.values())this._write(n,s,r,o,a,t-l)}_write(t,n,i,s,r,o){if(r===void 0)return;let a=t.get(i);a||(a=new Map,t.set(i,a));const l=this._textTracks.get(n);if(l&&typeof r=="number"){a.set("text",gr(l.textConfig,r,Math.max(0,o)));return}const c=this._motionPathTracks.get(n);if(c&&typeof r=="number"){const h=ci(c.motionPathConfig,r);a.set("motionPathX",h.x),a.set("motionPathY",h.y),c.motionPathConfig.autoRotate&&a.set("motionPathRotate",h.angle)}else a.set(s,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const i of bt(n)){const s=`${i}\0${n.property}`;if(t.has(s)){this._sharedWrites=!0;break t}t.add(s)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,dt(t)){this._trackPlayers.set(t.id,new pr(t));return}if(pt(t)){this._trackPlayers.set(t.id,new dr(t)),this._springTracks.set(t.id,t);return}if(Be(t))this._trackPlayers.set(t.id,new Ge(t)),this._textTracks.set(t.id,t);else if(Yn(t)){const n={id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,delay:t.delay,endDelay:t.endDelay,targets:t.targets,stagger:t.stagger};this._trackPlayers.set(t.id,new Ge(n)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new Ge(t))}replaceTrack(t,n){const i=this._tracks.findIndex(r=>r.id===t);if(i<0)return;const s=this._tracks.slice(i+1);this.removeTrack(t);for(const r of s)this.removeTrack(r.id);this.addTrack(n);for(const r of s)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(n=>n.id!==t),this._sharedWrites=null,this._trackPlayers.delete(t),this._motionPathTracks.delete(t),this._springTracks.delete(t),this._textTracks.delete(t)}getTracks(t={}){return this._tracks.filter(n=>this._matches(n,t))}removeTracks(t={}){const n=this.getTracks(t).map(i=>i.id);for(const i of n)this.removeTrack(i);return n}getTrackSpan(t){const n=this._trackPlayers.get(t);if(!n)return;const i=n.getTrack(),s=i.delay??0;if(pt(i)||dt(i))return{from:s,to:n.getDuration()};const r=i.keyframes;if(!(!r||r.length===0))return{from:r[0].time+s,to:n.getDuration()}}findConflicts(){const t=[];for(let n=0;n<this._tracks.length;n++){const i=this._tracks[n],s=this.getTrackSpan(i.id);if(s)for(let r=0;r<n;r++){const o=this._tracks[r];if(o.property!==i.property)continue;const a=bt(o).filter(u=>bt(i).includes(u));if(a.length===0)continue;const l=this.getTrackSpan(o.id);if(!l||!(l.from<=s.to&&s.from<=l.to))continue;const h=s.from>=l.from;for(const u of a)t.push({target:u,property:i.property,losingTrackId:h?o.id:i.id,winningTrackId:h?i.id:o.id})}}return t}_matches(t,n){if(n.id!==void 0&&t.id!==n.id||n.property!==void 0&&t.property!==n.property||n.target!==void 0&&!bt(t).includes(n.target))return!1;if(n.timeRange){const i=this.getTrackSpan(t.id);if(!i||i.to<n.timeRange.from||i.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:Kn(this._tracks),id:this.id,name:this.name,config:{...this._config},tracks:[...this._tracks],...this.captions&&{captions:this.captions}}}get config(){return this._config}get markers(){return[...this._config.markers??[]].sort((t,n)=>t.time-n.time)}setMarkers(t){const n=t&&t.length>0?[...t].sort((s,r)=>s.time-r.time).map(s=>({...s})):void 0,i={...this._config};n?i.markers=n:delete i.markers,this._config=i}get captions(){return this._captions}setCaptions(t){const n={};for(const[i,s]of Object.entries(t??{}))n[i]={...s};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,n]of this._trackPlayers)t=Math.max(t,n.getDuration());return t}_handleEndReached(){const t=this._config.loop??0;return t===-1||this._loopIteration<t?(this._loopIteration++,this._armRepeatDelay(),this._config.alternate?this._direction="reverse":this._repeatDelayRemaining>0?this._wrapAfterDelay=!0:this._currentTime=0,this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}_handleStartReached(){const t=this._config.loop??0;return this._config.alternate&&(t===-1||this._loopIteration<t)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const Ic=100;function ui(e,t,n,i){const s=[],r=[],{duration:o,alternate:a}=i,l=(d,m,p,g)=>{r.push([d,m]);const y=[];e.forEach((w,v)=>{(p==="forward"?(g?w>=d:w>d)&&w<=m:(g?w<=d:w<d)&&w>=m)&&y.push(v)}),y.sort((w,v)=>(p==="forward"?e[w]-e[v]:e[v]-e[w])||w-v);for(const w of y)s.push({kind:"event",index:w,direction:p})};let c=t.time,h=t.direction,u=t.fresh===!0;const f=Math.min(Ic,Math.max(0,n.iteration-t.iteration));for(let d=0;d<f;d++){const m=h==="forward"?o:0;l(c,m,h,u),s.push({kind:"repeat"}),a?(h=h==="forward"?"reverse":"forward",c=m,u=!1):(c=h==="forward"?0:o,u=!0)}return f>0&&i.holding&&!a?{crossings:s,passes:r}:(l(c,n.time,h,u),{crossings:s,passes:r})}function yr(e){return dt(e)?{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:br(e.inertia),...at(e)}:pt(e)?{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...at(e)}:Be(e)?{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:e.keyframes.map(fi),...at(e)}:Yn(e)?{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:e.keyframes.map(fi),...at(e)}:{id:e.id,target:e.target,property:e.property,keyframes:e.keyframes.map(fi),...e.interpolation!==void 0&&{interpolation:e.interpolation},...at(e)}}function br(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function fi(e){return{time:e.time,value:e.value,...e.easing&&{easing:e.easing}}}function at(e){const t=e.endDelay;return{...e.delay!==void 0&&{delay:e.delay},...t!==void 0&&{endDelay:t},...e.targets!==void 0&&{targets:[...e.targets]},...e.stagger!==void 0&&{stagger:{...e.stagger}}}}function wr(e){if(dt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:br(t.inertia),...at(t)}}if(pt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...at(t)}}if(Be(e)){const t=e;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((n,i)=>n.time-i.time),...at(t)}}if(e.property==="motionPath"&&"motionPathConfig"in e){const t=e,n=[...t.keyframes].sort((i,s)=>i.time-s.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:n,...at(t)}}return je({id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,...e.interpolation!==void 0&&{interpolation:e.interpolation},...at(e)})}function vr(e){const t=e._config.markers;return{formatVersion:Kn(e.tracks),id:e.id,name:e.name,config:{duration:e.duration>0?e.duration:void 0,loop:e._config.loop,speed:e._config.speed,alternate:e._config.alternate,repeatDelay:e._config.repeatDelay,...t&&{markers:t.map(n=>({...n}))}},tracks:e.tracks.map(yr),...e.captions&&{captions:JSON.parse(JSON.stringify(e.captions))}}}function Vt(e){const t=e.formatVersion??1;if(t>Wn)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${Wn}. Update tinyfly to play it.`);return new ge({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(wr),captions:e.captions})}function Cc(e){return JSON.stringify(vr(e))}function Hc(e){const t=JSON.parse(e);return Vt(t)}function Ut(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function ye(e){let t=e>>>0||2654435769;return{seed:e>>>0,next(){return t^=t<<13,t>>>=0,t^=t>>17,t^=t<<5,t>>>=0,t/4294967296}}}function di(e,t,n){return t+e.next()*(n-t)}function kr(e,t,n,i){if(i<=0)return di(e,t,n);const s=Math.floor((n-t)/i),r=Math.round(e.next()*s);return t+r*i}function $c(e,t){if(t.length!==0)return t[Math.floor(e.next()*t.length)]}const Sr=/^([+\-*/])=\s*(-?[\d.]+)$/,Mr=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Oc(e){return typeof e!="string"?!1:Sr.test(e.trim())||Mr.test(e.trim())}function pi(e,t={}){if(typeof e!="string")return e;const n=e.trim(),i=Sr.exec(n);if(i){const[,r,o]=i,a=t.base??0,l=Number.parseFloat(o);switch(r){case"+":return a+l;case"-":return a-l;case"*":return a*l;case"/":return l===0?a:a/l}}const s=Mr.exec(n);if(s){if(!t.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const r=Number.parseFloat(s[1]),o=Number.parseFloat(s[2]),a=s[3]!==void 0?Number.parseFloat(s[3]):void 0;return a!==void 0?kr(t.random,r,o,a):di(t.random,r,o)}return e}function Tr(e,t=0,n){const i=[];let s=t;for(const r of e){const o=pi(r,{base:s,random:n});i.push(o),typeof o=="number"&&(s=o)}return i}class Rc{random;constructor(t){this.random=ye(t)}get seed(){return this.random.seed}resolve(t,n=0){return pi(t,{base:n,random:this.random})}resolveSequence(t,n=0){return Tr(t,n,this.random)}}const Lc=600;function Er(e){if(Array.isArray(e)){const[f,d,m,p]=e;return{fn:Pr(f,d,m,p),bezier:[f,d,m,p]}}const{segments:t}=At(e);if(t.length===0)throw new Error(`customEase: no curve in "${e}"`);const n=t[0].startX,i=t[0].startY,s=t[t.length-1],r=s.endX-n,o=s.endY-i;if(r===0||o===0)throw new Error(`customEase: "${e}" must move along both axes`);const a=f=>(f-n)/r,l=f=>(f-i)/o;if(t.length===1&&s.type==="C"){const[f,d,m,p]=s.points,g=[a(f),l(d),a(m),l(p)];return{fn:Pr(...g),bezier:g}}const c=[],h=[],u=Math.max(8,Math.ceil(Lc/t.length));for(const f of t)for(let d=c.length===0?0:1;d<=u;d++){const[m,p]=Fc(f,d/u);c.push(a(m)),h.push(l(p))}return{fn:Dc(c,h)}}function Ar(e={}){const n=.1+Math.max(0,Math.min(1,e.strength??.7))*.7,i=[1];for(let r=n;r>.002;r*=n)i.push(2*Math.sqrt(r));const s=i.reduce((r,o)=>r+o,0);return r=>{if(r<=0)return 0;if(r>=1)return 1;let o=r*s;for(let a=0;a<i.length;a++){if(o<=i[a]){if(a===0)return(o/i[0])**2;const l=i[a]/2,c=l*l,h=o-l;return 1-(c-h*h)}o-=i[a]}return 1}}function xr(e={}){const t=Math.max(1,e.wiggles??10),n=e.type??"easeOut",i=s=>n==="uniform"?1:n==="easeInOut"?Math.sin(Math.PI*s):(1-s)**2;return s=>s<=0||s>=1?0:Math.sin(s*t*Math.PI*2)*i(s)}function Fc(e,t){if(e.type==="L"){const[c,h]=e.points;return[e.startX+(c-e.startX)*t,e.startY+(h-e.startY)*t]}const[n,i,s,r,o,a]=e.points,l=1-t;return[l*l*l*e.startX+3*l*l*t*n+3*l*t*t*s+t*t*t*o,l*l*l*e.startY+3*l*l*t*i+3*l*t*t*r+t*t*t*a]}function Dc(e,t){return n=>{if(n<=e[0])return t[0];if(n>=e[e.length-1])return t[t.length-1];let i=0,s=e.length-1;for(;s-i>1;){const o=i+s>>1;e[o]<=n?i=o:s=o}const r=e[s]-e[i];return r===0?t[s]:t[i]+(n-e[i])/r*(t[s]-t[i])}}function Pr(e,t,n,i){const s=(o,a,l)=>3*(1-o)*(1-o)*o*a+3*(1-o)*o*o*l+o*o*o,r=(o,a,l)=>3*(1-o)*(1-o)*a+6*(1-o)*o*(l-a)+3*o*o*(1-l);return o=>{if(o<=0)return 0;if(o>=1)return 1;let a=o;for(let h=0;h<8;h++){const u=s(a,e,n)-o,f=r(a,e,n);if(Math.abs(u)<1e-6)return s(a,t,i);if(Math.abs(f)<1e-6)break;a-=u/f}let l=0,c=1;a=o;for(let h=0;h<40;h++)s(a,e,n)<o?l=a:c=a,a=(l+c)/2;return s(a,t,i)}}const Bc=350,Nc=300,Wc=550;function Kc(e,t={}){const n=t.lead??Bc,i=t.gap??Nc,s=t.tail??Wc,r=[];let o=0;return e.forEach((a,l)=>{const c=[];let h=o+n;a.lines.forEach((f,d)=>{if(!(f.duration>=0))throw new Error(`narration: scene ${l} line ${d} has an invalid duration (${f.duration})`);d>0&&(h+=i),c.push({id:f.id??`s${l}-l${d}`,scene:l,line:d,start:h,end:h+f.duration,text:f.text}),h+=f.duration});const u=h+s+(a.tail??0);r.push({id:a.id??`s${l}`,start:o,duration:u-o,cues:c}),o=u}),{duration:o,scenes:r,cues:r.flatMap(a=>a.cues)}}function Yc(e){return e.cues.map(t=>({id:t.id,time:t.start,label:t.text}))}function Xc(e,t){let n=e.scenes[0];for(const i of e.scenes)if(t>=i.start)n=i;else break;return n}const mi=e=>6e4/e.bpm;function Je(e,t){return e.offset+t*mi(e)}function Ze(e,t){return(t-e.offset)/mi(e)}function qc(e,t){return Je(e,Math.round(Ze(e,t)))}function Vc(e,t){return Je(e,Math.ceil(Ze(e,t)-1e-9))}function Uc(e,t,n){const i=Math.max(1,Math.round(e.beatsPerBar??4)),s=[];if(!(e.bpm>0)||n<t)return s;for(let r=Math.ceil(Ze(e,t)-1e-9);;r++){const o=Je(e,r);if(o>n+1e-9)break;s.push({time:o,bar:(r%i+i)%i===0,n:r})}return s}const zt=100;function zc(e,t,n={}){const i=n.minBpm??70,s=n.maxBpm??180,r=Math.max(1,Math.round(t/zt)),o=Math.min(e.length,Math.round((n.maxSeconds??60)*t)),a=Math.floor(o/r);if(a<4)return{bpm:120,offset:0,confidence:0};const l=new Float64Array(a);for(let T=0;T<a;T++){let P=0;for(let A=T*r;A<(T+1)*r;A++)P+=e[A]*e[A];l[T]=Math.log(1e-6+P/r)}const c=new Float64Array(a);for(let T=1;T<a;T++)c[T]=Math.max(0,l[T]-l[T-1]);const h=c.reduce((T,P)=>T+P,0)/a;for(let T=0;T<a;T++)c[T]=Math.max(0,c[T]-h);const u=Math.max(1,Math.floor(60*zt/s)),f=Math.min(a-1,Math.ceil(60*zt/i)),d=T=>{let P=0;for(let A=T;A<a;A++)P+=c[A]*c[A-T];return P/(a-T)};let m=0;for(let T=0;T<a;T++)m+=c[T]*c[T];m/=a;let p=u,g=-1/0;for(let T=u;T<=f;T++){const P=60*zt/T,A=Math.exp(-.5*(Math.log2(P/120)/.9)**2),_=d(T)*A;_>g&&(g=_,p=T)}const y=T=>{const P=Math.floor(T);return P<0||P+1>=a?0:c[P]+(c[P+1]-c[P])*(T-P)},w=(T,P)=>{let A=0;for(let _=P;_<a;_+=T)A+=y(_);return A};let v=p,M=0,S=-1/0;for(let T=p-.6;T<=p+.6+1e-9;T+=.02){if(T<1)continue;const P=Math.max(1,Math.round(T*4));for(let A=0;A<P;A++){const _=A/P*T,I=w(T,_);I>S&&(S=I,M=_,v=T)}}const E=60*zt/v,k=m>0?Math.max(0,Math.min(1,d(p)/m)):0,x=(M+.5)*1e3/zt;return{bpm:Math.round(E*100)/100,offset:Math.round(x%(6e4/E)),confidence:k}}const jc=600,Gc=250,_r=1;function Jc(e,t){const n=t.target??"Camera",i={x:t.stage.width/2,y:t.stage.height/2},s={},r=(u,f,d,m)=>{const p=s[u]??=[];for(;p.length>0&&p[p.length-1].time>=f;)p.pop();p.push({time:f,value:d,...m?{easing:m}:{}})},o=u=>{const f=u.rotate*Math.PI/180,d=(u.focusX-i.x)*u.scale,m=(u.focusY-i.y)*u.scale;return{x:-(d*Math.cos(f)-m*Math.sin(f)),y:-(d*Math.sin(f)+m*Math.cos(f)),scale:u.scale,rotate:u.rotate}},a=(u,f,d)=>{const m=o(f);for(const p of["x","y","scale","rotate"])r(p,u,m[p],d)};let l={focusX:i.x,focusY:i.y,scale:1,rotate:0};const c=[...e].sort((u,f)=>u.at-f.at),h=c.filter(u=>!("shake"in u));h.length>0&&a(0,l);for(const u of h)if("frame"in u){const f=Math.max(_r,u.duration??jc);a(u.at,l),l={focusX:u.frame.focus?.x??i.x,focusY:u.frame.focus?.y??i.y,scale:u.frame.scale??1,rotate:u.frame.rotate??0},a(u.at+f,l,u.easing??(f>_r?"ease-in-out":void 0))}else{const{follow:f}=u,d=f.lag??Gc,m=new ge({id:"follow",tracks:[{id:"x",target:"s",property:"x",keyframes:f.x}]}),p=w=>m.getStateAtTime(w).values.get("s")?.get("x")??l.focusX,g=[u.at,...f.x.map(w=>w.time).filter(w=>w>u.at&&w<u.until),u.until];a(u.at,l);const y=w=>({focusX:p(w)+(f.lead??0),focusY:f.y??l.focusY,scale:f.scale??l.scale,rotate:l.rotate});for(const w of g){const v=f.x.find(M=>M.time===w)?.easing;a(w+d,y(w),w===u.at?"ease-in-out":v)}l=y(u.until)}for(const u of c.filter(f=>"shake"in f)){const f=u.shake.strength??12,d=u.shake.roll??1.5,m=1e3/(u.shake.frequency??24),p=ye(u.shake.seed??Math.round(u.at)+1),g=()=>p.next()*2-1;for(const y of["shakeX","shakeY","shakeRotate"])r(y,u.at,0);for(let y=u.at+m;y<u.at+u.duration;y+=m){const w=1-(y-u.at)/u.duration;r("shakeX",y,g()*f*w),r("shakeY",y,g()*f*w),r("shakeRotate",y,g()*d*w)}for(const y of["shakeX","shakeY","shakeRotate"])r(y,u.at+u.duration,0,"ease-out")}return Object.entries(s).map(([u,f])=>({id:`${n}-${u}`,target:n,property:u,keyframes:f}))}const lt=e=>Math.round(e*1e3)/1e3;function Ir(e,t={}){if(e.length===0)return"";const n=t.curviness??1,i=t.closed??!1,s=e.length;let r=`M${lt(e[0].x)} ${lt(e[0].y)}`;if(s===1)return r;const o=l=>i?e[(l%s+s)%s]:e[Math.max(0,Math.min(s-1,l))],a=i?s:s-1;for(let l=0;l<a;l++){const c=o(l-1),h=o(l),u=o(l+1),f=o(l+2);if(n===0){r+=` L${lt(u.x)} ${lt(u.y)}`;continue}const d=n/6,m=h.x+(u.x-c.x)*d,p=h.y+(u.y-c.y)*d,g=u.x-(f.x-h.x)*d,y=u.y-(f.y-h.y)*d;r+=` C${lt(m)} ${lt(p)} ${lt(g)} ${lt(y)} ${lt(u.x)} ${lt(u.y)}`}return i?`${r} Z`:r}const X=(e,t=0)=>{const n=parseFloat(e??"");return Number.isFinite(n)?n:t};function Zc(e){const t=(e??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let i=0;i+1<t.length;i+=2)n.push({x:t[i],y:t[i+1]});return n}function Qe(e){const t=e.attributes;switch(e.tag.toLowerCase()){case"path":return t.d??null;case"circle":case"ellipse":{const n=X(t.cx),i=X(t.cy),s=e.tag.toLowerCase()==="circle"?X(t.r):X(t.rx),r=e.tag.toLowerCase()==="circle"?X(t.r):X(t.ry);return`M${n+s} ${i} A${s} ${r} 0 1 1 ${n-s} ${i} A${s} ${r} 0 1 1 ${n+s} ${i} Z`}case"rect":{const n=X(t.x),i=X(t.y),s=X(t.width),r=X(t.height);let o=t.rx!=null?X(t.rx):t.ry!=null?X(t.ry):0,a=t.ry!=null?X(t.ry):o;return o=Math.min(o,s/2),a=Math.min(a,r/2),o===0||a===0?`M${n} ${i} H${n+s} V${i+r} H${n} Z`:`M${n+o} ${i} H${n+s-o} A${o} ${a} 0 0 1 ${n+s} ${i+a} V${i+r-a} A${o} ${a} 0 0 1 ${n+s-o} ${i+r} H${n+o} A${o} ${a} 0 0 1 ${n} ${i+r-a} V${i+a} A${o} ${a} 0 0 1 ${n+o} ${i} Z`}case"line":return`M${X(t.x1)} ${X(t.y1)} L${X(t.x2)} ${X(t.y2)}`;case"polyline":case"polygon":{const n=Zc(t.points);if(n.length===0)return null;const i=n.map((s,r)=>`${r===0?"M":"L"}${s.x} ${s.y}`).join(" ");return e.tag.toLowerCase()==="polygon"?`${i} Z`:i}default:return null}}function Qc(e,t,n){const i=Math.max(2,Math.round(n.samples??32)),s=Math.max(0,n.length),r=n.since!==void 0?Math.max(t-s,n.since):t-s;if(r>=t)return[];const o=n.period,a=[];for(let l=0;l<i;l++){const c=r+(t-r)*l/(i-1),h=o&&o>0&&l<i-1?(c%o+o)%o:c;a.push({at:e(h),time:c,age:s>0?(t-c)/s:0})}return a}const th=2.5;function Cr(e){const t=[],n=[],i=e.length,s=(r,o)=>{for(let a=r+o;a>=0&&a<i;a+=o){const l=(e[a].x-e[r].x)*o,c=(e[a].y-e[r].y)*o,h=Math.hypot(l,c);if(h>1e-9)return[l/h,c/h]}return null};for(let r=0;r<i;r++){const o=e[r],a=s(r,-1),l=s(r,1),c=a??l??[1,0],h=l??a??[1,0];let u=c[0]+h[0],f=c[1]+h[1];const d=Math.hypot(u,f);d<1e-9?(u=c[0],f=c[1]):(u/=d,f/=d);const m=u*c[0]+f*c[1],p=Math.min(th,1/Math.max(m,1e-6)),g=o.width/2*p;t.push({x:o.x-f*g,y:o.y+u*g}),n.push({x:o.x+f*g,y:o.y-u*g})}return{left:t,right:n}}function Hr(e){const t=e.length;if(t<2)return null;const n=e[t-1];for(let i=t-2;i>=0;i--){const s=n.x-e[i].x,r=n.y-e[i].y,o=Math.hypot(s,r);if(o>1e-9)return{x:n.x,y:n.y,radius:n.width/2,start:Math.atan2(s/o,-r/o)}}return null}function tn(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function en(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function be(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function we(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function nn(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function gi(e){return Math.hypot(e[0],e[1],e[2])}function $r(e,t){return gi(en(e,t))}function ve(e){const t=gi(e);return t===0?[0,0,0]:be(e,1/t)}function Or(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}const eh=Object.freeze(Object.defineProperty({__proto__:null,add:tn,cross:nn,distance:$r,dot:we,length:gi,lerp:Or,normalize:ve,scale:be,subtract:en},Symbol.toStringTag,{value:"Module"})),nh=Math.PI/180;function Rr(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function xt(e,t){const n=new Array(16);for(let i=0;i<4;i++)for(let s=0;s<4;s++){let r=0;for(let o=0;o<4;o++)r+=e[o*4+s]*t[i*4+o];n[i*4+s]=r}return n}function Lr(e){return[1,0,0,0,0,1,0,0,0,0,1,0,e[0],e[1],e[2],1]}function sn(e){return[e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,1]}function ke(e){const[t,n,i,s]=e;return[1-2*(n*n+i*i),2*(t*n+i*s),2*(t*i-n*s),0,2*(t*n-i*s),1-2*(t*t+i*i),2*(n*i+t*s),0,2*(t*i+n*s),2*(n*i-t*s),1-2*(t*t+n*n),0,0,0,0,1]}function Fr(e,t,n){const i=ke(t);for(let s=0;s<3;s++)i[s]*=n[0],i[4+s]*=n[1],i[8+s]*=n[2];return i[12]=e[0],i[13]=e[1],i[14]=e[2],i}function ih(e){const t=new Array(16);for(let n=0;n<4;n++)for(let i=0;i<4;i++)t[i*4+n]=e[n*4+i];return t}function sh(e){const[t,n,i,s,r,o,a,l,c,h,u,f,d,m,p,g]=e,y=t*o-n*r,w=t*a-i*r,v=t*l-s*r,M=n*a-i*o,S=n*l-s*o,E=i*l-s*a,k=c*m-h*d,x=c*p-u*d,T=c*g-f*d,P=h*p-u*m,A=h*g-f*m,_=u*g-f*p,I=y*_-w*A+v*P+M*T-S*x+E*k;if(Math.abs(I)<1e-12)return null;const C=1/I;return[(o*_-a*A+l*P)*C,(i*A-n*_-s*P)*C,(m*E-p*S+g*M)*C,(u*S-h*E-f*M)*C,(a*T-r*_-l*x)*C,(t*_-i*T+s*x)*C,(p*v-d*E-g*w)*C,(c*E-u*v+f*w)*C,(r*A-o*T+l*k)*C,(n*T-t*A-s*k)*C,(d*S-m*v+g*y)*C,(h*v-c*S-f*y)*C,(o*x-r*P-a*k)*C,(t*P-n*x+i*k)*C,(m*w-d*M-p*y)*C,(c*M-h*w+u*y)*C]}function rh(e,t,n,i){const s=1/Math.tan(e*nh/2),r=1/(n-i);return[s/t,0,0,0,0,s,0,0,0,0,(i+n)*r,-1,0,0,2*i*n*r,0]}function oh(e,t,n,i,s,r){const o=1/(t-e),a=1/(i-n),l=1/(r-s);return[2*o,0,0,0,0,2*a,0,0,0,0,-2*l,0,-(t+e)*o,-(i+n)*a,-(r+s)*l,1]}function ah(e,t,n=[0,1,0]){const i=ve(en(e,t)),s=ve(nn(n,i)),r=nn(i,s);return[s[0],r[0],i[0],0,s[1],r[1],i[1],0,s[2],r[2],i[2],0,-we(s,e),-we(r,e),-we(i,e),1]}function Dr(e,t){const n=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12],i=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13],s=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14],r=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15];return r===1||r===0?[n,i,s]:[n/r,i/r,s/r]}const lh=Object.freeze(Object.defineProperty({__proto__:null,compose:Fr,fromQuat:ke,identity:Rr,invert:sh,lookAt:ah,multiply:xt,orthographic:oh,perspective:rh,scaling:sn,transformPoint:Dr,translation:Lr,transpose:ih},Symbol.toStringTag,{value:"Module"})),rn={"power1.in":[.55,.085,.68,.53],"power1.out":[.25,.46,.45,.94],"power1.inout":[.455,.03,.515,.955],"power2.in":[.55,.055,.675,.19],"power2.out":[.215,.61,.355,1],"power2.inout":[.645,.045,.355,1],"power3.in":[.895,.03,.685,.22],"power3.out":[.165,.84,.44,1],"power3.inout":[.77,0,.175,1],"power4.in":[.755,.05,.855,.06],"power4.out":[.23,1,.32,1],"power4.inout":[.86,0,.07,1],"sine.in":[.47,0,.745,.715],"sine.out":[.39,.575,.565,1],"sine.inout":[.445,.05,.55,.95],"expo.in":[.95,.05,.795,.035],"expo.out":[.19,1,.22,1],"expo.inout":[1,0,0,1],"circ.in":[.6,.04,.98,.335],"circ.out":[.075,.82,.165,1],"circ.inout":[.785,.135,.15,.86],"back.in":[.6,-.28,.735,.045],"back.out":[.175,.885,.32,1.275],"back.inout":[.68,-.55,.265,1.55]},Br={none:"linear",linear:"linear","linear.none":"linear","power1.in":"ease-in-quad","power1.out":"ease-out-quad","power1.inout":"ease-in-out-quad","power2.in":"ease-in-cubic","power2.out":"ease-out-cubic","power2.inout":"ease-in-out-cubic"};function ch(e){let t=e.trim().toLowerCase();t=t.replace(/\.ease(in|out|inout)$/,".$1");const n=/^([a-z]+\d?)(\(.*\))?$/.exec(t);return n&&n[1]!=="steps"&&t!=="none"&&t!=="linear"&&(t=`${n[1]}.out${n[2]??""}`),t}G({type:"bounce",mode:"in"}),G({type:"bounce",mode:"in-out"});function Se(e){const t=Nr.get(e.trim().toLowerCase());if(t)return t;const n=ch(e),i=/^steps\(\s*(\d+)\s*\)$/.exec(n);if(i){const o={type:"steps",count:Math.max(1,Number.parseInt(i[1],10))+1,position:"none"};return{easing:o,fn:G(o)}}const s=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(s){const[,r,o,a]=s,l=(a??"").split(",").map(u=>Number.parseFloat(u)).filter(u=>Number.isFinite(u)),c=o==="inout"?"in-out":o;if(r==="back"&&l.length===0&&n in rn)return{easing:{type:"cubic-bezier",points:rn[n]}};const h=r==="elastic"?{type:"elastic",mode:c,...l[0]!==void 0&&{amplitude:l[0]},...l[1]!==void 0&&{period:l[1]}}:r==="bounce"?{type:"bounce",mode:c}:{type:"back",mode:c,...l[0]!==void 0&&{overshoot:l[0]}};return{easing:h,fn:G(h)}}return n in Br?{easing:Br[n]}:n in rn?{easing:{type:"cubic-bezier",points:rn[n]}}:{easing:"ease-out"}}const Nr=new Map;function yi(e,t){return Nr.set(e.trim().toLowerCase(),t.bezier?{easing:{type:"cubic-bezier",points:t.bezier},fn:t.fn}:{fn:t.fn,requiresBaking:"custom"}),e}function bi(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=t;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}const Wr=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function Kr(e){return typeof e=="string"&&Wr.test(e)}function hh(e=1){let t=bi(e);const n=(l,c)=>((...h)=>h.length>=l?c(...h):u=>c(...h,u)),i=(l,c,h)=>Math.min(Math.max(h,Math.min(l,c)),Math.max(l,c)),s=(l,c,h,u,f)=>c===l?h:h+(f-l)/(c-l)*(u-h),r=(l,c)=>{if(typeof l=="number")return l===0?c:Math.round(c/l)*l;if(Array.isArray(l))return Yr(l,c,1/0);if("values"in l)return Yr(l.values,c,l.radius??1/0);const h=Math.round(c/l.increment)*l.increment;return Math.abs(h-c)<=(l.radius??1/0)?h:c},o=(l,c,h)=>{const u=l+t()*(c-l);return h?Math.round(u/h)*h:u};return{clamp:n(3,i),mapRange:n(5,s),normalize:n(3,(l,c,h)=>s(l,c,0,1,h)),interpolate:n(3,(l,c,h)=>{if(typeof l=="object"&&!Array.isArray(l)){const u={};for(const f of Object.keys(l))u[f]=me(l[f])(l[f],c[f],h);return u}return me(l)(l,c,h)}),wrap:((l,c,h)=>{if(Array.isArray(l)){const p=l,g=y=>p[(Math.round(y)%p.length+p.length)%p.length];return c===void 0?g:g(c)}const u=l,d=c-u,m=p=>d===0?u:((p-u)%d+d)%d+u;return h===void 0?m:m(h)}),wrapYoyo:n(3,(l,c,h)=>{const u=c-l;if(u===0)return l;const f=((h-l)%(u*2)+u*2)%(u*2);return l+(f>u?u*2-f:f)}),snap:n(2,r),random:((l,c,h,u)=>{if(Array.isArray(l)){const d=()=>l[Math.floor(t()*l.length)];return c===!0?d:d()}const f=()=>o(l,c,h);return u?f:f()}),shuffle:l=>{for(let c=l.length-1;c>0;c--){const h=Math.floor(t()*(c+1));[l[c],l[h]]=[l[h],l[c]]}return l},distribute:({base:l=0,amount:c,each:h,from:u="start",ease:f})=>(d,m,p)=>{const g=p.length,w=Ne(d,g,{...c!==void 0?{amount:c}:{each:h??1},from:u}),v=c!==void 0?c:(h??1)*qn(g,u),M=f&&v>0?f(w/v)*v:w;return l+M},pipe:(...l)=>c=>l.reduce((h,u)=>u(h),c),splitColor:l=>uh(l),getUnit:l=>typeof l=="number"?"":/^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(l.trim())?.[1]??"",seed:l=>{t=bi(l)},resolveRandomString:l=>{const c=Wr.exec(l)?.[1]??"";if(c.startsWith("[")){const m=c.slice(1,-1).split(",").map(p=>p.trim()).filter(Boolean).map(p=>Number.isFinite(Number(p))?Number(p):p.replace(/^['"]|['"]$/g,""));return m[Math.floor(t()*m.length)]}const[h,u,f]=c.split(",").map(d=>Number.parseFloat(d));return o(h,u,Number.isFinite(f)?f:void 0)}}}function Yr(e,t,n){let i=t,s=1/0;for(const r of e){const o=Math.abs(r-t);o<s&&(s=o,i=r)}return s<=n?i:t}function uh(e){const t=e.trim(),n=/^#([0-9a-f]{3,8})$/i.exec(t)?.[1];if(n){const r=(n.length<=4?[...n].map(o=>o+o).join(""):n).match(/../g).map(o=>Number.parseInt(o,16));return r.length>=4?[r[0],r[1],r[2],Math.round(r[3]/255*1e3)/1e3]:[r[0],r[1],r[2]]}const i=(/rgba?\(([^)]+)\)/i.exec(t)?.[1]??"0,0,0").split(/[\s,/]+/).filter(Boolean).map(s=>Number.parseFloat(s));return i.length>=4?[i[0],i[1],i[2],i[3]]:[i[0]??0,i[1]??0,i[2]??0]}const fh=/^([+-])=\s*(-?[\d.]+)$/,dh=/^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;function Me(e,t){const n=t.scale??1,i=c=>Number.parseFloat(c)*n;if(e===void 0)return t.cursor;if(typeof e=="number")return e*n;const s=e.trim();if(s==="")return t.cursor;const r=fh.exec(s);if(r){const c=i(r[2]);return t.cursor+(r[1]==="-"?-c:c)}const o=dh.exec(s);if(o){const c=o[1]==="<"?t.previousStart:t.previousEnd;if(o[3]===void 0)return c;const h=i(o[3]);return c+(o[2]==="-"?-h:h)}const a=/^(.+?)([+-])=\s*(-?[\d.]+)$/.exec(s);if(a){const c=t.labels.get(a[1].trim());if(c!==void 0){const h=i(a[3]);return c+(a[2]==="-"?-h:h)}}const l=t.labels.get(s);return l!==void 0?l:/^-?[\d.]+$/.test(s)?i(s):t.cursor}function ph(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.grid!==void 0||t.from==="random"||Array.isArray(t.from)||t.ease!==void 0||t.axis!==void 0}function mh(e,t,n={}){if(e===0)return[];const i=t.grid==="auto"?Math.max(1,Math.min(e,n.columnsFromLayout?.()??e)):Array.isArray(t.grid)?Math.max(1,t.grid[1]):e,s=Array.isArray(t.grid)?Math.max(1,t.grid[0]):Math.ceil(e/i),r=m=>({x:m%i,y:Math.floor(m/i)}),o=t.from??"start",a=Array.isArray(o)?{x:o[0]*(i-1),y:o[1]*(s-1)}:typeof o=="number"?r(Math.max(0,Math.min(e-1,o))):o==="end"?r(e-1):o==="center"||o==="edges"?{x:(i-1)/2,y:(s-1)/2}:{x:0,y:0},l=m=>{const{x:p,y:g}=r(m),y=Math.abs(p-a.x),w=Math.abs(g-a.y);return t.axis==="x"?y:t.axis==="y"?w:Math.hypot(y,w)};let c=Array.from({length:e},(m,p)=>l(p));const h=Math.max(...c);if(o==="edges"&&(c=c.map(m=>h-m)),o==="random"){const m=n.random??Math.random;c=c.map(()=>m()*h)}const u=t.amount!==void 0?t.amount:(t.each??0)*h,f=t.ease?Se(t.ease):void 0,d=f?f.fn??G(f.easing):void 0;return c.map(m=>{const p=h===0?0:m/h;return(d?d(p):p)*u})}const wi=new Set(["duration","delay","ease","repeat","repeatDelay","yoyo","stagger","onComplete","onUpdate","onStart","onRepeat","onReverseComplete","repeatRefresh","keyframes","easeEach","scrollTo","id","immediateRender","overwrite","paused","scrollTrigger","spring"]),gh={rotation:"rotate",rotationZ:"rotate",rotationX:"rotateX",rotationY:"rotateY",transformPerspective:"perspective",perspective:"childPerspective"};function on(e){const t={},n={};for(const[i,s]of Object.entries(e))wi.has(i)?t[i]=s:n[gh[i]??i]=s;return{config:t,properties:n}}function an(e,t){return e===void 0?t:e*1e3}function vi(e,t){if(e!==void 0)return typeof e=="number"?{each:e*1e3}:ph(e)?{offsets:mh(t?.count??0,e,t??{}).map(i=>i*1e3)}:{...e.each!==void 0&&{each:e.each*1e3},...e.amount!==void 0&&{amount:e.amount*1e3},...e.from!==void 0&&{from:e.from}}}const yh={opacity:1,x:0,y:0,z:0,rotate:0,rotateX:0,rotateY:0,rotateZ:0,scale:1,scaleX:1,scaleY:1,scaleZ:1,skewX:0,skewY:0,originX:50,originY:50,perspective:0,blur:0,glow:0,clipTop:0,clipRight:0,clipBottom:0,clipLeft:0};function Xr(e){return yh[e]}function bh(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:e;if(!t||typeof t.path!="string"&&!Array.isArray(t.path))throw new Error("gsap-compat: motionPath needs a path — SVG path data or an array of { x, y } points.");let n;if(Array.isArray(t.path))n=Ir(t.path,{curviness:t.curviness});else if(Kt(t.path))n=t.path;else throw new Error(`gsap-compat: motionPath "${t.path}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);const i={pathData:n};return t.autoRotate!==void 0&&t.autoRotate!==!1&&(i.autoRotate=!0,typeof t.autoRotate=="number"&&(i.rotateOffset=t.autoRotate)),t.matrix&&(i.matrix=t.matrix),{config:i,start:t.start??0,end:t.end??1}}function wh(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:{...e};return{...t,start:t.end??1,end:t.start??0}}function qr(e){return typeof e=="object"&&e!==null&&"shape"in e?e.shape:e}function vh(e){if(e.morphSVG===void 0)return e;const{morphSVG:t,...n}=e,i=qr(t);if(typeof i!="string"||!Kt(i))throw new Error(`gsap-compat: morphSVG "${String(i)}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);return{...n,d:i}}function kh(e,t){if(e===!0)return[0,t];if(e===!1)return[0,0];if(typeof e=="number")return[0,Vr(e,t)];const n=e.trim().split(/[\s,]+/).filter(Boolean),i=o=>{const a=Number.parseFloat(o);if(Number.isNaN(a))throw new Error(`gsap-compat: drawSVG "${e}" is not a length or percentage`);return Vr(o.endsWith("%")?t*a/100:a,t)};if(n.length===0)return[0,t];if(n.length===1)return[0,i(n[0])];const s=i(n[0]),r=i(n[1]);return s<=r?[s,r]:[r,s]}function Sh(e,t){const[n,i]=kh(e,t);return{strokeDasharray:[i-n,t],strokeDashoffset:-n}}function Mh(e,t){if(e.drawSVG===void 0)return e;const{drawSVG:n,...i}=e;return{...i,...Sh(n,t)}}function Th(e){if(e.drawSVG!==void 0)throw new Error("gsap-compat: drawSVG needs the stroke length from the page. Use live.to(), or animate strokeDasharray / strokeDashoffset directly (see drawSvgProperties).");return e}function Vr(e,t){return Math.max(0,Math.min(t,e))}function Eh(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t>>>0}function Ah(e,t,n){if(e.scrambleText!==void 0){const i=e.scrambleText,s=typeof i=="string"?{text:i}:i;if(typeof s?.text!="string")throw new Error("gsap-compat: scrambleText needs the text to end on — a string, or { text }.");const r=s.revealDelay&&n>0?s.revealDelay*1e3/n:void 0;return{to:s.text,mode:"scramble",...s.chars!==void 0&&{chars:s.chars},...s.speed!==void 0&&{refreshRate:20*s.speed},...r!==void 0&&{revealDelay:Math.min(r,.999)},...s.tweenLength!==void 0&&{tweenLength:s.tweenLength},...s.rightToLeft!==void 0&&{rightToLeft:s.rightToLeft},seed:s.seed??Eh(`${t}|${s.text}`)}}if(e.text!==void 0){const i=e.text,s=typeof i=="string"?{value:i}:i;if(typeof s?.value!="string")throw new Error("gsap-compat: text needs the text to end on — a string, or { value }.");return{to:s.value,mode:"type",...s.rightToLeft!==void 0&&{rightToLeft:s.rightToLeft}}}}function ki(e){return Math.max(.1,e/25)}function xh(e,t){const n=typeof t=="number"?{velocity:t}:t;if(typeof n?.velocity!="number"||!Number.isFinite(n.velocity))throw new Error("gsap-compat: inertia needs a velocity for each property — a number, or { velocity }.");const i=n.friction??(n.resistance!==void 0?ki(n.resistance):void 0),s={from:e,velocity:n.velocity,...i!==void 0&&{friction:i},...n.min!==void 0&&{min:n.min},...n.max!==void 0&&{max:n.max}};return typeof n.end=="function"?s.end=[n.end(he(s))]:n.end!==void 0&&(s.end=Array.isArray(n.end)?[...n.end]:n.end),s}function Ph(e){const t=e===!0?{}:typeof e=="string"?{preset:e}:e;if(t.preset!==void 0&&!(t.preset in Ye))throw new Error(`gsap-compat: unknown spring preset "${t.preset}" — use one of ${Object.keys(Ye).join(", ")}`);return{...t.preset?Ye[t.preset]:{},...t.stiffness!==void 0&&{stiffness:t.stiffness},...t.damping!==void 0&&{damping:t.damping},...t.mass!==void 0&&{mass:t.mass},...t.restDelta!==void 0&&{restDelta:t.restDelta}}}function _h(e,t){if(e===!0||typeof e=="string")return;const n=e.velocity;return typeof n=="number"?n:n?.[t]}class Pt{timeline;options;cursor=0;fallbackRandom=bi(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(t={}){this.options=t,this.timeline=new ge({id:t.id??"gsap-compat",name:t.name,config:{...t.repeat!==void 0&&{loop:t.repeat},...t.yoyo!==void 0&&{alternate:t.yoyo},...t.repeatDelay!==void 0&&{repeatDelay:t.repeatDelay*1e3},...t.timeScale!==void 0&&{speed:t.timeScale}}})}to(t,n,i){return this.build(t,void 0,Te(n),i)}from(t,n,i){const{config:s,properties:r}=on(Te(n)),{motionPath:o,text:a,scrambleText:l,...c}=r,h=this.targetsOf(t)[0],u={...s};for(const m of Object.keys(c))u[m]=this.resolveStart(h,m);o!==void 0&&(u.motionPath=wh(o));const f={},d=String(this.resolveStart(h,"text"));return a!==void 0&&(f.text=Si(a),u.text=typeof a=="object"?{...a,value:d}:d),l!==void 0&&(f.text=Si(l),u.scrambleText=typeof l=="object"?{...l,text:d}:d),this.build(t,{...c,...f},u,i)}fromTo(t,n,i,s){const{properties:r}=on(Te(n));return this.build(t,r,Te(i),s)}set(t,n,i){return this.build(t,void 0,{...Te(n),duration:0},i)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(t){const n=Math.max(0,Me(t,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(t){return Me(t,this.context())}addLabel(t,n){return this.labels.set(t,Me(n,this.context())),this}labelTimes(){return[...this.labels.values()].sort((t,n)=>t-n)}labelTime(t){return this.labels.get(t)}add(t,n){const i=Me(n,this.context());for(const r of t.timeline.tracks){if(!("keyframes"in r))continue;const o=je({...r,id:this.nextTrackId(`nested-${r.id}`),keyframes:r.keyframes.map(a=>({...a,time:a.time+i}))});this.timeline.addTrack(o)}const s=i+t.timeline.duration;return this.previousStart=i,this.previousEnd=s,this.cursor=Math.max(this.cursor,s),this}play(){return this.timeline.play(),this}pause(){return this.timeline.pause(),this}restart(){return this.timeline.stop(),this.timeline.play(),this}reverse(){return this.timeline.reverse(),this}kill(){return this.timeline.removeTracks(),this}reset(){return this.timeline.removeTracks(),this.cursor=0,this.previousStart=0,this.previousEnd=0,this.labels.clear(),this.lastValues.clear(),this.trackCounter=0,this}seek(t){if(typeof t=="string"){const n=this.labels.get(t);return n!==void 0&&this.timeline.seek(n),this}return this.timeline.seek(t*1e3),this}progress(t){const n=this.timeline.duration;return t!==void 0&&n>0&&this.timeline.seek(t*n),n>0?this.timeline.currentTime/n:0}timeScale(t){return t!==void 0&&(this.timeline.speed=t),this.timeline.speed}duration(){return this.timeline.duration/1e3}tick(t){return this.timeline.tick(t),this}toDefinition(){return this.timeline.toDefinition()}build(t,n,i,s){const{config:r,properties:o}=on(i),{motionPath:a,text:l,scrambleText:c,inertia:h,...u}=o,f=this.targetsOf(t),d=Me(s,this.context()),m=an(r.delay,0),p=an(r.duration,500),g=vi(r.stagger,{count:f.length,columnsFromLayout:this.options.layoutColumns?()=>this.options.layoutColumns(f):void 0,random:this.options.random??this.fallbackRandom}),y=this.easingFor(r.ease),w=[],v=r.spring;let M=0,S=!1;for(const[A,_]of Object.entries(u)){const I=_;let C=n?.[A]!==void 0?n[A]:this.resolveStart(f[0],A);if(typeof C!=typeof I&&(this.warn(`no usable start value for "${A}" on "${f[0]}" — it will snap to ${String(I)}. Use fromTo() to animate it.`),C=I),v!==void 0&&(typeof C!="number"||typeof I!="number")&&this.warn(`spring works on numbers, so "${A}" on "${f[0]}" eases instead`),v!==void 0&&typeof C=="number"&&typeof I=="number"){const B={...Ph(v),from:C,to:I,velocity:_h(v,A)??this.options.startVelocity?.(f[0],A)??0},O=this.nextTrackId(`${f[0]}-${A}-spring`),L={id:O,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:A,kind:"spring",spring:B,delay:d+m};this.timeline.addTrack(L),w.push(O),M=Math.max(M,xs(B));for(const $ of f)this.lastValues.set(`${$}|${A}`,I);continue}S=!0;const H=this.keyframesFor(C,I,p,y,r.ease),R=this.nextTrackId(`${f[0]}-${A}`);this.timeline.addTrack(je({id:R,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:A,delay:d+m,keyframes:H,...A==="quaternion"&&{interpolation:"slerp"}})),w.push(R);for(const B of f)this.lastValues.set(`${B}|${A}`,I)}const E=Ah({text:l,scrambleText:c},f[0],p);if(E){const A=n?.text??n?.scrambleText,_=A!==void 0?Si(A):this.resolveStart(f[0],"text"),I=this.nextTrackId(`${f[0]}-text`),C={id:I,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:"text",textConfig:{from:typeof _=="string"?_:String(_??""),...E},delay:d+m,keyframes:this.keyframesFor(0,1,p,y,r.ease)};this.timeline.addTrack(C),w.push(I);for(const H of f)this.lastValues.set(`${H}|text`,E.to)}if(a!==void 0){const{config:A,start:_,end:I}=bh(a),C=this.nextTrackId(`${f[0]}-motionPath`),H={id:C,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:"motionPath",motionPathConfig:A,delay:d+m,keyframes:this.keyframesFor(_,I,p,y,r.ease)};this.timeline.addTrack(H),w.push(C)}if(h!==void 0)for(const[A,_]of Object.entries(h)){const I=this.resolveStart(f[0],A);if(typeof I!="number"){this.warn(`inertia on "${A}" needs a numeric start value; skipped`);continue}const C=xh(I,_),H=this.nextTrackId(`${f[0]}-${A}-inertia`),R={id:H,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:A,kind:"inertia",inertia:C,delay:d+m};this.timeline.addTrack(R),w.push(H),M=Math.max(M,Nt(C));for(const B of f)this.lastValues.set(`${B}|${A}`,Bt(C))}const T=((h!==void 0||v!==void 0)&&!S&&!E&&a===void 0?M:Math.max(p,M))+(g&&f.length>1?le(f.length,g):0),P=d+m+T;return this.previousStart=d+m,this.previousEnd=P,this.cursor=Math.max(this.cursor,P),{trackIds:w,start:d+m,end:P,kill:()=>{for(const A of w)this.timeline.removeTrack(A)}}}keyframesFor(t,n,i,s,r){const o={time:0,value:t};if(i<=0)return[{time:0,value:n}];const a=typeof r=="string"?Se(r):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&ae(s)){const c=a?.fn??G(s);return[o,...li(o,{time:i,value:n},c,{intervalMs:this.options.bakeIntervalMs})]}return[o,{time:i,value:n,...s&&{easing:s}}]}resolveStart(t,n){const i=this.lastValues.get(`${t}|${n}`);if(i!==void 0)return i;const s=this.options.startValue?.(t,n);if(s!==void 0)return s;const r=this.options.defaults?.[n];if(r!==void 0)return r;if(n==="text")return"";if(n==="quaternion")return[0,0,0,1];if(n==="d")throw new Error(`gsap-compat: no starting shape for "${t}". Use fromTo({ d: … }, { morphSVG: … }), or live.to(), which reads the element's current shape.`);const o=Xr(n);return o!==void 0?(this.warn(`no start value for "${n}" on "${t}" — using the static default ${o}. GSAP would read the live DOM here; tinyfly cannot, so pass an explicit fromTo() or a defaults map.`),o):(this.warn(`no start value or default for "${n}" on "${t}" — using 0`),0)}easingFor(t){if(t!==void 0){if(typeof t=="string")return Se(t).easing;if(typeof t=="function")throw new Error('gsap-compat: function eases cannot be serialized. Use a named ease, or a cubic-bezier via { type: "cubic-bezier", points: [...] }.');return t}}targetsOf(t){return Array.isArray(t)?t:[t]}context(){return{cursor:this.cursor,previousStart:this.previousStart,previousEnd:this.previousEnd,labels:this.labels,scale:1e3}}nextTrackId(t){return this.trackCounter+=1,`${t}-${this.trackCounter}`}warn(t){this.options.onWarning?.(`gsap-compat: ${t}`)}}function Si(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;return String(t.value??t.text??"")}return String(e??"")}function Ih(e){return new Pt(e)}function Te(e){return Th(vh(e))}function Ch(e){return!Array.isArray(e)||e.length!==4?null:`matrix3d(${ke(yt(e)).map(n=>Math.round(n*1e6)/1e6+0).join(", ")})`}const Hh=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),$h="#ffffff",Oh="rgba(0, 0, 0, 0.5)";function Rh(e){const t=[];if(e.blur!==void 0&&t.push(`blur(${Math.max(0,e.blur)}px)`),e.brightness!==void 0&&t.push(`brightness(${Math.max(0,e.brightness)})`),e.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,e.glow)}px ${e.glowColor??$h})`),e.shadowX!==void 0||e.shadowY!==void 0||e.shadowBlur!==void 0){const n=e.shadowX??0,i=e.shadowY??0,s=Math.max(0,e.shadowBlur??0);t.push(`drop-shadow(${n}px ${i}px ${s}px ${e.shadowColor??Oh})`)}return t.length>0?t.join(" "):null}function Lh(e,t){const n=e.childNodes.length===1?e.firstChild:null;if(n&&n.nodeType===3){const i=n;i.data!==t&&(i.data=t);return}e.textContent!==t&&(e.textContent=t)}function Fh(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const Ur=new Set(["width","height","top","right","bottom","left","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","borderRadius","borderWidth","fontSize","lineHeight","letterSpacing","outlineWidth","gap","rowGap","columnGap"]),Dh=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","quaternion","motionPathX","motionPathY","motionPathRotate"]),Bh=["x","motionPathX","y","motionPathY","z","rotate","rotateZ","motionPathRotate","rotateX","rotateY","quaternion","scale","scaleX","scaleY","scaleZ","skewX","skewY"],Nh=new Set(["childPerspective","perspectiveOriginX","perspectiveOriginY"]),Wh=new Set(["originX","originY"]),Kh=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Yh=new Set(["drawOn"]),Xh={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},zr={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},qh="http://www.w3.org/2000/svg";class _t{targets=new Map;registerTarget(t,n){this.targets.set(t,n)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[n,i]of t.values){const s=this.targets.get(n);s&&this.applyProperties(s,i)}}applyProperties(t,n){let i=null,s=null,r=null,o=null,a=null;const l=n.has("motionPathX"),c=n.has("motionPathY"),h=n.has("motionPathRotate");for(const[m,p]of n)if(!(m==="x"&&l)&&!(m==="y"&&c)&&!((m==="rotate"||m==="rotateZ")&&h)&&!Yh.has(m)){if(Dh.has(m))(i??={})[m]=p;else if(Nh.has(m))typeof p=="number"&&((s??={})[m]=p);else if(Wh.has(m))typeof p=="number"&&((r??={})[m]=p);else if(Kh.has(m))typeof p=="number"&&((o??={})[m]=p);else if(Hh.has(m))(a??={})[m]=p;else if(m!=="perspective"){if(m!=="shine")if(m==="text"&&typeof p=="string")Lh(t,p);else if(m==="d"&&typeof p=="string"){const g=t;(g.tagName?.toLowerCase()==="path"?g:g.querySelector?.("path"))?.setAttribute?.("d",p)}else this.applyStyleProperty(t,m,p)}}const u=n.get("shine");typeof u=="number"&&this.applyShine(t,u);const f=[],d=n.get("perspective");if(typeof d=="number"&&d>0&&f.push(`perspective(${d}px)`),i)for(const m of Bh){const p=i[m];if(p===void 0)continue;const g=this.buildTransformPart(m,p);g&&f.push(g)}if(f.length>0&&(t.style.transform=f.join(" "),Fh(t)),s&&(s.childPerspective!==void 0&&(t.style.perspective=`${s.childPerspective}px`),(s.perspectiveOriginX!==void 0||s.perspectiveOriginY!==void 0)&&(t.style.perspectiveOrigin=`${s.perspectiveOriginX??50}% ${s.perspectiveOriginY??50}%`)),r){const m=r.originX??50,p=r.originY??50;t.style.transformOrigin=`${m}% ${p}%`}if(o){const m=o.clipTop??0,p=o.clipRight??0,g=o.clipBottom??0,y=o.clipLeft??0;t.style.clipPath=`inset(${m}% ${p}% ${g}% ${y}%)`}if(a){const m=Rh(a);m&&(t.style.filter=m)}}buildTransformPart(t,n){if(t==="quaternion")return Ch(n);if(typeof n!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${n}px)`;case"y":case"motionPathY":return`translateY(${n}px)`;case"z":return`translateZ(${n}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${n}deg)`;case"rotateX":return`rotateX(${n}deg)`;case"rotateY":return`rotateY(${n}deg)`;case"scale":return`scale(${n})`;case"scaleX":return`scaleX(${n})`;case"scaleY":return`scaleY(${n})`;case"scaleZ":return`scaleZ(${n})`;case"skewX":return`skewX(${n}deg)`;case"skewY":return`skewY(${n}deg)`;default:return null}}applyShine(t,n){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const i=t.dataset.shineBase,s=-20+n*140,r=t.style;r.color="transparent",r.backgroundImage=`linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${i}, ${i})`,r.backgroundSize="250% 100%, 100% 100%",r.backgroundPosition=`${s}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,n,i){let s;if(t.namespaceURI===qh&&n in zr){const a=Array.isArray(i)?i.join(", "):String(i);t.style[zr[n]]=a;return}else n==="fill"&&t.dataset?.elementType==="text"?s="color":s=Xh[n]??n;let o;typeof i=="number"?Ur.has(n)||Ur.has(s)?o=`${i}px`:o=String(i):Array.isArray(i)?o=i.join(", "):o=i,t.style[s]=o}}const Vh={request:e=>requestAnimationFrame(e),cancel:e=>cancelAnimationFrame(e)};class jr{adapter=new _t;scheduler;rootOption;onWarning;names=new WeakMap;elements=new Map;nameCounter=0;objectNames=new WeakMap;objects=new Map;owned=new Set;currentCollector;tickerCallbacks=new Set;tickerTime=0;tickerFrame=0;liveTimelines=new Set;utils=hh();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(t={}){this.scheduler=t.scheduler??Vh,this.rootOption=t.root,this.onWarning=t.onWarning}get root(){return this.rootOption??document}resolveTargets(t){const n=[];for(const i of this.targetsOf(t)){const s=this.nameFor(i);Mi(i)&&this.currentCollector?.touch(i,s),n.push(s)}return n}query(t){return this.selectorRoot.querySelector(t)}get collector(){return this.currentCollector}setCollector(t){this.currentCollector=t}forget(t){this.applied.delete(t),this.dirty.delete(t)}get selectorRoot(){return this.currentCollector?.scope??this.root}elementFor(t){return this.elements.get(t)}objectFor(t){return this.objects.get(t)}appliedValue(t,n){return this.applied.get(t)?.get(n)}velocityOf(t,n){for(const s of[...this.active.keys()].reverse()){if(s.getTracks({target:t,property:n}).length===0)continue;const r=s.currentTime;if(r<4)return 0;const o=s.getStateAtTime(r).values.get(t)?.get(n),a=s.getStateAtTime(r-4).values.get(t)?.get(n);if(typeof o!="number"||typeof a!="number")return;const l=(o-a)/4;return(s.direction==="reverse"?-l:l)*1e3}}ticker={add:t=>{this.destroyed||(this.tickerCallbacks.size===0&&(this.tickerTime=0,this.tickerFrame=0),this.tickerCallbacks.add(t),this.currentCollector?.track({revert:()=>this.ticker.remove(t)}),this.startLoop())},remove:t=>{this.tickerCallbacks.delete(t),this.running||this.stopLoop()}};activate(t,n={}){this.destroyed||(t.onUpdate=i=>this.write(i),this.active.delete(t),this.active.set(t,n),this.startLoop())}deactivate(t){this.active.delete(t),this.running||this.stopLoop()}own(t){return this.destroyed?t.destroy():this.owned.add(t),t}destroy(){this.destroyed=!0;for(const t of this.owned)t.destroy();this.owned.clear();for(const t of this.active.keys())t.stop();this.active.clear(),this.stopLoop(),this.adapter.clearTargets(),this.elements.clear(),this.names=new WeakMap,this.objects.clear(),this.objectNames=new WeakMap,this.tickerCallbacks.clear(),this.liveTimelines.clear(),this.applied.clear(),this.dirty.clear()}apply(t,n){if(this.destroyed)return;const i=new Map(Object.entries(n));this.write({values:new Map([[t,i]]),currentTime:0,playbackState:"idle",direction:"forward",loopIteration:0}),this.flush()}render(t){this.destroyed||(this.write(t.getStateAtTime(t.currentTime)),this.flush())}tick(t){const n=[...this.active];for(const[i]of n)i.duration<=0?(this.write(i.getStateAtTime(0)),i.stop()):i.tick(t);this.flush();for(const[i,s]of n)s.onUpdate?.(),i.playbackState!=="playing"&&this.active.get(i)===s&&this.active.delete(i);this.flush(),this.runTicker(t),this.running||this.stopLoop()}get running(){return this.active.size>0||this.tickerCallbacks.size>0}runTicker(t){if(this.tickerCallbacks.size!==0){this.tickerTime+=t,this.tickerFrame+=1;for(const n of[...this.tickerCallbacks])n(this.tickerTime/1e3,t,this.tickerFrame)}}write(t){for(const[n,i]of t.values){let s=this.applied.get(n);s||(s=new Map,this.applied.set(n,s));for(const[r,o]of i)s.set(r,o);this.dirty.add(n)}}flush(){if(this.dirty.size===0)return;const t=new Map;for(const n of this.dirty){const i=this.applied.get(n),s=this.objects.get(n);if(s)for(const[r,o]of i)s[r]=o;else t.set(n,i)}this.dirty.clear(),t.size!==0&&this.adapter.applyState({values:t,currentTime:0,playbackState:"playing",direction:"forward",loopIteration:0})}frame=t=>{this.frameId=null;const n=this.lastTimestamp===null?0:t-this.lastTimestamp;this.lastTimestamp=t,n>0&&this.tick(n),this.running&&this.frameId===null&&(this.frameId=this.scheduler.request(this.frame))};startLoop(){this.frameId===null&&(this.lastTimestamp=null,this.frameId=this.scheduler.request(this.frame))}stopLoop(){this.frameId!==null&&this.scheduler.cancel(this.frameId),this.frameId=null,this.lastTimestamp=null}targetsOf(t){if(typeof t=="string")return Array.from(this.selectorRoot.querySelectorAll(t));if(Mi(t))return[t];if(!Uh(t))return[t];const n=[];for(const i of Array.from(t))n.push(...this.targetsOf(i));return n}nameFor(t){return Mi(t)?this.elementName(t):this.objectName(t)}objectName(t){const n=this.objectNames.get(t);if(n)return n;let i;do this.nameCounter+=1,i=`obj-${this.nameCounter}`;while(this.objects.has(i)||this.elements.has(i));return this.objectNames.set(t,i),this.objects.set(i,t),i}elementName(t){const n=this.names.get(t);if(n)return n;let i=t.id?`#${t.id}`:"";if(!i||this.elements.has(i))do this.nameCounter+=1,i=`el-${this.nameCounter}`;while(this.elements.has(i));return this.names.set(t,i),this.elements.set(i,t),this.adapter.registerTarget(i,t),i}}function Mi(e){return typeof e=="object"&&e!==null&&e.nodeType===1}function Uh(e){if(Array.isArray(e))return!0;const t=e;return typeof t.length=="number"&&typeof t.item=="function"}function ln(e){const t=e.style;if(!t)return e.getBoundingClientRect();const n=t.transform;t.transform="none";const i=e.getBoundingClientRect();return t.transform=n,i}const Gr=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function zh(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function jh(e){const t=e.getScreenCTM?.();if(t)return[t.a,t.b,t.c,t.d,t.e,t.f];const n=e.getBoundingClientRect();return[1,0,0,1,n.left,n.top]}function Gh(e,t){const n=typeof e=="string"||Array.isArray(e)||Gr(e)?{path:e}:e,{align:i,alignOrigin:s,path:r,...o}=n,a=E=>{const k=Gr(E)?E:t.query(E);return k||t.warn(`gsap-compat: motionPath could not find "${String(E)}"`),k};let l=null,c="";if(Array.isArray(r)||typeof r=="string"&&Kt(r))c=r;else{l=a(r);const E=l&&Qe({tag:l.localName,attributes:zh(l)});l&&!E&&t.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),c=E??""}const h={...o,path:c};if(i===void 0||i===!1)return h;const u=i===!0?l:a(i);if(!u)return i===!0&&t.warn("gsap-compat: motionPath align: true needs the path to be an element"),h;const f=t.targets[0];if(!f)return h;const[d,m,p,g,y,w]=jh(u),v=ln(f),[M,S]=s??[.5,.5];for(const E of t.targets.slice(1)){const k=ln(E);if(Math.abs(k.left-v.left)>.5||Math.abs(k.top-v.top)>.5){t.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");break}}return h.matrix=[d,m,p,g,y-v.left-M*v.width,w-v.top-S*v.height],h}const Jr=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function Zr(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function Qr(e){if(!e)return null;const t=Qe({tag:e.localName,attributes:Zr(e)});return t||(e.querySelector("path")?.getAttribute("d")??null)}function Jh(e,t,n){const i=qr(e);if(typeof i=="string"&&Kt(i))return i;const s=Jr(i)?i:typeof i=="string"?t(i):null,r=Qr(s);return r||(n(`gsap-compat: morphSVG could not find a shape for "${String(i)}"`),"")}const Zh=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function Qh(e,t=document){return(typeof e=="string"?Array.from(t.querySelectorAll(e)):Jr(e)?[e]:Array.from(e)).map(i=>{if(i.localName==="path")return i;const s=Qe({tag:i.localName,attributes:Zr(i)});if(!s||!i.parentNode)return i;const r=i.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path");for(const o of Array.from(i.attributes))Zh.has(o.name)||r.setAttribute(o.name,o.value);return r.setAttribute("d",s),i.parentNode.replaceChild(r,i),r})}const to=.3;class eo{options;target;running=!1;dragging=!1;passedTolerance=!1;lastX=0;lastY=0;startX=0;startY=0;velocityX=0;velocityY=0;lastTime=0;constructor(t){this.options=t,this.target=t.target}start(){if(this.running)return;this.running=!0;const t=this.options.type??["pointer","touch"];t.includes("pointer")&&(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointermove",this.onPointerMove),this.target.addEventListener("pointerup",this.onPointerUp),this.target.addEventListener("pointercancel",this.onPointerUp)),t.includes("touch")&&(this.target.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.target.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.target.addEventListener("touchend",this.onTouchEnd)),t.includes("wheel")&&this.target.addEventListener("wheel",this.onWheel,{passive:!1})}stop(){this.running&&(this.running=!1,this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointermove",this.onPointerMove),this.target.removeEventListener("pointerup",this.onPointerUp),this.target.removeEventListener("pointercancel",this.onPointerUp),this.target.removeEventListener("touchstart",this.onTouchStart),this.target.removeEventListener("touchmove",this.onTouchMove),this.target.removeEventListener("touchend",this.onTouchEnd),this.target.removeEventListener("wheel",this.onWheel))}destroy(){this.stop()}get velocity(){return{x:this.velocityX,y:this.velocityY}}begin(t,n,i){this.dragging=!0,this.passedTolerance=!1,this.startX=t,this.startY=n,this.lastX=t,this.lastY=n,this.velocityX=0,this.velocityY=0,this.lastTime=no(),this.options.onPress?.(this.stateFrom(0,0,i))}move(t,n,i){if(!this.dragging)return;const s=t-this.lastX,r=n-this.lastY;this.lastX=t,this.lastY=n;const o=t-this.startX,a=n-this.startY,l=this.options.tolerance??3;if(!this.passedTolerance){if(Math.hypot(o,a)<l)return;this.passedTolerance=!0}this.updateVelocity(s,r),this.options.preventDefault!==!1&&i.cancelable&&i.preventDefault(),this.options.onMove?.(this.stateFrom(s,r,i))}end(t){this.dragging&&(this.dragging=!1,this.options.onRelease?.(this.stateFrom(0,0,t)))}updateVelocity(t,n){const i=no(),s=Math.max(1,i-this.lastTime);this.lastTime=i;const r=t/s*1e3,o=n/s*1e3;this.velocityX+=(r-this.velocityX)*to,this.velocityY+=(o-this.velocityY)*to}stateFrom(t,n,i){return{deltaX:t,deltaY:n,velocityX:this.velocityX,velocityY:this.velocityY,totalX:this.lastX-this.startX,totalY:this.lastY-this.startY,isDragging:this.dragging,event:i}}onPointerDown=t=>{const n=t,i=this.target;if(typeof n.pointerId=="number"&&typeof i.setPointerCapture=="function")try{i.setPointerCapture(n.pointerId)}catch{}this.begin(n.clientX,n.clientY,t)};onPointerMove=t=>{const n=t;this.move(n.clientX,n.clientY,t)};onPointerUp=t=>this.end(t);onTouchStart=t=>{const n=t.touches[0];n&&this.begin(n.clientX,n.clientY,t)};onTouchMove=t=>{const n=t.touches[0];n&&this.move(n.clientX,n.clientY,t)};onTouchEnd=t=>this.end(t);onWheel=t=>{const n=t;this.options.preventDefault!==!1&&n.cancelable&&n.preventDefault(),this.updateVelocity(n.deltaX,n.deltaY),this.options.onMove?.({deltaX:n.deltaX,deltaY:n.deltaY,velocityX:this.velocityX,velocityY:this.velocityY,totalX:0,totalY:0,isDragging:!1,event:t})}}function no(){return typeof performance<"u"?performance.now():Date.now()}function io(e,t,n){let i={delta:0,line:null},s=n;for(const r of e)for(const o of t){const a=Math.abs(o-r);a<=s&&(s=a,i={delta:o-r,line:o})}return i}function so(e,t){return t<=0?[]:e.map(n=>Math.round(n/t)*t)}class Ti{options;observer;x;y;originX=0;originY=0;snappedX=null;snappedY=null;constructor(t){this.options=t,this.x=t.initialX??0,this.y=t.initialY??0,this.observer=new eo({target:t.target,onPress:n=>{const i=t.getPosition?.();i&&(this.x=i.x,this.y=i.y),this.originX=this.x,this.originY=this.y,t.onPress?.(n)},onMove:n=>this.handleMove(n),onRelease:n=>t.onRelease?.(n)})}start(){this.observer.start()}stop(){this.observer.stop()}destroy(){this.observer.destroy()}get position(){return{x:this.x,y:this.y}}get velocity(){return this.observer.velocity}setPosition(t,n){const i=this.options.axis??"both";this.x=i==="y"?this.x:this.applyConstraints(t,"x"),this.y=i==="x"?this.y:this.applyConstraints(n,"y")}get snapLines(){return{x:this.snappedX,y:this.snappedY}}snapThreshold(){if(this.options.snapThreshold!==void 0)return this.options.snapThreshold;const t=this.options.snap??0;return t>0?t/2:8}handleMove(t){this.setPosition(this.originX+t.totalX,this.originY+t.totalY),this.options.mode==="scrub"&&this.scrub(),this.options.onDrag?.(this.position,t),this.options.onSnap?.(this.snapLines)}scrub(){const t=this.options.timeline;if(!t)return;const n=t.duration;if(n<=0)return;const i=this.options.scrubDistance??500;if(i===0)return;const s=(this.options.axis??"both")==="y"?this.y:this.x,r=tu(s/i);t.pause(),t.seek(r*n)}applyConstraints(t,n){let i=t;const s=[...so([i],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],r=io([i],s,this.snapThreshold());i+=r.delta,n==="x"?this.snappedX=r.line:this.snappedY=r.line;const o=this.options.bounds;if(o){const a=n==="x"?o.minX:o.minY,l=n==="x"?o.maxX:o.maxY;a!==void 0&&(i=Math.max(a,i)),l!==void 0&&(i=Math.min(l,i))}return i}}function tu(e){return e<0?0:e>1?1:e}function eu(e){const t=new Ti(e);return t.start(),t}const nu={x:"x",y:"y","x,y":"both"},Ei=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function ro(e,t){const n=ln(e),i=t.getBoundingClientRect();return{minX:i.left-n.left,maxX:i.right-n.right,minY:i.top-n.top,maxY:i.bottom-n.bottom}}function oo(e){return Array.isArray(e)?[...e]:e}function iu(e,t,n,i={}){const[s]=t.resolveTargets(n),r=s?t.elementFor(s):void 0;if(!s||!r)throw new Error(`gsap-compat: live.draggable could not find ${String(n)}`);if(i.type==="rotation")return su(e,t,s,r,i);const o=nu[i.type??"x,y"],a=()=>{const p=t.appliedValue(s,"x"),g=t.appliedValue(s,"y");return{x:typeof p=="number"?p:0,y:typeof g=="number"?g:0}},l=typeof i.bounds=="string"?t.query(i.bounds):Ei(i.bounds)?i.bounds:null,h={bounds:(!l&&i.bounds&&!Ei(i.bounds)?i.bounds:void 0)??(l?ro(r,l):void 0)};let u=null;const f=()=>{u?.kill(),u=null},d=p=>{const g=i.inertia===!0?{}:i.inertia,y=g.friction??(g.resistance!==void 0?ki(g.resistance):4),w=a(),v=h.bounds??{};let M,S;const E=g.end;if(Array.isArray(E)){const x=he({from:w.x,velocity:o==="y"?0:p.x,friction:y}),T=he({from:w.y,velocity:o==="x"?0:p.y,friction:y});let P=E[0];for(const A of E)Math.hypot(A.x-x,A.y-T)<Math.hypot(P.x-x,P.y-T)&&(P=A);P&&(M=[P.x],S=[P.y])}else typeof E=="number"?(M=E,S=E):E&&(M=oo(E.x),S=oo(E.y));const k={};o!=="y"&&(k.x={velocity:p.x,friction:y,min:v.minX,max:v.maxX,end:M}),o!=="x"&&(k.y={velocity:p.y,friction:y,min:v.minY,max:v.maxY,end:S}),u=e.to(r,{inertia:k,onComplete:()=>i.onThrowComplete?.()})},m=new Ti({target:r,axis:o,snap:i.snap,get bounds(){return h.bounds},getPosition:a,onPress:()=>{f(),l&&(h.bounds=ro(r,l)),i.onPress?.()},onDrag:p=>{t.apply(s,o==="x"?{x:p.x}:o==="y"?{y:p.y}:{x:p.x,y:p.y}),i.onDrag?.(p)},onRelease:()=>{const p=m.velocity;i.onRelease?.(p),i.inertia&&d(p)}});return m.start(),{draggable:m,get position(){return a()},get rotation(){const p=t.appliedValue(s,"rotate");return typeof p=="number"?p:0},destroy(){f(),m.destroy()}}}function su(e,t,n,i,s){const r=typeof s.bounds=="object"&&s.bounds!==null&&!Ei(s.bounds)?s.bounds:{},o=()=>{const v=t.appliedValue(n,"rotate");return typeof v=="number"?v:0},a=v=>Math.min(r.maxRotation??1/0,Math.max(r.minRotation??-1/0,v));let l=null,c=!1,h,u={x:0,y:0},f=0,d=0,m=[];const p=v=>Math.atan2(v.clientY-u.y,v.clientX-u.x)*180/Math.PI,g=v=>{if(c)return;l?.kill(),l=null,c=!0,h=v.pointerId,i.setPointerCapture?.(v.pointerId);const M=i.getBoundingClientRect();u={x:M.left+M.width/2,y:M.top+M.height/2},f=p(v),d=o(),m=[{time:performance.now(),rotation:d}],s.onPress?.()},y=v=>{if(!c||v.pointerId!==h)return;const M=p(v);let S=M-f;S>180&&(S-=360),S<-180&&(S+=360),f=M,d+=S;let E=a(d);s.snap&&(E=a(Math.round(E/s.snap)*s.snap)),t.apply(n,{rotate:E});const k=performance.now();for(m.push({time:k,rotation:E});m.length>2&&k-m[0].time>100;)m.shift();const x={x:0,y:0};s.onDrag?.(x)},w=v=>{if(!c||v.pointerId!==h)return;c=!1;const M=m[0],S=m[m.length-1],E=M&&S?(S.time-M.time)/1e3:0,k=E>0?(S.rotation-M.rotation)/E:0;if(s.onRelease?.({x:k,y:0}),!s.inertia)return;const x=s.inertia===!0?{}:s.inertia,T=x.friction??(x.resistance!==void 0?ki(x.resistance):4),P=typeof x.end=="number"||Array.isArray(x.end)?x.end:void 0;l=e.to(i,{inertia:{rotate:{velocity:k,friction:T,min:r.minRotation,max:r.maxRotation,end:Array.isArray(P)?P.filter(A=>typeof A=="number"):P}},onComplete:()=>s.onThrowComplete?.()})};return i.addEventListener("pointerdown",g),i.addEventListener("pointermove",y),i.addEventListener("pointerup",w),i.addEventListener("pointercancel",w),i.style.touchAction="none",{draggable:void 0,position:{x:0,y:0},get rotation(){return o()},destroy(){l?.kill(),i.removeEventListener("pointerdown",g),i.removeEventListener("pointermove",y),i.removeEventListener("pointerup",w),i.removeEventListener("pointercancel",w)}}}const ru={opacity:0,scale:.6};function ou(e){const t=e.getBoundingClientRect();return t.width===0&&t.height===0?null:{cx:t.left+t.width/2,cy:t.top+t.height/2,width:t.width,height:t.height}}function ao(e){const t=ln(e);return t.width===0&&t.height===0?null:{cx:t.left+t.width/2,cy:t.top+t.height/2,width:t.width,height:t.height}}function Ai(e,t){const i=e.resolveTargets(t).map(o=>e.elementFor(o)).filter(o=>!!o),s=new Map,r=new Map;for(const o of i){const a=ou(o);s.set(o,a);const l=lo(o);a&&l!==void 0&&!r.has(l)&&r.set(l,{element:o,box:a})}return{elements:i,boxes:s,ids:r}}const xi=new WeakMap;function Pi(e,t,n,i={}){const s=i.duration??.6,r=i.ease??"power2.inOut",o=i.stagger??0,a=i.scale!==!1,l=i.enter===void 0?ru:i.enter,c=new Set(n.elements);if(i.targets!==void 0)for(const d of e.resolveTargets(i.targets)){const m=e.elementFor(d);m&&c.add(m)}const h=[...c].sort((d,m)=>d===m?0:d.compareDocumentPosition(m)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),u=t({onComplete:i.onComplete});let f=0;for(const d of h){const m=ao(d);if(!m)continue;let p=n.boxes.get(d)??null,g;const y=lo(d),w=!p&&y!==void 0?n.ids.get(y):void 0;w&&w.element!==d&&(p=w.box,g=w.element);const[v]=e.resolveTargets(d);xi.get(d)?.timeline.removeTracks({target:v});const M=f*o;if(!p){if(l===!1)continue;u.fromTo(d,{x:0,y:0,scaleX:1,scaleY:1,...l},{...co(l),x:0,y:0,scaleX:1,scaleY:1,duration:s,ease:r,delay:M},0),xi.set(d,u),f++;continue}const S=p.cx-m.cx,E=p.cy-m.cy,k=a?p.width/m.width:1,x=a?p.height/m.height:1;if(!(Math.abs(S)>.5||Math.abs(E)>.5||Math.abs(k-1)>.001||Math.abs(x-1)>.001)){const A=(_,I)=>{const C=e.appliedValue(v,_);return typeof C=="number"&&Math.abs(C-I)>1e-6};(A("x",0)||A("y",0)||A("scaleX",1)||A("scaleY",1))&&u.set(d,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const P=i.fade===!0&&g!==void 0;u.fromTo(d,{x:S,y:E,scaleX:k,scaleY:x,...P&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,...P&&{opacity:1},duration:s,ease:r,delay:M},0),P&&g&&ao(g)&&u.fromTo(g,{opacity:1},{opacity:0,duration:s,ease:r,delay:M},0),xi.set(d,u),f++}return u}function lo(e){return e.dataset?.flipId}function co(e){const t={};for(const n of Object.keys(e))t[n]=n==="opacity"||n.startsWith("scale")?1:0;return t}function au(e,t={}){const n=new Set((t.type??"chars,words,lines").split(",").map(p=>p.trim())),i={chars:t.charsClass??"char",words:t.wordsClass??"word",lines:t.linesClass??"line"},s=t.aria!==!1,r=e.map(p=>({element:p,html:p.innerHTML,ariaLabel:p.getAttribute("aria-label")}));let o={chars:[],words:[],lines:[],masks:[]},a,l,c=!1;const h=()=>{for(const{element:p,html:g,ariaLabel:y}of r)p.innerHTML=g,y===null?p.removeAttribute("aria-label"):p.setAttribute("aria-label",y)},u=()=>{a&&(a.revert?a.revert():a.kill?.(),a=void 0)},f=()=>{const p={chars:[],words:[],lines:[],masks:[]};for(const{element:g}of r){const y=(g.textContent??"").replace(/\s+/g," ").trim(),w=lu(g,i.words),v=n.has("chars")?w.flatMap(E=>cu(E,i.chars)):[],M=n.has("lines")?uu(g,w,i.lines):[];if(s){!g.hasAttribute("aria-label")&&y&&g.setAttribute("aria-label",y);for(const E of w)E.setAttribute("aria-hidden","true")}if(n.has("words"))p.words.push(...w);else for(const E of w)E.removeAttribute("class");p.chars.push(...v),p.lines.push(...M);const S=t.mask==="lines"?M:t.mask==="words"?w:t.mask==="chars"?v:[];for(const E of S)p.masks.push(fu(E,`${i[t.mask]}-mask`))}o=p},d={elements:e,get chars(){return o.chars},get words(){return o.words},get lines(){return o.lines},get masks(){return o.masks},split(){c||(u(),h(),f(),a=t.onSplit?.(d))},revert(){c=!0,l?.disconnect(),u(),h()}};f(),a=t.onSplit?.(d),t.autoSplit&&m();function m(){const p=new Map;let g=!1;const y=()=>{if(g)return;g=!0;const v=()=>{g=!1,d.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(v):setTimeout(v,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(v=>{let M=!1;for(const S of v){const E=Math.round(S.contentRect.width),k=p.get(S.target);p.set(S.target,E),k!==void 0&&k!==E&&(M=!0)}M&&y()});for(const v of e)l.observe(v)}const w=e[0]?.ownerDocument?.fonts;w&&w.status!=="loaded"&&w.ready.then(()=>y())}return d}function lu(e,t){const n=e.ownerDocument,i=[],s=n.createTreeWalker(e,4),r=[];for(let o=s.nextNode();o;o=s.nextNode())r.push(o);for(const o of r){const a=o.data.match(/\s+|\S+/g)??[];if(a.length===0)continue;const l=n.createDocumentFragment();for(const c of a){if(/^\s/.test(c)){l.appendChild(n.createTextNode(c));continue}const h=n.createElement("span");h.className=t,h.style.display="inline-block",h.textContent=c,l.appendChild(h),i.push(h)}o.replaceWith(l)}return i}function cu(e,t){const n=e.ownerDocument,i=hu(e.textContent??"").map(s=>{const r=n.createElement("span");return r.className=t,r.style.display="inline-block",r.textContent=s,r});return e.replaceChildren(...i),i}function hu(e){const t=Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),n=>n.segment):Array.from(e)}function uu(e,t,n){const i=e.ownerDocument,s=new Map(t.map(m=>[m,m.getBoundingClientRect()])),r=[],o=m=>{for(const p of Array.from(m.childNodes))p.nodeType===3||s.has(p)||p.tagName==="BR"?r.push(p):o(p)};o(e);const a=[];let l=null,c=0,h=0,u=!1,f=[];const d=()=>{l=i.createElement("span"),l.className=n,l.style.display="block",a.push(l),f=[]};for(const m of r){if(m.tagName==="BR"){u=!0;continue}const p=s.get(m);if(p&&(!l||u||p.top>c+h)&&(d(),c=p.top,h=p.height/2,u=!1),!l)continue;const g=[];for(let v=m.parentNode;v&&v!==e;v=v.parentNode)g.unshift(v);let y=0;for(;y<f.length&&y<g.length&&f[y].original===g[y];)y++;f.length=y;let w=y===0?l:f[y-1].clone;for(const v of g.slice(y)){const M=v.cloneNode(!1);w.appendChild(M),f.push({original:v,clone:M}),w=M}w.appendChild(m)}return e.replaceChildren(...a),a}function fu(e,t){const n=e.ownerDocument.createElement("span");return n.className=t,n.style.display=e.style.display==="block"?"block":"inline-block",n.style.overflow="clip",n.style.paddingBottom="0.12em",n.style.marginBottom="-0.12em",e.replaceWith(n),n.appendChild(e),n}const ho={top:0,left:0,start:0,center:.5,centre:.5,middle:.5,bottom:1,right:1,end:1};function _i(e){const t=e.trim().toLowerCase();if(t in ho)return ho[t];if(t.endsWith("%")){const n=Number.parseFloat(t.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function Ii(e){if(typeof e=="number")return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:e};let t=0;const i=e.replace(/([+-])=\s*(-?[\d.]+)/g,(o,a,l)=>(t+=(a==="-"?-1:1)*Number.parseFloat(l),"")).trim().split(/\s+/).filter(Boolean);if(i.length===1&&/^-?[\d.]+$/.test(i[0]))return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:Number.parseFloat(i[0])+t};const s=i[0]!==void 0?_i(i[0]):void 0,r=i[1]!==void 0?_i(i[1]):void 0;return{elementFraction:s??0,viewportFraction:r??0,offsetPx:t}}function jt(e,t,n){const i=Ii(n),s=i.absolutePx!==void 0?e.top+i.absolutePx:e.top+e.height*i.elementFraction,r=t*i.viewportFraction;return s-r+i.offsetPx}function du(e,t,n,i){const s=jt(e,t,n),o=jt(e,t,i)-s;return o<=0?s<=0?1:0:Ci(-s/o)}function Ci(e){return e<0?0:e>1?1:e===0?0:e}function uo(e,t,n,i){if(n<=0)return t;const s=1-Math.exp(-(i/1e3)/n);return e+(t-e)*s}function Hi(e,t,n,i,s){const r=h=>jt({top:e+s(h),bottom:e+s(h)+t,height:t},n,i),o=r(0),a=r(1);if(Math.sign(o)===Math.sign(a)||o===0||a===0)return o===0?0:a===0?1:Math.abs(o)<Math.abs(a)?0:1;let l=0,c=1;for(let h=0;h<40;h++){const u=(l+c)/2;Math.sign(r(u))===Math.sign(o)?l=u:c=u}return(l+c)/2}class fo{timeline;trigger;behaviour;options;observer=null;hasPlayed=!1;running=!1;constructor(t){this.timeline=t.timeline,this.trigger=t.trigger,this.behaviour=t.behaviour??"once",this.options=t}start(){if(!this.running){if(this.running=!0,typeof IntersectionObserver>"u"){this.enter();return}this.observer=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting?this.enter():this.leave()},{threshold:this.options.threshold??.15,rootMargin:this.options.rootMargin,root:this.options.root??null}),this.observer.observe(this.trigger)}}stop(){this.running=!1,this.observer?.disconnect(),this.observer=null}destroy(){this.stop()}reset(){this.hasPlayed=!1,this.timeline.stop()}enter(){this.options.onEnter?.(),!(this.behaviour==="once"&&this.hasPlayed)&&(this.hasPlayed=!0,this.behaviour!=="once"&&this.timeline.seek(0),this.timeline.play())}leave(){this.options.onLeave?.(),this.behaviour==="reset"&&this.timeline.stop()}}function pu(e){const t=new fo(e);return t.start(),t}class po{element;spacer;saved;axis;spacing;constructor(t,n={}){this.element=t,this.axis=n.axis??"y",this.spacing=n.spacing??!0;const i=t.ownerDocument;this.spacer=i.createElement("div"),this.spacer.className="pin-spacer",this.saved={position:t.style.position,top:t.style.top,left:t.style.left},this.axis==="x"&&(this.spacer.style.flexShrink="0"),t.replaceWith(this.spacer),this.spacer.appendChild(t)}release(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left}apply(t,n){const i=Math.max(0,n);this.element.style.position="sticky",this.axis==="x"?(this.spacer.style.width=`${this.element.offsetWidth+i}px`,this.spacer.style.marginRight=this.spacing?"":`-${i}px`,this.element.style.left=`${t}px`):(this.spacer.style.height=`${this.element.offsetHeight+i}px`,this.spacer.style.marginBottom=this.spacing?"":`-${i}px`,this.element.style.top=`${t}px`)}destroy(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left,this.spacer.parentNode&&this.spacer.replaceWith(this.element)}}const mu=.15;function mo(e){return typeof e=="object"&&!Array.isArray(e)?e:{snapTo:e}}function go(e,t,n){const i=cn(e+t*mu);if(typeof n=="function")return cn(n(i));if(typeof n=="number")return n<=0?e:cn(Math.round(i/n)*n);if(n.length===0)return e;let s=n[0];for(const r of n)Math.abs(r-i)<Math.abs(s-i)&&(s=r);return cn(s)}function yo(e,t,n){const i=e.duration??{min:.2,max:.8};if(typeof i=="number")return i;const s=Math.min(1,Math.abs(t)/Math.max(1,n));return i.min+(i.max-i.min)*s}class bo{rafId=null;cancelEvents=["wheel","touchstart","pointerdown","keydown"];onInterrupt=()=>this.cancel();write;eventTarget;constructor(t,n){this.write=t,this.eventTarget=n}get active(){return this.rafId!==null}animate(t,n,i,s=ue,r){if(this.cancel(),typeof requestAnimationFrame>"u"||i<=0){this.write(n),r?.();return}for(const l of this.cancelEvents)this.eventTarget?.addEventListener(l,this.onInterrupt,{passive:!0});let o=null;const a=l=>{o??=l;const c=Math.min(1,(l-o)/(i*1e3));this.write(t+(n-t)*s(c)),c<1?this.rafId=requestAnimationFrame(a):(this.rafId=null,this.detach(),r?.())};this.rafId=requestAnimationFrame(a)}cancel(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.detach()}detach(){for(const t of this.cancelEvents)this.eventTarget?.removeEventListener(t,this.onInterrupt)}}function cn(e){return Math.max(0,Math.min(1,e))}class wo{options;scroller;nodes=[];scrollerStart;scrollerEnd;start;end;constructor(t,n,i){this.options=i===!0?{}:i,this.scroller=n;const{startColor:s="#3ecf7a",endColor:r="#ff5a5a",id:o}=this.options,a=o?`${o} `:"",l=(c,h,u)=>{const f=t.createElement("div");return f.textContent=`${a}${c}`,f.setAttribute("aria-hidden","true"),f.className="scroll-marker",Object.assign(f.style,{position:u?"fixed":"absolute",right:`${this.options.indent??0}px`,zIndex:"2147483646",pointerEvents:"none",borderTop:`1px solid ${h}`,color:h,font:`${this.options.fontSize??"11px"} ui-monospace, monospace`,padding:"2px 6px",whiteSpace:"nowrap",background:"rgba(0, 0, 0, 0.35)"}),(n??t.body).appendChild(f),this.nodes.push(f),f};this.scrollerStart=l("scroller-start",s,!n),this.scrollerEnd=l("scroller-end",r,!n),this.start=l("start",s,!1),this.end=l("end",r,!1),n&&getComputedStyle(n).position==="static"&&(n.style.position="relative")}place(t,n){this.start.style.top=`${t.startPage}px`,this.end.style.top=`${t.endPage}px`;const i=this.scroller?n:0;this.scrollerStart.style.top=`${i+t.startViewport}px`,this.scrollerEnd.style.top=`${i+t.endViewport}px`}follow(t,n){this.scroller&&this.place(t,n)}destroy(){for(const t of this.nodes.splice(0))t.remove()}}const gu=120,Gt=[],Jt=new Set;let $i=!1;const yu=()=>{$i||Jt.size===0||($i=!0,queueMicrotask(()=>{$i=!1;for(const e of Jt)e.afterRefresh()}))},vo=()=>{for(const e of Jt)e.beforeRefresh();for(const e of Gt)e.refresh();for(const e of Jt)e.afterRefresh()};let Zt={width:0,height:0};const ko=()=>{const e=window.innerWidth,t=window.innerHeight,n=e===Zt.width&&t!==Zt.height,i=Math.abs(t-Zt.height)<Zt.height*.25,s=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&i&&s||(Zt={width:e,height:t},vo())};class Ee{timeline;options;running=!1;pin=null;startPx=0;endPx=0;targetProgress=0;displayProgress=0;zone="before";measured=!1;lastScroll=null;lastScrollTime=0;velocityPxPerSecond=0;idleTimer=null;lastEmitted=null;rafId=null;lastFrameTime=null;onScroll=()=>this.update();releaseVelocity=0;snapper;snapTimer=null;markers=null;markerGeometry=null;constructor(t){this.timeline=t.timeline,this.options=t,this.snapper=new bo(n=>this.scrollTo(n),typeof window<"u"?window:null)}start(){if(this.running)return;this.running=!0,this.timeline?.pause();const t=this.options.pin===!0?this.options.trigger:this.options.pin||null;t&&!this.options.container&&(this.pin=new po(t,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new wo(document,this.options.scroller??null,this.options.markers)),this.scrollTarget()?.addEventListener("scroll",this.onScroll,{passive:!0}),Gt.length===0&&typeof window<"u"&&(Zt={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",ko,{passive:!0})),Gt.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Gt.splice(Gt.indexOf(this),1),Gt.length===0&&typeof window<"u"&&window.removeEventListener("resize",ko),this.stopSmoothing(),this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=null,this.snapTimer!==null&&clearTimeout(this.snapTimer),this.snapTimer=null,this.snapper.cancel())}destroy(){this.stop(),this.pin?.destroy(),this.pin=null,this.markers?.destroy(),this.markers=null}get startOffset(){return this.startPx}get endOffset(){return this.endPx}static refreshAll(){vo()}static onRefresh(t){return Jt.add(t),()=>Jt.delete(t)}get progress(){return this.targetProgress}get velocity(){return this.velocityPxPerSecond}refresh(){if(!this.running)return;this.measured&&this.options.onRefresh?.();const t=this.scrollPosition();this.pin?.release();const n=this.triggerRect();if(n&&this.options.container)this.measureInContainer(this.options.container);else if(n){const i=this.viewportHeight();if(this.startPx=t+jt(n,i,Ae(this.options.start)??"top bottom"),this.endPx=this.resolveEnd(n,i,t),this.pin){const s=this.relativeRect(this.pin.element.getBoundingClientRect());this.pin.apply(s.top-(this.startPx-t),this.endPx-this.startPx)}this.markerGeometry=this.markers?this.markersFor(i):null}this.markers&&this.markerGeometry&&this.markers.place(this.markerGeometry,t),this.lastScroll=null,this.updateFrom(t,!this.measured),this.measured=!0,yu()}sample(){this.refresh()}update(t){this.running&&this.updateFrom(t??this.scrollPosition(),!1)}updateFrom(t,n){this.trackVelocity(t),this.markers&&this.markerGeometry&&this.markers.follow(this.markerGeometry,t);const i=this.endPx-this.startPx,s=this.zone;this.targetProgress=i>0?Ci((t-this.startPx)/i):t>=this.startPx?1:0,this.zone=i>0?t<=this.startPx?"before":t>=this.endPx?"after":"active":t>=this.startPx?"after":"before",this.fireBoundaryCallbacks(s,this.zone),n||this.smoothing()<=0?(this.displayProgress=this.targetProgress,this.applyProgress()):(this.emitUpdate(),this.startSmoothing())}smoothing(){const t=this.options.scrub;return typeof t=="number"?Math.max(0,t):0}resolveEnd(t,n,i){const s=Ae(this.options.end)??"bottom top",r=typeof s=="string"?s.trim().match(/^\+=\s*(-?[\d.]+)\s*(%|px)?$/):null;if(r){const o=Number.parseFloat(r[1]);return this.startPx+(r[2]==="%"?n*o/100:o)}return i+jt(t,n,s)}applyProgress(){const t=this.timeline?.duration??0;this.timeline&&t>0&&this.timeline.seek(this.displayProgress*t),this.emitUpdate()}emitUpdate(){if(!this.options.onUpdate)return;const t=[this.displayProgress,this.velocityPxPerSecond];this.lastEmitted&&this.lastEmitted[0]===t[0]&&this.lastEmitted[1]===t[1]||(this.lastEmitted=t,this.options.onUpdate(t[0],t[1]))}trackVelocity(t){const n=typeof performance<"u"?performance.now():Date.now();this.lastScroll!==null&&n>this.lastScrollTime&&t!==this.lastScroll&&(this.velocityPxPerSecond=(t-this.lastScroll)/(n-this.lastScrollTime)*1e3),(this.lastScroll===null||t!==this.lastScroll)&&(this.lastScroll=t,this.lastScrollTime=n),!(this.velocityPxPerSecond===0||typeof setTimeout>"u")&&(this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this.idleTimer=null,this.releaseVelocity=this.velocityPxPerSecond,this.velocityPxPerSecond=0,this.emitUpdate(),this.scheduleSnap()},gu))}fireBoundaryCallbacks(t,n){if(t===n)return;const{onEnter:i,onLeave:s,onEnterBack:r,onLeaveBack:o}=this.options;t==="before"?(i?.(),n==="after"&&s?.()):t==="after"?(r?.(),n==="before"&&o?.()):n==="after"?s?.():o?.()}scheduleSnap(){const t=this.options.snap;if(t===void 0||this.snapper.active)return;const n=mo(t),i=()=>{this.snapTimer=null;const s=this.endPx-this.startPx,r=this.scrollPosition();if(!this.running||s<=0||r<=this.startPx||r>=this.endPx)return;const o=(r-this.startPx)/s,a=this.startPx+go(o,this.releaseVelocity/s,n.snapTo)*s;Math.abs(a-r)<1||this.snapper.animate(r,a,yo(n,a-r,this.viewportHeight()),n.ease)};n.delay?this.snapTimer=setTimeout(i,n.delay*1e3):i()}scrollTo(t){const n=this.options.scroller,i=this.options.horizontal?{left:t}:{top:t};n?typeof n.scrollTo=="function"?n.scrollTo({...i,behavior:"instant"}):this.options.horizontal?n.scrollLeft=t:n.scrollTop=t:typeof window<"u"&&window.scrollTo({...i,behavior:"instant"})}measureInContainer(t){const n=this.options.trigger;if(typeof n?.getBoundingClientRect!="function")return;const i=n.getBoundingClientRect(),s=this.options.scroller?.getBoundingClientRect?.().left??0,r=this.options.scroller?this.options.scroller.clientWidth:typeof window<"u"?window.innerWidth:0,o=i.left-s-t.shiftAt(t.progress()),{start:a,end:l}=t.range(),c=d=>a+d*(l-a),h=Hi(o,i.width,r,Ae(this.options.start)??"left right",t.shiftAt);this.startPx=c(h);const u=Ae(this.options.end)??"right left",f=typeof u=="string"?u.trim().match(/^\+=\s*(-?[\d.]+)\s*(px)?$/):null;this.endPx=f?this.startPx+Number.parseFloat(f[1]):c(Hi(o,i.width,r,u,t.shiftAt)),this.markerGeometry=null}markersFor(t){const n=(r,o)=>{const a=Ae(r)??o;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=Ii(a);return t*l.viewportFraction-l.offsetPx},i=n(this.options.start,"top bottom")??0,s=n(this.options.end,"bottom top")??i;return{startViewport:i,endViewport:s,startPage:this.startPx+i,endPage:this.endPx+s}}startSmoothing(){if(this.rafId!==null||typeof requestAnimationFrame>"u")return;const t=n=>{if(this.rafId=null,!this.running)return;const i=this.lastFrameTime===null?16.67:n-this.lastFrameTime;this.lastFrameTime=n,this.displayProgress=uo(this.displayProgress,this.targetProgress,this.smoothing(),i);const s=Math.abs(this.targetProgress-this.displayProgress)<1e-4;s&&(this.displayProgress=this.targetProgress),this.applyProgress(),s?this.lastFrameTime=null:this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}stopSmoothing(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.lastFrameTime=null}scrollTarget(){return this.options.scroller??(typeof window<"u"?window:null)}scrollPosition(){const t=this.options.scroller,n=this.options.horizontal;return t?(n?t.scrollLeft:t.scrollTop)??0:typeof window<"u"?(n?window.scrollX:window.scrollY)??0:0}triggerRect(){const t=this.options.trigger;return typeof t?.getBoundingClientRect!="function"?null:this.relativeRect(t.getBoundingClientRect())}relativeRect(t){const n=this.options.horizontal,i=n?t.left??0:t.top,s=n?t.right??0:t.bottom,r=n?t.width??0:t.height,o=this.options.scroller;if(o&&typeof o.getBoundingClientRect=="function"){const a=o.getBoundingClientRect(),l=n?a.left:a.top;return{top:i-l,bottom:s-l,height:r}}return{top:i,bottom:s,height:r}}viewportHeight(){const t=this.options.scroller,n=this.options.horizontal;return t?n?t.clientWidth:t.clientHeight:typeof window<"u"?n?window.innerWidth:window.innerHeight:0}}function Ae(e){return typeof e=="function"?e():e}function bu(e){const t=new Ee(e);return t.start(),t}const Oi=new Set,wu=16,So=.5,vu=2;class Ri{options;frames;running=!1;reduced=!1;current=0;target=0;written=null;velocityPxPerSecond=0;frameId=null;lastTime=null;journey=null;pausedState=!1;effects=[];onWheel=t=>this.wheel(t);onScroll=()=>this.nativeScroll();onResize=()=>this.refresh();onLoad=()=>this.refresh();stopListening=null;constructor(t={}){this.options=t,this.frames=t.frames??{request:n=>requestAnimationFrame(n),cancel:n=>cancelAnimationFrame(n)}}start(){if(this.running||typeof window>"u")return this;this.running=!0,this.reduced=this.options.reducedMotion??(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),this.current=this.target=this.position();const t=this.options.scroller??window;return t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("scroll",this.onScroll,{passive:!0}),window.addEventListener("resize",this.onResize,{passive:!0}),window.addEventListener("load",this.onLoad),Oi.add(this),this.stopListening=Ee.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const t of Oi)t.refresh()}stop(){if(!this.running)return this;this.running=!1;const t=this.options.scroller??window;return t.removeEventListener("wheel",this.onWheel),t.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("load",this.onLoad),Oi.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const t of this.effects)Li(t.element,t.saved);this.effects=[]}kill(){this.destroy()}get state(){const t=this.limit();return{scroll:this.current,target:this.target,progress:t>0?this.current/t:0,velocity:this.velocityPxPerSecond}}paused(t){return t!==void 0&&(this.pausedState=t,t&&(this.target=this.current,this.journey=null)),this.pausedState}scrollTo(t,n={}){if(!this.running)return;const i=this.clamp(this.resolve(t)+(n.offset??0)),s=Math.abs(i-this.current),r=this.reduced?0:n.duration??Math.min(1.2,Math.max(.4,s/2500));if(r<=0){this.journey=null,this.current=this.target=i,this.write(i),this.applyEffects(0);return}this.target=i,this.journey={from:this.current,to:i,ms:r*1e3,ease:n.ease??ue,elapsed:0},this.requestFrame()}refresh(){if(!this.running)return;this.rest(),this.effects=[];const t=this.options.effects===!0?"[data-speed], [data-lag]":this.options.effects||"";if(t&&!this.reduced){const n=this.options.scroller??document,i=this.position(),s=this.viewportHeight(),r=this.options.scroller?.getBoundingClientRect().top??0;for(const o of n.querySelectorAll(t)){const a=Number.parseFloat(o.dataset.speed??""),l=Number.parseFloat(o.dataset.lag??""),c=o.getBoundingClientRect(),h=c.top-r+i;this.effects.push({element:o,speed:Number.isFinite(a)?a:void 0,lag:Number.isFinite(l)&&l>0?l:void 0,centre:h+c.height/2-s/2,lagged:i,shift:0,saved:o.style.getPropertyValue("translate")})}}this.current=this.target=this.clamp(this.position()),this.applyEffects(0)}rest(){for(const t of this.effects)Li(t.element,t.saved)}wheel(t){if(this.pausedState||this.reduced||(this.options.smooth??.8)<=0||t.ctrlKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||this.nestedScrollerTakes(t))return;const n=t.deltaMode===1?wu:t.deltaMode===2?this.viewportHeight():1,i=t.deltaY*n*(this.options.wheelMultiplier??1),s=this.clamp(this.target+i);s===this.target&&s===this.current||(t.preventDefault(),this.journey=null,this.target=s,this.requestFrame())}nativeScroll(){const t=this.position();this.written!==null&&Math.abs(t-this.written)<=vu||(this.written=null,this.journey=null,this.cancelFrame(),this.current=this.target=t,this.requestFrame())}nestedScrollerTakes(t){const n=this.options.scroller??document.documentElement;for(let i=t.target;i&&i!==n&&i!==document.body;i=i.parentElement){if(i.hasAttribute?.("data-smooth-ignore"))return!0;const s=getComputedStyle(i);if(!/(auto|scroll)/.test(s.overflowY)||i.scrollHeight<=i.clientHeight)continue;if(t.deltaY<0?i.scrollTop>0:i.scrollTop+i.clientHeight<i.scrollHeight-1)return!0}return!1}requestFrame(){this.frameId!==null||!this.running||(this.frameId=this.frames.request(t=>this.frame(t)))}cancelFrame(){this.frameId!==null&&this.frames.cancel(this.frameId),this.frameId=null,this.lastTime=null}frame(t){this.frameId=null;const n=this.lastTime===null?1e3/60:Math.min(100,t-this.lastTime);this.lastTime=t;const i=this.current;if(this.journey){const r=this.journey;r.elapsed+=n;const o=Math.min(1,r.elapsed/r.ms);this.current=r.from+(r.to-r.from)*r.ease(o),o>=1&&(this.journey=null)}else if(this.current!==this.target){const r=(this.options.smooth??.8)*1e3/3;this.current+=(this.target-this.current)*(1-Math.exp(-n/r)),Math.abs(this.target-this.current)<So&&(this.current=this.target)}this.current!==i&&this.write(this.current),this.velocityPxPerSecond=n>0?(this.current-i)*1e3/n:0;const s=this.applyEffects(n);this.current!==i&&this.options.onUpdate?.(this.state),this.journey||this.current!==this.target||s?this.requestFrame():(this.lastTime=null,this.velocityPxPerSecond=0)}applyEffects(t){let n=!1;const i=this.current;for(const s of this.effects){let r=0;if(s.speed!==void 0&&(r+=(i-s.centre)*(1-s.speed)),s.lag!==void 0){const o=s.lag*1e3/3;s.lagged=t===0?i:s.lagged+(i-s.lagged)*(1-Math.exp(-t/o)),Math.abs(i-s.lagged)<So?s.lagged=i:n=!0,r+=i-s.lagged}Li(s.element,r===0?s.saved:`0 ${ku(r)}px`),s.shift=r}return n}write(t){const n=Math.round(t);this.written=n;const i=this.options.scroller;i?i.scrollTop=n:window.scrollTo({top:n,behavior:"instant"})}position(){const t=this.options.scroller;return t?t.scrollTop:window.scrollY}viewportHeight(){const t=this.options.scroller;return t?t.clientHeight:window.innerHeight}limit(){const t=this.options.scroller??document.documentElement;return Math.max(0,t.scrollHeight-this.viewportHeight())}clamp(t){return Math.max(0,Math.min(this.limit(),t))}resolve(t){if(typeof t=="number")return t;const n=this.options.scroller??document,i=typeof t=="string"?n.querySelector(t):t;if(!i)return this.current;const s=this.options.scroller?.getBoundingClientRect().top??0,r=this.effects.find(o=>o.element===i)?.shift??0;return i.getBoundingClientRect().top-s+this.position()-r}}function Li(e,t){t?e.style.setProperty("translate",t):e.style.removeProperty("translate")}function ku(e){return Math.round(e*100)/100}function Su(e,t){switch(t){case"play":if(e.progress()>=1)break;e.reversed()?e.reverse():e.play();break;case"reverse":if(e.progress()<=0)break;e.reversed()?e.play():e.reverse();break;case"pause":e.pause();break;case"resume":e.resume();break;case"restart":e.restart();break;case"reset":e.pause(),e.progress(0);break;case"complete":e.pause(),e.progress(1);break}}function Fi(e,t,n,i,s=()=>{}){const r=d=>typeof d=="string"?e.query(d)??void 0:d,o=r(t.trigger)??i;if(!o){s(`gsap-compat: scrollTrigger has no trigger element${typeof t.trigger=="string"?` for "${t.trigger}"`:""}`);return}const a=t.scrub===void 0||t.scrub===!1?!1:t.scrub,l=(t.toggleActions??"play none none none").trim().split(/\s+/);let c=0,h;const u=(d,m)=>()=>{m?.(),n&&!a&&Su(n,l[d]??"none"),t.once&&d===0&&queueMicrotask(()=>h.destroy())},f=t.containerAnimation?Eu(e,t.containerAnimation,o,s):void 0;return h=new Ee({trigger:o,start:t.start,end:t.end,scrub:a===!1?void 0:a,pin:t.pin===!0?!0:r(t.pin),scroller:r(t.scroller),horizontal:t.horizontal,pinSpacing:t.pinSpacing,onRefresh:t.invalidateOnRefresh&&n?.invalidate?()=>n.invalidate():void 0,snap:t.snap===void 0?void 0:Mu(t.snap,n),markers:t.markers,container:f,onUpdate:(d,m)=>{if(n&&a!==!1&&n.progress(d),t.onUpdate){const p=d<c||m<0?-1:1;t.onUpdate({progress:d,velocity:m,direction:p})}c=d},onEnter:u(0,t.onEnter),onLeave:u(1,t.onLeave),onEnterBack:u(2,t.onEnterBack),onLeaveBack:u(3,t.onLeaveBack)}),n&&a===!1&&n.progress(0),h.start(),e.own(h)}function Mu(e,t){const n=s=>s==="labels"?r=>Tu(r,t?.labelProgresses?.()??[]):s;if(typeof e!="object"||Array.isArray(e))return n(e);const i=e.ease?Se(e.ease):void 0;return{snapTo:n(e.snapTo),duration:e.duration,delay:e.delay,ease:i?i.fn??G(i.easing):void 0}}function Tu(e,t){return t.reduce((n,i)=>Math.abs(i-e)<Math.abs(n-e)?i:n,t[0]??e)}function Eu(e,t,n,i){const s=()=>t.timeline.getTracks({property:"x"}).map(r=>r.target).filter(r=>{const o=e.elementFor(r);return!!o&&o!==n&&o.contains(n)});return s().length===0&&i("gsap-compat: containerAnimation does not move an ancestor of the trigger along x"),{range:()=>{const r=t.scrollTrigger;return r||i("gsap-compat: containerAnimation needs its own scrollTrigger (created before this one)"),{start:r?.startOffset??0,end:r?.endOffset??0}},progress:()=>t.progress(),shiftAt:r=>{const o=t.timeline.getStateAtTime(r*t.timeline.duration);let a=0;for(const l of s()){const c=o.values.get(l)?.get("x");typeof c=="number"&&(a+=c)}return a}}}class Mo{conditions={};scope;host;items=[];snapshots=new Map;constructor(t,n){this.host=t,this.scope=n}add(t){const n=this.host.collector;this.host.setCollector(this);try{const i=t();return typeof i=="function"&&this.items.push({revert:i}),i}finally{this.host.setCollector(n)}}track(t){this.items.push(t)}touch(t,n){this.snapshots.has(t)||this.snapshots.set(t,{name:n,style:t.getAttribute("style"),d:t.getAttribute("d")})}revert(){for(const t of this.items.splice(0).reverse())t.revert?t.revert():t.kill?t.kill():t.destroy?.();for(const[t,{name:n,style:i,d:s}]of this.snapshots)i===null?t.removeAttribute("style"):t.setAttribute("style",i),s!==null&&t.setAttribute("d",s),this.host.forget(n);this.snapshots.clear()}kill(){this.revert()}}class Au{host;scope;entries=[];listeners=[];scheduled=!1;constructor(t,n){this.host=t,this.scope=n}add(t,n){const i={conditions:t,setup:n,queries:new Map},s=typeof t=="string"?{matches:t}:t;if(typeof window<"u"&&typeof window.matchMedia=="function")for(const[r,o]of Object.entries(s)){const a=window.matchMedia(o);i.queries.set(r,a);const l=()=>this.scheduleUpdate();a.addEventListener("change",l),this.listeners.push(()=>a.removeEventListener("change",l))}return this.entries.push(i),this.update(i),this}revert(){for(const t of this.listeners.splice(0))t();for(const t of this.entries.splice(0))t.context?.revert()}kill(){this.revert()}scheduleUpdate(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1;for(const t of this.entries)this.update(t)}))}update(t){const n={};for(const[o,a]of t.queries)n[o]=a.matches;const i=Object.values(n).some(Boolean),s=i?JSON.stringify(n):void 0;if(s===t.key||(t.context?.revert(),t.context=void 0,t.key=s,!i))return;const r=new Mo(this.host,this.scope);r.conditions=n,r.add(()=>t.setup(r)),t.context=r}}class xu{frames;canvas;context;options;images;ready;current=0;drawn=-1;loadedCount=0;inFlight=0;destroyed=!1;onResize=()=>this.resize();constructor(t,n){this.canvas=t,this.context=t.getContext("2d"),this.options=n,this.frames=Math.max(1,Math.floor(n.frames)),this.images=new Array(this.frames),this.ready=new Array(this.frames).fill(!1),typeof window<"u"&&window.addEventListener("resize",this.onResize,{passive:!0}),this.resize(),this.pump()}get frame(){return this.current}set frame(t){this.current=Math.max(0,Math.min(this.frames-1,t)),this.draw()}get loaded(){return this.loadedCount}destroy(){this.destroyed=!0,typeof window<"u"&&window.removeEventListener("resize",this.onResize);for(const t of this.images)t&&(t.src="")}resize(){const t=typeof window<"u"?Math.min(window.devicePixelRatio||1,2):1,n=Math.round(this.canvas.clientWidth*t),i=Math.round(this.canvas.clientHeight*t);n>0&&i>0&&(this.canvas.width!==n||this.canvas.height!==i)&&(this.canvas.width=n,this.canvas.height=i),this.drawn=-1,this.draw()}draw(){const t=Math.round(this.current),n=this.nearestReady(t);if(n===-1||n===this.drawn||!this.context)return;const i=this.images[n],{width:s,height:r}=this.canvas,o=(this.options.fit??"cover")==="cover"?Math.max(s/i.naturalWidth,r/i.naturalHeight):Math.min(s/i.naturalWidth,r/i.naturalHeight),a=i.naturalWidth*o,l=i.naturalHeight*o;this.context.clearRect(0,0,s,r),this.context.drawImage(i,(s-a)/2,(r-l)/2,a,l),this.drawn=n,this.pump()}nearestReady(t){for(let n=0;n<this.frames;n++){if(t-n>=0&&this.ready[t-n])return t-n;if(t+n<this.frames&&this.ready[t+n])return t+n}return-1}pump(){const t=this.options.concurrency??6,n=Math.round(this.current);for(let i=0;i<this.frames&&this.inFlight<t;i++)for(const s of i===0?[n]:[n+i,n-i])s<0||s>=this.frames||this.images[s]||this.inFlight>=t||this.load(s)}load(t){const n=new Image;n.decoding="async",this.images[t]=n,this.inFlight++;const i=s=>{if(!this.destroyed){if(this.inFlight--,s){this.ready[t]=!0,this.loadedCount++,this.options.onProgress?.(this.loadedCount,this.frames);const r=Math.round(this.current);(Math.abs(t-r)<Math.abs(this.drawn-r)||this.drawn===-1)&&(this.drawn=-1,this.draw())}this.pump()}};n.onload=()=>i(!0),n.onerror=()=>i(!1),n.src=this.options.url(t)}}const Pu={opacity:0,y:-16},_u={opacity:0,y:16};async function Iu(e,t,n,i){const s=t.collector?.scope??t.root,r=s.ownerDocument??s,o=()=>i.shared?[...s.querySelectorAll(i.shared)]:[];if(i.native&&typeof r.startViewTransition=="function")return Cu(r,i,o);const a=i.duration??.35,l=i.ease??"power2.inOut",c=g=>new Promise(y=>{g(y)||y()}),h=o(),u=h.length?Ai(t,h):void 0,f=i.from!==void 0?To(t,i.from,i.shared):[];if(f.length&&i.leave!==!1){const g=i.leave??Pu;await c(y=>e.to(f,{...g,duration:a,ease:l,onComplete:y}))}await i.update();const d=[],m=typeof i.to=="function"?i.to():i.to,p=m!==void 0?To(t,m,i.shared):[];if(p.length&&i.enter!==!1){const g=i.enter??_u;d.push(c(y=>e.fromTo(p,g,{...co(g),duration:a,ease:l,onComplete:y})))}if(u){const g=o().filter(y=>!h.includes(y));g.length&&d.push(c(y=>Pi(t,n,u,{targets:g,duration:a*1.4,ease:l,enter:!1,onComplete:y})))}await Promise.all(d)}function To(e,t,n){const i=e.resolveTargets(t).map(s=>e.elementFor(s)).filter(s=>!!s);return n?i.flatMap(s=>!s.querySelector(n)&&!s.matches(n)?[s]:[...s.children].filter(r=>!r.matches(n)&&!r.querySelector(n))):i}async function Cu(e,t,n){const i=(a,l)=>{const c=a.dataset?.flipId;c&&a.style.setProperty("view-transition-name",l?`tf-${c.replace(/[^\w-]/g,"-")}`:"")},s=n();s.forEach(a=>i(a,!0));let r=[];await e.startViewTransition(async()=>{s.forEach(a=>i(a,!1)),await t.update(),r=n(),r.forEach(a=>i(a,!0))}).finished,r.forEach(a=>i(a,!1))}const Eo={create:(e,t)=>yi(e,Er(t))},Ao={create:(e,t)=>yi(e,{fn:Ar(t)})},xo={create:(e,t)=>yi(e,{fn:xr(t)})},Hu=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),Po=.5,$u="power1.inOut";function Ou(e){return e.keyframes!==void 0&&e.keyframes!==null}function Ru(e){const t=e.keyframes,n={};for(const[c,h]of Object.entries(e))Hu.has(c)||(n[c]=h);if(Array.isArray(t))return t.map(c=>({...n,...c,duration:c.duration??e.duration??Po}));const i=Object.entries(t),s=e.duration??Po,r=t.easeEach??e.easeEach??$u;if(i.length>0&&i.every(([c])=>/^\s*-?\d+(\.\d+)?\s*%\s*$/.test(c)||c==="easeEach")){const c=i.filter(([f])=>f!=="easeEach").map(([f,d])=>({at:Number.parseFloat(f)/100,step:d})).sort((f,d)=>f.at-d.at),h=[];let u=0;for(const{at:f,step:d}of c){const m=Math.max(0,f-u);h.push({...n,ease:r,...d,duration:m*s}),u=f}return h}const o=i.filter(([c,h])=>c!=="easeEach"&&Array.isArray(h)),a=Math.max(0,...o.map(([,c])=>c.length)),l=[];for(let c=0;c<a;c++){const h={...n,ease:r,duration:s/a};for(const[u,f]of o)c<f.length&&(h[u]=f[c]);l.push(h)}return l}function _o(e,t,n,i={}){const s=t.collector?.scope??t.root,r=typeof i.scroller=="string"?s.querySelector(i.scroller):i.scroller??null,o={x:r?r.scrollLeft:window.scrollX,y:r?r.scrollTop:window.scrollY},a={x:r?r.scrollWidth-r.clientWidth:document.documentElement.scrollWidth-window.innerWidth,y:r?r.scrollHeight-r.clientHeight:document.documentElement.scrollHeight-window.innerHeight},l=(w,v)=>{if(v===void 0)return o[w];if(typeof v=="number")return v;if(v==="max")return a[w];const M=typeof v=="string"?s.querySelector(v):v;if(!M)return o[w];const S=M.getBoundingClientRect(),E=r?.getBoundingClientRect(),k=(w==="x"?i.offsetX:i.offsetY)??i.offset??0;return w==="x"?S.left-(E?.left??0)+o.x-k:S.top-(E?.top??0)+o.y-k},c=typeof n=="object"&&n!==null&&!("nodeType"in n)?{x:l("x",n.x),y:l("y",n.y)}:{x:o.x,y:l("y",n)},h={x:Math.max(0,Math.min(a.x,c.x)),y:Math.max(0,Math.min(a.y,c.y))},u={...o},f=()=>{r?(r.scrollLeft=u.x,r.scrollTop=u.y):window.scrollTo({left:u.x,top:u.y,behavior:"instant"})},d=["wheel","touchstart","keydown"],m=r??window,p=()=>{y.kill(),g()},g=()=>{for(const w of d)m.removeEventListener(w,p)},y=e.to(u,{x:h.x,y:h.y,duration:i.duration??1,ease:i.ease??"power2.inOut",onStart:i.onStart,onUpdate:()=>{f(),i.onUpdate?.()},onComplete:()=>{g(),i.onComplete?.()}});if(i.autoKill!==!1)for(const w of d)m.addEventListener(w,p,{passive:!0});return y}function Lu(e,t,n){const i=e.collector?.scope??e.root,s=typeof t=="string"?[...i.querySelectorAll(t)]:"nodeType"in t?[t]:Array.from(t),{interval:r=.1,batchMax:o,onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h,...u}=n,f={onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h},d={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},m={},p=y=>{m[y]!==void 0&&clearTimeout(m[y]),m[y]=void 0;const w=d[y].splice(0);w.length>0&&f[y]?.(w)},g=(y,w)=>{if(f[y]){if(d[y].push(w),o!==void 0&&d[y].length>=o)return p(y);m[y]===void 0&&(m[y]=setTimeout(()=>p(y),r*1e3))}};return s.map(y=>Fi(e,{...u,trigger:y,onEnter:()=>g("onEnter",y),onLeave:()=>g("onLeave",y),onEnterBack:()=>g("onEnterBack",y),onLeaveBack:()=>g("onLeaveBack",y)})).filter(y=>y!==void 0)}class ct{compat;stage;options;autoplayPending;started=!1;killed=!1;recipe=[];firstElement;scrollDriver;events=[];ranges=[];playhead={time:0,iteration:0,direction:"forward",fresh:!0};waitingToWrap=!1;finishedThisFrame=!1;backwards=!1;constructor(t,n={}){this.stage=t;const i={...n,onWarning:n.onWarning??t.onWarning};if(this.options=i,this.compat=new Pt({...i,startValue:(s,r)=>{const o=t.objectFor(s);if(o)return Bu(o[r]);const a=t.appliedValue(s,r);if(a!==void 0)return a;if(r==="d")return Qr(t.elementFor(s))??void 0;if(r==="text")return t.elementFor(s)?.textContent??void 0;if(r==="strokeDasharray"||r==="strokeDashoffset"){const l=Oo(t.elementFor(s));if(l!==void 0)return r==="strokeDasharray"?[l,l]:0}},startVelocity:(s,r)=>t.velocityOf(s,r),layoutColumns:s=>$o(s.map(r=>t.elementFor(r))),random:()=>t.utils.random(0,1)}),this.compat.timeline.onComplete=()=>{this.finishedThisFrame=!0},t.collector?.track(this),t.liveTimelines.add(this),this.autoplayPending=!i.paused&&!i.scrollTrigger,i.scrollTrigger){const s=i.scrollTrigger;queueMicrotask(()=>{this.killed||(this.scrollDriver=Fi(t,s,this,this.firstElement,r=>i.onWarning?.(r)))})}this.autoplayPending&&queueMicrotask(()=>{this.autoplayPending&&this.play()})}get timeline(){return this.compat.timeline}get scrollTrigger(){return this.scrollDriver}to(t,n,i){return Ou(n)?this.record(()=>this.keyframed(t,n,i)):this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.to(r,s,o)))}from(t,n,i){return this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.from(r,s,o)))}fromTo(t,n,i,s){return this.record(()=>this.tween(t,[n,i],s,([r,o],a,l)=>this.compat.fromTo(a,r,o,l)))}set(t,n,i){return this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.set(r,s,o)))}addLabel(t,n){return this.record(()=>this.compat.addLabel(t,n))}add(t,n){return this.record(()=>{t.autoplayPending=!1,t.timeline.stop(),t.stage.deactivate(t.timeline),this.compat.add(t.compat,n)})}invalidate(){const t=this.compat.progress();this.compat.progress(0),this.stage.render(this.timeline),this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();return this.syncDuration(),this.compat.progress(t),this.stage.render(this.timeline),this}call(t,n=[],i){return this.record(()=>{const s=this.compat.addEvent(i);this.events.push({time:s,run:()=>t(...n)})})}addPause(t,n,i=[]){return this.record(()=>{const s=this.compat.addEvent(t);this.events.push({time:s,pause:!0,run:()=>n?.(...i)})})}tweenTo(t,n={}){return this.tweenFromTo(this.timeline.currentTime/1e3,t,n)}tweenFromTo(t,n,i={}){this.pause(),this.seek(t);const s=this.timeline.currentTime,r=Math.max(0,Math.min(this.timeline.duration,this.compat.timeOf(n))),o={time:s},a=i.duration??Math.abs(r-s)/1e3/(this.timeScale()||1),l=new ct(this.stage,{onStart:i.onStart,onComplete:i.onComplete});return l.to(o,{time:r,duration:a,ease:i.ease??"none",onUpdate:()=>{this.moveTo(o.time),i.onUpdate?.()}}),l}play(){this.autoplayPending=!1,this.started||(this.started=!0,this.options.onStart?.());const t=this.timeline.playbackState==="playing",n=this.timeline.playbackState==="paused";if(this.timeline.play(),!t){const i=this.timeline,s=i.direction==="forward"?i.currentTime===0:i.currentTime===i.duration;this.playhead={...this.readPlayhead(),fresh:s&&!n},this.waitingToWrap=!1}return this.stage.liveTimelines.add(this),this.stage.render(this.timeline),this.stage.activate(this.timeline,{onUpdate:()=>this.afterFrame()}),this}pause(){return this.autoplayPending=!1,this.timeline.pause(),this.stage.deactivate(this.timeline),this}resume(){return this.play()}restart(){return this.timeline.stop(),this.backwards=!1,this.play()}reverse(){this.backwards=!this.backwards;const t=this.timeline.playbackState==="idle"&&this.timeline.direction==="forward";return this.timeline.reverse(),t&&this.timeline.currentTime===0&&this.timeline.seek(this.timeline.duration),this.play()}labelProgresses(){const t=this.timeline.duration;return t>0?this.compat.labelTimes().map(n=>n/t):[]}reversed(){return this.timeline.direction==="reverse"}seek(t){return this.autoplayPending=!1,this.compat.seek(t),this.stage.render(this.timeline),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,this.options.onUpdate?.(),this}progress(t){return t===void 0?this.compat.progress():(this.autoplayPending=!1,this.moveTo(Math.max(0,Math.min(1,t))*this.timeline.duration),this.compat.progress())}timeScale(t){return this.compat.timeScale(t)}duration(){return this.compat.duration()}isActive(){return this.timeline.playbackState==="playing"}kill(){return this.killed=!0,this.stage.liveTimelines.delete(this),this.scrollDriver?.destroy(),this.scrollDriver=void 0,this.autoplayPending=!1,this.timeline.stop(),this.stage.deactivate(this.timeline),this.compat.kill(),this}toDefinition(){return this.compat.toDefinition()}killTweensOf(t,n){for(const i of t)for(const s of n??[void 0])this.timeline.removeTracks({target:i,...s!==void 0&&{property:s}});this.timeline.tracks.length===0&&this.events.length===0&&this.kill()}record(t){return this.recipe.push(t),t(),this.syncDuration(),this}syncDuration(){if(this.events.length===0)return;this.timeline.setDuration(void 0);const t=Math.max(...this.events.map(n=>n.time));t>this.timeline.duration&&this.timeline.setDuration(t)}readPlayhead(){const t=this.timeline;return{time:t.currentTime,iteration:t.loopIteration,direction:t.direction}}moveTo(t){const n=this.playhead;this.timeline.seek(t),this.stage.render(this.timeline);const i={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:t>=n.time?"forward":"reverse"},s={...n,iteration:i.iteration,direction:i.direction};this.playhead={...this.readPlayhead()},this.waitingToWrap=!1,this.runCrossings(s,i,!1),this.options.onUpdate?.()}refreshForRepeat(){const t=this.timeline.currentTime;this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();this.syncDuration(),this.timeline.seek(Math.min(t,this.timeline.duration))}afterFrame(){const t=this.timeline,n=t.repeatDelayRemaining>0;if(this.waitingToWrap&&n){this.options.onUpdate?.();return}this.waitingToWrap=!1;const i=this.playhead,s=this.readPlayhead();this.playhead=s;const r=this.options.yoyo===!0;n&&!r&&s.iteration>i.iteration&&(this.playhead={time:0,iteration:s.iteration,direction:"forward",fresh:!0},this.waitingToWrap=!0);const o=this.runCrossings(i,s,n);if(this.options.onUpdate?.(),this.finishedThisFrame&&!o){this.finishedThisFrame=!1;const a=t.currentTime===0&&t.direction==="reverse";!this.scrollDriver&&!r&&this.stage.liveTimelines.delete(this),a&&this.backwards?this.options.onReverseComplete?.():this.options.onComplete?.()}this.finishedThisFrame=!1}runCrossings(t,n,i){if(this.events.length===0&&this.ranges.length===0&&!this.options.onRepeat&&!this.options.repeatRefresh)return!1;const s=this.events,{crossings:r,passes:o}=ui(s.map(a=>a.time),t,n,{duration:this.timeline.duration,alternate:this.options.yoyo===!0,holding:i});for(const a of r){if(this.killed)return!0;if(a.kind==="repeat"){this.options.repeatRefresh&&this.refreshForRepeat(),this.options.onRepeat?.();continue}const l=s[a.index];if(!(l.direction&&l.direction!==a.direction)){if(l.pause)return this.timeline.seek(l.time),this.stage.render(this.timeline),this.pause(),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,l.run(),!0;l.run()}}for(const a of this.ranges)o.some(([c,h])=>c!==h&&Math.max(c,h)>=a.start&&Math.min(c,h)<=a.end)&&a.run();return!1}tween(t,n,i,s){const r=this.resolve(t);if(!r)return;const{onStart:o,onUpdate:a,onComplete:l}=n[n.length-1];if(o||a||l){let c=1/0,h=-1/0;const u=(f,d,m)=>{s(f,d,m),c=Math.min(c,this.compat.lastStart),h=Math.max(h,this.compat.lastEnd)};if(this.buildTween(r,n,i,u),c===1/0)return;o&&this.events.push({time:c,direction:"forward",run:o}),a&&this.ranges.push({start:c,end:h,run:a}),l&&this.events.push({time:h,direction:"forward",run:l});return}this.buildTween(r,n,i,s)}keyframed(t,n,i){const s=this.resolve(t);if(!s)return;const r=Ru(n);if(r.length===0)return;const o=s.length>1?vi(n.stagger,this.staggerContext(s)):void 0,a=s.map(g=>this.targetFor(g)).filter(g=>g!==void 0),l=o?a.map(g=>[g]):[a],c=o?We(s.length,o).map(g=>g/1e3):[0],h=this.compat.timeOf(i)/1e3+an(n.delay,0)/1e3;let u=1/0,f=-1/0;if(l.forEach((g,y)=>{r.forEach((w,v)=>{const M=v===0?h+c[y]:">";this.tween(g,[w],M,([S],E,k)=>this.compat.to(E,S,k)),u=Math.min(u,this.compat.lastStart),f=Math.max(f,this.compat.lastEnd)})}),u===1/0)return;const{onStart:d,onUpdate:m,onComplete:p}=n;d&&this.events.push({time:u,direction:"forward",run:d}),m&&this.ranges.push({start:u,end:f,run:m}),p&&this.events.push({time:f,direction:"forward",run:p})}staggerContext(t){return{count:t.length,columnsFromLayout:()=>$o(t.map(n=>this.stage.elementFor(n))),random:()=>this.stage.utils.random(0,1)}}buildTween(t,n,i,s){const r=t.map(f=>this.targetFor(f));if(!(t.length>1&&(n.some(Du)||t.some(f=>this.stage.objectFor(f)!==void 0)))){const f=this.targetFor(t[0]);s(n.map(d=>this.prepare(Ho(d,0,f,this.stage.utils,r),t)),t,i);return}const a=n.length-1,{stagger:l,...c}=n[a],h=vi(l,this.staggerContext(t)),u=h?We(t.length,h).map(f=>f/1e3):t.map(()=>0);t.forEach((f,d)=>{const m=d===0?an(c.delay,0)/1e3+u[0]:0,p=d===0?0:u[d]-u[d-1],g=d===0?i:`<${p<0?"-":"+"}${Math.abs(p).toFixed(6)}`,w=n.map((v,M)=>M===a?{...c,delay:m}:v).map(v=>this.prepare(Ho(v,d,this.targetFor(f),this.stage.utils,r),[f]));s(w,[f],g)})}targetFor(t){return this.stage.elementFor(t)??this.stage.objectFor(t)}prepare(t,n){const i=o=>this.options.onWarning?.(o),s=o=>this.stage.query(o);let r=t;if(t.motionPath!==void 0){const o=Gh(t.motionPath,{query:s,targets:n.map(a=>this.stage.elementFor(a)).filter(a=>!!a),warn:i});r={...r,motionPath:o}}if(t.morphSVG!==void 0){const o=Jh(t.morphSVG,s,i),{morphSVG:a,...l}=r;r=o?{...r,morphSVG:o}:l}if(t.drawSVG!==void 0){const o=Oo(this.stage.elementFor(n[0]));if(o===void 0){i("gsap-compat: drawSVG needs an SVG shape with a stroke (path, line, circle…)");const{drawSVG:a,...l}=r;r=l}else r=Mh(r,o)}return r}resolve(t){const n=this.stage.resolveTargets(t);if(n.length===0){this.options.onWarning?.(`gsap-compat: no elements found for target ${Nu(t)}`);return}return this.firstElement??=n.map(i=>this.stage.elementFor(i)).find(i=>i!==void 0),n}}function Io(e=new jr){const t=r=>{const{config:o}=on(r);return new ct(e,{repeat:o.repeat,yoyo:o.yoyo,repeatDelay:o.repeatDelay,paused:o.paused,onStart:o.onStart,onUpdate:o.onUpdate,onComplete:o.onComplete,onRepeat:o.onRepeat,onReverseComplete:o.onReverseComplete,repeatRefresh:o.repeatRefresh,scrollTrigger:o.scrollTrigger})},n=r=>{const{onStart:o,onUpdate:a,onComplete:l,onRepeat:c,onReverseComplete:h,repeatRefresh:u,...f}=r;return f},i=r=>(r&&e.collector?.track(r),r),s={stage:e,ticker:e.ticker,utils:e.utils,getProperty:(r,o)=>{const[a]=e.resolveTargets(r);if(a===void 0)return;const l=e.objectFor(a);return l?l[o]:e.appliedValue(a,o)??Xr(o)},scrollTrigger:r=>i(Fi(e,r)),scrollBatch:(r,o)=>Lu(e,r,o).map(a=>i(a)),scrollTo:(r,o)=>_o(s,e,r,o),refreshScroll:()=>{Ee.refreshAll(),Ri.refreshAll()},smoothScroll:(r={})=>{const o=typeof r.scroller=="string"?(e.collector?.scope??e.root).querySelector(r.scroller):r.scroller;return i(new Ri({...r,scroller:o}).start())},context:(r,o)=>{const a=new Mo(e,o);return r&&a.add(()=>r(a)),a},matchMedia:r=>new Au(e,r),customEase:Eo.create,customBounce:Ao.create,customWiggle:xo.create,pageTransition:r=>Iu(s,e,o=>new ct(e,o),r),imageSequence:(r,o)=>{const a=typeof r=="string"?(e.collector?.scope??e.root).querySelector(r):r;if(!(a instanceof HTMLCanvasElement))throw new Error(`gsap-compat: imageSequence needs a <canvas>, got ${String(r)}`);return i(new xu(a,o))},quickTo:(r,o,a={})=>{const l=new ct(e,{paused:!0}),[c]=e.resolveTargets(r);return Object.assign(u=>{if(!c)return;const f=a.spring!==void 0?e.velocityOf(c,o)??0:0;l.compat.reset(),l.compat.to(c,{[o]:u,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:Fu(a.spring,o,f)}}),l.timeline.stop(),l.timeline.play(),e.activate(l.timeline)},{tween:l,kill:()=>l.kill()})},timeline:r=>new ct(e,r),to:(r,o)=>{if(o.scrollTo!==void 0){const{scrollTo:a,...l}=o,c=typeof a=="object"&&a!==null&&!("nodeType"in a)?a:{},h=typeof r!="string"&&r!==window&&r.nodeType===1;return _o(s,e,a,{...l,offsetX:c.offsetX,offsetY:c.offsetY,scroller:h?r:void 0})}return t(o).to(r,n(o))},from:(r,o)=>t(o).from(r,n(o)),fromTo:(r,o,a)=>t(a).fromTo(r,o,n(a)),set:(r,o)=>t(o).set(r,n(o)),delayedCall:(r,o,a)=>new ct(e).call(o,a,r),killTweensOf:(r,o)=>{const a=e.resolveTargets(r),l=typeof o=="string"?o.split(",").map(c=>c.trim()).filter(Boolean):o;for(const c of[...e.liveTimelines])c.killTweensOf(a,l)},convertToPath:r=>Qh(r,e.root),splitText:(r,o)=>{const a=e.collector?.scope??e.root,l=typeof r=="string"?Array.from(a.querySelectorAll(r)):"nodeType"in r?[r]:Array.from(r);return i(au(l,o))},draggable:(r,o)=>i(iu(s,e,r,o)),getFlipState:r=>Ai(e,r),flipFrom:(r,o)=>Pi(e,a=>new ct(e,a),r,o),flip:(r,o,a)=>{const l=Ai(e,r);return o(),Pi(e,c=>new ct(e,c),l,{targets:r,...a})}};return s}const Q=Io();function Fu(e,t,n){return e===!0?{velocity:{[t]:n}}:typeof e=="string"?{preset:e,velocity:{[t]:n}}:{...e,velocity:{[t]:n}}}function Du(e){return e.morphSVG!==void 0||e.drawSVG!==void 0||e.text!==void 0||e.scrambleText!==void 0||Co(e)}function Co(e){return Object.entries(e).some(([t,n])=>(typeof n=="function"||Kr(n))&&!wi.has(t))}function Ho(e,t,n,i,s){if(!Co(e))return e;const r={};for(const[o,a]of Object.entries(e))wi.has(o)?r[o]=a:typeof a=="function"?r[o]=a(t,n,s):Kr(a)?r[o]=i.resolveRandomString(a):r[o]=a;return r}function $o(e){const t=e.map(i=>i?.getBoundingClientRect().top);if(t[0]===void 0)return e.length;let n=0;for(const i of t){if(i===void 0||Math.abs(i-t[0])>1)break;n++}return Math.max(1,n)}function Oo(e){const t=e;if(typeof t?.getTotalLength=="function")return t.getTotalLength()}function Bu(e){if(typeof e=="number"||typeof e=="string"||Array.isArray(e)&&e.every(t=>typeof t=="number"))return e}function Nu(e){return typeof e=="string"?`"${e}"`:String(e)}class Di{media;offset;driftTolerance;constructor(t,n={}){this.media=t,this.offset=n.offset??0,this.driftTolerance=Math.max(0,n.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,n){const i=this.targetTime(t);n?(this.media.paused&&this.safePlay(),Math.abs(this.media.currentTime-i)>this.driftTolerance&&(this.media.currentTime=i)):(this.media.paused||this.media.pause(),this.media.currentTime!==i&&(this.media.currentTime=i))}seek(t){this.media.currentTime=this.targetTime(t)}setRate(t){this.media.playbackRate=t}dispose(){this.media.paused||this.media.pause()}safePlay(){const t=this.media.play();t&&typeof t.catch=="function"&&t.catch(()=>{})}}function Ro(e,t,n,i,s){const r=n-s;if(r<0){t.paused||t.pause(),t.currentTime=0;return}e.update(r,i)}class hn{container;timeline=null;adapter;animationFrameId;lastTime;options;targets={};isDestroyed=!1;mediaSync;mediaTargets=[];symbolInstances=[];scenarioList=[];scenarioId;authored=new Map;markerList=[];listeners=new Set;playhead={time:0,iteration:0,direction:"forward"};stepping=!1;lastMarkerId=null;reducedQuery;onReducedChange=()=>this.applyReducedMotion();visibilityObserver;onScreen=!0;pausedByVisibility=!1;autoplayWhenSeen=!1;onDocumentVisibility=()=>this.updateVisibility();constructor(t,n={}){if(typeof t=="string"){const i=document.querySelector(t);if(!i)throw new Error(`Container not found: ${t}`);this.container=i}else this.container=t;this.options=n,this.adapter=new _t}async load(t){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(t)}async loadSource(t){let n;if(typeof t=="string"){const i=await fetch(t);if(!i.ok)throw new Error(`Failed to load animation: ${i.statusText}`);n=await i.json()}else n=t;this.useDefinition(n),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(t){const n={...t.config};this.options.speed!==void 0&&(n.speed=this.options.speed),this.options.loop!==void 0&&(n.loop=this.options.loop),this.options.alternate!==void 0&&(n.alternate=this.options.alternate),this.timeline=Vt({...t,config:n}),this.markerList=this.timeline.markers,this.lastMarkerId=null,this.options.onComplete&&(this.timeline.onComplete=this.options.onComplete),this.options.onUpdate&&(this.timeline.onUpdate=this.options.onUpdate),this.autoRegisterTargets(),this.setupSymbolInstances(),this.scanMedia()}async loadScenarios(t,n={}){if(t.length===0)throw new Error("tinyfly: loadScenarios needs at least one scenario");const i=new Set;for(const r of t){if(i.has(r.id))throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);i.add(r.id)}const s=n.initial===void 0?t[0]:t.find(r=>r.id===n.initial);if(!s)throw new Error(`tinyfly: there is no scenario "${n.initial}"`);this.scenarioList=[...t],this.scenarioId=s.id,await this.loadSource(s.timeline)}get scenarios(){return this.scenarioList.map(t=>({id:t.id,label:t.label??t.id}))}get scenario(){return this.scenarioId}setScenario(t){const n=this.scenarioList.find(a=>a.id===t);if(!n||!this.timeline)return!1;if(t===this.scenarioId)return!0;const i=this.isPlaying,s=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=t,this.useDefinition(n.timeline),this.lastMarkerId=null;let o=0;return this.reducedMotion||s?o=this.duration:r!==void 0&&(o=this.markers.find(a=>a.id===r)?.time??0),this.seek(o),i&&!this.reducedMotion?(this.stepping=this.options.stepMode===!0,this.startPlaying()):this.notify(),!0}rememberAuthored(t){if(this.authored.has(t))return;const n={style:t.getAttribute("style")};t.children.length===0&&(n.text=t.textContent??"");const i=t.tagName.toLowerCase()==="path"?t:t.querySelector("path");i&&(n.path={element:i,d:i.getAttribute("d")}),this.authored.set(t,n)}restoreAuthored(){for(const[t,n]of this.authored){n.style===null?t.removeAttribute("style"):t.setAttribute("style",n.style),n.text!==void 0&&t.textContent!==n.text&&(t.textContent=n.text),n.path&&(n.path.d===null?n.path.element.removeAttribute("d"):n.path.element.setAttribute("d",n.path.d));const i=t.dataset;i&&delete i.shineBase}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){for(const t of this.listeners)t()}get reducedMotion(){return this.reducedQuery?.matches===!0}get markers(){return this.markerList}get currentMarker(){const t=this.currentTime;let n;for(const i of this.markers)if(i.time<=t+.5)n=i;else break;return n}caption(t,n){const i=t?this.markers.find(o=>o.id===t):this.currentMarker;if(!i)return;const s=n??this.language(),r=o=>o?.[s]?.[i.id]??o?.[s.split("-")[0]]?.[i.id];return r(this.options.captions)??r(this.timeline?.captions)??i.label}next(){if(!this.timeline)return;const t=this.currentTime,n=this.markers.find(i=>i.time>t+.5);if(this.reducedMotion){this.seek(n?n.time:this.duration);return}t>=this.duration-.5||(this.stepping=n!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,n=[...this.markers].reverse().find(i=>i.time<t-.5);this.pause(),this.seek(n?n.time:0)}goToMarker(t){const n=this.markers.find(i=>i.id===t);n&&(this.pause(),this.seek(n.time))}language(){return this.container.closest("[lang]")?.getAttribute("lang")||(typeof document<"u"?document.documentElement.lang:"")||"en"}showInitialFrame(){if(!this.timeline)return;const t=this.options.initialFrame??"start";if(t==="none")return;const n=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,n))),this.applyState()}watchReducedMotion(){this.options.respectReducedMotion===!1||typeof window>"u"||typeof window.matchMedia!="function"||(this.reducedQuery??=window.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedQuery.addEventListener?.("change",this.onReducedChange),this.reducedQuery.matches&&this.applyReducedMotion())}applyReducedMotion(){!this.reducedMotion||!this.timeline||(this.autoplayWhenSeen=!1,this.pause(),this.seek(this.timeline.duration))}watchVisibility(){if(!(!this.options.playWhenVisible||typeof window>"u")){if(typeof IntersectionObserver=="function"){this.visibilityObserver?.disconnect(),this.visibilityObserver=new IntersectionObserver(n=>{for(const i of n)this.onScreen=i.isIntersecting;this.updateVisibility()}),this.visibilityObserver.observe(this.container);const t=this.container.getBoundingClientRect?.();t&&(t.width>0||t.height>0)&&(this.onScreen=t.bottom>0&&t.top<window.innerHeight&&t.right>0&&t.left<window.innerWidth)}document.addEventListener("visibilitychange",this.onDocumentVisibility)}}updateVisibility(){const t=this.onScreen&&document.visibilityState!=="hidden";!t&&this.isPlaying?(this.pausedByVisibility=!0,this.pause()):t&&(this.pausedByVisibility||this.autoplayWhenSeen)&&!this.reducedMotion&&(this.pausedByVisibility=!1,this.autoplayWhenSeen=!1,this.startPlaying())}announceMarker(){if(!this.options.onMarker)return;const t=this.currentMarker,n=t?.id;n!==this.lastMarkerId&&(this.lastMarkerId=n,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(n=>{const i=n,s=Number(i.getAttribute("data-tinyfly-start")??"0")||0,r=i.getAttribute("data-volume");r!==null&&(i.volume=Math.max(0,Math.min(1,Number(r)||0))),this.mediaTargets.push({el:i,startTime:s,sync:new Di(i)})})}syncAllMedia(t,n){for(const i of this.mediaTargets)Ro(i.sync,i.el,t,n,i.startTime)}loadFromString(t){const n=JSON.parse(t);this.load(n)}registerTarget(t,n){if(typeof n=="string"){const i=this.container.querySelector(n);i&&(this.rememberAuthored(i),this.targets[t]=i,this.adapter.registerTarget(t,i))}else this.rememberAuthored(n),this.targets[t]=n,this.adapter.registerTarget(t,n)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(n=>{const i=n.closest("[data-tinyfly-symbol]");if(i&&i!==n)return;const s=n.getAttribute("data-tinyfly");s&&this.registerTarget(s,n)}),this.timeline&&new Set(this.timeline.tracks.map(i=>i.target)).forEach(i=>{if(!this.targets[i]){const s=this.container.querySelector(`[data-tinyfly="${i}"]`)||this.container.querySelector(`.${i}`)||this.container.querySelector(`#${i}`);s&&this.registerTarget(i,s)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const n=new Map(t.map(i=>[i.id,i]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(i=>{const s=i.getAttribute("data-tinyfly-symbol");if(!s)return;const r=n.get(s);if(!r||!r.timeline.tracks?.length)return;const o=new _t;i.querySelectorAll("[data-tinyfly]").forEach(a=>{const l=a.getAttribute("data-tinyfly");l&&o.registerTarget(l,a)}),this.symbolInstances.push({adapter:o,timeline:Vt(r.timeline)})})}attachMedia(t,n){this.mediaSync=new Di(t,n),this.timeline&&(this.mediaSync.setRate(this.timeline.speed),this.mediaSync.update(this.timeline.currentTime,this.isPlaying))}detachMedia(){this.mediaSync?.dispose(),this.mediaSync=void 0}play(){!this.timeline||this.isDestroyed||(this.autoplayWhenSeen=!1,this.stepping=this.options.stepMode===!0,this.startPlaying())}startPlaying(){if(!this.timeline||this.isDestroyed)return;const t=this.timeline.playbackState==="idle";this.timeline.play(),t&&this.timeline.currentTime===0&&this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.update(this.timeline.currentTime,!0),this.syncAllMedia(this.timeline.currentTime,!0),this.startAnimationLoop(),this.notify()}pause(){this.timeline&&(this.stepping=!1,this.timeline.pause(),this.notify(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1),this.stopAnimationLoop())}stop(){this.timeline&&(this.timeline.stop(),this.stopAnimationLoop(),this.applyState(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1))}seek(t){this.timeline&&(this.timeline.seek(t),this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.seek(this.timeline.currentTime),this.syncAllMedia(this.timeline.currentTime,this.isPlaying))}setSpeed(t){this.timeline&&(this.timeline.speed=t,this.mediaSync?.setRate(t))}reverse(){this.timeline&&this.timeline.reverse()}get currentTime(){return this.timeline?.currentTime??0}get duration(){return this.timeline?.duration??0}get isPlaying(){return this.timeline?.playbackState==="playing"}destroy(){this.isDestroyed=!0,this.stopAnimationLoop(),this.reducedQuery?.removeEventListener?.("change",this.onReducedChange),this.visibilityObserver?.disconnect(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onDocumentVisibility),this.mediaSync?.dispose(),this.mediaSync=void 0;for(const t of this.mediaTargets)t.el.paused||t.el.pause();this.mediaTargets=[],this.adapter.clearTargets();for(const t of this.symbolInstances)t.adapter.clearTargets();this.symbolInstances=[],this.authored.clear(),this.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this.isDestroyed||!this.timeline)return;const i=n-(this.lastTime??n);this.lastTime=n;const s=this.playhead;this.timeline.tick(i),this.stopAtMarker(s),this.applyState();const r=this.timeline.playbackState==="playing";this.mediaSync?.update(this.timeline.currentTime,r),this.syncAllMedia(this.timeline.currentTime,r),this.timeline.playbackState==="playing"?this.animationFrameId=requestAnimationFrame(t):(this.animationFrameId=void 0,this.notify())};this.animationFrameId=requestAnimationFrame(t)}stopAtMarker(t){const n=this.timeline,i={time:n.currentTime,iteration:n.loopIteration,direction:n.direction};this.playhead=i;const s=this.markers;if(s.length===0)return;const{crossings:r}=ui(s.map(o=>o.time),t,i,{duration:n.duration,alternate:n.config.alternate===!0,holding:n.repeatDelayRemaining>0});for(const o of r){if(o.kind!=="event")continue;const a=s[o.index];if(this.stepping||a.pause){this.stepping=!1,n.pause(),n.seek(a.time),this.playhead={time:a.time,iteration:n.loopIteration,direction:n.direction};return}}}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}applyState(){if(!this.timeline)return;const t=this.timeline.currentTime;this.adapter.applyState(this.timeline.getStateAtTime(t)),this.announceMarker(),this.notify();for(const n of this.symbolInstances){const i=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(i>0?t%i:t))}}}async function Wu(e,t,n={}){const i=new hn(e,{...n,autoplay:!0});return await i.load(t),i}function Ku(e,t={}){return new hn(e,t)}const Lo={play:"Play",pause:"Pause",prev:"Previous step",next:"Next step",restart:"Restart",scrub:"Position",speed:"Speed",reveal:"Reveal",step:"Step",of:"of",stepFormat:"{index} / {total}",scenario:"Scenario",fullscreen:"Full screen",exitFullscreen:"Exit full screen"},Fo="tinyfly-controls-style",Yu=`
1
+ (function(b,Bt){typeof exports=="object"&&typeof module<"u"?Bt(exports):typeof define=="function"&&define.amd?define(["exports"],Bt):(b=typeof globalThis<"u"?globalThis:b||self,Bt(b.tinyfly=b.tinyfly||{}))})(this,(function(b){"use strict";function Bt(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function fe(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const qn=2;function Vn(e){return e.some(t=>t.interpolation!==void 0)?2:1}function Ye(e){return e.property==="text"&&"textConfig"in e}function mt(e){return e.kind==="inertia"&&"inertia"in e}function gt(e){return e.kind==="spring"&&"spring"in e}function Un(e){return e.property==="motionPath"&&"motionPathConfig"in e}function Xl(e){return typeof e=="object"&&e!==null&&"x"in e&&"y"in e&&"angle"in e}function Hs(e){return"keyframes"in e}class ql{_currentTime=0;_isRunning=!1;onTick=null;get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}start(){this._isRunning=!0}stop(){this._isRunning=!1}tick(t){this._currentTime+=t,this.onTick?.(t,this._currentTime)}reset(){this._currentTime=0}seek(t){this._currentTime=t}}class Vl{_currentTime=0;_isRunning=!1;_lastFrameTime=null;_rafId=null;_speed;onTick=null;constructor(t={}){this._speed=t.speed??1}get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}get speed(){return this._speed}set speed(t){this._speed=t}start(){this._isRunning||(this._isRunning=!0,this._lastFrameTime=null,this._scheduleFrame())}stop(){this._isRunning=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}reset(){this._currentTime=0,this._lastFrameTime=null}seek(t){this._currentTime=t}_scheduleFrame(){this._rafId=requestAnimationFrame(this._onFrame.bind(this))}_onFrame(t){if(this._isRunning){if(this._lastFrameTime!==null){const i=(t-this._lastFrameTime)*this._speed;this._currentTime+=i,this.onTick?.(i,this._currentTime)}this._lastFrameTime=t,this._scheduleFrame()}}}function $s(e,t){if(!(t>0))return e;const n=1e3/t;return Math.floor(e/n+1e-9)*n}function zn(e,t,n="start"){if(t<=1)return 0;if(typeof n=="number"){const i=Math.max(0,Math.min(t-1,n));return Math.abs(e-i)}switch(n){case"end":return t-1-e;case"center":return Math.abs(e-(t-1)/2);case"edges":return(t-1)/2-Math.abs(e-(t-1)/2);default:return e}}function Gn(e,t="start"){if(e<=1)return 0;let n=0;for(let i=0;i<e;i++)n=Math.max(n,zn(i,e,t));return n}function Xe(e,t,n){if(n.offsets)return n.offsets[e]??0;const i=n.from??"start",s=zn(e,t,i);if(n.amount!==void 0){const r=Gn(t,i);return r===0?0:n.amount*s/r}return n.each!==void 0?n.each*s:0}function qe(e,t){return Array.from({length:e},(n,i)=>Xe(i,e,t))}function de(e,t){return e<=1?0:Math.max(...qe(e,t))}const Nt=1,jn=6e4,Ve=jn/Nt,st={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},Ue={gentle:{stiffness:120,damping:18,mass:1},default:{stiffness:180,damping:12,mass:1},snappy:{stiffness:280,damping:20,mass:1},bouncy:{stiffness:220,damping:8,mass:1},wobbly:{stiffness:180,damping:5,mass:1},stiff:{stiffness:400,damping:30,mass:1}};class pe{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(t){this.from=t.from,this.to=t.to,this.stiffness=t.stiffness??st.stiffness,this.damping=t.damping??st.damping,this.mass=t.mass??st.mass,this.restDelta=t.restDelta??st.restDelta,this.restSpeed=t.restSpeed??st.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??st.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(t){return Math.abs(t-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(t){if(t<=0)return this.from;const n=Math.floor(t/Nt);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const i=this.samples[Math.min(n,this.samples.length-1)],s=this.samples[Math.min(n+1,this.samples.length-1)],r=t/Nt-n;return i+(s-i)*r}settleTime(){return this.simulateTo(Ve+1),this.settledStep!==null?this.settledStep*Nt:jn}simulateTo(t){if(this.settledStep!==null)return;const n=Math.min(t,Ve+1),i=Nt/1e3;for(;this.samples.length<n;){const s=this.samples[this.samples.length-1],r=s-this.to,o=-this.stiffness*r,a=-this.damping*this.velocity,l=(o+a)/this.mass;this.velocity+=l*i;const c=s+this.velocity*i;if(this.samples.push(c),this.isAtRest(c)){this.settledStep=this.samples.length-1;return}}this.samples.length>Ve&&(this.settledStep=Ve)}}function Ul(e,t){return new pe(e).valueAt(t)}function Rs(e){return new pe(e).settleTime()}function zl(e){const t=e.stiffness??st.stiffness,n=e.damping??st.damping,i=e.mass??st.mass;return n<2*Math.sqrt(t*i)}function Gl(e){const t=e.stiffness??st.stiffness,n=e.mass??st.mass;return 2*Math.sqrt(t*n)}const Jn=4,jl=.002,Jl=1e-4,Os=6e4;function ze(e){const t=e.friction??Jn;return t>0?t:Jn}function me(e){return e.from+e.velocity/ze(e)}function Zl(e,t){if(t===void 0)return e;if(typeof t=="number")return t>0?Math.round(e/t)*t:e;if(t.length===0)return e;let n=t[0];for(const i of t)Math.abs(i-e)<Math.abs(n-e)&&(n=i);return n}function Wt(e){let t=Zl(me(e),e.end);return e.min!==void 0&&(t=Math.max(e.min,t)),e.max!==void 0&&(t=Math.min(e.max,t)),t}function Kt(e){const t=Math.abs(Wt(e)-e.from);if(t===0)return 0;const n=e.restDelta??Math.max(Jl,t*jl);if(n>=t)return 0;const i=Math.log(t/n)/ze(e);return Math.min(Os,i*1e3)}function Ge(e,t){if(t<=0)return e.from;const n=Wt(e);if(t>=Kt(e))return n;const i=ze(e);return e.from+(n-e.from)*(1-Math.exp(-i*t/1e3))}function Ql(e,t){const n=ze(e),i=Wt(e);return t>=Kt(e)?0:(i-e.from)*n*Math.exp(-n*Math.max(0,t)/1e3)}const je=e=>e,Ls=e=>e*e,Fs=e=>1-(1-e)*(1-e),Ds=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,Zn=e=>e*e*e,Qn=e=>1-Math.pow(1-e,3),ge=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Bs=Zn,Ns=Qn,Ws=ge,tc={linear:je,"ease-in":Bs,"ease-out":Ns,"ease-in-out":Ws,"ease-in-quad":Ls,"ease-out-quad":Fs,"ease-in-out-quad":Ds,"ease-in-cubic":Zn,"ease-out-cubic":Qn,"ease-in-out-cubic":ge};function Ks(e){const[t,n,i,s]=e,r=3*t,o=3*(i-t)-r,a=1-r-o,l=3*n,c=3*(s-n)-l,h=1-l-c,u=p=>((a*p+o)*p+r)*p,f=p=>((h*p+c)*p+l)*p,d=p=>(3*a*p+2*o)*p+r,m=p=>{let g=p;for(let k=0;k<8;k++){const M=u(g)-p;if(Math.abs(M)<1e-7)return g;const S=d(g);if(Math.abs(S)<1e-7)break;g-=M/S}let y=0,w=1;for(g=p;y<w;){const k=u(g);if(Math.abs(k-p)<1e-7)return g;p>k?y=g:w=g,g=(y+w)/2}return g};return p=>{if(p<=0)return 0;if(p>=1)return 1;const g=m(p);return f(g)}}function ti(e,t="out"){if(t==="out")return e;const n=i=>1-e(1-i);return t==="in"?n:i=>i<.5?n(i*2)/2:e(i*2-1)/2+.5}function Ys(e=1,t=.3){const n=Math.max(1,e),i=t/(2*Math.PI)*Math.asin(1/n);return s=>s<=0?0:s>=1?1:n*Math.pow(2,-10*s)*Math.sin((s-i)*(2*Math.PI)/t)+1}const Xs=e=>{if(e<=0)return 0;if(e>=1)return 1;if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const s=e-.5454545454545454;return 7.5625*s*s+.75}if(e<2.5/2.75){const s=e-.8181818181818182;return 7.5625*s*s+.9375}const i=e-2.625/2.75;return 7.5625*i*i+.984375};function qs(e=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const n=t-1;return n*n*((e+1)*n+e)+1}}function Vs(e,t="end"){const n=Math.max(1,Math.floor(e));return i=>{if(i>=1)return 1;if(i<=0)return t==="start"||t==="both"?t==="start"?1/n:1/(n+1):0;const s=Math.floor(i*n);switch(t){case"start":return Math.min(1,(s+1)/n);case"both":return(s+1)/(n+1);case"none":return n===1?0:Math.min(1,s/(n-1));default:return s/n}}}function Us(e){switch(e.type){case"steps":return Vs(e.count,e.position);case"elastic":return ti(Ys(e.amplitude,e.period),e.mode);case"bounce":return ti(Xs,e.mode);case"back":return ti(qs(e.overshoot),e.mode)}}function J(e){return e===void 0?je:Bt(e)?Ks(e.points):fe(e)?Us(e):tc[e]??je}const zs=32,ec=256,Yt=new Map,nc=/[MmLlHhVvCcSsQqTtAaZz]/,ic=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,sc={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function rc(e){const t=[];let n=0,i=null;const s=()=>{for(;n<e.length&&/[\s,]/.test(e[n]);)n++};for(;n<e.length&&(s(),!(n>=e.length));){const r=e[n];if(nc.test(r)){i={type:r,args:[]},t.push(i),n++;continue}if(!i)break;const o=i.type==="A"||i.type==="a",a=i.args.length%7;if(o&&(a===3||a===4)){if(r!=="0"&&r!=="1")break;i.args.push(r==="1"?1:0),n++;continue}const l=ic.exec(e.slice(n));if(!l)break;i.args.push(parseFloat(l[0])),n+=l[0].length}return t}function oc(e,t,n,i,s,r,o,a,l){if(e===a&&t===l)return[];let c=Math.abs(n),h=Math.abs(i);if(c===0||h===0)return[[e,t,a,l,a,l]];const u=s*Math.PI/180,f=Math.cos(u),d=Math.sin(u),m=(e-a)/2,p=(t-l)/2,g=f*m+d*p,y=-d*m+f*p,w=g*g/(c*c)+y*y/(h*h);if(w>1){const O=Math.sqrt(w);c*=O,h*=O}const k=r===o?-1:1,M=c*c*h*h-c*c*y*y-h*h*g*g,S=c*c*y*y+h*h*g*g,A=k*Math.sqrt(Math.max(0,M/S)),E=A*c*y/h,T=-A*h*g/c,v=f*E-d*T+(e+a)/2,_=d*E+f*T+(t+l)/2,P=(O,D,N,K)=>{const Q=O*N+D*K,xt=Math.sqrt((O*O+D*D)*(N*N+K*K)),Dt=Math.acos(Math.max(-1,Math.min(1,Q/xt)));return O*K-D*N<0?-Dt:Dt},x=P(1,0,(g-E)/c,(y-T)/h);let I=P((g-E)/c,(y-T)/h,(-g-E)/c,(-y-T)/h);!o&&I>0&&(I-=2*Math.PI),o&&I<0&&(I+=2*Math.PI);const C=Math.max(1,Math.ceil(Math.abs(I)/(Math.PI/2))),H=I/C,R=4/3*Math.tan(H/4),B=O=>{const D=c*Math.cos(O),N=h*Math.sin(O);return[f*D-d*N+v,d*D+f*N+_]},$=O=>{const D=-c*Math.sin(O),N=h*Math.cos(O);return[f*D-d*N,d*D+f*N]},L=[];for(let O=0;O<C;O++){const D=x+O*H,N=D+H,[K,Q]=B(D),[xt,Dt]=O===C-1?[a,l]:B(N),[Zp,Qp]=$(D),[tm,em]=$(N);L.push([K+R*Zp,Q+R*Qp,xt-R*tm,Dt-R*em,xt,Dt])}return L}function yt(e,t,n,i,s){const r=1-s;return r*r*r*e+3*r*r*s*t+3*r*s*s*n+s*s*s*i}function Gs(e,t,n,i,s){const r=1-s;return 3*r*r*(t-e)+6*r*s*(n-t)+3*s*s*(i-n)}function ye(e,t,n,i){return{subpath:0,type:"L",points:[n,i],startX:e,startY:t,endX:n,endY:i,length:Math.hypot(n-e,i-t)}}function Je(e,t,n){const[i,s,r,o,a,l]=n,c=[0];let h=e,u=t,f=0;for(let d=1;d<=zs;d++){const m=d/zs,p=yt(e,i,r,a,m),g=yt(t,s,o,l,m);f+=Math.hypot(p-h,g-u),c.push(f),h=p,u=g}return{subpath:0,type:"C",points:[i,s,r,o,a,l],startX:e,startY:t,endX:a,endY:l,length:f,lengths:c}}function Pt(e){const t=Yt.get(e);if(t)return t;const n=[];let i=0,s=0,r=0,o=0,a=null,l=null,c=-1;const h=new Set,u=p=>{c<0&&(c=0),p.subpath=c,n.push(p)};for(const{type:p,args:g}of rc(e)){const y=p.toUpperCase(),w=p!==y,k=sc[y];if(y==="Z"){(i!==r||s!==o)&&u(ye(i,s,r,o)),c>=0&&h.add(c),i=r,s=o,a=l=null;continue}for(let M=0;M+k<=g.length;M+=k){const S=g.slice(M,M+k),A=w?i:0,E=w?s:0;let T=null,v=null;switch(y){case"M":M===0?(i=S[0]+A,s=S[1]+E,r=i,o=s,(c<0||n[n.length-1]?.subpath===c)&&c++):(u(ye(i,s,S[0]+A,S[1]+E)),i=S[0]+A,s=S[1]+E);break;case"L":u(ye(i,s,S[0]+A,S[1]+E)),i=S[0]+A,s=S[1]+E;break;case"H":u(ye(i,s,S[0]+A,s)),i=S[0]+A;break;case"V":u(ye(i,s,i,S[0]+E)),s=S[0]+E;break;case"C":{const _=[S[0]+A,S[1]+E,S[2]+A,S[3]+E,S[4]+A,S[5]+E];u(Je(i,s,_)),T=[_[2],_[3]],i=_[4],s=_[5];break}case"S":{const[_,P]=a?[2*i-a[0],2*s-a[1]]:[i,s],x=[_,P,S[0]+A,S[1]+E,S[2]+A,S[3]+E];u(Je(i,s,x)),T=[x[2],x[3]],i=x[4],s=x[5];break}case"Q":case"T":{let _=i,P=s;y==="Q"?(_=S[0]+A,P=S[1]+E):l&&(_=2*i-l[0],P=2*s-l[1]);const x=y==="Q"?S[2]+A:S[0]+A,I=y==="Q"?S[3]+E:S[1]+E;u(Je(i,s,[i+2/3*(_-i),s+2/3*(P-s),x+2/3*(_-x),I+2/3*(P-I),x,I])),v=[_,P],i=x,s=I;break}case"A":{const _=S[5]+A,P=S[6]+E;let x=i,I=s;for(const C of oc(i,s,S[0],S[1],S[2],S[3],S[4],_,P))u(Je(x,I,C)),x=C[4],I=C[5];i=_,s=P;break}}a=T,l=v}}const f=n.reduce((p,g)=>p+g.length,0),d=[];for(let p=0;p<n.length;){const g=n[p].subpath;let y=p,w=0;for(;y<n.length&&n[y].subpath===g;)w+=n[y++].length;const k=n[p],M=n[y-1],S=h.has(g)||Math.abs(M.endX-k.startX)<1e-9&&Math.abs(M.endY-k.startY)<1e-9;d.push({start:p,end:y,length:w,closed:S}),p=y}const m={segments:n,totalLength:f,subpaths:d};return Yt.size>=ec&&Yt.delete(Yt.keys().next().value),Yt.set(e,m),m}function ac(e,t){const n=e.lengths;if(t<=0)return 0;if(t>=e.length)return 1;let i=0,s=n.length-1;for(;i<s-1;){const a=i+s>>1;n[a]<t?i=a:s=a}const r=n[s]-n[i],o=r>0?(t-n[i])/r:0;return(i+o)/(n.length-1)}function lc(e,t){if(e.type==="L"){const u=e.length>0?Math.max(0,Math.min(1,t/e.length)):0;return{x:e.startX+(e.endX-e.startX)*u,y:e.startY+(e.endY-e.startY)*u,angle:Math.atan2(e.endY-e.startY,e.endX-e.startX)*180/Math.PI}}const[n,i,s,r,o,a]=e.points,l=ac(e,t);let c=Gs(e.startX,n,s,o,l),h=Gs(e.startY,i,r,a,l);if(Math.hypot(c,h)<1e-9){const u=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),f=yt(e.startX,n,s,o,u),d=yt(e.startY,i,r,a,u),m=yt(e.startX,n,s,o,l),p=yt(e.startY,i,r,a,l);c=l<.5?f-m:m-f,h=l<.5?d-p:p-d}return{x:yt(e.startX,n,s,o,l),y:yt(e.startY,i,r,a,l),angle:Math.atan2(h,c)*180/Math.PI}}function ei(e,t,n=0,i=e.length){if(i<=n)return{x:0,y:0,angle:0};let s=0;for(let r=n;r<i;r++){const o=e[r];if(s+o.length>=t||r===i-1)return lc(o,t-s);s+=o.length}return{x:0,y:0,angle:0}}function js(e,t){const{segments:n,totalLength:i}=Pt(e);return ei(n,Math.max(0,Math.min(1,t))*i)}function cc(){Yt.clear()}function hc(e){return Pt(e).totalLength}const uc=24,fc=320,dc=2.5,be=72,pc=64,mc=.2,gc=128,we=new Map;let Ze=0,bt;const Js=e=>Math.round(e*100)/100;function Zs(e,t){const{segments:n,subpaths:i,totalLength:s}=Pt(e);if(n.length===0)return[];if(t){const r=i.every(o=>o.closed);return[{segments:n,start:0,end:n.length,length:s,closed:r}]}return i.filter(r=>r.length>0).map(r=>({segments:n,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function ni(e,t){const n=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),i=ei(e.segments,n*e.length,e.start,e.end);return[i.x,i.y]}function Qs(e){const t=[];let n=0;for(let i=e.start;i<e.end;i++)n+=e.segments[i].length,e.length>0&&t.push(n/e.length);return t}function tr(e,t){const n=[];for(let i=0;i<t;i++)n.push(ni(e,e.closed?i/t:i/(t-1)));return n}function er(e){let t=0,n=0;for(const[i,s]of e)t+=i,n+=s;return t/=e.length,n/=e.length,e.map(([i,s])=>[i-t,s-n])}function yc(e,t,n){const i=e.closed&&t.closed;if(n!==void 0)return{offset:i?Math.abs(n)%be/be:0,reversed:n<0};const s=er(tr(e,be)),r=er(tr(t,be)),o=be;let a={offset:0,reversed:!1},l=1/0;for(const c of[!1,!0]){const h=i?o:1;for(let u=0;u<h;u++){let f=0;for(let d=0;d<o&&f<l;d++){const m=i?c?(u-d+o)%o:(d+u)%o:c?o-1-d:d,p=s[d][0]-r[m][0],g=s[d][1]-r[m][1];f+=p*p+g*g}f<l&&(l=f,a={offset:i?u/o:0,reversed:c})}}return a}function bc(e,t,n){return n?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function wc(e,t,n){return n?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function kc(e,t,n){const i=e.closed&&t.closed,s=yc(e,t,n.shapeIndex),r=Math.max(uc,Math.min(fc,Math.ceil(Math.max(e.length,t.length)/dc))),o=new Set,a=u=>o.add(Math.round(u*1e7)/1e7);for(let u=0;u<=r;u++)a(u/r);for(const u of Qs(e))a(u);for(const u of Qs(t))a(wc(u,s,i));let l=[...o].sort((u,f)=>u-f);i&&(l=l.filter(u=>u<1));const c=[],h=[];for(const u of l)c.push(...ni(e,u)),h.push(...ni(t,bc(u,s,i)));return vc({from:c,to:h,closed:i})}function vc(e){const t=e.from.length/2;if(t<=3)return e;const n=new Uint8Array(t);n[0]=1,n[t-1]=1;const i=[[0,t-1]];for(;i.length>0;){const[o,a]=i.pop();let l=-1,c=mc;for(let h=o+1;h<a;h++){const u=Math.max(nr(e.from,o,a,h),nr(e.to,o,a,h));u>c&&(c=u,l=h)}l!==-1&&(n[l]=1,i.push([o,l],[l,a]))}const s=[],r=[];for(let o=0;o<t;o++)n[o]&&(s.push(e.from[o*2],e.from[o*2+1]),r.push(e.to[o*2],e.to[o*2+1]));return{from:s,to:r,closed:e.closed}}function nr(e,t,n,i){const s=e[t*2],r=e[t*2+1],o=e[n*2]-s,a=e[n*2+1]-r,l=e[i*2]-s,c=e[i*2+1]-r,h=o*o+a*a,u=h===0?0:Math.max(0,Math.min(1,(l*o+c*a)/h));return Math.hypot(l-u*o,c-u*a)}function Sc(e,t,n){const i=n.shapeIndex;if(bt&&bt.from===e&&bt.to===t&&bt.shapeIndex===i)return bt.plan;const r=we.get(String(i??"auto"))?.get(e)?.get(t);if(r)return bt={from:e,to:t,shapeIndex:i,plan:r},r;const o=Pt(e).subpaths.filter(d=>d.length>0).length===Pt(t).subpaths.filter(d=>d.length>0).length,a=Zs(e,!o),l=Zs(t,!o),c={pairs:a.map((d,m)=>kc(d,l[m],n))};Ze>=gc&&(we.clear(),Ze=0);const h=String(i??"auto"),u=we.get(h)??new Map;we.set(h,u);const f=u.get(e)??new Map;return u.set(e,f),f.set(t,c),Ze++,bt={from:e,to:t,shapeIndex:i,plan:c},c}function ir(e,t,n,i={}){if(!e)return t;if(!t)return e;const s=Math.max(0,Math.min(1,n));if(s===0)return e;if(s===1)return t;const r=Sc(e,t,i);if(r.pairs.length===0)return s<.5?e:t;let o="";for(const a of r.pairs){for(let l=0;l<a.from.length;l+=2){const c=Js(a.from[l]+(a.to[l]-a.from[l])*s),h=Js(a.from[l+1]+(a.to[l+1]-a.from[l+1])*s);o+=`${l===0?o?" M":"M":" L"}${c} ${h}`}a.closed&&(o+=" Z")}return o}function Mc(){we.clear(),Ze=0,bt=void 0}function Xt(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const qt=Math.PI/180,Tc=.9995;function ii(){return[0,0,0,1]}function Vt(e,t){const n=Math.hypot(e[0],e[1],e[2]);if(n===0)return ii();const i=t*qt/2,s=Math.sin(i)/n;return[e[0]*s,e[1]*s,e[2]*s,Math.cos(i)]}function Ec(e,t,n){return si(si(Vt([0,1,0],t),Vt([1,0,0],e)),Vt([0,0,1],n))}function Ac(e){const[t,n,i,s]=wt(e),r=2*(t*i+n*s),o=2*(t*n+i*s),a=1-2*(t*t+i*i),l=2*(n*i-t*s),c=1-2*(n*n+i*i),h=2*(t*i-n*s),u=1-2*(t*t+n*n),f=Math.asin(Math.max(-1,Math.min(1,-l)));return Math.abs(l)<.9999999?[f/qt,Math.atan2(r,u)/qt,Math.atan2(o,a)/qt]:[f/qt,Math.atan2(-h,c)/qt,0]}function si(e,t){const[n,i,s,r]=e,[o,a,l,c]=t;return[r*o+n*c+i*l-s*a,r*a-n*l+i*c+s*o,r*l+n*a-i*o+s*c,r*c-n*o-i*a-s*l]}function sr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function rr(e){return Math.hypot(e[0],e[1],e[2],e[3])}function wt(e){const t=rr(e);return t===0?ii():[e[0]/t,e[1]/t,e[2]/t,e[3]/t]}function xc(e){return[-e[0],-e[1],-e[2],e[3]]}function or(e,t,n){const i=wt(e);let s=wt(t),r=sr(i,s);if(r<0&&(s=[-s[0],-s[1],-s[2],-s[3]],r=-r),r>Tc)return wt([i[0]+(s[0]-i[0])*n,i[1]+(s[1]-i[1])*n,i[2]+(s[2]-i[2])*n,i[3]+(s[3]-i[3])*n]);const o=Math.acos(r),a=Math.sin(o),l=Math.sin((1-n)*o)/a,c=Math.sin(n*o)/a;return wt([i[0]*l+s[0]*c,i[1]*l+s[1]*c,i[2]*l+s[2]*c,i[3]*l+s[3]*c])}function Pc(e,t){const[n,i,s,r]=wt(e),o=2*(i*t[2]-s*t[1]),a=2*(s*t[0]-n*t[2]),l=2*(n*t[1]-i*t[0]);return[t[0]+r*o+(i*l-s*a),t[1]+r*a+(s*o-n*l),t[2]+r*l+(n*a-i*o)]}const _c=Object.freeze(Object.defineProperty({__proto__:null,conjugate:xc,dot:sr,fromAxisAngle:Vt,fromEuler:Ec,identity:ii,length:rr,multiply:si,normalize:wt,rotateVec3:Pc,slerp:or,toEuler:Ac},Symbol.toStringTag,{value:"Module"})),lt=(e,t,n)=>e+(t-e)*n,ar=512,ri=new Map,oi=new Map;function lr(e){const t=ri.get(e);if(t)return t;const n=e.replace("#",""),i=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return ri.size<ar&&ri.set(e,i),i}const cr=e=>e.charCodeAt(0)===35,hr=e=>e.startsWith("rgb"),ur=e=>e.startsWith("rgba"),Ic=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,ai=e=>Math.round(e).toString(16).padStart(2,"0");function Cc(e,t,n){return`#${ai(e)}${ai(t)}${ai(n)}`}function fr(e){const t=oi.get(e);if(t)return t;const n=e.match(Ic);if(!n)throw new Error(`Invalid rgb color: ${e}`);const i=parseInt(n[1],10),s=parseInt(n[2],10),r=parseInt(n[3],10),o=n[4]!==void 0?[i,s,r,parseFloat(n[4])]:[i,s,r];return oi.size<ar&&oi.set(e,o),o}const dr=(e,t,n)=>{if(cr(e)&&cr(t)){const[i,s,r]=lr(e),[o,a,l]=lr(t),c=lt(i,o,n),h=lt(s,a,n),u=lt(r,l,n);return Cc(c,h,u)}if((hr(e)||ur(e))&&(hr(t)||ur(t))){const i=fr(e),s=fr(t),r=Math.round(lt(i[0],s[0],n)),o=Math.round(lt(i[1],s[1],n)),a=Math.round(lt(i[2],s[2],n));if(i.length===4||s.length===4){const l=i[3]??1,c=s[3]??1,h=lt(l,c,n);return`rgba(${r}, ${o}, ${a}, ${h})`}return`rgb(${r}, ${o}, ${a})`}return n<1?e:t},pr=(e,t,n)=>{const i=Math.min(e.length,t.length),s=[];for(let r=0;r<i;r++)s.push(lt(e[r],t[r],n));return s},mr=(e,t,n)=>or(e,t,n),li=(e,t,n)=>n<1?e:t,gr=(e,t,n)=>ir(e,t,n);function ke(e,t){return t==="slerp"?mr:typeof e=="number"?lt:Array.isArray(e)?pr:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?dr:Xt(e)?gr:li:li}const ci=1e3/60;function hi(e,t={}){if(!gt(e))throw new Error(`bakeSpringTrack: track "${e.id}" is not a spring track`);const n=new pe(e.spring);return yr(e,i=>n.valueAt(i),n.settleTime(),e.spring.from,e.spring.to,t)}function ui(e,t={}){if(!mt(e))throw new Error(`bakeInertiaTrack: track "${e.id}" is not an inertia track`);const n=e.inertia;return yr(e,i=>Ge(n,i),Kt(n),n.from,Wt(n),t)}function yr(e,t,n,i,s,r){const o=r.intervalMs??ci,a=r.tolerance??.01,l=e.delay??0,c=[];for(let u=0;u<=n;u+=o)c.push({time:u+l,value:t(u),easing:"linear"});const h=c[c.length-1];return!h||h.time<n+l?c.push({time:n+l,value:s,easing:"linear"}):h.value=s,l>0&&c.unshift({time:0,value:i,easing:"linear"}),{id:e.id,target:e.target,property:e.property,keyframes:a>0?wr(c,a):c,...e.targets&&{targets:[...e.targets]},...e.stagger&&{stagger:{...e.stagger}}}}function fi(e,t,n,i={}){const s=i.intervalMs??ci,r=typeof n=="function"?n:J(n),o=ke(e.value,i.interpolation),a=t.time-e.time;if(a<=0)return[t];const l=[];for(let h=s;h<a;h+=s){const u=h/a;l.push({time:e.time+h,value:o(e.value,t.value,r(u)),easing:"linear"})}const c=r(1);return l.push({...t,...c!==1&&{value:o(e.value,t.value,c)},easing:"linear"}),l}function Hc(e,t){return gt(e)?hi(e,t):mt(e)?ui(e,t):e}function br(e,t={}){const n=e.keyframes;if(!n.some(r=>fe(r.easing)))return e;const i=n.length>0?[n[0]]:[],s={...t,interpolation:e.interpolation??t.interpolation};for(let r=1;r<n.length;r++){const o=n[r];fe(o.easing)?i.push(...fi(n[r-1],o,o.easing,s)):i.push(o)}return{...e,keyframes:i}}function $c(e,t){return e.filter(Hs).map(n=>br(n,t)).concat(e.filter(gt).map(n=>hi(n,t)),e.filter(mt).map(n=>ui(n,t)))}function wr(e,t){if(e.length<=2)return e;const n=[e[0]];for(let i=1;i<e.length-1;i++){const s=n[n.length-1],r=e[i],o=e[i+1],a=o.time-s.time;if(a<=0)continue;const l=(r.time-s.time)/a,c=s.value+(o.value-s.value)*l;Math.abs(r.value-c)>t&&n.push(r)}return n.push(e[e.length-1]),n}function Qe(e){const t=[...e.keyframes].sort((n,i)=>n.time-i.time);return{...e,keyframes:t}}function kt(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function Ut(e,t,n,i){const s=n??0;return!i||t<=1?s:s+Xe(e,t,i)}class tn{track;targets;constructor(t){this.track=t,this.targets=kt(t)}getValueAtTime(t){return this.valueForOffset(t-Ut(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=Ut(s,n,this.track.delay,this.track.stagger),o=this.valueForOffset(t-r);o!==void 0&&i.push({target:this.targets[s],value:o,start:r+this.track.keyframes[0].time})}return i}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const n=t[t.length-1].time,i=this.track.stagger?de(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+i+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:n}=this.track;if(n.length===0)return;if(n.length===1||t<=n[0].time)return n[0].value;if(t>=n[n.length-1].time)return n[n.length-1].value;const{from:i,to:s}=this.findSurroundingKeyframes(t);if(!i||!s)return;if(i.time===t)return i.value;const r=s.time-i.time,o=(t-i.time)/r,l=J(s.easing)(o);return ke(i.value,this.track.interpolation)(i.value,s.value,l)}findSurroundingKeyframes(t){const{keyframes:n}=this.track;for(let i=0;i<n.length-1;i++)if(t>=n[i].time&&t<=n[i+1].time)return{from:n[i],to:n[i+1]};return{from:null,to:null}}}class kr{track;targets;sampler;constructor(t){this.track=t,this.targets=kt(t),this.sampler=new pe(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-Ut(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=Ut(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:this.sampler.valueAt(t-r),start:r})}return i}getDuration(){const t=this.track.stagger?de(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class vr{track;targets;duration;constructor(t){this.track=t,this.targets=kt(t),this.duration=Kt(t.inertia)}getValueAtTime(t){return Ge(this.track.inertia,t-Ut(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=Ut(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:Ge(this.track.inertia,t-r),start:r})}return i}getDuration(){const t=this.track.stagger?de(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function di(e,t){const n={...js(e.pathData,t)};if(e.matrix){const[i,s,r,o,a,l]=e.matrix,{x:c,y:h}=n;n.x=i*c+r*h+a,n.y=s*c+o*h+l;const u=n.angle*Math.PI/180,f=Math.cos(u),d=Math.sin(u);n.angle=Math.atan2(s*f+o*d,i*f+r*d)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(n.angle+=e.rotateOffset),n}function Rc(e,t,n,i){const s=t+(n-t)*i;return di(e,s)}const pi={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},Oc=20;function Sr(e){const t=pi[e??"upperCase"]??e??pi.upperCase,n=Array.from(t);return n.length>0?n:Array.from(pi.upperCase)}function Lc(e,t,n){let i=(e|0)^Math.imul(t+1,2654435761)^Math.imul(n+1,2246822507);return i=Math.imul(i^i>>>16,2146121005),i=Math.imul(i^i>>>15,2221713035),(i^i>>>16)>>>0}function Mr(e,t,n=0){const i=e.from??"",s=e.to,r=Math.max(0,Math.min(1,t));if(r<=0)return i;if(r>=1)return s;const o=Array.from(i),a=Array.from(s),l=e.rightToLeft??!1;if(e.mode==="type"){const w=Math.round(r*Math.max(o.length,a.length));return l?o.slice(0,Math.max(0,o.length-w)).join("")+a.slice(Math.max(0,a.length-w)).join(""):a.slice(0,w).join("")+o.slice(w).join("")}const c=Math.max(0,Math.min(.999,e.revealDelay??0)),h=Math.max(0,(r-c)/(1-c)),u=Math.floor(h*a.length),f=e.tweenLength===!1?a.length:Math.round(o.length+(a.length-o.length)*r),d=Sr(e.chars),m=e.refreshRate??Oc,p=m>0?Math.floor(n*m/1e3):0,g=e.seed??1;let y="";for(let w=0;w<f;w++){const k=l?w>=f-u:w<u,M=l?a[a.length-(f-w)]:a[w];k&&M!==void 0||M===" "||M===`
2
+ `?y+=M:y+=d[Lc(g,w,p)%d.length]}return y}class ve{id;name;_captions;_tracks=[];_trackPlayers=new Map;_motionPathTracks=new Map;_springTracks=new Map;_textTracks=new Map;_config;_currentTime=0;_playbackState="idle";_direction="forward";_loopIteration=0;_explicitDuration;_repeatDelayRemaining=0;_wrapAfterDelay=!1;onUpdate=null;onComplete=null;constructor(t){if(this.id=t.id,this.name=t.name,this._captions=t.captions,this._config=t.config??{},this._explicitDuration=t.config?.duration,t.tracks)for(const n of t.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(t){if(this._explicitDuration=t,t!==void 0)this._config={...this._config,duration:t};else if(this._config.duration!==void 0){const n={...this._config};delete n.duration,this._config=n}}get currentTime(){return this._currentTime}get playbackState(){return this._playbackState}get direction(){return this._direction}get loopIteration(){return this._loopIteration}get repeatDelayRemaining(){return this._repeatDelayRemaining}get speed(){return this._config.speed??1}set speed(t){this._config.speed=t}get drawingRate(){return this._config.drawingRate??0}set drawingRate(t){const n={...this._config};t>0?n.drawingRate=t:delete n.drawingRate,this._config=n}play(){const t=this.duration;this._direction==="forward"&&this._currentTime>=t&&t>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&t>0&&(this._currentTime=t,this._loopIteration=0),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="idle",this._repeatDelayRemaining=0,this._wrapAfterDelay=!1,this._currentTime=0,this._loopIteration=0,this._direction="forward"}seek(t){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let s=t*this.speed;if(this._repeatDelayRemaining>0){const a=Math.min(this._repeatDelayRemaining,s);if(this._repeatDelayRemaining-=a,s-=a,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const r=1e3;for(let a=0;a<r&&s>0&&this._playbackState==="playing";a++)if(this._direction==="forward"){const l=n-this._currentTime;if(s>=l){if(s-=l,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=s,s=0}else{const l=this._currentTime;if(s>=l){if(s-=l,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=s,s=0}const o=this.getStateAtTime(this._currentTime);this.onUpdate?.(o)}getStateAtTime(t){const n=new Map;if(t=$s(t,this._config.drawingRate??0),this._hasSharedWrites())this._resolveShared(t,n);else for(const[i,s]of this._trackPlayers){const r=s.getTrack().property;for(const{target:o,value:a,start:l}of s.getTargetValues(t))this._write(n,i,o,r,a,t-l)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,n){const i=new Map;for(const[s,r]of this._trackPlayers){const o=r.getTrack().property;for(const{target:a,value:l,start:c}of r.getTargetValues(t)){const h=`${a}\0${o}`,u=c<=t,f=i.get(h);(!f||(u!==f.started?u:u?c>=f.start:c<=f.start))&&i.set(h,{trackId:s,target:a,property:o,value:l,start:c,started:u})}}for(const{trackId:s,target:r,property:o,value:a,start:l}of i.values())this._write(n,s,r,o,a,t-l)}_write(t,n,i,s,r,o){if(r===void 0)return;let a=t.get(i);a||(a=new Map,t.set(i,a));const l=this._textTracks.get(n);if(l&&typeof r=="number"){a.set("text",Mr(l.textConfig,r,Math.max(0,o)));return}const c=this._motionPathTracks.get(n);if(c&&typeof r=="number"){const h=di(c.motionPathConfig,r);a.set("motionPathX",h.x),a.set("motionPathY",h.y),c.motionPathConfig.autoRotate&&a.set("motionPathRotate",h.angle)}else a.set(s,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const i of kt(n)){const s=`${i}\0${n.property}`;if(t.has(s)){this._sharedWrites=!0;break t}t.add(s)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,mt(t)){this._trackPlayers.set(t.id,new vr(t));return}if(gt(t)){this._trackPlayers.set(t.id,new kr(t)),this._springTracks.set(t.id,t);return}if(Ye(t))this._trackPlayers.set(t.id,new tn(t)),this._textTracks.set(t.id,t);else if(Un(t)){const n={id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,delay:t.delay,endDelay:t.endDelay,targets:t.targets,stagger:t.stagger};this._trackPlayers.set(t.id,new tn(n)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new tn(t))}replaceTrack(t,n){const i=this._tracks.findIndex(r=>r.id===t);if(i<0)return;const s=this._tracks.slice(i+1);this.removeTrack(t);for(const r of s)this.removeTrack(r.id);this.addTrack(n);for(const r of s)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(n=>n.id!==t),this._sharedWrites=null,this._trackPlayers.delete(t),this._motionPathTracks.delete(t),this._springTracks.delete(t),this._textTracks.delete(t)}getTracks(t={}){return this._tracks.filter(n=>this._matches(n,t))}removeTracks(t={}){const n=this.getTracks(t).map(i=>i.id);for(const i of n)this.removeTrack(i);return n}getTrackSpan(t){const n=this._trackPlayers.get(t);if(!n)return;const i=n.getTrack(),s=i.delay??0;if(gt(i)||mt(i))return{from:s,to:n.getDuration()};const r=i.keyframes;if(!(!r||r.length===0))return{from:r[0].time+s,to:n.getDuration()}}findConflicts(){const t=[];for(let n=0;n<this._tracks.length;n++){const i=this._tracks[n],s=this.getTrackSpan(i.id);if(s)for(let r=0;r<n;r++){const o=this._tracks[r];if(o.property!==i.property)continue;const a=kt(o).filter(u=>kt(i).includes(u));if(a.length===0)continue;const l=this.getTrackSpan(o.id);if(!l||!(l.from<=s.to&&s.from<=l.to))continue;const h=s.from>=l.from;for(const u of a)t.push({target:u,property:i.property,losingTrackId:h?o.id:i.id,winningTrackId:h?i.id:o.id})}}return t}_matches(t,n){if(n.id!==void 0&&t.id!==n.id||n.property!==void 0&&t.property!==n.property||n.target!==void 0&&!kt(t).includes(n.target))return!1;if(n.timeRange){const i=this.getTrackSpan(t.id);if(!i||i.to<n.timeRange.from||i.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:Vn(this._tracks),id:this.id,name:this.name,config:{...this._config},tracks:[...this._tracks],...this.captions&&{captions:this.captions}}}get config(){return this._config}get markers(){return[...this._config.markers??[]].sort((t,n)=>t.time-n.time)}setMarkers(t){const n=t&&t.length>0?[...t].sort((s,r)=>s.time-r.time).map(s=>({...s})):void 0,i={...this._config};n?i.markers=n:delete i.markers,this._config=i}get captions(){return this._captions}setCaptions(t){const n={};for(const[i,s]of Object.entries(t??{}))n[i]={...s};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,n]of this._trackPlayers)t=Math.max(t,n.getDuration());return t}_handleEndReached(){const t=this._config.loop??0;return t===-1||this._loopIteration<t?(this._loopIteration++,this._armRepeatDelay(),this._config.alternate?this._direction="reverse":this._repeatDelayRemaining>0?this._wrapAfterDelay=!0:this._currentTime=0,this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}_handleStartReached(){const t=this._config.loop??0;return this._config.alternate&&(t===-1||this._loopIteration<t)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const Fc=100;function mi(e,t,n,i){const s=[],r=[],{duration:o,alternate:a}=i,l=(d,m,p,g)=>{r.push([d,m]);const y=[];e.forEach((w,k)=>{(p==="forward"?(g?w>=d:w>d)&&w<=m:(g?w<=d:w<d)&&w>=m)&&y.push(k)}),y.sort((w,k)=>(p==="forward"?e[w]-e[k]:e[k]-e[w])||w-k);for(const w of y)s.push({kind:"event",index:w,direction:p})};let c=t.time,h=t.direction,u=t.fresh===!0;const f=Math.min(Fc,Math.max(0,n.iteration-t.iteration));for(let d=0;d<f;d++){const m=h==="forward"?o:0;l(c,m,h,u),s.push({kind:"repeat"}),a?(h=h==="forward"?"reverse":"forward",c=m,u=!1):(c=h==="forward"?0:o,u=!0)}return f>0&&i.holding&&!a?{crossings:s,passes:r}:(l(c,n.time,h,u),{crossings:s,passes:r})}function Tr(e){return mt(e)?{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:Er(e.inertia),...ct(e)}:gt(e)?{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...ct(e)}:Ye(e)?{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:e.keyframes.map(gi),...ct(e)}:Un(e)?{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:e.keyframes.map(gi),...ct(e)}:{id:e.id,target:e.target,property:e.property,keyframes:e.keyframes.map(gi),...e.interpolation!==void 0&&{interpolation:e.interpolation},...ct(e)}}function Er(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function gi(e){return{time:e.time,value:e.value,...e.easing&&{easing:e.easing}}}function ct(e){const t=e.endDelay;return{...e.delay!==void 0&&{delay:e.delay},...t!==void 0&&{endDelay:t},...e.targets!==void 0&&{targets:[...e.targets]},...e.stagger!==void 0&&{stagger:{...e.stagger}}}}function Ar(e){if(mt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Er(t.inertia),...ct(t)}}if(gt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...ct(t)}}if(Ye(e)){const t=e;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((n,i)=>n.time-i.time),...ct(t)}}if(e.property==="motionPath"&&"motionPathConfig"in e){const t=e,n=[...t.keyframes].sort((i,s)=>i.time-s.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:n,...ct(t)}}return Qe({id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,...e.interpolation!==void 0&&{interpolation:e.interpolation},...ct(e)})}function xr(e){const t=e._config.markers;return{formatVersion:Vn(e.tracks),id:e.id,name:e.name,config:{duration:e.duration>0?e.duration:void 0,loop:e._config.loop,speed:e._config.speed,alternate:e._config.alternate,repeatDelay:e._config.repeatDelay,...e._config.drawingRate?{drawingRate:e._config.drawingRate}:{},...t&&{markers:t.map(n=>({...n}))}},tracks:e.tracks.map(Tr),...e.captions&&{captions:JSON.parse(JSON.stringify(e.captions))}}}function zt(e){const t=e.formatVersion??1;if(t>qn)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${qn}. Update tinyfly to play it.`);return new ve({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(Ar),captions:e.captions})}function Dc(e){return JSON.stringify(xr(e))}function Bc(e){const t=JSON.parse(e);return zt(t)}function Gt(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function Se(e){let t=e>>>0||2654435769;return{seed:e>>>0,next(){return t^=t<<13,t>>>=0,t^=t>>17,t^=t<<5,t>>>=0,t/4294967296}}}function yi(e,t,n){return t+e.next()*(n-t)}function Pr(e,t,n,i){if(i<=0)return yi(e,t,n);const s=Math.floor((n-t)/i),r=Math.round(e.next()*s);return t+r*i}function Nc(e,t){if(t.length!==0)return t[Math.floor(e.next()*t.length)]}const _r=/^([+\-*/])=\s*(-?[\d.]+)$/,Ir=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Wc(e){return typeof e!="string"?!1:_r.test(e.trim())||Ir.test(e.trim())}function bi(e,t={}){if(typeof e!="string")return e;const n=e.trim(),i=_r.exec(n);if(i){const[,r,o]=i,a=t.base??0,l=Number.parseFloat(o);switch(r){case"+":return a+l;case"-":return a-l;case"*":return a*l;case"/":return l===0?a:a/l}}const s=Ir.exec(n);if(s){if(!t.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const r=Number.parseFloat(s[1]),o=Number.parseFloat(s[2]),a=s[3]!==void 0?Number.parseFloat(s[3]):void 0;return a!==void 0?Pr(t.random,r,o,a):yi(t.random,r,o)}return e}function Cr(e,t=0,n){const i=[];let s=t;for(const r of e){const o=bi(r,{base:s,random:n});i.push(o),typeof o=="number"&&(s=o)}return i}class Kc{random;constructor(t){this.random=Se(t)}get seed(){return this.random.seed}resolve(t,n=0){return bi(t,{base:n,random:this.random})}resolveSequence(t,n=0){return Cr(t,n,this.random)}}const Yc=600;function Hr(e){if(Array.isArray(e)){const[f,d,m,p]=e;return{fn:Or(f,d,m,p),bezier:[f,d,m,p]}}const{segments:t}=Pt(e);if(t.length===0)throw new Error(`customEase: no curve in "${e}"`);const n=t[0].startX,i=t[0].startY,s=t[t.length-1],r=s.endX-n,o=s.endY-i;if(r===0||o===0)throw new Error(`customEase: "${e}" must move along both axes`);const a=f=>(f-n)/r,l=f=>(f-i)/o;if(t.length===1&&s.type==="C"){const[f,d,m,p]=s.points,g=[a(f),l(d),a(m),l(p)];return{fn:Or(...g),bezier:g}}const c=[],h=[],u=Math.max(8,Math.ceil(Yc/t.length));for(const f of t)for(let d=c.length===0?0:1;d<=u;d++){const[m,p]=Xc(f,d/u);c.push(a(m)),h.push(l(p))}return{fn:qc(c,h)}}function $r(e={}){const n=.1+Math.max(0,Math.min(1,e.strength??.7))*.7,i=[1];for(let r=n;r>.002;r*=n)i.push(2*Math.sqrt(r));const s=i.reduce((r,o)=>r+o,0);return r=>{if(r<=0)return 0;if(r>=1)return 1;let o=r*s;for(let a=0;a<i.length;a++){if(o<=i[a]){if(a===0)return(o/i[0])**2;const l=i[a]/2,c=l*l,h=o-l;return 1-(c-h*h)}o-=i[a]}return 1}}function Rr(e={}){const t=Math.max(1,e.wiggles??10),n=e.type??"easeOut",i=s=>n==="uniform"?1:n==="easeInOut"?Math.sin(Math.PI*s):(1-s)**2;return s=>s<=0||s>=1?0:Math.sin(s*t*Math.PI*2)*i(s)}function Xc(e,t){if(e.type==="L"){const[c,h]=e.points;return[e.startX+(c-e.startX)*t,e.startY+(h-e.startY)*t]}const[n,i,s,r,o,a]=e.points,l=1-t;return[l*l*l*e.startX+3*l*l*t*n+3*l*t*t*s+t*t*t*o,l*l*l*e.startY+3*l*l*t*i+3*l*t*t*r+t*t*t*a]}function qc(e,t){return n=>{if(n<=e[0])return t[0];if(n>=e[e.length-1])return t[t.length-1];let i=0,s=e.length-1;for(;s-i>1;){const o=i+s>>1;e[o]<=n?i=o:s=o}const r=e[s]-e[i];return r===0?t[s]:t[i]+(n-e[i])/r*(t[s]-t[i])}}function Or(e,t,n,i){const s=(o,a,l)=>3*(1-o)*(1-o)*o*a+3*(1-o)*o*o*l+o*o*o,r=(o,a,l)=>3*(1-o)*(1-o)*a+6*(1-o)*o*(l-a)+3*o*o*(1-l);return o=>{if(o<=0)return 0;if(o>=1)return 1;let a=o;for(let h=0;h<8;h++){const u=s(a,e,n)-o,f=r(a,e,n);if(Math.abs(u)<1e-6)return s(a,t,i);if(Math.abs(f)<1e-6)break;a-=u/f}let l=0,c=1;a=o;for(let h=0;h<40;h++)s(a,e,n)<o?l=a:c=a,a=(l+c)/2;return s(a,t,i)}}const Vc=350,Uc=300,zc=550;function Gc(e,t={}){const n=t.lead??Vc,i=t.gap??Uc,s=t.tail??zc,r=[];let o=0;return e.forEach((a,l)=>{const c=[];let h=o+n;a.lines.forEach((f,d)=>{if(!(f.duration>=0))throw new Error(`narration: scene ${l} line ${d} has an invalid duration (${f.duration})`);d>0&&(h+=i),c.push({id:f.id??`s${l}-l${d}`,scene:l,line:d,start:h,end:h+f.duration,text:f.text}),h+=f.duration});const u=h+s+(a.tail??0);r.push({id:a.id??`s${l}`,start:o,duration:u-o,cues:c}),o=u}),{duration:o,scenes:r,cues:r.flatMap(a=>a.cues)}}function jc(e){return e.cues.map(t=>({id:t.id,time:t.start,label:t.text}))}function Jc(e,t){let n=e.scenes[0];for(const i of e.scenes)if(t>=i.start)n=i;else break;return n}const wi=e=>6e4/e.bpm;function en(e,t){return e.offset+t*wi(e)}function nn(e,t){return(t-e.offset)/wi(e)}function Zc(e,t){return en(e,Math.round(nn(e,t)))}function Qc(e,t){return en(e,Math.ceil(nn(e,t)-1e-9))}function th(e,t,n){const i=Math.max(1,Math.round(e.beatsPerBar??4)),s=[];if(!(e.bpm>0)||n<t)return s;for(let r=Math.ceil(nn(e,t)-1e-9);;r++){const o=en(e,r);if(o>n+1e-9)break;s.push({time:o,bar:(r%i+i)%i===0,n:r})}return s}const jt=100;function eh(e,t,n={}){const i=n.minBpm??70,s=n.maxBpm??180,r=Math.max(1,Math.round(t/jt)),o=Math.min(e.length,Math.round((n.maxSeconds??60)*t)),a=Math.floor(o/r);if(a<4)return{bpm:120,offset:0,confidence:0};const l=new Float64Array(a);for(let v=0;v<a;v++){let _=0;for(let P=v*r;P<(v+1)*r;P++)_+=e[P]*e[P];l[v]=Math.log(1e-6+_/r)}const c=new Float64Array(a);for(let v=1;v<a;v++)c[v]=Math.max(0,l[v]-l[v-1]);const h=c.reduce((v,_)=>v+_,0)/a;for(let v=0;v<a;v++)c[v]=Math.max(0,c[v]-h);const u=Math.max(1,Math.floor(60*jt/s)),f=Math.min(a-1,Math.ceil(60*jt/i)),d=v=>{let _=0;for(let P=v;P<a;P++)_+=c[P]*c[P-v];return _/(a-v)};let m=0;for(let v=0;v<a;v++)m+=c[v]*c[v];m/=a;let p=u,g=-1/0;for(let v=u;v<=f;v++){const _=60*jt/v,P=Math.exp(-.5*(Math.log2(_/120)/.9)**2),x=d(v)*P;x>g&&(g=x,p=v)}const y=v=>{const _=Math.floor(v);return _<0||_+1>=a?0:c[_]+(c[_+1]-c[_])*(v-_)},w=(v,_)=>{let P=0;for(let x=_;x<a;x+=v)P+=y(x);return P};let k=p,M=0,S=-1/0;for(let v=p-.6;v<=p+.6+1e-9;v+=.02){if(v<1)continue;const _=Math.max(1,Math.round(v*4));for(let P=0;P<_;P++){const x=P/_*v,I=w(v,x);I>S&&(S=I,M=x,k=v)}}const A=60*jt/k,E=m>0?Math.max(0,Math.min(1,d(p)/m)):0,T=(M+.5)*1e3/jt;return{bpm:Math.round(A*100)/100,offset:Math.round(T%(6e4/A)),confidence:E}}const nh=600,ih=250,Lr=1;function sh(e,t){const n=t.target??"Camera",i={x:t.stage.width/2,y:t.stage.height/2},s={},r=(u,f,d,m)=>{const p=s[u]??=[];for(;p.length>0&&p[p.length-1].time>=f;)p.pop();p.push({time:f,value:d,...m?{easing:m}:{}})},o=u=>{const f=u.rotate*Math.PI/180,d=(u.focusX-i.x)*u.scale,m=(u.focusY-i.y)*u.scale;return{x:-(d*Math.cos(f)-m*Math.sin(f)),y:-(d*Math.sin(f)+m*Math.cos(f)),scale:u.scale,rotate:u.rotate}},a=(u,f,d)=>{const m=o(f);for(const p of["x","y","scale","rotate"])r(p,u,m[p],d)};let l={focusX:i.x,focusY:i.y,scale:1,rotate:0};const c=[...e].sort((u,f)=>u.at-f.at),h=c.filter(u=>!("shake"in u));h.length>0&&a(0,l);for(const u of h)if("frame"in u){const f=Math.max(Lr,u.duration??nh);a(u.at,l),l={focusX:u.frame.focus?.x??i.x,focusY:u.frame.focus?.y??i.y,scale:u.frame.scale??1,rotate:u.frame.rotate??0},a(u.at+f,l,u.easing??(f>Lr?"ease-in-out":void 0))}else{const{follow:f}=u,d=f.lag??ih,m=new ve({id:"follow",tracks:[{id:"x",target:"s",property:"x",keyframes:f.x}]}),p=w=>m.getStateAtTime(w).values.get("s")?.get("x")??l.focusX,g=[u.at,...f.x.map(w=>w.time).filter(w=>w>u.at&&w<u.until),u.until];a(u.at,l);const y=w=>({focusX:p(w)+(f.lead??0),focusY:f.y??l.focusY,scale:f.scale??l.scale,rotate:l.rotate});for(const w of g){const k=f.x.find(M=>M.time===w)?.easing;a(w+d,y(w),w===u.at?"ease-in-out":k)}l=y(u.until)}for(const u of c.filter(f=>"shake"in f)){const f=u.shake.strength??12,d=u.shake.roll??1.5,m=1e3/(u.shake.frequency??24),p=Se(u.shake.seed??Math.round(u.at)+1),g=()=>p.next()*2-1;for(const y of["shakeX","shakeY","shakeRotate"])r(y,u.at,0);for(let y=u.at+m;y<u.at+u.duration;y+=m){const w=1-(y-u.at)/u.duration;r("shakeX",y,g()*f*w),r("shakeY",y,g()*f*w),r("shakeRotate",y,g()*d*w)}for(const y of["shakeX","shakeY","shakeRotate"])r(y,u.at+u.duration,0,"ease-out")}return Object.entries(s).map(([u,f])=>({id:`${n}-${u}`,target:n,property:u,keyframes:f}))}const ht=e=>Math.round(e*1e3)/1e3;function Fr(e,t={}){if(e.length===0)return"";const n=t.curviness??1,i=t.closed??!1,s=e.length;let r=`M${ht(e[0].x)} ${ht(e[0].y)}`;if(s===1)return r;const o=l=>i?e[(l%s+s)%s]:e[Math.max(0,Math.min(s-1,l))],a=i?s:s-1;for(let l=0;l<a;l++){const c=o(l-1),h=o(l),u=o(l+1),f=o(l+2);if(n===0){r+=` L${ht(u.x)} ${ht(u.y)}`;continue}const d=n/6,m=h.x+(u.x-c.x)*d,p=h.y+(u.y-c.y)*d,g=u.x-(f.x-h.x)*d,y=u.y-(f.y-h.y)*d;r+=` C${ht(m)} ${ht(p)} ${ht(g)} ${ht(y)} ${ht(u.x)} ${ht(u.y)}`}return i?`${r} Z`:r}const V=(e,t=0)=>{const n=parseFloat(e??"");return Number.isFinite(n)?n:t};function rh(e){const t=(e??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let i=0;i+1<t.length;i+=2)n.push({x:t[i],y:t[i+1]});return n}function sn(e){const t=e.attributes;switch(e.tag.toLowerCase()){case"path":return t.d??null;case"circle":case"ellipse":{const n=V(t.cx),i=V(t.cy),s=e.tag.toLowerCase()==="circle"?V(t.r):V(t.rx),r=e.tag.toLowerCase()==="circle"?V(t.r):V(t.ry);return`M${n+s} ${i} A${s} ${r} 0 1 1 ${n-s} ${i} A${s} ${r} 0 1 1 ${n+s} ${i} Z`}case"rect":{const n=V(t.x),i=V(t.y),s=V(t.width),r=V(t.height);let o=t.rx!=null?V(t.rx):t.ry!=null?V(t.ry):0,a=t.ry!=null?V(t.ry):o;return o=Math.min(o,s/2),a=Math.min(a,r/2),o===0||a===0?`M${n} ${i} H${n+s} V${i+r} H${n} Z`:`M${n+o} ${i} H${n+s-o} A${o} ${a} 0 0 1 ${n+s} ${i+a} V${i+r-a} A${o} ${a} 0 0 1 ${n+s-o} ${i+r} H${n+o} A${o} ${a} 0 0 1 ${n} ${i+r-a} V${i+a} A${o} ${a} 0 0 1 ${n+o} ${i} Z`}case"line":return`M${V(t.x1)} ${V(t.y1)} L${V(t.x2)} ${V(t.y2)}`;case"polyline":case"polygon":{const n=rh(t.points);if(n.length===0)return null;const i=n.map((s,r)=>`${r===0?"M":"L"}${s.x} ${s.y}`).join(" ");return e.tag.toLowerCase()==="polygon"?`${i} Z`:i}default:return null}}function oh(e,t,n){const i=Math.max(2,Math.round(n.samples??32)),s=Math.max(0,n.length),r=n.since!==void 0?Math.max(t-s,n.since):t-s;if(r>=t)return[];const o=n.period,a=[];for(let l=0;l<i;l++){const c=r+(t-r)*l/(i-1),h=o&&o>0&&l<i-1?(c%o+o)%o:c;a.push({at:e(h),time:c,age:s>0?(t-c)/s:0})}return a}const ah=2.5;function Dr(e){const t=[],n=[],i=e.length,s=(r,o)=>{for(let a=r+o;a>=0&&a<i;a+=o){const l=(e[a].x-e[r].x)*o,c=(e[a].y-e[r].y)*o,h=Math.hypot(l,c);if(h>1e-9)return[l/h,c/h]}return null};for(let r=0;r<i;r++){const o=e[r],a=s(r,-1),l=s(r,1),c=a??l??[1,0],h=l??a??[1,0];let u=c[0]+h[0],f=c[1]+h[1];const d=Math.hypot(u,f);d<1e-9?(u=c[0],f=c[1]):(u/=d,f/=d);const m=u*c[0]+f*c[1],p=Math.min(ah,1/Math.max(m,1e-6)),g=o.width/2*p;t.push({x:o.x-f*g,y:o.y+u*g}),n.push({x:o.x+f*g,y:o.y-u*g})}return{left:t,right:n}}function Br(e){const t=e.length;if(t<2)return null;const n=e[t-1];for(let i=t-2;i>=0;i--){const s=n.x-e[i].x,r=n.y-e[i].y,o=Math.hypot(s,r);if(o>1e-9)return{x:n.x,y:n.y,radius:n.width/2,start:Math.atan2(s/o,-r/o)}}return null}function rn(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function on(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function Me(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function Te(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function an(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function ki(e){return Math.hypot(e[0],e[1],e[2])}function Nr(e,t){return ki(on(e,t))}function Ee(e){const t=ki(e);return t===0?[0,0,0]:Me(e,1/t)}function Wr(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}const lh=Object.freeze(Object.defineProperty({__proto__:null,add:rn,cross:an,distance:Nr,dot:Te,length:ki,lerp:Wr,normalize:Ee,scale:Me,subtract:on},Symbol.toStringTag,{value:"Module"})),ch=Math.PI/180;function Kr(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function _t(e,t){const n=new Array(16);for(let i=0;i<4;i++)for(let s=0;s<4;s++){let r=0;for(let o=0;o<4;o++)r+=e[o*4+s]*t[i*4+o];n[i*4+s]=r}return n}function Yr(e){return[1,0,0,0,0,1,0,0,0,0,1,0,e[0],e[1],e[2],1]}function ln(e){return[e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,1]}function Ae(e){const[t,n,i,s]=e;return[1-2*(n*n+i*i),2*(t*n+i*s),2*(t*i-n*s),0,2*(t*n-i*s),1-2*(t*t+i*i),2*(n*i+t*s),0,2*(t*i+n*s),2*(n*i-t*s),1-2*(t*t+n*n),0,0,0,0,1]}function Xr(e,t,n){const i=Ae(t);for(let s=0;s<3;s++)i[s]*=n[0],i[4+s]*=n[1],i[8+s]*=n[2];return i[12]=e[0],i[13]=e[1],i[14]=e[2],i}function hh(e){const t=new Array(16);for(let n=0;n<4;n++)for(let i=0;i<4;i++)t[i*4+n]=e[n*4+i];return t}function uh(e){const[t,n,i,s,r,o,a,l,c,h,u,f,d,m,p,g]=e,y=t*o-n*r,w=t*a-i*r,k=t*l-s*r,M=n*a-i*o,S=n*l-s*o,A=i*l-s*a,E=c*m-h*d,T=c*p-u*d,v=c*g-f*d,_=h*p-u*m,P=h*g-f*m,x=u*g-f*p,I=y*x-w*P+k*_+M*v-S*T+A*E;if(Math.abs(I)<1e-12)return null;const C=1/I;return[(o*x-a*P+l*_)*C,(i*P-n*x-s*_)*C,(m*A-p*S+g*M)*C,(u*S-h*A-f*M)*C,(a*v-r*x-l*T)*C,(t*x-i*v+s*T)*C,(p*k-d*A-g*w)*C,(c*A-u*k+f*w)*C,(r*P-o*v+l*E)*C,(n*v-t*P-s*E)*C,(d*S-m*k+g*y)*C,(h*k-c*S-f*y)*C,(o*T-r*_-a*E)*C,(t*_-n*T+i*E)*C,(m*w-d*M-p*y)*C,(c*M-h*w+u*y)*C]}function fh(e,t,n,i){const s=1/Math.tan(e*ch/2),r=1/(n-i);return[s/t,0,0,0,0,s,0,0,0,0,(i+n)*r,-1,0,0,2*i*n*r,0]}function dh(e,t,n,i,s,r){const o=1/(t-e),a=1/(i-n),l=1/(r-s);return[2*o,0,0,0,0,2*a,0,0,0,0,-2*l,0,-(t+e)*o,-(i+n)*a,-(r+s)*l,1]}function ph(e,t,n=[0,1,0]){const i=Ee(on(e,t)),s=Ee(an(n,i)),r=an(i,s);return[s[0],r[0],i[0],0,s[1],r[1],i[1],0,s[2],r[2],i[2],0,-Te(s,e),-Te(r,e),-Te(i,e),1]}function qr(e,t){const n=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12],i=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13],s=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14],r=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15];return r===1||r===0?[n,i,s]:[n/r,i/r,s/r]}const mh=Object.freeze(Object.defineProperty({__proto__:null,compose:Xr,fromQuat:Ae,identity:Kr,invert:uh,lookAt:ph,multiply:_t,orthographic:dh,perspective:fh,scaling:ln,transformPoint:qr,translation:Yr,transpose:hh},Symbol.toStringTag,{value:"Module"})),cn={"power1.in":[.55,.085,.68,.53],"power1.out":[.25,.46,.45,.94],"power1.inout":[.455,.03,.515,.955],"power2.in":[.55,.055,.675,.19],"power2.out":[.215,.61,.355,1],"power2.inout":[.645,.045,.355,1],"power3.in":[.895,.03,.685,.22],"power3.out":[.165,.84,.44,1],"power3.inout":[.77,0,.175,1],"power4.in":[.755,.05,.855,.06],"power4.out":[.23,1,.32,1],"power4.inout":[.86,0,.07,1],"sine.in":[.47,0,.745,.715],"sine.out":[.39,.575,.565,1],"sine.inout":[.445,.05,.55,.95],"expo.in":[.95,.05,.795,.035],"expo.out":[.19,1,.22,1],"expo.inout":[1,0,0,1],"circ.in":[.6,.04,.98,.335],"circ.out":[.075,.82,.165,1],"circ.inout":[.785,.135,.15,.86],"back.in":[.6,-.28,.735,.045],"back.out":[.175,.885,.32,1.275],"back.inout":[.68,-.55,.265,1.55]},Vr={none:"linear",linear:"linear","linear.none":"linear","power1.in":"ease-in-quad","power1.out":"ease-out-quad","power1.inout":"ease-in-out-quad","power2.in":"ease-in-cubic","power2.out":"ease-out-cubic","power2.inout":"ease-in-out-cubic"};function gh(e){let t=e.trim().toLowerCase();t=t.replace(/\.ease(in|out|inout)$/,".$1");const n=/^([a-z]+\d?)(\(.*\))?$/.exec(t);return n&&n[1]!=="steps"&&t!=="none"&&t!=="linear"&&(t=`${n[1]}.out${n[2]??""}`),t}J({type:"bounce",mode:"in"}),J({type:"bounce",mode:"in-out"});function xe(e){const t=Ur.get(e.trim().toLowerCase());if(t)return t;const n=gh(e),i=/^steps\(\s*(\d+)\s*\)$/.exec(n);if(i){const o={type:"steps",count:Math.max(1,Number.parseInt(i[1],10))+1,position:"none"};return{easing:o,fn:J(o)}}const s=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(s){const[,r,o,a]=s,l=(a??"").split(",").map(u=>Number.parseFloat(u)).filter(u=>Number.isFinite(u)),c=o==="inout"?"in-out":o;if(r==="back"&&l.length===0&&n in cn)return{easing:{type:"cubic-bezier",points:cn[n]}};const h=r==="elastic"?{type:"elastic",mode:c,...l[0]!==void 0&&{amplitude:l[0]},...l[1]!==void 0&&{period:l[1]}}:r==="bounce"?{type:"bounce",mode:c}:{type:"back",mode:c,...l[0]!==void 0&&{overshoot:l[0]}};return{easing:h,fn:J(h)}}return n in Vr?{easing:Vr[n]}:n in cn?{easing:{type:"cubic-bezier",points:cn[n]}}:{easing:"ease-out"}}const Ur=new Map;function vi(e,t){return Ur.set(e.trim().toLowerCase(),t.bezier?{easing:{type:"cubic-bezier",points:t.bezier},fn:t.fn}:{fn:t.fn,requiresBaking:"custom"}),e}function Si(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=t;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}const zr=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function Gr(e){return typeof e=="string"&&zr.test(e)}function yh(e=1){let t=Si(e);const n=(l,c)=>((...h)=>h.length>=l?c(...h):u=>c(...h,u)),i=(l,c,h)=>Math.min(Math.max(h,Math.min(l,c)),Math.max(l,c)),s=(l,c,h,u,f)=>c===l?h:h+(f-l)/(c-l)*(u-h),r=(l,c)=>{if(typeof l=="number")return l===0?c:Math.round(c/l)*l;if(Array.isArray(l))return jr(l,c,1/0);if("values"in l)return jr(l.values,c,l.radius??1/0);const h=Math.round(c/l.increment)*l.increment;return Math.abs(h-c)<=(l.radius??1/0)?h:c},o=(l,c,h)=>{const u=l+t()*(c-l);return h?Math.round(u/h)*h:u};return{clamp:n(3,i),mapRange:n(5,s),normalize:n(3,(l,c,h)=>s(l,c,0,1,h)),interpolate:n(3,(l,c,h)=>{if(typeof l=="object"&&!Array.isArray(l)){const u={};for(const f of Object.keys(l))u[f]=ke(l[f])(l[f],c[f],h);return u}return ke(l)(l,c,h)}),wrap:((l,c,h)=>{if(Array.isArray(l)){const p=l,g=y=>p[(Math.round(y)%p.length+p.length)%p.length];return c===void 0?g:g(c)}const u=l,d=c-u,m=p=>d===0?u:((p-u)%d+d)%d+u;return h===void 0?m:m(h)}),wrapYoyo:n(3,(l,c,h)=>{const u=c-l;if(u===0)return l;const f=((h-l)%(u*2)+u*2)%(u*2);return l+(f>u?u*2-f:f)}),snap:n(2,r),random:((l,c,h,u)=>{if(Array.isArray(l)){const d=()=>l[Math.floor(t()*l.length)];return c===!0?d:d()}const f=()=>o(l,c,h);return u?f:f()}),shuffle:l=>{for(let c=l.length-1;c>0;c--){const h=Math.floor(t()*(c+1));[l[c],l[h]]=[l[h],l[c]]}return l},distribute:({base:l=0,amount:c,each:h,from:u="start",ease:f})=>(d,m,p)=>{const g=p.length,w=Xe(d,g,{...c!==void 0?{amount:c}:{each:h??1},from:u}),k=c!==void 0?c:(h??1)*Gn(g,u),M=f&&k>0?f(w/k)*k:w;return l+M},pipe:(...l)=>c=>l.reduce((h,u)=>u(h),c),splitColor:l=>bh(l),getUnit:l=>typeof l=="number"?"":/^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(l.trim())?.[1]??"",seed:l=>{t=Si(l)},resolveRandomString:l=>{const c=zr.exec(l)?.[1]??"";if(c.startsWith("[")){const m=c.slice(1,-1).split(",").map(p=>p.trim()).filter(Boolean).map(p=>Number.isFinite(Number(p))?Number(p):p.replace(/^['"]|['"]$/g,""));return m[Math.floor(t()*m.length)]}const[h,u,f]=c.split(",").map(d=>Number.parseFloat(d));return o(h,u,Number.isFinite(f)?f:void 0)}}}function jr(e,t,n){let i=t,s=1/0;for(const r of e){const o=Math.abs(r-t);o<s&&(s=o,i=r)}return s<=n?i:t}function bh(e){const t=e.trim(),n=/^#([0-9a-f]{3,8})$/i.exec(t)?.[1];if(n){const r=(n.length<=4?[...n].map(o=>o+o).join(""):n).match(/../g).map(o=>Number.parseInt(o,16));return r.length>=4?[r[0],r[1],r[2],Math.round(r[3]/255*1e3)/1e3]:[r[0],r[1],r[2]]}const i=(/rgba?\(([^)]+)\)/i.exec(t)?.[1]??"0,0,0").split(/[\s,/]+/).filter(Boolean).map(s=>Number.parseFloat(s));return i.length>=4?[i[0],i[1],i[2],i[3]]:[i[0]??0,i[1]??0,i[2]??0]}const wh=/^([+-])=\s*(-?[\d.]+)$/,kh=/^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;function Pe(e,t){const n=t.scale??1,i=c=>Number.parseFloat(c)*n;if(e===void 0)return t.cursor;if(typeof e=="number")return e*n;const s=e.trim();if(s==="")return t.cursor;const r=wh.exec(s);if(r){const c=i(r[2]);return t.cursor+(r[1]==="-"?-c:c)}const o=kh.exec(s);if(o){const c=o[1]==="<"?t.previousStart:t.previousEnd;if(o[3]===void 0)return c;const h=i(o[3]);return c+(o[2]==="-"?-h:h)}const a=/^(.+?)([+-])=\s*(-?[\d.]+)$/.exec(s);if(a){const c=t.labels.get(a[1].trim());if(c!==void 0){const h=i(a[3]);return c+(a[2]==="-"?-h:h)}}const l=t.labels.get(s);return l!==void 0?l:/^-?[\d.]+$/.test(s)?i(s):t.cursor}function vh(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.grid!==void 0||t.from==="random"||Array.isArray(t.from)||t.ease!==void 0||t.axis!==void 0}function Sh(e,t,n={}){if(e===0)return[];const i=t.grid==="auto"?Math.max(1,Math.min(e,n.columnsFromLayout?.()??e)):Array.isArray(t.grid)?Math.max(1,t.grid[1]):e,s=Array.isArray(t.grid)?Math.max(1,t.grid[0]):Math.ceil(e/i),r=m=>({x:m%i,y:Math.floor(m/i)}),o=t.from??"start",a=Array.isArray(o)?{x:o[0]*(i-1),y:o[1]*(s-1)}:typeof o=="number"?r(Math.max(0,Math.min(e-1,o))):o==="end"?r(e-1):o==="center"||o==="edges"?{x:(i-1)/2,y:(s-1)/2}:{x:0,y:0},l=m=>{const{x:p,y:g}=r(m),y=Math.abs(p-a.x),w=Math.abs(g-a.y);return t.axis==="x"?y:t.axis==="y"?w:Math.hypot(y,w)};let c=Array.from({length:e},(m,p)=>l(p));const h=Math.max(...c);if(o==="edges"&&(c=c.map(m=>h-m)),o==="random"){const m=n.random??Math.random;c=c.map(()=>m()*h)}const u=t.amount!==void 0?t.amount:(t.each??0)*h,f=t.ease?xe(t.ease):void 0,d=f?f.fn??J(f.easing):void 0;return c.map(m=>{const p=h===0?0:m/h;return(d?d(p):p)*u})}const Mi=new Set(["duration","delay","ease","repeat","repeatDelay","yoyo","stagger","onComplete","onUpdate","onStart","onRepeat","onReverseComplete","repeatRefresh","keyframes","easeEach","scrollTo","id","immediateRender","overwrite","paused","scrollTrigger","spring"]),Mh={rotation:"rotate",rotationZ:"rotate",rotationX:"rotateX",rotationY:"rotateY",transformPerspective:"perspective",perspective:"childPerspective"};function hn(e){const t={},n={};for(const[i,s]of Object.entries(e))Mi.has(i)?t[i]=s:n[Mh[i]??i]=s;return{config:t,properties:n}}function un(e,t){return e===void 0?t:e*1e3}function Ti(e,t){if(e!==void 0)return typeof e=="number"?{each:e*1e3}:vh(e)?{offsets:Sh(t?.count??0,e,t??{}).map(i=>i*1e3)}:{...e.each!==void 0&&{each:e.each*1e3},...e.amount!==void 0&&{amount:e.amount*1e3},...e.from!==void 0&&{from:e.from}}}const Th={opacity:1,x:0,y:0,z:0,rotate:0,rotateX:0,rotateY:0,rotateZ:0,scale:1,scaleX:1,scaleY:1,scaleZ:1,skewX:0,skewY:0,originX:50,originY:50,perspective:0,blur:0,glow:0,clipTop:0,clipRight:0,clipBottom:0,clipLeft:0};function Jr(e){return Th[e]}function Eh(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:e;if(!t||typeof t.path!="string"&&!Array.isArray(t.path))throw new Error("gsap-compat: motionPath needs a path — SVG path data or an array of { x, y } points.");let n;if(Array.isArray(t.path))n=Fr(t.path,{curviness:t.curviness});else if(Xt(t.path))n=t.path;else throw new Error(`gsap-compat: motionPath "${t.path}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);const i={pathData:n};return t.autoRotate!==void 0&&t.autoRotate!==!1&&(i.autoRotate=!0,typeof t.autoRotate=="number"&&(i.rotateOffset=t.autoRotate)),t.matrix&&(i.matrix=t.matrix),{config:i,start:t.start??0,end:t.end??1}}function Ah(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:{...e};return{...t,start:t.end??1,end:t.start??0}}function Zr(e){return typeof e=="object"&&e!==null&&"shape"in e?e.shape:e}function xh(e){if(e.morphSVG===void 0)return e;const{morphSVG:t,...n}=e,i=Zr(t);if(typeof i!="string"||!Xt(i))throw new Error(`gsap-compat: morphSVG "${String(i)}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);return{...n,d:i}}function Ph(e,t){if(e===!0)return[0,t];if(e===!1)return[0,0];if(typeof e=="number")return[0,Qr(e,t)];const n=e.trim().split(/[\s,]+/).filter(Boolean),i=o=>{const a=Number.parseFloat(o);if(Number.isNaN(a))throw new Error(`gsap-compat: drawSVG "${e}" is not a length or percentage`);return Qr(o.endsWith("%")?t*a/100:a,t)};if(n.length===0)return[0,t];if(n.length===1)return[0,i(n[0])];const s=i(n[0]),r=i(n[1]);return s<=r?[s,r]:[r,s]}function _h(e,t){const[n,i]=Ph(e,t);return{strokeDasharray:[i-n,t],strokeDashoffset:-n}}function Ih(e,t){if(e.drawSVG===void 0)return e;const{drawSVG:n,...i}=e;return{...i,..._h(n,t)}}function Ch(e){if(e.drawSVG!==void 0)throw new Error("gsap-compat: drawSVG needs the stroke length from the page. Use live.to(), or animate strokeDasharray / strokeDashoffset directly (see drawSvgProperties).");return e}function Qr(e,t){return Math.max(0,Math.min(t,e))}function Hh(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t>>>0}function $h(e,t,n){if(e.scrambleText!==void 0){const i=e.scrambleText,s=typeof i=="string"?{text:i}:i;if(typeof s?.text!="string")throw new Error("gsap-compat: scrambleText needs the text to end on — a string, or { text }.");const r=s.revealDelay&&n>0?s.revealDelay*1e3/n:void 0;return{to:s.text,mode:"scramble",...s.chars!==void 0&&{chars:s.chars},...s.speed!==void 0&&{refreshRate:20*s.speed},...r!==void 0&&{revealDelay:Math.min(r,.999)},...s.tweenLength!==void 0&&{tweenLength:s.tweenLength},...s.rightToLeft!==void 0&&{rightToLeft:s.rightToLeft},seed:s.seed??Hh(`${t}|${s.text}`)}}if(e.text!==void 0){const i=e.text,s=typeof i=="string"?{value:i}:i;if(typeof s?.value!="string")throw new Error("gsap-compat: text needs the text to end on — a string, or { value }.");return{to:s.value,mode:"type",...s.rightToLeft!==void 0&&{rightToLeft:s.rightToLeft}}}}function Ei(e){return Math.max(.1,e/25)}function Rh(e,t){const n=typeof t=="number"?{velocity:t}:t;if(typeof n?.velocity!="number"||!Number.isFinite(n.velocity))throw new Error("gsap-compat: inertia needs a velocity for each property — a number, or { velocity }.");const i=n.friction??(n.resistance!==void 0?Ei(n.resistance):void 0),s={from:e,velocity:n.velocity,...i!==void 0&&{friction:i},...n.min!==void 0&&{min:n.min},...n.max!==void 0&&{max:n.max}};return typeof n.end=="function"?s.end=[n.end(me(s))]:n.end!==void 0&&(s.end=Array.isArray(n.end)?[...n.end]:n.end),s}function Oh(e){const t=e===!0?{}:typeof e=="string"?{preset:e}:e;if(t.preset!==void 0&&!(t.preset in Ue))throw new Error(`gsap-compat: unknown spring preset "${t.preset}" — use one of ${Object.keys(Ue).join(", ")}`);return{...t.preset?Ue[t.preset]:{},...t.stiffness!==void 0&&{stiffness:t.stiffness},...t.damping!==void 0&&{damping:t.damping},...t.mass!==void 0&&{mass:t.mass},...t.restDelta!==void 0&&{restDelta:t.restDelta}}}function Lh(e,t){if(e===!0||typeof e=="string")return;const n=e.velocity;return typeof n=="number"?n:n?.[t]}class It{timeline;options;cursor=0;fallbackRandom=Si(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(t={}){this.options=t,this.timeline=new ve({id:t.id??"gsap-compat",name:t.name,config:{...t.repeat!==void 0&&{loop:t.repeat},...t.yoyo!==void 0&&{alternate:t.yoyo},...t.repeatDelay!==void 0&&{repeatDelay:t.repeatDelay*1e3},...t.timeScale!==void 0&&{speed:t.timeScale}}})}to(t,n,i){return this.build(t,void 0,_e(n),i)}from(t,n,i){const{config:s,properties:r}=hn(_e(n)),{motionPath:o,text:a,scrambleText:l,...c}=r,h=this.targetsOf(t)[0],u={...s};for(const m of Object.keys(c))u[m]=this.resolveStart(h,m);o!==void 0&&(u.motionPath=Ah(o));const f={},d=String(this.resolveStart(h,"text"));return a!==void 0&&(f.text=Ai(a),u.text=typeof a=="object"?{...a,value:d}:d),l!==void 0&&(f.text=Ai(l),u.scrambleText=typeof l=="object"?{...l,text:d}:d),this.build(t,{...c,...f},u,i)}fromTo(t,n,i,s){const{properties:r}=hn(_e(n));return this.build(t,r,_e(i),s)}set(t,n,i){return this.build(t,void 0,{..._e(n),duration:0},i)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(t){const n=Math.max(0,Pe(t,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(t){return Pe(t,this.context())}addLabel(t,n){return this.labels.set(t,Pe(n,this.context())),this}labelTimes(){return[...this.labels.values()].sort((t,n)=>t-n)}labelTime(t){return this.labels.get(t)}add(t,n){const i=Pe(n,this.context());for(const r of t.timeline.tracks){if(!("keyframes"in r))continue;const o=Qe({...r,id:this.nextTrackId(`nested-${r.id}`),keyframes:r.keyframes.map(a=>({...a,time:a.time+i}))});this.timeline.addTrack(o)}const s=i+t.timeline.duration;return this.previousStart=i,this.previousEnd=s,this.cursor=Math.max(this.cursor,s),this}play(){return this.timeline.play(),this}pause(){return this.timeline.pause(),this}restart(){return this.timeline.stop(),this.timeline.play(),this}reverse(){return this.timeline.reverse(),this}kill(){return this.timeline.removeTracks(),this}reset(){return this.timeline.removeTracks(),this.cursor=0,this.previousStart=0,this.previousEnd=0,this.labels.clear(),this.lastValues.clear(),this.trackCounter=0,this}seek(t){if(typeof t=="string"){const n=this.labels.get(t);return n!==void 0&&this.timeline.seek(n),this}return this.timeline.seek(t*1e3),this}progress(t){const n=this.timeline.duration;return t!==void 0&&n>0&&this.timeline.seek(t*n),n>0?this.timeline.currentTime/n:0}timeScale(t){return t!==void 0&&(this.timeline.speed=t),this.timeline.speed}duration(){return this.timeline.duration/1e3}tick(t){return this.timeline.tick(t),this}toDefinition(){return this.timeline.toDefinition()}build(t,n,i,s){const{config:r,properties:o}=hn(i),{motionPath:a,text:l,scrambleText:c,inertia:h,...u}=o,f=this.targetsOf(t),d=Pe(s,this.context()),m=un(r.delay,0),p=un(r.duration,500),g=Ti(r.stagger,{count:f.length,columnsFromLayout:this.options.layoutColumns?()=>this.options.layoutColumns(f):void 0,random:this.options.random??this.fallbackRandom}),y=this.easingFor(r.ease),w=[],k=r.spring;let M=0,S=!1;for(const[P,x]of Object.entries(u)){const I=x;let C=n?.[P]!==void 0?n[P]:this.resolveStart(f[0],P);if(typeof C!=typeof I&&(this.warn(`no usable start value for "${P}" on "${f[0]}" — it will snap to ${String(I)}. Use fromTo() to animate it.`),C=I),k!==void 0&&(typeof C!="number"||typeof I!="number")&&this.warn(`spring works on numbers, so "${P}" on "${f[0]}" eases instead`),k!==void 0&&typeof C=="number"&&typeof I=="number"){const B={...Oh(k),from:C,to:I,velocity:Lh(k,P)??this.options.startVelocity?.(f[0],P)??0},$=this.nextTrackId(`${f[0]}-${P}-spring`),L={id:$,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:P,kind:"spring",spring:B,delay:d+m};this.timeline.addTrack(L),w.push($),M=Math.max(M,Rs(B));for(const O of f)this.lastValues.set(`${O}|${P}`,I);continue}S=!0;const H=this.keyframesFor(C,I,p,y,r.ease),R=this.nextTrackId(`${f[0]}-${P}`);this.timeline.addTrack(Qe({id:R,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:P,delay:d+m,keyframes:H,...P==="quaternion"&&{interpolation:"slerp"}})),w.push(R);for(const B of f)this.lastValues.set(`${B}|${P}`,I)}const A=$h({text:l,scrambleText:c},f[0],p);if(A){const P=n?.text??n?.scrambleText,x=P!==void 0?Ai(P):this.resolveStart(f[0],"text"),I=this.nextTrackId(`${f[0]}-text`),C={id:I,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:"text",textConfig:{from:typeof x=="string"?x:String(x??""),...A},delay:d+m,keyframes:this.keyframesFor(0,1,p,y,r.ease)};this.timeline.addTrack(C),w.push(I);for(const H of f)this.lastValues.set(`${H}|text`,A.to)}if(a!==void 0){const{config:P,start:x,end:I}=Eh(a),C=this.nextTrackId(`${f[0]}-motionPath`),H={id:C,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:"motionPath",motionPathConfig:P,delay:d+m,keyframes:this.keyframesFor(x,I,p,y,r.ease)};this.timeline.addTrack(H),w.push(C)}if(h!==void 0)for(const[P,x]of Object.entries(h)){const I=this.resolveStart(f[0],P);if(typeof I!="number"){this.warn(`inertia on "${P}" needs a numeric start value; skipped`);continue}const C=Rh(I,x),H=this.nextTrackId(`${f[0]}-${P}-inertia`),R={id:H,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:P,kind:"inertia",inertia:C,delay:d+m};this.timeline.addTrack(R),w.push(H),M=Math.max(M,Kt(C));for(const B of f)this.lastValues.set(`${B}|${P}`,Wt(C))}const v=((h!==void 0||k!==void 0)&&!S&&!A&&a===void 0?M:Math.max(p,M))+(g&&f.length>1?de(f.length,g):0),_=d+m+v;return this.previousStart=d+m,this.previousEnd=_,this.cursor=Math.max(this.cursor,_),{trackIds:w,start:d+m,end:_,kill:()=>{for(const P of w)this.timeline.removeTrack(P)}}}keyframesFor(t,n,i,s,r){const o={time:0,value:t};if(i<=0)return[{time:0,value:n}];const a=typeof r=="string"?xe(r):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&fe(s)){const c=a?.fn??J(s);return[o,...fi(o,{time:i,value:n},c,{intervalMs:this.options.bakeIntervalMs})]}return[o,{time:i,value:n,...s&&{easing:s}}]}resolveStart(t,n){const i=this.lastValues.get(`${t}|${n}`);if(i!==void 0)return i;const s=this.options.startValue?.(t,n);if(s!==void 0)return s;const r=this.options.defaults?.[n];if(r!==void 0)return r;if(n==="text")return"";if(n==="quaternion")return[0,0,0,1];if(n==="d")throw new Error(`gsap-compat: no starting shape for "${t}". Use fromTo({ d: … }, { morphSVG: … }), or live.to(), which reads the element's current shape.`);const o=Jr(n);return o!==void 0?(this.warn(`no start value for "${n}" on "${t}" — using the static default ${o}. GSAP would read the live DOM here; tinyfly cannot, so pass an explicit fromTo() or a defaults map.`),o):(this.warn(`no start value or default for "${n}" on "${t}" — using 0`),0)}easingFor(t){if(t!==void 0){if(typeof t=="string")return xe(t).easing;if(typeof t=="function")throw new Error('gsap-compat: function eases cannot be serialized. Use a named ease, or a cubic-bezier via { type: "cubic-bezier", points: [...] }.');return t}}targetsOf(t){return Array.isArray(t)?t:[t]}context(){return{cursor:this.cursor,previousStart:this.previousStart,previousEnd:this.previousEnd,labels:this.labels,scale:1e3}}nextTrackId(t){return this.trackCounter+=1,`${t}-${this.trackCounter}`}warn(t){this.options.onWarning?.(`gsap-compat: ${t}`)}}function Ai(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;return String(t.value??t.text??"")}return String(e??"")}function Fh(e){return new It(e)}function _e(e){return Ch(xh(e))}function Dh(e){return!Array.isArray(e)||e.length!==4?null:`matrix3d(${Ae(wt(e)).map(n=>Math.round(n*1e6)/1e6+0).join(", ")})`}const Bh=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),Nh="#ffffff",Wh="rgba(0, 0, 0, 0.5)";function Kh(e){const t=[];if(e.blur!==void 0&&t.push(`blur(${Math.max(0,e.blur)}px)`),e.brightness!==void 0&&t.push(`brightness(${Math.max(0,e.brightness)})`),e.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,e.glow)}px ${e.glowColor??Nh})`),e.shadowX!==void 0||e.shadowY!==void 0||e.shadowBlur!==void 0){const n=e.shadowX??0,i=e.shadowY??0,s=Math.max(0,e.shadowBlur??0);t.push(`drop-shadow(${n}px ${i}px ${s}px ${e.shadowColor??Wh})`)}return t.length>0?t.join(" "):null}function Yh(e,t){const n=e.childNodes.length===1?e.firstChild:null;if(n&&n.nodeType===3){const i=n;i.data!==t&&(i.data=t);return}e.textContent!==t&&(e.textContent=t)}function Xh(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const to=new Set(["width","height","top","right","bottom","left","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","borderRadius","borderWidth","fontSize","lineHeight","letterSpacing","outlineWidth","gap","rowGap","columnGap"]),qh=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","quaternion","motionPathX","motionPathY","motionPathRotate"]),Vh=["x","motionPathX","y","motionPathY","z","rotate","rotateZ","motionPathRotate","rotateX","rotateY","quaternion","scale","scaleX","scaleY","scaleZ","skewX","skewY"],Uh=new Set(["childPerspective","perspectiveOriginX","perspectiveOriginY"]),zh=new Set(["originX","originY"]),Gh=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),jh=new Set(["drawOn"]),Jh={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},eo={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},Zh="http://www.w3.org/2000/svg";class Ct{targets=new Map;registerTarget(t,n){this.targets.set(t,n)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[n,i]of t.values){const s=this.targets.get(n);s&&this.applyProperties(s,i)}}applyProperties(t,n){let i=null,s=null,r=null,o=null,a=null;const l=n.has("motionPathX"),c=n.has("motionPathY"),h=n.has("motionPathRotate");for(const[m,p]of n)if(!(m==="x"&&l)&&!(m==="y"&&c)&&!((m==="rotate"||m==="rotateZ")&&h)&&!jh.has(m)){if(qh.has(m))(i??={})[m]=p;else if(Uh.has(m))typeof p=="number"&&((s??={})[m]=p);else if(zh.has(m))typeof p=="number"&&((r??={})[m]=p);else if(Gh.has(m))typeof p=="number"&&((o??={})[m]=p);else if(Bh.has(m))(a??={})[m]=p;else if(m!=="perspective"){if(m!=="shine")if(m==="text"&&typeof p=="string")Yh(t,p);else if(m==="d"&&typeof p=="string"){const g=t;(g.tagName?.toLowerCase()==="path"?g:g.querySelector?.("path"))?.setAttribute?.("d",p)}else this.applyStyleProperty(t,m,p)}}const u=n.get("shine");typeof u=="number"&&this.applyShine(t,u);const f=[],d=n.get("perspective");if(typeof d=="number"&&d>0&&f.push(`perspective(${d}px)`),i)for(const m of Vh){const p=i[m];if(p===void 0)continue;const g=this.buildTransformPart(m,p);g&&f.push(g)}if(f.length>0&&(t.style.transform=f.join(" "),Xh(t)),s&&(s.childPerspective!==void 0&&(t.style.perspective=`${s.childPerspective}px`),(s.perspectiveOriginX!==void 0||s.perspectiveOriginY!==void 0)&&(t.style.perspectiveOrigin=`${s.perspectiveOriginX??50}% ${s.perspectiveOriginY??50}%`)),r){const m=r.originX??50,p=r.originY??50;t.style.transformOrigin=`${m}% ${p}%`}if(o){const m=o.clipTop??0,p=o.clipRight??0,g=o.clipBottom??0,y=o.clipLeft??0;t.style.clipPath=`inset(${m}% ${p}% ${g}% ${y}%)`}if(a){const m=Kh(a);m&&(t.style.filter=m)}}buildTransformPart(t,n){if(t==="quaternion")return Dh(n);if(typeof n!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${n}px)`;case"y":case"motionPathY":return`translateY(${n}px)`;case"z":return`translateZ(${n}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${n}deg)`;case"rotateX":return`rotateX(${n}deg)`;case"rotateY":return`rotateY(${n}deg)`;case"scale":return`scale(${n})`;case"scaleX":return`scaleX(${n})`;case"scaleY":return`scaleY(${n})`;case"scaleZ":return`scaleZ(${n})`;case"skewX":return`skewX(${n}deg)`;case"skewY":return`skewY(${n}deg)`;default:return null}}applyShine(t,n){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const i=t.dataset.shineBase,s=-20+n*140,r=t.style;r.color="transparent",r.backgroundImage=`linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${i}, ${i})`,r.backgroundSize="250% 100%, 100% 100%",r.backgroundPosition=`${s}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,n,i){let s;if(t.namespaceURI===Zh&&n in eo){const a=Array.isArray(i)?i.join(", "):String(i);t.style[eo[n]]=a;return}else n==="fill"&&t.dataset?.elementType==="text"?s="color":s=Jh[n]??n;let o;typeof i=="number"?to.has(n)||to.has(s)?o=`${i}px`:o=String(i):Array.isArray(i)?o=i.join(", "):o=i,t.style[s]=o}}const Qh={request:e=>requestAnimationFrame(e),cancel:e=>cancelAnimationFrame(e)};class no{adapter=new Ct;scheduler;rootOption;onWarning;names=new WeakMap;elements=new Map;nameCounter=0;objectNames=new WeakMap;objects=new Map;owned=new Set;currentCollector;tickerCallbacks=new Set;tickerTime=0;tickerFrame=0;liveTimelines=new Set;utils=yh();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(t={}){this.scheduler=t.scheduler??Qh,this.rootOption=t.root,this.onWarning=t.onWarning}get root(){return this.rootOption??document}resolveTargets(t){const n=[];for(const i of this.targetsOf(t)){const s=this.nameFor(i);xi(i)&&this.currentCollector?.touch(i,s),n.push(s)}return n}query(t){return this.selectorRoot.querySelector(t)}get collector(){return this.currentCollector}setCollector(t){this.currentCollector=t}forget(t){this.applied.delete(t),this.dirty.delete(t)}get selectorRoot(){return this.currentCollector?.scope??this.root}elementFor(t){return this.elements.get(t)}objectFor(t){return this.objects.get(t)}appliedValue(t,n){return this.applied.get(t)?.get(n)}velocityOf(t,n){for(const s of[...this.active.keys()].reverse()){if(s.getTracks({target:t,property:n}).length===0)continue;const r=s.currentTime;if(r<4)return 0;const o=s.getStateAtTime(r).values.get(t)?.get(n),a=s.getStateAtTime(r-4).values.get(t)?.get(n);if(typeof o!="number"||typeof a!="number")return;const l=(o-a)/4;return(s.direction==="reverse"?-l:l)*1e3}}ticker={add:t=>{this.destroyed||(this.tickerCallbacks.size===0&&(this.tickerTime=0,this.tickerFrame=0),this.tickerCallbacks.add(t),this.currentCollector?.track({revert:()=>this.ticker.remove(t)}),this.startLoop())},remove:t=>{this.tickerCallbacks.delete(t),this.running||this.stopLoop()}};activate(t,n={}){this.destroyed||(t.onUpdate=i=>this.write(i),this.active.delete(t),this.active.set(t,n),this.startLoop())}deactivate(t){this.active.delete(t),this.running||this.stopLoop()}own(t){return this.destroyed?t.destroy():this.owned.add(t),t}destroy(){this.destroyed=!0;for(const t of this.owned)t.destroy();this.owned.clear();for(const t of this.active.keys())t.stop();this.active.clear(),this.stopLoop(),this.adapter.clearTargets(),this.elements.clear(),this.names=new WeakMap,this.objects.clear(),this.objectNames=new WeakMap,this.tickerCallbacks.clear(),this.liveTimelines.clear(),this.applied.clear(),this.dirty.clear()}apply(t,n){if(this.destroyed)return;const i=new Map(Object.entries(n));this.write({values:new Map([[t,i]]),currentTime:0,playbackState:"idle",direction:"forward",loopIteration:0}),this.flush()}render(t){this.destroyed||(this.write(t.getStateAtTime(t.currentTime)),this.flush())}tick(t){const n=[...this.active];for(const[i]of n)i.duration<=0?(this.write(i.getStateAtTime(0)),i.stop()):i.tick(t);this.flush();for(const[i,s]of n)s.onUpdate?.(),i.playbackState!=="playing"&&this.active.get(i)===s&&this.active.delete(i);this.flush(),this.runTicker(t),this.running||this.stopLoop()}get running(){return this.active.size>0||this.tickerCallbacks.size>0}runTicker(t){if(this.tickerCallbacks.size!==0){this.tickerTime+=t,this.tickerFrame+=1;for(const n of[...this.tickerCallbacks])n(this.tickerTime/1e3,t,this.tickerFrame)}}write(t){for(const[n,i]of t.values){let s=this.applied.get(n);s||(s=new Map,this.applied.set(n,s));for(const[r,o]of i)s.set(r,o);this.dirty.add(n)}}flush(){if(this.dirty.size===0)return;const t=new Map;for(const n of this.dirty){const i=this.applied.get(n),s=this.objects.get(n);if(s)for(const[r,o]of i)s[r]=o;else t.set(n,i)}this.dirty.clear(),t.size!==0&&this.adapter.applyState({values:t,currentTime:0,playbackState:"playing",direction:"forward",loopIteration:0})}frame=t=>{this.frameId=null;const n=this.lastTimestamp===null?0:t-this.lastTimestamp;this.lastTimestamp=t,n>0&&this.tick(n),this.running&&this.frameId===null&&(this.frameId=this.scheduler.request(this.frame))};startLoop(){this.frameId===null&&(this.lastTimestamp=null,this.frameId=this.scheduler.request(this.frame))}stopLoop(){this.frameId!==null&&this.scheduler.cancel(this.frameId),this.frameId=null,this.lastTimestamp=null}targetsOf(t){if(typeof t=="string")return Array.from(this.selectorRoot.querySelectorAll(t));if(xi(t))return[t];if(!tu(t))return[t];const n=[];for(const i of Array.from(t))n.push(...this.targetsOf(i));return n}nameFor(t){return xi(t)?this.elementName(t):this.objectName(t)}objectName(t){const n=this.objectNames.get(t);if(n)return n;let i;do this.nameCounter+=1,i=`obj-${this.nameCounter}`;while(this.objects.has(i)||this.elements.has(i));return this.objectNames.set(t,i),this.objects.set(i,t),i}elementName(t){const n=this.names.get(t);if(n)return n;let i=t.id?`#${t.id}`:"";if(!i||this.elements.has(i))do this.nameCounter+=1,i=`el-${this.nameCounter}`;while(this.elements.has(i));return this.names.set(t,i),this.elements.set(i,t),this.adapter.registerTarget(i,t),i}}function xi(e){return typeof e=="object"&&e!==null&&e.nodeType===1}function tu(e){if(Array.isArray(e))return!0;const t=e;return typeof t.length=="number"&&typeof t.item=="function"}function fn(e){const t=e.style;if(!t)return e.getBoundingClientRect();const n=t.transform;t.transform="none";const i=e.getBoundingClientRect();return t.transform=n,i}const io=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function eu(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function nu(e){const t=e.getScreenCTM?.();if(t)return[t.a,t.b,t.c,t.d,t.e,t.f];const n=e.getBoundingClientRect();return[1,0,0,1,n.left,n.top]}function iu(e,t){const n=typeof e=="string"||Array.isArray(e)||io(e)?{path:e}:e,{align:i,alignOrigin:s,path:r,...o}=n,a=A=>{const E=io(A)?A:t.query(A);return E||t.warn(`gsap-compat: motionPath could not find "${String(A)}"`),E};let l=null,c="";if(Array.isArray(r)||typeof r=="string"&&Xt(r))c=r;else{l=a(r);const A=l&&sn({tag:l.localName,attributes:eu(l)});l&&!A&&t.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),c=A??""}const h={...o,path:c};if(i===void 0||i===!1)return h;const u=i===!0?l:a(i);if(!u)return i===!0&&t.warn("gsap-compat: motionPath align: true needs the path to be an element"),h;const f=t.targets[0];if(!f)return h;const[d,m,p,g,y,w]=nu(u),k=fn(f),[M,S]=s??[.5,.5];for(const A of t.targets.slice(1)){const E=fn(A);if(Math.abs(E.left-k.left)>.5||Math.abs(E.top-k.top)>.5){t.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");break}}return h.matrix=[d,m,p,g,y-k.left-M*k.width,w-k.top-S*k.height],h}const so=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function ro(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function oo(e){if(!e)return null;const t=sn({tag:e.localName,attributes:ro(e)});return t||(e.querySelector("path")?.getAttribute("d")??null)}function su(e,t,n){const i=Zr(e);if(typeof i=="string"&&Xt(i))return i;const s=so(i)?i:typeof i=="string"?t(i):null,r=oo(s);return r||(n(`gsap-compat: morphSVG could not find a shape for "${String(i)}"`),"")}const ru=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function ou(e,t=document){return(typeof e=="string"?Array.from(t.querySelectorAll(e)):so(e)?[e]:Array.from(e)).map(i=>{if(i.localName==="path")return i;const s=sn({tag:i.localName,attributes:ro(i)});if(!s||!i.parentNode)return i;const r=i.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path");for(const o of Array.from(i.attributes))ru.has(o.name)||r.setAttribute(o.name,o.value);return r.setAttribute("d",s),i.parentNode.replaceChild(r,i),r})}const ao=.3;class lo{options;target;running=!1;dragging=!1;passedTolerance=!1;lastX=0;lastY=0;startX=0;startY=0;velocityX=0;velocityY=0;lastTime=0;constructor(t){this.options=t,this.target=t.target}start(){if(this.running)return;this.running=!0;const t=this.options.type??["pointer","touch"];t.includes("pointer")&&(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointermove",this.onPointerMove),this.target.addEventListener("pointerup",this.onPointerUp),this.target.addEventListener("pointercancel",this.onPointerUp)),t.includes("touch")&&(this.target.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.target.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.target.addEventListener("touchend",this.onTouchEnd)),t.includes("wheel")&&this.target.addEventListener("wheel",this.onWheel,{passive:!1})}stop(){this.running&&(this.running=!1,this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointermove",this.onPointerMove),this.target.removeEventListener("pointerup",this.onPointerUp),this.target.removeEventListener("pointercancel",this.onPointerUp),this.target.removeEventListener("touchstart",this.onTouchStart),this.target.removeEventListener("touchmove",this.onTouchMove),this.target.removeEventListener("touchend",this.onTouchEnd),this.target.removeEventListener("wheel",this.onWheel))}destroy(){this.stop()}get velocity(){return{x:this.velocityX,y:this.velocityY}}begin(t,n,i){this.dragging=!0,this.passedTolerance=!1,this.startX=t,this.startY=n,this.lastX=t,this.lastY=n,this.velocityX=0,this.velocityY=0,this.lastTime=co(),this.options.onPress?.(this.stateFrom(0,0,i))}move(t,n,i){if(!this.dragging)return;const s=t-this.lastX,r=n-this.lastY;this.lastX=t,this.lastY=n;const o=t-this.startX,a=n-this.startY,l=this.options.tolerance??3;if(!this.passedTolerance){if(Math.hypot(o,a)<l)return;this.passedTolerance=!0}this.updateVelocity(s,r),this.options.preventDefault!==!1&&i.cancelable&&i.preventDefault(),this.options.onMove?.(this.stateFrom(s,r,i))}end(t){this.dragging&&(this.dragging=!1,this.options.onRelease?.(this.stateFrom(0,0,t)))}updateVelocity(t,n){const i=co(),s=Math.max(1,i-this.lastTime);this.lastTime=i;const r=t/s*1e3,o=n/s*1e3;this.velocityX+=(r-this.velocityX)*ao,this.velocityY+=(o-this.velocityY)*ao}stateFrom(t,n,i){return{deltaX:t,deltaY:n,velocityX:this.velocityX,velocityY:this.velocityY,totalX:this.lastX-this.startX,totalY:this.lastY-this.startY,isDragging:this.dragging,event:i}}onPointerDown=t=>{const n=t,i=this.target;if(typeof n.pointerId=="number"&&typeof i.setPointerCapture=="function")try{i.setPointerCapture(n.pointerId)}catch{}this.begin(n.clientX,n.clientY,t)};onPointerMove=t=>{const n=t;this.move(n.clientX,n.clientY,t)};onPointerUp=t=>this.end(t);onTouchStart=t=>{const n=t.touches[0];n&&this.begin(n.clientX,n.clientY,t)};onTouchMove=t=>{const n=t.touches[0];n&&this.move(n.clientX,n.clientY,t)};onTouchEnd=t=>this.end(t);onWheel=t=>{const n=t;this.options.preventDefault!==!1&&n.cancelable&&n.preventDefault(),this.updateVelocity(n.deltaX,n.deltaY),this.options.onMove?.({deltaX:n.deltaX,deltaY:n.deltaY,velocityX:this.velocityX,velocityY:this.velocityY,totalX:0,totalY:0,isDragging:!1,event:t})}}function co(){return typeof performance<"u"?performance.now():Date.now()}function ho(e,t,n){let i={delta:0,line:null},s=n;for(const r of e)for(const o of t){const a=Math.abs(o-r);a<=s&&(s=a,i={delta:o-r,line:o})}return i}function uo(e,t){return t<=0?[]:e.map(n=>Math.round(n/t)*t)}class Pi{options;observer;x;y;originX=0;originY=0;snappedX=null;snappedY=null;constructor(t){this.options=t,this.x=t.initialX??0,this.y=t.initialY??0,this.observer=new lo({target:t.target,onPress:n=>{const i=t.getPosition?.();i&&(this.x=i.x,this.y=i.y),this.originX=this.x,this.originY=this.y,t.onPress?.(n)},onMove:n=>this.handleMove(n),onRelease:n=>t.onRelease?.(n)})}start(){this.observer.start()}stop(){this.observer.stop()}destroy(){this.observer.destroy()}get position(){return{x:this.x,y:this.y}}get velocity(){return this.observer.velocity}setPosition(t,n){const i=this.options.axis??"both";this.x=i==="y"?this.x:this.applyConstraints(t,"x"),this.y=i==="x"?this.y:this.applyConstraints(n,"y")}get snapLines(){return{x:this.snappedX,y:this.snappedY}}snapThreshold(){if(this.options.snapThreshold!==void 0)return this.options.snapThreshold;const t=this.options.snap??0;return t>0?t/2:8}handleMove(t){this.setPosition(this.originX+t.totalX,this.originY+t.totalY),this.options.mode==="scrub"&&this.scrub(),this.options.onDrag?.(this.position,t),this.options.onSnap?.(this.snapLines)}scrub(){const t=this.options.timeline;if(!t)return;const n=t.duration;if(n<=0)return;const i=this.options.scrubDistance??500;if(i===0)return;const s=(this.options.axis??"both")==="y"?this.y:this.x,r=au(s/i);t.pause(),t.seek(r*n)}applyConstraints(t,n){let i=t;const s=[...uo([i],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],r=ho([i],s,this.snapThreshold());i+=r.delta,n==="x"?this.snappedX=r.line:this.snappedY=r.line;const o=this.options.bounds;if(o){const a=n==="x"?o.minX:o.minY,l=n==="x"?o.maxX:o.maxY;a!==void 0&&(i=Math.max(a,i)),l!==void 0&&(i=Math.min(l,i))}return i}}function au(e){return e<0?0:e>1?1:e}function lu(e){const t=new Pi(e);return t.start(),t}const cu={x:"x",y:"y","x,y":"both"},_i=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function fo(e,t){const n=fn(e),i=t.getBoundingClientRect();return{minX:i.left-n.left,maxX:i.right-n.right,minY:i.top-n.top,maxY:i.bottom-n.bottom}}function po(e){return Array.isArray(e)?[...e]:e}function hu(e,t,n,i={}){const[s]=t.resolveTargets(n),r=s?t.elementFor(s):void 0;if(!s||!r)throw new Error(`gsap-compat: live.draggable could not find ${String(n)}`);if(i.type==="rotation")return uu(e,t,s,r,i);const o=cu[i.type??"x,y"],a=()=>{const p=t.appliedValue(s,"x"),g=t.appliedValue(s,"y");return{x:typeof p=="number"?p:0,y:typeof g=="number"?g:0}},l=typeof i.bounds=="string"?t.query(i.bounds):_i(i.bounds)?i.bounds:null,h={bounds:(!l&&i.bounds&&!_i(i.bounds)?i.bounds:void 0)??(l?fo(r,l):void 0)};let u=null;const f=()=>{u?.kill(),u=null},d=p=>{const g=i.inertia===!0?{}:i.inertia,y=g.friction??(g.resistance!==void 0?Ei(g.resistance):4),w=a(),k=h.bounds??{};let M,S;const A=g.end;if(Array.isArray(A)){const T=me({from:w.x,velocity:o==="y"?0:p.x,friction:y}),v=me({from:w.y,velocity:o==="x"?0:p.y,friction:y});let _=A[0];for(const P of A)Math.hypot(P.x-T,P.y-v)<Math.hypot(_.x-T,_.y-v)&&(_=P);_&&(M=[_.x],S=[_.y])}else typeof A=="number"?(M=A,S=A):A&&(M=po(A.x),S=po(A.y));const E={};o!=="y"&&(E.x={velocity:p.x,friction:y,min:k.minX,max:k.maxX,end:M}),o!=="x"&&(E.y={velocity:p.y,friction:y,min:k.minY,max:k.maxY,end:S}),u=e.to(r,{inertia:E,onComplete:()=>i.onThrowComplete?.()})},m=new Pi({target:r,axis:o,snap:i.snap,get bounds(){return h.bounds},getPosition:a,onPress:()=>{f(),l&&(h.bounds=fo(r,l)),i.onPress?.()},onDrag:p=>{t.apply(s,o==="x"?{x:p.x}:o==="y"?{y:p.y}:{x:p.x,y:p.y}),i.onDrag?.(p)},onRelease:()=>{const p=m.velocity;i.onRelease?.(p),i.inertia&&d(p)}});return m.start(),{draggable:m,get position(){return a()},get rotation(){const p=t.appliedValue(s,"rotate");return typeof p=="number"?p:0},destroy(){f(),m.destroy()}}}function uu(e,t,n,i,s){const r=typeof s.bounds=="object"&&s.bounds!==null&&!_i(s.bounds)?s.bounds:{},o=()=>{const k=t.appliedValue(n,"rotate");return typeof k=="number"?k:0},a=k=>Math.min(r.maxRotation??1/0,Math.max(r.minRotation??-1/0,k));let l=null,c=!1,h,u={x:0,y:0},f=0,d=0,m=[];const p=k=>Math.atan2(k.clientY-u.y,k.clientX-u.x)*180/Math.PI,g=k=>{if(c)return;l?.kill(),l=null,c=!0,h=k.pointerId,i.setPointerCapture?.(k.pointerId);const M=i.getBoundingClientRect();u={x:M.left+M.width/2,y:M.top+M.height/2},f=p(k),d=o(),m=[{time:performance.now(),rotation:d}],s.onPress?.()},y=k=>{if(!c||k.pointerId!==h)return;const M=p(k);let S=M-f;S>180&&(S-=360),S<-180&&(S+=360),f=M,d+=S;let A=a(d);s.snap&&(A=a(Math.round(A/s.snap)*s.snap)),t.apply(n,{rotate:A});const E=performance.now();for(m.push({time:E,rotation:A});m.length>2&&E-m[0].time>100;)m.shift();const T={x:0,y:0};s.onDrag?.(T)},w=k=>{if(!c||k.pointerId!==h)return;c=!1;const M=m[0],S=m[m.length-1],A=M&&S?(S.time-M.time)/1e3:0,E=A>0?(S.rotation-M.rotation)/A:0;if(s.onRelease?.({x:E,y:0}),!s.inertia)return;const T=s.inertia===!0?{}:s.inertia,v=T.friction??(T.resistance!==void 0?Ei(T.resistance):4),_=typeof T.end=="number"||Array.isArray(T.end)?T.end:void 0;l=e.to(i,{inertia:{rotate:{velocity:E,friction:v,min:r.minRotation,max:r.maxRotation,end:Array.isArray(_)?_.filter(P=>typeof P=="number"):_}},onComplete:()=>s.onThrowComplete?.()})};return i.addEventListener("pointerdown",g),i.addEventListener("pointermove",y),i.addEventListener("pointerup",w),i.addEventListener("pointercancel",w),i.style.touchAction="none",{draggable:void 0,position:{x:0,y:0},get rotation(){return o()},destroy(){l?.kill(),i.removeEventListener("pointerdown",g),i.removeEventListener("pointermove",y),i.removeEventListener("pointerup",w),i.removeEventListener("pointercancel",w)}}}const fu={opacity:0,scale:.6};function du(e){const t=e.getBoundingClientRect();return t.width===0&&t.height===0?null:{cx:t.left+t.width/2,cy:t.top+t.height/2,width:t.width,height:t.height}}function mo(e){const t=fn(e);return t.width===0&&t.height===0?null:{cx:t.left+t.width/2,cy:t.top+t.height/2,width:t.width,height:t.height}}function Ii(e,t){const i=e.resolveTargets(t).map(o=>e.elementFor(o)).filter(o=>!!o),s=new Map,r=new Map;for(const o of i){const a=du(o);s.set(o,a);const l=go(o);a&&l!==void 0&&!r.has(l)&&r.set(l,{element:o,box:a})}return{elements:i,boxes:s,ids:r}}const Ci=new WeakMap;function Hi(e,t,n,i={}){const s=i.duration??.6,r=i.ease??"power2.inOut",o=i.stagger??0,a=i.scale!==!1,l=i.enter===void 0?fu:i.enter,c=new Set(n.elements);if(i.targets!==void 0)for(const d of e.resolveTargets(i.targets)){const m=e.elementFor(d);m&&c.add(m)}const h=[...c].sort((d,m)=>d===m?0:d.compareDocumentPosition(m)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),u=t({onComplete:i.onComplete});let f=0;for(const d of h){const m=mo(d);if(!m)continue;let p=n.boxes.get(d)??null,g;const y=go(d),w=!p&&y!==void 0?n.ids.get(y):void 0;w&&w.element!==d&&(p=w.box,g=w.element);const[k]=e.resolveTargets(d);Ci.get(d)?.timeline.removeTracks({target:k});const M=f*o;if(!p){if(l===!1)continue;u.fromTo(d,{x:0,y:0,scaleX:1,scaleY:1,...l},{...yo(l),x:0,y:0,scaleX:1,scaleY:1,duration:s,ease:r,delay:M},0),Ci.set(d,u),f++;continue}const S=p.cx-m.cx,A=p.cy-m.cy,E=a?p.width/m.width:1,T=a?p.height/m.height:1;if(!(Math.abs(S)>.5||Math.abs(A)>.5||Math.abs(E-1)>.001||Math.abs(T-1)>.001)){const P=(x,I)=>{const C=e.appliedValue(k,x);return typeof C=="number"&&Math.abs(C-I)>1e-6};(P("x",0)||P("y",0)||P("scaleX",1)||P("scaleY",1))&&u.set(d,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const _=i.fade===!0&&g!==void 0;u.fromTo(d,{x:S,y:A,scaleX:E,scaleY:T,..._&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,..._&&{opacity:1},duration:s,ease:r,delay:M},0),_&&g&&mo(g)&&u.fromTo(g,{opacity:1},{opacity:0,duration:s,ease:r,delay:M},0),Ci.set(d,u),f++}return u}function go(e){return e.dataset?.flipId}function yo(e){const t={};for(const n of Object.keys(e))t[n]=n==="opacity"||n.startsWith("scale")?1:0;return t}function pu(e,t={}){const n=new Set((t.type??"chars,words,lines").split(",").map(p=>p.trim())),i={chars:t.charsClass??"char",words:t.wordsClass??"word",lines:t.linesClass??"line"},s=t.aria!==!1,r=e.map(p=>({element:p,html:p.innerHTML,ariaLabel:p.getAttribute("aria-label")}));let o={chars:[],words:[],lines:[],masks:[]},a,l,c=!1;const h=()=>{for(const{element:p,html:g,ariaLabel:y}of r)p.innerHTML=g,y===null?p.removeAttribute("aria-label"):p.setAttribute("aria-label",y)},u=()=>{a&&(a.revert?a.revert():a.kill?.(),a=void 0)},f=()=>{const p={chars:[],words:[],lines:[],masks:[]};for(const{element:g}of r){const y=(g.textContent??"").replace(/\s+/g," ").trim(),w=mu(g,i.words),k=n.has("chars")?w.flatMap(A=>gu(A,i.chars)):[],M=n.has("lines")?bu(g,w,i.lines):[];if(s){!g.hasAttribute("aria-label")&&y&&g.setAttribute("aria-label",y);for(const A of w)A.setAttribute("aria-hidden","true")}if(n.has("words"))p.words.push(...w);else for(const A of w)A.removeAttribute("class");p.chars.push(...k),p.lines.push(...M);const S=t.mask==="lines"?M:t.mask==="words"?w:t.mask==="chars"?k:[];for(const A of S)p.masks.push(wu(A,`${i[t.mask]}-mask`))}o=p},d={elements:e,get chars(){return o.chars},get words(){return o.words},get lines(){return o.lines},get masks(){return o.masks},split(){c||(u(),h(),f(),a=t.onSplit?.(d))},revert(){c=!0,l?.disconnect(),u(),h()}};f(),a=t.onSplit?.(d),t.autoSplit&&m();function m(){const p=new Map;let g=!1;const y=()=>{if(g)return;g=!0;const k=()=>{g=!1,d.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(k):setTimeout(k,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(k=>{let M=!1;for(const S of k){const A=Math.round(S.contentRect.width),E=p.get(S.target);p.set(S.target,A),E!==void 0&&E!==A&&(M=!0)}M&&y()});for(const k of e)l.observe(k)}const w=e[0]?.ownerDocument?.fonts;w&&w.status!=="loaded"&&w.ready.then(()=>y())}return d}function mu(e,t){const n=e.ownerDocument,i=[],s=n.createTreeWalker(e,4),r=[];for(let o=s.nextNode();o;o=s.nextNode())r.push(o);for(const o of r){const a=o.data.match(/\s+|\S+/g)??[];if(a.length===0)continue;const l=n.createDocumentFragment();for(const c of a){if(/^\s/.test(c)){l.appendChild(n.createTextNode(c));continue}const h=n.createElement("span");h.className=t,h.style.display="inline-block",h.textContent=c,l.appendChild(h),i.push(h)}o.replaceWith(l)}return i}function gu(e,t){const n=e.ownerDocument,i=yu(e.textContent??"").map(s=>{const r=n.createElement("span");return r.className=t,r.style.display="inline-block",r.textContent=s,r});return e.replaceChildren(...i),i}function yu(e){const t=Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),n=>n.segment):Array.from(e)}function bu(e,t,n){const i=e.ownerDocument,s=new Map(t.map(m=>[m,m.getBoundingClientRect()])),r=[],o=m=>{for(const p of Array.from(m.childNodes))p.nodeType===3||s.has(p)||p.tagName==="BR"?r.push(p):o(p)};o(e);const a=[];let l=null,c=0,h=0,u=!1,f=[];const d=()=>{l=i.createElement("span"),l.className=n,l.style.display="block",a.push(l),f=[]};for(const m of r){if(m.tagName==="BR"){u=!0;continue}const p=s.get(m);if(p&&(!l||u||p.top>c+h)&&(d(),c=p.top,h=p.height/2,u=!1),!l)continue;const g=[];for(let k=m.parentNode;k&&k!==e;k=k.parentNode)g.unshift(k);let y=0;for(;y<f.length&&y<g.length&&f[y].original===g[y];)y++;f.length=y;let w=y===0?l:f[y-1].clone;for(const k of g.slice(y)){const M=k.cloneNode(!1);w.appendChild(M),f.push({original:k,clone:M}),w=M}w.appendChild(m)}return e.replaceChildren(...a),a}function wu(e,t){const n=e.ownerDocument.createElement("span");return n.className=t,n.style.display=e.style.display==="block"?"block":"inline-block",n.style.overflow="clip",n.style.paddingBottom="0.12em",n.style.marginBottom="-0.12em",e.replaceWith(n),n.appendChild(e),n}const bo={top:0,left:0,start:0,center:.5,centre:.5,middle:.5,bottom:1,right:1,end:1};function $i(e){const t=e.trim().toLowerCase();if(t in bo)return bo[t];if(t.endsWith("%")){const n=Number.parseFloat(t.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function Ri(e){if(typeof e=="number")return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:e};let t=0;const i=e.replace(/([+-])=\s*(-?[\d.]+)/g,(o,a,l)=>(t+=(a==="-"?-1:1)*Number.parseFloat(l),"")).trim().split(/\s+/).filter(Boolean);if(i.length===1&&/^-?[\d.]+$/.test(i[0]))return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:Number.parseFloat(i[0])+t};const s=i[0]!==void 0?$i(i[0]):void 0,r=i[1]!==void 0?$i(i[1]):void 0;return{elementFraction:s??0,viewportFraction:r??0,offsetPx:t}}function Jt(e,t,n){const i=Ri(n),s=i.absolutePx!==void 0?e.top+i.absolutePx:e.top+e.height*i.elementFraction,r=t*i.viewportFraction;return s-r+i.offsetPx}function ku(e,t,n,i){const s=Jt(e,t,n),o=Jt(e,t,i)-s;return o<=0?s<=0?1:0:Oi(-s/o)}function Oi(e){return e<0?0:e>1?1:e===0?0:e}function wo(e,t,n,i){if(n<=0)return t;const s=1-Math.exp(-(i/1e3)/n);return e+(t-e)*s}function Li(e,t,n,i,s){const r=h=>Jt({top:e+s(h),bottom:e+s(h)+t,height:t},n,i),o=r(0),a=r(1);if(Math.sign(o)===Math.sign(a)||o===0||a===0)return o===0?0:a===0?1:Math.abs(o)<Math.abs(a)?0:1;let l=0,c=1;for(let h=0;h<40;h++){const u=(l+c)/2;Math.sign(r(u))===Math.sign(o)?l=u:c=u}return(l+c)/2}class ko{timeline;trigger;behaviour;options;observer=null;hasPlayed=!1;running=!1;constructor(t){this.timeline=t.timeline,this.trigger=t.trigger,this.behaviour=t.behaviour??"once",this.options=t}start(){if(!this.running){if(this.running=!0,typeof IntersectionObserver>"u"){this.enter();return}this.observer=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting?this.enter():this.leave()},{threshold:this.options.threshold??.15,rootMargin:this.options.rootMargin,root:this.options.root??null}),this.observer.observe(this.trigger)}}stop(){this.running=!1,this.observer?.disconnect(),this.observer=null}destroy(){this.stop()}reset(){this.hasPlayed=!1,this.timeline.stop()}enter(){this.options.onEnter?.(),!(this.behaviour==="once"&&this.hasPlayed)&&(this.hasPlayed=!0,this.behaviour!=="once"&&this.timeline.seek(0),this.timeline.play())}leave(){this.options.onLeave?.(),this.behaviour==="reset"&&this.timeline.stop()}}function vu(e){const t=new ko(e);return t.start(),t}class vo{element;spacer;saved;axis;spacing;constructor(t,n={}){this.element=t,this.axis=n.axis??"y",this.spacing=n.spacing??!0;const i=t.ownerDocument;this.spacer=i.createElement("div"),this.spacer.className="pin-spacer",this.saved={position:t.style.position,top:t.style.top,left:t.style.left},this.axis==="x"&&(this.spacer.style.flexShrink="0"),t.replaceWith(this.spacer),this.spacer.appendChild(t)}release(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left}apply(t,n){const i=Math.max(0,n);this.element.style.position="sticky",this.axis==="x"?(this.spacer.style.width=`${this.element.offsetWidth+i}px`,this.spacer.style.marginRight=this.spacing?"":`-${i}px`,this.element.style.left=`${t}px`):(this.spacer.style.height=`${this.element.offsetHeight+i}px`,this.spacer.style.marginBottom=this.spacing?"":`-${i}px`,this.element.style.top=`${t}px`)}destroy(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left,this.spacer.parentNode&&this.spacer.replaceWith(this.element)}}const Su=.15;function So(e){return typeof e=="object"&&!Array.isArray(e)?e:{snapTo:e}}function Mo(e,t,n){const i=dn(e+t*Su);if(typeof n=="function")return dn(n(i));if(typeof n=="number")return n<=0?e:dn(Math.round(i/n)*n);if(n.length===0)return e;let s=n[0];for(const r of n)Math.abs(r-i)<Math.abs(s-i)&&(s=r);return dn(s)}function To(e,t,n){const i=e.duration??{min:.2,max:.8};if(typeof i=="number")return i;const s=Math.min(1,Math.abs(t)/Math.max(1,n));return i.min+(i.max-i.min)*s}class Eo{rafId=null;cancelEvents=["wheel","touchstart","pointerdown","keydown"];onInterrupt=()=>this.cancel();write;eventTarget;constructor(t,n){this.write=t,this.eventTarget=n}get active(){return this.rafId!==null}animate(t,n,i,s=ge,r){if(this.cancel(),typeof requestAnimationFrame>"u"||i<=0){this.write(n),r?.();return}for(const l of this.cancelEvents)this.eventTarget?.addEventListener(l,this.onInterrupt,{passive:!0});let o=null;const a=l=>{o??=l;const c=Math.min(1,(l-o)/(i*1e3));this.write(t+(n-t)*s(c)),c<1?this.rafId=requestAnimationFrame(a):(this.rafId=null,this.detach(),r?.())};this.rafId=requestAnimationFrame(a)}cancel(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.detach()}detach(){for(const t of this.cancelEvents)this.eventTarget?.removeEventListener(t,this.onInterrupt)}}function dn(e){return Math.max(0,Math.min(1,e))}class Ao{options;scroller;nodes=[];scrollerStart;scrollerEnd;start;end;constructor(t,n,i){this.options=i===!0?{}:i,this.scroller=n;const{startColor:s="#3ecf7a",endColor:r="#ff5a5a",id:o}=this.options,a=o?`${o} `:"",l=(c,h,u)=>{const f=t.createElement("div");return f.textContent=`${a}${c}`,f.setAttribute("aria-hidden","true"),f.className="scroll-marker",Object.assign(f.style,{position:u?"fixed":"absolute",right:`${this.options.indent??0}px`,zIndex:"2147483646",pointerEvents:"none",borderTop:`1px solid ${h}`,color:h,font:`${this.options.fontSize??"11px"} ui-monospace, monospace`,padding:"2px 6px",whiteSpace:"nowrap",background:"rgba(0, 0, 0, 0.35)"}),(n??t.body).appendChild(f),this.nodes.push(f),f};this.scrollerStart=l("scroller-start",s,!n),this.scrollerEnd=l("scroller-end",r,!n),this.start=l("start",s,!1),this.end=l("end",r,!1),n&&getComputedStyle(n).position==="static"&&(n.style.position="relative")}place(t,n){this.start.style.top=`${t.startPage}px`,this.end.style.top=`${t.endPage}px`;const i=this.scroller?n:0;this.scrollerStart.style.top=`${i+t.startViewport}px`,this.scrollerEnd.style.top=`${i+t.endViewport}px`}follow(t,n){this.scroller&&this.place(t,n)}destroy(){for(const t of this.nodes.splice(0))t.remove()}}const Mu=120,Zt=[],Qt=new Set;let Fi=!1;const Tu=()=>{Fi||Qt.size===0||(Fi=!0,queueMicrotask(()=>{Fi=!1;for(const e of Qt)e.afterRefresh()}))},xo=()=>{for(const e of Qt)e.beforeRefresh();for(const e of Zt)e.refresh();for(const e of Qt)e.afterRefresh()};let te={width:0,height:0};const Po=()=>{const e=window.innerWidth,t=window.innerHeight,n=e===te.width&&t!==te.height,i=Math.abs(t-te.height)<te.height*.25,s=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&i&&s||(te={width:e,height:t},xo())};class Ie{timeline;options;running=!1;pin=null;startPx=0;endPx=0;targetProgress=0;displayProgress=0;zone="before";measured=!1;lastScroll=null;lastScrollTime=0;velocityPxPerSecond=0;idleTimer=null;lastEmitted=null;rafId=null;lastFrameTime=null;onScroll=()=>this.update();releaseVelocity=0;snapper;snapTimer=null;markers=null;markerGeometry=null;constructor(t){this.timeline=t.timeline,this.options=t,this.snapper=new Eo(n=>this.scrollTo(n),typeof window<"u"?window:null)}start(){if(this.running)return;this.running=!0,this.timeline?.pause();const t=this.options.pin===!0?this.options.trigger:this.options.pin||null;t&&!this.options.container&&(this.pin=new vo(t,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new Ao(document,this.options.scroller??null,this.options.markers)),this.scrollTarget()?.addEventListener("scroll",this.onScroll,{passive:!0}),Zt.length===0&&typeof window<"u"&&(te={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",Po,{passive:!0})),Zt.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Zt.splice(Zt.indexOf(this),1),Zt.length===0&&typeof window<"u"&&window.removeEventListener("resize",Po),this.stopSmoothing(),this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=null,this.snapTimer!==null&&clearTimeout(this.snapTimer),this.snapTimer=null,this.snapper.cancel())}destroy(){this.stop(),this.pin?.destroy(),this.pin=null,this.markers?.destroy(),this.markers=null}get startOffset(){return this.startPx}get endOffset(){return this.endPx}static refreshAll(){xo()}static onRefresh(t){return Qt.add(t),()=>Qt.delete(t)}get progress(){return this.targetProgress}get velocity(){return this.velocityPxPerSecond}refresh(){if(!this.running)return;this.measured&&this.options.onRefresh?.();const t=this.scrollPosition();this.pin?.release();const n=this.triggerRect();if(n&&this.options.container)this.measureInContainer(this.options.container);else if(n){const i=this.viewportHeight();if(this.startPx=t+Jt(n,i,Ce(this.options.start)??"top bottom"),this.endPx=this.resolveEnd(n,i,t),this.pin){const s=this.relativeRect(this.pin.element.getBoundingClientRect());this.pin.apply(s.top-(this.startPx-t),this.endPx-this.startPx)}this.markerGeometry=this.markers?this.markersFor(i):null}this.markers&&this.markerGeometry&&this.markers.place(this.markerGeometry,t),this.lastScroll=null,this.updateFrom(t,!this.measured),this.measured=!0,Tu()}sample(){this.refresh()}update(t){this.running&&this.updateFrom(t??this.scrollPosition(),!1)}updateFrom(t,n){this.trackVelocity(t),this.markers&&this.markerGeometry&&this.markers.follow(this.markerGeometry,t);const i=this.endPx-this.startPx,s=this.zone;this.targetProgress=i>0?Oi((t-this.startPx)/i):t>=this.startPx?1:0,this.zone=i>0?t<=this.startPx?"before":t>=this.endPx?"after":"active":t>=this.startPx?"after":"before",this.fireBoundaryCallbacks(s,this.zone),n||this.smoothing()<=0?(this.displayProgress=this.targetProgress,this.applyProgress()):(this.emitUpdate(),this.startSmoothing())}smoothing(){const t=this.options.scrub;return typeof t=="number"?Math.max(0,t):0}resolveEnd(t,n,i){const s=Ce(this.options.end)??"bottom top",r=typeof s=="string"?s.trim().match(/^\+=\s*(-?[\d.]+)\s*(%|px)?$/):null;if(r){const o=Number.parseFloat(r[1]);return this.startPx+(r[2]==="%"?n*o/100:o)}return i+Jt(t,n,s)}applyProgress(){const t=this.timeline?.duration??0;this.timeline&&t>0&&this.timeline.seek(this.displayProgress*t),this.emitUpdate()}emitUpdate(){if(!this.options.onUpdate)return;const t=[this.displayProgress,this.velocityPxPerSecond];this.lastEmitted&&this.lastEmitted[0]===t[0]&&this.lastEmitted[1]===t[1]||(this.lastEmitted=t,this.options.onUpdate(t[0],t[1]))}trackVelocity(t){const n=typeof performance<"u"?performance.now():Date.now();this.lastScroll!==null&&n>this.lastScrollTime&&t!==this.lastScroll&&(this.velocityPxPerSecond=(t-this.lastScroll)/(n-this.lastScrollTime)*1e3),(this.lastScroll===null||t!==this.lastScroll)&&(this.lastScroll=t,this.lastScrollTime=n),!(this.velocityPxPerSecond===0||typeof setTimeout>"u")&&(this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this.idleTimer=null,this.releaseVelocity=this.velocityPxPerSecond,this.velocityPxPerSecond=0,this.emitUpdate(),this.scheduleSnap()},Mu))}fireBoundaryCallbacks(t,n){if(t===n)return;const{onEnter:i,onLeave:s,onEnterBack:r,onLeaveBack:o}=this.options;t==="before"?(i?.(),n==="after"&&s?.()):t==="after"?(r?.(),n==="before"&&o?.()):n==="after"?s?.():o?.()}scheduleSnap(){const t=this.options.snap;if(t===void 0||this.snapper.active)return;const n=So(t),i=()=>{this.snapTimer=null;const s=this.endPx-this.startPx,r=this.scrollPosition();if(!this.running||s<=0||r<=this.startPx||r>=this.endPx)return;const o=(r-this.startPx)/s,a=this.startPx+Mo(o,this.releaseVelocity/s,n.snapTo)*s;Math.abs(a-r)<1||this.snapper.animate(r,a,To(n,a-r,this.viewportHeight()),n.ease)};n.delay?this.snapTimer=setTimeout(i,n.delay*1e3):i()}scrollTo(t){const n=this.options.scroller,i=this.options.horizontal?{left:t}:{top:t};n?typeof n.scrollTo=="function"?n.scrollTo({...i,behavior:"instant"}):this.options.horizontal?n.scrollLeft=t:n.scrollTop=t:typeof window<"u"&&window.scrollTo({...i,behavior:"instant"})}measureInContainer(t){const n=this.options.trigger;if(typeof n?.getBoundingClientRect!="function")return;const i=n.getBoundingClientRect(),s=this.options.scroller?.getBoundingClientRect?.().left??0,r=this.options.scroller?this.options.scroller.clientWidth:typeof window<"u"?window.innerWidth:0,o=i.left-s-t.shiftAt(t.progress()),{start:a,end:l}=t.range(),c=d=>a+d*(l-a),h=Li(o,i.width,r,Ce(this.options.start)??"left right",t.shiftAt);this.startPx=c(h);const u=Ce(this.options.end)??"right left",f=typeof u=="string"?u.trim().match(/^\+=\s*(-?[\d.]+)\s*(px)?$/):null;this.endPx=f?this.startPx+Number.parseFloat(f[1]):c(Li(o,i.width,r,u,t.shiftAt)),this.markerGeometry=null}markersFor(t){const n=(r,o)=>{const a=Ce(r)??o;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=Ri(a);return t*l.viewportFraction-l.offsetPx},i=n(this.options.start,"top bottom")??0,s=n(this.options.end,"bottom top")??i;return{startViewport:i,endViewport:s,startPage:this.startPx+i,endPage:this.endPx+s}}startSmoothing(){if(this.rafId!==null||typeof requestAnimationFrame>"u")return;const t=n=>{if(this.rafId=null,!this.running)return;const i=this.lastFrameTime===null?16.67:n-this.lastFrameTime;this.lastFrameTime=n,this.displayProgress=wo(this.displayProgress,this.targetProgress,this.smoothing(),i);const s=Math.abs(this.targetProgress-this.displayProgress)<1e-4;s&&(this.displayProgress=this.targetProgress),this.applyProgress(),s?this.lastFrameTime=null:this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}stopSmoothing(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.lastFrameTime=null}scrollTarget(){return this.options.scroller??(typeof window<"u"?window:null)}scrollPosition(){const t=this.options.scroller,n=this.options.horizontal;return t?(n?t.scrollLeft:t.scrollTop)??0:typeof window<"u"?(n?window.scrollX:window.scrollY)??0:0}triggerRect(){const t=this.options.trigger;return typeof t?.getBoundingClientRect!="function"?null:this.relativeRect(t.getBoundingClientRect())}relativeRect(t){const n=this.options.horizontal,i=n?t.left??0:t.top,s=n?t.right??0:t.bottom,r=n?t.width??0:t.height,o=this.options.scroller;if(o&&typeof o.getBoundingClientRect=="function"){const a=o.getBoundingClientRect(),l=n?a.left:a.top;return{top:i-l,bottom:s-l,height:r}}return{top:i,bottom:s,height:r}}viewportHeight(){const t=this.options.scroller,n=this.options.horizontal;return t?n?t.clientWidth:t.clientHeight:typeof window<"u"?n?window.innerWidth:window.innerHeight:0}}function Ce(e){return typeof e=="function"?e():e}function Eu(e){const t=new Ie(e);return t.start(),t}const Di=new Set,Au=16,_o=.5,xu=2;class Bi{options;frames;running=!1;reduced=!1;current=0;target=0;written=null;velocityPxPerSecond=0;frameId=null;lastTime=null;journey=null;pausedState=!1;effects=[];onWheel=t=>this.wheel(t);onScroll=()=>this.nativeScroll();onResize=()=>this.refresh();onLoad=()=>this.refresh();stopListening=null;constructor(t={}){this.options=t,this.frames=t.frames??{request:n=>requestAnimationFrame(n),cancel:n=>cancelAnimationFrame(n)}}start(){if(this.running||typeof window>"u")return this;this.running=!0,this.reduced=this.options.reducedMotion??(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),this.current=this.target=this.position();const t=this.options.scroller??window;return t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("scroll",this.onScroll,{passive:!0}),window.addEventListener("resize",this.onResize,{passive:!0}),window.addEventListener("load",this.onLoad),Di.add(this),this.stopListening=Ie.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const t of Di)t.refresh()}stop(){if(!this.running)return this;this.running=!1;const t=this.options.scroller??window;return t.removeEventListener("wheel",this.onWheel),t.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("load",this.onLoad),Di.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const t of this.effects)Ni(t.element,t.saved);this.effects=[]}kill(){this.destroy()}get state(){const t=this.limit();return{scroll:this.current,target:this.target,progress:t>0?this.current/t:0,velocity:this.velocityPxPerSecond}}paused(t){return t!==void 0&&(this.pausedState=t,t&&(this.target=this.current,this.journey=null)),this.pausedState}scrollTo(t,n={}){if(!this.running)return;const i=this.clamp(this.resolve(t)+(n.offset??0)),s=Math.abs(i-this.current),r=this.reduced?0:n.duration??Math.min(1.2,Math.max(.4,s/2500));if(r<=0){this.journey=null,this.current=this.target=i,this.write(i),this.applyEffects(0);return}this.target=i,this.journey={from:this.current,to:i,ms:r*1e3,ease:n.ease??ge,elapsed:0},this.requestFrame()}refresh(){if(!this.running)return;this.rest(),this.effects=[];const t=this.options.effects===!0?"[data-speed], [data-lag]":this.options.effects||"";if(t&&!this.reduced){const n=this.options.scroller??document,i=this.position(),s=this.viewportHeight(),r=this.options.scroller?.getBoundingClientRect().top??0;for(const o of n.querySelectorAll(t)){const a=Number.parseFloat(o.dataset.speed??""),l=Number.parseFloat(o.dataset.lag??""),c=o.getBoundingClientRect(),h=c.top-r+i;this.effects.push({element:o,speed:Number.isFinite(a)?a:void 0,lag:Number.isFinite(l)&&l>0?l:void 0,centre:h+c.height/2-s/2,lagged:i,shift:0,saved:o.style.getPropertyValue("translate")})}}this.current=this.target=this.clamp(this.position()),this.applyEffects(0)}rest(){for(const t of this.effects)Ni(t.element,t.saved)}wheel(t){if(this.pausedState||this.reduced||(this.options.smooth??.8)<=0||t.ctrlKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||this.nestedScrollerTakes(t))return;const n=t.deltaMode===1?Au:t.deltaMode===2?this.viewportHeight():1,i=t.deltaY*n*(this.options.wheelMultiplier??1),s=this.clamp(this.target+i);s===this.target&&s===this.current||(t.preventDefault(),this.journey=null,this.target=s,this.requestFrame())}nativeScroll(){const t=this.position();this.written!==null&&Math.abs(t-this.written)<=xu||(this.written=null,this.journey=null,this.cancelFrame(),this.current=this.target=t,this.requestFrame())}nestedScrollerTakes(t){const n=this.options.scroller??document.documentElement;for(let i=t.target;i&&i!==n&&i!==document.body;i=i.parentElement){if(i.hasAttribute?.("data-smooth-ignore"))return!0;const s=getComputedStyle(i);if(!/(auto|scroll)/.test(s.overflowY)||i.scrollHeight<=i.clientHeight)continue;if(t.deltaY<0?i.scrollTop>0:i.scrollTop+i.clientHeight<i.scrollHeight-1)return!0}return!1}requestFrame(){this.frameId!==null||!this.running||(this.frameId=this.frames.request(t=>this.frame(t)))}cancelFrame(){this.frameId!==null&&this.frames.cancel(this.frameId),this.frameId=null,this.lastTime=null}frame(t){this.frameId=null;const n=this.lastTime===null?1e3/60:Math.min(100,t-this.lastTime);this.lastTime=t;const i=this.current;if(this.journey){const r=this.journey;r.elapsed+=n;const o=Math.min(1,r.elapsed/r.ms);this.current=r.from+(r.to-r.from)*r.ease(o),o>=1&&(this.journey=null)}else if(this.current!==this.target){const r=(this.options.smooth??.8)*1e3/3;this.current+=(this.target-this.current)*(1-Math.exp(-n/r)),Math.abs(this.target-this.current)<_o&&(this.current=this.target)}this.current!==i&&this.write(this.current),this.velocityPxPerSecond=n>0?(this.current-i)*1e3/n:0;const s=this.applyEffects(n);this.current!==i&&this.options.onUpdate?.(this.state),this.journey||this.current!==this.target||s?this.requestFrame():(this.lastTime=null,this.velocityPxPerSecond=0)}applyEffects(t){let n=!1;const i=this.current;for(const s of this.effects){let r=0;if(s.speed!==void 0&&(r+=(i-s.centre)*(1-s.speed)),s.lag!==void 0){const o=s.lag*1e3/3;s.lagged=t===0?i:s.lagged+(i-s.lagged)*(1-Math.exp(-t/o)),Math.abs(i-s.lagged)<_o?s.lagged=i:n=!0,r+=i-s.lagged}Ni(s.element,r===0?s.saved:`0 ${Pu(r)}px`),s.shift=r}return n}write(t){const n=Math.round(t);this.written=n;const i=this.options.scroller;i?i.scrollTop=n:window.scrollTo({top:n,behavior:"instant"})}position(){const t=this.options.scroller;return t?t.scrollTop:window.scrollY}viewportHeight(){const t=this.options.scroller;return t?t.clientHeight:window.innerHeight}limit(){const t=this.options.scroller??document.documentElement;return Math.max(0,t.scrollHeight-this.viewportHeight())}clamp(t){return Math.max(0,Math.min(this.limit(),t))}resolve(t){if(typeof t=="number")return t;const n=this.options.scroller??document,i=typeof t=="string"?n.querySelector(t):t;if(!i)return this.current;const s=this.options.scroller?.getBoundingClientRect().top??0,r=this.effects.find(o=>o.element===i)?.shift??0;return i.getBoundingClientRect().top-s+this.position()-r}}function Ni(e,t){t?e.style.setProperty("translate",t):e.style.removeProperty("translate")}function Pu(e){return Math.round(e*100)/100}function _u(e,t){switch(t){case"play":if(e.progress()>=1)break;e.reversed()?e.reverse():e.play();break;case"reverse":if(e.progress()<=0)break;e.reversed()?e.play():e.reverse();break;case"pause":e.pause();break;case"resume":e.resume();break;case"restart":e.restart();break;case"reset":e.pause(),e.progress(0);break;case"complete":e.pause(),e.progress(1);break}}function Wi(e,t,n,i,s=()=>{}){const r=d=>typeof d=="string"?e.query(d)??void 0:d,o=r(t.trigger)??i;if(!o){s(`gsap-compat: scrollTrigger has no trigger element${typeof t.trigger=="string"?` for "${t.trigger}"`:""}`);return}const a=t.scrub===void 0||t.scrub===!1?!1:t.scrub,l=(t.toggleActions??"play none none none").trim().split(/\s+/);let c=0,h;const u=(d,m)=>()=>{m?.(),n&&!a&&_u(n,l[d]??"none"),t.once&&d===0&&queueMicrotask(()=>h.destroy())},f=t.containerAnimation?Hu(e,t.containerAnimation,o,s):void 0;return h=new Ie({trigger:o,start:t.start,end:t.end,scrub:a===!1?void 0:a,pin:t.pin===!0?!0:r(t.pin),scroller:r(t.scroller),horizontal:t.horizontal,pinSpacing:t.pinSpacing,onRefresh:t.invalidateOnRefresh&&n?.invalidate?()=>n.invalidate():void 0,snap:t.snap===void 0?void 0:Iu(t.snap,n),markers:t.markers,container:f,onUpdate:(d,m)=>{if(n&&a!==!1&&n.progress(d),t.onUpdate){const p=d<c||m<0?-1:1;t.onUpdate({progress:d,velocity:m,direction:p})}c=d},onEnter:u(0,t.onEnter),onLeave:u(1,t.onLeave),onEnterBack:u(2,t.onEnterBack),onLeaveBack:u(3,t.onLeaveBack)}),n&&a===!1&&n.progress(0),h.start(),e.own(h)}function Iu(e,t){const n=s=>s==="labels"?r=>Cu(r,t?.labelProgresses?.()??[]):s;if(typeof e!="object"||Array.isArray(e))return n(e);const i=e.ease?xe(e.ease):void 0;return{snapTo:n(e.snapTo),duration:e.duration,delay:e.delay,ease:i?i.fn??J(i.easing):void 0}}function Cu(e,t){return t.reduce((n,i)=>Math.abs(i-e)<Math.abs(n-e)?i:n,t[0]??e)}function Hu(e,t,n,i){const s=()=>t.timeline.getTracks({property:"x"}).map(r=>r.target).filter(r=>{const o=e.elementFor(r);return!!o&&o!==n&&o.contains(n)});return s().length===0&&i("gsap-compat: containerAnimation does not move an ancestor of the trigger along x"),{range:()=>{const r=t.scrollTrigger;return r||i("gsap-compat: containerAnimation needs its own scrollTrigger (created before this one)"),{start:r?.startOffset??0,end:r?.endOffset??0}},progress:()=>t.progress(),shiftAt:r=>{const o=t.timeline.getStateAtTime(r*t.timeline.duration);let a=0;for(const l of s()){const c=o.values.get(l)?.get("x");typeof c=="number"&&(a+=c)}return a}}}class Io{conditions={};scope;host;items=[];snapshots=new Map;constructor(t,n){this.host=t,this.scope=n}add(t){const n=this.host.collector;this.host.setCollector(this);try{const i=t();return typeof i=="function"&&this.items.push({revert:i}),i}finally{this.host.setCollector(n)}}track(t){this.items.push(t)}touch(t,n){this.snapshots.has(t)||this.snapshots.set(t,{name:n,style:t.getAttribute("style"),d:t.getAttribute("d")})}revert(){for(const t of this.items.splice(0).reverse())t.revert?t.revert():t.kill?t.kill():t.destroy?.();for(const[t,{name:n,style:i,d:s}]of this.snapshots)i===null?t.removeAttribute("style"):t.setAttribute("style",i),s!==null&&t.setAttribute("d",s),this.host.forget(n);this.snapshots.clear()}kill(){this.revert()}}class $u{host;scope;entries=[];listeners=[];scheduled=!1;constructor(t,n){this.host=t,this.scope=n}add(t,n){const i={conditions:t,setup:n,queries:new Map},s=typeof t=="string"?{matches:t}:t;if(typeof window<"u"&&typeof window.matchMedia=="function")for(const[r,o]of Object.entries(s)){const a=window.matchMedia(o);i.queries.set(r,a);const l=()=>this.scheduleUpdate();a.addEventListener("change",l),this.listeners.push(()=>a.removeEventListener("change",l))}return this.entries.push(i),this.update(i),this}revert(){for(const t of this.listeners.splice(0))t();for(const t of this.entries.splice(0))t.context?.revert()}kill(){this.revert()}scheduleUpdate(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1;for(const t of this.entries)this.update(t)}))}update(t){const n={};for(const[o,a]of t.queries)n[o]=a.matches;const i=Object.values(n).some(Boolean),s=i?JSON.stringify(n):void 0;if(s===t.key||(t.context?.revert(),t.context=void 0,t.key=s,!i))return;const r=new Io(this.host,this.scope);r.conditions=n,r.add(()=>t.setup(r)),t.context=r}}class Ru{frames;canvas;context;options;images;ready;current=0;drawn=-1;loadedCount=0;inFlight=0;destroyed=!1;onResize=()=>this.resize();constructor(t,n){this.canvas=t,this.context=t.getContext("2d"),this.options=n,this.frames=Math.max(1,Math.floor(n.frames)),this.images=new Array(this.frames),this.ready=new Array(this.frames).fill(!1),typeof window<"u"&&window.addEventListener("resize",this.onResize,{passive:!0}),this.resize(),this.pump()}get frame(){return this.current}set frame(t){this.current=Math.max(0,Math.min(this.frames-1,t)),this.draw()}get loaded(){return this.loadedCount}destroy(){this.destroyed=!0,typeof window<"u"&&window.removeEventListener("resize",this.onResize);for(const t of this.images)t&&(t.src="")}resize(){const t=typeof window<"u"?Math.min(window.devicePixelRatio||1,2):1,n=Math.round(this.canvas.clientWidth*t),i=Math.round(this.canvas.clientHeight*t);n>0&&i>0&&(this.canvas.width!==n||this.canvas.height!==i)&&(this.canvas.width=n,this.canvas.height=i),this.drawn=-1,this.draw()}draw(){const t=Math.round(this.current),n=this.nearestReady(t);if(n===-1||n===this.drawn||!this.context)return;const i=this.images[n],{width:s,height:r}=this.canvas,o=(this.options.fit??"cover")==="cover"?Math.max(s/i.naturalWidth,r/i.naturalHeight):Math.min(s/i.naturalWidth,r/i.naturalHeight),a=i.naturalWidth*o,l=i.naturalHeight*o;this.context.clearRect(0,0,s,r),this.context.drawImage(i,(s-a)/2,(r-l)/2,a,l),this.drawn=n,this.pump()}nearestReady(t){for(let n=0;n<this.frames;n++){if(t-n>=0&&this.ready[t-n])return t-n;if(t+n<this.frames&&this.ready[t+n])return t+n}return-1}pump(){const t=this.options.concurrency??6,n=Math.round(this.current);for(let i=0;i<this.frames&&this.inFlight<t;i++)for(const s of i===0?[n]:[n+i,n-i])s<0||s>=this.frames||this.images[s]||this.inFlight>=t||this.load(s)}load(t){const n=new Image;n.decoding="async",this.images[t]=n,this.inFlight++;const i=s=>{if(!this.destroyed){if(this.inFlight--,s){this.ready[t]=!0,this.loadedCount++,this.options.onProgress?.(this.loadedCount,this.frames);const r=Math.round(this.current);(Math.abs(t-r)<Math.abs(this.drawn-r)||this.drawn===-1)&&(this.drawn=-1,this.draw())}this.pump()}};n.onload=()=>i(!0),n.onerror=()=>i(!1),n.src=this.options.url(t)}}const Ou={opacity:0,y:-16},Lu={opacity:0,y:16};async function Fu(e,t,n,i){const s=t.collector?.scope??t.root,r=s.ownerDocument??s,o=()=>i.shared?[...s.querySelectorAll(i.shared)]:[];if(i.native&&typeof r.startViewTransition=="function")return Du(r,i,o);const a=i.duration??.35,l=i.ease??"power2.inOut",c=g=>new Promise(y=>{g(y)||y()}),h=o(),u=h.length?Ii(t,h):void 0,f=i.from!==void 0?Co(t,i.from,i.shared):[];if(f.length&&i.leave!==!1){const g=i.leave??Ou;await c(y=>e.to(f,{...g,duration:a,ease:l,onComplete:y}))}await i.update();const d=[],m=typeof i.to=="function"?i.to():i.to,p=m!==void 0?Co(t,m,i.shared):[];if(p.length&&i.enter!==!1){const g=i.enter??Lu;d.push(c(y=>e.fromTo(p,g,{...yo(g),duration:a,ease:l,onComplete:y})))}if(u){const g=o().filter(y=>!h.includes(y));g.length&&d.push(c(y=>Hi(t,n,u,{targets:g,duration:a*1.4,ease:l,enter:!1,onComplete:y})))}await Promise.all(d)}function Co(e,t,n){const i=e.resolveTargets(t).map(s=>e.elementFor(s)).filter(s=>!!s);return n?i.flatMap(s=>!s.querySelector(n)&&!s.matches(n)?[s]:[...s.children].filter(r=>!r.matches(n)&&!r.querySelector(n))):i}async function Du(e,t,n){const i=(a,l)=>{const c=a.dataset?.flipId;c&&a.style.setProperty("view-transition-name",l?`tf-${c.replace(/[^\w-]/g,"-")}`:"")},s=n();s.forEach(a=>i(a,!0));let r=[];await e.startViewTransition(async()=>{s.forEach(a=>i(a,!1)),await t.update(),r=n(),r.forEach(a=>i(a,!0))}).finished,r.forEach(a=>i(a,!1))}const Ho={create:(e,t)=>vi(e,Hr(t))},$o={create:(e,t)=>vi(e,{fn:$r(t)})},Ro={create:(e,t)=>vi(e,{fn:Rr(t)})},Bu=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),Oo=.5,Nu="power1.inOut";function Wu(e){return e.keyframes!==void 0&&e.keyframes!==null}function Ku(e){const t=e.keyframes,n={};for(const[c,h]of Object.entries(e))Bu.has(c)||(n[c]=h);if(Array.isArray(t))return t.map(c=>({...n,...c,duration:c.duration??e.duration??Oo}));const i=Object.entries(t),s=e.duration??Oo,r=t.easeEach??e.easeEach??Nu;if(i.length>0&&i.every(([c])=>/^\s*-?\d+(\.\d+)?\s*%\s*$/.test(c)||c==="easeEach")){const c=i.filter(([f])=>f!=="easeEach").map(([f,d])=>({at:Number.parseFloat(f)/100,step:d})).sort((f,d)=>f.at-d.at),h=[];let u=0;for(const{at:f,step:d}of c){const m=Math.max(0,f-u);h.push({...n,ease:r,...d,duration:m*s}),u=f}return h}const o=i.filter(([c,h])=>c!=="easeEach"&&Array.isArray(h)),a=Math.max(0,...o.map(([,c])=>c.length)),l=[];for(let c=0;c<a;c++){const h={...n,ease:r,duration:s/a};for(const[u,f]of o)c<f.length&&(h[u]=f[c]);l.push(h)}return l}function Lo(e,t,n,i={}){const s=t.collector?.scope??t.root,r=typeof i.scroller=="string"?s.querySelector(i.scroller):i.scroller??null,o={x:r?r.scrollLeft:window.scrollX,y:r?r.scrollTop:window.scrollY},a={x:r?r.scrollWidth-r.clientWidth:document.documentElement.scrollWidth-window.innerWidth,y:r?r.scrollHeight-r.clientHeight:document.documentElement.scrollHeight-window.innerHeight},l=(w,k)=>{if(k===void 0)return o[w];if(typeof k=="number")return k;if(k==="max")return a[w];const M=typeof k=="string"?s.querySelector(k):k;if(!M)return o[w];const S=M.getBoundingClientRect(),A=r?.getBoundingClientRect(),E=(w==="x"?i.offsetX:i.offsetY)??i.offset??0;return w==="x"?S.left-(A?.left??0)+o.x-E:S.top-(A?.top??0)+o.y-E},c=typeof n=="object"&&n!==null&&!("nodeType"in n)?{x:l("x",n.x),y:l("y",n.y)}:{x:o.x,y:l("y",n)},h={x:Math.max(0,Math.min(a.x,c.x)),y:Math.max(0,Math.min(a.y,c.y))},u={...o},f=()=>{r?(r.scrollLeft=u.x,r.scrollTop=u.y):window.scrollTo({left:u.x,top:u.y,behavior:"instant"})},d=["wheel","touchstart","keydown"],m=r??window,p=()=>{y.kill(),g()},g=()=>{for(const w of d)m.removeEventListener(w,p)},y=e.to(u,{x:h.x,y:h.y,duration:i.duration??1,ease:i.ease??"power2.inOut",onStart:i.onStart,onUpdate:()=>{f(),i.onUpdate?.()},onComplete:()=>{g(),i.onComplete?.()}});if(i.autoKill!==!1)for(const w of d)m.addEventListener(w,p,{passive:!0});return y}function Yu(e,t,n){const i=e.collector?.scope??e.root,s=typeof t=="string"?[...i.querySelectorAll(t)]:"nodeType"in t?[t]:Array.from(t),{interval:r=.1,batchMax:o,onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h,...u}=n,f={onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h},d={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},m={},p=y=>{m[y]!==void 0&&clearTimeout(m[y]),m[y]=void 0;const w=d[y].splice(0);w.length>0&&f[y]?.(w)},g=(y,w)=>{if(f[y]){if(d[y].push(w),o!==void 0&&d[y].length>=o)return p(y);m[y]===void 0&&(m[y]=setTimeout(()=>p(y),r*1e3))}};return s.map(y=>Wi(e,{...u,trigger:y,onEnter:()=>g("onEnter",y),onLeave:()=>g("onLeave",y),onEnterBack:()=>g("onEnterBack",y),onLeaveBack:()=>g("onLeaveBack",y)})).filter(y=>y!==void 0)}class ut{compat;stage;options;autoplayPending;started=!1;killed=!1;recipe=[];firstElement;scrollDriver;events=[];ranges=[];playhead={time:0,iteration:0,direction:"forward",fresh:!0};waitingToWrap=!1;finishedThisFrame=!1;backwards=!1;constructor(t,n={}){this.stage=t;const i={...n,onWarning:n.onWarning??t.onWarning};if(this.options=i,this.compat=new It({...i,startValue:(s,r)=>{const o=t.objectFor(s);if(o)return Vu(o[r]);const a=t.appliedValue(s,r);if(a!==void 0)return a;if(r==="d")return oo(t.elementFor(s))??void 0;if(r==="text")return t.elementFor(s)?.textContent??void 0;if(r==="strokeDasharray"||r==="strokeDashoffset"){const l=Wo(t.elementFor(s));if(l!==void 0)return r==="strokeDasharray"?[l,l]:0}},startVelocity:(s,r)=>t.velocityOf(s,r),layoutColumns:s=>No(s.map(r=>t.elementFor(r))),random:()=>t.utils.random(0,1)}),this.compat.timeline.onComplete=()=>{this.finishedThisFrame=!0},t.collector?.track(this),t.liveTimelines.add(this),this.autoplayPending=!i.paused&&!i.scrollTrigger,i.scrollTrigger){const s=i.scrollTrigger;queueMicrotask(()=>{this.killed||(this.scrollDriver=Wi(t,s,this,this.firstElement,r=>i.onWarning?.(r)))})}this.autoplayPending&&queueMicrotask(()=>{this.autoplayPending&&this.play()})}get timeline(){return this.compat.timeline}get scrollTrigger(){return this.scrollDriver}to(t,n,i){return Wu(n)?this.record(()=>this.keyframed(t,n,i)):this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.to(r,s,o)))}from(t,n,i){return this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.from(r,s,o)))}fromTo(t,n,i,s){return this.record(()=>this.tween(t,[n,i],s,([r,o],a,l)=>this.compat.fromTo(a,r,o,l)))}set(t,n,i){return this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.set(r,s,o)))}addLabel(t,n){return this.record(()=>this.compat.addLabel(t,n))}add(t,n){return this.record(()=>{t.autoplayPending=!1,t.timeline.stop(),t.stage.deactivate(t.timeline),this.compat.add(t.compat,n)})}invalidate(){const t=this.compat.progress();this.compat.progress(0),this.stage.render(this.timeline),this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();return this.syncDuration(),this.compat.progress(t),this.stage.render(this.timeline),this}call(t,n=[],i){return this.record(()=>{const s=this.compat.addEvent(i);this.events.push({time:s,run:()=>t(...n)})})}addPause(t,n,i=[]){return this.record(()=>{const s=this.compat.addEvent(t);this.events.push({time:s,pause:!0,run:()=>n?.(...i)})})}tweenTo(t,n={}){return this.tweenFromTo(this.timeline.currentTime/1e3,t,n)}tweenFromTo(t,n,i={}){this.pause(),this.seek(t);const s=this.timeline.currentTime,r=Math.max(0,Math.min(this.timeline.duration,this.compat.timeOf(n))),o={time:s},a=i.duration??Math.abs(r-s)/1e3/(this.timeScale()||1),l=new ut(this.stage,{onStart:i.onStart,onComplete:i.onComplete});return l.to(o,{time:r,duration:a,ease:i.ease??"none",onUpdate:()=>{this.moveTo(o.time),i.onUpdate?.()}}),l}play(){this.autoplayPending=!1,this.started||(this.started=!0,this.options.onStart?.());const t=this.timeline.playbackState==="playing",n=this.timeline.playbackState==="paused";if(this.timeline.play(),!t){const i=this.timeline,s=i.direction==="forward"?i.currentTime===0:i.currentTime===i.duration;this.playhead={...this.readPlayhead(),fresh:s&&!n},this.waitingToWrap=!1}return this.stage.liveTimelines.add(this),this.stage.render(this.timeline),this.stage.activate(this.timeline,{onUpdate:()=>this.afterFrame()}),this}pause(){return this.autoplayPending=!1,this.timeline.pause(),this.stage.deactivate(this.timeline),this}resume(){return this.play()}restart(){return this.timeline.stop(),this.backwards=!1,this.play()}reverse(){this.backwards=!this.backwards;const t=this.timeline.playbackState==="idle"&&this.timeline.direction==="forward";return this.timeline.reverse(),t&&this.timeline.currentTime===0&&this.timeline.seek(this.timeline.duration),this.play()}labelProgresses(){const t=this.timeline.duration;return t>0?this.compat.labelTimes().map(n=>n/t):[]}reversed(){return this.timeline.direction==="reverse"}seek(t){return this.autoplayPending=!1,this.compat.seek(t),this.stage.render(this.timeline),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,this.options.onUpdate?.(),this}progress(t){return t===void 0?this.compat.progress():(this.autoplayPending=!1,this.moveTo(Math.max(0,Math.min(1,t))*this.timeline.duration),this.compat.progress())}timeScale(t){return this.compat.timeScale(t)}duration(){return this.compat.duration()}isActive(){return this.timeline.playbackState==="playing"}kill(){return this.killed=!0,this.stage.liveTimelines.delete(this),this.scrollDriver?.destroy(),this.scrollDriver=void 0,this.autoplayPending=!1,this.timeline.stop(),this.stage.deactivate(this.timeline),this.compat.kill(),this}toDefinition(){return this.compat.toDefinition()}killTweensOf(t,n){for(const i of t)for(const s of n??[void 0])this.timeline.removeTracks({target:i,...s!==void 0&&{property:s}});this.timeline.tracks.length===0&&this.events.length===0&&this.kill()}record(t){return this.recipe.push(t),t(),this.syncDuration(),this}syncDuration(){if(this.events.length===0)return;this.timeline.setDuration(void 0);const t=Math.max(...this.events.map(n=>n.time));t>this.timeline.duration&&this.timeline.setDuration(t)}readPlayhead(){const t=this.timeline;return{time:t.currentTime,iteration:t.loopIteration,direction:t.direction}}moveTo(t){const n=this.playhead;this.timeline.seek(t),this.stage.render(this.timeline);const i={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:t>=n.time?"forward":"reverse"},s={...n,iteration:i.iteration,direction:i.direction};this.playhead={...this.readPlayhead()},this.waitingToWrap=!1,this.runCrossings(s,i,!1),this.options.onUpdate?.()}refreshForRepeat(){const t=this.timeline.currentTime;this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();this.syncDuration(),this.timeline.seek(Math.min(t,this.timeline.duration))}afterFrame(){const t=this.timeline,n=t.repeatDelayRemaining>0;if(this.waitingToWrap&&n){this.options.onUpdate?.();return}this.waitingToWrap=!1;const i=this.playhead,s=this.readPlayhead();this.playhead=s;const r=this.options.yoyo===!0;n&&!r&&s.iteration>i.iteration&&(this.playhead={time:0,iteration:s.iteration,direction:"forward",fresh:!0},this.waitingToWrap=!0);const o=this.runCrossings(i,s,n);if(this.options.onUpdate?.(),this.finishedThisFrame&&!o){this.finishedThisFrame=!1;const a=t.currentTime===0&&t.direction==="reverse";!this.scrollDriver&&!r&&this.stage.liveTimelines.delete(this),a&&this.backwards?this.options.onReverseComplete?.():this.options.onComplete?.()}this.finishedThisFrame=!1}runCrossings(t,n,i){if(this.events.length===0&&this.ranges.length===0&&!this.options.onRepeat&&!this.options.repeatRefresh)return!1;const s=this.events,{crossings:r,passes:o}=mi(s.map(a=>a.time),t,n,{duration:this.timeline.duration,alternate:this.options.yoyo===!0,holding:i});for(const a of r){if(this.killed)return!0;if(a.kind==="repeat"){this.options.repeatRefresh&&this.refreshForRepeat(),this.options.onRepeat?.();continue}const l=s[a.index];if(!(l.direction&&l.direction!==a.direction)){if(l.pause)return this.timeline.seek(l.time),this.stage.render(this.timeline),this.pause(),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,l.run(),!0;l.run()}}for(const a of this.ranges)o.some(([c,h])=>c!==h&&Math.max(c,h)>=a.start&&Math.min(c,h)<=a.end)&&a.run();return!1}tween(t,n,i,s){const r=this.resolve(t);if(!r)return;const{onStart:o,onUpdate:a,onComplete:l}=n[n.length-1];if(o||a||l){let c=1/0,h=-1/0;const u=(f,d,m)=>{s(f,d,m),c=Math.min(c,this.compat.lastStart),h=Math.max(h,this.compat.lastEnd)};if(this.buildTween(r,n,i,u),c===1/0)return;o&&this.events.push({time:c,direction:"forward",run:o}),a&&this.ranges.push({start:c,end:h,run:a}),l&&this.events.push({time:h,direction:"forward",run:l});return}this.buildTween(r,n,i,s)}keyframed(t,n,i){const s=this.resolve(t);if(!s)return;const r=Ku(n);if(r.length===0)return;const o=s.length>1?Ti(n.stagger,this.staggerContext(s)):void 0,a=s.map(g=>this.targetFor(g)).filter(g=>g!==void 0),l=o?a.map(g=>[g]):[a],c=o?qe(s.length,o).map(g=>g/1e3):[0],h=this.compat.timeOf(i)/1e3+un(n.delay,0)/1e3;let u=1/0,f=-1/0;if(l.forEach((g,y)=>{r.forEach((w,k)=>{const M=k===0?h+c[y]:">";this.tween(g,[w],M,([S],A,E)=>this.compat.to(A,S,E)),u=Math.min(u,this.compat.lastStart),f=Math.max(f,this.compat.lastEnd)})}),u===1/0)return;const{onStart:d,onUpdate:m,onComplete:p}=n;d&&this.events.push({time:u,direction:"forward",run:d}),m&&this.ranges.push({start:u,end:f,run:m}),p&&this.events.push({time:f,direction:"forward",run:p})}staggerContext(t){return{count:t.length,columnsFromLayout:()=>No(t.map(n=>this.stage.elementFor(n))),random:()=>this.stage.utils.random(0,1)}}buildTween(t,n,i,s){const r=t.map(f=>this.targetFor(f));if(!(t.length>1&&(n.some(qu)||t.some(f=>this.stage.objectFor(f)!==void 0)))){const f=this.targetFor(t[0]);s(n.map(d=>this.prepare(Bo(d,0,f,this.stage.utils,r),t)),t,i);return}const a=n.length-1,{stagger:l,...c}=n[a],h=Ti(l,this.staggerContext(t)),u=h?qe(t.length,h).map(f=>f/1e3):t.map(()=>0);t.forEach((f,d)=>{const m=d===0?un(c.delay,0)/1e3+u[0]:0,p=d===0?0:u[d]-u[d-1],g=d===0?i:`<${p<0?"-":"+"}${Math.abs(p).toFixed(6)}`,w=n.map((k,M)=>M===a?{...c,delay:m}:k).map(k=>this.prepare(Bo(k,d,this.targetFor(f),this.stage.utils,r),[f]));s(w,[f],g)})}targetFor(t){return this.stage.elementFor(t)??this.stage.objectFor(t)}prepare(t,n){const i=o=>this.options.onWarning?.(o),s=o=>this.stage.query(o);let r=t;if(t.motionPath!==void 0){const o=iu(t.motionPath,{query:s,targets:n.map(a=>this.stage.elementFor(a)).filter(a=>!!a),warn:i});r={...r,motionPath:o}}if(t.morphSVG!==void 0){const o=su(t.morphSVG,s,i),{morphSVG:a,...l}=r;r=o?{...r,morphSVG:o}:l}if(t.drawSVG!==void 0){const o=Wo(this.stage.elementFor(n[0]));if(o===void 0){i("gsap-compat: drawSVG needs an SVG shape with a stroke (path, line, circle…)");const{drawSVG:a,...l}=r;r=l}else r=Ih(r,o)}return r}resolve(t){const n=this.stage.resolveTargets(t);if(n.length===0){this.options.onWarning?.(`gsap-compat: no elements found for target ${Uu(t)}`);return}return this.firstElement??=n.map(i=>this.stage.elementFor(i)).find(i=>i!==void 0),n}}function Fo(e=new no){const t=r=>{const{config:o}=hn(r);return new ut(e,{repeat:o.repeat,yoyo:o.yoyo,repeatDelay:o.repeatDelay,paused:o.paused,onStart:o.onStart,onUpdate:o.onUpdate,onComplete:o.onComplete,onRepeat:o.onRepeat,onReverseComplete:o.onReverseComplete,repeatRefresh:o.repeatRefresh,scrollTrigger:o.scrollTrigger})},n=r=>{const{onStart:o,onUpdate:a,onComplete:l,onRepeat:c,onReverseComplete:h,repeatRefresh:u,...f}=r;return f},i=r=>(r&&e.collector?.track(r),r),s={stage:e,ticker:e.ticker,utils:e.utils,getProperty:(r,o)=>{const[a]=e.resolveTargets(r);if(a===void 0)return;const l=e.objectFor(a);return l?l[o]:e.appliedValue(a,o)??Jr(o)},scrollTrigger:r=>i(Wi(e,r)),scrollBatch:(r,o)=>Yu(e,r,o).map(a=>i(a)),scrollTo:(r,o)=>Lo(s,e,r,o),refreshScroll:()=>{Ie.refreshAll(),Bi.refreshAll()},smoothScroll:(r={})=>{const o=typeof r.scroller=="string"?(e.collector?.scope??e.root).querySelector(r.scroller):r.scroller;return i(new Bi({...r,scroller:o}).start())},context:(r,o)=>{const a=new Io(e,o);return r&&a.add(()=>r(a)),a},matchMedia:r=>new $u(e,r),customEase:Ho.create,customBounce:$o.create,customWiggle:Ro.create,pageTransition:r=>Fu(s,e,o=>new ut(e,o),r),imageSequence:(r,o)=>{const a=typeof r=="string"?(e.collector?.scope??e.root).querySelector(r):r;if(!(a instanceof HTMLCanvasElement))throw new Error(`gsap-compat: imageSequence needs a <canvas>, got ${String(r)}`);return i(new Ru(a,o))},quickTo:(r,o,a={})=>{const l=new ut(e,{paused:!0}),[c]=e.resolveTargets(r);return Object.assign(u=>{if(!c)return;const f=a.spring!==void 0?e.velocityOf(c,o)??0:0;l.compat.reset(),l.compat.to(c,{[o]:u,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:Xu(a.spring,o,f)}}),l.timeline.stop(),l.timeline.play(),e.activate(l.timeline)},{tween:l,kill:()=>l.kill()})},timeline:r=>new ut(e,r),to:(r,o)=>{if(o.scrollTo!==void 0){const{scrollTo:a,...l}=o,c=typeof a=="object"&&a!==null&&!("nodeType"in a)?a:{},h=typeof r!="string"&&r!==window&&r.nodeType===1;return Lo(s,e,a,{...l,offsetX:c.offsetX,offsetY:c.offsetY,scroller:h?r:void 0})}return t(o).to(r,n(o))},from:(r,o)=>t(o).from(r,n(o)),fromTo:(r,o,a)=>t(a).fromTo(r,o,n(a)),set:(r,o)=>t(o).set(r,n(o)),delayedCall:(r,o,a)=>new ut(e).call(o,a,r),killTweensOf:(r,o)=>{const a=e.resolveTargets(r),l=typeof o=="string"?o.split(",").map(c=>c.trim()).filter(Boolean):o;for(const c of[...e.liveTimelines])c.killTweensOf(a,l)},convertToPath:r=>ou(r,e.root),splitText:(r,o)=>{const a=e.collector?.scope??e.root,l=typeof r=="string"?Array.from(a.querySelectorAll(r)):"nodeType"in r?[r]:Array.from(r);return i(pu(l,o))},draggable:(r,o)=>i(hu(s,e,r,o)),getFlipState:r=>Ii(e,r),flipFrom:(r,o)=>Hi(e,a=>new ut(e,a),r,o),flip:(r,o,a)=>{const l=Ii(e,r);return o(),Hi(e,c=>new ut(e,c),l,{targets:r,...a})}};return s}const tt=Fo();function Xu(e,t,n){return e===!0?{velocity:{[t]:n}}:typeof e=="string"?{preset:e,velocity:{[t]:n}}:{...e,velocity:{[t]:n}}}function qu(e){return e.morphSVG!==void 0||e.drawSVG!==void 0||e.text!==void 0||e.scrambleText!==void 0||Do(e)}function Do(e){return Object.entries(e).some(([t,n])=>(typeof n=="function"||Gr(n))&&!Mi.has(t))}function Bo(e,t,n,i,s){if(!Do(e))return e;const r={};for(const[o,a]of Object.entries(e))Mi.has(o)?r[o]=a:typeof a=="function"?r[o]=a(t,n,s):Gr(a)?r[o]=i.resolveRandomString(a):r[o]=a;return r}function No(e){const t=e.map(i=>i?.getBoundingClientRect().top);if(t[0]===void 0)return e.length;let n=0;for(const i of t){if(i===void 0||Math.abs(i-t[0])>1)break;n++}return Math.max(1,n)}function Wo(e){const t=e;if(typeof t?.getTotalLength=="function")return t.getTotalLength()}function Vu(e){if(typeof e=="number"||typeof e=="string"||Array.isArray(e)&&e.every(t=>typeof t=="number"))return e}function Uu(e){return typeof e=="string"?`"${e}"`:String(e)}class Ki{media;offset;driftTolerance;constructor(t,n={}){this.media=t,this.offset=n.offset??0,this.driftTolerance=Math.max(0,n.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,n){const i=this.targetTime(t);n?(this.media.paused&&this.safePlay(),Math.abs(this.media.currentTime-i)>this.driftTolerance&&(this.media.currentTime=i)):(this.media.paused||this.media.pause(),this.media.currentTime!==i&&(this.media.currentTime=i))}seek(t){this.media.currentTime=this.targetTime(t)}setRate(t){this.media.playbackRate=t}dispose(){this.media.paused||this.media.pause()}safePlay(){const t=this.media.play();t&&typeof t.catch=="function"&&t.catch(()=>{})}}function Ko(e,t,n,i,s){const r=n-s;if(r<0){t.paused||t.pause(),t.currentTime=0;return}e.update(r,i)}class pn{container;timeline=null;adapter;animationFrameId;lastTime;options;targets={};isDestroyed=!1;mediaSync;mediaTargets=[];symbolInstances=[];scenarioList=[];scenarioId;authored=new Map;markerList=[];listeners=new Set;playhead={time:0,iteration:0,direction:"forward"};stepping=!1;lastMarkerId=null;reducedQuery;onReducedChange=()=>this.applyReducedMotion();visibilityObserver;onScreen=!0;pausedByVisibility=!1;autoplayWhenSeen=!1;onDocumentVisibility=()=>this.updateVisibility();constructor(t,n={}){if(typeof t=="string"){const i=document.querySelector(t);if(!i)throw new Error(`Container not found: ${t}`);this.container=i}else this.container=t;this.options=n,this.adapter=new Ct}async load(t){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(t)}async loadSource(t){let n;if(typeof t=="string"){const i=await fetch(t);if(!i.ok)throw new Error(`Failed to load animation: ${i.statusText}`);n=await i.json()}else n=t;this.useDefinition(n),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(t){const n={...t.config};this.options.speed!==void 0&&(n.speed=this.options.speed),this.options.loop!==void 0&&(n.loop=this.options.loop),this.options.alternate!==void 0&&(n.alternate=this.options.alternate),this.timeline=zt({...t,config:n}),this.markerList=this.timeline.markers,this.lastMarkerId=null,this.options.onComplete&&(this.timeline.onComplete=this.options.onComplete),this.options.onUpdate&&(this.timeline.onUpdate=this.options.onUpdate),this.autoRegisterTargets(),this.setupSymbolInstances(),this.scanMedia()}async loadScenarios(t,n={}){if(t.length===0)throw new Error("tinyfly: loadScenarios needs at least one scenario");const i=new Set;for(const r of t){if(i.has(r.id))throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);i.add(r.id)}const s=n.initial===void 0?t[0]:t.find(r=>r.id===n.initial);if(!s)throw new Error(`tinyfly: there is no scenario "${n.initial}"`);this.scenarioList=[...t],this.scenarioId=s.id,await this.loadSource(s.timeline)}get scenarios(){return this.scenarioList.map(t=>({id:t.id,label:t.label??t.id}))}get scenario(){return this.scenarioId}setScenario(t){const n=this.scenarioList.find(a=>a.id===t);if(!n||!this.timeline)return!1;if(t===this.scenarioId)return!0;const i=this.isPlaying,s=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=t,this.useDefinition(n.timeline),this.lastMarkerId=null;let o=0;return this.reducedMotion||s?o=this.duration:r!==void 0&&(o=this.markers.find(a=>a.id===r)?.time??0),this.seek(o),i&&!this.reducedMotion?(this.stepping=this.options.stepMode===!0,this.startPlaying()):this.notify(),!0}rememberAuthored(t){if(this.authored.has(t))return;const n={style:t.getAttribute("style")};t.children.length===0&&(n.text=t.textContent??"");const i=t.tagName.toLowerCase()==="path"?t:t.querySelector("path");i&&(n.path={element:i,d:i.getAttribute("d")}),this.authored.set(t,n)}restoreAuthored(){for(const[t,n]of this.authored){n.style===null?t.removeAttribute("style"):t.setAttribute("style",n.style),n.text!==void 0&&t.textContent!==n.text&&(t.textContent=n.text),n.path&&(n.path.d===null?n.path.element.removeAttribute("d"):n.path.element.setAttribute("d",n.path.d));const i=t.dataset;i&&delete i.shineBase}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){for(const t of this.listeners)t()}get reducedMotion(){return this.reducedQuery?.matches===!0}get markers(){return this.markerList}get currentMarker(){const t=this.currentTime;let n;for(const i of this.markers)if(i.time<=t+.5)n=i;else break;return n}caption(t,n){const i=t?this.markers.find(o=>o.id===t):this.currentMarker;if(!i)return;const s=n??this.language(),r=o=>o?.[s]?.[i.id]??o?.[s.split("-")[0]]?.[i.id];return r(this.options.captions)??r(this.timeline?.captions)??i.label}next(){if(!this.timeline)return;const t=this.currentTime,n=this.markers.find(i=>i.time>t+.5);if(this.reducedMotion){this.seek(n?n.time:this.duration);return}t>=this.duration-.5||(this.stepping=n!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,n=[...this.markers].reverse().find(i=>i.time<t-.5);this.pause(),this.seek(n?n.time:0)}goToMarker(t){const n=this.markers.find(i=>i.id===t);n&&(this.pause(),this.seek(n.time))}language(){return this.container.closest("[lang]")?.getAttribute("lang")||(typeof document<"u"?document.documentElement.lang:"")||"en"}showInitialFrame(){if(!this.timeline)return;const t=this.options.initialFrame??"start";if(t==="none")return;const n=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,n))),this.applyState()}watchReducedMotion(){this.options.respectReducedMotion===!1||typeof window>"u"||typeof window.matchMedia!="function"||(this.reducedQuery??=window.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedQuery.addEventListener?.("change",this.onReducedChange),this.reducedQuery.matches&&this.applyReducedMotion())}applyReducedMotion(){!this.reducedMotion||!this.timeline||(this.autoplayWhenSeen=!1,this.pause(),this.seek(this.timeline.duration))}watchVisibility(){if(!(!this.options.playWhenVisible||typeof window>"u")){if(typeof IntersectionObserver=="function"){this.visibilityObserver?.disconnect(),this.visibilityObserver=new IntersectionObserver(n=>{for(const i of n)this.onScreen=i.isIntersecting;this.updateVisibility()}),this.visibilityObserver.observe(this.container);const t=this.container.getBoundingClientRect?.();t&&(t.width>0||t.height>0)&&(this.onScreen=t.bottom>0&&t.top<window.innerHeight&&t.right>0&&t.left<window.innerWidth)}document.addEventListener("visibilitychange",this.onDocumentVisibility)}}updateVisibility(){const t=this.onScreen&&document.visibilityState!=="hidden";!t&&this.isPlaying?(this.pausedByVisibility=!0,this.pause()):t&&(this.pausedByVisibility||this.autoplayWhenSeen)&&!this.reducedMotion&&(this.pausedByVisibility=!1,this.autoplayWhenSeen=!1,this.startPlaying())}announceMarker(){if(!this.options.onMarker)return;const t=this.currentMarker,n=t?.id;n!==this.lastMarkerId&&(this.lastMarkerId=n,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(n=>{const i=n,s=Number(i.getAttribute("data-tinyfly-start")??"0")||0,r=i.getAttribute("data-volume");r!==null&&(i.volume=Math.max(0,Math.min(1,Number(r)||0))),this.mediaTargets.push({el:i,startTime:s,sync:new Ki(i)})})}syncAllMedia(t,n){for(const i of this.mediaTargets)Ko(i.sync,i.el,t,n,i.startTime)}loadFromString(t){const n=JSON.parse(t);this.load(n)}registerTarget(t,n){if(typeof n=="string"){const i=this.container.querySelector(n);i&&(this.rememberAuthored(i),this.targets[t]=i,this.adapter.registerTarget(t,i))}else this.rememberAuthored(n),this.targets[t]=n,this.adapter.registerTarget(t,n)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(n=>{const i=n.closest("[data-tinyfly-symbol]");if(i&&i!==n)return;const s=n.getAttribute("data-tinyfly");s&&this.registerTarget(s,n)}),this.timeline&&new Set(this.timeline.tracks.map(i=>i.target)).forEach(i=>{if(!this.targets[i]){const s=this.container.querySelector(`[data-tinyfly="${i}"]`)||this.container.querySelector(`.${i}`)||this.container.querySelector(`#${i}`);s&&this.registerTarget(i,s)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const n=new Map(t.map(i=>[i.id,i]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(i=>{const s=i.getAttribute("data-tinyfly-symbol");if(!s)return;const r=n.get(s);if(!r||!r.timeline.tracks?.length)return;const o=new Ct;i.querySelectorAll("[data-tinyfly]").forEach(a=>{const l=a.getAttribute("data-tinyfly");l&&o.registerTarget(l,a)}),this.symbolInstances.push({adapter:o,timeline:zt(r.timeline)})})}attachMedia(t,n){this.mediaSync=new Ki(t,n),this.timeline&&(this.mediaSync.setRate(this.timeline.speed),this.mediaSync.update(this.timeline.currentTime,this.isPlaying))}detachMedia(){this.mediaSync?.dispose(),this.mediaSync=void 0}play(){!this.timeline||this.isDestroyed||(this.autoplayWhenSeen=!1,this.stepping=this.options.stepMode===!0,this.startPlaying())}startPlaying(){if(!this.timeline||this.isDestroyed)return;const t=this.timeline.playbackState==="idle";this.timeline.play(),t&&this.timeline.currentTime===0&&this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.update(this.timeline.currentTime,!0),this.syncAllMedia(this.timeline.currentTime,!0),this.startAnimationLoop(),this.notify()}pause(){this.timeline&&(this.stepping=!1,this.timeline.pause(),this.notify(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1),this.stopAnimationLoop())}stop(){this.timeline&&(this.timeline.stop(),this.stopAnimationLoop(),this.applyState(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1))}seek(t){this.timeline&&(this.timeline.seek(t),this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.seek(this.timeline.currentTime),this.syncAllMedia(this.timeline.currentTime,this.isPlaying))}setSpeed(t){this.timeline&&(this.timeline.speed=t,this.mediaSync?.setRate(t))}reverse(){this.timeline&&this.timeline.reverse()}get currentTime(){return this.timeline?.currentTime??0}get duration(){return this.timeline?.duration??0}get isPlaying(){return this.timeline?.playbackState==="playing"}destroy(){this.isDestroyed=!0,this.stopAnimationLoop(),this.reducedQuery?.removeEventListener?.("change",this.onReducedChange),this.visibilityObserver?.disconnect(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onDocumentVisibility),this.mediaSync?.dispose(),this.mediaSync=void 0;for(const t of this.mediaTargets)t.el.paused||t.el.pause();this.mediaTargets=[],this.adapter.clearTargets();for(const t of this.symbolInstances)t.adapter.clearTargets();this.symbolInstances=[],this.authored.clear(),this.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this.isDestroyed||!this.timeline)return;const i=n-(this.lastTime??n);this.lastTime=n;const s=this.playhead;this.timeline.tick(i),this.stopAtMarker(s),this.applyState();const r=this.timeline.playbackState==="playing";this.mediaSync?.update(this.timeline.currentTime,r),this.syncAllMedia(this.timeline.currentTime,r),this.timeline.playbackState==="playing"?this.animationFrameId=requestAnimationFrame(t):(this.animationFrameId=void 0,this.notify())};this.animationFrameId=requestAnimationFrame(t)}stopAtMarker(t){const n=this.timeline,i={time:n.currentTime,iteration:n.loopIteration,direction:n.direction};this.playhead=i;const s=this.markers;if(s.length===0)return;const{crossings:r}=mi(s.map(o=>o.time),t,i,{duration:n.duration,alternate:n.config.alternate===!0,holding:n.repeatDelayRemaining>0});for(const o of r){if(o.kind!=="event")continue;const a=s[o.index];if(this.stepping||a.pause){this.stepping=!1,n.pause(),n.seek(a.time),this.playhead={time:a.time,iteration:n.loopIteration,direction:n.direction};return}}}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}applyState(){if(!this.timeline)return;const t=this.timeline.currentTime;this.adapter.applyState(this.timeline.getStateAtTime(t)),this.announceMarker(),this.notify();for(const n of this.symbolInstances){const i=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(i>0?t%i:t))}}}async function zu(e,t,n={}){const i=new pn(e,{...n,autoplay:!0});return await i.load(t),i}function Gu(e,t={}){return new pn(e,t)}const Yo={play:"Play",pause:"Pause",prev:"Previous step",next:"Next step",restart:"Restart",scrub:"Position",speed:"Speed",reveal:"Reveal",step:"Step",of:"of",stepFormat:"{index} / {total}",scenario:"Scenario",fullscreen:"Full screen",exitFullscreen:"Exit full screen"},Xo="tinyfly-controls-style",ju=`
3
3
  .tf-ctl { --tf-ctl-fg: #1d1d1f; --tf-ctl-bg: #f4f2ee; --tf-ctl-accent: #c2410c; --tf-ctl-radius: 8px;
4
4
  font: 14px/1.4 var(--tf-ctl-font, system-ui, sans-serif); color: var(--tf-ctl-fg); margin-top: 8px; }
5
5
  .tf-ctl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; border-radius: var(--tf-ctl-radius); background: var(--tf-ctl-bg); }
@@ -47,7 +47,7 @@
47
47
  .tf-fullscreen > svg, .tf-fullscreen > canvas { grid-column: 1; grid-row: 1 / span 12; height: calc(100vh - 24px) !important; height: calc(100dvh - 24px) !important; }
48
48
  .tf-fullscreen > :not(svg):not(canvas) { grid-column: 2; }
49
49
  }
50
- `;let Xu=0;function qu(e){if(e.getElementById(Fo))return;const t=e.createElement("style");t.id=Fo,t.textContent=Yu,e.head.appendChild(t)}function Do(e,t,n={}){const i=t.ownerDocument;qu(i);const s={...Lo,...n.labels},r=n.speeds??[.5,1,2],o=()=>e.markers.length>0,a=()=>e.markers.some(H=>H.label!==void 0||e.caption(H.id)!==void 0),l=i.createElement("div");l.className="tf-ctl";const c=i.createElement("div");c.className="tf-ctl-bar",c.setAttribute("role","group");const h=(H,R,B,O="")=>{const L=i.createElement("button");return L.type="button",L.className=`tf-ctl-btn ${O}`.trim(),L.setAttribute("aria-label",H),L.title=H,L.textContent=R,L.addEventListener("click",B),L},u=h(s.restart,"⟲",()=>{e.pause(),e.seek(0)}),f=h(s.prev,"|◀",()=>e.prev()),d=h(s.play,"▶",()=>e.isPlaying?e.pause():p(),"tf-ctl-primary"),m=h(s.next,"▶|",()=>e.next()),p=()=>{e.currentTime>=e.duration-.5&&e.seek(0),e.play()},g=i.createElement("input");g.type="range",g.className="tf-ctl-scrub",g.min="0",g.max="1000",g.step="1",g.setAttribute("aria-label",s.scrub),g.addEventListener("input",()=>{e.pause(),e.seek(Number(g.value)/1e3*e.duration)});const y=i.createElement("span");y.className="tf-ctl-step";const w=i.createElement("select");w.className="tf-ctl-speed",w.setAttribute("aria-label",s.speed);for(const H of r){const R=i.createElement("option");R.value=String(H),R.textContent=`${H}×`,H===1&&(R.selected=!0),w.appendChild(R)}w.addEventListener("change",()=>e.setSpeed(Number(w.value))),c.append(u,f,d,m,g,y),r.length>0&&c.append(w),l.append(c);const v=n.fullscreen?ju(t,i,s):void 0;v&&c.append(v.button);const M=i.createElement("p");M.className="tf-ctl-caption",M.setAttribute("aria-live","polite"),n.captions!==!1&&l.append(M);const S=i.createElement("div");S.className="tf-ctl-question",S.hidden=!0;const E=i.createElement("span"),k=h(s.reveal,s.reveal,()=>e.play(),"tf-ctl-primary");S.append(E,k),l.append(S);const x=Vu(e,i,s.scenario,n.scenarioControl??"buttons");x&&l.append(x.element);const T=n.mount;T?T.appendChild(l):t.insertAdjacentElement("afterend",l);const P=()=>{const H=e.isPlaying;d.textContent=H?"❚❚":"▶",d.setAttribute("aria-label",H?s.pause:s.play),d.title=H?s.pause:s.play;const R=e.duration;i.activeElement!==g&&(g.value=String(R>0?Math.round(e.currentTime/R*1e3):0));const B=e.markers;if(f.hidden=m.hidden=y.hidden=B.length===0,B.length>0){const O=e.currentMarker,L=O?B.indexOf(O)+1:0;y.textContent=s.stepFormat.replace("{index}",String(L)).replace("{total}",String(B.length)),y.setAttribute("aria-label",`${s.step} ${L} ${s.of} ${B.length}`),f.disabled=e.currentTime<=.5,m.disabled=e.currentTime>=R-.5;const $=e.caption()??"";M.textContent!==$&&(M.textContent=$),M.hidden=!a();const F=!H&&O?.question!==void 0&&Math.abs(e.currentTime-O.time)<1;S.hidden=!F,F&&E.textContent!==O.question&&(E.textContent=O.question)}else S.hidden=!0,M.hidden=!0;x?.update()},A=e.subscribe(P);P();const _=n.keyboardScope??t;!_.hasAttribute("tabindex")&&_.tabIndex<0&&(_.tabIndex=0);const I=new WeakSet,C=H=>{if(I.has(H)||(I.add(H),H.defaultPrevented||H.altKey||H.ctrlKey||H.metaKey))return;const R=H.target;if(!(R.tagName==="INPUT"||R.tagName==="SELECT")&&!(H.key===" "&&R.tagName==="BUTTON"))switch(H.key){case" ":H.preventDefault(),e.isPlaying?e.pause():p();break;case"ArrowRight":if(!o())return;H.preventDefault(),e.next();break;case"ArrowLeft":if(!o())return;H.preventDefault(),e.prev();break;case"Home":H.preventDefault(),e.pause(),e.seek(0);break;case"f":case"F":if(!v)return;H.preventDefault(),v.active?v.exit():v.enter();break}};return _.addEventListener("keydown",C),l.addEventListener("keydown",C),{element:l,fullscreen:v&&{get active(){return v.active},enter:v.enter,exit:v.exit},destroy(){v?.destroy(),A(),_.removeEventListener("keydown",C),l.removeEventListener("keydown",C),l.remove()}}}function Vu(e,t,n,i){const s=e.scenarios;if(s.length<2)return;if(i==="slider"){const h=t.createElement("div");h.className="tf-ctl-choice-slider";const u=t.createElement("span");u.textContent=n,u.setAttribute("aria-hidden","true");const f=t.createElement("input");f.type="range",f.min="0",f.max=String(s.length-1),f.step="1",f.setAttribute("aria-label",n);const d=t.createElement("output");return d.setAttribute("aria-hidden","true"),f.addEventListener("input",()=>{const p=s[Number(f.value)];p&&e.setScenario(p.id)}),h.append(u,f,d),{element:h,update:()=>{const p=Math.max(0,s.findIndex(y=>y.id===e.scenario));t.activeElement!==f&&(f.value=String(p));const g=s[p].label;d.textContent!==g&&(d.textContent=g),f.setAttribute("aria-valuetext",g)}}}const r=t.createElement("fieldset");r.className="tf-ctl-choices";const o=t.createElement("legend");o.textContent=n,r.append(o);const a=`tf-ctl-scenario-${++Xu}`,l=s.map(h=>{const u=t.createElement("label");u.className="tf-ctl-choice";const f=t.createElement("input");f.type="radio",f.name=a,f.value=h.id,f.addEventListener("change",()=>{f.checked&&e.setScenario(h.id)});const d=t.createElement("span");return d.textContent=h.label,u.append(f,d),r.append(u),f});return{element:r,update:()=>{for(const h of l){const u=h.value===e.scenario;h.checked!==u&&(h.checked=u)}}}}const Uu='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',zu='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';function ju(e,t,n){const i=t,s=e,r=t.createElement("button");r.type="button",r.className="tf-ctl-btn tf-ctl-fullscreen";let o,a="";const l=()=>{const p=o!==void 0;r.innerHTML=p?zu:Uu;const g=p?n.exitFullscreen:n.fullscreen;r.setAttribute("aria-label",g),r.title=g,r.setAttribute("aria-pressed",String(p)),e.classList.toggle("tf-fullscreen",p),e.classList.toggle("tf-fullscreen-overlay",o==="overlay")},c=()=>i.fullscreenElement??i.webkitFullscreenElement??null,h=()=>{c()===e?o="native":o==="native"&&(o=void 0),l()},u=p=>{p.key==="Escape"&&m()},f=()=>{o="overlay",a=t.documentElement.style.overflow,t.documentElement.style.overflow="hidden",t.addEventListener("keydown",u),l()};async function d(){if(o)return;const p=s.requestFullscreen?.bind(s)??s.webkitRequestFullscreen?.bind(s),g=i.fullscreenEnabled??i.webkitFullscreenEnabled??!1;if(p&&g)try{if(await p(),c()===e){o="native",l();return}}catch{}f()}async function m(){if(o==="overlay")t.removeEventListener("keydown",u),t.documentElement.style.overflow=a,o=void 0,l();else if(o==="native"){o=void 0,l();const p=i.exitFullscreen?.bind(i)??i.webkitExitFullscreen?.bind(i);c()===e&&p&&await p()}}return r.addEventListener("click",()=>{o?m():d()}),t.addEventListener("fullscreenchange",h),t.addEventListener("webkitfullscreenchange",h),l(),{button:r,get active(){return o!==void 0},enter:d,exit:m,destroy(){m(),t.removeEventListener("fullscreenchange",h),t.removeEventListener("webkitfullscreenchange",h),r.remove()}}}const Bo="tinyfly-choices-style",Gu=`
50
+ `;let Ju=0;function Zu(e){if(e.getElementById(Xo))return;const t=e.createElement("style");t.id=Xo,t.textContent=ju,e.head.appendChild(t)}function qo(e,t,n={}){const i=t.ownerDocument;Zu(i);const s={...Yo,...n.labels},r=n.speeds??[.5,1,2],o=()=>e.markers.length>0,a=()=>e.markers.some(H=>H.label!==void 0||e.caption(H.id)!==void 0),l=i.createElement("div");l.className="tf-ctl";const c=i.createElement("div");c.className="tf-ctl-bar",c.setAttribute("role","group");const h=(H,R,B,$="")=>{const L=i.createElement("button");return L.type="button",L.className=`tf-ctl-btn ${$}`.trim(),L.setAttribute("aria-label",H),L.title=H,L.textContent=R,L.addEventListener("click",B),L},u=h(s.restart,"⟲",()=>{e.pause(),e.seek(0)}),f=h(s.prev,"|◀",()=>e.prev()),d=h(s.play,"▶",()=>e.isPlaying?e.pause():p(),"tf-ctl-primary"),m=h(s.next,"▶|",()=>e.next()),p=()=>{e.currentTime>=e.duration-.5&&e.seek(0),e.play()},g=i.createElement("input");g.type="range",g.className="tf-ctl-scrub",g.min="0",g.max="1000",g.step="1",g.setAttribute("aria-label",s.scrub),g.addEventListener("input",()=>{e.pause(),e.seek(Number(g.value)/1e3*e.duration)});const y=i.createElement("span");y.className="tf-ctl-step";const w=i.createElement("select");w.className="tf-ctl-speed",w.setAttribute("aria-label",s.speed);for(const H of r){const R=i.createElement("option");R.value=String(H),R.textContent=`${H}×`,H===1&&(R.selected=!0),w.appendChild(R)}w.addEventListener("change",()=>e.setSpeed(Number(w.value))),c.append(u,f,d,m,g,y),r.length>0&&c.append(w),l.append(c);const k=n.fullscreen?nf(t,i,s):void 0;k&&c.append(k.button);const M=i.createElement("p");M.className="tf-ctl-caption",M.setAttribute("aria-live","polite"),n.captions!==!1&&l.append(M);const S=i.createElement("div");S.className="tf-ctl-question",S.hidden=!0;const A=i.createElement("span"),E=h(s.reveal,s.reveal,()=>e.play(),"tf-ctl-primary");S.append(A,E),l.append(S);const T=Qu(e,i,s.scenario,n.scenarioControl??"buttons");T&&l.append(T.element);const v=n.mount;v?v.appendChild(l):t.insertAdjacentElement("afterend",l);const _=()=>{const H=e.isPlaying;d.textContent=H?"❚❚":"▶",d.setAttribute("aria-label",H?s.pause:s.play),d.title=H?s.pause:s.play;const R=e.duration;i.activeElement!==g&&(g.value=String(R>0?Math.round(e.currentTime/R*1e3):0));const B=e.markers;if(f.hidden=m.hidden=y.hidden=B.length===0,B.length>0){const $=e.currentMarker,L=$?B.indexOf($)+1:0;y.textContent=s.stepFormat.replace("{index}",String(L)).replace("{total}",String(B.length)),y.setAttribute("aria-label",`${s.step} ${L} ${s.of} ${B.length}`),f.disabled=e.currentTime<=.5,m.disabled=e.currentTime>=R-.5;const O=e.caption()??"";M.textContent!==O&&(M.textContent=O),M.hidden=!a();const D=!H&&$?.question!==void 0&&Math.abs(e.currentTime-$.time)<1;S.hidden=!D,D&&A.textContent!==$.question&&(A.textContent=$.question)}else S.hidden=!0,M.hidden=!0;T?.update()},P=e.subscribe(_);_();const x=n.keyboardScope??t;!x.hasAttribute("tabindex")&&x.tabIndex<0&&(x.tabIndex=0);const I=new WeakSet,C=H=>{if(I.has(H)||(I.add(H),H.defaultPrevented||H.altKey||H.ctrlKey||H.metaKey))return;const R=H.target;if(!(R.tagName==="INPUT"||R.tagName==="SELECT")&&!(H.key===" "&&R.tagName==="BUTTON"))switch(H.key){case" ":H.preventDefault(),e.isPlaying?e.pause():p();break;case"ArrowRight":if(!o())return;H.preventDefault(),e.next();break;case"ArrowLeft":if(!o())return;H.preventDefault(),e.prev();break;case"Home":H.preventDefault(),e.pause(),e.seek(0);break;case"f":case"F":if(!k)return;H.preventDefault(),k.active?k.exit():k.enter();break}};return x.addEventListener("keydown",C),l.addEventListener("keydown",C),{element:l,fullscreen:k&&{get active(){return k.active},enter:k.enter,exit:k.exit},destroy(){k?.destroy(),P(),x.removeEventListener("keydown",C),l.removeEventListener("keydown",C),l.remove()}}}function Qu(e,t,n,i){const s=e.scenarios;if(s.length<2)return;if(i==="slider"){const h=t.createElement("div");h.className="tf-ctl-choice-slider";const u=t.createElement("span");u.textContent=n,u.setAttribute("aria-hidden","true");const f=t.createElement("input");f.type="range",f.min="0",f.max=String(s.length-1),f.step="1",f.setAttribute("aria-label",n);const d=t.createElement("output");return d.setAttribute("aria-hidden","true"),f.addEventListener("input",()=>{const p=s[Number(f.value)];p&&e.setScenario(p.id)}),h.append(u,f,d),{element:h,update:()=>{const p=Math.max(0,s.findIndex(y=>y.id===e.scenario));t.activeElement!==f&&(f.value=String(p));const g=s[p].label;d.textContent!==g&&(d.textContent=g),f.setAttribute("aria-valuetext",g)}}}const r=t.createElement("fieldset");r.className="tf-ctl-choices";const o=t.createElement("legend");o.textContent=n,r.append(o);const a=`tf-ctl-scenario-${++Ju}`,l=s.map(h=>{const u=t.createElement("label");u.className="tf-ctl-choice";const f=t.createElement("input");f.type="radio",f.name=a,f.value=h.id,f.addEventListener("change",()=>{f.checked&&e.setScenario(h.id)});const d=t.createElement("span");return d.textContent=h.label,u.append(f,d),r.append(u),f});return{element:r,update:()=>{for(const h of l){const u=h.value===e.scenario;h.checked!==u&&(h.checked=u)}}}}const tf='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',ef='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';function nf(e,t,n){const i=t,s=e,r=t.createElement("button");r.type="button",r.className="tf-ctl-btn tf-ctl-fullscreen";let o,a="";const l=()=>{const p=o!==void 0;r.innerHTML=p?ef:tf;const g=p?n.exitFullscreen:n.fullscreen;r.setAttribute("aria-label",g),r.title=g,r.setAttribute("aria-pressed",String(p)),e.classList.toggle("tf-fullscreen",p),e.classList.toggle("tf-fullscreen-overlay",o==="overlay")},c=()=>i.fullscreenElement??i.webkitFullscreenElement??null,h=()=>{c()===e?o="native":o==="native"&&(o=void 0),l()},u=p=>{p.key==="Escape"&&m()},f=()=>{o="overlay",a=t.documentElement.style.overflow,t.documentElement.style.overflow="hidden",t.addEventListener("keydown",u),l()};async function d(){if(o)return;const p=s.requestFullscreen?.bind(s)??s.webkitRequestFullscreen?.bind(s),g=i.fullscreenEnabled??i.webkitFullscreenEnabled??!1;if(p&&g)try{if(await p(),c()===e){o="native",l();return}}catch{}f()}async function m(){if(o==="overlay")t.removeEventListener("keydown",u),t.documentElement.style.overflow=a,o=void 0,l();else if(o==="native"){o=void 0,l();const p=i.exitFullscreen?.bind(i)??i.webkitExitFullscreen?.bind(i);c()===e&&p&&await p()}}return r.addEventListener("click",()=>{o?m():d()}),t.addEventListener("fullscreenchange",h),t.addEventListener("webkitfullscreenchange",h),l(),{button:r,get active(){return o!==void 0},enter:d,exit:m,destroy(){m(),t.removeEventListener("fullscreenchange",h),t.removeEventListener("webkitfullscreenchange",h),r.remove()}}}const Vo="tinyfly-choices-style",sf=`
51
51
  [data-tinyfly-choose] { cursor: pointer; }
52
52
  [data-tinyfly-choose]:focus-visible { outline: 2px solid var(--tf-ctl-accent, #c2410c); outline-offset: 2px; }
53
- `;function Ju(e){if(e.getElementById(Bo))return;const t=e.createElement("style");t.id=Bo,t.textContent=Gu,e.head.appendChild(t)}function No(e,t){const n=Array.from(t.querySelectorAll("[data-tinyfly-choose]"));if(n.length===0)return()=>{};Ju(t.ownerDocument);const i=[],s=[];for(const a of n){const l=a.getAttribute("data-tinyfly-choose")??"",c=[],h=(m,p)=>{a.hasAttribute(m)||(a.setAttribute(m,p),c.push(m))};h("role","button"),h("tabindex","0");const u=e.scenarios.find(m=>m.id===l)?.label;u!==void 0&&h("aria-label",u),a.setAttribute("aria-pressed","false"),c.push("aria-pressed"),i.push({element:a,attributes:c});const f=()=>e.setScenario(l),d=m=>{const p=m.key;p!=="Enter"&&p!==" "||(m.preventDefault(),f())};a.addEventListener("click",f),a.addEventListener("keydown",d),s.push(()=>{a.removeEventListener("click",f),a.removeEventListener("keydown",d)})}const r=()=>{for(const{element:a}of i)a.setAttribute("aria-pressed",String(a.getAttribute("data-tinyfly-choose")===e.scenario))},o=e.subscribe(r);return r(),()=>{o();for(const a of s)a();for(const{element:a,attributes:l}of i)for(const c of l)a.removeAttribute(c)}}const un=new WeakMap,Bi=new WeakMap;let Zu=0;function xe(e,t,n){if(e)try{return JSON.parse(e)}catch(i){console.warn(`tinyfly: invalid ${t} JSON on`,n,i);return}}async function Wo(e,t={}){const n=un.get(e);if(n)return n;const i=Array.from(e.querySelectorAll("script[data-tinyfly-timeline]")),s=i[0],r=e.getAttribute("data-src"),o=tf(e.getAttribute("data-markers")),a=i.length>1||s?.hasAttribute("data-scenario")?Qu(i,o,e):void 0;if(a&&a.length===0)return;let l=s&&!a?xe(s.textContent,"timeline",e):void 0;if(!l&&r&&o){const d=await fetch(r);d.ok&&(l=await d.json())}if(l&&o&&(l=Ko(l,o)),!l&&!r&&!a){console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)',e);return}const c=xe(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),h={playWhenVisible:!0,...t.player,...c&&{captions:c},...xe(e.getAttribute("data-options"),"data-options",e)};nf(e);const u=new hn(e,h),f={element:e,player:u};if(un.set(e,f),e.setAttribute("data-tinyfly-mounted",""),a){const d=e.getAttribute("data-scenario")??void 0;await u.loadScenarios(a,{initial:a.some(m=>m.id===d)?d:void 0}),Bi.set(e,No(u,e))}else await u.load(l??r);if(e.getAttribute("data-controls")!=="false"){const d=xe(e.getAttribute("data-labels"),"data-labels",e),m=e.querySelector("figcaption"),p=e.getAttribute("data-scenario-legend"),g=e.getAttribute("data-scenario-control");f.controls=Do(u,e,{...t.controls,...e.getAttribute("data-fullscreen")==="true"?{fullscreen:!0}:{},...g==="slider"||g==="buttons"?{scenarioControl:g}:{},labels:{...t.controls?.labels,...d,...p?{scenario:p}:{}},mount:void 0}),m?e.insertBefore(f.controls.element,m):e.appendChild(f.controls.element)}return f}function Qu(e,t,n){const i=[];return e.forEach((s,r)=>{const o=xe(s.textContent,"timeline",n);if(!o)return;const a=s.getAttribute("data-scenario")||`scenario-${r+1}`;if(i.some(c=>c.id===a)){console.warn(`tinyfly: scenario id "${a}" is used more than once; the later one is skipped`,n);return}const l=s.getAttribute("data-scenario-label")??void 0;i.push({id:a,label:l,timeline:t?Ko(o,t):o})}),i}function Ko(e,t){return e.config.markers?.length?e:{...e,config:{...e.config,markers:t.map((n,i)=>({id:`step-${i+1}`,time:n}))}}}function tf(e){if(!e)return;const t=e.split(/[\s,]+/).filter(Boolean).map(Number).filter(n=>Number.isFinite(n)&&n>=0).sort((n,i)=>n-i);return t.length>0?t:void 0}async function Yo(e=document,t={}){const n=Array.from(e.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(n.map(s=>Wo(s,t)))).filter(s=>s!==void 0)}function ef(e){const t=un.get(e);t&&(Bi.get(e)?.(),Bi.delete(e),t.controls?.destroy(),t.player.destroy(),un.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function nf(e){const t=e.querySelector("svg");if(!t||t.hasAttribute("role")||t.hasAttribute("aria-hidden"))return;const n=e.getAttribute("data-alt"),i=e.querySelector("figcaption");t.setAttribute("role","img"),n?t.setAttribute("aria-label",n):i&&(i.id||=`tinyfly-caption-${++Zu}`,t.setAttribute("aria-labelledby",i.id))}function sf(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const t=()=>{Yo()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}class Xo{container;containerA;containerB;adapterA;adapterB;timelineA=null;timelineB=null;symbolDefs=new Map;nestedByAdapter=new Map;sequence=null;options;_currentSceneIndex=0;_state="idle";_isPlaying=!1;_isDestroyed=!1;loopIteration=0;animationFrameId;lastTime;transitionTimer;constructor(t,n={}){if(typeof t=="string"){const i=document.querySelector(t);if(!i)throw new Error(`Container not found: ${t}`);this.container=i}else this.container=t;this.options=n,this.container.style.position="relative",this.container.style.overflow="hidden",this.containerA=this.createSceneContainer(),this.containerB=this.createSceneContainer(),this.container.appendChild(this.containerA),this.container.appendChild(this.containerB),this.containerB.style.visibility="hidden",this.adapterA=new _t,this.adapterB=new _t}async load(t){let n;if(typeof t=="string"){const i=await fetch(t);if(!i.ok)throw new Error(`Failed to load sequence: ${i.statusText}`);n=await i.json()}else n=t;this.sequence=n,this.symbolDefs.clear();for(const i of n.symbols??[])i.timeline?.tracks?.length&&this.symbolDefs.set(i.id,i.timeline);this.container.style.width=`${n.canvas.width}px`,this.container.style.height=`${n.canvas.height}px`,n.scenes.length>0&&(this.renderScene(n.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(n.scenes[0])),this.options.autoplay&&this.play()}play(){if(!(!this.sequence||this._isDestroyed)&&this.sequence.scenes.length!==0){if(this._isPlaying=!0,this._state==="idle"){if(this._state="playing-scene",this._currentSceneIndex=0,this.timelineA)this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play();else{this.onSceneComplete();return}this.options.onSceneChange?.(0)}else this._state==="playing-scene"&&this.timelineA&&this.timelineA.play();this.startAnimationLoop()}}pause(){this._isPlaying&&(this._isPlaying=!1,this.timelineA&&this.timelineA.pause(),this.timelineB&&this.timelineB.pause(),this.stopAnimationLoop())}stop(){if(this._isPlaying=!1,this._state="idle",this._currentSceneIndex=0,this.loopIteration=0,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.stopAnimationLoop(),this.sequence&&this.sequence.scenes.length>0&&(this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this.renderScene(this.sequence.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(this.sequence.scenes[0]),this.timelineA)){const t=this.timelineA.getStateAtTime(0);this.adapterA.applyState(t),this.applyNested(this.adapterA,0)}}goToScene(t){if(!this.sequence||t<0||t>=this.sequence.scenes.length)return;const n=this._isPlaying;this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this._currentSceneIndex=t,this._state=n?"playing-scene":"idle",this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB);const i=this.sequence.scenes[t];if(this.renderScene(i,this.containerA,this.adapterA),this.timelineA=this.createTimeline(i),this.options.onSceneChange?.(t),n)this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play(),this.startAnimationLoop()):this.onSceneComplete();else if(this.timelineA){const s=this.timelineA.getStateAtTime(0);this.adapterA.applyState(s),this.applyNested(this.adapterA,0)}}destroy(){this._isDestroyed=!0,this._isPlaying=!1,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.adapterA.clearTargets(),this.adapterB.clearTargets();for(const t of this.nestedByAdapter.values())for(const n of t)n.adapter.clearTargets();this.nestedByAdapter.clear(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.timelineA=null,this.timelineB=null,this.containerA.parentNode&&this.containerA.remove(),this.containerB.parentNode&&this.containerB.remove(),this.sequence=null}get currentSceneIndex(){return this._currentSceneIndex}get sceneCount(){return this.sequence?.scenes.length??0}get isPlaying(){return this._isPlaying}get state(){return this._state}createSceneContainer(){const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t}renderScene(t,n,i){n.innerHTML="",i.clearTargets();const s=document.createElement("div");s.style.cssText="position:absolute;inset:0;transform-origin:center center",s.setAttribute("data-tinyfly","Camera"),n.appendChild(s),i.registerTarget("Camera",s);for(const r of t.elements){if(!r.html)continue;const o=document.createElement("div");o.innerHTML=r.html.trim();const a=o.firstElementChild;if(a){s.appendChild(a);const l=a.getAttribute("data-tinyfly");l&&i.registerTarget(l,a)}}this.setupNested(s,i)}setupNested(t,n){const i=[];t.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const r=s.getAttribute("data-tinyfly-symbol");if(!r)return;const o=this.symbolDefs.get(r);if(!o)return;const a=new _t;s.querySelectorAll("[data-tinyfly]").forEach(l=>{const c=l.getAttribute("data-tinyfly");c&&a.registerTarget(c,l)}),i.push({adapter:a,timeline:Vt(o)})}),i.length?this.nestedByAdapter.set(n,i):this.nestedByAdapter.delete(n)}applyNested(t,n){const i=this.nestedByAdapter.get(t);if(i)for(const s of i){const r=s.timeline.duration;s.adapter.applyState(s.timeline.getStateAtTime(r>0?n%r:n))}}clearContainer(t){t.innerHTML=""}createTimeline(t){return t.timeline?Vt(t.timeline):null}onSceneComplete(){if(this._isDestroyed||!this.sequence)return;const t=this._currentSceneIndex+1;if(t>=this.sequence.scenes.length){const n=this.options.loop??this.sequence.loop??0;n===-1||n>0&&this.loopIteration<n-1?(this.loopIteration++,this.beginTransitionTo(0)):(this._isPlaying=!1,this._state="idle",this.stopAnimationLoop(),this.options.onComplete?.())}else this.beginTransitionTo(t)}beginTransitionTo(t){if(!this.sequence||this._isDestroyed)return;const n=this.sequence.scenes[t],i=n.transition;if(i.type==="none"||i.duration<=0){this.switchToScene(t);return}this._state="transitioning",this.containerB.style.visibility="visible",this.renderScene(n,this.containerB,this.adapterB),this.timelineB=this.createTimeline(n),this.timelineB&&this.timelineB.play(),this.applyTransition(i.type,i.duration),this.transitionTimer=window.setTimeout(()=>{this.finishTransition(t)},i.duration)}applyTransition(t,n){const i=`${n}ms`,s="ease-in-out";switch(this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),t){case"fade":this.containerB.style.opacity="0";break;case"slide-left":this.containerB.style.transform="translateX(100%)";break;case"slide-right":this.containerB.style.transform="translateX(-100%)";break;case"slide-up":this.containerB.style.transform="translateY(100%)";break;case"slide-down":this.containerB.style.transform="translateY(-100%)";break}switch(this.containerB.offsetHeight,this.containerA.style.transition=`opacity ${i} ${s}, transform ${i} ${s}`,this.containerB.style.transition=`opacity ${i} ${s}, transform ${i} ${s}`,t){case"fade":this.containerA.style.opacity="0",this.containerB.style.opacity="1";break;case"slide-left":this.containerA.style.transform="translateX(-100%)",this.containerB.style.transform="translateX(0)";break;case"slide-right":this.containerA.style.transform="translateX(100%)",this.containerB.style.transform="translateX(0)";break;case"slide-up":this.containerA.style.transform="translateY(-100%)",this.containerB.style.transform="translateY(0)";break;case"slide-down":this.containerA.style.transform="translateY(100%)",this.containerB.style.transform="translateY(0)";break}}resetTransitionStyles(t){t.style.transition="",t.style.opacity="1",t.style.transform=""}finishTransition(t){this.transitionTimer=void 0,this.timelineA&&(this.timelineA.stop(),this.timelineA=null),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const n=this.containerA;this.containerA=this.containerB,this.containerB=n;const i=this.adapterA;this.adapterA=this.adapterB,this.adapterB=i,this.timelineA=this.timelineB,this.timelineB=null,this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.playbackState!=="playing"&&this.timelineA.play()):this.onSceneComplete()}switchToScene(t){if(!this.sequence||this._isDestroyed)return;this.timelineA&&this.timelineA.stop(),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const n=this.sequence.scenes[t];this.renderScene(n,this.containerA,this.adapterA),this.timelineA=this.createTimeline(n),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play()):this.onSceneComplete()}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this._isDestroyed||!this._isPlaying)return;const i=n-(this.lastTime??n);if(this.lastTime=n,this.timelineA&&this.timelineA.playbackState==="playing"){this.timelineA.tick(i);const s=this.timelineA.getStateAtTime(this.timelineA.currentTime);this.adapterA.applyState(s),this.applyNested(this.adapterA,this.timelineA.currentTime)}if(this._state==="transitioning"&&this.timelineB&&this.timelineB.playbackState==="playing"){this.timelineB.tick(i);const s=this.timelineB.getStateAtTime(this.timelineB.currentTime);this.adapterB.applyState(s),this.applyNested(this.adapterB,this.timelineB.currentTime)}this._isPlaying?this.animationFrameId=requestAnimationFrame(t):this.animationFrameId=void 0};this.animationFrameId=requestAnimationFrame(t)}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}}async function rf(e,t,n={}){const i=new Xo(e,{...n,autoplay:!0});return await i.load(t),i}const of={type:"none",duration:0};function qo(e){let t=0;for(let n=1;n<e.length;n++)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function Qt(e,t){const n=Math.min(1,Math.max(0,t));if(e.length<2||n===1)return e.slice();if(n===0)return e.slice(0,1);let i=qo(e)*n;const s=[e[0]];for(let r=1;r<e.length;r++){const o=e[r-1],a=e[r],l=Math.hypot(a.x-o.x,a.y-o.y);if(l>=i){const c=l===0?0:i/l;return s.push({x:o.x+(a.x-o.x)*c,y:o.y+(a.y-o.y)*c}),s}s.push(a),i-=l}return s}function fn(e,t){const n=Qt(e,t);return n[n.length-1]}function Ni(e,t){return t>0?Math.floor(Math.max(0,e)*t/1e3):0}function dn(e,t,n){const i=t.roughness??2,s=Math.max(1,Math.round(t.passes??2)),r=Ni(n,t.boil??8);let o=0;const a=()=>{const f=o++;return d=>ye(Ut(`${t.seed??1}:${r}:${f}:${d}`))},l=(f,d)=>(f.next()*2-1)*d,c=f=>{const d=a(),m=e.lineWidth,p=e.globalAlpha;for(let g=0;g<s;g++)e.lineWidth=g===0?m:m*.55,e.globalAlpha=g===0?p:p*.6,f(d(g));e.lineWidth=m,e.globalAlpha=p},h=(f,d=1)=>{if(f.length<2)return;const m=f.slice(1).map((g,y)=>Math.hypot(g.x-f[y].x,g.y-f[y].y)),p=m.reduce((g,y)=>g+y,0)*Math.min(1,Math.max(0,d));c(g=>{const y=[],w=[];if(f.forEach((M,S)=>{y.push({x:M.x+l(g,i*.5),y:M.y+l(g,i*.5)}),S>0&&w.push([g.next()*2-1,g.next()*2-1])}),p<=0)return;e.beginPath(),e.moveTo(y[0].x,y[0].y);let v=0;for(let M=1;M<y.length;M++){const S=af(y[M-1],y[M],i,w[M-1]),E=m[M-1];if(v+E<=p){e.bezierCurveTo(S[1].x,S[1].y,S[2].x,S[2].y,S[3].x,S[3].y),v+=E;continue}const k=lf(S,E===0?1:(p-v)/E);e.bezierCurveTo(k[1].x,k[1].y,k[2].x,k[2].y,k[3].x,k[3].y);break}e.stroke()})},u=(f,d,m,p,g=1)=>{c(y=>{const v=y.next()*Math.PI*2,M=Math.PI*2+.15+y.next()*.3,S=[];for(let k=0;k<=14;k++){const x=v+M*k/14,T=l(y,i*.6);S.push({x:f+Math.cos(x)*(m+T),y:d+Math.sin(x)*(p+T)})}const E=Qt(S,g);E.length<2||(Vo(e,E),e.stroke())})};return{line:h,curve(f,d=1){if(f.length<2)return;const m=f[0],p=f[f.length-1],g=Math.hypot(p.x-m.x,p.y-m.y)||1,y=-(p.y-m.y)/g,w=(p.x-m.x)/g;c(v=>{const M={x:l(v,i*.5),y:l(v,i*.5)},S={x:l(v,i*.5),y:l(v,i*.5)},E=l(v,i*Math.min(1.5,Math.max(.3,g/80))),k=f.map((T,P)=>{const A=P/(f.length-1),_=Math.sin(Math.PI*A)*E;return{x:T.x+M.x+(S.x-M.x)*A+y*_,y:T.y+M.y+(S.y-M.y)*A+w*_}}),x=Qt(k,d);x.length<2||(Vo(e,x),e.stroke())})},circle(f,d,m,p=1){u(f,d,m,m,p)},ellipse:u,nudge(f=.5){const d=a()(0);return{x:l(d,i*f),y:l(d,i*f)}}}}function af(e,t,n,i){const s=t.x-e.x,r=t.y-e.y,o=Math.hypot(s,r)||1,a=n*Math.min(1.5,Math.max(.3,o/80)),l=-r/o,c=s/o;return[e,{x:e.x+s/3+l*i[0]*a,y:e.y+r/3+c*i[0]*a},{x:e.x+2*s/3+l*i[1]*a,y:e.y+2*r/3+c*i[1]*a},t]}function lf([e,t,n,i],s){const r=(u,f)=>({x:u.x+(f.x-u.x)*s,y:u.y+(f.y-u.y)*s}),o=r(e,t),a=r(t,n),l=r(n,i),c=r(o,a),h=r(a,l);return[e,o,c,r(c,h)]}function Vo(e,t){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length-1;i++){const s={x:(t[i].x+t[i+1].x)/2,y:(t[i].y+t[i+1].y)/2};e.quadraticCurveTo(t[i].x,t[i].y,s.x,s.y)}const n=t[t.length-1];e.lineTo(n.x,n.y)}function Pe(e,t,n){const i=e.length;if(i<2)return[];const s=[],r=[],o=a=>t+(n-t)*a/(i-1);return e.forEach((a,l)=>{const c=e[Math.max(0,l-1)],h=e[Math.min(i-1,l+1)],u=Math.hypot(h.x-c.x,h.y-c.y)||1,f=o(l)/2,d=-(h.y-c.y)/u*f,m=(h.x-c.x)/u*f;s.push({x:a.x+d,y:a.y+m}),r.push({x:a.x-d,y:a.y-m})}),[...s,...r.reverse()]}function pn(e,t,n,i){const s=t.length;if(s<2)return;const r=Pe(t,n,i),o=a=>n+(i-n)*a/(s-1);e.beginPath(),e.moveTo(r[0].x,r[0].y);for(const a of r.slice(1))e.lineTo(a.x,a.y);e.closePath(),e.fill(),t.forEach((a,l)=>{l!==0&&l!==s-1&&s>3||(e.beginPath(),e.arc(a.x,a.y,o(l)/2,0,Math.PI*2),e.fill())})}function It(e,t,n,i,s=16){const r={x:2*t.x-(e.x+n.x)/2,y:2*t.y-(e.y+n.y)/2},o=[];for(let a=0;a<=s;a++){const l=a/s,c=l<.5?{x:e.x+(t.x-e.x)*2*l,y:e.y+(t.y-e.y)*2*l}:{x:t.x+(n.x-t.x)*(2*l-1),y:t.y+(n.y-t.y)*(2*l-1)},h=1-l,u={x:h*h*e.x+2*h*l*r.x+l*l*n.x,y:h*h*e.y+2*h*l*r.y+l*l*n.y};o.push({x:c.x+(u.x-c.x)*i,y:c.y+(u.y-c.y)*i})}return o}function Wi(e,t,n,i,s,r=0,o=1,a=40){const l=Math.cos(s),c=Math.sin(s);return Array.from({length:a+1},(h,u)=>{const f=r+Math.PI*2*o*u/a,d=Math.cos(f)*n,m=Math.sin(f)*i;return{x:e+d*l-m*c,y:t+d*c+m*l}})}function Ki(e,t){return t.look==="pencil"?ff(e,t):cf(e,t.ink,t.look)}function mn(e,t,n=!1){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t.slice(1))e.lineTo(i.x,i.y);n&&e.closePath()}function cf(e,t,n){const i=n==="silhouette",s=i?1.25:1;return{look:n,ink:t,limb(r,o,a){e.fillStyle=t,pn(e,r,o*s,a*s)},line(r,o){r.length<2||(e.strokeStyle=t,e.lineWidth=o*s,e.lineCap="round",e.lineJoin="round",mn(e,r),e.stroke())},shape(r,o,a){mn(e,r,!0),(o!==null||i)&&(e.fillStyle=i?t:o,e.fill()),!(a<=0)&&(e.strokeStyle=t,e.lineWidth=a*s,e.lineJoin="round",e.stroke())},ellipse(r,o,a,l,c,h,u){e.beginPath(),e.ellipse(r,o,a,l,c,0,Math.PI*2),(h!==null||i)&&(e.fillStyle=i?t:h,e.fill()),!(u<=0)&&(e.strokeStyle=t,e.lineWidth=u*s,e.stroke())},dot(r,o,a){e.fillStyle=t,e.beginPath(),e.arc(r,o,a*s,0,Math.PI*2),e.fill()},guide(){},guideEllipse(){}}}function hf(e,t){const n=[e[0]];let i=0;for(let o=1;o<e.length;o++){const a=e[o-1],l=e[o],c=Math.hypot(l.x-a.x,l.y-a.y);let h=t-i;for(;h<c;){const u=h/c;n.push({x:a.x+(l.x-a.x)*u,y:a.y+(l.y-a.y)*u}),h+=t}i=c-(h-t)}const s=e[e.length-1],r=n[n.length-1];return Math.hypot(s.x-r.x,s.y-r.y)>t*.25?n.push(s):n[n.length-1]=s,n}function uf(e,t){const n=e.length;return e.map((i,s)=>{const r=e[Math.max(0,s-1)],o=e[Math.min(n-1,s+1)],a=Math.hypot(o.x-r.x,o.y-r.y)||1,l=t(n===1?0:s/(n-1));return{x:i.x-(o.y-r.y)/a*l,y:i.y+(o.x-r.x)/a*l}})}function Uo(e){const t=[.6,1.4,2.9].map(i=>({frequency:i*(.8+e.next()*.4),phase:e.next()*Math.PI*2,amount:.5+e.next()*.5})),n=t.reduce((i,s)=>i+s.amount,0);return i=>t.reduce((s,r)=>s+r.amount*Math.sin(Math.PI*2*r.frequency*i+r.phase),0)/n}function ff(e,t){const n=t.pencil??{},i=t.ink,s=n.roughness??Math.max(1,t.lineWidth*.12),r=Math.max(1,Math.round(n.passes??2)),o=Math.min(1,Math.max(0,n.pressure??.25)),a=Math.min(1,Math.max(0,n.rubbedOut??.15)),l=Ni(t.time,n.boil??8);let c=0;const h=(m,p,g=!1)=>ye(Ut(`${t.seed}:${g?"paper":l}:${m}:${p}`)),u=(m,p,g,y,w,v=0)=>{if(m.length<2)return;const M=m.slice(1).reduce((A,_,I)=>A+Math.hypot(_.x-m[I].x,_.y-m[I].y),0);let S=hf(m,Math.max(1.5,Math.min(t.lineWidth*.8,M/24)));if(v>0&&S.length>=2){const[A,_]=[S[S.length-2],S[S.length-1]],I=Math.hypot(_.x-A.x,_.y-A.y)||1;S=[...S,{x:_.x+(_.x-A.x)/I*v,y:_.y+(_.y-A.y)/I*v}]}const E=Uo(g),k=Uo(g),x=S.length,T=[],P=[];S.forEach((A,_)=>{const I=x===1?0:_/(x-1),C=S[Math.max(0,_-1)],H=S[Math.min(x-1,_+1)],R=Math.hypot(H.x-C.x,H.y-C.y)||1,B=-(H.y-C.y)/R,O=(H.x-C.x)/R,L=E(I)*w,$=Math.min(1,I/.08,(1-I)/.08),F=(.55+.45*Math.sqrt(Math.max(0,$)))*(1+o*k(I)),D=Math.max(.3,p(I)*F/2),W=A.x+B*L,Z=A.y+O*L;T.push({x:W+B*D,y:Z+O*D}),P.push({x:W-B*D,y:Z-O*D})}),e.save(),e.globalAlpha*=y,e.fillStyle=i,mn(e,[...T,...P.reverse()],!0),e.fill(),e.restore()},f=(m,p)=>{const g=c++,y=h(g,99,!0);if(y.next()<a){const S=(y.next()*2-1)*t.lineWidth*1.4,E=(y.next()*2-1)*t.lineWidth*1.4,k=m.map(x=>({x:x.x+S,y:x.y+E}));u(k,x=>p(x)*1.8,h(g,98,!0),.035,s),u(k,x=>p(x)*.45,h(g,97,!0),.12,s*1.5)}const w=m.slice(1).reduce((S,E,k)=>S+Math.hypot(E.x-m[k].x,E.y-m[k].y),0),v=p(.5)>4&&w>p(.5)*6,M=v?[-.3,.3,0]:[0];for(let S=0;S<r;S++){const E=S===0;M.forEach((k,x)=>{const T=h(g,S*10+x),P=k===0?m:uf(m,_=>p(_)*k*Math.sqrt(Math.sin(Math.PI*_))),A=!E&&k===0?t.lineWidth*(.3+T.next()*.8):0;u(P,_=>p(_)*(v?.5:1)*(E?1:.6),T,E?.85:.45,s*(E?.6:1),A)})}},d=(m,p,g,y,w,v)=>{const S=h(c,50).next()*Math.PI*2;f(Wi(m,p,g,y,w,S,1.08,48),()=>v)};return{look:"pencil",ink:i,limb(m,p,g){f(m,y=>p+(g-p)*y)},line(m,p){f(m,()=>p)},shape(m,p,g){p!==null&&(e.save(),e.globalAlpha*=.88,e.fillStyle=p,mn(e,m,!0),e.fill(),e.restore()),g>0&&f([...m,m[0]],()=>g)},ellipse(m,p,g,y,w,v,M){v!==null&&(e.save(),e.globalAlpha*=.9,e.fillStyle=v,e.beginPath(),e.ellipse(m,p,g,y,w,0,Math.PI*2),e.fill(),e.restore()),d(m,p,g,y,w,M)},dot(m,p,g){e.save(),e.globalAlpha*=.9,e.fillStyle=i,e.beginPath(),e.arc(m,p,g,0,Math.PI*2),e.fill(),e.restore()},guide(m){if(n.construction===!1||m.length<2)return;const p=c++;u(m,()=>Math.max(.6,t.lineWidth*.18),h(p,0),.28,s*1.2,t.lineWidth)},guideEllipse(m,p,g,y,w){if(n.construction===!1)return;const v=c++,M=h(v,0),S=Wi(m,p,g,y,w,M.next()*Math.PI*2,1.12,48);u(S,()=>Math.max(.6,t.lineWidth*.18),M,.28,s*1.5)}}}const zo=["thumb","index","middle","ring","pinky"],K={"thumb.curl":.15,"thumb.across":.15,"index.curl":.12,"middle.curl":.16,"ring.curl":.2,"pinky.curl":.25,spread:.25,turn:0,bend:0,tilt:0,roll:0};function Y(e={}){return{...K,...e}}const tt=(e,t,n,i,s)=>({"thumb.curl":e,"index.curl":t,"middle.curl":n,"ring.curl":i,"pinky.curl":s}),q={relaxed:K,open:Y({...tt(0,0,0,0,0),"thumb.across":0,spread:.55}),spread:Y({...tt(0,0,0,0,0),"thumb.across":0,spread:1}),flat:Y({...tt(0,0,0,0,0),"thumb.across":.35,spread:0}),fist:Y({...tt(.7,1,1,1,1),"thumb.across":.9,spread:0}),point:Y({...tt(.75,0,1,1,1),"thumb.across":.9,spread:0}),thumbsUp:Y({...tt(0,1,1,1,1),"thumb.across":0,spread:0,roll:70}),peace:Y({...tt(.75,0,0,1,1),"thumb.across":.9,spread:1}),ok:Y({...tt(.12,.6,.1,.15,.2),"thumb.across":.55,spread:.6}),pinch:Y({...tt(.1,.65,.75,.85,.9),"thumb.across":.55,spread:0}),cupped:Y({...tt(.25,.4,.4,.4,.4),"thumb.across":.4,spread:.05,turn:2}),wave:Y({...tt(0,.05,.05,.1,.12),"thumb.across":0,spread:.7,turn:2}),pencilGrip:Y({...tt(.1,.6,.72,.88,.95),"thumb.across":.5,spread:0,turn:.8,bend:10}),hold:Y({...tt(.5,.7,.72,.74,.76),"thumb.across":.75,spread:0,turn:1})};function te(e,t,n){const i={...e};for(const[s,r]of Object.entries(t)){const o=e[s]??r;i[s]=o+(r-o)*n}return i}const df={index:{knuckle:[-.16,.47,-.02],bones:[.2,.125,.1],width:.125,fan:-1},middle:{knuckle:[-.055,.49,-.02],bones:[.22,.135,.1],width:.13,fan:-.2},ring:{knuckle:[.05,.475,-.02],bones:[.2,.125,.1],width:.122,fan:.55},pinky:{knuckle:[.15,.43,-.02],bones:[.16,.1,.085],width:.108,fan:1.25}},pf={index:{knuckle:[-.14,.47,-.02],bones:[.2,.125,.1],width:.15,fan:-1},middle:{knuckle:[0,.49,-.02],bones:[.22,.135,.1],width:.155,fan:0},pinky:{knuckle:[.14,.45,-.02],bones:[.19,.115,.095],width:.145,fan:1}},ut={base:[-.11,.1,-.05],bones:[.2,.15,.12],widths:[.2,.145,.135],out:[-.7,.68,-.22],across:[.35,.5,-.8]},mf=[82,100,62],gf=[48,72],yf=3,bf=13,wf=.035,vf=-.075,kf=[[-.17,0],[-.215,.12],[-.235,.26],[-.225,.4],[-.185,.49],[-.075,.525],[.05,.51],[.16,.465],[.215,.4],[.225,.26],[.2,.1],[.16,0]],wt=e=>e*Math.PI/180,Yi=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],gn=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],Xi=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],_e=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function vt(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=Xi(t,e),o=t[0]*e[0]+t[1]*e[1]+t[2]*e[2];return[e[0]*i+r[0]*s+t[0]*o*(1-i),e[1]*i+r[1]*s+t[1]*o*(1-i),e[2]*i+r[2]*s+t[2]*o*(1-i)]}const jo=[1,0,0],Go=[0,1,0],Ie=[0,0,1];function Sf(e,t,n){const i=wt(e.fan*(yf+bf*n)),s=[Math.sin(i),Math.cos(i),0],r=[Math.cos(i),-Math.sin(i),0],o=[e.knuckle];let a=0;e.bones.forEach((h,u)=>{a+=wt(mf[u]*t),o.push(Yi(o[u],gn(vt(s,r,-a),h)))});const l=vt(Ie,r,-a),c=o.map((h,u)=>e.width*(1-.14*(u/(o.length-1))));return{joints:o,back:l,widths:c}}function Mf(e,t,n=1,i=1){const s=Math.min(1,Math.max(0,t)),r=_e(Yi(gn(_e(ut.out),1-s),gn(_e(ut.across),s))),o=_e(Xi(Ie,r)),a=_e(Xi(r,o)),l=[[ut.base[0]*i,ut.base[1],ut.base[2]]];let c=0;ut.bones.forEach((f,d)=>{d>0&&(c+=wt(gf[d-1]*e)),l.push(Yi(l[d],gn(vt(r,o,c),f)))});const h=vt(a,o,c),u=[...ut.widths,ut.widths[ut.widths.length-1]*.92].map(f=>f*n);return{joints:l,back:h,widths:u}}function yn(e,t={}){const n={...K,...e},i=t.size??100,s=t.side??"right",r=s==="left"?-1:1,o=wt(t.angle??0),a=t.fingers===4,l=Math.max(.5,t.plump??1),c=1+(l-1)*.7,h=_=>({..._,knuckle:[_.knuckle[0]*c,_.knuckle[1],_.knuckle[2]],width:_.width*l}),u=wt(n.bend??0),f=wt(n.tilt??0),d=wt(90*(n.turn??0)),m=_=>vt(vt(vt(_,jo,-u),Ie,-f),Go,d),p=Math.cos(o),g=Math.sin(o),y=wt(n.roll??0),w=Math.cos(y),v=Math.sin(y),M=_=>{const I=_[0]*i,C=-_[1]*i,H=(I*w-C*v)*r,R=I*v+C*w;return{x:H*p-R*g,y:H*g+R*p}},S=_=>{const I=M(_),C=Math.hypot(I.x,I.y);return C>1e-6*i?{x:I.x/C,y:I.y/C}:{x:0,y:0}},E={thumb:Mf(n["thumb.curl"]??0,n["thumb.across"]??0,l,c)},k=a?pf:df;for(const _ of zo){const I=k[_];I&&(E[_]=Sf(h(I),n[`${_}.curl`]??0,n.spread??0))}const x={};for(const[_,I]of Object.entries(E)){const C=I.joints.map(m),H=m(I.back);x[_]={points:C.map(M),depths:C.map(R=>R[2]*i),widths:I.widths.map(R=>R*i),nail:H[2],back:S(H)}}const T=kf.flatMap(([_,I])=>[m([_*c,I,wf]),m([_*c,I,vf])]),P=Tf(T.map(M)),A=T.reduce((_,I)=>_+I[2],0)/T.length*i;return{size:i,side:s,wrist:{x:0,y:0},palm:P,palmDepth:A,palmFacing:-m(Ie)[2],fingers:x,axes:{up:S(m(Go)),across:S(m(jo)),out:S(m(Ie))},curls:Object.fromEntries(Object.keys(x).map(_=>[_,n[`${_}.curl`]??0]))}}function Jo(e,t){const n=s=>({x:s.x+t.x-e.wrist.x,y:s.y+t.y-e.wrist.y}),i={};for(const[s,r]of Object.entries(e.fingers))i[s]={...r,points:r.points.map(n)};return{...e,wrist:n(e.wrist),palm:e.palm.map(n),fingers:i}}function Tf(e){const t=[...e].sort((r,o)=>r.x-o.x||r.y-o.y);if(t.length<3)return t;const n=(r,o,a)=>(o.x-r.x)*(a.y-r.y)-(o.y-r.y)*(a.x-r.x),i=[];for(const r of t){for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}const s=[];for(const r of[...t].reverse()){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],r)<=0;)s.pop();s.push(r)}return[...i.slice(0,-1),...s.slice(0,-1)]}const Ef="#f1c9a5",Af="#2f2f33";function bn(e,t,n,i={},s=0){const r=Jo(yn(n,i),t),o=i.ink??Af,a=i.lineWidth??r.size*.035,l=i.pen??Ki(e,{look:i.look??"clean",ink:o,lineWidth:a,seed:i.seed??1,time:s,pencil:{construction:!1,...i.pencil}}),c=i.skin??Ef,h=i.nails??!0,u=[{depth:r.palmDepth,draw:()=>xf(l,r,c,a)}];for(const f of Object.values(r.fingers)){const d=f.depths.reduce((m,p)=>m+p,0)/f.depths.length;u.push({depth:d,draw:()=>Pf(e,l,f,c,a,h)})}if(i.prop){const f=i.prop;u.push({depth:f.depth,draw:()=>f.draw(l)})}e.save(),e.lineCap="round",e.lineJoin="round";for(const f of[...u].sort((d,m)=>d.depth-m.depth))f.draw();return e.restore(),r}function xf(e,t,n,i){if(e.shape(t.palm,n,i),t.palmFacing<-.3&&e.look!=="silhouette"){const{up:s}=t.axes;for(const[r,o]of Object.entries(t.fingers)){const a=t.curls[r]??0;if(r==="thumb"||a<.5)continue;const l=o.points[0],c=o.widths[0]*.42,h={x:l.x-s.x*c*.2,y:l.y-s.y*c*.2},u=Math.atan2(s.y,s.x),f=Array.from({length:7},(d,m)=>{const p=u-Math.PI/2+Math.PI*m/6;return{x:h.x+Math.cos(p)*c,y:h.y+Math.sin(p)*c}});e.line(f,i*.6)}}if(t.palmFacing>.45&&e.look!=="silhouette"){const{up:s,across:r}=t.axes,o=t.size,a=t.wrist,l=(h,u)=>({x:a.x+(r.x*h+s.x*u)*o,y:a.y+(r.y*h+s.y*u)*o}),c=t.side==="left"?-1:1;e.line([l(-.15*c,.36),l(-.04*c,.3),l(.1*c,.33)],i*.5)}}function Pf(e,t,n,i,s,r){const{widths:o}=n,a=_f(n.points,2),l=n.points[0],c=a[a.length-1],h=o[0],u=o[o.length-1];if(e.save(),t.look!=="silhouette"){e.beginPath(),e.rect(l.x-1e5,l.y-1e5,2e5,2e5);const p=h/2+s*1.6;e.moveTo(l.x+p,l.y),e.arc(l.x,l.y,p,0,Math.PI*2),e.clip("evenodd")}if(t.limb(a,h+2*s,u+2*s),e.restore(),t.look!=="silhouette"&&(e.fillStyle=i,pn(e,a,h,u)),t.look==="silhouette"||!r||n.nail<.25)return;const f=a[a.length-2],d=If({x:c.x-f.x,y:c.y-f.y})??{x:0,y:-1},m={x:c.x-d.x*u*.22+n.back.x*u*.1,y:c.y-d.y*u*.22+n.back.y*u*.1};t.ellipse(m.x,m.y,u*.24*Math.max(.35,n.nail),u*.19,Math.atan2(d.y,d.x),"#f8e3d3",s*.45)}function _f(e,t){let n=e;for(let i=0;i<t;i++){if(n.length<3)return n;const s=[n[0]];for(let r=0;r<n.length-1;r++){const o=n[r],a=n[r+1];r>0&&s.push({x:o.x*.75+a.x*.25,y:o.y*.75+a.y*.25}),r<n.length-2&&s.push({x:o.x*.25+a.x*.75,y:o.y*.25+a.y*.75})}s.push(n[n.length-1]),n=s}return n}const If=e=>{const t=Math.hypot(e.x,e.y);return t>1e-6?{x:e.x/t,y:e.y/t}:null},Ct={walk:{swing:24,knee:30,arm:22,elbow:28,lean:4},bouncy:{swing:26,knee:45,arm:34,elbow:30,lean:2,bend:-4,bounce:.035,squash:.06},doubleBounce:{swing:22,knee:40,arm:26,elbow:24,lean:3,bounce:.02,bounces:2,squash:.04},sneak:{swing:28,knee:70,arm:6,elbow:0,forearm:110,shoulder:55,lean:16,bend:14,headTilt:-8,crouch:50,tiptoe:25},strut:{swing:26,knee:30,arm:30,elbow:20,lean:-4,bend:-10,headTilt:-6,sway:4,bounce:.01},tired:{swing:14,knee:14,arm:6,elbow:6,lean:10,bend:16,headTilt:12},run:{swing:40,knee:95,arm:45,elbow:0,forearm:90,lean:16,bend:6,bounce:.05,squash:.06}},Cf=40;function qi(e){return e===void 0?Ct.walk:typeof e=="string"?Ct[e]??Ct.walk:e}function Zo(e,t,n=N,i=1){const s=qi(e);if(s===Ct.walk)return sa(t,n,i);const r=t*Math.PI*2,o=Math.sin(r)*i,a=Math.cos(r)*i,l=y=>y<=Cf,c=s.shoulder??0,h=(y,w)=>l(y)?w*c+s.arm*o:y,u=s.forearm??0,f=l(n.leftShoulder)?n.leftElbow-u-s.elbow*Math.max(0,-o):n.leftElbow,d=l(n.rightShoulder)?n.rightElbow+u+s.elbow*Math.max(0,o):n.rightElbow,m=s.bounces??1,p=(1+Math.cos(r*2*m))/2,g=s.crouch??0;return{...n,lean:n.lean+s.lean*i+(s.sway??0)*Math.sin(r)*(1-(n.turn??0)),bend:(n.bend??0)+(s.bend??0),headTilt:n.headTilt-s.lean*.5*i+(s.headTilt??0),leftElbow:f,rightElbow:d,leftHip:-s.swing*o-g*.5,rightHip:-s.swing*o+g*.5,leftKnee:-s.knee*Math.max(0,a)-g,rightKnee:s.knee*Math.max(0,-a)+g,leftAnkle:(n.leftAnkle??0)+(s.tiptoe??0),rightAnkle:(n.rightAnkle??0)+(s.tiptoe??0),leftShoulder:h(n.leftShoulder,-1),rightShoulder:h(n.rightShoulder,1),rise:(n.rise??0)+(s.bounce??0)*i*p,stretch:n.stretch*(1+(s.squash??0)*(p-.5))}}function Qo(e,t,n=1){const i=qi(e),s=Ct.walk.swing,r=o=>Math.sin(o*Math.PI/180);return ra(t,n)*r(i.swing*n)/r(s*n)}const N={lean:0,bend:0,headTilt:0,leftShoulder:18,rightShoulder:18,leftElbow:-6,rightElbow:-6,leftHip:8,rightHip:8,leftKnee:0,rightKnee:0,leftWrist:0,rightWrist:0,leftAnkle:0,rightAnkle:0,leftFootOut:0,rightFootOut:0,mouth:0,smile:.6,mouthWidth:1,blink:0,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0,stretch:1,turn:0,sit:0,spin:0,rise:0};function j(e){return{...N,...e}}const ta={mouth:0,smile:0,mouthWidth:1,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0},V=e=>({...ta,...e}),U={neutral:ta,happy:V({smile:.9,leftBrow:.2,rightBrow:.2}),joyful:V({mouth:.6,smile:1,mouthWidth:1.2,leftEye:0,rightEye:0,leftBrow:.4,rightBrow:.4}),sad:V({smile:-.8,leftEye:.8,rightEye:.8,browTilt:.9,leftBrow:-.1,rightBrow:-.1,lookY:.6}),crying:V({mouth:.45,smile:-1,leftEye:0,rightEye:0,browTilt:1,lookY:.4}),surprised:V({mouth:.7,mouthWidth:.7,leftEye:1.5,rightEye:1.5,leftBrow:1,rightBrow:1}),shocked:V({mouth:1,mouthWidth:.8,leftEye:1.6,rightEye:1.6,leftBrow:1,rightBrow:1,browTilt:.4}),angry:V({smile:-.6,mouthWidth:.9,leftEye:.8,rightEye:.8,leftBrow:-.6,rightBrow:-.6,browTilt:-1}),furious:V({mouth:.5,smile:-1,mouthWidth:1.3,leftEye:.9,rightEye:.9,leftBrow:-.9,rightBrow:-.9,browTilt:-1}),worried:V({smile:-.3,mouthWidth:.8,leftEye:1.1,rightEye:1.1,leftBrow:.3,rightBrow:.3,browTilt:.8,lookX:-.5}),scared:V({mouth:.35,smile:-.5,mouthWidth:.8,leftEye:1.45,rightEye:1.45,leftBrow:.8,rightBrow:.8,browTilt:.9}),confused:V({smile:-.2,mouthWidth:.8,leftEye:.9,rightEye:1.15,leftBrow:-.3,rightBrow:.8,lookX:.5,lookY:-.4}),skeptical:V({smile:-.1,leftEye:.6,rightEye:1,leftBrow:-.4,rightBrow:.7,lookX:.4}),thinking:V({smile:0,mouthWidth:.7,leftBrow:.3,rightBrow:.5,lookX:.6,lookY:-.8}),sleepy:V({smile:.1,leftEye:.25,rightEye:.25,leftBrow:-.3,rightBrow:-.3,lookY:.5}),disgusted:V({smile:-.7,mouthWidth:.9,leftEye:.6,rightEye:.75,leftBrow:-.5,rightBrow:-.2,browTilt:-.4,lookX:-.6}),smug:V({smile:.6,mouthWidth:.9,leftEye:.6,rightEye:.6,leftBrow:.1,rightBrow:.5,lookX:.5}),wink:V({smile:.9,leftEye:0,rightEye:1,leftBrow:-.2,rightBrow:.3})};function Ce(e,t){return{...e,...typeof t=="string"?U[t]:t}}const ee={rest:N,wave:j({rightShoulder:135,rightElbow:30,headTilt:6,...U.happy}),cheer:j({leftShoulder:125,leftElbow:20,rightShoulder:125,rightElbow:20,...U.joyful}),shrug:j({leftShoulder:30,leftElbow:85,rightShoulder:30,rightElbow:85,headTilt:-10,...U.confused,lookX:0,lookY:0}),point:j({rightShoulder:90,rightElbow:0,lean:4,smile:.4}),think:j({rightShoulder:60,rightElbow:150,headTilt:10,...U.thinking}),handsOnHips:j({leftShoulder:45,leftElbow:-100,rightShoulder:45,rightElbow:-100,leftHip:14,rightHip:14,smile:.8}),sad:j({leftShoulder:14,rightShoulder:14,leftElbow:-4,rightElbow:-4,headTilt:-14,lean:-3,...U.sad}),surprised:j({leftShoulder:70,leftElbow:60,rightShoulder:70,rightElbow:60,...U.surprised}),crouch:j({stretch:.72,leftShoulder:35,rightShoulder:35,leftElbow:-50,rightElbow:-50,leftHip:22,rightHip:22,headTilt:-4}),sit:j({sit:1,turn:.5,leftShoulder:-25,rightShoulder:25,leftElbow:-55,rightElbow:55}),jump:j({stretch:1.22,leftShoulder:140,rightShoulder:140,leftElbow:20,rightElbow:20,leftHip:4,rightHip:4,...U.joyful}),sideSplit:j({leftHip:90,rightHip:90,leftAnkle:-45,rightAnkle:-45,leftShoulder:120,rightShoulder:120,leftElbow:10,rightElbow:10,...U.happy}),frontSplit:j({turn:1,leftHip:-90,rightHip:-90,leftAnkle:-45,rightAnkle:-45,leftShoulder:-150,rightShoulder:150,leftElbow:10,rightElbow:-10,...U.happy})},ea=Object.keys(N);function ne(e,t,n){const i={...e};for(const s of ea)i[s]=e[s]+(t[s]-e[s])*n;return i}const Vi=24,na=4,ia=28,Hf=40;function sa(e,t=N,n=1){const i=Math.sin(e*Math.PI*2)*n,s=Math.cos(e*Math.PI*2)*n,r=c=>c<=Hf,o=c=>r(c)?22*i:c,a=r(t.leftShoulder)?t.leftElbow-ia*Math.max(0,-i):t.leftElbow,l=r(t.rightShoulder)?t.rightElbow+ia*Math.max(0,i):t.rightElbow;return{...t,lean:t.lean+na*n,headTilt:t.headTilt-na*.5*n,leftElbow:a,rightElbow:l,leftHip:-Vi*i,rightHip:-Vi*i,leftKnee:-30*Math.max(0,s),rightKnee:30*Math.max(0,-s),leftShoulder:o(t.leftShoulder),rightShoulder:o(t.rightShoulder)}}function ra(e,t=1){return 4*((Ui+wn)*e)*Math.sin(Vi*t*Math.PI/180)}function oa(e){const t=Math.abs(Math.sin(e/65)),n=.55+.45*Math.sin(e/310);return t*n}const aa=.12,la=.46,$f=1-2*aa,Of=.1,Rf=.21,Lf=.19,Ui=.24,wn=.22,ca=.12,Ff=.14,ha=.33,ua=.7,fa=.3,Df=.35,Bf=[1.7,1.05],Nf=[1.3,.75],da=[1.45,.85],Wf=[1.15,.75],pa=.06,Kf=.7,Yf=.65,ma=.075,Xf=.3,qf=.02,Vf=.012,Uf=12,zf=.25,vn=90,jf=.25,Gf=.04,ga=.01,Ht=e=>Math.min(1,Math.max(0,e??0));function Jf(e,t=1){return wn*e*t}const zi=-.12,ya=.4,nt=e=>e*Math.PI/180,Zf=(e,t)=>({x:t*Math.sin(nt(e)),y:Math.cos(nt(e))}),ba=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),wa=(e,t,n,i)=>e-.3*t-n*.14*t-Math.max(0,i-1)*.12*t;function Qf(e,t,n,i,s,r){const o=Math.max(1,Math.min(r*.6,Ff*n)),a=Ht(t.turn),l=(ca+ha*a)*n,c=i+zi*n,h=l+t.lookX*.08*n,u=t.lookY*.07*n,f=[{x:-.34*n*(1-ua*a),squeeze:1-ua*a,open:t.leftEye,brow:t.leftBrow,side:-1},{x:.34*n*(1-fa*a),squeeze:1-fa*a,open:t.rightEye,brow:t.rightBrow,side:1}];e.fillStyle=s,e.strokeStyle=s,e.lineWidth=o;for(const y of f){const w=ba(y.open,t.blink);if(w<.2){const E=t.smile>.5?-.12*n:.06*n;e.beginPath(),e.moveTo(y.x+l-.12*n,c),e.quadraticCurveTo(y.x+l,c+E,y.x+l+.12*n,c),e.stroke()}else{if(w>1.2){const k=.13*n*w;e.beginPath(),e.ellipse(y.x+l,c,k*.85,k,0,0,Math.PI*2),e.fillStyle="#ffffff",e.fill(),e.stroke(),e.fillStyle=s}const E=w>1.2?.075*n:.1*n;e.beginPath(),e.ellipse(y.x+h,c+u,E,E*1.1*Math.min(w,1),0,0,Math.PI*2),e.fill()}const v=wa(c,n,y.brow,w),M=y.x+l-y.side*.13*n*y.squeeze,S=y.x+l+y.side*.13*n*y.squeeze;e.beginPath(),e.moveTo(S,v),e.lineTo(M,v-t.browTilt*.1*n),e.stroke()}const d=i+ya*n,m=.25*n*Math.max(.3,t.mouthWidth)*(1-Df*a),p=Math.min(1,Math.max(0,t.mouth));if(e.beginPath(),p<=.05){e.moveTo(l-m,d),e.quadraticCurveTo(l,d+t.smile*.25*n,l+m,d),e.stroke();return}const g=.3*n*p;t.smile>.3?(e.moveTo(l-m,d-.05*n),e.lineTo(l+m,d-.05*n),e.quadraticCurveTo(l,d+g*2,l-m,d-.05*n)):t.smile<-.3?(e.moveTo(l-m,d+g*.6),e.lineTo(l+m,d+g*.6),e.quadraticCurveTo(l,d-g*1.4,l-m,d+g*.6)):e.ellipse(l,d,m*.8,g,0,0,Math.PI*2),e.fill()}function va(e,t){const n=t.height??300,i=Math.min(3,Math.max(.3,e.stretch??1)),s=Math.sqrt(i),r=(t.headSize??2*aa)/2,o=t.headSize===void 0?$f:1-2*r,a=r*n,l=Ht(e.sit),c=e.leftHip+(-vn-e.leftHip)*l,h=e.leftKnee+(-vn-e.leftKnee)*l,u=e.rightHip+(vn-e.rightHip)*l,f=e.rightKnee+(vn-e.rightKnee)*l,d=t.classic===!0,m=Ht(e.turn),p=(O,L,$,F,D)=>{const W=Math.max(-Math.PI/2,Math.min(Math.PI/2,Math.abs(nt(L-$)/2)+nt(F))),Z=Math.max(-1,Math.min(1,Kf+D)),Et=m+(1-m)*O*Z;return d?{x:0,y:0}:{x:Math.cos(W)*pa*Et,y:Math.sin(W)*pa}},g={left:e.leftAnkle??0,right:e.rightAnkle??0},y={left:e.leftFootOut??0,right:e.rightFootOut??0};let w=0;if(l>0||!d){const O=(D,W,Z,Et,Lt)=>Ui*Math.cos(nt(W))+wn*Math.cos(nt(W-Z))+Math.max(0,p(D,W,Z,Et,Lt).y),L=Math.max(O(-1,c,h,g.left,y.left),O(1,u,f,g.right,y.right)),$=1-Ht((e.rise??0)/Gf),F=(d?Math.min(1,l/jf):1)*$;w=(la-L)*F*n*i}const v=-la*n*i+w,M=-o*n*i+w,S=d?0:(qf*Ht(e.turn)+Vf*l)*n*i,E=nt(e.bend??0),k={end:Sa(v,M,E,1),bend:E};let x;if(E!==0){x=[];for(let O=0;O<=ka;O++){const L=O/ka,$=Sa(v,M,E,L);x.push({x:$.x-S*Math.sin(Math.PI*L),y:$.y})}}else x=S===0?[{x:0,y:v},{x:0,y:M}]:It({x:0,y:v},{x:-S,y:(v+M)/2},{x:0,y:M},1,8);const T=M+Of*n*i,P=(t.shoulderWidth??0)*n*Math.cos(m*Math.PI/2),A=(O,L,$,F,D)=>{const W=Zf($,F);return{x:O+W.x*D*n,y:L+W.y*D*n}},_=(O,L,$)=>{const F=A(0,v,L,O,Ui*i);return{root:{x:0,y:v},joint:F,end:A(F.x,F.y,L-$,O,wn*i)}},I=(O,L,$)=>{const F={x:O*P,y:T},D=A(F.x,F.y,L,O,Rf*s);return{root:F,joint:D,end:A(D.x,D.y,L+$,O,Lf*s)}},C={left:_(-1,c,h),right:_(1,u,f)},H=(O,L,$,F,D,W)=>{const Z=p(O,$,F,D,W);return{x:L.end.x+Z.x*n*i,y:L.end.y+Z.y*n*i}},R=(O,L,$,F,D)=>A(L.end.x,L.end.y,$+F+D,O,ma*s),B={left:I(-1,e.leftShoulder,e.leftElbow),right:I(1,e.rightShoulder,e.rightElbow)};return{height:n,facing:(t.facing??1)<0?-1:1,stretch:i,lineWidth:t.lineWidth??n*.025,rubber:Math.min(1,Math.max(d?0:Xf,t.rubber??0)),r:a,headRx:a/Math.sqrt(i),headRy:a*Math.sqrt(i),hipY:v,neckY:M,drop:w,lean:d?e.lean:e.lean+Uf*Math.sin(Math.PI*l),classic:d,legs:C,toes:{left:H(-1,C.left,c,h,g.left,y.left),right:H(1,C.right,u,f,g.right,y.right)},spine:x,chest:k,arms:B,handTips:{left:R(-1,B.left,e.leftShoulder,e.leftElbow,e.leftWrist??0),right:R(1,B.right,e.rightShoulder,e.rightElbow,e.rightWrist??0)}}}const ka=10;function Sa(e,t,n,i){const s=e-t,r=n*i;if(Math.abs(n)<1e-9)return{x:0,y:e-s*i};const o=s/n;return{x:o*(1-Math.cos(r)),y:e-o*Math.sin(r)}}function td(e,t){if(e.chest.bend===0)return t;const n=$e(t,{x:0,y:e.neckY},e.chest.bend);return{x:n.x+e.chest.end.x,y:n.y+e.chest.end.y-e.neckY}}const He=(e,t)=>t===0?[e.root,e.joint,e.end]:It(e.root,e.joint,e.end,t);function $e(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=e.x-t.x,o=e.y-t.y;return{x:t.x+r*i-o*s,y:t.y+r*s+o*i}}function Ma(e,t,n=!0){const i=nd(e,t),s=t.spin??0,r=t.rise??0;return n&&(s!==0||r!==0)?ed(i,e,s,r):i}function Ta(e,t,n){return{pivot:{x:0,y:e.hipY},angle:e.facing*nt(t),lift:n*e.height}}function ed(e,t,n,i){const{pivot:s,angle:r,lift:o}=Ta(t,n,i),a=f=>{const d=$e(f,s,r);return{x:d.x,y:d.y-o}},l=f=>({left:a(f.left),right:a(f.right)}),c={left:Math.max(a(e.feet.left).y,a(e.toes.left).y),right:Math.max(a(e.feet.right).y,a(e.toes.right).y)},h=Math.max(c.left,c.right),u=ga*t.height;return{...e,hip:a(e.hip),neck:a(e.neck),shoulders:l(e.shoulders),elbows:l(e.elbows),hands:l(e.hands),fingertips:l(e.fingertips),knees:l(e.knees),feet:l(e.feet),toes:l(e.toes),feetY:h,grounded:{left:c.left>=h-u,right:c.right>=h-u},handAngle:{left:e.handAngle.left+r,right:e.handAngle.right+r},limbs:{leftArm:e.limbs.leftArm.map(a),rightArm:e.limbs.rightArm.map(a),leftLeg:e.limbs.leftLeg.map(a),rightLeg:e.limbs.rightLeg.map(a),spine:e.limbs.spine.map(a)},head:{...e.head,center:a(e.head.center),angle:e.head.angle+r}}}function nd(e,t){const n=nt(e.lean),i=nt(t.headTilt),s={x:0,y:e.hipY},r=M=>({x:e.facing*M.x,y:M.y}),o=M=>r($e(M,s,n)),a=M=>o(td(e,M)),l=M=>a($e({x:M.x,y:M.y+e.neckY},{x:0,y:e.neckY},i)),c=He(e.arms.left,e.rubber).map(a),h=He(e.arms.right,e.rubber).map(a),u=(M,S)=>Math.atan2(S.y-M.y,S.x-M.x),f={left:a(e.handTips.left),right:a(e.handTips.right)},d=(M,S)=>{const[E,k]=M.slice(-2),x=e.arms[S],T=u(a(x.end),f[S])-u(a(x.joint),a(x.end));return u(E,k)+T};let m=1/0;for(const[M,S]of[[t.leftBrow,t.leftEye],[t.rightBrow,t.rightEye]]){const E=wa(zi,1,M,ba(S,t.blink));m=Math.min(m,E,E-t.browTilt*.1)}const p={left:r(e.legs.left.end),right:r(e.legs.right.end)},g={left:r(e.toes.left),right:r(e.toes.right)},y={left:Math.max(p.left.y,g.left.y),right:Math.max(p.right.y,g.right.y)},w=Math.max(y.left,y.right),v=ga*e.height;return{facing:e.facing,height:e.height,stretch:e.stretch,lineWidth:e.lineWidth,hip:s,neck:a({x:0,y:e.neckY}),shoulders:{left:a(e.arms.left.root),right:a(e.arms.right.root)},elbows:{left:a(e.arms.left.joint),right:a(e.arms.right.joint)},hands:{left:a(e.arms.left.end),right:a(e.arms.right.end)},knees:{left:r(e.legs.left.joint),right:r(e.legs.right.joint)},feet:p,toes:g,feetY:w,grounded:{left:y.left>=w-v,right:y.right>=w-v},fingertips:f,handAngle:{left:d(c,"left"),right:d(h,"right")},limbs:{leftArm:c,rightArm:h,leftLeg:He(e.legs.left,e.rubber).map(r),rightLeg:He(e.legs.right,e.rubber).map(r),spine:e.spine.map(o)},head:{center:l({x:0,y:-e.headRy}),rx:e.headRx,ry:e.headRy,angle:e.facing*(n+e.chest.bend+i),eyeY:zi,browTopY:m,mouthY:ya,faceX:e.facing*(ca+ha*Ht(t.turn))}}}function Ea(e,t={}){return Ma(va(e,t),e)}function id(e,t,n){return $e({x:e.center.x+t*e.rx,y:e.center.y+n*e.ry},e.center,e.angle)}function Aa(e,t,n){const i=r=>({x:r.x+t,y:r.y+n}),s=r=>({left:i(r.left),right:i(r.right)});return{...e,hip:i(e.hip),neck:i(e.neck),shoulders:s(e.shoulders),elbows:s(e.elbows),hands:s(e.hands),knees:s(e.knees),feet:s(e.feet),toes:s(e.toes),feetY:e.feetY+n,grounded:{...e.grounded},handAngle:{...e.handAngle},limbs:{leftArm:e.limbs.leftArm.map(i),rightArm:e.limbs.rightArm.map(i),leftLeg:e.limbs.leftLeg.map(i),rightLeg:e.limbs.rightLeg.map(i),spine:e.limbs.spine.map(i)},head:{...e.head,center:i(e.head.center)}}}function xa(e,t,n={},i=0){const s=va(t,n),r=n.color??"#1e293b",o=n.layers??{},a=n.layers?Ma(s,t,!1):void 0,l=n.sketch?dn(e,n.sketch,i):void 0,c=n.sketch&&n.layers?dn(e,n.sketch,i):void 0,h=k=>{e.save(),k(),e.restore()},u=k=>{k&&a&&h(()=>k(e,a,i,c))},f=()=>e.scale(s.facing,1),d=()=>{f(),e.translate(0,s.hipY),e.rotate(nt(s.lean)),e.translate(0,-s.hipY)},m=()=>{d(),s.chest.bend!==0&&(e.translate(s.chest.end.x,s.chest.end.y),e.rotate(s.chest.bend),e.translate(0,-s.neckY))},p=(k,x,T)=>{if(l)return x?l.curve(k):l.line(k);if(s.classic){e.beginPath(),e.moveTo(k[0].x,k[0].y);for(const P of k.slice(1))e.lineTo(P.x,P.y);e.stroke();return}pn(e,k,T[0]*s.lineWidth,T[1]*s.lineWidth)},g=(k,x)=>p(He(k,s.rubber),s.rubber>0,x),y=k=>{s.classic||p([s.legs[k].end,s.toes[k]],!1,Wf)},w=k=>{if(n.hands&&!s.classic)return M(k);if(s.classic||l)return;const x=s.arms[k].end;e.beginPath(),e.arc(x.x,x.y,Yf*s.lineWidth,0,Math.PI*2),e.fill()};e.save(),e.strokeStyle=r,e.fillStyle=r,e.lineWidth=s.lineWidth,e.lineCap="round",e.lineJoin="round";const v=Ta(s,t.spin??0,t.rise??0);(v.angle!==0||v.lift!==0)&&(e.translate(0,-v.lift),e.translate(v.pivot.x,v.pivot.y),e.rotate(v.angle),e.translate(-v.pivot.x,-v.pivot.y));function M(k){const x=n.hands??{},T=s.arms[k].end,P=s.handTips[k],A=n.headFill??"#ffffff";bn(e,T,x[k]??K,{side:k,angle:Math.atan2(P.x-T.x,T.y-P.y)*180/Math.PI,size:(x.size??ma)*s.height*Math.sqrt(s.stretch),skin:x.skin??(A==="none"?void 0:A),ink:r,lineWidth:s.lineWidth*.45,fingers:x.fingers,plump:x.plump,look:n.sketch?"pencil":"clean",seed:n.sketch?.seed},i)}const S=k=>{h(()=>{m(),g(s.arms[k],Nf),w(k)});const x=o.sleeve;x&&a&&h(()=>x(e,a,k,i,c))},E=Ht(t.turn)>zf;u(o.behind),h(()=>{f(),g(s.legs.left,da),y("left"),g(s.legs.right,da),y("right")}),E&&S("left"),h(()=>{d(),p(s.spine,s.spine.length>2,Bf)}),h(()=>{m();const{left:k,right:x}={left:s.arms.left.root,right:s.arms.right.root};if(k.x!==x.x)if(s.classic)p([k,x],!1,[1,1]);else{const T={x:(k.x+x.x)/2,y:k.y-.3*Math.abs(x.x-k.x)};p(It(k,T,x,1,8),!0,[1.1,1.1])}}),u(o.body),E||S("left"),S("right"),u(o.behindHead),h(()=>{m(),e.translate(0,s.neckY),e.rotate(nt(t.headTilt));const k=-s.headRy;e.beginPath(),e.ellipse(0,k,s.headRx,s.headRy,0,0,Math.PI*2);const x=n.headFill??"#ffffff";if(x!=="none"&&(e.fillStyle=x,e.fill()),l){l.ellipse(0,k,s.headRx,s.headRy);const T=l.nudge();e.translate(T.x,T.y)}else e.stroke();e.translate(0,k),e.scale(s.headRx/s.r,s.headRy/s.r),Qf(e,t,s.r,0,r,s.lineWidth)}),u(o.overHead),u(o.front),e.restore(),n.label&&(e.save(),e.fillStyle=r,e.font=n.labelFont??`700 ${Math.round(s.height*.11)}px sans-serif`,e.textAlign="center",e.textBaseline="bottom",e.fillText(n.label,0,-s.height*s.stretch-.04*s.height+s.drop),e.restore())}function ji(e,t,n){const i={...e};let s=e.walking>0?ne(i,Zo(e.gait,e.walk,i),e.walking):i,r=sd(e);const o=e.dancing??0;if(n&&o>0){const a=n(e.beat??0);if(s=ne(s,a.pose,o),a.hands){const l=(c,h)=>h?te(c??K,h,o):c;r={left:l(r?.left,a.hands.left),right:l(r?.right,a.hands.right)}}}return e.talk>0&&(s={...s,mouth:Math.max(s.mouth,e.talk*oa(t))}),{pose:s,hands:r}}function Pa(e,t,n){return ji(e,t,n).pose}const _a=(e,t)=>(e.facing??t.facing??1)<0?-1:1,Oe=(e,t)=>`hand.${e}.${t}`;function sd(e){const t=s=>{if(typeof e[Oe(s,"spread")]=="number")return Object.fromEntries(Object.keys(K).map(r=>[r,e[Oe(s,r)]]))},n=t("left"),i=t("right");return n||i?{left:n,right:i}:void 0}function rd(e,t){return!t||!e.hands?e:{...e,hands:{...e.hands,left:t.left??e.hands.left,right:t.right??e.hands.right}}}function od(e){const t=e.style??{},n=t.height??300,i=n*.8,s={...j(e.pose??{}),walk:0,walking:0,gait:"walk",facing:(t.facing??1)<0?-1:1,talk:0,rubber:t.rubber??0,beat:0,dancing:0},r={};if(t.hands)for(const o of["left","right"]){const a=t.hands[o]??K;for(const l of Object.keys(K))r[Oe(o,l)]=a[l]??K[l]}return{type:"custom",x:e.x-i/2,y:e.y-n,width:i,height:n,props:{...s,...r},figureStyle:t,figureDance:e.dance,draw(o,a,l){const c=a.props,h=ji(c,l,e.dance);o.translate(i/2,n),xa(o,h.pose,rd({...t,rubber:c.rubber,facing:_a(c,t)},h.hands),l)}}}function Ia(e,t,n){const i=e.figureStyle;if(!i)throw new Error("stickFigureAt: the target was not made by stickFigureTarget");const s={...e.props};let r=0,o=0;for(const[c,h]of t.state?.values.get(n)??[])c==="gait"&&typeof h=="string"&&(s.gait=h),typeof h=="number"&&(c==="x"||c==="motionPathX"?r=h:c==="y"||c==="motionPathY"?o=h:c in s&&(s[c]=h));const a=Pa(s,t.time,e.figureDance),l=Ea(a,{...i,rubber:s.rubber,facing:_a(s,i)});return{pose:a,joints:Aa(l,e.x+r+e.width/2,e.y+o+e.height)}}function Gi(e){const t=[];return e.forEach((n,i)=>{const s=i===0?N:t[i-1],r=typeof n.pose=="string"?ee[n.pose]:{...s,...n.pose};t.push(n.expression?Ce(r,n.expression):r)}),t}function ad(e,t){const n=Gi(t);return ea.filter(i=>n.some(s=>s[i]!==N[i])).map(i=>({id:`${e}-${i}`,target:e,property:i,keyframes:t.map((s,r)=>({time:s.time,value:n[r][i],...s.easing?{easing:s.easing}:{}}))}))}const Ji=.5,Zi={pataka:Y({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:0,turn:2}),tripataka:Y({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":1,"pinky.curl":0,spread:0,turn:2}),alapadma:Y({"thumb.curl":.1,"thumb.across":0,"index.curl":.05,"middle.curl":.15,"ring.curl":.25,"pinky.curl":.35,spread:1,turn:2}),mushti:q.fist,shikhara:q.thumbsUp,hamsasya:Y({"thumb.curl":.15,"thumb.across":.6,"index.curl":.6,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:.7,turn:2}),katakamukha:Y({"thumb.curl":.2,"thumb.across":.6,"index.curl":.65,"middle.curl":.7,"ring.curl":0,"pinky.curl":0,spread:.4,turn:2})};function kn(e){return typeof e!="string"?e:e in Zi?Zi[e]:q[e]}function Ca(e,t,n){const i=[];for(const s of e.keys){const r=i[i.length-1],o=!r||s.reset?{pose:t,...n}:r;i.push({beat:s.beat,pose:{...o.pose,...s.pose},left:s.hands?.left?kn(s.hands.left):o.left,right:s.hands?.right?kn(s.hands.right):o.right,easing:s.easing??e.easing})}return i}const Qi=(e,t)=>(e%t+t)%t;function ld(e,t,n,i){const s=Ca(e,n,i);if(s.length===0)return{pose:n,hands:i};const r=Qi(t,e.beats);let o=s.length-1;for(let d=0;d<s.length;d++)s[d].beat<=r&&(o=d);const a=s[o],l=s[(o+1)%s.length],c=a.beat<=r?a.beat:a.beat-e.beats,h=l.beat>c?l.beat:l.beat+e.beats,u=h>c?(r-c)/(h-c):0,f=G(l.easing??"ease-in-out")(Math.min(1,Math.max(0,u)));return{pose:ne(a.pose,l.pose,f),hands:{left:te(a.left,l.left,f),right:te(a.right,l.right,f)}}}const cd=[["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"],["leftFootOut","rightFootOut"],["leftEye","rightEye"],["leftBrow","rightBrow"]],hd=["lean","headTilt","lookX","spin"],ud=new Set(["leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee"]);function Ha(e){const t={...e},n=(e.turn??0)>=.5;for(const[i,s]of cd){const r=n&&ud.has(i)?-1:1;t[i]=r*e[s],t[s]=r*e[i]}if(!n)for(const i of hd)t[i]=-e[i];return t}const fd=e=>Math.min(1,Math.max(-1,(.5-e)*4));function $a(e,t,n){const i=Qi(n,1),s=(1+Math.cos(2*Math.PI*i))/2,r=t.bounce*(t.accent==="up"?1-s:s),o=Math.min(1,Math.max(0,e.turn??0)),a=fd(o);return{...e,leftHip:e.leftHip+a*r/2,rightHip:e.rightHip+r/2,leftKnee:e.leftKnee+a*r,rightKnee:e.rightKnee+r,lean:e.lean+(t.sway??0)*(1-o)*Math.sin(Math.PI*n)}}function Sn(e){const t={...N,...e.stance};return e.expression?Ce(t,e.expression):t}function Oa(e){return{left:e.hands?.left?kn(e.hands.left):K,right:e.hands?.right?kn(e.hands.right):K}}function ts(e,t,n){const i=e.moves[t.move];if(!i)throw new Error(`dance: "${e.label}" has no move "${t.move}"`);const s=ld(i,n,Sn(e),Oa(e));return t.mirror?{pose:Ha(s.pose),hands:{left:s.hands?.right,right:s.hands?.left}}:s}function Mn(e,t,n={}){const i=typeof e=="string"?$t[e]:e;let s;if(n.move)s=ts(i,{move:n.move,mirror:n.mirror},t);else{const r=i.routine,o=r.reduce((u,f)=>u+f.beats,0),a=Qi(t,o);let l=0,c=0;for(;c<r.length-1&&a>=l+r[c].beats;)l+=r[c++].beats;const h=a-l;if(s=ts(i,r[c],h),h<Ji&&r.length>1&&t>=Ji){const u=r[(c-1+r.length)%r.length],f=ts(i,u,u.beats+h),d=G("ease-in-out")(h/Ji);s={pose:ne(f.pose,s.pose,d),hands:{left:te(f.hands.left,s.hands.left,d),right:te(f.hands.right,s.hands.right,d)}}}}return{...s,pose:$a(s.pose,i.groove,t)}}function dd(e,t,n={}){return Mn(e,t,n).pose}function Tn(e){return(typeof e=="string"?$t[e]:e).routine.reduce((n,i)=>n+i.beats,0)}const pd={leftToe:"rightToe",rightToe:"leftToe",leftHeel:"rightHeel",rightHeel:"leftHeel"};function Ra(e,t,n,i,s,r,o){for(let a=0;a*e.beats<n;a++)for(const l of e.keys){const c=a*e.beats+l.beat,h=t+c;if(!(c>=n||h<r||h>=o))for(const u of l.taps??[])s.push({beat:h,tap:i?pd[u]:u})}}function md(e,t,n,i={}){const s=typeof e=="string"?$t[e]:e,r=[];if(n<=t)return r;if(i.move){const o=s.moves[i.move],a=Math.floor(t/o.beats)*o.beats;Ra(o,a,Math.ceil((n-a)/o.beats)*o.beats,i.mirror,r,t,n)}else{const o=Tn(s);for(let a=Math.floor(t/o)*o;a<n;a+=o){let l=a;for(const c of s.routine)Ra(s.moves[c.move],l,c.beats,c.mirror,r,t,n),l+=c.beats}}return r.sort((o,a)=>o.beat-a.beat)}function La(e,t){const n=e.moves[t.move];if(!n?.travel)return 0;const i=n.travel/n.beats;return t.mirror?(Ca(n,Sn(e),Oa(e))[0]?.pose.turn??Sn(e).turn??0)>=.5?i:-i:i}function Fa(e,t){return t.move?[{move:t.move,beats:e.moves[t.move].beats,mirror:t.mirror}]:e.routine}function En(e,t,n={}){const i=typeof e=="string"?$t[e]:e,s=Fa(i,n),r=s.reduce((h,u)=>h+u.beats,0),o=s.reduce((h,u)=>h+La(i,u)*u.beats,0),a=Math.floor(t/r);let l=a*o,c=t-a*r;for(const h of s){const u=Math.min(h.beats,c);if(l+=La(i,h)*u,c-=u,c<=0)break}return l}function gd(e,t,n){const i=Fa(e,n),s=[0];let r=0;for(let o=0;r<t;o=(o+1)%i.length)r+=i[o].beats,s.push(Math.min(r,t));return s}const yd=8;function Da(e,t,n){const i=typeof t=="string"?$t[t]:t,s=n.bpm??i.bpm,r=n.beats??(n.move?i.moves[n.move].beats:Tn(i)),o=gd(i,r,n);if(o.every(y=>En(i,y,n)===0))return;const a=Math.min(n.fade??1,r/2),l=G("ease-in-out"),c=y=>a<=0?1:Math.min(l(Math.min(1,y/a)),l(Math.min(1,(r-y)/a))),h=Math.ceil(a*yd),u=a<=0?[]:Array.from({length:h+1},(y,w)=>[w/h*a,r-w/h*a]).flat(),f=[...new Set([...o,...u])].sort((y,w)=>y-w);let d=0;const m=f.map((y,w)=>{if(w>0){const v=f[w-1],M=Math.max(1,Math.ceil((y-v)*16));for(let S=0;S<M;S++){const E=v+(y-v)*S/M,k=v+(y-v)*(S+1)/M;d+=(En(i,k,n)-En(i,E,n))*c((E+k)/2)}}return{beat:y,travel:d}}),p=n.start??0,g=n.x??0;return{id:`${e}-x`,target:e,property:"x",keyframes:m.map(y=>({time:p+y.beat*6e4/s,value:g+n.height*y.travel,easing:"linear"}))}}function bd(e,t,n=0){return(e-n)*t/6e4}function wd(e,t={}){return n=>Mn(e,n,t)}function vd(e,t){const n=t.start??0,i=6e4/t.bpm,s=n+t.beats*i,r=Math.min((t.fade??1)*i,(s-n)/2);return[{id:`${e}-beat`,target:e,property:"beat",keyframes:[{time:n,value:0},{time:s,value:t.beats,easing:"linear"}]},{id:`${e}-dancing`,target:e,property:"dancing",keyframes:[{time:n,value:0},{time:n+r,value:1,easing:"ease-in-out"},{time:s-r,value:1},{time:s,value:0,easing:"ease-in-out"}]}]}function kd(e,t,n={}){const i=typeof t=="string"?$t[t]:t,s=n.bpm??i.bpm,r=n.beats??(n.move?i.moves[n.move].beats:Tn(i)),o=n.samplesPerBeat??4,a=n.start??0,l=Math.round(r*o),c=Array.from({length:l+1},(p,g)=>{const y=g/o;return{time:a+y*6e4/s,frame:Mn(i,y,n)}}),h=(p,g)=>({id:`${e}-${p}`,target:e,property:p,keyframes:c.map(y=>({time:y.time,value:g(y.frame)}))}),f=Object.keys(N).filter(p=>c.some(g=>g.frame.pose[p]!==c[0].frame.pose[p])||c[0].frame.pose[p]!==N[p]).map(p=>h(p,g=>g.pose[p])),d=n.height===void 0?void 0:Da(e,i,{...n,bpm:s,beats:r,start:a,height:n.height,fade:0});if(d&&f.push(d),n.hands===!1)return f;const m=[];for(const p of["left","right"])for(const g of Object.keys(K)){const y=w=>w.hands?.[p]?.[g]??K[g];c.some(w=>y(w.frame)!==K[g])&&m.push(h(Oe(p,g),y))}return[...f,...m]}const Re={type:"back",mode:"out",overshoot:1.1},J="ease-out-cubic",Sd={label:"Disco",bpm:120,stance:{leftHip:10,rightHip:10,leftKnee:6,rightKnee:6},expression:{smile:.9,mouth:.15,leftBrow:.3,rightBrow:.3},groove:{bounce:10,accent:"down",sway:2},moves:{point:{label:"The point",beats:2,easing:J,keys:[{beat:0,pose:{rightShoulder:150,rightElbow:0,rightWrist:0,leftShoulder:40,leftElbow:-105,leftWrist:-20,lean:-5,headTilt:8,rightHip:18,leftHip:6,lookX:.6,lookY:-.7},hands:{right:"point",left:"fist"}},{beat:1,pose:{rightShoulder:-30,rightWrist:10,lean:5,headTilt:-6,rightHip:6,leftHip:18,lookX:-.4,lookY:.6}}]},roll:{label:"Roll the arms",beats:2,easing:"linear",keys:[{beat:0,pose:{leftShoulder:42,leftElbow:-128,rightShoulder:26,rightElbow:-100,rightHip:18,leftHip:6,lean:-3},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{leftShoulder:26,leftElbow:-100,rightShoulder:42,rightElbow:-128}},{beat:1,pose:{leftShoulder:42,leftElbow:-128,rightShoulder:26,rightElbow:-100,rightHip:6,leftHip:18,lean:3}},{beat:1.5,pose:{leftShoulder:26,leftElbow:-100,rightShoulder:42,rightElbow:-128}}]},bump:{label:"Bump and clap",beats:4,keys:[{beat:0,pose:{lean:-10,rightHip:22,leftHip:4,leftShoulder:140,rightShoulder:140,leftElbow:0,rightElbow:0,leftWrist:20,rightWrist:20},hands:{left:"spread",right:"spread"},easing:J},{beat:1,pose:{lean:0,rightHip:10,leftHip:10,leftShoulder:168,rightShoulder:168,leftElbow:22,rightElbow:22,leftWrist:0,rightWrist:0},hands:{left:"flat",right:"flat"}},{beat:2,pose:{lean:10,rightHip:4,leftHip:22,leftShoulder:140,rightShoulder:140,leftElbow:0,rightElbow:0,leftWrist:20,rightWrist:20},hands:{left:"spread",right:"spread"},easing:J},{beat:3,pose:{lean:0,rightHip:10,leftHip:10,leftShoulder:168,rightShoulder:168,leftElbow:22,rightElbow:22,leftWrist:0,rightWrist:0},hands:{left:"flat",right:"flat"}}]}},routine:[{move:"point",beats:8},{move:"roll",beats:4},{move:"point",beats:8,mirror:!0},{move:"bump",beats:8}]},Md={label:"Hip hop",bpm:95,stance:{leftHip:14,rightHip:14,leftKnee:20,rightKnee:20,leftShoulder:22,rightShoulder:22,leftElbow:-30,rightElbow:-30,leftFootOut:.15,rightFootOut:.15},expression:"smug",hands:{left:"relaxed",right:"relaxed"},groove:{bounce:18,accent:"down"},moves:{bounce:{label:"Bounce",beats:2,keys:[{beat:0,pose:{leftShoulder:30,rightShoulder:30,leftElbow:-50,rightElbow:-50,lean:-3,headTilt:-5,leftWrist:-20,rightWrist:-20}},{beat:1,pose:{leftShoulder:14,rightShoulder:14,leftElbow:-18,rightElbow:-18,lean:3,headTilt:5,leftWrist:0,rightWrist:0}}]},runningMan:{label:"Running man",beats:2,keys:[{beat:0,reset:!0,pose:{turn:.85,leftHip:-84,leftKnee:-112,leftAnkle:25,rightHip:-26,rightKnee:8,leftShoulder:35,leftElbow:-50,rightShoulder:45,rightElbow:75,lean:6},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{leftHip:-4,leftKnee:-18,leftAnkle:0,rightHip:4,rightKnee:18,leftShoulder:5,leftElbow:-40,rightShoulder:5,rightElbow:40}},{beat:1,pose:{rightHip:84,rightKnee:112,rightAnkle:25,leftHip:26,leftKnee:-8,rightShoulder:-35,rightElbow:50,leftShoulder:-45,leftElbow:-75}},{beat:1.5,pose:{rightHip:4,rightKnee:18,rightAnkle:0,leftHip:-4,leftKnee:-18,rightShoulder:-5,rightElbow:40,leftShoulder:-5,leftElbow:-40}}]},armWave:{label:"Arm wave",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:90,rightShoulder:90,leftElbow:0,rightElbow:0},hands:{left:"flat",right:"flat"}},{beat:.5,pose:{leftWrist:45,leftElbow:-15}},{beat:1,pose:{leftWrist:-35,leftElbow:40,leftShoulder:84}},{beat:1.5,pose:{leftWrist:0,leftElbow:-10,leftShoulder:102,headTilt:-8}},{beat:2,pose:{leftElbow:0,leftShoulder:90,rightShoulder:102,headTilt:8}},{beat:2.5,pose:{rightShoulder:84,rightElbow:40,headTilt:0}},{beat:3,pose:{rightElbow:-15,rightWrist:45}},{beat:3.5,pose:{rightElbow:0,rightWrist:-35}}]}},routine:[{move:"bounce",beats:8},{move:"runningMan",beats:8},{move:"armWave",beats:8},{move:"bounce",beats:4}]},Td={label:"Breaking (toprock)",bpm:110,stance:{leftHip:14,rightHip:14,leftKnee:14,rightKnee:14,leftShoulder:35,rightShoulder:35,leftElbow:-90,rightElbow:-90},expression:{smile:.3,leftBrow:-.3,rightBrow:-.3,browTilt:-.3},hands:{left:"fist",right:"fist"},groove:{bounce:8,accent:"down"},moves:{toprock:{label:"Toprock (Indian step)",beats:4,keys:[{beat:0,pose:{rightHip:-24,rightKnee:10,leftHip:10,leftShoulder:80,leftElbow:40,rightShoulder:55,rightElbow:-50,lean:6,headTilt:-6},easing:J},{beat:1,reset:!0,pose:{leftHip:18,rightHip:18}},{beat:2,pose:{leftHip:-24,leftKnee:10,rightHip:10,rightShoulder:80,rightElbow:40,leftShoulder:55,leftElbow:-50,lean:-6,headTilt:6},easing:J},{beat:3,reset:!0,pose:{leftHip:18,rightHip:18}}]},kick:{label:"Kick out",beats:2,keys:[{beat:0,pose:{rightHip:72,rightKnee:4,rightAnkle:-20,leftHip:4,lean:-12,leftShoulder:100,leftElbow:20},easing:J},{beat:1,reset:!0}]},freeze:{label:"B-boy stance",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:26,leftElbow:-122,rightShoulder:22,rightElbow:-118,leftHip:18,rightHip:18,leftKnee:6,rightKnee:6,lean:-4,headTilt:10,smile:.6,leftEye:.6,rightEye:.6},easing:Re},{beat:2,pose:{headTilt:14,lean:-6}}]}},routine:[{move:"toprock",beats:8},{move:"kick",beats:4},{move:"toprock",beats:8},{move:"kick",beats:4,mirror:!0},{move:"freeze",beats:4}]},Ed={label:"Jazz",bpm:130,stance:{leftHip:10,rightHip:10},expression:{mouth:.55,smile:1,mouthWidth:1.2,leftBrow:.6,rightBrow:.6},hands:{left:"spread",right:"spread"},groove:{bounce:6,accent:"up"},moves:{jazzHands:{label:"Jazz hands",beats:2,easing:"linear",keys:[0,.25,.5,.75,1,1.25,1.5,1.75].map((e,t)=>({beat:e,pose:{leftShoulder:128,rightShoulder:128,leftElbow:8,rightElbow:8,leftWrist:t%2?4:26,rightWrist:t%2?26:4,leftHip:16,rightHip:16,leftKnee:e<1?26:8,rightKnee:e<1?26:8},hands:t===0?{left:{...q.spread,turn:2},right:{...q.spread,turn:2}}:void 0}))},kickBallChange:{label:"Kick ball change",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:88,rightKnee:0,rightAnkle:55,leftHip:4,lean:-12,leftShoulder:112,rightShoulder:112,leftWrist:15,rightWrist:15},hands:{left:"flat",right:"flat"},easing:J},{beat:1,reset:!0,pose:{rightHip:10,rightKnee:24,rightAnkle:45,leftShoulder:60,rightShoulder:60,leftElbow:-20,rightElbow:-20}},{beat:1.5,pose:{rightAnkle:0,rightKnee:6,leftAnkle:45,leftKnee:20}}]},splitDrop:{label:"Drop into the splits",beats:8,keys:[{beat:0,reset:!0},{beat:2,reset:!0,pose:{leftHip:90,rightHip:90,leftKnee:0,rightKnee:0,leftAnkle:-45,rightAnkle:-45,leftShoulder:125,rightShoulder:125,leftElbow:10,rightElbow:10},easing:"ease-in-out-cubic"},{beat:4,pose:{leftShoulder:95,rightShoulder:95,leftElbow:0,rightElbow:0,leftWrist:50,rightWrist:50,headTilt:8}},{beat:6,reset:!0,pose:{leftHip:30,rightHip:30,leftKnee:60,rightKnee:60,leftShoulder:40,rightShoulder:40},easing:"ease-in-out-cubic"},{beat:7.5,reset:!0}]},jazzSquare:{label:"Jazz square",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:-18,leftHip:8,leftShoulder:38,rightShoulder:46,leftElbow:100,rightElbow:96,lean:4},hands:{left:"pinch",right:"pinch"}},{beat:1,pose:{leftHip:18,rightHip:6,leftShoulder:46,rightShoulder:38,lean:-4}},{beat:2,pose:{rightHip:22,leftHip:6,leftShoulder:38,rightShoulder:46,lean:4}},{beat:3,pose:{leftHip:10,rightHip:10,leftShoulder:46,rightShoulder:38,lean:0}}]}},routine:[{move:"jazzHands",beats:4},{move:"kickBallChange",beats:4},{move:"kickBallChange",beats:4,mirror:!0},{move:"jazzSquare",beats:8},{move:"jazzHands",beats:4},{move:"splitDrop",beats:8}]},Ad={label:"K-pop",bpm:125,stance:{leftHip:9,rightHip:9,leftKnee:4,rightKnee:4},expression:"happy",groove:{bounce:5,accent:"down"},moves:{pointCombo:{label:"Point combo",beats:4,easing:Re,keys:[{beat:0,reset:!0,pose:{rightShoulder:142,rightElbow:0,leftShoulder:25,leftElbow:-125,headTilt:6,lean:-3,lookX:.6,lookY:-.6},hands:{right:"point",left:"flat"}},{beat:1,pose:{rightShoulder:-38,headTilt:-6,lean:3,lookX:-.3,lookY:.5,rightHip:18}},{beat:2,reset:!0,pose:{leftShoulder:36,leftElbow:-96,rightShoulder:36,rightElbow:-96,leftWrist:20,rightWrist:20},hands:{left:"fist",right:"fist"}},{beat:3,reset:!0,pose:{leftShoulder:96,rightShoulder:96,leftElbow:0,rightElbow:0,leftWrist:50,rightWrist:50,headTilt:8,leftHip:18,rightHip:18},hands:{left:"flat",right:"flat"}}]},heart:{label:"Big heart, finger heart",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:165,rightShoulder:165,leftElbow:46,rightElbow:46,headTilt:-8,lean:-4},hands:{left:"cupped",right:"cupped"},easing:Re},{beat:1,pose:{headTilt:8,lean:4}},{beat:2,reset:!0,pose:{rightShoulder:32,rightElbow:112,rightWrist:10,leftShoulder:20,leftElbow:-30,headTilt:10,leftEye:0,smile:1},hands:{right:"pinch",left:"relaxed"},easing:Re},{beat:3,pose:{headTilt:4}}]},isolations:{label:"Isolations",beats:2,easing:J,keys:[{beat:0,reset:!0,pose:{lean:-9,headTilt:11,leftShoulder:55,leftElbow:-112,rightShoulder:55,rightElbow:-112,rightHip:18},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{lean:0,headTilt:0,rightHip:9}},{beat:1,pose:{lean:9,headTilt:-11,leftHip:18}},{beat:1.5,pose:{lean:0,headTilt:0,leftHip:9}}]}},routine:[{move:"pointCombo",beats:8},{move:"isolations",beats:4},{move:"heart",beats:8},{move:"pointCombo",beats:8,mirror:!0},{move:"isolations",beats:4}]},xd={label:"Bollywood",bpm:120,stance:{leftHip:10,rightHip:10},expression:{smile:1,mouth:.3,leftBrow:.4,rightBrow:.4},groove:{bounce:8,accent:"down",sway:3},moves:{lightBulb:{label:"Screw the bulb, pat the dog",beats:2,keys:[{beat:0,reset:!0,pose:{rightShoulder:160,rightElbow:12,rightWrist:-15,leftShoulder:40,leftElbow:-12,leftWrist:-45,lean:-4,rightHip:16,lookX:.5,lookY:-.6},hands:{right:{...q.cupped,roll:-30},left:{...q.flat,turn:0}}},{beat:.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...q.cupped,roll:30}}},{beat:1,pose:{rightWrist:-15,rightElbow:12,leftWrist:-45,lean:-4,rightHip:16,leftHip:6},hands:{right:{...q.cupped,roll:-30}}},{beat:1.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...q.cupped,roll:30}}}]},thumka:{label:"Thumka",beats:2,keys:[{beat:0,reset:!0,pose:{lean:-11,rightHip:22,leftHip:2,leftKnee:14,rightShoulder:45,rightElbow:-105,leftShoulder:128,leftElbow:18,leftWrist:35,headTilt:10,lookX:-.5},hands:{right:"fist",left:{...q.open,turn:2}},easing:J},{beat:.5,pose:{lean:-4,rightHip:12,headTilt:6}},{beat:1,pose:{lean:-11,rightHip:22,headTilt:10},easing:J},{beat:1.5,pose:{lean:-4,rightHip:12,headTilt:6}}]},flick:{label:"Cross and flick",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:22,rightShoulder:22,leftElbow:-62,rightElbow:-62,leftHip:16,rightHip:16,leftKnee:26,rightKnee:26},hands:{left:"fist",right:"fist"}},{beat:1,pose:{leftShoulder:132,rightShoulder:132,leftElbow:0,rightElbow:0,leftWrist:30,rightWrist:30,leftKnee:0,rightKnee:0,leftHip:10,rightHip:10,stretch:1.03},hands:{left:"spread",right:"spread"},easing:J},{beat:2,pose:{leftShoulder:22,rightShoulder:22,leftElbow:-62,rightElbow:-62,leftWrist:0,rightWrist:0,leftHip:16,rightHip:16,leftKnee:26,rightKnee:26,stretch:1},hands:{left:"fist",right:"fist"}},{beat:3,pose:{leftShoulder:62,rightShoulder:62,leftElbow:0,rightElbow:0,leftWrist:35,rightWrist:35,leftKnee:0,rightKnee:0,leftHip:10,rightHip:10},hands:{left:"spread",right:"spread"},easing:J}]}},routine:[{move:"thumka",beats:4},{move:"lightBulb",beats:8},{move:"flick",beats:8},{move:"thumka",beats:4,mirror:!0},{move:"lightBulb",beats:8,mirror:!0}]},Pd={label:"Bhangra",bpm:100,stance:{leftShoulder:150,rightShoulder:150,leftElbow:18,rightElbow:18,leftHip:10,rightHip:10},expression:{mouth:.6,smile:1,mouthWidth:1.2,leftBrow:.5,rightBrow:.5},hands:{left:"open",right:"open"},groove:{bounce:12,accent:"down"},moves:{basic:{label:"Bhangra step",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:58,rightKnee:104,rightAnkle:30,leftShoulder:162,rightShoulder:140,headTilt:7}},{beat:.5,reset:!0,pose:{stretch:.98}},{beat:1,reset:!0,pose:{leftHip:58,leftKnee:104,leftAnkle:30,rightShoulder:162,leftShoulder:140,headTilt:-7}},{beat:1.5,reset:!0,pose:{stretch:.98}}]},dhamaal:{label:"Dhamaal (jump, arms up)",beats:2,keys:[{beat:0,reset:!0,pose:{leftHip:20,rightHip:20,leftKnee:40,rightKnee:40,stretch:.94}},{beat:.5,reset:!0,pose:{rise:.07,stretch:1.06,leftHip:6,rightHip:6,leftAnkle:45,rightAnkle:45,leftShoulder:172,rightShoulder:172,leftElbow:0,rightElbow:0},hands:{left:"point",right:"point"},easing:"ease-out-quad"},{beat:1,reset:!0,pose:{leftHip:20,rightHip:20,leftKnee:40,rightKnee:40,stretch:.94},hands:{left:"open",right:"open"},easing:"ease-in-quad"},{beat:1.5,reset:!0,pose:{rise:.07,stretch:1.06,leftHip:6,rightHip:6,leftAnkle:45,rightAnkle:45,leftShoulder:172,rightShoulder:172,leftElbow:0,rightElbow:0},hands:{left:"point",right:"point"},easing:"ease-out-quad"}]}},routine:[{move:"basic",beats:8},{move:"dhamaal",beats:4},{move:"basic",beats:8},{move:"dhamaal",beats:4}]},_d={label:"Bharatanatyam",bpm:80,stance:{...{leftHip:42,rightHip:42,leftKnee:82,rightKnee:82,leftFootOut:.3,rightFootOut:.3},leftShoulder:90,rightShoulder:90,leftElbow:0,rightElbow:0,leftWrist:75,rightWrist:75},expression:{smile:.5,leftEye:1.2,rightEye:1.2,leftBrow:.3,rightBrow:.3},hands:{left:"pataka",right:"pataka"},groove:{bounce:0},moves:{tatta:{label:"Tatta adavu (stamps)",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:48,rightKnee:104,rightAnkle:-18}},{beat:.3,reset:!0,easing:"ease-in-quad",taps:["rightToe","rightHeel"]},{beat:1,reset:!0,pose:{leftHip:48,leftKnee:104,leftAnkle:-18}},{beat:1.3,reset:!0,easing:"ease-in-quad",taps:["leftToe","leftHeel"]}]},natta:{label:"Natta adavu (stretch and look)",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:52,rightKnee:0,rightAnkle:-40,rightShoulder:125,rightWrist:60,leftShoulder:25,leftElbow:-125,leftWrist:0,headTilt:8,lookX:.9,lookY:-.4,lean:-6}},{beat:1,reset:!0},{beat:2,reset:!0,pose:{leftHip:52,leftKnee:0,leftAnkle:-40,leftShoulder:125,leftWrist:60,rightShoulder:25,rightElbow:-125,rightWrist:0,headTilt:-8,lookX:-.9,lookY:-.4,lean:6}},{beat:3,reset:!0}]},alapadma:{label:"Alapadma (lotus) to the sky",beats:4,keys:[{beat:0,reset:!0,pose:{rightShoulder:145,rightElbow:20,rightWrist:30,leftShoulder:28,leftElbow:-125,leftWrist:0,lookX:.7,lookY:-.9,headTilt:6},hands:{right:"alapadma",left:"pataka"}},{beat:1,pose:{rightWrist:55,headTilt:9}},{beat:2,reset:!0,pose:{leftShoulder:145,leftElbow:20,leftWrist:30,rightShoulder:28,rightElbow:-125,rightWrist:0,lookX:-.7,lookY:-.9,headTilt:-6},hands:{left:"alapadma",right:"pataka"}},{beat:3,pose:{leftWrist:55,headTilt:-9}}]}},routine:[{move:"tatta",beats:8},{move:"natta",beats:8},{move:"alapadma",beats:8},{move:"tatta",beats:4}]},Id={label:"Charleston",bpm:150,stance:{leftHip:10,rightHip:10,leftKnee:10,rightKnee:10,leftShoulder:30,rightShoulder:30,leftElbow:20,rightElbow:20},expression:{mouth:.4,smile:1,leftBrow:.5,rightBrow:.5},hands:{left:{...q.spread,turn:2},right:{...q.spread,turn:2}},groove:{bounce:8,accent:"down"},moves:{basic:{label:"Kick forward, kick back",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:48,rightKnee:8,rightAnkle:45,leftShoulder:75,rightShoulder:15,leftElbow:30,rightElbow:-10,lean:-7,headTilt:-5},easing:J},{beat:1,reset:!0},{beat:2,reset:!0,pose:{leftHip:18,leftKnee:85,leftAnkle:35,rightShoulder:75,leftShoulder:15,rightElbow:30,leftElbow:-10,lean:7,headTilt:5},easing:J},{beat:3,reset:!0}]},twist:{label:"Swivel (heels in, heels out)",beats:2,keys:[{beat:0,reset:!0,pose:{leftFootOut:-.9,rightFootOut:-.9,leftHip:4,rightHip:4,leftKnee:4,rightKnee:4,leftAnkle:-10,rightAnkle:-10,leftShoulder:18,rightShoulder:48,leftElbow:-10,rightElbow:50}},{beat:.5,pose:{leftFootOut:.6,rightFootOut:.6,leftHip:16,rightHip:16,leftKnee:22,rightKnee:22,leftAnkle:10,rightAnkle:10,leftShoulder:48,rightShoulder:18,leftElbow:50,rightElbow:-10}},{beat:1,pose:{leftFootOut:-.9,rightFootOut:-.9,leftHip:4,rightHip:4,leftKnee:4,rightKnee:4,leftAnkle:-10,rightAnkle:-10,leftShoulder:18,rightShoulder:48,leftElbow:-10,rightElbow:50}},{beat:1.5,pose:{leftFootOut:.6,rightFootOut:.6,leftHip:16,rightHip:16,leftKnee:22,rightKnee:22,leftAnkle:10,rightAnkle:10,leftShoulder:48,rightShoulder:18,leftElbow:50,rightElbow:-10}}]},kneeCross:{label:"Crossing knees",beats:2,keys:[{beat:0,reset:!0,pose:{leftHip:-6,rightHip:-6,leftKnee:-16,rightKnee:-16,leftFootOut:-.4,rightFootOut:-.4,leftShoulder:-12,rightShoulder:-12,leftElbow:0,rightElbow:0,lean:0,lookY:.6}},{beat:.5,pose:{leftHip:18,rightHip:18,leftKnee:28,rightKnee:28,leftFootOut:.3,rightFootOut:.3,leftShoulder:16,rightShoulder:16,lookY:0}},{beat:1,pose:{leftHip:-6,rightHip:-6,leftKnee:-16,rightKnee:-16,leftFootOut:-.4,rightFootOut:-.4,leftShoulder:-12,rightShoulder:-12,lookY:.6}},{beat:1.5,pose:{leftHip:18,rightHip:18,leftKnee:28,rightKnee:28,leftFootOut:.3,rightFootOut:.3,leftShoulder:16,rightShoulder:16,lookY:0}}]}},routine:[{move:"basic",beats:8},{move:"twist",beats:8},{move:"kneeCross",beats:8},{move:"basic",beats:8,mirror:!0},{move:"twist",beats:4}]},Cd={label:"Tap",bpm:120,stance:{turn:.8,leftHip:-3,rightHip:3,leftKnee:-10,rightKnee:10,leftShoulder:12,rightShoulder:12,leftElbow:-40,rightElbow:40,leftWrist:-15,rightWrist:15,lean:4},expression:{smile:.9,mouth:.2,leftBrow:.3,rightBrow:.3,lookY:.3},hands:{left:"relaxed",right:"relaxed"},groove:{bounce:6,accent:"down"},moves:{shuffleBallChange:{label:"Shuffle ball change",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:34,rightKnee:8,rightAnkle:30,leftShoulder:30,rightShoulder:-10},taps:["rightToe"]},{beat:.25,pose:{rightHip:24,rightKnee:62,rightAnkle:40},taps:["rightToe"]},{beat:.5,pose:{rightHip:-8,rightKnee:14,rightAnkle:50,leftAnkle:15,leftShoulder:12,rightShoulder:12},taps:["rightToe"]},{beat:.75,pose:{rightHip:3,rightKnee:10,rightAnkle:0,leftAnkle:0},taps:["leftHeel"]},{beat:1,reset:!0,pose:{leftHip:-34,leftKnee:-8,leftAnkle:30,rightShoulder:-30,leftShoulder:10},taps:["leftToe"]},{beat:1.25,pose:{leftHip:-24,leftKnee:-62,leftAnkle:40},taps:["leftToe"]},{beat:1.5,pose:{leftHip:8,leftKnee:-14,leftAnkle:50,rightAnkle:15,leftShoulder:12,rightShoulder:12},taps:["leftToe"]},{beat:1.75,pose:{leftHip:-3,leftKnee:-10,leftAnkle:0,rightAnkle:0},taps:["rightHeel"]}]},timeStep:{label:"Single time step",beats:4,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:8,rightKnee:4,rightAnkle:0,leftShoulder:25,rightShoulder:-20},taps:["rightToe","rightHeel"]},{beat:.5,pose:{rightHip:34,rightKnee:8,rightAnkle:30},taps:["rightToe"]},{beat:.75,pose:{rightHip:22,rightKnee:62,rightAnkle:40},taps:["rightToe"]},{beat:1,pose:{rise:.05,leftAnkle:45,leftKnee:-4,leftHip:-2,rightHip:26,rightKnee:70,stretch:1.03}},{beat:1.25,pose:{rise:0,leftAnkle:0,leftKnee:-14,stretch:1},taps:["leftToe"]},{beat:1.5,pose:{rightHip:4,rightKnee:12,rightAnkle:0,rightShoulder:25,leftShoulder:-20},taps:["rightToe"]},{beat:2,pose:{leftHip:-30,leftKnee:-6,leftAnkle:35},taps:["leftToe"]},{beat:2.25,pose:{leftHip:-4,leftKnee:-12,leftAnkle:0},taps:["leftToe"]},{beat:3,pose:{rightHip:10,rightAnkle:35,rightKnee:18,leftShoulder:12,rightShoulder:12},taps:["rightToe"]},{beat:3.5,pose:{rightHip:3,rightKnee:10,rightAnkle:0}}]},heelToe:{label:"Heel toe",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:26,rightKnee:0,rightAnkle:-35,leftShoulder:30,rightShoulder:-20},taps:["rightHeel"]},{beat:.5,pose:{rightHip:-16,rightKnee:24,rightAnkle:55,leftShoulder:-15,rightShoulder:25},taps:["rightToe"]},{beat:1,reset:!0,pose:{leftHip:-26,leftKnee:0,leftAnkle:-35,rightShoulder:-30,leftShoulder:20},taps:["leftHeel"]},{beat:1.5,pose:{leftHip:16,leftKnee:-24,leftAnkle:55,rightShoulder:15,leftShoulder:-25},taps:["leftToe"]}]},crampRoll:{label:"Cramp roll",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:12,rightKnee:26,leftHip:-12,leftKnee:-26}},{beat:.5,pose:{rightAnkle:40,rise:.02},taps:["rightToe"]},{beat:.625,pose:{leftAnkle:40},taps:["leftToe"]},{beat:.75,pose:{rightAnkle:0,rise:0},taps:["rightHeel"]},{beat:.875,pose:{leftAnkle:0},taps:["leftHeel"]},{beat:1,pose:{rightShoulder:135,leftShoulder:125,leftElbow:0,rightElbow:0,leftWrist:0,rightWrist:30,rightKnee:8,leftKnee:-8,rightHip:4,leftHip:-4},hands:{left:{...q.spread,turn:2},right:{...q.spread,turn:2}}},{beat:1.75,reset:!0}]}},routine:[{move:"shuffleBallChange",beats:8},{move:"timeStep",beats:4},{move:"timeStep",beats:4,mirror:!0},{move:"heelToe",beats:8},{move:"crampRoll",beats:4}]},$t={disco:Sd,hipHop:Md,breaking:Td,jazz:Ed,kpop:Ad,bollywood:xd,bhangra:Pd,bharatanatyam:_d,charleston:Id,tap:Cd,popping:{label:"Popping (glides, moonwalk)",bpm:100,stance:{leftHip:9,rightHip:9,leftShoulder:16,rightShoulder:16,leftElbow:-24,rightElbow:-24},expression:{smile:.35,leftEye:.85,rightEye:.85,leftBrow:-.2,rightBrow:-.2},hands:{left:"relaxed",right:"relaxed"},groove:{bounce:0},moves:{sideGlide:{label:"Side glide",beats:2,easing:"linear",travel:.2,keys:[{beat:0,reset:!0,pose:{leftHip:11,leftKnee:0,leftAnkle:0,rightHip:36,rightKnee:45,rightAnkle:45,rightShoulder:80,rightElbow:-10,rightWrist:10,leftShoulder:28,leftElbow:18,lean:-2,headTilt:4,lookX:.7},hands:{right:"flat",left:"relaxed"}},{beat:1,pose:{leftHip:27,leftKnee:54,leftAnkle:45,rightHip:-1,rightKnee:0,rightAnkle:0,rightShoulder:74,rightWrist:-10,lean:2}}]},moonwalk:{label:"Moonwalk",beats:2,easing:"linear",travel:-.29,keys:[{beat:0,reset:!0,pose:{turn:.9,lean:4,headTilt:-4,leftHip:-12,leftKnee:0,leftAnkle:0,rightHip:23,rightKnee:57,rightAnkle:45,leftShoulder:-10,leftElbow:-45,rightShoulder:14,rightElbow:50}},{beat:1,pose:{leftHip:-23,leftKnee:-57,leftAnkle:45,rightHip:12,rightKnee:0,rightAnkle:0,leftShoulder:-14,leftElbow:-50,rightShoulder:10,rightElbow:45}}]},forwardGlide:{label:"Forward glide",beats:2,easing:"linear",travel:.29,keys:[{beat:0,reset:!0,pose:{turn:.9,lean:2,leftHip:16,leftKnee:0,leftAnkle:0,rightHip:33,rightKnee:59,rightAnkle:45,leftShoulder:12,leftElbow:-40,rightShoulder:-12,rightElbow:40}},{beat:1,pose:{leftHip:-33,leftKnee:-59,leftAnkle:45,rightHip:-16,rightKnee:0,rightAnkle:0,leftShoulder:-12,leftElbow:-40,rightShoulder:12,rightElbow:40}}]},toeStand:{label:"Toe stand",beats:4,keys:[{beat:0,reset:!0,pose:{leftHip:6,rightHip:6,leftKnee:0,rightKnee:0,leftAnkle:65,rightAnkle:65,rightShoulder:150,rightElbow:75,leftShoulder:30,leftElbow:20,headTilt:-10,lookY:.4},hands:{right:"fist",left:"fist"},easing:Re},{beat:2,pose:{headTilt:-14,lean:-2}}]}},routine:[{move:"sideGlide",beats:4},{move:"sideGlide",beats:4,mirror:!0},{move:"moonwalk",beats:8},{move:"forwardGlide",beats:8},{move:"toeStand",beats:4}]}},An=e=>Math.min(1,Math.max(0,e));function Hd(e){const t={...N,turn:e.view},n=[];for(const i of e.keys){const s=n[n.length-1],r=!s||i.reset?t:s.pose;n.push({at:i.at,pose:{...r,...i.pose},easing:i.easing})}return n}function $d(e){return e-Od*Math.sin(2*Math.PI*e)/(2*Math.PI)}const Od=.5;function Rd(e,t){if(!(t<=e.takeoff||t>=e.landing))return(t-e.takeoff)/(e.landing-e.takeoff)}function Ba(e,t){const n=typeof e=="string"?Pn[e]:e,i=Hd(n),s=An(t);let r=0;for(let u=0;u<i.length;u++)i[u].at<=s&&(r=u);const o=i[r],a=i[Math.min(r+1,i.length-1)],l=a.at>o.at?(s-o.at)/(a.at-o.at):0,c=ne(o.pose,a.pose,G(a.easing??"ease-in-out")(An(l))),h=Rd(n,s);return h===void 0?{...c,spin:0,rise:0}:{...c,spin:n.spin*$d(h),rise:4*n.height*h*(1-h)}}function Na(e,t,n){const i=typeof e=="string"?Pn[e]:e,s=An(t),r=An((s-i.takeoff)/(i.landing-i.takeoff));return i.travel*n*r}function Ld(e,t,n={}){const i=typeof t=="string"?Pn[t]:t,s=n.start??0,r=n.duration??i.duration,o=n.samples??48,a=Array.from({length:o+1},(h,u)=>{const f=u/o;return{time:s+f*r,progress:f,pose:Ba(i,f)}}),c=Object.keys(N).filter(h=>a.some(u=>u.pose[h]!==N[h])).map(h=>({id:`${e}-${h}`,target:e,property:h,keyframes:a.map(u=>({time:u.time,value:u.pose[h]}))}));if(n.height!==void 0&&i.travel!==0){const h=(n.facing??1)<0?-1:1;c.push({id:`${e}-x`,target:e,property:"x",keyframes:a.map(u=>({time:u.time,value:(n.x??0)+h*Na(i,u.progress,n.height)}))})}return c}const Fd={leftHip:-55,leftKnee:-95,rightHip:55,rightKnee:95,leftShoulder:45,rightShoulder:-45,leftElbow:10,rightElbow:-10,lean:22,stretch:.94,headTilt:6},Dd={leftHip:0,leftKnee:0,rightHip:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:-172,rightShoulder:172,leftElbow:0,rightElbow:0,lean:0,stretch:1.08,headTilt:0},xn={leftHip:-128,leftKnee:-152,rightHip:128,rightKnee:152,leftAnkle:30,rightAnkle:30,leftShoulder:-78,rightShoulder:78,leftElbow:-48,rightElbow:48,lean:26,stretch:1,headTilt:14},Bd={leftHip:-22,leftKnee:-30,rightHip:22,rightKnee:30,leftAnkle:10,rightAnkle:10,leftShoulder:-125,rightShoulder:125,leftElbow:0,rightElbow:0,lean:8,headTilt:0},Nd={leftHip:-58,leftKnee:-100,rightHip:58,rightKnee:100,leftAnkle:0,rightAnkle:0,leftShoulder:-80,rightShoulder:80,leftElbow:-10,rightElbow:10,lean:20,stretch:.93};function ie(e,t,n,i,s,r=1300){return{label:e,view:1,spin:t,height:n,travel:i,takeoff:.27,landing:.8,duration:r,keys:[{at:0,reset:!0},{at:.16,pose:Fd},{at:.27,pose:Dd,easing:"ease-out-quad"},...s,{at:.76,pose:Bd},{at:.86,pose:Nd,easing:"ease-out-quad"},{at:1,reset:!0}]}}const Pn={frontFlip:ie("Front flip (tuck)",360,.56,.35,[{at:.38,pose:xn,easing:"ease-out-cubic"},{at:.64,pose:xn}]),backFlip:ie("Back flip (tuck)",-360,.58,-.15,[{at:.36,pose:{...xn,lean:18},easing:"ease-out-cubic"},{at:.64,pose:{...xn,lean:18}}]),layout:ie("Back layout (straight body)",-360,.66,-.2,[{at:.4,pose:{leftHip:8,rightHip:-8,leftKnee:0,rightKnee:0,leftAnkle:60,rightAnkle:60,leftShoulder:-178,rightShoulder:178,lean:-18,headTilt:-14}},{at:.64,pose:{leftHip:-4,rightHip:4,lean:-6,headTilt:-4,leftShoulder:-150,rightShoulder:150}}],1400),scissorFlip:ie("Scissor flip",360,.6,.45,[{at:.36,pose:{leftHip:-105,leftKnee:0,rightHip:-40,rightKnee:-20,leftAnkle:50,rightAnkle:50,leftShoulder:-150,rightShoulder:150,leftElbow:0,rightElbow:0,lean:12},easing:"ease-out-cubic"},{at:.52,pose:{leftHip:40,leftKnee:20,rightHip:105,rightKnee:0,leftShoulder:-140,rightShoulder:140}},{at:.66,pose:{leftHip:-30,leftKnee:-20,rightHip:30,rightKnee:20,leftShoulder:-110,rightShoulder:110,lean:6}}]),sideFlip:{label:"Side flip (tuck)",view:0,spin:360,height:.55,travel:.4,takeoff:.27,landing:.8,duration:1300,keys:[{at:0,reset:!0},{at:.16,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftShoulder:20,rightShoulder:20,lean:-10,stretch:.94}},{at:.27,pose:{leftHip:4,rightHip:4,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:165,rightShoulder:165,lean:6,stretch:1.08},easing:"ease-out-quad"},{at:.38,pose:{leftHip:105,rightHip:105,leftKnee:135,rightKnee:135,leftShoulder:40,rightShoulder:40,leftElbow:-95,rightElbow:-95,lean:0,stretch:1,headTilt:10},easing:"ease-out-cubic"},{at:.64,pose:{}},{at:.76,pose:{leftHip:20,rightHip:20,leftKnee:20,rightKnee:20,leftAnkle:10,rightAnkle:10,leftShoulder:100,rightShoulder:100,leftElbow:0,rightElbow:0,headTilt:0}},{at:.86,pose:{leftHip:24,rightHip:24,leftKnee:48,rightKnee:48,leftAnkle:0,rightAnkle:0,leftShoulder:70,rightShoulder:70,stretch:.93},easing:"ease-out-quad"},{at:1,reset:!0}]},cartwheel:{label:"Cartwheel",view:0,spin:360,height:.155,travel:.9,takeoff:.2,landing:.86,duration:1600,keys:[{at:0,reset:!0},{at:.12,pose:{leftShoulder:165,rightShoulder:165,rightHip:30,rightKnee:0,lean:-6}},{at:.24,pose:{leftShoulder:172,rightShoulder:172,leftHip:55,rightHip:55,leftKnee:0,rightKnee:0,leftAnkle:40,rightAnkle:40,lean:0}},{at:.75,pose:{}},{at:.9,pose:{leftHip:30,rightHip:12,leftAnkle:0,rightAnkle:0,leftShoulder:150,rightShoulder:150}},{at:1,reset:!0}]},splitLeap:ie("Split leap (grand jeté)",0,.36,.9,[{at:.4,pose:{leftHip:-96,rightHip:-84,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:-130,rightShoulder:-105,leftElbow:0,rightElbow:0,lean:4,headTilt:-6},easing:"ease-out-cubic"},{at:.64,pose:{lean:2}}]),toeTouch:{label:"Toe touch (straddle jump)",view:0,spin:0,height:.36,travel:0,takeoff:.27,landing:.8,duration:1200,keys:[{at:0,reset:!0},{at:.16,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftShoulder:-20,rightShoulder:-20,stretch:.94}},{at:.27,pose:{leftHip:4,rightHip:4,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:170,rightShoulder:170,stretch:1.06},easing:"ease-out-quad"},{at:.42,pose:{leftHip:104,rightHip:104,leftShoulder:96,rightShoulder:96,leftElbow:0,rightElbow:0,stretch:1,headTilt:0},easing:"ease-out-cubic"},{at:.62,pose:{}},{at:.76,pose:{leftHip:12,rightHip:12,leftAnkle:10,rightAnkle:10,leftShoulder:120,rightShoulder:120}},{at:.86,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftAnkle:0,rightAnkle:0,leftShoulder:60,rightShoulder:60,stretch:.94},easing:"ease-out-quad"},{at:1,reset:!0}]},backHandspring:ie("Back handspring",-360,.16,-.7,[{at:.38,pose:{leftHip:10,rightHip:-10,leftKnee:0,rightKnee:0,leftShoulder:-178,rightShoulder:178,lean:-26,headTilt:-20}},{at:.6,pose:{leftHip:-40,rightHip:40,leftKnee:-20,rightKnee:20,lean:6,headTilt:0}}],1200)},es=.215,ns=.205,Wd=.065,Wa=.035,Kd=.165,Yd=.155,Xd=12,qd=e=>e*Math.PI/180,z={turn:0,lean:0,side:0,"head.turn":0,"head.nod":0,"head.tilt":0,"arm.left.swing":0,"arm.left.spread":12,"arm.left.elbow":8,"arm.left.bend":0,"arm.right.swing":0,"arm.right.spread":12,"arm.right.elbow":8,"arm.right.bend":0,"leg.left.swing":0,"leg.left.spread":3,"leg.left.knee":0,"leg.left.ankle":0,"leg.left.toeOut":0,"leg.left.rotate":0,"leg.right.swing":0,"leg.right.spread":3,"leg.right.knee":0,"leg.right.ankle":0,"leg.right.toeOut":0,"leg.right.rotate":0,stretch:1,lift:0,roll:0,mouth:0,smile:.5,mouthWidth:1,blink:0,"eye.left":1,"eye.right":1,"brow.left":0,"brow.right":0,browTilt:0,lookX:0,lookY:0};function it(e={}){return{...z,...e}}const Vd=new Set(["turn","side","head.turn","head.tilt","roll","lookX"]);function Ud(e){const t={};for(const[n,i]of Object.entries(e)){const s=n.replace(/(^|\.)(left|right)(\.|$)/,(r,o,a,l)=>`${o}${a==="left"?"right":"left"}${l}`);t[s]=Vd.has(n)?-i:i}return t}function st(e,t){const n={};for(const i of["left","right"])for(const[s,r]of Object.entries(t))n[`${e}.${i}.${s}`]=r;return n}const Ka={rest:z,wave:it({"arm.right.spread":115,"arm.right.bend":55,"arm.right.elbow":0,"head.tilt":-6,smile:.9}),cheer:it({...st("arm",{spread:140,bend:20,elbow:0}),mouth:.6,smile:1,"eye.left":0,"eye.right":0}),point:it({"arm.right.spread":88,"arm.right.elbow":0,"arm.right.bend":0,"head.turn":-20,smile:.4}),handsOnHips:it({...st("arm",{spread:50,bend:-105,elbow:0}),...st("leg",{spread:9}),smile:.8}),think:it({"arm.right.spread":22,"arm.right.bend":-150,"arm.right.elbow":0,"head.tilt":10,lookX:-.5,lookY:-.8,smile:0}),shrug:it({...st("arm",{spread:35,bend:75,elbow:0}),"head.tilt":-10,smile:-.2}),sit:it({...st("leg",{swing:90,knee:90,spread:4}),...st("arm",{swing:25,elbow:45,spread:8})}),kneel:it({"leg.left.swing":90,"leg.left.knee":90,"leg.right.swing":-18,"leg.right.knee":108,"leg.right.ankle":16,...st("arm",{swing:20,elbow:30})}),crouch:it({...st("leg",{swing:75,knee:140,spread:6}),lean:25,...st("arm",{swing:50,elbow:40}),"head.nod":-15}),crawl:it({lean:82,"head.nod":-35,...st("arm",{swing:80,elbow:0,spread:4}),...st("leg",{knee:92,ankle:-88})}),lieDown:it({roll:90,...st("arm",{spread:8}),"head.nod":0})};function Ya(e={}){const t=e.headSize??.3,n=e.shoulderWidth??.06,i=e.hipWidth??.022,s=Math.max(.12,1-t-Wa-(es+ns)),r=l=>({id:`arm.${l}`,parent:"spine",offset:[(l==="left"?1:-1)*n,-.035,0],rest:[0,-1,0],side:l==="left"?1:-1,bones:[{length:Kd,width:[1.25,.9]},{length:Yd,width:[.9,.75]}]}),o=l=>({id:`leg.${l}`,parent:null,offset:[(l==="left"?1:-1)*i,0,0],rest:[0,-1,0],side:l==="left"?1:-1,bones:[{length:es,width:[1.45,1.05]},{length:ns,width:[1.05,.85]},{length:Wd,width:[.95,.7]}]}),a=(l,c)=>l[c]??z[c]??0;return{id:"human",hipHeight:es+ns,chains:[o("left"),o("right"),{id:"spine",parent:null,rest:[0,1,0],bones:[{length:s/2,width:[1.7,1.4]},{length:s/2,width:[1.4,1.1]}]},{id:"neck",parent:"spine",rest:[0,1,0],bones:[{length:Wa,width:[1,.9]}]},r("left"),r("right")],head:{on:"neck",size:t},contacts:[...["left","right"].flatMap(l=>[{chain:`leg.${l}`,joint:1},{chain:`leg.${l}`,joint:2},{chain:`leg.${l}`,joint:3},{chain:`arm.${l}`,joint:1},{chain:`arm.${l}`,joint:2}]),{chain:"spine",joint:0},{chain:"spine",joint:1},{chain:"spine",joint:2},{head:"top"}],angles(l,c){if(c.id==="spine"){const p=-a(l,"lean")/2,g=a(l,"side")/2;return[{swing:p,spread:g},{swing:p,spread:g}]}if(c.id==="neck")return[{swing:0,spread:0}];const[h,u]=c.id.split("."),f=p=>a(l,`${h}.${u}.${p}`);if(h==="arm")return[{swing:f("swing"),spread:f("spread")},{swing:f("elbow"),spread:f("bend")}];const d=(c.side??1)*f("rotate"),m=1-Math.cos(qd(f("rotate")));return[{swing:f("swing"),spread:f("spread"),yaw:d},{swing:-f("knee"),spread:0,yaw:d},{swing:90+f("ankle")-m*(f("swing")-f("knee")),spread:0,yaw:(Xd+f("toeOut"))*(c.side??1)}]},withAngles(l,c,h){const[u,f]=c.id.split("."),d=m=>`${u}.${f}.${m}`;return u==="arm"?{...l,[d("swing")]:h[0].swing,[d("spread")]:h[0].spread,[d("elbow")]:h[1].swing,[d("bend")]:h[1].spread}:u==="leg"?{...l,[d("swing")]:h[0].swing,[d("spread")]:h[0].spread,[d("knee")]:-h[1].swing}:l},boneScale(l,c){const h=Math.min(3,Math.max(.3,a(l,"stretch")));return c?.id.startsWith("arm.")?Math.sqrt(h):h},headPose(l){const c=Math.min(3,Math.max(.3,a(l,"stretch")));return{yaw:a(l,"head.turn"),nod:a(l,"head.nod"),tilt:a(l,"head.tilt"),sx:1/Math.sqrt(c),sy:Math.sqrt(c)}},landmarks:{neck:["neck",0],"shoulder.left":["arm.left",0],"elbow.left":["arm.left",1],"hand.left":["arm.left",2],"shoulder.right":["arm.right",0],"elbow.right":["arm.right",1],"hand.right":["arm.right",2],"hip.left":["leg.left",0],"knee.left":["leg.left",1],"ankle.left":["leg.left",2],"toe.left":["leg.left",3],"hip.right":["leg.right",0],"knee.right":["leg.right",1],"ankle.right":["leg.right",2],"toe.right":["leg.right",3]}}}function zd(e){const t=e.split(".");if(t[0]==="hand"&&t.length>=3){const i=`${t[1]==="left"?"Left":"Right"} hand`,s={spread:"finger spread",turn:"wrist turn",bend:"wrist bend",tilt:"wrist tilt",roll:"roll"},r=t.slice(2).join(".");return`${i} · ${s[r]??r.replace(".curl"," curl").replace(".across"," across")}`}if(t.length===3){const[i,s,r]=t;return`${`${s==="left"?"Left":"Right"} ${i}`} · ${{swing:"forward / back",spread:"out / in",elbow:"elbow bend",bend:"forearm out / in",knee:"knee bend",ankle:"foot tilt",toeOut:"toes out / in",rotate:"turn out at the hip"}[r]??r}`}return{turn:"View (front → side → back)",lean:"Lean forward / back",side:"Lean sideways","head.turn":"Head · turn","head.nod":"Head · nod","head.tilt":"Head · tilt",stretch:"Squash / stretch",lift:"Lift off the ground",roll:"Roll (whole figure)",mouth:"Mouth open",smile:"Smile",mouthWidth:"Mouth width",blink:"Blink","eye.left":"Left eye open","eye.right":"Right eye open","brow.left":"Left brow","brow.right":"Right brow",browTilt:"Brow slant",lookX:"Look left / right",lookY:"Look up / down"}[e]??e}const jd={leftEye:"eye.left",rightEye:"eye.right",leftBrow:"brow.left",rightBrow:"brow.right"},Gd=Object.fromEntries(Object.entries(U).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([n,i])=>[jd[n]??n,i]))]));function Jd(e,t){const n=Math.min(1,Math.max(0,e.turn??0)),i=1-n,s={...z,turn:n},r=[{stick:"right",human:"left",s:1},{stick:"left",human:"right",s:-1}];for(const{stick:a,human:l,s:c}of r){const h=e[`${a}Shoulder`],u=e[`${a}Elbow`];s[`arm.${l}.spread`]=h*i,s[`arm.${l}.swing`]=c*h*n,s[`arm.${l}.bend`]=u*i,s[`arm.${l}.elbow`]=c*u*n;const f=e[`${a}Hip`],d=e[`${a}Knee`],m=i+c*n;s[`leg.${l}.rotate`]=90*i,s[`leg.${l}.spread`]=0,s[`leg.${l}.swing`]=f*m,s[`leg.${l}.knee`]=d*m,s[`leg.${l}.ankle`]=-(e[`${a}Ankle`]??0),s[`leg.${l}.toeOut`]=(e[`${a}FootOut`]??0)*Zd,s[`eye.${l}`]=e[`${a}Eye`],s[`brow.${l}`]=e[`${a}Brow`],t&&Object.assign(s,Qd(l,t[a]??K,e[`${a}Wrist`]??0,n))}const o=e.bend??0;s.lean=(e.lean+o*.5)*n,s.side=(e.lean+o*.5)*i,s["head.tilt"]=(e.headTilt+o*.5)*i,s["head.nod"]=(e.headTilt+o*.5)*n;for(const a of["mouth","smile","mouthWidth","blink","browTilt","lookX","lookY","stretch"])s[a]=e[a];return s.lift=e.rise??0,s.roll=e.spin??0,s}const Zd=70;function Qd(e,t,n,i){const s=e==="right"?1-i:1+i,r={};for(const o of Object.keys(K))r[`hand.${e}.${o}`]=t[o]??K[o];return r[`hand.${e}.turn`]=(t.turn??0)-s,r[`hand.${e}.roll`]=(t.roll??0)+n,r}const rt=e=>e*Math.PI/180;function Xa([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e,t*s+n*r,-t*r+n*s]}function is([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s-t*r,e*r+t*s,n]}function Ot([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s+n*r,t,-e*r+n*s]}const kt=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],_n=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],In=(e,t)=>is(Xa(e,t.swing),t.spread);function ss(e,t){const n=Ot(e,t);return{point:{x:n[0],y:-n[1]},depth:n[2]}}function Cn(e,t,n){const i=n,r=[0,e.hipHeight*i*(e.boneScale?.(t,null)??1),0],o={};for(const p of e.chains){const g=p.parent?o[p.parent]:void 0;if(p.parent&&!g)throw new Error(`body plan ${e.id}: chain ${p.id} comes before its parent ${p.parent}`);const y=p.at??(g?g.joints3.length-1:0),w=g?g.joints3[y]:r,v=g?g.frames[Math.max(0,y-1)]:{swing:0,spread:0},M=p.offset?kt(w,In(_n(p.offset,i),v)):w,S=p.side??1,E=e.boneScale?.(t,p)??1,k=e.angles(t,p),x=[M],T=[];let P=v.swing,A=v.spread;p.bones.forEach((_,I)=>{const C=k[I]??{swing:0,spread:0};P+=rt(C.swing),A+=rt(C.spread)*S,T.push({swing:P,spread:A});const H=Ot(In(p.rest,{swing:P,spread:A}),rt(C.yaw??0));x.push(kt(x[I],_n(H,_.length*i*E)))}),o[p.id]={joints3:x,frames:T}}const a=o[e.head.on],l=e.headPose?.(t)??{yaw:0,nod:0,tilt:0,sx:1,sy:1},c=a.frames[a.frames.length-1],h=e.head.size/2*i,u=h*l.sx,f=h*l.sy,d=p=>In(Ot(Xa(is(p,-rt(l.tilt)),-rt(l.nod)),rt(l.yaw)),c),m=kt(a.joints3[a.joints3.length-1],d([0,f,0]));return{height:i,root:r,chains:o,head:{center:m,rx:u,ry:f,toBody:d}}}function rs(e,t,n){const i=n.height,s=rt(90*(t.turn??0)),r=Cn(e,t,i),{root:o}=r,a=r.chains,{rx:l,ry:c}=r.head,h=r.head.toBody,u=r.head.center,f={};for(const T of e.chains){const{joints3:P,frames:A}=a[T.id],_=P.map(I=>ss(I,s));f[T.id]={id:T.id,joints3:P,frames:A,points:_.map(I=>I.point),depths:_.map(I=>I.depth)}}const d=ss(u,s),m=[[1,0,0],[0,1,0],[0,0,1]].map(T=>Ot(h(T),s)),p=ss(o,s).point,g=rt(t.roll??0),y=T=>{const P=T.x-p.x,A=T.y-p.y;return{x:p.x+P*Math.cos(g)-A*Math.sin(g),y:p.y+P*Math.sin(g)+A*Math.cos(g)}},w=([T,P,A])=>[T*Math.cos(g)+P*Math.sin(g),-T*Math.sin(g)+P*Math.cos(g),A];for(const T of Object.values(f))T.points=T.points.map(y);const v={center:y(d.point),depth:d.depth,rx:l,ry:c,angle:0,axes:m.map(w)},M=v.axes[1];v.angle=Math.atan2(M[0],M[1]);const S=T=>{if("head"in T)return{x:v.center.x+M[0]*c,y:v.center.y-M[1]*c};const P=f[T.chain];return P.points[Math.min(T.joint,P.points.length-1)]};let E=0;(n.contact??"ground")==="ground"&&(E=-Math.max(...e.contacts.map(T=>S(T).y))),E-=(t.lift??0)*i;const k=T=>({x:T.x,y:T.y+E});for(const T of Object.values(f))T.points=T.points.map(k);v.center=k(v.center);const x=e.contacts.map(T=>({spec:T,point:S(T)}));return{height:i,view:s,chains:f,head:v,hip:k(y(p)),contacts:x,groundY:Math.max(...x.map(T=>T.point.y))}}const os=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],qa=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function as(e,t,n){const i=n.height,s=rt(90*(t.turn??0)),r=rt(t.roll??0),o=Cn(e,t,i),a=Ot(o.root,s),l=g=>kt(is(os(Ot(g,s),a),-r),a),c={};for(const g of e.chains)c[g.id]=o.chains[g.id].joints3.map(l);const h=l(o.head.center),u=g=>qa(os(l(kt(o.head.center,o.head.toBody(g))),h)),f=[u([1,0,0]),u([0,1,0]),u([0,0,1])],d=g=>{if("head"in g)return kt(h,_n(f[1],o.head.ry));const y=c[g.chain];return y[Math.min(g.joint,y.length-1)]};let m=0;(n.contact??"ground")==="ground"&&(m=-Math.min(...e.contacts.map(g=>d(g)[1]))),m+=(t.lift??0)*i;const p=g=>[g[0],g[1]+m,g[2]];return{height:i,hip:p(a),chains:Object.fromEntries(Object.entries(c).map(([g,y])=>[g,y.map(p)])),head:{center:p(h),rx:o.head.rx,ry:o.head.ry,axes:f}}}function ls(e,t,n,i){const s=n.height,r=rt(90*(t.turn??0)),o=Cn(e,t,s),a=as(e,t,n),l=a.hip,c=a.chains,h=a.head.center,u=T=>{if("head"in T)return kt(h,_n(a.head.axes[1],a.head.ry));const P=c[T.chain];return P[Math.min(T.joint,P.length-1)]},f=i.toView(l),d=i.toScreen(f),m=i.toScreen([f[0]+1,f[1],f[2]]),p=Math.hypot(m.x-d.x,m.y-d.y),g=T=>{const P=i.toView(T);return{point:i.toScreen(P),depth:P[2]*p}},y={};for(const T of e.chains){const P=c[T.id].map(g);y[T.id]={id:T.id,joints3:o.chains[T.id].joints3,frames:o.chains[T.id].frames,points:P.map(A=>A.point),depths:P.map(A=>A.depth)}}const w=i.toView(h),v=i.toScreen(w),M=i.toScreen([w[0]+1,w[1],w[2]]),S=Math.hypot(M.x-v.x,M.y-v.y),E=a.head.axes.map(T=>qa(os(i.toView(kt(h,T)),w))),k={center:v,depth:w[2]*p,rx:o.head.rx*S,ry:o.head.ry*S,angle:Math.atan2(E[1][0],E[1][1]),axes:E},x=e.contacts.map(T=>({spec:T,point:g(u(T)).point}));return{height:s*p,view:r,chains:y,head:k,hip:d,contacts:x,groundY:Math.max(...x.map(T=>T.point.y))}}function Va(e,[t,n,i]){const[s,r,o]=e.axes,a=[s[0]*t*e.rx+r[0]*n*e.ry+o[0]*i*e.rx,s[1]*t*e.rx+r[1]*n*e.ry+o[1]*i*e.rx,s[2]*t*e.rx+r[2]*n*e.ry+o[2]*i*e.rx],l=Math.hypot(t,n,i)||1,c=(s[2]*t+r[2]*n+o[2]*i)/l;return{point:{x:e.center.x+a[0],y:e.center.y-a[1]},depth:e.depth+a[2],facing:c}}class Ua{positions=[];normals=[];indices=[];vertex(t,n,i,s,r,o){const a=Math.hypot(s,r,o)||1;return this.positions.push(t,n,i),this.normals.push(s/a,r/a,o/a),this.positions.length/3-1}triangle(t,n,i){this.indices.push(t,n,i)}quad(t,n,i,s){this.indices.push(t,n,i,t,i,s)}build(){return{positions:this.positions,normals:this.normals,indices:this.indices}}}function t0(e){const t=new Map,n=[];for(let s=0;s<e.positions.length/3;s++){const r=[0,1,2].map(o=>Math.round(e.positions[s*3+o]*1e6)).join(",");t.has(r)||t.set(r,s),n.push(t.get(r))}const i=new Map;for(let s=0;s<e.indices.length/3;s++)for(let r=0;r<3;r++){const o=n[e.indices[s*3+r]],a=n[e.indices[s*3+(r+1)%3]];if(o===a)continue;const l=o<a?`${o}-${a}`:`${a}-${o}`,c=i.get(l);c?c.faces.push(s):i.set(l,{a:Math.min(o,a),b:Math.max(o,a),faces:[s]})}return[...i.values()]}const cs=Math.PI*2;function e0(e,t=16){const n=new Ua,i=Math.max(6,Math.round(t)),s=Math.max(3,Math.round(i/2)),r=[];for(let o=0;o<=s;o++){const a=o/s*Math.PI,l=[];for(let c=0;c<=i;c++){const h=c/i*cs,u=Math.sin(a)*Math.sin(h),f=Math.cos(a),d=Math.sin(a)*Math.cos(h);l.push(n.vertex(u*e,f*e,d*e,u,f,d))}r.push(l)}for(let o=0;o<s;o++)for(let a=0;a<i;a++){const l=r[o][a],c=r[o+1][a],h=r[o+1][a+1],u=r[o][a+1];o>0&&n.triangle(l,c,u),o<s-1&&n.triangle(c,h,u)}return n.build()}function za(e,t,n,i,s){const r=e.vertex(0,n,0,0,i,0),o=Array.from({length:s},(a,l)=>{const c=l/s*cs;return e.vertex(Math.sin(c)*t,n,Math.cos(c)*t,0,i,0)});for(let a=0;a<s;a++){const l=o[a],c=o[(a+1)%s];i===1?e.triangle(r,l,c):e.triangle(r,c,l)}}function n0(e,t,n=24){const i=new Ua,s=Math.max(6,Math.round(n)),r=t/2,o=-t/2,a=h=>Array.from({length:s+1},(u,f)=>{const d=f/s*cs;return i.vertex(Math.sin(d)*e,h,Math.cos(d)*e,Math.sin(d),0,Math.cos(d))}),l=a(o),c=a(r);for(let h=0;h<s;h++)i.quad(l[h],l[h+1],c[h+1],c[h]);return za(i,e,r,1,s),za(i,e,o,-1,s),i.build()}function ja(e){const t=Array.from({length:e.indices.length/3},()=>[]);for(const n of t0(e))for(const i of n.faces){const s=n.faces.find(r=>r!==i)??-1;t[i].push({a:n.a,b:n.b,across:s})}return{...e,faceEdges:t}}const Hn=e=>e*180/Math.PI,se=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],hs=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Le=e=>Math.hypot(e[0],e[1],e[2]),us=e=>{const t=Le(e)||1;return[e[0]/t,e[1]/t,e[2]/t]},$n=e=>Math.atan2(Math.sin(e),Math.cos(e));function Ga(e){const[t,n,i]=us(e);return{swing:Math.asin(Math.max(-1,Math.min(1,i))),spread:Math.atan2(t,-n)}}function i0(e,t,n,i,s){const r=e.chains.find(P=>P.id===n);if(!r)throw new Error(`reach: no chain ${n} in ${e.id}`);if(r.bones.length<2||r.rest[1]>-.99)throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);if(!e.withAngles)throw new Error(`reach: the ${e.id} plan cannot set angles`);const o=rs(e,{...t,turn:0,roll:0,lift:0},{height:s.height,contact:"none"}),a=o.chains[n],l=a.joints3[0],c=Le(se(a.joints3[1],a.joints3[0])),h=Le(se(a.joints3[2],a.joints3[1])),u=r.parent?o.chains[r.parent].frames[Math.max(0,(r.at??o.chains[r.parent].joints3.length-1)-1)]:{swing:0,spread:0},f=se(i,l),d=Math.min(c+h-1e-6,Math.max(Math.abs(c-h)+1e-6,Le(f))),m=us(f),p=r.parent!==null,g=In(r.pole??(p?[0,-.35,-1]:[0,0,1]),u);let y=se(g,[m[0]*hs(g,m),m[1]*hs(g,m),m[2]*hs(g,m)]);Le(y)<1e-6&&(y=Ot([1,0,0],0)),y=us(y);const w=(c*c+d*d-h*h)/(2*c*d),v=Math.sqrt(Math.max(0,1-w*w)),M=[l[0]+c*(w*m[0]+v*y[0]),l[1]+c*(w*m[1]+v*y[1]),l[2]+c*(w*m[2]+v*y[2])],S=[l[0]+m[0]*d,l[1]+m[1]*d,l[2]+m[2]*d],E=r.side??1,k=Ga(se(M,l)),x=Ga(se(S,M)),T=[{swing:Hn($n(k.swing-u.swing)),spread:Hn($n(k.spread-u.spread))*E},{swing:Hn($n(x.swing-k.swing)),spread:Hn($n(x.spread-k.spread))*E}];return e.withAngles(t,r,T)}const s0=.34,St=.12,ht=-.4,ft=(e,t,n)=>e[t]??n,r0=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),o0=.45,a0=.35,l0=.7;function On(e,t,n){const i=d=>Math.sqrt(Math.max(0,1-d.x*d.x-d.y*d.y)),s=Va(e,[n.x,n.y,i(n)]).facing,r=e.axes[2],o=Math.atan2(r[0],r[2]),a=Math.cos(o),l=a>=0?1:-1,c=l*Math.max(a0,Math.abs(a)),h=l*Math.max(l0,Math.abs(a)),u=Math.cos(e.angle),f=Math.sin(e.angle);return{facing:s,points:t.map(d=>{const m=o0*Math.sin(o)+n.x*c+(d.x-n.x)*h,p=d.y+r[1]*i(d),g=m*e.rx,y=p*e.ry;return{x:e.center.x+g*u+y*f,y:e.center.y+g*f-y*u}})}}const Rn=(e,t,n,i=12)=>Array.from({length:i+1},(s,r)=>{const o=r/i,a=1-o;return{x:a*a*e.x+2*a*o*t.x+o*o*n.x,y:a*a*e.y+2*a*o*t.y+o*o*n.y}}),fs=(e,t,n,i,s=16)=>Array.from({length:s},(r,o)=>{const a=Math.PI*2*o/s;return{x:e+Math.cos(a)*n,y:t+Math.sin(a)*i}}),Ja=.05;function c0(e,t,n,i){const s=Math.max(1,Math.min(i*.6,.14*t.rx)),r=(y,w)=>On(t,y,w).points,o=(y,w)=>On(t,[],{x:y,y:w}).facing,a=ft(n,"smile",0),l=ft(n,"blink",0),c=ft(n,"lookX",0),h=ft(n,"lookY",0),u=ft(n,"browTilt",0);for(const y of[1,-1]){const w=y===1?"left":"right",v=s0*y;if(o(v,St)<Ja)continue;const M={x:v,y:St},S=r0(ft(n,`eye.${w}`,1),l);if(S<.2){const T=a>.5?.12:-.06;e.line(r(Rn({x:v-.12,y:St},{x:v,y:St+T},{x:v+.12,y:St}),M),s)}else{if(S>1.2){const _=.13*S;e.shape(r(fs(v,St,_*.85,_),M),"#ffffff",s)}const T=S>1.2?.075:.1,P=v+c*.08,A=St-h*.07;e.shape(r(fs(P,A,T,T*1.1*Math.min(S,1)),M),e.ink,0)}const E=St+.3+ft(n,`brow.${w}`,0)*.14+Math.max(0,S-1)*.12,k={x:v+y*.13,y:E},x={x:v-y*.13,y:E+u*.1};e.line(r([k,{x:(k.x+x.x)/2,y:(k.y+x.y)/2},x],{x:v,y:E}),s)}const f={x:0,y:ht};if(o(0,ht)<-Ja)return;const d=.25*Math.max(.3,ft(n,"mouthWidth",1)),m=Math.min(1,Math.max(0,ft(n,"mouth",0)));if(m<=.05){e.line(r(Rn({x:-d,y:ht},{x:0,y:ht-a*.25},{x:d,y:ht}),f),s);return}const p=.3*m;let g;if(a>.3){const y=ht+.05;g=[...Rn({x:d,y},{x:0,y:ht-p*2},{x:-d,y})]}else if(a<-.3){const y=ht-p*.6;g=[...Rn({x:d,y},{x:0,y:ht+p*1.4},{x:-d,y})]}else g=fs(0,ht,d*.8,p);e.shape(r(g,f),e.ink,0)}function Za(e={}){const t=(e.proportions??"bold")==="bold",n=e.figure??"fluid",i=e.look??"clean",s=e.height??300,r=n==="stick";return{plan:e.plan??Ya({headSize:e.headSize??(t?.3:.24),shoulderWidth:r?0:e.shoulderWidth??.06,hipWidth:r?0:e.hipWidth??.022}),figure:n,look:i,height:s,lineWidth:e.lineWidth??s*(t?.045:.022),ink:e.ink??(i==="pencil"?"#2f2f33":"#1e293b"),skin:e.skin??(i==="pencil"?"none":"#ffffff"),seed:e.seed??1,pencil:e.pencil??{},layers:e.layers??{},contact:e.contact??"ground",hands:e.hands??"dot",handStyle:e.handStyle??"glove",handSize:e.handSize??(e.handStyle==="natural"?.14:.17)}}function h0(e,t,n,i){const{point:s,facing:r}=Va(e,[t,n,i]);return{point:s,facing:r}}const ds=e=>e.rest[1]<-.5,u0=.3;function f0(e,t,n){return e.figure==="stick"?ds(t)?n.slice(0,3):n:ds(t)&&n.length>=3?It(n[0],n[1],n[2],u0):n.length===3?It(n[0],n[1],n[2],1):n}function ps(e,t){const n=e.plan.id==="human"?{...z,...t}:t;return ms(e,n,rs(e.plan,n,{height:e.height,contact:e.contact}))}function ms(e,t,n){const i={},s={},r={},o=.01*e.height;e.plan.chains.forEach(f=>{const d=n.chains[f.id];i[f.id]=d.points;const m=d.depths.reduce((w,v)=>w+v,0)/d.depths.length,p=f.parent?n.chains[f.parent]:void 0,g=p?p.depths[f.at??p.depths.length-1]:0,y=m-g;r[f.id]=Math.abs(y)<o?0:y,s[f.id]={points:f0(e,f,d.points),depth:m}}),s.head={points:[n.head.center],depth:n.head.depth},r.head=0;const a=[...e.plan.chains.map(f=>f.id),"head"],l=[...a].sort((f,d)=>r[f]-r[d]||a.indexOf(f)-a.indexOf(d)),c={hip:n.hip};for(const[f,[d,m]]of Object.entries(e.plan.landmarks??{})){const p=n.chains[d]?.points;p&&(c[f]=p[Math.min(m,p.length-1)])}const h={};for(const[f,d]of Object.entries(c))h[f]=d.y>=n.groundY-.01*e.height;const u={height:e.height,lineWidth:e.lineWidth,turn:t.turn??0,points:c,chains:i,parts:s,head:n.head,groundY:n.groundY,grounded:h};return{skeleton:n,joints:u,order:l}}function Qa(e,t){return ps(e,t).joints}function d0(e,t,n){const{head:i}=n;e.guideEllipse(i.center.x,i.center.y,i.rx*1.03,i.ry*1.03,i.angle);const s=Array.from({length:13},(l,c)=>({x:0,y:-.95+1.9*c/12})),r=Array.from({length:13},(l,c)=>({x:-.95+1.9*c/12,y:.12})),o=On(i,s,{x:0,y:0});o.facing>0&&e.guide(o.points),e.guide(On(i,r,{x:0,y:.12}).points),e.guide(n.chains.spine??[]);const a=t.lineWidth*.9;for(const l of["shoulder.left","shoulder.right","elbow.left","elbow.right","hip.left","hip.right","knee.left","knee.right"]){const c=n.points[l];c&&e.guideEllipse(c.x,c.y,a,a,0)}}function p0(e,t,n,i,s,r){const o=n.lineWidth;if(s==="head"){const{head:d}=i,m=n.skin==="none"?null:n.skin;t.ellipse(d.center.x,d.center.y,d.rx,d.ry,d.angle,m,o),t.look!=="silhouette"&&c0(t,d,r,o);return}const a=n.plan.chains.find(d=>d.id===s),l=i.chains[s],c=i.parts[s].points;if(n.figure==="stick"){if(s==="neck")return;const d=s==="spine"?[...l,...i.chains.neck?.slice(1)??[]]:c;t.line(d,o);return}const h=(d,m)=>[a.bones[d].width[0]*o,a.bones[m].width[1]*o];if(ds(a)){const[d,m]=h(0,1);if(t.limb(c,d,m),a.bones.length>=3)t.limb([l[2],l[3]],a.bones[2].width[0]*o,a.bones[2].width[1]*o);else if(n.hands==="cartoon"&&s.startsWith("arm."))m0(e,t,n,l,s.endsWith(".left")?"left":"right",r);else{const p=l[l.length-1];t.dot(p.x,p.y,o*.62)}return}if(s==="spine"){const d=i.points["hip.left"],m=i.points["hip.right"];d&&m&&Math.hypot(d.x-m.x,d.y-m.y)>.5&&t.limb([d,m],o*1.3,o*1.3);const[p,g]=h(0,a.bones.length-1);t.limb(c,p,g);const y=i.points["shoulder.left"],w=i.points["shoulder.right"];y&&w&&Math.hypot(y.x-w.x,y.y-w.y)>.5&&t.limb(It(y,l[l.length-1],w,1,10),o*1.15,o*1.15);return}const[u,f]=h(0,a.bones.length-1);t.limb(c,u,f)}function tl(e,t){const n=`hand.${t}.`,i={};for(const[o,a]of Object.entries(e))o.startsWith(n)&&(i[o.slice(n.length)]=a);const s=e.turn??0,r=t==="right"?1-s:1+s;return{...K,...i,turn:r+(i.turn??0)}}function m0(e,t,n,i,s,r){const o=i[i.length-1],a=i[i.length-2],l=Math.atan2(o.x-a.x,-(o.y-a.y))*180/Math.PI;bn(e,o,tl(r,s),{size:n.handSize*n.height,side:s,angle:l,pen:t,skin:n.skin==="none"?"#ffffff":n.skin,fingers:n.handStyle==="natural"?5:4,plump:n.handStyle==="natural"?1.15:1.6,lineWidth:n.lineWidth*.3})}function el(e,t,n,i=0){const s=t.plan.id==="human"?{...z,...n}:n;sl(e,t,s,ps(t,s),i)}function nl(e,t){const n=t/e.height;return{...e,height:t,lineWidth:e.lineWidth*n}}function g0(e,t,n,i){const s=e.plan.id==="human"?{...z,...t}:t,r=ls(e.plan,s,{height:i.height,contact:e.contact},n);return ms(nl(e,r.height),s,r).joints}function il(e,t,n,i,s){const r=t.plan.id==="human"?{...z,...n}:n,o=ls(t.plan,r,{height:s.height,contact:t.contact},i),a=nl(t,o.height);sl(e,a,r,ms(a,r,o),s.time??0)}function sl(e,t,n,i,s){const{joints:r,order:o}=i,a=Ki(e,{look:t.look,ink:t.ink,lineWidth:t.lineWidth,seed:t.seed,time:s,pencil:t.pencil}),l=c=>{c&&(e.save(),c(e,r,a,s),e.restore())};e.save(),e.lineCap="round",e.lineJoin="round",t.look==="pencil"&&t.pencil.construction!==!1&&d0(a,t,r),l(t.layers.behind);for(const c of o){const h=t.layers.parts?.[c];l(h?.under),p0(e,a,t,r,c,n),l(h?.over)}l(t.layers.front),e.restore()}function y0(e,t,n){const i={...e};for(const[s,r]of Object.entries(t)){const o=e[s]??r;i[s]=o+(r-o)*n}return i}function b0(e,t,n,i){const s=e.plan.id==="human"?{...z,...t}:t;let r;if(Array.isArray(i))r=i;else{const{skeleton:o}=ps(e,s),a=rs(e.plan,{...s,roll:0},{height:e.height,contact:"none"}),l=(s.roll??0)*Math.PI/180,c=i.x-o.hip.x,h=i.y-o.hip.y,u=a.hip.x+c*Math.cos(-l)-h*Math.sin(-l),f=a.hip.y+c*Math.sin(-l)+h*Math.cos(-l),d=Math.PI/2*(s.turn??0),m=i.depth??o.chains[n].depths[o.chains[n].depths.length-1],p=Math.cos(d),g=Math.sin(d);r=[u*p-m*g,-f,u*g+m*p]}return i0(e.plan,s,n,r,{height:e.height})}function w0(e){const{character:t}=e,n=t.height*.8,i=t.height,s=t.plan.id==="human"?z:{};return{type:"custom",x:e.x-n/2,y:e.y-i,width:n,height:i,props:{...s,...e.pose},character:t,draw(r,o,a){r.translate(n/2,i),el(r,t,o.props,a)}}}function rl(e,t,n){const i=r=>({x:r.x+t,y:r.y+n}),s=r=>Object.fromEntries(Object.entries(r).map(([o,a])=>[o,a.map(i)]));return{...e,points:Object.fromEntries(Object.entries(e.points).map(([r,o])=>[r,i(o)])),chains:s(e.chains),parts:Object.fromEntries(Object.entries(e.parts).map(([r,o])=>[r,{...o,points:o.points.map(i)}])),head:{...e.head,center:i(e.head.center)},groundY:e.groundY+n}}function v0(e,t,n){const i=e.character;if(!i)throw new Error("characterAt: the target was not made by characterTarget");const s={...e.props};let r=0,o=0;for(const[l,c]of t.state?.values.get(n)??[])typeof c=="number"&&(l==="x"||l==="motionPathX"?r=c:l==="y"||l==="motionPathY"?o=c:l in s&&(s[l]=c));const a=Qa(i,s);return{pose:s,joints:rl(a,e.x+r+e.width/2,e.y+o+e.height)}}function gs(e,t=z){const n=[];return e.forEach((i,s)=>{const r=s===0?t:n[s-1],o=typeof i.pose=="string"?Ka[i.pose]:void 0;n.push(o?{...o,turn:r.turn??0}:{...r,...i.pose})}),n}function k0(e,t,n=z){const i=gs(t,n);return Object.keys(n).filter(r=>i.some(o=>(o[r]??n[r])!==n[r])).map(r=>({id:`${e}-${r}`,target:e,property:r,keyframes:t.map((o,a)=>({time:o.time,value:i[a][r]??n[r],...o.easing?{easing:o.easing}:{}}))}))}const S0=new Set(["x","y","z","position","rotateX","rotateY","rotateZ","quaternion","scale","scaleX","scaleY","scaleZ","visible","opacity","color"]),M0=1.7;function T0(e,t,n){const i=Array.from({length:24},(s,r)=>{const o=r/24*Math.PI*2,a=t.toView([Math.cos(o)*n,0,Math.sin(o)*n*.8]);return a[2]<-.001?t.toScreen(a):null});i.some(s=>s===null)||(e.beginPath(),i.forEach((s,r)=>r===0?e.moveTo(s.x,s.y):e.lineTo(s.x,s.y)),e.closePath(),e.fillStyle="rgba(0, 0, 0, 0.22)",e.fill())}function E0(e){const t=we([0,1,0],e);if(t>.999999)return Rr();if(t<-.999999)return ke(Xt([1,0,0],180));const n=nn([0,1,0],e);return ke(Xt(n,Math.acos(t)*180/Math.PI))}function A0(e,t,n,i,s){const r=e.solid??{},o=r.outline===!1?void 0:r.outline??{width:2,color:"#0f172a"},a={color:r.color??"#475569",shading:r.shading??"toon",outline:o},l={color:r.skin??"#f2c49b",shading:r.shading??"toon",outline:o},c={color:"#0f172a",shading:"unlit"},h=i.height*.034,u=[],f=(v,M,S)=>u.push({mesh:v,world:xt(s,M),material:S}),d=(v,M,S)=>f(t.sphere,Fr(v,[0,0,0,1],[M,M,M]),S);for(const v of n.chains){const M=i.chains[v.id],S=v.id==="spine"?1.9:1;v.bones.forEach((E,k)=>{const x=M[k],T=M[k+1],P=$r(x,T),[A,_]=E.width??[1,1],I=h*S*(A+_)/2;if(P>1e-6){const C=Or(x,T,.5),H=E0(ve(en(T,x)));f(t.cylinder,xt(Lr(C),xt(H,sn([I,P,I]))),a)}d(x,h*S*A,a),d(T,h*S*_,a)}),v.id.startsWith("arm.")&&d(M[M.length-1],h*1.5,l)}const{center:m,rx:p,ry:g,axes:y}=i.head,w=[...y[0],0,...y[1],0,...y[2],0,...m,1];f(t.sphere,xt(w,sn([p,g,p])),l);for(const v of[-1,1]){const M=ve([v*.36,.15,.92]),S=tn(m,tn(tn(be(y[0],M[0]*p*1.04),be(y[1],M[1]*g*1.04)),be(y[2],M[2]*p*1.04))),E=[...y[0],0,...y[1],0,...y[2],0,...S,1];f(t.sphere,xt(E,sn([p*.11,g*.14,p*.03])),c)}return u}const x0={kind:"character",validate(e){const t=e;return t.height!==void 0&&!(t.height>0)?["a character's height must be positive"]:[]},prepare(e){return{who:Za({...e.character,height:1}),cylinder:ja(n0(1,1,16)),sphere:ja(e0(1,20))}},resolve({object:e,prepared:t,values:n,world:i,camera:s,toScreen:r}){const o=e,a=t,l=a.who,c={...z,...o.pose};for(const[g,y]of n)typeof y=="number"&&!S0.has(g)&&(c[g]=y);const h=o.height??M0,u=xt(s.view,i),f={toView:g=>Dr(u,g),toScreen:g=>r(g)},m=-f.toView([0,h/2,0])[2];if(m<=s.near)return null;const p=o.shadow===!1?[]:[{depth:m+h,draw:g=>T0(g,f,h*.18)}];if(o.look==="solid"){const g=as(l.plan,c,{height:h,contact:l.contact});return{meshes:A0(o,a,l.plan,g,i),drawables:p}}return{drawables:[...p,{depth:m,draw(g,y){g.lineCap="round",g.lineJoin="round",il(g,l,c,f,{height:h,time:y.time})}}]}}};function ol(e,t,n={},i){const s=n.length??240,r=9,o=28,a=s-22;e.save(),e.translate(t.x,t.y),e.rotate((n.angle??-30)*Math.PI/180),e.fillStyle=n.color??"#f4c542",e.fillRect(o,-r,a-o,2*r),e.fillStyle="#e8b4a0",e.fillRect(a,-r,s-a,2*r),e.fillStyle="#f1dcbf",e.beginPath(),e.moveTo(0,0),e.lineTo(o,-r),e.lineTo(o,r),e.closePath(),e.fill(),e.fillStyle=n.outline??"#2f2f33",e.beginPath(),e.moveTo(0,0),e.lineTo(o*.35,-r*.35),e.lineTo(o*.35,r*.35),e.closePath(),e.fill(),e.strokeStyle=n.outline??"#2f2f33",e.lineWidth=3,e.lineJoin="round",e.lineCap="round";const l=[[{x:0,y:0},{x:o,y:-r},{x:s,y:-r},{x:s,y:r},{x:o,y:r},{x:0,y:0}],[{x:o,y:-r},{x:o,y:r}],[{x:a,y:-r},{x:a,y:r}]];for(const c of l)cl(e,c,i);e.restore()}function ys(e,t,n={},i){const s=n.length??90,r=n.thickness??34;e.save(),e.translate(t.x,t.y),e.rotate((n.angle??-35)*Math.PI/180);const o=-r/2;e.fillStyle=n.color??"#f4a7b9",e.fillRect(0,o,s,r),e.fillStyle="#e9edf2",e.fillRect(s*.45,o,s*.55,r),e.strokeStyle=n.outline??"#2f2f33",e.lineWidth=3,e.lineJoin="round";const a=[{x:0,y:o},{x:s,y:o},{x:s,y:-o},{x:0,y:-o},{x:0,y:o}],l=[{x:s*.45,y:o},{x:s*.45,y:-o}];if(i)i.line(a),i.line(l);else for(const c of[a,l]){e.beginPath(),e.moveTo(c[0].x,c[0].y);for(const h of c.slice(1))e.lineTo(h.x,h.y);e.stroke()}e.restore()}const al=150,P0={pencil:44,eraser:30};function bs(e,t,n={},i){const s=n.tool??"pencil",r=n.skin??"#f1c9a5",o=n.outline??"#2f2f33",a=n.scale??1,l=Math.min(1,Math.max(0,n.lift??0)),c=(n.angle??-30)*Math.PI/180,h=i?i.nudge(.6):{x:0,y:0},u=al*a*(1+.05*l);l>0&&(e.save(),e.fillStyle=o,e.globalAlpha=.15*l,e.beginPath(),e.ellipse(t.x,t.y,9*a,4*a,0,0,Math.PI*2),e.fill(),e.restore());const f={x:t.x+h.x+6*l*a,y:t.y+h.y-18*l*a},d=q.pencilGrip,m=k=>{const x=k.fingers.thumb,T=k.fingers.index,P=k.fingers.middle,A=ll([x.points[3],T.points[3],P.points[3]]),_=ll([x.points[1],T.points[0]]),I=(x.depths[3]+T.depths[3]+P.depths[3])/3;return{pinch:A,direction:Math.atan2(_.y-A.y,_.x-A.x),depth:I}},p=yn(d,{size:u}),g=c-m(p).direction,y=yn(d,{size:u,angle:g*180/Math.PI}),w=m(y),v=P0[s]*a,M={x:w.pinch.x-Math.cos(c)*v,y:w.pinch.y-Math.sin(c)*v},S={x:f.x-M.x,y:f.y-M.y},E=y.axes.up;_0(e,S,{x:-E.x,y:-E.y},u,n.arm??300*a,r,n.sleeve??"#5b7db1",o),bn(e,S,d,{size:u,angle:g*180/Math.PI,skin:r,ink:o,lineWidth:3*a,prop:{depth:w.depth,draw:()=>{e.save(),e.translate(f.x,f.y),e.scale(a,a),s==="eraser"?ys(e,{x:0,y:0},{angle:c*180/Math.PI,outline:o},i):ol(e,{x:0,y:0},{angle:c*180/Math.PI,length:190,outline:o},i),e.restore()}}})}const ll=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length});function _0(e,t,n,i,s,r,o,a){const l={x:-n.y,y:n.x},c=i*.15,h=(p,g,y)=>({x:t.x+n.x*p+l.x*g*y,y:t.y+n.y*p+l.y*g*y}),u=h(s,0,0),f=p=>{const g=e.createLinearGradient(t.x,t.y,u.x,u.y);return g.addColorStop(0,p),g.addColorStop(.6,p),g.addColorStop(1,$0(p)),g},d=Math.min(i*.55,s*.35);e.save(),e.lineJoin="round",e.lineCap="round",e.lineWidth=3*(i/al),e.beginPath(),e.moveTo(h(-i*.1,-1,c).x,h(-i*.1,-1,c).y),e.lineTo(h(d+4,-1,c*1.1).x,h(d+4,-1,c*1.1).y),e.lineTo(h(d+4,1,c*1.1).x,h(d+4,1,c*1.1).y),e.lineTo(h(-i*.1,1,c).x,h(-i*.1,1,c).y),e.closePath(),e.fillStyle=r,e.fill(),e.strokeStyle=a,e.beginPath(),e.moveTo(h(0,-1,c).x,h(0,-1,c).y),e.lineTo(h(d,-1,c*1.1).x,h(d,-1,c*1.1).y),e.moveTo(h(0,1,c).x,h(0,1,c).y),e.lineTo(h(d,1,c*1.1).x,h(d,1,c*1.1).y),e.stroke();const m=[h(d,-1,c*1.3),h(s,-1,c*1.5),h(s,1,c*1.5),h(d,1,c*1.3)];e.beginPath(),m.forEach((p,g)=>g?e.lineTo(p.x,p.y):e.moveTo(p.x,p.y)),e.closePath(),e.fillStyle=f(o),e.fill(),e.strokeStyle=f(a),e.beginPath(),e.moveTo(m[1].x,m[1].y),e.lineTo(m[0].x,m[0].y),e.lineTo(m[3].x,m[3].y),e.lineTo(m[2].x,m[2].y),e.stroke(),e.restore()}function I0(e,t,n={}){const i=n.offstage??{x:2e3,y:1400},s=n.enter??450,r=n.exit??450,o=n.linger??1500,a=[...e].filter(p=>p.path.length>0).sort((p,g)=>p.start-g.start),l=p=>p.tool??"pencil",c=p=>{const g=Math.min(1,Math.max(0,p));return g*g*(3-2*g)},h=(p,g,y)=>({x:p.x+(g.x-p.x)*y,y:p.y+(g.y-p.y)*y}),u=a.find(p=>t>=p.start&&t<=p.end);if(u){const p=u.end-u.start,g=p>0?(t-u.start)/p:1;return{at:fn(u.path,g),tool:l(u),lift:0,drawing:!0}}const f=[...a].reverse().find(p=>p.end<t),d=a.find(p=>p.start>t),m=p=>p.path[p.path.length-1];if(f&&d&&d.start-f.end<=o){const p=(t-f.end)/(d.start-f.end),g=p<.5?l(f):l(d);return{at:h(m(f),d.path[0],c(p)),tool:g,lift:Math.sin(Math.PI*p),drawing:!1}}if(d&&d.start-t<=s){const p=1-(d.start-t)/s;return{at:h(i,d.path[0],c(p)),tool:l(d),lift:1-c(p),drawing:!1}}if(f&&t-f.end<=r){const p=(t-f.end)/r;return{at:h(m(f),i,c(p)),tool:l(f),lift:c(p),drawing:!1}}return null}function C0(e,t,n,i=.08,s=32){const r=Math.PI*2*(1+i),o=[];for(let a=0;a<=s;a++){const l=-Math.PI/2+r*a/s;o.push({x:e+Math.cos(l)*n,y:t+Math.sin(l)*n})}return o}function H0(e){const{path:t}=e,n=t.map(a=>a.x),i=t.map(a=>a.y),s=Math.min(...n),r=Math.min(...i),o=e.hand===!1?void 0:e.hand===!0||e.hand===void 0?{}:e.hand;return{type:"custom",x:s,y:r,width:Math.max(1,Math.max(...n)-s),height:Math.max(1,Math.max(...i)-r),props:{draw:0},draw(a,l,c){const h=Math.min(1,Math.max(0,Number(l.props?.draw??0)));a.translate(-s,-r),a.strokeStyle=e.color??"#2f2f33",a.lineWidth=e.lineWidth??5,a.lineCap="round",a.lineJoin="round";const u=e.sketch?dn(a,e.sketch,c):void 0;h>0&&(u?e.smooth?u.curve(t,h):u.line(t,h):cl(a,Qt(t,h))),o&&h>0&&h<1&&bs(a,fn(t,h),o,u)}}}function $0(e){const t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return"rgba(0, 0, 0, 0)";const n=t[1].length===3?[...t[1]].map(o=>o+o).join(""):t[1],[i,s,r]=[0,2,4].map(o=>parseInt(n.slice(o,o+2),16));return`rgba(${i}, ${s}, ${r}, 0)`}function cl(e,t,n){if(!(t.length<2)){if(n)return n.line(t);e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t.slice(1))e.lineTo(i.x,i.y);e.stroke()}}const Ln=1e5;function O0(e,t,n,i,s=6){const r=[],o=Math.max(1,Math.round(s));for(let a=0;a<=o;a++)r.push({x:a%2===0?e:e+n,y:t+i*a/o});return r}function ws(e,t,n,i){if(i<=0||t.length===0)return;const s=Qt(t,i),r=n/2,o=a=>{e.beginPath(),e.rect(-Ln,-Ln,2*Ln,2*Ln),a(),e.clip("evenodd")};for(const a of s)o(()=>{e.moveTo(a.x+r,a.y),e.arc(a.x,a.y,r,0,Math.PI*2)});for(let a=1;a<s.length;a++){const l=s[a-1],c=s[a],h=Math.hypot(c.x-l.x,c.y-l.y);if(h===0)continue;const u=-(c.y-l.y)/h*r,f=(c.x-l.x)/h*r;o(()=>{e.moveTo(l.x+u,l.y+f),e.lineTo(c.x+u,c.y+f),e.lineTo(c.x-u,c.y-f),e.lineTo(l.x-u,l.y-f),e.closePath()})}}function R0(e,t,n,i,s){e.save(),ws(e,t,n,i),s(),e.restore()}function L0(e,t){const n=t.width??40,i=t.hand===!0?{}:t.hand||void 0,s=t.eraser===!1?void 0:t.eraser===!0||t.eraser===void 0?{}:t.eraser;return{...e,props:{...e.props,erase:0},draw(r,o,a){const l=Number(o.props?.erase??0);if(r.save(),ws(r,t.path,n,l),e.draw(r,o,a),r.restore(),!s||l<=0||l>=1)return;const c=fn(t.path,l);i?bs(r,c,{...i,tool:"eraser"}):ys(r,c,s)}}}const F0=(e,t,n)=>e.slice(Math.floor((e.length-1)*t),Math.ceil((e.length-1)*n)+1);function D0(e={}){const t=e.shirt??"#e2493b",n=e.trousers??"#24476b",i=a=>a.lineWidth*.45,s=(a,l,c)=>{const h=a.parts[`leg.${c}`].points;l.shape(Pe(h,a.height*.08,a.height*.05),n,i(a))},r=(a,l)=>{const c=a.chains.spine,h=c[0],u=c[c.length-1],f={x:h.x-(u.x-h.x)*.25,y:h.y-(u.y-h.y)*.25};l.shape(Pe([f,...a.parts.spine.points],a.height*.15,a.height*.14),t,i(a))},o=(a,l,c)=>{const h=a.parts[`arm.${c}`].points,u=h[0],f=a.chains.spine[a.chains.spine.length-1],m=[{x:u.x+(f.x-u.x)*.45,y:u.y+(f.y-u.y)*.45},...F0(h,0,.45)],p=Pe(m,a.height*.085,a.height*.06),g=m.length,y=p.slice(0,g),w=p.slice(g).reverse();l.shape(p,t,0);const v=E=>Math.hypot(E[1].x-f.x,E[1].y-f.y),[M,S]=v(y)>v(w)?[y,w]:[w,y];l.line(M.slice(1),i(a)),l.line(S.slice(Math.ceil(g*.45)),i(a)),l.line([y[g-1],w[g-1]],i(a))};return{parts:{"leg.left":{over:(a,l,c)=>s(l,c,"left")},"leg.right":{over:(a,l,c)=>s(l,c,"right")},spine:{over:(a,l,c)=>r(l,c)},"arm.left":{over:(a,l,c)=>o(l,c,"left")},"arm.right":{over:(a,l,c)=>o(l,c,"right")}}}}const Fn={full:{anticipation:.12,anticipationTime:.3,hold:0,overshoot:.08,settle:220,settleEase:"ease-in-out",actionEase:"ease-in-out-cubic",overlap:45,eyeLead:120,eyeDart:160,drift:.12,blinks:!0,jumpSquash:1},snappy:{anticipation:.2,anticipationTime:.35,hold:.12,overshoot:.12,settle:320,settleEase:{type:"elastic",mode:"out",amplitude:1,period:.35},actionEase:"ease-out-cubic",overlap:35,eyeLead:100,eyeDart:100,drift:.1,blinks:!0,jumpSquash:1.3},limited:{anticipation:.06,anticipationTime:.25,hold:0,overshoot:0,settle:0,settleEase:"ease-out",actionEase:"ease-in-out",overlap:30,eyeLead:80,eyeDart:120,drift:0,blinks:!0,jumpSquash:.6},none:{anticipation:0,anticipationTime:0,hold:0,overshoot:0,settle:0,settleEase:"linear",actionEase:"linear",overlap:0,eyeLead:0,eyeDart:0,drift:0,blinks:!1,jumpSquash:0}};function hl(e){if(e===void 0)return Fn.full;if(typeof e=="string")return Fn[e];const{base:t,...n}=e;return{...Fn[t??"full"],...n}}const vs=160,B0=120,N0=700,ks=60,W0=90,Dn=3200,re=1,Rt=1e-6;function Ss(e,t,n={}){const i=hl(n.style),s=n.seed??1,r={};if(e.length===0)return r;const o=Object.keys(e[0].pose).filter(u=>e.some(f=>Math.abs(f.pose[u]-e[0].pose[u])>Rt));for(const u of o)r[u]=K0(u,e,t,i,s);const a=t.blink,l=a!==void 0&&o.includes(a);if(i.blinks&&a!==void 0&&!l&&a in e[0].pose){const u=Y0(e,t,i,s,e[0].pose[a]);u.length>0&&(r[a]=u)}const{lift:c,stretch:h}=t;if(i.jumpSquash>0&&c&&h&&o.includes(c)&&!o.includes(h)&&h in e[0].pose){const u=X0(e,c,e[0].pose[h],i.jumpSquash);u.length>0&&(r[h]=u)}return r}function K0(e,t,n,i,s){const r=n.eyes.includes(e),o=n.limits[e],a=o!==void 0,l=r?-i.eyeLead:(n.depth[e]??1)*i.overlap,c=d=>{const m=(t[d].time-t[d-1].time)/2;return Math.max(-m,Math.min(m,l))},h=[{time:t[0].time,value:t[0].pose[e]}],u=(d,m,p)=>{const g=h[h.length-1];if(d<=g.time+re){h[h.length-1]={...g,value:m,...p?{easing:p}:{}};return}h.push({time:d,value:m,...p?{easing:p}:{}})};let f=t[0].pose[e];for(let d=1;d<t.length;d++){const m=t[d],p=t[d-1].pose[e],g=m.pose[e],y=g-p,w=h[h.length-1].time,v=m.act!==!1;if(Math.abs(y)<=Rt){const A=m.time+(v?c(d):0);if(d===t.length-1)Math.abs(f-g)>Rt&&u(Math.max(A,w+vs),g,"ease-in-out"),f=g;else if(v&&a&&i.drift>0&&n.drift.includes(e)&&A-w>=N0){const _=Ut(`${s}:${e}:${d}`)%2===0?1:-1;f=g+_*i.drift*o,u(A,f,"ease-in-out")}continue}if(!v){u(t[d-1].time,f),u(m.time,g,m.easing),f=g;continue}const M=c(d),S=Math.max(t[d-1].time+M,w);let E=m.time+M;r&&i.eyeDart>0&&(E=Math.min(E,S+i.eyeDart));const k=E-S;if(k<=re){u(m.time,g,m.easing),f=g;continue}u(S,f);const x=Math.sign(y);if(a&&i.anticipation>0&&o>0&&k>=vs){const A=f-x*Math.min(Math.abs(y)*i.anticipation,o),_=S+k*i.anticipationTime;u(_,A,"ease-in-out"),i.hold>0&&u(_+k*i.hold,A)}const T=d+1<t.length?t[d+1].time-m.time:1/0,P=Math.min(i.settle,T/2);if(a&&i.overshoot>0&&o>0&&k>=B0&&P>re){const A=Math.min(Math.abs(y)*i.overshoot,o);u(E,g+x*A,m.easing??i.actionEase),u(E+P,g,i.settleEase)}else u(E,g,m.easing??i.actionEase);f=g}return h}function Y0(e,t,n,i,s){const r=[],o=ks+W0;for(let d=1;d<e.length;d++){const m=e[d-1].pose,p=e[d].pose;Object.entries(t.headTurns).some(([y,w])=>Math.abs((p[y]??0)-(m[y]??0))>w)&&e[d].act!==!1&&r.push(Math.max(e[0].time,e[d-1].time-n.eyeLead))}const a=e[0].time,l=e[e.length-1].time,c=[...r];let h=a+Dn*.6,u=0;for(;h<l;){c.some(p=>Math.abs(p-h)<Dn/2)||r.push(h);const m=(Ut(`${i}:blink:${u++}`)%1e3/1e3-.5)*(Dn*.66);h+=Dn+m}r.sort((d,m)=>d-m);const f=[{time:a,value:s}];for(const d of r){const m=f[f.length-1].time;d+ks<=m+re||(d>m+re&&f.push({time:d,value:s}),f.push({time:d+ks,value:1,easing:"ease-in"}),f.push({time:d+o,value:s,easing:"ease-out"}))}return f.length>1?f:[]}function X0(e,t,n,i){const s=n*(1-.18*i),r=n*(1+.14*i),o=[{time:e[0].time,value:n}],a=(l,c,h)=>{const u=o[o.length-1];l<=u.time+re||o.push({time:l,value:c,...h?{easing:h}:{}})};for(let l=1;l<e.length;l++){const c=e[l-1].pose[t],h=e[l].pose[t],u=e[l-1].time,f=e[l].time,d=f-u;if(!(d<vs||e[l].act===!1)){if(c<=Rt&&h>Rt)a(u,n),a(u+d*.2,s,"ease-out"),a(u+d*.45,r,"ease-out"),a(f,n,"ease-in-out");else if(c>Rt&&h<=Rt){const m=l+1<e.length?e[l+1].time-f:400;a(u+d*.5,n),a(f-Math.min(60,d*.15),r,"ease-in"),a(f,s,"ease-out"),a(f+Math.min(260,m/2),n,{type:"back",mode:"out",overshoot:1.4})}}}return o.length>1?o:[]}const ul={depth:{lean:0,bend:0,rise:0,sit:0,spin:0,stretch:0,turn:0,leftHip:0,rightHip:0,headTilt:1,leftShoulder:1,rightShoulder:1,leftKnee:1,rightKnee:1,leftBrow:1,rightBrow:1,browTilt:1,leftEye:1,rightEye:1,leftElbow:2,rightElbow:2,leftAnkle:2,rightAnkle:2,leftFootOut:2,rightFootOut:2,mouth:2,smile:2,mouthWidth:2,leftWrist:3,rightWrist:3},limits:{lean:10,bend:10,headTilt:12,spin:25,turn:.06,sit:.06,stretch:.08,rise:0,leftShoulder:20,rightShoulder:20,leftElbow:18,rightElbow:18,leftWrist:15,rightWrist:15,leftHip:12,rightHip:12,leftKnee:15,rightKnee:15,leftAnkle:10,rightAnkle:10,leftBrow:.25,rightBrow:.25,leftEye:.15,rightEye:.15},eyes:["lookX","lookY"],blink:"blink",headTurns:{turn:.15,headTilt:8,lookX:.5,spin:45},drift:["lean","bend","headTilt","leftShoulder","rightShoulder","leftElbow","rightElbow"],lift:"rise",stretch:"stretch"};function q0(e){return/^(turn|lean|side|lift|roll|stretch)$/.test(e)?{depth:0,limit:{turn:.06,lean:10,side:8,lift:0,roll:25,stretch:.08}[e]}:/^leg\.\w+\.(swing|spread|rotate)$/.test(e)?{depth:0,limit:12}:/^head\./.test(e)?{depth:1,limit:12}:/^arm\.\w+\.(swing|spread)$/.test(e)?{depth:1,limit:20}:/^leg\.\w+\.knee$/.test(e)?{depth:1,limit:15}:/^(brow\.|browTilt$)/.test(e)?{depth:1,limit:e==="browTilt"?void 0:.25}:/^eye\./.test(e)?{depth:1,limit:.15}:/^arm\.\w+\.(elbow|bend)$/.test(e)?{depth:2,limit:18}:/^leg\.\w+\.(ankle|toeOut)$/.test(e)?{depth:2,limit:10}:/^(mouth|smile|mouthWidth)$/.test(e)?{depth:2}:/^hand\./.test(e)?{depth:3}:{depth:1}}function V0(){const e={},t={};for(const n of Object.keys(z)){const i=q0(n);e[n]=i.depth,i.limit!==void 0&&(t[n]=i.limit)}return{depth:e,limits:t,eyes:["lookX","lookY"],blink:"blink",headTurns:{turn:.15,"head.turn":15,"head.nod":12,lookX:.5,roll:45},drift:["lean","head.tilt","head.nod","arm.left.spread","arm.right.spread","arm.left.elbow","arm.right.elbow"],lift:"lift",stretch:"stretch"}}const fl=V0();function dl(e,t){return Object.entries(t).map(([n,i])=>({id:`${e}-${n}`,target:e,property:n,keyframes:i}))}function pl(e,t,n={}){const i=Gi(t),s=t.map((r,o)=>({time:r.time,pose:{...i[o]},easing:r.easing,act:r.act}));return dl(e,Ss(s,n.rig??ul,n))}function U0(e,t,n={}){const i=n.rest??z,s=gs(t,i),r=t.map((o,a)=>({time:o.time,pose:{...i,...s[a]},easing:o.easing,act:o.act}));return dl(e,Ss(r,n.rig??fl,n))}const ml=U.shocked,z0=U.scared,Bn={take:e=>[{after:140,pose:{stretch:.8,bend:10,lean:e.lean-4,leftShoulder:8,rightShoulder:8,leftEye:.35,rightEye:.35,leftBrow:-.6,rightBrow:-.6,mouth:0},easing:"ease-in-out"},{after:260,pose:{stretch:.78}},{after:360,pose:{rise:.22,stretch:1.35,bend:-14,leftShoulder:150,rightShoulder:150,leftElbow:35,rightElbow:35,leftHip:22,rightHip:22,leftKnee:45,rightKnee:45,...ml,headTilt:0},easing:"ease-out-cubic"},{after:720,pose:{rise:.25,stretch:1.25,bend:-10,leftShoulder:140,rightShoulder:140},easing:"ease-in-out"},{after:900,pose:{rise:0,stretch:.74,bend:12,leftShoulder:70,rightShoulder:70,leftHip:18,rightHip:18,leftKnee:30,rightKnee:30},easing:"ease-in-quad"},{after:1060,pose:{stretch:1.06,bend:-3,leftShoulder:60,rightShoulder:60,leftHip:e.leftHip,rightHip:e.rightHip,leftKnee:e.leftKnee,rightKnee:e.rightKnee},easing:"ease-out"},{after:1260,pose:{stretch:e.stretch,bend:e.bend,...U.surprised,leftShoulder:70,rightShoulder:70,leftElbow:60,rightElbow:60},easing:"ease-in-out"}],doubleTake:e=>[{after:160,pose:{lookX:1,lookY:0},easing:"ease-out"},{after:520,pose:{lookX:-.6,headTilt:e.headTilt-4,smile:.6,mouth:0},easing:"ease-in-out"},{after:1100,pose:{lookX:-.6}},{after:1180,pose:{bend:e.bend-10,headTilt:e.headTilt+10,rise:.05,stretch:1.18,...ml,lookX:1,lookY:0},easing:"ease-out-cubic"},{after:1360,pose:{rise:0,stretch:.88,bend:e.bend+4,headTilt:e.headTilt+4},easing:"ease-in-quad"},{after:1560,pose:{stretch:e.stretch,bend:e.bend,headTilt:e.headTilt},easing:{type:"elastic",mode:"out",amplitude:1,period:.35}}],windUp:()=>[{after:220,pose:{lean:-18,bend:-16,headTilt:-6,leftShoulder:70,leftElbow:-100,rightShoulder:40,rightElbow:100,leftHip:-45,leftKnee:-80,stretch:.92,...U.angry,lookX:1},easing:"ease-out"},{after:620,pose:{lean:-20,bend:-18,stretch:.9}},{after:700,pose:{lean:28,bend:14,headTilt:6,leftShoulder:30,rightShoulder:60,leftHip:30,leftKnee:-30,rightHip:-20,stretch:1.12},easing:"ease-out-cubic"}],land:e=>[{after:120,pose:{rise:0,stretch:.7,bend:14,leftShoulder:75,rightShoulder:75,leftHip:20,rightHip:20,leftKnee:35,rightKnee:35},easing:"ease-in-quad"},{after:300,pose:{stretch:1.05,bend:-4,leftShoulder:e.leftShoulder,rightShoulder:e.rightShoulder},easing:"ease-out"},{after:460,pose:{rise:0,stretch:e.stretch,bend:e.bend,leftHip:N.leftHip,rightHip:N.rightHip,leftKnee:0,rightKnee:0},easing:"ease-in-out"}],tremble:e=>{const t=[{after:80,pose:{...z0,bend:e.bend+8,leftShoulder:40,rightShoulder:40,leftElbow:110,rightElbow:110,stretch:.94},easing:"ease-out"}];for(let n=1;n<=14;n++)t.push({after:80+n*45,pose:{lean:e.lean+(n%2===0?2.5:-2.5),headTilt:e.headTilt+(n%2===0?-2:2)}});return t.push({after:755,pose:{lean:e.lean,headTilt:e.headTilt,bend:e.bend}}),t},deflate:e=>[{after:260,pose:{stretch:1.04,headTilt:e.headTilt+4,leftBrow:.3,rightBrow:.3},easing:"ease-in-out"},{after:900,pose:{...ee.sad,bend:18,stretch:.92,lean:e.lean+5,turn:e.turn,sit:e.sit},easing:"ease-in-out"}]};function gl(e,t){const n=typeof t.from=="string"?ee[t.from]:t.from??N,i=t.speed??1;let s=n;return[{time:t.at,pose:n},...Bn[e](n).map(r=>(s={...s,...r.pose},{time:t.at+r.after*i,pose:s,act:!1,...r.easing?{easing:r.easing}:{}}))]}function yl(e,t=1){const n=Bn[e](N);return n[n.length-1].after*t}function bl(e,t,n={}){if(t.length<2)return;const i=Math.max(1,Math.round(n.lines??3)),s=n.spacing??5,r=n.lineWidth??2,o=n.opacity??.7;e.save(),e.strokeStyle=n.color??"#222",e.lineCap="round";for(let a=0;a<i;a++){const l=(a-(i-1)/2)*s,c=Math.floor(Math.abs(l)/Math.max(s,1)*(t.length/6));for(let h=c+1;h<t.length;h++){const u=t[h-1],f=t[h],d=f.x-u.x,m=f.y-u.y,p=Math.hypot(d,m)||1,g=-m/p,y=d/p,w=1-h/(t.length-1);e.globalAlpha=o*(1-w),e.lineWidth=r*(1-w*.7),e.beginPath(),e.moveTo(u.x+g*l,u.y+y*l),e.lineTo(f.x+g*l,f.y+y*l),e.stroke()}}e.restore()}const j0={hands:[{name:"left hand",at:e=>e.hands.left},{name:"right hand",at:e=>e.hands.right}],toes:[{name:"left toe",at:e=>e.toes.left},{name:"right toe",at:e=>e.toes.right}],head:[{name:"head",at:e=>e.head.center}],body:[{name:"hip",at:e=>e.hip},{name:"neck",at:e=>e.neck}]};function G0(e,t,n,i,s={}){const r=n.stateAt;if(!r)return;const o=s.length??120,a=Math.max(2,Math.round(s.samples??8)),l=Math.max(0,n.time-o);if(n.time-l<1)return;const c=[];for(let d=0;d<a;d++){const m=l+(n.time-l)*d/(a-1);c.push(Ia(t,{time:m,state:r(m)},i).joints)}const h=c[c.length-1].height,u=(s.threshold??1.2)*h,f=(s.parts??["hands","toes","head"]).flatMap(d=>j0[d]);for(const d of f){const m=c.map(d.at);let p=0;for(let w=1;w<m.length;w++)p+=Math.hypot(m[w].x-m[w-1].x,m[w].y-m[w-1].y);const g=p/((n.time-l)/1e3);if(g<=u)continue;const y=Math.min(1,(g-u)/(u*.5));bl(e,m,{...s,opacity:(s.opacity??.7)*y,spacing:s.spacing??h*.02})}}function J0(e,t,n,i={}){if(n<=0||n>=1)return;const s=i.size??40,r=i.seed??1,o=.45+.55*(1-(1-n)**3);e.save(),e.strokeStyle=i.color??"#555",e.lineWidth=Math.max(1,s*.03),e.globalAlpha=Math.min(1,n/.08)*(1-n);for(let a=0;a<5;a++){const l=Ut(`${r}:puff:${a}`)%1e3/1e3,c=a-2,h=t.x+c*s*.3*o,u=t.y-s*(.06+.12*l)*o+Math.abs(c)*s*.03,f=s*(.11+.07*l)*o;e.beginPath(),e.arc(h,u,f,Math.PI*.95,Math.PI*2.05),e.stroke()}e.restore()}function Z0(e,t,n,i={}){if(n<=0||n>=1)return;const s=i.size??40,r=5,o=1-(1-n)**2;e.save(),e.strokeStyle=i.color??"#222",e.lineWidth=Math.max(1,s*.035),e.lineJoin="round",e.globalAlpha=n<.7?1:(1-n)/.3;for(let a=0;a<r;a++){const l=-Math.PI/2+(a-(r-1)/2)*Math.PI/(r+1),c=s*(.3+.7*o),h=t.x+Math.cos(l)*c,u=t.y+Math.sin(l)*c;Q0(e,h,u,s*.14,n*Math.PI+a),e.stroke()}e.restore()}function Q0(e,t,n,i,s){e.beginPath();for(let r=0;r<10;r++){const o=r%2===0?i:i*.45,a=s+r*Math.PI/5-Math.PI/2,l=t+Math.cos(a)*o,c=n+Math.sin(a)*o;r===0?e.moveTo(l,c):e.lineTo(l,c)}e.closePath()}const Mt={rest:{mouth:0,mouthWidth:1},a:{mouth:.75,mouthWidth:1.1},e:{mouth:.45,mouthWidth:1.3},i:{mouth:.28,mouthWidth:1.45},o:{mouth:.6,mouthWidth:.7},u:{mouth:.32,mouthWidth:.55},m:{mouth:0,mouthWidth:.9},f:{mouth:.1,mouthWidth:1.05},l:{mouth:.3,mouthWidth:1},c:{mouth:.2,mouthWidth:1}},Fe=1,Nn=.55,wl=.35,tp=1.6,vl={a:"a",e:"e",i:"i",y:"i",o:"o",u:"u"},kl={m:"m",b:"m",p:"m",f:"f",v:"f",w:"u",q:"u",l:"l",n:"l",d:"l",t:"l"},Sl={अ:"a",आ:"a",इ:"i",ई:"i",उ:"u",ऊ:"u",ऋ:"i",ए:"e",ऐ:"e",ओ:"o",औ:"o",ऍ:"e",ऑ:"o"},Ml={"ा":"a","ि":"i","ी":"i","ु":"u","ू":"u","ृ":"i","े":"e","ै":"e","ो":"o","ौ":"o","ॅ":"e","ॉ":"o"},ep={प:"m",फ:"m",ब:"m",भ:"m",म:"m",व:"u"},np="्",Tl="़",ip=e=>e>="क"&&e<="ह",El=new Set([".",",","!","?",";",":","…","।","॥","—","-"]);function Al(e){const t=[],n=Array.from(e.toLowerCase()),i=(s,r)=>{const o=t[t.length-1];o&&o.viseme===s?o.weight+=r*.5:t.push({viseme:s,weight:r})};for(let s=0;s<n.length;s++){const r=n[s],o=n[s+1];if(El.has(r))i("rest",tp);else if(/\s/.test(r)){const a=t[t.length-1];a&&a.viseme!=="rest"&&t.push({viseme:"c",weight:wl})}else if((r==="o"||r==="e")&&o===r)i(r==="o"?"u":"i",Fe),s++;else if(r in vl)i(vl[r],Fe);else if(r in kl)i(kl[r],Nn);else{if(r==="h")continue;if(/[a-z]/.test(r))i("c",Nn);else if(r in Sl)i(Sl[r],Fe);else if(ip(r)){const a=o===Tl?r==="फ"?"f":void 0:ep[r];i(a??"c",Nn);let l=s+1;n[l]===Tl&&l++;const c=n[l];c===np?s=l:c&&c in Ml?(i(Ml[c],Fe),s=l):(!c||/\s/.test(c)||El.has(c)||i("a",Fe*.6),s=l-1)}else(r==="ं"||r==="ँ")&&i("l",Nn*.6)}}for(;t.length>0&&(t[t.length-1].viseme==="rest"||t[t.length-1].weight===wl);)t.pop();return t}function Ms(e,t={}){const n=t.fields?.mouth??"mouth",i=t.fields?.mouthWidth??"mouthWidth",s=t.energy??1,r=Al(e.text),o=[{time:e.start,value:Mt.rest.mouth}],a=[{time:e.start,value:Mt.rest.mouthWidth}],l=r.reduce((h,u)=>h+u.weight,0),c=e.end-e.start;if(l>0&&c>0){let h=e.start;for(const u of r){const f=c*u.weight/l,d=h+Math.min(f*.4,60);if(d>o[o.length-1].time){const m=Mt[u.viseme];o.push({time:d,value:m.mouth*s,easing:"ease-out"}),a.push({time:d,value:1+(m.mouthWidth-1)*Math.min(1.3,s),easing:"ease-out"})}h+=f}}return e.end>o[o.length-1].time&&(o.push({time:e.end,value:Mt.rest.mouth,easing:"ease-in-out"}),a.push({time:e.end,value:Mt.rest.mouthWidth,easing:"ease-in-out"})),{[n]:o,[i]:a}}function sp(e,t,n={}){const i={};for(const s of[...t].sort((r,o)=>r.start-o.start))for(const[r,o]of Object.entries(Ms(s,n))){const a=i[r]??=[],l=a.length>0?a[a.length-1].time:-1/0;a.push(...o.filter(c=>c.time>l))}return Object.entries(i).map(([s,r])=>({id:`${e}-${s}`,target:e,property:s,keyframes:r}))}function xl(e,t,n,i={}){if(n.length===0)return t;const s=i.fields?.mouth??"mouth",r=i.fields?.mouthWidth??"mouthWidth",o={[s]:Mt.rest.mouth,[r]:Mt.rest.mouthWidth,...i.rest},a=new ge({id:"before-speech",tracks:t}),l=(u,f)=>a.getStateAtTime(f).values.get(e)?.get(u)??o[u],c=[s,r],h=t.filter(u=>u.target!==e||!c.includes(u.property));for(const u of c){const f=t.find(m=>m.target===e&&m.property===u);let d=f?[...f.keyframes]:[{time:0,value:l(u,0)}];for(const m of n){const p=Ms(m,i)[u];p[0]={...p[0],value:l(u,m.start)},p[p.length-1]={...p[p.length-1],value:l(u,m.end)},d=[...d.filter(g=>g.time<m.start||g.time>m.end),...p],d.sort((g,y)=>g.time-y.time)}h.push({id:f?.id??`${e}-${u}`,target:e,property:u,keyframes:d})}return h}const Pl={walk:1e3,bouncy:900,doubleBounce:1100,sneak:1600,strut:1100,tired:1500,run:560},Tt=450,_l=1200,rp=700,oe=320,De=220,op=65,ap=700,Ts=e=>e in Ct,Il=e=>e in Bn,lp=e=>e in ee;function Cl(e){return Math.max(ap,Array.from(e).length*op)}function cp(e,t,n={}){const i=n.from??0,s=n.height??300;let r=i,o=n.facing??1,a=n.start??N,l=0,c=0;const h=[{time:0,pose:a}],u=[{time:0,value:0}],f=[{time:0,value:0}],d=[{time:0,value:0}],m=[{time:0,value:"walk"}],p=[{time:0,value:o}],g=[],y=[],w=(k,x,T,P)=>{a={...a,...x},T&&(a=Ce(a,T)),h.push({time:k,pose:a})},v=(k,x,T)=>(w(k+oe/2,{turn:0},T),p.push({time:k+oe/2,value:o},{time:k+oe/2+1,value:x}),o=x,w(k+oe,{turn:1}),k+oe),M=k=>k<r?-1:1;for(const k of t){const x=Math.max(k.at??c,c===0?0:h[h.length-1].time);let T=x;const P=k.pose??{};if(Ts(k.do)){const A=k.to??r,_=A===r?o:M(A);let I=x;_!==o?I=v(x,_,k.mood):a.turn<1?(I=x+De,w(I,{turn:1,...P},k.mood)):(k.mood||k.pose)&&w(x+De,P,k.mood);const H=Math.abs(A-r)/Qo(k.do,s),R=k.for??Math.max(De*2,H*Pl[k.do]),B=I+R;m.push({time:I,value:k.do}),d.push({time:I,value:0},{time:I+De,value:1,easing:"ease-out"}),d.push({time:B-De,value:1},{time:B,value:0,easing:"ease-in"}),f.push({time:I,value:l},{time:B,value:l+H}),u.push({time:I,value:r-i},{time:B,value:A-i}),l+=H,r=A,w(B,{}),T=B}else if(Il(k.do)){const A=gl(k.do,{at:x,from:k.mood?Ce(a,k.mood):a});h.push(...A),a=A[A.length-1].pose,T=x+yl(k.do)}else if(k.do==="look"||k.do==="face"){const A=k.toward??"viewer",_=k.for??rp;if(A==="viewer")w(x+Tt,{turn:0,lookX:0,lookY:0,...P},k.mood);else if(A==="ahead")w(x+Tt,{turn:k.do==="face"?1:.6,lookX:1,...P},k.mood);else if(A==="back")w(x+Tt,{turn:.2,lookX:-1,...P},k.mood);else{const I=M(A);I!==o&&k.do==="face"?(v(x,I,k.mood),w(x+oe+1,{lookX:1,...P})):I!==o?w(x+Tt,{turn:.25,lookX:-1,...P},k.mood):w(x+Tt,{turn:k.do==="face"?1:.6,lookX:1,...P},k.mood)}T=x+Math.max(_,Tt)}else if(lp(k.do)||k.do==="stand"){const A=k.do==="stand"?N:ee[k.do],_=A.turn!==N.turn?A.turn:a.turn,I=k.mood?U[k.mood]:{lookX:a.lookX,lookY:a.lookY};w(x+Tt,{...A,turn:_,...I,...P}),T=x+(k.for??_l)}else{const A=k.for??(k.say?Cl(k.say):_l);(k.mood||k.pose)&&w(x+Math.min(Tt,A/2),P,k.mood),T=x+A}if(k.say){const A=Ts(k.do)||Il(k.do)?x:x+Math.min(150,(T-x)/4),_=Ts(k.do)?T:Math.max(A+200,T-100);g.push({text:k.say,start:A,end:_}),k.do==="say"&&fp(h,a,A,_)}T>h[h.length-1].time&&h.push({time:T,pose:a}),y.push({start:x,end:T}),c=T}const S=pl(e,up(h),n),E=[{id:`${e}-x`,target:e,property:"x",keyframes:u},{id:`${e}-walk`,target:e,property:"walk",keyframes:f},{id:`${e}-walking`,target:e,property:"walking",keyframes:d},{id:`${e}-gait`,target:e,property:"gait",keyframes:m},{id:`${e}-facing`,target:e,property:"facing",keyframes:p}].filter(k=>k.keyframes.length>1||k.property==="x");return{tracks:[...xl(e,S,g,{energy:n.energy}),...E],duration:c,lines:g,keys:h,beats:y}}const hp=30;function up(e){const t=[];for(const n of e){const i=t[t.length-1];i&&n.time-i.time<hp?t[t.length-1]={...n,time:i.time}:t.push(n)}return t}function fp(e,t,n,i){const r=e.filter(l=>l.time>n),o=e.filter(l=>l.time<=n),a=[];for(let l=n+520,c=0;l<i-520/2;l+=520,c++){const h=c%2===0?3:-2;a.push({time:l,pose:{...t,headTilt:t.headTilt+h,leftBrow:t.leftBrow+(c%2===0?.25:0),rightBrow:t.rightBrow+(c%2===0?.25:0)}})}a.length>0&&a.push({time:i,pose:t}),e.length=0,e.push(...o,...a.filter(l=>!r.some(c=>Math.abs(c.time-l.time)<60)),...r),e.sort((l,c)=>l.time-c.time)}function dp(e){const{timeline:t}=e,n=new _t;for(const[c,h]of Object.entries(e.targets)){const u=typeof h=="string"?document.querySelector(h):h;if(!u)throw new Error(`quickPlay: no element found for target "${c}" (${String(h)})`);n.registerTarget(c,u)}t.onUpdate=c=>{n.applyState(c),e.onUpdate?.(c)},e.onComplete&&(t.onComplete=e.onComplete);let i=null,s=null,r=!1;const o=c=>{if(r)return;const h=s===null?0:c-s;s=c,h>0&&t.tick(h),i=requestAnimationFrame(o)},a=()=>{i!==null||r||(s=null,i=requestAnimationFrame(o))},l=()=>{i!==null&&cancelAnimationFrame(i),i=null,s=null};return n.applyState(t.getStateAtTime(t.currentTime)),e.autoplay!==!1&&(t.play(),a()),{timeline:t,adapter:n,play(){t.play(),a()},pause(){t.pause(),l()},restart(){t.stop(),t.play(),a()},seek(c){t.seek(c*1e3),n.applyState(t.getStateAtTime(t.currentTime))},destroy(){r=!0,l(),t.stop(),n.clearTargets()}}}const pp={timeline:Ih,to(e,t,n){const i=new Pt(n);return i.to(e,t),i},from(e,t,n){const i=new Pt(n);return i.from(e,t),i},fromTo(e,t,n,i){const s=new Pt(i);return s.fromTo(e,t,n),s},set(e,t,n){const i=new Pt(n);return i.set(e,t),i}};function Hl(e,t,n){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(t,n);const i=e.canvas;if(i?.ownerDocument){const s=i.ownerDocument.createElement("canvas");return s.width=t,s.height=n,s}try{return i?.constructor?new i.constructor(t,n):null}catch{return null}}function mp(e,t){const n=e.length/4,i=new Float32Array(n*3),s=Math.min(.999,Math.max(0,t));for(let r=0;r<n;r++){const o=e[r*4]/255,a=e[r*4+1]/255,l=e[r*4+2]/255,c=e[r*4+3]/255,h=Math.max(o,a,l);if(h<=s)continue;const u=(h-s)/(1-s)*c/h;i[r*3]=o*u,i[r*3+1]=a*u,i[r*3+2]=l*u}return i}function $l(e,t,n,i,s){const r=new Float32Array(e.length),o=s?n:t,a=s?t:n,l=(h,u)=>(s?h*t+u:u*t+h)*3,c=i*2+1;for(let h=0;h<o;h++)for(let u=0;u<3;u++){let f=0;for(let d=-i;d<=i;d++)f+=e[l(h,Math.min(a-1,Math.max(0,d)))+u];for(let d=0;d<a;d++){r[l(h,d)+u]=f/c;const m=e[l(h,Math.max(0,d-i))+u],p=e[l(h,Math.min(a-1,d+i+1))+u];f+=p-m}}return r}function Ol(e,t,n,i){const s=Math.max(1,Math.round(i/Math.sqrt(3)));let r=e;for(let o=0;o<3;o++)r=$l(r,t,n,s,!0),r=$l(r,t,n,s,!1);return r}function gp(e,t={}){const n=e.canvas,i=n.width,s=n.height;if(!(i>0&&s>0))return;const r=Math.max(1,Math.round(t.downsample??4)),o=Math.max(1,Math.ceil(i/r)),a=Math.max(1,Math.ceil(s/r)),l=Hl(e,o,a),c=l?.getContext("2d");if(!l||!c)return;c.imageSmoothingEnabled=!0,c.drawImage(e.canvas,0,0,o,a);const h=mp(c.getImageData(0,0,o,a).data,t.threshold??.55),u=(t.radius??Math.max(i,s)*.02)/r,f=Ol(h,o,a,u),d=Ol(h,o,a,u*3),m=t.halo??.6,p=c.createImageData(o,a);for(let g=0;g<o*a;g++){for(let y=0;y<3;y++)p.data[g*4+y]=Math.round(Math.min(1,f[g*3+y]+d[g*3+y]*m)*255);p.data[g*4+3]=255}c.putImageData(p,0,0),e.save(),e.setTransform(1,0,0,1,0,0),e.globalCompositeOperation="lighter",e.globalAlpha=Math.max(0,t.strength??.9),e.imageSmoothingEnabled=!0,e.drawImage(l,0,0,i,s),e.restore()}function yp(e,t,n){const i=n.width??6,s=n.taper??1,r=n.fade??1,o=n.opacity??1,a=n.blend==="add";if(e.save(),t.length>=2){const c=wp(t,i,s,r,o);a?(e.globalCompositeOperation="lighter",Es(e,c,n.color)):vp(e,c,n.color)}const l=t[t.length-1];if(n.head&&l&&n.head.radius>0){a&&(e.globalCompositeOperation="lighter");const c=n.head.color??n.color,h=e.createRadialGradient(l.at.x,l.at.y,0,l.at.x,l.at.y,n.head.radius);h.addColorStop(0,c),h.addColorStop(.35,c),h.addColorStop(1,bp(e,c)),e.globalAlpha=o,e.fillStyle=h,e.beginPath(),e.arc(l.at.x,l.at.y,n.head.radius,0,Math.PI*2),e.fill()}e.restore()}function bp(e,t){e.fillStyle=t;const n=String(e.fillStyle),i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(n);if(i)return`rgba(${parseInt(i[1],16)}, ${parseInt(i[2],16)}, ${parseInt(i[3],16)}, 0)`;const s=/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i.exec(n);return s?`rgba(${s[1]}, ${s[2]}, ${s[3]}, 0)`:"rgba(0, 0, 0, 0)"}function wp(e,t,n,i,s){const r=e.map(c=>({x:c.at.x,y:c.at.y,width:t*(1-n*c.age)})),o=Cr(r),a=Hr(r)??void 0,l=[];for(let c=0;c+1<e.length;c++){const h=(e[c].age+e[c+1].age)/2,u=s*(1-i*h);if(u<=0)continue;const f=c+2===e.length;l.push({corners:[o.left[c],o.left[c+1],o.right[c+1],o.right[c]],alpha:u,...f&&a&&{cap:a}})}return l}function Es(e,t,n){e.fillStyle=n;for(const i of t){const[s,r,o,a]=i.corners;e.globalAlpha=Math.min(1,i.alpha),e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(r.x,r.y),i.cap&&e.arc(i.cap.x,i.cap.y,i.cap.radius,i.cap.start,i.cap.start-Math.PI,!0),e.lineTo(o.x,o.y),e.lineTo(a.x,a.y),e.closePath(),e.fill()}}function vp(e,t,n){const i=typeof e.getTransform=="function"?e.getTransform():null,s=p=>i?{x:i.a*p.x+i.c*p.y+i.e,y:i.b*p.x+i.d*p.y+i.f}:p,r=i?Math.sqrt(Math.abs(i.a*i.d-i.b*i.c)):1,o=t.map(p=>({...p,corners:p.corners.map(s),...p.cap&&{cap:{...p.cap,...s(p.cap),radius:p.cap.radius*r,start:p.cap.start+(i?Math.atan2(i.b,i.a):0)}}}));let a=1/0,l=1/0,c=-1/0,h=-1/0;for(const p of o){const g=p.cap?[{x:p.cap.x-p.cap.radius,y:p.cap.y-p.cap.radius},{x:p.cap.x+p.cap.radius,y:p.cap.y+p.cap.radius}]:[];for(const y of[...p.corners,...g])a=Math.min(a,y.x),l=Math.min(l,y.y),c=Math.max(c,y.x),h=Math.max(h,y.y)}if(!(c>a&&h>l))return;const u=Math.floor(a)-1,f=Math.floor(l)-1,d=i?Hl(e,Math.ceil(c)+1-u,Math.ceil(h)+1-f):null,m=d?.getContext("2d");if(!d||!m){Es(e,t,n);return}m.translate(-u,-f),m.globalCompositeOperation="lighter",Es(m,o,n),e.save(),e.setTransform(1,0,0,1,0,0),e.globalAlpha=1,e.drawImage(d,u,f),e.restore()}const Rl={x:0,y:0,scale:1,rotate:0,shakeX:0,shakeY:0,shakeRotate:0};function kp(e){const t=n=>{const i=e?.get(n);return typeof i=="number"?i:Rl[n]};return{x:t("x"),y:t("y"),scale:t("scale"),rotate:t("rotate"),shakeX:t("shakeX"),shakeY:t("shakeY"),shakeRotate:t("shakeRotate")}}function Sp(e,t,n){const i=n.width/2,s=n.height/2,o=1+2*Math.max(Math.abs(t.shakeX),Math.abs(t.shakeY))/Math.max(1,Math.min(n.width,n.height));e.translate(i+t.x+t.shakeX,s+t.y+t.shakeY),e.rotate((t.rotate+t.shakeRotate)*Math.PI/180),e.scale(t.scale*o,t.scale*o),e.translate(-i,-s)}function Mp(e,t,n){const i=t.width/2,s=t.height/2,r=(e.rotate+e.shakeRotate)*Math.PI/180,o=(n.x-i)*e.scale,a=(n.y-s)*e.scale;return{x:i+e.x+e.shakeX+o*Math.cos(r)-a*Math.sin(r),y:s+e.y+e.shakeY+o*Math.sin(r)+a*Math.cos(r)}}const Tp=Q.to,Ep=Q.from,Ap=Q.fromTo,xp=Q.set,Pp=Q.timeline,_p=Q.ticker,Ip=Q.splitText,Cp=Q.context,Hp=Q.matchMedia,$p=Q.quickTo,Op=Q.imageSequence,Rp=Q.pageTransition;sf(),b.ACTING_STYLES=Fn,b.Clock=Dl,b.CompatTimeline=Pt,b.CustomBounce=Ao,b.CustomEase=Eo,b.CustomWiggle=xo,b.DANCE_STYLES=$t,b.DEFAULT_BAKE_INTERVAL_MS=ri,b.DEFAULT_INERTIA_FRICTION=Un,b.DEFAULT_LABELS=Lo,b.DEFAULT_SPRING=et,b.DEFAULT_TRANSITION=of,b.Draggable=Ti,b.EXPRESSIONS=U,b.FINGERS=zo,b.FLIPS=Pn,b.FORMAT_VERSION=Wn,b.GAGS=Bn,b.GAITS=Ct,b.GAIT_CYCLE_MS=Pl,b.HAND_REST=K,b.HAND_SHAPES=q,b.HUMAN_ACTING_RIG=fl,b.HUMAN_EXPRESSIONS=Gd,b.HUMAN_POSES=Ka,b.HUMAN_REST=z,b.IDENTITY_CAMERA=Rl,b.INERTIA_MAX_DURATION_MS=Ps,b.InertiaTrackPlayer=pr,b.LiveTimeline=ct,b.MORPH_SAMPLES=ac,b.MUDRAS=Zi,b.ManualClock=Fl,b.MediaSync=Di,b.Observer=eo,b.POSES=ee,b.REST_POSE=N,b.SPRING_MAX_DURATION_MS=Vn,b.SPRING_PRESETS=Ye,b.SPRING_STEP_MS=Dt,b.STICK_ACTING_RIG=ul,b.ScrollAnimator=bo,b.ScrollDriver=Ee,b.ScrollMarkers=wo,b.ScrollPin=po,b.SmoothScroll=Ri,b.SpringSampler=ce,b.SpringTrackPlayer=dr,b.Stage=jr,b.Timeline=ge,b.TinyflyPlayer=hn,b.TinyflySequencer=Xo,b.TrackPlayer=Ge,b.VISEMES=Mt,b.ValueResolver=Rc,b.VisibilityDriver=fo,b.actCharacterTracks=U0,b.actKeyframes=Ss,b.actTracks=pl,b.applyBloom=gp,b.applyCamera=Sp,b.applyGroove=$a,b.backOut=Ds,b.bakeDanceTracks=kd,b.bakeEasing=li,b.bakeInertiaTrack=ai,b.bakeSpringTrack=oi,b.basicOutfit=D0,b.beatAt=bd,b.beatAtTime=Ze,b.beatLength=mi,b.beatTime=Je,b.beatsBetween=Uc,b.bindChoiceHotspots=No,b.blendPose=ne,b.boilFrame=Ni,b.bounceOut=Fs,b.cameraFromValues=kp,b.cameraPoint=Mp,b.cameraTracks=Jc,b.character=Za,b.characterAt=v0,b.characterHandPose=tl,b.characterJoints=Qa,b.characterJointsInView=g0,b.characterObjects=x0,b.characterPoseTracks=k0,b.characterTarget=w0,b.charactersFor=mr,b.circlePath=C0,b.clamp01=Ci,b.clearMorphCache=gc,b.clearPathCache=nc,b.clipErased=ws,b.containerProgressAt=Hi,b.context=Cp,b.create=Ku,b.createControls=Do,b.createCubicBezier=Rs,b.createLive=Io,b.createPen=Ki,b.createRandom=ye,b.createTrack=je,b.criticalDamping=Kl,b.customBounce=Ar,b.customEase=Er,b.customWiggle=xr,b.danceFrame=Mn,b.dancePose=dd,b.danceStance=Sn,b.danceTaps=md,b.danceTracks=vd,b.danceTravel=En,b.danceTravelTrack=Da,b.dancer=wd,b.deserializeTimeline=Vt,b.deserializeTrack=wr,b.detectTempo=zc,b.draggable=eu,b.drawCartoonHand=bn,b.drawCharacter=el,b.drawCharacterInView=il,b.drawDustPuff=J0,b.drawEraser=ys,b.drawHand=bs,b.drawImpactStars=Z0,b.drawPencil=ol,b.drawSpeedLines=bl,b.drawStickFigure=xa,b.drawStickSmear=G0,b.drawTrail=yp,b.drawnPathTarget=H0,b.easeIn=Hs,b.easeInCubic=zn,b.easeInOut=Os,b.easeInOutCubic=ue,b.easeInOutQuad=Cs,b.easeInQuad=_s,b.easeOut=$s,b.easeOutCubic=jn,b.easeOutQuad=Is,b.elasticOut=Ls,b.ellipsePoints=Wi,b.erasable=L0,b.expandParametricEasings=ur,b.flipPose=Ba,b.flipTracks=Ld,b.flipTravel=Na,b.formatVersionFor=Kn,b.from=Ep,b.fromJSON=Hc,b.fromTo=Ap,b.gag=gl,b.gagDuration=yl,b.gaitPose=Zo,b.gaitStrideLength=Qo,b.getEasingFunction=G,b.getInterpolator=me,b.getMotionPathPoint=ci,b.getPathLength=ic,b.getPointAtProgress=Ys,b.gridLinesFor=so,b.handAt=I0,b.handJoints=yn,b.handJointsAt=Jo,b.handPose=Y,b.handProp=Oe,b.hasKeyframes=As,b.hashSeed=Ut,b.headPoint=id,b.heldTime=Bl,b.humanFieldLabel=zd,b.humanPlan=Ya,b.humanPose=it,b.imageSequence=Op,b.inertiaDuration=Nt,b.inertiaRest=Bt,b.inertiaValueAt=qe,b.inertiaVelocityAt=Vl,b.interpolateArray=ar,b.interpolateColor=or,b.interpolateMotionPath=xc,b.interpolateNumber=ot,b.interpolatePathString=cr,b.interpolateQuaternion=lr,b.interpolateString=si,b.isCubicBezierEasing=Ft,b.isInertiaTrack=dt,b.isMotionPathPoint=Ll,b.isMotionPathTrack=Yn,b.isParametricEasing=ae,b.isPathData=Kt,b.isSpringTrack=pt,b.isTextTrack=Be,b.isUnderdamped=Wl,b.isUnresolved=Oc,b.jointsInScene=rl,b.jointsToScene=Aa,b.linear=Ve,b.lipSyncKeyframes=Ms,b.lipSyncOver=xl,b.lipSyncTracks=sp,b.live=Q,b.mapEase=Se,b.mat4=lh,b.matchMedia=Hp,b.maxStaggerDistance=qn,b.mirrorHumanPose=Ud,b.mirrorPose=Ha,b.mixHandPoses=te,b.mixPoses=y0,b.morphPath=Gs,b.mount=Wo,b.mountAll=Yo,b.narrationMarkers=Yc,b.narrationSceneAt=Xc,b.naturalRest=he,b.nearestBeat=qc,b.nextBeat=Vc,b.pageTransition=Rp,b.parametricEasing=Ns,b.parseEdge=_i,b.parsePath=At,b.parseTrigger=Ii,b.partialPath=Qt,b.pathLength=qo,b.planNarration=Kc,b.play=Wu,b.playSequence=rf,b.playWhenVisible=pu,b.playheadCrossings=ui,b.pointAlong=fn,b.pointAtDistance=Jn,b.pointOnHead=h0,b.pointsToPath=Ir,b.pose=j,b.poseTracks=ad,b.quat=Sc,b.quickPlay=dp,b.quickTo=$p,b.randomBetween=di,b.randomChoice=$c,b.randomSnapped=kr,b.reachCharacter=b0,b.resolveActingStyle=hl,b.resolveCharacterPoseKeys=gs,b.resolveGait=qi,b.resolvePoseKeys=Gi,b.resolveSequence=Tr,b.resolveStickFrame=ji,b.resolveStickPose=Pa,b.resolveValue=pi,b.ribbon=Cr,b.ribbonHeadCap=Hr,b.rotateAbout=vt,b.routineBeats=Tn,b.rubberLimb=It,b.scriptTracks=cp,b.scrollProgress=du,b.scrubOnScroll=bu,b.scrubPath=O0,b.seatHeight=Jf,b.serializeTimeline=vr,b.serializeTrack=yr,b.set=xp,b.shapeToPathData=Qe,b.simplifyKeyframes=fr,b.skeletonInView=ls,b.sketchPen=dn,b.smoothToward=uo,b.snapAxis=io,b.snapConfig=mo,b.snapDuration=yo,b.snapProgress=go,b.solvePlanSpace=Cn,b.soundsOf=Al,b.speechDuration=Cl,b.splitText=Ip,b.springDuration=xs,b.springValueAt=Nl,b.stagePlanSpace=as,b.staggerDistance=Xn,b.staggerOffset=Ne,b.staggerOffsets=We,b.staggerSpan=le,b.stepsEasing=Bs,b.stickFigureAt=Ia,b.stickFigureJoints=Ea,b.stickFigureTarget=od,b.stickToHuman=Jd,b.strideLength=ra,b.syncMediaElement=Ro,b.talkingMouth=oa,b.taperedLine=pn,b.taperedOutline=Pe,b.textAt=gr,b.tf=pp,b.ticker=_p,b.timeline=Pp,b.to=Tp,b.toJSON=Cc,b.toKeyframedTrack=Ec,b.toKeyframedTracks=Ac,b.trackTargets=bt,b.trailSamples=Qc,b.triggerDistance=jt,b.unmount=ef,b.vec3=eh,b.walkPose=sa,b.withErased=R0,b.withExpression=Ce,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
53
+ `;function rf(e){if(e.getElementById(Vo))return;const t=e.createElement("style");t.id=Vo,t.textContent=sf,e.head.appendChild(t)}function Uo(e,t){const n=Array.from(t.querySelectorAll("[data-tinyfly-choose]"));if(n.length===0)return()=>{};rf(t.ownerDocument);const i=[],s=[];for(const a of n){const l=a.getAttribute("data-tinyfly-choose")??"",c=[],h=(m,p)=>{a.hasAttribute(m)||(a.setAttribute(m,p),c.push(m))};h("role","button"),h("tabindex","0");const u=e.scenarios.find(m=>m.id===l)?.label;u!==void 0&&h("aria-label",u),a.setAttribute("aria-pressed","false"),c.push("aria-pressed"),i.push({element:a,attributes:c});const f=()=>e.setScenario(l),d=m=>{const p=m.key;p!=="Enter"&&p!==" "||(m.preventDefault(),f())};a.addEventListener("click",f),a.addEventListener("keydown",d),s.push(()=>{a.removeEventListener("click",f),a.removeEventListener("keydown",d)})}const r=()=>{for(const{element:a}of i)a.setAttribute("aria-pressed",String(a.getAttribute("data-tinyfly-choose")===e.scenario))},o=e.subscribe(r);return r(),()=>{o();for(const a of s)a();for(const{element:a,attributes:l}of i)for(const c of l)a.removeAttribute(c)}}const mn=new WeakMap,Yi=new WeakMap;let of=0;function He(e,t,n){if(e)try{return JSON.parse(e)}catch(i){console.warn(`tinyfly: invalid ${t} JSON on`,n,i);return}}async function zo(e,t={}){const n=mn.get(e);if(n)return n;const i=Array.from(e.querySelectorAll("script[data-tinyfly-timeline]")),s=i[0],r=e.getAttribute("data-src"),o=lf(e.getAttribute("data-markers")),a=i.length>1||s?.hasAttribute("data-scenario")?af(i,o,e):void 0;if(a&&a.length===0)return;let l=s&&!a?He(s.textContent,"timeline",e):void 0;if(!l&&r&&o){const d=await fetch(r);d.ok&&(l=await d.json())}if(l&&o&&(l=Go(l,o)),!l&&!r&&!a){console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)',e);return}const c=He(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),h={playWhenVisible:!0,...t.player,...c&&{captions:c},...He(e.getAttribute("data-options"),"data-options",e)};hf(e);const u=new pn(e,h),f={element:e,player:u};if(mn.set(e,f),e.setAttribute("data-tinyfly-mounted",""),a){const d=e.getAttribute("data-scenario")??void 0;await u.loadScenarios(a,{initial:a.some(m=>m.id===d)?d:void 0}),Yi.set(e,Uo(u,e))}else await u.load(l??r);if(e.getAttribute("data-controls")!=="false"){const d=He(e.getAttribute("data-labels"),"data-labels",e),m=e.querySelector("figcaption"),p=e.getAttribute("data-scenario-legend"),g=e.getAttribute("data-scenario-control");f.controls=qo(u,e,{...t.controls,...e.getAttribute("data-fullscreen")==="true"?{fullscreen:!0}:{},...g==="slider"||g==="buttons"?{scenarioControl:g}:{},labels:{...t.controls?.labels,...d,...p?{scenario:p}:{}},mount:void 0}),m?e.insertBefore(f.controls.element,m):e.appendChild(f.controls.element)}return f}function af(e,t,n){const i=[];return e.forEach((s,r)=>{const o=He(s.textContent,"timeline",n);if(!o)return;const a=s.getAttribute("data-scenario")||`scenario-${r+1}`;if(i.some(c=>c.id===a)){console.warn(`tinyfly: scenario id "${a}" is used more than once; the later one is skipped`,n);return}const l=s.getAttribute("data-scenario-label")??void 0;i.push({id:a,label:l,timeline:t?Go(o,t):o})}),i}function Go(e,t){return e.config.markers?.length?e:{...e,config:{...e.config,markers:t.map((n,i)=>({id:`step-${i+1}`,time:n}))}}}function lf(e){if(!e)return;const t=e.split(/[\s,]+/).filter(Boolean).map(Number).filter(n=>Number.isFinite(n)&&n>=0).sort((n,i)=>n-i);return t.length>0?t:void 0}async function jo(e=document,t={}){const n=Array.from(e.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(n.map(s=>zo(s,t)))).filter(s=>s!==void 0)}function cf(e){const t=mn.get(e);t&&(Yi.get(e)?.(),Yi.delete(e),t.controls?.destroy(),t.player.destroy(),mn.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function hf(e){const t=e.querySelector("svg");if(!t||t.hasAttribute("role")||t.hasAttribute("aria-hidden"))return;const n=e.getAttribute("data-alt"),i=e.querySelector("figcaption");t.setAttribute("role","img"),n?t.setAttribute("aria-label",n):i&&(i.id||=`tinyfly-caption-${++of}`,t.setAttribute("aria-labelledby",i.id))}function uf(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const t=()=>{jo()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}class Jo{container;containerA;containerB;adapterA;adapterB;timelineA=null;timelineB=null;symbolDefs=new Map;nestedByAdapter=new Map;sequence=null;options;_currentSceneIndex=0;_state="idle";_isPlaying=!1;_isDestroyed=!1;loopIteration=0;animationFrameId;lastTime;transitionTimer;constructor(t,n={}){if(typeof t=="string"){const i=document.querySelector(t);if(!i)throw new Error(`Container not found: ${t}`);this.container=i}else this.container=t;this.options=n,this.container.style.position="relative",this.container.style.overflow="hidden",this.containerA=this.createSceneContainer(),this.containerB=this.createSceneContainer(),this.container.appendChild(this.containerA),this.container.appendChild(this.containerB),this.containerB.style.visibility="hidden",this.adapterA=new Ct,this.adapterB=new Ct}async load(t){let n;if(typeof t=="string"){const i=await fetch(t);if(!i.ok)throw new Error(`Failed to load sequence: ${i.statusText}`);n=await i.json()}else n=t;this.sequence=n,this.symbolDefs.clear();for(const i of n.symbols??[])i.timeline?.tracks?.length&&this.symbolDefs.set(i.id,i.timeline);this.container.style.width=`${n.canvas.width}px`,this.container.style.height=`${n.canvas.height}px`,n.scenes.length>0&&(this.renderScene(n.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(n.scenes[0])),this.options.autoplay&&this.play()}play(){if(!(!this.sequence||this._isDestroyed)&&this.sequence.scenes.length!==0){if(this._isPlaying=!0,this._state==="idle"){if(this._state="playing-scene",this._currentSceneIndex=0,this.timelineA)this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play();else{this.onSceneComplete();return}this.options.onSceneChange?.(0)}else this._state==="playing-scene"&&this.timelineA&&this.timelineA.play();this.startAnimationLoop()}}pause(){this._isPlaying&&(this._isPlaying=!1,this.timelineA&&this.timelineA.pause(),this.timelineB&&this.timelineB.pause(),this.stopAnimationLoop())}stop(){if(this._isPlaying=!1,this._state="idle",this._currentSceneIndex=0,this.loopIteration=0,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.stopAnimationLoop(),this.sequence&&this.sequence.scenes.length>0&&(this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this.renderScene(this.sequence.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(this.sequence.scenes[0]),this.timelineA)){const t=this.timelineA.getStateAtTime(0);this.adapterA.applyState(t),this.applyNested(this.adapterA,0)}}goToScene(t){if(!this.sequence||t<0||t>=this.sequence.scenes.length)return;const n=this._isPlaying;this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this._currentSceneIndex=t,this._state=n?"playing-scene":"idle",this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB);const i=this.sequence.scenes[t];if(this.renderScene(i,this.containerA,this.adapterA),this.timelineA=this.createTimeline(i),this.options.onSceneChange?.(t),n)this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play(),this.startAnimationLoop()):this.onSceneComplete();else if(this.timelineA){const s=this.timelineA.getStateAtTime(0);this.adapterA.applyState(s),this.applyNested(this.adapterA,0)}}destroy(){this._isDestroyed=!0,this._isPlaying=!1,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.adapterA.clearTargets(),this.adapterB.clearTargets();for(const t of this.nestedByAdapter.values())for(const n of t)n.adapter.clearTargets();this.nestedByAdapter.clear(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.timelineA=null,this.timelineB=null,this.containerA.parentNode&&this.containerA.remove(),this.containerB.parentNode&&this.containerB.remove(),this.sequence=null}get currentSceneIndex(){return this._currentSceneIndex}get sceneCount(){return this.sequence?.scenes.length??0}get isPlaying(){return this._isPlaying}get state(){return this._state}createSceneContainer(){const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t}renderScene(t,n,i){n.innerHTML="",i.clearTargets();const s=document.createElement("div");s.style.cssText="position:absolute;inset:0;transform-origin:center center",s.setAttribute("data-tinyfly","Camera"),n.appendChild(s),i.registerTarget("Camera",s);for(const r of t.elements){if(!r.html)continue;const o=document.createElement("div");o.innerHTML=r.html.trim();const a=o.firstElementChild;if(a){s.appendChild(a);const l=a.getAttribute("data-tinyfly");l&&i.registerTarget(l,a)}}this.setupNested(s,i)}setupNested(t,n){const i=[];t.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const r=s.getAttribute("data-tinyfly-symbol");if(!r)return;const o=this.symbolDefs.get(r);if(!o)return;const a=new Ct;s.querySelectorAll("[data-tinyfly]").forEach(l=>{const c=l.getAttribute("data-tinyfly");c&&a.registerTarget(c,l)}),i.push({adapter:a,timeline:zt(o)})}),i.length?this.nestedByAdapter.set(n,i):this.nestedByAdapter.delete(n)}applyNested(t,n){const i=this.nestedByAdapter.get(t);if(i)for(const s of i){const r=s.timeline.duration;s.adapter.applyState(s.timeline.getStateAtTime(r>0?n%r:n))}}clearContainer(t){t.innerHTML=""}createTimeline(t){return t.timeline?zt(t.timeline):null}onSceneComplete(){if(this._isDestroyed||!this.sequence)return;const t=this._currentSceneIndex+1;if(t>=this.sequence.scenes.length){const n=this.options.loop??this.sequence.loop??0;n===-1||n>0&&this.loopIteration<n-1?(this.loopIteration++,this.beginTransitionTo(0)):(this._isPlaying=!1,this._state="idle",this.stopAnimationLoop(),this.options.onComplete?.())}else this.beginTransitionTo(t)}beginTransitionTo(t){if(!this.sequence||this._isDestroyed)return;const n=this.sequence.scenes[t],i=n.transition;if(i.type==="none"||i.duration<=0){this.switchToScene(t);return}this._state="transitioning",this.containerB.style.visibility="visible",this.renderScene(n,this.containerB,this.adapterB),this.timelineB=this.createTimeline(n),this.timelineB&&this.timelineB.play(),this.applyTransition(i.type,i.duration),this.transitionTimer=window.setTimeout(()=>{this.finishTransition(t)},i.duration)}applyTransition(t,n){const i=`${n}ms`,s="ease-in-out";switch(this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),t){case"fade":this.containerB.style.opacity="0";break;case"slide-left":this.containerB.style.transform="translateX(100%)";break;case"slide-right":this.containerB.style.transform="translateX(-100%)";break;case"slide-up":this.containerB.style.transform="translateY(100%)";break;case"slide-down":this.containerB.style.transform="translateY(-100%)";break}switch(this.containerB.offsetHeight,this.containerA.style.transition=`opacity ${i} ${s}, transform ${i} ${s}`,this.containerB.style.transition=`opacity ${i} ${s}, transform ${i} ${s}`,t){case"fade":this.containerA.style.opacity="0",this.containerB.style.opacity="1";break;case"slide-left":this.containerA.style.transform="translateX(-100%)",this.containerB.style.transform="translateX(0)";break;case"slide-right":this.containerA.style.transform="translateX(100%)",this.containerB.style.transform="translateX(0)";break;case"slide-up":this.containerA.style.transform="translateY(-100%)",this.containerB.style.transform="translateY(0)";break;case"slide-down":this.containerA.style.transform="translateY(100%)",this.containerB.style.transform="translateY(0)";break}}resetTransitionStyles(t){t.style.transition="",t.style.opacity="1",t.style.transform=""}finishTransition(t){this.transitionTimer=void 0,this.timelineA&&(this.timelineA.stop(),this.timelineA=null),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const n=this.containerA;this.containerA=this.containerB,this.containerB=n;const i=this.adapterA;this.adapterA=this.adapterB,this.adapterB=i,this.timelineA=this.timelineB,this.timelineB=null,this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.playbackState!=="playing"&&this.timelineA.play()):this.onSceneComplete()}switchToScene(t){if(!this.sequence||this._isDestroyed)return;this.timelineA&&this.timelineA.stop(),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const n=this.sequence.scenes[t];this.renderScene(n,this.containerA,this.adapterA),this.timelineA=this.createTimeline(n),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play()):this.onSceneComplete()}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this._isDestroyed||!this._isPlaying)return;const i=n-(this.lastTime??n);if(this.lastTime=n,this.timelineA&&this.timelineA.playbackState==="playing"){this.timelineA.tick(i);const s=this.timelineA.getStateAtTime(this.timelineA.currentTime);this.adapterA.applyState(s),this.applyNested(this.adapterA,this.timelineA.currentTime)}if(this._state==="transitioning"&&this.timelineB&&this.timelineB.playbackState==="playing"){this.timelineB.tick(i);const s=this.timelineB.getStateAtTime(this.timelineB.currentTime);this.adapterB.applyState(s),this.applyNested(this.adapterB,this.timelineB.currentTime)}this._isPlaying?this.animationFrameId=requestAnimationFrame(t):this.animationFrameId=void 0};this.animationFrameId=requestAnimationFrame(t)}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}}async function ff(e,t,n={}){const i=new Jo(e,{...n,autoplay:!0});return await i.load(t),i}const df={type:"none",duration:0};function Zo(e){let t=0;for(let n=1;n<e.length;n++)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function ee(e,t){const n=Math.min(1,Math.max(0,t));if(e.length<2||n===1)return e.slice();if(n===0)return e.slice(0,1);let i=Zo(e)*n;const s=[e[0]];for(let r=1;r<e.length;r++){const o=e[r-1],a=e[r],l=Math.hypot(a.x-o.x,a.y-o.y);if(l>=i){const c=l===0?0:i/l;return s.push({x:o.x+(a.x-o.x)*c,y:o.y+(a.y-o.y)*c}),s}s.push(a),i-=l}return s}function gn(e,t){const n=ee(e,t);return n[n.length-1]}function Xi(e,t){return t>0?Math.floor(Math.max(0,e)*t/1e3):0}function yn(e,t,n){const i=t.roughness??2,s=Math.max(1,Math.round(t.passes??2)),r=Xi(n,t.boil??8);let o=0;const a=()=>{const f=o++;return d=>Se(Gt(`${t.seed??1}:${r}:${f}:${d}`))},l=(f,d)=>(f.next()*2-1)*d,c=f=>{const d=a(),m=e.lineWidth,p=e.globalAlpha;for(let g=0;g<s;g++)e.lineWidth=g===0?m:m*.55,e.globalAlpha=g===0?p:p*.6,f(d(g));e.lineWidth=m,e.globalAlpha=p},h=(f,d=1)=>{if(f.length<2)return;const m=f.slice(1).map((g,y)=>Math.hypot(g.x-f[y].x,g.y-f[y].y)),p=m.reduce((g,y)=>g+y,0)*Math.min(1,Math.max(0,d));c(g=>{const y=[],w=[];if(f.forEach((M,S)=>{y.push({x:M.x+l(g,i*.5),y:M.y+l(g,i*.5)}),S>0&&w.push([g.next()*2-1,g.next()*2-1])}),p<=0)return;e.beginPath(),e.moveTo(y[0].x,y[0].y);let k=0;for(let M=1;M<y.length;M++){const S=pf(y[M-1],y[M],i,w[M-1]),A=m[M-1];if(k+A<=p){e.bezierCurveTo(S[1].x,S[1].y,S[2].x,S[2].y,S[3].x,S[3].y),k+=A;continue}const E=mf(S,A===0?1:(p-k)/A);e.bezierCurveTo(E[1].x,E[1].y,E[2].x,E[2].y,E[3].x,E[3].y);break}e.stroke()})},u=(f,d,m,p,g=1)=>{c(y=>{const k=y.next()*Math.PI*2,M=Math.PI*2+.15+y.next()*.3,S=[];for(let E=0;E<=14;E++){const T=k+M*E/14,v=l(y,i*.6);S.push({x:f+Math.cos(T)*(m+v),y:d+Math.sin(T)*(p+v)})}const A=ee(S,g);A.length<2||(Qo(e,A),e.stroke())})};return{line:h,curve(f,d=1){if(f.length<2)return;const m=f[0],p=f[f.length-1],g=Math.hypot(p.x-m.x,p.y-m.y)||1,y=-(p.y-m.y)/g,w=(p.x-m.x)/g;c(k=>{const M={x:l(k,i*.5),y:l(k,i*.5)},S={x:l(k,i*.5),y:l(k,i*.5)},A=l(k,i*Math.min(1.5,Math.max(.3,g/80))),E=f.map((v,_)=>{const P=_/(f.length-1),x=Math.sin(Math.PI*P)*A;return{x:v.x+M.x+(S.x-M.x)*P+y*x,y:v.y+M.y+(S.y-M.y)*P+w*x}}),T=ee(E,d);T.length<2||(Qo(e,T),e.stroke())})},circle(f,d,m,p=1){u(f,d,m,m,p)},ellipse:u,nudge(f=.5){const d=a()(0);return{x:l(d,i*f),y:l(d,i*f)}}}}function pf(e,t,n,i){const s=t.x-e.x,r=t.y-e.y,o=Math.hypot(s,r)||1,a=n*Math.min(1.5,Math.max(.3,o/80)),l=-r/o,c=s/o;return[e,{x:e.x+s/3+l*i[0]*a,y:e.y+r/3+c*i[0]*a},{x:e.x+2*s/3+l*i[1]*a,y:e.y+2*r/3+c*i[1]*a},t]}function mf([e,t,n,i],s){const r=(u,f)=>({x:u.x+(f.x-u.x)*s,y:u.y+(f.y-u.y)*s}),o=r(e,t),a=r(t,n),l=r(n,i),c=r(o,a),h=r(a,l);return[e,o,c,r(c,h)]}function Qo(e,t){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length-1;i++){const s={x:(t[i].x+t[i+1].x)/2,y:(t[i].y+t[i+1].y)/2};e.quadraticCurveTo(t[i].x,t[i].y,s.x,s.y)}const n=t[t.length-1];e.lineTo(n.x,n.y)}function $e(e,t,n){const i=e.length;if(i<2)return[];const s=[],r=[],o=a=>t+(n-t)*a/(i-1);return e.forEach((a,l)=>{const c=e[Math.max(0,l-1)],h=e[Math.min(i-1,l+1)],u=Math.hypot(h.x-c.x,h.y-c.y)||1,f=o(l)/2,d=-(h.y-c.y)/u*f,m=(h.x-c.x)/u*f;s.push({x:a.x+d,y:a.y+m}),r.push({x:a.x-d,y:a.y-m})}),[...s,...r.reverse()]}function bn(e,t,n,i){const s=t.length;if(s<2)return;const r=$e(t,n,i),o=a=>n+(i-n)*a/(s-1);e.beginPath(),e.moveTo(r[0].x,r[0].y);for(const a of r.slice(1))e.lineTo(a.x,a.y);e.closePath(),e.fill(),t.forEach((a,l)=>{l!==0&&l!==s-1&&s>3||(e.beginPath(),e.arc(a.x,a.y,o(l)/2,0,Math.PI*2),e.fill())})}function Ht(e,t,n,i,s=16){const r={x:2*t.x-(e.x+n.x)/2,y:2*t.y-(e.y+n.y)/2},o=[];for(let a=0;a<=s;a++){const l=a/s,c=l<.5?{x:e.x+(t.x-e.x)*2*l,y:e.y+(t.y-e.y)*2*l}:{x:t.x+(n.x-t.x)*(2*l-1),y:t.y+(n.y-t.y)*(2*l-1)},h=1-l,u={x:h*h*e.x+2*h*l*r.x+l*l*n.x,y:h*h*e.y+2*h*l*r.y+l*l*n.y};o.push({x:c.x+(u.x-c.x)*i,y:c.y+(u.y-c.y)*i})}return o}function qi(e,t,n,i,s,r=0,o=1,a=40){const l=Math.cos(s),c=Math.sin(s);return Array.from({length:a+1},(h,u)=>{const f=r+Math.PI*2*o*u/a,d=Math.cos(f)*n,m=Math.sin(f)*i;return{x:e+d*l-m*c,y:t+d*c+m*l}})}function Vi(e,t){return t.look==="pencil"?wf(e,t):gf(e,t.ink,t.look)}function wn(e,t,n=!1){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t.slice(1))e.lineTo(i.x,i.y);n&&e.closePath()}function gf(e,t,n){const i=n==="silhouette",s=i?1.25:1;return{look:n,ink:t,limb(r,o,a){e.fillStyle=t,bn(e,r,o*s,a*s)},line(r,o){r.length<2||(e.strokeStyle=t,e.lineWidth=o*s,e.lineCap="round",e.lineJoin="round",wn(e,r),e.stroke())},shape(r,o,a){wn(e,r,!0),(o!==null||i)&&(e.fillStyle=i?t:o,e.fill()),!(a<=0)&&(e.strokeStyle=t,e.lineWidth=a*s,e.lineJoin="round",e.stroke())},ellipse(r,o,a,l,c,h,u){e.beginPath(),e.ellipse(r,o,a,l,c,0,Math.PI*2),(h!==null||i)&&(e.fillStyle=i?t:h,e.fill()),!(u<=0)&&(e.strokeStyle=t,e.lineWidth=u*s,e.stroke())},dot(r,o,a){e.fillStyle=t,e.beginPath(),e.arc(r,o,a*s,0,Math.PI*2),e.fill()},guide(){},guideEllipse(){}}}function yf(e,t){const n=[e[0]];let i=0;for(let o=1;o<e.length;o++){const a=e[o-1],l=e[o],c=Math.hypot(l.x-a.x,l.y-a.y);let h=t-i;for(;h<c;){const u=h/c;n.push({x:a.x+(l.x-a.x)*u,y:a.y+(l.y-a.y)*u}),h+=t}i=c-(h-t)}const s=e[e.length-1],r=n[n.length-1];return Math.hypot(s.x-r.x,s.y-r.y)>t*.25?n.push(s):n[n.length-1]=s,n}function bf(e,t){const n=e.length;return e.map((i,s)=>{const r=e[Math.max(0,s-1)],o=e[Math.min(n-1,s+1)],a=Math.hypot(o.x-r.x,o.y-r.y)||1,l=t(n===1?0:s/(n-1));return{x:i.x-(o.y-r.y)/a*l,y:i.y+(o.x-r.x)/a*l}})}function ta(e){const t=[.6,1.4,2.9].map(i=>({frequency:i*(.8+e.next()*.4),phase:e.next()*Math.PI*2,amount:.5+e.next()*.5})),n=t.reduce((i,s)=>i+s.amount,0);return i=>t.reduce((s,r)=>s+r.amount*Math.sin(Math.PI*2*r.frequency*i+r.phase),0)/n}function wf(e,t){const n=t.pencil??{},i=t.ink,s=n.roughness??Math.max(1,t.lineWidth*.12),r=Math.max(1,Math.round(n.passes??2)),o=Math.min(1,Math.max(0,n.pressure??.25)),a=Math.min(1,Math.max(0,n.rubbedOut??.15)),l=Xi(t.time,n.boil??8);let c=0;const h=(m,p,g=!1)=>Se(Gt(`${t.seed}:${g?"paper":l}:${m}:${p}`)),u=(m,p,g,y,w,k=0)=>{if(m.length<2)return;const M=m.slice(1).reduce((P,x,I)=>P+Math.hypot(x.x-m[I].x,x.y-m[I].y),0);let S=yf(m,Math.max(1.5,Math.min(t.lineWidth*.8,M/24)));if(k>0&&S.length>=2){const[P,x]=[S[S.length-2],S[S.length-1]],I=Math.hypot(x.x-P.x,x.y-P.y)||1;S=[...S,{x:x.x+(x.x-P.x)/I*k,y:x.y+(x.y-P.y)/I*k}]}const A=ta(g),E=ta(g),T=S.length,v=[],_=[];S.forEach((P,x)=>{const I=T===1?0:x/(T-1),C=S[Math.max(0,x-1)],H=S[Math.min(T-1,x+1)],R=Math.hypot(H.x-C.x,H.y-C.y)||1,B=-(H.y-C.y)/R,$=(H.x-C.x)/R,L=A(I)*w,O=Math.min(1,I/.08,(1-I)/.08),D=(.55+.45*Math.sqrt(Math.max(0,O)))*(1+o*E(I)),N=Math.max(.3,p(I)*D/2),K=P.x+B*L,Q=P.y+$*L;v.push({x:K+B*N,y:Q+$*N}),_.push({x:K-B*N,y:Q-$*N})}),e.save(),e.globalAlpha*=y,e.fillStyle=i,wn(e,[...v,..._.reverse()],!0),e.fill(),e.restore()},f=(m,p)=>{const g=c++,y=h(g,99,!0);if(y.next()<a){const S=(y.next()*2-1)*t.lineWidth*1.4,A=(y.next()*2-1)*t.lineWidth*1.4,E=m.map(T=>({x:T.x+S,y:T.y+A}));u(E,T=>p(T)*1.8,h(g,98,!0),.035,s),u(E,T=>p(T)*.45,h(g,97,!0),.12,s*1.5)}const w=m.slice(1).reduce((S,A,E)=>S+Math.hypot(A.x-m[E].x,A.y-m[E].y),0),k=p(.5)>4&&w>p(.5)*6,M=k?[-.3,.3,0]:[0];for(let S=0;S<r;S++){const A=S===0;M.forEach((E,T)=>{const v=h(g,S*10+T),_=E===0?m:bf(m,x=>p(x)*E*Math.sqrt(Math.sin(Math.PI*x))),P=!A&&E===0?t.lineWidth*(.3+v.next()*.8):0;u(_,x=>p(x)*(k?.5:1)*(A?1:.6),v,A?.85:.45,s*(A?.6:1),P)})}},d=(m,p,g,y,w,k)=>{const S=h(c,50).next()*Math.PI*2;f(qi(m,p,g,y,w,S,1.08,48),()=>k)};return{look:"pencil",ink:i,limb(m,p,g){f(m,y=>p+(g-p)*y)},line(m,p){f(m,()=>p)},shape(m,p,g){p!==null&&(e.save(),e.globalAlpha*=.88,e.fillStyle=p,wn(e,m,!0),e.fill(),e.restore()),g>0&&f([...m,m[0]],()=>g)},ellipse(m,p,g,y,w,k,M){k!==null&&(e.save(),e.globalAlpha*=.9,e.fillStyle=k,e.beginPath(),e.ellipse(m,p,g,y,w,0,Math.PI*2),e.fill(),e.restore()),d(m,p,g,y,w,M)},dot(m,p,g){e.save(),e.globalAlpha*=.9,e.fillStyle=i,e.beginPath(),e.arc(m,p,g,0,Math.PI*2),e.fill(),e.restore()},guide(m){if(n.construction===!1||m.length<2)return;const p=c++;u(m,()=>Math.max(.6,t.lineWidth*.18),h(p,0),.28,s*1.2,t.lineWidth)},guideEllipse(m,p,g,y,w){if(n.construction===!1)return;const k=c++,M=h(k,0),S=qi(m,p,g,y,w,M.next()*Math.PI*2,1.12,48);u(S,()=>Math.max(.6,t.lineWidth*.18),M,.28,s*1.5)}}}const ea=["thumb","index","middle","ring","pinky"],Y={"thumb.curl":.15,"thumb.across":.15,"index.curl":.12,"middle.curl":.16,"ring.curl":.2,"pinky.curl":.25,spread:.25,turn:0,bend:0,tilt:0,roll:0};function X(e={}){return{...Y,...e}}const et=(e,t,n,i,s)=>({"thumb.curl":e,"index.curl":t,"middle.curl":n,"ring.curl":i,"pinky.curl":s}),U={relaxed:Y,open:X({...et(0,0,0,0,0),"thumb.across":0,spread:.55}),spread:X({...et(0,0,0,0,0),"thumb.across":0,spread:1}),flat:X({...et(0,0,0,0,0),"thumb.across":.35,spread:0}),fist:X({...et(.7,1,1,1,1),"thumb.across":.9,spread:0}),point:X({...et(.75,0,1,1,1),"thumb.across":.9,spread:0}),thumbsUp:X({...et(0,1,1,1,1),"thumb.across":0,spread:0,roll:70}),peace:X({...et(.75,0,0,1,1),"thumb.across":.9,spread:1}),ok:X({...et(.12,.6,.1,.15,.2),"thumb.across":.55,spread:.6}),pinch:X({...et(.1,.65,.75,.85,.9),"thumb.across":.55,spread:0}),cupped:X({...et(.25,.4,.4,.4,.4),"thumb.across":.4,spread:.05,turn:2}),wave:X({...et(0,.05,.05,.1,.12),"thumb.across":0,spread:.7,turn:2}),pencilGrip:X({...et(.1,.6,.72,.88,.95),"thumb.across":.5,spread:0,turn:.8,bend:10}),hold:X({...et(.5,.7,.72,.74,.76),"thumb.across":.75,spread:0,turn:1})};function ne(e,t,n){const i={...e};for(const[s,r]of Object.entries(t)){const o=e[s]??r;i[s]=o+(r-o)*n}return i}const kf={index:{knuckle:[-.16,.47,-.02],bones:[.2,.125,.1],width:.125,fan:-1},middle:{knuckle:[-.055,.49,-.02],bones:[.22,.135,.1],width:.13,fan:-.2},ring:{knuckle:[.05,.475,-.02],bones:[.2,.125,.1],width:.122,fan:.55},pinky:{knuckle:[.15,.43,-.02],bones:[.16,.1,.085],width:.108,fan:1.25}},vf={index:{knuckle:[-.14,.47,-.02],bones:[.2,.125,.1],width:.15,fan:-1},middle:{knuckle:[0,.49,-.02],bones:[.22,.135,.1],width:.155,fan:0},pinky:{knuckle:[.14,.45,-.02],bones:[.19,.115,.095],width:.145,fan:1}},dt={base:[-.11,.1,-.05],bones:[.2,.15,.12],widths:[.2,.145,.135],out:[-.7,.68,-.22],across:[.35,.5,-.8]},Sf=[82,100,62],Mf=[48,72],Tf=3,Ef=13,Af=.035,xf=-.075,Pf=[[-.17,0],[-.215,.12],[-.235,.26],[-.225,.4],[-.185,.49],[-.075,.525],[.05,.51],[.16,.465],[.215,.4],[.225,.26],[.2,.1],[.16,0]],vt=e=>e*Math.PI/180,Ui=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],kn=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],zi=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Re=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function St(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=zi(t,e),o=t[0]*e[0]+t[1]*e[1]+t[2]*e[2];return[e[0]*i+r[0]*s+t[0]*o*(1-i),e[1]*i+r[1]*s+t[1]*o*(1-i),e[2]*i+r[2]*s+t[2]*o*(1-i)]}const na=[1,0,0],ia=[0,1,0],Oe=[0,0,1];function _f(e,t,n){const i=vt(e.fan*(Tf+Ef*n)),s=[Math.sin(i),Math.cos(i),0],r=[Math.cos(i),-Math.sin(i),0],o=[e.knuckle];let a=0;e.bones.forEach((h,u)=>{a+=vt(Sf[u]*t),o.push(Ui(o[u],kn(St(s,r,-a),h)))});const l=St(Oe,r,-a),c=o.map((h,u)=>e.width*(1-.14*(u/(o.length-1))));return{joints:o,back:l,widths:c}}function If(e,t,n=1,i=1){const s=Math.min(1,Math.max(0,t)),r=Re(Ui(kn(Re(dt.out),1-s),kn(Re(dt.across),s))),o=Re(zi(Oe,r)),a=Re(zi(r,o)),l=[[dt.base[0]*i,dt.base[1],dt.base[2]]];let c=0;dt.bones.forEach((f,d)=>{d>0&&(c+=vt(Mf[d-1]*e)),l.push(Ui(l[d],kn(St(r,o,c),f)))});const h=St(a,o,c),u=[...dt.widths,dt.widths[dt.widths.length-1]*.92].map(f=>f*n);return{joints:l,back:h,widths:u}}function vn(e,t={}){const n={...Y,...e},i=t.size??100,s=t.side??"right",r=s==="left"?-1:1,o=vt(t.angle??0),a=t.fingers===4,l=Math.max(.5,t.plump??1),c=1+(l-1)*.7,h=x=>({...x,knuckle:[x.knuckle[0]*c,x.knuckle[1],x.knuckle[2]],width:x.width*l}),u=vt(n.bend??0),f=vt(n.tilt??0),d=vt(90*(n.turn??0)),m=x=>St(St(St(x,na,-u),Oe,-f),ia,d),p=Math.cos(o),g=Math.sin(o),y=vt(n.roll??0),w=Math.cos(y),k=Math.sin(y),M=x=>{const I=x[0]*i,C=-x[1]*i,H=(I*w-C*k)*r,R=I*k+C*w;return{x:H*p-R*g,y:H*g+R*p}},S=x=>{const I=M(x),C=Math.hypot(I.x,I.y);return C>1e-6*i?{x:I.x/C,y:I.y/C}:{x:0,y:0}},A={thumb:If(n["thumb.curl"]??0,n["thumb.across"]??0,l,c)},E=a?vf:kf;for(const x of ea){const I=E[x];I&&(A[x]=_f(h(I),n[`${x}.curl`]??0,n.spread??0))}const T={};for(const[x,I]of Object.entries(A)){const C=I.joints.map(m),H=m(I.back);T[x]={points:C.map(M),depths:C.map(R=>R[2]*i),widths:I.widths.map(R=>R*i),nail:H[2],back:S(H)}}const v=Pf.flatMap(([x,I])=>[m([x*c,I,Af]),m([x*c,I,xf])]),_=Cf(v.map(M)),P=v.reduce((x,I)=>x+I[2],0)/v.length*i;return{size:i,side:s,wrist:{x:0,y:0},palm:_,palmDepth:P,palmFacing:-m(Oe)[2],fingers:T,axes:{up:S(m(ia)),across:S(m(na)),out:S(m(Oe))},curls:Object.fromEntries(Object.keys(T).map(x=>[x,n[`${x}.curl`]??0]))}}function sa(e,t){const n=s=>({x:s.x+t.x-e.wrist.x,y:s.y+t.y-e.wrist.y}),i={};for(const[s,r]of Object.entries(e.fingers))i[s]={...r,points:r.points.map(n)};return{...e,wrist:n(e.wrist),palm:e.palm.map(n),fingers:i}}function Cf(e){const t=[...e].sort((r,o)=>r.x-o.x||r.y-o.y);if(t.length<3)return t;const n=(r,o,a)=>(o.x-r.x)*(a.y-r.y)-(o.y-r.y)*(a.x-r.x),i=[];for(const r of t){for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}const s=[];for(const r of[...t].reverse()){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],r)<=0;)s.pop();s.push(r)}return[...i.slice(0,-1),...s.slice(0,-1)]}const Hf="#f1c9a5",$f="#2f2f33";function Sn(e,t,n,i={},s=0){const r=sa(vn(n,i),t),o=i.ink??$f,a=i.lineWidth??r.size*.035,l=i.pen??Vi(e,{look:i.look??"clean",ink:o,lineWidth:a,seed:i.seed??1,time:s,pencil:{construction:!1,...i.pencil}}),c=i.skin??Hf,h=i.nails??!0,u=[{depth:r.palmDepth,draw:()=>Rf(l,r,c,a)}];for(const f of Object.values(r.fingers)){const d=f.depths.reduce((m,p)=>m+p,0)/f.depths.length;u.push({depth:d,draw:()=>Of(e,l,f,c,a,h)})}if(i.prop){const f=i.prop;u.push({depth:f.depth,draw:()=>f.draw(l)})}e.save(),e.lineCap="round",e.lineJoin="round";for(const f of[...u].sort((d,m)=>d.depth-m.depth))f.draw();return e.restore(),r}function Rf(e,t,n,i){if(e.shape(t.palm,n,i),t.palmFacing<-.3&&e.look!=="silhouette"){const{up:s}=t.axes;for(const[r,o]of Object.entries(t.fingers)){const a=t.curls[r]??0;if(r==="thumb"||a<.5)continue;const l=o.points[0],c=o.widths[0]*.42,h={x:l.x-s.x*c*.2,y:l.y-s.y*c*.2},u=Math.atan2(s.y,s.x),f=Array.from({length:7},(d,m)=>{const p=u-Math.PI/2+Math.PI*m/6;return{x:h.x+Math.cos(p)*c,y:h.y+Math.sin(p)*c}});e.line(f,i*.6)}}if(t.palmFacing>.45&&e.look!=="silhouette"){const{up:s,across:r}=t.axes,o=t.size,a=t.wrist,l=(h,u)=>({x:a.x+(r.x*h+s.x*u)*o,y:a.y+(r.y*h+s.y*u)*o}),c=t.side==="left"?-1:1;e.line([l(-.15*c,.36),l(-.04*c,.3),l(.1*c,.33)],i*.5)}}function Of(e,t,n,i,s,r){const{widths:o}=n,a=Lf(n.points,2),l=n.points[0],c=a[a.length-1],h=o[0],u=o[o.length-1];if(e.save(),t.look!=="silhouette"){e.beginPath(),e.rect(l.x-1e5,l.y-1e5,2e5,2e5);const p=h/2+s*1.6;e.moveTo(l.x+p,l.y),e.arc(l.x,l.y,p,0,Math.PI*2),e.clip("evenodd")}if(t.limb(a,h+2*s,u+2*s),e.restore(),t.look!=="silhouette"&&(e.fillStyle=i,bn(e,a,h,u)),t.look==="silhouette"||!r||n.nail<.25)return;const f=a[a.length-2],d=Ff({x:c.x-f.x,y:c.y-f.y})??{x:0,y:-1},m={x:c.x-d.x*u*.22+n.back.x*u*.1,y:c.y-d.y*u*.22+n.back.y*u*.1};t.ellipse(m.x,m.y,u*.24*Math.max(.35,n.nail),u*.19,Math.atan2(d.y,d.x),"#f8e3d3",s*.45)}function Lf(e,t){let n=e;for(let i=0;i<t;i++){if(n.length<3)return n;const s=[n[0]];for(let r=0;r<n.length-1;r++){const o=n[r],a=n[r+1];r>0&&s.push({x:o.x*.75+a.x*.25,y:o.y*.75+a.y*.25}),r<n.length-2&&s.push({x:o.x*.25+a.x*.75,y:o.y*.25+a.y*.75})}s.push(n[n.length-1]),n=s}return n}const Ff=e=>{const t=Math.hypot(e.x,e.y);return t>1e-6?{x:e.x/t,y:e.y/t}:null},$t={walk:{swing:24,knee:30,arm:22,elbow:28,lean:4},bouncy:{swing:26,knee:45,arm:34,elbow:30,lean:2,bend:-4,bounce:.035,squash:.06},doubleBounce:{swing:22,knee:40,arm:26,elbow:24,lean:3,bounce:.02,bounces:2,squash:.04},sneak:{swing:28,knee:70,arm:6,elbow:0,forearm:110,shoulder:55,lean:16,bend:14,headTilt:-8,crouch:50,tiptoe:25},strut:{swing:26,knee:30,arm:30,elbow:20,lean:-4,bend:-10,headTilt:-6,sway:4,bounce:.01},tired:{swing:14,knee:14,arm:6,elbow:6,lean:10,bend:16,headTilt:12},run:{swing:40,knee:95,arm:45,elbow:0,forearm:90,lean:16,bend:6,bounce:.05,squash:.06}},Df=40;function Le(e){return e===void 0?$t.walk:typeof e=="string"?$t[e]??$t.walk:e}function ra(e,t,n=W,i=1){const s=Le(e);if(s===$t.walk)return ua(t,n,i);const r=t*Math.PI*2,o=Math.sin(r)*i,a=Math.cos(r)*i,l=y=>y<=Df,c=s.shoulder??0,h=(y,w)=>l(y)?w*c+s.arm*o:y,u=s.forearm??0,f=l(n.leftShoulder)?n.leftElbow-u-s.elbow*Math.max(0,-o):n.leftElbow,d=l(n.rightShoulder)?n.rightElbow+u+s.elbow*Math.max(0,o):n.rightElbow,m=s.bounces??1,p=(1+Math.cos(r*2*m))/2,g=s.crouch??0;return{...n,lean:n.lean+s.lean*i+(s.sway??0)*Math.sin(r)*(1-(n.turn??0)),bend:(n.bend??0)+(s.bend??0),headTilt:n.headTilt-s.lean*.5*i+(s.headTilt??0),leftElbow:f,rightElbow:d,leftHip:-s.swing*o-g*.5,rightHip:-s.swing*o+g*.5,leftKnee:-s.knee*Math.max(0,a)-g,rightKnee:s.knee*Math.max(0,-a)+g,leftAnkle:(n.leftAnkle??0)+(s.tiptoe??0),rightAnkle:(n.rightAnkle??0)+(s.tiptoe??0),leftShoulder:h(n.leftShoulder,-1),rightShoulder:h(n.rightShoulder,1),rise:(n.rise??0)+(s.bounce??0)*i*p,stretch:n.stretch*(1+(s.squash??0)*(p-.5))}}function oa(e,t,n=1){const i=Le(e),s=$t.walk.swing,r=o=>Math.sin(o*Math.PI/180);return fa(t,n)*r(i.swing*n)/r(s*n)}const W={lean:0,bend:0,headTilt:0,leftShoulder:18,rightShoulder:18,leftElbow:-6,rightElbow:-6,leftHip:8,rightHip:8,leftKnee:0,rightKnee:0,leftWrist:0,rightWrist:0,leftAnkle:0,rightAnkle:0,leftFootOut:0,rightFootOut:0,mouth:0,smile:.6,mouthWidth:1,blink:0,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0,stretch:1,turn:0,sit:0,spin:0,rise:0};function j(e){return{...W,...e}}const aa={mouth:0,smile:0,mouthWidth:1,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0},z=e=>({...aa,...e}),G={neutral:aa,happy:z({smile:.9,leftBrow:.2,rightBrow:.2}),joyful:z({mouth:.6,smile:1,mouthWidth:1.2,leftEye:0,rightEye:0,leftBrow:.4,rightBrow:.4}),sad:z({smile:-.8,leftEye:.8,rightEye:.8,browTilt:.9,leftBrow:-.1,rightBrow:-.1,lookY:.6}),crying:z({mouth:.45,smile:-1,leftEye:0,rightEye:0,browTilt:1,lookY:.4}),surprised:z({mouth:.7,mouthWidth:.7,leftEye:1.5,rightEye:1.5,leftBrow:1,rightBrow:1}),shocked:z({mouth:1,mouthWidth:.8,leftEye:1.6,rightEye:1.6,leftBrow:1,rightBrow:1,browTilt:.4}),angry:z({smile:-.6,mouthWidth:.9,leftEye:.8,rightEye:.8,leftBrow:-.6,rightBrow:-.6,browTilt:-1}),furious:z({mouth:.5,smile:-1,mouthWidth:1.3,leftEye:.9,rightEye:.9,leftBrow:-.9,rightBrow:-.9,browTilt:-1}),worried:z({smile:-.3,mouthWidth:.8,leftEye:1.1,rightEye:1.1,leftBrow:.3,rightBrow:.3,browTilt:.8,lookX:-.5}),scared:z({mouth:.35,smile:-.5,mouthWidth:.8,leftEye:1.45,rightEye:1.45,leftBrow:.8,rightBrow:.8,browTilt:.9}),confused:z({smile:-.2,mouthWidth:.8,leftEye:.9,rightEye:1.15,leftBrow:-.3,rightBrow:.8,lookX:.5,lookY:-.4}),skeptical:z({smile:-.1,leftEye:.6,rightEye:1,leftBrow:-.4,rightBrow:.7,lookX:.4}),thinking:z({smile:0,mouthWidth:.7,leftBrow:.3,rightBrow:.5,lookX:.6,lookY:-.8}),sleepy:z({smile:.1,leftEye:.25,rightEye:.25,leftBrow:-.3,rightBrow:-.3,lookY:.5}),disgusted:z({smile:-.7,mouthWidth:.9,leftEye:.6,rightEye:.75,leftBrow:-.5,rightBrow:-.2,browTilt:-.4,lookX:-.6}),smug:z({smile:.6,mouthWidth:.9,leftEye:.6,rightEye:.6,leftBrow:.1,rightBrow:.5,lookX:.5}),wink:z({smile:.9,leftEye:0,rightEye:1,leftBrow:-.2,rightBrow:.3})};function ie(e,t){return{...e,...typeof t=="string"?G[t]:t}}const se={rest:W,wave:j({rightShoulder:135,rightElbow:30,headTilt:6,...G.happy}),cheer:j({leftShoulder:125,leftElbow:20,rightShoulder:125,rightElbow:20,...G.joyful}),shrug:j({leftShoulder:30,leftElbow:85,rightShoulder:30,rightElbow:85,headTilt:-10,...G.confused,lookX:0,lookY:0}),point:j({rightShoulder:90,rightElbow:0,lean:4,smile:.4}),think:j({rightShoulder:60,rightElbow:150,headTilt:10,...G.thinking}),handsOnHips:j({leftShoulder:45,leftElbow:-100,rightShoulder:45,rightElbow:-100,leftHip:14,rightHip:14,smile:.8}),sad:j({leftShoulder:14,rightShoulder:14,leftElbow:-4,rightElbow:-4,headTilt:-14,lean:-3,...G.sad}),surprised:j({leftShoulder:70,leftElbow:60,rightShoulder:70,rightElbow:60,...G.surprised}),crouch:j({stretch:.72,leftShoulder:35,rightShoulder:35,leftElbow:-50,rightElbow:-50,leftHip:22,rightHip:22,headTilt:-4}),sit:j({sit:1,turn:.5,leftShoulder:-25,rightShoulder:25,leftElbow:-55,rightElbow:55}),jump:j({stretch:1.22,leftShoulder:140,rightShoulder:140,leftElbow:20,rightElbow:20,leftHip:4,rightHip:4,...G.joyful}),sideSplit:j({leftHip:90,rightHip:90,leftAnkle:-45,rightAnkle:-45,leftShoulder:120,rightShoulder:120,leftElbow:10,rightElbow:10,...G.happy}),frontSplit:j({turn:1,leftHip:-90,rightHip:-90,leftAnkle:-45,rightAnkle:-45,leftShoulder:-150,rightShoulder:150,leftElbow:10,rightElbow:-10,...G.happy})},la=Object.keys(W);function re(e,t,n){const i={...e};for(const s of la)i[s]=e[s]+(t[s]-e[s])*n;return i}const Gi=24,ca=4,ha=28,Bf=40;function ua(e,t=W,n=1){const i=Math.sin(e*Math.PI*2)*n,s=Math.cos(e*Math.PI*2)*n,r=c=>c<=Bf,o=c=>r(c)?22*i:c,a=r(t.leftShoulder)?t.leftElbow-ha*Math.max(0,-i):t.leftElbow,l=r(t.rightShoulder)?t.rightElbow+ha*Math.max(0,i):t.rightElbow;return{...t,lean:t.lean+ca*n,headTilt:t.headTilt-ca*.5*n,leftElbow:a,rightElbow:l,leftHip:-Gi*i,rightHip:-Gi*i,leftKnee:-30*Math.max(0,s),rightKnee:30*Math.max(0,-s),leftShoulder:o(t.leftShoulder),rightShoulder:o(t.rightShoulder)}}function fa(e,t=1){return 4*((ji+Mn)*e)*Math.sin(Gi*t*Math.PI/180)}function da(e){const t=Math.abs(Math.sin(e/65)),n=.55+.45*Math.sin(e/310);return t*n}const pa=.12,ma=.46,Nf=1-2*pa,Wf=.1,Kf=.21,Yf=.19,ji=.24,Mn=.22,ga=.12,Xf=.14,ya=.33,ba=.7,wa=.3,qf=.35,Vf=[1.7,1.05],Uf=[1.3,.75],ka=[1.45,.85],zf=[1.15,.75],va=.06,Gf=.7,jf=.65,Sa=.075,Jf=.3,Zf=.02,Qf=.012,td=12,ed=.25,Tn=90,nd=.25,id=.04,Ma=.01,Rt=e=>Math.min(1,Math.max(0,e??0));function sd(e,t=1){return Mn*e*t}const Ji=-.12,Ta=.4,rt=e=>e*Math.PI/180,rd=(e,t)=>({x:t*Math.sin(rt(e)),y:Math.cos(rt(e))}),Ea=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),Aa=(e,t,n,i)=>e-.3*t-n*.14*t-Math.max(0,i-1)*.12*t;function od(e,t,n,i,s,r){const o=Math.max(1,Math.min(r*.6,Xf*n)),a=Rt(t.turn),l=(ga+ya*a)*n,c=i+Ji*n,h=l+t.lookX*.08*n,u=t.lookY*.07*n,f=[{x:-.34*n*(1-ba*a),squeeze:1-ba*a,open:t.leftEye,brow:t.leftBrow,side:-1},{x:.34*n*(1-wa*a),squeeze:1-wa*a,open:t.rightEye,brow:t.rightBrow,side:1}];e.fillStyle=s,e.strokeStyle=s,e.lineWidth=o;for(const y of f){const w=Ea(y.open,t.blink);if(w<.2){const A=t.smile>.5?-.12*n:.06*n;e.beginPath(),e.moveTo(y.x+l-.12*n,c),e.quadraticCurveTo(y.x+l,c+A,y.x+l+.12*n,c),e.stroke()}else{if(w>1.2){const E=.13*n*w;e.beginPath(),e.ellipse(y.x+l,c,E*.85,E,0,0,Math.PI*2),e.fillStyle="#ffffff",e.fill(),e.stroke(),e.fillStyle=s}const A=w>1.2?.075*n:.1*n;e.beginPath(),e.ellipse(y.x+h,c+u,A,A*1.1*Math.min(w,1),0,0,Math.PI*2),e.fill()}const k=Aa(c,n,y.brow,w),M=y.x+l-y.side*.13*n*y.squeeze,S=y.x+l+y.side*.13*n*y.squeeze;e.beginPath(),e.moveTo(S,k),e.lineTo(M,k-t.browTilt*.1*n),e.stroke()}const d=i+Ta*n,m=.25*n*Math.max(.3,t.mouthWidth)*(1-qf*a),p=Math.min(1,Math.max(0,t.mouth));if(e.beginPath(),p<=.05){e.moveTo(l-m,d),e.quadraticCurveTo(l,d+t.smile*.25*n,l+m,d),e.stroke();return}const g=.3*n*p;t.smile>.3?(e.moveTo(l-m,d-.05*n),e.lineTo(l+m,d-.05*n),e.quadraticCurveTo(l,d+g*2,l-m,d-.05*n)):t.smile<-.3?(e.moveTo(l-m,d+g*.6),e.lineTo(l+m,d+g*.6),e.quadraticCurveTo(l,d-g*1.4,l-m,d+g*.6)):e.ellipse(l,d,m*.8,g,0,0,Math.PI*2),e.fill()}function xa(e,t){const n=t.height??300,i=Math.min(3,Math.max(.3,e.stretch??1)),s=Math.sqrt(i),r=(t.headSize??2*pa)/2,o=t.headSize===void 0?Nf:1-2*r,a=r*n,l=Rt(e.sit),c=e.leftHip+(-Tn-e.leftHip)*l,h=e.leftKnee+(-Tn-e.leftKnee)*l,u=e.rightHip+(Tn-e.rightHip)*l,f=e.rightKnee+(Tn-e.rightKnee)*l,d=t.classic===!0,m=Rt(e.turn),p=($,L,O,D,N)=>{const K=Math.max(-Math.PI/2,Math.min(Math.PI/2,Math.abs(rt(L-O)/2)+rt(D))),Q=Math.max(-1,Math.min(1,Gf+N)),xt=m+(1-m)*$*Q;return d?{x:0,y:0}:{x:Math.cos(K)*va*xt,y:Math.sin(K)*va}},g={left:e.leftAnkle??0,right:e.rightAnkle??0},y={left:e.leftFootOut??0,right:e.rightFootOut??0};let w=0;if(l>0||!d){const $=(N,K,Q,xt,Dt)=>ji*Math.cos(rt(K))+Mn*Math.cos(rt(K-Q))+Math.max(0,p(N,K,Q,xt,Dt).y),L=Math.max($(-1,c,h,g.left,y.left),$(1,u,f,g.right,y.right)),O=1-Rt((e.rise??0)/id),D=(d?Math.min(1,l/nd):1)*O;w=(ma-L)*D*n*i}const k=-ma*n*i+w,M=-o*n*i+w,S=d?0:(Zf*Rt(e.turn)+Qf*l)*n*i,A=rt(e.bend??0),E={end:_a(k,M,A,1),bend:A};let T;if(A!==0){T=[];for(let $=0;$<=Pa;$++){const L=$/Pa,O=_a(k,M,A,L);T.push({x:O.x-S*Math.sin(Math.PI*L),y:O.y})}}else T=S===0?[{x:0,y:k},{x:0,y:M}]:Ht({x:0,y:k},{x:-S,y:(k+M)/2},{x:0,y:M},1,8);const v=M+Wf*n*i,_=(t.shoulderWidth??0)*n*Math.cos(m*Math.PI/2),P=($,L,O,D,N)=>{const K=rd(O,D);return{x:$+K.x*N*n,y:L+K.y*N*n}},x=($,L,O)=>{const D=P(0,k,L,$,ji*i);return{root:{x:0,y:k},joint:D,end:P(D.x,D.y,L-O,$,Mn*i)}},I=($,L,O)=>{const D={x:$*_,y:v},N=P(D.x,D.y,L,$,Kf*s);return{root:D,joint:N,end:P(N.x,N.y,L+O,$,Yf*s)}},C={left:x(-1,c,h),right:x(1,u,f)},H=($,L,O,D,N,K)=>{const Q=p($,O,D,N,K);return{x:L.end.x+Q.x*n*i,y:L.end.y+Q.y*n*i}},R=($,L,O,D,N)=>P(L.end.x,L.end.y,O+D+N,$,Sa*s),B={left:I(-1,e.leftShoulder,e.leftElbow),right:I(1,e.rightShoulder,e.rightElbow)};return{height:n,facing:(t.facing??1)<0?-1:1,stretch:i,lineWidth:t.lineWidth??n*.025,rubber:Math.min(1,Math.max(d?0:Jf,t.rubber??0)),r:a,headRx:a/Math.sqrt(i),headRy:a*Math.sqrt(i),hipY:k,neckY:M,drop:w,lean:d?e.lean:e.lean+td*Math.sin(Math.PI*l),classic:d,legs:C,toes:{left:H(-1,C.left,c,h,g.left,y.left),right:H(1,C.right,u,f,g.right,y.right)},spine:T,chest:E,arms:B,handTips:{left:R(-1,B.left,e.leftShoulder,e.leftElbow,e.leftWrist??0),right:R(1,B.right,e.rightShoulder,e.rightElbow,e.rightWrist??0)}}}const Pa=10;function _a(e,t,n,i){const s=e-t,r=n*i;if(Math.abs(n)<1e-9)return{x:0,y:e-s*i};const o=s/n;return{x:o*(1-Math.cos(r)),y:e-o*Math.sin(r)}}function ad(e,t){if(e.chest.bend===0)return t;const n=De(t,{x:0,y:e.neckY},e.chest.bend);return{x:n.x+e.chest.end.x,y:n.y+e.chest.end.y-e.neckY}}const Fe=(e,t)=>t===0?[e.root,e.joint,e.end]:Ht(e.root,e.joint,e.end,t);function De(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=e.x-t.x,o=e.y-t.y;return{x:t.x+r*i-o*s,y:t.y+r*s+o*i}}function Ia(e,t,n=!0){const i=cd(e,t),s=t.spin??0,r=t.rise??0;return n&&(s!==0||r!==0)?ld(i,e,s,r):i}function Ca(e,t,n){return{pivot:{x:0,y:e.hipY},angle:e.facing*rt(t),lift:n*e.height}}function ld(e,t,n,i){const{pivot:s,angle:r,lift:o}=Ca(t,n,i),a=f=>{const d=De(f,s,r);return{x:d.x,y:d.y-o}},l=f=>({left:a(f.left),right:a(f.right)}),c={left:Math.max(a(e.feet.left).y,a(e.toes.left).y),right:Math.max(a(e.feet.right).y,a(e.toes.right).y)},h=Math.max(c.left,c.right),u=Ma*t.height;return{...e,hip:a(e.hip),neck:a(e.neck),shoulders:l(e.shoulders),elbows:l(e.elbows),hands:l(e.hands),fingertips:l(e.fingertips),knees:l(e.knees),feet:l(e.feet),toes:l(e.toes),feetY:h,grounded:{left:c.left>=h-u,right:c.right>=h-u},handAngle:{left:e.handAngle.left+r,right:e.handAngle.right+r},limbs:{leftArm:e.limbs.leftArm.map(a),rightArm:e.limbs.rightArm.map(a),leftLeg:e.limbs.leftLeg.map(a),rightLeg:e.limbs.rightLeg.map(a),spine:e.limbs.spine.map(a)},head:{...e.head,center:a(e.head.center),angle:e.head.angle+r}}}function cd(e,t){const n=rt(e.lean),i=rt(t.headTilt),s={x:0,y:e.hipY},r=M=>({x:e.facing*M.x,y:M.y}),o=M=>r(De(M,s,n)),a=M=>o(ad(e,M)),l=M=>a(De({x:M.x,y:M.y+e.neckY},{x:0,y:e.neckY},i)),c=Fe(e.arms.left,e.rubber).map(a),h=Fe(e.arms.right,e.rubber).map(a),u=(M,S)=>Math.atan2(S.y-M.y,S.x-M.x),f={left:a(e.handTips.left),right:a(e.handTips.right)},d=(M,S)=>{const[A,E]=M.slice(-2),T=e.arms[S],v=u(a(T.end),f[S])-u(a(T.joint),a(T.end));return u(A,E)+v};let m=1/0;for(const[M,S]of[[t.leftBrow,t.leftEye],[t.rightBrow,t.rightEye]]){const A=Aa(Ji,1,M,Ea(S,t.blink));m=Math.min(m,A,A-t.browTilt*.1)}const p={left:r(e.legs.left.end),right:r(e.legs.right.end)},g={left:r(e.toes.left),right:r(e.toes.right)},y={left:Math.max(p.left.y,g.left.y),right:Math.max(p.right.y,g.right.y)},w=Math.max(y.left,y.right),k=Ma*e.height;return{facing:e.facing,height:e.height,stretch:e.stretch,lineWidth:e.lineWidth,hip:s,neck:a({x:0,y:e.neckY}),shoulders:{left:a(e.arms.left.root),right:a(e.arms.right.root)},elbows:{left:a(e.arms.left.joint),right:a(e.arms.right.joint)},hands:{left:a(e.arms.left.end),right:a(e.arms.right.end)},knees:{left:r(e.legs.left.joint),right:r(e.legs.right.joint)},feet:p,toes:g,feetY:w,grounded:{left:y.left>=w-k,right:y.right>=w-k},fingertips:f,handAngle:{left:d(c,"left"),right:d(h,"right")},limbs:{leftArm:c,rightArm:h,leftLeg:Fe(e.legs.left,e.rubber).map(r),rightLeg:Fe(e.legs.right,e.rubber).map(r),spine:e.spine.map(o)},head:{center:l({x:0,y:-e.headRy}),rx:e.headRx,ry:e.headRy,angle:e.facing*(n+e.chest.bend+i),eyeY:Ji,browTopY:m,mouthY:Ta,faceX:e.facing*(ga+ya*Rt(t.turn))}}}function Ha(e,t={}){return Ia(xa(e,t),e)}function hd(e,t,n){return De({x:e.center.x+t*e.rx,y:e.center.y+n*e.ry},e.center,e.angle)}function $a(e,t,n){const i=r=>({x:r.x+t,y:r.y+n}),s=r=>({left:i(r.left),right:i(r.right)});return{...e,hip:i(e.hip),neck:i(e.neck),shoulders:s(e.shoulders),elbows:s(e.elbows),hands:s(e.hands),knees:s(e.knees),feet:s(e.feet),toes:s(e.toes),feetY:e.feetY+n,grounded:{...e.grounded},handAngle:{...e.handAngle},limbs:{leftArm:e.limbs.leftArm.map(i),rightArm:e.limbs.rightArm.map(i),leftLeg:e.limbs.leftLeg.map(i),rightLeg:e.limbs.rightLeg.map(i),spine:e.limbs.spine.map(i)},head:{...e.head,center:i(e.head.center)}}}function Ra(e,t,n={},i=0){const s=xa(t,n),r=n.color??"#1e293b",o=n.layers??{},a=n.layers?Ia(s,t,!1):void 0,l=n.sketch?yn(e,n.sketch,i):void 0,c=n.sketch&&n.layers?yn(e,n.sketch,i):void 0,h=E=>{e.save(),E(),e.restore()},u=E=>{E&&a&&h(()=>E(e,a,i,c))},f=()=>e.scale(s.facing,1),d=()=>{f(),e.translate(0,s.hipY),e.rotate(rt(s.lean)),e.translate(0,-s.hipY)},m=()=>{d(),s.chest.bend!==0&&(e.translate(s.chest.end.x,s.chest.end.y),e.rotate(s.chest.bend),e.translate(0,-s.neckY))},p=(E,T,v)=>{if(l)return T?l.curve(E):l.line(E);if(s.classic){e.beginPath(),e.moveTo(E[0].x,E[0].y);for(const _ of E.slice(1))e.lineTo(_.x,_.y);e.stroke();return}bn(e,E,v[0]*s.lineWidth,v[1]*s.lineWidth)},g=(E,T)=>p(Fe(E,s.rubber),s.rubber>0,T),y=E=>{s.classic||p([s.legs[E].end,s.toes[E]],!1,zf)},w=E=>{if(n.hands&&!s.classic)return M(E);if(s.classic||l)return;const T=s.arms[E].end;e.beginPath(),e.arc(T.x,T.y,jf*s.lineWidth,0,Math.PI*2),e.fill()};e.save(),e.strokeStyle=r,e.fillStyle=r,e.lineWidth=s.lineWidth,e.lineCap="round",e.lineJoin="round";const k=Ca(s,t.spin??0,t.rise??0);(k.angle!==0||k.lift!==0)&&(e.translate(0,-k.lift),e.translate(k.pivot.x,k.pivot.y),e.rotate(k.angle),e.translate(-k.pivot.x,-k.pivot.y));function M(E){const T=n.hands??{},v=s.arms[E].end,_=s.handTips[E],P=n.headFill??"#ffffff";Sn(e,v,T[E]??Y,{side:E,angle:Math.atan2(_.x-v.x,v.y-_.y)*180/Math.PI,size:(T.size??Sa)*s.height*Math.sqrt(s.stretch),skin:T.skin??(P==="none"?void 0:P),ink:r,lineWidth:s.lineWidth*.45,fingers:T.fingers,plump:T.plump,look:n.sketch?"pencil":"clean",seed:n.sketch?.seed},i)}const S=E=>{h(()=>{m(),g(s.arms[E],Uf),w(E)});const T=o.sleeve;T&&a&&h(()=>T(e,a,E,i,c))},A=Rt(t.turn)>ed;u(o.behind),h(()=>{f(),g(s.legs.left,ka),y("left"),g(s.legs.right,ka),y("right")}),A&&S("left"),h(()=>{d(),p(s.spine,s.spine.length>2,Vf)}),h(()=>{m();const{left:E,right:T}={left:s.arms.left.root,right:s.arms.right.root};if(E.x!==T.x)if(s.classic)p([E,T],!1,[1,1]);else{const v={x:(E.x+T.x)/2,y:E.y-.3*Math.abs(T.x-E.x)};p(Ht(E,v,T,1,8),!0,[1.1,1.1])}}),u(o.body),A||S("left"),S("right"),u(o.behindHead),h(()=>{m(),e.translate(0,s.neckY),e.rotate(rt(t.headTilt));const E=-s.headRy;e.beginPath(),e.ellipse(0,E,s.headRx,s.headRy,0,0,Math.PI*2);const T=n.headFill??"#ffffff";if(T!=="none"&&(e.fillStyle=T,e.fill()),l){l.ellipse(0,E,s.headRx,s.headRy);const v=l.nudge();e.translate(v.x,v.y)}else e.stroke();e.translate(0,E),e.scale(s.headRx/s.r,s.headRy/s.r),od(e,t,s.r,0,r,s.lineWidth)}),u(o.overHead),u(o.front),e.restore(),n.label&&(e.save(),e.fillStyle=r,e.font=n.labelFont??`700 ${Math.round(s.height*.11)}px sans-serif`,e.textAlign="center",e.textBaseline="bottom",e.fillText(n.label,0,-s.height*s.stretch-.04*s.height+s.drop),e.restore())}function Zi(e,t,n){const i={...e};let s=e.walking>0?re(i,ra(e.gait,e.walk,i),e.walking):i,r=ud(e);const o=e.dancing??0;if(n&&o>0){const a=n(e.beat??0);if(s=re(s,a.pose,o),a.hands){const l=(c,h)=>h?ne(c??Y,h,o):c;r={left:l(r?.left,a.hands.left),right:l(r?.right,a.hands.right)}}}return e.talk>0&&(s={...s,mouth:Math.max(s.mouth,e.talk*da(t))}),{pose:s,hands:r}}function Oa(e,t,n){return Zi(e,t,n).pose}const La=(e,t)=>(e.facing??t.facing??1)<0?-1:1,Be=(e,t)=>`hand.${e}.${t}`;function ud(e){const t=s=>{if(typeof e[Be(s,"spread")]=="number")return Object.fromEntries(Object.keys(Y).map(r=>[r,e[Be(s,r)]]))},n=t("left"),i=t("right");return n||i?{left:n,right:i}:void 0}function fd(e,t){return!t||!e.hands?e:{...e,hands:{...e.hands,left:t.left??e.hands.left,right:t.right??e.hands.right}}}function dd(e){const t=e.style??{},n=t.height??300,i=n*.8,s={...j(e.pose??{}),walk:0,walking:0,gait:"walk",facing:(t.facing??1)<0?-1:1,talk:0,rubber:t.rubber??0,beat:0,dancing:0},r={};if(t.hands)for(const o of["left","right"]){const a=t.hands[o]??Y;for(const l of Object.keys(Y))r[Be(o,l)]=a[l]??Y[l]}return{type:"custom",x:e.x-i/2,y:e.y-n,width:i,height:n,props:{...s,...r},figureStyle:t,figureDance:e.dance,draw(o,a,l){const c=a.props,h=Zi(c,l,e.dance);o.translate(i/2,n),Ra(o,h.pose,fd({...t,rubber:c.rubber,facing:La(c,t)},h.hands),l)}}}function Fa(e,t,n){const i=e.figureStyle;if(!i)throw new Error("stickFigureAt: the target was not made by stickFigureTarget");const s={...e.props};let r=0,o=0;for(const[c,h]of t.state?.values.get(n)??[])c==="gait"&&typeof h=="string"&&(s.gait=h),typeof h=="number"&&(c==="x"||c==="motionPathX"?r=h:c==="y"||c==="motionPathY"?o=h:c in s&&(s[c]=h));const a=Oa(s,t.time,e.figureDance),l=Ha(a,{...i,rubber:s.rubber,facing:La(s,i)});return{pose:a,joints:$a(l,e.x+r+e.width/2,e.y+o+e.height)}}function Qi(e){const t=[];return e.forEach((n,i)=>{const s=i===0?W:t[i-1],r=typeof n.pose=="string"?se[n.pose]:{...s,...n.pose};t.push(n.expression?ie(r,n.expression):r)}),t}function pd(e,t){const n=Qi(t);return la.filter(i=>n.some(s=>s[i]!==W[i])).map(i=>({id:`${e}-${i}`,target:e,property:i,keyframes:t.map((s,r)=>({time:s.time,value:n[r][i],...s.easing?{easing:s.easing}:{}}))}))}const ts=.5,es={pataka:X({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:0,turn:2}),tripataka:X({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":1,"pinky.curl":0,spread:0,turn:2}),alapadma:X({"thumb.curl":.1,"thumb.across":0,"index.curl":.05,"middle.curl":.15,"ring.curl":.25,"pinky.curl":.35,spread:1,turn:2}),mushti:U.fist,shikhara:U.thumbsUp,hamsasya:X({"thumb.curl":.15,"thumb.across":.6,"index.curl":.6,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:.7,turn:2}),katakamukha:X({"thumb.curl":.2,"thumb.across":.6,"index.curl":.65,"middle.curl":.7,"ring.curl":0,"pinky.curl":0,spread:.4,turn:2})};function En(e){return typeof e!="string"?e:e in es?es[e]:U[e]}function Da(e,t,n){const i=[];for(const s of e.keys){const r=i[i.length-1],o=!r||s.reset?{pose:t,...n}:r;i.push({beat:s.beat,pose:{...o.pose,...s.pose},left:s.hands?.left?En(s.hands.left):o.left,right:s.hands?.right?En(s.hands.right):o.right,easing:s.easing??e.easing})}return i}const ns=(e,t)=>(e%t+t)%t;function md(e,t,n,i){const s=Da(e,n,i);if(s.length===0)return{pose:n,hands:i};const r=ns(t,e.beats);let o=s.length-1;for(let d=0;d<s.length;d++)s[d].beat<=r&&(o=d);const a=s[o],l=s[(o+1)%s.length],c=a.beat<=r?a.beat:a.beat-e.beats,h=l.beat>c?l.beat:l.beat+e.beats,u=h>c?(r-c)/(h-c):0,f=J(l.easing??"ease-in-out")(Math.min(1,Math.max(0,u)));return{pose:re(a.pose,l.pose,f),hands:{left:ne(a.left,l.left,f),right:ne(a.right,l.right,f)}}}const gd=[["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"],["leftFootOut","rightFootOut"],["leftEye","rightEye"],["leftBrow","rightBrow"]],yd=["lean","headTilt","lookX","spin"],bd=new Set(["leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee"]);function Ba(e){const t={...e},n=(e.turn??0)>=.5;for(const[i,s]of gd){const r=n&&bd.has(i)?-1:1;t[i]=r*e[s],t[s]=r*e[i]}if(!n)for(const i of yd)t[i]=-e[i];return t}const wd=e=>Math.min(1,Math.max(-1,(.5-e)*4));function Na(e,t,n){const i=ns(n,1),s=(1+Math.cos(2*Math.PI*i))/2,r=t.bounce*(t.accent==="up"?1-s:s),o=Math.min(1,Math.max(0,e.turn??0)),a=wd(o);return{...e,leftHip:e.leftHip+a*r/2,rightHip:e.rightHip+r/2,leftKnee:e.leftKnee+a*r,rightKnee:e.rightKnee+r,lean:e.lean+(t.sway??0)*(1-o)*Math.sin(Math.PI*n)}}function An(e){const t={...W,...e.stance};return e.expression?ie(t,e.expression):t}function Wa(e){return{left:e.hands?.left?En(e.hands.left):Y,right:e.hands?.right?En(e.hands.right):Y}}function is(e,t,n){const i=e.moves[t.move];if(!i)throw new Error(`dance: "${e.label}" has no move "${t.move}"`);const s=md(i,n,An(e),Wa(e));return t.mirror?{pose:Ba(s.pose),hands:{left:s.hands?.right,right:s.hands?.left}}:s}function xn(e,t,n={}){const i=typeof e=="string"?Ot[e]:e;let s;if(n.move)s=is(i,{move:n.move,mirror:n.mirror},t);else{const r=i.routine,o=r.reduce((u,f)=>u+f.beats,0),a=ns(t,o);let l=0,c=0;for(;c<r.length-1&&a>=l+r[c].beats;)l+=r[c++].beats;const h=a-l;if(s=is(i,r[c],h),h<ts&&r.length>1&&t>=ts){const u=r[(c-1+r.length)%r.length],f=is(i,u,u.beats+h),d=J("ease-in-out")(h/ts);s={pose:re(f.pose,s.pose,d),hands:{left:ne(f.hands.left,s.hands.left,d),right:ne(f.hands.right,s.hands.right,d)}}}}return{...s,pose:Na(s.pose,i.groove,t)}}function kd(e,t,n={}){return xn(e,t,n).pose}function Pn(e){return(typeof e=="string"?Ot[e]:e).routine.reduce((n,i)=>n+i.beats,0)}const vd={leftToe:"rightToe",rightToe:"leftToe",leftHeel:"rightHeel",rightHeel:"leftHeel"};function Ka(e,t,n,i,s,r,o){for(let a=0;a*e.beats<n;a++)for(const l of e.keys){const c=a*e.beats+l.beat,h=t+c;if(!(c>=n||h<r||h>=o))for(const u of l.taps??[])s.push({beat:h,tap:i?vd[u]:u})}}function Sd(e,t,n,i={}){const s=typeof e=="string"?Ot[e]:e,r=[];if(n<=t)return r;if(i.move){const o=s.moves[i.move],a=Math.floor(t/o.beats)*o.beats;Ka(o,a,Math.ceil((n-a)/o.beats)*o.beats,i.mirror,r,t,n)}else{const o=Pn(s);for(let a=Math.floor(t/o)*o;a<n;a+=o){let l=a;for(const c of s.routine)Ka(s.moves[c.move],l,c.beats,c.mirror,r,t,n),l+=c.beats}}return r.sort((o,a)=>o.beat-a.beat)}function Ya(e,t){const n=e.moves[t.move];if(!n?.travel)return 0;const i=n.travel/n.beats;return t.mirror?(Da(n,An(e),Wa(e))[0]?.pose.turn??An(e).turn??0)>=.5?i:-i:i}function Xa(e,t){return t.move?[{move:t.move,beats:e.moves[t.move].beats,mirror:t.mirror}]:e.routine}function _n(e,t,n={}){const i=typeof e=="string"?Ot[e]:e,s=Xa(i,n),r=s.reduce((h,u)=>h+u.beats,0),o=s.reduce((h,u)=>h+Ya(i,u)*u.beats,0),a=Math.floor(t/r);let l=a*o,c=t-a*r;for(const h of s){const u=Math.min(h.beats,c);if(l+=Ya(i,h)*u,c-=u,c<=0)break}return l}function Md(e,t,n){const i=Xa(e,n),s=[0];let r=0;for(let o=0;r<t;o=(o+1)%i.length)r+=i[o].beats,s.push(Math.min(r,t));return s}const Td=8;function qa(e,t,n){const i=typeof t=="string"?Ot[t]:t,s=n.bpm??i.bpm,r=n.beats??(n.move?i.moves[n.move].beats:Pn(i)),o=Md(i,r,n);if(o.every(y=>_n(i,y,n)===0))return;const a=Math.min(n.fade??1,r/2),l=J("ease-in-out"),c=y=>a<=0?1:Math.min(l(Math.min(1,y/a)),l(Math.min(1,(r-y)/a))),h=Math.ceil(a*Td),u=a<=0?[]:Array.from({length:h+1},(y,w)=>[w/h*a,r-w/h*a]).flat(),f=[...new Set([...o,...u])].sort((y,w)=>y-w);let d=0;const m=f.map((y,w)=>{if(w>0){const k=f[w-1],M=Math.max(1,Math.ceil((y-k)*16));for(let S=0;S<M;S++){const A=k+(y-k)*S/M,E=k+(y-k)*(S+1)/M;d+=(_n(i,E,n)-_n(i,A,n))*c((A+E)/2)}}return{beat:y,travel:d}}),p=n.start??0,g=n.x??0;return{id:`${e}-x`,target:e,property:"x",keyframes:m.map(y=>({time:p+y.beat*6e4/s,value:g+n.height*y.travel,easing:"linear"}))}}function Ed(e,t,n=0){return(e-n)*t/6e4}function Ad(e,t={}){return n=>xn(e,n,t)}function xd(e,t){const n=t.start??0,i=6e4/t.bpm,s=n+t.beats*i,r=Math.min((t.fade??1)*i,(s-n)/2);return[{id:`${e}-beat`,target:e,property:"beat",keyframes:[{time:n,value:0},{time:s,value:t.beats,easing:"linear"}]},{id:`${e}-dancing`,target:e,property:"dancing",keyframes:[{time:n,value:0},{time:n+r,value:1,easing:"ease-in-out"},{time:s-r,value:1},{time:s,value:0,easing:"ease-in-out"}]}]}function Pd(e,t,n={}){const i=typeof t=="string"?Ot[t]:t,s=n.bpm??i.bpm,r=n.beats??(n.move?i.moves[n.move].beats:Pn(i)),o=n.samplesPerBeat??4,a=n.start??0,l=Math.round(r*o),c=Array.from({length:l+1},(p,g)=>{const y=g/o;return{time:a+y*6e4/s,frame:xn(i,y,n)}}),h=(p,g)=>({id:`${e}-${p}`,target:e,property:p,keyframes:c.map(y=>({time:y.time,value:g(y.frame)}))}),f=Object.keys(W).filter(p=>c.some(g=>g.frame.pose[p]!==c[0].frame.pose[p])||c[0].frame.pose[p]!==W[p]).map(p=>h(p,g=>g.pose[p])),d=n.height===void 0?void 0:qa(e,i,{...n,bpm:s,beats:r,start:a,height:n.height,fade:0});if(d&&f.push(d),n.hands===!1)return f;const m=[];for(const p of["left","right"])for(const g of Object.keys(Y)){const y=w=>w.hands?.[p]?.[g]??Y[g];c.some(w=>y(w.frame)!==Y[g])&&m.push(h(Be(p,g),y))}return[...f,...m]}const Ne={type:"back",mode:"out",overshoot:1.1},Z="ease-out-cubic",_d={label:"Disco",bpm:120,stance:{leftHip:10,rightHip:10,leftKnee:6,rightKnee:6},expression:{smile:.9,mouth:.15,leftBrow:.3,rightBrow:.3},groove:{bounce:10,accent:"down",sway:2},moves:{point:{label:"The point",beats:2,easing:Z,keys:[{beat:0,pose:{rightShoulder:150,rightElbow:0,rightWrist:0,leftShoulder:40,leftElbow:-105,leftWrist:-20,lean:-5,headTilt:8,rightHip:18,leftHip:6,lookX:.6,lookY:-.7},hands:{right:"point",left:"fist"}},{beat:1,pose:{rightShoulder:-30,rightWrist:10,lean:5,headTilt:-6,rightHip:6,leftHip:18,lookX:-.4,lookY:.6}}]},roll:{label:"Roll the arms",beats:2,easing:"linear",keys:[{beat:0,pose:{leftShoulder:42,leftElbow:-128,rightShoulder:26,rightElbow:-100,rightHip:18,leftHip:6,lean:-3},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{leftShoulder:26,leftElbow:-100,rightShoulder:42,rightElbow:-128}},{beat:1,pose:{leftShoulder:42,leftElbow:-128,rightShoulder:26,rightElbow:-100,rightHip:6,leftHip:18,lean:3}},{beat:1.5,pose:{leftShoulder:26,leftElbow:-100,rightShoulder:42,rightElbow:-128}}]},bump:{label:"Bump and clap",beats:4,keys:[{beat:0,pose:{lean:-10,rightHip:22,leftHip:4,leftShoulder:140,rightShoulder:140,leftElbow:0,rightElbow:0,leftWrist:20,rightWrist:20},hands:{left:"spread",right:"spread"},easing:Z},{beat:1,pose:{lean:0,rightHip:10,leftHip:10,leftShoulder:168,rightShoulder:168,leftElbow:22,rightElbow:22,leftWrist:0,rightWrist:0},hands:{left:"flat",right:"flat"}},{beat:2,pose:{lean:10,rightHip:4,leftHip:22,leftShoulder:140,rightShoulder:140,leftElbow:0,rightElbow:0,leftWrist:20,rightWrist:20},hands:{left:"spread",right:"spread"},easing:Z},{beat:3,pose:{lean:0,rightHip:10,leftHip:10,leftShoulder:168,rightShoulder:168,leftElbow:22,rightElbow:22,leftWrist:0,rightWrist:0},hands:{left:"flat",right:"flat"}}]}},routine:[{move:"point",beats:8},{move:"roll",beats:4},{move:"point",beats:8,mirror:!0},{move:"bump",beats:8}]},Id={label:"Hip hop",bpm:95,stance:{leftHip:14,rightHip:14,leftKnee:20,rightKnee:20,leftShoulder:22,rightShoulder:22,leftElbow:-30,rightElbow:-30,leftFootOut:.15,rightFootOut:.15},expression:"smug",hands:{left:"relaxed",right:"relaxed"},groove:{bounce:18,accent:"down"},moves:{bounce:{label:"Bounce",beats:2,keys:[{beat:0,pose:{leftShoulder:30,rightShoulder:30,leftElbow:-50,rightElbow:-50,lean:-3,headTilt:-5,leftWrist:-20,rightWrist:-20}},{beat:1,pose:{leftShoulder:14,rightShoulder:14,leftElbow:-18,rightElbow:-18,lean:3,headTilt:5,leftWrist:0,rightWrist:0}}]},runningMan:{label:"Running man",beats:2,keys:[{beat:0,reset:!0,pose:{turn:.85,leftHip:-84,leftKnee:-112,leftAnkle:25,rightHip:-26,rightKnee:8,leftShoulder:35,leftElbow:-50,rightShoulder:45,rightElbow:75,lean:6},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{leftHip:-4,leftKnee:-18,leftAnkle:0,rightHip:4,rightKnee:18,leftShoulder:5,leftElbow:-40,rightShoulder:5,rightElbow:40}},{beat:1,pose:{rightHip:84,rightKnee:112,rightAnkle:25,leftHip:26,leftKnee:-8,rightShoulder:-35,rightElbow:50,leftShoulder:-45,leftElbow:-75}},{beat:1.5,pose:{rightHip:4,rightKnee:18,rightAnkle:0,leftHip:-4,leftKnee:-18,rightShoulder:-5,rightElbow:40,leftShoulder:-5,leftElbow:-40}}]},armWave:{label:"Arm wave",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:90,rightShoulder:90,leftElbow:0,rightElbow:0},hands:{left:"flat",right:"flat"}},{beat:.5,pose:{leftWrist:45,leftElbow:-15}},{beat:1,pose:{leftWrist:-35,leftElbow:40,leftShoulder:84}},{beat:1.5,pose:{leftWrist:0,leftElbow:-10,leftShoulder:102,headTilt:-8}},{beat:2,pose:{leftElbow:0,leftShoulder:90,rightShoulder:102,headTilt:8}},{beat:2.5,pose:{rightShoulder:84,rightElbow:40,headTilt:0}},{beat:3,pose:{rightElbow:-15,rightWrist:45}},{beat:3.5,pose:{rightElbow:0,rightWrist:-35}}]}},routine:[{move:"bounce",beats:8},{move:"runningMan",beats:8},{move:"armWave",beats:8},{move:"bounce",beats:4}]},Cd={label:"Breaking (toprock)",bpm:110,stance:{leftHip:14,rightHip:14,leftKnee:14,rightKnee:14,leftShoulder:35,rightShoulder:35,leftElbow:-90,rightElbow:-90},expression:{smile:.3,leftBrow:-.3,rightBrow:-.3,browTilt:-.3},hands:{left:"fist",right:"fist"},groove:{bounce:8,accent:"down"},moves:{toprock:{label:"Toprock (Indian step)",beats:4,keys:[{beat:0,pose:{rightHip:-24,rightKnee:10,leftHip:10,leftShoulder:80,leftElbow:40,rightShoulder:55,rightElbow:-50,lean:6,headTilt:-6},easing:Z},{beat:1,reset:!0,pose:{leftHip:18,rightHip:18}},{beat:2,pose:{leftHip:-24,leftKnee:10,rightHip:10,rightShoulder:80,rightElbow:40,leftShoulder:55,leftElbow:-50,lean:-6,headTilt:6},easing:Z},{beat:3,reset:!0,pose:{leftHip:18,rightHip:18}}]},kick:{label:"Kick out",beats:2,keys:[{beat:0,pose:{rightHip:72,rightKnee:4,rightAnkle:-20,leftHip:4,lean:-12,leftShoulder:100,leftElbow:20},easing:Z},{beat:1,reset:!0}]},freeze:{label:"B-boy stance",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:26,leftElbow:-122,rightShoulder:22,rightElbow:-118,leftHip:18,rightHip:18,leftKnee:6,rightKnee:6,lean:-4,headTilt:10,smile:.6,leftEye:.6,rightEye:.6},easing:Ne},{beat:2,pose:{headTilt:14,lean:-6}}]}},routine:[{move:"toprock",beats:8},{move:"kick",beats:4},{move:"toprock",beats:8},{move:"kick",beats:4,mirror:!0},{move:"freeze",beats:4}]},Hd={label:"Jazz",bpm:130,stance:{leftHip:10,rightHip:10},expression:{mouth:.55,smile:1,mouthWidth:1.2,leftBrow:.6,rightBrow:.6},hands:{left:"spread",right:"spread"},groove:{bounce:6,accent:"up"},moves:{jazzHands:{label:"Jazz hands",beats:2,easing:"linear",keys:[0,.25,.5,.75,1,1.25,1.5,1.75].map((e,t)=>({beat:e,pose:{leftShoulder:128,rightShoulder:128,leftElbow:8,rightElbow:8,leftWrist:t%2?4:26,rightWrist:t%2?26:4,leftHip:16,rightHip:16,leftKnee:e<1?26:8,rightKnee:e<1?26:8},hands:t===0?{left:{...U.spread,turn:2},right:{...U.spread,turn:2}}:void 0}))},kickBallChange:{label:"Kick ball change",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:88,rightKnee:0,rightAnkle:55,leftHip:4,lean:-12,leftShoulder:112,rightShoulder:112,leftWrist:15,rightWrist:15},hands:{left:"flat",right:"flat"},easing:Z},{beat:1,reset:!0,pose:{rightHip:10,rightKnee:24,rightAnkle:45,leftShoulder:60,rightShoulder:60,leftElbow:-20,rightElbow:-20}},{beat:1.5,pose:{rightAnkle:0,rightKnee:6,leftAnkle:45,leftKnee:20}}]},splitDrop:{label:"Drop into the splits",beats:8,keys:[{beat:0,reset:!0},{beat:2,reset:!0,pose:{leftHip:90,rightHip:90,leftKnee:0,rightKnee:0,leftAnkle:-45,rightAnkle:-45,leftShoulder:125,rightShoulder:125,leftElbow:10,rightElbow:10},easing:"ease-in-out-cubic"},{beat:4,pose:{leftShoulder:95,rightShoulder:95,leftElbow:0,rightElbow:0,leftWrist:50,rightWrist:50,headTilt:8}},{beat:6,reset:!0,pose:{leftHip:30,rightHip:30,leftKnee:60,rightKnee:60,leftShoulder:40,rightShoulder:40},easing:"ease-in-out-cubic"},{beat:7.5,reset:!0}]},jazzSquare:{label:"Jazz square",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:-18,leftHip:8,leftShoulder:38,rightShoulder:46,leftElbow:100,rightElbow:96,lean:4},hands:{left:"pinch",right:"pinch"}},{beat:1,pose:{leftHip:18,rightHip:6,leftShoulder:46,rightShoulder:38,lean:-4}},{beat:2,pose:{rightHip:22,leftHip:6,leftShoulder:38,rightShoulder:46,lean:4}},{beat:3,pose:{leftHip:10,rightHip:10,leftShoulder:46,rightShoulder:38,lean:0}}]}},routine:[{move:"jazzHands",beats:4},{move:"kickBallChange",beats:4},{move:"kickBallChange",beats:4,mirror:!0},{move:"jazzSquare",beats:8},{move:"jazzHands",beats:4},{move:"splitDrop",beats:8}]},$d={label:"K-pop",bpm:125,stance:{leftHip:9,rightHip:9,leftKnee:4,rightKnee:4},expression:"happy",groove:{bounce:5,accent:"down"},moves:{pointCombo:{label:"Point combo",beats:4,easing:Ne,keys:[{beat:0,reset:!0,pose:{rightShoulder:142,rightElbow:0,leftShoulder:25,leftElbow:-125,headTilt:6,lean:-3,lookX:.6,lookY:-.6},hands:{right:"point",left:"flat"}},{beat:1,pose:{rightShoulder:-38,headTilt:-6,lean:3,lookX:-.3,lookY:.5,rightHip:18}},{beat:2,reset:!0,pose:{leftShoulder:36,leftElbow:-96,rightShoulder:36,rightElbow:-96,leftWrist:20,rightWrist:20},hands:{left:"fist",right:"fist"}},{beat:3,reset:!0,pose:{leftShoulder:96,rightShoulder:96,leftElbow:0,rightElbow:0,leftWrist:50,rightWrist:50,headTilt:8,leftHip:18,rightHip:18},hands:{left:"flat",right:"flat"}}]},heart:{label:"Big heart, finger heart",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:165,rightShoulder:165,leftElbow:46,rightElbow:46,headTilt:-8,lean:-4},hands:{left:"cupped",right:"cupped"},easing:Ne},{beat:1,pose:{headTilt:8,lean:4}},{beat:2,reset:!0,pose:{rightShoulder:32,rightElbow:112,rightWrist:10,leftShoulder:20,leftElbow:-30,headTilt:10,leftEye:0,smile:1},hands:{right:"pinch",left:"relaxed"},easing:Ne},{beat:3,pose:{headTilt:4}}]},isolations:{label:"Isolations",beats:2,easing:Z,keys:[{beat:0,reset:!0,pose:{lean:-9,headTilt:11,leftShoulder:55,leftElbow:-112,rightShoulder:55,rightElbow:-112,rightHip:18},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{lean:0,headTilt:0,rightHip:9}},{beat:1,pose:{lean:9,headTilt:-11,leftHip:18}},{beat:1.5,pose:{lean:0,headTilt:0,leftHip:9}}]}},routine:[{move:"pointCombo",beats:8},{move:"isolations",beats:4},{move:"heart",beats:8},{move:"pointCombo",beats:8,mirror:!0},{move:"isolations",beats:4}]},Rd={label:"Bollywood",bpm:120,stance:{leftHip:10,rightHip:10},expression:{smile:1,mouth:.3,leftBrow:.4,rightBrow:.4},groove:{bounce:8,accent:"down",sway:3},moves:{lightBulb:{label:"Screw the bulb, pat the dog",beats:2,keys:[{beat:0,reset:!0,pose:{rightShoulder:160,rightElbow:12,rightWrist:-15,leftShoulder:40,leftElbow:-12,leftWrist:-45,lean:-4,rightHip:16,lookX:.5,lookY:-.6},hands:{right:{...U.cupped,roll:-30},left:{...U.flat,turn:0}}},{beat:.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...U.cupped,roll:30}}},{beat:1,pose:{rightWrist:-15,rightElbow:12,leftWrist:-45,lean:-4,rightHip:16,leftHip:6},hands:{right:{...U.cupped,roll:-30}}},{beat:1.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...U.cupped,roll:30}}}]},thumka:{label:"Thumka",beats:2,keys:[{beat:0,reset:!0,pose:{lean:-11,rightHip:22,leftHip:2,leftKnee:14,rightShoulder:45,rightElbow:-105,leftShoulder:128,leftElbow:18,leftWrist:35,headTilt:10,lookX:-.5},hands:{right:"fist",left:{...U.open,turn:2}},easing:Z},{beat:.5,pose:{lean:-4,rightHip:12,headTilt:6}},{beat:1,pose:{lean:-11,rightHip:22,headTilt:10},easing:Z},{beat:1.5,pose:{lean:-4,rightHip:12,headTilt:6}}]},flick:{label:"Cross and flick",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:22,rightShoulder:22,leftElbow:-62,rightElbow:-62,leftHip:16,rightHip:16,leftKnee:26,rightKnee:26},hands:{left:"fist",right:"fist"}},{beat:1,pose:{leftShoulder:132,rightShoulder:132,leftElbow:0,rightElbow:0,leftWrist:30,rightWrist:30,leftKnee:0,rightKnee:0,leftHip:10,rightHip:10,stretch:1.03},hands:{left:"spread",right:"spread"},easing:Z},{beat:2,pose:{leftShoulder:22,rightShoulder:22,leftElbow:-62,rightElbow:-62,leftWrist:0,rightWrist:0,leftHip:16,rightHip:16,leftKnee:26,rightKnee:26,stretch:1},hands:{left:"fist",right:"fist"}},{beat:3,pose:{leftShoulder:62,rightShoulder:62,leftElbow:0,rightElbow:0,leftWrist:35,rightWrist:35,leftKnee:0,rightKnee:0,leftHip:10,rightHip:10},hands:{left:"spread",right:"spread"},easing:Z}]}},routine:[{move:"thumka",beats:4},{move:"lightBulb",beats:8},{move:"flick",beats:8},{move:"thumka",beats:4,mirror:!0},{move:"lightBulb",beats:8,mirror:!0}]},Od={label:"Bhangra",bpm:100,stance:{leftShoulder:150,rightShoulder:150,leftElbow:18,rightElbow:18,leftHip:10,rightHip:10},expression:{mouth:.6,smile:1,mouthWidth:1.2,leftBrow:.5,rightBrow:.5},hands:{left:"open",right:"open"},groove:{bounce:12,accent:"down"},moves:{basic:{label:"Bhangra step",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:58,rightKnee:104,rightAnkle:30,leftShoulder:162,rightShoulder:140,headTilt:7}},{beat:.5,reset:!0,pose:{stretch:.98}},{beat:1,reset:!0,pose:{leftHip:58,leftKnee:104,leftAnkle:30,rightShoulder:162,leftShoulder:140,headTilt:-7}},{beat:1.5,reset:!0,pose:{stretch:.98}}]},dhamaal:{label:"Dhamaal (jump, arms up)",beats:2,keys:[{beat:0,reset:!0,pose:{leftHip:20,rightHip:20,leftKnee:40,rightKnee:40,stretch:.94}},{beat:.5,reset:!0,pose:{rise:.07,stretch:1.06,leftHip:6,rightHip:6,leftAnkle:45,rightAnkle:45,leftShoulder:172,rightShoulder:172,leftElbow:0,rightElbow:0},hands:{left:"point",right:"point"},easing:"ease-out-quad"},{beat:1,reset:!0,pose:{leftHip:20,rightHip:20,leftKnee:40,rightKnee:40,stretch:.94},hands:{left:"open",right:"open"},easing:"ease-in-quad"},{beat:1.5,reset:!0,pose:{rise:.07,stretch:1.06,leftHip:6,rightHip:6,leftAnkle:45,rightAnkle:45,leftShoulder:172,rightShoulder:172,leftElbow:0,rightElbow:0},hands:{left:"point",right:"point"},easing:"ease-out-quad"}]}},routine:[{move:"basic",beats:8},{move:"dhamaal",beats:4},{move:"basic",beats:8},{move:"dhamaal",beats:4}]},Ld={label:"Bharatanatyam",bpm:80,stance:{...{leftHip:42,rightHip:42,leftKnee:82,rightKnee:82,leftFootOut:.3,rightFootOut:.3},leftShoulder:90,rightShoulder:90,leftElbow:0,rightElbow:0,leftWrist:75,rightWrist:75},expression:{smile:.5,leftEye:1.2,rightEye:1.2,leftBrow:.3,rightBrow:.3},hands:{left:"pataka",right:"pataka"},groove:{bounce:0},moves:{tatta:{label:"Tatta adavu (stamps)",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:48,rightKnee:104,rightAnkle:-18}},{beat:.3,reset:!0,easing:"ease-in-quad",taps:["rightToe","rightHeel"]},{beat:1,reset:!0,pose:{leftHip:48,leftKnee:104,leftAnkle:-18}},{beat:1.3,reset:!0,easing:"ease-in-quad",taps:["leftToe","leftHeel"]}]},natta:{label:"Natta adavu (stretch and look)",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:52,rightKnee:0,rightAnkle:-40,rightShoulder:125,rightWrist:60,leftShoulder:25,leftElbow:-125,leftWrist:0,headTilt:8,lookX:.9,lookY:-.4,lean:-6}},{beat:1,reset:!0},{beat:2,reset:!0,pose:{leftHip:52,leftKnee:0,leftAnkle:-40,leftShoulder:125,leftWrist:60,rightShoulder:25,rightElbow:-125,rightWrist:0,headTilt:-8,lookX:-.9,lookY:-.4,lean:6}},{beat:3,reset:!0}]},alapadma:{label:"Alapadma (lotus) to the sky",beats:4,keys:[{beat:0,reset:!0,pose:{rightShoulder:145,rightElbow:20,rightWrist:30,leftShoulder:28,leftElbow:-125,leftWrist:0,lookX:.7,lookY:-.9,headTilt:6},hands:{right:"alapadma",left:"pataka"}},{beat:1,pose:{rightWrist:55,headTilt:9}},{beat:2,reset:!0,pose:{leftShoulder:145,leftElbow:20,leftWrist:30,rightShoulder:28,rightElbow:-125,rightWrist:0,lookX:-.7,lookY:-.9,headTilt:-6},hands:{left:"alapadma",right:"pataka"}},{beat:3,pose:{leftWrist:55,headTilt:-9}}]}},routine:[{move:"tatta",beats:8},{move:"natta",beats:8},{move:"alapadma",beats:8},{move:"tatta",beats:4}]},Fd={label:"Charleston",bpm:150,stance:{leftHip:10,rightHip:10,leftKnee:10,rightKnee:10,leftShoulder:30,rightShoulder:30,leftElbow:20,rightElbow:20},expression:{mouth:.4,smile:1,leftBrow:.5,rightBrow:.5},hands:{left:{...U.spread,turn:2},right:{...U.spread,turn:2}},groove:{bounce:8,accent:"down"},moves:{basic:{label:"Kick forward, kick back",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:48,rightKnee:8,rightAnkle:45,leftShoulder:75,rightShoulder:15,leftElbow:30,rightElbow:-10,lean:-7,headTilt:-5},easing:Z},{beat:1,reset:!0},{beat:2,reset:!0,pose:{leftHip:18,leftKnee:85,leftAnkle:35,rightShoulder:75,leftShoulder:15,rightElbow:30,leftElbow:-10,lean:7,headTilt:5},easing:Z},{beat:3,reset:!0}]},twist:{label:"Swivel (heels in, heels out)",beats:2,keys:[{beat:0,reset:!0,pose:{leftFootOut:-.9,rightFootOut:-.9,leftHip:4,rightHip:4,leftKnee:4,rightKnee:4,leftAnkle:-10,rightAnkle:-10,leftShoulder:18,rightShoulder:48,leftElbow:-10,rightElbow:50}},{beat:.5,pose:{leftFootOut:.6,rightFootOut:.6,leftHip:16,rightHip:16,leftKnee:22,rightKnee:22,leftAnkle:10,rightAnkle:10,leftShoulder:48,rightShoulder:18,leftElbow:50,rightElbow:-10}},{beat:1,pose:{leftFootOut:-.9,rightFootOut:-.9,leftHip:4,rightHip:4,leftKnee:4,rightKnee:4,leftAnkle:-10,rightAnkle:-10,leftShoulder:18,rightShoulder:48,leftElbow:-10,rightElbow:50}},{beat:1.5,pose:{leftFootOut:.6,rightFootOut:.6,leftHip:16,rightHip:16,leftKnee:22,rightKnee:22,leftAnkle:10,rightAnkle:10,leftShoulder:48,rightShoulder:18,leftElbow:50,rightElbow:-10}}]},kneeCross:{label:"Crossing knees",beats:2,keys:[{beat:0,reset:!0,pose:{leftHip:-6,rightHip:-6,leftKnee:-16,rightKnee:-16,leftFootOut:-.4,rightFootOut:-.4,leftShoulder:-12,rightShoulder:-12,leftElbow:0,rightElbow:0,lean:0,lookY:.6}},{beat:.5,pose:{leftHip:18,rightHip:18,leftKnee:28,rightKnee:28,leftFootOut:.3,rightFootOut:.3,leftShoulder:16,rightShoulder:16,lookY:0}},{beat:1,pose:{leftHip:-6,rightHip:-6,leftKnee:-16,rightKnee:-16,leftFootOut:-.4,rightFootOut:-.4,leftShoulder:-12,rightShoulder:-12,lookY:.6}},{beat:1.5,pose:{leftHip:18,rightHip:18,leftKnee:28,rightKnee:28,leftFootOut:.3,rightFootOut:.3,leftShoulder:16,rightShoulder:16,lookY:0}}]}},routine:[{move:"basic",beats:8},{move:"twist",beats:8},{move:"kneeCross",beats:8},{move:"basic",beats:8,mirror:!0},{move:"twist",beats:4}]},Dd={label:"Tap",bpm:120,stance:{turn:.8,leftHip:-3,rightHip:3,leftKnee:-10,rightKnee:10,leftShoulder:12,rightShoulder:12,leftElbow:-40,rightElbow:40,leftWrist:-15,rightWrist:15,lean:4},expression:{smile:.9,mouth:.2,leftBrow:.3,rightBrow:.3,lookY:.3},hands:{left:"relaxed",right:"relaxed"},groove:{bounce:6,accent:"down"},moves:{shuffleBallChange:{label:"Shuffle ball change",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:34,rightKnee:8,rightAnkle:30,leftShoulder:30,rightShoulder:-10},taps:["rightToe"]},{beat:.25,pose:{rightHip:24,rightKnee:62,rightAnkle:40},taps:["rightToe"]},{beat:.5,pose:{rightHip:-8,rightKnee:14,rightAnkle:50,leftAnkle:15,leftShoulder:12,rightShoulder:12},taps:["rightToe"]},{beat:.75,pose:{rightHip:3,rightKnee:10,rightAnkle:0,leftAnkle:0},taps:["leftHeel"]},{beat:1,reset:!0,pose:{leftHip:-34,leftKnee:-8,leftAnkle:30,rightShoulder:-30,leftShoulder:10},taps:["leftToe"]},{beat:1.25,pose:{leftHip:-24,leftKnee:-62,leftAnkle:40},taps:["leftToe"]},{beat:1.5,pose:{leftHip:8,leftKnee:-14,leftAnkle:50,rightAnkle:15,leftShoulder:12,rightShoulder:12},taps:["leftToe"]},{beat:1.75,pose:{leftHip:-3,leftKnee:-10,leftAnkle:0,rightAnkle:0},taps:["rightHeel"]}]},timeStep:{label:"Single time step",beats:4,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:8,rightKnee:4,rightAnkle:0,leftShoulder:25,rightShoulder:-20},taps:["rightToe","rightHeel"]},{beat:.5,pose:{rightHip:34,rightKnee:8,rightAnkle:30},taps:["rightToe"]},{beat:.75,pose:{rightHip:22,rightKnee:62,rightAnkle:40},taps:["rightToe"]},{beat:1,pose:{rise:.05,leftAnkle:45,leftKnee:-4,leftHip:-2,rightHip:26,rightKnee:70,stretch:1.03}},{beat:1.25,pose:{rise:0,leftAnkle:0,leftKnee:-14,stretch:1},taps:["leftToe"]},{beat:1.5,pose:{rightHip:4,rightKnee:12,rightAnkle:0,rightShoulder:25,leftShoulder:-20},taps:["rightToe"]},{beat:2,pose:{leftHip:-30,leftKnee:-6,leftAnkle:35},taps:["leftToe"]},{beat:2.25,pose:{leftHip:-4,leftKnee:-12,leftAnkle:0},taps:["leftToe"]},{beat:3,pose:{rightHip:10,rightAnkle:35,rightKnee:18,leftShoulder:12,rightShoulder:12},taps:["rightToe"]},{beat:3.5,pose:{rightHip:3,rightKnee:10,rightAnkle:0}}]},heelToe:{label:"Heel toe",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:26,rightKnee:0,rightAnkle:-35,leftShoulder:30,rightShoulder:-20},taps:["rightHeel"]},{beat:.5,pose:{rightHip:-16,rightKnee:24,rightAnkle:55,leftShoulder:-15,rightShoulder:25},taps:["rightToe"]},{beat:1,reset:!0,pose:{leftHip:-26,leftKnee:0,leftAnkle:-35,rightShoulder:-30,leftShoulder:20},taps:["leftHeel"]},{beat:1.5,pose:{leftHip:16,leftKnee:-24,leftAnkle:55,rightShoulder:15,leftShoulder:-25},taps:["leftToe"]}]},crampRoll:{label:"Cramp roll",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:12,rightKnee:26,leftHip:-12,leftKnee:-26}},{beat:.5,pose:{rightAnkle:40,rise:.02},taps:["rightToe"]},{beat:.625,pose:{leftAnkle:40},taps:["leftToe"]},{beat:.75,pose:{rightAnkle:0,rise:0},taps:["rightHeel"]},{beat:.875,pose:{leftAnkle:0},taps:["leftHeel"]},{beat:1,pose:{rightShoulder:135,leftShoulder:125,leftElbow:0,rightElbow:0,leftWrist:0,rightWrist:30,rightKnee:8,leftKnee:-8,rightHip:4,leftHip:-4},hands:{left:{...U.spread,turn:2},right:{...U.spread,turn:2}}},{beat:1.75,reset:!0}]}},routine:[{move:"shuffleBallChange",beats:8},{move:"timeStep",beats:4},{move:"timeStep",beats:4,mirror:!0},{move:"heelToe",beats:8},{move:"crampRoll",beats:4}]},Ot={disco:_d,hipHop:Id,breaking:Cd,jazz:Hd,kpop:$d,bollywood:Rd,bhangra:Od,bharatanatyam:Ld,charleston:Fd,tap:Dd,popping:{label:"Popping (glides, moonwalk)",bpm:100,stance:{leftHip:9,rightHip:9,leftShoulder:16,rightShoulder:16,leftElbow:-24,rightElbow:-24},expression:{smile:.35,leftEye:.85,rightEye:.85,leftBrow:-.2,rightBrow:-.2},hands:{left:"relaxed",right:"relaxed"},groove:{bounce:0},moves:{sideGlide:{label:"Side glide",beats:2,easing:"linear",travel:.2,keys:[{beat:0,reset:!0,pose:{leftHip:11,leftKnee:0,leftAnkle:0,rightHip:36,rightKnee:45,rightAnkle:45,rightShoulder:80,rightElbow:-10,rightWrist:10,leftShoulder:28,leftElbow:18,lean:-2,headTilt:4,lookX:.7},hands:{right:"flat",left:"relaxed"}},{beat:1,pose:{leftHip:27,leftKnee:54,leftAnkle:45,rightHip:-1,rightKnee:0,rightAnkle:0,rightShoulder:74,rightWrist:-10,lean:2}}]},moonwalk:{label:"Moonwalk",beats:2,easing:"linear",travel:-.29,keys:[{beat:0,reset:!0,pose:{turn:.9,lean:4,headTilt:-4,leftHip:-12,leftKnee:0,leftAnkle:0,rightHip:23,rightKnee:57,rightAnkle:45,leftShoulder:-10,leftElbow:-45,rightShoulder:14,rightElbow:50}},{beat:1,pose:{leftHip:-23,leftKnee:-57,leftAnkle:45,rightHip:12,rightKnee:0,rightAnkle:0,leftShoulder:-14,leftElbow:-50,rightShoulder:10,rightElbow:45}}]},forwardGlide:{label:"Forward glide",beats:2,easing:"linear",travel:.29,keys:[{beat:0,reset:!0,pose:{turn:.9,lean:2,leftHip:16,leftKnee:0,leftAnkle:0,rightHip:33,rightKnee:59,rightAnkle:45,leftShoulder:12,leftElbow:-40,rightShoulder:-12,rightElbow:40}},{beat:1,pose:{leftHip:-33,leftKnee:-59,leftAnkle:45,rightHip:-16,rightKnee:0,rightAnkle:0,leftShoulder:-12,leftElbow:-40,rightShoulder:12,rightElbow:40}}]},toeStand:{label:"Toe stand",beats:4,keys:[{beat:0,reset:!0,pose:{leftHip:6,rightHip:6,leftKnee:0,rightKnee:0,leftAnkle:65,rightAnkle:65,rightShoulder:150,rightElbow:75,leftShoulder:30,leftElbow:20,headTilt:-10,lookY:.4},hands:{right:"fist",left:"fist"},easing:Ne},{beat:2,pose:{headTilt:-14,lean:-2}}]}},routine:[{move:"sideGlide",beats:4},{move:"sideGlide",beats:4,mirror:!0},{move:"moonwalk",beats:8},{move:"forwardGlide",beats:8},{move:"toeStand",beats:4}]}},In=e=>Math.min(1,Math.max(0,e));function Bd(e){const t={...W,turn:e.view},n=[];for(const i of e.keys){const s=n[n.length-1],r=!s||i.reset?t:s.pose;n.push({at:i.at,pose:{...r,...i.pose},easing:i.easing})}return n}function Nd(e){return e-Wd*Math.sin(2*Math.PI*e)/(2*Math.PI)}const Wd=.5;function Kd(e,t){if(!(t<=e.takeoff||t>=e.landing))return(t-e.takeoff)/(e.landing-e.takeoff)}function Va(e,t){const n=typeof e=="string"?Hn[e]:e,i=Bd(n),s=In(t);let r=0;for(let u=0;u<i.length;u++)i[u].at<=s&&(r=u);const o=i[r],a=i[Math.min(r+1,i.length-1)],l=a.at>o.at?(s-o.at)/(a.at-o.at):0,c=re(o.pose,a.pose,J(a.easing??"ease-in-out")(In(l))),h=Kd(n,s);return h===void 0?{...c,spin:0,rise:0}:{...c,spin:n.spin*Nd(h),rise:4*n.height*h*(1-h)}}function Ua(e,t,n){const i=typeof e=="string"?Hn[e]:e,s=In(t),r=In((s-i.takeoff)/(i.landing-i.takeoff));return i.travel*n*r}function Yd(e,t,n={}){const i=typeof t=="string"?Hn[t]:t,s=n.start??0,r=n.duration??i.duration,o=n.samples??48,a=Array.from({length:o+1},(h,u)=>{const f=u/o;return{time:s+f*r,progress:f,pose:Va(i,f)}}),c=Object.keys(W).filter(h=>a.some(u=>u.pose[h]!==W[h])).map(h=>({id:`${e}-${h}`,target:e,property:h,keyframes:a.map(u=>({time:u.time,value:u.pose[h]}))}));if(n.height!==void 0&&i.travel!==0){const h=(n.facing??1)<0?-1:1;c.push({id:`${e}-x`,target:e,property:"x",keyframes:a.map(u=>({time:u.time,value:(n.x??0)+h*Ua(i,u.progress,n.height)}))})}return c}const Xd={leftHip:-55,leftKnee:-95,rightHip:55,rightKnee:95,leftShoulder:45,rightShoulder:-45,leftElbow:10,rightElbow:-10,lean:22,stretch:.94,headTilt:6},qd={leftHip:0,leftKnee:0,rightHip:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:-172,rightShoulder:172,leftElbow:0,rightElbow:0,lean:0,stretch:1.08,headTilt:0},Cn={leftHip:-128,leftKnee:-152,rightHip:128,rightKnee:152,leftAnkle:30,rightAnkle:30,leftShoulder:-78,rightShoulder:78,leftElbow:-48,rightElbow:48,lean:26,stretch:1,headTilt:14},Vd={leftHip:-22,leftKnee:-30,rightHip:22,rightKnee:30,leftAnkle:10,rightAnkle:10,leftShoulder:-125,rightShoulder:125,leftElbow:0,rightElbow:0,lean:8,headTilt:0},Ud={leftHip:-58,leftKnee:-100,rightHip:58,rightKnee:100,leftAnkle:0,rightAnkle:0,leftShoulder:-80,rightShoulder:80,leftElbow:-10,rightElbow:10,lean:20,stretch:.93};function oe(e,t,n,i,s,r=1300){return{label:e,view:1,spin:t,height:n,travel:i,takeoff:.27,landing:.8,duration:r,keys:[{at:0,reset:!0},{at:.16,pose:Xd},{at:.27,pose:qd,easing:"ease-out-quad"},...s,{at:.76,pose:Vd},{at:.86,pose:Ud,easing:"ease-out-quad"},{at:1,reset:!0}]}}const Hn={frontFlip:oe("Front flip (tuck)",360,.56,.35,[{at:.38,pose:Cn,easing:"ease-out-cubic"},{at:.64,pose:Cn}]),backFlip:oe("Back flip (tuck)",-360,.58,-.15,[{at:.36,pose:{...Cn,lean:18},easing:"ease-out-cubic"},{at:.64,pose:{...Cn,lean:18}}]),layout:oe("Back layout (straight body)",-360,.66,-.2,[{at:.4,pose:{leftHip:8,rightHip:-8,leftKnee:0,rightKnee:0,leftAnkle:60,rightAnkle:60,leftShoulder:-178,rightShoulder:178,lean:-18,headTilt:-14}},{at:.64,pose:{leftHip:-4,rightHip:4,lean:-6,headTilt:-4,leftShoulder:-150,rightShoulder:150}}],1400),scissorFlip:oe("Scissor flip",360,.6,.45,[{at:.36,pose:{leftHip:-105,leftKnee:0,rightHip:-40,rightKnee:-20,leftAnkle:50,rightAnkle:50,leftShoulder:-150,rightShoulder:150,leftElbow:0,rightElbow:0,lean:12},easing:"ease-out-cubic"},{at:.52,pose:{leftHip:40,leftKnee:20,rightHip:105,rightKnee:0,leftShoulder:-140,rightShoulder:140}},{at:.66,pose:{leftHip:-30,leftKnee:-20,rightHip:30,rightKnee:20,leftShoulder:-110,rightShoulder:110,lean:6}}]),sideFlip:{label:"Side flip (tuck)",view:0,spin:360,height:.55,travel:.4,takeoff:.27,landing:.8,duration:1300,keys:[{at:0,reset:!0},{at:.16,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftShoulder:20,rightShoulder:20,lean:-10,stretch:.94}},{at:.27,pose:{leftHip:4,rightHip:4,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:165,rightShoulder:165,lean:6,stretch:1.08},easing:"ease-out-quad"},{at:.38,pose:{leftHip:105,rightHip:105,leftKnee:135,rightKnee:135,leftShoulder:40,rightShoulder:40,leftElbow:-95,rightElbow:-95,lean:0,stretch:1,headTilt:10},easing:"ease-out-cubic"},{at:.64,pose:{}},{at:.76,pose:{leftHip:20,rightHip:20,leftKnee:20,rightKnee:20,leftAnkle:10,rightAnkle:10,leftShoulder:100,rightShoulder:100,leftElbow:0,rightElbow:0,headTilt:0}},{at:.86,pose:{leftHip:24,rightHip:24,leftKnee:48,rightKnee:48,leftAnkle:0,rightAnkle:0,leftShoulder:70,rightShoulder:70,stretch:.93},easing:"ease-out-quad"},{at:1,reset:!0}]},cartwheel:{label:"Cartwheel",view:0,spin:360,height:.155,travel:.9,takeoff:.2,landing:.86,duration:1600,keys:[{at:0,reset:!0},{at:.12,pose:{leftShoulder:165,rightShoulder:165,rightHip:30,rightKnee:0,lean:-6}},{at:.24,pose:{leftShoulder:172,rightShoulder:172,leftHip:55,rightHip:55,leftKnee:0,rightKnee:0,leftAnkle:40,rightAnkle:40,lean:0}},{at:.75,pose:{}},{at:.9,pose:{leftHip:30,rightHip:12,leftAnkle:0,rightAnkle:0,leftShoulder:150,rightShoulder:150}},{at:1,reset:!0}]},splitLeap:oe("Split leap (grand jeté)",0,.36,.9,[{at:.4,pose:{leftHip:-96,rightHip:-84,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:-130,rightShoulder:-105,leftElbow:0,rightElbow:0,lean:4,headTilt:-6},easing:"ease-out-cubic"},{at:.64,pose:{lean:2}}]),toeTouch:{label:"Toe touch (straddle jump)",view:0,spin:0,height:.36,travel:0,takeoff:.27,landing:.8,duration:1200,keys:[{at:0,reset:!0},{at:.16,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftShoulder:-20,rightShoulder:-20,stretch:.94}},{at:.27,pose:{leftHip:4,rightHip:4,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:170,rightShoulder:170,stretch:1.06},easing:"ease-out-quad"},{at:.42,pose:{leftHip:104,rightHip:104,leftShoulder:96,rightShoulder:96,leftElbow:0,rightElbow:0,stretch:1,headTilt:0},easing:"ease-out-cubic"},{at:.62,pose:{}},{at:.76,pose:{leftHip:12,rightHip:12,leftAnkle:10,rightAnkle:10,leftShoulder:120,rightShoulder:120}},{at:.86,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftAnkle:0,rightAnkle:0,leftShoulder:60,rightShoulder:60,stretch:.94},easing:"ease-out-quad"},{at:1,reset:!0}]},backHandspring:oe("Back handspring",-360,.16,-.7,[{at:.38,pose:{leftHip:10,rightHip:-10,leftKnee:0,rightKnee:0,leftShoulder:-178,rightShoulder:178,lean:-26,headTilt:-20}},{at:.6,pose:{leftHip:-40,rightHip:40,leftKnee:-20,rightKnee:20,lean:6,headTilt:0}}],1200)},ss=.215,rs=.205,zd=.065,za=.035,Gd=.165,jd=.155,Jd=12,Zd=.3,Qd=.7,t0=.35,e0=e=>e*Math.PI/180,q={turn:0,lean:0,bend:0,side:0,"head.turn":0,"head.nod":0,"head.tilt":0,"arm.left.swing":0,"arm.left.spread":12,"arm.left.elbow":8,"arm.left.bend":0,"arm.right.swing":0,"arm.right.spread":12,"arm.right.elbow":8,"arm.right.bend":0,"leg.left.swing":0,"leg.left.spread":3,"leg.left.knee":0,"leg.left.ankle":0,"leg.left.toeOut":0,"leg.left.rotate":0,"leg.right.swing":0,"leg.right.spread":3,"leg.right.knee":0,"leg.right.ankle":0,"leg.right.toeOut":0,"leg.right.rotate":0,stretch:1,lift:0,roll:0,mouth:0,smile:.5,mouthWidth:1,blink:0,"eye.left":1,"eye.right":1,"brow.left":0,"brow.right":0,browTilt:0,lookX:0,lookY:0};function nt(e={}){return{...q,...e}}const n0=new Set(["turn","side","head.turn","head.tilt","roll","lookX"]);function i0(e){const t={};for(const[n,i]of Object.entries(e)){const s=n.replace(/(^|\.)(left|right)(\.|$)/,(r,o,a,l)=>`${o}${a==="left"?"right":"left"}${l}`);t[s]=n0.has(n)?-i:i}return t}function ot(e,t){const n={};for(const i of["left","right"])for(const[s,r]of Object.entries(t))n[`${e}.${i}.${s}`]=r;return n}const Ga={rest:q,wave:nt({"arm.right.spread":115,"arm.right.bend":55,"arm.right.elbow":0,"head.tilt":-6,smile:.9}),cheer:nt({...ot("arm",{spread:140,bend:20,elbow:0}),mouth:.6,smile:1,"eye.left":0,"eye.right":0}),point:nt({"arm.right.spread":88,"arm.right.elbow":0,"arm.right.bend":0,"head.turn":-20,smile:.4}),handsOnHips:nt({...ot("arm",{spread:50,bend:-105,elbow:0}),...ot("leg",{spread:9}),smile:.8}),think:nt({"arm.right.spread":22,"arm.right.bend":-150,"arm.right.elbow":0,"head.tilt":10,lookX:-.5,lookY:-.8,smile:0}),shrug:nt({...ot("arm",{spread:35,bend:75,elbow:0}),"head.tilt":-10,smile:-.2}),sit:nt({...ot("leg",{swing:90,knee:90,spread:4}),...ot("arm",{swing:25,elbow:45,spread:8})}),kneel:nt({"leg.left.swing":90,"leg.left.knee":90,"leg.right.swing":-18,"leg.right.knee":108,"leg.right.ankle":16,...ot("arm",{swing:20,elbow:30})}),crouch:nt({...ot("leg",{swing:75,knee:140,spread:6}),lean:25,...ot("arm",{swing:50,elbow:40}),"head.nod":-15}),crawl:nt({lean:82,"head.nod":-35,...ot("arm",{swing:80,elbow:0,spread:4}),...ot("leg",{knee:92,ankle:-88})}),lieDown:nt({roll:90,...ot("arm",{spread:8}),"head.nod":0})};function ja(e={}){const t=e.headSize??.3,n=e.shoulderWidth??.06,i=e.hipWidth??.022,s=Math.max(.12,1-t-za-(ss+rs)),r=l=>({id:`arm.${l}`,parent:"spine",offset:[(l==="left"?1:-1)*n,-.035,0],rest:[0,-1,0],side:l==="left"?1:-1,bones:[{length:Gd,width:[1.25,.9]},{length:jd,width:[.9,.75]}]}),o=l=>({id:`leg.${l}`,parent:null,offset:[(l==="left"?1:-1)*i,0,0],rest:[0,-1,0],side:l==="left"?1:-1,bones:[{length:ss,width:[1.45,1.05]},{length:rs,width:[1.05,.85]},{length:zd,width:[.95,.7]}]}),a=(l,c)=>l[c]??q[c]??0;return{id:"human",hipHeight:ss+rs,chains:[o("left"),o("right"),{id:"spine",parent:null,rest:[0,1,0],bones:[{length:s/2,width:[1.7,1.4]},{length:s/2,width:[1.4,1.1]}]},{id:"neck",parent:"spine",rest:[0,1,0],bones:[{length:za,width:[1,.9]}]},r("left"),r("right")],head:{on:"neck",size:t},contacts:[...["left","right"].flatMap(l=>[{chain:`leg.${l}`,joint:1},{chain:`leg.${l}`,joint:2},{chain:`leg.${l}`,joint:3},{chain:`arm.${l}`,joint:1},{chain:`arm.${l}`,joint:2}]),{chain:"spine",joint:0},{chain:"spine",joint:1},{chain:"spine",joint:2},{head:"top"}],angles(l,c){if(c.id==="spine"){const p=-a(l,"lean")/2,g=a(l,"side")/2,y=-a(l,"bend");return[{swing:p+y*Zd,spread:g},{swing:p+y*Qd,spread:g}]}if(c.id==="neck")return[{swing:-a(l,"bend")*t0,spread:0}];const[h,u]=c.id.split("."),f=p=>a(l,`${h}.${u}.${p}`);if(h==="arm")return[{swing:f("swing"),spread:f("spread")},{swing:f("elbow"),spread:f("bend")}];const d=(c.side??1)*f("rotate"),m=1-Math.cos(e0(f("rotate")));return[{swing:f("swing"),spread:f("spread"),yaw:d},{swing:-f("knee"),spread:0,yaw:d},{swing:90+f("ankle")-m*(f("swing")-f("knee")),spread:0,yaw:(Jd+f("toeOut"))*(c.side??1)}]},withAngles(l,c,h){const[u,f]=c.id.split("."),d=m=>`${u}.${f}.${m}`;return u==="arm"?{...l,[d("swing")]:h[0].swing,[d("spread")]:h[0].spread,[d("elbow")]:h[1].swing,[d("bend")]:h[1].spread}:u==="leg"?{...l,[d("swing")]:h[0].swing,[d("spread")]:h[0].spread,[d("knee")]:-h[1].swing}:l},boneScale(l,c){const h=Math.min(3,Math.max(.3,a(l,"stretch")));return c?.id.startsWith("arm.")?Math.sqrt(h):h},headPose(l){const c=Math.min(3,Math.max(.3,a(l,"stretch")));return{yaw:a(l,"head.turn"),nod:a(l,"head.nod"),tilt:a(l,"head.tilt"),sx:1/Math.sqrt(c),sy:Math.sqrt(c)}},landmarks:{neck:["neck",0],"shoulder.left":["arm.left",0],"elbow.left":["arm.left",1],"hand.left":["arm.left",2],"shoulder.right":["arm.right",0],"elbow.right":["arm.right",1],"hand.right":["arm.right",2],"hip.left":["leg.left",0],"knee.left":["leg.left",1],"ankle.left":["leg.left",2],"toe.left":["leg.left",3],"hip.right":["leg.right",0],"knee.right":["leg.right",1],"ankle.right":["leg.right",2],"toe.right":["leg.right",3]}}}function s0(e){const t=e.split(".");if(t[0]==="hand"&&t.length>=3){const i=`${t[1]==="left"?"Left":"Right"} hand`,s={spread:"finger spread",turn:"wrist turn",bend:"wrist bend",tilt:"wrist tilt",roll:"roll"},r=t.slice(2).join(".");return`${i} · ${s[r]??r.replace(".curl"," curl").replace(".across"," across")}`}if(t.length===3){const[i,s,r]=t;return`${`${s==="left"?"Left":"Right"} ${i}`} · ${{swing:"forward / back",spread:"out / in",elbow:"elbow bend",bend:"forearm out / in",knee:"knee bend",ankle:"foot tilt",toeOut:"toes out / in",rotate:"turn out at the hip"}[r]??r}`}return{turn:"View (front → side → back)",lean:"Lean forward / back",bend:"Back curve (line of action)",side:"Lean sideways","head.turn":"Head · turn","head.nod":"Head · nod","head.tilt":"Head · tilt",stretch:"Squash / stretch",lift:"Lift off the ground",roll:"Roll (whole figure)",mouth:"Mouth open",smile:"Smile",mouthWidth:"Mouth width",blink:"Blink","eye.left":"Left eye open","eye.right":"Right eye open","brow.left":"Left brow","brow.right":"Right brow",browTilt:"Brow slant",lookX:"Look left / right",lookY:"Look up / down"}[e]??e}const r0={leftEye:"eye.left",rightEye:"eye.right",leftBrow:"brow.left",rightBrow:"brow.right"},Ja=Object.fromEntries(Object.entries(G).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([n,i])=>[r0[n]??n,i]))]));function o0(e,t){const n=Math.min(1,Math.max(0,e.turn??0)),i=1-n,s={...q,turn:n},r=[{stick:"right",human:"left",s:1},{stick:"left",human:"right",s:-1}];for(const{stick:a,human:l,s:c}of r){const h=e[`${a}Shoulder`],u=e[`${a}Elbow`];s[`arm.${l}.spread`]=h*i,s[`arm.${l}.swing`]=c*h*n,s[`arm.${l}.bend`]=u*i,s[`arm.${l}.elbow`]=c*u*n;const f=e[`${a}Hip`],d=e[`${a}Knee`],m=i+c*n;s[`leg.${l}.rotate`]=90*i,s[`leg.${l}.spread`]=0,s[`leg.${l}.swing`]=f*m,s[`leg.${l}.knee`]=d*m,s[`leg.${l}.ankle`]=-(e[`${a}Ankle`]??0),s[`leg.${l}.toeOut`]=(e[`${a}FootOut`]??0)*a0,s[`eye.${l}`]=e[`${a}Eye`],s[`brow.${l}`]=e[`${a}Brow`],t&&Object.assign(s,l0(l,t[a]??Y,e[`${a}Wrist`]??0,n))}const o=e.bend??0;s.lean=e.lean*n,s.bend=o*n,s.side=(e.lean+o*.5)*i,s["head.tilt"]=(e.headTilt+o*.5)*i,s["head.nod"]=e.headTilt*n;for(const a of["mouth","smile","mouthWidth","blink","browTilt","lookX","lookY","stretch"])s[a]=e[a];return s.lift=e.rise??0,s.roll=e.spin??0,s}const a0=70;function l0(e,t,n,i){const s=e==="right"?1-i:1+i,r={};for(const o of Object.keys(Y))r[`hand.${e}.${o}`]=t[o]??Y[o];return r[`hand.${e}.turn`]=(t.turn??0)-s,r[`hand.${e}.roll`]=(t.roll??0)+n,r}const at=e=>e*Math.PI/180;function Za([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e,t*s+n*r,-t*r+n*s]}function os([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s-t*r,e*r+t*s,n]}function Lt([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s+n*r,t,-e*r+n*s]}const Mt=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],$n=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],Rn=(e,t)=>os(Za(e,t.swing),t.spread);function as(e,t){const n=Lt(e,t);return{point:{x:n[0],y:-n[1]},depth:n[2]}}function On(e,t,n){const i=n,r=[0,e.hipHeight*i*(e.boneScale?.(t,null)??1),0],o={};for(const p of e.chains){const g=p.parent?o[p.parent]:void 0;if(p.parent&&!g)throw new Error(`body plan ${e.id}: chain ${p.id} comes before its parent ${p.parent}`);const y=p.at??(g?g.joints3.length-1:0),w=g?g.joints3[y]:r,k=g?g.frames[Math.max(0,y-1)]:{swing:0,spread:0},M=p.offset?Mt(w,Rn($n(p.offset,i),k)):w,S=p.side??1,A=e.boneScale?.(t,p)??1,E=e.angles(t,p),T=[M],v=[];let _=k.swing,P=k.spread;p.bones.forEach((x,I)=>{const C=E[I]??{swing:0,spread:0};_+=at(C.swing),P+=at(C.spread)*S,v.push({swing:_,spread:P});const H=Lt(Rn(p.rest,{swing:_,spread:P}),at(C.yaw??0));T.push(Mt(T[I],$n(H,x.length*i*A)))}),o[p.id]={joints3:T,frames:v}}const a=o[e.head.on],l=e.headPose?.(t)??{yaw:0,nod:0,tilt:0,sx:1,sy:1},c=a.frames[a.frames.length-1],h=e.head.size/2*i,u=h*l.sx,f=h*l.sy,d=p=>Rn(Lt(Za(os(p,-at(l.tilt)),-at(l.nod)),at(l.yaw)),c),m=Mt(a.joints3[a.joints3.length-1],d([0,f,0]));return{height:i,root:r,chains:o,head:{center:m,rx:u,ry:f,toBody:d}}}function ls(e,t,n){const i=n.height,s=at(90*(t.turn??0)),r=On(e,t,i),{root:o}=r,a=r.chains,{rx:l,ry:c}=r.head,h=r.head.toBody,u=r.head.center,f={};for(const v of e.chains){const{joints3:_,frames:P}=a[v.id],x=_.map(I=>as(I,s));f[v.id]={id:v.id,joints3:_,frames:P,points:x.map(I=>I.point),depths:x.map(I=>I.depth)}}const d=as(u,s),m=[[1,0,0],[0,1,0],[0,0,1]].map(v=>Lt(h(v),s)),p=as(o,s).point,g=at(t.roll??0),y=v=>{const _=v.x-p.x,P=v.y-p.y;return{x:p.x+_*Math.cos(g)-P*Math.sin(g),y:p.y+_*Math.sin(g)+P*Math.cos(g)}},w=([v,_,P])=>[v*Math.cos(g)+_*Math.sin(g),-v*Math.sin(g)+_*Math.cos(g),P];for(const v of Object.values(f))v.points=v.points.map(y);const k={center:y(d.point),depth:d.depth,rx:l,ry:c,angle:0,axes:m.map(w)},M=k.axes[1];k.angle=Math.atan2(M[0],M[1]);const S=v=>{if("head"in v)return{x:k.center.x+M[0]*c,y:k.center.y-M[1]*c};const _=f[v.chain];return _.points[Math.min(v.joint,_.points.length-1)]};let A=0;(n.contact??"ground")==="ground"&&(A=-Math.max(...e.contacts.map(v=>S(v).y))),A-=(t.lift??0)*i;const E=v=>({x:v.x,y:v.y+A});for(const v of Object.values(f))v.points=v.points.map(E);k.center=E(k.center);const T=e.contacts.map(v=>({spec:v,point:S(v)}));return{height:i,view:s,chains:f,head:k,hip:E(y(p)),contacts:T,groundY:Math.max(...T.map(v=>v.point.y))}}const cs=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Qa=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function hs(e,t,n){const i=n.height,s=at(90*(t.turn??0)),r=at(t.roll??0),o=On(e,t,i),a=Lt(o.root,s),l=g=>Mt(os(cs(Lt(g,s),a),-r),a),c={};for(const g of e.chains)c[g.id]=o.chains[g.id].joints3.map(l);const h=l(o.head.center),u=g=>Qa(cs(l(Mt(o.head.center,o.head.toBody(g))),h)),f=[u([1,0,0]),u([0,1,0]),u([0,0,1])],d=g=>{if("head"in g)return Mt(h,$n(f[1],o.head.ry));const y=c[g.chain];return y[Math.min(g.joint,y.length-1)]};let m=0;(n.contact??"ground")==="ground"&&(m=-Math.min(...e.contacts.map(g=>d(g)[1]))),m+=(t.lift??0)*i;const p=g=>[g[0],g[1]+m,g[2]];return{height:i,hip:p(a),chains:Object.fromEntries(Object.entries(c).map(([g,y])=>[g,y.map(p)])),head:{center:p(h),rx:o.head.rx,ry:o.head.ry,axes:f}}}function us(e,t,n,i){const s=n.height,r=at(90*(t.turn??0)),o=On(e,t,s),a=hs(e,t,n),l=a.hip,c=a.chains,h=a.head.center,u=v=>{if("head"in v)return Mt(h,$n(a.head.axes[1],a.head.ry));const _=c[v.chain];return _[Math.min(v.joint,_.length-1)]},f=i.toView(l),d=i.toScreen(f),m=i.toScreen([f[0]+1,f[1],f[2]]),p=Math.hypot(m.x-d.x,m.y-d.y),g=v=>{const _=i.toView(v);return{point:i.toScreen(_),depth:_[2]*p}},y={};for(const v of e.chains){const _=c[v.id].map(g);y[v.id]={id:v.id,joints3:o.chains[v.id].joints3,frames:o.chains[v.id].frames,points:_.map(P=>P.point),depths:_.map(P=>P.depth)}}const w=i.toView(h),k=i.toScreen(w),M=i.toScreen([w[0]+1,w[1],w[2]]),S=Math.hypot(M.x-k.x,M.y-k.y),A=a.head.axes.map(v=>Qa(cs(i.toView(Mt(h,v)),w))),E={center:k,depth:w[2]*p,rx:o.head.rx*S,ry:o.head.ry*S,angle:Math.atan2(A[1][0],A[1][1]),axes:A},T=e.contacts.map(v=>({spec:v,point:g(u(v)).point}));return{height:s*p,view:r,chains:y,head:E,hip:d,contacts:T,groundY:Math.max(...T.map(v=>v.point.y))}}function tl(e,[t,n,i]){const[s,r,o]=e.axes,a=[s[0]*t*e.rx+r[0]*n*e.ry+o[0]*i*e.rx,s[1]*t*e.rx+r[1]*n*e.ry+o[1]*i*e.rx,s[2]*t*e.rx+r[2]*n*e.ry+o[2]*i*e.rx],l=Math.hypot(t,n,i)||1,c=(s[2]*t+r[2]*n+o[2]*i)/l;return{point:{x:e.center.x+a[0],y:e.center.y-a[1]},depth:e.depth+a[2],facing:c}}class el{positions=[];normals=[];indices=[];vertex(t,n,i,s,r,o){const a=Math.hypot(s,r,o)||1;return this.positions.push(t,n,i),this.normals.push(s/a,r/a,o/a),this.positions.length/3-1}triangle(t,n,i){this.indices.push(t,n,i)}quad(t,n,i,s){this.indices.push(t,n,i,t,i,s)}build(){return{positions:this.positions,normals:this.normals,indices:this.indices}}}function c0(e){const t=new Map,n=[];for(let s=0;s<e.positions.length/3;s++){const r=[0,1,2].map(o=>Math.round(e.positions[s*3+o]*1e6)).join(",");t.has(r)||t.set(r,s),n.push(t.get(r))}const i=new Map;for(let s=0;s<e.indices.length/3;s++)for(let r=0;r<3;r++){const o=n[e.indices[s*3+r]],a=n[e.indices[s*3+(r+1)%3]];if(o===a)continue;const l=o<a?`${o}-${a}`:`${a}-${o}`,c=i.get(l);c?c.faces.push(s):i.set(l,{a:Math.min(o,a),b:Math.max(o,a),faces:[s]})}return[...i.values()]}const fs=Math.PI*2;function h0(e,t=16){const n=new el,i=Math.max(6,Math.round(t)),s=Math.max(3,Math.round(i/2)),r=[];for(let o=0;o<=s;o++){const a=o/s*Math.PI,l=[];for(let c=0;c<=i;c++){const h=c/i*fs,u=Math.sin(a)*Math.sin(h),f=Math.cos(a),d=Math.sin(a)*Math.cos(h);l.push(n.vertex(u*e,f*e,d*e,u,f,d))}r.push(l)}for(let o=0;o<s;o++)for(let a=0;a<i;a++){const l=r[o][a],c=r[o+1][a],h=r[o+1][a+1],u=r[o][a+1];o>0&&n.triangle(l,c,u),o<s-1&&n.triangle(c,h,u)}return n.build()}function nl(e,t,n,i,s){const r=e.vertex(0,n,0,0,i,0),o=Array.from({length:s},(a,l)=>{const c=l/s*fs;return e.vertex(Math.sin(c)*t,n,Math.cos(c)*t,0,i,0)});for(let a=0;a<s;a++){const l=o[a],c=o[(a+1)%s];i===1?e.triangle(r,l,c):e.triangle(r,c,l)}}function u0(e,t,n=24){const i=new el,s=Math.max(6,Math.round(n)),r=t/2,o=-t/2,a=h=>Array.from({length:s+1},(u,f)=>{const d=f/s*fs;return i.vertex(Math.sin(d)*e,h,Math.cos(d)*e,Math.sin(d),0,Math.cos(d))}),l=a(o),c=a(r);for(let h=0;h<s;h++)i.quad(l[h],l[h+1],c[h+1],c[h]);return nl(i,e,r,1,s),nl(i,e,o,-1,s),i.build()}function il(e){const t=Array.from({length:e.indices.length/3},()=>[]);for(const n of c0(e))for(const i of n.faces){const s=n.faces.find(r=>r!==i)??-1;t[i].push({a:n.a,b:n.b,across:s})}return{...e,faceEdges:t}}const Ln=e=>e*180/Math.PI,ae=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],ds=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],We=e=>Math.hypot(e[0],e[1],e[2]),ps=e=>{const t=We(e)||1;return[e[0]/t,e[1]/t,e[2]/t]},Fn=e=>Math.atan2(Math.sin(e),Math.cos(e));function sl(e){const[t,n,i]=ps(e);return{swing:Math.asin(Math.max(-1,Math.min(1,i))),spread:Math.atan2(t,-n)}}function f0(e,t,n,i,s){const r=e.chains.find(_=>_.id===n);if(!r)throw new Error(`reach: no chain ${n} in ${e.id}`);if(r.bones.length<2||r.rest[1]>-.99)throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);if(!e.withAngles)throw new Error(`reach: the ${e.id} plan cannot set angles`);const o=ls(e,{...t,turn:0,roll:0,lift:0},{height:s.height,contact:"none"}),a=o.chains[n],l=a.joints3[0],c=We(ae(a.joints3[1],a.joints3[0])),h=We(ae(a.joints3[2],a.joints3[1])),u=r.parent?o.chains[r.parent].frames[Math.max(0,(r.at??o.chains[r.parent].joints3.length-1)-1)]:{swing:0,spread:0},f=ae(i,l),d=Math.min(c+h-1e-6,Math.max(Math.abs(c-h)+1e-6,We(f))),m=ps(f),p=r.parent!==null,g=Rn(r.pole??(p?[0,-.35,-1]:[0,0,1]),u);let y=ae(g,[m[0]*ds(g,m),m[1]*ds(g,m),m[2]*ds(g,m)]);We(y)<1e-6&&(y=Lt([1,0,0],0)),y=ps(y);const w=(c*c+d*d-h*h)/(2*c*d),k=Math.sqrt(Math.max(0,1-w*w)),M=[l[0]+c*(w*m[0]+k*y[0]),l[1]+c*(w*m[1]+k*y[1]),l[2]+c*(w*m[2]+k*y[2])],S=[l[0]+m[0]*d,l[1]+m[1]*d,l[2]+m[2]*d],A=r.side??1,E=sl(ae(M,l)),T=sl(ae(S,M)),v=[{swing:Ln(Fn(E.swing-u.swing)),spread:Ln(Fn(E.spread-u.spread))*A},{swing:Ln(Fn(T.swing-E.swing)),spread:Ln(Fn(T.spread-E.spread))*A}];return e.withAngles(t,r,v)}const d0=.34,Tt=.12,ft=-.4,pt=(e,t,n)=>e[t]??n,p0=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),m0=.45,g0=.35,y0=.7;function Dn(e,t,n){const i=d=>Math.sqrt(Math.max(0,1-d.x*d.x-d.y*d.y)),s=tl(e,[n.x,n.y,i(n)]).facing,r=e.axes[2],o=Math.atan2(r[0],r[2]),a=Math.cos(o),l=a>=0?1:-1,c=l*Math.max(g0,Math.abs(a)),h=l*Math.max(y0,Math.abs(a)),u=Math.cos(e.angle),f=Math.sin(e.angle);return{facing:s,points:t.map(d=>{const m=m0*Math.sin(o)+n.x*c+(d.x-n.x)*h,p=d.y+r[1]*i(d),g=m*e.rx,y=p*e.ry;return{x:e.center.x+g*u+y*f,y:e.center.y+g*f-y*u}})}}const Bn=(e,t,n,i=12)=>Array.from({length:i+1},(s,r)=>{const o=r/i,a=1-o;return{x:a*a*e.x+2*a*o*t.x+o*o*n.x,y:a*a*e.y+2*a*o*t.y+o*o*n.y}}),ms=(e,t,n,i,s=16)=>Array.from({length:s},(r,o)=>{const a=Math.PI*2*o/s;return{x:e+Math.cos(a)*n,y:t+Math.sin(a)*i}}),rl=.05;function b0(e,t,n,i){const s=Math.max(1,Math.min(i*.6,.14*t.rx)),r=(y,w)=>Dn(t,y,w).points,o=(y,w)=>Dn(t,[],{x:y,y:w}).facing,a=pt(n,"smile",0),l=pt(n,"blink",0),c=pt(n,"lookX",0),h=pt(n,"lookY",0),u=pt(n,"browTilt",0);for(const y of[1,-1]){const w=y===1?"left":"right",k=d0*y;if(o(k,Tt)<rl)continue;const M={x:k,y:Tt},S=p0(pt(n,`eye.${w}`,1),l);if(S<.2){const v=a>.5?.12:-.06;e.line(r(Bn({x:k-.12,y:Tt},{x:k,y:Tt+v},{x:k+.12,y:Tt}),M),s)}else{if(S>1.2){const x=.13*S;e.shape(r(ms(k,Tt,x*.85,x),M),"#ffffff",s)}const v=S>1.2?.075:.1,_=k+c*.08,P=Tt-h*.07;e.shape(r(ms(_,P,v,v*1.1*Math.min(S,1)),M),e.ink,0)}const A=Tt+.3+pt(n,`brow.${w}`,0)*.14+Math.max(0,S-1)*.12,E={x:k+y*.13,y:A},T={x:k-y*.13,y:A+u*.1};e.line(r([E,{x:(E.x+T.x)/2,y:(E.y+T.y)/2},T],{x:k,y:A}),s)}const f={x:0,y:ft};if(o(0,ft)<-rl)return;const d=.25*Math.max(.3,pt(n,"mouthWidth",1)),m=Math.min(1,Math.max(0,pt(n,"mouth",0)));if(m<=.05){e.line(r(Bn({x:-d,y:ft},{x:0,y:ft-a*.25},{x:d,y:ft}),f),s);return}const p=.3*m;let g;if(a>.3){const y=ft+.05;g=[...Bn({x:d,y},{x:0,y:ft-p*2},{x:-d,y})]}else if(a<-.3){const y=ft-p*.6;g=[...Bn({x:d,y},{x:0,y:ft+p*1.4},{x:-d,y})]}else g=ms(0,ft,d*.8,p);e.shape(r(g,f),e.ink,0)}function ol(e={}){const t=(e.proportions??"bold")==="bold",n=e.figure??"fluid",i=e.look??"clean",s=e.height??300,r=n==="stick";return{plan:e.plan??ja({headSize:e.headSize??(t?.3:.24),shoulderWidth:r?0:e.shoulderWidth??.06,hipWidth:r?0:e.hipWidth??.022}),figure:n,look:i,height:s,lineWidth:e.lineWidth??s*(t?.045:.022),ink:e.ink??(i==="pencil"?"#2f2f33":"#1e293b"),skin:e.skin??(i==="pencil"?"none":"#ffffff"),seed:e.seed??1,pencil:e.pencil??{},layers:e.layers??{},contact:e.contact??"ground",hands:e.hands??"dot",handStyle:e.handStyle??"glove",handSize:e.handSize??(e.handStyle==="natural"?.14:.17)}}function w0(e,t,n,i){const{point:s,facing:r}=tl(e,[t,n,i]);return{point:s,facing:r}}const gs=e=>e.rest[1]<-.5,k0=.3;function v0(e,t,n){return e.figure==="stick"?gs(t)?n.slice(0,3):n:gs(t)&&n.length>=3?Ht(n[0],n[1],n[2],k0):n.length===3?Ht(n[0],n[1],n[2],1):n}function ys(e,t){const n=e.plan.id==="human"?{...q,...t}:t;return bs(e,n,ls(e.plan,n,{height:e.height,contact:e.contact}))}function bs(e,t,n){const i={},s={},r={},o=.01*e.height;e.plan.chains.forEach(f=>{const d=n.chains[f.id];i[f.id]=d.points;const m=d.depths.reduce((w,k)=>w+k,0)/d.depths.length,p=f.parent?n.chains[f.parent]:void 0,g=p?p.depths[f.at??p.depths.length-1]:0,y=m-g;r[f.id]=Math.abs(y)<o?0:y,s[f.id]={points:v0(e,f,d.points),depth:m}}),s.head={points:[n.head.center],depth:n.head.depth},r.head=0;const a=[...e.plan.chains.map(f=>f.id),"head"],l=[...a].sort((f,d)=>r[f]-r[d]||a.indexOf(f)-a.indexOf(d)),c={hip:n.hip};for(const[f,[d,m]]of Object.entries(e.plan.landmarks??{})){const p=n.chains[d]?.points;p&&(c[f]=p[Math.min(m,p.length-1)])}const h={};for(const[f,d]of Object.entries(c))h[f]=d.y>=n.groundY-.01*e.height;const u={height:e.height,lineWidth:e.lineWidth,turn:t.turn??0,points:c,chains:i,parts:s,head:n.head,groundY:n.groundY,grounded:h};return{skeleton:n,joints:u,order:l}}function al(e,t){return ys(e,t).joints}function S0(e,t,n){const{head:i}=n;e.guideEllipse(i.center.x,i.center.y,i.rx*1.03,i.ry*1.03,i.angle);const s=Array.from({length:13},(l,c)=>({x:0,y:-.95+1.9*c/12})),r=Array.from({length:13},(l,c)=>({x:-.95+1.9*c/12,y:.12})),o=Dn(i,s,{x:0,y:0});o.facing>0&&e.guide(o.points),e.guide(Dn(i,r,{x:0,y:.12}).points),e.guide(n.chains.spine??[]);const a=t.lineWidth*.9;for(const l of["shoulder.left","shoulder.right","elbow.left","elbow.right","hip.left","hip.right","knee.left","knee.right"]){const c=n.points[l];c&&e.guideEllipse(c.x,c.y,a,a,0)}}function M0(e,t,n,i,s,r){const o=n.lineWidth;if(s==="head"){const{head:d}=i,m=n.skin==="none"?null:n.skin;t.ellipse(d.center.x,d.center.y,d.rx,d.ry,d.angle,m,o),t.look!=="silhouette"&&b0(t,d,r,o);return}const a=n.plan.chains.find(d=>d.id===s),l=i.chains[s],c=i.parts[s].points;if(n.figure==="stick"){if(s==="neck")return;const d=s==="spine"?[...l,...i.chains.neck?.slice(1)??[]]:c;t.line(d,o);return}const h=(d,m)=>[a.bones[d].width[0]*o,a.bones[m].width[1]*o];if(gs(a)){const[d,m]=h(0,1);if(t.limb(c,d,m),a.bones.length>=3)t.limb([l[2],l[3]],a.bones[2].width[0]*o,a.bones[2].width[1]*o);else if(n.hands==="cartoon"&&s.startsWith("arm."))T0(e,t,n,l,s.endsWith(".left")?"left":"right",r);else{const p=l[l.length-1];t.dot(p.x,p.y,o*.62)}return}if(s==="spine"){const d=i.points["hip.left"],m=i.points["hip.right"];d&&m&&Math.hypot(d.x-m.x,d.y-m.y)>.5&&t.limb([d,m],o*1.3,o*1.3);const[p,g]=h(0,a.bones.length-1);t.limb(c,p,g);const y=i.points["shoulder.left"],w=i.points["shoulder.right"];y&&w&&Math.hypot(y.x-w.x,y.y-w.y)>.5&&t.limb(Ht(y,l[l.length-1],w,1,10),o*1.15,o*1.15);return}const[u,f]=h(0,a.bones.length-1);t.limb(c,u,f)}function ll(e,t){const n=`hand.${t}.`,i={};for(const[o,a]of Object.entries(e))o.startsWith(n)&&(i[o.slice(n.length)]=a);const s=e.turn??0,r=t==="right"?1-s:1+s;return{...Y,...i,turn:r+(i.turn??0)}}function T0(e,t,n,i,s,r){const o=i[i.length-1],a=i[i.length-2],l=Math.atan2(o.x-a.x,-(o.y-a.y))*180/Math.PI;Sn(e,o,ll(r,s),{size:n.handSize*n.height,side:s,angle:l,pen:t,skin:n.skin==="none"?"#ffffff":n.skin,fingers:n.handStyle==="natural"?5:4,plump:n.handStyle==="natural"?1.15:1.6,lineWidth:n.lineWidth*.3})}function cl(e,t,n,i=0){const s=t.plan.id==="human"?{...q,...n}:n;fl(e,t,s,ys(t,s),i)}function hl(e,t){const n=t/e.height;return{...e,height:t,lineWidth:e.lineWidth*n}}function E0(e,t,n,i){const s=e.plan.id==="human"?{...q,...t}:t,r=us(e.plan,s,{height:i.height,contact:e.contact},n);return bs(hl(e,r.height),s,r).joints}function ul(e,t,n,i,s){const r=t.plan.id==="human"?{...q,...n}:n,o=us(t.plan,r,{height:s.height,contact:t.contact},i),a=hl(t,o.height);fl(e,a,r,bs(a,r,o),s.time??0)}function fl(e,t,n,i,s){const{joints:r,order:o}=i,a=Vi(e,{look:t.look,ink:t.ink,lineWidth:t.lineWidth,seed:t.seed,time:s,pencil:t.pencil}),l=c=>{c&&(e.save(),c(e,r,a,s),e.restore())};e.save(),e.lineCap="round",e.lineJoin="round",t.look==="pencil"&&t.pencil.construction!==!1&&S0(a,t,r),l(t.layers.behind);for(const c of o){const h=t.layers.parts?.[c];l(h?.under),M0(e,a,t,r,c,n),l(h?.over)}l(t.layers.front),e.restore()}function A0(e,t,n){const i={...e};for(const[s,r]of Object.entries(t)){const o=e[s]??r;i[s]=o+(r-o)*n}return i}function x0(e,t,n,i){const s=e.plan.id==="human"?{...q,...t}:t;let r;if(Array.isArray(i))r=i;else{const{skeleton:o}=ys(e,s),a=ls(e.plan,{...s,roll:0},{height:e.height,contact:"none"}),l=(s.roll??0)*Math.PI/180,c=i.x-o.hip.x,h=i.y-o.hip.y,u=a.hip.x+c*Math.cos(-l)-h*Math.sin(-l),f=a.hip.y+c*Math.sin(-l)+h*Math.cos(-l),d=Math.PI/2*(s.turn??0),m=i.depth??o.chains[n].depths[o.chains[n].depths.length-1],p=Math.cos(d),g=Math.sin(d);r=[u*p-m*g,-f,u*g+m*p]}return f0(e.plan,s,n,r,{height:e.height})}function P0(e){const{character:t}=e,n=t.height*.8,i=t.height,s=t.plan.id==="human"?q:{};return{type:"custom",x:e.x-n/2,y:e.y-i,width:n,height:i,props:{...s,...e.pose},character:t,draw(r,o,a){r.translate(n/2,i),cl(r,t,o.props,a)}}}function dl(e,t,n){const i=r=>({x:r.x+t,y:r.y+n}),s=r=>Object.fromEntries(Object.entries(r).map(([o,a])=>[o,a.map(i)]));return{...e,points:Object.fromEntries(Object.entries(e.points).map(([r,o])=>[r,i(o)])),chains:s(e.chains),parts:Object.fromEntries(Object.entries(e.parts).map(([r,o])=>[r,{...o,points:o.points.map(i)}])),head:{...e.head,center:i(e.head.center)},groundY:e.groundY+n}}function _0(e,t,n){const i=e.character;if(!i)throw new Error("characterAt: the target was not made by characterTarget");const s={...e.props};let r=0,o=0;for(const[l,c]of t.state?.values.get(n)??[])typeof c=="number"&&(l==="x"||l==="motionPathX"?r=c:l==="y"||l==="motionPathY"?o=c:l in s&&(s[l]=c));const a=al(i,s);return{pose:s,joints:dl(a,e.x+r+e.width/2,e.y+o+e.height)}}function ws(e,t=q){const n=[];return e.forEach((i,s)=>{const r=s===0?t:n[s-1],o=typeof i.pose=="string"?Ga[i.pose]:void 0;n.push(o?{...o,turn:r.turn??0}:{...r,...i.pose})}),n}function I0(e,t,n=q){const i=ws(t,n);return Object.keys(n).filter(r=>i.some(o=>(o[r]??n[r])!==n[r])).map(r=>({id:`${e}-${r}`,target:e,property:r,keyframes:t.map((o,a)=>({time:o.time,value:i[a][r]??n[r],...o.easing?{easing:o.easing}:{}}))}))}const C0=new Set(["x","y","z","position","rotateX","rotateY","rotateZ","quaternion","scale","scaleX","scaleY","scaleZ","visible","opacity","color"]),H0=1.7;function $0(e,t,n){const i=Array.from({length:24},(s,r)=>{const o=r/24*Math.PI*2,a=t.toView([Math.cos(o)*n,0,Math.sin(o)*n*.8]);return a[2]<-.001?t.toScreen(a):null});i.some(s=>s===null)||(e.beginPath(),i.forEach((s,r)=>r===0?e.moveTo(s.x,s.y):e.lineTo(s.x,s.y)),e.closePath(),e.fillStyle="rgba(0, 0, 0, 0.22)",e.fill())}function R0(e){const t=Te([0,1,0],e);if(t>.999999)return Kr();if(t<-.999999)return Ae(Vt([1,0,0],180));const n=an([0,1,0],e);return Ae(Vt(n,Math.acos(t)*180/Math.PI))}function O0(e,t,n,i,s){const r=e.solid??{},o=r.outline===!1?void 0:r.outline??{width:2,color:"#0f172a"},a={color:r.color??"#475569",shading:r.shading??"toon",outline:o},l={color:r.skin??"#f2c49b",shading:r.shading??"toon",outline:o},c={color:"#0f172a",shading:"unlit"},h=i.height*.034,u=[],f=(k,M,S)=>u.push({mesh:k,world:_t(s,M),material:S}),d=(k,M,S)=>f(t.sphere,Xr(k,[0,0,0,1],[M,M,M]),S);for(const k of n.chains){const M=i.chains[k.id],S=k.id==="spine"?1.9:1;k.bones.forEach((A,E)=>{const T=M[E],v=M[E+1],_=Nr(T,v),[P,x]=A.width??[1,1],I=h*S*(P+x)/2;if(_>1e-6){const C=Wr(T,v,.5),H=R0(Ee(on(v,T)));f(t.cylinder,_t(Yr(C),_t(H,ln([I,_,I]))),a)}d(T,h*S*P,a),d(v,h*S*x,a)}),k.id.startsWith("arm.")&&d(M[M.length-1],h*1.5,l)}const{center:m,rx:p,ry:g,axes:y}=i.head,w=[...y[0],0,...y[1],0,...y[2],0,...m,1];f(t.sphere,_t(w,ln([p,g,p])),l);for(const k of[-1,1]){const M=Ee([k*.36,.15,.92]),S=rn(m,rn(rn(Me(y[0],M[0]*p*1.04),Me(y[1],M[1]*g*1.04)),Me(y[2],M[2]*p*1.04))),A=[...y[0],0,...y[1],0,...y[2],0,...S,1];f(t.sphere,_t(A,ln([p*.11,g*.14,p*.03])),c)}return u}const L0={kind:"character",validate(e){const t=e;return t.height!==void 0&&!(t.height>0)?["a character's height must be positive"]:[]},prepare(e){return{who:ol({...e.character,height:1}),cylinder:il(u0(1,1,16)),sphere:il(h0(1,20))}},resolve({object:e,prepared:t,values:n,world:i,camera:s,toScreen:r}){const o=e,a=t,l=a.who,c={...q,...o.pose};for(const[g,y]of n)typeof y=="number"&&!C0.has(g)&&(c[g]=y);const h=o.height??H0,u=_t(s.view,i),f={toView:g=>qr(u,g),toScreen:g=>r(g)},m=-f.toView([0,h/2,0])[2];if(m<=s.near)return null;const p=o.shadow===!1?[]:[{depth:m+h,draw:g=>$0(g,f,h*.18)}];if(o.look==="solid"){const g=hs(l.plan,c,{height:h,contact:l.contact});return{meshes:O0(o,a,l.plan,g,i),drawables:p}}return{drawables:[...p,{depth:m,draw(g,y){g.lineCap="round",g.lineJoin="round",ul(g,l,c,f,{height:h,time:y.time})}}]}}},pl={x:0,y:0,scale:1,rotate:0,shakeX:0,shakeY:0,shakeRotate:0};function F0(e){const t=n=>{const i=e?.get(n);return typeof i=="number"?i:pl[n]};return{x:t("x"),y:t("y"),scale:t("scale"),rotate:t("rotate"),shakeX:t("shakeX"),shakeY:t("shakeY"),shakeRotate:t("shakeRotate")}}function D0(e,t,n){const i=n.width/2,s=n.height/2,o=1+2*Math.max(Math.abs(t.shakeX),Math.abs(t.shakeY))/Math.max(1,Math.min(n.width,n.height));e.translate(i+t.x+t.shakeX,s+t.y+t.shakeY),e.rotate((t.rotate+t.shakeRotate)*Math.PI/180),e.scale(t.scale*o,t.scale*o),e.translate(-i,-s)}function B0(e,t,n){const i=t.width/2,s=t.height/2,r=(e.rotate+e.shakeRotate)*Math.PI/180,o=(n.x-i)*e.scale,a=(n.y-s)*e.scale;return{x:i+e.x+e.shakeX+o*Math.cos(r)-a*Math.sin(r),y:s+e.y+e.shakeY+o*Math.sin(r)+a*Math.cos(r)}}function ml(e,t,n={},i){const s=n.length??240,r=9,o=28,a=s-22;e.save(),e.translate(t.x,t.y),e.rotate((n.angle??-30)*Math.PI/180),e.fillStyle=n.color??"#f4c542",e.fillRect(o,-r,a-o,2*r),e.fillStyle="#e8b4a0",e.fillRect(a,-r,s-a,2*r),e.fillStyle="#f1dcbf",e.beginPath(),e.moveTo(0,0),e.lineTo(o,-r),e.lineTo(o,r),e.closePath(),e.fill(),e.fillStyle=n.outline??"#2f2f33",e.beginPath(),e.moveTo(0,0),e.lineTo(o*.35,-r*.35),e.lineTo(o*.35,r*.35),e.closePath(),e.fill(),e.strokeStyle=n.outline??"#2f2f33",e.lineWidth=3,e.lineJoin="round",e.lineCap="round";const l=[[{x:0,y:0},{x:o,y:-r},{x:s,y:-r},{x:s,y:r},{x:o,y:r},{x:0,y:0}],[{x:o,y:-r},{x:o,y:r}],[{x:a,y:-r},{x:a,y:r}]];for(const c of l)bl(e,c,i);e.restore()}function ks(e,t,n={},i){const s=n.length??90,r=n.thickness??34;e.save(),e.translate(t.x,t.y),e.rotate((n.angle??-35)*Math.PI/180);const o=-r/2;e.fillStyle=n.color??"#f4a7b9",e.fillRect(0,o,s,r),e.fillStyle="#e9edf2",e.fillRect(s*.45,o,s*.55,r),e.strokeStyle=n.outline??"#2f2f33",e.lineWidth=3,e.lineJoin="round";const a=[{x:0,y:o},{x:s,y:o},{x:s,y:-o},{x:0,y:-o},{x:0,y:o}],l=[{x:s*.45,y:o},{x:s*.45,y:-o}];if(i)i.line(a),i.line(l);else for(const c of[a,l]){e.beginPath(),e.moveTo(c[0].x,c[0].y);for(const h of c.slice(1))e.lineTo(h.x,h.y);e.stroke()}e.restore()}const gl=150,N0={pencil:44,eraser:30};function vs(e,t,n={},i){const s=n.tool??"pencil",r=n.skin??"#f1c9a5",o=n.outline??"#2f2f33",a=n.scale??1,l=Math.min(1,Math.max(0,n.lift??0)),c=(n.angle??-30)*Math.PI/180,h=i?i.nudge(.6):{x:0,y:0},u=gl*a*(1+.05*l);l>0&&(e.save(),e.fillStyle=o,e.globalAlpha=.15*l,e.beginPath(),e.ellipse(t.x,t.y,9*a,4*a,0,0,Math.PI*2),e.fill(),e.restore());const f={x:t.x+h.x+6*l*a,y:t.y+h.y-18*l*a},d=U.pencilGrip,m=E=>{const T=E.fingers.thumb,v=E.fingers.index,_=E.fingers.middle,P=yl([T.points[3],v.points[3],_.points[3]]),x=yl([T.points[1],v.points[0]]),I=(T.depths[3]+v.depths[3]+_.depths[3])/3;return{pinch:P,direction:Math.atan2(x.y-P.y,x.x-P.x),depth:I}},p=vn(d,{size:u}),g=c-m(p).direction,y=vn(d,{size:u,angle:g*180/Math.PI}),w=m(y),k=N0[s]*a,M={x:w.pinch.x-Math.cos(c)*k,y:w.pinch.y-Math.sin(c)*k},S={x:f.x-M.x,y:f.y-M.y},A=y.axes.up;W0(e,S,{x:-A.x,y:-A.y},u,n.arm??300*a,r,n.sleeve??"#5b7db1",o),Sn(e,S,d,{size:u,angle:g*180/Math.PI,skin:r,ink:o,lineWidth:3*a,prop:{depth:w.depth,draw:()=>{e.save(),e.translate(f.x,f.y),e.scale(a,a),s==="eraser"?ks(e,{x:0,y:0},{angle:c*180/Math.PI,outline:o},i):ml(e,{x:0,y:0},{angle:c*180/Math.PI,length:190,outline:o},i),e.restore()}}})}const yl=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length});function W0(e,t,n,i,s,r,o,a){const l={x:-n.y,y:n.x},c=i*.15,h=(p,g,y)=>({x:t.x+n.x*p+l.x*g*y,y:t.y+n.y*p+l.y*g*y}),u=h(s,0,0),f=p=>{const g=e.createLinearGradient(t.x,t.y,u.x,u.y);return g.addColorStop(0,p),g.addColorStop(.6,p),g.addColorStop(1,q0(p)),g},d=Math.min(i*.55,s*.35);e.save(),e.lineJoin="round",e.lineCap="round",e.lineWidth=3*(i/gl),e.beginPath(),e.moveTo(h(-i*.1,-1,c).x,h(-i*.1,-1,c).y),e.lineTo(h(d+4,-1,c*1.1).x,h(d+4,-1,c*1.1).y),e.lineTo(h(d+4,1,c*1.1).x,h(d+4,1,c*1.1).y),e.lineTo(h(-i*.1,1,c).x,h(-i*.1,1,c).y),e.closePath(),e.fillStyle=r,e.fill(),e.strokeStyle=a,e.beginPath(),e.moveTo(h(0,-1,c).x,h(0,-1,c).y),e.lineTo(h(d,-1,c*1.1).x,h(d,-1,c*1.1).y),e.moveTo(h(0,1,c).x,h(0,1,c).y),e.lineTo(h(d,1,c*1.1).x,h(d,1,c*1.1).y),e.stroke();const m=[h(d,-1,c*1.3),h(s,-1,c*1.5),h(s,1,c*1.5),h(d,1,c*1.3)];e.beginPath(),m.forEach((p,g)=>g?e.lineTo(p.x,p.y):e.moveTo(p.x,p.y)),e.closePath(),e.fillStyle=f(o),e.fill(),e.strokeStyle=f(a),e.beginPath(),e.moveTo(m[1].x,m[1].y),e.lineTo(m[0].x,m[0].y),e.lineTo(m[3].x,m[3].y),e.lineTo(m[2].x,m[2].y),e.stroke(),e.restore()}function K0(e,t,n={}){const i=n.offstage??{x:2e3,y:1400},s=n.enter??450,r=n.exit??450,o=n.linger??1500,a=[...e].filter(p=>p.path.length>0).sort((p,g)=>p.start-g.start),l=p=>p.tool??"pencil",c=p=>{const g=Math.min(1,Math.max(0,p));return g*g*(3-2*g)},h=(p,g,y)=>({x:p.x+(g.x-p.x)*y,y:p.y+(g.y-p.y)*y}),u=a.find(p=>t>=p.start&&t<=p.end);if(u){const p=u.end-u.start,g=p>0?(t-u.start)/p:1;return{at:gn(u.path,g),tool:l(u),lift:0,drawing:!0}}const f=[...a].reverse().find(p=>p.end<t),d=a.find(p=>p.start>t),m=p=>p.path[p.path.length-1];if(f&&d&&d.start-f.end<=o){const p=(t-f.end)/(d.start-f.end),g=p<.5?l(f):l(d);return{at:h(m(f),d.path[0],c(p)),tool:g,lift:Math.sin(Math.PI*p),drawing:!1}}if(d&&d.start-t<=s){const p=1-(d.start-t)/s;return{at:h(i,d.path[0],c(p)),tool:l(d),lift:1-c(p),drawing:!1}}if(f&&t-f.end<=r){const p=(t-f.end)/r;return{at:h(m(f),i,c(p)),tool:l(f),lift:c(p),drawing:!1}}return null}function Y0(e,t,n,i=.08,s=32){const r=Math.PI*2*(1+i),o=[];for(let a=0;a<=s;a++){const l=-Math.PI/2+r*a/s;o.push({x:e+Math.cos(l)*n,y:t+Math.sin(l)*n})}return o}function X0(e){const{path:t}=e,n=t.map(a=>a.x),i=t.map(a=>a.y),s=Math.min(...n),r=Math.min(...i),o=e.hand===!1?void 0:e.hand===!0||e.hand===void 0?{}:e.hand;return{type:"custom",x:s,y:r,width:Math.max(1,Math.max(...n)-s),height:Math.max(1,Math.max(...i)-r),props:{draw:0},draw(a,l,c){const h=Math.min(1,Math.max(0,Number(l.props?.draw??0)));a.translate(-s,-r),a.strokeStyle=e.color??"#2f2f33",a.lineWidth=e.lineWidth??5,a.lineCap="round",a.lineJoin="round";const u=e.sketch?yn(a,e.sketch,c):void 0;h>0&&(u?e.smooth?u.curve(t,h):u.line(t,h):bl(a,ee(t,h))),o&&h>0&&h<1&&vs(a,gn(t,h),o,u)}}}function q0(e){const t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return"rgba(0, 0, 0, 0)";const n=t[1].length===3?[...t[1]].map(o=>o+o).join(""):t[1],[i,s,r]=[0,2,4].map(o=>parseInt(n.slice(o,o+2),16));return`rgba(${i}, ${s}, ${r}, 0)`}function bl(e,t,n){if(!(t.length<2)){if(n)return n.line(t);e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t.slice(1))e.lineTo(i.x,i.y);e.stroke()}}const Nn=1e5;function V0(e,t,n,i,s=6){const r=[],o=Math.max(1,Math.round(s));for(let a=0;a<=o;a++)r.push({x:a%2===0?e:e+n,y:t+i*a/o});return r}function Ss(e,t,n,i){if(i<=0||t.length===0)return;const s=ee(t,i),r=n/2,o=a=>{e.beginPath(),e.rect(-Nn,-Nn,2*Nn,2*Nn),a(),e.clip("evenodd")};for(const a of s)o(()=>{e.moveTo(a.x+r,a.y),e.arc(a.x,a.y,r,0,Math.PI*2)});for(let a=1;a<s.length;a++){const l=s[a-1],c=s[a],h=Math.hypot(c.x-l.x,c.y-l.y);if(h===0)continue;const u=-(c.y-l.y)/h*r,f=(c.x-l.x)/h*r;o(()=>{e.moveTo(l.x+u,l.y+f),e.lineTo(c.x+u,c.y+f),e.lineTo(c.x-u,c.y-f),e.lineTo(l.x-u,l.y-f),e.closePath()})}}function U0(e,t,n,i,s){e.save(),Ss(e,t,n,i),s(),e.restore()}function z0(e,t){const n=t.width??40,i=t.hand===!0?{}:t.hand||void 0,s=t.eraser===!1?void 0:t.eraser===!0||t.eraser===void 0?{}:t.eraser;return{...e,props:{...e.props,erase:0},draw(r,o,a){const l=Number(o.props?.erase??0);if(r.save(),Ss(r,t.path,n,l),e.draw(r,o,a),r.restore(),!s||l<=0||l>=1)return;const c=gn(t.path,l);i?vs(r,c,{...i,tool:"eraser"}):ks(r,c,s)}}}const wl=40,G0=.215+.205,it=(e,t)=>{const n={};for(const i of["left","right"])for(const[s,r]of Object.entries(t))n[`${e}.${i}.${s}`]=r;return n},F=(e,t)=>e[t]??q[t]??0;function j0(e,t,n=q,i=1){const s=Le(e),r=t*Math.PI*2,o=Math.sin(r)*i,a=Math.cos(r)*i,l=(1+Math.cos(r*2*(s.bounces??1)))/2,c=s.crouch??0,h=s.shoulder??0,u=s.forearm??0,f={...q,...n};f["leg.left.swing"]=s.swing*o+c*.6,f["leg.right.swing"]=-s.swing*o+c*.6,f["leg.left.knee"]=s.knee*Math.max(0,a)+c*1.2,f["leg.right.knee"]=s.knee*Math.max(0,-a)+c*1.2,f["leg.left.ankle"]=F(n,"leg.left.ankle")-(s.tiptoe??0),f["leg.right.ankle"]=F(n,"leg.right.ankle")-(s.tiptoe??0);for(const[d,m]of[["left",-1],["right",1]])F(n,`arm.${d}.spread`)>wl||F(n,`arm.${d}.swing`)>wl||(f[`arm.${d}.swing`]=h+m*s.arm*o,f[`arm.${d}.elbow`]=F(n,`arm.${d}.elbow`)+u+s.elbow*Math.max(0,m*o));return f.lean=F(n,"lean")+s.lean*i,f.bend=F(n,"bend")+(s.bend??0),f["head.nod"]=F(n,"head.nod")-s.lean*.5*i+(s.headTilt??0),f.side=F(n,"side")+(s.sway??0)*Math.sin(r),f.lift=F(n,"lift")+(s.bounce??0)*i*l,f.stretch=F(n,"stretch")*(1+(s.squash??0)*(l-.5)),f}function J0(e,t,n=1){const i=Le(e);return 4*G0*t*Math.sin(i.swing*n*Math.PI/180)}const le=e=>Ja[e],kl={take:e=>[{after:140,pose:{stretch:.8,bend:10,lean:F(e,"lean")-4,...it("arm",{spread:6,swing:0,elbow:10}),"eye.left":.35,"eye.right":.35,"brow.left":-.6,"brow.right":-.6,mouth:0},easing:"ease-in-out"},{after:260,pose:{stretch:.78}},{after:360,pose:{lift:.22,stretch:1.35,bend:-14,...it("arm",{spread:150,bend:35,swing:0,elbow:0}),...it("leg",{swing:25,knee:60}),...le("shocked")},easing:"ease-out-cubic"},{after:720,pose:{lift:.25,stretch:1.25,bend:-10,...it("arm",{spread:140})},easing:"ease-in-out"},{after:900,pose:{lift:0,stretch:.74,bend:12,...it("arm",{spread:70,bend:0}),...it("leg",{swing:30,knee:60})},easing:"ease-in-quad"},{after:1060,pose:{stretch:1.06,bend:-3,...it("arm",{spread:60}),"leg.left.swing":F(e,"leg.left.swing"),"leg.right.swing":F(e,"leg.right.swing"),"leg.left.knee":F(e,"leg.left.knee"),"leg.right.knee":F(e,"leg.right.knee")},easing:"ease-out"},{after:1260,pose:{stretch:F(e,"stretch"),bend:F(e,"bend"),...le("surprised"),...it("arm",{spread:55,bend:60})},easing:"ease-in-out"}],doubleTake:e=>[{after:160,pose:{lookX:1,lookY:0,"head.turn":0},easing:"ease-out"},{after:520,pose:{lookX:-.6,"head.turn":30,"head.nod":F(e,"head.nod")-4,smile:.6,mouth:0},easing:"ease-in-out"},{after:1100,pose:{lookX:-.6}},{after:1180,pose:{"head.turn":0,"head.nod":F(e,"head.nod")-10,bend:F(e,"bend")-10,lift:.05,stretch:1.18,...le("shocked"),lookX:1,lookY:0},easing:"ease-out-cubic"},{after:1360,pose:{lift:0,stretch:.88,"head.nod":F(e,"head.nod")-4,bend:F(e,"bend")+4},easing:"ease-in-quad"},{after:1560,pose:{stretch:F(e,"stretch"),"head.nod":F(e,"head.nod"),bend:F(e,"bend")},easing:{type:"elastic",mode:"out",amplitude:1,period:.35}}],windUp:()=>[{after:220,pose:{lean:-18,bend:-16,"head.nod":-6,"arm.left.swing":60,"arm.left.elbow":100,"arm.right.swing":-40,"arm.right.elbow":90,"leg.left.swing":55,"leg.left.knee":95,stretch:.92,...le("angry"),lookX:1},easing:"ease-out"},{after:620,pose:{lean:-20,bend:-18,stretch:.9}},{after:700,pose:{lean:28,bend:14,"head.nod":6,"arm.left.swing":-30,"arm.right.swing":60,"leg.left.swing":-20,"leg.left.knee":30,"leg.right.swing":20,stretch:1.12},easing:"ease-out-cubic"}],land:e=>[{after:120,pose:{lift:0,stretch:.7,bend:14,...it("arm",{spread:75}),...it("leg",{swing:25,knee:50})},easing:"ease-in-quad"},{after:300,pose:{stretch:1.05,bend:-4,"arm.left.spread":F(e,"arm.left.spread"),"arm.right.spread":F(e,"arm.right.spread")},easing:"ease-out"},{after:460,pose:{lift:0,stretch:F(e,"stretch"),bend:F(e,"bend"),...it("leg",{swing:0,knee:0})},easing:"ease-in-out"}],tremble:e=>{const t=[{after:80,pose:{...le("scared"),...it("arm",{swing:40,elbow:110,spread:14}),stretch:.94,bend:F(e,"bend")+8},easing:"ease-out"}];for(let n=1;n<=14;n++){const i=n%2===0?1:-1;t.push({after:80+n*45,pose:{side:F(e,"side")+2.5*i,"head.tilt":F(e,"head.tilt")-2*i}})}return t.push({after:755,pose:{side:F(e,"side"),"head.tilt":F(e,"head.tilt"),bend:F(e,"bend")}}),t},deflate:e=>[{after:260,pose:{stretch:1.04,"head.nod":F(e,"head.nod")-4,"brow.left":.3,"brow.right":.3},easing:"ease-in-out"},{after:900,pose:{...le("sad"),bend:18,stretch:.92,lean:F(e,"lean")+5,"head.nod":14,...it("arm",{spread:6,swing:0,elbow:4,bend:0})},easing:"ease-in-out"}]};function Z0(e,t){const n=nt(t.from??{}),i=t.speed??1;let s=n;return[{time:t.at,pose:n},...kl[e](n).map(r=>(s={...s,...r.pose},{time:t.at+r.after*i,pose:s,act:!1,...r.easing?{easing:r.easing}:{}}))]}const Q0=(e,t,n)=>e.slice(Math.floor((e.length-1)*t),Math.ceil((e.length-1)*n)+1);function tp(e={}){const t=e.shirt??"#e2493b",n=e.trousers??"#24476b",i=a=>a.lineWidth*.45,s=(a,l,c)=>{const h=a.parts[`leg.${c}`].points;l.shape($e(h,a.height*.08,a.height*.05),n,i(a))},r=(a,l)=>{const c=a.chains.spine,h=c[0],u=c[c.length-1],f={x:h.x-(u.x-h.x)*.25,y:h.y-(u.y-h.y)*.25};l.shape($e([f,...a.parts.spine.points],a.height*.15,a.height*.14),t,i(a))},o=(a,l,c)=>{const h=a.parts[`arm.${c}`].points,u=h[0],f=a.chains.spine[a.chains.spine.length-1],m=[{x:u.x+(f.x-u.x)*.45,y:u.y+(f.y-u.y)*.45},...Q0(h,0,.45)],p=$e(m,a.height*.085,a.height*.06),g=m.length,y=p.slice(0,g),w=p.slice(g).reverse();l.shape(p,t,0);const k=A=>Math.hypot(A[1].x-f.x,A[1].y-f.y),[M,S]=k(y)>k(w)?[y,w]:[w,y];l.line(M.slice(1),i(a)),l.line(S.slice(Math.ceil(g*.45)),i(a)),l.line([y[g-1],w[g-1]],i(a))};return{parts:{"leg.left":{over:(a,l,c)=>s(l,c,"left")},"leg.right":{over:(a,l,c)=>s(l,c,"right")},spine:{over:(a,l,c)=>r(l,c)},"arm.left":{over:(a,l,c)=>o(l,c,"left")},"arm.right":{over:(a,l,c)=>o(l,c,"right")}}}}const Wn={full:{anticipation:.12,anticipationTime:.3,hold:0,overshoot:.08,settle:220,settleEase:"ease-in-out",actionEase:"ease-in-out-cubic",overlap:45,eyeLead:120,eyeDart:160,drift:.12,blinks:!0,jumpSquash:1},snappy:{anticipation:.2,anticipationTime:.35,hold:.12,overshoot:.12,settle:320,settleEase:{type:"elastic",mode:"out",amplitude:1,period:.35},actionEase:"ease-out-cubic",overlap:35,eyeLead:100,eyeDart:100,drift:.1,blinks:!0,jumpSquash:1.3},limited:{anticipation:.06,anticipationTime:.25,hold:0,overshoot:0,settle:0,settleEase:"ease-out",actionEase:"ease-in-out",overlap:30,eyeLead:80,eyeDart:120,drift:0,blinks:!0,jumpSquash:.6},none:{anticipation:0,anticipationTime:0,hold:0,overshoot:0,settle:0,settleEase:"linear",actionEase:"linear",overlap:0,eyeLead:0,eyeDart:0,drift:0,blinks:!1,jumpSquash:0}};function vl(e){if(e===void 0)return Wn.full;if(typeof e=="string")return Wn[e];const{base:t,...n}=e;return{...Wn[t??"full"],...n}}const Ms=160,ep=120,np=700,Ts=60,ip=90,Kn=3200,ce=1,Ft=1e-6;function Es(e,t,n={}){const i=vl(n.style),s=n.seed??1,r={};if(e.length===0)return r;const o=Object.keys(e[0].pose).filter(u=>e.some(f=>Math.abs(f.pose[u]-e[0].pose[u])>Ft));for(const u of o)r[u]=sp(u,e,t,i,s);const a=t.blink,l=a!==void 0&&o.includes(a);if(i.blinks&&a!==void 0&&!l&&a in e[0].pose){const u=rp(e,t,i,s,e[0].pose[a]);u.length>0&&(r[a]=u)}const{lift:c,stretch:h}=t;if(i.jumpSquash>0&&c&&h&&o.includes(c)&&!o.includes(h)&&h in e[0].pose){const u=op(e,c,e[0].pose[h],i.jumpSquash);u.length>0&&(r[h]=u)}return r}function sp(e,t,n,i,s){const r=n.eyes.includes(e),o=n.limits[e],a=o!==void 0,l=r?-i.eyeLead:(n.depth[e]??1)*i.overlap,c=d=>{const m=(t[d].time-t[d-1].time)/2;return Math.max(-m,Math.min(m,l))},h=[{time:t[0].time,value:t[0].pose[e]}],u=(d,m,p)=>{const g=h[h.length-1];if(d<=g.time+ce){h[h.length-1]={...g,value:m,...p?{easing:p}:{}};return}h.push({time:d,value:m,...p?{easing:p}:{}})};let f=t[0].pose[e];for(let d=1;d<t.length;d++){const m=t[d],p=t[d-1].pose[e],g=m.pose[e],y=g-p,w=h[h.length-1].time,k=m.act!==!1;if(Math.abs(y)<=Ft){const P=m.time+(k?c(d):0);if(d===t.length-1)Math.abs(f-g)>Ft&&u(Math.max(P,w+Ms),g,"ease-in-out"),f=g;else if(k&&a&&i.drift>0&&n.drift.includes(e)&&P-w>=np){const x=Gt(`${s}:${e}:${d}`)%2===0?1:-1;f=g+x*i.drift*o,u(P,f,"ease-in-out")}continue}if(!k){u(t[d-1].time,f),u(m.time,g,m.easing),f=g;continue}const M=c(d),S=Math.max(t[d-1].time+M,w);let A=m.time+M;r&&i.eyeDart>0&&(A=Math.min(A,S+i.eyeDart));const E=A-S;if(E<=ce){u(m.time,g,m.easing),f=g;continue}u(S,f);const T=Math.sign(y);if(a&&i.anticipation>0&&o>0&&E>=Ms){const P=f-T*Math.min(Math.abs(y)*i.anticipation,o),x=S+E*i.anticipationTime;u(x,P,"ease-in-out"),i.hold>0&&u(x+E*i.hold,P)}const v=d+1<t.length?t[d+1].time-m.time:1/0,_=Math.min(i.settle,v/2);if(a&&i.overshoot>0&&o>0&&E>=ep&&_>ce){const P=Math.min(Math.abs(y)*i.overshoot,o);u(A,g+T*P,m.easing??i.actionEase),u(A+_,g,i.settleEase)}else u(A,g,m.easing??i.actionEase);f=g}return h}function rp(e,t,n,i,s){const r=[],o=Ts+ip;for(let d=1;d<e.length;d++){const m=e[d-1].pose,p=e[d].pose;Object.entries(t.headTurns).some(([y,w])=>Math.abs((p[y]??0)-(m[y]??0))>w)&&e[d].act!==!1&&r.push(Math.max(e[0].time,e[d-1].time-n.eyeLead))}const a=e[0].time,l=e[e.length-1].time,c=[...r];let h=a+Kn*.6,u=0;for(;h<l;){c.some(p=>Math.abs(p-h)<Kn/2)||r.push(h);const m=(Gt(`${i}:blink:${u++}`)%1e3/1e3-.5)*(Kn*.66);h+=Kn+m}r.sort((d,m)=>d-m);const f=[{time:a,value:s}];for(const d of r){const m=f[f.length-1].time;d+Ts<=m+ce||(d>m+ce&&f.push({time:d,value:s}),f.push({time:d+Ts,value:1,easing:"ease-in"}),f.push({time:d+o,value:s,easing:"ease-out"}))}return f.length>1?f:[]}function op(e,t,n,i){const s=n*(1-.18*i),r=n*(1+.14*i),o=[{time:e[0].time,value:n}],a=(l,c,h)=>{const u=o[o.length-1];l<=u.time+ce||o.push({time:l,value:c,...h?{easing:h}:{}})};for(let l=1;l<e.length;l++){const c=e[l-1].pose[t],h=e[l].pose[t],u=e[l-1].time,f=e[l].time,d=f-u;if(!(d<Ms||e[l].act===!1)){if(c<=Ft&&h>Ft)a(u,n),a(u+d*.2,s,"ease-out"),a(u+d*.45,r,"ease-out"),a(f,n,"ease-in-out");else if(c>Ft&&h<=Ft){const m=l+1<e.length?e[l+1].time-f:400;a(u+d*.5,n),a(f-Math.min(60,d*.15),r,"ease-in"),a(f,s,"ease-out"),a(f+Math.min(260,m/2),n,{type:"back",mode:"out",overshoot:1.4})}}}return o.length>1?o:[]}const Sl={depth:{lean:0,bend:0,rise:0,sit:0,spin:0,stretch:0,turn:0,leftHip:0,rightHip:0,headTilt:1,leftShoulder:1,rightShoulder:1,leftKnee:1,rightKnee:1,leftBrow:1,rightBrow:1,browTilt:1,leftEye:1,rightEye:1,leftElbow:2,rightElbow:2,leftAnkle:2,rightAnkle:2,leftFootOut:2,rightFootOut:2,mouth:2,smile:2,mouthWidth:2,leftWrist:3,rightWrist:3},limits:{lean:10,bend:10,headTilt:12,spin:25,turn:.06,sit:.06,stretch:.08,rise:0,leftShoulder:20,rightShoulder:20,leftElbow:18,rightElbow:18,leftWrist:15,rightWrist:15,leftHip:12,rightHip:12,leftKnee:15,rightKnee:15,leftAnkle:10,rightAnkle:10,leftBrow:.25,rightBrow:.25,leftEye:.15,rightEye:.15},eyes:["lookX","lookY"],blink:"blink",headTurns:{turn:.15,headTilt:8,lookX:.5,spin:45},drift:["lean","bend","headTilt","leftShoulder","rightShoulder","leftElbow","rightElbow"],lift:"rise",stretch:"stretch"};function ap(e){return/^(turn|lean|bend|side|lift|roll|stretch)$/.test(e)?{depth:0,limit:{turn:.06,lean:10,bend:10,side:8,lift:0,roll:25,stretch:.08}[e]}:/^leg\.\w+\.(swing|spread|rotate)$/.test(e)?{depth:0,limit:12}:/^head\./.test(e)?{depth:1,limit:12}:/^arm\.\w+\.(swing|spread)$/.test(e)?{depth:1,limit:20}:/^leg\.\w+\.knee$/.test(e)?{depth:1,limit:15}:/^(brow\.|browTilt$)/.test(e)?{depth:1,limit:e==="browTilt"?void 0:.25}:/^eye\./.test(e)?{depth:1,limit:.15}:/^arm\.\w+\.(elbow|bend)$/.test(e)?{depth:2,limit:18}:/^leg\.\w+\.(ankle|toeOut)$/.test(e)?{depth:2,limit:10}:/^(mouth|smile|mouthWidth)$/.test(e)?{depth:2}:/^hand\./.test(e)?{depth:3}:{depth:1}}function lp(){const e={},t={};for(const n of Object.keys(q)){const i=ap(n);e[n]=i.depth,i.limit!==void 0&&(t[n]=i.limit)}return{depth:e,limits:t,eyes:["lookX","lookY"],blink:"blink",headTurns:{turn:.15,"head.turn":15,"head.nod":12,lookX:.5,roll:45},drift:["lean","bend","head.tilt","head.nod","arm.left.spread","arm.right.spread","arm.left.elbow","arm.right.elbow"],lift:"lift",stretch:"stretch"}}const Ml=lp();function Tl(e,t){return Object.entries(t).map(([n,i])=>({id:`${e}-${n}`,target:e,property:n,keyframes:i}))}function El(e,t,n={}){const i=Qi(t),s=t.map((r,o)=>({time:r.time,pose:{...i[o]},easing:r.easing,act:r.act}));return Tl(e,Es(s,n.rig??Sl,n))}function cp(e,t,n={}){const i=n.rest??q,s=ws(t,i),r=t.map((o,a)=>({time:o.time,pose:{...i,...s[a]},easing:o.easing,act:o.act}));return Tl(e,Es(r,n.rig??Ml,n))}const Al=G.shocked,hp=G.scared,Yn={take:e=>[{after:140,pose:{stretch:.8,bend:10,lean:e.lean-4,leftShoulder:8,rightShoulder:8,leftEye:.35,rightEye:.35,leftBrow:-.6,rightBrow:-.6,mouth:0},easing:"ease-in-out"},{after:260,pose:{stretch:.78}},{after:360,pose:{rise:.22,stretch:1.35,bend:-14,leftShoulder:150,rightShoulder:150,leftElbow:35,rightElbow:35,leftHip:22,rightHip:22,leftKnee:45,rightKnee:45,...Al,headTilt:0},easing:"ease-out-cubic"},{after:720,pose:{rise:.25,stretch:1.25,bend:-10,leftShoulder:140,rightShoulder:140},easing:"ease-in-out"},{after:900,pose:{rise:0,stretch:.74,bend:12,leftShoulder:70,rightShoulder:70,leftHip:18,rightHip:18,leftKnee:30,rightKnee:30},easing:"ease-in-quad"},{after:1060,pose:{stretch:1.06,bend:-3,leftShoulder:60,rightShoulder:60,leftHip:e.leftHip,rightHip:e.rightHip,leftKnee:e.leftKnee,rightKnee:e.rightKnee},easing:"ease-out"},{after:1260,pose:{stretch:e.stretch,bend:e.bend,...G.surprised,leftShoulder:70,rightShoulder:70,leftElbow:60,rightElbow:60},easing:"ease-in-out"}],doubleTake:e=>[{after:160,pose:{lookX:1,lookY:0},easing:"ease-out"},{after:520,pose:{lookX:-.6,headTilt:e.headTilt-4,smile:.6,mouth:0},easing:"ease-in-out"},{after:1100,pose:{lookX:-.6}},{after:1180,pose:{bend:e.bend-10,headTilt:e.headTilt+10,rise:.05,stretch:1.18,...Al,lookX:1,lookY:0},easing:"ease-out-cubic"},{after:1360,pose:{rise:0,stretch:.88,bend:e.bend+4,headTilt:e.headTilt+4},easing:"ease-in-quad"},{after:1560,pose:{stretch:e.stretch,bend:e.bend,headTilt:e.headTilt},easing:{type:"elastic",mode:"out",amplitude:1,period:.35}}],windUp:()=>[{after:220,pose:{lean:-18,bend:-16,headTilt:-6,leftShoulder:70,leftElbow:-100,rightShoulder:40,rightElbow:100,leftHip:-45,leftKnee:-80,stretch:.92,...G.angry,lookX:1},easing:"ease-out"},{after:620,pose:{lean:-20,bend:-18,stretch:.9}},{after:700,pose:{lean:28,bend:14,headTilt:6,leftShoulder:30,rightShoulder:60,leftHip:30,leftKnee:-30,rightHip:-20,stretch:1.12},easing:"ease-out-cubic"}],land:e=>[{after:120,pose:{rise:0,stretch:.7,bend:14,leftShoulder:75,rightShoulder:75,leftHip:20,rightHip:20,leftKnee:35,rightKnee:35},easing:"ease-in-quad"},{after:300,pose:{stretch:1.05,bend:-4,leftShoulder:e.leftShoulder,rightShoulder:e.rightShoulder},easing:"ease-out"},{after:460,pose:{rise:0,stretch:e.stretch,bend:e.bend,leftHip:W.leftHip,rightHip:W.rightHip,leftKnee:0,rightKnee:0},easing:"ease-in-out"}],tremble:e=>{const t=[{after:80,pose:{...hp,bend:e.bend+8,leftShoulder:40,rightShoulder:40,leftElbow:110,rightElbow:110,stretch:.94},easing:"ease-out"}];for(let n=1;n<=14;n++)t.push({after:80+n*45,pose:{lean:e.lean+(n%2===0?2.5:-2.5),headTilt:e.headTilt+(n%2===0?-2:2)}});return t.push({after:755,pose:{lean:e.lean,headTilt:e.headTilt,bend:e.bend}}),t},deflate:e=>[{after:260,pose:{stretch:1.04,headTilt:e.headTilt+4,leftBrow:.3,rightBrow:.3},easing:"ease-in-out"},{after:900,pose:{...se.sad,bend:18,stretch:.92,lean:e.lean+5,turn:e.turn,sit:e.sit},easing:"ease-in-out"}]};function As(e,t){const n=typeof t.from=="string"?se[t.from]:t.from??W,i=t.speed??1;let s=n;return[{time:t.at,pose:n},...Yn[e](n).map(r=>(s={...s,...r.pose},{time:t.at+r.after*i,pose:s,act:!1,...r.easing?{easing:r.easing}:{}}))]}function xs(e,t=1){const n=Yn[e](W);return n[n.length-1].after*t}function xl(e,t,n={}){if(t.length<2)return;const i=Math.max(1,Math.round(n.lines??3)),s=n.spacing??5,r=n.lineWidth??2,o=n.opacity??.7;e.save(),e.strokeStyle=n.color??"#222",e.lineCap="round";for(let a=0;a<i;a++){const l=(a-(i-1)/2)*s,c=Math.floor(Math.abs(l)/Math.max(s,1)*(t.length/6));for(let h=c+1;h<t.length;h++){const u=t[h-1],f=t[h],d=f.x-u.x,m=f.y-u.y,p=Math.hypot(d,m)||1,g=-m/p,y=d/p,w=1-h/(t.length-1);e.globalAlpha=o*(1-w),e.lineWidth=r*(1-w*.7),e.beginPath(),e.moveTo(u.x+g*l,u.y+y*l),e.lineTo(f.x+g*l,f.y+y*l),e.stroke()}}e.restore()}const up={hands:[{name:"left hand",at:e=>e.hands.left},{name:"right hand",at:e=>e.hands.right}],toes:[{name:"left toe",at:e=>e.toes.left},{name:"right toe",at:e=>e.toes.right}],head:[{name:"head",at:e=>e.head.center}],body:[{name:"hip",at:e=>e.hip},{name:"neck",at:e=>e.neck}]};function fp(e,t,n,i,s={}){const r=n.stateAt;if(!r)return;const o=s.length??120,a=Math.max(2,Math.round(s.samples??8)),l=Math.max(0,n.time-o);if(n.time-l<1)return;const c=[];for(let d=0;d<a;d++){const m=l+(n.time-l)*d/(a-1);c.push(Fa(t,{time:m,state:r(m)},i).joints)}const h=c[c.length-1].height,u=(s.threshold??1.2)*h,f=(s.parts??["hands","toes","head"]).flatMap(d=>up[d]);for(const d of f){const m=c.map(d.at);let p=0;for(let w=1;w<m.length;w++)p+=Math.hypot(m[w].x-m[w-1].x,m[w].y-m[w-1].y);const g=p/((n.time-l)/1e3);if(g<=u)continue;const y=Math.min(1,(g-u)/(u*.5));xl(e,m,{...s,opacity:(s.opacity??.7)*y,spacing:s.spacing??h*.02})}}function dp(e,t,n,i={}){if(n<=0||n>=1)return;const s=i.size??40,r=i.seed??1,o=.45+.55*(1-(1-n)**3);e.save(),e.strokeStyle=i.color??"#555",e.lineWidth=Math.max(1,s*.03),e.globalAlpha=Math.min(1,n/.08)*(1-n);for(let a=0;a<5;a++){const l=Gt(`${r}:puff:${a}`)%1e3/1e3,c=a-2,h=t.x+c*s*.3*o,u=t.y-s*(.06+.12*l)*o+Math.abs(c)*s*.03,f=s*(.11+.07*l)*o;e.beginPath(),e.arc(h,u,f,Math.PI*.95,Math.PI*2.05),e.stroke()}e.restore()}function pp(e,t,n,i={}){if(n<=0||n>=1)return;const s=i.size??40,r=5,o=1-(1-n)**2;e.save(),e.strokeStyle=i.color??"#222",e.lineWidth=Math.max(1,s*.035),e.lineJoin="round",e.globalAlpha=n<.7?1:(1-n)/.3;for(let a=0;a<r;a++){const l=-Math.PI/2+(a-(r-1)/2)*Math.PI/(r+1),c=s*(.3+.7*o),h=t.x+Math.cos(l)*c,u=t.y+Math.sin(l)*c;mp(e,h,u,s*.14,n*Math.PI+a),e.stroke()}e.restore()}function mp(e,t,n,i,s){e.beginPath();for(let r=0;r<10;r++){const o=r%2===0?i:i*.45,a=s+r*Math.PI/5-Math.PI/2,l=t+Math.cos(a)*o,c=n+Math.sin(a)*o;r===0?e.moveTo(l,c):e.lineTo(l,c)}e.closePath()}const Et={rest:{mouth:0,mouthWidth:1},a:{mouth:.75,mouthWidth:1.1},e:{mouth:.45,mouthWidth:1.3},i:{mouth:.28,mouthWidth:1.45},o:{mouth:.6,mouthWidth:.7},u:{mouth:.32,mouthWidth:.55},m:{mouth:0,mouthWidth:.9},f:{mouth:.1,mouthWidth:1.05},l:{mouth:.3,mouthWidth:1},c:{mouth:.2,mouthWidth:1}},Ke=1,Xn=.55,Pl=.35,gp=1.6,_l={a:"a",e:"e",i:"i",y:"i",o:"o",u:"u"},Il={m:"m",b:"m",p:"m",f:"f",v:"f",w:"u",q:"u",l:"l",n:"l",d:"l",t:"l"},Cl={अ:"a",आ:"a",इ:"i",ई:"i",उ:"u",ऊ:"u",ऋ:"i",ए:"e",ऐ:"e",ओ:"o",औ:"o",ऍ:"e",ऑ:"o"},Hl={"ा":"a","ि":"i","ी":"i","ु":"u","ू":"u","ृ":"i","े":"e","ै":"e","ो":"o","ौ":"o","ॅ":"e","ॉ":"o"},yp={प:"m",फ:"m",ब:"m",भ:"m",म:"m",व:"u"},bp="्",$l="़",wp=e=>e>="क"&&e<="ह",Rl=new Set([".",",","!","?",";",":","…","।","॥","—","-"]);function Ol(e){const t=[],n=Array.from(e.toLowerCase()),i=(s,r)=>{const o=t[t.length-1];o&&o.viseme===s?o.weight+=r*.5:t.push({viseme:s,weight:r})};for(let s=0;s<n.length;s++){const r=n[s],o=n[s+1];if(Rl.has(r))i("rest",gp);else if(/\s/.test(r)){const a=t[t.length-1];a&&a.viseme!=="rest"&&t.push({viseme:"c",weight:Pl})}else if((r==="o"||r==="e")&&o===r)i(r==="o"?"u":"i",Ke),s++;else if(r in _l)i(_l[r],Ke);else if(r in Il)i(Il[r],Xn);else{if(r==="h")continue;if(/[a-z]/.test(r))i("c",Xn);else if(r in Cl)i(Cl[r],Ke);else if(wp(r)){const a=o===$l?r==="फ"?"f":void 0:yp[r];i(a??"c",Xn);let l=s+1;n[l]===$l&&l++;const c=n[l];c===bp?s=l:c&&c in Hl?(i(Hl[c],Ke),s=l):(!c||/\s/.test(c)||Rl.has(c)||i("a",Ke*.6),s=l-1)}else(r==="ं"||r==="ँ")&&i("l",Xn*.6)}}for(;t.length>0&&(t[t.length-1].viseme==="rest"||t[t.length-1].weight===Pl);)t.pop();return t}function Ps(e,t={}){const n=t.fields?.mouth??"mouth",i=t.fields?.mouthWidth??"mouthWidth",s=t.energy??1,r=Ol(e.text),o=[{time:e.start,value:Et.rest.mouth}],a=[{time:e.start,value:Et.rest.mouthWidth}],l=r.reduce((h,u)=>h+u.weight,0),c=e.end-e.start;if(l>0&&c>0){let h=e.start;for(const u of r){const f=c*u.weight/l,d=h+Math.min(f*.4,60);if(d>o[o.length-1].time){const m=Et[u.viseme];o.push({time:d,value:m.mouth*s,easing:"ease-out"}),a.push({time:d,value:1+(m.mouthWidth-1)*Math.min(1.3,s),easing:"ease-out"})}h+=f}}return e.end>o[o.length-1].time&&(o.push({time:e.end,value:Et.rest.mouth,easing:"ease-in-out"}),a.push({time:e.end,value:Et.rest.mouthWidth,easing:"ease-in-out"})),{[n]:o,[i]:a}}function kp(e,t,n={}){const i={};for(const s of[...t].sort((r,o)=>r.start-o.start))for(const[r,o]of Object.entries(Ps(s,n))){const a=i[r]??=[],l=a.length>0?a[a.length-1].time:-1/0;a.push(...o.filter(c=>c.time>l))}return Object.entries(i).map(([s,r])=>({id:`${e}-${s}`,target:e,property:s,keyframes:r}))}function Ll(e,t,n,i={}){if(n.length===0)return t;const s=i.fields?.mouth??"mouth",r=i.fields?.mouthWidth??"mouthWidth",o={[s]:Et.rest.mouth,[r]:Et.rest.mouthWidth,...i.rest},a=new ve({id:"before-speech",tracks:t}),l=(u,f)=>a.getStateAtTime(f).values.get(e)?.get(u)??o[u],c=[s,r],h=t.filter(u=>u.target!==e||!c.includes(u.property));for(const u of c){const f=t.find(m=>m.target===e&&m.property===u);let d=f?[...f.keyframes]:[{time:0,value:l(u,0)}];for(const m of n){const p=Ps(m,i)[u];p[0]={...p[0],value:l(u,m.start)},p[p.length-1]={...p[p.length-1],value:l(u,m.end)},d=[...d.filter(g=>g.time<m.start||g.time>m.end),...p],d.sort((g,y)=>g.time-y.time)}h.push({id:f?.id??`${e}-${u}`,target:e,property:u,keyframes:d})}return h}const _s={walk:1e3,bouncy:900,doubleBounce:1100,sneak:1600,strut:1100,tired:1500,run:560},vp=450,Sp=2.4,Mp=160,Fl=2.5,At=450,Dl=1200,Tp=700,he=320,ue=220,Ep=65,Ap=700,Is=e=>e in $t,Bl=e=>e in Yn,xp=e=>e in se;function Nl(e){return Math.max(Ap,Array.from(e).length*Ep)}function Pp(e,t,n={}){const i=n.from??0,s=n.height??300;let r=i,o=n.facing??1,a=n.start??W,l=0,c=0;const h=[{time:0,pose:a}],u=[{time:0,value:0}],f=[{time:0,value:0}],d=[{time:0,value:0}],m=[{time:0,value:"walk"}],p=[{time:0,value:o}],g=[],y=[],w=[],k=(T,v,_,P)=>{a={...a,...v},_&&(a=ie(a,_)),h.push({time:T,pose:a})},M=(T,v,_)=>(k(T+he/2,{turn:0},_),p.push({time:T+he/2,value:o},{time:T+he/2+1,value:v}),o=v,k(T+he,{turn:1}),T+he),S=T=>T<r?-1:1;for(const T of t){const v=Math.max(T.at??c,c===0?0:h[h.length-1].time);let _=v;const P=T.pose??{};if(Is(T.do)){const x=T.to??r,I=x===r?o:S(x);let C=v;I!==o?C=M(v,I,T.mood):a.turn<1?(C=v+ue,k(C,{turn:1,...P},T.mood)):(T.mood||T.pose)&&k(v+ue,P,T.mood);const R=Math.abs(x-r)/oa(T.do,s),B=T.for??Math.max(ue*2,R*_s[T.do]),$=C+B;m.push({time:C,value:T.do}),d.push({time:C,value:0},{time:C+ue,value:1,easing:"ease-out"}),d.push({time:$-ue,value:1},{time:$,value:0,easing:"ease-in"}),f.push({time:C,value:l},{time:$,value:l+R}),u.push({time:C,value:r-i},{time:$,value:x-i}),l+=R,r=x,k($,{}),_=$}else if(T.do==="zip"){const x=T.to??r,I=x===r?o:S(x);let C=v;I!==o?C=M(v,I,T.mood):a.turn<1&&(C=v+ue,k(C,{turn:1},T.mood));const H=As("windUp",{at:C,from:T.mood?ie(a,T.mood):a});h.push(...H),a=H[H.length-1].pose;const R=C+xs("windUp"),B=R+vp,$=B+Math.max(Mp,Math.abs(x-r)/Sp);m.push({time:R,value:"run"}),d.push({time:R,value:0},{time:R+80,value:1,easing:"ease-out"},{time:$,value:1},{time:$+120,value:0}),f.push({time:R,value:l},{time:B,value:l+Fl,easing:"ease-in"}),l+=Fl+($-B)/_s.run*1.5,f.push({time:$,value:l}),u.push({time:B,value:r-i},{time:$,value:x-i,easing:"ease-in"}),w.push({kind:"dust",time:B,x:r,length:900}),r=x,k($,{}),_=$}else if(Bl(T.do)){const x=As(T.do,{at:v,from:T.mood?ie(a,T.mood):a});h.push(...x),a=x[x.length-1].pose,_=v+xs(T.do),T.do==="take"&&w.push({kind:"dust",time:v+900,x:r,length:500}),T.do==="land"&&w.push({kind:"dust",time:v+120,x:r,length:500})}else if(T.do==="look"||T.do==="face"){const x=T.toward??"viewer",I=T.for??Tp;if(x==="viewer")k(v+At,{turn:0,lookX:0,lookY:0,...P},T.mood);else if(x==="ahead")k(v+At,{turn:T.do==="face"?1:.6,lookX:1,...P},T.mood);else if(x==="back")k(v+At,{turn:.2,lookX:-1,...P},T.mood);else{const C=S(x);C!==o&&T.do==="face"?(M(v,C,T.mood),k(v+he+1,{lookX:1,...P})):C!==o?k(v+At,{turn:.25,lookX:-1,...P},T.mood):k(v+At,{turn:T.do==="face"?1:.6,lookX:1,...P},T.mood)}_=v+Math.max(I,At)}else if(xp(T.do)||T.do==="stand"){const x=T.do==="stand"?W:se[T.do],I=x.turn!==W.turn?x.turn:a.turn,C=T.mood?G[T.mood]:{lookX:a.lookX,lookY:a.lookY};k(v+At,{...x,turn:I,...C,...P}),_=v+(T.for??Dl)}else{const x=T.for??(T.say?Nl(T.say):Dl);(T.mood||T.pose)&&k(v+Math.min(At,x/2),P,T.mood),_=v+x}if(T.say){const x=Is(T.do)||Bl(T.do)?v:v+Math.min(150,(_-v)/4),I=Is(T.do)?_:Math.max(x+200,_-100);g.push({text:T.say,start:x,end:I}),T.do==="say"&&Cp(h,a,x,I)}_>h[h.length-1].time&&h.push({time:_,pose:a}),y.push({start:v,end:_}),c=_}const A=El(e,Ip(h),n),E=[{id:`${e}-x`,target:e,property:"x",keyframes:u},{id:`${e}-walk`,target:e,property:"walk",keyframes:f},{id:`${e}-walking`,target:e,property:"walking",keyframes:d},{id:`${e}-gait`,target:e,property:"gait",keyframes:m},{id:`${e}-facing`,target:e,property:"facing",keyframes:p}].filter(T=>T.keyframes.length>1||T.property==="x");return{tracks:[...Ll(e,A,g,{energy:n.energy}),...E],duration:c,lines:g,keys:h,beats:y,effects:w}}const _p=30;function Ip(e){const t=[];for(const n of e){const i=t[t.length-1];i&&n.time-i.time<_p?t[t.length-1]={...n,time:i.time}:t.push(n)}return t}function Cp(e,t,n,i){const r=e.filter(l=>l.time>n),o=e.filter(l=>l.time<=n),a=[];for(let l=n+520,c=0;l<i-520/2;l+=520,c++){const h=c%2===0?3:-2;a.push({time:l,pose:{...t,headTilt:t.headTilt+h,leftBrow:t.leftBrow+(c%2===0?.25:0),rightBrow:t.rightBrow+(c%2===0?.25:0)}})}a.length>0&&a.push({time:i,pose:t}),e.length=0,e.push(...o,...a.filter(l=>!r.some(c=>Math.abs(c.time-l.time)<60)),...r),e.sort((l,c)=>l.time-c.time)}function Hp(e){const{timeline:t}=e,n=new Ct;for(const[c,h]of Object.entries(e.targets)){const u=typeof h=="string"?document.querySelector(h):h;if(!u)throw new Error(`quickPlay: no element found for target "${c}" (${String(h)})`);n.registerTarget(c,u)}t.onUpdate=c=>{n.applyState(c),e.onUpdate?.(c)},e.onComplete&&(t.onComplete=e.onComplete);let i=null,s=null,r=!1;const o=c=>{if(r)return;const h=s===null?0:c-s;s=c,h>0&&t.tick(h),i=requestAnimationFrame(o)},a=()=>{i!==null||r||(s=null,i=requestAnimationFrame(o))},l=()=>{i!==null&&cancelAnimationFrame(i),i=null,s=null};return n.applyState(t.getStateAtTime(t.currentTime)),e.autoplay!==!1&&(t.play(),a()),{timeline:t,adapter:n,play(){t.play(),a()},pause(){t.pause(),l()},restart(){t.stop(),t.play(),a()},seek(c){t.seek(c*1e3),n.applyState(t.getStateAtTime(t.currentTime))},destroy(){r=!0,l(),t.stop(),n.clearTargets()}}}const $p={timeline:Fh,to(e,t,n){const i=new It(n);return i.to(e,t),i},from(e,t,n){const i=new It(n);return i.from(e,t),i},fromTo(e,t,n,i){const s=new It(i);return s.fromTo(e,t,n),s},set(e,t,n){const i=new It(n);return i.set(e,t),i}};function Wl(e,t,n){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(t,n);const i=e.canvas;if(i?.ownerDocument){const s=i.ownerDocument.createElement("canvas");return s.width=t,s.height=n,s}try{return i?.constructor?new i.constructor(t,n):null}catch{return null}}function Rp(e,t){const n=e.length/4,i=new Float32Array(n*3),s=Math.min(.999,Math.max(0,t));for(let r=0;r<n;r++){const o=e[r*4]/255,a=e[r*4+1]/255,l=e[r*4+2]/255,c=e[r*4+3]/255,h=Math.max(o,a,l);if(h<=s)continue;const u=(h-s)/(1-s)*c/h;i[r*3]=o*u,i[r*3+1]=a*u,i[r*3+2]=l*u}return i}function Kl(e,t,n,i,s){const r=new Float32Array(e.length),o=s?n:t,a=s?t:n,l=(h,u)=>(s?h*t+u:u*t+h)*3,c=i*2+1;for(let h=0;h<o;h++)for(let u=0;u<3;u++){let f=0;for(let d=-i;d<=i;d++)f+=e[l(h,Math.min(a-1,Math.max(0,d)))+u];for(let d=0;d<a;d++){r[l(h,d)+u]=f/c;const m=e[l(h,Math.max(0,d-i))+u],p=e[l(h,Math.min(a-1,d+i+1))+u];f+=p-m}}return r}function Yl(e,t,n,i){const s=Math.max(1,Math.round(i/Math.sqrt(3)));let r=e;for(let o=0;o<3;o++)r=Kl(r,t,n,s,!0),r=Kl(r,t,n,s,!1);return r}function Op(e,t={}){const n=e.canvas,i=n.width,s=n.height;if(!(i>0&&s>0))return;const r=Math.max(1,Math.round(t.downsample??4)),o=Math.max(1,Math.ceil(i/r)),a=Math.max(1,Math.ceil(s/r)),l=Wl(e,o,a),c=l?.getContext("2d");if(!l||!c)return;c.imageSmoothingEnabled=!0,c.drawImage(e.canvas,0,0,o,a);const h=Rp(c.getImageData(0,0,o,a).data,t.threshold??.55),u=(t.radius??Math.max(i,s)*.02)/r,f=Yl(h,o,a,u),d=Yl(h,o,a,u*3),m=t.halo??.6,p=c.createImageData(o,a);for(let g=0;g<o*a;g++){for(let y=0;y<3;y++)p.data[g*4+y]=Math.round(Math.min(1,f[g*3+y]+d[g*3+y]*m)*255);p.data[g*4+3]=255}c.putImageData(p,0,0),e.save(),e.setTransform(1,0,0,1,0,0),e.globalCompositeOperation="lighter",e.globalAlpha=Math.max(0,t.strength??.9),e.imageSmoothingEnabled=!0,e.drawImage(l,0,0,i,s),e.restore()}function Lp(e,t,n){const i=n.width??6,s=n.taper??1,r=n.fade??1,o=n.opacity??1,a=n.blend==="add";if(e.save(),t.length>=2){const c=Dp(t,i,s,r,o);a?(e.globalCompositeOperation="lighter",Cs(e,c,n.color)):Bp(e,c,n.color)}const l=t[t.length-1];if(n.head&&l&&n.head.radius>0){a&&(e.globalCompositeOperation="lighter");const c=n.head.color??n.color,h=e.createRadialGradient(l.at.x,l.at.y,0,l.at.x,l.at.y,n.head.radius);h.addColorStop(0,c),h.addColorStop(.35,c),h.addColorStop(1,Fp(e,c)),e.globalAlpha=o,e.fillStyle=h,e.beginPath(),e.arc(l.at.x,l.at.y,n.head.radius,0,Math.PI*2),e.fill()}e.restore()}function Fp(e,t){e.fillStyle=t;const n=String(e.fillStyle),i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(n);if(i)return`rgba(${parseInt(i[1],16)}, ${parseInt(i[2],16)}, ${parseInt(i[3],16)}, 0)`;const s=/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i.exec(n);return s?`rgba(${s[1]}, ${s[2]}, ${s[3]}, 0)`:"rgba(0, 0, 0, 0)"}function Dp(e,t,n,i,s){const r=e.map(c=>({x:c.at.x,y:c.at.y,width:t*(1-n*c.age)})),o=Dr(r),a=Br(r)??void 0,l=[];for(let c=0;c+1<e.length;c++){const h=(e[c].age+e[c+1].age)/2,u=s*(1-i*h);if(u<=0)continue;const f=c+2===e.length;l.push({corners:[o.left[c],o.left[c+1],o.right[c+1],o.right[c]],alpha:u,...f&&a&&{cap:a}})}return l}function Cs(e,t,n){e.fillStyle=n;for(const i of t){const[s,r,o,a]=i.corners;e.globalAlpha=Math.min(1,i.alpha),e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(r.x,r.y),i.cap&&e.arc(i.cap.x,i.cap.y,i.cap.radius,i.cap.start,i.cap.start-Math.PI,!0),e.lineTo(o.x,o.y),e.lineTo(a.x,a.y),e.closePath(),e.fill()}}function Bp(e,t,n){const i=typeof e.getTransform=="function"?e.getTransform():null,s=p=>i?{x:i.a*p.x+i.c*p.y+i.e,y:i.b*p.x+i.d*p.y+i.f}:p,r=i?Math.sqrt(Math.abs(i.a*i.d-i.b*i.c)):1,o=t.map(p=>({...p,corners:p.corners.map(s),...p.cap&&{cap:{...p.cap,...s(p.cap),radius:p.cap.radius*r,start:p.cap.start+(i?Math.atan2(i.b,i.a):0)}}}));let a=1/0,l=1/0,c=-1/0,h=-1/0;for(const p of o){const g=p.cap?[{x:p.cap.x-p.cap.radius,y:p.cap.y-p.cap.radius},{x:p.cap.x+p.cap.radius,y:p.cap.y+p.cap.radius}]:[];for(const y of[...p.corners,...g])a=Math.min(a,y.x),l=Math.min(l,y.y),c=Math.max(c,y.x),h=Math.max(h,y.y)}if(!(c>a&&h>l))return;const u=Math.floor(a)-1,f=Math.floor(l)-1,d=i?Wl(e,Math.ceil(c)+1-u,Math.ceil(h)+1-f):null,m=d?.getContext("2d");if(!d||!m){Cs(e,t,n);return}m.translate(-u,-f),m.globalCompositeOperation="lighter",Cs(m,o,n),e.save(),e.setTransform(1,0,0,1,0,0),e.globalAlpha=1,e.drawImage(d,u,f),e.restore()}const Np=tt.to,Wp=tt.from,Kp=tt.fromTo,Yp=tt.set,Xp=tt.timeline,qp=tt.ticker,Vp=tt.splitText,Up=tt.context,zp=tt.matchMedia,Gp=tt.quickTo,jp=tt.imageSequence,Jp=tt.pageTransition;uf(),b.ACTING_STYLES=Wn,b.Clock=Vl,b.CompatTimeline=It,b.CustomBounce=$o,b.CustomEase=Ho,b.CustomWiggle=Ro,b.DANCE_STYLES=Ot,b.DEFAULT_BAKE_INTERVAL_MS=ci,b.DEFAULT_INERTIA_FRICTION=Jn,b.DEFAULT_LABELS=Yo,b.DEFAULT_SPRING=st,b.DEFAULT_TRANSITION=df,b.Draggable=Pi,b.EXPRESSIONS=G,b.FINGERS=ea,b.FLIPS=Hn,b.FORMAT_VERSION=qn,b.GAGS=Yn,b.GAITS=$t,b.GAIT_CYCLE_MS=_s,b.HAND_REST=Y,b.HAND_SHAPES=U,b.HUMAN_ACTING_RIG=Ml,b.HUMAN_EXPRESSIONS=Ja,b.HUMAN_GAGS=kl,b.HUMAN_POSES=Ga,b.HUMAN_REST=q,b.IDENTITY_CAMERA=pl,b.INERTIA_MAX_DURATION_MS=Os,b.InertiaTrackPlayer=vr,b.LiveTimeline=ut,b.MORPH_SAMPLES=pc,b.MUDRAS=es,b.ManualClock=ql,b.MediaSync=Ki,b.Observer=lo,b.POSES=se,b.REST_POSE=W,b.SPRING_MAX_DURATION_MS=jn,b.SPRING_PRESETS=Ue,b.SPRING_STEP_MS=Nt,b.STICK_ACTING_RIG=Sl,b.ScrollAnimator=Eo,b.ScrollDriver=Ie,b.ScrollMarkers=Ao,b.ScrollPin=vo,b.SmoothScroll=Bi,b.SpringSampler=pe,b.SpringTrackPlayer=kr,b.Stage=no,b.Timeline=ve,b.TinyflyPlayer=pn,b.TinyflySequencer=Jo,b.TrackPlayer=tn,b.VISEMES=Et,b.ValueResolver=Kc,b.VisibilityDriver=ko,b.actCharacterTracks=cp,b.actKeyframes=Es,b.actTracks=El,b.applyBloom=Op,b.applyCamera=D0,b.applyGroove=Na,b.backOut=qs,b.bakeDanceTracks=Pd,b.bakeEasing=fi,b.bakeInertiaTrack=ui,b.bakeSpringTrack=hi,b.basicOutfit=tp,b.beatAt=Ed,b.beatAtTime=nn,b.beatLength=wi,b.beatTime=en,b.beatsBetween=th,b.bindChoiceHotspots=Uo,b.blendPose=re,b.boilFrame=Xi,b.bounceOut=Xs,b.cameraFromValues=F0,b.cameraPoint=B0,b.cameraTracks=sh,b.character=ol,b.characterAt=_0,b.characterHandPose=ll,b.characterJoints=al,b.characterJointsInView=E0,b.characterObjects=L0,b.characterPoseTracks=I0,b.characterTarget=P0,b.charactersFor=Sr,b.circlePath=Y0,b.clamp01=Oi,b.clearMorphCache=Mc,b.clearPathCache=cc,b.clipErased=Ss,b.containerProgressAt=Li,b.context=Up,b.create=Gu,b.createControls=qo,b.createCubicBezier=Ks,b.createLive=Fo,b.createPen=Vi,b.createRandom=Se,b.createTrack=Qe,b.criticalDamping=Gl,b.customBounce=$r,b.customEase=Hr,b.customWiggle=Rr,b.danceFrame=xn,b.dancePose=kd,b.danceStance=An,b.danceTaps=Sd,b.danceTracks=xd,b.danceTravel=_n,b.danceTravelTrack=qa,b.dancer=Ad,b.deserializeTimeline=zt,b.deserializeTrack=Ar,b.detectTempo=eh,b.draggable=lu,b.drawCartoonHand=Sn,b.drawCharacter=cl,b.drawCharacterInView=ul,b.drawDustPuff=dp,b.drawEraser=ks,b.drawHand=vs,b.drawImpactStars=pp,b.drawPencil=ml,b.drawSpeedLines=xl,b.drawStickFigure=Ra,b.drawStickSmear=fp,b.drawTrail=Lp,b.drawnPathTarget=X0,b.easeIn=Bs,b.easeInCubic=Zn,b.easeInOut=Ws,b.easeInOutCubic=ge,b.easeInOutQuad=Ds,b.easeInQuad=Ls,b.easeOut=Ns,b.easeOutCubic=Qn,b.easeOutQuad=Fs,b.elasticOut=Ys,b.ellipsePoints=qi,b.erasable=z0,b.expandParametricEasings=br,b.flipPose=Va,b.flipTracks=Yd,b.flipTravel=Ua,b.formatVersionFor=Vn,b.from=Wp,b.fromJSON=Bc,b.fromTo=Kp,b.gag=As,b.gagDuration=xs,b.gaitPose=ra,b.gaitStrideLength=oa,b.getEasingFunction=J,b.getInterpolator=ke,b.getMotionPathPoint=di,b.getPathLength=hc,b.getPointAtProgress=js,b.gridLinesFor=uo,b.handAt=K0,b.handJoints=vn,b.handJointsAt=sa,b.handPose=X,b.handProp=Be,b.hasKeyframes=Hs,b.hashSeed=Gt,b.headPoint=hd,b.heldTime=$s,b.humanFieldLabel=s0,b.humanGag=Z0,b.humanGaitPose=j0,b.humanGaitStrideLength=J0,b.humanPlan=ja,b.humanPose=nt,b.imageSequence=jp,b.inertiaDuration=Kt,b.inertiaRest=Wt,b.inertiaValueAt=Ge,b.inertiaVelocityAt=Ql,b.interpolateArray=pr,b.interpolateColor=dr,b.interpolateMotionPath=Rc,b.interpolateNumber=lt,b.interpolatePathString=gr,b.interpolateQuaternion=mr,b.interpolateString=li,b.isCubicBezierEasing=Bt,b.isInertiaTrack=mt,b.isMotionPathPoint=Xl,b.isMotionPathTrack=Un,b.isParametricEasing=fe,b.isPathData=Xt,b.isSpringTrack=gt,b.isTextTrack=Ye,b.isUnderdamped=zl,b.isUnresolved=Wc,b.jointsInScene=dl,b.jointsToScene=$a,b.linear=je,b.lipSyncKeyframes=Ps,b.lipSyncOver=Ll,b.lipSyncTracks=kp,b.live=tt,b.mapEase=xe,b.mat4=mh,b.matchMedia=zp,b.maxStaggerDistance=Gn,b.mirrorHumanPose=i0,b.mirrorPose=Ba,b.mixHandPoses=ne,b.mixPoses=A0,b.morphPath=ir,b.mount=zo,b.mountAll=jo,b.narrationMarkers=jc,b.narrationSceneAt=Jc,b.naturalRest=me,b.nearestBeat=Zc,b.nextBeat=Qc,b.pageTransition=Jp,b.parametricEasing=Us,b.parseEdge=$i,b.parsePath=Pt,b.parseTrigger=Ri,b.partialPath=ee,b.pathLength=Zo,b.planNarration=Gc,b.play=zu,b.playSequence=ff,b.playWhenVisible=vu,b.playheadCrossings=mi,b.pointAlong=gn,b.pointAtDistance=ei,b.pointOnHead=w0,b.pointsToPath=Fr,b.pose=j,b.poseTracks=pd,b.quat=_c,b.quickPlay=Hp,b.quickTo=Gp,b.randomBetween=yi,b.randomChoice=Nc,b.randomSnapped=Pr,b.reachCharacter=x0,b.resolveActingStyle=vl,b.resolveCharacterPoseKeys=ws,b.resolveGait=Le,b.resolvePoseKeys=Qi,b.resolveSequence=Cr,b.resolveStickFrame=Zi,b.resolveStickPose=Oa,b.resolveValue=bi,b.ribbon=Dr,b.ribbonHeadCap=Br,b.rotateAbout=St,b.routineBeats=Pn,b.rubberLimb=Ht,b.scriptTracks=Pp,b.scrollProgress=ku,b.scrubOnScroll=Eu,b.scrubPath=V0,b.seatHeight=sd,b.serializeTimeline=xr,b.serializeTrack=Tr,b.set=Yp,b.shapeToPathData=sn,b.simplifyKeyframes=wr,b.skeletonInView=us,b.sketchPen=yn,b.smoothToward=wo,b.snapAxis=ho,b.snapConfig=So,b.snapDuration=To,b.snapProgress=Mo,b.solvePlanSpace=On,b.soundsOf=Ol,b.speechDuration=Nl,b.splitText=Vp,b.springDuration=Rs,b.springValueAt=Ul,b.stagePlanSpace=hs,b.staggerDistance=zn,b.staggerOffset=Xe,b.staggerOffsets=qe,b.staggerSpan=de,b.stepsEasing=Vs,b.stickFigureAt=Fa,b.stickFigureJoints=Ha,b.stickFigureTarget=dd,b.stickToHuman=o0,b.strideLength=fa,b.syncMediaElement=Ko,b.talkingMouth=da,b.taperedLine=bn,b.taperedOutline=$e,b.textAt=Mr,b.tf=$p,b.ticker=qp,b.timeline=Xp,b.to=Np,b.toJSON=Dc,b.toKeyframedTrack=Hc,b.toKeyframedTracks=$c,b.trackTargets=kt,b.trailSamples=oh,b.triggerDistance=Jt,b.unmount=cf,b.vec3=lh,b.walkPose=ua,b.withErased=U0,b.withExpression=ie,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));