@algorisys/tinyfly 0.65.0 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -6
- package/lib/browser/tinyfly.iife.js +21 -2
- package/lib/browser/tinyfly.js +1313 -1118
- package/lib/browser/tinyfly.umd.js +21 -2
- package/lib/embed/tinyfly-embed.iife.js +2 -2
- package/lib/embed/tinyfly-embed.js +19 -18
- package/lib/types/browser/index.d.ts +10 -0
- package/lib/types/embed/auto-mount.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(O){"use strict";function ce(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function le(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const U=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 he(e){return e.property==="motionPath"&&"motionPathConfig"in e}function xt(e,t,s="start"){if(t<=1)return 0;if(typeof s=="number"){const n=Math.max(0,Math.min(t-1,s));return Math.abs(e-n)}switch(s){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 ue(e,t="start"){if(e<=1)return 0;let s=0;for(let n=0;n<e;n++)s=Math.max(s,xt(n,e,t));return s}function vt(e,t,s){if(s.offsets)return s.offsets[e]??0;const n=s.from??"start",i=xt(e,t,n);if(s.amount!==void 0){const r=ue(t,n);return r===0?0:s.amount*i/r}return s.each!==void 0?s.each*i:0}function fe(e,t){return Array.from({length:e},(s,n)=>vt(n,e,t))}function ut(e,t){return e<=1?0:Math.max(...fe(e,t))}const j=1,At=6e4,tt=At/j,q={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1};class de{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??q.stiffness,this.damping=t.damping??q.damping,this.mass=t.mass??q.mass,this.restDelta=t.restDelta??q.restDelta,this.restSpeed=t.restSpeed??q.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??q.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 s=Math.floor(t/j);if(this.simulateTo(s+1),this.settledStep!==null&&s>=this.settledStep)return this.to;const n=this.samples[Math.min(s,this.samples.length-1)],i=this.samples[Math.min(s+1,this.samples.length-1)],r=t/j-s;return n+(i-n)*r}settleTime(){return this.simulateTo(tt+1),this.settledStep!==null?this.settledStep*j:At}simulateTo(t){if(this.settledStep!==null)return;const s=Math.min(t,tt+1),n=j/1e3;for(;this.samples.length<s;){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*n;const l=i+this.velocity*n;if(this.samples.push(l),this.isAtRest(l)){this.settledStep=this.samples.length-1;return}}this.samples.length>tt&&(this.settledStep=tt)}}const Pt=4,pe=.002,me=1e-4,ge=6e4;function ft(e){const t=e.friction??Pt;return t>0?t:Pt}function ye(e){return e.from+e.velocity/ft(e)}function be(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 s=t[0];for(const n of t)Math.abs(n-e)<Math.abs(s-e)&&(s=n);return s}function It(e){let t=be(ye(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 Ct(e){const t=Math.abs(It(e)-e.from);if(t===0)return 0;const s=e.restDelta??Math.max(me,t*pe);if(s>=t)return 0;const n=Math.log(t/s)/ft(e);return Math.min(ge,n*1e3)}function Rt(e,t){if(t<=0)return e.from;const s=It(e);if(t>=Ct(e))return s;const n=ft(e);return e.from+(s-e.from)*(1-Math.exp(-n*t/1e3))}const dt=e=>e,ke=e=>e*e,Me=e=>1-(1-e)*(1-e),Te=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,Et=e=>e*e*e,Dt=e=>1-Math.pow(1-e,3),$t=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Se={linear:dt,"ease-in":Et,"ease-out":Dt,"ease-in-out":$t,"ease-in-quad":ke,"ease-out-quad":Me,"ease-in-out-quad":Te,"ease-in-cubic":Et,"ease-out-cubic":Dt,"ease-in-out-cubic":$t};function we(e){const[t,s,n,i]=e,r=3*t,a=3*(n-t)-r,o=1-r-a,c=3*s,l=3*(i-s)-c,u=1-c-l,h=p=>((o*p+a)*p+r)*p,f=p=>((u*p+l)*p+c)*p,d=p=>(3*o*p+2*a)*p+r,b=p=>{let m=p;for(let T=0;T<8;T++){const w=h(m)-p;if(Math.abs(w)<1e-7)return m;const g=d(m);if(Math.abs(g)<1e-7)break;m-=w/g}let k=0,y=1;for(m=p;k<y;){const T=h(m);if(Math.abs(T-p)<1e-7)return m;p>T?k=m:y=m,m=(k+y)/2}return m};return p=>{if(p<=0)return 0;if(p>=1)return 1;const m=b(p);return f(m)}}function pt(e,t="out"){if(t==="out")return e;const s=n=>1-e(1-n);return t==="in"?s:n=>n<.5?s(n*2)/2:e(n*2-1)/2+.5}function _e(e=1,t=.3){const s=Math.max(1,e),n=t/(2*Math.PI)*Math.asin(1/s);return i=>i<=0?0:i>=1?1:s*Math.pow(2,-10*i)*Math.sin((i-n)*(2*Math.PI)/t)+1}const xe=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 n=e-2.625/2.75;return 7.5625*n*n+.984375};function ve(e=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const s=t-1;return s*s*((e+1)*s+e)+1}}function Ae(e,t="end"){const s=Math.max(1,Math.floor(e));return n=>{if(n>=1)return 1;if(n<=0)return t==="start"||t==="both"?t==="start"?1/s:1/(s+1):0;const i=Math.floor(n*s);switch(t){case"start":return Math.min(1,(i+1)/s);case"both":return(i+1)/(s+1);case"none":return s===1?0:Math.min(1,i/(s-1));default:return i/s}}}function Pe(e){switch(e.type){case"steps":return Ae(e.count,e.position);case"elastic":return pt(_e(e.amplitude,e.period),e.mode);case"bounce":return pt(xe,e.mode);case"back":return pt(ve(e.overshoot),e.mode)}}function Ie(e){return e===void 0?dt:ce(e)?we(e.points):le(e)?Pe(e):Se[e]??dt}const Ot=32,Ce=256,H=new Map,Re=/[MmLlHhVvCcSsQqTtAaZz]/,Ee=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,De={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function $e(e){const t=[];let s=0,n=null;const i=()=>{for(;s<e.length&&/[\s,]/.test(e[s]);)s++};for(;s<e.length&&(i(),!(s>=e.length));){const r=e[s];if(Re.test(r)){n={type:r,args:[]},t.push(n),s++;continue}if(!n)break;const a=n.type==="A"||n.type==="a",o=n.args.length%7;if(a&&(o===3||o===4)){if(r!=="0"&&r!=="1")break;n.args.push(r==="1"?1:0),s++;continue}const c=Ee.exec(e.slice(s));if(!c)break;n.args.push(parseFloat(c[0])),s+=c[0].length}return t}function Oe(e,t,s,n,i,r,a,o,c){if(e===o&&t===c)return[];let l=Math.abs(s),u=Math.abs(n);if(l===0||u===0)return[[e,t,o,c,o,c]];const h=i*Math.PI/180,f=Math.cos(h),d=Math.sin(h),b=(e-o)/2,p=(t-c)/2,m=f*b+d*p,k=-d*b+f*p,y=m*m/(l*l)+k*k/(u*u);if(y>1){const P=Math.sqrt(y);l*=P,u*=P}const T=r===a?-1:1,w=l*l*u*u-l*l*k*k-u*u*m*m,g=l*l*k*k+u*u*m*m,_=T*Math.sqrt(Math.max(0,w/g)),S=_*l*k/u,I=-_*u*m/l,W=f*S-d*I+(e+o)/2,x=d*S+f*I+(t+c)/2,C=(P,R,$,B)=>{const wt=P*$+R*B,ct=Math.sqrt((P*P+R*R)*($*$+B*B)),J=Math.acos(Math.max(-1,Math.min(1,wt/ct)));return P*B-R*$<0?-J:J},A=C(1,0,(m-S)/l,(k-I)/u);let M=C((m-S)/l,(k-I)/u,(-m-S)/l,(-k-I)/u);!a&&M>0&&(M-=2*Math.PI),a&&M<0&&(M+=2*Math.PI);const v=Math.max(1,Math.ceil(Math.abs(M)/(Math.PI/2))),L=M/v,E=4/3*Math.tan(L/4),D=P=>{const R=l*Math.cos(P),$=u*Math.sin(P);return[f*R-d*$+W,d*R+f*$+x]},Z=P=>{const R=-l*Math.sin(P),$=u*Math.cos(P);return[f*R-d*$,d*R+f*$]},K=[];for(let P=0;P<v;P++){const R=A+P*L,$=R+L,[B,wt]=D(R),[ct,J]=P===v-1?[o,c]:D($),[Ws,Bs]=Z(R),[Us,js]=Z($);K.push([B+E*Ws,wt+E*Bs,ct-E*Us,J-E*js,ct,J])}return K}function F(e,t,s,n,i){const r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*s+i*i*i*n}function Lt(e,t,s,n,i){const r=1-i;return 3*r*r*(t-e)+6*r*i*(s-t)+3*i*i*(n-s)}function z(e,t,s,n){return{subpath:0,type:"L",points:[s,n],startX:e,startY:t,endX:s,endY:n,length:Math.hypot(s-e,n-t)}}function et(e,t,s){const[n,i,r,a,o,c]=s,l=[0];let u=e,h=t,f=0;for(let d=1;d<=Ot;d++){const b=d/Ot,p=F(e,n,r,o,b),m=F(t,i,a,c,b);f+=Math.hypot(p-u,m-h),l.push(f),u=p,h=m}return{subpath:0,type:"C",points:[n,i,r,a,o,c],startX:e,startY:t,endX:o,endY:c,length:f,lengths:l}}function st(e){const t=H.get(e);if(t)return t;const s=[];let n=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,s.push(p)};for(const{type:p,args:m}of $e(e)){const k=p.toUpperCase(),y=p!==k,T=De[k];if(k==="Z"){(n!==r||i!==a)&&h(z(n,i,r,a)),l>=0&&u.add(l),n=r,i=a,o=c=null;continue}for(let w=0;w+T<=m.length;w+=T){const g=m.slice(w,w+T),_=y?n:0,S=y?i:0;let I=null,W=null;switch(k){case"M":w===0?(n=g[0]+_,i=g[1]+S,r=n,a=i,(l<0||s[s.length-1]?.subpath===l)&&l++):(h(z(n,i,g[0]+_,g[1]+S)),n=g[0]+_,i=g[1]+S);break;case"L":h(z(n,i,g[0]+_,g[1]+S)),n=g[0]+_,i=g[1]+S;break;case"H":h(z(n,i,g[0]+_,i)),n=g[0]+_;break;case"V":h(z(n,i,n,g[0]+S)),i=g[0]+S;break;case"C":{const x=[g[0]+_,g[1]+S,g[2]+_,g[3]+S,g[4]+_,g[5]+S];h(et(n,i,x)),I=[x[2],x[3]],n=x[4],i=x[5];break}case"S":{const[x,C]=o?[2*n-o[0],2*i-o[1]]:[n,i],A=[x,C,g[0]+_,g[1]+S,g[2]+_,g[3]+S];h(et(n,i,A)),I=[A[2],A[3]],n=A[4],i=A[5];break}case"Q":case"T":{let x=n,C=i;k==="Q"?(x=g[0]+_,C=g[1]+S):c&&(x=2*n-c[0],C=2*i-c[1]);const A=k==="Q"?g[2]+_:g[0]+_,M=k==="Q"?g[3]+S:g[1]+S;h(et(n,i,[n+2/3*(x-n),i+2/3*(C-i),A+2/3*(x-A),M+2/3*(C-M),A,M])),W=[x,C],n=A,i=M;break}case"A":{const x=g[5]+_,C=g[6]+S;let A=n,M=i;for(const v of Oe(n,i,g[0],g[1],g[2],g[3],g[4],x,C))h(et(A,M,v)),A=v[4],M=v[5];n=x,i=C;break}}o=I,c=W}}const f=s.reduce((p,m)=>p+m.length,0),d=[];for(let p=0;p<s.length;){const m=s[p].subpath;let k=p,y=0;for(;k<s.length&&s[k].subpath===m;)y+=s[k++].length;const T=s[p],w=s[k-1],g=u.has(m)||Math.abs(w.endX-T.startX)<1e-9&&Math.abs(w.endY-T.startY)<1e-9;d.push({start:p,end:k,length:y,closed:g}),p=k}const b={segments:s,totalLength:f,subpaths:d};return H.size>=Ce&&H.delete(H.keys().next().value),H.set(e,b),b}function Le(e,t){const s=e.lengths;if(t<=0)return 0;if(t>=e.length)return 1;let n=0,i=s.length-1;for(;n<i-1;){const o=n+i>>1;s[o]<t?n=o:i=o}const r=s[i]-s[n],a=r>0?(t-s[n])/r:0;return(n+a)/(s.length-1)}function Ne(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[s,n,i,r,a,o]=e.points,c=Le(e,t);let l=Lt(e.startX,s,i,a,c),u=Lt(e.startY,n,r,o,c);if(Math.hypot(l,u)<1e-9){const h=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),f=F(e.startX,s,i,a,h),d=F(e.startY,n,r,o,h),b=F(e.startX,s,i,a,c),p=F(e.startY,n,r,o,c);l=c<.5?f-b:b-f,u=c<.5?d-p:p-d}return{x:F(e.startX,s,i,a,c),y:F(e.startY,n,r,o,c),angle:Math.atan2(u,l)*180/Math.PI}}function Nt(e,t,s=0,n=e.length){if(n<=s)return{x:0,y:0,angle:0};let i=0;for(let r=s;r<n;r++){const a=e[r];if(i+a.length>=t||r===n-1)return Ne(a,t-i);i+=a.length}return{x:0,y:0,angle:0}}function Fe(e,t){const{segments:s,totalLength:n}=st(e);return Nt(s,Math.max(0,Math.min(1,t))*n)}const Xe=24,Ye=320,qe=2.5,G=72,Ve=.2,We=128,nt=new Map;let mt=0,X;const Ft=e=>Math.round(e*100)/100;function Xt(e,t){const{segments:s,subpaths:n,totalLength:i}=st(e);if(s.length===0)return[];if(t){const r=n.every(a=>a.closed);return[{segments:s,start:0,end:s.length,length:i,closed:r}]}return n.filter(r=>r.length>0).map(r=>({segments:s,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function gt(e,t){const s=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),n=Nt(e.segments,s*e.length,e.start,e.end);return[n.x,n.y]}function Yt(e){const t=[];let s=0;for(let n=e.start;n<e.end;n++)s+=e.segments[n].length,e.length>0&&t.push(s/e.length);return t}function qt(e,t){const s=[];for(let n=0;n<t;n++)s.push(gt(e,e.closed?n/t:n/(t-1)));return s}function Vt(e){let t=0,s=0;for(const[n,i]of e)t+=n,s+=i;return t/=e.length,s/=e.length,e.map(([n,i])=>[n-t,i-s])}function Be(e,t,s){const n=e.closed&&t.closed;if(s!==void 0)return{offset:n?Math.abs(s)%G/G:0,reversed:s<0};const i=Vt(qt(e,G)),r=Vt(qt(t,G)),a=G;let o={offset:0,reversed:!1},c=1/0;for(const l of[!1,!0]){const u=n?a:1;for(let h=0;h<u;h++){let f=0;for(let d=0;d<a&&f<c;d++){const b=n?l?(h-d+a)%a:(d+h)%a:l?a-1-d:d,p=i[d][0]-r[b][0],m=i[d][1]-r[b][1];f+=p*p+m*m}f<c&&(c=f,o={offset:n?h/a:0,reversed:l})}}return o}function Ue(e,t,s){return s?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function je(e,t,s){return s?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function He(e,t,s){const n=e.closed&&t.closed,i=Be(e,t,s.shapeIndex),r=Math.max(Xe,Math.min(Ye,Math.ceil(Math.max(e.length,t.length)/qe))),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 Yt(e))o(h);for(const h of Yt(t))o(je(h,i,n));let c=[...a].sort((h,f)=>h-f);n&&(c=c.filter(h=>h<1));const l=[],u=[];for(const h of c)l.push(...gt(e,h)),u.push(...gt(t,Ue(h,i,n)));return ze({from:l,to:u,closed:n})}function ze(e){const t=e.from.length/2;if(t<=3)return e;const s=new Uint8Array(t);s[0]=1,s[t-1]=1;const n=[[0,t-1]];for(;n.length>0;){const[a,o]=n.pop();let c=-1,l=Ve;for(let u=a+1;u<o;u++){const h=Math.max(Wt(e.from,a,o,u),Wt(e.to,a,o,u));h>l&&(l=h,c=u)}c!==-1&&(s[c]=1,n.push([a,c],[c,o]))}const i=[],r=[];for(let a=0;a<t;a++)s[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 Wt(e,t,s,n){const i=e[t*2],r=e[t*2+1],a=e[s*2]-i,o=e[s*2+1]-r,c=e[n*2]-i,l=e[n*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 Ge(e,t,s){const n=s.shapeIndex;if(X&&X.from===e&&X.to===t&&X.shapeIndex===n)return X.plan;const r=nt.get(String(n??"auto"))?.get(e)?.get(t);if(r)return X={from:e,to:t,shapeIndex:n,plan:r},r;const a=st(e).subpaths.filter(d=>d.length>0).length===st(t).subpaths.filter(d=>d.length>0).length,o=Xt(e,!a),c=Xt(t,!a),l={pairs:o.map((d,b)=>He(d,c[b],s))};mt>=We&&(nt.clear(),mt=0);const u=String(n??"auto"),h=nt.get(u)??new Map;nt.set(u,h);const f=h.get(e)??new Map;return h.set(e,f),f.set(t,l),mt++,X={from:e,to:t,shapeIndex:n,plan:l},l}function Qe(e,t,s,n={}){if(!e)return t;if(!t)return e;const i=Math.max(0,Math.min(1,s));if(i===0)return e;if(i===1)return t;const r=Ge(e,t,n);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=Ft(o.from[c]+(o.to[c]-o.from[c])*i),u=Ft(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 Ze(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const N=(e,t,s)=>e+(t-e)*s,Bt=512,yt=new Map,bt=new Map;function Ut(e){const t=yt.get(e);if(t)return t;const s=e.replace("#",""),n=[parseInt(s.slice(0,2),16),parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16)];return yt.size<Bt&&yt.set(e,n),n}const jt=e=>e.charCodeAt(0)===35,Ht=e=>e.startsWith("rgb"),zt=e=>e.startsWith("rgba"),Ke=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,kt=e=>Math.round(e).toString(16).padStart(2,"0");function Je(e,t,s){return`#${kt(e)}${kt(t)}${kt(s)}`}function Gt(e){const t=bt.get(e);if(t)return t;const s=e.match(Ke);if(!s)throw new Error(`Invalid rgb color: ${e}`);const n=parseInt(s[1],10),i=parseInt(s[2],10),r=parseInt(s[3],10),a=s[4]!==void 0?[n,i,r,parseFloat(s[4])]:[n,i,r];return bt.size<Bt&&bt.set(e,a),a}const ts=(e,t,s)=>{if(jt(e)&&jt(t)){const[n,i,r]=Ut(e),[a,o,c]=Ut(t),l=N(n,a,s),u=N(i,o,s),h=N(r,c,s);return Je(l,u,h)}if((Ht(e)||zt(e))&&(Ht(t)||zt(t))){const n=Gt(e),i=Gt(t),r=Math.round(N(n[0],i[0],s)),a=Math.round(N(n[1],i[1],s)),o=Math.round(N(n[2],i[2],s));if(n.length===4||i.length===4){const c=n[3]??1,l=i[3]??1,u=N(c,l,s);return`rgba(${r}, ${a}, ${o}, ${u})`}return`rgb(${r}, ${a}, ${o})`}return s<1?e:t},es=(e,t,s)=>{const n=Math.min(e.length,t.length),i=[];for(let r=0;r<n;r++)i.push(N(e[r],t[r],s));return i},Qt=(e,t,s)=>s<1?e:t,ss=(e,t,s)=>Qe(e,t,s);function ns(e){return typeof e=="number"?N:Array.isArray(e)?es:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?ts:Ze(e)?ss:Qt:Qt}function is(e){const t=[...e.keyframes].sort((s,n)=>s.time-n.time);return{...e,keyframes:t}}function Y(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function V(e,t,s,n){const i=s??0;return!n||t<=1?i:i+vt(e,t,n)}class Mt{track;targets;constructor(t){this.track=t,this.targets=Y(t)}getValueAtTime(t){return this.valueForOffset(t-V(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const s=this.targets.length,n=[];for(let i=0;i<s;i++){const r=V(i,s,this.track.delay,this.track.stagger),a=this.valueForOffset(t-r);a!==void 0&&n.push({target:this.targets[i],value:a,start:r+this.track.keyframes[0].time})}return n}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const s=t[t.length-1].time,n=this.track.stagger?ut(this.targets.length,this.track.stagger):0;return s+(this.track.delay??0)+n+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:s}=this.track;if(s.length===0)return;if(s.length===1||t<=s[0].time)return s[0].value;if(t>=s[s.length-1].time)return s[s.length-1].value;const{from:n,to:i}=this.findSurroundingKeyframes(t);if(!n||!i)return;if(n.time===t)return n.value;const r=i.time-n.time,a=(t-n.time)/r,c=Ie(i.easing)(a);return ns(n.value)(n.value,i.value,c)}findSurroundingKeyframes(t){const{keyframes:s}=this.track;for(let n=0;n<s.length-1;n++)if(t>=s[n].time&&t<=s[n+1].time)return{from:s[n],to:s[n+1]};return{from:null,to:null}}}class rs{track;targets;sampler;constructor(t){this.track=t,this.targets=Y(t),this.sampler=new de(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-V(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const s=this.targets.length,n=[];for(let i=0;i<s;i++){const r=V(i,s,this.track.delay,this.track.stagger);n.push({target:this.targets[i],value:this.sampler.valueAt(t-r),start:r})}return n}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 as{track;targets;duration;constructor(t){this.track=t,this.targets=Y(t),this.duration=Ct(t.inertia)}getValueAtTime(t){return Rt(this.track.inertia,t-V(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const s=this.targets.length,n=[];for(let i=0;i<s;i++){const r=V(i,s,this.track.delay,this.track.stagger);n.push({target:this.targets[i],value:Rt(this.track.inertia,t-r),start:r})}return n}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 os(e,t){const s={...Fe(e.pathData,t)};if(e.matrix){const[n,i,r,a,o,c]=e.matrix,{x:l,y:u}=s;s.x=n*l+r*u+o,s.y=i*l+a*u+c;const h=s.angle*Math.PI/180,f=Math.cos(h),d=Math.sin(h);s.angle=Math.atan2(i*f+a*d,n*f+r*d)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(s.angle+=e.rotateOffset),s}const Tt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},cs=20;function ls(e){const t=Tt[e??"upperCase"]??e??Tt.upperCase,s=Array.from(t);return s.length>0?s:Array.from(Tt.upperCase)}function hs(e,t,s){let n=(e|0)^Math.imul(t+1,2654435761)^Math.imul(s+1,2246822507);return n=Math.imul(n^n>>>16,2146121005),n=Math.imul(n^n>>>15,2221713035),(n^n>>>16)>>>0}function us(e,t,s=0){const n=e.from??"",i=e.to,r=Math.max(0,Math.min(1,t));if(r<=0)return n;if(r>=1)return i;const a=Array.from(n),o=Array.from(i),c=e.rightToLeft??!1;if(e.mode==="type"){const y=Math.round(r*Math.max(a.length,o.length));return c?a.slice(0,Math.max(0,a.length-y)).join("")+o.slice(Math.max(0,o.length-y)).join(""):o.slice(0,y).join("")+a.slice(y).join("")}const l=Math.max(0,Math.min(.999,e.revealDelay??0)),u=Math.max(0,(r-l)/(1-l)),h=Math.floor(u*o.length),f=e.tweenLength===!1?o.length:Math.round(a.length+(o.length-a.length)*r),d=ls(e.chars),b=e.refreshRate??cs,p=b>0?Math.floor(s*b/1e3):0,m=e.seed??1;let k="";for(let y=0;y<f;y++){const T=c?y>=f-h:y<h,w=c?o[o.length-(f-y)]:o[y];T&&w!==void 0||w===" "||w===`
|
|
1
|
+
(function(O){"use strict";function ce(e){return typeof e=="object"&&e!==null&&e.type==="cubic-bezier"}function le(e){return typeof e=="object"&&e!==null&&e.type!=="cubic-bezier"}const U=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 he(e){return e.property==="motionPath"&&"motionPathConfig"in e}function xt(e,t,s="start"){if(t<=1)return 0;if(typeof s=="number"){const n=Math.max(0,Math.min(t-1,s));return Math.abs(e-n)}switch(s){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 ue(e,t="start"){if(e<=1)return 0;let s=0;for(let n=0;n<e;n++)s=Math.max(s,xt(n,e,t));return s}function vt(e,t,s){if(s.offsets)return s.offsets[e]??0;const n=s.from??"start",i=xt(e,t,n);if(s.amount!==void 0){const r=ue(t,n);return r===0?0:s.amount*i/r}return s.each!==void 0?s.each*i:0}function fe(e,t){return Array.from({length:e},(s,n)=>vt(n,e,t))}function ut(e,t){return e<=1?0:Math.max(...fe(e,t))}const j=1,At=6e4,tt=At/j,q={stiffness:180,damping:12,mass:1,velocity:0,restDelta:.01,restSpeed:.1};class de{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??q.stiffness,this.damping=t.damping??q.damping,this.mass=t.mass??q.mass,this.restDelta=t.restDelta??q.restDelta,this.restSpeed=t.restSpeed??q.restSpeed,this.distance=Math.abs(this.to-this.from)||1,this.samples=[this.from],this.velocity=t.velocity??q.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 s=Math.floor(t/j);if(this.simulateTo(s+1),this.settledStep!==null&&s>=this.settledStep)return this.to;const n=this.samples[Math.min(s,this.samples.length-1)],i=this.samples[Math.min(s+1,this.samples.length-1)],r=t/j-s;return n+(i-n)*r}settleTime(){return this.simulateTo(tt+1),this.settledStep!==null?this.settledStep*j:At}simulateTo(t){if(this.settledStep!==null)return;const s=Math.min(t,tt+1),n=j/1e3;for(;this.samples.length<s;){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*n;const l=i+this.velocity*n;if(this.samples.push(l),this.isAtRest(l)){this.settledStep=this.samples.length-1;return}}this.samples.length>tt&&(this.settledStep=tt)}}const Pt=4,pe=.002,me=1e-4,ge=6e4;function ft(e){const t=e.friction??Pt;return t>0?t:Pt}function ye(e){return e.from+e.velocity/ft(e)}function be(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 s=t[0];for(const n of t)Math.abs(n-e)<Math.abs(s-e)&&(s=n);return s}function It(e){let t=be(ye(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 Ct(e){const t=Math.abs(It(e)-e.from);if(t===0)return 0;const s=e.restDelta??Math.max(me,t*pe);if(s>=t)return 0;const n=Math.log(t/s)/ft(e);return Math.min(ge,n*1e3)}function Rt(e,t){if(t<=0)return e.from;const s=It(e);if(t>=Ct(e))return s;const n=ft(e);return e.from+(s-e.from)*(1-Math.exp(-n*t/1e3))}const dt=e=>e,ke=e=>e*e,Me=e=>1-(1-e)*(1-e),Te=e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,Et=e=>e*e*e,Dt=e=>1-Math.pow(1-e,3),$t=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,Se={linear:dt,"ease-in":Et,"ease-out":Dt,"ease-in-out":$t,"ease-in-quad":ke,"ease-out-quad":Me,"ease-in-out-quad":Te,"ease-in-cubic":Et,"ease-out-cubic":Dt,"ease-in-out-cubic":$t};function we(e){const[t,s,n,i]=e,r=3*t,a=3*(n-t)-r,o=1-r-a,c=3*s,l=3*(i-s)-c,u=1-c-l,h=p=>((o*p+a)*p+r)*p,f=p=>((u*p+l)*p+c)*p,d=p=>(3*o*p+2*a)*p+r,b=p=>{let m=p;for(let T=0;T<8;T++){const w=h(m)-p;if(Math.abs(w)<1e-7)return m;const g=d(m);if(Math.abs(g)<1e-7)break;m-=w/g}let k=0,y=1;for(m=p;k<y;){const T=h(m);if(Math.abs(T-p)<1e-7)return m;p>T?k=m:y=m,m=(k+y)/2}return m};return p=>{if(p<=0)return 0;if(p>=1)return 1;const m=b(p);return f(m)}}function pt(e,t="out"){if(t==="out")return e;const s=n=>1-e(1-n);return t==="in"?s:n=>n<.5?s(n*2)/2:e(n*2-1)/2+.5}function _e(e=1,t=.3){const s=Math.max(1,e),n=t/(2*Math.PI)*Math.asin(1/s);return i=>i<=0?0:i>=1?1:s*Math.pow(2,-10*i)*Math.sin((i-n)*(2*Math.PI)/t)+1}const xe=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 n=e-2.625/2.75;return 7.5625*n*n+.984375};function ve(e=1.70158){return t=>{if(t<=0)return 0;if(t>=1)return 1;const s=t-1;return s*s*((e+1)*s+e)+1}}function Ae(e,t="end"){const s=Math.max(1,Math.floor(e));return n=>{if(n>=1)return 1;if(n<=0)return t==="start"||t==="both"?t==="start"?1/s:1/(s+1):0;const i=Math.floor(n*s);switch(t){case"start":return Math.min(1,(i+1)/s);case"both":return(i+1)/(s+1);case"none":return s===1?0:Math.min(1,i/(s-1));default:return i/s}}}function Pe(e){switch(e.type){case"steps":return Ae(e.count,e.position);case"elastic":return pt(_e(e.amplitude,e.period),e.mode);case"bounce":return pt(xe,e.mode);case"back":return pt(ve(e.overshoot),e.mode)}}function Ie(e){return e===void 0?dt:ce(e)?we(e.points):le(e)?Pe(e):Se[e]??dt}const Ot=32,Ce=256,H=new Map,Re=/[MmLlHhVvCcSsQqTtAaZz]/,Ee=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/,De={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};function $e(e){const t=[];let s=0,n=null;const i=()=>{for(;s<e.length&&/[\s,]/.test(e[s]);)s++};for(;s<e.length&&(i(),!(s>=e.length));){const r=e[s];if(Re.test(r)){n={type:r,args:[]},t.push(n),s++;continue}if(!n)break;const a=n.type==="A"||n.type==="a",o=n.args.length%7;if(a&&(o===3||o===4)){if(r!=="0"&&r!=="1")break;n.args.push(r==="1"?1:0),s++;continue}const c=Ee.exec(e.slice(s));if(!c)break;n.args.push(parseFloat(c[0])),s+=c[0].length}return t}function Oe(e,t,s,n,i,r,a,o,c){if(e===o&&t===c)return[];let l=Math.abs(s),u=Math.abs(n);if(l===0||u===0)return[[e,t,o,c,o,c]];const h=i*Math.PI/180,f=Math.cos(h),d=Math.sin(h),b=(e-o)/2,p=(t-c)/2,m=f*b+d*p,k=-d*b+f*p,y=m*m/(l*l)+k*k/(u*u);if(y>1){const P=Math.sqrt(y);l*=P,u*=P}const T=r===a?-1:1,w=l*l*u*u-l*l*k*k-u*u*m*m,g=l*l*k*k+u*u*m*m,_=T*Math.sqrt(Math.max(0,w/g)),S=_*l*k/u,I=-_*u*m/l,W=f*S-d*I+(e+o)/2,x=d*S+f*I+(t+c)/2,C=(P,R,$,B)=>{const wt=P*$+R*B,ct=Math.sqrt((P*P+R*R)*($*$+B*B)),J=Math.acos(Math.max(-1,Math.min(1,wt/ct)));return P*B-R*$<0?-J:J},A=C(1,0,(m-S)/l,(k-I)/u);let M=C((m-S)/l,(k-I)/u,(-m-S)/l,(-k-I)/u);!a&&M>0&&(M-=2*Math.PI),a&&M<0&&(M+=2*Math.PI);const v=Math.max(1,Math.ceil(Math.abs(M)/(Math.PI/2))),L=M/v,E=4/3*Math.tan(L/4),D=P=>{const R=l*Math.cos(P),$=u*Math.sin(P);return[f*R-d*$+W,d*R+f*$+x]},Z=P=>{const R=-l*Math.sin(P),$=u*Math.cos(P);return[f*R-d*$,d*R+f*$]},K=[];for(let P=0;P<v;P++){const R=A+P*L,$=R+L,[B,wt]=D(R),[ct,J]=P===v-1?[o,c]:D($),[Bs,Us]=Z(R),[js,Hs]=Z($);K.push([B+E*Bs,wt+E*Us,ct-E*js,J-E*Hs,ct,J])}return K}function F(e,t,s,n,i){const r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*s+i*i*i*n}function Lt(e,t,s,n,i){const r=1-i;return 3*r*r*(t-e)+6*r*i*(s-t)+3*i*i*(n-s)}function z(e,t,s,n){return{subpath:0,type:"L",points:[s,n],startX:e,startY:t,endX:s,endY:n,length:Math.hypot(s-e,n-t)}}function et(e,t,s){const[n,i,r,a,o,c]=s,l=[0];let u=e,h=t,f=0;for(let d=1;d<=Ot;d++){const b=d/Ot,p=F(e,n,r,o,b),m=F(t,i,a,c,b);f+=Math.hypot(p-u,m-h),l.push(f),u=p,h=m}return{subpath:0,type:"C",points:[n,i,r,a,o,c],startX:e,startY:t,endX:o,endY:c,length:f,lengths:l}}function st(e){const t=H.get(e);if(t)return t;const s=[];let n=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,s.push(p)};for(const{type:p,args:m}of $e(e)){const k=p.toUpperCase(),y=p!==k,T=De[k];if(k==="Z"){(n!==r||i!==a)&&h(z(n,i,r,a)),l>=0&&u.add(l),n=r,i=a,o=c=null;continue}for(let w=0;w+T<=m.length;w+=T){const g=m.slice(w,w+T),_=y?n:0,S=y?i:0;let I=null,W=null;switch(k){case"M":w===0?(n=g[0]+_,i=g[1]+S,r=n,a=i,(l<0||s[s.length-1]?.subpath===l)&&l++):(h(z(n,i,g[0]+_,g[1]+S)),n=g[0]+_,i=g[1]+S);break;case"L":h(z(n,i,g[0]+_,g[1]+S)),n=g[0]+_,i=g[1]+S;break;case"H":h(z(n,i,g[0]+_,i)),n=g[0]+_;break;case"V":h(z(n,i,n,g[0]+S)),i=g[0]+S;break;case"C":{const x=[g[0]+_,g[1]+S,g[2]+_,g[3]+S,g[4]+_,g[5]+S];h(et(n,i,x)),I=[x[2],x[3]],n=x[4],i=x[5];break}case"S":{const[x,C]=o?[2*n-o[0],2*i-o[1]]:[n,i],A=[x,C,g[0]+_,g[1]+S,g[2]+_,g[3]+S];h(et(n,i,A)),I=[A[2],A[3]],n=A[4],i=A[5];break}case"Q":case"T":{let x=n,C=i;k==="Q"?(x=g[0]+_,C=g[1]+S):c&&(x=2*n-c[0],C=2*i-c[1]);const A=k==="Q"?g[2]+_:g[0]+_,M=k==="Q"?g[3]+S:g[1]+S;h(et(n,i,[n+2/3*(x-n),i+2/3*(C-i),A+2/3*(x-A),M+2/3*(C-M),A,M])),W=[x,C],n=A,i=M;break}case"A":{const x=g[5]+_,C=g[6]+S;let A=n,M=i;for(const v of Oe(n,i,g[0],g[1],g[2],g[3],g[4],x,C))h(et(A,M,v)),A=v[4],M=v[5];n=x,i=C;break}}o=I,c=W}}const f=s.reduce((p,m)=>p+m.length,0),d=[];for(let p=0;p<s.length;){const m=s[p].subpath;let k=p,y=0;for(;k<s.length&&s[k].subpath===m;)y+=s[k++].length;const T=s[p],w=s[k-1],g=u.has(m)||Math.abs(w.endX-T.startX)<1e-9&&Math.abs(w.endY-T.startY)<1e-9;d.push({start:p,end:k,length:y,closed:g}),p=k}const b={segments:s,totalLength:f,subpaths:d};return H.size>=Ce&&H.delete(H.keys().next().value),H.set(e,b),b}function Le(e,t){const s=e.lengths;if(t<=0)return 0;if(t>=e.length)return 1;let n=0,i=s.length-1;for(;n<i-1;){const o=n+i>>1;s[o]<t?n=o:i=o}const r=s[i]-s[n],a=r>0?(t-s[n])/r:0;return(n+a)/(s.length-1)}function Ne(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[s,n,i,r,a,o]=e.points,c=Le(e,t);let l=Lt(e.startX,s,i,a,c),u=Lt(e.startY,n,r,o,c);if(Math.hypot(l,u)<1e-9){const h=c<.5?Math.min(1,c+.001):Math.max(0,c-.001),f=F(e.startX,s,i,a,h),d=F(e.startY,n,r,o,h),b=F(e.startX,s,i,a,c),p=F(e.startY,n,r,o,c);l=c<.5?f-b:b-f,u=c<.5?d-p:p-d}return{x:F(e.startX,s,i,a,c),y:F(e.startY,n,r,o,c),angle:Math.atan2(u,l)*180/Math.PI}}function Nt(e,t,s=0,n=e.length){if(n<=s)return{x:0,y:0,angle:0};let i=0;for(let r=s;r<n;r++){const a=e[r];if(i+a.length>=t||r===n-1)return Ne(a,t-i);i+=a.length}return{x:0,y:0,angle:0}}function Fe(e,t){const{segments:s,totalLength:n}=st(e);return Nt(s,Math.max(0,Math.min(1,t))*n)}const Xe=24,Ye=320,qe=2.5,G=72,Ve=.2,We=128,nt=new Map;let mt=0,X;const Ft=e=>Math.round(e*100)/100;function Xt(e,t){const{segments:s,subpaths:n,totalLength:i}=st(e);if(s.length===0)return[];if(t){const r=n.every(a=>a.closed);return[{segments:s,start:0,end:s.length,length:i,closed:r}]}return n.filter(r=>r.length>0).map(r=>({segments:s,start:r.start,end:r.end,length:r.length,closed:r.closed}))}function gt(e,t){const s=e.closed?(t%1+1)%1:Math.max(0,Math.min(1,t)),n=Nt(e.segments,s*e.length,e.start,e.end);return[n.x,n.y]}function Yt(e){const t=[];let s=0;for(let n=e.start;n<e.end;n++)s+=e.segments[n].length,e.length>0&&t.push(s/e.length);return t}function qt(e,t){const s=[];for(let n=0;n<t;n++)s.push(gt(e,e.closed?n/t:n/(t-1)));return s}function Vt(e){let t=0,s=0;for(const[n,i]of e)t+=n,s+=i;return t/=e.length,s/=e.length,e.map(([n,i])=>[n-t,i-s])}function Be(e,t,s){const n=e.closed&&t.closed;if(s!==void 0)return{offset:n?Math.abs(s)%G/G:0,reversed:s<0};const i=Vt(qt(e,G)),r=Vt(qt(t,G)),a=G;let o={offset:0,reversed:!1},c=1/0;for(const l of[!1,!0]){const u=n?a:1;for(let h=0;h<u;h++){let f=0;for(let d=0;d<a&&f<c;d++){const b=n?l?(h-d+a)%a:(d+h)%a:l?a-1-d:d,p=i[d][0]-r[b][0],m=i[d][1]-r[b][1];f+=p*p+m*m}f<c&&(c=f,o={offset:n?h/a:0,reversed:l})}}return o}function Ue(e,t,s){return s?((t.reversed?t.offset-e:e+t.offset)%1+1)%1:t.reversed?1-e:e}function je(e,t,s){return s?((t.reversed?t.offset-e:e-t.offset)%1+1)%1:t.reversed?1-e:e}function He(e,t,s){const n=e.closed&&t.closed,i=Be(e,t,s.shapeIndex),r=Math.max(Xe,Math.min(Ye,Math.ceil(Math.max(e.length,t.length)/qe))),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 Yt(e))o(h);for(const h of Yt(t))o(je(h,i,n));let c=[...a].sort((h,f)=>h-f);n&&(c=c.filter(h=>h<1));const l=[],u=[];for(const h of c)l.push(...gt(e,h)),u.push(...gt(t,Ue(h,i,n)));return ze({from:l,to:u,closed:n})}function ze(e){const t=e.from.length/2;if(t<=3)return e;const s=new Uint8Array(t);s[0]=1,s[t-1]=1;const n=[[0,t-1]];for(;n.length>0;){const[a,o]=n.pop();let c=-1,l=Ve;for(let u=a+1;u<o;u++){const h=Math.max(Wt(e.from,a,o,u),Wt(e.to,a,o,u));h>l&&(l=h,c=u)}c!==-1&&(s[c]=1,n.push([a,c],[c,o]))}const i=[],r=[];for(let a=0;a<t;a++)s[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 Wt(e,t,s,n){const i=e[t*2],r=e[t*2+1],a=e[s*2]-i,o=e[s*2+1]-r,c=e[n*2]-i,l=e[n*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 Ge(e,t,s){const n=s.shapeIndex;if(X&&X.from===e&&X.to===t&&X.shapeIndex===n)return X.plan;const r=nt.get(String(n??"auto"))?.get(e)?.get(t);if(r)return X={from:e,to:t,shapeIndex:n,plan:r},r;const a=st(e).subpaths.filter(d=>d.length>0).length===st(t).subpaths.filter(d=>d.length>0).length,o=Xt(e,!a),c=Xt(t,!a),l={pairs:o.map((d,b)=>He(d,c[b],s))};mt>=We&&(nt.clear(),mt=0);const u=String(n??"auto"),h=nt.get(u)??new Map;nt.set(u,h);const f=h.get(e)??new Map;return h.set(e,f),f.set(t,l),mt++,X={from:e,to:t,shapeIndex:n,plan:l},l}function Qe(e,t,s,n={}){if(!e)return t;if(!t)return e;const i=Math.max(0,Math.min(1,s));if(i===0)return e;if(i===1)return t;const r=Ge(e,t,n);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=Ft(o.from[c]+(o.to[c]-o.from[c])*i),u=Ft(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 Ze(e){return/^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e)}const N=(e,t,s)=>e+(t-e)*s,Bt=512,yt=new Map,bt=new Map;function Ut(e){const t=yt.get(e);if(t)return t;const s=e.replace("#",""),n=[parseInt(s.slice(0,2),16),parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16)];return yt.size<Bt&&yt.set(e,n),n}const jt=e=>e.charCodeAt(0)===35,Ht=e=>e.startsWith("rgb"),zt=e=>e.startsWith("rgba"),Ke=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/,kt=e=>Math.round(e).toString(16).padStart(2,"0");function Je(e,t,s){return`#${kt(e)}${kt(t)}${kt(s)}`}function Gt(e){const t=bt.get(e);if(t)return t;const s=e.match(Ke);if(!s)throw new Error(`Invalid rgb color: ${e}`);const n=parseInt(s[1],10),i=parseInt(s[2],10),r=parseInt(s[3],10),a=s[4]!==void 0?[n,i,r,parseFloat(s[4])]:[n,i,r];return bt.size<Bt&&bt.set(e,a),a}const ts=(e,t,s)=>{if(jt(e)&&jt(t)){const[n,i,r]=Ut(e),[a,o,c]=Ut(t),l=N(n,a,s),u=N(i,o,s),h=N(r,c,s);return Je(l,u,h)}if((Ht(e)||zt(e))&&(Ht(t)||zt(t))){const n=Gt(e),i=Gt(t),r=Math.round(N(n[0],i[0],s)),a=Math.round(N(n[1],i[1],s)),o=Math.round(N(n[2],i[2],s));if(n.length===4||i.length===4){const c=n[3]??1,l=i[3]??1,u=N(c,l,s);return`rgba(${r}, ${a}, ${o}, ${u})`}return`rgb(${r}, ${a}, ${o})`}return s<1?e:t},es=(e,t,s)=>{const n=Math.min(e.length,t.length),i=[];for(let r=0;r<n;r++)i.push(N(e[r],t[r],s));return i},Qt=(e,t,s)=>s<1?e:t,ss=(e,t,s)=>Qe(e,t,s);function ns(e){return typeof e=="number"?N:Array.isArray(e)?es:typeof e=="string"?e.startsWith("#")||e.startsWith("rgb")?ts:Ze(e)?ss:Qt:Qt}function is(e){const t=[...e.keyframes].sort((s,n)=>s.time-n.time);return{...e,keyframes:t}}function Y(e){return e.targets&&e.targets.length>0?e.targets:[e.target]}function V(e,t,s,n){const i=s??0;return!n||t<=1?i:i+vt(e,t,n)}class Mt{track;targets;constructor(t){this.track=t,this.targets=Y(t)}getValueAtTime(t){return this.valueForOffset(t-V(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const s=this.targets.length,n=[];for(let i=0;i<s;i++){const r=V(i,s,this.track.delay,this.track.stagger),a=this.valueForOffset(t-r);a!==void 0&&n.push({target:this.targets[i],value:a,start:r+this.track.keyframes[0].time})}return n}getDuration(){const{keyframes:t}=this.track;if(t.length===0)return 0;const s=t[t.length-1].time,n=this.track.stagger?ut(this.targets.length,this.track.stagger):0;return s+(this.track.delay??0)+n+(this.track.endDelay??0)}getTrack(){return this.track}valueForOffset(t){const{keyframes:s}=this.track;if(s.length===0)return;if(s.length===1||t<=s[0].time)return s[0].value;if(t>=s[s.length-1].time)return s[s.length-1].value;const{from:n,to:i}=this.findSurroundingKeyframes(t);if(!n||!i)return;if(n.time===t)return n.value;const r=i.time-n.time,a=(t-n.time)/r,c=Ie(i.easing)(a);return ns(n.value)(n.value,i.value,c)}findSurroundingKeyframes(t){const{keyframes:s}=this.track;for(let n=0;n<s.length-1;n++)if(t>=s[n].time&&t<=s[n+1].time)return{from:s[n],to:s[n+1]};return{from:null,to:null}}}class rs{track;targets;sampler;constructor(t){this.track=t,this.targets=Y(t),this.sampler=new de(t.spring)}getValueAtTime(t){return this.sampler.valueAt(t-V(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const s=this.targets.length,n=[];for(let i=0;i<s;i++){const r=V(i,s,this.track.delay,this.track.stagger);n.push({target:this.targets[i],value:this.sampler.valueAt(t-r),start:r})}return n}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 as{track;targets;duration;constructor(t){this.track=t,this.targets=Y(t),this.duration=Ct(t.inertia)}getValueAtTime(t){return Rt(this.track.inertia,t-V(0,this.targets.length,this.track.delay,this.track.stagger))}getTargetValues(t){const s=this.targets.length,n=[];for(let i=0;i<s;i++){const r=V(i,s,this.track.delay,this.track.stagger);n.push({target:this.targets[i],value:Rt(this.track.inertia,t-r),start:r})}return n}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 os(e,t){const s={...Fe(e.pathData,t)};if(e.matrix){const[n,i,r,a,o,c]=e.matrix,{x:l,y:u}=s;s.x=n*l+r*u+o,s.y=i*l+a*u+c;const h=s.angle*Math.PI/180,f=Math.cos(h),d=Math.sin(h);s.angle=Math.atan2(i*f+a*d,n*f+r*d)*180/Math.PI}return e.autoRotate&&e.rotateOffset&&(s.angle+=e.rotateOffset),s}const Tt={upperCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",lowerCase:"abcdefghijklmnopqrstuvwxyz",upperAndLowerCase:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",numbers:"0123456789"},cs=20;function ls(e){const t=Tt[e??"upperCase"]??e??Tt.upperCase,s=Array.from(t);return s.length>0?s:Array.from(Tt.upperCase)}function hs(e,t,s){let n=(e|0)^Math.imul(t+1,2654435761)^Math.imul(s+1,2246822507);return n=Math.imul(n^n>>>16,2146121005),n=Math.imul(n^n>>>15,2221713035),(n^n>>>16)>>>0}function us(e,t,s=0){const n=e.from??"",i=e.to,r=Math.max(0,Math.min(1,t));if(r<=0)return n;if(r>=1)return i;const a=Array.from(n),o=Array.from(i),c=e.rightToLeft??!1;if(e.mode==="type"){const y=Math.round(r*Math.max(a.length,o.length));return c?a.slice(0,Math.max(0,a.length-y)).join("")+o.slice(Math.max(0,o.length-y)).join(""):o.slice(0,y).join("")+a.slice(y).join("")}const l=Math.max(0,Math.min(.999,e.revealDelay??0)),u=Math.max(0,(r-l)/(1-l)),h=Math.floor(u*o.length),f=e.tweenLength===!1?o.length:Math.round(a.length+(o.length-a.length)*r),d=ls(e.chars),b=e.refreshRate??cs,p=b>0?Math.floor(s*b/1e3):0,m=e.seed??1;let k="";for(let y=0;y<f;y++){const T=c?y>=f-h:y<h,w=c?o[o.length-(f-y)]:o[y];T&&w!==void 0||w===" "||w===`
|
|
2
2
|
`?k+=w:k+=d[hs(m,y,p)%d.length]}return k}class fs{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 s of t.tracks)this.addTrack(s)}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 s={...this._config};delete s.duration,this._config=s}}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 s=this.duration>0?this.duration:1/0;this._currentTime=Math.max(0,Math.min(t,s)),this._repeatDelayRemaining=0,this._wrapAfterDelay=!1}reverse(){this._direction=this._direction==="forward"?"reverse":"forward"}tick(t){if(this._playbackState!=="playing")return;const s=this.duration;if(s<=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=s-this._currentTime;if(i>=c){if(i-=c,this._currentTime=s,!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 s=new Map;if(this._hasSharedWrites())this._resolveShared(t,s);else for(const[n,i]of this._trackPlayers){const r=i.getTrack().property;for(const{target:a,value:o,start:c}of i.getTargetValues(t))this._write(s,n,a,r,o,t-c)}return{values:s,currentTime:this._currentTime,playbackState:this._playbackState,direction:this._direction,loopIteration:this._loopIteration}}_resolveShared(t,s){const n=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,f=n.get(u);(!f||(h!==f.started?h:h?l>=f.start:l<=f.start))&&n.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 n.values())this._write(s,i,r,a,o,t-c)}_write(t,s,n,i,r,a){if(r===void 0)return;let o=t.get(n);o||(o=new Map,t.set(n,o));const c=this._textTracks.get(s);if(c&&typeof r=="number"){o.set("text",us(c.textConfig,r,Math.max(0,a)));return}const l=this._motionPathTracks.get(s);if(l&&typeof r=="number"){const u=os(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 s of this._tracks)for(const n of Y(s)){const i=`${n}\0${s.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 as(t));return}if(ht(t)){this._trackPlayers.set(t.id,new rs(t)),this._springTracks.set(t.id,t);return}if(_t(t))this._trackPlayers.set(t.id,new Mt(t)),this._textTracks.set(t.id,t);else if(he(t)){const s={id:t.id,target:t.target,property:t.property,keyframes:t.keyframes,delay:t.delay,endDelay:t.endDelay,targets:t.targets,stagger:t.stagger};this._trackPlayers.set(t.id,new Mt(s)),this._motionPathTracks.set(t.id,t)}else this._trackPlayers.set(t.id,new Mt(t))}replaceTrack(t,s){const n=this._tracks.findIndex(r=>r.id===t);if(n<0)return;const i=this._tracks.slice(n+1);this.removeTrack(t);for(const r of i)this.removeTrack(r.id);this.addTrack(s);for(const r of i)this.addTrack(r)}removeTrack(t){this._tracks=this._tracks.filter(s=>s.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(s=>this._matches(s,t))}removeTracks(t={}){const s=this.getTracks(t).map(n=>n.id);for(const n of s)this.removeTrack(n);return s}getTrackSpan(t){const s=this._trackPlayers.get(t);if(!s)return;const n=s.getTrack(),i=n.delay??0;if(ht(n)||lt(n))return{from:i,to:s.getDuration()};const r=n.keyframes;if(!(!r||r.length===0))return{from:r[0].time+i,to:s.getDuration()}}findConflicts(){const t=[];for(let s=0;s<this._tracks.length;s++){const n=this._tracks[s],i=this.getTrackSpan(n.id);if(i)for(let r=0;r<s;r++){const a=this._tracks[r];if(a.property!==n.property)continue;const o=Y(a).filter(h=>Y(n).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:n.property,losingTrackId:u?a.id:n.id,winningTrackId:u?n.id:a.id})}}return t}_matches(t,s){if(s.id!==void 0&&t.id!==s.id||s.property!==void 0&&t.property!==s.property||s.target!==void 0&&!Y(t).includes(s.target))return!1;if(s.timeRange){const n=this.getTrackSpan(t.id);if(!n||n.to<s.timeRange.from||n.from>s.timeRange.to)return!1}return!0}toDefinition(){return{formatVersion:U,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,s)=>t.time-s.time)}setMarkers(t){const s=t&&t.length>0?[...t].sort((i,r)=>i.time-r.time).map(i=>({...i})):void 0,n={...this._config};s?n.markers=s:delete n.markers,this._config=n}get captions(){return this._captions}setCaptions(t){const s={};for(const[n,i]of Object.entries(t??{}))s[n]={...i};this._captions=Object.keys(s).length>0?s:void 0}_armRepeatDelay(){this._repeatDelayRemaining=this._config.repeatDelay??0}_calculateDuration(){let t=0;for(const[,s]of this._trackPlayers)t=Math.max(t,s.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 ds=100;function ps(e,t,s,n){const i=[],r=[],{duration:a,alternate:o}=n,c=(d,b,p,m)=>{r.push([d,b]);const k=[];e.forEach((y,T)=>{(p==="forward"?(m?y>=d:y>d)&&y<=b:(m?y<=d:y<d)&&y>=b)&&k.push(T)}),k.sort((y,T)=>(p==="forward"?e[y]-e[T]:e[T]-e[y])||y-T);for(const y of k)i.push({kind:"event",index:y,direction:p})};let l=t.time,u=t.direction,h=t.fresh===!0;const f=Math.min(ds,Math.max(0,s.iteration-t.iteration));for(let d=0;d<f;d++){const b=u==="forward"?a:0;c(l,b,u,h),i.push({kind:"repeat"}),o?(u=u==="forward"?"reverse":"forward",l=b,h=!1):(l=u==="forward"?0:a,h=!0)}return f>0&&n.holding&&!o?{crossings:i,passes:r}:(c(l,s.time,u,h),{crossings:i,passes:r})}function ms(e){return{...e,...Array.isArray(e.end)&&{end:[...e.end]}}}function Q(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 gs(e){if(lt(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"inertia",inertia:ms(t.inertia),...Q(t)}}if(ht(e)){const t=e;return{id:t.id,target:t.target,property:t.property,kind:"spring",spring:{...t.spring},...Q(t)}}if(_t(e)){const t=e;return{id:t.id,target:t.target,property:"text",textConfig:{...t.textConfig},keyframes:[...t.keyframes].sort((s,n)=>s.time-n.time),...Q(t)}}if(e.property==="motionPath"&&"motionPathConfig"in e){const t=e,s=[...t.keyframes].sort((n,i)=>n.time-i.time);return{id:t.id,target:t.target,property:"motionPath",motionPathConfig:{...t.motionPathConfig},keyframes:s,...Q(t)}}return is({id:e.id,target:e.target,property:e.property,keyframes:e.keyframes,...Q(e)})}function it(e){const t=e.formatVersion??1;if(t>U)throw new Error(`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${U}. Update tinyfly to play it.`);return new fs({id:e.id,name:e.name,config:e.config,tracks:e.tracks.map(gs),captions:e.captions})}const ys=new Set(["blur","brightness","glow","glowColor","shadowX","shadowY","shadowBlur","shadowColor"]),bs="#ffffff",ks="rgba(0, 0, 0, 0.5)";function Ms(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??bs})`),e.shadowX!==void 0||e.shadowY!==void 0||e.shadowBlur!==void 0){const s=e.shadowX??0,n=e.shadowY??0,i=Math.max(0,e.shadowBlur??0);t.push(`drop-shadow(${s}px ${n}px ${i}px ${e.shadowColor??ks})`)}return t.length>0?t.join(" "):null}function Ts(e,t){const s=e.childNodes.length===1?e.firstChild:null;if(s&&s.nodeType===3){const n=s;n.data!==t&&(n.data=t);return}e.textContent!==t&&(e.textContent=t)}function Ss(e){if(!("ownerSVGElement"in e))return;const t=e.style;!t||t.transformBox||(t.transformBox="fill-box",t.transformOrigin||(t.transformOrigin="50% 50%"))}const Zt=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"]),ws=new Set(["x","y","z","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skewX","skewY","motionPathX","motionPathY","motionPathRotate"]),_s=new Set(["originX","originY"]),xs=new Set(["clipTop","clipRight","clipBottom","clipLeft"]),vs={fill:"backgroundColor",stroke:"borderColor",strokeWidth:"borderWidth",color:"color",backgroundColor:"backgroundColor",borderColor:"borderColor"},Kt={fill:"fill",stroke:"stroke",strokeWidth:"strokeWidth",strokeDasharray:"strokeDasharray",strokeDashoffset:"strokeDashoffset",fillOpacity:"fillOpacity",strokeOpacity:"strokeOpacity"},As="http://www.w3.org/2000/svg";class St{targets=new Map;registerTarget(t,s){this.targets.set(t,s)}unregisterTarget(t){this.targets.delete(t)}getTarget(t){return this.targets.get(t)}clearTargets(){this.targets.clear()}applyState(t){for(const[s,n]of t.values){const i=this.targets.get(s);i&&this.applyProperties(i,n)}}applyProperties(t,s){const n=[];let i=null,r=null,a=null;const o=s.has("motionPathX"),c=s.has("motionPathY"),l=s.has("motionPathRotate");for(const[f,d]of s)if(!(f==="x"&&o)&&!(f==="y"&&c)&&!((f==="rotate"||f==="rotateZ")&&l)){if(ws.has(f)){const b=this.buildTransformPart(f,d);b&&n.push(b)}else if(_s.has(f))typeof d=="number"&&((i??={})[f]=d);else if(xs.has(f))typeof d=="number"&&((r??={})[f]=d);else if(ys.has(f))(a??={})[f]=d;else if(f!=="perspective"){if(f!=="shine")if(f==="text"&&typeof d=="string")Ts(t,d);else if(f==="d"&&typeof d=="string"){const b=t;(b.tagName?.toLowerCase()==="path"?b:b.querySelector?.("path"))?.setAttribute?.("d",d)}else this.applyStyleProperty(t,f,d)}}const u=s.get("shine");typeof u=="number"&&this.applyShine(t,u);const h=s.get("perspective");if(typeof h=="number"&&n.unshift(`perspective(${h}px)`),n.length>0&&(t.style.transform=n.join(" "),Ss(t)),i){const f=i.originX??50,d=i.originY??50;t.style.transformOrigin=`${f}% ${d}%`}if(r){const f=r.clipTop??0,d=r.clipRight??0,b=r.clipBottom??0,p=r.clipLeft??0;t.style.clipPath=`inset(${f}% ${d}% ${b}% ${p}%)`}if(a){const f=Ms(a);f&&(t.style.filter=f)}}buildTransformPart(t,s){if(typeof s!="number")return null;switch(t){case"x":case"motionPathX":return`translateX(${s}px)`;case"y":case"motionPathY":return`translateY(${s}px)`;case"z":return`translateZ(${s}px)`;case"rotate":case"rotateZ":case"motionPathRotate":return`rotate(${s}deg)`;case"rotateX":return`rotateX(${s}deg)`;case"rotateY":return`rotateY(${s}deg)`;case"scale":return`scale(${s})`;case"scaleX":return`scaleX(${s})`;case"scaleY":return`scaleY(${s})`;case"scaleZ":return`scaleZ(${s})`;case"skewX":return`skewX(${s}deg)`;case"skewY":return`skewY(${s}deg)`;default:return null}}applyShine(t,s){t.dataset.shineBase||(t.dataset.shineBase=t.style.color||"currentColor");const n=t.dataset.shineBase,i=-20+s*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(${n}, ${n})`,r.backgroundSize="250% 100%, 100% 100%",r.backgroundPosition=`${i}% 0, 0 0`,r.backgroundRepeat="no-repeat",r.webkitBackgroundClip="text",r.backgroundClip="text"}applyStyleProperty(t,s,n){let i;if(t.namespaceURI===As&&s in Kt){const o=Array.isArray(n)?n.join(", "):String(n);t.style[Kt[s]]=o;return}else s==="fill"&&t.dataset?.elementType==="text"?i="color":i=vs[s]??s;let a;typeof n=="number"?Zt.has(s)||Zt.has(i)?a=`${n}px`:a=String(n):Array.isArray(n)?a=n.join(", "):a=n,t.style[i]=a}}class Jt{media;offset;driftTolerance;constructor(t,s={}){this.media=t,this.offset=s.offset??0,this.driftTolerance=Math.max(0,s.driftTolerance??.15)}targetTime(t){return Math.max(0,t/1e3+this.offset)}update(t,s){const n=this.targetTime(t);s?(this.media.paused&&this.safePlay(),Math.abs(this.media.currentTime-n)>this.driftTolerance&&(this.media.currentTime=n)):(this.media.paused||this.media.pause(),this.media.currentTime!==n&&(this.media.currentTime=n))}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 Ps(e,t,s,n,i){const r=s-i;if(r<0){t.paused||t.pause(),t.currentTime=0;return}e.update(r,n)}class rt{container;timeline=null;adapter;animationFrameId;lastTime;options;targets={};isDestroyed=!1;mediaSync;mediaTargets=[];symbolInstances=[];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,s={}){if(typeof t=="string"){const n=document.querySelector(t);if(!n)throw new Error(`Container not found: ${t}`);this.container=n}else this.container=t;this.options=s,this.adapter=new St}async load(t){let s;if(typeof t=="string"){const n=await fetch(t);if(!n.ok)throw new Error(`Failed to load animation: ${n.statusText}`);s=await n.json()}else s=t;this.options.speed!==void 0&&(s.config={...s.config,speed:this.options.speed}),this.options.loop!==void 0&&(s.config={...s.config,loop:this.options.loop}),this.options.alternate!==void 0&&(s.config={...s.config,alternate:this.options.alternate}),this.timeline=it(s),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(),this.showInitialFrame(),this.watchReducedMotion(),this.watchVisibility(),this.options.autoplay&&!this.reducedMotion&&(this.options.playWhenVisible&&!this.onScreen?this.autoplayWhenSeen=!0:this.play())}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 s;for(const n of this.markers)if(n.time<=t+.5)s=n;else break;return s}caption(t,s){const n=t?this.markers.find(a=>a.id===t):this.currentMarker;if(!n)return;const i=s??this.language(),r=a=>a?.[i]?.[n.id]??a?.[i.split("-")[0]]?.[n.id];return r(this.options.captions)??r(this.timeline?.captions)??n.label}next(){if(!this.timeline)return;const t=this.currentTime,s=this.markers.find(n=>n.time>t+.5);if(this.reducedMotion){this.seek(s?s.time:this.duration);return}t>=this.duration-.5||(this.stepping=s!==void 0,this.startPlaying())}prev(){if(!this.timeline)return;const t=this.currentTime,s=[...this.markers].reverse().find(n=>n.time<t-.5);this.pause(),this.seek(s?s.time:0)}goToMarker(t){const s=this.markers.find(n=>n.id===t);s&&(this.pause(),this.seek(s.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 s=t==="end"?this.timeline.duration:t==="start"?0:t;this.timeline.seek(Math.max(0,Math.min(this.timeline.duration,s))),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.listeners.clear(),this.visibilityObserver=new IntersectionObserver(s=>{for(const n of s)this.onScreen=n.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,s=t?.id;s!==this.lastMarkerId&&(this.lastMarkerId=s,this.options.onMarker(t))}scanMedia(){this.mediaTargets=[],this.container.querySelectorAll("[data-tinyfly-media]").forEach(s=>{const n=s,i=Number(n.getAttribute("data-tinyfly-start")??"0")||0,r=n.getAttribute("data-volume");r!==null&&(n.volume=Math.max(0,Math.min(1,Number(r)||0))),this.mediaTargets.push({el:n,startTime:i,sync:new Jt(n)})})}syncAllMedia(t,s){for(const n of this.mediaTargets)Ps(n.sync,n.el,t,s,n.startTime)}loadFromString(t){const s=JSON.parse(t);this.load(s)}registerTarget(t,s){if(typeof s=="string"){const n=this.container.querySelector(s);n&&(this.targets[t]=n,this.adapter.registerTarget(t,n))}else this.targets[t]=s,this.adapter.registerTarget(t,s)}autoRegisterTargets(){this.container.querySelectorAll("[data-tinyfly]").forEach(s=>{const n=s.closest("[data-tinyfly-symbol]");if(n&&n!==s)return;const i=s.getAttribute("data-tinyfly");i&&this.registerTarget(i,s)}),this.timeline&&new Set(this.timeline.tracks.map(n=>n.target)).forEach(n=>{if(!this.targets[n]){const i=this.container.querySelector(`[data-tinyfly="${n}"]`)||this.container.querySelector(`.${n}`)||this.container.querySelector(`#${n}`);i&&this.registerTarget(n,i)}})}setupSymbolInstances(){this.symbolInstances=[];const t=this.options.symbols;if(!t||t.length===0)return;const s=new Map(t.map(n=>[n.id,n]));this.container.querySelectorAll("[data-tinyfly-symbol]").forEach(n=>{const i=n.getAttribute("data-tinyfly-symbol");if(!i)return;const r=s.get(i);if(!r||!r.timeline.tracks?.length)return;const a=new St;n.querySelectorAll("[data-tinyfly]").forEach(o=>{const c=o.getAttribute("data-tinyfly");c&&a.registerTarget(c,o)}),this.symbolInstances.push({adapter:a,timeline:it(r.timeline)})})}attachMedia(t,s){this.mediaSync=new Jt(t,s),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.timeline=null}startAnimationLoop(){if(this.animationFrameId!==void 0)return;this.lastTime=performance.now();const t=s=>{if(this.isDestroyed||!this.timeline)return;const n=s-(this.lastTime??s);this.lastTime=s;const i=this.playhead;this.timeline.tick(n),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 s=this.timeline,n={time:s.currentTime,iteration:s.loopIteration,direction:s.direction};this.playhead=n;const i=this.markers;if(i.length===0)return;const{crossings:r}=ps(i.map(a=>a.time),t,n,{duration:s.duration,alternate:s.config.alternate===!0,holding:s.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,s.pause(),s.seek(o.time),this.playhead={time:o.time,iteration:s.loopIteration,direction:s.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 s of this.symbolInstances){const n=s.timeline.duration;s.adapter.applyState(s.timeline.getStateAtTime(n>0?t%n:t))}}}async function Is(e,t,s={}){const n=new rt(e,{...s,autoplay:!0});return await n.load(t),n}function Cs(e,t={}){return new rt(e,t)}const te={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}"},ee="tinyfly-controls-style",Rs=`
|
|
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; }
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
/* The hidden attribute only hides through the browser's default stylesheet; any rule
|
|
19
19
|
above that sets display would override it, so enforce it for everything here. */
|
|
20
20
|
.tf-ctl [hidden] { display: none !important; }
|
|
21
|
-
`;function Es(e){if(e.getElementById(ee))return;const t=e.createElement("style");t.id=ee,t.textContent=Rs,e.head.appendChild(t)}function se(e,t,s={}){const n=t.ownerDocument;Es(n);const i={...te,...s.labels},r=s.speeds??[.5,1,2],a=()=>e.markers.length>0,o=()=>e.markers.some(M=>M.label!==void 0||e.caption(M.id)!==void 0),c=n.createElement("div");c.className="tf-ctl";const l=n.createElement("div");l.className="tf-ctl-bar",l.setAttribute("role","group");const u=(M,v,L,E="")=>{const D=n.createElement("button");return D.type="button",D.className=`tf-ctl-btn ${E}`.trim(),D.setAttribute("aria-label",M),D.title=M,D.textContent=v,D.addEventListener("click",L),D},h=u(i.restart,"⟲",()=>{e.pause(),e.seek(0)}),f=u(i.prev,"◀",()=>e.prev()),d=u(i.play,"▶",()=>e.isPlaying?e.pause():p(),"tf-ctl-primary"),b=u(i.next,"▶|",()=>e.next()),p=()=>{e.currentTime>=e.duration-.5&&e.seek(0),e.play()},m=n.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 k=n.createElement("span");k.className="tf-ctl-step";const y=n.createElement("select");y.className="tf-ctl-speed",y.setAttribute("aria-label",i.speed);for(const M of r){const v=n.createElement("option");v.value=String(M),v.textContent=`${M}×`,M===1&&(v.selected=!0),y.appendChild(v)}y.addEventListener("change",()=>e.setSpeed(Number(y.value))),l.append(h,f,d,b,m,k),r.length>0&&l.append(y),c.append(l);const T=n.createElement("p");T.className="tf-ctl-caption",T.setAttribute("aria-live","polite"),s.captions!==!1&&c.append(T);const w=n.createElement("div");w.className="tf-ctl-question",w.hidden=!0;const g=n.createElement("span"),_=u(i.reveal,i.reveal,()=>e.play(),"tf-ctl-primary");w.append(g,_),c.append(w);const S=s.mount;S?S.appendChild(c):t.insertAdjacentElement("afterend",c);const I=()=>{const M=e.isPlaying;d.textContent=M?"❚❚":"▶",d.setAttribute("aria-label",M?i.pause:i.play),d.title=M?i.pause:i.play;const v=e.duration;n.activeElement!==m&&(m.value=String(v>0?Math.round(e.currentTime/v*1e3):0));const L=e.markers;if(f.hidden=b.hidden=k.hidden=L.length===0,L.length>0){const E=e.currentMarker,D=E?L.indexOf(E)+1:0;k.textContent=i.stepFormat.replace("{index}",String(D)).replace("{total}",String(L.length)),k.setAttribute("aria-label",`${i.step} ${D} ${i.of} ${L.length}`),f.disabled=e.currentTime<=.5,b.disabled=e.currentTime>=v-.5;const Z=e.caption()??"";T.textContent!==Z&&(T.textContent=Z),T.hidden=!o();const K=!M&&E?.question!==void 0&&Math.abs(e.currentTime-E.time)<1;w.hidden=!K,K&&g.textContent!==E.question&&(g.textContent=E.question)}else w.hidden=!0,T.hidden=!0},W=e.subscribe(I);I();const x=s.keyboardScope??t;!x.hasAttribute("tabindex")&&x.tabIndex<0&&(x.tabIndex=0);const C=new WeakSet,A=M=>{if(C.has(M)||(C.add(M),M.defaultPrevented||M.altKey||M.ctrlKey||M.metaKey))return;const v=M.target;if(!(v.tagName==="INPUT"||v.tagName==="SELECT")&&!(M.key===" "&&v.tagName==="BUTTON"))switch(M.key){case" ":M.preventDefault(),e.isPlaying?e.pause():p();break;case"ArrowRight":if(!a())return;M.preventDefault(),e.next();break;case"ArrowLeft":if(!a())return;M.preventDefault(),e.prev();break;case"Home":M.preventDefault(),e.pause(),e.seek(0);break}};return x.addEventListener("keydown",A),c.addEventListener("keydown",A),{element:c,destroy(){W(),x.removeEventListener("keydown",A),c.removeEventListener("keydown",A),c.remove()}}}const at=new WeakMap;let Ds=0;function ot(e,t,s){if(e)try{return JSON.parse(e)}catch(n){console.warn(`tinyfly: invalid ${t} JSON on`,s,n);return}}async function ne(e,t={}){const s=at.get(e);if(s)return s;const n=e.querySelector("script[data-tinyfly-timeline]"),i=e.getAttribute("data-src");let r=n?ot(n.textContent,"timeline",e):void 0;const a=$s(e.getAttribute("data-markers"));if(!r&&i&&a){const h=await fetch(i);h.ok&&(r=await h.json())}if(r&&a&&!r.config.markers?.length&&(r.config={...r.config,markers:a.map((h,f)=>({id:`step-${f+1}`,time:h}))}),!r&&!i){console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)',e);return}const o=ot(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),c={playWhenVisible:!0,...t.player,...o&&{captions:o},...ot(e.getAttribute("data-options"),"data-options",e)};Ls(e);const l=new rt(e,c),u={element:e,player:l};if(at.set(e,u),e.setAttribute("data-tinyfly-mounted",""),await l.load(r??i),e.getAttribute("data-controls")!=="false"){const h=ot(e.getAttribute("data-labels"),"data-labels",e),f=e.querySelector("figcaption");u.controls=se(l,e,{...t.controls,labels:{...t.controls?.labels,...h},mount:void 0}),f?e.insertBefore(u.controls.element,f):e.appendChild(u.controls.element)}return u}function $s(e){if(!e)return;const t=e.split(/[\s,]+/).filter(Boolean).map(Number).filter(s=>Number.isFinite(s)&&s>=0).sort((s,n)=>s-n);return t.length>0?t:void 0}async function ie(e=document,t={}){const s=Array.from(e.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(s.map(i=>ne(i,t)))).filter(i=>i!==void 0)}function Os(e){const t=at.get(e);t&&(t.controls?.destroy(),t.player.destroy(),at.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function Ls(e){const t=e.querySelector("svg");if(!t||t.hasAttribute("role")||t.hasAttribute("aria-hidden"))return;const s=e.getAttribute("data-alt"),n=e.querySelector("figcaption");t.setAttribute("role","img"),s?t.setAttribute("aria-label",s):n&&(n.id||=`tinyfly-caption-${++Ds}`,t.setAttribute("aria-labelledby",n.id))}function re(e){const t=new Set;for(const s of e.matchAll(/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/g))t.add(s[2]??s[3]);return[...t]}function
|
|
21
|
+
`;function Es(e){if(e.getElementById(ee))return;const t=e.createElement("style");t.id=ee,t.textContent=Rs,e.head.appendChild(t)}function se(e,t,s={}){const n=t.ownerDocument;Es(n);const i={...te,...s.labels},r=s.speeds??[.5,1,2],a=()=>e.markers.length>0,o=()=>e.markers.some(M=>M.label!==void 0||e.caption(M.id)!==void 0),c=n.createElement("div");c.className="tf-ctl";const l=n.createElement("div");l.className="tf-ctl-bar",l.setAttribute("role","group");const u=(M,v,L,E="")=>{const D=n.createElement("button");return D.type="button",D.className=`tf-ctl-btn ${E}`.trim(),D.setAttribute("aria-label",M),D.title=M,D.textContent=v,D.addEventListener("click",L),D},h=u(i.restart,"⟲",()=>{e.pause(),e.seek(0)}),f=u(i.prev,"◀",()=>e.prev()),d=u(i.play,"▶",()=>e.isPlaying?e.pause():p(),"tf-ctl-primary"),b=u(i.next,"▶|",()=>e.next()),p=()=>{e.currentTime>=e.duration-.5&&e.seek(0),e.play()},m=n.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 k=n.createElement("span");k.className="tf-ctl-step";const y=n.createElement("select");y.className="tf-ctl-speed",y.setAttribute("aria-label",i.speed);for(const M of r){const v=n.createElement("option");v.value=String(M),v.textContent=`${M}×`,M===1&&(v.selected=!0),y.appendChild(v)}y.addEventListener("change",()=>e.setSpeed(Number(y.value))),l.append(h,f,d,b,m,k),r.length>0&&l.append(y),c.append(l);const T=n.createElement("p");T.className="tf-ctl-caption",T.setAttribute("aria-live","polite"),s.captions!==!1&&c.append(T);const w=n.createElement("div");w.className="tf-ctl-question",w.hidden=!0;const g=n.createElement("span"),_=u(i.reveal,i.reveal,()=>e.play(),"tf-ctl-primary");w.append(g,_),c.append(w);const S=s.mount;S?S.appendChild(c):t.insertAdjacentElement("afterend",c);const I=()=>{const M=e.isPlaying;d.textContent=M?"❚❚":"▶",d.setAttribute("aria-label",M?i.pause:i.play),d.title=M?i.pause:i.play;const v=e.duration;n.activeElement!==m&&(m.value=String(v>0?Math.round(e.currentTime/v*1e3):0));const L=e.markers;if(f.hidden=b.hidden=k.hidden=L.length===0,L.length>0){const E=e.currentMarker,D=E?L.indexOf(E)+1:0;k.textContent=i.stepFormat.replace("{index}",String(D)).replace("{total}",String(L.length)),k.setAttribute("aria-label",`${i.step} ${D} ${i.of} ${L.length}`),f.disabled=e.currentTime<=.5,b.disabled=e.currentTime>=v-.5;const Z=e.caption()??"";T.textContent!==Z&&(T.textContent=Z),T.hidden=!o();const K=!M&&E?.question!==void 0&&Math.abs(e.currentTime-E.time)<1;w.hidden=!K,K&&g.textContent!==E.question&&(g.textContent=E.question)}else w.hidden=!0,T.hidden=!0},W=e.subscribe(I);I();const x=s.keyboardScope??t;!x.hasAttribute("tabindex")&&x.tabIndex<0&&(x.tabIndex=0);const C=new WeakSet,A=M=>{if(C.has(M)||(C.add(M),M.defaultPrevented||M.altKey||M.ctrlKey||M.metaKey))return;const v=M.target;if(!(v.tagName==="INPUT"||v.tagName==="SELECT")&&!(M.key===" "&&v.tagName==="BUTTON"))switch(M.key){case" ":M.preventDefault(),e.isPlaying?e.pause():p();break;case"ArrowRight":if(!a())return;M.preventDefault(),e.next();break;case"ArrowLeft":if(!a())return;M.preventDefault(),e.prev();break;case"Home":M.preventDefault(),e.pause(),e.seek(0);break}};return x.addEventListener("keydown",A),c.addEventListener("keydown",A),{element:c,destroy(){W(),x.removeEventListener("keydown",A),c.removeEventListener("keydown",A),c.remove()}}}const at=new WeakMap;let Ds=0;function ot(e,t,s){if(e)try{return JSON.parse(e)}catch(n){console.warn(`tinyfly: invalid ${t} JSON on`,s,n);return}}async function ne(e,t={}){const s=at.get(e);if(s)return s;const n=e.querySelector("script[data-tinyfly-timeline]"),i=e.getAttribute("data-src");let r=n?ot(n.textContent,"timeline",e):void 0;const a=$s(e.getAttribute("data-markers"));if(!r&&i&&a){const h=await fetch(i);h.ok&&(r=await h.json())}if(r&&a&&!r.config.markers?.length&&(r.config={...r.config,markers:a.map((h,f)=>({id:`step-${f+1}`,time:h}))}),!r&&!i){console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)',e);return}const o=ot(e.querySelector("script[data-tinyfly-captions]")?.textContent,"captions",e),c={playWhenVisible:!0,...t.player,...o&&{captions:o},...ot(e.getAttribute("data-options"),"data-options",e)};Ls(e);const l=new rt(e,c),u={element:e,player:l};if(at.set(e,u),e.setAttribute("data-tinyfly-mounted",""),await l.load(r??i),e.getAttribute("data-controls")!=="false"){const h=ot(e.getAttribute("data-labels"),"data-labels",e),f=e.querySelector("figcaption");u.controls=se(l,e,{...t.controls,labels:{...t.controls?.labels,...h},mount:void 0}),f?e.insertBefore(u.controls.element,f):e.appendChild(u.controls.element)}return u}function $s(e){if(!e)return;const t=e.split(/[\s,]+/).filter(Boolean).map(Number).filter(s=>Number.isFinite(s)&&s>=0).sort((s,n)=>s-n);return t.length>0?t:void 0}async function ie(e=document,t={}){const s=Array.from(e.querySelectorAll("[data-tinyfly-embed]"));return(await Promise.all(s.map(i=>ne(i,t)))).filter(i=>i!==void 0)}function Os(e){const t=at.get(e);t&&(t.controls?.destroy(),t.player.destroy(),at.delete(e),e.removeAttribute("data-tinyfly-mounted"))}function Ls(e){const t=e.querySelector("svg");if(!t||t.hasAttribute("role")||t.hasAttribute("aria-hidden"))return;const s=e.getAttribute("data-alt"),n=e.querySelector("figcaption");t.setAttribute("role","img"),s?t.setAttribute("aria-label",s):n&&(n.id||=`tinyfly-caption-${++Ds}`,t.setAttribute("aria-labelledby",n.id))}function Ns(){if(!(typeof document<"u"?document.currentScript:null)?.hasAttribute("data-tinyfly-auto"))return;const t=()=>{ie()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}function re(e){const t=new Set;for(const s of e.matchAll(/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/g))t.add(s[2]??s[3]);return[...t]}function Fs(e,t={}){const s=[],n=l=>s.push({level:"error",message:l}),i=l=>s.push({level:"warning",message:l});if((e.formatVersion??1)>U)return n(`format version ${e.formatVersion} is newer than this tinyfly reads (${U})`),s;let r=0;try{r=it(e).duration}catch(l){return n(`the timeline does not load: ${l instanceof Error?l.message:String(l)}`),s}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&&n(`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)&&n(`marker id "${l.id}" is used more than once`),c.add(l.id),(l.time<0||l.time>r)&&n(`marker "${l.id}" at ${l.time}ms is outside the animation (0–${r}ms)`),u>0&&l.time<o[u-1].time&&n(`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)||n(`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(re(t.markup)),u=new Set;for(const h of e.tracks)for(const f of[h.target,...h.targets??[]])u.add(f),l.has(f)||n(`track "${h.id}" targets "${f}", but no element has data-tinyfly="${f}"`);for(const h of l)u.has(h)||i(`data-tinyfly="${h}" is never animated`)}return s}function Xs(e,t,s="end"){const n=it(t),i=t.config?.markers??[],r=s==="start"?0:s==="end"?n.duration:typeof s=="number"?s:i.find(f=>f.id===s)?.time??n.duration,a=n.getStateAtTime(Math.max(0,Math.min(n.duration,r))),o=new St,c=new Map,l=qs(e);for(const f of e.matchAll(ae)){const d=/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(f[2]??"");if(!d)continue;const b=d[2]??d[3];if(c.has(b))continue;const p=Ys(l(f.index??0));c.set(b,p),o.registerTarget(b,p)}o.applyState(a);let u="",h=0;for(const f of e.matchAll(ae)){const[d,b,p="",m]=f,k=f.index??0,y=/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(p),T=y?c.get(y[2]??y[3]):void 0;if(!T||Object.keys(T.style).length===0&&T.text===void 0)continue;u+=e.slice(h,k);const w=Object.entries(T.style).map(([S,I])=>`${Vs(S)}: ${I}`).join("; "),g=/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/.exec(p);let _=p;if(w)if(g){const S=`${(g[2]??g[3]).trim().replace(/;?$/,";")} ${w}`.trim();_=p.replace(g[0],` style="${oe(S)}"`)}else _=`${p} style="${oe(w)}"`;if(u+=`<${b}${_}${m?" /":""}>`,h=k+d.length,T.text!==void 0&&!m){const S=e.indexOf(`</${b}`,h),I=S===-1?"":e.slice(h,S);S!==-1&&!I.includes("<")&&(u+=Ws(T.text),h=S)}}return u+e.slice(h)}const ae=/<([a-zA-Z][\w:-]*)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*)\s*(\/?)>/g;function Ys(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(s){t.text=s}};return e&&(t.ownerSVGElement=null),t}function qs(e){const t=[],s=/<svg[\s>]/gi;let n;for(;n=s.exec(e);){const i=e.toLowerCase().indexOf("</svg>",n.index);t.push([n.index+1,i===-1?e.length:i])}return i=>t.some(([r,a])=>i>r&&i<a)}function Vs(e){const t=e.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);return/^(webkit|moz|ms)-/.test(t)?`-${t}`:t}function oe(e){return e.replace(/&/g,"&").replace(/"/g,""")}function Ws(e){return e.replace(/&/g,"&").replace(/</g,"<")}Ns(),O.DEFAULT_LABELS=te,O.TinyflyPlayer=rt,O.create=Cs,O.createControls=se,O.mount=ne,O.mountAll=ie,O.play=Is,O.renderFrame=Xs,O.targetNamesIn=re,O.unmount=Os,O.validateEmbed=Fs,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})})(this.tinyfly=this.tinyfly||{});
|
|
@@ -2216,7 +2216,14 @@ function Fs(e) {
|
|
|
2216
2216
|
const s = e.getAttribute("data-alt"), n = e.querySelector("figcaption");
|
|
2217
2217
|
t.setAttribute("role", "img"), s ? t.setAttribute("aria-label", s) : n && (n.id ||= `tinyfly-caption-${++Ds}`, t.setAttribute("aria-labelledby", n.id));
|
|
2218
2218
|
}
|
|
2219
|
-
function Xs(
|
|
2219
|
+
function Xs() {
|
|
2220
|
+
if (!(typeof document < "u" ? document.currentScript : null)?.hasAttribute("data-tinyfly-auto")) return;
|
|
2221
|
+
const t = () => {
|
|
2222
|
+
Ns();
|
|
2223
|
+
};
|
|
2224
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t, { once: !0 }) : t();
|
|
2225
|
+
}
|
|
2226
|
+
function Ys(e) {
|
|
2220
2227
|
const t = /* @__PURE__ */ new Set();
|
|
2221
2228
|
for (const s of e.matchAll(/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/g)) t.add(s[2] ?? s[3]);
|
|
2222
2229
|
return [...t];
|
|
@@ -2249,7 +2256,7 @@ function zs(e, t = {}) {
|
|
|
2249
2256
|
h in u || i(`marker "${h}" has no ${l} caption; its label is shown instead`);
|
|
2250
2257
|
}
|
|
2251
2258
|
if (t.markup !== void 0) {
|
|
2252
|
-
const l = new Set(
|
|
2259
|
+
const l = new Set(Ys(t.markup)), u = /* @__PURE__ */ new Set();
|
|
2253
2260
|
for (const h of e.tracks)
|
|
2254
2261
|
for (const f of [h.target, ...h.targets ?? []])
|
|
2255
2262
|
u.add(f), l.has(f) || n(`track "${h.id}" targets "${f}", but no element has data-tinyfly="${f}"`);
|
|
@@ -2258,13 +2265,13 @@ function zs(e, t = {}) {
|
|
|
2258
2265
|
return s;
|
|
2259
2266
|
}
|
|
2260
2267
|
function Gs(e, t, s = "end") {
|
|
2261
|
-
const n = rt(t), i = t.config?.markers ?? [], r = s === "start" ? 0 : s === "end" ? n.duration : typeof s == "number" ? s : i.find((f) => f.id === s)?.time ?? n.duration, a = n.getStateAtTime(Math.max(0, Math.min(n.duration, r))), o = new kt(), c = /* @__PURE__ */ new Map(), l =
|
|
2268
|
+
const n = rt(t), i = t.config?.markers ?? [], r = s === "start" ? 0 : s === "end" ? n.duration : typeof s == "number" ? s : i.find((f) => f.id === s)?.time ?? n.duration, a = n.getStateAtTime(Math.max(0, Math.min(n.duration, r))), o = new kt(), c = /* @__PURE__ */ new Map(), l = Vs(e);
|
|
2262
2269
|
for (const f of e.matchAll(Wt)) {
|
|
2263
2270
|
const d = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(f[2] ?? "");
|
|
2264
2271
|
if (!d) continue;
|
|
2265
2272
|
const b = d[2] ?? d[3];
|
|
2266
2273
|
if (c.has(b)) continue;
|
|
2267
|
-
const p =
|
|
2274
|
+
const p = qs(l(f.index ?? 0));
|
|
2268
2275
|
c.set(b, p), o.registerTarget(b, p);
|
|
2269
2276
|
}
|
|
2270
2277
|
o.applyState(a);
|
|
@@ -2273,7 +2280,7 @@ function Gs(e, t, s = "end") {
|
|
|
2273
2280
|
const [d, b, p = "", m] = f, k = f.index ?? 0, y = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(p), T = y ? c.get(y[2] ?? y[3]) : void 0;
|
|
2274
2281
|
if (!T || Object.keys(T.style).length === 0 && T.text === void 0) continue;
|
|
2275
2282
|
u += e.slice(h, k);
|
|
2276
|
-
const w = Object.entries(T.style).map(([S, I]) => `${
|
|
2283
|
+
const w = Object.entries(T.style).map(([S, I]) => `${Ws(S)}: ${I}`).join("; "), g = /\sstyle\s*=\s*("([^"]*)"|'([^']*)')/.exec(p);
|
|
2277
2284
|
let x = p;
|
|
2278
2285
|
if (w)
|
|
2279
2286
|
if (g) {
|
|
@@ -2283,13 +2290,13 @@ function Gs(e, t, s = "end") {
|
|
|
2283
2290
|
x = `${p} style="${Bt(w)}"`;
|
|
2284
2291
|
if (u += `<${b}${x}${m ? " /" : ""}>`, h = k + d.length, T.text !== void 0 && !m) {
|
|
2285
2292
|
const S = e.indexOf(`</${b}`, h), I = S === -1 ? "" : e.slice(h, S);
|
|
2286
|
-
S !== -1 && !I.includes("<") && (u +=
|
|
2293
|
+
S !== -1 && !I.includes("<") && (u += Bs(T.text), h = S);
|
|
2287
2294
|
}
|
|
2288
2295
|
}
|
|
2289
2296
|
return u + e.slice(h);
|
|
2290
2297
|
}
|
|
2291
2298
|
const Wt = /<([a-zA-Z][\w:-]*)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*)\s*(\/?)>/g;
|
|
2292
|
-
function
|
|
2299
|
+
function qs(e) {
|
|
2293
2300
|
const t = {
|
|
2294
2301
|
style: {},
|
|
2295
2302
|
dataset: {},
|
|
@@ -2304,7 +2311,7 @@ function Ys(e) {
|
|
|
2304
2311
|
};
|
|
2305
2312
|
return e && (t.ownerSVGElement = null), t;
|
|
2306
2313
|
}
|
|
2307
|
-
function
|
|
2314
|
+
function Vs(e) {
|
|
2308
2315
|
const t = [], s = /<svg[\s>]/gi;
|
|
2309
2316
|
let n;
|
|
2310
2317
|
for (; n = s.exec(e); ) {
|
|
@@ -2313,23 +2320,17 @@ function qs(e) {
|
|
|
2313
2320
|
}
|
|
2314
2321
|
return (i) => t.some(([r, a]) => i > r && i < a);
|
|
2315
2322
|
}
|
|
2316
|
-
function
|
|
2323
|
+
function Ws(e) {
|
|
2317
2324
|
const t = e.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
|
|
2318
2325
|
return /^(webkit|moz|ms)-/.test(t) ? `-${t}` : t;
|
|
2319
2326
|
}
|
|
2320
2327
|
function Bt(e) {
|
|
2321
2328
|
return e.replace(/&/g, "&").replace(/"/g, """);
|
|
2322
2329
|
}
|
|
2323
|
-
function
|
|
2330
|
+
function Bs(e) {
|
|
2324
2331
|
return e.replace(/&/g, "&").replace(/</g, "<");
|
|
2325
2332
|
}
|
|
2326
|
-
|
|
2327
|
-
if (Bs?.hasAttribute("data-tinyfly-auto")) {
|
|
2328
|
-
const e = () => {
|
|
2329
|
-
Ns();
|
|
2330
|
-
};
|
|
2331
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e, { once: !0 }) : e();
|
|
2332
|
-
}
|
|
2333
|
+
Xs();
|
|
2333
2334
|
export {
|
|
2334
2335
|
Cs as DEFAULT_LABELS,
|
|
2335
2336
|
St as TinyflyPlayer,
|
|
@@ -2339,7 +2340,7 @@ export {
|
|
|
2339
2340
|
Ns as mountAll,
|
|
2340
2341
|
Us as play,
|
|
2341
2342
|
Gs as renderFrame,
|
|
2342
|
-
|
|
2343
|
+
Ys as targetNamesIn,
|
|
2343
2344
|
Hs as unmount,
|
|
2344
2345
|
zs as validateEmbed
|
|
2345
2346
|
};
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
* facade (they play on real elements). The engine, the player, the compiling
|
|
12
12
|
* `tf` facade, drivers and interaction are all available on the same global.
|
|
13
13
|
*
|
|
14
|
+
* Teaching embeds are included too: step controls (`createControls`), declarative
|
|
15
|
+
* mounting (`mountAll`, or automatically when the script tag has
|
|
16
|
+
* `data-tinyfly-auto`). The build-time `validateEmbed` / `renderFrame` stay in
|
|
17
|
+
* `@algorisys/tinyfly/embed` and the CLI. For a page that only shows teaching
|
|
18
|
+
* figures, `tinyfly-embed.iife.js` is the smaller choice.
|
|
19
|
+
*
|
|
14
20
|
* Bundler users should import the individual entry points instead
|
|
15
21
|
* (`tinyfly`, `tinyfly/player`, `tinyfly/gsap-compat`, …) so unused parts
|
|
16
22
|
* tree-shake away; this file exists for pages with no build step.
|
|
@@ -39,3 +45,7 @@ export * from '../player';
|
|
|
39
45
|
export * from '../drivers';
|
|
40
46
|
export * from '../interaction';
|
|
41
47
|
export { tf, live, createLive, Stage, LiveTimeline, CompatTimeline, quickPlay, mapEase, CustomEase, CustomBounce, CustomWiggle, } from '../compat/gsap';
|
|
48
|
+
export { createControls, DEFAULT_LABELS } from '../embed/controls';
|
|
49
|
+
export type { Controls, ControlsOptions, ControlLabels } from '../embed/controls';
|
|
50
|
+
export { mount, mountAll, unmount } from '../embed/mount';
|
|
51
|
+
export type { MountedEmbed, MountOptions } from '../embed/mount';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount every `[data-tinyfly-embed]` when the page is ready, if the script that
|
|
3
|
+
* is running now was loaded with `data-tinyfly-auto`. Call it at the top level of
|
|
4
|
+
* a bundle's entry: `document.currentScript` is only set while a classic script
|
|
5
|
+
* first runs.
|
|
6
|
+
*/
|
|
7
|
+
export declare function autoMountFromCurrentScript(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algorisys/tinyfly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.66.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Lightweight, API-driven animation engine and editor. The engine is framework-agnostic and runs in browsers, Web Workers, and Node.",
|
|
6
6
|
"license": "MIT",
|