@algorisys/tinyfly 0.92.0 → 0.93.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 +466 -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 +123 -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 +2694 -1809
- package/lib/addons/target-properties-BtN9skb-.js +142 -0
- package/lib/browser/tinyfly.iife.js +9 -4
- package/lib/browser/tinyfly.js +6498 -5483
- 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 +95 -0
- package/lib/types/characters/acting/hand-path.d.ts +32 -0
- package/lib/types/characters/acting/index.d.ts +2 -0
- package/lib/types/characters/acting/script.d.ts +66 -7
- package/lib/types/characters/capabilities.d.ts +50 -0
- package/lib/types/characters/code-panel.d.ts +201 -0
- package/lib/types/characters/figure-actions.d.ts +11 -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 +2 -0
- 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 +12548 -0
- package/llms.txt +57 -0
- package/package.json +6 -2
- package/skills/tinyfly/SKILL.md +64 -0
- package/lib/addons/camera-C7bZOWMB.js +0 -33
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(b){"use strict";function Cs(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function ue(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const Xn=2;function qn(e){return e.some(t=>t.interpolation!==void 0)?2:1}function Ke(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 Vn(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 Un(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 zn(e,t="start"){if(e<=1)return 0;let n=0;for(let i=0;i<e;i++)n=Math.max(n,Un(i,e,t));return n}function Ye(e,t,n){if(n.offsets)return n.offsets[e]??0;const i=n.from??"start",s=Un(e,t,i);if(n.amount!==void 0){const r=zn(t,i);return r===0?0:n.amount*s/r}return n.each!==void 0?n.each*s:0}function Xe(e,t){return Array.from({length:e},(n,i)=>Ye(i,e,t))}function fe(e,t){return e<=1?0:Math.max(...Xe(e,t))}const Bt=1,Gn=6e4,qe=Gn/Bt,st={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},Ve={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 de{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/Bt);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/Bt-n;return i+(s-i)*r}settleTime(){return this.simulateTo(qe+1),this.settledStep!==null?this.settledStep*Bt:Gn}simulateTo(t){if(this.settledStep!==null)return;const n=Math.min(t,qe+1),i=Bt/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>qe&&(this.settledStep=qe)}}function Ul(e,t){return new de(e).valueAt(t)}function Rs(e){return new de(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 Ue(e){const t=e.friction??jn;return t>0?t:jn}function pe(e){return e.from+e.velocity/Ue(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 Nt(e){let t=Zl(pe(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 Wt(e){const t=Math.abs(Nt(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)/Ue(e);return Math.min(Os,i*1e3)}function ze(e,t){if(t<=0)return e.from;const n=Nt(e);if(t>=Wt(e))return n;const i=Ue(e);return e.from+(n-e.from)*(1-Math.exp(-i*t/1e3))}function Ql(e,t){const n=Ue(e),i=Nt(e);return t>=Wt(e)?0:(i-e.from)*n*Math.exp(-n*Math.max(0,t)/1e3)}const Ge=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,Jn=e=>e*e*e,Zn=e=>1-Math.pow(1-e,3),me=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Bs=Jn,Ns=Zn,Ws=me,tc={linear:Ge,"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":Jn,"ease-out-cubic":Zn,"ease-in-out-cubic":me};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 Qn(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 Qn(Ys(e.amplitude,e.period),e.mode);case"bounce":return Qn(Xs,e.mode);case"back":return Qn(qs(e.overshoot),e.mode)}}function J(e){return e===void 0?Ge:Cs(e)?Ks(e.points):ue(e)?Us(e):tc[e]??Ge}const zs=32,ec=256,Kt=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 ge(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=Kt.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(ge(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(ge(i,s,S[0]+A,S[1]+E)),i=S[0]+A,s=S[1]+E);break;case"L":u(ge(i,s,S[0]+A,S[1]+E)),i=S[0]+A,s=S[1]+E;break;case"H":u(ge(i,s,S[0]+A,s)),i=S[0]+A;break;case"V":u(ge(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 Kt.size>=ec&&Kt.delete(Kt.keys().next().value),Kt.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 ti(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 ti(n,Math.max(0,Math.min(1,t))*i)}function cc(){Kt.clear()}function hc(e){return Pt(e).totalLength}const uc=24,fc=320,dc=2.5,ye=72,pc=64,mc=.2,gc=128,be=new Map;let Je=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 ei(e,t){const n=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),i=ti(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(ei(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)%ye/ye:0,reversed:n<0};const s=er(tr(e,ye)),r=er(tr(t,ye)),o=ye;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(...ei(e,u)),h.push(...ei(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=be.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))};Je>=gc&&(be.clear(),Je=0);const h=String(i??"auto"),u=be.get(h)??new Map;be.set(h,u);const f=u.get(e)??new Map;return u.set(e,f),f.set(t,c),Je++,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(){be.clear(),Je=0,bt=void 0}function Yt(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const Xt=Math.PI/180,Tc=.9995;function ni(){return[0,0,0,1]}function qt(e,t){const n=Math.hypot(e[0],e[1],e[2]);if(n===0)return ni();const i=t*Xt/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 ii(ii(qt([0,1,0],t),qt([1,0,0],e)),qt([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/Xt,Math.atan2(r,u)/Xt,Math.atan2(o,a)/Xt]:[f/Xt,Math.atan2(-h,c)/Xt,0]}function ii(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?ni():[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:qt,fromEuler:Ec,identity:ni,length:rr,multiply:ii,normalize:wt,rotateVec3:Pc,slerp:or,toEuler:Ac},Symbol.toStringTag,{value:"Module"})),lt=(e,t,n)=>e+(t-e)*n,ar=512,si=new Map,ri=new Map;function lr(e){const t=si.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 si.size<ar&&si.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*\)/,oi=e=>Math.round(e).toString(16).padStart(2,"0");function Cc(e,t,n){return`#${oi(e)}${oi(t)}${oi(n)}`}function fr(e){const t=ri.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 ri.size<ar&&ri.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),ai=(e,t,n)=>n<1?e:t,gr=(e,t,n)=>ir(e,t,n);function we(e,t){return t==="slerp"?mr:typeof e=="number"?lt:Array.isArray(e)?pr:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?dr:Yt(e)?gr:ai:ai}const li=1e3/60;function ci(e,t={}){if(!gt(e))throw new Error(`bakeSpringTrack: track "${e.id}" is not a spring track`);const n=new de(e.spring);return yr(e,i=>n.valueAt(i),n.settleTime(),e.spring.from,e.spring.to,t)}function hi(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=>ze(n,i),Wt(n),n.from,Nt(n),t)}function yr(e,t,n,i,s,r){const o=r.intervalMs??li,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 ui(e,t,n,i={}){const s=i.intervalMs??li,r=typeof n=="function"?n:J(n),o=we(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)?ci(e,t):mt(e)?hi(e,t):e}function br(e,t={}){const n=e.keyframes;if(!n.some(r=>ue(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];ue(o.easing)?i.push(...ui(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=>ci(n,t)),e.filter(mt).map(n=>hi(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 Ze(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 Vt(e,t,n,i){const s=n??0;return!i||t<=1?s:s+Ye(e,t,i)}class Qe{track;targets;constructor(t){this.track=t,this.targets=kt(t)}getValueAtTime(t){return this.valueForOffset(t-Vt(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=Vt(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?fe(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 we(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 de(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-Vt(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=Vt(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?fe(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=Wt(t.inertia)}getValueAtTime(t){return ze(this.track.inertia,t-Vt(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=Vt(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:ze(this.track.inertia,t-r),start:r})}return i}getDuration(){const t=this.track.stagger?fe(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function fi(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 fi(e,s)}const di={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},Oc=20;function Sr(e){const t=di[e??"upperCase"]??e??di.upperCase,n=Array.from(t);return n.length>0?n:Array.from(di.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 ke{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=fi(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(Ke(t))this._trackPlayers.set(t.id,new Qe(t)),this._textTracks.set(t.id,t);else if(Vn(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 Qe(n)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new Qe(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:qn(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 pi(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)}:Ke(e)?{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:e.keyframes.map(mi),...ct(e)}:Vn(e)?{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:e.keyframes.map(mi),...ct(e)}:{id:e.id,target:e.target,property:e.property,keyframes:e.keyframes.map(mi),...e.interpolation!==void 0&&{interpolation:e.interpolation},...ct(e)}}function Er(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function mi(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(Ke(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 Ze({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:qn(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 Ut(e){const t=e.formatVersion??1;if(t>Xn)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${Xn}. Update tinyfly to play it.`);return new ke({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 Ut(t)}function zt(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 ve(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 gi(e,t,n){return t+e.next()*(n-t)}function Pr(e,t,n,i){if(i<=0)return gi(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 yi(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):gi(t.random,r,o)}return e}function Cr(e,t=0,n){const i=[];let s=t;for(const r of e){const o=yi(r,{base:s,random:n});i.push(o),typeof o=="number"&&(s=o)}return i}class Kc{random;constructor(t){this.random=ve(t)}get seed(){return this.random.seed}resolve(t,n=0){return yi(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 bi=e=>6e4/e.bpm;function tn(e,t){return e.offset+t*bi(e)}function en(e,t){return(t-e.offset)/bi(e)}function Zc(e,t){return tn(e,Math.round(en(e,t)))}function Qc(e,t){return tn(e,Math.ceil(en(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(en(e,t)-1e-9);;r++){const o=tn(e,r);if(o>n+1e-9)break;s.push({time:o,bar:(r%i+i)%i===0,n:r})}return s}const Gt=100;function eh(e,t,n={}){const i=n.minBpm??70,s=n.maxBpm??180,r=Math.max(1,Math.round(t/Gt)),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*Gt/s)),f=Math.min(a-1,Math.ceil(60*Gt/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*Gt/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*Gt/k,E=m>0?Math.max(0,Math.min(1,d(p)/m)):0,T=(M+.5)*1e3/Gt;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 ke({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=ve(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 nn(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 sn(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function rn(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function Se(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function Me(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function on(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 wi(e){return Math.hypot(e[0],e[1],e[2])}function Nr(e,t){return wi(rn(e,t))}function Te(e){const t=wi(e);return t===0?[0,0,0]:Se(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:sn,cross:on,distance:Nr,dot:Me,length:wi,lerp:Wr,normalize:Te,scale:Se,subtract:rn},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 an(e){return[e[0],0,0,0,0,e[1],0,0,0,0,e[2],0,0,0,0,1]}function Ee(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=Ee(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=Te(rn(e,t)),s=Te(on(n,i)),r=on(i,s);return[s[0],r[0],i[0],0,s[1],r[1],i[1],0,s[2],r[2],i[2],0,-Me(s,e),-Me(r,e),-Me(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:Ee,identity:Kr,invert:uh,lookAt:ph,multiply:_t,orthographic:dh,perspective:fh,scaling:an,transformPoint:qr,translation:Yr,transpose:hh},Symbol.toStringTag,{value:"Module"})),ln={"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 Ae(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 ln)return{easing:{type:"cubic-bezier",points:ln[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 ln?{easing:{type:"cubic-bezier",points:ln[n]}}:{easing:"ease-out"}}const Ur=new Map;function ki(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 vi(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=vi(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]=we(l[f])(l[f],c[f],h);return u}return we(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=Ye(d,g,{...c!==void 0?{amount:c}:{each:h??1},from:u}),k=c!==void 0?c:(h??1)*zn(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=vi(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 xe(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?Ae(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 Si=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 cn(e){const t={},n={};for(const[i,s]of Object.entries(e))Si.has(i)?t[i]=s:n[Mh[i]??i]=s;return{config:t,properties:n}}function hn(e,t){return e===void 0?t:e*1e3}function Mi(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(Yt(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"||!Yt(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 Ti(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?Ti(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(pe(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 Ve))throw new Error(`gsap-compat: unknown spring preset "${t.preset}" — use one of ${Object.keys(Ve).join(", ")}`);return{...t.preset?Ve[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=vi(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(t={}){this.options=t,this.timeline=new ke({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,Pe(n),i)}from(t,n,i){const{config:s,properties:r}=cn(Pe(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=Ei(a),u.text=typeof a=="object"?{...a,value:d}:d),l!==void 0&&(f.text=Ei(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}=cn(Pe(n));return this.build(t,r,Pe(i),s)}set(t,n,i){return this.build(t,void 0,{...Pe(n),duration:0},i)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(t){const n=Math.max(0,xe(t,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(t){return xe(t,this.context())}addLabel(t,n){return this.labels.set(t,xe(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=xe(n,this.context());for(const r of t.timeline.tracks){if(!("keyframes"in r))continue;const o=Ze({...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}=cn(i),{motionPath:a,text:l,scrambleText:c,inertia:h,...u}=o,f=this.targetsOf(t),d=xe(s,this.context()),m=hn(r.delay,0),p=hn(r.duration,500),g=Mi(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(Ze({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?Ei(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,Wt(C));for(const B of f)this.lastValues.set(`${B}|${P}`,Nt(C))}const v=((h!==void 0||k!==void 0)&&!S&&!A&&a===void 0?M:Math.max(p,M))+(g&&f.length>1?fe(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"?Ae(r):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&ue(s)){const c=a?.fn??J(s);return[o,...ui(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 Ae(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 Ei(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 Pe(e){return Ch(xh(e))}function Dh(e){return!Array.isArray(e)||e.length!==4?null:`matrix3d(${Ee(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);Ai(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(Ai(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 Ai(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 Ai(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 un(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"&&Yt(r))c=r;else{l=a(r);const A=l&&nn({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=un(f),[M,S]=s??[.5,.5];for(const A of t.targets.slice(1)){const E=un(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=nn({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"&&Yt(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=nn({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 xi{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 xi(e);return t.start(),t}const cu={x:"x",y:"y","x,y":"both"},Pi=e=>typeof e=="object"&&e!==null&&e.nodeType===1;function fo(e,t){const n=un(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):Pi(i.bounds)?i.bounds:null,h={bounds:(!l&&i.bounds&&!Pi(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?Ti(g.resistance):4),w=a(),k=h.bounds??{};let M,S;const A=g.end;if(Array.isArray(A)){const T=pe({from:w.x,velocity:o==="y"?0:p.x,friction:y}),v=pe({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 xi({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&&!Pi(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?Ti(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=un(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 _i(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 Ii=new WeakMap;function Ci(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);Ii.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),Ii.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),Ii.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 Hi(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 $i(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?Hi(i[0]):void 0,r=i[1]!==void 0?Hi(i[1]):void 0;return{elementFraction:s??0,viewportFraction:r??0,offsetPx:t}}function jt(e,t,n){const i=$i(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:Ri(-s/o)}function Ri(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 Oi(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=fn(e+t*Su);if(typeof n=="function")return fn(n(i));if(typeof n=="number")return n<=0?e:fn(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 fn(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=me,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 fn(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,Jt=[],Zt=new Set;let Li=!1;const Tu=()=>{Li||Zt.size===0||(Li=!0,queueMicrotask(()=>{Li=!1;for(const e of Zt)e.afterRefresh()}))},xo=()=>{for(const e of Zt)e.beforeRefresh();for(const e of Jt)e.refresh();for(const e of Zt)e.afterRefresh()};let Qt={width:0,height:0};const Po=()=>{const e=window.innerWidth,t=window.innerHeight,n=e===Qt.width&&t!==Qt.height,i=Math.abs(t-Qt.height)<Qt.height*.25,s=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&i&&s||(Qt={width:e,height:t},xo())};class _e{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}),Jt.length===0&&typeof window<"u"&&(Qt={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",Po,{passive:!0})),Jt.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Jt.splice(Jt.indexOf(this),1),Jt.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 Zt.add(t),()=>Zt.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,Ie(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?Ri((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=Ie(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=Oi(o,i.width,r,Ie(this.options.start)??"left right",t.shiftAt);this.startPx=c(h);const u=Ie(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(Oi(o,i.width,r,u,t.shiftAt)),this.markerGeometry=null}markersFor(t){const n=(r,o)=>{const a=Ie(r)??o;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=$i(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 Ie(e){return typeof e=="function"?e():e}function Eu(e){const t=new _e(e);return t.start(),t}const Fi=new Set,Au=16,_o=.5,xu=2;class Di{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),Fi.add(this),this.stopListening=_e.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const t of Fi)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),Fi.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const t of this.effects)Bi(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??me,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)Bi(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}Bi(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 Bi(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 Ni(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 _e({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?Ae(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?_i(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=>Ci(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)=>ki(e,Hr(t))},$o={create:(e,t)=>ki(e,{fn:$r(t)})},Ro={create:(e,t)=>ki(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=>Ni(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=Ni(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}=pi(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?Mi(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?Xe(s.length,o).map(g=>g/1e3):[0],h=this.compat.timeOf(i)/1e3+hn(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=Mi(l,this.staggerContext(t)),u=h?Xe(t.length,h).map(f=>f/1e3):t.map(()=>0);t.forEach((f,d)=>{const m=d===0?hn(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}=cn(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(Ni(e,r)),scrollBatch:(r,o)=>Yu(e,r,o).map(a=>i(a)),scrollTo:(r,o)=>Lo(s,e,r,o),refreshScroll:()=>{_e.refreshAll(),Di.refreshAll()},smoothScroll:(r={})=>{const o=typeof r.scroller=="string"?(e.collector?.scope??e.root).querySelector(r.scroller):r.scroller;return i(new Di({...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=>_i(e,r),flipFrom:(r,o)=>Ci(e,a=>new ut(e,a),r,o),flip:(r,o,a)=>{const l=_i(e,r);return o(),Ci(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))&&!Si.has(t))}function Bo(e,t,n,i,s){if(!Do(e))return e;const r={};for(const[o,a]of Object.entries(e))Si.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 Wi{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 dn{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=Ut({...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 Wi(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:Ut(r.timeline)})})}attachMedia(t,n){this.mediaSync=new Wi(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}=pi(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 dn(e,{...n,autoplay:!0});return await i.load(t),i}function Gu(e,t={}){return new dn(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){"use strict";function Io(t){return typeof t=="object"&&t!==null&&t.type==="cubic-bezier"}function Be(t){return typeof t=="object"&&t!==null&&t.type!=="cubic-bezier"}const Ii=2;function Hi(t){return t.some(e=>e.interpolation!==void 0)?2:1}function Tn(t){return t.property==="text"&&"textConfig"in t}function Xt(t){return t.kind==="inertia"&&"inertia"in t}function qt(t){return t.kind==="spring"&&"spring"in t}function Ci(t){return t.property==="motionPath"&&"motionPathConfig"in t}function uh(t){return typeof t=="object"&&t!==null&&"x"in t&&"y"in t&&"angle"in t}function Ho(t){return"keyframes"in t}class fh{_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 dh{_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 Co(t,e){if(!(e>0))return t;const n=1e3/e;return Math.floor(t/n+1e-9)*n}function Oi(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 Ri(t,e="start"){if(t<=1)return 0;let n=0;for(let i=0;i<t;i++)n=Math.max(n,Oi(i,t,e));return n}function En(t,e,n){if(n.offsets)return n.offsets[t]??0;const i=n.from??"start",s=Oi(t,e,i);if(n.amount!==void 0){const o=Ri(e,i);return o===0?0:n.amount*s/o}return n.each!==void 0?n.each*s:0}function An(t,e){return Array.from({length:t},(n,i)=>En(i,t,e))}function We(t,e){return t<=1?0:Math.max(...An(t,e))}const me=1,Li=6e4,xn=Li/me,$t={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},Pn={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 Ke{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??$t.stiffness,this.damping=e.damping??$t.damping,this.mass=e.mass??$t.mass,this.restDelta=e.restDelta??$t.restDelta,this.restSpeed=e.restSpeed??$t.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=e.velocity??$t.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/me);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/me-n;return i+(s-i)*o}settleTime(){return this.simulateTo(xn+1),this.settledStep!==null?this.settledStep*me:Li}simulateTo(e){if(this.settledStep!==null)return;const n=Math.min(e,xn+1),i=me/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>xn&&(this.settledStep=xn)}}function ph(t,e){return new Ke(t).valueAt(e)}function Oo(t){return new Ke(t).settleTime()}function gh(t){const e=t.stiffness??$t.stiffness,n=t.damping??$t.damping,i=t.mass??$t.mass;return n<2*Math.sqrt(e*i)}function mh(t){const e=t.stiffness??$t.stiffness,n=t.mass??$t.mass;return 2*Math.sqrt(e*n)}const Fi=4,yh=.002,bh=1e-4,Ro=6e4;function $n(t){const e=t.friction??Fi;return e>0?e:Fi}function Ye(t){return t.from+t.velocity/$n(t)}function wh(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 ye(t){let e=wh(Ye(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 be(t){const e=Math.abs(ye(t)-t.from);if(e===0)return 0;const n=t.restDelta??Math.max(bh,e*yh);if(n>=e)return 0;const i=Math.log(e/n)/$n(t);return Math.min(Ro,i*1e3)}function _n(t,e){if(e<=0)return t.from;const n=ye(t);if(e>=be(t))return n;const i=$n(t);return t.from+(n-t.from)*(1-Math.exp(-i*e/1e3))}function kh(t,e){const n=$n(t),i=ye(t);return e>=be(t)?0:(i-t.from)*n*Math.exp(-n*Math.max(0,e)/1e3)}const In=t=>t,Lo=t=>t*t,Fo=t=>1-(1-t)*(1-t),Do=t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,Di=t=>t*t*t,Ni=t=>1-Math.pow(1-t,3),je=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,No=Di,Bo=Ni,Wo=je,vh={linear:In,"ease-in":No,"ease-out":Bo,"ease-in-out":Wo,"ease-in-quad":Lo,"ease-out-quad":Fo,"ease-in-out-quad":Do,"ease-in-cubic":Di,"ease-out-cubic":Ni,"ease-in-out-cubic":je};function Ko(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,u=p=>((a*p+r)*p+o)*p,f=p=>((h*p+c)*p+l)*p,d=p=>(3*a*p+2*r)*p+o,g=p=>{let m=p;for(let k=0;k<8;k++){const E=u(m)-p;if(Math.abs(E)<1e-7)return m;const T=d(m);if(Math.abs(T)<1e-7)break;m-=E/T}let y=0,w=1;for(m=p;y<w;){const k=u(m);if(Math.abs(k-p)<1e-7)return m;p>k?y=m:w=m,m=(y+w)/2}return m};return p=>{if(p<=0)return 0;if(p>=1)return 1;const m=g(p);return f(m)}}function Bi(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 Yo(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 Xo(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 Uo(t){switch(t.type){case"steps":return qo(t.count,t.position);case"elastic":return Bi(Yo(t.amplitude,t.period),t.mode);case"bounce":return Bi(jo,t.mode);case"back":return Bi(Xo(t.overshoot),t.mode)}}function vt(t){return t===void 0?In:Io(t)?Ko(t.points):Be(t)?Uo(t):vh[t]??In}const Vo=32,Sh=256,we=new Map,Mh=/[MmLlHhVvCcSsQqTtAaZz]/,Th=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Eh={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Ah(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(Mh.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=Th.exec(t.slice(n));if(!l)break;i.args.push(parseFloat(l[0])),n+=l[0].length}return e}function xh(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 u=s*Math.PI/180,f=Math.cos(u),d=Math.sin(u),g=(t-a)/2,p=(e-l)/2,m=f*g+d*p,y=-d*g+f*p,w=m*m/(c*c)+y*y/(h*h);if(w>1){const j=Math.sqrt(w);c*=j,h*=j}const k=o===r?-1:1,E=c*c*h*h-c*c*y*y-h*h*m*m,T=c*c*y*y+h*h*m*m,S=k*Math.sqrt(Math.max(0,E/T)),P=S*c*y/h,O=-S*h*m/c,A=f*P-d*O+(t+a)/2,C=d*P+f*O+(e+l)/2,I=(j,v,x,M)=>{const _=j*x+v*M,H=Math.sqrt((j*j+v*v)*(x*x+M*M)),D=Math.acos(Math.max(-1,Math.min(1,_/H)));return j*M-v*x<0?-D:D},R=I(1,0,(m-P)/c,(y-O)/h);let F=I((m-P)/c,(y-O)/h,(-m-P)/c,(-y-O)/h);!r&&F>0&&(F-=2*Math.PI),r&&F<0&&(F+=2*Math.PI);const N=Math.max(1,Math.ceil(Math.abs(F)/(Math.PI/2))),X=F/N,G=4/3*Math.tan(X/4),$=j=>{const v=c*Math.cos(j),x=h*Math.sin(j);return[f*v-d*x+A,d*v+f*x+C]},L=j=>{const v=-c*Math.sin(j),x=h*Math.cos(j);return[f*v-d*x,d*v+f*x]},W=[];for(let j=0;j<N;j++){const v=R+j*X,x=v+X,[M,_]=$(v),[H,D]=j===N-1?[a,l]:$(x),[K,B]=L(v),[Y,J]=L(x);W.push([M+G*K,_+G*B,H-G*Y,D-G*J,H,D])}return W}function Ut(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 Go(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 Xe(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,u=e,f=0;for(let d=1;d<=Vo;d++){const g=d/Vo,p=Ut(t,i,o,a,g),m=Ut(e,s,r,l,g);f+=Math.hypot(p-h,m-u),c.push(f),h=p,u=m}return{subpath:0,type:"C",points:[i,s,o,r,a,l],startX:t,startY:e,endX:a,endY:l,length:f,lengths:c}}function re(t){const e=we.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,u=p=>{c<0&&(c=0),p.subpath=c,n.push(p)};for(const{type:p,args:m}of Ah(t)){const y=p.toUpperCase(),w=p!==y,k=Eh[y];if(y==="Z"){(i!==o||s!==r)&&u(Xe(i,s,o,r)),c>=0&&h.add(c),i=o,s=r,a=l=null;continue}for(let E=0;E+k<=m.length;E+=k){const T=m.slice(E,E+k),S=w?i:0,P=w?s:0;let O=null,A=null;switch(y){case"M":E===0?(i=T[0]+S,s=T[1]+P,o=i,r=s,(c<0||n[n.length-1]?.subpath===c)&&c++):(u(Xe(i,s,T[0]+S,T[1]+P)),i=T[0]+S,s=T[1]+P);break;case"L":u(Xe(i,s,T[0]+S,T[1]+P)),i=T[0]+S,s=T[1]+P;break;case"H":u(Xe(i,s,T[0]+S,s)),i=T[0]+S;break;case"V":u(Xe(i,s,i,T[0]+P)),s=T[0]+P;break;case"C":{const C=[T[0]+S,T[1]+P,T[2]+S,T[3]+P,T[4]+S,T[5]+P];u(Hn(i,s,C)),O=[C[2],C[3]],i=C[4],s=C[5];break}case"S":{const[C,I]=a?[2*i-a[0],2*s-a[1]]:[i,s],R=[C,I,T[0]+S,T[1]+P,T[2]+S,T[3]+P];u(Hn(i,s,R)),O=[R[2],R[3]],i=R[4],s=R[5];break}case"Q":case"T":{let C=i,I=s;y==="Q"?(C=T[0]+S,I=T[1]+P):l&&(C=2*i-l[0],I=2*s-l[1]);const R=y==="Q"?T[2]+S:T[0]+S,F=y==="Q"?T[3]+P:T[1]+P;u(Hn(i,s,[i+2/3*(C-i),s+2/3*(I-s),R+2/3*(C-R),F+2/3*(I-F),R,F])),A=[C,I],i=R,s=F;break}case"A":{const C=T[5]+S,I=T[6]+P;let R=i,F=s;for(const N of xh(i,s,T[0],T[1],T[2],T[3],T[4],C,I))u(Hn(R,F,N)),R=N[4],F=N[5];i=C,s=I;break}}a=O,l=A}}const f=n.reduce((p,m)=>p+m.length,0),d=[];for(let p=0;p<n.length;){const m=n[p].subpath;let y=p,w=0;for(;y<n.length&&n[y].subpath===m;)w+=n[y++].length;const k=n[p],E=n[y-1],T=h.has(m)||Math.abs(E.endX-k.startX)<1e-9&&Math.abs(E.endY-k.startY)<1e-9;d.push({start:p,end:y,length:w,closed:T}),p=y}const g={segments:n,totalLength:f,subpaths:d};return we.size>=Sh&&we.delete(we.keys().next().value),we.set(t,g),g}function Ph(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 $h(t,e){if(t.type==="L"){const u=t.length>0?Math.max(0,Math.min(1,e/t.length)):0;return{x:t.startX+(t.endX-t.startX)*u,y:t.startY+(t.endY-t.startY)*u,angle:Math.atan2(t.endY-t.startY,t.endX-t.startX)*180/Math.PI}}const[n,i,s,o,r,a]=t.points,l=Ph(t,e);let c=Go(t.startX,n,s,r,l),h=Go(t.startY,i,o,a,l);if(Math.hypot(c,h)<1e-9){const u=l<.5?Math.min(1,l+.001):Math.max(0,l-.001),f=Ut(t.startX,n,s,r,u),d=Ut(t.startY,i,o,a,u),g=Ut(t.startX,n,s,r,l),p=Ut(t.startY,i,o,a,l);c=l<.5?f-g:g-f,h=l<.5?d-p:p-d}return{x:Ut(t.startX,n,s,r,l),y:Ut(t.startY,i,o,a,l),angle:Math.atan2(h,c)*180/Math.PI}}function Wi(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 $h(r,e-s);s+=r.length}return{x:0,y:0,angle:0}}function zo(t,e){const{segments:n,totalLength:i}=re(t);return Wi(n,Math.max(0,Math.min(1,e))*i)}function _h(){we.clear()}function Ih(t){return re(t).totalLength}const Hh=24,Ch=320,Oh=2.5,qe=72,Rh=64,Lh=.2,Fh=128,Ue=new Map;let Cn=0,Vt;const Jo=t=>Math.round(t*100)/100;function Zo(t,e){const{segments:n,subpaths:i,totalLength:s}=re(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 Ki(t,e){const n=t.closed?(e%1+1)%1:Math.max(0,Math.min(1,e)),i=Wi(t.segments,n*t.length,t.start,t.end);return[i.x,i.y]}function Qo(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 tr(t,e){const n=[];for(let i=0;i<e;i++)n.push(Ki(t,t.closed?i/e:i/(e-1)));return n}function er(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 Dh(t,e,n){const i=t.closed&&e.closed;if(n!==void 0)return{offset:i?Math.abs(n)%qe/qe:0,reversed:n<0};const s=er(tr(t,qe)),o=er(tr(e,qe)),r=qe;let a={offset:0,reversed:!1},l=1/0;for(const c of[!1,!0]){const h=i?r:1;for(let u=0;u<h;u++){let f=0;for(let d=0;d<r&&f<l;d++){const g=i?c?(u-d+r)%r:(d+u)%r:c?r-1-d:d,p=s[d][0]-o[g][0],m=s[d][1]-o[g][1];f+=p*p+m*m}f<l&&(l=f,a={offset:i?u/r:0,reversed:c})}}return a}function Nh(t,e,n){return n?((e.reversed?e.offset-t:t+e.offset)%1+1)%1:e.reversed?1-t:t}function Bh(t,e,n){return n?((e.reversed?e.offset-t:t-e.offset)%1+1)%1:e.reversed?1-t:t}function Wh(t,e,n){const i=t.closed&&e.closed,s=Dh(t,e,n.shapeIndex),o=Math.max(Hh,Math.min(Ch,Math.ceil(Math.max(t.length,e.length)/Oh))),r=new Set,a=u=>r.add(Math.round(u*1e7)/1e7);for(let u=0;u<=o;u++)a(u/o);for(const u of Qo(t))a(u);for(const u of Qo(e))a(Bh(u,s,i));let l=[...r].sort((u,f)=>u-f);i&&(l=l.filter(u=>u<1));const c=[],h=[];for(const u of l)c.push(...Ki(t,u)),h.push(...Ki(e,Nh(u,s,i)));return Kh({from:c,to:h,closed:i})}function Kh(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=Lh;for(let h=r+1;h<a;h++){const u=Math.max(nr(t.from,r,a,h),nr(t.to,r,a,h));u>c&&(c=u,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 nr(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,u=h===0?0:Math.max(0,Math.min(1,(l*r+c*a)/h));return Math.hypot(l-u*r,c-u*a)}function Yh(t,e,n){const i=n.shapeIndex;if(Vt&&Vt.from===t&&Vt.to===e&&Vt.shapeIndex===i)return Vt.plan;const o=Ue.get(String(i??"auto"))?.get(t)?.get(e);if(o)return Vt={from:t,to:e,shapeIndex:i,plan:o},o;const r=re(t).subpaths.filter(d=>d.length>0).length===re(e).subpaths.filter(d=>d.length>0).length,a=Zo(t,!r),l=Zo(e,!r),c={pairs:a.map((d,g)=>Wh(d,l[g],n))};Cn>=Fh&&(Ue.clear(),Cn=0);const h=String(i??"auto"),u=Ue.get(h)??new Map;Ue.set(h,u);const f=u.get(t)??new Map;return u.set(t,f),f.set(e,c),Cn++,Vt={from:t,to:e,shapeIndex:i,plan:c},c}function ir(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=Yh(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=Jo(a.from[l]+(a.to[l]-a.from[l])*s),h=Jo(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 jh(){Ue.clear(),Cn=0,Vt=void 0}function ke(t){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(t)}const ve=Math.PI/180,Xh=.9995;function Yi(){return[0,0,0,1]}function Se(t,e){const n=Math.hypot(t[0],t[1],t[2]);if(n===0)return Yi();const i=e*ve/2,s=Math.sin(i)/n;return[t[0]*s,t[1]*s,t[2]*s,Math.cos(i)]}function qh(t,e,n){return ji(ji(Se([0,1,0],e),Se([1,0,0],t)),Se([0,0,1],n))}function Uh(t){const[e,n,i,s]=Gt(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),u=1-2*(e*e+n*n),f=Math.asin(Math.max(-1,Math.min(1,-l)));return Math.abs(l)<.9999999?[f/ve,Math.atan2(o,u)/ve,Math.atan2(r,a)/ve]:[f/ve,Math.atan2(-h,c)/ve,0]}function ji(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 sr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function or(t){return Math.hypot(t[0],t[1],t[2],t[3])}function Gt(t){const e=or(t);return e===0?Yi():[t[0]/e,t[1]/e,t[2]/e,t[3]/e]}function Vh(t){return[-t[0],-t[1],-t[2],t[3]]}function rr(t,e,n){const i=Gt(t);let s=Gt(e),o=sr(i,s);if(o<0&&(s=[-s[0],-s[1],-s[2],-s[3]],o=-o),o>Xh)return Gt([i[0]+(s[0]-i[0])*n,i[1]+(s[1]-i[1])*n,i[2]+(s[2]-i[2])*n,i[3]+(s[3]-i[3])*n]);const r=Math.acos(o),a=Math.sin(r),l=Math.sin((1-n)*r)/a,c=Math.sin(n*r)/a;return Gt([i[0]*l+s[0]*c,i[1]*l+s[1]*c,i[2]*l+s[2]*c,i[3]*l+s[3]*c])}function Gh(t,e){const[n,i,s,o]=Gt(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 zh=Object.freeze(Object.defineProperty({__proto__:null,conjugate:Vh,dot:sr,fromAxisAngle:Se,fromEuler:qh,identity:Yi,length:or,multiply:ji,normalize:Gt,rotateVec3:Gh,slerp:rr,toEuler:Uh},Symbol.toStringTag,{value:"Module"})),Ot=(t,e,n)=>t+(e-t)*n,ar=512,Xi=new Map,qi=new Map;function lr(t){const e=Xi.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 Xi.size<ar&&Xi.set(t,i),i}const cr=t=>t.charCodeAt(0)===35,hr=t=>t.startsWith("rgb"),ur=t=>t.startsWith("rgba"),Jh=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Ui=t=>Math.round(t).toString(16).padStart(2,"0");function Zh(t,e,n){return`#${Ui(t)}${Ui(e)}${Ui(n)}`}function fr(t){const e=qi.get(t);if(e)return e;const n=t.match(Jh);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 qi.size<ar&&qi.set(t,r),r}const dr=(t,e,n)=>{if(cr(t)&&cr(e)){const[i,s,o]=lr(t),[r,a,l]=lr(e),c=Ot(i,r,n),h=Ot(s,a,n),u=Ot(o,l,n);return Zh(c,h,u)}if((hr(t)||ur(t))&&(hr(e)||ur(e))){const i=fr(t),s=fr(e),o=Math.round(Ot(i[0],s[0],n)),r=Math.round(Ot(i[1],s[1],n)),a=Math.round(Ot(i[2],s[2],n));if(i.length===4||s.length===4){const l=i[3]??1,c=s[3]??1,h=Ot(l,c,n);return`rgba(${o}, ${r}, ${a}, ${h})`}return`rgb(${o}, ${r}, ${a})`}return n<1?t:e},pr=(t,e,n)=>{const i=Math.min(t.length,e.length),s=[];for(let o=0;o<i;o++)s.push(Ot(t[o],e[o],n));return s},gr=(t,e,n)=>rr(t,e,n),Vi=(t,e,n)=>n<1?t:e,mr=(t,e,n)=>ir(t,e,n);function Ve(t,e){return e==="slerp"?gr:typeof t=="number"?Ot:Array.isArray(t)?pr:typeof t=="string"?t.startsWith("#")||t.startsWith("rgb")?dr:ke(t)?mr:Vi:Vi}const Gi=1e3/60;function zi(t,e={}){if(!qt(t))throw new Error(`bakeSpringTrack: track "${t.id}" is not a spring track`);const n=new Ke(t.spring);return yr(t,i=>n.valueAt(i),n.settleTime(),t.spring.from,t.spring.to,e)}function Ji(t,e={}){if(!Xt(t))throw new Error(`bakeInertiaTrack: track "${t.id}" is not an inertia track`);const n=t.inertia;return yr(t,i=>_n(n,i),be(n),n.from,ye(n),e)}function yr(t,e,n,i,s,o){const r=o.intervalMs??Gi,a=o.tolerance??.01,l=t.delay??0,c=[];for(let u=0;u<=n;u+=r)c.push({time:u+l,value:e(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:t.id,target:t.target,property:t.property,keyframes:a>0?wr(c,a):c,...t.targets&&{targets:[...t.targets]},...t.stagger&&{stagger:{...t.stagger}}}}function Zi(t,e,n,i={}){const s=i.intervalMs??Gi,o=typeof n=="function"?n:vt(n),r=Ve(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 u=h/a;l.push({time:t.time+h,value:r(t.value,e.value,o(u)),easing:"linear"})}const c=o(1);return l.push({...e,...c!==1&&{value:r(t.value,e.value,c)},easing:"linear"}),l}function Qh(t,e){return qt(t)?zi(t,e):Xt(t)?Ji(t,e):t}function br(t,e={}){const n=t.keyframes;if(!n.some(o=>Be(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];Be(r.easing)?i.push(...Zi(n[o-1],r,r.easing,s)):i.push(r)}return{...t,keyframes:i}}function tu(t,e){return t.filter(Ho).map(n=>br(n,e)).concat(t.filter(qt).map(n=>zi(n,e)),t.filter(Xt).map(n=>Ji(n,e)))}function wr(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 On(t){const e=[...t.keyframes].sort((n,i)=>n.time-i.time);return{...t,keyframes:e}}function zt(t){return t.targets&&t.targets.length>0?t.targets:[t.target]}function Me(t,e,n,i){const s=n??0;return!i||e<=1?s:s+En(t,e,i)}class Rn{track;targets;constructor(e){this.track=e,this.targets=zt(e)}getValueAtTime(e){return this.valueForOffset(e-Me(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=Me(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?We(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=vt(s.easing)(r);return Ve(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 kr{track;targets;sampler;constructor(e){this.track=e,this.targets=zt(e),this.sampler=new Ke(e.spring)}getValueAtTime(e){return this.sampler.valueAt(e-Me(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=Me(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?We(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+e}getTrack(){return this.track}}class vr{track;targets;duration;constructor(e){this.track=e,this.targets=zt(e),this.duration=be(e.inertia)}getValueAtTime(e){return _n(this.track.inertia,e-Me(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=Me(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:_n(this.track.inertia,e-o),start:o})}return i}getDuration(){const e=this.track.stagger?We(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+e}getTrack(){return this.track}}function Qi(t,e){const n={...zo(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 u=n.angle*Math.PI/180,f=Math.cos(u),d=Math.sin(u);n.angle=Math.atan2(s*f+r*d,i*f+o*d)*180/Math.PI}return t.autoRotate&&t.rotateOffset&&(n.angle+=t.rotateOffset),n}function eu(t,e,n,i){const s=e+(n-e)*i;return Qi(t,s)}const ts={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},nu=20;function Sr(t){const e=ts[t??"upperCase"]??t??ts.upperCase,n=Array.from(e);return n.length>0?n:Array.from(ts.upperCase)}function iu(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 Mr(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)),u=Math.floor(h*a.length),f=t.tweenLength===!1?a.length:Math.round(r.length+(a.length-r.length)*o),d=Sr(t.chars),g=t.refreshRate??nu,p=g>0?Math.floor(n*g/1e3):0,m=t.seed??1;let y="";for(let w=0;w<f;w++){const k=l?w>=f-u:w<u,E=l?a[a.length-(f-w)]:a[w];k&&E!==void 0||E===" "||E===`
|
|
2
|
+
`?y+=E:y+=d[iu(m,w,p)%d.length]}return y}class ae{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=Co(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}`,u=c<=e,f=i.get(h);(!f||(u!==f.started?u:u?c>=f.start:c<=f.start))&&i.set(h,{trackId:s,target:a,property:r,value:l,start:c,started:u})}}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",Mr(l.textConfig,o,Math.max(0,r)));return}const c=this._motionPathTracks.get(n);if(c&&typeof o=="number"){const h=Qi(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 zt(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,Xt(e)){this._trackPlayers.set(e.id,new vr(e));return}if(qt(e)){this._trackPlayers.set(e.id,new kr(e)),this._springTracks.set(e.id,e);return}if(Tn(e))this._trackPlayers.set(e.id,new Rn(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 Rn(n)),this._motionPathTracks.set(e.id,e)}else this._trackPlayers.set(e.id,new Rn(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(qt(i)||Xt(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=zt(r).filter(u=>zt(i).includes(u));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 u of a)e.push({target:u,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&&!zt(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 su=100;function es(t,e,n,i){const s=[],o=[],{duration:r,alternate:a}=i,l=(d,g,p,m)=>{o.push([d,g]);const y=[];t.forEach((w,k)=>{(p==="forward"?(m?w>=d:w>d)&&w<=g:(m?w<=d:w<d)&&w>=g)&&y.push(k)}),y.sort((w,k)=>(p==="forward"?t[w]-t[k]:t[k]-t[w])||w-k);for(const w of y)s.push({kind:"event",index:w,direction:p})};let c=e.time,h=e.direction,u=e.fresh===!0;const f=Math.min(su,Math.max(0,n.iteration-e.iteration));for(let d=0;d<f;d++){const g=h==="forward"?r:0;l(c,g,h,u),s.push({kind:"repeat"}),a?(h=h==="forward"?"reverse":"forward",c=g,u=!1):(c=h==="forward"?0:r,u=!0)}return f>0&&i.holding&&!a?{crossings:s,passes:o}:(l(c,n.time,h,u),{crossings:s,passes:o})}function Tr(t){return Xt(t)?{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Er(t.inertia),...Rt(t)}:qt(t)?{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...Rt(t)}:Tn(t)?{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:t.keyframes.map(ns),...Rt(t)}:Ci(t)?{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:t.keyframes.map(ns),...Rt(t)}:{id:t.id,target:t.target,property:t.property,keyframes:t.keyframes.map(ns),...t.interpolation!==void 0&&{interpolation:t.interpolation},...Rt(t)}}function Er(t){return{...t,...Array.isArray(t.end)&&{end:[...t.end]}}}function ns(t){return{time:t.time,value:t.value,...t.easing&&{easing:t.easing}}}function Rt(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 Ar(t){if(Xt(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:Er(e.inertia),...Rt(e)}}if(qt(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...Rt(e)}}if(Tn(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),...Rt(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,...Rt(e)}}return On({id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,...t.interpolation!==void 0&&{interpolation:t.interpolation},...Rt(t)})}function xr(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(Tr),...t.captions&&{captions:JSON.parse(JSON.stringify(t.captions))}}}function Te(t){const e=t.formatVersion??1;if(e>Ii)throw new Error(`tinyfly: this animation uses format version ${e}, but this tinyfly reads up to version ${Ii}. Update tinyfly to play it.`);return new ae({id:t.id,name:t.name,config:t.config,tracks:t.tracks.map(Ar),captions:t.captions})}function ou(t){return JSON.stringify(xr(t))}function ru(t){const e=JSON.parse(t);return Te(e)}function Ee(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 Ge(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 is(t,e,n){return e+t.next()*(n-e)}function Pr(t,e,n,i){if(i<=0)return is(t,e,n);const s=Math.floor((n-e)/i),o=Math.round(t.next()*s);return e+o*i}function au(t,e){if(e.length!==0)return e[Math.floor(t.next()*e.length)]}const $r=/^([+\-*/])=\s*(-?[\d.]+)$/,_r=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function lu(t){return typeof t!="string"?!1:$r.test(t.trim())||_r.test(t.trim())}function ss(t,e={}){if(typeof t!="string")return t;const n=t.trim(),i=$r.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=_r.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?Pr(e.random,o,r,a):is(e.random,o,r)}return t}function Ir(t,e=0,n){const i=[];let s=e;for(const o of t){const r=ss(o,{base:s,random:n});i.push(r),typeof r=="number"&&(s=r)}return i}class cu{random;constructor(e){this.random=Ge(e)}get seed(){return this.random.seed}resolve(e,n=0){return ss(e,{base:n,random:this.random})}resolveSequence(e,n=0){return Ir(e,n,this.random)}}const hu=600;function Hr(t){if(Array.isArray(t)){const[f,d,g,p]=t;return{fn:Rr(f,d,g,p),bezier:[f,d,g,p]}}const{segments:e}=re(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=f=>(f-n)/o,l=f=>(f-i)/r;if(e.length===1&&s.type==="C"){const[f,d,g,p]=s.points,m=[a(f),l(d),a(g),l(p)];return{fn:Rr(...m),bezier:m}}const c=[],h=[],u=Math.max(8,Math.ceil(hu/e.length));for(const f of e)for(let d=c.length===0?0:1;d<=u;d++){const[g,p]=uu(f,d/u);c.push(a(g)),h.push(l(p))}return{fn:fu(c,h)}}function Cr(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 Or(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 uu(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 fu(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 Rr(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 u=s(a,t,n)-r,f=o(a,t,n);if(Math.abs(u)<1e-6)return s(a,e,i);if(Math.abs(f)<1e-6)break;a-=u/f}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 du=350,pu=300,gu=550;function mu(t,e={}){const n=e.lead??du,i=e.gap??pu,s=e.tail??gu,o=[];let r=0;return t.forEach((a,l)=>{const c=[];let h=r+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);o.push({id:a.id??`s${l}`,start:r,duration:u-r,cues:c}),r=u}),{duration:r,scenes:o,cues:o.flatMap(a=>a.cues)}}function yu(t){return t.cues.map(e=>({id:e.id,time:e.start,label:e.text}))}function bu(t,e){let n=t.scenes[0];for(const i of t.scenes)if(e>=i.start)n=i;else break;return n}const os=t=>6e4/t.bpm;function Ln(t,e){return t.offset+e*os(t)}function Fn(t,e){return(e-t.offset)/os(t)}function wu(t,e){return Ln(t,Math.round(Fn(t,e)))}function ku(t,e){return Ln(t,Math.ceil(Fn(t,e)-1e-9))}function vu(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(Fn(t,e)-1e-9);;o++){const r=Ln(t,o);if(r>n+1e-9)break;s.push({time:r,bar:(o%i+i)%i===0,n:o})}return s}const Ae=100;function Su(t,e,n={}){const i=n.minBpm??70,s=n.maxBpm??180,o=Math.max(1,Math.round(e/Ae)),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 A=0;A<a;A++){let C=0;for(let I=A*o;I<(A+1)*o;I++)C+=t[I]*t[I];l[A]=Math.log(1e-6+C/o)}const c=new Float64Array(a);for(let A=1;A<a;A++)c[A]=Math.max(0,l[A]-l[A-1]);const h=c.reduce((A,C)=>A+C,0)/a;for(let A=0;A<a;A++)c[A]=Math.max(0,c[A]-h);const u=Math.max(1,Math.floor(60*Ae/s)),f=Math.min(a-1,Math.ceil(60*Ae/i)),d=A=>{let C=0;for(let I=A;I<a;I++)C+=c[I]*c[I-A];return C/(a-A)};let g=0;for(let A=0;A<a;A++)g+=c[A]*c[A];g/=a;let p=u,m=-1/0;for(let A=u;A<=f;A++){const C=60*Ae/A,I=Math.exp(-.5*(Math.log2(C/120)/.9)**2),R=d(A)*I;R>m&&(m=R,p=A)}const y=A=>{const C=Math.floor(A);return C<0||C+1>=a?0:c[C]+(c[C+1]-c[C])*(A-C)},w=(A,C)=>{let I=0;for(let R=C;R<a;R+=A)I+=y(R);return I};let k=p,E=0,T=-1/0;for(let A=p-.6;A<=p+.6+1e-9;A+=.02){if(A<1)continue;const C=Math.max(1,Math.round(A*4));for(let I=0;I<C;I++){const R=I/C*A,F=w(A,R);F>T&&(T=F,E=R,k=A)}}const S=60*Ae/k,P=g>0?Math.max(0,Math.min(1,d(p)/g)):0,O=(E+.5)*1e3/Ae;return{bpm:Math.round(S*100)/100,offset:Math.round(O%(6e4/S)),confidence:P}}const Mu=600,Tu=250,Lr=1;function Eu(t,e){const n=e.target??"Camera",i={x:e.stage.width/2,y:e.stage.height/2},s={},o=(u,f,d,g)=>{const p=s[u]??=[];for(;p.length>0&&p[p.length-1].time>=f;)p.pop();p.push({time:f,value:d,...g?{easing:g}:{}})},r=u=>{const f=u.rotate*Math.PI/180,d=(u.focusX-i.x)*u.scale,g=(u.focusY-i.y)*u.scale;return{x:-(d*Math.cos(f)-g*Math.sin(f)),y:-(d*Math.sin(f)+g*Math.cos(f)),scale:u.scale,rotate:u.rotate}},a=(u,f,d)=>{const g=r(f);for(const p of["x","y","scale","rotate"])o(p,u,g[p],d)};let l={focusX:i.x,focusY:i.y,scale:1,rotate:0};const c=[...t].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??Mu);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??Tu,g=new ae({id:"follow",tracks:[{id:"x",target:"s",property:"x",keyframes:f.x}]}),p=w=>g.getStateAtTime(w).values.get("s")?.get("x")??l.focusX,m=[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 m){const k=f.x.find(E=>E.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,g=1e3/(u.shake.frequency??24),p=Ge(u.shake.seed??Math.round(u.at)+1),m=()=>p.next()*2-1;for(const y of["shakeX","shakeY","shakeRotate"])o(y,u.at,0);for(let y=u.at+g;y<u.at+u.duration;y+=g){const w=1-(y-u.at)/u.duration;o("shakeX",y,m()*f*w),o("shakeY",y,m()*f*w),o("shakeRotate",y,m()*d*w)}for(const y of["shakeX","shakeY","shakeRotate"])o(y,u.at+u.duration,0,"ease-out")}return Object.entries(s).map(([u,f])=>({id:`${n}-${u}`,target:n,property:u,keyframes:f}))}function Fr(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 Dn(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=Fr(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 Bt(t,e,n,i){const s=typeof e=="string"?i??Dn(e,n):void 0;return`Unknown ${t} ${JSON.stringify(e)}${s?`: did you mean "${s}"?`:"."} Known: ${n.join(", ")}`}const Lt=t=>Math.round(t*1e3)/1e3;function Dr(t,e={}){if(t.length===0)return"";const n=e.curviness??1,i=e.closed??!1,s=t.length;let o=`M${Lt(t[0].x)} ${Lt(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),u=r(l+1),f=r(l+2);if(n===0){o+=` L${Lt(u.x)} ${Lt(u.y)}`;continue}const d=n/6,g=h.x+(u.x-c.x)*d,p=h.y+(u.y-c.y)*d,m=u.x-(f.x-h.x)*d,y=u.y-(f.y-h.y)*d;o+=` C${Lt(g)} ${Lt(p)} ${Lt(m)} ${Lt(y)} ${Lt(u.x)} ${Lt(u.y)}`}return i?`${o} Z`:o}const mt=(t,e=0)=>{const n=parseFloat(t??"");return Number.isFinite(n)?n:e};function Au(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 Nn(t){const e=t.attributes;switch(t.tag.toLowerCase()){case"path":return e.d??null;case"circle":case"ellipse":{const n=mt(e.cx),i=mt(e.cy),s=t.tag.toLowerCase()==="circle"?mt(e.r):mt(e.rx),o=t.tag.toLowerCase()==="circle"?mt(e.r):mt(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=mt(e.x),i=mt(e.y),s=mt(e.width),o=mt(e.height);let r=e.rx!=null?mt(e.rx):e.ry!=null?mt(e.ry):0,a=e.ry!=null?mt(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${mt(e.x1)} ${mt(e.y1)} L${mt(e.x2)} ${mt(e.y2)}`;case"polyline":case"polygon":{const n=Au(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 xu(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 Pu=2.5;function Nr(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 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 g=u*c[0]+f*c[1],p=Math.min(Pu,1/Math.max(g,1e-6)),m=r.width/2*p;e.push({x:r.x-f*m,y:r.y+u*m}),n.push({x:r.x+f*m,y:r.y-u*m})}return{left:e,right:n}}function Br(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 Bn(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function Wn(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 Je(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Kn(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 rs(t){return Math.hypot(t[0],t[1],t[2])}function Wr(t,e){return rs(Wn(t,e))}function Ze(t){const e=rs(t);return e===0?[0,0,0]:ze(t,1/e)}function Kr(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 $u=Object.freeze(Object.defineProperty({__proto__:null,add:Bn,cross:Kn,distance:Wr,dot:Je,length:rs,lerp:Kr,normalize:Ze,scale:ze,subtract:Wn},Symbol.toStringTag,{value:"Module"})),_u=Math.PI/180;function Yr(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function le(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 Yn(t){return[t[0],0,0,0,0,t[1],0,0,0,0,t[2],0,0,0,0,1]}function Qe(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 Xr(t,e,n){const i=Qe(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 Iu(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 Hu(t){const[e,n,i,s,o,r,a,l,c,h,u,f,d,g,p,m]=t,y=e*r-n*o,w=e*a-i*o,k=e*l-s*o,E=n*a-i*r,T=n*l-s*r,S=i*l-s*a,P=c*g-h*d,O=c*p-u*d,A=c*m-f*d,C=h*p-u*g,I=h*m-f*g,R=u*m-f*p,F=y*R-w*I+k*C+E*A-T*O+S*P;if(Math.abs(F)<1e-12)return null;const N=1/F;return[(r*R-a*I+l*C)*N,(i*I-n*R-s*C)*N,(g*S-p*T+m*E)*N,(u*T-h*S-f*E)*N,(a*A-o*R-l*O)*N,(e*R-i*A+s*O)*N,(p*k-d*S-m*w)*N,(c*S-u*k+f*w)*N,(o*I-r*A+l*P)*N,(n*A-e*I-s*P)*N,(d*T-g*k+m*y)*N,(h*k-c*T-f*y)*N,(r*O-o*C-a*P)*N,(e*C-n*O+i*P)*N,(g*w-d*E-p*y)*N,(c*E-h*w+u*y)*N]}function Cu(t,e,n,i){const s=1/Math.tan(t*_u/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 Ou(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 Ru(t,e,n=[0,1,0]){const i=Ze(Wn(t,e)),s=Ze(Kn(n,i)),o=Kn(i,s);return[s[0],o[0],i[0],0,s[1],o[1],i[1],0,s[2],o[2],i[2],0,-Je(s,t),-Je(o,t),-Je(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 Lu=Object.freeze(Object.defineProperty({__proto__:null,compose:Xr,fromQuat:Qe,identity:Yr,invert:Hu,lookAt:Ru,multiply:le,orthographic:Ou,perspective:Cu,scaling:Yn,transformPoint:qr,translation:jr,transpose:Iu},Symbol.toStringTag,{value:"Module"})),jn={"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]},Ur={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 Fu(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}vt({type:"bounce",mode:"in"}),vt({type:"bounce",mode:"in-out"});function tn(t){const e=Vr.get(t.trim().toLowerCase());if(e)return e;const n=Fu(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:vt(r)}}const s=/^(elastic|bounce|back)\.(in|out|inout)(?:\(([^)]*)\))?$/.exec(n);if(s){const[,o,r,a]=s,l=(a??"").split(",").map(u=>Number.parseFloat(u)).filter(u=>Number.isFinite(u)),c=r==="inout"?"in-out":r;if(o==="back"&&l.length===0&&n in jn)return{easing:{type:"cubic-bezier",points:jn[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:vt(h)}}return n in Ur?{easing:Ur[n]}:n in jn?{easing:{type:"cubic-bezier",points:jn[n]}}:{easing:"ease-out"}}const Vr=new Map;function as(t,e){return Vr.set(t.trim().toLowerCase(),e.bezier?{easing:{type:"cubic-bezier",points:e.bezier},fn:e.fn}:{fn:e.fn,requiresBaking:"custom"}),t}function ls(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 Gr=/^\s*random\(\s*(\[.*\]|[^)]*)\s*\)\s*$/;function zr(t){return typeof t=="string"&&Gr.test(t)}function Du(t=1){let e=ls(t);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),o=(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},r=(l,c,h)=>{const u=l+e()*(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]=Ve(l[f])(l[f],c[f],h);return u}return Ve(l)(l,c,h)}),wrap:((l,c,h)=>{if(Array.isArray(l)){const p=l,m=y=>p[(Math.round(y)%p.length+p.length)%p.length];return c===void 0?m:m(c)}const u=l,d=c-u,g=p=>d===0?u:((p-u)%d+d)%d+u;return h===void 0?g:g(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,o),random:((l,c,h,u)=>{if(Array.isArray(l)){const d=()=>l[Math.floor(e()*l.length)];return c===!0?d:d()}const f=()=>r(l,c,h);return u?f:f()}),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:u="start",ease:f})=>(d,g,p)=>{const m=p.length,w=En(d,m,{...c!==void 0?{amount:c}:{each:h??1},from:u}),k=c!==void 0?c:(h??1)*Ri(m,u),E=f&&k>0?f(w/k)*k:w;return l+E},pipe:(...l)=>c=>l.reduce((h,u)=>u(h),c),splitColor:l=>Nu(l),getUnit:l=>typeof l=="number"?"":/^-?[\d.]+(?:e[-+]?\d+)?([a-z%]*)$/i.exec(l.trim())?.[1]??"",seed:l=>{e=ls(l)},resolveRandomString:l=>{const c=Gr.exec(l)?.[1]??"";if(c.startsWith("[")){const g=c.slice(1,-1).split(",").map(p=>p.trim()).filter(Boolean).map(p=>Number.isFinite(Number(p))?Number(p):p.replace(/^['"]|['"]$/g,""));return g[Math.floor(e()*g.length)]}const[h,u,f]=c.split(",").map(d=>Number.parseFloat(d));return r(h,u,Number.isFinite(f)?f:void 0)}}}function Jr(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 Nu(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 Bu=/^([+-])=\s*(-?[\d.]+)$/,Wu=/^([<>])\s*(?:([+-])?=?\s*(-?[\d.]+))?$/;function en(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=Bu.exec(s);if(o){const c=i(o[2]);return e.cursor+(o[1]==="-"?-c:c)}const r=Wu.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 Ku(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 Yu(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:p,y:m}=o(g),y=Math.abs(p-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,p)=>l(p));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 u=e.amount!==void 0?e.amount:(e.each??0)*h,f=e.ease?tn(e.ease):void 0,d=f?f.fn??vt(f.easing):void 0;return c.map(g=>{const p=h===0?0:g/h;return(d?d(p):p)*u})}const cs=new Set(["duration","delay","ease","repeat","repeatDelay","yoyo","stagger","onComplete","onUpdate","onStart","onRepeat","onReverseComplete","repeatRefresh","keyframes","easeEach","scrollTo","id","immediateRender","overwrite","paused","scrollTrigger","spring"]),ju={rotation:"rotate",rotationZ:"rotate",rotationX:"rotateX",rotationY:"rotateY",transformPerspective:"perspective",perspective:"childPerspective"};function Xn(t){const e={},n={};for(const[i,s]of Object.entries(t))cs.has(i)?e[i]=s:n[ju[i]??i]=s;return{config:e,properties:n}}function qn(t,e){return t===void 0?e:t*1e3}function hs(t,e){if(t!==void 0)return typeof t=="number"?{each:t*1e3}:Ku(t)?{offsets:Yu(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 Xu={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 Zr(t){return Xu[t]}function qu(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=Dr(e.path,{curviness:e.curviness});else if(ke(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 Uu(t){const e=typeof t=="string"||Array.isArray(t)?{path:t}:{...t};return{...e,start:e.end??1,end:e.start??0}}function Qr(t){return typeof t=="object"&&t!==null&&"shape"in t?t.shape:t}function Vu(t){if(t.morphSVG===void 0)return t;const{morphSVG:e,...n}=t,i=Qr(e);if(typeof i!="string"||!ke(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 Gu(t,e){if(t===!0)return[0,e];if(t===!1)return[0,0];if(typeof t=="number")return[0,ta(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 ta(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 zu(t,e){const[n,i]=Gu(t,e);return{strokeDasharray:[i-n,e],strokeDashoffset:-n}}function Ju(t,e){if(t.drawSVG===void 0)return t;const{drawSVG:n,...i}=t;return{...i,...zu(n,e)}}function Zu(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 ta(t,e){return Math.max(0,Math.min(e,t))}function Qu(t){let e=2166136261;for(let n=0;n<t.length;n++)e=Math.imul(e^t.charCodeAt(n),16777619);return e>>>0}function tf(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??Qu(`${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 us(t){return Math.max(.1,t/25)}function ef(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?us(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(Ye(s))]:n.end!==void 0&&(s.end=Array.isArray(n.end)?[...n.end]:n.end),s}function nf(t){const e=t===!0?{}:typeof t=="string"?{preset:t}:t;if(e.preset!==void 0&&!(e.preset in Pn))throw new Error(`gsap-compat: unknown spring preset "${e.preset}" — use one of ${Object.keys(Pn).join(", ")}`);return{...e.preset?Pn[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 sf(t,e){if(t===!0||typeof t=="string")return;const n=t.velocity;return typeof n=="number"?n:n?.[e]}class ce{timeline;options;cursor=0;fallbackRandom=ls(1);previousStart=0;previousEnd=0;labels=new Map;trackCounter=0;lastValues=new Map;constructor(e={}){this.options=e,this.timeline=new ae({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,nn(n),i)}from(e,n,i){const{config:s,properties:o}=Xn(nn(n)),{motionPath:r,text:a,scrambleText:l,...c}=o,h=this.targetsOf(e)[0],u={...s};for(const g of Object.keys(c))u[g]=this.resolveStart(h,g);r!==void 0&&(u.motionPath=Uu(r));const f={},d=String(this.resolveStart(h,"text"));return a!==void 0&&(f.text=fs(a),u.text=typeof a=="object"?{...a,value:d}:d),l!==void 0&&(f.text=fs(l),u.scrambleText=typeof l=="object"?{...l,text:d}:d),this.build(e,{...c,...f},u,i)}fromTo(e,n,i,s){const{properties:o}=Xn(nn(n));return this.build(e,o,nn(i),s)}set(e,n,i){return this.build(e,void 0,{...nn(n),duration:0},i)}get lastStart(){return this.previousStart}get lastEnd(){return this.previousEnd}addEvent(e){const n=Math.max(0,en(e,this.context()));return this.previousStart=n,this.previousEnd=n,this.cursor=Math.max(this.cursor,n),n}timeOf(e){return en(e,this.context())}addLabel(e,n){return this.labels.set(e,en(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=en(n,this.context());for(const o of e.timeline.tracks){if(!("keyframes"in o))continue;const r=On({...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}=Xn(i),{motionPath:a,text:l,scrambleText:c,inertia:h,...u}=r,f=this.targetsOf(e),d=en(s,this.context()),g=qn(o.delay,0),p=qn(o.duration,500),m=hs(o.stagger,{count:f.length,columnsFromLayout:this.options.layoutColumns?()=>this.options.layoutColumns(f):void 0,random:this.options.random??this.fallbackRandom}),y=this.easingFor(o.ease),w=[],k=o.spring;let E=0,T=!1;for(const[I,R]of Object.entries(u)){const F=R;let N=n?.[I]!==void 0?n[I]:this.resolveStart(f[0],I);if(typeof N!=typeof F&&(this.warn(`no usable start value for "${I}" on "${f[0]}" — it will snap to ${String(F)}. Use fromTo() to animate it.`),N=F),k!==void 0&&(typeof N!="number"||typeof F!="number")&&this.warn(`spring works on numbers, so "${I}" on "${f[0]}" eases instead`),k!==void 0&&typeof N=="number"&&typeof F=="number"){const $={...nf(k),from:N,to:F,velocity:sf(k,I)??this.options.startVelocity?.(f[0],I)??0},L=this.nextTrackId(`${f[0]}-${I}-spring`),W={id:L,target:f[0],...f.length>1&&{targets:f},...m&&f.length>1&&{stagger:m},property:I,kind:"spring",spring:$,delay:d+g};this.timeline.addTrack(W),w.push(L),E=Math.max(E,Oo($));for(const j of f)this.lastValues.set(`${j}|${I}`,F);continue}T=!0;const X=this.keyframesFor(N,F,p,y,o.ease),G=this.nextTrackId(`${f[0]}-${I}`);this.timeline.addTrack(On({id:G,target:f[0],...f.length>1&&{targets:f},...m&&f.length>1&&{stagger:m},property:I,delay:d+g,keyframes:X,...I==="quaternion"&&{interpolation:"slerp"}})),w.push(G);for(const $ of f)this.lastValues.set(`${$}|${I}`,F)}const S=tf({text:l,scrambleText:c},f[0],p);if(S){const I=n?.text??n?.scrambleText,R=I!==void 0?fs(I):this.resolveStart(f[0],"text"),F=this.nextTrackId(`${f[0]}-text`),N={id:F,target:f[0],...f.length>1&&{targets:f},...m&&f.length>1&&{stagger:m},property:"text",textConfig:{from:typeof R=="string"?R:String(R??""),...S},delay:d+g,keyframes:this.keyframesFor(0,1,p,y,o.ease)};this.timeline.addTrack(N),w.push(F);for(const X of f)this.lastValues.set(`${X}|text`,S.to)}if(a!==void 0){const{config:I,start:R,end:F}=qu(a),N=this.nextTrackId(`${f[0]}-motionPath`),X={id:N,target:f[0],...f.length>1&&{targets:f},...m&&f.length>1&&{stagger:m},property:"motionPath",motionPathConfig:I,delay:d+g,keyframes:this.keyframesFor(R,F,p,y,o.ease)};this.timeline.addTrack(X),w.push(N)}if(h!==void 0)for(const[I,R]of Object.entries(h)){const F=this.resolveStart(f[0],I);if(typeof F!="number"){this.warn(`inertia on "${I}" needs a numeric start value; skipped`);continue}const N=ef(F,R),X=this.nextTrackId(`${f[0]}-${I}-inertia`),G={id:X,target:f[0],...f.length>1&&{targets:f},...m&&f.length>1&&{stagger:m},property:I,kind:"inertia",inertia:N,delay:d+g};this.timeline.addTrack(G),w.push(X),E=Math.max(E,be(N));for(const $ of f)this.lastValues.set(`${$}|${I}`,ye(N))}const A=((h!==void 0||k!==void 0)&&!T&&!S&&a===void 0?E:Math.max(p,E))+(m&&f.length>1?We(f.length,m):0),C=d+g+A;return this.previousStart=d+g,this.previousEnd=C,this.cursor=Math.max(this.cursor,C),{trackIds:w,start:d+g,end:C,kill:()=>{for(const I of w)this.timeline.removeTrack(I)}}}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"?tn(o):void 0;if(a?.requiresBaking==="custom"||this.options.bakeEases&&Be(s)){const c=a?.fn??vt(s);return[r,...Zi(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=Zr(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 tn(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 fs(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 of(t){return new ce(t)}function nn(t){return Zu(Vu(t))}function rf(t){return!Array.isArray(t)||t.length!==4?null:`matrix3d(${Qe(Gt(t)).map(n=>Math.round(n*1e6)/1e6+0).join(", ")})`}const af=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),lf="#ffffff",cf="rgba(0, 0, 0, 0.5)";function hf(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??lf})`),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??cf})`)}return e.length>0?e.join(" "):null}function uf(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 ff(t){if(!("ownerSVGElement"in t))return;const e=t.style;!e||e.transformBox||(e.transformBox="fill-box",e.transformOrigin||(e.transformOrigin="50% 50%"))}const ea=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"]),df=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","quaternion","motionPathX","motionPathY","motionPathRotate"]),pf=["x","motionPathX","y","motionPathY","z","rotate","rotateZ","motionPathRotate","rotateX","rotateY","quaternion","scale","scaleX","scaleY","scaleZ","skewX","skewY"],gf=new Set(["childPerspective","perspectiveOriginX","perspectiveOriginY"]),mf=new Set(["originX","originY"]),yf=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),bf=new Set(["drawOn"]),wf={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},na={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},kf="http://www.w3.org/2000/svg";class he{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,p]of n)if(!(g==="x"&&l)&&!(g==="y"&&c)&&!((g==="rotate"||g==="rotateZ")&&h)&&!bf.has(g)){if(df.has(g))(i??={})[g]=p;else if(gf.has(g))typeof p=="number"&&((s??={})[g]=p);else if(mf.has(g))typeof p=="number"&&((o??={})[g]=p);else if(yf.has(g))typeof p=="number"&&((r??={})[g]=p);else if(af.has(g))(a??={})[g]=p;else if(g!=="perspective"){if(g!=="shine")if(g==="text"&&typeof p=="string")uf(e,p);else if(g==="d"&&typeof p=="string"){const m=e;(m.tagName?.toLowerCase()==="path"?m:m.querySelector?.("path"))?.setAttribute?.("d",p)}else this.applyStyleProperty(e,g,p)}}const u=n.get("shine");typeof u=="number"&&this.applyShine(e,u);const f=[],d=n.get("perspective");if(typeof d=="number"&&d>0&&f.push(`perspective(${d}px)`),i)for(const g of pf){const p=i[g];if(p===void 0)continue;const m=this.buildTransformPart(g,p);m&&f.push(m)}if(f.length>0&&(e.style.transform=f.join(" "),ff(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,p=o.originY??50;e.style.transformOrigin=`${g}% ${p}%`}if(r){const g=r.clipTop??0,p=r.clipRight??0,m=r.clipBottom??0,y=r.clipLeft??0;e.style.clipPath=`inset(${g}% ${p}% ${m}% ${y}%)`}if(a){const g=hf(a);g&&(e.style.filter=g)}}buildTransformPart(e,n){if(e==="quaternion")return rf(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===kf&&n in na){const a=Array.isArray(i)?i.join(", "):String(i);e.style[na[n]]=a;return}else n==="fill"&&e.dataset?.elementType==="text"?s="color":s=wf[n]??n;let r;typeof i=="number"?ea.has(n)||ea.has(s)?r=`${i}px`:r=String(i):Array.isArray(i)?r=i.join(", "):r=i,e.style[s]=r}}const vf={request:t=>requestAnimationFrame(t),cancel:t=>cancelAnimationFrame(t)};class ia{adapter=new he;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=Du();active=new Map;applied=new Map;dirty=new Set;frameId=null;lastTimestamp=null;destroyed=!1;constructor(e={}){this.scheduler=e.scheduler??vf,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);ds(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(ds(e))return[e];if(!Sf(e))return[e];const n=[];for(const i of Array.from(e))n.push(...this.targetsOf(i));return n}nameFor(e){return ds(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 ds(t){return typeof t=="object"&&t!==null&&t.nodeType===1}function Sf(t){if(Array.isArray(t))return!0;const e=t;return typeof e.length=="number"&&typeof e.item=="function"}function Un(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 sa=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function Mf(t){const e={};for(const n of Array.from(t.attributes))e[n.name]=n.value;return e}function Tf(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 Ef(t,e){const n=typeof t=="string"||Array.isArray(t)||sa(t)?{path:t}:t,{align:i,alignOrigin:s,path:o,...r}=n,a=S=>{const P=sa(S)?S:e.query(S);return P||e.warn(`gsap-compat: motionPath could not find "${String(S)}"`),P};let l=null,c="";if(Array.isArray(o)||typeof o=="string"&&ke(o))c=o;else{l=a(o);const S=l&&Nn({tag:l.localName,attributes:Mf(l)});l&&!S&&e.warn(`gsap-compat: motionPath element <${l.localName}> has no path geometry`),c=S??""}const h={...r,path:c};if(i===void 0||i===!1)return h;const u=i===!0?l:a(i);if(!u)return i===!0&&e.warn("gsap-compat: motionPath align: true needs the path to be an element"),h;const f=e.targets[0];if(!f)return h;const[d,g,p,m,y,w]=Tf(u),k=Un(f),[E,T]=s??[.5,.5];for(const S of e.targets.slice(1)){const P=Un(S);if(Math.abs(P.left-k.left)>.5||Math.abs(P.top-k.top)>.5){e.warn("gsap-compat: motionPath align measures the first target; the others are laid out elsewhere");break}}return h.matrix=[d,g,p,m,y-k.left-E*k.width,w-k.top-T*k.height],h}const oa=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function ra(t){const e={};for(const n of Array.from(t.attributes))e[n.name]=n.value;return e}function aa(t){if(!t)return null;const e=Nn({tag:t.localName,attributes:ra(t)});return e||(t.querySelector("path")?.getAttribute("d")??null)}function Af(t,e,n){const i=Qr(t);if(typeof i=="string"&&ke(i))return i;const s=oa(i)?i:typeof i=="string"?e(i):null,o=aa(s);return o||(n(`gsap-compat: morphSVG could not find a shape for "${String(i)}"`),"")}const xf=new Set(["cx","cy","r","rx","ry","x","y","width","height","x1","y1","x2","y2","points"]);function Pf(t,e=document){return(typeof t=="string"?Array.from(e.querySelectorAll(t)):oa(t)?[t]:Array.from(t)).map(i=>{if(i.localName==="path")return i;const s=Nn({tag:i.localName,attributes:ra(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))xf.has(r.name)||o.setAttribute(r.name,r.value);return o.setAttribute("d",s),i.parentNode.replaceChild(o,i),o})}const la=.3;class ca{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=ha(),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=ha(),s=Math.max(1,i-this.lastTime);this.lastTime=i;const o=e/s*1e3,r=n/s*1e3;this.velocityX+=(o-this.velocityX)*la,this.velocityY+=(r-this.velocityY)*la}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 ha(){return typeof performance<"u"?performance.now():Date.now()}function ua(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 fa(t,e){return e<=0?[]:t.map(n=>Math.round(n/e)*e)}class ps{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 ca({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=$f(s/i);e.pause(),e.seek(o*n)}applyConstraints(e,n){let i=e;const s=[...fa([i],this.options.snap??0),...(n==="x"?this.options.snapLinesX:this.options.snapLinesY)??[]],o=ua([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 $f(t){return t<0?0:t>1?1:t}function _f(t){const e=new ps(t);return e.start(),e}const If={x:"x",y:"y","x,y":"both"},gs=t=>typeof t=="object"&&t!==null&&t.nodeType===1;function da(t,e){const n=Un(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 pa(t){return Array.isArray(t)?[...t]:t}function Hf(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 Cf(t,e,s,o,i);const r=If[i.type??"x,y"],a=()=>{const p=e.appliedValue(s,"x"),m=e.appliedValue(s,"y");return{x:typeof p=="number"?p:0,y:typeof m=="number"?m:0}},l=typeof i.bounds=="string"?e.query(i.bounds):gs(i.bounds)?i.bounds:null,h={bounds:(!l&&i.bounds&&!gs(i.bounds)?i.bounds:void 0)??(l?da(o,l):void 0)};let u=null;const f=()=>{u?.kill(),u=null},d=p=>{const m=i.inertia===!0?{}:i.inertia,y=m.friction??(m.resistance!==void 0?us(m.resistance):4),w=a(),k=h.bounds??{};let E,T;const S=m.end;if(Array.isArray(S)){const O=Ye({from:w.x,velocity:r==="y"?0:p.x,friction:y}),A=Ye({from:w.y,velocity:r==="x"?0:p.y,friction:y});let C=S[0];for(const I of S)Math.hypot(I.x-O,I.y-A)<Math.hypot(C.x-O,C.y-A)&&(C=I);C&&(E=[C.x],T=[C.y])}else typeof S=="number"?(E=S,T=S):S&&(E=pa(S.x),T=pa(S.y));const P={};r!=="y"&&(P.x={velocity:p.x,friction:y,min:k.minX,max:k.maxX,end:E}),r!=="x"&&(P.y={velocity:p.y,friction:y,min:k.minY,max:k.maxY,end:T}),u=t.to(o,{inertia:P,onComplete:()=>i.onThrowComplete?.()})},g=new ps({target:o,axis:r,snap:i.snap,get bounds(){return h.bounds},getPosition:a,onPress:()=>{f(),l&&(h.bounds=da(o,l)),i.onPress?.()},onDrag:p=>{e.apply(s,r==="x"?{x:p.x}:r==="y"?{y:p.y}:{x:p.x,y:p.y}),i.onDrag?.(p)},onRelease:()=>{const p=g.velocity;i.onRelease?.(p),i.inertia&&d(p)}});return g.start(),{draggable:g,get position(){return a()},get rotation(){const p=e.appliedValue(s,"rotate");return typeof p=="number"?p:0},destroy(){f(),g.destroy()}}}function Cf(t,e,n,i,s){const o=typeof s.bounds=="object"&&s.bounds!==null&&!gs(s.bounds)?s.bounds:{},r=()=>{const k=e.appliedValue(n,"rotate");return typeof k=="number"?k:0},a=k=>Math.min(o.maxRotation??1/0,Math.max(o.minRotation??-1/0,k));let l=null,c=!1,h,u={x:0,y:0},f=0,d=0,g=[];const p=k=>Math.atan2(k.clientY-u.y,k.clientX-u.x)*180/Math.PI,m=k=>{if(c)return;l?.kill(),l=null,c=!0,h=k.pointerId,i.setPointerCapture?.(k.pointerId);const E=i.getBoundingClientRect();u={x:E.left+E.width/2,y:E.top+E.height/2},f=p(k),d=r(),g=[{time:performance.now(),rotation:d}],s.onPress?.()},y=k=>{if(!c||k.pointerId!==h)return;const E=p(k);let T=E-f;T>180&&(T-=360),T<-180&&(T+=360),f=E,d+=T;let S=a(d);s.snap&&(S=a(Math.round(S/s.snap)*s.snap)),e.apply(n,{rotate:S});const P=performance.now();for(g.push({time:P,rotation:S});g.length>2&&P-g[0].time>100;)g.shift();const O={x:0,y:0};s.onDrag?.(O)},w=k=>{if(!c||k.pointerId!==h)return;c=!1;const E=g[0],T=g[g.length-1],S=E&&T?(T.time-E.time)/1e3:0,P=S>0?(T.rotation-E.rotation)/S:0;if(s.onRelease?.({x:P,y:0}),!s.inertia)return;const O=s.inertia===!0?{}:s.inertia,A=O.friction??(O.resistance!==void 0?us(O.resistance):4),C=typeof O.end=="number"||Array.isArray(O.end)?O.end:void 0;l=t.to(i,{inertia:{rotate:{velocity:P,friction:A,min:o.minRotation,max:o.maxRotation,end:Array.isArray(C)?C.filter(I=>typeof I=="number"):C}},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 Of={opacity:0,scale:.6};function Rf(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 ga(t){const e=Un(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 ms(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=Rf(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 ys=new WeakMap;function bs(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?Of:i.enter,c=new Set(n.elements);if(i.targets!==void 0)for(const d of t.resolveTargets(i.targets)){const g=t.elementFor(d);g&&c.add(g)}const h=[...c].sort((d,g)=>d===g?0:d.compareDocumentPosition(g)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),u=e({onComplete:i.onComplete});let f=0;for(const d of h){const g=ga(d);if(!g)continue;let p=n.boxes.get(d)??null,m;const y=ma(d),w=!p&&y!==void 0?n.ids.get(y):void 0;w&&w.element!==d&&(p=w.box,m=w.element);const[k]=t.resolveTargets(d);ys.get(d)?.timeline.removeTracks({target:k});const E=f*r;if(!p){if(l===!1)continue;u.fromTo(d,{x:0,y:0,scaleX:1,scaleY:1,...l},{...ya(l),x:0,y:0,scaleX:1,scaleY:1,duration:s,ease:o,delay:E},0),ys.set(d,u),f++;continue}const T=p.cx-g.cx,S=p.cy-g.cy,P=a?p.width/g.width:1,O=a?p.height/g.height:1;if(!(Math.abs(T)>.5||Math.abs(S)>.5||Math.abs(P-1)>.001||Math.abs(O-1)>.001)){const I=(R,F)=>{const N=t.appliedValue(k,R);return typeof N=="number"&&Math.abs(N-F)>1e-6};(I("x",0)||I("y",0)||I("scaleX",1)||I("scaleY",1))&&u.set(d,{x:0,y:0,scaleX:1,scaleY:1},0);continue}const C=i.fade===!0&&m!==void 0;u.fromTo(d,{x:T,y:S,scaleX:P,scaleY:O,...C&&{opacity:0}},{x:0,y:0,scaleX:1,scaleY:1,...C&&{opacity:1},duration:s,ease:o,delay:E},0),C&&m&&ga(m)&&u.fromTo(m,{opacity:1},{opacity:0,duration:s,ease:o,delay:E},0),ys.set(d,u),f++}return u}function ma(t){return t.dataset?.flipId}function ya(t){const e={};for(const n of Object.keys(t))e[n]=n==="opacity"||n.startsWith("scale")?1:0;return e}function Lf(t,e={}){const n=new Set((e.type??"chars,words,lines").split(",").map(p=>p.trim())),i={chars:e.charsClass??"char",words:e.wordsClass??"word",lines:e.linesClass??"line"},s=e.aria!==!1,o=t.map(p=>({element:p,html:p.innerHTML,ariaLabel:p.getAttribute("aria-label")}));let r={chars:[],words:[],lines:[],masks:[]},a,l,c=!1;const h=()=>{for(const{element:p,html:m,ariaLabel:y}of o)p.innerHTML=m,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:m}of o){const y=(m.textContent??"").replace(/\s+/g," ").trim(),w=Ff(m,i.words),k=n.has("chars")?w.flatMap(S=>Df(S,i.chars)):[],E=n.has("lines")?Bf(m,w,i.lines):[];if(s){!m.hasAttribute("aria-label")&&y&&m.setAttribute("aria-label",y);for(const S of w)S.setAttribute("aria-hidden","true")}if(n.has("words"))p.words.push(...w);else for(const S of w)S.removeAttribute("class");p.chars.push(...k),p.lines.push(...E);const T=e.mask==="lines"?E:e.mask==="words"?w:e.mask==="chars"?k:[];for(const S of T)p.masks.push(Wf(S,`${i[e.mask]}-mask`))}r=p},d={elements:t,get chars(){return r.chars},get words(){return r.words},get lines(){return r.lines},get masks(){return r.masks},split(){c||(u(),h(),f(),a=e.onSplit?.(d))},revert(){c=!0,l?.disconnect(),u(),h()}};f(),a=e.onSplit?.(d),e.autoSplit&&g();function g(){const p=new Map;let m=!1;const y=()=>{if(m)return;m=!0;const k=()=>{m=!1,d.split()};typeof requestAnimationFrame=="function"?requestAnimationFrame(k):setTimeout(k,0)};if(typeof ResizeObserver=="function"){l=new ResizeObserver(k=>{let E=!1;for(const T of k){const S=Math.round(T.contentRect.width),P=p.get(T.target);p.set(T.target,S),P!==void 0&&P!==S&&(E=!0)}E&&y()});for(const k of t)l.observe(k)}const w=t[0]?.ownerDocument?.fonts;w&&w.status!=="loaded"&&w.ready.then(()=>y())}return d}function Ff(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 Df(t,e){const n=t.ownerDocument,i=Nf(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 Nf(t){const e=Intl.Segmenter;return e?Array.from(new e(void 0,{granularity:"grapheme"}).segment(t),n=>n.segment):Array.from(t)}function Bf(t,e,n){const i=t.ownerDocument,s=new Map(e.map(g=>[g,g.getBoundingClientRect()])),o=[],r=g=>{for(const p of Array.from(g.childNodes))p.nodeType===3||s.has(p)||p.tagName==="BR"?o.push(p):r(p)};r(t);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 g of o){if(g.tagName==="BR"){u=!0;continue}const p=s.get(g);if(p&&(!l||u||p.top>c+h)&&(d(),c=p.top,h=p.height/2,u=!1),!l)continue;const m=[];for(let k=g.parentNode;k&&k!==t;k=k.parentNode)m.unshift(k);let y=0;for(;y<f.length&&y<m.length&&f[y].original===m[y];)y++;f.length=y;let w=y===0?l:f[y-1].clone;for(const k of m.slice(y)){const E=k.cloneNode(!1);w.appendChild(E),f.push({original:k,clone:E}),w=E}w.appendChild(g)}return t.replaceChildren(...a),a}function Wf(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 ba={top:0,left:0,start:0,center:.5,centre:.5,middle:.5,bottom:1,right:1,end:1};function ws(t){const e=t.trim().toLowerCase();if(e in ba)return ba[e];if(e.endsWith("%")){const n=Number.parseFloat(e.slice(0,-1));return Number.isNaN(n)?void 0:n/100}}function ks(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?ws(i[0]):void 0,o=i[1]!==void 0?ws(i[1]):void 0;return{elementFraction:s??0,viewportFraction:o??0,offsetPx:e}}function xe(t,e,n){const i=ks(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 Kf(t,e,n,i){const s=xe(t,e,n),r=xe(t,e,i)-s;return r<=0?s<=0?1:0:vs(-s/r)}function vs(t){return t<0?0:t>1?1:t===0?0:t}function wa(t,e,n,i){if(n<=0)return e;const s=1-Math.exp(-(i/1e3)/n);return t+(e-t)*s}function Ss(t,e,n,i,s){const o=h=>xe({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 u=(l+c)/2;Math.sign(o(u))===Math.sign(r)?l=u:c=u}return(l+c)/2}class ka{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 Yf(t){const e=new ka(t);return e.start(),e}class va{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 jf=.15;function Sa(t){return typeof t=="object"&&!Array.isArray(t)?t:{snapTo:t}}function Ma(t,e,n){const i=Vn(t+e*jf);if(typeof n=="function")return Vn(n(i));if(typeof n=="number")return n<=0?t:Vn(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 Vn(s)}function Ta(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 Ea{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=je,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 Vn(t){return Math.max(0,Math.min(1,t))}class Aa{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,u)=>{const f=e.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??e.body).appendChild(f),this.nodes.push(f),f};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 Xf=120,Pe=[],$e=new Set;let Ms=!1;const qf=()=>{Ms||$e.size===0||(Ms=!0,queueMicrotask(()=>{Ms=!1;for(const t of $e)t.afterRefresh()}))},xa=()=>{for(const t of $e)t.beforeRefresh();for(const t of Pe)t.refresh();for(const t of $e)t.afterRefresh()};let _e={width:0,height:0};const Pa=()=>{const t=window.innerWidth,e=window.innerHeight,n=t===_e.width&&e!==_e.height,i=Math.abs(e-_e.height)<_e.height*.25,s=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0;n&&i&&s||(_e={width:t,height:e},xa())};class sn{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 Ea(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 va(e,{axis:this.options.horizontal?"x":"y",spacing:this.options.pinSpacing!==!1})),this.options.markers&&!this.options.horizontal&&typeof document<"u"&&(this.markers=new Aa(document,this.options.scroller??null,this.options.markers)),this.scrollTarget()?.addEventListener("scroll",this.onScroll,{passive:!0}),Pe.length===0&&typeof window<"u"&&(_e={width:window.innerWidth,height:window.innerHeight},window.addEventListener("resize",Pa,{passive:!0})),Pe.push(this),this.refresh()}stop(){this.running&&(this.running=!1,this.scrollTarget()?.removeEventListener("scroll",this.onScroll),Pe.splice(Pe.indexOf(this),1),Pe.length===0&&typeof window<"u"&&window.removeEventListener("resize",Pa),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(){xa()}static onRefresh(e){return $e.add(e),()=>$e.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+xe(n,i,on(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,qf()}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?vs((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=on(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+xe(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()},Xf))}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=Sa(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+Ma(r,this.releaseVelocity/s,n.snapTo)*s;Math.abs(a-o)<1||this.snapper.animate(o,a,Ta(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=d=>a+d*(l-a),h=Ss(r,i.width,o,on(this.options.start)??"left right",e.shiftAt);this.startPx=c(h);const u=on(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(Ss(r,i.width,o,u,e.shiftAt)),this.markerGeometry=null}markersFor(e){const n=(o,r)=>{const a=on(o)??r;if(typeof a=="number")return 0;if(/^\s*\+=/.test(a))return;const l=ks(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=wa(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 on(t){return typeof t=="function"?t():t}function Uf(t){const e=new sn(t);return e.start(),e}const Ts=new Set,Vf=16,$a=.5,Gf=2;class Es{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),Ts.add(this),this.stopListening=sn.onRefresh({beforeRefresh:()=>this.rest(),afterRefresh:()=>this.refresh()}),this.refresh(),this}static refreshAll(){for(const e of Ts)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),Ts.delete(this),this.stopListening?.(),this.stopListening=null,this.cancelFrame(),this.journey=null,this}destroy(){this.stop();for(const e of this.effects)As(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??je,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)As(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?Vf: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)<=Gf||(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)<$a&&(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)<$a?s.lagged=i:n=!0,o+=i-s.lagged}As(s.element,o===0?s.saved:`0 ${zf(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 As(t,e){e?t.style.setProperty("translate",e):t.style.removeProperty("translate")}function zf(t){return Math.round(t*100)/100}function Jf(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 xs(t,e,n,i,s=()=>{}){const o=d=>typeof d=="string"?t.query(d)??void 0:d,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 u=(d,g)=>()=>{g?.(),n&&!a&&Jf(n,l[d]??"none"),e.once&&d===0&&queueMicrotask(()=>h.destroy())},f=e.containerAnimation?td(t,e.containerAnimation,r,s):void 0;return h=new sn({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:Zf(e.snap,n),markers:e.markers,container:f,onUpdate:(d,g)=>{if(n&&a!==!1&&n.progress(d),e.onUpdate){const p=d<c||g<0?-1:1;e.onUpdate({progress:d,velocity:g,direction:p})}c=d},onEnter:u(0,e.onEnter),onLeave:u(1,e.onLeave),onEnterBack:u(2,e.onEnterBack),onLeaveBack:u(3,e.onLeaveBack)}),n&&a===!1&&n.progress(0),h.start(),t.own(h)}function Zf(t,e){const n=s=>s==="labels"?o=>Qf(o,e?.labelProgresses?.()??[]):s;if(typeof t!="object"||Array.isArray(t))return n(t);const i=t.ease?tn(t.ease):void 0;return{snapTo:n(t.snapTo),duration:t.duration,delay:t.delay,ease:i?i.fn??vt(i.easing):void 0}}function Qf(t,e){return e.reduce((n,i)=>Math.abs(i-t)<Math.abs(n-t)?i:n,e[0]??t)}function td(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 _a{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 ed{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 _a(this.host,this.scope);o.conditions=n,o.add(()=>e.setup(o)),e.context=o}}class nd{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 id={opacity:0,y:-16},sd={opacity:0,y:16};async function od(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 rd(o,i,r);const a=i.duration??.35,l=i.ease??"power2.inOut",c=m=>new Promise(y=>{m(y)||y()}),h=r(),u=h.length?ms(e,h):void 0,f=i.from!==void 0?Ia(e,i.from,i.shared):[];if(f.length&&i.leave!==!1){const m=i.leave??id;await c(y=>t.to(f,{...m,duration:a,ease:l,onComplete:y}))}await i.update();const d=[],g=typeof i.to=="function"?i.to():i.to,p=g!==void 0?Ia(e,g,i.shared):[];if(p.length&&i.enter!==!1){const m=i.enter??sd;d.push(c(y=>t.fromTo(p,m,{...ya(m),duration:a,ease:l,onComplete:y})))}if(u){const m=r().filter(y=>!h.includes(y));m.length&&d.push(c(y=>bs(e,n,u,{targets:m,duration:a*1.4,ease:l,enter:!1,onComplete:y})))}await Promise.all(d)}function Ia(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 rd(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 Ha={create:(t,e)=>as(t,Hr(e))},Ca={create:(t,e)=>as(t,{fn:Cr(e)})},Oa={create:(t,e)=>as(t,{fn:Or(e)})},ad=new Set(["keyframes","duration","delay","ease","easeEach","stagger","repeat","repeatDelay","yoyo","repeatRefresh","paused","id","onStart","onUpdate","onComplete","onRepeat","onReverseComplete","scrollTrigger"]),Ra=.5,ld="power1.inOut";function cd(t){return t.keyframes!==void 0&&t.keyframes!==null}function hd(t){const e=t.keyframes,n={};for(const[c,h]of Object.entries(t))ad.has(c)||(n[c]=h);if(Array.isArray(e))return e.map(c=>({...n,...c,duration:c.duration??t.duration??Ra}));const i=Object.entries(e),s=t.duration??Ra,o=e.easeEach??t.easeEach??ld;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 g=Math.max(0,f-u);h.push({...n,ease:o,...d,duration:g*s}),u=f}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[u,f]of r)c<f.length&&(h[u]=f[c]);l.push(h)}return l}function La(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,k)=>{if(k===void 0)return r[w];if(typeof k=="number")return k;if(k==="max")return a[w];const E=typeof k=="string"?s.querySelector(k):k;if(!E)return r[w];const T=E.getBoundingClientRect(),S=o?.getBoundingClientRect(),P=(w==="x"?i.offsetX:i.offsetY)??i.offset??0;return w==="x"?T.left-(S?.left??0)+r.x-P:T.top-(S?.top??0)+r.y-P},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))},u={...r},f=()=>{o?(o.scrollLeft=u.x,o.scrollTop=u.y):window.scrollTo({left:u.x,top:u.y,behavior:"instant"})},d=["wheel","touchstart","keydown"],g=o??window,p=()=>{y.kill(),m()},m=()=>{for(const w of d)g.removeEventListener(w,p)},y=t.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:()=>{m(),i.onComplete?.()}});if(i.autoKill!==!1)for(const w of d)g.addEventListener(w,p,{passive:!0});return y}function ud(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,...u}=n,f={onEnter:a,onLeave:l,onEnterBack:c,onLeaveBack:h},d={onEnter:[],onLeave:[],onEnterBack:[],onLeaveBack:[]},g={},p=y=>{g[y]!==void 0&&clearTimeout(g[y]),g[y]=void 0;const w=d[y].splice(0);w.length>0&&f[y]?.(w)},m=(y,w)=>{if(f[y]){if(d[y].push(w),r!==void 0&&d[y].length>=r)return p(y);g[y]===void 0&&(g[y]=setTimeout(()=>p(y),o*1e3))}};return s.map(y=>xs(t,{...u,trigger:y,onEnter:()=>m("onEnter",y),onLeave:()=>m("onLeave",y),onEnterBack:()=>m("onEnterBack",y),onLeaveBack:()=>m("onLeaveBack",y)})).filter(y=>y!==void 0)}class Ft{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 ce({...i,startValue:(s,o)=>{const r=e.objectFor(s);if(r)return pd(r[o]);const a=e.appliedValue(s,o);if(a!==void 0)return a;if(o==="d")return aa(e.elementFor(s))??void 0;if(o==="text")return e.elementFor(s)?.textContent??void 0;if(o==="strokeDasharray"||o==="strokeDashoffset"){const l=Wa(e.elementFor(s));if(l!==void 0)return o==="strokeDasharray"?[l,l]:0}},startVelocity:(s,o)=>e.velocityOf(s,o),layoutColumns:s=>Ba(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=xs(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 cd(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 Ft(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}=es(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 u=(f,d,g)=>{s(f,d,g),c=Math.min(c,this.compat.lastStart),h=Math.max(h,this.compat.lastEnd)};if(this.buildTween(o,n,i,u),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=hd(n);if(o.length===0)return;const r=s.length>1?hs(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?An(s.length,r).map(m=>m/1e3):[0],h=this.compat.timeOf(i)/1e3+qn(n.delay,0)/1e3;let u=1/0,f=-1/0;if(l.forEach((m,y)=>{o.forEach((w,k)=>{const E=k===0?h+c[y]:">";this.tween(m,[w],E,([T],S,P)=>this.compat.to(S,T,P)),u=Math.min(u,this.compat.lastStart),f=Math.max(f,this.compat.lastEnd)})}),u===1/0)return;const{onStart:d,onUpdate:g,onComplete:p}=n;d&&this.events.push({time:u,direction:"forward",run:d}),g&&this.ranges.push({start:u,end:f,run:g}),p&&this.events.push({time:f,direction:"forward",run:p})}staggerContext(e){return{count:e.length,columnsFromLayout:()=>Ba(e.map(n=>this.stage.elementFor(n))),random:()=>this.stage.utils.random(0,1)}}buildTween(e,n,i,s){const o=e.map(f=>this.targetFor(f));if(!(e.length>1&&(n.some(dd)||e.some(f=>this.stage.objectFor(f)!==void 0)))){const f=this.targetFor(e[0]);s(n.map(d=>this.prepare(Na(d,0,f,this.stage.utils,o),e)),e,i);return}const a=n.length-1,{stagger:l,...c}=n[a],h=hs(l,this.staggerContext(e)),u=h?An(e.length,h).map(f=>f/1e3):e.map(()=>0);e.forEach((f,d)=>{const g=d===0?qn(c.delay,0)/1e3+u[0]:0,p=d===0?0:u[d]-u[d-1],m=d===0?i:`<${p<0?"-":"+"}${Math.abs(p).toFixed(6)}`,w=n.map((k,E)=>E===a?{...c,delay:g}:k).map(k=>this.prepare(Na(k,d,this.targetFor(f),this.stage.utils,o),[f]));s(w,[f],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=Ef(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=Af(e.morphSVG,s,i),{morphSVG:a,...l}=o;o=r?{...o,morphSVG:r}:l}if(e.drawSVG!==void 0){const r=Wa(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=Ju(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 ${gd(e)}`);return}return this.firstElement??=n.map(i=>this.stage.elementFor(i)).find(i=>i!==void 0),n}}function Fa(t=new ia){const e=o=>{const{config:r}=Xn(o);return new Ft(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:u,...f}=o;return f},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)??Zr(r)},scrollTrigger:o=>i(xs(t,o)),scrollBatch:(o,r)=>ud(t,o,r).map(a=>i(a)),scrollTo:(o,r)=>La(s,t,o,r),refreshScroll:()=>{sn.refreshAll(),Es.refreshAll()},smoothScroll:(o={})=>{const r=typeof o.scroller=="string"?(t.collector?.scope??t.root).querySelector(o.scroller):o.scroller;return i(new Es({...o,scroller:r}).start())},context:(o,r)=>{const a=new _a(t,r);return o&&a.add(()=>o(a)),a},matchMedia:o=>new ed(t,o),customEase:Ha.create,customBounce:Ca.create,customWiggle:Oa.create,pageTransition:o=>od(s,t,r=>new Ft(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 nd(a,r))},quickTo:(o,r,a={})=>{const l=new Ft(t,{paused:!0}),[c]=t.resolveTargets(o);return Object.assign(u=>{if(!c)return;const f=a.spring!==void 0?t.velocityOf(c,r)??0:0;l.compat.reset(),l.compat.to(c,{[r]:u,duration:a.duration??.4,ease:a.ease??"power3.out",...a.spring!==void 0&&{spring:fd(a.spring,r,f)}}),l.timeline.stop(),l.timeline.play(),t.activate(l.timeline)},{tween:l,kill:()=>l.kill()})},timeline:o=>new Ft(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 La(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 Ft(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=>Pf(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(Lf(l,r))},draggable:(o,r)=>i(Hf(s,t,o,r)),getFlipState:o=>ms(t,o),flipFrom:(o,r)=>bs(t,a=>new Ft(t,a),o,r),flip:(o,r,a)=>{const l=ms(t,o);return r(),bs(t,c=>new Ft(t,c),l,{targets:o,...a})}};return s}const Tt=Fa();function fd(t,e,n){return t===!0?{velocity:{[e]:n}}:typeof t=="string"?{preset:t,velocity:{[e]:n}}:{...t,velocity:{[e]:n}}}function dd(t){return t.morphSVG!==void 0||t.drawSVG!==void 0||t.text!==void 0||t.scrambleText!==void 0||Da(t)}function Da(t){return Object.entries(t).some(([e,n])=>(typeof n=="function"||zr(n))&&!cs.has(e))}function Na(t,e,n,i,s){if(!Da(t))return t;const o={};for(const[r,a]of Object.entries(t))cs.has(r)?o[r]=a:typeof a=="function"?o[r]=a(e,n,s):zr(a)?o[r]=i.resolveRandomString(a):o[r]=a;return o}function Ba(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 Wa(t){const e=t;if(typeof e?.getTotalLength=="function")return e.getTotalLength()}function pd(t){if(typeof t=="number"||typeof t=="string"||Array.isArray(t)&&t.every(e=>typeof e=="number"))return t}function gd(t){return typeof t=="string"?`"${t}"`:String(t)}class Ps{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 Ka(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 Gn{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 he}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=Te({...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 Ps(i)})})}syncAllMedia(e,n){for(const i of this.mediaTargets)Ka(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 he;i.querySelectorAll("[data-tinyfly]").forEach(a=>{const l=a.getAttribute("data-tinyfly");l&&r.registerTarget(l,a)}),this.symbolInstances.push({adapter:r,timeline:Te(o.timeline)})})}attachMedia(e,n){this.mediaSync=new Ps(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}=es(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 md(t,e,n={}){const i=new Gn(t,{...n,autoplay:!0});return await i.load(e),i}function yd(t,e={}){return new Gn(t,e)}const Ya={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",bd=`
|
|
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 wd=0;function kd(t){if(t.getElementById(ja))return;const e=t.createElement("style");e.id=ja,e.textContent=bd,t.head.appendChild(e)}function Xa(t,e,n={}){const i=e.ownerDocument;kd(i);const s={...Ya,...n.labels},o=n.speeds??[.5,1,2],r=()=>t.markers.length>0,a=()=>t.markers.some(X=>X.label!==void 0||t.caption(X.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=(X,G,$,L="")=>{const W=i.createElement("button");return W.type="button",W.className=`tf-ctl-btn ${L}`.trim(),W.setAttribute("aria-label",X),W.title=X,W.textContent=G,W.addEventListener("click",$),W},u=h(s.restart,"⟲",()=>{t.pause(),t.seek(0)}),f=h(s.prev,"|◀",()=>t.prev()),d=h(s.play,"▶",()=>t.isPlaying?t.pause():p(),"tf-ctl-primary"),g=h(s.next,"▶|",()=>t.next()),p=()=>{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 X of o){const G=i.createElement("option");G.value=String(X),G.textContent=`${X}×`,X===1&&(G.selected=!0),w.appendChild(G)}w.addEventListener("change",()=>t.setSpeed(Number(w.value))),c.append(u,f,d,g,m,y),o.length>0&&c.append(w),l.append(c);const k=n.fullscreen?Td(e,i,s):void 0;k&&c.append(k.button);const E=i.createElement("p");E.className="tf-ctl-caption",E.setAttribute("aria-live","polite"),n.captions!==!1&&l.append(E);const T=i.createElement("div");T.className="tf-ctl-question",T.hidden=!0;const S=i.createElement("span"),P=h(s.reveal,s.reveal,()=>t.play(),"tf-ctl-primary");T.append(S,P),l.append(T);const O=vd(t,i,s.scenario,n.scenarioControl??"buttons");O&&l.append(O.element);const A=n.mount;A?A.appendChild(l):e.insertAdjacentElement("afterend",l);const C=()=>{const X=t.isPlaying;d.textContent=X?"❚❚":"▶",d.setAttribute("aria-label",X?s.pause:s.play),d.title=X?s.pause:s.play;const G=t.duration;i.activeElement!==m&&(m.value=String(G>0?Math.round(t.currentTime/G*1e3):0));const $=t.markers;if(f.hidden=g.hidden=y.hidden=$.length===0,$.length>0){const L=t.currentMarker,W=L?$.indexOf(L)+1:0;y.textContent=s.stepFormat.replace("{index}",String(W)).replace("{total}",String($.length)),y.setAttribute("aria-label",`${s.step} ${W} ${s.of} ${$.length}`),f.disabled=t.currentTime<=.5,g.disabled=t.currentTime>=G-.5;const j=t.caption()??"";E.textContent!==j&&(E.textContent=j),E.hidden=!a();const v=!X&&L?.question!==void 0&&Math.abs(t.currentTime-L.time)<1;T.hidden=!v,v&&S.textContent!==L.question&&(S.textContent=L.question)}else T.hidden=!0,E.hidden=!0;O?.update()},I=t.subscribe(C);C();const R=n.keyboardScope??e;!R.hasAttribute("tabindex")&&R.tabIndex<0&&(R.tabIndex=0);const F=new WeakSet,N=X=>{if(F.has(X)||(F.add(X),X.defaultPrevented||X.altKey||X.ctrlKey||X.metaKey))return;const G=X.target;if(!(G.tagName==="INPUT"||G.tagName==="SELECT")&&!(X.key===" "&&G.tagName==="BUTTON"))switch(X.key){case" ":X.preventDefault(),t.isPlaying?t.pause():p();break;case"ArrowRight":if(!r())return;X.preventDefault(),t.next();break;case"ArrowLeft":if(!r())return;X.preventDefault(),t.prev();break;case"Home":X.preventDefault(),t.pause(),t.seek(0);break;case"f":case"F":if(!k)return;X.preventDefault(),k.active?k.exit():k.enter();break}};return R.addEventListener("keydown",N),l.addEventListener("keydown",N),{element:l,fullscreen:k&&{get active(){return k.active},enter:k.enter,exit:k.exit},destroy(){k?.destroy(),I(),R.removeEventListener("keydown",N),l.removeEventListener("keydown",N),l.remove()}}}function vd(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 u=e.createElement("span");u.textContent=n,u.setAttribute("aria-hidden","true");const f=e.createElement("input");f.type="range",f.min="0",f.max=String(s.length-1),f.step="1",f.setAttribute("aria-label",n);const d=e.createElement("output");return d.setAttribute("aria-hidden","true"),f.addEventListener("input",()=>{const p=s[Number(f.value)];p&&t.setScenario(p.id)}),h.append(u,f,d),{element:h,update:()=>{const p=Math.max(0,s.findIndex(y=>y.id===t.scenario));e.activeElement!==f&&(f.value=String(p));const m=s[p].label;d.textContent!==m&&(d.textContent=m),f.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-${++wd}`,l=s.map(h=>{const u=e.createElement("label");u.className="tf-ctl-choice";const f=e.createElement("input");f.type="radio",f.name=a,f.value=h.id,f.addEventListener("change",()=>{f.checked&&t.setScenario(h.id)});const d=e.createElement("span");return d.textContent=h.label,u.append(f,d),o.append(u),f});return{element:o,update:()=>{for(const h of l){const u=h.value===t.scenario;h.checked!==u&&(h.checked=u)}}}}const Sd='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',Md='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';function Td(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 p=r!==void 0;o.innerHTML=p?Md:Sd;const m=p?n.exitFullscreen:n.fullscreen;o.setAttribute("aria-label",m),o.title=m,o.setAttribute("aria-pressed",String(p)),t.classList.toggle("tf-fullscreen",p),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()},u=p=>{p.key==="Escape"&&g()},f=()=>{r="overlay",a=e.documentElement.style.overflow,e.documentElement.style.overflow="hidden",e.addEventListener("keydown",u),l()};async function d(){if(r)return;const p=s.requestFullscreen?.bind(s)??s.webkitRequestFullscreen?.bind(s),m=i.fullscreenEnabled??i.webkitFullscreenEnabled??!1;if(p&&m)try{if(await p(),c()===t){r="native",l();return}}catch{}f()}async function g(){if(r==="overlay")e.removeEventListener("keydown",u),e.documentElement.style.overflow=a,r=void 0,l();else if(r==="native"){r=void 0,l();const p=i.exitFullscreen?.bind(i)??i.webkitExitFullscreen?.bind(i);c()===t&&p&&await p()}}return o.addEventListener("click",()=>{r?g():d()}),e.addEventListener("fullscreenchange",h),e.addEventListener("webkitfullscreenchange",h),l(),{button:o,get active(){return r!==void 0},enter:d,exit:g,destroy(){g(),e.removeEventListener("fullscreenchange",h),e.removeEventListener("webkitfullscreenchange",h),o.remove()}}}const qa="tinyfly-choices-style",Ed=`
|
|
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 pn=new WeakMap,Ki=new WeakMap;let of=0;function Ce(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=pn.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?Ce(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=Ce(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),h={playWhenVisible:!0,...t.player,...c&&{captions:c},...Ce(e.getAttribute("data-options"),"data-options",e)};hf(e);const u=new dn(e,h),f={element:e,player:u};if(pn.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}),Ki.set(e,Uo(u,e))}else await u.load(l??r);if(e.getAttribute("data-controls")!=="false"){const d=Ce(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=Ce(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=pn.get(e);t&&(Ki.get(e)?.(),Ki.delete(e),t.controls?.destroy(),t.player.destroy(),pn.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:Ut(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?Ut(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 te(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 mn(e,t){const n=te(e,t);return n[n.length-1]}function Yi(e,t){return t>0?Math.floor(Math.max(0,e)*t/1e3):0}function gn(e,t,n){const i=t.roughness??2,s=Math.max(1,Math.round(t.passes??2)),r=Yi(n,t.boil??8);let o=0;const a=()=>{const f=o++;return d=>ve(zt(`${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=te(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=te(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 He(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 yn(e,t,n,i){const s=t.length;if(s<2)return;const r=He(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 Xi(e,t,n,i,s,r=0,o=1,a=40){const l=Math.cos(s),c=Math.sin(s);return Array.from({length:a+1},(h,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 qi(e,t){return t.look==="pencil"?wf(e,t):gf(e,t.ink,t.look)}function bn(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,yn(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",bn(e,r),e.stroke())},shape(r,o,a){bn(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=Yi(t.time,n.boil??8);let c=0;const h=(m,p,g=!1)=>ve(zt(`${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,bn(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(Xi(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,bn(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=Xi(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 ee(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,Vi=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],wn=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],Ui=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],$e=e=>{const t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function St(e,t,n){const i=Math.cos(n),s=Math.sin(n),r=Ui(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],Re=[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(Vi(o[u],wn(St(s,r,-a),h)))});const l=St(Re,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=$e(Vi(wn($e(dt.out),1-s),wn($e(dt.across),s))),o=$e(Ui(Re,r)),a=$e(Ui(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(Vi(l[d],wn(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 kn(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),Re,-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(Re)[2],fingers:T,axes:{up:S(m(ia)),across:S(m(na)),out:S(m(Re))},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 vn(e,t,n,i={},s=0){const r=sa(kn(n,i),t),o=i.ink??$f,a=i.lineWidth??r.size*.035,l=i.pen??qi(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,yn(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 Oe(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=Oe(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=Oe(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 ne(e,t){return{...e,...typeof t=="string"?G[t]:t}}const ie={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 se(e,t,n){const i={...e};for(const s of la)i[s]=e[s]+(t[s]-e[s])*n;return i}const zi=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:-zi*i,rightHip:-zi*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*((Gi+Sn)*e)*Math.sin(zi*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,Gi=.24,Sn=.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,Mn=90,nd=.25,id=.04,Ma=.01,Rt=e=>Math.min(1,Math.max(0,e??0));function sd(e,t=1){return Sn*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+(-Mn-e.leftHip)*l,h=e.leftKnee+(-Mn-e.leftKnee)*l,u=e.rightHip+(Mn-e.rightHip)*l,f=e.rightKnee+(Mn-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)=>Gi*Math.cos(rt(K))+Sn*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,$,Gi*i);return{root:{x:0,y:k},joint:D,end:P(D.x,D.y,L-O,$,Sn*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=Fe(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 Le=(e,t)=>t===0?[e.root,e.joint,e.end]:Ht(e.root,e.joint,e.end,t);function Fe(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=Fe(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(Fe(M,s,n)),a=M=>o(ad(e,M)),l=M=>a(Fe({x:M.x,y:M.y+e.neckY},{x:0,y:e.neckY},i)),c=Le(e.arms.left,e.rubber).map(a),h=Le(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:Le(e.legs.left,e.rubber).map(r),rightLeg:Le(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 Fe({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?gn(e,n.sketch,i):void 0,c=n.sketch&&n.layers?gn(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}yn(e,E,v[0]*s.lineWidth,v[1]*s.lineWidth)},g=(E,T)=>p(Le(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";vn(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 Ji(e,t,n){const i={...e};let s=e.walking>0?se(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=se(s,a.pose,o),a.hands){const l=(c,h)=>h?ee(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 Ji(e,t,n).pose}const La=(e,t)=>(e.facing??t.facing??1)<0?-1:1,De=(e,t)=>`hand.${e}.${t}`;function ud(e){const t=s=>{if(typeof e[De(s,"spread")]=="number")return Object.fromEntries(Object.keys(Y).map(r=>[r,e[De(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[De(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=Ji(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 Zi(e){const t=[];return e.forEach((n,i)=>{const s=i===0?W:t[i-1],r=typeof n.pose=="string"?ie[n.pose]:{...s,...n.pose};t.push(n.expression?ne(r,n.expression):r)}),t}function pd(e,t){const n=Zi(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 Qi=.5,ts={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 Tn(e){return typeof e!="string"?e:e in ts?ts[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?Tn(s.hands.left):o.left,right:s.hands?.right?Tn(s.hands.right):o.right,easing:s.easing??e.easing})}return i}const es=(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=es(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:se(a.pose,l.pose,f),hands:{left:ee(a.left,l.left,f),right:ee(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=es(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 En(e){const t={...W,...e.stance};return e.expression?ne(t,e.expression):t}function Wa(e){return{left:e.hands?.left?Tn(e.hands.left):Y,right:e.hands?.right?Tn(e.hands.right):Y}}function ns(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,En(e),Wa(e));return t.mirror?{pose:Ba(s.pose),hands:{left:s.hands?.right,right:s.hands?.left}}:s}function An(e,t,n={}){const i=typeof e=="string"?Ot[e]:e;let s;if(n.move)s=ns(i,{move:n.move,mirror:n.mirror},t);else{const r=i.routine,o=r.reduce((u,f)=>u+f.beats,0),a=es(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=ns(i,r[c],h),h<Qi&&r.length>1&&t>=Qi){const u=r[(c-1+r.length)%r.length],f=ns(i,u,u.beats+h),d=J("ease-in-out")(h/Qi);s={pose:se(f.pose,s.pose,d),hands:{left:ee(f.hands.left,s.hands.left,d),right:ee(f.hands.right,s.hands.right,d)}}}}return{...s,pose:Na(s.pose,i.groove,t)}}function kd(e,t,n={}){return An(e,t,n).pose}function xn(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=xn(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,En(e),Wa(e))[0]?.pose.turn??En(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 Pn(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:xn(i)),o=Md(i,r,n);if(o.every(y=>Pn(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+=(Pn(i,E,n)-Pn(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=>An(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:xn(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:An(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(De(p,g),y))}return[...f,...m]}const Be={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:Be},{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:Be,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:Be},{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:Be},{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:Be},{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}]}},_n=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"?Cn[e]:e,i=Bd(n),s=_n(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=se(o.pose,a.pose,J(a.easing??"ease-in-out")(_n(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"?Cn[e]:e,s=_n(t),r=_n((s-i.takeoff)/(i.landing-i.takeoff));return i.travel*n*r}function Yd(e,t,n={}){const i=typeof t=="string"?Cn[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},In={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 re(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 Cn={frontFlip:re("Front flip (tuck)",360,.56,.35,[{at:.38,pose:In,easing:"ease-out-cubic"},{at:.64,pose:In}]),backFlip:re("Back flip (tuck)",-360,.58,-.15,[{at:.36,pose:{...In,lean:18},easing:"ease-out-cubic"},{at:.64,pose:{...In,lean:18}}]),layout:re("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:re("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:re("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:re("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)},is=.215,ss=.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-(is+ss)),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:is,width:[1.45,1.05]},{length:ss,width:[1.05,.85]},{length:zd,width:[.95,.7]}]}),a=(l,c)=>l[c]??q[c]??0;return{id:"human",hipHeight:is+ss,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 rs([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]],Hn=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],$n=(e,t)=>rs(Za(e,t.swing),t.spread);function os(e,t){const n=Lt(e,t);return{point:{x:n[0],y:-n[1]},depth:n[2]}}function Rn(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,$n(Hn(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($n(p.rest,{swing:_,spread:P}),at(C.yaw??0));T.push(Mt(T[I],Hn(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=>$n(Lt(Za(rs(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 as(e,t,n){const i=n.height,s=at(90*(t.turn??0)),r=Rn(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=>os(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=os(u,s),m=[[1,0,0],[0,1,0],[0,0,1]].map(v=>Lt(h(v),s)),p=os(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 ls=(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 cs(e,t,n){const i=n.height,s=at(90*(t.turn??0)),r=at(t.roll??0),o=Rn(e,t,i),a=Lt(o.root,s),l=g=>Mt(rs(ls(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(ls(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,Hn(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 hs(e,t,n,i){const s=n.height,r=at(90*(t.turn??0)),o=Rn(e,t,s),a=cs(e,t,n),l=a.hip,c=a.chains,h=a.head.center,u=v=>{if("head"in v)return Mt(h,Hn(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(ls(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 us=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*us,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*us;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*us;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 On=e=>e*180/Math.PI,oe=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],fs=(e,t)=>e[0]*t[0]+e[1]*t[1]+e[2]*t[2],Ne=e=>Math.hypot(e[0],e[1],e[2]),ds=e=>{const t=Ne(e)||1;return[e[0]/t,e[1]/t,e[2]/t]},Ln=e=>Math.atan2(Math.sin(e),Math.cos(e));function sl(e){const[t,n,i]=ds(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=as(e,{...t,turn:0,roll:0,lift:0},{height:s.height,contact:"none"}),a=o.chains[n],l=a.joints3[0],c=Ne(oe(a.joints3[1],a.joints3[0])),h=Ne(oe(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=oe(i,l),d=Math.min(c+h-1e-6,Math.max(Math.abs(c-h)+1e-6,Ne(f))),m=ds(f),p=r.parent!==null,g=$n(r.pole??(p?[0,-.35,-1]:[0,0,1]),u);let y=oe(g,[m[0]*fs(g,m),m[1]*fs(g,m),m[2]*fs(g,m)]);Ne(y)<1e-6&&(y=Lt([1,0,0],0)),y=ds(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(oe(M,l)),T=sl(oe(S,M)),v=[{swing:On(Ln(E.swing-u.swing)),spread:On(Ln(E.spread-u.spread))*A},{swing:On(Ln(T.swing-E.swing)),spread:On(Ln(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 Fn(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 Dn=(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}}),ps=(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)=>Fn(t,y,w).points,o=(y,w)=>Fn(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(Dn({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(ps(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(ps(_,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(Dn({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=[...Dn({x:d,y},{x:0,y:ft-p*2},{x:-d,y})]}else if(a<-.3){const y=ft-p*.6;g=[...Dn({x:d,y},{x:0,y:ft+p*1.4},{x:-d,y})]}else g=ps(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 ms=e=>e.rest[1]<-.5,k0=.3;function v0(e,t,n){return e.figure==="stick"?ms(t)?n.slice(0,3):n:ms(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 gs(e,t){const n=e.plan.id==="human"?{...q,...t}:t;return ys(e,n,as(e.plan,n,{height:e.height,contact:e.contact}))}function ys(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 gs(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=Fn(i,s,{x:0,y:0});o.facing>0&&e.guide(o.points),e.guide(Fn(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(ms(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;vn(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,gs(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=hs(e.plan,s,{height:i.height,contact:e.contact},n);return ys(hl(e,r.height),s,r).joints}function ul(e,t,n,i,s){const r=t.plan.id==="human"?{...q,...n}:n,o=hs(t.plan,r,{height:s.height,contact:t.contact},i),a=hl(t,o.height);fl(e,a,r,ys(a,r,o),s.time??0)}function fl(e,t,n,i,s){const{joints:r,order:o}=i,a=qi(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}=gs(e,s),a=as(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 bs(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=bs(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=Me([0,1,0],e);if(t>.999999)return Kr();if(t<-.999999)return Ee(qt([1,0,0],180));const n=on([0,1,0],e);return Ee(qt(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(Te(rn(v,T)));f(t.cylinder,_t(Yr(C),_t(H,an([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,an([p,g,p])),l);for(const k of[-1,1]){const M=Te([k*.36,.15,.92]),S=sn(m,sn(sn(Se(y[0],M[0]*p*1.04),Se(y[1],M[1]*g*1.04)),Se(y[2],M[2]*p*1.04))),A=[...y[0],0,...y[1],0,...y[2],0,...S,1];f(t.sphere,_t(A,an([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=cs(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 ws(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 ks(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=kn(d,{size:u}),g=c-m(p).direction,y=kn(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),vn(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"?ws(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:mn(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?gn(a,e.sketch,c):void 0;h>0&&(u?e.smooth?u.curve(t,h):u.line(t,h):bl(a,te(t,h))),o&&h>0&&h<1&&ks(a,mn(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 Bn=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 vs(e,t,n,i){if(i<=0||t.length===0)return;const s=te(t,i),r=n/2,o=a=>{e.beginPath(),e.rect(-Bn,-Bn,2*Bn,2*Bn),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(),vs(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(),vs(r,t.path,n,l),e.draw(r,o,a),r.restore(),!s||l<=0||l>=1)return;const c=mn(t.path,l);i?ks(r,c,{...i,tool:"eraser"}):ws(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=Oe(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=Oe(e);return 4*G0*t*Math.sin(i.swing*n*Math.PI/180)}const ae=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}),...ae("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"),...ae("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,...ae("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,...ae("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:{...ae("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:{...ae("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(He(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(He([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=He(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 Nn={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 Nn.full;if(typeof e=="string")return Nn[e];const{base:t,...n}=e;return{...Nn[t??"full"],...n}}const Ss=160,ep=120,np=700,Ms=60,ip=90,Wn=3200,le=1,Ft=1e-6;function Ts(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+le){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+Ss),g,"ease-in-out"),f=g;else if(k&&a&&i.drift>0&&n.drift.includes(e)&&P-w>=np){const x=zt(`${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<=le){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>=Ss){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&&_>le){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=Ms+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+Wn*.6,u=0;for(;h<l;){c.some(p=>Math.abs(p-h)<Wn/2)||r.push(h);const m=(zt(`${i}:blink:${u++}`)%1e3/1e3-.5)*(Wn*.66);h+=Wn+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+Ms<=m+le||(d>m+le&&f.push({time:d,value:s}),f.push({time:d+Ms,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+le||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<Ss||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=Zi(t),s=t.map((r,o)=>({time:r.time,pose:{...i[o]},easing:r.easing,act:r.act}));return Tl(e,Ts(s,n.rig??Sl,n))}function cp(e,t,n={}){const i=n.rest??q,s=bs(t,i),r=t.map((o,a)=>({time:o.time,pose:{...i,...s[a]},easing:o.easing,act:o.act}));return Tl(e,Ts(r,n.rig??Ml,n))}const Al=G.shocked,hp=G.scared,Kn={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:{...ie.sad,bend:18,stretch:.92,lean:e.lean+5,turn:e.turn,sit:e.sit},easing:"ease-in-out"}]};function Es(e,t){const n=typeof t.from=="string"?ie[t.from]:t.from??W,i=t.speed??1;let s=n;return[{time:t.at,pose:n},...Kn[e](n).map(r=>(s={...s,...r.pose},{time:t.at+r.after*i,pose:s,act:!1,...r.easing?{easing:r.easing}:{}}))]}function As(e,t=1){const n=Kn[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=zt(`${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}},We=1,Yn=.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",We),s++;else if(r in _l)i(_l[r],We);else if(r in Il)i(Il[r],Yn);else{if(r==="h")continue;if(/[a-z]/.test(r))i("c",Yn);else if(r in Cl)i(Cl[r],We);else if(wp(r)){const a=o===$l?r==="फ"?"f":void 0:yp[r];i(a??"c",Yn);let l=s+1;n[l]===$l&&l++;const c=n[l];c===bp?s=l:c&&c in Hl?(i(Hl[c],We),s=l):(!c||/\s/.test(c)||Rl.has(c)||i("a",We*.6),s=l-1)}else(r==="ं"||r==="ँ")&&i("l",Yn*.6)}}for(;t.length>0&&(t[t.length-1].viseme==="rest"||t[t.length-1].weight===Pl);)t.pop();return t}function xs(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(xs(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 ke({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=xs(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 Ps={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,ce=320,he=220,Ep=65,Ap=700,_s=e=>e in $t,Bl=e=>e in Kn,xp=e=>e in ie;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=ne(a,_)),h.push({time:T,pose:a})},M=(T,v,_)=>(k(T+ce/2,{turn:0},_),p.push({time:T+ce/2,value:o},{time:T+ce/2+1,value:v}),o=v,k(T+ce,{turn:1}),T+ce),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(_s(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+he,k(C,{turn:1,...P},T.mood)):(T.mood||T.pose)&&k(v+he,P,T.mood);const R=Math.abs(x-r)/oa(T.do,s),B=T.for??Math.max(he*2,R*Ps[T.do]),$=C+B;m.push({time:C,value:T.do}),d.push({time:C,value:0},{time:C+he,value:1,easing:"ease-out"}),d.push({time:$-he,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+he,k(C,{turn:1},T.mood));const H=Es("windUp",{at:C,from:T.mood?ne(a,T.mood):a});h.push(...H),a=H[H.length-1].pose;const R=C+As("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)/Ps.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=Es(T.do,{at:v,from:T.mood?ne(a,T.mood):a});h.push(...x),a=x[x.length-1].pose,_=v+As(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+ce+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:ie[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=_s(T.do)||Bl(T.do)?v:v+Math.min(150,(_-v)/4),I=_s(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",Is(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 Is(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){Is(e,t,n);return}m.translate(-u,-f),m.globalCompositeOperation="lighter",Is(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=Nn,b.Clock=Vl,b.CompatTimeline=It,b.CustomBounce=$o,b.CustomEase=Ho,b.CustomWiggle=Ro,b.DANCE_STYLES=Ot,b.DEFAULT_BAKE_INTERVAL_MS=li,b.DEFAULT_INERTIA_FRICTION=jn,b.DEFAULT_LABELS=Yo,b.DEFAULT_SPRING=st,b.DEFAULT_TRANSITION=df,b.Draggable=xi,b.EXPRESSIONS=G,b.FINGERS=ea,b.FLIPS=Cn,b.FORMAT_VERSION=Xn,b.GAGS=Kn,b.GAITS=$t,b.GAIT_CYCLE_MS=Ps,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=ts,b.ManualClock=ql,b.MediaSync=Wi,b.Observer=lo,b.POSES=ie,b.REST_POSE=W,b.SPRING_MAX_DURATION_MS=Gn,b.SPRING_PRESETS=Ve,b.SPRING_STEP_MS=Bt,b.STICK_ACTING_RIG=Sl,b.ScrollAnimator=Eo,b.ScrollDriver=_e,b.ScrollMarkers=Ao,b.ScrollPin=vo,b.SmoothScroll=Di,b.SpringSampler=de,b.SpringTrackPlayer=kr,b.Stage=no,b.Timeline=ke,b.TinyflyPlayer=dn,b.TinyflySequencer=Jo,b.TrackPlayer=Qe,b.VISEMES=Et,b.ValueResolver=Kc,b.VisibilityDriver=ko,b.actCharacterTracks=cp,b.actKeyframes=Ts,b.actTracks=El,b.applyBloom=Op,b.applyCamera=D0,b.applyGroove=Na,b.backOut=qs,b.bakeDanceTracks=Pd,b.bakeEasing=ui,b.bakeInertiaTrack=hi,b.bakeSpringTrack=ci,b.basicOutfit=tp,b.beatAt=Ed,b.beatAtTime=en,b.beatLength=bi,b.beatTime=tn,b.beatsBetween=th,b.bindChoiceHotspots=Uo,b.blendPose=se,b.boilFrame=Yi,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=Ri,b.clearMorphCache=Mc,b.clearPathCache=cc,b.clipErased=vs,b.containerProgressAt=Oi,b.context=Up,b.create=Gu,b.createControls=qo,b.createCubicBezier=Ks,b.createLive=Fo,b.createPen=qi,b.createRandom=ve,b.createTrack=Ze,b.criticalDamping=Gl,b.customBounce=$r,b.customEase=Hr,b.customWiggle=Rr,b.danceFrame=An,b.dancePose=kd,b.danceStance=En,b.danceTaps=Sd,b.danceTracks=xd,b.danceTravel=Pn,b.danceTravelTrack=qa,b.dancer=Ad,b.deserializeTimeline=Ut,b.deserializeTrack=Ar,b.detectTempo=eh,b.draggable=lu,b.drawCartoonHand=vn,b.drawCharacter=cl,b.drawCharacterInView=ul,b.drawDustPuff=dp,b.drawEraser=ws,b.drawHand=ks,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=Jn,b.easeInOut=Ws,b.easeInOutCubic=me,b.easeInOutQuad=Ds,b.easeInQuad=Ls,b.easeOut=Ns,b.easeOutCubic=Zn,b.easeOutQuad=Fs,b.elasticOut=Ys,b.ellipsePoints=Xi,b.erasable=z0,b.expandParametricEasings=br,b.flipPose=Va,b.flipTracks=Yd,b.flipTravel=Ua,b.formatVersionFor=qn,b.from=Wp,b.fromJSON=Bc,b.fromTo=Kp,b.gag=Es,b.gagDuration=As,b.gaitPose=ra,b.gaitStrideLength=oa,b.getEasingFunction=J,b.getInterpolator=we,b.getMotionPathPoint=fi,b.getPathLength=hc,b.getPointAtProgress=js,b.gridLinesFor=uo,b.handAt=K0,b.handJoints=kn,b.handJointsAt=sa,b.handPose=X,b.handProp=De,b.hasKeyframes=Hs,b.hashSeed=zt,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=Wt,b.inertiaRest=Nt,b.inertiaValueAt=ze,b.inertiaVelocityAt=Ql,b.interpolateArray=pr,b.interpolateColor=dr,b.interpolateMotionPath=Rc,b.interpolateNumber=lt,b.interpolatePathString=gr,b.interpolateQuaternion=mr,b.interpolateString=ai,b.isCubicBezierEasing=Cs,b.isInertiaTrack=mt,b.isMotionPathPoint=Xl,b.isMotionPathTrack=Vn,b.isParametricEasing=ue,b.isPathData=Yt,b.isSpringTrack=gt,b.isTextTrack=Ke,b.isUnderdamped=zl,b.isUnresolved=Wc,b.jointsInScene=dl,b.jointsToScene=$a,b.linear=Ge,b.lipSyncKeyframes=xs,b.lipSyncOver=Ll,b.lipSyncTracks=kp,b.live=tt,b.mapEase=Ae,b.mat4=mh,b.matchMedia=zp,b.maxStaggerDistance=zn,b.mirrorHumanPose=i0,b.mirrorPose=Ba,b.mixHandPoses=ee,b.mixPoses=A0,b.morphPath=ir,b.mount=zo,b.mountAll=jo,b.narrationMarkers=jc,b.narrationSceneAt=Jc,b.naturalRest=pe,b.nearestBeat=Zc,b.nextBeat=Qc,b.pageTransition=Jp,b.parametricEasing=Us,b.parseEdge=Hi,b.parsePath=Pt,b.parseTrigger=$i,b.partialPath=te,b.pathLength=Zo,b.planNarration=Gc,b.play=zu,b.playSequence=ff,b.playWhenVisible=vu,b.playheadCrossings=pi,b.pointAlong=mn,b.pointAtDistance=ti,b.pointOnHead=w0,b.pointsToPath=Fr,b.pose=j,b.poseTracks=pd,b.quat=_c,b.quickPlay=Hp,b.quickTo=Gp,b.randomBetween=gi,b.randomChoice=Nc,b.randomSnapped=Pr,b.reachCharacter=x0,b.resolveActingStyle=vl,b.resolveCharacterPoseKeys=bs,b.resolveGait=Oe,b.resolvePoseKeys=Zi,b.resolveSequence=Cr,b.resolveStickFrame=Ji,b.resolveStickPose=Oa,b.resolveValue=yi,b.ribbon=Dr,b.ribbonHeadCap=Br,b.rotateAbout=St,b.routineBeats=xn,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=nn,b.simplifyKeyframes=wr,b.skeletonInView=hs,b.sketchPen=gn,b.smoothToward=wo,b.snapAxis=ho,b.snapConfig=So,b.snapDuration=To,b.snapProgress=Mo,b.solvePlanSpace=Rn,b.soundsOf=Ol,b.speechDuration=Nl,b.splitText=Vp,b.springDuration=Rs,b.springValueAt=Ul,b.stagePlanSpace=cs,b.staggerDistance=Un,b.staggerOffset=Ye,b.staggerOffsets=Xe,b.staggerSpan=fe,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=yn,b.taperedOutline=He,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=ne,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});
|
|
53
|
+
`;function Ad(t){if(t.getElementById(qa))return;const e=t.createElement("style");e.id=qa,e.textContent=Ed,t.head.appendChild(e)}function Ua(t,e){const n=Array.from(e.querySelectorAll("[data-tinyfly-choose]"));if(n.length===0)return()=>{};Ad(e.ownerDocument);const i=[],s=[];for(const a of n){const l=a.getAttribute("data-tinyfly-choose")??"",c=[],h=(g,p)=>{a.hasAttribute(g)||(a.setAttribute(g,p),c.push(g))};h("role","button"),h("tabindex","0");const u=t.scenarios.find(g=>g.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=()=>t.setScenario(l),d=g=>{const p=g.key;p!=="Enter"&&p!==" "||(g.preventDefault(),f())};a.addEventListener("click",f),a.addEventListener("keydown",d),s.push(()=>{a.removeEventListener("click",f),a.removeEventListener("keydown",d)})}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 zn=new WeakMap,$s=new WeakMap;let xd=0;function rn(t,e,n){if(t)try{return JSON.parse(t)}catch(i){console.warn(`tinyfly: invalid ${e} JSON on`,n,i);return}}async function Va(t,e={}){const n=zn.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=$d(t.getAttribute("data-markers")),a=i.length>1||s?.hasAttribute("data-scenario")?Pd(i,r,t):void 0;if(a&&a.length===0)return;let l=s&&!a?rn(s.textContent,"timeline",t):void 0;if(!l&&o&&r){const d=await fetch(o);d.ok&&(l=await d.json())}if(l&&r&&(l=Ga(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=rn(t.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",t),h={playWhenVisible:!0,...e.player,...c&&{captions:c},...rn(t.getAttribute("data-options"),"data-options",t)};Id(t);const u=new Gn(t,h),f={element:t,player:u};if(zn.set(t,f),t.setAttribute("data-tinyfly-mounted",""),a){const d=t.getAttribute("data-scenario")??void 0;await u.loadScenarios(a,{initial:a.some(g=>g.id===d)?d:void 0}),$s.set(t,Ua(u,t))}else await u.load(l??o);if(t.getAttribute("data-controls")!=="false"){const d=rn(t.getAttribute("data-labels"),"data-labels",t),g=t.querySelector("figcaption"),p=t.getAttribute("data-scenario-legend"),m=t.getAttribute("data-scenario-control");f.controls=Xa(u,t,{...e.controls,...t.getAttribute("data-fullscreen")==="true"?{fullscreen:!0}:{},...m==="slider"||m==="buttons"?{scenarioControl:m}:{},labels:{...e.controls?.labels,...d,...p?{scenario:p}:{}},mount:void 0}),g?t.insertBefore(f.controls.element,g):t.appendChild(f.controls.element)}return f}function Pd(t,e,n){const i=[];return t.forEach((s,o)=>{const r=rn(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?Ga(r,e):r})}),i}function Ga(t,e){return t.config.markers?.length?t:{...t,config:{...t.config,markers:e.map((n,i)=>({id:`step-${i+1}`,time:n}))}}}function $d(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 za(t=document,e={}){const n=Array.from(t.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(n.map(s=>Va(s,e)))).filter(s=>s!==void 0)}function _d(t){const e=zn.get(t);e&&($s.get(t)?.(),$s.delete(t),e.controls?.destroy(),e.player.destroy(),zn.delete(t),t.removeAttribute("data-tinyfly-mounted"))}function Id(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-${++xd}`,e.setAttribute("aria-labelledby",i.id))}function Hd(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const e=()=>{za()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}class Ja{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 he,this.adapterB=new he}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 he;s.querySelectorAll("[data-tinyfly]").forEach(l=>{const c=l.getAttribute("data-tinyfly");c&&a.registerTarget(c,l)}),i.push({adapter:a,timeline:Te(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?Te(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 Cd(t,e,n={}){const i=new Ja(t,{...n,autoplay:!0});return await i.load(e),i}const Od={type:"none",duration:0},at=t=>({description:t,unit:"degrees"}),rt=(t,e=0,n=1)=>({description:t,unit:`${e}..${n}`,min:e,max:n}),Za={lean:at("Upper body tipped about the hips (+ toward the way it faces)"),bend:at("Line of action: the spine curved (+ curls forward, − arches back)"),headTilt:at("Head tilt"),leftShoulder:at("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:at("Right upper arm: 0 hangs down, 90 straight out (forward, in profile), 180 straight up"),leftElbow:at("Left elbow bend, added to the upper arm"),rightElbow:at("Right elbow bend, added to the upper arm"),leftHip:at("Left thigh: 0 straight down; in profile negative is forward"),rightHip:at("Right thigh: 0 straight down; in profile positive is forward"),leftKnee:at("Left knee bend (negative folds the shin back)"),rightKnee:at("Right knee bend (positive folds the shin back)"),leftWrist:at("Left wrist bend, added to the forearm"),rightWrist:at("Right wrist bend, added to the forearm"),leftAnkle:at("Left ankle: + points the toe down (tiptoe), − onto the heel"),rightAnkle:at("Right ankle: + points the toe down (tiptoe), − onto the heel"),leftFootOut:rt("Left foot turned out (seen from the front): 0 natural, 1 sideways, negative turned in",-1,1),rightFootOut:rt("Right foot turned out (seen from the front): 0 natural, 1 sideways, negative turned in",-1,1),mouth:rt("Mouth open: 0 closed, 1 wide open"),smile:rt("−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:rt("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:rt("Left eyebrow: −1 lowered, 0 rest, 1 raised",-1,1),rightBrow:rt("Right eyebrow: −1 lowered, 0 rest, 1 raised",-1,1),browTilt:rt("Eyebrow slant: −1 angry, 1 worried",-1,1),lookX:rt("Eyes look across: + the way it faces",-1,1),lookY:rt("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:rt("0 front-on, 1 in profile, turned the way it faces"),sit:rt("0 standing, 1 seated"),spin:at("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"}},Qa={walk:{description:"Walk-cycle phase, in strides: animate 0 → n for n strides",unit:"strides"},walking:rt("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:rt("How much the mouth chatters"),rubber:rt("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:rt("How much of the dance is applied")},tl={"thumb.curl":rt("Thumb curled in"),"thumb.across":rt("Thumb across the palm"),"index.curl":rt("Index finger curled"),"middle.curl":rt("Middle finger curled"),"ring.curl":rt("Ring finger curled"),"pinky.curl":rt("Little finger curled"),spread:rt("Fingers spread apart"),turn:at("Hand turned about the forearm"),bend:at("Hand bent at the wrist, palm-ward"),tilt:at("Hand tilted sideways"),roll:at("Hand rolled to show the back or the palm")};let el;function Rd(t){el=t}function Ld(){return el?.()??{}}function nl(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 Ie(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=nl(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 Jn(t,e){const n=Ie(t,e);return n[n.length-1]}function _s(t,e){return e>0?Math.floor(Math.max(0,t)*e/1e3):0}function Zn(t,e,n){const i=e.roughness??2,s=Math.max(1,Math.round(e.passes??2)),o=_s(n,e.boil??8);let r=0;const a=()=>{const f=r++;return d=>Ge(Ee(`${e.seed??1}:${o}:${f}:${d}`))},l=(f,d)=>(f.next()*2-1)*d,c=f=>{const d=a(),g=t.lineWidth,p=t.globalAlpha;for(let m=0;m<s;m++)t.lineWidth=m===0?g:g*.55,t.globalAlpha=m===0?p:p*.6,f(d(m));t.lineWidth=g,t.globalAlpha=p},h=(f,d=1)=>{if(f.length<2)return;const g=f.slice(1).map((m,y)=>Math.hypot(m.x-f[y].x,m.y-f[y].y)),p=g.reduce((m,y)=>m+y,0)*Math.min(1,Math.max(0,d));c(m=>{const y=[],w=[];if(f.forEach((E,T)=>{y.push({x:E.x+l(m,i*.5),y:E.y+l(m,i*.5)}),T>0&&w.push([m.next()*2-1,m.next()*2-1])}),p<=0)return;t.beginPath(),t.moveTo(y[0].x,y[0].y);let k=0;for(let E=1;E<y.length;E++){const T=Fd(y[E-1],y[E],i,w[E-1]),S=g[E-1];if(k+S<=p){t.bezierCurveTo(T[1].x,T[1].y,T[2].x,T[2].y,T[3].x,T[3].y),k+=S;continue}const P=Dd(T,S===0?1:(p-k)/S);t.bezierCurveTo(P[1].x,P[1].y,P[2].x,P[2].y,P[3].x,P[3].y);break}t.stroke()})},u=(f,d,g,p,m=1)=>{c(y=>{const k=y.next()*Math.PI*2,E=Math.PI*2+.15+y.next()*.3,T=[];for(let P=0;P<=14;P++){const O=k+E*P/14,A=l(y,i*.6);T.push({x:f+Math.cos(O)*(g+A),y:d+Math.sin(O)*(p+A)})}const S=Ie(T,m);S.length<2||(il(t,S),t.stroke())})};return{line:h,curve(f,d=1){if(f.length<2)return;const g=f[0],p=f[f.length-1],m=Math.hypot(p.x-g.x,p.y-g.y)||1,y=-(p.y-g.y)/m,w=(p.x-g.x)/m;c(k=>{const E={x:l(k,i*.5),y:l(k,i*.5)},T={x:l(k,i*.5),y:l(k,i*.5)},S=l(k,i*Math.min(1.5,Math.max(.3,m/80))),P=f.map((A,C)=>{const I=C/(f.length-1),R=Math.sin(Math.PI*I)*S;return{x:A.x+E.x+(T.x-E.x)*I+y*R,y:A.y+E.y+(T.y-E.y)*I+w*R}}),O=Ie(P,d);O.length<2||(il(t,O),t.stroke())})},circle(f,d,g,p=1){u(f,d,g,g,p)},ellipse:u,nudge(f=.5){const d=a()(0);return{x:l(d,i*f),y:l(d,i*f)}}}}function Fd(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 Dd([t,e,n,i],s){const o=(u,f)=>({x:u.x+(f.x-u.x)*s,y:u.y+(f.y-u.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 il(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 an(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)],u=Math.hypot(h.x-c.x,h.y-c.y)||1,f=r(l)/2,d=-(h.y-c.y)/u*f,g=(h.x-c.x)/u*f;s.push({x:a.x+d,y:a.y+g}),o.push({x:a.x-d,y:a.y-g})}),[...s,...o.reverse()]}function Qn(t,e,n,i){const s=e.length;if(s<2)return;const o=an(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 ue(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,u={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+(u.x-c.x)*i,y:c.y+(u.y-c.y)*i})}return r}function Is(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,u)=>{const f=o+Math.PI*2*r*u/a,d=Math.cos(f)*n,g=Math.sin(f)*i;return{x:t+d*l-g*c,y:e+d*c+g*l}})}function Hs(t,e){return e.look==="pencil"?Kd(t,e):Nd(t,e.ink,e.look)}function ti(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 Nd(t,e,n){const i=n==="silhouette",s=i?1.25:1;return{look:n,ink:e,limb(o,r,a){t.fillStyle=e,Qn(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",ti(t,o),t.stroke())},shape(o,r,a){ti(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,u){t.beginPath(),t.ellipse(o,r,a,l,c,0,Math.PI*2),(h!==null||i)&&(t.fillStyle=i?e:h,t.fill()),!(u<=0)&&(t.strokeStyle=e,t.lineWidth=u*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 Bd(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 u=h/c;n.push({x:a.x+(l.x-a.x)*u,y:a.y+(l.y-a.y)*u}),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 Wd(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 sl(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 Kd(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=_s(e.time,n.boil??8);let c=0;const h=(g,p,m=!1)=>Ge(Ee(`${e.seed}:${m?"paper":l}:${g}:${p}`)),u=(g,p,m,y,w,k=0)=>{if(g.length<2)return;const E=g.slice(1).reduce((I,R,F)=>I+Math.hypot(R.x-g[F].x,R.y-g[F].y),0);let T=Bd(g,Math.max(1.5,Math.min(e.lineWidth*.8,E/24)));if(k>0&&T.length>=2){const[I,R]=[T[T.length-2],T[T.length-1]],F=Math.hypot(R.x-I.x,R.y-I.y)||1;T=[...T,{x:R.x+(R.x-I.x)/F*k,y:R.y+(R.y-I.y)/F*k}]}const S=sl(m),P=sl(m),O=T.length,A=[],C=[];T.forEach((I,R)=>{const F=O===1?0:R/(O-1),N=T[Math.max(0,R-1)],X=T[Math.min(O-1,R+1)],G=Math.hypot(X.x-N.x,X.y-N.y)||1,$=-(X.y-N.y)/G,L=(X.x-N.x)/G,W=S(F)*w,j=Math.min(1,F/.08,(1-F)/.08),v=(.55+.45*Math.sqrt(Math.max(0,j)))*(1+r*P(F)),x=Math.max(.3,p(F)*v/2),M=I.x+$*W,_=I.y+L*W;A.push({x:M+$*x,y:_+L*x}),C.push({x:M-$*x,y:_-L*x})}),t.save(),t.globalAlpha*=y,t.fillStyle=i,ti(t,[...A,...C.reverse()],!0),t.fill(),t.restore()},f=(g,p)=>{const m=c++,y=h(m,99,!0);if(y.next()<a){const T=(y.next()*2-1)*e.lineWidth*1.4,S=(y.next()*2-1)*e.lineWidth*1.4,P=g.map(O=>({x:O.x+T,y:O.y+S}));u(P,O=>p(O)*1.8,h(m,98,!0),.035,s),u(P,O=>p(O)*.45,h(m,97,!0),.12,s*1.5)}const w=g.slice(1).reduce((T,S,P)=>T+Math.hypot(S.x-g[P].x,S.y-g[P].y),0),k=p(.5)>4&&w>p(.5)*6,E=k?[-.3,.3,0]:[0];for(let T=0;T<o;T++){const S=T===0;E.forEach((P,O)=>{const A=h(m,T*10+O),C=P===0?g:Wd(g,R=>p(R)*P*Math.sqrt(Math.sin(Math.PI*R))),I=!S&&P===0?e.lineWidth*(.3+A.next()*.8):0;u(C,R=>p(R)*(k?.5:1)*(S?1:.6),A,S?.85:.45,s*(S?.6:1),I)})}},d=(g,p,m,y,w,k)=>{const T=h(c,50).next()*Math.PI*2;f(Is(g,p,m,y,w,T,1.08,48),()=>k)};return{look:"pencil",ink:i,limb(g,p,m){f(g,y=>p+(m-p)*y)},line(g,p){f(g,()=>p)},shape(g,p,m){p!==null&&(t.save(),t.globalAlpha*=.88,t.fillStyle=p,ti(t,g,!0),t.fill(),t.restore()),m>0&&f([...g,g[0]],()=>m)},ellipse(g,p,m,y,w,k,E){k!==null&&(t.save(),t.globalAlpha*=.9,t.fillStyle=k,t.beginPath(),t.ellipse(g,p,m,y,w,0,Math.PI*2),t.fill(),t.restore()),d(g,p,m,y,w,E)},dot(g,p,m){t.save(),t.globalAlpha*=.9,t.fillStyle=i,t.beginPath(),t.arc(g,p,m,0,Math.PI*2),t.fill(),t.restore()},guide(g){if(n.construction===!1||g.length<2)return;const p=c++;u(g,()=>Math.max(.6,e.lineWidth*.18),h(p,0),.28,s*1.2,e.lineWidth)},guideEllipse(g,p,m,y,w){if(n.construction===!1)return;const k=c++,E=h(k,0),T=Is(g,p,m,y,w,E.next()*Math.PI*2,1.12,48);u(T,()=>Math.max(.6,e.lineWidth*.18),E,.28,s*1.5)}}}const ol=["thumb","index","middle","ring","pinky"],ct={"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 ht(t={}){return{...ct,...t}}const Et=(t,e,n,i,s)=>({"thumb.curl":t,"index.curl":e,"middle.curl":n,"ring.curl":i,"pinky.curl":s}),dt={relaxed:ct,open:ht({...Et(0,0,0,0,0),"thumb.across":0,spread:.55}),spread:ht({...Et(0,0,0,0,0),"thumb.across":0,spread:1}),flat:ht({...Et(0,0,0,0,0),"thumb.across":.35,spread:0}),fist:ht({...Et(.7,1,1,1,1),"thumb.across":.9,spread:0}),point:ht({...Et(.75,0,1,1,1),"thumb.across":.9,spread:0}),thumbsUp:ht({...Et(0,1,1,1,1),"thumb.across":0,spread:0,roll:70}),peace:ht({...Et(.75,0,0,1,1),"thumb.across":.9,spread:1}),ok:ht({...Et(.12,.6,.1,.15,.2),"thumb.across":.55,spread:.6}),pinch:ht({...Et(.1,.65,.75,.85,.9),"thumb.across":.55,spread:0}),cupped:ht({...Et(.25,.4,.4,.4,.4),"thumb.across":.4,spread:.05,turn:2}),wave:ht({...Et(0,.05,.05,.1,.12),"thumb.across":0,spread:.7,turn:2}),pencilGrip:ht({...Et(.1,.6,.72,.88,.95),"thumb.across":.5,spread:0,turn:.8,bend:10}),hold:ht({...Et(.5,.7,.72,.74,.76),"thumb.across":.75,spread:0,turn:1})};function He(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 Yd={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}},jd={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}},Wt={base:[-.11,.1,-.05],bones:[.2,.15,.12],widths:[.2,.145,.135],out:[-.7,.68,-.22],across:[.35,.5,-.8]},Xd=[82,100,62],qd=[48,72],Ud=3,Vd=13,Gd=.035,zd=-.075,Jd=[[-.17,0],[-.215,.12],[-.235,.26],[-.225,.4],[-.185,.49],[-.075,.525],[.05,.51],[.16,.465],[.215,.4],[.225,.26],[.2,.1],[.16,0]],Jt=t=>t*Math.PI/180,Cs=(t,e)=>[t[0]+e[0],t[1]+e[1],t[2]+e[2]],ei=(t,e)=>[t[0]*e,t[1]*e,t[2]*e],Os=(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]],ln=t=>{const e=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/e,t[1]/e,t[2]/e]};function Zt(t,e,n){const i=Math.cos(n),s=Math.sin(n),o=Os(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 rl=[1,0,0],al=[0,1,0],cn=[0,0,1];function Zd(t,e,n){const i=Jt(t.fan*(Ud+Vd*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,u)=>{a+=Jt(Xd[u]*e),r.push(Cs(r[u],ei(Zt(s,o,-a),h)))});const l=Zt(cn,o,-a),c=r.map((h,u)=>t.width*(1-.14*(u/(r.length-1))));return{joints:r,back:l,widths:c}}function Qd(t,e,n=1,i=1){const s=Math.min(1,Math.max(0,e)),o=ln(Cs(ei(ln(Wt.out),1-s),ei(ln(Wt.across),s))),r=ln(Os(cn,o)),a=ln(Os(o,r)),l=[[Wt.base[0]*i,Wt.base[1],Wt.base[2]]];let c=0;Wt.bones.forEach((f,d)=>{d>0&&(c+=Jt(qd[d-1]*t)),l.push(Cs(l[d],ei(Zt(o,r,c),f)))});const h=Zt(a,r,c),u=[...Wt.widths,Wt.widths[Wt.widths.length-1]*.92].map(f=>f*n);return{joints:l,back:h,widths:u}}function ni(t,e={}){const n={...ct,...t},i=e.size??100,s=e.side??"right",o=s==="left"?-1:1,r=Jt(e.angle??0),a=e.fingers===4,l=Math.max(.5,e.plump??1),c=1+(l-1)*.7,h=R=>({...R,knuckle:[R.knuckle[0]*c,R.knuckle[1],R.knuckle[2]],width:R.width*l}),u=Jt(n.bend??0),f=Jt(n.tilt??0),d=Jt(90*(n.turn??0)),g=R=>Zt(Zt(Zt(R,rl,-u),cn,-f),al,d),p=Math.cos(r),m=Math.sin(r),y=Jt(n.roll??0),w=Math.cos(y),k=Math.sin(y),E=R=>{const F=R[0]*i,N=-R[1]*i,X=(F*w-N*k)*o,G=F*k+N*w;return{x:X*p-G*m,y:X*m+G*p}},T=R=>{const F=E(R),N=Math.hypot(F.x,F.y);return N>1e-6*i?{x:F.x/N,y:F.y/N}:{x:0,y:0}},S={thumb:Qd(n["thumb.curl"]??0,n["thumb.across"]??0,l,c)},P=a?jd:Yd;for(const R of ol){const F=P[R];F&&(S[R]=Zd(h(F),n[`${R}.curl`]??0,n.spread??0))}const O={};for(const[R,F]of Object.entries(S)){const N=F.joints.map(g),X=g(F.back);O[R]={points:N.map(E),depths:N.map(G=>G[2]*i),widths:F.widths.map(G=>G*i),nail:X[2],back:T(X)}}const A=Jd.flatMap(([R,F])=>[g([R*c,F,Gd]),g([R*c,F,zd])]),C=t0(A.map(E)),I=A.reduce((R,F)=>R+F[2],0)/A.length*i;return{size:i,side:s,wrist:{x:0,y:0},palm:C,palmDepth:I,palmFacing:-g(cn)[2],fingers:O,axes:{up:T(g(al)),across:T(g(rl)),out:T(g(cn))},curls:Object.fromEntries(Object.keys(O).map(R=>[R,n[`${R}.curl`]??0]))}}function ll(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 t0(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 e0="#f1c9a5",n0="#2f2f33";function ii(t,e,n,i={},s=0){const o=ll(ni(n,i),e),r=i.ink??n0,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??e0,h=i.nails??!0,u=[{depth:o.palmDepth,draw:()=>i0(l,o,c,a)}];for(const f of Object.values(o.fingers)){const d=f.depths.reduce((g,p)=>g+p,0)/f.depths.length;u.push({depth:d,draw:()=>s0(t,l,f,c,a,h)})}if(i.prop){const f=i.prop;u.push({depth:f.depth,draw:()=>f.draw(l)})}t.save(),t.lineCap="round",t.lineJoin="round";for(const f of[...u].sort((d,g)=>d.depth-g.depth))f.draw();return t.restore(),o}function i0(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},u=Math.atan2(s.y,s.x),f=Array.from({length:7},(d,g)=>{const p=u-Math.PI/2+Math.PI*g/6;return{x:h.x+Math.cos(p)*c,y:h.y+Math.sin(p)*c}});t.line(f,i*.6)}}if(e.palmFacing>.45&&t.look!=="silhouette"){const{up:s,across:o}=e.axes,r=e.size,a=e.wrist,l=(h,u)=>({x:a.x+(o.x*h+s.x*u)*r,y:a.y+(o.y*h+s.y*u)*r}),c=e.side==="left"?-1:1;t.line([l(-.15*c,.36),l(-.04*c,.3),l(.1*c,.33)],i*.5)}}function s0(t,e,n,i,s,o){const{widths:r}=n,a=o0(n.points,2),l=n.points[0],c=a[a.length-1],h=r[0],u=r[r.length-1];if(t.save(),e.look!=="silhouette"){t.beginPath(),t.rect(l.x-1e5,l.y-1e5,2e5,2e5);const p=h/2+s*1.6;t.moveTo(l.x+p,l.y),t.arc(l.x,l.y,p,0,Math.PI*2),t.clip("evenodd")}if(e.limb(a,h+2*s,u+2*s),t.restore(),e.look!=="silhouette"&&(t.fillStyle=i,Qn(t,a,h,u)),e.look==="silhouette"||!o||n.nail<.25)return;const f=a[a.length-2],d=r0({x:c.x-f.x,y:c.y-f.y})??{x:0,y:-1},g={x:c.x-d.x*u*.22+n.back.x*u*.1,y:c.y-d.y*u*.22+n.back.y*u*.1};e.ellipse(g.x,g.y,u*.24*Math.max(.35,n.nail),u*.19,Math.atan2(d.y,d.x),"#f8e3d3",s*.45)}function o0(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 r0=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}},a0=40;function hn(t){return t===void 0?_t.walk:typeof t=="string"?_t[t]??_t.walk:t}function cl(t,e,n=V,i=1){const s=hn(t);if(s===_t.walk)return pl(e,n,i);const o=e*Math.PI*2,r=Math.sin(o)*i,a=Math.cos(o)*i,l=y=>Math.abs(y)<=a0,c=s.shoulder??0,h=(y,w)=>l(y)?w*c+s.arm*r:y,u=s.forearm??0,f=l(n.leftShoulder)?n.leftElbow-u-s.elbow*Math.max(0,-r):n.leftElbow,d=l(n.rightShoulder)?n.rightElbow+u+s.elbow*Math.max(0,r):n.rightElbow,g=s.bounces??1,p=(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:f,rightElbow:d,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*p,stretch:n.stretch*(1+(s.squash??0)*(p-.5))}}function Rs(t,e,n=1){const i=hn(t),s=_t.walk.swing,o=r=>Math.sin(r*Math.PI/180);return gl(e,n)*o(i.swing*n)/o(s*n)}const V={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 yt(t){return{...V,...t}}const hl={mouth:0,smile:0,mouthWidth:1,leftEye:1,rightEye:1,leftBrow:0,rightBrow:0,browTilt:0,lookX:0,lookY:0},bt=t=>({...hl,...t}),ot={neutral:hl,happy:bt({smile:.9,leftBrow:.2,rightBrow:.2}),joyful:bt({mouth:.6,smile:1,mouthWidth:1.2,leftEye:0,rightEye:0,leftBrow:.4,rightBrow:.4}),sad:bt({smile:-.8,leftEye:.8,rightEye:.8,browTilt:.9,leftBrow:-.1,rightBrow:-.1,lookY:.6}),crying:bt({mouth:.45,smile:-1,leftEye:0,rightEye:0,browTilt:1,lookY:.4}),surprised:bt({mouth:.7,mouthWidth:.7,leftEye:1.5,rightEye:1.5,leftBrow:1,rightBrow:1}),shocked:bt({mouth:1,mouthWidth:.8,leftEye:1.6,rightEye:1.6,leftBrow:1,rightBrow:1,browTilt:.4}),angry:bt({smile:-.6,mouthWidth:.9,leftEye:.8,rightEye:.8,leftBrow:-.6,rightBrow:-.6,browTilt:-1}),furious:bt({mouth:.5,smile:-1,mouthWidth:1.3,leftEye:.9,rightEye:.9,leftBrow:-.9,rightBrow:-.9,browTilt:-1}),worried:bt({smile:-.3,mouthWidth:.8,leftEye:1.1,rightEye:1.1,leftBrow:.3,rightBrow:.3,browTilt:.8,lookX:-.5}),scared:bt({mouth:.35,smile:-.5,mouthWidth:.8,leftEye:1.45,rightEye:1.45,leftBrow:.8,rightBrow:.8,browTilt:.9}),confused:bt({smile:-.2,mouthWidth:.8,leftEye:.9,rightEye:1.15,leftBrow:-.3,rightBrow:.8,lookX:.5,lookY:-.4}),skeptical:bt({smile:-.1,leftEye:.6,rightEye:1,leftBrow:-.4,rightBrow:.7,lookX:.4}),thinking:bt({smile:0,mouthWidth:.7,leftBrow:.3,rightBrow:.5,lookX:.6,lookY:-.8}),sleepy:bt({smile:.1,leftEye:.25,rightEye:.25,leftBrow:-.3,rightBrow:-.3,lookY:.5}),disgusted:bt({smile:-.7,mouthWidth:.9,leftEye:.6,rightEye:.75,leftBrow:-.5,rightBrow:-.2,browTilt:-.4,lookX:-.6}),smug:bt({smile:.6,mouthWidth:.9,leftEye:.6,rightEye:.6,leftBrow:.1,rightBrow:.5,lookX:.5}),wink:bt({smile:.9,leftEye:0,rightEye:1,leftBrow:-.2,rightBrow:.3})};function Ce(t,e){return{...t,...typeof e=="string"?ot[e]:e}}const Dt={rest:V,wave:yt({rightShoulder:135,rightElbow:30,headTilt:6,...ot.happy}),cheer:yt({leftShoulder:125,leftElbow:20,rightShoulder:125,rightElbow:20,...ot.joyful}),shrug:yt({leftShoulder:30,leftElbow:85,rightShoulder:30,rightElbow:85,headTilt:-10,...ot.confused,lookX:0,lookY:0}),point:yt({rightShoulder:90,rightElbow:0,lean:4,smile:.4}),think:yt({rightShoulder:60,rightElbow:150,headTilt:10,...ot.thinking}),handsOnHips:yt({leftShoulder:45,leftElbow:-100,rightShoulder:45,rightElbow:-100,leftHip:14,rightHip:14,smile:.8}),sad:yt({leftShoulder:14,rightShoulder:14,leftElbow:-4,rightElbow:-4,headTilt:-14,lean:-3,...ot.sad}),surprised:yt({leftShoulder:70,leftElbow:60,rightShoulder:70,rightElbow:60,...ot.surprised}),crouch:yt({stretch:.72,leftShoulder:35,rightShoulder:35,leftElbow:-50,rightElbow:-50,leftHip:22,rightHip:22,headTilt:-4}),sit:yt({sit:1,turn:.5,leftShoulder:-25,rightShoulder:25,leftElbow:-55,rightElbow:55}),jump:yt({stretch:1.22,leftShoulder:140,rightShoulder:140,leftElbow:20,rightElbow:20,leftHip:4,rightHip:4,...ot.joyful}),duck:yt({stretch:.62,bend:28,headTilt:-8,leftShoulder:150,rightShoulder:150,leftElbow:130,rightElbow:130,leftHip:25,rightHip:25,...ot.scared}),lie:yt({spin:-90,rise:-.42,leftShoulder:165,rightShoulder:165,leftElbow:150,rightElbow:150,...ot.sleepy}),sideSplit:yt({leftHip:90,rightHip:90,leftAnkle:-45,rightAnkle:-45,leftShoulder:120,rightShoulder:120,leftElbow:10,rightElbow:10,...ot.happy}),frontSplit:yt({turn:1,leftHip:-90,rightHip:-90,leftAnkle:-45,rightAnkle:-45,leftShoulder:-150,rightShoulder:150,leftElbow:10,rightElbow:-10,...ot.happy})},ul=Object.keys(V);function Oe(t,e,n){const i={...t};for(const s of ul)i[s]=t[s]+(e[s]-t[s])*n;return i}const Ls=24,fl=4,dl=28,l0=40;function pl(t,e=V,n=1){const i=Math.sin(t*Math.PI*2)*n,s=Math.cos(t*Math.PI*2)*n,o=c=>Math.abs(c)<=l0,r=c=>o(c)?22*i:c,a=o(e.leftShoulder)?e.leftElbow-dl*Math.max(0,-i):e.leftElbow,l=o(e.rightShoulder)?e.rightElbow+dl*Math.max(0,i):e.rightElbow;return{...e,lean:e.lean+fl*n,headTilt:e.headTilt-fl*.5*n,leftElbow:a,rightElbow:l,leftHip:-Ls*i,rightHip:-Ls*i,leftKnee:-30*Math.max(0,s),rightKnee:30*Math.max(0,-s),leftShoulder:r(e.leftShoulder),rightShoulder:r(e.rightShoulder)}}function gl(t,e=1){return 4*((Fs+si)*t)*Math.sin(Ls*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 yl=.12,bl=.46,c0=1-2*yl,h0=.1,u0=.21,f0=.19,Fs=.24,si=.22,wl=.12,d0=.14,kl=.33,vl=.7,Sl=.3,p0=.35,g0=[1.7,1.05],m0=[1.3,.75],Ml=[1.45,.85],y0=[1.15,.75],Tl=.06,b0=.7,w0=.65,El=.075,k0=.3,v0=.02,S0=.012,M0=12,T0=.25,oi=90,E0=.25,A0=.04,Al=.01,fe=t=>Math.min(1,Math.max(0,t??0));function x0(t,e=1){return si*t*e}const Ds=-.12,xl=.4,It=t=>t*Math.PI/180,P0=(t,e)=>({x:e*Math.sin(It(t)),y:Math.cos(It(t))}),Pl=(t,e)=>Math.max(0,t)*(1-Math.min(1,Math.max(0,e))),$l=(t,e,n,i)=>t-.3*e-n*.14*e-Math.max(0,i-1)*.12*e;function $0(t,e,n,i,s,o){const r=Math.max(1,Math.min(o*.6,d0*n)),a=fe(e.turn),l=(wl+kl*a)*n,c=i+Ds*n,h=l+e.lookX*.08*n,u=e.lookY*.07*n,f=[{x:-.34*n*(1-vl*a),squeeze:1-vl*a,open:e.leftEye,brow:e.leftBrow,side:-1},{x:.34*n*(1-Sl*a),squeeze:1-Sl*a,open:e.rightEye,brow:e.rightBrow,side:1}];t.fillStyle=s,t.strokeStyle=s,t.lineWidth=r;for(const y of f){const w=Pl(y.open,e.blink);if(w<.2){const S=e.smile>.5?-.12*n:.06*n;t.beginPath(),t.moveTo(y.x+l-.12*n,c),t.quadraticCurveTo(y.x+l,c+S,y.x+l+.12*n,c),t.stroke()}else{if(w>1.2){const P=.13*n*w;t.beginPath(),t.ellipse(y.x+l,c,P*.85,P,0,0,Math.PI*2),t.fillStyle="#ffffff",t.fill(),t.stroke(),t.fillStyle=s}const S=w>1.2?.075*n:.1*n;t.beginPath(),t.ellipse(y.x+h,c+u,S,S*1.1*Math.min(w,1),0,0,Math.PI*2),t.fill()}const k=$l(c,n,y.brow,w),E=y.x+l-y.side*.13*n*y.squeeze,T=y.x+l+y.side*.13*n*y.squeeze;t.beginPath(),t.moveTo(T,k),t.lineTo(E,k-e.browTilt*.1*n),t.stroke()}const d=i+xl*n,g=.25*n*Math.max(.3,e.mouthWidth)*(1-p0*a),p=Math.min(1,Math.max(0,e.mouth));if(t.beginPath(),p<=.05){t.moveTo(l-g,d),t.quadraticCurveTo(l,d+e.smile*.25*n,l+g,d),t.stroke();return}const m=.3*n*p;e.smile>.3?(t.moveTo(l-g,d-.05*n),t.lineTo(l+g,d-.05*n),t.quadraticCurveTo(l,d+m*2,l-g,d-.05*n)):e.smile<-.3?(t.moveTo(l-g,d+m*.6),t.lineTo(l+g,d+m*.6),t.quadraticCurveTo(l,d-m*1.4,l-g,d+m*.6)):t.ellipse(l,d,g*.8,m,0,0,Math.PI*2),t.fill()}function _l(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*yl)/2,r=e.headSize===void 0?c0:1-2*o,a=o*n,l=fe(t.sit),c=t.leftHip+(-oi-t.leftHip)*l,h=t.leftKnee+(-oi-t.leftKnee)*l,u=t.rightHip+(oi-t.rightHip)*l,f=t.rightKnee+(oi-t.rightKnee)*l,d=e.classic===!0,g=fe(t.turn),p=(L,W,j,v,x)=>{const M=Math.max(-Math.PI/2,Math.min(Math.PI/2,Math.abs(It(W-j)/2)+It(v))),_=Math.max(-1,Math.min(1,b0+x)),H=g+(1-g)*L*_;return d?{x:0,y:0}:{x:Math.cos(M)*Tl*H,y:Math.sin(M)*Tl}},m={left:t.leftAnkle??0,right:t.rightAnkle??0},y={left:t.leftFootOut??0,right:t.rightFootOut??0};let w=0;if(l>0||!d){const L=(x,M,_,H,D)=>Fs*Math.cos(It(M))+si*Math.cos(It(M-_))+Math.max(0,p(x,M,_,H,D).y),W=Math.max(L(-1,c,h,m.left,y.left),L(1,u,f,m.right,y.right)),j=1-fe((t.rise??0)/A0),v=(d?Math.min(1,l/E0):1)*j;w=(bl-W)*v*n*i}const k=-bl*n*i+w,E=-r*n*i+w,T=d?0:(v0*fe(t.turn)+S0*l)*n*i,S=It(t.bend??0),P={end:Hl(k,E,S,1),bend:S};let O;if(S!==0){O=[];for(let L=0;L<=Il;L++){const W=L/Il,j=Hl(k,E,S,W);O.push({x:j.x-T*Math.sin(Math.PI*W),y:j.y})}}else O=T===0?[{x:0,y:k},{x:0,y:E}]:ue({x:0,y:k},{x:-T,y:(k+E)/2},{x:0,y:E},1,8);const A=E+h0*n*i,C=(e.shoulderWidth??0)*n*Math.cos(g*Math.PI/2),I=(L,W,j,v,x)=>{const M=P0(j,v);return{x:L+M.x*x*n,y:W+M.y*x*n}},R=(L,W,j)=>{const v=I(0,k,W,L,Fs*i);return{root:{x:0,y:k},joint:v,end:I(v.x,v.y,W-j,L,si*i)}},F=(L,W,j)=>{const v={x:L*C,y:A},x=I(v.x,v.y,W,L,u0*s);return{root:v,joint:x,end:I(x.x,x.y,W+j,L,f0*s)}},N={left:R(-1,c,h),right:R(1,u,f)},X=(L,W,j,v,x,M)=>{const _=p(L,j,v,x,M);return{x:W.end.x+_.x*n*i,y:W.end.y+_.y*n*i}},G=(L,W,j,v,x)=>I(W.end.x,W.end.y,j+v+x,L,El*s),$={left:F(-1,t.leftShoulder,t.leftElbow),right:F(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(d?0:k0,e.rubber??0)),r:a,headRx:a/Math.sqrt(i),headRy:a*Math.sqrt(i),hipY:k,neckY:E,drop:w,lean:d?t.lean:t.lean+M0*Math.sin(Math.PI*l),classic:d,legs:N,toes:{left:X(-1,N.left,c,h,m.left,y.left),right:X(1,N.right,u,f,m.right,y.right)},spine:O,chest:P,arms:$,handTips:{left:G(-1,$.left,t.leftShoulder,t.leftElbow,t.leftWrist??0),right:G(1,$.right,t.rightShoulder,t.rightElbow,t.rightWrist??0)}}}const Il=10;function Hl(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 _0(t,e){if(t.chest.bend===0)return e;const n=fn(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 un=(t,e)=>e===0?[t.root,t.joint,t.end]:ue(t.root,t.joint,t.end,e);function fn(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 Cl(t,e,n=!0){const i=H0(t,e),s=e.spin??0,o=e.rise??0;return n&&(s!==0||o!==0)?I0(i,t,s,o):i}function Ol(t,e,n){return{pivot:{x:0,y:t.hipY},angle:t.facing*It(e),lift:n*t.height}}function I0(t,e,n,i){const{pivot:s,angle:o,lift:r}=Ol(e,n,i),a=f=>{const d=fn(f,s,o);return{x:d.x,y:d.y-r}},l=f=>({left:a(f.left),right:a(f.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),u=Al*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-u,right:c.right>=h-u},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 H0(t,e){const n=It(t.lean),i=It(e.headTilt),s={x:0,y:t.hipY},o=E=>({x:t.facing*E.x,y:E.y}),r=E=>o(fn(E,s,n)),a=E=>r(_0(t,E)),l=E=>a(fn({x:E.x,y:E.y+t.neckY},{x:0,y:t.neckY},i)),c=un(t.arms.left,t.rubber).map(a),h=un(t.arms.right,t.rubber).map(a),u=(E,T)=>Math.atan2(T.y-E.y,T.x-E.x),f={left:a(t.handTips.left),right:a(t.handTips.right)},d=(E,T)=>{const[S,P]=E.slice(-2),O=t.arms[T],A=u(a(O.end),f[T])-u(a(O.joint),a(O.end));return u(S,P)+A};let g=1/0;for(const[E,T]of[[e.leftBrow,e.leftEye],[e.rightBrow,e.rightEye]]){const S=$l(Ds,1,E,Pl(T,e.blink));g=Math.min(g,S,S-e.browTilt*.1)}const p={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(p.left.y,m.left.y),right:Math.max(p.right.y,m.right.y)},w=Math.max(y.left,y.right),k=Al*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:p,toes:m,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:un(t.legs.left,t.rubber).map(o),rightLeg:un(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:Ds,browTopY:g,mouthY:xl,faceX:t.facing*(wl+kl*fe(e.turn))}}}function Qt(t,e={}){return Cl(_l(t,e),t)}function C0(t,e,n){return fn({x:t.center.x+e*t.rx,y:t.center.y+n*t.ry},t.center,t.angle)}function Rl(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 Ll(t,e,n={},i=0){const s=_l(e,n),o=n.color??"#1e293b",r=n.layers??{},a=n.layers?Cl(s,e,!1):void 0,l=n.sketch?Zn(t,n.sketch,i):void 0,c=n.sketch&&n.layers?Zn(t,n.sketch,i):void 0,h=P=>{t.save(),P(),t.restore()},u=P=>{P&&a&&h(()=>P(t,a,i,c))},f=()=>t.scale(s.facing,1),d=()=>{f(),t.translate(0,s.hipY),t.rotate(It(s.lean)),t.translate(0,-s.hipY)},g=()=>{d(),s.chest.bend!==0&&(t.translate(s.chest.end.x,s.chest.end.y),t.rotate(s.chest.bend),t.translate(0,-s.neckY))},p=(P,O,A)=>{if(l)return O?l.curve(P):l.line(P);if(s.classic){t.beginPath(),t.moveTo(P[0].x,P[0].y);for(const C of P.slice(1))t.lineTo(C.x,C.y);t.stroke();return}Qn(t,P,A[0]*s.lineWidth,A[1]*s.lineWidth)},m=(P,O)=>p(un(P,s.rubber),s.rubber>0,O),y=P=>{s.classic||p([s.legs[P].end,s.toes[P]],!1,y0)},w=P=>{if(n.hands&&!s.classic)return E(P);if(s.classic||l)return;const O=s.arms[P].end;t.beginPath(),t.arc(O.x,O.y,w0*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 k=Ol(s,e.spin??0,e.rise??0);(k.angle!==0||k.lift!==0)&&(t.translate(0,-k.lift),t.translate(k.pivot.x,k.pivot.y),t.rotate(k.angle),t.translate(-k.pivot.x,-k.pivot.y));function E(P){const O=n.hands??{},A=s.arms[P].end,C=s.handTips[P],I=n.headFill??"#ffffff";ii(t,A,O[P]??ct,{side:P,angle:Math.atan2(C.x-A.x,A.y-C.y)*180/Math.PI,size:(O.size??El)*s.height*Math.sqrt(s.stretch),skin:O.skin??(I==="none"?void 0:I),ink:o,lineWidth:s.lineWidth*.45,fingers:O.fingers,plump:O.plump,look:n.sketch?"pencil":"clean",seed:n.sketch?.seed},i)}const T=P=>{h(()=>{g(),m(s.arms[P],m0),w(P)});const O=r.sleeve;O&&a&&h(()=>O(t,a,P,i,c))},S=fe(e.turn)>T0;u(r.behind),h(()=>{f(),m(s.legs.left,Ml),y("left"),m(s.legs.right,Ml),y("right")}),S&&T("left"),h(()=>{d(),p(s.spine,s.spine.length>2,g0)}),h(()=>{g();const{left:P,right:O}={left:s.arms.left.root,right:s.arms.right.root};if(P.x!==O.x)if(s.classic)p([P,O],!1,[1,1]);else{const A={x:(P.x+O.x)/2,y:P.y-.3*Math.abs(O.x-P.x)};p(ue(P,A,O,1,8),!0,[1.1,1.1])}}),u(r.body),S||T("left"),T("right"),u(r.behindHead),h(()=>{g(),t.translate(0,s.neckY),t.rotate(It(e.headTilt));const P=-s.headRy;t.beginPath(),t.ellipse(0,P,s.headRx,s.headRy,0,0,Math.PI*2);const O=n.headFill??"#ffffff";if(O!=="none"&&(t.fillStyle=O,t.fill()),l){l.ellipse(0,P,s.headRx,s.headRy);const A=l.nudge();t.translate(A.x,A.y)}else t.stroke();t.translate(0,P),t.scale(s.headRx/s.r,s.headRy/s.r),$0(t,e,s.r,0,o,s.lineWidth)}),u(r.overHead),u(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 Ns(t,e,n){const i={...t};let s=t.walking>0?Oe(i,cl(t.gait,t.walk,i),t.walking):i,o=O0(t);const r=t.dancing??0;if(n&&r>0){const a=n(t.beat??0);if(s=Oe(s,a.pose,r),a.hands){const l=(c,h)=>h?He(c??ct,h,r):c;o={left:l(o?.left,a.hands.left),right:l(o?.right,a.hands.right)}}}return t.talk>0&&(s={...s,mouth:Math.max(s.mouth,t.talk*ml(e))}),{pose:s,hands:o}}function Fl(t,e,n){return Ns(t,e,n).pose}const Dl=(t,e)=>(t.facing??e.facing??1)<0?-1:1,dn=(t,e)=>`hand.${t}.${e}`;function O0(t){const e=s=>{if(typeof t[dn(s,"spread")]=="number")return Object.fromEntries(Object.keys(ct).map(o=>[o,t[dn(s,o)]]))},n=e("left"),i=e("right");return n||i?{left:n,right:i}:void 0}function R0(t,e){return!e||!t.hands?t:{...t,hands:{...t.hands,left:e.left??t.hands.left,right:e.right??t.hands.right}}}function Nl(t){const e=t.style??{},n=e.height??300,i=n*.8,s={...yt(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]??ct;for(const l of Object.keys(ct))o[dn(r,l)]=a[l]??ct[l]}return{type:"custom",x:t.x-i/2,y:t.y-n,width:i,height:n,props:{...s,...o},about:L0(Object.keys(o)),figureStyle:e,figureDance:t.dance,draw(r,a,l){const c=a.props,h=Ns(c,l,t.dance);r.translate(i/2,n),Ll(r,h.pose,R0({...e,rubber:c.rubber,facing:Dl(c,e)},h.hands),l)}}}function L0(t){const e={...Za,...Qa};for(const n of t){const[,i,...s]=n.split("."),o=tl[s.join(".")];o&&(e[n]={...o,description:`${i==="left"?"Left":"Right"} hand: ${o.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:e,get actions(){return Ld()}}}function Bs(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=Fl(s,e.time,t.figureDance),l=Qt(a,{...i,rubber:s.rubber,facing:Dl(s,i)});return{pose:a,joints:Rl(l,t.x+o+t.width/2,t.y+r+t.height)}}function Ws(t){const e=[];return t.forEach((n,i)=>{const s=i===0?V:e[i-1],o=typeof n.pose=="string"?Dt[n.pose]:{...s,...n.pose};e.push(n.expression?Ce(o,n.expression):o)}),e}function F0(t,e){const n=Ws(e);return ul.filter(i=>n.some(s=>s[i]!==V[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 Ks=.5,ri={pataka:ht({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:0,turn:2}),tripataka:ht({"thumb.curl":.3,"thumb.across":.6,"index.curl":0,"middle.curl":0,"ring.curl":1,"pinky.curl":0,spread:0,turn:2}),alapadma:ht({"thumb.curl":.1,"thumb.across":0,"index.curl":.05,"middle.curl":.15,"ring.curl":.25,"pinky.curl":.35,spread:1,turn:2}),mushti:dt.fist,shikhara:dt.thumbsUp,hamsasya:ht({"thumb.curl":.15,"thumb.across":.6,"index.curl":.6,"middle.curl":0,"ring.curl":0,"pinky.curl":0,spread:.7,turn:2}),katakamukha:ht({"thumb.curl":.2,"thumb.across":.6,"index.curl":.65,"middle.curl":.7,"ring.curl":0,"pinky.curl":0,spread:.4,turn:2})};function ai(t){return typeof t!="string"?t:t in ri?ri[t]:dt[t]}function Bl(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?ai(s.hands.left):r.left,right:s.hands?.right?ai(s.hands.right):r.right,easing:s.easing??t.easing})}return i}const Ys=(t,e)=>(t%e+e)%e;function D0(t,e,n,i){const s=Bl(t,n,i);if(s.length===0)return{pose:n,hands:i};const o=Ys(e,t.beats);let r=s.length-1;for(let d=0;d<s.length;d++)s[d].beat<=o&&(r=d);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,u=h>c?(o-c)/(h-c):0,f=vt(l.easing??"ease-in-out")(Math.min(1,Math.max(0,u)));return{pose:Oe(a.pose,l.pose,f),hands:{left:He(a.left,l.left,f),right:He(a.right,l.right,f)}}}const N0=[["leftShoulder","rightShoulder"],["leftElbow","rightElbow"],["leftWrist","rightWrist"],["leftHip","rightHip"],["leftKnee","rightKnee"],["leftAnkle","rightAnkle"],["leftFootOut","rightFootOut"],["leftEye","rightEye"],["leftBrow","rightBrow"]],B0=["lean","headTilt","lookX","spin"],W0=new Set(["leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee"]);function Wl(t){const e={...t},n=(t.turn??0)>=.5;for(const[i,s]of N0){const o=n&&W0.has(i)?-1:1;e[i]=o*t[s],e[s]=o*t[i]}if(!n)for(const i of B0)e[i]=-t[i];return e}const K0=t=>Math.min(1,Math.max(-1,(.5-t)*4));function Kl(t,e,n){const i=Ys(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=K0(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 li(t){const e={...V,...t.stance};return t.expression?Ce(e,t.expression):e}function Yl(t){return{left:t.hands?.left?ai(t.hands.left):ct,right:t.hands?.right?ai(t.hands.right):ct}}function js(t,e,n){const i=t.moves[e.move];if(!i)throw new Error(`dance: "${t.label}" has no move "${e.move}"`);const s=D0(i,n,li(t),Yl(t));return e.mirror?{pose:Wl(s.pose),hands:{left:s.hands?.right,right:s.hands?.left}}:s}function ci(t,e,n={}){const i=typeof t=="string"?te[t]:t;let s;if(n.move)s=js(i,{move:n.move,mirror:n.mirror},e);else{const o=i.routine,r=o.reduce((u,f)=>u+f.beats,0),a=Ys(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=js(i,o[c],h),h<Ks&&o.length>1&&e>=Ks){const u=o[(c-1+o.length)%o.length],f=js(i,u,u.beats+h),d=vt("ease-in-out")(h/Ks);s={pose:Oe(f.pose,s.pose,d),hands:{left:He(f.hands.left,s.hands.left,d),right:He(f.hands.right,s.hands.right,d)}}}}return{...s,pose:Kl(s.pose,i.groove,e)}}function Y0(t,e,n={}){return ci(t,e,n).pose}function hi(t){return(typeof t=="string"?te[t]:t).routine.reduce((n,i)=>n+i.beats,0)}const j0={leftToe:"rightToe",rightToe:"leftToe",leftHeel:"rightHeel",rightHeel:"leftHeel"};function jl(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 u of l.taps??[])s.push({beat:h,tap:i?j0[u]:u})}}function X0(t,e,n,i={}){const s=typeof t=="string"?te[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;jl(r,a,Math.ceil((n-a)/r.beats)*r.beats,i.mirror,o,e,n)}else{const r=hi(s);for(let a=Math.floor(e/r)*r;a<n;a+=r){let l=a;for(const c of s.routine)jl(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 Xl(t,e){const n=t.moves[e.move];if(!n?.travel)return 0;const i=n.travel/n.beats;return e.mirror?(Bl(n,li(t),Yl(t))[0]?.pose.turn??li(t).turn??0)>=.5?i:-i:i}function ql(t,e){return e.move?[{move:e.move,beats:t.moves[e.move].beats,mirror:e.mirror}]:t.routine}function ui(t,e,n={}){const i=typeof t=="string"?te[t]:t,s=ql(i,n),o=s.reduce((h,u)=>h+u.beats,0),r=s.reduce((h,u)=>h+Xl(i,u)*u.beats,0),a=Math.floor(e/o);let l=a*r,c=e-a*o;for(const h of s){const u=Math.min(h.beats,c);if(l+=Xl(i,h)*u,c-=u,c<=0)break}return l}function q0(t,e,n){const i=ql(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 U0=8;function Ul(t,e,n){const i=typeof e=="string"?te[e]:e,s=n.bpm??i.bpm,o=n.beats??(n.move?i.moves[n.move].beats:hi(i)),r=q0(i,o,n);if(r.every(y=>ui(i,y,n)===0))return;const a=Math.min(n.fade??1,o/2),l=vt("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*U0),u=a<=0?[]:Array.from({length:h+1},(y,w)=>[w/h*a,o-w/h*a]).flat(),f=[...new Set([...r,...u])].sort((y,w)=>y-w);let d=0;const g=f.map((y,w)=>{if(w>0){const k=f[w-1],E=Math.max(1,Math.ceil((y-k)*16));for(let T=0;T<E;T++){const S=k+(y-k)*T/E,P=k+(y-k)*(T+1)/E;d+=(ui(i,P,n)-ui(i,S,n))*c((S+P)/2)}}return{beat:y,travel:d}}),p=n.start??0,m=n.x??0;return{id:`${t}-x`,target:t,property:"x",keyframes:g.map(y=>({time:p+y.beat*6e4/s,value:m+n.height*y.travel,easing:"linear"}))}}function V0(t,e,n=0){return(t-n)*e/6e4}function G0(t,e={}){return n=>ci(t,n,e)}function z0(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 J0(t,e,n={}){const i=typeof e=="string"?te[e]:e,s=n.bpm??i.bpm,o=n.beats??(n.move?i.moves[n.move].beats:hi(i)),r=n.samplesPerBeat??4,a=n.start??0,l=Math.round(o*r),c=Array.from({length:l+1},(p,m)=>{const y=m/r;return{time:a+y*6e4/s,frame:ci(i,y,n)}}),h=(p,m)=>({id:`${t}-${p}`,target:t,property:p,keyframes:c.map(y=>({time:y.time,value:m(y.frame)}))}),f=Object.keys(V).filter(p=>c.some(m=>m.frame.pose[p]!==c[0].frame.pose[p])||c[0].frame.pose[p]!==V[p]).map(p=>h(p,m=>m.pose[p])),d=n.height===void 0?void 0:Ul(t,i,{...n,bpm:s,beats:o,start:a,height:n.height,fade:0});if(d&&f.push(d),n.hands===!1)return f;const g=[];for(const p of["left","right"])for(const m of Object.keys(ct)){const y=w=>w.hands?.[p]?.[m]??ct[m];c.some(w=>y(w.frame)!==ct[m])&&g.push(h(dn(p,m),y))}return[...f,...g]}const pn={type:"back",mode:"out",overshoot:1.1},St="ease-out-cubic",Z0={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:St,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:St},{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:St},{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}]},Q0={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}]},tp={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:St},{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:St},{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:St},{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:pn},{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}]},ep={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:{...dt.spread,turn:2},right:{...dt.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:St},{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}]},np={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:pn,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:pn},{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:pn},{beat:3,pose:{headTilt:4}}]},isolations:{label:"Isolations",beats:2,easing:St,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}]},ip={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:{...dt.cupped,roll:-30},left:{...dt.flat,turn:0}}},{beat:.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...dt.cupped,roll:30}}},{beat:1,pose:{rightWrist:-15,rightElbow:12,leftWrist:-45,lean:-4,rightHip:16,leftHip:6},hands:{right:{...dt.cupped,roll:-30}}},{beat:1.5,pose:{rightWrist:25,rightElbow:22,leftWrist:10,lean:4,rightHip:6,leftHip:16},hands:{right:{...dt.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:{...dt.open,turn:2}},easing:St},{beat:.5,pose:{lean:-4,rightHip:12,headTilt:6}},{beat:1,pose:{lean:-11,rightHip:22,headTilt:10},easing:St},{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:St},{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:St}]}},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}]},sp={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}]},op={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}]},rp={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:{...dt.spread,turn:2},right:{...dt.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:St},{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:St},{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}]},ap={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:{...dt.spread,turn:2},right:{...dt.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}]},te={disco:Z0,hipHop:Q0,breaking:tp,jazz:ep,kpop:np,bollywood:ip,bhangra:sp,bharatanatyam:op,charleston:rp,tap:ap,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:pn},{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}]}},fi=t=>Math.min(1,Math.max(0,t));function lp(t){const e={...V,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 cp(t){return t-hp*Math.sin(2*Math.PI*t)/(2*Math.PI)}const hp=.5;function up(t,e){if(!(e<=t.takeoff||e>=t.landing))return(e-t.takeoff)/(t.landing-t.takeoff)}function Vl(t,e){const n=typeof t=="string"?gn[t]:t,i=lp(n),s=fi(e);let o=0;for(let u=0;u<i.length;u++)i[u].at<=s&&(o=u);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=Oe(r.pose,a.pose,vt(a.easing??"ease-in-out")(fi(l))),h=up(n,s);return h===void 0?{...c,spin:0,rise:0}:{...c,spin:n.spin*cp(h),rise:4*n.height*h*(1-h)}}function Gl(t,e,n){const i=typeof t=="string"?gn[t]:t,s=fi(e),o=fi((s-i.takeoff)/(i.landing-i.takeoff));return i.travel*n*o}function fp(t,e,n={}){const i=typeof e=="string"?gn[e]:e,s=n.start??0,o=n.duration??i.duration,r=n.samples??48,a=Array.from({length:r+1},(h,u)=>{const f=u/r;return{time:s+f*o,progress:f,pose:Vl(i,f)}}),c=Object.keys(V).filter(h=>a.some(u=>u.pose[h]!==V[h])).map(h=>({id:`${t}-${h}`,target:t,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:`${t}-x`,target:t,property:"x",keyframes:a.map(u=>({time:u.time,value:(n.x??0)+h*Gl(i,u.progress,n.height)}))})}return c}const dp={leftHip:-55,leftKnee:-95,rightHip:55,rightKnee:95,leftShoulder:45,rightShoulder:-45,leftElbow:10,rightElbow:-10,lean:22,stretch:.94,headTilt:6},pp={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},di={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},gp={leftHip:-22,leftKnee:-30,rightHip:22,rightKnee:30,leftAnkle:10,rightAnkle:10,leftShoulder:-125,rightShoulder:125,leftElbow:0,rightElbow:0,lean:8,headTilt:0},mp={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 Re(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:dp},{at:.27,pose:pp,easing:"ease-out-quad"},...s,{at:.76,pose:gp},{at:.86,pose:mp,easing:"ease-out-quad"},{at:1,reset:!0}]}}const gn={frontFlip:Re("Front flip (tuck)",360,.56,.35,[{at:.38,pose:di,easing:"ease-out-cubic"},{at:.64,pose:di}]),backFlip:Re("Back flip (tuck)",-360,.58,-.15,[{at:.36,pose:{...di,lean:18},easing:"ease-out-cubic"},{at:.64,pose:{...di,lean:18}}]),layout:Re("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:Re("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:Re("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:Re("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)},Xs=.215,qs=.205,yp=.065,zl=.035,bp=.165,wp=.155,kp=12,vp=.3,Sp=.7,Mp=.35,Tp=t=>t*Math.PI/180,ut={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 At(t={}){return{...ut,...t}}const Ep=new Set(["turn","side","head.turn","head.tilt","roll","lookX"]);function Ap(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]=Ep.has(n)?-i:i}return e}function Ht(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 Us={rest:ut,wave:At({"arm.right.spread":115,"arm.right.bend":55,"arm.right.elbow":0,"head.tilt":-6,smile:.9}),cheer:At({...Ht("arm",{spread:140,bend:20,elbow:0}),mouth:.6,smile:1,"eye.left":0,"eye.right":0}),point:At({"arm.right.spread":88,"arm.right.elbow":0,"arm.right.bend":0,"head.turn":-20,smile:.4}),handsOnHips:At({...Ht("arm",{spread:50,bend:-105,elbow:0}),...Ht("leg",{spread:9}),smile:.8}),think:At({"arm.right.spread":22,"arm.right.bend":-150,"arm.right.elbow":0,"head.tilt":10,lookX:-.5,lookY:-.8,smile:0}),shrug:At({...Ht("arm",{spread:35,bend:75,elbow:0}),"head.tilt":-10,smile:-.2}),sit:At({...Ht("leg",{swing:90,knee:90,spread:4}),...Ht("arm",{swing:25,elbow:45,spread:8})}),kneel:At({"leg.left.swing":90,"leg.left.knee":90,"leg.right.swing":-18,"leg.right.knee":108,"leg.right.ankle":16,...Ht("arm",{swing:20,elbow:30})}),crouch:At({...Ht("leg",{swing:75,knee:140,spread:6}),lean:25,...Ht("arm",{swing:50,elbow:40}),"head.nod":-15}),crawl:At({lean:82,"head.nod":-35,...Ht("arm",{swing:80,elbow:0,spread:4}),...Ht("leg",{knee:92,ankle:-88})}),lieDown:At({roll:90,...Ht("arm",{spread:8}),"head.nod":0})};function Jl(t={}){const e=t.headSize??.3,n=t.shoulderWidth??.06,i=t.hipWidth??.022,s=Math.max(.12,1-e-zl-(Xs+qs)),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:bp,width:[1.25,.9]},{length:wp,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:Xs,width:[1.45,1.05]},{length:qs,width:[1.05,.85]},{length:yp,width:[.95,.7]}]}),a=(l,c)=>l[c]??ut[c]??0;return{id:"human",hipHeight:Xs+qs,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:zl,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 p=-a(l,"lean")/2,m=a(l,"side")/2,y=-a(l,"bend");return[{swing:p+y*vp,spread:m},{swing:p+y*Sp,spread:m}]}if(c.id==="neck")return[{swing:-a(l,"bend")*Mp,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"),g=1-Math.cos(Tp(f("rotate")));return[{swing:f("swing"),spread:f("spread"),yaw:d},{swing:-f("knee"),spread:0,yaw:d},{swing:90+f("ankle")-g*(f("swing")-f("knee")),spread:0,yaw:(kp+f("toeOut"))*(c.side??1)}]},withAngles(l,c,h){const[u,f]=c.id.split("."),d=g=>`${u}.${f}.${g}`;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 xp(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 Pp={leftEye:"eye.left",rightEye:"eye.right",leftBrow:"brow.left",rightBrow:"brow.right"},Vs=Object.fromEntries(Object.entries(ot).map(([t,e])=>[t,Object.fromEntries(Object.entries(e).map(([n,i])=>[Pp[n]??n,i]))]));function $p(t,e){const n=Math.min(1,Math.max(0,t.turn??0)),i=1-n,s={...ut,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`],u=t[`${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=t[`${a}Hip`],d=t[`${a}Knee`],g=i+c*n;s[`leg.${l}.rotate`]=90*i,s[`leg.${l}.spread`]=0,s[`leg.${l}.swing`]=f*g,s[`leg.${l}.knee`]=d*g,s[`leg.${l}.ankle`]=-(t[`${a}Ankle`]??0),s[`leg.${l}.toeOut`]=(t[`${a}FootOut`]??0)*_p,s[`eye.${l}`]=t[`${a}Eye`],s[`brow.${l}`]=t[`${a}Brow`],e&&Object.assign(s,Ip(l,e[a]??ct,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 _p=70;function Ip(t,e,n,i){const s=t==="right"?1-i:1+i,o={};for(const r of Object.keys(ct))o[`hand.${t}.${r}`]=e[r]??ct[r];return o[`hand.${t}.turn`]=(e.turn??0)-s,o[`hand.${t}.roll`]=(e.roll??0)+n,o}const Ct=t=>t*Math.PI/180;function Zl([t,e,n],i){const s=Math.cos(i),o=Math.sin(i);return[t,e*s+n*o,-e*o+n*s]}function Gs([t,e,n],i){const s=Math.cos(i),o=Math.sin(i);return[t*s-e*o,t*o+e*s,n]}function de([t,e,n],i){const s=Math.cos(i),o=Math.sin(i);return[t*s+n*o,e,-t*o+n*s]}const ee=(t,e)=>[t[0]+e[0],t[1]+e[1],t[2]+e[2]],pi=(t,e)=>[t[0]*e,t[1]*e,t[2]*e],gi=(t,e)=>Gs(Zl(t,e.swing),e.spread);function zs(t,e){const n=de(t,e);return{point:{x:n[0],y:-n[1]},depth:n[2]}}function mi(t,e,n){const i=n,o=[0,t.hipHeight*i*(t.boneScale?.(e,null)??1),0],r={};for(const p of t.chains){const m=p.parent?r[p.parent]:void 0;if(p.parent&&!m)throw new Error(`body plan ${t.id}: chain ${p.id} comes before its parent ${p.parent}`);const y=p.at??(m?m.joints3.length-1:0),w=m?m.joints3[y]:o,k=m?m.frames[Math.max(0,y-1)]:{swing:0,spread:0},E=p.offset?ee(w,gi(pi(p.offset,i),k)):w,T=p.side??1,S=t.boneScale?.(e,p)??1,P=t.angles(e,p),O=[E],A=[];let C=k.swing,I=k.spread;p.bones.forEach((R,F)=>{const N=P[F]??{swing:0,spread:0};C+=Ct(N.swing),I+=Ct(N.spread)*T,A.push({swing:C,spread:I});const X=de(gi(p.rest,{swing:C,spread:I}),Ct(N.yaw??0));O.push(ee(O[F],pi(X,R.length*i*S)))}),r[p.id]={joints3:O,frames:A}}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,u=h*l.sx,f=h*l.sy,d=p=>gi(de(Zl(Gs(p,-Ct(l.tilt)),-Ct(l.nod)),Ct(l.yaw)),c),g=ee(a.joints3[a.joints3.length-1],d([0,f,0]));return{height:i,root:o,chains:r,head:{center:g,rx:u,ry:f,toBody:d}}}function Js(t,e,n){const i=n.height,s=Ct(90*(e.turn??0)),o=mi(t,e,i),{root:r}=o,a=o.chains,{rx:l,ry:c}=o.head,h=o.head.toBody,u=o.head.center,f={};for(const A of t.chains){const{joints3:C,frames:I}=a[A.id],R=C.map(F=>zs(F,s));f[A.id]={id:A.id,joints3:C,frames:I,points:R.map(F=>F.point),depths:R.map(F=>F.depth)}}const d=zs(u,s),g=[[1,0,0],[0,1,0],[0,0,1]].map(A=>de(h(A),s)),p=zs(r,s).point,m=Ct(e.roll??0),y=A=>{const C=A.x-p.x,I=A.y-p.y;return{x:p.x+C*Math.cos(m)-I*Math.sin(m),y:p.y+C*Math.sin(m)+I*Math.cos(m)}},w=([A,C,I])=>[A*Math.cos(m)+C*Math.sin(m),-A*Math.sin(m)+C*Math.cos(m),I];for(const A of Object.values(f))A.points=A.points.map(y);const k={center:y(d.point),depth:d.depth,rx:l,ry:c,angle:0,axes:g.map(w)},E=k.axes[1];k.angle=Math.atan2(E[0],E[1]);const T=A=>{if("head"in A)return{x:k.center.x+E[0]*c,y:k.center.y-E[1]*c};const C=f[A.chain];return C.points[Math.min(A.joint,C.points.length-1)]};let S=0;(n.contact??"ground")==="ground"&&(S=-Math.max(...t.contacts.map(A=>T(A).y))),S-=(e.lift??0)*i;const P=A=>({x:A.x,y:A.y+S});for(const A of Object.values(f))A.points=A.points.map(P);k.center=P(k.center);const O=t.contacts.map(A=>({spec:A,point:T(A)}));return{height:i,view:s,chains:f,head:k,hip:P(y(p)),contacts:O,groundY:Math.max(...O.map(A=>A.point.y))}}const Zs=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],Ql=t=>{const e=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/e,t[1]/e,t[2]/e]};function Qs(t,e,n){const i=n.height,s=Ct(90*(e.turn??0)),o=Ct(e.roll??0),r=mi(t,e,i),a=de(r.root,s),l=m=>ee(Gs(Zs(de(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),u=m=>Ql(Zs(l(ee(r.head.center,r.head.toBody(m))),h)),f=[u([1,0,0]),u([0,1,0]),u([0,0,1])],d=m=>{if("head"in m)return ee(h,pi(f[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=>d(m)[1]))),g+=(e.lift??0)*i;const p=m=>[m[0],m[1]+g,m[2]];return{height:i,hip:p(a),chains:Object.fromEntries(Object.entries(c).map(([m,y])=>[m,y.map(p)])),head:{center:p(h),rx:r.head.rx,ry:r.head.ry,axes:f}}}function to(t,e,n,i){const s=n.height,o=Ct(90*(e.turn??0)),r=mi(t,e,s),a=Qs(t,e,n),l=a.hip,c=a.chains,h=a.head.center,u=A=>{if("head"in A)return ee(h,pi(a.head.axes[1],a.head.ry));const C=c[A.chain];return C[Math.min(A.joint,C.length-1)]},f=i.toView(l),d=i.toScreen(f),g=i.toScreen([f[0]+1,f[1],f[2]]),p=Math.hypot(g.x-d.x,g.y-d.y),m=A=>{const C=i.toView(A);return{point:i.toScreen(C),depth:C[2]*p}},y={};for(const A of t.chains){const C=c[A.id].map(m);y[A.id]={id:A.id,joints3:r.chains[A.id].joints3,frames:r.chains[A.id].frames,points:C.map(I=>I.point),depths:C.map(I=>I.depth)}}const w=i.toView(h),k=i.toScreen(w),E=i.toScreen([w[0]+1,w[1],w[2]]),T=Math.hypot(E.x-k.x,E.y-k.y),S=a.head.axes.map(A=>Ql(Zs(i.toView(ee(h,A)),w))),P={center:k,depth:w[2]*p,rx:r.head.rx*T,ry:r.head.ry*T,angle:Math.atan2(S[1][0],S[1][1]),axes:S},O=t.contacts.map(A=>({spec:A,point:m(u(A)).point}));return{height:s*p,view:o,chains:y,head:P,hip:d,contacts:O,groundY:Math.max(...O.map(A=>A.point.y))}}function tc(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 ec{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 Hp(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 eo=Math.PI*2;function Cp(t,e=16){const n=new ec,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*eo,u=Math.sin(a)*Math.sin(h),f=Math.cos(a),d=Math.sin(a)*Math.cos(h);l.push(n.vertex(u*t,f*t,d*t,u,f,d))}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],u=o[r][a+1];r>0&&n.triangle(l,c,u),r<s-1&&n.triangle(c,h,u)}return n.build()}function nc(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*eo;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 Op(t,e,n=24){const i=new ec,s=Math.max(6,Math.round(n)),o=e/2,r=-e/2,a=h=>Array.from({length:s+1},(u,f)=>{const d=f/s*eo;return i.vertex(Math.sin(d)*t,h,Math.cos(d)*t,Math.sin(d),0,Math.cos(d))}),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 nc(i,t,o,1,s),nc(i,t,r,-1,s),i.build()}function ic(t){const e=Array.from({length:t.indices.length/3},()=>[]);for(const n of Hp(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 yi=t=>t*180/Math.PI,Le=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],no=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],mn=t=>Math.hypot(t[0],t[1],t[2]),io=t=>{const e=mn(t)||1;return[t[0]/e,t[1]/e,t[2]/e]},bi=t=>Math.atan2(Math.sin(t),Math.cos(t));function sc(t){const[e,n,i]=io(t);return{swing:Math.asin(Math.max(-1,Math.min(1,i))),spread:Math.atan2(e,-n)}}function Rp(t,e,n,i,s){const o=t.chains.find(C=>C.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=Js(t,{...e,turn:0,roll:0,lift:0},{height:s.height,contact:"none"}),a=r.chains[n],l=a.joints3[0],c=mn(Le(a.joints3[1],a.joints3[0])),h=mn(Le(a.joints3[2],a.joints3[1])),u=o.parent?r.chains[o.parent].frames[Math.max(0,(o.at??r.chains[o.parent].joints3.length-1)-1)]:{swing:0,spread:0},f=Le(i,l),d=Math.min(c+h-1e-6,Math.max(Math.abs(c-h)+1e-6,mn(f))),g=io(f),p=o.parent!==null,m=gi(o.pole??(p?[0,-.35,-1]:[0,0,1]),u);let y=Le(m,[g[0]*no(m,g),g[1]*no(m,g),g[2]*no(m,g)]);mn(y)<1e-6&&(y=de([1,0,0],0)),y=io(y);const w=(c*c+d*d-h*h)/(2*c*d),k=Math.sqrt(Math.max(0,1-w*w)),E=[l[0]+c*(w*g[0]+k*y[0]),l[1]+c*(w*g[1]+k*y[1]),l[2]+c*(w*g[2]+k*y[2])],T=[l[0]+g[0]*d,l[1]+g[1]*d,l[2]+g[2]*d],S=o.side??1,P=sc(Le(E,l)),O=sc(Le(T,E)),A=[{swing:yi(bi(P.swing-u.swing)),spread:yi(bi(P.spread-u.spread))*S},{swing:yi(bi(O.swing-P.swing)),spread:yi(bi(O.spread-P.spread))*S}];return t.withAngles(e,o,A)}const Lp=.34,ne=.12,Nt=-.4,Kt=(t,e,n)=>t[e]??n,Fp=(t,e)=>Math.max(0,t)*(1-Math.min(1,Math.max(0,e))),Dp=.45,Np=.35,Bp=.7;function wi(t,e,n){const i=d=>Math.sqrt(Math.max(0,1-d.x*d.x-d.y*d.y)),s=tc(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(Np,Math.abs(a)),h=l*Math.max(Bp,Math.abs(a)),u=Math.cos(t.angle),f=Math.sin(t.angle);return{facing:s,points:e.map(d=>{const g=Dp*Math.sin(r)+n.x*c+(d.x-n.x)*h,p=d.y+o[1]*i(d),m=g*t.rx,y=p*t.ry;return{x:t.center.x+m*u+y*f,y:t.center.y+m*f-y*u}})}}const ki=(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}}),so=(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}}),oc=.05;function Wp(t,e,n,i){const s=Math.max(1,Math.min(i*.6,.14*e.rx)),o=(y,w)=>wi(e,y,w).points,r=(y,w)=>wi(e,[],{x:y,y:w}).facing,a=Kt(n,"smile",0),l=Kt(n,"blink",0),c=Kt(n,"lookX",0),h=Kt(n,"lookY",0),u=Kt(n,"browTilt",0);for(const y of[1,-1]){const w=y===1?"left":"right",k=Lp*y;if(r(k,ne)<oc)continue;const E={x:k,y:ne},T=Fp(Kt(n,`eye.${w}`,1),l);if(T<.2){const A=a>.5?.12:-.06;t.line(o(ki({x:k-.12,y:ne},{x:k,y:ne+A},{x:k+.12,y:ne}),E),s)}else{if(T>1.2){const R=.13*T;t.shape(o(so(k,ne,R*.85,R),E),"#ffffff",s)}const A=T>1.2?.075:.1,C=k+c*.08,I=ne-h*.07;t.shape(o(so(C,I,A,A*1.1*Math.min(T,1)),E),t.ink,0)}const S=ne+.3+Kt(n,`brow.${w}`,0)*.14+Math.max(0,T-1)*.12,P={x:k+y*.13,y:S},O={x:k-y*.13,y:S+u*.1};t.line(o([P,{x:(P.x+O.x)/2,y:(P.y+O.y)/2},O],{x:k,y:S}),s)}const f={x:0,y:Nt};if(r(0,Nt)<-oc)return;const d=.25*Math.max(.3,Kt(n,"mouthWidth",1)),g=Math.min(1,Math.max(0,Kt(n,"mouth",0)));if(g<=.05){t.line(o(ki({x:-d,y:Nt},{x:0,y:Nt-a*.25},{x:d,y:Nt}),f),s);return}const p=.3*g;let m;if(a>.3){const y=Nt+.05;m=[...ki({x:d,y},{x:0,y:Nt-p*2},{x:-d,y})]}else if(a<-.3){const y=Nt-p*.6;m=[...ki({x:d,y},{x:0,y:Nt+p*1.4},{x:-d,y})]}else m=so(0,Nt,d*.8,p);t.shape(o(m,f),t.ink,0)}function rc(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??Jl({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 Kp(t,e,n,i){const{point:s,facing:o}=tc(t,[e,n,i]);return{point:s,facing:o}}const oo=t=>t.rest[1]<-.5,Yp=.3;function jp(t,e,n){return t.figure==="stick"?oo(e)?n.slice(0,3):n:oo(e)&&n.length>=3?ue(n[0],n[1],n[2],Yp):n.length===3?ue(n[0],n[1],n[2],1):n}function ro(t,e){const n=t.plan.id==="human"?{...ut,...e}:e;return ao(t,n,Js(t.plan,n,{height:t.height,contact:t.contact}))}function ao(t,e,n){const i={},s={},o={},r=.01*t.height;t.plan.chains.forEach(f=>{const d=n.chains[f.id];i[f.id]=d.points;const g=d.depths.reduce((w,k)=>w+k,0)/d.depths.length,p=f.parent?n.chains[f.parent]:void 0,m=p?p.depths[f.at??p.depths.length-1]:0,y=g-m;o[f.id]=Math.abs(y)<r?0:y,s[f.id]={points:jp(t,f,d.points),depth:g}}),s.head={points:[n.head.center],depth:n.head.depth},o.head=0;const a=[...t.plan.chains.map(f=>f.id),"head"],l=[...a].sort((f,d)=>o[f]-o[d]||a.indexOf(f)-a.indexOf(d)),c={hip:n.hip};for(const[f,[d,g]]of Object.entries(t.plan.landmarks??{})){const p=n.chains[d]?.points;p&&(c[f]=p[Math.min(g,p.length-1)])}const h={};for(const[f,d]of Object.entries(c))h[f]=d.y>=n.groundY-.01*t.height;const u={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:u,order:l}}function ac(t,e){return ro(t,e).joints}function Xp(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=wi(i,s,{x:0,y:0});r.facing>0&&t.guide(r.points),t.guide(wi(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 qp(t,e,n,i,s,o){const r=n.lineWidth;if(s==="head"){const{head:d}=i,g=n.skin==="none"?null:n.skin;e.ellipse(d.center.x,d.center.y,d.rx,d.ry,d.angle,g,r),e.look!=="silhouette"&&Wp(e,d,o,r);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;e.line(d,r);return}const h=(d,g)=>[a.bones[d].width[0]*r,a.bones[g].width[1]*r];if(oo(a)){const[d,g]=h(0,1);if(e.limb(c,d,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."))Up(t,e,n,l,s.endsWith(".left")?"left":"right",o);else{const p=l[l.length-1];e.dot(p.x,p.y,r*.62)}return}if(s==="spine"){const d=i.points["hip.left"],g=i.points["hip.right"];d&&g&&Math.hypot(d.x-g.x,d.y-g.y)>.5&&e.limb([d,g],r*1.3,r*1.3);const[p,m]=h(0,a.bones.length-1);e.limb(c,p,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(ue(y,l[l.length-1],w,1,10),r*1.15,r*1.15);return}const[u,f]=h(0,a.bones.length-1);e.limb(c,u,f)}function lc(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{...ct,...i,turn:o+(i.turn??0)}}function Up(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;ii(t,r,lc(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 cc(t,e,n,i=0){const s=e.plan.id==="human"?{...ut,...n}:n;fc(t,e,s,ro(e,s),i)}function hc(t,e){const n=e/t.height;return{...t,height:e,lineWidth:t.lineWidth*n}}function Vp(t,e,n,i){const s=t.plan.id==="human"?{...ut,...e}:e,o=to(t.plan,s,{height:i.height,contact:t.contact},n);return ao(hc(t,o.height),s,o).joints}function uc(t,e,n,i,s){const o=e.plan.id==="human"?{...ut,...n}:n,r=to(e.plan,o,{height:s.height,contact:e.contact},i),a=hc(e,r.height);fc(t,a,o,ao(a,o,r),s.time??0)}function fc(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&&Xp(a,e,o),l(e.layers.behind);for(const c of r){const h=e.layers.parts?.[c];l(h?.under),qp(t,a,e,o,c,n),l(h?.over)}l(e.layers.front),t.restore()}function Gp(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 zp(t,e,n,i){const s=t.plan.id==="human"?{...ut,...e}:e;let o;if(Array.isArray(i))o=i;else{const{skeleton:r}=ro(t,s),a=Js(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,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),g=i.depth??r.chains[n].depths[r.chains[n].depths.length-1],p=Math.cos(d),m=Math.sin(d);o=[u*p-g*m,-f,u*m+g*p]}return Rp(t.plan,s,n,o,{height:t.height})}function Jp(t){const{character:e}=t,n=e.height*.8,i=e.height,s=e.plan.id==="human"?ut:{};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),cc(o,e,r.props,a)}}}function dc(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 Zp(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=ac(i,s);return{pose:s,joints:dc(a,t.x+o+t.width/2,t.y+r+t.height)}}function lo(t,e=ut){const n=[];return t.forEach((i,s)=>{const o=s===0?e:n[s-1],r=typeof i.pose=="string"?Us[i.pose]:void 0;n.push(r?{...r,turn:o.turn??0}:{...o,...i.pose})}),n}function Qp(t,e,n=ut){const i=lo(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 tg=new Set(["x","y","z","position","rotateX","rotateY","rotateZ","quaternion","scale","scaleX","scaleY","scaleZ","visible","opacity","color"]),eg=1.7;function ng(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 ig(t){const e=Je([0,1,0],t);if(e>.999999)return Yr();if(e<-.999999)return Qe(Se([1,0,0],180));const n=Kn([0,1,0],t);return Qe(Se(n,Math.acos(e)*180/Math.PI))}function sg(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,u=[],f=(k,E,T)=>u.push({mesh:k,world:le(s,E),material:T}),d=(k,E,T)=>f(e.sphere,Xr(k,[0,0,0,1],[E,E,E]),T);for(const k of n.chains){const E=i.chains[k.id],T=k.id==="spine"?1.9:1;k.bones.forEach((S,P)=>{const O=E[P],A=E[P+1],C=Wr(O,A),[I,R]=S.width??[1,1],F=h*T*(I+R)/2;if(C>1e-6){const N=Kr(O,A,.5),X=ig(Ze(Wn(A,O)));f(e.cylinder,le(jr(N),le(X,Yn([F,C,F]))),a)}d(O,h*T*I,a),d(A,h*T*R,a)}),k.id.startsWith("arm.")&&d(E[E.length-1],h*1.5,l)}const{center:g,rx:p,ry:m,axes:y}=i.head,w=[...y[0],0,...y[1],0,...y[2],0,...g,1];f(e.sphere,le(w,Yn([p,m,p])),l);for(const k of[-1,1]){const E=Ze([k*.36,.15,.92]),T=Bn(g,Bn(Bn(ze(y[0],E[0]*p*1.04),ze(y[1],E[1]*m*1.04)),ze(y[2],E[2]*p*1.04))),S=[...y[0],0,...y[1],0,...y[2],0,...T,1];f(e.sphere,le(S,Yn([p*.11,m*.14,p*.03])),c)}return u}const og={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:rc({...t.character,height:1}),cylinder:ic(Op(1,1,16)),sphere:ic(Cp(1,20))}},resolve({object:t,prepared:e,values:n,world:i,camera:s,toScreen:o}){const r=t,a=e,l=a.who,c={...ut,...r.pose};for(const[m,y]of n)typeof y=="number"&&!tg.has(m)&&(c[m]=y);const h=r.height??eg,u=le(s.view,i),f={toView:m=>qr(u,m),toScreen:m=>o(m)},g=-f.toView([0,h/2,0])[2];if(g<=s.near)return null;const p=r.shadow===!1?[]:[{depth:g+h,draw:m=>ng(m,f,h*.18)}];if(r.look==="solid"){const m=Qs(l.plan,c,{height:h,contact:l.contact});return{meshes:sg(r,a,l.plan,m,i),drawables:p}}return{drawables:[...p,{depth:g,draw(m,y){m.lineCap="round",m.lineJoin="round",uc(m,l,c,f,{height:h,time:y.time})}}]}}},pc={x:0,y:0,scale:1,rotate:0,shakeX:0,shakeY:0,shakeRotate:0};function rg(t){const e=n=>{const i=t?.get(n);return typeof i=="number"?i:pc[n]};return{x:e("x"),y:e("y"),scale:e("scale"),rotate:e("rotate"),shakeX:e("shakeX"),shakeY:e("shakeY"),shakeRotate:e("shakeRotate")}}function ag(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 lg(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 gc(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)bc(t,c,i);t.restore()}function co(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 mc=150,cg={pencil:44,eraser:30};function ho(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},u=mc*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 f={x:e.x+h.x+6*l*a,y:e.y+h.y-18*l*a},d=dt.pencilGrip,g=P=>{const O=P.fingers.thumb,A=P.fingers.index,C=P.fingers.middle,I=yc([O.points[3],A.points[3],C.points[3]]),R=yc([O.points[1],A.points[0]]),F=(O.depths[3]+A.depths[3]+C.depths[3])/3;return{pinch:I,direction:Math.atan2(R.y-I.y,R.x-I.x),depth:F}},p=ni(d,{size:u}),m=c-g(p).direction,y=ni(d,{size:u,angle:m*180/Math.PI}),w=g(y),k=cg[s]*a,E={x:w.pinch.x-Math.cos(c)*k,y:w.pinch.y-Math.sin(c)*k},T={x:f.x-E.x,y:f.y-E.y},S=y.axes.up;hg(t,T,{x:-S.x,y:-S.y},u,n.arm??300*a,o,n.sleeve??"#5b7db1",r),ii(t,T,d,{size:u,angle:m*180/Math.PI,skin:o,ink:r,lineWidth:3*a,prop:{depth:w.depth,draw:()=>{t.save(),t.translate(f.x,f.y),t.scale(a,a),s==="eraser"?co(t,{x:0,y:0},{angle:c*180/Math.PI,outline:r},i):gc(t,{x:0,y:0},{angle:c*180/Math.PI,length:190,outline:r},i),t.restore()}}})}const yc=t=>({x:t.reduce((e,n)=>e+n.x,0)/t.length,y:t.reduce((e,n)=>e+n.y,0)/t.length});function hg(t,e,n,i,s,o,r,a){const l={x:-n.y,y:n.x},c=i*.15,h=(p,m,y)=>({x:e.x+n.x*p+l.x*m*y,y:e.y+n.y*p+l.y*m*y}),u=h(s,0,0),f=p=>{const m=t.createLinearGradient(e.x,e.y,u.x,u.y);return m.addColorStop(0,p),m.addColorStop(.6,p),m.addColorStop(1,pg(p)),m},d=Math.min(i*.55,s*.35);t.save(),t.lineJoin="round",t.lineCap="round",t.lineWidth=3*(i/mc),t.beginPath(),t.moveTo(h(-i*.1,-1,c).x,h(-i*.1,-1,c).y),t.lineTo(h(d+4,-1,c*1.1).x,h(d+4,-1,c*1.1).y),t.lineTo(h(d+4,1,c*1.1).x,h(d+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(d,-1,c*1.1).x,h(d,-1,c*1.1).y),t.moveTo(h(0,1,c).x,h(0,1,c).y),t.lineTo(h(d,1,c*1.1).x,h(d,1,c*1.1).y),t.stroke();const g=[h(d,-1,c*1.3),h(s,-1,c*1.5),h(s,1,c*1.5),h(d,1,c*1.3)];t.beginPath(),g.forEach((p,m)=>m?t.lineTo(p.x,p.y):t.moveTo(p.x,p.y)),t.closePath(),t.fillStyle=f(r),t.fill(),t.strokeStyle=f(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 ug(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(p=>p.path.length>0).sort((p,m)=>p.start-m.start),l=p=>p.tool??"pencil",c=p=>{const m=Math.min(1,Math.max(0,p));return m*m*(3-2*m)},h=(p,m,y)=>({x:p.x+(m.x-p.x)*y,y:p.y+(m.y-p.y)*y}),u=a.find(p=>e>=p.start&&e<=p.end);if(u){const p=u.end-u.start,m=p>0?(e-u.start)/p:1;return{at:Jn(u.path,m),tool:l(u),lift:0,drawing:!0}}const f=[...a].reverse().find(p=>p.end<e),d=a.find(p=>p.start>e),g=p=>p.path[p.path.length-1];if(f&&d&&d.start-f.end<=r){const p=(e-f.end)/(d.start-f.end),m=p<.5?l(f):l(d);return{at:h(g(f),d.path[0],c(p)),tool:m,lift:Math.sin(Math.PI*p),drawing:!1}}if(d&&d.start-e<=s){const p=1-(d.start-e)/s;return{at:h(i,d.path[0],c(p)),tool:l(d),lift:1-c(p),drawing:!1}}if(f&&e-f.end<=o){const p=(e-f.end)/o;return{at:h(g(f),i,c(p)),tool:l(f),lift:c(p),drawing:!1}}return null}function fg(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 dg(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 u=t.sketch?Zn(a,t.sketch,c):void 0;h>0&&(u?t.smooth?u.curve(e,h):u.line(e,h):bc(a,Ie(e,h))),r&&h>0&&h<1&&ho(a,Jn(e,h),r,u)}}}function pg(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 bc(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 vi=1e5;function gg(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 uo(t,e,n,i){if(i<=0||e.length===0)return;const s=Ie(e,i),o=n/2,r=a=>{t.beginPath(),t.rect(-vi,-vi,2*vi,2*vi),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 u=-(c.y-l.y)/h*o,f=(c.x-l.x)/h*o;r(()=>{t.moveTo(l.x+u,l.y+f),t.lineTo(c.x+u,c.y+f),t.lineTo(c.x-u,c.y-f),t.lineTo(l.x-u,l.y-f),t.closePath()})}}function mg(t,e,n,i,s){t.save(),uo(t,e,n,i),s(),t.restore()}function yg(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(),uo(o,e.path,n,l),t.draw(o,r,a),o.restore(),!s||l<=0||l>=1)return;const c=Jn(e.path,l);i?ho(o,c,{...i,tool:"eraser"}):co(o,c,s)}}}const wc={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"},Si=["wipe","fly","blur"],bg=.0016,wg=.6,yn=33,kg=.9,vg=8;function Sg(t){const e={...wc,...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(v=>v.length)),c=t.width??r*2+a+l*o,h=r*2+n.length*s,u=t.x+r+a,f=new Set(t.hidden??[]),d=t.language??"plain";if(!Ti.includes(d))throw new Error(`codePanel: ${Bt("language",d,Ti)}`);const g=n.map(v=>vc(v,d).flatMap(x=>Array.from(x.text,()=>e[x.kind]))),p=new Map,m=[],y=new Map,w=[],k=[],E=v=>{if(!Number.isInteger(v)||v<1||v>n.length)throw new Error(`codePanel: no line ${v} (it has ${n.length})`)},T=(v,...x)=>p.set(v,[...p.get(v)??[],...x]),S=(v,x,M,_,H=300)=>T(v,{time:_.at,value:x},{time:_.at+(_.duration??H),value:M,..._.easing?{easing:_.easing}:{}}),P=(v,x,M,_,H,D=300)=>{E(v),S(`line.${v}.${x}`,M,_,H,D)},O=(v,x)=>m.filter(M=>M.line<v&&M.closed<=x).length,A=(v,x,M,_)=>({x:v+M/2,y:x+_/2,left:v,right:v+M,top:x,bottom:x+_,width:M,height:_}),C=v=>t.y+r+(v-1)*s,I=v=>Array.isArray(v)?v:[v],R=(v,x)=>{const M=p.get(v);return M?[...M].sort((_,H)=>_.time-H.time)[M.length-1].value:x},F=(v,x,M)=>{let _=-1;for(let H=0;H<M;H++)if(_=n[v-1].indexOf(x,_+1),_<0)throw new Error(`codePanel: line ${v} has no ${M>1?`${M}th `:""}"${x}"`);return _},N={};n.forEach((v,x)=>{const M=x+1;N[`line.${M}.highlight`]=0,N[`line.${M}.strike`]=0,N[`line.${M}.wipe`]=0,N[`line.${M}.reveal`]=f.has(M)?0:1,N[`line.${M}.shift`]=0});const X={type:"custom",x:t.x,y:t.y,width:c,height:h,props:N,about:{kind:"code panel",summary:`${n.length} lines of ${d} code. Its lines and words are places in the scene (line(), token(), spot()); its edits are methods that record tracks (tracks()).`,get props(){return Tg(Object.keys(N))},actions:fo},draw(v,x){const M=x.props??{},_=B=>Number(M[B]??N[B]),H=r+a,D=B=>r+(B-1)*s-_(`line.${B}.shift`)*s;v.fillStyle=e.background,kc(v,0,0,c,h,8),v.fill(),v.font=`${i}px ${e.font}`,v.textBaseline="middle",v.textAlign="left";const K=(B,Y,J,et,Q)=>{const nt=n[B-1];for(let U=Y;U<J;U++)nt[U]!==" "&&(v.fillStyle=g[B-1][U],v.fillText(nt[U],et+(U-Y)*o,Q))};v.save(),kc(v,0,0,c,h,8),v.clip(),n.forEach((B,Y)=>{const J=Y+1,et=_(`line.${J}.wipe`);if(et>=1)return;const Q=D(J),nt=Q+s/2,U=Math.max(1,B.length)*o,pt=Math.round(_(`line.${J}.reveal`)*B.length),gt=y.get(J)??{style:"wipe",from:"left"};v.save(),et>0&&Mg(v,gt,et,{left:H-a,top:Q,width:a+U+o,height:s},c);const wt=_(`line.${J}.highlight`);wt>0&&(v.globalAlpha*=Math.min(1,wt),v.fillStyle=e.highlight,v.fillRect(H-o/2,Q,U+o,s),v.globalAlpha/=Math.min(1,wt)),a>0&&pt>0&&(v.fillStyle=e.gutter,v.textAlign="right",v.fillText(String(J),H-o,nt),v.textAlign="left");const oe=[...w.filter(q=>q.line===J).map(q=>({column:q.column,length:q.text.length,piece:q,insert:void 0})),...k.filter(q=>q.line===J).map(q=>({column:q.column,length:0,piece:void 0,insert:q}))].sort((q,it)=>q.column-it.column||q.length-it.length);let Pt=0,z=H;for(const q of oe){K(J,Pt,Math.min(q.column,pt),z,nt),z+=(q.column-Pt)*o;let it=q.length,lt="";if(q.piece){const ft=q.piece.written??"",kt=_(`piece.${q.piece.id}.write`);ft&&kt>0?(lt=ft.slice(0,Math.round(kt*ft.length)),it=q.length+(ft.length-q.length)*Math.min(1,kt*2)):it=q.length*(1-_(`piece.${q.piece.id}.away`))}else q.insert&&(it=q.insert.chars*_(`insert.${q.insert.id}.open`),q.insert.text&&(lt=q.insert.text.slice(0,Math.round(_(`insert.${q.insert.id}.type`)*q.insert.text.length))));v.fillStyle=e.text;for(let ft=0;ft<lt.length;ft++)lt[ft]!==" "&&v.fillText(lt[ft],z+ft*o,nt);z+=it*o,Pt=q.column+q.length}K(J,Pt,Math.max(Pt,pt),z,nt);const st=_(`line.${J}.strike`);st>0&&(v.strokeStyle=e.strike,v.lineWidth=Math.max(1.5,i/10),v.beginPath(),v.moveTo(H,nt),v.lineTo(H+U*Math.min(1,st),nt),v.stroke()),v.restore()});for(const B of w){const Y=_(`piece.${B.id}.opacity`);if(Y<=0||_(`line.${B.line}.wipe`)>=1)continue;const J=H+(B.column+B.text.length/2)*o+_(`piece.${B.id}.x`),et=D(B.line)+s/2+_(`piece.${B.id}.y`);v.save(),v.globalAlpha=Math.min(1,Y),v.translate(J,et),v.rotate(_(`piece.${B.id}.rotate`)*Math.PI/180),K(B.line,B.column,B.column+B.text.length,-B.text.length*o/2,0),v.restore()}v.restore()}},G=(v,x)=>({x:v.home.x+bn(p.get(`piece.${v.id}.x`),x),y:v.home.y+bn(p.get(`piece.${v.id}.y`),x)}),$=(v,x)=>{for(const M of["x","y","rotate"]){const _=`piece.${v.id}.${M}`,H=(p.get(_)??[]).filter(D=>D.time<=x);p.set(_,H)}},L={target:X,lines:n,box:A(t.x,t.y,c,h),line(v,x=1/0){return E(v),A(u,C(v)-O(v,x)*s,Math.max(1,n[v-1].length)*o,s)},token(v,x,M=1,_=1/0){E(v);const H=F(v,x,M);return A(u+H*o,C(v)-O(v,_)*s,x.length*o,s)},highlight(v,x){for(const M of I(v)){const _=R(`line.${M}.highlight`,0);P(M,"highlight",_,x.on===!1?0:1,x,200)}return L},strike(v,x){for(const M of I(v))P(M,"strike",R(`line.${M}.strike`,0),1,x);return L},remove(v,x){const M=I(v),_=x.style??"wipe";if(!Si.includes(_))throw new Error(`codePanel.remove: ${Bt("style",_,Si)}`);const H=_==="wipe"?300:450,D=x.at+(x.duration??H),K=x.close??250;for(const B of M)P(B,"wipe",0,1,{...x,easing:x.easing??(_==="fly"?"ease-in":void 0)},H),y.set(B,{style:_,from:x.from??"left"}),m.push({line:B,closed:D+K});for(let B=1;B<=n.length;B++){if(M.includes(B))continue;const Y=M.filter(et=>et<B).length;if(Y===0)continue;const J=R(`line.${B}.shift`,0);P(B,"shift",J,J+Y,{at:D,duration:K,easing:"ease-in-out"})}return L},type(v,x){return P(v,"reveal",0,1,{duration:n[v-1].length*45,...x}),L},piece(v,x,M=1){E(v);const _=F(v,x,M),H=w.find(K=>K.line===v&&K.column===_&&K.text===x);if(H)return H;if(w.some(K=>K.line===v&&_<K.column+K.text.length&&K.column<_+x.length))throw new Error(`codePanel: "${x}" on line ${v} overlaps another piece`);const D={id:w.length+1,line:v,column:_,text:x,home:L.token(v,x,M,0)};w.push(D);for(const K of["x","y","rotate","write","away"])N[`piece.${D.id}.${K}`]=0;return N[`piece.${D.id}.opacity`]=1,D},follow(v,x){for(const M of x)T(`piece.${v.id}.x`,{time:M.time,value:M.x-v.home.x}),T(`piece.${v.id}.y`,{time:M.time,value:M.y-v.home.y});return L},fling(v,x){const M=G(v,x.at),_=x.velocity??j(v,x.at)??{x:.5,y:-.6},H=x.gravity??bg,D=x.duration??900,K=(x.spin??wg)*(_.x<0?-1:1),B=bn(p.get(`piece.${v.id}.rotate`),x.at);$(v,x.at);for(let Y=0;Y<=D;Y+=yn){const J=M.x+_.x*Y,et=M.y+_.y*Y+.5*H*Y*Y;T(`piece.${v.id}.x`,{time:x.at+Y,value:J-v.home.x}),T(`piece.${v.id}.y`,{time:x.at+Y,value:et-v.home.y}),T(`piece.${v.id}.rotate`,{time:x.at+Y,value:B+K*Y})}return S(`piece.${v.id}.opacity`,1,0,{at:x.at+D*.6,duration:D*.4}),L},move(v,x){const M=G(v,x.at);return S(`piece.${v.id}.x`,M.x-v.home.x,x.to.x-v.home.x,x,400),S(`piece.${v.id}.y`,M.y-v.home.y,x.to.y-v.home.y,x,400),L},write(v,x,M){return v.written=x,S(`piece.${v.id}.write`,0,1,{duration:Math.max(1,x.length)*70,...M}),L},spot(v,x,M=1,_=1/0){E(v);const H=k.filter(D=>D.line===v&&D.column<=x&&D.at<=_).reduce((D,K)=>D+K.chars,0);return A(u+(x+H)*o,C(v)-O(v,_)*s,M*o,s)},insert(v,x,M,_){E(v);const H={id:k.length+1,line:v,column:x,chars:M.length,text:M,at:_.at};k.push(H),N[`insert.${H.id}.open`]=0,N[`insert.${H.id}.type`]=0;const D=_.duration??M.length*70;return S(`insert.${H.id}.open`,0,1,{at:_.at,duration:D*.6,easing:"ease-out"}),S(`insert.${H.id}.type`,0,1,{at:_.at,duration:D}),L},drop(v,x,M,_){E(x);const H=_.duration??250,D=x===v.line,K=_.easing??(D?"linear":"ease-out"),B=L.landing(v,x,M,_.at),Y={id:k.length+1,line:x,column:M,chars:v.text.length,at:_.at};return k.push(Y),N[`insert.${Y.id}.open`]=0,S(`insert.${Y.id}.open`,0,1,{at:_.at,duration:H,easing:D?K:"ease-out"}),S(`piece.${v.id}.away`,R(`piece.${v.id}.away`,0),1,{at:_.at,duration:H,easing:D?K:"ease-in-out"}),$(v,_.at),L.move(v,{at:_.at,duration:H,easing:K,to:{x:B.x,y:B.y}}),S(`piece.${v.id}.rotate`,bn(p.get(`piece.${v.id}.rotate`),_.at),0,{at:_.at,duration:H}),L},landing(v,x,M,_=1/0){const H=L.spot(x,M,v.text.length,_),D=x===v.line&&M>v.column?v.text.length*o:0;return A(H.left-D,H.top,H.width,H.height)},ride(v,x,M){return W(v,x,M.ground,M.every??yn)},tracks(v){return[...p].filter(([,x])=>x.length>0).map(([x,M])=>({id:`${v}-${x}`,target:v,property:x,keyframes:Eg(M)}))}};function W(v,x,M,_){const H=n.map((z,st)=>p.get(`line.${st+1}.shift`)??[]);if(H.every(z=>z.length===0))return v;const D=v.find(z=>z.target===x&&z.property==="y"),K=new ae({id:`${x}-ride`,tracks:D?[D]:[]}),B=z=>D?Number(K.getStateAtTime(z).values.get(x)?.get("y")??0):0,Y=z=>{const st=M+B(z);return n.findIndex((q,it)=>Math.abs(C(it+1)-st)<.5)},J=(D?.keyframes??[]).map(z=>z.time),et=z=>{const st=kt=>kt<0?0:-bn(H[kt],z)*s,q=Y(z);if(q>=0)return st(q);if(Math.abs(B(z))<.5)return 0;const it=kt=>Y(kt)>=0||Math.abs(B(kt))<.5,lt=[...J].reverse().find(kt=>kt<=z&&it(kt)),ft=J.find(kt=>kt>=z&&it(kt));return lt===void 0&&ft===void 0?0:lt===void 0?st(Y(ft)):ft===void 0||ft===lt?st(Y(lt)):st(Y(lt))+(st(Y(ft))-st(Y(lt)))*(z-lt)/(ft-lt)},Q=H.flatMap(z=>{const st=[...z].sort((q,it)=>q.time-it.time);return st.slice(1).flatMap((q,it)=>q.value!==st[it].value?[{start:st[it].time,end:q.time}]:[])}),nt=(z,st)=>Q.some(q=>q.start<st&&q.end>z)||et(z)!==et(st),U=D?[...D.keyframes]:[{time:0,value:0}],pt=[{...U[0],value:U[0].value+et(U[0].time)}],gt=(z,st)=>{const q=new Set([st]);for(let it=z+_;it<st;it+=_)q.add(it);for(const it of Q)for(const lt of[it.start,it.end])lt>z&<<st&&q.add(lt);for(const it of[...q].sort((lt,ft)=>lt-ft))pt.push({time:it,value:B(it)+et(it)})};for(let z=1;z<U.length;z++){const st=U[z-1].time,q=U[z].time;nt(st,q)?gt(st,q):pt.push({...U[z],value:U[z].value+et(q)})}const wt=U[U.length-1].time,oe=Math.max(wt,...Q.map(z=>z.end));oe>wt&>(wt,oe);const Pt={id:D?.id??`${x}-y`,target:x,property:"y",keyframes:pt};return D?v.map(z=>z===D?Pt:z):[...v,Pt]}function j(v,x){const M=p.get(`piece.${v.id}.x`);if(!M||M.length<2)return;const _=G(v,x-yn),H=G(v,x);return{x:(H.x-_.x)/yn,y:(H.y-_.y)/yn}}return L}function Mg(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=vg*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*kg*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 bn(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 fo={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 Tg(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 Eg(t){return[...t].sort((n,i)=>n.time-i.time).map(n=>({time:n.time,value:n.value,...n.easing?{easing:n.easing}:{}}))}function kc(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 Mi={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:[]};Mi.typescript=[...Mi.javascript,"enum","interface","type","implements","private","public","readonly","keyof","as","declare","namespace"];const Ti=Object.keys(Mi),Ag={go:"//",rust:"//",csharp:"//",javascript:"//",typescript:"//",python:"#",plain:null};function vc(t,e){const n=new Set(Mi[e]),i=Ag[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 Sc=40,xg=.215+.205,xt=(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},Z=(t,e)=>t[e]??ut[e]??0;function Pg(t,e,n=ut,i=1){const s=hn(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,u=s.forearm??0,f={...ut,...n};f["leg.left.swing"]=s.swing*r+c*.6,f["leg.right.swing"]=-s.swing*r+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"]=Z(n,"leg.left.ankle")-(s.tiptoe??0),f["leg.right.ankle"]=Z(n,"leg.right.ankle")-(s.tiptoe??0);for(const[d,g]of[["left",-1],["right",1]])Z(n,`arm.${d}.spread`)>Sc||Z(n,`arm.${d}.swing`)>Sc||(f[`arm.${d}.swing`]=h+g*s.arm*r,f[`arm.${d}.elbow`]=Z(n,`arm.${d}.elbow`)+u+s.elbow*Math.max(0,g*r));return f.lean=Z(n,"lean")+s.lean*i,f.bend=Z(n,"bend")+(s.bend??0),f["head.nod"]=Z(n,"head.nod")-s.lean*.5*i+(s.headTilt??0),f.side=Z(n,"side")+(s.sway??0)*Math.sin(o),f.lift=Z(n,"lift")+(s.bounce??0)*i*l,f.stretch=Z(n,"stretch")*(1+(s.squash??0)*(l-.5)),f}function $g(t,e,n=1){const i=hn(t);return 4*xg*e*Math.sin(i.swing*n*Math.PI/180)}const Fe=t=>Vs[t],po={take:t=>[{after:140,pose:{stretch:.8,bend:10,lean:Z(t,"lean")-4,...xt("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,...xt("arm",{spread:150,bend:35,swing:0,elbow:0}),...xt("leg",{swing:25,knee:60}),...Fe("shocked")},easing:"ease-out-cubic"},{after:720,pose:{lift:.25,stretch:1.25,bend:-10,...xt("arm",{spread:140})},easing:"ease-in-out"},{after:900,pose:{lift:0,stretch:.74,bend:12,...xt("arm",{spread:70,bend:0}),...xt("leg",{swing:30,knee:60})},easing:"ease-in-quad"},{after:1060,pose:{stretch:1.06,bend:-3,...xt("arm",{spread:60}),"leg.left.swing":Z(t,"leg.left.swing"),"leg.right.swing":Z(t,"leg.right.swing"),"leg.left.knee":Z(t,"leg.left.knee"),"leg.right.knee":Z(t,"leg.right.knee")},easing:"ease-out"},{after:1260,pose:{stretch:Z(t,"stretch"),bend:Z(t,"bend"),...Fe("surprised"),...xt("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":Z(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":Z(t,"head.nod")-10,bend:Z(t,"bend")-10,lift:.05,stretch:1.18,...Fe("shocked"),lookX:1,lookY:0},easing:"ease-out-cubic"},{after:1360,pose:{lift:0,stretch:.88,"head.nod":Z(t,"head.nod")-4,bend:Z(t,"bend")+4},easing:"ease-in-quad"},{after:1560,pose:{stretch:Z(t,"stretch"),"head.nod":Z(t,"head.nod"),bend:Z(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,...Fe("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,...xt("arm",{spread:75}),...xt("leg",{swing:25,knee:50})},easing:"ease-in-quad"},{after:300,pose:{stretch:1.05,bend:-4,"arm.left.spread":Z(t,"arm.left.spread"),"arm.right.spread":Z(t,"arm.right.spread")},easing:"ease-out"},{after:460,pose:{lift:0,stretch:Z(t,"stretch"),bend:Z(t,"bend"),...xt("leg",{swing:0,knee:0})},easing:"ease-in-out"}],tremble:t=>{const e=[{after:80,pose:{...Fe("scared"),...xt("arm",{swing:40,elbow:110,spread:14}),stretch:.94,bend:Z(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:Z(t,"side")+2.5*i,"head.tilt":Z(t,"head.tilt")-2*i}})}return e.push({after:755,pose:{side:Z(t,"side"),"head.tilt":Z(t,"head.tilt"),bend:Z(t,"bend")}}),e},deflate:t=>[{after:260,pose:{stretch:1.04,"head.nod":Z(t,"head.nod")-4,"brow.left":.3,"brow.right":.3},easing:"ease-in-out"},{after:900,pose:{...Fe("sad"),bend:18,stretch:.92,lean:Z(t,"lean")+5,"head.nod":14,...xt("arm",{spread:6,swing:0,elbow:4,bend:0})},easing:"ease-in-out"}]};function _g(t,e){const n=At(e.from??{}),i=e.speed??1;let s=n;return[{time:e.at,pose:n},...po[t](n).map(o=>(s={...s,...o.pose},{time:e.at+o.after*i,pose:s,act:!1,...o.easing?{easing:o.easing}:{}}))]}const Ig=(t,e,n)=>t.slice(Math.floor((t.length-1)*e),Math.ceil((t.length-1)*n)+1);function Hg(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(an(h,a.height*.08,a.height*.05),n,i(a))},o=(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(an([f,...a.parts.spine.points],a.height*.15,a.height*.14),e,i(a))},r=(a,l,c)=>{const h=a.parts[`arm.${c}`].points,u=h[0],f=a.chains.spine[a.chains.spine.length-1],g=[{x:u.x+(f.x-u.x)*.45,y:u.y+(f.y-u.y)*.45},...Ig(h,0,.45)],p=an(g,a.height*.085,a.height*.06),m=g.length,y=p.slice(0,m),w=p.slice(m).reverse();l.shape(p,e,0);const k=S=>Math.hypot(S[1].x-f.x,S[1].y-f.y),[E,T]=k(y)>k(w)?[y,w]:[w,y];l.line(E.slice(1),i(a)),l.line(T.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 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 Mc(t){if(t===void 0)return wn.full;if(typeof t=="string")return wn[t];const{base:e,...n}=t;return{...wn[e??"full"],...n}}const go=160,Cg=120,Og=700,mo=60,Rg=90,Ei=3200,De=1,pe=1e-6;function yo(t,e,n={}){const i=Mc(n.style),s=n.seed??1,o={};if(t.length===0)return o;const r=Object.keys(t[0].pose).filter(u=>t.some(f=>Math.abs(f.pose[u]-t[0].pose[u])>pe));for(const u of r)o[u]=Lg(u,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 u=Fg(t,e,i,s,t[0].pose[a]);u.length>0&&(o[a]=u)}const{lift:c,stretch:h}=e;if(i.jumpSquash>0&&c&&h&&r.includes(c)&&!r.includes(h)&&h in t[0].pose){const u=Dg(t,c,t[0].pose[h],i.jumpSquash);u.length>0&&(o[h]=u)}return o}function Lg(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=d=>{const g=(e[d].time-e[d-1].time)/2;return Math.max(-g,Math.min(g,l))},h=[{time:e[0].time,value:e[0].pose[t]}],u=(d,g,p)=>{const m=h[h.length-1];if(d<=m.time+De){h[h.length-1]={...m,value:g,...p?{easing:p}:{}};return}h.push({time:d,value:g,...p?{easing:p}:{}})};let f=e[0].pose[t];for(let d=1;d<e.length;d++){const g=e[d],p=e[d-1].pose[t],m=g.pose[t],y=m-p,w=h[h.length-1].time,k=g.act!==!1;if(Math.abs(y)<=pe){const I=g.time+(k?c(d):0);if(d===e.length-1)Math.abs(f-m)>pe&&u(Math.max(I,w+go),m,"ease-in-out"),f=m;else if(k&&a&&i.drift>0&&n.drift.includes(t)&&I-w>=Og){const R=Ee(`${s}:${t}:${d}`)%2===0?1:-1;f=m+R*i.drift*r,u(I,f,"ease-in-out")}continue}if(!k){u(e[d-1].time,f),u(g.time,m,g.easing),f=m;continue}const E=c(d),T=Math.max(e[d-1].time+E,w);let S=g.time+E;o&&i.eyeDart>0&&(S=Math.min(S,T+i.eyeDart));const P=S-T;if(P<=De){u(g.time,m,g.easing),f=m;continue}u(T,f);const O=Math.sign(y);if(a&&i.anticipation>0&&r>0&&P>=go){const I=f-O*Math.min(Math.abs(y)*i.anticipation,r),R=T+P*i.anticipationTime;u(R,I,"ease-in-out"),i.hold>0&&u(R+P*i.hold,I)}const A=d+1<e.length?e[d+1].time-g.time:1/0,C=Math.min(i.settle,A/2);if(a&&i.overshoot>0&&r>0&&P>=Cg&&C>De){const I=Math.min(Math.abs(y)*i.overshoot,r);u(S,m+O*I,g.easing??i.actionEase),u(S+C,m,i.settleEase)}else u(S,m,g.easing??i.actionEase);f=m}return h}function Fg(t,e,n,i,s){const o=[],r=mo+Rg;for(let d=1;d<t.length;d++){const g=t[d-1].pose,p=t[d].pose;Object.entries(e.headTurns).some(([y,w])=>Math.abs((p[y]??0)-(g[y]??0))>w)&&t[d].act!==!1&&o.push(Math.max(t[0].time,t[d-1].time-n.eyeLead))}const a=t[0].time,l=t[t.length-1].time,c=[...o];let h=a+Ei*.6,u=0;for(;h<l;){c.some(p=>Math.abs(p-h)<Ei/2)||o.push(h);const g=(Ee(`${i}:blink:${u++}`)%1e3/1e3-.5)*(Ei*.66);h+=Ei+g}o.sort((d,g)=>d-g);const f=[{time:a,value:s}];for(const d of o){const g=f[f.length-1].time;d+mo<=g+De||(d>g+De&&f.push({time:d,value:s}),f.push({time:d+mo,value:1,easing:"ease-in"}),f.push({time:d+r,value:s,easing:"ease-out"}))}return f.length>1?f:[]}function Dg(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 u=r[r.length-1];l<=u.time+De||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],u=t[l-1].time,f=t[l].time,d=f-u;if(!(d<go||t[l].act===!1)){if(c<=pe&&h>pe)a(u,n),a(u+d*.2,s,"ease-out"),a(u+d*.45,o,"ease-out"),a(f,n,"ease-in-out");else if(c>pe&&h<=pe){const g=l+1<t.length?t[l+1].time-f:400;a(u+d*.5,n),a(f-Math.min(60,d*.15),o,"ease-in"),a(f,s,"ease-out"),a(f+Math.min(260,g/2),n,{type:"back",mode:"out",overshoot:1.4})}}}return r.length>1?r:[]}const Tc={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 Ng(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 Bg(){const t={},e={};for(const n of Object.keys(ut)){const i=Ng(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 Ec=Bg();function Ac(t,e){return Object.entries(e).map(([n,i])=>({id:`${t}-${n}`,target:t,property:n,keyframes:i}))}function xc(t,e,n={}){const i=Ws(e),s=e.map((o,r)=>({time:o.time,pose:{...i[r]},easing:o.easing,act:o.act}));return Ac(t,yo(s,n.rig??Tc,n))}function Wg(t,e,n={}){const i=n.rest??ut,s=lo(e,i),o=e.map((r,a)=>({time:r.time,pose:{...i,...s[a]},easing:r.easing,act:r.act}));return Ac(t,yo(o,n.rig??Ec,n))}const Pc=ot.shocked,Kg=ot.scared,ie={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,...Pc,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,...ot.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,...Pc,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,...ot.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:V.leftHip,rightHip:V.rightHip,leftKnee:0,rightKnee:0},easing:"ease-in-out"}],tremble:t=>{const e=[{after:80,pose:{...Kg,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:{...Dt.sad,bend:18,stretch:.92,lean:t.lean+5,turn:t.turn,sit:t.sit},easing:"ease-in-out"}]};function bo(t,e){const n=typeof e.from=="string"?Dt[e.from]:e.from??V,i=e.speed??1;let s=n;return[{time:e.at,pose:n},...ie[t](n).map(o=>(s={...s,...o.pose},{time:e.at+o.after*i,pose:s,act:!1,...o.easing?{easing:o.easing}:{}}))]}function kn(t,e=1){const n=ie[t](V);return n[n.length-1].after*e}function $c(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 u=e[h-1],f=e[h],d=f.x-u.x,g=f.y-u.y,p=Math.hypot(d,g)||1,m=-g/p,y=d/p,w=1-h/(e.length-1);t.globalAlpha=r*(1-w),t.lineWidth=o*(1-w*.7),t.beginPath(),t.moveTo(u.x+m*l,u.y+y*l),t.lineTo(f.x+m*l,f.y+y*l),t.stroke()}}t.restore()}const Yg={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 jg(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 d=0;d<a;d++){const g=l+(n.time-l)*d/(a-1);c.push(Bs(e,{time:g,state:o(g)},i).joints)}const h=c[c.length-1].height,u=(s.threshold??1.2)*h,f=(s.parts??["hands","toes","head"]).flatMap(d=>Yg[d]);for(const d of f){const g=c.map(d.at);let p=0;for(let w=1;w<g.length;w++)p+=Math.hypot(g[w].x-g[w-1].x,g[w].y-g[w-1].y);const m=p/((n.time-l)/1e3);if(m<=u)continue;const y=Math.min(1,(m-u)/(u*.5));$c(t,g,{...s,opacity:(s.opacity??.7)*y,spacing:s.spacing??h*.02})}}function Xg(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=Ee(`${o}:puff:${a}`)%1e3/1e3,c=a-2,h=e.x+c*s*.3*r,u=e.y-s*(.06+.12*l)*r+Math.abs(c)*s*.03,f=s*(.11+.07*l)*r;t.beginPath(),t.arc(h,u,f,Math.PI*.95,Math.PI*2.05),t.stroke()}t.restore()}function qg(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,u=e.y+Math.sin(l)*c;Ug(t,h,u,s*.14,n*Math.PI+a),t.stroke()}t.restore()}function Ug(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 se={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}},vn=1,Ai=.55,_c=.35,Vg=1.6,Ic={a:"a",e:"e",i:"i",y:"i",o:"o",u:"u"},Hc={m:"m",b:"m",p:"m",f:"f",v:"f",w:"u",q:"u",l:"l",n:"l",d:"l",t:"l"},Cc={अ:"a",आ:"a",इ:"i",ई:"i",उ:"u",ऊ:"u",ऋ:"i",ए:"e",ऐ:"e",ओ:"o",औ:"o",ऍ:"e",ऑ:"o"},Oc={"ा":"a","ि":"i","ी":"i","ु":"u","ू":"u","ृ":"i","े":"e","ै":"e","ो":"o","ौ":"o","ॅ":"e","ॉ":"o"},Gg={प:"m",फ:"m",ब:"m",भ:"m",म:"m",व:"u"},zg="्",Rc="़",Jg=t=>t>="क"&&t<="ह",Lc=new Set([".",",","!","?",";",":","…","।","॥","—","-"]);function Fc(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(Lc.has(o))i("rest",Vg);else if(/\s/.test(o)){const a=e[e.length-1];a&&a.viseme!=="rest"&&e.push({viseme:"c",weight:_c})}else if((o==="o"||o==="e")&&r===o)i(o==="o"?"u":"i",vn),s++;else if(o in Ic)i(Ic[o],vn);else if(o in Hc)i(Hc[o],Ai);else{if(o==="h")continue;if(/[a-z]/.test(o))i("c",Ai);else if(o in Cc)i(Cc[o],vn);else if(Jg(o)){const a=r===Rc?o==="फ"?"f":void 0:Gg[o];i(a??"c",Ai);let l=s+1;n[l]===Rc&&l++;const c=n[l];c===zg?s=l:c&&c in Oc?(i(Oc[c],vn),s=l):(!c||/\s/.test(c)||Lc.has(c)||i("a",vn*.6),s=l-1)}else(o==="ं"||o==="ँ")&&i("l",Ai*.6)}}for(;e.length>0&&(e[e.length-1].viseme==="rest"||e[e.length-1].weight===_c);)e.pop();return e}function wo(t,e={}){const n=e.fields?.mouth??"mouth",i=e.fields?.mouthWidth??"mouthWidth",s=e.energy??1,o=Fc(t.text),r=[{time:t.start,value:se.rest.mouth}],a=[{time:t.start,value:se.rest.mouthWidth}],l=o.reduce((h,u)=>h+u.weight,0),c=t.end-t.start;if(l>0&&c>0){let h=t.start;for(const u of o){const f=c*u.weight/l,d=h+Math.min(f*.4,60);if(d>r[r.length-1].time){const g=se[u.viseme];r.push({time:d,value:g.mouth*s,easing:"ease-out"}),a.push({time:d,value:1+(g.mouthWidth-1)*Math.min(1.3,s),easing:"ease-out"})}h+=f}}return t.end>r[r.length-1].time&&(r.push({time:t.end,value:se.rest.mouth,easing:"ease-in-out"}),a.push({time:t.end,value:se.rest.mouthWidth,easing:"ease-in-out"})),{[n]:r,[i]:a}}function Zg(t,e,n={}){const i={};for(const s of[...e].sort((o,r)=>o.start-r.start))for(const[o,r]of Object.entries(wo(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 Dc(t,e,n,i={}){if(n.length===0)return e;const s=i.fields?.mouth??"mouth",o=i.fields?.mouthWidth??"mouthWidth",r={[s]:se.rest.mouth,[o]:se.rest.mouthWidth,...i.rest},a=new ae({id:"before-speech",tracks:e}),l=(u,f)=>a.getStateAtTime(f).values.get(t)?.get(u)??r[u],c=[s,o],h=e.filter(u=>u.target!==t||!c.includes(u.property));for(const u of c){const f=e.find(g=>g.target===t&&g.property===u);let d=f?[...f.keyframes]:[{time:0,value:l(u,0)}];for(const g of n){const p=wo(g,i)[u];p[0]={...p[0],value:l(u,g.start)},p[p.length-1]={...p[p.length-1],value:l(u,g.end)},d=[...d.filter(m=>m.time<g.start||m.time>g.end),...p],d.sort((m,y)=>m.time-y.time)}h.push({id:f?.id??`${t}-${u}`,target:t,property:u,keyframes:d})}return h}const Sn={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 the rest pose, keeping the way it is turned."},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 Nc(){return[...Object.keys(_t),...Object.keys(Dt),...Object.keys(ie),...Object.keys(Sn)]}function Bc(){const t={};for(const e of Object.keys(_t))t[e]=`Walks to \`to\` in the ${e} gait, feet planted, turning round first if needed.`;for(const e of Object.keys(Dt))t[e]=`Moves into the ${e} pose and holds it.`;for(const e of Object.keys(ie))t[e]=`The ${e} gag, built on the current pose.`;for(const[e,n]of Object.entries(Sn))t[e]=n.summary;return t}const xi=["do","at","for","to","toward","mood","say","pose","target","onto"],Qg={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"},Pi=["viewer","ahead","back"],ge=t=>typeof t=="number"&&Number.isFinite(t);function Wc(t){const e=[];if(!Array.isArray(t))return[{level:"error",beat:-1,message:`Beats must be an array of { do: … } objects (got ${typeof t}).`}];const n=Nc(),i=Object.keys(ot),s=Object.keys(V);let o=-1/0;return t.forEach((r,a)=>{const l=d=>e.push({level:"error",beat:a,message:d}),c=d=>e.push({level:"warning",beat:a,message:d});if(!r||typeof r!="object"||Array.isArray(r)){l(`Each beat must be an object like { do: 'walk', to: 400 } (got ${JSON.stringify(r)}).`);return}const h=r;for(const d of Object.keys(h))xi.includes(d)||l(Bt("beat field",d,xi,Qg[d.toLowerCase()]));const u=h.do;if(u===void 0){l(`A beat needs \`do\` (what happens). Actions: ${n.join(", ")}`);return}if(typeof u!="string"||!n.includes(u)){l(Bt("action",u,n));return}const f=Sn[u];for(const d of f?.needs??[])h[d]===void 0&&l(`\`${u}\` needs \`${d}\`.`);if(u in _t&&h.to===void 0&&c(`\`${u}\` without \`to\` walks nowhere.`),u==="leap"&&h.to===void 0&&h.onto===void 0&&c("`leap` without `to` or `onto` jumps on the spot."),h.mood!==void 0&&(typeof h.mood!="string"||!i.includes(h.mood))&&l(Bt("mood",h.mood,i)),h.pose!==void 0)if(!h.pose||typeof h.pose!="object"||Array.isArray(h.pose))l("`pose` is joints to change, an object like { rightShoulder: 90 } (for a named pose, use it as the action).");else for(const[d,g]of Object.entries(h.pose))s.includes(d)?ge(g)||l(`Pose joint \`${d}\` must be a number (got ${JSON.stringify(g)}).`):l(Bt("pose joint",d,s));for(const d of["at","for"]){const g=h[d];g!==void 0&&!(ge(g)&&g>=0)&&l(`\`${d}\` is milliseconds, a number ≥ 0 (got ${JSON.stringify(g)}).`)}ge(h.at)&&(h.at<o&&c(`\`at\` ${h.at} is before an earlier beat's \`at\` (${o}); beats run in order, so it starts when the one before ends.`),o=h.at);for(const d of["to","onto"]){const g=h[d];g!==void 0&&!ge(g)&&l(`\`${d}\` is a scene ${d==="to"?"x":"y"} in px, a number (got ${JSON.stringify(g)}).`)}if(h.toward!==void 0&&!ge(h.toward)&&!Pi.includes(h.toward)&&l(`\`toward\` is a scene x or one of ${Pi.join(", ")}${typeof h.toward=="string"&&Dn(h.toward,Pi)?` (did you mean "${Dn(h.toward,Pi)}"?)`:""} (got ${JSON.stringify(h.toward)}).`),h.say!==void 0&&typeof h.say!="string"&&l(`\`say\` is the line spoken, a string (got ${JSON.stringify(h.say)}).`),h.target!==void 0){const d=h.target;(!d||typeof d!="object"||!ge(d.x)||!ge(d.y))&&l("`target` is a point or box in scene px: { x, y } (a code panel’s line(), token() or spot() fits).")}}),e}function Kc(t){const e=Wc(t).filter(n=>n.level==="error");if(e.length!==0)throw new Error(`scriptTracks: ${e.length} problem(s) in the beats:
|
|
55
|
+
${e.map(n=>` beat ${n.beat}: ${n.message}`).join(`
|
|
56
|
+
`)}`)}Rd(Bc);const ko={walk:1e3,bouncy:900,doubleBounce:1100,sneak:1600,strut:1100,tired:1500,shove:1300,run:560},tm=450,em=2.4,nm=160,Yc=2.5,im=200,sm=340,om=1.1,jc=[380,900],rm=.35,$i=300,vo=150,am=260,lm=1.2,So=160,Xc=400,Mn=300,cm=450,qc=500,Mo=350,Uc=150,hm=120,To=180,Vc=420,um=300,Gc=300,fm=140,Eo=150,zc=450,dm=450,Ao=150,Jc=350,Zc=400,pm=12,gm=600,Qc=90,th=400,mm=200,ym=.09,eh=350,Yt=450,xo=1200,bm=700,Ne=320,jt=220,wm=65,km=700,Po=t=>t in _t,nh=t=>t in ie,vm=t=>t in Dt;function ih(t){return Math.max(km,Array.from(t).length*wm)}function Sm(t,e,n={}){Kc(e);const i=n.from??0,s=n.ground??0,o=n.height??300;let r=i,a=s,l=n.facing??1,c=n.start??V,h=0,u=0;const f=[{time:0,pose:c}],d=[{time:0,value:0}],g=[{time:0,value:0}],p=[{time:0,value:0}],m=[{time:0,value:0}],y=[{time:0,value:"walk"}],w=[{time:0,value:l}],k=[],E=[],T=[],S=($,L,W,j)=>{c={...c,...L},W&&(c=Ce(c,W)),f.push({time:$,pose:c,...j===!1?{act:j}:{}})},P=($,L,W)=>(S($+Ne/2,{turn:0},W),w.push({time:$+Ne/2,value:l},{time:$+Ne/2+1,value:L}),l=L,S($+Ne,{turn:1}),$+Ne),O=$=>$<r?-1:1,A=($,L,W)=>O(L)!==l?P($,O(L),W):$,C=($,L,W,j="arm")=>{const v=j==="arm",x=Qt({...$,...v?{rightShoulder:0,rightElbow:0}:{rightHip:0,rightKnee:0}},{height:o,facing:l}),M=v?x.shoulders.right:x.hip,_=v?x.elbows.right:x.knees.right,H=(B,Y)=>Math.atan2(l*B,Y)*180/Math.PI,K=((H(L-(r+M.x),W-(a+M.y))-H(_.x-M.x,_.y-M.y))%360+360)%360;return K>270?K-360:K},I=($,L,W,j)=>{const v=j==="arm",x=Qt({...$,...v?{rightShoulder:90,rightElbow:0,rightWrist:0}:{rightHip:90,rightKnee:0}},{height:o,facing:l}),M=v?x.shoulders.right:x.hip,_=v?{x:(x.hands.right.x+x.fingertips.right.x)/2,y:(x.hands.right.y+x.fingertips.right.y)/2}:x.feet.right,H=Math.hypot(_.x-M.x,_.y-M.y),D=W-(a+M.y),K=Math.abs(D)<H?Math.sqrt(H*H-D*D):H*.1;return L-M.x-l*K},R=$=>{const L=Qt($,{height:o,facing:l});return{x:r+(L.hands.right.x+L.fingertips.right.x)/2,y:a+(L.hands.right.y+L.fingertips.right.y)/2}},F=($,L,W)=>{const j={...$,rightWrist:0,rightElbow:0,rightShoulder:C($,L,W)},v=Qt(j,{height:o,facing:l}),x={x:r+v.shoulders.right.x,y:a+v.shoulders.right.y},M={x:r+v.elbows.right.x,y:a+v.elbows.right.y},_=R(j),H=Math.hypot(M.x-x.x,M.y-x.y),D=Math.hypot(_.x-M.x,_.y-M.y),K=Math.min(H+D-.01,Math.max(Math.abs(H-D)+.01,Math.hypot(L-x.x,W-x.y))),B=nt=>nt*180/Math.PI,Y=B(Math.acos((H*H+K*K-D*D)/(2*H*K))),J=180-B(Math.acos((H*H+D*D-K*K)/(2*H*D)));let et={rightShoulder:j.rightShoulder,rightElbow:0},Q=1/0;for(const nt of[1,-1])for(const U of[1,-1]){const pt={rightShoulder:j.rightShoulder+nt*Y,rightElbow:U*J},gt={...$,rightWrist:0,...pt},wt=R(gt),Pt=Math.hypot(wt.x-L,wt.y-W)-Qt(gt,{height:o,facing:l}).elbows.right.y*.001;Pt<Q&&(Q=Pt,et=pt)}return et},N=($,L,W)=>Math.abs(L-r)<2?$:(d.push({time:$,value:r-i},{time:$+W,value:L-i,easing:"ease-in-out"}),r=L,$+W);for(const $ of e){const L=Math.max($.at??u,u===0?0:f[f.length-1].time);let W=L,j,v;const x=$.pose??{};if(Po($.do)){const M=$.to??r,_=M===r?l:O(M);let H=L;_!==l?H=P(L,_,$.mood):c.turn<1?(H=L+jt,S(H,{turn:1,...x},$.mood)):($.mood||$.pose)&&S(L+jt,x,$.mood);const K=Math.abs(M-r)/Rs($.do,o),B=$.for??Math.max(jt*2,K*ko[$.do]),Y=H+B;y.push({time:H,value:$.do}),m.push({time:H,value:0},{time:H+jt,value:1,easing:"ease-out"}),m.push({time:Y-jt,value:1},{time:Y,value:0,easing:"ease-in"}),p.push({time:H,value:h},{time:Y,value:h+K}),d.push({time:H,value:r-i},{time:Y,value:M-i}),h+=K,r=M,S(Y,{}),W=Y}else if($.do==="zip"){const M=$.to??r,_=M===r?l:O(M);let H=L;_!==l?H=P(L,_,$.mood):c.turn<1&&(H=L+jt,S(H,{turn:1},$.mood));const D=bo("windUp",{at:H,from:$.mood?Ce(c,$.mood):c});f.push(...D),c=D[D.length-1].pose;const K=H+kn("windUp"),B=K+tm,Y=B+Math.max(nm,Math.abs(M-r)/em);y.push({time:K,value:"run"}),m.push({time:K,value:0},{time:K+80,value:1,easing:"ease-out"},{time:Y,value:1},{time:Y+120,value:0}),p.push({time:K,value:h},{time:B,value:h+Yc,easing:"ease-in"}),h+=Yc+(Y-B)/ko.run*1.5,p.push({time:Y,value:h}),d.push({time:B,value:r-i},{time:Y,value:M-i,easing:"ease-in"}),T.push({kind:"dust",time:B,x:r,y:a,length:900}),r=M,S(Y,{}),W=Y}else if($.do==="leap"){const M=$.to??r,_=$.onto??a;let H=M===r?L:A(L,M,$.mood);c.turn<1&&(H+=jt,S(H,{turn:1},$.mood));const D={leftShoulder:35,rightShoulder:35,leftElbow:-50,rightElbow:-50};S(H+im,{stretch:.75,bend:12,leftHip:22,rightHip:22,...D},$.mood,!1);const K=H+sm;S(K-40,{stretch:.72},void 0,!1),S(K,{stretch:1.2,bend:-6,leftShoulder:140,rightShoulder:140,leftElbow:20,rightElbow:20,leftHip:4,rightHip:4},void 0,!1);const B=Math.hypot(M-r,_-a),Y=$.for??Math.min(jc[1],Math.max(jc[0],300+B*om)),J=Math.min(a,_)-rm*o,et=Math.sqrt(a-J),Q=Math.sqrt(_-J),nt=K+Y*et/(et+Q),U=K+Y;S(nt,{stretch:1,bend:4,leftHip:-55,leftKnee:-80,rightHip:55,rightKnee:80,leftShoulder:110,rightShoulder:110},void 0,!1),S(U,{stretch:.72,bend:12,leftShoulder:75,rightShoulder:75,leftElbow:0,rightElbow:0,leftHip:18,rightHip:18,leftKnee:0,rightKnee:0},void 0,!1),S(U+180,{stretch:1.05,bend:-3},void 0,!1),S(U+340,{stretch:1,bend:0,leftHip:V.leftHip,rightHip:V.rightHip,leftShoulder:V.leftShoulder,rightShoulder:V.rightShoulder,leftElbow:V.leftElbow,rightElbow:V.rightElbow},void 0,!1),d.push({time:K,value:r-i},{time:U,value:M-i}),g.push({time:K,value:a-s},{time:nt,value:J-s,easing:"ease-out-quad"},{time:U,value:_-s,easing:"ease-in-quad"}),r=M,a=_,T.push({kind:"dust",time:U,x:r,y:a,length:500}),W=U+340,j=U}else if($.do==="point"&&$.target){const M=$.target,_=A(L,M.x,$.mood),H={...c,...$.mood?ot[$.mood]:{},turn:Math.max(c.turn,.6),rightElbow:0,rightWrist:0,...x},D=Qt(H,{height:o,facing:l}).head.center,K=Math.abs(M.x-(r+D.x)),B=M.y-(a+D.y),Y=_+Yt;S(Y,{...H,rightShoulder:C(H,M.x,M.y),lookX:1,lookY:Mm(B/Math.max(1,Math.hypot(K,B)))*.8}),W=Y+($.for??xo),j=Y,v=W}else if($.do==="swipe"){const M=$.target??{x:r+l*o*.5,y:a-o*.6},_=O(M.x),H=A(L,M.x,$.mood),D=_===1?M.left??M.x:M.right??M.x,K=_===1?M.right??M.x:M.left??M.x,B={...c,turn:1,lean:-10,bend:-8,rightElbow:40,lookX:1,...x};S(H+$i,{...B,rightShoulder:C(B,r-l*o*.3,a-o*1.1)},$.mood,!1);const Y={...c,lean:6,bend:4,rightElbow:0,rightWrist:0},J={...c,lean:14,bend:12,rightElbow:0,rightWrist:0};N(H,I(Y,D,M.y,"arm"),$i+vo),S(H+$i+vo,{lean:-12},void 0,!1);const et=H+$i+vo+80;S(et,{...Y,rightShoulder:C(Y,D,M.y)},void 0,!1);const Q=et+($.for??Math.max(am,Math.abs(K-D)/lm));d.push({time:et,value:r-i}),r=I(J,K,M.y,"arm"),d.push({time:Q,value:r-i}),S(Q,{...J,rightShoulder:C(J,K,M.y)},void 0,!1),S(Q+So,{lean:16,bend:14,rightShoulder:C(c,K+_*o*.4,M.y+o*.25)},void 0,!1),S(Q+So+Xc,{lean:0,bend:0,rightShoulder:V.rightShoulder,rightElbow:V.rightElbow}),W=Q+So+Xc,j=et,v=Q}else if($.do==="grab"&&$.target){const M=$.target,_=A(L,M.x,$.mood),H=M.y>a-o*.5,D={...c,turn:1,rightElbow:0,bend:H?35:0,lean:H?12:0,stretch:H?.75:1,lookX:1,lookY:H?.8:0,...x},B=N(_,I(D,M.x,M.y,"arm"),Mn)+cm;S(B,{...D,rightShoulder:C(D,M.x,M.y)},$.mood,!1),S(B+120,{},void 0,!1),S(B+qc,{bend:0,lean:-3,stretch:1,rightShoulder:165,rightElbow:20,lookY:-.6}),W=B+qc+150,j=B}else if($.do==="throw"){const M=$.target?.x??$.to??r+l*o,_=A(L,M,$.mood),H={...c,turn:1,lean:-12,bend:-10,rightElbow:60,stretch:.95,lookX:1,lookY:-.3,...x};S(_+Mo,{...H,rightShoulder:C(H,r-l*o*.4,a-o*1.05)},$.mood,!1),S(_+Mo+Uc,{lean:-14},void 0,!1);const D=_+Mo+Uc+hm,K={...c,lean:14,bend:12,rightElbow:0,stretch:1.04};f.push({time:D,pose:c={...K,rightShoulder:C(K,r+l*o,a-o*1.1)},easing:"ease-in",act:!1}),S(D+To,{lean:18,bend:14,rightShoulder:55,stretch:1},void 0,!1),S(D+To+Vc,{lean:0,bend:0,rightShoulder:V.rightShoulder,rightElbow:V.rightElbow,lookY:0}),W=D+To+Vc,j=D,v=D}else if($.do==="kick"&&$.target){const M=$.target,_=A(L,M.x,$.mood),H={...c,turn:1,lean:-12,bend:-6,rightKnee:0,leftShoulder:100,rightShoulder:70},D=N(_,I(H,M.x,M.y,"leg"),um),K={leftShoulder:70,rightShoulder:50,leftElbow:-20,rightElbow:20};S(D+Gc,{turn:1,lean:8,bend:6,rightHip:-40,rightKnee:80,lookX:1,lookY:.7,...K,...x},$.mood,!1);const B=D+Gc+fm,Y=C(H,M.x,M.y,"leg");f.push({time:B,pose:c={...c,...H,rightHip:Y},easing:"ease-in",act:!1}),S(B+Eo,{lean:-15,rightHip:Y+20},void 0,!1),S(B+Eo+zc,{lean:0,bend:0,rightHip:V.rightHip,rightKnee:0,leftShoulder:V.leftShoulder,rightShoulder:V.rightShoulder,leftElbow:V.leftElbow,rightElbow:V.rightElbow,lookY:0}),W=B+Eo+zc,j=B}else if($.do==="put"&&$.target){const M=$.target,_=A(L,M.x,$.mood),H=M.y>a-o*.5,D={...c,turn:1,rightElbow:0,rightWrist:0,bend:H?35:0,lean:H?12:0,stretch:H?.75:1,lookX:1,lookY:H?.8:0,...x},B=N(_,I(D,M.x,M.y,"arm"),Mn)+dm;S(B,{...D,rightShoulder:C(D,M.x,M.y)},$.mood,!1),S(B+Ao,{},void 0,!1),S(B+Ao+Jc,{bend:0,lean:0,stretch:1,rightShoulder:V.rightShoulder,rightElbow:V.rightElbow,lookY:0}),W=B+Ao+Jc,j=B}else if($.do==="write"&&$.target){const M=$.target,_=M.left??M.x,H=M.right??M.x,D=A(L,(_+H)/2,$.mood),K={...c,turn:1,rightElbow:0,rightWrist:0,...ot.thinking,lookX:1,lookY:0,...x},B=gt=>I(K,gt,M.y,"arm")+l*o*.08,Y=gt=>{const wt=R({...K,...F(K,gt,M.y),rightWrist:0});return Math.hypot(wt.x-gt,wt.y-M.y)<2},J=l===1?_:H,et=N(D,B((_+H)/2),Mn),Q=!Y(_)||!Y(H),nt=Q?N(et,B(_),Mn)+Zc:et+Zc;S(nt,{...K,...F(K,Q?_:J,M.y)},$.mood,!1);const U=$.for??Math.max(gm,Math.abs(H-_)*pm);Q&&d.push({time:nt,value:r-i});for(let gt=Qc,wt=0;gt<=U;gt+=Qc,wt++){const oe=_+(H-_)*Math.min(gt,U)/U;Q&&(r=B(oe),d.push({time:nt+gt,value:r-i}));const Pt=(wt%2===0?-1:1)*o*.02;S(nt+gt,F(K,oe,M.y+Pt),void 0,!1)}const pt=nt+U;S(pt,F(K,H,M.y),void 0,!1),S(pt+th,{rightShoulder:V.rightShoulder,rightElbow:V.rightElbow,...ot.happy}),W=pt+th,j=nt,v=pt}else if($.do==="push"&&$.target){const M=$.target,_=$.to??M.x,H=A(L,r+(_>=M.x?1:-1),$.mood),D=l===1?M.left??M.x:M.right??M.x,K={...c,turn:1,lean:16,bend:8,rightWrist:0,leftWrist:0,lookX:1,...x},B=I(K,D,M.y,"arm"),Y=N(H,B+l*o*.06,Mn),J=F(K,D,M.y),et={...K,...J,leftShoulder:-J.rightShoulder,leftElbow:-J.rightElbow},Q=Y+mm;S(Q,et,$.mood,!1);const nt=Math.abs(_-M.x),U=Q+($.for??Math.max(600,nt/ym)),pt=nt/Rs("shove",o);y.push({time:Q,value:"shove"}),m.push({time:Q,value:0},{time:Q+jt,value:1,easing:"ease-out"},{time:U-jt,value:1},{time:U,value:0,easing:"ease-in"}),p.push({time:Q,value:h},{time:U,value:h+pt}),h+=pt,d.push({time:Q,value:r-i},{time:U,value:r+(_-M.x)-i}),r+=_-M.x,S(U,{},void 0,!1),S(U+eh,{lean:0,bend:0,rightShoulder:V.rightShoulder,leftShoulder:V.leftShoulder,rightElbow:V.rightElbow,leftElbow:V.leftElbow}),W=U+eh,j=Q,v=U}else if(nh($.do)){const M=bo($.do,{at:L,from:$.mood?Ce(c,$.mood):c});f.push(...M),c=M[M.length-1].pose,W=L+kn($.do),$.do==="take"&&T.push({kind:"dust",time:L+900,x:r,y:a,length:500}),$.do==="land"&&T.push({kind:"dust",time:L+120,x:r,y:a,length:500})}else if($.do==="look"||$.do==="face"){const M=$.toward??"viewer",_=$.for??bm;if(M==="viewer")S(L+Yt,{turn:0,lookX:0,lookY:0,...x},$.mood);else if(M==="ahead")S(L+Yt,{turn:$.do==="face"?1:.6,lookX:1,...x},$.mood);else if(M==="back")S(L+Yt,{turn:.2,lookX:-1,...x},$.mood);else{const H=O(M);H!==l&&$.do==="face"?(P(L,H,$.mood),S(L+Ne+1,{lookX:1,...x})):H!==l?S(L+Yt,{turn:.25,lookX:-1,...x},$.mood):S(L+Yt,{turn:$.do==="face"?1:.6,lookX:1,...x},$.mood)}W=L+Math.max(_,Yt)}else if(vm($.do)||$.do==="stand"){const M=$.do==="stand"?V:Dt[$.do],_=M.turn!==V.turn?M.turn:c.turn,H=$.mood?ot[$.mood]:{lookX:c.lookX,lookY:c.lookY};S(L+Yt,{...M,turn:_,...H,...x}),W=L+($.for??xo)}else{const M=$.for??($.say?ih($.say):xo);($.mood||$.pose)&&S(L+Math.min(Yt,M/2),x,$.mood),W=L+M}if($.say){const M=Po($.do)||nh($.do)?L:L+Math.min(150,(W-L)/4),_=Po($.do)?W:Math.max(M+200,W-100);k.push({text:$.say,start:M,end:_}),$.do==="say"&&Am(f,c,M,_)}$.onto!==void 0&&$.do!=="leap"&&$.onto!==a&&(g.push({time:L,value:a-s},{time:W,value:$.onto-s,easing:"ease-in-out"}),a=$.onto),W>f[f.length-1].time&&f.push({time:W,pose:c}),E.push({start:L,end:W,...j!==void 0?{contact:j}:{},...v!==void 0?{release:v}:{}}),u=W}const X=xc(t,Em(f),n),G=[{id:`${t}-x`,target:t,property:"x",keyframes:d},{id:`${t}-y`,target:t,property:"y",keyframes:g},{id:`${t}-walk`,target:t,property:"walk",keyframes:p},{id:`${t}-walking`,target:t,property:"walking",keyframes:m},{id:`${t}-gait`,target:t,property:"gait",keyframes:y},{id:`${t}-facing`,target:t,property:"facing",keyframes:w}].filter($=>$.keyframes.length>1||$.property==="x");return{tracks:[...Dc(t,X,k,{energy:n.energy}),...G],duration:u,lines:k,keys:f,beats:E,effects:T}}const Mm=t=>Math.max(-1,Math.min(1,t)),Tm=30;function Em(t){const e=[];for(const n of t){const i=e[e.length-1];i&&n.time-i.time<Tm?e[e.length-1]={...n,time:i.time}:e.push(n)}return e}function Am(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 xm(t,e,n){const i=new ae({id:`${t}-hand`,tracks:e.filter(l=>l.target===t)}),s=Nl({x:n.x,y:n.y,style:n.style}),o=n.side??"right",r=n.every??33,a=[];for(let l=n.start;;l=Math.min(n.end,l+r)){const{joints:c}=Bs(s,{time:l,state:i.getStateAtTime(l)},t),h=c.hands[o],u=c.fingertips[o];if(a.push({time:l,x:(h.x+u.x)/2,y:(h.y+u.y)/2}),l>=n.end)break}return a}const tt=["rect","circle","text","line","path","image","custom"],_i={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:tt},y:{description:"Moves it down by this much from where it was placed (an offset)",unit:"px",types:tt},opacity:{description:"How opaque it is",unit:"0..1",min:0,max:1,types:tt},rotate:{description:"Turns it clockwise about its origin",unit:"degrees",types:tt},rotateX:{description:"Tips it about the horizontal axis (3D; shows with perspective)",unit:"degrees",types:tt},rotateY:{description:"Turns it about the vertical axis (3D; shows with perspective)",unit:"degrees",types:tt},z:{description:"Depth toward the viewer (shows with perspective)",unit:"px",types:tt},perspective:{description:"Distance from the viewer: nearer parts grow, further ones shrink",unit:"px",min:1,types:tt},scale:{description:"Size, both ways",unit:"factor",types:tt},scaleX:{description:"Width factor",unit:"factor",types:tt},scaleY:{description:"Height factor",unit:"factor",types:tt},skewX:{description:"Slants it sideways",unit:"degrees",types:tt},skewY:{description:"Slants it up and down",unit:"degrees",types:tt},originX:{description:"Transform pivot across its box",unit:"% (0 left, 50 centre, 100 right)",min:0,max:100,types:tt},originY:{description:"Transform pivot down its box",unit:"% (0 top, 50 centre, 100 bottom)",min:0,max:100,types:tt},fill:{description:"Fill colour (also written fillStyle)",kind:"color",types:tt},stroke:{description:"Outline colour (also written strokeStyle)",kind:"color",types:tt},strokeWidth:{description:"Outline width (also written lineWidth)",unit:"px",min:0,types:tt},clipTop:{description:"Hides this much from the top edge, for reveals",unit:"% of its height",min:0,max:100,types:tt},clipRight:{description:"Hides this much from the right edge",unit:"% of its width",min:0,max:100,types:tt},clipBottom:{description:"Hides this much from the bottom edge",unit:"% of its height",min:0,max:100,types:tt},clipLeft:{description:"Hides this much from the left edge",unit:"% of its width",min:0,max:100,types:tt},blur:{description:"Gaussian blur",unit:"px",min:0,types:tt},brightness:{description:"Brightness factor (1 unchanged)",unit:"factor",min:0,types:tt},glow:{description:"Soft glow around it, in glowColor",unit:"px",min:0,types:tt},glowColor:{description:"Colour of the glow",kind:"color",types:tt},shadowX:{description:"Drop shadow offset right",unit:"px",types:tt},shadowY:{description:"Drop shadow offset down",unit:"px",types:tt},shadowBlur:{description:"Drop shadow softness",unit:"px",min:0,types:tt},shadowColor:{description:"Drop shadow colour",kind:"color",types:tt},shine:{description:"A highlight sweeping across the fill",unit:"0..1 (progress)",min:0,max:1,types:tt},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:tt},quaternion:{description:'A rotation as [x, y, z, w] (a track with interpolation: "slerp")',kind:"list",types:tt}},$o={fillStyle:"fill",strokeStyle:"stroke",lineWidth:"strokeWidth",rotateZ:"rotate",motionPathX:"x",motionPathY:"y",motionPathRotate:"rotate"},Pm={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 sh(t){const e=t,n=Object.entries(_i).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 oh(t){const e=sh(t).properties.map(n=>n.name);return[...e,...Object.keys($o).filter(n=>e.includes($o[n]))]}function $m(t,e){const n=[],i=Object.keys(e);for(const s of t){const o=f=>n.push({level:"error",track:s.id,message:f}),r=e[s.target];if(!r){o(Bt("target",s.target,i));continue}const a=oh(r),l=r.type==="custom"&&r.acceptsProp?.(s.property);if(!a.includes(s.property)&&!l){o(`${s.target}: ${Bt("property",s.property,a,Pm[s.property])}`);continue}const c=s.keyframes??[];for(let f=1;f<c.length;f++)c[f].time<c[f-1].time&&o(`${s.target}.${s.property}: keyframes out of time order (${c[f-1].time} ms, then ${c[f].time} ms).`);const h=_i[$o[s.property]??s.property]??r.about?.props?.[s.property],u=h&&(h.kind??"number")==="number";for(const f of c){if(u&&typeof f.value!="number"){o(`${s.target}.${s.property}: values are numbers${h.unit?` (${h.unit})`:""} (got ${JSON.stringify(f.value)} at ${f.time} ms).`);break}if(u&&typeof f.value=="number"&&(h.min!==void 0&&f.value<h.min||h.max!==void 0&&f.value>h.max)){n.push({level:"warning",track:s.id,message:`${s.target}.${s.property}: ${f.value} at ${f.time} ms is outside ${h.min??"−∞"}..${h.max??"∞"}${h.unit?` (${h.unit})`:""}.`});break}}}return n}const _m={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 rh(t){const e={};for(const n of Object.keys(_t))e[n]={summary:`Walks to \`to\` in the ${n} gait.`,needs:["to"]};for(const n of Object.keys(Dt))e[n]={summary:`Moves into the ${n} pose and holds it (\`for\` ms).`};for(const n of Object.keys(ie))e[n]={summary:`The ${n} gag (${kn(n)} ms).`};for(const[n,i]of Object.entries(Sn))e[n]={...i};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(_m),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:_i,stickFigure:{poseFields:Za,props:Qa,handFields:tl,poses:Object.keys(Dt),expressions:Object.keys(ot),gags:Object.fromEntries(Object.keys(ie).map(n=>[n,kn(n)])),gaits:Object.keys(_t),actingStyles:Object.keys(wn),beatFields:xi,actions:e,dances:Object.fromEntries(Object.entries(te).map(([n,i])=>[n,Object.keys(i.moves)])),flips:Object.fromEntries(Object.entries(gn).map(([n,i])=>[n,i.label])),handShapes:Object.keys(dt),mudras:Object.keys(ri)},character:{poses:Object.keys(Us),expressions:Object.keys(Vs),gags:Object.keys(po)},codePanel:{languages:Ti,removeStyles:Si,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:fo},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 Mt=t=>t.map(e=>`\`${e}\``).join(", "),ah=t=>Object.entries(t).map(([e,n])=>`| \`${e}\` | ${n.unit??n.kind??""} | ${n.description} |`).join(`
|
|
57
|
+
`);function Im(t){const e=rh(t),n=e.stickFigure;return[`# tinyfly capabilities${e.version?` (v${e.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.** ${e.timing}`,"","## Easings","",`Named: ${Mt(e.easings.named)}.`,"",...Object.entries(e.easings.parametric).map(([s,o])=>`- ${s}: \`${o}\``),"","## Track kinds","",...Object.entries(e.trackKinds).map(([s,o])=>`- **${s}**: ${o}`),"","## 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(e.canvasProperties).map(([s,o])=>`| \`${s}\` | ${o.unit??o.kind??""} | ${o.description} | ${o.types.length===7?"all":o.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 |","|---|---|---|",ah(n.poseFields),"","### Other props","","| Prop | Unit | What it does |","|---|---|---|",ah(n.props),"",`With \`style.hands\`, each hand has \`hand.left.<field>\` / \`hand.right.<field>\` props: ${Mt(Object.keys(n.handFields))}.`,"",`**Poses** (a beat's \`do\`, or a pose key): ${Mt(n.poses)}.`,"",`**Expressions** (a beat's \`mood\`): ${Mt(n.expressions)}.`,"",`**Gags** (ms): ${Object.entries(n.gags).map(([s,o])=>`\`${s}\` (${o})`).join(", ")}.`,"",`**Gaits**: ${Mt(n.gaits)}. **Acting styles** (\`style\`): ${Mt(n.actingStyles)}.`,"","### Beat scripts","",`\`scriptTracks(target, beats, { from, ground, height, facing, style })\`. A beat has these fields only: ${Mt(n.beatFields)}. Times are ms; \`to\` and \`target\` are scene px; \`onto\` is a floor's scene y.`,"","| `do` | Needs | What happens |","|---|---|---|",...Object.entries(n.actions).map(([s,o])=>`| \`${s}\` | ${(o.needs??[]).map(r=>`\`${r}\``).join(", ")} | ${o.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(n.dances).map(([s,o])=>`\`${s}\` (${o.join(", ")})`).join("; ")}.`,"",`**Flips**: ${Object.entries(n.flips).map(([s,o])=>`\`${s}\` (${o})`).join(", ")}.`,"",`**Hand shapes**: ${Mt(n.handShapes)}. **Mudras**: ${Mt(n.mudras)}.`,"","## Character (v2 human)","",`Poses: ${Mt(e.character.poses)}. Expressions: ${Mt(e.character.expressions)}. Gags: ${Mt(e.character.gags)}.`,"","## Code panel","",`\`codePanel({ code, language, x, y, fontSize?, lineHeight?, width? })\`: a code listing as a scene object. Languages: ${Mt(e.codePanel.languages)}. Remove styles: ${Mt(e.codePanel.removeStyles)}.`,"",...Object.entries(e.codePanel.anchors).map(([s,o])=>`- \`${s}\`: ${o}`),"",...Object.values(e.codePanel.edits).map(s=>`- \`${s.split(":")[0]}\`:${s.split(":").slice(1).join(":")}`),"","## Camera shots (`cameraTracks(shots, { stage })`)","",...Object.entries(e.cameraShots).map(([s,o])=>`- **${s}**: \`${o}\``),"","## Teaching (`@algorisys/tinyfly/teach`)","",...Object.entries(e.teach).map(([s,o])=>`- \`${s}\`: ${o}`),"","## Command line","",...Object.entries(e.cli).map(([s,o])=>`- \`${s}\`: ${o}`),""].join(`
|
|
58
|
+
`)}function Hm(t){const{timeline:e}=t,n=new he;for(const[c,h]of Object.entries(t.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)}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 Cm={timeline:of,to(t,e,n){const i=new ce(n);return i.to(t,e),i},from(t,e,n){const i=new ce(n);return i.from(t,e),i},fromTo(t,e,n,i){const s=new ce(i);return s.fromTo(t,e,n),s},set(t,e,n){const i=new ce(n);return i.set(t,e),i}};function lh(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 Om(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 u=(h-s)/(1-s)*c/h;i[o*3]=r*u,i[o*3+1]=a*u,i[o*3+2]=l*u}return i}function ch(t,e,n,i,s){const o=new Float32Array(t.length),r=s?n:e,a=s?e:n,l=(h,u)=>(s?h*e+u:u*e+h)*3,c=i*2+1;for(let h=0;h<r;h++)for(let u=0;u<3;u++){let f=0;for(let d=-i;d<=i;d++)f+=t[l(h,Math.min(a-1,Math.max(0,d)))+u];for(let d=0;d<a;d++){o[l(h,d)+u]=f/c;const g=t[l(h,Math.max(0,d-i))+u],p=t[l(h,Math.min(a-1,d+i+1))+u];f+=p-g}}return o}function hh(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=ch(o,e,n,s,!0),o=ch(o,e,n,s,!1);return o}function Rm(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=lh(t,r,a),c=l?.getContext("2d");if(!l||!c)return;c.imageSmoothingEnabled=!0,c.drawImage(t.canvas,0,0,r,a);const h=Om(c.getImageData(0,0,r,a).data,e.threshold??.55),u=(e.radius??Math.max(i,s)*.02)/o,f=hh(h,r,a,u),d=hh(h,r,a,u*3),g=e.halo??.6,p=c.createImageData(r,a);for(let m=0;m<r*a;m++){for(let y=0;y<3;y++)p.data[m*4+y]=Math.round(Math.min(1,f[m*3+y]+d[m*3+y]*g)*255);p.data[m*4+3]=255}c.putImageData(p,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 Lm(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=Dm(e,i,s,o,r);a?(t.globalCompositeOperation="lighter",_o(t,c,n.color)):Nm(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,Fm(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 Fm(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 Dm(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=Nr(o),a=Br(o)??void 0,l=[];for(let c=0;c+1<t.length;c++){const h=(t[c].age+t[c+1].age)/2,u=s*(1-i*h);if(u<=0)continue;const f=c+2===t.length;l.push({corners:[r.left[c],r.left[c+1],r.right[c+1],r.right[c]],alpha:u,...f&&a&&{cap:a}})}return l}function _o(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 Nm(t,e,n){const i=typeof t.getTransform=="function"?t.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,o=i?Math.sqrt(Math.abs(i.a*i.d-i.b*i.c)):1,r=e.map(p=>({...p,corners:p.corners.map(s),...p.cap&&{cap:{...p.cap,...s(p.cap),radius:p.cap.radius*o,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 r){const m=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,...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 u=Math.floor(a)-1,f=Math.floor(l)-1,d=i?lh(t,Math.ceil(c)+1-u,Math.ceil(h)+1-f):null,g=d?.getContext("2d");if(!d||!g){_o(t,e,n);return}g.translate(-u,-f),g.globalCompositeOperation="lighter",_o(g,r,n),t.save(),t.setTransform(1,0,0,1,0,0),t.globalAlpha=1,t.drawImage(d,u,f),t.restore()}const Bm=Tt.to,Wm=Tt.from,Km=Tt.fromTo,Ym=Tt.set,jm=Tt.timeline,Xm=Tt.ticker,qm=Tt.splitText,Um=Tt.context,Vm=Tt.matchMedia,Gm=Tt.quickTo,zm=Tt.imageSequence,Jm=Tt.pageTransition;Hd(),b.ACTING_STYLES=wn,b.BEAT_FIELDS=xi,b.CANVAS_PROPERTIES=_i,b.CODE_LANGUAGES=Ti,b.CODE_PANEL_EDITS=fo,b.CODE_THEME=wc,b.Clock=dh,b.CompatTimeline=ce,b.CustomBounce=Ca,b.CustomEase=Ha,b.CustomWiggle=Oa,b.DANCE_STYLES=te,b.DEFAULT_BAKE_INTERVAL_MS=Gi,b.DEFAULT_INERTIA_FRICTION=Fi,b.DEFAULT_LABELS=Ya,b.DEFAULT_SPRING=$t,b.DEFAULT_TRANSITION=Od,b.Draggable=ps,b.EXPRESSIONS=ot,b.FINGERS=ol,b.FLIPS=gn,b.FORMAT_VERSION=Ii,b.GAGS=ie,b.GAITS=_t,b.GAIT_CYCLE_MS=ko,b.HAND_REST=ct,b.HAND_SHAPES=dt,b.HUMAN_ACTING_RIG=Ec,b.HUMAN_EXPRESSIONS=Vs,b.HUMAN_GAGS=po,b.HUMAN_POSES=Us,b.HUMAN_REST=ut,b.IDENTITY_CAMERA=pc,b.INERTIA_MAX_DURATION_MS=Ro,b.InertiaTrackPlayer=vr,b.LiveTimeline=Ft,b.MORPH_SAMPLES=Rh,b.MUDRAS=ri,b.ManualClock=fh,b.MediaSync=Ps,b.Observer=ca,b.POSES=Dt,b.REMOVE_STYLES=Si,b.REST_POSE=V,b.SCRIPT_ACTIONS=Sn,b.SPRING_MAX_DURATION_MS=Li,b.SPRING_PRESETS=Pn,b.SPRING_STEP_MS=me,b.STICK_ACTING_RIG=Tc,b.ScrollAnimator=Ea,b.ScrollDriver=sn,b.ScrollMarkers=Aa,b.ScrollPin=va,b.SmoothScroll=Es,b.SpringSampler=Ke,b.SpringTrackPlayer=kr,b.Stage=ia,b.Timeline=ae,b.TinyflyPlayer=Gn,b.TinyflySequencer=Ja,b.TrackPlayer=Rn,b.VISEMES=se,b.ValueResolver=cu,b.VisibilityDriver=ka,b.actCharacterTracks=Wg,b.actKeyframes=yo,b.actTracks=xc,b.actionNames=Nc,b.animatableProperties=oh,b.applyBloom=Rm,b.applyCamera=ag,b.applyGroove=Kl,b.assertBeats=Kc,b.backOut=Xo,b.bakeDanceTracks=J0,b.bakeEasing=Zi,b.bakeInertiaTrack=Ji,b.bakeSpringTrack=zi,b.basicOutfit=Hg,b.beatAt=V0,b.beatAtTime=Fn,b.beatLength=os,b.beatTime=Ln,b.beatsBetween=vu,b.bindChoiceHotspots=Ua,b.blendPose=Oe,b.boilFrame=_s,b.bounceOut=jo,b.cameraFromValues=rg,b.cameraPoint=lg,b.cameraTracks=Eu,b.capabilities=rh,b.capabilitiesMarkdown=Im,b.character=rc,b.characterAt=Zp,b.characterHandPose=lc,b.characterJoints=ac,b.characterJointsInView=Vp,b.characterObjects=og,b.characterPoseTracks=Qp,b.characterTarget=Jp,b.charactersFor=Sr,b.checkBeats=Wc,b.checkTracks=$m,b.circlePath=fg,b.clamp01=vs,b.clearMorphCache=jh,b.clearPathCache=_h,b.clipErased=uo,b.closestName=Dn,b.codePanel=Sg,b.codeTokens=vc,b.containerProgressAt=Ss,b.context=Um,b.create=yd,b.createControls=Xa,b.createCubicBezier=Ko,b.createLive=Fa,b.createPen=Hs,b.createRandom=Ge,b.createTrack=On,b.criticalDamping=mh,b.customBounce=Cr,b.customEase=Hr,b.customWiggle=Or,b.danceFrame=ci,b.dancePose=Y0,b.danceStance=li,b.danceTaps=X0,b.danceTracks=z0,b.danceTravel=ui,b.danceTravelTrack=Ul,b.dancer=G0,b.describeTarget=sh,b.deserializeTimeline=Te,b.deserializeTrack=Ar,b.detectTempo=Su,b.draggable=_f,b.drawCartoonHand=ii,b.drawCharacter=cc,b.drawCharacterInView=uc,b.drawDustPuff=Xg,b.drawEraser=co,b.drawHand=ho,b.drawImpactStars=qg,b.drawPencil=gc,b.drawSpeedLines=$c,b.drawStickFigure=Ll,b.drawStickSmear=jg,b.drawTrail=Lm,b.drawnPathTarget=dg,b.easeIn=No,b.easeInCubic=Di,b.easeInOut=Wo,b.easeInOutCubic=je,b.easeInOutQuad=Do,b.easeInQuad=Lo,b.easeOut=Bo,b.easeOutCubic=Ni,b.easeOutQuad=Fo,b.editDistance=Fr,b.elasticOut=Yo,b.ellipsePoints=Is,b.erasable=yg,b.expandParametricEasings=br,b.flipPose=Vl,b.flipTracks=fp,b.flipTravel=Gl,b.formatVersionFor=Hi,b.from=Wm,b.fromJSON=ru,b.fromTo=Km,b.gag=bo,b.gagDuration=kn,b.gaitPose=cl,b.gaitStrideLength=Rs,b.getEasingFunction=vt,b.getInterpolator=Ve,b.getMotionPathPoint=Qi,b.getPathLength=Ih,b.getPointAtProgress=zo,b.gridLinesFor=fa,b.handAt=ug,b.handJoints=ni,b.handJointsAt=ll,b.handPath=xm,b.handPose=ht,b.handProp=dn,b.hasKeyframes=Ho,b.hashSeed=Ee,b.headPoint=C0,b.heldTime=Co,b.humanFieldLabel=xp,b.humanGag=_g,b.humanGaitPose=Pg,b.humanGaitStrideLength=$g,b.humanPlan=Jl,b.humanPose=At,b.imageSequence=zm,b.inertiaDuration=be,b.inertiaRest=ye,b.inertiaValueAt=_n,b.inertiaVelocityAt=kh,b.interpolateArray=pr,b.interpolateColor=dr,b.interpolateMotionPath=eu,b.interpolateNumber=Ot,b.interpolatePathString=mr,b.interpolateQuaternion=gr,b.interpolateString=Vi,b.isCubicBezierEasing=Io,b.isInertiaTrack=Xt,b.isMotionPathPoint=uh,b.isMotionPathTrack=Ci,b.isParametricEasing=Be,b.isPathData=ke,b.isSpringTrack=qt,b.isTextTrack=Tn,b.isUnderdamped=gh,b.isUnresolved=lu,b.jointsInScene=dc,b.jointsToScene=Rl,b.linear=In,b.lipSyncKeyframes=wo,b.lipSyncOver=Dc,b.lipSyncTracks=Zg,b.live=Tt,b.mapEase=tn,b.mat4=Lu,b.matchMedia=Vm,b.maxStaggerDistance=Ri,b.mirrorHumanPose=Ap,b.mirrorPose=Wl,b.mixHandPoses=He,b.mixPoses=Gp,b.morphPath=ir,b.mount=Va,b.mountAll=za,b.narrationMarkers=yu,b.narrationSceneAt=bu,b.naturalRest=Ye,b.nearestBeat=wu,b.nextBeat=ku,b.pageTransition=Jm,b.parametricEasing=Uo,b.parseEdge=ws,b.parsePath=re,b.parseTrigger=ks,b.partialPath=Ie,b.pathLength=nl,b.planNarration=mu,b.play=md,b.playSequence=Cd,b.playWhenVisible=Yf,b.playheadCrossings=es,b.pointAlong=Jn,b.pointAtDistance=Wi,b.pointOnHead=Kp,b.pointsToPath=Dr,b.pose=yt,b.poseTracks=F0,b.quat=zh,b.quickPlay=Hm,b.quickTo=Gm,b.randomBetween=is,b.randomChoice=au,b.randomSnapped=Pr,b.reachCharacter=zp,b.resolveActingStyle=Mc,b.resolveCharacterPoseKeys=lo,b.resolveGait=hn,b.resolvePoseKeys=Ws,b.resolveSequence=Ir,b.resolveStickFrame=Ns,b.resolveStickPose=Fl,b.resolveValue=ss,b.ribbon=Nr,b.ribbonHeadCap=Br,b.rotateAbout=Zt,b.routineBeats=hi,b.rubberLimb=ue,b.scriptActionSummaries=Bc,b.scriptTracks=Sm,b.scrollProgress=Kf,b.scrubOnScroll=Uf,b.scrubPath=gg,b.seatHeight=x0,b.serializeTimeline=xr,b.serializeTrack=Tr,b.set=Ym,b.shapeToPathData=Nn,b.simplifyKeyframes=wr,b.skeletonInView=to,b.sketchPen=Zn,b.smoothToward=wa,b.snapAxis=ua,b.snapConfig=Sa,b.snapDuration=Ta,b.snapProgress=Ma,b.solvePlanSpace=mi,b.soundsOf=Fc,b.speechDuration=ih,b.splitText=qm,b.springDuration=Oo,b.springValueAt=ph,b.stagePlanSpace=Qs,b.staggerDistance=Oi,b.staggerOffset=En,b.staggerOffsets=An,b.staggerSpan=We,b.stepsEasing=qo,b.stickFigureAt=Bs,b.stickFigureJoints=Qt,b.stickFigureTarget=Nl,b.stickToHuman=$p,b.strideLength=gl,b.syncMediaElement=Ka,b.talkingMouth=ml,b.taperedLine=Qn,b.taperedOutline=an,b.textAt=Mr,b.tf=Cm,b.ticker=Xm,b.timeline=jm,b.to=Bm,b.toJSON=ou,b.toKeyframedTrack=Qh,b.toKeyframedTracks=tu,b.trackTargets=zt,b.trailSamples=xu,b.triggerDistance=xe,b.unknownName=Bt,b.unmount=_d,b.vec3=$u,b.walkPose=pl,b.withErased=mg,b.withExpression=Ce,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});
|