@algorisys/tinyfly 0.92.0 → 0.94.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.
- package/README.md +7 -6
- package/bin/tinyfly.mjs +34 -1
- package/docs/2d-animation-roadmap.md +191 -0
- package/docs/3d-rotations.md +164 -0
- package/docs/3d-support-plan.md +628 -0
- package/docs/DEPLOYMENT.md +414 -0
- package/docs/acting.md +529 -0
- package/docs/api-reference.md +2353 -0
- package/docs/camera.md +94 -0
- package/docs/cartoon-hands.md +96 -0
- package/docs/character-system-m1.md +218 -0
- package/docs/character-system-plan.md +384 -0
- package/docs/dance.md +315 -0
- package/docs/editor-guide.md +1249 -0
- package/docs/examples.md +765 -0
- package/docs/extending.md +168 -0
- package/docs/file-format.md +690 -0
- package/docs/getting-started.md +314 -0
- package/docs/grid-and-snapping.md +64 -0
- package/docs/gsap-compat.md +1241 -0
- package/docs/llm-guide.md +131 -0
- package/docs/maps.md +116 -0
- package/docs/onion-skinning.md +41 -0
- package/docs/pen-tool.md +65 -0
- package/docs/polygon-star.md +44 -0
- package/docs/scene-3d.md +299 -0
- package/docs/scroll-animation.md +314 -0
- package/docs/shape-morph.md +61 -0
- package/docs/sprite-sheet-export.md +54 -0
- package/docs/symbols-and-library.md +137 -0
- package/docs/teaching.md +348 -0
- package/docs/video-rendering.md +728 -0
- package/lib/addons/adapters.js +22 -18
- package/lib/addons/characters.js +3045 -2024
- package/lib/addons/target-properties-BtN9skb-.js +142 -0
- package/lib/browser/tinyfly.iife.js +9 -4
- package/lib/browser/tinyfly.js +6968 -5817
- package/lib/browser/tinyfly.umd.js +9 -4
- package/lib/engine/tinyfly-engine.js +286 -258
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/types/adapters/canvas/canvas-adapter.d.ts +6 -0
- package/lib/types/adapters/canvas/index.d.ts +1 -0
- package/lib/types/adapters/canvas/target-properties.d.ts +68 -0
- package/lib/types/characters/acting/beat-check.d.ts +102 -0
- package/lib/types/characters/acting/custom.d.ts +66 -0
- package/lib/types/characters/acting/gags.d.ts +10 -0
- package/lib/types/characters/acting/hand-path.d.ts +35 -0
- package/lib/types/characters/acting/index.d.ts +4 -0
- package/lib/types/characters/acting/persona.d.ts +93 -0
- package/lib/types/characters/acting/script.d.ts +75 -11
- package/lib/types/characters/capabilities.d.ts +61 -0
- package/lib/types/characters/code-panel.d.ts +201 -0
- package/lib/types/characters/figure-actions.d.ts +12 -0
- package/lib/types/characters/figure-props.d.ts +87 -0
- package/lib/types/characters/gaits.d.ts +8 -0
- package/lib/types/characters/index.d.ts +3 -0
- package/lib/types/characters/stick-figure.d.ts +9 -2
- package/lib/types/engine/authoring/did-you-mean.d.ts +14 -0
- package/lib/types/engine/authoring/index.d.ts +1 -0
- package/llms-full.txt +12631 -0
- package/llms.txt +57 -0
- package/package.json +6 -2
- package/skills/tinyfly/SKILL.md +67 -0
- package/lib/addons/camera-C7bZOWMB.js +0 -33
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(b,Bt){typeof exports=="object"&&typeof module<"u"?Bt(exports):typeof define=="function"&&define.amd?define(["exports"],Bt):(b=typeof globalThis<"u"?globalThis:b||self,Bt(b.tinyfly=b.tinyfly||{}))})(this,(function(b){"use strict";function Bt(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function fe(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const qn=2;function Vn(e){return e.some(t=>t.interpolation!==void 0)?2:1}function Ye(e){return e.property==="text"&&"textConfig"in e}function mt(e){return e.kind==="inertia"&&"inertia"in e}function gt(e){return e.kind==="spring"&&"spring"in e}function Un(e){return e.property==="motionPath"&&"motionPathConfig"in e}function Xl(e){return typeof e=="object"&&e!==null&&"x"in e&&"y"in e&&"angle"in e}function Hs(e){return"keyframes"in e}class ql{_currentTime=0;_isRunning=!1;onTick=null;get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}start(){this._isRunning=!0}stop(){this._isRunning=!1}tick(t){this._currentTime+=t,this.onTick?.(t,this._currentTime)}reset(){this._currentTime=0}seek(t){this._currentTime=t}}class Vl{_currentTime=0;_isRunning=!1;_lastFrameTime=null;_rafId=null;_speed;onTick=null;constructor(t={}){this._speed=t.speed??1}get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}get speed(){return this._speed}set speed(t){this._speed=t}start(){this._isRunning||(this._isRunning=!0,this._lastFrameTime=null,this._scheduleFrame())}stop(){this._isRunning=!1,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null)}reset(){this._currentTime=0,this._lastFrameTime=null}seek(t){this._currentTime=t}_scheduleFrame(){this._rafId=requestAnimationFrame(this._onFrame.bind(this))}_onFrame(t){if(this._isRunning){if(this._lastFrameTime!==null){const i=(t-this._lastFrameTime)*this._speed;this._currentTime+=i,this.onTick?.(i,this._currentTime)}this._lastFrameTime=t,this._scheduleFrame()}}}function $s(e,t){if(!(t>0))return e;const n=1e3/t;return Math.floor(e/n+1e-9)*n}function zn(e,t,n="start"){if(t<=1)return 0;if(typeof n=="number"){const i=Math.max(0,Math.min(t-1,n));return Math.abs(e-i)}switch(n){case"end":return t-1-e;case"center":return Math.abs(e-(t-1)/2);case"edges":return(t-1)/2-Math.abs(e-(t-1)/2);default:return e}}function Gn(e,t="start"){if(e<=1)return 0;let n=0;for(let i=0;i<e;i++)n=Math.max(n,zn(i,e,t));return n}function Xe(e,t,n){if(n.offsets)return n.offsets[e]??0;const i=n.from??"start",s=zn(e,t,i);if(n.amount!==void 0){const r=Gn(t,i);return r===0?0:n.amount*s/r}return n.each!==void 0?n.each*s:0}function qe(e,t){return Array.from({length:e},(n,i)=>Xe(i,e,t))}function de(e,t){return e<=1?0:Math.max(...qe(e,t))}const Nt=1,jn=6e4,Ve=jn/Nt,st={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},Ue={gentle:{stiffness:120,damping:18,mass:1},default:{stiffness:180,damping:12,mass:1},snappy:{stiffness:280,damping:20,mass:1},bouncy:{stiffness:220,damping:8,mass:1},wobbly:{stiffness:180,damping:5,mass:1},stiff:{stiffness:400,damping:30,mass:1}};class pe{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(t){this.from=t.from,this.to=t.to,this.stiffness=t.stiffness??st.stiffness,this.damping=t.damping??st.damping,this.mass=t.mass??st.mass,this.restDelta=t.restDelta??st.restDelta,this.restSpeed=t.restSpeed??st.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??st.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(t){return Math.abs(t-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(t){if(t<=0)return this.from;const n=Math.floor(t/Nt);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const i=this.samples[Math.min(n,this.samples.length-1)],s=this.samples[Math.min(n+1,this.samples.length-1)],r=t/Nt-n;return i+(s-i)*r}settleTime(){return this.simulateTo(Ve+1),this.settledStep!==null?this.settledStep*Nt:jn}simulateTo(t){if(this.settledStep!==null)return;const n=Math.min(t,Ve+1),i=Nt/1e3;for(;this.samples.length<n;){const s=this.samples[this.samples.length-1],r=s-this.to,o=-this.stiffness*r,a=-this.damping*this.velocity,l=(o+a)/this.mass;this.velocity+=l*i;const c=s+this.velocity*i;if(this.samples.push(c),this.isAtRest(c)){this.settledStep=this.samples.length-1;return}}this.samples.length>Ve&&(this.settledStep=Ve)}}function Ul(e,t){return new pe(e).valueAt(t)}function Rs(e){return new pe(e).settleTime()}function zl(e){const t=e.stiffness??st.stiffness,n=e.damping??st.damping,i=e.mass??st.mass;return n<2*Math.sqrt(t*i)}function Gl(e){const t=e.stiffness??st.stiffness,n=e.mass??st.mass;return 2*Math.sqrt(t*n)}const Jn=4,jl=.002,Jl=1e-4,Os=6e4;function ze(e){const t=e.friction??Jn;return t>0?t:Jn}function me(e){return e.from+e.velocity/ze(e)}function Zl(e,t){if(t===void 0)return e;if(typeof t=="number")return t>0?Math.round(e/t)*t:e;if(t.length===0)return e;let n=t[0];for(const i of t)Math.abs(i-e)<Math.abs(n-e)&&(n=i);return n}function Wt(e){let t=Zl(me(e),e.end);return e.min!==void 0&&(t=Math.max(e.min,t)),e.max!==void 0&&(t=Math.min(e.max,t)),t}function Kt(e){const t=Math.abs(Wt(e)-e.from);if(t===0)return 0;const n=e.restDelta??Math.max(Jl,t*jl);if(n>=t)return 0;const i=Math.log(t/n)/ze(e);return Math.min(Os,i*1e3)}function Ge(e,t){if(t<=0)return e.from;const n=Wt(e);if(t>=Kt(e))return n;const i=ze(e);return e.from+(n-e.from)*(1-Math.exp(-i*t/1e3))}function Ql(e,t){const n=ze(e),i=Wt(e);return t>=Kt(e)?0:(i-e.from)*n*Math.exp(-n*Math.max(0,t)/1e3)}const je=e=>e,Ls=e=>e*e,Fs=e=>1-(1-e)*(1-e),Ds=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,Zn=e=>e*e*e,Qn=e=>1-Math.pow(1-e,3),ge=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Bs=Zn,Ns=Qn,Ws=ge,tc={linear:je,"ease-in":Bs,"ease-out":Ns,"ease-in-out":Ws,"ease-in-quad":Ls,"ease-out-quad":Fs,"ease-in-out-quad":Ds,"ease-in-cubic":Zn,"ease-out-cubic":Qn,"ease-in-out-cubic":ge};function Ks(e){const[t,n,i,s]=e,r=3*t,o=3*(i-t)-r,a=1-r-o,l=3*n,c=3*(s-n)-l,h=1-l-c,u=p=>((a*p+o)*p+r)*p,f=p=>((h*p+c)*p+l)*p,d=p=>(3*a*p+2*o)*p+r,m=p=>{let g=p;for(let k=0;k<8;k++){const M=u(g)-p;if(Math.abs(M)<1e-7)return g;const S=d(g);if(Math.abs(S)<1e-7)break;g-=M/S}let y=0,w=1;for(g=p;y<w;){const k=u(g);if(Math.abs(k-p)<1e-7)return g;p>k?y=g:w=g,g=(y+w)/2}return g};return p=>{if(p<=0)return 0;if(p>=1)return 1;const g=m(p);return f(g)}}function ti(e,t="out"){if(t==="out")return e;const n=i=>1-e(1-i);return t==="in"?n:i=>i<.5?n(i*2)/2:e(i*2-1)/2+.5}function Ys(e=1,t=.3){const n=Math.max(1,e),i=t/(2*Math.PI)*Math.asin(1/n);return s=>s<=0?0:s>=1?1:n*Math.pow(2,-10*s)*Math.sin((s-i)*(2*Math.PI)/t)+1}const Xs=e=>{if(e<=0)return 0;if(e>=1)return 1;if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const s=e-.5454545454545454;return 7.5625*s*s+.75}if(e<2.5/2.75){const s=e-.8181818181818182;return 7.5625*s*s+.9375}const i=e-2.625/2.75;return 7.5625*i*i+.984375};function qs(e=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const n=t-1;return n*n*((e+1)*n+e)+1}}function Vs(e,t="end"){const n=Math.max(1,Math.floor(e));return i=>{if(i>=1)return 1;if(i<=0)return t==="start"||t==="both"?t==="start"?1/n:1/(n+1):0;const s=Math.floor(i*n);switch(t){case"start":return Math.min(1,(s+1)/n);case"both":return(s+1)/(n+1);case"none":return n===1?0:Math.min(1,s/(n-1));default:return s/n}}}function Us(e){switch(e.type){case"steps":return Vs(e.count,e.position);case"elastic":return ti(Ys(e.amplitude,e.period),e.mode);case"bounce":return ti(Xs,e.mode);case"back":return ti(qs(e.overshoot),e.mode)}}function J(e){return e===void 0?je:Bt(e)?Ks(e.points):fe(e)?Us(e):tc[e]??je}const zs=32,ec=256,Yt=new Map,nc=/[MmLlHhVvCcSsQqTtAaZz]/,ic=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,sc={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function rc(e){const t=[];let n=0,i=null;const s=()=>{for(;n<e.length&&/[\s,]/.test(e[n]);)n++};for(;n<e.length&&(s(),!(n>=e.length));){const r=e[n];if(nc.test(r)){i={type:r,args:[]},t.push(i),n++;continue}if(!i)break;const o=i.type==="A"||i.type==="a",a=i.args.length%7;if(o&&(a===3||a===4)){if(r!=="0"&&r!=="1")break;i.args.push(r==="1"?1:0),n++;continue}const l=ic.exec(e.slice(n));if(!l)break;i.args.push(parseFloat(l[0])),n+=l[0].length}return t}function oc(e,t,n,i,s,r,o,a,l){if(e===a&&t===l)return[];let c=Math.abs(n),h=Math.abs(i);if(c===0||h===0)return[[e,t,a,l,a,l]];const u=s*Math.PI/180,f=Math.cos(u),d=Math.sin(u),m=(e-a)/2,p=(t-l)/2,g=f*m+d*p,y=-d*m+f*p,w=g*g/(c*c)+y*y/(h*h);if(w>1){const O=Math.sqrt(w);c*=O,h*=O}const k=r===o?-1:1,M=c*c*h*h-c*c*y*y-h*h*g*g,S=c*c*y*y+h*h*g*g,A=k*Math.sqrt(Math.max(0,M/S)),E=A*c*y/h,T=-A*h*g/c,v=f*E-d*T+(e+a)/2,_=d*E+f*T+(t+l)/2,P=(O,D,N,K)=>{const Q=O*N+D*K,xt=Math.sqrt((O*O+D*D)*(N*N+K*K)),Dt=Math.acos(Math.max(-1,Math.min(1,Q/xt)));return O*K-D*N<0?-Dt:Dt},x=P(1,0,(g-E)/c,(y-T)/h);let I=P((g-E)/c,(y-T)/h,(-g-E)/c,(-y-T)/h);!o&&I>0&&(I-=2*Math.PI),o&&I<0&&(I+=2*Math.PI);const C=Math.max(1,Math.ceil(Math.abs(I)/(Math.PI/2))),H=I/C,R=4/3*Math.tan(H/4),B=O=>{const D=c*Math.cos(O),N=h*Math.sin(O);return[f*D-d*N+v,d*D+f*N+_]},$=O=>{const D=-c*Math.sin(O),N=h*Math.cos(O);return[f*D-d*N,d*D+f*N]},L=[];for(let O=0;O<C;O++){const D=x+O*H,N=D+H,[K,Q]=B(D),[xt,Dt]=O===C-1?[a,l]:B(N),[Zp,Qp]=$(D),[tm,em]=$(N);L.push([K+R*Zp,Q+R*Qp,xt-R*tm,Dt-R*em,xt,Dt])}return L}function yt(e,t,n,i,s){const r=1-s;return r*r*r*e+3*r*r*s*t+3*r*s*s*n+s*s*s*i}function Gs(e,t,n,i,s){const r=1-s;return 3*r*r*(t-e)+6*r*s*(n-t)+3*s*s*(i-n)}function ye(e,t,n,i){return{subpath:0,type:"L",points:[n,i],startX:e,startY:t,endX:n,endY:i,length:Math.hypot(n-e,i-t)}}function Je(e,t,n){const[i,s,r,o,a,l]=n,c=[0];let h=e,u=t,f=0;for(let d=1;d<=zs;d++){const m=d/zs,p=yt(e,i,r,a,m),g=yt(t,s,o,l,m);f+=Math.hypot(p-h,g-u),c.push(f),h=p,u=g}return{subpath:0,type:"C",points:[i,s,r,o,a,l],startX:e,startY:t,endX:a,endY:l,length:f,lengths:c}}function Pt(e){const t=Yt.get(e);if(t)return t;const n=[];let i=0,s=0,r=0,o=0,a=null,l=null,c=-1;const h=new Set,u=p=>{c<0&&(c=0),p.subpath=c,n.push(p)};for(const{type:p,args:g}of rc(e)){const y=p.toUpperCase(),w=p!==y,k=sc[y];if(y==="Z"){(i!==r||s!==o)&&u(ye(i,s,r,o)),c>=0&&h.add(c),i=r,s=o,a=l=null;continue}for(let M=0;M+k<=g.length;M+=k){const S=g.slice(M,M+k),A=w?i:0,E=w?s:0;let T=null,v=null;switch(y){case"M":M===0?(i=S[0]+A,s=S[1]+E,r=i,o=s,(c<0||n[n.length-1]?.subpath===c)&&c++):(u(ye(i,s,S[0]+A,S[1]+E)),i=S[0]+A,s=S[1]+E);break;case"L":u(ye(i,s,S[0]+A,S[1]+E)),i=S[0]+A,s=S[1]+E;break;case"H":u(ye(i,s,S[0]+A,s)),i=S[0]+A;break;case"V":u(ye(i,s,i,S[0]+E)),s=S[0]+E;break;case"C":{const _=[S[0]+A,S[1]+E,S[2]+A,S[3]+E,S[4]+A,S[5]+E];u(Je(i,s,_)),T=[_[2],_[3]],i=_[4],s=_[5];break}case"S":{const[_,P]=a?[2*i-a[0],2*s-a[1]]:[i,s],x=[_,P,S[0]+A,S[1]+E,S[2]+A,S[3]+E];u(Je(i,s,x)),T=[x[2],x[3]],i=x[4],s=x[5];break}case"Q":case"T":{let _=i,P=s;y==="Q"?(_=S[0]+A,P=S[1]+E):l&&(_=2*i-l[0],P=2*s-l[1]);const x=y==="Q"?S[2]+A:S[0]+A,I=y==="Q"?S[3]+E:S[1]+E;u(Je(i,s,[i+2/3*(_-i),s+2/3*(P-s),x+2/3*(_-x),I+2/3*(P-I),x,I])),v=[_,P],i=x,s=I;break}case"A":{const _=S[5]+A,P=S[6]+E;let x=i,I=s;for(const C of oc(i,s,S[0],S[1],S[2],S[3],S[4],_,P))u(Je(x,I,C)),x=C[4],I=C[5];i=_,s=P;break}}a=T,l=v}}const f=n.reduce((p,g)=>p+g.length,0),d=[];for(let p=0;p<n.length;){const g=n[p].subpath;let y=p,w=0;for(;y<n.length&&n[y].subpath===g;)w+=n[y++].length;const k=n[p],M=n[y-1],S=h.has(g)||Math.abs(M.endX-k.startX)<1e-9&&Math.abs(M.endY-k.startY)<1e-9;d.push({start:p,end:y,length:w,closed:S}),p=y}const m={segments:n,totalLength:f,subpaths:d};return Yt.size>=ec&&Yt.delete(Yt.keys().next().value),Yt.set(e,m),m}function ac(e,t){const n=e.lengths;if(t<=0)return 0;if(t>=e.length)return 1;let i=0,s=n.length-1;for(;i<s-1;){const a=i+s>>1;n[a]<t?i=a:s=a}const r=n[s]-n[i],o=r>0?(t-n[i])/r:0;return(i+o)/(n.length-1)}function lc(e,t){if(e.type==="L"){const u=e.length>0?Math.max(0,Math.min(1,t/e.length)):0;return{x:e.startX+(e.endX-e.startX)*u,y:e.startY+(e.endY-e.startY)*u,angle:Math.atan2(e.endY-e.startY,e.endX-e.startX)*180/Math.PI}}const[n,i,s,r,o,a]=e.points,l=ac(e,t);let c=Gs(e.startX,n,s,o,l),h=Gs(e.startY,i,r,a,l);if(Math.hypot(c,h)<1e-9){const u=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),f=yt(e.startX,n,s,o,u),d=yt(e.startY,i,r,a,u),m=yt(e.startX,n,s,o,l),p=yt(e.startY,i,r,a,l);c=l<.5?f-m:m-f,h=l<.5?d-p:p-d}return{x:yt(e.startX,n,s,o,l),y:yt(e.startY,i,r,a,l),angle:Math.atan2(h,c)*180/Math.PI}}function ei(e,t,n=0,i=e.length){if(i<=n)return{x:0,y:0,angle:0};let s=0;for(let r=n;r<i;r++){const o=e[r];if(s+o.length>=t||r===i-1)return lc(o,t-s);s+=o.length}return{x:0,y:0,angle:0}}function js(e,t){const{segments:n,totalLength:i}=Pt(e);return ei(n,Math.max(0,Math.min(1,t))*i)}function cc(){Yt.clear()}function hc(e){return Pt(e).totalLength}const uc=24,fc=320,dc=2.5,be=72,pc=64,mc=.2,gc=128,we=new Map;let Ze=0,bt;const Js=e=>Math.round(e*100)/100;function Zs(e,t){const{segments:n,subpaths:i,totalLength:s}=Pt(e);if(n.length===0)return[];if(t){const r=i.every(o=>o.closed);return[{segments:n,start:0,end:n.length,length:s,closed:r}]}return i.filter(r=>r.length>0).map(r=>({segments:n,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function ni(e,t){const n=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),i=ei(e.segments,n*e.length,e.start,e.end);return[i.x,i.y]}function Qs(e){const t=[];let n=0;for(let i=e.start;i<e.end;i++)n+=e.segments[i].length,e.length>0&&t.push(n/e.length);return t}function tr(e,t){const n=[];for(let i=0;i<t;i++)n.push(ni(e,e.closed?i/t:i/(t-1)));return n}function er(e){let t=0,n=0;for(const[i,s]of e)t+=i,n+=s;return t/=e.length,n/=e.length,e.map(([i,s])=>[i-t,s-n])}function yc(e,t,n){const i=e.closed&&t.closed;if(n!==void 0)return{offset:i?Math.abs(n)%be/be:0,reversed:n<0};const s=er(tr(e,be)),r=er(tr(t,be)),o=be;let a={offset:0,reversed:!1},l=1/0;for(const c of[!1,!0]){const h=i?o:1;for(let u=0;u<h;u++){let f=0;for(let d=0;d<o&&f<l;d++){const m=i?c?(u-d+o)%o:(d+u)%o:c?o-1-d:d,p=s[d][0]-r[m][0],g=s[d][1]-r[m][1];f+=p*p+g*g}f<l&&(l=f,a={offset:i?u/o:0,reversed:c})}}return a}function bc(e,t,n){return n?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function wc(e,t,n){return n?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function kc(e,t,n){const i=e.closed&&t.closed,s=yc(e,t,n.shapeIndex),r=Math.max(uc,Math.min(fc,Math.ceil(Math.max(e.length,t.length)/dc))),o=new Set,a=u=>o.add(Math.round(u*1e7)/1e7);for(let u=0;u<=r;u++)a(u/r);for(const u of Qs(e))a(u);for(const u of Qs(t))a(wc(u,s,i));let l=[...o].sort((u,f)=>u-f);i&&(l=l.filter(u=>u<1));const c=[],h=[];for(const u of l)c.push(...ni(e,u)),h.push(...ni(t,bc(u,s,i)));return vc({from:c,to:h,closed:i})}function vc(e){const t=e.from.length/2;if(t<=3)return e;const n=new Uint8Array(t);n[0]=1,n[t-1]=1;const i=[[0,t-1]];for(;i.length>0;){const[o,a]=i.pop();let l=-1,c=mc;for(let h=o+1;h<a;h++){const u=Math.max(nr(e.from,o,a,h),nr(e.to,o,a,h));u>c&&(c=u,l=h)}l!==-1&&(n[l]=1,i.push([o,l],[l,a]))}const s=[],r=[];for(let o=0;o<t;o++)n[o]&&(s.push(e.from[o*2],e.from[o*2+1]),r.push(e.to[o*2],e.to[o*2+1]));return{from:s,to:r,closed:e.closed}}function nr(e,t,n,i){const s=e[t*2],r=e[t*2+1],o=e[n*2]-s,a=e[n*2+1]-r,l=e[i*2]-s,c=e[i*2+1]-r,h=o*o+a*a,u=h===0?0:Math.max(0,Math.min(1,(l*o+c*a)/h));return Math.hypot(l-u*o,c-u*a)}function Sc(e,t,n){const i=n.shapeIndex;if(bt&&bt.from===e&&bt.to===t&&bt.shapeIndex===i)return bt.plan;const r=we.get(String(i??"auto"))?.get(e)?.get(t);if(r)return bt={from:e,to:t,shapeIndex:i,plan:r},r;const o=Pt(e).subpaths.filter(d=>d.length>0).length===Pt(t).subpaths.filter(d=>d.length>0).length,a=Zs(e,!o),l=Zs(t,!o),c={pairs:a.map((d,m)=>kc(d,l[m],n))};Ze>=gc&&(we.clear(),Ze=0);const h=String(i??"auto"),u=we.get(h)??new Map;we.set(h,u);const f=u.get(e)??new Map;return u.set(e,f),f.set(t,c),Ze++,bt={from:e,to:t,shapeIndex:i,plan:c},c}function ir(e,t,n,i={}){if(!e)return t;if(!t)return e;const s=Math.max(0,Math.min(1,n));if(s===0)return e;if(s===1)return t;const r=Sc(e,t,i);if(r.pairs.length===0)return s<.5?e:t;let o="";for(const a of r.pairs){for(let l=0;l<a.from.length;l+=2){const c=Js(a.from[l]+(a.to[l]-a.from[l])*s),h=Js(a.from[l+1]+(a.to[l+1]-a.from[l+1])*s);o+=`${l===0?o?" M":"M":" L"}${c} ${h}`}a.closed&&(o+=" Z")}return o}function Mc(){we.clear(),Ze=0,bt=void 0}function Xt(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const qt=Math.PI/180,Tc=.9995;function ii(){return[0,0,0,1]}function Vt(e,t){const n=Math.hypot(e[0],e[1],e[2]);if(n===0)return ii();const i=t*qt/2,s=Math.sin(i)/n;return[e[0]*s,e[1]*s,e[2]*s,Math.cos(i)]}function Ec(e,t,n){return si(si(Vt([0,1,0],t),Vt([1,0,0],e)),Vt([0,0,1],n))}function Ac(e){const[t,n,i,s]=wt(e),r=2*(t*i+n*s),o=2*(t*n+i*s),a=1-2*(t*t+i*i),l=2*(n*i-t*s),c=1-2*(n*n+i*i),h=2*(t*i-n*s),u=1-2*(t*t+n*n),f=Math.asin(Math.max(-1,Math.min(1,-l)));return Math.abs(l)<.9999999?[f/qt,Math.atan2(r,u)/qt,Math.atan2(o,a)/qt]:[f/qt,Math.atan2(-h,c)/qt,0]}function si(e,t){const[n,i,s,r]=e,[o,a,l,c]=t;return[r*o+n*c+i*l-s*a,r*a-n*l+i*c+s*o,r*l+n*a-i*o+s*c,r*c-n*o-i*a-s*l]}function sr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function rr(e){return Math.hypot(e[0],e[1],e[2],e[3])}function wt(e){const t=rr(e);return t===0?ii():[e[0]/t,e[1]/t,e[2]/t,e[3]/t]}function xc(e){return[-e[0],-e[1],-e[2],e[3]]}function or(e,t,n){const i=wt(e);let s=wt(t),r=sr(i,s);if(r<0&&(s=[-s[0],-s[1],-s[2],-s[3]],r=-r),r>Tc)return wt([i[0]+(s[0]-i[0])*n,i[1]+(s[1]-i[1])*n,i[2]+(s[2]-i[2])*n,i[3]+(s[3]-i[3])*n]);const o=Math.acos(r),a=Math.sin(o),l=Math.sin((1-n)*o)/a,c=Math.sin(n*o)/a;return wt([i[0]*l+s[0]*c,i[1]*l+s[1]*c,i[2]*l+s[2]*c,i[3]*l+s[3]*c])}function Pc(e,t){const[n,i,s,r]=wt(e),o=2*(i*t[2]-s*t[1]),a=2*(s*t[0]-n*t[2]),l=2*(n*t[1]-i*t[0]);return[t[0]+r*o+(i*l-s*a),t[1]+r*a+(s*o-n*l),t[2]+r*l+(n*a-i*o)]}const _c=Object.freeze(Object.defineProperty({__proto__:null,conjugate:xc,dot:sr,fromAxisAngle:Vt,fromEuler:Ec,identity:ii,length:rr,multiply:si,normalize:wt,rotateVec3:Pc,slerp:or,toEuler:Ac},Symbol.toStringTag,{value:"Module"})),lt=(e,t,n)=>e+(t-e)*n,ar=512,ri=new Map,oi=new Map;function lr(e){const t=ri.get(e);if(t)return t;const n=e.replace("#",""),i=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return ri.size<ar&&ri.set(e,i),i}const cr=e=>e.charCodeAt(0)===35,hr=e=>e.startsWith("rgb"),ur=e=>e.startsWith("rgba"),Ic=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,ai=e=>Math.round(e).toString(16).padStart(2,"0");function Cc(e,t,n){return`#${ai(e)}${ai(t)}${ai(n)}`}function fr(e){const t=oi.get(e);if(t)return t;const n=e.match(Ic);if(!n)throw new Error(`Invalid rgb color: ${e}`);const i=parseInt(n[1],10),s=parseInt(n[2],10),r=parseInt(n[3],10),o=n[4]!==void 0?[i,s,r,parseFloat(n[4])]:[i,s,r];return oi.size<ar&&oi.set(e,o),o}const dr=(e,t,n)=>{if(cr(e)&&cr(t)){const[i,s,r]=lr(e),[o,a,l]=lr(t),c=lt(i,o,n),h=lt(s,a,n),u=lt(r,l,n);return Cc(c,h,u)}if((hr(e)||ur(e))&&(hr(t)||ur(t))){const i=fr(e),s=fr(t),r=Math.round(lt(i[0],s[0],n)),o=Math.round(lt(i[1],s[1],n)),a=Math.round(lt(i[2],s[2],n));if(i.length===4||s.length===4){const l=i[3]??1,c=s[3]??1,h=lt(l,c,n);return`rgba(${r}, ${o}, ${a}, ${h})`}return`rgb(${r}, ${o}, ${a})`}return n<1?e:t},pr=(e,t,n)=>{const i=Math.min(e.length,t.length),s=[];for(let r=0;r<i;r++)s.push(lt(e[r],t[r],n));return s},mr=(e,t,n)=>or(e,t,n),li=(e,t,n)=>n<1?e:t,gr=(e,t,n)=>ir(e,t,n);function ke(e,t){return t==="slerp"?mr:typeof e=="number"?lt:Array.isArray(e)?pr:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?dr:Xt(e)?gr:li:li}const ci=1e3/60;function hi(e,t={}){if(!gt(e))throw new Error(`bakeSpringTrack: track "${e.id}" is not a spring track`);const n=new pe(e.spring);return yr(e,i=>n.valueAt(i),n.settleTime(),e.spring.from,e.spring.to,t)}function ui(e,t={}){if(!mt(e))throw new Error(`bakeInertiaTrack: track "${e.id}" is not an inertia track`);const n=e.inertia;return yr(e,i=>Ge(n,i),Kt(n),n.from,Wt(n),t)}function yr(e,t,n,i,s,r){const o=r.intervalMs??ci,a=r.tolerance??.01,l=e.delay??0,c=[];for(let u=0;u<=n;u+=o)c.push({time:u+l,value:t(u),easing:"linear"});const h=c[c.length-1];return!h||h.time<n+l?c.push({time:n+l,value:s,easing:"linear"}):h.value=s,l>0&&c.unshift({time:0,value:i,easing:"linear"}),{id:e.id,target:e.target,property:e.property,keyframes:a>0?wr(c,a):c,...e.targets&&{targets:[...e.targets]},...e.stagger&&{stagger:{...e.stagger}}}}function fi(e,t,n,i={}){const s=i.intervalMs??ci,r=typeof n=="function"?n:J(n),o=ke(e.value,i.interpolation),a=t.time-e.time;if(a<=0)return[t];const l=[];for(let h=s;h<a;h+=s){const u=h/a;l.push({time:e.time+h,value:o(e.value,t.value,r(u)),easing:"linear"})}const c=r(1);return l.push({...t,...c!==1&&{value:o(e.value,t.value,c)},easing:"linear"}),l}function Hc(e,t){return gt(e)?hi(e,t):mt(e)?ui(e,t):e}function br(e,t={}){const n=e.keyframes;if(!n.some(r=>fe(r.easing)))return e;const i=n.length>0?[n[0]]:[],s={...t,interpolation:e.interpolation??t.interpolation};for(let r=1;r<n.length;r++){const o=n[r];fe(o.easing)?i.push(...fi(n[r-1],o,o.easing,s)):i.push(o)}return{...e,keyframes:i}}function $c(e,t){return e.filter(Hs).map(n=>br(n,t)).concat(e.filter(gt).map(n=>hi(n,t)),e.filter(mt).map(n=>ui(n,t)))}function wr(e,t){if(e.length<=2)return e;const n=[e[0]];for(let i=1;i<e.length-1;i++){const s=n[n.length-1],r=e[i],o=e[i+1],a=o.time-s.time;if(a<=0)continue;const l=(r.time-s.time)/a,c=s.value+(o.value-s.value)*l;Math.abs(r.value-c)>t&&n.push(r)}return n.push(e[e.length-1]),n}function Qe(e){const t=[...e.keyframes].sort((n,i)=>n.time-i.time);return{...e,keyframes:t}}function kt(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function Ut(e,t,n,i){const s=n??0;return!i||t<=1?s:s+Xe(e,t,i)}class tn{track;targets;constructor(t){this.track=t,this.targets=kt(t)}getValueAtTime(t){return this.valueForOffset(t-Ut(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=Ut(s,n,this.track.delay,this.track.stagger),o=this.valueForOffset(t-r);o!==void 0&&i.push({target:this.targets[s],value:o,start:r+this.track.keyframes[0].time})}return i}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const n=t[t.length-1].time,i=this.track.stagger?de(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+i+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:n}=this.track;if(n.length===0)return;if(n.length===1||t<=n[0].time)return n[0].value;if(t>=n[n.length-1].time)return n[n.length-1].value;const{from:i,to:s}=this.findSurroundingKeyframes(t);if(!i||!s)return;if(i.time===t)return i.value;const r=s.time-i.time,o=(t-i.time)/r,l=J(s.easing)(o);return ke(i.value,this.track.interpolation)(i.value,s.value,l)}findSurroundingKeyframes(t){const{keyframes:n}=this.track;for(let i=0;i<n.length-1;i++)if(t>=n[i].time&&t<=n[i+1].time)return{from:n[i],to:n[i+1]};return{from:null,to:null}}}class kr{track;targets;sampler;constructor(t){this.track=t,this.targets=kt(t),this.sampler=new pe(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-Ut(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=Ut(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:this.sampler.valueAt(t-r),start:r})}return i}getDuration(){const t=this.track.stagger?de(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class vr{track;targets;duration;constructor(t){this.track=t,this.targets=kt(t),this.duration=Kt(t.inertia)}getValueAtTime(t){return Ge(this.track.inertia,t-Ut(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=Ut(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:Ge(this.track.inertia,t-r),start:r})}return i}getDuration(){const t=this.track.stagger?de(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function di(e,t){const n={...js(e.pathData,t)};if(e.matrix){const[i,s,r,o,a,l]=e.matrix,{x:c,y:h}=n;n.x=i*c+r*h+a,n.y=s*c+o*h+l;const u=n.angle*Math.PI/180,f=Math.cos(u),d=Math.sin(u);n.angle=Math.atan2(s*f+o*d,i*f+r*d)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(n.angle+=e.rotateOffset),n}function Rc(e,t,n,i){const s=t+(n-t)*i;return di(e,s)}const pi={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},Oc=20;function Sr(e){const t=pi[e??"upperCase"]??e??pi.upperCase,n=Array.from(t);return n.length>0?n:Array.from(pi.upperCase)}function Lc(e,t,n){let i=(e|0)^Math.imul(t+1,2654435761)^Math.imul(n+1,2246822507);return i=Math.imul(i^i>>>16,2146121005),i=Math.imul(i^i>>>15,2221713035),(i^i>>>16)>>>0}function Mr(e,t,n=0){const i=e.from??"",s=e.to,r=Math.max(0,Math.min(1,t));if(r<=0)return i;if(r>=1)return s;const o=Array.from(i),a=Array.from(s),l=e.rightToLeft??!1;if(e.mode==="type"){const w=Math.round(r*Math.max(o.length,a.length));return l?o.slice(0,Math.max(0,o.length-w)).join("")+a.slice(Math.max(0,a.length-w)).join(""):a.slice(0,w).join("")+o.slice(w).join("")}const c=Math.max(0,Math.min(.999,e.revealDelay??0)),h=Math.max(0,(r-c)/(1-c)),u=Math.floor(h*a.length),f=e.tweenLength===!1?a.length:Math.round(o.length+(a.length-o.length)*r),d=Sr(e.chars),m=e.refreshRate??Oc,p=m>0?Math.floor(n*m/1e3):0,g=e.seed??1;let y="";for(let w=0;w<f;w++){const k=l?w>=f-u:w<u,M=l?a[a.length-(f-w)]:a[w];k&&M!==void 0||M===" "||M===`
|
|
2
|
-
`?y+=M:y+=d[Lc(g,w,p)%d.length]}return y}class ve{id;name;_captions;_tracks=[];_trackPlayers=new Map;_motionPathTracks=new Map;_springTracks=new Map;_textTracks=new Map;_config;_currentTime=0;_playbackState="idle";_direction="forward";_loopIteration=0;_explicitDuration;_repeatDelayRemaining=0;_wrapAfterDelay=!1;onUpdate=null;onComplete=null;constructor(t){if(this.id=t.id,this.name=t.name,this._captions=t.captions,this._config=t.config??{},this._explicitDuration=t.config?.duration,t.tracks)for(const n of t.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(t){if(this._explicitDuration=t,t!==void 0)this._config={...this._config,duration:t};else if(this._config.duration!==void 0){const n={...this._config};delete n.duration,this._config=n}}get currentTime(){return this._currentTime}get playbackState(){return this._playbackState}get direction(){return this._direction}get loopIteration(){return this._loopIteration}get repeatDelayRemaining(){return this._repeatDelayRemaining}get speed(){return this._config.speed??1}set speed(t){this._config.speed=t}get drawingRate(){return this._config.drawingRate??0}set drawingRate(t){const n={...this._config};t>0?n.drawingRate=t:delete n.drawingRate,this._config=n}play(){const t=this.duration;this._direction==="forward"&&this._currentTime>=t&&t>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&t>0&&(this._currentTime=t,this._loopIteration=0),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="idle",this._repeatDelayRemaining=0,this._wrapAfterDelay=!1,this._currentTime=0,this._loopIteration=0,this._direction="forward"}seek(t){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let s=t*this.speed;if(this._repeatDelayRemaining>0){const a=Math.min(this._repeatDelayRemaining,s);if(this._repeatDelayRemaining-=a,s-=a,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const r=1e3;for(let a=0;a<r&&s>0&&this._playbackState==="playing";a++)if(this._direction==="forward"){const l=n-this._currentTime;if(s>=l){if(s-=l,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=s,s=0}else{const l=this._currentTime;if(s>=l){if(s-=l,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=s,s=0}const o=this.getStateAtTime(this._currentTime);this.onUpdate?.(o)}getStateAtTime(t){const n=new Map;if(t=$s(t,this._config.drawingRate??0),this._hasSharedWrites())this._resolveShared(t,n);else for(const[i,s]of this._trackPlayers){const r=s.getTrack().property;for(const{target:o,value:a,start:l}of s.getTargetValues(t))this._write(n,i,o,r,a,t-l)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,n){const i=new Map;for(const[s,r]of this._trackPlayers){const o=r.getTrack().property;for(const{target:a,value:l,start:c}of r.getTargetValues(t)){const h=`${a}\0${o}`,u=c<=t,f=i.get(h);(!f||(u!==f.started?u:u?c>=f.start:c<=f.start))&&i.set(h,{trackId:s,target:a,property:o,value:l,start:c,started:u})}}for(const{trackId:s,target:r,property:o,value:a,start:l}of i.values())this._write(n,s,r,o,a,t-l)}_write(t,n,i,s,r,o){if(r===void 0)return;let a=t.get(i);a||(a=new Map,t.set(i,a));const l=this._textTracks.get(n);if(l&&typeof r=="number"){a.set("text",Mr(l.textConfig,r,Math.max(0,o)));return}const c=this._motionPathTracks.get(n);if(c&&typeof r=="number"){const h=di(c.motionPathConfig,r);a.set("motionPathX",h.x),a.set("motionPathY",h.y),c.motionPathConfig.autoRotate&&a.set("motionPathRotate",h.angle)}else a.set(s,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const i of kt(n)){const s=`${i}\0${n.property}`;if(t.has(s)){this._sharedWrites=!0;break t}t.add(s)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,mt(t)){this._trackPlayers.set(t.id,new vr(t));return}if(gt(t)){this._trackPlayers.set(t.id,new kr(t)),this._springTracks.set(t.id,t);return}if(Ye(t))this._trackPlayers.set(t.id,new tn(t)),this._textTracks.set(t.id,t);else if(Un(t)){const n={id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,delay:t.delay,endDelay:t.endDelay,targets:t.targets,stagger:t.stagger};this._trackPlayers.set(t.id,new tn(n)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new tn(t))}replaceTrack(t,n){const i=this._tracks.findIndex(r=>r.id===t);if(i<0)return;const s=this._tracks.slice(i+1);this.removeTrack(t);for(const r of s)this.removeTrack(r.id);this.addTrack(n);for(const r of s)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(n=>n.id!==t),this._sharedWrites=null,this._trackPlayers.delete(t),this._motionPathTracks.delete(t),this._springTracks.delete(t),this._textTracks.delete(t)}getTracks(t={}){return this._tracks.filter(n=>this._matches(n,t))}removeTracks(t={}){const n=this.getTracks(t).map(i=>i.id);for(const i of n)this.removeTrack(i);return n}getTrackSpan(t){const n=this._trackPlayers.get(t);if(!n)return;const i=n.getTrack(),s=i.delay??0;if(gt(i)||mt(i))return{from:s,to:n.getDuration()};const r=i.keyframes;if(!(!r||r.length===0))return{from:r[0].time+s,to:n.getDuration()}}findConflicts(){const t=[];for(let n=0;n<this._tracks.length;n++){const i=this._tracks[n],s=this.getTrackSpan(i.id);if(s)for(let r=0;r<n;r++){const o=this._tracks[r];if(o.property!==i.property)continue;const a=kt(o).filter(u=>kt(i).includes(u));if(a.length===0)continue;const l=this.getTrackSpan(o.id);if(!l||!(l.from<=s.to&&s.from<=l.to))continue;const h=s.from>=l.from;for(const u of a)t.push({target:u,property:i.property,losingTrackId:h?o.id:i.id,winningTrackId:h?i.id:o.id})}}return t}_matches(t,n){if(n.id!==void 0&&t.id!==n.id||n.property!==void 0&&t.property!==n.property||n.target!==void 0&&!kt(t).includes(n.target))return!1;if(n.timeRange){const i=this.getTrackSpan(t.id);if(!i||i.to<n.timeRange.from||i.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:Vn(this._tracks),id:this.id,name:this.name,config:{...this._config},tracks:[...this._tracks],...this.captions&&{captions:this.captions}}}get config(){return this._config}get markers(){return[...this._config.markers??[]].sort((t,n)=>t.time-n.time)}setMarkers(t){const n=t&&t.length>0?[...t].sort((s,r)=>s.time-r.time).map(s=>({...s})):void 0,i={...this._config};n?i.markers=n:delete i.markers,this._config=i}get captions(){return this._captions}setCaptions(t){const n={};for(const[i,s]of Object.entries(t??{}))n[i]={...s};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,n]of this._trackPlayers)t=Math.max(t,n.getDuration());return t}_handleEndReached(){const t=this._config.loop??0;return t===-1||this._loopIteration<t?(this._loopIteration++,this._armRepeatDelay(),this._config.alternate?this._direction="reverse":this._repeatDelayRemaining>0?this._wrapAfterDelay=!0:this._currentTime=0,this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}_handleStartReached(){const t=this._config.loop??0;return this._config.alternate&&(t===-1||this._loopIteration<t)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const Fc=100;function mi(e,t,n,i){const s=[],r=[],{duration:o,alternate:a}=i,l=(d,m,p,g)=>{r.push([d,m]);const y=[];e.forEach((w,k)=>{(p==="forward"?(g?w>=d:w>d)&&w<=m:(g?w<=d:w<d)&&w>=m)&&y.push(k)}),y.sort((w,k)=>(p==="forward"?e[w]-e[k]:e[k]-e[w])||w-k);for(const w of y)s.push({kind:"event",index:w,direction:p})};let c=t.time,h=t.direction,u=t.fresh===!0;const f=Math.min(Fc,Math.max(0,n.iteration-t.iteration));for(let d=0;d<f;d++){const m=h==="forward"?o:0;l(c,m,h,u),s.push({kind:"repeat"}),a?(h=h==="forward"?"reverse":"forward",c=m,u=!1):(c=h==="forward"?0:o,u=!0)}return f>0&&i.holding&&!a?{crossings:s,passes:r}:(l(c,n.time,h,u),{crossings:s,passes:r})}function Tr(e){return mt(e)?{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:Er(e.inertia),...ct(e)}:gt(e)?{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...ct(e)}:Ye(e)?{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:e.keyframes.map(gi),...ct(e)}:Un(e)?{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:e.keyframes.map(gi),...ct(e)}:{id:e.id,target:e.target,property:e.property,keyframes:e.keyframes.map(gi),...e.interpolation!==void 0&&{interpolation:e.interpolation},...ct(e)}}function Er(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function gi(e){return{time:e.time,value:e.value,...e.easing&&{easing:e.easing}}}function ct(e){const t=e.endDelay;return{...e.delay!==void 0&&{delay:e.delay},...t!==void 0&&{endDelay:t},...e.targets!==void 0&&{targets:[...e.targets]},...e.stagger!==void 0&&{stagger:{...e.stagger}}}}function Ar(e){if(mt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Er(t.inertia),...ct(t)}}if(gt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...ct(t)}}if(Ye(e)){const t=e;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((n,i)=>n.time-i.time),...ct(t)}}if(e.property==="motionPath"&&"motionPathConfig"in e){const t=e,n=[...t.keyframes].sort((i,s)=>i.time-s.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:n,...ct(t)}}return Qe({id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,...e.interpolation!==void 0&&{interpolation:e.interpolation},...ct(e)})}function xr(e){const t=e._config.markers;return{formatVersion:Vn(e.tracks),id:e.id,name:e.name,config:{duration:e.duration>0?e.duration:void 0,loop:e._config.loop,speed:e._config.speed,alternate:e._config.alternate,repeatDelay:e._config.repeatDelay,...e._config.drawingRate?{drawingRate:e._config.drawingRate}:{},...t&&{markers:t.map(n=>({...n}))}},tracks:e.tracks.map(Tr),...e.captions&&{captions:JSON.parse(JSON.stringify(e.captions))}}}function zt(e){const t=e.formatVersion??1;if(t>qn)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${qn}. Update tinyfly to play it.`);return new ve({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(Ar),captions:e.captions})}function Dc(e){return JSON.stringify(xr(e))}function Bc(e){const t=JSON.parse(e);return zt(t)}function Gt(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function Se(e){let t=e>>>0||2654435769;return{seed:e>>>0,next(){return t^=t<<13,t>>>=0,t^=t>>17,t^=t<<5,t>>>=0,t/4294967296}}}function yi(e,t,n){return t+e.next()*(n-t)}function Pr(e,t,n,i){if(i<=0)return yi(e,t,n);const s=Math.floor((n-t)/i),r=Math.round(e.next()*s);return t+r*i}function Nc(e,t){if(t.length!==0)return t[Math.floor(e.next()*t.length)]}const _r=/^([+\-*/])=\s*(-?[\d.]+)$/,Ir=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Wc(e){return typeof e!="string"?!1:_r.test(e.trim())||Ir.test(e.trim())}function bi(e,t={}){if(typeof e!="string")return e;const n=e.trim(),i=_r.exec(n);if(i){const[,r,o]=i,a=t.base??0,l=Number.parseFloat(o);switch(r){case"+":return a+l;case"-":return a-l;case"*":return a*l;case"/":return l===0?a:a/l}}const s=Ir.exec(n);if(s){if(!t.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const r=Number.parseFloat(s[1]),o=Number.parseFloat(s[2]),a=s[3]!==void 0?Number.parseFloat(s[3]):void 0;return a!==void 0?Pr(t.random,r,o,a):yi(t.random,r,o)}return e}function Cr(e,t=0,n){const i=[];let s=t;for(const r of e){const o=bi(r,{base:s,random:n});i.push(o),typeof o=="number"&&(s=o)}return i}class Kc{random;constructor(t){this.random=Se(t)}get seed(){return this.random.seed}resolve(t,n=0){return bi(t,{base:n,random:this.random})}resolveSequence(t,n=0){return Cr(t,n,this.random)}}const Yc=600;function Hr(e){if(Array.isArray(e)){const[f,d,m,p]=e;return{fn:Or(f,d,m,p),bezier:[f,d,m,p]}}const{segments:t}=Pt(e);if(t.length===0)throw new Error(`customEase: no curve in "${e}"`);const n=t[0].startX,i=t[0].startY,s=t[t.length-1],r=s.endX-n,o=s.endY-i;if(r===0||o===0)throw new Error(`customEase: "${e}" must move along both axes`);const a=f=>(f-n)/r,l=f=>(f-i)/o;if(t.length===1&&s.type==="C"){const[f,d,m,p]=s.points,g=[a(f),l(d),a(m),l(p)];return{fn:Or(...g),bezier:g}}const c=[],h=[],u=Math.max(8,Math.ceil(Yc/t.length));for(const f of t)for(let d=c.length===0?0:1;d<=u;d++){const[m,p]=Xc(f,d/u);c.push(a(m)),h.push(l(p))}return{fn:qc(c,h)}}function $r(e={}){const n=.1+Math.max(0,Math.min(1,e.strength??.7))*.7,i=[1];for(let r=n;r>.002;r*=n)i.push(2*Math.sqrt(r));const s=i.reduce((r,o)=>r+o,0);return r=>{if(r<=0)return 0;if(r>=1)return 1;let o=r*s;for(let a=0;a<i.length;a++){if(o<=i[a]){if(a===0)return(o/i[0])**2;const l=i[a]/2,c=l*l,h=o-l;return 1-(c-h*h)}o-=i[a]}return 1}}function Rr(e={}){const t=Math.max(1,e.wiggles??10),n=e.type??"easeOut",i=s=>n==="uniform"?1:n==="easeInOut"?Math.sin(Math.PI*s):(1-s)**2;return s=>s<=0||s>=1?0:Math.sin(s*t*Math.PI*2)*i(s)}function Xc(e,t){if(e.type==="L"){const[c,h]=e.points;return[e.startX+(c-e.startX)*t,e.startY+(h-e.startY)*t]}const[n,i,s,r,o,a]=e.points,l=1-t;return[l*l*l*e.startX+3*l*l*t*n+3*l*t*t*s+t*t*t*o,l*l*l*e.startY+3*l*l*t*i+3*l*t*t*r+t*t*t*a]}function qc(e,t){return n=>{if(n<=e[0])return t[0];if(n>=e[e.length-1])return t[t.length-1];let i=0,s=e.length-1;for(;s-i>1;){const o=i+s>>1;e[o]<=n?i=o:s=o}const r=e[s]-e[i];return r===0?t[s]:t[i]+(n-e[i])/r*(t[s]-t[i])}}function Or(e,t,n,i){const s=(o,a,l)=>3*(1-o)*(1-o)*o*a+3*(1-o)*o*o*l+o*o*o,r=(o,a,l)=>3*(1-o)*(1-o)*a+6*(1-o)*o*(l-a)+3*o*o*(1-l);return o=>{if(o<=0)return 0;if(o>=1)return 1;let a=o;for(let h=0;h<8;h++){const u=s(a,e,n)-o,f=r(a,e,n);if(Math.abs(u)<1e-6)return s(a,t,i);if(Math.abs(f)<1e-6)break;a-=u/f}let l=0,c=1;a=o;for(let h=0;h<40;h++)s(a,e,n)<o?l=a:c=a,a=(l+c)/2;return s(a,t,i)}}const Vc=350,Uc=300,zc=550;function Gc(e,t={}){const n=t.lead??Vc,i=t.gap??Uc,s=t.tail??zc,r=[];let o=0;return e.forEach((a,l)=>{const c=[];let h=o+n;a.lines.forEach((f,d)=>{if(!(f.duration>=0))throw new Error(`narration: scene ${l} line ${d} has an invalid duration (${f.duration})`);d>0&&(h+=i),c.push({id:f.id??`s${l}-l${d}`,scene:l,line:d,start:h,end:h+f.duration,text:f.text}),h+=f.duration});const u=h+s+(a.tail??0);r.push({id:a.id??`s${l}`,start:o,duration:u-o,cues:c}),o=u}),{duration:o,scenes:r,cues:r.flatMap(a=>a.cues)}}function jc(e){return e.cues.map(t=>({id:t.id,time:t.start,label:t.text}))}function Jc(e,t){let n=e.scenes[0];for(const i of e.scenes)if(t>=i.start)n=i;else break;return n}const wi=e=>6e4/e.bpm;function en(e,t){return e.offset+t*wi(e)}function nn(e,t){return(t-e.offset)/wi(e)}function Zc(e,t){return en(e,Math.round(nn(e,t)))}function Qc(e,t){return en(e,Math.ceil(nn(e,t)-1e-9))}function th(e,t,n){const i=Math.max(1,Math.round(e.beatsPerBar??4)),s=[];if(!(e.bpm>0)||n<t)return s;for(let r=Math.ceil(nn(e,t)-1e-9);;r++){const o=en(e,r);if(o>n+1e-9)break;s.push({time:o,bar:(r%i+i)%i===0,n:r})}return s}const jt=100;function eh(e,t,n={}){const i=n.minBpm??70,s=n.maxBpm??180,r=Math.max(1,Math.round(t/jt)),o=Math.min(e.length,Math.round((n.maxSeconds??60)*t)),a=Math.floor(o/r);if(a<4)return{bpm:120,offset:0,confidence:0};const l=new Float64Array(a);for(let v=0;v<a;v++){let _=0;for(let P=v*r;P<(v+1)*r;P++)_+=e[P]*e[P];l[v]=Math.log(1e-6+_/r)}const c=new Float64Array(a);for(let v=1;v<a;v++)c[v]=Math.max(0,l[v]-l[v-1]);const h=c.reduce((v,_)=>v+_,0)/a;for(let v=0;v<a;v++)c[v]=Math.max(0,c[v]-h);const u=Math.max(1,Math.floor(60*jt/s)),f=Math.min(a-1,Math.ceil(60*jt/i)),d=v=>{let _=0;for(let P=v;P<a;P++)_+=c[P]*c[P-v];return _/(a-v)};let m=0;for(let v=0;v<a;v++)m+=c[v]*c[v];m/=a;let p=u,g=-1/0;for(let v=u;v<=f;v++){const _=60*jt/v,P=Math.exp(-.5*(Math.log2(_/120)/.9)**2),x=d(v)*P;x>g&&(g=x,p=v)}const y=v=>{const _=Math.floor(v);return _<0||_+1>=a?0:c[_]+(c[_+1]-c[_])*(v-_)},w=(v,_)=>{let P=0;for(let x=_;x<a;x+=v)P+=y(x);return P};let k=p,M=0,S=-1/0;for(let v=p-.6;v<=p+.6+1e-9;v+=.02){if(v<1)continue;const _=Math.max(1,Math.round(v*4));for(let P=0;P<_;P++){const x=P/_*v,I=w(v,x);I>S&&(S=I,M=x,k=v)}}const A=60*jt/k,E=m>0?Math.max(0,Math.min(1,d(p)/m)):0,T=(M+.5)*1e3/jt;return{bpm:Math.round(A*100)/100,offset:Math.round(T%(6e4/A)),confidence:E}}const nh=600,ih=250,Lr=1;function sh(e,t){const n=t.target??"Camera",i={x:t.stage.width/2,y:t.stage.height/2},s={},r=(u,f,d,m)=>{const p=s[u]??=[];for(;p.length>0&&p[p.length-1].time>=f;)p.pop();p.push({time:f,value:d,...m?{easing:m}:{}})},o=u=>{const f=u.rotate*Math.PI/180,d=(u.focusX-i.x)*u.scale,m=(u.focusY-i.y)*u.scale;return{x:-(d*Math.cos(f)-m*Math.sin(f)),y:-(d*Math.sin(f)+m*Math.cos(f)),scale:u.scale,rotate:u.rotate}},a=(u,f,d)=>{const m=o(f);for(const p of["x","y","scale","rotate"])r(p,u,m[p],d)};let l={focusX:i.x,focusY:i.y,scale:1,rotate:0};const c=[...e].sort((u,f)=>u.at-f.at),h=c.filter(u=>!("shake"in u));h.length>0&&a(0,l);for(const u of h)if("frame"in u){const f=Math.max(Lr,u.duration??nh);a(u.at,l),l={focusX:u.frame.focus?.x??i.x,focusY:u.frame.focus?.y??i.y,scale:u.frame.scale??1,rotate:u.frame.rotate??0},a(u.at+f,l,u.easing??(f>Lr?"ease-in-out":void 0))}else{const{follow:f}=u,d=f.lag??ih,m=new ve({id:"follow",tracks:[{id:"x",target:"s",property:"x",keyframes:f.x}]}),p=w=>m.getStateAtTime(w).values.get("s")?.get("x")??l.focusX,g=[u.at,...f.x.map(w=>w.time).filter(w=>w>u.at&&w<u.until),u.until];a(u.at,l);const y=w=>({focusX:p(w)+(f.lead??0),focusY:f.y??l.focusY,scale:f.scale??l.scale,rotate:l.rotate});for(const w of g){const k=f.x.find(M=>M.time===w)?.easing;a(w+d,y(w),w===u.at?"ease-in-out":k)}l=y(u.until)}for(const u of c.filter(f=>"shake"in f)){const f=u.shake.strength??12,d=u.shake.roll??1.5,m=1e3/(u.shake.frequency??24),p=Se(u.shake.seed??Math.round(u.at)+1),g=()=>p.next()*2-1;for(const y of["shakeX","shakeY","shakeRotate"])r(y,u.at,0);for(let y=u.at+m;y<u.at+u.duration;y+=m){const w=1-(y-u.at)/u.duration;r("shakeX",y,g()*f*w),r("shakeY",y,g()*f*w),r("shakeRotate",y,g()*d*w)}for(const y of["shakeX","shakeY","shakeRotate"])r(y,u.at+u.duration,0,"ease-out")}return Object.entries(s).map(([u,f])=>({id:`${n}-${u}`,target:n,property:u,keyframes:f}))}const ht=e=>Math.round(e*1e3)/1e3;function Fr(e,t={}){if(e.length===0)return"";const n=t.curviness??1,i=t.closed??!1,s=e.length;let r=`M${ht(e[0].x)} ${ht(e[0].y)}`;if(s===1)return r;const o=l=>i?e[(l%s+s)%s]:e[Math.max(0,Math.min(s-1,l))],a=i?s:s-1;for(let l=0;l<a;l++){const c=o(l-1),h=o(l),u=o(l+1),f=o(l+2);if(n===0){r+=` L${ht(u.x)} ${ht(u.y)}`;continue}const d=n/6,m=h.x+(u.x-c.x)*d,p=h.y+(u.y-c.y)*d,g=u.x-(f.x-h.x)*d,y=u.y-(f.y-h.y)*d;r+=` C${ht(m)} ${ht(p)} ${ht(g)} ${ht(y)} ${ht(u.x)} ${ht(u.y)}`}return i?`${r} Z`:r}const V=(e,t=0)=>{const n=parseFloat(e??"");return Number.isFinite(n)?n:t};function rh(e){const t=(e??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let i=0;i+1<t.length;i+=2)n.push({x:t[i],y:t[i+1]});return n}function sn(e){const t=e.attributes;switch(e.tag.toLowerCase()){case"path":return t.d??null;case"circle":case"ellipse":{const n=V(t.cx),i=V(t.cy),s=e.tag.toLowerCase()==="circle"?V(t.r):V(t.rx),r=e.tag.toLowerCase()==="circle"?V(t.r):V(t.ry);return`M${n+s} ${i} A${s} ${r} 0 1 1 ${n-s} ${i} A${s} ${r} 0 1 1 ${n+s} ${i} Z`}case"rect":{const n=V(t.x),i=V(t.y),s=V(t.width),r=V(t.height);let o=t.rx!=null?V(t.rx):t.ry!=null?V(t.ry):0,a=t.ry!=null?V(t.ry):o;return o=Math.min(o,s/2),a=Math.min(a,r/2),o===0||a===0?`M${n} ${i} H${n+s} V${i+r} H${n} Z`:`M${n+o} ${i} H${n+s-o} A${o} ${a} 0 0 1 ${n+s} ${i+a} V${i+r-a} A${o} ${a} 0 0 1 ${n+s-o} ${i+r} H${n+o} A${o} ${a} 0 0 1 ${n} ${i+r-a} V${i+a} A${o} ${a} 0 0 1 ${n+o} ${i} Z`}case"line":return`M${V(t.x1)} ${V(t.y1)} L${V(t.x2)} ${V(t.y2)}`;case"polyline":case"polygon":{const n=rh(t.points);if(n.length===0)return null;const i=n.map((s,r)=>`${r===0?"M":"L"}${s.x} ${s.y}`).join(" ");return e.tag.toLowerCase()==="polygon"?`${i} Z`:i}default:return null}}function oh(e,t,n){const i=Math.max(2,Math.round(n.samples??32)),s=Math.max(0,n.length),r=n.since!==void 0?Math.max(t-s,n.since):t-s;if(r>=t)return[];const o=n.period,a=[];for(let l=0;l<i;l++){const c=r+(t-r)*l/(i-1),h=o&&o>0&&l<i-1?(c%o+o)%o:c;a.push({at:e(h),time:c,age:s>0?(t-c)/s:0})}return a}const ah=2.5;function Dr(e){const t=[],n=[],i=e.length,s=(r,o)=>{for(let a=r+o;a>=0&&a<i;a+=o){const l=(e[a].x-e[r].x)*o,c=(e[a].y-e[r].y)*o,h=Math.hypot(l,c);if(h>1e-9)return[l/h,c/h]}return null};for(let r=0;r<i;r++){const o=e[r],a=s(r,-1),l=s(r,1),c=a??l??[1,0],h=l??a??[1,0];let u=c[0]+h[0],f=c[1]+h[1];const d=Math.hypot(u,f);d<1e-9?(u=c[0],f=c[1]):(u/=d,f/=d);const m=u*c[0]+f*c[1],p=Math.min(ah,1/Math.max(m,1e-6)),g=o.width/2*p;t.push({x:o.x-f*g,y:o.y+u*g}),n.push({x:o.x+f*g,y:o.y-u*g})}return{left:t,right:n}}function Br(e){const t=e.length;if(t<2)return null;const n=e[t-1];for(let i=t-2;i>=0;i--){const s=n.x-e[i].x,r=n.y-e[i].y,o=Math.hypot(s,r);if(o>1e-9)return{x:n.x,y:n.y,radius:n.width/2,start:Math.atan2(s/o,-r/o)}}return null}function rn(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function on(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function Me(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function Te(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function an(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function ki(e){return Math.hypot(e[0],e[1],e[2])}function Nr(e,t){return ki(on(e,t))}function Ee(e){const t=ki(e);return t===0?[0,0,0]:Me(e,1/t)}function Wr(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}const lh=Object.freeze(Object.defineProperty({__proto__:null,add:rn,cross:an,distance:Nr,dot:Te,length:ki,lerp:Wr,normalize:Ee,scale:Me,subtract:on},Symbol.toStringTag,{value:"Module"})),ch=Math.PI/180;function Kr(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function _t(e,t){const n=new Array(16);for(let i=0;i<4;i++)for(let s=0;s<4;s++){let r=0;for(let o=0;o<4;o++)r+=e[o*4+s]*t[i*4+o];n[i*4+s]=r}return n}function Yr(e){return[1,0,0,0,0,1,0,0,0,0,1,0,e[0],e[1],e[2],1]}function ln(e){return[e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,1]}function Ae(e){const[t,n,i,s]=e;return[1-2*(n*n+i*i),2*(t*n+i*s),2*(t*i-n*s),0,2*(t*n-i*s),1-2*(t*t+i*i),2*(n*i+t*s),0,2*(t*i+n*s),2*(n*i-t*s),1-2*(t*t+n*n),0,0,0,0,1]}function Xr(e,t,n){const i=Ae(t);for(let s=0;s<3;s++)i[s]*=n[0],i[4+s]*=n[1],i[8+s]*=n[2];return i[12]=e[0],i[13]=e[1],i[14]=e[2],i}function hh(e){const t=new Array(16);for(let n=0;n<4;n++)for(let i=0;i<4;i++)t[i*4+n]=e[n*4+i];return t}function uh(e){const[t,n,i,s,r,o,a,l,c,h,u,f,d,m,p,g]=e,y=t*o-n*r,w=t*a-i*r,k=t*l-s*r,M=n*a-i*o,S=n*l-s*o,A=i*l-s*a,E=c*m-h*d,T=c*p-u*d,v=c*g-f*d,_=h*p-u*m,P=h*g-f*m,x=u*g-f*p,I=y*x-w*P+k*_+M*v-S*T+A*E;if(Math.abs(I)<1e-12)return null;const C=1/I;return[(o*x-a*P+l*_)*C,(i*P-n*x-s*_)*C,(m*A-p*S+g*M)*C,(u*S-h*A-f*M)*C,(a*v-r*x-l*T)*C,(t*x-i*v+s*T)*C,(p*k-d*A-g*w)*C,(c*A-u*k+f*w)*C,(r*P-o*v+l*E)*C,(n*v-t*P-s*E)*C,(d*S-m*k+g*y)*C,(h*k-c*S-f*y)*C,(o*T-r*_-a*E)*C,(t*_-n*T+i*E)*C,(m*w-d*M-p*y)*C,(c*M-h*w+u*y)*C]}function fh(e,t,n,i){const s=1/Math.tan(e*ch/2),r=1/(n-i);return[s/t,0,0,0,0,s,0,0,0,0,(i+n)*r,-1,0,0,2*i*n*r,0]}function dh(e,t,n,i,s,r){const o=1/(t-e),a=1/(i-n),l=1/(r-s);return[2*o,0,0,0,0,2*a,0,0,0,0,-2*l,0,-(t+e)*o,-(i+n)*a,-(r+s)*l,1]}function ph(e,t,n=[0,1,0]){const i=Ee(on(e,t)),s=Ee(an(n,i)),r=an(i,s);return[s[0],r[0],i[0],0,s[1],r[1],i[1],0,s[2],r[2],i[2],0,-Te(s,e),-Te(r,e),-Te(i,e),1]}function qr(e,t){const n=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12],i=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13],s=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14],r=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15];return r===1||r===0?[n,i,s]:[n/r,i/r,s/r]}const mh=Object.freeze(Object.defineProperty({__proto__:null,compose:Xr,fromQuat:Ae,identity:Kr,invert:uh,lookAt:ph,multiply:_t,orthographic:dh,perspective:fh,scaling:ln,transformPoint:qr,translation:Yr,transpose:hh},Symbol.toStringTag,{value:"Module"})),cn={"power1.in":[.55,.085,.68,.53],"power1.out":[.25,.46,.45,.94],"power1.inout":[.455,.03,.515,.955],"power2.in":[.55,.055,.675,.19],"power2.out":[.215,.61,.355,1],"power2.inout":[.645,.045,.355,1],"power3.in":[.895,.03,.685,.22],"power3.out":[.165,.84,.44,1],"power3.inout":[.77,0,.175,1],"power4.in":[.755,.05,.855,.06],"power4.out":[.23,1,.32,1],"power4.inout":[.86,0,.07,1],"sine.in":[.47,0,.745,.715],"sine.out":[.39,.575,.565,1],"sine.inout":[.445,.05,.55,.95],"expo.in":[.95,.05,.795,.035],"expo.out":[.19,1,.22,1],"expo.inout":[1,0,0,1],"circ.in":[.6,.04,.98,.335],"circ.out":[.075,.82,.165,1],"circ.inout":[.785,.135,.15,.86],"back.in":[.6,-.28,.735,.045],"back.out":[.175,.885,.32,1.275],"back.inout":[.68,-.55,.265,1.55]},Vr={none:"linear",linear:"linear","linear.none":"linear","power1.in":"ease-in-quad","power1.out":"ease-out-quad","power1.inout":"ease-in-out-quad","power2.in":"ease-in-cubic","power2.out":"ease-out-cubic","power2.inout":"ease-in-out-cubic"};function gh(e){let t=e.trim().toLowerCase();t=t.replace(/\.ease(in|out|inout)$/,".$1");const n=/^([a-z]+\d?)(\(.*\))?$/.exec(t);return n&&n[1]!=="steps"&&t!=="none"&&t!=="linear"&&(t=`${n[1]}.out${n[2]??""}`),t}J({type:"bounce",mode:"in"}),J({type:"bounce",mode:"in-out"});function xe(e){const t=Ur.get(e.trim().toLowerCase());if(t)return t;const n=gh(e),i=/^steps\(\s*(\d+)\s*\)$/.exec(n);if(i){const o={type:"steps",count:Math.max(1,Number.parseInt(i[1],10))+1,position:"none"};return{easing:o,fn:J(o)}}const s=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(s){const[,r,o,a]=s,l=(a??"").split(",").map(u=>Number.parseFloat(u)).filter(u=>Number.isFinite(u)),c=o==="inout"?"in-out":o;if(r==="back"&&l.length===0&&n in cn)return{easing:{type:"cubic-bezier",points:cn[n]}};const h=r==="elastic"?{type:"elastic",mode:c,...l[0]!==void 0&&{amplitude:l[0]},...l[1]!==void 0&&{period:l[1]}}:r==="bounce"?{type:"bounce",mode:c}:{type:"back",mode:c,...l[0]!==void 0&&{overshoot:l[0]}};return{easing:h,fn:J(h)}}return n in Vr?{easing:Vr[n]}:n in cn?{easing:{type:"cubic-bezier",points:cn[n]}}:{easing:"ease-out"}}const Ur=new Map;function vi(e,t){return Ur.set(e.trim().toLowerCase(),t.bezier?{easing:{type:"cubic-bezier",points:t.bezier},fn:t.fn}:{fn:t.fn,requiresBaking:"custom"}),e}function Si(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let n=t;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}const zr=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function Gr(e){return typeof e=="string"&&zr.test(e)}function yh(e=1){let t=Si(e);const n=(l,c)=>((...h)=>h.length>=l?c(...h):u=>c(...h,u)),i=(l,c,h)=>Math.min(Math.max(h,Math.min(l,c)),Math.max(l,c)),s=(l,c,h,u,f)=>c===l?h:h+(f-l)/(c-l)*(u-h),r=(l,c)=>{if(typeof l=="number")return l===0?c:Math.round(c/l)*l;if(Array.isArray(l))return jr(l,c,1/0);if("values"in l)return jr(l.values,c,l.radius??1/0);const h=Math.round(c/l.increment)*l.increment;return Math.abs(h-c)<=(l.radius??1/0)?h:c},o=(l,c,h)=>{const u=l+t()*(c-l);return h?Math.round(u/h)*h:u};return{clamp:n(3,i),mapRange:n(5,s),normalize:n(3,(l,c,h)=>s(l,c,0,1,h)),interpolate:n(3,(l,c,h)=>{if(typeof l=="object"&&!Array.isArray(l)){const u={};for(const f of Object.keys(l))u[f]=ke(l[f])(l[f],c[f],h);return u}return ke(l)(l,c,h)}),wrap:((l,c,h)=>{if(Array.isArray(l)){const p=l,g=y=>p[(Math.round(y)%p.length+p.length)%p.length];return c===void 0?g:g(c)}const u=l,d=c-u,m=p=>d===0?u:((p-u)%d+d)%d+u;return h===void 0?m:m(h)}),wrapYoyo:n(3,(l,c,h)=>{const u=c-l;if(u===0)return l;const f=((h-l)%(u*2)+u*2)%(u*2);return l+(f>u?u*2-f:f)}),snap:n(2,r),random:((l,c,h,u)=>{if(Array.isArray(l)){const d=()=>l[Math.floor(t()*l.length)];return c===!0?d:d()}const f=()=>o(l,c,h);return u?f:f()}),shuffle:l=>{for(let c=l.length-1;c>0;c--){const h=Math.floor(t()*(c+1));[l[c],l[h]]=[l[h],l[c]]}return l},distribute:({base:l=0,amount:c,each:h,from:u="start",ease:f})=>(d,m,p)=>{const g=p.length,w=Xe(d,g,{...c!==void 0?{amount:c}:{each:h??1},from:u}),k=c!==void 0?c:(h??1)*Gn(g,u),M=f&&k>0?f(w/k)*k:w;return l+M},pipe:(...l)=>c=>l.reduce((h,u)=>u(h),c),splitColor:l=>bh(l),getUnit:l=>typeof l=="number"?"":/^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(l.trim())?.[1]??"",seed:l=>{t=Si(l)},resolveRandomString:l=>{const c=zr.exec(l)?.[1]??"";if(c.startsWith("[")){const m=c.slice(1,-1).split(",").map(p=>p.trim()).filter(Boolean).map(p=>Number.isFinite(Number(p))?Number(p):p.replace(/^['"]|['"]$/g,""));return m[Math.floor(t()*m.length)]}const[h,u,f]=c.split(",").map(d=>Number.parseFloat(d));return o(h,u,Number.isFinite(f)?f:void 0)}}}function jr(e,t,n){let i=t,s=1/0;for(const r of e){const o=Math.abs(r-t);o<s&&(s=o,i=r)}return s<=n?i:t}function bh(e){const t=e.trim(),n=/^#([0-9a-f]{3,8})$/i.exec(t)?.[1];if(n){const r=(n.length<=4?[...n].map(o=>o+o).join(""):n).match(/../g).map(o=>Number.parseInt(o,16));return r.length>=4?[r[0],r[1],r[2],Math.round(r[3]/255*1e3)/1e3]:[r[0],r[1],r[2]]}const i=(/rgba?\(([^)]+)\)/i.exec(t)?.[1]??"0,0,0").split(/[\s,/]+/).filter(Boolean).map(s=>Number.parseFloat(s));return i.length>=4?[i[0],i[1],i[2],i[3]]:[i[0]??0,i[1]??0,i[2]??0]}const wh=/^([+-])=\s*(-?[\d.]+)$/,kh=/^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;function Pe(e,t){const n=t.scale??1,i=c=>Number.parseFloat(c)*n;if(e===void 0)return t.cursor;if(typeof e=="number")return e*n;const s=e.trim();if(s==="")return t.cursor;const r=wh.exec(s);if(r){const c=i(r[2]);return t.cursor+(r[1]==="-"?-c:c)}const o=kh.exec(s);if(o){const c=o[1]==="<"?t.previousStart:t.previousEnd;if(o[3]===void 0)return c;const h=i(o[3]);return c+(o[2]==="-"?-h:h)}const a=/^(.+?)([+-])=\s*(-?[\d.]+)$/.exec(s);if(a){const c=t.labels.get(a[1].trim());if(c!==void 0){const h=i(a[3]);return c+(a[2]==="-"?-h:h)}}const l=t.labels.get(s);return l!==void 0?l:/^-?[\d.]+$/.test(s)?i(s):t.cursor}function vh(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.grid!==void 0||t.from==="random"||Array.isArray(t.from)||t.ease!==void 0||t.axis!==void 0}function Sh(e,t,n={}){if(e===0)return[];const i=t.grid==="auto"?Math.max(1,Math.min(e,n.columnsFromLayout?.()??e)):Array.isArray(t.grid)?Math.max(1,t.grid[1]):e,s=Array.isArray(t.grid)?Math.max(1,t.grid[0]):Math.ceil(e/i),r=m=>({x:m%i,y:Math.floor(m/i)}),o=t.from??"start",a=Array.isArray(o)?{x:o[0]*(i-1),y:o[1]*(s-1)}:typeof o=="number"?r(Math.max(0,Math.min(e-1,o))):o==="end"?r(e-1):o==="center"||o==="edges"?{x:(i-1)/2,y:(s-1)/2}:{x:0,y:0},l=m=>{const{x:p,y:g}=r(m),y=Math.abs(p-a.x),w=Math.abs(g-a.y);return t.axis==="x"?y:t.axis==="y"?w:Math.hypot(y,w)};let c=Array.from({length:e},(m,p)=>l(p));const h=Math.max(...c);if(o==="edges"&&(c=c.map(m=>h-m)),o==="random"){const m=n.random??Math.random;c=c.map(()=>m()*h)}const u=t.amount!==void 0?t.amount:(t.each??0)*h,f=t.ease?xe(t.ease):void 0,d=f?f.fn??J(f.easing):void 0;return c.map(m=>{const p=h===0?0:m/h;return(d?d(p):p)*u})}const Mi=new Set(["duration","delay","ease","repeat","repeatDelay","yoyo","stagger","onComplete","onUpdate","onStart","onRepeat","onReverseComplete","repeatRefresh","keyframes","easeEach","scrollTo","id","immediateRender","overwrite","paused","scrollTrigger","spring"]),Mh={rotation:"rotate",rotationZ:"rotate",rotationX:"rotateX",rotationY:"rotateY",transformPerspective:"perspective",perspective:"childPerspective"};function hn(e){const t={},n={};for(const[i,s]of Object.entries(e))Mi.has(i)?t[i]=s:n[Mh[i]??i]=s;return{config:t,properties:n}}function un(e,t){return e===void 0?t:e*1e3}function Ti(e,t){if(e!==void 0)return typeof e=="number"?{each:e*1e3}:vh(e)?{offsets:Sh(t?.count??0,e,t??{}).map(i=>i*1e3)}:{...e.each!==void 0&&{each:e.each*1e3},...e.amount!==void 0&&{amount:e.amount*1e3},...e.from!==void 0&&{from:e.from}}}const Th={opacity:1,x:0,y:0,z:0,rotate:0,rotateX:0,rotateY:0,rotateZ:0,scale:1,scaleX:1,scaleY:1,scaleZ:1,skewX:0,skewY:0,originX:50,originY:50,perspective:0,blur:0,glow:0,clipTop:0,clipRight:0,clipBottom:0,clipLeft:0};function Jr(e){return Th[e]}function Eh(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:e;if(!t||typeof t.path!="string"&&!Array.isArray(t.path))throw new Error("gsap-compat: motionPath needs a path — SVG path data or an array of { x, y } points.");let n;if(Array.isArray(t.path))n=Fr(t.path,{curviness:t.curviness});else if(Xt(t.path))n=t.path;else throw new Error(`gsap-compat: motionPath "${t.path}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);const i={pathData:n};return t.autoRotate!==void 0&&t.autoRotate!==!1&&(i.autoRotate=!0,typeof t.autoRotate=="number"&&(i.rotateOffset=t.autoRotate)),t.matrix&&(i.matrix=t.matrix),{config:i,start:t.start??0,end:t.end??1}}function Ah(e){const t=typeof e=="string"||Array.isArray(e)?{path:e}:{...e};return{...t,start:t.end??1,end:t.start??0}}function Zr(e){return typeof e=="object"&&e!==null&&"shape"in e?e.shape:e}function xh(e){if(e.morphSVG===void 0)return e;const{morphSVG:t,...n}=e,i=Zr(t);if(typeof i!="string"||!Xt(i))throw new Error(`gsap-compat: morphSVG "${String(i)}" is not path data. Selectors and elements are resolved by live.to(); timeline() and tf need the path data itself.`);return{...n,d:i}}function Ph(e,t){if(e===!0)return[0,t];if(e===!1)return[0,0];if(typeof e=="number")return[0,Qr(e,t)];const n=e.trim().split(/[\s,]+/).filter(Boolean),i=o=>{const a=Number.parseFloat(o);if(Number.isNaN(a))throw new Error(`gsap-compat: drawSVG "${e}" is not a length or percentage`);return Qr(o.endsWith("%")?t*a/100:a,t)};if(n.length===0)return[0,t];if(n.length===1)return[0,i(n[0])];const s=i(n[0]),r=i(n[1]);return s<=r?[s,r]:[r,s]}function _h(e,t){const[n,i]=Ph(e,t);return{strokeDasharray:[i-n,t],strokeDashoffset:-n}}function Ih(e,t){if(e.drawSVG===void 0)return e;const{drawSVG:n,...i}=e;return{...i,..._h(n,t)}}function Ch(e){if(e.drawSVG!==void 0)throw new Error("gsap-compat: drawSVG needs the stroke length from the page. Use live.to(), or animate strokeDasharray / strokeDashoffset directly (see drawSvgProperties).");return e}function Qr(e,t){return Math.max(0,Math.min(t,e))}function Hh(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t>>>0}function $h(e,t,n){if(e.scrambleText!==void 0){const i=e.scrambleText,s=typeof i=="string"?{text:i}:i;if(typeof s?.text!="string")throw new Error("gsap-compat: scrambleText needs the text to end on — a string, or { text }.");const r=s.revealDelay&&n>0?s.revealDelay*1e3/n:void 0;return{to:s.text,mode:"scramble",...s.chars!==void 0&&{chars:s.chars},...s.speed!==void 0&&{refreshRate:20*s.speed},...r!==void 0&&{revealDelay:Math.min(r,.999)},...s.tweenLength!==void 0&&{tweenLength:s.tweenLength},...s.rightToLeft!==void 0&&{rightToLeft:s.rightToLeft},seed:s.seed??Hh(`${t}|${s.text}`)}}if(e.text!==void 0){const i=e.text,s=typeof i=="string"?{value:i}:i;if(typeof s?.value!="string")throw new Error("gsap-compat: text needs the text to end on — a string, or { value }.");return{to:s.value,mode:"type",...s.rightToLeft!==void 0&&{rightToLeft:s.rightToLeft}}}}function Ei(e){return Math.max(.1,e/25)}function Rh(e,t){const n=typeof t=="number"?{velocity:t}:t;if(typeof n?.velocity!="number"||!Number.isFinite(n.velocity))throw new Error("gsap-compat: inertia needs a velocity for each property — a number, or { velocity }.");const i=n.friction??(n.resistance!==void 0?Ei(n.resistance):void 0),s={from:e,velocity:n.velocity,...i!==void 0&&{friction:i},...n.min!==void 0&&{min:n.min},...n.max!==void 0&&{max:n.max}};return typeof n.end=="function"?s.end=[n.end(me(s))]:n.end!==void 0&&(s.end=Array.isArray(n.end)?[...n.end]:n.end),s}function Oh(e){const t=e===!0?{}:typeof e=="string"?{preset:e}:e;if(t.preset!==void 0&&!(t.preset in Ue))throw new Error(`gsap-compat: unknown spring preset "${t.preset}" — use one of ${Object.keys(Ue).join(", ")}`);return{...t.preset?Ue[t.preset]:{},...t.stiffness!==void 0&&{stiffness:t.stiffness},...t.damping!==void 0&&{damping:t.damping},...t.mass!==void 0&&{mass:t.mass},...t.restDelta!==void 0&&{restDelta:t.restDelta}}}function Lh(e,t){if(e===!0||typeof e=="string")return;const n=e.velocity;return typeof n=="number"?n:n?.[t]}class It{timeline;options;cursor=0;fallbackRandom=Si(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(t={}){this.options=t,this.timeline=new ve({id:t.id??"gsap-compat",name:t.name,config:{...t.repeat!==void 0&&{loop:t.repeat},...t.yoyo!==void 0&&{alternate:t.yoyo},...t.repeatDelay!==void 0&&{repeatDelay:t.repeatDelay*1e3},...t.timeScale!==void 0&&{speed:t.timeScale}}})}to(t,n,i){return this.build(t,void 0,_e(n),i)}from(t,n,i){const{config:s,properties:r}=hn(_e(n)),{motionPath:o,text:a,scrambleText:l,...c}=r,h=this.targetsOf(t)[0],u={...s};for(const m of Object.keys(c))u[m]=this.resolveStart(h,m);o!==void 0&&(u.motionPath=Ah(o));const f={},d=String(this.resolveStart(h,"text"));return a!==void 0&&(f.text=Ai(a),u.text=typeof a=="object"?{...a,value:d}:d),l!==void 0&&(f.text=Ai(l),u.scrambleText=typeof l=="object"?{...l,text:d}:d),this.build(t,{...c,...f},u,i)}fromTo(t,n,i,s){const{properties:r}=hn(_e(n));return this.build(t,r,_e(i),s)}set(t,n,i){return this.build(t,void 0,{..._e(n),duration:0},i)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(t){const n=Math.max(0,Pe(t,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(t){return Pe(t,this.context())}addLabel(t,n){return this.labels.set(t,Pe(n,this.context())),this}labelTimes(){return[...this.labels.values()].sort((t,n)=>t-n)}labelTime(t){return this.labels.get(t)}add(t,n){const i=Pe(n,this.context());for(const r of t.timeline.tracks){if(!("keyframes"in r))continue;const o=Qe({...r,id:this.nextTrackId(`nested-${r.id}`),keyframes:r.keyframes.map(a=>({...a,time:a.time+i}))});this.timeline.addTrack(o)}const s=i+t.timeline.duration;return this.previousStart=i,this.previousEnd=s,this.cursor=Math.max(this.cursor,s),this}play(){return this.timeline.play(),this}pause(){return this.timeline.pause(),this}restart(){return this.timeline.stop(),this.timeline.play(),this}reverse(){return this.timeline.reverse(),this}kill(){return this.timeline.removeTracks(),this}reset(){return this.timeline.removeTracks(),this.cursor=0,this.previousStart=0,this.previousEnd=0,this.labels.clear(),this.lastValues.clear(),this.trackCounter=0,this}seek(t){if(typeof t=="string"){const n=this.labels.get(t);return n!==void 0&&this.timeline.seek(n),this}return this.timeline.seek(t*1e3),this}progress(t){const n=this.timeline.duration;return t!==void 0&&n>0&&this.timeline.seek(t*n),n>0?this.timeline.currentTime/n:0}timeScale(t){return t!==void 0&&(this.timeline.speed=t),this.timeline.speed}duration(){return this.timeline.duration/1e3}tick(t){return this.timeline.tick(t),this}toDefinition(){return this.timeline.toDefinition()}build(t,n,i,s){const{config:r,properties:o}=hn(i),{motionPath:a,text:l,scrambleText:c,inertia:h,...u}=o,f=this.targetsOf(t),d=Pe(s,this.context()),m=un(r.delay,0),p=un(r.duration,500),g=Ti(r.stagger,{count:f.length,columnsFromLayout:this.options.layoutColumns?()=>this.options.layoutColumns(f):void 0,random:this.options.random??this.fallbackRandom}),y=this.easingFor(r.ease),w=[],k=r.spring;let M=0,S=!1;for(const[P,x]of Object.entries(u)){const I=x;let C=n?.[P]!==void 0?n[P]:this.resolveStart(f[0],P);if(typeof C!=typeof I&&(this.warn(`no usable start value for "${P}" on "${f[0]}" — it will snap to ${String(I)}. Use fromTo() to animate it.`),C=I),k!==void 0&&(typeof C!="number"||typeof I!="number")&&this.warn(`spring works on numbers, so "${P}" on "${f[0]}" eases instead`),k!==void 0&&typeof C=="number"&&typeof I=="number"){const B={...Oh(k),from:C,to:I,velocity:Lh(k,P)??this.options.startVelocity?.(f[0],P)??0},$=this.nextTrackId(`${f[0]}-${P}-spring`),L={id:$,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:P,kind:"spring",spring:B,delay:d+m};this.timeline.addTrack(L),w.push($),M=Math.max(M,Rs(B));for(const O of f)this.lastValues.set(`${O}|${P}`,I);continue}S=!0;const H=this.keyframesFor(C,I,p,y,r.ease),R=this.nextTrackId(`${f[0]}-${P}`);this.timeline.addTrack(Qe({id:R,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:P,delay:d+m,keyframes:H,...P==="quaternion"&&{interpolation:"slerp"}})),w.push(R);for(const B of f)this.lastValues.set(`${B}|${P}`,I)}const A=$h({text:l,scrambleText:c},f[0],p);if(A){const P=n?.text??n?.scrambleText,x=P!==void 0?Ai(P):this.resolveStart(f[0],"text"),I=this.nextTrackId(`${f[0]}-text`),C={id:I,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:"text",textConfig:{from:typeof x=="string"?x:String(x??""),...A},delay:d+m,keyframes:this.keyframesFor(0,1,p,y,r.ease)};this.timeline.addTrack(C),w.push(I);for(const H of f)this.lastValues.set(`${H}|text`,A.to)}if(a!==void 0){const{config:P,start:x,end:I}=Eh(a),C=this.nextTrackId(`${f[0]}-motionPath`),H={id:C,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:"motionPath",motionPathConfig:P,delay:d+m,keyframes:this.keyframesFor(x,I,p,y,r.ease)};this.timeline.addTrack(H),w.push(C)}if(h!==void 0)for(const[P,x]of Object.entries(h)){const I=this.resolveStart(f[0],P);if(typeof I!="number"){this.warn(`inertia on "${P}" needs a numeric start value; skipped`);continue}const C=Rh(I,x),H=this.nextTrackId(`${f[0]}-${P}-inertia`),R={id:H,target:f[0],...f.length>1&&{targets:f},...g&&f.length>1&&{stagger:g},property:P,kind:"inertia",inertia:C,delay:d+m};this.timeline.addTrack(R),w.push(H),M=Math.max(M,Kt(C));for(const B of f)this.lastValues.set(`${B}|${P}`,Wt(C))}const v=((h!==void 0||k!==void 0)&&!S&&!A&&a===void 0?M:Math.max(p,M))+(g&&f.length>1?de(f.length,g):0),_=d+m+v;return this.previousStart=d+m,this.previousEnd=_,this.cursor=Math.max(this.cursor,_),{trackIds:w,start:d+m,end:_,kill:()=>{for(const P of w)this.timeline.removeTrack(P)}}}keyframesFor(t,n,i,s,r){const o={time:0,value:t};if(i<=0)return[{time:0,value:n}];const a=typeof r=="string"?xe(r):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&fe(s)){const c=a?.fn??J(s);return[o,...fi(o,{time:i,value:n},c,{intervalMs:this.options.bakeIntervalMs})]}return[o,{time:i,value:n,...s&&{easing:s}}]}resolveStart(t,n){const i=this.lastValues.get(`${t}|${n}`);if(i!==void 0)return i;const s=this.options.startValue?.(t,n);if(s!==void 0)return s;const r=this.options.defaults?.[n];if(r!==void 0)return r;if(n==="text")return"";if(n==="quaternion")return[0,0,0,1];if(n==="d")throw new Error(`gsap-compat: no starting shape for "${t}". Use fromTo({ d: … }, { morphSVG: … }), or live.to(), which reads the element's current shape.`);const o=Jr(n);return o!==void 0?(this.warn(`no start value for "${n}" on "${t}" — using the static default ${o}. GSAP would read the live DOM here; tinyfly cannot, so pass an explicit fromTo() or a defaults map.`),o):(this.warn(`no start value or default for "${n}" on "${t}" — using 0`),0)}easingFor(t){if(t!==void 0){if(typeof t=="string")return xe(t).easing;if(typeof t=="function")throw new Error('gsap-compat: function eases cannot be serialized. Use a named ease, or a cubic-bezier via { type: "cubic-bezier", points: [...] }.');return t}}targetsOf(t){return Array.isArray(t)?t:[t]}context(){return{cursor:this.cursor,previousStart:this.previousStart,previousEnd:this.previousEnd,labels:this.labels,scale:1e3}}nextTrackId(t){return this.trackCounter+=1,`${t}-${this.trackCounter}`}warn(t){this.options.onWarning?.(`gsap-compat: ${t}`)}}function Ai(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e;return String(t.value??t.text??"")}return String(e??"")}function Fh(e){return new It(e)}function _e(e){return Ch(xh(e))}function Dh(e){return!Array.isArray(e)||e.length!==4?null:`matrix3d(${Ae(wt(e)).map(n=>Math.round(n*1e6)/1e6+0).join(", ")})`}const Bh=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),Nh="#ffffff",Wh="rgba(0, 0, 0, 0.5)";function Kh(e){const t=[];if(e.blur!==void 0&&t.push(`blur(${Math.max(0,e.blur)}px)`),e.brightness!==void 0&&t.push(`brightness(${Math.max(0,e.brightness)})`),e.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,e.glow)}px ${e.glowColor??Nh})`),e.shadowX!==void 0||e.shadowY!==void 0||e.shadowBlur!==void 0){const n=e.shadowX??0,i=e.shadowY??0,s=Math.max(0,e.shadowBlur??0);t.push(`drop-shadow(${n}px ${i}px ${s}px ${e.shadowColor??Wh})`)}return t.length>0?t.join(" "):null}function Yh(e,t){const n=e.childNodes.length===1?e.firstChild:null;if(n&&n.nodeType===3){const i=n;i.data!==t&&(i.data=t);return}e.textContent!==t&&(e.textContent=t)}function Xh(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const to=new Set(["width","height","top","right","bottom","left","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","borderRadius","borderWidth","fontSize","lineHeight","letterSpacing","outlineWidth","gap","rowGap","columnGap"]),qh=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","quaternion","motionPathX","motionPathY","motionPathRotate"]),Vh=["x","motionPathX","y","motionPathY","z","rotate","rotateZ","motionPathRotate","rotateX","rotateY","quaternion","scale","scaleX","scaleY","scaleZ","skewX","skewY"],Uh=new Set(["childPerspective","perspectiveOriginX","perspectiveOriginY"]),zh=new Set(["originX","originY"]),Gh=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),jh=new Set(["drawOn"]),Jh={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},eo={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},Zh="http://www.w3.org/2000/svg";class Ct{targets=new Map;registerTarget(t,n){this.targets.set(t,n)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[n,i]of t.values){const s=this.targets.get(n);s&&this.applyProperties(s,i)}}applyProperties(t,n){let i=null,s=null,r=null,o=null,a=null;const l=n.has("motionPathX"),c=n.has("motionPathY"),h=n.has("motionPathRotate");for(const[m,p]of n)if(!(m==="x"&&l)&&!(m==="y"&&c)&&!((m==="rotate"||m==="rotateZ")&&h)&&!jh.has(m)){if(qh.has(m))(i??={})[m]=p;else if(Uh.has(m))typeof p=="number"&&((s??={})[m]=p);else if(zh.has(m))typeof p=="number"&&((r??={})[m]=p);else if(Gh.has(m))typeof p=="number"&&((o??={})[m]=p);else if(Bh.has(m))(a??={})[m]=p;else if(m!=="perspective"){if(m!=="shine")if(m==="text"&&typeof p=="string")Yh(t,p);else if(m==="d"&&typeof p=="string"){const g=t;(g.tagName?.toLowerCase()==="path"?g:g.querySelector?.("path"))?.setAttribute?.("d",p)}else this.applyStyleProperty(t,m,p)}}const u=n.get("shine");typeof u=="number"&&this.applyShine(t,u);const f=[],d=n.get("perspective");if(typeof d=="number"&&d>0&&f.push(`perspective(${d}px)`),i)for(const m of Vh){const p=i[m];if(p===void 0)continue;const g=this.buildTransformPart(m,p);g&&f.push(g)}if(f.length>0&&(t.style.transform=f.join(" "),Xh(t)),s&&(s.childPerspective!==void 0&&(t.style.perspective=`${s.childPerspective}px`),(s.perspectiveOriginX!==void 0||s.perspectiveOriginY!==void 0)&&(t.style.perspectiveOrigin=`${s.perspectiveOriginX??50}% ${s.perspectiveOriginY??50}%`)),r){const m=r.originX??50,p=r.originY??50;t.style.transformOrigin=`${m}% ${p}%`}if(o){const m=o.clipTop??0,p=o.clipRight??0,g=o.clipBottom??0,y=o.clipLeft??0;t.style.clipPath=`inset(${m}% ${p}% ${g}% ${y}%)`}if(a){const m=Kh(a);m&&(t.style.filter=m)}}buildTransformPart(t,n){if(t==="quaternion")return Dh(n);if(typeof n!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${n}px)`;case"y":case"motionPathY":return`translateY(${n}px)`;case"z":return`translateZ(${n}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${n}deg)`;case"rotateX":return`rotateX(${n}deg)`;case"rotateY":return`rotateY(${n}deg)`;case"scale":return`scale(${n})`;case"scaleX":return`scaleX(${n})`;case"scaleY":return`scaleY(${n})`;case"scaleZ":return`scaleZ(${n})`;case"skewX":return`skewX(${n}deg)`;case"skewY":return`skewY(${n}deg)`;default:return null}}applyShine(t,n){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const i=t.dataset.shineBase,s=-20+n*140,r=t.style;r.color="transparent",r.backgroundImage=`linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${i}, ${i})`,r.backgroundSize="250% 100%, 100% 100%",r.backgroundPosition=`${s}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,n,i){let s;if(t.namespaceURI===Zh&&n in eo){const a=Array.isArray(i)?i.join(", "):String(i);t.style[eo[n]]=a;return}else n==="fill"&&t.dataset?.elementType==="text"?s="color":s=Jh[n]??n;let o;typeof i=="number"?to.has(n)||to.has(s)?o=`${i}px`:o=String(i):Array.isArray(i)?o=i.join(", "):o=i,t.style[s]=o}}const Qh={request:e=>requestAnimationFrame(e),cancel:e=>cancelAnimationFrame(e)};class no{adapter=new Ct;scheduler;rootOption;onWarning;names=new WeakMap;elements=new Map;nameCounter=0;objectNames=new WeakMap;objects=new Map;owned=new Set;currentCollector;tickerCallbacks=new Set;tickerTime=0;tickerFrame=0;liveTimelines=new Set;utils=yh();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(t={}){this.scheduler=t.scheduler??Qh,this.rootOption=t.root,this.onWarning=t.onWarning}get root(){return this.rootOption??document}resolveTargets(t){const n=[];for(const i of this.targetsOf(t)){const s=this.nameFor(i);xi(i)&&this.currentCollector?.touch(i,s),n.push(s)}return n}query(t){return this.selectorRoot.querySelector(t)}get collector(){return this.currentCollector}setCollector(t){this.currentCollector=t}forget(t){this.applied.delete(t),this.dirty.delete(t)}get selectorRoot(){return this.currentCollector?.scope??this.root}elementFor(t){return this.elements.get(t)}objectFor(t){return this.objects.get(t)}appliedValue(t,n){return this.applied.get(t)?.get(n)}velocityOf(t,n){for(const s of[...this.active.keys()].reverse()){if(s.getTracks({target:t,property:n}).length===0)continue;const r=s.currentTime;if(r<4)return 0;const o=s.getStateAtTime(r).values.get(t)?.get(n),a=s.getStateAtTime(r-4).values.get(t)?.get(n);if(typeof o!="number"||typeof a!="number")return;const l=(o-a)/4;return(s.direction==="reverse"?-l:l)*1e3}}ticker={add:t=>{this.destroyed||(this.tickerCallbacks.size===0&&(this.tickerTime=0,this.tickerFrame=0),this.tickerCallbacks.add(t),this.currentCollector?.track({revert:()=>this.ticker.remove(t)}),this.startLoop())},remove:t=>{this.tickerCallbacks.delete(t),this.running||this.stopLoop()}};activate(t,n={}){this.destroyed||(t.onUpdate=i=>this.write(i),this.active.delete(t),this.active.set(t,n),this.startLoop())}deactivate(t){this.active.delete(t),this.running||this.stopLoop()}own(t){return this.destroyed?t.destroy():this.owned.add(t),t}destroy(){this.destroyed=!0;for(const t of this.owned)t.destroy();this.owned.clear();for(const t of this.active.keys())t.stop();this.active.clear(),this.stopLoop(),this.adapter.clearTargets(),this.elements.clear(),this.names=new WeakMap,this.objects.clear(),this.objectNames=new WeakMap,this.tickerCallbacks.clear(),this.liveTimelines.clear(),this.applied.clear(),this.dirty.clear()}apply(t,n){if(this.destroyed)return;const i=new Map(Object.entries(n));this.write({values:new Map([[t,i]]),currentTime:0,playbackState:"idle",direction:"forward",loopIteration:0}),this.flush()}render(t){this.destroyed||(this.write(t.getStateAtTime(t.currentTime)),this.flush())}tick(t){const n=[...this.active];for(const[i]of n)i.duration<=0?(this.write(i.getStateAtTime(0)),i.stop()):i.tick(t);this.flush();for(const[i,s]of n)s.onUpdate?.(),i.playbackState!=="playing"&&this.active.get(i)===s&&this.active.delete(i);this.flush(),this.runTicker(t),this.running||this.stopLoop()}get running(){return this.active.size>0||this.tickerCallbacks.size>0}runTicker(t){if(this.tickerCallbacks.size!==0){this.tickerTime+=t,this.tickerFrame+=1;for(const n of[...this.tickerCallbacks])n(this.tickerTime/1e3,t,this.tickerFrame)}}write(t){for(const[n,i]of t.values){let s=this.applied.get(n);s||(s=new Map,this.applied.set(n,s));for(const[r,o]of i)s.set(r,o);this.dirty.add(n)}}flush(){if(this.dirty.size===0)return;const t=new Map;for(const n of this.dirty){const i=this.applied.get(n),s=this.objects.get(n);if(s)for(const[r,o]of i)s[r]=o;else t.set(n,i)}this.dirty.clear(),t.size!==0&&this.adapter.applyState({values:t,currentTime:0,playbackState:"playing",direction:"forward",loopIteration:0})}frame=t=>{this.frameId=null;const n=this.lastTimestamp===null?0:t-this.lastTimestamp;this.lastTimestamp=t,n>0&&this.tick(n),this.running&&this.frameId===null&&(this.frameId=this.scheduler.request(this.frame))};startLoop(){this.frameId===null&&(this.lastTimestamp=null,this.frameId=this.scheduler.request(this.frame))}stopLoop(){this.frameId!==null&&this.scheduler.cancel(this.frameId),this.frameId=null,this.lastTimestamp=null}targetsOf(t){if(typeof t=="string")return Array.from(this.selectorRoot.querySelectorAll(t));if(xi(t))return[t];if(!tu(t))return[t];const n=[];for(const i of Array.from(t))n.push(...this.targetsOf(i));return n}nameFor(t){return xi(t)?this.elementName(t):this.objectName(t)}objectName(t){const n=this.objectNames.get(t);if(n)return n;let i;do this.nameCounter+=1,i=`obj-${this.nameCounter}`;while(this.objects.has(i)||this.elements.has(i));return this.objectNames.set(t,i),this.objects.set(i,t),i}elementName(t){const n=this.names.get(t);if(n)return n;let i=t.id?`#${t.id}`:"";if(!i||this.elements.has(i))do this.nameCounter+=1,i=`el-${this.nameCounter}`;while(this.elements.has(i));return this.names.set(t,i),this.elements.set(i,t),this.adapter.registerTarget(i,t),i}}function xi(e){return typeof e=="object"&&e!==null&&e.nodeType===1}function tu(e){if(Array.isArray(e))return!0;const t=e;return typeof t.length=="number"&&typeof t.item=="function"}function fn(e){const t=e.style;if(!t)return e.getBoundingClientRect();const n=t.transform;t.transform="none";const i=e.getBoundingClientRect();return t.transform=n,i}const io=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function eu(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function nu(e){const t=e.getScreenCTM?.();if(t)return[t.a,t.b,t.c,t.d,t.e,t.f];const n=e.getBoundingClientRect();return[1,0,0,1,n.left,n.top]}function iu(e,t){const n=typeof e=="string"||Array.isArray(e)||io(e)?{path:e}:e,{align:i,alignOrigin:s,path:r,...o}=n,a=A=>{const E=io(A)?A:t.query(A);return E||t.warn(`gsap-compat: motionPath could not find "${String(A)}"`),E};let l=null,c="";if(Array.isArray(r)||typeof r=="string"&&Xt(r))c=r;else{l=a(r);const A=l&&sn({tag:l.localName,attributes:eu(l)});l&&!A&&t.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),c=A??""}const h={...o,path:c};if(i===void 0||i===!1)return h;const u=i===!0?l:a(i);if(!u)return i===!0&&t.warn("gsap-compat: motionPath align: true needs the path to be an element"),h;const f=t.targets[0];if(!f)return h;const[d,m,p,g,y,w]=nu(u),k=fn(f),[M,S]=s??[.5,.5];for(const A of t.targets.slice(1)){const E=fn(A);if(Math.abs(E.left-k.left)>.5||Math.abs(E.top-k.top)>.5){t.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");break}}return h.matrix=[d,m,p,g,y-k.left-M*k.width,w-k.top-S*k.height],h}const so=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function ro(e){const t={};for(const n of Array.from(e.attributes))t[n.name]=n.value;return t}function oo(e){if(!e)return null;const t=sn({tag:e.localName,attributes:ro(e)});return t||(e.querySelector("path")?.getAttribute("d")??null)}function su(e,t,n){const i=Zr(e);if(typeof i=="string"&&Xt(i))return i;const s=so(i)?i:typeof i=="string"?t(i):null,r=oo(s);return r||(n(`gsap-compat: morphSVG could not find a shape for "${String(i)}"`),"")}const ru=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function ou(e,t=document){return(typeof e=="string"?Array.from(t.querySelectorAll(e)):so(e)?[e]:Array.from(e)).map(i=>{if(i.localName==="path")return i;const s=sn({tag:i.localName,attributes:ro(i)});if(!s||!i.parentNode)return i;const r=i.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path");for(const o of Array.from(i.attributes))ru.has(o.name)||r.setAttribute(o.name,o.value);return r.setAttribute("d",s),i.parentNode.replaceChild(r,i),r})}const ao=.3;class lo{options;target;running=!1;dragging=!1;passedTolerance=!1;lastX=0;lastY=0;startX=0;startY=0;velocityX=0;velocityY=0;lastTime=0;constructor(t){this.options=t,this.target=t.target}start(){if(this.running)return;this.running=!0;const t=this.options.type??["pointer","touch"];t.includes("pointer")&&(this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointermove",this.onPointerMove),this.target.addEventListener("pointerup",this.onPointerUp),this.target.addEventListener("pointercancel",this.onPointerUp)),t.includes("touch")&&(this.target.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.target.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.target.addEventListener("touchend",this.onTouchEnd)),t.includes("wheel")&&this.target.addEventListener("wheel",this.onWheel,{passive:!1})}stop(){this.running&&(this.running=!1,this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointermove",this.onPointerMove),this.target.removeEventListener("pointerup",this.onPointerUp),this.target.removeEventListener("pointercancel",this.onPointerUp),this.target.removeEventListener("touchstart",this.onTouchStart),this.target.removeEventListener("touchmove",this.onTouchMove),this.target.removeEventListener("touchend",this.onTouchEnd),this.target.removeEventListener("wheel",this.onWheel))}destroy(){this.stop()}get velocity(){return{x:this.velocityX,y:this.velocityY}}begin(t,n,i){this.dragging=!0,this.passedTolerance=!1,this.startX=t,this.startY=n,this.lastX=t,this.lastY=n,this.velocityX=0,this.velocityY=0,this.lastTime=co(),this.options.onPress?.(this.stateFrom(0,0,i))}move(t,n,i){if(!this.dragging)return;const s=t-this.lastX,r=n-this.lastY;this.lastX=t,this.lastY=n;const o=t-this.startX,a=n-this.startY,l=this.options.tolerance??3;if(!this.passedTolerance){if(Math.hypot(o,a)<l)return;this.passedTolerance=!0}this.updateVelocity(s,r),this.options.preventDefault!==!1&&i.cancelable&&i.preventDefault(),this.options.onMove?.(this.stateFrom(s,r,i))}end(t){this.dragging&&(this.dragging=!1,this.options.onRelease?.(this.stateFrom(0,0,t)))}updateVelocity(t,n){const i=co(),s=Math.max(1,i-this.lastTime);this.lastTime=i;const r=t/s*1e3,o=n/s*1e3;this.velocityX+=(r-this.velocityX)*ao,this.velocityY+=(o-this.velocityY)*ao}stateFrom(t,n,i){return{deltaX:t,deltaY:n,velocityX:this.velocityX,velocityY:this.velocityY,totalX:this.lastX-this.startX,totalY:this.lastY-this.startY,isDragging:this.dragging,event:i}}onPointerDown=t=>{const n=t,i=this.target;if(typeof n.pointerId=="number"&&typeof i.setPointerCapture=="function")try{i.setPointerCapture(n.pointerId)}catch{}this.begin(n.clientX,n.clientY,t)};onPointerMove=t=>{const n=t;this.move(n.clientX,n.clientY,t)};onPointerUp=t=>this.end(t);onTouchStart=t=>{const n=t.touches[0];n&&this.begin(n.clientX,n.clientY,t)};onTouchMove=t=>{const n=t.touches[0];n&&this.move(n.clientX,n.clientY,t)};onTouchEnd=t=>this.end(t);onWheel=t=>{const n=t;this.options.preventDefault!==!1&&n.cancelable&&n.preventDefault(),this.updateVelocity(n.deltaX,n.deltaY),this.options.onMove?.({deltaX:n.deltaX,deltaY:n.deltaY,velocityX:this.velocityX,velocityY:this.velocityY,totalX:0,totalY:0,isDragging:!1,event:t})}}function co(){return typeof performance<"u"?performance.now():Date.now()}function ho(e,t,n){let i={delta:0,line:null},s=n;for(const r of e)for(const o of t){const a=Math.abs(o-r);a<=s&&(s=a,i={delta:o-r,line:o})}return i}function uo(e,t){return t<=0?[]:e.map(n=>Math.round(n/t)*t)}class Pi{options;observer;x;y;originX=0;originY=0;snappedX=null;snappedY=null;constructor(t){this.options=t,this.x=t.initialX??0,this.y=t.initialY??0,this.observer=new lo({target:t.target,onPress:n=>{const i=t.getPosition?.();i&&(this.x=i.x,this.y=i.y),this.originX=this.x,this.originY=this.y,t.onPress?.(n)},onMove:n=>this.handleMove(n),onRelease:n=>t.onRelease?.(n)})}start(){this.observer.start()}stop(){this.observer.stop()}destroy(){this.observer.destroy()}get position(){return{x:this.x,y:this.y}}get velocity(){return this.observer.velocity}setPosition(t,n){const i=this.options.axis??"both";this.x=i==="y"?this.x:this.applyConstraints(t,"x"),this.y=i==="x"?this.y:this.applyConstraints(n,"y")}get snapLines(){return{x:this.snappedX,y:this.snappedY}}snapThreshold(){if(this.options.snapThreshold!==void 0)return this.options.snapThreshold;const t=this.options.snap??0;return t>0?t/2:8}handleMove(t){this.setPosition(this.originX+t.totalX,this.originY+t.totalY),this.options.mode==="scrub"&&this.scrub(),this.options.onDrag?.(this.position,t),this.options.onSnap?.(this.snapLines)}scrub(){const t=this.options.timeline;if(!t)return;const n=t.duration;if(n<=0)return;const i=this.options.scrubDistance??500;if(i===0)return;const s=(this.options.axis??"both")==="y"?this.y:this.x,r=au(s/i);t.pause(),t.seek(r*n)}applyConstraints(t,n){let i=t;const s=[...uo([i],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],r=ho([i],s,this.snapThreshold());i+=r.delta,n==="x"?this.snappedX=r.line:this.snappedY=r.line;const o=this.options.bounds;if(o){const a=n==="x"?o.minX:o.minY,l=n==="x"?o.maxX:o.maxY;a!==void 0&&(i=Math.max(a,i)),l!==void 0&&(i=Math.min(l,i))}return i}}function au(e){return e<0?0:e>1?1:e}function lu(e){const t=new Pi(e);return t.start(),t}const cu={x:"x",y:"y","x,y":"both"},_i=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function fo(e,t){const n=fn(e),i=t.getBoundingClientRect();return{minX:i.left-n.left,maxX:i.right-n.right,minY:i.top-n.top,maxY:i.bottom-n.bottom}}function po(e){return Array.isArray(e)?[...e]:e}function hu(e,t,n,i={}){const[s]=t.resolveTargets(n),r=s?t.elementFor(s):void 0;if(!s||!r)throw new Error(`gsap-compat: live.draggable could not find ${String(n)}`);if(i.type==="rotation")return uu(e,t,s,r,i);const o=cu[i.type??"x,y"],a=()=>{const p=t.appliedValue(s,"x"),g=t.appliedValue(s,"y");return{x:typeof p=="number"?p:0,y:typeof g=="number"?g:0}},l=typeof i.bounds=="string"?t.query(i.bounds):_i(i.bounds)?i.bounds:null,h={bounds:(!l&&i.bounds&&!_i(i.bounds)?i.bounds:void 0)??(l?fo(r,l):void 0)};let u=null;const f=()=>{u?.kill(),u=null},d=p=>{const g=i.inertia===!0?{}:i.inertia,y=g.friction??(g.resistance!==void 0?Ei(g.resistance):4),w=a(),k=h.bounds??{};let M,S;const A=g.end;if(Array.isArray(A)){const T=me({from:w.x,velocity:o==="y"?0:p.x,friction:y}),v=me({from:w.y,velocity:o==="x"?0:p.y,friction:y});let _=A[0];for(const P of A)Math.hypot(P.x-T,P.y-v)<Math.hypot(_.x-T,_.y-v)&&(_=P);_&&(M=[_.x],S=[_.y])}else typeof A=="number"?(M=A,S=A):A&&(M=po(A.x),S=po(A.y));const E={};o!=="y"&&(E.x={velocity:p.x,friction:y,min:k.minX,max:k.maxX,end:M}),o!=="x"&&(E.y={velocity:p.y,friction:y,min:k.minY,max:k.maxY,end:S}),u=e.to(r,{inertia:E,onComplete:()=>i.onThrowComplete?.()})},m=new Pi({target:r,axis:o,snap:i.snap,get bounds(){return h.bounds},getPosition:a,onPress:()=>{f(),l&&(h.bounds=fo(r,l)),i.onPress?.()},onDrag:p=>{t.apply(s,o==="x"?{x:p.x}:o==="y"?{y:p.y}:{x:p.x,y:p.y}),i.onDrag?.(p)},onRelease:()=>{const p=m.velocity;i.onRelease?.(p),i.inertia&&d(p)}});return m.start(),{draggable:m,get position(){return a()},get rotation(){const p=t.appliedValue(s,"rotate");return typeof p=="number"?p:0},destroy(){f(),m.destroy()}}}function uu(e,t,n,i,s){const r=typeof s.bounds=="object"&&s.bounds!==null&&!_i(s.bounds)?s.bounds:{},o=()=>{const k=t.appliedValue(n,"rotate");return typeof k=="number"?k:0},a=k=>Math.min(r.maxRotation??1/0,Math.max(r.minRotation??-1/0,k));let l=null,c=!1,h,u={x:0,y:0},f=0,d=0,m=[];const p=k=>Math.atan2(k.clientY-u.y,k.clientX-u.x)*180/Math.PI,g=k=>{if(c)return;l?.kill(),l=null,c=!0,h=k.pointerId,i.setPointerCapture?.(k.pointerId);const M=i.getBoundingClientRect();u={x:M.left+M.width/2,y:M.top+M.height/2},f=p(k),d=o(),m=[{time:performance.now(),rotation:d}],s.onPress?.()},y=k=>{if(!c||k.pointerId!==h)return;const M=p(k);let S=M-f;S>180&&(S-=360),S<-180&&(S+=360),f=M,d+=S;let A=a(d);s.snap&&(A=a(Math.round(A/s.snap)*s.snap)),t.apply(n,{rotate:A});const E=performance.now();for(m.push({time:E,rotation:A});m.length>2&&E-m[0].time>100;)m.shift();const T={x:0,y:0};s.onDrag?.(T)},w=k=>{if(!c||k.pointerId!==h)return;c=!1;const M=m[0],S=m[m.length-1],A=M&&S?(S.time-M.time)/1e3:0,E=A>0?(S.rotation-M.rotation)/A:0;if(s.onRelease?.({x:E,y:0}),!s.inertia)return;const T=s.inertia===!0?{}:s.inertia,v=T.friction??(T.resistance!==void 0?Ei(T.resistance):4),_=typeof T.end=="number"||Array.isArray(T.end)?T.end:void 0;l=e.to(i,{inertia:{rotate:{velocity:E,friction:v,min:r.minRotation,max:r.maxRotation,end:Array.isArray(_)?_.filter(P=>typeof P=="number"):_}},onComplete:()=>s.onThrowComplete?.()})};return i.addEventListener("pointerdown",g),i.addEventListener("pointermove",y),i.addEventListener("pointerup",w),i.addEventListener("pointercancel",w),i.style.touchAction="none",{draggable:void 0,position:{x:0,y:0},get rotation(){return o()},destroy(){l?.kill(),i.removeEventListener("pointerdown",g),i.removeEventListener("pointermove",y),i.removeEventListener("pointerup",w),i.removeEventListener("pointercancel",w)}}}const fu={opacity:0,scale:.6};function du(e){const t=e.getBoundingClientRect();return t.width===0&&t.height===0?null:{cx:t.left+t.width/2,cy:t.top+t.height/2,width:t.width,height:t.height}}function mo(e){const t=fn(e);return t.width===0&&t.height===0?null:{cx:t.left+t.width/2,cy:t.top+t.height/2,width:t.width,height:t.height}}function Ii(e,t){const i=e.resolveTargets(t).map(o=>e.elementFor(o)).filter(o=>!!o),s=new Map,r=new Map;for(const o of i){const a=du(o);s.set(o,a);const l=go(o);a&&l!==void 0&&!r.has(l)&&r.set(l,{element:o,box:a})}return{elements:i,boxes:s,ids:r}}const Ci=new WeakMap;function Hi(e,t,n,i={}){const s=i.duration??.6,r=i.ease??"power2.inOut",o=i.stagger??0,a=i.scale!==!1,l=i.enter===void 0?fu:i.enter,c=new Set(n.elements);if(i.targets!==void 0)for(const d of e.resolveTargets(i.targets)){const m=e.elementFor(d);m&&c.add(m)}const h=[...c].sort((d,m)=>d===m?0:d.compareDocumentPosition(m)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),u=t({onComplete:i.onComplete});let f=0;for(const d of h){const m=mo(d);if(!m)continue;let p=n.boxes.get(d)??null,g;const y=go(d),w=!p&&y!==void 0?n.ids.get(y):void 0;w&&w.element!==d&&(p=w.box,g=w.element);const[k]=e.resolveTargets(d);Ci.get(d)?.timeline.removeTracks({target:k});const M=f*o;if(!p){if(l===!1)continue;u.fromTo(d,{x:0,y:0,scaleX:1,scaleY:1,...l},{...yo(l),x:0,y:0,scaleX:1,scaleY:1,duration:s,ease:r,delay:M},0),Ci.set(d,u),f++;continue}const S=p.cx-m.cx,A=p.cy-m.cy,E=a?p.width/m.width:1,T=a?p.height/m.height:1;if(!(Math.abs(S)>.5||Math.abs(A)>.5||Math.abs(E-1)>.001||Math.abs(T-1)>.001)){const P=(x,I)=>{const C=e.appliedValue(k,x);return typeof C=="number"&&Math.abs(C-I)>1e-6};(P("x",0)||P("y",0)||P("scaleX",1)||P("scaleY",1))&&u.set(d,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const _=i.fade===!0&&g!==void 0;u.fromTo(d,{x:S,y:A,scaleX:E,scaleY:T,..._&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,..._&&{opacity:1},duration:s,ease:r,delay:M},0),_&&g&&mo(g)&&u.fromTo(g,{opacity:1},{opacity:0,duration:s,ease:r,delay:M},0),Ci.set(d,u),f++}return u}function go(e){return e.dataset?.flipId}function yo(e){const t={};for(const n of Object.keys(e))t[n]=n==="opacity"||n.startsWith("scale")?1:0;return t}function pu(e,t={}){const n=new Set((t.type??"chars,words,lines").split(",").map(p=>p.trim())),i={chars:t.charsClass??"char",words:t.wordsClass??"word",lines:t.linesClass??"line"},s=t.aria!==!1,r=e.map(p=>({element:p,html:p.innerHTML,ariaLabel:p.getAttribute("aria-label")}));let o={chars:[],words:[],lines:[],masks:[]},a,l,c=!1;const h=()=>{for(const{element:p,html:g,ariaLabel:y}of r)p.innerHTML=g,y===null?p.removeAttribute("aria-label"):p.setAttribute("aria-label",y)},u=()=>{a&&(a.revert?a.revert():a.kill?.(),a=void 0)},f=()=>{const p={chars:[],words:[],lines:[],masks:[]};for(const{element:g}of r){const y=(g.textContent??"").replace(/\s+/g," ").trim(),w=mu(g,i.words),k=n.has("chars")?w.flatMap(A=>gu(A,i.chars)):[],M=n.has("lines")?bu(g,w,i.lines):[];if(s){!g.hasAttribute("aria-label")&&y&&g.setAttribute("aria-label",y);for(const A of w)A.setAttribute("aria-hidden","true")}if(n.has("words"))p.words.push(...w);else for(const A of w)A.removeAttribute("class");p.chars.push(...k),p.lines.push(...M);const S=t.mask==="lines"?M:t.mask==="words"?w:t.mask==="chars"?k:[];for(const A of S)p.masks.push(wu(A,`${i[t.mask]}-mask`))}o=p},d={elements:e,get chars(){return o.chars},get words(){return o.words},get lines(){return o.lines},get masks(){return o.masks},split(){c||(u(),h(),f(),a=t.onSplit?.(d))},revert(){c=!0,l?.disconnect(),u(),h()}};f(),a=t.onSplit?.(d),t.autoSplit&&m();function m(){const p=new Map;let g=!1;const y=()=>{if(g)return;g=!0;const k=()=>{g=!1,d.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(k):setTimeout(k,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(k=>{let M=!1;for(const S of k){const A=Math.round(S.contentRect.width),E=p.get(S.target);p.set(S.target,A),E!==void 0&&E!==A&&(M=!0)}M&&y()});for(const k of e)l.observe(k)}const w=e[0]?.ownerDocument?.fonts;w&&w.status!=="loaded"&&w.ready.then(()=>y())}return d}function mu(e,t){const n=e.ownerDocument,i=[],s=n.createTreeWalker(e,4),r=[];for(let o=s.nextNode();o;o=s.nextNode())r.push(o);for(const o of r){const a=o.data.match(/\s+|\S+/g)??[];if(a.length===0)continue;const l=n.createDocumentFragment();for(const c of a){if(/^\s/.test(c)){l.appendChild(n.createTextNode(c));continue}const h=n.createElement("span");h.className=t,h.style.display="inline-block",h.textContent=c,l.appendChild(h),i.push(h)}o.replaceWith(l)}return i}function gu(e,t){const n=e.ownerDocument,i=yu(e.textContent??"").map(s=>{const r=n.createElement("span");return r.className=t,r.style.display="inline-block",r.textContent=s,r});return e.replaceChildren(...i),i}function yu(e){const t=Intl.Segmenter;return t?Array.from(new t(void 0,{granularity:"grapheme"}).segment(e),n=>n.segment):Array.from(e)}function bu(e,t,n){const i=e.ownerDocument,s=new Map(t.map(m=>[m,m.getBoundingClientRect()])),r=[],o=m=>{for(const p of Array.from(m.childNodes))p.nodeType===3||s.has(p)||p.tagName==="BR"?r.push(p):o(p)};o(e);const a=[];let l=null,c=0,h=0,u=!1,f=[];const d=()=>{l=i.createElement("span"),l.className=n,l.style.display="block",a.push(l),f=[]};for(const m of r){if(m.tagName==="BR"){u=!0;continue}const p=s.get(m);if(p&&(!l||u||p.top>c+h)&&(d(),c=p.top,h=p.height/2,u=!1),!l)continue;const g=[];for(let k=m.parentNode;k&&k!==e;k=k.parentNode)g.unshift(k);let y=0;for(;y<f.length&&y<g.length&&f[y].original===g[y];)y++;f.length=y;let w=y===0?l:f[y-1].clone;for(const k of g.slice(y)){const M=k.cloneNode(!1);w.appendChild(M),f.push({original:k,clone:M}),w=M}w.appendChild(m)}return e.replaceChildren(...a),a}function wu(e,t){const n=e.ownerDocument.createElement("span");return n.className=t,n.style.display=e.style.display==="block"?"block":"inline-block",n.style.overflow="clip",n.style.paddingBottom="0.12em",n.style.marginBottom="-0.12em",e.replaceWith(n),n.appendChild(e),n}const bo={top:0,left:0,start:0,center:.5,centre:.5,middle:.5,bottom:1,right:1,end:1};function $i(e){const t=e.trim().toLowerCase();if(t in bo)return bo[t];if(t.endsWith("%")){const n=Number.parseFloat(t.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function Ri(e){if(typeof e=="number")return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:e};let t=0;const i=e.replace(/([+-])=\s*(-?[\d.]+)/g,(o,a,l)=>(t+=(a==="-"?-1:1)*Number.parseFloat(l),"")).trim().split(/\s+/).filter(Boolean);if(i.length===1&&/^-?[\d.]+$/.test(i[0]))return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:Number.parseFloat(i[0])+t};const s=i[0]!==void 0?$i(i[0]):void 0,r=i[1]!==void 0?$i(i[1]):void 0;return{elementFraction:s??0,viewportFraction:r??0,offsetPx:t}}function Jt(e,t,n){const i=Ri(n),s=i.absolutePx!==void 0?e.top+i.absolutePx:e.top+e.height*i.elementFraction,r=t*i.viewportFraction;return s-r+i.offsetPx}function ku(e,t,n,i){const s=Jt(e,t,n),o=Jt(e,t,i)-s;return o<=0?s<=0?1:0:Oi(-s/o)}function Oi(e){return e<0?0:e>1?1:e===0?0:e}function wo(e,t,n,i){if(n<=0)return t;const s=1-Math.exp(-(i/1e3)/n);return e+(t-e)*s}function Li(e,t,n,i,s){const r=h=>Jt({top:e+s(h),bottom:e+s(h)+t,height:t},n,i),o=r(0),a=r(1);if(Math.sign(o)===Math.sign(a)||o===0||a===0)return o===0?0:a===0?1:Math.abs(o)<Math.abs(a)?0:1;let l=0,c=1;for(let h=0;h<40;h++){const u=(l+c)/2;Math.sign(r(u))===Math.sign(o)?l=u:c=u}return(l+c)/2}class ko{timeline;trigger;behaviour;options;observer=null;hasPlayed=!1;running=!1;constructor(t){this.timeline=t.timeline,this.trigger=t.trigger,this.behaviour=t.behaviour??"once",this.options=t}start(){if(!this.running){if(this.running=!0,typeof IntersectionObserver>"u"){this.enter();return}this.observer=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting?this.enter():this.leave()},{threshold:this.options.threshold??.15,rootMargin:this.options.rootMargin,root:this.options.root??null}),this.observer.observe(this.trigger)}}stop(){this.running=!1,this.observer?.disconnect(),this.observer=null}destroy(){this.stop()}reset(){this.hasPlayed=!1,this.timeline.stop()}enter(){this.options.onEnter?.(),!(this.behaviour==="once"&&this.hasPlayed)&&(this.hasPlayed=!0,this.behaviour!=="once"&&this.timeline.seek(0),this.timeline.play())}leave(){this.options.onLeave?.(),this.behaviour==="reset"&&this.timeline.stop()}}function vu(e){const t=new ko(e);return t.start(),t}class vo{element;spacer;saved;axis;spacing;constructor(t,n={}){this.element=t,this.axis=n.axis??"y",this.spacing=n.spacing??!0;const i=t.ownerDocument;this.spacer=i.createElement("div"),this.spacer.className="pin-spacer",this.saved={position:t.style.position,top:t.style.top,left:t.style.left},this.axis==="x"&&(this.spacer.style.flexShrink="0"),t.replaceWith(this.spacer),this.spacer.appendChild(t)}release(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left}apply(t,n){const i=Math.max(0,n);this.element.style.position="sticky",this.axis==="x"?(this.spacer.style.width=`${this.element.offsetWidth+i}px`,this.spacer.style.marginRight=this.spacing?"":`-${i}px`,this.element.style.left=`${t}px`):(this.spacer.style.height=`${this.element.offsetHeight+i}px`,this.spacer.style.marginBottom=this.spacing?"":`-${i}px`,this.element.style.top=`${t}px`)}destroy(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left,this.spacer.parentNode&&this.spacer.replaceWith(this.element)}}const Su=.15;function So(e){return typeof e=="object"&&!Array.isArray(e)?e:{snapTo:e}}function Mo(e,t,n){const i=dn(e+t*Su);if(typeof n=="function")return dn(n(i));if(typeof n=="number")return n<=0?e:dn(Math.round(i/n)*n);if(n.length===0)return e;let s=n[0];for(const r of n)Math.abs(r-i)<Math.abs(s-i)&&(s=r);return dn(s)}function To(e,t,n){const i=e.duration??{min:.2,max:.8};if(typeof i=="number")return i;const s=Math.min(1,Math.abs(t)/Math.max(1,n));return i.min+(i.max-i.min)*s}class Eo{rafId=null;cancelEvents=["wheel","touchstart","pointerdown","keydown"];onInterrupt=()=>this.cancel();write;eventTarget;constructor(t,n){this.write=t,this.eventTarget=n}get active(){return this.rafId!==null}animate(t,n,i,s=ge,r){if(this.cancel(),typeof requestAnimationFrame>"u"||i<=0){this.write(n),r?.();return}for(const l of this.cancelEvents)this.eventTarget?.addEventListener(l,this.onInterrupt,{passive:!0});let o=null;const a=l=>{o??=l;const c=Math.min(1,(l-o)/(i*1e3));this.write(t+(n-t)*s(c)),c<1?this.rafId=requestAnimationFrame(a):(this.rafId=null,this.detach(),r?.())};this.rafId=requestAnimationFrame(a)}cancel(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.detach()}detach(){for(const t of this.cancelEvents)this.eventTarget?.removeEventListener(t,this.onInterrupt)}}function dn(e){return Math.max(0,Math.min(1,e))}class Ao{options;scroller;nodes=[];scrollerStart;scrollerEnd;start;end;constructor(t,n,i){this.options=i===!0?{}:i,this.scroller=n;const{startColor:s="#3ecf7a",endColor:r="#ff5a5a",id:o}=this.options,a=o?`${o} `:"",l=(c,h,u)=>{const f=t.createElement("div");return f.textContent=`${a}${c}`,f.setAttribute("aria-hidden","true"),f.className="scroll-marker",Object.assign(f.style,{position:u?"fixed":"absolute",right:`${this.options.indent??0}px`,zIndex:"2147483646",pointerEvents:"none",borderTop:`1px solid ${h}`,color:h,font:`${this.options.fontSize??"11px"} ui-monospace, monospace`,padding:"2px 6px",whiteSpace:"nowrap",background:"rgba(0, 0, 0, 0.35)"}),(n??t.body).appendChild(f),this.nodes.push(f),f};this.scrollerStart=l("scroller-start",s,!n),this.scrollerEnd=l("scroller-end",r,!n),this.start=l("start",s,!1),this.end=l("end",r,!1),n&&getComputedStyle(n).position==="static"&&(n.style.position="relative")}place(t,n){this.start.style.top=`${t.startPage}px`,this.end.style.top=`${t.endPage}px`;const i=this.scroller?n:0;this.scrollerStart.style.top=`${i+t.startViewport}px`,this.scrollerEnd.style.top=`${i+t.endViewport}px`}follow(t,n){this.scroller&&this.place(t,n)}destroy(){for(const t of this.nodes.splice(0))t.remove()}}const Mu=120,Zt=[],Qt=new Set;let Fi=!1;const Tu=()=>{Fi||Qt.size===0||(Fi=!0,queueMicrotask(()=>{Fi=!1;for(const e of Qt)e.afterRefresh()}))},xo=()=>{for(const e of Qt)e.beforeRefresh();for(const e of Zt)e.refresh();for(const e of Qt)e.afterRefresh()};let te={width:0,height:0};const Po=()=>{const e=window.innerWidth,t=window.innerHeight,n=e===te.width&&t!==te.height,i=Math.abs(t-te.height)<te.height*.25,s=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&i&&s||(te={width:e,height:t},xo())};class Ie{timeline;options;running=!1;pin=null;startPx=0;endPx=0;targetProgress=0;displayProgress=0;zone="before";measured=!1;lastScroll=null;lastScrollTime=0;velocityPxPerSecond=0;idleTimer=null;lastEmitted=null;rafId=null;lastFrameTime=null;onScroll=()=>this.update();releaseVelocity=0;snapper;snapTimer=null;markers=null;markerGeometry=null;constructor(t){this.timeline=t.timeline,this.options=t,this.snapper=new Eo(n=>this.scrollTo(n),typeof window<"u"?window:null)}start(){if(this.running)return;this.running=!0,this.timeline?.pause();const t=this.options.pin===!0?this.options.trigger:this.options.pin||null;t&&!this.options.container&&(this.pin=new vo(t,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new Ao(document,this.options.scroller??null,this.options.markers)),this.scrollTarget()?.addEventListener("scroll",this.onScroll,{passive:!0}),Zt.length===0&&typeof window<"u"&&(te={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",Po,{passive:!0})),Zt.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Zt.splice(Zt.indexOf(this),1),Zt.length===0&&typeof window<"u"&&window.removeEventListener("resize",Po),this.stopSmoothing(),this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=null,this.snapTimer!==null&&clearTimeout(this.snapTimer),this.snapTimer=null,this.snapper.cancel())}destroy(){this.stop(),this.pin?.destroy(),this.pin=null,this.markers?.destroy(),this.markers=null}get startOffset(){return this.startPx}get endOffset(){return this.endPx}static refreshAll(){xo()}static onRefresh(t){return Qt.add(t),()=>Qt.delete(t)}get progress(){return this.targetProgress}get velocity(){return this.velocityPxPerSecond}refresh(){if(!this.running)return;this.measured&&this.options.onRefresh?.();const t=this.scrollPosition();this.pin?.release();const n=this.triggerRect();if(n&&this.options.container)this.measureInContainer(this.options.container);else if(n){const i=this.viewportHeight();if(this.startPx=t+Jt(n,i,Ce(this.options.start)??"top bottom"),this.endPx=this.resolveEnd(n,i,t),this.pin){const s=this.relativeRect(this.pin.element.getBoundingClientRect());this.pin.apply(s.top-(this.startPx-t),this.endPx-this.startPx)}this.markerGeometry=this.markers?this.markersFor(i):null}this.markers&&this.markerGeometry&&this.markers.place(this.markerGeometry,t),this.lastScroll=null,this.updateFrom(t,!this.measured),this.measured=!0,Tu()}sample(){this.refresh()}update(t){this.running&&this.updateFrom(t??this.scrollPosition(),!1)}updateFrom(t,n){this.trackVelocity(t),this.markers&&this.markerGeometry&&this.markers.follow(this.markerGeometry,t);const i=this.endPx-this.startPx,s=this.zone;this.targetProgress=i>0?Oi((t-this.startPx)/i):t>=this.startPx?1:0,this.zone=i>0?t<=this.startPx?"before":t>=this.endPx?"after":"active":t>=this.startPx?"after":"before",this.fireBoundaryCallbacks(s,this.zone),n||this.smoothing()<=0?(this.displayProgress=this.targetProgress,this.applyProgress()):(this.emitUpdate(),this.startSmoothing())}smoothing(){const t=this.options.scrub;return typeof t=="number"?Math.max(0,t):0}resolveEnd(t,n,i){const s=Ce(this.options.end)??"bottom top",r=typeof s=="string"?s.trim().match(/^\+=\s*(-?[\d.]+)\s*(%|px)?$/):null;if(r){const o=Number.parseFloat(r[1]);return this.startPx+(r[2]==="%"?n*o/100:o)}return i+Jt(t,n,s)}applyProgress(){const t=this.timeline?.duration??0;this.timeline&&t>0&&this.timeline.seek(this.displayProgress*t),this.emitUpdate()}emitUpdate(){if(!this.options.onUpdate)return;const t=[this.displayProgress,this.velocityPxPerSecond];this.lastEmitted&&this.lastEmitted[0]===t[0]&&this.lastEmitted[1]===t[1]||(this.lastEmitted=t,this.options.onUpdate(t[0],t[1]))}trackVelocity(t){const n=typeof performance<"u"?performance.now():Date.now();this.lastScroll!==null&&n>this.lastScrollTime&&t!==this.lastScroll&&(this.velocityPxPerSecond=(t-this.lastScroll)/(n-this.lastScrollTime)*1e3),(this.lastScroll===null||t!==this.lastScroll)&&(this.lastScroll=t,this.lastScrollTime=n),!(this.velocityPxPerSecond===0||typeof setTimeout>"u")&&(this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this.idleTimer=null,this.releaseVelocity=this.velocityPxPerSecond,this.velocityPxPerSecond=0,this.emitUpdate(),this.scheduleSnap()},Mu))}fireBoundaryCallbacks(t,n){if(t===n)return;const{onEnter:i,onLeave:s,onEnterBack:r,onLeaveBack:o}=this.options;t==="before"?(i?.(),n==="after"&&s?.()):t==="after"?(r?.(),n==="before"&&o?.()):n==="after"?s?.():o?.()}scheduleSnap(){const t=this.options.snap;if(t===void 0||this.snapper.active)return;const n=So(t),i=()=>{this.snapTimer=null;const s=this.endPx-this.startPx,r=this.scrollPosition();if(!this.running||s<=0||r<=this.startPx||r>=this.endPx)return;const o=(r-this.startPx)/s,a=this.startPx+Mo(o,this.releaseVelocity/s,n.snapTo)*s;Math.abs(a-r)<1||this.snapper.animate(r,a,To(n,a-r,this.viewportHeight()),n.ease)};n.delay?this.snapTimer=setTimeout(i,n.delay*1e3):i()}scrollTo(t){const n=this.options.scroller,i=this.options.horizontal?{left:t}:{top:t};n?typeof n.scrollTo=="function"?n.scrollTo({...i,behavior:"instant"}):this.options.horizontal?n.scrollLeft=t:n.scrollTop=t:typeof window<"u"&&window.scrollTo({...i,behavior:"instant"})}measureInContainer(t){const n=this.options.trigger;if(typeof n?.getBoundingClientRect!="function")return;const i=n.getBoundingClientRect(),s=this.options.scroller?.getBoundingClientRect?.().left??0,r=this.options.scroller?this.options.scroller.clientWidth:typeof window<"u"?window.innerWidth:0,o=i.left-s-t.shiftAt(t.progress()),{start:a,end:l}=t.range(),c=d=>a+d*(l-a),h=Li(o,i.width,r,Ce(this.options.start)??"left right",t.shiftAt);this.startPx=c(h);const u=Ce(this.options.end)??"right left",f=typeof u=="string"?u.trim().match(/^\+=\s*(-?[\d.]+)\s*(px)?$/):null;this.endPx=f?this.startPx+Number.parseFloat(f[1]):c(Li(o,i.width,r,u,t.shiftAt)),this.markerGeometry=null}markersFor(t){const n=(r,o)=>{const a=Ce(r)??o;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=Ri(a);return t*l.viewportFraction-l.offsetPx},i=n(this.options.start,"top bottom")??0,s=n(this.options.end,"bottom top")??i;return{startViewport:i,endViewport:s,startPage:this.startPx+i,endPage:this.endPx+s}}startSmoothing(){if(this.rafId!==null||typeof requestAnimationFrame>"u")return;const t=n=>{if(this.rafId=null,!this.running)return;const i=this.lastFrameTime===null?16.67:n-this.lastFrameTime;this.lastFrameTime=n,this.displayProgress=wo(this.displayProgress,this.targetProgress,this.smoothing(),i);const s=Math.abs(this.targetProgress-this.displayProgress)<1e-4;s&&(this.displayProgress=this.targetProgress),this.applyProgress(),s?this.lastFrameTime=null:this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}stopSmoothing(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.lastFrameTime=null}scrollTarget(){return this.options.scroller??(typeof window<"u"?window:null)}scrollPosition(){const t=this.options.scroller,n=this.options.horizontal;return t?(n?t.scrollLeft:t.scrollTop)??0:typeof window<"u"?(n?window.scrollX:window.scrollY)??0:0}triggerRect(){const t=this.options.trigger;return typeof t?.getBoundingClientRect!="function"?null:this.relativeRect(t.getBoundingClientRect())}relativeRect(t){const n=this.options.horizontal,i=n?t.left??0:t.top,s=n?t.right??0:t.bottom,r=n?t.width??0:t.height,o=this.options.scroller;if(o&&typeof o.getBoundingClientRect=="function"){const a=o.getBoundingClientRect(),l=n?a.left:a.top;return{top:i-l,bottom:s-l,height:r}}return{top:i,bottom:s,height:r}}viewportHeight(){const t=this.options.scroller,n=this.options.horizontal;return t?n?t.clientWidth:t.clientHeight:typeof window<"u"?n?window.innerWidth:window.innerHeight:0}}function Ce(e){return typeof e=="function"?e():e}function Eu(e){const t=new Ie(e);return t.start(),t}const Di=new Set,Au=16,_o=.5,xu=2;class Bi{options;frames;running=!1;reduced=!1;current=0;target=0;written=null;velocityPxPerSecond=0;frameId=null;lastTime=null;journey=null;pausedState=!1;effects=[];onWheel=t=>this.wheel(t);onScroll=()=>this.nativeScroll();onResize=()=>this.refresh();onLoad=()=>this.refresh();stopListening=null;constructor(t={}){this.options=t,this.frames=t.frames??{request:n=>requestAnimationFrame(n),cancel:n=>cancelAnimationFrame(n)}}start(){if(this.running||typeof window>"u")return this;this.running=!0,this.reduced=this.options.reducedMotion??(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),this.current=this.target=this.position();const t=this.options.scroller??window;return t.addEventListener("wheel",this.onWheel,{passive:!1}),t.addEventListener("scroll",this.onScroll,{passive:!0}),window.addEventListener("resize",this.onResize,{passive:!0}),window.addEventListener("load",this.onLoad),Di.add(this),this.stopListening=Ie.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const t of Di)t.refresh()}stop(){if(!this.running)return this;this.running=!1;const t=this.options.scroller??window;return t.removeEventListener("wheel",this.onWheel),t.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("load",this.onLoad),Di.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const t of this.effects)Ni(t.element,t.saved);this.effects=[]}kill(){this.destroy()}get state(){const t=this.limit();return{scroll:this.current,target:this.target,progress:t>0?this.current/t:0,velocity:this.velocityPxPerSecond}}paused(t){return t!==void 0&&(this.pausedState=t,t&&(this.target=this.current,this.journey=null)),this.pausedState}scrollTo(t,n={}){if(!this.running)return;const i=this.clamp(this.resolve(t)+(n.offset??0)),s=Math.abs(i-this.current),r=this.reduced?0:n.duration??Math.min(1.2,Math.max(.4,s/2500));if(r<=0){this.journey=null,this.current=this.target=i,this.write(i),this.applyEffects(0);return}this.target=i,this.journey={from:this.current,to:i,ms:r*1e3,ease:n.ease??ge,elapsed:0},this.requestFrame()}refresh(){if(!this.running)return;this.rest(),this.effects=[];const t=this.options.effects===!0?"[data-speed], [data-lag]":this.options.effects||"";if(t&&!this.reduced){const n=this.options.scroller??document,i=this.position(),s=this.viewportHeight(),r=this.options.scroller?.getBoundingClientRect().top??0;for(const o of n.querySelectorAll(t)){const a=Number.parseFloat(o.dataset.speed??""),l=Number.parseFloat(o.dataset.lag??""),c=o.getBoundingClientRect(),h=c.top-r+i;this.effects.push({element:o,speed:Number.isFinite(a)?a:void 0,lag:Number.isFinite(l)&&l>0?l:void 0,centre:h+c.height/2-s/2,lagged:i,shift:0,saved:o.style.getPropertyValue("translate")})}}this.current=this.target=this.clamp(this.position()),this.applyEffects(0)}rest(){for(const t of this.effects)Ni(t.element,t.saved)}wheel(t){if(this.pausedState||this.reduced||(this.options.smooth??.8)<=0||t.ctrlKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||this.nestedScrollerTakes(t))return;const n=t.deltaMode===1?Au:t.deltaMode===2?this.viewportHeight():1,i=t.deltaY*n*(this.options.wheelMultiplier??1),s=this.clamp(this.target+i);s===this.target&&s===this.current||(t.preventDefault(),this.journey=null,this.target=s,this.requestFrame())}nativeScroll(){const t=this.position();this.written!==null&&Math.abs(t-this.written)<=xu||(this.written=null,this.journey=null,this.cancelFrame(),this.current=this.target=t,this.requestFrame())}nestedScrollerTakes(t){const n=this.options.scroller??document.documentElement;for(let i=t.target;i&&i!==n&&i!==document.body;i=i.parentElement){if(i.hasAttribute?.("data-smooth-ignore"))return!0;const s=getComputedStyle(i);if(!/(auto|scroll)/.test(s.overflowY)||i.scrollHeight<=i.clientHeight)continue;if(t.deltaY<0?i.scrollTop>0:i.scrollTop+i.clientHeight<i.scrollHeight-1)return!0}return!1}requestFrame(){this.frameId!==null||!this.running||(this.frameId=this.frames.request(t=>this.frame(t)))}cancelFrame(){this.frameId!==null&&this.frames.cancel(this.frameId),this.frameId=null,this.lastTime=null}frame(t){this.frameId=null;const n=this.lastTime===null?1e3/60:Math.min(100,t-this.lastTime);this.lastTime=t;const i=this.current;if(this.journey){const r=this.journey;r.elapsed+=n;const o=Math.min(1,r.elapsed/r.ms);this.current=r.from+(r.to-r.from)*r.ease(o),o>=1&&(this.journey=null)}else if(this.current!==this.target){const r=(this.options.smooth??.8)*1e3/3;this.current+=(this.target-this.current)*(1-Math.exp(-n/r)),Math.abs(this.target-this.current)<_o&&(this.current=this.target)}this.current!==i&&this.write(this.current),this.velocityPxPerSecond=n>0?(this.current-i)*1e3/n:0;const s=this.applyEffects(n);this.current!==i&&this.options.onUpdate?.(this.state),this.journey||this.current!==this.target||s?this.requestFrame():(this.lastTime=null,this.velocityPxPerSecond=0)}applyEffects(t){let n=!1;const i=this.current;for(const s of this.effects){let r=0;if(s.speed!==void 0&&(r+=(i-s.centre)*(1-s.speed)),s.lag!==void 0){const o=s.lag*1e3/3;s.lagged=t===0?i:s.lagged+(i-s.lagged)*(1-Math.exp(-t/o)),Math.abs(i-s.lagged)<_o?s.lagged=i:n=!0,r+=i-s.lagged}Ni(s.element,r===0?s.saved:`0 ${Pu(r)}px`),s.shift=r}return n}write(t){const n=Math.round(t);this.written=n;const i=this.options.scroller;i?i.scrollTop=n:window.scrollTo({top:n,behavior:"instant"})}position(){const t=this.options.scroller;return t?t.scrollTop:window.scrollY}viewportHeight(){const t=this.options.scroller;return t?t.clientHeight:window.innerHeight}limit(){const t=this.options.scroller??document.documentElement;return Math.max(0,t.scrollHeight-this.viewportHeight())}clamp(t){return Math.max(0,Math.min(this.limit(),t))}resolve(t){if(typeof t=="number")return t;const n=this.options.scroller??document,i=typeof t=="string"?n.querySelector(t):t;if(!i)return this.current;const s=this.options.scroller?.getBoundingClientRect().top??0,r=this.effects.find(o=>o.element===i)?.shift??0;return i.getBoundingClientRect().top-s+this.position()-r}}function Ni(e,t){t?e.style.setProperty("translate",t):e.style.removeProperty("translate")}function Pu(e){return Math.round(e*100)/100}function _u(e,t){switch(t){case"play":if(e.progress()>=1)break;e.reversed()?e.reverse():e.play();break;case"reverse":if(e.progress()<=0)break;e.reversed()?e.play():e.reverse();break;case"pause":e.pause();break;case"resume":e.resume();break;case"restart":e.restart();break;case"reset":e.pause(),e.progress(0);break;case"complete":e.pause(),e.progress(1);break}}function Wi(e,t,n,i,s=()=>{}){const r=d=>typeof d=="string"?e.query(d)??void 0:d,o=r(t.trigger)??i;if(!o){s(`gsap-compat: scrollTrigger has no trigger element${typeof t.trigger=="string"?` for "${t.trigger}"`:""}`);return}const a=t.scrub===void 0||t.scrub===!1?!1:t.scrub,l=(t.toggleActions??"play none none none").trim().split(/\s+/);let c=0,h;const u=(d,m)=>()=>{m?.(),n&&!a&&_u(n,l[d]??"none"),t.once&&d===0&&queueMicrotask(()=>h.destroy())},f=t.containerAnimation?Hu(e,t.containerAnimation,o,s):void 0;return h=new Ie({trigger:o,start:t.start,end:t.end,scrub:a===!1?void 0:a,pin:t.pin===!0?!0:r(t.pin),scroller:r(t.scroller),horizontal:t.horizontal,pinSpacing:t.pinSpacing,onRefresh:t.invalidateOnRefresh&&n?.invalidate?()=>n.invalidate():void 0,snap:t.snap===void 0?void 0:Iu(t.snap,n),markers:t.markers,container:f,onUpdate:(d,m)=>{if(n&&a!==!1&&n.progress(d),t.onUpdate){const p=d<c||m<0?-1:1;t.onUpdate({progress:d,velocity:m,direction:p})}c=d},onEnter:u(0,t.onEnter),onLeave:u(1,t.onLeave),onEnterBack:u(2,t.onEnterBack),onLeaveBack:u(3,t.onLeaveBack)}),n&&a===!1&&n.progress(0),h.start(),e.own(h)}function Iu(e,t){const n=s=>s==="labels"?r=>Cu(r,t?.labelProgresses?.()??[]):s;if(typeof e!="object"||Array.isArray(e))return n(e);const i=e.ease?xe(e.ease):void 0;return{snapTo:n(e.snapTo),duration:e.duration,delay:e.delay,ease:i?i.fn??J(i.easing):void 0}}function Cu(e,t){return t.reduce((n,i)=>Math.abs(i-e)<Math.abs(n-e)?i:n,t[0]??e)}function Hu(e,t,n,i){const s=()=>t.timeline.getTracks({property:"x"}).map(r=>r.target).filter(r=>{const o=e.elementFor(r);return!!o&&o!==n&&o.contains(n)});return s().length===0&&i("gsap-compat: containerAnimation does not move an ancestor of the trigger along x"),{range:()=>{const r=t.scrollTrigger;return r||i("gsap-compat: containerAnimation needs its own scrollTrigger (created before this one)"),{start:r?.startOffset??0,end:r?.endOffset??0}},progress:()=>t.progress(),shiftAt:r=>{const o=t.timeline.getStateAtTime(r*t.timeline.duration);let a=0;for(const l of s()){const c=o.values.get(l)?.get("x");typeof c=="number"&&(a+=c)}return a}}}class Io{conditions={};scope;host;items=[];snapshots=new Map;constructor(t,n){this.host=t,this.scope=n}add(t){const n=this.host.collector;this.host.setCollector(this);try{const i=t();return typeof i=="function"&&this.items.push({revert:i}),i}finally{this.host.setCollector(n)}}track(t){this.items.push(t)}touch(t,n){this.snapshots.has(t)||this.snapshots.set(t,{name:n,style:t.getAttribute("style"),d:t.getAttribute("d")})}revert(){for(const t of this.items.splice(0).reverse())t.revert?t.revert():t.kill?t.kill():t.destroy?.();for(const[t,{name:n,style:i,d:s}]of this.snapshots)i===null?t.removeAttribute("style"):t.setAttribute("style",i),s!==null&&t.setAttribute("d",s),this.host.forget(n);this.snapshots.clear()}kill(){this.revert()}}class $u{host;scope;entries=[];listeners=[];scheduled=!1;constructor(t,n){this.host=t,this.scope=n}add(t,n){const i={conditions:t,setup:n,queries:new Map},s=typeof t=="string"?{matches:t}:t;if(typeof window<"u"&&typeof window.matchMedia=="function")for(const[r,o]of Object.entries(s)){const a=window.matchMedia(o);i.queries.set(r,a);const l=()=>this.scheduleUpdate();a.addEventListener("change",l),this.listeners.push(()=>a.removeEventListener("change",l))}return this.entries.push(i),this.update(i),this}revert(){for(const t of this.listeners.splice(0))t();for(const t of this.entries.splice(0))t.context?.revert()}kill(){this.revert()}scheduleUpdate(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1;for(const t of this.entries)this.update(t)}))}update(t){const n={};for(const[o,a]of t.queries)n[o]=a.matches;const i=Object.values(n).some(Boolean),s=i?JSON.stringify(n):void 0;if(s===t.key||(t.context?.revert(),t.context=void 0,t.key=s,!i))return;const r=new Io(this.host,this.scope);r.conditions=n,r.add(()=>t.setup(r)),t.context=r}}class Ru{frames;canvas;context;options;images;ready;current=0;drawn=-1;loadedCount=0;inFlight=0;destroyed=!1;onResize=()=>this.resize();constructor(t,n){this.canvas=t,this.context=t.getContext("2d"),this.options=n,this.frames=Math.max(1,Math.floor(n.frames)),this.images=new Array(this.frames),this.ready=new Array(this.frames).fill(!1),typeof window<"u"&&window.addEventListener("resize",this.onResize,{passive:!0}),this.resize(),this.pump()}get frame(){return this.current}set frame(t){this.current=Math.max(0,Math.min(this.frames-1,t)),this.draw()}get loaded(){return this.loadedCount}destroy(){this.destroyed=!0,typeof window<"u"&&window.removeEventListener("resize",this.onResize);for(const t of this.images)t&&(t.src="")}resize(){const t=typeof window<"u"?Math.min(window.devicePixelRatio||1,2):1,n=Math.round(this.canvas.clientWidth*t),i=Math.round(this.canvas.clientHeight*t);n>0&&i>0&&(this.canvas.width!==n||this.canvas.height!==i)&&(this.canvas.width=n,this.canvas.height=i),this.drawn=-1,this.draw()}draw(){const t=Math.round(this.current),n=this.nearestReady(t);if(n===-1||n===this.drawn||!this.context)return;const i=this.images[n],{width:s,height:r}=this.canvas,o=(this.options.fit??"cover")==="cover"?Math.max(s/i.naturalWidth,r/i.naturalHeight):Math.min(s/i.naturalWidth,r/i.naturalHeight),a=i.naturalWidth*o,l=i.naturalHeight*o;this.context.clearRect(0,0,s,r),this.context.drawImage(i,(s-a)/2,(r-l)/2,a,l),this.drawn=n,this.pump()}nearestReady(t){for(let n=0;n<this.frames;n++){if(t-n>=0&&this.ready[t-n])return t-n;if(t+n<this.frames&&this.ready[t+n])return t+n}return-1}pump(){const t=this.options.concurrency??6,n=Math.round(this.current);for(let i=0;i<this.frames&&this.inFlight<t;i++)for(const s of i===0?[n]:[n+i,n-i])s<0||s>=this.frames||this.images[s]||this.inFlight>=t||this.load(s)}load(t){const n=new Image;n.decoding="async",this.images[t]=n,this.inFlight++;const i=s=>{if(!this.destroyed){if(this.inFlight--,s){this.ready[t]=!0,this.loadedCount++,this.options.onProgress?.(this.loadedCount,this.frames);const r=Math.round(this.current);(Math.abs(t-r)<Math.abs(this.drawn-r)||this.drawn===-1)&&(this.drawn=-1,this.draw())}this.pump()}};n.onload=()=>i(!0),n.onerror=()=>i(!1),n.src=this.options.url(t)}}const Ou={opacity:0,y:-16},Lu={opacity:0,y:16};async function Fu(e,t,n,i){const s=t.collector?.scope??t.root,r=s.ownerDocument??s,o=()=>i.shared?[...s.querySelectorAll(i.shared)]:[];if(i.native&&typeof r.startViewTransition=="function")return Du(r,i,o);const a=i.duration??.35,l=i.ease??"power2.inOut",c=g=>new Promise(y=>{g(y)||y()}),h=o(),u=h.length?Ii(t,h):void 0,f=i.from!==void 0?Co(t,i.from,i.shared):[];if(f.length&&i.leave!==!1){const g=i.leave??Ou;await c(y=>e.to(f,{...g,duration:a,ease:l,onComplete:y}))}await i.update();const d=[],m=typeof i.to=="function"?i.to():i.to,p=m!==void 0?Co(t,m,i.shared):[];if(p.length&&i.enter!==!1){const g=i.enter??Lu;d.push(c(y=>e.fromTo(p,g,{...yo(g),duration:a,ease:l,onComplete:y})))}if(u){const g=o().filter(y=>!h.includes(y));g.length&&d.push(c(y=>Hi(t,n,u,{targets:g,duration:a*1.4,ease:l,enter:!1,onComplete:y})))}await Promise.all(d)}function Co(e,t,n){const i=e.resolveTargets(t).map(s=>e.elementFor(s)).filter(s=>!!s);return n?i.flatMap(s=>!s.querySelector(n)&&!s.matches(n)?[s]:[...s.children].filter(r=>!r.matches(n)&&!r.querySelector(n))):i}async function Du(e,t,n){const i=(a,l)=>{const c=a.dataset?.flipId;c&&a.style.setProperty("view-transition-name",l?`tf-${c.replace(/[^\w-]/g,"-")}`:"")},s=n();s.forEach(a=>i(a,!0));let r=[];await e.startViewTransition(async()=>{s.forEach(a=>i(a,!1)),await t.update(),r=n(),r.forEach(a=>i(a,!0))}).finished,r.forEach(a=>i(a,!1))}const Ho={create:(e,t)=>vi(e,Hr(t))},$o={create:(e,t)=>vi(e,{fn:$r(t)})},Ro={create:(e,t)=>vi(e,{fn:Rr(t)})},Bu=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),Oo=.5,Nu="power1.inOut";function Wu(e){return e.keyframes!==void 0&&e.keyframes!==null}function Ku(e){const t=e.keyframes,n={};for(const[c,h]of Object.entries(e))Bu.has(c)||(n[c]=h);if(Array.isArray(t))return t.map(c=>({...n,...c,duration:c.duration??e.duration??Oo}));const i=Object.entries(t),s=e.duration??Oo,r=t.easeEach??e.easeEach??Nu;if(i.length>0&&i.every(([c])=>/^\s*-?\d+(\.\d+)?\s*%\s*$/.test(c)||c==="easeEach")){const c=i.filter(([f])=>f!=="easeEach").map(([f,d])=>({at:Number.parseFloat(f)/100,step:d})).sort((f,d)=>f.at-d.at),h=[];let u=0;for(const{at:f,step:d}of c){const m=Math.max(0,f-u);h.push({...n,ease:r,...d,duration:m*s}),u=f}return h}const o=i.filter(([c,h])=>c!=="easeEach"&&Array.isArray(h)),a=Math.max(0,...o.map(([,c])=>c.length)),l=[];for(let c=0;c<a;c++){const h={...n,ease:r,duration:s/a};for(const[u,f]of o)c<f.length&&(h[u]=f[c]);l.push(h)}return l}function Lo(e,t,n,i={}){const s=t.collector?.scope??t.root,r=typeof i.scroller=="string"?s.querySelector(i.scroller):i.scroller??null,o={x:r?r.scrollLeft:window.scrollX,y:r?r.scrollTop:window.scrollY},a={x:r?r.scrollWidth-r.clientWidth:document.documentElement.scrollWidth-window.innerWidth,y:r?r.scrollHeight-r.clientHeight:document.documentElement.scrollHeight-window.innerHeight},l=(w,k)=>{if(k===void 0)return o[w];if(typeof k=="number")return k;if(k==="max")return a[w];const M=typeof k=="string"?s.querySelector(k):k;if(!M)return o[w];const S=M.getBoundingClientRect(),A=r?.getBoundingClientRect(),E=(w==="x"?i.offsetX:i.offsetY)??i.offset??0;return w==="x"?S.left-(A?.left??0)+o.x-E:S.top-(A?.top??0)+o.y-E},c=typeof n=="object"&&n!==null&&!("nodeType"in n)?{x:l("x",n.x),y:l("y",n.y)}:{x:o.x,y:l("y",n)},h={x:Math.max(0,Math.min(a.x,c.x)),y:Math.max(0,Math.min(a.y,c.y))},u={...o},f=()=>{r?(r.scrollLeft=u.x,r.scrollTop=u.y):window.scrollTo({left:u.x,top:u.y,behavior:"instant"})},d=["wheel","touchstart","keydown"],m=r??window,p=()=>{y.kill(),g()},g=()=>{for(const w of d)m.removeEventListener(w,p)},y=e.to(u,{x:h.x,y:h.y,duration:i.duration??1,ease:i.ease??"power2.inOut",onStart:i.onStart,onUpdate:()=>{f(),i.onUpdate?.()},onComplete:()=>{g(),i.onComplete?.()}});if(i.autoKill!==!1)for(const w of d)m.addEventListener(w,p,{passive:!0});return y}function Yu(e,t,n){const i=e.collector?.scope??e.root,s=typeof t=="string"?[...i.querySelectorAll(t)]:"nodeType"in t?[t]:Array.from(t),{interval:r=.1,batchMax:o,onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h,...u}=n,f={onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h},d={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},m={},p=y=>{m[y]!==void 0&&clearTimeout(m[y]),m[y]=void 0;const w=d[y].splice(0);w.length>0&&f[y]?.(w)},g=(y,w)=>{if(f[y]){if(d[y].push(w),o!==void 0&&d[y].length>=o)return p(y);m[y]===void 0&&(m[y]=setTimeout(()=>p(y),r*1e3))}};return s.map(y=>Wi(e,{...u,trigger:y,onEnter:()=>g("onEnter",y),onLeave:()=>g("onLeave",y),onEnterBack:()=>g("onEnterBack",y),onLeaveBack:()=>g("onLeaveBack",y)})).filter(y=>y!==void 0)}class ut{compat;stage;options;autoplayPending;started=!1;killed=!1;recipe=[];firstElement;scrollDriver;events=[];ranges=[];playhead={time:0,iteration:0,direction:"forward",fresh:!0};waitingToWrap=!1;finishedThisFrame=!1;backwards=!1;constructor(t,n={}){this.stage=t;const i={...n,onWarning:n.onWarning??t.onWarning};if(this.options=i,this.compat=new It({...i,startValue:(s,r)=>{const o=t.objectFor(s);if(o)return Vu(o[r]);const a=t.appliedValue(s,r);if(a!==void 0)return a;if(r==="d")return oo(t.elementFor(s))??void 0;if(r==="text")return t.elementFor(s)?.textContent??void 0;if(r==="strokeDasharray"||r==="strokeDashoffset"){const l=Wo(t.elementFor(s));if(l!==void 0)return r==="strokeDasharray"?[l,l]:0}},startVelocity:(s,r)=>t.velocityOf(s,r),layoutColumns:s=>No(s.map(r=>t.elementFor(r))),random:()=>t.utils.random(0,1)}),this.compat.timeline.onComplete=()=>{this.finishedThisFrame=!0},t.collector?.track(this),t.liveTimelines.add(this),this.autoplayPending=!i.paused&&!i.scrollTrigger,i.scrollTrigger){const s=i.scrollTrigger;queueMicrotask(()=>{this.killed||(this.scrollDriver=Wi(t,s,this,this.firstElement,r=>i.onWarning?.(r)))})}this.autoplayPending&&queueMicrotask(()=>{this.autoplayPending&&this.play()})}get timeline(){return this.compat.timeline}get scrollTrigger(){return this.scrollDriver}to(t,n,i){return Wu(n)?this.record(()=>this.keyframed(t,n,i)):this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.to(r,s,o)))}from(t,n,i){return this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.from(r,s,o)))}fromTo(t,n,i,s){return this.record(()=>this.tween(t,[n,i],s,([r,o],a,l)=>this.compat.fromTo(a,r,o,l)))}set(t,n,i){return this.record(()=>this.tween(t,[n],i,([s],r,o)=>this.compat.set(r,s,o)))}addLabel(t,n){return this.record(()=>this.compat.addLabel(t,n))}add(t,n){return this.record(()=>{t.autoplayPending=!1,t.timeline.stop(),t.stage.deactivate(t.timeline),this.compat.add(t.compat,n)})}invalidate(){const t=this.compat.progress();this.compat.progress(0),this.stage.render(this.timeline),this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();return this.syncDuration(),this.compat.progress(t),this.stage.render(this.timeline),this}call(t,n=[],i){return this.record(()=>{const s=this.compat.addEvent(i);this.events.push({time:s,run:()=>t(...n)})})}addPause(t,n,i=[]){return this.record(()=>{const s=this.compat.addEvent(t);this.events.push({time:s,pause:!0,run:()=>n?.(...i)})})}tweenTo(t,n={}){return this.tweenFromTo(this.timeline.currentTime/1e3,t,n)}tweenFromTo(t,n,i={}){this.pause(),this.seek(t);const s=this.timeline.currentTime,r=Math.max(0,Math.min(this.timeline.duration,this.compat.timeOf(n))),o={time:s},a=i.duration??Math.abs(r-s)/1e3/(this.timeScale()||1),l=new ut(this.stage,{onStart:i.onStart,onComplete:i.onComplete});return l.to(o,{time:r,duration:a,ease:i.ease??"none",onUpdate:()=>{this.moveTo(o.time),i.onUpdate?.()}}),l}play(){this.autoplayPending=!1,this.started||(this.started=!0,this.options.onStart?.());const t=this.timeline.playbackState==="playing",n=this.timeline.playbackState==="paused";if(this.timeline.play(),!t){const i=this.timeline,s=i.direction==="forward"?i.currentTime===0:i.currentTime===i.duration;this.playhead={...this.readPlayhead(),fresh:s&&!n},this.waitingToWrap=!1}return this.stage.liveTimelines.add(this),this.stage.render(this.timeline),this.stage.activate(this.timeline,{onUpdate:()=>this.afterFrame()}),this}pause(){return this.autoplayPending=!1,this.timeline.pause(),this.stage.deactivate(this.timeline),this}resume(){return this.play()}restart(){return this.timeline.stop(),this.backwards=!1,this.play()}reverse(){this.backwards=!this.backwards;const t=this.timeline.playbackState==="idle"&&this.timeline.direction==="forward";return this.timeline.reverse(),t&&this.timeline.currentTime===0&&this.timeline.seek(this.timeline.duration),this.play()}labelProgresses(){const t=this.timeline.duration;return t>0?this.compat.labelTimes().map(n=>n/t):[]}reversed(){return this.timeline.direction==="reverse"}seek(t){return this.autoplayPending=!1,this.compat.seek(t),this.stage.render(this.timeline),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,this.options.onUpdate?.(),this}progress(t){return t===void 0?this.compat.progress():(this.autoplayPending=!1,this.moveTo(Math.max(0,Math.min(1,t))*this.timeline.duration),this.compat.progress())}timeScale(t){return this.compat.timeScale(t)}duration(){return this.compat.duration()}isActive(){return this.timeline.playbackState==="playing"}kill(){return this.killed=!0,this.stage.liveTimelines.delete(this),this.scrollDriver?.destroy(),this.scrollDriver=void 0,this.autoplayPending=!1,this.timeline.stop(),this.stage.deactivate(this.timeline),this.compat.kill(),this}toDefinition(){return this.compat.toDefinition()}killTweensOf(t,n){for(const i of t)for(const s of n??[void 0])this.timeline.removeTracks({target:i,...s!==void 0&&{property:s}});this.timeline.tracks.length===0&&this.events.length===0&&this.kill()}record(t){return this.recipe.push(t),t(),this.syncDuration(),this}syncDuration(){if(this.events.length===0)return;this.timeline.setDuration(void 0);const t=Math.max(...this.events.map(n=>n.time));t>this.timeline.duration&&this.timeline.setDuration(t)}readPlayhead(){const t=this.timeline;return{time:t.currentTime,iteration:t.loopIteration,direction:t.direction}}moveTo(t){const n=this.playhead;this.timeline.seek(t),this.stage.render(this.timeline);const i={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:t>=n.time?"forward":"reverse"},s={...n,iteration:i.iteration,direction:i.direction};this.playhead={...this.readPlayhead()},this.waitingToWrap=!1,this.runCrossings(s,i,!1),this.options.onUpdate?.()}refreshForRepeat(){const t=this.timeline.currentTime;this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();this.syncDuration(),this.timeline.seek(Math.min(t,this.timeline.duration))}afterFrame(){const t=this.timeline,n=t.repeatDelayRemaining>0;if(this.waitingToWrap&&n){this.options.onUpdate?.();return}this.waitingToWrap=!1;const i=this.playhead,s=this.readPlayhead();this.playhead=s;const r=this.options.yoyo===!0;n&&!r&&s.iteration>i.iteration&&(this.playhead={time:0,iteration:s.iteration,direction:"forward",fresh:!0},this.waitingToWrap=!0);const o=this.runCrossings(i,s,n);if(this.options.onUpdate?.(),this.finishedThisFrame&&!o){this.finishedThisFrame=!1;const a=t.currentTime===0&&t.direction==="reverse";!this.scrollDriver&&!r&&this.stage.liveTimelines.delete(this),a&&this.backwards?this.options.onReverseComplete?.():this.options.onComplete?.()}this.finishedThisFrame=!1}runCrossings(t,n,i){if(this.events.length===0&&this.ranges.length===0&&!this.options.onRepeat&&!this.options.repeatRefresh)return!1;const s=this.events,{crossings:r,passes:o}=mi(s.map(a=>a.time),t,n,{duration:this.timeline.duration,alternate:this.options.yoyo===!0,holding:i});for(const a of r){if(this.killed)return!0;if(a.kind==="repeat"){this.options.repeatRefresh&&this.refreshForRepeat(),this.options.onRepeat?.();continue}const l=s[a.index];if(!(l.direction&&l.direction!==a.direction)){if(l.pause)return this.timeline.seek(l.time),this.stage.render(this.timeline),this.pause(),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,l.run(),!0;l.run()}}for(const a of this.ranges)o.some(([c,h])=>c!==h&&Math.max(c,h)>=a.start&&Math.min(c,h)<=a.end)&&a.run();return!1}tween(t,n,i,s){const r=this.resolve(t);if(!r)return;const{onStart:o,onUpdate:a,onComplete:l}=n[n.length-1];if(o||a||l){let c=1/0,h=-1/0;const u=(f,d,m)=>{s(f,d,m),c=Math.min(c,this.compat.lastStart),h=Math.max(h,this.compat.lastEnd)};if(this.buildTween(r,n,i,u),c===1/0)return;o&&this.events.push({time:c,direction:"forward",run:o}),a&&this.ranges.push({start:c,end:h,run:a}),l&&this.events.push({time:h,direction:"forward",run:l});return}this.buildTween(r,n,i,s)}keyframed(t,n,i){const s=this.resolve(t);if(!s)return;const r=Ku(n);if(r.length===0)return;const o=s.length>1?Ti(n.stagger,this.staggerContext(s)):void 0,a=s.map(g=>this.targetFor(g)).filter(g=>g!==void 0),l=o?a.map(g=>[g]):[a],c=o?qe(s.length,o).map(g=>g/1e3):[0],h=this.compat.timeOf(i)/1e3+un(n.delay,0)/1e3;let u=1/0,f=-1/0;if(l.forEach((g,y)=>{r.forEach((w,k)=>{const M=k===0?h+c[y]:">";this.tween(g,[w],M,([S],A,E)=>this.compat.to(A,S,E)),u=Math.min(u,this.compat.lastStart),f=Math.max(f,this.compat.lastEnd)})}),u===1/0)return;const{onStart:d,onUpdate:m,onComplete:p}=n;d&&this.events.push({time:u,direction:"forward",run:d}),m&&this.ranges.push({start:u,end:f,run:m}),p&&this.events.push({time:f,direction:"forward",run:p})}staggerContext(t){return{count:t.length,columnsFromLayout:()=>No(t.map(n=>this.stage.elementFor(n))),random:()=>this.stage.utils.random(0,1)}}buildTween(t,n,i,s){const r=t.map(f=>this.targetFor(f));if(!(t.length>1&&(n.some(qu)||t.some(f=>this.stage.objectFor(f)!==void 0)))){const f=this.targetFor(t[0]);s(n.map(d=>this.prepare(Bo(d,0,f,this.stage.utils,r),t)),t,i);return}const a=n.length-1,{stagger:l,...c}=n[a],h=Ti(l,this.staggerContext(t)),u=h?qe(t.length,h).map(f=>f/1e3):t.map(()=>0);t.forEach((f,d)=>{const m=d===0?un(c.delay,0)/1e3+u[0]:0,p=d===0?0:u[d]-u[d-1],g=d===0?i:`<${p<0?"-":"+"}${Math.abs(p).toFixed(6)}`,w=n.map((k,M)=>M===a?{...c,delay:m}:k).map(k=>this.prepare(Bo(k,d,this.targetFor(f),this.stage.utils,r),[f]));s(w,[f],g)})}targetFor(t){return this.stage.elementFor(t)??this.stage.objectFor(t)}prepare(t,n){const i=o=>this.options.onWarning?.(o),s=o=>this.stage.query(o);let r=t;if(t.motionPath!==void 0){const o=iu(t.motionPath,{query:s,targets:n.map(a=>this.stage.elementFor(a)).filter(a=>!!a),warn:i});r={...r,motionPath:o}}if(t.morphSVG!==void 0){const o=su(t.morphSVG,s,i),{morphSVG:a,...l}=r;r=o?{...r,morphSVG:o}:l}if(t.drawSVG!==void 0){const o=Wo(this.stage.elementFor(n[0]));if(o===void 0){i("gsap-compat: drawSVG needs an SVG shape with a stroke (path, line, circle…)");const{drawSVG:a,...l}=r;r=l}else r=Ih(r,o)}return r}resolve(t){const n=this.stage.resolveTargets(t);if(n.length===0){this.options.onWarning?.(`gsap-compat: no elements found for target ${Uu(t)}`);return}return this.firstElement??=n.map(i=>this.stage.elementFor(i)).find(i=>i!==void 0),n}}function Fo(e=new no){const t=r=>{const{config:o}=hn(r);return new ut(e,{repeat:o.repeat,yoyo:o.yoyo,repeatDelay:o.repeatDelay,paused:o.paused,onStart:o.onStart,onUpdate:o.onUpdate,onComplete:o.onComplete,onRepeat:o.onRepeat,onReverseComplete:o.onReverseComplete,repeatRefresh:o.repeatRefresh,scrollTrigger:o.scrollTrigger})},n=r=>{const{onStart:o,onUpdate:a,onComplete:l,onRepeat:c,onReverseComplete:h,repeatRefresh:u,...f}=r;return f},i=r=>(r&&e.collector?.track(r),r),s={stage:e,ticker:e.ticker,utils:e.utils,getProperty:(r,o)=>{const[a]=e.resolveTargets(r);if(a===void 0)return;const l=e.objectFor(a);return l?l[o]:e.appliedValue(a,o)??Jr(o)},scrollTrigger:r=>i(Wi(e,r)),scrollBatch:(r,o)=>Yu(e,r,o).map(a=>i(a)),scrollTo:(r,o)=>Lo(s,e,r,o),refreshScroll:()=>{Ie.refreshAll(),Bi.refreshAll()},smoothScroll:(r={})=>{const o=typeof r.scroller=="string"?(e.collector?.scope??e.root).querySelector(r.scroller):r.scroller;return i(new Bi({...r,scroller:o}).start())},context:(r,o)=>{const a=new Io(e,o);return r&&a.add(()=>r(a)),a},matchMedia:r=>new $u(e,r),customEase:Ho.create,customBounce:$o.create,customWiggle:Ro.create,pageTransition:r=>Fu(s,e,o=>new ut(e,o),r),imageSequence:(r,o)=>{const a=typeof r=="string"?(e.collector?.scope??e.root).querySelector(r):r;if(!(a instanceof HTMLCanvasElement))throw new Error(`gsap-compat: imageSequence needs a <canvas>, got ${String(r)}`);return i(new Ru(a,o))},quickTo:(r,o,a={})=>{const l=new ut(e,{paused:!0}),[c]=e.resolveTargets(r);return Object.assign(u=>{if(!c)return;const f=a.spring!==void 0?e.velocityOf(c,o)??0:0;l.compat.reset(),l.compat.to(c,{[o]:u,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:Xu(a.spring,o,f)}}),l.timeline.stop(),l.timeline.play(),e.activate(l.timeline)},{tween:l,kill:()=>l.kill()})},timeline:r=>new ut(e,r),to:(r,o)=>{if(o.scrollTo!==void 0){const{scrollTo:a,...l}=o,c=typeof a=="object"&&a!==null&&!("nodeType"in a)?a:{},h=typeof r!="string"&&r!==window&&r.nodeType===1;return Lo(s,e,a,{...l,offsetX:c.offsetX,offsetY:c.offsetY,scroller:h?r:void 0})}return t(o).to(r,n(o))},from:(r,o)=>t(o).from(r,n(o)),fromTo:(r,o,a)=>t(a).fromTo(r,o,n(a)),set:(r,o)=>t(o).set(r,n(o)),delayedCall:(r,o,a)=>new ut(e).call(o,a,r),killTweensOf:(r,o)=>{const a=e.resolveTargets(r),l=typeof o=="string"?o.split(",").map(c=>c.trim()).filter(Boolean):o;for(const c of[...e.liveTimelines])c.killTweensOf(a,l)},convertToPath:r=>ou(r,e.root),splitText:(r,o)=>{const a=e.collector?.scope??e.root,l=typeof r=="string"?Array.from(a.querySelectorAll(r)):"nodeType"in r?[r]:Array.from(r);return i(pu(l,o))},draggable:(r,o)=>i(hu(s,e,r,o)),getFlipState:r=>Ii(e,r),flipFrom:(r,o)=>Hi(e,a=>new ut(e,a),r,o),flip:(r,o,a)=>{const l=Ii(e,r);return o(),Hi(e,c=>new ut(e,c),l,{targets:r,...a})}};return s}const tt=Fo();function Xu(e,t,n){return e===!0?{velocity:{[t]:n}}:typeof e=="string"?{preset:e,velocity:{[t]:n}}:{...e,velocity:{[t]:n}}}function qu(e){return e.morphSVG!==void 0||e.drawSVG!==void 0||e.text!==void 0||e.scrambleText!==void 0||Do(e)}function Do(e){return Object.entries(e).some(([t,n])=>(typeof n=="function"||Gr(n))&&!Mi.has(t))}function Bo(e,t,n,i,s){if(!Do(e))return e;const r={};for(const[o,a]of Object.entries(e))Mi.has(o)?r[o]=a:typeof a=="function"?r[o]=a(t,n,s):Gr(a)?r[o]=i.resolveRandomString(a):r[o]=a;return r}function No(e){const t=e.map(i=>i?.getBoundingClientRect().top);if(t[0]===void 0)return e.length;let n=0;for(const i of t){if(i===void 0||Math.abs(i-t[0])>1)break;n++}return Math.max(1,n)}function Wo(e){const t=e;if(typeof t?.getTotalLength=="function")return t.getTotalLength()}function Vu(e){if(typeof e=="number"||typeof e=="string"||Array.isArray(e)&&e.every(t=>typeof t=="number"))return e}function Uu(e){return typeof e=="string"?`"${e}"`:String(e)}class Ki{media;offset;driftTolerance;constructor(t,n={}){this.media=t,this.offset=n.offset??0,this.driftTolerance=Math.max(0,n.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,n){const i=this.targetTime(t);n?(this.media.paused&&this.safePlay(),Math.abs(this.media.currentTime-i)>this.driftTolerance&&(this.media.currentTime=i)):(this.media.paused||this.media.pause(),this.media.currentTime!==i&&(this.media.currentTime=i))}seek(t){this.media.currentTime=this.targetTime(t)}setRate(t){this.media.playbackRate=t}dispose(){this.media.paused||this.media.pause()}safePlay(){const t=this.media.play();t&&typeof t.catch=="function"&&t.catch(()=>{})}}function Ko(e,t,n,i,s){const r=n-s;if(r<0){t.paused||t.pause(),t.currentTime=0;return}e.update(r,i)}class pn{container;timeline=null;adapter;animationFrameId;lastTime;options;targets={};isDestroyed=!1;mediaSync;mediaTargets=[];symbolInstances=[];scenarioList=[];scenarioId;authored=new Map;markerList=[];listeners=new Set;playhead={time:0,iteration:0,direction:"forward"};stepping=!1;lastMarkerId=null;reducedQuery;onReducedChange=()=>this.applyReducedMotion();visibilityObserver;onScreen=!0;pausedByVisibility=!1;autoplayWhenSeen=!1;onDocumentVisibility=()=>this.updateVisibility();constructor(t,n={}){if(typeof t=="string"){const i=document.querySelector(t);if(!i)throw new Error(`Container not found: ${t}`);this.container=i}else this.container=t;this.options=n,this.adapter=new Ct}async load(t){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(t)}async loadSource(t){let n;if(typeof t=="string"){const i=await fetch(t);if(!i.ok)throw new Error(`Failed to load animation: ${i.statusText}`);n=await i.json()}else n=t;this.useDefinition(n),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(t){const n={...t.config};this.options.speed!==void 0&&(n.speed=this.options.speed),this.options.loop!==void 0&&(n.loop=this.options.loop),this.options.alternate!==void 0&&(n.alternate=this.options.alternate),this.timeline=zt({...t,config:n}),this.markerList=this.timeline.markers,this.lastMarkerId=null,this.options.onComplete&&(this.timeline.onComplete=this.options.onComplete),this.options.onUpdate&&(this.timeline.onUpdate=this.options.onUpdate),this.autoRegisterTargets(),this.setupSymbolInstances(),this.scanMedia()}async loadScenarios(t,n={}){if(t.length===0)throw new Error("tinyfly: loadScenarios needs at least one scenario");const i=new Set;for(const r of t){if(i.has(r.id))throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);i.add(r.id)}const s=n.initial===void 0?t[0]:t.find(r=>r.id===n.initial);if(!s)throw new Error(`tinyfly: there is no scenario "${n.initial}"`);this.scenarioList=[...t],this.scenarioId=s.id,await this.loadSource(s.timeline)}get scenarios(){return this.scenarioList.map(t=>({id:t.id,label:t.label??t.id}))}get scenario(){return this.scenarioId}setScenario(t){const n=this.scenarioList.find(a=>a.id===t);if(!n||!this.timeline)return!1;if(t===this.scenarioId)return!0;const i=this.isPlaying,s=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=t,this.useDefinition(n.timeline),this.lastMarkerId=null;let o=0;return this.reducedMotion||s?o=this.duration:r!==void 0&&(o=this.markers.find(a=>a.id===r)?.time??0),this.seek(o),i&&!this.reducedMotion?(this.stepping=this.options.stepMode===!0,this.startPlaying()):this.notify(),!0}rememberAuthored(t){if(this.authored.has(t))return;const n={style:t.getAttribute("style")};t.children.length===0&&(n.text=t.textContent??"");const i=t.tagName.toLowerCase()==="path"?t:t.querySelector("path");i&&(n.path={element:i,d:i.getAttribute("d")}),this.authored.set(t,n)}restoreAuthored(){for(const[t,n]of this.authored){n.style===null?t.removeAttribute("style"):t.setAttribute("style",n.style),n.text!==void 0&&t.textContent!==n.text&&(t.textContent=n.text),n.path&&(n.path.d===null?n.path.element.removeAttribute("d"):n.path.element.setAttribute("d",n.path.d));const i=t.dataset;i&&delete i.shineBase}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){for(const t of this.listeners)t()}get reducedMotion(){return this.reducedQuery?.matches===!0}get markers(){return this.markerList}get currentMarker(){const t=this.currentTime;let n;for(const i of this.markers)if(i.time<=t+.5)n=i;else break;return n}caption(t,n){const i=t?this.markers.find(o=>o.id===t):this.currentMarker;if(!i)return;const s=n??this.language(),r=o=>o?.[s]?.[i.id]??o?.[s.split("-")[0]]?.[i.id];return r(this.options.captions)??r(this.timeline?.captions)??i.label}next(){if(!this.timeline)return;const t=this.currentTime,n=this.markers.find(i=>i.time>t+.5);if(this.reducedMotion){this.seek(n?n.time:this.duration);return}t>=this.duration-.5||(this.stepping=n!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,n=[...this.markers].reverse().find(i=>i.time<t-.5);this.pause(),this.seek(n?n.time:0)}goToMarker(t){const n=this.markers.find(i=>i.id===t);n&&(this.pause(),this.seek(n.time))}language(){return this.container.closest("[lang]")?.getAttribute("lang")||(typeof document<"u"?document.documentElement.lang:"")||"en"}showInitialFrame(){if(!this.timeline)return;const t=this.options.initialFrame??"start";if(t==="none")return;const n=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,n))),this.applyState()}watchReducedMotion(){this.options.respectReducedMotion===!1||typeof window>"u"||typeof window.matchMedia!="function"||(this.reducedQuery??=window.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedQuery.addEventListener?.("change",this.onReducedChange),this.reducedQuery.matches&&this.applyReducedMotion())}applyReducedMotion(){!this.reducedMotion||!this.timeline||(this.autoplayWhenSeen=!1,this.pause(),this.seek(this.timeline.duration))}watchVisibility(){if(!(!this.options.playWhenVisible||typeof window>"u")){if(typeof IntersectionObserver=="function"){this.visibilityObserver?.disconnect(),this.visibilityObserver=new IntersectionObserver(n=>{for(const i of n)this.onScreen=i.isIntersecting;this.updateVisibility()}),this.visibilityObserver.observe(this.container);const t=this.container.getBoundingClientRect?.();t&&(t.width>0||t.height>0)&&(this.onScreen=t.bottom>0&&t.top<window.innerHeight&&t.right>0&&t.left<window.innerWidth)}document.addEventListener("visibilitychange",this.onDocumentVisibility)}}updateVisibility(){const t=this.onScreen&&document.visibilityState!=="hidden";!t&&this.isPlaying?(this.pausedByVisibility=!0,this.pause()):t&&(this.pausedByVisibility||this.autoplayWhenSeen)&&!this.reducedMotion&&(this.pausedByVisibility=!1,this.autoplayWhenSeen=!1,this.startPlaying())}announceMarker(){if(!this.options.onMarker)return;const t=this.currentMarker,n=t?.id;n!==this.lastMarkerId&&(this.lastMarkerId=n,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(n=>{const i=n,s=Number(i.getAttribute("data-tinyfly-start")??"0")||0,r=i.getAttribute("data-volume");r!==null&&(i.volume=Math.max(0,Math.min(1,Number(r)||0))),this.mediaTargets.push({el:i,startTime:s,sync:new Ki(i)})})}syncAllMedia(t,n){for(const i of this.mediaTargets)Ko(i.sync,i.el,t,n,i.startTime)}loadFromString(t){const n=JSON.parse(t);this.load(n)}registerTarget(t,n){if(typeof n=="string"){const i=this.container.querySelector(n);i&&(this.rememberAuthored(i),this.targets[t]=i,this.adapter.registerTarget(t,i))}else this.rememberAuthored(n),this.targets[t]=n,this.adapter.registerTarget(t,n)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(n=>{const i=n.closest("[data-tinyfly-symbol]");if(i&&i!==n)return;const s=n.getAttribute("data-tinyfly");s&&this.registerTarget(s,n)}),this.timeline&&new Set(this.timeline.tracks.map(i=>i.target)).forEach(i=>{if(!this.targets[i]){const s=this.container.querySelector(`[data-tinyfly="${i}"]`)||this.container.querySelector(`.${i}`)||this.container.querySelector(`#${i}`);s&&this.registerTarget(i,s)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const n=new Map(t.map(i=>[i.id,i]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(i=>{const s=i.getAttribute("data-tinyfly-symbol");if(!s)return;const r=n.get(s);if(!r||!r.timeline.tracks?.length)return;const o=new Ct;i.querySelectorAll("[data-tinyfly]").forEach(a=>{const l=a.getAttribute("data-tinyfly");l&&o.registerTarget(l,a)}),this.symbolInstances.push({adapter:o,timeline:zt(r.timeline)})})}attachMedia(t,n){this.mediaSync=new Ki(t,n),this.timeline&&(this.mediaSync.setRate(this.timeline.speed),this.mediaSync.update(this.timeline.currentTime,this.isPlaying))}detachMedia(){this.mediaSync?.dispose(),this.mediaSync=void 0}play(){!this.timeline||this.isDestroyed||(this.autoplayWhenSeen=!1,this.stepping=this.options.stepMode===!0,this.startPlaying())}startPlaying(){if(!this.timeline||this.isDestroyed)return;const t=this.timeline.playbackState==="idle";this.timeline.play(),t&&this.timeline.currentTime===0&&this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.update(this.timeline.currentTime,!0),this.syncAllMedia(this.timeline.currentTime,!0),this.startAnimationLoop(),this.notify()}pause(){this.timeline&&(this.stepping=!1,this.timeline.pause(),this.notify(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1),this.stopAnimationLoop())}stop(){this.timeline&&(this.timeline.stop(),this.stopAnimationLoop(),this.applyState(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1))}seek(t){this.timeline&&(this.timeline.seek(t),this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.seek(this.timeline.currentTime),this.syncAllMedia(this.timeline.currentTime,this.isPlaying))}setSpeed(t){this.timeline&&(this.timeline.speed=t,this.mediaSync?.setRate(t))}reverse(){this.timeline&&this.timeline.reverse()}get currentTime(){return this.timeline?.currentTime??0}get duration(){return this.timeline?.duration??0}get isPlaying(){return this.timeline?.playbackState==="playing"}destroy(){this.isDestroyed=!0,this.stopAnimationLoop(),this.reducedQuery?.removeEventListener?.("change",this.onReducedChange),this.visibilityObserver?.disconnect(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onDocumentVisibility),this.mediaSync?.dispose(),this.mediaSync=void 0;for(const t of this.mediaTargets)t.el.paused||t.el.pause();this.mediaTargets=[],this.adapter.clearTargets();for(const t of this.symbolInstances)t.adapter.clearTargets();this.symbolInstances=[],this.authored.clear(),this.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this.isDestroyed||!this.timeline)return;const i=n-(this.lastTime??n);this.lastTime=n;const s=this.playhead;this.timeline.tick(i),this.stopAtMarker(s),this.applyState();const r=this.timeline.playbackState==="playing";this.mediaSync?.update(this.timeline.currentTime,r),this.syncAllMedia(this.timeline.currentTime,r),this.timeline.playbackState==="playing"?this.animationFrameId=requestAnimationFrame(t):(this.animationFrameId=void 0,this.notify())};this.animationFrameId=requestAnimationFrame(t)}stopAtMarker(t){const n=this.timeline,i={time:n.currentTime,iteration:n.loopIteration,direction:n.direction};this.playhead=i;const s=this.markers;if(s.length===0)return;const{crossings:r}=mi(s.map(o=>o.time),t,i,{duration:n.duration,alternate:n.config.alternate===!0,holding:n.repeatDelayRemaining>0});for(const o of r){if(o.kind!=="event")continue;const a=s[o.index];if(this.stepping||a.pause){this.stepping=!1,n.pause(),n.seek(a.time),this.playhead={time:a.time,iteration:n.loopIteration,direction:n.direction};return}}}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}applyState(){if(!this.timeline)return;const t=this.timeline.currentTime;this.adapter.applyState(this.timeline.getStateAtTime(t)),this.announceMarker(),this.notify();for(const n of this.symbolInstances){const i=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(i>0?t%i:t))}}}async function zu(e,t,n={}){const i=new pn(e,{...n,autoplay:!0});return await i.load(t),i}function Gu(e,t={}){return new pn(e,t)}const Yo={play:"Play",pause:"Pause",prev:"Previous step",next:"Next step",restart:"Restart",scrub:"Position",speed:"Speed",reveal:"Reveal",step:"Step",of:"of",stepFormat:"{index} / {total}",scenario:"Scenario",fullscreen:"Full screen",exitFullscreen:"Exit full screen"},Xo="tinyfly-controls-style",ju=`
|
|
1
|
+
(function(b,be){typeof exports=="object"&&typeof module<"u"?be(exports):typeof define=="function"&&define.amd?define(["exports"],be):(b=typeof globalThis<"u"?globalThis:b||self,be(b.tinyfly=b.tinyfly||{}))})(this,(function(b){"use strict";function be(t){return typeof t=="object"&&t!==null&&t.type==="cubic-bezier"}function Ke(t){return typeof t=="object"&&t!==null&&t.type!=="cubic-bezier"}const Oi=2;function Hi(t){return t.some(e=>e.interpolation!==void 0)?2:1}function En(t){return t.property==="text"&&"textConfig"in t}function qt(t){return t.kind==="inertia"&&"inertia"in t}function Ut(t){return t.kind==="spring"&&"spring"in t}function Ci(t){return t.property==="motionPath"&&"motionPathConfig"in t}function yh(t){return typeof t=="object"&&t!==null&&"x"in t&&"y"in t&&"angle"in t}function No(t){return"keyframes"in t}class bh{_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(e){this._currentTime+=e,this.onTick?.(e,this._currentTime)}reset(){this._currentTime=0}seek(e){this._currentTime=e}}class wh{_currentTime=0;_isRunning=!1;_lastFrameTime=null;_rafId=null;_speed;onTick=null;constructor(e={}){this._speed=e.speed??1}get currentTime(){return this._currentTime}get isRunning(){return this._isRunning}get speed(){return this._speed}set speed(e){this._speed=e}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(e){this._currentTime=e}_scheduleFrame(){this._rafId=requestAnimationFrame(this._onFrame.bind(this))}_onFrame(e){if(this._isRunning){if(this._lastFrameTime!==null){const i=(e-this._lastFrameTime)*this._speed;this._currentTime+=i,this.onTick?.(i,this._currentTime)}this._lastFrameTime=e,this._scheduleFrame()}}}function Bo(t,e){if(!(e>0))return t;const n=1e3/e;return Math.floor(t/n+1e-9)*n}function Ri(t,e,n="start"){if(e<=1)return 0;if(typeof n=="number"){const i=Math.max(0,Math.min(e-1,n));return Math.abs(t-i)}switch(n){case"end":return e-1-t;case"center":return Math.abs(t-(e-1)/2);case"edges":return(e-1)/2-Math.abs(t-(e-1)/2);default:return t}}function Li(t,e="start"){if(t<=1)return 0;let n=0;for(let i=0;i<t;i++)n=Math.max(n,Ri(i,t,e));return n}function An(t,e,n){if(n.offsets)return n.offsets[t]??0;const i=n.from??"start",s=Ri(t,e,i);if(n.amount!==void 0){const o=Li(e,i);return o===0?0:n.amount*s/o}return n.each!==void 0?n.each*s:0}function xn(t,e){return Array.from({length:t},(n,i)=>An(i,t,e))}function Ye(t,e){return t<=1?0:Math.max(...xn(t,e))}const we=1,Fi=6e4,Pn=Fi/we,Ht={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},$n={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 je{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(e){this.from=e.from,this.to=e.to,this.stiffness=e.stiffness??Ht.stiffness,this.damping=e.damping??Ht.damping,this.mass=e.mass??Ht.mass,this.restDelta=e.restDelta??Ht.restDelta,this.restSpeed=e.restSpeed??Ht.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=e.velocity??Ht.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(e){return Math.abs(e-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(e){if(e<=0)return this.from;const n=Math.floor(e/we);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)],o=e/we-n;return i+(s-i)*o}settleTime(){return this.simulateTo(Pn+1),this.settledStep!==null?this.settledStep*we:Fi}simulateTo(e){if(this.settledStep!==null)return;const n=Math.min(e,Pn+1),i=we/1e3;for(;this.samples.length<n;){const s=this.samples[this.samples.length-1],o=s-this.to,r=-this.stiffness*o,a=-this.damping*this.velocity,l=(r+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>Pn&&(this.settledStep=Pn)}}function kh(t,e){return new je(t).valueAt(e)}function Wo(t){return new je(t).settleTime()}function vh(t){const e=t.stiffness??Ht.stiffness,n=t.damping??Ht.damping,i=t.mass??Ht.mass;return n<2*Math.sqrt(e*i)}function Sh(t){const e=t.stiffness??Ht.stiffness,n=t.mass??Ht.mass;return 2*Math.sqrt(e*n)}const Di=4,Mh=.002,Th=1e-4,Ko=6e4;function _n(t){const e=t.friction??Di;return e>0?e:Di}function Xe(t){return t.from+t.velocity/_n(t)}function Eh(t,e){if(e===void 0)return t;if(typeof e=="number")return e>0?Math.round(t/e)*e:t;if(e.length===0)return t;let n=e[0];for(const i of e)Math.abs(i-t)<Math.abs(n-t)&&(n=i);return n}function ke(t){let e=Eh(Xe(t),t.end);return t.min!==void 0&&(e=Math.max(t.min,e)),t.max!==void 0&&(e=Math.min(t.max,e)),e}function ve(t){const e=Math.abs(ke(t)-t.from);if(e===0)return 0;const n=t.restDelta??Math.max(Th,e*Mh);if(n>=e)return 0;const i=Math.log(e/n)/_n(t);return Math.min(Ko,i*1e3)}function In(t,e){if(e<=0)return t.from;const n=ke(t);if(e>=ve(t))return n;const i=_n(t);return t.from+(n-t.from)*(1-Math.exp(-i*e/1e3))}function Ah(t,e){const n=_n(t),i=ke(t);return e>=ve(t)?0:(i-t.from)*n*Math.exp(-n*Math.max(0,e)/1e3)}const On=t=>t,Yo=t=>t*t,jo=t=>1-(1-t)*(1-t),Xo=t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,Ni=t=>t*t*t,Bi=t=>1-Math.pow(1-t,3),qe=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,qo=Ni,Uo=Bi,Vo=qe,xh={linear:On,"ease-in":qo,"ease-out":Uo,"ease-in-out":Vo,"ease-in-quad":Yo,"ease-out-quad":jo,"ease-in-out-quad":Xo,"ease-in-cubic":Ni,"ease-out-cubic":Bi,"ease-in-out-cubic":qe};function Go(t){const[e,n,i,s]=t,o=3*e,r=3*(i-e)-o,a=1-o-r,l=3*n,c=3*(s-n)-l,h=1-l-c,f=d=>((a*d+r)*d+o)*d,u=d=>((h*d+c)*d+l)*d,p=d=>(3*a*d+2*r)*d+o,g=d=>{let m=d;for(let v=0;v<8;v++){const T=f(m)-d;if(Math.abs(T)<1e-7)return m;const S=p(m);if(Math.abs(S)<1e-7)break;m-=T/S}let y=0,w=1;for(m=d;y<w;){const v=f(m);if(Math.abs(v-d)<1e-7)return m;d>v?y=m:w=m,m=(y+w)/2}return m};return d=>{if(d<=0)return 0;if(d>=1)return 1;const m=g(d);return u(m)}}function Wi(t,e="out"){if(e==="out")return t;const n=i=>1-t(1-i);return e==="in"?n:i=>i<.5?n(i*2)/2:t(i*2-1)/2+.5}function zo(t=1,e=.3){const n=Math.max(1,t),i=e/(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)/e)+1}const Jo=t=>{if(t<=0)return 0;if(t>=1)return 1;if(t<1/2.75)return 7.5625*t*t;if(t<2/2.75){const s=t-.5454545454545454;return 7.5625*s*s+.75}if(t<2.5/2.75){const s=t-.8181818181818182;return 7.5625*s*s+.9375}const i=t-2.625/2.75;return 7.5625*i*i+.984375};function Zo(t=1.70158){return e=>{if(e<=0)return 0;if(e>=1)return 1;const n=e-1;return n*n*((t+1)*n+t)+1}}function Qo(t,e="end"){const n=Math.max(1,Math.floor(t));return i=>{if(i>=1)return 1;if(i<=0)return e==="start"||e==="both"?e==="start"?1/n:1/(n+1):0;const s=Math.floor(i*n);switch(e){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 tr(t){switch(t.type){case"steps":return Qo(t.count,t.position);case"elastic":return Wi(zo(t.amplitude,t.period),t.mode);case"bounce":return Wi(Jo,t.mode);case"back":return Wi(Zo(t.overshoot),t.mode)}}function Mt(t){return t===void 0?On:be(t)?Go(t.points):Ke(t)?tr(t):xh[t]??On}const er=32,Ph=256,Se=new Map,$h=/[MmLlHhVvCcSsQqTtAaZz]/,_h=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Ih={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Oh(t){const e=[];let n=0,i=null;const s=()=>{for(;n<t.length&&/[\s,]/.test(t[n]);)n++};for(;n<t.length&&(s(),!(n>=t.length));){const o=t[n];if($h.test(o)){i={type:o,args:[]},e.push(i),n++;continue}if(!i)break;const r=i.type==="A"||i.type==="a",a=i.args.length%7;if(r&&(a===3||a===4)){if(o!=="0"&&o!=="1")break;i.args.push(o==="1"?1:0),n++;continue}const l=_h.exec(t.slice(n));if(!l)break;i.args.push(parseFloat(l[0])),n+=l[0].length}return e}function Hh(t,e,n,i,s,o,r,a,l){if(t===a&&e===l)return[];let c=Math.abs(n),h=Math.abs(i);if(c===0||h===0)return[[t,e,a,l,a,l]];const f=s*Math.PI/180,u=Math.cos(f),p=Math.sin(f),g=(t-a)/2,d=(e-l)/2,m=u*g+p*d,y=-p*g+u*d,w=m*m/(c*c)+y*y/(h*h);if(w>1){const J=Math.sqrt(w);c*=J,h*=J}const v=o===r?-1:1,T=c*c*h*h-c*c*y*y-h*h*m*m,S=c*c*y*y+h*h*m*m,A=v*Math.sqrt(Math.max(0,T/S)),x=A*c*y/h,C=-A*h*m/c,E=u*x-p*C+(t+a)/2,H=p*x+u*C+(e+l)/2,_=(J,M,I,k)=>{const $=J*I+M*k,R=Math.sqrt((J*J+M*M)*(I*I+k*k)),W=Math.acos(Math.max(-1,Math.min(1,$/R)));return J*k-M*I<0?-W:W},P=_(1,0,(m-x)/c,(y-C)/h);let L=_((m-x)/c,(y-C)/h,(-m-x)/c,(-y-C)/h);!r&&L>0&&(L-=2*Math.PI),r&&L<0&&(L+=2*Math.PI);const F=Math.max(1,Math.ceil(Math.abs(L)/(Math.PI/2))),K=L/F,V=4/3*Math.tan(K/4),ot=J=>{const M=c*Math.cos(J),I=h*Math.sin(J);return[u*M-p*I+E,p*M+u*I+H]},X=J=>{const M=-c*Math.sin(J),I=h*Math.cos(J);return[u*M-p*I,p*M+u*I]},tt=[];for(let J=0;J<F;J++){const M=P+J*K,I=M+K,[k,$]=ot(M),[R,W]=J===F-1?[a,l]:ot(I),[Q,B]=X(M),[G,O]=X(I);tt.push([k+V*Q,$+V*B,R-V*G,W-V*O,R,W])}return tt}function Vt(t,e,n,i,s){const o=1-s;return o*o*o*t+3*o*o*s*e+3*o*s*s*n+s*s*s*i}function nr(t,e,n,i,s){const o=1-s;return 3*o*o*(e-t)+6*o*s*(n-e)+3*s*s*(i-n)}function Ue(t,e,n,i){return{subpath:0,type:"L",points:[n,i],startX:t,startY:e,endX:n,endY:i,length:Math.hypot(n-t,i-e)}}function Hn(t,e,n){const[i,s,o,r,a,l]=n,c=[0];let h=t,f=e,u=0;for(let p=1;p<=er;p++){const g=p/er,d=Vt(t,i,o,a,g),m=Vt(e,s,r,l,g);u+=Math.hypot(d-h,m-f),c.push(u),h=d,f=m}return{subpath:0,type:"C",points:[i,s,o,r,a,l],startX:t,startY:e,endX:a,endY:l,length:u,lengths:c}}function ae(t){const e=Se.get(t);if(e)return e;const n=[];let i=0,s=0,o=0,r=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:m}of Oh(t)){const y=d.toUpperCase(),w=d!==y,v=Ih[y];if(y==="Z"){(i!==o||s!==r)&&f(Ue(i,s,o,r)),c>=0&&h.add(c),i=o,s=r,a=l=null;continue}for(let T=0;T+v<=m.length;T+=v){const S=m.slice(T,T+v),A=w?i:0,x=w?s:0;let C=null,E=null;switch(y){case"M":T===0?(i=S[0]+A,s=S[1]+x,o=i,r=s,(c<0||n[n.length-1]?.subpath===c)&&c++):(f(Ue(i,s,S[0]+A,S[1]+x)),i=S[0]+A,s=S[1]+x);break;case"L":f(Ue(i,s,S[0]+A,S[1]+x)),i=S[0]+A,s=S[1]+x;break;case"H":f(Ue(i,s,S[0]+A,s)),i=S[0]+A;break;case"V":f(Ue(i,s,i,S[0]+x)),s=S[0]+x;break;case"C":{const H=[S[0]+A,S[1]+x,S[2]+A,S[3]+x,S[4]+A,S[5]+x];f(Hn(i,s,H)),C=[H[2],H[3]],i=H[4],s=H[5];break}case"S":{const[H,_]=a?[2*i-a[0],2*s-a[1]]:[i,s],P=[H,_,S[0]+A,S[1]+x,S[2]+A,S[3]+x];f(Hn(i,s,P)),C=[P[2],P[3]],i=P[4],s=P[5];break}case"Q":case"T":{let H=i,_=s;y==="Q"?(H=S[0]+A,_=S[1]+x):l&&(H=2*i-l[0],_=2*s-l[1]);const P=y==="Q"?S[2]+A:S[0]+A,L=y==="Q"?S[3]+x:S[1]+x;f(Hn(i,s,[i+2/3*(H-i),s+2/3*(_-s),P+2/3*(H-P),L+2/3*(_-L),P,L])),E=[H,_],i=P,s=L;break}case"A":{const H=S[5]+A,_=S[6]+x;let P=i,L=s;for(const F of Hh(i,s,S[0],S[1],S[2],S[3],S[4],H,_))f(Hn(P,L,F)),P=F[4],L=F[5];i=H,s=_;break}}a=C,l=E}}const u=n.reduce((d,m)=>d+m.length,0),p=[];for(let d=0;d<n.length;){const m=n[d].subpath;let y=d,w=0;for(;y<n.length&&n[y].subpath===m;)w+=n[y++].length;const v=n[d],T=n[y-1],S=h.has(m)||Math.abs(T.endX-v.startX)<1e-9&&Math.abs(T.endY-v.startY)<1e-9;p.push({start:d,end:y,length:w,closed:S}),d=y}const g={segments:n,totalLength:u,subpaths:p};return Se.size>=Ph&&Se.delete(Se.keys().next().value),Se.set(t,g),g}function Ch(t,e){const n=t.lengths;if(e<=0)return 0;if(e>=t.length)return 1;let i=0,s=n.length-1;for(;i<s-1;){const a=i+s>>1;n[a]<e?i=a:s=a}const o=n[s]-n[i],r=o>0?(e-n[i])/o:0;return(i+r)/(n.length-1)}function Rh(t,e){if(t.type==="L"){const f=t.length>0?Math.max(0,Math.min(1,e/t.length)):0;return{x:t.startX+(t.endX-t.startX)*f,y:t.startY+(t.endY-t.startY)*f,angle:Math.atan2(t.endY-t.startY,t.endX-t.startX)*180/Math.PI}}const[n,i,s,o,r,a]=t.points,l=Ch(t,e);let c=nr(t.startX,n,s,r,l),h=nr(t.startY,i,o,a,l);if(Math.hypot(c,h)<1e-9){const f=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),u=Vt(t.startX,n,s,r,f),p=Vt(t.startY,i,o,a,f),g=Vt(t.startX,n,s,r,l),d=Vt(t.startY,i,o,a,l);c=l<.5?u-g:g-u,h=l<.5?p-d:d-p}return{x:Vt(t.startX,n,s,r,l),y:Vt(t.startY,i,o,a,l),angle:Math.atan2(h,c)*180/Math.PI}}function Ki(t,e,n=0,i=t.length){if(i<=n)return{x:0,y:0,angle:0};let s=0;for(let o=n;o<i;o++){const r=t[o];if(s+r.length>=e||o===i-1)return Rh(r,e-s);s+=r.length}return{x:0,y:0,angle:0}}function ir(t,e){const{segments:n,totalLength:i}=ae(t);return Ki(n,Math.max(0,Math.min(1,e))*i)}function Lh(){Se.clear()}function Fh(t){return ae(t).totalLength}const Dh=24,Nh=320,Bh=2.5,Ve=72,Wh=64,Kh=.2,Yh=128,Ge=new Map;let Cn=0,Gt;const sr=t=>Math.round(t*100)/100;function or(t,e){const{segments:n,subpaths:i,totalLength:s}=ae(t);if(n.length===0)return[];if(e){const o=i.every(r=>r.closed);return[{segments:n,start:0,end:n.length,length:s,closed:o}]}return i.filter(o=>o.length>0).map(o=>({segments:n,start:o.start,end:o.end,length:o.length,closed:o.closed}))}function Yi(t,e){const n=t.closed?(e%1+1)%1:Math.max(0,Math.min(1,e)),i=Ki(t.segments,n*t.length,t.start,t.end);return[i.x,i.y]}function rr(t){const e=[];let n=0;for(let i=t.start;i<t.end;i++)n+=t.segments[i].length,t.length>0&&e.push(n/t.length);return e}function ar(t,e){const n=[];for(let i=0;i<e;i++)n.push(Yi(t,t.closed?i/e:i/(e-1)));return n}function lr(t){let e=0,n=0;for(const[i,s]of t)e+=i,n+=s;return e/=t.length,n/=t.length,t.map(([i,s])=>[i-e,s-n])}function jh(t,e,n){const i=t.closed&&e.closed;if(n!==void 0)return{offset:i?Math.abs(n)%Ve/Ve:0,reversed:n<0};const s=lr(ar(t,Ve)),o=lr(ar(e,Ve)),r=Ve;let a={offset:0,reversed:!1},l=1/0;for(const c of[!1,!0]){const h=i?r:1;for(let f=0;f<h;f++){let u=0;for(let p=0;p<r&&u<l;p++){const g=i?c?(f-p+r)%r:(p+f)%r:c?r-1-p:p,d=s[p][0]-o[g][0],m=s[p][1]-o[g][1];u+=d*d+m*m}u<l&&(l=u,a={offset:i?f/r:0,reversed:c})}}return a}function Xh(t,e,n){return n?((e.reversed?e.offset-t:t+e.offset)%1+1)%1:e.reversed?1-t:t}function qh(t,e,n){return n?((e.reversed?e.offset-t:t-e.offset)%1+1)%1:e.reversed?1-t:t}function Uh(t,e,n){const i=t.closed&&e.closed,s=jh(t,e,n.shapeIndex),o=Math.max(Dh,Math.min(Nh,Math.ceil(Math.max(t.length,e.length)/Bh))),r=new Set,a=f=>r.add(Math.round(f*1e7)/1e7);for(let f=0;f<=o;f++)a(f/o);for(const f of rr(t))a(f);for(const f of rr(e))a(qh(f,s,i));let l=[...r].sort((f,u)=>f-u);i&&(l=l.filter(f=>f<1));const c=[],h=[];for(const f of l)c.push(...Yi(t,f)),h.push(...Yi(e,Xh(f,s,i)));return Vh({from:c,to:h,closed:i})}function Vh(t){const e=t.from.length/2;if(e<=3)return t;const n=new Uint8Array(e);n[0]=1,n[e-1]=1;const i=[[0,e-1]];for(;i.length>0;){const[r,a]=i.pop();let l=-1,c=Kh;for(let h=r+1;h<a;h++){const f=Math.max(cr(t.from,r,a,h),cr(t.to,r,a,h));f>c&&(c=f,l=h)}l!==-1&&(n[l]=1,i.push([r,l],[l,a]))}const s=[],o=[];for(let r=0;r<e;r++)n[r]&&(s.push(t.from[r*2],t.from[r*2+1]),o.push(t.to[r*2],t.to[r*2+1]));return{from:s,to:o,closed:t.closed}}function cr(t,e,n,i){const s=t[e*2],o=t[e*2+1],r=t[n*2]-s,a=t[n*2+1]-o,l=t[i*2]-s,c=t[i*2+1]-o,h=r*r+a*a,f=h===0?0:Math.max(0,Math.min(1,(l*r+c*a)/h));return Math.hypot(l-f*r,c-f*a)}function Gh(t,e,n){const i=n.shapeIndex;if(Gt&&Gt.from===t&&Gt.to===e&&Gt.shapeIndex===i)return Gt.plan;const o=Ge.get(String(i??"auto"))?.get(t)?.get(e);if(o)return Gt={from:t,to:e,shapeIndex:i,plan:o},o;const r=ae(t).subpaths.filter(p=>p.length>0).length===ae(e).subpaths.filter(p=>p.length>0).length,a=or(t,!r),l=or(e,!r),c={pairs:a.map((p,g)=>Uh(p,l[g],n))};Cn>=Yh&&(Ge.clear(),Cn=0);const h=String(i??"auto"),f=Ge.get(h)??new Map;Ge.set(h,f);const u=f.get(t)??new Map;return f.set(t,u),u.set(e,c),Cn++,Gt={from:t,to:e,shapeIndex:i,plan:c},c}function hr(t,e,n,i={}){if(!t)return e;if(!e)return t;const s=Math.max(0,Math.min(1,n));if(s===0)return t;if(s===1)return e;const o=Gh(t,e,i);if(o.pairs.length===0)return s<.5?t:e;let r="";for(const a of o.pairs){for(let l=0;l<a.from.length;l+=2){const c=sr(a.from[l]+(a.to[l]-a.from[l])*s),h=sr(a.from[l+1]+(a.to[l+1]-a.from[l+1])*s);r+=`${l===0?r?" M":"M":" L"}${c} ${h}`}a.closed&&(r+=" Z")}return r}function zh(){Ge.clear(),Cn=0,Gt=void 0}function Me(t){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(t)}const Te=Math.PI/180,Jh=.9995;function ji(){return[0,0,0,1]}function Ee(t,e){const n=Math.hypot(t[0],t[1],t[2]);if(n===0)return ji();const i=e*Te/2,s=Math.sin(i)/n;return[t[0]*s,t[1]*s,t[2]*s,Math.cos(i)]}function Zh(t,e,n){return Xi(Xi(Ee([0,1,0],e),Ee([1,0,0],t)),Ee([0,0,1],n))}function Qh(t){const[e,n,i,s]=zt(t),o=2*(e*i+n*s),r=2*(e*n+i*s),a=1-2*(e*e+i*i),l=2*(n*i-e*s),c=1-2*(n*n+i*i),h=2*(e*i-n*s),f=1-2*(e*e+n*n),u=Math.asin(Math.max(-1,Math.min(1,-l)));return Math.abs(l)<.9999999?[u/Te,Math.atan2(o,f)/Te,Math.atan2(r,a)/Te]:[u/Te,Math.atan2(-h,c)/Te,0]}function Xi(t,e){const[n,i,s,o]=t,[r,a,l,c]=e;return[o*r+n*c+i*l-s*a,o*a-n*l+i*c+s*r,o*l+n*a-i*r+s*c,o*c-n*r-i*a-s*l]}function ur(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function fr(t){return Math.hypot(t[0],t[1],t[2],t[3])}function zt(t){const e=fr(t);return e===0?ji():[t[0]/e,t[1]/e,t[2]/e,t[3]/e]}function tu(t){return[-t[0],-t[1],-t[2],t[3]]}function dr(t,e,n){const i=zt(t);let s=zt(e),o=ur(i,s);if(o<0&&(s=[-s[0],-s[1],-s[2],-s[3]],o=-o),o>Jh)return zt([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 r=Math.acos(o),a=Math.sin(r),l=Math.sin((1-n)*r)/a,c=Math.sin(n*r)/a;return zt([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 eu(t,e){const[n,i,s,o]=zt(t),r=2*(i*e[2]-s*e[1]),a=2*(s*e[0]-n*e[2]),l=2*(n*e[1]-i*e[0]);return[e[0]+o*r+(i*l-s*a),e[1]+o*a+(s*r-n*l),e[2]+o*l+(n*a-i*r)]}const nu=Object.freeze(Object.defineProperty({__proto__:null,conjugate:tu,dot:ur,fromAxisAngle:Ee,fromEuler:Zh,identity:ji,length:fr,multiply:Xi,normalize:zt,rotateVec3:eu,slerp:dr,toEuler:Qh},Symbol.toStringTag,{value:"Module"})),Ft=(t,e,n)=>t+(e-t)*n,pr=512,qi=new Map,Ui=new Map;function gr(t){const e=qi.get(t);if(e)return e;const n=t.replace("#",""),i=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return qi.size<pr&&qi.set(t,i),i}const mr=t=>t.charCodeAt(0)===35,yr=t=>t.startsWith("rgb"),br=t=>t.startsWith("rgba"),iu=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Vi=t=>Math.round(t).toString(16).padStart(2,"0");function su(t,e,n){return`#${Vi(t)}${Vi(e)}${Vi(n)}`}function wr(t){const e=Ui.get(t);if(e)return e;const n=t.match(iu);if(!n)throw new Error(`Invalid rgb color: ${t}`);const i=parseInt(n[1],10),s=parseInt(n[2],10),o=parseInt(n[3],10),r=n[4]!==void 0?[i,s,o,parseFloat(n[4])]:[i,s,o];return Ui.size<pr&&Ui.set(t,r),r}const kr=(t,e,n)=>{if(mr(t)&&mr(e)){const[i,s,o]=gr(t),[r,a,l]=gr(e),c=Ft(i,r,n),h=Ft(s,a,n),f=Ft(o,l,n);return su(c,h,f)}if((yr(t)||br(t))&&(yr(e)||br(e))){const i=wr(t),s=wr(e),o=Math.round(Ft(i[0],s[0],n)),r=Math.round(Ft(i[1],s[1],n)),a=Math.round(Ft(i[2],s[2],n));if(i.length===4||s.length===4){const l=i[3]??1,c=s[3]??1,h=Ft(l,c,n);return`rgba(${o}, ${r}, ${a}, ${h})`}return`rgb(${o}, ${r}, ${a})`}return n<1?t:e},vr=(t,e,n)=>{const i=Math.min(t.length,e.length),s=[];for(let o=0;o<i;o++)s.push(Ft(t[o],e[o],n));return s},Sr=(t,e,n)=>dr(t,e,n),Gi=(t,e,n)=>n<1?t:e,Mr=(t,e,n)=>hr(t,e,n);function ze(t,e){return e==="slerp"?Sr:typeof t=="number"?Ft:Array.isArray(t)?vr:typeof t=="string"?t.startsWith("#")||t.startsWith("rgb")?kr:Me(t)?Mr:Gi:Gi}const zi=1e3/60;function Ji(t,e={}){if(!Ut(t))throw new Error(`bakeSpringTrack: track "${t.id}" is not a spring track`);const n=new je(t.spring);return Tr(t,i=>n.valueAt(i),n.settleTime(),t.spring.from,t.spring.to,e)}function Zi(t,e={}){if(!qt(t))throw new Error(`bakeInertiaTrack: track "${t.id}" is not an inertia track`);const n=t.inertia;return Tr(t,i=>In(n,i),ve(n),n.from,ke(n),e)}function Tr(t,e,n,i,s,o){const r=o.intervalMs??zi,a=o.tolerance??.01,l=t.delay??0,c=[];for(let f=0;f<=n;f+=r)c.push({time:f+l,value:e(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:t.id,target:t.target,property:t.property,keyframes:a>0?Ar(c,a):c,...t.targets&&{targets:[...t.targets]},...t.stagger&&{stagger:{...t.stagger}}}}function Qi(t,e,n,i={}){const s=i.intervalMs??zi,o=typeof n=="function"?n:Mt(n),r=ze(t.value,i.interpolation),a=e.time-t.time;if(a<=0)return[e];const l=[];for(let h=s;h<a;h+=s){const f=h/a;l.push({time:t.time+h,value:r(t.value,e.value,o(f)),easing:"linear"})}const c=o(1);return l.push({...e,...c!==1&&{value:r(t.value,e.value,c)},easing:"linear"}),l}function ou(t,e){return Ut(t)?Ji(t,e):qt(t)?Zi(t,e):t}function Er(t,e={}){const n=t.keyframes;if(!n.some(o=>Ke(o.easing)))return t;const i=n.length>0?[n[0]]:[],s={...e,interpolation:t.interpolation??e.interpolation};for(let o=1;o<n.length;o++){const r=n[o];Ke(r.easing)?i.push(...Qi(n[o-1],r,r.easing,s)):i.push(r)}return{...t,keyframes:i}}function ru(t,e){return t.filter(No).map(n=>Er(n,e)).concat(t.filter(Ut).map(n=>Ji(n,e)),t.filter(qt).map(n=>Zi(n,e)))}function Ar(t,e){if(t.length<=2)return t;const n=[t[0]];for(let i=1;i<t.length-1;i++){const s=n[n.length-1],o=t[i],r=t[i+1],a=r.time-s.time;if(a<=0)continue;const l=(o.time-s.time)/a,c=s.value+(r.value-s.value)*l;Math.abs(o.value-c)>e&&n.push(o)}return n.push(t[t.length-1]),n}function Rn(t){const e=[...t.keyframes].sort((n,i)=>n.time-i.time);return{...t,keyframes:e}}function Jt(t){return t.targets&&t.targets.length>0?t.targets:[t.target]}function Ae(t,e,n,i){const s=n??0;return!i||e<=1?s:s+An(t,e,i)}class Ln{track;targets;constructor(e){this.track=e,this.targets=Jt(e)}getValueAtTime(e){return this.valueForOffset(e-Ae(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const o=Ae(s,n,this.track.delay,this.track.stagger),r=this.valueForOffset(e-o);r!==void 0&&i.push({target:this.targets[s],value:r,start:o+this.track.keyframes[0].time})}return i}getDuration(){const{keyframes:e}=this.track;if(e.length===0)return 0;const n=e[e.length-1].time,i=this.track.stagger?Ye(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+i+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(e){const{keyframes:n}=this.track;if(n.length===0)return;if(n.length===1||e<=n[0].time)return n[0].value;if(e>=n[n.length-1].time)return n[n.length-1].value;const{from:i,to:s}=this.findSurroundingKeyframes(e);if(!i||!s)return;if(i.time===e)return i.value;const o=s.time-i.time,r=(e-i.time)/o,l=Mt(s.easing)(r);return ze(i.value,this.track.interpolation)(i.value,s.value,l)}findSurroundingKeyframes(e){const{keyframes:n}=this.track;for(let i=0;i<n.length-1;i++)if(e>=n[i].time&&e<=n[i+1].time)return{from:n[i],to:n[i+1]};return{from:null,to:null}}}class xr{track;targets;sampler;constructor(e){this.track=e,this.targets=Jt(e),this.sampler=new je(e.spring)}getValueAtTime(e){return this.sampler.valueAt(e-Ae(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const o=Ae(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:this.sampler.valueAt(e-o),start:o})}return i}getDuration(){const e=this.track.stagger?Ye(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+e}getTrack(){return this.track}}class Pr{track;targets;duration;constructor(e){this.track=e,this.targets=Jt(e),this.duration=ve(e.inertia)}getValueAtTime(e){return In(this.track.inertia,e-Ae(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const o=Ae(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:In(this.track.inertia,e-o),start:o})}return i}getDuration(){const e=this.track.stagger?Ye(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+e}getTrack(){return this.track}}function ts(t,e){const n={...ir(t.pathData,e)};if(t.matrix){const[i,s,o,r,a,l]=t.matrix,{x:c,y:h}=n;n.x=i*c+o*h+a,n.y=s*c+r*h+l;const f=n.angle*Math.PI/180,u=Math.cos(f),p=Math.sin(f);n.angle=Math.atan2(s*u+r*p,i*u+o*p)*180/Math.PI}return t.autoRotate&&t.rotateOffset&&(n.angle+=t.rotateOffset),n}function au(t,e,n,i){const s=e+(n-e)*i;return ts(t,s)}const es={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},lu=20;function $r(t){const e=es[t??"upperCase"]??t??es.upperCase,n=Array.from(e);return n.length>0?n:Array.from(es.upperCase)}function cu(t,e,n){let i=(t|0)^Math.imul(e+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 _r(t,e,n=0){const i=t.from??"",s=t.to,o=Math.max(0,Math.min(1,e));if(o<=0)return i;if(o>=1)return s;const r=Array.from(i),a=Array.from(s),l=t.rightToLeft??!1;if(t.mode==="type"){const w=Math.round(o*Math.max(r.length,a.length));return l?r.slice(0,Math.max(0,r.length-w)).join("")+a.slice(Math.max(0,a.length-w)).join(""):a.slice(0,w).join("")+r.slice(w).join("")}const c=Math.max(0,Math.min(.999,t.revealDelay??0)),h=Math.max(0,(o-c)/(1-c)),f=Math.floor(h*a.length),u=t.tweenLength===!1?a.length:Math.round(r.length+(a.length-r.length)*o),p=$r(t.chars),g=t.refreshRate??lu,d=g>0?Math.floor(n*g/1e3):0,m=t.seed??1;let y="";for(let w=0;w<u;w++){const v=l?w>=u-f:w<f,T=l?a[a.length-(u-w)]:a[w];v&&T!==void 0||T===" "||T===`
|
|
2
|
+
`?y+=T:y+=p[cu(m,w,d)%p.length]}return y}class le{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(e){if(this.id=e.id,this.name=e.name,this._captions=e.captions,this._config=e.config??{},this._explicitDuration=e.config?.duration,e.tracks)for(const n of e.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(e){if(this._explicitDuration=e,e!==void 0)this._config={...this._config,duration:e};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(e){this._config.speed=e}get drawingRate(){return this._config.drawingRate??0}set drawingRate(e){const n={...this._config};e>0?n.drawingRate=e:delete n.drawingRate,this._config=n}play(){const e=this.duration;this._direction==="forward"&&this._currentTime>=e&&e>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&e>0&&(this._currentTime=e,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(e){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(e,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(e){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let s=e*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 o=1e3;for(let a=0;a<o&&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 r=this.getStateAtTime(this._currentTime);this.onUpdate?.(r)}getStateAtTime(e){const n=new Map;if(e=Bo(e,this._config.drawingRate??0),this._hasSharedWrites())this._resolveShared(e,n);else for(const[i,s]of this._trackPlayers){const o=s.getTrack().property;for(const{target:r,value:a,start:l}of s.getTargetValues(e))this._write(n,i,r,o,a,e-l)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(e,n){const i=new Map;for(const[s,o]of this._trackPlayers){const r=o.getTrack().property;for(const{target:a,value:l,start:c}of o.getTargetValues(e)){const h=`${a}\0${r}`,f=c<=e,u=i.get(h);(!u||(f!==u.started?f:f?c>=u.start:c<=u.start))&&i.set(h,{trackId:s,target:a,property:r,value:l,start:c,started:f})}}for(const{trackId:s,target:o,property:r,value:a,start:l}of i.values())this._write(n,s,o,r,a,e-l)}_write(e,n,i,s,o,r){if(o===void 0)return;let a=e.get(i);a||(a=new Map,e.set(i,a));const l=this._textTracks.get(n);if(l&&typeof o=="number"){a.set("text",_r(l.textConfig,o,Math.max(0,r)));return}const c=this._motionPathTracks.get(n);if(c&&typeof o=="number"){const h=ts(c.motionPathConfig,o);a.set("motionPathX",h.x),a.set("motionPathY",h.y),c.motionPathConfig.autoRotate&&a.set("motionPathRotate",h.angle)}else a.set(s,o)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const e=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const i of Jt(n)){const s=`${i}\0${n.property}`;if(e.has(s)){this._sharedWrites=!0;break t}e.add(s)}}return this._sharedWrites}addTrack(e){if(this._tracks.push(e),this._sharedWrites=null,qt(e)){this._trackPlayers.set(e.id,new Pr(e));return}if(Ut(e)){this._trackPlayers.set(e.id,new xr(e)),this._springTracks.set(e.id,e);return}if(En(e))this._trackPlayers.set(e.id,new Ln(e)),this._textTracks.set(e.id,e);else if(Ci(e)){const n={id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,delay:e.delay,endDelay:e.endDelay,targets:e.targets,stagger:e.stagger};this._trackPlayers.set(e.id,new Ln(n)),this._motionPathTracks.set(e.id,e)}else this._trackPlayers.set(e.id,new Ln(e))}replaceTrack(e,n){const i=this._tracks.findIndex(o=>o.id===e);if(i<0)return;const s=this._tracks.slice(i+1);this.removeTrack(e);for(const o of s)this.removeTrack(o.id);this.addTrack(n);for(const o of s)this.addTrack(o)}removeTrack(e){this._tracks=this._tracks.filter(n=>n.id!==e),this._sharedWrites=null,this._trackPlayers.delete(e),this._motionPathTracks.delete(e),this._springTracks.delete(e),this._textTracks.delete(e)}getTracks(e={}){return this._tracks.filter(n=>this._matches(n,e))}removeTracks(e={}){const n=this.getTracks(e).map(i=>i.id);for(const i of n)this.removeTrack(i);return n}getTrackSpan(e){const n=this._trackPlayers.get(e);if(!n)return;const i=n.getTrack(),s=i.delay??0;if(Ut(i)||qt(i))return{from:s,to:n.getDuration()};const o=i.keyframes;if(!(!o||o.length===0))return{from:o[0].time+s,to:n.getDuration()}}findConflicts(){const e=[];for(let n=0;n<this._tracks.length;n++){const i=this._tracks[n],s=this.getTrackSpan(i.id);if(s)for(let o=0;o<n;o++){const r=this._tracks[o];if(r.property!==i.property)continue;const a=Jt(r).filter(f=>Jt(i).includes(f));if(a.length===0)continue;const l=this.getTrackSpan(r.id);if(!l||!(l.from<=s.to&&s.from<=l.to))continue;const h=s.from>=l.from;for(const f of a)e.push({target:f,property:i.property,losingTrackId:h?r.id:i.id,winningTrackId:h?i.id:r.id})}}return e}_matches(e,n){if(n.id!==void 0&&e.id!==n.id||n.property!==void 0&&e.property!==n.property||n.target!==void 0&&!Jt(e).includes(n.target))return!1;if(n.timeRange){const i=this.getTrackSpan(e.id);if(!i||i.to<n.timeRange.from||i.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:Hi(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((e,n)=>e.time-n.time)}setMarkers(e){const n=e&&e.length>0?[...e].sort((s,o)=>s.time-o.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(e){const n={};for(const[i,s]of Object.entries(e??{}))n[i]={...s};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let e=0;for(const[,n]of this._trackPlayers)e=Math.max(e,n.getDuration());return e}_handleEndReached(){const e=this._config.loop??0;return e===-1||this._loopIteration<e?(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 e=this._config.loop??0;return this._config.alternate&&(e===-1||this._loopIteration<e)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const hu=100;function ns(t,e,n,i){const s=[],o=[],{duration:r,alternate:a}=i,l=(p,g,d,m)=>{o.push([p,g]);const y=[];t.forEach((w,v)=>{(d==="forward"?(m?w>=p:w>p)&&w<=g:(m?w<=p:w<p)&&w>=g)&&y.push(v)}),y.sort((w,v)=>(d==="forward"?t[w]-t[v]:t[v]-t[w])||w-v);for(const w of y)s.push({kind:"event",index:w,direction:d})};let c=e.time,h=e.direction,f=e.fresh===!0;const u=Math.min(hu,Math.max(0,n.iteration-e.iteration));for(let p=0;p<u;p++){const g=h==="forward"?r:0;l(c,g,h,f),s.push({kind:"repeat"}),a?(h=h==="forward"?"reverse":"forward",c=g,f=!1):(c=h==="forward"?0:r,f=!0)}return u>0&&i.holding&&!a?{crossings:s,passes:o}:(l(c,n.time,h,f),{crossings:s,passes:o})}function Ir(t){return qt(t)?{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Or(t.inertia),...Dt(t)}:Ut(t)?{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...Dt(t)}:En(t)?{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:t.keyframes.map(is),...Dt(t)}:Ci(t)?{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:t.keyframes.map(is),...Dt(t)}:{id:t.id,target:t.target,property:t.property,keyframes:t.keyframes.map(is),...t.interpolation!==void 0&&{interpolation:t.interpolation},...Dt(t)}}function Or(t){return{...t,...Array.isArray(t.end)&&{end:[...t.end]}}}function is(t){return{time:t.time,value:t.value,...t.easing&&{easing:t.easing}}}function Dt(t){const e=t.endDelay;return{...t.delay!==void 0&&{delay:t.delay},...e!==void 0&&{endDelay:e},...t.targets!==void 0&&{targets:[...t.targets]},...t.stagger!==void 0&&{stagger:{...t.stagger}}}}function Hr(t){if(qt(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:Or(e.inertia),...Dt(e)}}if(Ut(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...Dt(e)}}if(En(t)){const e=t;return{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:[...e.keyframes].sort((n,i)=>n.time-i.time),...Dt(e)}}if(t.property==="motionPath"&&"motionPathConfig"in t){const e=t,n=[...e.keyframes].sort((i,s)=>i.time-s.time);return{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:n,...Dt(e)}}return Rn({id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,...t.interpolation!==void 0&&{interpolation:t.interpolation},...Dt(t)})}function Cr(t){const e=t._config.markers;return{formatVersion:Hi(t.tracks),id:t.id,name:t.name,config:{duration:t.duration>0?t.duration:void 0,loop:t._config.loop,speed:t._config.speed,alternate:t._config.alternate,repeatDelay:t._config.repeatDelay,...t._config.drawingRate?{drawingRate:t._config.drawingRate}:{},...e&&{markers:e.map(n=>({...n}))}},tracks:t.tracks.map(Ir),...t.captions&&{captions:JSON.parse(JSON.stringify(t.captions))}}}function xe(t){const e=t.formatVersion??1;if(e>Oi)throw new Error(`tinyfly: this animation uses format version ${e}, but this tinyfly reads up to version ${Oi}. Update tinyfly to play it.`);return new le({id:t.id,name:t.name,config:t.config,tracks:t.tracks.map(Hr),captions:t.captions})}function uu(t){return JSON.stringify(Cr(t))}function fu(t){const e=JSON.parse(t);return xe(e)}function Pe(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function Je(t){let e=t>>>0||2654435769;return{seed:t>>>0,next(){return e^=e<<13,e>>>=0,e^=e>>17,e^=e<<5,e>>>=0,e/4294967296}}}function ss(t,e,n){return e+t.next()*(n-e)}function Rr(t,e,n,i){if(i<=0)return ss(t,e,n);const s=Math.floor((n-e)/i),o=Math.round(t.next()*s);return e+o*i}function du(t,e){if(e.length!==0)return e[Math.floor(t.next()*e.length)]}const Lr=/^([+\-*/])=\s*(-?[\d.]+)$/,Fr=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function pu(t){return typeof t!="string"?!1:Lr.test(t.trim())||Fr.test(t.trim())}function os(t,e={}){if(typeof t!="string")return t;const n=t.trim(),i=Lr.exec(n);if(i){const[,o,r]=i,a=e.base??0,l=Number.parseFloat(r);switch(o){case"+":return a+l;case"-":return a-l;case"*":return a*l;case"/":return l===0?a:a/l}}const s=Fr.exec(n);if(s){if(!e.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const o=Number.parseFloat(s[1]),r=Number.parseFloat(s[2]),a=s[3]!==void 0?Number.parseFloat(s[3]):void 0;return a!==void 0?Rr(e.random,o,r,a):ss(e.random,o,r)}return t}function Dr(t,e=0,n){const i=[];let s=e;for(const o of t){const r=os(o,{base:s,random:n});i.push(r),typeof r=="number"&&(s=r)}return i}class gu{random;constructor(e){this.random=Je(e)}get seed(){return this.random.seed}resolve(e,n=0){return os(e,{base:n,random:this.random})}resolveSequence(e,n=0){return Dr(e,n,this.random)}}const mu=600;function Nr(t){if(Array.isArray(t)){const[u,p,g,d]=t;return{fn:Kr(u,p,g,d),bezier:[u,p,g,d]}}const{segments:e}=ae(t);if(e.length===0)throw new Error(`customEase: no curve in "${t}"`);const n=e[0].startX,i=e[0].startY,s=e[e.length-1],o=s.endX-n,r=s.endY-i;if(o===0||r===0)throw new Error(`customEase: "${t}" must move along both axes`);const a=u=>(u-n)/o,l=u=>(u-i)/r;if(e.length===1&&s.type==="C"){const[u,p,g,d]=s.points,m=[a(u),l(p),a(g),l(d)];return{fn:Kr(...m),bezier:m}}const c=[],h=[],f=Math.max(8,Math.ceil(mu/e.length));for(const u of e)for(let p=c.length===0?0:1;p<=f;p++){const[g,d]=yu(u,p/f);c.push(a(g)),h.push(l(d))}return{fn:bu(c,h)}}function Br(t={}){const n=.1+Math.max(0,Math.min(1,t.strength??.7))*.7,i=[1];for(let o=n;o>.002;o*=n)i.push(2*Math.sqrt(o));const s=i.reduce((o,r)=>o+r,0);return o=>{if(o<=0)return 0;if(o>=1)return 1;let r=o*s;for(let a=0;a<i.length;a++){if(r<=i[a]){if(a===0)return(r/i[0])**2;const l=i[a]/2,c=l*l,h=r-l;return 1-(c-h*h)}r-=i[a]}return 1}}function Wr(t={}){const e=Math.max(1,t.wiggles??10),n=t.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*e*Math.PI*2)*i(s)}function yu(t,e){if(t.type==="L"){const[c,h]=t.points;return[t.startX+(c-t.startX)*e,t.startY+(h-t.startY)*e]}const[n,i,s,o,r,a]=t.points,l=1-e;return[l*l*l*t.startX+3*l*l*e*n+3*l*e*e*s+e*e*e*r,l*l*l*t.startY+3*l*l*e*i+3*l*e*e*o+e*e*e*a]}function bu(t,e){return n=>{if(n<=t[0])return e[0];if(n>=t[t.length-1])return e[e.length-1];let i=0,s=t.length-1;for(;s-i>1;){const r=i+s>>1;t[r]<=n?i=r:s=r}const o=t[s]-t[i];return o===0?e[s]:e[i]+(n-t[i])/o*(e[s]-e[i])}}function Kr(t,e,n,i){const s=(r,a,l)=>3*(1-r)*(1-r)*r*a+3*(1-r)*r*r*l+r*r*r,o=(r,a,l)=>3*(1-r)*(1-r)*a+6*(1-r)*r*(l-a)+3*r*r*(1-l);return r=>{if(r<=0)return 0;if(r>=1)return 1;let a=r;for(let h=0;h<8;h++){const f=s(a,t,n)-r,u=o(a,t,n);if(Math.abs(f)<1e-6)return s(a,e,i);if(Math.abs(u)<1e-6)break;a-=f/u}let l=0,c=1;a=r;for(let h=0;h<40;h++)s(a,t,n)<r?l=a:c=a,a=(l+c)/2;return s(a,e,i)}}const wu=350,ku=300,vu=550;function Su(t,e={}){const n=e.lead??wu,i=e.gap??ku,s=e.tail??vu,o=[];let r=0;return t.forEach((a,l)=>{const c=[];let h=r+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);o.push({id:a.id??`s${l}`,start:r,duration:f-r,cues:c}),r=f}),{duration:r,scenes:o,cues:o.flatMap(a=>a.cues)}}function Mu(t){return t.cues.map(e=>({id:e.id,time:e.start,label:e.text}))}function Tu(t,e){let n=t.scenes[0];for(const i of t.scenes)if(e>=i.start)n=i;else break;return n}const rs=t=>6e4/t.bpm;function Fn(t,e){return t.offset+e*rs(t)}function Dn(t,e){return(e-t.offset)/rs(t)}function Eu(t,e){return Fn(t,Math.round(Dn(t,e)))}function Au(t,e){return Fn(t,Math.ceil(Dn(t,e)-1e-9))}function xu(t,e,n){const i=Math.max(1,Math.round(t.beatsPerBar??4)),s=[];if(!(t.bpm>0)||n<e)return s;for(let o=Math.ceil(Dn(t,e)-1e-9);;o++){const r=Fn(t,o);if(r>n+1e-9)break;s.push({time:r,bar:(o%i+i)%i===0,n:o})}return s}const $e=100;function Pu(t,e,n={}){const i=n.minBpm??70,s=n.maxBpm??180,o=Math.max(1,Math.round(e/$e)),r=Math.min(t.length,Math.round((n.maxSeconds??60)*e)),a=Math.floor(r/o);if(a<4)return{bpm:120,offset:0,confidence:0};const l=new Float64Array(a);for(let E=0;E<a;E++){let H=0;for(let _=E*o;_<(E+1)*o;_++)H+=t[_]*t[_];l[E]=Math.log(1e-6+H/o)}const c=new Float64Array(a);for(let E=1;E<a;E++)c[E]=Math.max(0,l[E]-l[E-1]);const h=c.reduce((E,H)=>E+H,0)/a;for(let E=0;E<a;E++)c[E]=Math.max(0,c[E]-h);const f=Math.max(1,Math.floor(60*$e/s)),u=Math.min(a-1,Math.ceil(60*$e/i)),p=E=>{let H=0;for(let _=E;_<a;_++)H+=c[_]*c[_-E];return H/(a-E)};let g=0;for(let E=0;E<a;E++)g+=c[E]*c[E];g/=a;let d=f,m=-1/0;for(let E=f;E<=u;E++){const H=60*$e/E,_=Math.exp(-.5*(Math.log2(H/120)/.9)**2),P=p(E)*_;P>m&&(m=P,d=E)}const y=E=>{const H=Math.floor(E);return H<0||H+1>=a?0:c[H]+(c[H+1]-c[H])*(E-H)},w=(E,H)=>{let _=0;for(let P=H;P<a;P+=E)_+=y(P);return _};let v=d,T=0,S=-1/0;for(let E=d-.6;E<=d+.6+1e-9;E+=.02){if(E<1)continue;const H=Math.max(1,Math.round(E*4));for(let _=0;_<H;_++){const P=_/H*E,L=w(E,P);L>S&&(S=L,T=P,v=E)}}const A=60*$e/v,x=g>0?Math.max(0,Math.min(1,p(d)/g)):0,C=(T+.5)*1e3/$e;return{bpm:Math.round(A*100)/100,offset:Math.round(C%(6e4/A)),confidence:x}}const $u=600,_u=250,Yr=1;function Iu(t,e){const n=e.target??"Camera",i={x:e.stage.width/2,y:e.stage.height/2},s={},o=(f,u,p,g)=>{const d=s[f]??=[];for(;d.length>0&&d[d.length-1].time>=u;)d.pop();d.push({time:u,value:p,...g?{easing:g}:{}})},r=f=>{const u=f.rotate*Math.PI/180,p=(f.focusX-i.x)*f.scale,g=(f.focusY-i.y)*f.scale;return{x:-(p*Math.cos(u)-g*Math.sin(u)),y:-(p*Math.sin(u)+g*Math.cos(u)),scale:f.scale,rotate:f.rotate}},a=(f,u,p)=>{const g=r(u);for(const d of["x","y","scale","rotate"])o(d,f,g[d],p)};let l={focusX:i.x,focusY:i.y,scale:1,rotate:0};const c=[...t].sort((f,u)=>f.at-u.at),h=c.filter(f=>!("shake"in f));h.length>0&&a(0,l);for(const f of h)if("frame"in f){const u=Math.max(Yr,f.duration??$u);a(f.at,l),l={focusX:f.frame.focus?.x??i.x,focusY:f.frame.focus?.y??i.y,scale:f.frame.scale??1,rotate:f.frame.rotate??0},a(f.at+u,l,f.easing??(u>Yr?"ease-in-out":void 0))}else{const{follow:u}=f,p=u.lag??_u,g=new le({id:"follow",tracks:[{id:"x",target:"s",property:"x",keyframes:u.x}]}),d=w=>g.getStateAtTime(w).values.get("s")?.get("x")??l.focusX,m=[f.at,...u.x.map(w=>w.time).filter(w=>w>f.at&&w<f.until),f.until];a(f.at,l);const y=w=>({focusX:d(w)+(u.lead??0),focusY:u.y??l.focusY,scale:u.scale??l.scale,rotate:l.rotate});for(const w of m){const v=u.x.find(T=>T.time===w)?.easing;a(w+p,y(w),w===f.at?"ease-in-out":v)}l=y(f.until)}for(const f of c.filter(u=>"shake"in u)){const u=f.shake.strength??12,p=f.shake.roll??1.5,g=1e3/(f.shake.frequency??24),d=Je(f.shake.seed??Math.round(f.at)+1),m=()=>d.next()*2-1;for(const y of["shakeX","shakeY","shakeRotate"])o(y,f.at,0);for(let y=f.at+g;y<f.at+f.duration;y+=g){const w=1-(y-f.at)/f.duration;o("shakeX",y,m()*u*w),o("shakeY",y,m()*u*w),o("shakeRotate",y,m()*p*w)}for(const y of["shakeX","shakeY","shakeRotate"])o(y,f.at+f.duration,0,"ease-out")}return Object.entries(s).map(([f,u])=>({id:`${n}-${f}`,target:n,property:f,keyframes:u}))}function jr(t,e){const n=t.toLowerCase(),i=e.toLowerCase();let s=Array.from({length:i.length+1},(o,r)=>r);for(let o=1;o<=n.length;o++){const r=[o];for(let a=1;a<=i.length;a++)r[a]=Math.min(s[a]+1,r[a-1]+1,s[a-1]+(n[o-1]===i[a-1]?0:1));s=r}return s[i.length]}function Nn(t,e){const n=t.toLowerCase(),i=e.find(r=>r.toLowerCase().includes(n)||n.includes(r.toLowerCase()));if(i&&Math.min(t.length,i.length)>=3)return i;let s,o=1/0;for(const r of e){const a=jr(t,r);a<o&&(o=a,s=r)}return s!==void 0&&o<=Math.max(2,Math.floor(t.length/3))?s:void 0}function At(t,e,n,i){const s=typeof e=="string"?i??Nn(e,n):void 0;return`Unknown ${t} ${JSON.stringify(e)}${s?`: did you mean "${s}"?`:"."} Known: ${n.join(", ")}`}const Nt=t=>Math.round(t*1e3)/1e3;function Xr(t,e={}){if(t.length===0)return"";const n=e.curviness??1,i=e.closed??!1,s=t.length;let o=`M${Nt(t[0].x)} ${Nt(t[0].y)}`;if(s===1)return o;const r=l=>i?t[(l%s+s)%s]:t[Math.max(0,Math.min(s-1,l))],a=i?s:s-1;for(let l=0;l<a;l++){const c=r(l-1),h=r(l),f=r(l+1),u=r(l+2);if(n===0){o+=` L${Nt(f.x)} ${Nt(f.y)}`;continue}const p=n/6,g=h.x+(f.x-c.x)*p,d=h.y+(f.y-c.y)*p,m=f.x-(u.x-h.x)*p,y=f.y-(u.y-h.y)*p;o+=` C${Nt(g)} ${Nt(d)} ${Nt(m)} ${Nt(y)} ${Nt(f.x)} ${Nt(f.y)}`}return i?`${o} Z`:o}const kt=(t,e=0)=>{const n=parseFloat(t??"");return Number.isFinite(n)?n:e};function Ou(t){const e=(t??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let i=0;i+1<e.length;i+=2)n.push({x:e[i],y:e[i+1]});return n}function Bn(t){const e=t.attributes;switch(t.tag.toLowerCase()){case"path":return e.d??null;case"circle":case"ellipse":{const n=kt(e.cx),i=kt(e.cy),s=t.tag.toLowerCase()==="circle"?kt(e.r):kt(e.rx),o=t.tag.toLowerCase()==="circle"?kt(e.r):kt(e.ry);return`M${n+s} ${i} A${s} ${o} 0 1 1 ${n-s} ${i} A${s} ${o} 0 1 1 ${n+s} ${i} Z`}case"rect":{const n=kt(e.x),i=kt(e.y),s=kt(e.width),o=kt(e.height);let r=e.rx!=null?kt(e.rx):e.ry!=null?kt(e.ry):0,a=e.ry!=null?kt(e.ry):r;return r=Math.min(r,s/2),a=Math.min(a,o/2),r===0||a===0?`M${n} ${i} H${n+s} V${i+o} H${n} Z`:`M${n+r} ${i} H${n+s-r} A${r} ${a} 0 0 1 ${n+s} ${i+a} V${i+o-a} A${r} ${a} 0 0 1 ${n+s-r} ${i+o} H${n+r} A${r} ${a} 0 0 1 ${n} ${i+o-a} V${i+a} A${r} ${a} 0 0 1 ${n+r} ${i} Z`}case"line":return`M${kt(e.x1)} ${kt(e.y1)} L${kt(e.x2)} ${kt(e.y2)}`;case"polyline":case"polygon":{const n=Ou(e.points);if(n.length===0)return null;const i=n.map((s,o)=>`${o===0?"M":"L"}${s.x} ${s.y}`).join(" ");return t.tag.toLowerCase()==="polygon"?`${i} Z`:i}default:return null}}function Hu(t,e,n){const i=Math.max(2,Math.round(n.samples??32)),s=Math.max(0,n.length),o=n.since!==void 0?Math.max(e-s,n.since):e-s;if(o>=e)return[];const r=n.period,a=[];for(let l=0;l<i;l++){const c=o+(e-o)*l/(i-1),h=r&&r>0&&l<i-1?(c%r+r)%r:c;a.push({at:t(h),time:c,age:s>0?(e-c)/s:0})}return a}const Cu=2.5;function qr(t){const e=[],n=[],i=t.length,s=(o,r)=>{for(let a=o+r;a>=0&&a<i;a+=r){const l=(t[a].x-t[o].x)*r,c=(t[a].y-t[o].y)*r,h=Math.hypot(l,c);if(h>1e-9)return[l/h,c/h]}return null};for(let o=0;o<i;o++){const r=t[o],a=s(o,-1),l=s(o,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 g=f*c[0]+u*c[1],d=Math.min(Cu,1/Math.max(g,1e-6)),m=r.width/2*d;e.push({x:r.x-u*m,y:r.y+f*m}),n.push({x:r.x+u*m,y:r.y-f*m})}return{left:e,right:n}}function Ur(t){const e=t.length;if(e<2)return null;const n=t[e-1];for(let i=e-2;i>=0;i--){const s=n.x-t[i].x,o=n.y-t[i].y,r=Math.hypot(s,o);if(r>1e-9)return{x:n.x,y:n.y,radius:n.width/2,start:Math.atan2(s/r,-o/r)}}return null}function Wn(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function Kn(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function Ze(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Qe(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Yn(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function as(t){return Math.hypot(t[0],t[1],t[2])}function Vr(t,e){return as(Kn(t,e))}function tn(t){const e=as(t);return e===0?[0,0,0]:Ze(t,1/e)}function Gr(t,e,n){return[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n,t[2]+(e[2]-t[2])*n]}const Ru=Object.freeze(Object.defineProperty({__proto__:null,add:Wn,cross:Yn,distance:Vr,dot:Qe,length:as,lerp:Gr,normalize:tn,scale:Ze,subtract:Kn},Symbol.toStringTag,{value:"Module"})),Lu=Math.PI/180;function zr(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function ce(t,e){const n=new Array(16);for(let i=0;i<4;i++)for(let s=0;s<4;s++){let o=0;for(let r=0;r<4;r++)o+=t[r*4+s]*e[i*4+r];n[i*4+s]=o}return n}function Jr(t){return[1,0,0,0,0,1,0,0,0,0,1,0,t[0],t[1],t[2],1]}function jn(t){return[t[0],0,0,0,0,t[1],0,0,0,0,t[2],0,0,0,0,1]}function en(t){const[e,n,i,s]=t;return[1-2*(n*n+i*i),2*(e*n+i*s),2*(e*i-n*s),0,2*(e*n-i*s),1-2*(e*e+i*i),2*(n*i+e*s),0,2*(e*i+n*s),2*(n*i-e*s),1-2*(e*e+n*n),0,0,0,0,1]}function Zr(t,e,n){const i=en(e);for(let s=0;s<3;s++)i[s]*=n[0],i[4+s]*=n[1],i[8+s]*=n[2];return i[12]=t[0],i[13]=t[1],i[14]=t[2],i}function Fu(t){const e=new Array(16);for(let n=0;n<4;n++)for(let i=0;i<4;i++)e[i*4+n]=t[n*4+i];return e}function Du(t){const[e,n,i,s,o,r,a,l,c,h,f,u,p,g,d,m]=t,y=e*r-n*o,w=e*a-i*o,v=e*l-s*o,T=n*a-i*r,S=n*l-s*r,A=i*l-s*a,x=c*g-h*p,C=c*d-f*p,E=c*m-u*p,H=h*d-f*g,_=h*m-u*g,P=f*m-u*d,L=y*P-w*_+v*H+T*E-S*C+A*x;if(Math.abs(L)<1e-12)return null;const F=1/L;return[(r*P-a*_+l*H)*F,(i*_-n*P-s*H)*F,(g*A-d*S+m*T)*F,(f*S-h*A-u*T)*F,(a*E-o*P-l*C)*F,(e*P-i*E+s*C)*F,(d*v-p*A-m*w)*F,(c*A-f*v+u*w)*F,(o*_-r*E+l*x)*F,(n*E-e*_-s*x)*F,(p*S-g*v+m*y)*F,(h*v-c*S-u*y)*F,(r*C-o*H-a*x)*F,(e*H-n*C+i*x)*F,(g*w-p*T-d*y)*F,(c*T-h*w+f*y)*F]}function Nu(t,e,n,i){const s=1/Math.tan(t*Lu/2),o=1/(n-i);return[s/e,0,0,0,0,s,0,0,0,0,(i+n)*o,-1,0,0,2*i*n*o,0]}function Bu(t,e,n,i,s,o){const r=1/(e-t),a=1/(i-n),l=1/(o-s);return[2*r,0,0,0,0,2*a,0,0,0,0,-2*l,0,-(e+t)*r,-(i+n)*a,-(o+s)*l,1]}function Wu(t,e,n=[0,1,0]){const i=tn(Kn(t,e)),s=tn(Yn(n,i)),o=Yn(i,s);return[s[0],o[0],i[0],0,s[1],o[1],i[1],0,s[2],o[2],i[2],0,-Qe(s,t),-Qe(o,t),-Qe(i,t),1]}function Qr(t,e){const n=t[0]*e[0]+t[4]*e[1]+t[8]*e[2]+t[12],i=t[1]*e[0]+t[5]*e[1]+t[9]*e[2]+t[13],s=t[2]*e[0]+t[6]*e[1]+t[10]*e[2]+t[14],o=t[3]*e[0]+t[7]*e[1]+t[11]*e[2]+t[15];return o===1||o===0?[n,i,s]:[n/o,i/o,s/o]}const Ku=Object.freeze(Object.defineProperty({__proto__:null,compose:Zr,fromQuat:en,identity:zr,invert:Du,lookAt:Wu,multiply:ce,orthographic:Bu,perspective:Nu,scaling:jn,transformPoint:Qr,translation:Jr,transpose:Fu},Symbol.toStringTag,{value:"Module"})),Xn={"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]},ta={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 Yu(t){let e=t.trim().toLowerCase();e=e.replace(/\.ease(in|out|inout)$/,".$1");const n=/^([a-z]+\d?)(\(.*\))?$/.exec(e);return n&&n[1]!=="steps"&&e!=="none"&&e!=="linear"&&(e=`${n[1]}.out${n[2]??""}`),e}Mt({type:"bounce",mode:"in"}),Mt({type:"bounce",mode:"in-out"});function nn(t){const e=ea.get(t.trim().toLowerCase());if(e)return e;const n=Yu(t),i=/^steps\(\s*(\d+)\s*\)$/.exec(n);if(i){const r={type:"steps",count:Math.max(1,Number.parseInt(i[1],10))+1,position:"none"};return{easing:r,fn:Mt(r)}}const s=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(s){const[,o,r,a]=s,l=(a??"").split(",").map(f=>Number.parseFloat(f)).filter(f=>Number.isFinite(f)),c=r==="inout"?"in-out":r;if(o==="back"&&l.length===0&&n in Xn)return{easing:{type:"cubic-bezier",points:Xn[n]}};const h=o==="elastic"?{type:"elastic",mode:c,...l[0]!==void 0&&{amplitude:l[0]},...l[1]!==void 0&&{period:l[1]}}:o==="bounce"?{type:"bounce",mode:c}:{type:"back",mode:c,...l[0]!==void 0&&{overshoot:l[0]}};return{easing:h,fn:Mt(h)}}return n in ta?{easing:ta[n]}:n in Xn?{easing:{type:"cubic-bezier",points:Xn[n]}}:{easing:"ease-out"}}const ea=new Map;function ls(t,e){return ea.set(t.trim().toLowerCase(),e.bezier?{easing:{type:"cubic-bezier",points:e.bezier},fn:e.fn}:{fn:e.fn,requiresBaking:"custom"}),t}function cs(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}const na=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function ia(t){return typeof t=="string"&&na.test(t)}function ju(t=1){let e=cs(t);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),o=(l,c)=>{if(typeof l=="number")return l===0?c:Math.round(c/l)*l;if(Array.isArray(l))return sa(l,c,1/0);if("values"in l)return sa(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},r=(l,c,h)=>{const f=l+e()*(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]=ze(l[u])(l[u],c[u],h);return f}return ze(l)(l,c,h)}),wrap:((l,c,h)=>{if(Array.isArray(l)){const d=l,m=y=>d[(Math.round(y)%d.length+d.length)%d.length];return c===void 0?m:m(c)}const f=l,p=c-f,g=d=>p===0?f:((d-f)%p+p)%p+f;return h===void 0?g:g(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,o),random:((l,c,h,f)=>{if(Array.isArray(l)){const p=()=>l[Math.floor(e()*l.length)];return c===!0?p:p()}const u=()=>r(l,c,h);return f?u:u()}),shuffle:l=>{for(let c=l.length-1;c>0;c--){const h=Math.floor(e()*(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,g,d)=>{const m=d.length,w=An(p,m,{...c!==void 0?{amount:c}:{each:h??1},from:f}),v=c!==void 0?c:(h??1)*Li(m,f),T=u&&v>0?u(w/v)*v:w;return l+T},pipe:(...l)=>c=>l.reduce((h,f)=>f(h),c),splitColor:l=>Xu(l),getUnit:l=>typeof l=="number"?"":/^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(l.trim())?.[1]??"",seed:l=>{e=cs(l)},resolveRandomString:l=>{const c=na.exec(l)?.[1]??"";if(c.startsWith("[")){const g=c.slice(1,-1).split(",").map(d=>d.trim()).filter(Boolean).map(d=>Number.isFinite(Number(d))?Number(d):d.replace(/^['"]|['"]$/g,""));return g[Math.floor(e()*g.length)]}const[h,f,u]=c.split(",").map(p=>Number.parseFloat(p));return r(h,f,Number.isFinite(u)?u:void 0)}}}function sa(t,e,n){let i=e,s=1/0;for(const o of t){const r=Math.abs(o-e);r<s&&(s=r,i=o)}return s<=n?i:e}function Xu(t){const e=t.trim(),n=/^#([0-9a-f]{3,8})$/i.exec(e)?.[1];if(n){const o=(n.length<=4?[...n].map(r=>r+r).join(""):n).match(/../g).map(r=>Number.parseInt(r,16));return o.length>=4?[o[0],o[1],o[2],Math.round(o[3]/255*1e3)/1e3]:[o[0],o[1],o[2]]}const i=(/rgba?\(([^)]+)\)/i.exec(e)?.[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 qu=/^([+-])=\s*(-?[\d.]+)$/,Uu=/^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;function sn(t,e){const n=e.scale??1,i=c=>Number.parseFloat(c)*n;if(t===void 0)return e.cursor;if(typeof t=="number")return t*n;const s=t.trim();if(s==="")return e.cursor;const o=qu.exec(s);if(o){const c=i(o[2]);return e.cursor+(o[1]==="-"?-c:c)}const r=Uu.exec(s);if(r){const c=r[1]==="<"?e.previousStart:e.previousEnd;if(r[3]===void 0)return c;const h=i(r[3]);return c+(r[2]==="-"?-h:h)}const a=/^(.+?)([+-])=\s*(-?[\d.]+)$/.exec(s);if(a){const c=e.labels.get(a[1].trim());if(c!==void 0){const h=i(a[3]);return c+(a[2]==="-"?-h:h)}}const l=e.labels.get(s);return l!==void 0?l:/^-?[\d.]+$/.test(s)?i(s):e.cursor}function Vu(t){if(typeof t!="object"||t===null)return!1;const e=t;return e.grid!==void 0||e.from==="random"||Array.isArray(e.from)||e.ease!==void 0||e.axis!==void 0}function Gu(t,e,n={}){if(t===0)return[];const i=e.grid==="auto"?Math.max(1,Math.min(t,n.columnsFromLayout?.()??t)):Array.isArray(e.grid)?Math.max(1,e.grid[1]):t,s=Array.isArray(e.grid)?Math.max(1,e.grid[0]):Math.ceil(t/i),o=g=>({x:g%i,y:Math.floor(g/i)}),r=e.from??"start",a=Array.isArray(r)?{x:r[0]*(i-1),y:r[1]*(s-1)}:typeof r=="number"?o(Math.max(0,Math.min(t-1,r))):r==="end"?o(t-1):r==="center"||r==="edges"?{x:(i-1)/2,y:(s-1)/2}:{x:0,y:0},l=g=>{const{x:d,y:m}=o(g),y=Math.abs(d-a.x),w=Math.abs(m-a.y);return e.axis==="x"?y:e.axis==="y"?w:Math.hypot(y,w)};let c=Array.from({length:t},(g,d)=>l(d));const h=Math.max(...c);if(r==="edges"&&(c=c.map(g=>h-g)),r==="random"){const g=n.random??Math.random;c=c.map(()=>g()*h)}const f=e.amount!==void 0?e.amount:(e.each??0)*h,u=e.ease?nn(e.ease):void 0,p=u?u.fn??Mt(u.easing):void 0;return c.map(g=>{const d=h===0?0:g/h;return(p?p(d):d)*f})}const hs=new Set(["duration","delay","ease","repeat","repeatDelay","yoyo","stagger","onComplete","onUpdate","onStart","onRepeat","onReverseComplete","repeatRefresh","keyframes","easeEach","scrollTo","id","immediateRender","overwrite","paused","scrollTrigger","spring"]),zu={rotation:"rotate",rotationZ:"rotate",rotationX:"rotateX",rotationY:"rotateY",transformPerspective:"perspective",perspective:"childPerspective"};function qn(t){const e={},n={};for(const[i,s]of Object.entries(t))hs.has(i)?e[i]=s:n[zu[i]??i]=s;return{config:e,properties:n}}function Un(t,e){return t===void 0?e:t*1e3}function us(t,e){if(t!==void 0)return typeof t=="number"?{each:t*1e3}:Vu(t)?{offsets:Gu(e?.count??0,t,e??{}).map(i=>i*1e3)}:{...t.each!==void 0&&{each:t.each*1e3},...t.amount!==void 0&&{amount:t.amount*1e3},...t.from!==void 0&&{from:t.from}}}const Ju={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 oa(t){return Ju[t]}function Zu(t){const e=typeof t=="string"||Array.isArray(t)?{path:t}:t;if(!e||typeof e.path!="string"&&!Array.isArray(e.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(e.path))n=Xr(e.path,{curviness:e.curviness});else if(Me(e.path))n=e.path;else throw new Error(`gsap-compat: motionPath "${e.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 e.autoRotate!==void 0&&e.autoRotate!==!1&&(i.autoRotate=!0,typeof e.autoRotate=="number"&&(i.rotateOffset=e.autoRotate)),e.matrix&&(i.matrix=e.matrix),{config:i,start:e.start??0,end:e.end??1}}function Qu(t){const e=typeof t=="string"||Array.isArray(t)?{path:t}:{...t};return{...e,start:e.end??1,end:e.start??0}}function ra(t){return typeof t=="object"&&t!==null&&"shape"in t?t.shape:t}function tf(t){if(t.morphSVG===void 0)return t;const{morphSVG:e,...n}=t,i=ra(e);if(typeof i!="string"||!Me(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 ef(t,e){if(t===!0)return[0,e];if(t===!1)return[0,0];if(typeof t=="number")return[0,aa(t,e)];const n=t.trim().split(/[\s,]+/).filter(Boolean),i=r=>{const a=Number.parseFloat(r);if(Number.isNaN(a))throw new Error(`gsap-compat: drawSVG "${t}" is not a length or percentage`);return aa(r.endsWith("%")?e*a/100:a,e)};if(n.length===0)return[0,e];if(n.length===1)return[0,i(n[0])];const s=i(n[0]),o=i(n[1]);return s<=o?[s,o]:[o,s]}function nf(t,e){const[n,i]=ef(t,e);return{strokeDasharray:[i-n,e],strokeDashoffset:-n}}function sf(t,e){if(t.drawSVG===void 0)return t;const{drawSVG:n,...i}=t;return{...i,...nf(n,e)}}function of(t){if(t.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 t}function aa(t,e){return Math.max(0,Math.min(e,t))}function rf(t){let e=2166136261;for(let n=0;n<t.length;n++)e=Math.imul(e^t.charCodeAt(n),16777619);return e>>>0}function af(t,e,n){if(t.scrambleText!==void 0){const i=t.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 o=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},...o!==void 0&&{revealDelay:Math.min(o,.999)},...s.tweenLength!==void 0&&{tweenLength:s.tweenLength},...s.rightToLeft!==void 0&&{rightToLeft:s.rightToLeft},seed:s.seed??rf(`${e}|${s.text}`)}}if(t.text!==void 0){const i=t.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 fs(t){return Math.max(.1,t/25)}function lf(t,e){const n=typeof e=="number"?{velocity:e}:e;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?fs(n.resistance):void 0),s={from:t,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(Xe(s))]:n.end!==void 0&&(s.end=Array.isArray(n.end)?[...n.end]:n.end),s}function cf(t){const e=t===!0?{}:typeof t=="string"?{preset:t}:t;if(e.preset!==void 0&&!(e.preset in $n))throw new Error(`gsap-compat: unknown spring preset "${e.preset}" — use one of ${Object.keys($n).join(", ")}`);return{...e.preset?$n[e.preset]:{},...e.stiffness!==void 0&&{stiffness:e.stiffness},...e.damping!==void 0&&{damping:e.damping},...e.mass!==void 0&&{mass:e.mass},...e.restDelta!==void 0&&{restDelta:e.restDelta}}}function hf(t,e){if(t===!0||typeof t=="string")return;const n=t.velocity;return typeof n=="number"?n:n?.[e]}class he{timeline;options;cursor=0;fallbackRandom=cs(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(e={}){this.options=e,this.timeline=new le({id:e.id??"gsap-compat",name:e.name,config:{...e.repeat!==void 0&&{loop:e.repeat},...e.yoyo!==void 0&&{alternate:e.yoyo},...e.repeatDelay!==void 0&&{repeatDelay:e.repeatDelay*1e3},...e.timeScale!==void 0&&{speed:e.timeScale}}})}to(e,n,i){return this.build(e,void 0,on(n),i)}from(e,n,i){const{config:s,properties:o}=qn(on(n)),{motionPath:r,text:a,scrambleText:l,...c}=o,h=this.targetsOf(e)[0],f={...s};for(const g of Object.keys(c))f[g]=this.resolveStart(h,g);r!==void 0&&(f.motionPath=Qu(r));const u={},p=String(this.resolveStart(h,"text"));return a!==void 0&&(u.text=ds(a),f.text=typeof a=="object"?{...a,value:p}:p),l!==void 0&&(u.text=ds(l),f.scrambleText=typeof l=="object"?{...l,text:p}:p),this.build(e,{...c,...u},f,i)}fromTo(e,n,i,s){const{properties:o}=qn(on(n));return this.build(e,o,on(i),s)}set(e,n,i){return this.build(e,void 0,{...on(n),duration:0},i)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(e){const n=Math.max(0,sn(e,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(e){return sn(e,this.context())}addLabel(e,n){return this.labels.set(e,sn(n,this.context())),this}labelTimes(){return[...this.labels.values()].sort((e,n)=>e-n)}labelTime(e){return this.labels.get(e)}add(e,n){const i=sn(n,this.context());for(const o of e.timeline.tracks){if(!("keyframes"in o))continue;const r=Rn({...o,id:this.nextTrackId(`nested-${o.id}`),keyframes:o.keyframes.map(a=>({...a,time:a.time+i}))});this.timeline.addTrack(r)}const s=i+e.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(e){if(typeof e=="string"){const n=this.labels.get(e);return n!==void 0&&this.timeline.seek(n),this}return this.timeline.seek(e*1e3),this}progress(e){const n=this.timeline.duration;return e!==void 0&&n>0&&this.timeline.seek(e*n),n>0?this.timeline.currentTime/n:0}timeScale(e){return e!==void 0&&(this.timeline.speed=e),this.timeline.speed}duration(){return this.timeline.duration/1e3}tick(e){return this.timeline.tick(e),this}toDefinition(){return this.timeline.toDefinition()}build(e,n,i,s){const{config:o,properties:r}=qn(i),{motionPath:a,text:l,scrambleText:c,inertia:h,...f}=r,u=this.targetsOf(e),p=sn(s,this.context()),g=Un(o.delay,0),d=Un(o.duration,500),m=us(o.stagger,{count:u.length,columnsFromLayout:this.options.layoutColumns?()=>this.options.layoutColumns(u):void 0,random:this.options.random??this.fallbackRandom}),y=this.easingFor(o.ease),w=[],v=o.spring;let T=0,S=!1;for(const[_,P]of Object.entries(f)){const L=P;let F=n?.[_]!==void 0?n[_]:this.resolveStart(u[0],_);if(typeof F!=typeof L&&(this.warn(`no usable start value for "${_}" on "${u[0]}" — it will snap to ${String(L)}. Use fromTo() to animate it.`),F=L),v!==void 0&&(typeof F!="number"||typeof L!="number")&&this.warn(`spring works on numbers, so "${_}" on "${u[0]}" eases instead`),v!==void 0&&typeof F=="number"&&typeof L=="number"){const ot={...cf(v),from:F,to:L,velocity:hf(v,_)??this.options.startVelocity?.(u[0],_)??0},X=this.nextTrackId(`${u[0]}-${_}-spring`),tt={id:X,target:u[0],...u.length>1&&{targets:u},...m&&u.length>1&&{stagger:m},property:_,kind:"spring",spring:ot,delay:p+g};this.timeline.addTrack(tt),w.push(X),T=Math.max(T,Wo(ot));for(const J of u)this.lastValues.set(`${J}|${_}`,L);continue}S=!0;const K=this.keyframesFor(F,L,d,y,o.ease),V=this.nextTrackId(`${u[0]}-${_}`);this.timeline.addTrack(Rn({id:V,target:u[0],...u.length>1&&{targets:u},...m&&u.length>1&&{stagger:m},property:_,delay:p+g,keyframes:K,..._==="quaternion"&&{interpolation:"slerp"}})),w.push(V);for(const ot of u)this.lastValues.set(`${ot}|${_}`,L)}const A=af({text:l,scrambleText:c},u[0],d);if(A){const _=n?.text??n?.scrambleText,P=_!==void 0?ds(_):this.resolveStart(u[0],"text"),L=this.nextTrackId(`${u[0]}-text`),F={id:L,target:u[0],...u.length>1&&{targets:u},...m&&u.length>1&&{stagger:m},property:"text",textConfig:{from:typeof P=="string"?P:String(P??""),...A},delay:p+g,keyframes:this.keyframesFor(0,1,d,y,o.ease)};this.timeline.addTrack(F),w.push(L);for(const K of u)this.lastValues.set(`${K}|text`,A.to)}if(a!==void 0){const{config:_,start:P,end:L}=Zu(a),F=this.nextTrackId(`${u[0]}-motionPath`),K={id:F,target:u[0],...u.length>1&&{targets:u},...m&&u.length>1&&{stagger:m},property:"motionPath",motionPathConfig:_,delay:p+g,keyframes:this.keyframesFor(P,L,d,y,o.ease)};this.timeline.addTrack(K),w.push(F)}if(h!==void 0)for(const[_,P]of Object.entries(h)){const L=this.resolveStart(u[0],_);if(typeof L!="number"){this.warn(`inertia on "${_}" needs a numeric start value; skipped`);continue}const F=lf(L,P),K=this.nextTrackId(`${u[0]}-${_}-inertia`),V={id:K,target:u[0],...u.length>1&&{targets:u},...m&&u.length>1&&{stagger:m},property:_,kind:"inertia",inertia:F,delay:p+g};this.timeline.addTrack(V),w.push(K),T=Math.max(T,ve(F));for(const ot of u)this.lastValues.set(`${ot}|${_}`,ke(F))}const E=((h!==void 0||v!==void 0)&&!S&&!A&&a===void 0?T:Math.max(d,T))+(m&&u.length>1?Ye(u.length,m):0),H=p+g+E;return this.previousStart=p+g,this.previousEnd=H,this.cursor=Math.max(this.cursor,H),{trackIds:w,start:p+g,end:H,kill:()=>{for(const _ of w)this.timeline.removeTrack(_)}}}keyframesFor(e,n,i,s,o){const r={time:0,value:e};if(i<=0)return[{time:0,value:n}];const a=typeof o=="string"?nn(o):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&Ke(s)){const c=a?.fn??Mt(s);return[r,...Qi(r,{time:i,value:n},c,{intervalMs:this.options.bakeIntervalMs})]}return[r,{time:i,value:n,...s&&{easing:s}}]}resolveStart(e,n){const i=this.lastValues.get(`${e}|${n}`);if(i!==void 0)return i;const s=this.options.startValue?.(e,n);if(s!==void 0)return s;const o=this.options.defaults?.[n];if(o!==void 0)return o;if(n==="text")return"";if(n==="quaternion")return[0,0,0,1];if(n==="d")throw new Error(`gsap-compat: no starting shape for "${e}". Use fromTo({ d: … }, { morphSVG: … }), or live.to(), which reads the element's current shape.`);const r=oa(n);return r!==void 0?(this.warn(`no start value for "${n}" on "${e}" — using the static default ${r}. GSAP would read the live DOM here; tinyfly cannot, so pass an explicit fromTo() or a defaults map.`),r):(this.warn(`no start value or default for "${n}" on "${e}" — using 0`),0)}easingFor(e){if(e!==void 0){if(typeof e=="string")return nn(e).easing;if(typeof e=="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 e}}targetsOf(e){return Array.isArray(e)?e:[e]}context(){return{cursor:this.cursor,previousStart:this.previousStart,previousEnd:this.previousEnd,labels:this.labels,scale:1e3}}nextTrackId(e){return this.trackCounter+=1,`${e}-${this.trackCounter}`}warn(e){this.options.onWarning?.(`gsap-compat: ${e}`)}}function ds(t){if(typeof t=="string")return t;if(t&&typeof t=="object"){const e=t;return String(e.value??e.text??"")}return String(t??"")}function uf(t){return new he(t)}function on(t){return of(tf(t))}function ff(t){return!Array.isArray(t)||t.length!==4?null:`matrix3d(${en(zt(t)).map(n=>Math.round(n*1e6)/1e6+0).join(", ")})`}const df=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),pf="#ffffff",gf="rgba(0, 0, 0, 0.5)";function mf(t){const e=[];if(t.blur!==void 0&&e.push(`blur(${Math.max(0,t.blur)}px)`),t.brightness!==void 0&&e.push(`brightness(${Math.max(0,t.brightness)})`),t.glow!==void 0&&e.push(`drop-shadow(0 0 ${Math.max(0,t.glow)}px ${t.glowColor??pf})`),t.shadowX!==void 0||t.shadowY!==void 0||t.shadowBlur!==void 0){const n=t.shadowX??0,i=t.shadowY??0,s=Math.max(0,t.shadowBlur??0);e.push(`drop-shadow(${n}px ${i}px ${s}px ${t.shadowColor??gf})`)}return e.length>0?e.join(" "):null}function yf(t,e){const n=t.childNodes.length===1?t.firstChild:null;if(n&&n.nodeType===3){const i=n;i.data!==e&&(i.data=e);return}t.textContent!==e&&(t.textContent=e)}function bf(t){if(!("ownerSVGElement"in t))return;const e=t.style;!e||e.transformBox||(e.transformBox="fill-box",e.transformOrigin||(e.transformOrigin="50% 50%"))}const la=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"]),wf=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","quaternion","motionPathX","motionPathY","motionPathRotate"]),kf=["x","motionPathX","y","motionPathY","z","rotate","rotateZ","motionPathRotate","rotateX","rotateY","quaternion","scale","scaleX","scaleY","scaleZ","skewX","skewY"],vf=new Set(["childPerspective","perspectiveOriginX","perspectiveOriginY"]),Sf=new Set(["originX","originY"]),Mf=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Tf=new Set(["drawOn"]),Ef={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},ca={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},Af="http://www.w3.org/2000/svg";class ue{targets=new Map;registerTarget(e,n){this.targets.set(e,n)}unregisterTarget(e){this.targets.delete(e)}getTarget(e){return this.targets.get(e)}clearTargets(){this.targets.clear()}applyState(e){for(const[n,i]of e.values){const s=this.targets.get(n);s&&this.applyProperties(s,i)}}applyProperties(e,n){let i=null,s=null,o=null,r=null,a=null;const l=n.has("motionPathX"),c=n.has("motionPathY"),h=n.has("motionPathRotate");for(const[g,d]of n)if(!(g==="x"&&l)&&!(g==="y"&&c)&&!((g==="rotate"||g==="rotateZ")&&h)&&!Tf.has(g)){if(wf.has(g))(i??={})[g]=d;else if(vf.has(g))typeof d=="number"&&((s??={})[g]=d);else if(Sf.has(g))typeof d=="number"&&((o??={})[g]=d);else if(Mf.has(g))typeof d=="number"&&((r??={})[g]=d);else if(df.has(g))(a??={})[g]=d;else if(g!=="perspective"){if(g!=="shine")if(g==="text"&&typeof d=="string")yf(e,d);else if(g==="d"&&typeof d=="string"){const m=e;(m.tagName?.toLowerCase()==="path"?m:m.querySelector?.("path"))?.setAttribute?.("d",d)}else this.applyStyleProperty(e,g,d)}}const f=n.get("shine");typeof f=="number"&&this.applyShine(e,f);const u=[],p=n.get("perspective");if(typeof p=="number"&&p>0&&u.push(`perspective(${p}px)`),i)for(const g of kf){const d=i[g];if(d===void 0)continue;const m=this.buildTransformPart(g,d);m&&u.push(m)}if(u.length>0&&(e.style.transform=u.join(" "),bf(e)),s&&(s.childPerspective!==void 0&&(e.style.perspective=`${s.childPerspective}px`),(s.perspectiveOriginX!==void 0||s.perspectiveOriginY!==void 0)&&(e.style.perspectiveOrigin=`${s.perspectiveOriginX??50}% ${s.perspectiveOriginY??50}%`)),o){const g=o.originX??50,d=o.originY??50;e.style.transformOrigin=`${g}% ${d}%`}if(r){const g=r.clipTop??0,d=r.clipRight??0,m=r.clipBottom??0,y=r.clipLeft??0;e.style.clipPath=`inset(${g}% ${d}% ${m}% ${y}%)`}if(a){const g=mf(a);g&&(e.style.filter=g)}}buildTransformPart(e,n){if(e==="quaternion")return ff(n);if(typeof n!="number")return null;switch(e){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(e,n){e.dataset.shineBase||(e.dataset.shineBase=e.style.color||"currentColor");const i=e.dataset.shineBase,s=-20+n*140,o=e.style;o.color="transparent",o.backgroundImage=`linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${i}, ${i})`,o.backgroundSize="250% 100%, 100% 100%",o.backgroundPosition=`${s}% 0, 0 0`,o.backgroundRepeat="no-repeat",o.webkitBackgroundClip="text",o.backgroundClip="text"}applyStyleProperty(e,n,i){let s;if(e.namespaceURI===Af&&n in ca){const a=Array.isArray(i)?i.join(", "):String(i);e.style[ca[n]]=a;return}else n==="fill"&&e.dataset?.elementType==="text"?s="color":s=Ef[n]??n;let r;typeof i=="number"?la.has(n)||la.has(s)?r=`${i}px`:r=String(i):Array.isArray(i)?r=i.join(", "):r=i,e.style[s]=r}}const xf={request:t=>requestAnimationFrame(t),cancel:t=>cancelAnimationFrame(t)};class ha{adapter=new ue;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=ju();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(e={}){this.scheduler=e.scheduler??xf,this.rootOption=e.root,this.onWarning=e.onWarning}get root(){return this.rootOption??document}resolveTargets(e){const n=[];for(const i of this.targetsOf(e)){const s=this.nameFor(i);ps(i)&&this.currentCollector?.touch(i,s),n.push(s)}return n}query(e){return this.selectorRoot.querySelector(e)}get collector(){return this.currentCollector}setCollector(e){this.currentCollector=e}forget(e){this.applied.delete(e),this.dirty.delete(e)}get selectorRoot(){return this.currentCollector?.scope??this.root}elementFor(e){return this.elements.get(e)}objectFor(e){return this.objects.get(e)}appliedValue(e,n){return this.applied.get(e)?.get(n)}velocityOf(e,n){for(const s of[...this.active.keys()].reverse()){if(s.getTracks({target:e,property:n}).length===0)continue;const o=s.currentTime;if(o<4)return 0;const r=s.getStateAtTime(o).values.get(e)?.get(n),a=s.getStateAtTime(o-4).values.get(e)?.get(n);if(typeof r!="number"||typeof a!="number")return;const l=(r-a)/4;return(s.direction==="reverse"?-l:l)*1e3}}ticker={add:e=>{this.destroyed||(this.tickerCallbacks.size===0&&(this.tickerTime=0,this.tickerFrame=0),this.tickerCallbacks.add(e),this.currentCollector?.track({revert:()=>this.ticker.remove(e)}),this.startLoop())},remove:e=>{this.tickerCallbacks.delete(e),this.running||this.stopLoop()}};activate(e,n={}){this.destroyed||(e.onUpdate=i=>this.write(i),this.active.delete(e),this.active.set(e,n),this.startLoop())}deactivate(e){this.active.delete(e),this.running||this.stopLoop()}own(e){return this.destroyed?e.destroy():this.owned.add(e),e}destroy(){this.destroyed=!0;for(const e of this.owned)e.destroy();this.owned.clear();for(const e of this.active.keys())e.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(e,n){if(this.destroyed)return;const i=new Map(Object.entries(n));this.write({values:new Map([[e,i]]),currentTime:0,playbackState:"idle",direction:"forward",loopIteration:0}),this.flush()}render(e){this.destroyed||(this.write(e.getStateAtTime(e.currentTime)),this.flush())}tick(e){const n=[...this.active];for(const[i]of n)i.duration<=0?(this.write(i.getStateAtTime(0)),i.stop()):i.tick(e);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(e),this.running||this.stopLoop()}get running(){return this.active.size>0||this.tickerCallbacks.size>0}runTicker(e){if(this.tickerCallbacks.size!==0){this.tickerTime+=e,this.tickerFrame+=1;for(const n of[...this.tickerCallbacks])n(this.tickerTime/1e3,e,this.tickerFrame)}}write(e){for(const[n,i]of e.values){let s=this.applied.get(n);s||(s=new Map,this.applied.set(n,s));for(const[o,r]of i)s.set(o,r);this.dirty.add(n)}}flush(){if(this.dirty.size===0)return;const e=new Map;for(const n of this.dirty){const i=this.applied.get(n),s=this.objects.get(n);if(s)for(const[o,r]of i)s[o]=r;else e.set(n,i)}this.dirty.clear(),e.size!==0&&this.adapter.applyState({values:e,currentTime:0,playbackState:"playing",direction:"forward",loopIteration:0})}frame=e=>{this.frameId=null;const n=this.lastTimestamp===null?0:e-this.lastTimestamp;this.lastTimestamp=e,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(e){if(typeof e=="string")return Array.from(this.selectorRoot.querySelectorAll(e));if(ps(e))return[e];if(!Pf(e))return[e];const n=[];for(const i of Array.from(e))n.push(...this.targetsOf(i));return n}nameFor(e){return ps(e)?this.elementName(e):this.objectName(e)}objectName(e){const n=this.objectNames.get(e);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(e,i),this.objects.set(i,e),i}elementName(e){const n=this.names.get(e);if(n)return n;let i=e.id?`#${e.id}`:"";if(!i||this.elements.has(i))do this.nameCounter+=1,i=`el-${this.nameCounter}`;while(this.elements.has(i));return this.names.set(e,i),this.elements.set(i,e),this.adapter.registerTarget(i,e),i}}function ps(t){return typeof t=="object"&&t!==null&&t.nodeType===1}function Pf(t){if(Array.isArray(t))return!0;const e=t;return typeof e.length=="number"&&typeof e.item=="function"}function Vn(t){const e=t.style;if(!e)return t.getBoundingClientRect();const n=e.transform;e.transform="none";const i=t.getBoundingClientRect();return e.transform=n,i}const ua=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function $f(t){const e={};for(const n of Array.from(t.attributes))e[n.name]=n.value;return e}function _f(t){const e=t.getScreenCTM?.();if(e)return[e.a,e.b,e.c,e.d,e.e,e.f];const n=t.getBoundingClientRect();return[1,0,0,1,n.left,n.top]}function If(t,e){const n=typeof t=="string"||Array.isArray(t)||ua(t)?{path:t}:t,{align:i,alignOrigin:s,path:o,...r}=n,a=A=>{const x=ua(A)?A:e.query(A);return x||e.warn(`gsap-compat: motionPath could not find "${String(A)}"`),x};let l=null,c="";if(Array.isArray(o)||typeof o=="string"&&Me(o))c=o;else{l=a(o);const A=l&&Bn({tag:l.localName,attributes:$f(l)});l&&!A&&e.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),c=A??""}const h={...r,path:c};if(i===void 0||i===!1)return h;const f=i===!0?l:a(i);if(!f)return i===!0&&e.warn("gsap-compat: motionPath align: true needs the path to be an element"),h;const u=e.targets[0];if(!u)return h;const[p,g,d,m,y,w]=_f(f),v=Vn(u),[T,S]=s??[.5,.5];for(const A of e.targets.slice(1)){const x=Vn(A);if(Math.abs(x.left-v.left)>.5||Math.abs(x.top-v.top)>.5){e.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");break}}return h.matrix=[p,g,d,m,y-v.left-T*v.width,w-v.top-S*v.height],h}const fa=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function da(t){const e={};for(const n of Array.from(t.attributes))e[n.name]=n.value;return e}function pa(t){if(!t)return null;const e=Bn({tag:t.localName,attributes:da(t)});return e||(t.querySelector("path")?.getAttribute("d")??null)}function Of(t,e,n){const i=ra(t);if(typeof i=="string"&&Me(i))return i;const s=fa(i)?i:typeof i=="string"?e(i):null,o=pa(s);return o||(n(`gsap-compat: morphSVG could not find a shape for "${String(i)}"`),"")}const Hf=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function Cf(t,e=document){return(typeof t=="string"?Array.from(e.querySelectorAll(t)):fa(t)?[t]:Array.from(t)).map(i=>{if(i.localName==="path")return i;const s=Bn({tag:i.localName,attributes:da(i)});if(!s||!i.parentNode)return i;const o=i.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path");for(const r of Array.from(i.attributes))Hf.has(r.name)||o.setAttribute(r.name,r.value);return o.setAttribute("d",s),i.parentNode.replaceChild(o,i),o})}const ga=.3;class ma{options;target;running=!1;dragging=!1;passedTolerance=!1;lastX=0;lastY=0;startX=0;startY=0;velocityX=0;velocityY=0;lastTime=0;constructor(e){this.options=e,this.target=e.target}start(){if(this.running)return;this.running=!0;const e=this.options.type??["pointer","touch"];e.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)),e.includes("touch")&&(this.target.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.target.addEventListener("touchmove",this.onTouchMove,{passive:!1}),this.target.addEventListener("touchend",this.onTouchEnd)),e.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(e,n,i){this.dragging=!0,this.passedTolerance=!1,this.startX=e,this.startY=n,this.lastX=e,this.lastY=n,this.velocityX=0,this.velocityY=0,this.lastTime=ya(),this.options.onPress?.(this.stateFrom(0,0,i))}move(e,n,i){if(!this.dragging)return;const s=e-this.lastX,o=n-this.lastY;this.lastX=e,this.lastY=n;const r=e-this.startX,a=n-this.startY,l=this.options.tolerance??3;if(!this.passedTolerance){if(Math.hypot(r,a)<l)return;this.passedTolerance=!0}this.updateVelocity(s,o),this.options.preventDefault!==!1&&i.cancelable&&i.preventDefault(),this.options.onMove?.(this.stateFrom(s,o,i))}end(e){this.dragging&&(this.dragging=!1,this.options.onRelease?.(this.stateFrom(0,0,e)))}updateVelocity(e,n){const i=ya(),s=Math.max(1,i-this.lastTime);this.lastTime=i;const o=e/s*1e3,r=n/s*1e3;this.velocityX+=(o-this.velocityX)*ga,this.velocityY+=(r-this.velocityY)*ga}stateFrom(e,n,i){return{deltaX:e,deltaY:n,velocityX:this.velocityX,velocityY:this.velocityY,totalX:this.lastX-this.startX,totalY:this.lastY-this.startY,isDragging:this.dragging,event:i}}onPointerDown=e=>{const n=e,i=this.target;if(typeof n.pointerId=="number"&&typeof i.setPointerCapture=="function")try{i.setPointerCapture(n.pointerId)}catch{}this.begin(n.clientX,n.clientY,e)};onPointerMove=e=>{const n=e;this.move(n.clientX,n.clientY,e)};onPointerUp=e=>this.end(e);onTouchStart=e=>{const n=e.touches[0];n&&this.begin(n.clientX,n.clientY,e)};onTouchMove=e=>{const n=e.touches[0];n&&this.move(n.clientX,n.clientY,e)};onTouchEnd=e=>this.end(e);onWheel=e=>{const n=e;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:e})}}function ya(){return typeof performance<"u"?performance.now():Date.now()}function ba(t,e,n){let i={delta:0,line:null},s=n;for(const o of t)for(const r of e){const a=Math.abs(r-o);a<=s&&(s=a,i={delta:r-o,line:r})}return i}function wa(t,e){return e<=0?[]:t.map(n=>Math.round(n/e)*e)}class gs{options;observer;x;y;originX=0;originY=0;snappedX=null;snappedY=null;constructor(e){this.options=e,this.x=e.initialX??0,this.y=e.initialY??0,this.observer=new ma({target:e.target,onPress:n=>{const i=e.getPosition?.();i&&(this.x=i.x,this.y=i.y),this.originX=this.x,this.originY=this.y,e.onPress?.(n)},onMove:n=>this.handleMove(n),onRelease:n=>e.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(e,n){const i=this.options.axis??"both";this.x=i==="y"?this.x:this.applyConstraints(e,"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 e=this.options.snap??0;return e>0?e/2:8}handleMove(e){this.setPosition(this.originX+e.totalX,this.originY+e.totalY),this.options.mode==="scrub"&&this.scrub(),this.options.onDrag?.(this.position,e),this.options.onSnap?.(this.snapLines)}scrub(){const e=this.options.timeline;if(!e)return;const n=e.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,o=Rf(s/i);e.pause(),e.seek(o*n)}applyConstraints(e,n){let i=e;const s=[...wa([i],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],o=ba([i],s,this.snapThreshold());i+=o.delta,n==="x"?this.snappedX=o.line:this.snappedY=o.line;const r=this.options.bounds;if(r){const a=n==="x"?r.minX:r.minY,l=n==="x"?r.maxX:r.maxY;a!==void 0&&(i=Math.max(a,i)),l!==void 0&&(i=Math.min(l,i))}return i}}function Rf(t){return t<0?0:t>1?1:t}function Lf(t){const e=new gs(t);return e.start(),e}const Ff={x:"x",y:"y","x,y":"both"},ms=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function ka(t,e){const n=Vn(t),i=e.getBoundingClientRect();return{minX:i.left-n.left,maxX:i.right-n.right,minY:i.top-n.top,maxY:i.bottom-n.bottom}}function va(t){return Array.isArray(t)?[...t]:t}function Df(t,e,n,i={}){const[s]=e.resolveTargets(n),o=s?e.elementFor(s):void 0;if(!s||!o)throw new Error(`gsap-compat: live.draggable could not find ${String(n)}`);if(i.type==="rotation")return Nf(t,e,s,o,i);const r=Ff[i.type??"x,y"],a=()=>{const d=e.appliedValue(s,"x"),m=e.appliedValue(s,"y");return{x:typeof d=="number"?d:0,y:typeof m=="number"?m:0}},l=typeof i.bounds=="string"?e.query(i.bounds):ms(i.bounds)?i.bounds:null,h={bounds:(!l&&i.bounds&&!ms(i.bounds)?i.bounds:void 0)??(l?ka(o,l):void 0)};let f=null;const u=()=>{f?.kill(),f=null},p=d=>{const m=i.inertia===!0?{}:i.inertia,y=m.friction??(m.resistance!==void 0?fs(m.resistance):4),w=a(),v=h.bounds??{};let T,S;const A=m.end;if(Array.isArray(A)){const C=Xe({from:w.x,velocity:r==="y"?0:d.x,friction:y}),E=Xe({from:w.y,velocity:r==="x"?0:d.y,friction:y});let H=A[0];for(const _ of A)Math.hypot(_.x-C,_.y-E)<Math.hypot(H.x-C,H.y-E)&&(H=_);H&&(T=[H.x],S=[H.y])}else typeof A=="number"?(T=A,S=A):A&&(T=va(A.x),S=va(A.y));const x={};r!=="y"&&(x.x={velocity:d.x,friction:y,min:v.minX,max:v.maxX,end:T}),r!=="x"&&(x.y={velocity:d.y,friction:y,min:v.minY,max:v.maxY,end:S}),f=t.to(o,{inertia:x,onComplete:()=>i.onThrowComplete?.()})},g=new gs({target:o,axis:r,snap:i.snap,get bounds(){return h.bounds},getPosition:a,onPress:()=>{u(),l&&(h.bounds=ka(o,l)),i.onPress?.()},onDrag:d=>{e.apply(s,r==="x"?{x:d.x}:r==="y"?{y:d.y}:{x:d.x,y:d.y}),i.onDrag?.(d)},onRelease:()=>{const d=g.velocity;i.onRelease?.(d),i.inertia&&p(d)}});return g.start(),{draggable:g,get position(){return a()},get rotation(){const d=e.appliedValue(s,"rotate");return typeof d=="number"?d:0},destroy(){u(),g.destroy()}}}function Nf(t,e,n,i,s){const o=typeof s.bounds=="object"&&s.bounds!==null&&!ms(s.bounds)?s.bounds:{},r=()=>{const v=e.appliedValue(n,"rotate");return typeof v=="number"?v:0},a=v=>Math.min(o.maxRotation??1/0,Math.max(o.minRotation??-1/0,v));let l=null,c=!1,h,f={x:0,y:0},u=0,p=0,g=[];const d=v=>Math.atan2(v.clientY-f.y,v.clientX-f.x)*180/Math.PI,m=v=>{if(c)return;l?.kill(),l=null,c=!0,h=v.pointerId,i.setPointerCapture?.(v.pointerId);const T=i.getBoundingClientRect();f={x:T.left+T.width/2,y:T.top+T.height/2},u=d(v),p=r(),g=[{time:performance.now(),rotation:p}],s.onPress?.()},y=v=>{if(!c||v.pointerId!==h)return;const T=d(v);let S=T-u;S>180&&(S-=360),S<-180&&(S+=360),u=T,p+=S;let A=a(p);s.snap&&(A=a(Math.round(A/s.snap)*s.snap)),e.apply(n,{rotate:A});const x=performance.now();for(g.push({time:x,rotation:A});g.length>2&&x-g[0].time>100;)g.shift();const C={x:0,y:0};s.onDrag?.(C)},w=v=>{if(!c||v.pointerId!==h)return;c=!1;const T=g[0],S=g[g.length-1],A=T&&S?(S.time-T.time)/1e3:0,x=A>0?(S.rotation-T.rotation)/A:0;if(s.onRelease?.({x,y:0}),!s.inertia)return;const C=s.inertia===!0?{}:s.inertia,E=C.friction??(C.resistance!==void 0?fs(C.resistance):4),H=typeof C.end=="number"||Array.isArray(C.end)?C.end:void 0;l=t.to(i,{inertia:{rotate:{velocity:x,friction:E,min:o.minRotation,max:o.maxRotation,end:Array.isArray(H)?H.filter(_=>typeof _=="number"):H}},onComplete:()=>s.onThrowComplete?.()})};return i.addEventListener("pointerdown",m),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 r()},destroy(){l?.kill(),i.removeEventListener("pointerdown",m),i.removeEventListener("pointermove",y),i.removeEventListener("pointerup",w),i.removeEventListener("pointercancel",w)}}}const Bf={opacity:0,scale:.6};function Wf(t){const e=t.getBoundingClientRect();return e.width===0&&e.height===0?null:{cx:e.left+e.width/2,cy:e.top+e.height/2,width:e.width,height:e.height}}function Sa(t){const e=Vn(t);return e.width===0&&e.height===0?null:{cx:e.left+e.width/2,cy:e.top+e.height/2,width:e.width,height:e.height}}function ys(t,e){const i=t.resolveTargets(e).map(r=>t.elementFor(r)).filter(r=>!!r),s=new Map,o=new Map;for(const r of i){const a=Wf(r);s.set(r,a);const l=Ma(r);a&&l!==void 0&&!o.has(l)&&o.set(l,{element:r,box:a})}return{elements:i,boxes:s,ids:o}}const bs=new WeakMap;function ws(t,e,n,i={}){const s=i.duration??.6,o=i.ease??"power2.inOut",r=i.stagger??0,a=i.scale!==!1,l=i.enter===void 0?Bf:i.enter,c=new Set(n.elements);if(i.targets!==void 0)for(const p of t.resolveTargets(i.targets)){const g=t.elementFor(p);g&&c.add(g)}const h=[...c].sort((p,g)=>p===g?0:p.compareDocumentPosition(g)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),f=e({onComplete:i.onComplete});let u=0;for(const p of h){const g=Sa(p);if(!g)continue;let d=n.boxes.get(p)??null,m;const y=Ma(p),w=!d&&y!==void 0?n.ids.get(y):void 0;w&&w.element!==p&&(d=w.box,m=w.element);const[v]=t.resolveTargets(p);bs.get(p)?.timeline.removeTracks({target:v});const T=u*r;if(!d){if(l===!1)continue;f.fromTo(p,{x:0,y:0,scaleX:1,scaleY:1,...l},{...Ta(l),x:0,y:0,scaleX:1,scaleY:1,duration:s,ease:o,delay:T},0),bs.set(p,f),u++;continue}const S=d.cx-g.cx,A=d.cy-g.cy,x=a?d.width/g.width:1,C=a?d.height/g.height:1;if(!(Math.abs(S)>.5||Math.abs(A)>.5||Math.abs(x-1)>.001||Math.abs(C-1)>.001)){const _=(P,L)=>{const F=t.appliedValue(v,P);return typeof F=="number"&&Math.abs(F-L)>1e-6};(_("x",0)||_("y",0)||_("scaleX",1)||_("scaleY",1))&&f.set(p,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const H=i.fade===!0&&m!==void 0;f.fromTo(p,{x:S,y:A,scaleX:x,scaleY:C,...H&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,...H&&{opacity:1},duration:s,ease:o,delay:T},0),H&&m&&Sa(m)&&f.fromTo(m,{opacity:1},{opacity:0,duration:s,ease:o,delay:T},0),bs.set(p,f),u++}return f}function Ma(t){return t.dataset?.flipId}function Ta(t){const e={};for(const n of Object.keys(t))e[n]=n==="opacity"||n.startsWith("scale")?1:0;return e}function Kf(t,e={}){const n=new Set((e.type??"chars,words,lines").split(",").map(d=>d.trim())),i={chars:e.charsClass??"char",words:e.wordsClass??"word",lines:e.linesClass??"line"},s=e.aria!==!1,o=t.map(d=>({element:d,html:d.innerHTML,ariaLabel:d.getAttribute("aria-label")}));let r={chars:[],words:[],lines:[],masks:[]},a,l,c=!1;const h=()=>{for(const{element:d,html:m,ariaLabel:y}of o)d.innerHTML=m,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:m}of o){const y=(m.textContent??"").replace(/\s+/g," ").trim(),w=Yf(m,i.words),v=n.has("chars")?w.flatMap(A=>jf(A,i.chars)):[],T=n.has("lines")?qf(m,w,i.lines):[];if(s){!m.hasAttribute("aria-label")&&y&&m.setAttribute("aria-label",y);for(const A of w)A.setAttribute("aria-hidden","true")}if(n.has("words"))d.words.push(...w);else for(const A of w)A.removeAttribute("class");d.chars.push(...v),d.lines.push(...T);const S=e.mask==="lines"?T:e.mask==="words"?w:e.mask==="chars"?v:[];for(const A of S)d.masks.push(Uf(A,`${i[e.mask]}-mask`))}r=d},p={elements:t,get chars(){return r.chars},get words(){return r.words},get lines(){return r.lines},get masks(){return r.masks},split(){c||(f(),h(),u(),a=e.onSplit?.(p))},revert(){c=!0,l?.disconnect(),f(),h()}};u(),a=e.onSplit?.(p),e.autoSplit&&g();function g(){const d=new Map;let m=!1;const y=()=>{if(m)return;m=!0;const v=()=>{m=!1,p.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(v):setTimeout(v,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(v=>{let T=!1;for(const S of v){const A=Math.round(S.contentRect.width),x=d.get(S.target);d.set(S.target,A),x!==void 0&&x!==A&&(T=!0)}T&&y()});for(const v of t)l.observe(v)}const w=t[0]?.ownerDocument?.fonts;w&&w.status!=="loaded"&&w.ready.then(()=>y())}return p}function Yf(t,e){const n=t.ownerDocument,i=[],s=n.createTreeWalker(t,4),o=[];for(let r=s.nextNode();r;r=s.nextNode())o.push(r);for(const r of o){const a=r.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=e,h.style.display="inline-block",h.textContent=c,l.appendChild(h),i.push(h)}r.replaceWith(l)}return i}function jf(t,e){const n=t.ownerDocument,i=Xf(t.textContent??"").map(s=>{const o=n.createElement("span");return o.className=e,o.style.display="inline-block",o.textContent=s,o});return t.replaceChildren(...i),i}function Xf(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),n=>n.segment):Array.from(t)}function qf(t,e,n){const i=t.ownerDocument,s=new Map(e.map(g=>[g,g.getBoundingClientRect()])),o=[],r=g=>{for(const d of Array.from(g.childNodes))d.nodeType===3||s.has(d)||d.tagName==="BR"?o.push(d):r(d)};r(t);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 g of o){if(g.tagName==="BR"){f=!0;continue}const d=s.get(g);if(d&&(!l||f||d.top>c+h)&&(p(),c=d.top,h=d.height/2,f=!1),!l)continue;const m=[];for(let v=g.parentNode;v&&v!==t;v=v.parentNode)m.unshift(v);let y=0;for(;y<u.length&&y<m.length&&u[y].original===m[y];)y++;u.length=y;let w=y===0?l:u[y-1].clone;for(const v of m.slice(y)){const T=v.cloneNode(!1);w.appendChild(T),u.push({original:v,clone:T}),w=T}w.appendChild(g)}return t.replaceChildren(...a),a}function Uf(t,e){const n=t.ownerDocument.createElement("span");return n.className=e,n.style.display=t.style.display==="block"?"block":"inline-block",n.style.overflow="clip",n.style.paddingBottom="0.12em",n.style.marginBottom="-0.12em",t.replaceWith(n),n.appendChild(t),n}const Ea={top:0,left:0,start:0,center:.5,centre:.5,middle:.5,bottom:1,right:1,end:1};function ks(t){const e=t.trim().toLowerCase();if(e in Ea)return Ea[e];if(e.endsWith("%")){const n=Number.parseFloat(e.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function vs(t){if(typeof t=="number")return{elementFraction:0,viewportFraction:0,offsetPx:0,absolutePx:t};let e=0;const i=t.replace(/([+-])=\s*(-?[\d.]+)/g,(r,a,l)=>(e+=(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])+e};const s=i[0]!==void 0?ks(i[0]):void 0,o=i[1]!==void 0?ks(i[1]):void 0;return{elementFraction:s??0,viewportFraction:o??0,offsetPx:e}}function _e(t,e,n){const i=vs(n),s=i.absolutePx!==void 0?t.top+i.absolutePx:t.top+t.height*i.elementFraction,o=e*i.viewportFraction;return s-o+i.offsetPx}function Vf(t,e,n,i){const s=_e(t,e,n),r=_e(t,e,i)-s;return r<=0?s<=0?1:0:Ss(-s/r)}function Ss(t){return t<0?0:t>1?1:t===0?0:t}function Aa(t,e,n,i){if(n<=0)return e;const s=1-Math.exp(-(i/1e3)/n);return t+(e-t)*s}function Ms(t,e,n,i,s){const o=h=>_e({top:t+s(h),bottom:t+s(h)+e,height:e},n,i),r=o(0),a=o(1);if(Math.sign(r)===Math.sign(a)||r===0||a===0)return r===0?0:a===0?1:Math.abs(r)<Math.abs(a)?0:1;let l=0,c=1;for(let h=0;h<40;h++){const f=(l+c)/2;Math.sign(o(f))===Math.sign(r)?l=f:c=f}return(l+c)/2}class xa{timeline;trigger;behaviour;options;observer=null;hasPlayed=!1;running=!1;constructor(e){this.timeline=e.timeline,this.trigger=e.trigger,this.behaviour=e.behaviour??"once",this.options=e}start(){if(!this.running){if(this.running=!0,typeof IntersectionObserver>"u"){this.enter();return}this.observer=new IntersectionObserver(e=>{for(const n of e)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 Gf(t){const e=new xa(t);return e.start(),e}class Pa{element;spacer;saved;axis;spacing;constructor(e,n={}){this.element=e,this.axis=n.axis??"y",this.spacing=n.spacing??!0;const i=e.ownerDocument;this.spacer=i.createElement("div"),this.spacer.className="pin-spacer",this.saved={position:e.style.position,top:e.style.top,left:e.style.left},this.axis==="x"&&(this.spacer.style.flexShrink="0"),e.replaceWith(this.spacer),this.spacer.appendChild(e)}release(){this.element.style.position=this.saved.position,this.element.style.top=this.saved.top,this.element.style.left=this.saved.left}apply(e,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=`${e}px`):(this.spacer.style.height=`${this.element.offsetHeight+i}px`,this.spacer.style.marginBottom=this.spacing?"":`-${i}px`,this.element.style.top=`${e}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 zf=.15;function $a(t){return typeof t=="object"&&!Array.isArray(t)?t:{snapTo:t}}function _a(t,e,n){const i=Gn(t+e*zf);if(typeof n=="function")return Gn(n(i));if(typeof n=="number")return n<=0?t:Gn(Math.round(i/n)*n);if(n.length===0)return t;let s=n[0];for(const o of n)Math.abs(o-i)<Math.abs(s-i)&&(s=o);return Gn(s)}function Ia(t,e,n){const i=t.duration??{min:.2,max:.8};if(typeof i=="number")return i;const s=Math.min(1,Math.abs(e)/Math.max(1,n));return i.min+(i.max-i.min)*s}class Oa{rafId=null;cancelEvents=["wheel","touchstart","pointerdown","keydown"];onInterrupt=()=>this.cancel();write;eventTarget;constructor(e,n){this.write=e,this.eventTarget=n}get active(){return this.rafId!==null}animate(e,n,i,s=qe,o){if(this.cancel(),typeof requestAnimationFrame>"u"||i<=0){this.write(n),o?.();return}for(const l of this.cancelEvents)this.eventTarget?.addEventListener(l,this.onInterrupt,{passive:!0});let r=null;const a=l=>{r??=l;const c=Math.min(1,(l-r)/(i*1e3));this.write(e+(n-e)*s(c)),c<1?this.rafId=requestAnimationFrame(a):(this.rafId=null,this.detach(),o?.())};this.rafId=requestAnimationFrame(a)}cancel(){this.rafId!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.rafId),this.rafId=null,this.detach()}detach(){for(const e of this.cancelEvents)this.eventTarget?.removeEventListener(e,this.onInterrupt)}}function Gn(t){return Math.max(0,Math.min(1,t))}class Ha{options;scroller;nodes=[];scrollerStart;scrollerEnd;start;end;constructor(e,n,i){this.options=i===!0?{}:i,this.scroller=n;const{startColor:s="#3ecf7a",endColor:o="#ff5a5a",id:r}=this.options,a=r?`${r} `:"",l=(c,h,f)=>{const u=e.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??e.body).appendChild(u),this.nodes.push(u),u};this.scrollerStart=l("scroller-start",s,!n),this.scrollerEnd=l("scroller-end",o,!n),this.start=l("start",s,!1),this.end=l("end",o,!1),n&&getComputedStyle(n).position==="static"&&(n.style.position="relative")}place(e,n){this.start.style.top=`${e.startPage}px`,this.end.style.top=`${e.endPage}px`;const i=this.scroller?n:0;this.scrollerStart.style.top=`${i+e.startViewport}px`,this.scrollerEnd.style.top=`${i+e.endViewport}px`}follow(e,n){this.scroller&&this.place(e,n)}destroy(){for(const e of this.nodes.splice(0))e.remove()}}const Jf=120,Ie=[],Oe=new Set;let Ts=!1;const Zf=()=>{Ts||Oe.size===0||(Ts=!0,queueMicrotask(()=>{Ts=!1;for(const t of Oe)t.afterRefresh()}))},Ca=()=>{for(const t of Oe)t.beforeRefresh();for(const t of Ie)t.refresh();for(const t of Oe)t.afterRefresh()};let He={width:0,height:0};const Ra=()=>{const t=window.innerWidth,e=window.innerHeight,n=t===He.width&&e!==He.height,i=Math.abs(e-He.height)<He.height*.25,s=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&i&&s||(He={width:t,height:e},Ca())};class rn{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(e){this.timeline=e.timeline,this.options=e,this.snapper=new Oa(n=>this.scrollTo(n),typeof window<"u"?window:null)}start(){if(this.running)return;this.running=!0,this.timeline?.pause();const e=this.options.pin===!0?this.options.trigger:this.options.pin||null;e&&!this.options.container&&(this.pin=new Pa(e,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new Ha(document,this.options.scroller??null,this.options.markers)),this.scrollTarget()?.addEventListener("scroll",this.onScroll,{passive:!0}),Ie.length===0&&typeof window<"u"&&(He={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",Ra,{passive:!0})),Ie.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Ie.splice(Ie.indexOf(this),1),Ie.length===0&&typeof window<"u"&&window.removeEventListener("resize",Ra),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(){Ca()}static onRefresh(e){return Oe.add(e),()=>Oe.delete(e)}get progress(){return this.targetProgress}get velocity(){return this.velocityPxPerSecond}refresh(){if(!this.running)return;this.measured&&this.options.onRefresh?.();const e=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=e+_e(n,i,an(this.options.start)??"top bottom"),this.endPx=this.resolveEnd(n,i,e),this.pin){const s=this.relativeRect(this.pin.element.getBoundingClientRect());this.pin.apply(s.top-(this.startPx-e),this.endPx-this.startPx)}this.markerGeometry=this.markers?this.markersFor(i):null}this.markers&&this.markerGeometry&&this.markers.place(this.markerGeometry,e),this.lastScroll=null,this.updateFrom(e,!this.measured),this.measured=!0,Zf()}sample(){this.refresh()}update(e){this.running&&this.updateFrom(e??this.scrollPosition(),!1)}updateFrom(e,n){this.trackVelocity(e),this.markers&&this.markerGeometry&&this.markers.follow(this.markerGeometry,e);const i=this.endPx-this.startPx,s=this.zone;this.targetProgress=i>0?Ss((e-this.startPx)/i):e>=this.startPx?1:0,this.zone=i>0?e<=this.startPx?"before":e>=this.endPx?"after":"active":e>=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 e=this.options.scrub;return typeof e=="number"?Math.max(0,e):0}resolveEnd(e,n,i){const s=an(this.options.end)??"bottom top",o=typeof s=="string"?s.trim().match(/^\+=\s*(-?[\d.]+)\s*(%|px)?$/):null;if(o){const r=Number.parseFloat(o[1]);return this.startPx+(o[2]==="%"?n*r/100:r)}return i+_e(e,n,s)}applyProgress(){const e=this.timeline?.duration??0;this.timeline&&e>0&&this.timeline.seek(this.displayProgress*e),this.emitUpdate()}emitUpdate(){if(!this.options.onUpdate)return;const e=[this.displayProgress,this.velocityPxPerSecond];this.lastEmitted&&this.lastEmitted[0]===e[0]&&this.lastEmitted[1]===e[1]||(this.lastEmitted=e,this.options.onUpdate(e[0],e[1]))}trackVelocity(e){const n=typeof performance<"u"?performance.now():Date.now();this.lastScroll!==null&&n>this.lastScrollTime&&e!==this.lastScroll&&(this.velocityPxPerSecond=(e-this.lastScroll)/(n-this.lastScrollTime)*1e3),(this.lastScroll===null||e!==this.lastScroll)&&(this.lastScroll=e,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()},Jf))}fireBoundaryCallbacks(e,n){if(e===n)return;const{onEnter:i,onLeave:s,onEnterBack:o,onLeaveBack:r}=this.options;e==="before"?(i?.(),n==="after"&&s?.()):e==="after"?(o?.(),n==="before"&&r?.()):n==="after"?s?.():r?.()}scheduleSnap(){const e=this.options.snap;if(e===void 0||this.snapper.active)return;const n=$a(e),i=()=>{this.snapTimer=null;const s=this.endPx-this.startPx,o=this.scrollPosition();if(!this.running||s<=0||o<=this.startPx||o>=this.endPx)return;const r=(o-this.startPx)/s,a=this.startPx+_a(r,this.releaseVelocity/s,n.snapTo)*s;Math.abs(a-o)<1||this.snapper.animate(o,a,Ia(n,a-o,this.viewportHeight()),n.ease)};n.delay?this.snapTimer=setTimeout(i,n.delay*1e3):i()}scrollTo(e){const n=this.options.scroller,i=this.options.horizontal?{left:e}:{top:e};n?typeof n.scrollTo=="function"?n.scrollTo({...i,behavior:"instant"}):this.options.horizontal?n.scrollLeft=e:n.scrollTop=e:typeof window<"u"&&window.scrollTo({...i,behavior:"instant"})}measureInContainer(e){const n=this.options.trigger;if(typeof n?.getBoundingClientRect!="function")return;const i=n.getBoundingClientRect(),s=this.options.scroller?.getBoundingClientRect?.().left??0,o=this.options.scroller?this.options.scroller.clientWidth:typeof window<"u"?window.innerWidth:0,r=i.left-s-e.shiftAt(e.progress()),{start:a,end:l}=e.range(),c=p=>a+p*(l-a),h=Ms(r,i.width,o,an(this.options.start)??"left right",e.shiftAt);this.startPx=c(h);const f=an(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(Ms(r,i.width,o,f,e.shiftAt)),this.markerGeometry=null}markersFor(e){const n=(o,r)=>{const a=an(o)??r;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=vs(a);return e*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 e=n=>{if(this.rafId=null,!this.running)return;const i=this.lastFrameTime===null?16.67:n-this.lastFrameTime;this.lastFrameTime=n,this.displayProgress=Aa(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(e)};this.rafId=requestAnimationFrame(e)}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 e=this.options.scroller,n=this.options.horizontal;return e?(n?e.scrollLeft:e.scrollTop)??0:typeof window<"u"?(n?window.scrollX:window.scrollY)??0:0}triggerRect(){const e=this.options.trigger;return typeof e?.getBoundingClientRect!="function"?null:this.relativeRect(e.getBoundingClientRect())}relativeRect(e){const n=this.options.horizontal,i=n?e.left??0:e.top,s=n?e.right??0:e.bottom,o=n?e.width??0:e.height,r=this.options.scroller;if(r&&typeof r.getBoundingClientRect=="function"){const a=r.getBoundingClientRect(),l=n?a.left:a.top;return{top:i-l,bottom:s-l,height:o}}return{top:i,bottom:s,height:o}}viewportHeight(){const e=this.options.scroller,n=this.options.horizontal;return e?n?e.clientWidth:e.clientHeight:typeof window<"u"?n?window.innerWidth:window.innerHeight:0}}function an(t){return typeof t=="function"?t():t}function Qf(t){const e=new rn(t);return e.start(),e}const Es=new Set,td=16,La=.5,ed=2;class As{options;frames;running=!1;reduced=!1;current=0;target=0;written=null;velocityPxPerSecond=0;frameId=null;lastTime=null;journey=null;pausedState=!1;effects=[];onWheel=e=>this.wheel(e);onScroll=()=>this.nativeScroll();onResize=()=>this.refresh();onLoad=()=>this.refresh();stopListening=null;constructor(e={}){this.options=e,this.frames=e.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 e=this.options.scroller??window;return e.addEventListener("wheel",this.onWheel,{passive:!1}),e.addEventListener("scroll",this.onScroll,{passive:!0}),window.addEventListener("resize",this.onResize,{passive:!0}),window.addEventListener("load",this.onLoad),Es.add(this),this.stopListening=rn.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const e of Es)e.refresh()}stop(){if(!this.running)return this;this.running=!1;const e=this.options.scroller??window;return e.removeEventListener("wheel",this.onWheel),e.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("load",this.onLoad),Es.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const e of this.effects)xs(e.element,e.saved);this.effects=[]}kill(){this.destroy()}get state(){const e=this.limit();return{scroll:this.current,target:this.target,progress:e>0?this.current/e:0,velocity:this.velocityPxPerSecond}}paused(e){return e!==void 0&&(this.pausedState=e,e&&(this.target=this.current,this.journey=null)),this.pausedState}scrollTo(e,n={}){if(!this.running)return;const i=this.clamp(this.resolve(e)+(n.offset??0)),s=Math.abs(i-this.current),o=this.reduced?0:n.duration??Math.min(1.2,Math.max(.4,s/2500));if(o<=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:o*1e3,ease:n.ease??qe,elapsed:0},this.requestFrame()}refresh(){if(!this.running)return;this.rest(),this.effects=[];const e=this.options.effects===!0?"[data-speed], [data-lag]":this.options.effects||"";if(e&&!this.reduced){const n=this.options.scroller??document,i=this.position(),s=this.viewportHeight(),o=this.options.scroller?.getBoundingClientRect().top??0;for(const r of n.querySelectorAll(e)){const a=Number.parseFloat(r.dataset.speed??""),l=Number.parseFloat(r.dataset.lag??""),c=r.getBoundingClientRect(),h=c.top-o+i;this.effects.push({element:r,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:r.style.getPropertyValue("translate")})}}this.current=this.target=this.clamp(this.position()),this.applyEffects(0)}rest(){for(const e of this.effects)xs(e.element,e.saved)}wheel(e){if(this.pausedState||this.reduced||(this.options.smooth??.8)<=0||e.ctrlKey||Math.abs(e.deltaX)>Math.abs(e.deltaY)||this.nestedScrollerTakes(e))return;const n=e.deltaMode===1?td:e.deltaMode===2?this.viewportHeight():1,i=e.deltaY*n*(this.options.wheelMultiplier??1),s=this.clamp(this.target+i);s===this.target&&s===this.current||(e.preventDefault(),this.journey=null,this.target=s,this.requestFrame())}nativeScroll(){const e=this.position();this.written!==null&&Math.abs(e-this.written)<=ed||(this.written=null,this.journey=null,this.cancelFrame(),this.current=this.target=e,this.requestFrame())}nestedScrollerTakes(e){const n=this.options.scroller??document.documentElement;for(let i=e.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(e.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(e=>this.frame(e)))}cancelFrame(){this.frameId!==null&&this.frames.cancel(this.frameId),this.frameId=null,this.lastTime=null}frame(e){this.frameId=null;const n=this.lastTime===null?1e3/60:Math.min(100,e-this.lastTime);this.lastTime=e;const i=this.current;if(this.journey){const o=this.journey;o.elapsed+=n;const r=Math.min(1,o.elapsed/o.ms);this.current=o.from+(o.to-o.from)*o.ease(r),r>=1&&(this.journey=null)}else if(this.current!==this.target){const o=(this.options.smooth??.8)*1e3/3;this.current+=(this.target-this.current)*(1-Math.exp(-n/o)),Math.abs(this.target-this.current)<La&&(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(e){let n=!1;const i=this.current;for(const s of this.effects){let o=0;if(s.speed!==void 0&&(o+=(i-s.centre)*(1-s.speed)),s.lag!==void 0){const r=s.lag*1e3/3;s.lagged=e===0?i:s.lagged+(i-s.lagged)*(1-Math.exp(-e/r)),Math.abs(i-s.lagged)<La?s.lagged=i:n=!0,o+=i-s.lagged}xs(s.element,o===0?s.saved:`0 ${nd(o)}px`),s.shift=o}return n}write(e){const n=Math.round(e);this.written=n;const i=this.options.scroller;i?i.scrollTop=n:window.scrollTo({top:n,behavior:"instant"})}position(){const e=this.options.scroller;return e?e.scrollTop:window.scrollY}viewportHeight(){const e=this.options.scroller;return e?e.clientHeight:window.innerHeight}limit(){const e=this.options.scroller??document.documentElement;return Math.max(0,e.scrollHeight-this.viewportHeight())}clamp(e){return Math.max(0,Math.min(this.limit(),e))}resolve(e){if(typeof e=="number")return e;const n=this.options.scroller??document,i=typeof e=="string"?n.querySelector(e):e;if(!i)return this.current;const s=this.options.scroller?.getBoundingClientRect().top??0,o=this.effects.find(r=>r.element===i)?.shift??0;return i.getBoundingClientRect().top-s+this.position()-o}}function xs(t,e){e?t.style.setProperty("translate",e):t.style.removeProperty("translate")}function nd(t){return Math.round(t*100)/100}function id(t,e){switch(e){case"play":if(t.progress()>=1)break;t.reversed()?t.reverse():t.play();break;case"reverse":if(t.progress()<=0)break;t.reversed()?t.play():t.reverse();break;case"pause":t.pause();break;case"resume":t.resume();break;case"restart":t.restart();break;case"reset":t.pause(),t.progress(0);break;case"complete":t.pause(),t.progress(1);break}}function Ps(t,e,n,i,s=()=>{}){const o=p=>typeof p=="string"?t.query(p)??void 0:p,r=o(e.trigger)??i;if(!r){s(`gsap-compat: scrollTrigger has no trigger element${typeof e.trigger=="string"?` for "${e.trigger}"`:""}`);return}const a=e.scrub===void 0||e.scrub===!1?!1:e.scrub,l=(e.toggleActions??"play none none none").trim().split(/\s+/);let c=0,h;const f=(p,g)=>()=>{g?.(),n&&!a&&id(n,l[p]??"none"),e.once&&p===0&&queueMicrotask(()=>h.destroy())},u=e.containerAnimation?rd(t,e.containerAnimation,r,s):void 0;return h=new rn({trigger:r,start:e.start,end:e.end,scrub:a===!1?void 0:a,pin:e.pin===!0?!0:o(e.pin),scroller:o(e.scroller),horizontal:e.horizontal,pinSpacing:e.pinSpacing,onRefresh:e.invalidateOnRefresh&&n?.invalidate?()=>n.invalidate():void 0,snap:e.snap===void 0?void 0:sd(e.snap,n),markers:e.markers,container:u,onUpdate:(p,g)=>{if(n&&a!==!1&&n.progress(p),e.onUpdate){const d=p<c||g<0?-1:1;e.onUpdate({progress:p,velocity:g,direction:d})}c=p},onEnter:f(0,e.onEnter),onLeave:f(1,e.onLeave),onEnterBack:f(2,e.onEnterBack),onLeaveBack:f(3,e.onLeaveBack)}),n&&a===!1&&n.progress(0),h.start(),t.own(h)}function sd(t,e){const n=s=>s==="labels"?o=>od(o,e?.labelProgresses?.()??[]):s;if(typeof t!="object"||Array.isArray(t))return n(t);const i=t.ease?nn(t.ease):void 0;return{snapTo:n(t.snapTo),duration:t.duration,delay:t.delay,ease:i?i.fn??Mt(i.easing):void 0}}function od(t,e){return e.reduce((n,i)=>Math.abs(i-t)<Math.abs(n-t)?i:n,e[0]??t)}function rd(t,e,n,i){const s=()=>e.timeline.getTracks({property:"x"}).map(o=>o.target).filter(o=>{const r=t.elementFor(o);return!!r&&r!==n&&r.contains(n)});return s().length===0&&i("gsap-compat: containerAnimation does not move an ancestor of the trigger along x"),{range:()=>{const o=e.scrollTrigger;return o||i("gsap-compat: containerAnimation needs its own scrollTrigger (created before this one)"),{start:o?.startOffset??0,end:o?.endOffset??0}},progress:()=>e.progress(),shiftAt:o=>{const r=e.timeline.getStateAtTime(o*e.timeline.duration);let a=0;for(const l of s()){const c=r.values.get(l)?.get("x");typeof c=="number"&&(a+=c)}return a}}}class Fa{conditions={};scope;host;items=[];snapshots=new Map;constructor(e,n){this.host=e,this.scope=n}add(e){const n=this.host.collector;this.host.setCollector(this);try{const i=e();return typeof i=="function"&&this.items.push({revert:i}),i}finally{this.host.setCollector(n)}}track(e){this.items.push(e)}touch(e,n){this.snapshots.has(e)||this.snapshots.set(e,{name:n,style:e.getAttribute("style"),d:e.getAttribute("d")})}revert(){for(const e of this.items.splice(0).reverse())e.revert?e.revert():e.kill?e.kill():e.destroy?.();for(const[e,{name:n,style:i,d:s}]of this.snapshots)i===null?e.removeAttribute("style"):e.setAttribute("style",i),s!==null&&e.setAttribute("d",s),this.host.forget(n);this.snapshots.clear()}kill(){this.revert()}}class ad{host;scope;entries=[];listeners=[];scheduled=!1;constructor(e,n){this.host=e,this.scope=n}add(e,n){const i={conditions:e,setup:n,queries:new Map},s=typeof e=="string"?{matches:e}:e;if(typeof window<"u"&&typeof window.matchMedia=="function")for(const[o,r]of Object.entries(s)){const a=window.matchMedia(r);i.queries.set(o,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 e of this.listeners.splice(0))e();for(const e of this.entries.splice(0))e.context?.revert()}kill(){this.revert()}scheduleUpdate(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1;for(const e of this.entries)this.update(e)}))}update(e){const n={};for(const[r,a]of e.queries)n[r]=a.matches;const i=Object.values(n).some(Boolean),s=i?JSON.stringify(n):void 0;if(s===e.key||(e.context?.revert(),e.context=void 0,e.key=s,!i))return;const o=new Fa(this.host,this.scope);o.conditions=n,o.add(()=>e.setup(o)),e.context=o}}class ld{frames;canvas;context;options;images;ready;current=0;drawn=-1;loadedCount=0;inFlight=0;destroyed=!1;onResize=()=>this.resize();constructor(e,n){this.canvas=e,this.context=e.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(e){this.current=Math.max(0,Math.min(this.frames-1,e)),this.draw()}get loaded(){return this.loadedCount}destroy(){this.destroyed=!0,typeof window<"u"&&window.removeEventListener("resize",this.onResize);for(const e of this.images)e&&(e.src="")}resize(){const e=typeof window<"u"?Math.min(window.devicePixelRatio||1,2):1,n=Math.round(this.canvas.clientWidth*e),i=Math.round(this.canvas.clientHeight*e);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 e=Math.round(this.current),n=this.nearestReady(e);if(n===-1||n===this.drawn||!this.context)return;const i=this.images[n],{width:s,height:o}=this.canvas,r=(this.options.fit??"cover")==="cover"?Math.max(s/i.naturalWidth,o/i.naturalHeight):Math.min(s/i.naturalWidth,o/i.naturalHeight),a=i.naturalWidth*r,l=i.naturalHeight*r;this.context.clearRect(0,0,s,o),this.context.drawImage(i,(s-a)/2,(o-l)/2,a,l),this.drawn=n,this.pump()}nearestReady(e){for(let n=0;n<this.frames;n++){if(e-n>=0&&this.ready[e-n])return e-n;if(e+n<this.frames&&this.ready[e+n])return e+n}return-1}pump(){const e=this.options.concurrency??6,n=Math.round(this.current);for(let i=0;i<this.frames&&this.inFlight<e;i++)for(const s of i===0?[n]:[n+i,n-i])s<0||s>=this.frames||this.images[s]||this.inFlight>=e||this.load(s)}load(e){const n=new Image;n.decoding="async",this.images[e]=n,this.inFlight++;const i=s=>{if(!this.destroyed){if(this.inFlight--,s){this.ready[e]=!0,this.loadedCount++,this.options.onProgress?.(this.loadedCount,this.frames);const o=Math.round(this.current);(Math.abs(e-o)<Math.abs(this.drawn-o)||this.drawn===-1)&&(this.drawn=-1,this.draw())}this.pump()}};n.onload=()=>i(!0),n.onerror=()=>i(!1),n.src=this.options.url(e)}}const cd={opacity:0,y:-16},hd={opacity:0,y:16};async function ud(t,e,n,i){const s=e.collector?.scope??e.root,o=s.ownerDocument??s,r=()=>i.shared?[...s.querySelectorAll(i.shared)]:[];if(i.native&&typeof o.startViewTransition=="function")return fd(o,i,r);const a=i.duration??.35,l=i.ease??"power2.inOut",c=m=>new Promise(y=>{m(y)||y()}),h=r(),f=h.length?ys(e,h):void 0,u=i.from!==void 0?Da(e,i.from,i.shared):[];if(u.length&&i.leave!==!1){const m=i.leave??cd;await c(y=>t.to(u,{...m,duration:a,ease:l,onComplete:y}))}await i.update();const p=[],g=typeof i.to=="function"?i.to():i.to,d=g!==void 0?Da(e,g,i.shared):[];if(d.length&&i.enter!==!1){const m=i.enter??hd;p.push(c(y=>t.fromTo(d,m,{...Ta(m),duration:a,ease:l,onComplete:y})))}if(f){const m=r().filter(y=>!h.includes(y));m.length&&p.push(c(y=>ws(e,n,f,{targets:m,duration:a*1.4,ease:l,enter:!1,onComplete:y})))}await Promise.all(p)}function Da(t,e,n){const i=t.resolveTargets(e).map(s=>t.elementFor(s)).filter(s=>!!s);return n?i.flatMap(s=>!s.querySelector(n)&&!s.matches(n)?[s]:[...s.children].filter(o=>!o.matches(n)&&!o.querySelector(n))):i}async function fd(t,e,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 o=[];await t.startViewTransition(async()=>{s.forEach(a=>i(a,!1)),await e.update(),o=n(),o.forEach(a=>i(a,!0))}).finished,o.forEach(a=>i(a,!1))}const Na={create:(t,e)=>ls(t,Nr(e))},Ba={create:(t,e)=>ls(t,{fn:Br(e)})},Wa={create:(t,e)=>ls(t,{fn:Wr(e)})},dd=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),Ka=.5,pd="power1.inOut";function gd(t){return t.keyframes!==void 0&&t.keyframes!==null}function md(t){const e=t.keyframes,n={};for(const[c,h]of Object.entries(t))dd.has(c)||(n[c]=h);if(Array.isArray(e))return e.map(c=>({...n,...c,duration:c.duration??t.duration??Ka}));const i=Object.entries(e),s=t.duration??Ka,o=e.easeEach??t.easeEach??pd;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 g=Math.max(0,u-f);h.push({...n,ease:o,...p,duration:g*s}),f=u}return h}const r=i.filter(([c,h])=>c!=="easeEach"&&Array.isArray(h)),a=Math.max(0,...r.map(([,c])=>c.length)),l=[];for(let c=0;c<a;c++){const h={...n,ease:o,duration:s/a};for(const[f,u]of r)c<u.length&&(h[f]=u[c]);l.push(h)}return l}function Ya(t,e,n,i={}){const s=e.collector?.scope??e.root,o=typeof i.scroller=="string"?s.querySelector(i.scroller):i.scroller??null,r={x:o?o.scrollLeft:window.scrollX,y:o?o.scrollTop:window.scrollY},a={x:o?o.scrollWidth-o.clientWidth:document.documentElement.scrollWidth-window.innerWidth,y:o?o.scrollHeight-o.clientHeight:document.documentElement.scrollHeight-window.innerHeight},l=(w,v)=>{if(v===void 0)return r[w];if(typeof v=="number")return v;if(v==="max")return a[w];const T=typeof v=="string"?s.querySelector(v):v;if(!T)return r[w];const S=T.getBoundingClientRect(),A=o?.getBoundingClientRect(),x=(w==="x"?i.offsetX:i.offsetY)??i.offset??0;return w==="x"?S.left-(A?.left??0)+r.x-x:S.top-(A?.top??0)+r.y-x},c=typeof n=="object"&&n!==null&&!("nodeType"in n)?{x:l("x",n.x),y:l("y",n.y)}:{x:r.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={...r},u=()=>{o?(o.scrollLeft=f.x,o.scrollTop=f.y):window.scrollTo({left:f.x,top:f.y,behavior:"instant"})},p=["wheel","touchstart","keydown"],g=o??window,d=()=>{y.kill(),m()},m=()=>{for(const w of p)g.removeEventListener(w,d)},y=t.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:()=>{m(),i.onComplete?.()}});if(i.autoKill!==!1)for(const w of p)g.addEventListener(w,d,{passive:!0});return y}function yd(t,e,n){const i=t.collector?.scope??t.root,s=typeof e=="string"?[...i.querySelectorAll(e)]:"nodeType"in e?[e]:Array.from(e),{interval:o=.1,batchMax:r,onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h,...f}=n,u={onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h},p={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},g={},d=y=>{g[y]!==void 0&&clearTimeout(g[y]),g[y]=void 0;const w=p[y].splice(0);w.length>0&&u[y]?.(w)},m=(y,w)=>{if(u[y]){if(p[y].push(w),r!==void 0&&p[y].length>=r)return d(y);g[y]===void 0&&(g[y]=setTimeout(()=>d(y),o*1e3))}};return s.map(y=>Ps(t,{...f,trigger:y,onEnter:()=>m("onEnter",y),onLeave:()=>m("onLeave",y),onEnterBack:()=>m("onEnterBack",y),onLeaveBack:()=>m("onLeaveBack",y)})).filter(y=>y!==void 0)}class Bt{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(e,n={}){this.stage=e;const i={...n,onWarning:n.onWarning??e.onWarning};if(this.options=i,this.compat=new he({...i,startValue:(s,o)=>{const r=e.objectFor(s);if(r)return kd(r[o]);const a=e.appliedValue(s,o);if(a!==void 0)return a;if(o==="d")return pa(e.elementFor(s))??void 0;if(o==="text")return e.elementFor(s)?.textContent??void 0;if(o==="strokeDasharray"||o==="strokeDashoffset"){const l=Va(e.elementFor(s));if(l!==void 0)return o==="strokeDasharray"?[l,l]:0}},startVelocity:(s,o)=>e.velocityOf(s,o),layoutColumns:s=>Ua(s.map(o=>e.elementFor(o))),random:()=>e.utils.random(0,1)}),this.compat.timeline.onComplete=()=>{this.finishedThisFrame=!0},e.collector?.track(this),e.liveTimelines.add(this),this.autoplayPending=!i.paused&&!i.scrollTrigger,i.scrollTrigger){const s=i.scrollTrigger;queueMicrotask(()=>{this.killed||(this.scrollDriver=Ps(e,s,this,this.firstElement,o=>i.onWarning?.(o)))})}this.autoplayPending&&queueMicrotask(()=>{this.autoplayPending&&this.play()})}get timeline(){return this.compat.timeline}get scrollTrigger(){return this.scrollDriver}to(e,n,i){return gd(n)?this.record(()=>this.keyframed(e,n,i)):this.record(()=>this.tween(e,[n],i,([s],o,r)=>this.compat.to(o,s,r)))}from(e,n,i){return this.record(()=>this.tween(e,[n],i,([s],o,r)=>this.compat.from(o,s,r)))}fromTo(e,n,i,s){return this.record(()=>this.tween(e,[n,i],s,([o,r],a,l)=>this.compat.fromTo(a,o,r,l)))}set(e,n,i){return this.record(()=>this.tween(e,[n],i,([s],o,r)=>this.compat.set(o,s,r)))}addLabel(e,n){return this.record(()=>this.compat.addLabel(e,n))}add(e,n){return this.record(()=>{e.autoplayPending=!1,e.timeline.stop(),e.stage.deactivate(e.timeline),this.compat.add(e.compat,n)})}invalidate(){const e=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(e),this.stage.render(this.timeline),this}call(e,n=[],i){return this.record(()=>{const s=this.compat.addEvent(i);this.events.push({time:s,run:()=>e(...n)})})}addPause(e,n,i=[]){return this.record(()=>{const s=this.compat.addEvent(e);this.events.push({time:s,pause:!0,run:()=>n?.(...i)})})}tweenTo(e,n={}){return this.tweenFromTo(this.timeline.currentTime/1e3,e,n)}tweenFromTo(e,n,i={}){this.pause(),this.seek(e);const s=this.timeline.currentTime,o=Math.max(0,Math.min(this.timeline.duration,this.compat.timeOf(n))),r={time:s},a=i.duration??Math.abs(o-s)/1e3/(this.timeScale()||1),l=new Bt(this.stage,{onStart:i.onStart,onComplete:i.onComplete});return l.to(r,{time:o,duration:a,ease:i.ease??"none",onUpdate:()=>{this.moveTo(r.time),i.onUpdate?.()}}),l}play(){this.autoplayPending=!1,this.started||(this.started=!0,this.options.onStart?.());const e=this.timeline.playbackState==="playing",n=this.timeline.playbackState==="paused";if(this.timeline.play(),!e){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 e=this.timeline.playbackState==="idle"&&this.timeline.direction==="forward";return this.timeline.reverse(),e&&this.timeline.currentTime===0&&this.timeline.seek(this.timeline.duration),this.play()}labelProgresses(){const e=this.timeline.duration;return e>0?this.compat.labelTimes().map(n=>n/e):[]}reversed(){return this.timeline.direction==="reverse"}seek(e){return this.autoplayPending=!1,this.compat.seek(e),this.stage.render(this.timeline),this.playhead=this.readPlayhead(),this.waitingToWrap=!1,this.options.onUpdate?.(),this}progress(e){return e===void 0?this.compat.progress():(this.autoplayPending=!1,this.moveTo(Math.max(0,Math.min(1,e))*this.timeline.duration),this.compat.progress())}timeScale(e){return this.compat.timeScale(e)}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(e,n){for(const i of e)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(e){return this.recipe.push(e),e(),this.syncDuration(),this}syncDuration(){if(this.events.length===0)return;this.timeline.setDuration(void 0);const e=Math.max(...this.events.map(n=>n.time));e>this.timeline.duration&&this.timeline.setDuration(e)}readPlayhead(){const e=this.timeline;return{time:e.currentTime,iteration:e.loopIteration,direction:e.direction}}moveTo(e){const n=this.playhead;this.timeline.seek(e),this.stage.render(this.timeline);const i={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:e>=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 e=this.timeline.currentTime;this.compat.reset(),this.events=[],this.ranges=[];for(const n of this.recipe)n();this.syncDuration(),this.timeline.seek(Math.min(e,this.timeline.duration))}afterFrame(){const e=this.timeline,n=e.repeatDelayRemaining>0;if(this.waitingToWrap&&n){this.options.onUpdate?.();return}this.waitingToWrap=!1;const i=this.playhead,s=this.readPlayhead();this.playhead=s;const o=this.options.yoyo===!0;n&&!o&&s.iteration>i.iteration&&(this.playhead={time:0,iteration:s.iteration,direction:"forward",fresh:!0},this.waitingToWrap=!0);const r=this.runCrossings(i,s,n);if(this.options.onUpdate?.(),this.finishedThisFrame&&!r){this.finishedThisFrame=!1;const a=e.currentTime===0&&e.direction==="reverse";!this.scrollDriver&&!o&&this.stage.liveTimelines.delete(this),a&&this.backwards?this.options.onReverseComplete?.():this.options.onComplete?.()}this.finishedThisFrame=!1}runCrossings(e,n,i){if(this.events.length===0&&this.ranges.length===0&&!this.options.onRepeat&&!this.options.repeatRefresh)return!1;const s=this.events,{crossings:o,passes:r}=ns(s.map(a=>a.time),e,n,{duration:this.timeline.duration,alternate:this.options.yoyo===!0,holding:i});for(const a of o){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)r.some(([c,h])=>c!==h&&Math.max(c,h)>=a.start&&Math.min(c,h)<=a.end)&&a.run();return!1}tween(e,n,i,s){const o=this.resolve(e);if(!o)return;const{onStart:r,onUpdate:a,onComplete:l}=n[n.length-1];if(r||a||l){let c=1/0,h=-1/0;const f=(u,p,g)=>{s(u,p,g),c=Math.min(c,this.compat.lastStart),h=Math.max(h,this.compat.lastEnd)};if(this.buildTween(o,n,i,f),c===1/0)return;r&&this.events.push({time:c,direction:"forward",run:r}),a&&this.ranges.push({start:c,end:h,run:a}),l&&this.events.push({time:h,direction:"forward",run:l});return}this.buildTween(o,n,i,s)}keyframed(e,n,i){const s=this.resolve(e);if(!s)return;const o=md(n);if(o.length===0)return;const r=s.length>1?us(n.stagger,this.staggerContext(s)):void 0,a=s.map(m=>this.targetFor(m)).filter(m=>m!==void 0),l=r?a.map(m=>[m]):[a],c=r?xn(s.length,r).map(m=>m/1e3):[0],h=this.compat.timeOf(i)/1e3+Un(n.delay,0)/1e3;let f=1/0,u=-1/0;if(l.forEach((m,y)=>{o.forEach((w,v)=>{const T=v===0?h+c[y]:">";this.tween(m,[w],T,([S],A,x)=>this.compat.to(A,S,x)),f=Math.min(f,this.compat.lastStart),u=Math.max(u,this.compat.lastEnd)})}),f===1/0)return;const{onStart:p,onUpdate:g,onComplete:d}=n;p&&this.events.push({time:f,direction:"forward",run:p}),g&&this.ranges.push({start:f,end:u,run:g}),d&&this.events.push({time:u,direction:"forward",run:d})}staggerContext(e){return{count:e.length,columnsFromLayout:()=>Ua(e.map(n=>this.stage.elementFor(n))),random:()=>this.stage.utils.random(0,1)}}buildTween(e,n,i,s){const o=e.map(u=>this.targetFor(u));if(!(e.length>1&&(n.some(wd)||e.some(u=>this.stage.objectFor(u)!==void 0)))){const u=this.targetFor(e[0]);s(n.map(p=>this.prepare(qa(p,0,u,this.stage.utils,o),e)),e,i);return}const a=n.length-1,{stagger:l,...c}=n[a],h=us(l,this.staggerContext(e)),f=h?xn(e.length,h).map(u=>u/1e3):e.map(()=>0);e.forEach((u,p)=>{const g=p===0?Un(c.delay,0)/1e3+f[0]:0,d=p===0?0:f[p]-f[p-1],m=p===0?i:`<${d<0?"-":"+"}${Math.abs(d).toFixed(6)}`,w=n.map((v,T)=>T===a?{...c,delay:g}:v).map(v=>this.prepare(qa(v,p,this.targetFor(u),this.stage.utils,o),[u]));s(w,[u],m)})}targetFor(e){return this.stage.elementFor(e)??this.stage.objectFor(e)}prepare(e,n){const i=r=>this.options.onWarning?.(r),s=r=>this.stage.query(r);let o=e;if(e.motionPath!==void 0){const r=If(e.motionPath,{query:s,targets:n.map(a=>this.stage.elementFor(a)).filter(a=>!!a),warn:i});o={...o,motionPath:r}}if(e.morphSVG!==void 0){const r=Of(e.morphSVG,s,i),{morphSVG:a,...l}=o;o=r?{...o,morphSVG:r}:l}if(e.drawSVG!==void 0){const r=Va(this.stage.elementFor(n[0]));if(r===void 0){i("gsap-compat: drawSVG needs an SVG shape with a stroke (path, line, circle…)");const{drawSVG:a,...l}=o;o=l}else o=sf(o,r)}return o}resolve(e){const n=this.stage.resolveTargets(e);if(n.length===0){this.options.onWarning?.(`gsap-compat: no elements found for target ${vd(e)}`);return}return this.firstElement??=n.map(i=>this.stage.elementFor(i)).find(i=>i!==void 0),n}}function ja(t=new ha){const e=o=>{const{config:r}=qn(o);return new Bt(t,{repeat:r.repeat,yoyo:r.yoyo,repeatDelay:r.repeatDelay,paused:r.paused,onStart:r.onStart,onUpdate:r.onUpdate,onComplete:r.onComplete,onRepeat:r.onRepeat,onReverseComplete:r.onReverseComplete,repeatRefresh:r.repeatRefresh,scrollTrigger:r.scrollTrigger})},n=o=>{const{onStart:r,onUpdate:a,onComplete:l,onRepeat:c,onReverseComplete:h,repeatRefresh:f,...u}=o;return u},i=o=>(o&&t.collector?.track(o),o),s={stage:t,ticker:t.ticker,utils:t.utils,getProperty:(o,r)=>{const[a]=t.resolveTargets(o);if(a===void 0)return;const l=t.objectFor(a);return l?l[r]:t.appliedValue(a,r)??oa(r)},scrollTrigger:o=>i(Ps(t,o)),scrollBatch:(o,r)=>yd(t,o,r).map(a=>i(a)),scrollTo:(o,r)=>Ya(s,t,o,r),refreshScroll:()=>{rn.refreshAll(),As.refreshAll()},smoothScroll:(o={})=>{const r=typeof o.scroller=="string"?(t.collector?.scope??t.root).querySelector(o.scroller):o.scroller;return i(new As({...o,scroller:r}).start())},context:(o,r)=>{const a=new Fa(t,r);return o&&a.add(()=>o(a)),a},matchMedia:o=>new ad(t,o),customEase:Na.create,customBounce:Ba.create,customWiggle:Wa.create,pageTransition:o=>ud(s,t,r=>new Bt(t,r),o),imageSequence:(o,r)=>{const a=typeof o=="string"?(t.collector?.scope??t.root).querySelector(o):o;if(!(a instanceof HTMLCanvasElement))throw new Error(`gsap-compat: imageSequence needs a <canvas>, got ${String(o)}`);return i(new ld(a,r))},quickTo:(o,r,a={})=>{const l=new Bt(t,{paused:!0}),[c]=t.resolveTargets(o);return Object.assign(f=>{if(!c)return;const u=a.spring!==void 0?t.velocityOf(c,r)??0:0;l.compat.reset(),l.compat.to(c,{[r]:f,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:bd(a.spring,r,u)}}),l.timeline.stop(),l.timeline.play(),t.activate(l.timeline)},{tween:l,kill:()=>l.kill()})},timeline:o=>new Bt(t,o),to:(o,r)=>{if(r.scrollTo!==void 0){const{scrollTo:a,...l}=r,c=typeof a=="object"&&a!==null&&!("nodeType"in a)?a:{},h=typeof o!="string"&&o!==window&&o.nodeType===1;return Ya(s,t,a,{...l,offsetX:c.offsetX,offsetY:c.offsetY,scroller:h?o:void 0})}return e(r).to(o,n(r))},from:(o,r)=>e(r).from(o,n(r)),fromTo:(o,r,a)=>e(a).fromTo(o,r,n(a)),set:(o,r)=>e(r).set(o,n(r)),delayedCall:(o,r,a)=>new Bt(t).call(r,a,o),killTweensOf:(o,r)=>{const a=t.resolveTargets(o),l=typeof r=="string"?r.split(",").map(c=>c.trim()).filter(Boolean):r;for(const c of[...t.liveTimelines])c.killTweensOf(a,l)},convertToPath:o=>Cf(o,t.root),splitText:(o,r)=>{const a=t.collector?.scope??t.root,l=typeof o=="string"?Array.from(a.querySelectorAll(o)):"nodeType"in o?[o]:Array.from(o);return i(Kf(l,r))},draggable:(o,r)=>i(Df(s,t,o,r)),getFlipState:o=>ys(t,o),flipFrom:(o,r)=>ws(t,a=>new Bt(t,a),o,r),flip:(o,r,a)=>{const l=ys(t,o);return r(),ws(t,c=>new Bt(t,c),l,{targets:o,...a})}};return s}const xt=ja();function bd(t,e,n){return t===!0?{velocity:{[e]:n}}:typeof t=="string"?{preset:t,velocity:{[e]:n}}:{...t,velocity:{[e]:n}}}function wd(t){return t.morphSVG!==void 0||t.drawSVG!==void 0||t.text!==void 0||t.scrambleText!==void 0||Xa(t)}function Xa(t){return Object.entries(t).some(([e,n])=>(typeof n=="function"||ia(n))&&!hs.has(e))}function qa(t,e,n,i,s){if(!Xa(t))return t;const o={};for(const[r,a]of Object.entries(t))hs.has(r)?o[r]=a:typeof a=="function"?o[r]=a(e,n,s):ia(a)?o[r]=i.resolveRandomString(a):o[r]=a;return o}function Ua(t){const e=t.map(i=>i?.getBoundingClientRect().top);if(e[0]===void 0)return t.length;let n=0;for(const i of e){if(i===void 0||Math.abs(i-e[0])>1)break;n++}return Math.max(1,n)}function Va(t){const e=t;if(typeof e?.getTotalLength=="function")return e.getTotalLength()}function kd(t){if(typeof t=="number"||typeof t=="string"||Array.isArray(t)&&t.every(e=>typeof e=="number"))return t}function vd(t){return typeof t=="string"?`"${t}"`:String(t)}class $s{media;offset;driftTolerance;constructor(e,n={}){this.media=e,this.offset=n.offset??0,this.driftTolerance=Math.max(0,n.driftTolerance??.15)}targetTime(e){return Math.max(0,e/1e3+this.offset)}update(e,n){const i=this.targetTime(e);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(e){this.media.currentTime=this.targetTime(e)}setRate(e){this.media.playbackRate=e}dispose(){this.media.paused||this.media.pause()}safePlay(){const e=this.media.play();e&&typeof e.catch=="function"&&e.catch(()=>{})}}function Ga(t,e,n,i,s){const o=n-s;if(o<0){e.paused||e.pause(),e.currentTime=0;return}t.update(o,i)}class zn{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(e,n={}){if(typeof e=="string"){const i=document.querySelector(e);if(!i)throw new Error(`Container not found: ${e}`);this.container=i}else this.container=e;this.options=n,this.adapter=new ue}async load(e){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(e)}async loadSource(e){let n;if(typeof e=="string"){const i=await fetch(e);if(!i.ok)throw new Error(`Failed to load animation: ${i.statusText}`);n=await i.json()}else n=e;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(e){const n={...e.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=xe({...e,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(e,n={}){if(e.length===0)throw new Error("tinyfly: loadScenarios needs at least one scenario");const i=new Set;for(const o of e){if(i.has(o.id))throw new Error(`tinyfly: scenario id "${o.id}" is used more than once`);i.add(o.id)}const s=n.initial===void 0?e[0]:e.find(o=>o.id===n.initial);if(!s)throw new Error(`tinyfly: there is no scenario "${n.initial}"`);this.scenarioList=[...e],this.scenarioId=s.id,await this.loadSource(s.timeline)}get scenarios(){return this.scenarioList.map(e=>({id:e.id,label:e.label??e.id}))}get scenario(){return this.scenarioId}setScenario(e){const n=this.scenarioList.find(a=>a.id===e);if(!n||!this.timeline)return!1;if(e===this.scenarioId)return!0;const i=this.isPlaying,s=this.currentTime>=this.duration-.5,o=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=e,this.useDefinition(n.timeline),this.lastMarkerId=null;let r=0;return this.reducedMotion||s?r=this.duration:o!==void 0&&(r=this.markers.find(a=>a.id===o)?.time??0),this.seek(r),i&&!this.reducedMotion?(this.stepping=this.options.stepMode===!0,this.startPlaying()):this.notify(),!0}rememberAuthored(e){if(this.authored.has(e))return;const n={style:e.getAttribute("style")};e.children.length===0&&(n.text=e.textContent??"");const i=e.tagName.toLowerCase()==="path"?e:e.querySelector("path");i&&(n.path={element:i,d:i.getAttribute("d")}),this.authored.set(e,n)}restoreAuthored(){for(const[e,n]of this.authored){n.style===null?e.removeAttribute("style"):e.setAttribute("style",n.style),n.text!==void 0&&e.textContent!==n.text&&(e.textContent=n.text),n.path&&(n.path.d===null?n.path.element.removeAttribute("d"):n.path.element.setAttribute("d",n.path.d));const i=e.dataset;i&&delete i.shineBase}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){for(const e of this.listeners)e()}get reducedMotion(){return this.reducedQuery?.matches===!0}get markers(){return this.markerList}get currentMarker(){const e=this.currentTime;let n;for(const i of this.markers)if(i.time<=e+.5)n=i;else break;return n}caption(e,n){const i=e?this.markers.find(r=>r.id===e):this.currentMarker;if(!i)return;const s=n??this.language(),o=r=>r?.[s]?.[i.id]??r?.[s.split("-")[0]]?.[i.id];return o(this.options.captions)??o(this.timeline?.captions)??i.label}next(){if(!this.timeline)return;const e=this.currentTime,n=this.markers.find(i=>i.time>e+.5);if(this.reducedMotion){this.seek(n?n.time:this.duration);return}e>=this.duration-.5||(this.stepping=n!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const e=this.currentTime,n=[...this.markers].reverse().find(i=>i.time<e-.5);this.pause(),this.seek(n?n.time:0)}goToMarker(e){const n=this.markers.find(i=>i.id===e);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 e=this.options.initialFrame??"start";if(e==="none")return;const n=e==="end"?this.timeline.duration:e==="start"?0:e;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 e=this.container.getBoundingClientRect?.();e&&(e.width>0||e.height>0)&&(this.onScreen=e.bottom>0&&e.top<window.innerHeight&&e.right>0&&e.left<window.innerWidth)}document.addEventListener("visibilitychange",this.onDocumentVisibility)}}updateVisibility(){const e=this.onScreen&&document.visibilityState!=="hidden";!e&&this.isPlaying?(this.pausedByVisibility=!0,this.pause()):e&&(this.pausedByVisibility||this.autoplayWhenSeen)&&!this.reducedMotion&&(this.pausedByVisibility=!1,this.autoplayWhenSeen=!1,this.startPlaying())}announceMarker(){if(!this.options.onMarker)return;const e=this.currentMarker,n=e?.id;n!==this.lastMarkerId&&(this.lastMarkerId=n,this.options.onMarker(e))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(n=>{const i=n,s=Number(i.getAttribute("data-tinyfly-start")??"0")||0,o=i.getAttribute("data-volume");o!==null&&(i.volume=Math.max(0,Math.min(1,Number(o)||0))),this.mediaTargets.push({el:i,startTime:s,sync:new $s(i)})})}syncAllMedia(e,n){for(const i of this.mediaTargets)Ga(i.sync,i.el,e,n,i.startTime)}loadFromString(e){const n=JSON.parse(e);this.load(n)}registerTarget(e,n){if(typeof n=="string"){const i=this.container.querySelector(n);i&&(this.rememberAuthored(i),this.targets[e]=i,this.adapter.registerTarget(e,i))}else this.rememberAuthored(n),this.targets[e]=n,this.adapter.registerTarget(e,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 e=this.options.symbols;if(!e||e.length===0)return;const n=new Map(e.map(i=>[i.id,i]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(i=>{const s=i.getAttribute("data-tinyfly-symbol");if(!s)return;const o=n.get(s);if(!o||!o.timeline.tracks?.length)return;const r=new ue;i.querySelectorAll("[data-tinyfly]").forEach(a=>{const l=a.getAttribute("data-tinyfly");l&&r.registerTarget(l,a)}),this.symbolInstances.push({adapter:r,timeline:xe(o.timeline)})})}attachMedia(e,n){this.mediaSync=new $s(e,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 e=this.timeline.playbackState==="idle";this.timeline.play(),e&&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(e){this.timeline&&(this.timeline.seek(e),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(e){this.timeline&&(this.timeline.speed=e,this.mediaSync?.setRate(e))}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 e of this.mediaTargets)e.el.paused||e.el.pause();this.mediaTargets=[],this.adapter.clearTargets();for(const e of this.symbolInstances)e.adapter.clearTargets();this.symbolInstances=[],this.authored.clear(),this.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const e=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 o=this.timeline.playbackState==="playing";this.mediaSync?.update(this.timeline.currentTime,o),this.syncAllMedia(this.timeline.currentTime,o),this.timeline.playbackState==="playing"?this.animationFrameId=requestAnimationFrame(e):(this.animationFrameId=void 0,this.notify())};this.animationFrameId=requestAnimationFrame(e)}stopAtMarker(e){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:o}=ns(s.map(r=>r.time),e,i,{duration:n.duration,alternate:n.config.alternate===!0,holding:n.repeatDelayRemaining>0});for(const r of o){if(r.kind!=="event")continue;const a=s[r.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 e=this.timeline.currentTime;this.adapter.applyState(this.timeline.getStateAtTime(e)),this.announceMarker(),this.notify();for(const n of this.symbolInstances){const i=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(i>0?e%i:e))}}}async function Sd(t,e,n={}){const i=new zn(t,{...n,autoplay:!0});return await i.load(e),i}function Md(t,e={}){return new zn(t,e)}const za={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"},Ja="tinyfly-controls-style",Td=`
|
|
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,12 @@
|
|
|
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
|
|
50
|
+
`;let Ed=0;function Ad(t){if(t.getElementById(Ja))return;const e=t.createElement("style");e.id=Ja,e.textContent=Td,t.head.appendChild(e)}function Za(t,e,n={}){const i=e.ownerDocument;Ad(i);const s={...za,...n.labels},o=n.speeds??[.5,1,2],r=()=>t.markers.length>0,a=()=>t.markers.some(K=>K.label!==void 0||t.caption(K.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=(K,V,ot,X="")=>{const tt=i.createElement("button");return tt.type="button",tt.className=`tf-ctl-btn ${X}`.trim(),tt.setAttribute("aria-label",K),tt.title=K,tt.textContent=V,tt.addEventListener("click",ot),tt},f=h(s.restart,"⟲",()=>{t.pause(),t.seek(0)}),u=h(s.prev,"|◀",()=>t.prev()),p=h(s.play,"▶",()=>t.isPlaying?t.pause():d(),"tf-ctl-primary"),g=h(s.next,"▶|",()=>t.next()),d=()=>{t.currentTime>=t.duration-.5&&t.seek(0),t.play()},m=i.createElement("input");m.type="range",m.className="tf-ctl-scrub",m.min="0",m.max="1000",m.step="1",m.setAttribute("aria-label",s.scrub),m.addEventListener("input",()=>{t.pause(),t.seek(Number(m.value)/1e3*t.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 K of o){const V=i.createElement("option");V.value=String(K),V.textContent=`${K}×`,K===1&&(V.selected=!0),w.appendChild(V)}w.addEventListener("change",()=>t.setSpeed(Number(w.value))),c.append(f,u,p,g,m,y),o.length>0&&c.append(w),l.append(c);const v=n.fullscreen?_d(e,i,s):void 0;v&&c.append(v.button);const T=i.createElement("p");T.className="tf-ctl-caption",T.setAttribute("aria-live","polite"),n.captions!==!1&&l.append(T);const S=i.createElement("div");S.className="tf-ctl-question",S.hidden=!0;const A=i.createElement("span"),x=h(s.reveal,s.reveal,()=>t.play(),"tf-ctl-primary");S.append(A,x),l.append(S);const C=xd(t,i,s.scenario,n.scenarioControl??"buttons");C&&l.append(C.element);const E=n.mount;E?E.appendChild(l):e.insertAdjacentElement("afterend",l);const H=()=>{const K=t.isPlaying;p.textContent=K?"❚❚":"▶",p.setAttribute("aria-label",K?s.pause:s.play),p.title=K?s.pause:s.play;const V=t.duration;i.activeElement!==m&&(m.value=String(V>0?Math.round(t.currentTime/V*1e3):0));const ot=t.markers;if(u.hidden=g.hidden=y.hidden=ot.length===0,ot.length>0){const X=t.currentMarker,tt=X?ot.indexOf(X)+1:0;y.textContent=s.stepFormat.replace("{index}",String(tt)).replace("{total}",String(ot.length)),y.setAttribute("aria-label",`${s.step} ${tt} ${s.of} ${ot.length}`),u.disabled=t.currentTime<=.5,g.disabled=t.currentTime>=V-.5;const J=t.caption()??"";T.textContent!==J&&(T.textContent=J),T.hidden=!a();const M=!K&&X?.question!==void 0&&Math.abs(t.currentTime-X.time)<1;S.hidden=!M,M&&A.textContent!==X.question&&(A.textContent=X.question)}else S.hidden=!0,T.hidden=!0;C?.update()},_=t.subscribe(H);H();const P=n.keyboardScope??e;!P.hasAttribute("tabindex")&&P.tabIndex<0&&(P.tabIndex=0);const L=new WeakSet,F=K=>{if(L.has(K)||(L.add(K),K.defaultPrevented||K.altKey||K.ctrlKey||K.metaKey))return;const V=K.target;if(!(V.tagName==="INPUT"||V.tagName==="SELECT")&&!(K.key===" "&&V.tagName==="BUTTON"))switch(K.key){case" ":K.preventDefault(),t.isPlaying?t.pause():d();break;case"ArrowRight":if(!r())return;K.preventDefault(),t.next();break;case"ArrowLeft":if(!r())return;K.preventDefault(),t.prev();break;case"Home":K.preventDefault(),t.pause(),t.seek(0);break;case"f":case"F":if(!v)return;K.preventDefault(),v.active?v.exit():v.enter();break}};return P.addEventListener("keydown",F),l.addEventListener("keydown",F),{element:l,fullscreen:v&&{get active(){return v.active},enter:v.enter,exit:v.exit},destroy(){v?.destroy(),_(),P.removeEventListener("keydown",F),l.removeEventListener("keydown",F),l.remove()}}}function xd(t,e,n,i){const s=t.scenarios;if(s.length<2)return;if(i==="slider"){const h=e.createElement("div");h.className="tf-ctl-choice-slider";const f=e.createElement("span");f.textContent=n,f.setAttribute("aria-hidden","true");const u=e.createElement("input");u.type="range",u.min="0",u.max=String(s.length-1),u.step="1",u.setAttribute("aria-label",n);const p=e.createElement("output");return p.setAttribute("aria-hidden","true"),u.addEventListener("input",()=>{const d=s[Number(u.value)];d&&t.setScenario(d.id)}),h.append(f,u,p),{element:h,update:()=>{const d=Math.max(0,s.findIndex(y=>y.id===t.scenario));e.activeElement!==u&&(u.value=String(d));const m=s[d].label;p.textContent!==m&&(p.textContent=m),u.setAttribute("aria-valuetext",m)}}}const o=e.createElement("fieldset");o.className="tf-ctl-choices";const r=e.createElement("legend");r.textContent=n,o.append(r);const a=`tf-ctl-scenario-${++Ed}`,l=s.map(h=>{const f=e.createElement("label");f.className="tf-ctl-choice";const u=e.createElement("input");u.type="radio",u.name=a,u.value=h.id,u.addEventListener("change",()=>{u.checked&&t.setScenario(h.id)});const p=e.createElement("span");return p.textContent=h.label,f.append(u,p),o.append(f),u});return{element:o,update:()=>{for(const h of l){const f=h.value===t.scenario;h.checked!==f&&(h.checked=f)}}}}const Pd='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',$d='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';function _d(t,e,n){const i=e,s=t,o=e.createElement("button");o.type="button",o.className="tf-ctl-btn tf-ctl-fullscreen";let r,a="";const l=()=>{const d=r!==void 0;o.innerHTML=d?$d:Pd;const m=d?n.exitFullscreen:n.fullscreen;o.setAttribute("aria-label",m),o.title=m,o.setAttribute("aria-pressed",String(d)),t.classList.toggle("tf-fullscreen",d),t.classList.toggle("tf-fullscreen-overlay",r==="overlay")},c=()=>i.fullscreenElement??i.webkitFullscreenElement??null,h=()=>{c()===t?r="native":r==="native"&&(r=void 0),l()},f=d=>{d.key==="Escape"&&g()},u=()=>{r="overlay",a=e.documentElement.style.overflow,e.documentElement.style.overflow="hidden",e.addEventListener("keydown",f),l()};async function p(){if(r)return;const d=s.requestFullscreen?.bind(s)??s.webkitRequestFullscreen?.bind(s),m=i.fullscreenEnabled??i.webkitFullscreenEnabled??!1;if(d&&m)try{if(await d(),c()===t){r="native",l();return}}catch{}u()}async function g(){if(r==="overlay")e.removeEventListener("keydown",f),e.documentElement.style.overflow=a,r=void 0,l();else if(r==="native"){r=void 0,l();const d=i.exitFullscreen?.bind(i)??i.webkitExitFullscreen?.bind(i);c()===t&&d&&await d()}}return o.addEventListener("click",()=>{r?g():p()}),e.addEventListener("fullscreenchange",h),e.addEventListener("webkitfullscreenchange",h),l(),{button:o,get active(){return r!==void 0},enter:p,exit:g,destroy(){g(),e.removeEventListener("fullscreenchange",h),e.removeEventListener("webkitfullscreenchange",h),o.remove()}}}const Qa="tinyfly-choices-style",Id=`
|
|
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 rf(e){if(e.getElementById(Vo))return;const t=e.createElement("style");t.id=Vo,t.textContent=sf,e.head.appendChild(t)}function Uo(e,t){const n=Array.from(t.querySelectorAll("[data-tinyfly-choose]"));if(n.length===0)return()=>{};rf(t.ownerDocument);const i=[],s=[];for(const a of n){const l=a.getAttribute("data-tinyfly-choose")??"",c=[],h=(m,p)=>{a.hasAttribute(m)||(a.setAttribute(m,p),c.push(m))};h("role","button"),h("tabindex","0");const u=e.scenarios.find(m=>m.id===l)?.label;u!==void 0&&h("aria-label",u),a.setAttribute("aria-pressed","false"),c.push("aria-pressed"),i.push({element:a,attributes:c});const f=()=>e.setScenario(l),d=m=>{const p=m.key;p!=="Enter"&&p!==" "||(m.preventDefault(),f())};a.addEventListener("click",f),a.addEventListener("keydown",d),s.push(()=>{a.removeEventListener("click",f),a.removeEventListener("keydown",d)})}const r=()=>{for(const{element:a}of i)a.setAttribute("aria-pressed",String(a.getAttribute("data-tinyfly-choose")===e.scenario))},o=e.subscribe(r);return r(),()=>{o();for(const a of s)a();for(const{element:a,attributes:l}of i)for(const c of l)a.removeAttribute(c)}}const mn=new WeakMap,Yi=new WeakMap;let of=0;function He(e,t,n){if(e)try{return JSON.parse(e)}catch(i){console.warn(`tinyfly: invalid ${t} JSON on`,n,i);return}}async function zo(e,t={}){const n=mn.get(e);if(n)return n;const i=Array.from(e.querySelectorAll("script[data-tinyfly-timeline]")),s=i[0],r=e.getAttribute("data-src"),o=lf(e.getAttribute("data-markers")),a=i.length>1||s?.hasAttribute("data-scenario")?af(i,o,e):void 0;if(a&&a.length===0)return;let l=s&&!a?He(s.textContent,"timeline",e):void 0;if(!l&&r&&o){const d=await fetch(r);d.ok&&(l=await d.json())}if(l&&o&&(l=Go(l,o)),!l&&!r&&!a){console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)',e);return}const c=He(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),h={playWhenVisible:!0,...t.player,...c&&{captions:c},...He(e.getAttribute("data-options"),"data-options",e)};hf(e);const u=new pn(e,h),f={element:e,player:u};if(mn.set(e,f),e.setAttribute("data-tinyfly-mounted",""),a){const d=e.getAttribute("data-scenario")??void 0;await u.loadScenarios(a,{initial:a.some(m=>m.id===d)?d:void 0}),Yi.set(e,Uo(u,e))}else await u.load(l??r);if(e.getAttribute("data-controls")!=="false"){const d=He(e.getAttribute("data-labels"),"data-labels",e),m=e.querySelector("figcaption"),p=e.getAttribute("data-scenario-legend"),g=e.getAttribute("data-scenario-control");f.controls=qo(u,e,{...t.controls,...e.getAttribute("data-fullscreen")==="true"?{fullscreen:!0}:{},...g==="slider"||g==="buttons"?{scenarioControl:g}:{},labels:{...t.controls?.labels,...d,...p?{scenario:p}:{}},mount:void 0}),m?e.insertBefore(f.controls.element,m):e.appendChild(f.controls.element)}return f}function af(e,t,n){const i=[];return e.forEach((s,r)=>{const o=He(s.textContent,"timeline",n);if(!o)return;const a=s.getAttribute("data-scenario")||`scenario-${r+1}`;if(i.some(c=>c.id===a)){console.warn(`tinyfly: scenario id "${a}" is used more than once; the later one is skipped`,n);return}const l=s.getAttribute("data-scenario-label")??void 0;i.push({id:a,label:l,timeline:t?Go(o,t):o})}),i}function Go(e,t){return e.config.markers?.length?e:{...e,config:{...e.config,markers:t.map((n,i)=>({id:`step-${i+1}`,time:n}))}}}function lf(e){if(!e)return;const t=e.split(/[\s,]+/).filter(Boolean).map(Number).filter(n=>Number.isFinite(n)&&n>=0).sort((n,i)=>n-i);return t.length>0?t:void 0}async function jo(e=document,t={}){const n=Array.from(e.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(n.map(s=>zo(s,t)))).filter(s=>s!==void 0)}function cf(e){const t=mn.get(e);t&&(Yi.get(e)?.(),Yi.delete(e),t.controls?.destroy(),t.player.destroy(),mn.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function hf(e){const t=e.querySelector("svg");if(!t||t.hasAttribute("role")||t.hasAttribute("aria-hidden"))return;const n=e.getAttribute("data-alt"),i=e.querySelector("figcaption");t.setAttribute("role","img"),n?t.setAttribute("aria-label",n):i&&(i.id||=`tinyfly-caption-${++of}`,t.setAttribute("aria-labelledby",i.id))}function uf(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const t=()=>{jo()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}class Jo{container;containerA;containerB;adapterA;adapterB;timelineA=null;timelineB=null;symbolDefs=new Map;nestedByAdapter=new Map;sequence=null;options;_currentSceneIndex=0;_state="idle";_isPlaying=!1;_isDestroyed=!1;loopIteration=0;animationFrameId;lastTime;transitionTimer;constructor(t,n={}){if(typeof t=="string"){const i=document.querySelector(t);if(!i)throw new Error(`Container not found: ${t}`);this.container=i}else this.container=t;this.options=n,this.container.style.position="relative",this.container.style.overflow="hidden",this.containerA=this.createSceneContainer(),this.containerB=this.createSceneContainer(),this.container.appendChild(this.containerA),this.container.appendChild(this.containerB),this.containerB.style.visibility="hidden",this.adapterA=new Ct,this.adapterB=new Ct}async load(t){let n;if(typeof t=="string"){const i=await fetch(t);if(!i.ok)throw new Error(`Failed to load sequence: ${i.statusText}`);n=await i.json()}else n=t;this.sequence=n,this.symbolDefs.clear();for(const i of n.symbols??[])i.timeline?.tracks?.length&&this.symbolDefs.set(i.id,i.timeline);this.container.style.width=`${n.canvas.width}px`,this.container.style.height=`${n.canvas.height}px`,n.scenes.length>0&&(this.renderScene(n.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(n.scenes[0])),this.options.autoplay&&this.play()}play(){if(!(!this.sequence||this._isDestroyed)&&this.sequence.scenes.length!==0){if(this._isPlaying=!0,this._state==="idle"){if(this._state="playing-scene",this._currentSceneIndex=0,this.timelineA)this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play();else{this.onSceneComplete();return}this.options.onSceneChange?.(0)}else this._state==="playing-scene"&&this.timelineA&&this.timelineA.play();this.startAnimationLoop()}}pause(){this._isPlaying&&(this._isPlaying=!1,this.timelineA&&this.timelineA.pause(),this.timelineB&&this.timelineB.pause(),this.stopAnimationLoop())}stop(){if(this._isPlaying=!1,this._state="idle",this._currentSceneIndex=0,this.loopIteration=0,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.stopAnimationLoop(),this.sequence&&this.sequence.scenes.length>0&&(this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this.renderScene(this.sequence.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(this.sequence.scenes[0]),this.timelineA)){const t=this.timelineA.getStateAtTime(0);this.adapterA.applyState(t),this.applyNested(this.adapterA,0)}}goToScene(t){if(!this.sequence||t<0||t>=this.sequence.scenes.length)return;const n=this._isPlaying;this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this._currentSceneIndex=t,this._state=n?"playing-scene":"idle",this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB);const i=this.sequence.scenes[t];if(this.renderScene(i,this.containerA,this.adapterA),this.timelineA=this.createTimeline(i),this.options.onSceneChange?.(t),n)this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play(),this.startAnimationLoop()):this.onSceneComplete();else if(this.timelineA){const s=this.timelineA.getStateAtTime(0);this.adapterA.applyState(s),this.applyNested(this.adapterA,0)}}destroy(){this._isDestroyed=!0,this._isPlaying=!1,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.adapterA.clearTargets(),this.adapterB.clearTargets();for(const t of this.nestedByAdapter.values())for(const n of t)n.adapter.clearTargets();this.nestedByAdapter.clear(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.timelineA=null,this.timelineB=null,this.containerA.parentNode&&this.containerA.remove(),this.containerB.parentNode&&this.containerB.remove(),this.sequence=null}get currentSceneIndex(){return this._currentSceneIndex}get sceneCount(){return this.sequence?.scenes.length??0}get isPlaying(){return this._isPlaying}get state(){return this._state}createSceneContainer(){const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t}renderScene(t,n,i){n.innerHTML="",i.clearTargets();const s=document.createElement("div");s.style.cssText="position:absolute;inset:0;transform-origin:center center",s.setAttribute("data-tinyfly","Camera"),n.appendChild(s),i.registerTarget("Camera",s);for(const r of t.elements){if(!r.html)continue;const o=document.createElement("div");o.innerHTML=r.html.trim();const a=o.firstElementChild;if(a){s.appendChild(a);const l=a.getAttribute("data-tinyfly");l&&i.registerTarget(l,a)}}this.setupNested(s,i)}setupNested(t,n){const i=[];t.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const r=s.getAttribute("data-tinyfly-symbol");if(!r)return;const o=this.symbolDefs.get(r);if(!o)return;const a=new Ct;s.querySelectorAll("[data-tinyfly]").forEach(l=>{const c=l.getAttribute("data-tinyfly");c&&a.registerTarget(c,l)}),i.push({adapter:a,timeline:zt(o)})}),i.length?this.nestedByAdapter.set(n,i):this.nestedByAdapter.delete(n)}applyNested(t,n){const i=this.nestedByAdapter.get(t);if(i)for(const s of i){const r=s.timeline.duration;s.adapter.applyState(s.timeline.getStateAtTime(r>0?n%r:n))}}clearContainer(t){t.innerHTML=""}createTimeline(t){return t.timeline?zt(t.timeline):null}onSceneComplete(){if(this._isDestroyed||!this.sequence)return;const t=this._currentSceneIndex+1;if(t>=this.sequence.scenes.length){const n=this.options.loop??this.sequence.loop??0;n===-1||n>0&&this.loopIteration<n-1?(this.loopIteration++,this.beginTransitionTo(0)):(this._isPlaying=!1,this._state="idle",this.stopAnimationLoop(),this.options.onComplete?.())}else this.beginTransitionTo(t)}beginTransitionTo(t){if(!this.sequence||this._isDestroyed)return;const n=this.sequence.scenes[t],i=n.transition;if(i.type==="none"||i.duration<=0){this.switchToScene(t);return}this._state="transitioning",this.containerB.style.visibility="visible",this.renderScene(n,this.containerB,this.adapterB),this.timelineB=this.createTimeline(n),this.timelineB&&this.timelineB.play(),this.applyTransition(i.type,i.duration),this.transitionTimer=window.setTimeout(()=>{this.finishTransition(t)},i.duration)}applyTransition(t,n){const i=`${n}ms`,s="ease-in-out";switch(this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),t){case"fade":this.containerB.style.opacity="0";break;case"slide-left":this.containerB.style.transform="translateX(100%)";break;case"slide-right":this.containerB.style.transform="translateX(-100%)";break;case"slide-up":this.containerB.style.transform="translateY(100%)";break;case"slide-down":this.containerB.style.transform="translateY(-100%)";break}switch(this.containerB.offsetHeight,this.containerA.style.transition=`opacity ${i} ${s}, transform ${i} ${s}`,this.containerB.style.transition=`opacity ${i} ${s}, transform ${i} ${s}`,t){case"fade":this.containerA.style.opacity="0",this.containerB.style.opacity="1";break;case"slide-left":this.containerA.style.transform="translateX(-100%)",this.containerB.style.transform="translateX(0)";break;case"slide-right":this.containerA.style.transform="translateX(100%)",this.containerB.style.transform="translateX(0)";break;case"slide-up":this.containerA.style.transform="translateY(-100%)",this.containerB.style.transform="translateY(0)";break;case"slide-down":this.containerA.style.transform="translateY(100%)",this.containerB.style.transform="translateY(0)";break}}resetTransitionStyles(t){t.style.transition="",t.style.opacity="1",t.style.transform=""}finishTransition(t){this.transitionTimer=void 0,this.timelineA&&(this.timelineA.stop(),this.timelineA=null),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const n=this.containerA;this.containerA=this.containerB,this.containerB=n;const i=this.adapterA;this.adapterA=this.adapterB,this.adapterB=i,this.timelineA=this.timelineB,this.timelineB=null,this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.playbackState!=="playing"&&this.timelineA.play()):this.onSceneComplete()}switchToScene(t){if(!this.sequence||this._isDestroyed)return;this.timelineA&&this.timelineA.stop(),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const n=this.sequence.scenes[t];this.renderScene(n,this.containerA,this.adapterA),this.timelineA=this.createTimeline(n),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play()):this.onSceneComplete()}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this._isDestroyed||!this._isPlaying)return;const i=n-(this.lastTime??n);if(this.lastTime=n,this.timelineA&&this.timelineA.playbackState==="playing"){this.timelineA.tick(i);const s=this.timelineA.getStateAtTime(this.timelineA.currentTime);this.adapterA.applyState(s),this.applyNested(this.adapterA,this.timelineA.currentTime)}if(this._state==="transitioning"&&this.timelineB&&this.timelineB.playbackState==="playing"){this.timelineB.tick(i);const s=this.timelineB.getStateAtTime(this.timelineB.currentTime);this.adapterB.applyState(s),this.applyNested(this.adapterB,this.timelineB.currentTime)}this._isPlaying?this.animationFrameId=requestAnimationFrame(t):this.animationFrameId=void 0};this.animationFrameId=requestAnimationFrame(t)}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}}async function ff(e,t,n={}){const i=new Jo(e,{...n,autoplay:!0});return await i.load(t),i}const df={type:"none",duration:0};function Zo(e){let t=0;for(let n=1;n<e.length;n++)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function ee(e,t){const n=Math.min(1,Math.max(0,t));if(e.length<2||n===1)return e.slice();if(n===0)return e.slice(0,1);let i=Zo(e)*n;const s=[e[0]];for(let r=1;r<e.length;r++){const o=e[r-1],a=e[r],l=Math.hypot(a.x-o.x,a.y-o.y);if(l>=i){const c=l===0?0:i/l;return s.push({x:o.x+(a.x-o.x)*c,y:o.y+(a.y-o.y)*c}),s}s.push(a),i-=l}return s}function gn(e,t){const n=ee(e,t);return n[n.length-1]}function Xi(e,t){return t>0?Math.floor(Math.max(0,e)*t/1e3):0}function yn(e,t,n){const i=t.roughness??2,s=Math.max(1,Math.round(t.passes??2)),r=Xi(n,t.boil??8);let o=0;const a=()=>{const f=o++;return d=>Se(Gt(`${t.seed??1}:${r}:${f}:${d}`))},l=(f,d)=>(f.next()*2-1)*d,c=f=>{const d=a(),m=e.lineWidth,p=e.globalAlpha;for(let g=0;g<s;g++)e.lineWidth=g===0?m:m*.55,e.globalAlpha=g===0?p:p*.6,f(d(g));e.lineWidth=m,e.globalAlpha=p},h=(f,d=1)=>{if(f.length<2)return;const m=f.slice(1).map((g,y)=>Math.hypot(g.x-f[y].x,g.y-f[y].y)),p=m.reduce((g,y)=>g+y,0)*Math.min(1,Math.max(0,d));c(g=>{const y=[],w=[];if(f.forEach((M,S)=>{y.push({x:M.x+l(g,i*.5),y:M.y+l(g,i*.5)}),S>0&&w.push([g.next()*2-1,g.next()*2-1])}),p<=0)return;e.beginPath(),e.moveTo(y[0].x,y[0].y);let k=0;for(let M=1;M<y.length;M++){const S=pf(y[M-1],y[M],i,w[M-1]),A=m[M-1];if(k+A<=p){e.bezierCurveTo(S[1].x,S[1].y,S[2].x,S[2].y,S[3].x,S[3].y),k+=A;continue}const E=mf(S,A===0?1:(p-k)/A);e.bezierCurveTo(E[1].x,E[1].y,E[2].x,E[2].y,E[3].x,E[3].y);break}e.stroke()})},u=(f,d,m,p,g=1)=>{c(y=>{const k=y.next()*Math.PI*2,M=Math.PI*2+.15+y.next()*.3,S=[];for(let E=0;E<=14;E++){const T=k+M*E/14,v=l(y,i*.6);S.push({x:f+Math.cos(T)*(m+v),y:d+Math.sin(T)*(p+v)})}const A=ee(S,g);A.length<2||(Qo(e,A),e.stroke())})};return{line:h,curve(f,d=1){if(f.length<2)return;const m=f[0],p=f[f.length-1],g=Math.hypot(p.x-m.x,p.y-m.y)||1,y=-(p.y-m.y)/g,w=(p.x-m.x)/g;c(k=>{const M={x:l(k,i*.5),y:l(k,i*.5)},S={x:l(k,i*.5),y:l(k,i*.5)},A=l(k,i*Math.min(1.5,Math.max(.3,g/80))),E=f.map((v,_)=>{const P=_/(f.length-1),x=Math.sin(Math.PI*P)*A;return{x:v.x+M.x+(S.x-M.x)*P+y*x,y:v.y+M.y+(S.y-M.y)*P+w*x}}),T=ee(E,d);T.length<2||(Qo(e,T),e.stroke())})},circle(f,d,m,p=1){u(f,d,m,m,p)},ellipse:u,nudge(f=.5){const d=a()(0);return{x:l(d,i*f),y:l(d,i*f)}}}}function pf(e,t,n,i){const s=t.x-e.x,r=t.y-e.y,o=Math.hypot(s,r)||1,a=n*Math.min(1.5,Math.max(.3,o/80)),l=-r/o,c=s/o;return[e,{x:e.x+s/3+l*i[0]*a,y:e.y+r/3+c*i[0]*a},{x:e.x+2*s/3+l*i[1]*a,y:e.y+2*r/3+c*i[1]*a},t]}function mf([e,t,n,i],s){const r=(u,f)=>({x:u.x+(f.x-u.x)*s,y:u.y+(f.y-u.y)*s}),o=r(e,t),a=r(t,n),l=r(n,i),c=r(o,a),h=r(a,l);return[e,o,c,r(c,h)]}function Qo(e,t){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length-1;i++){const s={x:(t[i].x+t[i+1].x)/2,y:(t[i].y+t[i+1].y)/2};e.quadraticCurveTo(t[i].x,t[i].y,s.x,s.y)}const n=t[t.length-1];e.lineTo(n.x,n.y)}function $e(e,t,n){const i=e.length;if(i<2)return[];const s=[],r=[],o=a=>t+(n-t)*a/(i-1);return e.forEach((a,l)=>{const c=e[Math.max(0,l-1)],h=e[Math.min(i-1,l+1)],u=Math.hypot(h.x-c.x,h.y-c.y)||1,f=o(l)/2,d=-(h.y-c.y)/u*f,m=(h.x-c.x)/u*f;s.push({x:a.x+d,y:a.y+m}),r.push({x:a.x-d,y:a.y-m})}),[...s,...r.reverse()]}function bn(e,t,n,i){const s=t.length;if(s<2)return;const r=$e(t,n,i),o=a=>n+(i-n)*a/(s-1);e.beginPath(),e.moveTo(r[0].x,r[0].y);for(const a of r.slice(1))e.lineTo(a.x,a.y);e.closePath(),e.fill(),t.forEach((a,l)=>{l!==0&&l!==s-1&&s>3||(e.beginPath(),e.arc(a.x,a.y,o(l)/2,0,Math.PI*2),e.fill())})}function Ht(e,t,n,i,s=16){const r={x:2*t.x-(e.x+n.x)/2,y:2*t.y-(e.y+n.y)/2},o=[];for(let a=0;a<=s;a++){const l=a/s,c=l<.5?{x:e.x+(t.x-e.x)*2*l,y:e.y+(t.y-e.y)*2*l}:{x:t.x+(n.x-t.x)*(2*l-1),y:t.y+(n.y-t.y)*(2*l-1)},h=1-l,u={x:h*h*e.x+2*h*l*r.x+l*l*n.x,y:h*h*e.y+2*h*l*r.y+l*l*n.y};o.push({x:c.x+(u.x-c.x)*i,y:c.y+(u.y-c.y)*i})}return o}function qi(e,t,n,i,s,r=0,o=1,a=40){const l=Math.cos(s),c=Math.sin(s);return Array.from({length:a+1},(h,u)=>{const f=r+Math.PI*2*o*u/a,d=Math.cos(f)*n,m=Math.sin(f)*i;return{x:e+d*l-m*c,y:t+d*c+m*l}})}function Vi(e,t){return t.look==="pencil"?wf(e,t):gf(e,t.ink,t.look)}function wn(e,t,n=!1){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t.slice(1))e.lineTo(i.x,i.y);n&&e.closePath()}function gf(e,t,n){const i=n==="silhouette",s=i?1.25:1;return{look:n,ink:t,limb(r,o,a){e.fillStyle=t,bn(e,r,o*s,a*s)},line(r,o){r.length<2||(e.strokeStyle=t,e.lineWidth=o*s,e.lineCap="round",e.lineJoin="round",wn(e,r),e.stroke())},shape(r,o,a){wn(e,r,!0),(o!==null||i)&&(e.fillStyle=i?t:o,e.fill()),!(a<=0)&&(e.strokeStyle=t,e.lineWidth=a*s,e.lineJoin="round",e.stroke())},ellipse(r,o,a,l,c,h,u){e.beginPath(),e.ellipse(r,o,a,l,c,0,Math.PI*2),(h!==null||i)&&(e.fillStyle=i?t:h,e.fill()),!(u<=0)&&(e.strokeStyle=t,e.lineWidth=u*s,e.stroke())},dot(r,o,a){e.fillStyle=t,e.beginPath(),e.arc(r,o,a*s,0,Math.PI*2),e.fill()},guide(){},guideEllipse(){}}}function yf(e,t){const n=[e[0]];let i=0;for(let o=1;o<e.length;o++){const a=e[o-1],l=e[o],c=Math.hypot(l.x-a.x,l.y-a.y);let h=t-i;for(;h<c;){const u=h/c;n.push({x:a.x+(l.x-a.x)*u,y:a.y+(l.y-a.y)*u}),h+=t}i=c-(h-t)}const s=e[e.length-1],r=n[n.length-1];return Math.hypot(s.x-r.x,s.y-r.y)>t*.25?n.push(s):n[n.length-1]=s,n}function bf(e,t){const n=e.length;return e.map((i,s)=>{const r=e[Math.max(0,s-1)],o=e[Math.min(n-1,s+1)],a=Math.hypot(o.x-r.x,o.y-r.y)||1,l=t(n===1?0:s/(n-1));return{x:i.x-(o.y-r.y)/a*l,y:i.y+(o.x-r.x)/a*l}})}function ta(e){const t=[.6,1.4,2.9].map(i=>({frequency:i*(.8+e.next()*.4),phase:e.next()*Math.PI*2,amount:.5+e.next()*.5})),n=t.reduce((i,s)=>i+s.amount,0);return i=>t.reduce((s,r)=>s+r.amount*Math.sin(Math.PI*2*r.frequency*i+r.phase),0)/n}function wf(e,t){const n=t.pencil??{},i=t.ink,s=n.roughness??Math.max(1,t.lineWidth*.12),r=Math.max(1,Math.round(n.passes??2)),o=Math.min(1,Math.max(0,n.pressure??.25)),a=Math.min(1,Math.max(0,n.rubbedOut??.15)),l=Xi(t.time,n.boil??8);let c=0;const h=(m,p,g=!1)=>Se(Gt(`${t.seed}:${g?"paper":l}:${m}:${p}`)),u=(m,p,g,y,w,k=0)=>{if(m.length<2)return;const M=m.slice(1).reduce((P,x,I)=>P+Math.hypot(x.x-m[I].x,x.y-m[I].y),0);let S=yf(m,Math.max(1.5,Math.min(t.lineWidth*.8,M/24)));if(k>0&&S.length>=2){const[P,x]=[S[S.length-2],S[S.length-1]],I=Math.hypot(x.x-P.x,x.y-P.y)||1;S=[...S,{x:x.x+(x.x-P.x)/I*k,y:x.y+(x.y-P.y)/I*k}]}const A=ta(g),E=ta(g),T=S.length,v=[],_=[];S.forEach((P,x)=>{const I=T===1?0:x/(T-1),C=S[Math.max(0,x-1)],H=S[Math.min(T-1,x+1)],R=Math.hypot(H.x-C.x,H.y-C.y)||1,B=-(H.y-C.y)/R,$=(H.x-C.x)/R,L=A(I)*w,O=Math.min(1,I/.08,(1-I)/.08),D=(.55+.45*Math.sqrt(Math.max(0,O)))*(1+o*E(I)),N=Math.max(.3,p(I)*D/2),K=P.x+B*L,Q=P.y+$*L;v.push({x:K+B*N,y:Q+$*N}),_.push({x:K-B*N,y:Q-$*N})}),e.save(),e.globalAlpha*=y,e.fillStyle=i,wn(e,[...v,..._.reverse()],!0),e.fill(),e.restore()},f=(m,p)=>{const g=c++,y=h(g,99,!0);if(y.next()<a){const S=(y.next()*2-1)*t.lineWidth*1.4,A=(y.next()*2-1)*t.lineWidth*1.4,E=m.map(T=>({x:T.x+S,y:T.y+A}));u(E,T=>p(T)*1.8,h(g,98,!0),.035,s),u(E,T=>p(T)*.45,h(g,97,!0),.12,s*1.5)}const w=m.slice(1).reduce((S,A,E)=>S+Math.hypot(A.x-m[E].x,A.y-m[E].y),0),k=p(.5)>4&&w>p(.5)*6,M=k?[-.3,.3,0]:[0];for(let S=0;S<r;S++){const A=S===0;M.forEach((E,T)=>{const v=h(g,S*10+T),_=E===0?m:bf(m,x=>p(x)*E*Math.sqrt(Math.sin(Math.PI*x))),P=!A&&E===0?t.lineWidth*(.3+v.next()*.8):0;u(_,x=>p(x)*(k?.5:1)*(A?1:.6),v,A?.85:.45,s*(A?.6:1),P)})}},d=(m,p,g,y,w,k)=>{const S=h(c,50).next()*Math.PI*2;f(qi(m,p,g,y,w,S,1.08,48),()=>k)};return{look:"pencil",ink:i,limb(m,p,g){f(m,y=>p+(g-p)*y)},line(m,p){f(m,()=>p)},shape(m,p,g){p!==null&&(e.save(),e.globalAlpha*=.88,e.fillStyle=p,wn(e,m,!0),e.fill(),e.restore()),g>0&&f([...m,m[0]],()=>g)},ellipse(m,p,g,y,w,k,M){k!==null&&(e.save(),e.globalAlpha*=.9,e.fillStyle=k,e.beginPath(),e.ellipse(m,p,g,y,w,0,Math.PI*2),e.fill(),e.restore()),d(m,p,g,y,w,M)},dot(m,p,g){e.save(),e.globalAlpha*=.9,e.fillStyle=i,e.beginPath(),e.arc(m,p,g,0,Math.PI*2),e.fill(),e.restore()},guide(m){if(n.construction===!1||m.length<2)return;const p=c++;u(m,()=>Math.max(.6,t.lineWidth*.18),h(p,0),.28,s*1.2,t.lineWidth)},guideEllipse(m,p,g,y,w){if(n.construction===!1)return;const k=c++,M=h(k,0),S=qi(m,p,g,y,w,M.next()*Math.PI*2,1.12,48);u(S,()=>Math.max(.6,t.lineWidth*.18),M,.28,s*1.5)}}}const ea=["thumb","index","middle","ring","pinky"],Y={"thumb.curl":.15,"thumb.across":.15,"index.curl":.12,"middle.curl":.16,"ring.curl":.2,"pinky.curl":.25,spread:.25,turn:0,bend:0,tilt:0,roll:0};function X(e={}){return{...Y,...e}}const et=(e,t,n,i,s)=>({"thumb.curl":e,"index.curl":t,"middle.curl":n,"ring.curl":i,"pinky.curl":s}),U={relaxed:Y,open:X({...et(0,0,0,0,0),"thumb.across":0,spread:.55}),spread:X({...et(0,0,0,0,0),"thumb.across":0,spread:1}),flat:X({...et(0,0,0,0,0),"thumb.across":.35,spread:0}),fist:X({...et(.7,1,1,1,1),"thumb.across":.9,spread:0}),point:X({...et(.75,0,1,1,1),"thumb.across":.9,spread:0}),thumbsUp:X({...et(0,1,1,1,1),"thumb.across":0,spread:0,roll:70}),peace:X({...et(.75,0,0,1,1),"thumb.across":.9,spread:1}),ok:X({...et(.12,.6,.1,.15,.2),"thumb.across":.55,spread:.6}),pinch:X({...et(.1,.65,.75,.85,.9),"thumb.across":.55,spread:0}),cupped:X({...et(.25,.4,.4,.4,.4),"thumb.across":.4,spread:.05,turn:2}),wave:X({...et(0,.05,.05,.1,.12),"thumb.across":0,spread:.7,turn:2}),pencilGrip:X({...et(.1,.6,.72,.88,.95),"thumb.across":.5,spread:0,turn:.8,bend:10}),hold:X({...et(.5,.7,.72,.74,.76),"thumb.across":.75,spread:0,turn:1})};function ne(e,t,n){const i={...e};for(const[s,r]of Object.entries(t)){const o=e[s]??r;i[s]=o+(r-o)*n}return i}const kf={index:{knuckle:[-.16,.47,-.02],bones:[.2,.125,.1],width:.125,fan:-1},middle:{knuckle:[-.055,.49,-.02],bones:[.22,.135,.1],width:.13,fan:-.2},ring:{knuckle:[.05,.475,-.02],bones:[.2,.125,.1],width:.122,fan:.55},pinky:{knuckle:[.15,.43,-.02],bones:[.16,.1,.085],width:.108,fan:1.25}},vf={index:{knuckle:[-.14,.47,-.02],bones:[.2,.125,.1],width:.15,fan:-1},middle:{knuckle:[0,.49,-.02],bones:[.22,.135,.1],width:.155,fan:0},pinky:{knuckle:[.14,.45,-.02],bones:[.19,.115,.095],width:.145,fan:1}},dt={base:[-.11,.1,-.05],bones:[.2,.15,.12],widths:[.2,.145,.135],out:[-.7,.68,-.22],across:[.35,.5,-.8]},Sf=[82,100,62],Mf=[48,72],Tf=3,Ef=13,Af=.035,xf=-.075,Pf=[[-.17,0],[-.215,.12],[-.235,.26],[-.225,.4],[-.185,.49],[-.075,.525],[.05,.51],[.16,.465],[.215,.4],[.225,.26],[.2,.1],[.16,0]],vt=e=>e*Math.PI/180,Ui=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],kn=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],zi=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],Re=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function St(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=zi(t,e),o=t[0]*e[0]+t[1]*e[1]+t[2]*e[2];return[e[0]*i+r[0]*s+t[0]*o*(1-i),e[1]*i+r[1]*s+t[1]*o*(1-i),e[2]*i+r[2]*s+t[2]*o*(1-i)]}const na=[1,0,0],ia=[0,1,0],Oe=[0,0,1];function _f(e,t,n){const i=vt(e.fan*(Tf+Ef*n)),s=[Math.sin(i),Math.cos(i),0],r=[Math.cos(i),-Math.sin(i),0],o=[e.knuckle];let a=0;e.bones.forEach((h,u)=>{a+=vt(Sf[u]*t),o.push(Ui(o[u],kn(St(s,r,-a),h)))});const l=St(Oe,r,-a),c=o.map((h,u)=>e.width*(1-.14*(u/(o.length-1))));return{joints:o,back:l,widths:c}}function If(e,t,n=1,i=1){const s=Math.min(1,Math.max(0,t)),r=Re(Ui(kn(Re(dt.out),1-s),kn(Re(dt.across),s))),o=Re(zi(Oe,r)),a=Re(zi(r,o)),l=[[dt.base[0]*i,dt.base[1],dt.base[2]]];let c=0;dt.bones.forEach((f,d)=>{d>0&&(c+=vt(Mf[d-1]*e)),l.push(Ui(l[d],kn(St(r,o,c),f)))});const h=St(a,o,c),u=[...dt.widths,dt.widths[dt.widths.length-1]*.92].map(f=>f*n);return{joints:l,back:h,widths:u}}function vn(e,t={}){const n={...Y,...e},i=t.size??100,s=t.side??"right",r=s==="left"?-1:1,o=vt(t.angle??0),a=t.fingers===4,l=Math.max(.5,t.plump??1),c=1+(l-1)*.7,h=x=>({...x,knuckle:[x.knuckle[0]*c,x.knuckle[1],x.knuckle[2]],width:x.width*l}),u=vt(n.bend??0),f=vt(n.tilt??0),d=vt(90*(n.turn??0)),m=x=>St(St(St(x,na,-u),Oe,-f),ia,d),p=Math.cos(o),g=Math.sin(o),y=vt(n.roll??0),w=Math.cos(y),k=Math.sin(y),M=x=>{const I=x[0]*i,C=-x[1]*i,H=(I*w-C*k)*r,R=I*k+C*w;return{x:H*p-R*g,y:H*g+R*p}},S=x=>{const I=M(x),C=Math.hypot(I.x,I.y);return C>1e-6*i?{x:I.x/C,y:I.y/C}:{x:0,y:0}},A={thumb:If(n["thumb.curl"]??0,n["thumb.across"]??0,l,c)},E=a?vf:kf;for(const x of ea){const I=E[x];I&&(A[x]=_f(h(I),n[`${x}.curl`]??0,n.spread??0))}const T={};for(const[x,I]of Object.entries(A)){const C=I.joints.map(m),H=m(I.back);T[x]={points:C.map(M),depths:C.map(R=>R[2]*i),widths:I.widths.map(R=>R*i),nail:H[2],back:S(H)}}const v=Pf.flatMap(([x,I])=>[m([x*c,I,Af]),m([x*c,I,xf])]),_=Cf(v.map(M)),P=v.reduce((x,I)=>x+I[2],0)/v.length*i;return{size:i,side:s,wrist:{x:0,y:0},palm:_,palmDepth:P,palmFacing:-m(Oe)[2],fingers:T,axes:{up:S(m(ia)),across:S(m(na)),out:S(m(Oe))},curls:Object.fromEntries(Object.keys(T).map(x=>[x,n[`${x}.curl`]??0]))}}function sa(e,t){const n=s=>({x:s.x+t.x-e.wrist.x,y:s.y+t.y-e.wrist.y}),i={};for(const[s,r]of Object.entries(e.fingers))i[s]={...r,points:r.points.map(n)};return{...e,wrist:n(e.wrist),palm:e.palm.map(n),fingers:i}}function Cf(e){const t=[...e].sort((r,o)=>r.x-o.x||r.y-o.y);if(t.length<3)return t;const n=(r,o,a)=>(o.x-r.x)*(a.y-r.y)-(o.y-r.y)*(a.x-r.x),i=[];for(const r of t){for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}const s=[];for(const r of[...t].reverse()){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],r)<=0;)s.pop();s.push(r)}return[...i.slice(0,-1),...s.slice(0,-1)]}const Hf="#f1c9a5",$f="#2f2f33";function Sn(e,t,n,i={},s=0){const r=sa(vn(n,i),t),o=i.ink??$f,a=i.lineWidth??r.size*.035,l=i.pen??Vi(e,{look:i.look??"clean",ink:o,lineWidth:a,seed:i.seed??1,time:s,pencil:{construction:!1,...i.pencil}}),c=i.skin??Hf,h=i.nails??!0,u=[{depth:r.palmDepth,draw:()=>Rf(l,r,c,a)}];for(const f of Object.values(r.fingers)){const d=f.depths.reduce((m,p)=>m+p,0)/f.depths.length;u.push({depth:d,draw:()=>Of(e,l,f,c,a,h)})}if(i.prop){const f=i.prop;u.push({depth:f.depth,draw:()=>f.draw(l)})}e.save(),e.lineCap="round",e.lineJoin="round";for(const f of[...u].sort((d,m)=>d.depth-m.depth))f.draw();return e.restore(),r}function Rf(e,t,n,i){if(e.shape(t.palm,n,i),t.palmFacing<-.3&&e.look!=="silhouette"){const{up:s}=t.axes;for(const[r,o]of Object.entries(t.fingers)){const a=t.curls[r]??0;if(r==="thumb"||a<.5)continue;const l=o.points[0],c=o.widths[0]*.42,h={x:l.x-s.x*c*.2,y:l.y-s.y*c*.2},u=Math.atan2(s.y,s.x),f=Array.from({length:7},(d,m)=>{const p=u-Math.PI/2+Math.PI*m/6;return{x:h.x+Math.cos(p)*c,y:h.y+Math.sin(p)*c}});e.line(f,i*.6)}}if(t.palmFacing>.45&&e.look!=="silhouette"){const{up:s,across:r}=t.axes,o=t.size,a=t.wrist,l=(h,u)=>({x:a.x+(r.x*h+s.x*u)*o,y:a.y+(r.y*h+s.y*u)*o}),c=t.side==="left"?-1:1;e.line([l(-.15*c,.36),l(-.04*c,.3),l(.1*c,.33)],i*.5)}}function Of(e,t,n,i,s,r){const{widths:o}=n,a=Lf(n.points,2),l=n.points[0],c=a[a.length-1],h=o[0],u=o[o.length-1];if(e.save(),t.look!=="silhouette"){e.beginPath(),e.rect(l.x-1e5,l.y-1e5,2e5,2e5);const p=h/2+s*1.6;e.moveTo(l.x+p,l.y),e.arc(l.x,l.y,p,0,Math.PI*2),e.clip("evenodd")}if(t.limb(a,h+2*s,u+2*s),e.restore(),t.look!=="silhouette"&&(e.fillStyle=i,bn(e,a,h,u)),t.look==="silhouette"||!r||n.nail<.25)return;const f=a[a.length-2],d=Ff({x:c.x-f.x,y:c.y-f.y})??{x:0,y:-1},m={x:c.x-d.x*u*.22+n.back.x*u*.1,y:c.y-d.y*u*.22+n.back.y*u*.1};t.ellipse(m.x,m.y,u*.24*Math.max(.35,n.nail),u*.19,Math.atan2(d.y,d.x),"#f8e3d3",s*.45)}function Lf(e,t){let n=e;for(let i=0;i<t;i++){if(n.length<3)return n;const s=[n[0]];for(let r=0;r<n.length-1;r++){const o=n[r],a=n[r+1];r>0&&s.push({x:o.x*.75+a.x*.25,y:o.y*.75+a.y*.25}),r<n.length-2&&s.push({x:o.x*.25+a.x*.75,y:o.y*.25+a.y*.75})}s.push(n[n.length-1]),n=s}return n}const Ff=e=>{const t=Math.hypot(e.x,e.y);return t>1e-6?{x:e.x/t,y:e.y/t}:null},$t={walk:{swing:24,knee:30,arm:22,elbow:28,lean:4},bouncy:{swing:26,knee:45,arm:34,elbow:30,lean:2,bend:-4,bounce:.035,squash:.06},doubleBounce:{swing:22,knee:40,arm:26,elbow:24,lean:3,bounce:.02,bounces:2,squash:.04},sneak:{swing:28,knee:70,arm:6,elbow:0,forearm:110,shoulder:55,lean:16,bend:14,headTilt:-8,crouch:50,tiptoe:25},strut:{swing:26,knee:30,arm:30,elbow:20,lean:-4,bend:-10,headTilt:-6,sway:4,bounce:.01},tired:{swing:14,knee:14,arm:6,elbow:6,lean:10,bend:16,headTilt:12},run:{swing:40,knee:95,arm:45,elbow:0,forearm:90,lean:16,bend:6,bounce:.05,squash:.06}},Df=40;function Le(e){return e===void 0?$t.walk:typeof e=="string"?$t[e]??$t.walk:e}function ra(e,t,n=W,i=1){const s=Le(e);if(s===$t.walk)return ua(t,n,i);const r=t*Math.PI*2,o=Math.sin(r)*i,a=Math.cos(r)*i,l=y=>y<=Df,c=s.shoulder??0,h=(y,w)=>l(y)?w*c+s.arm*o:y,u=s.forearm??0,f=l(n.leftShoulder)?n.leftElbow-u-s.elbow*Math.max(0,-o):n.leftElbow,d=l(n.rightShoulder)?n.rightElbow+u+s.elbow*Math.max(0,o):n.rightElbow,m=s.bounces??1,p=(1+Math.cos(r*2*m))/2,g=s.crouch??0;return{...n,lean:n.lean+s.lean*i+(s.sway??0)*Math.sin(r)*(1-(n.turn??0)),bend:(n.bend??0)+(s.bend??0),headTilt:n.headTilt-s.lean*.5*i+(s.headTilt??0),leftElbow:f,rightElbow:d,leftHip:-s.swing*o-g*.5,rightHip:-s.swing*o+g*.5,leftKnee:-s.knee*Math.max(0,a)-g,rightKnee:s.knee*Math.max(0,-a)+g,leftAnkle:(n.leftAnkle??0)+(s.tiptoe??0),rightAnkle:(n.rightAnkle??0)+(s.tiptoe??0),leftShoulder:h(n.leftShoulder,-1),rightShoulder:h(n.rightShoulder,1),rise:(n.rise??0)+(s.bounce??0)*i*p,stretch:n.stretch*(1+(s.squash??0)*(p-.5))}}function oa(e,t,n=1){const i=Le(e),s=$t.walk.swing,r=o=>Math.sin(o*Math.PI/180);return fa(t,n)*r(i.swing*n)/r(s*n)}const W={lean:0,bend:0,headTilt:0,leftShoulder:18,rightShoulder:18,leftElbow:-6,rightElbow:-6,leftHip:8,rightHip:8,leftKnee:0,rightKnee:0,leftWrist:0,rightWrist:0,leftAnkle:0,rightAnkle:0,leftFootOut:0,rightFootOut:0,mouth:0,smile:.6,mouthWidth:1,blink:0,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0,stretch:1,turn:0,sit:0,spin:0,rise:0};function j(e){return{...W,...e}}const aa={mouth:0,smile:0,mouthWidth:1,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0},z=e=>({...aa,...e}),G={neutral:aa,happy:z({smile:.9,leftBrow:.2,rightBrow:.2}),joyful:z({mouth:.6,smile:1,mouthWidth:1.2,leftEye:0,rightEye:0,leftBrow:.4,rightBrow:.4}),sad:z({smile:-.8,leftEye:.8,rightEye:.8,browTilt:.9,leftBrow:-.1,rightBrow:-.1,lookY:.6}),crying:z({mouth:.45,smile:-1,leftEye:0,rightEye:0,browTilt:1,lookY:.4}),surprised:z({mouth:.7,mouthWidth:.7,leftEye:1.5,rightEye:1.5,leftBrow:1,rightBrow:1}),shocked:z({mouth:1,mouthWidth:.8,leftEye:1.6,rightEye:1.6,leftBrow:1,rightBrow:1,browTilt:.4}),angry:z({smile:-.6,mouthWidth:.9,leftEye:.8,rightEye:.8,leftBrow:-.6,rightBrow:-.6,browTilt:-1}),furious:z({mouth:.5,smile:-1,mouthWidth:1.3,leftEye:.9,rightEye:.9,leftBrow:-.9,rightBrow:-.9,browTilt:-1}),worried:z({smile:-.3,mouthWidth:.8,leftEye:1.1,rightEye:1.1,leftBrow:.3,rightBrow:.3,browTilt:.8,lookX:-.5}),scared:z({mouth:.35,smile:-.5,mouthWidth:.8,leftEye:1.45,rightEye:1.45,leftBrow:.8,rightBrow:.8,browTilt:.9}),confused:z({smile:-.2,mouthWidth:.8,leftEye:.9,rightEye:1.15,leftBrow:-.3,rightBrow:.8,lookX:.5,lookY:-.4}),skeptical:z({smile:-.1,leftEye:.6,rightEye:1,leftBrow:-.4,rightBrow:.7,lookX:.4}),thinking:z({smile:0,mouthWidth:.7,leftBrow:.3,rightBrow:.5,lookX:.6,lookY:-.8}),sleepy:z({smile:.1,leftEye:.25,rightEye:.25,leftBrow:-.3,rightBrow:-.3,lookY:.5}),disgusted:z({smile:-.7,mouthWidth:.9,leftEye:.6,rightEye:.75,leftBrow:-.5,rightBrow:-.2,browTilt:-.4,lookX:-.6}),smug:z({smile:.6,mouthWidth:.9,leftEye:.6,rightEye:.6,leftBrow:.1,rightBrow:.5,lookX:.5}),wink:z({smile:.9,leftEye:0,rightEye:1,leftBrow:-.2,rightBrow:.3})};function ie(e,t){return{...e,...typeof t=="string"?G[t]:t}}const se={rest:W,wave:j({rightShoulder:135,rightElbow:30,headTilt:6,...G.happy}),cheer:j({leftShoulder:125,leftElbow:20,rightShoulder:125,rightElbow:20,...G.joyful}),shrug:j({leftShoulder:30,leftElbow:85,rightShoulder:30,rightElbow:85,headTilt:-10,...G.confused,lookX:0,lookY:0}),point:j({rightShoulder:90,rightElbow:0,lean:4,smile:.4}),think:j({rightShoulder:60,rightElbow:150,headTilt:10,...G.thinking}),handsOnHips:j({leftShoulder:45,leftElbow:-100,rightShoulder:45,rightElbow:-100,leftHip:14,rightHip:14,smile:.8}),sad:j({leftShoulder:14,rightShoulder:14,leftElbow:-4,rightElbow:-4,headTilt:-14,lean:-3,...G.sad}),surprised:j({leftShoulder:70,leftElbow:60,rightShoulder:70,rightElbow:60,...G.surprised}),crouch:j({stretch:.72,leftShoulder:35,rightShoulder:35,leftElbow:-50,rightElbow:-50,leftHip:22,rightHip:22,headTilt:-4}),sit:j({sit:1,turn:.5,leftShoulder:-25,rightShoulder:25,leftElbow:-55,rightElbow:55}),jump:j({stretch:1.22,leftShoulder:140,rightShoulder:140,leftElbow:20,rightElbow:20,leftHip:4,rightHip:4,...G.joyful}),sideSplit:j({leftHip:90,rightHip:90,leftAnkle:-45,rightAnkle:-45,leftShoulder:120,rightShoulder:120,leftElbow:10,rightElbow:10,...G.happy}),frontSplit:j({turn:1,leftHip:-90,rightHip:-90,leftAnkle:-45,rightAnkle:-45,leftShoulder:-150,rightShoulder:150,leftElbow:10,rightElbow:-10,...G.happy})},la=Object.keys(W);function re(e,t,n){const i={...e};for(const s of la)i[s]=e[s]+(t[s]-e[s])*n;return i}const Gi=24,ca=4,ha=28,Bf=40;function ua(e,t=W,n=1){const i=Math.sin(e*Math.PI*2)*n,s=Math.cos(e*Math.PI*2)*n,r=c=>c<=Bf,o=c=>r(c)?22*i:c,a=r(t.leftShoulder)?t.leftElbow-ha*Math.max(0,-i):t.leftElbow,l=r(t.rightShoulder)?t.rightElbow+ha*Math.max(0,i):t.rightElbow;return{...t,lean:t.lean+ca*n,headTilt:t.headTilt-ca*.5*n,leftElbow:a,rightElbow:l,leftHip:-Gi*i,rightHip:-Gi*i,leftKnee:-30*Math.max(0,s),rightKnee:30*Math.max(0,-s),leftShoulder:o(t.leftShoulder),rightShoulder:o(t.rightShoulder)}}function fa(e,t=1){return 4*((ji+Mn)*e)*Math.sin(Gi*t*Math.PI/180)}function da(e){const t=Math.abs(Math.sin(e/65)),n=.55+.45*Math.sin(e/310);return t*n}const pa=.12,ma=.46,Nf=1-2*pa,Wf=.1,Kf=.21,Yf=.19,ji=.24,Mn=.22,ga=.12,Xf=.14,ya=.33,ba=.7,wa=.3,qf=.35,Vf=[1.7,1.05],Uf=[1.3,.75],ka=[1.45,.85],zf=[1.15,.75],va=.06,Gf=.7,jf=.65,Sa=.075,Jf=.3,Zf=.02,Qf=.012,td=12,ed=.25,Tn=90,nd=.25,id=.04,Ma=.01,Rt=e=>Math.min(1,Math.max(0,e??0));function sd(e,t=1){return Mn*e*t}const Ji=-.12,Ta=.4,rt=e=>e*Math.PI/180,rd=(e,t)=>({x:t*Math.sin(rt(e)),y:Math.cos(rt(e))}),Ea=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),Aa=(e,t,n,i)=>e-.3*t-n*.14*t-Math.max(0,i-1)*.12*t;function od(e,t,n,i,s,r){const o=Math.max(1,Math.min(r*.6,Xf*n)),a=Rt(t.turn),l=(ga+ya*a)*n,c=i+Ji*n,h=l+t.lookX*.08*n,u=t.lookY*.07*n,f=[{x:-.34*n*(1-ba*a),squeeze:1-ba*a,open:t.leftEye,brow:t.leftBrow,side:-1},{x:.34*n*(1-wa*a),squeeze:1-wa*a,open:t.rightEye,brow:t.rightBrow,side:1}];e.fillStyle=s,e.strokeStyle=s,e.lineWidth=o;for(const y of f){const w=Ea(y.open,t.blink);if(w<.2){const A=t.smile>.5?-.12*n:.06*n;e.beginPath(),e.moveTo(y.x+l-.12*n,c),e.quadraticCurveTo(y.x+l,c+A,y.x+l+.12*n,c),e.stroke()}else{if(w>1.2){const E=.13*n*w;e.beginPath(),e.ellipse(y.x+l,c,E*.85,E,0,0,Math.PI*2),e.fillStyle="#ffffff",e.fill(),e.stroke(),e.fillStyle=s}const A=w>1.2?.075*n:.1*n;e.beginPath(),e.ellipse(y.x+h,c+u,A,A*1.1*Math.min(w,1),0,0,Math.PI*2),e.fill()}const k=Aa(c,n,y.brow,w),M=y.x+l-y.side*.13*n*y.squeeze,S=y.x+l+y.side*.13*n*y.squeeze;e.beginPath(),e.moveTo(S,k),e.lineTo(M,k-t.browTilt*.1*n),e.stroke()}const d=i+Ta*n,m=.25*n*Math.max(.3,t.mouthWidth)*(1-qf*a),p=Math.min(1,Math.max(0,t.mouth));if(e.beginPath(),p<=.05){e.moveTo(l-m,d),e.quadraticCurveTo(l,d+t.smile*.25*n,l+m,d),e.stroke();return}const g=.3*n*p;t.smile>.3?(e.moveTo(l-m,d-.05*n),e.lineTo(l+m,d-.05*n),e.quadraticCurveTo(l,d+g*2,l-m,d-.05*n)):t.smile<-.3?(e.moveTo(l-m,d+g*.6),e.lineTo(l+m,d+g*.6),e.quadraticCurveTo(l,d-g*1.4,l-m,d+g*.6)):e.ellipse(l,d,m*.8,g,0,0,Math.PI*2),e.fill()}function xa(e,t){const n=t.height??300,i=Math.min(3,Math.max(.3,e.stretch??1)),s=Math.sqrt(i),r=(t.headSize??2*pa)/2,o=t.headSize===void 0?Nf:1-2*r,a=r*n,l=Rt(e.sit),c=e.leftHip+(-Tn-e.leftHip)*l,h=e.leftKnee+(-Tn-e.leftKnee)*l,u=e.rightHip+(Tn-e.rightHip)*l,f=e.rightKnee+(Tn-e.rightKnee)*l,d=t.classic===!0,m=Rt(e.turn),p=($,L,O,D,N)=>{const K=Math.max(-Math.PI/2,Math.min(Math.PI/2,Math.abs(rt(L-O)/2)+rt(D))),Q=Math.max(-1,Math.min(1,Gf+N)),xt=m+(1-m)*$*Q;return d?{x:0,y:0}:{x:Math.cos(K)*va*xt,y:Math.sin(K)*va}},g={left:e.leftAnkle??0,right:e.rightAnkle??0},y={left:e.leftFootOut??0,right:e.rightFootOut??0};let w=0;if(l>0||!d){const $=(N,K,Q,xt,Dt)=>ji*Math.cos(rt(K))+Mn*Math.cos(rt(K-Q))+Math.max(0,p(N,K,Q,xt,Dt).y),L=Math.max($(-1,c,h,g.left,y.left),$(1,u,f,g.right,y.right)),O=1-Rt((e.rise??0)/id),D=(d?Math.min(1,l/nd):1)*O;w=(ma-L)*D*n*i}const k=-ma*n*i+w,M=-o*n*i+w,S=d?0:(Zf*Rt(e.turn)+Qf*l)*n*i,A=rt(e.bend??0),E={end:_a(k,M,A,1),bend:A};let T;if(A!==0){T=[];for(let $=0;$<=Pa;$++){const L=$/Pa,O=_a(k,M,A,L);T.push({x:O.x-S*Math.sin(Math.PI*L),y:O.y})}}else T=S===0?[{x:0,y:k},{x:0,y:M}]:Ht({x:0,y:k},{x:-S,y:(k+M)/2},{x:0,y:M},1,8);const v=M+Wf*n*i,_=(t.shoulderWidth??0)*n*Math.cos(m*Math.PI/2),P=($,L,O,D,N)=>{const K=rd(O,D);return{x:$+K.x*N*n,y:L+K.y*N*n}},x=($,L,O)=>{const D=P(0,k,L,$,ji*i);return{root:{x:0,y:k},joint:D,end:P(D.x,D.y,L-O,$,Mn*i)}},I=($,L,O)=>{const D={x:$*_,y:v},N=P(D.x,D.y,L,$,Kf*s);return{root:D,joint:N,end:P(N.x,N.y,L+O,$,Yf*s)}},C={left:x(-1,c,h),right:x(1,u,f)},H=($,L,O,D,N,K)=>{const Q=p($,O,D,N,K);return{x:L.end.x+Q.x*n*i,y:L.end.y+Q.y*n*i}},R=($,L,O,D,N)=>P(L.end.x,L.end.y,O+D+N,$,Sa*s),B={left:I(-1,e.leftShoulder,e.leftElbow),right:I(1,e.rightShoulder,e.rightElbow)};return{height:n,facing:(t.facing??1)<0?-1:1,stretch:i,lineWidth:t.lineWidth??n*.025,rubber:Math.min(1,Math.max(d?0:Jf,t.rubber??0)),r:a,headRx:a/Math.sqrt(i),headRy:a*Math.sqrt(i),hipY:k,neckY:M,drop:w,lean:d?e.lean:e.lean+td*Math.sin(Math.PI*l),classic:d,legs:C,toes:{left:H(-1,C.left,c,h,g.left,y.left),right:H(1,C.right,u,f,g.right,y.right)},spine:T,chest:E,arms:B,handTips:{left:R(-1,B.left,e.leftShoulder,e.leftElbow,e.leftWrist??0),right:R(1,B.right,e.rightShoulder,e.rightElbow,e.rightWrist??0)}}}const Pa=10;function _a(e,t,n,i){const s=e-t,r=n*i;if(Math.abs(n)<1e-9)return{x:0,y:e-s*i};const o=s/n;return{x:o*(1-Math.cos(r)),y:e-o*Math.sin(r)}}function ad(e,t){if(e.chest.bend===0)return t;const n=De(t,{x:0,y:e.neckY},e.chest.bend);return{x:n.x+e.chest.end.x,y:n.y+e.chest.end.y-e.neckY}}const Fe=(e,t)=>t===0?[e.root,e.joint,e.end]:Ht(e.root,e.joint,e.end,t);function De(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=e.x-t.x,o=e.y-t.y;return{x:t.x+r*i-o*s,y:t.y+r*s+o*i}}function Ia(e,t,n=!0){const i=cd(e,t),s=t.spin??0,r=t.rise??0;return n&&(s!==0||r!==0)?ld(i,e,s,r):i}function Ca(e,t,n){return{pivot:{x:0,y:e.hipY},angle:e.facing*rt(t),lift:n*e.height}}function ld(e,t,n,i){const{pivot:s,angle:r,lift:o}=Ca(t,n,i),a=f=>{const d=De(f,s,r);return{x:d.x,y:d.y-o}},l=f=>({left:a(f.left),right:a(f.right)}),c={left:Math.max(a(e.feet.left).y,a(e.toes.left).y),right:Math.max(a(e.feet.right).y,a(e.toes.right).y)},h=Math.max(c.left,c.right),u=Ma*t.height;return{...e,hip:a(e.hip),neck:a(e.neck),shoulders:l(e.shoulders),elbows:l(e.elbows),hands:l(e.hands),fingertips:l(e.fingertips),knees:l(e.knees),feet:l(e.feet),toes:l(e.toes),feetY:h,grounded:{left:c.left>=h-u,right:c.right>=h-u},handAngle:{left:e.handAngle.left+r,right:e.handAngle.right+r},limbs:{leftArm:e.limbs.leftArm.map(a),rightArm:e.limbs.rightArm.map(a),leftLeg:e.limbs.leftLeg.map(a),rightLeg:e.limbs.rightLeg.map(a),spine:e.limbs.spine.map(a)},head:{...e.head,center:a(e.head.center),angle:e.head.angle+r}}}function cd(e,t){const n=rt(e.lean),i=rt(t.headTilt),s={x:0,y:e.hipY},r=M=>({x:e.facing*M.x,y:M.y}),o=M=>r(De(M,s,n)),a=M=>o(ad(e,M)),l=M=>a(De({x:M.x,y:M.y+e.neckY},{x:0,y:e.neckY},i)),c=Fe(e.arms.left,e.rubber).map(a),h=Fe(e.arms.right,e.rubber).map(a),u=(M,S)=>Math.atan2(S.y-M.y,S.x-M.x),f={left:a(e.handTips.left),right:a(e.handTips.right)},d=(M,S)=>{const[A,E]=M.slice(-2),T=e.arms[S],v=u(a(T.end),f[S])-u(a(T.joint),a(T.end));return u(A,E)+v};let m=1/0;for(const[M,S]of[[t.leftBrow,t.leftEye],[t.rightBrow,t.rightEye]]){const A=Aa(Ji,1,M,Ea(S,t.blink));m=Math.min(m,A,A-t.browTilt*.1)}const p={left:r(e.legs.left.end),right:r(e.legs.right.end)},g={left:r(e.toes.left),right:r(e.toes.right)},y={left:Math.max(p.left.y,g.left.y),right:Math.max(p.right.y,g.right.y)},w=Math.max(y.left,y.right),k=Ma*e.height;return{facing:e.facing,height:e.height,stretch:e.stretch,lineWidth:e.lineWidth,hip:s,neck:a({x:0,y:e.neckY}),shoulders:{left:a(e.arms.left.root),right:a(e.arms.right.root)},elbows:{left:a(e.arms.left.joint),right:a(e.arms.right.joint)},hands:{left:a(e.arms.left.end),right:a(e.arms.right.end)},knees:{left:r(e.legs.left.joint),right:r(e.legs.right.joint)},feet:p,toes:g,feetY:w,grounded:{left:y.left>=w-k,right:y.right>=w-k},fingertips:f,handAngle:{left:d(c,"left"),right:d(h,"right")},limbs:{leftArm:c,rightArm:h,leftLeg:Fe(e.legs.left,e.rubber).map(r),rightLeg:Fe(e.legs.right,e.rubber).map(r),spine:e.spine.map(o)},head:{center:l({x:0,y:-e.headRy}),rx:e.headRx,ry:e.headRy,angle:e.facing*(n+e.chest.bend+i),eyeY:Ji,browTopY:m,mouthY:Ta,faceX:e.facing*(ga+ya*Rt(t.turn))}}}function Ha(e,t={}){return Ia(xa(e,t),e)}function hd(e,t,n){return De({x:e.center.x+t*e.rx,y:e.center.y+n*e.ry},e.center,e.angle)}function $a(e,t,n){const i=r=>({x:r.x+t,y:r.y+n}),s=r=>({left:i(r.left),right:i(r.right)});return{...e,hip:i(e.hip),neck:i(e.neck),shoulders:s(e.shoulders),elbows:s(e.elbows),hands:s(e.hands),knees:s(e.knees),feet:s(e.feet),toes:s(e.toes),feetY:e.feetY+n,grounded:{...e.grounded},handAngle:{...e.handAngle},limbs:{leftArm:e.limbs.leftArm.map(i),rightArm:e.limbs.rightArm.map(i),leftLeg:e.limbs.leftLeg.map(i),rightLeg:e.limbs.rightLeg.map(i),spine:e.limbs.spine.map(i)},head:{...e.head,center:i(e.head.center)}}}function Ra(e,t,n={},i=0){const s=xa(t,n),r=n.color??"#1e293b",o=n.layers??{},a=n.layers?Ia(s,t,!1):void 0,l=n.sketch?yn(e,n.sketch,i):void 0,c=n.sketch&&n.layers?yn(e,n.sketch,i):void 0,h=E=>{e.save(),E(),e.restore()},u=E=>{E&&a&&h(()=>E(e,a,i,c))},f=()=>e.scale(s.facing,1),d=()=>{f(),e.translate(0,s.hipY),e.rotate(rt(s.lean)),e.translate(0,-s.hipY)},m=()=>{d(),s.chest.bend!==0&&(e.translate(s.chest.end.x,s.chest.end.y),e.rotate(s.chest.bend),e.translate(0,-s.neckY))},p=(E,T,v)=>{if(l)return T?l.curve(E):l.line(E);if(s.classic){e.beginPath(),e.moveTo(E[0].x,E[0].y);for(const _ of E.slice(1))e.lineTo(_.x,_.y);e.stroke();return}bn(e,E,v[0]*s.lineWidth,v[1]*s.lineWidth)},g=(E,T)=>p(Fe(E,s.rubber),s.rubber>0,T),y=E=>{s.classic||p([s.legs[E].end,s.toes[E]],!1,zf)},w=E=>{if(n.hands&&!s.classic)return M(E);if(s.classic||l)return;const T=s.arms[E].end;e.beginPath(),e.arc(T.x,T.y,jf*s.lineWidth,0,Math.PI*2),e.fill()};e.save(),e.strokeStyle=r,e.fillStyle=r,e.lineWidth=s.lineWidth,e.lineCap="round",e.lineJoin="round";const k=Ca(s,t.spin??0,t.rise??0);(k.angle!==0||k.lift!==0)&&(e.translate(0,-k.lift),e.translate(k.pivot.x,k.pivot.y),e.rotate(k.angle),e.translate(-k.pivot.x,-k.pivot.y));function M(E){const T=n.hands??{},v=s.arms[E].end,_=s.handTips[E],P=n.headFill??"#ffffff";Sn(e,v,T[E]??Y,{side:E,angle:Math.atan2(_.x-v.x,v.y-_.y)*180/Math.PI,size:(T.size??Sa)*s.height*Math.sqrt(s.stretch),skin:T.skin??(P==="none"?void 0:P),ink:r,lineWidth:s.lineWidth*.45,fingers:T.fingers,plump:T.plump,look:n.sketch?"pencil":"clean",seed:n.sketch?.seed},i)}const S=E=>{h(()=>{m(),g(s.arms[E],Uf),w(E)});const T=o.sleeve;T&&a&&h(()=>T(e,a,E,i,c))},A=Rt(t.turn)>ed;u(o.behind),h(()=>{f(),g(s.legs.left,ka),y("left"),g(s.legs.right,ka),y("right")}),A&&S("left"),h(()=>{d(),p(s.spine,s.spine.length>2,Vf)}),h(()=>{m();const{left:E,right:T}={left:s.arms.left.root,right:s.arms.right.root};if(E.x!==T.x)if(s.classic)p([E,T],!1,[1,1]);else{const v={x:(E.x+T.x)/2,y:E.y-.3*Math.abs(T.x-E.x)};p(Ht(E,v,T,1,8),!0,[1.1,1.1])}}),u(o.body),A||S("left"),S("right"),u(o.behindHead),h(()=>{m(),e.translate(0,s.neckY),e.rotate(rt(t.headTilt));const E=-s.headRy;e.beginPath(),e.ellipse(0,E,s.headRx,s.headRy,0,0,Math.PI*2);const T=n.headFill??"#ffffff";if(T!=="none"&&(e.fillStyle=T,e.fill()),l){l.ellipse(0,E,s.headRx,s.headRy);const v=l.nudge();e.translate(v.x,v.y)}else e.stroke();e.translate(0,E),e.scale(s.headRx/s.r,s.headRy/s.r),od(e,t,s.r,0,r,s.lineWidth)}),u(o.overHead),u(o.front),e.restore(),n.label&&(e.save(),e.fillStyle=r,e.font=n.labelFont??`700 ${Math.round(s.height*.11)}px sans-serif`,e.textAlign="center",e.textBaseline="bottom",e.fillText(n.label,0,-s.height*s.stretch-.04*s.height+s.drop),e.restore())}function Zi(e,t,n){const i={...e};let s=e.walking>0?re(i,ra(e.gait,e.walk,i),e.walking):i,r=ud(e);const o=e.dancing??0;if(n&&o>0){const a=n(e.beat??0);if(s=re(s,a.pose,o),a.hands){const l=(c,h)=>h?ne(c??Y,h,o):c;r={left:l(r?.left,a.hands.left),right:l(r?.right,a.hands.right)}}}return e.talk>0&&(s={...s,mouth:Math.max(s.mouth,e.talk*da(t))}),{pose:s,hands:r}}function Oa(e,t,n){return Zi(e,t,n).pose}const La=(e,t)=>(e.facing??t.facing??1)<0?-1:1,Be=(e,t)=>`hand.${e}.${t}`;function ud(e){const t=s=>{if(typeof e[Be(s,"spread")]=="number")return Object.fromEntries(Object.keys(Y).map(r=>[r,e[Be(s,r)]]))},n=t("left"),i=t("right");return n||i?{left:n,right:i}:void 0}function fd(e,t){return!t||!e.hands?e:{...e,hands:{...e.hands,left:t.left??e.hands.left,right:t.right??e.hands.right}}}function dd(e){const t=e.style??{},n=t.height??300,i=n*.8,s={...j(e.pose??{}),walk:0,walking:0,gait:"walk",facing:(t.facing??1)<0?-1:1,talk:0,rubber:t.rubber??0,beat:0,dancing:0},r={};if(t.hands)for(const o of["left","right"]){const a=t.hands[o]??Y;for(const l of Object.keys(Y))r[Be(o,l)]=a[l]??Y[l]}return{type:"custom",x:e.x-i/2,y:e.y-n,width:i,height:n,props:{...s,...r},figureStyle:t,figureDance:e.dance,draw(o,a,l){const c=a.props,h=Zi(c,l,e.dance);o.translate(i/2,n),Ra(o,h.pose,fd({...t,rubber:c.rubber,facing:La(c,t)},h.hands),l)}}}function Fa(e,t,n){const i=e.figureStyle;if(!i)throw new Error("stickFigureAt: the target was not made by stickFigureTarget");const s={...e.props};let r=0,o=0;for(const[c,h]of t.state?.values.get(n)??[])c==="gait"&&typeof h=="string"&&(s.gait=h),typeof h=="number"&&(c==="x"||c==="motionPathX"?r=h:c==="y"||c==="motionPathY"?o=h:c in s&&(s[c]=h));const a=Oa(s,t.time,e.figureDance),l=Ha(a,{...i,rubber:s.rubber,facing:La(s,i)});return{pose:a,joints:$a(l,e.x+r+e.width/2,e.y+o+e.height)}}function Qi(e){const t=[];return e.forEach((n,i)=>{const s=i===0?W:t[i-1],r=typeof n.pose=="string"?se[n.pose]:{...s,...n.pose};t.push(n.expression?ie(r,n.expression):r)}),t}function pd(e,t){const n=Qi(t);return la.filter(i=>n.some(s=>s[i]!==W[i])).map(i=>({id:`${e}-${i}`,target:e,property:i,keyframes:t.map((s,r)=>({time:s.time,value:n[r][i],...s.easing?{easing:s.easing}:{}}))}))}const ts=.5,es={pataka:X({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:0,turn:2}),tripataka:X({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":1,"pinky.curl":0,spread:0,turn:2}),alapadma:X({"thumb.curl":.1,"thumb.across":0,"index.curl":.05,"middle.curl":.15,"ring.curl":.25,"pinky.curl":.35,spread:1,turn:2}),mushti:U.fist,shikhara:U.thumbsUp,hamsasya:X({"thumb.curl":.15,"thumb.across":.6,"index.curl":.6,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:.7,turn:2}),katakamukha:X({"thumb.curl":.2,"thumb.across":.6,"index.curl":.65,"middle.curl":.7,"ring.curl":0,"pinky.curl":0,spread:.4,turn:2})};function En(e){return typeof e!="string"?e:e in es?es[e]:U[e]}function Da(e,t,n){const i=[];for(const s of e.keys){const r=i[i.length-1],o=!r||s.reset?{pose:t,...n}:r;i.push({beat:s.beat,pose:{...o.pose,...s.pose},left:s.hands?.left?En(s.hands.left):o.left,right:s.hands?.right?En(s.hands.right):o.right,easing:s.easing??e.easing})}return i}const ns=(e,t)=>(e%t+t)%t;function md(e,t,n,i){const s=Da(e,n,i);if(s.length===0)return{pose:n,hands:i};const r=ns(t,e.beats);let o=s.length-1;for(let d=0;d<s.length;d++)s[d].beat<=r&&(o=d);const a=s[o],l=s[(o+1)%s.length],c=a.beat<=r?a.beat:a.beat-e.beats,h=l.beat>c?l.beat:l.beat+e.beats,u=h>c?(r-c)/(h-c):0,f=J(l.easing??"ease-in-out")(Math.min(1,Math.max(0,u)));return{pose:re(a.pose,l.pose,f),hands:{left:ne(a.left,l.left,f),right:ne(a.right,l.right,f)}}}const gd=[["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"],["leftFootOut","rightFootOut"],["leftEye","rightEye"],["leftBrow","rightBrow"]],yd=["lean","headTilt","lookX","spin"],bd=new Set(["leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee"]);function Ba(e){const t={...e},n=(e.turn??0)>=.5;for(const[i,s]of gd){const r=n&&bd.has(i)?-1:1;t[i]=r*e[s],t[s]=r*e[i]}if(!n)for(const i of yd)t[i]=-e[i];return t}const wd=e=>Math.min(1,Math.max(-1,(.5-e)*4));function Na(e,t,n){const i=ns(n,1),s=(1+Math.cos(2*Math.PI*i))/2,r=t.bounce*(t.accent==="up"?1-s:s),o=Math.min(1,Math.max(0,e.turn??0)),a=wd(o);return{...e,leftHip:e.leftHip+a*r/2,rightHip:e.rightHip+r/2,leftKnee:e.leftKnee+a*r,rightKnee:e.rightKnee+r,lean:e.lean+(t.sway??0)*(1-o)*Math.sin(Math.PI*n)}}function An(e){const t={...W,...e.stance};return e.expression?ie(t,e.expression):t}function Wa(e){return{left:e.hands?.left?En(e.hands.left):Y,right:e.hands?.right?En(e.hands.right):Y}}function is(e,t,n){const i=e.moves[t.move];if(!i)throw new Error(`dance: "${e.label}" has no move "${t.move}"`);const s=md(i,n,An(e),Wa(e));return t.mirror?{pose:Ba(s.pose),hands:{left:s.hands?.right,right:s.hands?.left}}:s}function xn(e,t,n={}){const i=typeof e=="string"?Ot[e]:e;let s;if(n.move)s=is(i,{move:n.move,mirror:n.mirror},t);else{const r=i.routine,o=r.reduce((u,f)=>u+f.beats,0),a=ns(t,o);let l=0,c=0;for(;c<r.length-1&&a>=l+r[c].beats;)l+=r[c++].beats;const h=a-l;if(s=is(i,r[c],h),h<ts&&r.length>1&&t>=ts){const u=r[(c-1+r.length)%r.length],f=is(i,u,u.beats+h),d=J("ease-in-out")(h/ts);s={pose:re(f.pose,s.pose,d),hands:{left:ne(f.hands.left,s.hands.left,d),right:ne(f.hands.right,s.hands.right,d)}}}}return{...s,pose:Na(s.pose,i.groove,t)}}function kd(e,t,n={}){return xn(e,t,n).pose}function Pn(e){return(typeof e=="string"?Ot[e]:e).routine.reduce((n,i)=>n+i.beats,0)}const vd={leftToe:"rightToe",rightToe:"leftToe",leftHeel:"rightHeel",rightHeel:"leftHeel"};function Ka(e,t,n,i,s,r,o){for(let a=0;a*e.beats<n;a++)for(const l of e.keys){const c=a*e.beats+l.beat,h=t+c;if(!(c>=n||h<r||h>=o))for(const u of l.taps??[])s.push({beat:h,tap:i?vd[u]:u})}}function Sd(e,t,n,i={}){const s=typeof e=="string"?Ot[e]:e,r=[];if(n<=t)return r;if(i.move){const o=s.moves[i.move],a=Math.floor(t/o.beats)*o.beats;Ka(o,a,Math.ceil((n-a)/o.beats)*o.beats,i.mirror,r,t,n)}else{const o=Pn(s);for(let a=Math.floor(t/o)*o;a<n;a+=o){let l=a;for(const c of s.routine)Ka(s.moves[c.move],l,c.beats,c.mirror,r,t,n),l+=c.beats}}return r.sort((o,a)=>o.beat-a.beat)}function Ya(e,t){const n=e.moves[t.move];if(!n?.travel)return 0;const i=n.travel/n.beats;return t.mirror?(Da(n,An(e),Wa(e))[0]?.pose.turn??An(e).turn??0)>=.5?i:-i:i}function Xa(e,t){return t.move?[{move:t.move,beats:e.moves[t.move].beats,mirror:t.mirror}]:e.routine}function _n(e,t,n={}){const i=typeof e=="string"?Ot[e]:e,s=Xa(i,n),r=s.reduce((h,u)=>h+u.beats,0),o=s.reduce((h,u)=>h+Ya(i,u)*u.beats,0),a=Math.floor(t/r);let l=a*o,c=t-a*r;for(const h of s){const u=Math.min(h.beats,c);if(l+=Ya(i,h)*u,c-=u,c<=0)break}return l}function Md(e,t,n){const i=Xa(e,n),s=[0];let r=0;for(let o=0;r<t;o=(o+1)%i.length)r+=i[o].beats,s.push(Math.min(r,t));return s}const Td=8;function qa(e,t,n){const i=typeof t=="string"?Ot[t]:t,s=n.bpm??i.bpm,r=n.beats??(n.move?i.moves[n.move].beats:Pn(i)),o=Md(i,r,n);if(o.every(y=>_n(i,y,n)===0))return;const a=Math.min(n.fade??1,r/2),l=J("ease-in-out"),c=y=>a<=0?1:Math.min(l(Math.min(1,y/a)),l(Math.min(1,(r-y)/a))),h=Math.ceil(a*Td),u=a<=0?[]:Array.from({length:h+1},(y,w)=>[w/h*a,r-w/h*a]).flat(),f=[...new Set([...o,...u])].sort((y,w)=>y-w);let d=0;const m=f.map((y,w)=>{if(w>0){const k=f[w-1],M=Math.max(1,Math.ceil((y-k)*16));for(let S=0;S<M;S++){const A=k+(y-k)*S/M,E=k+(y-k)*(S+1)/M;d+=(_n(i,E,n)-_n(i,A,n))*c((A+E)/2)}}return{beat:y,travel:d}}),p=n.start??0,g=n.x??0;return{id:`${e}-x`,target:e,property:"x",keyframes:m.map(y=>({time:p+y.beat*6e4/s,value:g+n.height*y.travel,easing:"linear"}))}}function Ed(e,t,n=0){return(e-n)*t/6e4}function Ad(e,t={}){return n=>xn(e,n,t)}function xd(e,t){const n=t.start??0,i=6e4/t.bpm,s=n+t.beats*i,r=Math.min((t.fade??1)*i,(s-n)/2);return[{id:`${e}-beat`,target:e,property:"beat",keyframes:[{time:n,value:0},{time:s,value:t.beats,easing:"linear"}]},{id:`${e}-dancing`,target:e,property:"dancing",keyframes:[{time:n,value:0},{time:n+r,value:1,easing:"ease-in-out"},{time:s-r,value:1},{time:s,value:0,easing:"ease-in-out"}]}]}function Pd(e,t,n={}){const i=typeof t=="string"?Ot[t]:t,s=n.bpm??i.bpm,r=n.beats??(n.move?i.moves[n.move].beats:Pn(i)),o=n.samplesPerBeat??4,a=n.start??0,l=Math.round(r*o),c=Array.from({length:l+1},(p,g)=>{const y=g/o;return{time:a+y*6e4/s,frame:xn(i,y,n)}}),h=(p,g)=>({id:`${e}-${p}`,target:e,property:p,keyframes:c.map(y=>({time:y.time,value:g(y.frame)}))}),f=Object.keys(W).filter(p=>c.some(g=>g.frame.pose[p]!==c[0].frame.pose[p])||c[0].frame.pose[p]!==W[p]).map(p=>h(p,g=>g.pose[p])),d=n.height===void 0?void 0:qa(e,i,{...n,bpm:s,beats:r,start:a,height:n.height,fade:0});if(d&&f.push(d),n.hands===!1)return f;const m=[];for(const p of["left","right"])for(const g of Object.keys(Y)){const y=w=>w.hands?.[p]?.[g]??Y[g];c.some(w=>y(w.frame)!==Y[g])&&m.push(h(Be(p,g),y))}return[...f,...m]}const Ne={type:"back",mode:"out",overshoot:1.1},Z="ease-out-cubic",_d={label:"Disco",bpm:120,stance:{leftHip:10,rightHip:10,leftKnee:6,rightKnee:6},expression:{smile:.9,mouth:.15,leftBrow:.3,rightBrow:.3},groove:{bounce:10,accent:"down",sway:2},moves:{point:{label:"The point",beats:2,easing:Z,keys:[{beat:0,pose:{rightShoulder:150,rightElbow:0,rightWrist:0,leftShoulder:40,leftElbow:-105,leftWrist:-20,lean:-5,headTilt:8,rightHip:18,leftHip:6,lookX:.6,lookY:-.7},hands:{right:"point",left:"fist"}},{beat:1,pose:{rightShoulder:-30,rightWrist:10,lean:5,headTilt:-6,rightHip:6,leftHip:18,lookX:-.4,lookY:.6}}]},roll:{label:"Roll the arms",beats:2,easing:"linear",keys:[{beat:0,pose:{leftShoulder:42,leftElbow:-128,rightShoulder:26,rightElbow:-100,rightHip:18,leftHip:6,lean:-3},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{leftShoulder:26,leftElbow:-100,rightShoulder:42,rightElbow:-128}},{beat:1,pose:{leftShoulder:42,leftElbow:-128,rightShoulder:26,rightElbow:-100,rightHip:6,leftHip:18,lean:3}},{beat:1.5,pose:{leftShoulder:26,leftElbow:-100,rightShoulder:42,rightElbow:-128}}]},bump:{label:"Bump and clap",beats:4,keys:[{beat:0,pose:{lean:-10,rightHip:22,leftHip:4,leftShoulder:140,rightShoulder:140,leftElbow:0,rightElbow:0,leftWrist:20,rightWrist:20},hands:{left:"spread",right:"spread"},easing:Z},{beat:1,pose:{lean:0,rightHip:10,leftHip:10,leftShoulder:168,rightShoulder:168,leftElbow:22,rightElbow:22,leftWrist:0,rightWrist:0},hands:{left:"flat",right:"flat"}},{beat:2,pose:{lean:10,rightHip:4,leftHip:22,leftShoulder:140,rightShoulder:140,leftElbow:0,rightElbow:0,leftWrist:20,rightWrist:20},hands:{left:"spread",right:"spread"},easing:Z},{beat:3,pose:{lean:0,rightHip:10,leftHip:10,leftShoulder:168,rightShoulder:168,leftElbow:22,rightElbow:22,leftWrist:0,rightWrist:0},hands:{left:"flat",right:"flat"}}]}},routine:[{move:"point",beats:8},{move:"roll",beats:4},{move:"point",beats:8,mirror:!0},{move:"bump",beats:8}]},Id={label:"Hip hop",bpm:95,stance:{leftHip:14,rightHip:14,leftKnee:20,rightKnee:20,leftShoulder:22,rightShoulder:22,leftElbow:-30,rightElbow:-30,leftFootOut:.15,rightFootOut:.15},expression:"smug",hands:{left:"relaxed",right:"relaxed"},groove:{bounce:18,accent:"down"},moves:{bounce:{label:"Bounce",beats:2,keys:[{beat:0,pose:{leftShoulder:30,rightShoulder:30,leftElbow:-50,rightElbow:-50,lean:-3,headTilt:-5,leftWrist:-20,rightWrist:-20}},{beat:1,pose:{leftShoulder:14,rightShoulder:14,leftElbow:-18,rightElbow:-18,lean:3,headTilt:5,leftWrist:0,rightWrist:0}}]},runningMan:{label:"Running man",beats:2,keys:[{beat:0,reset:!0,pose:{turn:.85,leftHip:-84,leftKnee:-112,leftAnkle:25,rightHip:-26,rightKnee:8,leftShoulder:35,leftElbow:-50,rightShoulder:45,rightElbow:75,lean:6},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{leftHip:-4,leftKnee:-18,leftAnkle:0,rightHip:4,rightKnee:18,leftShoulder:5,leftElbow:-40,rightShoulder:5,rightElbow:40}},{beat:1,pose:{rightHip:84,rightKnee:112,rightAnkle:25,leftHip:26,leftKnee:-8,rightShoulder:-35,rightElbow:50,leftShoulder:-45,leftElbow:-75}},{beat:1.5,pose:{rightHip:4,rightKnee:18,rightAnkle:0,leftHip:-4,leftKnee:-18,rightShoulder:-5,rightElbow:40,leftShoulder:-5,leftElbow:-40}}]},armWave:{label:"Arm wave",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:90,rightShoulder:90,leftElbow:0,rightElbow:0},hands:{left:"flat",right:"flat"}},{beat:.5,pose:{leftWrist:45,leftElbow:-15}},{beat:1,pose:{leftWrist:-35,leftElbow:40,leftShoulder:84}},{beat:1.5,pose:{leftWrist:0,leftElbow:-10,leftShoulder:102,headTilt:-8}},{beat:2,pose:{leftElbow:0,leftShoulder:90,rightShoulder:102,headTilt:8}},{beat:2.5,pose:{rightShoulder:84,rightElbow:40,headTilt:0}},{beat:3,pose:{rightElbow:-15,rightWrist:45}},{beat:3.5,pose:{rightElbow:0,rightWrist:-35}}]}},routine:[{move:"bounce",beats:8},{move:"runningMan",beats:8},{move:"armWave",beats:8},{move:"bounce",beats:4}]},Cd={label:"Breaking (toprock)",bpm:110,stance:{leftHip:14,rightHip:14,leftKnee:14,rightKnee:14,leftShoulder:35,rightShoulder:35,leftElbow:-90,rightElbow:-90},expression:{smile:.3,leftBrow:-.3,rightBrow:-.3,browTilt:-.3},hands:{left:"fist",right:"fist"},groove:{bounce:8,accent:"down"},moves:{toprock:{label:"Toprock (Indian step)",beats:4,keys:[{beat:0,pose:{rightHip:-24,rightKnee:10,leftHip:10,leftShoulder:80,leftElbow:40,rightShoulder:55,rightElbow:-50,lean:6,headTilt:-6},easing:Z},{beat:1,reset:!0,pose:{leftHip:18,rightHip:18}},{beat:2,pose:{leftHip:-24,leftKnee:10,rightHip:10,rightShoulder:80,rightElbow:40,leftShoulder:55,leftElbow:-50,lean:-6,headTilt:6},easing:Z},{beat:3,reset:!0,pose:{leftHip:18,rightHip:18}}]},kick:{label:"Kick out",beats:2,keys:[{beat:0,pose:{rightHip:72,rightKnee:4,rightAnkle:-20,leftHip:4,lean:-12,leftShoulder:100,leftElbow:20},easing:Z},{beat:1,reset:!0}]},freeze:{label:"B-boy stance",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:26,leftElbow:-122,rightShoulder:22,rightElbow:-118,leftHip:18,rightHip:18,leftKnee:6,rightKnee:6,lean:-4,headTilt:10,smile:.6,leftEye:.6,rightEye:.6},easing:Ne},{beat:2,pose:{headTilt:14,lean:-6}}]}},routine:[{move:"toprock",beats:8},{move:"kick",beats:4},{move:"toprock",beats:8},{move:"kick",beats:4,mirror:!0},{move:"freeze",beats:4}]},Hd={label:"Jazz",bpm:130,stance:{leftHip:10,rightHip:10},expression:{mouth:.55,smile:1,mouthWidth:1.2,leftBrow:.6,rightBrow:.6},hands:{left:"spread",right:"spread"},groove:{bounce:6,accent:"up"},moves:{jazzHands:{label:"Jazz hands",beats:2,easing:"linear",keys:[0,.25,.5,.75,1,1.25,1.5,1.75].map((e,t)=>({beat:e,pose:{leftShoulder:128,rightShoulder:128,leftElbow:8,rightElbow:8,leftWrist:t%2?4:26,rightWrist:t%2?26:4,leftHip:16,rightHip:16,leftKnee:e<1?26:8,rightKnee:e<1?26:8},hands:t===0?{left:{...U.spread,turn:2},right:{...U.spread,turn:2}}:void 0}))},kickBallChange:{label:"Kick ball change",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:88,rightKnee:0,rightAnkle:55,leftHip:4,lean:-12,leftShoulder:112,rightShoulder:112,leftWrist:15,rightWrist:15},hands:{left:"flat",right:"flat"},easing:Z},{beat:1,reset:!0,pose:{rightHip:10,rightKnee:24,rightAnkle:45,leftShoulder:60,rightShoulder:60,leftElbow:-20,rightElbow:-20}},{beat:1.5,pose:{rightAnkle:0,rightKnee:6,leftAnkle:45,leftKnee:20}}]},splitDrop:{label:"Drop into the splits",beats:8,keys:[{beat:0,reset:!0},{beat:2,reset:!0,pose:{leftHip:90,rightHip:90,leftKnee:0,rightKnee:0,leftAnkle:-45,rightAnkle:-45,leftShoulder:125,rightShoulder:125,leftElbow:10,rightElbow:10},easing:"ease-in-out-cubic"},{beat:4,pose:{leftShoulder:95,rightShoulder:95,leftElbow:0,rightElbow:0,leftWrist:50,rightWrist:50,headTilt:8}},{beat:6,reset:!0,pose:{leftHip:30,rightHip:30,leftKnee:60,rightKnee:60,leftShoulder:40,rightShoulder:40},easing:"ease-in-out-cubic"},{beat:7.5,reset:!0}]},jazzSquare:{label:"Jazz square",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:-18,leftHip:8,leftShoulder:38,rightShoulder:46,leftElbow:100,rightElbow:96,lean:4},hands:{left:"pinch",right:"pinch"}},{beat:1,pose:{leftHip:18,rightHip:6,leftShoulder:46,rightShoulder:38,lean:-4}},{beat:2,pose:{rightHip:22,leftHip:6,leftShoulder:38,rightShoulder:46,lean:4}},{beat:3,pose:{leftHip:10,rightHip:10,leftShoulder:46,rightShoulder:38,lean:0}}]}},routine:[{move:"jazzHands",beats:4},{move:"kickBallChange",beats:4},{move:"kickBallChange",beats:4,mirror:!0},{move:"jazzSquare",beats:8},{move:"jazzHands",beats:4},{move:"splitDrop",beats:8}]},$d={label:"K-pop",bpm:125,stance:{leftHip:9,rightHip:9,leftKnee:4,rightKnee:4},expression:"happy",groove:{bounce:5,accent:"down"},moves:{pointCombo:{label:"Point combo",beats:4,easing:Ne,keys:[{beat:0,reset:!0,pose:{rightShoulder:142,rightElbow:0,leftShoulder:25,leftElbow:-125,headTilt:6,lean:-3,lookX:.6,lookY:-.6},hands:{right:"point",left:"flat"}},{beat:1,pose:{rightShoulder:-38,headTilt:-6,lean:3,lookX:-.3,lookY:.5,rightHip:18}},{beat:2,reset:!0,pose:{leftShoulder:36,leftElbow:-96,rightShoulder:36,rightElbow:-96,leftWrist:20,rightWrist:20},hands:{left:"fist",right:"fist"}},{beat:3,reset:!0,pose:{leftShoulder:96,rightShoulder:96,leftElbow:0,rightElbow:0,leftWrist:50,rightWrist:50,headTilt:8,leftHip:18,rightHip:18},hands:{left:"flat",right:"flat"}}]},heart:{label:"Big heart, finger heart",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:165,rightShoulder:165,leftElbow:46,rightElbow:46,headTilt:-8,lean:-4},hands:{left:"cupped",right:"cupped"},easing:Ne},{beat:1,pose:{headTilt:8,lean:4}},{beat:2,reset:!0,pose:{rightShoulder:32,rightElbow:112,rightWrist:10,leftShoulder:20,leftElbow:-30,headTilt:10,leftEye:0,smile:1},hands:{right:"pinch",left:"relaxed"},easing:Ne},{beat:3,pose:{headTilt:4}}]},isolations:{label:"Isolations",beats:2,easing:Z,keys:[{beat:0,reset:!0,pose:{lean:-9,headTilt:11,leftShoulder:55,leftElbow:-112,rightShoulder:55,rightElbow:-112,rightHip:18},hands:{left:"fist",right:"fist"}},{beat:.5,pose:{lean:0,headTilt:0,rightHip:9}},{beat:1,pose:{lean:9,headTilt:-11,leftHip:18}},{beat:1.5,pose:{lean:0,headTilt:0,leftHip:9}}]}},routine:[{move:"pointCombo",beats:8},{move:"isolations",beats:4},{move:"heart",beats:8},{move:"pointCombo",beats:8,mirror:!0},{move:"isolations",beats:4}]},Rd={label:"Bollywood",bpm:120,stance:{leftHip:10,rightHip:10},expression:{smile:1,mouth:.3,leftBrow:.4,rightBrow:.4},groove:{bounce:8,accent:"down",sway:3},moves:{lightBulb:{label:"Screw the bulb, pat the dog",beats:2,keys:[{beat:0,reset:!0,pose:{rightShoulder:160,rightElbow:12,rightWrist:-15,leftShoulder:40,leftElbow:-12,leftWrist:-45,lean:-4,rightHip:16,lookX:.5,lookY:-.6},hands:{right:{...U.cupped,roll:-30},left:{...U.flat,turn:0}}},{beat:.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...U.cupped,roll:30}}},{beat:1,pose:{rightWrist:-15,rightElbow:12,leftWrist:-45,lean:-4,rightHip:16,leftHip:6},hands:{right:{...U.cupped,roll:-30}}},{beat:1.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...U.cupped,roll:30}}}]},thumka:{label:"Thumka",beats:2,keys:[{beat:0,reset:!0,pose:{lean:-11,rightHip:22,leftHip:2,leftKnee:14,rightShoulder:45,rightElbow:-105,leftShoulder:128,leftElbow:18,leftWrist:35,headTilt:10,lookX:-.5},hands:{right:"fist",left:{...U.open,turn:2}},easing:Z},{beat:.5,pose:{lean:-4,rightHip:12,headTilt:6}},{beat:1,pose:{lean:-11,rightHip:22,headTilt:10},easing:Z},{beat:1.5,pose:{lean:-4,rightHip:12,headTilt:6}}]},flick:{label:"Cross and flick",beats:4,keys:[{beat:0,reset:!0,pose:{leftShoulder:22,rightShoulder:22,leftElbow:-62,rightElbow:-62,leftHip:16,rightHip:16,leftKnee:26,rightKnee:26},hands:{left:"fist",right:"fist"}},{beat:1,pose:{leftShoulder:132,rightShoulder:132,leftElbow:0,rightElbow:0,leftWrist:30,rightWrist:30,leftKnee:0,rightKnee:0,leftHip:10,rightHip:10,stretch:1.03},hands:{left:"spread",right:"spread"},easing:Z},{beat:2,pose:{leftShoulder:22,rightShoulder:22,leftElbow:-62,rightElbow:-62,leftWrist:0,rightWrist:0,leftHip:16,rightHip:16,leftKnee:26,rightKnee:26,stretch:1},hands:{left:"fist",right:"fist"}},{beat:3,pose:{leftShoulder:62,rightShoulder:62,leftElbow:0,rightElbow:0,leftWrist:35,rightWrist:35,leftKnee:0,rightKnee:0,leftHip:10,rightHip:10},hands:{left:"spread",right:"spread"},easing:Z}]}},routine:[{move:"thumka",beats:4},{move:"lightBulb",beats:8},{move:"flick",beats:8},{move:"thumka",beats:4,mirror:!0},{move:"lightBulb",beats:8,mirror:!0}]},Od={label:"Bhangra",bpm:100,stance:{leftShoulder:150,rightShoulder:150,leftElbow:18,rightElbow:18,leftHip:10,rightHip:10},expression:{mouth:.6,smile:1,mouthWidth:1.2,leftBrow:.5,rightBrow:.5},hands:{left:"open",right:"open"},groove:{bounce:12,accent:"down"},moves:{basic:{label:"Bhangra step",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:58,rightKnee:104,rightAnkle:30,leftShoulder:162,rightShoulder:140,headTilt:7}},{beat:.5,reset:!0,pose:{stretch:.98}},{beat:1,reset:!0,pose:{leftHip:58,leftKnee:104,leftAnkle:30,rightShoulder:162,leftShoulder:140,headTilt:-7}},{beat:1.5,reset:!0,pose:{stretch:.98}}]},dhamaal:{label:"Dhamaal (jump, arms up)",beats:2,keys:[{beat:0,reset:!0,pose:{leftHip:20,rightHip:20,leftKnee:40,rightKnee:40,stretch:.94}},{beat:.5,reset:!0,pose:{rise:.07,stretch:1.06,leftHip:6,rightHip:6,leftAnkle:45,rightAnkle:45,leftShoulder:172,rightShoulder:172,leftElbow:0,rightElbow:0},hands:{left:"point",right:"point"},easing:"ease-out-quad"},{beat:1,reset:!0,pose:{leftHip:20,rightHip:20,leftKnee:40,rightKnee:40,stretch:.94},hands:{left:"open",right:"open"},easing:"ease-in-quad"},{beat:1.5,reset:!0,pose:{rise:.07,stretch:1.06,leftHip:6,rightHip:6,leftAnkle:45,rightAnkle:45,leftShoulder:172,rightShoulder:172,leftElbow:0,rightElbow:0},hands:{left:"point",right:"point"},easing:"ease-out-quad"}]}},routine:[{move:"basic",beats:8},{move:"dhamaal",beats:4},{move:"basic",beats:8},{move:"dhamaal",beats:4}]},Ld={label:"Bharatanatyam",bpm:80,stance:{...{leftHip:42,rightHip:42,leftKnee:82,rightKnee:82,leftFootOut:.3,rightFootOut:.3},leftShoulder:90,rightShoulder:90,leftElbow:0,rightElbow:0,leftWrist:75,rightWrist:75},expression:{smile:.5,leftEye:1.2,rightEye:1.2,leftBrow:.3,rightBrow:.3},hands:{left:"pataka",right:"pataka"},groove:{bounce:0},moves:{tatta:{label:"Tatta adavu (stamps)",beats:2,keys:[{beat:0,reset:!0,pose:{rightHip:48,rightKnee:104,rightAnkle:-18}},{beat:.3,reset:!0,easing:"ease-in-quad",taps:["rightToe","rightHeel"]},{beat:1,reset:!0,pose:{leftHip:48,leftKnee:104,leftAnkle:-18}},{beat:1.3,reset:!0,easing:"ease-in-quad",taps:["leftToe","leftHeel"]}]},natta:{label:"Natta adavu (stretch and look)",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:52,rightKnee:0,rightAnkle:-40,rightShoulder:125,rightWrist:60,leftShoulder:25,leftElbow:-125,leftWrist:0,headTilt:8,lookX:.9,lookY:-.4,lean:-6}},{beat:1,reset:!0},{beat:2,reset:!0,pose:{leftHip:52,leftKnee:0,leftAnkle:-40,leftShoulder:125,leftWrist:60,rightShoulder:25,rightElbow:-125,rightWrist:0,headTilt:-8,lookX:-.9,lookY:-.4,lean:6}},{beat:3,reset:!0}]},alapadma:{label:"Alapadma (lotus) to the sky",beats:4,keys:[{beat:0,reset:!0,pose:{rightShoulder:145,rightElbow:20,rightWrist:30,leftShoulder:28,leftElbow:-125,leftWrist:0,lookX:.7,lookY:-.9,headTilt:6},hands:{right:"alapadma",left:"pataka"}},{beat:1,pose:{rightWrist:55,headTilt:9}},{beat:2,reset:!0,pose:{leftShoulder:145,leftElbow:20,leftWrist:30,rightShoulder:28,rightElbow:-125,rightWrist:0,lookX:-.7,lookY:-.9,headTilt:-6},hands:{left:"alapadma",right:"pataka"}},{beat:3,pose:{leftWrist:55,headTilt:-9}}]}},routine:[{move:"tatta",beats:8},{move:"natta",beats:8},{move:"alapadma",beats:8},{move:"tatta",beats:4}]},Fd={label:"Charleston",bpm:150,stance:{leftHip:10,rightHip:10,leftKnee:10,rightKnee:10,leftShoulder:30,rightShoulder:30,leftElbow:20,rightElbow:20},expression:{mouth:.4,smile:1,leftBrow:.5,rightBrow:.5},hands:{left:{...U.spread,turn:2},right:{...U.spread,turn:2}},groove:{bounce:8,accent:"down"},moves:{basic:{label:"Kick forward, kick back",beats:4,keys:[{beat:0,reset:!0,pose:{rightHip:48,rightKnee:8,rightAnkle:45,leftShoulder:75,rightShoulder:15,leftElbow:30,rightElbow:-10,lean:-7,headTilt:-5},easing:Z},{beat:1,reset:!0},{beat:2,reset:!0,pose:{leftHip:18,leftKnee:85,leftAnkle:35,rightShoulder:75,leftShoulder:15,rightElbow:30,leftElbow:-10,lean:7,headTilt:5},easing:Z},{beat:3,reset:!0}]},twist:{label:"Swivel (heels in, heels out)",beats:2,keys:[{beat:0,reset:!0,pose:{leftFootOut:-.9,rightFootOut:-.9,leftHip:4,rightHip:4,leftKnee:4,rightKnee:4,leftAnkle:-10,rightAnkle:-10,leftShoulder:18,rightShoulder:48,leftElbow:-10,rightElbow:50}},{beat:.5,pose:{leftFootOut:.6,rightFootOut:.6,leftHip:16,rightHip:16,leftKnee:22,rightKnee:22,leftAnkle:10,rightAnkle:10,leftShoulder:48,rightShoulder:18,leftElbow:50,rightElbow:-10}},{beat:1,pose:{leftFootOut:-.9,rightFootOut:-.9,leftHip:4,rightHip:4,leftKnee:4,rightKnee:4,leftAnkle:-10,rightAnkle:-10,leftShoulder:18,rightShoulder:48,leftElbow:-10,rightElbow:50}},{beat:1.5,pose:{leftFootOut:.6,rightFootOut:.6,leftHip:16,rightHip:16,leftKnee:22,rightKnee:22,leftAnkle:10,rightAnkle:10,leftShoulder:48,rightShoulder:18,leftElbow:50,rightElbow:-10}}]},kneeCross:{label:"Crossing knees",beats:2,keys:[{beat:0,reset:!0,pose:{leftHip:-6,rightHip:-6,leftKnee:-16,rightKnee:-16,leftFootOut:-.4,rightFootOut:-.4,leftShoulder:-12,rightShoulder:-12,leftElbow:0,rightElbow:0,lean:0,lookY:.6}},{beat:.5,pose:{leftHip:18,rightHip:18,leftKnee:28,rightKnee:28,leftFootOut:.3,rightFootOut:.3,leftShoulder:16,rightShoulder:16,lookY:0}},{beat:1,pose:{leftHip:-6,rightHip:-6,leftKnee:-16,rightKnee:-16,leftFootOut:-.4,rightFootOut:-.4,leftShoulder:-12,rightShoulder:-12,lookY:.6}},{beat:1.5,pose:{leftHip:18,rightHip:18,leftKnee:28,rightKnee:28,leftFootOut:.3,rightFootOut:.3,leftShoulder:16,rightShoulder:16,lookY:0}}]}},routine:[{move:"basic",beats:8},{move:"twist",beats:8},{move:"kneeCross",beats:8},{move:"basic",beats:8,mirror:!0},{move:"twist",beats:4}]},Dd={label:"Tap",bpm:120,stance:{turn:.8,leftHip:-3,rightHip:3,leftKnee:-10,rightKnee:10,leftShoulder:12,rightShoulder:12,leftElbow:-40,rightElbow:40,leftWrist:-15,rightWrist:15,lean:4},expression:{smile:.9,mouth:.2,leftBrow:.3,rightBrow:.3,lookY:.3},hands:{left:"relaxed",right:"relaxed"},groove:{bounce:6,accent:"down"},moves:{shuffleBallChange:{label:"Shuffle ball change",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:34,rightKnee:8,rightAnkle:30,leftShoulder:30,rightShoulder:-10},taps:["rightToe"]},{beat:.25,pose:{rightHip:24,rightKnee:62,rightAnkle:40},taps:["rightToe"]},{beat:.5,pose:{rightHip:-8,rightKnee:14,rightAnkle:50,leftAnkle:15,leftShoulder:12,rightShoulder:12},taps:["rightToe"]},{beat:.75,pose:{rightHip:3,rightKnee:10,rightAnkle:0,leftAnkle:0},taps:["leftHeel"]},{beat:1,reset:!0,pose:{leftHip:-34,leftKnee:-8,leftAnkle:30,rightShoulder:-30,leftShoulder:10},taps:["leftToe"]},{beat:1.25,pose:{leftHip:-24,leftKnee:-62,leftAnkle:40},taps:["leftToe"]},{beat:1.5,pose:{leftHip:8,leftKnee:-14,leftAnkle:50,rightAnkle:15,leftShoulder:12,rightShoulder:12},taps:["leftToe"]},{beat:1.75,pose:{leftHip:-3,leftKnee:-10,leftAnkle:0,rightAnkle:0},taps:["rightHeel"]}]},timeStep:{label:"Single time step",beats:4,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:8,rightKnee:4,rightAnkle:0,leftShoulder:25,rightShoulder:-20},taps:["rightToe","rightHeel"]},{beat:.5,pose:{rightHip:34,rightKnee:8,rightAnkle:30},taps:["rightToe"]},{beat:.75,pose:{rightHip:22,rightKnee:62,rightAnkle:40},taps:["rightToe"]},{beat:1,pose:{rise:.05,leftAnkle:45,leftKnee:-4,leftHip:-2,rightHip:26,rightKnee:70,stretch:1.03}},{beat:1.25,pose:{rise:0,leftAnkle:0,leftKnee:-14,stretch:1},taps:["leftToe"]},{beat:1.5,pose:{rightHip:4,rightKnee:12,rightAnkle:0,rightShoulder:25,leftShoulder:-20},taps:["rightToe"]},{beat:2,pose:{leftHip:-30,leftKnee:-6,leftAnkle:35},taps:["leftToe"]},{beat:2.25,pose:{leftHip:-4,leftKnee:-12,leftAnkle:0},taps:["leftToe"]},{beat:3,pose:{rightHip:10,rightAnkle:35,rightKnee:18,leftShoulder:12,rightShoulder:12},taps:["rightToe"]},{beat:3.5,pose:{rightHip:3,rightKnee:10,rightAnkle:0}}]},heelToe:{label:"Heel toe",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:26,rightKnee:0,rightAnkle:-35,leftShoulder:30,rightShoulder:-20},taps:["rightHeel"]},{beat:.5,pose:{rightHip:-16,rightKnee:24,rightAnkle:55,leftShoulder:-15,rightShoulder:25},taps:["rightToe"]},{beat:1,reset:!0,pose:{leftHip:-26,leftKnee:0,leftAnkle:-35,rightShoulder:-30,leftShoulder:20},taps:["leftHeel"]},{beat:1.5,pose:{leftHip:16,leftKnee:-24,leftAnkle:55,rightShoulder:15,leftShoulder:-25},taps:["leftToe"]}]},crampRoll:{label:"Cramp roll",beats:2,easing:"ease-out-quad",keys:[{beat:0,reset:!0,pose:{rightHip:12,rightKnee:26,leftHip:-12,leftKnee:-26}},{beat:.5,pose:{rightAnkle:40,rise:.02},taps:["rightToe"]},{beat:.625,pose:{leftAnkle:40},taps:["leftToe"]},{beat:.75,pose:{rightAnkle:0,rise:0},taps:["rightHeel"]},{beat:.875,pose:{leftAnkle:0},taps:["leftHeel"]},{beat:1,pose:{rightShoulder:135,leftShoulder:125,leftElbow:0,rightElbow:0,leftWrist:0,rightWrist:30,rightKnee:8,leftKnee:-8,rightHip:4,leftHip:-4},hands:{left:{...U.spread,turn:2},right:{...U.spread,turn:2}}},{beat:1.75,reset:!0}]}},routine:[{move:"shuffleBallChange",beats:8},{move:"timeStep",beats:4},{move:"timeStep",beats:4,mirror:!0},{move:"heelToe",beats:8},{move:"crampRoll",beats:4}]},Ot={disco:_d,hipHop:Id,breaking:Cd,jazz:Hd,kpop:$d,bollywood:Rd,bhangra:Od,bharatanatyam:Ld,charleston:Fd,tap:Dd,popping:{label:"Popping (glides, moonwalk)",bpm:100,stance:{leftHip:9,rightHip:9,leftShoulder:16,rightShoulder:16,leftElbow:-24,rightElbow:-24},expression:{smile:.35,leftEye:.85,rightEye:.85,leftBrow:-.2,rightBrow:-.2},hands:{left:"relaxed",right:"relaxed"},groove:{bounce:0},moves:{sideGlide:{label:"Side glide",beats:2,easing:"linear",travel:.2,keys:[{beat:0,reset:!0,pose:{leftHip:11,leftKnee:0,leftAnkle:0,rightHip:36,rightKnee:45,rightAnkle:45,rightShoulder:80,rightElbow:-10,rightWrist:10,leftShoulder:28,leftElbow:18,lean:-2,headTilt:4,lookX:.7},hands:{right:"flat",left:"relaxed"}},{beat:1,pose:{leftHip:27,leftKnee:54,leftAnkle:45,rightHip:-1,rightKnee:0,rightAnkle:0,rightShoulder:74,rightWrist:-10,lean:2}}]},moonwalk:{label:"Moonwalk",beats:2,easing:"linear",travel:-.29,keys:[{beat:0,reset:!0,pose:{turn:.9,lean:4,headTilt:-4,leftHip:-12,leftKnee:0,leftAnkle:0,rightHip:23,rightKnee:57,rightAnkle:45,leftShoulder:-10,leftElbow:-45,rightShoulder:14,rightElbow:50}},{beat:1,pose:{leftHip:-23,leftKnee:-57,leftAnkle:45,rightHip:12,rightKnee:0,rightAnkle:0,leftShoulder:-14,leftElbow:-50,rightShoulder:10,rightElbow:45}}]},forwardGlide:{label:"Forward glide",beats:2,easing:"linear",travel:.29,keys:[{beat:0,reset:!0,pose:{turn:.9,lean:2,leftHip:16,leftKnee:0,leftAnkle:0,rightHip:33,rightKnee:59,rightAnkle:45,leftShoulder:12,leftElbow:-40,rightShoulder:-12,rightElbow:40}},{beat:1,pose:{leftHip:-33,leftKnee:-59,leftAnkle:45,rightHip:-16,rightKnee:0,rightAnkle:0,leftShoulder:-12,leftElbow:-40,rightShoulder:12,rightElbow:40}}]},toeStand:{label:"Toe stand",beats:4,keys:[{beat:0,reset:!0,pose:{leftHip:6,rightHip:6,leftKnee:0,rightKnee:0,leftAnkle:65,rightAnkle:65,rightShoulder:150,rightElbow:75,leftShoulder:30,leftElbow:20,headTilt:-10,lookY:.4},hands:{right:"fist",left:"fist"},easing:Ne},{beat:2,pose:{headTilt:-14,lean:-2}}]}},routine:[{move:"sideGlide",beats:4},{move:"sideGlide",beats:4,mirror:!0},{move:"moonwalk",beats:8},{move:"forwardGlide",beats:8},{move:"toeStand",beats:4}]}},In=e=>Math.min(1,Math.max(0,e));function Bd(e){const t={...W,turn:e.view},n=[];for(const i of e.keys){const s=n[n.length-1],r=!s||i.reset?t:s.pose;n.push({at:i.at,pose:{...r,...i.pose},easing:i.easing})}return n}function Nd(e){return e-Wd*Math.sin(2*Math.PI*e)/(2*Math.PI)}const Wd=.5;function Kd(e,t){if(!(t<=e.takeoff||t>=e.landing))return(t-e.takeoff)/(e.landing-e.takeoff)}function Va(e,t){const n=typeof e=="string"?Hn[e]:e,i=Bd(n),s=In(t);let r=0;for(let u=0;u<i.length;u++)i[u].at<=s&&(r=u);const o=i[r],a=i[Math.min(r+1,i.length-1)],l=a.at>o.at?(s-o.at)/(a.at-o.at):0,c=re(o.pose,a.pose,J(a.easing??"ease-in-out")(In(l))),h=Kd(n,s);return h===void 0?{...c,spin:0,rise:0}:{...c,spin:n.spin*Nd(h),rise:4*n.height*h*(1-h)}}function Ua(e,t,n){const i=typeof e=="string"?Hn[e]:e,s=In(t),r=In((s-i.takeoff)/(i.landing-i.takeoff));return i.travel*n*r}function Yd(e,t,n={}){const i=typeof t=="string"?Hn[t]:t,s=n.start??0,r=n.duration??i.duration,o=n.samples??48,a=Array.from({length:o+1},(h,u)=>{const f=u/o;return{time:s+f*r,progress:f,pose:Va(i,f)}}),c=Object.keys(W).filter(h=>a.some(u=>u.pose[h]!==W[h])).map(h=>({id:`${e}-${h}`,target:e,property:h,keyframes:a.map(u=>({time:u.time,value:u.pose[h]}))}));if(n.height!==void 0&&i.travel!==0){const h=(n.facing??1)<0?-1:1;c.push({id:`${e}-x`,target:e,property:"x",keyframes:a.map(u=>({time:u.time,value:(n.x??0)+h*Ua(i,u.progress,n.height)}))})}return c}const Xd={leftHip:-55,leftKnee:-95,rightHip:55,rightKnee:95,leftShoulder:45,rightShoulder:-45,leftElbow:10,rightElbow:-10,lean:22,stretch:.94,headTilt:6},qd={leftHip:0,leftKnee:0,rightHip:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:-172,rightShoulder:172,leftElbow:0,rightElbow:0,lean:0,stretch:1.08,headTilt:0},Cn={leftHip:-128,leftKnee:-152,rightHip:128,rightKnee:152,leftAnkle:30,rightAnkle:30,leftShoulder:-78,rightShoulder:78,leftElbow:-48,rightElbow:48,lean:26,stretch:1,headTilt:14},Vd={leftHip:-22,leftKnee:-30,rightHip:22,rightKnee:30,leftAnkle:10,rightAnkle:10,leftShoulder:-125,rightShoulder:125,leftElbow:0,rightElbow:0,lean:8,headTilt:0},Ud={leftHip:-58,leftKnee:-100,rightHip:58,rightKnee:100,leftAnkle:0,rightAnkle:0,leftShoulder:-80,rightShoulder:80,leftElbow:-10,rightElbow:10,lean:20,stretch:.93};function oe(e,t,n,i,s,r=1300){return{label:e,view:1,spin:t,height:n,travel:i,takeoff:.27,landing:.8,duration:r,keys:[{at:0,reset:!0},{at:.16,pose:Xd},{at:.27,pose:qd,easing:"ease-out-quad"},...s,{at:.76,pose:Vd},{at:.86,pose:Ud,easing:"ease-out-quad"},{at:1,reset:!0}]}}const Hn={frontFlip:oe("Front flip (tuck)",360,.56,.35,[{at:.38,pose:Cn,easing:"ease-out-cubic"},{at:.64,pose:Cn}]),backFlip:oe("Back flip (tuck)",-360,.58,-.15,[{at:.36,pose:{...Cn,lean:18},easing:"ease-out-cubic"},{at:.64,pose:{...Cn,lean:18}}]),layout:oe("Back layout (straight body)",-360,.66,-.2,[{at:.4,pose:{leftHip:8,rightHip:-8,leftKnee:0,rightKnee:0,leftAnkle:60,rightAnkle:60,leftShoulder:-178,rightShoulder:178,lean:-18,headTilt:-14}},{at:.64,pose:{leftHip:-4,rightHip:4,lean:-6,headTilt:-4,leftShoulder:-150,rightShoulder:150}}],1400),scissorFlip:oe("Scissor flip",360,.6,.45,[{at:.36,pose:{leftHip:-105,leftKnee:0,rightHip:-40,rightKnee:-20,leftAnkle:50,rightAnkle:50,leftShoulder:-150,rightShoulder:150,leftElbow:0,rightElbow:0,lean:12},easing:"ease-out-cubic"},{at:.52,pose:{leftHip:40,leftKnee:20,rightHip:105,rightKnee:0,leftShoulder:-140,rightShoulder:140}},{at:.66,pose:{leftHip:-30,leftKnee:-20,rightHip:30,rightKnee:20,leftShoulder:-110,rightShoulder:110,lean:6}}]),sideFlip:{label:"Side flip (tuck)",view:0,spin:360,height:.55,travel:.4,takeoff:.27,landing:.8,duration:1300,keys:[{at:0,reset:!0},{at:.16,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftShoulder:20,rightShoulder:20,lean:-10,stretch:.94}},{at:.27,pose:{leftHip:4,rightHip:4,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:165,rightShoulder:165,lean:6,stretch:1.08},easing:"ease-out-quad"},{at:.38,pose:{leftHip:105,rightHip:105,leftKnee:135,rightKnee:135,leftShoulder:40,rightShoulder:40,leftElbow:-95,rightElbow:-95,lean:0,stretch:1,headTilt:10},easing:"ease-out-cubic"},{at:.64,pose:{}},{at:.76,pose:{leftHip:20,rightHip:20,leftKnee:20,rightKnee:20,leftAnkle:10,rightAnkle:10,leftShoulder:100,rightShoulder:100,leftElbow:0,rightElbow:0,headTilt:0}},{at:.86,pose:{leftHip:24,rightHip:24,leftKnee:48,rightKnee:48,leftAnkle:0,rightAnkle:0,leftShoulder:70,rightShoulder:70,stretch:.93},easing:"ease-out-quad"},{at:1,reset:!0}]},cartwheel:{label:"Cartwheel",view:0,spin:360,height:.155,travel:.9,takeoff:.2,landing:.86,duration:1600,keys:[{at:0,reset:!0},{at:.12,pose:{leftShoulder:165,rightShoulder:165,rightHip:30,rightKnee:0,lean:-6}},{at:.24,pose:{leftShoulder:172,rightShoulder:172,leftHip:55,rightHip:55,leftKnee:0,rightKnee:0,leftAnkle:40,rightAnkle:40,lean:0}},{at:.75,pose:{}},{at:.9,pose:{leftHip:30,rightHip:12,leftAnkle:0,rightAnkle:0,leftShoulder:150,rightShoulder:150}},{at:1,reset:!0}]},splitLeap:oe("Split leap (grand jeté)",0,.36,.9,[{at:.4,pose:{leftHip:-96,rightHip:-84,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:-130,rightShoulder:-105,leftElbow:0,rightElbow:0,lean:4,headTilt:-6},easing:"ease-out-cubic"},{at:.64,pose:{lean:2}}]),toeTouch:{label:"Toe touch (straddle jump)",view:0,spin:0,height:.36,travel:0,takeoff:.27,landing:.8,duration:1200,keys:[{at:0,reset:!0},{at:.16,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftShoulder:-20,rightShoulder:-20,stretch:.94}},{at:.27,pose:{leftHip:4,rightHip:4,leftKnee:0,rightKnee:0,leftAnkle:55,rightAnkle:55,leftShoulder:170,rightShoulder:170,stretch:1.06},easing:"ease-out-quad"},{at:.42,pose:{leftHip:104,rightHip:104,leftShoulder:96,rightShoulder:96,leftElbow:0,rightElbow:0,stretch:1,headTilt:0},easing:"ease-out-cubic"},{at:.62,pose:{}},{at:.76,pose:{leftHip:12,rightHip:12,leftAnkle:10,rightAnkle:10,leftShoulder:120,rightShoulder:120}},{at:.86,pose:{leftHip:22,rightHip:22,leftKnee:44,rightKnee:44,leftAnkle:0,rightAnkle:0,leftShoulder:60,rightShoulder:60,stretch:.94},easing:"ease-out-quad"},{at:1,reset:!0}]},backHandspring:oe("Back handspring",-360,.16,-.7,[{at:.38,pose:{leftHip:10,rightHip:-10,leftKnee:0,rightKnee:0,leftShoulder:-178,rightShoulder:178,lean:-26,headTilt:-20}},{at:.6,pose:{leftHip:-40,rightHip:40,leftKnee:-20,rightKnee:20,lean:6,headTilt:0}}],1200)},ss=.215,rs=.205,zd=.065,za=.035,Gd=.165,jd=.155,Jd=12,Zd=.3,Qd=.7,t0=.35,e0=e=>e*Math.PI/180,q={turn:0,lean:0,bend:0,side:0,"head.turn":0,"head.nod":0,"head.tilt":0,"arm.left.swing":0,"arm.left.spread":12,"arm.left.elbow":8,"arm.left.bend":0,"arm.right.swing":0,"arm.right.spread":12,"arm.right.elbow":8,"arm.right.bend":0,"leg.left.swing":0,"leg.left.spread":3,"leg.left.knee":0,"leg.left.ankle":0,"leg.left.toeOut":0,"leg.left.rotate":0,"leg.right.swing":0,"leg.right.spread":3,"leg.right.knee":0,"leg.right.ankle":0,"leg.right.toeOut":0,"leg.right.rotate":0,stretch:1,lift:0,roll:0,mouth:0,smile:.5,mouthWidth:1,blink:0,"eye.left":1,"eye.right":1,"brow.left":0,"brow.right":0,browTilt:0,lookX:0,lookY:0};function nt(e={}){return{...q,...e}}const n0=new Set(["turn","side","head.turn","head.tilt","roll","lookX"]);function i0(e){const t={};for(const[n,i]of Object.entries(e)){const s=n.replace(/(^|\.)(left|right)(\.|$)/,(r,o,a,l)=>`${o}${a==="left"?"right":"left"}${l}`);t[s]=n0.has(n)?-i:i}return t}function ot(e,t){const n={};for(const i of["left","right"])for(const[s,r]of Object.entries(t))n[`${e}.${i}.${s}`]=r;return n}const Ga={rest:q,wave:nt({"arm.right.spread":115,"arm.right.bend":55,"arm.right.elbow":0,"head.tilt":-6,smile:.9}),cheer:nt({...ot("arm",{spread:140,bend:20,elbow:0}),mouth:.6,smile:1,"eye.left":0,"eye.right":0}),point:nt({"arm.right.spread":88,"arm.right.elbow":0,"arm.right.bend":0,"head.turn":-20,smile:.4}),handsOnHips:nt({...ot("arm",{spread:50,bend:-105,elbow:0}),...ot("leg",{spread:9}),smile:.8}),think:nt({"arm.right.spread":22,"arm.right.bend":-150,"arm.right.elbow":0,"head.tilt":10,lookX:-.5,lookY:-.8,smile:0}),shrug:nt({...ot("arm",{spread:35,bend:75,elbow:0}),"head.tilt":-10,smile:-.2}),sit:nt({...ot("leg",{swing:90,knee:90,spread:4}),...ot("arm",{swing:25,elbow:45,spread:8})}),kneel:nt({"leg.left.swing":90,"leg.left.knee":90,"leg.right.swing":-18,"leg.right.knee":108,"leg.right.ankle":16,...ot("arm",{swing:20,elbow:30})}),crouch:nt({...ot("leg",{swing:75,knee:140,spread:6}),lean:25,...ot("arm",{swing:50,elbow:40}),"head.nod":-15}),crawl:nt({lean:82,"head.nod":-35,...ot("arm",{swing:80,elbow:0,spread:4}),...ot("leg",{knee:92,ankle:-88})}),lieDown:nt({roll:90,...ot("arm",{spread:8}),"head.nod":0})};function ja(e={}){const t=e.headSize??.3,n=e.shoulderWidth??.06,i=e.hipWidth??.022,s=Math.max(.12,1-t-za-(ss+rs)),r=l=>({id:`arm.${l}`,parent:"spine",offset:[(l==="left"?1:-1)*n,-.035,0],rest:[0,-1,0],side:l==="left"?1:-1,bones:[{length:Gd,width:[1.25,.9]},{length:jd,width:[.9,.75]}]}),o=l=>({id:`leg.${l}`,parent:null,offset:[(l==="left"?1:-1)*i,0,0],rest:[0,-1,0],side:l==="left"?1:-1,bones:[{length:ss,width:[1.45,1.05]},{length:rs,width:[1.05,.85]},{length:zd,width:[.95,.7]}]}),a=(l,c)=>l[c]??q[c]??0;return{id:"human",hipHeight:ss+rs,chains:[o("left"),o("right"),{id:"spine",parent:null,rest:[0,1,0],bones:[{length:s/2,width:[1.7,1.4]},{length:s/2,width:[1.4,1.1]}]},{id:"neck",parent:"spine",rest:[0,1,0],bones:[{length:za,width:[1,.9]}]},r("left"),r("right")],head:{on:"neck",size:t},contacts:[...["left","right"].flatMap(l=>[{chain:`leg.${l}`,joint:1},{chain:`leg.${l}`,joint:2},{chain:`leg.${l}`,joint:3},{chain:`arm.${l}`,joint:1},{chain:`arm.${l}`,joint:2}]),{chain:"spine",joint:0},{chain:"spine",joint:1},{chain:"spine",joint:2},{head:"top"}],angles(l,c){if(c.id==="spine"){const p=-a(l,"lean")/2,g=a(l,"side")/2,y=-a(l,"bend");return[{swing:p+y*Zd,spread:g},{swing:p+y*Qd,spread:g}]}if(c.id==="neck")return[{swing:-a(l,"bend")*t0,spread:0}];const[h,u]=c.id.split("."),f=p=>a(l,`${h}.${u}.${p}`);if(h==="arm")return[{swing:f("swing"),spread:f("spread")},{swing:f("elbow"),spread:f("bend")}];const d=(c.side??1)*f("rotate"),m=1-Math.cos(e0(f("rotate")));return[{swing:f("swing"),spread:f("spread"),yaw:d},{swing:-f("knee"),spread:0,yaw:d},{swing:90+f("ankle")-m*(f("swing")-f("knee")),spread:0,yaw:(Jd+f("toeOut"))*(c.side??1)}]},withAngles(l,c,h){const[u,f]=c.id.split("."),d=m=>`${u}.${f}.${m}`;return u==="arm"?{...l,[d("swing")]:h[0].swing,[d("spread")]:h[0].spread,[d("elbow")]:h[1].swing,[d("bend")]:h[1].spread}:u==="leg"?{...l,[d("swing")]:h[0].swing,[d("spread")]:h[0].spread,[d("knee")]:-h[1].swing}:l},boneScale(l,c){const h=Math.min(3,Math.max(.3,a(l,"stretch")));return c?.id.startsWith("arm.")?Math.sqrt(h):h},headPose(l){const c=Math.min(3,Math.max(.3,a(l,"stretch")));return{yaw:a(l,"head.turn"),nod:a(l,"head.nod"),tilt:a(l,"head.tilt"),sx:1/Math.sqrt(c),sy:Math.sqrt(c)}},landmarks:{neck:["neck",0],"shoulder.left":["arm.left",0],"elbow.left":["arm.left",1],"hand.left":["arm.left",2],"shoulder.right":["arm.right",0],"elbow.right":["arm.right",1],"hand.right":["arm.right",2],"hip.left":["leg.left",0],"knee.left":["leg.left",1],"ankle.left":["leg.left",2],"toe.left":["leg.left",3],"hip.right":["leg.right",0],"knee.right":["leg.right",1],"ankle.right":["leg.right",2],"toe.right":["leg.right",3]}}}function s0(e){const t=e.split(".");if(t[0]==="hand"&&t.length>=3){const i=`${t[1]==="left"?"Left":"Right"} hand`,s={spread:"finger spread",turn:"wrist turn",bend:"wrist bend",tilt:"wrist tilt",roll:"roll"},r=t.slice(2).join(".");return`${i} · ${s[r]??r.replace(".curl"," curl").replace(".across"," across")}`}if(t.length===3){const[i,s,r]=t;return`${`${s==="left"?"Left":"Right"} ${i}`} · ${{swing:"forward / back",spread:"out / in",elbow:"elbow bend",bend:"forearm out / in",knee:"knee bend",ankle:"foot tilt",toeOut:"toes out / in",rotate:"turn out at the hip"}[r]??r}`}return{turn:"View (front → side → back)",lean:"Lean forward / back",bend:"Back curve (line of action)",side:"Lean sideways","head.turn":"Head · turn","head.nod":"Head · nod","head.tilt":"Head · tilt",stretch:"Squash / stretch",lift:"Lift off the ground",roll:"Roll (whole figure)",mouth:"Mouth open",smile:"Smile",mouthWidth:"Mouth width",blink:"Blink","eye.left":"Left eye open","eye.right":"Right eye open","brow.left":"Left brow","brow.right":"Right brow",browTilt:"Brow slant",lookX:"Look left / right",lookY:"Look up / down"}[e]??e}const r0={leftEye:"eye.left",rightEye:"eye.right",leftBrow:"brow.left",rightBrow:"brow.right"},Ja=Object.fromEntries(Object.entries(G).map(([e,t])=>[e,Object.fromEntries(Object.entries(t).map(([n,i])=>[r0[n]??n,i]))]));function o0(e,t){const n=Math.min(1,Math.max(0,e.turn??0)),i=1-n,s={...q,turn:n},r=[{stick:"right",human:"left",s:1},{stick:"left",human:"right",s:-1}];for(const{stick:a,human:l,s:c}of r){const h=e[`${a}Shoulder`],u=e[`${a}Elbow`];s[`arm.${l}.spread`]=h*i,s[`arm.${l}.swing`]=c*h*n,s[`arm.${l}.bend`]=u*i,s[`arm.${l}.elbow`]=c*u*n;const f=e[`${a}Hip`],d=e[`${a}Knee`],m=i+c*n;s[`leg.${l}.rotate`]=90*i,s[`leg.${l}.spread`]=0,s[`leg.${l}.swing`]=f*m,s[`leg.${l}.knee`]=d*m,s[`leg.${l}.ankle`]=-(e[`${a}Ankle`]??0),s[`leg.${l}.toeOut`]=(e[`${a}FootOut`]??0)*a0,s[`eye.${l}`]=e[`${a}Eye`],s[`brow.${l}`]=e[`${a}Brow`],t&&Object.assign(s,l0(l,t[a]??Y,e[`${a}Wrist`]??0,n))}const o=e.bend??0;s.lean=e.lean*n,s.bend=o*n,s.side=(e.lean+o*.5)*i,s["head.tilt"]=(e.headTilt+o*.5)*i,s["head.nod"]=e.headTilt*n;for(const a of["mouth","smile","mouthWidth","blink","browTilt","lookX","lookY","stretch"])s[a]=e[a];return s.lift=e.rise??0,s.roll=e.spin??0,s}const a0=70;function l0(e,t,n,i){const s=e==="right"?1-i:1+i,r={};for(const o of Object.keys(Y))r[`hand.${e}.${o}`]=t[o]??Y[o];return r[`hand.${e}.turn`]=(t.turn??0)-s,r[`hand.${e}.roll`]=(t.roll??0)+n,r}const at=e=>e*Math.PI/180;function Za([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e,t*s+n*r,-t*r+n*s]}function os([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s-t*r,e*r+t*s,n]}function Lt([e,t,n],i){const s=Math.cos(i),r=Math.sin(i);return[e*s+n*r,t,-e*r+n*s]}const Mt=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],$n=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],Rn=(e,t)=>os(Za(e,t.swing),t.spread);function as(e,t){const n=Lt(e,t);return{point:{x:n[0],y:-n[1]},depth:n[2]}}function On(e,t,n){const i=n,r=[0,e.hipHeight*i*(e.boneScale?.(t,null)??1),0],o={};for(const p of e.chains){const g=p.parent?o[p.parent]:void 0;if(p.parent&&!g)throw new Error(`body plan ${e.id}: chain ${p.id} comes before its parent ${p.parent}`);const y=p.at??(g?g.joints3.length-1:0),w=g?g.joints3[y]:r,k=g?g.frames[Math.max(0,y-1)]:{swing:0,spread:0},M=p.offset?Mt(w,Rn($n(p.offset,i),k)):w,S=p.side??1,A=e.boneScale?.(t,p)??1,E=e.angles(t,p),T=[M],v=[];let _=k.swing,P=k.spread;p.bones.forEach((x,I)=>{const C=E[I]??{swing:0,spread:0};_+=at(C.swing),P+=at(C.spread)*S,v.push({swing:_,spread:P});const H=Lt(Rn(p.rest,{swing:_,spread:P}),at(C.yaw??0));T.push(Mt(T[I],$n(H,x.length*i*A)))}),o[p.id]={joints3:T,frames:v}}const a=o[e.head.on],l=e.headPose?.(t)??{yaw:0,nod:0,tilt:0,sx:1,sy:1},c=a.frames[a.frames.length-1],h=e.head.size/2*i,u=h*l.sx,f=h*l.sy,d=p=>Rn(Lt(Za(os(p,-at(l.tilt)),-at(l.nod)),at(l.yaw)),c),m=Mt(a.joints3[a.joints3.length-1],d([0,f,0]));return{height:i,root:r,chains:o,head:{center:m,rx:u,ry:f,toBody:d}}}function ls(e,t,n){const i=n.height,s=at(90*(t.turn??0)),r=On(e,t,i),{root:o}=r,a=r.chains,{rx:l,ry:c}=r.head,h=r.head.toBody,u=r.head.center,f={};for(const v of e.chains){const{joints3:_,frames:P}=a[v.id],x=_.map(I=>as(I,s));f[v.id]={id:v.id,joints3:_,frames:P,points:x.map(I=>I.point),depths:x.map(I=>I.depth)}}const d=as(u,s),m=[[1,0,0],[0,1,0],[0,0,1]].map(v=>Lt(h(v),s)),p=as(o,s).point,g=at(t.roll??0),y=v=>{const _=v.x-p.x,P=v.y-p.y;return{x:p.x+_*Math.cos(g)-P*Math.sin(g),y:p.y+_*Math.sin(g)+P*Math.cos(g)}},w=([v,_,P])=>[v*Math.cos(g)+_*Math.sin(g),-v*Math.sin(g)+_*Math.cos(g),P];for(const v of Object.values(f))v.points=v.points.map(y);const k={center:y(d.point),depth:d.depth,rx:l,ry:c,angle:0,axes:m.map(w)},M=k.axes[1];k.angle=Math.atan2(M[0],M[1]);const S=v=>{if("head"in v)return{x:k.center.x+M[0]*c,y:k.center.y-M[1]*c};const _=f[v.chain];return _.points[Math.min(v.joint,_.points.length-1)]};let A=0;(n.contact??"ground")==="ground"&&(A=-Math.max(...e.contacts.map(v=>S(v).y))),A-=(t.lift??0)*i;const E=v=>({x:v.x,y:v.y+A});for(const v of Object.values(f))v.points=v.points.map(E);k.center=E(k.center);const T=e.contacts.map(v=>({spec:v,point:S(v)}));return{height:i,view:s,chains:f,head:k,hip:E(y(p)),contacts:T,groundY:Math.max(...T.map(v=>v.point.y))}}const cs=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],Qa=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function hs(e,t,n){const i=n.height,s=at(90*(t.turn??0)),r=at(t.roll??0),o=On(e,t,i),a=Lt(o.root,s),l=g=>Mt(os(cs(Lt(g,s),a),-r),a),c={};for(const g of e.chains)c[g.id]=o.chains[g.id].joints3.map(l);const h=l(o.head.center),u=g=>Qa(cs(l(Mt(o.head.center,o.head.toBody(g))),h)),f=[u([1,0,0]),u([0,1,0]),u([0,0,1])],d=g=>{if("head"in g)return Mt(h,$n(f[1],o.head.ry));const y=c[g.chain];return y[Math.min(g.joint,y.length-1)]};let m=0;(n.contact??"ground")==="ground"&&(m=-Math.min(...e.contacts.map(g=>d(g)[1]))),m+=(t.lift??0)*i;const p=g=>[g[0],g[1]+m,g[2]];return{height:i,hip:p(a),chains:Object.fromEntries(Object.entries(c).map(([g,y])=>[g,y.map(p)])),head:{center:p(h),rx:o.head.rx,ry:o.head.ry,axes:f}}}function us(e,t,n,i){const s=n.height,r=at(90*(t.turn??0)),o=On(e,t,s),a=hs(e,t,n),l=a.hip,c=a.chains,h=a.head.center,u=v=>{if("head"in v)return Mt(h,$n(a.head.axes[1],a.head.ry));const _=c[v.chain];return _[Math.min(v.joint,_.length-1)]},f=i.toView(l),d=i.toScreen(f),m=i.toScreen([f[0]+1,f[1],f[2]]),p=Math.hypot(m.x-d.x,m.y-d.y),g=v=>{const _=i.toView(v);return{point:i.toScreen(_),depth:_[2]*p}},y={};for(const v of e.chains){const _=c[v.id].map(g);y[v.id]={id:v.id,joints3:o.chains[v.id].joints3,frames:o.chains[v.id].frames,points:_.map(P=>P.point),depths:_.map(P=>P.depth)}}const w=i.toView(h),k=i.toScreen(w),M=i.toScreen([w[0]+1,w[1],w[2]]),S=Math.hypot(M.x-k.x,M.y-k.y),A=a.head.axes.map(v=>Qa(cs(i.toView(Mt(h,v)),w))),E={center:k,depth:w[2]*p,rx:o.head.rx*S,ry:o.head.ry*S,angle:Math.atan2(A[1][0],A[1][1]),axes:A},T=e.contacts.map(v=>({spec:v,point:g(u(v)).point}));return{height:s*p,view:r,chains:y,head:E,hip:d,contacts:T,groundY:Math.max(...T.map(v=>v.point.y))}}function tl(e,[t,n,i]){const[s,r,o]=e.axes,a=[s[0]*t*e.rx+r[0]*n*e.ry+o[0]*i*e.rx,s[1]*t*e.rx+r[1]*n*e.ry+o[1]*i*e.rx,s[2]*t*e.rx+r[2]*n*e.ry+o[2]*i*e.rx],l=Math.hypot(t,n,i)||1,c=(s[2]*t+r[2]*n+o[2]*i)/l;return{point:{x:e.center.x+a[0],y:e.center.y-a[1]},depth:e.depth+a[2],facing:c}}class el{positions=[];normals=[];indices=[];vertex(t,n,i,s,r,o){const a=Math.hypot(s,r,o)||1;return this.positions.push(t,n,i),this.normals.push(s/a,r/a,o/a),this.positions.length/3-1}triangle(t,n,i){this.indices.push(t,n,i)}quad(t,n,i,s){this.indices.push(t,n,i,t,i,s)}build(){return{positions:this.positions,normals:this.normals,indices:this.indices}}}function c0(e){const t=new Map,n=[];for(let s=0;s<e.positions.length/3;s++){const r=[0,1,2].map(o=>Math.round(e.positions[s*3+o]*1e6)).join(",");t.has(r)||t.set(r,s),n.push(t.get(r))}const i=new Map;for(let s=0;s<e.indices.length/3;s++)for(let r=0;r<3;r++){const o=n[e.indices[s*3+r]],a=n[e.indices[s*3+(r+1)%3]];if(o===a)continue;const l=o<a?`${o}-${a}`:`${a}-${o}`,c=i.get(l);c?c.faces.push(s):i.set(l,{a:Math.min(o,a),b:Math.max(o,a),faces:[s]})}return[...i.values()]}const fs=Math.PI*2;function h0(e,t=16){const n=new el,i=Math.max(6,Math.round(t)),s=Math.max(3,Math.round(i/2)),r=[];for(let o=0;o<=s;o++){const a=o/s*Math.PI,l=[];for(let c=0;c<=i;c++){const h=c/i*fs,u=Math.sin(a)*Math.sin(h),f=Math.cos(a),d=Math.sin(a)*Math.cos(h);l.push(n.vertex(u*e,f*e,d*e,u,f,d))}r.push(l)}for(let o=0;o<s;o++)for(let a=0;a<i;a++){const l=r[o][a],c=r[o+1][a],h=r[o+1][a+1],u=r[o][a+1];o>0&&n.triangle(l,c,u),o<s-1&&n.triangle(c,h,u)}return n.build()}function nl(e,t,n,i,s){const r=e.vertex(0,n,0,0,i,0),o=Array.from({length:s},(a,l)=>{const c=l/s*fs;return e.vertex(Math.sin(c)*t,n,Math.cos(c)*t,0,i,0)});for(let a=0;a<s;a++){const l=o[a],c=o[(a+1)%s];i===1?e.triangle(r,l,c):e.triangle(r,c,l)}}function u0(e,t,n=24){const i=new el,s=Math.max(6,Math.round(n)),r=t/2,o=-t/2,a=h=>Array.from({length:s+1},(u,f)=>{const d=f/s*fs;return i.vertex(Math.sin(d)*e,h,Math.cos(d)*e,Math.sin(d),0,Math.cos(d))}),l=a(o),c=a(r);for(let h=0;h<s;h++)i.quad(l[h],l[h+1],c[h+1],c[h]);return nl(i,e,r,1,s),nl(i,e,o,-1,s),i.build()}function il(e){const t=Array.from({length:e.indices.length/3},()=>[]);for(const n of c0(e))for(const i of n.faces){const s=n.faces.find(r=>r!==i)??-1;t[i].push({a:n.a,b:n.b,across:s})}return{...e,faceEdges:t}}const Ln=e=>e*180/Math.PI,ae=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],ds=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],We=e=>Math.hypot(e[0],e[1],e[2]),ps=e=>{const t=We(e)||1;return[e[0]/t,e[1]/t,e[2]/t]},Fn=e=>Math.atan2(Math.sin(e),Math.cos(e));function sl(e){const[t,n,i]=ps(e);return{swing:Math.asin(Math.max(-1,Math.min(1,i))),spread:Math.atan2(t,-n)}}function f0(e,t,n,i,s){const r=e.chains.find(_=>_.id===n);if(!r)throw new Error(`reach: no chain ${n} in ${e.id}`);if(r.bones.length<2||r.rest[1]>-.99)throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);if(!e.withAngles)throw new Error(`reach: the ${e.id} plan cannot set angles`);const o=ls(e,{...t,turn:0,roll:0,lift:0},{height:s.height,contact:"none"}),a=o.chains[n],l=a.joints3[0],c=We(ae(a.joints3[1],a.joints3[0])),h=We(ae(a.joints3[2],a.joints3[1])),u=r.parent?o.chains[r.parent].frames[Math.max(0,(r.at??o.chains[r.parent].joints3.length-1)-1)]:{swing:0,spread:0},f=ae(i,l),d=Math.min(c+h-1e-6,Math.max(Math.abs(c-h)+1e-6,We(f))),m=ps(f),p=r.parent!==null,g=Rn(r.pole??(p?[0,-.35,-1]:[0,0,1]),u);let y=ae(g,[m[0]*ds(g,m),m[1]*ds(g,m),m[2]*ds(g,m)]);We(y)<1e-6&&(y=Lt([1,0,0],0)),y=ps(y);const w=(c*c+d*d-h*h)/(2*c*d),k=Math.sqrt(Math.max(0,1-w*w)),M=[l[0]+c*(w*m[0]+k*y[0]),l[1]+c*(w*m[1]+k*y[1]),l[2]+c*(w*m[2]+k*y[2])],S=[l[0]+m[0]*d,l[1]+m[1]*d,l[2]+m[2]*d],A=r.side??1,E=sl(ae(M,l)),T=sl(ae(S,M)),v=[{swing:Ln(Fn(E.swing-u.swing)),spread:Ln(Fn(E.spread-u.spread))*A},{swing:Ln(Fn(T.swing-E.swing)),spread:Ln(Fn(T.spread-E.spread))*A}];return e.withAngles(t,r,v)}const d0=.34,Tt=.12,ft=-.4,pt=(e,t,n)=>e[t]??n,p0=(e,t)=>Math.max(0,e)*(1-Math.min(1,Math.max(0,t))),m0=.45,g0=.35,y0=.7;function Dn(e,t,n){const i=d=>Math.sqrt(Math.max(0,1-d.x*d.x-d.y*d.y)),s=tl(e,[n.x,n.y,i(n)]).facing,r=e.axes[2],o=Math.atan2(r[0],r[2]),a=Math.cos(o),l=a>=0?1:-1,c=l*Math.max(g0,Math.abs(a)),h=l*Math.max(y0,Math.abs(a)),u=Math.cos(e.angle),f=Math.sin(e.angle);return{facing:s,points:t.map(d=>{const m=m0*Math.sin(o)+n.x*c+(d.x-n.x)*h,p=d.y+r[1]*i(d),g=m*e.rx,y=p*e.ry;return{x:e.center.x+g*u+y*f,y:e.center.y+g*f-y*u}})}}const Bn=(e,t,n,i=12)=>Array.from({length:i+1},(s,r)=>{const o=r/i,a=1-o;return{x:a*a*e.x+2*a*o*t.x+o*o*n.x,y:a*a*e.y+2*a*o*t.y+o*o*n.y}}),ms=(e,t,n,i,s=16)=>Array.from({length:s},(r,o)=>{const a=Math.PI*2*o/s;return{x:e+Math.cos(a)*n,y:t+Math.sin(a)*i}}),rl=.05;function b0(e,t,n,i){const s=Math.max(1,Math.min(i*.6,.14*t.rx)),r=(y,w)=>Dn(t,y,w).points,o=(y,w)=>Dn(t,[],{x:y,y:w}).facing,a=pt(n,"smile",0),l=pt(n,"blink",0),c=pt(n,"lookX",0),h=pt(n,"lookY",0),u=pt(n,"browTilt",0);for(const y of[1,-1]){const w=y===1?"left":"right",k=d0*y;if(o(k,Tt)<rl)continue;const M={x:k,y:Tt},S=p0(pt(n,`eye.${w}`,1),l);if(S<.2){const v=a>.5?.12:-.06;e.line(r(Bn({x:k-.12,y:Tt},{x:k,y:Tt+v},{x:k+.12,y:Tt}),M),s)}else{if(S>1.2){const x=.13*S;e.shape(r(ms(k,Tt,x*.85,x),M),"#ffffff",s)}const v=S>1.2?.075:.1,_=k+c*.08,P=Tt-h*.07;e.shape(r(ms(_,P,v,v*1.1*Math.min(S,1)),M),e.ink,0)}const A=Tt+.3+pt(n,`brow.${w}`,0)*.14+Math.max(0,S-1)*.12,E={x:k+y*.13,y:A},T={x:k-y*.13,y:A+u*.1};e.line(r([E,{x:(E.x+T.x)/2,y:(E.y+T.y)/2},T],{x:k,y:A}),s)}const f={x:0,y:ft};if(o(0,ft)<-rl)return;const d=.25*Math.max(.3,pt(n,"mouthWidth",1)),m=Math.min(1,Math.max(0,pt(n,"mouth",0)));if(m<=.05){e.line(r(Bn({x:-d,y:ft},{x:0,y:ft-a*.25},{x:d,y:ft}),f),s);return}const p=.3*m;let g;if(a>.3){const y=ft+.05;g=[...Bn({x:d,y},{x:0,y:ft-p*2},{x:-d,y})]}else if(a<-.3){const y=ft-p*.6;g=[...Bn({x:d,y},{x:0,y:ft+p*1.4},{x:-d,y})]}else g=ms(0,ft,d*.8,p);e.shape(r(g,f),e.ink,0)}function ol(e={}){const t=(e.proportions??"bold")==="bold",n=e.figure??"fluid",i=e.look??"clean",s=e.height??300,r=n==="stick";return{plan:e.plan??ja({headSize:e.headSize??(t?.3:.24),shoulderWidth:r?0:e.shoulderWidth??.06,hipWidth:r?0:e.hipWidth??.022}),figure:n,look:i,height:s,lineWidth:e.lineWidth??s*(t?.045:.022),ink:e.ink??(i==="pencil"?"#2f2f33":"#1e293b"),skin:e.skin??(i==="pencil"?"none":"#ffffff"),seed:e.seed??1,pencil:e.pencil??{},layers:e.layers??{},contact:e.contact??"ground",hands:e.hands??"dot",handStyle:e.handStyle??"glove",handSize:e.handSize??(e.handStyle==="natural"?.14:.17)}}function w0(e,t,n,i){const{point:s,facing:r}=tl(e,[t,n,i]);return{point:s,facing:r}}const gs=e=>e.rest[1]<-.5,k0=.3;function v0(e,t,n){return e.figure==="stick"?gs(t)?n.slice(0,3):n:gs(t)&&n.length>=3?Ht(n[0],n[1],n[2],k0):n.length===3?Ht(n[0],n[1],n[2],1):n}function ys(e,t){const n=e.plan.id==="human"?{...q,...t}:t;return bs(e,n,ls(e.plan,n,{height:e.height,contact:e.contact}))}function bs(e,t,n){const i={},s={},r={},o=.01*e.height;e.plan.chains.forEach(f=>{const d=n.chains[f.id];i[f.id]=d.points;const m=d.depths.reduce((w,k)=>w+k,0)/d.depths.length,p=f.parent?n.chains[f.parent]:void 0,g=p?p.depths[f.at??p.depths.length-1]:0,y=m-g;r[f.id]=Math.abs(y)<o?0:y,s[f.id]={points:v0(e,f,d.points),depth:m}}),s.head={points:[n.head.center],depth:n.head.depth},r.head=0;const a=[...e.plan.chains.map(f=>f.id),"head"],l=[...a].sort((f,d)=>r[f]-r[d]||a.indexOf(f)-a.indexOf(d)),c={hip:n.hip};for(const[f,[d,m]]of Object.entries(e.plan.landmarks??{})){const p=n.chains[d]?.points;p&&(c[f]=p[Math.min(m,p.length-1)])}const h={};for(const[f,d]of Object.entries(c))h[f]=d.y>=n.groundY-.01*e.height;const u={height:e.height,lineWidth:e.lineWidth,turn:t.turn??0,points:c,chains:i,parts:s,head:n.head,groundY:n.groundY,grounded:h};return{skeleton:n,joints:u,order:l}}function al(e,t){return ys(e,t).joints}function S0(e,t,n){const{head:i}=n;e.guideEllipse(i.center.x,i.center.y,i.rx*1.03,i.ry*1.03,i.angle);const s=Array.from({length:13},(l,c)=>({x:0,y:-.95+1.9*c/12})),r=Array.from({length:13},(l,c)=>({x:-.95+1.9*c/12,y:.12})),o=Dn(i,s,{x:0,y:0});o.facing>0&&e.guide(o.points),e.guide(Dn(i,r,{x:0,y:.12}).points),e.guide(n.chains.spine??[]);const a=t.lineWidth*.9;for(const l of["shoulder.left","shoulder.right","elbow.left","elbow.right","hip.left","hip.right","knee.left","knee.right"]){const c=n.points[l];c&&e.guideEllipse(c.x,c.y,a,a,0)}}function M0(e,t,n,i,s,r){const o=n.lineWidth;if(s==="head"){const{head:d}=i,m=n.skin==="none"?null:n.skin;t.ellipse(d.center.x,d.center.y,d.rx,d.ry,d.angle,m,o),t.look!=="silhouette"&&b0(t,d,r,o);return}const a=n.plan.chains.find(d=>d.id===s),l=i.chains[s],c=i.parts[s].points;if(n.figure==="stick"){if(s==="neck")return;const d=s==="spine"?[...l,...i.chains.neck?.slice(1)??[]]:c;t.line(d,o);return}const h=(d,m)=>[a.bones[d].width[0]*o,a.bones[m].width[1]*o];if(gs(a)){const[d,m]=h(0,1);if(t.limb(c,d,m),a.bones.length>=3)t.limb([l[2],l[3]],a.bones[2].width[0]*o,a.bones[2].width[1]*o);else if(n.hands==="cartoon"&&s.startsWith("arm."))T0(e,t,n,l,s.endsWith(".left")?"left":"right",r);else{const p=l[l.length-1];t.dot(p.x,p.y,o*.62)}return}if(s==="spine"){const d=i.points["hip.left"],m=i.points["hip.right"];d&&m&&Math.hypot(d.x-m.x,d.y-m.y)>.5&&t.limb([d,m],o*1.3,o*1.3);const[p,g]=h(0,a.bones.length-1);t.limb(c,p,g);const y=i.points["shoulder.left"],w=i.points["shoulder.right"];y&&w&&Math.hypot(y.x-w.x,y.y-w.y)>.5&&t.limb(Ht(y,l[l.length-1],w,1,10),o*1.15,o*1.15);return}const[u,f]=h(0,a.bones.length-1);t.limb(c,u,f)}function ll(e,t){const n=`hand.${t}.`,i={};for(const[o,a]of Object.entries(e))o.startsWith(n)&&(i[o.slice(n.length)]=a);const s=e.turn??0,r=t==="right"?1-s:1+s;return{...Y,...i,turn:r+(i.turn??0)}}function T0(e,t,n,i,s,r){const o=i[i.length-1],a=i[i.length-2],l=Math.atan2(o.x-a.x,-(o.y-a.y))*180/Math.PI;Sn(e,o,ll(r,s),{size:n.handSize*n.height,side:s,angle:l,pen:t,skin:n.skin==="none"?"#ffffff":n.skin,fingers:n.handStyle==="natural"?5:4,plump:n.handStyle==="natural"?1.15:1.6,lineWidth:n.lineWidth*.3})}function cl(e,t,n,i=0){const s=t.plan.id==="human"?{...q,...n}:n;fl(e,t,s,ys(t,s),i)}function hl(e,t){const n=t/e.height;return{...e,height:t,lineWidth:e.lineWidth*n}}function E0(e,t,n,i){const s=e.plan.id==="human"?{...q,...t}:t,r=us(e.plan,s,{height:i.height,contact:e.contact},n);return bs(hl(e,r.height),s,r).joints}function ul(e,t,n,i,s){const r=t.plan.id==="human"?{...q,...n}:n,o=us(t.plan,r,{height:s.height,contact:t.contact},i),a=hl(t,o.height);fl(e,a,r,bs(a,r,o),s.time??0)}function fl(e,t,n,i,s){const{joints:r,order:o}=i,a=Vi(e,{look:t.look,ink:t.ink,lineWidth:t.lineWidth,seed:t.seed,time:s,pencil:t.pencil}),l=c=>{c&&(e.save(),c(e,r,a,s),e.restore())};e.save(),e.lineCap="round",e.lineJoin="round",t.look==="pencil"&&t.pencil.construction!==!1&&S0(a,t,r),l(t.layers.behind);for(const c of o){const h=t.layers.parts?.[c];l(h?.under),M0(e,a,t,r,c,n),l(h?.over)}l(t.layers.front),e.restore()}function A0(e,t,n){const i={...e};for(const[s,r]of Object.entries(t)){const o=e[s]??r;i[s]=o+(r-o)*n}return i}function x0(e,t,n,i){const s=e.plan.id==="human"?{...q,...t}:t;let r;if(Array.isArray(i))r=i;else{const{skeleton:o}=ys(e,s),a=ls(e.plan,{...s,roll:0},{height:e.height,contact:"none"}),l=(s.roll??0)*Math.PI/180,c=i.x-o.hip.x,h=i.y-o.hip.y,u=a.hip.x+c*Math.cos(-l)-h*Math.sin(-l),f=a.hip.y+c*Math.sin(-l)+h*Math.cos(-l),d=Math.PI/2*(s.turn??0),m=i.depth??o.chains[n].depths[o.chains[n].depths.length-1],p=Math.cos(d),g=Math.sin(d);r=[u*p-m*g,-f,u*g+m*p]}return f0(e.plan,s,n,r,{height:e.height})}function P0(e){const{character:t}=e,n=t.height*.8,i=t.height,s=t.plan.id==="human"?q:{};return{type:"custom",x:e.x-n/2,y:e.y-i,width:n,height:i,props:{...s,...e.pose},character:t,draw(r,o,a){r.translate(n/2,i),cl(r,t,o.props,a)}}}function dl(e,t,n){const i=r=>({x:r.x+t,y:r.y+n}),s=r=>Object.fromEntries(Object.entries(r).map(([o,a])=>[o,a.map(i)]));return{...e,points:Object.fromEntries(Object.entries(e.points).map(([r,o])=>[r,i(o)])),chains:s(e.chains),parts:Object.fromEntries(Object.entries(e.parts).map(([r,o])=>[r,{...o,points:o.points.map(i)}])),head:{...e.head,center:i(e.head.center)},groundY:e.groundY+n}}function _0(e,t,n){const i=e.character;if(!i)throw new Error("characterAt: the target was not made by characterTarget");const s={...e.props};let r=0,o=0;for(const[l,c]of t.state?.values.get(n)??[])typeof c=="number"&&(l==="x"||l==="motionPathX"?r=c:l==="y"||l==="motionPathY"?o=c:l in s&&(s[l]=c));const a=al(i,s);return{pose:s,joints:dl(a,e.x+r+e.width/2,e.y+o+e.height)}}function ws(e,t=q){const n=[];return e.forEach((i,s)=>{const r=s===0?t:n[s-1],o=typeof i.pose=="string"?Ga[i.pose]:void 0;n.push(o?{...o,turn:r.turn??0}:{...r,...i.pose})}),n}function I0(e,t,n=q){const i=ws(t,n);return Object.keys(n).filter(r=>i.some(o=>(o[r]??n[r])!==n[r])).map(r=>({id:`${e}-${r}`,target:e,property:r,keyframes:t.map((o,a)=>({time:o.time,value:i[a][r]??n[r],...o.easing?{easing:o.easing}:{}}))}))}const C0=new Set(["x","y","z","position","rotateX","rotateY","rotateZ","quaternion","scale","scaleX","scaleY","scaleZ","visible","opacity","color"]),H0=1.7;function $0(e,t,n){const i=Array.from({length:24},(s,r)=>{const o=r/24*Math.PI*2,a=t.toView([Math.cos(o)*n,0,Math.sin(o)*n*.8]);return a[2]<-.001?t.toScreen(a):null});i.some(s=>s===null)||(e.beginPath(),i.forEach((s,r)=>r===0?e.moveTo(s.x,s.y):e.lineTo(s.x,s.y)),e.closePath(),e.fillStyle="rgba(0, 0, 0, 0.22)",e.fill())}function R0(e){const t=Te([0,1,0],e);if(t>.999999)return Kr();if(t<-.999999)return Ae(Vt([1,0,0],180));const n=an([0,1,0],e);return Ae(Vt(n,Math.acos(t)*180/Math.PI))}function O0(e,t,n,i,s){const r=e.solid??{},o=r.outline===!1?void 0:r.outline??{width:2,color:"#0f172a"},a={color:r.color??"#475569",shading:r.shading??"toon",outline:o},l={color:r.skin??"#f2c49b",shading:r.shading??"toon",outline:o},c={color:"#0f172a",shading:"unlit"},h=i.height*.034,u=[],f=(k,M,S)=>u.push({mesh:k,world:_t(s,M),material:S}),d=(k,M,S)=>f(t.sphere,Xr(k,[0,0,0,1],[M,M,M]),S);for(const k of n.chains){const M=i.chains[k.id],S=k.id==="spine"?1.9:1;k.bones.forEach((A,E)=>{const T=M[E],v=M[E+1],_=Nr(T,v),[P,x]=A.width??[1,1],I=h*S*(P+x)/2;if(_>1e-6){const C=Wr(T,v,.5),H=R0(Ee(on(v,T)));f(t.cylinder,_t(Yr(C),_t(H,ln([I,_,I]))),a)}d(T,h*S*P,a),d(v,h*S*x,a)}),k.id.startsWith("arm.")&&d(M[M.length-1],h*1.5,l)}const{center:m,rx:p,ry:g,axes:y}=i.head,w=[...y[0],0,...y[1],0,...y[2],0,...m,1];f(t.sphere,_t(w,ln([p,g,p])),l);for(const k of[-1,1]){const M=Ee([k*.36,.15,.92]),S=rn(m,rn(rn(Me(y[0],M[0]*p*1.04),Me(y[1],M[1]*g*1.04)),Me(y[2],M[2]*p*1.04))),A=[...y[0],0,...y[1],0,...y[2],0,...S,1];f(t.sphere,_t(A,ln([p*.11,g*.14,p*.03])),c)}return u}const L0={kind:"character",validate(e){const t=e;return t.height!==void 0&&!(t.height>0)?["a character's height must be positive"]:[]},prepare(e){return{who:ol({...e.character,height:1}),cylinder:il(u0(1,1,16)),sphere:il(h0(1,20))}},resolve({object:e,prepared:t,values:n,world:i,camera:s,toScreen:r}){const o=e,a=t,l=a.who,c={...q,...o.pose};for(const[g,y]of n)typeof y=="number"&&!C0.has(g)&&(c[g]=y);const h=o.height??H0,u=_t(s.view,i),f={toView:g=>qr(u,g),toScreen:g=>r(g)},m=-f.toView([0,h/2,0])[2];if(m<=s.near)return null;const p=o.shadow===!1?[]:[{depth:m+h,draw:g=>$0(g,f,h*.18)}];if(o.look==="solid"){const g=hs(l.plan,c,{height:h,contact:l.contact});return{meshes:O0(o,a,l.plan,g,i),drawables:p}}return{drawables:[...p,{depth:m,draw(g,y){g.lineCap="round",g.lineJoin="round",ul(g,l,c,f,{height:h,time:y.time})}}]}}},pl={x:0,y:0,scale:1,rotate:0,shakeX:0,shakeY:0,shakeRotate:0};function F0(e){const t=n=>{const i=e?.get(n);return typeof i=="number"?i:pl[n]};return{x:t("x"),y:t("y"),scale:t("scale"),rotate:t("rotate"),shakeX:t("shakeX"),shakeY:t("shakeY"),shakeRotate:t("shakeRotate")}}function D0(e,t,n){const i=n.width/2,s=n.height/2,o=1+2*Math.max(Math.abs(t.shakeX),Math.abs(t.shakeY))/Math.max(1,Math.min(n.width,n.height));e.translate(i+t.x+t.shakeX,s+t.y+t.shakeY),e.rotate((t.rotate+t.shakeRotate)*Math.PI/180),e.scale(t.scale*o,t.scale*o),e.translate(-i,-s)}function B0(e,t,n){const i=t.width/2,s=t.height/2,r=(e.rotate+e.shakeRotate)*Math.PI/180,o=(n.x-i)*e.scale,a=(n.y-s)*e.scale;return{x:i+e.x+e.shakeX+o*Math.cos(r)-a*Math.sin(r),y:s+e.y+e.shakeY+o*Math.sin(r)+a*Math.cos(r)}}function ml(e,t,n={},i){const s=n.length??240,r=9,o=28,a=s-22;e.save(),e.translate(t.x,t.y),e.rotate((n.angle??-30)*Math.PI/180),e.fillStyle=n.color??"#f4c542",e.fillRect(o,-r,a-o,2*r),e.fillStyle="#e8b4a0",e.fillRect(a,-r,s-a,2*r),e.fillStyle="#f1dcbf",e.beginPath(),e.moveTo(0,0),e.lineTo(o,-r),e.lineTo(o,r),e.closePath(),e.fill(),e.fillStyle=n.outline??"#2f2f33",e.beginPath(),e.moveTo(0,0),e.lineTo(o*.35,-r*.35),e.lineTo(o*.35,r*.35),e.closePath(),e.fill(),e.strokeStyle=n.outline??"#2f2f33",e.lineWidth=3,e.lineJoin="round",e.lineCap="round";const l=[[{x:0,y:0},{x:o,y:-r},{x:s,y:-r},{x:s,y:r},{x:o,y:r},{x:0,y:0}],[{x:o,y:-r},{x:o,y:r}],[{x:a,y:-r},{x:a,y:r}]];for(const c of l)bl(e,c,i);e.restore()}function ks(e,t,n={},i){const s=n.length??90,r=n.thickness??34;e.save(),e.translate(t.x,t.y),e.rotate((n.angle??-35)*Math.PI/180);const o=-r/2;e.fillStyle=n.color??"#f4a7b9",e.fillRect(0,o,s,r),e.fillStyle="#e9edf2",e.fillRect(s*.45,o,s*.55,r),e.strokeStyle=n.outline??"#2f2f33",e.lineWidth=3,e.lineJoin="round";const a=[{x:0,y:o},{x:s,y:o},{x:s,y:-o},{x:0,y:-o},{x:0,y:o}],l=[{x:s*.45,y:o},{x:s*.45,y:-o}];if(i)i.line(a),i.line(l);else for(const c of[a,l]){e.beginPath(),e.moveTo(c[0].x,c[0].y);for(const h of c.slice(1))e.lineTo(h.x,h.y);e.stroke()}e.restore()}const gl=150,N0={pencil:44,eraser:30};function vs(e,t,n={},i){const s=n.tool??"pencil",r=n.skin??"#f1c9a5",o=n.outline??"#2f2f33",a=n.scale??1,l=Math.min(1,Math.max(0,n.lift??0)),c=(n.angle??-30)*Math.PI/180,h=i?i.nudge(.6):{x:0,y:0},u=gl*a*(1+.05*l);l>0&&(e.save(),e.fillStyle=o,e.globalAlpha=.15*l,e.beginPath(),e.ellipse(t.x,t.y,9*a,4*a,0,0,Math.PI*2),e.fill(),e.restore());const f={x:t.x+h.x+6*l*a,y:t.y+h.y-18*l*a},d=U.pencilGrip,m=E=>{const T=E.fingers.thumb,v=E.fingers.index,_=E.fingers.middle,P=yl([T.points[3],v.points[3],_.points[3]]),x=yl([T.points[1],v.points[0]]),I=(T.depths[3]+v.depths[3]+_.depths[3])/3;return{pinch:P,direction:Math.atan2(x.y-P.y,x.x-P.x),depth:I}},p=vn(d,{size:u}),g=c-m(p).direction,y=vn(d,{size:u,angle:g*180/Math.PI}),w=m(y),k=N0[s]*a,M={x:w.pinch.x-Math.cos(c)*k,y:w.pinch.y-Math.sin(c)*k},S={x:f.x-M.x,y:f.y-M.y},A=y.axes.up;W0(e,S,{x:-A.x,y:-A.y},u,n.arm??300*a,r,n.sleeve??"#5b7db1",o),Sn(e,S,d,{size:u,angle:g*180/Math.PI,skin:r,ink:o,lineWidth:3*a,prop:{depth:w.depth,draw:()=>{e.save(),e.translate(f.x,f.y),e.scale(a,a),s==="eraser"?ks(e,{x:0,y:0},{angle:c*180/Math.PI,outline:o},i):ml(e,{x:0,y:0},{angle:c*180/Math.PI,length:190,outline:o},i),e.restore()}}})}const yl=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length});function W0(e,t,n,i,s,r,o,a){const l={x:-n.y,y:n.x},c=i*.15,h=(p,g,y)=>({x:t.x+n.x*p+l.x*g*y,y:t.y+n.y*p+l.y*g*y}),u=h(s,0,0),f=p=>{const g=e.createLinearGradient(t.x,t.y,u.x,u.y);return g.addColorStop(0,p),g.addColorStop(.6,p),g.addColorStop(1,q0(p)),g},d=Math.min(i*.55,s*.35);e.save(),e.lineJoin="round",e.lineCap="round",e.lineWidth=3*(i/gl),e.beginPath(),e.moveTo(h(-i*.1,-1,c).x,h(-i*.1,-1,c).y),e.lineTo(h(d+4,-1,c*1.1).x,h(d+4,-1,c*1.1).y),e.lineTo(h(d+4,1,c*1.1).x,h(d+4,1,c*1.1).y),e.lineTo(h(-i*.1,1,c).x,h(-i*.1,1,c).y),e.closePath(),e.fillStyle=r,e.fill(),e.strokeStyle=a,e.beginPath(),e.moveTo(h(0,-1,c).x,h(0,-1,c).y),e.lineTo(h(d,-1,c*1.1).x,h(d,-1,c*1.1).y),e.moveTo(h(0,1,c).x,h(0,1,c).y),e.lineTo(h(d,1,c*1.1).x,h(d,1,c*1.1).y),e.stroke();const m=[h(d,-1,c*1.3),h(s,-1,c*1.5),h(s,1,c*1.5),h(d,1,c*1.3)];e.beginPath(),m.forEach((p,g)=>g?e.lineTo(p.x,p.y):e.moveTo(p.x,p.y)),e.closePath(),e.fillStyle=f(o),e.fill(),e.strokeStyle=f(a),e.beginPath(),e.moveTo(m[1].x,m[1].y),e.lineTo(m[0].x,m[0].y),e.lineTo(m[3].x,m[3].y),e.lineTo(m[2].x,m[2].y),e.stroke(),e.restore()}function K0(e,t,n={}){const i=n.offstage??{x:2e3,y:1400},s=n.enter??450,r=n.exit??450,o=n.linger??1500,a=[...e].filter(p=>p.path.length>0).sort((p,g)=>p.start-g.start),l=p=>p.tool??"pencil",c=p=>{const g=Math.min(1,Math.max(0,p));return g*g*(3-2*g)},h=(p,g,y)=>({x:p.x+(g.x-p.x)*y,y:p.y+(g.y-p.y)*y}),u=a.find(p=>t>=p.start&&t<=p.end);if(u){const p=u.end-u.start,g=p>0?(t-u.start)/p:1;return{at:gn(u.path,g),tool:l(u),lift:0,drawing:!0}}const f=[...a].reverse().find(p=>p.end<t),d=a.find(p=>p.start>t),m=p=>p.path[p.path.length-1];if(f&&d&&d.start-f.end<=o){const p=(t-f.end)/(d.start-f.end),g=p<.5?l(f):l(d);return{at:h(m(f),d.path[0],c(p)),tool:g,lift:Math.sin(Math.PI*p),drawing:!1}}if(d&&d.start-t<=s){const p=1-(d.start-t)/s;return{at:h(i,d.path[0],c(p)),tool:l(d),lift:1-c(p),drawing:!1}}if(f&&t-f.end<=r){const p=(t-f.end)/r;return{at:h(m(f),i,c(p)),tool:l(f),lift:c(p),drawing:!1}}return null}function Y0(e,t,n,i=.08,s=32){const r=Math.PI*2*(1+i),o=[];for(let a=0;a<=s;a++){const l=-Math.PI/2+r*a/s;o.push({x:e+Math.cos(l)*n,y:t+Math.sin(l)*n})}return o}function X0(e){const{path:t}=e,n=t.map(a=>a.x),i=t.map(a=>a.y),s=Math.min(...n),r=Math.min(...i),o=e.hand===!1?void 0:e.hand===!0||e.hand===void 0?{}:e.hand;return{type:"custom",x:s,y:r,width:Math.max(1,Math.max(...n)-s),height:Math.max(1,Math.max(...i)-r),props:{draw:0},draw(a,l,c){const h=Math.min(1,Math.max(0,Number(l.props?.draw??0)));a.translate(-s,-r),a.strokeStyle=e.color??"#2f2f33",a.lineWidth=e.lineWidth??5,a.lineCap="round",a.lineJoin="round";const u=e.sketch?yn(a,e.sketch,c):void 0;h>0&&(u?e.smooth?u.curve(t,h):u.line(t,h):bl(a,ee(t,h))),o&&h>0&&h<1&&vs(a,gn(t,h),o,u)}}}function q0(e){const t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return"rgba(0, 0, 0, 0)";const n=t[1].length===3?[...t[1]].map(o=>o+o).join(""):t[1],[i,s,r]=[0,2,4].map(o=>parseInt(n.slice(o,o+2),16));return`rgba(${i}, ${s}, ${r}, 0)`}function bl(e,t,n){if(!(t.length<2)){if(n)return n.line(t);e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t.slice(1))e.lineTo(i.x,i.y);e.stroke()}}const Nn=1e5;function V0(e,t,n,i,s=6){const r=[],o=Math.max(1,Math.round(s));for(let a=0;a<=o;a++)r.push({x:a%2===0?e:e+n,y:t+i*a/o});return r}function Ss(e,t,n,i){if(i<=0||t.length===0)return;const s=ee(t,i),r=n/2,o=a=>{e.beginPath(),e.rect(-Nn,-Nn,2*Nn,2*Nn),a(),e.clip("evenodd")};for(const a of s)o(()=>{e.moveTo(a.x+r,a.y),e.arc(a.x,a.y,r,0,Math.PI*2)});for(let a=1;a<s.length;a++){const l=s[a-1],c=s[a],h=Math.hypot(c.x-l.x,c.y-l.y);if(h===0)continue;const u=-(c.y-l.y)/h*r,f=(c.x-l.x)/h*r;o(()=>{e.moveTo(l.x+u,l.y+f),e.lineTo(c.x+u,c.y+f),e.lineTo(c.x-u,c.y-f),e.lineTo(l.x-u,l.y-f),e.closePath()})}}function U0(e,t,n,i,s){e.save(),Ss(e,t,n,i),s(),e.restore()}function z0(e,t){const n=t.width??40,i=t.hand===!0?{}:t.hand||void 0,s=t.eraser===!1?void 0:t.eraser===!0||t.eraser===void 0?{}:t.eraser;return{...e,props:{...e.props,erase:0},draw(r,o,a){const l=Number(o.props?.erase??0);if(r.save(),Ss(r,t.path,n,l),e.draw(r,o,a),r.restore(),!s||l<=0||l>=1)return;const c=gn(t.path,l);i?vs(r,c,{...i,tool:"eraser"}):ks(r,c,s)}}}const wl=40,G0=.215+.205,it=(e,t)=>{const n={};for(const i of["left","right"])for(const[s,r]of Object.entries(t))n[`${e}.${i}.${s}`]=r;return n},F=(e,t)=>e[t]??q[t]??0;function j0(e,t,n=q,i=1){const s=Le(e),r=t*Math.PI*2,o=Math.sin(r)*i,a=Math.cos(r)*i,l=(1+Math.cos(r*2*(s.bounces??1)))/2,c=s.crouch??0,h=s.shoulder??0,u=s.forearm??0,f={...q,...n};f["leg.left.swing"]=s.swing*o+c*.6,f["leg.right.swing"]=-s.swing*o+c*.6,f["leg.left.knee"]=s.knee*Math.max(0,a)+c*1.2,f["leg.right.knee"]=s.knee*Math.max(0,-a)+c*1.2,f["leg.left.ankle"]=F(n,"leg.left.ankle")-(s.tiptoe??0),f["leg.right.ankle"]=F(n,"leg.right.ankle")-(s.tiptoe??0);for(const[d,m]of[["left",-1],["right",1]])F(n,`arm.${d}.spread`)>wl||F(n,`arm.${d}.swing`)>wl||(f[`arm.${d}.swing`]=h+m*s.arm*o,f[`arm.${d}.elbow`]=F(n,`arm.${d}.elbow`)+u+s.elbow*Math.max(0,m*o));return f.lean=F(n,"lean")+s.lean*i,f.bend=F(n,"bend")+(s.bend??0),f["head.nod"]=F(n,"head.nod")-s.lean*.5*i+(s.headTilt??0),f.side=F(n,"side")+(s.sway??0)*Math.sin(r),f.lift=F(n,"lift")+(s.bounce??0)*i*l,f.stretch=F(n,"stretch")*(1+(s.squash??0)*(l-.5)),f}function J0(e,t,n=1){const i=Le(e);return 4*G0*t*Math.sin(i.swing*n*Math.PI/180)}const le=e=>Ja[e],kl={take:e=>[{after:140,pose:{stretch:.8,bend:10,lean:F(e,"lean")-4,...it("arm",{spread:6,swing:0,elbow:10}),"eye.left":.35,"eye.right":.35,"brow.left":-.6,"brow.right":-.6,mouth:0},easing:"ease-in-out"},{after:260,pose:{stretch:.78}},{after:360,pose:{lift:.22,stretch:1.35,bend:-14,...it("arm",{spread:150,bend:35,swing:0,elbow:0}),...it("leg",{swing:25,knee:60}),...le("shocked")},easing:"ease-out-cubic"},{after:720,pose:{lift:.25,stretch:1.25,bend:-10,...it("arm",{spread:140})},easing:"ease-in-out"},{after:900,pose:{lift:0,stretch:.74,bend:12,...it("arm",{spread:70,bend:0}),...it("leg",{swing:30,knee:60})},easing:"ease-in-quad"},{after:1060,pose:{stretch:1.06,bend:-3,...it("arm",{spread:60}),"leg.left.swing":F(e,"leg.left.swing"),"leg.right.swing":F(e,"leg.right.swing"),"leg.left.knee":F(e,"leg.left.knee"),"leg.right.knee":F(e,"leg.right.knee")},easing:"ease-out"},{after:1260,pose:{stretch:F(e,"stretch"),bend:F(e,"bend"),...le("surprised"),...it("arm",{spread:55,bend:60})},easing:"ease-in-out"}],doubleTake:e=>[{after:160,pose:{lookX:1,lookY:0,"head.turn":0},easing:"ease-out"},{after:520,pose:{lookX:-.6,"head.turn":30,"head.nod":F(e,"head.nod")-4,smile:.6,mouth:0},easing:"ease-in-out"},{after:1100,pose:{lookX:-.6}},{after:1180,pose:{"head.turn":0,"head.nod":F(e,"head.nod")-10,bend:F(e,"bend")-10,lift:.05,stretch:1.18,...le("shocked"),lookX:1,lookY:0},easing:"ease-out-cubic"},{after:1360,pose:{lift:0,stretch:.88,"head.nod":F(e,"head.nod")-4,bend:F(e,"bend")+4},easing:"ease-in-quad"},{after:1560,pose:{stretch:F(e,"stretch"),"head.nod":F(e,"head.nod"),bend:F(e,"bend")},easing:{type:"elastic",mode:"out",amplitude:1,period:.35}}],windUp:()=>[{after:220,pose:{lean:-18,bend:-16,"head.nod":-6,"arm.left.swing":60,"arm.left.elbow":100,"arm.right.swing":-40,"arm.right.elbow":90,"leg.left.swing":55,"leg.left.knee":95,stretch:.92,...le("angry"),lookX:1},easing:"ease-out"},{after:620,pose:{lean:-20,bend:-18,stretch:.9}},{after:700,pose:{lean:28,bend:14,"head.nod":6,"arm.left.swing":-30,"arm.right.swing":60,"leg.left.swing":-20,"leg.left.knee":30,"leg.right.swing":20,stretch:1.12},easing:"ease-out-cubic"}],land:e=>[{after:120,pose:{lift:0,stretch:.7,bend:14,...it("arm",{spread:75}),...it("leg",{swing:25,knee:50})},easing:"ease-in-quad"},{after:300,pose:{stretch:1.05,bend:-4,"arm.left.spread":F(e,"arm.left.spread"),"arm.right.spread":F(e,"arm.right.spread")},easing:"ease-out"},{after:460,pose:{lift:0,stretch:F(e,"stretch"),bend:F(e,"bend"),...it("leg",{swing:0,knee:0})},easing:"ease-in-out"}],tremble:e=>{const t=[{after:80,pose:{...le("scared"),...it("arm",{swing:40,elbow:110,spread:14}),stretch:.94,bend:F(e,"bend")+8},easing:"ease-out"}];for(let n=1;n<=14;n++){const i=n%2===0?1:-1;t.push({after:80+n*45,pose:{side:F(e,"side")+2.5*i,"head.tilt":F(e,"head.tilt")-2*i}})}return t.push({after:755,pose:{side:F(e,"side"),"head.tilt":F(e,"head.tilt"),bend:F(e,"bend")}}),t},deflate:e=>[{after:260,pose:{stretch:1.04,"head.nod":F(e,"head.nod")-4,"brow.left":.3,"brow.right":.3},easing:"ease-in-out"},{after:900,pose:{...le("sad"),bend:18,stretch:.92,lean:F(e,"lean")+5,"head.nod":14,...it("arm",{spread:6,swing:0,elbow:4,bend:0})},easing:"ease-in-out"}]};function Z0(e,t){const n=nt(t.from??{}),i=t.speed??1;let s=n;return[{time:t.at,pose:n},...kl[e](n).map(r=>(s={...s,...r.pose},{time:t.at+r.after*i,pose:s,act:!1,...r.easing?{easing:r.easing}:{}}))]}const Q0=(e,t,n)=>e.slice(Math.floor((e.length-1)*t),Math.ceil((e.length-1)*n)+1);function tp(e={}){const t=e.shirt??"#e2493b",n=e.trousers??"#24476b",i=a=>a.lineWidth*.45,s=(a,l,c)=>{const h=a.parts[`leg.${c}`].points;l.shape($e(h,a.height*.08,a.height*.05),n,i(a))},r=(a,l)=>{const c=a.chains.spine,h=c[0],u=c[c.length-1],f={x:h.x-(u.x-h.x)*.25,y:h.y-(u.y-h.y)*.25};l.shape($e([f,...a.parts.spine.points],a.height*.15,a.height*.14),t,i(a))},o=(a,l,c)=>{const h=a.parts[`arm.${c}`].points,u=h[0],f=a.chains.spine[a.chains.spine.length-1],m=[{x:u.x+(f.x-u.x)*.45,y:u.y+(f.y-u.y)*.45},...Q0(h,0,.45)],p=$e(m,a.height*.085,a.height*.06),g=m.length,y=p.slice(0,g),w=p.slice(g).reverse();l.shape(p,t,0);const k=A=>Math.hypot(A[1].x-f.x,A[1].y-f.y),[M,S]=k(y)>k(w)?[y,w]:[w,y];l.line(M.slice(1),i(a)),l.line(S.slice(Math.ceil(g*.45)),i(a)),l.line([y[g-1],w[g-1]],i(a))};return{parts:{"leg.left":{over:(a,l,c)=>s(l,c,"left")},"leg.right":{over:(a,l,c)=>s(l,c,"right")},spine:{over:(a,l,c)=>r(l,c)},"arm.left":{over:(a,l,c)=>o(l,c,"left")},"arm.right":{over:(a,l,c)=>o(l,c,"right")}}}}const Wn={full:{anticipation:.12,anticipationTime:.3,hold:0,overshoot:.08,settle:220,settleEase:"ease-in-out",actionEase:"ease-in-out-cubic",overlap:45,eyeLead:120,eyeDart:160,drift:.12,blinks:!0,jumpSquash:1},snappy:{anticipation:.2,anticipationTime:.35,hold:.12,overshoot:.12,settle:320,settleEase:{type:"elastic",mode:"out",amplitude:1,period:.35},actionEase:"ease-out-cubic",overlap:35,eyeLead:100,eyeDart:100,drift:.1,blinks:!0,jumpSquash:1.3},limited:{anticipation:.06,anticipationTime:.25,hold:0,overshoot:0,settle:0,settleEase:"ease-out",actionEase:"ease-in-out",overlap:30,eyeLead:80,eyeDart:120,drift:0,blinks:!0,jumpSquash:.6},none:{anticipation:0,anticipationTime:0,hold:0,overshoot:0,settle:0,settleEase:"linear",actionEase:"linear",overlap:0,eyeLead:0,eyeDart:0,drift:0,blinks:!1,jumpSquash:0}};function vl(e){if(e===void 0)return Wn.full;if(typeof e=="string")return Wn[e];const{base:t,...n}=e;return{...Wn[t??"full"],...n}}const Ms=160,ep=120,np=700,Ts=60,ip=90,Kn=3200,ce=1,Ft=1e-6;function Es(e,t,n={}){const i=vl(n.style),s=n.seed??1,r={};if(e.length===0)return r;const o=Object.keys(e[0].pose).filter(u=>e.some(f=>Math.abs(f.pose[u]-e[0].pose[u])>Ft));for(const u of o)r[u]=sp(u,e,t,i,s);const a=t.blink,l=a!==void 0&&o.includes(a);if(i.blinks&&a!==void 0&&!l&&a in e[0].pose){const u=rp(e,t,i,s,e[0].pose[a]);u.length>0&&(r[a]=u)}const{lift:c,stretch:h}=t;if(i.jumpSquash>0&&c&&h&&o.includes(c)&&!o.includes(h)&&h in e[0].pose){const u=op(e,c,e[0].pose[h],i.jumpSquash);u.length>0&&(r[h]=u)}return r}function sp(e,t,n,i,s){const r=n.eyes.includes(e),o=n.limits[e],a=o!==void 0,l=r?-i.eyeLead:(n.depth[e]??1)*i.overlap,c=d=>{const m=(t[d].time-t[d-1].time)/2;return Math.max(-m,Math.min(m,l))},h=[{time:t[0].time,value:t[0].pose[e]}],u=(d,m,p)=>{const g=h[h.length-1];if(d<=g.time+ce){h[h.length-1]={...g,value:m,...p?{easing:p}:{}};return}h.push({time:d,value:m,...p?{easing:p}:{}})};let f=t[0].pose[e];for(let d=1;d<t.length;d++){const m=t[d],p=t[d-1].pose[e],g=m.pose[e],y=g-p,w=h[h.length-1].time,k=m.act!==!1;if(Math.abs(y)<=Ft){const P=m.time+(k?c(d):0);if(d===t.length-1)Math.abs(f-g)>Ft&&u(Math.max(P,w+Ms),g,"ease-in-out"),f=g;else if(k&&a&&i.drift>0&&n.drift.includes(e)&&P-w>=np){const x=Gt(`${s}:${e}:${d}`)%2===0?1:-1;f=g+x*i.drift*o,u(P,f,"ease-in-out")}continue}if(!k){u(t[d-1].time,f),u(m.time,g,m.easing),f=g;continue}const M=c(d),S=Math.max(t[d-1].time+M,w);let A=m.time+M;r&&i.eyeDart>0&&(A=Math.min(A,S+i.eyeDart));const E=A-S;if(E<=ce){u(m.time,g,m.easing),f=g;continue}u(S,f);const T=Math.sign(y);if(a&&i.anticipation>0&&o>0&&E>=Ms){const P=f-T*Math.min(Math.abs(y)*i.anticipation,o),x=S+E*i.anticipationTime;u(x,P,"ease-in-out"),i.hold>0&&u(x+E*i.hold,P)}const v=d+1<t.length?t[d+1].time-m.time:1/0,_=Math.min(i.settle,v/2);if(a&&i.overshoot>0&&o>0&&E>=ep&&_>ce){const P=Math.min(Math.abs(y)*i.overshoot,o);u(A,g+T*P,m.easing??i.actionEase),u(A+_,g,i.settleEase)}else u(A,g,m.easing??i.actionEase);f=g}return h}function rp(e,t,n,i,s){const r=[],o=Ts+ip;for(let d=1;d<e.length;d++){const m=e[d-1].pose,p=e[d].pose;Object.entries(t.headTurns).some(([y,w])=>Math.abs((p[y]??0)-(m[y]??0))>w)&&e[d].act!==!1&&r.push(Math.max(e[0].time,e[d-1].time-n.eyeLead))}const a=e[0].time,l=e[e.length-1].time,c=[...r];let h=a+Kn*.6,u=0;for(;h<l;){c.some(p=>Math.abs(p-h)<Kn/2)||r.push(h);const m=(Gt(`${i}:blink:${u++}`)%1e3/1e3-.5)*(Kn*.66);h+=Kn+m}r.sort((d,m)=>d-m);const f=[{time:a,value:s}];for(const d of r){const m=f[f.length-1].time;d+Ts<=m+ce||(d>m+ce&&f.push({time:d,value:s}),f.push({time:d+Ts,value:1,easing:"ease-in"}),f.push({time:d+o,value:s,easing:"ease-out"}))}return f.length>1?f:[]}function op(e,t,n,i){const s=n*(1-.18*i),r=n*(1+.14*i),o=[{time:e[0].time,value:n}],a=(l,c,h)=>{const u=o[o.length-1];l<=u.time+ce||o.push({time:l,value:c,...h?{easing:h}:{}})};for(let l=1;l<e.length;l++){const c=e[l-1].pose[t],h=e[l].pose[t],u=e[l-1].time,f=e[l].time,d=f-u;if(!(d<Ms||e[l].act===!1)){if(c<=Ft&&h>Ft)a(u,n),a(u+d*.2,s,"ease-out"),a(u+d*.45,r,"ease-out"),a(f,n,"ease-in-out");else if(c>Ft&&h<=Ft){const m=l+1<e.length?e[l+1].time-f:400;a(u+d*.5,n),a(f-Math.min(60,d*.15),r,"ease-in"),a(f,s,"ease-out"),a(f+Math.min(260,m/2),n,{type:"back",mode:"out",overshoot:1.4})}}}return o.length>1?o:[]}const Sl={depth:{lean:0,bend:0,rise:0,sit:0,spin:0,stretch:0,turn:0,leftHip:0,rightHip:0,headTilt:1,leftShoulder:1,rightShoulder:1,leftKnee:1,rightKnee:1,leftBrow:1,rightBrow:1,browTilt:1,leftEye:1,rightEye:1,leftElbow:2,rightElbow:2,leftAnkle:2,rightAnkle:2,leftFootOut:2,rightFootOut:2,mouth:2,smile:2,mouthWidth:2,leftWrist:3,rightWrist:3},limits:{lean:10,bend:10,headTilt:12,spin:25,turn:.06,sit:.06,stretch:.08,rise:0,leftShoulder:20,rightShoulder:20,leftElbow:18,rightElbow:18,leftWrist:15,rightWrist:15,leftHip:12,rightHip:12,leftKnee:15,rightKnee:15,leftAnkle:10,rightAnkle:10,leftBrow:.25,rightBrow:.25,leftEye:.15,rightEye:.15},eyes:["lookX","lookY"],blink:"blink",headTurns:{turn:.15,headTilt:8,lookX:.5,spin:45},drift:["lean","bend","headTilt","leftShoulder","rightShoulder","leftElbow","rightElbow"],lift:"rise",stretch:"stretch"};function ap(e){return/^(turn|lean|bend|side|lift|roll|stretch)$/.test(e)?{depth:0,limit:{turn:.06,lean:10,bend:10,side:8,lift:0,roll:25,stretch:.08}[e]}:/^leg\.\w+\.(swing|spread|rotate)$/.test(e)?{depth:0,limit:12}:/^head\./.test(e)?{depth:1,limit:12}:/^arm\.\w+\.(swing|spread)$/.test(e)?{depth:1,limit:20}:/^leg\.\w+\.knee$/.test(e)?{depth:1,limit:15}:/^(brow\.|browTilt$)/.test(e)?{depth:1,limit:e==="browTilt"?void 0:.25}:/^eye\./.test(e)?{depth:1,limit:.15}:/^arm\.\w+\.(elbow|bend)$/.test(e)?{depth:2,limit:18}:/^leg\.\w+\.(ankle|toeOut)$/.test(e)?{depth:2,limit:10}:/^(mouth|smile|mouthWidth)$/.test(e)?{depth:2}:/^hand\./.test(e)?{depth:3}:{depth:1}}function lp(){const e={},t={};for(const n of Object.keys(q)){const i=ap(n);e[n]=i.depth,i.limit!==void 0&&(t[n]=i.limit)}return{depth:e,limits:t,eyes:["lookX","lookY"],blink:"blink",headTurns:{turn:.15,"head.turn":15,"head.nod":12,lookX:.5,roll:45},drift:["lean","bend","head.tilt","head.nod","arm.left.spread","arm.right.spread","arm.left.elbow","arm.right.elbow"],lift:"lift",stretch:"stretch"}}const Ml=lp();function Tl(e,t){return Object.entries(t).map(([n,i])=>({id:`${e}-${n}`,target:e,property:n,keyframes:i}))}function El(e,t,n={}){const i=Qi(t),s=t.map((r,o)=>({time:r.time,pose:{...i[o]},easing:r.easing,act:r.act}));return Tl(e,Es(s,n.rig??Sl,n))}function cp(e,t,n={}){const i=n.rest??q,s=ws(t,i),r=t.map((o,a)=>({time:o.time,pose:{...i,...s[a]},easing:o.easing,act:o.act}));return Tl(e,Es(r,n.rig??Ml,n))}const Al=G.shocked,hp=G.scared,Yn={take:e=>[{after:140,pose:{stretch:.8,bend:10,lean:e.lean-4,leftShoulder:8,rightShoulder:8,leftEye:.35,rightEye:.35,leftBrow:-.6,rightBrow:-.6,mouth:0},easing:"ease-in-out"},{after:260,pose:{stretch:.78}},{after:360,pose:{rise:.22,stretch:1.35,bend:-14,leftShoulder:150,rightShoulder:150,leftElbow:35,rightElbow:35,leftHip:22,rightHip:22,leftKnee:45,rightKnee:45,...Al,headTilt:0},easing:"ease-out-cubic"},{after:720,pose:{rise:.25,stretch:1.25,bend:-10,leftShoulder:140,rightShoulder:140},easing:"ease-in-out"},{after:900,pose:{rise:0,stretch:.74,bend:12,leftShoulder:70,rightShoulder:70,leftHip:18,rightHip:18,leftKnee:30,rightKnee:30},easing:"ease-in-quad"},{after:1060,pose:{stretch:1.06,bend:-3,leftShoulder:60,rightShoulder:60,leftHip:e.leftHip,rightHip:e.rightHip,leftKnee:e.leftKnee,rightKnee:e.rightKnee},easing:"ease-out"},{after:1260,pose:{stretch:e.stretch,bend:e.bend,...G.surprised,leftShoulder:70,rightShoulder:70,leftElbow:60,rightElbow:60},easing:"ease-in-out"}],doubleTake:e=>[{after:160,pose:{lookX:1,lookY:0},easing:"ease-out"},{after:520,pose:{lookX:-.6,headTilt:e.headTilt-4,smile:.6,mouth:0},easing:"ease-in-out"},{after:1100,pose:{lookX:-.6}},{after:1180,pose:{bend:e.bend-10,headTilt:e.headTilt+10,rise:.05,stretch:1.18,...Al,lookX:1,lookY:0},easing:"ease-out-cubic"},{after:1360,pose:{rise:0,stretch:.88,bend:e.bend+4,headTilt:e.headTilt+4},easing:"ease-in-quad"},{after:1560,pose:{stretch:e.stretch,bend:e.bend,headTilt:e.headTilt},easing:{type:"elastic",mode:"out",amplitude:1,period:.35}}],windUp:()=>[{after:220,pose:{lean:-18,bend:-16,headTilt:-6,leftShoulder:70,leftElbow:-100,rightShoulder:40,rightElbow:100,leftHip:-45,leftKnee:-80,stretch:.92,...G.angry,lookX:1},easing:"ease-out"},{after:620,pose:{lean:-20,bend:-18,stretch:.9}},{after:700,pose:{lean:28,bend:14,headTilt:6,leftShoulder:30,rightShoulder:60,leftHip:30,leftKnee:-30,rightHip:-20,stretch:1.12},easing:"ease-out-cubic"}],land:e=>[{after:120,pose:{rise:0,stretch:.7,bend:14,leftShoulder:75,rightShoulder:75,leftHip:20,rightHip:20,leftKnee:35,rightKnee:35},easing:"ease-in-quad"},{after:300,pose:{stretch:1.05,bend:-4,leftShoulder:e.leftShoulder,rightShoulder:e.rightShoulder},easing:"ease-out"},{after:460,pose:{rise:0,stretch:e.stretch,bend:e.bend,leftHip:W.leftHip,rightHip:W.rightHip,leftKnee:0,rightKnee:0},easing:"ease-in-out"}],tremble:e=>{const t=[{after:80,pose:{...hp,bend:e.bend+8,leftShoulder:40,rightShoulder:40,leftElbow:110,rightElbow:110,stretch:.94},easing:"ease-out"}];for(let n=1;n<=14;n++)t.push({after:80+n*45,pose:{lean:e.lean+(n%2===0?2.5:-2.5),headTilt:e.headTilt+(n%2===0?-2:2)}});return t.push({after:755,pose:{lean:e.lean,headTilt:e.headTilt,bend:e.bend}}),t},deflate:e=>[{after:260,pose:{stretch:1.04,headTilt:e.headTilt+4,leftBrow:.3,rightBrow:.3},easing:"ease-in-out"},{after:900,pose:{...se.sad,bend:18,stretch:.92,lean:e.lean+5,turn:e.turn,sit:e.sit},easing:"ease-in-out"}]};function As(e,t){const n=typeof t.from=="string"?se[t.from]:t.from??W,i=t.speed??1;let s=n;return[{time:t.at,pose:n},...Yn[e](n).map(r=>(s={...s,...r.pose},{time:t.at+r.after*i,pose:s,act:!1,...r.easing?{easing:r.easing}:{}}))]}function xs(e,t=1){const n=Yn[e](W);return n[n.length-1].after*t}function xl(e,t,n={}){if(t.length<2)return;const i=Math.max(1,Math.round(n.lines??3)),s=n.spacing??5,r=n.lineWidth??2,o=n.opacity??.7;e.save(),e.strokeStyle=n.color??"#222",e.lineCap="round";for(let a=0;a<i;a++){const l=(a-(i-1)/2)*s,c=Math.floor(Math.abs(l)/Math.max(s,1)*(t.length/6));for(let h=c+1;h<t.length;h++){const u=t[h-1],f=t[h],d=f.x-u.x,m=f.y-u.y,p=Math.hypot(d,m)||1,g=-m/p,y=d/p,w=1-h/(t.length-1);e.globalAlpha=o*(1-w),e.lineWidth=r*(1-w*.7),e.beginPath(),e.moveTo(u.x+g*l,u.y+y*l),e.lineTo(f.x+g*l,f.y+y*l),e.stroke()}}e.restore()}const up={hands:[{name:"left hand",at:e=>e.hands.left},{name:"right hand",at:e=>e.hands.right}],toes:[{name:"left toe",at:e=>e.toes.left},{name:"right toe",at:e=>e.toes.right}],head:[{name:"head",at:e=>e.head.center}],body:[{name:"hip",at:e=>e.hip},{name:"neck",at:e=>e.neck}]};function fp(e,t,n,i,s={}){const r=n.stateAt;if(!r)return;const o=s.length??120,a=Math.max(2,Math.round(s.samples??8)),l=Math.max(0,n.time-o);if(n.time-l<1)return;const c=[];for(let d=0;d<a;d++){const m=l+(n.time-l)*d/(a-1);c.push(Fa(t,{time:m,state:r(m)},i).joints)}const h=c[c.length-1].height,u=(s.threshold??1.2)*h,f=(s.parts??["hands","toes","head"]).flatMap(d=>up[d]);for(const d of f){const m=c.map(d.at);let p=0;for(let w=1;w<m.length;w++)p+=Math.hypot(m[w].x-m[w-1].x,m[w].y-m[w-1].y);const g=p/((n.time-l)/1e3);if(g<=u)continue;const y=Math.min(1,(g-u)/(u*.5));xl(e,m,{...s,opacity:(s.opacity??.7)*y,spacing:s.spacing??h*.02})}}function dp(e,t,n,i={}){if(n<=0||n>=1)return;const s=i.size??40,r=i.seed??1,o=.45+.55*(1-(1-n)**3);e.save(),e.strokeStyle=i.color??"#555",e.lineWidth=Math.max(1,s*.03),e.globalAlpha=Math.min(1,n/.08)*(1-n);for(let a=0;a<5;a++){const l=Gt(`${r}:puff:${a}`)%1e3/1e3,c=a-2,h=t.x+c*s*.3*o,u=t.y-s*(.06+.12*l)*o+Math.abs(c)*s*.03,f=s*(.11+.07*l)*o;e.beginPath(),e.arc(h,u,f,Math.PI*.95,Math.PI*2.05),e.stroke()}e.restore()}function pp(e,t,n,i={}){if(n<=0||n>=1)return;const s=i.size??40,r=5,o=1-(1-n)**2;e.save(),e.strokeStyle=i.color??"#222",e.lineWidth=Math.max(1,s*.035),e.lineJoin="round",e.globalAlpha=n<.7?1:(1-n)/.3;for(let a=0;a<r;a++){const l=-Math.PI/2+(a-(r-1)/2)*Math.PI/(r+1),c=s*(.3+.7*o),h=t.x+Math.cos(l)*c,u=t.y+Math.sin(l)*c;mp(e,h,u,s*.14,n*Math.PI+a),e.stroke()}e.restore()}function mp(e,t,n,i,s){e.beginPath();for(let r=0;r<10;r++){const o=r%2===0?i:i*.45,a=s+r*Math.PI/5-Math.PI/2,l=t+Math.cos(a)*o,c=n+Math.sin(a)*o;r===0?e.moveTo(l,c):e.lineTo(l,c)}e.closePath()}const Et={rest:{mouth:0,mouthWidth:1},a:{mouth:.75,mouthWidth:1.1},e:{mouth:.45,mouthWidth:1.3},i:{mouth:.28,mouthWidth:1.45},o:{mouth:.6,mouthWidth:.7},u:{mouth:.32,mouthWidth:.55},m:{mouth:0,mouthWidth:.9},f:{mouth:.1,mouthWidth:1.05},l:{mouth:.3,mouthWidth:1},c:{mouth:.2,mouthWidth:1}},Ke=1,Xn=.55,Pl=.35,gp=1.6,_l={a:"a",e:"e",i:"i",y:"i",o:"o",u:"u"},Il={m:"m",b:"m",p:"m",f:"f",v:"f",w:"u",q:"u",l:"l",n:"l",d:"l",t:"l"},Cl={अ:"a",आ:"a",इ:"i",ई:"i",उ:"u",ऊ:"u",ऋ:"i",ए:"e",ऐ:"e",ओ:"o",औ:"o",ऍ:"e",ऑ:"o"},Hl={"ा":"a","ि":"i","ी":"i","ु":"u","ू":"u","ृ":"i","े":"e","ै":"e","ो":"o","ौ":"o","ॅ":"e","ॉ":"o"},yp={प:"m",फ:"m",ब:"m",भ:"m",म:"m",व:"u"},bp="्",$l="़",wp=e=>e>="क"&&e<="ह",Rl=new Set([".",",","!","?",";",":","…","।","॥","—","-"]);function Ol(e){const t=[],n=Array.from(e.toLowerCase()),i=(s,r)=>{const o=t[t.length-1];o&&o.viseme===s?o.weight+=r*.5:t.push({viseme:s,weight:r})};for(let s=0;s<n.length;s++){const r=n[s],o=n[s+1];if(Rl.has(r))i("rest",gp);else if(/\s/.test(r)){const a=t[t.length-1];a&&a.viseme!=="rest"&&t.push({viseme:"c",weight:Pl})}else if((r==="o"||r==="e")&&o===r)i(r==="o"?"u":"i",Ke),s++;else if(r in _l)i(_l[r],Ke);else if(r in Il)i(Il[r],Xn);else{if(r==="h")continue;if(/[a-z]/.test(r))i("c",Xn);else if(r in Cl)i(Cl[r],Ke);else if(wp(r)){const a=o===$l?r==="फ"?"f":void 0:yp[r];i(a??"c",Xn);let l=s+1;n[l]===$l&&l++;const c=n[l];c===bp?s=l:c&&c in Hl?(i(Hl[c],Ke),s=l):(!c||/\s/.test(c)||Rl.has(c)||i("a",Ke*.6),s=l-1)}else(r==="ं"||r==="ँ")&&i("l",Xn*.6)}}for(;t.length>0&&(t[t.length-1].viseme==="rest"||t[t.length-1].weight===Pl);)t.pop();return t}function Ps(e,t={}){const n=t.fields?.mouth??"mouth",i=t.fields?.mouthWidth??"mouthWidth",s=t.energy??1,r=Ol(e.text),o=[{time:e.start,value:Et.rest.mouth}],a=[{time:e.start,value:Et.rest.mouthWidth}],l=r.reduce((h,u)=>h+u.weight,0),c=e.end-e.start;if(l>0&&c>0){let h=e.start;for(const u of r){const f=c*u.weight/l,d=h+Math.min(f*.4,60);if(d>o[o.length-1].time){const m=Et[u.viseme];o.push({time:d,value:m.mouth*s,easing:"ease-out"}),a.push({time:d,value:1+(m.mouthWidth-1)*Math.min(1.3,s),easing:"ease-out"})}h+=f}}return e.end>o[o.length-1].time&&(o.push({time:e.end,value:Et.rest.mouth,easing:"ease-in-out"}),a.push({time:e.end,value:Et.rest.mouthWidth,easing:"ease-in-out"})),{[n]:o,[i]:a}}function kp(e,t,n={}){const i={};for(const s of[...t].sort((r,o)=>r.start-o.start))for(const[r,o]of Object.entries(Ps(s,n))){const a=i[r]??=[],l=a.length>0?a[a.length-1].time:-1/0;a.push(...o.filter(c=>c.time>l))}return Object.entries(i).map(([s,r])=>({id:`${e}-${s}`,target:e,property:s,keyframes:r}))}function Ll(e,t,n,i={}){if(n.length===0)return t;const s=i.fields?.mouth??"mouth",r=i.fields?.mouthWidth??"mouthWidth",o={[s]:Et.rest.mouth,[r]:Et.rest.mouthWidth,...i.rest},a=new ve({id:"before-speech",tracks:t}),l=(u,f)=>a.getStateAtTime(f).values.get(e)?.get(u)??o[u],c=[s,r],h=t.filter(u=>u.target!==e||!c.includes(u.property));for(const u of c){const f=t.find(m=>m.target===e&&m.property===u);let d=f?[...f.keyframes]:[{time:0,value:l(u,0)}];for(const m of n){const p=Ps(m,i)[u];p[0]={...p[0],value:l(u,m.start)},p[p.length-1]={...p[p.length-1],value:l(u,m.end)},d=[...d.filter(g=>g.time<m.start||g.time>m.end),...p],d.sort((g,y)=>g.time-y.time)}h.push({id:f?.id??`${e}-${u}`,target:e,property:u,keyframes:d})}return h}const _s={walk:1e3,bouncy:900,doubleBounce:1100,sneak:1600,strut:1100,tired:1500,run:560},vp=450,Sp=2.4,Mp=160,Fl=2.5,At=450,Dl=1200,Tp=700,he=320,ue=220,Ep=65,Ap=700,Is=e=>e in $t,Bl=e=>e in Yn,xp=e=>e in se;function Nl(e){return Math.max(Ap,Array.from(e).length*Ep)}function Pp(e,t,n={}){const i=n.from??0,s=n.height??300;let r=i,o=n.facing??1,a=n.start??W,l=0,c=0;const h=[{time:0,pose:a}],u=[{time:0,value:0}],f=[{time:0,value:0}],d=[{time:0,value:0}],m=[{time:0,value:"walk"}],p=[{time:0,value:o}],g=[],y=[],w=[],k=(T,v,_,P)=>{a={...a,...v},_&&(a=ie(a,_)),h.push({time:T,pose:a})},M=(T,v,_)=>(k(T+he/2,{turn:0},_),p.push({time:T+he/2,value:o},{time:T+he/2+1,value:v}),o=v,k(T+he,{turn:1}),T+he),S=T=>T<r?-1:1;for(const T of t){const v=Math.max(T.at??c,c===0?0:h[h.length-1].time);let _=v;const P=T.pose??{};if(Is(T.do)){const x=T.to??r,I=x===r?o:S(x);let C=v;I!==o?C=M(v,I,T.mood):a.turn<1?(C=v+ue,k(C,{turn:1,...P},T.mood)):(T.mood||T.pose)&&k(v+ue,P,T.mood);const R=Math.abs(x-r)/oa(T.do,s),B=T.for??Math.max(ue*2,R*_s[T.do]),$=C+B;m.push({time:C,value:T.do}),d.push({time:C,value:0},{time:C+ue,value:1,easing:"ease-out"}),d.push({time:$-ue,value:1},{time:$,value:0,easing:"ease-in"}),f.push({time:C,value:l},{time:$,value:l+R}),u.push({time:C,value:r-i},{time:$,value:x-i}),l+=R,r=x,k($,{}),_=$}else if(T.do==="zip"){const x=T.to??r,I=x===r?o:S(x);let C=v;I!==o?C=M(v,I,T.mood):a.turn<1&&(C=v+ue,k(C,{turn:1},T.mood));const H=As("windUp",{at:C,from:T.mood?ie(a,T.mood):a});h.push(...H),a=H[H.length-1].pose;const R=C+xs("windUp"),B=R+vp,$=B+Math.max(Mp,Math.abs(x-r)/Sp);m.push({time:R,value:"run"}),d.push({time:R,value:0},{time:R+80,value:1,easing:"ease-out"},{time:$,value:1},{time:$+120,value:0}),f.push({time:R,value:l},{time:B,value:l+Fl,easing:"ease-in"}),l+=Fl+($-B)/_s.run*1.5,f.push({time:$,value:l}),u.push({time:B,value:r-i},{time:$,value:x-i,easing:"ease-in"}),w.push({kind:"dust",time:B,x:r,length:900}),r=x,k($,{}),_=$}else if(Bl(T.do)){const x=As(T.do,{at:v,from:T.mood?ie(a,T.mood):a});h.push(...x),a=x[x.length-1].pose,_=v+xs(T.do),T.do==="take"&&w.push({kind:"dust",time:v+900,x:r,length:500}),T.do==="land"&&w.push({kind:"dust",time:v+120,x:r,length:500})}else if(T.do==="look"||T.do==="face"){const x=T.toward??"viewer",I=T.for??Tp;if(x==="viewer")k(v+At,{turn:0,lookX:0,lookY:0,...P},T.mood);else if(x==="ahead")k(v+At,{turn:T.do==="face"?1:.6,lookX:1,...P},T.mood);else if(x==="back")k(v+At,{turn:.2,lookX:-1,...P},T.mood);else{const C=S(x);C!==o&&T.do==="face"?(M(v,C,T.mood),k(v+he+1,{lookX:1,...P})):C!==o?k(v+At,{turn:.25,lookX:-1,...P},T.mood):k(v+At,{turn:T.do==="face"?1:.6,lookX:1,...P},T.mood)}_=v+Math.max(I,At)}else if(xp(T.do)||T.do==="stand"){const x=T.do==="stand"?W:se[T.do],I=x.turn!==W.turn?x.turn:a.turn,C=T.mood?G[T.mood]:{lookX:a.lookX,lookY:a.lookY};k(v+At,{...x,turn:I,...C,...P}),_=v+(T.for??Dl)}else{const x=T.for??(T.say?Nl(T.say):Dl);(T.mood||T.pose)&&k(v+Math.min(At,x/2),P,T.mood),_=v+x}if(T.say){const x=Is(T.do)||Bl(T.do)?v:v+Math.min(150,(_-v)/4),I=Is(T.do)?_:Math.max(x+200,_-100);g.push({text:T.say,start:x,end:I}),T.do==="say"&&Cp(h,a,x,I)}_>h[h.length-1].time&&h.push({time:_,pose:a}),y.push({start:v,end:_}),c=_}const A=El(e,Ip(h),n),E=[{id:`${e}-x`,target:e,property:"x",keyframes:u},{id:`${e}-walk`,target:e,property:"walk",keyframes:f},{id:`${e}-walking`,target:e,property:"walking",keyframes:d},{id:`${e}-gait`,target:e,property:"gait",keyframes:m},{id:`${e}-facing`,target:e,property:"facing",keyframes:p}].filter(T=>T.keyframes.length>1||T.property==="x");return{tracks:[...Ll(e,A,g,{energy:n.energy}),...E],duration:c,lines:g,keys:h,beats:y,effects:w}}const _p=30;function Ip(e){const t=[];for(const n of e){const i=t[t.length-1];i&&n.time-i.time<_p?t[t.length-1]={...n,time:i.time}:t.push(n)}return t}function Cp(e,t,n,i){const r=e.filter(l=>l.time>n),o=e.filter(l=>l.time<=n),a=[];for(let l=n+520,c=0;l<i-520/2;l+=520,c++){const h=c%2===0?3:-2;a.push({time:l,pose:{...t,headTilt:t.headTilt+h,leftBrow:t.leftBrow+(c%2===0?.25:0),rightBrow:t.rightBrow+(c%2===0?.25:0)}})}a.length>0&&a.push({time:i,pose:t}),e.length=0,e.push(...o,...a.filter(l=>!r.some(c=>Math.abs(c.time-l.time)<60)),...r),e.sort((l,c)=>l.time-c.time)}function Hp(e){const{timeline:t}=e,n=new Ct;for(const[c,h]of Object.entries(e.targets)){const u=typeof h=="string"?document.querySelector(h):h;if(!u)throw new Error(`quickPlay: no element found for target "${c}" (${String(h)})`);n.registerTarget(c,u)}t.onUpdate=c=>{n.applyState(c),e.onUpdate?.(c)},e.onComplete&&(t.onComplete=e.onComplete);let i=null,s=null,r=!1;const o=c=>{if(r)return;const h=s===null?0:c-s;s=c,h>0&&t.tick(h),i=requestAnimationFrame(o)},a=()=>{i!==null||r||(s=null,i=requestAnimationFrame(o))},l=()=>{i!==null&&cancelAnimationFrame(i),i=null,s=null};return n.applyState(t.getStateAtTime(t.currentTime)),e.autoplay!==!1&&(t.play(),a()),{timeline:t,adapter:n,play(){t.play(),a()},pause(){t.pause(),l()},restart(){t.stop(),t.play(),a()},seek(c){t.seek(c*1e3),n.applyState(t.getStateAtTime(t.currentTime))},destroy(){r=!0,l(),t.stop(),n.clearTargets()}}}const $p={timeline:Fh,to(e,t,n){const i=new It(n);return i.to(e,t),i},from(e,t,n){const i=new It(n);return i.from(e,t),i},fromTo(e,t,n,i){const s=new It(i);return s.fromTo(e,t,n),s},set(e,t,n){const i=new It(n);return i.set(e,t),i}};function Wl(e,t,n){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(t,n);const i=e.canvas;if(i?.ownerDocument){const s=i.ownerDocument.createElement("canvas");return s.width=t,s.height=n,s}try{return i?.constructor?new i.constructor(t,n):null}catch{return null}}function Rp(e,t){const n=e.length/4,i=new Float32Array(n*3),s=Math.min(.999,Math.max(0,t));for(let r=0;r<n;r++){const o=e[r*4]/255,a=e[r*4+1]/255,l=e[r*4+2]/255,c=e[r*4+3]/255,h=Math.max(o,a,l);if(h<=s)continue;const u=(h-s)/(1-s)*c/h;i[r*3]=o*u,i[r*3+1]=a*u,i[r*3+2]=l*u}return i}function Kl(e,t,n,i,s){const r=new Float32Array(e.length),o=s?n:t,a=s?t:n,l=(h,u)=>(s?h*t+u:u*t+h)*3,c=i*2+1;for(let h=0;h<o;h++)for(let u=0;u<3;u++){let f=0;for(let d=-i;d<=i;d++)f+=e[l(h,Math.min(a-1,Math.max(0,d)))+u];for(let d=0;d<a;d++){r[l(h,d)+u]=f/c;const m=e[l(h,Math.max(0,d-i))+u],p=e[l(h,Math.min(a-1,d+i+1))+u];f+=p-m}}return r}function Yl(e,t,n,i){const s=Math.max(1,Math.round(i/Math.sqrt(3)));let r=e;for(let o=0;o<3;o++)r=Kl(r,t,n,s,!0),r=Kl(r,t,n,s,!1);return r}function Op(e,t={}){const n=e.canvas,i=n.width,s=n.height;if(!(i>0&&s>0))return;const r=Math.max(1,Math.round(t.downsample??4)),o=Math.max(1,Math.ceil(i/r)),a=Math.max(1,Math.ceil(s/r)),l=Wl(e,o,a),c=l?.getContext("2d");if(!l||!c)return;c.imageSmoothingEnabled=!0,c.drawImage(e.canvas,0,0,o,a);const h=Rp(c.getImageData(0,0,o,a).data,t.threshold??.55),u=(t.radius??Math.max(i,s)*.02)/r,f=Yl(h,o,a,u),d=Yl(h,o,a,u*3),m=t.halo??.6,p=c.createImageData(o,a);for(let g=0;g<o*a;g++){for(let y=0;y<3;y++)p.data[g*4+y]=Math.round(Math.min(1,f[g*3+y]+d[g*3+y]*m)*255);p.data[g*4+3]=255}c.putImageData(p,0,0),e.save(),e.setTransform(1,0,0,1,0,0),e.globalCompositeOperation="lighter",e.globalAlpha=Math.max(0,t.strength??.9),e.imageSmoothingEnabled=!0,e.drawImage(l,0,0,i,s),e.restore()}function Lp(e,t,n){const i=n.width??6,s=n.taper??1,r=n.fade??1,o=n.opacity??1,a=n.blend==="add";if(e.save(),t.length>=2){const c=Dp(t,i,s,r,o);a?(e.globalCompositeOperation="lighter",Cs(e,c,n.color)):Bp(e,c,n.color)}const l=t[t.length-1];if(n.head&&l&&n.head.radius>0){a&&(e.globalCompositeOperation="lighter");const c=n.head.color??n.color,h=e.createRadialGradient(l.at.x,l.at.y,0,l.at.x,l.at.y,n.head.radius);h.addColorStop(0,c),h.addColorStop(.35,c),h.addColorStop(1,Fp(e,c)),e.globalAlpha=o,e.fillStyle=h,e.beginPath(),e.arc(l.at.x,l.at.y,n.head.radius,0,Math.PI*2),e.fill()}e.restore()}function Fp(e,t){e.fillStyle=t;const n=String(e.fillStyle),i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(n);if(i)return`rgba(${parseInt(i[1],16)}, ${parseInt(i[2],16)}, ${parseInt(i[3],16)}, 0)`;const s=/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i.exec(n);return s?`rgba(${s[1]}, ${s[2]}, ${s[3]}, 0)`:"rgba(0, 0, 0, 0)"}function Dp(e,t,n,i,s){const r=e.map(c=>({x:c.at.x,y:c.at.y,width:t*(1-n*c.age)})),o=Dr(r),a=Br(r)??void 0,l=[];for(let c=0;c+1<e.length;c++){const h=(e[c].age+e[c+1].age)/2,u=s*(1-i*h);if(u<=0)continue;const f=c+2===e.length;l.push({corners:[o.left[c],o.left[c+1],o.right[c+1],o.right[c]],alpha:u,...f&&a&&{cap:a}})}return l}function Cs(e,t,n){e.fillStyle=n;for(const i of t){const[s,r,o,a]=i.corners;e.globalAlpha=Math.min(1,i.alpha),e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(r.x,r.y),i.cap&&e.arc(i.cap.x,i.cap.y,i.cap.radius,i.cap.start,i.cap.start-Math.PI,!0),e.lineTo(o.x,o.y),e.lineTo(a.x,a.y),e.closePath(),e.fill()}}function Bp(e,t,n){const i=typeof e.getTransform=="function"?e.getTransform():null,s=p=>i?{x:i.a*p.x+i.c*p.y+i.e,y:i.b*p.x+i.d*p.y+i.f}:p,r=i?Math.sqrt(Math.abs(i.a*i.d-i.b*i.c)):1,o=t.map(p=>({...p,corners:p.corners.map(s),...p.cap&&{cap:{...p.cap,...s(p.cap),radius:p.cap.radius*r,start:p.cap.start+(i?Math.atan2(i.b,i.a):0)}}}));let a=1/0,l=1/0,c=-1/0,h=-1/0;for(const p of o){const g=p.cap?[{x:p.cap.x-p.cap.radius,y:p.cap.y-p.cap.radius},{x:p.cap.x+p.cap.radius,y:p.cap.y+p.cap.radius}]:[];for(const y of[...p.corners,...g])a=Math.min(a,y.x),l=Math.min(l,y.y),c=Math.max(c,y.x),h=Math.max(h,y.y)}if(!(c>a&&h>l))return;const u=Math.floor(a)-1,f=Math.floor(l)-1,d=i?Wl(e,Math.ceil(c)+1-u,Math.ceil(h)+1-f):null,m=d?.getContext("2d");if(!d||!m){Cs(e,t,n);return}m.translate(-u,-f),m.globalCompositeOperation="lighter",Cs(m,o,n),e.save(),e.setTransform(1,0,0,1,0,0),e.globalAlpha=1,e.drawImage(d,u,f),e.restore()}const Np=tt.to,Wp=tt.from,Kp=tt.fromTo,Yp=tt.set,Xp=tt.timeline,qp=tt.ticker,Vp=tt.splitText,Up=tt.context,zp=tt.matchMedia,Gp=tt.quickTo,jp=tt.imageSequence,Jp=tt.pageTransition;uf(),b.ACTING_STYLES=Wn,b.Clock=Vl,b.CompatTimeline=It,b.CustomBounce=$o,b.CustomEase=Ho,b.CustomWiggle=Ro,b.DANCE_STYLES=Ot,b.DEFAULT_BAKE_INTERVAL_MS=ci,b.DEFAULT_INERTIA_FRICTION=Jn,b.DEFAULT_LABELS=Yo,b.DEFAULT_SPRING=st,b.DEFAULT_TRANSITION=df,b.Draggable=Pi,b.EXPRESSIONS=G,b.FINGERS=ea,b.FLIPS=Hn,b.FORMAT_VERSION=qn,b.GAGS=Yn,b.GAITS=$t,b.GAIT_CYCLE_MS=_s,b.HAND_REST=Y,b.HAND_SHAPES=U,b.HUMAN_ACTING_RIG=Ml,b.HUMAN_EXPRESSIONS=Ja,b.HUMAN_GAGS=kl,b.HUMAN_POSES=Ga,b.HUMAN_REST=q,b.IDENTITY_CAMERA=pl,b.INERTIA_MAX_DURATION_MS=Os,b.InertiaTrackPlayer=vr,b.LiveTimeline=ut,b.MORPH_SAMPLES=pc,b.MUDRAS=es,b.ManualClock=ql,b.MediaSync=Ki,b.Observer=lo,b.POSES=se,b.REST_POSE=W,b.SPRING_MAX_DURATION_MS=jn,b.SPRING_PRESETS=Ue,b.SPRING_STEP_MS=Nt,b.STICK_ACTING_RIG=Sl,b.ScrollAnimator=Eo,b.ScrollDriver=Ie,b.ScrollMarkers=Ao,b.ScrollPin=vo,b.SmoothScroll=Bi,b.SpringSampler=pe,b.SpringTrackPlayer=kr,b.Stage=no,b.Timeline=ve,b.TinyflyPlayer=pn,b.TinyflySequencer=Jo,b.TrackPlayer=tn,b.VISEMES=Et,b.ValueResolver=Kc,b.VisibilityDriver=ko,b.actCharacterTracks=cp,b.actKeyframes=Es,b.actTracks=El,b.applyBloom=Op,b.applyCamera=D0,b.applyGroove=Na,b.backOut=qs,b.bakeDanceTracks=Pd,b.bakeEasing=fi,b.bakeInertiaTrack=ui,b.bakeSpringTrack=hi,b.basicOutfit=tp,b.beatAt=Ed,b.beatAtTime=nn,b.beatLength=wi,b.beatTime=en,b.beatsBetween=th,b.bindChoiceHotspots=Uo,b.blendPose=re,b.boilFrame=Xi,b.bounceOut=Xs,b.cameraFromValues=F0,b.cameraPoint=B0,b.cameraTracks=sh,b.character=ol,b.characterAt=_0,b.characterHandPose=ll,b.characterJoints=al,b.characterJointsInView=E0,b.characterObjects=L0,b.characterPoseTracks=I0,b.characterTarget=P0,b.charactersFor=Sr,b.circlePath=Y0,b.clamp01=Oi,b.clearMorphCache=Mc,b.clearPathCache=cc,b.clipErased=Ss,b.containerProgressAt=Li,b.context=Up,b.create=Gu,b.createControls=qo,b.createCubicBezier=Ks,b.createLive=Fo,b.createPen=Vi,b.createRandom=Se,b.createTrack=Qe,b.criticalDamping=Gl,b.customBounce=$r,b.customEase=Hr,b.customWiggle=Rr,b.danceFrame=xn,b.dancePose=kd,b.danceStance=An,b.danceTaps=Sd,b.danceTracks=xd,b.danceTravel=_n,b.danceTravelTrack=qa,b.dancer=Ad,b.deserializeTimeline=zt,b.deserializeTrack=Ar,b.detectTempo=eh,b.draggable=lu,b.drawCartoonHand=Sn,b.drawCharacter=cl,b.drawCharacterInView=ul,b.drawDustPuff=dp,b.drawEraser=ks,b.drawHand=vs,b.drawImpactStars=pp,b.drawPencil=ml,b.drawSpeedLines=xl,b.drawStickFigure=Ra,b.drawStickSmear=fp,b.drawTrail=Lp,b.drawnPathTarget=X0,b.easeIn=Bs,b.easeInCubic=Zn,b.easeInOut=Ws,b.easeInOutCubic=ge,b.easeInOutQuad=Ds,b.easeInQuad=Ls,b.easeOut=Ns,b.easeOutCubic=Qn,b.easeOutQuad=Fs,b.elasticOut=Ys,b.ellipsePoints=qi,b.erasable=z0,b.expandParametricEasings=br,b.flipPose=Va,b.flipTracks=Yd,b.flipTravel=Ua,b.formatVersionFor=Vn,b.from=Wp,b.fromJSON=Bc,b.fromTo=Kp,b.gag=As,b.gagDuration=xs,b.gaitPose=ra,b.gaitStrideLength=oa,b.getEasingFunction=J,b.getInterpolator=ke,b.getMotionPathPoint=di,b.getPathLength=hc,b.getPointAtProgress=js,b.gridLinesFor=uo,b.handAt=K0,b.handJoints=vn,b.handJointsAt=sa,b.handPose=X,b.handProp=Be,b.hasKeyframes=Hs,b.hashSeed=Gt,b.headPoint=hd,b.heldTime=$s,b.humanFieldLabel=s0,b.humanGag=Z0,b.humanGaitPose=j0,b.humanGaitStrideLength=J0,b.humanPlan=ja,b.humanPose=nt,b.imageSequence=jp,b.inertiaDuration=Kt,b.inertiaRest=Wt,b.inertiaValueAt=Ge,b.inertiaVelocityAt=Ql,b.interpolateArray=pr,b.interpolateColor=dr,b.interpolateMotionPath=Rc,b.interpolateNumber=lt,b.interpolatePathString=gr,b.interpolateQuaternion=mr,b.interpolateString=li,b.isCubicBezierEasing=Bt,b.isInertiaTrack=mt,b.isMotionPathPoint=Xl,b.isMotionPathTrack=Un,b.isParametricEasing=fe,b.isPathData=Xt,b.isSpringTrack=gt,b.isTextTrack=Ye,b.isUnderdamped=zl,b.isUnresolved=Wc,b.jointsInScene=dl,b.jointsToScene=$a,b.linear=je,b.lipSyncKeyframes=Ps,b.lipSyncOver=Ll,b.lipSyncTracks=kp,b.live=tt,b.mapEase=xe,b.mat4=mh,b.matchMedia=zp,b.maxStaggerDistance=Gn,b.mirrorHumanPose=i0,b.mirrorPose=Ba,b.mixHandPoses=ne,b.mixPoses=A0,b.morphPath=ir,b.mount=zo,b.mountAll=jo,b.narrationMarkers=jc,b.narrationSceneAt=Jc,b.naturalRest=me,b.nearestBeat=Zc,b.nextBeat=Qc,b.pageTransition=Jp,b.parametricEasing=Us,b.parseEdge=$i,b.parsePath=Pt,b.parseTrigger=Ri,b.partialPath=ee,b.pathLength=Zo,b.planNarration=Gc,b.play=zu,b.playSequence=ff,b.playWhenVisible=vu,b.playheadCrossings=mi,b.pointAlong=gn,b.pointAtDistance=ei,b.pointOnHead=w0,b.pointsToPath=Fr,b.pose=j,b.poseTracks=pd,b.quat=_c,b.quickPlay=Hp,b.quickTo=Gp,b.randomBetween=yi,b.randomChoice=Nc,b.randomSnapped=Pr,b.reachCharacter=x0,b.resolveActingStyle=vl,b.resolveCharacterPoseKeys=ws,b.resolveGait=Le,b.resolvePoseKeys=Qi,b.resolveSequence=Cr,b.resolveStickFrame=Zi,b.resolveStickPose=Oa,b.resolveValue=bi,b.ribbon=Dr,b.ribbonHeadCap=Br,b.rotateAbout=St,b.routineBeats=Pn,b.rubberLimb=Ht,b.scriptTracks=Pp,b.scrollProgress=ku,b.scrubOnScroll=Eu,b.scrubPath=V0,b.seatHeight=sd,b.serializeTimeline=xr,b.serializeTrack=Tr,b.set=Yp,b.shapeToPathData=sn,b.simplifyKeyframes=wr,b.skeletonInView=us,b.sketchPen=yn,b.smoothToward=wo,b.snapAxis=ho,b.snapConfig=So,b.snapDuration=To,b.snapProgress=Mo,b.solvePlanSpace=On,b.soundsOf=Ol,b.speechDuration=Nl,b.splitText=Vp,b.springDuration=Rs,b.springValueAt=Ul,b.stagePlanSpace=hs,b.staggerDistance=zn,b.staggerOffset=Xe,b.staggerOffsets=qe,b.staggerSpan=de,b.stepsEasing=Vs,b.stickFigureAt=Fa,b.stickFigureJoints=Ha,b.stickFigureTarget=dd,b.stickToHuman=o0,b.strideLength=fa,b.syncMediaElement=Ko,b.talkingMouth=da,b.taperedLine=bn,b.taperedOutline=$e,b.textAt=Mr,b.tf=$p,b.ticker=qp,b.timeline=Xp,b.to=Np,b.toJSON=Dc,b.toKeyframedTrack=Hc,b.toKeyframedTracks=$c,b.trackTargets=kt,b.trailSamples=oh,b.triggerDistance=Jt,b.unmount=cf,b.vec3=lh,b.walkPose=ua,b.withErased=U0,b.withExpression=ie,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
|
|
53
|
+
`;function Od(t){if(t.getElementById(Qa))return;const e=t.createElement("style");e.id=Qa,e.textContent=Id,t.head.appendChild(e)}function tl(t,e){const n=Array.from(e.querySelectorAll("[data-tinyfly-choose]"));if(n.length===0)return()=>{};Od(e.ownerDocument);const i=[],s=[];for(const a of n){const l=a.getAttribute("data-tinyfly-choose")??"",c=[],h=(g,d)=>{a.hasAttribute(g)||(a.setAttribute(g,d),c.push(g))};h("role","button"),h("tabindex","0");const f=t.scenarios.find(g=>g.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=()=>t.setScenario(l),p=g=>{const d=g.key;d!=="Enter"&&d!==" "||(g.preventDefault(),u())};a.addEventListener("click",u),a.addEventListener("keydown",p),s.push(()=>{a.removeEventListener("click",u),a.removeEventListener("keydown",p)})}const o=()=>{for(const{element:a}of i)a.setAttribute("aria-pressed",String(a.getAttribute("data-tinyfly-choose")===t.scenario))},r=t.subscribe(o);return o(),()=>{r();for(const a of s)a();for(const{element:a,attributes:l}of i)for(const c of l)a.removeAttribute(c)}}const Jn=new WeakMap,_s=new WeakMap;let Hd=0;function ln(t,e,n){if(t)try{return JSON.parse(t)}catch(i){console.warn(`tinyfly: invalid ${e} JSON on`,n,i);return}}async function el(t,e={}){const n=Jn.get(t);if(n)return n;const i=Array.from(t.querySelectorAll("script[data-tinyfly-timeline]")),s=i[0],o=t.getAttribute("data-src"),r=Rd(t.getAttribute("data-markers")),a=i.length>1||s?.hasAttribute("data-scenario")?Cd(i,r,t):void 0;if(a&&a.length===0)return;let l=s&&!a?ln(s.textContent,"timeline",t):void 0;if(!l&&o&&r){const p=await fetch(o);p.ok&&(l=await p.json())}if(l&&r&&(l=nl(l,r)),!l&&!o&&!a){console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)',t);return}const c=ln(t.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",t),h={playWhenVisible:!0,...e.player,...c&&{captions:c},...ln(t.getAttribute("data-options"),"data-options",t)};Fd(t);const f=new zn(t,h),u={element:t,player:f};if(Jn.set(t,u),t.setAttribute("data-tinyfly-mounted",""),a){const p=t.getAttribute("data-scenario")??void 0;await f.loadScenarios(a,{initial:a.some(g=>g.id===p)?p:void 0}),_s.set(t,tl(f,t))}else await f.load(l??o);if(t.getAttribute("data-controls")!=="false"){const p=ln(t.getAttribute("data-labels"),"data-labels",t),g=t.querySelector("figcaption"),d=t.getAttribute("data-scenario-legend"),m=t.getAttribute("data-scenario-control");u.controls=Za(f,t,{...e.controls,...t.getAttribute("data-fullscreen")==="true"?{fullscreen:!0}:{},...m==="slider"||m==="buttons"?{scenarioControl:m}:{},labels:{...e.controls?.labels,...p,...d?{scenario:d}:{}},mount:void 0}),g?t.insertBefore(u.controls.element,g):t.appendChild(u.controls.element)}return u}function Cd(t,e,n){const i=[];return t.forEach((s,o)=>{const r=ln(s.textContent,"timeline",n);if(!r)return;const a=s.getAttribute("data-scenario")||`scenario-${o+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:e?nl(r,e):r})}),i}function nl(t,e){return t.config.markers?.length?t:{...t,config:{...t.config,markers:e.map((n,i)=>({id:`step-${i+1}`,time:n}))}}}function Rd(t){if(!t)return;const e=t.split(/[\s,]+/).filter(Boolean).map(Number).filter(n=>Number.isFinite(n)&&n>=0).sort((n,i)=>n-i);return e.length>0?e:void 0}async function il(t=document,e={}){const n=Array.from(t.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(n.map(s=>el(s,e)))).filter(s=>s!==void 0)}function Ld(t){const e=Jn.get(t);e&&(_s.get(t)?.(),_s.delete(t),e.controls?.destroy(),e.player.destroy(),Jn.delete(t),t.removeAttribute("data-tinyfly-mounted"))}function Fd(t){const e=t.querySelector("svg");if(!e||e.hasAttribute("role")||e.hasAttribute("aria-hidden"))return;const n=t.getAttribute("data-alt"),i=t.querySelector("figcaption");e.setAttribute("role","img"),n?e.setAttribute("aria-label",n):i&&(i.id||=`tinyfly-caption-${++Hd}`,e.setAttribute("aria-labelledby",i.id))}function Dd(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const e=()=>{il()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}class sl{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(e,n={}){if(typeof e=="string"){const i=document.querySelector(e);if(!i)throw new Error(`Container not found: ${e}`);this.container=i}else this.container=e;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 ue,this.adapterB=new ue}async load(e){let n;if(typeof e=="string"){const i=await fetch(e);if(!i.ok)throw new Error(`Failed to load sequence: ${i.statusText}`);n=await i.json()}else n=e;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 e=this.timelineA.getStateAtTime(0);this.adapterA.applyState(e),this.applyNested(this.adapterA,0)}}goToScene(e){if(!this.sequence||e<0||e>=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=e,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[e];if(this.renderScene(i,this.containerA,this.adapterA),this.timelineA=this.createTimeline(i),this.options.onSceneChange?.(e),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 e of this.nestedByAdapter.values())for(const n of e)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 e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.height="100%",e}renderScene(e,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 o of e.elements){if(!o.html)continue;const r=document.createElement("div");r.innerHTML=o.html.trim();const a=r.firstElementChild;if(a){s.appendChild(a);const l=a.getAttribute("data-tinyfly");l&&i.registerTarget(l,a)}}this.setupNested(s,i)}setupNested(e,n){const i=[];e.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const o=s.getAttribute("data-tinyfly-symbol");if(!o)return;const r=this.symbolDefs.get(o);if(!r)return;const a=new ue;s.querySelectorAll("[data-tinyfly]").forEach(l=>{const c=l.getAttribute("data-tinyfly");c&&a.registerTarget(c,l)}),i.push({adapter:a,timeline:xe(r)})}),i.length?this.nestedByAdapter.set(n,i):this.nestedByAdapter.delete(n)}applyNested(e,n){const i=this.nestedByAdapter.get(e);if(i)for(const s of i){const o=s.timeline.duration;s.adapter.applyState(s.timeline.getStateAtTime(o>0?n%o:n))}}clearContainer(e){e.innerHTML=""}createTimeline(e){return e.timeline?xe(e.timeline):null}onSceneComplete(){if(this._isDestroyed||!this.sequence)return;const e=this._currentSceneIndex+1;if(e>=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(e)}beginTransitionTo(e){if(!this.sequence||this._isDestroyed)return;const n=this.sequence.scenes[e],i=n.transition;if(i.type==="none"||i.duration<=0){this.switchToScene(e);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(e)},i.duration)}applyTransition(e,n){const i=`${n}ms`,s="ease-in-out";switch(this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),e){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}`,e){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(e){e.style.transition="",e.style.opacity="1",e.style.transform=""}finishTransition(e){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=e,this._state="playing-scene",this.options.onSceneChange?.(e),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.playbackState!=="playing"&&this.timelineA.play()):this.onSceneComplete()}switchToScene(e){if(!this.sequence||this._isDestroyed)return;this.timelineA&&this.timelineA.stop(),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const n=this.sequence.scenes[e];this.renderScene(n,this.containerA,this.adapterA),this.timelineA=this.createTimeline(n),this._currentSceneIndex=e,this._state="playing-scene",this.options.onSceneChange?.(e),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play()):this.onSceneComplete()}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const e=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(e):this.animationFrameId=void 0};this.animationFrameId=requestAnimationFrame(e)}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}}async function Nd(t,e,n={}){const i=new sl(t,{...n,autoplay:!0});return await i.load(e),i}const Bd={type:"none",duration:0},dt=t=>({description:t,unit:"degrees"}),ft=(t,e=0,n=1)=>({description:t,unit:`${e}..${n}`,min:e,max:n}),ol={lean:dt("Upper body tipped about the hips (+ toward the way it faces)"),bend:dt("Line of action: the spine curved (+ curls forward, − arches back)"),headTilt:dt("Head tilt"),leftShoulder:dt("Left upper arm: 0 hangs down, 90 straight out to its side, 180 straight up; in profile, forward is negative for the left arm"),rightShoulder:dt("Right upper arm: 0 hangs down, 90 straight out (forward, in profile), 180 straight up"),leftElbow:dt("Left elbow bend, added to the upper arm"),rightElbow:dt("Right elbow bend, added to the upper arm"),leftHip:dt("Left thigh: 0 straight down; in profile negative is forward"),rightHip:dt("Right thigh: 0 straight down; in profile positive is forward"),leftKnee:dt("Left knee bend (negative folds the shin back)"),rightKnee:dt("Right knee bend (positive folds the shin back)"),leftWrist:dt("Left wrist bend, added to the forearm"),rightWrist:dt("Right wrist bend, added to the forearm"),leftAnkle:dt("Left ankle: + points the toe down (tiptoe), − onto the heel"),rightAnkle:dt("Right ankle: + points the toe down (tiptoe), − onto the heel"),leftFootOut:ft("Left foot turned out (seen from the front): 0 natural, 1 sideways, negative turned in",-1,1),rightFootOut:ft("Right foot turned out (seen from the front): 0 natural, 1 sideways, negative turned in",-1,1),mouth:ft("Mouth open: 0 closed, 1 wide open"),smile:ft("−1 frown, 0 flat, 1 smile",-1,1),mouthWidth:{description:"Mouth width: 1 normal, 0.5 pursed, 1.5 wide",unit:"factor",min:.3,max:2},blink:ft("Eyes closed by a blink: 0 open, 1 shut"),leftEye:{description:"Left eye openness: 0 shut, 1 normal, 1.6 wide",unit:"factor",min:0,max:2},rightEye:{description:"Right eye openness: 0 shut, 1 normal, 1.6 wide",unit:"factor",min:0,max:2},leftBrow:ft("Left eyebrow: −1 lowered, 0 rest, 1 raised",-1,1),rightBrow:ft("Right eyebrow: −1 lowered, 0 rest, 1 raised",-1,1),browTilt:ft("Eyebrow slant: −1 angry, 1 worried",-1,1),lookX:ft("Eyes look across: + the way it faces",-1,1),lookY:ft("Eyes look down (+) or up (−)",-1,1),stretch:{description:"Squash and stretch: 1 normal, above taller (a jump), below squashed (a landing)",unit:"factor",min:.3,max:3},turn:ft("0 front-on, 1 in profile, turned the way it faces"),sit:ft("0 standing, 1 seated"),spin:dt("Whole body turned about the hips: + rolls forward (a front flip), 360 a full turn"),rise:{description:"Lift off the ground, as a fraction of its height (the arc of a jump)",unit:"× height"}},rl={walk:{description:"Walk-cycle phase, in strides: animate 0 → n for n strides",unit:"strides"},walking:ft("How much of the walk cycle is applied (0 standing)"),gait:{description:"How it walks: a gait name (walk, bouncy, doubleBounce, sneak, strut, tired, run, shove); a string track switches it",kind:"string"},talk:ft("How much the mouth chatters"),rubber:ft("Limbs from jointed (0) to rubber hose (1)"),facing:{description:"Which way it faces: 1 right, −1 left (key the flip while turn is near 0)",unit:"±1",min:-1,max:1},beat:{description:"Beats into its dance (with a dance)",unit:"beats"},dancing:ft("How much of the dance is applied")},al={"thumb.curl":ft("Thumb curled in"),"thumb.across":ft("Thumb across the palm"),"index.curl":ft("Index finger curled"),"middle.curl":ft("Middle finger curled"),"ring.curl":ft("Ring finger curled"),"pinky.curl":ft("Little finger curled"),spread:ft("Fingers spread apart"),turn:dt("Hand turned about the forearm"),bend:dt("Hand bent at the wrist, palm-ward"),tilt:dt("Hand tilted sideways"),roll:dt("Hand rolled to show the back or the palm")};let ll;function Wd(t){ll=t}function Kd(t){return ll?.(t)??{}}function cl(t){let e=0;for(let n=1;n<t.length;n++)e+=Math.hypot(t[n].x-t[n-1].x,t[n].y-t[n-1].y);return e}function Ce(t,e){const n=Math.min(1,Math.max(0,e));if(t.length<2||n===1)return t.slice();if(n===0)return t.slice(0,1);let i=cl(t)*n;const s=[t[0]];for(let o=1;o<t.length;o++){const r=t[o-1],a=t[o],l=Math.hypot(a.x-r.x,a.y-r.y);if(l>=i){const c=l===0?0:i/l;return s.push({x:r.x+(a.x-r.x)*c,y:r.y+(a.y-r.y)*c}),s}s.push(a),i-=l}return s}function Zn(t,e){const n=Ce(t,e);return n[n.length-1]}function Is(t,e){return e>0?Math.floor(Math.max(0,t)*e/1e3):0}function Qn(t,e,n){const i=e.roughness??2,s=Math.max(1,Math.round(e.passes??2)),o=Is(n,e.boil??8);let r=0;const a=()=>{const u=r++;return p=>Je(Pe(`${e.seed??1}:${o}:${u}:${p}`))},l=(u,p)=>(u.next()*2-1)*p,c=u=>{const p=a(),g=t.lineWidth,d=t.globalAlpha;for(let m=0;m<s;m++)t.lineWidth=m===0?g:g*.55,t.globalAlpha=m===0?d:d*.6,u(p(m));t.lineWidth=g,t.globalAlpha=d},h=(u,p=1)=>{if(u.length<2)return;const g=u.slice(1).map((m,y)=>Math.hypot(m.x-u[y].x,m.y-u[y].y)),d=g.reduce((m,y)=>m+y,0)*Math.min(1,Math.max(0,p));c(m=>{const y=[],w=[];if(u.forEach((T,S)=>{y.push({x:T.x+l(m,i*.5),y:T.y+l(m,i*.5)}),S>0&&w.push([m.next()*2-1,m.next()*2-1])}),d<=0)return;t.beginPath(),t.moveTo(y[0].x,y[0].y);let v=0;for(let T=1;T<y.length;T++){const S=Yd(y[T-1],y[T],i,w[T-1]),A=g[T-1];if(v+A<=d){t.bezierCurveTo(S[1].x,S[1].y,S[2].x,S[2].y,S[3].x,S[3].y),v+=A;continue}const x=jd(S,A===0?1:(d-v)/A);t.bezierCurveTo(x[1].x,x[1].y,x[2].x,x[2].y,x[3].x,x[3].y);break}t.stroke()})},f=(u,p,g,d,m=1)=>{c(y=>{const v=y.next()*Math.PI*2,T=Math.PI*2+.15+y.next()*.3,S=[];for(let x=0;x<=14;x++){const C=v+T*x/14,E=l(y,i*.6);S.push({x:u+Math.cos(C)*(g+E),y:p+Math.sin(C)*(d+E)})}const A=Ce(S,m);A.length<2||(hl(t,A),t.stroke())})};return{line:h,curve(u,p=1){if(u.length<2)return;const g=u[0],d=u[u.length-1],m=Math.hypot(d.x-g.x,d.y-g.y)||1,y=-(d.y-g.y)/m,w=(d.x-g.x)/m;c(v=>{const T={x:l(v,i*.5),y:l(v,i*.5)},S={x:l(v,i*.5),y:l(v,i*.5)},A=l(v,i*Math.min(1.5,Math.max(.3,m/80))),x=u.map((E,H)=>{const _=H/(u.length-1),P=Math.sin(Math.PI*_)*A;return{x:E.x+T.x+(S.x-T.x)*_+y*P,y:E.y+T.y+(S.y-T.y)*_+w*P}}),C=Ce(x,p);C.length<2||(hl(t,C),t.stroke())})},circle(u,p,g,d=1){f(u,p,g,g,d)},ellipse:f,nudge(u=.5){const p=a()(0);return{x:l(p,i*u),y:l(p,i*u)}}}}function Yd(t,e,n,i){const s=e.x-t.x,o=e.y-t.y,r=Math.hypot(s,o)||1,a=n*Math.min(1.5,Math.max(.3,r/80)),l=-o/r,c=s/r;return[t,{x:t.x+s/3+l*i[0]*a,y:t.y+o/3+c*i[0]*a},{x:t.x+2*s/3+l*i[1]*a,y:t.y+2*o/3+c*i[1]*a},e]}function jd([t,e,n,i],s){const o=(f,u)=>({x:f.x+(u.x-f.x)*s,y:f.y+(u.y-f.y)*s}),r=o(t,e),a=o(e,n),l=o(n,i),c=o(r,a),h=o(a,l);return[t,r,c,o(c,h)]}function hl(t,e){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let i=1;i<e.length-1;i++){const s={x:(e[i].x+e[i+1].x)/2,y:(e[i].y+e[i+1].y)/2};t.quadraticCurveTo(e[i].x,e[i].y,s.x,s.y)}const n=e[e.length-1];t.lineTo(n.x,n.y)}function cn(t,e,n){const i=t.length;if(i<2)return[];const s=[],o=[],r=a=>e+(n-e)*a/(i-1);return t.forEach((a,l)=>{const c=t[Math.max(0,l-1)],h=t[Math.min(i-1,l+1)],f=Math.hypot(h.x-c.x,h.y-c.y)||1,u=r(l)/2,p=-(h.y-c.y)/f*u,g=(h.x-c.x)/f*u;s.push({x:a.x+p,y:a.y+g}),o.push({x:a.x-p,y:a.y-g})}),[...s,...o.reverse()]}function ti(t,e,n,i){const s=e.length;if(s<2)return;const o=cn(e,n,i),r=a=>n+(i-n)*a/(s-1);t.beginPath(),t.moveTo(o[0].x,o[0].y);for(const a of o.slice(1))t.lineTo(a.x,a.y);t.closePath(),t.fill(),e.forEach((a,l)=>{l!==0&&l!==s-1&&s>3||(t.beginPath(),t.arc(a.x,a.y,r(l)/2,0,Math.PI*2),t.fill())})}function fe(t,e,n,i,s=16){const o={x:2*e.x-(t.x+n.x)/2,y:2*e.y-(t.y+n.y)/2},r=[];for(let a=0;a<=s;a++){const l=a/s,c=l<.5?{x:t.x+(e.x-t.x)*2*l,y:t.y+(e.y-t.y)*2*l}:{x:e.x+(n.x-e.x)*(2*l-1),y:e.y+(n.y-e.y)*(2*l-1)},h=1-l,f={x:h*h*t.x+2*h*l*o.x+l*l*n.x,y:h*h*t.y+2*h*l*o.y+l*l*n.y};r.push({x:c.x+(f.x-c.x)*i,y:c.y+(f.y-c.y)*i})}return r}function Os(t,e,n,i,s,o=0,r=1,a=40){const l=Math.cos(s),c=Math.sin(s);return Array.from({length:a+1},(h,f)=>{const u=o+Math.PI*2*r*f/a,p=Math.cos(u)*n,g=Math.sin(u)*i;return{x:t+p*l-g*c,y:e+p*c+g*l}})}function Hs(t,e){return e.look==="pencil"?Vd(t,e):Xd(t,e.ink,e.look)}function ei(t,e,n=!1){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(const i of e.slice(1))t.lineTo(i.x,i.y);n&&t.closePath()}function Xd(t,e,n){const i=n==="silhouette",s=i?1.25:1;return{look:n,ink:e,limb(o,r,a){t.fillStyle=e,ti(t,o,r*s,a*s)},line(o,r){o.length<2||(t.strokeStyle=e,t.lineWidth=r*s,t.lineCap="round",t.lineJoin="round",ei(t,o),t.stroke())},shape(o,r,a){ei(t,o,!0),(r!==null||i)&&(t.fillStyle=i?e:r,t.fill()),!(a<=0)&&(t.strokeStyle=e,t.lineWidth=a*s,t.lineJoin="round",t.stroke())},ellipse(o,r,a,l,c,h,f){t.beginPath(),t.ellipse(o,r,a,l,c,0,Math.PI*2),(h!==null||i)&&(t.fillStyle=i?e:h,t.fill()),!(f<=0)&&(t.strokeStyle=e,t.lineWidth=f*s,t.stroke())},dot(o,r,a){t.fillStyle=e,t.beginPath(),t.arc(o,r,a*s,0,Math.PI*2),t.fill()},guide(){},guideEllipse(){}}}function qd(t,e){const n=[t[0]];let i=0;for(let r=1;r<t.length;r++){const a=t[r-1],l=t[r],c=Math.hypot(l.x-a.x,l.y-a.y);let h=e-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+=e}i=c-(h-e)}const s=t[t.length-1],o=n[n.length-1];return Math.hypot(s.x-o.x,s.y-o.y)>e*.25?n.push(s):n[n.length-1]=s,n}function Ud(t,e){const n=t.length;return t.map((i,s)=>{const o=t[Math.max(0,s-1)],r=t[Math.min(n-1,s+1)],a=Math.hypot(r.x-o.x,r.y-o.y)||1,l=e(n===1?0:s/(n-1));return{x:i.x-(r.y-o.y)/a*l,y:i.y+(r.x-o.x)/a*l}})}function ul(t){const e=[.6,1.4,2.9].map(i=>({frequency:i*(.8+t.next()*.4),phase:t.next()*Math.PI*2,amount:.5+t.next()*.5})),n=e.reduce((i,s)=>i+s.amount,0);return i=>e.reduce((s,o)=>s+o.amount*Math.sin(Math.PI*2*o.frequency*i+o.phase),0)/n}function Vd(t,e){const n=e.pencil??{},i=e.ink,s=n.roughness??Math.max(1,e.lineWidth*.12),o=Math.max(1,Math.round(n.passes??2)),r=Math.min(1,Math.max(0,n.pressure??.25)),a=Math.min(1,Math.max(0,n.rubbedOut??.15)),l=Is(e.time,n.boil??8);let c=0;const h=(g,d,m=!1)=>Je(Pe(`${e.seed}:${m?"paper":l}:${g}:${d}`)),f=(g,d,m,y,w,v=0)=>{if(g.length<2)return;const T=g.slice(1).reduce((_,P,L)=>_+Math.hypot(P.x-g[L].x,P.y-g[L].y),0);let S=qd(g,Math.max(1.5,Math.min(e.lineWidth*.8,T/24)));if(v>0&&S.length>=2){const[_,P]=[S[S.length-2],S[S.length-1]],L=Math.hypot(P.x-_.x,P.y-_.y)||1;S=[...S,{x:P.x+(P.x-_.x)/L*v,y:P.y+(P.y-_.y)/L*v}]}const A=ul(m),x=ul(m),C=S.length,E=[],H=[];S.forEach((_,P)=>{const L=C===1?0:P/(C-1),F=S[Math.max(0,P-1)],K=S[Math.min(C-1,P+1)],V=Math.hypot(K.x-F.x,K.y-F.y)||1,ot=-(K.y-F.y)/V,X=(K.x-F.x)/V,tt=A(L)*w,J=Math.min(1,L/.08,(1-L)/.08),M=(.55+.45*Math.sqrt(Math.max(0,J)))*(1+r*x(L)),I=Math.max(.3,d(L)*M/2),k=_.x+ot*tt,$=_.y+X*tt;E.push({x:k+ot*I,y:$+X*I}),H.push({x:k-ot*I,y:$-X*I})}),t.save(),t.globalAlpha*=y,t.fillStyle=i,ei(t,[...E,...H.reverse()],!0),t.fill(),t.restore()},u=(g,d)=>{const m=c++,y=h(m,99,!0);if(y.next()<a){const S=(y.next()*2-1)*e.lineWidth*1.4,A=(y.next()*2-1)*e.lineWidth*1.4,x=g.map(C=>({x:C.x+S,y:C.y+A}));f(x,C=>d(C)*1.8,h(m,98,!0),.035,s),f(x,C=>d(C)*.45,h(m,97,!0),.12,s*1.5)}const w=g.slice(1).reduce((S,A,x)=>S+Math.hypot(A.x-g[x].x,A.y-g[x].y),0),v=d(.5)>4&&w>d(.5)*6,T=v?[-.3,.3,0]:[0];for(let S=0;S<o;S++){const A=S===0;T.forEach((x,C)=>{const E=h(m,S*10+C),H=x===0?g:Ud(g,P=>d(P)*x*Math.sqrt(Math.sin(Math.PI*P))),_=!A&&x===0?e.lineWidth*(.3+E.next()*.8):0;f(H,P=>d(P)*(v?.5:1)*(A?1:.6),E,A?.85:.45,s*(A?.6:1),_)})}},p=(g,d,m,y,w,v)=>{const S=h(c,50).next()*Math.PI*2;u(Os(g,d,m,y,w,S,1.08,48),()=>v)};return{look:"pencil",ink:i,limb(g,d,m){u(g,y=>d+(m-d)*y)},line(g,d){u(g,()=>d)},shape(g,d,m){d!==null&&(t.save(),t.globalAlpha*=.88,t.fillStyle=d,ei(t,g,!0),t.fill(),t.restore()),m>0&&u([...g,g[0]],()=>m)},ellipse(g,d,m,y,w,v,T){v!==null&&(t.save(),t.globalAlpha*=.9,t.fillStyle=v,t.beginPath(),t.ellipse(g,d,m,y,w,0,Math.PI*2),t.fill(),t.restore()),p(g,d,m,y,w,T)},dot(g,d,m){t.save(),t.globalAlpha*=.9,t.fillStyle=i,t.beginPath(),t.arc(g,d,m,0,Math.PI*2),t.fill(),t.restore()},guide(g){if(n.construction===!1||g.length<2)return;const d=c++;f(g,()=>Math.max(.6,e.lineWidth*.18),h(d,0),.28,s*1.2,e.lineWidth)},guideEllipse(g,d,m,y,w){if(n.construction===!1)return;const v=c++,T=h(v,0),S=Os(g,d,m,y,w,T.next()*Math.PI*2,1.12,48);f(S,()=>Math.max(.6,e.lineWidth*.18),T,.28,s*1.5)}}}const fl=["thumb","index","middle","ring","pinky"],gt={"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 mt(t={}){return{...gt,...t}}const Pt=(t,e,n,i,s)=>({"thumb.curl":t,"index.curl":e,"middle.curl":n,"ring.curl":i,"pinky.curl":s}),bt={relaxed:gt,open:mt({...Pt(0,0,0,0,0),"thumb.across":0,spread:.55}),spread:mt({...Pt(0,0,0,0,0),"thumb.across":0,spread:1}),flat:mt({...Pt(0,0,0,0,0),"thumb.across":.35,spread:0}),fist:mt({...Pt(.7,1,1,1,1),"thumb.across":.9,spread:0}),point:mt({...Pt(.75,0,1,1,1),"thumb.across":.9,spread:0}),thumbsUp:mt({...Pt(0,1,1,1,1),"thumb.across":0,spread:0,roll:70}),peace:mt({...Pt(.75,0,0,1,1),"thumb.across":.9,spread:1}),ok:mt({...Pt(.12,.6,.1,.15,.2),"thumb.across":.55,spread:.6}),pinch:mt({...Pt(.1,.65,.75,.85,.9),"thumb.across":.55,spread:0}),cupped:mt({...Pt(.25,.4,.4,.4,.4),"thumb.across":.4,spread:.05,turn:2}),wave:mt({...Pt(0,.05,.05,.1,.12),"thumb.across":0,spread:.7,turn:2}),pencilGrip:mt({...Pt(.1,.6,.72,.88,.95),"thumb.across":.5,spread:0,turn:.8,bend:10}),hold:mt({...Pt(.5,.7,.72,.74,.76),"thumb.across":.75,spread:0,turn:1})};function Re(t,e,n){const i={...t};for(const[s,o]of Object.entries(e)){const r=t[s]??o;i[s]=r+(o-r)*n}return i}const Gd={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}},zd={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}},Kt={base:[-.11,.1,-.05],bones:[.2,.15,.12],widths:[.2,.145,.135],out:[-.7,.68,-.22],across:[.35,.5,-.8]},Jd=[82,100,62],Zd=[48,72],Qd=3,t0=13,e0=.035,n0=-.075,i0=[[-.17,0],[-.215,.12],[-.235,.26],[-.225,.4],[-.185,.49],[-.075,.525],[.05,.51],[.16,.465],[.215,.4],[.225,.26],[.2,.1],[.16,0]],Zt=t=>t*Math.PI/180,Cs=(t,e)=>[t[0]+e[0],t[1]+e[1],t[2]+e[2]],ni=(t,e)=>[t[0]*e,t[1]*e,t[2]*e],Rs=(t,e)=>[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]],hn=t=>{const e=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/e,t[1]/e,t[2]/e]};function Qt(t,e,n){const i=Math.cos(n),s=Math.sin(n),o=Rs(e,t),r=e[0]*t[0]+e[1]*t[1]+e[2]*t[2];return[t[0]*i+o[0]*s+e[0]*r*(1-i),t[1]*i+o[1]*s+e[1]*r*(1-i),t[2]*i+o[2]*s+e[2]*r*(1-i)]}const dl=[1,0,0],pl=[0,1,0],un=[0,0,1];function s0(t,e,n){const i=Zt(t.fan*(Qd+t0*n)),s=[Math.sin(i),Math.cos(i),0],o=[Math.cos(i),-Math.sin(i),0],r=[t.knuckle];let a=0;t.bones.forEach((h,f)=>{a+=Zt(Jd[f]*e),r.push(Cs(r[f],ni(Qt(s,o,-a),h)))});const l=Qt(un,o,-a),c=r.map((h,f)=>t.width*(1-.14*(f/(r.length-1))));return{joints:r,back:l,widths:c}}function o0(t,e,n=1,i=1){const s=Math.min(1,Math.max(0,e)),o=hn(Cs(ni(hn(Kt.out),1-s),ni(hn(Kt.across),s))),r=hn(Rs(un,o)),a=hn(Rs(o,r)),l=[[Kt.base[0]*i,Kt.base[1],Kt.base[2]]];let c=0;Kt.bones.forEach((u,p)=>{p>0&&(c+=Zt(Zd[p-1]*t)),l.push(Cs(l[p],ni(Qt(o,r,c),u)))});const h=Qt(a,r,c),f=[...Kt.widths,Kt.widths[Kt.widths.length-1]*.92].map(u=>u*n);return{joints:l,back:h,widths:f}}function ii(t,e={}){const n={...gt,...t},i=e.size??100,s=e.side??"right",o=s==="left"?-1:1,r=Zt(e.angle??0),a=e.fingers===4,l=Math.max(.5,e.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=Zt(n.bend??0),u=Zt(n.tilt??0),p=Zt(90*(n.turn??0)),g=P=>Qt(Qt(Qt(P,dl,-f),un,-u),pl,p),d=Math.cos(r),m=Math.sin(r),y=Zt(n.roll??0),w=Math.cos(y),v=Math.sin(y),T=P=>{const L=P[0]*i,F=-P[1]*i,K=(L*w-F*v)*o,V=L*v+F*w;return{x:K*d-V*m,y:K*m+V*d}},S=P=>{const L=T(P),F=Math.hypot(L.x,L.y);return F>1e-6*i?{x:L.x/F,y:L.y/F}:{x:0,y:0}},A={thumb:o0(n["thumb.curl"]??0,n["thumb.across"]??0,l,c)},x=a?zd:Gd;for(const P of fl){const L=x[P];L&&(A[P]=s0(h(L),n[`${P}.curl`]??0,n.spread??0))}const C={};for(const[P,L]of Object.entries(A)){const F=L.joints.map(g),K=g(L.back);C[P]={points:F.map(T),depths:F.map(V=>V[2]*i),widths:L.widths.map(V=>V*i),nail:K[2],back:S(K)}}const E=i0.flatMap(([P,L])=>[g([P*c,L,e0]),g([P*c,L,n0])]),H=r0(E.map(T)),_=E.reduce((P,L)=>P+L[2],0)/E.length*i;return{size:i,side:s,wrist:{x:0,y:0},palm:H,palmDepth:_,palmFacing:-g(un)[2],fingers:C,axes:{up:S(g(pl)),across:S(g(dl)),out:S(g(un))},curls:Object.fromEntries(Object.keys(C).map(P=>[P,n[`${P}.curl`]??0]))}}function gl(t,e){const n=s=>({x:s.x+e.x-t.wrist.x,y:s.y+e.y-t.wrist.y}),i={};for(const[s,o]of Object.entries(t.fingers))i[s]={...o,points:o.points.map(n)};return{...t,wrist:n(t.wrist),palm:t.palm.map(n),fingers:i}}function r0(t){const e=[...t].sort((o,r)=>o.x-r.x||o.y-r.y);if(e.length<3)return e;const n=(o,r,a)=>(r.x-o.x)*(a.y-o.y)-(r.y-o.y)*(a.x-o.x),i=[];for(const o of e){for(;i.length>=2&&n(i[i.length-2],i[i.length-1],o)<=0;)i.pop();i.push(o)}const s=[];for(const o of[...e].reverse()){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],o)<=0;)s.pop();s.push(o)}return[...i.slice(0,-1),...s.slice(0,-1)]}const a0="#f1c9a5",l0="#2f2f33";function si(t,e,n,i={},s=0){const o=gl(ii(n,i),e),r=i.ink??l0,a=i.lineWidth??o.size*.035,l=i.pen??Hs(t,{look:i.look??"clean",ink:r,lineWidth:a,seed:i.seed??1,time:s,pencil:{construction:!1,...i.pencil}}),c=i.skin??a0,h=i.nails??!0,f=[{depth:o.palmDepth,draw:()=>c0(l,o,c,a)}];for(const u of Object.values(o.fingers)){const p=u.depths.reduce((g,d)=>g+d,0)/u.depths.length;f.push({depth:p,draw:()=>h0(t,l,u,c,a,h)})}if(i.prop){const u=i.prop;f.push({depth:u.depth,draw:()=>u.draw(l)})}t.save(),t.lineCap="round",t.lineJoin="round";for(const u of[...f].sort((p,g)=>p.depth-g.depth))u.draw();return t.restore(),o}function c0(t,e,n,i){if(t.shape(e.palm,n,i),e.palmFacing<-.3&&t.look!=="silhouette"){const{up:s}=e.axes;for(const[o,r]of Object.entries(e.fingers)){const a=e.curls[o]??0;if(o==="thumb"||a<.5)continue;const l=r.points[0],c=r.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,g)=>{const d=f-Math.PI/2+Math.PI*g/6;return{x:h.x+Math.cos(d)*c,y:h.y+Math.sin(d)*c}});t.line(u,i*.6)}}if(e.palmFacing>.45&&t.look!=="silhouette"){const{up:s,across:o}=e.axes,r=e.size,a=e.wrist,l=(h,f)=>({x:a.x+(o.x*h+s.x*f)*r,y:a.y+(o.y*h+s.y*f)*r}),c=e.side==="left"?-1:1;t.line([l(-.15*c,.36),l(-.04*c,.3),l(.1*c,.33)],i*.5)}}function h0(t,e,n,i,s,o){const{widths:r}=n,a=u0(n.points,2),l=n.points[0],c=a[a.length-1],h=r[0],f=r[r.length-1];if(t.save(),e.look!=="silhouette"){t.beginPath(),t.rect(l.x-1e5,l.y-1e5,2e5,2e5);const d=h/2+s*1.6;t.moveTo(l.x+d,l.y),t.arc(l.x,l.y,d,0,Math.PI*2),t.clip("evenodd")}if(e.limb(a,h+2*s,f+2*s),t.restore(),e.look!=="silhouette"&&(t.fillStyle=i,ti(t,a,h,f)),e.look==="silhouette"||!o||n.nail<.25)return;const u=a[a.length-2],p=f0({x:c.x-u.x,y:c.y-u.y})??{x:0,y:-1},g={x:c.x-p.x*f*.22+n.back.x*f*.1,y:c.y-p.y*f*.22+n.back.y*f*.1};e.ellipse(g.x,g.y,f*.24*Math.max(.35,n.nail),f*.19,Math.atan2(p.y,p.x),"#f8e3d3",s*.45)}function u0(t,e){let n=t;for(let i=0;i<e;i++){if(n.length<3)return n;const s=[n[0]];for(let o=0;o<n.length-1;o++){const r=n[o],a=n[o+1];o>0&&s.push({x:r.x*.75+a.x*.25,y:r.y*.75+a.y*.25}),o<n.length-2&&s.push({x:r.x*.25+a.x*.75,y:r.y*.25+a.y*.75})}s.push(n[n.length-1]),n=s}return n}const f0=t=>{const e=Math.hypot(t.x,t.y);return e>1e-6?{x:t.x/e,y:t.y/e}:null},$t={walk:{swing:24,knee:30,arm:22,elbow:28,lean:4},bouncy:{swing:26,knee:45,arm:34,elbow:30,lean:2,bend:-4,bounce:.035,squash:.06},doubleBounce:{swing:22,knee:40,arm:26,elbow:24,lean:3,bounce:.02,bounces:2,squash:.04},sneak:{swing:28,knee:70,arm:6,elbow:0,forearm:110,shoulder:55,lean:16,bend:14,headTilt:-8,crouch:50,tiptoe:25},strut:{swing:26,knee:30,arm:30,elbow:20,lean:-4,bend:-10,headTilt:-6,sway:4,bounce:.01},tired:{swing:14,knee:14,arm:6,elbow:6,lean:10,bend:16,headTilt:12},run:{swing:40,knee:95,arm:45,elbow:0,forearm:90,lean:16,bend:6,bounce:.05,squash:.06},shove:{swing:18,knee:28,arm:0,elbow:0,lean:0}},d0=40;function fn(t){return t===void 0?$t.walk:typeof t=="string"?$t[t]??$t.walk:t}function ml(t,e,n=et,i=1){const s=fn(t);if(s===$t.walk)return vl(e,n,i);const o=e*Math.PI*2,r=Math.sin(o)*i,a=Math.cos(o)*i,l=y=>Math.abs(y)<=d0,c=s.shoulder??0,h=(y,w)=>l(y)?w*c+s.arm*r:y,f=s.forearm??0,u=l(n.leftShoulder)?n.leftElbow-f-s.elbow*Math.max(0,-r):n.leftElbow,p=l(n.rightShoulder)?n.rightElbow+f+s.elbow*Math.max(0,r):n.rightElbow,g=s.bounces??1,d=(1+Math.cos(o*2*g))/2,m=s.crouch??0;return{...n,lean:n.lean+s.lean*i+(s.sway??0)*Math.sin(o)*(1-(n.turn??0)),bend:(n.bend??0)+(s.bend??0),headTilt:n.headTilt-s.lean*.5*i+(s.headTilt??0),leftElbow:u,rightElbow:p,leftHip:-s.swing*r-m*.5,rightHip:-s.swing*r+m*.5,leftKnee:-s.knee*Math.max(0,a)-m,rightKnee:s.knee*Math.max(0,-a)+m,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*d,stretch:n.stretch*(1+(s.squash??0)*(d-.5))}}function Ls(t,e,n=1){const i=fn(t),s=$t.walk.swing,o=r=>Math.sin(r*Math.PI/180);return Sl(e,n)*o(i.swing*n)/o(s*n)}const et={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 wt(t){return{...et,...t}}const yl={mouth:0,smile:0,mouthWidth:1,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0},vt=t=>({...yl,...t}),ct={neutral:yl,happy:vt({smile:.9,leftBrow:.2,rightBrow:.2}),joyful:vt({mouth:.6,smile:1,mouthWidth:1.2,leftEye:0,rightEye:0,leftBrow:.4,rightBrow:.4}),sad:vt({smile:-.8,leftEye:.8,rightEye:.8,browTilt:.9,leftBrow:-.1,rightBrow:-.1,lookY:.6}),crying:vt({mouth:.45,smile:-1,leftEye:0,rightEye:0,browTilt:1,lookY:.4}),surprised:vt({mouth:.7,mouthWidth:.7,leftEye:1.5,rightEye:1.5,leftBrow:1,rightBrow:1}),shocked:vt({mouth:1,mouthWidth:.8,leftEye:1.6,rightEye:1.6,leftBrow:1,rightBrow:1,browTilt:.4}),angry:vt({smile:-.6,mouthWidth:.9,leftEye:.8,rightEye:.8,leftBrow:-.6,rightBrow:-.6,browTilt:-1}),furious:vt({mouth:.5,smile:-1,mouthWidth:1.3,leftEye:.9,rightEye:.9,leftBrow:-.9,rightBrow:-.9,browTilt:-1}),worried:vt({smile:-.3,mouthWidth:.8,leftEye:1.1,rightEye:1.1,leftBrow:.3,rightBrow:.3,browTilt:.8,lookX:-.5}),scared:vt({mouth:.35,smile:-.5,mouthWidth:.8,leftEye:1.45,rightEye:1.45,leftBrow:.8,rightBrow:.8,browTilt:.9}),confused:vt({smile:-.2,mouthWidth:.8,leftEye:.9,rightEye:1.15,leftBrow:-.3,rightBrow:.8,lookX:.5,lookY:-.4}),skeptical:vt({smile:-.1,leftEye:.6,rightEye:1,leftBrow:-.4,rightBrow:.7,lookX:.4}),thinking:vt({smile:0,mouthWidth:.7,leftBrow:.3,rightBrow:.5,lookX:.6,lookY:-.8}),sleepy:vt({smile:.1,leftEye:.25,rightEye:.25,leftBrow:-.3,rightBrow:-.3,lookY:.5}),disgusted:vt({smile:-.7,mouthWidth:.9,leftEye:.6,rightEye:.75,leftBrow:-.5,rightBrow:-.2,browTilt:-.4,lookX:-.6}),smug:vt({smile:.6,mouthWidth:.9,leftEye:.6,rightEye:.6,leftBrow:.1,rightBrow:.5,lookX:.5}),wink:vt({smile:.9,leftEye:0,rightEye:1,leftBrow:-.2,rightBrow:.3})};function te(t,e){return{...t,...typeof e=="string"?ct[e]:e}}const _t={rest:et,wave:wt({rightShoulder:135,rightElbow:30,headTilt:6,...ct.happy}),cheer:wt({leftShoulder:125,leftElbow:20,rightShoulder:125,rightElbow:20,...ct.joyful}),shrug:wt({leftShoulder:30,leftElbow:85,rightShoulder:30,rightElbow:85,headTilt:-10,...ct.confused,lookX:0,lookY:0}),point:wt({rightShoulder:90,rightElbow:0,lean:4,smile:.4}),think:wt({rightShoulder:60,rightElbow:150,headTilt:10,...ct.thinking}),handsOnHips:wt({leftShoulder:45,leftElbow:-100,rightShoulder:45,rightElbow:-100,leftHip:14,rightHip:14,smile:.8}),sad:wt({leftShoulder:14,rightShoulder:14,leftElbow:-4,rightElbow:-4,headTilt:-14,lean:-3,...ct.sad}),surprised:wt({leftShoulder:70,leftElbow:60,rightShoulder:70,rightElbow:60,...ct.surprised}),crouch:wt({stretch:.72,leftShoulder:35,rightShoulder:35,leftElbow:-50,rightElbow:-50,leftHip:22,rightHip:22,headTilt:-4}),sit:wt({sit:1,turn:.5,leftShoulder:-25,rightShoulder:25,leftElbow:-55,rightElbow:55}),jump:wt({stretch:1.22,leftShoulder:140,rightShoulder:140,leftElbow:20,rightElbow:20,leftHip:4,rightHip:4,...ct.joyful}),duck:wt({stretch:.62,bend:28,headTilt:-8,leftShoulder:150,rightShoulder:150,leftElbow:130,rightElbow:130,leftHip:25,rightHip:25,...ct.scared}),lie:wt({spin:-90,rise:-.42,leftShoulder:165,rightShoulder:165,leftElbow:150,rightElbow:150,...ct.sleepy}),sideSplit:wt({leftHip:90,rightHip:90,leftAnkle:-45,rightAnkle:-45,leftShoulder:120,rightShoulder:120,leftElbow:10,rightElbow:10,...ct.happy}),frontSplit:wt({turn:1,leftHip:-90,rightHip:-90,leftAnkle:-45,rightAnkle:-45,leftShoulder:-150,rightShoulder:150,leftElbow:10,rightElbow:-10,...ct.happy})},bl=Object.keys(et);function Le(t,e,n){const i={...t};for(const s of bl)i[s]=t[s]+(e[s]-t[s])*n;return i}const Fs=24,wl=4,kl=28,p0=40;function vl(t,e=et,n=1){const i=Math.sin(t*Math.PI*2)*n,s=Math.cos(t*Math.PI*2)*n,o=c=>Math.abs(c)<=p0,r=c=>o(c)?22*i:c,a=o(e.leftShoulder)?e.leftElbow-kl*Math.max(0,-i):e.leftElbow,l=o(e.rightShoulder)?e.rightElbow+kl*Math.max(0,i):e.rightElbow;return{...e,lean:e.lean+wl*n,headTilt:e.headTilt-wl*.5*n,leftElbow:a,rightElbow:l,leftHip:-Fs*i,rightHip:-Fs*i,leftKnee:-30*Math.max(0,s),rightKnee:30*Math.max(0,-s),leftShoulder:r(e.leftShoulder),rightShoulder:r(e.rightShoulder)}}function Sl(t,e=1){return 4*((Ds+oi)*t)*Math.sin(Fs*e*Math.PI/180)}function Ml(t){const e=Math.abs(Math.sin(t/65)),n=.55+.45*Math.sin(t/310);return e*n}const Tl=.12,El=.46,g0=1-2*Tl,m0=.1,y0=.21,b0=.19,Ds=.24,oi=.22,Al=.12,w0=.14,xl=.33,Pl=.7,$l=.3,k0=.35,v0=[1.7,1.05],S0=[1.3,.75],_l=[1.45,.85],M0=[1.15,.75],Il=.06,T0=.7,E0=.65,Ol=.075,A0=.3,x0=.02,P0=.012,$0=12,_0=.25,ri=90,I0=.25,O0=.04,Hl=.01,de=t=>Math.min(1,Math.max(0,t??0));function H0(t,e=1){return oi*t*e}const Ns=-.12,Cl=.4,Ct=t=>t*Math.PI/180,C0=(t,e)=>({x:e*Math.sin(Ct(t)),y:Math.cos(Ct(t))}),Rl=(t,e)=>Math.max(0,t)*(1-Math.min(1,Math.max(0,e))),Ll=(t,e,n,i)=>t-.3*e-n*.14*e-Math.max(0,i-1)*.12*e;function R0(t,e,n,i,s,o){const r=Math.max(1,Math.min(o*.6,w0*n)),a=de(e.turn),l=(Al+xl*a)*n,c=i+Ns*n,h=l+e.lookX*.08*n,f=e.lookY*.07*n,u=[{x:-.34*n*(1-Pl*a),squeeze:1-Pl*a,open:e.leftEye,brow:e.leftBrow,side:-1},{x:.34*n*(1-$l*a),squeeze:1-$l*a,open:e.rightEye,brow:e.rightBrow,side:1}];t.fillStyle=s,t.strokeStyle=s,t.lineWidth=r;for(const y of u){const w=Rl(y.open,e.blink);if(w<.2){const A=e.smile>.5?-.12*n:.06*n;t.beginPath(),t.moveTo(y.x+l-.12*n,c),t.quadraticCurveTo(y.x+l,c+A,y.x+l+.12*n,c),t.stroke()}else{if(w>1.2){const x=.13*n*w;t.beginPath(),t.ellipse(y.x+l,c,x*.85,x,0,0,Math.PI*2),t.fillStyle="#ffffff",t.fill(),t.stroke(),t.fillStyle=s}const A=w>1.2?.075*n:.1*n;t.beginPath(),t.ellipse(y.x+h,c+f,A,A*1.1*Math.min(w,1),0,0,Math.PI*2),t.fill()}const v=Ll(c,n,y.brow,w),T=y.x+l-y.side*.13*n*y.squeeze,S=y.x+l+y.side*.13*n*y.squeeze;t.beginPath(),t.moveTo(S,v),t.lineTo(T,v-e.browTilt*.1*n),t.stroke()}const p=i+Cl*n,g=.25*n*Math.max(.3,e.mouthWidth)*(1-k0*a),d=Math.min(1,Math.max(0,e.mouth));if(t.beginPath(),d<=.05){t.moveTo(l-g,p),t.quadraticCurveTo(l,p+e.smile*.25*n,l+g,p),t.stroke();return}const m=.3*n*d;e.smile>.3?(t.moveTo(l-g,p-.05*n),t.lineTo(l+g,p-.05*n),t.quadraticCurveTo(l,p+m*2,l-g,p-.05*n)):e.smile<-.3?(t.moveTo(l-g,p+m*.6),t.lineTo(l+g,p+m*.6),t.quadraticCurveTo(l,p-m*1.4,l-g,p+m*.6)):t.ellipse(l,p,g*.8,m,0,0,Math.PI*2),t.fill()}function Fl(t,e){const n=e.height??300,i=Math.min(3,Math.max(.3,t.stretch??1)),s=Math.sqrt(i),o=(e.headSize??2*Tl)/2,r=e.headSize===void 0?g0:1-2*o,a=o*n,l=de(t.sit),c=t.leftHip+(-ri-t.leftHip)*l,h=t.leftKnee+(-ri-t.leftKnee)*l,f=t.rightHip+(ri-t.rightHip)*l,u=t.rightKnee+(ri-t.rightKnee)*l,p=e.classic===!0,g=de(t.turn),d=(X,tt,J,M,I)=>{const k=Math.max(-Math.PI/2,Math.min(Math.PI/2,Math.abs(Ct(tt-J)/2)+Ct(M))),$=Math.max(-1,Math.min(1,T0+I)),R=g+(1-g)*X*$;return p?{x:0,y:0}:{x:Math.cos(k)*Il*R,y:Math.sin(k)*Il}},m={left:t.leftAnkle??0,right:t.rightAnkle??0},y={left:t.leftFootOut??0,right:t.rightFootOut??0};let w=0;if(l>0||!p){const X=(I,k,$,R,W)=>Ds*Math.cos(Ct(k))+oi*Math.cos(Ct(k-$))+Math.max(0,d(I,k,$,R,W).y),tt=Math.max(X(-1,c,h,m.left,y.left),X(1,f,u,m.right,y.right)),J=1-de((t.rise??0)/O0),M=(p?Math.min(1,l/I0):1)*J;w=(El-tt)*M*n*i}const v=-El*n*i+w,T=-r*n*i+w,S=p?0:(x0*de(t.turn)+P0*l)*n*i,A=Ct(t.bend??0),x={end:Nl(v,T,A,1),bend:A};let C;if(A!==0){C=[];for(let X=0;X<=Dl;X++){const tt=X/Dl,J=Nl(v,T,A,tt);C.push({x:J.x-S*Math.sin(Math.PI*tt),y:J.y})}}else C=S===0?[{x:0,y:v},{x:0,y:T}]:fe({x:0,y:v},{x:-S,y:(v+T)/2},{x:0,y:T},1,8);const E=T+m0*n*i,H=(e.shoulderWidth??0)*n*Math.cos(g*Math.PI/2),_=(X,tt,J,M,I)=>{const k=C0(J,M);return{x:X+k.x*I*n,y:tt+k.y*I*n}},P=(X,tt,J)=>{const M=_(0,v,tt,X,Ds*i);return{root:{x:0,y:v},joint:M,end:_(M.x,M.y,tt-J,X,oi*i)}},L=(X,tt,J)=>{const M={x:X*H,y:E},I=_(M.x,M.y,tt,X,y0*s);return{root:M,joint:I,end:_(I.x,I.y,tt+J,X,b0*s)}},F={left:P(-1,c,h),right:P(1,f,u)},K=(X,tt,J,M,I,k)=>{const $=d(X,J,M,I,k);return{x:tt.end.x+$.x*n*i,y:tt.end.y+$.y*n*i}},V=(X,tt,J,M,I)=>_(tt.end.x,tt.end.y,J+M+I,X,Ol*s),ot={left:L(-1,t.leftShoulder,t.leftElbow),right:L(1,t.rightShoulder,t.rightElbow)};return{height:n,facing:(e.facing??1)<0?-1:1,stretch:i,lineWidth:e.lineWidth??n*.025,rubber:Math.min(1,Math.max(p?0:A0,e.rubber??0)),r:a,headRx:a/Math.sqrt(i),headRy:a*Math.sqrt(i),hipY:v,neckY:T,drop:w,lean:p?t.lean:t.lean+$0*Math.sin(Math.PI*l),classic:p,legs:F,toes:{left:K(-1,F.left,c,h,m.left,y.left),right:K(1,F.right,f,u,m.right,y.right)},spine:C,chest:x,arms:ot,handTips:{left:V(-1,ot.left,t.leftShoulder,t.leftElbow,t.leftWrist??0),right:V(1,ot.right,t.rightShoulder,t.rightElbow,t.rightWrist??0)}}}const Dl=10;function Nl(t,e,n,i){const s=t-e,o=n*i;if(Math.abs(n)<1e-9)return{x:0,y:t-s*i};const r=s/n;return{x:r*(1-Math.cos(o)),y:t-r*Math.sin(o)}}function L0(t,e){if(t.chest.bend===0)return e;const n=pn(e,{x:0,y:t.neckY},t.chest.bend);return{x:n.x+t.chest.end.x,y:n.y+t.chest.end.y-t.neckY}}const dn=(t,e)=>e===0?[t.root,t.joint,t.end]:fe(t.root,t.joint,t.end,e);function pn(t,e,n){const i=Math.cos(n),s=Math.sin(n),o=t.x-e.x,r=t.y-e.y;return{x:e.x+o*i-r*s,y:e.y+o*s+r*i}}function Bl(t,e,n=!0){const i=D0(t,e),s=e.spin??0,o=e.rise??0;return n&&(s!==0||o!==0)?F0(i,t,s,o):i}function Wl(t,e,n){return{pivot:{x:0,y:t.hipY},angle:t.facing*Ct(e),lift:n*t.height}}function F0(t,e,n,i){const{pivot:s,angle:o,lift:r}=Wl(e,n,i),a=u=>{const p=pn(u,s,o);return{x:p.x,y:p.y-r}},l=u=>({left:a(u.left),right:a(u.right)}),c={left:Math.max(a(t.feet.left).y,a(t.toes.left).y),right:Math.max(a(t.feet.right).y,a(t.toes.right).y)},h=Math.max(c.left,c.right),f=Hl*e.height;return{...t,hip:a(t.hip),neck:a(t.neck),shoulders:l(t.shoulders),elbows:l(t.elbows),hands:l(t.hands),fingertips:l(t.fingertips),knees:l(t.knees),feet:l(t.feet),toes:l(t.toes),feetY:h,grounded:{left:c.left>=h-f,right:c.right>=h-f},handAngle:{left:t.handAngle.left+o,right:t.handAngle.right+o},limbs:{leftArm:t.limbs.leftArm.map(a),rightArm:t.limbs.rightArm.map(a),leftLeg:t.limbs.leftLeg.map(a),rightLeg:t.limbs.rightLeg.map(a),spine:t.limbs.spine.map(a)},head:{...t.head,center:a(t.head.center),angle:t.head.angle+o}}}function D0(t,e){const n=Ct(t.lean),i=Ct(e.headTilt),s={x:0,y:t.hipY},o=T=>({x:t.facing*T.x,y:T.y}),r=T=>o(pn(T,s,n)),a=T=>r(L0(t,T)),l=T=>a(pn({x:T.x,y:T.y+t.neckY},{x:0,y:t.neckY},i)),c=dn(t.arms.left,t.rubber).map(a),h=dn(t.arms.right,t.rubber).map(a),f=(T,S)=>Math.atan2(S.y-T.y,S.x-T.x),u={left:a(t.handTips.left),right:a(t.handTips.right)},p=(T,S)=>{const[A,x]=T.slice(-2),C=t.arms[S],E=f(a(C.end),u[S])-f(a(C.joint),a(C.end));return f(A,x)+E};let g=1/0;for(const[T,S]of[[e.leftBrow,e.leftEye],[e.rightBrow,e.rightEye]]){const A=Ll(Ns,1,T,Rl(S,e.blink));g=Math.min(g,A,A-e.browTilt*.1)}const d={left:o(t.legs.left.end),right:o(t.legs.right.end)},m={left:o(t.toes.left),right:o(t.toes.right)},y={left:Math.max(d.left.y,m.left.y),right:Math.max(d.right.y,m.right.y)},w=Math.max(y.left,y.right),v=Hl*t.height;return{facing:t.facing,height:t.height,stretch:t.stretch,lineWidth:t.lineWidth,hip:s,neck:a({x:0,y:t.neckY}),shoulders:{left:a(t.arms.left.root),right:a(t.arms.right.root)},elbows:{left:a(t.arms.left.joint),right:a(t.arms.right.joint)},hands:{left:a(t.arms.left.end),right:a(t.arms.right.end)},knees:{left:o(t.legs.left.joint),right:o(t.legs.right.joint)},feet:d,toes:m,feetY:w,grounded:{left:y.left>=w-v,right:y.right>=w-v},fingertips:u,handAngle:{left:p(c,"left"),right:p(h,"right")},limbs:{leftArm:c,rightArm:h,leftLeg:dn(t.legs.left,t.rubber).map(o),rightLeg:dn(t.legs.right,t.rubber).map(o),spine:t.spine.map(r)},head:{center:l({x:0,y:-t.headRy}),rx:t.headRx,ry:t.headRy,angle:t.facing*(n+t.chest.bend+i),eyeY:Ns,browTopY:g,mouthY:Cl,faceX:t.facing*(Al+xl*de(e.turn))}}}function ee(t,e={}){return Bl(Fl(t,e),t)}function N0(t,e,n){return pn({x:t.center.x+e*t.rx,y:t.center.y+n*t.ry},t.center,t.angle)}function Kl(t,e,n){const i=o=>({x:o.x+e,y:o.y+n}),s=o=>({left:i(o.left),right:i(o.right)});return{...t,hip:i(t.hip),neck:i(t.neck),shoulders:s(t.shoulders),elbows:s(t.elbows),hands:s(t.hands),fingertips:s(t.fingertips),knees:s(t.knees),feet:s(t.feet),toes:s(t.toes),feetY:t.feetY+n,grounded:{...t.grounded},handAngle:{...t.handAngle},limbs:{leftArm:t.limbs.leftArm.map(i),rightArm:t.limbs.rightArm.map(i),leftLeg:t.limbs.leftLeg.map(i),rightLeg:t.limbs.rightLeg.map(i),spine:t.limbs.spine.map(i)},head:{...t.head,center:i(t.head.center)}}}function Yl(t,e,n={},i=0){const s=Fl(e,n),o=n.color??"#1e293b",r=n.layers??{},a=n.layers?Bl(s,e,!1):void 0,l=n.sketch?Qn(t,n.sketch,i):void 0,c=n.sketch&&n.layers?Qn(t,n.sketch,i):void 0,h=x=>{t.save(),x(),t.restore()},f=x=>{x&&a&&h(()=>x(t,a,i,c))},u=()=>t.scale(s.facing,1),p=()=>{u(),t.translate(0,s.hipY),t.rotate(Ct(s.lean)),t.translate(0,-s.hipY)},g=()=>{p(),s.chest.bend!==0&&(t.translate(s.chest.end.x,s.chest.end.y),t.rotate(s.chest.bend),t.translate(0,-s.neckY))},d=(x,C,E)=>{if(l)return C?l.curve(x):l.line(x);if(s.classic){t.beginPath(),t.moveTo(x[0].x,x[0].y);for(const H of x.slice(1))t.lineTo(H.x,H.y);t.stroke();return}ti(t,x,E[0]*s.lineWidth,E[1]*s.lineWidth)},m=(x,C)=>d(dn(x,s.rubber),s.rubber>0,C),y=x=>{s.classic||d([s.legs[x].end,s.toes[x]],!1,M0)},w=x=>{if(n.hands&&!s.classic)return T(x);if(s.classic||l)return;const C=s.arms[x].end;t.beginPath(),t.arc(C.x,C.y,E0*s.lineWidth,0,Math.PI*2),t.fill()};t.save(),t.strokeStyle=o,t.fillStyle=o,t.lineWidth=s.lineWidth,t.lineCap="round",t.lineJoin="round";const v=Wl(s,e.spin??0,e.rise??0);(v.angle!==0||v.lift!==0)&&(t.translate(0,-v.lift),t.translate(v.pivot.x,v.pivot.y),t.rotate(v.angle),t.translate(-v.pivot.x,-v.pivot.y));function T(x){const C=n.hands??{},E=s.arms[x].end,H=s.handTips[x],_=n.headFill??"#ffffff";si(t,E,C[x]??gt,{side:x,angle:Math.atan2(H.x-E.x,E.y-H.y)*180/Math.PI,size:(C.size??Ol)*s.height*Math.sqrt(s.stretch),skin:C.skin??(_==="none"?void 0:_),ink:o,lineWidth:s.lineWidth*.45,fingers:C.fingers,plump:C.plump,look:n.sketch?"pencil":"clean",seed:n.sketch?.seed},i)}const S=x=>{h(()=>{g(),m(s.arms[x],S0),w(x)});const C=r.sleeve;C&&a&&h(()=>C(t,a,x,i,c))},A=de(e.turn)>_0;f(r.behind),h(()=>{u(),m(s.legs.left,_l),y("left"),m(s.legs.right,_l),y("right")}),A&&S("left"),h(()=>{p(),d(s.spine,s.spine.length>2,v0)}),h(()=>{g();const{left:x,right:C}={left:s.arms.left.root,right:s.arms.right.root};if(x.x!==C.x)if(s.classic)d([x,C],!1,[1,1]);else{const E={x:(x.x+C.x)/2,y:x.y-.3*Math.abs(C.x-x.x)};d(fe(x,E,C,1,8),!0,[1.1,1.1])}}),f(r.body),A||S("left"),S("right"),f(r.behindHead),h(()=>{g(),t.translate(0,s.neckY),t.rotate(Ct(e.headTilt));const x=-s.headRy;t.beginPath(),t.ellipse(0,x,s.headRx,s.headRy,0,0,Math.PI*2);const C=n.headFill??"#ffffff";if(C!=="none"&&(t.fillStyle=C,t.fill()),l){l.ellipse(0,x,s.headRx,s.headRy);const E=l.nudge();t.translate(E.x,E.y)}else t.stroke();t.translate(0,x),t.scale(s.headRx/s.r,s.headRy/s.r),R0(t,e,s.r,0,o,s.lineWidth)}),f(r.overHead),f(r.front),t.restore(),n.label&&(t.save(),t.fillStyle=o,t.font=n.labelFont??`700 ${Math.round(s.height*.11)}px sans-serif`,t.textAlign="center",t.textBaseline="bottom",t.fillText(n.label,0,-s.height*s.stretch-.04*s.height+s.drop),t.restore())}function Bs(t,e,n,i){const s={...t},o=t.gait&&i?.[t.gait]||t.gait;let r=t.walking>0?Le(s,ml(o,t.walk,s),t.walking):s,a=B0(t);const l=t.dancing??0;if(n&&l>0){const c=n(t.beat??0);if(r=Le(r,c.pose,l),c.hands){const h=(f,u)=>u?Re(f??gt,u,l):f;a={left:h(a?.left,c.hands.left),right:h(a?.right,c.hands.right)}}}return t.talk>0&&(r={...r,mouth:Math.max(r.mouth,t.talk*Ml(e))}),{pose:r,hands:a}}function jl(t,e,n,i){return Bs(t,e,n,i).pose}const Xl=(t,e)=>(t.facing??e.facing??1)<0?-1:1,gn=(t,e)=>`hand.${t}.${e}`;function B0(t){const e=s=>{if(typeof t[gn(s,"spread")]=="number")return Object.fromEntries(Object.keys(gt).map(o=>[o,t[gn(s,o)]]))},n=e("left"),i=e("right");return n||i?{left:n,right:i}:void 0}function W0(t,e){return!e||!t.hands?t:{...t,hands:{...t.hands,left:e.left??t.hands.left,right:e.right??t.hands.right}}}function Ws(t){const e=t.style??{},n=e.height??300,i=n*.8,s={...wt(t.pose??{}),walk:0,walking:0,gait:"walk",facing:(e.facing??1)<0?-1:1,talk:0,rubber:e.rubber??0,beat:0,dancing:0},o={};if(e.hands)for(const r of["left","right"]){const a=e.hands[r]??gt;for(const l of Object.keys(gt))o[gn(r,l)]=a[l]??gt[l]}return{type:"custom",x:t.x-i/2,y:t.y-n,width:i,height:n,props:{...s,...o},about:K0(Object.keys(o),t.cast),figureStyle:e,figureDance:t.dance,figureGaits:t.cast?.gaits,draw(r,a,l){const c=a.props,h=Bs(c,l,t.dance,t.cast?.gaits);r.translate(i/2,n),Yl(r,h.pose,W0({...e,rubber:c.rubber,facing:Xl(c,e)},h.hands),l)}}}function K0(t,e){const n={...ol,...rl};for(const i of t){const[,s,...o]=i.split("."),r=al[o.join(".")];r&&(n[i]={...r,description:`${s==="left"?"Left":"Right"} hand: ${r.description.toLowerCase()}`})}return{kind:"stick figure",summary:"A poseable stick figure: pose it with joint tracks, or give it beats (`scriptTracks`) that compile into acted tracks.",props:n,get actions(){return Kd(e)}}}function Ks(t,e,n){const i=t.figureStyle;if(!i)throw new Error("stickFigureAt: the target was not made by stickFigureTarget");const s={...t.props};let o=0,r=0;for(const[c,h]of e.state?.values.get(n)??[])c==="gait"&&typeof h=="string"&&(s.gait=h),typeof h=="number"&&(c==="x"||c==="motionPathX"?o=h:c==="y"||c==="motionPathY"?r=h:c in s&&(s[c]=h));const a=jl(s,e.time,t.figureDance,t.figureGaits),l=ee(a,{...i,rubber:s.rubber,facing:Xl(s,i)});return{pose:a,joints:Kl(l,t.x+o+t.width/2,t.y+r+t.height)}}function Ys(t){const e=[];return t.forEach((n,i)=>{const s=i===0?et:e[i-1],o=typeof n.pose=="string"?_t[n.pose]:{...s,...n.pose};e.push(n.expression?te(o,n.expression):o)}),e}function Y0(t,e){const n=Ys(e);return bl.filter(i=>n.some(s=>s[i]!==et[i])).map(i=>({id:`${t}-${i}`,target:t,property:i,keyframes:e.map((s,o)=>({time:s.time,value:n[o][i],...s.easing?{easing:s.easing}:{}}))}))}const js=.5,ai={pataka:mt({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:0,turn:2}),tripataka:mt({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":1,"pinky.curl":0,spread:0,turn:2}),alapadma:mt({"thumb.curl":.1,"thumb.across":0,"index.curl":.05,"middle.curl":.15,"ring.curl":.25,"pinky.curl":.35,spread:1,turn:2}),mushti:bt.fist,shikhara:bt.thumbsUp,hamsasya:mt({"thumb.curl":.15,"thumb.across":.6,"index.curl":.6,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:.7,turn:2}),katakamukha:mt({"thumb.curl":.2,"thumb.across":.6,"index.curl":.65,"middle.curl":.7,"ring.curl":0,"pinky.curl":0,spread:.4,turn:2})};function li(t){return typeof t!="string"?t:t in ai?ai[t]:bt[t]}function ql(t,e,n){const i=[];for(const s of t.keys){const o=i[i.length-1],r=!o||s.reset?{pose:e,...n}:o;i.push({beat:s.beat,pose:{...r.pose,...s.pose},left:s.hands?.left?li(s.hands.left):r.left,right:s.hands?.right?li(s.hands.right):r.right,easing:s.easing??t.easing})}return i}const Xs=(t,e)=>(t%e+e)%e;function j0(t,e,n,i){const s=ql(t,n,i);if(s.length===0)return{pose:n,hands:i};const o=Xs(e,t.beats);let r=s.length-1;for(let p=0;p<s.length;p++)s[p].beat<=o&&(r=p);const a=s[r],l=s[(r+1)%s.length],c=a.beat<=o?a.beat:a.beat-t.beats,h=l.beat>c?l.beat:l.beat+t.beats,f=h>c?(o-c)/(h-c):0,u=Mt(l.easing??"ease-in-out")(Math.min(1,Math.max(0,f)));return{pose:Le(a.pose,l.pose,u),hands:{left:Re(a.left,l.left,u),right:Re(a.right,l.right,u)}}}const X0=[["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"],["leftFootOut","rightFootOut"],["leftEye","rightEye"],["leftBrow","rightBrow"]],q0=["lean","headTilt","lookX","spin"],U0=new Set(["leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee"]);function Ul(t){const e={...t},n=(t.turn??0)>=.5;for(const[i,s]of X0){const o=n&&U0.has(i)?-1:1;e[i]=o*t[s],e[s]=o*t[i]}if(!n)for(const i of q0)e[i]=-t[i];return e}const V0=t=>Math.min(1,Math.max(-1,(.5-t)*4));function Vl(t,e,n){const i=Xs(n,1),s=(1+Math.cos(2*Math.PI*i))/2,o=e.bounce*(e.accent==="up"?1-s:s),r=Math.min(1,Math.max(0,t.turn??0)),a=V0(r);return{...t,leftHip:t.leftHip+a*o/2,rightHip:t.rightHip+o/2,leftKnee:t.leftKnee+a*o,rightKnee:t.rightKnee+o,lean:t.lean+(e.sway??0)*(1-r)*Math.sin(Math.PI*n)}}function ci(t){const e={...et,...t.stance};return t.expression?te(e,t.expression):e}function Gl(t){return{left:t.hands?.left?li(t.hands.left):gt,right:t.hands?.right?li(t.hands.right):gt}}function qs(t,e,n){const i=t.moves[e.move];if(!i)throw new Error(`dance: "${t.label}" has no move "${e.move}"`);const s=j0(i,n,ci(t),Gl(t));return e.mirror?{pose:Ul(s.pose),hands:{left:s.hands?.right,right:s.hands?.left}}:s}function hi(t,e,n={}){const i=typeof t=="string"?ne[t]:t;let s;if(n.move)s=qs(i,{move:n.move,mirror:n.mirror},e);else{const o=i.routine,r=o.reduce((f,u)=>f+u.beats,0),a=Xs(e,r);let l=0,c=0;for(;c<o.length-1&&a>=l+o[c].beats;)l+=o[c++].beats;const h=a-l;if(s=qs(i,o[c],h),h<js&&o.length>1&&e>=js){const f=o[(c-1+o.length)%o.length],u=qs(i,f,f.beats+h),p=Mt("ease-in-out")(h/js);s={pose:Le(u.pose,s.pose,p),hands:{left:Re(u.hands.left,s.hands.left,p),right:Re(u.hands.right,s.hands.right,p)}}}}return{...s,pose:Vl(s.pose,i.groove,e)}}function G0(t,e,n={}){return hi(t,e,n).pose}function ui(t){return(typeof t=="string"?ne[t]:t).routine.reduce((n,i)=>n+i.beats,0)}const z0={leftToe:"rightToe",rightToe:"leftToe",leftHeel:"rightHeel",rightHeel:"leftHeel"};function zl(t,e,n,i,s,o,r){for(let a=0;a*t.beats<n;a++)for(const l of t.keys){const c=a*t.beats+l.beat,h=e+c;if(!(c>=n||h<o||h>=r))for(const f of l.taps??[])s.push({beat:h,tap:i?z0[f]:f})}}function J0(t,e,n,i={}){const s=typeof t=="string"?ne[t]:t,o=[];if(n<=e)return o;if(i.move){const r=s.moves[i.move],a=Math.floor(e/r.beats)*r.beats;zl(r,a,Math.ceil((n-a)/r.beats)*r.beats,i.mirror,o,e,n)}else{const r=ui(s);for(let a=Math.floor(e/r)*r;a<n;a+=r){let l=a;for(const c of s.routine)zl(s.moves[c.move],l,c.beats,c.mirror,o,e,n),l+=c.beats}}return o.sort((r,a)=>r.beat-a.beat)}function Jl(t,e){const n=t.moves[e.move];if(!n?.travel)return 0;const i=n.travel/n.beats;return e.mirror?(ql(n,ci(t),Gl(t))[0]?.pose.turn??ci(t).turn??0)>=.5?i:-i:i}function Zl(t,e){return e.move?[{move:e.move,beats:t.moves[e.move].beats,mirror:e.mirror}]:t.routine}function fi(t,e,n={}){const i=typeof t=="string"?ne[t]:t,s=Zl(i,n),o=s.reduce((h,f)=>h+f.beats,0),r=s.reduce((h,f)=>h+Jl(i,f)*f.beats,0),a=Math.floor(e/o);let l=a*r,c=e-a*o;for(const h of s){const f=Math.min(h.beats,c);if(l+=Jl(i,h)*f,c-=f,c<=0)break}return l}function Z0(t,e,n){const i=Zl(t,n),s=[0];let o=0;for(let r=0;o<e;r=(r+1)%i.length)o+=i[r].beats,s.push(Math.min(o,e));return s}const Q0=8;function Ql(t,e,n){const i=typeof e=="string"?ne[e]:e,s=n.bpm??i.bpm,o=n.beats??(n.move?i.moves[n.move].beats:ui(i)),r=Z0(i,o,n);if(r.every(y=>fi(i,y,n)===0))return;const a=Math.min(n.fade??1,o/2),l=Mt("ease-in-out"),c=y=>a<=0?1:Math.min(l(Math.min(1,y/a)),l(Math.min(1,(o-y)/a))),h=Math.ceil(a*Q0),f=a<=0?[]:Array.from({length:h+1},(y,w)=>[w/h*a,o-w/h*a]).flat(),u=[...new Set([...r,...f])].sort((y,w)=>y-w);let p=0;const g=u.map((y,w)=>{if(w>0){const v=u[w-1],T=Math.max(1,Math.ceil((y-v)*16));for(let S=0;S<T;S++){const A=v+(y-v)*S/T,x=v+(y-v)*(S+1)/T;p+=(fi(i,x,n)-fi(i,A,n))*c((A+x)/2)}}return{beat:y,travel:p}}),d=n.start??0,m=n.x??0;return{id:`${t}-x`,target:t,property:"x",keyframes:g.map(y=>({time:d+y.beat*6e4/s,value:m+n.height*y.travel,easing:"linear"}))}}function tp(t,e,n=0){return(t-n)*e/6e4}function ep(t,e={}){return n=>hi(t,n,e)}function np(t,e){const n=e.start??0,i=6e4/e.bpm,s=n+e.beats*i,o=Math.min((e.fade??1)*i,(s-n)/2);return[{id:`${t}-beat`,target:t,property:"beat",keyframes:[{time:n,value:0},{time:s,value:e.beats,easing:"linear"}]},{id:`${t}-dancing`,target:t,property:"dancing",keyframes:[{time:n,value:0},{time:n+o,value:1,easing:"ease-in-out"},{time:s-o,value:1},{time:s,value:0,easing:"ease-in-out"}]}]}function ip(t,e,n={}){const i=typeof e=="string"?ne[e]:e,s=n.bpm??i.bpm,o=n.beats??(n.move?i.moves[n.move].beats:ui(i)),r=n.samplesPerBeat??4,a=n.start??0,l=Math.round(o*r),c=Array.from({length:l+1},(d,m)=>{const y=m/r;return{time:a+y*6e4/s,frame:hi(i,y,n)}}),h=(d,m)=>({id:`${t}-${d}`,target:t,property:d,keyframes:c.map(y=>({time:y.time,value:m(y.frame)}))}),u=Object.keys(et).filter(d=>c.some(m=>m.frame.pose[d]!==c[0].frame.pose[d])||c[0].frame.pose[d]!==et[d]).map(d=>h(d,m=>m.pose[d])),p=n.height===void 0?void 0:Ql(t,i,{...n,bpm:s,beats:o,start:a,height:n.height,fade:0});if(p&&u.push(p),n.hands===!1)return u;const g=[];for(const d of["left","right"])for(const m of Object.keys(gt)){const y=w=>w.hands?.[d]?.[m]??gt[m];c.some(w=>y(w.frame)!==gt[m])&&g.push(h(gn(d,m),y))}return[...u,...g]}const mn={type:"back",mode:"out",overshoot:1.1},Tt="ease-out-cubic",sp={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:Tt,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:Tt},{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:Tt},{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}]},op={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}]},rp={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:Tt},{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:Tt},{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:Tt},{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:mn},{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}]},ap={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((t,e)=>({beat:t,pose:{leftShoulder:128,rightShoulder:128,leftElbow:8,rightElbow:8,leftWrist:e%2?4:26,rightWrist:e%2?26:4,leftHip:16,rightHip:16,leftKnee:t<1?26:8,rightKnee:t<1?26:8},hands:e===0?{left:{...bt.spread,turn:2},right:{...bt.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:Tt},{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}]},lp={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:mn,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:mn},{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:mn},{beat:3,pose:{headTilt:4}}]},isolations:{label:"Isolations",beats:2,easing:Tt,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}]},cp={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:{...bt.cupped,roll:-30},left:{...bt.flat,turn:0}}},{beat:.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...bt.cupped,roll:30}}},{beat:1,pose:{rightWrist:-15,rightElbow:12,leftWrist:-45,lean:-4,rightHip:16,leftHip:6},hands:{right:{...bt.cupped,roll:-30}}},{beat:1.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...bt.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:{...bt.open,turn:2}},easing:Tt},{beat:.5,pose:{lean:-4,rightHip:12,headTilt:6}},{beat:1,pose:{lean:-11,rightHip:22,headTilt:10},easing:Tt},{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:Tt},{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:Tt}]}},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}]},hp={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}]},up={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}]},fp={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:{...bt.spread,turn:2},right:{...bt.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:Tt},{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:Tt},{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}]},dp={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:{...bt.spread,turn:2},right:{...bt.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}]},ne={disco:sp,hipHop:op,breaking:rp,jazz:ap,kpop:lp,bollywood:cp,bhangra:hp,bharatanatyam:up,charleston:fp,tap:dp,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:mn},{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}]}},di=t=>Math.min(1,Math.max(0,t));function pp(t){const e={...et,turn:t.view},n=[];for(const i of t.keys){const s=n[n.length-1],o=!s||i.reset?e:s.pose;n.push({at:i.at,pose:{...o,...i.pose},easing:i.easing})}return n}function gp(t){return t-mp*Math.sin(2*Math.PI*t)/(2*Math.PI)}const mp=.5;function yp(t,e){if(!(e<=t.takeoff||e>=t.landing))return(e-t.takeoff)/(t.landing-t.takeoff)}function tc(t,e){const n=typeof t=="string"?yn[t]:t,i=pp(n),s=di(e);let o=0;for(let f=0;f<i.length;f++)i[f].at<=s&&(o=f);const r=i[o],a=i[Math.min(o+1,i.length-1)],l=a.at>r.at?(s-r.at)/(a.at-r.at):0,c=Le(r.pose,a.pose,Mt(a.easing??"ease-in-out")(di(l))),h=yp(n,s);return h===void 0?{...c,spin:0,rise:0}:{...c,spin:n.spin*gp(h),rise:4*n.height*h*(1-h)}}function ec(t,e,n){const i=typeof t=="string"?yn[t]:t,s=di(e),o=di((s-i.takeoff)/(i.landing-i.takeoff));return i.travel*n*o}function bp(t,e,n={}){const i=typeof e=="string"?yn[e]:e,s=n.start??0,o=n.duration??i.duration,r=n.samples??48,a=Array.from({length:r+1},(h,f)=>{const u=f/r;return{time:s+u*o,progress:u,pose:tc(i,u)}}),c=Object.keys(et).filter(h=>a.some(f=>f.pose[h]!==et[h])).map(h=>({id:`${t}-${h}`,target:t,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:`${t}-x`,target:t,property:"x",keyframes:a.map(f=>({time:f.time,value:(n.x??0)+h*ec(i,f.progress,n.height)}))})}return c}const wp={leftHip:-55,leftKnee:-95,rightHip:55,rightKnee:95,leftShoulder:45,rightShoulder:-45,leftElbow:10,rightElbow:-10,lean:22,stretch:.94,headTilt:6},kp={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},pi={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},vp={leftHip:-22,leftKnee:-30,rightHip:22,rightKnee:30,leftAnkle:10,rightAnkle:10,leftShoulder:-125,rightShoulder:125,leftElbow:0,rightElbow:0,lean:8,headTilt:0},Sp={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 Fe(t,e,n,i,s,o=1300){return{label:t,view:1,spin:e,height:n,travel:i,takeoff:.27,landing:.8,duration:o,keys:[{at:0,reset:!0},{at:.16,pose:wp},{at:.27,pose:kp,easing:"ease-out-quad"},...s,{at:.76,pose:vp},{at:.86,pose:Sp,easing:"ease-out-quad"},{at:1,reset:!0}]}}const yn={frontFlip:Fe("Front flip (tuck)",360,.56,.35,[{at:.38,pose:pi,easing:"ease-out-cubic"},{at:.64,pose:pi}]),backFlip:Fe("Back flip (tuck)",-360,.58,-.15,[{at:.36,pose:{...pi,lean:18},easing:"ease-out-cubic"},{at:.64,pose:{...pi,lean:18}}]),layout:Fe("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:Fe("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:Fe("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:Fe("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)},Us=.215,Vs=.205,Mp=.065,nc=.035,Tp=.165,Ep=.155,Ap=12,xp=.3,Pp=.7,$p=.35,_p=t=>t*Math.PI/180,yt={turn:0,lean:0,bend:0,side:0,"head.turn":0,"head.nod":0,"head.tilt":0,"arm.left.swing":0,"arm.left.spread":12,"arm.left.elbow":8,"arm.left.bend":0,"arm.right.swing":0,"arm.right.spread":12,"arm.right.elbow":8,"arm.right.bend":0,"leg.left.swing":0,"leg.left.spread":3,"leg.left.knee":0,"leg.left.ankle":0,"leg.left.toeOut":0,"leg.left.rotate":0,"leg.right.swing":0,"leg.right.spread":3,"leg.right.knee":0,"leg.right.ankle":0,"leg.right.toeOut":0,"leg.right.rotate":0,stretch:1,lift:0,roll:0,mouth:0,smile:.5,mouthWidth:1,blink:0,"eye.left":1,"eye.right":1,"brow.left":0,"brow.right":0,browTilt:0,lookX:0,lookY:0};function It(t={}){return{...yt,...t}}const Ip=new Set(["turn","side","head.turn","head.tilt","roll","lookX"]);function Op(t){const e={};for(const[n,i]of Object.entries(t)){const s=n.replace(/(^|\.)(left|right)(\.|$)/,(o,r,a,l)=>`${r}${a==="left"?"right":"left"}${l}`);e[s]=Ip.has(n)?-i:i}return e}function Rt(t,e){const n={};for(const i of["left","right"])for(const[s,o]of Object.entries(e))n[`${t}.${i}.${s}`]=o;return n}const Gs={rest:yt,wave:It({"arm.right.spread":115,"arm.right.bend":55,"arm.right.elbow":0,"head.tilt":-6,smile:.9}),cheer:It({...Rt("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({...Rt("arm",{spread:50,bend:-105,elbow:0}),...Rt("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({...Rt("arm",{spread:35,bend:75,elbow:0}),"head.tilt":-10,smile:-.2}),sit:It({...Rt("leg",{swing:90,knee:90,spread:4}),...Rt("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,...Rt("arm",{swing:20,elbow:30})}),crouch:It({...Rt("leg",{swing:75,knee:140,spread:6}),lean:25,...Rt("arm",{swing:50,elbow:40}),"head.nod":-15}),crawl:It({lean:82,"head.nod":-35,...Rt("arm",{swing:80,elbow:0,spread:4}),...Rt("leg",{knee:92,ankle:-88})}),lieDown:It({roll:90,...Rt("arm",{spread:8}),"head.nod":0})};function ic(t={}){const e=t.headSize??.3,n=t.shoulderWidth??.06,i=t.hipWidth??.022,s=Math.max(.12,1-e-nc-(Us+Vs)),o=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:Tp,width:[1.25,.9]},{length:Ep,width:[.9,.75]}]}),r=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:Us,width:[1.45,1.05]},{length:Vs,width:[1.05,.85]},{length:Mp,width:[.95,.7]}]}),a=(l,c)=>l[c]??yt[c]??0;return{id:"human",hipHeight:Us+Vs,chains:[r("left"),r("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:nc,width:[1,.9]}]},o("left"),o("right")],head:{on:"neck",size:e},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,m=a(l,"side")/2,y=-a(l,"bend");return[{swing:d+y*xp,spread:m},{swing:d+y*Pp,spread:m}]}if(c.id==="neck")return[{swing:-a(l,"bend")*$p,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"),g=1-Math.cos(_p(u("rotate")));return[{swing:u("swing"),spread:u("spread"),yaw:p},{swing:-u("knee"),spread:0,yaw:p},{swing:90+u("ankle")-g*(u("swing")-u("knee")),spread:0,yaw:(Ap+u("toeOut"))*(c.side??1)}]},withAngles(l,c,h){const[f,u]=c.id.split("."),p=g=>`${f}.${u}.${g}`;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 Hp(t){const e=t.split(".");if(e[0]==="hand"&&e.length>=3){const i=`${e[1]==="left"?"Left":"Right"} hand`,s={spread:"finger spread",turn:"wrist turn",bend:"wrist bend",tilt:"wrist tilt",roll:"roll"},o=e.slice(2).join(".");return`${i} · ${s[o]??o.replace(".curl"," curl").replace(".across"," across")}`}if(e.length===3){const[i,s,o]=e;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"}[o]??o}`}return{turn:"View (front → side → back)",lean:"Lean forward / back",bend:"Back curve (line of action)",side:"Lean sideways","head.turn":"Head · turn","head.nod":"Head · nod","head.tilt":"Head · tilt",stretch:"Squash / stretch",lift:"Lift off the ground",roll:"Roll (whole figure)",mouth:"Mouth open",smile:"Smile",mouthWidth:"Mouth width",blink:"Blink","eye.left":"Left eye open","eye.right":"Right eye open","brow.left":"Left brow","brow.right":"Right brow",browTilt:"Brow slant",lookX:"Look left / right",lookY:"Look up / down"}[t]??t}const Cp={leftEye:"eye.left",rightEye:"eye.right",leftBrow:"brow.left",rightBrow:"brow.right"},zs=Object.fromEntries(Object.entries(ct).map(([t,e])=>[t,Object.fromEntries(Object.entries(e).map(([n,i])=>[Cp[n]??n,i]))]));function Rp(t,e){const n=Math.min(1,Math.max(0,t.turn??0)),i=1-n,s={...yt,turn:n},o=[{stick:"right",human:"left",s:1},{stick:"left",human:"right",s:-1}];for(const{stick:a,human:l,s:c}of o){const h=t[`${a}Shoulder`],f=t[`${a}Elbow`];s[`arm.${l}.spread`]=h*i,s[`arm.${l}.swing`]=c*h*n,s[`arm.${l}.bend`]=f*i,s[`arm.${l}.elbow`]=c*f*n;const u=t[`${a}Hip`],p=t[`${a}Knee`],g=i+c*n;s[`leg.${l}.rotate`]=90*i,s[`leg.${l}.spread`]=0,s[`leg.${l}.swing`]=u*g,s[`leg.${l}.knee`]=p*g,s[`leg.${l}.ankle`]=-(t[`${a}Ankle`]??0),s[`leg.${l}.toeOut`]=(t[`${a}FootOut`]??0)*Lp,s[`eye.${l}`]=t[`${a}Eye`],s[`brow.${l}`]=t[`${a}Brow`],e&&Object.assign(s,Fp(l,e[a]??gt,t[`${a}Wrist`]??0,n))}const r=t.bend??0;s.lean=t.lean*n,s.bend=r*n,s.side=(t.lean+r*.5)*i,s["head.tilt"]=(t.headTilt+r*.5)*i,s["head.nod"]=t.headTilt*n;for(const a of["mouth","smile","mouthWidth","blink","browTilt","lookX","lookY","stretch"])s[a]=t[a];return s.lift=t.rise??0,s.roll=t.spin??0,s}const Lp=70;function Fp(t,e,n,i){const s=t==="right"?1-i:1+i,o={};for(const r of Object.keys(gt))o[`hand.${t}.${r}`]=e[r]??gt[r];return o[`hand.${t}.turn`]=(e.turn??0)-s,o[`hand.${t}.roll`]=(e.roll??0)+n,o}const Lt=t=>t*Math.PI/180;function sc([t,e,n],i){const s=Math.cos(i),o=Math.sin(i);return[t,e*s+n*o,-e*o+n*s]}function Js([t,e,n],i){const s=Math.cos(i),o=Math.sin(i);return[t*s-e*o,t*o+e*s,n]}function pe([t,e,n],i){const s=Math.cos(i),o=Math.sin(i);return[t*s+n*o,e,-t*o+n*s]}const ie=(t,e)=>[t[0]+e[0],t[1]+e[1],t[2]+e[2]],gi=(t,e)=>[t[0]*e,t[1]*e,t[2]*e],mi=(t,e)=>Js(sc(t,e.swing),e.spread);function Zs(t,e){const n=pe(t,e);return{point:{x:n[0],y:-n[1]},depth:n[2]}}function yi(t,e,n){const i=n,o=[0,t.hipHeight*i*(t.boneScale?.(e,null)??1),0],r={};for(const d of t.chains){const m=d.parent?r[d.parent]:void 0;if(d.parent&&!m)throw new Error(`body plan ${t.id}: chain ${d.id} comes before its parent ${d.parent}`);const y=d.at??(m?m.joints3.length-1:0),w=m?m.joints3[y]:o,v=m?m.frames[Math.max(0,y-1)]:{swing:0,spread:0},T=d.offset?ie(w,mi(gi(d.offset,i),v)):w,S=d.side??1,A=t.boneScale?.(e,d)??1,x=t.angles(e,d),C=[T],E=[];let H=v.swing,_=v.spread;d.bones.forEach((P,L)=>{const F=x[L]??{swing:0,spread:0};H+=Lt(F.swing),_+=Lt(F.spread)*S,E.push({swing:H,spread:_});const K=pe(mi(d.rest,{swing:H,spread:_}),Lt(F.yaw??0));C.push(ie(C[L],gi(K,P.length*i*A)))}),r[d.id]={joints3:C,frames:E}}const a=r[t.head.on],l=t.headPose?.(e)??{yaw:0,nod:0,tilt:0,sx:1,sy:1},c=a.frames[a.frames.length-1],h=t.head.size/2*i,f=h*l.sx,u=h*l.sy,p=d=>mi(pe(sc(Js(d,-Lt(l.tilt)),-Lt(l.nod)),Lt(l.yaw)),c),g=ie(a.joints3[a.joints3.length-1],p([0,u,0]));return{height:i,root:o,chains:r,head:{center:g,rx:f,ry:u,toBody:p}}}function Qs(t,e,n){const i=n.height,s=Lt(90*(e.turn??0)),o=yi(t,e,i),{root:r}=o,a=o.chains,{rx:l,ry:c}=o.head,h=o.head.toBody,f=o.head.center,u={};for(const E of t.chains){const{joints3:H,frames:_}=a[E.id],P=H.map(L=>Zs(L,s));u[E.id]={id:E.id,joints3:H,frames:_,points:P.map(L=>L.point),depths:P.map(L=>L.depth)}}const p=Zs(f,s),g=[[1,0,0],[0,1,0],[0,0,1]].map(E=>pe(h(E),s)),d=Zs(r,s).point,m=Lt(e.roll??0),y=E=>{const H=E.x-d.x,_=E.y-d.y;return{x:d.x+H*Math.cos(m)-_*Math.sin(m),y:d.y+H*Math.sin(m)+_*Math.cos(m)}},w=([E,H,_])=>[E*Math.cos(m)+H*Math.sin(m),-E*Math.sin(m)+H*Math.cos(m),_];for(const E of Object.values(u))E.points=E.points.map(y);const v={center:y(p.point),depth:p.depth,rx:l,ry:c,angle:0,axes:g.map(w)},T=v.axes[1];v.angle=Math.atan2(T[0],T[1]);const S=E=>{if("head"in E)return{x:v.center.x+T[0]*c,y:v.center.y-T[1]*c};const H=u[E.chain];return H.points[Math.min(E.joint,H.points.length-1)]};let A=0;(n.contact??"ground")==="ground"&&(A=-Math.max(...t.contacts.map(E=>S(E).y))),A-=(e.lift??0)*i;const x=E=>({x:E.x,y:E.y+A});for(const E of Object.values(u))E.points=E.points.map(x);v.center=x(v.center);const C=t.contacts.map(E=>({spec:E,point:S(E)}));return{height:i,view:s,chains:u,head:v,hip:x(y(d)),contacts:C,groundY:Math.max(...C.map(E=>E.point.y))}}const to=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],oc=t=>{const e=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/e,t[1]/e,t[2]/e]};function eo(t,e,n){const i=n.height,s=Lt(90*(e.turn??0)),o=Lt(e.roll??0),r=yi(t,e,i),a=pe(r.root,s),l=m=>ie(Js(to(pe(m,s),a),-o),a),c={};for(const m of t.chains)c[m.id]=r.chains[m.id].joints3.map(l);const h=l(r.head.center),f=m=>oc(to(l(ie(r.head.center,r.head.toBody(m))),h)),u=[f([1,0,0]),f([0,1,0]),f([0,0,1])],p=m=>{if("head"in m)return ie(h,gi(u[1],r.head.ry));const y=c[m.chain];return y[Math.min(m.joint,y.length-1)]};let g=0;(n.contact??"ground")==="ground"&&(g=-Math.min(...t.contacts.map(m=>p(m)[1]))),g+=(e.lift??0)*i;const d=m=>[m[0],m[1]+g,m[2]];return{height:i,hip:d(a),chains:Object.fromEntries(Object.entries(c).map(([m,y])=>[m,y.map(d)])),head:{center:d(h),rx:r.head.rx,ry:r.head.ry,axes:u}}}function no(t,e,n,i){const s=n.height,o=Lt(90*(e.turn??0)),r=yi(t,e,s),a=eo(t,e,n),l=a.hip,c=a.chains,h=a.head.center,f=E=>{if("head"in E)return ie(h,gi(a.head.axes[1],a.head.ry));const H=c[E.chain];return H[Math.min(E.joint,H.length-1)]},u=i.toView(l),p=i.toScreen(u),g=i.toScreen([u[0]+1,u[1],u[2]]),d=Math.hypot(g.x-p.x,g.y-p.y),m=E=>{const H=i.toView(E);return{point:i.toScreen(H),depth:H[2]*d}},y={};for(const E of t.chains){const H=c[E.id].map(m);y[E.id]={id:E.id,joints3:r.chains[E.id].joints3,frames:r.chains[E.id].frames,points:H.map(_=>_.point),depths:H.map(_=>_.depth)}}const w=i.toView(h),v=i.toScreen(w),T=i.toScreen([w[0]+1,w[1],w[2]]),S=Math.hypot(T.x-v.x,T.y-v.y),A=a.head.axes.map(E=>oc(to(i.toView(ie(h,E)),w))),x={center:v,depth:w[2]*d,rx:r.head.rx*S,ry:r.head.ry*S,angle:Math.atan2(A[1][0],A[1][1]),axes:A},C=t.contacts.map(E=>({spec:E,point:m(f(E)).point}));return{height:s*d,view:o,chains:y,head:x,hip:p,contacts:C,groundY:Math.max(...C.map(E=>E.point.y))}}function rc(t,[e,n,i]){const[s,o,r]=t.axes,a=[s[0]*e*t.rx+o[0]*n*t.ry+r[0]*i*t.rx,s[1]*e*t.rx+o[1]*n*t.ry+r[1]*i*t.rx,s[2]*e*t.rx+o[2]*n*t.ry+r[2]*i*t.rx],l=Math.hypot(e,n,i)||1,c=(s[2]*e+o[2]*n+r[2]*i)/l;return{point:{x:t.center.x+a[0],y:t.center.y-a[1]},depth:t.depth+a[2],facing:c}}class ac{positions=[];normals=[];indices=[];vertex(e,n,i,s,o,r){const a=Math.hypot(s,o,r)||1;return this.positions.push(e,n,i),this.normals.push(s/a,o/a,r/a),this.positions.length/3-1}triangle(e,n,i){this.indices.push(e,n,i)}quad(e,n,i,s){this.indices.push(e,n,i,e,i,s)}build(){return{positions:this.positions,normals:this.normals,indices:this.indices}}}function Dp(t){const e=new Map,n=[];for(let s=0;s<t.positions.length/3;s++){const o=[0,1,2].map(r=>Math.round(t.positions[s*3+r]*1e6)).join(",");e.has(o)||e.set(o,s),n.push(e.get(o))}const i=new Map;for(let s=0;s<t.indices.length/3;s++)for(let o=0;o<3;o++){const r=n[t.indices[s*3+o]],a=n[t.indices[s*3+(o+1)%3]];if(r===a)continue;const l=r<a?`${r}-${a}`:`${a}-${r}`,c=i.get(l);c?c.faces.push(s):i.set(l,{a:Math.min(r,a),b:Math.max(r,a),faces:[s]})}return[...i.values()]}const io=Math.PI*2;function Np(t,e=16){const n=new ac,i=Math.max(6,Math.round(e)),s=Math.max(3,Math.round(i/2)),o=[];for(let r=0;r<=s;r++){const a=r/s*Math.PI,l=[];for(let c=0;c<=i;c++){const h=c/i*io,f=Math.sin(a)*Math.sin(h),u=Math.cos(a),p=Math.sin(a)*Math.cos(h);l.push(n.vertex(f*t,u*t,p*t,f,u,p))}o.push(l)}for(let r=0;r<s;r++)for(let a=0;a<i;a++){const l=o[r][a],c=o[r+1][a],h=o[r+1][a+1],f=o[r][a+1];r>0&&n.triangle(l,c,f),r<s-1&&n.triangle(c,h,f)}return n.build()}function lc(t,e,n,i,s){const o=t.vertex(0,n,0,0,i,0),r=Array.from({length:s},(a,l)=>{const c=l/s*io;return t.vertex(Math.sin(c)*e,n,Math.cos(c)*e,0,i,0)});for(let a=0;a<s;a++){const l=r[a],c=r[(a+1)%s];i===1?t.triangle(o,l,c):t.triangle(o,c,l)}}function Bp(t,e,n=24){const i=new ac,s=Math.max(6,Math.round(n)),o=e/2,r=-e/2,a=h=>Array.from({length:s+1},(f,u)=>{const p=u/s*io;return i.vertex(Math.sin(p)*t,h,Math.cos(p)*t,Math.sin(p),0,Math.cos(p))}),l=a(r),c=a(o);for(let h=0;h<s;h++)i.quad(l[h],l[h+1],c[h+1],c[h]);return lc(i,t,o,1,s),lc(i,t,r,-1,s),i.build()}function cc(t){const e=Array.from({length:t.indices.length/3},()=>[]);for(const n of Dp(t))for(const i of n.faces){const s=n.faces.find(o=>o!==i)??-1;e[i].push({a:n.a,b:n.b,across:s})}return{...t,faceEdges:e}}const bi=t=>t*180/Math.PI,De=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],so=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],bn=t=>Math.hypot(t[0],t[1],t[2]),oo=t=>{const e=bn(t)||1;return[t[0]/e,t[1]/e,t[2]/e]},wi=t=>Math.atan2(Math.sin(t),Math.cos(t));function hc(t){const[e,n,i]=oo(t);return{swing:Math.asin(Math.max(-1,Math.min(1,i))),spread:Math.atan2(e,-n)}}function Wp(t,e,n,i,s){const o=t.chains.find(H=>H.id===n);if(!o)throw new Error(`reach: no chain ${n} in ${t.id}`);if(o.bones.length<2||o.rest[1]>-.99)throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);if(!t.withAngles)throw new Error(`reach: the ${t.id} plan cannot set angles`);const r=Qs(t,{...e,turn:0,roll:0,lift:0},{height:s.height,contact:"none"}),a=r.chains[n],l=a.joints3[0],c=bn(De(a.joints3[1],a.joints3[0])),h=bn(De(a.joints3[2],a.joints3[1])),f=o.parent?r.chains[o.parent].frames[Math.max(0,(o.at??r.chains[o.parent].joints3.length-1)-1)]:{swing:0,spread:0},u=De(i,l),p=Math.min(c+h-1e-6,Math.max(Math.abs(c-h)+1e-6,bn(u))),g=oo(u),d=o.parent!==null,m=mi(o.pole??(d?[0,-.35,-1]:[0,0,1]),f);let y=De(m,[g[0]*so(m,g),g[1]*so(m,g),g[2]*so(m,g)]);bn(y)<1e-6&&(y=pe([1,0,0],0)),y=oo(y);const w=(c*c+p*p-h*h)/(2*c*p),v=Math.sqrt(Math.max(0,1-w*w)),T=[l[0]+c*(w*g[0]+v*y[0]),l[1]+c*(w*g[1]+v*y[1]),l[2]+c*(w*g[2]+v*y[2])],S=[l[0]+g[0]*p,l[1]+g[1]*p,l[2]+g[2]*p],A=o.side??1,x=hc(De(T,l)),C=hc(De(S,T)),E=[{swing:bi(wi(x.swing-f.swing)),spread:bi(wi(x.spread-f.spread))*A},{swing:bi(wi(C.swing-x.swing)),spread:bi(wi(C.spread-x.spread))*A}];return t.withAngles(e,o,E)}const Kp=.34,se=.12,Wt=-.4,Yt=(t,e,n)=>t[e]??n,Yp=(t,e)=>Math.max(0,t)*(1-Math.min(1,Math.max(0,e))),jp=.45,Xp=.35,qp=.7;function ki(t,e,n){const i=p=>Math.sqrt(Math.max(0,1-p.x*p.x-p.y*p.y)),s=rc(t,[n.x,n.y,i(n)]).facing,o=t.axes[2],r=Math.atan2(o[0],o[2]),a=Math.cos(r),l=a>=0?1:-1,c=l*Math.max(Xp,Math.abs(a)),h=l*Math.max(qp,Math.abs(a)),f=Math.cos(t.angle),u=Math.sin(t.angle);return{facing:s,points:e.map(p=>{const g=jp*Math.sin(r)+n.x*c+(p.x-n.x)*h,d=p.y+o[1]*i(p),m=g*t.rx,y=d*t.ry;return{x:t.center.x+m*f+y*u,y:t.center.y+m*u-y*f}})}}const vi=(t,e,n,i=12)=>Array.from({length:i+1},(s,o)=>{const r=o/i,a=1-r;return{x:a*a*t.x+2*a*r*e.x+r*r*n.x,y:a*a*t.y+2*a*r*e.y+r*r*n.y}}),ro=(t,e,n,i,s=16)=>Array.from({length:s},(o,r)=>{const a=Math.PI*2*r/s;return{x:t+Math.cos(a)*n,y:e+Math.sin(a)*i}}),uc=.05;function Up(t,e,n,i){const s=Math.max(1,Math.min(i*.6,.14*e.rx)),o=(y,w)=>ki(e,y,w).points,r=(y,w)=>ki(e,[],{x:y,y:w}).facing,a=Yt(n,"smile",0),l=Yt(n,"blink",0),c=Yt(n,"lookX",0),h=Yt(n,"lookY",0),f=Yt(n,"browTilt",0);for(const y of[1,-1]){const w=y===1?"left":"right",v=Kp*y;if(r(v,se)<uc)continue;const T={x:v,y:se},S=Yp(Yt(n,`eye.${w}`,1),l);if(S<.2){const E=a>.5?.12:-.06;t.line(o(vi({x:v-.12,y:se},{x:v,y:se+E},{x:v+.12,y:se}),T),s)}else{if(S>1.2){const P=.13*S;t.shape(o(ro(v,se,P*.85,P),T),"#ffffff",s)}const E=S>1.2?.075:.1,H=v+c*.08,_=se-h*.07;t.shape(o(ro(H,_,E,E*1.1*Math.min(S,1)),T),t.ink,0)}const A=se+.3+Yt(n,`brow.${w}`,0)*.14+Math.max(0,S-1)*.12,x={x:v+y*.13,y:A},C={x:v-y*.13,y:A+f*.1};t.line(o([x,{x:(x.x+C.x)/2,y:(x.y+C.y)/2},C],{x:v,y:A}),s)}const u={x:0,y:Wt};if(r(0,Wt)<-uc)return;const p=.25*Math.max(.3,Yt(n,"mouthWidth",1)),g=Math.min(1,Math.max(0,Yt(n,"mouth",0)));if(g<=.05){t.line(o(vi({x:-p,y:Wt},{x:0,y:Wt-a*.25},{x:p,y:Wt}),u),s);return}const d=.3*g;let m;if(a>.3){const y=Wt+.05;m=[...vi({x:p,y},{x:0,y:Wt-d*2},{x:-p,y})]}else if(a<-.3){const y=Wt-d*.6;m=[...vi({x:p,y},{x:0,y:Wt+d*1.4},{x:-p,y})]}else m=ro(0,Wt,p*.8,d);t.shape(o(m,u),t.ink,0)}function fc(t={}){const e=(t.proportions??"bold")==="bold",n=t.figure??"fluid",i=t.look??"clean",s=t.height??300,o=n==="stick";return{plan:t.plan??ic({headSize:t.headSize??(e?.3:.24),shoulderWidth:o?0:t.shoulderWidth??.06,hipWidth:o?0:t.hipWidth??.022}),figure:n,look:i,height:s,lineWidth:t.lineWidth??s*(e?.045:.022),ink:t.ink??(i==="pencil"?"#2f2f33":"#1e293b"),skin:t.skin??(i==="pencil"?"none":"#ffffff"),seed:t.seed??1,pencil:t.pencil??{},layers:t.layers??{},contact:t.contact??"ground",hands:t.hands??"dot",handStyle:t.handStyle??"glove",handSize:t.handSize??(t.handStyle==="natural"?.14:.17)}}function Vp(t,e,n,i){const{point:s,facing:o}=rc(t,[e,n,i]);return{point:s,facing:o}}const ao=t=>t.rest[1]<-.5,Gp=.3;function zp(t,e,n){return t.figure==="stick"?ao(e)?n.slice(0,3):n:ao(e)&&n.length>=3?fe(n[0],n[1],n[2],Gp):n.length===3?fe(n[0],n[1],n[2],1):n}function lo(t,e){const n=t.plan.id==="human"?{...yt,...e}:e;return co(t,n,Qs(t.plan,n,{height:t.height,contact:t.contact}))}function co(t,e,n){const i={},s={},o={},r=.01*t.height;t.plan.chains.forEach(u=>{const p=n.chains[u.id];i[u.id]=p.points;const g=p.depths.reduce((w,v)=>w+v,0)/p.depths.length,d=u.parent?n.chains[u.parent]:void 0,m=d?d.depths[u.at??d.depths.length-1]:0,y=g-m;o[u.id]=Math.abs(y)<r?0:y,s[u.id]={points:zp(t,u,p.points),depth:g}}),s.head={points:[n.head.center],depth:n.head.depth},o.head=0;const a=[...t.plan.chains.map(u=>u.id),"head"],l=[...a].sort((u,p)=>o[u]-o[p]||a.indexOf(u)-a.indexOf(p)),c={hip:n.hip};for(const[u,[p,g]]of Object.entries(t.plan.landmarks??{})){const d=n.chains[p]?.points;d&&(c[u]=d[Math.min(g,d.length-1)])}const h={};for(const[u,p]of Object.entries(c))h[u]=p.y>=n.groundY-.01*t.height;const f={height:t.height,lineWidth:t.lineWidth,turn:e.turn??0,points:c,chains:i,parts:s,head:n.head,groundY:n.groundY,grounded:h};return{skeleton:n,joints:f,order:l}}function dc(t,e){return lo(t,e).joints}function Jp(t,e,n){const{head:i}=n;t.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})),o=Array.from({length:13},(l,c)=>({x:-.95+1.9*c/12,y:.12})),r=ki(i,s,{x:0,y:0});r.facing>0&&t.guide(r.points),t.guide(ki(i,o,{x:0,y:.12}).points),t.guide(n.chains.spine??[]);const a=e.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&&t.guideEllipse(c.x,c.y,a,a,0)}}function Zp(t,e,n,i,s,o){const r=n.lineWidth;if(s==="head"){const{head:p}=i,g=n.skin==="none"?null:n.skin;e.ellipse(p.center.x,p.center.y,p.rx,p.ry,p.angle,g,r),e.look!=="silhouette"&&Up(e,p,o,r);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;e.line(p,r);return}const h=(p,g)=>[a.bones[p].width[0]*r,a.bones[g].width[1]*r];if(ao(a)){const[p,g]=h(0,1);if(e.limb(c,p,g),a.bones.length>=3)e.limb([l[2],l[3]],a.bones[2].width[0]*r,a.bones[2].width[1]*r);else if(n.hands==="cartoon"&&s.startsWith("arm."))Qp(t,e,n,l,s.endsWith(".left")?"left":"right",o);else{const d=l[l.length-1];e.dot(d.x,d.y,r*.62)}return}if(s==="spine"){const p=i.points["hip.left"],g=i.points["hip.right"];p&&g&&Math.hypot(p.x-g.x,p.y-g.y)>.5&&e.limb([p,g],r*1.3,r*1.3);const[d,m]=h(0,a.bones.length-1);e.limb(c,d,m);const y=i.points["shoulder.left"],w=i.points["shoulder.right"];y&&w&&Math.hypot(y.x-w.x,y.y-w.y)>.5&&e.limb(fe(y,l[l.length-1],w,1,10),r*1.15,r*1.15);return}const[f,u]=h(0,a.bones.length-1);e.limb(c,f,u)}function pc(t,e){const n=`hand.${e}.`,i={};for(const[r,a]of Object.entries(t))r.startsWith(n)&&(i[r.slice(n.length)]=a);const s=t.turn??0,o=e==="right"?1-s:1+s;return{...gt,...i,turn:o+(i.turn??0)}}function Qp(t,e,n,i,s,o){const r=i[i.length-1],a=i[i.length-2],l=Math.atan2(r.x-a.x,-(r.y-a.y))*180/Math.PI;si(t,r,pc(o,s),{size:n.handSize*n.height,side:s,angle:l,pen:e,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 gc(t,e,n,i=0){const s=e.plan.id==="human"?{...yt,...n}:n;bc(t,e,s,lo(e,s),i)}function mc(t,e){const n=e/t.height;return{...t,height:e,lineWidth:t.lineWidth*n}}function tg(t,e,n,i){const s=t.plan.id==="human"?{...yt,...e}:e,o=no(t.plan,s,{height:i.height,contact:t.contact},n);return co(mc(t,o.height),s,o).joints}function yc(t,e,n,i,s){const o=e.plan.id==="human"?{...yt,...n}:n,r=no(e.plan,o,{height:s.height,contact:e.contact},i),a=mc(e,r.height);bc(t,a,o,co(a,o,r),s.time??0)}function bc(t,e,n,i,s){const{joints:o,order:r}=i,a=Hs(t,{look:e.look,ink:e.ink,lineWidth:e.lineWidth,seed:e.seed,time:s,pencil:e.pencil}),l=c=>{c&&(t.save(),c(t,o,a,s),t.restore())};t.save(),t.lineCap="round",t.lineJoin="round",e.look==="pencil"&&e.pencil.construction!==!1&&Jp(a,e,o),l(e.layers.behind);for(const c of r){const h=e.layers.parts?.[c];l(h?.under),Zp(t,a,e,o,c,n),l(h?.over)}l(e.layers.front),t.restore()}function eg(t,e,n){const i={...t};for(const[s,o]of Object.entries(e)){const r=t[s]??o;i[s]=r+(o-r)*n}return i}function ng(t,e,n,i){const s=t.plan.id==="human"?{...yt,...e}:e;let o;if(Array.isArray(i))o=i;else{const{skeleton:r}=lo(t,s),a=Qs(t.plan,{...s,roll:0},{height:t.height,contact:"none"}),l=(s.roll??0)*Math.PI/180,c=i.x-r.hip.x,h=i.y-r.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),g=i.depth??r.chains[n].depths[r.chains[n].depths.length-1],d=Math.cos(p),m=Math.sin(p);o=[f*d-g*m,-u,f*m+g*d]}return Wp(t.plan,s,n,o,{height:t.height})}function ig(t){const{character:e}=t,n=e.height*.8,i=e.height,s=e.plan.id==="human"?yt:{};return{type:"custom",x:t.x-n/2,y:t.y-i,width:n,height:i,props:{...s,...t.pose},character:e,draw(o,r,a){o.translate(n/2,i),gc(o,e,r.props,a)}}}function wc(t,e,n){const i=o=>({x:o.x+e,y:o.y+n}),s=o=>Object.fromEntries(Object.entries(o).map(([r,a])=>[r,a.map(i)]));return{...t,points:Object.fromEntries(Object.entries(t.points).map(([o,r])=>[o,i(r)])),chains:s(t.chains),parts:Object.fromEntries(Object.entries(t.parts).map(([o,r])=>[o,{...r,points:r.points.map(i)}])),head:{...t.head,center:i(t.head.center)},groundY:t.groundY+n}}function sg(t,e,n){const i=t.character;if(!i)throw new Error("characterAt: the target was not made by characterTarget");const s={...t.props};let o=0,r=0;for(const[l,c]of e.state?.values.get(n)??[])typeof c=="number"&&(l==="x"||l==="motionPathX"?o=c:l==="y"||l==="motionPathY"?r=c:l in s&&(s[l]=c));const a=dc(i,s);return{pose:s,joints:wc(a,t.x+o+t.width/2,t.y+r+t.height)}}function ho(t,e=yt){const n=[];return t.forEach((i,s)=>{const o=s===0?e:n[s-1],r=typeof i.pose=="string"?Gs[i.pose]:void 0;n.push(r?{...r,turn:o.turn??0}:{...o,...i.pose})}),n}function og(t,e,n=yt){const i=ho(e,n);return Object.keys(n).filter(o=>i.some(r=>(r[o]??n[o])!==n[o])).map(o=>({id:`${t}-${o}`,target:t,property:o,keyframes:e.map((r,a)=>({time:r.time,value:i[a][o]??n[o],...r.easing?{easing:r.easing}:{}}))}))}const rg=new Set(["x","y","z","position","rotateX","rotateY","rotateZ","quaternion","scale","scaleX","scaleY","scaleZ","visible","opacity","color"]),ag=1.7;function lg(t,e,n){const i=Array.from({length:24},(s,o)=>{const r=o/24*Math.PI*2,a=e.toView([Math.cos(r)*n,0,Math.sin(r)*n*.8]);return a[2]<-.001?e.toScreen(a):null});i.some(s=>s===null)||(t.beginPath(),i.forEach((s,o)=>o===0?t.moveTo(s.x,s.y):t.lineTo(s.x,s.y)),t.closePath(),t.fillStyle="rgba(0, 0, 0, 0.22)",t.fill())}function cg(t){const e=Qe([0,1,0],t);if(e>.999999)return zr();if(e<-.999999)return en(Ee([1,0,0],180));const n=Yn([0,1,0],t);return en(Ee(n,Math.acos(e)*180/Math.PI))}function hg(t,e,n,i,s){const o=t.solid??{},r=o.outline===!1?void 0:o.outline??{width:2,color:"#0f172a"},a={color:o.color??"#475569",shading:o.shading??"toon",outline:r},l={color:o.skin??"#f2c49b",shading:o.shading??"toon",outline:r},c={color:"#0f172a",shading:"unlit"},h=i.height*.034,f=[],u=(v,T,S)=>f.push({mesh:v,world:ce(s,T),material:S}),p=(v,T,S)=>u(e.sphere,Zr(v,[0,0,0,1],[T,T,T]),S);for(const v of n.chains){const T=i.chains[v.id],S=v.id==="spine"?1.9:1;v.bones.forEach((A,x)=>{const C=T[x],E=T[x+1],H=Vr(C,E),[_,P]=A.width??[1,1],L=h*S*(_+P)/2;if(H>1e-6){const F=Gr(C,E,.5),K=cg(tn(Kn(E,C)));u(e.cylinder,ce(Jr(F),ce(K,jn([L,H,L]))),a)}p(C,h*S*_,a),p(E,h*S*P,a)}),v.id.startsWith("arm.")&&p(T[T.length-1],h*1.5,l)}const{center:g,rx:d,ry:m,axes:y}=i.head,w=[...y[0],0,...y[1],0,...y[2],0,...g,1];u(e.sphere,ce(w,jn([d,m,d])),l);for(const v of[-1,1]){const T=tn([v*.36,.15,.92]),S=Wn(g,Wn(Wn(Ze(y[0],T[0]*d*1.04),Ze(y[1],T[1]*m*1.04)),Ze(y[2],T[2]*d*1.04))),A=[...y[0],0,...y[1],0,...y[2],0,...S,1];u(e.sphere,ce(A,jn([d*.11,m*.14,d*.03])),c)}return f}const ug={kind:"character",validate(t){const e=t;return e.height!==void 0&&!(e.height>0)?["a character's height must be positive"]:[]},prepare(t){return{who:fc({...t.character,height:1}),cylinder:cc(Bp(1,1,16)),sphere:cc(Np(1,20))}},resolve({object:t,prepared:e,values:n,world:i,camera:s,toScreen:o}){const r=t,a=e,l=a.who,c={...yt,...r.pose};for(const[m,y]of n)typeof y=="number"&&!rg.has(m)&&(c[m]=y);const h=r.height??ag,f=ce(s.view,i),u={toView:m=>Qr(f,m),toScreen:m=>o(m)},g=-u.toView([0,h/2,0])[2];if(g<=s.near)return null;const d=r.shadow===!1?[]:[{depth:g+h,draw:m=>lg(m,u,h*.18)}];if(r.look==="solid"){const m=eo(l.plan,c,{height:h,contact:l.contact});return{meshes:hg(r,a,l.plan,m,i),drawables:d}}return{drawables:[...d,{depth:g,draw(m,y){m.lineCap="round",m.lineJoin="round",yc(m,l,c,u,{height:h,time:y.time})}}]}}},kc={x:0,y:0,scale:1,rotate:0,shakeX:0,shakeY:0,shakeRotate:0};function fg(t){const e=n=>{const i=t?.get(n);return typeof i=="number"?i:kc[n]};return{x:e("x"),y:e("y"),scale:e("scale"),rotate:e("rotate"),shakeX:e("shakeX"),shakeY:e("shakeY"),shakeRotate:e("shakeRotate")}}function dg(t,e,n){const i=n.width/2,s=n.height/2,r=1+2*Math.max(Math.abs(e.shakeX),Math.abs(e.shakeY))/Math.max(1,Math.min(n.width,n.height));t.translate(i+e.x+e.shakeX,s+e.y+e.shakeY),t.rotate((e.rotate+e.shakeRotate)*Math.PI/180),t.scale(e.scale*r,e.scale*r),t.translate(-i,-s)}function pg(t,e,n){const i=e.width/2,s=e.height/2,o=(t.rotate+t.shakeRotate)*Math.PI/180,r=(n.x-i)*t.scale,a=(n.y-s)*t.scale;return{x:i+t.x+t.shakeX+r*Math.cos(o)-a*Math.sin(o),y:s+t.y+t.shakeY+r*Math.sin(o)+a*Math.cos(o)}}function vc(t,e,n={},i){const s=n.length??240,o=9,r=28,a=s-22;t.save(),t.translate(e.x,e.y),t.rotate((n.angle??-30)*Math.PI/180),t.fillStyle=n.color??"#f4c542",t.fillRect(r,-o,a-r,2*o),t.fillStyle="#e8b4a0",t.fillRect(a,-o,s-a,2*o),t.fillStyle="#f1dcbf",t.beginPath(),t.moveTo(0,0),t.lineTo(r,-o),t.lineTo(r,o),t.closePath(),t.fill(),t.fillStyle=n.outline??"#2f2f33",t.beginPath(),t.moveTo(0,0),t.lineTo(r*.35,-o*.35),t.lineTo(r*.35,o*.35),t.closePath(),t.fill(),t.strokeStyle=n.outline??"#2f2f33",t.lineWidth=3,t.lineJoin="round",t.lineCap="round";const l=[[{x:0,y:0},{x:r,y:-o},{x:s,y:-o},{x:s,y:o},{x:r,y:o},{x:0,y:0}],[{x:r,y:-o},{x:r,y:o}],[{x:a,y:-o},{x:a,y:o}]];for(const c of l)Tc(t,c,i);t.restore()}function uo(t,e,n={},i){const s=n.length??90,o=n.thickness??34;t.save(),t.translate(e.x,e.y),t.rotate((n.angle??-35)*Math.PI/180);const r=-o/2;t.fillStyle=n.color??"#f4a7b9",t.fillRect(0,r,s,o),t.fillStyle="#e9edf2",t.fillRect(s*.45,r,s*.55,o),t.strokeStyle=n.outline??"#2f2f33",t.lineWidth=3,t.lineJoin="round";const a=[{x:0,y:r},{x:s,y:r},{x:s,y:-r},{x:0,y:-r},{x:0,y:r}],l=[{x:s*.45,y:r},{x:s*.45,y:-r}];if(i)i.line(a),i.line(l);else for(const c of[a,l]){t.beginPath(),t.moveTo(c[0].x,c[0].y);for(const h of c.slice(1))t.lineTo(h.x,h.y);t.stroke()}t.restore()}const Sc=150,gg={pencil:44,eraser:30};function fo(t,e,n={},i){const s=n.tool??"pencil",o=n.skin??"#f1c9a5",r=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=Sc*a*(1+.05*l);l>0&&(t.save(),t.fillStyle=r,t.globalAlpha=.15*l,t.beginPath(),t.ellipse(e.x,e.y,9*a,4*a,0,0,Math.PI*2),t.fill(),t.restore());const u={x:e.x+h.x+6*l*a,y:e.y+h.y-18*l*a},p=bt.pencilGrip,g=x=>{const C=x.fingers.thumb,E=x.fingers.index,H=x.fingers.middle,_=Mc([C.points[3],E.points[3],H.points[3]]),P=Mc([C.points[1],E.points[0]]),L=(C.depths[3]+E.depths[3]+H.depths[3])/3;return{pinch:_,direction:Math.atan2(P.y-_.y,P.x-_.x),depth:L}},d=ii(p,{size:f}),m=c-g(d).direction,y=ii(p,{size:f,angle:m*180/Math.PI}),w=g(y),v=gg[s]*a,T={x:w.pinch.x-Math.cos(c)*v,y:w.pinch.y-Math.sin(c)*v},S={x:u.x-T.x,y:u.y-T.y},A=y.axes.up;mg(t,S,{x:-A.x,y:-A.y},f,n.arm??300*a,o,n.sleeve??"#5b7db1",r),si(t,S,p,{size:f,angle:m*180/Math.PI,skin:o,ink:r,lineWidth:3*a,prop:{depth:w.depth,draw:()=>{t.save(),t.translate(u.x,u.y),t.scale(a,a),s==="eraser"?uo(t,{x:0,y:0},{angle:c*180/Math.PI,outline:r},i):vc(t,{x:0,y:0},{angle:c*180/Math.PI,length:190,outline:r},i),t.restore()}}})}const Mc=t=>({x:t.reduce((e,n)=>e+n.x,0)/t.length,y:t.reduce((e,n)=>e+n.y,0)/t.length});function mg(t,e,n,i,s,o,r,a){const l={x:-n.y,y:n.x},c=i*.15,h=(d,m,y)=>({x:e.x+n.x*d+l.x*m*y,y:e.y+n.y*d+l.y*m*y}),f=h(s,0,0),u=d=>{const m=t.createLinearGradient(e.x,e.y,f.x,f.y);return m.addColorStop(0,d),m.addColorStop(.6,d),m.addColorStop(1,kg(d)),m},p=Math.min(i*.55,s*.35);t.save(),t.lineJoin="round",t.lineCap="round",t.lineWidth=3*(i/Sc),t.beginPath(),t.moveTo(h(-i*.1,-1,c).x,h(-i*.1,-1,c).y),t.lineTo(h(p+4,-1,c*1.1).x,h(p+4,-1,c*1.1).y),t.lineTo(h(p+4,1,c*1.1).x,h(p+4,1,c*1.1).y),t.lineTo(h(-i*.1,1,c).x,h(-i*.1,1,c).y),t.closePath(),t.fillStyle=o,t.fill(),t.strokeStyle=a,t.beginPath(),t.moveTo(h(0,-1,c).x,h(0,-1,c).y),t.lineTo(h(p,-1,c*1.1).x,h(p,-1,c*1.1).y),t.moveTo(h(0,1,c).x,h(0,1,c).y),t.lineTo(h(p,1,c*1.1).x,h(p,1,c*1.1).y),t.stroke();const g=[h(p,-1,c*1.3),h(s,-1,c*1.5),h(s,1,c*1.5),h(p,1,c*1.3)];t.beginPath(),g.forEach((d,m)=>m?t.lineTo(d.x,d.y):t.moveTo(d.x,d.y)),t.closePath(),t.fillStyle=u(r),t.fill(),t.strokeStyle=u(a),t.beginPath(),t.moveTo(g[1].x,g[1].y),t.lineTo(g[0].x,g[0].y),t.lineTo(g[3].x,g[3].y),t.lineTo(g[2].x,g[2].y),t.stroke(),t.restore()}function yg(t,e,n={}){const i=n.offstage??{x:2e3,y:1400},s=n.enter??450,o=n.exit??450,r=n.linger??1500,a=[...t].filter(d=>d.path.length>0).sort((d,m)=>d.start-m.start),l=d=>d.tool??"pencil",c=d=>{const m=Math.min(1,Math.max(0,d));return m*m*(3-2*m)},h=(d,m,y)=>({x:d.x+(m.x-d.x)*y,y:d.y+(m.y-d.y)*y}),f=a.find(d=>e>=d.start&&e<=d.end);if(f){const d=f.end-f.start,m=d>0?(e-f.start)/d:1;return{at:Zn(f.path,m),tool:l(f),lift:0,drawing:!0}}const u=[...a].reverse().find(d=>d.end<e),p=a.find(d=>d.start>e),g=d=>d.path[d.path.length-1];if(u&&p&&p.start-u.end<=r){const d=(e-u.end)/(p.start-u.end),m=d<.5?l(u):l(p);return{at:h(g(u),p.path[0],c(d)),tool:m,lift:Math.sin(Math.PI*d),drawing:!1}}if(p&&p.start-e<=s){const d=1-(p.start-e)/s;return{at:h(i,p.path[0],c(d)),tool:l(p),lift:1-c(d),drawing:!1}}if(u&&e-u.end<=o){const d=(e-u.end)/o;return{at:h(g(u),i,c(d)),tool:l(u),lift:c(d),drawing:!1}}return null}function bg(t,e,n,i=.08,s=32){const o=Math.PI*2*(1+i),r=[];for(let a=0;a<=s;a++){const l=-Math.PI/2+o*a/s;r.push({x:t+Math.cos(l)*n,y:e+Math.sin(l)*n})}return r}function wg(t){const{path:e}=t,n=e.map(a=>a.x),i=e.map(a=>a.y),s=Math.min(...n),o=Math.min(...i),r=t.hand===!1?void 0:t.hand===!0||t.hand===void 0?{}:t.hand;return{type:"custom",x:s,y:o,width:Math.max(1,Math.max(...n)-s),height:Math.max(1,Math.max(...i)-o),props:{draw:0},draw(a,l,c){const h=Math.min(1,Math.max(0,Number(l.props?.draw??0)));a.translate(-s,-o),a.strokeStyle=t.color??"#2f2f33",a.lineWidth=t.lineWidth??5,a.lineCap="round",a.lineJoin="round";const f=t.sketch?Qn(a,t.sketch,c):void 0;h>0&&(f?t.smooth?f.curve(e,h):f.line(e,h):Tc(a,Ce(e,h))),r&&h>0&&h<1&&fo(a,Zn(e,h),r,f)}}}function kg(t){const e=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());if(!e)return"rgba(0, 0, 0, 0)";const n=e[1].length===3?[...e[1]].map(r=>r+r).join(""):e[1],[i,s,o]=[0,2,4].map(r=>parseInt(n.slice(r,r+2),16));return`rgba(${i}, ${s}, ${o}, 0)`}function Tc(t,e,n){if(!(e.length<2)){if(n)return n.line(e);t.beginPath(),t.moveTo(e[0].x,e[0].y);for(const i of e.slice(1))t.lineTo(i.x,i.y);t.stroke()}}const Si=1e5;function vg(t,e,n,i,s=6){const o=[],r=Math.max(1,Math.round(s));for(let a=0;a<=r;a++)o.push({x:a%2===0?t:t+n,y:e+i*a/r});return o}function po(t,e,n,i){if(i<=0||e.length===0)return;const s=Ce(e,i),o=n/2,r=a=>{t.beginPath(),t.rect(-Si,-Si,2*Si,2*Si),a(),t.clip("evenodd")};for(const a of s)r(()=>{t.moveTo(a.x+o,a.y),t.arc(a.x,a.y,o,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*o,u=(c.x-l.x)/h*o;r(()=>{t.moveTo(l.x+f,l.y+u),t.lineTo(c.x+f,c.y+u),t.lineTo(c.x-f,c.y-u),t.lineTo(l.x-f,l.y-u),t.closePath()})}}function Sg(t,e,n,i,s){t.save(),po(t,e,n,i),s(),t.restore()}function Mg(t,e){const n=e.width??40,i=e.hand===!0?{}:e.hand||void 0,s=e.eraser===!1?void 0:e.eraser===!0||e.eraser===void 0?{}:e.eraser;return{...t,props:{...t.props,erase:0},draw(o,r,a){const l=Number(r.props?.erase??0);if(o.save(),po(o,e.path,n,l),t.draw(o,r,a),o.restore(),!s||l<=0||l>=1)return;const c=Zn(e.path,l);i?fo(o,c,{...i,tool:"eraser"}):uo(o,c,s)}}}const Ec={background:"#1e1e2e",gutter:"#6c7086",text:"#cdd6f4",keyword:"#cba6f7",string:"#a6e3a1",number:"#fab387",comment:"#7f849c",highlight:"rgba(249, 226, 175, 0.22)",strike:"#f38ba8",font:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"},Mi=["wipe","fly","blur"],Tg=.0016,Eg=.6,wn=33,Ag=.9,xg=8;function Pg(t){const e={...Ec,...t.theme},n=t.code.replace(/\t/g," ").replace(/\n$/,"").split(`
|
|
54
|
+
`),i=t.fontSize??16,s=(t.lineHeight??1.6)*i,o=(t.charWidth??.6)*i,r=t.padding??12,a=t.lineNumbers===!1?0:(String(n.length).length+2)*o,l=Math.max(1,...n.map(M=>M.length)),c=t.width??r*2+a+l*o,h=r*2+n.length*s,f=t.x+r+a,u=new Set(t.hidden??[]),p=t.language??"plain";if(!Ei.includes(p))throw new Error(`codePanel: ${At("language",p,Ei)}`);const g=n.map(M=>xc(M,p).flatMap(I=>Array.from(I.text,()=>e[I.kind]))),d=new Map,m=[],y=new Map,w=[],v=[],T=M=>{if(!Number.isInteger(M)||M<1||M>n.length)throw new Error(`codePanel: no line ${M} (it has ${n.length})`)},S=(M,...I)=>d.set(M,[...d.get(M)??[],...I]),A=(M,I,k,$,R=300)=>S(M,{time:$.at,value:I},{time:$.at+($.duration??R),value:k,...$.easing?{easing:$.easing}:{}}),x=(M,I,k,$,R,W=300)=>{T(M),A(`line.${M}.${I}`,k,$,R,W)},C=(M,I)=>m.filter(k=>k.line<M&&k.closed<=I).length,E=(M,I,k,$)=>({x:M+k/2,y:I+$/2,left:M,right:M+k,top:I,bottom:I+$,width:k,height:$}),H=M=>t.y+r+(M-1)*s,_=M=>Array.isArray(M)?M:[M],P=(M,I)=>{const k=d.get(M);return k?[...k].sort(($,R)=>$.time-R.time)[k.length-1].value:I},L=(M,I,k)=>{let $=-1;for(let R=0;R<k;R++)if($=n[M-1].indexOf(I,$+1),$<0)throw new Error(`codePanel: line ${M} has no ${k>1?`${k}th `:""}"${I}"`);return $},F={};n.forEach((M,I)=>{const k=I+1;F[`line.${k}.highlight`]=0,F[`line.${k}.strike`]=0,F[`line.${k}.wipe`]=0,F[`line.${k}.reveal`]=u.has(k)?0:1,F[`line.${k}.shift`]=0});const K={type:"custom",x:t.x,y:t.y,width:c,height:h,props:F,about:{kind:"code panel",summary:`${n.length} lines of ${p} code. Its lines and words are places in the scene (line(), token(), spot()); its edits are methods that record tracks (tracks()).`,get props(){return _g(Object.keys(F))},actions:go},draw(M,I){const k=I.props??{},$=B=>Number(k[B]??F[B]),R=r+a,W=B=>r+(B-1)*s-$(`line.${B}.shift`)*s;M.fillStyle=e.background,Ac(M,0,0,c,h,8),M.fill(),M.font=`${i}px ${e.font}`,M.textBaseline="middle",M.textAlign="left";const Q=(B,G,O,N,D)=>{const q=n[B-1];for(let Y=G;Y<O;Y++)q[Y]!==" "&&(M.fillStyle=g[B-1][Y],M.fillText(q[Y],N+(Y-G)*o,D))};M.save(),Ac(M,0,0,c,h,8),M.clip(),n.forEach((B,G)=>{const O=G+1,N=$(`line.${O}.wipe`);if(N>=1)return;const D=W(O),q=D+s/2,Y=Math.max(1,B.length)*o,Z=Math.round($(`line.${O}.reveal`)*B.length),it=y.get(O)??{style:"wipe",from:"left"};M.save(),N>0&&$g(M,it,N,{left:R-a,top:D,width:a+Y+o,height:s},c);const ut=$(`line.${O}.highlight`);ut>0&&(M.globalAlpha*=Math.min(1,ut),M.fillStyle=e.highlight,M.fillRect(R-o/2,D,Y+o,s),M.globalAlpha/=Math.min(1,ut)),a>0&&Z>0&&(M.fillStyle=e.gutter,M.textAlign="right",M.fillText(String(O),R-o,q),M.textAlign="left");const pt=[...w.filter(j=>j.line===O).map(j=>({column:j.column,length:j.text.length,piece:j,insert:void 0})),...v.filter(j=>j.line===O).map(j=>({column:j.column,length:0,piece:void 0,insert:j}))].sort((j,nt)=>j.column-nt.column||j.length-nt.length);let rt=0,U=R;for(const j of pt){Q(O,rt,Math.min(j.column,Z),U,q),U+=(j.column-rt)*o;let nt=j.length,lt="";if(j.piece){const ht=j.piece.written??"",St=$(`piece.${j.piece.id}.write`);ht&&St>0?(lt=ht.slice(0,Math.round(St*ht.length)),nt=j.length+(ht.length-j.length)*Math.min(1,St*2)):nt=j.length*(1-$(`piece.${j.piece.id}.away`))}else j.insert&&(nt=j.insert.chars*$(`insert.${j.insert.id}.open`),j.insert.text&&(lt=j.insert.text.slice(0,Math.round($(`insert.${j.insert.id}.type`)*j.insert.text.length))));M.fillStyle=e.text;for(let ht=0;ht<lt.length;ht++)lt[ht]!==" "&&M.fillText(lt[ht],U+ht*o,q);U+=nt*o,rt=j.column+j.length}Q(O,rt,Math.max(rt,Z),U,q);const z=$(`line.${O}.strike`);z>0&&(M.strokeStyle=e.strike,M.lineWidth=Math.max(1.5,i/10),M.beginPath(),M.moveTo(R,q),M.lineTo(R+Y*Math.min(1,z),q),M.stroke()),M.restore()});for(const B of w){const G=$(`piece.${B.id}.opacity`);if(G<=0||$(`line.${B.line}.wipe`)>=1)continue;const O=R+(B.column+B.text.length/2)*o+$(`piece.${B.id}.x`),N=W(B.line)+s/2+$(`piece.${B.id}.y`);M.save(),M.globalAlpha=Math.min(1,G),M.translate(O,N),M.rotate($(`piece.${B.id}.rotate`)*Math.PI/180),Q(B.line,B.column,B.column+B.text.length,-B.text.length*o/2,0),M.restore()}M.restore()}},V=(M,I)=>({x:M.home.x+kn(d.get(`piece.${M.id}.x`),I),y:M.home.y+kn(d.get(`piece.${M.id}.y`),I)}),ot=(M,I)=>{for(const k of["x","y","rotate"]){const $=`piece.${M.id}.${k}`,R=(d.get($)??[]).filter(W=>W.time<=I);d.set($,R)}},X={target:K,lines:n,box:E(t.x,t.y,c,h),line(M,I=1/0){return T(M),E(f,H(M)-C(M,I)*s,Math.max(1,n[M-1].length)*o,s)},token(M,I,k=1,$=1/0){T(M);const R=L(M,I,k);return E(f+R*o,H(M)-C(M,$)*s,I.length*o,s)},highlight(M,I){for(const k of _(M)){const $=P(`line.${k}.highlight`,0);x(k,"highlight",$,I.on===!1?0:1,I,200)}return X},strike(M,I){for(const k of _(M))x(k,"strike",P(`line.${k}.strike`,0),1,I);return X},remove(M,I){const k=_(M),$=I.style??"wipe";if(!Mi.includes($))throw new Error(`codePanel.remove: ${At("style",$,Mi)}`);const R=$==="wipe"?300:450,W=I.at+(I.duration??R),Q=I.close??250;for(const B of k)x(B,"wipe",0,1,{...I,easing:I.easing??($==="fly"?"ease-in":void 0)},R),y.set(B,{style:$,from:I.from??"left"}),m.push({line:B,closed:W+Q});for(let B=1;B<=n.length;B++){if(k.includes(B))continue;const G=k.filter(N=>N<B).length;if(G===0)continue;const O=P(`line.${B}.shift`,0);x(B,"shift",O,O+G,{at:W,duration:Q,easing:"ease-in-out"})}return X},type(M,I){return x(M,"reveal",0,1,{duration:n[M-1].length*45,...I}),X},piece(M,I,k=1){T(M);const $=L(M,I,k),R=w.find(Q=>Q.line===M&&Q.column===$&&Q.text===I);if(R)return R;if(w.some(Q=>Q.line===M&&$<Q.column+Q.text.length&&Q.column<$+I.length))throw new Error(`codePanel: "${I}" on line ${M} overlaps another piece`);const W={id:w.length+1,line:M,column:$,text:I,home:X.token(M,I,k,0)};w.push(W);for(const Q of["x","y","rotate","write","away"])F[`piece.${W.id}.${Q}`]=0;return F[`piece.${W.id}.opacity`]=1,W},follow(M,I){for(const k of I)S(`piece.${M.id}.x`,{time:k.time,value:k.x-M.home.x}),S(`piece.${M.id}.y`,{time:k.time,value:k.y-M.home.y});return X},fling(M,I){const k=V(M,I.at),$=I.velocity??J(M,I.at)??{x:.5,y:-.6},R=I.gravity??Tg,W=I.duration??900,Q=(I.spin??Eg)*($.x<0?-1:1),B=kn(d.get(`piece.${M.id}.rotate`),I.at);ot(M,I.at);for(let G=0;G<=W;G+=wn){const O=k.x+$.x*G,N=k.y+$.y*G+.5*R*G*G;S(`piece.${M.id}.x`,{time:I.at+G,value:O-M.home.x}),S(`piece.${M.id}.y`,{time:I.at+G,value:N-M.home.y}),S(`piece.${M.id}.rotate`,{time:I.at+G,value:B+Q*G})}return A(`piece.${M.id}.opacity`,1,0,{at:I.at+W*.6,duration:W*.4}),X},move(M,I){const k=V(M,I.at);return A(`piece.${M.id}.x`,k.x-M.home.x,I.to.x-M.home.x,I,400),A(`piece.${M.id}.y`,k.y-M.home.y,I.to.y-M.home.y,I,400),X},write(M,I,k){return M.written=I,A(`piece.${M.id}.write`,0,1,{duration:Math.max(1,I.length)*70,...k}),X},spot(M,I,k=1,$=1/0){T(M);const R=v.filter(W=>W.line===M&&W.column<=I&&W.at<=$).reduce((W,Q)=>W+Q.chars,0);return E(f+(I+R)*o,H(M)-C(M,$)*s,k*o,s)},insert(M,I,k,$){T(M);const R={id:v.length+1,line:M,column:I,chars:k.length,text:k,at:$.at};v.push(R),F[`insert.${R.id}.open`]=0,F[`insert.${R.id}.type`]=0;const W=$.duration??k.length*70;return A(`insert.${R.id}.open`,0,1,{at:$.at,duration:W*.6,easing:"ease-out"}),A(`insert.${R.id}.type`,0,1,{at:$.at,duration:W}),X},drop(M,I,k,$){T(I);const R=$.duration??250,W=I===M.line,Q=$.easing??(W?"linear":"ease-out"),B=X.landing(M,I,k,$.at),G={id:v.length+1,line:I,column:k,chars:M.text.length,at:$.at};return v.push(G),F[`insert.${G.id}.open`]=0,A(`insert.${G.id}.open`,0,1,{at:$.at,duration:R,easing:W?Q:"ease-out"}),A(`piece.${M.id}.away`,P(`piece.${M.id}.away`,0),1,{at:$.at,duration:R,easing:W?Q:"ease-in-out"}),ot(M,$.at),X.move(M,{at:$.at,duration:R,easing:Q,to:{x:B.x,y:B.y}}),A(`piece.${M.id}.rotate`,kn(d.get(`piece.${M.id}.rotate`),$.at),0,{at:$.at,duration:R}),X},landing(M,I,k,$=1/0){const R=X.spot(I,k,M.text.length,$),W=I===M.line&&k>M.column?M.text.length*o:0;return E(R.left-W,R.top,R.width,R.height)},ride(M,I,k){return tt(M,I,k.ground,k.every??wn)},tracks(M){return[...d].filter(([,I])=>I.length>0).map(([I,k])=>({id:`${M}-${I}`,target:M,property:I,keyframes:Ig(k)}))}};function tt(M,I,k,$){const R=n.map((U,z)=>d.get(`line.${z+1}.shift`)??[]);if(R.every(U=>U.length===0))return M;const W=M.find(U=>U.target===I&&U.property==="y"),Q=new le({id:`${I}-ride`,tracks:W?[W]:[]}),B=U=>W?Number(Q.getStateAtTime(U).values.get(I)?.get("y")??0):0,G=U=>{const z=k+B(U);return n.findIndex((j,nt)=>Math.abs(H(nt+1)-z)<.5)},O=(W?.keyframes??[]).map(U=>U.time),N=U=>{const z=St=>St<0?0:-kn(R[St],U)*s,j=G(U);if(j>=0)return z(j);if(Math.abs(B(U))<.5)return 0;const nt=St=>G(St)>=0||Math.abs(B(St))<.5,lt=[...O].reverse().find(St=>St<=U&&nt(St)),ht=O.find(St=>St>=U&&nt(St));return lt===void 0&&ht===void 0?0:lt===void 0?z(G(ht)):ht===void 0||ht===lt?z(G(lt)):z(G(lt))+(z(G(ht))-z(G(lt)))*(U-lt)/(ht-lt)},D=R.flatMap(U=>{const z=[...U].sort((j,nt)=>j.time-nt.time);return z.slice(1).flatMap((j,nt)=>j.value!==z[nt].value?[{start:z[nt].time,end:j.time}]:[])}),q=(U,z)=>D.some(j=>j.start<z&&j.end>U)||N(U)!==N(z),Y=W?[...W.keyframes]:[{time:0,value:0}],Z=[{...Y[0],value:Y[0].value+N(Y[0].time)}],it=(U,z)=>{const j=new Set([z]);for(let nt=U+$;nt<z;nt+=$)j.add(nt);for(const nt of D)for(const lt of[nt.start,nt.end])lt>U&<<z&&j.add(lt);for(const nt of[...j].sort((lt,ht)=>lt-ht))Z.push({time:nt,value:B(nt)+N(nt)})};for(let U=1;U<Y.length;U++){const z=Y[U-1].time,j=Y[U].time;q(z,j)?it(z,j):Z.push({...Y[U],value:Y[U].value+N(j)})}const ut=Y[Y.length-1].time,pt=Math.max(ut,...D.map(U=>U.end));pt>ut&&it(ut,pt);const rt={id:W?.id??`${I}-y`,target:I,property:"y",keyframes:Z};return W?M.map(U=>U===W?rt:U):[...M,rt]}function J(M,I){const k=d.get(`piece.${M.id}.x`);if(!k||k.length<2)return;const $=V(M,I-wn),R=V(M,I);return{x:(R.x-$.x)/wn,y:(R.y-$.y)/wn}}return X}function $g(t,e,n,i,s){if(e.style==="wipe"){t.beginPath(),e.from==="right"?t.rect(i.left,i.top,i.width*(1-n),i.height):t.rect(i.left+n*i.width,i.top,i.width*(1-n),i.height),t.clip();return}const o=xg*n;if(o>.2&&"filter"in t&&(t.filter=`blur(${o.toFixed(1)}px)`),t.globalAlpha*=1-n,e.style==="fly"){const r=e.from==="right"?-1:1;t.translate(r*n*Ag*s,0),t.rotate(r*n*.08)}else{const r=1+.08*n,a=i.left+i.width/2,l=i.top+i.height/2;t.translate(a,l),t.scale(r,r),t.translate(-a,-l)}}function kn(t,e){if(!t||t.length===0)return 0;const n=[...t].sort((i,s)=>i.time-s.time);if(e<=n[0].time)return n[0].value;for(let i=1;i<n.length;i++)if(e<=n[i].time){const s=n[i-1],o=n[i];return o.time===s.time?o.value:s.value+(o.value-s.value)*(e-s.time)/(o.time-s.time)}return n[n.length-1].value}const go={highlight:"highlight(n | n[], { at, duration?, on? }): tint lines (on: false clears)",strike:"strike(n | n[], { at, duration? }): strike lines through, left to right",remove:"remove(n | n[], { at, duration?, style?: wipe | fly | blur, from?: left | right, close? }): take lines away; the lines below close the gap",type:"type(n, { at, duration? }): type in a line given in `hidden`",piece:"piece(n, text, occurrence?): make a word a piece that can come loose (returns it, with its home box)",follow:"follow(piece, path): carry a piece along timed points (handPath() gives a hand’s)",fling:"fling(piece, { at, velocity?, spin?, gravity?, duration? }): throw or kick a piece away on a spinning arc",move:"move(piece, { at, to: { x, y }, duration?, easing? }): move a piece’s centre to a point",write:"write(piece, text, { at, duration? }): type new text into a piece’s place",insert:"insert(n, column, text, { at, duration? }): type new text into a line; the line makes room",drop:"drop(piece, n, column, { at, duration? }): put a piece into a line (into its own line it slides, the text closing behind it)",ride:"ride(tracks, figureId, { ground }): a figure’s tracks with it carried by the line it stands on"};function _g(t){const e=[[/^line\.\d+\.highlight$/,{description:"How much the line is tinted",unit:"0..1",min:0,max:1}],[/^line\.\d+\.strike$/,{description:"How far the strike-through has drawn",unit:"0..1",min:0,max:1}],[/^line\.\d+\.wipe$/,{description:"How far the line has gone (wiped, flown off or blurred)",unit:"0..1",min:0,max:1}],[/^line\.\d+\.reveal$/,{description:"How much of the line is typed in",unit:"0..1",min:0,max:1}],[/^line\.\d+\.shift$/,{description:"How many rows the line has moved up",unit:"rows"}],[/^piece\.\d+\.(x|y)$/,{description:"The piece moved from its home",unit:"px"}],[/^piece\.\d+\.rotate$/,{description:"The piece turned",unit:"degrees"}],[/^piece\.\d+\.opacity$/,{description:"How opaque the piece is",unit:"0..1",min:0,max:1}],[/^piece\.\d+\.write$/,{description:"How much of the text written into its place is typed",unit:"0..1",min:0,max:1}],[/^piece\.\d+\.away$/,{description:"How far its old place has closed",unit:"0..1",min:0,max:1}],[/^insert\.\d+\.open$/,{description:"How much room the insert has opened",unit:"0..1",min:0,max:1}],[/^insert\.\d+\.type$/,{description:"How much of the inserted text is typed",unit:"0..1",min:0,max:1}]],n={};for(const i of t){const s=e.find(([o])=>o.test(i));s&&(n[i]=s[1])}return n}function Ig(t){return[...t].sort((n,i)=>n.time-i.time).map(n=>({time:n.time,value:n.value,...n.easing?{easing:n.easing}:{}}))}function Ac(t,e,n,i,s,o){t.beginPath(),t.moveTo(e+o,n),t.arcTo(e+i,n,e+i,n+s,o),t.arcTo(e+i,n+s,e,n+s,o),t.arcTo(e,n+s,e,n,o),t.arcTo(e,n,e+i,n,o),t.closePath()}const Ti={go:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","nil","true","false"],rust:["as","async","await","break","const","continue","crate","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","unsafe","use","where","while","Some","None","Ok","Err"],csharp:["abstract","async","await","base","bool","break","case","catch","class","const","continue","default","do","else","enum","false","finally","for","foreach","if","in","int","interface","internal","is","namespace","new","null","object","out","override","private","protected","public","readonly","ref","return","sealed","static","string","struct","switch","this","throw","true","try","using","var","virtual","void","while"],javascript:["async","await","break","case","catch","class","const","continue","default","delete","do","else","export","extends","false","finally","for","function","if","import","in","instanceof","let","new","null","of","return","static","super","switch","this","throw","true","try","typeof","undefined","var","void","while","yield"],typescript:[],python:["and","as","assert","async","await","break","class","continue","def","del","elif","else","except","False","finally","for","from","global","if","import","in","is","lambda","None","nonlocal","not","or","pass","raise","return","True","try","while","with","yield"],plain:[]};Ti.typescript=[...Ti.javascript,"enum","interface","type","implements","private","public","readonly","keyof","as","declare","namespace"];const Ei=Object.keys(Ti),Og={go:"//",rust:"//",csharp:"//",javascript:"//",typescript:"//",python:"#",plain:null};function xc(t,e){const n=new Set(Ti[e]),i=Og[e],s=[],o=(a,l)=>{const c=s[s.length-1];c&&c.kind===l?c.text+=a:s.push({text:a,kind:l})};let r=0;for(;r<t.length;){const a=t[r];if(e!=="plain"&&i&&t.startsWith(i,r)){o(t.slice(r),"comment");break}if(e!=="plain"&&(a==='"'||a==="'"||a==="`")){let h=r+1;for(;h<t.length&&t[h]!==a;)h+=t[h]==="\\"?2:1;o(t.slice(r,h+1),"string"),r=h+1;continue}const l=/^[A-Za-z_][A-Za-z0-9_]*/.exec(t.slice(r));if(l){o(l[0],n.has(l[0])?"keyword":"text"),r+=l[0].length;continue}const c=/^\d[\d_.]*/.exec(t.slice(r));if(c&&e!=="plain"){o(c[0],"number"),r+=c[0].length;continue}o(a,"text"),r++}return s}const Pc=40,Hg=.215+.205,Ot=(t,e)=>{const n={};for(const i of["left","right"])for(const[s,o]of Object.entries(e))n[`${t}.${i}.${s}`]=o;return n},st=(t,e)=>t[e]??yt[e]??0;function Cg(t,e,n=yt,i=1){const s=fn(t),o=e*Math.PI*2,r=Math.sin(o)*i,a=Math.cos(o)*i,l=(1+Math.cos(o*2*(s.bounces??1)))/2,c=s.crouch??0,h=s.shoulder??0,f=s.forearm??0,u={...yt,...n};u["leg.left.swing"]=s.swing*r+c*.6,u["leg.right.swing"]=-s.swing*r+c*.6,u["leg.left.knee"]=s.knee*Math.max(0,a)+c*1.2,u["leg.right.knee"]=s.knee*Math.max(0,-a)+c*1.2,u["leg.left.ankle"]=st(n,"leg.left.ankle")-(s.tiptoe??0),u["leg.right.ankle"]=st(n,"leg.right.ankle")-(s.tiptoe??0);for(const[p,g]of[["left",-1],["right",1]])st(n,`arm.${p}.spread`)>Pc||st(n,`arm.${p}.swing`)>Pc||(u[`arm.${p}.swing`]=h+g*s.arm*r,u[`arm.${p}.elbow`]=st(n,`arm.${p}.elbow`)+f+s.elbow*Math.max(0,g*r));return u.lean=st(n,"lean")+s.lean*i,u.bend=st(n,"bend")+(s.bend??0),u["head.nod"]=st(n,"head.nod")-s.lean*.5*i+(s.headTilt??0),u.side=st(n,"side")+(s.sway??0)*Math.sin(o),u.lift=st(n,"lift")+(s.bounce??0)*i*l,u.stretch=st(n,"stretch")*(1+(s.squash??0)*(l-.5)),u}function Rg(t,e,n=1){const i=fn(t);return 4*Hg*e*Math.sin(i.swing*n*Math.PI/180)}const Ne=t=>zs[t],mo={take:t=>[{after:140,pose:{stretch:.8,bend:10,lean:st(t,"lean")-4,...Ot("arm",{spread:6,swing:0,elbow:10}),"eye.left":.35,"eye.right":.35,"brow.left":-.6,"brow.right":-.6,mouth:0},easing:"ease-in-out"},{after:260,pose:{stretch:.78}},{after:360,pose:{lift:.22,stretch:1.35,bend:-14,...Ot("arm",{spread:150,bend:35,swing:0,elbow:0}),...Ot("leg",{swing:25,knee:60}),...Ne("shocked")},easing:"ease-out-cubic"},{after:720,pose:{lift:.25,stretch:1.25,bend:-10,...Ot("arm",{spread:140})},easing:"ease-in-out"},{after:900,pose:{lift:0,stretch:.74,bend:12,...Ot("arm",{spread:70,bend:0}),...Ot("leg",{swing:30,knee:60})},easing:"ease-in-quad"},{after:1060,pose:{stretch:1.06,bend:-3,...Ot("arm",{spread:60}),"leg.left.swing":st(t,"leg.left.swing"),"leg.right.swing":st(t,"leg.right.swing"),"leg.left.knee":st(t,"leg.left.knee"),"leg.right.knee":st(t,"leg.right.knee")},easing:"ease-out"},{after:1260,pose:{stretch:st(t,"stretch"),bend:st(t,"bend"),...Ne("surprised"),...Ot("arm",{spread:55,bend:60})},easing:"ease-in-out"}],doubleTake:t=>[{after:160,pose:{lookX:1,lookY:0,"head.turn":0},easing:"ease-out"},{after:520,pose:{lookX:-.6,"head.turn":30,"head.nod":st(t,"head.nod")-4,smile:.6,mouth:0},easing:"ease-in-out"},{after:1100,pose:{lookX:-.6}},{after:1180,pose:{"head.turn":0,"head.nod":st(t,"head.nod")-10,bend:st(t,"bend")-10,lift:.05,stretch:1.18,...Ne("shocked"),lookX:1,lookY:0},easing:"ease-out-cubic"},{after:1360,pose:{lift:0,stretch:.88,"head.nod":st(t,"head.nod")-4,bend:st(t,"bend")+4},easing:"ease-in-quad"},{after:1560,pose:{stretch:st(t,"stretch"),"head.nod":st(t,"head.nod"),bend:st(t,"bend")},easing:{type:"elastic",mode:"out",amplitude:1,period:.35}}],windUp:()=>[{after:220,pose:{lean:-18,bend:-16,"head.nod":-6,"arm.left.swing":60,"arm.left.elbow":100,"arm.right.swing":-40,"arm.right.elbow":90,"leg.left.swing":55,"leg.left.knee":95,stretch:.92,...Ne("angry"),lookX:1},easing:"ease-out"},{after:620,pose:{lean:-20,bend:-18,stretch:.9}},{after:700,pose:{lean:28,bend:14,"head.nod":6,"arm.left.swing":-30,"arm.right.swing":60,"leg.left.swing":-20,"leg.left.knee":30,"leg.right.swing":20,stretch:1.12},easing:"ease-out-cubic"}],land:t=>[{after:120,pose:{lift:0,stretch:.7,bend:14,...Ot("arm",{spread:75}),...Ot("leg",{swing:25,knee:50})},easing:"ease-in-quad"},{after:300,pose:{stretch:1.05,bend:-4,"arm.left.spread":st(t,"arm.left.spread"),"arm.right.spread":st(t,"arm.right.spread")},easing:"ease-out"},{after:460,pose:{lift:0,stretch:st(t,"stretch"),bend:st(t,"bend"),...Ot("leg",{swing:0,knee:0})},easing:"ease-in-out"}],tremble:t=>{const e=[{after:80,pose:{...Ne("scared"),...Ot("arm",{swing:40,elbow:110,spread:14}),stretch:.94,bend:st(t,"bend")+8},easing:"ease-out"}];for(let n=1;n<=14;n++){const i=n%2===0?1:-1;e.push({after:80+n*45,pose:{side:st(t,"side")+2.5*i,"head.tilt":st(t,"head.tilt")-2*i}})}return e.push({after:755,pose:{side:st(t,"side"),"head.tilt":st(t,"head.tilt"),bend:st(t,"bend")}}),e},deflate:t=>[{after:260,pose:{stretch:1.04,"head.nod":st(t,"head.nod")-4,"brow.left":.3,"brow.right":.3},easing:"ease-in-out"},{after:900,pose:{...Ne("sad"),bend:18,stretch:.92,lean:st(t,"lean")+5,"head.nod":14,...Ot("arm",{spread:6,swing:0,elbow:4,bend:0})},easing:"ease-in-out"}]};function Lg(t,e){const n=It(e.from??{}),i=e.speed??1;let s=n;return[{time:e.at,pose:n},...mo[t](n).map(o=>(s={...s,...o.pose},{time:e.at+o.after*i,pose:s,act:!1,...o.easing?{easing:o.easing}:{}}))]}const Fg=(t,e,n)=>t.slice(Math.floor((t.length-1)*e),Math.ceil((t.length-1)*n)+1);function Dg(t={}){const e=t.shirt??"#e2493b",n=t.trousers??"#24476b",i=a=>a.lineWidth*.45,s=(a,l,c)=>{const h=a.parts[`leg.${c}`].points;l.shape(cn(h,a.height*.08,a.height*.05),n,i(a))},o=(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(cn([u,...a.parts.spine.points],a.height*.15,a.height*.14),e,i(a))},r=(a,l,c)=>{const h=a.parts[`arm.${c}`].points,f=h[0],u=a.chains.spine[a.chains.spine.length-1],g=[{x:f.x+(u.x-f.x)*.45,y:f.y+(u.y-f.y)*.45},...Fg(h,0,.45)],d=cn(g,a.height*.085,a.height*.06),m=g.length,y=d.slice(0,m),w=d.slice(m).reverse();l.shape(d,e,0);const v=A=>Math.hypot(A[1].x-u.x,A[1].y-u.y),[T,S]=v(y)>v(w)?[y,w]:[w,y];l.line(T.slice(1),i(a)),l.line(S.slice(Math.ceil(m*.45)),i(a)),l.line([y[m-1],w[m-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)=>o(l,c)},"arm.left":{over:(a,l,c)=>r(l,c,"left")},"arm.right":{over:(a,l,c)=>r(l,c,"right")}}}}const ge={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 $c(t){if(t===void 0)return ge.full;if(typeof t=="string")return ge[t];const{base:e,...n}=t;return{...ge[e??"full"],...n}}const yo=160,Ng=120,Bg=700,bo=60,Wg=90,Ai=3200,Be=1,me=1e-6;function wo(t,e,n={}){const i=$c(n.style),s=n.seed??1,o={};if(t.length===0)return o;const r=Object.keys(t[0].pose).filter(f=>t.some(u=>Math.abs(u.pose[f]-t[0].pose[f])>me));for(const f of r)o[f]=Kg(f,t,e,i,s);const a=e.blink,l=a!==void 0&&r.includes(a);if(i.blinks&&a!==void 0&&!l&&a in t[0].pose){const f=Yg(t,e,i,s,t[0].pose[a]);f.length>0&&(o[a]=f)}const{lift:c,stretch:h}=e;if(i.jumpSquash>0&&c&&h&&r.includes(c)&&!r.includes(h)&&h in t[0].pose){const f=jg(t,c,t[0].pose[h],i.jumpSquash);f.length>0&&(o[h]=f)}return o}function Kg(t,e,n,i,s){const o=n.eyes.includes(t),r=n.limits[t],a=r!==void 0,l=o?-i.eyeLead:(n.depth[t]??1)*i.overlap,c=p=>{const g=(e[p].time-e[p-1].time)/2;return Math.max(-g,Math.min(g,l))},h=[{time:e[0].time,value:e[0].pose[t]}],f=(p,g,d)=>{const m=h[h.length-1];if(p<=m.time+Be){h[h.length-1]={...m,value:g,...d?{easing:d}:{}};return}h.push({time:p,value:g,...d?{easing:d}:{}})};let u=e[0].pose[t];for(let p=1;p<e.length;p++){const g=e[p],d=e[p-1].pose[t],m=g.pose[t],y=m-d,w=h[h.length-1].time,v=g.act!==!1;if(Math.abs(y)<=me){const _=g.time+(v?c(p):0);if(p===e.length-1)Math.abs(u-m)>me&&f(Math.max(_,w+yo),m,"ease-in-out"),u=m;else if(v&&a&&i.drift>0&&n.drift.includes(t)&&_-w>=Bg){const P=Pe(`${s}:${t}:${p}`)%2===0?1:-1;u=m+P*i.drift*r,f(_,u,"ease-in-out")}continue}if(!v){f(e[p-1].time,u),f(g.time,m,g.easing),u=m;continue}const T=c(p),S=Math.max(e[p-1].time+T,w);let A=g.time+T;o&&i.eyeDart>0&&(A=Math.min(A,S+i.eyeDart));const x=A-S;if(x<=Be){f(g.time,m,g.easing),u=m;continue}f(S,u);const C=Math.sign(y);if(a&&i.anticipation>0&&r>0&&x>=yo){const _=u-C*Math.min(Math.abs(y)*i.anticipation,r),P=S+x*i.anticipationTime;f(P,_,"ease-in-out"),i.hold>0&&f(P+x*i.hold,_)}const E=p+1<e.length?e[p+1].time-g.time:1/0,H=Math.min(i.settle,E/2);if(a&&i.overshoot>0&&r>0&&x>=Ng&&H>Be){const _=Math.min(Math.abs(y)*i.overshoot,r);f(A,m+C*_,g.easing??i.actionEase),f(A+H,m,i.settleEase)}else f(A,m,g.easing??i.actionEase);u=m}return h}function Yg(t,e,n,i,s){const o=[],r=bo+Wg;for(let p=1;p<t.length;p++){const g=t[p-1].pose,d=t[p].pose;Object.entries(e.headTurns).some(([y,w])=>Math.abs((d[y]??0)-(g[y]??0))>w)&&t[p].act!==!1&&o.push(Math.max(t[0].time,t[p-1].time-n.eyeLead))}const a=t[0].time,l=t[t.length-1].time,c=[...o];let h=a+Ai*.6,f=0;for(;h<l;){c.some(d=>Math.abs(d-h)<Ai/2)||o.push(h);const g=(Pe(`${i}:blink:${f++}`)%1e3/1e3-.5)*(Ai*.66);h+=Ai+g}o.sort((p,g)=>p-g);const u=[{time:a,value:s}];for(const p of o){const g=u[u.length-1].time;p+bo<=g+Be||(p>g+Be&&u.push({time:p,value:s}),u.push({time:p+bo,value:1,easing:"ease-in"}),u.push({time:p+r,value:s,easing:"ease-out"}))}return u.length>1?u:[]}function jg(t,e,n,i){const s=n*(1-.18*i),o=n*(1+.14*i),r=[{time:t[0].time,value:n}],a=(l,c,h)=>{const f=r[r.length-1];l<=f.time+Be||r.push({time:l,value:c,...h?{easing:h}:{}})};for(let l=1;l<t.length;l++){const c=t[l-1].pose[e],h=t[l].pose[e],f=t[l-1].time,u=t[l].time,p=u-f;if(!(p<yo||t[l].act===!1)){if(c<=me&&h>me)a(f,n),a(f+p*.2,s,"ease-out"),a(f+p*.45,o,"ease-out"),a(u,n,"ease-in-out");else if(c>me&&h<=me){const g=l+1<t.length?t[l+1].time-u:400;a(f+p*.5,n),a(u-Math.min(60,p*.15),o,"ease-in"),a(u,s,"ease-out"),a(u+Math.min(260,g/2),n,{type:"back",mode:"out",overshoot:1.4})}}}return r.length>1?r:[]}const _c={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 Xg(t){return/^(turn|lean|bend|side|lift|roll|stretch)$/.test(t)?{depth:0,limit:{turn:.06,lean:10,bend:10,side:8,lift:0,roll:25,stretch:.08}[t]}:/^leg\.\w+\.(swing|spread|rotate)$/.test(t)?{depth:0,limit:12}:/^head\./.test(t)?{depth:1,limit:12}:/^arm\.\w+\.(swing|spread)$/.test(t)?{depth:1,limit:20}:/^leg\.\w+\.knee$/.test(t)?{depth:1,limit:15}:/^(brow\.|browTilt$)/.test(t)?{depth:1,limit:t==="browTilt"?void 0:.25}:/^eye\./.test(t)?{depth:1,limit:.15}:/^arm\.\w+\.(elbow|bend)$/.test(t)?{depth:2,limit:18}:/^leg\.\w+\.(ankle|toeOut)$/.test(t)?{depth:2,limit:10}:/^(mouth|smile|mouthWidth)$/.test(t)?{depth:2}:/^hand\./.test(t)?{depth:3}:{depth:1}}function qg(){const t={},e={};for(const n of Object.keys(yt)){const i=Xg(n);t[n]=i.depth,i.limit!==void 0&&(e[n]=i.limit)}return{depth:t,limits:e,eyes:["lookX","lookY"],blink:"blink",headTurns:{turn:.15,"head.turn":15,"head.nod":12,lookX:.5,roll:45},drift:["lean","bend","head.tilt","head.nod","arm.left.spread","arm.right.spread","arm.left.elbow","arm.right.elbow"],lift:"lift",stretch:"stretch"}}const Ic=qg();function Oc(t,e){return Object.entries(e).map(([n,i])=>({id:`${t}-${n}`,target:t,property:n,keyframes:i}))}function Hc(t,e,n={}){const i=Ys(e),s=e.map((o,r)=>({time:o.time,pose:{...i[r]},easing:o.easing,act:o.act}));return Oc(t,wo(s,n.rig??_c,n))}function Ug(t,e,n={}){const i=n.rest??yt,s=ho(e,i),o=e.map((r,a)=>({time:r.time,pose:{...i,...s[a]},easing:r.easing,act:r.act}));return Oc(t,wo(o,n.rig??Ic,n))}const Cc=ct.shocked,Vg=ct.scared,oe={take:t=>[{after:140,pose:{stretch:.8,bend:10,lean:t.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,...Cc,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:t.leftHip,rightHip:t.rightHip,leftKnee:t.leftKnee,rightKnee:t.rightKnee},easing:"ease-out"},{after:1260,pose:{stretch:t.stretch,bend:t.bend,...ct.surprised,leftShoulder:70,rightShoulder:70,leftElbow:60,rightElbow:60},easing:"ease-in-out"}],doubleTake:t=>[{after:160,pose:{lookX:1,lookY:0},easing:"ease-out"},{after:520,pose:{lookX:-.6,headTilt:t.headTilt-4,smile:.6,mouth:0},easing:"ease-in-out"},{after:1100,pose:{lookX:-.6}},{after:1180,pose:{bend:t.bend-10,headTilt:t.headTilt+10,rise:.05,stretch:1.18,...Cc,lookX:1,lookY:0},easing:"ease-out-cubic"},{after:1360,pose:{rise:0,stretch:.88,bend:t.bend+4,headTilt:t.headTilt+4},easing:"ease-in-quad"},{after:1560,pose:{stretch:t.stretch,bend:t.bend,headTilt:t.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,...ct.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:t=>[{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:t.leftShoulder,rightShoulder:t.rightShoulder},easing:"ease-out"},{after:460,pose:{rise:0,stretch:t.stretch,bend:t.bend,leftHip:et.leftHip,rightHip:et.rightHip,leftKnee:0,rightKnee:0},easing:"ease-in-out"}],tremble:t=>{const e=[{after:80,pose:{...Vg,bend:t.bend+8,leftShoulder:40,rightShoulder:40,leftElbow:110,rightElbow:110,stretch:.94},easing:"ease-out"}];for(let n=1;n<=14;n++)e.push({after:80+n*45,pose:{lean:t.lean+(n%2===0?2.5:-2.5),headTilt:t.headTilt+(n%2===0?-2:2)}});return e.push({after:755,pose:{lean:t.lean,headTilt:t.headTilt,bend:t.bend}}),e},deflate:t=>[{after:260,pose:{stretch:1.04,headTilt:t.headTilt+4,leftBrow:.3,rightBrow:.3},easing:"ease-in-out"},{after:900,pose:{..._t.sad,bend:18,stretch:.92,lean:t.lean+5,turn:t.turn,sit:t.sit},easing:"ease-in-out"}]};function ko(t,e){const n=typeof e.from=="string"?_t[e.from]:e.from??et;return vo(oe[t](n),{...e,from:n})}function vo(t,e){const n=e.speed??1;let i=e.from;return[{time:e.at,pose:e.from},...t.map(s=>(i={...i,...s.pose},{time:e.at+s.after*n,pose:i,act:!1,...s.easing?{easing:s.easing}:{}}))]}function vn(t,e=1){const n=oe[t](et);return n[n.length-1].after*e}function Rc(t,e,n={}){if(e.length<2)return;const i=Math.max(1,Math.round(n.lines??3)),s=n.spacing??5,o=n.lineWidth??2,r=n.opacity??.7;t.save(),t.strokeStyle=n.color??"#222",t.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)*(e.length/6));for(let h=c+1;h<e.length;h++){const f=e[h-1],u=e[h],p=u.x-f.x,g=u.y-f.y,d=Math.hypot(p,g)||1,m=-g/d,y=p/d,w=1-h/(e.length-1);t.globalAlpha=r*(1-w),t.lineWidth=o*(1-w*.7),t.beginPath(),t.moveTo(f.x+m*l,f.y+y*l),t.lineTo(u.x+m*l,u.y+y*l),t.stroke()}}t.restore()}const Gg={hands:[{name:"left hand",at:t=>t.hands.left},{name:"right hand",at:t=>t.hands.right}],toes:[{name:"left toe",at:t=>t.toes.left},{name:"right toe",at:t=>t.toes.right}],head:[{name:"head",at:t=>t.head.center}],body:[{name:"hip",at:t=>t.hip},{name:"neck",at:t=>t.neck}]};function zg(t,e,n,i,s={}){const o=n.stateAt;if(!o)return;const r=s.length??120,a=Math.max(2,Math.round(s.samples??8)),l=Math.max(0,n.time-r);if(n.time-l<1)return;const c=[];for(let p=0;p<a;p++){const g=l+(n.time-l)*p/(a-1);c.push(Ks(e,{time:g,state:o(g)},i).joints)}const h=c[c.length-1].height,f=(s.threshold??1.2)*h,u=(s.parts??["hands","toes","head"]).flatMap(p=>Gg[p]);for(const p of u){const g=c.map(p.at);let d=0;for(let w=1;w<g.length;w++)d+=Math.hypot(g[w].x-g[w-1].x,g[w].y-g[w-1].y);const m=d/((n.time-l)/1e3);if(m<=f)continue;const y=Math.min(1,(m-f)/(f*.5));Rc(t,g,{...s,opacity:(s.opacity??.7)*y,spacing:s.spacing??h*.02})}}function Jg(t,e,n,i={}){if(n<=0||n>=1)return;const s=i.size??40,o=i.seed??1,r=.45+.55*(1-(1-n)**3);t.save(),t.strokeStyle=i.color??"#555",t.lineWidth=Math.max(1,s*.03),t.globalAlpha=Math.min(1,n/.08)*(1-n);for(let a=0;a<5;a++){const l=Pe(`${o}:puff:${a}`)%1e3/1e3,c=a-2,h=e.x+c*s*.3*r,f=e.y-s*(.06+.12*l)*r+Math.abs(c)*s*.03,u=s*(.11+.07*l)*r;t.beginPath(),t.arc(h,f,u,Math.PI*.95,Math.PI*2.05),t.stroke()}t.restore()}function Zg(t,e,n,i={}){if(n<=0||n>=1)return;const s=i.size??40,o=5,r=1-(1-n)**2;t.save(),t.strokeStyle=i.color??"#222",t.lineWidth=Math.max(1,s*.035),t.lineJoin="round",t.globalAlpha=n<.7?1:(1-n)/.3;for(let a=0;a<o;a++){const l=-Math.PI/2+(a-(o-1)/2)*Math.PI/(o+1),c=s*(.3+.7*r),h=e.x+Math.cos(l)*c,f=e.y+Math.sin(l)*c;Qg(t,h,f,s*.14,n*Math.PI+a),t.stroke()}t.restore()}function Qg(t,e,n,i,s){t.beginPath();for(let o=0;o<10;o++){const r=o%2===0?i:i*.45,a=s+o*Math.PI/5-Math.PI/2,l=e+Math.cos(a)*r,c=n+Math.sin(a)*r;o===0?t.moveTo(l,c):t.lineTo(l,c)}t.closePath()}const re={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}},Sn=1,xi=.55,Lc=.35,tm=1.6,Fc={a:"a",e:"e",i:"i",y:"i",o:"o",u:"u"},Dc={m:"m",b:"m",p:"m",f:"f",v:"f",w:"u",q:"u",l:"l",n:"l",d:"l",t:"l"},Nc={अ:"a",आ:"a",इ:"i",ई:"i",उ:"u",ऊ:"u",ऋ:"i",ए:"e",ऐ:"e",ओ:"o",औ:"o",ऍ:"e",ऑ:"o"},Bc={"ा":"a","ि":"i","ी":"i","ु":"u","ू":"u","ृ":"i","े":"e","ै":"e","ो":"o","ौ":"o","ॅ":"e","ॉ":"o"},em={प:"m",फ:"m",ब:"m",भ:"m",म:"m",व:"u"},nm="्",Wc="़",im=t=>t>="क"&&t<="ह",Kc=new Set([".",",","!","?",";",":","…","।","॥","—","-"]);function Yc(t){const e=[],n=Array.from(t.toLowerCase()),i=(s,o)=>{const r=e[e.length-1];r&&r.viseme===s?r.weight+=o*.5:e.push({viseme:s,weight:o})};for(let s=0;s<n.length;s++){const o=n[s],r=n[s+1];if(Kc.has(o))i("rest",tm);else if(/\s/.test(o)){const a=e[e.length-1];a&&a.viseme!=="rest"&&e.push({viseme:"c",weight:Lc})}else if((o==="o"||o==="e")&&r===o)i(o==="o"?"u":"i",Sn),s++;else if(o in Fc)i(Fc[o],Sn);else if(o in Dc)i(Dc[o],xi);else{if(o==="h")continue;if(/[a-z]/.test(o))i("c",xi);else if(o in Nc)i(Nc[o],Sn);else if(im(o)){const a=r===Wc?o==="फ"?"f":void 0:em[o];i(a??"c",xi);let l=s+1;n[l]===Wc&&l++;const c=n[l];c===nm?s=l:c&&c in Bc?(i(Bc[c],Sn),s=l):(!c||/\s/.test(c)||Kc.has(c)||i("a",Sn*.6),s=l-1)}else(o==="ं"||o==="ँ")&&i("l",xi*.6)}}for(;e.length>0&&(e[e.length-1].viseme==="rest"||e[e.length-1].weight===Lc);)e.pop();return e}function So(t,e={}){const n=e.fields?.mouth??"mouth",i=e.fields?.mouthWidth??"mouthWidth",s=e.energy??1,o=Yc(t.text),r=[{time:t.start,value:re.rest.mouth}],a=[{time:t.start,value:re.rest.mouthWidth}],l=o.reduce((h,f)=>h+f.weight,0),c=t.end-t.start;if(l>0&&c>0){let h=t.start;for(const f of o){const u=c*f.weight/l,p=h+Math.min(u*.4,60);if(p>r[r.length-1].time){const g=re[f.viseme];r.push({time:p,value:g.mouth*s,easing:"ease-out"}),a.push({time:p,value:1+(g.mouthWidth-1)*Math.min(1.3,s),easing:"ease-out"})}h+=u}}return t.end>r[r.length-1].time&&(r.push({time:t.end,value:re.rest.mouth,easing:"ease-in-out"}),a.push({time:t.end,value:re.rest.mouthWidth,easing:"ease-in-out"})),{[n]:r,[i]:a}}function sm(t,e,n={}){const i={};for(const s of[...e].sort((o,r)=>o.start-r.start))for(const[o,r]of Object.entries(So(s,n))){const a=i[o]??=[],l=a.length>0?a[a.length-1].time:-1/0;a.push(...r.filter(c=>c.time>l))}return Object.entries(i).map(([s,o])=>({id:`${t}-${s}`,target:t,property:s,keyframes:o}))}function jc(t,e,n,i={}){if(n.length===0)return e;const s=i.fields?.mouth??"mouth",o=i.fields?.mouthWidth??"mouthWidth",r={[s]:re.rest.mouth,[o]:re.rest.mouthWidth,...i.rest},a=new le({id:"before-speech",tracks:e}),l=(f,u)=>a.getStateAtTime(u).values.get(t)?.get(f)??r[f],c=[s,o],h=e.filter(f=>f.target!==t||!c.includes(f.property));for(const f of c){const u=e.find(g=>g.target===t&&g.property===f);let p=u?[...u.keyframes]:[{time:0,value:l(f,0)}];for(const g of n){const d=So(g,i)[f];d[0]={...d[0],value:l(f,g.start)},d[d.length-1]={...d[d.length-1],value:l(f,g.end)},p=[...p.filter(m=>m.time<g.start||m.time>g.end),...d],p.sort((m,y)=>m.time-y.time)}h.push({id:u?.id??`${t}-${f}`,target:t,property:f,keyframes:p})}return h}const Mn={look:{summary:"Turns the head and eyes toward a scene x, `viewer`, `ahead` or `back`.",uses:["toward"]},face:{summary:"Turns the whole figure toward a scene x (turning round if needed), `viewer`, `ahead` or `back`.",uses:["toward"]},say:{summary:"Lip-syncs the `say` line with small nods; the beat lasts as long as the line.",needs:["say"]},hold:{summary:"Holds the pose (the acting pass drifts long holds)."},stand:{summary:"Back to its resting stance (a character’s own, else the rest pose), keeping the way it is turned."},go:{summary:"Walks to `to` in its own gait (a character’s, else walk).",needs:["to"]},zip:{summary:"The cartoon exit: winds up, wheels its legs in place, then shoots off to `to`, leaving dust.",needs:["to"]},leap:{summary:"Crouches, springs, arcs and lands squashed at `to`, on the floor `onto` (a scene y).",uses:["to","onto"]},swipe:{summary:"Winds an arm up, then slides along the target with the arm out so the hand crosses it edge to edge.",uses:["target"]},grab:{summary:"Steps to where its arm reaches the target (crouching for low things), takes it and lifts it overhead.",needs:["target"]},throw:{summary:"Winds the arm back and throws forward and up toward `to` (or the target); `release` is when it lets go.",uses:["to","target"]},kick:{summary:"Steps to a leg’s length from the target, draws the leg back and kicks through it.",needs:["target"]},put:{summary:"Steps to where its arm reaches the spot and sets the thing down there.",needs:["target"]},write:{summary:"Reaches a pen to the spot and writes along it left to right (moving along when it is wide).",needs:["target"]},push:{summary:"Sets both hands on the target’s near side and walks it along until its centre is at `to`.",needs:["target","to"]}};function Mo(t={}){return[...Object.keys($t),...Object.keys(_t),...Object.keys(oe),...Object.keys(Mn),...Object.keys(t.gaits??{}),...Object.keys(t.actions??{})]}function To(t={}){const e=new Set(Mo()),n=[];for(const i of[...Object.keys(t.actions??{}),...Object.keys(t.gaits??{})])e.has(i)&&n.push(`Custom action or gait "${i}" has the name of a built-in one; give it its own name.`);for(const i of Object.keys(t.actions??{}))t.gaits&&i in t.gaits&&n.push(`"${i}" is both a custom action and a custom gait.`);return n}function Eo(t={}){const e={};for(const n of Object.keys($t))e[n]=`Walks to \`to\` in the ${n} gait, feet planted, turning round first if needed.`;for(const n of Object.keys(_t))e[n]=`Moves into the ${n} pose and holds it.`;for(const n of Object.keys(oe))e[n]=`The ${n} gag, built on the current pose.`;for(const[n,i]of Object.entries(Mn))e[n]=i.summary;for(const[n,i]of Object.entries(t.gaits??{}))e[n]=i.summary??`Walks to \`to\` in the ${n} gait (custom).`;for(const[n,i]of Object.entries(t.actions??{}))e[n]=i.summary;return e}const Pi=["do","at","for","to","toward","mood","say","pose","target","onto"],om={action:"do",type:"do",verb:"do",time:"at",start:"at",delay:"at",duration:"for",length:"for",ms:"for",x:"to",position:"to",destination:"to",expression:"mood",emotion:"mood",face:"mood",feeling:"mood",text:"say",line:"say",speech:"say",dialogue:"say",joints:"pose",y:"onto",floor:"onto",ground:"onto",object:"target",at_target:"target"},$i=["viewer","ahead","back"],ye=t=>typeof t=="number"&&Number.isFinite(t);function Ao(t,e={}){const n=To(e).map(l=>({level:"error",beat:-1,message:l}));if(!Array.isArray(t))return[...n,{level:"error",beat:-1,message:`Beats must be an array of { do: … } objects (got ${typeof t}).`}];const i=Mo(e),s=l=>l in $t||l in(e.gaits??{}),o=Object.keys(ct),r=Object.keys(et);let a=-1/0;return t.forEach((l,c)=>{const h=d=>n.push({level:"error",beat:c,message:d}),f=d=>n.push({level:"warning",beat:c,message:d});if(!l||typeof l!="object"||Array.isArray(l)){h(`Each beat must be an object like { do: 'walk', to: 400 } (got ${JSON.stringify(l)}).`);return}const u=l;for(const d of Object.keys(u))Pi.includes(d)||h(At("beat field",d,Pi,om[d.toLowerCase()]));const p=u.do;if(p===void 0){h(`A beat needs \`do\` (what happens). Actions: ${i.join(", ")}`);return}if(typeof p!="string"||!i.includes(p)){h(At("action",p,i));return}const g=Mn[p]??e.actions?.[p];for(const d of g?.needs??[])u[d]===void 0&&h(`\`${p}\` needs \`${d}\`.`);if(s(p)&&u.to===void 0&&f(`\`${p}\` without \`to\` walks nowhere.`),p==="leap"&&u.to===void 0&&u.onto===void 0&&f("`leap` without `to` or `onto` jumps on the spot."),u.mood!==void 0&&(typeof u.mood!="string"||!o.includes(u.mood))&&h(At("mood",u.mood,o)),u.pose!==void 0)if(!u.pose||typeof u.pose!="object"||Array.isArray(u.pose))h("`pose` is joints to change, an object like { rightShoulder: 90 } (for a named pose, use it as the action).");else for(const[d,m]of Object.entries(u.pose))r.includes(d)?ye(m)||h(`Pose joint \`${d}\` must be a number (got ${JSON.stringify(m)}).`):h(At("pose joint",d,r));for(const d of["at","for"]){const m=u[d];m!==void 0&&!(ye(m)&&m>=0)&&h(`\`${d}\` is milliseconds, a number ≥ 0 (got ${JSON.stringify(m)}).`)}ye(u.at)&&(u.at<a&&f(`\`at\` ${u.at} is before an earlier beat's \`at\` (${a}); beats run in order, so it starts when the one before ends.`),a=u.at);for(const d of["to","onto"]){const m=u[d];m!==void 0&&!ye(m)&&h(`\`${d}\` is a scene ${d==="to"?"x":"y"} in px, a number (got ${JSON.stringify(m)}).`)}if(u.toward!==void 0&&!ye(u.toward)&&!$i.includes(u.toward)&&h(`\`toward\` is a scene x or one of ${$i.join(", ")}${typeof u.toward=="string"&&Nn(u.toward,$i)?` (did you mean "${Nn(u.toward,$i)}"?)`:""} (got ${JSON.stringify(u.toward)}).`),u.say!==void 0&&typeof u.say!="string"&&h(`\`say\` is the line spoken, a string (got ${JSON.stringify(u.say)}).`),u.target!==void 0){const d=u.target;(!d||typeof d!="object"||!ye(d.x)||!ye(d.y))&&h("`target` is a point or box in scene px: { x, y } (a code panel’s line(), token() or spot() fits).")}}),n}function xo(t,e={},n="scriptTracks"){const i=Ao(t,e).filter(s=>s.level==="error");if(i.length!==0)throw new Error(`${n}: ${i.length} problem(s) in the beats:
|
|
55
|
+
${i.map(s=>` ${s.beat>=0?`beat ${s.beat}: `:""}${s.message}`).join(`
|
|
56
|
+
`)}`)}Wd(Eo);function rm(t){const e="steps"in t&&typeof t.steps=="function",n="beats"in t&&typeof t.beats=="function";if(e===n)throw new Error("defineAction: give either `steps: (from, beat) => [...]` or `beats: (beat) => [...]`");if(!t.summary)throw new Error("defineAction: give a `summary`: one line on what the figure does");return t}function am(t){for(const e of["swing","knee","arm","elbow","lean"])if(typeof t[e]!="number")throw new Error(`defineGait: \`${e}\` must be a number (degrees)`);if(t.cycle!==void 0&&!(t.cycle>0))throw new Error("defineGait: `cycle` is ms per two steps, above 0");return t}const Xc=8;function Po(t,e={},n=0){if(n>Xc)throw new Error(`scriptTracks: custom actions nest more than ${Xc} deep (does one build itself?)`);return t.flatMap(i=>{const s=e[i.do];if(!s||!("beats"in s))return[i];const o=s.beats(i).map((r,a)=>a===0?{...r,...i.at!==void 0&&r.at===void 0?{at:i.at}:{},...i.mood&&!r.mood?{mood:i.mood}:{},...i.say&&!r.say?{say:i.say}:{}}:r);return Po(o,e,n+1)})}function qc(t){return t.length===0?0:Math.max(...t.map(e=>e.after))}const $o={walk:1e3,bouncy:900,doubleBounce:1100,sneak:1600,strut:1100,tired:1500,shove:1300,run:560},lm=450,cm=2.4,hm=160,Uc=2.5,um=200,fm=340,dm=1.1,Vc=[380,900],pm=.35,_i=300,_o=150,gm=260,mm=1.2,Io=160,Gc=400,Tn=300,ym=450,zc=500,Oo=350,Jc=150,bm=120,Ho=180,Zc=420,wm=300,Qc=300,km=140,Co=150,th=450,vm=450,Ro=150,eh=350,nh=400,Sm=12,Mm=600,ih=90,sh=400,Tm=200,Em=.09,oh=350,jt=450,Lo=1200,Am=700,We=320,Xt=220,xm=65,Pm=700,rh=t=>t in oe,$m=t=>t in _t;function ah(t){return Math.max(Pm,Array.from(t).length*xm)}function lh(t,e,n={}){const i={actions:n.actions,gaits:n.gaits};xo(e,i);const s=n.gait??"walk",o=Po(e,n.actions).map(k=>k.do==="go"?{...k,do:s}:k);xo(o,i,"scriptTracks (after expanding custom actions)");const r=k=>$t[k]??n.gaits?.[k],a=k=>$o[k]??n.gaits?.[k]?.cycle??1e3,l=k=>{const $=n.actions?.[k];return $&&"steps"in $?$:void 0},c=n.from??0,h=n.ground??0,f=n.height??300;let u=c,p=h,g=n.facing??1,d=n.start??et,m=0,y=0;const w=[{time:0,pose:d}],v=[{time:0,value:0}],T=[{time:0,value:0}],S=[{time:0,value:0}],A=[{time:0,value:0}],x=[{time:0,value:"walk"}],C=[{time:0,value:g}],E=[],H=[],_=[],P=(k,$,R,W)=>{d={...d,...$},R&&(d=te(d,R)),w.push({time:k,pose:d,...W===!1?{act:W}:{}})},L=(k,$,R)=>(P(k+We/2,{turn:0},R),C.push({time:k+We/2,value:g},{time:k+We/2+1,value:$}),g=$,P(k+We,{turn:1}),k+We),F=k=>k<u?-1:1,K=(k,$,R)=>F($)!==g?L(k,F($),R):k,V=(k,$,R,W="arm")=>{const Q=W==="arm",B=ee({...k,...Q?{rightShoulder:0,rightElbow:0}:{rightHip:0,rightKnee:0}},{height:f,facing:g}),G=Q?B.shoulders.right:B.hip,O=Q?B.elbows.right:B.knees.right,N=(Y,Z)=>Math.atan2(g*Y,Z)*180/Math.PI,q=((N($-(u+G.x),R-(p+G.y))-N(O.x-G.x,O.y-G.y))%360+360)%360;return q>270?q-360:q},ot=(k,$,R,W)=>{const Q=W==="arm",B=ee({...k,...Q?{rightShoulder:90,rightElbow:0,rightWrist:0}:{rightHip:90,rightKnee:0}},{height:f,facing:g}),G=Q?B.shoulders.right:B.hip,O=Q?{x:(B.hands.right.x+B.fingertips.right.x)/2,y:(B.hands.right.y+B.fingertips.right.y)/2}:B.feet.right,N=Math.hypot(O.x-G.x,O.y-G.y),D=R-(p+G.y),q=Math.abs(D)<N?Math.sqrt(N*N-D*D):N*.1;return $-G.x-g*q},X=k=>{const $=ee(k,{height:f,facing:g});return{x:u+($.hands.right.x+$.fingertips.right.x)/2,y:p+($.hands.right.y+$.fingertips.right.y)/2}},tt=(k,$,R)=>{const W={...k,rightWrist:0,rightElbow:0,rightShoulder:V(k,$,R)},Q=ee(W,{height:f,facing:g}),B={x:u+Q.shoulders.right.x,y:p+Q.shoulders.right.y},G={x:u+Q.elbows.right.x,y:p+Q.elbows.right.y},O=X(W),N=Math.hypot(G.x-B.x,G.y-B.y),D=Math.hypot(O.x-G.x,O.y-G.y),q=Math.min(N+D-.01,Math.max(Math.abs(N-D)+.01,Math.hypot($-B.x,R-B.y))),Y=rt=>rt*180/Math.PI,Z=Y(Math.acos((N*N+q*q-D*D)/(2*N*q))),it=180-Y(Math.acos((N*N+D*D-q*q)/(2*N*D)));let ut={rightShoulder:W.rightShoulder,rightElbow:0},pt=1/0;for(const rt of[1,-1])for(const U of[1,-1]){const z={rightShoulder:W.rightShoulder+rt*Z,rightElbow:U*it},j={...k,rightWrist:0,...z},nt=X(j),ht=Math.hypot(nt.x-$,nt.y-R)-ee(j,{height:f,facing:g}).elbows.right.y*.001;ht<pt&&(pt=ht,ut=z)}return ut},J=(k,$,R)=>Math.abs($-u)<2?k:(v.push({time:k,value:u-c},{time:k+R,value:$-c,easing:"ease-in-out"}),u=$,k+R);for(const k of o){const $=Math.max(k.at??y,y===0?0:w[w.length-1].time);let R=$,W,Q;const B=k.pose??{},G=l(k.do);if(r(k.do)){const O=k.to??u,N=O===u?g:F(O);let D=$;N!==g?D=L($,N,k.mood):d.turn<1?(D=$+Xt,P(D,{turn:1,...B},k.mood)):(k.mood||k.pose)&&P($+Xt,B,k.mood);const Y=Math.abs(O-u)/Ls(r(k.do),f),Z=k.for??Math.max(Xt*2,Y*a(k.do)),it=D+Z;x.push({time:D,value:k.do}),A.push({time:D,value:0},{time:D+Xt,value:1,easing:"ease-out"}),A.push({time:it-Xt,value:1},{time:it,value:0,easing:"ease-in"}),S.push({time:D,value:m},{time:it,value:m+Y}),v.push({time:D,value:u-c},{time:it,value:O-c}),m+=Y,u=O,P(it,{}),R=it}else if(k.do==="zip"){const O=k.to??u,N=O===u?g:F(O);let D=$;N!==g?D=L($,N,k.mood):d.turn<1&&(D=$+Xt,P(D,{turn:1},k.mood));const q=ko("windUp",{at:D,from:k.mood?te(d,k.mood):d});w.push(...q),d=q[q.length-1].pose;const Y=D+vn("windUp"),Z=Y+lm,it=Z+Math.max(hm,Math.abs(O-u)/cm);x.push({time:Y,value:"run"}),A.push({time:Y,value:0},{time:Y+80,value:1,easing:"ease-out"},{time:it,value:1},{time:it+120,value:0}),S.push({time:Y,value:m},{time:Z,value:m+Uc,easing:"ease-in"}),m+=Uc+(it-Z)/$o.run*1.5,S.push({time:it,value:m}),v.push({time:Z,value:u-c},{time:it,value:O-c,easing:"ease-in"}),_.push({kind:"dust",time:Z,x:u,y:p,length:900}),u=O,P(it,{}),R=it}else if(k.do==="leap"){const O=k.to??u,N=k.onto??p;let D=O===u?$:K($,O,k.mood);d.turn<1&&(D+=Xt,P(D,{turn:1},k.mood));const q={leftShoulder:35,rightShoulder:35,leftElbow:-50,rightElbow:-50};P(D+um,{stretch:.75,bend:12,leftHip:22,rightHip:22,...q},k.mood,!1);const Y=D+fm;P(Y-40,{stretch:.72},void 0,!1),P(Y,{stretch:1.2,bend:-6,leftShoulder:140,rightShoulder:140,leftElbow:20,rightElbow:20,leftHip:4,rightHip:4},void 0,!1);const Z=Math.hypot(O-u,N-p),it=k.for??Math.min(Vc[1],Math.max(Vc[0],300+Z*dm)),ut=Math.min(p,N)-pm*f,pt=Math.sqrt(p-ut),rt=Math.sqrt(N-ut),U=Y+it*pt/(pt+rt),z=Y+it;P(U,{stretch:1,bend:4,leftHip:-55,leftKnee:-80,rightHip:55,rightKnee:80,leftShoulder:110,rightShoulder:110},void 0,!1),P(z,{stretch:.72,bend:12,leftShoulder:75,rightShoulder:75,leftElbow:0,rightElbow:0,leftHip:18,rightHip:18,leftKnee:0,rightKnee:0},void 0,!1),P(z+180,{stretch:1.05,bend:-3},void 0,!1),P(z+340,{stretch:1,bend:0,leftHip:et.leftHip,rightHip:et.rightHip,leftShoulder:et.leftShoulder,rightShoulder:et.rightShoulder,leftElbow:et.leftElbow,rightElbow:et.rightElbow},void 0,!1),v.push({time:Y,value:u-c},{time:z,value:O-c}),T.push({time:Y,value:p-h},{time:U,value:ut-h,easing:"ease-out-quad"},{time:z,value:N-h,easing:"ease-in-quad"}),u=O,p=N,_.push({kind:"dust",time:z,x:u,y:p,length:500}),R=z+340,W=z}else if(k.do==="point"&&k.target){const O=k.target,N=K($,O.x,k.mood),D={...d,...k.mood?ct[k.mood]:{},turn:Math.max(d.turn,.6),rightElbow:0,rightWrist:0,...B},q=ee(D,{height:f,facing:g}).head.center,Y=Math.abs(O.x-(u+q.x)),Z=O.y-(p+q.y),it=N+jt;P(it,{...D,rightShoulder:V(D,O.x,O.y),lookX:1,lookY:_m(Z/Math.max(1,Math.hypot(Y,Z)))*.8}),R=it+(k.for??Lo),W=it,Q=R}else if(k.do==="swipe"){const O=k.target??{x:u+g*f*.5,y:p-f*.6},N=F(O.x),D=K($,O.x,k.mood),q=N===1?O.left??O.x:O.right??O.x,Y=N===1?O.right??O.x:O.left??O.x,Z={...d,turn:1,lean:-10,bend:-8,rightElbow:40,lookX:1,...B};P(D+_i,{...Z,rightShoulder:V(Z,u-g*f*.3,p-f*1.1)},k.mood,!1);const it={...d,lean:6,bend:4,rightElbow:0,rightWrist:0},ut={...d,lean:14,bend:12,rightElbow:0,rightWrist:0};J(D,ot(it,q,O.y,"arm"),_i+_o),P(D+_i+_o,{lean:-12},void 0,!1);const pt=D+_i+_o+80;P(pt,{...it,rightShoulder:V(it,q,O.y)},void 0,!1);const rt=pt+(k.for??Math.max(gm,Math.abs(Y-q)/mm));v.push({time:pt,value:u-c}),u=ot(ut,Y,O.y,"arm"),v.push({time:rt,value:u-c}),P(rt,{...ut,rightShoulder:V(ut,Y,O.y)},void 0,!1),P(rt+Io,{lean:16,bend:14,rightShoulder:V(d,Y+N*f*.4,O.y+f*.25)},void 0,!1),P(rt+Io+Gc,{lean:0,bend:0,rightShoulder:et.rightShoulder,rightElbow:et.rightElbow}),R=rt+Io+Gc,W=pt,Q=rt}else if(k.do==="grab"&&k.target){const O=k.target,N=K($,O.x,k.mood),D=O.y>p-f*.5,q={...d,turn:1,rightElbow:0,bend:D?35:0,lean:D?12:0,stretch:D?.75:1,lookX:1,lookY:D?.8:0,...B},Z=J(N,ot(q,O.x,O.y,"arm"),Tn)+ym;P(Z,{...q,rightShoulder:V(q,O.x,O.y)},k.mood,!1),P(Z+120,{},void 0,!1),P(Z+zc,{bend:0,lean:-3,stretch:1,rightShoulder:165,rightElbow:20,lookY:-.6}),R=Z+zc+150,W=Z}else if(k.do==="throw"){const O=k.target?.x??k.to??u+g*f,N=K($,O,k.mood),D={...d,turn:1,lean:-12,bend:-10,rightElbow:60,stretch:.95,lookX:1,lookY:-.3,...B};P(N+Oo,{...D,rightShoulder:V(D,u-g*f*.4,p-f*1.05)},k.mood,!1),P(N+Oo+Jc,{lean:-14},void 0,!1);const q=N+Oo+Jc+bm,Y={...d,lean:14,bend:12,rightElbow:0,stretch:1.04};w.push({time:q,pose:d={...Y,rightShoulder:V(Y,u+g*f,p-f*1.1)},easing:"ease-in",act:!1}),P(q+Ho,{lean:18,bend:14,rightShoulder:55,stretch:1},void 0,!1),P(q+Ho+Zc,{lean:0,bend:0,rightShoulder:et.rightShoulder,rightElbow:et.rightElbow,lookY:0}),R=q+Ho+Zc,W=q,Q=q}else if(k.do==="kick"&&k.target){const O=k.target,N=K($,O.x,k.mood),D={...d,turn:1,lean:-12,bend:-6,rightKnee:0,leftShoulder:100,rightShoulder:70},q=J(N,ot(D,O.x,O.y,"leg"),wm),Y={leftShoulder:70,rightShoulder:50,leftElbow:-20,rightElbow:20};P(q+Qc,{turn:1,lean:8,bend:6,rightHip:-40,rightKnee:80,lookX:1,lookY:.7,...Y,...B},k.mood,!1);const Z=q+Qc+km,it=V(D,O.x,O.y,"leg");w.push({time:Z,pose:d={...d,...D,rightHip:it},easing:"ease-in",act:!1}),P(Z+Co,{lean:-15,rightHip:it+20},void 0,!1),P(Z+Co+th,{lean:0,bend:0,rightHip:et.rightHip,rightKnee:0,leftShoulder:et.leftShoulder,rightShoulder:et.rightShoulder,leftElbow:et.leftElbow,rightElbow:et.rightElbow,lookY:0}),R=Z+Co+th,W=Z}else if(k.do==="put"&&k.target){const O=k.target,N=K($,O.x,k.mood),D=O.y>p-f*.5,q={...d,turn:1,rightElbow:0,rightWrist:0,bend:D?35:0,lean:D?12:0,stretch:D?.75:1,lookX:1,lookY:D?.8:0,...B},Z=J(N,ot(q,O.x,O.y,"arm"),Tn)+vm;P(Z,{...q,rightShoulder:V(q,O.x,O.y)},k.mood,!1),P(Z+Ro,{},void 0,!1),P(Z+Ro+eh,{bend:0,lean:0,stretch:1,rightShoulder:et.rightShoulder,rightElbow:et.rightElbow,lookY:0}),R=Z+Ro+eh,W=Z}else if(k.do==="write"&&k.target){const O=k.target,N=O.left??O.x,D=O.right??O.x,q=K($,(N+D)/2,k.mood),Y={...d,turn:1,rightElbow:0,rightWrist:0,...ct.thinking,lookX:1,lookY:0,...B},Z=nt=>ot(Y,nt,O.y,"arm")+g*f*.08,it=nt=>{const lt=X({...Y,...tt(Y,nt,O.y),rightWrist:0});return Math.hypot(lt.x-nt,lt.y-O.y)<2},ut=g===1?N:D,pt=J(q,Z((N+D)/2),Tn),rt=!it(N)||!it(D),U=rt?J(pt,Z(N),Tn)+nh:pt+nh;P(U,{...Y,...tt(Y,rt?N:ut,O.y)},k.mood,!1);const z=k.for??Math.max(Mm,Math.abs(D-N)*Sm);rt&&v.push({time:U,value:u-c});for(let nt=ih,lt=0;nt<=z;nt+=ih,lt++){const ht=N+(D-N)*Math.min(nt,z)/z;rt&&(u=Z(ht),v.push({time:U+nt,value:u-c}));const St=(lt%2===0?-1:1)*f*.02;P(U+nt,tt(Y,ht,O.y+St),void 0,!1)}const j=U+z;P(j,tt(Y,D,O.y),void 0,!1),P(j+sh,{rightShoulder:et.rightShoulder,rightElbow:et.rightElbow,...ct.happy}),R=j+sh,W=U,Q=j}else if(k.do==="push"&&k.target){const O=k.target,N=k.to??O.x,D=K($,u+(N>=O.x?1:-1),k.mood),q=g===1?O.left??O.x:O.right??O.x,Y={...d,turn:1,lean:16,bend:8,rightWrist:0,leftWrist:0,lookX:1,...B},Z=ot(Y,q,O.y,"arm"),it=J(D,Z+g*f*.06,Tn),ut=tt(Y,q,O.y),pt={...Y,...ut,leftShoulder:-ut.rightShoulder,leftElbow:-ut.rightElbow},rt=it+Tm;P(rt,pt,k.mood,!1);const U=Math.abs(N-O.x),z=rt+(k.for??Math.max(600,U/Em)),j=U/Ls("shove",f);x.push({time:rt,value:"shove"}),A.push({time:rt,value:0},{time:rt+Xt,value:1,easing:"ease-out"},{time:z-Xt,value:1},{time:z,value:0,easing:"ease-in"}),S.push({time:rt,value:m},{time:z,value:m+j}),m+=j,v.push({time:rt,value:u-c},{time:z,value:u+(N-O.x)-c}),u+=N-O.x,P(z,{},void 0,!1),P(z+oh,{lean:0,bend:0,rightShoulder:et.rightShoulder,leftShoulder:et.leftShoulder,rightElbow:et.rightElbow,leftElbow:et.leftElbow}),R=z+oh,W=rt,Q=z}else if(G){const O=k.mood?te(d,k.mood):d,N=G.steps(O,k),D=vo(N,{at:$,from:O});w.push(...D),d=D[D.length-1].pose,R=$+Math.max(qc(N),k.for??0)}else if(rh(k.do)){const O=ko(k.do,{at:$,from:k.mood?te(d,k.mood):d});w.push(...O),d=O[O.length-1].pose,R=$+vn(k.do),k.do==="take"&&_.push({kind:"dust",time:$+900,x:u,y:p,length:500}),k.do==="land"&&_.push({kind:"dust",time:$+120,x:u,y:p,length:500})}else if(k.do==="look"||k.do==="face"){const O=k.toward??"viewer",N=k.for??Am;if(O==="viewer")P($+jt,{turn:0,lookX:0,lookY:0,...B},k.mood);else if(O==="ahead")P($+jt,{turn:k.do==="face"?1:.6,lookX:1,...B},k.mood);else if(O==="back")P($+jt,{turn:.2,lookX:-1,...B},k.mood);else{const D=F(O);D!==g&&k.do==="face"?(L($,D,k.mood),P($+We+1,{lookX:1,...B})):D!==g?P($+jt,{turn:.25,lookX:-1,...B},k.mood):P($+jt,{turn:k.do==="face"?1:.6,lookX:1,...B},k.mood)}R=$+Math.max(N,jt)}else if($m(k.do)||k.do==="stand"){const O=k.do==="stand"?n.rest??et:_t[k.do],N=O.turn!==et.turn?O.turn:d.turn,D=k.mood?ct[k.mood]:{lookX:d.lookX,lookY:d.lookY};P($+jt,{...O,turn:N,...D,...B}),R=$+(k.for??Lo)}else{const O=k.for??(k.say?ah(k.say):Lo);(k.mood||k.pose)&&P($+Math.min(jt,O/2),B,k.mood),R=$+O}if(k.say){const O=r(k.do)||rh(k.do)||G?$:$+Math.min(150,(R-$)/4),N=r(k.do)?R:Math.max(O+200,R-100);E.push({text:k.say,start:O,end:N}),k.do==="say"&&Hm(w,d,O,N)}k.onto!==void 0&&k.do!=="leap"&&k.onto!==p&&(T.push({time:$,value:p-h},{time:R,value:k.onto-h,easing:"ease-in-out"}),p=k.onto),R>w[w.length-1].time&&w.push({time:R,pose:d}),H.push({start:$,end:R,...W!==void 0?{contact:W}:{},...Q!==void 0?{release:Q}:{}}),y=R}const M=Hc(t,Om(w),n),I=[{id:`${t}-x`,target:t,property:"x",keyframes:v},{id:`${t}-y`,target:t,property:"y",keyframes:T},{id:`${t}-walk`,target:t,property:"walk",keyframes:S},{id:`${t}-walking`,target:t,property:"walking",keyframes:A},{id:`${t}-gait`,target:t,property:"gait",keyframes:x},{id:`${t}-facing`,target:t,property:"facing",keyframes:C}].filter(k=>k.keyframes.length>1||k.property==="x");return{tracks:[...jc(t,M,E,{energy:n.energy}),...I],duration:y,lines:E,keys:w,beats:H,effects:_}}const _m=t=>Math.max(-1,Math.min(1,t)),Im=30;function Om(t){const e=[];for(const n of t){const i=e[e.length-1];i&&n.time-i.time<Im?e[e.length-1]={...n,time:i.time}:e.push(n)}return e}function Hm(t,e,n,i){const o=t.filter(l=>l.time>n),r=t.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:{...e,headTilt:e.headTilt+h,leftBrow:e.leftBrow+(c%2===0?.25:0),rightBrow:e.rightBrow+(c%2===0?.25:0)}})}a.length>0&&a.push({time:i,pose:e}),t.length=0,t.push(...r,...a.filter(l=>!o.some(c=>Math.abs(c.time-l.time)<60)),...o),t.sort((l,c)=>l.time-c.time)}function ch(t,e,n){const i=new le({id:`${t}-hand`,tracks:e.filter(l=>l.target===t)}),s=Ws({x:n.x,y:n.y,style:n.style,cast:n.cast}),o=n.side??"right",r=n.every??33,a=[];for(let l=n.start;;l=Math.min(n.end,l+r)){const{joints:c}=Ks(s,{time:l,state:i.getStateAtTime(l)},t),h=c.hands[o],f=c.fingertips[o];if(a.push({time:l,x:(h.x+f.x)/2,y:(h.y+f.y)/2}),l>=n.end)break}return a}function Cm(t){const e={actions:t.actions,gaits:t.gaits},n=To(e);if(n.length>0)throw new Error(`persona "${t.name}": ${n.join(" ")}`);const i=[...Object.keys($t),...Object.keys(t.gaits??{})],s=t.gait??"walk";if(!i.includes(s))throw new Error(`persona "${t.name}": ${At("gait",s,i)}`);if(t.mood&&!(t.mood in ct))throw new Error(`persona "${t.name}": ${At("mood",t.mood,Object.keys(ct))}`);const o=t.acting??"snappy";if(typeof o=="string"&&!(o in ge))throw new Error(`persona "${t.name}": ${At("acting style",o,Object.keys(ge))}`);if(typeof t.stance=="string"&&!(t.stance in _t))throw new Error(`persona "${t.name}": ${At("stance",t.stance,Object.keys(_t))}`);const r=t.height??120,a=typeof t.stance=="string"?_t[t.stance]:wt(t.stance??{}),l=t.mood?te(a,t.mood):a,c={...t.look,height:r},h=t.summary??`${t.name}, a stick figure`;return{name:t.name,summary:h,cast:e,rest:l,height:r,figure:f=>Ws({x:f.x,y:f.y,pose:l,style:{...c,...f.facing?{facing:f.facing}:{}},cast:e}),script:(f,u,p={})=>lh(f,u,{...e,from:p.from,ground:p.ground,facing:p.facing,height:r,style:o,gait:s,start:l,rest:l,energy:t.energy}),check:f=>Ao(f,e),handPath:(f,u,p)=>ch(f,u,{...p,style:c,cast:e}),describe:()=>({name:t.name,summary:h,habits:{height:r,acting:typeof o=="string"?o:"custom",gait:s,...t.mood?{mood:t.mood}:{},stance:typeof t.stance=="string"?t.stance:t.stance?"custom":"rest"},actions:Eo(e),own:{actions:Object.keys(t.actions??{}),gaits:Object.keys(t.gaits??{})}})}}const at=["rect","circle","text","line","path","image","custom"],Ii={x:{description:"Moves it right by this much from where it was placed (an offset; the target’s own x is its place)",unit:"px",types:at},y:{description:"Moves it down by this much from where it was placed (an offset)",unit:"px",types:at},opacity:{description:"How opaque it is",unit:"0..1",min:0,max:1,types:at},rotate:{description:"Turns it clockwise about its origin",unit:"degrees",types:at},rotateX:{description:"Tips it about the horizontal axis (3D; shows with perspective)",unit:"degrees",types:at},rotateY:{description:"Turns it about the vertical axis (3D; shows with perspective)",unit:"degrees",types:at},z:{description:"Depth toward the viewer (shows with perspective)",unit:"px",types:at},perspective:{description:"Distance from the viewer: nearer parts grow, further ones shrink",unit:"px",min:1,types:at},scale:{description:"Size, both ways",unit:"factor",types:at},scaleX:{description:"Width factor",unit:"factor",types:at},scaleY:{description:"Height factor",unit:"factor",types:at},skewX:{description:"Slants it sideways",unit:"degrees",types:at},skewY:{description:"Slants it up and down",unit:"degrees",types:at},originX:{description:"Transform pivot across its box",unit:"% (0 left, 50 centre, 100 right)",min:0,max:100,types:at},originY:{description:"Transform pivot down its box",unit:"% (0 top, 50 centre, 100 bottom)",min:0,max:100,types:at},fill:{description:"Fill colour (also written fillStyle)",kind:"color",types:at},stroke:{description:"Outline colour (also written strokeStyle)",kind:"color",types:at},strokeWidth:{description:"Outline width (also written lineWidth)",unit:"px",min:0,types:at},clipTop:{description:"Hides this much from the top edge, for reveals",unit:"% of its height",min:0,max:100,types:at},clipRight:{description:"Hides this much from the right edge",unit:"% of its width",min:0,max:100,types:at},clipBottom:{description:"Hides this much from the bottom edge",unit:"% of its height",min:0,max:100,types:at},clipLeft:{description:"Hides this much from the left edge",unit:"% of its width",min:0,max:100,types:at},blur:{description:"Gaussian blur",unit:"px",min:0,types:at},brightness:{description:"Brightness factor (1 unchanged)",unit:"factor",min:0,types:at},glow:{description:"Soft glow around it, in glowColor",unit:"px",min:0,types:at},glowColor:{description:"Colour of the glow",kind:"color",types:at},shadowX:{description:"Drop shadow offset right",unit:"px",types:at},shadowY:{description:"Drop shadow offset down",unit:"px",types:at},shadowBlur:{description:"Drop shadow softness",unit:"px",min:0,types:at},shadowColor:{description:"Drop shadow colour",kind:"color",types:at},shine:{description:"A highlight sweeping across the fill",unit:"0..1 (progress)",min:0,max:1,types:at},drawOn:{description:"How much of the outline is drawn, for drawing a shape on; the fill appears when it is complete",unit:"0..1",min:0,max:1,types:["rect","circle","line","path"]},width:{description:"Box width",unit:"px",min:0,types:["rect","image"]},height:{description:"Box height",unit:"px",min:0,types:["rect","image"]},borderRadius:{description:"Rounded corners",unit:"px",min:0,types:["rect","image"]},radius:{description:"Circle radius",unit:"px",min:0,types:["circle"]},x2:{description:"Line end, x",unit:"px",types:["line"]},y2:{description:"Line end, y",unit:"px",types:["line"]},d:{description:"SVG path data; tween between paths to morph",kind:"string",types:["path"]},text:{description:"The text shown (a text track types or scrambles it)",kind:"string",types:["text"]},fontSize:{description:"Font size",unit:"px",min:0,types:["text"]},fontWeight:{description:"Font weight",unit:"100..900",min:100,max:900,types:["text"]},motionPath:{description:"Moves it along an SVG path (a motion-path track writes motionPathX/Y and, aligned, rotate)",kind:"string",types:at},quaternion:{description:'A rotation as [x, y, z, w] (a track with interpolation: "slerp")',kind:"list",types:at}},Fo={fillStyle:"fill",strokeStyle:"stroke",lineWidth:"strokeWidth",rotateZ:"rotate",motionPathX:"x",motionPathY:"y",motionPathRotate:"rotate"},Rm={rotation:"rotate",angle:"rotate",alpha:"opacity",fade:"opacity",color:"fill",colour:"fill",background:"fill",size:"scale",left:"x",top:"y",translateX:"x",translateY:"y",r:"radius",path:"d",content:"text"};function hh(t){const e=t,n=Object.entries(Ii).filter(([,s])=>s.types.includes(t.type)).map(([s,{types:o,...r}])=>({name:s,...r,...e[s]!==void 0&&typeof e[s]!="object"?{value:e[s]}:{}}));if(t.type!=="custom")return{type:t.type,properties:n};const i=t.about;for(const[s,o]of Object.entries(t.props??{}))n.push({name:s,description:i?.props?.[s]?.description??"",...i?.props?.[s],value:o});return{type:"custom",...i?{kind:i.kind,summary:i.summary}:{},properties:n,...i?.actions?{actions:i.actions}:{}}}function uh(t){const e=hh(t).properties.map(n=>n.name);return[...e,...Object.keys(Fo).filter(n=>e.includes(Fo[n]))]}function Lm(t,e){const n=[],i=Object.keys(e);for(const s of t){const o=u=>n.push({level:"error",track:s.id,message:u}),r=e[s.target];if(!r){o(At("target",s.target,i));continue}const a=uh(r),l=r.type==="custom"&&r.acceptsProp?.(s.property);if(!a.includes(s.property)&&!l){o(`${s.target}: ${At("property",s.property,a,Rm[s.property])}`);continue}const c=s.keyframes??[];for(let u=1;u<c.length;u++)c[u].time<c[u-1].time&&o(`${s.target}.${s.property}: keyframes out of time order (${c[u-1].time} ms, then ${c[u].time} ms).`);const h=Ii[Fo[s.property]??s.property]??r.about?.props?.[s.property],f=h&&(h.kind??"number")==="number";for(const u of c){if(f&&typeof u.value!="number"){o(`${s.target}.${s.property}: values are numbers${h.unit?` (${h.unit})`:""} (got ${JSON.stringify(u.value)} at ${u.time} ms).`);break}if(f&&typeof u.value=="number"&&(h.min!==void 0&&u.value<h.min||h.max!==void 0&&u.value>h.max)){n.push({level:"warning",track:s.id,message:`${s.target}.${s.property}: ${u.value} at ${u.time} ms is outside ${h.min??"−∞"}..${h.max??"∞"}${h.unit?` (${h.unit})`:""}.`});break}}}return n}const Fm={linear:!0,"ease-in":!0,"ease-out":!0,"ease-in-out":!0,"ease-in-quad":!0,"ease-out-quad":!0,"ease-in-out-quad":!0,"ease-in-cubic":!0,"ease-out-cubic":!0,"ease-in-out-cubic":!0};function fh(t,e={}){const n={};for(const i of Object.keys($t))n[i]={summary:`Walks to \`to\` in the ${i} gait.`,needs:["to"]};for(const i of Object.keys(_t))n[i]={summary:`Moves into the ${i} pose and holds it (\`for\` ms).`};for(const i of Object.keys(oe))n[i]={summary:`The ${i} gag (${vn(i)} ms).`};for(const[i,s]of Object.entries(Mn))n[i]={...s};return{...t?{version:t}:{},timing:"JSON timelines and tracks are in milliseconds; the GSAP-style API (live.to, tf.timeline) takes seconds. Scene x grows right, y grows down, in px.",easings:{named:Object.keys(Fm),parametric:{"cubic-bezier":'{ type: "cubic-bezier", points: [x1, y1, x2, y2] }',steps:'{ type: "steps", count, position?: start | end | none | both }',elastic:'{ type: "elastic", mode?: in | out | in-out, amplitude?, period? }',bounce:'{ type: "bounce", mode?: in | out | in-out }',back:'{ type: "back", mode?: in | out | in-out, overshoot? }'}},trackKinds:{keyframe:"{ id, target, property, keyframes: [{ time, value, easing? }] }: values between keys are interpolated (numbers, colours, paths)",spring:'{ id, target, property, kind: "spring", spring: { from, to, stiffness?, damping?, mass?, velocity? }, delay? }: physics settle',inertia:'{ id, target, property, kind: "inertia", inertia: { from, velocity, friction?, min?, max?, end? }, delay? }: a flick that slows (end snaps to a value or the nearest of a list)',motionPath:'{ property: "motionPath", path, align? }: moves along an SVG path',text:'{ property: "text", … }: types or scrambles text'},canvasProperties:Ii,stickFigure:{poseFields:ol,props:rl,handFields:al,poses:Object.keys(_t),expressions:Object.keys(ct),gags:Object.fromEntries(Object.keys(oe).map(i=>[i,vn(i)])),gaits:Object.keys($t),actingStyles:Object.keys(ge),beatFields:Pi,actions:n,dances:Object.fromEntries(Object.entries(ne).map(([i,s])=>[i,Object.keys(s.moves)])),flips:Object.fromEntries(Object.entries(yn).map(([i,s])=>[i,s.label])),handShapes:Object.keys(bt),mudras:Object.keys(ai)},custom:{api:{"defineAction({ summary, needs?, steps: (from, beat) => [{ after, pose, easing? }] })":"a new action written as timed pose steps from the current pose, like a gag","defineAction({ summary, needs?, beats: (beat) => [beats] })":"a new action built from other beats (which may be custom too)","defineGait({ swing, knee, arm, elbow, lean, cycle?, … })":"a new gait (the Gait fields in degrees; cycle is ms per two steps)","scriptTracks(id, beats, { actions, gaits })":"beats may then use those names; checkBeats(beats, { actions, gaits }) knows them","stickFigureTarget({ …, cast: { actions, gaits } })":"a figure that draws the gaits and lists the actions in describeTarget","persona({ name, summary?, height?, look?, acting?, gait?, mood?, stance?, energy?, actions?, gaits? })":"a character’s look, acting style and habits: .figure({ x, y }), .script(id, beats, { from, ground }), .check(beats), .handPath(…), .describe(); `go` walks in its gait, `stand` returns to its stance and face"},actions:Object.fromEntries(Object.entries(e.actions??{}).map(([i,s])=>[i,{summary:s.summary,...s.needs?{needs:s.needs}:{}}])),gaits:Object.fromEntries(Object.entries(e.gaits??{}).map(([i,s])=>[i,s.summary??"custom gait"]))},character:{poses:Object.keys(Gs),expressions:Object.keys(zs),gags:Object.keys(mo)},codePanel:{languages:Ei,removeStyles:Mi,anchors:{"line(n, time?)":"line n’s text box { x, y, left, right, top, bottom, width, height }: stand on top, point at x, y","token(n, text, occurrence?, time?)":"a word on a line","spot(n, column, width?, time?)":"a place in a line, for put and write","landing(piece, n, column)":"where a dropped piece will land",box:"the whole panel"},edits:go},cameraShots:{frame:"{ at, duration?, easing?, frame: { focus?: { x, y }, scale?, rotate? } }: push in, pull out, or cut (duration 0)",shake:"{ at, duration, shake: { strength?, frequency?, roll?, seed? } }",follow:"{ at, until, follow: { x: <the subject’s x keyframes>, lead?, y?, lag?, scale? } }: keeps a subject centred"},teach:{"lesson({ id })":"steps as timeline JSON: to, set, together, wait, marker (with pause, question, captions)","cells, pointer, stack, queue, table, pipeline":"diagram primitives (SVG markup + step helpers)","figure({ width, height, children })":"the SVG holding the pieces"},cli:{"tinyfly capabilities [--json]":"this catalog","tinyfly check <beats.json>":"check a beat script (names, fields) with suggestions","tinyfly validate <timeline.json> [--markup file]":"check a timeline against its markup","tinyfly render <timeline.json> <markup> [--at …]":"a frame as static markup","tinyfly video <scene.mjs> [--stills dir --times …]":"MP4, or PNG stills to look at"}}}const Et=t=>t.map(e=>`\`${e}\``).join(", "),dh=t=>Object.entries(t).map(([e,n])=>`| \`${e}\` | ${n.unit??n.kind??""} | ${n.description} |`).join(`
|
|
57
|
+
`);function Dm(t,e={}){const n=fh(t,e),i=n.stickFigure;return[`# tinyfly capabilities${n.version?` (v${n.version})`:""}`,"","Generated from the library itself: every name below is accepted, and names not listed are rejected (beat scripts, code panels and `checkTracks` say which name was probably meant).","",`**Timing.** ${n.timing}`,"","## Easings","",`Named: ${Et(n.easings.named)}.`,"",...Object.entries(n.easings.parametric).map(([o,r])=>`- ${o}: \`${r}\``),"","## Track kinds","",...Object.entries(n.trackKinds).map(([o,r])=>`- **${o}**: ${r}`),"","## Canvas targets","","Types: `rect`, `circle`, `text`, `line`, `path`, `image`, `custom`. `describeTarget(target)` lists what one can animate with its values; `checkTracks(tracks, targets)` checks tracks before playing them.","","| Property | Unit | What it does | Types |","|---|---|---|---|",...Object.entries(n.canvasProperties).map(([o,r])=>`| \`${o}\` | ${r.unit??r.kind??""} | ${r.description} | ${r.types.length===7?"all":r.types.join(", ")} |`),"","## Stick figure (`@algorisys/tinyfly/characters`)","","`stickFigureTarget({ x, y, style })` is a custom canvas target; its props are the pose fields and the props below. Pose it with tracks (`poseTracks`), or write beats (`scriptTracks`).","","### Pose fields","","| Field | Unit | What it does |","|---|---|---|",dh(i.poseFields),"","### Other props","","| Prop | Unit | What it does |","|---|---|---|",dh(i.props),"",`With \`style.hands\`, each hand has \`hand.left.<field>\` / \`hand.right.<field>\` props: ${Et(Object.keys(i.handFields))}.`,"",`**Poses** (a beat's \`do\`, or a pose key): ${Et(i.poses)}.`,"",`**Expressions** (a beat's \`mood\`): ${Et(i.expressions)}.`,"",`**Gags** (ms): ${Object.entries(i.gags).map(([o,r])=>`\`${o}\` (${r})`).join(", ")}.`,"",`**Gaits**: ${Et(i.gaits)}. **Acting styles** (\`style\`): ${Et(i.actingStyles)}.`,"","### Beat scripts","",`\`scriptTracks(target, beats, { from, ground, height, facing, style })\`. A beat has these fields only: ${Et(i.beatFields)}. Times are ms; \`to\` and \`target\` are scene px; \`onto\` is a floor's scene y.`,"","| `do` | Needs | What happens |","|---|---|---|",...Object.entries(i.actions).map(([o,r])=>`| \`${o}\` | ${(r.needs??[]).map(a=>`\`${a}\``).join(", ")} | ${r.summary} |`),"","Beats that touch something report `contact` (and `release`) times in `result.beats[i]`; key the thing they touch to those.","",`**Dances** (\`dancer(style, { move })\`): ${Object.entries(i.dances).map(([o,r])=>`\`${o}\` (${r.join(", ")})`).join("; ")}.`,"",`**Flips**: ${Object.entries(i.flips).map(([o,r])=>`\`${o}\` (${r})`).join(", ")}.`,"",`**Hand shapes**: ${Et(i.handShapes)}. **Mudras**: ${Et(i.mudras)}.`,"","### Your own actions, gaits and personas","","Nothing is registered globally: pass your definitions where they are used.","",...Object.entries(n.custom.api).map(([o,r])=>`- \`${o}\`: ${r}`),"",...Object.keys(n.custom.actions).length||Object.keys(n.custom.gaits).length?["**This cast’s own:**","",...Object.entries(n.custom.actions).map(([o,r])=>`- \`${o}\`${r.needs?.length?` (needs ${r.needs.map(a=>`\`${a}\``).join(", ")})`:""}: ${r.summary}`),...Object.entries(n.custom.gaits).map(([o,r])=>`- \`${o}\` (gait): ${r}`),""]:[],"## Character (v2 human)","",`Poses: ${Et(n.character.poses)}. Expressions: ${Et(n.character.expressions)}. Gags: ${Et(n.character.gags)}.`,"","## Code panel","",`\`codePanel({ code, language, x, y, fontSize?, lineHeight?, width? })\`: a code listing as a scene object. Languages: ${Et(n.codePanel.languages)}. Remove styles: ${Et(n.codePanel.removeStyles)}.`,"",...Object.entries(n.codePanel.anchors).map(([o,r])=>`- \`${o}\`: ${r}`),"",...Object.values(n.codePanel.edits).map(o=>`- \`${o.split(":")[0]}\`:${o.split(":").slice(1).join(":")}`),"","## Camera shots (`cameraTracks(shots, { stage })`)","",...Object.entries(n.cameraShots).map(([o,r])=>`- **${o}**: \`${r}\``),"","## Teaching (`@algorisys/tinyfly/teach`)","",...Object.entries(n.teach).map(([o,r])=>`- \`${o}\`: ${r}`),"","## Command line","",...Object.entries(n.cli).map(([o,r])=>`- \`${o}\`: ${r}`),""].join(`
|
|
58
|
+
`)}function Nm(t){const{timeline:e}=t,n=new ue;for(const[c,h]of Object.entries(t.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)}e.onUpdate=c=>{n.applyState(c),t.onUpdate?.(c)},t.onComplete&&(e.onComplete=t.onComplete);let i=null,s=null,o=!1;const r=c=>{if(o)return;const h=s===null?0:c-s;s=c,h>0&&e.tick(h),i=requestAnimationFrame(r)},a=()=>{i!==null||o||(s=null,i=requestAnimationFrame(r))},l=()=>{i!==null&&cancelAnimationFrame(i),i=null,s=null};return n.applyState(e.getStateAtTime(e.currentTime)),t.autoplay!==!1&&(e.play(),a()),{timeline:e,adapter:n,play(){e.play(),a()},pause(){e.pause(),l()},restart(){e.stop(),e.play(),a()},seek(c){e.seek(c*1e3),n.applyState(e.getStateAtTime(e.currentTime))},destroy(){o=!0,l(),e.stop(),n.clearTargets()}}}const Bm={timeline:uf,to(t,e,n){const i=new he(n);return i.to(t,e),i},from(t,e,n){const i=new he(n);return i.from(t,e),i},fromTo(t,e,n,i){const s=new he(i);return s.fromTo(t,e,n),s},set(t,e,n){const i=new he(n);return i.set(t,e),i}};function ph(t,e,n){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,n);const i=t.canvas;if(i?.ownerDocument){const s=i.ownerDocument.createElement("canvas");return s.width=e,s.height=n,s}try{return i?.constructor?new i.constructor(e,n):null}catch{return null}}function Wm(t,e){const n=t.length/4,i=new Float32Array(n*3),s=Math.min(.999,Math.max(0,e));for(let o=0;o<n;o++){const r=t[o*4]/255,a=t[o*4+1]/255,l=t[o*4+2]/255,c=t[o*4+3]/255,h=Math.max(r,a,l);if(h<=s)continue;const f=(h-s)/(1-s)*c/h;i[o*3]=r*f,i[o*3+1]=a*f,i[o*3+2]=l*f}return i}function gh(t,e,n,i,s){const o=new Float32Array(t.length),r=s?n:e,a=s?e:n,l=(h,f)=>(s?h*e+f:f*e+h)*3,c=i*2+1;for(let h=0;h<r;h++)for(let f=0;f<3;f++){let u=0;for(let p=-i;p<=i;p++)u+=t[l(h,Math.min(a-1,Math.max(0,p)))+f];for(let p=0;p<a;p++){o[l(h,p)+f]=u/c;const g=t[l(h,Math.max(0,p-i))+f],d=t[l(h,Math.min(a-1,p+i+1))+f];u+=d-g}}return o}function mh(t,e,n,i){const s=Math.max(1,Math.round(i/Math.sqrt(3)));let o=t;for(let r=0;r<3;r++)o=gh(o,e,n,s,!0),o=gh(o,e,n,s,!1);return o}function Km(t,e={}){const n=t.canvas,i=n.width,s=n.height;if(!(i>0&&s>0))return;const o=Math.max(1,Math.round(e.downsample??4)),r=Math.max(1,Math.ceil(i/o)),a=Math.max(1,Math.ceil(s/o)),l=ph(t,r,a),c=l?.getContext("2d");if(!l||!c)return;c.imageSmoothingEnabled=!0,c.drawImage(t.canvas,0,0,r,a);const h=Wm(c.getImageData(0,0,r,a).data,e.threshold??.55),f=(e.radius??Math.max(i,s)*.02)/o,u=mh(h,r,a,f),p=mh(h,r,a,f*3),g=e.halo??.6,d=c.createImageData(r,a);for(let m=0;m<r*a;m++){for(let y=0;y<3;y++)d.data[m*4+y]=Math.round(Math.min(1,u[m*3+y]+p[m*3+y]*g)*255);d.data[m*4+3]=255}c.putImageData(d,0,0),t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation="lighter",t.globalAlpha=Math.max(0,e.strength??.9),t.imageSmoothingEnabled=!0,t.drawImage(l,0,0,i,s),t.restore()}function Ym(t,e,n){const i=n.width??6,s=n.taper??1,o=n.fade??1,r=n.opacity??1,a=n.blend==="add";if(t.save(),e.length>=2){const c=Xm(e,i,s,o,r);a?(t.globalCompositeOperation="lighter",Do(t,c,n.color)):qm(t,c,n.color)}const l=e[e.length-1];if(n.head&&l&&n.head.radius>0){a&&(t.globalCompositeOperation="lighter");const c=n.head.color??n.color,h=t.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,jm(t,c)),t.globalAlpha=r,t.fillStyle=h,t.beginPath(),t.arc(l.at.x,l.at.y,n.head.radius,0,Math.PI*2),t.fill()}t.restore()}function jm(t,e){t.fillStyle=e;const n=String(t.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 Xm(t,e,n,i,s){const o=t.map(c=>({x:c.at.x,y:c.at.y,width:e*(1-n*c.age)})),r=qr(o),a=Ur(o)??void 0,l=[];for(let c=0;c+1<t.length;c++){const h=(t[c].age+t[c+1].age)/2,f=s*(1-i*h);if(f<=0)continue;const u=c+2===t.length;l.push({corners:[r.left[c],r.left[c+1],r.right[c+1],r.right[c]],alpha:f,...u&&a&&{cap:a}})}return l}function Do(t,e,n){t.fillStyle=n;for(const i of e){const[s,o,r,a]=i.corners;t.globalAlpha=Math.min(1,i.alpha),t.beginPath(),t.moveTo(s.x,s.y),t.lineTo(o.x,o.y),i.cap&&t.arc(i.cap.x,i.cap.y,i.cap.radius,i.cap.start,i.cap.start-Math.PI,!0),t.lineTo(r.x,r.y),t.lineTo(a.x,a.y),t.closePath(),t.fill()}}function qm(t,e,n){const i=typeof t.getTransform=="function"?t.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,o=i?Math.sqrt(Math.abs(i.a*i.d-i.b*i.c)):1,r=e.map(d=>({...d,corners:d.corners.map(s),...d.cap&&{cap:{...d.cap,...s(d.cap),radius:d.cap.radius*o,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 r){const m=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,...m])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?ph(t,Math.ceil(c)+1-f,Math.ceil(h)+1-u):null,g=p?.getContext("2d");if(!p||!g){Do(t,e,n);return}g.translate(-f,-u),g.globalCompositeOperation="lighter",Do(g,r,n),t.save(),t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.drawImage(p,f,u),t.restore()}const Um=xt.to,Vm=xt.from,Gm=xt.fromTo,zm=xt.set,Jm=xt.timeline,Zm=xt.ticker,Qm=xt.splitText,ty=xt.context,ey=xt.matchMedia,ny=xt.quickTo,iy=xt.imageSequence,sy=xt.pageTransition;Dd(),b.ACTING_STYLES=ge,b.BEAT_FIELDS=Pi,b.CANVAS_PROPERTIES=Ii,b.CODE_LANGUAGES=Ei,b.CODE_PANEL_EDITS=go,b.CODE_THEME=Ec,b.Clock=wh,b.CompatTimeline=he,b.CustomBounce=Ba,b.CustomEase=Na,b.CustomWiggle=Wa,b.DANCE_STYLES=ne,b.DEFAULT_BAKE_INTERVAL_MS=zi,b.DEFAULT_INERTIA_FRICTION=Di,b.DEFAULT_LABELS=za,b.DEFAULT_SPRING=Ht,b.DEFAULT_TRANSITION=Bd,b.Draggable=gs,b.EXPRESSIONS=ct,b.FINGERS=fl,b.FLIPS=yn,b.FORMAT_VERSION=Oi,b.GAGS=oe,b.GAITS=$t,b.GAIT_CYCLE_MS=$o,b.HAND_REST=gt,b.HAND_SHAPES=bt,b.HUMAN_ACTING_RIG=Ic,b.HUMAN_EXPRESSIONS=zs,b.HUMAN_GAGS=mo,b.HUMAN_POSES=Gs,b.HUMAN_REST=yt,b.IDENTITY_CAMERA=kc,b.INERTIA_MAX_DURATION_MS=Ko,b.InertiaTrackPlayer=Pr,b.LiveTimeline=Bt,b.MORPH_SAMPLES=Wh,b.MUDRAS=ai,b.ManualClock=bh,b.MediaSync=$s,b.Observer=ma,b.POSES=_t,b.REMOVE_STYLES=Mi,b.REST_POSE=et,b.SCRIPT_ACTIONS=Mn,b.SPRING_MAX_DURATION_MS=Fi,b.SPRING_PRESETS=$n,b.SPRING_STEP_MS=we,b.STICK_ACTING_RIG=_c,b.ScrollAnimator=Oa,b.ScrollDriver=rn,b.ScrollMarkers=Ha,b.ScrollPin=Pa,b.SmoothScroll=As,b.SpringSampler=je,b.SpringTrackPlayer=xr,b.Stage=ha,b.Timeline=le,b.TinyflyPlayer=zn,b.TinyflySequencer=sl,b.TrackPlayer=Ln,b.VISEMES=re,b.ValueResolver=gu,b.VisibilityDriver=xa,b.actCharacterTracks=Ug,b.actKeyframes=wo,b.actTracks=Hc,b.actionNames=Mo,b.animatableProperties=uh,b.applyBloom=Km,b.applyCamera=dg,b.applyGroove=Vl,b.assertBeats=xo,b.backOut=Zo,b.bakeDanceTracks=ip,b.bakeEasing=Qi,b.bakeInertiaTrack=Zi,b.bakeSpringTrack=Ji,b.basicOutfit=Dg,b.beatAt=tp,b.beatAtTime=Dn,b.beatLength=rs,b.beatTime=Fn,b.beatsBetween=xu,b.bindChoiceHotspots=tl,b.blendPose=Le,b.boilFrame=Is,b.bounceOut=Jo,b.cameraFromValues=fg,b.cameraPoint=pg,b.cameraTracks=Iu,b.capabilities=fh,b.capabilitiesMarkdown=Dm,b.character=fc,b.characterAt=sg,b.characterHandPose=pc,b.characterJoints=dc,b.characterJointsInView=tg,b.characterObjects=ug,b.characterPoseTracks=og,b.characterTarget=ig,b.charactersFor=$r,b.checkBeats=Ao,b.checkCast=To,b.checkTracks=Lm,b.circlePath=bg,b.clamp01=Ss,b.clearMorphCache=zh,b.clearPathCache=Lh,b.clipErased=po,b.closestName=Nn,b.codePanel=Pg,b.codeTokens=xc,b.containerProgressAt=Ms,b.context=ty,b.create=Md,b.createControls=Za,b.createCubicBezier=Go,b.createLive=ja,b.createPen=Hs,b.createRandom=Je,b.createTrack=Rn,b.criticalDamping=Sh,b.customBounce=Br,b.customEase=Nr,b.customWiggle=Wr,b.danceFrame=hi,b.dancePose=G0,b.danceStance=ci,b.danceTaps=J0,b.danceTracks=np,b.danceTravel=fi,b.danceTravelTrack=Ql,b.dancer=ep,b.defineAction=rm,b.defineGait=am,b.describeTarget=hh,b.deserializeTimeline=xe,b.deserializeTrack=Hr,b.detectTempo=Pu,b.draggable=Lf,b.drawCartoonHand=si,b.drawCharacter=gc,b.drawCharacterInView=yc,b.drawDustPuff=Jg,b.drawEraser=uo,b.drawHand=fo,b.drawImpactStars=Zg,b.drawPencil=vc,b.drawSpeedLines=Rc,b.drawStickFigure=Yl,b.drawStickSmear=zg,b.drawTrail=Ym,b.drawnPathTarget=wg,b.easeIn=qo,b.easeInCubic=Ni,b.easeInOut=Vo,b.easeInOutCubic=qe,b.easeInOutQuad=Xo,b.easeInQuad=Yo,b.easeOut=Uo,b.easeOutCubic=Bi,b.easeOutQuad=jo,b.editDistance=jr,b.elasticOut=zo,b.ellipsePoints=Os,b.erasable=Mg,b.expandBeats=Po,b.expandParametricEasings=Er,b.flipPose=tc,b.flipTracks=bp,b.flipTravel=ec,b.formatVersionFor=Hi,b.from=Vm,b.fromJSON=fu,b.fromTo=Gm,b.gag=ko,b.gagDuration=vn,b.gaitPose=ml,b.gaitStrideLength=Ls,b.getEasingFunction=Mt,b.getInterpolator=ze,b.getMotionPathPoint=ts,b.getPathLength=Fh,b.getPointAtProgress=ir,b.gridLinesFor=wa,b.handAt=yg,b.handJoints=ii,b.handJointsAt=gl,b.handPath=ch,b.handPose=mt,b.handProp=gn,b.hasKeyframes=No,b.hashSeed=Pe,b.headPoint=N0,b.heldTime=Bo,b.humanFieldLabel=Hp,b.humanGag=Lg,b.humanGaitPose=Cg,b.humanGaitStrideLength=Rg,b.humanPlan=ic,b.humanPose=It,b.imageSequence=iy,b.inertiaDuration=ve,b.inertiaRest=ke,b.inertiaValueAt=In,b.inertiaVelocityAt=Ah,b.interpolateArray=vr,b.interpolateColor=kr,b.interpolateMotionPath=au,b.interpolateNumber=Ft,b.interpolatePathString=Mr,b.interpolateQuaternion=Sr,b.interpolateString=Gi,b.isCubicBezierEasing=be,b.isInertiaTrack=qt,b.isMotionPathPoint=yh,b.isMotionPathTrack=Ci,b.isParametricEasing=Ke,b.isPathData=Me,b.isSpringTrack=Ut,b.isTextTrack=En,b.isUnderdamped=vh,b.isUnresolved=pu,b.jointsInScene=wc,b.jointsToScene=Kl,b.linear=On,b.lipSyncKeyframes=So,b.lipSyncOver=jc,b.lipSyncTracks=sm,b.live=xt,b.mapEase=nn,b.mat4=Ku,b.matchMedia=ey,b.maxStaggerDistance=Li,b.mirrorHumanPose=Op,b.mirrorPose=Ul,b.mixHandPoses=Re,b.mixPoses=eg,b.morphPath=hr,b.mount=el,b.mountAll=il,b.narrationMarkers=Mu,b.narrationSceneAt=Tu,b.naturalRest=Xe,b.nearestBeat=Eu,b.nextBeat=Au,b.pageTransition=sy,b.parametricEasing=tr,b.parseEdge=ks,b.parsePath=ae,b.parseTrigger=vs,b.partialPath=Ce,b.pathLength=cl,b.persona=Cm,b.planNarration=Su,b.play=Sd,b.playSequence=Nd,b.playWhenVisible=Gf,b.playheadCrossings=ns,b.pointAlong=Zn,b.pointAtDistance=Ki,b.pointOnHead=Vp,b.pointsToPath=Xr,b.pose=wt,b.poseTracks=Y0,b.quat=nu,b.quickPlay=Nm,b.quickTo=ny,b.randomBetween=ss,b.randomChoice=du,b.randomSnapped=Rr,b.reachCharacter=ng,b.resolveActingStyle=$c,b.resolveCharacterPoseKeys=ho,b.resolveGait=fn,b.resolvePoseKeys=Ys,b.resolveSequence=Dr,b.resolveStickFrame=Bs,b.resolveStickPose=jl,b.resolveValue=os,b.ribbon=qr,b.ribbonHeadCap=Ur,b.rotateAbout=Qt,b.routineBeats=ui,b.rubberLimb=fe,b.scriptActionSummaries=Eo,b.scriptTracks=lh,b.scrollProgress=Vf,b.scrubOnScroll=Qf,b.scrubPath=vg,b.seatHeight=H0,b.serializeTimeline=Cr,b.serializeTrack=Ir,b.set=zm,b.shapeToPathData=Bn,b.simplifyKeyframes=Ar,b.skeletonInView=no,b.sketchPen=Qn,b.smoothToward=Aa,b.snapAxis=ba,b.snapConfig=$a,b.snapDuration=Ia,b.snapProgress=_a,b.solvePlanSpace=yi,b.soundsOf=Yc,b.speechDuration=ah,b.splitText=Qm,b.springDuration=Wo,b.springValueAt=kh,b.stagePlanSpace=eo,b.staggerDistance=Ri,b.staggerOffset=An,b.staggerOffsets=xn,b.staggerSpan=Ye,b.stepsDuration=qc,b.stepsEasing=Qo,b.stepsToKeys=vo,b.stickFigureAt=Ks,b.stickFigureJoints=ee,b.stickFigureTarget=Ws,b.stickToHuman=Rp,b.strideLength=Sl,b.syncMediaElement=Ga,b.talkingMouth=Ml,b.taperedLine=ti,b.taperedOutline=cn,b.textAt=_r,b.tf=Bm,b.ticker=Zm,b.timeline=Jm,b.to=Um,b.toJSON=uu,b.toKeyframedTrack=ou,b.toKeyframedTracks=ru,b.trackTargets=Jt,b.trailSamples=Hu,b.triggerDistance=_e,b.unknownName=At,b.unmount=Ld,b.vec3=Ru,b.walkPose=vl,b.withErased=Sg,b.withExpression=te,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
|