@algorisys/tinyfly 0.94.0 → 0.97.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 +6 -6
- package/docs/acting.md +170 -0
- package/docs/api-reference.md +3 -1
- package/docs/editor-guide.md +1 -1
- package/docs/examples.md +1 -1
- package/docs/getting-started.md +1 -1
- package/docs/gsap-compat.md +1 -1
- package/docs/llm-guide.md +41 -2
- package/docs/maps.md +2 -2
- package/docs/props.md +202 -0
- package/docs/scene-3d.md +141 -0
- package/docs/teaching.md +1 -1
- package/lib/addons/characters.js +6188 -2261
- package/lib/addons/scene-3d.js +140 -138
- package/lib/browser/tinyfly-scene-3d.iife.js +1 -1
- package/lib/browser/tinyfly.iife.js +17 -9
- package/lib/browser/tinyfly.js +8077 -4095
- package/lib/browser/tinyfly.umd.js +17 -9
- package/lib/engine/tinyfly-engine.js +612 -600
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/types/characters/acting/index.d.ts +1 -0
- package/lib/types/characters/acting/surface-script.d.ts +92 -0
- package/lib/types/characters/capabilities.d.ts +22 -0
- package/lib/types/characters/character-script-3d.d.ts +80 -0
- package/lib/types/characters/character.d.ts +19 -0
- package/lib/types/characters/chart.d.ts +108 -0
- package/lib/types/characters/code-panel.d.ts +21 -46
- package/lib/types/characters/ground-path.d.ts +32 -0
- package/lib/types/characters/index.d.ts +6 -0
- package/lib/types/characters/props/clip.d.ts +5 -0
- package/lib/types/characters/props/draw.d.ts +60 -0
- package/lib/types/characters/props/effects.d.ts +12 -0
- package/lib/types/characters/props/families/aircraft.d.ts +37 -0
- package/lib/types/characters/props/families/animals.d.ts +156 -0
- package/lib/types/characters/props/families/birds.d.ts +86 -0
- package/lib/types/characters/props/families/environment.d.ts +71 -0
- package/lib/types/characters/props/families/vehicle.d.ts +129 -0
- package/lib/types/characters/props/hidden.d.ts +49 -0
- package/lib/types/characters/props/index.d.ts +24 -0
- package/lib/types/characters/props/mesh-3d.d.ts +24 -0
- package/lib/types/characters/props/presets.d.ts +34 -0
- package/lib/types/characters/props/prop-surface.d.ts +63 -0
- package/lib/types/characters/props/ride-3d.d.ts +71 -0
- package/lib/types/characters/props/ride.d.ts +79 -0
- package/lib/types/characters/props/rig.d.ts +224 -0
- package/lib/types/characters/props/scene-objects.d.ts +2 -0
- package/lib/types/characters/props/script-3d.d.ts +85 -0
- package/lib/types/characters/props/script.d.ts +145 -0
- package/lib/types/characters/props/shapes.d.ts +96 -0
- package/lib/types/characters/props/slice.d.ts +66 -0
- package/lib/types/characters/props/target.d.ts +129 -0
- package/lib/types/characters/surface/edit-log.d.ts +47 -0
- package/lib/types/characters/surface/index.d.ts +11 -0
- package/lib/types/characters/surface/pieces.d.ts +61 -0
- package/lib/types/characters/surface/ride.d.ts +31 -0
- package/lib/types/characters/surface/surface-box.d.ts +18 -0
- package/lib/types/characters/surface/surface.d.ts +79 -0
- package/lib/types/characters/whiteboard.d.ts +131 -0
- package/lib/types/engine/authoring/index.d.ts +1 -0
- package/lib/types/engine/authoring/spring-follow.d.ts +25 -0
- package/lib/types/scene-3d/object-kind.d.ts +4 -1
- package/lib/types/scene-3d/scene-types.d.ts +41 -1
- package/llms-full.txt +699 -11
- package/llms.txt +28 -27
- package/package.json +1 -1
- package/skills/tinyfly/SKILL.md +37 -9
|
@@ -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 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 wt(t){return t.property==="motionPath"&&"motionPathConfig"in t}function Sn(t){return typeof t=="object"&&t!==null&&"x"in t&&"y"in t&&"angle"in t}function oe(t){return"keyframes"in t}class An{_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 wn{_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 ce(t,e){if(!(e>0))return t;const n=1e3/e;return Math.floor(t/n+1e-9)*n}function Pt(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 ue(t,e="start"){if(t<=1)return 0;let n=0;for(let r=0;r<t;r++)n=Math.max(n,Pt(r,t,e));return n}function vt(t,e,n){if(n.offsets)return n.offsets[t]??0;const r=n.from??"start",s=Pt(t,e,r);if(n.amount!==void 0){const a=ue(e,r);return a===0?0:n.amount*s/a}return n.each!==void 0?n.each*s:0}function le(t,e){return Array.from({length:t},(n,r)=>vt(r,t,e))}function ut(t,e){return t<=1?0:Math.max(...le(t,e))}const G=1,Rt=6e4,lt=Rt/G,x={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},Pn={gentle:{stiffness:120,damping:18,mass:1},default:{stiffness:180,damping:12,mass:1},snappy:{stiffness:280,damping:20,mass:1},bouncy:{stiffness:220,damping:8,mass:1},wobbly:{stiffness:180,damping:5,mass:1},stiff:{stiffness:400,damping:30,mass:1}};class 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:Rt}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 vn(t,e){return new tt(t).valueAt(e)}function Rn(t){return new tt(t).settleTime()}function In(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 Cn(t){const e=t.stiffness??x.stiffness,n=t.mass??x.mass;return 2*Math.sqrt(e*n)}const It=4,Dn=.002,En=1e-4,he=6e4;function ht(t){const e=t.friction??It;return e>0?e:It}function fe(t){return t.from+t.velocity/ht(t)}function $n(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=$n(fe(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*Dn);if(n>=e)return 0;const r=Math.log(e/n)/ht(t);return Math.min(he,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 On(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,de=t=>t*t,ge=t=>1-(1-t)*(1-t),me=t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,Ct=t=>t*t*t,Dt=t=>1-Math.pow(1-t,3),Et=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,pe=Ct,ye=Dt,Me=Et,Ln={linear:dt,"ease-in":pe,"ease-out":ye,"ease-in-out":Me,"ease-in-quad":de,"ease-out-quad":ge,"ease-in-out-quad":me,"ease-in-cubic":Ct,"ease-out-cubic":Dt,"ease-in-out-cubic":Et};function _e(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,f=1-c-l,u=m=>((o*m+i)*m+a)*m,d=m=>((f*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 w=u(p)-m;if(Math.abs(w)<1e-7)return p;const b=g(p);if(Math.abs(b)<1e-7)break;p-=w/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 Te(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 be=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 ke(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 Se(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 Ae(t){switch(t.type){case"steps":return Se(t.count,t.position);case"elastic":return $t(Te(t.amplitude,t.period),t.mode);case"bounce":return $t(be,t.mode);case"back":return $t(ke(t.overshoot),t.mode)}}function Ot(t){return t===void 0?dt:Q(t)?_e(t.points):ot(t)?Ae(t):Ln[t]??dt}const we=32,xn=256,K=new Map,Fn=/[MmLlHhVvCcSsQqTtAaZz]/,Nn=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Xn={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function zn(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(Fn.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=Nn.exec(t.slice(n));if(!c)break;r.args.push(parseFloat(c[0])),n+=c[0].length}return e}function Yn(t,e,n,r,s,a,i,o,c){if(t===o&&e===c)return[];let l=Math.abs(n),f=Math.abs(r);if(l===0||f===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)+_*_/(f*f);if(M>1){const D=Math.sqrt(M);l*=D,f*=D}const A=a===i?-1:1,w=l*l*f*f-l*l*_*_-f*f*p*p,b=l*l*_*_+f*f*p*p,R=A*Math.sqrt(Math.max(0,w/b)),v=R*l*_/f,$=-R*f*p/l,T=d*v-g*$+(t+o)/2,k=g*v+d*$+(e+c)/2,S=(D,O,L,Z)=>{const ie=D*L+O*Z,kt=Math.sqrt((D*D+O*O)*(L*L+Z*Z)),it=Math.acos(Math.max(-1,Math.min(1,ie/kt)));return D*Z-O*L<0?-it:it},P=S(1,0,(p-v)/l,(_-$)/f);let C=S((p-v)/l,(_-$)/f,(-p-v)/l,(-_-$)/f);!i&&C>0&&(C-=2*Math.PI),i&&C<0&&(C+=2*Math.PI);const I=Math.max(1,Math.ceil(Math.abs(C)/(Math.PI/2))),ae=C/I,bt=4/3*Math.tan(ae/4),Tn=D=>{const O=l*Math.cos(D),L=f*Math.sin(D);return[d*O-g*L+T,g*O+d*L+k]},bn=D=>{const O=-l*Math.sin(D),L=f*Math.cos(D);return[d*O-g*L,g*O+d*L]},kn=[];for(let D=0;D<I;D++){const O=P+D*ae,L=O+ae,[Z,ie]=Tn(O),[kt,it]=D===I-1?[o,c]:Tn(L),[ps,ys]=bn(O),[Ms,_s]=bn(L);kn.push([Z+bt*ps,ie+bt*ys,kt-bt*Ms,it-bt*_s,kt,it])}return kn}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 f=t,u=e,d=0;for(let g=1;g<=we;g++){const y=g/we,m=U(t,r,a,o,y),p=U(e,s,i,c,y);d+=Math.hypot(m-f,p-u),l.push(d),f=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 f=new Set,u=m=>{l<0&&(l=0),m.subpath=l,n.push(m)};for(const{type:m,args:p}of zn(t)){const _=m.toUpperCase(),M=m!==_,A=Xn[_];if(_==="Z"){(r!==a||s!==i)&&u(rt(r,s,a,i)),l>=0&&f.add(l),r=a,s=i,o=c=null;continue}for(let w=0;w+A<=p.length;w+=A){const b=p.slice(w,w+A),R=M?r:0,v=M?s:0;let $=null,T=null;switch(_){case"M":w===0?(r=b[0]+R,s=b[1]+v,a=r,i=s,(l<0||n[n.length-1]?.subpath===l)&&l++):(u(rt(r,s,b[0]+R,b[1]+v)),r=b[0]+R,s=b[1]+v);break;case"L":u(rt(r,s,b[0]+R,b[1]+v)),r=b[0]+R,s=b[1]+v;break;case"H":u(rt(r,s,b[0]+R,s)),r=b[0]+R;break;case"V":u(rt(r,s,r,b[0]+v)),s=b[0]+v;break;case"C":{const k=[b[0]+R,b[1]+v,b[2]+R,b[3]+v,b[4]+R,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],P=[k,S,b[0]+R,b[1]+v,b[2]+R,b[3]+v];u(gt(r,s,P)),$=[P[2],P[3]],r=P[4],s=P[5];break}case"Q":case"T":{let k=r,S=s;_==="Q"?(k=b[0]+R,S=b[1]+v):c&&(k=2*r-c[0],S=2*s-c[1]);const P=_==="Q"?b[2]+R:b[0]+R,C=_==="Q"?b[3]+v:b[1]+v;u(gt(r,s,[r+2/3*(k-r),s+2/3*(S-s),P+2/3*(k-P),C+2/3*(S-C),P,C])),T=[k,S],r=P,s=C;break}case"A":{const k=b[5]+R,S=b[6]+v;let P=r,C=s;for(const I of Yn(r,s,b[0],b[1],b[2],b[3],b[4],k,S))u(gt(P,C,I)),P=I[4],C=I[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],w=n[_-1],b=f.has(p)||Math.abs(w.endX-A.startX)<1e-9&&Math.abs(w.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>=xn&&K.delete(K.keys().next().value),K.set(t,y),y}function Un(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 Vn(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=Un(t,e);let l=Pe(t.startX,n,s,i,c),f=Pe(t.startY,r,a,o,c);if(Math.hypot(l,f)<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,f=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(f,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 Vn(i,e-s);s+=i.length}return{x:0,y:0,angle:0}}function ve(t,e){const{segments:n,totalLength:r}=B(t);return Lt(n,Math.max(0,Math.min(1,e))*r)}function jn(){K.clear()}function Bn(t){return B(t).totalLength}const Hn=24,Qn=320,Gn=2.5,st=72,Kn=64,Wn=.2,qn=128,at=new Map;let mt=0,V;const Re=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 Ce(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 De(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 Ee(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 Jn(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=Ee(De(t,st)),a=Ee(De(e,st)),i=st;let o={offset:0,reversed:!1},c=1/0;for(const l of[!1,!0]){const f=r?i:1;for(let u=0;u<f;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 Zn(t,e,n){return n?((e.reversed?e.offset-t:t+e.offset)%1+1)%1:e.reversed?1-t:t}function tr(t,e,n){return n?((e.reversed?e.offset-t:t-e.offset)%1+1)%1:e.reversed?1-t:t}function er(t,e,n){const r=t.closed&&e.closed,s=Jn(t,e,n.shapeIndex),a=Math.max(Hn,Math.min(Qn,Math.ceil(Math.max(t.length,e.length)/Gn))),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 Ce(t))o(u);for(const u of Ce(e))o(tr(u,s,r));let c=[...i].sort((u,d)=>u-d);r&&(c=c.filter(u=>u<1));const l=[],f=[];for(const u of c)l.push(...xt(t,u)),f.push(...xt(e,Zn(u,s,r)));return nr({from:l,to:f,closed:r})}function nr(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=Wn;for(let f=i+1;f<o;f++){const u=Math.max($e(t.from,i,o,f),$e(t.to,i,o,f));u>l&&(l=u,c=f)}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 $e(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,f=i*i+o*o,u=f===0?0:Math.max(0,Math.min(1,(c*i+l*o)/f));return Math.hypot(c-u*i,l-u*o)}function rr(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)=>er(g,c[y],n))};mt>=qn&&(at.clear(),mt=0);const f=String(r??"auto"),u=at.get(f)??new Map;at.set(f,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 Oe(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=rr(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=Re(o.from[c]+(o.to[c]-o.from[c])*s),f=Re(o.from[c+1]+(o.to[c+1]-o.from[c+1])*s);i+=`${c===0?i?" M":"M":" L"}${l} ${f}`}o.closed&&(i+=" Z")}return i}function sr(){at.clear(),mt=0,V=void 0}function Le(t){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(t)}const W=Math.PI/180,ar=.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 ir(t,e,n){return Nt(Nt(pt([0,1,0],e),pt([1,0,0],t)),pt([0,0,1],n))}function or(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),f=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(-f,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 xe(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Fe(t){return Math.hypot(t[0],t[1],t[2],t[3])}function H(t){const e=Fe(t);return e===0?Ft():[t[0]/e,t[1]/e,t[2]/e,t[3]/e]}function cr(t){return[-t[0],-t[1],-t[2],t[3]]}function Ne(t,e,n){const r=H(t);let s=H(e),a=xe(r,s);if(a<0&&(s=[-s[0],-s[1],-s[2],-s[3]],a=-a),a>ar)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 ur(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 lr=Object.freeze(Object.defineProperty({__proto__:null,conjugate:cr,dot:xe,fromAxisAngle:pt,fromEuler:ir,identity:Ft,length:Fe,multiply:Nt,normalize:H,rotateVec3:ur,slerp:Ne,toEuler:or},Symbol.toStringTag,{value:"Module"})),F=(t,e,n)=>t+(e-t)*n,Xe=512,Xt=new Map,zt=new Map;function ze(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<Xe&&Xt.set(t,r),r}const Ye=t=>t.charCodeAt(0)===35,Ue=t=>t.startsWith("rgb"),Ve=t=>t.startsWith("rgba"),hr=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Yt=t=>Math.round(t).toString(16).padStart(2,"0");function fr(t,e,n){return`#${Yt(t)}${Yt(e)}${Yt(n)}`}function je(t){const e=zt.get(t);if(e)return e;const n=t.match(hr);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<Xe&&zt.set(t,i),i}const Be=(t,e,n)=>{if(Ye(t)&&Ye(e)){const[r,s,a]=ze(t),[i,o,c]=ze(e),l=F(r,i,n),f=F(s,o,n),u=F(a,c,n);return fr(l,f,u)}if((Ue(t)||Ve(t))&&(Ue(e)||Ve(e))){const r=je(t),s=je(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,f=F(c,l,n);return`rgba(${a}, ${i}, ${o}, ${f})`}return`rgb(${a}, ${i}, ${o})`}return n<1?t:e},He=(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},Qe=(t,e,n)=>Ne(t,e,n),Ut=(t,e,n)=>n<1?t:e,Ge=(t,e,n)=>Oe(t,e,n);function Vt(t,e){return e==="slerp"?Qe:typeof t=="number"?F:Array.isArray(t)?He:typeof t=="string"?t.startsWith("#")||t.startsWith("rgb")?Be:Le(t)?Ge: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 Ke(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 Ke(t,r=>ft(n,r),nt(n),n.from,et(n),e)}function Ke(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 f=l[l.length-1];return!f||f.time<n+c?l.push({time:n+c,value:s,easing:"linear"}):f.value=s,c>0&&l.unshift({time:0,value:r,easing:"linear"}),{id:t.id,target:t.target,property:t.property,keyframes:o>0?Je(l,o):l,...t.targets&&{targets:[...t.targets]},...t.stagger&&{stagger:{...t.stagger}}}}function We(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 f=s;f<o;f+=s){const u=f/o;c.push({time:t.time+f,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 dr(t,e){return Y(t)?Bt(t,e):z(t)?Ht(t,e):t}function qe(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(...We(n[a-1],i,i.easing,s)):r.push(i)}return{...t,keyframes:r}}function gr(t,e){return t.filter(oe).map(n=>qe(n,e)).concat(t.filter(Y).map(n=>Bt(n,e)),t.filter(z).map(n=>Ht(n,e)))}function Je(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 tn{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 en{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={...ve(t.pathData,e)};if(t.matrix){const[r,s,a,i,o,c]=t.matrix,{x:l,y:f}=n;n.x=r*l+a*f+o,n.y=s*l+i*f+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 mr(t,e,n,r){const s=e+(n-e)*r;return Qt(t,s)}const Gt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},pr=20;function nn(t){const e=Gt[t??"upperCase"]??t??Gt.upperCase,n=Array.from(e);return n.length>0?n:Array.from(Gt.upperCase)}function yr(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 rn(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)),f=Math.max(0,(a-l)/(1-l)),u=Math.floor(f*o.length),d=t.tweenLength===!1?o.length:Math.round(i.length+(o.length-i.length)*a),g=nn(t.chars),y=t.refreshRate??pr,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,w=c?o[o.length-(d-M)]:o[M];A&&w!==void 0||w===" "||w===`
|
|
2
|
-
`?_+=w:_+=g[yr(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}get drawingRate(){return this._config.drawingRate??0}set drawingRate(e){const n={...this._config};e>0?n.drawingRate=e:delete n.drawingRate,this._config=n}play(){const e=this.duration;this._direction==="forward"&&this._currentTime>=e&&e>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&e>0&&(this._currentTime=e,this._loopIteration=0),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="idle",this._repeatDelayRemaining=0,this._wrapAfterDelay=!1,this._currentTime=0,this._loopIteration=0,this._direction="forward"}seek(e){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(e,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(e){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let s=e*this.speed;if(this._repeatDelayRemaining>0){const 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(e=ce(e,this._config.drawingRate??0),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 f=`${o}\0${i}`,u=l<=e,d=r.get(f);(!d||(u!==d.started?u:u?l>=d.start:l<=d.start))&&r.set(f,{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",rn(c.textConfig,a,Math.max(0,i)));return}const l=this._motionPathTracks.get(n);if(l&&typeof a=="number"){const f=Qt(l.motionPathConfig,a);o.set("motionPathX",f.x),o.set("motionPathY",f.y),l.motionPathConfig.autoRotate&&o.set("motionPathRotate",f.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 en(e));return}if(Y(e)){this._trackPlayers.set(e.id,new tn(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(wt(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 f=s.from>=c.from;for(const u of o)e.push({target:u,property:r.property,losingTrackId:f?i.id:r.id,winningTrackId:f?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 Mr=100;function _r(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,f=e.direction,u=e.fresh===!0;const d=Math.min(Mr,Math.max(0,n.iteration-e.iteration));for(let g=0;g<d;g++){const y=f==="forward"?i:0;c(l,y,f,u),s.push({kind:"repeat"}),o?(f=f==="forward"?"reverse":"forward",l=y,u=!1):(l=f==="forward"?0:i,u=!0)}return d>0&&r.holding&&!o?{crossings:s,passes:a}:(c(l,n.time,f,u),{crossings:s,passes:a})}function sn(t){return z(t)?{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:an(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)}:wt(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 an(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 on(t){if(z(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:an(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 cn(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,...t._config.drawingRate?{drawingRate:t._config.drawingRate}:{},...e&&{markers:e.map(n=>({...n}))}},tracks:t.tracks.map(sn),...t.captions&&{captions:JSON.parse(JSON.stringify(t.captions))}}}function un(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(on),captions:t.captions})}function Tr(t){return JSON.stringify(cn(t))}function br(t){const e=JSON.parse(t);return un(e)}function kr(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 Jt(t,e,n){return e+t.next()*(n-e)}function ln(t,e,n,r){if(r<=0)return Jt(t,e,n);const s=Math.floor((n-e)/r),a=Math.round(t.next()*s);return e+a*r}function Sr(t,e){if(e.length!==0)return e[Math.floor(t.next()*e.length)]}const hn=/^([+\-*/])=\s*(-?[\d.]+)$/,fn=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Ar(t){return typeof t!="string"?!1:hn.test(t.trim())||fn.test(t.trim())}function Zt(t,e={}){if(typeof t!="string")return t;const n=t.trim(),r=hn.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=fn.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?ln(e.random,a,i,o):Jt(e.random,a,i)}return t}function dn(t,e=0,n){const r=[];let s=e;for(const a of t){const i=Zt(a,{base:s,random:n});r.push(i),typeof i=="number"&&(s=i)}return r}class wr{random;constructor(e){this.random=qt(e)}get seed(){return this.random.seed}resolve(e,n=0){return Zt(e,{base:n,random:this.random})}resolveSequence(e,n=0){return dn(e,n,this.random)}}const Pr=600;function vr(t){if(Array.isArray(t)){const[d,g,y,m]=t;return{fn:gn(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:gn(...p),bezier:p}}const l=[],f=[],u=Math.max(8,Math.ceil(Pr/e.length));for(const d of e)for(let g=l.length===0?0:1;g<=u;g++){const[y,m]=Cr(d,g/u);l.push(o(y)),f.push(c(m))}return{fn:Dr(l,f)}}function Rr(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,f=i-c;return 1-(l-f*f)}i-=r[o]}return 1}}function Ir(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 Cr(t,e){if(t.type==="L"){const[l,f]=t.points;return[t.startX+(l-t.startX)*e,t.startY+(f-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 Dr(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 gn(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 f=0;f<8;f++){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 f=0;f<40;f++)s(o,t,n)<i?c=o:l=o,o=(c+l)/2;return s(o,e,r)}}const Er=350,$r=300,Or=550;function Lr(t,e={}){const n=e.lead??Er,r=e.gap??$r,s=e.tail??Or,a=[];let i=0;return t.forEach((o,c)=>{const l=[];let f=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&&(f+=r),l.push({id:d.id??`s${c}-l${g}`,scene:c,line:g,start:f,end:f+d.duration,text:d.text}),f+=d.duration});const u=f+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 xr(t){return t.cues.map(e=>({id:e.id,time:e.start,label:e.text}))}function Fr(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 Nr(t,e){return Mt(t,Math.round(_t(t,e)))}function Xr(t,e){return Mt(t,Math.ceil(_t(t,e)-1e-9))}function zr(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 J=100;function Yr(t,e,n={}){const r=n.minBpm??70,s=n.maxBpm??180,a=Math.max(1,Math.round(e/J)),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 f=l.reduce((T,k)=>T+k,0)/o;for(let T=0;T<o;T++)l[T]=Math.max(0,l[T]-f);const u=Math.max(1,Math.floor(60*J/s)),d=Math.min(o-1,Math.ceil(60*J/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*J/T,S=Math.exp(-.5*(Math.log2(k/120)/.9)**2),P=g(T)*S;P>p&&(p=P,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 P=k;P<o;P+=T)S+=_(P);return S};let A=m,w=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 P=S/k*T,C=M(T,P);C>b&&(b=C,w=P,A=T)}}const R=60*J/A,v=y>0?Math.max(0,Math.min(1,g(m)/y)):0,$=(w+.5)*1e3/J;return{bpm:Math.round(R*100)/100,offset:Math.round($%(6e4/R)),confidence:v}}const Ur=600,Vr=250,mn=1;function jr(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),f=l.filter(u=>!("shake"in u));f.length>0&&o(0,c);for(const u of f)if("frame"in u){const d=Math.max(mn,u.duration??Ur);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>mn?"ease-in-out":void 0))}else{const{follow:d}=u,g=d.lag??Vr,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(w=>w.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}))}function pn(t,e){const n=t.toLowerCase(),r=e.toLowerCase();let s=Array.from({length:r.length+1},(a,i)=>i);for(let a=1;a<=n.length;a++){const i=[a];for(let o=1;o<=r.length;o++)i[o]=Math.min(s[o]+1,i[o-1]+1,s[o-1]+(n[a-1]===r[o-1]?0:1));s=i}return s[r.length]}function yn(t,e){const n=t.toLowerCase(),r=e.find(i=>i.toLowerCase().includes(n)||n.includes(i.toLowerCase()));if(r&&Math.min(t.length,r.length)>=3)return r;let s,a=1/0;for(const i of e){const o=pn(t,i);o<a&&(a=o,s=i)}return s!==void 0&&a<=Math.max(2,Math.floor(t.length/3))?s:void 0}function Br(t,e,n,r){const s=typeof e=="string"?r??yn(e,n):void 0;return`Unknown ${t} ${JSON.stringify(e)}${s?`: did you mean "${s}"?`:"."} Known: ${n.join(", ")}`}const X=t=>Math.round(t*1e3)/1e3;function Hr(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),f=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=f.x+(u.x-l.x)*g,m=f.y+(u.y-l.y)*g,p=u.x-(d.x-f.x)*g,_=u.y-(d.y-f.y)*g;a+=` C${X(y)} ${X(m)} ${X(p)} ${X(_)} ${X(u.x)} ${X(u.y)}`}return r?`${a} Z`:a}const E=(t,e=0)=>{const n=parseFloat(t??"");return Number.isFinite(n)?n:e};function Qr(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 Gr(t){const e=t.attributes;switch(t.tag.toLowerCase()){case"path":return e.d??null;case"circle":case"ellipse":{const n=E(e.cx),r=E(e.cy),s=t.tag.toLowerCase()==="circle"?E(e.r):E(e.rx),a=t.tag.toLowerCase()==="circle"?E(e.r):E(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=E(e.x),r=E(e.y),s=E(e.width),a=E(e.height);let i=e.rx!=null?E(e.rx):e.ry!=null?E(e.ry):0,o=e.ry!=null?E(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${E(e.x1)} ${E(e.y1)} L${E(e.x2)} ${E(e.y2)}`;case"polyline":case"polygon":{const n=Qr(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 Kr(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),f=i&&i>0&&c<r-1?(l%i+i)%i:l;o.push({at:t(f),time:l,age:s>0?(e-l)/s:0})}return o}const Wr=2.5;function qr(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,f=Math.hypot(c,l);if(f>1e-9)return[c/f,l/f]}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],f=c??o??[1,0];let u=l[0]+f[0],d=l[1]+f[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(Wr,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 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,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 Zr(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 ts(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 es(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 ns=Object.freeze(Object.defineProperty({__proto__:null,add:Zr,cross:ne,distance:ts,dot:Tt,length:re,lerp:es,normalize:se,scale:Mn,subtract:ee},Symbol.toStringTag,{value:"Module"})),rs=Math.PI/180;function ss(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function as(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 is(t){return[1,0,0,0,0,1,0,0,0,0,1,0,t[0],t[1],t[2],1]}function os(t){return[t[0],0,0,0,0,t[1],0,0,0,0,t[2],0,0,0,0,1]}function _n(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 cs(t,e,n){const r=_n(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 us(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 ls(t){const[e,n,r,s,a,i,o,c,l,f,u,d,g,y,m,p]=t,_=e*i-n*a,M=e*o-r*a,A=e*c-s*a,w=n*o-r*i,b=n*c-s*i,R=r*c-s*o,v=l*y-f*g,$=l*m-u*g,T=l*p-d*g,k=f*m-u*y,S=f*p-d*y,P=u*p-d*m,C=_*P-M*S+A*k+w*T-b*$+R*v;if(Math.abs(C)<1e-12)return null;const I=1/C;return[(i*P-o*S+c*k)*I,(r*S-n*P-s*k)*I,(y*R-m*b+p*w)*I,(u*b-f*R-d*w)*I,(o*T-a*P-c*$)*I,(e*P-r*T+s*$)*I,(m*A-g*R-p*M)*I,(l*R-u*A+d*M)*I,(a*S-i*T+c*v)*I,(n*T-e*S-s*v)*I,(g*b-y*A+p*_)*I,(f*A-l*b-d*_)*I,(i*$-a*k-o*v)*I,(e*k-n*$+r*v)*I,(y*M-g*w-m*_)*I,(l*w-f*M+u*_)*I]}function hs(t,e,n,r){const s=1/Math.tan(t*rs/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 fs(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 ds(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 gs(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 ms=Object.freeze(Object.defineProperty({__proto__:null,compose:cs,fromQuat:_n,identity:ss,invert:ls,lookAt:ds,multiply:as,orthographic:fs,perspective:hs,scaling:os,transformPoint:gs,translation:is,transpose:us},Symbol.toStringTag,{value:"Module"}));h.Clock=wn,h.DEFAULT_BAKE_INTERVAL_MS=jt,h.DEFAULT_INERTIA_FRICTION=It,h.DEFAULT_SPRING=x,h.FORMAT_VERSION=St,h.INERTIA_MAX_DURATION_MS=he,h.InertiaTrackPlayer=en,h.MORPH_SAMPLES=Kn,h.ManualClock=An,h.SPRING_MAX_DURATION_MS=Rt,h.SPRING_PRESETS=Pn,h.SPRING_STEP_MS=G,h.SpringSampler=tt,h.SpringTrackPlayer=tn,h.Timeline=Kt,h.TrackPlayer=yt,h.ValueResolver=wr,h.backOut=ke,h.bakeEasing=We,h.bakeInertiaTrack=Ht,h.bakeSpringTrack=Bt,h.beatAtTime=_t,h.beatLength=te,h.beatTime=Mt,h.beatsBetween=zr,h.bounceOut=be,h.cameraTracks=jr,h.charactersFor=nn,h.clearMorphCache=sr,h.clearPathCache=jn,h.closestName=yn,h.createCubicBezier=_e,h.createRandom=qt,h.createTrack=Ze,h.criticalDamping=Cn,h.customBounce=Rr,h.customEase=vr,h.customWiggle=Ir,h.deserializeTimeline=un,h.deserializeTrack=on,h.detectTempo=Yr,h.easeIn=pe,h.easeInCubic=Ct,h.easeInOut=Me,h.easeInOutCubic=Et,h.easeInOutQuad=me,h.easeInQuad=de,h.easeOut=ye,h.easeOutCubic=Dt,h.easeOutQuad=ge,h.editDistance=pn,h.elasticOut=Te,h.expandParametricEasings=qe,h.formatVersionFor=At,h.fromJSON=br,h.getEasingFunction=Ot,h.getInterpolator=Vt,h.getMotionPathPoint=Qt,h.getPathLength=Bn,h.getPointAtProgress=ve,h.hasKeyframes=oe,h.hashSeed=kr,h.heldTime=ce,h.inertiaDuration=nt,h.inertiaRest=et,h.inertiaValueAt=ft,h.inertiaVelocityAt=On,h.interpolateArray=He,h.interpolateColor=Be,h.interpolateMotionPath=mr,h.interpolateNumber=F,h.interpolatePathString=Ge,h.interpolateQuaternion=Qe,h.interpolateString=Ut,h.isCubicBezierEasing=Q,h.isInertiaTrack=z,h.isMotionPathPoint=Sn,h.isMotionPathTrack=wt,h.isParametricEasing=ot,h.isPathData=Le,h.isSpringTrack=Y,h.isTextTrack=ct,h.isUnderdamped=In,h.isUnresolved=Ar,h.linear=dt,h.mat4=ms,h.maxStaggerDistance=ue,h.morphPath=Oe,h.narrationMarkers=xr,h.narrationSceneAt=Fr,h.naturalRest=fe,h.nearestBeat=Nr,h.nextBeat=Xr,h.parametricEasing=Ae,h.parsePath=B,h.planNarration=Lr,h.playheadCrossings=_r,h.pointAtDistance=Lt,h.pointsToPath=Hr,h.quat=lr,h.randomBetween=Jt,h.randomChoice=Sr,h.randomSnapped=ln,h.resolveSequence=dn,h.resolveValue=Zt,h.ribbon=qr,h.ribbonHeadCap=Jr,h.serializeTimeline=cn,h.serializeTrack=sn,h.shapeToPathData=Gr,h.simplifyKeyframes=Je,h.springDuration=Rn,h.springValueAt=vn,h.staggerDistance=Pt,h.staggerOffset=vt,h.staggerOffsets=le,h.staggerSpan=ut,h.stepsEasing=Se,h.textAt=rn,h.toJSON=Tr,h.toKeyframedTrack=dr,h.toKeyframedTracks=gr,h.trackTargets=j,h.trailSamples=Kr,h.unknownName=Br,h.vec3=ns,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 wt(t){return t.property==="motionPath"&&"motionPathConfig"in t}function Sn(t){return typeof t=="object"&&t!==null&&"x"in t&&"y"in t&&"angle"in t}function oe(t){return"keyframes"in t}class An{_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 wn{_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 ce(t,e){if(!(e>0))return t;const n=1e3/e;return Math.floor(t/n+1e-9)*n}function Pt(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 ue(t,e="start"){if(t<=1)return 0;let n=0;for(let r=0;r<t;r++)n=Math.max(n,Pt(r,t,e));return n}function vt(t,e,n){if(n.offsets)return n.offsets[t]??0;const r=n.from??"start",s=Pt(t,e,r);if(n.amount!==void 0){const a=ue(e,r);return a===0?0:n.amount*s/a}return n.each!==void 0?n.each*s:0}function le(t,e){return Array.from({length:t},(n,r)=>vt(r,t,e))}function ut(t,e){return t<=1?0:Math.max(...le(t,e))}const G=1,Rt=6e4,lt=Rt/G,x={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1},Pn={gentle:{stiffness:120,damping:18,mass:1},default:{stiffness:180,damping:12,mass:1},snappy:{stiffness:280,damping:20,mass:1},bouncy:{stiffness:220,damping:8,mass:1},wobbly:{stiffness:180,damping:5,mass:1},stiff:{stiffness:400,damping:30,mass:1}};class 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:Rt}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 vn(t,e){return new tt(t).valueAt(e)}function Rn(t){return new tt(t).settleTime()}function In(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 Cn(t){const e=t.stiffness??x.stiffness,n=t.mass??x.mass;return 2*Math.sqrt(e*n)}const It=4,Dn=.002,En=1e-4,he=6e4;function ht(t){const e=t.friction??It;return e>0?e:It}function fe(t){return t.from+t.velocity/ht(t)}function $n(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=$n(fe(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*Dn);if(n>=e)return 0;const r=Math.log(e/n)/ht(t);return Math.min(he,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 On(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,de=t=>t*t,ge=t=>1-(1-t)*(1-t),me=t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2,Ct=t=>t*t*t,Dt=t=>1-Math.pow(1-t,3),Et=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,pe=Ct,ye=Dt,Me=Et,Ln={linear:dt,"ease-in":pe,"ease-out":ye,"ease-in-out":Me,"ease-in-quad":de,"ease-out-quad":ge,"ease-in-out-quad":me,"ease-in-cubic":Ct,"ease-out-cubic":Dt,"ease-in-out-cubic":Et};function _e(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 w=u(p)-m;if(Math.abs(w)<1e-7)return p;const b=g(p);if(Math.abs(b)<1e-7)break;p-=w/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 Te(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 be=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 ke(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 Se(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 Ae(t){switch(t.type){case"steps":return Se(t.count,t.position);case"elastic":return $t(Te(t.amplitude,t.period),t.mode);case"bounce":return $t(be,t.mode);case"back":return $t(ke(t.overshoot),t.mode)}}function Ot(t){return t===void 0?dt:Q(t)?_e(t.points):ot(t)?Ae(t):Ln[t]??dt}const we=32,xn=256,K=new Map,Fn=/[MmLlHhVvCcSsQqTtAaZz]/,Nn=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Xn={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function zn(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(Fn.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=Nn.exec(t.slice(n));if(!c)break;r.args.push(parseFloat(c[0])),n+=c[0].length}return e}function Yn(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,w=l*l*h*h-l*l*_*_-h*h*p*p,b=l*l*_*_+h*h*p*p,R=A*Math.sqrt(Math.max(0,w/b)),v=R*l*_/h,$=-R*h*p/l,T=d*v-g*$+(t+o)/2,k=g*v+d*$+(e+c)/2,S=(D,O,L,Z)=>{const ie=D*L+O*Z,kt=Math.sqrt((D*D+O*O)*(L*L+Z*Z)),it=Math.acos(Math.max(-1,Math.min(1,ie/kt)));return D*Z-O*L<0?-it:it},P=S(1,0,(p-v)/l,(_-$)/h);let C=S((p-v)/l,(_-$)/h,(-p-v)/l,(-_-$)/h);!i&&C>0&&(C-=2*Math.PI),i&&C<0&&(C+=2*Math.PI);const I=Math.max(1,Math.ceil(Math.abs(C)/(Math.PI/2))),ae=C/I,bt=4/3*Math.tan(ae/4),Tn=D=>{const O=l*Math.cos(D),L=h*Math.sin(D);return[d*O-g*L+T,g*O+d*L+k]},bn=D=>{const O=-l*Math.sin(D),L=h*Math.cos(D);return[d*O-g*L,g*O+d*L]},kn=[];for(let D=0;D<I;D++){const O=P+D*ae,L=O+ae,[Z,ie]=Tn(O),[kt,it]=D===I-1?[o,c]:Tn(L),[ys,Ms]=bn(O),[_s,Ts]=bn(L);kn.push([Z+bt*ys,ie+bt*Ms,kt-bt*_s,it-bt*Ts,kt,it])}return kn}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<=we;g++){const y=g/we,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 zn(t)){const _=m.toUpperCase(),M=m!==_,A=Xn[_];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 w=0;w+A<=p.length;w+=A){const b=p.slice(w,w+A),R=M?r:0,v=M?s:0;let $=null,T=null;switch(_){case"M":w===0?(r=b[0]+R,s=b[1]+v,a=r,i=s,(l<0||n[n.length-1]?.subpath===l)&&l++):(u(rt(r,s,b[0]+R,b[1]+v)),r=b[0]+R,s=b[1]+v);break;case"L":u(rt(r,s,b[0]+R,b[1]+v)),r=b[0]+R,s=b[1]+v;break;case"H":u(rt(r,s,b[0]+R,s)),r=b[0]+R;break;case"V":u(rt(r,s,r,b[0]+v)),s=b[0]+v;break;case"C":{const k=[b[0]+R,b[1]+v,b[2]+R,b[3]+v,b[4]+R,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],P=[k,S,b[0]+R,b[1]+v,b[2]+R,b[3]+v];u(gt(r,s,P)),$=[P[2],P[3]],r=P[4],s=P[5];break}case"Q":case"T":{let k=r,S=s;_==="Q"?(k=b[0]+R,S=b[1]+v):c&&(k=2*r-c[0],S=2*s-c[1]);const P=_==="Q"?b[2]+R:b[0]+R,C=_==="Q"?b[3]+v:b[1]+v;u(gt(r,s,[r+2/3*(k-r),s+2/3*(S-s),P+2/3*(k-P),C+2/3*(S-C),P,C])),T=[k,S],r=P,s=C;break}case"A":{const k=b[5]+R,S=b[6]+v;let P=r,C=s;for(const I of Yn(r,s,b[0],b[1],b[2],b[3],b[4],k,S))u(gt(P,C,I)),P=I[4],C=I[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],w=n[_-1],b=h.has(p)||Math.abs(w.endX-A.startX)<1e-9&&Math.abs(w.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>=xn&&K.delete(K.keys().next().value),K.set(t,y),y}function Un(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 Vn(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=Un(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 Vn(i,e-s);s+=i.length}return{x:0,y:0,angle:0}}function ve(t,e){const{segments:n,totalLength:r}=B(t);return Lt(n,Math.max(0,Math.min(1,e))*r)}function jn(){K.clear()}function Bn(t){return B(t).totalLength}const Hn=24,Qn=320,Gn=2.5,st=72,Kn=64,Wn=.2,qn=128,at=new Map;let mt=0,V;const Re=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 Ce(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 De(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 Ee(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 Jn(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=Ee(De(t,st)),a=Ee(De(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 Zn(t,e,n){return n?((e.reversed?e.offset-t:t+e.offset)%1+1)%1:e.reversed?1-t:t}function tr(t,e,n){return n?((e.reversed?e.offset-t:t-e.offset)%1+1)%1:e.reversed?1-t:t}function er(t,e,n){const r=t.closed&&e.closed,s=Jn(t,e,n.shapeIndex),a=Math.max(Hn,Math.min(Qn,Math.ceil(Math.max(t.length,e.length)/Gn))),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 Ce(t))o(u);for(const u of Ce(e))o(tr(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,Zn(u,s,r)));return nr({from:l,to:h,closed:r})}function nr(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=Wn;for(let h=i+1;h<o;h++){const u=Math.max($e(t.from,i,o,h),$e(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 $e(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 rr(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)=>er(g,c[y],n))};mt>=qn&&(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 Oe(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=rr(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=Re(o.from[c]+(o.to[c]-o.from[c])*s),h=Re(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 sr(){at.clear(),mt=0,V=void 0}function Le(t){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(t)}const W=Math.PI/180,ar=.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 ir(t,e,n){return Nt(Nt(pt([0,1,0],e),pt([1,0,0],t)),pt([0,0,1],n))}function or(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 xe(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Fe(t){return Math.hypot(t[0],t[1],t[2],t[3])}function H(t){const e=Fe(t);return e===0?Ft():[t[0]/e,t[1]/e,t[2]/e,t[3]/e]}function cr(t){return[-t[0],-t[1],-t[2],t[3]]}function Ne(t,e,n){const r=H(t);let s=H(e),a=xe(r,s);if(a<0&&(s=[-s[0],-s[1],-s[2],-s[3]],a=-a),a>ar)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 ur(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 lr=Object.freeze(Object.defineProperty({__proto__:null,conjugate:cr,dot:xe,fromAxisAngle:pt,fromEuler:ir,identity:Ft,length:Fe,multiply:Nt,normalize:H,rotateVec3:ur,slerp:Ne,toEuler:or},Symbol.toStringTag,{value:"Module"})),F=(t,e,n)=>t+(e-t)*n,Xe=512,Xt=new Map,zt=new Map;function ze(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<Xe&&Xt.set(t,r),r}const Ye=t=>t.charCodeAt(0)===35,Ue=t=>t.startsWith("rgb"),Ve=t=>t.startsWith("rgba"),hr=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,Yt=t=>Math.round(t).toString(16).padStart(2,"0");function fr(t,e,n){return`#${Yt(t)}${Yt(e)}${Yt(n)}`}function je(t){const e=zt.get(t);if(e)return e;const n=t.match(hr);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<Xe&&zt.set(t,i),i}const Be=(t,e,n)=>{if(Ye(t)&&Ye(e)){const[r,s,a]=ze(t),[i,o,c]=ze(e),l=F(r,i,n),h=F(s,o,n),u=F(a,c,n);return fr(l,h,u)}if((Ue(t)||Ve(t))&&(Ue(e)||Ve(e))){const r=je(t),s=je(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},He=(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},Qe=(t,e,n)=>Ne(t,e,n),Ut=(t,e,n)=>n<1?t:e,Ge=(t,e,n)=>Oe(t,e,n);function Vt(t,e){return e==="slerp"?Qe:typeof t=="number"?F:Array.isArray(t)?He:typeof t=="string"?t.startsWith("#")||t.startsWith("rgb")?Be:Le(t)?Ge: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 Ke(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 Ke(t,r=>ft(n,r),nt(n),n.from,et(n),e)}function Ke(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?Je(l,o):l,...t.targets&&{targets:[...t.targets]},...t.stagger&&{stagger:{...t.stagger}}}}function We(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 dr(t,e){return Y(t)?Bt(t,e):z(t)?Ht(t,e):t}function qe(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(...We(n[a-1],i,i.easing,s)):r.push(i)}return{...t,keyframes:r}}function gr(t,e){return t.filter(oe).map(n=>qe(n,e)).concat(t.filter(Y).map(n=>Bt(n,e)),t.filter(z).map(n=>Ht(n,e)))}function Je(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 tn{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 en{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={...ve(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 mr(t,e,n,r){const s=e+(n-e)*r;return Qt(t,s)}const Gt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},pr=20;function nn(t){const e=Gt[t??"upperCase"]??t??Gt.upperCase,n=Array.from(e);return n.length>0?n:Array.from(Gt.upperCase)}function yr(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 rn(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=nn(t.chars),y=t.refreshRate??pr,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,w=c?o[o.length-(d-M)]:o[M];A&&w!==void 0||w===" "||w===`
|
|
2
|
+
`?_+=w:_+=g[yr(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}get drawingRate(){return this._config.drawingRate??0}set drawingRate(e){const n={...this._config};e>0?n.drawingRate=e:delete n.drawingRate,this._config=n}play(){const e=this.duration;this._direction==="forward"&&this._currentTime>=e&&e>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&e>0&&(this._currentTime=e,this._loopIteration=0),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="idle",this._repeatDelayRemaining=0,this._wrapAfterDelay=!1,this._currentTime=0,this._loopIteration=0,this._direction="forward"}seek(e){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(e,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(e){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let s=e*this.speed;if(this._repeatDelayRemaining>0){const 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(e=ce(e,this._config.drawingRate??0),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",rn(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 en(e));return}if(Y(e)){this._trackPlayers.set(e.id,new tn(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(wt(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 Mr=100;function _r(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(Mr,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 sn(t){return z(t)?{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:an(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)}:wt(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 an(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 on(t){if(z(t)){const e=t;return{id:e.id,target:e.target,property:e.property,kind:"inertia",inertia:an(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 cn(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,...t._config.drawingRate?{drawingRate:t._config.drawingRate}:{},...e&&{markers:e.map(n=>({...n}))}},tracks:t.tracks.map(sn),...t.captions&&{captions:JSON.parse(JSON.stringify(t.captions))}}}function un(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(on),captions:t.captions})}function Tr(t){return JSON.stringify(cn(t))}function br(t){const e=JSON.parse(t);return un(e)}function kr(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 Jt(t,e,n){return e+t.next()*(n-e)}function ln(t,e,n,r){if(r<=0)return Jt(t,e,n);const s=Math.floor((n-e)/r),a=Math.round(t.next()*s);return e+a*r}function Sr(t,e){if(e.length!==0)return e[Math.floor(t.next()*e.length)]}const hn=/^([+\-*/])=\s*(-?[\d.]+)$/,fn=/^random\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*(?:,\s*(-?[\d.]+)\s*)?\)$/i;function Ar(t){return typeof t!="string"?!1:hn.test(t.trim())||fn.test(t.trim())}function Zt(t,e={}){if(typeof t!="string")return t;const n=t.trim(),r=hn.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=fn.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?ln(e.random,a,i,o):Jt(e.random,a,i)}return t}function dn(t,e=0,n){const r=[];let s=e;for(const a of t){const i=Zt(a,{base:s,random:n});r.push(i),typeof i=="number"&&(s=i)}return r}class wr{random;constructor(e){this.random=qt(e)}get seed(){return this.random.seed}resolve(e,n=0){return Zt(e,{base:n,random:this.random})}resolveSequence(e,n=0){return dn(e,n,this.random)}}const Pr=600;function vr(t){if(Array.isArray(t)){const[d,g,y,m]=t;return{fn:gn(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:gn(...p),bezier:p}}const l=[],h=[],u=Math.max(8,Math.ceil(Pr/e.length));for(const d of e)for(let g=l.length===0?0:1;g<=u;g++){const[y,m]=Cr(d,g/u);l.push(o(y)),h.push(c(m))}return{fn:Dr(l,h)}}function Rr(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 Ir(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 Cr(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 Dr(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 gn(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,$r=300,Or=550;function Lr(t,e={}){const n=e.lead??Er,r=e.gap??$r,s=e.tail??Or,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 xr(t){return t.cues.map(e=>({id:e.id,time:e.start,label:e.text}))}function Fr(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 Nr(t,e){return Mt(t,Math.round(_t(t,e)))}function Xr(t,e){return Mt(t,Math.ceil(_t(t,e)-1e-9))}function zr(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 J=100;function Yr(t,e,n={}){const r=n.minBpm??70,s=n.maxBpm??180,a=Math.max(1,Math.round(e/J)),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*J/s)),d=Math.min(o-1,Math.ceil(60*J/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*J/T,S=Math.exp(-.5*(Math.log2(k/120)/.9)**2),P=g(T)*S;P>p&&(p=P,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 P=k;P<o;P+=T)S+=_(P);return S};let A=m,w=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 P=S/k*T,C=M(T,P);C>b&&(b=C,w=P,A=T)}}const R=60*J/A,v=y>0?Math.max(0,Math.min(1,g(m)/y)):0,$=(w+.5)*1e3/J;return{bpm:Math.round(R*100)/100,offset:Math.round($%(6e4/R)),confidence:v}}const Ur=600,Vr=250,mn=1;function jr(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(mn,u.duration??Ur);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>mn?"ease-in-out":void 0))}else{const{follow:d}=u,g=d.lag??Vr,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(w=>w.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}))}function pn(t,e){const n=t.toLowerCase(),r=e.toLowerCase();let s=Array.from({length:r.length+1},(a,i)=>i);for(let a=1;a<=n.length;a++){const i=[a];for(let o=1;o<=r.length;o++)i[o]=Math.min(s[o]+1,i[o-1]+1,s[o-1]+(n[a-1]===r[o-1]?0:1));s=i}return s[r.length]}function yn(t,e){const n=t.toLowerCase(),r=e.find(i=>i.toLowerCase().includes(n)||n.includes(i.toLowerCase()));if(r&&Math.min(t.length,r.length)>=3)return r;let s,a=1/0;for(const i of e){const o=pn(t,i);o<a&&(a=o,s=i)}return s!==void 0&&a<=Math.max(2,Math.floor(t.length/3))?s:void 0}function Br(t,e,n,r){const s=typeof e=="string"?r??yn(e,n):void 0;return`Unknown ${t} ${JSON.stringify(e)}${s?`: did you mean "${s}"?`:"."} Known: ${n.join(", ")}`}function Hr(t,e){const n=e.step??33,r=e.stiffness??120,s=e.damping??9,a=e.mass??1;let i=t(e.start),o=0;const c=[{time:e.start,value:i}];let l=e.start+n;for(let h=e.start+1;h<=e.end;h++){const d=r*(t(h)-i)-s*o;o+=d/a*.001,i+=o*.001,(h>=l||h===e.end)&&(c.push({time:h,value:i}),l+=n)}return c}const X=t=>Math.round(t*1e3)/1e3;function Qr(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 E=(t,e=0)=>{const n=parseFloat(t??"");return Number.isFinite(n)?n:e};function Gr(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 Kr(t){const e=t.attributes;switch(t.tag.toLowerCase()){case"path":return e.d??null;case"circle":case"ellipse":{const n=E(e.cx),r=E(e.cy),s=t.tag.toLowerCase()==="circle"?E(e.r):E(e.rx),a=t.tag.toLowerCase()==="circle"?E(e.r):E(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=E(e.x),r=E(e.y),s=E(e.width),a=E(e.height);let i=e.rx!=null?E(e.rx):e.ry!=null?E(e.ry):0,o=e.ry!=null?E(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${E(e.x1)} ${E(e.y1)} L${E(e.x2)} ${E(e.y2)}`;case"polyline":case"polygon":{const n=Gr(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 Wr(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 Jr(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 Zr(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 ts(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 es(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 ns(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 rs=Object.freeze(Object.defineProperty({__proto__:null,add:ts,cross:ne,distance:es,dot:Tt,length:re,lerp:ns,normalize:se,scale:Mn,subtract:ee},Symbol.toStringTag,{value:"Module"})),ss=Math.PI/180;function as(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function is(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 os(t){return[1,0,0,0,0,1,0,0,0,0,1,0,t[0],t[1],t[2],1]}function cs(t){return[t[0],0,0,0,0,t[1],0,0,0,0,t[2],0,0,0,0,1]}function _n(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 us(t,e,n){const r=_n(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 ls(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 hs(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,w=n*o-r*i,b=n*c-s*i,R=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,P=u*p-d*m,C=_*P-M*S+A*k+w*T-b*$+R*v;if(Math.abs(C)<1e-12)return null;const I=1/C;return[(i*P-o*S+c*k)*I,(r*S-n*P-s*k)*I,(y*R-m*b+p*w)*I,(u*b-h*R-d*w)*I,(o*T-a*P-c*$)*I,(e*P-r*T+s*$)*I,(m*A-g*R-p*M)*I,(l*R-u*A+d*M)*I,(a*S-i*T+c*v)*I,(n*T-e*S-s*v)*I,(g*b-y*A+p*_)*I,(h*A-l*b-d*_)*I,(i*$-a*k-o*v)*I,(e*k-n*$+r*v)*I,(y*M-g*w-m*_)*I,(l*w-h*M+u*_)*I]}function fs(t,e,n,r){const s=1/Math.tan(t*ss/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 ds(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 gs(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 ms(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 ps=Object.freeze(Object.defineProperty({__proto__:null,compose:us,fromQuat:_n,identity:as,invert:hs,lookAt:gs,multiply:is,orthographic:ds,perspective:fs,scaling:cs,transformPoint:ms,translation:os,transpose:ls},Symbol.toStringTag,{value:"Module"}));f.Clock=wn,f.DEFAULT_BAKE_INTERVAL_MS=jt,f.DEFAULT_INERTIA_FRICTION=It,f.DEFAULT_SPRING=x,f.FORMAT_VERSION=St,f.INERTIA_MAX_DURATION_MS=he,f.InertiaTrackPlayer=en,f.MORPH_SAMPLES=Kn,f.ManualClock=An,f.SPRING_MAX_DURATION_MS=Rt,f.SPRING_PRESETS=Pn,f.SPRING_STEP_MS=G,f.SpringSampler=tt,f.SpringTrackPlayer=tn,f.Timeline=Kt,f.TrackPlayer=yt,f.ValueResolver=wr,f.backOut=ke,f.bakeEasing=We,f.bakeInertiaTrack=Ht,f.bakeSpringTrack=Bt,f.beatAtTime=_t,f.beatLength=te,f.beatTime=Mt,f.beatsBetween=zr,f.bounceOut=be,f.cameraTracks=jr,f.charactersFor=nn,f.clearMorphCache=sr,f.clearPathCache=jn,f.closestName=yn,f.createCubicBezier=_e,f.createRandom=qt,f.createTrack=Ze,f.criticalDamping=Cn,f.customBounce=Rr,f.customEase=vr,f.customWiggle=Ir,f.deserializeTimeline=un,f.deserializeTrack=on,f.detectTempo=Yr,f.easeIn=pe,f.easeInCubic=Ct,f.easeInOut=Me,f.easeInOutCubic=Et,f.easeInOutQuad=me,f.easeInQuad=de,f.easeOut=ye,f.easeOutCubic=Dt,f.easeOutQuad=ge,f.editDistance=pn,f.elasticOut=Te,f.expandParametricEasings=qe,f.formatVersionFor=At,f.fromJSON=br,f.getEasingFunction=Ot,f.getInterpolator=Vt,f.getMotionPathPoint=Qt,f.getPathLength=Bn,f.getPointAtProgress=ve,f.hasKeyframes=oe,f.hashSeed=kr,f.heldTime=ce,f.inertiaDuration=nt,f.inertiaRest=et,f.inertiaValueAt=ft,f.inertiaVelocityAt=On,f.interpolateArray=He,f.interpolateColor=Be,f.interpolateMotionPath=mr,f.interpolateNumber=F,f.interpolatePathString=Ge,f.interpolateQuaternion=Qe,f.interpolateString=Ut,f.isCubicBezierEasing=Q,f.isInertiaTrack=z,f.isMotionPathPoint=Sn,f.isMotionPathTrack=wt,f.isParametricEasing=ot,f.isPathData=Le,f.isSpringTrack=Y,f.isTextTrack=ct,f.isUnderdamped=In,f.isUnresolved=Ar,f.linear=dt,f.mat4=ps,f.maxStaggerDistance=ue,f.morphPath=Oe,f.narrationMarkers=xr,f.narrationSceneAt=Fr,f.naturalRest=fe,f.nearestBeat=Nr,f.nextBeat=Xr,f.parametricEasing=Ae,f.parsePath=B,f.planNarration=Lr,f.playheadCrossings=_r,f.pointAtDistance=Lt,f.pointsToPath=Qr,f.quat=lr,f.randomBetween=Jt,f.randomChoice=Sr,f.randomSnapped=ln,f.resolveSequence=dn,f.resolveValue=Zt,f.ribbon=Jr,f.ribbonHeadCap=Zr,f.serializeTimeline=cn,f.serializeTrack=sn,f.shapeToPathData=Kr,f.simplifyKeyframes=Je,f.springDuration=Rn,f.springFollow=Hr,f.springValueAt=vn,f.staggerDistance=Pt,f.staggerOffset=vt,f.staggerOffsets=le,f.staggerSpan=ut,f.stepsEasing=Se,f.textAt=rn,f.toJSON=Tr,f.toKeyframedTrack=dr,f.toKeyframedTracks=gr,f.trackTargets=j,f.trailSamples=Wr,f.unknownName=Br,f.vec3=rs,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Track } from '../../engine/types';
|
|
2
|
+
import type { StickStyle } from '../stick-figure';
|
|
3
|
+
import type { Surface } from '../surface/surface';
|
|
4
|
+
import { type BeatProblem } from './beat-check';
|
|
5
|
+
import { type Cast } from './custom';
|
|
6
|
+
import { type Beat, type BeatTarget, type ScriptOptions, type ScriptResult } from './script';
|
|
7
|
+
/**
|
|
8
|
+
* A figure acting on surfaces, written as plain data: beats name the places
|
|
9
|
+
* they act on (`{ surface: 'code', anchor: 'token:4:Println' }`) and say what
|
|
10
|
+
* the surface does in answer (`then`), at a moment of the beat.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const result = surfaceScript('hero', { code }, [
|
|
14
|
+
* { do: 'leap', to: { surface: 'code', anchor: 'line:4' }, onto: { surface: 'code', anchor: 'line:5' } },
|
|
15
|
+
* { do: 'grab', target: { surface: 'code', anchor: 'token:4:Println' },
|
|
16
|
+
* then: { surface: 'code', edit: 'carry', anchor: 'token:4:Println', until: { beat: 2, at: 'release' } } },
|
|
17
|
+
* { do: 'throw', then: { surface: 'code', edit: 'fling', anchor: 'token:4:Println', at: 'release' } },
|
|
18
|
+
* ], { from: 600, ground: code.box.bottom })
|
|
19
|
+
* const timeline = { tracks: result.tracks } // the figure's tracks and every surface's
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* It compiles to the same calls written by hand: the beats go to
|
|
23
|
+
* `scriptTracks` with each named place swapped for its box (as laid out,
|
|
24
|
+
* before any edit moves it), then each `then` runs `surface.edit()` at its
|
|
25
|
+
* beat's moment, in the order the beats are written. A `carry` makes the
|
|
26
|
+
* piece follow the figure's hand (`handPath`). Last, the figure is carried
|
|
27
|
+
* by any surface it stands on (`surface.ride()`), unless `ride: false`.
|
|
28
|
+
*/
|
|
29
|
+
/** A named place on one of the scene's surfaces (`surfaces[surface].anchor(anchor)`). */
|
|
30
|
+
export interface SurfaceRef {
|
|
31
|
+
surface: string;
|
|
32
|
+
anchor: string;
|
|
33
|
+
}
|
|
34
|
+
/** A moment of a beat: when it starts, when it touches its target, when it lets go, when it ends. */
|
|
35
|
+
export type BeatMoment = 'start' | 'contact' | 'release' | 'end';
|
|
36
|
+
export declare const BEAT_MOMENTS: readonly BeatMoment[];
|
|
37
|
+
/** A moment of this beat, or of a later one (`beat` is its index in the script). */
|
|
38
|
+
export type CueTime = BeatMoment | {
|
|
39
|
+
beat: number;
|
|
40
|
+
at?: BeatMoment;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* What a surface does in answer to a beat: one of its edits (or `carry`),
|
|
44
|
+
* at one of its places. Every other field is the edit's own options (`text`,
|
|
45
|
+
* `into`, `to`, `style`…). Its time is a moment of the beat, not ms.
|
|
46
|
+
*/
|
|
47
|
+
export interface SurfaceCue {
|
|
48
|
+
surface: string;
|
|
49
|
+
/** One of the surface's edits, or `carry`: the piece at `anchor` follows the hand from `at` to `until` */
|
|
50
|
+
edit: string;
|
|
51
|
+
anchor: string | string[];
|
|
52
|
+
/** When it starts: a moment of the beat (default its contact, or its start when it has none) */
|
|
53
|
+
at?: BeatMoment;
|
|
54
|
+
/** When it ends: sets the edit's duration (`carry` needs it) */
|
|
55
|
+
until?: CueTime;
|
|
56
|
+
[option: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
/** A beat whose places can be named on a surface, and that a surface can answer. */
|
|
59
|
+
export interface SurfaceBeat extends Omit<Beat, 'target' | 'to' | 'onto'> {
|
|
60
|
+
/** What it acts on: a point or box, or a named place */
|
|
61
|
+
target?: BeatTarget | SurfaceRef;
|
|
62
|
+
/** Walking: where to, scene x, or a named place (its centre x) */
|
|
63
|
+
to?: number | SurfaceRef;
|
|
64
|
+
/** The floor it ends the beat on, scene y, or a named place (its top) */
|
|
65
|
+
onto?: number | SurfaceRef;
|
|
66
|
+
/** What the surfaces do in answer */
|
|
67
|
+
then?: SurfaceCue | SurfaceCue[];
|
|
68
|
+
}
|
|
69
|
+
export interface SurfaceScriptOptions extends ScriptOptions {
|
|
70
|
+
/** How the figure is drawn, for a `carry` to follow its hand (default: just its `height`) */
|
|
71
|
+
figureStyle?: StickStyle;
|
|
72
|
+
/** Carry the figure on the surfaces it stands on (default true) */
|
|
73
|
+
ride?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface SurfaceScriptResult extends ScriptResult {
|
|
76
|
+
/** The figure's tracks (ridden), then every surface's tracks, keyed by its name in `surfaces` */
|
|
77
|
+
tracks: Track[];
|
|
78
|
+
/** Just the figure's tracks (ridden) */
|
|
79
|
+
figureTracks: Track[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Compile beats that act on surfaces into the figure's tracks and the
|
|
83
|
+
* surfaces' edits. Throws when a beat or a cue is wrong (see
|
|
84
|
+
* `checkSurfaceBeats`), naming the beat.
|
|
85
|
+
*/
|
|
86
|
+
export declare function surfaceScript(figure: string, surfaces: Record<string, Surface>, beats: SurfaceBeat[], options?: SurfaceScriptOptions): SurfaceScriptResult;
|
|
87
|
+
/**
|
|
88
|
+
* Problems in beats that act on surfaces: everything `checkBeats` finds,
|
|
89
|
+
* plus surfaces, places, edits and moments that do not exist (with the
|
|
90
|
+
* likely intended name). Errors make `surfaceScript` throw.
|
|
91
|
+
*/
|
|
92
|
+
export declare function checkSurfaceBeats(beats: unknown, surfaces: Record<string, Surface>, cast?: Cast): BeatProblem[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PropertyInfo } from '../adapters/canvas/target-properties';
|
|
2
|
+
import type { SurfaceAbout } from './surface/surface';
|
|
2
3
|
import type { Cast } from './acting/custom';
|
|
3
4
|
export interface Capabilities {
|
|
4
5
|
version?: string;
|
|
@@ -31,6 +32,23 @@ export interface Capabilities {
|
|
|
31
32
|
handShapes: string[];
|
|
32
33
|
mudras: string[];
|
|
33
34
|
};
|
|
35
|
+
/** Props: everyday objects with behaviours */
|
|
36
|
+
props: {
|
|
37
|
+
api: Record<string, string>;
|
|
38
|
+
beatFields: readonly string[];
|
|
39
|
+
commonControls: Record<string, string>;
|
|
40
|
+
commonActions: Record<string, string>;
|
|
41
|
+
presets: Record<string, {
|
|
42
|
+
family: string;
|
|
43
|
+
summary: string;
|
|
44
|
+
actions: Record<string, {
|
|
45
|
+
summary: string;
|
|
46
|
+
needs?: string[];
|
|
47
|
+
}>;
|
|
48
|
+
controls: string[];
|
|
49
|
+
anchors: string[];
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
34
52
|
/** Making your own: actions, gaits and personas */
|
|
35
53
|
custom: {
|
|
36
54
|
api: Record<string, string>;
|
|
@@ -51,6 +69,10 @@ export interface Capabilities {
|
|
|
51
69
|
anchors: Record<string, string>;
|
|
52
70
|
edits: Record<string, string>;
|
|
53
71
|
};
|
|
72
|
+
/** Surfaces figures act on, by kind: their named anchors and edits (`surface.anchor(name)`, `surface.edit(name, anchor, options)`) */
|
|
73
|
+
surfaces: Record<string, SurfaceAbout>;
|
|
74
|
+
/** Beats that act on surfaces (`surfaceScript`): named places and the cues surfaces answer with */
|
|
75
|
+
surfaceScript: Record<string, string>;
|
|
54
76
|
cameraShots: Record<string, string>;
|
|
55
77
|
teach: Record<string, string>;
|
|
56
78
|
cli: Record<string, string>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Track } from '../engine/types';
|
|
2
|
+
import type { Pose } from './rig/body-plan';
|
|
3
|
+
import { GAITS } from './gaits';
|
|
4
|
+
import { type HumanPoseName } from './species/human';
|
|
5
|
+
import { type HumanGagName } from './species/human-motion';
|
|
6
|
+
import { type GroundPoint } from './ground-path';
|
|
7
|
+
/**
|
|
8
|
+
* Characters in world metres, for 3D scenes: a v2 character walks to a point
|
|
9
|
+
* or along a path through points, turning to face the way first, its gait's
|
|
10
|
+
* phase keyed with the distance so its feet stay planted; it faces things,
|
|
11
|
+
* strikes poses and plays gags. It writes the scene object's tracks: `x`,
|
|
12
|
+
* `z`, `rotateY`, its walk (`walk`, `walking`, `gait`, which the character
|
|
13
|
+
* object turns into the stepping pose as it draws) and pose fields.
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* const tum = characterScript3D('tum', [
|
|
17
|
+
* { do: 'walk', to: [2, 1] },
|
|
18
|
+
* { do: 'pose', pose: 'wave', for: 400 },
|
|
19
|
+
* { do: 'run', through: [[4, -2], [0, -4]] },
|
|
20
|
+
* { do: 'face', toward: [0, 0] },
|
|
21
|
+
* { do: 'gag', gag: 'take' },
|
|
22
|
+
* ], { scene: 'village', position: [0, 3], heading: 0 })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface CharacterBeat3D {
|
|
26
|
+
/** A gait to move in (`walk`, `run`, `sneak`, `strut`, `tired`, `bouncy`, `doubleBounce`, `shove`), `face`, `hold`, `pose`, `gag`, or `place` (put it at `to` at once, facing `toward`: where a ride left it) */
|
|
27
|
+
do: string;
|
|
28
|
+
/** When it starts, ms (default: when the beat before ends) */
|
|
29
|
+
at?: number;
|
|
30
|
+
/** How long it takes, ms (a move: default the distance at the gait's pace; a pose: default 500) */
|
|
31
|
+
for?: number;
|
|
32
|
+
/** A move: where to, [x, z] metres */
|
|
33
|
+
to?: GroundPoint;
|
|
34
|
+
/** A move: a path through these points, [x, z] metres each; it curves smoothly through them */
|
|
35
|
+
through?: GroundPoint[];
|
|
36
|
+
/** `face`: a point [x, z] to face, or a heading in degrees (0 faces +z, 90 faces +x) */
|
|
37
|
+
toward?: GroundPoint | number;
|
|
38
|
+
/** A move: metres per second (default the gait's own pace for its height) */
|
|
39
|
+
speed?: number;
|
|
40
|
+
/** `pose`: a named pose (`wave`, `point`, `cheer`, `think`, `sit`…) or pose fields */
|
|
41
|
+
pose?: HumanPoseName | Pose;
|
|
42
|
+
/** `gag`: a gag's name (`take`, `doubleTake`, `windUp`…) */
|
|
43
|
+
gag?: HumanGagName;
|
|
44
|
+
}
|
|
45
|
+
export declare const CHARACTER_BEAT_3D_FIELDS: readonly ["do", "at", "for", "to", "through", "toward", "speed", "pose", "gag"];
|
|
46
|
+
export interface CharacterScript3DOptions {
|
|
47
|
+
/** The scene's id: the tracks target `<scene>/<id>` */
|
|
48
|
+
scene: string;
|
|
49
|
+
/** Where it was placed, [x, z] metres (its object's position) */
|
|
50
|
+
position?: GroundPoint;
|
|
51
|
+
/** Which way it faces at first, degrees (its object's rotation about y; 0 faces +z) */
|
|
52
|
+
heading?: number;
|
|
53
|
+
/** Its height, metres, as its object has it (default 1.7): its stride and pace follow it */
|
|
54
|
+
height?: number;
|
|
55
|
+
/** The pose it starts in (its object's `pose`) */
|
|
56
|
+
pose?: Pose;
|
|
57
|
+
}
|
|
58
|
+
export interface CharacterScript3DResult {
|
|
59
|
+
tracks: Track[];
|
|
60
|
+
duration: number;
|
|
61
|
+
beats: Array<{
|
|
62
|
+
do: string;
|
|
63
|
+
start: number;
|
|
64
|
+
end: number;
|
|
65
|
+
}>;
|
|
66
|
+
end: {
|
|
67
|
+
position: GroundPoint;
|
|
68
|
+
heading: number;
|
|
69
|
+
pose: Pose;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** How fast each gait goes for a 1.7 m person, metres per second (taller is faster, shorter slower). */
|
|
73
|
+
export declare const CHARACTER_GAIT_SPEEDS: Record<keyof typeof GAITS, number>;
|
|
74
|
+
/** Problems in 3D character beats, naming what was probably meant. */
|
|
75
|
+
export declare function checkCharacterBeats3D(beats: unknown): Array<{
|
|
76
|
+
beat: number;
|
|
77
|
+
message: string;
|
|
78
|
+
}>;
|
|
79
|
+
/** Compiles 3D character beats into the scene object's tracks (see the module's notes). */
|
|
80
|
+
export declare function characterScript3D(id: string, beats: CharacterBeat3D[], options: CharacterScript3DOptions): CharacterScript3DResult;
|
|
@@ -153,6 +153,25 @@ export declare function characterJointsInView(character: Character, pose: Pose,
|
|
|
153
153
|
* canvas is drawn on as it is (no translation to the feet).
|
|
154
154
|
*/
|
|
155
155
|
export declare function drawCharacterInView(ctx: CanvasRenderingContext2D, character: Character, pose: Pose, projection: ViewProjection, options: InViewOptions): void;
|
|
156
|
+
/** One part of a character seen through a camera: its depth (nearer is larger) and how to draw it. */
|
|
157
|
+
export interface CharacterPartInView {
|
|
158
|
+
/** The chain's id (`spine`, `arm.left`, `leg.right`…) or `head` */
|
|
159
|
+
part: string;
|
|
160
|
+
/** Its depth in the view, in the projection's units, nearer is larger (metres in a 3D scene) */
|
|
161
|
+
depth: number;
|
|
162
|
+
/** Draws it; `time` (ms) is the pencil's boil frame and the layer hooks' time */
|
|
163
|
+
draw(ctx: CanvasRenderingContext2D, time?: number): void;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* A character seen through any camera, part by part, each with its depth:
|
|
167
|
+
* for drawing it among other things that each sort by depth (in a 3D scene,
|
|
168
|
+
* a rider's far leg behind a horse and the near one in front). Drawn in
|
|
169
|
+
* their order they make what `drawCharacterInView` draws; each part has its
|
|
170
|
+
* own pen, seeded by the character and the part, so a pencil boils the same
|
|
171
|
+
* whatever order they come in. Wardrobe layers go with their parts; those
|
|
172
|
+
* behind and in front of the whole figure go with its first and last parts.
|
|
173
|
+
*/
|
|
174
|
+
export declare function characterPartsInView(character: Character, pose: Pose, projection: ViewProjection, options: Pick<InViewOptions, 'height'>): CharacterPartInView[];
|
|
156
175
|
/** A full blend of two poses: `t` 0 is `from`, 1 is `to`. Fields in only one keep its value. */
|
|
157
176
|
export declare function mixPoses(from: Pose, to: Pose, t: number): Pose;
|
|
158
177
|
/**
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { CustomTarget } from '../adapters/canvas/canvas-adapter';
|
|
2
|
+
import type { Track } from '../engine/types';
|
|
3
|
+
import { type EditOptions } from './surface/edit-log';
|
|
4
|
+
import { type FlingOptions, type SurfacePiece, type TimedPoint } from './surface/pieces';
|
|
5
|
+
import { type Surface, type SurfaceAbout, type SurfaceEditOptions } from './surface/surface';
|
|
6
|
+
import { type SurfaceBox } from './surface/surface-box';
|
|
7
|
+
/**
|
|
8
|
+
* A bar or line chart as a scene object figures act on: they point at a
|
|
9
|
+
* bar, highlight the dip, and stand on a bar as it grows.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const sales = chart({
|
|
13
|
+
* x: 40, y: 30, width: 420, height: 280, kind: 'bar', title: 'Sales',
|
|
14
|
+
* data: [
|
|
15
|
+
* { id: 'q1', label: 'Q1', value: 40 },
|
|
16
|
+
* { id: 'q2', label: 'Q2', value: 25 },
|
|
17
|
+
* { id: 'q3', label: 'Q3', value: 55, hidden: true },
|
|
18
|
+
* ],
|
|
19
|
+
* })
|
|
20
|
+
* sales.edit('highlight', 'bar:q2', { at: 600 })
|
|
21
|
+
* sales.edit('show', 'bar:q3', { at: 1200 }) // grows in from the axis
|
|
22
|
+
* sales.edit('set', 'bar:q1', { at: 2000, value: 80 }) // and its value label counts up
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* The data is declared up front; the scale (`max`) is fixed when it is made
|
|
26
|
+
* (from the data, or given), so a bar set past it grows out of the plot.
|
|
27
|
+
* Its places follow the values: `anchor('bar:q1', time)` is the bar as it
|
|
28
|
+
* stands at `time` (default: after every edit; a surface script aims beats
|
|
29
|
+
* at it as laid out). A figure standing on a bar's top is carried up and
|
|
30
|
+
* down with it (`ride()`). Edits are keys on its props: `bar.ID.value`,
|
|
31
|
+
* `bar.ID.show`, `bar.ID.highlight` (or `point.ID.…` on a line chart).
|
|
32
|
+
*/
|
|
33
|
+
export type ChartKind = 'bar' | 'line';
|
|
34
|
+
export declare const CHART_KINDS: readonly ChartKind[];
|
|
35
|
+
export type ChartThemeName = 'light' | 'dark';
|
|
36
|
+
export interface ChartTheme {
|
|
37
|
+
background: string;
|
|
38
|
+
text: string;
|
|
39
|
+
/** Axis and grid lines */
|
|
40
|
+
grid: string;
|
|
41
|
+
/** Bars, the line and its points */
|
|
42
|
+
color: string;
|
|
43
|
+
/** A highlighted bar or point */
|
|
44
|
+
highlight: string;
|
|
45
|
+
font: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const CHART_THEMES: Record<ChartThemeName, ChartTheme>;
|
|
48
|
+
/** One bar or point. */
|
|
49
|
+
export interface ChartDatum {
|
|
50
|
+
id: string;
|
|
51
|
+
/** Under it, on the axis (default its id) */
|
|
52
|
+
label?: string;
|
|
53
|
+
value: number;
|
|
54
|
+
/** Start at nothing: a bar flat on the axis, a point the line has not reached; brought in with `show` */
|
|
55
|
+
hidden?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface ChartOptions {
|
|
58
|
+
/** Top-left corner, scene px */
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
kind: ChartKind;
|
|
64
|
+
data: ChartDatum[];
|
|
65
|
+
/** The value at the top of the plot (default: a round number above the largest value) */
|
|
66
|
+
max?: number;
|
|
67
|
+
title?: string;
|
|
68
|
+
theme?: ChartThemeName | Partial<ChartTheme>;
|
|
69
|
+
/** Value labels: decimal places (default 0), and text before and after the number */
|
|
70
|
+
decimals?: number;
|
|
71
|
+
prefix?: string;
|
|
72
|
+
suffix?: string;
|
|
73
|
+
/** Show each value above its bar or point (default true) */
|
|
74
|
+
values?: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface Chart extends Surface {
|
|
77
|
+
readonly kind: 'chart';
|
|
78
|
+
readonly chartKind: ChartKind;
|
|
79
|
+
readonly target: CustomTarget;
|
|
80
|
+
readonly box: SurfaceBox;
|
|
81
|
+
/** The value at the top of the plot */
|
|
82
|
+
readonly max: number;
|
|
83
|
+
/** The box at a named place, as it stands at `time`: `box`, `bar:ID` or `point:ID`, `label:ID`, `value:ID` */
|
|
84
|
+
anchor(name: string, time?: number): SurfaceBox;
|
|
85
|
+
/** A chart has no pieces: this throws */
|
|
86
|
+
piece(anchor: string): SurfacePiece;
|
|
87
|
+
/** Change the chart at a time by name, at named places (see `CHART_SURFACE.edits`) */
|
|
88
|
+
edit(name: string, anchor: string | string[], options: SurfaceEditOptions): Chart;
|
|
89
|
+
follow(piece: SurfacePiece, path: TimedPoint[]): Chart;
|
|
90
|
+
fling(piece: SurfacePiece, options: FlingOptions): Chart;
|
|
91
|
+
move(piece: SurfacePiece, options: EditOptions & {
|
|
92
|
+
to: {
|
|
93
|
+
x: number;
|
|
94
|
+
y: number;
|
|
95
|
+
};
|
|
96
|
+
}): Chart;
|
|
97
|
+
/** A figure's tracks with it carried up and down by the bar it stands on */
|
|
98
|
+
ride(tracks: Track[], target: string, options: {
|
|
99
|
+
ground: number;
|
|
100
|
+
every?: number;
|
|
101
|
+
}): Track[];
|
|
102
|
+
tracks(target: string): Track[];
|
|
103
|
+
}
|
|
104
|
+
/** A chart's anchors and edits, as data: for its `about`, the capability catalog and the checks. */
|
|
105
|
+
export declare const CHART_SURFACE: SurfaceAbout;
|
|
106
|
+
export declare function chart(options: ChartOptions): Chart;
|
|
107
|
+
/** The smallest of 1, 2, 2.5, 5 × a power of ten at or above `value`. */
|
|
108
|
+
export declare function niceCeiling(value: number): number;
|