@algorisys/tinyfly 0.89.0 → 0.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/lib/addons/adapters.js +208 -177
- package/lib/addons/characters.js +1912 -1619
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +4845 -4464
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/engine/tinyfly-engine.js +824 -767
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/headless/headless.js +39 -3
- package/lib/types/adapters/canvas/camera.d.ts +46 -0
- package/lib/types/adapters/canvas/index.d.ts +1 -0
- package/lib/types/browser/index.d.ts +2 -0
- package/lib/types/characters/acting/index.d.ts +2 -0
- package/lib/types/characters/acting/lip-sync.d.ts +115 -0
- package/lib/types/characters/acting/script.d.ts +83 -0
- package/lib/types/characters/gaits.d.ts +141 -0
- package/lib/types/characters/index.d.ts +1 -0
- package/lib/types/characters/stick-figure.d.ts +15 -0
- package/lib/types/engine/authoring/camera-shots.d.ts +73 -0
- package/lib/types/engine/authoring/index.d.ts +1 -0
- package/lib/types/headless/video-scene.d.ts +14 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(h,Q){typeof exports=="object"&&typeof module<"u"?Q(exports):typeof define=="function"&&define.amd?define(["exports"],Q):(h=typeof globalThis<"u"?globalThis:h||self,Q(h.tinyfly={}))})(this,(function(h){"use strict";function Q(t){return typeof t=="object"&&t!==null&&t.type==="cubic-bezier"}function ot(t){return typeof t=="object"&&t!==null&&t.type!=="cubic-bezier"}const kt=2;function At(t){return t.some(e=>e.interpolation!==void 0)?2:1}function ct(t){return t.property==="text"&&"textConfig"in t}function z(t){return t.kind==="inertia"&&"inertia"in t}function V(t){return t.kind==="spring"&&"spring"in t}function Pt(t){return t.property==="motionPath"&&"motionPathConfig"in t}function _n(t){return typeof t=="object"&&t!==null&&"x"in t&&"y"in t&&"angle"in t}function ie(t){return"keyframes"in t}class Tn{_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 bn{_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 r=(e-this._lastFrameTime)*this._speed;this._currentTime+=r,this.onTick?.(r,this._currentTime)}this._lastFrameTime=e,this._scheduleFrame()}}}function Sn(t,e){if(!(e>0))return t;const n=1e3/e;return Math.floor(t/n+1e-9)*n}function vt(t,e,n="start"){if(e<=1)return 0;if(typeof n=="number"){const r=Math.max(0,Math.min(e-1,n));return Math.abs(t-r)}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 ae(t,e="start"){if(t<=1)return 0;let n=0;for(let r=0;r<t;r++)n=Math.max(n,vt(r,t,e));return n}function wt(t,e,n){if(n.offsets)return n.offsets[t]??0;const r=n.from??"start",s=vt(t,e,r);if(n.amount!==void 0){const i=ae(e,r);return i===0?0:n.amount*s/i}return n.each!==void 0?n.each*s:0}function oe(t,e){return Array.from({length:t},(n,r)=>wt(r,t,e))}function ut(t,e){return t<=1?0:Math.max(...oe(t,e))}const G=1,It=6e4,lt=It/G,F={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},kn={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 tt{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??F.stiffness,this.damping=e.damping??F.damping,this.mass=e.mass??F.mass,this.restDelta=e.restDelta??F.restDelta,this.restSpeed=e.restSpeed??F.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=e.velocity??F.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/G);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const r=this.samples[Math.min(n,this.samples.length-1)],s=this.samples[Math.min(n+1,this.samples.length-1)],i=e/G-n;return r+(s-r)*i}settleTime(){return this.simulateTo(lt+1),this.settledStep!==null?this.settledStep*G:It}simulateTo(e){if(this.settledStep!==null)return;const n=Math.min(e,lt+1),r=G/1e3;for(;this.samples.length<n;){const s=this.samples[this.samples.length-1],i=s-this.to,a=-this.stiffness*i,o=-this.damping*this.velocity,c=(a+o)/this.mass;this.velocity+=c*r;const u=s+this.velocity*r;if(this.samples.push(u),this.isAtRest(u)){this.settledStep=this.samples.length-1;return}}this.samples.length>lt&&(this.settledStep=lt)}}function An(t,e){return new tt(t).valueAt(e)}function Pn(t){return new tt(t).settleTime()}function vn(t){const e=t.stiffness??F.stiffness,n=t.damping??F.damping,r=t.mass??F.mass;return n<2*Math.sqrt(e*r)}function wn(t){const e=t.stiffness??F.stiffness,n=t.mass??F.mass;return 2*Math.sqrt(e*n)}const Rt=4,In=.002,Rn=1e-4,ce=6e4;function ht(t){const e=t.friction??Rt;return e>0?e:Rt}function ue(t){return t.from+t.velocity/ht(t)}function Dn(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 r of e)Math.abs(r-t)<Math.abs(n-t)&&(n=r);return n}function et(t){let e=Dn(ue(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 nt(t){const e=Math.abs(et(t)-t.from);if(e===0)return 0;const n=t.restDelta??Math.max(Rn,e*In);if(n>=e)return 0;const r=Math.log(e/n)/ht(t);return Math.min(ce,r*1e3)}function ft(t,e){if(e<=0)return t.from;const n=et(t);if(e>=nt(t))return n;const r=ht(t);return t.from+(n-t.from)*(1-Math.exp(-r*e/1e3))}function En(t,e){const n=ht(t),r=et(t);return e>=nt(t)?0:(r-t.from)*n*Math.exp(-n*Math.max(0,e)/1e3)}const dt=t=>t,le=t=>t*t,he=t=>1-(1-t)*(1-t),fe=t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,Dt=t=>t*t*t,Et=t=>1-Math.pow(1-t,3),Ct=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,de=Dt,ge=Et,me=Ct,Cn={linear:dt,"ease-in":de,"ease-out":ge,"ease-in-out":me,"ease-in-quad":le,"ease-out-quad":he,"ease-in-out-quad":fe,"ease-in-cubic":Dt,"ease-out-cubic":Et,"ease-in-out-cubic":Ct};function pe(t){const[e,n,r,s]=t,i=3*e,a=3*(r-e)-i,o=1-i-a,c=3*n,u=3*(s-n)-c,l=1-c-u,f=m=>((o*m+a)*m+i)*m,d=m=>((l*m+u)*m+c)*m,g=m=>(3*o*m+2*a)*m+i,_=m=>{let p=m;for(let A=0;A<8;A++){const w=f(p)-m;if(Math.abs(w)<1e-7)return p;const M=g(p);if(Math.abs(M)<1e-7)break;p-=w/M}let T=0,b=1;for(p=m;T<b;){const A=f(p);if(Math.abs(A-m)<1e-7)return p;m>A?T=p:b=p,p=(T+b)/2}return p};return m=>{if(m<=0)return 0;if(m>=1)return 1;const p=_(m);return d(p)}}function $t(t,e="out"){if(e==="out")return t;const n=r=>1-t(1-r);return e==="in"?n:r=>r<.5?n(r*2)/2:t(r*2-1)/2+.5}function ye(t=1,e=.3){const n=Math.max(1,t),r=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-r)*(2*Math.PI)/e)+1}const Me=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 r=t-2.625/2.75;return 7.5625*r*r+.984375};function _e(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 Te(t,e="end"){const n=Math.max(1,Math.floor(t));return r=>{if(r>=1)return 1;if(r<=0)return e==="start"||e==="both"?e==="start"?1/n:1/(n+1):0;const s=Math.floor(r*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 be(t){switch(t.type){case"steps":return Te(t.count,t.position);case"elastic":return $t(ye(t.amplitude,t.period),t.mode);case"bounce":return $t(Me,t.mode);case"back":return $t(_e(t.overshoot),t.mode)}}function Ot(t){return t===void 0?dt:Q(t)?pe(t.points):ot(t)?be(t):Cn[t]??dt}const Se=32,$n=256,K=new Map,On=/[MmLlHhVvCcSsQqTtAaZz]/,Ln=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Fn={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Nn(t){const e=[];let n=0,r=null;const s=()=>{for(;n<t.length&&/[\s,]/.test(t[n]);)n++};for(;n<t.length&&(s(),!(n>=t.length));){const i=t[n];if(On.test(i)){r={type:i,args:[]},e.push(r),n++;continue}if(!r)break;const a=r.type==="A"||r.type==="a",o=r.args.length%7;if(a&&(o===3||o===4)){if(i!=="0"&&i!=="1")break;r.args.push(i==="1"?1:0),n++;continue}const c=Ln.exec(t.slice(n));if(!c)break;r.args.push(parseFloat(c[0])),n+=c[0].length}return e}function xn(t,e,n,r,s,i,a,o,c){if(t===o&&e===c)return[];let u=Math.abs(n),l=Math.abs(r);if(u===0||l===0)return[[t,e,o,c,o,c]];const f=s*Math.PI/180,d=Math.cos(f),g=Math.sin(f),_=(t-o)/2,m=(e-c)/2,p=d*_+g*m,T=-g*_+d*m,b=p*p/(u*u)+T*T/(l*l);if(b>1){const E=Math.sqrt(b);u*=E,l*=E}const A=i===a?-1:1,w=u*u*l*l-u*u*T*T-l*l*p*p,M=u*u*T*T+l*l*p*p,I=A*Math.sqrt(Math.max(0,w/M)),v=I*u*T/l,$=-I*l*p/u,y=d*v-g*$+(t+o)/2,S=g*v+d*$+(e+c)/2,k=(E,O,L,J)=>{const se=E*L+O*J,St=Math.sqrt((E*E+O*O)*(L*L+J*J)),at=Math.acos(Math.max(-1,Math.min(1,se/St)));return E*J-O*L<0?-at:at},P=k(1,0,(p-v)/u,(T-$)/l);let D=k((p-v)/u,(T-$)/l,(-p-v)/u,(-T-$)/l);!a&&D>0&&(D-=2*Math.PI),a&&D<0&&(D+=2*Math.PI);const R=Math.max(1,Math.ceil(Math.abs(D)/(Math.PI/2))),re=D/R,bt=4/3*Math.tan(re/4),pn=E=>{const O=u*Math.cos(E),L=l*Math.sin(E);return[d*O-g*L+y,g*O+d*L+S]},yn=E=>{const O=-u*Math.sin(E),L=l*Math.cos(E);return[d*O-g*L,g*O+d*L]},Mn=[];for(let E=0;E<R;E++){const O=P+E*re,L=O+re,[J,se]=pn(O),[St,at]=E===R-1?[o,c]:pn(L),[us,ls]=yn(O),[hs,fs]=yn(L);Mn.push([J+bt*us,se+bt*ls,St-bt*hs,at-bt*fs,St,at])}return Mn}function U(t,e,n,r,s){const i=1-s;return i*i*i*t+3*i*i*s*e+3*i*s*s*n+s*s*s*r}function ke(t,e,n,r,s){const i=1-s;return 3*i*i*(e-t)+6*i*s*(n-e)+3*s*s*(r-n)}function rt(t,e,n,r){return{subpath:0,type:"L",points:[n,r],startX:t,startY:e,endX:n,endY:r,length:Math.hypot(n-t,r-e)}}function gt(t,e,n){const[r,s,i,a,o,c]=n,u=[0];let l=t,f=e,d=0;for(let g=1;g<=Se;g++){const _=g/Se,m=U(t,r,i,o,_),p=U(e,s,a,c,_);d+=Math.hypot(m-l,p-f),u.push(d),l=m,f=p}return{subpath:0,type:"C",points:[r,s,i,a,o,c],startX:t,startY:e,endX:o,endY:c,length:d,lengths:u}}function j(t){const e=K.get(t);if(e)return e;const n=[];let r=0,s=0,i=0,a=0,o=null,c=null,u=-1;const l=new Set,f=m=>{u<0&&(u=0),m.subpath=u,n.push(m)};for(const{type:m,args:p}of Nn(t)){const T=m.toUpperCase(),b=m!==T,A=Fn[T];if(T==="Z"){(r!==i||s!==a)&&f(rt(r,s,i,a)),u>=0&&l.add(u),r=i,s=a,o=c=null;continue}for(let w=0;w+A<=p.length;w+=A){const M=p.slice(w,w+A),I=b?r:0,v=b?s:0;let $=null,y=null;switch(T){case"M":w===0?(r=M[0]+I,s=M[1]+v,i=r,a=s,(u<0||n[n.length-1]?.subpath===u)&&u++):(f(rt(r,s,M[0]+I,M[1]+v)),r=M[0]+I,s=M[1]+v);break;case"L":f(rt(r,s,M[0]+I,M[1]+v)),r=M[0]+I,s=M[1]+v;break;case"H":f(rt(r,s,M[0]+I,s)),r=M[0]+I;break;case"V":f(rt(r,s,r,M[0]+v)),s=M[0]+v;break;case"C":{const S=[M[0]+I,M[1]+v,M[2]+I,M[3]+v,M[4]+I,M[5]+v];f(gt(r,s,S)),$=[S[2],S[3]],r=S[4],s=S[5];break}case"S":{const[S,k]=o?[2*r-o[0],2*s-o[1]]:[r,s],P=[S,k,M[0]+I,M[1]+v,M[2]+I,M[3]+v];f(gt(r,s,P)),$=[P[2],P[3]],r=P[4],s=P[5];break}case"Q":case"T":{let S=r,k=s;T==="Q"?(S=M[0]+I,k=M[1]+v):c&&(S=2*r-c[0],k=2*s-c[1]);const P=T==="Q"?M[2]+I:M[0]+I,D=T==="Q"?M[3]+v:M[1]+v;f(gt(r,s,[r+2/3*(S-r),s+2/3*(k-s),P+2/3*(S-P),D+2/3*(k-D),P,D])),y=[S,k],r=P,s=D;break}case"A":{const S=M[5]+I,k=M[6]+v;let P=r,D=s;for(const R of xn(r,s,M[0],M[1],M[2],M[3],M[4],S,k))f(gt(P,D,R)),P=R[4],D=R[5];r=S,s=k;break}}o=$,c=y}}const d=n.reduce((m,p)=>m+p.length,0),g=[];for(let m=0;m<n.length;){const p=n[m].subpath;let T=m,b=0;for(;T<n.length&&n[T].subpath===p;)b+=n[T++].length;const A=n[m],w=n[T-1],M=l.has(p)||Math.abs(w.endX-A.startX)<1e-9&&Math.abs(w.endY-A.startY)<1e-9;g.push({start:m,end:T,length:b,closed:M}),m=T}const _={segments:n,totalLength:d,subpaths:g};return K.size>=$n&&K.delete(K.keys().next().value),K.set(t,_),_}function Xn(t,e){const n=t.lengths;if(e<=0)return 0;if(e>=t.length)return 1;let r=0,s=n.length-1;for(;r<s-1;){const o=r+s>>1;n[o]<e?r=o:s=o}const i=n[s]-n[r],a=i>0?(e-n[r])/i:0;return(r+a)/(n.length-1)}function zn(t,e){if(t.type==="L"){const f=t.length>0?Math.max(0,Math.min(1,e/t.length)):0;return{x:t.startX+(t.endX-t.startX)*f,y:t.startY+(t.endY-t.startY)*f,angle:Math.atan2(t.endY-t.startY,t.endX-t.startX)*180/Math.PI}}const[n,r,s,i,a,o]=t.points,c=Xn(t,e);let u=ke(t.startX,n,s,a,c),l=ke(t.startY,r,i,o,c);if(Math.hypot(u,l)<1e-9){const f=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),d=U(t.startX,n,s,a,f),g=U(t.startY,r,i,o,f),_=U(t.startX,n,s,a,c),m=U(t.startY,r,i,o,c);u=c<.5?d-_:_-d,l=c<.5?g-m:m-g}return{x:U(t.startX,n,s,a,c),y:U(t.startY,r,i,o,c),angle:Math.atan2(l,u)*180/Math.PI}}function Lt(t,e,n=0,r=t.length){if(r<=n)return{x:0,y:0,angle:0};let s=0;for(let i=n;i<r;i++){const a=t[i];if(s+a.length>=e||i===r-1)return zn(a,e-s);s+=a.length}return{x:0,y:0,angle:0}}function Ae(t,e){const{segments:n,totalLength:r}=j(t);return Lt(n,Math.max(0,Math.min(1,e))*r)}function Vn(){K.clear()}function Un(t){return j(t).totalLength}const Yn=24,Bn=320,jn=2.5,st=72,Hn=64,Qn=.2,Gn=128,it=new Map;let mt=0,Y;const Pe=t=>Math.round(t*100)/100;function ve(t,e){const{segments:n,subpaths:r,totalLength:s}=j(t);if(n.length===0)return[];if(e){const i=r.every(a=>a.closed);return[{segments:n,start:0,end:n.length,length:s,closed:i}]}return r.filter(i=>i.length>0).map(i=>({segments:n,start:i.start,end:i.end,length:i.length,closed:i.closed}))}function Ft(t,e){const n=t.closed?(e%1+1)%1:Math.max(0,Math.min(1,e)),r=Lt(t.segments,n*t.length,t.start,t.end);return[r.x,r.y]}function we(t){const e=[];let n=0;for(let r=t.start;r<t.end;r++)n+=t.segments[r].length,t.length>0&&e.push(n/t.length);return e}function Ie(t,e){const n=[];for(let r=0;r<e;r++)n.push(Ft(t,t.closed?r/e:r/(e-1)));return n}function Re(t){let e=0,n=0;for(const[r,s]of t)e+=r,n+=s;return e/=t.length,n/=t.length,t.map(([r,s])=>[r-e,s-n])}function Kn(t,e,n){const r=t.closed&&e.closed;if(n!==void 0)return{offset:r?Math.abs(n)%st/st:0,reversed:n<0};const s=Re(Ie(t,st)),i=Re(Ie(e,st)),a=st;let o={offset:0,reversed:!1},c=1/0;for(const u of[!1,!0]){const l=r?a:1;for(let f=0;f<l;f++){let d=0;for(let g=0;g<a&&d<c;g++){const _=r?u?(f-g+a)%a:(g+f)%a:u?a-1-g:g,m=s[g][0]-i[_][0],p=s[g][1]-i[_][1];d+=m*m+p*p}d<c&&(c=d,o={offset:r?f/a:0,reversed:u})}}return o}function Wn(t,e,n){return n?((e.reversed?e.offset-t:t+e.offset)%1+1)%1:e.reversed?1-t:t}function qn(t,e,n){return n?((e.reversed?e.offset-t:t-e.offset)%1+1)%1:e.reversed?1-t:t}function Zn(t,e,n){const r=t.closed&&e.closed,s=Kn(t,e,n.shapeIndex),i=Math.max(Yn,Math.min(Bn,Math.ceil(Math.max(t.length,e.length)/jn))),a=new Set,o=f=>a.add(Math.round(f*1e7)/1e7);for(let f=0;f<=i;f++)o(f/i);for(const f of we(t))o(f);for(const f of we(e))o(qn(f,s,r));let c=[...a].sort((f,d)=>f-d);r&&(c=c.filter(f=>f<1));const u=[],l=[];for(const f of c)u.push(...Ft(t,f)),l.push(...Ft(e,Wn(f,s,r)));return Jn({from:u,to:l,closed:r})}function Jn(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 r=[[0,e-1]];for(;r.length>0;){const[a,o]=r.pop();let c=-1,u=Qn;for(let l=a+1;l<o;l++){const f=Math.max(De(t.from,a,o,l),De(t.to,a,o,l));f>u&&(u=f,c=l)}c!==-1&&(n[c]=1,r.push([a,c],[c,o]))}const s=[],i=[];for(let a=0;a<e;a++)n[a]&&(s.push(t.from[a*2],t.from[a*2+1]),i.push(t.to[a*2],t.to[a*2+1]));return{from:s,to:i,closed:t.closed}}function De(t,e,n,r){const s=t[e*2],i=t[e*2+1],a=t[n*2]-s,o=t[n*2+1]-i,c=t[r*2]-s,u=t[r*2+1]-i,l=a*a+o*o,f=l===0?0:Math.max(0,Math.min(1,(c*a+u*o)/l));return Math.hypot(c-f*a,u-f*o)}function tr(t,e,n){const r=n.shapeIndex;if(Y&&Y.from===t&&Y.to===e&&Y.shapeIndex===r)return Y.plan;const i=it.get(String(r??"auto"))?.get(t)?.get(e);if(i)return Y={from:t,to:e,shapeIndex:r,plan:i},i;const a=j(t).subpaths.filter(g=>g.length>0).length===j(e).subpaths.filter(g=>g.length>0).length,o=ve(t,!a),c=ve(e,!a),u={pairs:o.map((g,_)=>Zn(g,c[_],n))};mt>=Gn&&(it.clear(),mt=0);const l=String(r??"auto"),f=it.get(l)??new Map;it.set(l,f);const d=f.get(t)??new Map;return f.set(t,d),d.set(e,u),mt++,Y={from:t,to:e,shapeIndex:r,plan:u},u}function Ee(t,e,n,r={}){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 i=tr(t,e,r);if(i.pairs.length===0)return s<.5?t:e;let a="";for(const o of i.pairs){for(let c=0;c<o.from.length;c+=2){const u=Pe(o.from[c]+(o.to[c]-o.from[c])*s),l=Pe(o.from[c+1]+(o.to[c+1]-o.from[c+1])*s);a+=`${c===0?a?" M":"M":" L"}${u} ${l}`}o.closed&&(a+=" Z")}return a}function er(){it.clear(),mt=0,Y=void 0}function Ce(t){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(t)}const W=Math.PI/180,nr=.9995;function Nt(){return[0,0,0,1]}function pt(t,e){const n=Math.hypot(t[0],t[1],t[2]);if(n===0)return Nt();const r=e*W/2,s=Math.sin(r)/n;return[t[0]*s,t[1]*s,t[2]*s,Math.cos(r)]}function rr(t,e,n){return xt(xt(pt([0,1,0],e),pt([1,0,0],t)),pt([0,0,1],n))}function sr(t){const[e,n,r,s]=H(t),i=2*(e*r+n*s),a=2*(e*n+r*s),o=1-2*(e*e+r*r),c=2*(n*r-e*s),u=1-2*(n*n+r*r),l=2*(e*r-n*s),f=1-2*(e*e+n*n),d=Math.asin(Math.max(-1,Math.min(1,-c)));return Math.abs(c)<.9999999?[d/W,Math.atan2(i,f)/W,Math.atan2(a,o)/W]:[d/W,Math.atan2(-l,u)/W,0]}function xt(t,e){const[n,r,s,i]=t,[a,o,c,u]=e;return[i*a+n*u+r*c-s*o,i*o-n*c+r*u+s*a,i*c+n*o-r*a+s*u,i*u-n*a-r*o-s*c]}function $e(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Oe(t){return Math.hypot(t[0],t[1],t[2],t[3])}function H(t){const e=Oe(t);return e===0?Nt():[t[0]/e,t[1]/e,t[2]/e,t[3]/e]}function ir(t){return[-t[0],-t[1],-t[2],t[3]]}function Le(t,e,n){const r=H(t);let s=H(e),i=$e(r,s);if(i<0&&(s=[-s[0],-s[1],-s[2],-s[3]],i=-i),i>nr)return H([r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n,r[2]+(s[2]-r[2])*n,r[3]+(s[3]-r[3])*n]);const a=Math.acos(i),o=Math.sin(a),c=Math.sin((1-n)*a)/o,u=Math.sin(n*a)/o;return H([r[0]*c+s[0]*u,r[1]*c+s[1]*u,r[2]*c+s[2]*u,r[3]*c+s[3]*u])}function ar(t,e){const[n,r,s,i]=H(t),a=2*(r*e[2]-s*e[1]),o=2*(s*e[0]-n*e[2]),c=2*(n*e[1]-r*e[0]);return[e[0]+i*a+(r*c-s*o),e[1]+i*o+(s*a-n*c),e[2]+i*c+(n*o-r*a)]}const or=Object.freeze(Object.defineProperty({__proto__:null,conjugate:ir,dot:$e,fromAxisAngle:pt,fromEuler:rr,identity:Nt,length:Oe,multiply:xt,normalize:H,rotateVec3:ar,slerp:Le,toEuler:sr},Symbol.toStringTag,{value:"Module"})),N=(t,e,n)=>t+(e-t)*n,Fe=512,Xt=new Map,zt=new Map;function Ne(t){const e=Xt.get(t);if(e)return e;const n=t.replace("#",""),r=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return Xt.size<Fe&&Xt.set(t,r),r}const xe=t=>t.charCodeAt(0)===35,Xe=t=>t.startsWith("rgb"),ze=t=>t.startsWith("rgba"),cr=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Vt=t=>Math.round(t).toString(16).padStart(2,"0");function ur(t,e,n){return`#${Vt(t)}${Vt(e)}${Vt(n)}`}function Ve(t){const e=zt.get(t);if(e)return e;const n=t.match(cr);if(!n)throw new Error(`Invalid rgb color: ${t}`);const r=parseInt(n[1],10),s=parseInt(n[2],10),i=parseInt(n[3],10),a=n[4]!==void 0?[r,s,i,parseFloat(n[4])]:[r,s,i];return zt.size<Fe&&zt.set(t,a),a}const Ue=(t,e,n)=>{if(xe(t)&&xe(e)){const[r,s,i]=Ne(t),[a,o,c]=Ne(e),u=N(r,a,n),l=N(s,o,n),f=N(i,c,n);return ur(u,l,f)}if((Xe(t)||ze(t))&&(Xe(e)||ze(e))){const r=Ve(t),s=Ve(e),i=Math.round(N(r[0],s[0],n)),a=Math.round(N(r[1],s[1],n)),o=Math.round(N(r[2],s[2],n));if(r.length===4||s.length===4){const c=r[3]??1,u=s[3]??1,l=N(c,u,n);return`rgba(${i}, ${a}, ${o}, ${l})`}return`rgb(${i}, ${a}, ${o})`}return n<1?t:e},Ye=(t,e,n)=>{const r=Math.min(t.length,e.length),s=[];for(let i=0;i<r;i++)s.push(N(t[i],e[i],n));return s},Be=(t,e,n)=>Le(t,e,n),Ut=(t,e,n)=>n<1?t:e,je=(t,e,n)=>Ee(t,e,n);function Yt(t,e){return e==="slerp"?Be:typeof t=="number"?N:Array.isArray(t)?Ye:typeof t=="string"?t.startsWith("#")||t.startsWith("rgb")?Ue:Ce(t)?je:Ut:Ut}const Bt=1e3/60;function jt(t,e={}){if(!V(t))throw new Error(`bakeSpringTrack: track "${t.id}" is not a spring track`);const n=new tt(t.spring);return He(t,r=>n.valueAt(r),n.settleTime(),t.spring.from,t.spring.to,e)}function Ht(t,e={}){if(!z(t))throw new Error(`bakeInertiaTrack: track "${t.id}" is not an inertia track`);const n=t.inertia;return He(t,r=>ft(n,r),nt(n),n.from,et(n),e)}function He(t,e,n,r,s,i){const a=i.intervalMs??Bt,o=i.tolerance??.01,c=t.delay??0,u=[];for(let f=0;f<=n;f+=a)u.push({time:f+c,value:e(f),easing:"linear"});const l=u[u.length-1];return!l||l.time<n+c?u.push({time:n+c,value:s,easing:"linear"}):l.value=s,c>0&&u.unshift({time:0,value:r,easing:"linear"}),{id:t.id,target:t.target,property:t.property,keyframes:o>0?Ke(u,o):u,...t.targets&&{targets:[...t.targets]},...t.stagger&&{stagger:{...t.stagger}}}}function Qe(t,e,n,r={}){const s=r.intervalMs??Bt,i=typeof n=="function"?n:Ot(n),a=Yt(t.value,r.interpolation),o=e.time-t.time;if(o<=0)return[e];const c=[];for(let l=s;l<o;l+=s){const f=l/o;c.push({time:t.time+l,value:a(t.value,e.value,i(f)),easing:"linear"})}const u=i(1);return c.push({...e,...u!==1&&{value:a(t.value,e.value,u)},easing:"linear"}),c}function lr(t,e){return V(t)?jt(t,e):z(t)?Ht(t,e):t}function Ge(t,e={}){const n=t.keyframes;if(!n.some(i=>ot(i.easing)))return t;const r=n.length>0?[n[0]]:[],s={...e,interpolation:t.interpolation??e.interpolation};for(let i=1;i<n.length;i++){const a=n[i];ot(a.easing)?r.push(...Qe(n[i-1],a,a.easing,s)):r.push(a)}return{...t,keyframes:r}}function hr(t,e){return t.filter(ie).map(n=>Ge(n,e)).concat(t.filter(V).map(n=>jt(n,e)),t.filter(z).map(n=>Ht(n,e)))}function Ke(t,e){if(t.length<=2)return t;const n=[t[0]];for(let r=1;r<t.length-1;r++){const s=n[n.length-1],i=t[r],a=t[r+1],o=a.time-s.time;if(o<=0)continue;const c=(i.time-s.time)/o,u=s.value+(a.value-s.value)*c;Math.abs(i.value-u)>e&&n.push(i)}return n.push(t[t.length-1]),n}function We(t){const e=[...t.keyframes].sort((n,r)=>n.time-r.time);return{...t,keyframes:e}}function B(t){return t.targets&&t.targets.length>0?t.targets:[t.target]}function q(t,e,n,r){const s=n??0;return!r||e<=1?s:s+wt(t,e,r)}class yt{track;targets;constructor(e){this.track=e,this.targets=B(e)}getValueAtTime(e){return this.valueForOffset(e-q(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const i=q(s,n,this.track.delay,this.track.stagger),a=this.valueForOffset(e-i);a!==void 0&&r.push({target:this.targets[s],value:a,start:i+this.track.keyframes[0].time})}return r}getDuration(){const{keyframes:e}=this.track;if(e.length===0)return 0;const n=e[e.length-1].time,r=this.track.stagger?ut(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+r+(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:r,to:s}=this.findSurroundingKeyframes(e);if(!r||!s)return;if(r.time===e)return r.value;const i=s.time-r.time,a=(e-r.time)/i,c=Ot(s.easing)(a);return Yt(r.value,this.track.interpolation)(r.value,s.value,c)}findSurroundingKeyframes(e){const{keyframes:n}=this.track;for(let r=0;r<n.length-1;r++)if(e>=n[r].time&&e<=n[r+1].time)return{from:n[r],to:n[r+1]};return{from:null,to:null}}}class qe{track;targets;sampler;constructor(e){this.track=e,this.targets=B(e),this.sampler=new tt(e.spring)}getValueAtTime(e){return this.sampler.valueAt(e-q(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const i=q(s,n,this.track.delay,this.track.stagger);r.push({target:this.targets[s],value:this.sampler.valueAt(e-i),start:i})}return r}getDuration(){const e=this.track.stagger?ut(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+e}getTrack(){return this.track}}class Ze{track;targets;duration;constructor(e){this.track=e,this.targets=B(e),this.duration=nt(e.inertia)}getValueAtTime(e){return ft(this.track.inertia,e-q(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const i=q(s,n,this.track.delay,this.track.stagger);r.push({target:this.targets[s],value:ft(this.track.inertia,e-i),start:i})}return r}getDuration(){const e=this.track.stagger?ut(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+e}getTrack(){return this.track}}function Qt(t,e){const n={...Ae(t.pathData,e)};if(t.matrix){const[r,s,i,a,o,c]=t.matrix,{x:u,y:l}=n;n.x=r*u+i*l+o,n.y=s*u+a*l+c;const f=n.angle*Math.PI/180,d=Math.cos(f),g=Math.sin(f);n.angle=Math.atan2(s*d+a*g,r*d+i*g)*180/Math.PI}return t.autoRotate&&t.rotateOffset&&(n.angle+=t.rotateOffset),n}function fr(t,e,n,r){const s=e+(n-e)*r;return Qt(t,s)}const Gt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},dr=20;function Je(t){const e=Gt[t??"upperCase"]??t??Gt.upperCase,n=Array.from(e);return n.length>0?n:Array.from(Gt.upperCase)}function gr(t,e,n){let r=(t|0)^Math.imul(e+1,2654435761)^Math.imul(n+1,2246822507);return r=Math.imul(r^r>>>16,2146121005),r=Math.imul(r^r>>>15,2221713035),(r^r>>>16)>>>0}function tn(t,e,n=0){const r=t.from??"",s=t.to,i=Math.max(0,Math.min(1,e));if(i<=0)return r;if(i>=1)return s;const a=Array.from(r),o=Array.from(s),c=t.rightToLeft??!1;if(t.mode==="type"){const b=Math.round(i*Math.max(a.length,o.length));return c?a.slice(0,Math.max(0,a.length-b)).join("")+o.slice(Math.max(0,o.length-b)).join(""):o.slice(0,b).join("")+a.slice(b).join("")}const u=Math.max(0,Math.min(.999,t.revealDelay??0)),l=Math.max(0,(i-u)/(1-u)),f=Math.floor(l*o.length),d=t.tweenLength===!1?o.length:Math.round(a.length+(o.length-a.length)*i),g=Je(t.chars),_=t.refreshRate??dr,m=_>0?Math.floor(n*_/1e3):0,p=t.seed??1;let T="";for(let b=0;b<d;b++){const A=c?b>=d-f:b<f,w=c?o[o.length-(d-b)]:o[b];A&&w!==void 0||w===" "||w===`
|
|
2
|
-
`?T+=w:T+=g[gr(p,b,m)%g.length]}return T}class en{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}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 o=Math.min(this._repeatDelayRemaining,s);if(this._repeatDelayRemaining-=o,s-=o,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const i=1e3;for(let o=0;o<i&&s>0&&this._playbackState==="playing";o++)if(this._direction==="forward"){const c=n-this._currentTime;if(s>=c){if(s-=c,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=s,s=0}else{const c=this._currentTime;if(s>=c){if(s-=c,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=s,s=0}const a=this.getStateAtTime(this._currentTime);this.onUpdate?.(a)}getStateAtTime(e){const n=new Map;if(this._hasSharedWrites())this._resolveShared(e,n);else for(const[r,s]of this._trackPlayers){const i=s.getTrack().property;for(const{target:a,value:o,start:c}of s.getTargetValues(e))this._write(n,r,a,i,o,e-c)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(e,n){const r=new Map;for(const[s,i]of this._trackPlayers){const a=i.getTrack().property;for(const{target:o,value:c,start:u}of i.getTargetValues(e)){const l=`${o}\0${a}`,f=u<=e,d=r.get(l);(!d||(f!==d.started?f:f?u>=d.start:u<=d.start))&&r.set(l,{trackId:s,target:o,property:a,value:c,start:u,started:f})}}for(const{trackId:s,target:i,property:a,value:o,start:c}of r.values())this._write(n,s,i,a,o,e-c)}_write(e,n,r,s,i,a){if(i===void 0)return;let o=e.get(r);o||(o=new Map,e.set(r,o));const c=this._textTracks.get(n);if(c&&typeof i=="number"){o.set("text",tn(c.textConfig,i,Math.max(0,a)));return}const u=this._motionPathTracks.get(n);if(u&&typeof i=="number"){const l=Qt(u.motionPathConfig,i);o.set("motionPathX",l.x),o.set("motionPathY",l.y),u.motionPathConfig.autoRotate&&o.set("motionPathRotate",l.angle)}else o.set(s,i)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const e=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const r of B(n)){const s=`${r}\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,z(e)){this._trackPlayers.set(e.id,new Ze(e));return}if(V(e)){this._trackPlayers.set(e.id,new qe(e)),this._springTracks.set(e.id,e);return}if(ct(e))this._trackPlayers.set(e.id,new yt(e)),this._textTracks.set(e.id,e);else if(Pt(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 yt(n)),this._motionPathTracks.set(e.id,e)}else this._trackPlayers.set(e.id,new yt(e))}replaceTrack(e,n){const r=this._tracks.findIndex(i=>i.id===e);if(r<0)return;const s=this._tracks.slice(r+1);this.removeTrack(e);for(const i of s)this.removeTrack(i.id);this.addTrack(n);for(const i of s)this.addTrack(i)}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(r=>r.id);for(const r of n)this.removeTrack(r);return n}getTrackSpan(e){const n=this._trackPlayers.get(e);if(!n)return;const r=n.getTrack(),s=r.delay??0;if(V(r)||z(r))return{from:s,to:n.getDuration()};const i=r.keyframes;if(!(!i||i.length===0))return{from:i[0].time+s,to:n.getDuration()}}findConflicts(){const e=[];for(let n=0;n<this._tracks.length;n++){const r=this._tracks[n],s=this.getTrackSpan(r.id);if(s)for(let i=0;i<n;i++){const a=this._tracks[i];if(a.property!==r.property)continue;const o=B(a).filter(f=>B(r).includes(f));if(o.length===0)continue;const c=this.getTrackSpan(a.id);if(!c||!(c.from<=s.to&&s.from<=c.to))continue;const l=s.from>=c.from;for(const f of o)e.push({target:f,property:r.property,losingTrackId:l?a.id:r.id,winningTrackId:l?r.id:a.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&&!B(e).includes(n.target))return!1;if(n.timeRange){const r=this.getTrackSpan(e.id);if(!r||r.to<n.timeRange.from||r.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:At(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,i)=>s.time-i.time).map(s=>({...s})):void 0,r={...this._config};n?r.markers=n:delete r.markers,this._config=r}get captions(){return this._captions}setCaptions(e){const n={};for(const[r,s]of Object.entries(e??{}))n[r]={...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 mr=100;function pr(t,e,n,r){const s=[],i=[],{duration:a,alternate:o}=r,c=(g,_,m,p)=>{i.push([g,_]);const T=[];t.forEach((b,A)=>{(m==="forward"?(p?b>=g:b>g)&&b<=_:(p?b<=g:b<g)&&b>=_)&&T.push(A)}),T.sort((b,A)=>(m==="forward"?t[b]-t[A]:t[A]-t[b])||b-A);for(const b of T)s.push({kind:"event",index:b,direction:m})};let u=e.time,l=e.direction,f=e.fresh===!0;const d=Math.min(mr,Math.max(0,n.iteration-e.iteration));for(let g=0;g<d;g++){const _=l==="forward"?a:0;c(u,_,l,f),s.push({kind:"repeat"}),o?(l=l==="forward"?"reverse":"forward",u=_,f=!1):(u=l==="forward"?0:a,f=!0)}return d>0&&r.holding&&!o?{crossings:s,passes:i}:(c(u,n.time,l,f),{crossings:s,passes:i})}function nn(t){return z(t)?{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:rn(t.inertia),...x(t)}:V(t)?{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...x(t)}:ct(t)?{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:t.keyframes.map(Kt),...x(t)}:Pt(t)?{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:t.keyframes.map(Kt),...x(t)}:{id:t.id,target:t.target,property:t.property,keyframes:t.keyframes.map(Kt),...t.interpolation!==void 0&&{interpolation:t.interpolation},...x(t)}}function rn(t){return{...t,...Array.isArray(t.end)&&{end:[...t.end]}}}function Kt(t){return{time:t.time,value:t.value,...t.easing&&{easing:t.easing}}}function x(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 sn(t){if(z(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:rn(e.inertia),...x(e)}}if(V(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...x(e)}}if(ct(t)){const e=t;return{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:[...e.keyframes].sort((n,r)=>n.time-r.time),...x(e)}}if(t.property==="motionPath"&&"motionPathConfig"in t){const e=t,n=[...e.keyframes].sort((r,s)=>r.time-s.time);return{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:n,...x(e)}}return We({id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,...t.interpolation!==void 0&&{interpolation:t.interpolation},...x(t)})}function an(t){const e=t._config.markers;return{formatVersion:At(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,...e&&{markers:e.map(n=>({...n}))}},tracks:t.tracks.map(nn),...t.captions&&{captions:JSON.parse(JSON.stringify(t.captions))}}}function on(t){const e=t.formatVersion??1;if(e>kt)throw new Error(`tinyfly: this animation uses format version ${e}, but this tinyfly reads up to version ${kt}. Update tinyfly to play it.`);return new en({id:t.id,name:t.name,config:t.config,tracks:t.tracks.map(sn),captions:t.captions})}function yr(t){return JSON.stringify(an(t))}function Mr(t){const e=JSON.parse(t);return on(e)}function _r(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 cn(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 Wt(t,e,n){return e+t.next()*(n-e)}function un(t,e,n,r){if(r<=0)return Wt(t,e,n);const s=Math.floor((n-e)/r),i=Math.round(t.next()*s);return e+i*r}function Tr(t,e){if(e.length!==0)return e[Math.floor(t.next()*e.length)]}const ln=/^([+\-*/])=\s*(-?[\d.]+)$/,hn=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function br(t){return typeof t!="string"?!1:ln.test(t.trim())||hn.test(t.trim())}function qt(t,e={}){if(typeof t!="string")return t;const n=t.trim(),r=ln.exec(n);if(r){const[,i,a]=r,o=e.base??0,c=Number.parseFloat(a);switch(i){case"+":return o+c;case"-":return o-c;case"*":return o*c;case"/":return c===0?o:o/c}}const s=hn.exec(n);if(s){if(!e.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const i=Number.parseFloat(s[1]),a=Number.parseFloat(s[2]),o=s[3]!==void 0?Number.parseFloat(s[3]):void 0;return o!==void 0?un(e.random,i,a,o):Wt(e.random,i,a)}return t}function fn(t,e=0,n){const r=[];let s=e;for(const i of t){const a=qt(i,{base:s,random:n});r.push(a),typeof a=="number"&&(s=a)}return r}class Sr{random;constructor(e){this.random=cn(e)}get seed(){return this.random.seed}resolve(e,n=0){return qt(e,{base:n,random:this.random})}resolveSequence(e,n=0){return fn(e,n,this.random)}}const kr=600;function Ar(t){if(Array.isArray(t)){const[d,g,_,m]=t;return{fn:dn(d,g,_,m),bezier:[d,g,_,m]}}const{segments:e}=j(t);if(e.length===0)throw new Error(`customEase: no curve in "${t}"`);const n=e[0].startX,r=e[0].startY,s=e[e.length-1],i=s.endX-n,a=s.endY-r;if(i===0||a===0)throw new Error(`customEase: "${t}" must move along both axes`);const o=d=>(d-n)/i,c=d=>(d-r)/a;if(e.length===1&&s.type==="C"){const[d,g,_,m]=s.points,p=[o(d),c(g),o(_),c(m)];return{fn:dn(...p),bezier:p}}const u=[],l=[],f=Math.max(8,Math.ceil(kr/e.length));for(const d of e)for(let g=u.length===0?0:1;g<=f;g++){const[_,m]=wr(d,g/f);u.push(o(_)),l.push(c(m))}return{fn:Ir(u,l)}}function Pr(t={}){const n=.1+Math.max(0,Math.min(1,t.strength??.7))*.7,r=[1];for(let i=n;i>.002;i*=n)r.push(2*Math.sqrt(i));const s=r.reduce((i,a)=>i+a,0);return i=>{if(i<=0)return 0;if(i>=1)return 1;let a=i*s;for(let o=0;o<r.length;o++){if(a<=r[o]){if(o===0)return(a/r[0])**2;const c=r[o]/2,u=c*c,l=a-c;return 1-(u-l*l)}a-=r[o]}return 1}}function vr(t={}){const e=Math.max(1,t.wiggles??10),n=t.type??"easeOut",r=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)*r(s)}function wr(t,e){if(t.type==="L"){const[u,l]=t.points;return[t.startX+(u-t.startX)*e,t.startY+(l-t.startY)*e]}const[n,r,s,i,a,o]=t.points,c=1-e;return[c*c*c*t.startX+3*c*c*e*n+3*c*e*e*s+e*e*e*a,c*c*c*t.startY+3*c*c*e*r+3*c*e*e*i+e*e*e*o]}function Ir(t,e){return n=>{if(n<=t[0])return e[0];if(n>=t[t.length-1])return e[e.length-1];let r=0,s=t.length-1;for(;s-r>1;){const a=r+s>>1;t[a]<=n?r=a:s=a}const i=t[s]-t[r];return i===0?e[s]:e[r]+(n-t[r])/i*(e[s]-e[r])}}function dn(t,e,n,r){const s=(a,o,c)=>3*(1-a)*(1-a)*a*o+3*(1-a)*a*a*c+a*a*a,i=(a,o,c)=>3*(1-a)*(1-a)*o+6*(1-a)*a*(c-o)+3*a*a*(1-c);return a=>{if(a<=0)return 0;if(a>=1)return 1;let o=a;for(let l=0;l<8;l++){const f=s(o,t,n)-a,d=i(o,t,n);if(Math.abs(f)<1e-6)return s(o,e,r);if(Math.abs(d)<1e-6)break;o-=f/d}let c=0,u=1;o=a;for(let l=0;l<40;l++)s(o,t,n)<a?c=o:u=o,o=(c+u)/2;return s(o,e,r)}}const Rr=350,Dr=300,Er=550;function Cr(t,e={}){const n=e.lead??Rr,r=e.gap??Dr,s=e.tail??Er,i=[];let a=0;return t.forEach((o,c)=>{const u=[];let l=a+n;o.lines.forEach((d,g)=>{if(!(d.duration>=0))throw new Error(`narration: scene ${c} line ${g} has an invalid duration (${d.duration})`);g>0&&(l+=r),u.push({id:d.id??`s${c}-l${g}`,scene:c,line:g,start:l,end:l+d.duration,text:d.text}),l+=d.duration});const f=l+s+(o.tail??0);i.push({id:o.id??`s${c}`,start:a,duration:f-a,cues:u}),a=f}),{duration:a,scenes:i,cues:i.flatMap(o=>o.cues)}}function $r(t){return t.cues.map(e=>({id:e.id,time:e.start,label:e.text}))}function Or(t,e){let n=t.scenes[0];for(const r of t.scenes)if(e>=r.start)n=r;else break;return n}const Zt=t=>6e4/t.bpm;function Mt(t,e){return t.offset+e*Zt(t)}function _t(t,e){return(e-t.offset)/Zt(t)}function Lr(t,e){return Mt(t,Math.round(_t(t,e)))}function Fr(t,e){return Mt(t,Math.ceil(_t(t,e)-1e-9))}function Nr(t,e,n){const r=Math.max(1,Math.round(t.beatsPerBar??4)),s=[];if(!(t.bpm>0)||n<e)return s;for(let i=Math.ceil(_t(t,e)-1e-9);;i++){const a=Mt(t,i);if(a>n+1e-9)break;s.push({time:a,bar:(i%r+r)%r===0,n:i})}return s}const Z=100;function xr(t,e,n={}){const r=n.minBpm??70,s=n.maxBpm??180,i=Math.max(1,Math.round(e/Z)),a=Math.min(t.length,Math.round((n.maxSeconds??60)*e)),o=Math.floor(a/i);if(o<4)return{bpm:120,offset:0,confidence:0};const c=new Float64Array(o);for(let y=0;y<o;y++){let S=0;for(let k=y*i;k<(y+1)*i;k++)S+=t[k]*t[k];c[y]=Math.log(1e-6+S/i)}const u=new Float64Array(o);for(let y=1;y<o;y++)u[y]=Math.max(0,c[y]-c[y-1]);const l=u.reduce((y,S)=>y+S,0)/o;for(let y=0;y<o;y++)u[y]=Math.max(0,u[y]-l);const f=Math.max(1,Math.floor(60*Z/s)),d=Math.min(o-1,Math.ceil(60*Z/r)),g=y=>{let S=0;for(let k=y;k<o;k++)S+=u[k]*u[k-y];return S/(o-y)};let _=0;for(let y=0;y<o;y++)_+=u[y]*u[y];_/=o;let m=f,p=-1/0;for(let y=f;y<=d;y++){const S=60*Z/y,k=Math.exp(-.5*(Math.log2(S/120)/.9)**2),P=g(y)*k;P>p&&(p=P,m=y)}const T=y=>{const S=Math.floor(y);return S<0||S+1>=o?0:u[S]+(u[S+1]-u[S])*(y-S)},b=(y,S)=>{let k=0;for(let P=S;P<o;P+=y)k+=T(P);return k};let A=m,w=0,M=-1/0;for(let y=m-.6;y<=m+.6+1e-9;y+=.02){if(y<1)continue;const S=Math.max(1,Math.round(y*4));for(let k=0;k<S;k++){const P=k/S*y,D=b(y,P);D>M&&(M=D,w=P,A=y)}}const I=60*Z/A,v=_>0?Math.max(0,Math.min(1,g(m)/_)):0,$=(w+.5)*1e3/Z;return{bpm:Math.round(I*100)/100,offset:Math.round($%(6e4/I)),confidence:v}}const X=t=>Math.round(t*1e3)/1e3;function Xr(t,e={}){if(t.length===0)return"";const n=e.curviness??1,r=e.closed??!1,s=t.length;let i=`M${X(t[0].x)} ${X(t[0].y)}`;if(s===1)return i;const a=c=>r?t[(c%s+s)%s]:t[Math.max(0,Math.min(s-1,c))],o=r?s:s-1;for(let c=0;c<o;c++){const u=a(c-1),l=a(c),f=a(c+1),d=a(c+2);if(n===0){i+=` L${X(f.x)} ${X(f.y)}`;continue}const g=n/6,_=l.x+(f.x-u.x)*g,m=l.y+(f.y-u.y)*g,p=f.x-(d.x-l.x)*g,T=f.y-(d.y-l.y)*g;i+=` C${X(_)} ${X(m)} ${X(p)} ${X(T)} ${X(f.x)} ${X(f.y)}`}return r?`${i} Z`:i}const C=(t,e=0)=>{const n=parseFloat(t??"");return Number.isFinite(n)?n:e};function zr(t){const e=(t??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let r=0;r+1<e.length;r+=2)n.push({x:e[r],y:e[r+1]});return n}function Vr(t){const e=t.attributes;switch(t.tag.toLowerCase()){case"path":return e.d??null;case"circle":case"ellipse":{const n=C(e.cx),r=C(e.cy),s=t.tag.toLowerCase()==="circle"?C(e.r):C(e.rx),i=t.tag.toLowerCase()==="circle"?C(e.r):C(e.ry);return`M${n+s} ${r} A${s} ${i} 0 1 1 ${n-s} ${r} A${s} ${i} 0 1 1 ${n+s} ${r} Z`}case"rect":{const n=C(e.x),r=C(e.y),s=C(e.width),i=C(e.height);let a=e.rx!=null?C(e.rx):e.ry!=null?C(e.ry):0,o=e.ry!=null?C(e.ry):a;return a=Math.min(a,s/2),o=Math.min(o,i/2),a===0||o===0?`M${n} ${r} H${n+s} V${r+i} H${n} Z`:`M${n+a} ${r} H${n+s-a} A${a} ${o} 0 0 1 ${n+s} ${r+o} V${r+i-o} A${a} ${o} 0 0 1 ${n+s-a} ${r+i} H${n+a} A${a} ${o} 0 0 1 ${n} ${r+i-o} V${r+o} A${a} ${o} 0 0 1 ${n+a} ${r} Z`}case"line":return`M${C(e.x1)} ${C(e.y1)} L${C(e.x2)} ${C(e.y2)}`;case"polyline":case"polygon":{const n=zr(e.points);if(n.length===0)return null;const r=n.map((s,i)=>`${i===0?"M":"L"}${s.x} ${s.y}`).join(" ");return t.tag.toLowerCase()==="polygon"?`${r} Z`:r}default:return null}}function Ur(t,e,n){const r=Math.max(2,Math.round(n.samples??32)),s=Math.max(0,n.length),i=n.since!==void 0?Math.max(e-s,n.since):e-s;if(i>=e)return[];const a=n.period,o=[];for(let c=0;c<r;c++){const u=i+(e-i)*c/(r-1),l=a&&a>0&&c<r-1?(u%a+a)%a:u;o.push({at:t(l),time:u,age:s>0?(e-u)/s:0})}return o}const Yr=2.5;function Br(t){const e=[],n=[],r=t.length,s=(i,a)=>{for(let o=i+a;o>=0&&o<r;o+=a){const c=(t[o].x-t[i].x)*a,u=(t[o].y-t[i].y)*a,l=Math.hypot(c,u);if(l>1e-9)return[c/l,u/l]}return null};for(let i=0;i<r;i++){const a=t[i],o=s(i,-1),c=s(i,1),u=o??c??[1,0],l=c??o??[1,0];let f=u[0]+l[0],d=u[1]+l[1];const g=Math.hypot(f,d);g<1e-9?(f=u[0],d=u[1]):(f/=g,d/=g);const _=f*u[0]+d*u[1],m=Math.min(Yr,1/Math.max(_,1e-6)),p=a.width/2*m;e.push({x:a.x-d*p,y:a.y+f*p}),n.push({x:a.x+d*p,y:a.y-f*p})}return{left:e,right:n}}function jr(t){const e=t.length;if(e<2)return null;const n=t[e-1];for(let r=e-2;r>=0;r--){const s=n.x-t[r].x,i=n.y-t[r].y,a=Math.hypot(s,i);if(a>1e-9)return{x:n.x,y:n.y,radius:n.width/2,start:Math.atan2(s/a,-i/a)}}return null}function Hr(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function Jt(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function gn(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Tt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function te(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 ee(t){return Math.hypot(t[0],t[1],t[2])}function Qr(t,e){return ee(Jt(t,e))}function ne(t){const e=ee(t);return e===0?[0,0,0]:gn(t,1/e)}function Gr(t,e,n){return[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n,t[2]+(e[2]-t[2])*n]}const Kr=Object.freeze(Object.defineProperty({__proto__:null,add:Hr,cross:te,distance:Qr,dot:Tt,length:ee,lerp:Gr,normalize:ne,scale:gn,subtract:Jt},Symbol.toStringTag,{value:"Module"})),Wr=Math.PI/180;function qr(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Zr(t,e){const n=new Array(16);for(let r=0;r<4;r++)for(let s=0;s<4;s++){let i=0;for(let a=0;a<4;a++)i+=t[a*4+s]*e[r*4+a];n[r*4+s]=i}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 ts(t){return[t[0],0,0,0,0,t[1],0,0,0,0,t[2],0,0,0,0,1]}function mn(t){const[e,n,r,s]=t;return[1-2*(n*n+r*r),2*(e*n+r*s),2*(e*r-n*s),0,2*(e*n-r*s),1-2*(e*e+r*r),2*(n*r+e*s),0,2*(e*r+n*s),2*(n*r-e*s),1-2*(e*e+n*n),0,0,0,0,1]}function es(t,e,n){const r=mn(e);for(let s=0;s<3;s++)r[s]*=n[0],r[4+s]*=n[1],r[8+s]*=n[2];return r[12]=t[0],r[13]=t[1],r[14]=t[2],r}function ns(t){const e=new Array(16);for(let n=0;n<4;n++)for(let r=0;r<4;r++)e[r*4+n]=t[n*4+r];return e}function rs(t){const[e,n,r,s,i,a,o,c,u,l,f,d,g,_,m,p]=t,T=e*a-n*i,b=e*o-r*i,A=e*c-s*i,w=n*o-r*a,M=n*c-s*a,I=r*c-s*o,v=u*_-l*g,$=u*m-f*g,y=u*p-d*g,S=l*m-f*_,k=l*p-d*_,P=f*p-d*m,D=T*P-b*k+A*S+w*y-M*$+I*v;if(Math.abs(D)<1e-12)return null;const R=1/D;return[(a*P-o*k+c*S)*R,(r*k-n*P-s*S)*R,(_*I-m*M+p*w)*R,(f*M-l*I-d*w)*R,(o*y-i*P-c*$)*R,(e*P-r*y+s*$)*R,(m*A-g*I-p*b)*R,(u*I-f*A+d*b)*R,(i*k-a*y+c*v)*R,(n*y-e*k-s*v)*R,(g*M-_*A+p*T)*R,(l*A-u*M-d*T)*R,(a*$-i*S-o*v)*R,(e*S-n*$+r*v)*R,(_*b-g*w-m*T)*R,(u*w-l*b+f*T)*R]}function ss(t,e,n,r){const s=1/Math.tan(t*Wr/2),i=1/(n-r);return[s/e,0,0,0,0,s,0,0,0,0,(r+n)*i,-1,0,0,2*r*n*i,0]}function is(t,e,n,r,s,i){const a=1/(e-t),o=1/(r-n),c=1/(i-s);return[2*a,0,0,0,0,2*o,0,0,0,0,-2*c,0,-(e+t)*a,-(r+n)*o,-(i+s)*c,1]}function as(t,e,n=[0,1,0]){const r=ne(Jt(t,e)),s=ne(te(n,r)),i=te(r,s);return[s[0],i[0],r[0],0,s[1],i[1],r[1],0,s[2],i[2],r[2],0,-Tt(s,t),-Tt(i,t),-Tt(r,t),1]}function os(t,e){const n=t[0]*e[0]+t[4]*e[1]+t[8]*e[2]+t[12],r=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],i=t[3]*e[0]+t[7]*e[1]+t[11]*e[2]+t[15];return i===1||i===0?[n,r,s]:[n/i,r/i,s/i]}const cs=Object.freeze(Object.defineProperty({__proto__:null,compose:es,fromQuat:mn,identity:qr,invert:rs,lookAt:as,multiply:Zr,orthographic:is,perspective:ss,scaling:ts,transformPoint:os,translation:Jr,transpose:ns},Symbol.toStringTag,{value:"Module"}));h.Clock=bn,h.DEFAULT_BAKE_INTERVAL_MS=Bt,h.DEFAULT_INERTIA_FRICTION=Rt,h.DEFAULT_SPRING=F,h.FORMAT_VERSION=kt,h.INERTIA_MAX_DURATION_MS=ce,h.InertiaTrackPlayer=Ze,h.MORPH_SAMPLES=Hn,h.ManualClock=Tn,h.SPRING_MAX_DURATION_MS=It,h.SPRING_PRESETS=kn,h.SPRING_STEP_MS=G,h.SpringSampler=tt,h.SpringTrackPlayer=qe,h.Timeline=en,h.TrackPlayer=yt,h.ValueResolver=Sr,h.backOut=_e,h.bakeEasing=Qe,h.bakeInertiaTrack=Ht,h.bakeSpringTrack=jt,h.beatAtTime=_t,h.beatLength=Zt,h.beatTime=Mt,h.beatsBetween=Nr,h.bounceOut=Me,h.charactersFor=Je,h.clearMorphCache=er,h.clearPathCache=Vn,h.createCubicBezier=pe,h.createRandom=cn,h.createTrack=We,h.criticalDamping=wn,h.customBounce=Pr,h.customEase=Ar,h.customWiggle=vr,h.deserializeTimeline=on,h.deserializeTrack=sn,h.detectTempo=xr,h.easeIn=de,h.easeInCubic=Dt,h.easeInOut=me,h.easeInOutCubic=Ct,h.easeInOutQuad=fe,h.easeInQuad=le,h.easeOut=ge,h.easeOutCubic=Et,h.easeOutQuad=he,h.elasticOut=ye,h.expandParametricEasings=Ge,h.formatVersionFor=At,h.fromJSON=Mr,h.getEasingFunction=Ot,h.getInterpolator=Yt,h.getMotionPathPoint=Qt,h.getPathLength=Un,h.getPointAtProgress=Ae,h.hasKeyframes=ie,h.hashSeed=_r,h.heldTime=Sn,h.inertiaDuration=nt,h.inertiaRest=et,h.inertiaValueAt=ft,h.inertiaVelocityAt=En,h.interpolateArray=Ye,h.interpolateColor=Ue,h.interpolateMotionPath=fr,h.interpolateNumber=N,h.interpolatePathString=je,h.interpolateQuaternion=Be,h.interpolateString=Ut,h.isCubicBezierEasing=Q,h.isInertiaTrack=z,h.isMotionPathPoint=_n,h.isMotionPathTrack=Pt,h.isParametricEasing=ot,h.isPathData=Ce,h.isSpringTrack=V,h.isTextTrack=ct,h.isUnderdamped=vn,h.isUnresolved=br,h.linear=dt,h.mat4=cs,h.maxStaggerDistance=ae,h.morphPath=Ee,h.narrationMarkers=$r,h.narrationSceneAt=Or,h.naturalRest=ue,h.nearestBeat=Lr,h.nextBeat=Fr,h.parametricEasing=be,h.parsePath=j,h.planNarration=Cr,h.playheadCrossings=pr,h.pointAtDistance=Lt,h.pointsToPath=Xr,h.quat=or,h.randomBetween=Wt,h.randomChoice=Tr,h.randomSnapped=un,h.resolveSequence=fn,h.resolveValue=qt,h.ribbon=Br,h.ribbonHeadCap=jr,h.serializeTimeline=an,h.serializeTrack=nn,h.shapeToPathData=Vr,h.simplifyKeyframes=Ke,h.springDuration=Pn,h.springValueAt=An,h.staggerDistance=vt,h.staggerOffset=wt,h.staggerOffsets=oe,h.staggerSpan=ut,h.stepsEasing=Te,h.textAt=tn,h.toJSON=yr,h.toKeyframedTrack=lr,h.toKeyframedTracks=hr,h.trackTargets=B,h.trailSamples=Ur,h.vec3=Kr,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(f,Q){typeof exports=="object"&&typeof module<"u"?Q(exports):typeof define=="function"&&define.amd?define(["exports"],Q):(f=typeof globalThis<"u"?globalThis:f||self,Q(f.tinyfly={}))})(this,(function(f){"use strict";function Q(t){return typeof t=="object"&&t!==null&&t.type==="cubic-bezier"}function ot(t){return typeof t=="object"&&t!==null&&t.type!=="cubic-bezier"}const St=2;function At(t){return t.some(e=>e.interpolation!==void 0)?2:1}function ct(t){return t.property==="text"&&"textConfig"in t}function z(t){return t.kind==="inertia"&&"inertia"in t}function Y(t){return t.kind==="spring"&&"spring"in t}function Pt(t){return t.property==="motionPath"&&"motionPathConfig"in t}function Tn(t){return typeof t=="object"&&t!==null&&"x"in t&&"y"in t&&"angle"in t}function oe(t){return"keyframes"in t}class bn{_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 kn{_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 r=(e-this._lastFrameTime)*this._speed;this._currentTime+=r,this.onTick?.(r,this._currentTime)}this._lastFrameTime=e,this._scheduleFrame()}}}function Sn(t,e){if(!(e>0))return t;const n=1e3/e;return Math.floor(t/n+1e-9)*n}function wt(t,e,n="start"){if(e<=1)return 0;if(typeof n=="number"){const r=Math.max(0,Math.min(e-1,n));return Math.abs(t-r)}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 ce(t,e="start"){if(t<=1)return 0;let n=0;for(let r=0;r<t;r++)n=Math.max(n,wt(r,t,e));return n}function vt(t,e,n){if(n.offsets)return n.offsets[t]??0;const r=n.from??"start",s=wt(t,e,r);if(n.amount!==void 0){const a=ce(e,r);return a===0?0:n.amount*s/a}return n.each!==void 0?n.each*s:0}function ue(t,e){return Array.from({length:t},(n,r)=>vt(r,t,e))}function ut(t,e){return t<=1?0:Math.max(...ue(t,e))}const G=1,It=6e4,lt=It/G,x={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},An={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 tt{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??x.stiffness,this.damping=e.damping??x.damping,this.mass=e.mass??x.mass,this.restDelta=e.restDelta??x.restDelta,this.restSpeed=e.restSpeed??x.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=e.velocity??x.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/G);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const r=this.samples[Math.min(n,this.samples.length-1)],s=this.samples[Math.min(n+1,this.samples.length-1)],a=e/G-n;return r+(s-r)*a}settleTime(){return this.simulateTo(lt+1),this.settledStep!==null?this.settledStep*G:It}simulateTo(e){if(this.settledStep!==null)return;const n=Math.min(e,lt+1),r=G/1e3;for(;this.samples.length<n;){const s=this.samples[this.samples.length-1],a=s-this.to,i=-this.stiffness*a,o=-this.damping*this.velocity,c=(i+o)/this.mass;this.velocity+=c*r;const l=s+this.velocity*r;if(this.samples.push(l),this.isAtRest(l)){this.settledStep=this.samples.length-1;return}}this.samples.length>lt&&(this.settledStep=lt)}}function Pn(t,e){return new tt(t).valueAt(e)}function wn(t){return new tt(t).settleTime()}function vn(t){const e=t.stiffness??x.stiffness,n=t.damping??x.damping,r=t.mass??x.mass;return n<2*Math.sqrt(e*r)}function In(t){const e=t.stiffness??x.stiffness,n=t.mass??x.mass;return 2*Math.sqrt(e*n)}const Rt=4,Rn=.002,En=1e-4,le=6e4;function ht(t){const e=t.friction??Rt;return e>0?e:Rt}function he(t){return t.from+t.velocity/ht(t)}function Dn(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 r of e)Math.abs(r-t)<Math.abs(n-t)&&(n=r);return n}function et(t){let e=Dn(he(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 nt(t){const e=Math.abs(et(t)-t.from);if(e===0)return 0;const n=t.restDelta??Math.max(En,e*Rn);if(n>=e)return 0;const r=Math.log(e/n)/ht(t);return Math.min(le,r*1e3)}function ft(t,e){if(e<=0)return t.from;const n=et(t);if(e>=nt(t))return n;const r=ht(t);return t.from+(n-t.from)*(1-Math.exp(-r*e/1e3))}function Cn(t,e){const n=ht(t),r=et(t);return e>=nt(t)?0:(r-t.from)*n*Math.exp(-n*Math.max(0,e)/1e3)}const dt=t=>t,fe=t=>t*t,de=t=>1-(1-t)*(1-t),ge=t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,Et=t=>t*t*t,Dt=t=>1-Math.pow(1-t,3),Ct=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,me=Et,pe=Dt,ye=Ct,$n={linear:dt,"ease-in":me,"ease-out":pe,"ease-in-out":ye,"ease-in-quad":fe,"ease-out-quad":de,"ease-in-out-quad":ge,"ease-in-cubic":Et,"ease-out-cubic":Dt,"ease-in-out-cubic":Ct};function Me(t){const[e,n,r,s]=t,a=3*e,i=3*(r-e)-a,o=1-a-i,c=3*n,l=3*(s-n)-c,h=1-c-l,u=m=>((o*m+i)*m+a)*m,d=m=>((h*m+l)*m+c)*m,g=m=>(3*o*m+2*i)*m+a,y=m=>{let p=m;for(let A=0;A<8;A++){const P=u(p)-m;if(Math.abs(P)<1e-7)return p;const b=g(p);if(Math.abs(b)<1e-7)break;p-=P/b}let _=0,M=1;for(p=m;_<M;){const A=u(p);if(Math.abs(A-m)<1e-7)return p;m>A?_=p:M=p,p=(_+M)/2}return p};return m=>{if(m<=0)return 0;if(m>=1)return 1;const p=y(m);return d(p)}}function $t(t,e="out"){if(e==="out")return t;const n=r=>1-t(1-r);return e==="in"?n:r=>r<.5?n(r*2)/2:t(r*2-1)/2+.5}function _e(t=1,e=.3){const n=Math.max(1,t),r=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-r)*(2*Math.PI)/e)+1}const Te=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 r=t-2.625/2.75;return 7.5625*r*r+.984375};function be(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 ke(t,e="end"){const n=Math.max(1,Math.floor(t));return r=>{if(r>=1)return 1;if(r<=0)return e==="start"||e==="both"?e==="start"?1/n:1/(n+1):0;const s=Math.floor(r*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 Se(t){switch(t.type){case"steps":return ke(t.count,t.position);case"elastic":return $t(_e(t.amplitude,t.period),t.mode);case"bounce":return $t(Te,t.mode);case"back":return $t(be(t.overshoot),t.mode)}}function Ot(t){return t===void 0?dt:Q(t)?Me(t.points):ot(t)?Se(t):$n[t]??dt}const Ae=32,On=256,K=new Map,Ln=/[MmLlHhVvCcSsQqTtAaZz]/,xn=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Fn={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Nn(t){const e=[];let n=0,r=null;const s=()=>{for(;n<t.length&&/[\s,]/.test(t[n]);)n++};for(;n<t.length&&(s(),!(n>=t.length));){const a=t[n];if(Ln.test(a)){r={type:a,args:[]},e.push(r),n++;continue}if(!r)break;const i=r.type==="A"||r.type==="a",o=r.args.length%7;if(i&&(o===3||o===4)){if(a!=="0"&&a!=="1")break;r.args.push(a==="1"?1:0),n++;continue}const c=xn.exec(t.slice(n));if(!c)break;r.args.push(parseFloat(c[0])),n+=c[0].length}return e}function Xn(t,e,n,r,s,a,i,o,c){if(t===o&&e===c)return[];let l=Math.abs(n),h=Math.abs(r);if(l===0||h===0)return[[t,e,o,c,o,c]];const u=s*Math.PI/180,d=Math.cos(u),g=Math.sin(u),y=(t-o)/2,m=(e-c)/2,p=d*y+g*m,_=-g*y+d*m,M=p*p/(l*l)+_*_/(h*h);if(M>1){const D=Math.sqrt(M);l*=D,h*=D}const A=a===i?-1:1,P=l*l*h*h-l*l*_*_-h*h*p*p,b=l*l*_*_+h*h*p*p,I=A*Math.sqrt(Math.max(0,P/b)),v=I*l*_/h,$=-I*h*p/l,T=d*v-g*$+(t+o)/2,k=g*v+d*$+(e+c)/2,S=(D,O,L,J)=>{const ie=D*L+O*J,kt=Math.sqrt((D*D+O*O)*(L*L+J*J)),it=Math.acos(Math.max(-1,Math.min(1,ie/kt)));return D*J-O*L<0?-it:it},w=S(1,0,(p-v)/l,(_-$)/h);let E=S((p-v)/l,(_-$)/h,(-p-v)/l,(-_-$)/h);!i&&E>0&&(E-=2*Math.PI),i&&E<0&&(E+=2*Math.PI);const R=Math.max(1,Math.ceil(Math.abs(E)/(Math.PI/2))),ae=E/R,bt=4/3*Math.tan(ae/4),yn=D=>{const O=l*Math.cos(D),L=h*Math.sin(D);return[d*O-g*L+T,g*O+d*L+k]},Mn=D=>{const O=-l*Math.sin(D),L=h*Math.cos(D);return[d*O-g*L,g*O+d*L]},_n=[];for(let D=0;D<R;D++){const O=w+D*ae,L=O+ae,[J,ie]=yn(O),[kt,it]=D===R-1?[o,c]:yn(L),[ds,gs]=Mn(O),[ms,ps]=Mn(L);_n.push([J+bt*ds,ie+bt*gs,kt-bt*ms,it-bt*ps,kt,it])}return _n}function U(t,e,n,r,s){const a=1-s;return a*a*a*t+3*a*a*s*e+3*a*s*s*n+s*s*s*r}function Pe(t,e,n,r,s){const a=1-s;return 3*a*a*(e-t)+6*a*s*(n-e)+3*s*s*(r-n)}function rt(t,e,n,r){return{subpath:0,type:"L",points:[n,r],startX:t,startY:e,endX:n,endY:r,length:Math.hypot(n-t,r-e)}}function gt(t,e,n){const[r,s,a,i,o,c]=n,l=[0];let h=t,u=e,d=0;for(let g=1;g<=Ae;g++){const y=g/Ae,m=U(t,r,a,o,y),p=U(e,s,i,c,y);d+=Math.hypot(m-h,p-u),l.push(d),h=m,u=p}return{subpath:0,type:"C",points:[r,s,a,i,o,c],startX:t,startY:e,endX:o,endY:c,length:d,lengths:l}}function B(t){const e=K.get(t);if(e)return e;const n=[];let r=0,s=0,a=0,i=0,o=null,c=null,l=-1;const h=new Set,u=m=>{l<0&&(l=0),m.subpath=l,n.push(m)};for(const{type:m,args:p}of Nn(t)){const _=m.toUpperCase(),M=m!==_,A=Fn[_];if(_==="Z"){(r!==a||s!==i)&&u(rt(r,s,a,i)),l>=0&&h.add(l),r=a,s=i,o=c=null;continue}for(let P=0;P+A<=p.length;P+=A){const b=p.slice(P,P+A),I=M?r:0,v=M?s:0;let $=null,T=null;switch(_){case"M":P===0?(r=b[0]+I,s=b[1]+v,a=r,i=s,(l<0||n[n.length-1]?.subpath===l)&&l++):(u(rt(r,s,b[0]+I,b[1]+v)),r=b[0]+I,s=b[1]+v);break;case"L":u(rt(r,s,b[0]+I,b[1]+v)),r=b[0]+I,s=b[1]+v;break;case"H":u(rt(r,s,b[0]+I,s)),r=b[0]+I;break;case"V":u(rt(r,s,r,b[0]+v)),s=b[0]+v;break;case"C":{const k=[b[0]+I,b[1]+v,b[2]+I,b[3]+v,b[4]+I,b[5]+v];u(gt(r,s,k)),$=[k[2],k[3]],r=k[4],s=k[5];break}case"S":{const[k,S]=o?[2*r-o[0],2*s-o[1]]:[r,s],w=[k,S,b[0]+I,b[1]+v,b[2]+I,b[3]+v];u(gt(r,s,w)),$=[w[2],w[3]],r=w[4],s=w[5];break}case"Q":case"T":{let k=r,S=s;_==="Q"?(k=b[0]+I,S=b[1]+v):c&&(k=2*r-c[0],S=2*s-c[1]);const w=_==="Q"?b[2]+I:b[0]+I,E=_==="Q"?b[3]+v:b[1]+v;u(gt(r,s,[r+2/3*(k-r),s+2/3*(S-s),w+2/3*(k-w),E+2/3*(S-E),w,E])),T=[k,S],r=w,s=E;break}case"A":{const k=b[5]+I,S=b[6]+v;let w=r,E=s;for(const R of Xn(r,s,b[0],b[1],b[2],b[3],b[4],k,S))u(gt(w,E,R)),w=R[4],E=R[5];r=k,s=S;break}}o=$,c=T}}const d=n.reduce((m,p)=>m+p.length,0),g=[];for(let m=0;m<n.length;){const p=n[m].subpath;let _=m,M=0;for(;_<n.length&&n[_].subpath===p;)M+=n[_++].length;const A=n[m],P=n[_-1],b=h.has(p)||Math.abs(P.endX-A.startX)<1e-9&&Math.abs(P.endY-A.startY)<1e-9;g.push({start:m,end:_,length:M,closed:b}),m=_}const y={segments:n,totalLength:d,subpaths:g};return K.size>=On&&K.delete(K.keys().next().value),K.set(t,y),y}function zn(t,e){const n=t.lengths;if(e<=0)return 0;if(e>=t.length)return 1;let r=0,s=n.length-1;for(;r<s-1;){const o=r+s>>1;n[o]<e?r=o:s=o}const a=n[s]-n[r],i=a>0?(e-n[r])/a:0;return(r+i)/(n.length-1)}function Yn(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,r,s,a,i,o]=t.points,c=zn(t,e);let l=Pe(t.startX,n,s,i,c),h=Pe(t.startY,r,a,o,c);if(Math.hypot(l,h)<1e-9){const u=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),d=U(t.startX,n,s,i,u),g=U(t.startY,r,a,o,u),y=U(t.startX,n,s,i,c),m=U(t.startY,r,a,o,c);l=c<.5?d-y:y-d,h=c<.5?g-m:m-g}return{x:U(t.startX,n,s,i,c),y:U(t.startY,r,a,o,c),angle:Math.atan2(h,l)*180/Math.PI}}function Lt(t,e,n=0,r=t.length){if(r<=n)return{x:0,y:0,angle:0};let s=0;for(let a=n;a<r;a++){const i=t[a];if(s+i.length>=e||a===r-1)return Yn(i,e-s);s+=i.length}return{x:0,y:0,angle:0}}function we(t,e){const{segments:n,totalLength:r}=B(t);return Lt(n,Math.max(0,Math.min(1,e))*r)}function Un(){K.clear()}function Vn(t){return B(t).totalLength}const jn=24,Bn=320,Hn=2.5,st=72,Qn=64,Gn=.2,Kn=128,at=new Map;let mt=0,V;const ve=t=>Math.round(t*100)/100;function Ie(t,e){const{segments:n,subpaths:r,totalLength:s}=B(t);if(n.length===0)return[];if(e){const a=r.every(i=>i.closed);return[{segments:n,start:0,end:n.length,length:s,closed:a}]}return r.filter(a=>a.length>0).map(a=>({segments:n,start:a.start,end:a.end,length:a.length,closed:a.closed}))}function xt(t,e){const n=t.closed?(e%1+1)%1:Math.max(0,Math.min(1,e)),r=Lt(t.segments,n*t.length,t.start,t.end);return[r.x,r.y]}function Re(t){const e=[];let n=0;for(let r=t.start;r<t.end;r++)n+=t.segments[r].length,t.length>0&&e.push(n/t.length);return e}function Ee(t,e){const n=[];for(let r=0;r<e;r++)n.push(xt(t,t.closed?r/e:r/(e-1)));return n}function De(t){let e=0,n=0;for(const[r,s]of t)e+=r,n+=s;return e/=t.length,n/=t.length,t.map(([r,s])=>[r-e,s-n])}function Wn(t,e,n){const r=t.closed&&e.closed;if(n!==void 0)return{offset:r?Math.abs(n)%st/st:0,reversed:n<0};const s=De(Ee(t,st)),a=De(Ee(e,st)),i=st;let o={offset:0,reversed:!1},c=1/0;for(const l of[!1,!0]){const h=r?i:1;for(let u=0;u<h;u++){let d=0;for(let g=0;g<i&&d<c;g++){const y=r?l?(u-g+i)%i:(g+u)%i:l?i-1-g:g,m=s[g][0]-a[y][0],p=s[g][1]-a[y][1];d+=m*m+p*p}d<c&&(c=d,o={offset:r?u/i:0,reversed:l})}}return o}function qn(t,e,n){return n?((e.reversed?e.offset-t:t+e.offset)%1+1)%1:e.reversed?1-t:t}function Zn(t,e,n){return n?((e.reversed?e.offset-t:t-e.offset)%1+1)%1:e.reversed?1-t:t}function Jn(t,e,n){const r=t.closed&&e.closed,s=Wn(t,e,n.shapeIndex),a=Math.max(jn,Math.min(Bn,Math.ceil(Math.max(t.length,e.length)/Hn))),i=new Set,o=u=>i.add(Math.round(u*1e7)/1e7);for(let u=0;u<=a;u++)o(u/a);for(const u of Re(t))o(u);for(const u of Re(e))o(Zn(u,s,r));let c=[...i].sort((u,d)=>u-d);r&&(c=c.filter(u=>u<1));const l=[],h=[];for(const u of c)l.push(...xt(t,u)),h.push(...xt(e,qn(u,s,r)));return tr({from:l,to:h,closed:r})}function tr(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 r=[[0,e-1]];for(;r.length>0;){const[i,o]=r.pop();let c=-1,l=Gn;for(let h=i+1;h<o;h++){const u=Math.max(Ce(t.from,i,o,h),Ce(t.to,i,o,h));u>l&&(l=u,c=h)}c!==-1&&(n[c]=1,r.push([i,c],[c,o]))}const s=[],a=[];for(let i=0;i<e;i++)n[i]&&(s.push(t.from[i*2],t.from[i*2+1]),a.push(t.to[i*2],t.to[i*2+1]));return{from:s,to:a,closed:t.closed}}function Ce(t,e,n,r){const s=t[e*2],a=t[e*2+1],i=t[n*2]-s,o=t[n*2+1]-a,c=t[r*2]-s,l=t[r*2+1]-a,h=i*i+o*o,u=h===0?0:Math.max(0,Math.min(1,(c*i+l*o)/h));return Math.hypot(c-u*i,l-u*o)}function er(t,e,n){const r=n.shapeIndex;if(V&&V.from===t&&V.to===e&&V.shapeIndex===r)return V.plan;const a=at.get(String(r??"auto"))?.get(t)?.get(e);if(a)return V={from:t,to:e,shapeIndex:r,plan:a},a;const i=B(t).subpaths.filter(g=>g.length>0).length===B(e).subpaths.filter(g=>g.length>0).length,o=Ie(t,!i),c=Ie(e,!i),l={pairs:o.map((g,y)=>Jn(g,c[y],n))};mt>=Kn&&(at.clear(),mt=0);const h=String(r??"auto"),u=at.get(h)??new Map;at.set(h,u);const d=u.get(t)??new Map;return u.set(t,d),d.set(e,l),mt++,V={from:t,to:e,shapeIndex:r,plan:l},l}function $e(t,e,n,r={}){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 a=er(t,e,r);if(a.pairs.length===0)return s<.5?t:e;let i="";for(const o of a.pairs){for(let c=0;c<o.from.length;c+=2){const l=ve(o.from[c]+(o.to[c]-o.from[c])*s),h=ve(o.from[c+1]+(o.to[c+1]-o.from[c+1])*s);i+=`${c===0?i?" M":"M":" L"}${l} ${h}`}o.closed&&(i+=" Z")}return i}function nr(){at.clear(),mt=0,V=void 0}function Oe(t){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(t)}const W=Math.PI/180,rr=.9995;function Ft(){return[0,0,0,1]}function pt(t,e){const n=Math.hypot(t[0],t[1],t[2]);if(n===0)return Ft();const r=e*W/2,s=Math.sin(r)/n;return[t[0]*s,t[1]*s,t[2]*s,Math.cos(r)]}function sr(t,e,n){return Nt(Nt(pt([0,1,0],e),pt([1,0,0],t)),pt([0,0,1],n))}function ar(t){const[e,n,r,s]=H(t),a=2*(e*r+n*s),i=2*(e*n+r*s),o=1-2*(e*e+r*r),c=2*(n*r-e*s),l=1-2*(n*n+r*r),h=2*(e*r-n*s),u=1-2*(e*e+n*n),d=Math.asin(Math.max(-1,Math.min(1,-c)));return Math.abs(c)<.9999999?[d/W,Math.atan2(a,u)/W,Math.atan2(i,o)/W]:[d/W,Math.atan2(-h,l)/W,0]}function Nt(t,e){const[n,r,s,a]=t,[i,o,c,l]=e;return[a*i+n*l+r*c-s*o,a*o-n*c+r*l+s*i,a*c+n*o-r*i+s*l,a*l-n*i-r*o-s*c]}function Le(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function xe(t){return Math.hypot(t[0],t[1],t[2],t[3])}function H(t){const e=xe(t);return e===0?Ft():[t[0]/e,t[1]/e,t[2]/e,t[3]/e]}function ir(t){return[-t[0],-t[1],-t[2],t[3]]}function Fe(t,e,n){const r=H(t);let s=H(e),a=Le(r,s);if(a<0&&(s=[-s[0],-s[1],-s[2],-s[3]],a=-a),a>rr)return H([r[0]+(s[0]-r[0])*n,r[1]+(s[1]-r[1])*n,r[2]+(s[2]-r[2])*n,r[3]+(s[3]-r[3])*n]);const i=Math.acos(a),o=Math.sin(i),c=Math.sin((1-n)*i)/o,l=Math.sin(n*i)/o;return H([r[0]*c+s[0]*l,r[1]*c+s[1]*l,r[2]*c+s[2]*l,r[3]*c+s[3]*l])}function or(t,e){const[n,r,s,a]=H(t),i=2*(r*e[2]-s*e[1]),o=2*(s*e[0]-n*e[2]),c=2*(n*e[1]-r*e[0]);return[e[0]+a*i+(r*c-s*o),e[1]+a*o+(s*i-n*c),e[2]+a*c+(n*o-r*i)]}const cr=Object.freeze(Object.defineProperty({__proto__:null,conjugate:ir,dot:Le,fromAxisAngle:pt,fromEuler:sr,identity:Ft,length:xe,multiply:Nt,normalize:H,rotateVec3:or,slerp:Fe,toEuler:ar},Symbol.toStringTag,{value:"Module"})),F=(t,e,n)=>t+(e-t)*n,Ne=512,Xt=new Map,zt=new Map;function Xe(t){const e=Xt.get(t);if(e)return e;const n=t.replace("#",""),r=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return Xt.size<Ne&&Xt.set(t,r),r}const ze=t=>t.charCodeAt(0)===35,Ye=t=>t.startsWith("rgb"),Ue=t=>t.startsWith("rgba"),ur=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Yt=t=>Math.round(t).toString(16).padStart(2,"0");function lr(t,e,n){return`#${Yt(t)}${Yt(e)}${Yt(n)}`}function Ve(t){const e=zt.get(t);if(e)return e;const n=t.match(ur);if(!n)throw new Error(`Invalid rgb color: ${t}`);const r=parseInt(n[1],10),s=parseInt(n[2],10),a=parseInt(n[3],10),i=n[4]!==void 0?[r,s,a,parseFloat(n[4])]:[r,s,a];return zt.size<Ne&&zt.set(t,i),i}const je=(t,e,n)=>{if(ze(t)&&ze(e)){const[r,s,a]=Xe(t),[i,o,c]=Xe(e),l=F(r,i,n),h=F(s,o,n),u=F(a,c,n);return lr(l,h,u)}if((Ye(t)||Ue(t))&&(Ye(e)||Ue(e))){const r=Ve(t),s=Ve(e),a=Math.round(F(r[0],s[0],n)),i=Math.round(F(r[1],s[1],n)),o=Math.round(F(r[2],s[2],n));if(r.length===4||s.length===4){const c=r[3]??1,l=s[3]??1,h=F(c,l,n);return`rgba(${a}, ${i}, ${o}, ${h})`}return`rgb(${a}, ${i}, ${o})`}return n<1?t:e},Be=(t,e,n)=>{const r=Math.min(t.length,e.length),s=[];for(let a=0;a<r;a++)s.push(F(t[a],e[a],n));return s},He=(t,e,n)=>Fe(t,e,n),Ut=(t,e,n)=>n<1?t:e,Qe=(t,e,n)=>$e(t,e,n);function Vt(t,e){return e==="slerp"?He:typeof t=="number"?F:Array.isArray(t)?Be:typeof t=="string"?t.startsWith("#")||t.startsWith("rgb")?je:Oe(t)?Qe:Ut:Ut}const jt=1e3/60;function Bt(t,e={}){if(!Y(t))throw new Error(`bakeSpringTrack: track "${t.id}" is not a spring track`);const n=new tt(t.spring);return Ge(t,r=>n.valueAt(r),n.settleTime(),t.spring.from,t.spring.to,e)}function Ht(t,e={}){if(!z(t))throw new Error(`bakeInertiaTrack: track "${t.id}" is not an inertia track`);const n=t.inertia;return Ge(t,r=>ft(n,r),nt(n),n.from,et(n),e)}function Ge(t,e,n,r,s,a){const i=a.intervalMs??jt,o=a.tolerance??.01,c=t.delay??0,l=[];for(let u=0;u<=n;u+=i)l.push({time:u+c,value:e(u),easing:"linear"});const h=l[l.length-1];return!h||h.time<n+c?l.push({time:n+c,value:s,easing:"linear"}):h.value=s,c>0&&l.unshift({time:0,value:r,easing:"linear"}),{id:t.id,target:t.target,property:t.property,keyframes:o>0?qe(l,o):l,...t.targets&&{targets:[...t.targets]},...t.stagger&&{stagger:{...t.stagger}}}}function Ke(t,e,n,r={}){const s=r.intervalMs??jt,a=typeof n=="function"?n:Ot(n),i=Vt(t.value,r.interpolation),o=e.time-t.time;if(o<=0)return[e];const c=[];for(let h=s;h<o;h+=s){const u=h/o;c.push({time:t.time+h,value:i(t.value,e.value,a(u)),easing:"linear"})}const l=a(1);return c.push({...e,...l!==1&&{value:i(t.value,e.value,l)},easing:"linear"}),c}function hr(t,e){return Y(t)?Bt(t,e):z(t)?Ht(t,e):t}function We(t,e={}){const n=t.keyframes;if(!n.some(a=>ot(a.easing)))return t;const r=n.length>0?[n[0]]:[],s={...e,interpolation:t.interpolation??e.interpolation};for(let a=1;a<n.length;a++){const i=n[a];ot(i.easing)?r.push(...Ke(n[a-1],i,i.easing,s)):r.push(i)}return{...t,keyframes:r}}function fr(t,e){return t.filter(oe).map(n=>We(n,e)).concat(t.filter(Y).map(n=>Bt(n,e)),t.filter(z).map(n=>Ht(n,e)))}function qe(t,e){if(t.length<=2)return t;const n=[t[0]];for(let r=1;r<t.length-1;r++){const s=n[n.length-1],a=t[r],i=t[r+1],o=i.time-s.time;if(o<=0)continue;const c=(a.time-s.time)/o,l=s.value+(i.value-s.value)*c;Math.abs(a.value-l)>e&&n.push(a)}return n.push(t[t.length-1]),n}function Ze(t){const e=[...t.keyframes].sort((n,r)=>n.time-r.time);return{...t,keyframes:e}}function j(t){return t.targets&&t.targets.length>0?t.targets:[t.target]}function q(t,e,n,r){const s=n??0;return!r||e<=1?s:s+vt(t,e,r)}class yt{track;targets;constructor(e){this.track=e,this.targets=j(e)}getValueAtTime(e){return this.valueForOffset(e-q(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const a=q(s,n,this.track.delay,this.track.stagger),i=this.valueForOffset(e-a);i!==void 0&&r.push({target:this.targets[s],value:i,start:a+this.track.keyframes[0].time})}return r}getDuration(){const{keyframes:e}=this.track;if(e.length===0)return 0;const n=e[e.length-1].time,r=this.track.stagger?ut(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+r+(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:r,to:s}=this.findSurroundingKeyframes(e);if(!r||!s)return;if(r.time===e)return r.value;const a=s.time-r.time,i=(e-r.time)/a,c=Ot(s.easing)(i);return Vt(r.value,this.track.interpolation)(r.value,s.value,c)}findSurroundingKeyframes(e){const{keyframes:n}=this.track;for(let r=0;r<n.length-1;r++)if(e>=n[r].time&&e<=n[r+1].time)return{from:n[r],to:n[r+1]};return{from:null,to:null}}}class Je{track;targets;sampler;constructor(e){this.track=e,this.targets=j(e),this.sampler=new tt(e.spring)}getValueAtTime(e){return this.sampler.valueAt(e-q(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const a=q(s,n,this.track.delay,this.track.stagger);r.push({target:this.targets[s],value:this.sampler.valueAt(e-a),start:a})}return r}getDuration(){const e=this.track.stagger?ut(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+e}getTrack(){return this.track}}class tn{track;targets;duration;constructor(e){this.track=e,this.targets=j(e),this.duration=nt(e.inertia)}getValueAtTime(e){return ft(this.track.inertia,e-q(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(e){const n=this.targets.length,r=[];for(let s=0;s<n;s++){const a=q(s,n,this.track.delay,this.track.stagger);r.push({target:this.targets[s],value:ft(this.track.inertia,e-a),start:a})}return r}getDuration(){const e=this.track.stagger?ut(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+e}getTrack(){return this.track}}function Qt(t,e){const n={...we(t.pathData,e)};if(t.matrix){const[r,s,a,i,o,c]=t.matrix,{x:l,y:h}=n;n.x=r*l+a*h+o,n.y=s*l+i*h+c;const u=n.angle*Math.PI/180,d=Math.cos(u),g=Math.sin(u);n.angle=Math.atan2(s*d+i*g,r*d+a*g)*180/Math.PI}return t.autoRotate&&t.rotateOffset&&(n.angle+=t.rotateOffset),n}function dr(t,e,n,r){const s=e+(n-e)*r;return Qt(t,s)}const Gt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},gr=20;function en(t){const e=Gt[t??"upperCase"]??t??Gt.upperCase,n=Array.from(e);return n.length>0?n:Array.from(Gt.upperCase)}function mr(t,e,n){let r=(t|0)^Math.imul(e+1,2654435761)^Math.imul(n+1,2246822507);return r=Math.imul(r^r>>>16,2146121005),r=Math.imul(r^r>>>15,2221713035),(r^r>>>16)>>>0}function nn(t,e,n=0){const r=t.from??"",s=t.to,a=Math.max(0,Math.min(1,e));if(a<=0)return r;if(a>=1)return s;const i=Array.from(r),o=Array.from(s),c=t.rightToLeft??!1;if(t.mode==="type"){const M=Math.round(a*Math.max(i.length,o.length));return c?i.slice(0,Math.max(0,i.length-M)).join("")+o.slice(Math.max(0,o.length-M)).join(""):o.slice(0,M).join("")+i.slice(M).join("")}const l=Math.max(0,Math.min(.999,t.revealDelay??0)),h=Math.max(0,(a-l)/(1-l)),u=Math.floor(h*o.length),d=t.tweenLength===!1?o.length:Math.round(i.length+(o.length-i.length)*a),g=en(t.chars),y=t.refreshRate??gr,m=y>0?Math.floor(n*y/1e3):0,p=t.seed??1;let _="";for(let M=0;M<d;M++){const A=c?M>=d-u:M<u,P=c?o[o.length-(d-M)]:o[M];A&&P!==void 0||P===" "||P===`
|
|
2
|
+
`?_+=P:_+=g[mr(p,M,m)%g.length]}return _}class Kt{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}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 o=Math.min(this._repeatDelayRemaining,s);if(this._repeatDelayRemaining-=o,s-=o,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const a=1e3;for(let o=0;o<a&&s>0&&this._playbackState==="playing";o++)if(this._direction==="forward"){const c=n-this._currentTime;if(s>=c){if(s-=c,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=s,s=0}else{const c=this._currentTime;if(s>=c){if(s-=c,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=s,s=0}const i=this.getStateAtTime(this._currentTime);this.onUpdate?.(i)}getStateAtTime(e){const n=new Map;if(this._hasSharedWrites())this._resolveShared(e,n);else for(const[r,s]of this._trackPlayers){const a=s.getTrack().property;for(const{target:i,value:o,start:c}of s.getTargetValues(e))this._write(n,r,i,a,o,e-c)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(e,n){const r=new Map;for(const[s,a]of this._trackPlayers){const i=a.getTrack().property;for(const{target:o,value:c,start:l}of a.getTargetValues(e)){const h=`${o}\0${i}`,u=l<=e,d=r.get(h);(!d||(u!==d.started?u:u?l>=d.start:l<=d.start))&&r.set(h,{trackId:s,target:o,property:i,value:c,start:l,started:u})}}for(const{trackId:s,target:a,property:i,value:o,start:c}of r.values())this._write(n,s,a,i,o,e-c)}_write(e,n,r,s,a,i){if(a===void 0)return;let o=e.get(r);o||(o=new Map,e.set(r,o));const c=this._textTracks.get(n);if(c&&typeof a=="number"){o.set("text",nn(c.textConfig,a,Math.max(0,i)));return}const l=this._motionPathTracks.get(n);if(l&&typeof a=="number"){const h=Qt(l.motionPathConfig,a);o.set("motionPathX",h.x),o.set("motionPathY",h.y),l.motionPathConfig.autoRotate&&o.set("motionPathRotate",h.angle)}else o.set(s,a)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const e=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const r of j(n)){const s=`${r}\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,z(e)){this._trackPlayers.set(e.id,new tn(e));return}if(Y(e)){this._trackPlayers.set(e.id,new Je(e)),this._springTracks.set(e.id,e);return}if(ct(e))this._trackPlayers.set(e.id,new yt(e)),this._textTracks.set(e.id,e);else if(Pt(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 yt(n)),this._motionPathTracks.set(e.id,e)}else this._trackPlayers.set(e.id,new yt(e))}replaceTrack(e,n){const r=this._tracks.findIndex(a=>a.id===e);if(r<0)return;const s=this._tracks.slice(r+1);this.removeTrack(e);for(const a of s)this.removeTrack(a.id);this.addTrack(n);for(const a of s)this.addTrack(a)}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(r=>r.id);for(const r of n)this.removeTrack(r);return n}getTrackSpan(e){const n=this._trackPlayers.get(e);if(!n)return;const r=n.getTrack(),s=r.delay??0;if(Y(r)||z(r))return{from:s,to:n.getDuration()};const a=r.keyframes;if(!(!a||a.length===0))return{from:a[0].time+s,to:n.getDuration()}}findConflicts(){const e=[];for(let n=0;n<this._tracks.length;n++){const r=this._tracks[n],s=this.getTrackSpan(r.id);if(s)for(let a=0;a<n;a++){const i=this._tracks[a];if(i.property!==r.property)continue;const o=j(i).filter(u=>j(r).includes(u));if(o.length===0)continue;const c=this.getTrackSpan(i.id);if(!c||!(c.from<=s.to&&s.from<=c.to))continue;const h=s.from>=c.from;for(const u of o)e.push({target:u,property:r.property,losingTrackId:h?i.id:r.id,winningTrackId:h?r.id:i.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&&!j(e).includes(n.target))return!1;if(n.timeRange){const r=this.getTrackSpan(e.id);if(!r||r.to<n.timeRange.from||r.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:At(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,a)=>s.time-a.time).map(s=>({...s})):void 0,r={...this._config};n?r.markers=n:delete r.markers,this._config=r}get captions(){return this._captions}setCaptions(e){const n={};for(const[r,s]of Object.entries(e??{}))n[r]={...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 pr=100;function yr(t,e,n,r){const s=[],a=[],{duration:i,alternate:o}=r,c=(g,y,m,p)=>{a.push([g,y]);const _=[];t.forEach((M,A)=>{(m==="forward"?(p?M>=g:M>g)&&M<=y:(p?M<=g:M<g)&&M>=y)&&_.push(A)}),_.sort((M,A)=>(m==="forward"?t[M]-t[A]:t[A]-t[M])||M-A);for(const M of _)s.push({kind:"event",index:M,direction:m})};let l=e.time,h=e.direction,u=e.fresh===!0;const d=Math.min(pr,Math.max(0,n.iteration-e.iteration));for(let g=0;g<d;g++){const y=h==="forward"?i:0;c(l,y,h,u),s.push({kind:"repeat"}),o?(h=h==="forward"?"reverse":"forward",l=y,u=!1):(l=h==="forward"?0:i,u=!0)}return d>0&&r.holding&&!o?{crossings:s,passes:a}:(c(l,n.time,h,u),{crossings:s,passes:a})}function rn(t){return z(t)?{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:sn(t.inertia),...N(t)}:Y(t)?{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...N(t)}:ct(t)?{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:t.keyframes.map(Wt),...N(t)}:Pt(t)?{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:t.keyframes.map(Wt),...N(t)}:{id:t.id,target:t.target,property:t.property,keyframes:t.keyframes.map(Wt),...t.interpolation!==void 0&&{interpolation:t.interpolation},...N(t)}}function sn(t){return{...t,...Array.isArray(t.end)&&{end:[...t.end]}}}function Wt(t){return{time:t.time,value:t.value,...t.easing&&{easing:t.easing}}}function N(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 an(t){if(z(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:sn(e.inertia),...N(e)}}if(Y(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"spring",spring:{...e.spring},...N(e)}}if(ct(t)){const e=t;return{id:e.id,target:e.target,property:"text",textConfig:{...e.textConfig},keyframes:[...e.keyframes].sort((n,r)=>n.time-r.time),...N(e)}}if(t.property==="motionPath"&&"motionPathConfig"in t){const e=t,n=[...e.keyframes].sort((r,s)=>r.time-s.time);return{id:e.id,target:e.target,property:"motionPath",motionPathConfig:{...e.motionPathConfig},keyframes:n,...N(e)}}return Ze({id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,...t.interpolation!==void 0&&{interpolation:t.interpolation},...N(t)})}function on(t){const e=t._config.markers;return{formatVersion:At(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,...e&&{markers:e.map(n=>({...n}))}},tracks:t.tracks.map(rn),...t.captions&&{captions:JSON.parse(JSON.stringify(t.captions))}}}function cn(t){const e=t.formatVersion??1;if(e>St)throw new Error(`tinyfly: this animation uses format version ${e}, but this tinyfly reads up to version ${St}. Update tinyfly to play it.`);return new Kt({id:t.id,name:t.name,config:t.config,tracks:t.tracks.map(an),captions:t.captions})}function Mr(t){return JSON.stringify(on(t))}function _r(t){const e=JSON.parse(t);return cn(e)}function Tr(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 qt(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 Zt(t,e,n){return e+t.next()*(n-e)}function un(t,e,n,r){if(r<=0)return Zt(t,e,n);const s=Math.floor((n-e)/r),a=Math.round(t.next()*s);return e+a*r}function br(t,e){if(e.length!==0)return e[Math.floor(t.next()*e.length)]}const ln=/^([+\-*/])=\s*(-?[\d.]+)$/,hn=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function kr(t){return typeof t!="string"?!1:ln.test(t.trim())||hn.test(t.trim())}function Jt(t,e={}){if(typeof t!="string")return t;const n=t.trim(),r=ln.exec(n);if(r){const[,a,i]=r,o=e.base??0,c=Number.parseFloat(i);switch(a){case"+":return o+c;case"-":return o-c;case"*":return o*c;case"/":return c===0?o:o/c}}const s=hn.exec(n);if(s){if(!e.random)throw new Error(`resolveValue: "${n}" needs a random source — pass one via context.random`);const a=Number.parseFloat(s[1]),i=Number.parseFloat(s[2]),o=s[3]!==void 0?Number.parseFloat(s[3]):void 0;return o!==void 0?un(e.random,a,i,o):Zt(e.random,a,i)}return t}function fn(t,e=0,n){const r=[];let s=e;for(const a of t){const i=Jt(a,{base:s,random:n});r.push(i),typeof i=="number"&&(s=i)}return r}class Sr{random;constructor(e){this.random=qt(e)}get seed(){return this.random.seed}resolve(e,n=0){return Jt(e,{base:n,random:this.random})}resolveSequence(e,n=0){return fn(e,n,this.random)}}const Ar=600;function Pr(t){if(Array.isArray(t)){const[d,g,y,m]=t;return{fn:dn(d,g,y,m),bezier:[d,g,y,m]}}const{segments:e}=B(t);if(e.length===0)throw new Error(`customEase: no curve in "${t}"`);const n=e[0].startX,r=e[0].startY,s=e[e.length-1],a=s.endX-n,i=s.endY-r;if(a===0||i===0)throw new Error(`customEase: "${t}" must move along both axes`);const o=d=>(d-n)/a,c=d=>(d-r)/i;if(e.length===1&&s.type==="C"){const[d,g,y,m]=s.points,p=[o(d),c(g),o(y),c(m)];return{fn:dn(...p),bezier:p}}const l=[],h=[],u=Math.max(8,Math.ceil(Ar/e.length));for(const d of e)for(let g=l.length===0?0:1;g<=u;g++){const[y,m]=Ir(d,g/u);l.push(o(y)),h.push(c(m))}return{fn:Rr(l,h)}}function wr(t={}){const n=.1+Math.max(0,Math.min(1,t.strength??.7))*.7,r=[1];for(let a=n;a>.002;a*=n)r.push(2*Math.sqrt(a));const s=r.reduce((a,i)=>a+i,0);return a=>{if(a<=0)return 0;if(a>=1)return 1;let i=a*s;for(let o=0;o<r.length;o++){if(i<=r[o]){if(o===0)return(i/r[0])**2;const c=r[o]/2,l=c*c,h=i-c;return 1-(l-h*h)}i-=r[o]}return 1}}function vr(t={}){const e=Math.max(1,t.wiggles??10),n=t.type??"easeOut",r=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)*r(s)}function Ir(t,e){if(t.type==="L"){const[l,h]=t.points;return[t.startX+(l-t.startX)*e,t.startY+(h-t.startY)*e]}const[n,r,s,a,i,o]=t.points,c=1-e;return[c*c*c*t.startX+3*c*c*e*n+3*c*e*e*s+e*e*e*i,c*c*c*t.startY+3*c*c*e*r+3*c*e*e*a+e*e*e*o]}function Rr(t,e){return n=>{if(n<=t[0])return e[0];if(n>=t[t.length-1])return e[e.length-1];let r=0,s=t.length-1;for(;s-r>1;){const i=r+s>>1;t[i]<=n?r=i:s=i}const a=t[s]-t[r];return a===0?e[s]:e[r]+(n-t[r])/a*(e[s]-e[r])}}function dn(t,e,n,r){const s=(i,o,c)=>3*(1-i)*(1-i)*i*o+3*(1-i)*i*i*c+i*i*i,a=(i,o,c)=>3*(1-i)*(1-i)*o+6*(1-i)*i*(c-o)+3*i*i*(1-c);return i=>{if(i<=0)return 0;if(i>=1)return 1;let o=i;for(let h=0;h<8;h++){const u=s(o,t,n)-i,d=a(o,t,n);if(Math.abs(u)<1e-6)return s(o,e,r);if(Math.abs(d)<1e-6)break;o-=u/d}let c=0,l=1;o=i;for(let h=0;h<40;h++)s(o,t,n)<i?c=o:l=o,o=(c+l)/2;return s(o,e,r)}}const Er=350,Dr=300,Cr=550;function $r(t,e={}){const n=e.lead??Er,r=e.gap??Dr,s=e.tail??Cr,a=[];let i=0;return t.forEach((o,c)=>{const l=[];let h=i+n;o.lines.forEach((d,g)=>{if(!(d.duration>=0))throw new Error(`narration: scene ${c} line ${g} has an invalid duration (${d.duration})`);g>0&&(h+=r),l.push({id:d.id??`s${c}-l${g}`,scene:c,line:g,start:h,end:h+d.duration,text:d.text}),h+=d.duration});const u=h+s+(o.tail??0);a.push({id:o.id??`s${c}`,start:i,duration:u-i,cues:l}),i=u}),{duration:i,scenes:a,cues:a.flatMap(o=>o.cues)}}function Or(t){return t.cues.map(e=>({id:e.id,time:e.start,label:e.text}))}function Lr(t,e){let n=t.scenes[0];for(const r of t.scenes)if(e>=r.start)n=r;else break;return n}const te=t=>6e4/t.bpm;function Mt(t,e){return t.offset+e*te(t)}function _t(t,e){return(e-t.offset)/te(t)}function xr(t,e){return Mt(t,Math.round(_t(t,e)))}function Fr(t,e){return Mt(t,Math.ceil(_t(t,e)-1e-9))}function Nr(t,e,n){const r=Math.max(1,Math.round(t.beatsPerBar??4)),s=[];if(!(t.bpm>0)||n<e)return s;for(let a=Math.ceil(_t(t,e)-1e-9);;a++){const i=Mt(t,a);if(i>n+1e-9)break;s.push({time:i,bar:(a%r+r)%r===0,n:a})}return s}const Z=100;function Xr(t,e,n={}){const r=n.minBpm??70,s=n.maxBpm??180,a=Math.max(1,Math.round(e/Z)),i=Math.min(t.length,Math.round((n.maxSeconds??60)*e)),o=Math.floor(i/a);if(o<4)return{bpm:120,offset:0,confidence:0};const c=new Float64Array(o);for(let T=0;T<o;T++){let k=0;for(let S=T*a;S<(T+1)*a;S++)k+=t[S]*t[S];c[T]=Math.log(1e-6+k/a)}const l=new Float64Array(o);for(let T=1;T<o;T++)l[T]=Math.max(0,c[T]-c[T-1]);const h=l.reduce((T,k)=>T+k,0)/o;for(let T=0;T<o;T++)l[T]=Math.max(0,l[T]-h);const u=Math.max(1,Math.floor(60*Z/s)),d=Math.min(o-1,Math.ceil(60*Z/r)),g=T=>{let k=0;for(let S=T;S<o;S++)k+=l[S]*l[S-T];return k/(o-T)};let y=0;for(let T=0;T<o;T++)y+=l[T]*l[T];y/=o;let m=u,p=-1/0;for(let T=u;T<=d;T++){const k=60*Z/T,S=Math.exp(-.5*(Math.log2(k/120)/.9)**2),w=g(T)*S;w>p&&(p=w,m=T)}const _=T=>{const k=Math.floor(T);return k<0||k+1>=o?0:l[k]+(l[k+1]-l[k])*(T-k)},M=(T,k)=>{let S=0;for(let w=k;w<o;w+=T)S+=_(w);return S};let A=m,P=0,b=-1/0;for(let T=m-.6;T<=m+.6+1e-9;T+=.02){if(T<1)continue;const k=Math.max(1,Math.round(T*4));for(let S=0;S<k;S++){const w=S/k*T,E=M(T,w);E>b&&(b=E,P=w,A=T)}}const I=60*Z/A,v=y>0?Math.max(0,Math.min(1,g(m)/y)):0,$=(P+.5)*1e3/Z;return{bpm:Math.round(I*100)/100,offset:Math.round($%(6e4/I)),confidence:v}}const zr=600,Yr=250,gn=1;function Ur(t,e){const n=e.target??"Camera",r={x:e.stage.width/2,y:e.stage.height/2},s={},a=(u,d,g,y)=>{const m=s[u]??=[];for(;m.length>0&&m[m.length-1].time>=d;)m.pop();m.push({time:d,value:g,...y?{easing:y}:{}})},i=u=>{const d=u.rotate*Math.PI/180,g=(u.focusX-r.x)*u.scale,y=(u.focusY-r.y)*u.scale;return{x:-(g*Math.cos(d)-y*Math.sin(d)),y:-(g*Math.sin(d)+y*Math.cos(d)),scale:u.scale,rotate:u.rotate}},o=(u,d,g)=>{const y=i(d);for(const m of["x","y","scale","rotate"])a(m,u,y[m],g)};let c={focusX:r.x,focusY:r.y,scale:1,rotate:0};const l=[...t].sort((u,d)=>u.at-d.at),h=l.filter(u=>!("shake"in u));h.length>0&&o(0,c);for(const u of h)if("frame"in u){const d=Math.max(gn,u.duration??zr);o(u.at,c),c={focusX:u.frame.focus?.x??r.x,focusY:u.frame.focus?.y??r.y,scale:u.frame.scale??1,rotate:u.frame.rotate??0},o(u.at+d,c,u.easing??(d>gn?"ease-in-out":void 0))}else{const{follow:d}=u,g=d.lag??Yr,y=new Kt({id:"follow",tracks:[{id:"x",target:"s",property:"x",keyframes:d.x}]}),m=M=>y.getStateAtTime(M).values.get("s")?.get("x")??c.focusX,p=[u.at,...d.x.map(M=>M.time).filter(M=>M>u.at&&M<u.until),u.until];o(u.at,c);const _=M=>({focusX:m(M)+(d.lead??0),focusY:d.y??c.focusY,scale:d.scale??c.scale,rotate:c.rotate});for(const M of p){const A=d.x.find(P=>P.time===M)?.easing;o(M+g,_(M),M===u.at?"ease-in-out":A)}c=_(u.until)}for(const u of l.filter(d=>"shake"in d)){const d=u.shake.strength??12,g=u.shake.roll??1.5,y=1e3/(u.shake.frequency??24),m=qt(u.shake.seed??Math.round(u.at)+1),p=()=>m.next()*2-1;for(const _ of["shakeX","shakeY","shakeRotate"])a(_,u.at,0);for(let _=u.at+y;_<u.at+u.duration;_+=y){const M=1-(_-u.at)/u.duration;a("shakeX",_,p()*d*M),a("shakeY",_,p()*d*M),a("shakeRotate",_,p()*g*M)}for(const _ of["shakeX","shakeY","shakeRotate"])a(_,u.at+u.duration,0,"ease-out")}return Object.entries(s).map(([u,d])=>({id:`${n}-${u}`,target:n,property:u,keyframes:d}))}const X=t=>Math.round(t*1e3)/1e3;function Vr(t,e={}){if(t.length===0)return"";const n=e.curviness??1,r=e.closed??!1,s=t.length;let a=`M${X(t[0].x)} ${X(t[0].y)}`;if(s===1)return a;const i=c=>r?t[(c%s+s)%s]:t[Math.max(0,Math.min(s-1,c))],o=r?s:s-1;for(let c=0;c<o;c++){const l=i(c-1),h=i(c),u=i(c+1),d=i(c+2);if(n===0){a+=` L${X(u.x)} ${X(u.y)}`;continue}const g=n/6,y=h.x+(u.x-l.x)*g,m=h.y+(u.y-l.y)*g,p=u.x-(d.x-h.x)*g,_=u.y-(d.y-h.y)*g;a+=` C${X(y)} ${X(m)} ${X(p)} ${X(_)} ${X(u.x)} ${X(u.y)}`}return r?`${a} Z`:a}const C=(t,e=0)=>{const n=parseFloat(t??"");return Number.isFinite(n)?n:e};function jr(t){const e=(t??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),n=[];for(let r=0;r+1<e.length;r+=2)n.push({x:e[r],y:e[r+1]});return n}function Br(t){const e=t.attributes;switch(t.tag.toLowerCase()){case"path":return e.d??null;case"circle":case"ellipse":{const n=C(e.cx),r=C(e.cy),s=t.tag.toLowerCase()==="circle"?C(e.r):C(e.rx),a=t.tag.toLowerCase()==="circle"?C(e.r):C(e.ry);return`M${n+s} ${r} A${s} ${a} 0 1 1 ${n-s} ${r} A${s} ${a} 0 1 1 ${n+s} ${r} Z`}case"rect":{const n=C(e.x),r=C(e.y),s=C(e.width),a=C(e.height);let i=e.rx!=null?C(e.rx):e.ry!=null?C(e.ry):0,o=e.ry!=null?C(e.ry):i;return i=Math.min(i,s/2),o=Math.min(o,a/2),i===0||o===0?`M${n} ${r} H${n+s} V${r+a} H${n} Z`:`M${n+i} ${r} H${n+s-i} A${i} ${o} 0 0 1 ${n+s} ${r+o} V${r+a-o} A${i} ${o} 0 0 1 ${n+s-i} ${r+a} H${n+i} A${i} ${o} 0 0 1 ${n} ${r+a-o} V${r+o} A${i} ${o} 0 0 1 ${n+i} ${r} Z`}case"line":return`M${C(e.x1)} ${C(e.y1)} L${C(e.x2)} ${C(e.y2)}`;case"polyline":case"polygon":{const n=jr(e.points);if(n.length===0)return null;const r=n.map((s,a)=>`${a===0?"M":"L"}${s.x} ${s.y}`).join(" ");return t.tag.toLowerCase()==="polygon"?`${r} Z`:r}default:return null}}function Hr(t,e,n){const r=Math.max(2,Math.round(n.samples??32)),s=Math.max(0,n.length),a=n.since!==void 0?Math.max(e-s,n.since):e-s;if(a>=e)return[];const i=n.period,o=[];for(let c=0;c<r;c++){const l=a+(e-a)*c/(r-1),h=i&&i>0&&c<r-1?(l%i+i)%i:l;o.push({at:t(h),time:l,age:s>0?(e-l)/s:0})}return o}const Qr=2.5;function Gr(t){const e=[],n=[],r=t.length,s=(a,i)=>{for(let o=a+i;o>=0&&o<r;o+=i){const c=(t[o].x-t[a].x)*i,l=(t[o].y-t[a].y)*i,h=Math.hypot(c,l);if(h>1e-9)return[c/h,l/h]}return null};for(let a=0;a<r;a++){const i=t[a],o=s(a,-1),c=s(a,1),l=o??c??[1,0],h=c??o??[1,0];let u=l[0]+h[0],d=l[1]+h[1];const g=Math.hypot(u,d);g<1e-9?(u=l[0],d=l[1]):(u/=g,d/=g);const y=u*l[0]+d*l[1],m=Math.min(Qr,1/Math.max(y,1e-6)),p=i.width/2*m;e.push({x:i.x-d*p,y:i.y+u*p}),n.push({x:i.x+d*p,y:i.y-u*p})}return{left:e,right:n}}function Kr(t){const e=t.length;if(e<2)return null;const n=t[e-1];for(let r=e-2;r>=0;r--){const s=n.x-t[r].x,a=n.y-t[r].y,i=Math.hypot(s,a);if(i>1e-9)return{x:n.x,y:n.y,radius:n.width/2,start:Math.atan2(s/i,-a/i)}}return null}function Wr(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function ee(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function mn(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Tt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ne(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 re(t){return Math.hypot(t[0],t[1],t[2])}function qr(t,e){return re(ee(t,e))}function se(t){const e=re(t);return e===0?[0,0,0]:mn(t,1/e)}function Zr(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 Jr=Object.freeze(Object.defineProperty({__proto__:null,add:Wr,cross:ne,distance:qr,dot:Tt,length:re,lerp:Zr,normalize:se,scale:mn,subtract:ee},Symbol.toStringTag,{value:"Module"})),ts=Math.PI/180;function es(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function ns(t,e){const n=new Array(16);for(let r=0;r<4;r++)for(let s=0;s<4;s++){let a=0;for(let i=0;i<4;i++)a+=t[i*4+s]*e[r*4+i];n[r*4+s]=a}return n}function rs(t){return[1,0,0,0,0,1,0,0,0,0,1,0,t[0],t[1],t[2],1]}function ss(t){return[t[0],0,0,0,0,t[1],0,0,0,0,t[2],0,0,0,0,1]}function pn(t){const[e,n,r,s]=t;return[1-2*(n*n+r*r),2*(e*n+r*s),2*(e*r-n*s),0,2*(e*n-r*s),1-2*(e*e+r*r),2*(n*r+e*s),0,2*(e*r+n*s),2*(n*r-e*s),1-2*(e*e+n*n),0,0,0,0,1]}function as(t,e,n){const r=pn(e);for(let s=0;s<3;s++)r[s]*=n[0],r[4+s]*=n[1],r[8+s]*=n[2];return r[12]=t[0],r[13]=t[1],r[14]=t[2],r}function is(t){const e=new Array(16);for(let n=0;n<4;n++)for(let r=0;r<4;r++)e[r*4+n]=t[n*4+r];return e}function os(t){const[e,n,r,s,a,i,o,c,l,h,u,d,g,y,m,p]=t,_=e*i-n*a,M=e*o-r*a,A=e*c-s*a,P=n*o-r*i,b=n*c-s*i,I=r*c-s*o,v=l*y-h*g,$=l*m-u*g,T=l*p-d*g,k=h*m-u*y,S=h*p-d*y,w=u*p-d*m,E=_*w-M*S+A*k+P*T-b*$+I*v;if(Math.abs(E)<1e-12)return null;const R=1/E;return[(i*w-o*S+c*k)*R,(r*S-n*w-s*k)*R,(y*I-m*b+p*P)*R,(u*b-h*I-d*P)*R,(o*T-a*w-c*$)*R,(e*w-r*T+s*$)*R,(m*A-g*I-p*M)*R,(l*I-u*A+d*M)*R,(a*S-i*T+c*v)*R,(n*T-e*S-s*v)*R,(g*b-y*A+p*_)*R,(h*A-l*b-d*_)*R,(i*$-a*k-o*v)*R,(e*k-n*$+r*v)*R,(y*M-g*P-m*_)*R,(l*P-h*M+u*_)*R]}function cs(t,e,n,r){const s=1/Math.tan(t*ts/2),a=1/(n-r);return[s/e,0,0,0,0,s,0,0,0,0,(r+n)*a,-1,0,0,2*r*n*a,0]}function us(t,e,n,r,s,a){const i=1/(e-t),o=1/(r-n),c=1/(a-s);return[2*i,0,0,0,0,2*o,0,0,0,0,-2*c,0,-(e+t)*i,-(r+n)*o,-(a+s)*c,1]}function ls(t,e,n=[0,1,0]){const r=se(ee(t,e)),s=se(ne(n,r)),a=ne(r,s);return[s[0],a[0],r[0],0,s[1],a[1],r[1],0,s[2],a[2],r[2],0,-Tt(s,t),-Tt(a,t),-Tt(r,t),1]}function hs(t,e){const n=t[0]*e[0]+t[4]*e[1]+t[8]*e[2]+t[12],r=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],a=t[3]*e[0]+t[7]*e[1]+t[11]*e[2]+t[15];return a===1||a===0?[n,r,s]:[n/a,r/a,s/a]}const fs=Object.freeze(Object.defineProperty({__proto__:null,compose:as,fromQuat:pn,identity:es,invert:os,lookAt:ls,multiply:ns,orthographic:us,perspective:cs,scaling:ss,transformPoint:hs,translation:rs,transpose:is},Symbol.toStringTag,{value:"Module"}));f.Clock=kn,f.DEFAULT_BAKE_INTERVAL_MS=jt,f.DEFAULT_INERTIA_FRICTION=Rt,f.DEFAULT_SPRING=x,f.FORMAT_VERSION=St,f.INERTIA_MAX_DURATION_MS=le,f.InertiaTrackPlayer=tn,f.MORPH_SAMPLES=Qn,f.ManualClock=bn,f.SPRING_MAX_DURATION_MS=It,f.SPRING_PRESETS=An,f.SPRING_STEP_MS=G,f.SpringSampler=tt,f.SpringTrackPlayer=Je,f.Timeline=Kt,f.TrackPlayer=yt,f.ValueResolver=Sr,f.backOut=be,f.bakeEasing=Ke,f.bakeInertiaTrack=Ht,f.bakeSpringTrack=Bt,f.beatAtTime=_t,f.beatLength=te,f.beatTime=Mt,f.beatsBetween=Nr,f.bounceOut=Te,f.cameraTracks=Ur,f.charactersFor=en,f.clearMorphCache=nr,f.clearPathCache=Un,f.createCubicBezier=Me,f.createRandom=qt,f.createTrack=Ze,f.criticalDamping=In,f.customBounce=wr,f.customEase=Pr,f.customWiggle=vr,f.deserializeTimeline=cn,f.deserializeTrack=an,f.detectTempo=Xr,f.easeIn=me,f.easeInCubic=Et,f.easeInOut=ye,f.easeInOutCubic=Ct,f.easeInOutQuad=ge,f.easeInQuad=fe,f.easeOut=pe,f.easeOutCubic=Dt,f.easeOutQuad=de,f.elasticOut=_e,f.expandParametricEasings=We,f.formatVersionFor=At,f.fromJSON=_r,f.getEasingFunction=Ot,f.getInterpolator=Vt,f.getMotionPathPoint=Qt,f.getPathLength=Vn,f.getPointAtProgress=we,f.hasKeyframes=oe,f.hashSeed=Tr,f.heldTime=Sn,f.inertiaDuration=nt,f.inertiaRest=et,f.inertiaValueAt=ft,f.inertiaVelocityAt=Cn,f.interpolateArray=Be,f.interpolateColor=je,f.interpolateMotionPath=dr,f.interpolateNumber=F,f.interpolatePathString=Qe,f.interpolateQuaternion=He,f.interpolateString=Ut,f.isCubicBezierEasing=Q,f.isInertiaTrack=z,f.isMotionPathPoint=Tn,f.isMotionPathTrack=Pt,f.isParametricEasing=ot,f.isPathData=Oe,f.isSpringTrack=Y,f.isTextTrack=ct,f.isUnderdamped=vn,f.isUnresolved=kr,f.linear=dt,f.mat4=fs,f.maxStaggerDistance=ce,f.morphPath=$e,f.narrationMarkers=Or,f.narrationSceneAt=Lr,f.naturalRest=he,f.nearestBeat=xr,f.nextBeat=Fr,f.parametricEasing=Se,f.parsePath=B,f.planNarration=$r,f.playheadCrossings=yr,f.pointAtDistance=Lt,f.pointsToPath=Vr,f.quat=cr,f.randomBetween=Zt,f.randomChoice=br,f.randomSnapped=un,f.resolveSequence=fn,f.resolveValue=Jt,f.ribbon=Gr,f.ribbonHeadCap=Kr,f.serializeTimeline=on,f.serializeTrack=rn,f.shapeToPathData=Br,f.simplifyKeyframes=qe,f.springDuration=wn,f.springValueAt=Pn,f.staggerDistance=wt,f.staggerOffset=vt,f.staggerOffsets=ue,f.staggerSpan=ut,f.stepsEasing=ke,f.textAt=nn,f.toJSON=Mr,f.toKeyframedTrack=hr,f.toKeyframedTracks=fr,f.trackTargets=j,f.trailSamples=Hr,f.vec3=Jr,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
package/lib/headless/headless.js
CHANGED
|
@@ -1197,6 +1197,32 @@ function applyBloom(ctx, options = {}) {
|
|
|
1197
1197
|
ctx.drawImage(small, 0, 0, W, H);
|
|
1198
1198
|
ctx.restore();
|
|
1199
1199
|
}
|
|
1200
|
+
const IDENTITY_CAMERA = { x: 0, y: 0, scale: 1, rotate: 0, shakeX: 0, shakeY: 0, shakeRotate: 0 };
|
|
1201
|
+
function cameraFromValues(values) {
|
|
1202
|
+
const read = (property) => {
|
|
1203
|
+
const value = values?.get(property);
|
|
1204
|
+
return typeof value === "number" ? value : IDENTITY_CAMERA[property];
|
|
1205
|
+
};
|
|
1206
|
+
return {
|
|
1207
|
+
x: read("x"),
|
|
1208
|
+
y: read("y"),
|
|
1209
|
+
scale: read("scale"),
|
|
1210
|
+
rotate: read("rotate"),
|
|
1211
|
+
shakeX: read("shakeX"),
|
|
1212
|
+
shakeY: read("shakeY"),
|
|
1213
|
+
shakeRotate: read("shakeRotate")
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
function applyCamera(ctx, view, stage) {
|
|
1217
|
+
const cx = stage.width / 2;
|
|
1218
|
+
const cy = stage.height / 2;
|
|
1219
|
+
const shake = Math.max(Math.abs(view.shakeX), Math.abs(view.shakeY));
|
|
1220
|
+
const overscan = 1 + 2 * shake / Math.max(1, Math.min(stage.width, stage.height));
|
|
1221
|
+
ctx.translate(cx + view.x + view.shakeX, cy + view.y + view.shakeY);
|
|
1222
|
+
ctx.rotate((view.rotate + view.shakeRotate) * Math.PI / 180);
|
|
1223
|
+
ctx.scale(view.scale * overscan, view.scale * overscan);
|
|
1224
|
+
ctx.translate(-cx, -cy);
|
|
1225
|
+
}
|
|
1200
1226
|
class FrameRenderer {
|
|
1201
1227
|
scene;
|
|
1202
1228
|
fps;
|
|
@@ -1267,16 +1293,26 @@ class FrameRenderer {
|
|
|
1267
1293
|
const stateAt = timeline && ((at) => timeline.getStateAtTime(heldTime(at, drawingRate)));
|
|
1268
1294
|
const frame = { index, time, state, stateAt, width: this.scene.width, height: this.scene.height };
|
|
1269
1295
|
const background = this.scene.background ?? "#ffffff";
|
|
1270
|
-
if (typeof background
|
|
1271
|
-
this.drawIsolated(ctx, background, frame);
|
|
1272
|
-
} else if (background !== "transparent") {
|
|
1296
|
+
if (typeof background !== "function" && background !== "transparent") {
|
|
1273
1297
|
ctx.fillStyle = background;
|
|
1274
1298
|
ctx.fillRect(0, 0, this.scene.width, this.scene.height);
|
|
1275
1299
|
}
|
|
1300
|
+
const camera = this.scene.camera;
|
|
1301
|
+
if (camera) {
|
|
1302
|
+
const id = camera === true ? "Camera" : camera;
|
|
1303
|
+
applyCamera(ctx, cameraFromValues(state?.values.get(id)), this.scene);
|
|
1304
|
+
}
|
|
1305
|
+
if (typeof background === "function") this.drawIsolated(ctx, background, frame);
|
|
1276
1306
|
if (state) this.adapter.applyState(state);
|
|
1277
1307
|
this.adapter.render(ctx);
|
|
1278
1308
|
if (this.scene.draw) this.drawIsolated(ctx, this.scene.draw, frame);
|
|
1279
1309
|
ctx.restore();
|
|
1310
|
+
if (this.scene.overlay) {
|
|
1311
|
+
ctx.save();
|
|
1312
|
+
ctx.scale(this.scale, this.scale);
|
|
1313
|
+
this.drawIsolated(ctx, this.scene.overlay, frame);
|
|
1314
|
+
ctx.restore();
|
|
1315
|
+
}
|
|
1280
1316
|
if (this.scene.bloom) {
|
|
1281
1317
|
const options = this.scene.bloom === true ? {} : this.scene.bloom;
|
|
1282
1318
|
applyBloom(ctx, options.radius !== void 0 ? { ...options, radius: options.radius * this.scale } : options);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AnimatableValue } from '../../engine/types';
|
|
2
|
+
/**
|
|
3
|
+
* A 2D camera for canvas scenes: pan, zoom and rotate the whole picture.
|
|
4
|
+
*
|
|
5
|
+
* Like the editor's camera, it is just tracks on a reserved target (named
|
|
6
|
+
* `Camera` by convention) with the properties `x`, `y` (pan, px), `scale`
|
|
7
|
+
* (zoom about the stage centre) and `rotate` (degrees about the centre).
|
|
8
|
+
* Three more add on top for shakes, so a shake never disturbs a pan:
|
|
9
|
+
* `shakeX`, `shakeY` (px) and `shakeRotate` (degrees).
|
|
10
|
+
*
|
|
11
|
+
* A point `p` of the scene lands on screen at
|
|
12
|
+
* `centre + (x, y) + shake + R(rotate) · scale · (p − centre)`.
|
|
13
|
+
*/
|
|
14
|
+
export interface CameraView {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
scale: number;
|
|
18
|
+
rotate: number;
|
|
19
|
+
shakeX: number;
|
|
20
|
+
shakeY: number;
|
|
21
|
+
shakeRotate: number;
|
|
22
|
+
}
|
|
23
|
+
/** The camera that changes nothing. */
|
|
24
|
+
export declare const IDENTITY_CAMERA: CameraView;
|
|
25
|
+
/** The camera's view from a target's animated values (missing ones are identity). */
|
|
26
|
+
export declare function cameraFromValues(values: Map<string, AnimatableValue> | undefined): CameraView;
|
|
27
|
+
/**
|
|
28
|
+
* Transform a context so what is drawn next is seen through the camera.
|
|
29
|
+
* `stage` is the scene's size. While shaking, the picture zooms in just
|
|
30
|
+
* enough that the shake never shows past its edges.
|
|
31
|
+
*/
|
|
32
|
+
export declare function applyCamera(ctx: CanvasRenderingContext2D, view: CameraView, stage: {
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
}): void;
|
|
36
|
+
/** Where a scene point appears through the camera (no shake overscan): for placing captions or checking framing. */
|
|
37
|
+
export declare function cameraPoint(view: CameraView, stage: {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
}, point: {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
}): {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
};
|
|
@@ -50,6 +50,8 @@ export { tf, live, createLive, Stage, LiveTimeline, CompatTimeline, quickPlay, m
|
|
|
50
50
|
export { applyBloom } from '../adapters/canvas/bloom';
|
|
51
51
|
export type { BloomOptions } from '../adapters/canvas/bloom';
|
|
52
52
|
export { drawTrail } from '../adapters/canvas/trail';
|
|
53
|
+
export { applyCamera, cameraFromValues, cameraPoint, IDENTITY_CAMERA } from '../adapters/canvas/camera';
|
|
54
|
+
export type { CameraView } from '../adapters/canvas/camera';
|
|
53
55
|
export type { TrailStyle } from '../adapters/canvas/trail';
|
|
54
56
|
export { createControls, DEFAULT_LABELS } from '../embed/controls';
|
|
55
57
|
export type { Controls, ControlsOptions, ControlLabels, FullscreenControl } from '../embed/controls';
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { Keyframe, Track } from '../../engine/types';
|
|
2
|
+
/**
|
|
3
|
+
* Lip-sync from text: the mouth shapes a line of dialogue makes, timed over
|
|
4
|
+
* the span it is spoken in.
|
|
5
|
+
*
|
|
6
|
+
* No audio analysis: the text is read as a sequence of sounds (vowels open
|
|
7
|
+
* the mouth in their shape, m/b/p close it, f/v bite the lip, pauses rest
|
|
8
|
+
* it), and the sounds share the line's time by how long each one tends to
|
|
9
|
+
* take. That is how cartoon lip-sync is usually done by hand (a few mouth
|
|
10
|
+
* shapes, timed to the track), and it is close enough for stick figures and
|
|
11
|
+
* cartoon faces. It reads Latin script and Devanagari.
|
|
12
|
+
*
|
|
13
|
+
* Shapes are the face fields `mouth` (0 closed … 1 wide open) and
|
|
14
|
+
* `mouthWidth` (0.5 pursed … 1.5 wide), which the stick figure and the v2
|
|
15
|
+
* characters both have.
|
|
16
|
+
*/
|
|
17
|
+
/** A mouth shape. */
|
|
18
|
+
export interface Viseme {
|
|
19
|
+
mouth: number;
|
|
20
|
+
mouthWidth: number;
|
|
21
|
+
}
|
|
22
|
+
/** The shapes, after the classic cartoon mouth chart. */
|
|
23
|
+
export declare const VISEMES: {
|
|
24
|
+
/** Closed and relaxed */
|
|
25
|
+
rest: {
|
|
26
|
+
mouth: number;
|
|
27
|
+
mouthWidth: number;
|
|
28
|
+
};
|
|
29
|
+
/** "ah": open wide */
|
|
30
|
+
a: {
|
|
31
|
+
mouth: number;
|
|
32
|
+
mouthWidth: number;
|
|
33
|
+
};
|
|
34
|
+
/** "eh": open, wide */
|
|
35
|
+
e: {
|
|
36
|
+
mouth: number;
|
|
37
|
+
mouthWidth: number;
|
|
38
|
+
};
|
|
39
|
+
/** "ee": a little open, stretched wide */
|
|
40
|
+
i: {
|
|
41
|
+
mouth: number;
|
|
42
|
+
mouthWidth: number;
|
|
43
|
+
};
|
|
44
|
+
/** "oh": round */
|
|
45
|
+
o: {
|
|
46
|
+
mouth: number;
|
|
47
|
+
mouthWidth: number;
|
|
48
|
+
};
|
|
49
|
+
/** "oo": small and pursed */
|
|
50
|
+
u: {
|
|
51
|
+
mouth: number;
|
|
52
|
+
mouthWidth: number;
|
|
53
|
+
};
|
|
54
|
+
/** m, b, p: lips pressed */
|
|
55
|
+
m: {
|
|
56
|
+
mouth: number;
|
|
57
|
+
mouthWidth: number;
|
|
58
|
+
};
|
|
59
|
+
/** f, v: lip under the teeth */
|
|
60
|
+
f: {
|
|
61
|
+
mouth: number;
|
|
62
|
+
mouthWidth: number;
|
|
63
|
+
};
|
|
64
|
+
/** l, th, n, d, t: tongue up, a little open */
|
|
65
|
+
l: {
|
|
66
|
+
mouth: number;
|
|
67
|
+
mouthWidth: number;
|
|
68
|
+
};
|
|
69
|
+
/** Other consonants: slightly open */
|
|
70
|
+
c: {
|
|
71
|
+
mouth: number;
|
|
72
|
+
mouthWidth: number;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export type VisemeName = keyof typeof VISEMES;
|
|
76
|
+
/** One sound of a line: its shape, and how long it takes relative to the others. */
|
|
77
|
+
export interface Sound {
|
|
78
|
+
viseme: VisemeName;
|
|
79
|
+
weight: number;
|
|
80
|
+
}
|
|
81
|
+
/** The sounds of a line, in order. */
|
|
82
|
+
export declare function soundsOf(text: string): Sound[];
|
|
83
|
+
export interface LipSyncOptions {
|
|
84
|
+
/** How wide the mouth opens: 1 as charted, less for mumbling, more for shouting (default 1) */
|
|
85
|
+
energy?: number;
|
|
86
|
+
/** Field names, if not `mouth` and `mouthWidth` */
|
|
87
|
+
fields?: {
|
|
88
|
+
mouth?: string;
|
|
89
|
+
mouthWidth?: string;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** A spoken line: what is said, and when (ms). */
|
|
93
|
+
export interface SpokenLine {
|
|
94
|
+
text: string;
|
|
95
|
+
start: number;
|
|
96
|
+
end: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Mouth keyframes for a line spoken from `start` to `end` ms: closed at the
|
|
100
|
+
* start, a shape per sound, closed again at the end. Keys are in time order,
|
|
101
|
+
* for the `mouth` and `mouthWidth` fields.
|
|
102
|
+
*/
|
|
103
|
+
export declare function lipSyncKeyframes(line: SpokenLine, options?: LipSyncOptions): Record<string, Keyframe<number>[]>;
|
|
104
|
+
/** Mouth tracks on `target` for several spoken lines (in time order, not overlapping). */
|
|
105
|
+
export declare function lipSyncTracks(target: string, lines: SpokenLine[], options?: LipSyncOptions): Track[];
|
|
106
|
+
/**
|
|
107
|
+
* Tracks with spoken lines lip-synced over their mouth: during each line the
|
|
108
|
+
* lip-sync shapes replace the `mouth` and `mouthWidth` keys, starting and
|
|
109
|
+
* ending on whatever the face was doing, so a shocked gape or a grin carries
|
|
110
|
+
* on around the speech. Other tracks pass through. Fields missing from
|
|
111
|
+
* `tracks` start from `rest` (default: closed, normal width).
|
|
112
|
+
*/
|
|
113
|
+
export declare function lipSyncOver(target: string, tracks: Track[], lines: SpokenLine[], options?: LipSyncOptions & {
|
|
114
|
+
rest?: Record<string, number>;
|
|
115
|
+
}): Track[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Track } from '../../engine/types';
|
|
2
|
+
import { type ExpressionName, type PoseKey, type PoseName, type StickPose } from '../stick-figure';
|
|
3
|
+
import { type GaitName } from '../gaits';
|
|
4
|
+
import { type GagName } from './gags';
|
|
5
|
+
import { type SpokenLine } from './lip-sync';
|
|
6
|
+
import type { ActingOptions } from './acting';
|
|
7
|
+
/**
|
|
8
|
+
* Beat scripts: a story written as what a character does, compiled into
|
|
9
|
+
* acted tracks.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const { tracks, duration, lines } = scriptTracks('crow', [
|
|
13
|
+
* { do: 'walk', to: 600, mood: 'sad' },
|
|
14
|
+
* { do: 'look', toward: 900, mood: 'surprised' },
|
|
15
|
+
* { do: 'take' },
|
|
16
|
+
* { do: 'say', say: 'A pot of water!', mood: 'joyful' },
|
|
17
|
+
* { do: 'run', to: 880 },
|
|
18
|
+
* { do: 'cheer', for: 1200 },
|
|
19
|
+
* ], { from: 200, height: 170, style: 'snappy' })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Each beat starts when the one before it ends (or at `at`). Walking beats
|
|
23
|
+
* move the figure (its `x` track, as an offset from where it was placed at
|
|
24
|
+
* `from`), turn it to face the way it goes, and pick the gait; pose beats key
|
|
25
|
+
* a named pose; gag beats splice in a gag; `say` lip-syncs a line. The poses
|
|
26
|
+
* then go through the acting pass, so the result winds up, overshoots and
|
|
27
|
+
* overlaps like any `actTracks()` output. Everything is plain keyframes.
|
|
28
|
+
*/
|
|
29
|
+
/** The ways to get somewhere. */
|
|
30
|
+
export type GaitAction = GaitName;
|
|
31
|
+
/** Everything a beat can do. */
|
|
32
|
+
export type Action = GaitAction | PoseName | GagName | 'look' | 'say' | 'hold' | 'stand' | 'face';
|
|
33
|
+
export interface Beat {
|
|
34
|
+
/** What happens */
|
|
35
|
+
do: Action;
|
|
36
|
+
/** When it starts, ms (default: when the beat before ends) */
|
|
37
|
+
at?: number;
|
|
38
|
+
/** How long it takes, ms (default: the action's own length) */
|
|
39
|
+
for?: number;
|
|
40
|
+
/** Walking: where to, scene x */
|
|
41
|
+
to?: number;
|
|
42
|
+
/** `look` and `face`: a scene x, or `viewer` (front-on), `ahead` or `back` */
|
|
43
|
+
toward?: number | 'viewer' | 'ahead' | 'back';
|
|
44
|
+
/** The face for the beat */
|
|
45
|
+
mood?: ExpressionName;
|
|
46
|
+
/** Spoken during the beat, lip-synced (with `do: 'say'`, the beat lasts as long as the line) */
|
|
47
|
+
say?: string;
|
|
48
|
+
/** Joints to change on top of the action's pose */
|
|
49
|
+
pose?: Partial<StickPose>;
|
|
50
|
+
}
|
|
51
|
+
export interface ScriptOptions extends ActingOptions {
|
|
52
|
+
/** Scene x the figure was placed at (its `x` track is an offset from here; default 0) */
|
|
53
|
+
from?: number;
|
|
54
|
+
/** Figure height, px, for stride length (default 300, the stick figure's) */
|
|
55
|
+
height?: number;
|
|
56
|
+
/** Which way it faces at the start (default 1, screen-right) */
|
|
57
|
+
facing?: 1 | -1;
|
|
58
|
+
/** The pose it starts in (default rest) */
|
|
59
|
+
start?: StickPose;
|
|
60
|
+
/** Lip-sync energy (default 1) */
|
|
61
|
+
energy?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface ScriptResult {
|
|
64
|
+
/** Every track the script writes, on the target */
|
|
65
|
+
tracks: Track[];
|
|
66
|
+
/** When the last beat ends, ms */
|
|
67
|
+
duration: number;
|
|
68
|
+
/** The spoken lines with their times, for captions */
|
|
69
|
+
lines: SpokenLine[];
|
|
70
|
+
/** The key poses, before acting */
|
|
71
|
+
keys: PoseKey[];
|
|
72
|
+
/** When each beat starts and ends, ms */
|
|
73
|
+
beats: Array<{
|
|
74
|
+
start: number;
|
|
75
|
+
end: number;
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
/** Time for one gait cycle (two steps), ms. */
|
|
79
|
+
export declare const GAIT_CYCLE_MS: Record<GaitName, number>;
|
|
80
|
+
/** How long a line takes to say, ms. */
|
|
81
|
+
export declare function speechDuration(text: string): number;
|
|
82
|
+
/** Compile beats into tracks on `target` (a `stickFigureTarget`). */
|
|
83
|
+
export declare function scriptTracks(target: string, beats: Beat[], options?: ScriptOptions): ScriptResult;
|