@algorisys/tinyfly 0.88.0 → 0.90.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,It){typeof exports=="object"&&typeof module<"u"?It(exports):typeof define=="function"&&define.amd?define(["exports"],It):(b=typeof globalThis<"u"?globalThis:b||self,It(b.tinyfly=b.tinyfly||{}))})(this,(function(b){"use strict";function It(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function Jt(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const En=2;function An(e){return e.some(t=>t.interpolation!==void 0)?2:1}function Te(e){return e.property==="text"&&"textConfig"in e}function ft(e){return e.kind==="inertia"&&"inertia"in e}function dt(e){return e.kind==="spring"&&"spring"in e}function xn(e){return e.property==="motionPath"&&"motionPathConfig"in e}function Da(e){return typeof e=="object"&&e!==null&&"x"in e&&"y"in e&&"angle"in e}function rs(e){return"keyframes"in e}class Na{_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 Wa{_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 Pn(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 _n(e,t="start"){if(e<=1)return 0;let n=0;for(let i=0;i<e;i++)n=Math.max(n,Pn(i,e,t));return n}function Ee(e,t,n){if(n.offsets)return n.offsets[e]??0;const i=n.from??"start",s=Pn(e,t,i);if(n.amount!==void 0){const r=_n(t,i);return r===0?0:n.amount*s/r}return n.each!==void 0?n.each*s:0}function Ae(e,t){return Array.from({length:e},(n,i)=>Ee(i,e,t))}function Zt(e,t){return e<=1?0:Math.max(...Ae(e,t))}const Ht=1,Cn=6e4,xe=Cn/Ht,Q={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},Pe={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 Qt{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??Q.stiffness,this.damping=t.damping??Q.damping,this.mass=t.mass??Q.mass,this.restDelta=t.restDelta??Q.restDelta,this.restSpeed=t.restSpeed??Q.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??Q.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/Ht);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/Ht-n;return i+(s-i)*r}settleTime(){return this.simulateTo(xe+1),this.settledStep!==null?this.settledStep*Ht:Cn}simulateTo(t){if(this.settledStep!==null)return;const n=Math.min(t,xe+1),i=Ht/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>xe&&(this.settledStep=xe)}}function Ya(e,t){return new Qt(e).valueAt(t)}function os(e){return new Qt(e).settleTime()}function Ka(e){const t=e.stiffness??Q.stiffness,n=e.damping??Q.damping,i=e.mass??Q.mass;return n<2*Math.sqrt(t*i)}function qa(e){const t=e.stiffness??Q.stiffness,n=e.mass??Q.mass;return 2*Math.sqrt(t*n)}const In=4,Xa=.002,Va=1e-4,as=6e4;function _e(e){const t=e.friction??In;return t>0?t:In}function te(e){return e.from+e.velocity/_e(e)}function Ua(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 $t(e){let t=Ua(te(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 Rt(e){const t=Math.abs($t(e)-e.from);if(t===0)return 0;const n=e.restDelta??Math.max(Va,t*Xa);if(n>=t)return 0;const i=Math.log(t/n)/_e(e);return Math.min(as,i*1e3)}function Ce(e,t){if(t<=0)return e.from;const n=$t(e);if(t>=Rt(e))return n;const i=_e(e);return e.from+(n-e.from)*(1-Math.exp(-i*t/1e3))}function za(e,t){const n=_e(e),i=$t(e);return t>=Rt(e)?0:(i-e.from)*n*Math.exp(-n*Math.max(0,t)/1e3)}const Ie=e=>e,ls=e=>e*e,cs=e=>1-(1-e)*(1-e),hs=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,Hn=e=>e*e*e,$n=e=>1-Math.pow(1-e,3),ee=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,us=Hn,fs=$n,ds=ee,ja={linear:Ie,"ease-in":us,"ease-out":fs,"ease-in-out":ds,"ease-in-quad":ls,"ease-out-quad":cs,"ease-in-out-quad":hs,"ease-in-cubic":Hn,"ease-out-cubic":$n,"ease-in-out-cubic":ee};function ps(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,f=d=>((a*d+o)*d+r)*d,u=d=>((h*d+c)*d+l)*d,p=d=>(3*a*d+2*o)*d+r,m=d=>{let g=d;for(let w=0;w<8;w++){const M=f(g)-d;if(Math.abs(M)<1e-7)return g;const k=p(g);if(Math.abs(k)<1e-7)break;g-=M/k}let y=0,v=1;for(g=d;y<v;){const w=f(g);if(Math.abs(w-d)<1e-7)return g;d>w?y=g:v=g,g=(y+v)/2}return g};return d=>{if(d<=0)return 0;if(d>=1)return 1;const g=m(d);return u(g)}}function Rn(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 ms(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 gs=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 ys(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 ws(e){switch(e.type){case"steps":return bs(e.count,e.position);case"elastic":return Rn(ms(e.amplitude,e.period),e.mode);case"bounce":return Rn(gs,e.mode);case"back":return Rn(ys(e.overshoot),e.mode)}}function V(e){return e===void 0?Ie:It(e)?ps(e.points):Jt(e)?ws(e):ja[e]??Ie}const vs=32,Ga=256,Ot=new Map,Ja=/[MmLlHhVvCcSsQqTtAaZz]/,Za=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Qa={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function tl(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(Ja.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=Za.exec(e.slice(n));if(!l)break;i.args.push(parseFloat(l[0])),n+=l[0].length}return t}function el(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 f=s*Math.PI/180,u=Math.cos(f),p=Math.sin(f),m=(e-a)/2,d=(t-l)/2,g=u*m+p*d,y=-p*m+u*d,v=g*g/(c*c)+y*y/(h*h);if(v>1){const R=Math.sqrt(v);c*=R,h*=R}const w=r===o?-1:1,M=c*c*h*h-c*c*y*y-h*h*g*g,k=c*c*y*y+h*h*g*g,S=w*Math.sqrt(Math.max(0,M/k)),E=S*c*y/h,_=-S*h*g/c,T=u*E-p*_+(e+a)/2,x=p*E+u*_+(t+l)/2,A=(R,B,D,Z)=>{const St=R*D+B*Z,Tn=Math.sqrt((R*R+B*B)*(D*D+Z*Z)),Me=Math.acos(Math.max(-1,Math.min(1,St/Tn)));return R*Z-B*D<0?-Me:Me},P=A(1,0,(g-E)/c,(y-_)/h);let C=A((g-E)/c,(y-_)/h,(-g-E)/c,(-y-_)/h);!o&&C>0&&(C-=2*Math.PI),o&&C<0&&(C+=2*Math.PI);const I=Math.max(1,Math.ceil(Math.abs(C)/(Math.PI/2))),H=C/I,$=4/3*Math.tan(H/4),O=R=>{const B=c*Math.cos(R),D=h*Math.sin(R);return[u*B-p*D+T,p*B+u*D+x]},L=R=>{const B=-c*Math.sin(R),D=h*Math.cos(R);return[u*B-p*D,p*B+u*D]},F=[];for(let R=0;R<I;R++){const B=P+R*H,D=B+H,[Z,St]=O(B),[Tn,Me]=R===I-1?[a,l]:O(D),[s0,r0]=L(B),[o0,a0]=L(D);F.push([Z+$*s0,St+$*r0,Tn-$*o0,Me-$*a0,Tn,Me])}return F}function pt(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 ne(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 He(e,t,n){const[i,s,r,o,a,l]=n,c=[0];let h=e,f=t,u=0;for(let p=1;p<=vs;p++){const m=p/vs,d=pt(e,i,r,a,m),g=pt(t,s,o,l,m);u+=Math.hypot(d-h,g-f),c.push(u),h=d,f=g}return{subpath:0,type:"C",points:[i,s,r,o,a,l],startX:e,startY:t,endX:a,endY:l,length:u,lengths:c}}function Mt(e){const t=Ot.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,f=d=>{c<0&&(c=0),d.subpath=c,n.push(d)};for(const{type:d,args:g}of tl(e)){const y=d.toUpperCase(),v=d!==y,w=Qa[y];if(y==="Z"){(i!==r||s!==o)&&f(ne(i,s,r,o)),c>=0&&h.add(c),i=r,s=o,a=l=null;continue}for(let M=0;M+w<=g.length;M+=w){const k=g.slice(M,M+w),S=v?i:0,E=v?s:0;let _=null,T=null;switch(y){case"M":M===0?(i=k[0]+S,s=k[1]+E,r=i,o=s,(c<0||n[n.length-1]?.subpath===c)&&c++):(f(ne(i,s,k[0]+S,k[1]+E)),i=k[0]+S,s=k[1]+E);break;case"L":f(ne(i,s,k[0]+S,k[1]+E)),i=k[0]+S,s=k[1]+E;break;case"H":f(ne(i,s,k[0]+S,s)),i=k[0]+S;break;case"V":f(ne(i,s,i,k[0]+E)),s=k[0]+E;break;case"C":{const x=[k[0]+S,k[1]+E,k[2]+S,k[3]+E,k[4]+S,k[5]+E];f(He(i,s,x)),_=[x[2],x[3]],i=x[4],s=x[5];break}case"S":{const[x,A]=a?[2*i-a[0],2*s-a[1]]:[i,s],P=[x,A,k[0]+S,k[1]+E,k[2]+S,k[3]+E];f(He(i,s,P)),_=[P[2],P[3]],i=P[4],s=P[5];break}case"Q":case"T":{let x=i,A=s;y==="Q"?(x=k[0]+S,A=k[1]+E):l&&(x=2*i-l[0],A=2*s-l[1]);const P=y==="Q"?k[2]+S:k[0]+S,C=y==="Q"?k[3]+E:k[1]+E;f(He(i,s,[i+2/3*(x-i),s+2/3*(A-s),P+2/3*(x-P),C+2/3*(A-C),P,C])),T=[x,A],i=P,s=C;break}case"A":{const x=k[5]+S,A=k[6]+E;let P=i,C=s;for(const I of el(i,s,k[0],k[1],k[2],k[3],k[4],x,A))f(He(P,C,I)),P=I[4],C=I[5];i=x,s=A;break}}a=_,l=T}}const u=n.reduce((d,g)=>d+g.length,0),p=[];for(let d=0;d<n.length;){const g=n[d].subpath;let y=d,v=0;for(;y<n.length&&n[y].subpath===g;)v+=n[y++].length;const w=n[d],M=n[y-1],k=h.has(g)||Math.abs(M.endX-w.startX)<1e-9&&Math.abs(M.endY-w.startY)<1e-9;p.push({start:d,end:y,length:v,closed:k}),d=y}const m={segments:n,totalLength:u,subpaths:p};return Ot.size>=Ga&&Ot.delete(Ot.keys().next().value),Ot.set(e,m),m}function nl(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 il(e,t){if(e.type==="L"){const f=e.length>0?Math.max(0,Math.min(1,t/e.length)):0;return{x:e.startX+(e.endX-e.startX)*f,y:e.startY+(e.endY-e.startY)*f,angle:Math.atan2(e.endY-e.startY,e.endX-e.startX)*180/Math.PI}}const[n,i,s,r,o,a]=e.points,l=nl(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 f=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),u=pt(e.startX,n,s,o,f),p=pt(e.startY,i,r,a,f),m=pt(e.startX,n,s,o,l),d=pt(e.startY,i,r,a,l);c=l<.5?u-m:m-u,h=l<.5?p-d:d-p}return{x:pt(e.startX,n,s,o,l),y:pt(e.startY,i,r,a,l),angle:Math.atan2(h,c)*180/Math.PI}}function On(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 il(o,t-s);s+=o.length}return{x:0,y:0,angle:0}}function Ss(e,t){const{segments:n,totalLength:i}=Mt(e);return On(n,Math.max(0,Math.min(1,t))*i)}function sl(){Ot.clear()}function rl(e){return Mt(e).totalLength}const ol=24,al=320,ll=2.5,ie=72,cl=64,hl=.2,ul=128,se=new Map;let $e=0,mt;const Ms=e=>Math.round(e*100)/100;function Ts(e,t){const{segments:n,subpaths:i,totalLength:s}=Mt(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 Fn(e,t){const n=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),i=On(e.segments,n*e.length,e.start,e.end);return[i.x,i.y]}function Es(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 As(e,t){const n=[];for(let i=0;i<t;i++)n.push(Fn(e,e.closed?i/t:i/(t-1)));return n}function xs(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 fl(e,t,n){const i=e.closed&&t.closed;if(n!==void 0)return{offset:i?Math.abs(n)%ie/ie:0,reversed:n<0};const s=xs(As(e,ie)),r=xs(As(t,ie)),o=ie;let a={offset:0,reversed:!1},l=1/0;for(const c of[!1,!0]){const h=i?o:1;for(let f=0;f<h;f++){let u=0;for(let p=0;p<o&&u<l;p++){const m=i?c?(f-p+o)%o:(p+f)%o:c?o-1-p:p,d=s[p][0]-r[m][0],g=s[p][1]-r[m][1];u+=d*d+g*g}u<l&&(l=u,a={offset:i?f/o:0,reversed:c})}}return a}function dl(e,t,n){return n?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function pl(e,t,n){return n?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function ml(e,t,n){const i=e.closed&&t.closed,s=fl(e,t,n.shapeIndex),r=Math.max(ol,Math.min(al,Math.ceil(Math.max(e.length,t.length)/ll))),o=new Set,a=f=>o.add(Math.round(f*1e7)/1e7);for(let f=0;f<=r;f++)a(f/r);for(const f of Es(e))a(f);for(const f of Es(t))a(pl(f,s,i));let l=[...o].sort((f,u)=>f-u);i&&(l=l.filter(f=>f<1));const c=[],h=[];for(const f of l)c.push(...Fn(e,f)),h.push(...Fn(t,dl(f,s,i)));return gl({from:c,to:h,closed:i})}function gl(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=hl;for(let h=o+1;h<a;h++){const f=Math.max(Ps(e.from,o,a,h),Ps(e.to,o,a,h));f>c&&(c=f,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 Ps(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,f=h===0?0:Math.max(0,Math.min(1,(l*o+c*a)/h));return Math.hypot(l-f*o,c-f*a)}function yl(e,t,n){const i=n.shapeIndex;if(mt&&mt.from===e&&mt.to===t&&mt.shapeIndex===i)return mt.plan;const r=se.get(String(i??"auto"))?.get(e)?.get(t);if(r)return mt={from:e,to:t,shapeIndex:i,plan:r},r;const o=Mt(e).subpaths.filter(p=>p.length>0).length===Mt(t).subpaths.filter(p=>p.length>0).length,a=Ts(e,!o),l=Ts(t,!o),c={pairs:a.map((p,m)=>ml(p,l[m],n))};$e>=ul&&(se.clear(),$e=0);const h=String(i??"auto"),f=se.get(h)??new Map;se.set(h,f);const u=f.get(e)??new Map;return f.set(e,u),u.set(t,c),$e++,mt={from:e,to:t,shapeIndex:i,plan:c},c}function _s(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=yl(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=Ms(a.from[l]+(a.to[l]-a.from[l])*s),h=Ms(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 bl(){se.clear(),$e=0,mt=void 0}function Ft(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const Lt=Math.PI/180,wl=.9995;function Ln(){return[0,0,0,1]}function Bt(e,t){const n=Math.hypot(e[0],e[1],e[2]);if(n===0)return Ln();const i=t*Lt/2,s=Math.sin(i)/n;return[e[0]*s,e[1]*s,e[2]*s,Math.cos(i)]}function vl(e,t,n){return Bn(Bn(Bt([0,1,0],t),Bt([1,0,0],e)),Bt([0,0,1],n))}function kl(e){const[t,n,i,s]=gt(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),f=1-2*(t*t+n*n),u=Math.asin(Math.max(-1,Math.min(1,-l)));return Math.abs(l)<.9999999?[u/Lt,Math.atan2(r,f)/Lt,Math.atan2(o,a)/Lt]:[u/Lt,Math.atan2(-h,c)/Lt,0]}function Bn(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 Cs(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function Is(e){return Math.hypot(e[0],e[1],e[2],e[3])}function gt(e){const t=Is(e);return t===0?Ln():[e[0]/t,e[1]/t,e[2]/t,e[3]/t]}function Sl(e){return[-e[0],-e[1],-e[2],e[3]]}function Hs(e,t,n){const i=gt(e);let s=gt(t),r=Cs(i,s);if(r<0&&(s=[-s[0],-s[1],-s[2],-s[3]],r=-r),r>wl)return gt([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 gt([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 Ml(e,t){const[n,i,s,r]=gt(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 Tl=Object.freeze(Object.defineProperty({__proto__:null,conjugate:Sl,dot:Cs,fromAxisAngle:Bt,fromEuler:vl,identity:Ln,length:Is,multiply:Bn,normalize:gt,rotateVec3:Ml,slerp:Hs,toEuler:kl},Symbol.toStringTag,{value:"Module"})),rt=(e,t,n)=>e+(t-e)*n,$s=512,Dn=new Map,Nn=new Map;function Rs(e){const t=Dn.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 Dn.size<$s&&Dn.set(e,i),i}const Os=e=>e.charCodeAt(0)===35,Fs=e=>e.startsWith("rgb"),Ls=e=>e.startsWith("rgba"),El=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Wn=e=>Math.round(e).toString(16).padStart(2,"0");function Al(e,t,n){return`#${Wn(e)}${Wn(t)}${Wn(n)}`}function Bs(e){const t=Nn.get(e);if(t)return t;const n=e.match(El);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 Nn.size<$s&&Nn.set(e,o),o}const Ds=(e,t,n)=>{if(Os(e)&&Os(t)){const[i,s,r]=Rs(e),[o,a,l]=Rs(t),c=rt(i,o,n),h=rt(s,a,n),f=rt(r,l,n);return Al(c,h,f)}if((Fs(e)||Ls(e))&&(Fs(t)||Ls(t))){const i=Bs(e),s=Bs(t),r=Math.round(rt(i[0],s[0],n)),o=Math.round(rt(i[1],s[1],n)),a=Math.round(rt(i[2],s[2],n));if(i.length===4||s.length===4){const l=i[3]??1,c=s[3]??1,h=rt(l,c,n);return`rgba(${r}, ${o}, ${a}, ${h})`}return`rgb(${r}, ${o}, ${a})`}return n<1?e:t},Ns=(e,t,n)=>{const i=Math.min(e.length,t.length),s=[];for(let r=0;r<i;r++)s.push(rt(e[r],t[r],n));return s},Ws=(e,t,n)=>Hs(e,t,n),Yn=(e,t,n)=>n<1?e:t,Ys=(e,t,n)=>_s(e,t,n);function re(e,t){return t==="slerp"?Ws:typeof e=="number"?rt:Array.isArray(e)?Ns:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?Ds:Ft(e)?Ys:Yn:Yn}const Kn=1e3/60;function qn(e,t={}){if(!dt(e))throw new Error(`bakeSpringTrack: track "${e.id}" is not a spring track`);const n=new Qt(e.spring);return Ks(e,i=>n.valueAt(i),n.settleTime(),e.spring.from,e.spring.to,t)}function Xn(e,t={}){if(!ft(e))throw new Error(`bakeInertiaTrack: track "${e.id}" is not an inertia track`);const n=e.inertia;return Ks(e,i=>Ce(n,i),Rt(n),n.from,$t(n),t)}function Ks(e,t,n,i,s,r){const o=r.intervalMs??Kn,a=r.tolerance??.01,l=e.delay??0,c=[];for(let f=0;f<=n;f+=o)c.push({time:f+l,value:t(f),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?Xs(c,a):c,...e.targets&&{targets:[...e.targets]},...e.stagger&&{stagger:{...e.stagger}}}}function Vn(e,t,n,i={}){const s=i.intervalMs??Kn,r=typeof n=="function"?n:V(n),o=re(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 f=h/a;l.push({time:e.time+h,value:o(e.value,t.value,r(f)),easing:"linear"})}const c=r(1);return l.push({...t,...c!==1&&{value:o(e.value,t.value,c)},easing:"linear"}),l}function xl(e,t){return dt(e)?qn(e,t):ft(e)?Xn(e,t):e}function qs(e,t={}){const n=e.keyframes;if(!n.some(r=>Jt(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];Jt(o.easing)?i.push(...Vn(n[r-1],o,o.easing,s)):i.push(o)}return{...e,keyframes:i}}function Pl(e,t){return e.filter(rs).map(n=>qs(n,t)).concat(e.filter(dt).map(n=>qn(n,t)),e.filter(ft).map(n=>Xn(n,t)))}function Xs(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 Re(e){const t=[...e.keyframes].sort((n,i)=>n.time-i.time);return{...e,keyframes:t}}function yt(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function Dt(e,t,n,i){const s=n??0;return!i||t<=1?s:s+Ee(e,t,i)}class Oe{track;targets;constructor(t){this.track=t,this.targets=yt(t)}getValueAtTime(t){return this.valueForOffset(t-Dt(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=Dt(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?Zt(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=V(s.easing)(o);return re(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 Vs{track;targets;sampler;constructor(t){this.track=t,this.targets=yt(t),this.sampler=new Qt(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-Dt(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=Dt(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?Zt(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class Us{track;targets;duration;constructor(t){this.track=t,this.targets=yt(t),this.duration=Rt(t.inertia)}getValueAtTime(t){return Ce(this.track.inertia,t-Dt(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=Dt(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:Ce(this.track.inertia,t-r),start:r})}return i}getDuration(){const t=this.track.stagger?Zt(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function Un(e,t){const n={...Ss(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 f=n.angle*Math.PI/180,u=Math.cos(f),p=Math.sin(f);n.angle=Math.atan2(s*u+o*p,i*u+r*p)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(n.angle+=e.rotateOffset),n}function _l(e,t,n,i){const s=t+(n-t)*i;return Un(e,s)}const zn={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},Cl=20;function zs(e){const t=zn[e??"upperCase"]??e??zn.upperCase,n=Array.from(t);return n.length>0?n:Array.from(zn.upperCase)}function Il(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 js(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 v=Math.round(r*Math.max(o.length,a.length));return l?o.slice(0,Math.max(0,o.length-v)).join("")+a.slice(Math.max(0,a.length-v)).join(""):a.slice(0,v).join("")+o.slice(v).join("")}const c=Math.max(0,Math.min(.999,e.revealDelay??0)),h=Math.max(0,(r-c)/(1-c)),f=Math.floor(h*a.length),u=e.tweenLength===!1?a.length:Math.round(o.length+(a.length-o.length)*r),p=zs(e.chars),m=e.refreshRate??Cl,d=m>0?Math.floor(n*m/1e3):0,g=e.seed??1;let y="";for(let v=0;v<u;v++){const w=l?v>=u-f:v<f,M=l?a[a.length-(u-v)]:a[v];w&&M!==void 0||M===" "||M===`
2
- `?y+=M:y+=p[Il(g,v,d)%p.length]}return y}class jn{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}`,f=c<=t,u=i.get(h);(!u||(f!==u.started?f:f?c>=u.start:c<=u.start))&&i.set(h,{trackId:s,target:a,property:o,value:l,start:c,started:f})}}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",js(l.textConfig,r,Math.max(0,o)));return}const c=this._motionPathTracks.get(n);if(c&&typeof r=="number"){const h=Un(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 yt(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,ft(t)){this._trackPlayers.set(t.id,new Us(t));return}if(dt(t)){this._trackPlayers.set(t.id,new Vs(t)),this._springTracks.set(t.id,t);return}if(Te(t))this._trackPlayers.set(t.id,new Oe(t)),this._textTracks.set(t.id,t);else if(xn(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 Oe(n)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new Oe(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(dt(i)||ft(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=yt(o).filter(f=>yt(i).includes(f));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 f of a)t.push({target:f,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&&!yt(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:An(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 Hl=100;function Gn(e,t,n,i){const s=[],r=[],{duration:o,alternate:a}=i,l=(p,m,d,g)=>{r.push([p,m]);const y=[];e.forEach((v,w)=>{(d==="forward"?(g?v>=p:v>p)&&v<=m:(g?v<=p:v<p)&&v>=m)&&y.push(w)}),y.sort((v,w)=>(d==="forward"?e[v]-e[w]:e[w]-e[v])||v-w);for(const v of y)s.push({kind:"event",index:v,direction:d})};let c=t.time,h=t.direction,f=t.fresh===!0;const u=Math.min(Hl,Math.max(0,n.iteration-t.iteration));for(let p=0;p<u;p++){const m=h==="forward"?o:0;l(c,m,h,f),s.push({kind:"repeat"}),a?(h=h==="forward"?"reverse":"forward",c=m,f=!1):(c=h==="forward"?0:o,f=!0)}return u>0&&i.holding&&!a?{crossings:s,passes:r}:(l(c,n.time,h,f),{crossings:s,passes:r})}function Gs(e){return ft(e)?{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:Js(e.inertia),...ot(e)}:dt(e)?{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...ot(e)}:Te(e)?{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:e.keyframes.map(Jn),...ot(e)}:xn(e)?{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:e.keyframes.map(Jn),...ot(e)}:{id:e.id,target:e.target,property:e.property,keyframes:e.keyframes.map(Jn),...e.interpolation!==void 0&&{interpolation:e.interpolation},...ot(e)}}function Js(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function Jn(e){return{time:e.time,value:e.value,...e.easing&&{easing:e.easing}}}function ot(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 Zs(e){if(ft(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Js(t.inertia),...ot(t)}}if(dt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...ot(t)}}if(Te(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),...ot(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,...ot(t)}}return Re({id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,...e.interpolation!==void 0&&{interpolation:e.interpolation},...ot(e)})}function Qs(e){const t=e._config.markers;return{formatVersion:An(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(Gs),...e.captions&&{captions:JSON.parse(JSON.stringify(e.captions))}}}function Nt(e){const t=e.formatVersion??1;if(t>En)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${En}. Update tinyfly to play it.`);return new jn({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(Zs),captions:e.captions})}function $l(e){return JSON.stringify(Qs(e))}function Rl(e){const t=JSON.parse(e);return Nt(t)}function Zn(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 Fe(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 Qn(e,t,n){return t+e.next()*(n-t)}function tr(e,t,n,i){if(i<=0)return Qn(e,t,n);const s=Math.floor((n-t)/i),r=Math.round(e.next()*s);return t+r*i}function Ol(e,t){if(t.length!==0)return t[Math.floor(e.next()*t.length)]}const er=/^([+\-*/])=\s*(-?[\d.]+)$/,nr=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Fl(e){return typeof e!="string"?!1:er.test(e.trim())||nr.test(e.trim())}function ti(e,t={}){if(typeof e!="string")return e;const n=e.trim(),i=er.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=nr.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?tr(t.random,r,o,a):Qn(t.random,r,o)}return e}function ir(e,t=0,n){const i=[];let s=t;for(const r of e){const o=ti(r,{base:s,random:n});i.push(o),typeof o=="number"&&(s=o)}return i}class Ll{random;constructor(t){this.random=Fe(t)}get seed(){return this.random.seed}resolve(t,n=0){return ti(t,{base:n,random:this.random})}resolveSequence(t,n=0){return ir(t,n,this.random)}}const Bl=600;function sr(e){if(Array.isArray(e)){const[u,p,m,d]=e;return{fn:ar(u,p,m,d),bezier:[u,p,m,d]}}const{segments:t}=Mt(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=u=>(u-n)/r,l=u=>(u-i)/o;if(t.length===1&&s.type==="C"){const[u,p,m,d]=s.points,g=[a(u),l(p),a(m),l(d)];return{fn:ar(...g),bezier:g}}const c=[],h=[],f=Math.max(8,Math.ceil(Bl/t.length));for(const u of t)for(let p=c.length===0?0:1;p<=f;p++){const[m,d]=Dl(u,p/f);c.push(a(m)),h.push(l(d))}return{fn:Nl(c,h)}}function rr(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 or(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 Dl(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 Nl(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 ar(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 f=s(a,e,n)-o,u=r(a,e,n);if(Math.abs(f)<1e-6)return s(a,t,i);if(Math.abs(u)<1e-6)break;a-=f/u}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 Wl=350,Yl=300,Kl=550;function ql(e,t={}){const n=t.lead??Wl,i=t.gap??Yl,s=t.tail??Kl,r=[];let o=0;return e.forEach((a,l)=>{const c=[];let h=o+n;a.lines.forEach((u,p)=>{if(!(u.duration>=0))throw new Error(`narration: scene ${l} line ${p} has an invalid duration (${u.duration})`);p>0&&(h+=i),c.push({id:u.id??`s${l}-l${p}`,scene:l,line:p,start:h,end:h+u.duration,text:u.text}),h+=u.duration});const f=h+s+(a.tail??0);r.push({id:a.id??`s${l}`,start:o,duration:f-o,cues:c}),o=f}),{duration:o,scenes:r,cues:r.flatMap(a=>a.cues)}}function Xl(e){return e.cues.map(t=>({id:t.id,time:t.start,label:t.text}))}function Vl(e,t){let n=e.scenes[0];for(const i of e.scenes)if(t>=i.start)n=i;else break;return n}const ei=e=>6e4/e.bpm;function Le(e,t){return e.offset+t*ei(e)}function Be(e,t){return(t-e.offset)/ei(e)}function Ul(e,t){return Le(e,Math.round(Be(e,t)))}function zl(e,t){return Le(e,Math.ceil(Be(e,t)-1e-9))}function jl(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(Be(e,t)-1e-9);;r++){const o=Le(e,r);if(o>n+1e-9)break;s.push({time:o,bar:(r%i+i)%i===0,n:r})}return s}const Wt=100;function Gl(e,t,n={}){const i=n.minBpm??70,s=n.maxBpm??180,r=Math.max(1,Math.round(t/Wt)),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 x=0;for(let A=T*r;A<(T+1)*r;A++)x+=e[A]*e[A];l[T]=Math.log(1e-6+x/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,x)=>T+x,0)/a;for(let T=0;T<a;T++)c[T]=Math.max(0,c[T]-h);const f=Math.max(1,Math.floor(60*Wt/s)),u=Math.min(a-1,Math.ceil(60*Wt/i)),p=T=>{let x=0;for(let A=T;A<a;A++)x+=c[A]*c[A-T];return x/(a-T)};let m=0;for(let T=0;T<a;T++)m+=c[T]*c[T];m/=a;let d=f,g=-1/0;for(let T=f;T<=u;T++){const x=60*Wt/T,A=Math.exp(-.5*(Math.log2(x/120)/.9)**2),P=p(T)*A;P>g&&(g=P,d=T)}const y=T=>{const x=Math.floor(T);return x<0||x+1>=a?0:c[x]+(c[x+1]-c[x])*(T-x)},v=(T,x)=>{let A=0;for(let P=x;P<a;P+=T)A+=y(P);return A};let w=d,M=0,k=-1/0;for(let T=d-.6;T<=d+.6+1e-9;T+=.02){if(T<1)continue;const x=Math.max(1,Math.round(T*4));for(let A=0;A<x;A++){const P=A/x*T,C=v(T,P);C>k&&(k=C,M=P,w=T)}}const S=60*Wt/w,E=m>0?Math.max(0,Math.min(1,p(d)/m)):0,_=(M+.5)*1e3/Wt;return{bpm:Math.round(S*100)/100,offset:Math.round(_%(6e4/S)),confidence:E}}const at=e=>Math.round(e*1e3)/1e3;function lr(e,t={}){if(e.length===0)return"";const n=t.curviness??1,i=t.closed??!1,s=e.length;let r=`M${at(e[0].x)} ${at(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),f=o(l+1),u=o(l+2);if(n===0){r+=` L${at(f.x)} ${at(f.y)}`;continue}const p=n/6,m=h.x+(f.x-c.x)*p,d=h.y+(f.y-c.y)*p,g=f.x-(u.x-h.x)*p,y=f.y-(u.y-h.y)*p;r+=` C${at(m)} ${at(d)} ${at(g)} ${at(y)} ${at(f.x)} ${at(f.y)}`}return i?`${r} Z`:r}const Y=(e,t=0)=>{const n=parseFloat(e??"");return Number.isFinite(n)?n:t};function Jl(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 De(e){const t=e.attributes;switch(e.tag.toLowerCase()){case"path":return t.d??null;case"circle":case"ellipse":{const n=Y(t.cx),i=Y(t.cy),s=e.tag.toLowerCase()==="circle"?Y(t.r):Y(t.rx),r=e.tag.toLowerCase()==="circle"?Y(t.r):Y(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=Y(t.x),i=Y(t.y),s=Y(t.width),r=Y(t.height);let o=t.rx!=null?Y(t.rx):t.ry!=null?Y(t.ry):0,a=t.ry!=null?Y(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${Y(t.x1)} ${Y(t.y1)} L${Y(t.x2)} ${Y(t.y2)}`;case"polyline":case"polygon":{const n=Jl(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 Zl(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 Ql=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 f=c[0]+h[0],u=c[1]+h[1];const p=Math.hypot(f,u);p<1e-9?(f=c[0],u=c[1]):(f/=p,u/=p);const m=f*c[0]+u*c[1],d=Math.min(Ql,1/Math.max(m,1e-6)),g=o.width/2*d;t.push({x:o.x-u*g,y:o.y+f*g}),n.push({x:o.x+u*g,y:o.y-f*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 Ne(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function We(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function oe(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function ae(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Ye(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 ni(e){return Math.hypot(e[0],e[1],e[2])}function ur(e,t){return ni(We(e,t))}function le(e){const t=ni(e);return t===0?[0,0,0]:oe(e,1/t)}function fr(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 tc=Object.freeze(Object.defineProperty({__proto__:null,add:Ne,cross:Ye,distance:ur,dot:ae,length:ni,lerp:fr,normalize:le,scale:oe,subtract:We},Symbol.toStringTag,{value:"Module"})),ec=Math.PI/180;function dr(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Tt(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 pr(e){return[1,0,0,0,0,1,0,0,0,0,1,0,e[0],e[1],e[2],1]}function Ke(e){return[e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,1]}function ce(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 mr(e,t,n){const i=ce(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 nc(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 ic(e){const[t,n,i,s,r,o,a,l,c,h,f,u,p,m,d,g]=e,y=t*o-n*r,v=t*a-i*r,w=t*l-s*r,M=n*a-i*o,k=n*l-s*o,S=i*l-s*a,E=c*m-h*p,_=c*d-f*p,T=c*g-u*p,x=h*d-f*m,A=h*g-u*m,P=f*g-u*d,C=y*P-v*A+w*x+M*T-k*_+S*E;if(Math.abs(C)<1e-12)return null;const I=1/C;return[(o*P-a*A+l*x)*I,(i*A-n*P-s*x)*I,(m*S-d*k+g*M)*I,(f*k-h*S-u*M)*I,(a*T-r*P-l*_)*I,(t*P-i*T+s*_)*I,(d*w-p*S-g*v)*I,(c*S-f*w+u*v)*I,(r*A-o*T+l*E)*I,(n*T-t*A-s*E)*I,(p*k-m*w+g*y)*I,(h*w-c*k-u*y)*I,(o*_-r*x-a*E)*I,(t*x-n*_+i*E)*I,(m*v-p*M-d*y)*I,(c*M-h*v+f*y)*I]}function sc(e,t,n,i){const s=1/Math.tan(e*ec/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 rc(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 oc(e,t,n=[0,1,0]){const i=le(We(e,t)),s=le(Ye(n,i)),r=Ye(i,s);return[s[0],r[0],i[0],0,s[1],r[1],i[1],0,s[2],r[2],i[2],0,-ae(s,e),-ae(r,e),-ae(i,e),1]}function gr(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 ac=Object.freeze(Object.defineProperty({__proto__:null,compose:mr,fromQuat:ce,identity:dr,invert:ic,lookAt:oc,multiply:Tt,orthographic:rc,perspective:sc,scaling:Ke,transformPoint:gr,translation:pr,transpose:nc},Symbol.toStringTag,{value:"Module"})),qe={"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]},yr={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 lc(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}V({type:"bounce",mode:"in"}),V({type:"bounce",mode:"in-out"});function he(e){const t=br.get(e.trim().toLowerCase());if(t)return t;const n=lc(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:V(o)}}const s=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(s){const[,r,o,a]=s,l=(a??"").split(",").map(f=>Number.parseFloat(f)).filter(f=>Number.isFinite(f)),c=o==="inout"?"in-out":o;if(r==="back"&&l.length===0&&n in qe)return{easing:{type:"cubic-bezier",points:qe[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:V(h)}}return n in yr?{easing:yr[n]}:n in qe?{easing:{type:"cubic-bezier",points:qe[n]}}:{easing:"ease-out"}}const br=new Map;function ii(e,t){return br.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 wr=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function vr(e){return typeof e=="string"&&wr.test(e)}function cc(e=1){let t=si(e);const n=(l,c)=>((...h)=>h.length>=l?c(...h):f=>c(...h,f)),i=(l,c,h)=>Math.min(Math.max(h,Math.min(l,c)),Math.max(l,c)),s=(l,c,h,f,u)=>c===l?h:h+(u-l)/(c-l)*(f-h),r=(l,c)=>{if(typeof l=="number")return l===0?c:Math.round(c/l)*l;if(Array.isArray(l))return kr(l,c,1/0);if("values"in l)return kr(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 f=l+t()*(c-l);return h?Math.round(f/h)*h:f};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 f={};for(const u of Object.keys(l))f[u]=re(l[u])(l[u],c[u],h);return f}return re(l)(l,c,h)}),wrap:((l,c,h)=>{if(Array.isArray(l)){const d=l,g=y=>d[(Math.round(y)%d.length+d.length)%d.length];return c===void 0?g:g(c)}const f=l,p=c-f,m=d=>p===0?f:((d-f)%p+p)%p+f;return h===void 0?m:m(h)}),wrapYoyo:n(3,(l,c,h)=>{const f=c-l;if(f===0)return l;const u=((h-l)%(f*2)+f*2)%(f*2);return l+(u>f?f*2-u:u)}),snap:n(2,r),random:((l,c,h,f)=>{if(Array.isArray(l)){const p=()=>l[Math.floor(t()*l.length)];return c===!0?p:p()}const u=()=>o(l,c,h);return f?u:u()}),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:f="start",ease:u})=>(p,m,d)=>{const g=d.length,v=Ee(p,g,{...c!==void 0?{amount:c}:{each:h??1},from:f}),w=c!==void 0?c:(h??1)*_n(g,f),M=u&&w>0?u(v/w)*w:v;return l+M},pipe:(...l)=>c=>l.reduce((h,f)=>f(h),c),splitColor:l=>hc(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=wr.exec(l)?.[1]??"";if(c.startsWith("[")){const m=c.slice(1,-1).split(",").map(d=>d.trim()).filter(Boolean).map(d=>Number.isFinite(Number(d))?Number(d):d.replace(/^['"]|['"]$/g,""));return m[Math.floor(t()*m.length)]}const[h,f,u]=c.split(",").map(p=>Number.parseFloat(p));return o(h,f,Number.isFinite(u)?u:void 0)}}}function kr(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 hc(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 uc=/^([+-])=\s*(-?[\d.]+)$/,fc=/^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;function ue(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=uc.exec(s);if(r){const c=i(r[2]);return t.cursor+(r[1]==="-"?-c:c)}const o=fc.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 dc(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 pc(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:d,y:g}=r(m),y=Math.abs(d-a.x),v=Math.abs(g-a.y);return t.axis==="x"?y:t.axis==="y"?v:Math.hypot(y,v)};let c=Array.from({length:e},(m,d)=>l(d));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 f=t.amount!==void 0?t.amount:(t.each??0)*h,u=t.ease?he(t.ease):void 0,p=u?u.fn??V(u.easing):void 0;return c.map(m=>{const d=h===0?0:m/h;return(p?p(d):d)*f})}const ri=new Set(["duration","delay","ease","repeat","repeatDelay","yoyo","stagger","onComplete","onUpdate","onStart","onRepeat","onReverseComplete","repeatRefresh","keyframes","easeEach","scrollTo","id","immediateRender","overwrite","paused","scrollTrigger","spring"]),mc={rotation:"rotate",rotationZ:"rotate",rotationX:"rotateX",rotationY:"rotateY",transformPerspective:"perspective",perspective:"childPerspective"};function Xe(e){const t={},n={};for(const[i,s]of Object.entries(e))ri.has(i)?t[i]=s:n[mc[i]??i]=s;return{config:t,properties:n}}function Ve(e,t){return e===void 0?t:e*1e3}function oi(e,t){if(e!==void 0)return typeof e=="number"?{each:e*1e3}:dc(e)?{offsets:pc(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 gc={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 Sr(e){return gc[e]}function yc(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=lr(t.path,{curviness:t.curviness});else if(Ft(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 bc(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:{...e};return{...t,start:t.end??1,end:t.start??0}}function Mr(e){return typeof e=="object"&&e!==null&&"shape"in e?e.shape:e}function wc(e){if(e.morphSVG===void 0)return e;const{morphSVG:t,...n}=e,i=Mr(t);if(typeof i!="string"||!Ft(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 vc(e,t){if(e===!0)return[0,t];if(e===!1)return[0,0];if(typeof e=="number")return[0,Tr(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 Tr(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 kc(e,t){const[n,i]=vc(e,t);return{strokeDasharray:[i-n,t],strokeDashoffset:-n}}function Sc(e,t){if(e.drawSVG===void 0)return e;const{drawSVG:n,...i}=e;return{...i,...kc(n,t)}}function Mc(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 Tr(e,t){return Math.max(0,Math.min(t,e))}function Tc(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t>>>0}function Ec(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??Tc(`${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 ai(e){return Math.max(.1,e/25)}function Ac(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?ai(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(te(s))]:n.end!==void 0&&(s.end=Array.isArray(n.end)?[...n.end]:n.end),s}function xc(e){const t=e===!0?{}:typeof e=="string"?{preset:e}:e;if(t.preset!==void 0&&!(t.preset in Pe))throw new Error(`gsap-compat: unknown spring preset "${t.preset}" — use one of ${Object.keys(Pe).join(", ")}`);return{...t.preset?Pe[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 Pc(e,t){if(e===!0||typeof e=="string")return;const n=e.velocity;return typeof n=="number"?n:n?.[t]}class Et{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 jn({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,fe(n),i)}from(t,n,i){const{config:s,properties:r}=Xe(fe(n)),{motionPath:o,text:a,scrambleText:l,...c}=r,h=this.targetsOf(t)[0],f={...s};for(const m of Object.keys(c))f[m]=this.resolveStart(h,m);o!==void 0&&(f.motionPath=bc(o));const u={},p=String(this.resolveStart(h,"text"));return a!==void 0&&(u.text=li(a),f.text=typeof a=="object"?{...a,value:p}:p),l!==void 0&&(u.text=li(l),f.scrambleText=typeof l=="object"?{...l,text:p}:p),this.build(t,{...c,...u},f,i)}fromTo(t,n,i,s){const{properties:r}=Xe(fe(n));return this.build(t,r,fe(i),s)}set(t,n,i){return this.build(t,void 0,{...fe(n),duration:0},i)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(t){const n=Math.max(0,ue(t,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(t){return ue(t,this.context())}addLabel(t,n){return this.labels.set(t,ue(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=ue(n,this.context());for(const r of t.timeline.tracks){if(!("keyframes"in r))continue;const o=Re({...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}=Xe(i),{motionPath:a,text:l,scrambleText:c,inertia:h,...f}=o,u=this.targetsOf(t),p=ue(s,this.context()),m=Ve(r.delay,0),d=Ve(r.duration,500),g=oi(r.stagger,{count:u.length,columnsFromLayout:this.options.layoutColumns?()=>this.options.layoutColumns(u):void 0,random:this.options.random??this.fallbackRandom}),y=this.easingFor(r.ease),v=[],w=r.spring;let M=0,k=!1;for(const[A,P]of Object.entries(f)){const C=P;let I=n?.[A]!==void 0?n[A]:this.resolveStart(u[0],A);if(typeof I!=typeof C&&(this.warn(`no usable start value for "${A}" on "${u[0]}" — it will snap to ${String(C)}. Use fromTo() to animate it.`),I=C),w!==void 0&&(typeof I!="number"||typeof C!="number")&&this.warn(`spring works on numbers, so "${A}" on "${u[0]}" eases instead`),w!==void 0&&typeof I=="number"&&typeof C=="number"){const O={...xc(w),from:I,to:C,velocity:Pc(w,A)??this.options.startVelocity?.(u[0],A)??0},L=this.nextTrackId(`${u[0]}-${A}-spring`),F={id:L,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:A,kind:"spring",spring:O,delay:p+m};this.timeline.addTrack(F),v.push(L),M=Math.max(M,os(O));for(const R of u)this.lastValues.set(`${R}|${A}`,C);continue}k=!0;const H=this.keyframesFor(I,C,d,y,r.ease),$=this.nextTrackId(`${u[0]}-${A}`);this.timeline.addTrack(Re({id:$,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:A,delay:p+m,keyframes:H,...A==="quaternion"&&{interpolation:"slerp"}})),v.push($);for(const O of u)this.lastValues.set(`${O}|${A}`,C)}const S=Ec({text:l,scrambleText:c},u[0],d);if(S){const A=n?.text??n?.scrambleText,P=A!==void 0?li(A):this.resolveStart(u[0],"text"),C=this.nextTrackId(`${u[0]}-text`),I={id:C,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:"text",textConfig:{from:typeof P=="string"?P:String(P??""),...S},delay:p+m,keyframes:this.keyframesFor(0,1,d,y,r.ease)};this.timeline.addTrack(I),v.push(C);for(const H of u)this.lastValues.set(`${H}|text`,S.to)}if(a!==void 0){const{config:A,start:P,end:C}=yc(a),I=this.nextTrackId(`${u[0]}-motionPath`),H={id:I,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:"motionPath",motionPathConfig:A,delay:p+m,keyframes:this.keyframesFor(P,C,d,y,r.ease)};this.timeline.addTrack(H),v.push(I)}if(h!==void 0)for(const[A,P]of Object.entries(h)){const C=this.resolveStart(u[0],A);if(typeof C!="number"){this.warn(`inertia on "${A}" needs a numeric start value; skipped`);continue}const I=Ac(C,P),H=this.nextTrackId(`${u[0]}-${A}-inertia`),$={id:H,target:u[0],...u.length>1&&{targets:u},...g&&u.length>1&&{stagger:g},property:A,kind:"inertia",inertia:I,delay:p+m};this.timeline.addTrack($),v.push(H),M=Math.max(M,Rt(I));for(const O of u)this.lastValues.set(`${O}|${A}`,$t(I))}const T=((h!==void 0||w!==void 0)&&!k&&!S&&a===void 0?M:Math.max(d,M))+(g&&u.length>1?Zt(u.length,g):0),x=p+m+T;return this.previousStart=p+m,this.previousEnd=x,this.cursor=Math.max(this.cursor,x),{trackIds:v,start:p+m,end:x,kill:()=>{for(const A of v)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"?he(r):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&Jt(s)){const c=a?.fn??V(s);return[o,...Vn(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=Sr(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 he(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 li(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 _c(e){return new Et(e)}function fe(e){return Mc(wc(e))}function Cc(e){return!Array.isArray(e)||e.length!==4?null:`matrix3d(${ce(gt(e)).map(n=>Math.round(n*1e6)/1e6+0).join(", ")})`}const Ic=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),Hc="#ffffff",$c="rgba(0, 0, 0, 0.5)";function Rc(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??Hc})`),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??$c})`)}return t.length>0?t.join(" "):null}function Oc(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 Fc(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const Er=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"]),Lc=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","quaternion","motionPathX","motionPathY","motionPathRotate"]),Bc=["x","motionPathX","y","motionPathY","z","rotate","rotateZ","motionPathRotate","rotateX","rotateY","quaternion","scale","scaleX","scaleY","scaleZ","skewX","skewY"],Dc=new Set(["childPerspective","perspectiveOriginX","perspectiveOriginY"]),Nc=new Set(["originX","originY"]),Wc=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Yc=new Set(["drawOn"]),Kc={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},Ar={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},qc="http://www.w3.org/2000/svg";class At{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,d]of n)if(!(m==="x"&&l)&&!(m==="y"&&c)&&!((m==="rotate"||m==="rotateZ")&&h)&&!Yc.has(m)){if(Lc.has(m))(i??={})[m]=d;else if(Dc.has(m))typeof d=="number"&&((s??={})[m]=d);else if(Nc.has(m))typeof d=="number"&&((r??={})[m]=d);else if(Wc.has(m))typeof d=="number"&&((o??={})[m]=d);else if(Ic.has(m))(a??={})[m]=d;else if(m!=="perspective"){if(m!=="shine")if(m==="text"&&typeof d=="string")Oc(t,d);else if(m==="d"&&typeof d=="string"){const g=t;(g.tagName?.toLowerCase()==="path"?g:g.querySelector?.("path"))?.setAttribute?.("d",d)}else this.applyStyleProperty(t,m,d)}}const f=n.get("shine");typeof f=="number"&&this.applyShine(t,f);const u=[],p=n.get("perspective");if(typeof p=="number"&&p>0&&u.push(`perspective(${p}px)`),i)for(const m of Bc){const d=i[m];if(d===void 0)continue;const g=this.buildTransformPart(m,d);g&&u.push(g)}if(u.length>0&&(t.style.transform=u.join(" "),Fc(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,d=r.originY??50;t.style.transformOrigin=`${m}% ${d}%`}if(o){const m=o.clipTop??0,d=o.clipRight??0,g=o.clipBottom??0,y=o.clipLeft??0;t.style.clipPath=`inset(${m}% ${d}% ${g}% ${y}%)`}if(a){const m=Rc(a);m&&(t.style.filter=m)}}buildTransformPart(t,n){if(t==="quaternion")return Cc(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===qc&&n in Ar){const a=Array.isArray(i)?i.join(", "):String(i);t.style[Ar[n]]=a;return}else n==="fill"&&t.dataset?.elementType==="text"?s="color":s=Kc[n]??n;let o;typeof i=="number"?Er.has(n)||Er.has(s)?o=`${i}px`:o=String(i):Array.isArray(i)?o=i.join(", "):o=i,t.style[s]=o}}const Xc={request:e=>requestAnimationFrame(e),cancel:e=>cancelAnimationFrame(e)};class xr{adapter=new At;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=cc();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(t={}){this.scheduler=t.scheduler??Xc,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);ci(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(ci(t))return[t];if(!Vc(t))return[t];const n=[];for(const i of Array.from(t))n.push(...this.targetsOf(i));return n}nameFor(t){return ci(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 ci(e){return typeof e=="object"&&e!==null&&e.nodeType===1}function Vc(e){if(Array.isArray(e))return!0;const t=e;return typeof t.length=="number"&&typeof t.item=="function"}function Ue(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 Pr=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function Uc(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function zc(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 jc(e,t){const n=typeof e=="string"||Array.isArray(e)||Pr(e)?{path:e}:e,{align:i,alignOrigin:s,path:r,...o}=n,a=S=>{const E=Pr(S)?S:t.query(S);return E||t.warn(`gsap-compat: motionPath could not find "${String(S)}"`),E};let l=null,c="";if(Array.isArray(r)||typeof r=="string"&&Ft(r))c=r;else{l=a(r);const S=l&&De({tag:l.localName,attributes:Uc(l)});l&&!S&&t.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),c=S??""}const h={...o,path:c};if(i===void 0||i===!1)return h;const f=i===!0?l:a(i);if(!f)return i===!0&&t.warn("gsap-compat: motionPath align: true needs the path to be an element"),h;const u=t.targets[0];if(!u)return h;const[p,m,d,g,y,v]=zc(f),w=Ue(u),[M,k]=s??[.5,.5];for(const S of t.targets.slice(1)){const E=Ue(S);if(Math.abs(E.left-w.left)>.5||Math.abs(E.top-w.top)>.5){t.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");break}}return h.matrix=[p,m,d,g,y-w.left-M*w.width,v-w.top-k*w.height],h}const _r=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function Cr(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function Ir(e){if(!e)return null;const t=De({tag:e.localName,attributes:Cr(e)});return t||(e.querySelector("path")?.getAttribute("d")??null)}function Gc(e,t,n){const i=Mr(e);if(typeof i=="string"&&Ft(i))return i;const s=_r(i)?i:typeof i=="string"?t(i):null,r=Ir(s);return r||(n(`gsap-compat: morphSVG could not find a shape for "${String(i)}"`),"")}const Jc=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function Zc(e,t=document){return(typeof e=="string"?Array.from(t.querySelectorAll(e)):_r(e)?[e]:Array.from(e)).map(i=>{if(i.localName==="path")return i;const s=De({tag:i.localName,attributes:Cr(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))Jc.has(o.name)||r.setAttribute(o.name,o.value);return r.setAttribute("d",s),i.parentNode.replaceChild(r,i),r})}const Hr=.3;class $r{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=Rr(),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=Rr(),s=Math.max(1,i-this.lastTime);this.lastTime=i;const r=t/s*1e3,o=n/s*1e3;this.velocityX+=(r-this.velocityX)*Hr,this.velocityY+=(o-this.velocityY)*Hr}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 Rr(){return typeof performance<"u"?performance.now():Date.now()}function Or(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 Fr(e,t){return t<=0?[]:e.map(n=>Math.round(n/t)*t)}class hi{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 $r({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=Qc(s/i);t.pause(),t.seek(r*n)}applyConstraints(t,n){let i=t;const s=[...Fr([i],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],r=Or([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 Qc(e){return e<0?0:e>1?1:e}function th(e){const t=new hi(e);return t.start(),t}const eh={x:"x",y:"y","x,y":"both"},ui=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function Lr(e,t){const n=Ue(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 Br(e){return Array.isArray(e)?[...e]:e}function nh(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 ih(e,t,s,r,i);const o=eh[i.type??"x,y"],a=()=>{const d=t.appliedValue(s,"x"),g=t.appliedValue(s,"y");return{x:typeof d=="number"?d:0,y:typeof g=="number"?g:0}},l=typeof i.bounds=="string"?t.query(i.bounds):ui(i.bounds)?i.bounds:null,h={bounds:(!l&&i.bounds&&!ui(i.bounds)?i.bounds:void 0)??(l?Lr(r,l):void 0)};let f=null;const u=()=>{f?.kill(),f=null},p=d=>{const g=i.inertia===!0?{}:i.inertia,y=g.friction??(g.resistance!==void 0?ai(g.resistance):4),v=a(),w=h.bounds??{};let M,k;const S=g.end;if(Array.isArray(S)){const _=te({from:v.x,velocity:o==="y"?0:d.x,friction:y}),T=te({from:v.y,velocity:o==="x"?0:d.y,friction:y});let x=S[0];for(const A of S)Math.hypot(A.x-_,A.y-T)<Math.hypot(x.x-_,x.y-T)&&(x=A);x&&(M=[x.x],k=[x.y])}else typeof S=="number"?(M=S,k=S):S&&(M=Br(S.x),k=Br(S.y));const E={};o!=="y"&&(E.x={velocity:d.x,friction:y,min:w.minX,max:w.maxX,end:M}),o!=="x"&&(E.y={velocity:d.y,friction:y,min:w.minY,max:w.maxY,end:k}),f=e.to(r,{inertia:E,onComplete:()=>i.onThrowComplete?.()})},m=new hi({target:r,axis:o,snap:i.snap,get bounds(){return h.bounds},getPosition:a,onPress:()=>{u(),l&&(h.bounds=Lr(r,l)),i.onPress?.()},onDrag:d=>{t.apply(s,o==="x"?{x:d.x}:o==="y"?{y:d.y}:{x:d.x,y:d.y}),i.onDrag?.(d)},onRelease:()=>{const d=m.velocity;i.onRelease?.(d),i.inertia&&p(d)}});return m.start(),{draggable:m,get position(){return a()},get rotation(){const d=t.appliedValue(s,"rotate");return typeof d=="number"?d:0},destroy(){u(),m.destroy()}}}function ih(e,t,n,i,s){const r=typeof s.bounds=="object"&&s.bounds!==null&&!ui(s.bounds)?s.bounds:{},o=()=>{const w=t.appliedValue(n,"rotate");return typeof w=="number"?w:0},a=w=>Math.min(r.maxRotation??1/0,Math.max(r.minRotation??-1/0,w));let l=null,c=!1,h,f={x:0,y:0},u=0,p=0,m=[];const d=w=>Math.atan2(w.clientY-f.y,w.clientX-f.x)*180/Math.PI,g=w=>{if(c)return;l?.kill(),l=null,c=!0,h=w.pointerId,i.setPointerCapture?.(w.pointerId);const M=i.getBoundingClientRect();f={x:M.left+M.width/2,y:M.top+M.height/2},u=d(w),p=o(),m=[{time:performance.now(),rotation:p}],s.onPress?.()},y=w=>{if(!c||w.pointerId!==h)return;const M=d(w);let k=M-u;k>180&&(k-=360),k<-180&&(k+=360),u=M,p+=k;let S=a(p);s.snap&&(S=a(Math.round(S/s.snap)*s.snap)),t.apply(n,{rotate:S});const E=performance.now();for(m.push({time:E,rotation:S});m.length>2&&E-m[0].time>100;)m.shift();const _={x:0,y:0};s.onDrag?.(_)},v=w=>{if(!c||w.pointerId!==h)return;c=!1;const M=m[0],k=m[m.length-1],S=M&&k?(k.time-M.time)/1e3:0,E=S>0?(k.rotation-M.rotation)/S:0;if(s.onRelease?.({x:E,y:0}),!s.inertia)return;const _=s.inertia===!0?{}:s.inertia,T=_.friction??(_.resistance!==void 0?ai(_.resistance):4),x=typeof _.end=="number"||Array.isArray(_.end)?_.end:void 0;l=e.to(i,{inertia:{rotate:{velocity:E,friction:T,min:r.minRotation,max:r.maxRotation,end:Array.isArray(x)?x.filter(A=>typeof A=="number"):x}},onComplete:()=>s.onThrowComplete?.()})};return i.addEventListener("pointerdown",g),i.addEventListener("pointermove",y),i.addEventListener("pointerup",v),i.addEventListener("pointercancel",v),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",v),i.removeEventListener("pointercancel",v)}}}const sh={opacity:0,scale:.6};function rh(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 Dr(e){const t=Ue(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 fi(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=rh(o);s.set(o,a);const l=Nr(o);a&&l!==void 0&&!r.has(l)&&r.set(l,{element:o,box:a})}return{elements:i,boxes:s,ids:r}}const di=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?sh:i.enter,c=new Set(n.elements);if(i.targets!==void 0)for(const p of e.resolveTargets(i.targets)){const m=e.elementFor(p);m&&c.add(m)}const h=[...c].sort((p,m)=>p===m?0:p.compareDocumentPosition(m)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),f=t({onComplete:i.onComplete});let u=0;for(const p of h){const m=Dr(p);if(!m)continue;let d=n.boxes.get(p)??null,g;const y=Nr(p),v=!d&&y!==void 0?n.ids.get(y):void 0;v&&v.element!==p&&(d=v.box,g=v.element);const[w]=e.resolveTargets(p);di.get(p)?.timeline.removeTracks({target:w});const M=u*o;if(!d){if(l===!1)continue;f.fromTo(p,{x:0,y:0,scaleX:1,scaleY:1,...l},{...Wr(l),x:0,y:0,scaleX:1,scaleY:1,duration:s,ease:r,delay:M},0),di.set(p,f),u++;continue}const k=d.cx-m.cx,S=d.cy-m.cy,E=a?d.width/m.width:1,_=a?d.height/m.height:1;if(!(Math.abs(k)>.5||Math.abs(S)>.5||Math.abs(E-1)>.001||Math.abs(_-1)>.001)){const A=(P,C)=>{const I=e.appliedValue(w,P);return typeof I=="number"&&Math.abs(I-C)>1e-6};(A("x",0)||A("y",0)||A("scaleX",1)||A("scaleY",1))&&f.set(p,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const x=i.fade===!0&&g!==void 0;f.fromTo(p,{x:k,y:S,scaleX:E,scaleY:_,...x&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,...x&&{opacity:1},duration:s,ease:r,delay:M},0),x&&g&&Dr(g)&&f.fromTo(g,{opacity:1},{opacity:0,duration:s,ease:r,delay:M},0),di.set(p,f),u++}return f}function Nr(e){return e.dataset?.flipId}function Wr(e){const t={};for(const n of Object.keys(e))t[n]=n==="opacity"||n.startsWith("scale")?1:0;return t}function oh(e,t={}){const n=new Set((t.type??"chars,words,lines").split(",").map(d=>d.trim())),i={chars:t.charsClass??"char",words:t.wordsClass??"word",lines:t.linesClass??"line"},s=t.aria!==!1,r=e.map(d=>({element:d,html:d.innerHTML,ariaLabel:d.getAttribute("aria-label")}));let o={chars:[],words:[],lines:[],masks:[]},a,l,c=!1;const h=()=>{for(const{element:d,html:g,ariaLabel:y}of r)d.innerHTML=g,y===null?d.removeAttribute("aria-label"):d.setAttribute("aria-label",y)},f=()=>{a&&(a.revert?a.revert():a.kill?.(),a=void 0)},u=()=>{const d={chars:[],words:[],lines:[],masks:[]};for(const{element:g}of r){const y=(g.textContent??"").replace(/\s+/g," ").trim(),v=ah(g,i.words),w=n.has("chars")?v.flatMap(S=>lh(S,i.chars)):[],M=n.has("lines")?hh(g,v,i.lines):[];if(s){!g.hasAttribute("aria-label")&&y&&g.setAttribute("aria-label",y);for(const S of v)S.setAttribute("aria-hidden","true")}if(n.has("words"))d.words.push(...v);else for(const S of v)S.removeAttribute("class");d.chars.push(...w),d.lines.push(...M);const k=t.mask==="lines"?M:t.mask==="words"?v:t.mask==="chars"?w:[];for(const S of k)d.masks.push(uh(S,`${i[t.mask]}-mask`))}o=d},p={elements:e,get chars(){return o.chars},get words(){return o.words},get lines(){return o.lines},get masks(){return o.masks},split(){c||(f(),h(),u(),a=t.onSplit?.(p))},revert(){c=!0,l?.disconnect(),f(),h()}};u(),a=t.onSplit?.(p),t.autoSplit&&m();function m(){const d=new Map;let g=!1;const y=()=>{if(g)return;g=!0;const w=()=>{g=!1,p.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(w):setTimeout(w,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(w=>{let M=!1;for(const k of w){const S=Math.round(k.contentRect.width),E=d.get(k.target);d.set(k.target,S),E!==void 0&&E!==S&&(M=!0)}M&&y()});for(const w of e)l.observe(w)}const v=e[0]?.ownerDocument?.fonts;v&&v.status!=="loaded"&&v.ready.then(()=>y())}return p}function ah(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 lh(e,t){const n=e.ownerDocument,i=ch(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 ch(e){const t=Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),n=>n.segment):Array.from(e)}function hh(e,t,n){const i=e.ownerDocument,s=new Map(t.map(m=>[m,m.getBoundingClientRect()])),r=[],o=m=>{for(const d of Array.from(m.childNodes))d.nodeType===3||s.has(d)||d.tagName==="BR"?r.push(d):o(d)};o(e);const a=[];let l=null,c=0,h=0,f=!1,u=[];const p=()=>{l=i.createElement("span"),l.className=n,l.style.display="block",a.push(l),u=[]};for(const m of r){if(m.tagName==="BR"){f=!0;continue}const d=s.get(m);if(d&&(!l||f||d.top>c+h)&&(p(),c=d.top,h=d.height/2,f=!1),!l)continue;const g=[];for(let w=m.parentNode;w&&w!==e;w=w.parentNode)g.unshift(w);let y=0;for(;y<u.length&&y<g.length&&u[y].original===g[y];)y++;u.length=y;let v=y===0?l:u[y-1].clone;for(const w of g.slice(y)){const M=w.cloneNode(!1);v.appendChild(M),u.push({original:w,clone:M}),v=M}v.appendChild(m)}return e.replaceChildren(...a),a}function uh(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 Yr={top:0,left:0,start:0,center:.5,centre:.5,middle:.5,bottom:1,right:1,end:1};function mi(e){const t=e.trim().toLowerCase();if(t in Yr)return Yr[t];if(t.endsWith("%")){const n=Number.parseFloat(t.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function gi(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?mi(i[0]):void 0,r=i[1]!==void 0?mi(i[1]):void 0;return{elementFraction:s??0,viewportFraction:r??0,offsetPx:t}}function Yt(e,t,n){const i=gi(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 fh(e,t,n,i){const s=Yt(e,t,n),o=Yt(e,t,i)-s;return o<=0?s<=0?1:0:yi(-s/o)}function yi(e){return e<0?0:e>1?1:e===0?0:e}function Kr(e,t,n,i){if(n<=0)return t;const s=1-Math.exp(-(i/1e3)/n);return e+(t-e)*s}function bi(e,t,n,i,s){const r=h=>Yt({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 f=(l+c)/2;Math.sign(r(f))===Math.sign(o)?l=f:c=f}return(l+c)/2}class qr{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 dh(e){const t=new qr(e);return t.start(),t}class Xr{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 ph=.15;function Vr(e){return typeof e=="object"&&!Array.isArray(e)?e:{snapTo:e}}function Ur(e,t,n){const i=ze(e+t*ph);if(typeof n=="function")return ze(n(i));if(typeof n=="number")return n<=0?e:ze(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 ze(s)}function zr(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 jr{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=ee,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 ze(e){return Math.max(0,Math.min(1,e))}class Gr{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,f)=>{const u=t.createElement("div");return u.textContent=`${a}${c}`,u.setAttribute("aria-hidden","true"),u.className="scroll-marker",Object.assign(u.style,{position:f?"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(u),this.nodes.push(u),u};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 mh=120,Kt=[],qt=new Set;let wi=!1;const gh=()=>{wi||qt.size===0||(wi=!0,queueMicrotask(()=>{wi=!1;for(const e of qt)e.afterRefresh()}))},Jr=()=>{for(const e of qt)e.beforeRefresh();for(const e of Kt)e.refresh();for(const e of qt)e.afterRefresh()};let Xt={width:0,height:0};const Zr=()=>{const e=window.innerWidth,t=window.innerHeight,n=e===Xt.width&&t!==Xt.height,i=Math.abs(t-Xt.height)<Xt.height*.25,s=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&i&&s||(Xt={width:e,height:t},Jr())};class de{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 jr(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 Xr(t,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new Gr(document,this.options.scroller??null,this.options.markers)),this.scrollTarget()?.addEventListener("scroll",this.onScroll,{passive:!0}),Kt.length===0&&typeof window<"u"&&(Xt={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",Zr,{passive:!0})),Kt.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Kt.splice(Kt.indexOf(this),1),Kt.length===0&&typeof window<"u"&&window.removeEventListener("resize",Zr),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(){Jr()}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+Yt(n,i,pe(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,gh()}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?yi((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=pe(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+Yt(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()},mh))}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=Vr(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+Ur(o,this.releaseVelocity/s,n.snapTo)*s;Math.abs(a-r)<1||this.snapper.animate(r,a,zr(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=p=>a+p*(l-a),h=bi(o,i.width,r,pe(this.options.start)??"left right",t.shiftAt);this.startPx=c(h);const f=pe(this.options.end)??"right left",u=typeof f=="string"?f.trim().match(/^\+=\s*(-?[\d.]+)\s*(px)?$/):null;this.endPx=u?this.startPx+Number.parseFloat(u[1]):c(bi(o,i.width,r,f,t.shiftAt)),this.markerGeometry=null}markersFor(t){const n=(r,o)=>{const a=pe(r)??o;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=gi(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=Kr(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 pe(e){return typeof e=="function"?e():e}function yh(e){const t=new de(e);return t.start(),t}const vi=new Set,bh=16,Qr=.5,wh=2;class ki{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),vi.add(this),this.stopListening=de.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const t of vi)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),vi.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const t of this.effects)Si(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??ee,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)Si(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?bh: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)<=wh||(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)<Qr&&(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)<Qr?s.lagged=i:n=!0,r+=i-s.lagged}Si(s.element,r===0?s.saved:`0 ${vh(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 Si(e,t){t?e.style.setProperty("translate",t):e.style.removeProperty("translate")}function vh(e){return Math.round(e*100)/100}function kh(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 Mi(e,t,n,i,s=()=>{}){const r=p=>typeof p=="string"?e.query(p)??void 0:p,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 f=(p,m)=>()=>{m?.(),n&&!a&&kh(n,l[p]??"none"),t.once&&p===0&&queueMicrotask(()=>h.destroy())},u=t.containerAnimation?Th(e,t.containerAnimation,o,s):void 0;return h=new de({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:Sh(t.snap,n),markers:t.markers,container:u,onUpdate:(p,m)=>{if(n&&a!==!1&&n.progress(p),t.onUpdate){const d=p<c||m<0?-1:1;t.onUpdate({progress:p,velocity:m,direction:d})}c=p},onEnter:f(0,t.onEnter),onLeave:f(1,t.onLeave),onEnterBack:f(2,t.onEnterBack),onLeaveBack:f(3,t.onLeaveBack)}),n&&a===!1&&n.progress(0),h.start(),e.own(h)}function Sh(e,t){const n=s=>s==="labels"?r=>Mh(r,t?.labelProgresses?.()??[]):s;if(typeof e!="object"||Array.isArray(e))return n(e);const i=e.ease?he(e.ease):void 0;return{snapTo:n(e.snapTo),duration:e.duration,delay:e.delay,ease:i?i.fn??V(i.easing):void 0}}function Mh(e,t){return t.reduce((n,i)=>Math.abs(i-e)<Math.abs(n-e)?i:n,t[0]??e)}function Th(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 to{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 Eh{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 to(this.host,this.scope);r.conditions=n,r.add(()=>t.setup(r)),t.context=r}}class Ah{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 xh={opacity:0,y:-16},Ph={opacity:0,y:16};async function _h(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 Ch(r,i,o);const a=i.duration??.35,l=i.ease??"power2.inOut",c=g=>new Promise(y=>{g(y)||y()}),h=o(),f=h.length?fi(t,h):void 0,u=i.from!==void 0?eo(t,i.from,i.shared):[];if(u.length&&i.leave!==!1){const g=i.leave??xh;await c(y=>e.to(u,{...g,duration:a,ease:l,onComplete:y}))}await i.update();const p=[],m=typeof i.to=="function"?i.to():i.to,d=m!==void 0?eo(t,m,i.shared):[];if(d.length&&i.enter!==!1){const g=i.enter??Ph;p.push(c(y=>e.fromTo(d,g,{...Wr(g),duration:a,ease:l,onComplete:y})))}if(f){const g=o().filter(y=>!h.includes(y));g.length&&p.push(c(y=>pi(t,n,f,{targets:g,duration:a*1.4,ease:l,enter:!1,onComplete:y})))}await Promise.all(p)}function eo(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 Ch(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 no={create:(e,t)=>ii(e,sr(t))},io={create:(e,t)=>ii(e,{fn:rr(t)})},so={create:(e,t)=>ii(e,{fn:or(t)})},Ih=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),ro=.5,Hh="power1.inOut";function $h(e){return e.keyframes!==void 0&&e.keyframes!==null}function Rh(e){const t=e.keyframes,n={};for(const[c,h]of Object.entries(e))Ih.has(c)||(n[c]=h);if(Array.isArray(t))return t.map(c=>({...n,...c,duration:c.duration??e.duration??ro}));const i=Object.entries(t),s=e.duration??ro,r=t.easeEach??e.easeEach??Hh;if(i.length>0&&i.every(([c])=>/^\s*-?\d+(\.\d+)?\s*%\s*$/.test(c)||c==="easeEach")){const c=i.filter(([u])=>u!=="easeEach").map(([u,p])=>({at:Number.parseFloat(u)/100,step:p})).sort((u,p)=>u.at-p.at),h=[];let f=0;for(const{at:u,step:p}of c){const m=Math.max(0,u-f);h.push({...n,ease:r,...p,duration:m*s}),f=u}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[f,u]of o)c<u.length&&(h[f]=u[c]);l.push(h)}return l}function oo(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=(v,w)=>{if(w===void 0)return o[v];if(typeof w=="number")return w;if(w==="max")return a[v];const M=typeof w=="string"?s.querySelector(w):w;if(!M)return o[v];const k=M.getBoundingClientRect(),S=r?.getBoundingClientRect(),E=(v==="x"?i.offsetX:i.offsetY)??i.offset??0;return v==="x"?k.left-(S?.left??0)+o.x-E:k.top-(S?.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))},f={...o},u=()=>{r?(r.scrollLeft=f.x,r.scrollTop=f.y):window.scrollTo({left:f.x,top:f.y,behavior:"instant"})},p=["wheel","touchstart","keydown"],m=r??window,d=()=>{y.kill(),g()},g=()=>{for(const v of p)m.removeEventListener(v,d)},y=e.to(f,{x:h.x,y:h.y,duration:i.duration??1,ease:i.ease??"power2.inOut",onStart:i.onStart,onUpdate:()=>{u(),i.onUpdate?.()},onComplete:()=>{g(),i.onComplete?.()}});if(i.autoKill!==!1)for(const v of p)m.addEventListener(v,d,{passive:!0});return y}function Oh(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,...f}=n,u={onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h},p={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},m={},d=y=>{m[y]!==void 0&&clearTimeout(m[y]),m[y]=void 0;const v=p[y].splice(0);v.length>0&&u[y]?.(v)},g=(y,v)=>{if(u[y]){if(p[y].push(v),o!==void 0&&p[y].length>=o)return d(y);m[y]===void 0&&(m[y]=setTimeout(()=>d(y),r*1e3))}};return s.map(y=>Mi(e,{...f,trigger:y,onEnter:()=>g("onEnter",y),onLeave:()=>g("onLeave",y),onEnterBack:()=>g("onEnterBack",y),onLeaveBack:()=>g("onLeaveBack",y)})).filter(y=>y!==void 0)}class lt{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 Et({...i,startValue:(s,r)=>{const o=t.objectFor(s);if(o)return Bh(o[r]);const a=t.appliedValue(s,r);if(a!==void 0)return a;if(r==="d")return Ir(t.elementFor(s))??void 0;if(r==="text")return t.elementFor(s)?.textContent??void 0;if(r==="strokeDasharray"||r==="strokeDashoffset"){const l=uo(t.elementFor(s));if(l!==void 0)return r==="strokeDasharray"?[l,l]:0}},startVelocity:(s,r)=>t.velocityOf(s,r),layoutColumns:s=>ho(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=Mi(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 $h(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 lt(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}=Gn(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 f=(u,p,m)=>{s(u,p,m),c=Math.min(c,this.compat.lastStart),h=Math.max(h,this.compat.lastEnd)};if(this.buildTween(r,n,i,f),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=Rh(n);if(r.length===0)return;const o=s.length>1?oi(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?Ae(s.length,o).map(g=>g/1e3):[0],h=this.compat.timeOf(i)/1e3+Ve(n.delay,0)/1e3;let f=1/0,u=-1/0;if(l.forEach((g,y)=>{r.forEach((v,w)=>{const M=w===0?h+c[y]:">";this.tween(g,[v],M,([k],S,E)=>this.compat.to(S,k,E)),f=Math.min(f,this.compat.lastStart),u=Math.max(u,this.compat.lastEnd)})}),f===1/0)return;const{onStart:p,onUpdate:m,onComplete:d}=n;p&&this.events.push({time:f,direction:"forward",run:p}),m&&this.ranges.push({start:f,end:u,run:m}),d&&this.events.push({time:u,direction:"forward",run:d})}staggerContext(t){return{count:t.length,columnsFromLayout:()=>ho(t.map(n=>this.stage.elementFor(n))),random:()=>this.stage.utils.random(0,1)}}buildTween(t,n,i,s){const r=t.map(u=>this.targetFor(u));if(!(t.length>1&&(n.some(Lh)||t.some(u=>this.stage.objectFor(u)!==void 0)))){const u=this.targetFor(t[0]);s(n.map(p=>this.prepare(co(p,0,u,this.stage.utils,r),t)),t,i);return}const a=n.length-1,{stagger:l,...c}=n[a],h=oi(l,this.staggerContext(t)),f=h?Ae(t.length,h).map(u=>u/1e3):t.map(()=>0);t.forEach((u,p)=>{const m=p===0?Ve(c.delay,0)/1e3+f[0]:0,d=p===0?0:f[p]-f[p-1],g=p===0?i:`<${d<0?"-":"+"}${Math.abs(d).toFixed(6)}`,v=n.map((w,M)=>M===a?{...c,delay:m}:w).map(w=>this.prepare(co(w,p,this.targetFor(u),this.stage.utils,r),[u]));s(v,[u],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=jc(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=Gc(t.morphSVG,s,i),{morphSVG:a,...l}=r;r=o?{...r,morphSVG:o}:l}if(t.drawSVG!==void 0){const o=uo(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=Sc(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 ${Dh(t)}`);return}return this.firstElement??=n.map(i=>this.stage.elementFor(i)).find(i=>i!==void 0),n}}function ao(e=new xr){const t=r=>{const{config:o}=Xe(r);return new lt(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:f,...u}=r;return u},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)??Sr(o)},scrollTrigger:r=>i(Mi(e,r)),scrollBatch:(r,o)=>Oh(e,r,o).map(a=>i(a)),scrollTo:(r,o)=>oo(s,e,r,o),refreshScroll:()=>{de.refreshAll(),ki.refreshAll()},smoothScroll:(r={})=>{const o=typeof r.scroller=="string"?(e.collector?.scope??e.root).querySelector(r.scroller):r.scroller;return i(new ki({...r,scroller:o}).start())},context:(r,o)=>{const a=new to(e,o);return r&&a.add(()=>r(a)),a},matchMedia:r=>new Eh(e,r),customEase:no.create,customBounce:io.create,customWiggle:so.create,pageTransition:r=>_h(s,e,o=>new lt(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 Ah(a,o))},quickTo:(r,o,a={})=>{const l=new lt(e,{paused:!0}),[c]=e.resolveTargets(r);return Object.assign(f=>{if(!c)return;const u=a.spring!==void 0?e.velocityOf(c,o)??0:0;l.compat.reset(),l.compat.to(c,{[o]:f,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:Fh(a.spring,o,u)}}),l.timeline.stop(),l.timeline.play(),e.activate(l.timeline)},{tween:l,kill:()=>l.kill()})},timeline:r=>new lt(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 oo(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 lt(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=>Zc(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(oh(l,o))},draggable:(r,o)=>i(nh(s,e,r,o)),getFlipState:r=>fi(e,r),flipFrom:(r,o)=>pi(e,a=>new lt(e,a),r,o),flip:(r,o,a)=>{const l=fi(e,r);return o(),pi(e,c=>new lt(e,c),l,{targets:r,...a})}};return s}const z=ao();function Fh(e,t,n){return e===!0?{velocity:{[t]:n}}:typeof e=="string"?{preset:e,velocity:{[t]:n}}:{...e,velocity:{[t]:n}}}function Lh(e){return e.morphSVG!==void 0||e.drawSVG!==void 0||e.text!==void 0||e.scrambleText!==void 0||lo(e)}function lo(e){return Object.entries(e).some(([t,n])=>(typeof n=="function"||vr(n))&&!ri.has(t))}function co(e,t,n,i,s){if(!lo(e))return e;const r={};for(const[o,a]of Object.entries(e))ri.has(o)?r[o]=a:typeof a=="function"?r[o]=a(t,n,s):vr(a)?r[o]=i.resolveRandomString(a):r[o]=a;return r}function ho(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 uo(e){const t=e;if(typeof t?.getTotalLength=="function")return t.getTotalLength()}function Bh(e){if(typeof e=="number"||typeof e=="string"||Array.isArray(e)&&e.every(t=>typeof t=="number"))return e}function Dh(e){return typeof e=="string"?`"${e}"`:String(e)}class Ti{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 fo(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 je{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 At}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=Nt({...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 Ti(i)})})}syncAllMedia(t,n){for(const i of this.mediaTargets)fo(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 At;i.querySelectorAll("[data-tinyfly]").forEach(a=>{const l=a.getAttribute("data-tinyfly");l&&o.registerTarget(l,a)}),this.symbolInstances.push({adapter:o,timeline:Nt(r.timeline)})})}attachMedia(t,n){this.mediaSync=new Ti(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}=Gn(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 Nh(e,t,n={}){const i=new je(e,{...n,autoplay:!0});return await i.load(t),i}function Wh(e,t={}){return new je(e,t)}const po={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"},mo="tinyfly-controls-style",Yh=`
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=`
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 Kh=0;function qh(e){if(e.getElementById(mo))return;const t=e.createElement("style");t.id=mo,t.textContent=Yh,e.head.appendChild(t)}function go(e,t,n={}){const i=t.ownerDocument;qh(i);const s={...po,...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,$,O,L="")=>{const F=i.createElement("button");return F.type="button",F.className=`tf-ctl-btn ${L}`.trim(),F.setAttribute("aria-label",H),F.title=H,F.textContent=$,F.addEventListener("click",O),F},f=h(s.restart,"⟲",()=>{e.pause(),e.seek(0)}),u=h(s.prev,"|◀",()=>e.prev()),p=h(s.play,"▶",()=>e.isPlaying?e.pause():d(),"tf-ctl-primary"),m=h(s.next,"▶|",()=>e.next()),d=()=>{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 v=i.createElement("select");v.className="tf-ctl-speed",v.setAttribute("aria-label",s.speed);for(const H of r){const $=i.createElement("option");$.value=String(H),$.textContent=`${H}×`,H===1&&($.selected=!0),v.appendChild($)}v.addEventListener("change",()=>e.setSpeed(Number(v.value))),c.append(f,u,p,m,g,y),r.length>0&&c.append(v),l.append(c);const w=n.fullscreen?zh(t,i,s):void 0;w&&c.append(w.button);const M=i.createElement("p");M.className="tf-ctl-caption",M.setAttribute("aria-live","polite"),n.captions!==!1&&l.append(M);const k=i.createElement("div");k.className="tf-ctl-question",k.hidden=!0;const S=i.createElement("span"),E=h(s.reveal,s.reveal,()=>e.play(),"tf-ctl-primary");k.append(S,E),l.append(k);const _=Xh(e,i,s.scenario,n.scenarioControl??"buttons");_&&l.append(_.element);const T=n.mount;T?T.appendChild(l):t.insertAdjacentElement("afterend",l);const x=()=>{const H=e.isPlaying;p.textContent=H?"❚❚":"▶",p.setAttribute("aria-label",H?s.pause:s.play),p.title=H?s.pause:s.play;const $=e.duration;i.activeElement!==g&&(g.value=String($>0?Math.round(e.currentTime/$*1e3):0));const O=e.markers;if(u.hidden=m.hidden=y.hidden=O.length===0,O.length>0){const L=e.currentMarker,F=L?O.indexOf(L)+1:0;y.textContent=s.stepFormat.replace("{index}",String(F)).replace("{total}",String(O.length)),y.setAttribute("aria-label",`${s.step} ${F} ${s.of} ${O.length}`),u.disabled=e.currentTime<=.5,m.disabled=e.currentTime>=$-.5;const R=e.caption()??"";M.textContent!==R&&(M.textContent=R),M.hidden=!a();const B=!H&&L?.question!==void 0&&Math.abs(e.currentTime-L.time)<1;k.hidden=!B,B&&S.textContent!==L.question&&(S.textContent=L.question)}else k.hidden=!0,M.hidden=!0;_?.update()},A=e.subscribe(x);x();const P=n.keyboardScope??t;!P.hasAttribute("tabindex")&&P.tabIndex<0&&(P.tabIndex=0);const C=new WeakSet,I=H=>{if(C.has(H)||(C.add(H),H.defaultPrevented||H.altKey||H.ctrlKey||H.metaKey))return;const $=H.target;if(!($.tagName==="INPUT"||$.tagName==="SELECT")&&!(H.key===" "&&$.tagName==="BUTTON"))switch(H.key){case" ":H.preventDefault(),e.isPlaying?e.pause():d();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(!w)return;H.preventDefault(),w.active?w.exit():w.enter();break}};return P.addEventListener("keydown",I),l.addEventListener("keydown",I),{element:l,fullscreen:w&&{get active(){return w.active},enter:w.enter,exit:w.exit},destroy(){w?.destroy(),A(),P.removeEventListener("keydown",I),l.removeEventListener("keydown",I),l.remove()}}}function Xh(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 f=t.createElement("span");f.textContent=n,f.setAttribute("aria-hidden","true");const u=t.createElement("input");u.type="range",u.min="0",u.max=String(s.length-1),u.step="1",u.setAttribute("aria-label",n);const p=t.createElement("output");return p.setAttribute("aria-hidden","true"),u.addEventListener("input",()=>{const d=s[Number(u.value)];d&&e.setScenario(d.id)}),h.append(f,u,p),{element:h,update:()=>{const d=Math.max(0,s.findIndex(y=>y.id===e.scenario));t.activeElement!==u&&(u.value=String(d));const g=s[d].label;p.textContent!==g&&(p.textContent=g),u.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-${++Kh}`,l=s.map(h=>{const f=t.createElement("label");f.className="tf-ctl-choice";const u=t.createElement("input");u.type="radio",u.name=a,u.value=h.id,u.addEventListener("change",()=>{u.checked&&e.setScenario(h.id)});const p=t.createElement("span");return p.textContent=h.label,f.append(u,p),r.append(f),u});return{element:r,update:()=>{for(const h of l){const f=h.value===e.scenario;h.checked!==f&&(h.checked=f)}}}}const Vh='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',Uh='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';function zh(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 d=o!==void 0;r.innerHTML=d?Uh:Vh;const g=d?n.exitFullscreen:n.fullscreen;r.setAttribute("aria-label",g),r.title=g,r.setAttribute("aria-pressed",String(d)),e.classList.toggle("tf-fullscreen",d),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()},f=d=>{d.key==="Escape"&&m()},u=()=>{o="overlay",a=t.documentElement.style.overflow,t.documentElement.style.overflow="hidden",t.addEventListener("keydown",f),l()};async function p(){if(o)return;const d=s.requestFullscreen?.bind(s)??s.webkitRequestFullscreen?.bind(s),g=i.fullscreenEnabled??i.webkitFullscreenEnabled??!1;if(d&&g)try{if(await d(),c()===e){o="native",l();return}}catch{}u()}async function m(){if(o==="overlay")t.removeEventListener("keydown",f),t.documentElement.style.overflow=a,o=void 0,l();else if(o==="native"){o=void 0,l();const d=i.exitFullscreen?.bind(i)??i.webkitExitFullscreen?.bind(i);c()===e&&d&&await d()}}return r.addEventListener("click",()=>{o?m():p()}),t.addEventListener("fullscreenchange",h),t.addEventListener("webkitfullscreenchange",h),l(),{button:r,get active(){return o!==void 0},enter:p,exit:m,destroy(){m(),t.removeEventListener("fullscreenchange",h),t.removeEventListener("webkitfullscreenchange",h),r.remove()}}}const yo="tinyfly-choices-style",jh=`
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=`
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 Gh(e){if(e.getElementById(yo))return;const t=e.createElement("style");t.id=yo,t.textContent=jh,e.head.appendChild(t)}function bo(e,t){const n=Array.from(t.querySelectorAll("[data-tinyfly-choose]"));if(n.length===0)return()=>{};Gh(t.ownerDocument);const i=[],s=[];for(const a of n){const l=a.getAttribute("data-tinyfly-choose")??"",c=[],h=(m,d)=>{a.hasAttribute(m)||(a.setAttribute(m,d),c.push(m))};h("role","button"),h("tabindex","0");const f=e.scenarios.find(m=>m.id===l)?.label;f!==void 0&&h("aria-label",f),a.setAttribute("aria-pressed","false"),c.push("aria-pressed"),i.push({element:a,attributes:c});const u=()=>e.setScenario(l),p=m=>{const d=m.key;d!=="Enter"&&d!==" "||(m.preventDefault(),u())};a.addEventListener("click",u),a.addEventListener("keydown",p),s.push(()=>{a.removeEventListener("click",u),a.removeEventListener("keydown",p)})}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 Ge=new WeakMap,Ei=new WeakMap;let Jh=0;function me(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=Ge.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=Qh(e.getAttribute("data-markers")),a=i.length>1||s?.hasAttribute("data-scenario")?Zh(i,o,e):void 0;if(a&&a.length===0)return;let l=s&&!a?me(s.textContent,"timeline",e):void 0;if(!l&&r&&o){const p=await fetch(r);p.ok&&(l=await p.json())}if(l&&o&&(l=vo(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=me(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),h={playWhenVisible:!0,...t.player,...c&&{captions:c},...me(e.getAttribute("data-options"),"data-options",e)};eu(e);const f=new je(e,h),u={element:e,player:f};if(Ge.set(e,u),e.setAttribute("data-tinyfly-mounted",""),a){const p=e.getAttribute("data-scenario")??void 0;await f.loadScenarios(a,{initial:a.some(m=>m.id===p)?p:void 0}),Ei.set(e,bo(f,e))}else await f.load(l??r);if(e.getAttribute("data-controls")!=="false"){const p=me(e.getAttribute("data-labels"),"data-labels",e),m=e.querySelector("figcaption"),d=e.getAttribute("data-scenario-legend"),g=e.getAttribute("data-scenario-control");u.controls=go(f,e,{...t.controls,...e.getAttribute("data-fullscreen")==="true"?{fullscreen:!0}:{},...g==="slider"||g==="buttons"?{scenarioControl:g}:{},labels:{...t.controls?.labels,...p,...d?{scenario:d}:{}},mount:void 0}),m?e.insertBefore(u.controls.element,m):e.appendChild(u.controls.element)}return u}function Zh(e,t,n){const i=[];return e.forEach((s,r)=>{const o=me(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?vo(o,t):o})}),i}function vo(e,t){return e.config.markers?.length?e:{...e,config:{...e.config,markers:t.map((n,i)=>({id:`step-${i+1}`,time:n}))}}}function Qh(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 ko(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 tu(e){const t=Ge.get(e);t&&(Ei.get(e)?.(),Ei.delete(e),t.controls?.destroy(),t.player.destroy(),Ge.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function eu(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-${++Jh}`,t.setAttribute("aria-labelledby",i.id))}function nu(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const t=()=>{ko()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}class So{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 At,this.adapterB=new At}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 At;s.querySelectorAll("[data-tinyfly]").forEach(l=>{const c=l.getAttribute("data-tinyfly");c&&a.registerTarget(c,l)}),i.push({adapter:a,timeline:Nt(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?Nt(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 iu(e,t,n={}){const i=new So(e,{...n,autoplay:!0});return await i.load(t),i}const su={type:"none",duration:0};function Mo(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 Vt(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=Mo(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 Je(e,t){const n=Vt(e,t);return n[n.length-1]}function Ai(e,t){return t>0?Math.floor(Math.max(0,e)*t/1e3):0}function Ze(e,t,n){const i=t.roughness??2,s=Math.max(1,Math.round(t.passes??2)),r=Ai(n,t.boil??8);let o=0;const a=()=>{const u=o++;return p=>Fe(Zn(`${t.seed??1}:${r}:${u}:${p}`))},l=(u,p)=>(u.next()*2-1)*p,c=u=>{const p=a(),m=e.lineWidth,d=e.globalAlpha;for(let g=0;g<s;g++)e.lineWidth=g===0?m:m*.55,e.globalAlpha=g===0?d:d*.6,u(p(g));e.lineWidth=m,e.globalAlpha=d},h=(u,p=1)=>{if(u.length<2)return;const m=u.slice(1).map((g,y)=>Math.hypot(g.x-u[y].x,g.y-u[y].y)),d=m.reduce((g,y)=>g+y,0)*Math.min(1,Math.max(0,p));c(g=>{const y=[],v=[];if(u.forEach((M,k)=>{y.push({x:M.x+l(g,i*.5),y:M.y+l(g,i*.5)}),k>0&&v.push([g.next()*2-1,g.next()*2-1])}),d<=0)return;e.beginPath(),e.moveTo(y[0].x,y[0].y);let w=0;for(let M=1;M<y.length;M++){const k=ru(y[M-1],y[M],i,v[M-1]),S=m[M-1];if(w+S<=d){e.bezierCurveTo(k[1].x,k[1].y,k[2].x,k[2].y,k[3].x,k[3].y),w+=S;continue}const E=ou(k,S===0?1:(d-w)/S);e.bezierCurveTo(E[1].x,E[1].y,E[2].x,E[2].y,E[3].x,E[3].y);break}e.stroke()})},f=(u,p,m,d,g=1)=>{c(y=>{const w=y.next()*Math.PI*2,M=Math.PI*2+.15+y.next()*.3,k=[];for(let E=0;E<=14;E++){const _=w+M*E/14,T=l(y,i*.6);k.push({x:u+Math.cos(_)*(m+T),y:p+Math.sin(_)*(d+T)})}const S=Vt(k,g);S.length<2||(To(e,S),e.stroke())})};return{line:h,curve(u,p=1){if(u.length<2)return;const m=u[0],d=u[u.length-1],g=Math.hypot(d.x-m.x,d.y-m.y)||1,y=-(d.y-m.y)/g,v=(d.x-m.x)/g;c(w=>{const M={x:l(w,i*.5),y:l(w,i*.5)},k={x:l(w,i*.5),y:l(w,i*.5)},S=l(w,i*Math.min(1.5,Math.max(.3,g/80))),E=u.map((T,x)=>{const A=x/(u.length-1),P=Math.sin(Math.PI*A)*S;return{x:T.x+M.x+(k.x-M.x)*A+y*P,y:T.y+M.y+(k.y-M.y)*A+v*P}}),_=Vt(E,p);_.length<2||(To(e,_),e.stroke())})},circle(u,p,m,d=1){f(u,p,m,m,d)},ellipse:f,nudge(u=.5){const p=a()(0);return{x:l(p,i*u),y:l(p,i*u)}}}}function ru(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 ou([e,t,n,i],s){const r=(f,u)=>({x:f.x+(u.x-f.x)*s,y:f.y+(u.y-f.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 To(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 ge(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)],f=Math.hypot(h.x-c.x,h.y-c.y)||1,u=o(l)/2,p=-(h.y-c.y)/f*u,m=(h.x-c.x)/f*u;s.push({x:a.x+p,y:a.y+m}),r.push({x:a.x-p,y:a.y-m})}),[...s,...r.reverse()]}function Qe(e,t,n,i){const s=t.length;if(s<2)return;const r=ge(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 xt(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,f={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+(f.x-c.x)*i,y:c.y+(f.y-c.y)*i})}return o}function xi(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,f)=>{const u=r+Math.PI*2*o*f/a,p=Math.cos(u)*n,m=Math.sin(u)*i;return{x:e+p*l-m*c,y:t+p*c+m*l}})}function Pi(e,t){return t.look==="pencil"?hu(e,t):au(e,t.ink,t.look)}function tn(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 au(e,t,n){const i=n==="silhouette",s=i?1.25:1;return{look:n,ink:t,limb(r,o,a){e.fillStyle=t,Qe(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",tn(e,r),e.stroke())},shape(r,o,a){tn(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,f){e.beginPath(),e.ellipse(r,o,a,l,c,0,Math.PI*2),(h!==null||i)&&(e.fillStyle=i?t:h,e.fill()),!(f<=0)&&(e.strokeStyle=t,e.lineWidth=f*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 lu(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 f=h/c;n.push({x:a.x+(l.x-a.x)*f,y:a.y+(l.y-a.y)*f}),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 cu(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 Eo(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 hu(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=Ai(t.time,n.boil??8);let c=0;const h=(m,d,g=!1)=>Fe(Zn(`${t.seed}:${g?"paper":l}:${m}:${d}`)),f=(m,d,g,y,v,w=0)=>{if(m.length<2)return;const M=m.slice(1).reduce((A,P,C)=>A+Math.hypot(P.x-m[C].x,P.y-m[C].y),0);let k=lu(m,Math.max(1.5,Math.min(t.lineWidth*.8,M/24)));if(w>0&&k.length>=2){const[A,P]=[k[k.length-2],k[k.length-1]],C=Math.hypot(P.x-A.x,P.y-A.y)||1;k=[...k,{x:P.x+(P.x-A.x)/C*w,y:P.y+(P.y-A.y)/C*w}]}const S=Eo(g),E=Eo(g),_=k.length,T=[],x=[];k.forEach((A,P)=>{const C=_===1?0:P/(_-1),I=k[Math.max(0,P-1)],H=k[Math.min(_-1,P+1)],$=Math.hypot(H.x-I.x,H.y-I.y)||1,O=-(H.y-I.y)/$,L=(H.x-I.x)/$,F=S(C)*v,R=Math.min(1,C/.08,(1-C)/.08),B=(.55+.45*Math.sqrt(Math.max(0,R)))*(1+o*E(C)),D=Math.max(.3,d(C)*B/2),Z=A.x+O*F,St=A.y+L*F;T.push({x:Z+O*D,y:St+L*D}),x.push({x:Z-O*D,y:St-L*D})}),e.save(),e.globalAlpha*=y,e.fillStyle=i,tn(e,[...T,...x.reverse()],!0),e.fill(),e.restore()},u=(m,d)=>{const g=c++,y=h(g,99,!0);if(y.next()<a){const k=(y.next()*2-1)*t.lineWidth*1.4,S=(y.next()*2-1)*t.lineWidth*1.4,E=m.map(_=>({x:_.x+k,y:_.y+S}));f(E,_=>d(_)*1.8,h(g,98,!0),.035,s),f(E,_=>d(_)*.45,h(g,97,!0),.12,s*1.5)}const v=m.slice(1).reduce((k,S,E)=>k+Math.hypot(S.x-m[E].x,S.y-m[E].y),0),w=d(.5)>4&&v>d(.5)*6,M=w?[-.3,.3,0]:[0];for(let k=0;k<r;k++){const S=k===0;M.forEach((E,_)=>{const T=h(g,k*10+_),x=E===0?m:cu(m,P=>d(P)*E*Math.sqrt(Math.sin(Math.PI*P))),A=!S&&E===0?t.lineWidth*(.3+T.next()*.8):0;f(x,P=>d(P)*(w?.5:1)*(S?1:.6),T,S?.85:.45,s*(S?.6:1),A)})}},p=(m,d,g,y,v,w)=>{const k=h(c,50).next()*Math.PI*2;u(xi(m,d,g,y,v,k,1.08,48),()=>w)};return{look:"pencil",ink:i,limb(m,d,g){u(m,y=>d+(g-d)*y)},line(m,d){u(m,()=>d)},shape(m,d,g){d!==null&&(e.save(),e.globalAlpha*=.88,e.fillStyle=d,tn(e,m,!0),e.fill(),e.restore()),g>0&&u([...m,m[0]],()=>g)},ellipse(m,d,g,y,v,w,M){w!==null&&(e.save(),e.globalAlpha*=.9,e.fillStyle=w,e.beginPath(),e.ellipse(m,d,g,y,v,0,Math.PI*2),e.fill(),e.restore()),p(m,d,g,y,v,M)},dot(m,d,g){e.save(),e.globalAlpha*=.9,e.fillStyle=i,e.beginPath(),e.arc(m,d,g,0,Math.PI*2),e.fill(),e.restore()},guide(m){if(n.construction===!1||m.length<2)return;const d=c++;f(m,()=>Math.max(.6,t.lineWidth*.18),h(d,0),.28,s*1.2,t.lineWidth)},guideEllipse(m,d,g,y,v){if(n.construction===!1)return;const w=c++,M=h(w,0),k=xi(m,d,g,y,v,M.next()*Math.PI*2,1.12,48);f(k,()=>Math.max(.6,t.lineWidth*.18),M,.28,s*1.5)}}}const Ao=["thumb","index","middle","ring","pinky"],N={"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 W(e={}){return{...N,...e}}const j=(e,t,n,i,s)=>({"thumb.curl":e,"index.curl":t,"middle.curl":n,"ring.curl":i,"pinky.curl":s}),K={relaxed:N,open:W({...j(0,0,0,0,0),"thumb.across":0,spread:.55}),spread:W({...j(0,0,0,0,0),"thumb.across":0,spread:1}),flat:W({...j(0,0,0,0,0),"thumb.across":.35,spread:0}),fist:W({...j(.7,1,1,1,1),"thumb.across":.9,spread:0}),point:W({...j(.75,0,1,1,1),"thumb.across":.9,spread:0}),thumbsUp:W({...j(0,1,1,1,1),"thumb.across":0,spread:0,roll:70}),peace:W({...j(.75,0,0,1,1),"thumb.across":.9,spread:1}),ok:W({...j(.12,.6,.1,.15,.2),"thumb.across":.55,spread:.6}),pinch:W({...j(.1,.65,.75,.85,.9),"thumb.across":.55,spread:0}),cupped:W({...j(.25,.4,.4,.4,.4),"thumb.across":.4,spread:.05,turn:2}),wave:W({...j(0,.05,.05,.1,.12),"thumb.across":0,spread:.7,turn:2}),pencilGrip:W({...j(.1,.6,.72,.88,.95),"thumb.across":.5,spread:0,turn:.8,bend:10}),hold:W({...j(.5,.7,.72,.74,.76),"thumb.across":.75,spread:0,turn:1})};function Ut(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 uu={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}},fu={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}},ht={base:[-.11,.1,-.05],bones:[.2,.15,.12],widths:[.2,.145,.135],out:[-.7,.68,-.22],across:[.35,.5,-.8]},du=[82,100,62],pu=[48,72],mu=3,gu=13,yu=.035,bu=-.075,wu=[[-.17,0],[-.215,.12],[-.235,.26],[-.225,.4],[-.185,.49],[-.075,.525],[.05,.51],[.16,.465],[.215,.4],[.225,.26],[.2,.1],[.16,0]],bt=e=>e*Math.PI/180,_i=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],en=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],Ci=(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]],ye=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function wt(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=Ci(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 xo=[1,0,0],Po=[0,1,0],be=[0,0,1];function vu(e,t,n){const i=bt(e.fan*(mu+gu*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,f)=>{a+=bt(du[f]*t),o.push(_i(o[f],en(wt(s,r,-a),h)))});const l=wt(be,r,-a),c=o.map((h,f)=>e.width*(1-.14*(f/(o.length-1))));return{joints:o,back:l,widths:c}}function ku(e,t,n=1,i=1){const s=Math.min(1,Math.max(0,t)),r=ye(_i(en(ye(ht.out),1-s),en(ye(ht.across),s))),o=ye(Ci(be,r)),a=ye(Ci(r,o)),l=[[ht.base[0]*i,ht.base[1],ht.base[2]]];let c=0;ht.bones.forEach((u,p)=>{p>0&&(c+=bt(pu[p-1]*e)),l.push(_i(l[p],en(wt(r,o,c),u)))});const h=wt(a,o,c),f=[...ht.widths,ht.widths[ht.widths.length-1]*.92].map(u=>u*n);return{joints:l,back:h,widths:f}}function nn(e,t={}){const n={...N,...e},i=t.size??100,s=t.side??"right",r=s==="left"?-1:1,o=bt(t.angle??0),a=t.fingers===4,l=Math.max(.5,t.plump??1),c=1+(l-1)*.7,h=P=>({...P,knuckle:[P.knuckle[0]*c,P.knuckle[1],P.knuckle[2]],width:P.width*l}),f=bt(n.bend??0),u=bt(n.tilt??0),p=bt(90*(n.turn??0)),m=P=>wt(wt(wt(P,xo,-f),be,-u),Po,p),d=Math.cos(o),g=Math.sin(o),y=bt(n.roll??0),v=Math.cos(y),w=Math.sin(y),M=P=>{const C=P[0]*i,I=-P[1]*i,H=(C*v-I*w)*r,$=C*w+I*v;return{x:H*d-$*g,y:H*g+$*d}},k=P=>{const C=M(P),I=Math.hypot(C.x,C.y);return I>1e-6*i?{x:C.x/I,y:C.y/I}:{x:0,y:0}},S={thumb:ku(n["thumb.curl"]??0,n["thumb.across"]??0,l,c)},E=a?fu:uu;for(const P of Ao){const C=E[P];C&&(S[P]=vu(h(C),n[`${P}.curl`]??0,n.spread??0))}const _={};for(const[P,C]of Object.entries(S)){const I=C.joints.map(m),H=m(C.back);_[P]={points:I.map(M),depths:I.map($=>$[2]*i),widths:C.widths.map($=>$*i),nail:H[2],back:k(H)}}const T=wu.flatMap(([P,C])=>[m([P*c,C,yu]),m([P*c,C,bu])]),x=Su(T.map(M)),A=T.reduce((P,C)=>P+C[2],0)/T.length*i;return{size:i,side:s,wrist:{x:0,y:0},palm:x,palmDepth:A,palmFacing:-m(be)[2],fingers:_,axes:{up:k(m(Po)),across:k(m(xo)),out:k(m(be))},curls:Object.fromEntries(Object.keys(_).map(P=>[P,n[`${P}.curl`]??0]))}}function _o(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 Su(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 Mu="#f1c9a5",Tu="#2f2f33";function sn(e,t,n,i={},s=0){const r=_o(nn(n,i),t),o=i.ink??Tu,a=i.lineWidth??r.size*.035,l=i.pen??Pi(e,{look:i.look??"clean",ink:o,lineWidth:a,seed:i.seed??1,time:s,pencil:{construction:!1,...i.pencil}}),c=i.skin??Mu,h=i.nails??!0,f=[{depth:r.palmDepth,draw:()=>Eu(l,r,c,a)}];for(const u of Object.values(r.fingers)){const p=u.depths.reduce((m,d)=>m+d,0)/u.depths.length;f.push({depth:p,draw:()=>Au(e,l,u,c,a,h)})}if(i.prop){const u=i.prop;f.push({depth:u.depth,draw:()=>u.draw(l)})}e.save(),e.lineCap="round",e.lineJoin="round";for(const u of[...f].sort((p,m)=>p.depth-m.depth))u.draw();return e.restore(),r}function Eu(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},f=Math.atan2(s.y,s.x),u=Array.from({length:7},(p,m)=>{const d=f-Math.PI/2+Math.PI*m/6;return{x:h.x+Math.cos(d)*c,y:h.y+Math.sin(d)*c}});e.line(u,i*.6)}}if(t.palmFacing>.45&&e.look!=="silhouette"){const{up:s,across:r}=t.axes,o=t.size,a=t.wrist,l=(h,f)=>({x:a.x+(r.x*h+s.x*f)*o,y:a.y+(r.y*h+s.y*f)*o}),c=t.side==="left"?-1:1;e.line([l(-.15*c,.36),l(-.04*c,.3),l(.1*c,.33)],i*.5)}}function Au(e,t,n,i,s,r){const{widths:o}=n,a=xu(n.points,2),l=n.points[0],c=a[a.length-1],h=o[0],f=o[o.length-1];if(e.save(),t.look!=="silhouette"){e.beginPath(),e.rect(l.x-1e5,l.y-1e5,2e5,2e5);const d=h/2+s*1.6;e.moveTo(l.x+d,l.y),e.arc(l.x,l.y,d,0,Math.PI*2),e.clip("evenodd")}if(t.limb(a,h+2*s,f+2*s),e.restore(),t.look!=="silhouette"&&(e.fillStyle=i,Qe(e,a,h,f)),t.look==="silhouette"||!r||n.nail<.25)return;const u=a[a.length-2],p=Pu({x:c.x-u.x,y:c.y-u.y})??{x:0,y:-1},m={x:c.x-p.x*f*.22+n.back.x*f*.1,y:c.y-p.y*f*.22+n.back.y*f*.1};t.ellipse(m.x,m.y,f*.24*Math.max(.35,n.nail),f*.19,Math.atan2(p.y,p.x),"#f8e3d3",s*.45)}function xu(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 Pu=e=>{const t=Math.hypot(e.x,e.y);return t>1e-6?{x:e.x/t,y:e.y/t}:null},G={lean: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 X(e){return{...G,...e}}const Co={mouth:0,smile:0,mouthWidth:1,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0},q=e=>({...Co,...e}),tt={neutral:Co,happy:q({smile:.9,leftBrow:.2,rightBrow:.2}),joyful:q({mouth:.6,smile:1,mouthWidth:1.2,leftEye:0,rightEye:0,leftBrow:.4,rightBrow:.4}),sad:q({smile:-.8,leftEye:.8,rightEye:.8,browTilt:.9,leftBrow:-.1,rightBrow:-.1,lookY:.6}),crying:q({mouth:.45,smile:-1,leftEye:0,rightEye:0,browTilt:1,lookY:.4}),surprised:q({mouth:.7,mouthWidth:.7,leftEye:1.5,rightEye:1.5,leftBrow:1,rightBrow:1}),shocked:q({mouth:1,mouthWidth:.8,leftEye:1.6,rightEye:1.6,leftBrow:1,rightBrow:1,browTilt:.4}),angry:q({smile:-.6,mouthWidth:.9,leftEye:.8,rightEye:.8,leftBrow:-.6,rightBrow:-.6,browTilt:-1}),furious:q({mouth:.5,smile:-1,mouthWidth:1.3,leftEye:.9,rightEye:.9,leftBrow:-.9,rightBrow:-.9,browTilt:-1}),worried:q({smile:-.3,mouthWidth:.8,leftEye:1.1,rightEye:1.1,leftBrow:.3,rightBrow:.3,browTilt:.8,lookX:-.5}),scared:q({mouth:.35,smile:-.5,mouthWidth:.8,leftEye:1.45,rightEye:1.45,leftBrow:.8,rightBrow:.8,browTilt:.9}),confused:q({smile:-.2,mouthWidth:.8,leftEye:.9,rightEye:1.15,leftBrow:-.3,rightBrow:.8,lookX:.5,lookY:-.4}),skeptical:q({smile:-.1,leftEye:.6,rightEye:1,leftBrow:-.4,rightBrow:.7,lookX:.4}),thinking:q({smile:0,mouthWidth:.7,leftBrow:.3,rightBrow:.5,lookX:.6,lookY:-.8}),sleepy:q({smile:.1,leftEye:.25,rightEye:.25,leftBrow:-.3,rightBrow:-.3,lookY:.5}),disgusted:q({smile:-.7,mouthWidth:.9,leftEye:.6,rightEye:.75,leftBrow:-.5,rightBrow:-.2,browTilt:-.4,lookX:-.6}),smug:q({smile:.6,mouthWidth:.9,leftEye:.6,rightEye:.6,leftBrow:.1,rightBrow:.5,lookX:.5}),wink:q({smile:.9,leftEye:0,rightEye:1,leftBrow:-.2,rightBrow:.3})};function Ii(e,t){return{...e,...typeof t=="string"?tt[t]:t}}const Io={rest:G,wave:X({rightShoulder:135,rightElbow:30,headTilt:6,...tt.happy}),cheer:X({leftShoulder:125,leftElbow:20,rightShoulder:125,rightElbow:20,...tt.joyful}),shrug:X({leftShoulder:30,leftElbow:85,rightShoulder:30,rightElbow:85,headTilt:-10,...tt.confused,lookX:0,lookY:0}),point:X({rightShoulder:90,rightElbow:0,lean:4,smile:.4}),think:X({rightShoulder:60,rightElbow:150,headTilt:10,...tt.thinking}),handsOnHips:X({leftShoulder:45,leftElbow:-100,rightShoulder:45,rightElbow:-100,leftHip:14,rightHip:14,smile:.8}),sad:X({leftShoulder:14,rightShoulder:14,leftElbow:-4,rightElbow:-4,headTilt:-14,lean:-3,...tt.sad}),surprised:X({leftShoulder:70,leftElbow:60,rightShoulder:70,rightElbow:60,...tt.surprised}),crouch:X({stretch:.72,leftShoulder:35,rightShoulder:35,leftElbow:-50,rightElbow:-50,leftHip:22,rightHip:22,headTilt:-4}),sit:X({sit:1,turn:.5,leftShoulder:-25,rightShoulder:25,leftElbow:-55,rightElbow:55}),jump:X({stretch:1.22,leftShoulder:140,rightShoulder:140,leftElbow:20,rightElbow:20,leftHip:4,rightHip:4,...tt.joyful}),sideSplit:X({leftHip:90,rightHip:90,leftAnkle:-45,rightAnkle:-45,leftShoulder:120,rightShoulder:120,leftElbow:10,rightElbow:10,...tt.happy}),frontSplit:X({turn:1,leftHip:-90,rightHip:-90,leftAnkle:-45,rightAnkle:-45,leftShoulder:-150,rightShoulder:150,leftElbow:10,rightElbow:-10,...tt.happy})},Ho=Object.keys(G);function zt(e,t,n){const i={...e};for(const s of Ho)i[s]=e[s]+(t[s]-e[s])*n;return i}const Hi=24,$o=4,Ro=28,_u=40;function Oo(e,t=G,n=1){const i=Math.sin(e*Math.PI*2)*n,s=Math.cos(e*Math.PI*2)*n,r=c=>c<=_u,o=c=>r(c)?22*i:c,a=r(t.leftShoulder)?t.leftElbow-Ro*Math.max(0,-i):t.leftElbow,l=r(t.rightShoulder)?t.rightElbow+Ro*Math.max(0,i):t.rightElbow;return{...t,lean:t.lean+$o*n,headTilt:t.headTilt-$o*.5*n,leftElbow:a,rightElbow:l,leftHip:-Hi*i,rightHip:-Hi*i,leftKnee:-30*Math.max(0,s),rightKnee:30*Math.max(0,-s),leftShoulder:o(t.leftShoulder),rightShoulder:o(t.rightShoulder)}}function Cu(e,t=1){return 4*(($i+rn)*e)*Math.sin(Hi*t*Math.PI/180)}function Fo(e){const t=Math.abs(Math.sin(e/65)),n=.55+.45*Math.sin(e/310);return t*n}const Lo=.12,Bo=.46,Iu=1-2*Lo,Hu=.1,$u=.21,Ru=.19,$i=.24,rn=.22,Do=.12,Ou=.14,No=.33,Wo=.7,Yo=.3,Fu=.35,Lu=[1.7,1.05],Bu=[1.3,.75],Ko=[1.45,.85],Du=[1.15,.75],qo=.06,Nu=.7,Wu=.65,Xo=.075,Yu=.3,Ku=.02,qu=.012,Xu=12,Vu=.25,on=90,Uu=.25,zu=.04,Vo=.01,Pt=e=>Math.min(1,Math.max(0,e??0));function ju(e,t=1){return rn*e*t}const Ri=-.12,Uo=.4,it=e=>e*Math.PI/180,Gu=(e,t)=>({x:t*Math.sin(it(e)),y:Math.cos(it(e))}),zo=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),jo=(e,t,n,i)=>e-.3*t-n*.14*t-Math.max(0,i-1)*.12*t;function Ju(e,t,n,i,s,r){const o=Math.max(1,Math.min(r*.6,Ou*n)),a=Pt(t.turn),l=(Do+No*a)*n,c=i+Ri*n,h=l+t.lookX*.08*n,f=t.lookY*.07*n,u=[{x:-.34*n*(1-Wo*a),squeeze:1-Wo*a,open:t.leftEye,brow:t.leftBrow,side:-1},{x:.34*n*(1-Yo*a),squeeze:1-Yo*a,open:t.rightEye,brow:t.rightBrow,side:1}];e.fillStyle=s,e.strokeStyle=s,e.lineWidth=o;for(const y of u){const v=zo(y.open,t.blink);if(v<.2){const S=t.smile>.5?-.12*n:.06*n;e.beginPath(),e.moveTo(y.x+l-.12*n,c),e.quadraticCurveTo(y.x+l,c+S,y.x+l+.12*n,c),e.stroke()}else{if(v>1.2){const E=.13*n*v;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 S=v>1.2?.075*n:.1*n;e.beginPath(),e.ellipse(y.x+h,c+f,S,S*1.1*Math.min(v,1),0,0,Math.PI*2),e.fill()}const w=jo(c,n,y.brow,v),M=y.x+l-y.side*.13*n*y.squeeze,k=y.x+l+y.side*.13*n*y.squeeze;e.beginPath(),e.moveTo(k,w),e.lineTo(M,w-t.browTilt*.1*n),e.stroke()}const p=i+Uo*n,m=.25*n*Math.max(.3,t.mouthWidth)*(1-Fu*a),d=Math.min(1,Math.max(0,t.mouth));if(e.beginPath(),d<=.05){e.moveTo(l-m,p),e.quadraticCurveTo(l,p+t.smile*.25*n,l+m,p),e.stroke();return}const g=.3*n*d;t.smile>.3?(e.moveTo(l-m,p-.05*n),e.lineTo(l+m,p-.05*n),e.quadraticCurveTo(l,p+g*2,l-m,p-.05*n)):t.smile<-.3?(e.moveTo(l-m,p+g*.6),e.lineTo(l+m,p+g*.6),e.quadraticCurveTo(l,p-g*1.4,l-m,p+g*.6)):e.ellipse(l,p,m*.8,g,0,0,Math.PI*2),e.fill()}function Go(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*Lo)/2,o=t.headSize===void 0?Iu:1-2*r,a=r*n,l=Pt(e.sit),c=e.leftHip+(-on-e.leftHip)*l,h=e.leftKnee+(-on-e.leftKnee)*l,f=e.rightHip+(on-e.rightHip)*l,u=e.rightKnee+(on-e.rightKnee)*l,p=t.classic===!0,m=Pt(e.turn),d=($,O,L,F,R)=>{const B=Math.max(-Math.PI/2,Math.min(Math.PI/2,Math.abs(it(O-L)/2)+it(F))),D=Math.max(-1,Math.min(1,Nu+R)),Z=m+(1-m)*$*D;return p?{x:0,y:0}:{x:Math.cos(B)*qo*Z,y:Math.sin(B)*qo}},g={left:e.leftAnkle??0,right:e.rightAnkle??0},y={left:e.leftFootOut??0,right:e.rightFootOut??0};let v=0;if(l>0||!p){const $=(R,B,D,Z,St)=>$i*Math.cos(it(B))+rn*Math.cos(it(B-D))+Math.max(0,d(R,B,D,Z,St).y),O=Math.max($(-1,c,h,g.left,y.left),$(1,f,u,g.right,y.right)),L=1-Pt((e.rise??0)/zu),F=(p?Math.min(1,l/Uu):1)*L;v=(Bo-O)*F*n*i}const w=-Bo*n*i+v,M=-o*n*i+v,k=p?0:(Ku*Pt(e.turn)+qu*l)*n*i,S=k===0?[{x:0,y:w},{x:0,y:M}]:xt({x:0,y:w},{x:-k,y:(w+M)/2},{x:0,y:M},1,8),E=M+Hu*n*i,_=(t.shoulderWidth??0)*n*Math.cos(m*Math.PI/2),T=($,O,L,F,R)=>{const B=Gu(L,F);return{x:$+B.x*R*n,y:O+B.y*R*n}},x=($,O,L)=>{const F=T(0,w,O,$,$i*i);return{root:{x:0,y:w},joint:F,end:T(F.x,F.y,O-L,$,rn*i)}},A=($,O,L)=>{const F={x:$*_,y:E},R=T(F.x,F.y,O,$,$u*s);return{root:F,joint:R,end:T(R.x,R.y,O+L,$,Ru*s)}},P={left:x(-1,c,h),right:x(1,f,u)},C=($,O,L,F,R,B)=>{const D=d($,L,F,R,B);return{x:O.end.x+D.x*n*i,y:O.end.y+D.y*n*i}},I=($,O,L,F,R)=>T(O.end.x,O.end.y,L+F+R,$,Xo*s),H={left:A(-1,e.leftShoulder,e.leftElbow),right:A(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(p?0:Yu,t.rubber??0)),r:a,headRx:a/Math.sqrt(i),headRy:a*Math.sqrt(i),hipY:w,neckY:M,drop:v,lean:p?e.lean:e.lean+Xu*Math.sin(Math.PI*l),classic:p,legs:P,toes:{left:C(-1,P.left,c,h,g.left,y.left),right:C(1,P.right,f,u,g.right,y.right)},spine:S,arms:H,handTips:{left:I(-1,H.left,e.leftShoulder,e.leftElbow,e.leftWrist??0),right:I(1,H.right,e.rightShoulder,e.rightElbow,e.rightWrist??0)}}}const we=(e,t)=>t===0?[e.root,e.joint,e.end]:xt(e.root,e.joint,e.end,t);function an(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 Jo(e,t,n=!0){const i=Qu(e,t),s=t.spin??0,r=t.rise??0;return n&&(s!==0||r!==0)?Zu(i,e,s,r):i}function Zo(e,t,n){return{pivot:{x:0,y:e.hipY},angle:e.facing*it(t),lift:n*e.height}}function Zu(e,t,n,i){const{pivot:s,angle:r,lift:o}=Zo(t,n,i),a=u=>{const p=an(u,s,r);return{x:p.x,y:p.y-o}},l=u=>({left:a(u.left),right:a(u.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),f=Vo*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-f,right:c.right>=h-f},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 Qu(e,t){const n=it(e.lean),i=it(t.headTilt),s={x:0,y:e.hipY},r=w=>({x:e.facing*w.x,y:w.y}),o=w=>r(an(w,s,n)),a=w=>o(an({x:w.x,y:w.y+e.neckY},{x:0,y:e.neckY},i)),l=we(e.arms.left,e.rubber).map(o),c=we(e.arms.right,e.rubber).map(o),h=(w,M)=>Math.atan2(M.y-w.y,M.x-w.x),f={left:o(e.handTips.left),right:o(e.handTips.right)},u=(w,M)=>{const[k,S]=w.slice(-2),E=e.arms[M],_=h(o(E.end),f[M])-h(o(E.joint),o(E.end));return h(k,S)+_};let p=1/0;for(const[w,M]of[[t.leftBrow,t.leftEye],[t.rightBrow,t.rightEye]]){const k=jo(Ri,1,w,zo(M,t.blink));p=Math.min(p,k,k-t.browTilt*.1)}const m={left:r(e.legs.left.end),right:r(e.legs.right.end)},d={left:r(e.toes.left),right:r(e.toes.right)},g={left:Math.max(m.left.y,d.left.y),right:Math.max(m.right.y,d.right.y)},y=Math.max(g.left,g.right),v=Vo*e.height;return{facing:e.facing,height:e.height,stretch:e.stretch,lineWidth:e.lineWidth,hip:s,neck:o({x:0,y:e.neckY}),shoulders:{left:o(e.arms.left.root),right:o(e.arms.right.root)},elbows:{left:o(e.arms.left.joint),right:o(e.arms.right.joint)},hands:{left:o(e.arms.left.end),right:o(e.arms.right.end)},knees:{left:r(e.legs.left.joint),right:r(e.legs.right.joint)},feet:m,toes:d,feetY:y,grounded:{left:g.left>=y-v,right:g.right>=y-v},fingertips:f,handAngle:{left:u(l,"left"),right:u(c,"right")},limbs:{leftArm:l,rightArm:c,leftLeg:we(e.legs.left,e.rubber).map(r),rightLeg:we(e.legs.right,e.rubber).map(r),spine:e.spine.map(o)},head:{center:a({x:0,y:-e.headRy}),rx:e.headRx,ry:e.headRy,angle:e.facing*(n+i),eyeY:Ri,browTopY:p,mouthY:Uo,faceX:e.facing*(Do+No*Pt(t.turn))}}}function Qo(e,t={}){return Jo(Go(e,t),e)}function tf(e,t,n){return an({x:e.center.x+t*e.rx,y:e.center.y+n*e.ry},e.center,e.angle)}function ta(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 ea(e,t,n={},i=0){const s=Go(t,n),r=n.color??"#1e293b",o=n.layers??{},a=n.layers?Jo(s,t,!1):void 0,l=n.sketch?Ze(e,n.sketch,i):void 0,c=n.sketch&&n.layers?Ze(e,n.sketch,i):void 0,h=S=>{e.save(),S(),e.restore()},f=S=>{S&&a&&h(()=>S(e,a,i,c))},u=()=>e.scale(s.facing,1),p=()=>{u(),e.translate(0,s.hipY),e.rotate(it(s.lean)),e.translate(0,-s.hipY)},m=(S,E,_)=>{if(l)return E?l.curve(S):l.line(S);if(s.classic){e.beginPath(),e.moveTo(S[0].x,S[0].y);for(const T of S.slice(1))e.lineTo(T.x,T.y);e.stroke();return}Qe(e,S,_[0]*s.lineWidth,_[1]*s.lineWidth)},d=(S,E)=>m(we(S,s.rubber),s.rubber>0,E),g=S=>{s.classic||m([s.legs[S].end,s.toes[S]],!1,Du)},y=S=>{if(n.hands&&!s.classic)return w(S);if(s.classic||l)return;const E=s.arms[S].end;e.beginPath(),e.arc(E.x,E.y,Wu*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=Zo(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 w(S){const E=n.hands??{},_=s.arms[S].end,T=s.handTips[S],x=n.headFill??"#ffffff";sn(e,_,E[S]??N,{side:S,angle:Math.atan2(T.x-_.x,_.y-T.y)*180/Math.PI,size:(E.size??Xo)*s.height*Math.sqrt(s.stretch),skin:E.skin??(x==="none"?void 0:x),ink:r,lineWidth:s.lineWidth*.45,fingers:E.fingers,plump:E.plump,look:n.sketch?"pencil":"clean",seed:n.sketch?.seed},i)}const M=S=>{h(()=>{p(),d(s.arms[S],Bu),y(S)});const E=o.sleeve;E&&a&&h(()=>E(e,a,S,i,c))},k=Pt(t.turn)>Vu;f(o.behind),h(()=>{u(),d(s.legs.left,Ko),g("left"),d(s.legs.right,Ko),g("right")}),k&&M("left"),h(()=>{p(),m(s.spine,s.spine.length>2,Lu);const{left:S,right:E}={left:s.arms.left.root,right:s.arms.right.root};if(S.x!==E.x)if(s.classic)m([S,E],!1,[1,1]);else{const _={x:(S.x+E.x)/2,y:S.y-.3*Math.abs(E.x-S.x)};m(xt(S,_,E,1,8),!0,[1.1,1.1])}}),f(o.body),k||M("left"),M("right"),f(o.behindHead),h(()=>{p(),e.translate(0,s.neckY),e.rotate(it(t.headTilt));const S=-s.headRy;e.beginPath(),e.ellipse(0,S,s.headRx,s.headRy,0,0,Math.PI*2);const E=n.headFill??"#ffffff";if(E!=="none"&&(e.fillStyle=E,e.fill()),l){l.ellipse(0,S,s.headRx,s.headRy);const _=l.nudge();e.translate(_.x,_.y)}else e.stroke();e.translate(0,S),e.scale(s.headRx/s.r,s.headRy/s.r),Ju(e,t,s.r,0,r,s.lineWidth)}),f(o.overHead),f(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 Oi(e,t,n){const i={...e};let s=e.walking>0?zt(i,Oo(e.walk,i),e.walking):i,r=ef(e);const o=e.dancing??0;if(n&&o>0){const a=n(e.beat??0);if(s=zt(s,a.pose,o),a.hands){const l=(c,h)=>h?Ut(c??N,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*Fo(t))}),{pose:s,hands:r}}function na(e,t,n){return Oi(e,t,n).pose}const ve=(e,t)=>`hand.${e}.${t}`;function ef(e){const t=s=>{if(typeof e[ve(s,"spread")]=="number")return Object.fromEntries(Object.keys(N).map(r=>[r,e[ve(s,r)]]))},n=t("left"),i=t("right");return n||i?{left:n,right:i}:void 0}function nf(e,t){return!t||!e.hands?e:{...e,hands:{...e.hands,left:t.left??e.hands.left,right:t.right??e.hands.right}}}function sf(e){const t=e.style??{},n=t.height??300,i=n*.8,s={...X(e.pose??{}),walk:0,walking:0,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]??N;for(const l of Object.keys(N))r[ve(o,l)]=a[l]??N[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=Oi(c,l,e.dance);o.translate(i/2,n),ea(o,h.pose,nf({...t,rubber:c.rubber},h.hands),l)}}}function rf(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)??[])typeof h=="number"&&(c==="x"||c==="motionPathX"?r=h:c==="y"||c==="motionPathY"?o=h:c in s&&(s[c]=h));const a=na(s,t.time,e.figureDance),l=Qo(a,{...i,rubber:s.rubber});return{pose:a,joints:ta(l,e.x+r+e.width/2,e.y+o+e.height)}}function of(e,t){const n=[];return t.forEach((i,s)=>{const r=s===0?G:n[s-1],o=typeof i.pose=="string"?Io[i.pose]:{...r,...i.pose};n.push(i.expression?Ii(o,i.expression):o)}),Ho.filter(i=>n.some(s=>s[i]!==G[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 Fi=.5,Li={pataka:W({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:0,turn:2}),tripataka:W({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":1,"pinky.curl":0,spread:0,turn:2}),alapadma:W({"thumb.curl":.1,"thumb.across":0,"index.curl":.05,"middle.curl":.15,"ring.curl":.25,"pinky.curl":.35,spread:1,turn:2}),mushti:K.fist,shikhara:K.thumbsUp,hamsasya:W({"thumb.curl":.15,"thumb.across":.6,"index.curl":.6,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:.7,turn:2}),katakamukha:W({"thumb.curl":.2,"thumb.across":.6,"index.curl":.65,"middle.curl":.7,"ring.curl":0,"pinky.curl":0,spread:.4,turn:2})};function ln(e){return typeof e!="string"?e:e in Li?Li[e]:K[e]}function ia(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?ln(s.hands.left):o.left,right:s.hands?.right?ln(s.hands.right):o.right,easing:s.easing??e.easing})}return i}const Bi=(e,t)=>(e%t+t)%t;function af(e,t,n,i){const s=ia(e,n,i);if(s.length===0)return{pose:n,hands:i};const r=Bi(t,e.beats);let o=s.length-1;for(let p=0;p<s.length;p++)s[p].beat<=r&&(o=p);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,f=h>c?(r-c)/(h-c):0,u=V(l.easing??"ease-in-out")(Math.min(1,Math.max(0,f)));return{pose:zt(a.pose,l.pose,u),hands:{left:Ut(a.left,l.left,u),right:Ut(a.right,l.right,u)}}}const lf=[["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"],["leftFootOut","rightFootOut"],["leftEye","rightEye"],["leftBrow","rightBrow"]],cf=["lean","headTilt","lookX","spin"],hf=new Set(["leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee"]);function sa(e){const t={...e},n=(e.turn??0)>=.5;for(const[i,s]of lf){const r=n&&hf.has(i)?-1:1;t[i]=r*e[s],t[s]=r*e[i]}if(!n)for(const i of cf)t[i]=-e[i];return t}const uf=e=>Math.min(1,Math.max(-1,(.5-e)*4));function ra(e,t,n){const i=Bi(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=uf(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 cn(e){const t={...G,...e.stance};return e.expression?Ii(t,e.expression):t}function oa(e){return{left:e.hands?.left?ln(e.hands.left):N,right:e.hands?.right?ln(e.hands.right):N}}function Di(e,t,n){const i=e.moves[t.move];if(!i)throw new Error(`dance: "${e.label}" has no move "${t.move}"`);const s=af(i,n,cn(e),oa(e));return t.mirror?{pose:sa(s.pose),hands:{left:s.hands?.right,right:s.hands?.left}}:s}function hn(e,t,n={}){const i=typeof e=="string"?_t[e]:e;let s;if(n.move)s=Di(i,{move:n.move,mirror:n.mirror},t);else{const r=i.routine,o=r.reduce((f,u)=>f+u.beats,0),a=Bi(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=Di(i,r[c],h),h<Fi&&r.length>1&&t>=Fi){const f=r[(c-1+r.length)%r.length],u=Di(i,f,f.beats+h),p=V("ease-in-out")(h/Fi);s={pose:zt(u.pose,s.pose,p),hands:{left:Ut(u.hands.left,s.hands.left,p),right:Ut(u.hands.right,s.hands.right,p)}}}}return{...s,pose:ra(s.pose,i.groove,t)}}function ff(e,t,n={}){return hn(e,t,n).pose}function un(e){return(typeof e=="string"?_t[e]:e).routine.reduce((n,i)=>n+i.beats,0)}const df={leftToe:"rightToe",rightToe:"leftToe",leftHeel:"rightHeel",rightHeel:"leftHeel"};function aa(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 f of l.taps??[])s.push({beat:h,tap:i?df[f]:f})}}function pf(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;aa(o,a,Math.ceil((n-a)/o.beats)*o.beats,i.mirror,r,t,n)}else{const o=un(s);for(let a=Math.floor(t/o)*o;a<n;a+=o){let l=a;for(const c of s.routine)aa(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?(ia(n,cn(e),oa(e))[0]?.pose.turn??cn(e).turn??0)>=.5?i:-i:i}function ca(e,t){return t.move?[{move:t.move,beats:e.moves[t.move].beats,mirror:t.mirror}]:e.routine}function fn(e,t,n={}){const i=typeof e=="string"?_t[e]:e,s=ca(i,n),r=s.reduce((h,f)=>h+f.beats,0),o=s.reduce((h,f)=>h+la(i,f)*f.beats,0),a=Math.floor(t/r);let l=a*o,c=t-a*r;for(const h of s){const f=Math.min(h.beats,c);if(l+=la(i,h)*f,c-=f,c<=0)break}return l}function mf(e,t,n){const i=ca(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 gf=8;function ha(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:un(i)),o=mf(i,r,n);if(o.every(y=>fn(i,y,n)===0))return;const a=Math.min(n.fade??1,r/2),l=V("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*gf),f=a<=0?[]:Array.from({length:h+1},(y,v)=>[v/h*a,r-v/h*a]).flat(),u=[...new Set([...o,...f])].sort((y,v)=>y-v);let p=0;const m=u.map((y,v)=>{if(v>0){const w=u[v-1],M=Math.max(1,Math.ceil((y-w)*16));for(let k=0;k<M;k++){const S=w+(y-w)*k/M,E=w+(y-w)*(k+1)/M;p+=(fn(i,E,n)-fn(i,S,n))*c((S+E)/2)}}return{beat:y,travel:p}}),d=n.start??0,g=n.x??0;return{id:`${e}-x`,target:e,property:"x",keyframes:m.map(y=>({time:d+y.beat*6e4/s,value:g+n.height*y.travel,easing:"linear"}))}}function yf(e,t,n=0){return(e-n)*t/6e4}function bf(e,t={}){return n=>hn(e,n,t)}function wf(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 vf(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:un(i)),o=n.samplesPerBeat??4,a=n.start??0,l=Math.round(r*o),c=Array.from({length:l+1},(d,g)=>{const y=g/o;return{time:a+y*6e4/s,frame:hn(i,y,n)}}),h=(d,g)=>({id:`${e}-${d}`,target:e,property:d,keyframes:c.map(y=>({time:y.time,value:g(y.frame)}))}),u=Object.keys(G).filter(d=>c.some(g=>g.frame.pose[d]!==c[0].frame.pose[d])||c[0].frame.pose[d]!==G[d]).map(d=>h(d,g=>g.pose[d])),p=n.height===void 0?void 0:ha(e,i,{...n,bpm:s,beats:r,start:a,height:n.height,fade:0});if(p&&u.push(p),n.hands===!1)return u;const m=[];for(const d of["left","right"])for(const g of Object.keys(N)){const y=v=>v.hands?.[d]?.[g]??N[g];c.some(v=>y(v.frame)!==N[g])&&m.push(h(ve(d,g),y))}return[...u,...m]}const ke={type:"back",mode:"out",overshoot:1.1},U="ease-out-cubic",kf={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:U,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:U},{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:U},{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}]},Sf={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}]},Mf={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:U},{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:U},{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:U},{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:ke},{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}]},Tf={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:{...K.spread,turn:2},right:{...K.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:U},{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}]},Ef={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:ke,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:ke},{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:ke},{beat:3,pose:{headTilt:4}}]},isolations:{label:"Isolations",beats:2,easing:U,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}]},Af={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:{...K.cupped,roll:-30},left:{...K.flat,turn:0}}},{beat:.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...K.cupped,roll:30}}},{beat:1,pose:{rightWrist:-15,rightElbow:12,leftWrist:-45,lean:-4,rightHip:16,leftHip:6},hands:{right:{...K.cupped,roll:-30}}},{beat:1.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...K.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:{...K.open,turn:2}},easing:U},{beat:.5,pose:{lean:-4,rightHip:12,headTilt:6}},{beat:1,pose:{lean:-11,rightHip:22,headTilt:10},easing:U},{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:U},{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:U}]}},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}]},xf={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}]},Pf={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}]},_f={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:{...K.spread,turn:2},right:{...K.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:U},{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:U},{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}]},Cf={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:{...K.spread,turn:2},right:{...K.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:kf,hipHop:Sf,breaking:Mf,jazz:Tf,kpop:Ef,bollywood:Af,bhangra:xf,bharatanatyam:Pf,charleston:_f,tap:Cf,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:ke},{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}]}},dn=e=>Math.min(1,Math.max(0,e));function If(e){const t={...G,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 Hf(e){return e-$f*Math.sin(2*Math.PI*e)/(2*Math.PI)}const $f=.5;function Rf(e,t){if(!(t<=e.takeoff||t>=e.landing))return(t-e.takeoff)/(e.landing-e.takeoff)}function ua(e,t){const n=typeof e=="string"?mn[e]:e,i=If(n),s=dn(t);let r=0;for(let f=0;f<i.length;f++)i[f].at<=s&&(r=f);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=zt(o.pose,a.pose,V(a.easing??"ease-in-out")(dn(l))),h=Rf(n,s);return h===void 0?{...c,spin:0,rise:0}:{...c,spin:n.spin*Hf(h),rise:4*n.height*h*(1-h)}}function fa(e,t,n){const i=typeof e=="string"?mn[e]:e,s=dn(t),r=dn((s-i.takeoff)/(i.landing-i.takeoff));return i.travel*n*r}function Of(e,t,n={}){const i=typeof t=="string"?mn[t]:t,s=n.start??0,r=n.duration??i.duration,o=n.samples??48,a=Array.from({length:o+1},(h,f)=>{const u=f/o;return{time:s+u*r,progress:u,pose:ua(i,u)}}),c=Object.keys(G).filter(h=>a.some(f=>f.pose[h]!==G[h])).map(h=>({id:`${e}-${h}`,target:e,property:h,keyframes:a.map(f=>({time:f.time,value:f.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(f=>({time:f.time,value:(n.x??0)+h*fa(i,f.progress,n.height)}))})}return c}const Ff={leftHip:-55,leftKnee:-95,rightHip:55,rightKnee:95,leftShoulder:45,rightShoulder:-45,leftElbow:10,rightElbow:-10,lean:22,stretch:.94,headTilt:6},Lf={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},pn={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},Bf={leftHip:-22,leftKnee:-30,rightHip:22,rightKnee:30,leftAnkle:10,rightAnkle:10,leftShoulder:-125,rightShoulder:125,leftElbow:0,rightElbow:0,lean:8,headTilt:0},Df={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 jt(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:Ff},{at:.27,pose:Lf,easing:"ease-out-quad"},...s,{at:.76,pose:Bf},{at:.86,pose:Df,easing:"ease-out-quad"},{at:1,reset:!0}]}}const mn={frontFlip:jt("Front flip (tuck)",360,.56,.35,[{at:.38,pose:pn,easing:"ease-out-cubic"},{at:.64,pose:pn}]),backFlip:jt("Back flip (tuck)",-360,.58,-.15,[{at:.36,pose:{...pn,lean:18},easing:"ease-out-cubic"},{at:.64,pose:{...pn,lean:18}}]),layout:jt("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:jt("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:jt("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:jt("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)},Ni=.215,Wi=.205,Nf=.065,da=.035,Wf=.165,Yf=.155,Kf=12,qf=e=>e*Math.PI/180,J={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 et(e={}){return{...J,...e}}const Xf=new Set(["turn","side","head.turn","head.tilt","roll","lookX"]);function Vf(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]=Xf.has(n)?-i:i}return t}function nt(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 pa={rest:J,wave:et({"arm.right.spread":115,"arm.right.bend":55,"arm.right.elbow":0,"head.tilt":-6,smile:.9}),cheer:et({...nt("arm",{spread:140,bend:20,elbow:0}),mouth:.6,smile:1,"eye.left":0,"eye.right":0}),point:et({"arm.right.spread":88,"arm.right.elbow":0,"arm.right.bend":0,"head.turn":-20,smile:.4}),handsOnHips:et({...nt("arm",{spread:50,bend:-105,elbow:0}),...nt("leg",{spread:9}),smile:.8}),think:et({"arm.right.spread":22,"arm.right.bend":-150,"arm.right.elbow":0,"head.tilt":10,lookX:-.5,lookY:-.8,smile:0}),shrug:et({...nt("arm",{spread:35,bend:75,elbow:0}),"head.tilt":-10,smile:-.2}),sit:et({...nt("leg",{swing:90,knee:90,spread:4}),...nt("arm",{swing:25,elbow:45,spread:8})}),kneel:et({"leg.left.swing":90,"leg.left.knee":90,"leg.right.swing":-18,"leg.right.knee":108,"leg.right.ankle":16,...nt("arm",{swing:20,elbow:30})}),crouch:et({...nt("leg",{swing:75,knee:140,spread:6}),lean:25,...nt("arm",{swing:50,elbow:40}),"head.nod":-15}),crawl:et({lean:82,"head.nod":-35,...nt("arm",{swing:80,elbow:0,spread:4}),...nt("leg",{knee:92,ankle:-88})}),lieDown:et({roll:90,...nt("arm",{spread:8}),"head.nod":0})};function ma(e={}){const t=e.headSize??.3,n=e.shoulderWidth??.06,i=e.hipWidth??.022,s=Math.max(.12,1-t-da-(Ni+Wi)),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:Wf,width:[1.25,.9]},{length:Yf,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:Ni,width:[1.45,1.05]},{length:Wi,width:[1.05,.85]},{length:Nf,width:[.95,.7]}]}),a=(l,c)=>l[c]??J[c]??0;return{id:"human",hipHeight:Ni+Wi,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:da,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 d=-a(l,"lean")/2,g=a(l,"side")/2;return[{swing:d,spread:g},{swing:d,spread:g}]}if(c.id==="neck")return[{swing:0,spread:0}];const[h,f]=c.id.split("."),u=d=>a(l,`${h}.${f}.${d}`);if(h==="arm")return[{swing:u("swing"),spread:u("spread")},{swing:u("elbow"),spread:u("bend")}];const p=(c.side??1)*u("rotate"),m=1-Math.cos(qf(u("rotate")));return[{swing:u("swing"),spread:u("spread"),yaw:p},{swing:-u("knee"),spread:0,yaw:p},{swing:90+u("ankle")-m*(u("swing")-u("knee")),spread:0,yaw:(Kf+u("toeOut"))*(c.side??1)}]},withAngles(l,c,h){const[f,u]=c.id.split("."),p=m=>`${f}.${u}.${m}`;return f==="arm"?{...l,[p("swing")]:h[0].swing,[p("spread")]:h[0].spread,[p("elbow")]:h[1].swing,[p("bend")]:h[1].spread}:f==="leg"?{...l,[p("swing")]:h[0].swing,[p("spread")]:h[0].spread,[p("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 Uf(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 zf={leftEye:"eye.left",rightEye:"eye.right",leftBrow:"brow.left",rightBrow:"brow.right"},jf=Object.fromEntries(Object.entries(tt).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([n,i])=>[zf[n]??n,i]))]));function Gf(e,t){const n=Math.min(1,Math.max(0,e.turn??0)),i=1-n,s={...J,turn:n},r=[{stick:"right",human:"left",s:1},{stick:"left",human:"right",s:-1}];for(const{stick:o,human:a,s:l}of r){const c=e[`${o}Shoulder`],h=e[`${o}Elbow`];s[`arm.${a}.spread`]=c*i,s[`arm.${a}.swing`]=l*c*n,s[`arm.${a}.bend`]=h*i,s[`arm.${a}.elbow`]=l*h*n;const f=e[`${o}Hip`],u=e[`${o}Knee`],p=i+l*n;s[`leg.${a}.rotate`]=90*i,s[`leg.${a}.spread`]=0,s[`leg.${a}.swing`]=f*p,s[`leg.${a}.knee`]=u*p,s[`leg.${a}.ankle`]=-(e[`${o}Ankle`]??0),s[`leg.${a}.toeOut`]=(e[`${o}FootOut`]??0)*Jf,s[`eye.${a}`]=e[`${o}Eye`],s[`brow.${a}`]=e[`${o}Brow`],t&&Object.assign(s,Zf(a,t[o]??N,e[`${o}Wrist`]??0,n))}s.lean=e.lean*n,s.side=e.lean*i,s["head.tilt"]=e.headTilt*i,s["head.nod"]=e.headTilt*n;for(const o of["mouth","smile","mouthWidth","blink","browTilt","lookX","lookY","stretch"])s[o]=e[o];return s.lift=e.rise??0,s.roll=e.spin??0,s}const Jf=70;function Zf(e,t,n,i){const s=e==="right"?1-i:1+i,r={};for(const o of Object.keys(N))r[`hand.${e}.${o}`]=t[o]??N[o];return r[`hand.${e}.turn`]=(t.turn??0)-s,r[`hand.${e}.roll`]=(t.roll??0)+n,r}const st=e=>e*Math.PI/180;function ga([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e,t*s+n*r,-t*r+n*s]}function Yi([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s-t*r,e*r+t*s,n]}function Ct([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s+n*r,t,-e*r+n*s]}const vt=(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],yn=(e,t)=>Yi(ga(e,t.swing),t.spread);function Ki(e,t){const n=Ct(e,t);return{point:{x:n[0],y:-n[1]},depth:n[2]}}function bn(e,t,n){const i=n,r=[0,e.hipHeight*i*(e.boneScale?.(t,null)??1),0],o={};for(const d of e.chains){const g=d.parent?o[d.parent]:void 0;if(d.parent&&!g)throw new Error(`body plan ${e.id}: chain ${d.id} comes before its parent ${d.parent}`);const y=d.at??(g?g.joints3.length-1:0),v=g?g.joints3[y]:r,w=g?g.frames[Math.max(0,y-1)]:{swing:0,spread:0},M=d.offset?vt(v,yn(gn(d.offset,i),w)):v,k=d.side??1,S=e.boneScale?.(t,d)??1,E=e.angles(t,d),_=[M],T=[];let x=w.swing,A=w.spread;d.bones.forEach((P,C)=>{const I=E[C]??{swing:0,spread:0};x+=st(I.swing),A+=st(I.spread)*k,T.push({swing:x,spread:A});const H=Ct(yn(d.rest,{swing:x,spread:A}),st(I.yaw??0));_.push(vt(_[C],gn(H,P.length*i*S)))}),o[d.id]={joints3:_,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,f=h*l.sx,u=h*l.sy,p=d=>yn(Ct(ga(Yi(d,-st(l.tilt)),-st(l.nod)),st(l.yaw)),c),m=vt(a.joints3[a.joints3.length-1],p([0,u,0]));return{height:i,root:r,chains:o,head:{center:m,rx:f,ry:u,toBody:p}}}function qi(e,t,n){const i=n.height,s=st(90*(t.turn??0)),r=bn(e,t,i),{root:o}=r,a=r.chains,{rx:l,ry:c}=r.head,h=r.head.toBody,f=r.head.center,u={};for(const T of e.chains){const{joints3:x,frames:A}=a[T.id],P=x.map(C=>Ki(C,s));u[T.id]={id:T.id,joints3:x,frames:A,points:P.map(C=>C.point),depths:P.map(C=>C.depth)}}const p=Ki(f,s),m=[[1,0,0],[0,1,0],[0,0,1]].map(T=>Ct(h(T),s)),d=Ki(o,s).point,g=st(t.roll??0),y=T=>{const x=T.x-d.x,A=T.y-d.y;return{x:d.x+x*Math.cos(g)-A*Math.sin(g),y:d.y+x*Math.sin(g)+A*Math.cos(g)}},v=([T,x,A])=>[T*Math.cos(g)+x*Math.sin(g),-T*Math.sin(g)+x*Math.cos(g),A];for(const T of Object.values(u))T.points=T.points.map(y);const w={center:y(p.point),depth:p.depth,rx:l,ry:c,angle:0,axes:m.map(v)},M=w.axes[1];w.angle=Math.atan2(M[0],M[1]);const k=T=>{if("head"in T)return{x:w.center.x+M[0]*c,y:w.center.y-M[1]*c};const x=u[T.chain];return x.points[Math.min(T.joint,x.points.length-1)]};let S=0;(n.contact??"ground")==="ground"&&(S=-Math.max(...e.contacts.map(T=>k(T).y))),S-=(t.lift??0)*i;const E=T=>({x:T.x,y:T.y+S});for(const T of Object.values(u))T.points=T.points.map(E);w.center=E(w.center);const _=e.contacts.map(T=>({spec:T,point:k(T)}));return{height:i,view:s,chains:u,head:w,hip:E(y(d)),contacts:_,groundY:Math.max(..._.map(T=>T.point.y))}}const Xi=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],ya=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function Vi(e,t,n){const i=n.height,s=st(90*(t.turn??0)),r=st(t.roll??0),o=bn(e,t,i),a=Ct(o.root,s),l=g=>vt(Yi(Xi(Ct(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),f=g=>ya(Xi(l(vt(o.head.center,o.head.toBody(g))),h)),u=[f([1,0,0]),f([0,1,0]),f([0,0,1])],p=g=>{if("head"in g)return vt(h,gn(u[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=>p(g)[1]))),m+=(t.lift??0)*i;const d=g=>[g[0],g[1]+m,g[2]];return{height:i,hip:d(a),chains:Object.fromEntries(Object.entries(c).map(([g,y])=>[g,y.map(d)])),head:{center:d(h),rx:o.head.rx,ry:o.head.ry,axes:u}}}function Ui(e,t,n,i){const s=n.height,r=st(90*(t.turn??0)),o=bn(e,t,s),a=Vi(e,t,n),l=a.hip,c=a.chains,h=a.head.center,f=T=>{if("head"in T)return vt(h,gn(a.head.axes[1],a.head.ry));const x=c[T.chain];return x[Math.min(T.joint,x.length-1)]},u=i.toView(l),p=i.toScreen(u),m=i.toScreen([u[0]+1,u[1],u[2]]),d=Math.hypot(m.x-p.x,m.y-p.y),g=T=>{const x=i.toView(T);return{point:i.toScreen(x),depth:x[2]*d}},y={};for(const T of e.chains){const x=c[T.id].map(g);y[T.id]={id:T.id,joints3:o.chains[T.id].joints3,frames:o.chains[T.id].frames,points:x.map(A=>A.point),depths:x.map(A=>A.depth)}}const v=i.toView(h),w=i.toScreen(v),M=i.toScreen([v[0]+1,v[1],v[2]]),k=Math.hypot(M.x-w.x,M.y-w.y),S=a.head.axes.map(T=>ya(Xi(i.toView(vt(h,T)),v))),E={center:w,depth:v[2]*d,rx:o.head.rx*k,ry:o.head.ry*k,angle:Math.atan2(S[1][0],S[1][1]),axes:S},_=e.contacts.map(T=>({spec:T,point:g(f(T)).point}));return{height:s*d,view:r,chains:y,head:E,hip:p,contacts:_,groundY:Math.max(..._.map(T=>T.point.y))}}function ba(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 wa{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 Qf(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 zi=Math.PI*2;function td(e,t=16){const n=new wa,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*zi,f=Math.sin(a)*Math.sin(h),u=Math.cos(a),p=Math.sin(a)*Math.cos(h);l.push(n.vertex(f*e,u*e,p*e,f,u,p))}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],f=r[o][a+1];o>0&&n.triangle(l,c,f),o<s-1&&n.triangle(c,h,f)}return n.build()}function va(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*zi;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 ed(e,t,n=24){const i=new wa,s=Math.max(6,Math.round(n)),r=t/2,o=-t/2,a=h=>Array.from({length:s+1},(f,u)=>{const p=u/s*zi;return i.vertex(Math.sin(p)*e,h,Math.cos(p)*e,Math.sin(p),0,Math.cos(p))}),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 va(i,e,r,1,s),va(i,e,o,-1,s),i.build()}function ka(e){const t=Array.from({length:e.indices.length/3},()=>[]);for(const n of Qf(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 wn=e=>e*180/Math.PI,Gt=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],ji=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Se=e=>Math.hypot(e[0],e[1],e[2]),Gi=e=>{const t=Se(e)||1;return[e[0]/t,e[1]/t,e[2]/t]},vn=e=>Math.atan2(Math.sin(e),Math.cos(e));function Sa(e){const[t,n,i]=Gi(e);return{swing:Math.asin(Math.max(-1,Math.min(1,i))),spread:Math.atan2(t,-n)}}function nd(e,t,n,i,s){const r=e.chains.find(x=>x.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=qi(e,{...t,turn:0,roll:0,lift:0},{height:s.height,contact:"none"}),a=o.chains[n],l=a.joints3[0],c=Se(Gt(a.joints3[1],a.joints3[0])),h=Se(Gt(a.joints3[2],a.joints3[1])),f=r.parent?o.chains[r.parent].frames[Math.max(0,(r.at??o.chains[r.parent].joints3.length-1)-1)]:{swing:0,spread:0},u=Gt(i,l),p=Math.min(c+h-1e-6,Math.max(Math.abs(c-h)+1e-6,Se(u))),m=Gi(u),d=r.parent!==null,g=yn(r.pole??(d?[0,-.35,-1]:[0,0,1]),f);let y=Gt(g,[m[0]*ji(g,m),m[1]*ji(g,m),m[2]*ji(g,m)]);Se(y)<1e-6&&(y=Ct([1,0,0],0)),y=Gi(y);const v=(c*c+p*p-h*h)/(2*c*p),w=Math.sqrt(Math.max(0,1-v*v)),M=[l[0]+c*(v*m[0]+w*y[0]),l[1]+c*(v*m[1]+w*y[1]),l[2]+c*(v*m[2]+w*y[2])],k=[l[0]+m[0]*p,l[1]+m[1]*p,l[2]+m[2]*p],S=r.side??1,E=Sa(Gt(M,l)),_=Sa(Gt(k,M)),T=[{swing:wn(vn(E.swing-f.swing)),spread:wn(vn(E.spread-f.spread))*S},{swing:wn(vn(_.swing-E.swing)),spread:wn(vn(_.spread-E.spread))*S}];return e.withAngles(t,r,T)}const id=.34,kt=.12,ct=-.4,ut=(e,t,n)=>e[t]??n,sd=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),rd=.45,od=.35,ad=.7;function kn(e,t,n){const i=p=>Math.sqrt(Math.max(0,1-p.x*p.x-p.y*p.y)),s=ba(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(od,Math.abs(a)),h=l*Math.max(ad,Math.abs(a)),f=Math.cos(e.angle),u=Math.sin(e.angle);return{facing:s,points:t.map(p=>{const m=rd*Math.sin(o)+n.x*c+(p.x-n.x)*h,d=p.y+r[1]*i(p),g=m*e.rx,y=d*e.ry;return{x:e.center.x+g*f+y*u,y:e.center.y+g*u-y*f}})}}const Sn=(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}}),Ji=(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}}),Ma=.05;function ld(e,t,n,i){const s=Math.max(1,Math.min(i*.6,.14*t.rx)),r=(y,v)=>kn(t,y,v).points,o=(y,v)=>kn(t,[],{x:y,y:v}).facing,a=ut(n,"smile",0),l=ut(n,"blink",0),c=ut(n,"lookX",0),h=ut(n,"lookY",0),f=ut(n,"browTilt",0);for(const y of[1,-1]){const v=y===1?"left":"right",w=id*y;if(o(w,kt)<Ma)continue;const M={x:w,y:kt},k=sd(ut(n,`eye.${v}`,1),l);if(k<.2){const T=a>.5?.12:-.06;e.line(r(Sn({x:w-.12,y:kt},{x:w,y:kt+T},{x:w+.12,y:kt}),M),s)}else{if(k>1.2){const P=.13*k;e.shape(r(Ji(w,kt,P*.85,P),M),"#ffffff",s)}const T=k>1.2?.075:.1,x=w+c*.08,A=kt-h*.07;e.shape(r(Ji(x,A,T,T*1.1*Math.min(k,1)),M),e.ink,0)}const S=kt+.3+ut(n,`brow.${v}`,0)*.14+Math.max(0,k-1)*.12,E={x:w+y*.13,y:S},_={x:w-y*.13,y:S+f*.1};e.line(r([E,{x:(E.x+_.x)/2,y:(E.y+_.y)/2},_],{x:w,y:S}),s)}const u={x:0,y:ct};if(o(0,ct)<-Ma)return;const p=.25*Math.max(.3,ut(n,"mouthWidth",1)),m=Math.min(1,Math.max(0,ut(n,"mouth",0)));if(m<=.05){e.line(r(Sn({x:-p,y:ct},{x:0,y:ct-a*.25},{x:p,y:ct}),u),s);return}const d=.3*m;let g;if(a>.3){const y=ct+.05;g=[...Sn({x:p,y},{x:0,y:ct-d*2},{x:-p,y})]}else if(a<-.3){const y=ct-d*.6;g=[...Sn({x:p,y},{x:0,y:ct+d*1.4},{x:-p,y})]}else g=Ji(0,ct,p*.8,d);e.shape(r(g,u),e.ink,0)}function Ta(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??ma({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 cd(e,t,n,i){const{point:s,facing:r}=ba(e,[t,n,i]);return{point:s,facing:r}}const Zi=e=>e.rest[1]<-.5,hd=.3;function ud(e,t,n){return e.figure==="stick"?Zi(t)?n.slice(0,3):n:Zi(t)&&n.length>=3?xt(n[0],n[1],n[2],hd):n.length===3?xt(n[0],n[1],n[2],1):n}function Qi(e,t){const n=e.plan.id==="human"?{...J,...t}:t;return ts(e,n,qi(e.plan,n,{height:e.height,contact:e.contact}))}function ts(e,t,n){const i={},s={},r={},o=.01*e.height;e.plan.chains.forEach(u=>{const p=n.chains[u.id];i[u.id]=p.points;const m=p.depths.reduce((v,w)=>v+w,0)/p.depths.length,d=u.parent?n.chains[u.parent]:void 0,g=d?d.depths[u.at??d.depths.length-1]:0,y=m-g;r[u.id]=Math.abs(y)<o?0:y,s[u.id]={points:ud(e,u,p.points),depth:m}}),s.head={points:[n.head.center],depth:n.head.depth},r.head=0;const a=[...e.plan.chains.map(u=>u.id),"head"],l=[...a].sort((u,p)=>r[u]-r[p]||a.indexOf(u)-a.indexOf(p)),c={hip:n.hip};for(const[u,[p,m]]of Object.entries(e.plan.landmarks??{})){const d=n.chains[p]?.points;d&&(c[u]=d[Math.min(m,d.length-1)])}const h={};for(const[u,p]of Object.entries(c))h[u]=p.y>=n.groundY-.01*e.height;const f={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:f,order:l}}function Ea(e,t){return Qi(e,t).joints}function fd(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=kn(i,s,{x:0,y:0});o.facing>0&&e.guide(o.points),e.guide(kn(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 dd(e,t,n,i,s,r){const o=n.lineWidth;if(s==="head"){const{head:p}=i,m=n.skin==="none"?null:n.skin;t.ellipse(p.center.x,p.center.y,p.rx,p.ry,p.angle,m,o),t.look!=="silhouette"&&ld(t,p,r,o);return}const a=n.plan.chains.find(p=>p.id===s),l=i.chains[s],c=i.parts[s].points;if(n.figure==="stick"){if(s==="neck")return;const p=s==="spine"?[...l,...i.chains.neck?.slice(1)??[]]:c;t.line(p,o);return}const h=(p,m)=>[a.bones[p].width[0]*o,a.bones[m].width[1]*o];if(Zi(a)){const[p,m]=h(0,1);if(t.limb(c,p,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."))pd(e,t,n,l,s.endsWith(".left")?"left":"right",r);else{const d=l[l.length-1];t.dot(d.x,d.y,o*.62)}return}if(s==="spine"){const p=i.points["hip.left"],m=i.points["hip.right"];p&&m&&Math.hypot(p.x-m.x,p.y-m.y)>.5&&t.limb([p,m],o*1.3,o*1.3);const[d,g]=h(0,a.bones.length-1);t.limb(c,d,g);const y=i.points["shoulder.left"],v=i.points["shoulder.right"];y&&v&&Math.hypot(y.x-v.x,y.y-v.y)>.5&&t.limb(xt(y,l[l.length-1],v,1,10),o*1.15,o*1.15);return}const[f,u]=h(0,a.bones.length-1);t.limb(c,f,u)}function Aa(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{...N,...i,turn:r+(i.turn??0)}}function pd(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,Aa(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 xa(e,t,n,i=0){const s=t.plan.id==="human"?{...J,...n}:n;Ca(e,t,s,Qi(t,s),i)}function Pa(e,t){const n=t/e.height;return{...e,height:t,lineWidth:e.lineWidth*n}}function md(e,t,n,i){const s=e.plan.id==="human"?{...J,...t}:t,r=Ui(e.plan,s,{height:i.height,contact:e.contact},n);return ts(Pa(e,r.height),s,r).joints}function _a(e,t,n,i,s){const r=t.plan.id==="human"?{...J,...n}:n,o=Ui(t.plan,r,{height:s.height,contact:t.contact},i),a=Pa(t,o.height);Ca(e,a,r,ts(a,r,o),s.time??0)}function Ca(e,t,n,i,s){const{joints:r,order:o}=i,a=Pi(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&&fd(a,t,r),l(t.layers.behind);for(const c of o){const h=t.layers.parts?.[c];l(h?.under),dd(e,a,t,r,c,n),l(h?.over)}l(t.layers.front),e.restore()}function gd(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 yd(e,t,n,i){const s=e.plan.id==="human"?{...J,...t}:t;let r;if(Array.isArray(i))r=i;else{const{skeleton:o}=Qi(e,s),a=qi(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,f=a.hip.x+c*Math.cos(-l)-h*Math.sin(-l),u=a.hip.y+c*Math.sin(-l)+h*Math.cos(-l),p=Math.PI/2*(s.turn??0),m=i.depth??o.chains[n].depths[o.chains[n].depths.length-1],d=Math.cos(p),g=Math.sin(p);r=[f*d-m*g,-u,f*g+m*d]}return nd(e.plan,s,n,r,{height:e.height})}function bd(e){const{character:t}=e,n=t.height*.8,i=t.height,s=t.plan.id==="human"?J:{};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),xa(r,t,o.props,a)}}}function Ia(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 wd(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=Ea(i,s);return{pose:s,joints:Ia(a,e.x+r+e.width/2,e.y+o+e.height)}}function vd(e,t,n=J){const i=[];return t.forEach((r,o)=>{const a=o===0?n:i[o-1],l=typeof r.pose=="string"?pa[r.pose]:void 0;i.push(l?{...l,turn:a.turn??0}:{...a,...r.pose})}),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 kd=new Set(["x","y","z","position","rotateX","rotateY","rotateZ","quaternion","scale","scaleX","scaleY","scaleZ","visible","opacity","color"]),Sd=1.7;function Md(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 Td(e){const t=ae([0,1,0],e);if(t>.999999)return dr();if(t<-.999999)return ce(Bt([1,0,0],180));const n=Ye([0,1,0],e);return ce(Bt(n,Math.acos(t)*180/Math.PI))}function Ed(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,f=[],u=(w,M,k)=>f.push({mesh:w,world:Tt(s,M),material:k}),p=(w,M,k)=>u(t.sphere,mr(w,[0,0,0,1],[M,M,M]),k);for(const w of n.chains){const M=i.chains[w.id],k=w.id==="spine"?1.9:1;w.bones.forEach((S,E)=>{const _=M[E],T=M[E+1],x=ur(_,T),[A,P]=S.width??[1,1],C=h*k*(A+P)/2;if(x>1e-6){const I=fr(_,T,.5),H=Td(le(We(T,_)));u(t.cylinder,Tt(pr(I),Tt(H,Ke([C,x,C]))),a)}p(_,h*k*A,a),p(T,h*k*P,a)}),w.id.startsWith("arm.")&&p(M[M.length-1],h*1.5,l)}const{center:m,rx:d,ry:g,axes:y}=i.head,v=[...y[0],0,...y[1],0,...y[2],0,...m,1];u(t.sphere,Tt(v,Ke([d,g,d])),l);for(const w of[-1,1]){const M=le([w*.36,.15,.92]),k=Ne(m,Ne(Ne(oe(y[0],M[0]*d*1.04),oe(y[1],M[1]*g*1.04)),oe(y[2],M[2]*d*1.04))),S=[...y[0],0,...y[1],0,...y[2],0,...k,1];u(t.sphere,Tt(S,Ke([d*.11,g*.14,d*.03])),c)}return f}const Ad={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:Ta({...e.character,height:1}),cylinder:ka(ed(1,1,16)),sphere:ka(td(1,20))}},resolve({object:e,prepared:t,values:n,world:i,camera:s,toScreen:r}){const o=e,a=t,l=a.who,c={...J,...o.pose};for(const[g,y]of n)typeof y=="number"&&!kd.has(g)&&(c[g]=y);const h=o.height??Sd,f=Tt(s.view,i),u={toView:g=>gr(f,g),toScreen:g=>r(g)},m=-u.toView([0,h/2,0])[2];if(m<=s.near)return null;const d=o.shadow===!1?[]:[{depth:m+h,draw:g=>Md(g,u,h*.18)}];if(o.look==="solid"){const g=Vi(l.plan,c,{height:h,contact:l.contact});return{meshes:Ed(o,a,l.plan,g,i),drawables:d}}return{drawables:[...d,{depth:m,draw(g,y){g.lineCap="round",g.lineJoin="round",_a(g,l,c,u,{height:h,time:y.time})}}]}}};function Ha(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)Oa(e,c,i);e.restore()}function es(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 $a=150,xd={pencil:44,eraser:30};function ns(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},f=$a*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 u={x:t.x+h.x+6*l*a,y:t.y+h.y-18*l*a},p=K.pencilGrip,m=E=>{const _=E.fingers.thumb,T=E.fingers.index,x=E.fingers.middle,A=Ra([_.points[3],T.points[3],x.points[3]]),P=Ra([_.points[1],T.points[0]]),C=(_.depths[3]+T.depths[3]+x.depths[3])/3;return{pinch:A,direction:Math.atan2(P.y-A.y,P.x-A.x),depth:C}},d=nn(p,{size:f}),g=c-m(d).direction,y=nn(p,{size:f,angle:g*180/Math.PI}),v=m(y),w=xd[s]*a,M={x:v.pinch.x-Math.cos(c)*w,y:v.pinch.y-Math.sin(c)*w},k={x:u.x-M.x,y:u.y-M.y},S=y.axes.up;Pd(e,k,{x:-S.x,y:-S.y},f,n.arm??300*a,r,n.sleeve??"#5b7db1",o),sn(e,k,p,{size:f,angle:g*180/Math.PI,skin:r,ink:o,lineWidth:3*a,prop:{depth:v.depth,draw:()=>{e.save(),e.translate(u.x,u.y),e.scale(a,a),s==="eraser"?es(e,{x:0,y:0},{angle:c*180/Math.PI,outline:o},i):Ha(e,{x:0,y:0},{angle:c*180/Math.PI,length:190,outline:o},i),e.restore()}}})}const Ra=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length});function Pd(e,t,n,i,s,r,o,a){const l={x:-n.y,y:n.x},c=i*.15,h=(d,g,y)=>({x:t.x+n.x*d+l.x*g*y,y:t.y+n.y*d+l.y*g*y}),f=h(s,0,0),u=d=>{const g=e.createLinearGradient(t.x,t.y,f.x,f.y);return g.addColorStop(0,d),g.addColorStop(.6,d),g.addColorStop(1,Hd(d)),g},p=Math.min(i*.55,s*.35);e.save(),e.lineJoin="round",e.lineCap="round",e.lineWidth=3*(i/$a),e.beginPath(),e.moveTo(h(-i*.1,-1,c).x,h(-i*.1,-1,c).y),e.lineTo(h(p+4,-1,c*1.1).x,h(p+4,-1,c*1.1).y),e.lineTo(h(p+4,1,c*1.1).x,h(p+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(p,-1,c*1.1).x,h(p,-1,c*1.1).y),e.moveTo(h(0,1,c).x,h(0,1,c).y),e.lineTo(h(p,1,c*1.1).x,h(p,1,c*1.1).y),e.stroke();const m=[h(p,-1,c*1.3),h(s,-1,c*1.5),h(s,1,c*1.5),h(p,1,c*1.3)];e.beginPath(),m.forEach((d,g)=>g?e.lineTo(d.x,d.y):e.moveTo(d.x,d.y)),e.closePath(),e.fillStyle=u(o),e.fill(),e.strokeStyle=u(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 _d(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(d=>d.path.length>0).sort((d,g)=>d.start-g.start),l=d=>d.tool??"pencil",c=d=>{const g=Math.min(1,Math.max(0,d));return g*g*(3-2*g)},h=(d,g,y)=>({x:d.x+(g.x-d.x)*y,y:d.y+(g.y-d.y)*y}),f=a.find(d=>t>=d.start&&t<=d.end);if(f){const d=f.end-f.start,g=d>0?(t-f.start)/d:1;return{at:Je(f.path,g),tool:l(f),lift:0,drawing:!0}}const u=[...a].reverse().find(d=>d.end<t),p=a.find(d=>d.start>t),m=d=>d.path[d.path.length-1];if(u&&p&&p.start-u.end<=o){const d=(t-u.end)/(p.start-u.end),g=d<.5?l(u):l(p);return{at:h(m(u),p.path[0],c(d)),tool:g,lift:Math.sin(Math.PI*d),drawing:!1}}if(p&&p.start-t<=s){const d=1-(p.start-t)/s;return{at:h(i,p.path[0],c(d)),tool:l(p),lift:1-c(d),drawing:!1}}if(u&&t-u.end<=r){const d=(t-u.end)/r;return{at:h(m(u),i,c(d)),tool:l(u),lift:c(d),drawing:!1}}return null}function Cd(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 Id(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 f=e.sketch?Ze(a,e.sketch,c):void 0;h>0&&(f?e.smooth?f.curve(t,h):f.line(t,h):Oa(a,Vt(t,h))),o&&h>0&&h<1&&ns(a,Je(t,h),o,f)}}}function Hd(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 Oa(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 Mn=1e5;function $d(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 is(e,t,n,i){if(i<=0||t.length===0)return;const s=Vt(t,i),r=n/2,o=a=>{e.beginPath(),e.rect(-Mn,-Mn,2*Mn,2*Mn),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 f=-(c.y-l.y)/h*r,u=(c.x-l.x)/h*r;o(()=>{e.moveTo(l.x+f,l.y+u),e.lineTo(c.x+f,c.y+u),e.lineTo(c.x-f,c.y-u),e.lineTo(l.x-f,l.y-u),e.closePath()})}}function Rd(e,t,n,i,s){e.save(),is(e,t,n,i),s(),e.restore()}function Od(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(),is(r,t.path,n,l),e.draw(r,o,a),r.restore(),!s||l<=0||l>=1)return;const c=Je(t.path,l);i?ns(r,c,{...i,tool:"eraser"}):es(r,c,s)}}}const Fd=(e,t,n)=>e.slice(Math.floor((e.length-1)*t),Math.ceil((e.length-1)*n)+1);function Ld(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(ge(h,a.height*.08,a.height*.05),n,i(a))},r=(a,l)=>{const c=a.chains.spine,h=c[0],f=c[c.length-1],u={x:h.x-(f.x-h.x)*.25,y:h.y-(f.y-h.y)*.25};l.shape(ge([u,...a.parts.spine.points],a.height*.15,a.height*.14),t,i(a))},o=(a,l,c)=>{const h=a.parts[`arm.${c}`].points,f=h[0],u=a.chains.spine[a.chains.spine.length-1],m=[{x:f.x+(u.x-f.x)*.45,y:f.y+(u.y-f.y)*.45},...Fd(h,0,.45)],d=ge(m,a.height*.085,a.height*.06),g=m.length,y=d.slice(0,g),v=d.slice(g).reverse();l.shape(d,t,0);const w=S=>Math.hypot(S[1].x-u.x,S[1].y-u.y),[M,k]=w(y)>w(v)?[y,v]:[v,y];l.line(M.slice(1),i(a)),l.line(k.slice(Math.ceil(g*.45)),i(a)),l.line([y[g-1],v[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")}}}}function Bd(e){const{timeline:t}=e,n=new At;for(const[c,h]of Object.entries(e.targets)){const f=typeof h=="string"?document.querySelector(h):h;if(!f)throw new Error(`quickPlay: no element found for target "${c}" (${String(h)})`);n.registerTarget(c,f)}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 Dd={timeline:_c,to(e,t,n){const i=new Et(n);return i.to(e,t),i},from(e,t,n){const i=new Et(n);return i.from(e,t),i},fromTo(e,t,n,i){const s=new Et(i);return s.fromTo(e,t,n),s},set(e,t,n){const i=new Et(n);return i.set(e,t),i}};function Fa(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 Nd(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 f=(h-s)/(1-s)*c/h;i[r*3]=o*f,i[r*3+1]=a*f,i[r*3+2]=l*f}return i}function La(e,t,n,i,s){const r=new Float32Array(e.length),o=s?n:t,a=s?t:n,l=(h,f)=>(s?h*t+f:f*t+h)*3,c=i*2+1;for(let h=0;h<o;h++)for(let f=0;f<3;f++){let u=0;for(let p=-i;p<=i;p++)u+=e[l(h,Math.min(a-1,Math.max(0,p)))+f];for(let p=0;p<a;p++){r[l(h,p)+f]=u/c;const m=e[l(h,Math.max(0,p-i))+f],d=e[l(h,Math.min(a-1,p+i+1))+f];u+=d-m}}return r}function Ba(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=La(r,t,n,s,!0),r=La(r,t,n,s,!1);return r}function Wd(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=Fa(e,o,a),c=l?.getContext("2d");if(!l||!c)return;c.imageSmoothingEnabled=!0,c.drawImage(e.canvas,0,0,o,a);const h=Nd(c.getImageData(0,0,o,a).data,t.threshold??.55),f=(t.radius??Math.max(i,s)*.02)/r,u=Ba(h,o,a,f),p=Ba(h,o,a,f*3),m=t.halo??.6,d=c.createImageData(o,a);for(let g=0;g<o*a;g++){for(let y=0;y<3;y++)d.data[g*4+y]=Math.round(Math.min(1,u[g*3+y]+p[g*3+y]*m)*255);d.data[g*4+3]=255}c.putImageData(d,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 Yd(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=qd(t,i,s,r,o);a?(e.globalCompositeOperation="lighter",ss(e,c,n.color)):Xd(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,Kd(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 Kd(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 qd(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,f=s*(1-i*h);if(f<=0)continue;const u=c+2===e.length;l.push({corners:[o.left[c],o.left[c+1],o.right[c+1],o.right[c]],alpha:f,...u&&a&&{cap:a}})}return l}function ss(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 Xd(e,t,n){const i=typeof e.getTransform=="function"?e.getTransform():null,s=d=>i?{x:i.a*d.x+i.c*d.y+i.e,y:i.b*d.x+i.d*d.y+i.f}:d,r=i?Math.sqrt(Math.abs(i.a*i.d-i.b*i.c)):1,o=t.map(d=>({...d,corners:d.corners.map(s),...d.cap&&{cap:{...d.cap,...s(d.cap),radius:d.cap.radius*r,start:d.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 d of o){const g=d.cap?[{x:d.cap.x-d.cap.radius,y:d.cap.y-d.cap.radius},{x:d.cap.x+d.cap.radius,y:d.cap.y+d.cap.radius}]:[];for(const y of[...d.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 f=Math.floor(a)-1,u=Math.floor(l)-1,p=i?Fa(e,Math.ceil(c)+1-f,Math.ceil(h)+1-u):null,m=p?.getContext("2d");if(!p||!m){ss(e,t,n);return}m.translate(-f,-u),m.globalCompositeOperation="lighter",ss(m,o,n),e.save(),e.setTransform(1,0,0,1,0,0),e.globalAlpha=1,e.drawImage(p,f,u),e.restore()}const Vd=z.to,Ud=z.from,zd=z.fromTo,jd=z.set,Gd=z.timeline,Jd=z.ticker,Zd=z.splitText,Qd=z.context,t0=z.matchMedia,e0=z.quickTo,n0=z.imageSequence,i0=z.pageTransition;nu(),b.Clock=Wa,b.CompatTimeline=Et,b.CustomBounce=io,b.CustomEase=no,b.CustomWiggle=so,b.DANCE_STYLES=_t,b.DEFAULT_BAKE_INTERVAL_MS=Kn,b.DEFAULT_INERTIA_FRICTION=In,b.DEFAULT_LABELS=po,b.DEFAULT_SPRING=Q,b.DEFAULT_TRANSITION=su,b.Draggable=hi,b.EXPRESSIONS=tt,b.FINGERS=Ao,b.FLIPS=mn,b.FORMAT_VERSION=En,b.HAND_REST=N,b.HAND_SHAPES=K,b.HUMAN_EXPRESSIONS=jf,b.HUMAN_POSES=pa,b.HUMAN_REST=J,b.INERTIA_MAX_DURATION_MS=as,b.InertiaTrackPlayer=Us,b.LiveTimeline=lt,b.MORPH_SAMPLES=cl,b.MUDRAS=Li,b.ManualClock=Na,b.MediaSync=Ti,b.Observer=$r,b.POSES=Io,b.REST_POSE=G,b.SPRING_MAX_DURATION_MS=Cn,b.SPRING_PRESETS=Pe,b.SPRING_STEP_MS=Ht,b.ScrollAnimator=jr,b.ScrollDriver=de,b.ScrollMarkers=Gr,b.ScrollPin=Xr,b.SmoothScroll=ki,b.SpringSampler=Qt,b.SpringTrackPlayer=Vs,b.Stage=xr,b.Timeline=jn,b.TinyflyPlayer=je,b.TinyflySequencer=So,b.TrackPlayer=Oe,b.ValueResolver=Ll,b.VisibilityDriver=qr,b.applyBloom=Wd,b.applyGroove=ra,b.backOut=ys,b.bakeDanceTracks=vf,b.bakeEasing=Vn,b.bakeInertiaTrack=Xn,b.bakeSpringTrack=qn,b.basicOutfit=Ld,b.beatAt=yf,b.beatAtTime=Be,b.beatLength=ei,b.beatTime=Le,b.beatsBetween=jl,b.bindChoiceHotspots=bo,b.blendPose=zt,b.boilFrame=Ai,b.bounceOut=gs,b.character=Ta,b.characterAt=wd,b.characterHandPose=Aa,b.characterJoints=Ea,b.characterJointsInView=md,b.characterObjects=Ad,b.characterPoseTracks=vd,b.characterTarget=bd,b.charactersFor=zs,b.circlePath=Cd,b.clamp01=yi,b.clearMorphCache=bl,b.clearPathCache=sl,b.clipErased=is,b.containerProgressAt=bi,b.context=Qd,b.create=Wh,b.createControls=go,b.createCubicBezier=ps,b.createLive=ao,b.createPen=Pi,b.createRandom=Fe,b.createTrack=Re,b.criticalDamping=qa,b.customBounce=rr,b.customEase=sr,b.customWiggle=or,b.danceFrame=hn,b.dancePose=ff,b.danceStance=cn,b.danceTaps=pf,b.danceTracks=wf,b.danceTravel=fn,b.danceTravelTrack=ha,b.dancer=bf,b.deserializeTimeline=Nt,b.deserializeTrack=Zs,b.detectTempo=Gl,b.draggable=th,b.drawCartoonHand=sn,b.drawCharacter=xa,b.drawCharacterInView=_a,b.drawEraser=es,b.drawHand=ns,b.drawPencil=Ha,b.drawStickFigure=ea,b.drawTrail=Yd,b.drawnPathTarget=Id,b.easeIn=us,b.easeInCubic=Hn,b.easeInOut=ds,b.easeInOutCubic=ee,b.easeInOutQuad=hs,b.easeInQuad=ls,b.easeOut=fs,b.easeOutCubic=$n,b.easeOutQuad=cs,b.elasticOut=ms,b.ellipsePoints=xi,b.erasable=Od,b.expandParametricEasings=qs,b.flipPose=ua,b.flipTracks=Of,b.flipTravel=fa,b.formatVersionFor=An,b.from=Ud,b.fromJSON=Rl,b.fromTo=zd,b.getEasingFunction=V,b.getInterpolator=re,b.getMotionPathPoint=Un,b.getPathLength=rl,b.getPointAtProgress=Ss,b.gridLinesFor=Fr,b.handAt=_d,b.handJoints=nn,b.handJointsAt=_o,b.handPose=W,b.handProp=ve,b.hasKeyframes=rs,b.hashSeed=Zn,b.headPoint=tf,b.humanFieldLabel=Uf,b.humanPlan=ma,b.humanPose=et,b.imageSequence=n0,b.inertiaDuration=Rt,b.inertiaRest=$t,b.inertiaValueAt=Ce,b.inertiaVelocityAt=za,b.interpolateArray=Ns,b.interpolateColor=Ds,b.interpolateMotionPath=_l,b.interpolateNumber=rt,b.interpolatePathString=Ys,b.interpolateQuaternion=Ws,b.interpolateString=Yn,b.isCubicBezierEasing=It,b.isInertiaTrack=ft,b.isMotionPathPoint=Da,b.isMotionPathTrack=xn,b.isParametricEasing=Jt,b.isPathData=Ft,b.isSpringTrack=dt,b.isTextTrack=Te,b.isUnderdamped=Ka,b.isUnresolved=Fl,b.jointsInScene=Ia,b.jointsToScene=ta,b.linear=Ie,b.live=z,b.mapEase=he,b.mat4=ac,b.matchMedia=t0,b.maxStaggerDistance=_n,b.mirrorHumanPose=Vf,b.mirrorPose=sa,b.mixHandPoses=Ut,b.mixPoses=gd,b.morphPath=_s,b.mount=wo,b.mountAll=ko,b.narrationMarkers=Xl,b.narrationSceneAt=Vl,b.naturalRest=te,b.nearestBeat=Ul,b.nextBeat=zl,b.pageTransition=i0,b.parametricEasing=ws,b.parseEdge=mi,b.parsePath=Mt,b.parseTrigger=gi,b.partialPath=Vt,b.pathLength=Mo,b.planNarration=ql,b.play=Nh,b.playSequence=iu,b.playWhenVisible=dh,b.playheadCrossings=Gn,b.pointAlong=Je,b.pointAtDistance=On,b.pointOnHead=cd,b.pointsToPath=lr,b.pose=X,b.poseTracks=of,b.quat=Tl,b.quickPlay=Bd,b.quickTo=e0,b.randomBetween=Qn,b.randomChoice=Ol,b.randomSnapped=tr,b.reachCharacter=yd,b.resolveSequence=ir,b.resolveStickFrame=Oi,b.resolveStickPose=na,b.resolveValue=ti,b.ribbon=cr,b.ribbonHeadCap=hr,b.rotateAbout=wt,b.routineBeats=un,b.rubberLimb=xt,b.scrollProgress=fh,b.scrubOnScroll=yh,b.scrubPath=$d,b.seatHeight=ju,b.serializeTimeline=Qs,b.serializeTrack=Gs,b.set=jd,b.shapeToPathData=De,b.simplifyKeyframes=Xs,b.skeletonInView=Ui,b.sketchPen=Ze,b.smoothToward=Kr,b.snapAxis=Or,b.snapConfig=Vr,b.snapDuration=zr,b.snapProgress=Ur,b.solvePlanSpace=bn,b.splitText=Zd,b.springDuration=os,b.springValueAt=Ya,b.stagePlanSpace=Vi,b.staggerDistance=Pn,b.staggerOffset=Ee,b.staggerOffsets=Ae,b.staggerSpan=Zt,b.stepsEasing=bs,b.stickFigureAt=rf,b.stickFigureJoints=Qo,b.stickFigureTarget=sf,b.stickToHuman=Gf,b.strideLength=Cu,b.syncMediaElement=fo,b.talkingMouth=Fo,b.taperedLine=Qe,b.taperedOutline=ge,b.textAt=js,b.tf=Dd,b.ticker=Jd,b.timeline=Gd,b.to=Vd,b.toJSON=$l,b.toKeyframedTrack=xl,b.toKeyframedTracks=Pl,b.trackTargets=yt,b.trailSamples=Zl,b.triggerDistance=Yt,b.unmount=tu,b.vec3=tc,b.walkPose=Oo,b.withErased=Rd,b.withExpression=Ii,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
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"})}));