@algorisys/tinyfly 0.82.0 → 0.86.2
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 +11 -4
- package/lib/addons/adapters.js +363 -248
- package/lib/addons/characters.js +1652 -1470
- package/lib/addons/dom-adapter-Cphr2HZn.js +372 -0
- package/lib/addons/gsap-compat.js +197 -187
- package/lib/addons/load-scene-vp14_Jj-.js +324 -0
- package/lib/addons/scene-3d-webgl.js +237 -0
- package/lib/addons/scene-3d.js +306 -0
- package/lib/addons/shading-ByG9UXd0.js +85 -0
- package/lib/browser/tinyfly-scene-3d-webgl.iife.js +114 -0
- package/lib/browser/tinyfly-scene-3d.iife.js +3 -0
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +3028 -2480
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/cli/tools.js +137 -22
- package/lib/embed/tinyfly-embed.iife.js +4 -4
- package/lib/embed/tinyfly-embed.js +921 -833
- package/lib/engine/tinyfly-engine.js +1022 -776
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/headless/headless.js +264 -7
- package/lib/player/tinyfly-player.es.js +459 -371
- package/lib/player/tinyfly-player.iife.js +2 -2
- package/lib/player/tinyfly-player.umd.js +2 -2
- package/lib/types/adapters/canvas/canvas-adapter.d.ts +36 -0
- package/lib/types/adapters/transform-3d.d.ts +99 -0
- package/lib/types/adapters/webgl/webgl-adapter.d.ts +17 -0
- package/lib/types/characters/character.d.ts +20 -1
- package/lib/types/characters/index.d.ts +2 -0
- package/lib/types/characters/rig/body-plan.d.ts +3 -1
- package/lib/types/characters/rig/skeleton.d.ts +57 -0
- package/lib/types/characters/scene-objects.d.ts +2 -0
- package/lib/types/compat/gsap/vars.d.ts +8 -0
- package/lib/types/engine/core/bake.d.ts +3 -1
- package/lib/types/engine/index.d.ts +1 -0
- package/lib/types/engine/interpolation/interpolators.d.ts +10 -3
- package/lib/types/engine/math/index.d.ts +11 -0
- package/lib/types/engine/math/mat4.d.ts +37 -0
- package/lib/types/engine/math/quat.d.ts +39 -0
- package/lib/types/engine/math/vec3.d.ts +16 -0
- package/lib/types/engine/types.d.ts +23 -2
- package/lib/types/scene-3d/camera.d.ts +27 -0
- package/lib/types/scene-3d/canvas-2d-renderer.d.ts +21 -0
- package/lib/types/scene-3d/geometry/extrude.d.ts +17 -0
- package/lib/types/scene-3d/geometry/mesh.d.ts +36 -0
- package/lib/types/scene-3d/geometry/primitives.d.ts +16 -0
- package/lib/types/scene-3d/geometry/triangulate.d.ts +24 -0
- package/lib/types/scene-3d/index.d.ts +20 -0
- package/lib/types/scene-3d/load-scene.d.ts +31 -0
- package/lib/types/scene-3d/object-kind.d.ts +54 -0
- package/lib/types/scene-3d/resolve-scene.d.ts +122 -0
- package/lib/types/scene-3d/scene-3d-adapter.d.ts +46 -0
- package/lib/types/scene-3d/scene-types.d.ts +191 -0
- package/lib/types/scene-3d/shading.d.ts +20 -0
- package/lib/types/scene-3d/validate-scene.d.ts +11 -0
- package/lib/types/scene-3d/webgl/gl-data.d.ts +28 -0
- package/lib/types/scene-3d/webgl/index.d.ts +16 -0
- package/lib/types/scene-3d/webgl/shaders.d.ts +29 -0
- package/lib/types/scene-3d/webgl/webgl2-renderer.d.ts +33 -0
- package/package.json +10 -2
- package/lib/addons/dom-adapter-CrNwoomd.js +0 -243
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function($){"use strict";function fe(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function pe(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const H=1;function _t(e){return e.property==="text"&&"textConfig"in e}function lt(e){return e.kind==="inertia"&&"inertia"in e}function ht(e){return e.kind==="spring"&&"spring"in e}function me(e){return e.property==="motionPath"&&"motionPathConfig"in e}function At(e,t,n="start"){if(t<=1)return 0;if(typeof n=="number"){const s=Math.max(0,Math.min(t-1,n));return Math.abs(e-s)}switch(n){case"end":return t-1-e;case"center":return Math.abs(e-(t-1)/2);case"edges":return(t-1)/2-Math.abs(e-(t-1)/2);default:return e}}function ge(e,t="start"){if(e<=1)return 0;let n=0;for(let s=0;s<e;s++)n=Math.max(n,At(s,e,t));return n}function Et(e,t,n){if(n.offsets)return n.offsets[e]??0;const s=n.from??"start",i=At(e,t,s);if(n.amount!==void 0){const r=ge(t,s);return r===0?0:n.amount*i/r}return n.each!==void 0?n.each*i:0}function ye(e,t){return Array.from({length:e},(n,s)=>Et(s,e,t))}function ut(e,t){return e<=1?0:Math.max(...ye(e,t))}const z=1,Pt=6e4,et=Pt/z,B={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1};class be{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(t){this.from=t.from,this.to=t.to,this.stiffness=t.stiffness??B.stiffness,this.damping=t.damping??B.damping,this.mass=t.mass??B.mass,this.restDelta=t.restDelta??B.restDelta,this.restSpeed=t.restSpeed??B.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??B.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(t){return Math.abs(t-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(t){if(t<=0)return this.from;const n=Math.floor(t/z);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const s=this.samples[Math.min(n,this.samples.length-1)],i=this.samples[Math.min(n+1,this.samples.length-1)],r=t/z-n;return s+(i-s)*r}settleTime(){return this.simulateTo(et+1),this.settledStep!==null?this.settledStep*z:Pt}simulateTo(t){if(this.settledStep!==null)return;const n=Math.min(t,et+1),s=z/1e3;for(;this.samples.length<n;){const i=this.samples[this.samples.length-1],r=i-this.to,a=-this.stiffness*r,o=-this.damping*this.velocity,c=(a+o)/this.mass;this.velocity+=c*s;const l=i+this.velocity*s;if(this.samples.push(l),this.isAtRest(l)){this.settledStep=this.samples.length-1;return}}this.samples.length>et&&(this.settledStep=et)}}const Ct=4,ve=.002,ke=1e-4,xe=6e4;function dt(e){const t=e.friction??Ct;return t>0?t:Ct}function we(e){return e.from+e.velocity/dt(e)}function Me(e,t){if(t===void 0)return e;if(typeof t=="number")return t>0?Math.round(e/t)*t:e;if(t.length===0)return e;let n=t[0];for(const s of t)Math.abs(s-e)<Math.abs(n-e)&&(n=s);return n}function It(e){let t=Me(we(e),e.end);return e.min!==void 0&&(t=Math.max(e.min,t)),e.max!==void 0&&(t=Math.min(e.max,t)),t}function Rt(e){const t=Math.abs(It(e)-e.from);if(t===0)return 0;const n=e.restDelta??Math.max(ke,t*ve);if(n>=t)return 0;const s=Math.log(t/n)/dt(e);return Math.min(xe,s*1e3)}function $t(e,t){if(t<=0)return e.from;const n=It(e);if(t>=Rt(e))return n;const s=dt(e);return e.from+(n-e.from)*(1-Math.exp(-s*t/1e3))}const ft=e=>e,Se=e=>e*e,Te=e=>1-(1-e)*(1-e),_e=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,Lt=e=>e*e*e,Dt=e=>1-Math.pow(1-e,3),Ot=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Ae={linear:ft,"ease-in":Lt,"ease-out":Dt,"ease-in-out":Ot,"ease-in-quad":Se,"ease-out-quad":Te,"ease-in-out-quad":_e,"ease-in-cubic":Lt,"ease-out-cubic":Dt,"ease-in-out-cubic":Ot};function Ee(e){const[t,n,s,i]=e,r=3*t,a=3*(s-t)-r,o=1-r-a,c=3*n,l=3*(i-n)-c,u=1-c-l,h=p=>((o*p+a)*p+r)*p,d=p=>((u*p+l)*p+c)*p,f=p=>(3*o*p+2*a)*p+r,g=p=>{let m=p;for(let k=0;k<8;k++){const M=h(m)-p;if(Math.abs(M)<1e-7)return m;const y=f(m);if(Math.abs(y)<1e-7)break;m-=M/y}let b=0,v=1;for(m=p;b<v;){const k=h(m);if(Math.abs(k-p)<1e-7)return m;p>k?b=m:v=m,m=(b+v)/2}return m};return p=>{if(p<=0)return 0;if(p>=1)return 1;const m=g(p);return d(m)}}function pt(e,t="out"){if(t==="out")return e;const n=s=>1-e(1-s);return t==="in"?n:s=>s<.5?n(s*2)/2:e(s*2-1)/2+.5}function Pe(e=1,t=.3){const n=Math.max(1,e),s=t/(2*Math.PI)*Math.asin(1/n);return i=>i<=0?0:i>=1?1:n*Math.pow(2,-10*i)*Math.sin((i-s)*(2*Math.PI)/t)+1}const Ce=e=>{if(e<=0)return 0;if(e>=1)return 1;if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const i=e-.5454545454545454;return 7.5625*i*i+.75}if(e<2.5/2.75){const i=e-.8181818181818182;return 7.5625*i*i+.9375}const s=e-2.625/2.75;return 7.5625*s*s+.984375};function Ie(e=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const n=t-1;return n*n*((e+1)*n+e)+1}}function Re(e,t="end"){const n=Math.max(1,Math.floor(e));return s=>{if(s>=1)return 1;if(s<=0)return t==="start"||t==="both"?t==="start"?1/n:1/(n+1):0;const i=Math.floor(s*n);switch(t){case"start":return Math.min(1,(i+1)/n);case"both":return(i+1)/(n+1);case"none":return n===1?0:Math.min(1,i/(n-1));default:return i/n}}}function $e(e){switch(e.type){case"steps":return Re(e.count,e.position);case"elastic":return pt(Pe(e.amplitude,e.period),e.mode);case"bounce":return pt(Ce,e.mode);case"back":return pt(Ie(e.overshoot),e.mode)}}function Le(e){return e===void 0?ft:fe(e)?Ee(e.points):pe(e)?$e(e):Ae[e]??ft}const Nt=32,De=256,G=new Map,Oe=/[MmLlHhVvCcSsQqTtAaZz]/,Ne=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Fe={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Xe(e){const t=[];let n=0,s=null;const i=()=>{for(;n<e.length&&/[\s,]/.test(e[n]);)n++};for(;n<e.length&&(i(),!(n>=e.length));){const r=e[n];if(Oe.test(r)){s={type:r,args:[]},t.push(s),n++;continue}if(!s)break;const a=s.type==="A"||s.type==="a",o=s.args.length%7;if(a&&(o===3||o===4)){if(r!=="0"&&r!=="1")break;s.args.push(r==="1"?1:0),n++;continue}const c=Ne.exec(e.slice(n));if(!c)break;s.args.push(parseFloat(c[0])),n+=c[0].length}return t}function Ye(e,t,n,s,i,r,a,o,c){if(e===o&&t===c)return[];let l=Math.abs(n),u=Math.abs(s);if(l===0||u===0)return[[e,t,o,c,o,c]];const h=i*Math.PI/180,d=Math.cos(h),f=Math.sin(h),g=(e-o)/2,p=(t-c)/2,m=d*g+f*p,b=-f*g+d*p,v=m*m/(l*l)+b*b/(u*u);if(v>1){const A=Math.sqrt(v);l*=A,u*=A}const k=r===a?-1:1,M=l*l*u*u-l*l*b*b-u*u*m*m,y=l*l*b*b+u*u*m*m,S=k*Math.sqrt(Math.max(0,M/y)),x=S*l*b/u,P=-S*u*m/l,W=d*x-f*P+(e+o)/2,T=f*x+d*P+(t+c)/2,R=(A,I,D,j)=>{const Tt=A*D+I*j,ct=Math.sqrt((A*A+I*I)*(D*D+j*j)),tt=Math.acos(Math.max(-1,Math.min(1,Tt/ct)));return A*j-I*D<0?-tt:tt},_=R(1,0,(m-x)/l,(b-P)/u);let C=R((m-x)/l,(b-P)/u,(-m-x)/l,(-b-P)/u);!a&&C>0&&(C-=2*Math.PI),a&&C<0&&(C+=2*Math.PI);const O=Math.max(1,Math.ceil(Math.abs(C)/(Math.PI/2))),w=C/O,E=4/3*Math.tan(w/4),F=A=>{const I=l*Math.cos(A),D=u*Math.sin(A);return[d*I-f*D+W,f*I+d*D+T]},N=A=>{const I=-l*Math.sin(A),D=u*Math.cos(A);return[d*I-f*D,f*I+d*D]},L=[];for(let A=0;A<O;A++){const I=_+A*w,D=I+w,[j,Tt]=F(I),[ct,tt]=A===O-1?[o,c]:F(D),[as,os]=N(I),[cs,ls]=N(D);L.push([j+E*as,Tt+E*os,ct-E*cs,tt-E*ls,ct,tt])}return L}function Y(e,t,n,s,i){const r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*n+i*i*i*s}function Ft(e,t,n,s,i){const r=1-i;return 3*r*r*(t-e)+6*r*i*(n-t)+3*i*i*(s-n)}function Q(e,t,n,s){return{subpath:0,type:"L",points:[n,s],startX:e,startY:t,endX:n,endY:s,length:Math.hypot(n-e,s-t)}}function nt(e,t,n){const[s,i,r,a,o,c]=n,l=[0];let u=e,h=t,d=0;for(let f=1;f<=Nt;f++){const g=f/Nt,p=Y(e,s,r,o,g),m=Y(t,i,a,c,g);d+=Math.hypot(p-u,m-h),l.push(d),u=p,h=m}return{subpath:0,type:"C",points:[s,i,r,a,o,c],startX:e,startY:t,endX:o,endY:c,length:d,lengths:l}}function st(e){const t=G.get(e);if(t)return t;const n=[];let s=0,i=0,r=0,a=0,o=null,c=null,l=-1;const u=new Set,h=p=>{l<0&&(l=0),p.subpath=l,n.push(p)};for(const{type:p,args:m}of Xe(e)){const b=p.toUpperCase(),v=p!==b,k=Fe[b];if(b==="Z"){(s!==r||i!==a)&&h(Q(s,i,r,a)),l>=0&&u.add(l),s=r,i=a,o=c=null;continue}for(let M=0;M+k<=m.length;M+=k){const y=m.slice(M,M+k),S=v?s:0,x=v?i:0;let P=null,W=null;switch(b){case"M":M===0?(s=y[0]+S,i=y[1]+x,r=s,a=i,(l<0||n[n.length-1]?.subpath===l)&&l++):(h(Q(s,i,y[0]+S,y[1]+x)),s=y[0]+S,i=y[1]+x);break;case"L":h(Q(s,i,y[0]+S,y[1]+x)),s=y[0]+S,i=y[1]+x;break;case"H":h(Q(s,i,y[0]+S,i)),s=y[0]+S;break;case"V":h(Q(s,i,s,y[0]+x)),i=y[0]+x;break;case"C":{const T=[y[0]+S,y[1]+x,y[2]+S,y[3]+x,y[4]+S,y[5]+x];h(nt(s,i,T)),P=[T[2],T[3]],s=T[4],i=T[5];break}case"S":{const[T,R]=o?[2*s-o[0],2*i-o[1]]:[s,i],_=[T,R,y[0]+S,y[1]+x,y[2]+S,y[3]+x];h(nt(s,i,_)),P=[_[2],_[3]],s=_[4],i=_[5];break}case"Q":case"T":{let T=s,R=i;b==="Q"?(T=y[0]+S,R=y[1]+x):c&&(T=2*s-c[0],R=2*i-c[1]);const _=b==="Q"?y[2]+S:y[0]+S,C=b==="Q"?y[3]+x:y[1]+x;h(nt(s,i,[s+2/3*(T-s),i+2/3*(R-i),_+2/3*(T-_),C+2/3*(R-C),_,C])),W=[T,R],s=_,i=C;break}case"A":{const T=y[5]+S,R=y[6]+x;let _=s,C=i;for(const O of Ye(s,i,y[0],y[1],y[2],y[3],y[4],T,R))h(nt(_,C,O)),_=O[4],C=O[5];s=T,i=R;break}}o=P,c=W}}const d=n.reduce((p,m)=>p+m.length,0),f=[];for(let p=0;p<n.length;){const m=n[p].subpath;let b=p,v=0;for(;b<n.length&&n[b].subpath===m;)v+=n[b++].length;const k=n[p],M=n[b-1],y=u.has(m)||Math.abs(M.endX-k.startX)<1e-9&&Math.abs(M.endY-k.startY)<1e-9;f.push({start:p,end:b,length:v,closed:y}),p=b}const g={segments:n,totalLength:d,subpaths:f};return G.size>=De&&G.delete(G.keys().next().value),G.set(e,g),g}function qe(e,t){const n=e.lengths;if(t<=0)return 0;if(t>=e.length)return 1;let s=0,i=n.length-1;for(;s<i-1;){const o=s+i>>1;n[o]<t?s=o:i=o}const r=n[i]-n[s],a=r>0?(t-n[s])/r:0;return(s+a)/(n.length-1)}function Ve(e,t){if(e.type==="L"){const h=e.length>0?Math.max(0,Math.min(1,t/e.length)):0;return{x:e.startX+(e.endX-e.startX)*h,y:e.startY+(e.endY-e.startY)*h,angle:Math.atan2(e.endY-e.startY,e.endX-e.startX)*180/Math.PI}}const[n,s,i,r,a,o]=e.points,c=qe(e,t);let l=Ft(e.startX,n,i,a,c),u=Ft(e.startY,s,r,o,c);if(Math.hypot(l,u)<1e-9){const h=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),d=Y(e.startX,n,i,a,h),f=Y(e.startY,s,r,o,h),g=Y(e.startX,n,i,a,c),p=Y(e.startY,s,r,o,c);l=c<.5?d-g:g-d,u=c<.5?f-p:p-f}return{x:Y(e.startX,n,i,a,c),y:Y(e.startY,s,r,o,c),angle:Math.atan2(u,l)*180/Math.PI}}function Xt(e,t,n=0,s=e.length){if(s<=n)return{x:0,y:0,angle:0};let i=0;for(let r=n;r<s;r++){const a=e[r];if(i+a.length>=t||r===s-1)return Ve(a,t-i);i+=a.length}return{x:0,y:0,angle:0}}function We(e,t){const{segments:n,totalLength:s}=st(e);return Xt(n,Math.max(0,Math.min(1,t))*s)}const Be=24,Ue=320,je=2.5,Z=72,He=.2,ze=128,it=new Map;let mt=0,q;const Yt=e=>Math.round(e*100)/100;function qt(e,t){const{segments:n,subpaths:s,totalLength:i}=st(e);if(n.length===0)return[];if(t){const r=s.every(a=>a.closed);return[{segments:n,start:0,end:n.length,length:i,closed:r}]}return s.filter(r=>r.length>0).map(r=>({segments:n,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function gt(e,t){const n=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),s=Xt(e.segments,n*e.length,e.start,e.end);return[s.x,s.y]}function Vt(e){const t=[];let n=0;for(let s=e.start;s<e.end;s++)n+=e.segments[s].length,e.length>0&&t.push(n/e.length);return t}function Wt(e,t){const n=[];for(let s=0;s<t;s++)n.push(gt(e,e.closed?s/t:s/(t-1)));return n}function Bt(e){let t=0,n=0;for(const[s,i]of e)t+=s,n+=i;return t/=e.length,n/=e.length,e.map(([s,i])=>[s-t,i-n])}function Ge(e,t,n){const s=e.closed&&t.closed;if(n!==void 0)return{offset:s?Math.abs(n)%Z/Z:0,reversed:n<0};const i=Bt(Wt(e,Z)),r=Bt(Wt(t,Z)),a=Z;let o={offset:0,reversed:!1},c=1/0;for(const l of[!1,!0]){const u=s?a:1;for(let h=0;h<u;h++){let d=0;for(let f=0;f<a&&d<c;f++){const g=s?l?(h-f+a)%a:(f+h)%a:l?a-1-f:f,p=i[f][0]-r[g][0],m=i[f][1]-r[g][1];d+=p*p+m*m}d<c&&(c=d,o={offset:s?h/a:0,reversed:l})}}return o}function Qe(e,t,n){return n?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function Ze(e,t,n){return n?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function Ke(e,t,n){const s=e.closed&&t.closed,i=Ge(e,t,n.shapeIndex),r=Math.max(Be,Math.min(Ue,Math.ceil(Math.max(e.length,t.length)/je))),a=new Set,o=h=>a.add(Math.round(h*1e7)/1e7);for(let h=0;h<=r;h++)o(h/r);for(const h of Vt(e))o(h);for(const h of Vt(t))o(Ze(h,i,s));let c=[...a].sort((h,d)=>h-d);s&&(c=c.filter(h=>h<1));const l=[],u=[];for(const h of c)l.push(...gt(e,h)),u.push(...gt(t,Qe(h,i,s)));return Je({from:l,to:u,closed:s})}function Je(e){const t=e.from.length/2;if(t<=3)return e;const n=new Uint8Array(t);n[0]=1,n[t-1]=1;const s=[[0,t-1]];for(;s.length>0;){const[a,o]=s.pop();let c=-1,l=He;for(let u=a+1;u<o;u++){const h=Math.max(Ut(e.from,a,o,u),Ut(e.to,a,o,u));h>l&&(l=h,c=u)}c!==-1&&(n[c]=1,s.push([a,c],[c,o]))}const i=[],r=[];for(let a=0;a<t;a++)n[a]&&(i.push(e.from[a*2],e.from[a*2+1]),r.push(e.to[a*2],e.to[a*2+1]));return{from:i,to:r,closed:e.closed}}function Ut(e,t,n,s){const i=e[t*2],r=e[t*2+1],a=e[n*2]-i,o=e[n*2+1]-r,c=e[s*2]-i,l=e[s*2+1]-r,u=a*a+o*o,h=u===0?0:Math.max(0,Math.min(1,(c*a+l*o)/u));return Math.hypot(c-h*a,l-h*o)}function tn(e,t,n){const s=n.shapeIndex;if(q&&q.from===e&&q.to===t&&q.shapeIndex===s)return q.plan;const r=it.get(String(s??"auto"))?.get(e)?.get(t);if(r)return q={from:e,to:t,shapeIndex:s,plan:r},r;const a=st(e).subpaths.filter(f=>f.length>0).length===st(t).subpaths.filter(f=>f.length>0).length,o=qt(e,!a),c=qt(t,!a),l={pairs:o.map((f,g)=>Ke(f,c[g],n))};mt>=ze&&(it.clear(),mt=0);const u=String(s??"auto"),h=it.get(u)??new Map;it.set(u,h);const d=h.get(e)??new Map;return h.set(e,d),d.set(t,l),mt++,q={from:e,to:t,shapeIndex:s,plan:l},l}function en(e,t,n,s={}){if(!e)return t;if(!t)return e;const i=Math.max(0,Math.min(1,n));if(i===0)return e;if(i===1)return t;const r=tn(e,t,s);if(r.pairs.length===0)return i<.5?e:t;let a="";for(const o of r.pairs){for(let c=0;c<o.from.length;c+=2){const l=Yt(o.from[c]+(o.to[c]-o.from[c])*i),u=Yt(o.from[c+1]+(o.to[c+1]-o.from[c+1])*i);a+=`${c===0?a?" M":"M":" L"}${l} ${u}`}o.closed&&(a+=" Z")}return a}function nn(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const X=(e,t,n)=>e+(t-e)*n,jt=512,yt=new Map,bt=new Map;function Ht(e){const t=yt.get(e);if(t)return t;const n=e.replace("#",""),s=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return yt.size<jt&&yt.set(e,s),s}const zt=e=>e.charCodeAt(0)===35,Gt=e=>e.startsWith("rgb"),Qt=e=>e.startsWith("rgba"),sn=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,vt=e=>Math.round(e).toString(16).padStart(2,"0");function rn(e,t,n){return`#${vt(e)}${vt(t)}${vt(n)}`}function Zt(e){const t=bt.get(e);if(t)return t;const n=e.match(sn);if(!n)throw new Error(`Invalid rgb color: ${e}`);const s=parseInt(n[1],10),i=parseInt(n[2],10),r=parseInt(n[3],10),a=n[4]!==void 0?[s,i,r,parseFloat(n[4])]:[s,i,r];return bt.size<jt&&bt.set(e,a),a}const an=(e,t,n)=>{if(zt(e)&&zt(t)){const[s,i,r]=Ht(e),[a,o,c]=Ht(t),l=X(s,a,n),u=X(i,o,n),h=X(r,c,n);return rn(l,u,h)}if((Gt(e)||Qt(e))&&(Gt(t)||Qt(t))){const s=Zt(e),i=Zt(t),r=Math.round(X(s[0],i[0],n)),a=Math.round(X(s[1],i[1],n)),o=Math.round(X(s[2],i[2],n));if(s.length===4||i.length===4){const c=s[3]??1,l=i[3]??1,u=X(c,l,n);return`rgba(${r}, ${a}, ${o}, ${u})`}return`rgb(${r}, ${a}, ${o})`}return n<1?e:t},on=(e,t,n)=>{const s=Math.min(e.length,t.length),i=[];for(let r=0;r<s;r++)i.push(X(e[r],t[r],n));return i},Kt=(e,t,n)=>n<1?e:t,cn=(e,t,n)=>en(e,t,n);function ln(e){return typeof e=="number"?X:Array.isArray(e)?on:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?an:nn(e)?cn:Kt:Kt}function hn(e){const t=[...e.keyframes].sort((n,s)=>n.time-s.time);return{...e,keyframes:t}}function V(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function U(e,t,n,s){const i=n??0;return!s||t<=1?i:i+Et(e,t,s)}class kt{track;targets;constructor(t){this.track=t,this.targets=V(t)}getValueAtTime(t){return this.valueForOffset(t-U(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,s=[];for(let i=0;i<n;i++){const r=U(i,n,this.track.delay,this.track.stagger),a=this.valueForOffset(t-r);a!==void 0&&s.push({target:this.targets[i],value:a,start:r+this.track.keyframes[0].time})}return s}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const n=t[t.length-1].time,s=this.track.stagger?ut(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+s+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:n}=this.track;if(n.length===0)return;if(n.length===1||t<=n[0].time)return n[0].value;if(t>=n[n.length-1].time)return n[n.length-1].value;const{from:s,to:i}=this.findSurroundingKeyframes(t);if(!s||!i)return;if(s.time===t)return s.value;const r=i.time-s.time,a=(t-s.time)/r,c=Le(i.easing)(a);return ln(s.value)(s.value,i.value,c)}findSurroundingKeyframes(t){const{keyframes:n}=this.track;for(let s=0;s<n.length-1;s++)if(t>=n[s].time&&t<=n[s+1].time)return{from:n[s],to:n[s+1]};return{from:null,to:null}}}class un{track;targets;sampler;constructor(t){this.track=t,this.targets=V(t),this.sampler=new be(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-U(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,s=[];for(let i=0;i<n;i++){const r=U(i,n,this.track.delay,this.track.stagger);s.push({target:this.targets[i],value:this.sampler.valueAt(t-r),start:r})}return s}getDuration(){const t=this.track.stagger?ut(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class dn{track;targets;duration;constructor(t){this.track=t,this.targets=V(t),this.duration=Rt(t.inertia)}getValueAtTime(t){return $t(this.track.inertia,t-U(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,s=[];for(let i=0;i<n;i++){const r=U(i,n,this.track.delay,this.track.stagger);s.push({target:this.targets[i],value:$t(this.track.inertia,t-r),start:r})}return s}getDuration(){const t=this.track.stagger?ut(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function fn(e,t){const n={...We(e.pathData,t)};if(e.matrix){const[s,i,r,a,o,c]=e.matrix,{x:l,y:u}=n;n.x=s*l+r*u+o,n.y=i*l+a*u+c;const h=n.angle*Math.PI/180,d=Math.cos(h),f=Math.sin(h);n.angle=Math.atan2(i*d+a*f,s*d+r*f)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(n.angle+=e.rotateOffset),n}const xt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},pn=20;function mn(e){const t=xt[e??"upperCase"]??e??xt.upperCase,n=Array.from(t);return n.length>0?n:Array.from(xt.upperCase)}function gn(e,t,n){let s=(e|0)^Math.imul(t+1,2654435761)^Math.imul(n+1,2246822507);return s=Math.imul(s^s>>>16,2146121005),s=Math.imul(s^s>>>15,2221713035),(s^s>>>16)>>>0}function yn(e,t,n=0){const s=e.from??"",i=e.to,r=Math.max(0,Math.min(1,t));if(r<=0)return s;if(r>=1)return i;const a=Array.from(s),o=Array.from(i),c=e.rightToLeft??!1;if(e.mode==="type"){const v=Math.round(r*Math.max(a.length,o.length));return c?a.slice(0,Math.max(0,a.length-v)).join("")+o.slice(Math.max(0,o.length-v)).join(""):o.slice(0,v).join("")+a.slice(v).join("")}const l=Math.max(0,Math.min(.999,e.revealDelay??0)),u=Math.max(0,(r-l)/(1-l)),h=Math.floor(u*o.length),d=e.tweenLength===!1?o.length:Math.round(a.length+(o.length-a.length)*r),f=mn(e.chars),g=e.refreshRate??pn,p=g>0?Math.floor(n*g/1e3):0,m=e.seed??1;let b="";for(let v=0;v<d;v++){const k=c?v>=d-h:v<h,M=c?o[o.length-(d-v)]:o[v];k&&M!==void 0||M===" "||M===`
|
|
2
|
-
`?b+=M:b+=f[gn(m,v,p)%f.length]}return b}class bn{id;name;_captions;_tracks=[];_trackPlayers=new Map;_motionPathTracks=new Map;_springTracks=new Map;_textTracks=new Map;_config;_currentTime=0;_playbackState="idle";_direction="forward";_loopIteration=0;_explicitDuration;_repeatDelayRemaining=0;_wrapAfterDelay=!1;onUpdate=null;onComplete=null;constructor(t){if(this.id=t.id,this.name=t.name,this._captions=t.captions,this._config=t.config??{},this._explicitDuration=t.config?.duration,t.tracks)for(const n of t.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(t){if(this._explicitDuration=t,t!==void 0)this._config={...this._config,duration:t};else if(this._config.duration!==void 0){const n={...this._config};delete n.duration,this._config=n}}get currentTime(){return this._currentTime}get playbackState(){return this._playbackState}get direction(){return this._direction}get loopIteration(){return this._loopIteration}get repeatDelayRemaining(){return this._repeatDelayRemaining}get speed(){return this._config.speed??1}set speed(t){this._config.speed=t}play(){const t=this.duration;this._direction==="forward"&&this._currentTime>=t&&t>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&t>0&&(this._currentTime=t,this._loopIteration=0),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="idle",this._repeatDelayRemaining=0,this._wrapAfterDelay=!1,this._currentTime=0,this._loopIteration=0,this._direction="forward"}seek(t){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let i=t*this.speed;if(this._repeatDelayRemaining>0){const o=Math.min(this._repeatDelayRemaining,i);if(this._repeatDelayRemaining-=o,i-=o,this._repeatDelayRemaining>0){this.onUpdate?.(this.getStateAtTime(this._currentTime));return}this._wrapAfterDelay&&(this._wrapAfterDelay=!1,this._currentTime=0)}const r=1e3;for(let o=0;o<r&&i>0&&this._playbackState==="playing";o++)if(this._direction==="forward"){const c=n-this._currentTime;if(i>=c){if(i-=c,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=i,i=0}else{const c=this._currentTime;if(i>=c){if(i-=c,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=i,i=0}const a=this.getStateAtTime(this._currentTime);this.onUpdate?.(a)}getStateAtTime(t){const n=new Map;if(this._hasSharedWrites())this._resolveShared(t,n);else for(const[s,i]of this._trackPlayers){const r=i.getTrack().property;for(const{target:a,value:o,start:c}of i.getTargetValues(t))this._write(n,s,a,r,o,t-c)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,n){const s=new Map;for(const[i,r]of this._trackPlayers){const a=r.getTrack().property;for(const{target:o,value:c,start:l}of r.getTargetValues(t)){const u=`${o}\0${a}`,h=l<=t,d=s.get(u);(!d||(h!==d.started?h:h?l>=d.start:l<=d.start))&&s.set(u,{trackId:i,target:o,property:a,value:c,start:l,started:h})}}for(const{trackId:i,target:r,property:a,value:o,start:c}of s.values())this._write(n,i,r,a,o,t-c)}_write(t,n,s,i,r,a){if(r===void 0)return;let o=t.get(s);o||(o=new Map,t.set(s,o));const c=this._textTracks.get(n);if(c&&typeof r=="number"){o.set("text",yn(c.textConfig,r,Math.max(0,a)));return}const l=this._motionPathTracks.get(n);if(l&&typeof r=="number"){const u=fn(l.motionPathConfig,r);o.set("motionPathX",u.x),o.set("motionPathY",u.y),l.motionPathConfig.autoRotate&&o.set("motionPathRotate",u.angle)}else o.set(i,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const s of V(n)){const i=`${s}\0${n.property}`;if(t.has(i)){this._sharedWrites=!0;break t}t.add(i)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,lt(t)){this._trackPlayers.set(t.id,new dn(t));return}if(ht(t)){this._trackPlayers.set(t.id,new un(t)),this._springTracks.set(t.id,t);return}if(_t(t))this._trackPlayers.set(t.id,new kt(t)),this._textTracks.set(t.id,t);else if(me(t)){const n={id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,delay:t.delay,endDelay:t.endDelay,targets:t.targets,stagger:t.stagger};this._trackPlayers.set(t.id,new kt(n)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new kt(t))}replaceTrack(t,n){const s=this._tracks.findIndex(r=>r.id===t);if(s<0)return;const i=this._tracks.slice(s+1);this.removeTrack(t);for(const r of i)this.removeTrack(r.id);this.addTrack(n);for(const r of i)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(n=>n.id!==t),this._sharedWrites=null,this._trackPlayers.delete(t),this._motionPathTracks.delete(t),this._springTracks.delete(t),this._textTracks.delete(t)}getTracks(t={}){return this._tracks.filter(n=>this._matches(n,t))}removeTracks(t={}){const n=this.getTracks(t).map(s=>s.id);for(const s of n)this.removeTrack(s);return n}getTrackSpan(t){const n=this._trackPlayers.get(t);if(!n)return;const s=n.getTrack(),i=s.delay??0;if(ht(s)||lt(s))return{from:i,to:n.getDuration()};const r=s.keyframes;if(!(!r||r.length===0))return{from:r[0].time+i,to:n.getDuration()}}findConflicts(){const t=[];for(let n=0;n<this._tracks.length;n++){const s=this._tracks[n],i=this.getTrackSpan(s.id);if(i)for(let r=0;r<n;r++){const a=this._tracks[r];if(a.property!==s.property)continue;const o=V(a).filter(h=>V(s).includes(h));if(o.length===0)continue;const c=this.getTrackSpan(a.id);if(!c||!(c.from<=i.to&&i.from<=c.to))continue;const u=i.from>=c.from;for(const h of o)t.push({target:h,property:s.property,losingTrackId:u?a.id:s.id,winningTrackId:u?s.id:a.id})}}return t}_matches(t,n){if(n.id!==void 0&&t.id!==n.id||n.property!==void 0&&t.property!==n.property||n.target!==void 0&&!V(t).includes(n.target))return!1;if(n.timeRange){const s=this.getTrackSpan(t.id);if(!s||s.to<n.timeRange.from||s.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:H,id:this.id,name:this.name,config:{...this._config},tracks:[...this._tracks],...this.captions&&{captions:this.captions}}}get config(){return this._config}get markers(){return[...this._config.markers??[]].sort((t,n)=>t.time-n.time)}setMarkers(t){const n=t&&t.length>0?[...t].sort((i,r)=>i.time-r.time).map(i=>({...i})):void 0,s={...this._config};n?s.markers=n:delete s.markers,this._config=s}get captions(){return this._captions}setCaptions(t){const n={};for(const[s,i]of Object.entries(t??{}))n[s]={...i};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,n]of this._trackPlayers)t=Math.max(t,n.getDuration());return t}_handleEndReached(){const t=this._config.loop??0;return t===-1||this._loopIteration<t?(this._loopIteration++,this._armRepeatDelay(),this._config.alternate?this._direction="reverse":this._repeatDelayRemaining>0?this._wrapAfterDelay=!0:this._currentTime=0,this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}_handleStartReached(){const t=this._config.loop??0;return this._config.alternate&&(t===-1||this._loopIteration<t)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const vn=100;function kn(e,t,n,s){const i=[],r=[],{duration:a,alternate:o}=s,c=(f,g,p,m)=>{r.push([f,g]);const b=[];e.forEach((v,k)=>{(p==="forward"?(m?v>=f:v>f)&&v<=g:(m?v<=f:v<f)&&v>=g)&&b.push(k)}),b.sort((v,k)=>(p==="forward"?e[v]-e[k]:e[k]-e[v])||v-k);for(const v of b)i.push({kind:"event",index:v,direction:p})};let l=t.time,u=t.direction,h=t.fresh===!0;const d=Math.min(vn,Math.max(0,n.iteration-t.iteration));for(let f=0;f<d;f++){const g=u==="forward"?a:0;c(l,g,u,h),i.push({kind:"repeat"}),o?(u=u==="forward"?"reverse":"forward",l=g,h=!1):(l=u==="forward"?0:a,h=!0)}return d>0&&s.holding&&!o?{crossings:i,passes:r}:(c(l,n.time,u,h),{crossings:i,passes:r})}function xn(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function K(e){const t=e.endDelay;return{...e.delay!==void 0&&{delay:e.delay},...t!==void 0&&{endDelay:t},...e.targets!==void 0&&{targets:[...e.targets]},...e.stagger!==void 0&&{stagger:{...e.stagger}}}}function wn(e){if(lt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:xn(t.inertia),...K(t)}}if(ht(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...K(t)}}if(_t(e)){const t=e;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((n,s)=>n.time-s.time),...K(t)}}if(e.property==="motionPath"&&"motionPathConfig"in e){const t=e,n=[...t.keyframes].sort((s,i)=>s.time-i.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:n,...K(t)}}return hn({id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,...K(e)})}function rt(e){const t=e.formatVersion??1;if(t>H)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${H}. Update tinyfly to play it.`);return new bn({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(wn),captions:e.captions})}const Mn=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),Sn="#ffffff",Tn="rgba(0, 0, 0, 0.5)";function _n(e){const t=[];if(e.blur!==void 0&&t.push(`blur(${Math.max(0,e.blur)}px)`),e.brightness!==void 0&&t.push(`brightness(${Math.max(0,e.brightness)})`),e.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,e.glow)}px ${e.glowColor??Sn})`),e.shadowX!==void 0||e.shadowY!==void 0||e.shadowBlur!==void 0){const n=e.shadowX??0,s=e.shadowY??0,i=Math.max(0,e.shadowBlur??0);t.push(`drop-shadow(${n}px ${s}px ${i}px ${e.shadowColor??Tn})`)}return t.length>0?t.join(" "):null}function An(e,t){const n=e.childNodes.length===1?e.firstChild:null;if(n&&n.nodeType===3){const s=n;s.data!==t&&(s.data=t);return}e.textContent!==t&&(e.textContent=t)}function En(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const Jt=new Set(["width","height","top","right","bottom","left","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","borderRadius","borderWidth","fontSize","lineHeight","letterSpacing","outlineWidth","gap","rowGap","columnGap"]),Pn=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","motionPathX","motionPathY","motionPathRotate"]),Cn=new Set(["originX","originY"]),In=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Rn=new Set(["drawOn"]),$n={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},te={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},Ln="http://www.w3.org/2000/svg";class wt{targets=new Map;registerTarget(t,n){this.targets.set(t,n)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[n,s]of t.values){const i=this.targets.get(n);i&&this.applyProperties(i,s)}}applyProperties(t,n){const s=[];let i=null,r=null,a=null;const o=n.has("motionPathX"),c=n.has("motionPathY"),l=n.has("motionPathRotate");for(const[d,f]of n)if(!(d==="x"&&o)&&!(d==="y"&&c)&&!((d==="rotate"||d==="rotateZ")&&l)&&!Rn.has(d)){if(Pn.has(d)){const g=this.buildTransformPart(d,f);g&&s.push(g)}else if(Cn.has(d))typeof f=="number"&&((i??={})[d]=f);else if(In.has(d))typeof f=="number"&&((r??={})[d]=f);else if(Mn.has(d))(a??={})[d]=f;else if(d!=="perspective"){if(d!=="shine")if(d==="text"&&typeof f=="string")An(t,f);else if(d==="d"&&typeof f=="string"){const g=t;(g.tagName?.toLowerCase()==="path"?g:g.querySelector?.("path"))?.setAttribute?.("d",f)}else this.applyStyleProperty(t,d,f)}}const u=n.get("shine");typeof u=="number"&&this.applyShine(t,u);const h=n.get("perspective");if(typeof h=="number"&&s.unshift(`perspective(${h}px)`),s.length>0&&(t.style.transform=s.join(" "),En(t)),i){const d=i.originX??50,f=i.originY??50;t.style.transformOrigin=`${d}% ${f}%`}if(r){const d=r.clipTop??0,f=r.clipRight??0,g=r.clipBottom??0,p=r.clipLeft??0;t.style.clipPath=`inset(${d}% ${f}% ${g}% ${p}%)`}if(a){const d=_n(a);d&&(t.style.filter=d)}}buildTransformPart(t,n){if(typeof n!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${n}px)`;case"y":case"motionPathY":return`translateY(${n}px)`;case"z":return`translateZ(${n}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${n}deg)`;case"rotateX":return`rotateX(${n}deg)`;case"rotateY":return`rotateY(${n}deg)`;case"scale":return`scale(${n})`;case"scaleX":return`scaleX(${n})`;case"scaleY":return`scaleY(${n})`;case"scaleZ":return`scaleZ(${n})`;case"skewX":return`skewX(${n}deg)`;case"skewY":return`skewY(${n}deg)`;default:return null}}applyShine(t,n){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const s=t.dataset.shineBase,i=-20+n*140,r=t.style;r.color="transparent",r.backgroundImage=`linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${s}, ${s})`,r.backgroundSize="250% 100%, 100% 100%",r.backgroundPosition=`${i}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,n,s){let i;if(t.namespaceURI===Ln&&n in te){const o=Array.isArray(s)?s.join(", "):String(s);t.style[te[n]]=o;return}else n==="fill"&&t.dataset?.elementType==="text"?i="color":i=$n[n]??n;let a;typeof s=="number"?Jt.has(n)||Jt.has(i)?a=`${s}px`:a=String(s):Array.isArray(s)?a=s.join(", "):a=s,t.style[i]=a}}class ee{media;offset;driftTolerance;constructor(t,n={}){this.media=t,this.offset=n.offset??0,this.driftTolerance=Math.max(0,n.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,n){const s=this.targetTime(t);n?(this.media.paused&&this.safePlay(),Math.abs(this.media.currentTime-s)>this.driftTolerance&&(this.media.currentTime=s)):(this.media.paused||this.media.pause(),this.media.currentTime!==s&&(this.media.currentTime=s))}seek(t){this.media.currentTime=this.targetTime(t)}setRate(t){this.media.playbackRate=t}dispose(){this.media.paused||this.media.pause()}safePlay(){const t=this.media.play();t&&typeof t.catch=="function"&&t.catch(()=>{})}}function Dn(e,t,n,s,i){const r=n-i;if(r<0){t.paused||t.pause(),t.currentTime=0;return}e.update(r,s)}class at{container;timeline=null;adapter;animationFrameId;lastTime;options;targets={};isDestroyed=!1;mediaSync;mediaTargets=[];symbolInstances=[];scenarioList=[];scenarioId;authored=new Map;markerList=[];listeners=new Set;playhead={time:0,iteration:0,direction:"forward"};stepping=!1;lastMarkerId=null;reducedQuery;onReducedChange=()=>this.applyReducedMotion();visibilityObserver;onScreen=!0;pausedByVisibility=!1;autoplayWhenSeen=!1;onDocumentVisibility=()=>this.updateVisibility();constructor(t,n={}){if(typeof t=="string"){const s=document.querySelector(t);if(!s)throw new Error(`Container not found: ${t}`);this.container=s}else this.container=t;this.options=n,this.adapter=new wt}async load(t){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(t)}async loadSource(t){let n;if(typeof t=="string"){const s=await fetch(t);if(!s.ok)throw new Error(`Failed to load animation: ${s.statusText}`);n=await s.json()}else n=t;this.useDefinition(n),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(t){const n={...t.config};this.options.speed!==void 0&&(n.speed=this.options.speed),this.options.loop!==void 0&&(n.loop=this.options.loop),this.options.alternate!==void 0&&(n.alternate=this.options.alternate),this.timeline=rt({...t,config:n}),this.markerList=this.timeline.markers,this.lastMarkerId=null,this.options.onComplete&&(this.timeline.onComplete=this.options.onComplete),this.options.onUpdate&&(this.timeline.onUpdate=this.options.onUpdate),this.autoRegisterTargets(),this.setupSymbolInstances(),this.scanMedia()}async loadScenarios(t,n={}){if(t.length===0)throw new Error("tinyfly: loadScenarios needs at least one scenario");const s=new Set;for(const r of t){if(s.has(r.id))throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);s.add(r.id)}const i=n.initial===void 0?t[0]:t.find(r=>r.id===n.initial);if(!i)throw new Error(`tinyfly: there is no scenario "${n.initial}"`);this.scenarioList=[...t],this.scenarioId=i.id,await this.loadSource(i.timeline)}get scenarios(){return this.scenarioList.map(t=>({id:t.id,label:t.label??t.id}))}get scenario(){return this.scenarioId}setScenario(t){const n=this.scenarioList.find(o=>o.id===t);if(!n||!this.timeline)return!1;if(t===this.scenarioId)return!0;const s=this.isPlaying,i=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=t,this.useDefinition(n.timeline),this.lastMarkerId=null;let a=0;return this.reducedMotion||i?a=this.duration:r!==void 0&&(a=this.markers.find(o=>o.id===r)?.time??0),this.seek(a),s&&!this.reducedMotion?(this.stepping=this.options.stepMode===!0,this.startPlaying()):this.notify(),!0}rememberAuthored(t){if(this.authored.has(t))return;const n={style:t.getAttribute("style")};t.children.length===0&&(n.text=t.textContent??"");const s=t.tagName.toLowerCase()==="path"?t:t.querySelector("path");s&&(n.path={element:s,d:s.getAttribute("d")}),this.authored.set(t,n)}restoreAuthored(){for(const[t,n]of this.authored){n.style===null?t.removeAttribute("style"):t.setAttribute("style",n.style),n.text!==void 0&&t.textContent!==n.text&&(t.textContent=n.text),n.path&&(n.path.d===null?n.path.element.removeAttribute("d"):n.path.element.setAttribute("d",n.path.d));const s=t.dataset;s&&delete s.shineBase}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){for(const t of this.listeners)t()}get reducedMotion(){return this.reducedQuery?.matches===!0}get markers(){return this.markerList}get currentMarker(){const t=this.currentTime;let n;for(const s of this.markers)if(s.time<=t+.5)n=s;else break;return n}caption(t,n){const s=t?this.markers.find(a=>a.id===t):this.currentMarker;if(!s)return;const i=n??this.language(),r=a=>a?.[i]?.[s.id]??a?.[i.split("-")[0]]?.[s.id];return r(this.options.captions)??r(this.timeline?.captions)??s.label}next(){if(!this.timeline)return;const t=this.currentTime,n=this.markers.find(s=>s.time>t+.5);if(this.reducedMotion){this.seek(n?n.time:this.duration);return}t>=this.duration-.5||(this.stepping=n!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,n=[...this.markers].reverse().find(s=>s.time<t-.5);this.pause(),this.seek(n?n.time:0)}goToMarker(t){const n=this.markers.find(s=>s.id===t);n&&(this.pause(),this.seek(n.time))}language(){return this.container.closest("[lang]")?.getAttribute("lang")||(typeof document<"u"?document.documentElement.lang:"")||"en"}showInitialFrame(){if(!this.timeline)return;const t=this.options.initialFrame??"start";if(t==="none")return;const n=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,n))),this.applyState()}watchReducedMotion(){this.options.respectReducedMotion===!1||typeof window>"u"||typeof window.matchMedia!="function"||(this.reducedQuery??=window.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedQuery.addEventListener?.("change",this.onReducedChange),this.reducedQuery.matches&&this.applyReducedMotion())}applyReducedMotion(){!this.reducedMotion||!this.timeline||(this.autoplayWhenSeen=!1,this.pause(),this.seek(this.timeline.duration))}watchVisibility(){if(!(!this.options.playWhenVisible||typeof window>"u")){if(typeof IntersectionObserver=="function"){this.visibilityObserver?.disconnect(),this.visibilityObserver=new IntersectionObserver(n=>{for(const s of n)this.onScreen=s.isIntersecting;this.updateVisibility()}),this.visibilityObserver.observe(this.container);const t=this.container.getBoundingClientRect?.();t&&(t.width>0||t.height>0)&&(this.onScreen=t.bottom>0&&t.top<window.innerHeight&&t.right>0&&t.left<window.innerWidth)}document.addEventListener("visibilitychange",this.onDocumentVisibility)}}updateVisibility(){const t=this.onScreen&&document.visibilityState!=="hidden";!t&&this.isPlaying?(this.pausedByVisibility=!0,this.pause()):t&&(this.pausedByVisibility||this.autoplayWhenSeen)&&!this.reducedMotion&&(this.pausedByVisibility=!1,this.autoplayWhenSeen=!1,this.startPlaying())}announceMarker(){if(!this.options.onMarker)return;const t=this.currentMarker,n=t?.id;n!==this.lastMarkerId&&(this.lastMarkerId=n,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(n=>{const s=n,i=Number(s.getAttribute("data-tinyfly-start")??"0")||0,r=s.getAttribute("data-volume");r!==null&&(s.volume=Math.max(0,Math.min(1,Number(r)||0))),this.mediaTargets.push({el:s,startTime:i,sync:new ee(s)})})}syncAllMedia(t,n){for(const s of this.mediaTargets)Dn(s.sync,s.el,t,n,s.startTime)}loadFromString(t){const n=JSON.parse(t);this.load(n)}registerTarget(t,n){if(typeof n=="string"){const s=this.container.querySelector(n);s&&(this.rememberAuthored(s),this.targets[t]=s,this.adapter.registerTarget(t,s))}else this.rememberAuthored(n),this.targets[t]=n,this.adapter.registerTarget(t,n)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(n=>{const s=n.closest("[data-tinyfly-symbol]");if(s&&s!==n)return;const i=n.getAttribute("data-tinyfly");i&&this.registerTarget(i,n)}),this.timeline&&new Set(this.timeline.tracks.map(s=>s.target)).forEach(s=>{if(!this.targets[s]){const i=this.container.querySelector(`[data-tinyfly="${s}"]`)||this.container.querySelector(`.${s}`)||this.container.querySelector(`#${s}`);i&&this.registerTarget(s,i)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const n=new Map(t.map(s=>[s.id,s]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const i=s.getAttribute("data-tinyfly-symbol");if(!i)return;const r=n.get(i);if(!r||!r.timeline.tracks?.length)return;const a=new wt;s.querySelectorAll("[data-tinyfly]").forEach(o=>{const c=o.getAttribute("data-tinyfly");c&&a.registerTarget(c,o)}),this.symbolInstances.push({adapter:a,timeline:rt(r.timeline)})})}attachMedia(t,n){this.mediaSync=new ee(t,n),this.timeline&&(this.mediaSync.setRate(this.timeline.speed),this.mediaSync.update(this.timeline.currentTime,this.isPlaying))}detachMedia(){this.mediaSync?.dispose(),this.mediaSync=void 0}play(){!this.timeline||this.isDestroyed||(this.autoplayWhenSeen=!1,this.stepping=this.options.stepMode===!0,this.startPlaying())}startPlaying(){if(!this.timeline||this.isDestroyed)return;const t=this.timeline.playbackState==="idle";this.timeline.play(),t&&this.timeline.currentTime===0&&this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.update(this.timeline.currentTime,!0),this.syncAllMedia(this.timeline.currentTime,!0),this.startAnimationLoop(),this.notify()}pause(){this.timeline&&(this.stepping=!1,this.timeline.pause(),this.notify(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1),this.stopAnimationLoop())}stop(){this.timeline&&(this.timeline.stop(),this.stopAnimationLoop(),this.applyState(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1))}seek(t){this.timeline&&(this.timeline.seek(t),this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.seek(this.timeline.currentTime),this.syncAllMedia(this.timeline.currentTime,this.isPlaying))}setSpeed(t){this.timeline&&(this.timeline.speed=t,this.mediaSync?.setRate(t))}reverse(){this.timeline&&this.timeline.reverse()}get currentTime(){return this.timeline?.currentTime??0}get duration(){return this.timeline?.duration??0}get isPlaying(){return this.timeline?.playbackState==="playing"}destroy(){this.isDestroyed=!0,this.stopAnimationLoop(),this.reducedQuery?.removeEventListener?.("change",this.onReducedChange),this.visibilityObserver?.disconnect(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onDocumentVisibility),this.mediaSync?.dispose(),this.mediaSync=void 0;for(const t of this.mediaTargets)t.el.paused||t.el.pause();this.mediaTargets=[],this.adapter.clearTargets();for(const t of this.symbolInstances)t.adapter.clearTargets();this.symbolInstances=[],this.authored.clear(),this.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this.isDestroyed||!this.timeline)return;const s=n-(this.lastTime??n);this.lastTime=n;const i=this.playhead;this.timeline.tick(s),this.stopAtMarker(i),this.applyState();const r=this.timeline.playbackState==="playing";this.mediaSync?.update(this.timeline.currentTime,r),this.syncAllMedia(this.timeline.currentTime,r),this.timeline.playbackState==="playing"?this.animationFrameId=requestAnimationFrame(t):(this.animationFrameId=void 0,this.notify())};this.animationFrameId=requestAnimationFrame(t)}stopAtMarker(t){const n=this.timeline,s={time:n.currentTime,iteration:n.loopIteration,direction:n.direction};this.playhead=s;const i=this.markers;if(i.length===0)return;const{crossings:r}=kn(i.map(a=>a.time),t,s,{duration:n.duration,alternate:n.config.alternate===!0,holding:n.repeatDelayRemaining>0});for(const a of r){if(a.kind!=="event")continue;const o=i[a.index];if(this.stepping||o.pause){this.stepping=!1,n.pause(),n.seek(o.time),this.playhead={time:o.time,iteration:n.loopIteration,direction:n.direction};return}}}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}applyState(){if(!this.timeline)return;const t=this.timeline.currentTime;this.adapter.applyState(this.timeline.getStateAtTime(t)),this.announceMarker(),this.notify();for(const n of this.symbolInstances){const s=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(s>0?t%s:t))}}}async function On(e,t,n={}){const s=new at(e,{...n,autoplay:!0});return await s.load(t),s}function Nn(e,t={}){return new at(e,t)}const ne={play:"Play",pause:"Pause",prev:"Previous step",next:"Next step",restart:"Restart",scrub:"Position",speed:"Speed",reveal:"Reveal",step:"Step",of:"of",stepFormat:"{index} / {total}",scenario:"Scenario",fullscreen:"Full screen",exitFullscreen:"Exit full screen"},se="tinyfly-controls-style",Fn=`
|
|
1
|
+
(function($){"use strict";function pe(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function me(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const et=2;function ge(e){return e.some(t=>t.interpolation!==void 0)?2:1}function At(e){return e.property==="text"&&"textConfig"in e}function ht(e){return e.kind==="inertia"&&"inertia"in e}function ut(e){return e.kind==="spring"&&"spring"in e}function ye(e){return e.property==="motionPath"&&"motionPathConfig"in e}function Et(e,t,n="start"){if(t<=1)return 0;if(typeof n=="number"){const i=Math.max(0,Math.min(t-1,n));return Math.abs(e-i)}switch(n){case"end":return t-1-e;case"center":return Math.abs(e-(t-1)/2);case"edges":return(t-1)/2-Math.abs(e-(t-1)/2);default:return e}}function be(e,t="start"){if(e<=1)return 0;let n=0;for(let i=0;i<e;i++)n=Math.max(n,Et(i,e,t));return n}function Pt(e,t,n){if(n.offsets)return n.offsets[e]??0;const i=n.from??"start",s=Et(e,t,i);if(n.amount!==void 0){const r=be(t,i);return r===0?0:n.amount*s/r}return n.each!==void 0?n.each*s:0}function ve(e,t){return Array.from({length:e},(n,i)=>Pt(i,e,t))}function dt(e,t){return e<=1?0:Math.max(...ve(e,t))}const H=1,Ct=6e4,nt=Ct/H,B={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1};class ke{from;to;stiffness;damping;mass;restDelta;restSpeed;distance;samples;velocity;settledStep=null;constructor(t){this.from=t.from,this.to=t.to,this.stiffness=t.stiffness??B.stiffness,this.damping=t.damping??B.damping,this.mass=t.mass??B.mass,this.restDelta=t.restDelta??B.restDelta,this.restSpeed=t.restSpeed??B.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??B.velocity,this.isAtRest(this.from)&&(this.settledStep=0)}isAtRest(t){return Math.abs(t-this.to)<this.restDelta*this.distance&&Math.abs(this.velocity)<this.restSpeed*this.distance}valueAt(t){if(t<=0)return this.from;const n=Math.floor(t/H);if(this.simulateTo(n+1),this.settledStep!==null&&n>=this.settledStep)return this.to;const i=this.samples[Math.min(n,this.samples.length-1)],s=this.samples[Math.min(n+1,this.samples.length-1)],r=t/H-n;return i+(s-i)*r}settleTime(){return this.simulateTo(nt+1),this.settledStep!==null?this.settledStep*H:Ct}simulateTo(t){if(this.settledStep!==null)return;const n=Math.min(t,nt+1),i=H/1e3;for(;this.samples.length<n;){const s=this.samples[this.samples.length-1],r=s-this.to,a=-this.stiffness*r,o=-this.damping*this.velocity,c=(a+o)/this.mass;this.velocity+=c*i;const l=s+this.velocity*i;if(this.samples.push(l),this.isAtRest(l)){this.settledStep=this.samples.length-1;return}}this.samples.length>nt&&(this.settledStep=nt)}}const It=4,xe=.002,we=1e-4,Me=6e4;function ft(e){const t=e.friction??It;return t>0?t:It}function Se(e){return e.from+e.velocity/ft(e)}function Te(e,t){if(t===void 0)return e;if(typeof t=="number")return t>0?Math.round(e/t)*t:e;if(t.length===0)return e;let n=t[0];for(const i of t)Math.abs(i-e)<Math.abs(n-e)&&(n=i);return n}function Rt(e){let t=Te(Se(e),e.end);return e.min!==void 0&&(t=Math.max(e.min,t)),e.max!==void 0&&(t=Math.min(e.max,t)),t}function $t(e){const t=Math.abs(Rt(e)-e.from);if(t===0)return 0;const n=e.restDelta??Math.max(we,t*xe);if(n>=t)return 0;const i=Math.log(t/n)/ft(e);return Math.min(Me,i*1e3)}function Lt(e,t){if(t<=0)return e.from;const n=Rt(e);if(t>=$t(e))return n;const i=ft(e);return e.from+(n-e.from)*(1-Math.exp(-i*t/1e3))}const pt=e=>e,_e=e=>e*e,Ae=e=>1-(1-e)*(1-e),Ee=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,Dt=e=>e*e*e,Ot=e=>1-Math.pow(1-e,3),Nt=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Pe={linear:pt,"ease-in":Dt,"ease-out":Ot,"ease-in-out":Nt,"ease-in-quad":_e,"ease-out-quad":Ae,"ease-in-out-quad":Ee,"ease-in-cubic":Dt,"ease-out-cubic":Ot,"ease-in-out-cubic":Nt};function Ce(e){const[t,n,i,s]=e,r=3*t,a=3*(i-t)-r,o=1-r-a,c=3*n,l=3*(s-n)-c,u=1-c-l,h=d=>((o*d+a)*d+r)*d,f=d=>((u*d+l)*d+c)*d,m=d=>(3*o*d+2*a)*d+r,p=d=>{let g=d;for(let k=0;k<8;k++){const M=h(g)-d;if(Math.abs(M)<1e-7)return g;const y=m(g);if(Math.abs(y)<1e-7)break;g-=M/y}let b=0,v=1;for(g=d;b<v;){const k=h(g);if(Math.abs(k-d)<1e-7)return g;d>k?b=g:v=g,g=(b+v)/2}return g};return d=>{if(d<=0)return 0;if(d>=1)return 1;const g=p(d);return f(g)}}function mt(e,t="out"){if(t==="out")return e;const n=i=>1-e(1-i);return t==="in"?n:i=>i<.5?n(i*2)/2:e(i*2-1)/2+.5}function Ie(e=1,t=.3){const n=Math.max(1,e),i=t/(2*Math.PI)*Math.asin(1/n);return s=>s<=0?0:s>=1?1:n*Math.pow(2,-10*s)*Math.sin((s-i)*(2*Math.PI)/t)+1}const Re=e=>{if(e<=0)return 0;if(e>=1)return 1;if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const s=e-.5454545454545454;return 7.5625*s*s+.75}if(e<2.5/2.75){const s=e-.8181818181818182;return 7.5625*s*s+.9375}const i=e-2.625/2.75;return 7.5625*i*i+.984375};function $e(e=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const n=t-1;return n*n*((e+1)*n+e)+1}}function Le(e,t="end"){const n=Math.max(1,Math.floor(e));return i=>{if(i>=1)return 1;if(i<=0)return t==="start"||t==="both"?t==="start"?1/n:1/(n+1):0;const s=Math.floor(i*n);switch(t){case"start":return Math.min(1,(s+1)/n);case"both":return(s+1)/(n+1);case"none":return n===1?0:Math.min(1,s/(n-1));default:return s/n}}}function De(e){switch(e.type){case"steps":return Le(e.count,e.position);case"elastic":return mt(Ie(e.amplitude,e.period),e.mode);case"bounce":return mt(Re,e.mode);case"back":return mt($e(e.overshoot),e.mode)}}function Oe(e){return e===void 0?pt:pe(e)?Ce(e.points):me(e)?De(e):Pe[e]??pt}const Ft=32,Ne=256,z=new Map,Fe=/[MmLlHhVvCcSsQqTtAaZz]/,Xe=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,Ye={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Ve(e){const t=[];let n=0,i=null;const s=()=>{for(;n<e.length&&/[\s,]/.test(e[n]);)n++};for(;n<e.length&&(s(),!(n>=e.length));){const r=e[n];if(Fe.test(r)){i={type:r,args:[]},t.push(i),n++;continue}if(!i)break;const a=i.type==="A"||i.type==="a",o=i.args.length%7;if(a&&(o===3||o===4)){if(r!=="0"&&r!=="1")break;i.args.push(r==="1"?1:0),n++;continue}const c=Xe.exec(e.slice(n));if(!c)break;i.args.push(parseFloat(c[0])),n+=c[0].length}return t}function qe(e,t,n,i,s,r,a,o,c){if(e===o&&t===c)return[];let l=Math.abs(n),u=Math.abs(i);if(l===0||u===0)return[[e,t,o,c,o,c]];const h=s*Math.PI/180,f=Math.cos(h),m=Math.sin(h),p=(e-o)/2,d=(t-c)/2,g=f*p+m*d,b=-m*p+f*d,v=g*g/(l*l)+b*b/(u*u);if(v>1){const A=Math.sqrt(v);l*=A,u*=A}const k=r===a?-1:1,M=l*l*u*u-l*l*b*b-u*u*g*g,y=l*l*b*b+u*u*g*g,S=k*Math.sqrt(Math.max(0,M/y)),x=S*l*b/u,P=-S*u*g/l,W=f*x-m*P+(e+o)/2,T=m*x+f*P+(t+c)/2,R=(A,I,D,j)=>{const _t=A*D+I*j,lt=Math.sqrt((A*A+I*I)*(D*D+j*j)),tt=Math.acos(Math.max(-1,Math.min(1,_t/lt)));return A*j-I*D<0?-tt:tt},_=R(1,0,(g-x)/l,(b-P)/u);let C=R((g-x)/l,(b-P)/u,(-g-x)/l,(-b-P)/u);!a&&C>0&&(C-=2*Math.PI),a&&C<0&&(C+=2*Math.PI);const O=Math.max(1,Math.ceil(Math.abs(C)/(Math.PI/2))),w=C/O,E=4/3*Math.tan(w/4),F=A=>{const I=l*Math.cos(A),D=u*Math.sin(A);return[f*I-m*D+W,m*I+f*D+T]},N=A=>{const I=-l*Math.sin(A),D=u*Math.cos(A);return[f*I-m*D,m*I+f*D]},L=[];for(let A=0;A<O;A++){const I=_+A*w,D=I+w,[j,_t]=F(I),[lt,tt]=A===O-1?[o,c]:F(D),[bi,vi]=N(I),[ki,xi]=N(D);L.push([j+E*bi,_t+E*vi,lt-E*ki,tt-E*xi,lt,tt])}return L}function Y(e,t,n,i,s){const r=1-s;return r*r*r*e+3*r*r*s*t+3*r*s*s*n+s*s*s*i}function Xt(e,t,n,i,s){const r=1-s;return 3*r*r*(t-e)+6*r*s*(n-t)+3*s*s*(i-n)}function Q(e,t,n,i){return{subpath:0,type:"L",points:[n,i],startX:e,startY:t,endX:n,endY:i,length:Math.hypot(n-e,i-t)}}function it(e,t,n){const[i,s,r,a,o,c]=n,l=[0];let u=e,h=t,f=0;for(let m=1;m<=Ft;m++){const p=m/Ft,d=Y(e,i,r,o,p),g=Y(t,s,a,c,p);f+=Math.hypot(d-u,g-h),l.push(f),u=d,h=g}return{subpath:0,type:"C",points:[i,s,r,a,o,c],startX:e,startY:t,endX:o,endY:c,length:f,lengths:l}}function st(e){const t=z.get(e);if(t)return t;const n=[];let i=0,s=0,r=0,a=0,o=null,c=null,l=-1;const u=new Set,h=d=>{l<0&&(l=0),d.subpath=l,n.push(d)};for(const{type:d,args:g}of Ve(e)){const b=d.toUpperCase(),v=d!==b,k=Ye[b];if(b==="Z"){(i!==r||s!==a)&&h(Q(i,s,r,a)),l>=0&&u.add(l),i=r,s=a,o=c=null;continue}for(let M=0;M+k<=g.length;M+=k){const y=g.slice(M,M+k),S=v?i:0,x=v?s:0;let P=null,W=null;switch(b){case"M":M===0?(i=y[0]+S,s=y[1]+x,r=i,a=s,(l<0||n[n.length-1]?.subpath===l)&&l++):(h(Q(i,s,y[0]+S,y[1]+x)),i=y[0]+S,s=y[1]+x);break;case"L":h(Q(i,s,y[0]+S,y[1]+x)),i=y[0]+S,s=y[1]+x;break;case"H":h(Q(i,s,y[0]+S,s)),i=y[0]+S;break;case"V":h(Q(i,s,i,y[0]+x)),s=y[0]+x;break;case"C":{const T=[y[0]+S,y[1]+x,y[2]+S,y[3]+x,y[4]+S,y[5]+x];h(it(i,s,T)),P=[T[2],T[3]],i=T[4],s=T[5];break}case"S":{const[T,R]=o?[2*i-o[0],2*s-o[1]]:[i,s],_=[T,R,y[0]+S,y[1]+x,y[2]+S,y[3]+x];h(it(i,s,_)),P=[_[2],_[3]],i=_[4],s=_[5];break}case"Q":case"T":{let T=i,R=s;b==="Q"?(T=y[0]+S,R=y[1]+x):c&&(T=2*i-c[0],R=2*s-c[1]);const _=b==="Q"?y[2]+S:y[0]+S,C=b==="Q"?y[3]+x:y[1]+x;h(it(i,s,[i+2/3*(T-i),s+2/3*(R-s),_+2/3*(T-_),C+2/3*(R-C),_,C])),W=[T,R],i=_,s=C;break}case"A":{const T=y[5]+S,R=y[6]+x;let _=i,C=s;for(const O of qe(i,s,y[0],y[1],y[2],y[3],y[4],T,R))h(it(_,C,O)),_=O[4],C=O[5];i=T,s=R;break}}o=P,c=W}}const f=n.reduce((d,g)=>d+g.length,0),m=[];for(let d=0;d<n.length;){const g=n[d].subpath;let b=d,v=0;for(;b<n.length&&n[b].subpath===g;)v+=n[b++].length;const k=n[d],M=n[b-1],y=u.has(g)||Math.abs(M.endX-k.startX)<1e-9&&Math.abs(M.endY-k.startY)<1e-9;m.push({start:d,end:b,length:v,closed:y}),d=b}const p={segments:n,totalLength:f,subpaths:m};return z.size>=Ne&&z.delete(z.keys().next().value),z.set(e,p),p}function We(e,t){const n=e.lengths;if(t<=0)return 0;if(t>=e.length)return 1;let i=0,s=n.length-1;for(;i<s-1;){const o=i+s>>1;n[o]<t?i=o:s=o}const r=n[s]-n[i],a=r>0?(t-n[i])/r:0;return(i+a)/(n.length-1)}function Be(e,t){if(e.type==="L"){const h=e.length>0?Math.max(0,Math.min(1,t/e.length)):0;return{x:e.startX+(e.endX-e.startX)*h,y:e.startY+(e.endY-e.startY)*h,angle:Math.atan2(e.endY-e.startY,e.endX-e.startX)*180/Math.PI}}const[n,i,s,r,a,o]=e.points,c=We(e,t);let l=Xt(e.startX,n,s,a,c),u=Xt(e.startY,i,r,o,c);if(Math.hypot(l,u)<1e-9){const h=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),f=Y(e.startX,n,s,a,h),m=Y(e.startY,i,r,o,h),p=Y(e.startX,n,s,a,c),d=Y(e.startY,i,r,o,c);l=c<.5?f-p:p-f,u=c<.5?m-d:d-m}return{x:Y(e.startX,n,s,a,c),y:Y(e.startY,i,r,o,c),angle:Math.atan2(u,l)*180/Math.PI}}function Yt(e,t,n=0,i=e.length){if(i<=n)return{x:0,y:0,angle:0};let s=0;for(let r=n;r<i;r++){const a=e[r];if(s+a.length>=t||r===i-1)return Be(a,t-s);s+=a.length}return{x:0,y:0,angle:0}}function Ue(e,t){const{segments:n,totalLength:i}=st(e);return Yt(n,Math.max(0,Math.min(1,t))*i)}const je=24,He=320,ze=2.5,G=72,Qe=.2,Ge=128,rt=new Map;let gt=0,V;const Vt=e=>Math.round(e*100)/100;function qt(e,t){const{segments:n,subpaths:i,totalLength:s}=st(e);if(n.length===0)return[];if(t){const r=i.every(a=>a.closed);return[{segments:n,start:0,end:n.length,length:s,closed:r}]}return i.filter(r=>r.length>0).map(r=>({segments:n,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function yt(e,t){const n=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),i=Yt(e.segments,n*e.length,e.start,e.end);return[i.x,i.y]}function Wt(e){const t=[];let n=0;for(let i=e.start;i<e.end;i++)n+=e.segments[i].length,e.length>0&&t.push(n/e.length);return t}function Bt(e,t){const n=[];for(let i=0;i<t;i++)n.push(yt(e,e.closed?i/t:i/(t-1)));return n}function Ut(e){let t=0,n=0;for(const[i,s]of e)t+=i,n+=s;return t/=e.length,n/=e.length,e.map(([i,s])=>[i-t,s-n])}function Ze(e,t,n){const i=e.closed&&t.closed;if(n!==void 0)return{offset:i?Math.abs(n)%G/G:0,reversed:n<0};const s=Ut(Bt(e,G)),r=Ut(Bt(t,G)),a=G;let o={offset:0,reversed:!1},c=1/0;for(const l of[!1,!0]){const u=i?a:1;for(let h=0;h<u;h++){let f=0;for(let m=0;m<a&&f<c;m++){const p=i?l?(h-m+a)%a:(m+h)%a:l?a-1-m:m,d=s[m][0]-r[p][0],g=s[m][1]-r[p][1];f+=d*d+g*g}f<c&&(c=f,o={offset:i?h/a:0,reversed:l})}}return o}function Ke(e,t,n){return n?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function Je(e,t,n){return n?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function tn(e,t,n){const i=e.closed&&t.closed,s=Ze(e,t,n.shapeIndex),r=Math.max(je,Math.min(He,Math.ceil(Math.max(e.length,t.length)/ze))),a=new Set,o=h=>a.add(Math.round(h*1e7)/1e7);for(let h=0;h<=r;h++)o(h/r);for(const h of Wt(e))o(h);for(const h of Wt(t))o(Je(h,s,i));let c=[...a].sort((h,f)=>h-f);i&&(c=c.filter(h=>h<1));const l=[],u=[];for(const h of c)l.push(...yt(e,h)),u.push(...yt(t,Ke(h,s,i)));return en({from:l,to:u,closed:i})}function en(e){const t=e.from.length/2;if(t<=3)return e;const n=new Uint8Array(t);n[0]=1,n[t-1]=1;const i=[[0,t-1]];for(;i.length>0;){const[a,o]=i.pop();let c=-1,l=Qe;for(let u=a+1;u<o;u++){const h=Math.max(jt(e.from,a,o,u),jt(e.to,a,o,u));h>l&&(l=h,c=u)}c!==-1&&(n[c]=1,i.push([a,c],[c,o]))}const s=[],r=[];for(let a=0;a<t;a++)n[a]&&(s.push(e.from[a*2],e.from[a*2+1]),r.push(e.to[a*2],e.to[a*2+1]));return{from:s,to:r,closed:e.closed}}function jt(e,t,n,i){const s=e[t*2],r=e[t*2+1],a=e[n*2]-s,o=e[n*2+1]-r,c=e[i*2]-s,l=e[i*2+1]-r,u=a*a+o*o,h=u===0?0:Math.max(0,Math.min(1,(c*a+l*o)/u));return Math.hypot(c-h*a,l-h*o)}function nn(e,t,n){const i=n.shapeIndex;if(V&&V.from===e&&V.to===t&&V.shapeIndex===i)return V.plan;const r=rt.get(String(i??"auto"))?.get(e)?.get(t);if(r)return V={from:e,to:t,shapeIndex:i,plan:r},r;const a=st(e).subpaths.filter(m=>m.length>0).length===st(t).subpaths.filter(m=>m.length>0).length,o=qt(e,!a),c=qt(t,!a),l={pairs:o.map((m,p)=>tn(m,c[p],n))};gt>=Ge&&(rt.clear(),gt=0);const u=String(i??"auto"),h=rt.get(u)??new Map;rt.set(u,h);const f=h.get(e)??new Map;return h.set(e,f),f.set(t,l),gt++,V={from:e,to:t,shapeIndex:i,plan:l},l}function sn(e,t,n,i={}){if(!e)return t;if(!t)return e;const s=Math.max(0,Math.min(1,n));if(s===0)return e;if(s===1)return t;const r=nn(e,t,i);if(r.pairs.length===0)return s<.5?e:t;let a="";for(const o of r.pairs){for(let c=0;c<o.from.length;c+=2){const l=Vt(o.from[c]+(o.to[c]-o.from[c])*s),u=Vt(o.from[c+1]+(o.to[c+1]-o.from[c+1])*s);a+=`${c===0?a?" M":"M":" L"}${l} ${u}`}o.closed&&(a+=" Z")}return a}function rn(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const an=.9995;function on(){return[0,0,0,1]}function cn(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function ln(e){return Math.hypot(e[0],e[1],e[2],e[3])}function Z(e){const t=ln(e);return t===0?on():[e[0]/t,e[1]/t,e[2]/t,e[3]/t]}function hn(e,t,n){const i=Z(e);let s=Z(t),r=cn(i,s);if(r<0&&(s=[-s[0],-s[1],-s[2],-s[3]],r=-r),r>an)return Z([i[0]+(s[0]-i[0])*n,i[1]+(s[1]-i[1])*n,i[2]+(s[2]-i[2])*n,i[3]+(s[3]-i[3])*n]);const a=Math.acos(r),o=Math.sin(a),c=Math.sin((1-n)*a)/o,l=Math.sin(n*a)/o;return Z([i[0]*c+s[0]*l,i[1]*c+s[1]*l,i[2]*c+s[2]*l,i[3]*c+s[3]*l])}const X=(e,t,n)=>e+(t-e)*n,Ht=512,bt=new Map,vt=new Map;function zt(e){const t=bt.get(e);if(t)return t;const n=e.replace("#",""),i=[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)];return bt.size<Ht&&bt.set(e,i),i}const Qt=e=>e.charCodeAt(0)===35,Gt=e=>e.startsWith("rgb"),Zt=e=>e.startsWith("rgba"),un=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,kt=e=>Math.round(e).toString(16).padStart(2,"0");function dn(e,t,n){return`#${kt(e)}${kt(t)}${kt(n)}`}function Kt(e){const t=vt.get(e);if(t)return t;const n=e.match(un);if(!n)throw new Error(`Invalid rgb color: ${e}`);const i=parseInt(n[1],10),s=parseInt(n[2],10),r=parseInt(n[3],10),a=n[4]!==void 0?[i,s,r,parseFloat(n[4])]:[i,s,r];return vt.size<Ht&&vt.set(e,a),a}const fn=(e,t,n)=>{if(Qt(e)&&Qt(t)){const[i,s,r]=zt(e),[a,o,c]=zt(t),l=X(i,a,n),u=X(s,o,n),h=X(r,c,n);return dn(l,u,h)}if((Gt(e)||Zt(e))&&(Gt(t)||Zt(t))){const i=Kt(e),s=Kt(t),r=Math.round(X(i[0],s[0],n)),a=Math.round(X(i[1],s[1],n)),o=Math.round(X(i[2],s[2],n));if(i.length===4||s.length===4){const c=i[3]??1,l=s[3]??1,u=X(c,l,n);return`rgba(${r}, ${a}, ${o}, ${u})`}return`rgb(${r}, ${a}, ${o})`}return n<1?e:t},pn=(e,t,n)=>{const i=Math.min(e.length,t.length),s=[];for(let r=0;r<i;r++)s.push(X(e[r],t[r],n));return s},mn=(e,t,n)=>hn(e,t,n),Jt=(e,t,n)=>n<1?e:t,gn=(e,t,n)=>sn(e,t,n);function yn(e,t){return t==="slerp"?mn:typeof e=="number"?X:Array.isArray(e)?pn:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?fn:rn(e)?gn:Jt:Jt}function bn(e){const t=[...e.keyframes].sort((n,i)=>n.time-i.time);return{...e,keyframes:t}}function q(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function U(e,t,n,i){const s=n??0;return!i||t<=1?s:s+Pt(e,t,i)}class xt{track;targets;constructor(t){this.track=t,this.targets=q(t)}getValueAtTime(t){return this.valueForOffset(t-U(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=U(s,n,this.track.delay,this.track.stagger),a=this.valueForOffset(t-r);a!==void 0&&i.push({target:this.targets[s],value:a,start:r+this.track.keyframes[0].time})}return i}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const n=t[t.length-1].time,i=this.track.stagger?dt(this.targets.length,this.track.stagger):0;return n+(this.track.delay??0)+i+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:n}=this.track;if(n.length===0)return;if(n.length===1||t<=n[0].time)return n[0].value;if(t>=n[n.length-1].time)return n[n.length-1].value;const{from:i,to:s}=this.findSurroundingKeyframes(t);if(!i||!s)return;if(i.time===t)return i.value;const r=s.time-i.time,a=(t-i.time)/r,c=Oe(s.easing)(a);return yn(i.value,this.track.interpolation)(i.value,s.value,c)}findSurroundingKeyframes(t){const{keyframes:n}=this.track;for(let i=0;i<n.length-1;i++)if(t>=n[i].time&&t<=n[i+1].time)return{from:n[i],to:n[i+1]};return{from:null,to:null}}}class vn{track;targets;sampler;constructor(t){this.track=t,this.targets=q(t),this.sampler=new ke(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-U(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=U(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:this.sampler.valueAt(t-r),start:r})}return i}getDuration(){const t=this.track.stagger?dt(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class kn{track;targets;duration;constructor(t){this.track=t,this.targets=q(t),this.duration=$t(t.inertia)}getValueAtTime(t){return Lt(this.track.inertia,t-U(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const n=this.targets.length,i=[];for(let s=0;s<n;s++){const r=U(s,n,this.track.delay,this.track.stagger);i.push({target:this.targets[s],value:Lt(this.track.inertia,t-r),start:r})}return i}getDuration(){const t=this.track.stagger?dt(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function xn(e,t){const n={...Ue(e.pathData,t)};if(e.matrix){const[i,s,r,a,o,c]=e.matrix,{x:l,y:u}=n;n.x=i*l+r*u+o,n.y=s*l+a*u+c;const h=n.angle*Math.PI/180,f=Math.cos(h),m=Math.sin(h);n.angle=Math.atan2(s*f+a*m,i*f+r*m)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(n.angle+=e.rotateOffset),n}const wt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},wn=20;function Mn(e){const t=wt[e??"upperCase"]??e??wt.upperCase,n=Array.from(t);return n.length>0?n:Array.from(wt.upperCase)}function Sn(e,t,n){let i=(e|0)^Math.imul(t+1,2654435761)^Math.imul(n+1,2246822507);return i=Math.imul(i^i>>>16,2146121005),i=Math.imul(i^i>>>15,2221713035),(i^i>>>16)>>>0}function Tn(e,t,n=0){const i=e.from??"",s=e.to,r=Math.max(0,Math.min(1,t));if(r<=0)return i;if(r>=1)return s;const a=Array.from(i),o=Array.from(s),c=e.rightToLeft??!1;if(e.mode==="type"){const v=Math.round(r*Math.max(a.length,o.length));return c?a.slice(0,Math.max(0,a.length-v)).join("")+o.slice(Math.max(0,o.length-v)).join(""):o.slice(0,v).join("")+a.slice(v).join("")}const l=Math.max(0,Math.min(.999,e.revealDelay??0)),u=Math.max(0,(r-l)/(1-l)),h=Math.floor(u*o.length),f=e.tweenLength===!1?o.length:Math.round(a.length+(o.length-a.length)*r),m=Mn(e.chars),p=e.refreshRate??wn,d=p>0?Math.floor(n*p/1e3):0,g=e.seed??1;let b="";for(let v=0;v<f;v++){const k=c?v>=f-h:v<h,M=c?o[o.length-(f-v)]:o[v];k&&M!==void 0||M===" "||M===`
|
|
2
|
+
`?b+=M:b+=m[Sn(g,v,d)%m.length]}return b}class _n{id;name;_captions;_tracks=[];_trackPlayers=new Map;_motionPathTracks=new Map;_springTracks=new Map;_textTracks=new Map;_config;_currentTime=0;_playbackState="idle";_direction="forward";_loopIteration=0;_explicitDuration;_repeatDelayRemaining=0;_wrapAfterDelay=!1;onUpdate=null;onComplete=null;constructor(t){if(this.id=t.id,this.name=t.name,this._captions=t.captions,this._config=t.config??{},this._explicitDuration=t.config?.duration,t.tracks)for(const n of t.tracks)this.addTrack(n)}get tracks(){return[...this._tracks]}get duration(){return this._explicitDuration!==void 0?this._explicitDuration:this._calculateDuration()}setDuration(t){if(this._explicitDuration=t,t!==void 0)this._config={...this._config,duration:t};else if(this._config.duration!==void 0){const n={...this._config};delete n.duration,this._config=n}}get currentTime(){return this._currentTime}get playbackState(){return this._playbackState}get direction(){return this._direction}get loopIteration(){return this._loopIteration}get repeatDelayRemaining(){return this._repeatDelayRemaining}get speed(){return this._config.speed??1}set speed(t){this._config.speed=t}play(){const t=this.duration;this._direction==="forward"&&this._currentTime>=t&&t>0?(this._currentTime=0,this._loopIteration=0):this._direction==="reverse"&&this._currentTime<=0&&t>0&&(this._currentTime=t,this._loopIteration=0),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="idle",this._repeatDelayRemaining=0,this._wrapAfterDelay=!1,this._currentTime=0,this._loopIteration=0,this._direction="forward"}seek(t){const n=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,n)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const n=this.duration;if(n<=0)return;let s=t*this.speed;if(this._repeatDelayRemaining>0){const 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 r=1e3;for(let o=0;o<r&&s>0&&this._playbackState==="playing";o++)if(this._direction==="forward"){const c=n-this._currentTime;if(s>=c){if(s-=c,this._currentTime=n,!this._handleEndReached())break}else this._currentTime+=s,s=0}else{const c=this._currentTime;if(s>=c){if(s-=c,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=s,s=0}const a=this.getStateAtTime(this._currentTime);this.onUpdate?.(a)}getStateAtTime(t){const n=new Map;if(this._hasSharedWrites())this._resolveShared(t,n);else for(const[i,s]of this._trackPlayers){const r=s.getTrack().property;for(const{target:a,value:o,start:c}of s.getTargetValues(t))this._write(n,i,a,r,o,t-c)}return{values:n,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,n){const i=new Map;for(const[s,r]of this._trackPlayers){const a=r.getTrack().property;for(const{target:o,value:c,start:l}of r.getTargetValues(t)){const u=`${o}\0${a}`,h=l<=t,f=i.get(u);(!f||(h!==f.started?h:h?l>=f.start:l<=f.start))&&i.set(u,{trackId:s,target:o,property:a,value:c,start:l,started:h})}}for(const{trackId:s,target:r,property:a,value:o,start:c}of i.values())this._write(n,s,r,a,o,t-c)}_write(t,n,i,s,r,a){if(r===void 0)return;let o=t.get(i);o||(o=new Map,t.set(i,o));const c=this._textTracks.get(n);if(c&&typeof r=="number"){o.set("text",Tn(c.textConfig,r,Math.max(0,a)));return}const l=this._motionPathTracks.get(n);if(l&&typeof r=="number"){const u=xn(l.motionPathConfig,r);o.set("motionPathX",u.x),o.set("motionPathY",u.y),l.motionPathConfig.autoRotate&&o.set("motionPathRotate",u.angle)}else o.set(s,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const n of this._tracks)for(const i of q(n)){const s=`${i}\0${n.property}`;if(t.has(s)){this._sharedWrites=!0;break t}t.add(s)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,ht(t)){this._trackPlayers.set(t.id,new kn(t));return}if(ut(t)){this._trackPlayers.set(t.id,new vn(t)),this._springTracks.set(t.id,t);return}if(At(t))this._trackPlayers.set(t.id,new xt(t)),this._textTracks.set(t.id,t);else if(ye(t)){const n={id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,delay:t.delay,endDelay:t.endDelay,targets:t.targets,stagger:t.stagger};this._trackPlayers.set(t.id,new xt(n)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new xt(t))}replaceTrack(t,n){const i=this._tracks.findIndex(r=>r.id===t);if(i<0)return;const s=this._tracks.slice(i+1);this.removeTrack(t);for(const r of s)this.removeTrack(r.id);this.addTrack(n);for(const r of s)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(n=>n.id!==t),this._sharedWrites=null,this._trackPlayers.delete(t),this._motionPathTracks.delete(t),this._springTracks.delete(t),this._textTracks.delete(t)}getTracks(t={}){return this._tracks.filter(n=>this._matches(n,t))}removeTracks(t={}){const n=this.getTracks(t).map(i=>i.id);for(const i of n)this.removeTrack(i);return n}getTrackSpan(t){const n=this._trackPlayers.get(t);if(!n)return;const i=n.getTrack(),s=i.delay??0;if(ut(i)||ht(i))return{from:s,to:n.getDuration()};const r=i.keyframes;if(!(!r||r.length===0))return{from:r[0].time+s,to:n.getDuration()}}findConflicts(){const t=[];for(let n=0;n<this._tracks.length;n++){const i=this._tracks[n],s=this.getTrackSpan(i.id);if(s)for(let r=0;r<n;r++){const a=this._tracks[r];if(a.property!==i.property)continue;const o=q(a).filter(h=>q(i).includes(h));if(o.length===0)continue;const c=this.getTrackSpan(a.id);if(!c||!(c.from<=s.to&&s.from<=c.to))continue;const u=s.from>=c.from;for(const h of o)t.push({target:h,property:i.property,losingTrackId:u?a.id:i.id,winningTrackId:u?i.id:a.id})}}return t}_matches(t,n){if(n.id!==void 0&&t.id!==n.id||n.property!==void 0&&t.property!==n.property||n.target!==void 0&&!q(t).includes(n.target))return!1;if(n.timeRange){const i=this.getTrackSpan(t.id);if(!i||i.to<n.timeRange.from||i.from>n.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:ge(this._tracks),id:this.id,name:this.name,config:{...this._config},tracks:[...this._tracks],...this.captions&&{captions:this.captions}}}get config(){return this._config}get markers(){return[...this._config.markers??[]].sort((t,n)=>t.time-n.time)}setMarkers(t){const n=t&&t.length>0?[...t].sort((s,r)=>s.time-r.time).map(s=>({...s})):void 0,i={...this._config};n?i.markers=n:delete i.markers,this._config=i}get captions(){return this._captions}setCaptions(t){const n={};for(const[i,s]of Object.entries(t??{}))n[i]={...s};this._captions=Object.keys(n).length>0?n:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,n]of this._trackPlayers)t=Math.max(t,n.getDuration());return t}_handleEndReached(){const t=this._config.loop??0;return t===-1||this._loopIteration<t?(this._loopIteration++,this._armRepeatDelay(),this._config.alternate?this._direction="reverse":this._repeatDelayRemaining>0?this._wrapAfterDelay=!0:this._currentTime=0,this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}_handleStartReached(){const t=this._config.loop??0;return this._config.alternate&&(t===-1||this._loopIteration<t)?(this._loopIteration++,this._armRepeatDelay(),this._direction="forward",this._repeatDelayRemaining===0):(this._playbackState="idle",this.onComplete?.(),!1)}}const An=100;function En(e,t,n,i){const s=[],r=[],{duration:a,alternate:o}=i,c=(m,p,d,g)=>{r.push([m,p]);const b=[];e.forEach((v,k)=>{(d==="forward"?(g?v>=m:v>m)&&v<=p:(g?v<=m:v<m)&&v>=p)&&b.push(k)}),b.sort((v,k)=>(d==="forward"?e[v]-e[k]:e[k]-e[v])||v-k);for(const v of b)s.push({kind:"event",index:v,direction:d})};let l=t.time,u=t.direction,h=t.fresh===!0;const f=Math.min(An,Math.max(0,n.iteration-t.iteration));for(let m=0;m<f;m++){const p=u==="forward"?a:0;c(l,p,u,h),s.push({kind:"repeat"}),o?(u=u==="forward"?"reverse":"forward",l=p,h=!1):(l=u==="forward"?0:a,h=!0)}return f>0&&i.holding&&!o?{crossings:s,passes:r}:(c(l,n.time,u,h),{crossings:s,passes:r})}function Pn(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function K(e){const t=e.endDelay;return{...e.delay!==void 0&&{delay:e.delay},...t!==void 0&&{endDelay:t},...e.targets!==void 0&&{targets:[...e.targets]},...e.stagger!==void 0&&{stagger:{...e.stagger}}}}function Cn(e){if(ht(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:Pn(t.inertia),...K(t)}}if(ut(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...K(t)}}if(At(e)){const t=e;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((n,i)=>n.time-i.time),...K(t)}}if(e.property==="motionPath"&&"motionPathConfig"in e){const t=e,n=[...t.keyframes].sort((i,s)=>i.time-s.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:n,...K(t)}}return bn({id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,...e.interpolation!==void 0&&{interpolation:e.interpolation},...K(e)})}function at(e){const t=e.formatVersion??1;if(t>et)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${et}. Update tinyfly to play it.`);return new _n({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(Cn),captions:e.captions})}function In(e){const[t,n,i,s]=e;return[1-2*(n*n+i*i),2*(t*n+i*s),2*(t*i-n*s),0,2*(t*n-i*s),1-2*(t*t+i*i),2*(n*i+t*s),0,2*(t*i+n*s),2*(n*i-t*s),1-2*(t*t+n*n),0,0,0,0,1]}function Rn(e){return!Array.isArray(e)||e.length!==4?null:`matrix3d(${In(Z(e)).map(n=>Math.round(n*1e6)/1e6+0).join(", ")})`}const $n=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),Ln="#ffffff",Dn="rgba(0, 0, 0, 0.5)";function On(e){const t=[];if(e.blur!==void 0&&t.push(`blur(${Math.max(0,e.blur)}px)`),e.brightness!==void 0&&t.push(`brightness(${Math.max(0,e.brightness)})`),e.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,e.glow)}px ${e.glowColor??Ln})`),e.shadowX!==void 0||e.shadowY!==void 0||e.shadowBlur!==void 0){const n=e.shadowX??0,i=e.shadowY??0,s=Math.max(0,e.shadowBlur??0);t.push(`drop-shadow(${n}px ${i}px ${s}px ${e.shadowColor??Dn})`)}return t.length>0?t.join(" "):null}function Nn(e,t){const n=e.childNodes.length===1?e.firstChild:null;if(n&&n.nodeType===3){const i=n;i.data!==t&&(i.data=t);return}e.textContent!==t&&(e.textContent=t)}function Fn(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const te=new Set(["width","height","top","right","bottom","left","margin","marginTop","marginRight","marginBottom","marginLeft","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","borderRadius","borderWidth","fontSize","lineHeight","letterSpacing","outlineWidth","gap","rowGap","columnGap"]),Xn=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","quaternion","motionPathX","motionPathY","motionPathRotate"]),Yn=["x","motionPathX","y","motionPathY","z","rotate","rotateZ","motionPathRotate","rotateX","rotateY","quaternion","scale","scaleX","scaleY","scaleZ","skewX","skewY"],Vn=new Set(["childPerspective","perspectiveOriginX","perspectiveOriginY"]),qn=new Set(["originX","originY"]),Wn=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Bn=new Set(["drawOn"]),Un={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},ee={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},jn="http://www.w3.org/2000/svg";class Mt{targets=new Map;registerTarget(t,n){this.targets.set(t,n)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[n,i]of t.values){const s=this.targets.get(n);s&&this.applyProperties(s,i)}}applyProperties(t,n){let i=null,s=null,r=null,a=null,o=null;const c=n.has("motionPathX"),l=n.has("motionPathY"),u=n.has("motionPathRotate");for(const[p,d]of n)if(!(p==="x"&&c)&&!(p==="y"&&l)&&!((p==="rotate"||p==="rotateZ")&&u)&&!Bn.has(p)){if(Xn.has(p))(i??={})[p]=d;else if(Vn.has(p))typeof d=="number"&&((s??={})[p]=d);else if(qn.has(p))typeof d=="number"&&((r??={})[p]=d);else if(Wn.has(p))typeof d=="number"&&((a??={})[p]=d);else if($n.has(p))(o??={})[p]=d;else if(p!=="perspective"){if(p!=="shine")if(p==="text"&&typeof d=="string")Nn(t,d);else if(p==="d"&&typeof d=="string"){const g=t;(g.tagName?.toLowerCase()==="path"?g:g.querySelector?.("path"))?.setAttribute?.("d",d)}else this.applyStyleProperty(t,p,d)}}const h=n.get("shine");typeof h=="number"&&this.applyShine(t,h);const f=[],m=n.get("perspective");if(typeof m=="number"&&m>0&&f.push(`perspective(${m}px)`),i)for(const p of Yn){const d=i[p];if(d===void 0)continue;const g=this.buildTransformPart(p,d);g&&f.push(g)}if(f.length>0&&(t.style.transform=f.join(" "),Fn(t)),s&&(s.childPerspective!==void 0&&(t.style.perspective=`${s.childPerspective}px`),(s.perspectiveOriginX!==void 0||s.perspectiveOriginY!==void 0)&&(t.style.perspectiveOrigin=`${s.perspectiveOriginX??50}% ${s.perspectiveOriginY??50}%`)),r){const p=r.originX??50,d=r.originY??50;t.style.transformOrigin=`${p}% ${d}%`}if(a){const p=a.clipTop??0,d=a.clipRight??0,g=a.clipBottom??0,b=a.clipLeft??0;t.style.clipPath=`inset(${p}% ${d}% ${g}% ${b}%)`}if(o){const p=On(o);p&&(t.style.filter=p)}}buildTransformPart(t,n){if(t==="quaternion")return Rn(n);if(typeof n!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${n}px)`;case"y":case"motionPathY":return`translateY(${n}px)`;case"z":return`translateZ(${n}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${n}deg)`;case"rotateX":return`rotateX(${n}deg)`;case"rotateY":return`rotateY(${n}deg)`;case"scale":return`scale(${n})`;case"scaleX":return`scaleX(${n})`;case"scaleY":return`scaleY(${n})`;case"scaleZ":return`scaleZ(${n})`;case"skewX":return`skewX(${n}deg)`;case"skewY":return`skewY(${n}deg)`;default:return null}}applyShine(t,n){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const i=t.dataset.shineBase,s=-20+n*140,r=t.style;r.color="transparent",r.backgroundImage=`linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${i}, ${i})`,r.backgroundSize="250% 100%, 100% 100%",r.backgroundPosition=`${s}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,n,i){let s;if(t.namespaceURI===jn&&n in ee){const o=Array.isArray(i)?i.join(", "):String(i);t.style[ee[n]]=o;return}else n==="fill"&&t.dataset?.elementType==="text"?s="color":s=Un[n]??n;let a;typeof i=="number"?te.has(n)||te.has(s)?a=`${i}px`:a=String(i):Array.isArray(i)?a=i.join(", "):a=i,t.style[s]=a}}class ne{media;offset;driftTolerance;constructor(t,n={}){this.media=t,this.offset=n.offset??0,this.driftTolerance=Math.max(0,n.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,n){const i=this.targetTime(t);n?(this.media.paused&&this.safePlay(),Math.abs(this.media.currentTime-i)>this.driftTolerance&&(this.media.currentTime=i)):(this.media.paused||this.media.pause(),this.media.currentTime!==i&&(this.media.currentTime=i))}seek(t){this.media.currentTime=this.targetTime(t)}setRate(t){this.media.playbackRate=t}dispose(){this.media.paused||this.media.pause()}safePlay(){const t=this.media.play();t&&typeof t.catch=="function"&&t.catch(()=>{})}}function Hn(e,t,n,i,s){const r=n-s;if(r<0){t.paused||t.pause(),t.currentTime=0;return}e.update(r,i)}class ot{container;timeline=null;adapter;animationFrameId;lastTime;options;targets={};isDestroyed=!1;mediaSync;mediaTargets=[];symbolInstances=[];scenarioList=[];scenarioId;authored=new Map;markerList=[];listeners=new Set;playhead={time:0,iteration:0,direction:"forward"};stepping=!1;lastMarkerId=null;reducedQuery;onReducedChange=()=>this.applyReducedMotion();visibilityObserver;onScreen=!0;pausedByVisibility=!1;autoplayWhenSeen=!1;onDocumentVisibility=()=>this.updateVisibility();constructor(t,n={}){if(typeof t=="string"){const i=document.querySelector(t);if(!i)throw new Error(`Container not found: ${t}`);this.container=i}else this.container=t;this.options=n,this.adapter=new Mt}async load(t){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(t)}async loadSource(t){let n;if(typeof t=="string"){const i=await fetch(t);if(!i.ok)throw new Error(`Failed to load animation: ${i.statusText}`);n=await i.json()}else n=t;this.useDefinition(n),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(t){const n={...t.config};this.options.speed!==void 0&&(n.speed=this.options.speed),this.options.loop!==void 0&&(n.loop=this.options.loop),this.options.alternate!==void 0&&(n.alternate=this.options.alternate),this.timeline=at({...t,config:n}),this.markerList=this.timeline.markers,this.lastMarkerId=null,this.options.onComplete&&(this.timeline.onComplete=this.options.onComplete),this.options.onUpdate&&(this.timeline.onUpdate=this.options.onUpdate),this.autoRegisterTargets(),this.setupSymbolInstances(),this.scanMedia()}async loadScenarios(t,n={}){if(t.length===0)throw new Error("tinyfly: loadScenarios needs at least one scenario");const i=new Set;for(const r of t){if(i.has(r.id))throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);i.add(r.id)}const s=n.initial===void 0?t[0]:t.find(r=>r.id===n.initial);if(!s)throw new Error(`tinyfly: there is no scenario "${n.initial}"`);this.scenarioList=[...t],this.scenarioId=s.id,await this.loadSource(s.timeline)}get scenarios(){return this.scenarioList.map(t=>({id:t.id,label:t.label??t.id}))}get scenario(){return this.scenarioId}setScenario(t){const n=this.scenarioList.find(o=>o.id===t);if(!n||!this.timeline)return!1;if(t===this.scenarioId)return!0;const i=this.isPlaying,s=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=t,this.useDefinition(n.timeline),this.lastMarkerId=null;let a=0;return this.reducedMotion||s?a=this.duration:r!==void 0&&(a=this.markers.find(o=>o.id===r)?.time??0),this.seek(a),i&&!this.reducedMotion?(this.stepping=this.options.stepMode===!0,this.startPlaying()):this.notify(),!0}rememberAuthored(t){if(this.authored.has(t))return;const n={style:t.getAttribute("style")};t.children.length===0&&(n.text=t.textContent??"");const i=t.tagName.toLowerCase()==="path"?t:t.querySelector("path");i&&(n.path={element:i,d:i.getAttribute("d")}),this.authored.set(t,n)}restoreAuthored(){for(const[t,n]of this.authored){n.style===null?t.removeAttribute("style"):t.setAttribute("style",n.style),n.text!==void 0&&t.textContent!==n.text&&(t.textContent=n.text),n.path&&(n.path.d===null?n.path.element.removeAttribute("d"):n.path.element.setAttribute("d",n.path.d));const i=t.dataset;i&&delete i.shineBase}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){for(const t of this.listeners)t()}get reducedMotion(){return this.reducedQuery?.matches===!0}get markers(){return this.markerList}get currentMarker(){const t=this.currentTime;let n;for(const i of this.markers)if(i.time<=t+.5)n=i;else break;return n}caption(t,n){const i=t?this.markers.find(a=>a.id===t):this.currentMarker;if(!i)return;const s=n??this.language(),r=a=>a?.[s]?.[i.id]??a?.[s.split("-")[0]]?.[i.id];return r(this.options.captions)??r(this.timeline?.captions)??i.label}next(){if(!this.timeline)return;const t=this.currentTime,n=this.markers.find(i=>i.time>t+.5);if(this.reducedMotion){this.seek(n?n.time:this.duration);return}t>=this.duration-.5||(this.stepping=n!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,n=[...this.markers].reverse().find(i=>i.time<t-.5);this.pause(),this.seek(n?n.time:0)}goToMarker(t){const n=this.markers.find(i=>i.id===t);n&&(this.pause(),this.seek(n.time))}language(){return this.container.closest("[lang]")?.getAttribute("lang")||(typeof document<"u"?document.documentElement.lang:"")||"en"}showInitialFrame(){if(!this.timeline)return;const t=this.options.initialFrame??"start";if(t==="none")return;const n=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,n))),this.applyState()}watchReducedMotion(){this.options.respectReducedMotion===!1||typeof window>"u"||typeof window.matchMedia!="function"||(this.reducedQuery??=window.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedQuery.addEventListener?.("change",this.onReducedChange),this.reducedQuery.matches&&this.applyReducedMotion())}applyReducedMotion(){!this.reducedMotion||!this.timeline||(this.autoplayWhenSeen=!1,this.pause(),this.seek(this.timeline.duration))}watchVisibility(){if(!(!this.options.playWhenVisible||typeof window>"u")){if(typeof IntersectionObserver=="function"){this.visibilityObserver?.disconnect(),this.visibilityObserver=new IntersectionObserver(n=>{for(const i of n)this.onScreen=i.isIntersecting;this.updateVisibility()}),this.visibilityObserver.observe(this.container);const t=this.container.getBoundingClientRect?.();t&&(t.width>0||t.height>0)&&(this.onScreen=t.bottom>0&&t.top<window.innerHeight&&t.right>0&&t.left<window.innerWidth)}document.addEventListener("visibilitychange",this.onDocumentVisibility)}}updateVisibility(){const t=this.onScreen&&document.visibilityState!=="hidden";!t&&this.isPlaying?(this.pausedByVisibility=!0,this.pause()):t&&(this.pausedByVisibility||this.autoplayWhenSeen)&&!this.reducedMotion&&(this.pausedByVisibility=!1,this.autoplayWhenSeen=!1,this.startPlaying())}announceMarker(){if(!this.options.onMarker)return;const t=this.currentMarker,n=t?.id;n!==this.lastMarkerId&&(this.lastMarkerId=n,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(n=>{const i=n,s=Number(i.getAttribute("data-tinyfly-start")??"0")||0,r=i.getAttribute("data-volume");r!==null&&(i.volume=Math.max(0,Math.min(1,Number(r)||0))),this.mediaTargets.push({el:i,startTime:s,sync:new ne(i)})})}syncAllMedia(t,n){for(const i of this.mediaTargets)Hn(i.sync,i.el,t,n,i.startTime)}loadFromString(t){const n=JSON.parse(t);this.load(n)}registerTarget(t,n){if(typeof n=="string"){const i=this.container.querySelector(n);i&&(this.rememberAuthored(i),this.targets[t]=i,this.adapter.registerTarget(t,i))}else this.rememberAuthored(n),this.targets[t]=n,this.adapter.registerTarget(t,n)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(n=>{const i=n.closest("[data-tinyfly-symbol]");if(i&&i!==n)return;const s=n.getAttribute("data-tinyfly");s&&this.registerTarget(s,n)}),this.timeline&&new Set(this.timeline.tracks.map(i=>i.target)).forEach(i=>{if(!this.targets[i]){const s=this.container.querySelector(`[data-tinyfly="${i}"]`)||this.container.querySelector(`.${i}`)||this.container.querySelector(`#${i}`);s&&this.registerTarget(i,s)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const n=new Map(t.map(i=>[i.id,i]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(i=>{const s=i.getAttribute("data-tinyfly-symbol");if(!s)return;const r=n.get(s);if(!r||!r.timeline.tracks?.length)return;const a=new Mt;i.querySelectorAll("[data-tinyfly]").forEach(o=>{const c=o.getAttribute("data-tinyfly");c&&a.registerTarget(c,o)}),this.symbolInstances.push({adapter:a,timeline:at(r.timeline)})})}attachMedia(t,n){this.mediaSync=new ne(t,n),this.timeline&&(this.mediaSync.setRate(this.timeline.speed),this.mediaSync.update(this.timeline.currentTime,this.isPlaying))}detachMedia(){this.mediaSync?.dispose(),this.mediaSync=void 0}play(){!this.timeline||this.isDestroyed||(this.autoplayWhenSeen=!1,this.stepping=this.options.stepMode===!0,this.startPlaying())}startPlaying(){if(!this.timeline||this.isDestroyed)return;const t=this.timeline.playbackState==="idle";this.timeline.play(),t&&this.timeline.currentTime===0&&this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.update(this.timeline.currentTime,!0),this.syncAllMedia(this.timeline.currentTime,!0),this.startAnimationLoop(),this.notify()}pause(){this.timeline&&(this.stepping=!1,this.timeline.pause(),this.notify(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1),this.stopAnimationLoop())}stop(){this.timeline&&(this.timeline.stop(),this.stopAnimationLoop(),this.applyState(),this.mediaSync?.update(this.timeline.currentTime,!1),this.syncAllMedia(this.timeline.currentTime,!1))}seek(t){this.timeline&&(this.timeline.seek(t),this.applyState(),this.playhead={time:this.timeline.currentTime,iteration:this.timeline.loopIteration,direction:this.timeline.direction},this.mediaSync?.seek(this.timeline.currentTime),this.syncAllMedia(this.timeline.currentTime,this.isPlaying))}setSpeed(t){this.timeline&&(this.timeline.speed=t,this.mediaSync?.setRate(t))}reverse(){this.timeline&&this.timeline.reverse()}get currentTime(){return this.timeline?.currentTime??0}get duration(){return this.timeline?.duration??0}get isPlaying(){return this.timeline?.playbackState==="playing"}destroy(){this.isDestroyed=!0,this.stopAnimationLoop(),this.reducedQuery?.removeEventListener?.("change",this.onReducedChange),this.visibilityObserver?.disconnect(),typeof document<"u"&&document.removeEventListener("visibilitychange",this.onDocumentVisibility),this.mediaSync?.dispose(),this.mediaSync=void 0;for(const t of this.mediaTargets)t.el.paused||t.el.pause();this.mediaTargets=[],this.adapter.clearTargets();for(const t of this.symbolInstances)t.adapter.clearTargets();this.symbolInstances=[],this.authored.clear(),this.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=n=>{if(this.isDestroyed||!this.timeline)return;const i=n-(this.lastTime??n);this.lastTime=n;const s=this.playhead;this.timeline.tick(i),this.stopAtMarker(s),this.applyState();const r=this.timeline.playbackState==="playing";this.mediaSync?.update(this.timeline.currentTime,r),this.syncAllMedia(this.timeline.currentTime,r),this.timeline.playbackState==="playing"?this.animationFrameId=requestAnimationFrame(t):(this.animationFrameId=void 0,this.notify())};this.animationFrameId=requestAnimationFrame(t)}stopAtMarker(t){const n=this.timeline,i={time:n.currentTime,iteration:n.loopIteration,direction:n.direction};this.playhead=i;const s=this.markers;if(s.length===0)return;const{crossings:r}=En(s.map(a=>a.time),t,i,{duration:n.duration,alternate:n.config.alternate===!0,holding:n.repeatDelayRemaining>0});for(const a of r){if(a.kind!=="event")continue;const o=s[a.index];if(this.stepping||o.pause){this.stepping=!1,n.pause(),n.seek(o.time),this.playhead={time:o.time,iteration:n.loopIteration,direction:n.direction};return}}}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}applyState(){if(!this.timeline)return;const t=this.timeline.currentTime;this.adapter.applyState(this.timeline.getStateAtTime(t)),this.announceMarker(),this.notify();for(const n of this.symbolInstances){const i=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(i>0?t%i:t))}}}async function zn(e,t,n={}){const i=new ot(e,{...n,autoplay:!0});return await i.load(t),i}function Qn(e,t={}){return new ot(e,t)}const ie={play:"Play",pause:"Pause",prev:"Previous step",next:"Next step",restart:"Restart",scrub:"Position",speed:"Speed",reveal:"Reveal",step:"Step",of:"of",stepFormat:"{index} / {total}",scenario:"Scenario",fullscreen:"Full screen",exitFullscreen:"Exit full screen"},se="tinyfly-controls-style",Gn=`
|
|
3
3
|
.tf-ctl { --tf-ctl-fg: #1d1d1f; --tf-ctl-bg: #f4f2ee; --tf-ctl-accent: #c2410c; --tf-ctl-radius: 8px;
|
|
4
4
|
font: 14px/1.4 var(--tf-ctl-font, system-ui, sans-serif); color: var(--tf-ctl-fg); margin-top: 8px; }
|
|
5
5
|
.tf-ctl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; border-radius: var(--tf-ctl-radius); background: var(--tf-ctl-bg); }
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
.tf-fullscreen > svg, .tf-fullscreen > canvas { grid-column: 1; grid-row: 1 / span 12; height: calc(100vh - 24px) !important; height: calc(100dvh - 24px) !important; }
|
|
48
48
|
.tf-fullscreen > :not(svg):not(canvas) { grid-column: 2; }
|
|
49
49
|
}
|
|
50
|
-
`;let
|
|
50
|
+
`;let Zn=0;function Kn(e){if(e.getElementById(se))return;const t=e.createElement("style");t.id=se,t.textContent=Gn,e.head.appendChild(t)}function re(e,t,n={}){const i=t.ownerDocument;Kn(i);const s={...ie,...n.labels},r=n.speeds??[.5,1,2],a=()=>e.markers.length>0,o=()=>e.markers.some(w=>w.label!==void 0||e.caption(w.id)!==void 0),c=i.createElement("div");c.className="tf-ctl";const l=i.createElement("div");l.className="tf-ctl-bar",l.setAttribute("role","group");const u=(w,E,F,N="")=>{const L=i.createElement("button");return L.type="button",L.className=`tf-ctl-btn ${N}`.trim(),L.setAttribute("aria-label",w),L.title=w,L.textContent=E,L.addEventListener("click",F),L},h=u(s.restart,"⟲",()=>{e.pause(),e.seek(0)}),f=u(s.prev,"|◀",()=>e.prev()),m=u(s.play,"▶",()=>e.isPlaying?e.pause():d(),"tf-ctl-primary"),p=u(s.next,"▶|",()=>e.next()),d=()=>{e.currentTime>=e.duration-.5&&e.seek(0),e.play()},g=i.createElement("input");g.type="range",g.className="tf-ctl-scrub",g.min="0",g.max="1000",g.step="1",g.setAttribute("aria-label",s.scrub),g.addEventListener("input",()=>{e.pause(),e.seek(Number(g.value)/1e3*e.duration)});const b=i.createElement("span");b.className="tf-ctl-step";const v=i.createElement("select");v.className="tf-ctl-speed",v.setAttribute("aria-label",s.speed);for(const w of r){const E=i.createElement("option");E.value=String(w),E.textContent=`${w}×`,w===1&&(E.selected=!0),v.appendChild(E)}v.addEventListener("change",()=>e.setSpeed(Number(v.value))),l.append(h,f,m,p,g,b),r.length>0&&l.append(v),c.append(l);const k=n.fullscreen?ni(t,i,s):void 0;k&&l.append(k.button);const M=i.createElement("p");M.className="tf-ctl-caption",M.setAttribute("aria-live","polite"),n.captions!==!1&&c.append(M);const y=i.createElement("div");y.className="tf-ctl-question",y.hidden=!0;const S=i.createElement("span"),x=u(s.reveal,s.reveal,()=>e.play(),"tf-ctl-primary");y.append(S,x),c.append(y);const P=Jn(e,i,s.scenario,n.scenarioControl??"buttons");P&&c.append(P.element);const W=n.mount;W?W.appendChild(c):t.insertAdjacentElement("afterend",c);const T=()=>{const w=e.isPlaying;m.textContent=w?"❚❚":"▶",m.setAttribute("aria-label",w?s.pause:s.play),m.title=w?s.pause:s.play;const E=e.duration;i.activeElement!==g&&(g.value=String(E>0?Math.round(e.currentTime/E*1e3):0));const F=e.markers;if(f.hidden=p.hidden=b.hidden=F.length===0,F.length>0){const N=e.currentMarker,L=N?F.indexOf(N)+1:0;b.textContent=s.stepFormat.replace("{index}",String(L)).replace("{total}",String(F.length)),b.setAttribute("aria-label",`${s.step} ${L} ${s.of} ${F.length}`),f.disabled=e.currentTime<=.5,p.disabled=e.currentTime>=E-.5;const A=e.caption()??"";M.textContent!==A&&(M.textContent=A),M.hidden=!o();const I=!w&&N?.question!==void 0&&Math.abs(e.currentTime-N.time)<1;y.hidden=!I,I&&S.textContent!==N.question&&(S.textContent=N.question)}else y.hidden=!0,M.hidden=!0;P?.update()},R=e.subscribe(T);T();const _=n.keyboardScope??t;!_.hasAttribute("tabindex")&&_.tabIndex<0&&(_.tabIndex=0);const C=new WeakSet,O=w=>{if(C.has(w)||(C.add(w),w.defaultPrevented||w.altKey||w.ctrlKey||w.metaKey))return;const E=w.target;if(!(E.tagName==="INPUT"||E.tagName==="SELECT")&&!(w.key===" "&&E.tagName==="BUTTON"))switch(w.key){case" ":w.preventDefault(),e.isPlaying?e.pause():d();break;case"ArrowRight":if(!a())return;w.preventDefault(),e.next();break;case"ArrowLeft":if(!a())return;w.preventDefault(),e.prev();break;case"Home":w.preventDefault(),e.pause(),e.seek(0);break;case"f":case"F":if(!k)return;w.preventDefault(),k.active?k.exit():k.enter();break}};return _.addEventListener("keydown",O),c.addEventListener("keydown",O),{element:c,fullscreen:k&&{get active(){return k.active},enter:k.enter,exit:k.exit},destroy(){k?.destroy(),R(),_.removeEventListener("keydown",O),c.removeEventListener("keydown",O),c.remove()}}}function Jn(e,t,n,i){const s=e.scenarios;if(s.length<2)return;if(i==="slider"){const u=t.createElement("div");u.className="tf-ctl-choice-slider";const h=t.createElement("span");h.textContent=n,h.setAttribute("aria-hidden","true");const f=t.createElement("input");f.type="range",f.min="0",f.max=String(s.length-1),f.step="1",f.setAttribute("aria-label",n);const m=t.createElement("output");return m.setAttribute("aria-hidden","true"),f.addEventListener("input",()=>{const d=s[Number(f.value)];d&&e.setScenario(d.id)}),u.append(h,f,m),{element:u,update:()=>{const d=Math.max(0,s.findIndex(b=>b.id===e.scenario));t.activeElement!==f&&(f.value=String(d));const g=s[d].label;m.textContent!==g&&(m.textContent=g),f.setAttribute("aria-valuetext",g)}}}const r=t.createElement("fieldset");r.className="tf-ctl-choices";const a=t.createElement("legend");a.textContent=n,r.append(a);const o=`tf-ctl-scenario-${++Zn}`,c=s.map(u=>{const h=t.createElement("label");h.className="tf-ctl-choice";const f=t.createElement("input");f.type="radio",f.name=o,f.value=u.id,f.addEventListener("change",()=>{f.checked&&e.setScenario(u.id)});const m=t.createElement("span");return m.textContent=u.label,h.append(f,m),r.append(h),f});return{element:r,update:()=>{for(const u of c){const h=u.value===e.scenario;u.checked!==h&&(u.checked=h)}}}}const ti='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',ei='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';function ni(e,t,n){const i=t,s=e,r=t.createElement("button");r.type="button",r.className="tf-ctl-btn tf-ctl-fullscreen";let a,o="";const c=()=>{const d=a!==void 0;r.innerHTML=d?ei:ti;const g=d?n.exitFullscreen:n.fullscreen;r.setAttribute("aria-label",g),r.title=g,r.setAttribute("aria-pressed",String(d)),e.classList.toggle("tf-fullscreen",d),e.classList.toggle("tf-fullscreen-overlay",a==="overlay")},l=()=>i.fullscreenElement??i.webkitFullscreenElement??null,u=()=>{l()===e?a="native":a==="native"&&(a=void 0),c()},h=d=>{d.key==="Escape"&&p()},f=()=>{a="overlay",o=t.documentElement.style.overflow,t.documentElement.style.overflow="hidden",t.addEventListener("keydown",h),c()};async function m(){if(a)return;const d=s.requestFullscreen?.bind(s)??s.webkitRequestFullscreen?.bind(s),g=i.fullscreenEnabled??i.webkitFullscreenEnabled??!1;if(d&&g)try{if(await d(),l()===e){a="native",c();return}}catch{}f()}async function p(){if(a==="overlay")t.removeEventListener("keydown",h),t.documentElement.style.overflow=o,a=void 0,c();else if(a==="native"){a=void 0,c();const d=i.exitFullscreen?.bind(i)??i.webkitExitFullscreen?.bind(i);l()===e&&d&&await d()}}return r.addEventListener("click",()=>{a?p():m()}),t.addEventListener("fullscreenchange",u),t.addEventListener("webkitfullscreenchange",u),c(),{button:r,get active(){return a!==void 0},enter:m,exit:p,destroy(){p(),t.removeEventListener("fullscreenchange",u),t.removeEventListener("webkitfullscreenchange",u),r.remove()}}}const ae="tinyfly-choices-style",ii=`
|
|
51
51
|
[data-tinyfly-choose] { cursor: pointer; }
|
|
52
52
|
[data-tinyfly-choose]:focus-visible { outline: 2px solid var(--tf-ctl-accent, #c2410c); outline-offset: 2px; }
|
|
53
|
-
`;function
|
|
53
|
+
`;function si(e){if(e.getElementById(ae))return;const t=e.createElement("style");t.id=ae,t.textContent=ii,e.head.appendChild(t)}function oe(e,t){const n=Array.from(t.querySelectorAll("[data-tinyfly-choose]"));if(n.length===0)return()=>{};si(t.ownerDocument);const i=[],s=[];for(const o of n){const c=o.getAttribute("data-tinyfly-choose")??"",l=[],u=(p,d)=>{o.hasAttribute(p)||(o.setAttribute(p,d),l.push(p))};u("role","button"),u("tabindex","0");const h=e.scenarios.find(p=>p.id===c)?.label;h!==void 0&&u("aria-label",h),o.setAttribute("aria-pressed","false"),l.push("aria-pressed"),i.push({element:o,attributes:l});const f=()=>e.setScenario(c),m=p=>{const d=p.key;d!=="Enter"&&d!==" "||(p.preventDefault(),f())};o.addEventListener("click",f),o.addEventListener("keydown",m),s.push(()=>{o.removeEventListener("click",f),o.removeEventListener("keydown",m)})}const r=()=>{for(const{element:o}of i)o.setAttribute("aria-pressed",String(o.getAttribute("data-tinyfly-choose")===e.scenario))},a=e.subscribe(r);return r(),()=>{a();for(const o of s)o();for(const{element:o,attributes:c}of i)for(const l of c)o.removeAttribute(l)}}const ct=new WeakMap,St=new WeakMap;let ri=0;function J(e,t,n){if(e)try{return JSON.parse(e)}catch(i){console.warn(`tinyfly: invalid ${t} JSON on`,n,i);return}}async function ce(e,t={}){const n=ct.get(e);if(n)return n;const i=Array.from(e.querySelectorAll("script[data-tinyfly-timeline]")),s=i[0],r=e.getAttribute("data-src"),a=oi(e.getAttribute("data-markers")),o=i.length>1||s?.hasAttribute("data-scenario")?ai(i,a,e):void 0;if(o&&o.length===0)return;let c=s&&!o?J(s.textContent,"timeline",e):void 0;if(!c&&r&&a){const m=await fetch(r);m.ok&&(c=await m.json())}if(c&&a&&(c=le(c,a)),!c&&!r&&!o){console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)',e);return}const l=J(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),u={playWhenVisible:!0,...t.player,...l&&{captions:l},...J(e.getAttribute("data-options"),"data-options",e)};li(e);const h=new ot(e,u),f={element:e,player:h};if(ct.set(e,f),e.setAttribute("data-tinyfly-mounted",""),o){const m=e.getAttribute("data-scenario")??void 0;await h.loadScenarios(o,{initial:o.some(p=>p.id===m)?m:void 0}),St.set(e,oe(h,e))}else await h.load(c??r);if(e.getAttribute("data-controls")!=="false"){const m=J(e.getAttribute("data-labels"),"data-labels",e),p=e.querySelector("figcaption"),d=e.getAttribute("data-scenario-legend"),g=e.getAttribute("data-scenario-control");f.controls=re(h,e,{...t.controls,...e.getAttribute("data-fullscreen")==="true"?{fullscreen:!0}:{},...g==="slider"||g==="buttons"?{scenarioControl:g}:{},labels:{...t.controls?.labels,...m,...d?{scenario:d}:{}},mount:void 0}),p?e.insertBefore(f.controls.element,p):e.appendChild(f.controls.element)}return f}function ai(e,t,n){const i=[];return e.forEach((s,r)=>{const a=J(s.textContent,"timeline",n);if(!a)return;const o=s.getAttribute("data-scenario")||`scenario-${r+1}`;if(i.some(l=>l.id===o)){console.warn(`tinyfly: scenario id "${o}" is used more than once; the later one is skipped`,n);return}const c=s.getAttribute("data-scenario-label")??void 0;i.push({id:o,label:c,timeline:t?le(a,t):a})}),i}function le(e,t){return e.config.markers?.length?e:{...e,config:{...e.config,markers:t.map((n,i)=>({id:`step-${i+1}`,time:n}))}}}function oi(e){if(!e)return;const t=e.split(/[\s,]+/).filter(Boolean).map(Number).filter(n=>Number.isFinite(n)&&n>=0).sort((n,i)=>n-i);return t.length>0?t:void 0}async function he(e=document,t={}){const n=Array.from(e.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(n.map(s=>ce(s,t)))).filter(s=>s!==void 0)}function ci(e){const t=ct.get(e);t&&(St.get(e)?.(),St.delete(e),t.controls?.destroy(),t.player.destroy(),ct.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function li(e){const t=e.querySelector("svg");if(!t||t.hasAttribute("role")||t.hasAttribute("aria-hidden"))return;const n=e.getAttribute("data-alt"),i=e.querySelector("figcaption");t.setAttribute("role","img"),n?t.setAttribute("aria-label",n):i&&(i.id||=`tinyfly-caption-${++ri}`,t.setAttribute("aria-labelledby",i.id))}function hi(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const t=()=>{he()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}function Tt(e){const t=new Set;for(const n of e.matchAll(/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/g))t.add(n[2]??n[3]);return[...t]}function ue(e,t={}){const n=[],i=l=>n.push({level:"error",message:l}),s=l=>n.push({level:"warning",message:l});if((e.formatVersion??1)>et)return i(`format version ${e.formatVersion} is newer than this tinyfly reads (${et})`),n;let r=0;try{r=at(e).duration}catch(l){return i(`the timeline does not load: ${l instanceof Error?l.message:String(l)}`),n}const a=e.config?.duration;if(a!==void 0)for(const l of e.tracks){if(!("keyframes"in l))continue;const u=l.keyframes.filter(h=>h.time>a);u.length>0&&i(`track "${l.id}" has a keyframe at ${u[0].time}ms, after the ${a}ms duration`)}const o=e.config?.markers??[],c=new Set;o.forEach((l,u)=>{c.has(l.id)&&i(`marker id "${l.id}" is used more than once`),c.add(l.id),(l.time<0||l.time>r)&&i(`marker "${l.id}" at ${l.time}ms is outside the animation (0–${r}ms)`),u>0&&l.time<o[u-1].time&&i(`marker "${l.id}" comes before "${o[u-1].id}" in time; list markers in order`)});for(const[l,u]of Object.entries(e.captions??{})){for(const h of Object.keys(u))c.has(h)||i(`caption "${h}" (${l}) has no marker with that id`);for(const h of c)h in u||s(`marker "${h}" has no ${l} caption; its label is shown instead`)}if(t.markup!==void 0){const l=new Set(Tt(t.markup)),u=new Set;for(const h of e.tracks)for(const f of[h.target,...h.targets??[]])u.add(f),l.has(f)||i(`track "${h.id}" targets "${f}", but no element has data-tinyfly="${f}"`);for(const h of l)u.has(h)||s(`data-tinyfly="${h}" is never animated`)}return n}function ui(e){const t=new Set;for(const n of e.matchAll(/data-tinyfly-choose\s*=\s*("([^"]*)"|'([^']*)')/g))t.add(n[2]??n[3]);return[...t]}function di(e,t={}){const n=[];e.length===1&&n.push({level:"warning",message:"only one scenario, so the reader has nothing to choose"});const i=new Set,s=new Set;for(const r of e){if(i.has(r.id)){n.push({level:"error",message:`scenario id "${r.id}" is used more than once`});continue}i.add(r.id);for(const a of ue(r.timeline,t))/is never animated$/.test(a.message)||n.push({level:a.level,message:`scenario "${r.id}": ${a.message}`});for(const a of r.timeline.tracks)for(const o of[a.target,...a.targets??[]])s.add(o)}if(t.markup!==void 0){for(const r of ui(t.markup))i.has(r)||n.push({level:"error",message:`data-tinyfly-choose="${r}" names no scenario`});for(const r of Tt(t.markup))s.has(r)||n.push({level:"warning",message:`data-tinyfly="${r}" is never animated in any scenario`})}return n}function fi(e,t,n="end"){const i=at(t),s=t.config?.markers??[],r=n==="start"?0:n==="end"?i.duration:typeof n=="number"?n:s.find(f=>f.id===n)?.time??i.duration,a=i.getStateAtTime(Math.max(0,Math.min(i.duration,r))),o=new Mt,c=new Map,l=mi(e);for(const f of e.matchAll(de)){const m=/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(f[2]??"");if(!m)continue;const p=m[2]??m[3];if(c.has(p))continue;const d=pi(l(f.index??0));c.set(p,d),o.registerTarget(p,d)}o.applyState(a);let u="",h=0;for(const f of e.matchAll(de)){const[m,p,d="",g]=f,b=f.index??0,v=/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(d),k=v?c.get(v[2]??v[3]):void 0;if(!k||Object.keys(k.style).length===0&&k.text===void 0)continue;u+=e.slice(h,b);const M=Object.entries(k.style).map(([x,P])=>`${gi(x)}: ${P}`).join("; "),y=/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/.exec(d);let S=d;if(M)if(y){const x=`${(y[2]??y[3]).trim().replace(/;?$/,";")} ${M}`.trim();S=d.replace(y[0],` style="${fe(x)}"`)}else S=`${d} style="${fe(M)}"`;if(u+=`<${p}${S}${g?" /":""}>`,h=b+m.length,k.text!==void 0&&!g){const x=e.indexOf(`</${p}`,h),P=x===-1?"":e.slice(h,x);x!==-1&&!P.includes("<")&&(u+=yi(k.text),h=x)}}return u+e.slice(h)}const de=/<([a-zA-Z][\w:-]*)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*)\s*(\/?)>/g;function pi(e){const t={style:{},dataset:{},namespaceURI:e?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",childNodes:[],get textContent(){return t.text??""},set textContent(n){t.text=n}};return e&&(t.ownerSVGElement=null),t}function mi(e){const t=[],n=/<svg[\s>]/gi;let i;for(;i=n.exec(e);){const s=e.toLowerCase().indexOf("</svg>",i.index);t.push([i.index+1,s===-1?e.length:s])}return s=>t.some(([r,a])=>s>r&&s<a)}function gi(e){const t=e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);return/^(webkit|moz|ms)-/.test(t)?`-${t}`:t}function fe(e){return e.replace(/&/g,"&").replace(/"/g,""")}function yi(e){return e.replace(/&/g,"&").replace(/</g,"<")}hi(),$.DEFAULT_LABELS=ie,$.TinyflyPlayer=ot,$.bindChoiceHotspots=oe,$.create=Qn,$.createControls=re,$.mount=ce,$.mountAll=he,$.play=zn,$.renderFrame=fi,$.targetNamesIn=Tt,$.unmount=ci,$.validateEmbed=ue,$.validateScenarios=di,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});
|