@algorisys/tinyfly 0.74.1 → 0.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -7
- package/lib/addons/adapters.js +236 -121
- package/lib/addons/characters.js +501 -141
- package/lib/addons/{dom-adapter-ChrbtkLC.js → dom-adapter-CrNwoomd.js} +52 -52
- package/lib/addons/gsap-compat.js +1 -1
- package/lib/addons/sketch-CB6VNfnR.js +128 -0
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +3526 -3047
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/cli/tools.js +2 -0
- package/lib/embed/tinyfly-embed.iife.js +4 -4
- package/lib/embed/tinyfly-embed.js +70 -70
- package/lib/headless/headless.js +302 -2
- package/lib/player/tinyfly-player.es.js +73 -73
- 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 +18 -0
- package/lib/types/adapters/canvas/index.d.ts +3 -0
- package/lib/types/adapters/canvas/outline.d.ts +26 -0
- package/lib/types/adapters/canvas/polyline.d.ts +12 -0
- package/lib/types/adapters/canvas/sketch.d.ts +54 -0
- package/lib/types/characters/erase.d.ts +31 -0
- package/lib/types/characters/hand.d.ts +81 -0
- package/lib/types/characters/index.d.ts +7 -1
- package/lib/types/characters/polyline.d.ts +12 -0
- package/lib/types/characters/sketch.d.ts +54 -0
- package/lib/types/characters/stick-figure.d.ts +214 -5
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(R){"use strict";function te(i){return typeof i=="object"&&i!==null&&i.type==="cubic-bezier"}function ee(i){return typeof i=="object"&&i!==null&&i.type!=="cubic-bezier"}const it=1;function At(i){return i.property==="text"&&"textConfig"in i}function st(i){return i.kind==="inertia"&&"inertia"in i}function nt(i){return i.kind==="spring"&&"spring"in i}function ie(i){return i.property==="motionPath"&&"motionPathConfig"in i}function St(i,t,e="start"){if(t<=1)return 0;if(typeof e=="number"){const s=Math.max(0,Math.min(t-1,e));return Math.abs(i-s)}switch(e){case"end":return t-1-i;case"center":return Math.abs(i-(t-1)/2);case"edges":return(t-1)/2-Math.abs(i-(t-1)/2);default:return i}}function se(i,t="start"){if(i<=1)return 0;let e=0;for(let s=0;s<i;s++)e=Math.max(e,St(s,i,t));return e}function Mt(i,t,e){if(e.offsets)return e.offsets[i]??0;const s=e.from??"start",n=St(i,t,s);if(e.amount!==void 0){const r=se(t,s);return r===0?0:e.amount*n/r}return e.each!==void 0?e.each*n:0}function ne(i,t){return Array.from({length:i},(e,s)=>Mt(s,i,t))}function rt(i,t){return i<=1?0:Math.max(...ne(i,t))}const Y=1,_t=6e4,Q=_t/Y,F={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1};class re{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??F.stiffness,this.damping=t.damping??F.damping,this.mass=t.mass??F.mass,this.restDelta=t.restDelta??F.restDelta,this.restSpeed=t.restSpeed??F.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??F.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 e=Math.floor(t/Y);if(this.simulateTo(e+1),this.settledStep!==null&&e>=this.settledStep)return this.to;const s=this.samples[Math.min(e,this.samples.length-1)],n=this.samples[Math.min(e+1,this.samples.length-1)],r=t/Y-e;return s+(n-s)*r}settleTime(){return this.simulateTo(Q+1),this.settledStep!==null?this.settledStep*Y:_t}simulateTo(t){if(this.settledStep!==null)return;const e=Math.min(t,Q+1),s=Y/1e3;for(;this.samples.length<e;){const n=this.samples[this.samples.length-1],r=n-this.to,a=-this.stiffness*r,o=-this.damping*this.velocity,c=(a+o)/this.mass;this.velocity+=c*s;const h=n+this.velocity*s;if(this.samples.push(h),this.isAtRest(h)){this.settledStep=this.samples.length-1;return}}this.samples.length>Q&&(this.settledStep=Q)}}const kt=4,ae=.002,oe=1e-4,ce=6e4;function at(i){const t=i.friction??kt;return t>0?t:kt}function he(i){return i.from+i.velocity/at(i)}function le(i,t){if(t===void 0)return i;if(typeof t=="number")return t>0?Math.round(i/t)*t:i;if(t.length===0)return i;let e=t[0];for(const s of t)Math.abs(s-i)<Math.abs(e-i)&&(e=s);return e}function wt(i){let t=le(he(i),i.end);return i.min!==void 0&&(t=Math.max(i.min,t)),i.max!==void 0&&(t=Math.min(i.max,t)),t}function Pt(i){const t=Math.abs(wt(i)-i.from);if(t===0)return 0;const e=i.restDelta??Math.max(oe,t*ae);if(e>=t)return 0;const s=Math.log(t/e)/at(i);return Math.min(ce,s*1e3)}function vt(i,t){if(t<=0)return i.from;const e=wt(i);if(t>=Pt(i))return e;const s=at(i);return i.from+(e-i.from)*(1-Math.exp(-s*t/1e3))}const ot=i=>i,ue=i=>i*i,de=i=>1-(1-i)*(1-i),fe=i=>i<.5?2*i*i:1-Math.pow(-2*i+2,2)/2,It=i=>i*i*i,Ct=i=>1-Math.pow(1-i,3),xt=i=>i<.5?4*i*i*i:1-Math.pow(-2*i+2,3)/2,pe={linear:ot,"ease-in":It,"ease-out":Ct,"ease-in-out":xt,"ease-in-quad":ue,"ease-out-quad":de,"ease-in-out-quad":fe,"ease-in-cubic":It,"ease-out-cubic":Ct,"ease-in-out-cubic":xt};function me(i){const[t,e,s,n]=i,r=3*t,a=3*(s-t)-r,o=1-r-a,c=3*e,h=3*(n-e)-c,u=1-c-h,l=p=>((o*p+a)*p+r)*p,d=p=>((u*p+h)*p+c)*p,f=p=>(3*o*p+2*a)*p+r,b=p=>{let y=p;for(let A=0;A<8;A++){const M=l(y)-p;if(Math.abs(M)<1e-7)return y;const m=f(y);if(Math.abs(m)<1e-7)break;y-=M/m}let g=0,T=1;for(y=p;g<T;){const A=l(y);if(Math.abs(A-p)<1e-7)return y;p>A?g=y:T=y,y=(g+T)/2}return y};return p=>{if(p<=0)return 0;if(p>=1)return 1;const y=b(p);return d(y)}}function ct(i,t="out"){if(t==="out")return i;const e=s=>1-i(1-s);return t==="in"?e:s=>s<.5?e(s*2)/2:i(s*2-1)/2+.5}function ye(i=1,t=.3){const e=Math.max(1,i),s=t/(2*Math.PI)*Math.asin(1/e);return n=>n<=0?0:n>=1?1:e*Math.pow(2,-10*n)*Math.sin((n-s)*(2*Math.PI)/t)+1}const ge=i=>{if(i<=0)return 0;if(i>=1)return 1;if(i<1/2.75)return 7.5625*i*i;if(i<2/2.75){const n=i-.5454545454545454;return 7.5625*n*n+.75}if(i<2.5/2.75){const n=i-.8181818181818182;return 7.5625*n*n+.9375}const s=i-2.625/2.75;return 7.5625*s*s+.984375};function Te(i=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const e=t-1;return e*e*((i+1)*e+i)+1}}function be(i,t="end"){const e=Math.max(1,Math.floor(i));return s=>{if(s>=1)return 1;if(s<=0)return t==="start"||t==="both"?t==="start"?1/e:1/(e+1):0;const n=Math.floor(s*e);switch(t){case"start":return Math.min(1,(n+1)/e);case"both":return(n+1)/(e+1);case"none":return e===1?0:Math.min(1,n/(e-1));default:return n/e}}}function Ae(i){switch(i.type){case"steps":return be(i.count,i.position);case"elastic":return ct(ye(i.amplitude,i.period),i.mode);case"bounce":return ct(ge,i.mode);case"back":return ct(Te(i.overshoot),i.mode)}}function Se(i){return i===void 0?ot:te(i)?me(i.points):ee(i)?Ae(i):pe[i]??ot}const Rt=32,Me=256,N=new Map,_e=/[MmLlHhVvCcSsQqTtAaZz]/,ke=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,we={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Pe(i){const t=[];let e=0,s=null;const n=()=>{for(;e<i.length&&/[\s,]/.test(i[e]);)e++};for(;e<i.length&&(n(),!(e>=i.length));){const r=i[e];if(_e.test(r)){s={type:r,args:[]},t.push(s),e++;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),e++;continue}const c=ke.exec(i.slice(e));if(!c)break;s.args.push(parseFloat(c[0])),e+=c[0].length}return t}function ve(i,t,e,s,n,r,a,o,c){if(i===o&&t===c)return[];let h=Math.abs(e),u=Math.abs(s);if(h===0||u===0)return[[i,t,o,c,o,c]];const l=n*Math.PI/180,d=Math.cos(l),f=Math.sin(l),b=(i-o)/2,p=(t-c)/2,y=d*b+f*p,g=-f*b+d*p,T=y*y/(h*h)+g*g/(u*u);if(T>1){const w=Math.sqrt(T);h*=w,u*=w}const A=r===a?-1:1,M=h*h*u*u-h*h*g*g-u*u*y*y,m=h*h*g*g+u*u*y*y,_=A*Math.sqrt(Math.max(0,M/m)),S=_*h*g/u,B=-_*u*y/h,J=d*S-f*B+(i+o)/2,k=f*S+d*B+(t+c)/2,C=(w,I,x,q)=>{const bt=w*x+I*q,et=Math.sqrt((w*w+I*I)*(x*x+q*q)),j=Math.acos(Math.max(-1,Math.min(1,bt/et)));return w*q-I*x<0?-j:j},P=C(1,0,(y-S)/h,(g-B)/u);let v=C((y-S)/h,(g-B)/u,(-y-S)/h,(-g-B)/u);!a&&v>0&&(v-=2*Math.PI),a&&v<0&&(v+=2*Math.PI);const $=Math.max(1,Math.ceil(Math.abs(v)/(Math.PI/2))),Tt=v/$,tt=4/3*Math.tan(Tt/4),Zt=w=>{const I=h*Math.cos(w),x=u*Math.sin(w);return[d*I-f*x+J,f*I+d*x+k]},Kt=w=>{const I=-h*Math.sin(w),x=u*Math.cos(w);return[d*I-f*x,f*I+d*x]},Jt=[];for(let w=0;w<$;w++){const I=P+w*Tt,x=I+Tt,[q,bt]=Zt(I),[et,j]=w===$-1?[o,c]:Zt(x),[ki,wi]=Kt(I),[Pi,vi]=Kt(x);Jt.push([q+tt*ki,bt+tt*wi,et-tt*Pi,j-tt*vi,et,j])}return Jt}function E(i,t,e,s,n){const r=1-n;return r*r*r*i+3*r*r*n*t+3*r*n*n*e+n*n*n*s}function Dt(i,t,e,s,n){const r=1-n;return 3*r*r*(t-i)+6*r*n*(e-t)+3*n*n*(s-e)}function V(i,t,e,s){return{subpath:0,type:"L",points:[e,s],startX:i,startY:t,endX:e,endY:s,length:Math.hypot(e-i,s-t)}}function z(i,t,e){const[s,n,r,a,o,c]=e,h=[0];let u=i,l=t,d=0;for(let f=1;f<=Rt;f++){const b=f/Rt,p=E(i,s,r,o,b),y=E(t,n,a,c,b);d+=Math.hypot(p-u,y-l),h.push(d),u=p,l=y}return{subpath:0,type:"C",points:[s,n,r,a,o,c],startX:i,startY:t,endX:o,endY:c,length:d,lengths:h}}function G(i){const t=N.get(i);if(t)return t;const e=[];let s=0,n=0,r=0,a=0,o=null,c=null,h=-1;const u=new Set,l=p=>{h<0&&(h=0),p.subpath=h,e.push(p)};for(const{type:p,args:y}of Pe(i)){const g=p.toUpperCase(),T=p!==g,A=we[g];if(g==="Z"){(s!==r||n!==a)&&l(V(s,n,r,a)),h>=0&&u.add(h),s=r,n=a,o=c=null;continue}for(let M=0;M+A<=y.length;M+=A){const m=y.slice(M,M+A),_=T?s:0,S=T?n:0;let B=null,J=null;switch(g){case"M":M===0?(s=m[0]+_,n=m[1]+S,r=s,a=n,(h<0||e[e.length-1]?.subpath===h)&&h++):(l(V(s,n,m[0]+_,m[1]+S)),s=m[0]+_,n=m[1]+S);break;case"L":l(V(s,n,m[0]+_,m[1]+S)),s=m[0]+_,n=m[1]+S;break;case"H":l(V(s,n,m[0]+_,n)),s=m[0]+_;break;case"V":l(V(s,n,s,m[0]+S)),n=m[0]+S;break;case"C":{const k=[m[0]+_,m[1]+S,m[2]+_,m[3]+S,m[4]+_,m[5]+S];l(z(s,n,k)),B=[k[2],k[3]],s=k[4],n=k[5];break}case"S":{const[k,C]=o?[2*s-o[0],2*n-o[1]]:[s,n],P=[k,C,m[0]+_,m[1]+S,m[2]+_,m[3]+S];l(z(s,n,P)),B=[P[2],P[3]],s=P[4],n=P[5];break}case"Q":case"T":{let k=s,C=n;g==="Q"?(k=m[0]+_,C=m[1]+S):c&&(k=2*s-c[0],C=2*n-c[1]);const P=g==="Q"?m[2]+_:m[0]+_,v=g==="Q"?m[3]+S:m[1]+S;l(z(s,n,[s+2/3*(k-s),n+2/3*(C-n),P+2/3*(k-P),v+2/3*(C-v),P,v])),J=[k,C],s=P,n=v;break}case"A":{const k=m[5]+_,C=m[6]+S;let P=s,v=n;for(const $ of ve(s,n,m[0],m[1],m[2],m[3],m[4],k,C))l(z(P,v,$)),P=$[4],v=$[5];s=k,n=C;break}}o=B,c=J}}const d=e.reduce((p,y)=>p+y.length,0),f=[];for(let p=0;p<e.length;){const y=e[p].subpath;let g=p,T=0;for(;g<e.length&&e[g].subpath===y;)T+=e[g++].length;const A=e[p],M=e[g-1],m=u.has(y)||Math.abs(M.endX-A.startX)<1e-9&&Math.abs(M.endY-A.startY)<1e-9;f.push({start:p,end:g,length:T,closed:m}),p=g}const b={segments:e,totalLength:d,subpaths:f};return N.size>=Me&&N.delete(N.keys().next().value),N.set(i,b),b}function Ie(i,t){const e=i.lengths;if(t<=0)return 0;if(t>=i.length)return 1;let s=0,n=e.length-1;for(;s<n-1;){const o=s+n>>1;e[o]<t?s=o:n=o}const r=e[n]-e[s],a=r>0?(t-e[s])/r:0;return(s+a)/(e.length-1)}function Ce(i,t){if(i.type==="L"){const l=i.length>0?Math.max(0,Math.min(1,t/i.length)):0;return{x:i.startX+(i.endX-i.startX)*l,y:i.startY+(i.endY-i.startY)*l,angle:Math.atan2(i.endY-i.startY,i.endX-i.startX)*180/Math.PI}}const[e,s,n,r,a,o]=i.points,c=Ie(i,t);let h=Dt(i.startX,e,n,a,c),u=Dt(i.startY,s,r,o,c);if(Math.hypot(h,u)<1e-9){const l=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),d=E(i.startX,e,n,a,l),f=E(i.startY,s,r,o,l),b=E(i.startX,e,n,a,c),p=E(i.startY,s,r,o,c);h=c<.5?d-b:b-d,u=c<.5?f-p:p-f}return{x:E(i.startX,e,n,a,c),y:E(i.startY,s,r,o,c),angle:Math.atan2(u,h)*180/Math.PI}}function Bt(i,t,e=0,s=i.length){if(s<=e)return{x:0,y:0,angle:0};let n=0;for(let r=e;r<s;r++){const a=i[r];if(n+a.length>=t||r===s-1)return Ce(a,t-n);n+=a.length}return{x:0,y:0,angle:0}}function xe(i,t){const{segments:e,totalLength:s}=G(i);return Bt(e,Math.max(0,Math.min(1,t))*s)}const Re=24,De=320,Be=2.5,W=72,Ee=.2,Le=128,Z=new Map;let ht=0,L;const Et=i=>Math.round(i*100)/100;function Lt(i,t){const{segments:e,subpaths:s,totalLength:n}=G(i);if(e.length===0)return[];if(t){const r=s.every(a=>a.closed);return[{segments:e,start:0,end:e.length,length:n,closed:r}]}return s.filter(r=>r.length>0).map(r=>({segments:e,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function lt(i,t){const e=i.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),s=Bt(i.segments,e*i.length,i.start,i.end);return[s.x,s.y]}function Ot(i){const t=[];let e=0;for(let s=i.start;s<i.end;s++)e+=i.segments[s].length,i.length>0&&t.push(e/i.length);return t}function $t(i,t){const e=[];for(let s=0;s<t;s++)e.push(lt(i,i.closed?s/t:s/(t-1)));return e}function Ft(i){let t=0,e=0;for(const[s,n]of i)t+=s,e+=n;return t/=i.length,e/=i.length,i.map(([s,n])=>[s-t,n-e])}function Oe(i,t,e){const s=i.closed&&t.closed;if(e!==void 0)return{offset:s?Math.abs(e)%W/W:0,reversed:e<0};const n=Ft($t(i,W)),r=Ft($t(t,W)),a=W;let o={offset:0,reversed:!1},c=1/0;for(const h of[!1,!0]){const u=s?a:1;for(let l=0;l<u;l++){let d=0;for(let f=0;f<a&&d<c;f++){const b=s?h?(l-f+a)%a:(f+l)%a:h?a-1-f:f,p=n[f][0]-r[b][0],y=n[f][1]-r[b][1];d+=p*p+y*y}d<c&&(c=d,o={offset:s?l/a:0,reversed:h})}}return o}function $e(i,t,e){return e?((t.reversed?t.offset-i:i+t.offset)%1+1)%1:t.reversed?1-i:i}function Fe(i,t,e){return e?((t.reversed?t.offset-i:i-t.offset)%1+1)%1:t.reversed?1-i:i}function Xe(i,t,e){const s=i.closed&&t.closed,n=Oe(i,t,e.shapeIndex),r=Math.max(Re,Math.min(De,Math.ceil(Math.max(i.length,t.length)/Be))),a=new Set,o=l=>a.add(Math.round(l*1e7)/1e7);for(let l=0;l<=r;l++)o(l/r);for(const l of Ot(i))o(l);for(const l of Ot(t))o(Fe(l,n,s));let c=[...a].sort((l,d)=>l-d);s&&(c=c.filter(l=>l<1));const h=[],u=[];for(const l of c)h.push(...lt(i,l)),u.push(...lt(t,$e(l,n,s)));return qe({from:h,to:u,closed:s})}function qe(i){const t=i.from.length/2;if(t<=3)return i;const e=new Uint8Array(t);e[0]=1,e[t-1]=1;const s=[[0,t-1]];for(;s.length>0;){const[a,o]=s.pop();let c=-1,h=Ee;for(let u=a+1;u<o;u++){const l=Math.max(Xt(i.from,a,o,u),Xt(i.to,a,o,u));l>h&&(h=l,c=u)}c!==-1&&(e[c]=1,s.push([a,c],[c,o]))}const n=[],r=[];for(let a=0;a<t;a++)e[a]&&(n.push(i.from[a*2],i.from[a*2+1]),r.push(i.to[a*2],i.to[a*2+1]));return{from:n,to:r,closed:i.closed}}function Xt(i,t,e,s){const n=i[t*2],r=i[t*2+1],a=i[e*2]-n,o=i[e*2+1]-r,c=i[s*2]-n,h=i[s*2+1]-r,u=a*a+o*o,l=u===0?0:Math.max(0,Math.min(1,(c*a+h*o)/u));return Math.hypot(c-l*a,h-l*o)}function Ye(i,t,e){const s=e.shapeIndex;if(L&&L.from===i&&L.to===t&&L.shapeIndex===s)return L.plan;const r=Z.get(String(s??"auto"))?.get(i)?.get(t);if(r)return L={from:i,to:t,shapeIndex:s,plan:r},r;const a=G(i).subpaths.filter(f=>f.length>0).length===G(t).subpaths.filter(f=>f.length>0).length,o=Lt(i,!a),c=Lt(t,!a),h={pairs:o.map((f,b)=>Xe(f,c[b],e))};ht>=Le&&(Z.clear(),ht=0);const u=String(s??"auto"),l=Z.get(u)??new Map;Z.set(u,l);const d=l.get(i)??new Map;return l.set(i,d),d.set(t,h),ht++,L={from:i,to:t,shapeIndex:s,plan:h},h}function Ne(i,t,e,s={}){if(!i)return t;if(!t)return i;const n=Math.max(0,Math.min(1,e));if(n===0)return i;if(n===1)return t;const r=Ye(i,t,s);if(r.pairs.length===0)return n<.5?i:t;let a="";for(const o of r.pairs){for(let c=0;c<o.from.length;c+=2){const h=Et(o.from[c]+(o.to[c]-o.from[c])*n),u=Et(o.from[c+1]+(o.to[c+1]-o.from[c+1])*n);a+=`${c===0?a?" M":"M":" L"}${h} ${u}`}o.closed&&(a+=" Z")}return a}function Ve(i){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(i)}const D=(i,t,e)=>i+(t-i)*e,qt=512,ut=new Map,dt=new Map;function Yt(i){const t=ut.get(i);if(t)return t;const e=i.replace("#",""),s=[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return ut.size<qt&&ut.set(i,s),s}const Nt=i=>i.charCodeAt(0)===35,Vt=i=>i.startsWith("rgb"),Wt=i=>i.startsWith("rgba"),We=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,ft=i=>Math.round(i).toString(16).padStart(2,"0");function Ue(i,t,e){return`#${ft(i)}${ft(t)}${ft(e)}`}function Ut(i){const t=dt.get(i);if(t)return t;const e=i.match(We);if(!e)throw new Error(`Invalid rgb color: ${i}`);const s=parseInt(e[1],10),n=parseInt(e[2],10),r=parseInt(e[3],10),a=e[4]!==void 0?[s,n,r,parseFloat(e[4])]:[s,n,r];return dt.size<qt&&dt.set(i,a),a}const He=(i,t,e)=>{if(Nt(i)&&Nt(t)){const[s,n,r]=Yt(i),[a,o,c]=Yt(t),h=D(s,a,e),u=D(n,o,e),l=D(r,c,e);return Ue(h,u,l)}if((Vt(i)||Wt(i))&&(Vt(t)||Wt(t))){const s=Ut(i),n=Ut(t),r=Math.round(D(s[0],n[0],e)),a=Math.round(D(s[1],n[1],e)),o=Math.round(D(s[2],n[2],e));if(s.length===4||n.length===4){const c=s[3]??1,h=n[3]??1,u=D(c,h,e);return`rgba(${r}, ${a}, ${o}, ${u})`}return`rgb(${r}, ${a}, ${o})`}return e<1?i:t},je=(i,t,e)=>{const s=Math.min(i.length,t.length),n=[];for(let r=0;r<s;r++)n.push(D(i[r],t[r],e));return n},Ht=(i,t,e)=>e<1?i:t,Qe=(i,t,e)=>Ne(i,t,e);function ze(i){return typeof i=="number"?D:Array.isArray(i)?je:typeof i=="string"?i.startsWith("#")||i.startsWith("rgb")?He:Ve(i)?Qe:Ht:Ht}function Ge(i){const t=[...i.keyframes].sort((e,s)=>e.time-s.time);return{...i,keyframes:t}}function O(i){return i.targets&&i.targets.length>0?i.targets:[i.target]}function X(i,t,e,s){const n=e??0;return!s||t<=1?n:n+Mt(i,t,s)}class pt{track;targets;constructor(t){this.track=t,this.targets=O(t)}getValueAtTime(t){return this.valueForOffset(t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger),a=this.valueForOffset(t-r);a!==void 0&&s.push({target:this.targets[n],value:a,start:r+this.track.keyframes[0].time})}return s}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const e=t[t.length-1].time,s=this.track.stagger?rt(this.targets.length,this.track.stagger):0;return e+(this.track.delay??0)+s+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:e}=this.track;if(e.length===0)return;if(e.length===1||t<=e[0].time)return e[0].value;if(t>=e[e.length-1].time)return e[e.length-1].value;const{from:s,to:n}=this.findSurroundingKeyframes(t);if(!s||!n)return;if(s.time===t)return s.value;const r=n.time-s.time,a=(t-s.time)/r,c=Se(n.easing)(a);return ze(s.value)(s.value,n.value,c)}findSurroundingKeyframes(t){const{keyframes:e}=this.track;for(let s=0;s<e.length-1;s++)if(t>=e[s].time&&t<=e[s+1].time)return{from:e[s],to:e[s+1]};return{from:null,to:null}}}class Ze{track;targets;sampler;constructor(t){this.track=t,this.targets=O(t),this.sampler=new re(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger);s.push({target:this.targets[n],value:this.sampler.valueAt(t-r),start:r})}return s}getDuration(){const t=this.track.stagger?rt(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class Ke{track;targets;duration;constructor(t){this.track=t,this.targets=O(t),this.duration=Pt(t.inertia)}getValueAtTime(t){return vt(this.track.inertia,t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger);s.push({target:this.targets[n],value:vt(this.track.inertia,t-r),start:r})}return s}getDuration(){const t=this.track.stagger?rt(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function Je(i,t){const e={...xe(i.pathData,t)};if(i.matrix){const[s,n,r,a,o,c]=i.matrix,{x:h,y:u}=e;e.x=s*h+r*u+o,e.y=n*h+a*u+c;const l=e.angle*Math.PI/180,d=Math.cos(l),f=Math.sin(l);e.angle=Math.atan2(n*d+a*f,s*d+r*f)*180/Math.PI}return i.autoRotate&&i.rotateOffset&&(e.angle+=i.rotateOffset),e}const mt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},ti=20;function ei(i){const t=mt[i??"upperCase"]??i??mt.upperCase,e=Array.from(t);return e.length>0?e:Array.from(mt.upperCase)}function ii(i,t,e){let s=(i|0)^Math.imul(t+1,2654435761)^Math.imul(e+1,2246822507);return s=Math.imul(s^s>>>16,2146121005),s=Math.imul(s^s>>>15,2221713035),(s^s>>>16)>>>0}function si(i,t,e=0){const s=i.from??"",n=i.to,r=Math.max(0,Math.min(1,t));if(r<=0)return s;if(r>=1)return n;const a=Array.from(s),o=Array.from(n),c=i.rightToLeft??!1;if(i.mode==="type"){const T=Math.round(r*Math.max(a.length,o.length));return c?a.slice(0,Math.max(0,a.length-T)).join("")+o.slice(Math.max(0,o.length-T)).join(""):o.slice(0,T).join("")+a.slice(T).join("")}const h=Math.max(0,Math.min(.999,i.revealDelay??0)),u=Math.max(0,(r-h)/(1-h)),l=Math.floor(u*o.length),d=i.tweenLength===!1?o.length:Math.round(a.length+(o.length-a.length)*r),f=ei(i.chars),b=i.refreshRate??ti,p=b>0?Math.floor(e*b/1e3):0,y=i.seed??1;let g="";for(let T=0;T<d;T++){const A=c?T>=d-l:T<l,M=c?o[o.length-(d-T)]:o[T];A&&M!==void 0||M===" "||M===`
|
|
2
|
-
`?g+=M:g+=f[ii(y,T,p)%f.length]}return g}class ni{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 e of t.tracks)this.addTrack(e)}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 e={...this._config};delete e.duration,this._config=e}}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 e=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,e)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const e=this.duration;if(e<=0)return;let n=t*this.speed;if(this._repeatDelayRemaining>0){const o=Math.min(this._repeatDelayRemaining,n);if(this._repeatDelayRemaining-=o,n-=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&&n>0&&this._playbackState==="playing";o++)if(this._direction==="forward"){const c=e-this._currentTime;if(n>=c){if(n-=c,this._currentTime=e,!this._handleEndReached())break}else this._currentTime+=n,n=0}else{const c=this._currentTime;if(n>=c){if(n-=c,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=n,n=0}const a=this.getStateAtTime(this._currentTime);this.onUpdate?.(a)}getStateAtTime(t){const e=new Map;if(this._hasSharedWrites())this._resolveShared(t,e);else for(const[s,n]of this._trackPlayers){const r=n.getTrack().property;for(const{target:a,value:o,start:c}of n.getTargetValues(t))this._write(e,s,a,r,o,t-c)}return{values:e,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,e){const s=new Map;for(const[n,r]of this._trackPlayers){const a=r.getTrack().property;for(const{target:o,value:c,start:h}of r.getTargetValues(t)){const u=`${o}\0${a}`,l=h<=t,d=s.get(u);(!d||(l!==d.started?l:l?h>=d.start:h<=d.start))&&s.set(u,{trackId:n,target:o,property:a,value:c,start:h,started:l})}}for(const{trackId:n,target:r,property:a,value:o,start:c}of s.values())this._write(e,n,r,a,o,t-c)}_write(t,e,s,n,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(e);if(c&&typeof r=="number"){o.set("text",si(c.textConfig,r,Math.max(0,a)));return}const h=this._motionPathTracks.get(e);if(h&&typeof r=="number"){const u=Je(h.motionPathConfig,r);o.set("motionPathX",u.x),o.set("motionPathY",u.y),h.motionPathConfig.autoRotate&&o.set("motionPathRotate",u.angle)}else o.set(n,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const e of this._tracks)for(const s of O(e)){const n=`${s}\0${e.property}`;if(t.has(n)){this._sharedWrites=!0;break t}t.add(n)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,st(t)){this._trackPlayers.set(t.id,new Ke(t));return}if(nt(t)){this._trackPlayers.set(t.id,new Ze(t)),this._springTracks.set(t.id,t);return}if(At(t))this._trackPlayers.set(t.id,new pt(t)),this._textTracks.set(t.id,t);else if(ie(t)){const e={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 pt(e)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new pt(t))}replaceTrack(t,e){const s=this._tracks.findIndex(r=>r.id===t);if(s<0)return;const n=this._tracks.slice(s+1);this.removeTrack(t);for(const r of n)this.removeTrack(r.id);this.addTrack(e);for(const r of n)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(e=>e.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(e=>this._matches(e,t))}removeTracks(t={}){const e=this.getTracks(t).map(s=>s.id);for(const s of e)this.removeTrack(s);return e}getTrackSpan(t){const e=this._trackPlayers.get(t);if(!e)return;const s=e.getTrack(),n=s.delay??0;if(nt(s)||st(s))return{from:n,to:e.getDuration()};const r=s.keyframes;if(!(!r||r.length===0))return{from:r[0].time+n,to:e.getDuration()}}findConflicts(){const t=[];for(let e=0;e<this._tracks.length;e++){const s=this._tracks[e],n=this.getTrackSpan(s.id);if(n)for(let r=0;r<e;r++){const a=this._tracks[r];if(a.property!==s.property)continue;const o=O(a).filter(l=>O(s).includes(l));if(o.length===0)continue;const c=this.getTrackSpan(a.id);if(!c||!(c.from<=n.to&&n.from<=c.to))continue;const u=n.from>=c.from;for(const l of o)t.push({target:l,property:s.property,losingTrackId:u?a.id:s.id,winningTrackId:u?s.id:a.id})}}return t}_matches(t,e){if(e.id!==void 0&&t.id!==e.id||e.property!==void 0&&t.property!==e.property||e.target!==void 0&&!O(t).includes(e.target))return!1;if(e.timeRange){const s=this.getTrackSpan(t.id);if(!s||s.to<e.timeRange.from||s.from>e.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:it,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,e)=>t.time-e.time)}setMarkers(t){const e=t&&t.length>0?[...t].sort((n,r)=>n.time-r.time).map(n=>({...n})):void 0,s={...this._config};e?s.markers=e:delete s.markers,this._config=s}get captions(){return this._captions}setCaptions(t){const e={};for(const[s,n]of Object.entries(t??{}))e[s]={...n};this._captions=Object.keys(e).length>0?e:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,e]of this._trackPlayers)t=Math.max(t,e.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 ri=100;function ai(i,t,e,s){const n=[],r=[],{duration:a,alternate:o}=s,c=(f,b,p,y)=>{r.push([f,b]);const g=[];i.forEach((T,A)=>{(p==="forward"?(y?T>=f:T>f)&&T<=b:(y?T<=f:T<f)&&T>=b)&&g.push(A)}),g.sort((T,A)=>(p==="forward"?i[T]-i[A]:i[A]-i[T])||T-A);for(const T of g)n.push({kind:"event",index:T,direction:p})};let h=t.time,u=t.direction,l=t.fresh===!0;const d=Math.min(ri,Math.max(0,e.iteration-t.iteration));for(let f=0;f<d;f++){const b=u==="forward"?a:0;c(h,b,u,l),n.push({kind:"repeat"}),o?(u=u==="forward"?"reverse":"forward",h=b,l=!1):(h=u==="forward"?0:a,l=!0)}return d>0&&s.holding&&!o?{crossings:n,passes:r}:(c(h,e.time,u,l),{crossings:n,passes:r})}function oi(i){return{...i,...Array.isArray(i.end)&&{end:[...i.end]}}}function U(i){const t=i.endDelay;return{...i.delay!==void 0&&{delay:i.delay},...t!==void 0&&{endDelay:t},...i.targets!==void 0&&{targets:[...i.targets]},...i.stagger!==void 0&&{stagger:{...i.stagger}}}}function ci(i){if(st(i)){const t=i;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:oi(t.inertia),...U(t)}}if(nt(i)){const t=i;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...U(t)}}if(At(i)){const t=i;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((e,s)=>e.time-s.time),...U(t)}}if(i.property==="motionPath"&&"motionPathConfig"in i){const t=i,e=[...t.keyframes].sort((s,n)=>s.time-n.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:e,...U(t)}}return Ge({id:i.id,target:i.target,property:i.property,keyframes:i.keyframes,...U(i)})}function K(i){const t=i.formatVersion??1;if(t>it)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${it}. Update tinyfly to play it.`);return new ni({id:i.id,name:i.name,config:i.config,tracks:i.tracks.map(ci),captions:i.captions})}const hi=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),li="#ffffff",ui="rgba(0, 0, 0, 0.5)";function di(i){const t=[];if(i.blur!==void 0&&t.push(`blur(${Math.max(0,i.blur)}px)`),i.brightness!==void 0&&t.push(`brightness(${Math.max(0,i.brightness)})`),i.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,i.glow)}px ${i.glowColor??li})`),i.shadowX!==void 0||i.shadowY!==void 0||i.shadowBlur!==void 0){const e=i.shadowX??0,s=i.shadowY??0,n=Math.max(0,i.shadowBlur??0);t.push(`drop-shadow(${e}px ${s}px ${n}px ${i.shadowColor??ui})`)}return t.length>0?t.join(" "):null}function fi(i,t){const e=i.childNodes.length===1?i.firstChild:null;if(e&&e.nodeType===3){const s=e;s.data!==t&&(s.data=t);return}i.textContent!==t&&(i.textContent=t)}function pi(i){if(!("ownerSVGElement"in i))return;const t=i.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"]),mi=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","motionPathX","motionPathY","motionPathRotate"]),yi=new Set(["originX","originY"]),gi=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Ti={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},Qt={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},bi="http://www.w3.org/2000/svg";class H{targets=new Map;registerTarget(t,e){this.targets.set(t,e)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[e,s]of t.values){const n=this.targets.get(e);n&&this.applyProperties(n,s)}}applyProperties(t,e){const s=[];let n=null,r=null,a=null;const o=e.has("motionPathX"),c=e.has("motionPathY"),h=e.has("motionPathRotate");for(const[d,f]of e)if(!(d==="x"&&o)&&!(d==="y"&&c)&&!((d==="rotate"||d==="rotateZ")&&h)){if(mi.has(d)){const b=this.buildTransformPart(d,f);b&&s.push(b)}else if(yi.has(d))typeof f=="number"&&((n??={})[d]=f);else if(gi.has(d))typeof f=="number"&&((r??={})[d]=f);else if(hi.has(d))(a??={})[d]=f;else if(d!=="perspective"){if(d!=="shine")if(d==="text"&&typeof f=="string")fi(t,f);else if(d==="d"&&typeof f=="string"){const b=t;(b.tagName?.toLowerCase()==="path"?b:b.querySelector?.("path"))?.setAttribute?.("d",f)}else this.applyStyleProperty(t,d,f)}}const u=e.get("shine");typeof u=="number"&&this.applyShine(t,u);const l=e.get("perspective");if(typeof l=="number"&&s.unshift(`perspective(${l}px)`),s.length>0&&(t.style.transform=s.join(" "),pi(t)),n){const d=n.originX??50,f=n.originY??50;t.style.transformOrigin=`${d}% ${f}%`}if(r){const d=r.clipTop??0,f=r.clipRight??0,b=r.clipBottom??0,p=r.clipLeft??0;t.style.clipPath=`inset(${d}% ${f}% ${b}% ${p}%)`}if(a){const d=di(a);d&&(t.style.filter=d)}}buildTransformPart(t,e){if(typeof e!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${e}px)`;case"y":case"motionPathY":return`translateY(${e}px)`;case"z":return`translateZ(${e}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${e}deg)`;case"rotateX":return`rotateX(${e}deg)`;case"rotateY":return`rotateY(${e}deg)`;case"scale":return`scale(${e})`;case"scaleX":return`scaleX(${e})`;case"scaleY":return`scaleY(${e})`;case"scaleZ":return`scaleZ(${e})`;case"skewX":return`skewX(${e}deg)`;case"skewY":return`skewY(${e}deg)`;default:return null}}applyShine(t,e){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const s=t.dataset.shineBase,n=-20+e*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=`${n}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,e,s){let n;if(t.namespaceURI===bi&&e in Qt){const o=Array.isArray(s)?s.join(", "):String(s);t.style[Qt[e]]=o;return}else e==="fill"&&t.dataset?.elementType==="text"?n="color":n=Ti[e]??e;let a;typeof s=="number"?jt.has(e)||jt.has(n)?a=`${s}px`:a=String(s):Array.isArray(s)?a=s.join(", "):a=s,t.style[n]=a}}class yt{media;offset;driftTolerance;constructor(t,e={}){this.media=t,this.offset=e.offset??0,this.driftTolerance=Math.max(0,e.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,e){const s=this.targetTime(t);e?(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 zt(i,t,e,s,n){const r=e-n;if(r<0){t.paused||t.pause(),t.currentTime=0;return}i.update(r,s)}class gt{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,e={}){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=e,this.adapter=new H}async load(t){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(t)}async loadSource(t){let e;if(typeof t=="string"){const s=await fetch(t);if(!s.ok)throw new Error(`Failed to load animation: ${s.statusText}`);e=await s.json()}else e=t;this.useDefinition(e),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(t){const e={...t.config};this.options.speed!==void 0&&(e.speed=this.options.speed),this.options.loop!==void 0&&(e.loop=this.options.loop),this.options.alternate!==void 0&&(e.alternate=this.options.alternate),this.timeline=K({...t,config:e}),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,e={}){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 n=e.initial===void 0?t[0]:t.find(r=>r.id===e.initial);if(!n)throw new Error(`tinyfly: there is no scenario "${e.initial}"`);this.scenarioList=[...t],this.scenarioId=n.id,await this.loadSource(n.timeline)}get scenarios(){return this.scenarioList.map(t=>({id:t.id,label:t.label??t.id}))}get scenario(){return this.scenarioId}setScenario(t){const e=this.scenarioList.find(o=>o.id===t);if(!e||!this.timeline)return!1;if(t===this.scenarioId)return!0;const s=this.isPlaying,n=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=t,this.useDefinition(e.timeline),this.lastMarkerId=null;let a=0;return this.reducedMotion||n?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 e={style:t.getAttribute("style")};t.children.length===0&&(e.text=t.textContent??"");const s=t.tagName.toLowerCase()==="path"?t:t.querySelector("path");s&&(e.path={element:s,d:s.getAttribute("d")}),this.authored.set(t,e)}restoreAuthored(){for(const[t,e]of this.authored){e.style===null?t.removeAttribute("style"):t.setAttribute("style",e.style),e.text!==void 0&&t.textContent!==e.text&&(t.textContent=e.text),e.path&&(e.path.d===null?e.path.element.removeAttribute("d"):e.path.element.setAttribute("d",e.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 e;for(const s of this.markers)if(s.time<=t+.5)e=s;else break;return e}caption(t,e){const s=t?this.markers.find(a=>a.id===t):this.currentMarker;if(!s)return;const n=e??this.language(),r=a=>a?.[n]?.[s.id]??a?.[n.split("-")[0]]?.[s.id];return r(this.options.captions)??r(this.timeline?.captions)??s.label}next(){if(!this.timeline)return;const t=this.currentTime,e=this.markers.find(s=>s.time>t+.5);if(this.reducedMotion){this.seek(e?e.time:this.duration);return}t>=this.duration-.5||(this.stepping=e!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,e=[...this.markers].reverse().find(s=>s.time<t-.5);this.pause(),this.seek(e?e.time:0)}goToMarker(t){const e=this.markers.find(s=>s.id===t);e&&(this.pause(),this.seek(e.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 e=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,e))),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(e=>{for(const s of e)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,e=t?.id;e!==this.lastMarkerId&&(this.lastMarkerId=e,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(e=>{const s=e,n=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:n,sync:new yt(s)})})}syncAllMedia(t,e){for(const s of this.mediaTargets)zt(s.sync,s.el,t,e,s.startTime)}loadFromString(t){const e=JSON.parse(t);this.load(e)}registerTarget(t,e){if(typeof e=="string"){const s=this.container.querySelector(e);s&&(this.rememberAuthored(s),this.targets[t]=s,this.adapter.registerTarget(t,s))}else this.rememberAuthored(e),this.targets[t]=e,this.adapter.registerTarget(t,e)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(e=>{const s=e.closest("[data-tinyfly-symbol]");if(s&&s!==e)return;const n=e.getAttribute("data-tinyfly");n&&this.registerTarget(n,e)}),this.timeline&&new Set(this.timeline.tracks.map(s=>s.target)).forEach(s=>{if(!this.targets[s]){const n=this.container.querySelector(`[data-tinyfly="${s}"]`)||this.container.querySelector(`.${s}`)||this.container.querySelector(`#${s}`);n&&this.registerTarget(s,n)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const e=new Map(t.map(s=>[s.id,s]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const n=s.getAttribute("data-tinyfly-symbol");if(!n)return;const r=e.get(n);if(!r||!r.timeline.tracks?.length)return;const a=new H;s.querySelectorAll("[data-tinyfly]").forEach(o=>{const c=o.getAttribute("data-tinyfly");c&&a.registerTarget(c,o)}),this.symbolInstances.push({adapter:a,timeline:K(r.timeline)})})}attachMedia(t,e){this.mediaSync=new yt(t,e),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=e=>{if(this.isDestroyed||!this.timeline)return;const s=e-(this.lastTime??e);this.lastTime=e;const n=this.playhead;this.timeline.tick(s),this.stopAtMarker(n),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 e=this.timeline,s={time:e.currentTime,iteration:e.loopIteration,direction:e.direction};this.playhead=s;const n=this.markers;if(n.length===0)return;const{crossings:r}=ai(n.map(a=>a.time),t,s,{duration:e.duration,alternate:e.config.alternate===!0,holding:e.repeatDelayRemaining>0});for(const a of r){if(a.kind!=="event")continue;const o=n[a.index];if(this.stepping||o.pause){this.stepping=!1,e.pause(),e.seek(o.time),this.playhead={time:o.time,iteration:e.loopIteration,direction:e.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 e of this.symbolInstances){const s=e.timeline.duration;e.adapter.applyState(e.timeline.getStateAtTime(s>0?t%s:t))}}}async function Ai(i,t,e={}){const s=new gt(i,{...e,autoplay:!0});return await s.load(t),s}function Si(i,t={}){return new gt(i,t)}class Gt{container;containerA;containerB;adapterA;adapterB;timelineA=null;timelineB=null;symbolDefs=new Map;nestedByAdapter=new Map;sequence=null;options;_currentSceneIndex=0;_state="idle";_isPlaying=!1;_isDestroyed=!1;loopIteration=0;animationFrameId;lastTime;transitionTimer;constructor(t,e={}){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=e,this.container.style.position="relative",this.container.style.overflow="hidden",this.containerA=this.createSceneContainer(),this.containerB=this.createSceneContainer(),this.container.appendChild(this.containerA),this.container.appendChild(this.containerB),this.containerB.style.visibility="hidden",this.adapterA=new H,this.adapterB=new H}async load(t){let e;if(typeof t=="string"){const s=await fetch(t);if(!s.ok)throw new Error(`Failed to load sequence: ${s.statusText}`);e=await s.json()}else e=t;this.sequence=e,this.symbolDefs.clear();for(const s of e.symbols??[])s.timeline?.tracks?.length&&this.symbolDefs.set(s.id,s.timeline);this.container.style.width=`${e.canvas.width}px`,this.container.style.height=`${e.canvas.height}px`,e.scenes.length>0&&(this.renderScene(e.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(e.scenes[0])),this.options.autoplay&&this.play()}play(){if(!(!this.sequence||this._isDestroyed)&&this.sequence.scenes.length!==0){if(this._isPlaying=!0,this._state==="idle"){if(this._state="playing-scene",this._currentSceneIndex=0,this.timelineA)this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play();else{this.onSceneComplete();return}this.options.onSceneChange?.(0)}else this._state==="playing-scene"&&this.timelineA&&this.timelineA.play();this.startAnimationLoop()}}pause(){this._isPlaying&&(this._isPlaying=!1,this.timelineA&&this.timelineA.pause(),this.timelineB&&this.timelineB.pause(),this.stopAnimationLoop())}stop(){if(this._isPlaying=!1,this._state="idle",this._currentSceneIndex=0,this.loopIteration=0,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.stopAnimationLoop(),this.sequence&&this.sequence.scenes.length>0&&(this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this.renderScene(this.sequence.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(this.sequence.scenes[0]),this.timelineA)){const t=this.timelineA.getStateAtTime(0);this.adapterA.applyState(t),this.applyNested(this.adapterA,0)}}goToScene(t){if(!this.sequence||t<0||t>=this.sequence.scenes.length)return;const e=this._isPlaying;this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this._currentSceneIndex=t,this._state=e?"playing-scene":"idle",this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB);const s=this.sequence.scenes[t];if(this.renderScene(s,this.containerA,this.adapterA),this.timelineA=this.createTimeline(s),this.options.onSceneChange?.(t),e)this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play(),this.startAnimationLoop()):this.onSceneComplete();else if(this.timelineA){const n=this.timelineA.getStateAtTime(0);this.adapterA.applyState(n),this.applyNested(this.adapterA,0)}}destroy(){this._isDestroyed=!0,this._isPlaying=!1,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.adapterA.clearTargets(),this.adapterB.clearTargets();for(const t of this.nestedByAdapter.values())for(const e of t)e.adapter.clearTargets();this.nestedByAdapter.clear(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.timelineA=null,this.timelineB=null,this.containerA.parentNode&&this.containerA.remove(),this.containerB.parentNode&&this.containerB.remove(),this.sequence=null}get currentSceneIndex(){return this._currentSceneIndex}get sceneCount(){return this.sequence?.scenes.length??0}get isPlaying(){return this._isPlaying}get state(){return this._state}createSceneContainer(){const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t}renderScene(t,e,s){e.innerHTML="",s.clearTargets();const n=document.createElement("div");n.style.cssText="position:absolute;inset:0;transform-origin:center center",n.setAttribute("data-tinyfly","Camera"),e.appendChild(n),s.registerTarget("Camera",n);for(const r of t.elements){if(!r.html)continue;const a=document.createElement("div");a.innerHTML=r.html.trim();const o=a.firstElementChild;if(o){n.appendChild(o);const c=o.getAttribute("data-tinyfly");c&&s.registerTarget(c,o)}}this.setupNested(n,s)}setupNested(t,e){const s=[];t.querySelectorAll("[data-tinyfly-symbol]").forEach(n=>{const r=n.getAttribute("data-tinyfly-symbol");if(!r)return;const a=this.symbolDefs.get(r);if(!a)return;const o=new H;n.querySelectorAll("[data-tinyfly]").forEach(c=>{const h=c.getAttribute("data-tinyfly");h&&o.registerTarget(h,c)}),s.push({adapter:o,timeline:K(a)})}),s.length?this.nestedByAdapter.set(e,s):this.nestedByAdapter.delete(e)}applyNested(t,e){const s=this.nestedByAdapter.get(t);if(s)for(const n of s){const r=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(r>0?e%r:e))}}clearContainer(t){t.innerHTML=""}createTimeline(t){return t.timeline?K(t.timeline):null}onSceneComplete(){if(this._isDestroyed||!this.sequence)return;const t=this._currentSceneIndex+1;if(t>=this.sequence.scenes.length){const e=this.options.loop??this.sequence.loop??0;e===-1||e>0&&this.loopIteration<e-1?(this.loopIteration++,this.beginTransitionTo(0)):(this._isPlaying=!1,this._state="idle",this.stopAnimationLoop(),this.options.onComplete?.())}else this.beginTransitionTo(t)}beginTransitionTo(t){if(!this.sequence||this._isDestroyed)return;const e=this.sequence.scenes[t],s=e.transition;if(s.type==="none"||s.duration<=0){this.switchToScene(t);return}this._state="transitioning",this.containerB.style.visibility="visible",this.renderScene(e,this.containerB,this.adapterB),this.timelineB=this.createTimeline(e),this.timelineB&&this.timelineB.play(),this.applyTransition(s.type,s.duration),this.transitionTimer=window.setTimeout(()=>{this.finishTransition(t)},s.duration)}applyTransition(t,e){const s=`${e}ms`,n="ease-in-out";switch(this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),t){case"fade":this.containerB.style.opacity="0";break;case"slide-left":this.containerB.style.transform="translateX(100%)";break;case"slide-right":this.containerB.style.transform="translateX(-100%)";break;case"slide-up":this.containerB.style.transform="translateY(100%)";break;case"slide-down":this.containerB.style.transform="translateY(-100%)";break}switch(this.containerB.offsetHeight,this.containerA.style.transition=`opacity ${s} ${n}, transform ${s} ${n}`,this.containerB.style.transition=`opacity ${s} ${n}, transform ${s} ${n}`,t){case"fade":this.containerA.style.opacity="0",this.containerB.style.opacity="1";break;case"slide-left":this.containerA.style.transform="translateX(-100%)",this.containerB.style.transform="translateX(0)";break;case"slide-right":this.containerA.style.transform="translateX(100%)",this.containerB.style.transform="translateX(0)";break;case"slide-up":this.containerA.style.transform="translateY(-100%)",this.containerB.style.transform="translateY(0)";break;case"slide-down":this.containerA.style.transform="translateY(100%)",this.containerB.style.transform="translateY(0)";break}}resetTransitionStyles(t){t.style.transition="",t.style.opacity="1",t.style.transform=""}finishTransition(t){this.transitionTimer=void 0,this.timelineA&&(this.timelineA.stop(),this.timelineA=null),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const e=this.containerA;this.containerA=this.containerB,this.containerB=e;const s=this.adapterA;this.adapterA=this.adapterB,this.adapterB=s,this.timelineA=this.timelineB,this.timelineB=null,this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.playbackState!=="playing"&&this.timelineA.play()):this.onSceneComplete()}switchToScene(t){if(!this.sequence||this._isDestroyed)return;this.timelineA&&this.timelineA.stop(),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const e=this.sequence.scenes[t];this.renderScene(e,this.containerA,this.adapterA),this.timelineA=this.createTimeline(e),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play()):this.onSceneComplete()}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=e=>{if(this._isDestroyed||!this._isPlaying)return;const s=e-(this.lastTime??e);if(this.lastTime=e,this.timelineA&&this.timelineA.playbackState==="playing"){this.timelineA.tick(s);const n=this.timelineA.getStateAtTime(this.timelineA.currentTime);this.adapterA.applyState(n),this.applyNested(this.adapterA,this.timelineA.currentTime)}if(this._state==="transitioning"&&this.timelineB&&this.timelineB.playbackState==="playing"){this.timelineB.tick(s);const n=this.timelineB.getStateAtTime(this.timelineB.currentTime);this.adapterB.applyState(n),this.applyNested(this.adapterB,this.timelineB.currentTime)}this._isPlaying?this.animationFrameId=requestAnimationFrame(t):this.animationFrameId=void 0};this.animationFrameId=requestAnimationFrame(t)}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}}async function Mi(i,t,e={}){const s=new Gt(i,{...e,autoplay:!0});return await s.load(t),s}const _i={type:"none",duration:0};R.DEFAULT_TRANSITION=_i,R.MediaSync=yt,R.TinyflyPlayer=gt,R.TinyflySequencer=Gt,R.create=Si,R.play=Ai,R.playSequence=Mi,R.syncMediaElement=zt,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});
|
|
1
|
+
(function(R){"use strict";function te(i){return typeof i=="object"&&i!==null&&i.type==="cubic-bezier"}function ee(i){return typeof i=="object"&&i!==null&&i.type!=="cubic-bezier"}const it=1;function At(i){return i.property==="text"&&"textConfig"in i}function st(i){return i.kind==="inertia"&&"inertia"in i}function nt(i){return i.kind==="spring"&&"spring"in i}function ie(i){return i.property==="motionPath"&&"motionPathConfig"in i}function St(i,t,e="start"){if(t<=1)return 0;if(typeof e=="number"){const s=Math.max(0,Math.min(t-1,e));return Math.abs(i-s)}switch(e){case"end":return t-1-i;case"center":return Math.abs(i-(t-1)/2);case"edges":return(t-1)/2-Math.abs(i-(t-1)/2);default:return i}}function se(i,t="start"){if(i<=1)return 0;let e=0;for(let s=0;s<i;s++)e=Math.max(e,St(s,i,t));return e}function Mt(i,t,e){if(e.offsets)return e.offsets[i]??0;const s=e.from??"start",n=St(i,t,s);if(e.amount!==void 0){const r=se(t,s);return r===0?0:e.amount*n/r}return e.each!==void 0?e.each*n:0}function ne(i,t){return Array.from({length:i},(e,s)=>Mt(s,i,t))}function rt(i,t){return i<=1?0:Math.max(...ne(i,t))}const N=1,_t=6e4,Q=_t/N,F={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1};class re{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??F.stiffness,this.damping=t.damping??F.damping,this.mass=t.mass??F.mass,this.restDelta=t.restDelta??F.restDelta,this.restSpeed=t.restSpeed??F.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??F.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 e=Math.floor(t/N);if(this.simulateTo(e+1),this.settledStep!==null&&e>=this.settledStep)return this.to;const s=this.samples[Math.min(e,this.samples.length-1)],n=this.samples[Math.min(e+1,this.samples.length-1)],r=t/N-e;return s+(n-s)*r}settleTime(){return this.simulateTo(Q+1),this.settledStep!==null?this.settledStep*N:_t}simulateTo(t){if(this.settledStep!==null)return;const e=Math.min(t,Q+1),s=N/1e3;for(;this.samples.length<e;){const n=this.samples[this.samples.length-1],r=n-this.to,a=-this.stiffness*r,o=-this.damping*this.velocity,c=(a+o)/this.mass;this.velocity+=c*s;const h=n+this.velocity*s;if(this.samples.push(h),this.isAtRest(h)){this.settledStep=this.samples.length-1;return}}this.samples.length>Q&&(this.settledStep=Q)}}const kt=4,ae=.002,oe=1e-4,ce=6e4;function at(i){const t=i.friction??kt;return t>0?t:kt}function he(i){return i.from+i.velocity/at(i)}function le(i,t){if(t===void 0)return i;if(typeof t=="number")return t>0?Math.round(i/t)*t:i;if(t.length===0)return i;let e=t[0];for(const s of t)Math.abs(s-i)<Math.abs(e-i)&&(e=s);return e}function wt(i){let t=le(he(i),i.end);return i.min!==void 0&&(t=Math.max(i.min,t)),i.max!==void 0&&(t=Math.min(i.max,t)),t}function Pt(i){const t=Math.abs(wt(i)-i.from);if(t===0)return 0;const e=i.restDelta??Math.max(oe,t*ae);if(e>=t)return 0;const s=Math.log(t/e)/at(i);return Math.min(ce,s*1e3)}function vt(i,t){if(t<=0)return i.from;const e=wt(i);if(t>=Pt(i))return e;const s=at(i);return i.from+(e-i.from)*(1-Math.exp(-s*t/1e3))}const ot=i=>i,ue=i=>i*i,de=i=>1-(1-i)*(1-i),fe=i=>i<.5?2*i*i:1-Math.pow(-2*i+2,2)/2,It=i=>i*i*i,Ct=i=>1-Math.pow(1-i,3),xt=i=>i<.5?4*i*i*i:1-Math.pow(-2*i+2,3)/2,pe={linear:ot,"ease-in":It,"ease-out":Ct,"ease-in-out":xt,"ease-in-quad":ue,"ease-out-quad":de,"ease-in-out-quad":fe,"ease-in-cubic":It,"ease-out-cubic":Ct,"ease-in-out-cubic":xt};function me(i){const[t,e,s,n]=i,r=3*t,a=3*(s-t)-r,o=1-r-a,c=3*e,h=3*(n-e)-c,u=1-c-h,l=p=>((o*p+a)*p+r)*p,d=p=>((u*p+h)*p+c)*p,f=p=>(3*o*p+2*a)*p+r,b=p=>{let y=p;for(let A=0;A<8;A++){const M=l(y)-p;if(Math.abs(M)<1e-7)return y;const m=f(y);if(Math.abs(m)<1e-7)break;y-=M/m}let g=0,T=1;for(y=p;g<T;){const A=l(y);if(Math.abs(A-p)<1e-7)return y;p>A?g=y:T=y,y=(g+T)/2}return y};return p=>{if(p<=0)return 0;if(p>=1)return 1;const y=b(p);return d(y)}}function ct(i,t="out"){if(t==="out")return i;const e=s=>1-i(1-s);return t==="in"?e:s=>s<.5?e(s*2)/2:i(s*2-1)/2+.5}function ye(i=1,t=.3){const e=Math.max(1,i),s=t/(2*Math.PI)*Math.asin(1/e);return n=>n<=0?0:n>=1?1:e*Math.pow(2,-10*n)*Math.sin((n-s)*(2*Math.PI)/t)+1}const ge=i=>{if(i<=0)return 0;if(i>=1)return 1;if(i<1/2.75)return 7.5625*i*i;if(i<2/2.75){const n=i-.5454545454545454;return 7.5625*n*n+.75}if(i<2.5/2.75){const n=i-.8181818181818182;return 7.5625*n*n+.9375}const s=i-2.625/2.75;return 7.5625*s*s+.984375};function Te(i=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const e=t-1;return e*e*((i+1)*e+i)+1}}function be(i,t="end"){const e=Math.max(1,Math.floor(i));return s=>{if(s>=1)return 1;if(s<=0)return t==="start"||t==="both"?t==="start"?1/e:1/(e+1):0;const n=Math.floor(s*e);switch(t){case"start":return Math.min(1,(n+1)/e);case"both":return(n+1)/(e+1);case"none":return e===1?0:Math.min(1,n/(e-1));default:return n/e}}}function Ae(i){switch(i.type){case"steps":return be(i.count,i.position);case"elastic":return ct(ye(i.amplitude,i.period),i.mode);case"bounce":return ct(ge,i.mode);case"back":return ct(Te(i.overshoot),i.mode)}}function Se(i){return i===void 0?ot:te(i)?me(i.points):ee(i)?Ae(i):pe[i]??ot}const Rt=32,Me=256,Y=new Map,_e=/[MmLlHhVvCcSsQqTtAaZz]/,ke=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,we={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Pe(i){const t=[];let e=0,s=null;const n=()=>{for(;e<i.length&&/[\s,]/.test(i[e]);)e++};for(;e<i.length&&(n(),!(e>=i.length));){const r=i[e];if(_e.test(r)){s={type:r,args:[]},t.push(s),e++;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),e++;continue}const c=ke.exec(i.slice(e));if(!c)break;s.args.push(parseFloat(c[0])),e+=c[0].length}return t}function ve(i,t,e,s,n,r,a,o,c){if(i===o&&t===c)return[];let h=Math.abs(e),u=Math.abs(s);if(h===0||u===0)return[[i,t,o,c,o,c]];const l=n*Math.PI/180,d=Math.cos(l),f=Math.sin(l),b=(i-o)/2,p=(t-c)/2,y=d*b+f*p,g=-f*b+d*p,T=y*y/(h*h)+g*g/(u*u);if(T>1){const w=Math.sqrt(T);h*=w,u*=w}const A=r===a?-1:1,M=h*h*u*u-h*h*g*g-u*u*y*y,m=h*h*g*g+u*u*y*y,_=A*Math.sqrt(Math.max(0,M/m)),S=_*h*g/u,B=-_*u*y/h,J=d*S-f*B+(i+o)/2,k=f*S+d*B+(t+c)/2,C=(w,I,x,q)=>{const bt=w*x+I*q,et=Math.sqrt((w*w+I*I)*(x*x+q*q)),j=Math.acos(Math.max(-1,Math.min(1,bt/et)));return w*q-I*x<0?-j:j},P=C(1,0,(y-S)/h,(g-B)/u);let v=C((y-S)/h,(g-B)/u,(-y-S)/h,(-g-B)/u);!a&&v>0&&(v-=2*Math.PI),a&&v<0&&(v+=2*Math.PI);const $=Math.max(1,Math.ceil(Math.abs(v)/(Math.PI/2))),Tt=v/$,tt=4/3*Math.tan(Tt/4),Zt=w=>{const I=h*Math.cos(w),x=u*Math.sin(w);return[d*I-f*x+J,f*I+d*x+k]},Kt=w=>{const I=-h*Math.sin(w),x=u*Math.cos(w);return[d*I-f*x,f*I+d*x]},Jt=[];for(let w=0;w<$;w++){const I=P+w*Tt,x=I+Tt,[q,bt]=Zt(I),[et,j]=w===$-1?[o,c]:Zt(x),[wi,Pi]=Kt(I),[vi,Ii]=Kt(x);Jt.push([q+tt*wi,bt+tt*Pi,et-tt*vi,j-tt*Ii,et,j])}return Jt}function E(i,t,e,s,n){const r=1-n;return r*r*r*i+3*r*r*n*t+3*r*n*n*e+n*n*n*s}function Dt(i,t,e,s,n){const r=1-n;return 3*r*r*(t-i)+6*r*n*(e-t)+3*n*n*(s-e)}function V(i,t,e,s){return{subpath:0,type:"L",points:[e,s],startX:i,startY:t,endX:e,endY:s,length:Math.hypot(e-i,s-t)}}function z(i,t,e){const[s,n,r,a,o,c]=e,h=[0];let u=i,l=t,d=0;for(let f=1;f<=Rt;f++){const b=f/Rt,p=E(i,s,r,o,b),y=E(t,n,a,c,b);d+=Math.hypot(p-u,y-l),h.push(d),u=p,l=y}return{subpath:0,type:"C",points:[s,n,r,a,o,c],startX:i,startY:t,endX:o,endY:c,length:d,lengths:h}}function G(i){const t=Y.get(i);if(t)return t;const e=[];let s=0,n=0,r=0,a=0,o=null,c=null,h=-1;const u=new Set,l=p=>{h<0&&(h=0),p.subpath=h,e.push(p)};for(const{type:p,args:y}of Pe(i)){const g=p.toUpperCase(),T=p!==g,A=we[g];if(g==="Z"){(s!==r||n!==a)&&l(V(s,n,r,a)),h>=0&&u.add(h),s=r,n=a,o=c=null;continue}for(let M=0;M+A<=y.length;M+=A){const m=y.slice(M,M+A),_=T?s:0,S=T?n:0;let B=null,J=null;switch(g){case"M":M===0?(s=m[0]+_,n=m[1]+S,r=s,a=n,(h<0||e[e.length-1]?.subpath===h)&&h++):(l(V(s,n,m[0]+_,m[1]+S)),s=m[0]+_,n=m[1]+S);break;case"L":l(V(s,n,m[0]+_,m[1]+S)),s=m[0]+_,n=m[1]+S;break;case"H":l(V(s,n,m[0]+_,n)),s=m[0]+_;break;case"V":l(V(s,n,s,m[0]+S)),n=m[0]+S;break;case"C":{const k=[m[0]+_,m[1]+S,m[2]+_,m[3]+S,m[4]+_,m[5]+S];l(z(s,n,k)),B=[k[2],k[3]],s=k[4],n=k[5];break}case"S":{const[k,C]=o?[2*s-o[0],2*n-o[1]]:[s,n],P=[k,C,m[0]+_,m[1]+S,m[2]+_,m[3]+S];l(z(s,n,P)),B=[P[2],P[3]],s=P[4],n=P[5];break}case"Q":case"T":{let k=s,C=n;g==="Q"?(k=m[0]+_,C=m[1]+S):c&&(k=2*s-c[0],C=2*n-c[1]);const P=g==="Q"?m[2]+_:m[0]+_,v=g==="Q"?m[3]+S:m[1]+S;l(z(s,n,[s+2/3*(k-s),n+2/3*(C-n),P+2/3*(k-P),v+2/3*(C-v),P,v])),J=[k,C],s=P,n=v;break}case"A":{const k=m[5]+_,C=m[6]+S;let P=s,v=n;for(const $ of ve(s,n,m[0],m[1],m[2],m[3],m[4],k,C))l(z(P,v,$)),P=$[4],v=$[5];s=k,n=C;break}}o=B,c=J}}const d=e.reduce((p,y)=>p+y.length,0),f=[];for(let p=0;p<e.length;){const y=e[p].subpath;let g=p,T=0;for(;g<e.length&&e[g].subpath===y;)T+=e[g++].length;const A=e[p],M=e[g-1],m=u.has(y)||Math.abs(M.endX-A.startX)<1e-9&&Math.abs(M.endY-A.startY)<1e-9;f.push({start:p,end:g,length:T,closed:m}),p=g}const b={segments:e,totalLength:d,subpaths:f};return Y.size>=Me&&Y.delete(Y.keys().next().value),Y.set(i,b),b}function Ie(i,t){const e=i.lengths;if(t<=0)return 0;if(t>=i.length)return 1;let s=0,n=e.length-1;for(;s<n-1;){const o=s+n>>1;e[o]<t?s=o:n=o}const r=e[n]-e[s],a=r>0?(t-e[s])/r:0;return(s+a)/(e.length-1)}function Ce(i,t){if(i.type==="L"){const l=i.length>0?Math.max(0,Math.min(1,t/i.length)):0;return{x:i.startX+(i.endX-i.startX)*l,y:i.startY+(i.endY-i.startY)*l,angle:Math.atan2(i.endY-i.startY,i.endX-i.startX)*180/Math.PI}}const[e,s,n,r,a,o]=i.points,c=Ie(i,t);let h=Dt(i.startX,e,n,a,c),u=Dt(i.startY,s,r,o,c);if(Math.hypot(h,u)<1e-9){const l=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),d=E(i.startX,e,n,a,l),f=E(i.startY,s,r,o,l),b=E(i.startX,e,n,a,c),p=E(i.startY,s,r,o,c);h=c<.5?d-b:b-d,u=c<.5?f-p:p-f}return{x:E(i.startX,e,n,a,c),y:E(i.startY,s,r,o,c),angle:Math.atan2(u,h)*180/Math.PI}}function Bt(i,t,e=0,s=i.length){if(s<=e)return{x:0,y:0,angle:0};let n=0;for(let r=e;r<s;r++){const a=i[r];if(n+a.length>=t||r===s-1)return Ce(a,t-n);n+=a.length}return{x:0,y:0,angle:0}}function xe(i,t){const{segments:e,totalLength:s}=G(i);return Bt(e,Math.max(0,Math.min(1,t))*s)}const Re=24,De=320,Be=2.5,W=72,Ee=.2,Le=128,Z=new Map;let ht=0,L;const Et=i=>Math.round(i*100)/100;function Lt(i,t){const{segments:e,subpaths:s,totalLength:n}=G(i);if(e.length===0)return[];if(t){const r=s.every(a=>a.closed);return[{segments:e,start:0,end:e.length,length:n,closed:r}]}return s.filter(r=>r.length>0).map(r=>({segments:e,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function lt(i,t){const e=i.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),s=Bt(i.segments,e*i.length,i.start,i.end);return[s.x,s.y]}function Ot(i){const t=[];let e=0;for(let s=i.start;s<i.end;s++)e+=i.segments[s].length,i.length>0&&t.push(e/i.length);return t}function $t(i,t){const e=[];for(let s=0;s<t;s++)e.push(lt(i,i.closed?s/t:s/(t-1)));return e}function Ft(i){let t=0,e=0;for(const[s,n]of i)t+=s,e+=n;return t/=i.length,e/=i.length,i.map(([s,n])=>[s-t,n-e])}function Oe(i,t,e){const s=i.closed&&t.closed;if(e!==void 0)return{offset:s?Math.abs(e)%W/W:0,reversed:e<0};const n=Ft($t(i,W)),r=Ft($t(t,W)),a=W;let o={offset:0,reversed:!1},c=1/0;for(const h of[!1,!0]){const u=s?a:1;for(let l=0;l<u;l++){let d=0;for(let f=0;f<a&&d<c;f++){const b=s?h?(l-f+a)%a:(f+l)%a:h?a-1-f:f,p=n[f][0]-r[b][0],y=n[f][1]-r[b][1];d+=p*p+y*y}d<c&&(c=d,o={offset:s?l/a:0,reversed:h})}}return o}function $e(i,t,e){return e?((t.reversed?t.offset-i:i+t.offset)%1+1)%1:t.reversed?1-i:i}function Fe(i,t,e){return e?((t.reversed?t.offset-i:i-t.offset)%1+1)%1:t.reversed?1-i:i}function Xe(i,t,e){const s=i.closed&&t.closed,n=Oe(i,t,e.shapeIndex),r=Math.max(Re,Math.min(De,Math.ceil(Math.max(i.length,t.length)/Be))),a=new Set,o=l=>a.add(Math.round(l*1e7)/1e7);for(let l=0;l<=r;l++)o(l/r);for(const l of Ot(i))o(l);for(const l of Ot(t))o(Fe(l,n,s));let c=[...a].sort((l,d)=>l-d);s&&(c=c.filter(l=>l<1));const h=[],u=[];for(const l of c)h.push(...lt(i,l)),u.push(...lt(t,$e(l,n,s)));return qe({from:h,to:u,closed:s})}function qe(i){const t=i.from.length/2;if(t<=3)return i;const e=new Uint8Array(t);e[0]=1,e[t-1]=1;const s=[[0,t-1]];for(;s.length>0;){const[a,o]=s.pop();let c=-1,h=Ee;for(let u=a+1;u<o;u++){const l=Math.max(Xt(i.from,a,o,u),Xt(i.to,a,o,u));l>h&&(h=l,c=u)}c!==-1&&(e[c]=1,s.push([a,c],[c,o]))}const n=[],r=[];for(let a=0;a<t;a++)e[a]&&(n.push(i.from[a*2],i.from[a*2+1]),r.push(i.to[a*2],i.to[a*2+1]));return{from:n,to:r,closed:i.closed}}function Xt(i,t,e,s){const n=i[t*2],r=i[t*2+1],a=i[e*2]-n,o=i[e*2+1]-r,c=i[s*2]-n,h=i[s*2+1]-r,u=a*a+o*o,l=u===0?0:Math.max(0,Math.min(1,(c*a+h*o)/u));return Math.hypot(c-l*a,h-l*o)}function Ne(i,t,e){const s=e.shapeIndex;if(L&&L.from===i&&L.to===t&&L.shapeIndex===s)return L.plan;const r=Z.get(String(s??"auto"))?.get(i)?.get(t);if(r)return L={from:i,to:t,shapeIndex:s,plan:r},r;const a=G(i).subpaths.filter(f=>f.length>0).length===G(t).subpaths.filter(f=>f.length>0).length,o=Lt(i,!a),c=Lt(t,!a),h={pairs:o.map((f,b)=>Xe(f,c[b],e))};ht>=Le&&(Z.clear(),ht=0);const u=String(s??"auto"),l=Z.get(u)??new Map;Z.set(u,l);const d=l.get(i)??new Map;return l.set(i,d),d.set(t,h),ht++,L={from:i,to:t,shapeIndex:s,plan:h},h}function Ye(i,t,e,s={}){if(!i)return t;if(!t)return i;const n=Math.max(0,Math.min(1,e));if(n===0)return i;if(n===1)return t;const r=Ne(i,t,s);if(r.pairs.length===0)return n<.5?i:t;let a="";for(const o of r.pairs){for(let c=0;c<o.from.length;c+=2){const h=Et(o.from[c]+(o.to[c]-o.from[c])*n),u=Et(o.from[c+1]+(o.to[c+1]-o.from[c+1])*n);a+=`${c===0?a?" M":"M":" L"}${h} ${u}`}o.closed&&(a+=" Z")}return a}function Ve(i){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(i)}const D=(i,t,e)=>i+(t-i)*e,qt=512,ut=new Map,dt=new Map;function Nt(i){const t=ut.get(i);if(t)return t;const e=i.replace("#",""),s=[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return ut.size<qt&&ut.set(i,s),s}const Yt=i=>i.charCodeAt(0)===35,Vt=i=>i.startsWith("rgb"),Wt=i=>i.startsWith("rgba"),We=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,ft=i=>Math.round(i).toString(16).padStart(2,"0");function Ue(i,t,e){return`#${ft(i)}${ft(t)}${ft(e)}`}function Ut(i){const t=dt.get(i);if(t)return t;const e=i.match(We);if(!e)throw new Error(`Invalid rgb color: ${i}`);const s=parseInt(e[1],10),n=parseInt(e[2],10),r=parseInt(e[3],10),a=e[4]!==void 0?[s,n,r,parseFloat(e[4])]:[s,n,r];return dt.size<qt&&dt.set(i,a),a}const He=(i,t,e)=>{if(Yt(i)&&Yt(t)){const[s,n,r]=Nt(i),[a,o,c]=Nt(t),h=D(s,a,e),u=D(n,o,e),l=D(r,c,e);return Ue(h,u,l)}if((Vt(i)||Wt(i))&&(Vt(t)||Wt(t))){const s=Ut(i),n=Ut(t),r=Math.round(D(s[0],n[0],e)),a=Math.round(D(s[1],n[1],e)),o=Math.round(D(s[2],n[2],e));if(s.length===4||n.length===4){const c=s[3]??1,h=n[3]??1,u=D(c,h,e);return`rgba(${r}, ${a}, ${o}, ${u})`}return`rgb(${r}, ${a}, ${o})`}return e<1?i:t},je=(i,t,e)=>{const s=Math.min(i.length,t.length),n=[];for(let r=0;r<s;r++)n.push(D(i[r],t[r],e));return n},Ht=(i,t,e)=>e<1?i:t,Qe=(i,t,e)=>Ye(i,t,e);function ze(i){return typeof i=="number"?D:Array.isArray(i)?je:typeof i=="string"?i.startsWith("#")||i.startsWith("rgb")?He:Ve(i)?Qe:Ht:Ht}function Ge(i){const t=[...i.keyframes].sort((e,s)=>e.time-s.time);return{...i,keyframes:t}}function O(i){return i.targets&&i.targets.length>0?i.targets:[i.target]}function X(i,t,e,s){const n=e??0;return!s||t<=1?n:n+Mt(i,t,s)}class pt{track;targets;constructor(t){this.track=t,this.targets=O(t)}getValueAtTime(t){return this.valueForOffset(t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger),a=this.valueForOffset(t-r);a!==void 0&&s.push({target:this.targets[n],value:a,start:r+this.track.keyframes[0].time})}return s}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const e=t[t.length-1].time,s=this.track.stagger?rt(this.targets.length,this.track.stagger):0;return e+(this.track.delay??0)+s+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:e}=this.track;if(e.length===0)return;if(e.length===1||t<=e[0].time)return e[0].value;if(t>=e[e.length-1].time)return e[e.length-1].value;const{from:s,to:n}=this.findSurroundingKeyframes(t);if(!s||!n)return;if(s.time===t)return s.value;const r=n.time-s.time,a=(t-s.time)/r,c=Se(n.easing)(a);return ze(s.value)(s.value,n.value,c)}findSurroundingKeyframes(t){const{keyframes:e}=this.track;for(let s=0;s<e.length-1;s++)if(t>=e[s].time&&t<=e[s+1].time)return{from:e[s],to:e[s+1]};return{from:null,to:null}}}class Ze{track;targets;sampler;constructor(t){this.track=t,this.targets=O(t),this.sampler=new re(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger);s.push({target:this.targets[n],value:this.sampler.valueAt(t-r),start:r})}return s}getDuration(){const t=this.track.stagger?rt(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class Ke{track;targets;duration;constructor(t){this.track=t,this.targets=O(t),this.duration=Pt(t.inertia)}getValueAtTime(t){return vt(this.track.inertia,t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger);s.push({target:this.targets[n],value:vt(this.track.inertia,t-r),start:r})}return s}getDuration(){const t=this.track.stagger?rt(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function Je(i,t){const e={...xe(i.pathData,t)};if(i.matrix){const[s,n,r,a,o,c]=i.matrix,{x:h,y:u}=e;e.x=s*h+r*u+o,e.y=n*h+a*u+c;const l=e.angle*Math.PI/180,d=Math.cos(l),f=Math.sin(l);e.angle=Math.atan2(n*d+a*f,s*d+r*f)*180/Math.PI}return i.autoRotate&&i.rotateOffset&&(e.angle+=i.rotateOffset),e}const mt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},ti=20;function ei(i){const t=mt[i??"upperCase"]??i??mt.upperCase,e=Array.from(t);return e.length>0?e:Array.from(mt.upperCase)}function ii(i,t,e){let s=(i|0)^Math.imul(t+1,2654435761)^Math.imul(e+1,2246822507);return s=Math.imul(s^s>>>16,2146121005),s=Math.imul(s^s>>>15,2221713035),(s^s>>>16)>>>0}function si(i,t,e=0){const s=i.from??"",n=i.to,r=Math.max(0,Math.min(1,t));if(r<=0)return s;if(r>=1)return n;const a=Array.from(s),o=Array.from(n),c=i.rightToLeft??!1;if(i.mode==="type"){const T=Math.round(r*Math.max(a.length,o.length));return c?a.slice(0,Math.max(0,a.length-T)).join("")+o.slice(Math.max(0,o.length-T)).join(""):o.slice(0,T).join("")+a.slice(T).join("")}const h=Math.max(0,Math.min(.999,i.revealDelay??0)),u=Math.max(0,(r-h)/(1-h)),l=Math.floor(u*o.length),d=i.tweenLength===!1?o.length:Math.round(a.length+(o.length-a.length)*r),f=ei(i.chars),b=i.refreshRate??ti,p=b>0?Math.floor(e*b/1e3):0,y=i.seed??1;let g="";for(let T=0;T<d;T++){const A=c?T>=d-l:T<l,M=c?o[o.length-(d-T)]:o[T];A&&M!==void 0||M===" "||M===`
|
|
2
|
+
`?g+=M:g+=f[ii(y,T,p)%f.length]}return g}class ni{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 e of t.tracks)this.addTrack(e)}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 e={...this._config};delete e.duration,this._config=e}}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 e=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,e)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const e=this.duration;if(e<=0)return;let n=t*this.speed;if(this._repeatDelayRemaining>0){const o=Math.min(this._repeatDelayRemaining,n);if(this._repeatDelayRemaining-=o,n-=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&&n>0&&this._playbackState==="playing";o++)if(this._direction==="forward"){const c=e-this._currentTime;if(n>=c){if(n-=c,this._currentTime=e,!this._handleEndReached())break}else this._currentTime+=n,n=0}else{const c=this._currentTime;if(n>=c){if(n-=c,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=n,n=0}const a=this.getStateAtTime(this._currentTime);this.onUpdate?.(a)}getStateAtTime(t){const e=new Map;if(this._hasSharedWrites())this._resolveShared(t,e);else for(const[s,n]of this._trackPlayers){const r=n.getTrack().property;for(const{target:a,value:o,start:c}of n.getTargetValues(t))this._write(e,s,a,r,o,t-c)}return{values:e,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,e){const s=new Map;for(const[n,r]of this._trackPlayers){const a=r.getTrack().property;for(const{target:o,value:c,start:h}of r.getTargetValues(t)){const u=`${o}\0${a}`,l=h<=t,d=s.get(u);(!d||(l!==d.started?l:l?h>=d.start:h<=d.start))&&s.set(u,{trackId:n,target:o,property:a,value:c,start:h,started:l})}}for(const{trackId:n,target:r,property:a,value:o,start:c}of s.values())this._write(e,n,r,a,o,t-c)}_write(t,e,s,n,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(e);if(c&&typeof r=="number"){o.set("text",si(c.textConfig,r,Math.max(0,a)));return}const h=this._motionPathTracks.get(e);if(h&&typeof r=="number"){const u=Je(h.motionPathConfig,r);o.set("motionPathX",u.x),o.set("motionPathY",u.y),h.motionPathConfig.autoRotate&&o.set("motionPathRotate",u.angle)}else o.set(n,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const e of this._tracks)for(const s of O(e)){const n=`${s}\0${e.property}`;if(t.has(n)){this._sharedWrites=!0;break t}t.add(n)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,st(t)){this._trackPlayers.set(t.id,new Ke(t));return}if(nt(t)){this._trackPlayers.set(t.id,new Ze(t)),this._springTracks.set(t.id,t);return}if(At(t))this._trackPlayers.set(t.id,new pt(t)),this._textTracks.set(t.id,t);else if(ie(t)){const e={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 pt(e)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new pt(t))}replaceTrack(t,e){const s=this._tracks.findIndex(r=>r.id===t);if(s<0)return;const n=this._tracks.slice(s+1);this.removeTrack(t);for(const r of n)this.removeTrack(r.id);this.addTrack(e);for(const r of n)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(e=>e.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(e=>this._matches(e,t))}removeTracks(t={}){const e=this.getTracks(t).map(s=>s.id);for(const s of e)this.removeTrack(s);return e}getTrackSpan(t){const e=this._trackPlayers.get(t);if(!e)return;const s=e.getTrack(),n=s.delay??0;if(nt(s)||st(s))return{from:n,to:e.getDuration()};const r=s.keyframes;if(!(!r||r.length===0))return{from:r[0].time+n,to:e.getDuration()}}findConflicts(){const t=[];for(let e=0;e<this._tracks.length;e++){const s=this._tracks[e],n=this.getTrackSpan(s.id);if(n)for(let r=0;r<e;r++){const a=this._tracks[r];if(a.property!==s.property)continue;const o=O(a).filter(l=>O(s).includes(l));if(o.length===0)continue;const c=this.getTrackSpan(a.id);if(!c||!(c.from<=n.to&&n.from<=c.to))continue;const u=n.from>=c.from;for(const l of o)t.push({target:l,property:s.property,losingTrackId:u?a.id:s.id,winningTrackId:u?s.id:a.id})}}return t}_matches(t,e){if(e.id!==void 0&&t.id!==e.id||e.property!==void 0&&t.property!==e.property||e.target!==void 0&&!O(t).includes(e.target))return!1;if(e.timeRange){const s=this.getTrackSpan(t.id);if(!s||s.to<e.timeRange.from||s.from>e.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:it,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,e)=>t.time-e.time)}setMarkers(t){const e=t&&t.length>0?[...t].sort((n,r)=>n.time-r.time).map(n=>({...n})):void 0,s={...this._config};e?s.markers=e:delete s.markers,this._config=s}get captions(){return this._captions}setCaptions(t){const e={};for(const[s,n]of Object.entries(t??{}))e[s]={...n};this._captions=Object.keys(e).length>0?e:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,e]of this._trackPlayers)t=Math.max(t,e.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 ri=100;function ai(i,t,e,s){const n=[],r=[],{duration:a,alternate:o}=s,c=(f,b,p,y)=>{r.push([f,b]);const g=[];i.forEach((T,A)=>{(p==="forward"?(y?T>=f:T>f)&&T<=b:(y?T<=f:T<f)&&T>=b)&&g.push(A)}),g.sort((T,A)=>(p==="forward"?i[T]-i[A]:i[A]-i[T])||T-A);for(const T of g)n.push({kind:"event",index:T,direction:p})};let h=t.time,u=t.direction,l=t.fresh===!0;const d=Math.min(ri,Math.max(0,e.iteration-t.iteration));for(let f=0;f<d;f++){const b=u==="forward"?a:0;c(h,b,u,l),n.push({kind:"repeat"}),o?(u=u==="forward"?"reverse":"forward",h=b,l=!1):(h=u==="forward"?0:a,l=!0)}return d>0&&s.holding&&!o?{crossings:n,passes:r}:(c(h,e.time,u,l),{crossings:n,passes:r})}function oi(i){return{...i,...Array.isArray(i.end)&&{end:[...i.end]}}}function U(i){const t=i.endDelay;return{...i.delay!==void 0&&{delay:i.delay},...t!==void 0&&{endDelay:t},...i.targets!==void 0&&{targets:[...i.targets]},...i.stagger!==void 0&&{stagger:{...i.stagger}}}}function ci(i){if(st(i)){const t=i;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:oi(t.inertia),...U(t)}}if(nt(i)){const t=i;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...U(t)}}if(At(i)){const t=i;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((e,s)=>e.time-s.time),...U(t)}}if(i.property==="motionPath"&&"motionPathConfig"in i){const t=i,e=[...t.keyframes].sort((s,n)=>s.time-n.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:e,...U(t)}}return Ge({id:i.id,target:i.target,property:i.property,keyframes:i.keyframes,...U(i)})}function K(i){const t=i.formatVersion??1;if(t>it)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${it}. Update tinyfly to play it.`);return new ni({id:i.id,name:i.name,config:i.config,tracks:i.tracks.map(ci),captions:i.captions})}const hi=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),li="#ffffff",ui="rgba(0, 0, 0, 0.5)";function di(i){const t=[];if(i.blur!==void 0&&t.push(`blur(${Math.max(0,i.blur)}px)`),i.brightness!==void 0&&t.push(`brightness(${Math.max(0,i.brightness)})`),i.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,i.glow)}px ${i.glowColor??li})`),i.shadowX!==void 0||i.shadowY!==void 0||i.shadowBlur!==void 0){const e=i.shadowX??0,s=i.shadowY??0,n=Math.max(0,i.shadowBlur??0);t.push(`drop-shadow(${e}px ${s}px ${n}px ${i.shadowColor??ui})`)}return t.length>0?t.join(" "):null}function fi(i,t){const e=i.childNodes.length===1?i.firstChild:null;if(e&&e.nodeType===3){const s=e;s.data!==t&&(s.data=t);return}i.textContent!==t&&(i.textContent=t)}function pi(i){if(!("ownerSVGElement"in i))return;const t=i.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"]),mi=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","motionPathX","motionPathY","motionPathRotate"]),yi=new Set(["originX","originY"]),gi=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Ti=new Set(["drawOn"]),bi={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},Qt={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},Ai="http://www.w3.org/2000/svg";class H{targets=new Map;registerTarget(t,e){this.targets.set(t,e)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[e,s]of t.values){const n=this.targets.get(e);n&&this.applyProperties(n,s)}}applyProperties(t,e){const s=[];let n=null,r=null,a=null;const o=e.has("motionPathX"),c=e.has("motionPathY"),h=e.has("motionPathRotate");for(const[d,f]of e)if(!(d==="x"&&o)&&!(d==="y"&&c)&&!((d==="rotate"||d==="rotateZ")&&h)&&!Ti.has(d)){if(mi.has(d)){const b=this.buildTransformPart(d,f);b&&s.push(b)}else if(yi.has(d))typeof f=="number"&&((n??={})[d]=f);else if(gi.has(d))typeof f=="number"&&((r??={})[d]=f);else if(hi.has(d))(a??={})[d]=f;else if(d!=="perspective"){if(d!=="shine")if(d==="text"&&typeof f=="string")fi(t,f);else if(d==="d"&&typeof f=="string"){const b=t;(b.tagName?.toLowerCase()==="path"?b:b.querySelector?.("path"))?.setAttribute?.("d",f)}else this.applyStyleProperty(t,d,f)}}const u=e.get("shine");typeof u=="number"&&this.applyShine(t,u);const l=e.get("perspective");if(typeof l=="number"&&s.unshift(`perspective(${l}px)`),s.length>0&&(t.style.transform=s.join(" "),pi(t)),n){const d=n.originX??50,f=n.originY??50;t.style.transformOrigin=`${d}% ${f}%`}if(r){const d=r.clipTop??0,f=r.clipRight??0,b=r.clipBottom??0,p=r.clipLeft??0;t.style.clipPath=`inset(${d}% ${f}% ${b}% ${p}%)`}if(a){const d=di(a);d&&(t.style.filter=d)}}buildTransformPart(t,e){if(typeof e!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${e}px)`;case"y":case"motionPathY":return`translateY(${e}px)`;case"z":return`translateZ(${e}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${e}deg)`;case"rotateX":return`rotateX(${e}deg)`;case"rotateY":return`rotateY(${e}deg)`;case"scale":return`scale(${e})`;case"scaleX":return`scaleX(${e})`;case"scaleY":return`scaleY(${e})`;case"scaleZ":return`scaleZ(${e})`;case"skewX":return`skewX(${e}deg)`;case"skewY":return`skewY(${e}deg)`;default:return null}}applyShine(t,e){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const s=t.dataset.shineBase,n=-20+e*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=`${n}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,e,s){let n;if(t.namespaceURI===Ai&&e in Qt){const o=Array.isArray(s)?s.join(", "):String(s);t.style[Qt[e]]=o;return}else e==="fill"&&t.dataset?.elementType==="text"?n="color":n=bi[e]??e;let a;typeof s=="number"?jt.has(e)||jt.has(n)?a=`${s}px`:a=String(s):Array.isArray(s)?a=s.join(", "):a=s,t.style[n]=a}}class yt{media;offset;driftTolerance;constructor(t,e={}){this.media=t,this.offset=e.offset??0,this.driftTolerance=Math.max(0,e.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,e){const s=this.targetTime(t);e?(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 zt(i,t,e,s,n){const r=e-n;if(r<0){t.paused||t.pause(),t.currentTime=0;return}i.update(r,s)}class gt{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,e={}){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=e,this.adapter=new H}async load(t){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(t)}async loadSource(t){let e;if(typeof t=="string"){const s=await fetch(t);if(!s.ok)throw new Error(`Failed to load animation: ${s.statusText}`);e=await s.json()}else e=t;this.useDefinition(e),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(t){const e={...t.config};this.options.speed!==void 0&&(e.speed=this.options.speed),this.options.loop!==void 0&&(e.loop=this.options.loop),this.options.alternate!==void 0&&(e.alternate=this.options.alternate),this.timeline=K({...t,config:e}),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,e={}){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 n=e.initial===void 0?t[0]:t.find(r=>r.id===e.initial);if(!n)throw new Error(`tinyfly: there is no scenario "${e.initial}"`);this.scenarioList=[...t],this.scenarioId=n.id,await this.loadSource(n.timeline)}get scenarios(){return this.scenarioList.map(t=>({id:t.id,label:t.label??t.id}))}get scenario(){return this.scenarioId}setScenario(t){const e=this.scenarioList.find(o=>o.id===t);if(!e||!this.timeline)return!1;if(t===this.scenarioId)return!0;const s=this.isPlaying,n=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=t,this.useDefinition(e.timeline),this.lastMarkerId=null;let a=0;return this.reducedMotion||n?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 e={style:t.getAttribute("style")};t.children.length===0&&(e.text=t.textContent??"");const s=t.tagName.toLowerCase()==="path"?t:t.querySelector("path");s&&(e.path={element:s,d:s.getAttribute("d")}),this.authored.set(t,e)}restoreAuthored(){for(const[t,e]of this.authored){e.style===null?t.removeAttribute("style"):t.setAttribute("style",e.style),e.text!==void 0&&t.textContent!==e.text&&(t.textContent=e.text),e.path&&(e.path.d===null?e.path.element.removeAttribute("d"):e.path.element.setAttribute("d",e.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 e;for(const s of this.markers)if(s.time<=t+.5)e=s;else break;return e}caption(t,e){const s=t?this.markers.find(a=>a.id===t):this.currentMarker;if(!s)return;const n=e??this.language(),r=a=>a?.[n]?.[s.id]??a?.[n.split("-")[0]]?.[s.id];return r(this.options.captions)??r(this.timeline?.captions)??s.label}next(){if(!this.timeline)return;const t=this.currentTime,e=this.markers.find(s=>s.time>t+.5);if(this.reducedMotion){this.seek(e?e.time:this.duration);return}t>=this.duration-.5||(this.stepping=e!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,e=[...this.markers].reverse().find(s=>s.time<t-.5);this.pause(),this.seek(e?e.time:0)}goToMarker(t){const e=this.markers.find(s=>s.id===t);e&&(this.pause(),this.seek(e.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 e=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,e))),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(e=>{for(const s of e)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,e=t?.id;e!==this.lastMarkerId&&(this.lastMarkerId=e,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(e=>{const s=e,n=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:n,sync:new yt(s)})})}syncAllMedia(t,e){for(const s of this.mediaTargets)zt(s.sync,s.el,t,e,s.startTime)}loadFromString(t){const e=JSON.parse(t);this.load(e)}registerTarget(t,e){if(typeof e=="string"){const s=this.container.querySelector(e);s&&(this.rememberAuthored(s),this.targets[t]=s,this.adapter.registerTarget(t,s))}else this.rememberAuthored(e),this.targets[t]=e,this.adapter.registerTarget(t,e)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(e=>{const s=e.closest("[data-tinyfly-symbol]");if(s&&s!==e)return;const n=e.getAttribute("data-tinyfly");n&&this.registerTarget(n,e)}),this.timeline&&new Set(this.timeline.tracks.map(s=>s.target)).forEach(s=>{if(!this.targets[s]){const n=this.container.querySelector(`[data-tinyfly="${s}"]`)||this.container.querySelector(`.${s}`)||this.container.querySelector(`#${s}`);n&&this.registerTarget(s,n)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const e=new Map(t.map(s=>[s.id,s]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const n=s.getAttribute("data-tinyfly-symbol");if(!n)return;const r=e.get(n);if(!r||!r.timeline.tracks?.length)return;const a=new H;s.querySelectorAll("[data-tinyfly]").forEach(o=>{const c=o.getAttribute("data-tinyfly");c&&a.registerTarget(c,o)}),this.symbolInstances.push({adapter:a,timeline:K(r.timeline)})})}attachMedia(t,e){this.mediaSync=new yt(t,e),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=e=>{if(this.isDestroyed||!this.timeline)return;const s=e-(this.lastTime??e);this.lastTime=e;const n=this.playhead;this.timeline.tick(s),this.stopAtMarker(n),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 e=this.timeline,s={time:e.currentTime,iteration:e.loopIteration,direction:e.direction};this.playhead=s;const n=this.markers;if(n.length===0)return;const{crossings:r}=ai(n.map(a=>a.time),t,s,{duration:e.duration,alternate:e.config.alternate===!0,holding:e.repeatDelayRemaining>0});for(const a of r){if(a.kind!=="event")continue;const o=n[a.index];if(this.stepping||o.pause){this.stepping=!1,e.pause(),e.seek(o.time),this.playhead={time:o.time,iteration:e.loopIteration,direction:e.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 e of this.symbolInstances){const s=e.timeline.duration;e.adapter.applyState(e.timeline.getStateAtTime(s>0?t%s:t))}}}async function Si(i,t,e={}){const s=new gt(i,{...e,autoplay:!0});return await s.load(t),s}function Mi(i,t={}){return new gt(i,t)}class Gt{container;containerA;containerB;adapterA;adapterB;timelineA=null;timelineB=null;symbolDefs=new Map;nestedByAdapter=new Map;sequence=null;options;_currentSceneIndex=0;_state="idle";_isPlaying=!1;_isDestroyed=!1;loopIteration=0;animationFrameId;lastTime;transitionTimer;constructor(t,e={}){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=e,this.container.style.position="relative",this.container.style.overflow="hidden",this.containerA=this.createSceneContainer(),this.containerB=this.createSceneContainer(),this.container.appendChild(this.containerA),this.container.appendChild(this.containerB),this.containerB.style.visibility="hidden",this.adapterA=new H,this.adapterB=new H}async load(t){let e;if(typeof t=="string"){const s=await fetch(t);if(!s.ok)throw new Error(`Failed to load sequence: ${s.statusText}`);e=await s.json()}else e=t;this.sequence=e,this.symbolDefs.clear();for(const s of e.symbols??[])s.timeline?.tracks?.length&&this.symbolDefs.set(s.id,s.timeline);this.container.style.width=`${e.canvas.width}px`,this.container.style.height=`${e.canvas.height}px`,e.scenes.length>0&&(this.renderScene(e.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(e.scenes[0])),this.options.autoplay&&this.play()}play(){if(!(!this.sequence||this._isDestroyed)&&this.sequence.scenes.length!==0){if(this._isPlaying=!0,this._state==="idle"){if(this._state="playing-scene",this._currentSceneIndex=0,this.timelineA)this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play();else{this.onSceneComplete();return}this.options.onSceneChange?.(0)}else this._state==="playing-scene"&&this.timelineA&&this.timelineA.play();this.startAnimationLoop()}}pause(){this._isPlaying&&(this._isPlaying=!1,this.timelineA&&this.timelineA.pause(),this.timelineB&&this.timelineB.pause(),this.stopAnimationLoop())}stop(){if(this._isPlaying=!1,this._state="idle",this._currentSceneIndex=0,this.loopIteration=0,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.stopAnimationLoop(),this.sequence&&this.sequence.scenes.length>0&&(this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this.renderScene(this.sequence.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(this.sequence.scenes[0]),this.timelineA)){const t=this.timelineA.getStateAtTime(0);this.adapterA.applyState(t),this.applyNested(this.adapterA,0)}}goToScene(t){if(!this.sequence||t<0||t>=this.sequence.scenes.length)return;const e=this._isPlaying;this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this._currentSceneIndex=t,this._state=e?"playing-scene":"idle",this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB);const s=this.sequence.scenes[t];if(this.renderScene(s,this.containerA,this.adapterA),this.timelineA=this.createTimeline(s),this.options.onSceneChange?.(t),e)this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play(),this.startAnimationLoop()):this.onSceneComplete();else if(this.timelineA){const n=this.timelineA.getStateAtTime(0);this.adapterA.applyState(n),this.applyNested(this.adapterA,0)}}destroy(){this._isDestroyed=!0,this._isPlaying=!1,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.adapterA.clearTargets(),this.adapterB.clearTargets();for(const t of this.nestedByAdapter.values())for(const e of t)e.adapter.clearTargets();this.nestedByAdapter.clear(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.timelineA=null,this.timelineB=null,this.containerA.parentNode&&this.containerA.remove(),this.containerB.parentNode&&this.containerB.remove(),this.sequence=null}get currentSceneIndex(){return this._currentSceneIndex}get sceneCount(){return this.sequence?.scenes.length??0}get isPlaying(){return this._isPlaying}get state(){return this._state}createSceneContainer(){const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t}renderScene(t,e,s){e.innerHTML="",s.clearTargets();const n=document.createElement("div");n.style.cssText="position:absolute;inset:0;transform-origin:center center",n.setAttribute("data-tinyfly","Camera"),e.appendChild(n),s.registerTarget("Camera",n);for(const r of t.elements){if(!r.html)continue;const a=document.createElement("div");a.innerHTML=r.html.trim();const o=a.firstElementChild;if(o){n.appendChild(o);const c=o.getAttribute("data-tinyfly");c&&s.registerTarget(c,o)}}this.setupNested(n,s)}setupNested(t,e){const s=[];t.querySelectorAll("[data-tinyfly-symbol]").forEach(n=>{const r=n.getAttribute("data-tinyfly-symbol");if(!r)return;const a=this.symbolDefs.get(r);if(!a)return;const o=new H;n.querySelectorAll("[data-tinyfly]").forEach(c=>{const h=c.getAttribute("data-tinyfly");h&&o.registerTarget(h,c)}),s.push({adapter:o,timeline:K(a)})}),s.length?this.nestedByAdapter.set(e,s):this.nestedByAdapter.delete(e)}applyNested(t,e){const s=this.nestedByAdapter.get(t);if(s)for(const n of s){const r=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(r>0?e%r:e))}}clearContainer(t){t.innerHTML=""}createTimeline(t){return t.timeline?K(t.timeline):null}onSceneComplete(){if(this._isDestroyed||!this.sequence)return;const t=this._currentSceneIndex+1;if(t>=this.sequence.scenes.length){const e=this.options.loop??this.sequence.loop??0;e===-1||e>0&&this.loopIteration<e-1?(this.loopIteration++,this.beginTransitionTo(0)):(this._isPlaying=!1,this._state="idle",this.stopAnimationLoop(),this.options.onComplete?.())}else this.beginTransitionTo(t)}beginTransitionTo(t){if(!this.sequence||this._isDestroyed)return;const e=this.sequence.scenes[t],s=e.transition;if(s.type==="none"||s.duration<=0){this.switchToScene(t);return}this._state="transitioning",this.containerB.style.visibility="visible",this.renderScene(e,this.containerB,this.adapterB),this.timelineB=this.createTimeline(e),this.timelineB&&this.timelineB.play(),this.applyTransition(s.type,s.duration),this.transitionTimer=window.setTimeout(()=>{this.finishTransition(t)},s.duration)}applyTransition(t,e){const s=`${e}ms`,n="ease-in-out";switch(this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),t){case"fade":this.containerB.style.opacity="0";break;case"slide-left":this.containerB.style.transform="translateX(100%)";break;case"slide-right":this.containerB.style.transform="translateX(-100%)";break;case"slide-up":this.containerB.style.transform="translateY(100%)";break;case"slide-down":this.containerB.style.transform="translateY(-100%)";break}switch(this.containerB.offsetHeight,this.containerA.style.transition=`opacity ${s} ${n}, transform ${s} ${n}`,this.containerB.style.transition=`opacity ${s} ${n}, transform ${s} ${n}`,t){case"fade":this.containerA.style.opacity="0",this.containerB.style.opacity="1";break;case"slide-left":this.containerA.style.transform="translateX(-100%)",this.containerB.style.transform="translateX(0)";break;case"slide-right":this.containerA.style.transform="translateX(100%)",this.containerB.style.transform="translateX(0)";break;case"slide-up":this.containerA.style.transform="translateY(-100%)",this.containerB.style.transform="translateY(0)";break;case"slide-down":this.containerA.style.transform="translateY(100%)",this.containerB.style.transform="translateY(0)";break}}resetTransitionStyles(t){t.style.transition="",t.style.opacity="1",t.style.transform=""}finishTransition(t){this.transitionTimer=void 0,this.timelineA&&(this.timelineA.stop(),this.timelineA=null),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const e=this.containerA;this.containerA=this.containerB,this.containerB=e;const s=this.adapterA;this.adapterA=this.adapterB,this.adapterB=s,this.timelineA=this.timelineB,this.timelineB=null,this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.playbackState!=="playing"&&this.timelineA.play()):this.onSceneComplete()}switchToScene(t){if(!this.sequence||this._isDestroyed)return;this.timelineA&&this.timelineA.stop(),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const e=this.sequence.scenes[t];this.renderScene(e,this.containerA,this.adapterA),this.timelineA=this.createTimeline(e),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play()):this.onSceneComplete()}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=e=>{if(this._isDestroyed||!this._isPlaying)return;const s=e-(this.lastTime??e);if(this.lastTime=e,this.timelineA&&this.timelineA.playbackState==="playing"){this.timelineA.tick(s);const n=this.timelineA.getStateAtTime(this.timelineA.currentTime);this.adapterA.applyState(n),this.applyNested(this.adapterA,this.timelineA.currentTime)}if(this._state==="transitioning"&&this.timelineB&&this.timelineB.playbackState==="playing"){this.timelineB.tick(s);const n=this.timelineB.getStateAtTime(this.timelineB.currentTime);this.adapterB.applyState(n),this.applyNested(this.adapterB,this.timelineB.currentTime)}this._isPlaying?this.animationFrameId=requestAnimationFrame(t):this.animationFrameId=void 0};this.animationFrameId=requestAnimationFrame(t)}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}}async function _i(i,t,e={}){const s=new Gt(i,{...e,autoplay:!0});return await s.load(t),s}const ki={type:"none",duration:0};R.DEFAULT_TRANSITION=ki,R.MediaSync=yt,R.TinyflyPlayer=gt,R.TinyflySequencer=Gt,R.create=Mi,R.play=Si,R.playSequence=_i,R.syncMediaElement=zt,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(v,Y){typeof exports=="object"&&typeof module<"u"?Y(exports):typeof define=="function"&&define.amd?define(["exports"],Y):(v=typeof globalThis<"u"?globalThis:v||self,Y(v.tinyfly=v.tinyfly||{}))})(this,(function(v){"use strict";function Y(i){return typeof i=="object"&&i!==null&&i.type==="cubic-bezier"}function ee(i){return typeof i=="object"&&i!==null&&i.type!=="cubic-bezier"}const st=1;function St(i){return i.property==="text"&&"textConfig"in i}function nt(i){return i.kind==="inertia"&&"inertia"in i}function rt(i){return i.kind==="spring"&&"spring"in i}function ie(i){return i.property==="motionPath"&&"motionPathConfig"in i}function Mt(i,t,e="start"){if(t<=1)return 0;if(typeof e=="number"){const s=Math.max(0,Math.min(t-1,e));return Math.abs(i-s)}switch(e){case"end":return t-1-i;case"center":return Math.abs(i-(t-1)/2);case"edges":return(t-1)/2-Math.abs(i-(t-1)/2);default:return i}}function se(i,t="start"){if(i<=1)return 0;let e=0;for(let s=0;s<i;s++)e=Math.max(e,Mt(s,i,t));return e}function _t(i,t,e){if(e.offsets)return e.offsets[i]??0;const s=e.from??"start",n=Mt(i,t,s);if(e.amount!==void 0){const r=se(t,s);return r===0?0:e.amount*n/r}return e.each!==void 0?e.each*n:0}function ne(i,t){return Array.from({length:i},(e,s)=>_t(s,i,t))}function at(i,t){return i<=1?0:Math.max(...ne(i,t))}const N=1,kt=6e4,z=kt/N,F={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1};class re{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??F.stiffness,this.damping=t.damping??F.damping,this.mass=t.mass??F.mass,this.restDelta=t.restDelta??F.restDelta,this.restSpeed=t.restSpeed??F.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??F.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 e=Math.floor(t/N);if(this.simulateTo(e+1),this.settledStep!==null&&e>=this.settledStep)return this.to;const s=this.samples[Math.min(e,this.samples.length-1)],n=this.samples[Math.min(e+1,this.samples.length-1)],r=t/N-e;return s+(n-s)*r}settleTime(){return this.simulateTo(z+1),this.settledStep!==null?this.settledStep*N:kt}simulateTo(t){if(this.settledStep!==null)return;const e=Math.min(t,z+1),s=N/1e3;for(;this.samples.length<e;){const n=this.samples[this.samples.length-1],r=n-this.to,a=-this.stiffness*r,o=-this.damping*this.velocity,c=(a+o)/this.mass;this.velocity+=c*s;const h=n+this.velocity*s;if(this.samples.push(h),this.isAtRest(h)){this.settledStep=this.samples.length-1;return}}this.samples.length>z&&(this.settledStep=z)}}const wt=4,ae=.002,oe=1e-4,ce=6e4;function ot(i){const t=i.friction??wt;return t>0?t:wt}function he(i){return i.from+i.velocity/ot(i)}function le(i,t){if(t===void 0)return i;if(typeof t=="number")return t>0?Math.round(i/t)*t:i;if(t.length===0)return i;let e=t[0];for(const s of t)Math.abs(s-i)<Math.abs(e-i)&&(e=s);return e}function Pt(i){let t=le(he(i),i.end);return i.min!==void 0&&(t=Math.max(i.min,t)),i.max!==void 0&&(t=Math.min(i.max,t)),t}function vt(i){const t=Math.abs(Pt(i)-i.from);if(t===0)return 0;const e=i.restDelta??Math.max(oe,t*ae);if(e>=t)return 0;const s=Math.log(t/e)/ot(i);return Math.min(ce,s*1e3)}function It(i,t){if(t<=0)return i.from;const e=Pt(i);if(t>=vt(i))return e;const s=ot(i);return i.from+(e-i.from)*(1-Math.exp(-s*t/1e3))}const ct=i=>i,ue=i=>i*i,de=i=>1-(1-i)*(1-i),fe=i=>i<.5?2*i*i:1-Math.pow(-2*i+2,2)/2,xt=i=>i*i*i,Ct=i=>1-Math.pow(1-i,3),Rt=i=>i<.5?4*i*i*i:1-Math.pow(-2*i+2,3)/2,pe={linear:ct,"ease-in":xt,"ease-out":Ct,"ease-in-out":Rt,"ease-in-quad":ue,"ease-out-quad":de,"ease-in-out-quad":fe,"ease-in-cubic":xt,"ease-out-cubic":Ct,"ease-in-out-cubic":Rt};function me(i){const[t,e,s,n]=i,r=3*t,a=3*(s-t)-r,o=1-r-a,c=3*e,h=3*(n-e)-c,u=1-c-h,l=p=>((o*p+a)*p+r)*p,d=p=>((u*p+h)*p+c)*p,f=p=>(3*o*p+2*a)*p+r,b=p=>{let y=p;for(let A=0;A<8;A++){const M=l(y)-p;if(Math.abs(M)<1e-7)return y;const m=f(y);if(Math.abs(m)<1e-7)break;y-=M/m}let g=0,T=1;for(y=p;g<T;){const A=l(y);if(Math.abs(A-p)<1e-7)return y;p>A?g=y:T=y,y=(g+T)/2}return y};return p=>{if(p<=0)return 0;if(p>=1)return 1;const y=b(p);return d(y)}}function ht(i,t="out"){if(t==="out")return i;const e=s=>1-i(1-s);return t==="in"?e:s=>s<.5?e(s*2)/2:i(s*2-1)/2+.5}function ye(i=1,t=.3){const e=Math.max(1,i),s=t/(2*Math.PI)*Math.asin(1/e);return n=>n<=0?0:n>=1?1:e*Math.pow(2,-10*n)*Math.sin((n-s)*(2*Math.PI)/t)+1}const ge=i=>{if(i<=0)return 0;if(i>=1)return 1;if(i<1/2.75)return 7.5625*i*i;if(i<2/2.75){const n=i-.5454545454545454;return 7.5625*n*n+.75}if(i<2.5/2.75){const n=i-.8181818181818182;return 7.5625*n*n+.9375}const s=i-2.625/2.75;return 7.5625*s*s+.984375};function Te(i=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const e=t-1;return e*e*((i+1)*e+i)+1}}function be(i,t="end"){const e=Math.max(1,Math.floor(i));return s=>{if(s>=1)return 1;if(s<=0)return t==="start"||t==="both"?t==="start"?1/e:1/(e+1):0;const n=Math.floor(s*e);switch(t){case"start":return Math.min(1,(n+1)/e);case"both":return(n+1)/(e+1);case"none":return e===1?0:Math.min(1,n/(e-1));default:return n/e}}}function Ae(i){switch(i.type){case"steps":return be(i.count,i.position);case"elastic":return ht(ye(i.amplitude,i.period),i.mode);case"bounce":return ht(ge,i.mode);case"back":return ht(Te(i.overshoot),i.mode)}}function Se(i){return i===void 0?ct:Y(i)?me(i.points):ee(i)?Ae(i):pe[i]??ct}const Dt=32,Me=256,V=new Map,_e=/[MmLlHhVvCcSsQqTtAaZz]/,ke=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,we={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Pe(i){const t=[];let e=0,s=null;const n=()=>{for(;e<i.length&&/[\s,]/.test(i[e]);)e++};for(;e<i.length&&(n(),!(e>=i.length));){const r=i[e];if(_e.test(r)){s={type:r,args:[]},t.push(s),e++;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),e++;continue}const c=ke.exec(i.slice(e));if(!c)break;s.args.push(parseFloat(c[0])),e+=c[0].length}return t}function ve(i,t,e,s,n,r,a,o,c){if(i===o&&t===c)return[];let h=Math.abs(e),u=Math.abs(s);if(h===0||u===0)return[[i,t,o,c,o,c]];const l=n*Math.PI/180,d=Math.cos(l),f=Math.sin(l),b=(i-o)/2,p=(t-c)/2,y=d*b+f*p,g=-f*b+d*p,T=y*y/(h*h)+g*g/(u*u);if(T>1){const w=Math.sqrt(T);h*=w,u*=w}const A=r===a?-1:1,M=h*h*u*u-h*h*g*g-u*u*y*y,m=h*h*g*g+u*u*y*y,_=A*Math.sqrt(Math.max(0,M/m)),S=_*h*g/u,B=-_*u*y/h,tt=d*S-f*B+(i+o)/2,k=f*S+d*B+(t+c)/2,C=(w,x,R,q)=>{const At=w*R+x*q,it=Math.sqrt((w*w+x*x)*(R*R+q*q)),Q=Math.acos(Math.max(-1,Math.min(1,At/it)));return w*q-x*R<0?-Q:Q},P=C(1,0,(y-S)/h,(g-B)/u);let I=C((y-S)/h,(g-B)/u,(-y-S)/h,(-g-B)/u);!a&&I>0&&(I-=2*Math.PI),a&&I<0&&(I+=2*Math.PI);const $=Math.max(1,Math.ceil(Math.abs(I)/(Math.PI/2))),bt=I/$,et=4/3*Math.tan(bt/4),Kt=w=>{const x=h*Math.cos(w),R=u*Math.sin(w);return[d*x-f*R+tt,f*x+d*R+k]},Jt=w=>{const x=-h*Math.sin(w),R=u*Math.cos(w);return[d*x-f*R,f*x+d*R]},te=[];for(let w=0;w<$;w++){const x=P+w*bt,R=x+bt,[q,At]=Kt(x),[it,Q]=w===$-1?[o,c]:Kt(R),[ki,wi]=Jt(x),[Pi,vi]=Jt(R);te.push([q+et*ki,At+et*wi,it-et*Pi,Q-et*vi,it,Q])}return te}function E(i,t,e,s,n){const r=1-n;return r*r*r*i+3*r*r*n*t+3*r*n*n*e+n*n*n*s}function Bt(i,t,e,s,n){const r=1-n;return 3*r*r*(t-i)+6*r*n*(e-t)+3*n*n*(s-e)}function W(i,t,e,s){return{subpath:0,type:"L",points:[e,s],startX:i,startY:t,endX:e,endY:s,length:Math.hypot(e-i,s-t)}}function G(i,t,e){const[s,n,r,a,o,c]=e,h=[0];let u=i,l=t,d=0;for(let f=1;f<=Dt;f++){const b=f/Dt,p=E(i,s,r,o,b),y=E(t,n,a,c,b);d+=Math.hypot(p-u,y-l),h.push(d),u=p,l=y}return{subpath:0,type:"C",points:[s,n,r,a,o,c],startX:i,startY:t,endX:o,endY:c,length:d,lengths:h}}function Z(i){const t=V.get(i);if(t)return t;const e=[];let s=0,n=0,r=0,a=0,o=null,c=null,h=-1;const u=new Set,l=p=>{h<0&&(h=0),p.subpath=h,e.push(p)};for(const{type:p,args:y}of Pe(i)){const g=p.toUpperCase(),T=p!==g,A=we[g];if(g==="Z"){(s!==r||n!==a)&&l(W(s,n,r,a)),h>=0&&u.add(h),s=r,n=a,o=c=null;continue}for(let M=0;M+A<=y.length;M+=A){const m=y.slice(M,M+A),_=T?s:0,S=T?n:0;let B=null,tt=null;switch(g){case"M":M===0?(s=m[0]+_,n=m[1]+S,r=s,a=n,(h<0||e[e.length-1]?.subpath===h)&&h++):(l(W(s,n,m[0]+_,m[1]+S)),s=m[0]+_,n=m[1]+S);break;case"L":l(W(s,n,m[0]+_,m[1]+S)),s=m[0]+_,n=m[1]+S;break;case"H":l(W(s,n,m[0]+_,n)),s=m[0]+_;break;case"V":l(W(s,n,s,m[0]+S)),n=m[0]+S;break;case"C":{const k=[m[0]+_,m[1]+S,m[2]+_,m[3]+S,m[4]+_,m[5]+S];l(G(s,n,k)),B=[k[2],k[3]],s=k[4],n=k[5];break}case"S":{const[k,C]=o?[2*s-o[0],2*n-o[1]]:[s,n],P=[k,C,m[0]+_,m[1]+S,m[2]+_,m[3]+S];l(G(s,n,P)),B=[P[2],P[3]],s=P[4],n=P[5];break}case"Q":case"T":{let k=s,C=n;g==="Q"?(k=m[0]+_,C=m[1]+S):c&&(k=2*s-c[0],C=2*n-c[1]);const P=g==="Q"?m[2]+_:m[0]+_,I=g==="Q"?m[3]+S:m[1]+S;l(G(s,n,[s+2/3*(k-s),n+2/3*(C-n),P+2/3*(k-P),I+2/3*(C-I),P,I])),tt=[k,C],s=P,n=I;break}case"A":{const k=m[5]+_,C=m[6]+S;let P=s,I=n;for(const $ of ve(s,n,m[0],m[1],m[2],m[3],m[4],k,C))l(G(P,I,$)),P=$[4],I=$[5];s=k,n=C;break}}o=B,c=tt}}const d=e.reduce((p,y)=>p+y.length,0),f=[];for(let p=0;p<e.length;){const y=e[p].subpath;let g=p,T=0;for(;g<e.length&&e[g].subpath===y;)T+=e[g++].length;const A=e[p],M=e[g-1],m=u.has(y)||Math.abs(M.endX-A.startX)<1e-9&&Math.abs(M.endY-A.startY)<1e-9;f.push({start:p,end:g,length:T,closed:m}),p=g}const b={segments:e,totalLength:d,subpaths:f};return V.size>=Me&&V.delete(V.keys().next().value),V.set(i,b),b}function Ie(i,t){const e=i.lengths;if(t<=0)return 0;if(t>=i.length)return 1;let s=0,n=e.length-1;for(;s<n-1;){const o=s+n>>1;e[o]<t?s=o:n=o}const r=e[n]-e[s],a=r>0?(t-e[s])/r:0;return(s+a)/(e.length-1)}function xe(i,t){if(i.type==="L"){const l=i.length>0?Math.max(0,Math.min(1,t/i.length)):0;return{x:i.startX+(i.endX-i.startX)*l,y:i.startY+(i.endY-i.startY)*l,angle:Math.atan2(i.endY-i.startY,i.endX-i.startX)*180/Math.PI}}const[e,s,n,r,a,o]=i.points,c=Ie(i,t);let h=Bt(i.startX,e,n,a,c),u=Bt(i.startY,s,r,o,c);if(Math.hypot(h,u)<1e-9){const l=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),d=E(i.startX,e,n,a,l),f=E(i.startY,s,r,o,l),b=E(i.startX,e,n,a,c),p=E(i.startY,s,r,o,c);h=c<.5?d-b:b-d,u=c<.5?f-p:p-f}return{x:E(i.startX,e,n,a,c),y:E(i.startY,s,r,o,c),angle:Math.atan2(u,h)*180/Math.PI}}function Et(i,t,e=0,s=i.length){if(s<=e)return{x:0,y:0,angle:0};let n=0;for(let r=e;r<s;r++){const a=i[r];if(n+a.length>=t||r===s-1)return xe(a,t-n);n+=a.length}return{x:0,y:0,angle:0}}function Ce(i,t){const{segments:e,totalLength:s}=Z(i);return Et(e,Math.max(0,Math.min(1,t))*s)}const Re=24,De=320,Be=2.5,U=72,Ee=.2,Le=128,K=new Map;let lt=0,L;const Lt=i=>Math.round(i*100)/100;function Ot(i,t){const{segments:e,subpaths:s,totalLength:n}=Z(i);if(e.length===0)return[];if(t){const r=s.every(a=>a.closed);return[{segments:e,start:0,end:e.length,length:n,closed:r}]}return s.filter(r=>r.length>0).map(r=>({segments:e,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function ut(i,t){const e=i.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),s=Et(i.segments,e*i.length,i.start,i.end);return[s.x,s.y]}function $t(i){const t=[];let e=0;for(let s=i.start;s<i.end;s++)e+=i.segments[s].length,i.length>0&&t.push(e/i.length);return t}function Ft(i,t){const e=[];for(let s=0;s<t;s++)e.push(ut(i,i.closed?s/t:s/(t-1)));return e}function Xt(i){let t=0,e=0;for(const[s,n]of i)t+=s,e+=n;return t/=i.length,e/=i.length,i.map(([s,n])=>[s-t,n-e])}function Oe(i,t,e){const s=i.closed&&t.closed;if(e!==void 0)return{offset:s?Math.abs(e)%U/U:0,reversed:e<0};const n=Xt(Ft(i,U)),r=Xt(Ft(t,U)),a=U;let o={offset:0,reversed:!1},c=1/0;for(const h of[!1,!0]){const u=s?a:1;for(let l=0;l<u;l++){let d=0;for(let f=0;f<a&&d<c;f++){const b=s?h?(l-f+a)%a:(f+l)%a:h?a-1-f:f,p=n[f][0]-r[b][0],y=n[f][1]-r[b][1];d+=p*p+y*y}d<c&&(c=d,o={offset:s?l/a:0,reversed:h})}}return o}function $e(i,t,e){return e?((t.reversed?t.offset-i:i+t.offset)%1+1)%1:t.reversed?1-i:i}function Fe(i,t,e){return e?((t.reversed?t.offset-i:i-t.offset)%1+1)%1:t.reversed?1-i:i}function Xe(i,t,e){const s=i.closed&&t.closed,n=Oe(i,t,e.shapeIndex),r=Math.max(Re,Math.min(De,Math.ceil(Math.max(i.length,t.length)/Be))),a=new Set,o=l=>a.add(Math.round(l*1e7)/1e7);for(let l=0;l<=r;l++)o(l/r);for(const l of $t(i))o(l);for(const l of $t(t))o(Fe(l,n,s));let c=[...a].sort((l,d)=>l-d);s&&(c=c.filter(l=>l<1));const h=[],u=[];for(const l of c)h.push(...ut(i,l)),u.push(...ut(t,$e(l,n,s)));return qe({from:h,to:u,closed:s})}function qe(i){const t=i.from.length/2;if(t<=3)return i;const e=new Uint8Array(t);e[0]=1,e[t-1]=1;const s=[[0,t-1]];for(;s.length>0;){const[a,o]=s.pop();let c=-1,h=Ee;for(let u=a+1;u<o;u++){const l=Math.max(qt(i.from,a,o,u),qt(i.to,a,o,u));l>h&&(h=l,c=u)}c!==-1&&(e[c]=1,s.push([a,c],[c,o]))}const n=[],r=[];for(let a=0;a<t;a++)e[a]&&(n.push(i.from[a*2],i.from[a*2+1]),r.push(i.to[a*2],i.to[a*2+1]));return{from:n,to:r,closed:i.closed}}function qt(i,t,e,s){const n=i[t*2],r=i[t*2+1],a=i[e*2]-n,o=i[e*2+1]-r,c=i[s*2]-n,h=i[s*2+1]-r,u=a*a+o*o,l=u===0?0:Math.max(0,Math.min(1,(c*a+h*o)/u));return Math.hypot(c-l*a,h-l*o)}function Ye(i,t,e){const s=e.shapeIndex;if(L&&L.from===i&&L.to===t&&L.shapeIndex===s)return L.plan;const r=K.get(String(s??"auto"))?.get(i)?.get(t);if(r)return L={from:i,to:t,shapeIndex:s,plan:r},r;const a=Z(i).subpaths.filter(f=>f.length>0).length===Z(t).subpaths.filter(f=>f.length>0).length,o=Ot(i,!a),c=Ot(t,!a),h={pairs:o.map((f,b)=>Xe(f,c[b],e))};lt>=Le&&(K.clear(),lt=0);const u=String(s??"auto"),l=K.get(u)??new Map;K.set(u,l);const d=l.get(i)??new Map;return l.set(i,d),d.set(t,h),lt++,L={from:i,to:t,shapeIndex:s,plan:h},h}function Ne(i,t,e,s={}){if(!i)return t;if(!t)return i;const n=Math.max(0,Math.min(1,e));if(n===0)return i;if(n===1)return t;const r=Ye(i,t,s);if(r.pairs.length===0)return n<.5?i:t;let a="";for(const o of r.pairs){for(let c=0;c<o.from.length;c+=2){const h=Lt(o.from[c]+(o.to[c]-o.from[c])*n),u=Lt(o.from[c+1]+(o.to[c+1]-o.from[c+1])*n);a+=`${c===0?a?" M":"M":" L"}${h} ${u}`}o.closed&&(a+=" Z")}return a}function Ve(i){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(i)}const D=(i,t,e)=>i+(t-i)*e,Yt=512,dt=new Map,ft=new Map;function Nt(i){const t=dt.get(i);if(t)return t;const e=i.replace("#",""),s=[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return dt.size<Yt&&dt.set(i,s),s}const Vt=i=>i.charCodeAt(0)===35,Wt=i=>i.startsWith("rgb"),Ut=i=>i.startsWith("rgba"),We=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,pt=i=>Math.round(i).toString(16).padStart(2,"0");function Ue(i,t,e){return`#${pt(i)}${pt(t)}${pt(e)}`}function Ht(i){const t=ft.get(i);if(t)return t;const e=i.match(We);if(!e)throw new Error(`Invalid rgb color: ${i}`);const s=parseInt(e[1],10),n=parseInt(e[2],10),r=parseInt(e[3],10),a=e[4]!==void 0?[s,n,r,parseFloat(e[4])]:[s,n,r];return ft.size<Yt&&ft.set(i,a),a}const He=(i,t,e)=>{if(Vt(i)&&Vt(t)){const[s,n,r]=Nt(i),[a,o,c]=Nt(t),h=D(s,a,e),u=D(n,o,e),l=D(r,c,e);return Ue(h,u,l)}if((Wt(i)||Ut(i))&&(Wt(t)||Ut(t))){const s=Ht(i),n=Ht(t),r=Math.round(D(s[0],n[0],e)),a=Math.round(D(s[1],n[1],e)),o=Math.round(D(s[2],n[2],e));if(s.length===4||n.length===4){const c=s[3]??1,h=n[3]??1,u=D(c,h,e);return`rgba(${r}, ${a}, ${o}, ${u})`}return`rgb(${r}, ${a}, ${o})`}return e<1?i:t},je=(i,t,e)=>{const s=Math.min(i.length,t.length),n=[];for(let r=0;r<s;r++)n.push(D(i[r],t[r],e));return n},jt=(i,t,e)=>e<1?i:t,Qe=(i,t,e)=>Ne(i,t,e);function ze(i){return typeof i=="number"?D:Array.isArray(i)?je:typeof i=="string"?i.startsWith("#")||i.startsWith("rgb")?He:Ve(i)?Qe:jt:jt}function Ge(i){const t=[...i.keyframes].sort((e,s)=>e.time-s.time);return{...i,keyframes:t}}function O(i){return i.targets&&i.targets.length>0?i.targets:[i.target]}function X(i,t,e,s){const n=e??0;return!s||t<=1?n:n+_t(i,t,s)}class mt{track;targets;constructor(t){this.track=t,this.targets=O(t)}getValueAtTime(t){return this.valueForOffset(t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger),a=this.valueForOffset(t-r);a!==void 0&&s.push({target:this.targets[n],value:a,start:r+this.track.keyframes[0].time})}return s}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const e=t[t.length-1].time,s=this.track.stagger?at(this.targets.length,this.track.stagger):0;return e+(this.track.delay??0)+s+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:e}=this.track;if(e.length===0)return;if(e.length===1||t<=e[0].time)return e[0].value;if(t>=e[e.length-1].time)return e[e.length-1].value;const{from:s,to:n}=this.findSurroundingKeyframes(t);if(!s||!n)return;if(s.time===t)return s.value;const r=n.time-s.time,a=(t-s.time)/r,c=Se(n.easing)(a);return ze(s.value)(s.value,n.value,c)}findSurroundingKeyframes(t){const{keyframes:e}=this.track;for(let s=0;s<e.length-1;s++)if(t>=e[s].time&&t<=e[s+1].time)return{from:e[s],to:e[s+1]};return{from:null,to:null}}}class Ze{track;targets;sampler;constructor(t){this.track=t,this.targets=O(t),this.sampler=new re(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger);s.push({target:this.targets[n],value:this.sampler.valueAt(t-r),start:r})}return s}getDuration(){const t=this.track.stagger?at(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class Ke{track;targets;duration;constructor(t){this.track=t,this.targets=O(t),this.duration=vt(t.inertia)}getValueAtTime(t){return It(this.track.inertia,t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger);s.push({target:this.targets[n],value:It(this.track.inertia,t-r),start:r})}return s}getDuration(){const t=this.track.stagger?at(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function Je(i,t){const e={...Ce(i.pathData,t)};if(i.matrix){const[s,n,r,a,o,c]=i.matrix,{x:h,y:u}=e;e.x=s*h+r*u+o,e.y=n*h+a*u+c;const l=e.angle*Math.PI/180,d=Math.cos(l),f=Math.sin(l);e.angle=Math.atan2(n*d+a*f,s*d+r*f)*180/Math.PI}return i.autoRotate&&i.rotateOffset&&(e.angle+=i.rotateOffset),e}const yt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},ti=20;function ei(i){const t=yt[i??"upperCase"]??i??yt.upperCase,e=Array.from(t);return e.length>0?e:Array.from(yt.upperCase)}function ii(i,t,e){let s=(i|0)^Math.imul(t+1,2654435761)^Math.imul(e+1,2246822507);return s=Math.imul(s^s>>>16,2146121005),s=Math.imul(s^s>>>15,2221713035),(s^s>>>16)>>>0}function si(i,t,e=0){const s=i.from??"",n=i.to,r=Math.max(0,Math.min(1,t));if(r<=0)return s;if(r>=1)return n;const a=Array.from(s),o=Array.from(n),c=i.rightToLeft??!1;if(i.mode==="type"){const T=Math.round(r*Math.max(a.length,o.length));return c?a.slice(0,Math.max(0,a.length-T)).join("")+o.slice(Math.max(0,o.length-T)).join(""):o.slice(0,T).join("")+a.slice(T).join("")}const h=Math.max(0,Math.min(.999,i.revealDelay??0)),u=Math.max(0,(r-h)/(1-h)),l=Math.floor(u*o.length),d=i.tweenLength===!1?o.length:Math.round(a.length+(o.length-a.length)*r),f=ei(i.chars),b=i.refreshRate??ti,p=b>0?Math.floor(e*b/1e3):0,y=i.seed??1;let g="";for(let T=0;T<d;T++){const A=c?T>=d-l:T<l,M=c?o[o.length-(d-T)]:o[T];A&&M!==void 0||M===" "||M===`
|
|
2
|
-
`?g+=M:g+=f[ii(y,T,p)%f.length]}return g}class ni{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 e of t.tracks)this.addTrack(e)}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 e={...this._config};delete e.duration,this._config=e}}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 e=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,e)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const e=this.duration;if(e<=0)return;let n=t*this.speed;if(this._repeatDelayRemaining>0){const o=Math.min(this._repeatDelayRemaining,n);if(this._repeatDelayRemaining-=o,n-=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&&n>0&&this._playbackState==="playing";o++)if(this._direction==="forward"){const c=e-this._currentTime;if(n>=c){if(n-=c,this._currentTime=e,!this._handleEndReached())break}else this._currentTime+=n,n=0}else{const c=this._currentTime;if(n>=c){if(n-=c,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=n,n=0}const a=this.getStateAtTime(this._currentTime);this.onUpdate?.(a)}getStateAtTime(t){const e=new Map;if(this._hasSharedWrites())this._resolveShared(t,e);else for(const[s,n]of this._trackPlayers){const r=n.getTrack().property;for(const{target:a,value:o,start:c}of n.getTargetValues(t))this._write(e,s,a,r,o,t-c)}return{values:e,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,e){const s=new Map;for(const[n,r]of this._trackPlayers){const a=r.getTrack().property;for(const{target:o,value:c,start:h}of r.getTargetValues(t)){const u=`${o}\0${a}`,l=h<=t,d=s.get(u);(!d||(l!==d.started?l:l?h>=d.start:h<=d.start))&&s.set(u,{trackId:n,target:o,property:a,value:c,start:h,started:l})}}for(const{trackId:n,target:r,property:a,value:o,start:c}of s.values())this._write(e,n,r,a,o,t-c)}_write(t,e,s,n,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(e);if(c&&typeof r=="number"){o.set("text",si(c.textConfig,r,Math.max(0,a)));return}const h=this._motionPathTracks.get(e);if(h&&typeof r=="number"){const u=Je(h.motionPathConfig,r);o.set("motionPathX",u.x),o.set("motionPathY",u.y),h.motionPathConfig.autoRotate&&o.set("motionPathRotate",u.angle)}else o.set(n,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const e of this._tracks)for(const s of O(e)){const n=`${s}\0${e.property}`;if(t.has(n)){this._sharedWrites=!0;break t}t.add(n)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,nt(t)){this._trackPlayers.set(t.id,new Ke(t));return}if(rt(t)){this._trackPlayers.set(t.id,new Ze(t)),this._springTracks.set(t.id,t);return}if(St(t))this._trackPlayers.set(t.id,new mt(t)),this._textTracks.set(t.id,t);else if(ie(t)){const e={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 mt(e)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new mt(t))}replaceTrack(t,e){const s=this._tracks.findIndex(r=>r.id===t);if(s<0)return;const n=this._tracks.slice(s+1);this.removeTrack(t);for(const r of n)this.removeTrack(r.id);this.addTrack(e);for(const r of n)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(e=>e.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(e=>this._matches(e,t))}removeTracks(t={}){const e=this.getTracks(t).map(s=>s.id);for(const s of e)this.removeTrack(s);return e}getTrackSpan(t){const e=this._trackPlayers.get(t);if(!e)return;const s=e.getTrack(),n=s.delay??0;if(rt(s)||nt(s))return{from:n,to:e.getDuration()};const r=s.keyframes;if(!(!r||r.length===0))return{from:r[0].time+n,to:e.getDuration()}}findConflicts(){const t=[];for(let e=0;e<this._tracks.length;e++){const s=this._tracks[e],n=this.getTrackSpan(s.id);if(n)for(let r=0;r<e;r++){const a=this._tracks[r];if(a.property!==s.property)continue;const o=O(a).filter(l=>O(s).includes(l));if(o.length===0)continue;const c=this.getTrackSpan(a.id);if(!c||!(c.from<=n.to&&n.from<=c.to))continue;const u=n.from>=c.from;for(const l of o)t.push({target:l,property:s.property,losingTrackId:u?a.id:s.id,winningTrackId:u?s.id:a.id})}}return t}_matches(t,e){if(e.id!==void 0&&t.id!==e.id||e.property!==void 0&&t.property!==e.property||e.target!==void 0&&!O(t).includes(e.target))return!1;if(e.timeRange){const s=this.getTrackSpan(t.id);if(!s||s.to<e.timeRange.from||s.from>e.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:st,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,e)=>t.time-e.time)}setMarkers(t){const e=t&&t.length>0?[...t].sort((n,r)=>n.time-r.time).map(n=>({...n})):void 0,s={...this._config};e?s.markers=e:delete s.markers,this._config=s}get captions(){return this._captions}setCaptions(t){const e={};for(const[s,n]of Object.entries(t??{}))e[s]={...n};this._captions=Object.keys(e).length>0?e:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,e]of this._trackPlayers)t=Math.max(t,e.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 ri=100;function ai(i,t,e,s){const n=[],r=[],{duration:a,alternate:o}=s,c=(f,b,p,y)=>{r.push([f,b]);const g=[];i.forEach((T,A)=>{(p==="forward"?(y?T>=f:T>f)&&T<=b:(y?T<=f:T<f)&&T>=b)&&g.push(A)}),g.sort((T,A)=>(p==="forward"?i[T]-i[A]:i[A]-i[T])||T-A);for(const T of g)n.push({kind:"event",index:T,direction:p})};let h=t.time,u=t.direction,l=t.fresh===!0;const d=Math.min(ri,Math.max(0,e.iteration-t.iteration));for(let f=0;f<d;f++){const b=u==="forward"?a:0;c(h,b,u,l),n.push({kind:"repeat"}),o?(u=u==="forward"?"reverse":"forward",h=b,l=!1):(h=u==="forward"?0:a,l=!0)}return d>0&&s.holding&&!o?{crossings:n,passes:r}:(c(h,e.time,u,l),{crossings:n,passes:r})}function oi(i){return{...i,...Array.isArray(i.end)&&{end:[...i.end]}}}function H(i){const t=i.endDelay;return{...i.delay!==void 0&&{delay:i.delay},...t!==void 0&&{endDelay:t},...i.targets!==void 0&&{targets:[...i.targets]},...i.stagger!==void 0&&{stagger:{...i.stagger}}}}function ci(i){if(nt(i)){const t=i;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:oi(t.inertia),...H(t)}}if(rt(i)){const t=i;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...H(t)}}if(St(i)){const t=i;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((e,s)=>e.time-s.time),...H(t)}}if(i.property==="motionPath"&&"motionPathConfig"in i){const t=i,e=[...t.keyframes].sort((s,n)=>s.time-n.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:e,...H(t)}}return Ge({id:i.id,target:i.target,property:i.property,keyframes:i.keyframes,...H(i)})}function J(i){const t=i.formatVersion??1;if(t>st)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${st}. Update tinyfly to play it.`);return new ni({id:i.id,name:i.name,config:i.config,tracks:i.tracks.map(ci),captions:i.captions})}const hi=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),li="#ffffff",ui="rgba(0, 0, 0, 0.5)";function di(i){const t=[];if(i.blur!==void 0&&t.push(`blur(${Math.max(0,i.blur)}px)`),i.brightness!==void 0&&t.push(`brightness(${Math.max(0,i.brightness)})`),i.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,i.glow)}px ${i.glowColor??li})`),i.shadowX!==void 0||i.shadowY!==void 0||i.shadowBlur!==void 0){const e=i.shadowX??0,s=i.shadowY??0,n=Math.max(0,i.shadowBlur??0);t.push(`drop-shadow(${e}px ${s}px ${n}px ${i.shadowColor??ui})`)}return t.length>0?t.join(" "):null}function fi(i,t){const e=i.childNodes.length===1?i.firstChild:null;if(e&&e.nodeType===3){const s=e;s.data!==t&&(s.data=t);return}i.textContent!==t&&(i.textContent=t)}function pi(i){if(!("ownerSVGElement"in i))return;const t=i.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const Qt=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"]),mi=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","motionPathX","motionPathY","motionPathRotate"]),yi=new Set(["originX","originY"]),gi=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Ti={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},zt={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},bi="http://www.w3.org/2000/svg";class j{targets=new Map;registerTarget(t,e){this.targets.set(t,e)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[e,s]of t.values){const n=this.targets.get(e);n&&this.applyProperties(n,s)}}applyProperties(t,e){const s=[];let n=null,r=null,a=null;const o=e.has("motionPathX"),c=e.has("motionPathY"),h=e.has("motionPathRotate");for(const[d,f]of e)if(!(d==="x"&&o)&&!(d==="y"&&c)&&!((d==="rotate"||d==="rotateZ")&&h)){if(mi.has(d)){const b=this.buildTransformPart(d,f);b&&s.push(b)}else if(yi.has(d))typeof f=="number"&&((n??={})[d]=f);else if(gi.has(d))typeof f=="number"&&((r??={})[d]=f);else if(hi.has(d))(a??={})[d]=f;else if(d!=="perspective"){if(d!=="shine")if(d==="text"&&typeof f=="string")fi(t,f);else if(d==="d"&&typeof f=="string"){const b=t;(b.tagName?.toLowerCase()==="path"?b:b.querySelector?.("path"))?.setAttribute?.("d",f)}else this.applyStyleProperty(t,d,f)}}const u=e.get("shine");typeof u=="number"&&this.applyShine(t,u);const l=e.get("perspective");if(typeof l=="number"&&s.unshift(`perspective(${l}px)`),s.length>0&&(t.style.transform=s.join(" "),pi(t)),n){const d=n.originX??50,f=n.originY??50;t.style.transformOrigin=`${d}% ${f}%`}if(r){const d=r.clipTop??0,f=r.clipRight??0,b=r.clipBottom??0,p=r.clipLeft??0;t.style.clipPath=`inset(${d}% ${f}% ${b}% ${p}%)`}if(a){const d=di(a);d&&(t.style.filter=d)}}buildTransformPart(t,e){if(typeof e!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${e}px)`;case"y":case"motionPathY":return`translateY(${e}px)`;case"z":return`translateZ(${e}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${e}deg)`;case"rotateX":return`rotateX(${e}deg)`;case"rotateY":return`rotateY(${e}deg)`;case"scale":return`scale(${e})`;case"scaleX":return`scaleX(${e})`;case"scaleY":return`scaleY(${e})`;case"scaleZ":return`scaleZ(${e})`;case"skewX":return`skewX(${e}deg)`;case"skewY":return`skewY(${e}deg)`;default:return null}}applyShine(t,e){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const s=t.dataset.shineBase,n=-20+e*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=`${n}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,e,s){let n;if(t.namespaceURI===bi&&e in zt){const o=Array.isArray(s)?s.join(", "):String(s);t.style[zt[e]]=o;return}else e==="fill"&&t.dataset?.elementType==="text"?n="color":n=Ti[e]??e;let a;typeof s=="number"?Qt.has(e)||Qt.has(n)?a=`${s}px`:a=String(s):Array.isArray(s)?a=s.join(", "):a=s,t.style[n]=a}}class gt{media;offset;driftTolerance;constructor(t,e={}){this.media=t,this.offset=e.offset??0,this.driftTolerance=Math.max(0,e.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,e){const s=this.targetTime(t);e?(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 Gt(i,t,e,s,n){const r=e-n;if(r<0){t.paused||t.pause(),t.currentTime=0;return}i.update(r,s)}class Tt{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,e={}){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=e,this.adapter=new j}async load(t){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(t)}async loadSource(t){let e;if(typeof t=="string"){const s=await fetch(t);if(!s.ok)throw new Error(`Failed to load animation: ${s.statusText}`);e=await s.json()}else e=t;this.useDefinition(e),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(t){const e={...t.config};this.options.speed!==void 0&&(e.speed=this.options.speed),this.options.loop!==void 0&&(e.loop=this.options.loop),this.options.alternate!==void 0&&(e.alternate=this.options.alternate),this.timeline=J({...t,config:e}),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,e={}){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 n=e.initial===void 0?t[0]:t.find(r=>r.id===e.initial);if(!n)throw new Error(`tinyfly: there is no scenario "${e.initial}"`);this.scenarioList=[...t],this.scenarioId=n.id,await this.loadSource(n.timeline)}get scenarios(){return this.scenarioList.map(t=>({id:t.id,label:t.label??t.id}))}get scenario(){return this.scenarioId}setScenario(t){const e=this.scenarioList.find(o=>o.id===t);if(!e||!this.timeline)return!1;if(t===this.scenarioId)return!0;const s=this.isPlaying,n=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=t,this.useDefinition(e.timeline),this.lastMarkerId=null;let a=0;return this.reducedMotion||n?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 e={style:t.getAttribute("style")};t.children.length===0&&(e.text=t.textContent??"");const s=t.tagName.toLowerCase()==="path"?t:t.querySelector("path");s&&(e.path={element:s,d:s.getAttribute("d")}),this.authored.set(t,e)}restoreAuthored(){for(const[t,e]of this.authored){e.style===null?t.removeAttribute("style"):t.setAttribute("style",e.style),e.text!==void 0&&t.textContent!==e.text&&(t.textContent=e.text),e.path&&(e.path.d===null?e.path.element.removeAttribute("d"):e.path.element.setAttribute("d",e.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 e;for(const s of this.markers)if(s.time<=t+.5)e=s;else break;return e}caption(t,e){const s=t?this.markers.find(a=>a.id===t):this.currentMarker;if(!s)return;const n=e??this.language(),r=a=>a?.[n]?.[s.id]??a?.[n.split("-")[0]]?.[s.id];return r(this.options.captions)??r(this.timeline?.captions)??s.label}next(){if(!this.timeline)return;const t=this.currentTime,e=this.markers.find(s=>s.time>t+.5);if(this.reducedMotion){this.seek(e?e.time:this.duration);return}t>=this.duration-.5||(this.stepping=e!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,e=[...this.markers].reverse().find(s=>s.time<t-.5);this.pause(),this.seek(e?e.time:0)}goToMarker(t){const e=this.markers.find(s=>s.id===t);e&&(this.pause(),this.seek(e.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 e=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,e))),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(e=>{for(const s of e)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,e=t?.id;e!==this.lastMarkerId&&(this.lastMarkerId=e,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(e=>{const s=e,n=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:n,sync:new gt(s)})})}syncAllMedia(t,e){for(const s of this.mediaTargets)Gt(s.sync,s.el,t,e,s.startTime)}loadFromString(t){const e=JSON.parse(t);this.load(e)}registerTarget(t,e){if(typeof e=="string"){const s=this.container.querySelector(e);s&&(this.rememberAuthored(s),this.targets[t]=s,this.adapter.registerTarget(t,s))}else this.rememberAuthored(e),this.targets[t]=e,this.adapter.registerTarget(t,e)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(e=>{const s=e.closest("[data-tinyfly-symbol]");if(s&&s!==e)return;const n=e.getAttribute("data-tinyfly");n&&this.registerTarget(n,e)}),this.timeline&&new Set(this.timeline.tracks.map(s=>s.target)).forEach(s=>{if(!this.targets[s]){const n=this.container.querySelector(`[data-tinyfly="${s}"]`)||this.container.querySelector(`.${s}`)||this.container.querySelector(`#${s}`);n&&this.registerTarget(s,n)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const e=new Map(t.map(s=>[s.id,s]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const n=s.getAttribute("data-tinyfly-symbol");if(!n)return;const r=e.get(n);if(!r||!r.timeline.tracks?.length)return;const a=new j;s.querySelectorAll("[data-tinyfly]").forEach(o=>{const c=o.getAttribute("data-tinyfly");c&&a.registerTarget(c,o)}),this.symbolInstances.push({adapter:a,timeline:J(r.timeline)})})}attachMedia(t,e){this.mediaSync=new gt(t,e),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=e=>{if(this.isDestroyed||!this.timeline)return;const s=e-(this.lastTime??e);this.lastTime=e;const n=this.playhead;this.timeline.tick(s),this.stopAtMarker(n),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 e=this.timeline,s={time:e.currentTime,iteration:e.loopIteration,direction:e.direction};this.playhead=s;const n=this.markers;if(n.length===0)return;const{crossings:r}=ai(n.map(a=>a.time),t,s,{duration:e.duration,alternate:e.config.alternate===!0,holding:e.repeatDelayRemaining>0});for(const a of r){if(a.kind!=="event")continue;const o=n[a.index];if(this.stepping||o.pause){this.stepping=!1,e.pause(),e.seek(o.time),this.playhead={time:o.time,iteration:e.loopIteration,direction:e.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 e of this.symbolInstances){const s=e.timeline.duration;e.adapter.applyState(e.timeline.getStateAtTime(s>0?t%s:t))}}}async function Ai(i,t,e={}){const s=new Tt(i,{...e,autoplay:!0});return await s.load(t),s}function Si(i,t={}){return new Tt(i,t)}class Zt{container;containerA;containerB;adapterA;adapterB;timelineA=null;timelineB=null;symbolDefs=new Map;nestedByAdapter=new Map;sequence=null;options;_currentSceneIndex=0;_state="idle";_isPlaying=!1;_isDestroyed=!1;loopIteration=0;animationFrameId;lastTime;transitionTimer;constructor(t,e={}){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=e,this.container.style.position="relative",this.container.style.overflow="hidden",this.containerA=this.createSceneContainer(),this.containerB=this.createSceneContainer(),this.container.appendChild(this.containerA),this.container.appendChild(this.containerB),this.containerB.style.visibility="hidden",this.adapterA=new j,this.adapterB=new j}async load(t){let e;if(typeof t=="string"){const s=await fetch(t);if(!s.ok)throw new Error(`Failed to load sequence: ${s.statusText}`);e=await s.json()}else e=t;this.sequence=e,this.symbolDefs.clear();for(const s of e.symbols??[])s.timeline?.tracks?.length&&this.symbolDefs.set(s.id,s.timeline);this.container.style.width=`${e.canvas.width}px`,this.container.style.height=`${e.canvas.height}px`,e.scenes.length>0&&(this.renderScene(e.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(e.scenes[0])),this.options.autoplay&&this.play()}play(){if(!(!this.sequence||this._isDestroyed)&&this.sequence.scenes.length!==0){if(this._isPlaying=!0,this._state==="idle"){if(this._state="playing-scene",this._currentSceneIndex=0,this.timelineA)this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play();else{this.onSceneComplete();return}this.options.onSceneChange?.(0)}else this._state==="playing-scene"&&this.timelineA&&this.timelineA.play();this.startAnimationLoop()}}pause(){this._isPlaying&&(this._isPlaying=!1,this.timelineA&&this.timelineA.pause(),this.timelineB&&this.timelineB.pause(),this.stopAnimationLoop())}stop(){if(this._isPlaying=!1,this._state="idle",this._currentSceneIndex=0,this.loopIteration=0,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.stopAnimationLoop(),this.sequence&&this.sequence.scenes.length>0&&(this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this.renderScene(this.sequence.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(this.sequence.scenes[0]),this.timelineA)){const t=this.timelineA.getStateAtTime(0);this.adapterA.applyState(t),this.applyNested(this.adapterA,0)}}goToScene(t){if(!this.sequence||t<0||t>=this.sequence.scenes.length)return;const e=this._isPlaying;this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this._currentSceneIndex=t,this._state=e?"playing-scene":"idle",this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB);const s=this.sequence.scenes[t];if(this.renderScene(s,this.containerA,this.adapterA),this.timelineA=this.createTimeline(s),this.options.onSceneChange?.(t),e)this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play(),this.startAnimationLoop()):this.onSceneComplete();else if(this.timelineA){const n=this.timelineA.getStateAtTime(0);this.adapterA.applyState(n),this.applyNested(this.adapterA,0)}}destroy(){this._isDestroyed=!0,this._isPlaying=!1,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.adapterA.clearTargets(),this.adapterB.clearTargets();for(const t of this.nestedByAdapter.values())for(const e of t)e.adapter.clearTargets();this.nestedByAdapter.clear(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.timelineA=null,this.timelineB=null,this.containerA.parentNode&&this.containerA.remove(),this.containerB.parentNode&&this.containerB.remove(),this.sequence=null}get currentSceneIndex(){return this._currentSceneIndex}get sceneCount(){return this.sequence?.scenes.length??0}get isPlaying(){return this._isPlaying}get state(){return this._state}createSceneContainer(){const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t}renderScene(t,e,s){e.innerHTML="",s.clearTargets();const n=document.createElement("div");n.style.cssText="position:absolute;inset:0;transform-origin:center center",n.setAttribute("data-tinyfly","Camera"),e.appendChild(n),s.registerTarget("Camera",n);for(const r of t.elements){if(!r.html)continue;const a=document.createElement("div");a.innerHTML=r.html.trim();const o=a.firstElementChild;if(o){n.appendChild(o);const c=o.getAttribute("data-tinyfly");c&&s.registerTarget(c,o)}}this.setupNested(n,s)}setupNested(t,e){const s=[];t.querySelectorAll("[data-tinyfly-symbol]").forEach(n=>{const r=n.getAttribute("data-tinyfly-symbol");if(!r)return;const a=this.symbolDefs.get(r);if(!a)return;const o=new j;n.querySelectorAll("[data-tinyfly]").forEach(c=>{const h=c.getAttribute("data-tinyfly");h&&o.registerTarget(h,c)}),s.push({adapter:o,timeline:J(a)})}),s.length?this.nestedByAdapter.set(e,s):this.nestedByAdapter.delete(e)}applyNested(t,e){const s=this.nestedByAdapter.get(t);if(s)for(const n of s){const r=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(r>0?e%r:e))}}clearContainer(t){t.innerHTML=""}createTimeline(t){return t.timeline?J(t.timeline):null}onSceneComplete(){if(this._isDestroyed||!this.sequence)return;const t=this._currentSceneIndex+1;if(t>=this.sequence.scenes.length){const e=this.options.loop??this.sequence.loop??0;e===-1||e>0&&this.loopIteration<e-1?(this.loopIteration++,this.beginTransitionTo(0)):(this._isPlaying=!1,this._state="idle",this.stopAnimationLoop(),this.options.onComplete?.())}else this.beginTransitionTo(t)}beginTransitionTo(t){if(!this.sequence||this._isDestroyed)return;const e=this.sequence.scenes[t],s=e.transition;if(s.type==="none"||s.duration<=0){this.switchToScene(t);return}this._state="transitioning",this.containerB.style.visibility="visible",this.renderScene(e,this.containerB,this.adapterB),this.timelineB=this.createTimeline(e),this.timelineB&&this.timelineB.play(),this.applyTransition(s.type,s.duration),this.transitionTimer=window.setTimeout(()=>{this.finishTransition(t)},s.duration)}applyTransition(t,e){const s=`${e}ms`,n="ease-in-out";switch(this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),t){case"fade":this.containerB.style.opacity="0";break;case"slide-left":this.containerB.style.transform="translateX(100%)";break;case"slide-right":this.containerB.style.transform="translateX(-100%)";break;case"slide-up":this.containerB.style.transform="translateY(100%)";break;case"slide-down":this.containerB.style.transform="translateY(-100%)";break}switch(this.containerB.offsetHeight,this.containerA.style.transition=`opacity ${s} ${n}, transform ${s} ${n}`,this.containerB.style.transition=`opacity ${s} ${n}, transform ${s} ${n}`,t){case"fade":this.containerA.style.opacity="0",this.containerB.style.opacity="1";break;case"slide-left":this.containerA.style.transform="translateX(-100%)",this.containerB.style.transform="translateX(0)";break;case"slide-right":this.containerA.style.transform="translateX(100%)",this.containerB.style.transform="translateX(0)";break;case"slide-up":this.containerA.style.transform="translateY(-100%)",this.containerB.style.transform="translateY(0)";break;case"slide-down":this.containerA.style.transform="translateY(100%)",this.containerB.style.transform="translateY(0)";break}}resetTransitionStyles(t){t.style.transition="",t.style.opacity="1",t.style.transform=""}finishTransition(t){this.transitionTimer=void 0,this.timelineA&&(this.timelineA.stop(),this.timelineA=null),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const e=this.containerA;this.containerA=this.containerB,this.containerB=e;const s=this.adapterA;this.adapterA=this.adapterB,this.adapterB=s,this.timelineA=this.timelineB,this.timelineB=null,this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.playbackState!=="playing"&&this.timelineA.play()):this.onSceneComplete()}switchToScene(t){if(!this.sequence||this._isDestroyed)return;this.timelineA&&this.timelineA.stop(),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const e=this.sequence.scenes[t];this.renderScene(e,this.containerA,this.adapterA),this.timelineA=this.createTimeline(e),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play()):this.onSceneComplete()}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=e=>{if(this._isDestroyed||!this._isPlaying)return;const s=e-(this.lastTime??e);if(this.lastTime=e,this.timelineA&&this.timelineA.playbackState==="playing"){this.timelineA.tick(s);const n=this.timelineA.getStateAtTime(this.timelineA.currentTime);this.adapterA.applyState(n),this.applyNested(this.adapterA,this.timelineA.currentTime)}if(this._state==="transitioning"&&this.timelineB&&this.timelineB.playbackState==="playing"){this.timelineB.tick(s);const n=this.timelineB.getStateAtTime(this.timelineB.currentTime);this.adapterB.applyState(n),this.applyNested(this.adapterB,this.timelineB.currentTime)}this._isPlaying?this.animationFrameId=requestAnimationFrame(t):this.animationFrameId=void 0};this.animationFrameId=requestAnimationFrame(t)}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}}async function Mi(i,t,e={}){const s=new Zt(i,{...e,autoplay:!0});return await s.load(t),s}const _i={type:"none",duration:0};v.DEFAULT_TRANSITION=_i,v.MediaSync=gt,v.TinyflyPlayer=Tt,v.TinyflySequencer=Zt,v.create=Si,v.play=Ai,v.playSequence=Mi,v.syncMediaElement=Gt,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(v,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(v=typeof globalThis<"u"?globalThis:v||self,N(v.tinyfly=v.tinyfly||{}))})(this,(function(v){"use strict";function N(i){return typeof i=="object"&&i!==null&&i.type==="cubic-bezier"}function ee(i){return typeof i=="object"&&i!==null&&i.type!=="cubic-bezier"}const st=1;function St(i){return i.property==="text"&&"textConfig"in i}function nt(i){return i.kind==="inertia"&&"inertia"in i}function rt(i){return i.kind==="spring"&&"spring"in i}function ie(i){return i.property==="motionPath"&&"motionPathConfig"in i}function Mt(i,t,e="start"){if(t<=1)return 0;if(typeof e=="number"){const s=Math.max(0,Math.min(t-1,e));return Math.abs(i-s)}switch(e){case"end":return t-1-i;case"center":return Math.abs(i-(t-1)/2);case"edges":return(t-1)/2-Math.abs(i-(t-1)/2);default:return i}}function se(i,t="start"){if(i<=1)return 0;let e=0;for(let s=0;s<i;s++)e=Math.max(e,Mt(s,i,t));return e}function _t(i,t,e){if(e.offsets)return e.offsets[i]??0;const s=e.from??"start",n=Mt(i,t,s);if(e.amount!==void 0){const r=se(t,s);return r===0?0:e.amount*n/r}return e.each!==void 0?e.each*n:0}function ne(i,t){return Array.from({length:i},(e,s)=>_t(s,i,t))}function at(i,t){return i<=1?0:Math.max(...ne(i,t))}const Y=1,kt=6e4,z=kt/Y,F={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1};class re{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??F.stiffness,this.damping=t.damping??F.damping,this.mass=t.mass??F.mass,this.restDelta=t.restDelta??F.restDelta,this.restSpeed=t.restSpeed??F.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??F.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 e=Math.floor(t/Y);if(this.simulateTo(e+1),this.settledStep!==null&&e>=this.settledStep)return this.to;const s=this.samples[Math.min(e,this.samples.length-1)],n=this.samples[Math.min(e+1,this.samples.length-1)],r=t/Y-e;return s+(n-s)*r}settleTime(){return this.simulateTo(z+1),this.settledStep!==null?this.settledStep*Y:kt}simulateTo(t){if(this.settledStep!==null)return;const e=Math.min(t,z+1),s=Y/1e3;for(;this.samples.length<e;){const n=this.samples[this.samples.length-1],r=n-this.to,a=-this.stiffness*r,o=-this.damping*this.velocity,c=(a+o)/this.mass;this.velocity+=c*s;const h=n+this.velocity*s;if(this.samples.push(h),this.isAtRest(h)){this.settledStep=this.samples.length-1;return}}this.samples.length>z&&(this.settledStep=z)}}const wt=4,ae=.002,oe=1e-4,ce=6e4;function ot(i){const t=i.friction??wt;return t>0?t:wt}function he(i){return i.from+i.velocity/ot(i)}function le(i,t){if(t===void 0)return i;if(typeof t=="number")return t>0?Math.round(i/t)*t:i;if(t.length===0)return i;let e=t[0];for(const s of t)Math.abs(s-i)<Math.abs(e-i)&&(e=s);return e}function Pt(i){let t=le(he(i),i.end);return i.min!==void 0&&(t=Math.max(i.min,t)),i.max!==void 0&&(t=Math.min(i.max,t)),t}function vt(i){const t=Math.abs(Pt(i)-i.from);if(t===0)return 0;const e=i.restDelta??Math.max(oe,t*ae);if(e>=t)return 0;const s=Math.log(t/e)/ot(i);return Math.min(ce,s*1e3)}function It(i,t){if(t<=0)return i.from;const e=Pt(i);if(t>=vt(i))return e;const s=ot(i);return i.from+(e-i.from)*(1-Math.exp(-s*t/1e3))}const ct=i=>i,ue=i=>i*i,de=i=>1-(1-i)*(1-i),fe=i=>i<.5?2*i*i:1-Math.pow(-2*i+2,2)/2,xt=i=>i*i*i,Ct=i=>1-Math.pow(1-i,3),Rt=i=>i<.5?4*i*i*i:1-Math.pow(-2*i+2,3)/2,pe={linear:ct,"ease-in":xt,"ease-out":Ct,"ease-in-out":Rt,"ease-in-quad":ue,"ease-out-quad":de,"ease-in-out-quad":fe,"ease-in-cubic":xt,"ease-out-cubic":Ct,"ease-in-out-cubic":Rt};function me(i){const[t,e,s,n]=i,r=3*t,a=3*(s-t)-r,o=1-r-a,c=3*e,h=3*(n-e)-c,u=1-c-h,l=p=>((o*p+a)*p+r)*p,d=p=>((u*p+h)*p+c)*p,f=p=>(3*o*p+2*a)*p+r,b=p=>{let y=p;for(let A=0;A<8;A++){const M=l(y)-p;if(Math.abs(M)<1e-7)return y;const m=f(y);if(Math.abs(m)<1e-7)break;y-=M/m}let g=0,T=1;for(y=p;g<T;){const A=l(y);if(Math.abs(A-p)<1e-7)return y;p>A?g=y:T=y,y=(g+T)/2}return y};return p=>{if(p<=0)return 0;if(p>=1)return 1;const y=b(p);return d(y)}}function ht(i,t="out"){if(t==="out")return i;const e=s=>1-i(1-s);return t==="in"?e:s=>s<.5?e(s*2)/2:i(s*2-1)/2+.5}function ye(i=1,t=.3){const e=Math.max(1,i),s=t/(2*Math.PI)*Math.asin(1/e);return n=>n<=0?0:n>=1?1:e*Math.pow(2,-10*n)*Math.sin((n-s)*(2*Math.PI)/t)+1}const ge=i=>{if(i<=0)return 0;if(i>=1)return 1;if(i<1/2.75)return 7.5625*i*i;if(i<2/2.75){const n=i-.5454545454545454;return 7.5625*n*n+.75}if(i<2.5/2.75){const n=i-.8181818181818182;return 7.5625*n*n+.9375}const s=i-2.625/2.75;return 7.5625*s*s+.984375};function Te(i=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const e=t-1;return e*e*((i+1)*e+i)+1}}function be(i,t="end"){const e=Math.max(1,Math.floor(i));return s=>{if(s>=1)return 1;if(s<=0)return t==="start"||t==="both"?t==="start"?1/e:1/(e+1):0;const n=Math.floor(s*e);switch(t){case"start":return Math.min(1,(n+1)/e);case"both":return(n+1)/(e+1);case"none":return e===1?0:Math.min(1,n/(e-1));default:return n/e}}}function Ae(i){switch(i.type){case"steps":return be(i.count,i.position);case"elastic":return ht(ye(i.amplitude,i.period),i.mode);case"bounce":return ht(ge,i.mode);case"back":return ht(Te(i.overshoot),i.mode)}}function Se(i){return i===void 0?ct:N(i)?me(i.points):ee(i)?Ae(i):pe[i]??ct}const Dt=32,Me=256,V=new Map,_e=/[MmLlHhVvCcSsQqTtAaZz]/,ke=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,we={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function Pe(i){const t=[];let e=0,s=null;const n=()=>{for(;e<i.length&&/[\s,]/.test(i[e]);)e++};for(;e<i.length&&(n(),!(e>=i.length));){const r=i[e];if(_e.test(r)){s={type:r,args:[]},t.push(s),e++;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),e++;continue}const c=ke.exec(i.slice(e));if(!c)break;s.args.push(parseFloat(c[0])),e+=c[0].length}return t}function ve(i,t,e,s,n,r,a,o,c){if(i===o&&t===c)return[];let h=Math.abs(e),u=Math.abs(s);if(h===0||u===0)return[[i,t,o,c,o,c]];const l=n*Math.PI/180,d=Math.cos(l),f=Math.sin(l),b=(i-o)/2,p=(t-c)/2,y=d*b+f*p,g=-f*b+d*p,T=y*y/(h*h)+g*g/(u*u);if(T>1){const w=Math.sqrt(T);h*=w,u*=w}const A=r===a?-1:1,M=h*h*u*u-h*h*g*g-u*u*y*y,m=h*h*g*g+u*u*y*y,_=A*Math.sqrt(Math.max(0,M/m)),S=_*h*g/u,B=-_*u*y/h,tt=d*S-f*B+(i+o)/2,k=f*S+d*B+(t+c)/2,C=(w,x,R,q)=>{const At=w*R+x*q,it=Math.sqrt((w*w+x*x)*(R*R+q*q)),Q=Math.acos(Math.max(-1,Math.min(1,At/it)));return w*q-x*R<0?-Q:Q},P=C(1,0,(y-S)/h,(g-B)/u);let I=C((y-S)/h,(g-B)/u,(-y-S)/h,(-g-B)/u);!a&&I>0&&(I-=2*Math.PI),a&&I<0&&(I+=2*Math.PI);const $=Math.max(1,Math.ceil(Math.abs(I)/(Math.PI/2))),bt=I/$,et=4/3*Math.tan(bt/4),Kt=w=>{const x=h*Math.cos(w),R=u*Math.sin(w);return[d*x-f*R+tt,f*x+d*R+k]},Jt=w=>{const x=-h*Math.sin(w),R=u*Math.cos(w);return[d*x-f*R,f*x+d*R]},te=[];for(let w=0;w<$;w++){const x=P+w*bt,R=x+bt,[q,At]=Kt(x),[it,Q]=w===$-1?[o,c]:Kt(R),[wi,Pi]=Jt(x),[vi,Ii]=Jt(R);te.push([q+et*wi,At+et*Pi,it-et*vi,Q-et*Ii,it,Q])}return te}function E(i,t,e,s,n){const r=1-n;return r*r*r*i+3*r*r*n*t+3*r*n*n*e+n*n*n*s}function Bt(i,t,e,s,n){const r=1-n;return 3*r*r*(t-i)+6*r*n*(e-t)+3*n*n*(s-e)}function W(i,t,e,s){return{subpath:0,type:"L",points:[e,s],startX:i,startY:t,endX:e,endY:s,length:Math.hypot(e-i,s-t)}}function G(i,t,e){const[s,n,r,a,o,c]=e,h=[0];let u=i,l=t,d=0;for(let f=1;f<=Dt;f++){const b=f/Dt,p=E(i,s,r,o,b),y=E(t,n,a,c,b);d+=Math.hypot(p-u,y-l),h.push(d),u=p,l=y}return{subpath:0,type:"C",points:[s,n,r,a,o,c],startX:i,startY:t,endX:o,endY:c,length:d,lengths:h}}function Z(i){const t=V.get(i);if(t)return t;const e=[];let s=0,n=0,r=0,a=0,o=null,c=null,h=-1;const u=new Set,l=p=>{h<0&&(h=0),p.subpath=h,e.push(p)};for(const{type:p,args:y}of Pe(i)){const g=p.toUpperCase(),T=p!==g,A=we[g];if(g==="Z"){(s!==r||n!==a)&&l(W(s,n,r,a)),h>=0&&u.add(h),s=r,n=a,o=c=null;continue}for(let M=0;M+A<=y.length;M+=A){const m=y.slice(M,M+A),_=T?s:0,S=T?n:0;let B=null,tt=null;switch(g){case"M":M===0?(s=m[0]+_,n=m[1]+S,r=s,a=n,(h<0||e[e.length-1]?.subpath===h)&&h++):(l(W(s,n,m[0]+_,m[1]+S)),s=m[0]+_,n=m[1]+S);break;case"L":l(W(s,n,m[0]+_,m[1]+S)),s=m[0]+_,n=m[1]+S;break;case"H":l(W(s,n,m[0]+_,n)),s=m[0]+_;break;case"V":l(W(s,n,s,m[0]+S)),n=m[0]+S;break;case"C":{const k=[m[0]+_,m[1]+S,m[2]+_,m[3]+S,m[4]+_,m[5]+S];l(G(s,n,k)),B=[k[2],k[3]],s=k[4],n=k[5];break}case"S":{const[k,C]=o?[2*s-o[0],2*n-o[1]]:[s,n],P=[k,C,m[0]+_,m[1]+S,m[2]+_,m[3]+S];l(G(s,n,P)),B=[P[2],P[3]],s=P[4],n=P[5];break}case"Q":case"T":{let k=s,C=n;g==="Q"?(k=m[0]+_,C=m[1]+S):c&&(k=2*s-c[0],C=2*n-c[1]);const P=g==="Q"?m[2]+_:m[0]+_,I=g==="Q"?m[3]+S:m[1]+S;l(G(s,n,[s+2/3*(k-s),n+2/3*(C-n),P+2/3*(k-P),I+2/3*(C-I),P,I])),tt=[k,C],s=P,n=I;break}case"A":{const k=m[5]+_,C=m[6]+S;let P=s,I=n;for(const $ of ve(s,n,m[0],m[1],m[2],m[3],m[4],k,C))l(G(P,I,$)),P=$[4],I=$[5];s=k,n=C;break}}o=B,c=tt}}const d=e.reduce((p,y)=>p+y.length,0),f=[];for(let p=0;p<e.length;){const y=e[p].subpath;let g=p,T=0;for(;g<e.length&&e[g].subpath===y;)T+=e[g++].length;const A=e[p],M=e[g-1],m=u.has(y)||Math.abs(M.endX-A.startX)<1e-9&&Math.abs(M.endY-A.startY)<1e-9;f.push({start:p,end:g,length:T,closed:m}),p=g}const b={segments:e,totalLength:d,subpaths:f};return V.size>=Me&&V.delete(V.keys().next().value),V.set(i,b),b}function Ie(i,t){const e=i.lengths;if(t<=0)return 0;if(t>=i.length)return 1;let s=0,n=e.length-1;for(;s<n-1;){const o=s+n>>1;e[o]<t?s=o:n=o}const r=e[n]-e[s],a=r>0?(t-e[s])/r:0;return(s+a)/(e.length-1)}function xe(i,t){if(i.type==="L"){const l=i.length>0?Math.max(0,Math.min(1,t/i.length)):0;return{x:i.startX+(i.endX-i.startX)*l,y:i.startY+(i.endY-i.startY)*l,angle:Math.atan2(i.endY-i.startY,i.endX-i.startX)*180/Math.PI}}const[e,s,n,r,a,o]=i.points,c=Ie(i,t);let h=Bt(i.startX,e,n,a,c),u=Bt(i.startY,s,r,o,c);if(Math.hypot(h,u)<1e-9){const l=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),d=E(i.startX,e,n,a,l),f=E(i.startY,s,r,o,l),b=E(i.startX,e,n,a,c),p=E(i.startY,s,r,o,c);h=c<.5?d-b:b-d,u=c<.5?f-p:p-f}return{x:E(i.startX,e,n,a,c),y:E(i.startY,s,r,o,c),angle:Math.atan2(u,h)*180/Math.PI}}function Et(i,t,e=0,s=i.length){if(s<=e)return{x:0,y:0,angle:0};let n=0;for(let r=e;r<s;r++){const a=i[r];if(n+a.length>=t||r===s-1)return xe(a,t-n);n+=a.length}return{x:0,y:0,angle:0}}function Ce(i,t){const{segments:e,totalLength:s}=Z(i);return Et(e,Math.max(0,Math.min(1,t))*s)}const Re=24,De=320,Be=2.5,U=72,Ee=.2,Le=128,K=new Map;let lt=0,L;const Lt=i=>Math.round(i*100)/100;function Ot(i,t){const{segments:e,subpaths:s,totalLength:n}=Z(i);if(e.length===0)return[];if(t){const r=s.every(a=>a.closed);return[{segments:e,start:0,end:e.length,length:n,closed:r}]}return s.filter(r=>r.length>0).map(r=>({segments:e,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function ut(i,t){const e=i.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),s=Et(i.segments,e*i.length,i.start,i.end);return[s.x,s.y]}function $t(i){const t=[];let e=0;for(let s=i.start;s<i.end;s++)e+=i.segments[s].length,i.length>0&&t.push(e/i.length);return t}function Ft(i,t){const e=[];for(let s=0;s<t;s++)e.push(ut(i,i.closed?s/t:s/(t-1)));return e}function Xt(i){let t=0,e=0;for(const[s,n]of i)t+=s,e+=n;return t/=i.length,e/=i.length,i.map(([s,n])=>[s-t,n-e])}function Oe(i,t,e){const s=i.closed&&t.closed;if(e!==void 0)return{offset:s?Math.abs(e)%U/U:0,reversed:e<0};const n=Xt(Ft(i,U)),r=Xt(Ft(t,U)),a=U;let o={offset:0,reversed:!1},c=1/0;for(const h of[!1,!0]){const u=s?a:1;for(let l=0;l<u;l++){let d=0;for(let f=0;f<a&&d<c;f++){const b=s?h?(l-f+a)%a:(f+l)%a:h?a-1-f:f,p=n[f][0]-r[b][0],y=n[f][1]-r[b][1];d+=p*p+y*y}d<c&&(c=d,o={offset:s?l/a:0,reversed:h})}}return o}function $e(i,t,e){return e?((t.reversed?t.offset-i:i+t.offset)%1+1)%1:t.reversed?1-i:i}function Fe(i,t,e){return e?((t.reversed?t.offset-i:i-t.offset)%1+1)%1:t.reversed?1-i:i}function Xe(i,t,e){const s=i.closed&&t.closed,n=Oe(i,t,e.shapeIndex),r=Math.max(Re,Math.min(De,Math.ceil(Math.max(i.length,t.length)/Be))),a=new Set,o=l=>a.add(Math.round(l*1e7)/1e7);for(let l=0;l<=r;l++)o(l/r);for(const l of $t(i))o(l);for(const l of $t(t))o(Fe(l,n,s));let c=[...a].sort((l,d)=>l-d);s&&(c=c.filter(l=>l<1));const h=[],u=[];for(const l of c)h.push(...ut(i,l)),u.push(...ut(t,$e(l,n,s)));return qe({from:h,to:u,closed:s})}function qe(i){const t=i.from.length/2;if(t<=3)return i;const e=new Uint8Array(t);e[0]=1,e[t-1]=1;const s=[[0,t-1]];for(;s.length>0;){const[a,o]=s.pop();let c=-1,h=Ee;for(let u=a+1;u<o;u++){const l=Math.max(qt(i.from,a,o,u),qt(i.to,a,o,u));l>h&&(h=l,c=u)}c!==-1&&(e[c]=1,s.push([a,c],[c,o]))}const n=[],r=[];for(let a=0;a<t;a++)e[a]&&(n.push(i.from[a*2],i.from[a*2+1]),r.push(i.to[a*2],i.to[a*2+1]));return{from:n,to:r,closed:i.closed}}function qt(i,t,e,s){const n=i[t*2],r=i[t*2+1],a=i[e*2]-n,o=i[e*2+1]-r,c=i[s*2]-n,h=i[s*2+1]-r,u=a*a+o*o,l=u===0?0:Math.max(0,Math.min(1,(c*a+h*o)/u));return Math.hypot(c-l*a,h-l*o)}function Ne(i,t,e){const s=e.shapeIndex;if(L&&L.from===i&&L.to===t&&L.shapeIndex===s)return L.plan;const r=K.get(String(s??"auto"))?.get(i)?.get(t);if(r)return L={from:i,to:t,shapeIndex:s,plan:r},r;const a=Z(i).subpaths.filter(f=>f.length>0).length===Z(t).subpaths.filter(f=>f.length>0).length,o=Ot(i,!a),c=Ot(t,!a),h={pairs:o.map((f,b)=>Xe(f,c[b],e))};lt>=Le&&(K.clear(),lt=0);const u=String(s??"auto"),l=K.get(u)??new Map;K.set(u,l);const d=l.get(i)??new Map;return l.set(i,d),d.set(t,h),lt++,L={from:i,to:t,shapeIndex:s,plan:h},h}function Ye(i,t,e,s={}){if(!i)return t;if(!t)return i;const n=Math.max(0,Math.min(1,e));if(n===0)return i;if(n===1)return t;const r=Ne(i,t,s);if(r.pairs.length===0)return n<.5?i:t;let a="";for(const o of r.pairs){for(let c=0;c<o.from.length;c+=2){const h=Lt(o.from[c]+(o.to[c]-o.from[c])*n),u=Lt(o.from[c+1]+(o.to[c+1]-o.from[c+1])*n);a+=`${c===0?a?" M":"M":" L"}${h} ${u}`}o.closed&&(a+=" Z")}return a}function Ve(i){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(i)}const D=(i,t,e)=>i+(t-i)*e,Nt=512,dt=new Map,ft=new Map;function Yt(i){const t=dt.get(i);if(t)return t;const e=i.replace("#",""),s=[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)];return dt.size<Nt&&dt.set(i,s),s}const Vt=i=>i.charCodeAt(0)===35,Wt=i=>i.startsWith("rgb"),Ut=i=>i.startsWith("rgba"),We=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,pt=i=>Math.round(i).toString(16).padStart(2,"0");function Ue(i,t,e){return`#${pt(i)}${pt(t)}${pt(e)}`}function Ht(i){const t=ft.get(i);if(t)return t;const e=i.match(We);if(!e)throw new Error(`Invalid rgb color: ${i}`);const s=parseInt(e[1],10),n=parseInt(e[2],10),r=parseInt(e[3],10),a=e[4]!==void 0?[s,n,r,parseFloat(e[4])]:[s,n,r];return ft.size<Nt&&ft.set(i,a),a}const He=(i,t,e)=>{if(Vt(i)&&Vt(t)){const[s,n,r]=Yt(i),[a,o,c]=Yt(t),h=D(s,a,e),u=D(n,o,e),l=D(r,c,e);return Ue(h,u,l)}if((Wt(i)||Ut(i))&&(Wt(t)||Ut(t))){const s=Ht(i),n=Ht(t),r=Math.round(D(s[0],n[0],e)),a=Math.round(D(s[1],n[1],e)),o=Math.round(D(s[2],n[2],e));if(s.length===4||n.length===4){const c=s[3]??1,h=n[3]??1,u=D(c,h,e);return`rgba(${r}, ${a}, ${o}, ${u})`}return`rgb(${r}, ${a}, ${o})`}return e<1?i:t},je=(i,t,e)=>{const s=Math.min(i.length,t.length),n=[];for(let r=0;r<s;r++)n.push(D(i[r],t[r],e));return n},jt=(i,t,e)=>e<1?i:t,Qe=(i,t,e)=>Ye(i,t,e);function ze(i){return typeof i=="number"?D:Array.isArray(i)?je:typeof i=="string"?i.startsWith("#")||i.startsWith("rgb")?He:Ve(i)?Qe:jt:jt}function Ge(i){const t=[...i.keyframes].sort((e,s)=>e.time-s.time);return{...i,keyframes:t}}function O(i){return i.targets&&i.targets.length>0?i.targets:[i.target]}function X(i,t,e,s){const n=e??0;return!s||t<=1?n:n+_t(i,t,s)}class mt{track;targets;constructor(t){this.track=t,this.targets=O(t)}getValueAtTime(t){return this.valueForOffset(t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger),a=this.valueForOffset(t-r);a!==void 0&&s.push({target:this.targets[n],value:a,start:r+this.track.keyframes[0].time})}return s}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const e=t[t.length-1].time,s=this.track.stagger?at(this.targets.length,this.track.stagger):0;return e+(this.track.delay??0)+s+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:e}=this.track;if(e.length===0)return;if(e.length===1||t<=e[0].time)return e[0].value;if(t>=e[e.length-1].time)return e[e.length-1].value;const{from:s,to:n}=this.findSurroundingKeyframes(t);if(!s||!n)return;if(s.time===t)return s.value;const r=n.time-s.time,a=(t-s.time)/r,c=Se(n.easing)(a);return ze(s.value)(s.value,n.value,c)}findSurroundingKeyframes(t){const{keyframes:e}=this.track;for(let s=0;s<e.length-1;s++)if(t>=e[s].time&&t<=e[s+1].time)return{from:e[s],to:e[s+1]};return{from:null,to:null}}}class Ze{track;targets;sampler;constructor(t){this.track=t,this.targets=O(t),this.sampler=new re(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger);s.push({target:this.targets[n],value:this.sampler.valueAt(t-r),start:r})}return s}getDuration(){const t=this.track.stagger?at(this.targets.length,this.track.stagger):0;return this.sampler.settleTime()+(this.track.delay??0)+t}getTrack(){return this.track}}class Ke{track;targets;duration;constructor(t){this.track=t,this.targets=O(t),this.duration=vt(t.inertia)}getValueAtTime(t){return It(this.track.inertia,t-X(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const e=this.targets.length,s=[];for(let n=0;n<e;n++){const r=X(n,e,this.track.delay,this.track.stagger);s.push({target:this.targets[n],value:It(this.track.inertia,t-r),start:r})}return s}getDuration(){const t=this.track.stagger?at(this.targets.length,this.track.stagger):0;return this.duration+(this.track.delay??0)+t}getTrack(){return this.track}}function Je(i,t){const e={...Ce(i.pathData,t)};if(i.matrix){const[s,n,r,a,o,c]=i.matrix,{x:h,y:u}=e;e.x=s*h+r*u+o,e.y=n*h+a*u+c;const l=e.angle*Math.PI/180,d=Math.cos(l),f=Math.sin(l);e.angle=Math.atan2(n*d+a*f,s*d+r*f)*180/Math.PI}return i.autoRotate&&i.rotateOffset&&(e.angle+=i.rotateOffset),e}const yt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},ti=20;function ei(i){const t=yt[i??"upperCase"]??i??yt.upperCase,e=Array.from(t);return e.length>0?e:Array.from(yt.upperCase)}function ii(i,t,e){let s=(i|0)^Math.imul(t+1,2654435761)^Math.imul(e+1,2246822507);return s=Math.imul(s^s>>>16,2146121005),s=Math.imul(s^s>>>15,2221713035),(s^s>>>16)>>>0}function si(i,t,e=0){const s=i.from??"",n=i.to,r=Math.max(0,Math.min(1,t));if(r<=0)return s;if(r>=1)return n;const a=Array.from(s),o=Array.from(n),c=i.rightToLeft??!1;if(i.mode==="type"){const T=Math.round(r*Math.max(a.length,o.length));return c?a.slice(0,Math.max(0,a.length-T)).join("")+o.slice(Math.max(0,o.length-T)).join(""):o.slice(0,T).join("")+a.slice(T).join("")}const h=Math.max(0,Math.min(.999,i.revealDelay??0)),u=Math.max(0,(r-h)/(1-h)),l=Math.floor(u*o.length),d=i.tweenLength===!1?o.length:Math.round(a.length+(o.length-a.length)*r),f=ei(i.chars),b=i.refreshRate??ti,p=b>0?Math.floor(e*b/1e3):0,y=i.seed??1;let g="";for(let T=0;T<d;T++){const A=c?T>=d-l:T<l,M=c?o[o.length-(d-T)]:o[T];A&&M!==void 0||M===" "||M===`
|
|
2
|
+
`?g+=M:g+=f[ii(y,T,p)%f.length]}return g}class ni{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 e of t.tracks)this.addTrack(e)}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 e={...this._config};delete e.duration,this._config=e}}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 e=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,e)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const e=this.duration;if(e<=0)return;let n=t*this.speed;if(this._repeatDelayRemaining>0){const o=Math.min(this._repeatDelayRemaining,n);if(this._repeatDelayRemaining-=o,n-=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&&n>0&&this._playbackState==="playing";o++)if(this._direction==="forward"){const c=e-this._currentTime;if(n>=c){if(n-=c,this._currentTime=e,!this._handleEndReached())break}else this._currentTime+=n,n=0}else{const c=this._currentTime;if(n>=c){if(n-=c,this._currentTime=0,!this._handleStartReached())break}else this._currentTime-=n,n=0}const a=this.getStateAtTime(this._currentTime);this.onUpdate?.(a)}getStateAtTime(t){const e=new Map;if(this._hasSharedWrites())this._resolveShared(t,e);else for(const[s,n]of this._trackPlayers){const r=n.getTrack().property;for(const{target:a,value:o,start:c}of n.getTargetValues(t))this._write(e,s,a,r,o,t-c)}return{values:e,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,e){const s=new Map;for(const[n,r]of this._trackPlayers){const a=r.getTrack().property;for(const{target:o,value:c,start:h}of r.getTargetValues(t)){const u=`${o}\0${a}`,l=h<=t,d=s.get(u);(!d||(l!==d.started?l:l?h>=d.start:h<=d.start))&&s.set(u,{trackId:n,target:o,property:a,value:c,start:h,started:l})}}for(const{trackId:n,target:r,property:a,value:o,start:c}of s.values())this._write(e,n,r,a,o,t-c)}_write(t,e,s,n,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(e);if(c&&typeof r=="number"){o.set("text",si(c.textConfig,r,Math.max(0,a)));return}const h=this._motionPathTracks.get(e);if(h&&typeof r=="number"){const u=Je(h.motionPathConfig,r);o.set("motionPathX",u.x),o.set("motionPathY",u.y),h.motionPathConfig.autoRotate&&o.set("motionPathRotate",u.angle)}else o.set(n,r)}_sharedWrites=null;_hasSharedWrites(){if(this._sharedWrites===null){const t=new Set;this._sharedWrites=!1;t:for(const e of this._tracks)for(const s of O(e)){const n=`${s}\0${e.property}`;if(t.has(n)){this._sharedWrites=!0;break t}t.add(n)}}return this._sharedWrites}addTrack(t){if(this._tracks.push(t),this._sharedWrites=null,nt(t)){this._trackPlayers.set(t.id,new Ke(t));return}if(rt(t)){this._trackPlayers.set(t.id,new Ze(t)),this._springTracks.set(t.id,t);return}if(St(t))this._trackPlayers.set(t.id,new mt(t)),this._textTracks.set(t.id,t);else if(ie(t)){const e={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 mt(e)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new mt(t))}replaceTrack(t,e){const s=this._tracks.findIndex(r=>r.id===t);if(s<0)return;const n=this._tracks.slice(s+1);this.removeTrack(t);for(const r of n)this.removeTrack(r.id);this.addTrack(e);for(const r of n)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(e=>e.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(e=>this._matches(e,t))}removeTracks(t={}){const e=this.getTracks(t).map(s=>s.id);for(const s of e)this.removeTrack(s);return e}getTrackSpan(t){const e=this._trackPlayers.get(t);if(!e)return;const s=e.getTrack(),n=s.delay??0;if(rt(s)||nt(s))return{from:n,to:e.getDuration()};const r=s.keyframes;if(!(!r||r.length===0))return{from:r[0].time+n,to:e.getDuration()}}findConflicts(){const t=[];for(let e=0;e<this._tracks.length;e++){const s=this._tracks[e],n=this.getTrackSpan(s.id);if(n)for(let r=0;r<e;r++){const a=this._tracks[r];if(a.property!==s.property)continue;const o=O(a).filter(l=>O(s).includes(l));if(o.length===0)continue;const c=this.getTrackSpan(a.id);if(!c||!(c.from<=n.to&&n.from<=c.to))continue;const u=n.from>=c.from;for(const l of o)t.push({target:l,property:s.property,losingTrackId:u?a.id:s.id,winningTrackId:u?s.id:a.id})}}return t}_matches(t,e){if(e.id!==void 0&&t.id!==e.id||e.property!==void 0&&t.property!==e.property||e.target!==void 0&&!O(t).includes(e.target))return!1;if(e.timeRange){const s=this.getTrackSpan(t.id);if(!s||s.to<e.timeRange.from||s.from>e.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:st,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,e)=>t.time-e.time)}setMarkers(t){const e=t&&t.length>0?[...t].sort((n,r)=>n.time-r.time).map(n=>({...n})):void 0,s={...this._config};e?s.markers=e:delete s.markers,this._config=s}get captions(){return this._captions}setCaptions(t){const e={};for(const[s,n]of Object.entries(t??{}))e[s]={...n};this._captions=Object.keys(e).length>0?e:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,e]of this._trackPlayers)t=Math.max(t,e.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 ri=100;function ai(i,t,e,s){const n=[],r=[],{duration:a,alternate:o}=s,c=(f,b,p,y)=>{r.push([f,b]);const g=[];i.forEach((T,A)=>{(p==="forward"?(y?T>=f:T>f)&&T<=b:(y?T<=f:T<f)&&T>=b)&&g.push(A)}),g.sort((T,A)=>(p==="forward"?i[T]-i[A]:i[A]-i[T])||T-A);for(const T of g)n.push({kind:"event",index:T,direction:p})};let h=t.time,u=t.direction,l=t.fresh===!0;const d=Math.min(ri,Math.max(0,e.iteration-t.iteration));for(let f=0;f<d;f++){const b=u==="forward"?a:0;c(h,b,u,l),n.push({kind:"repeat"}),o?(u=u==="forward"?"reverse":"forward",h=b,l=!1):(h=u==="forward"?0:a,l=!0)}return d>0&&s.holding&&!o?{crossings:n,passes:r}:(c(h,e.time,u,l),{crossings:n,passes:r})}function oi(i){return{...i,...Array.isArray(i.end)&&{end:[...i.end]}}}function H(i){const t=i.endDelay;return{...i.delay!==void 0&&{delay:i.delay},...t!==void 0&&{endDelay:t},...i.targets!==void 0&&{targets:[...i.targets]},...i.stagger!==void 0&&{stagger:{...i.stagger}}}}function ci(i){if(nt(i)){const t=i;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:oi(t.inertia),...H(t)}}if(rt(i)){const t=i;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...H(t)}}if(St(i)){const t=i;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((e,s)=>e.time-s.time),...H(t)}}if(i.property==="motionPath"&&"motionPathConfig"in i){const t=i,e=[...t.keyframes].sort((s,n)=>s.time-n.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:e,...H(t)}}return Ge({id:i.id,target:i.target,property:i.property,keyframes:i.keyframes,...H(i)})}function J(i){const t=i.formatVersion??1;if(t>st)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${st}. Update tinyfly to play it.`);return new ni({id:i.id,name:i.name,config:i.config,tracks:i.tracks.map(ci),captions:i.captions})}const hi=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),li="#ffffff",ui="rgba(0, 0, 0, 0.5)";function di(i){const t=[];if(i.blur!==void 0&&t.push(`blur(${Math.max(0,i.blur)}px)`),i.brightness!==void 0&&t.push(`brightness(${Math.max(0,i.brightness)})`),i.glow!==void 0&&t.push(`drop-shadow(0 0 ${Math.max(0,i.glow)}px ${i.glowColor??li})`),i.shadowX!==void 0||i.shadowY!==void 0||i.shadowBlur!==void 0){const e=i.shadowX??0,s=i.shadowY??0,n=Math.max(0,i.shadowBlur??0);t.push(`drop-shadow(${e}px ${s}px ${n}px ${i.shadowColor??ui})`)}return t.length>0?t.join(" "):null}function fi(i,t){const e=i.childNodes.length===1?i.firstChild:null;if(e&&e.nodeType===3){const s=e;s.data!==t&&(s.data=t);return}i.textContent!==t&&(i.textContent=t)}function pi(i){if(!("ownerSVGElement"in i))return;const t=i.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const Qt=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"]),mi=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","motionPathX","motionPathY","motionPathRotate"]),yi=new Set(["originX","originY"]),gi=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),Ti=new Set(["drawOn"]),bi={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},zt={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},Ai="http://www.w3.org/2000/svg";class j{targets=new Map;registerTarget(t,e){this.targets.set(t,e)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[e,s]of t.values){const n=this.targets.get(e);n&&this.applyProperties(n,s)}}applyProperties(t,e){const s=[];let n=null,r=null,a=null;const o=e.has("motionPathX"),c=e.has("motionPathY"),h=e.has("motionPathRotate");for(const[d,f]of e)if(!(d==="x"&&o)&&!(d==="y"&&c)&&!((d==="rotate"||d==="rotateZ")&&h)&&!Ti.has(d)){if(mi.has(d)){const b=this.buildTransformPart(d,f);b&&s.push(b)}else if(yi.has(d))typeof f=="number"&&((n??={})[d]=f);else if(gi.has(d))typeof f=="number"&&((r??={})[d]=f);else if(hi.has(d))(a??={})[d]=f;else if(d!=="perspective"){if(d!=="shine")if(d==="text"&&typeof f=="string")fi(t,f);else if(d==="d"&&typeof f=="string"){const b=t;(b.tagName?.toLowerCase()==="path"?b:b.querySelector?.("path"))?.setAttribute?.("d",f)}else this.applyStyleProperty(t,d,f)}}const u=e.get("shine");typeof u=="number"&&this.applyShine(t,u);const l=e.get("perspective");if(typeof l=="number"&&s.unshift(`perspective(${l}px)`),s.length>0&&(t.style.transform=s.join(" "),pi(t)),n){const d=n.originX??50,f=n.originY??50;t.style.transformOrigin=`${d}% ${f}%`}if(r){const d=r.clipTop??0,f=r.clipRight??0,b=r.clipBottom??0,p=r.clipLeft??0;t.style.clipPath=`inset(${d}% ${f}% ${b}% ${p}%)`}if(a){const d=di(a);d&&(t.style.filter=d)}}buildTransformPart(t,e){if(typeof e!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${e}px)`;case"y":case"motionPathY":return`translateY(${e}px)`;case"z":return`translateZ(${e}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${e}deg)`;case"rotateX":return`rotateX(${e}deg)`;case"rotateY":return`rotateY(${e}deg)`;case"scale":return`scale(${e})`;case"scaleX":return`scaleX(${e})`;case"scaleY":return`scaleY(${e})`;case"scaleZ":return`scaleZ(${e})`;case"skewX":return`skewX(${e}deg)`;case"skewY":return`skewY(${e}deg)`;default:return null}}applyShine(t,e){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const s=t.dataset.shineBase,n=-20+e*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=`${n}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,e,s){let n;if(t.namespaceURI===Ai&&e in zt){const o=Array.isArray(s)?s.join(", "):String(s);t.style[zt[e]]=o;return}else e==="fill"&&t.dataset?.elementType==="text"?n="color":n=bi[e]??e;let a;typeof s=="number"?Qt.has(e)||Qt.has(n)?a=`${s}px`:a=String(s):Array.isArray(s)?a=s.join(", "):a=s,t.style[n]=a}}class gt{media;offset;driftTolerance;constructor(t,e={}){this.media=t,this.offset=e.offset??0,this.driftTolerance=Math.max(0,e.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,e){const s=this.targetTime(t);e?(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 Gt(i,t,e,s,n){const r=e-n;if(r<0){t.paused||t.pause(),t.currentTime=0;return}i.update(r,s)}class Tt{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,e={}){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=e,this.adapter=new j}async load(t){this.scenarioList=[],this.scenarioId=void 0,await this.loadSource(t)}async loadSource(t){let e;if(typeof t=="string"){const s=await fetch(t);if(!s.ok)throw new Error(`Failed to load animation: ${s.statusText}`);e=await s.json()}else e=t;this.useDefinition(e),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}useDefinition(t){const e={...t.config};this.options.speed!==void 0&&(e.speed=this.options.speed),this.options.loop!==void 0&&(e.loop=this.options.loop),this.options.alternate!==void 0&&(e.alternate=this.options.alternate),this.timeline=J({...t,config:e}),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,e={}){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 n=e.initial===void 0?t[0]:t.find(r=>r.id===e.initial);if(!n)throw new Error(`tinyfly: there is no scenario "${e.initial}"`);this.scenarioList=[...t],this.scenarioId=n.id,await this.loadSource(n.timeline)}get scenarios(){return this.scenarioList.map(t=>({id:t.id,label:t.label??t.id}))}get scenario(){return this.scenarioId}setScenario(t){const e=this.scenarioList.find(o=>o.id===t);if(!e||!this.timeline)return!1;if(t===this.scenarioId)return!0;const s=this.isPlaying,n=this.currentTime>=this.duration-.5,r=this.currentMarker?.id;this.stopAnimationLoop(),this.stepping=!1,this.pausedByVisibility=!1,this.restoreAuthored(),this.scenarioId=t,this.useDefinition(e.timeline),this.lastMarkerId=null;let a=0;return this.reducedMotion||n?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 e={style:t.getAttribute("style")};t.children.length===0&&(e.text=t.textContent??"");const s=t.tagName.toLowerCase()==="path"?t:t.querySelector("path");s&&(e.path={element:s,d:s.getAttribute("d")}),this.authored.set(t,e)}restoreAuthored(){for(const[t,e]of this.authored){e.style===null?t.removeAttribute("style"):t.setAttribute("style",e.style),e.text!==void 0&&t.textContent!==e.text&&(t.textContent=e.text),e.path&&(e.path.d===null?e.path.element.removeAttribute("d"):e.path.element.setAttribute("d",e.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 e;for(const s of this.markers)if(s.time<=t+.5)e=s;else break;return e}caption(t,e){const s=t?this.markers.find(a=>a.id===t):this.currentMarker;if(!s)return;const n=e??this.language(),r=a=>a?.[n]?.[s.id]??a?.[n.split("-")[0]]?.[s.id];return r(this.options.captions)??r(this.timeline?.captions)??s.label}next(){if(!this.timeline)return;const t=this.currentTime,e=this.markers.find(s=>s.time>t+.5);if(this.reducedMotion){this.seek(e?e.time:this.duration);return}t>=this.duration-.5||(this.stepping=e!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,e=[...this.markers].reverse().find(s=>s.time<t-.5);this.pause(),this.seek(e?e.time:0)}goToMarker(t){const e=this.markers.find(s=>s.id===t);e&&(this.pause(),this.seek(e.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 e=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,e))),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(e=>{for(const s of e)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,e=t?.id;e!==this.lastMarkerId&&(this.lastMarkerId=e,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(e=>{const s=e,n=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:n,sync:new gt(s)})})}syncAllMedia(t,e){for(const s of this.mediaTargets)Gt(s.sync,s.el,t,e,s.startTime)}loadFromString(t){const e=JSON.parse(t);this.load(e)}registerTarget(t,e){if(typeof e=="string"){const s=this.container.querySelector(e);s&&(this.rememberAuthored(s),this.targets[t]=s,this.adapter.registerTarget(t,s))}else this.rememberAuthored(e),this.targets[t]=e,this.adapter.registerTarget(t,e)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(e=>{const s=e.closest("[data-tinyfly-symbol]");if(s&&s!==e)return;const n=e.getAttribute("data-tinyfly");n&&this.registerTarget(n,e)}),this.timeline&&new Set(this.timeline.tracks.map(s=>s.target)).forEach(s=>{if(!this.targets[s]){const n=this.container.querySelector(`[data-tinyfly="${s}"]`)||this.container.querySelector(`.${s}`)||this.container.querySelector(`#${s}`);n&&this.registerTarget(s,n)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const e=new Map(t.map(s=>[s.id,s]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(s=>{const n=s.getAttribute("data-tinyfly-symbol");if(!n)return;const r=e.get(n);if(!r||!r.timeline.tracks?.length)return;const a=new j;s.querySelectorAll("[data-tinyfly]").forEach(o=>{const c=o.getAttribute("data-tinyfly");c&&a.registerTarget(c,o)}),this.symbolInstances.push({adapter:a,timeline:J(r.timeline)})})}attachMedia(t,e){this.mediaSync=new gt(t,e),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=e=>{if(this.isDestroyed||!this.timeline)return;const s=e-(this.lastTime??e);this.lastTime=e;const n=this.playhead;this.timeline.tick(s),this.stopAtMarker(n),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 e=this.timeline,s={time:e.currentTime,iteration:e.loopIteration,direction:e.direction};this.playhead=s;const n=this.markers;if(n.length===0)return;const{crossings:r}=ai(n.map(a=>a.time),t,s,{duration:e.duration,alternate:e.config.alternate===!0,holding:e.repeatDelayRemaining>0});for(const a of r){if(a.kind!=="event")continue;const o=n[a.index];if(this.stepping||o.pause){this.stepping=!1,e.pause(),e.seek(o.time),this.playhead={time:o.time,iteration:e.loopIteration,direction:e.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 e of this.symbolInstances){const s=e.timeline.duration;e.adapter.applyState(e.timeline.getStateAtTime(s>0?t%s:t))}}}async function Si(i,t,e={}){const s=new Tt(i,{...e,autoplay:!0});return await s.load(t),s}function Mi(i,t={}){return new Tt(i,t)}class Zt{container;containerA;containerB;adapterA;adapterB;timelineA=null;timelineB=null;symbolDefs=new Map;nestedByAdapter=new Map;sequence=null;options;_currentSceneIndex=0;_state="idle";_isPlaying=!1;_isDestroyed=!1;loopIteration=0;animationFrameId;lastTime;transitionTimer;constructor(t,e={}){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=e,this.container.style.position="relative",this.container.style.overflow="hidden",this.containerA=this.createSceneContainer(),this.containerB=this.createSceneContainer(),this.container.appendChild(this.containerA),this.container.appendChild(this.containerB),this.containerB.style.visibility="hidden",this.adapterA=new j,this.adapterB=new j}async load(t){let e;if(typeof t=="string"){const s=await fetch(t);if(!s.ok)throw new Error(`Failed to load sequence: ${s.statusText}`);e=await s.json()}else e=t;this.sequence=e,this.symbolDefs.clear();for(const s of e.symbols??[])s.timeline?.tracks?.length&&this.symbolDefs.set(s.id,s.timeline);this.container.style.width=`${e.canvas.width}px`,this.container.style.height=`${e.canvas.height}px`,e.scenes.length>0&&(this.renderScene(e.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(e.scenes[0])),this.options.autoplay&&this.play()}play(){if(!(!this.sequence||this._isDestroyed)&&this.sequence.scenes.length!==0){if(this._isPlaying=!0,this._state==="idle"){if(this._state="playing-scene",this._currentSceneIndex=0,this.timelineA)this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play();else{this.onSceneComplete();return}this.options.onSceneChange?.(0)}else this._state==="playing-scene"&&this.timelineA&&this.timelineA.play();this.startAnimationLoop()}}pause(){this._isPlaying&&(this._isPlaying=!1,this.timelineA&&this.timelineA.pause(),this.timelineB&&this.timelineB.pause(),this.stopAnimationLoop())}stop(){if(this._isPlaying=!1,this._state="idle",this._currentSceneIndex=0,this.loopIteration=0,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.stopAnimationLoop(),this.sequence&&this.sequence.scenes.length>0&&(this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this.renderScene(this.sequence.scenes[0],this.containerA,this.adapterA),this.timelineA=this.createTimeline(this.sequence.scenes[0]),this.timelineA)){const t=this.timelineA.getStateAtTime(0);this.adapterA.applyState(t),this.applyNested(this.adapterA,0)}}goToScene(t){if(!this.sequence||t<0||t>=this.sequence.scenes.length)return;const e=this._isPlaying;this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this._currentSceneIndex=t,this._state=e?"playing-scene":"idle",this.clearContainer(this.containerA),this.clearContainer(this.containerB),this.adapterA.clearTargets(),this.adapterB.clearTargets(),this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB);const s=this.sequence.scenes[t];if(this.renderScene(s,this.containerA,this.adapterA),this.timelineA=this.createTimeline(s),this.options.onSceneChange?.(t),e)this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play(),this.startAnimationLoop()):this.onSceneComplete();else if(this.timelineA){const n=this.timelineA.getStateAtTime(0);this.adapterA.applyState(n),this.applyNested(this.adapterA,0)}}destroy(){this._isDestroyed=!0,this._isPlaying=!1,this.transitionTimer!==void 0&&(clearTimeout(this.transitionTimer),this.transitionTimer=void 0),this.stopAnimationLoop(),this.adapterA.clearTargets(),this.adapterB.clearTargets();for(const t of this.nestedByAdapter.values())for(const e of t)e.adapter.clearTargets();this.nestedByAdapter.clear(),this.timelineA&&this.timelineA.stop(),this.timelineB&&this.timelineB.stop(),this.timelineA=null,this.timelineB=null,this.containerA.parentNode&&this.containerA.remove(),this.containerB.parentNode&&this.containerB.remove(),this.sequence=null}get currentSceneIndex(){return this._currentSceneIndex}get sceneCount(){return this.sequence?.scenes.length??0}get isPlaying(){return this._isPlaying}get state(){return this._state}createSceneContainer(){const t=document.createElement("div");return t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t}renderScene(t,e,s){e.innerHTML="",s.clearTargets();const n=document.createElement("div");n.style.cssText="position:absolute;inset:0;transform-origin:center center",n.setAttribute("data-tinyfly","Camera"),e.appendChild(n),s.registerTarget("Camera",n);for(const r of t.elements){if(!r.html)continue;const a=document.createElement("div");a.innerHTML=r.html.trim();const o=a.firstElementChild;if(o){n.appendChild(o);const c=o.getAttribute("data-tinyfly");c&&s.registerTarget(c,o)}}this.setupNested(n,s)}setupNested(t,e){const s=[];t.querySelectorAll("[data-tinyfly-symbol]").forEach(n=>{const r=n.getAttribute("data-tinyfly-symbol");if(!r)return;const a=this.symbolDefs.get(r);if(!a)return;const o=new j;n.querySelectorAll("[data-tinyfly]").forEach(c=>{const h=c.getAttribute("data-tinyfly");h&&o.registerTarget(h,c)}),s.push({adapter:o,timeline:J(a)})}),s.length?this.nestedByAdapter.set(e,s):this.nestedByAdapter.delete(e)}applyNested(t,e){const s=this.nestedByAdapter.get(t);if(s)for(const n of s){const r=n.timeline.duration;n.adapter.applyState(n.timeline.getStateAtTime(r>0?e%r:e))}}clearContainer(t){t.innerHTML=""}createTimeline(t){return t.timeline?J(t.timeline):null}onSceneComplete(){if(this._isDestroyed||!this.sequence)return;const t=this._currentSceneIndex+1;if(t>=this.sequence.scenes.length){const e=this.options.loop??this.sequence.loop??0;e===-1||e>0&&this.loopIteration<e-1?(this.loopIteration++,this.beginTransitionTo(0)):(this._isPlaying=!1,this._state="idle",this.stopAnimationLoop(),this.options.onComplete?.())}else this.beginTransitionTo(t)}beginTransitionTo(t){if(!this.sequence||this._isDestroyed)return;const e=this.sequence.scenes[t],s=e.transition;if(s.type==="none"||s.duration<=0){this.switchToScene(t);return}this._state="transitioning",this.containerB.style.visibility="visible",this.renderScene(e,this.containerB,this.adapterB),this.timelineB=this.createTimeline(e),this.timelineB&&this.timelineB.play(),this.applyTransition(s.type,s.duration),this.transitionTimer=window.setTimeout(()=>{this.finishTransition(t)},s.duration)}applyTransition(t,e){const s=`${e}ms`,n="ease-in-out";switch(this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),t){case"fade":this.containerB.style.opacity="0";break;case"slide-left":this.containerB.style.transform="translateX(100%)";break;case"slide-right":this.containerB.style.transform="translateX(-100%)";break;case"slide-up":this.containerB.style.transform="translateY(100%)";break;case"slide-down":this.containerB.style.transform="translateY(-100%)";break}switch(this.containerB.offsetHeight,this.containerA.style.transition=`opacity ${s} ${n}, transform ${s} ${n}`,this.containerB.style.transition=`opacity ${s} ${n}, transform ${s} ${n}`,t){case"fade":this.containerA.style.opacity="0",this.containerB.style.opacity="1";break;case"slide-left":this.containerA.style.transform="translateX(-100%)",this.containerB.style.transform="translateX(0)";break;case"slide-right":this.containerA.style.transform="translateX(100%)",this.containerB.style.transform="translateX(0)";break;case"slide-up":this.containerA.style.transform="translateY(-100%)",this.containerB.style.transform="translateY(0)";break;case"slide-down":this.containerA.style.transform="translateY(100%)",this.containerB.style.transform="translateY(0)";break}}resetTransitionStyles(t){t.style.transition="",t.style.opacity="1",t.style.transform=""}finishTransition(t){this.transitionTimer=void 0,this.timelineA&&(this.timelineA.stop(),this.timelineA=null),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const e=this.containerA;this.containerA=this.containerB,this.containerB=e;const s=this.adapterA;this.adapterA=this.adapterB,this.adapterB=s,this.timelineA=this.timelineB,this.timelineB=null,this.containerB.style.visibility="hidden",this.resetTransitionStyles(this.containerA),this.resetTransitionStyles(this.containerB),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.playbackState!=="playing"&&this.timelineA.play()):this.onSceneComplete()}switchToScene(t){if(!this.sequence||this._isDestroyed)return;this.timelineA&&this.timelineA.stop(),this.adapterA.clearTargets(),this.clearContainer(this.containerA);const e=this.sequence.scenes[t];this.renderScene(e,this.containerA,this.adapterA),this.timelineA=this.createTimeline(e),this._currentSceneIndex=t,this._state="playing-scene",this.options.onSceneChange?.(t),this.timelineA?(this.timelineA.onComplete=()=>this.onSceneComplete(),this.timelineA.play()):this.onSceneComplete()}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=e=>{if(this._isDestroyed||!this._isPlaying)return;const s=e-(this.lastTime??e);if(this.lastTime=e,this.timelineA&&this.timelineA.playbackState==="playing"){this.timelineA.tick(s);const n=this.timelineA.getStateAtTime(this.timelineA.currentTime);this.adapterA.applyState(n),this.applyNested(this.adapterA,this.timelineA.currentTime)}if(this._state==="transitioning"&&this.timelineB&&this.timelineB.playbackState==="playing"){this.timelineB.tick(s);const n=this.timelineB.getStateAtTime(this.timelineB.currentTime);this.adapterB.applyState(n),this.applyNested(this.adapterB,this.timelineB.currentTime)}this._isPlaying?this.animationFrameId=requestAnimationFrame(t):this.animationFrameId=void 0};this.animationFrameId=requestAnimationFrame(t)}stopAnimationLoop(){this.animationFrameId!==void 0&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0)}}async function _i(i,t,e={}){const s=new Zt(i,{...e,autoplay:!0});return await s.load(t),s}const ki={type:"none",duration:0};v.DEFAULT_TRANSITION=ki,v.MediaSync=gt,v.TinyflyPlayer=Tt,v.TinyflySequencer=Zt,v.create=Mi,v.play=Si,v.playSequence=_i,v.syncMediaElement=Gt,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
|