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