var nt=Object.defineProperty;var it=(o,e,n)=>e in o?nt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n;var X=(o,e,n)=>(it(o,typeof e!="symbol"?e+"":e,n),n);import{as as Y,ao as rt,at as st}from"./index.f2790301.js";const{abs:Q,cos:R,sin:N,acos:ot,atan2:U,sqrt:W,pow:C}=Math;function I(o){return o<0?-C(-o,1/3):C(o,1/3)}const tt=Math.PI,J=2*tt,S=tt/2,ut=1e-6,Z=Number.MAX_SAFE_INTEGER||9007199254740991,H=Number.MIN_SAFE_INTEGER||-9007199254740991,ct={x:0,y:0,z:0},l={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(o,e){const n=e(o);let i=n.x*n.x+n.y*n.y;return typeof n.z<"u"&&(i+=n.z*n.z),W(i)},compute:function(o,e,n){if(o===0)return e[0].t=0,e[0];const i=e.length-1;if(o===1)return e[i].t=1,e[i];const s=1-o;let u=e;if(i===0)return e[0].t=o,e[0];if(i===1){const c={x:s*u[0].x+o*u[1].x,y:s*u[0].y+o*u[1].y,t:o};return n&&(c.z=s*u[0].z+o*u[1].z),c}if(i<4){let c=s*s,a=o*o,h,y,f,x=0;i===2?(u=[u[0],u[1],u[2],ct],h=c,y=s*o*2,f=a):i===3&&(h=c*s,y=c*o*3,f=s*a*3,x=o*a);const p={x:h*u[0].x+y*u[1].x+f*u[2].x+x*u[3].x,y:h*u[0].y+y*u[1].y+f*u[2].y+x*u[3].y,t:o};return n&&(p.z=h*u[0].z+y*u[1].z+f*u[2].z+x*u[3].z),p}const r=JSON.parse(JSON.stringify(e));for(;r.length>1;){for(let c=0;c<r.length-1;c++)r[c]={x:r[c].x+(r[c+1].x-r[c].x)*o,y:r[c].y+(r[c+1].y-r[c].y)*o},typeof r[c].z<"u"&&(r[c]=r[c].z+(r[c+1].z-r[c].z)*o);r.splice(r.length-1,1)}return r[0].t=o,r[0]},computeWithRatios:function(o,e,n,i){const s=1-o,u=n,r=e;let c=u[0],a=u[1],h=u[2],y=u[3],f;if(c*=s,a*=o,r.length===2)return f=c+a,{x:(c*r[0].x+a*r[1].x)/f,y:(c*r[0].y+a*r[1].y)/f,z:i?(c*r[0].z+a*r[1].z)/f:!1,t:o};if(c*=s,a*=2*s,h*=o*o,r.length===3)return f=c+a+h,{x:(c*r[0].x+a*r[1].x+h*r[2].x)/f,y:(c*r[0].y+a*r[1].y+h*r[2].y)/f,z:i?(c*r[0].z+a*r[1].z+h*r[2].z)/f:!1,t:o};if(c*=s,a*=1.5*s,h*=3*s,y*=o*o*o,r.length===4)return f=c+a+h+y,{x:(c*r[0].x+a*r[1].x+h*r[2].x+y*r[3].x)/f,y:(c*r[0].y+a*r[1].y+h*r[2].y+y*r[3].y)/f,z:i?(c*r[0].z+a*r[1].z+h*r[2].z+y*r[3].z)/f:!1,t:o}},derive:function(o,e){const n=[];for(let i=o,s=i.length,u=s-1;s>1;s--,u--){const r=[];for(let c=0,a;c<u;c++)a={x:u*(i[c+1].x-i[c].x),y:u*(i[c+1].y-i[c].y)},e&&(a.z=u*(i[c+1].z-i[c].z)),r.push(a);n.push(r),i=r}return n},between:function(o,e,n){return e<=o&&o<=n||l.approximately(o,e)||l.approximately(o,n)},approximately:function(o,e,n){return Q(o-e)<=(n||ut)},length:function(o){const n=l.Tvalues.length;let i=0;for(let s=0,u;s<n;s++)u=.5*l.Tvalues[s]+.5,i+=l.Cvalues[s]*l.arcfn(u,o);return .5*i},map:function(o,e,n,i,s){const u=n-e,r=s-i,c=o-e,a=c/u;return i+r*a},lerp:function(o,e,n){const i={x:e.x+o*(n.x-e.x),y:e.y+o*(n.y-e.y)};return e.z!==void 0&&n.z!==void 0&&(i.z=e.z+o*(n.z-e.z)),i},pointToString:function(o){let e=o.x+"/"+o.y;return typeof o.z<"u"&&(e+="/"+o.z),e},pointsToString:function(o){return"["+o.map(l.pointToString).join(", ")+"]"},copy:function(o){return JSON.parse(JSON.stringify(o))},angle:function(o,e,n){const i=e.x-o.x,s=e.y-o.y,u=n.x-o.x,r=n.y-o.y,c=i*r-s*u,a=i*u+s*r;return U(c,a)},round:function(o,e){const n=""+o,i=n.indexOf(".");return parseFloat(n.substring(0,i+1+e))},dist:function(o,e){const n=o.x-e.x,i=o.y-e.y;return W(n*n+i*i)},closest:function(o,e){let n=C(2,63),i,s;return o.forEach(function(u,r){s=l.dist(e,u),s<n&&(n=s,i=r)}),{mdist:n,mpos:i}},abcratio:function(o,e){if(e!==2&&e!==3)return!1;if(typeof o>"u")o=.5;else if(o===0||o===1)return o;const n=C(o,e)+C(1-o,e),i=n-1;return Q(i/n)},projectionratio:function(o,e){if(e!==2&&e!==3)return!1;if(typeof o>"u")o=.5;else if(o===0||o===1)return o;const n=C(1-o,e),i=C(o,e)+n;return n/i},lli8:function(o,e,n,i,s,u,r,c){const a=(o*i-e*n)*(s-r)-(o-n)*(s*c-u*r),h=(o*i-e*n)*(u-c)-(e-i)*(s*c-u*r),y=(o-n)*(u-c)-(e-i)*(s-r);return y==0?!1:{x:a/y,y:h/y}},lli4:function(o,e,n,i){const s=o.x,u=o.y,r=e.x,c=e.y,a=n.x,h=n.y,y=i.x,f=i.y;return l.lli8(s,u,r,c,a,h,y,f)},lli:function(o,e){return l.lli4(o,o.c,e,e.c)},makeline:function(o,e){return new _(o.x,o.y,(o.x+e.x)/2,(o.y+e.y)/2,e.x,e.y)},findbbox:function(o){let e=Z,n=Z,i=H,s=H;return o.forEach(function(u){const r=u.bbox();e>r.x.min&&(e=r.x.min),n>r.y.min&&(n=r.y.min),i<r.x.max&&(i=r.x.max),s<r.y.max&&(s=r.y.max)}),{x:{min:e,mid:(e+i)/2,max:i,size:i-e},y:{min:n,mid:(n+s)/2,max:s,size:s-n}}},shapeintersections:function(o,e,n,i,s){if(!l.bboxoverlap(e,i))return[];const u=[],r=[o.startcap,o.forward,o.back,o.endcap],c=[n.startcap,n.forward,n.back,n.endcap];return r.forEach(function(a){a.virtual||c.forEach(function(h){if(h.virtual)return;const y=a.intersects(h,s);y.length>0&&(y.c1=a,y.c2=h,y.s1=o,y.s2=n,u.push(y))})}),u},makeshape:function(o,e,n){const i=e.points.length,s=o.points.length,u=l.makeline(e.points[i-1],o.points[0]),r=l.makeline(o.points[s-1],e.points[0]),c={startcap:u,forward:o,back:e,endcap:r,bbox:l.findbbox([u,o,e,r])};return c.intersections=function(a){return l.shapeintersections(c,c.bbox,a,a.bbox,n)},c},getminmax:function(o,e,n){if(!n)return{min:0,max:0};let i=Z,s=H,u,r;n.indexOf(0)===-1&&(n=[0].concat(n)),n.indexOf(1)===-1&&n.push(1);for(let c=0,a=n.length;c<a;c++)u=n[c],r=o.get(u),r[e]<i&&(i=r[e]),r[e]>s&&(s=r[e]);return{min:i,mid:(i+s)/2,max:s,size:s-i}},align:function(o,e){const n=e.p1.x,i=e.p1.y,s=-U(e.p2.y-i,e.p2.x-n),u=function(r){return{x:(r.x-n)*R(s)-(r.y-i)*N(s),y:(r.x-n)*N(s)+(r.y-i)*R(s)}};return o.map(u)},roots:function(o,e){e=e||{p1:{x:0,y:0},p2:{x:1,y:0}};const n=o.length-1,i=l.align(o,e),s=function(d){return 0<=d&&d<=1};if(n===2){const d=i[0].y,z=i[1].y,b=i[2].y,k=d-2*z+b;if(k!==0){const M=-W(z*z-d*b),F=-d+z,A=-(M+F)/k,j=-(-M+F)/k;return[A,j].filter(s)}else if(z!==b&&k===0)return[(2*z-b)/(2*z-2*b)].filter(s);return[]}const u=i[0].y,r=i[1].y,c=i[2].y,a=i[3].y;let h=-u+3*r-3*c+a,y=3*u-6*r+3*c,f=-3*u+3*r,x=u;if(l.approximately(h,0)){if(l.approximately(y,0))return l.approximately(f,0)?[]:[-x/f].filter(s);const d=W(f*f-4*y*x),z=2*y;return[(d-f)/z,(-f-d)/z].filter(s)}y/=h,f/=h,x/=h;const p=(3*f-y*y)/3,g=p/3,v=(2*y*y*y-9*y*f+27*x)/27,E=v/2,T=E*E+g*g*g;let V,w,O,m,q;if(T<0){const d=-p/3,z=d*d*d,b=W(z),k=-v/(2*b),M=k<-1?-1:k>1?1:k,F=ot(M),A=I(b),j=2*A;return O=j*R(F/3)-y/3,m=j*R((F+J)/3)-y/3,q=j*R((F+2*J)/3)-y/3,[O,m,q].filter(s)}else{if(T===0)return V=E<0?I(-E):-I(E),O=2*V-y/3,m=-V-y/3,[O,m].filter(s);{const d=W(T);return V=I(-E+d),w=I(E+d),[V-w-y/3].filter(s)}}},droots:function(o){if(o.length===3){const e=o[0],n=o[1],i=o[2],s=e-2*n+i;if(s!==0){const u=-W(n*n-e*i),r=-e+n,c=-(u+r)/s,a=-(-u+r)/s;return[c,a]}else if(n!==i&&s===0)return[(2*n-i)/(2*(n-i))];return[]}if(o.length===2){const e=o[0],n=o[1];return e!==n?[e/(e-n)]:[]}return[]},curvature:function(o,e,n,i,s){let u,r,c,a,h=0,y=0;const f=l.compute(o,e),x=l.compute(o,n),p=f.x*f.x+f.y*f.y;if(i?(u=W(C(f.y*x.z-x.y*f.z,2)+C(f.z*x.x-x.z*f.x,2)+C(f.x*x.y-x.x*f.y,2)),r=C(p+f.z*f.z,3/2)):(u=f.x*x.y-f.y*x.x,r=C(p,3/2)),u===0||r===0)return{k:0,r:0};if(h=u/r,y=r/u,!s){const g=l.curvature(o-.001,e,n,i,!0).k,v=l.curvature(o+.001,e,n,i,!0).k;a=(v-h+(h-g))/2,c=(Q(v-h)+Q(h-g))/2}return{k:h,r:y,dk:a,adk:c}},inflections:function(o){if(o.length<4)return[];const e=l.align(o,{p1:o[0],p2:o.slice(-1)[0]}),n=e[2].x*e[1].y,i=e[3].x*e[1].y,s=e[1].x*e[2].y,u=e[3].x*e[2].y,r=18*(-3*n+2*i+3*s-u),c=18*(3*n-i-3*s),a=18*(s-n);if(l.approximately(r,0)){if(!l.approximately(c,0)){let x=-a/c;if(0<=x&&x<=1)return[x]}return[]}const h=2*r;if(l.approximately(h,0))return[];const y=c*c-4*r*a;if(y<0)return[];const f=Math.sqrt(y);return[(f-c)/h,-(c+f)/h].filter(function(x){return 0<=x&&x<=1})},bboxoverlap:function(o,e){const n=["x","y"],i=n.length;for(let s=0,u,r,c,a;s<i;s++)if(u=n[s],r=o[u].mid,c=e[u].mid,a=(o[u].size+e[u].size)/2,Q(r-c)>=a)return!1;return!0},expandbox:function(o,e){e.x.min<o.x.min&&(o.x.min=e.x.min),e.y.min<o.y.min&&(o.y.min=e.y.min),e.z&&e.z.min<o.z.min&&(o.z.min=e.z.min),e.x.max>o.x.max&&(o.x.max=e.x.max),e.y.max>o.y.max&&(o.y.max=e.y.max),e.z&&e.z.max>o.z.max&&(o.z.max=e.z.max),o.x.mid=(o.x.min+o.x.max)/2,o.y.mid=(o.y.min+o.y.max)/2,o.z&&(o.z.mid=(o.z.min+o.z.max)/2),o.x.size=o.x.max-o.x.min,o.y.size=o.y.max-o.y.min,o.z&&(o.z.size=o.z.max-o.z.min)},pairiteration:function(o,e,n){const i=o.bbox(),s=e.bbox(),u=1e5,r=n||.5;if(i.x.size+i.y.size<r&&s.x.size+s.y.size<r)return[(u*(o._t1+o._t2)/2|0)/u+"/"+(u*(e._t1+e._t2)/2|0)/u];let c=o.split(.5),a=e.split(.5),h=[{left:c.left,right:a.left},{left:c.left,right:a.right},{left:c.right,right:a.right},{left:c.right,right:a.left}];h=h.filter(function(f){return l.bboxoverlap(f.left.bbox(),f.right.bbox())});let y=[];return h.length===0||(h.forEach(function(f){y=y.concat(l.pairiteration(f.left,f.right,r))}),y=y.filter(function(f,x){return y.indexOf(f)===x})),y},getccenter:function(o,e,n){const i=e.x-o.x,s=e.y-o.y,u=n.x-e.x,r=n.y-e.y,c=i*R(S)-s*N(S),a=i*N(S)+s*R(S),h=u*R(S)-r*N(S),y=u*N(S)+r*R(S),f=(o.x+e.x)/2,x=(o.y+e.y)/2,p=(e.x+n.x)/2,g=(e.y+n.y)/2,v=f+c,E=x+a,T=p+h,V=g+y,w=l.lli8(f,x,v,E,p,g,T,V),O=l.dist(w,o);let m=U(o.y-w.y,o.x-w.x),q=U(e.y-w.y,e.x-w.x),d=U(n.y-w.y,n.x-w.x),z;return m<d?((m>q||q>d)&&(m+=J),m>d&&(z=d,d=m,m=z)):d<q&&q<m?(z=d,d=m,m=z):d+=J,w.s=m,w.e=d,w.r=O,w},numberSort:function(o,e){return o-e}};class D{constructor(e){this.curves=[],this._3d=!1,e&&(this.curves=e,this._3d=this.curves[0]._3d)}valueOf(){return this.toString()}toString(){return"["+this.curves.map(function(e){return l.pointsToString(e.points)}).join(", ")+"]"}addCurve(e){this.curves.push(e),this._3d=this._3d||e._3d}length(){return this.curves.map(function(e){return e.length()}).reduce(function(e,n){return e+n})}curve(e){return this.curves[e]}bbox(){const e=this.curves;for(var n=e[0].bbox(),i=1;i<e.length;i++)l.expandbox(n,e[i].bbox());return n}offset(e){const n=[];return this.curves.forEach(function(i){n.push(...i.offset(e))}),new D(n)}}const{abs:P,min:K,max:B,cos:at,sin:ht,acos:ft,sqrt:$}=Math,lt=Math.PI;class _{constructor(e){let n=e&&e.forEach?e:Array.from(arguments).slice(),i=!1;if(typeof n[0]=="object"){i=n.length;const p=[];n.forEach(function(g){["x","y","z"].forEach(function(v){typeof g[v]<"u"&&p.push(g[v])})}),n=p}let s=!1;const u=n.length;if(i){if(i>4){if(arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");s=!0}}else if(u!==6&&u!==8&&u!==9&&u!==12&&arguments.length!==1)throw new Error("Only new Bezier(point[]) is accepted for 4th and higher order curves");const r=this._3d=!s&&(u===9||u===12)||e&&e[0]&&typeof e[0].z<"u",c=this.points=[];for(let p=0,g=r?3:2;p<u;p+=g){var a={x:n[p],y:n[p+1]};r&&(a.z=n[p+2]),c.push(a)}const h=this.order=c.length-1,y=this.dims=["x","y"];r&&y.push("z"),this.dimlen=y.length;const f=l.align(c,{p1:c[0],p2:c[h]}),x=l.dist(c[0],c[h]);this._linear=f.reduce((p,g)=>p+P(g.y),0)<x/50,this._lut=[],this._t1=0,this._t2=1,this.update()}static quadraticFromPoints(e,n,i,s){if(typeof s>"u"&&(s=.5),s===0)return new _(n,n,i);if(s===1)return new _(e,n,n);const u=_.getABC(2,e,n,i,s);return new _(e,u.A,i)}static cubicFromPoints(e,n,i,s,u){typeof s>"u"&&(s=.5);const r=_.getABC(3,e,n,i,s);typeof u>"u"&&(u=l.dist(n,r.C));const c=u*(1-s)/s,a=l.dist(e,i),h=(i.x-e.x)/a,y=(i.y-e.y)/a,f=u*h,x=u*y,p=c*h,g=c*y,v={x:n.x-f,y:n.y-x},E={x:n.x+p,y:n.y+g},T=r.A,V={x:T.x+(v.x-T.x)/(1-s),y:T.y+(v.y-T.y)/(1-s)},w={x:T.x+(E.x-T.x)/s,y:T.y+(E.y-T.y)/s},O={x:e.x+(V.x-e.x)/s,y:e.y+(V.y-e.y)/s},m={x:i.x+(w.x-i.x)/(1-s),y:i.y+(w.y-i.y)/(1-s)};return new _(e,O,m,i)}static getUtils(){return l}getUtils(){return _.getUtils()}static get PolyBezier(){return D}valueOf(){return this.toString()}toString(){return l.pointsToString(this.points)}toSVG(){if(this._3d)return!1;const e=this.points,n=e[0].x,i=e[0].y,s=["M",n,i,this.order===2?"Q":"C"];for(let u=1,r=e.length;u<r;u++)s.push(e[u].x),s.push(e[u].y);return s.join(" ")}setRatios(e){if(e.length!==this.points.length)throw new Error("incorrect number of ratio values");this.ratios=e,this._lut=[]}verify(){const e=this.coordDigest();e!==this._print&&(this._print=e,this.update())}coordDigest(){return this.points.map(function(e,n){return""+n+e.x+e.y+(e.z?e.z:0)}).join("")}update(){this._lut=[],this.dpoints=l.derive(this.points,this._3d),this.computedirection()}computedirection(){const e=this.points,n=l.angle(e[0],e[this.order],e[1]);this.clockwise=n>0}length(){return l.length(this.derivative.bind(this))}static getABC(e=2,n,i,s,u=.5){const r=l.projectionratio(u,e),c=1-r,a={x:r*n.x+c*s.x,y:r*n.y+c*s.y},h=l.abcratio(u,e);return{A:{x:i.x+(i.x-a.x)/h,y:i.y+(i.y-a.y)/h},B:i,C:a,S:n,E:s}}getABC(e,n){n=n||this.get(e);let i=this.points[0],s=this.points[this.order];return _.getABC(this.order,i,n,s,e)}getLUT(e){if(this.verify(),e=e||100,this._lut.length===e)return this._lut;this._lut=[],e++,this._lut=[];for(let n=0,i,s;n<e;n++)s=n/(e-1),i=this.compute(s),i.t=s,this._lut.push(i);return this._lut}on(e,n){n=n||5;const i=this.getLUT(),s=[];for(let u=0,r,c=0;u<i.length;u++)r=i[u],l.dist(r,e)<n&&(s.push(r),c+=u/i.length);return s.length?t/=s.length:!1}project(e){const n=this.getLUT(),i=n.length-1,s=l.closest(n,e),u=s.mpos,r=(u-1)/i,c=(u+1)/i,a=.1/i;let h=s.mdist,y=r,f=y,x;h+=1;for(let p;y<c+a;y+=a)x=this.compute(y),p=l.dist(e,x),p<h&&(h=p,f=y);return f=f<0?0:f>1?1:f,x=this.compute(f),x.t=f,x.d=h,x}get(e){return this.compute(e)}point(e){return this.points[e]}compute(e){return this.ratios?l.computeWithRatios(e,this.points,this.ratios,this._3d):l.compute(e,this.points,this._3d,this.ratios)}raise(){const e=this.points,n=[e[0]],i=e.length;for(let s=1,u,r;s<i;s++)u=e[s],r=e[s-1],n[s]={x:(i-s)/i*u.x+s/i*r.x,y:(i-s)/i*u.y+s/i*r.y};return n[i]=e[i-1],new _(n)}derivative(e){return l.compute(e,this.dpoints[0],this._3d)}dderivative(e){return l.compute(e,this.dpoints[1],this._3d)}align(){let e=this.points;return new _(l.align(e,{p1:e[0],p2:e[e.length-1]}))}curvature(e){return l.curvature(e,this.dpoints[0],this.dpoints[1],this._3d)}inflections(){return l.inflections(this.points)}normal(e){return this._3d?this.__normal3(e):this.__normal2(e)}__normal2(e){const n=this.derivative(e),i=$(n.x*n.x+n.y*n.y);return{t:e,x:-n.y/i,y:n.x/i}}__normal3(e){const n=this.derivative(e),i=this.derivative(e+.01),s=$(n.x*n.x+n.y*n.y+n.z*n.z),u=$(i.x*i.x+i.y*i.y+i.z*i.z);n.x/=s,n.y/=s,n.z/=s,i.x/=u,i.y/=u,i.z/=u;const r={x:i.y*n.z-i.z*n.y,y:i.z*n.x-i.x*n.z,z:i.x*n.y-i.y*n.x},c=$(r.x*r.x+r.y*r.y+r.z*r.z);r.x/=c,r.y/=c,r.z/=c;const a=[r.x*r.x,r.x*r.y-r.z,r.x*r.z+r.y,r.x*r.y+r.z,r.y*r.y,r.y*r.z-r.x,r.x*r.z-r.y,r.y*r.z+r.x,r.z*r.z];return{t:e,x:a[0]*n.x+a[1]*n.y+a[2]*n.z,y:a[3]*n.x+a[4]*n.y+a[5]*n.z,z:a[6]*n.x+a[7]*n.y+a[8]*n.z}}hull(e){let n=this.points,i=[],s=[],u=0;for(s[u++]=n[0],s[u++]=n[1],s[u++]=n[2],this.order===3&&(s[u++]=n[3]);n.length>1;){i=[];for(let r=0,c,a=n.length-1;r<a;r++)c=l.lerp(e,n[r],n[r+1]),s[u++]=c,i.push(c);n=i}return s}split(e,n){if(e===0&&!!n)return this.split(n).left;if(n===1)return this.split(e).right;const i=this.hull(e),s={left:this.order===2?new _([i[0],i[3],i[5]]):new _([i[0],i[4],i[7],i[9]]),right:this.order===2?new _([i[5],i[4],i[2]]):new _([i[9],i[8],i[6],i[3]]),span:i};return s.left._t1=l.map(0,0,1,this._t1,this._t2),s.left._t2=l.map(e,0,1,this._t1,this._t2),s.right._t1=l.map(e,0,1,this._t1,this._t2),s.right._t2=l.map(1,0,1,this._t1,this._t2),n?(n=l.map(n,e,1,0,1),s.right.split(n).left):s}extrema(){const e={};let n=[];return this.dims.forEach(function(i){let s=function(r){return r[i]},u=this.dpoints[0].map(s);e[i]=l.droots(u),this.order===3&&(u=this.dpoints[1].map(s),e[i]=e[i].concat(l.droots(u))),e[i]=e[i].filter(function(r){return r>=0&&r<=1}),n=n.concat(e[i].sort(l.numberSort))}.bind(this)),e.values=n.sort(l.numberSort).filter(function(i,s){return n.indexOf(i)===s}),e}bbox(){const e=this.extrema(),n={};return this.dims.forEach(function(i){n[i]=l.getminmax(this,i,e[i])}.bind(this)),n}overlaps(e){const n=this.bbox(),i=e.bbox();return l.bboxoverlap(n,i)}offset(e,n){if(typeof n<"u"){const i=this.get(e),s=this.normal(e),u={c:i,n:s,x:i.x+s.x*n,y:i.y+s.y*n};return this._3d&&(u.z=i.z+s.z*n),u}if(this._linear){const i=this.normal(0),s=this.points.map(function(u){const r={x:u.x+e*i.x,y:u.y+e*i.y};return u.z&&i.z&&(r.z=u.z+e*i.z),r});return[new _(s)]}return this.reduce().map(function(i){return i._linear?i.offset(e)[0]:i.scale(e)})}simple(){if(this.order===3){const s=l.angle(this.points[0],this.points[3],this.points[1]),u=l.angle(this.points[0],this.points[3],this.points[2]);if(s>0&&u<0||s<0&&u>0)return!1}const e=this.normal(0),n=this.normal(1);let i=e.x*n.x+e.y*n.y;return this._3d&&(i+=e.z*n.z),P(ft(i))<lt/3}reduce(){let e,n=0,i=0,s=.01,u,r=[],c=[],a=this.extrema().values;for(a.indexOf(0)===-1&&(a=[0].concat(a)),a.indexOf(1)===-1&&a.push(1),n=a[0],e=1;e<a.length;e++)i=a[e],u=this.split(n,i),u._t1=n,u._t2=i,r.push(u),n=i;return r.forEach(function(h){for(n=0,i=0;i<=1;)for(i=n+s;i<=1+s;i+=s)if(u=h.split(n,i),!u.simple()){if(i-=s,P(n-i)<s)return[];u=h.split(n,i),u._t1=l.map(n,0,1,h._t1,h._t2),u._t2=l.map(i,0,1,h._t1,h._t2),c.push(u),n=i;break}n<1&&(u=h.split(n,1),u._t1=l.map(n,0,1,h._t1,h._t2),u._t2=h._t2,c.push(u))}),c}translate(e,n,i){i=typeof i=="number"?i:n;const s=this.order;let u=this.points.map((r,c)=>(1-c/s)*n+c/s*i);return new _(this.points.map((r,c)=>({x:r.x+e.x*u[c],y:r.y+e.y*u[c]})))}scale(e){const n=this.order;let i=!1;if(typeof e=="function"&&(i=e),i&&n===2)return this.raise().scale(i);const s=this.clockwise,u=this.points;if(this._linear)return this.translate(this.normal(0),i?i(0):e,i?i(1):e);const r=i?i(0):e,c=i?i(1):e,a=[this.offset(0,10),this.offset(1,10)],h=[],y=l.lli4(a[0],a[0].c,a[1],a[1].c);if(!y)throw new Error("cannot scale this curve. Try reducing it first.");return[0,1].forEach(function(f){const x=h[f*n]=l.copy(u[f*n]);x.x+=(f?c:r)*a[f].n.x,x.y+=(f?c:r)*a[f].n.y}),i?([0,1].forEach(function(f){if(!(n===2&&!!f)){var x=u[f+1],p={x:x.x-y.x,y:x.y-y.y},g=i?i((f+1)/n):e;i&&!s&&(g=-g);var v=$(p.x*p.x+p.y*p.y);p.x/=v,p.y/=v,h[f+1]={x:x.x+g*p.x,y:x.y+g*p.y}}}),new _(h)):([0,1].forEach(f=>{if(n===2&&!!f)return;const x=h[f*n],p=this.derivative(f),g={x:x.x+p.x,y:x.y+p.y};h[f+1]=l.lli4(x,g,y,u[f+1])}),new _(h))}outline(e,n,i,s){if(n=n===void 0?e:n,this._linear){const m=this.normal(0),q=this.points[0],d=this.points[this.points.length-1];let z,b,k;i===void 0&&(i=e,s=n),z={x:q.x+m.x*e,y:q.y+m.y*e},k={x:d.x+m.x*i,y:d.y+m.y*i},b={x:(z.x+k.x)/2,y:(z.y+k.y)/2};const M=[z,b,k];z={x:q.x-m.x*n,y:q.y-m.y*n},k={x:d.x-m.x*s,y:d.y-m.y*s},b={x:(z.x+k.x)/2,y:(z.y+k.y)/2};const F=[k,b,z],A=l.makeline(F[2],M[0]),j=l.makeline(M[2],F[0]),et=[A,new _(M),j,new _(F)];return new D(et)}const u=this.reduce(),r=u.length,c=[];let a=[],h,y=0,f=this.length();const x=typeof i<"u"&&typeof s<"u";function p(m,q,d,z,b){return function(k){const M=z/d,F=(z+b)/d,A=q-m;return l.map(k,0,1,m+M*A,m+F*A)}}u.forEach(function(m){const q=m.length();x?(c.push(m.scale(p(e,i,f,y,q))),a.push(m.scale(p(-n,-s,f,y,q)))):(c.push(m.scale(e)),a.push(m.scale(-n))),y+=q}),a=a.map(function(m){return h=m.points,h[3]?m.points=[h[3],h[2],h[1],h[0]]:m.points=[h[2],h[1],h[0]],m}).reverse();const g=c[0].points[0],v=c[r-1].points[c[r-1].points.length-1],E=a[r-1].points[a[r-1].points.length-1],T=a[0].points[0],V=l.makeline(E,g),w=l.makeline(v,T),O=[V].concat(c).concat([w]).concat(a);return new D(O)}outlineshapes(e,n,i){n=n||e;const s=this.outline(e,n).curves,u=[];for(let r=1,c=s.length;r<c/2;r++){const a=l.makeshape(s[r],s[c-r],i);a.startcap.virtual=r>1,a.endcap.virtual=r<c/2-1,u.push(a)}return u}intersects(e,n){return e?e.p1&&e.p2?this.lineIntersects(e):(e instanceof _&&(e=e.reduce()),this.curveintersects(this.reduce(),e,n)):this.selfintersects(n)}lineIntersects(e){const n=K(e.p1.x,e.p2.x),i=K(e.p1.y,e.p2.y),s=B(e.p1.x,e.p2.x),u=B(e.p1.y,e.p2.y);return l.roots(this.points,e).filter(r=>{var c=this.get(r);return l.between(c.x,n,s)&&l.between(c.y,i,u)})}selfintersects(e){const n=this.reduce(),i=n.length-2,s=[];for(let u=0,r,c,a;u<i;u++)c=n.slice(u,u+1),a=n.slice(u+2),r=this.curveintersects(c,a,e),s.push(...r);return s}curveintersects(e,n,i){const s=[];e.forEach(function(r){n.forEach(function(c){r.overlaps(c)&&s.push({left:r,right:c})})});let u=[];return s.forEach(function(r){const c=l.pairiteration(r.left,r.right,i);c.length>0&&(u=u.concat(c))}),u}arcs(e){return e=e||.5,this._iterate(e,[])}_error(e,n,i,s){const u=(s-i)/4,r=this.get(i+u),c=this.get(s-u),a=l.dist(e,n),h=l.dist(e,r),y=l.dist(e,c);return P(h-a)+P(y-a)}_iterate(e,n){let i=0,s=1,u;do{u=0,s=1;let r=this.get(i),c,a,h,y,f=!1,x=!1,p,g=s,v=1;do if(x=f,y=h,g=(i+s)/2,c=this.get(g),a=this.get(s),h=l.getccenter(r,c,a),h.interval={start:i,end:s},f=this._error(h,r,i,s)<=e,p=x&&!f,p||(v=s),f){if(s>=1){if(h.interval.end=v=1,y=h,s>1){let T={x:h.x+h.r*at(h.e),y:h.y+h.r*ht(h.e)};h.e+=l.angle({x:h.x,y:h.y},T,this.get(1))}break}s=s+(s-i)/2}else s=g;while(!p&&u++<100);if(u>=100)break;y=y||h,n.push(y),i=v}while(s<1);return n}}class yt{constructor(){this._queue=[],this._waitingForFrame=!1}add(e){this._queue.push(e),this._runQueue()}_runQueue(){this._waitingForFrame||(this._waitingForFrame=!0,window.requestAnimationFrame(this._processQueue.bind(this)))}_processQueue(e){const n=this._queue;this._queue=[],n.forEach(i=>{typeof i=="function"&&i(e)}),this._waitingForFrame=!1,this._queue.length>0&&this._runQueue()}}const xt=new yt,G=class{constructor(e,n){switch(this.type=e||"number",this.callback=n,this.type){case"number":default:this.startValue=0,this.endValue=0;break;case"vector":this.startValue=new Y(0,0),this.endValue=new Y(0,0);break}this.time=0,this.currentTime=0,this._prevTime=null,this._frameWaiting=!1,this._halt=!1,this._endResolve=null}_calcDeltaTime(e){this._prevTime||(this._prevTime=e);const n=e-this._prevTime;return this._prevTime=e,n}_update(e){if(this._frameWaiting=!1,this._halt)this._halt=!1;else{const n=this._calcDeltaTime(e);this.currentTime+=n,this.currentTime<this.time?this._frameWaiting||(this._frameWaiting=!0,xt.add(this._update.bind(this))):(this.currentTime=e,this._endResolve(this)),this.callback&&this.callback({lerp:this.lerp,berp:this.berp})}}_computeValue(e){switch(e=rt(e||0,0,1),this.type){case"number":default:return this._decorateWithRounded(e*(this.endValue-this.startValue)+this.startValue);case"vector":return new Y(this._decorateWithRounded(e*(this.endValue.x-this.startValue.x)+this.startValue.x),this._decorateWithRounded(e*(this.endValue.y-this.startValue.y)+this.startValue.y))}}_decorateWithRounded(e){return st(e,"rounded",Math.round(e))}_computeBezier(e,n){return n<=0?0:n>=1?1:e.get(e.intersects({p1:{x:n,y:0},p2:{x:n,y:1}})[0]).y}get progress(){return this.currentTime>=this.time?1:this.currentTime<=0?0:this.time?this.currentTime/this.time:0}start(e,n,i){return new Promise(s=>{this._endResolve=s,e&&(this.startValue=e),n&&(this.endValue=n),this.time=i,this.reset()})}stop(){this._frameWaiting&&(this._halt=!0),this.currentTime=0}reset(){this.currentTime=0,this._prevTime=null,this._update(0)}get ended(){return this.currentTime>=this.time}get lerp(){return this._computeValue(this.currentTime/this.time)}get berp(){return this._computeValue(this._computeBezier(G.berpCurve,this.progress))}get qerp(){return this._computeValue(this._computeBezier(G.qerpCurve,this.progress))}};let L=G;X(L,"berpCurve",new _({x:-1e-4,y:0},{x:.5,y:0},{x:.5,y:1},{x:1.0001,y:1})),X(L,"qerpCurve",new _({x:-1e-4,y:0},{x:0,y:.25},{x:0,y:1},{x:1.0001,y:1}));export{L as A,yt as F};
//# sourceMappingURL=animation.d9c14651.js.map
