/* MIT License Copyright (c) 2012 - 2021 @jonobr1 / http://jono.fyi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ var Two=(()=>{var ge=Object.defineProperty;var Gi=Object.getOwnPropertyDescriptor;var qi=Object.getOwnPropertyNames;var Ki=Object.prototype.hasOwnProperty;var Ji=(i,t,e)=>t in i?ge(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var $i=i=>ge(i,"__esModule",{value:!0});var Ce=(i,t)=>{for(var e in t)ge(i,e,{get:t[e],enumerable:!0})},Zi=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of qi(t))!Ki.call(i,r)&&(e||r!=="default")&&ge(i,r,{get:()=>t[r],enumerable:!(s=Gi(t,r))||s.enumerable});return i};var Qi=(i=>(t,e)=>i&&i.get(t)||(e=Zi($i({}),t,1),i&&i.set(t,e),e))(typeof WeakMap!="undefined"?new WeakMap:0);var w=(i,t,e)=>(Ji(i,typeof t!="symbol"?t+"":t,e),e);var Js={};Ce(Js,{default:()=>I});var v={move:"M",line:"L",curve:"C",arc:"A",close:"Z"};var Ie={};Ce(Ie,{HALF_PI:()=>$,NumArray:()=>xt,TWO_PI:()=>J,decomposeMatrix:()=>Lt,getComputedMatrix:()=>pt,getPoT:()=>Pe,lerp:()=>nt,mod:()=>it,setMatrix:()=>Le,toFixed:()=>K});var H;typeof window!="undefined"?H=window:typeof global!="undefined"?H=global:typeof self!="undefined"&&(H=self);var oi,J=Math.PI*2,$=Math.PI*.5;function Lt(i,t,e,s,r,n){let a;return arguments.length<=1?(a=i.a,t=i.b,e=i.c,s=i.d,r=i.e,n=i.f):a=i,{translateX:r,translateY:n,scaleX:Math.sqrt(a*a+t*t),scaleY:Math.sqrt(e*e+s*s),rotation:180*Math.atan2(t,a)/Math.PI}}function Le(i){oi=i}function pt(i,t){t=t&&t.identity()||new oi;let e=i,s=[];for(;e&&e._matrix;)s.push(e._matrix),e=e.parent;s.reverse();for(let r=0;rjt,getAnchorsFromArcData:()=>is,getComponentOnCubicBezier:()=>Dt,getControlPoints:()=>ci,getCurveBoundingBox:()=>je,getCurveFromPoints:()=>Ne,getCurveLength:()=>Be,getReflection:()=>pe,integrate:()=>fi,subdivide:()=>te});var m=class{_events={};_bound=!1;constructor(){}addEventListener(t,e){return(this._events[t]||(this._events[t]=[])).push(e),this._bound=!0,this}on(){return this.addEventListener.apply(this,arguments)}bind(){return this.addEventListener.apply(this,arguments)}removeEventListener(t,e){if(!this._events)return this;if(!t&&!e)return this._events={},this._bound=!1,this;let s=t?[t]:Object.keys(this._events);for(let r=0,n=s.length;r=4){let n=arguments[0]-arguments[2],a=arguments[1]-arguments[3];return Math.atan2(a,n)}let s=t.x-e.x,r=t.y-e.y;return Math.atan2(r,s)}static distanceBetween(t,e){return Math.sqrt(Ot.distanceBetweenSquared(t,e))}static distanceBetweenSquared(t,e){let s=t.x-e.x,r=t.y-e.y;return s*s+r*r}set(t,e){return this.x=t,this.y=e,this}copy(t){return this.x=t.x,this.y=t.y,this}clear(){return this.x=0,this.y=0,this}clone(){return new Ot(this.x,this.y)}add(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x+=t,this.y+=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x+=t.x,this.y+=t.y):(this.x+=t,this.y+=e),this)}addSelf(t){return this.add.apply(this,arguments)}sub(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x-=t,this.y-=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x-=t.x,this.y-=t.y):(this.x-=t,this.y-=e),this)}subtract(){return this.sub.apply(this,arguments)}subSelf(t){return this.sub.apply(this,arguments)}subtractSelf(t){return this.sub.apply(this,arguments)}multiply(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x*=t,this.y*=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x*=t.x,this.y*=t.y):(this.x*=t,this.y*=e),this)}multiplySelf(t){return this.multiply.apply(this,arguments)}multiplyScalar(t){return this.multiply(t)}divide(t,e){return arguments.length<=0?this:(arguments.length<=1?typeof t=="number"?(this.x/=t,this.y/=t):t&&typeof t.x=="number"&&typeof t.y=="number"&&(this.x/=t.x,this.y/=t.y):(this.x/=t,this.y/=e),isNaN(this.x)&&(this.x=0),isNaN(this.y)&&(this.y=0),this)}divideSelf(t){return this.divide.apply(this,arguments)}divideScalar(t){return this.divide(t)}negate(){return this.multiply(-1)}dot(t){return this.x*t.x+this.y*t.y}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this.x*this.x+this.y*this.y}normalize(){return this.divideScalar(this.length())}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y;return e*e+s*s}setLength(t){return this.normalize().multiplyScalar(t)}equals(t,e){return e=typeof e=="undefined"?1e-4:e,this.distanceTo(t)>1,f=s&1?n[h++]*i(o):0;for(;h=0&&t<4294967296}var S={isNaN:function(i){return typeof i=="number"&&i!==+i},isElement:function(i){return!!(i&&i.nodeType===1)},isObject:function(i){let t=typeof i;return t==="function"||t==="object"&&!!i},extend:function(i){let t=ui.call(arguments,1);for(let e=0;e=0&&this.classList.splice(n,1)}this.classList=this.classList.concat(e)}this._className=i}}};var as=Math.cos,os=Math.sin,_i=Math.tan,ze=[],mt=class extends m{elements=new xt(9);manual=!1;constructor(t,e,s,r,n,a){super();let o=t;Array.isArray(o)||(o=Array.prototype.slice.call(arguments)),this.identity(),o.length>0&&this.set(o)}static Multiply(t,e,s){if(e.length<=3){let E=t,C,j,M,T=e[0]||0,N=e[1]||0,z=e[2]||0;return C=E[0]*T+E[1]*N+E[2]*z,j=E[3]*T+E[4]*N+E[5]*z,M=E[6]*T+E[7]*N+E[8]*z,{x:C,y:j,z:M}}let r=t[0],n=t[1],a=t[2],o=t[3],h=t[4],l=t[5],f=t[6],u=t[7],_=t[8],d=e[0],c=e[1],p=e[2],b=e[3],g=e[4],y=e[5],x=e[6],R=e[7],A=e[8];return s=s||new xt(9),s[0]=r*d+n*b+a*x,s[1]=r*c+n*g+a*R,s[2]=r*p+n*y+a*A,s[3]=o*d+h*b+l*x,s[4]=o*c+h*g+l*R,s[5]=o*p+h*y+l*A,s[6]=f*d+u*b+_*x,s[7]=f*c+u*g+_*R,s[8]=f*p+u*y+_*A,s}set(t,e,s,r,n,a,o,h,l){if(typeof e=="undefined"){let f=t;t=f[0],e=f[1],s=f[2],r=f[3],n=f[4],a=f[5],o=f[6],h=f[7],l=f[8]}return this.elements[0]=t,this.elements[1]=e,this.elements[2]=s,this.elements[3]=r,this.elements[4]=n,this.elements[5]=a,this.elements[6]=o,this.elements[7]=h,this.elements[8]=l,this.trigger(m.Types.change)}copy(t){return this.elements[0]=t.elements[0],this.elements[1]=t.elements[1],this.elements[2]=t.elements[2],this.elements[3]=t.elements[3],this.elements[4]=t.elements[4],this.elements[5]=t.elements[5],this.elements[6]=t.elements[6],this.elements[7]=t.elements[7],this.elements[8]=t.elements[8],this.manual=t.manual,this.trigger(m.Types.change)}identity(){return this.elements[0]=mt.Identity[0],this.elements[1]=mt.Identity[1],this.elements[2]=mt.Identity[2],this.elements[3]=mt.Identity[3],this.elements[4]=mt.Identity[4],this.elements[5]=mt.Identity[5],this.elements[6]=mt.Identity[6],this.elements[7]=mt.Identity[7],this.elements[8]=mt.Identity[8],this.trigger(m.Types.change)}multiply(t,e,s,r,n,a,o,h,l){if(typeof e=="undefined")return this.elements[0]*=t,this.elements[1]*=t,this.elements[2]*=t,this.elements[3]*=t,this.elements[4]*=t,this.elements[5]*=t,this.elements[6]*=t,this.elements[7]*=t,this.elements[8]*=t,this.trigger(m.Types.change);if(typeof r=="undefined"){t=t||0,e=e||0,s=s||0,n=this.elements;let V=n[0]*t+n[1]*e+n[2]*s,ft=n[3]*t+n[4]*e+n[5]*s,ct=n[6]*t+n[7]*e+n[8]*s;return{x:V,y:ft,z:ct}}let f=this.elements,u=[t,e,s,r,n,a,o,h,l],_=f[0],d=f[1],c=f[2],p=f[3],b=f[4],g=f[5],y=f[6],x=f[7],R=f[8],A=u[0],E=u[1],C=u[2],j=u[3],M=u[4],T=u[5],N=u[6],z=u[7],W=u[8];return this.elements[0]=_*A+d*j+c*N,this.elements[1]=_*E+d*M+c*z,this.elements[2]=_*C+d*T+c*W,this.elements[3]=p*A+b*j+g*N,this.elements[4]=p*E+b*M+g*z,this.elements[5]=p*C+b*T+g*W,this.elements[6]=y*A+x*j+R*N,this.elements[7]=y*E+x*M+R*z,this.elements[8]=y*C+x*T+R*W,this.trigger(m.Types.change)}inverse(t){let e=this.elements;t=t||new mt;let s=e[0],r=e[1],n=e[2],a=e[3],o=e[4],h=e[5],l=e[6],f=e[7],u=e[8],_=u*o-h*f,d=-u*a+h*l,c=f*a-o*l,p=s*_+r*d+n*c;return p?(p=1/p,t.elements[0]=_*p,t.elements[1]=(-u*r+n*f)*p,t.elements[2]=(h*r-n*o)*p,t.elements[3]=d*p,t.elements[4]=(u*s-n*l)*p,t.elements[5]=(-h*s+n*a)*p,t.elements[6]=c*p,t.elements[7]=(-f*s+r*l)*p,t.elements[8]=(o*s-r*a)*p,t):null}scale(t,e){return arguments.length<=1&&(e=t),this.multiply(t,0,0,0,e,0,0,0,1)}rotate(t){let e=as(t),s=os(t);return this.multiply(e,-s,0,s,e,0,0,0,1)}translate(t,e){return this.multiply(1,0,t,0,1,e,0,0,1)}skewX(t){let e=_i(t);return this.multiply(1,e,0,0,1,0,0,0,1)}skewY(t){let e=_i(t);return this.multiply(1,0,0,e,1,0,0,0,1)}toString(t){return ze.length=0,this.toTransformArray(t,ze),ze.map(K).join(" ")}toTransformArray(t,e){let s=this.elements,r=!!e,n=s[0],a=s[1],o=s[2],h=s[3],l=s[4],f=s[5];if(t){let u=s[6],_=s[7],d=s[8];if(r){e[0]=n,e[1]=h,e[2]=u,e[3]=a,e[4]=l,e[5]=_,e[6]=o,e[7]=f,e[8]=d;return}return[n,h,u,a,l,_,o,f,d]}if(r){e[0]=n,e[1]=h,e[2]=a,e[3]=l,e[4]=o,e[5]=f;return}return[n,h,a,l,o,f]}toArray(t,e){let s=this.elements,r=!!e,n=s[0],a=s[1],o=s[2],h=s[3],l=s[4],f=s[5];if(t){let u=s[6],_=s[7],d=s[8];if(r){e[0]=n,e[1]=a,e[2]=o,e[3]=h,e[4]=l,e[5]=f,e[6]=u,e[7]=_,e[8]=d;return}return[n,a,o,h,l,f,u,_,d]}if(r){e[0]=n,e[1]=a,e[2]=o,e[3]=h,e[4]=l,e[5]=f;return}return[n,a,o,h,l,f]}toObject(){return{elements:this.toArray(!0),manual:!!this.manual}}clone(){return new mt().copy(this)}},at=mt;w(at,"Identity",[1,0,0,0,1,0,0,0,1]);Le(at);var ot=class extends Et{_flagMatrix=!0;_flagScale=!1;_matrix=null;_worldMatrix=null;_position=null;_rotation=0;_scale=1;_skewX=0;_skewY=0;constructor(){super();for(let t in me)Object.defineProperty(this,t,me[t]);this._renderer.flagMatrix=gi.bind(this),this.isShape=!0,this.id=X.Identifier+X.uniqueId(),this.matrix=new at,this.worldMatrix=new at,this.position=new k,this.rotation=0,this.scale=1,this.skewX=0,this.skewY=0}get renderer(){return this._renderer}set renderer(t){this._renderer=t}get translation(){return me.position.get.apply(this,arguments)}set translation(t){me.position.set.apply(this,arguments)}addTo(t){return t.add(this),this}remove(){return this.parent?(this.parent.remove(this),this):this}clone(t){let e=new ot;return e.position.copy(this.position),e.rotation=this.rotation,e.scale=this.scale,e.skewX=this.skewX,e.skewY=this.skewY,this.matrix.manual&&e.matrix.copy(this.matrix),t&&t.add(e),e._update()}_update(t){return!this._matrix.manual&&this._flagMatrix&&(this._matrix.identity().translate(this.position.x,this.position.y),this._scale instanceof k?this._matrix.scale(this._scale.x,this._scale.y):this._matrix.scale(this._scale),this._matrix.rotate(this.rotation),this._matrix.skewX(this.skewX),this._matrix.skewY(this.skewY)),t&&this.parent&&this.parent._update&&this.parent._update(),this}flagReset(){return this._flagMatrix=this._flagScale=!1,super.flagReset.call(this),this}},me={position:{enumerable:!0,get:function(){return this._position},set:function(i){this._position&&this._position.unbind(m.Types.change,this._renderer.flagMatrix),this._position=i,this._position.bind(m.Types.change,this._renderer.flagMatrix),gi.call(this)}},rotation:{enumerable:!0,get:function(){return this._rotation},set:function(i){this._rotation=i,this._flagMatrix=!0}},scale:{enumerable:!0,get:function(){return this._scale},set:function(i){this._scale instanceof k&&this._scale.unbind(m.Types.change,this._renderer.flagMatrix),this._scale=i,this._scale instanceof k&&this._scale.bind(m.Types.change,this._renderer.flagMatrix),this._flagMatrix=!0,this._flagScale=!0}},skewX:{enumerable:!0,get:function(){return this._skewX},set:function(i){this._skewX=i,this._flagMatrix=!0}},skewY:{enumerable:!0,get:function(){return this._skewY},set:function(i){this._skewY=i,this._flagMatrix=!0}},matrix:{enumerable:!0,get:function(){return this._matrix},set:function(i){this._matrix=i,this._flagMatrix=!0}},worldMatrix:{enumerable:!0,get:function(){return pt(this,this._worldMatrix),this._worldMatrix},set:function(i){this._worldMatrix=i}}};function gi(){this._flagMatrix=!0}var lt=class extends Array{_events=new m;get _bound(){return this._events._bound}set _bound(t){this._events._bound=t}addEventListener(){return this._events.addEventListener.apply(this,arguments)}on(){return this._events.on.apply(this,arguments)}bind(){return this._events.bind.apply(this,arguments)}removeEventListener(){return this._events.removeEventListener.apply(this,arguments)}off(){return this._events.off.apply(this,arguments)}unbind(){return this._events.unbind.apply(this,arguments)}dispatchEvent(){return this._events.dispatchEvent.apply(this,arguments)}trigger(){return this._events.trigger.apply(this,arguments)}listen(){return this._events.listen.apply(this,arguments)}ignore(){return this._events.ignore.apply(this,arguments)}constructor(){super();arguments[0]&&Array.isArray(arguments[0])?arguments[0].length>0&&this.push.apply(this,arguments[0]):arguments.length>0&&this.push.apply(this,arguments)}pop(){let t=super.pop.apply(this,arguments);return this.trigger(m.Types.remove,[t]),t}shift(){let t=super.shift.apply(this,arguments);return this.trigger(m.Types.remove,[t]),t}push(){let t=super.push.apply(this,arguments);return this.trigger(m.Types.insert,arguments),t}unshift(){let t=super.unshift.apply(this,arguments);return this.trigger(m.Types.insert,arguments),t}splice(){let t=super.splice.apply(this,arguments);if(this.trigger(m.Types.remove,t),arguments.length>2){let e=this.slice(arguments[0],arguments[0]+arguments.length-2);this.trigger(m.Types.insert,e),this.trigger(m.Types.order)}return t}sort(){return super.sort.apply(this,arguments),this.trigger(m.Types.order),this}reverse(){return super.reverse.apply(this,arguments),this.trigger(m.Types.order),this}indexOf(){return super.indexOf.apply(this,arguments)}};var ye=class extends lt{ids={};constructor(t){t=Array.isArray(t)?t:Array.prototype.slice.call(arguments);super(t);this.attach(t),this.on(m.Types.insert,this.attach),this.on(m.Types.remove,this.detach)}attach(t){for(let e=0;e=0&&e.push(r),r.children)for(let n=0;n=0&&this.children.splice(r,1),this.children.push(s)}return this}remove(t){let e=arguments.length,s=this.parent;if(e<=0&&s)return s.remove(this),this;t instanceof Array?t=t.slice():t=Array.prototype.slice.call(arguments);for(let r=0;r=0&&this.children.splice(a,1)}return this}getBoundingClientRect(t){let e,s,r,n,a,o,h,l,f,u;this._update(!0);let _=1/0,d=-1/0,c=1/0,p=-1/0,b=/texture|gradient/i;s=t?this._matrix:pt(this);for(let g=0;go+e?(s.beginning=1,s.ending=1):lo&&ho&&l0&&e(this._children)),this._children=new ye(i),this._children.bind(m.Types.insert,t),this._children.bind(m.Types.remove,e),this._children.bind(m.Types.order,s),i.length>0&&t(i)}},mask:{enumerable:!0,get:function(){return this._mask},set:function(i){this._mask=i,this._flagMask=!0,S.isObject(i)&&!i.clip&&(i.clip=!0)}}};function mi(i,t){let e=i.parent,s;if(e===t){r();return}if(e&&e.children.ids[i.id]&&(s=Array.prototype.indexOf.call(e.children,i),e.children.splice(s,1),n()),t){r();return}n(),e._flagAdditions&&e.additions.length===0&&(e._flagAdditions=!1),e._flagSubtractions&&e.subtractions.length===0&&(e._flagSubtractions=!1),delete i.parent;function r(){t.subtractions.length>0&&(s=Array.prototype.indexOf.call(t.subtractions,i),s>=0&&t.subtractions.splice(s,1)),t.additions.length>0&&(s=Array.prototype.indexOf.call(t.additions,i),s>=0&&t.additions.splice(s,1)),i.parent=t,t.additions.push(i),t._flagAdditions=!0}function n(){s=Array.prototype.indexOf.call(e.additions,i),s>=0&&e.additions.splice(s,1),s=Array.prototype.indexOf.call(e.subtractions,i),s<0&&(e.subtractions.push(i),e._flagSubtractions=!0)}}var yi=new at,De=[],He=Math.max,ls=Math.min,xi=Math.abs,ve=Math.sin,we=Math.cos,hs=Math.acos,ke=Math.sqrt,tt={isHidden:/(undefined|none|transparent)/i,alignments:{left:"start",middle:"center",right:"end"},shim:function(i,t){return i.tagName=i.nodeName=t||"canvas",i.nodeType=1,i.getAttribute=function(e){return this[e]},i.setAttribute=function(e,s){return this[e]=s,this},i},group:{renderChild:function(i){tt[i._renderer.type].render.call(i,this.ctx,!0,this.clip)},render:function(i){if(!this._visible)return this;this._update();let t=this._matrix.elements,e=this.parent;this._renderer.opacity=this._opacity*(e&&e._renderer?e._renderer.opacity:1);let s=this._mask,r=Ae(t),n=!r||!!s;if(this._renderer.context||(this._renderer.context={}),this._renderer.context.ctx=i,n&&(i.save(),r||i.transform(t[0],t[3],t[1],t[4],t[2],t[5])),s&&tt[s._renderer.type].render.call(s,i,!0),this._opacity>0&&this._scale!==0)for(let a=0;a0&&(i.lineDashOffset=rt.offset||0,i.setLineDash(rt)),i.beginPath();let Mt,$t,Zt,Qt,wt,Q,ai;for(let Ct=0;Ct=p&&_&&(x=R,N=y.controls&&y.controls.right||k.zero,z=x.controls&&x.controls.left||k.zero,y._relative?(C=N.x+y.x,j=N.y+y.y):(C=N.x,j=N.y),x._relative?(A=z.x+x.x,E=z.y+x.y):(A=z.x,E=z.y),W=x.x,V=x.y,i.bezierCurveTo(C,j,A,E,W,V));break;case v.line:i.lineTo(W,V);break;case v.move:R=y,i.moveTo(W,V);break}return _&&i.closePath(),!ct&&!e&&(tt.isHidden.test(a)||(ut=a._renderer&&a._renderer.offset,ut&&(i.save(),i.translate(-a._renderer.offset.x,-a._renderer.offset.y),i.scale(a._renderer.scale.x,a._renderer.scale.y)),i.fill(),ut&&i.restore()),tt.isHidden.test(r)||(ut=r._renderer&&r._renderer.offset,ut&&(i.save(),i.translate(-r._renderer.offset.x,-r._renderer.offset.y),i.scale(r._renderer.scale.x,r._renderer.scale.y),i.lineWidth=n/r._renderer.scale.x),i.stroke(),ut&&i.restore())),Z||i.restore(),ct&&!e&&i.clip(),rt&&rt.length>0&&i.setLineDash(De),this.flagReset()}},points:{render:function(i,t,e){let s,r,n,a,o,h,l,f,u,_,d,c,p,b,g,y;if(y=this.parent&&this.parent._renderer?this.parent._renderer.opacity:1,o=this._opacity*(y||1),h=this._visible,!t&&(!h||o===0))return this;this._update(),s=this._matrix.elements,r=this._stroke,n=this._linewidth,a=this._fill,f=this._renderer.collection,u=f.length,p=Ae(s),g=this.dashes,l=this._size,p||(i.save(),i.transform(s[0],s[3],s[1],s[4],s[2],s[5])),a&&(typeof a=="string"?i.fillStyle=a:(tt[a._renderer.type].render.call(a,i,this),i.fillStyle=a._renderer.effect)),r&&(typeof r=="string"?i.strokeStyle=r:(tt[r._renderer.type].render.call(r,i,this),i.strokeStyle=r._renderer.effect),n&&(i.lineWidth=n)),typeof o=="number"&&(i.globalAlpha=o),g&&g.length>0&&(i.lineDashOffset=g.offset||0,i.setLineDash(g)),i.beginPath();let x=l*.5,R;this._sizeAttenuation||(pt(this,yi),R=yi.elements,R=Lt(R[0],R[3],R[1],R[4],R[2],R[5]),x/=Math.max(R.scaleX,R.scaleY));for(let A=0;A0&&i.setLineDash(De),this.flagReset()}},text:{render:function(i,t,e){let s=this.parent&&this.parent._renderer?this.parent._renderer.opacity:1,r=this._opacity*s,n=this._visible,a=this._mask,o=this._clip;if(!t&&(!n||o||r===0))return this;this._update();let h=this._matrix.elements,l=this._stroke,f=this._linewidth,u=this._fill,_=this._decoration,d=Ae(h),c=u._renderer&&u._renderer.offset&&l._renderer&&l._renderer.offset,p=this.dashes,b=tt.alignments[this._alignment]||this._alignment,g=this._baseline,y,x,R,A,E,C,j,M,T,N,z;if(d||(i.save(),i.transform(h[0],h[3],h[1],h[4],h[2],h[5])),a&&tt[a._renderer.type].render.call(a,i,!0),c||(i.font=[this._style,this._weight,this._size+"px/"+this._leading+"px",this._family].join(" ")),i.textAlign=b,i.textBaseline=g,u&&(typeof u=="string"?i.fillStyle=u:(tt[u._renderer.type].render.call(u,i,this),i.fillStyle=u._renderer.effect)),l&&(typeof l=="string"?i.strokeStyle=l:(tt[l._renderer.type].render.call(l,i,this),i.strokeStyle=l._renderer.effect),f&&(i.lineWidth=f)),typeof r=="number"&&(i.globalAlpha=r),p&&p.length>0&&(i.lineDashOffset=p.offset||0,i.setLineDash(p)),!o&&!e&&(tt.isHidden.test(u)||(u._renderer&&u._renderer.offset?(C=u._renderer.scale.x,j=u._renderer.scale.y,i.save(),i.translate(-u._renderer.offset.x,-u._renderer.offset.y),i.scale(C,j),y=this._size/u._renderer.scale.y,x=this._leading/u._renderer.scale.y,i.font=[this._style,this._weight,y+"px/",x+"px",this._family].join(" "),R=u._renderer.offset.x/u._renderer.scale.x,A=u._renderer.offset.y/u._renderer.scale.y,i.fillText(this.value,R,A),i.restore()):i.fillText(this.value,0,0)),tt.isHidden.test(l)||(l._renderer&&l._renderer.offset?(C=l._renderer.scale.x,j=l._renderer.scale.y,i.save(),i.translate(-l._renderer.offset.x,-l._renderer.offset.y),i.scale(C,j),y=this._size/l._renderer.scale.y,x=this._leading/l._renderer.scale.y,i.font=[this._style,this._weight,y+"px/",x+"px",this._family].join(" "),R=l._renderer.offset.x/l._renderer.scale.x,A=l._renderer.offset.y/l._renderer.scale.y,E=f/l._renderer.scale.x,i.lineWidth=E,i.strokeText(this.value,R,A),i.restore()):i.strokeText(this.value,0,0))),/(underline|strikethrough)/i.test(_)){let W=i.measureText(this.value),V=1;switch(_){case"underline":T=W.actualBoundingBoxAscent,z=W.actualBoundingBoxAscent;break;case"strikethrough":T=0,z=0,V=.5;break}switch(g){case"top":T+=this._size*V,z+=this._size*V;break;case"baseline":case"bottom":T-=this._size*V,z-=this._size*V;break}switch(b){case"left":case"start":M=0,N=W.width;break;case"right":case"end":M=-W.width,N=0;break;default:M=-W.width/2,N=W.width/2}i.lineWidth=Math.max(Math.floor(this._size/15),1),i.strokeStyle=i.fillStyle,i.beginPath(),i.moveTo(M,T),i.lineTo(N,z),i.stroke()}return d||i.restore(),o&&!e&&i.clip(),p&&p.length>0&&i.setLineDash(De),this.flagReset()}},"linear-gradient":{render:function(i,t){if(!!t){if(this._update(),!this._renderer.effect||this._flagEndPoints||this._flagStops||this._flagUnits){let e,s=this.left._x,r=this.left._y,n=this.right._x,a=this.right._y;/objectBoundingBox/i.test(this._units)&&(e=t.getBoundingClientRect(!0),s=(s-.5)*e.width,r=(r-.5)*e.height,n=(n-.5)*e.width,a=(a-.5)*e.height),this._renderer.effect=i.createLinearGradient(s,r,n,a);for(let o=0;o1){let V=ke(y);s=V*s,r=V*r,b=s*s,g=r*r}let x=b*p+g*c,R=(b*g-x)/x,A=ke(He(0,R));n===a&&(A=-A);let E=A*s*d/r,C=-A*r*_/s,j=we(o)*E-ve(o)*C+(t+h)/2,M=ve(o)*E+we(o)*C+(e+l)/2,T=bi(1,0,(_-E)/s,(d-C)/r),N=bi((_-E)/s,(d-C)/r,(-_-E)/s,(-d-C)/r)%J,z=T+N;fs(i,j,M,s,r,T,z,a===0,o)}},kt=class extends m{constructor(t){super();let e=t.smoothing!==!1;this.domElement=t.domElement||document.createElement("canvas"),this.ctx=this.domElement.getContext("2d"),this.overdraw=t.overdraw||!1,typeof this.ctx.imageSmoothingEnabled!="undefined"&&(this.ctx.imageSmoothingEnabled=e),this.scene=new G,this.scene.parent=this}setSize(t,e,s){return this.width=t,this.height=e,this.ratio=typeof s=="undefined"?Ht(this.ctx):s,this.domElement.width=t*this.ratio,this.domElement.height=e*this.ratio,this.domElement.style&&S.extend(this.domElement.style,{width:t+"px",height:e+"px"}),this.trigger(m.Types.resize,t,e,s)}render(){let t=this.ratio===1;return t||(this.ctx.save(),this.ctx.scale(this.ratio,this.ratio)),this.overdraw||this.ctx.clearRect(0,0,this.width,this.height),tt.group.render.call(this.scene,this.ctx),t||this.ctx.restore(),this}};w(kt,"Utils",tt);function fs(i,t,e,s,r,n,a,o,h){let l=a-n,f=jt.Tolerance.epsilon,u=Math.abs(l)=s)return s-r>=0;r+=a}return!1}function Xt(i,t){let e=i._length;if(t<=0)return 0;if(t>=e)return i._lengths.length-1;for(let s=0,r=0;s=t)return t-=r,Math.max(s-1,0)+t/i._lengths[s];r+=i._lengths[s]}return-1}function Re(i,t,e){let s,r,n,a,o,h,l,f,u=t.controls&&t.controls.right,_=i.controls&&i.controls.left;return s=t.x,o=t.y,r=(u||t).x,h=(u||t).y,n=(_||i).x,l=(_||i).y,a=i.x,f=i.y,u&&t._relative&&(r+=t.x,h+=t.y),_&&i._relative&&(n+=i.x,l+=i.y),Be(s,o,r,h,n,l,a,f,e)}function Xe(i,t,e){let s,r,n,a,o,h,l,f,u=t.controls&&t.controls.right,_=i.controls&&i.controls.left;return s=t.x,o=t.y,r=(u||t).x,h=(u||t).y,n=(_||i).x,l=(_||i).y,a=i.x,f=i.y,u&&t._relative&&(r+=t.x,h+=t.y),_&&i._relative&&(n+=i.x,l+=i.y),te(s,o,r,h,n,l,a,f,e)}var Tt=class extends Et{_flagOffset=!0;_flagOpacity=!0;_flagColor=!0;_offset=0;_opacity=1;_color="#fff";constructor(t,e,s){super();for(let r in vi)Object.defineProperty(this,r,vi[r]);this._renderer.type="stop",this.offset=typeof t=="number"?t:Tt.Index<=0?0:1,this.opacity=typeof s=="number"?s:1,this.color=typeof e=="string"?e:Tt.Index<=0?"#fff":"#000",Tt.Index=(Tt.Index+1)%2}clone(){let t=new Tt;return S.each(Tt.Properties,function(e){t[e]=this[e]},this),t}toObject(){let t={};return S.each(Tt.Properties,function(e){t[e]=this[e]},this),t}flagReset(){return this._flagOffset=this._flagColor=this._flagOpacity=!1,super.flagReset.call(this),this}},_t=Tt;w(_t,"Index",0),w(_t,"Properties",["offset","opacity","color"]);var vi={offset:{enumerable:!0,get:function(){return this._offset},set:function(i){this._offset=i,this._flagOffset=!0,this.parent&&(this.parent._flagStops=!0)}},opacity:{enumerable:!0,get:function(){return this._opacity},set:function(i){this._opacity=i,this._flagOpacity=!0,this.parent&&(this.parent._flagStops=!0)}},color:{enumerable:!0,get:function(){return this._color},set:function(i){this._color=i,this._flagColor=!0,this.parent&&(this.parent._flagStops=!0)}}};var ee=class extends Et{_flagStops=!1;_flagSpread=!1;_flagUnits=!1;_spread="";_units="";constructor(t){super();for(let e in wi)Object.defineProperty(this,e,wi[e]);this._renderer.type="gradient",this.id=X.Identifier+X.uniqueId(),this.classList=[],this._renderer.flagStops=cs.bind(this),this._renderer.bindStops=us.bind(this),this._renderer.unbindStops=ds.bind(this),this.spread="pad",this.units="objectBoundingBox",t&&(this.stops=t)}clone(t){let e=this.stops.map(function(r){return r.clone()}),s=new ee(e);return S.each(ee.Properties,function(r){s[r]=this[r]},this),t&&t.add(s),s}toObject(){let t={stops:this.stops.map(function(e){return e.toObject()})};return S.each(ee.Properties,function(e){t[e]=this[e]},this),t}_update(){return(this._flagSpread||this._flagStops)&&this.trigger(m.Types.change),this}flagReset(){return this._flagSpread=this._flagUnits=this._flagStops=!1,super.flagReset.call(this),this}},Y=ee;w(Y,"Stop",_t),w(Y,"Properties",["spread","stops","renderer","id","units"]);var wi={spread:{enumerable:!0,get:function(){return this._spread},set:function(i){this._spread=i,this._flagSpread=!0}},units:{enumerable:!0,get:function(){return this._units},set:function(i){this._units=i,this._flagUnits=!0}},stops:{enumerable:!0,get:function(){return this._stops},set:function(i){let t=this._renderer.bindStops,e=this._renderer.unbindStops;this._stops&&this._stops.unbind(m.Types.insert,t).unbind(m.Types.remove,e),this._stops=new lt((i||[]).slice(0)),this._stops.bind(m.Types.insert,t).bind(m.Types.remove,e),t(this._stops)}}};function cs(){this._flagStops=!0}function us(i){let t=i.length;for(;t--;)i[t].bind(m.Types.change,this._renderer.flagStops),i[t].parent=this;this._renderer.flagStops()}function ds(i){let t=i.length;for(;t--;)i[t].unbind(m.Types.change,this._renderer.flagStops),delete i[t].parent;this._renderer.flagStops()}var Ye=class extends Y{_flagEndPoints=!1;_left=null;_right=null;constructor(t,e,s,r,n){super(n);for(let a in ki)Object.defineProperty(this,a,ki[a]);this._renderer.type="linear-gradient",this._renderer.flagEndPoints=_s.bind(this),this.left=new k,this.right=new k,typeof t=="number"&&(this.left.x=t),typeof e=="number"&&(this.left.y=e),typeof s=="number"&&(this.right.x=s),typeof r=="number"&&(this.right.y=r)}clone(t){let e=this.stops.map(function(r){return r.clone()}),s=new Ye(this.left._x,this.left._y,this.right._x,this.right._y,e);return S.each(Y.Properties,function(r){s[r]=this[r]},this),t&&t.add(s),s}toObject(){let t=super.toObject.call(this);return t.left=this.left.toObject(),t.right=this.right.toObject(),t}_update(){return(this._flagEndPoints||this._flagSpread||this._flagStops)&&this.trigger(m.Types.change),this}flagReset(){return this._flagEndPoints=!1,super.flagReset.call(this),this}},U=Ye;w(U,"Properties",["left","right"]),w(U,"Stop",_t);var ki={left:{enumerable:!0,get:function(){return this._left},set:function(i){this._left instanceof k&&this._left.unbind(m.Types.change,this._renderer.flagEndPoints),this._left=i,this._left.bind(m.Types.change,this._renderer.flagEndPoints),this._flagEndPoints=!0}},right:{enumerable:!0,get:function(){return this._right},set:function(i){this._right instanceof k&&this._right.unbind(m.Types.change,this._renderer.flagEndPoints),this._right=i,this._right.bind(m.Types.change,this._renderer.flagEndPoints),this._flagEndPoints=!0}}};function _s(){this._flagEndPoints=!0}var ie=class extends Y{_flagRadius=!1;_flagCenter=!1;_flagFocal=!1;_radius=0;_center=null;_focal=null;constructor(t,e,s,r,n,a){super(r);for(let o in Ai)Object.defineProperty(this,o,Ai[o]);this._renderer.type="radial-gradient",this._renderer.flagCenter=gs.bind(this),this._renderer.flagFocal=ps.bind(this),this.center=new k,this.radius=typeof s=="number"?s:20,this.focal=new k,typeof t=="number"&&(this.center.x=t),typeof e=="number"&&(this.center.y=e),this.focal.copy(this.center),typeof n=="number"&&(this.focal.x=n),typeof a=="number"&&(this.focal.y=a)}clone(t){let e=this.stops.map(function(r){return r.clone()}),s=new ie(this.center._x,this.center._y,this._radius,e,this.focal._x,this.focal._y);return S.each(Y.Properties.concat(ie.Properties),function(r){s[r]=this[r]},this),t&&t.add(s),s}toObject(){let t=super.toObject.call(this);return S.each(ie.Properties,function(e){t[e]=this[e]},this),t.center=this.center.toObject(),t.focal=this.focal.toObject(),t}_update(){return(this._flagRadius||this._flatCenter||this._flagFocal||this._flagSpread||this._flagStops)&&this.trigger(m.Types.change),this}flagReset(){return this._flagRadius=this._flagCenter=this._flagFocal=!1,super.flagReset.call(this),this}},D=ie;w(D,"Stop",_t),w(D,"Properties",["center","radius","focal"]);var Ai={radius:{enumerable:!0,get:function(){return this._radius},set:function(i){this._radius=i,this._flagRadius=!0}},center:{enumerable:!0,get:function(){return this._center},set:function(i){this._center&&this._center.unbind(m.Types.change,this._renderer.flagCenter),this._center=i,this._center.bind(m.Types.change,this._renderer.flagCenter),this._flagCenter=!0}},focal:{enumerable:!0,get:function(){return this._focal},set:function(i){this._focal&&this._focal.unbind(m.Types.change,this._renderer.flagFocal),this._focal=i,this._focal.bind(m.Types.change,this._renderer.flagFocal),this._flagFocal=!0}}};function gs(){this._flagCenter=!0}function ps(){this._flagFocal=!0}var Se,Ri={video:/\.(mp4|webm|ogg)$/i,image:/\.(jpe?g|png|gif|tiff|webp)$/i,effect:/texture|gradient/i};H.document&&(Se=document.createElement("a"));var st=class extends Et{_flagSrc=!1;_flagImage=!1;_flagVideo=!1;_flagLoaded=!1;_flagRepeat=!1;_flagOffset=!1;_flagScale=!1;_src="";_image=null;_loaded=!1;_repeat="no-repeat";_scale=1;_offset=null;constructor(t,e){super();this._renderer={};for(let s in Si)Object.defineProperty(this,s,Si[s]);if(this._renderer.type="texture",this._renderer.flagOffset=ms.bind(this),this._renderer.flagScale=ys.bind(this),this.id=X.Identifier+X.uniqueId(),this.classList=[],this.loaded=!1,this.repeat="no-repeat",this.offset=new k,typeof e=="function"){let s=function(){this.unbind(m.Types.load,s),typeof e=="function"&&e()}.bind(this);this.bind(m.Types.load,s)}if(typeof t=="string")this.src=t;else if(typeof t=="object"){let s=Object.prototype.toString.call(t);(s==="[object HTMLImageElement]"||s==="[object HTMLCanvasElement]"||s==="[object HTMLVideoElement]"||s==="[object Image]")&&(this.image=t)}this._update()}static getAbsoluteURL(t){return Se?(Se.href=t,Se.href):t}static loadHeadlessBuffer(t,e){t.image.onload=e,t.image.src=t.src}static getTag(t){return t&&t.nodeName&&t.nodeName.toLowerCase()||"img"}static getImage(t){let e=st.getAbsoluteURL(t);if(st.ImageRegistry.contains(e))return st.ImageRegistry.get(e);let s;return ht.Image?(s=new ht.Image,kt.Utils.shim(s,"img")):H.document?Ri.video.test(e)?s=document.createElement("video"):s=document.createElement("img"):console.warn("Two.js: no prototypical image defined for Two.Texture"),s.crossOrigin="anonymous",s}static load(t,e){let s=t.image,r=st.getTag(s);t._flagImage&&(/canvas/i.test(r)?st.Register.canvas(t,e):(t._src=!ht.isHeadless&&s.getAttribute("two-src")||s.src,st.Register[r](t,e))),t._flagSrc&&(s||(s=st.getImage(t.src),t.image=s),r=st.getTag(s),st.Register[r](t,e))}clone(){let t=new st(this.src);return t.repeat=this.repeat,t.offset.copy(this.origin),t.scale=this.scale,t}toObject(){return{src:this.src,repeat:this.repeat,origin:this.origin.toObject(),scale:typeof this.scale=="number"?this.scale:this.scale.toObject()}}_update(){return(this._flagSrc||this._flagImage)&&(this.trigger(m.Types.change),(this._flagSrc||this._flagImage)&&(this.loaded=!1,st.load(this,function(){this.loaded=!0,this.trigger(m.Types.change).trigger(m.Types.load)}.bind(this)))),this._image&&this._image.readyState>=4&&(this._flagVideo=!0),this}flagReset(){return this._flagSrc=this._flagImage=this._flagLoaded=this._flagRepeat=this._flagVideo=this._flagScale=this._flagOffset=!1,super.flagReset.call(this),this}},B=st;w(B,"Properties",["id","className","src","loaded","repeat","scale","offset","image"]),w(B,"RegularExpressions",Ri),w(B,"ImageRegistry",new Ft),w(B,"Register",{canvas:function(t,e){t._src="#"+t.id,st.ImageRegistry.add(t.src,t.image),typeof e=="function"&&e()},img:function(t,e){let s=t.image,r=function(a){!ht.isHeadless&&s.removeEventListener&&typeof s.removeEventListener=="function"&&(s.removeEventListener("load",r,!1),s.removeEventListener("error",n,!1)),typeof e=="function"&&e()},n=function(a){throw!ht.isHeadless&&typeof s.removeEventListener=="function"&&(s.removeEventListener("load",r,!1),s.removeEventListener("error",n,!1)),new et("unable to load "+t.src)};typeof s.width=="number"&&s.width>0&&typeof s.height=="number"&&s.height>0?r():!ht.isHeadless&&typeof s.addEventListener=="function"&&(s.addEventListener("load",r,!1),s.addEventListener("error",n,!1)),t._src=st.getAbsoluteURL(t._src),!(!ht.isHeadless&&s&&s.getAttribute("two-src"))&&(ht.isHeadless||s.setAttribute("two-src",t.src),st.ImageRegistry.add(t.src,s),ht.isHeadless?st.loadHeadlessBuffer(t,r):t.image.src=t.src)},video:function(t,e){if(ht.isHeadless)throw new et("video textures are not implemented in headless environments.");let s=function(n){t.image.removeEventListener("canplaythrough",s,!1),t.image.removeEventListener("error",r,!1),t.image.width=t.image.videoWidth,t.image.height=t.image.videoHeight,typeof e=="function"&&e()},r=function(n){throw t.image.removeEventListener("canplaythrough",s,!1),t.image.removeEventListener("error",r,!1),new et("unable to load "+t.src)};t._src=st.getAbsoluteURL(t._src),t.image.getAttribute("two-src")||(t.image.setAttribute("two-src",t.src),st.ImageRegistry.add(t.src,t.image)),t.image.readyState>=4?s():(t.image.addEventListener("canplaythrough",s,!1),t.image.addEventListener("error",r,!1),t.image.src=t.src,t.image.load())}});var Si={src:{enumerable:!0,get:function(){return this._src},set:function(i){this._src=i,this._flagSrc=!0}},loaded:{enumerable:!0,get:function(){return this._loaded},set:function(i){this._loaded=i,this._flagLoaded=!0}},repeat:{enumerable:!0,get:function(){return this._repeat},set:function(i){this._repeat=i,this._flagRepeat=!0}},image:{enumerable:!0,get:function(){return this._image},set:function(i){let t=B.getTag(i),e;switch(t){case"canvas":e="#"+i.id;break;default:e=i.src}B.ImageRegistry.contains(e)?this._image=B.ImageRegistry.get(i.src):this._image=i,this._flagImage=!0}},offset:{enumerable:!0,get:function(){return this._offset},set:function(i){this._offset&&this._offset.unbind(m.Types.change,this._renderer.flagOffset),this._offset=i,this._offset.bind(m.Types.change,this._renderer.flagOffset),this._flagOffset=!0}},scale:{enumerable:!0,get:function(){return this._scale},set:function(i){this._scale instanceof k&&this._scale.unbind(m.Types.change,this._renderer.flagScale),this._scale=i,this._scale instanceof k&&this._scale.bind(m.Types.change,this._renderer.flagScale),this._flagScale=!0}}};function ms(){this._flagOffset=!0}function ys(){this._flagScale=!0}var Pt=Math.min,It=Math.max,xs=Math.ceil,bs=Math.floor,vs=new k,Yt=class extends ot{_flagVertices=!0;_flagLength=!0;_flagFill=!0;_flagStroke=!0;_flagLinewidth=!0;_flagOpacity=!0;_flagVisible=!0;_flagCap=!0;_flagJoin=!0;_flagMiter=!0;_flagMask=!1;_flagClip=!1;_length=0;_fill="#fff";_stroke="#000";_linewidth=1;_opacity=1;_visible=!0;_cap="round";_join="round";_miter=4;_closed=!0;_curved=!1;_automatic=!0;_beginning=0;_ending=1;_mask=null;_clip=!1;_dashes=null;constructor(t,e,s,r){super();for(let n in Ei)Object.defineProperty(this,n,Ei[n]);this._renderer.type="path",this._renderer.flagVertices=Ge.bind(this),this._renderer.bindVertices=qe.bind(this),this._renderer.unbindVertices=Ke.bind(this),this._renderer.flagFill=Je.bind(this),this._renderer.flagStroke=$e.bind(this),this._renderer.vertices=[],this._renderer.collection=[],this._closed=!!e,this._curved=!!s,this.beginning=0,this.ending=1,this.fill="#fff",this.stroke="#000",this.linewidth=1,this.opacity=1,this.className="",this.visible=!0,this.cap="butt",this.join="miter",this.miter=4,this.vertices=t,this.automatic=!r,this.dashes=[],this.dashes.offset=0}clone(t){let e=new Yt;for(let s=0;s=y){this._closed?(s=it(Z,x),r=it(Z-1,x),Z===0&&(s=r,r=Z)):(s=Z,r=Math.min(Math.max(Z-1,0),R)),A=this.vertices[s],E=this.vertices[r],y-=rt,this._lengths[Z]!==0?t=y/this._lengths[Z]:t=0;break}rt+=this._lengths[Z]}if(A===null||E===null)return null;if(A){if(!E)return A}else return E;g=E.controls&&E.controls.right,b=A.controls&&A.controls.left,o=E.x,_=E.y,h=(g||E).x,d=(g||E).y,l=(b||A).x,c=(b||A).y,f=A.x,p=A.y,g&&E.relative&&(h+=E.x,d+=E.y),b&&A.relative&&(l+=A.x,c+=A.y),a=Dt(t,o,h,l,f),u=Dt(t,_,d,c,p);let C=nt(o,h,t),j=nt(_,d,t),M=nt(h,l,t),T=nt(d,c,t),N=nt(l,f,t),z=nt(c,p,t),W=nt(C,M,t),V=nt(j,T,t),ft=nt(M,N,t),ct=nt(T,z,t);return S.isObject(e)?(e.x=a,e.y=u,e instanceof F&&(e.controls.left.x=W,e.controls.left.y=V,e.controls.right.x=ft,e.controls.right.y=ct,(typeof e.relative!="boolean"||e.relative)&&(e.controls.left.x-=a,e.controls.left.y-=u,e.controls.right.x-=a,e.controls.right.y-=u)),e.t=t,e):(n=new F(a,u,W-a,V-u,ft-a,ct-u,this._curved?v.curve:v.line),n.t=t,n)}plot(){if(this.curved)return Ne(this._collection,this.closed),this;for(let t=0;t0&&(n[n.length-1].command=v.line),r=o;return}a=Xe(o,r,t),n=n.concat(a),S.each(a,function(l,f){f<=0&&r.command===v.move?l.command=v.move:l.command=v.line}),h>=e&&(this._closed&&this._automatic?(r=o,a=Xe(o,r,t),n=n.concat(a),S.each(a,function(l,f){f<=0&&r.command===v.move?l.command=v.move:l.command=v.line})):s&&n.push(new F(o.x,o.y)),n[n.length-1].command=s?v.close:v.line),r=o},this),this._automatic=!1,this._curved=!1,this.vertices=n,this}_updateLength(t,e){e||this._update();let s=this.vertices.length,r=s-1,n=!1,a=this.vertices[r],o=0;return typeof this._lengths=="undefined"&&(this._lengths=[]),S.each(this.vertices,function(h,l){if(l<=0&&!n||h.command===v.move){a=h,this._lengths[l]=0;return}this._lengths[l]=Re(h,a,t),o+=this._lengths[l],l>=r&&n&&(a=this.vertices[(l+1)%s],this._lengths[l+1]=Re(h,a,t),o+=this._lengths[l+1]),a=h},this),this._length=o,this._flagLength=!1,this}_update(){if(this._flagVertices){this._automatic&&this.plot(),this._flagLength&&this._updateLength(void 0,!0);let t=this._collection.length,e=this._closed,s=Math.min(this._beginning,this._ending),r=Math.max(this._beginning,this._ending),n=Xt(this,s*this._length),a=Xt(this,r*this._length),o=xs(n),h=bs(a),l,f,u,_,d,c;for(this._renderer.vertices.length=0,c=0;ch&&!f?(d=this._renderer.collection[c].copy(this._collection[c]),this.getPointAt(r,d),d.command=this._renderer.collection[c].command,this._renderer.vertices.push(d),f=d,u=this._collection[c-1],u&&u.controls&&(d.controls.relative?d.controls.right.clear():d.controls.right.copy(d),this._renderer.collection[c-1].controls.right.copy(u).lerp(u.controls.right,d.t))):c>=o&&c<=h&&(d=this._renderer.collection[c].copy(this._collection[c]),this._renderer.vertices.push(d),c===h&&We(this,r)?(f=d,!e&&f.controls&&(f.relative?f.controls.right.clear():f.controls.right.copy(f))):c===o&&We(this,s)&&(l=d,l.command=v.move,!e&&l.controls&&(l.relative?l.controls.left.clear():l.controls.left.copy(l))));o>0&&!l&&(c=o-1,d=this._renderer.collection[c].copy(this._collection[c]),this.getPointAt(s,d),d.command=v.move,this._renderer.vertices.unshift(d),_=this._collection[c+1],_&&_.controls&&(d.controls.left.clear(),_.relative?this._renderer.collection[c+1].controls.left.copy(_.controls.left).lerp(k.zero,d.t):(vs.copy(_),this._renderer.collection[c+1].controls.left.copy(_.controls.left).lerp(_,d.t))))}return ot.prototype._update.apply(this,arguments),this}flagReset(){return this._flagVertices=this._flagLength=this._flagFill=this._flagStroke=this._flagLinewidth=this._flagOpacity=this._flagVisible=this._flagCap=this._flagJoin=this._flagMiter=this._flagClip=!1,ot.prototype.flagReset.call(this),this}},L=Yt;w(L,"Properties",["fill","stroke","linewidth","opacity","visible","cap","join","miter","closed","curved","automatic","beginning","ending"]),w(L,"Utils",{getCurveLength:Re});var Ei={linewidth:{enumerable:!0,get:function(){return this._linewidth},set:function(i){this._linewidth=i,this._flagLinewidth=!0}},opacity:{enumerable:!0,get:function(){return this._opacity},set:function(i){this._opacity=i,this._flagOpacity=!0}},visible:{enumerable:!0,get:function(){return this._visible},set:function(i){this._visible=i,this._flagVisible=!0}},cap:{enumerable:!0,get:function(){return this._cap},set:function(i){this._cap=i,this._flagCap=!0}},join:{enumerable:!0,get:function(){return this._join},set:function(i){this._join=i,this._flagJoin=!0}},miter:{enumerable:!0,get:function(){return this._miter},set:function(i){this._miter=i,this._flagMiter=!0}},fill:{enumerable:!0,get:function(){return this._fill},set:function(i){(this._fill instanceof Y||this._fill instanceof U||this._fill instanceof D||this._fill instanceof B)&&this._fill.unbind(m.Types.change,this._renderer.flagFill),this._fill=i,this._flagFill=!0,(this._fill instanceof Y||this._fill instanceof U||this._fill instanceof D||this._fill instanceof B)&&this._fill.bind(m.Types.change,this._renderer.flagFill)}},stroke:{enumerable:!0,get:function(){return this._stroke},set:function(i){(this._stroke instanceof Y||this._stroke instanceof U||this._stroke instanceof D||this._stroke instanceof B)&&this._stroke.unbind(m.Types.change,this._renderer.flagStroke),this._stroke=i,this._flagStroke=!0,(this._stroke instanceof Y||this._stroke instanceof U||this._stroke instanceof D||this._stroke instanceof B)&&this._stroke.bind(m.Types.change,this._renderer.flagStroke)}},length:{get:function(){return this._flagLength&&this._updateLength(),this._length}},closed:{enumerable:!0,get:function(){return this._closed},set:function(i){this._closed=!!i,this._flagVertices=!0}},curved:{enumerable:!0,get:function(){return this._curved},set:function(i){this._curved=!!i,this._flagVertices=!0}},automatic:{enumerable:!0,get:function(){return this._automatic},set:function(i){if(i===this._automatic)return;this._automatic=!!i;let t=this._automatic?"ignore":"listen";S.each(this.vertices,function(e){e[t]()})}},beginning:{enumerable:!0,get:function(){return this._beginning},set:function(i){this._beginning=i,this._flagVertices=!0}},ending:{enumerable:!0,get:function(){return this._ending},set:function(i){this._ending=i,this._flagVertices=!0}},vertices:{enumerable:!0,get:function(){return this._collection},set:function(i){let t=this._renderer.bindVertices,e=this._renderer.unbindVertices;this._collection&&this._collection.unbind(m.Types.insert,t).unbind(m.Types.remove,e),i instanceof lt?this._collection=i:this._collection=new lt(i||[]),this._collection.bind(m.Types.insert,t).bind(m.Types.remove,e),t(this._collection)}},mask:{enumerable:!0,get:function(){return this._mask},set:function(i){this._mask=i,this._flagMask=!0,S.isObject(i)&&!i.clip&&(i.clip=!0)}},clip:{enumerable:!0,get:function(){return this._clip},set:function(i){this._clip=i,this._flagClip=!0}},dashes:{enumerable:!0,get:function(){return this._dashes},set:function(i){typeof i.offset!="number"&&(i.offset=this.dashes&&this._dashes.offset||0),this._dashes=i}}};function Ge(){this._flagVertices=!0,this._flagLength=!0,this.parent&&(this.parent._flagLength=!0)}function qe(i){let t=i.length;for(;t--;)i[t].bind(m.Types.change,this._renderer.flagVertices);this._renderer.flagVertices()}function Ke(i){let t=i.length;for(;t--;)i[t].unbind(m.Types.change,this._renderer.flagVertices);this._renderer.flagVertices()}function Je(){this._flagFill=!0}function $e(){this._flagStroke=!0}var Ze=class extends L{constructor(t,e,s,r){let n=[new F,new F,new F,new F];super(n,!0,!1,!0);for(let a in Fi)Object.defineProperty(this,a,Fi[a]);this.width=s,this.height=r,this.origin=new k,this.translation.set(t,e),this._update()}_flagWidth=0;_flagHeight=0;_width=0;_height=0;_origin=null;_update(){if(this._flagVertices||this._flagWidth||this._flagHeight){let t=this._width/2,e=this._height/2;!this._closed&&this.vertices.length===4&&this.vertices.push(new F),this.vertices[0].set(-t,-e).sub(this._origin).command=v.move,this.vertices[1].set(t,-e).sub(this._origin).command=v.line,this.vertices[2].set(t,e).sub(this._origin).command=v.line,this.vertices[3].set(-t,e).sub(this._origin).command=v.line,this.vertices[4]&&(this.vertices[4].set(-t,-e).sub(this._origin).command=v.line)}return super._update.call(this),this}flagReset(){return this._flagWidth=this._flagHeight=!1,super.flagReset.call(this),this}clone(t){let e=new Ze(0,0,this.width,this.height);e.translation.copy(this.translation),e.rotation=this.rotation,e.scale=this.scale,e.skewX=this.skewX,e.skewY=this.skewY,this.matrix.manual&&e.matrix.copy(this.matrix);for(let s=0;s0&&(S.isNaN(this._lastFrame)&&(this._lastFrame=o-1),a=S.performance.now()-this._startTime,_=this._lastFrame+1,h=1e3*(_-this._firstFrame)/this._frameRate,this._loop?a=a%h:a=Math.min(a,h),l=nt(this._firstFrame,_,a/h),l=Math.floor(l),l!==this._index&&(this._index=l,l>=this._lastFrame-1&&this._onLastFrame&&this._onLastFrame()));let d=this._index%e,c=Math.floor(this._index/e),p=-r*d+(f-r)/2,b=-n*c+(u-n)/2;p!==t.offset.x&&(t.offset.x=p),b!==t.offset.y&&(t.offset.y=b)}return super._update.call(this),this}flagReset(){return this._flagTexture=this._flagColumns=this._flagRows=this._flagFrameRate=!1,super.flagReset.call(this),this}},Nt=Qe;w(Nt,"Properties",["texture","columns","rows","frameRate","index"]);var Ti={texture:{enumerable:!0,get:function(){return this._texture},set:function(i){this._texture=i,this._flagTexture=!0}},columns:{enumerable:!0,get:function(){return this._columns},set:function(i){this._columns=i,this._flagColumns=!0}},rows:{enumerable:!0,get:function(){return this._rows},set:function(i){this._rows=i,this._flagRows=!0}},frameRate:{enumerable:!0,get:function(){return this._frameRate},set:function(i){this._frameRate=i,this._flagFrameRate=!0}},index:{enumerable:!0,get:function(){return this._index},set:function(i){this._index=i,this._flagIndex=!0}}};var ti=Math.cos,ei=Math.sin,se=class extends L{_flagRadius=!1;_radius=0;constructor(t,e,s,r){let n=r?Math.max(r,2):4,a=[];for(let o=0;o2&&(t-=1);let e=4/3*Math.tan(Math.PI/(t*2)),s=this._radius,r=s*e;for(let n=0;n2&&(t-=1);let e=4/3*Math.tan(Math.PI/(this.vertices.length*2)),s=this._width/2,r=this._height/2;for(let n=0;n=0&&t.splice(r,1)}return t}function Ls(i,t){let e=t.split(/[\s,]/),s=-parseFloat(e[0]),r=-parseFloat(e[1]),n=parseFloat(e[2]),a=parseFloat(e[3]);if(s&&r)for(let u=0;u0?i.gradientTransform.baseVal[0].matrix:i.getCTM?i.getCTM():null,o===null))break;switch(_=Lt(o),t._renderer.type){case"linear-gradient":Ni(_,t.left),Ni(_,t.right);break;case"radial-gradient":t.center.x+=_.translateX,t.center.y+=_.translateY,t.focal.x+=_.translateX,t.focal.y+=_.translateY,t.radius*=Math.max(_.scaleX,_.scaleY);break}break;case"transform":if(/none/i.test(l)||(o=i.transform&&i.transform.baseVal&&i.transform.baseVal.length>0?i.transform.baseVal[0].matrix:i.getCTM?i.getCTM():null,o===null))break;X.AutoCalculateImportedMatrices?(_=Lt(o),t.translation.set(_.translateX,_.translateY),t.rotation=Math.PI*(_.rotation/180),t.scale=new k(_.scaleX,_.scaleY),d=parseFloat((s.x+"").replace("px")),c=parseFloat((s.y+"").replace("px")),d&&(t.translation.x=d),c&&(t.translation.y=c)):(o=i.getCTM(),t._matrix.manual=!0,t._matrix.set(o.a,o.b,o.c,o.d,o.e,o.f));break;case"visible":if(t instanceof G){t._visible=l;break}t.visible=l;break;case"stroke-linecap":if(t instanceof G){t._cap=l;break}t.cap=l;break;case"stroke-linejoin":if(t instanceof G){t._join=l;break}t.join=l;break;case"stroke-miterlimit":if(t instanceof G){t._miter=l;break}t.miter=l;break;case"stroke-width":if(t instanceof G){t._linewidth=parseFloat(l);break}t.linewidth=parseFloat(l);break;case"opacity":case"stroke-opacity":case"fill-opacity":if(t instanceof G){t._opacity=parseFloat(l);break}t.opacity=parseFloat(l);break;case"clip-path":if(Rt.cssBackgroundImage.test(l)&&(p=l.replace(Rt.cssBackgroundImage,"$1"),q.defs.current&&q.defs.current.contains(p)&&(g=q.defs.current.get(p),g&&g.childNodes.length>0)))switch(g=g.childNodes[0],y=ae(g.nodeName),t.mask=q[y].call(this,g,{}),t._renderer.type){case"text":case"path":t.position.add(t.mask.position),t.mask.position.clear();break}break;case"fill":case"stroke":f=(t instanceof G?"_":"")+h,Rt.cssBackgroundImage.test(l)?(p=l.replace(Rt.cssBackgroundImage,"$1"),q.defs.current&&q.defs.current.contains(p)?(g=q.defs.current.get(p),g.object||(y=ae(g.nodeName),g.object=q[y].call(this,g,{})),g=g.object):(b=Ps(this),g=b.getById(p)),t[f]=g):t[f]=/none/i.test(l)?"transparent":l;break;case"id":t.id=l;break;case"class":case"className":t.classList=l.split(" "),t._flagClassName=!0;break;case"x":case"y":if(x=t instanceof Y,R=t instanceof U,A=t instanceof D,x||R||A)break;l.match("[a-z%]$")&&!l.endsWith("px")&&(E=new et("only pixel values are supported with the "+h+" attribute."),console.warn(E.name,E.message)),t.translation[h]=parseFloat(l);break;case"font-family":t instanceof gt&&(t.family=l);break;case"font-size":t instanceof gt&&(t.size=l);break;case"font-weight":t instanceof gt&&(t.weight=l);break;case"font-style":t instanceof gt&&(t.style=l);break;case"text-decoration":t instanceof gt&&(t.decoration=l);break;case"line-height":t instanceof gt&&(t.leading=l);break}return Object.keys(i.dataset).length&&(t.dataset=i.dataset),s}function Os(i,t){for(let e=0,s=i.childNodes.length;e with no href."),console.warn(e.name,e.message),null;let r=s.slice(1);if(!q.defs.current.contains(r))return e=new et("unable to find element for reference "+s+"."),console.warn(e.name,e.message),null;let a=q.defs.current.get(r).cloneNode(!0);for(let h=0;h1&&(g=1);break;case"m":case"l":case"t":c.length>2&&(g=2);break;case"s":case"q":c.length>4&&(g=4);break;case"c":c.length>6&&(g=6);break;case"a":c.length>7&&(g=7);break}if(g){for(y=0,x=c.length,A=0;y0)switch(p){case"m":R="l";break;case"M":R="L";break}E.push(R+c.slice(y,y+g).join(" ")),A++}f=Array.prototype.concat.apply(f,E)}else f.push(_)}),S.each(f,function(_,d){let c,p,b,g=_[0],y=g.toLowerCase();l=_.slice(1).trim().match(Rt.path),n=g===y;let x,R,A,E,C,j,M,T,N,z,W,V,ft,ct,Z,ut,rt;switch(y){case"z":if(d>=u)r=!0;else{p=o.x,b=o.y,c=new F(p,b,void 0,void 0,void 0,void 0,v.close);for(let St=s.length-1;St>=0;St--){let Mt=s[St];if(/m/i.test(Mt.command)){o=Mt;break}}}break;case"m":case"l":h=void 0,p=parseFloat(l[0]),b=parseFloat(l[1]),c=new F(p,b,void 0,void 0,void 0,void 0,/m/i.test(y)?v.move:v.line),n&&c.addSelf(o),o=c;break;case"h":case"v":z=/h/i.test(y)?"x":"y",W=/x/i.test(z)?"y":"x",c=new F(void 0,void 0,void 0,void 0,void 0,void 0,v.line),c[z]=parseFloat(l[0]),c[W]=o[W],n&&(c[z]+=o[z]),o=c;break;case"c":case"s":x=o.x,R=o.y,h||(h=new k),/c/i.test(y)?(A=parseFloat(l[0]),E=parseFloat(l[1]),C=parseFloat(l[2]),j=parseFloat(l[3]),M=parseFloat(l[4]),T=parseFloat(l[5])):(N=pe(o,h,n),A=N.x,E=N.y,C=parseFloat(l[0]),j=parseFloat(l[1]),M=parseFloat(l[2]),T=parseFloat(l[3])),n&&(A+=x,E+=R,C+=x,j+=R,M+=x,T+=R),o.controls.right.set(A-o.x,E-o.y),c=new F(M,T,C-M,j-T,void 0,void 0,v.curve),o=c,h=c.controls.left;break;case"t":case"q":x=o.x,R=o.y,h||(h=new k),/q/i.test(y)?(A=parseFloat(l[0]),E=parseFloat(l[1]),C=parseFloat(l[0]),j=parseFloat(l[1]),M=parseFloat(l[2]),T=parseFloat(l[3])):(N=pe(o,h,n),A=N.x,E=N.y,C=N.x,j=N.y,M=parseFloat(l[0]),T=parseFloat(l[1])),n&&(A+=x,E+=R,C+=x,j+=R,M+=x,T+=R),o.controls.right.set((A-o.x)*.33,(E-o.y)*.33),c=new F(M,T,C-M,j-T,void 0,void 0,v.curve),o=c,h=c.controls.left;break;case"a":x=o.x,R=o.y,ft=parseFloat(l[0]),ct=parseFloat(l[1]),Z=parseFloat(l[2]),ut=parseFloat(l[3]),rt=parseFloat(l[4]),M=parseFloat(l[5]),T=parseFloat(l[6]),n&&(M+=x,T+=R),V=new F(M,T),V.command=v.arc,V.rx=ft,V.ry=ct,V.xAxisRotation=Z,V.largeArcFlag=ut,V.sweepFlag=rt,c=V,o=V,h=void 0;break}c&&(Array.isArray(c)?s=s.concat(c):s.push(c))})}e=new L(s,r,void 0,!0).noStroke(),e.fill="black";let a=e.getBoundingClientRect(!0);return a.centroid={x:a.left+a.width/2,y:a.top+a.height/2},S.each(e.vertices,function(o){o.subSelf(a.centroid)}),vt.call(this,i,e,t),e.translation.addSelf(a.centroid),e},circle:function(i,t){let e=parseFloat(i.getAttribute("cx")),s=parseFloat(i.getAttribute("cy")),r=parseFloat(i.getAttribute("r")),n=new Vt(0,0,r).noStroke();return n.fill="black",vt.call(this,i,n,t),n.translation.x=e,n.translation.y=s,n},ellipse:function(i,t){let e=parseFloat(i.getAttribute("cx")),s=parseFloat(i.getAttribute("cy")),r=parseFloat(i.getAttribute("rx")),n=parseFloat(i.getAttribute("ry")),a=new zt(0,0,r,n).noStroke();return a.fill="black",vt.call(this,i,a,t),a.translation.x=e,a.translation.y=s,a},rect:function(i,t){let e=parseFloat(i.getAttribute("rx")),s=parseFloat(i.getAttribute("ry"));if(!S.isNaN(e)||!S.isNaN(s))return q["rounded-rect"](i);let r=parseFloat(i.getAttribute("width")),n=parseFloat(i.getAttribute("height")),a=r/2,o=n/2,h=new bt(0,0,r,n).noStroke();return h.fill="black",vt.call(this,i,h,t),h.translation.x+=a,h.translation.y+=o,h},"rounded-rect":function(i,t){let e=parseFloat(i.getAttribute("rx"))||0,s=parseFloat(i.getAttribute("ry"))||0,r=parseFloat(i.getAttribute("width")),n=parseFloat(i.getAttribute("height")),a=r/2,o=n/2,h=new k(e,s),l=new Ut(0,0,r,n,h).noStroke();return l.fill="black",vt.call(this,i,l,t),l.translation.x+=a,l.translation.y+=o,l},line:function(i,t){let e=parseFloat(i.getAttribute("x1")),s=parseFloat(i.getAttribute("y1")),r=parseFloat(i.getAttribute("x2")),n=parseFloat(i.getAttribute("y2")),a=new Gt(e,s,r,n).noFill();return vt.call(this,i,a,t),a},lineargradient:function(i,t){let e=i.getAttribute("gradientUnits"),s=i.getAttribute("spreadMethod");e||(e="objectBoundingBox"),s||(s="pad");let r=parseFloat(i.getAttribute("x1")||0),n=parseFloat(i.getAttribute("y1")||0),a=parseFloat(i.getAttribute("x2")||0),o=parseFloat(i.getAttribute("y2")||0),h=(a+r)/2,l=(o+n)/2;/userSpaceOnUse/i.test(e)&&(r-=h,n-=l,a-=h,o-=l);let f=[];for(let _=0;_1?y[1]:void 0),b===null?(y=g?g.match(/stop-opacity:\s?([0-9.-]*)/):!1,b=y&&y.length>1?parseFloat(y[1]):1):b=parseFloat(b),f.push(new _t(c,p,b))}let u=new U(r,n,a,o,f);return u.spread=s,u.units=e,vt.call(this,i,u,t),u},radialgradient:function(i,t){let e=i.getAttribute("gradientUnits"),s=i.getAttribute("spreadMethod");e||(e="objectBoundingBox"),s||(s="pad");let r=parseFloat(i.getAttribute("cx"))||0,n=parseFloat(i.getAttribute("cy"))||0,a=parseFloat(i.getAttribute("r")),o=parseFloat(i.getAttribute("fx")),h=parseFloat(i.getAttribute("fy"));S.isNaN(o)&&(o=r),S.isNaN(h)&&(h=n);let l=Math.abs(r+o)/2,f=Math.abs(n+h)/2;/userSpaceOnUse/i.test(e)&&(r-=l,n-=f,o-=l,h-=f);let u=[];for(let d=0;d1?x[1]:void 0),g===null?(x=y?y.match(/stop-opacity:\s?([0-9.-]*)/):!1,g=x&&x.length>1?parseFloat(x[1]):1):g=parseFloat(g),u.push(new _t(p,b,g))}let _=new D(r,n,a,u,o,h);return _.spread=s,_.units=e,vt.call(this,i,_,t),_},text:function(i,t){let e=Es(i.getAttribute("text-anchor"))||"left",s=Fs(i)||"baseline",r=i.textContent,n=new gt(r);return vt.call(this,i,n,t),n.alignment=e,n.baseline=s,n},clippath:function(i,t){return q.defs.current&&!q.defs.current.contains(i.id)&&q.defs.current.add(i.id,i),null},image:function(i,t){let e,s=i.getAttribute("href")||i.getAttribute("xlink:href");if(!s)return e=new et("encountered with no href."),console.warn(e.name,e.message),null;let r=parseFloat(i.getAttribute("x"))||0,n=parseFloat(i.getAttribute("y"))||0,a=parseFloat(i.getAttribute("width")),o=parseFloat(i.getAttribute("height")),h=new Nt(s,r,n);return S.isNaN(a)||(h.width=a),S.isNaN(o)||(h.height=o),vt.call(this,i,h,t),h}};function ri(i,t){let e=new XMLHttpRequest;return e.open("GET",i),e.onreadystatechange=function(){e.readyState===4&&e.status===200&&t(e.responseText)},e.send(),e}var Ee=class extends bt{_flagTextures=!1;_flagFrameRate=!1;_flagIndex=!1;_amount=1;_duration=0;_index=0;_startTime=0;_playing=!1;_firstFrame=0;_lastFrame=0;_loop=!0;_textures=null;_frameRate=0;_origin=null;constructor(t,e,s,r){super(e,s,0,0);for(let n in Vi)Object.defineProperty(this,n,Vi[n]);this._renderer.flagTextures=Is.bind(this),this._renderer.bindTextures=Bs.bind(this),this._renderer.unbindTextures=js.bind(this),this.noStroke(),this.noFill(),Array.isArray(t)?this.textures=t.map(zi.bind(this)):this.textures=[zi(t)],this.origin=new k,this._update(),typeof r=="number"?this.frameRate=r:this.frameRate=Ee.DefaultFrameRate,this.index=0}play(t,e,s){return this._playing=!0,this._firstFrame=0,this._lastFrame=this.amount-1,this._startTime=S.performance.now(),typeof t=="number"&&(this._firstFrame=t),typeof e=="number"&&(this._lastFrame=e),typeof s=="function"?this._onLastFrame=s:delete this._onLastFrame,this._index!==this._firstFrame&&(this._startTime-=1e3*Math.abs(this._index-this._firstFrame)/this._frameRate),this}pause(){return this._playing=!1,this}stop(){return this._playing=!1,this._index=this._firstFrame,this}clone(t){let e=new Ee(this.textures,this.translation.x,this.translation.y,this.frameRate);return e._loop=this._loop,this._playing&&e.play(),t&&t.add(e),e}toObject(){let t=super.toObject.call(this);return t.textures=this.textures.map(function(e){return e.toObject()}),t.frameRate=this.frameRate,t.index=this.index,t._firstFrame=this._firstFrame,t._lastFrame=this._lastFrame,t._loop=this._loop,t}_update(){let t=this._textures,e,s,r,n,a,o,h,l;return t&&(this._flagTextures&&(this._amount=t.length),this._flagFrameRate&&(this._duration=1e3*this._amount/this._frameRate),this._playing&&this._frameRate>0?(n=this._amount,S.isNaN(this._lastFrame)&&(this._lastFrame=n-1),r=S.performance.now()-this._startTime,l=this._lastFrame+1,a=1e3*(l-this._firstFrame)/this._frameRate,this._loop?r=r%a:r=Math.min(r,a),h=nt(this._firstFrame,l,r/a),h=Math.floor(h),h!==this._index&&(this._index=h,o=t[this._index],o.loaded&&(e=o.image.width,s=o.image.height,this.width!==e&&(this.width=e),this.height!==s&&(this.height=s),this.fill=o,h>=this._lastFrame-1&&this._onLastFrame&&this._onLastFrame()))):(this._flagIndex||!(this.fill instanceof B))&&(o=t[this._index],o.loaded&&(e=o.image.width,s=o.image.height,this.width!==e&&(this.width=e),this.height!==s&&(this.height=s)),this.fill=o)),super._update.call(this),this}flagReset(){return this._flagTextures=this._flagFrameRate=!1,super.flagReset.call(this),this}},qt=Ee;w(qt,"Properties",["textures","frameRate","index"]),w(qt,"DefaultFrameRate",30);var Vi={frameRate:{enumerable:!0,get:function(){return this._frameRate},set:function(i){this._frameRate=i,this._flagFrameRate=!0}},index:{enumerable:!0,get:function(){return this._index},set:function(i){this._index=i,this._flagIndex=!0}},textures:{enumerable:!0,get:function(){return this._textures},set:function(i){let t=this._renderer.bindTextures,e=this._renderer.unbindTextures;this._textures&&this._textures.unbind(m.Types.insert,t).unbind(m.Types.remove,e),this._textures=new lt((i||[]).slice(0)),this._textures.bind(m.Types.insert,t).bind(m.Types.remove,e),t(this._textures)}}};function Is(){this._flagTextures=!0}function Bs(i){let t=i.length;for(;t--;)i[t].bind(m.Types.change,this._renderer.flagTextures);this._renderer.flagTextures()}function js(i){let t=i.length;for(;t--;)i[t].unbind(m.Types.change,this._renderer.flagTextures);this._renderer.flagTextures()}function zi(i){if(i instanceof B)return i;if(typeof i=="string")return new B(i)}var le=class extends L{_flagStartAngle=!1;_flagEndAngle=!1;_flagInnerRadius=!1;_flagOuterRadius=!1;_startAngle=0;_endAngle=J;_innerRadius=0;_outerRadius=0;constructor(t,e,s,r,n,a,o){let h=o||X.Resolution*3,l=[];for(let f=0;f0,o=this.vertices,h=a?o.length/2:o.length,l,f=0,u,_,d,c,p,b,g,y,x;for(n?h--:a||(h-=2),u=0,_=h-1;u=n&&l<=a&&(h=this._collection[l],this._renderer.collection.push(h),this._renderer.vertices[o*2+0]=h.x,this._renderer.vertices[o*2+1]=h.y,o++)}return super._update.apply(this,arguments),this}flagReset(){return this._flagVertices=this._flagLength=this._flagFill=this._flagStroke=this._flagLinewidth=this._flagOpacity=this._flagVisible=this._flagSize=this._flagSizeAttenuation=!1,super.flagReset.call(this),this}},he=Kt;w(he,"Properties",["fill","stroke","linewidth","opacity","visible","size","sizeAttenuation","beginning","ending"]);var Di={linewidth:{enumerable:!0,get:function(){return this._linewidth},set:function(i){this._linewidth=i,this._flagLinewidth=!0}},opacity:{enumerable:!0,get:function(){return this._opacity},set:function(i){this._opacity=i,this._flagOpacity=!0}},visible:{enumerable:!0,get:function(){return this._visible},set:function(i){this._visible=i,this._flagVisible=!0}},size:{enumerable:!0,get:function(){return this._size},set:function(i){this._size=i,this._flagSize=!0}},sizeAttenuation:{enumerable:!0,get:function(){return this._sizeAttenuation},set:function(i){this._sizeAttenuation=i,this._flagSizeAttenuation=!0}},fill:{enumerable:!0,get:function(){return this._fill},set:function(i){(this._fill instanceof Y||this._fill instanceof U||this._fill instanceof D||this._fill instanceof B)&&this._fill.unbind(m.Types.change,this._renderer.flagFill),this._fill=i,this._flagFill=!0,(this._fill instanceof Y||this._fill instanceof U||this._fill instanceof D||this._fill instanceof B)&&this._fill.bind(m.Types.change,this._renderer.flagFill)}},stroke:{enumerable:!0,get:function(){return this._stroke},set:function(i){(this._stroke instanceof Y||this._stroke instanceof U||this._stroke instanceof D||this._stroke instanceof B)&&this._stroke.unbind(m.Types.change,this._renderer.flagStroke),this._stroke=i,this._flagStroke=!0,(this._stroke instanceof Y||this._stroke instanceof U||this._stroke instanceof D||this._stroke instanceof B)&&this._stroke.bind(m.Types.change,this._renderer.flagStroke)}},length:{get:function(){return this._flagLength&&this._updateLength(),this._length}},beginning:{enumerable:!0,get:function(){return this._beginning},set:function(i){this._beginning=i,this._flagVertices=!0}},ending:{enumerable:!0,get:function(){return this._ending},set:function(i){this._ending=i,this._flagVertices=!0}},vertices:{enumerable:!0,get:function(){return this._collection},set:function(i){let t=this._renderer.bindVertices,e=this._renderer.unbindVertices;this._collection&&this._collection.unbind(m.Types.insert,t).unbind(m.Types.remove,e),i instanceof lt?this._collection=i:this._collection=new lt(i||[]),this._collection.bind(m.Types.insert,t).bind(m.Types.remove,e),t(this._collection)}},dashes:{enumerable:!0,get:function(){return this._dashes},set:function(i){typeof i.offset!="number"&&(i.offset=this.dashes&&this._dashes.offset||0),this._dashes=i}}};var zs=Math.cos,Us=Math.sin,ce=class extends L{_flagWidth=!1;_flagHeight=!1;_flagSides=!1;_width=0;_height=0;_sides=0;constructor(t,e,s,r){r=Math.max(r||0,3);super();for(let n in Hi)Object.defineProperty(this,n,Hi[n]);this.closed=!0,this.automatic=!1,typeof s=="number"&&(this.width=s*2),typeof s=="number"&&(this.height=s*2),typeof r=="number"&&(this.sides=r),this._update(),typeof t=="number"&&(this.translation.x=t),typeof e=="number"&&(this.translation.y=e)}_update(){if(this._flagVertices||this._flagWidth||this._flagHeight||this._flagSides){let t=this._sides,e=t+1,s=this.vertices.length;s>t&&(this.vertices.splice(t-1,s-t),s=t);for(let r=0;r=s?this.vertices.push(new F(o,h)):this.vertices[r].set(o,h),this.vertices[r].command=r===0?v.move:v.line}}return super._update.call(this),this}flagReset(){return this._flagWidth=this._flagHeight=this._flagSides=!1,super.flagReset.call(this),this}clone(t){let e=new ce(0,0,this.radius,this.sides);e.translation.copy(this.translation),e.rotation=this.rotation,e.scale=this.scale,e.skewX=this.skewX,e.skewY=this.skewY,this.matrix.manual&&e.matrix.copy(this.matrix);for(let s=0;st&&(this.vertices.splice(t-1,s-t),s=t);for(let r=0;r=s?this.vertices.push(new F(h,l)):this.vertices[r].set(h,l),this.vertices[r].command=r===0?v.move:v.line}}return super._update.call(this),this}flagReset(){return this._flagInnerRadius=this._flagOuterRadius=this._flagSides=!1,super.flagReset.call(this),this}clone(t){let e=this.innerRadius,s=this.outerRadius,r=this.sides,n=new de(0,0,e,s,r);n.translation.copy(this.translation),n.rotation=this.rotation,n.scale=this.scale,n.skewX=this.skewX,n.skewY=this.skewY,this.matrix.manual&&n.matrix.copy(this.matrix);for(let a=0;a0&&O.setAttributes(s,t),s},setAttributes:function(i,t){let e=Object.keys(t);for(let s=0;s=s&&t&&(o.command===v.curve&&(u=r,y=o.controls&&o.controls.right||o,x=u.controls&&u.controls.left||u,o.relative?(_=K(y.x+o.x),d=K(y.y+o.y)):(_=K(y.x),d=K(y.y)),u.relative?(c=K(x.x+u.x),p=K(x.y+u.y)):(c=K(x.x),p=K(x.y)),M=K(u.x),T=K(u.y),f+=" C "+_+" "+d+" "+c+" "+p+" "+M+" "+T),o.command!==v.close&&(f+=" Z")),n+=f+" "}return n},pointsToString:function(i,t){let e="",s=t*.5;for(let r=0;r0&&(t["stroke-dasharray"]=this.dashes.join(" "),t["stroke-dashoffset"]=this.dashes.offset||0),this._renderer.elem?O.setAttributes(this._renderer.elem,t):(t.id=this._id,this._renderer.elem=O.createElement("path",t),i.appendChild(this._renderer.elem)),this._flagClip){let s=O.getClip(this,i),r=this._renderer.elem;this._clip?(r.removeAttribute("id"),s.setAttribute("id",this.id),s.appendChild(r)):(s.removeAttribute("id"),r.setAttribute("id",this.id),this.parent._renderer.elem.appendChild(r))}return this._flagMask&&(this._mask?(O[this._mask._renderer.type].render.call(this._mask,i),this._renderer.elem.setAttribute("clip-path","url(#"+this._mask.id+")")):this._renderer.elem.removeAttribute("clip-path")),this.flagReset()}},points:{render:function(i){if(this._opacity===0&&!this._flagOpacity)return this;this._update();let t={};if((this._matrix.manual||this._flagMatrix)&&(t.transform="matrix("+this._matrix.toString()+")"),this._flagId&&(t.id=this._id),this._flagVertices||this._flagSize||this._flagSizeAttenuation){let s=this._size;if(!this._sizeAttenuation){pt(this,Xi);let n=Xi.elements,a=Lt(n[0],n[3],n[1],n[4],n[2],n[5]);s/=Math.max(a.scaleX,a.scaleY)}let r=O.pointsToString(this._renderer.collection,s);t.d=r}return this._fill&&this._fill._renderer&&(this._fill._update(),O[this._fill._renderer.type].render.call(this._fill,i,!0)),this._flagFill&&(t.fill=this._fill&&this._fill.id?"url(#"+this._fill.id+")":this._fill),this._stroke&&this._stroke._renderer&&(this._stroke._update(),O[this._stroke._renderer.type].render.call(this._stroke,i,!0)),this._flagStroke&&(t.stroke=this._stroke&&this._stroke.id?"url(#"+this._stroke.id+")":this._stroke),this._flagLinewidth&&(t["stroke-width"]=this._linewidth),this._flagOpacity&&(t["stroke-opacity"]=this._opacity,t["fill-opacity"]=this._opacity),this._flagClassName&&(t.class=this.classList.join(" ")),this._flagVisible&&(t.visibility=this._visible?"visible":"hidden"),this.dashes&&this.dashes.length>0&&(t["stroke-dasharray"]=this.dashes.join(" "),t["stroke-dashoffset"]=this.dashes.offset||0),this._renderer.elem?O.setAttributes(this._renderer.elem,t):(t.id=this._id,this._renderer.elem=O.createElement("path",t),i.appendChild(this._renderer.elem)),this.flagReset()}},text:{render:function(i){this._update();let t={};if((this._matrix.manual||this._flagMatrix)&&(t.transform="matrix("+this._matrix.toString()+")"),this._flagId&&(t.id=this._id),this._flagFamily&&(t["font-family"]=this._family),this._flagSize&&(t["font-size"]=this._size),this._flagLeading&&(t["line-height"]=this._leading),this._flagAlignment&&(t["text-anchor"]=O.alignments[this._alignment]||this._alignment),this._flagBaseline&&(t["alignment-baseline"]=t["dominant-baseline"]=this._baseline),this._flagStyle&&(t["font-style"]=this._style),this._flagWeight&&(t["font-weight"]=this._weight),this._flagDecoration&&(t["text-decoration"]=this._decoration),this._fill&&this._fill._renderer&&(this._fill._update(),O[this._fill._renderer.type].render.call(this._fill,i,!0)),this._flagFill&&(t.fill=this._fill&&this._fill.id?"url(#"+this._fill.id+")":this._fill),this._stroke&&this._stroke._renderer&&(this._stroke._update(),O[this._stroke._renderer.type].render.call(this._stroke,i,!0)),this._flagStroke&&(t.stroke=this._stroke&&this._stroke.id?"url(#"+this._stroke.id+")":this._stroke),this._flagLinewidth&&(t["stroke-width"]=this._linewidth),this._flagOpacity&&(t.opacity=this._opacity),this._flagClassName&&(t.class=this.classList.join(" ")),this._flagVisible&&(t.visibility=this._visible?"visible":"hidden"),this.dashes&&this.dashes.length>0&&(t["stroke-dasharray"]=this.dashes.join(" "),t["stroke-dashoffset"]=this.dashes.offset||0),this._renderer.elem?O.setAttributes(this._renderer.elem,t):(t.id=this._id,this._renderer.elem=O.createElement("text",t),i.defs.appendChild(this._renderer.elem)),this._flagClip){let s=O.getClip(this,i),r=this._renderer.elem;this._clip?(r.removeAttribute("id"),s.setAttribute("id",this.id),s.appendChild(r)):(s.removeAttribute("id"),r.setAttribute("id",this.id),this.parent._renderer.elem.appendChild(r))}return this._flagMask&&(this._mask?(O[this._mask._renderer.type].render.call(this._mask,i),this._renderer.elem.setAttribute("clip-path","url(#"+this._mask.id+")")):this._renderer.elem.removeAttribute("clip-path")),this._flagValue&&(this._renderer.elem.textContent=this._value),this.flagReset()}},"linear-gradient":{render:function(i,t){t||this._update();let e={};if(this._flagId&&(e.id=this._id),this._flagEndPoints&&(e.x1=this.left._x,e.y1=this.left._y,e.x2=this.right._x,e.y2=this.right._y),this._flagSpread&&(e.spreadMethod=this._spread),this._flagUnits&&(e.gradientUnits=this._units),this._renderer.elem?O.setAttributes(this._renderer.elem,e):(e.id=this._id,this._renderer.elem=O.createElement("linearGradient",e),i.defs.appendChild(this._renderer.elem)),this._flagStops){let s=this._renderer.elem.childNodes.length!==this.stops.length;if(s)for(;this._renderer.elem.lastChild;)this._renderer.elem.removeChild(this._renderer.elem.lastChild);for(let r=0;r0&&(e.x*=-1),e.y>0&&(e.y*=-1)),(this._flagScale||this._flagLoaded||this._flagRepeat)&&(e.width=0,e.height=0,r)){switch(s.width=e.width=r.width,s.height=e.height=r.height,this._repeat){case"no-repeat":e.width+=1,e.height+=1;break}this._scale instanceof k?(e.width*=this._scale.x,e.height*=this._scale.y):(e.width*=this._scale,e.height*=this._scale)}return(this._flagScale||this._flagLoaded)&&(this._renderer.image?O.setAttributes(this._renderer.image,s):this._renderer.image=O.createElement("image",s)),this._renderer.elem?Object.keys(e).length!==0&&O.setAttributes(this._renderer.elem,e):(e.id=this._id,e.patternUnits="userSpaceOnUse",this._renderer.elem=O.createElement("pattern",e),i.defs.appendChild(this._renderer.elem)),this._renderer.elem&&this._renderer.image&&!this._renderer.appended&&(this._renderer.elem.appendChild(this._renderer.image),this._renderer.appended=!0),this.flagReset()}}},Fe=class extends m{constructor(t){super();this.domElement=t.domElement||O.createElement("svg"),this.scene=new G,this.scene.parent=this,this.defs=O.createElement("defs"),this.domElement.appendChild(this.defs),this.domElement.defs=this.defs,this.domElement.style.overflow="hidden"}setSize(t,e){return this.width=t,this.height=e,O.setAttributes(this.domElement,{width:t,height:e}),this.trigger(m.Types.resize,t,e)}render(){return O.group.render.call(this.scene,this.domElement),this}};w(Fe,"Utils",O);var yt={create:function(i,t,e){let s=i.createShader(i[e]);if(i.shaderSource(s,t),i.compileShader(s),!i.getShaderParameter(s,i.COMPILE_STATUS)){let n=i.getShaderInfoLog(s);throw i.deleteShader(s),new et("unable to compile shader "+s+": "+n)}return s},types:{vertex:"VERTEX_SHADER",fragment:"FRAGMENT_SHADER"},path:{vertex:` precision mediump float; attribute vec2 a_position; uniform mat3 u_matrix; uniform vec2 u_resolution; uniform vec4 u_rect; varying vec2 v_textureCoords; void main() { vec2 rectCoords = (a_position * (u_rect.zw - u_rect.xy)) + u_rect.xy; vec2 projected = (u_matrix * vec3(rectCoords, 1.0)).xy; vec2 normal = projected / u_resolution; vec2 clipspace = (normal * 2.0) - 1.0; gl_Position = vec4(clipspace * vec2(1.0, -1.0), 0.0, 1.0); v_textureCoords = a_position; } `,fragment:` precision mediump float; uniform sampler2D u_image; varying vec2 v_textureCoords; void main() { vec4 texel = texture2D(u_image, v_textureCoords); if (texel.a == 0.0) { discard; } gl_FragColor = texel; } `},points:{vertex:` precision mediump float; attribute vec2 a_position; uniform float u_size; uniform mat3 u_matrix; uniform vec2 u_resolution; varying vec2 v_textureCoords; void main() { vec2 projected = (u_matrix * vec3(a_position, 1.0)).xy; vec2 normal = projected / u_resolution; vec2 clipspace = (normal * 2.0) - 1.0; gl_PointSize = u_size; gl_Position = vec4(clipspace * vec2(1.0, -1.0), 0.0, 1.0); v_textureCoords = a_position; } `,fragment:` precision mediump float; uniform sampler2D u_image; void main() { vec4 texel = texture2D(u_image, gl_PointCoord); if (texel.a == 0.0) { discard; } gl_FragColor = texel; } `}};var Te=at.Multiply,Ws=[1,0,0,0,1,0,0,0,1],Bt=new xt(9),Xs=kt.Utils,ni=new xt([0,0,1,0,0,1,0,1,1,0,1,1]),P={precision:.9,isHidden:/(undefined|none|transparent)/i,canvas:H.document?H.document.createElement("canvas"):{getContext:function(){}},alignments:{left:"start",middle:"center",right:"end"},matrix:new at,group:{removeChild:function(i,t){if(i.children)for(let e=0;e0&&(g.lineDashOffset=N.offset||0,g.setLineDash(N));let Z,ut,rt,St,Mt,$t,Zt,Qt;g.save(),g.scale(y.x,y.y),g.translate(ft,ct),g.beginPath();for(let wt=0;wt=W&&T&&(s=Z,f=Q.controls&&Q.controls.right||k.zero,u=s.controls&&s.controls.left||k.zero,Q._relative?(a=f.x+Q.x,o=f.y+Q.y):(a=f.x,o=f.y),s._relative?(r=u.x+s.x,n=u.y+s.y):(r=u.x,n=u.y),_=s.x,d=s.y,g.bezierCurveTo(a,o,r,n,_,d));break;case v.line:g.lineTo(_,d);break;case v.move:Z=Q,g.moveTo(_,d);break}}T&&g.closePath(),P.isHidden.test(A)||(c=A._renderer&&A._renderer.offset,c&&(g.save(),g.translate(-A._renderer.offset.x,-A._renderer.offset.y),g.scale(A._renderer.scale.x,A._renderer.scale.y)),g.fill(),c&&g.restore()),P.isHidden.test(x)||(c=x._renderer&&x._renderer.offset,c&&(g.save(),g.translate(-x._renderer.offset.x,-x._renderer.offset.y),g.scale(x._renderer.scale.x,x._renderer.scale.y),g.lineWidth=R/x._renderer.scale.x),g.stroke(),c&&g.restore()),g.restore()},getBoundingClientRect:function(i,t,e){let s=1/0,r=-1/0,n=1/0,a=-1/0,o,h;i.forEach(function(l){let f=l.x,u=l.y,_=l.controls,d,c,p,b,g,y;n=Math.min(u,n),s=Math.min(f,s),r=Math.max(f,r),a=Math.max(u,a),!!l.controls&&(g=_.left,y=_.right,!(!g||!y)&&(d=l._relative?g.x+f:g.x,c=l._relative?g.y+u:g.y,p=l._relative?y.x+f:y.x,b=l._relative?y.y+u:y.y,!(!d||!c||!p||!b)&&(n=Math.min(c,b,n),s=Math.min(d,p,s),r=Math.max(d,p,r),a=Math.max(c,b,a))))}),typeof t=="number"&&(n-=t,s-=t,r+=t,a+=t),o=r-s,h=a-n,e.top=n,e.left=s,e.right=r,e.bottom=a,e.width=o,e.height=h,e.centroid||(e.centroid={}),e.centroid.x=-s,e.centroid.y=-n},render:function(i,t,e){if(!this._visible||!this._opacity)return this;this._update();let s=e||this.parent,r=t[this._renderer.type],n=s._matrix.manual||s._flagMatrix,a=this._matrix.manual||this._flagMatrix,o=this._renderer.parent!==s,h=this._flagVertices||this._flagFill||this._fill instanceof U&&(this._fill._flagSpread||this._fill._flagStops||this._fill._flagEndPoints)||this._fill instanceof D&&(this._fill._flagSpread||this._fill._flagStops||this._fill._flagRadius||this._fill._flagCenter||this._fill._flagFocal)||this._fill instanceof B&&(this._fill._flagLoaded&&this._fill.loaded||this._fill._flagImage||this._fill._flagVideo||this._fill._flagRepeat||this._fill._flagOffset||this._fill._flagScale)||this._stroke instanceof U&&(this._stroke._flagSpread||this._stroke._flagStops||this._stroke._flagEndPoints)||this._stroke instanceof D&&(this._stroke._flagSpread||this._stroke._flagStops||this._stroke._flagRadius||this._stroke._flagCenter||this._stroke._flagFocal)||this._stroke instanceof B&&(this._stroke._flagLoaded&&this._stroke.loaded||this._stroke._flagImage||this._stroke._flagVideo||this._stroke._flagRepeat||this._stroke._flagOffset||this._fill._flagScale)||this._flagStroke||this._flagLinewidth||this._flagOpacity||s._flagOpacity||this._flagVisible||this._flagCap||this._flagJoin||this._flagMiter||this._flagScale||this.dashes&&this.dashes.length>0||!this._renderer.texture;if((n||a||o)&&(this._renderer.matrix||(this._renderer.matrix=new xt(9)),this._matrix.toTransformArray(!0,Bt),Te(Bt,s._renderer.matrix,this._renderer.matrix),this._renderer.scale instanceof k||(this._renderer.scale=new k),this._scale instanceof k?(this._renderer.scale.x=this._scale.x*s._renderer.scale.x,this._renderer.scale.y=this._scale.y*s._renderer.scale.y):(this._renderer.scale.x=this._scale*s._renderer.scale.x,this._renderer.scale.y=this._scale*s._renderer.scale.y),o&&(this._renderer.parent=s)),this._mask&&(i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST),i.stencilFunc(i.ALWAYS,1,0),i.stencilOp(i.KEEP,i.KEEP,i.REPLACE),i.colorMask(!1,!1,!1,!1),P[this._mask._renderer.type].render.call(this._mask,i,t,this),i.stencilFunc(i.EQUAL,1,255),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.colorMask(!0,!0,!0,!0)),h?(this._renderer.rect||(this._renderer.rect={}),this._renderer.opacity=this._opacity*s._renderer.opacity,P.path.getBoundingClientRect(this._renderer.vertices,this._linewidth,this._renderer.rect),P.updateTexture.call(P,i,this)):(this._fill&&this._fill._update&&this._fill._update(),this._stroke&&this._stroke._update&&this._stroke._update()),this._clip&&!e||!this._renderer.texture)return this;t.current!==r&&(i.useProgram(r),i.bindBuffer(i.ARRAY_BUFFER,t.buffers.position),i.vertexAttribPointer(r.position,2,i.FLOAT,!1,0,0),i.enableVertexAttribArray(r.position),i.bufferData(i.ARRAY_BUFFER,ni,i.STATIC_DRAW),t.resolution.flagged||i.uniform2f(i.getUniformLocation(r,"u_resolution"),t.resolution.width,t.resolution.height),t.current=r),t.resolution.flagged&&i.uniform2f(i.getUniformLocation(r,"u_resolution"),t.resolution.width,t.resolution.height),i.bindTexture(i.TEXTURE_2D,this._renderer.texture);let l=this._renderer.rect;return i.uniformMatrix3fv(r.matrix,!1,this._renderer.matrix),i.uniform4f(r.rect,l.left,l.top,l.right,l.bottom),i.drawArrays(i.TRIANGLES,0,6),this._mask&&i.disable(i.STENCIL_TEST),this.flagReset()}},points:{updateCanvas:function(i){let t,e=this.canvas,s=this.ctx,r=i._stroke,n=i._linewidth,a=i._fill,o=i._renderer.opacity||i._opacity,h=i.dashes,l=i._size,f=l;P.isHidden.test(r)||(f+=n),e.width=Pe(f),e.height=e.width;let u=f/e.width,_=e.width/2,d=e.height/2;s.clearRect(0,0,e.width,e.height),a&&(typeof a=="string"?s.fillStyle=a:(P[a._renderer.type].render.call(a,s,i),s.fillStyle=a._renderer.effect)),r&&(typeof r=="string"?s.strokeStyle=r:(P[r._renderer.type].render.call(r,s,i),s.strokeStyle=r._renderer.effect),n&&(s.lineWidth=n/u)),typeof o=="number"&&(s.globalAlpha=o),h&&h.length>0&&(s.lineDashOffset=h.offset||0,s.setLineDash(h)),s.save(),s.translate(_,d),s.scale(P.precision,P.precision),s.beginPath(),s.arc(0,0,l/u*.5,0,J),s.restore(),closed&&s.closePath(),P.isHidden.test(a)||(t=a._renderer&&a._renderer.offset,t&&(s.save(),s.translate(-a._renderer.offset.x,-a._renderer.offset.y),s.scale(a._renderer.scale.x,a._renderer.scale.y)),s.fill(),t&&s.restore()),P.isHidden.test(r)||(t=r._renderer&&r._renderer.offset,t&&(s.save(),s.translate(-r._renderer.offset.x,-r._renderer.offset.y),s.scale(r._renderer.scale.x,r._renderer.scale.y),s.lineWidth=n/r._renderer.scale.x),s.stroke(),t&&s.restore())},render:function(i,t,e){if(!this._visible||!this._opacity)return this;this._update();let s=this._size,r=e||this.parent,n=t[this._renderer.type],a=this._sizeAttenuation,o=this._stroke,h=this._linewidth,l=r._matrix.manual||r._flagMatrix,f=this._matrix.manual||this._flagMatrix,u=this._renderer.parent!==r,_=this._renderer.vertices,d=this._renderer.collection.length,c=this._flagVertices,p=this._flagFill||this._fill instanceof U&&(this._fill._flagSpread||this._fill._flagStops||this._fill._flagEndPoints)||this._fill instanceof D&&(this._fill._flagSpread||this._fill._flagStops||this._fill._flagRadius||this._fill._flagCenter||this._fill._flagFocal)||this._fill instanceof B&&(this._fill._flagLoaded&&this._fill.loaded||this._fill._flagImage||this._fill._flagVideo||this._fill._flagRepeat||this._fill._flagOffset||this._fill._flagScale)||this._stroke instanceof U&&(this._stroke._flagSpread||this._stroke._flagStops||this._stroke._flagEndPoints)||this._stroke instanceof D&&(this._stroke._flagSpread||this._stroke._flagStops||this._stroke._flagRadius||this._stroke._flagCenter||this._stroke._flagFocal)||this._stroke instanceof B&&(this._stroke._flagLoaded&&this._stroke.loaded||this._stroke._flagImage||this._stroke._flagVideo||this._stroke._flagRepeat||this._stroke._flagOffset||this._fill._flagScale)||this._flagStroke||this._flagLinewidth||this._flagOpacity||r._flagOpacity||this._flagVisible||this._flagScale||this.dashes&&this.dashes.length>0||!this._renderer.texture;if((l||f||u)&&(this._renderer.matrix||(this._renderer.matrix=new xt(9)),this._matrix.toTransformArray(!0,Bt),Te(Bt,r._renderer.matrix,this._renderer.matrix),this._renderer.scale instanceof k||(this._renderer.scale=new k),this._scale instanceof k?(this._renderer.scale.x=this._scale.x*r._renderer.scale.x,this._renderer.scale.y=this._scale.y*r._renderer.scale.y):(this._renderer.scale.x=this._scale*r._renderer.scale.x,this._renderer.scale.y=this._scale*r._renderer.scale.y),u&&(this._renderer.parent=r)),c){let b=this._renderer.positionBuffer;b&&i.deleteBuffer(b),this._renderer.positionBuffer=i.createBuffer(),i.bindBuffer(i.ARRAY_BUFFER,this._renderer.positionBuffer),i.vertexAttribPointer(n.position,2,i.FLOAT,!1,0,0),i.enableVertexAttribArray(n.position),i.bufferData(i.ARRAY_BUFFER,_,i.STATIC_DRAW)}return p?(this._renderer.opacity=this._opacity*r._renderer.opacity,P.updateTexture.call(P,i,this)):(this._fill&&this._fill._update&&this._fill._update(),this._stroke&&this._stroke._update&&this._stroke._update()),this._clip&&!e||!this._renderer.texture?this:(P.isHidden.test(o)||(s+=h),s/=P.precision,a&&(s*=Math.max(this._renderer.scale.x,this._renderer.scale.y)),t.current!==n&&(i.useProgram(n),t.resolution.flagged||i.uniform2f(i.getUniformLocation(n,"u_resolution"),t.resolution.width,t.resolution.height),t.current=n),t.resolution.flagged&&i.uniform2f(i.getUniformLocation(n,"u_resolution"),t.resolution.width,t.resolution.height),i.bindTexture(i.TEXTURE_2D,this._renderer.texture),i.uniformMatrix3fv(n.matrix,!1,this._renderer.matrix),i.uniform1f(n.size,s*t.resolution.ratio),i.drawArrays(i.POINTS,0,d),this.flagReset())}},text:{updateCanvas:function(i){let t=this.canvas,e=this.ctx,s=i._renderer.scale,r=i._stroke,n=i._linewidth*s,a=i._fill,o=i._renderer.opacity||i._opacity,h=i.dashes,l=i._decoration;t.width=Math.max(Math.ceil(i._renderer.rect.width*s.x),1),t.height=Math.max(Math.ceil(i._renderer.rect.height*s.y),1);let f=i._renderer.rect.centroid,u=f.x,_=f.y,d,c,p,b,g,y,x,R,A,E,C,j=a._renderer&&a._renderer.offset&&r._renderer&&r._renderer.offset;if(e.clearRect(0,0,t.width,t.height),j||(e.font=[i._style,i._weight,i._size+"px/"+i._leading+"px",i._family].join(" ")),e.textAlign="center",e.textBaseline="middle",a&&(typeof a=="string"?e.fillStyle=a:(P[a._renderer.type].render.call(a,e,i),e.fillStyle=a._renderer.effect)),r&&(typeof r=="string"?e.strokeStyle=r:(P[r._renderer.type].render.call(r,e,i),e.strokeStyle=r._renderer.effect),n&&(e.lineWidth=n)),typeof o=="number"&&(e.globalAlpha=o),h&&h.length>0&&(e.lineDashOffset=h.offset||0,e.setLineDash(h)),e.save(),e.scale(s.x,s.y),e.translate(u,_),P.isHidden.test(a)||(a._renderer&&a._renderer.offset?(y=a._renderer.scale.x,x=a._renderer.scale.y,e.save(),e.translate(-a._renderer.offset.x,-a._renderer.offset.y),e.scale(y,x),d=i._size/a._renderer.scale.y,c=i._leading/a._renderer.scale.y,e.font=[i._style,i._weight,d+"px/",c+"px",i._family].join(" "),p=a._renderer.offset.x/a._renderer.scale.x,b=a._renderer.offset.y/a._renderer.scale.y,e.fillText(i.value,p,b),e.restore()):e.fillText(i.value,0,0)),P.isHidden.test(r)||(r._renderer&&r._renderer.offset?(y=r._renderer.scale.x,x=r._renderer.scale.y,e.save(),e.translate(-r._renderer.offset.x,-r._renderer.offset.y),e.scale(y,x),d=i._size/r._renderer.scale.y,c=i._leading/r._renderer.scale.y,e.font=[i._style,i._weight,d+"px/",c+"px",i._family].join(" "),p=r._renderer.offset.x/r._renderer.scale.x,b=r._renderer.offset.y/r._renderer.scale.y,g=n/r._renderer.scale.x,e.lineWidth=g,e.strokeText(i.value,p,b),e.restore()):e.strokeText(i.value,0,0)),/(underline|strikethrough)/i.test(l)){let M=e.measureText(i.value);switch(l){case"underline":A=M.actualBoundingBoxAscent,C=M.actualBoundingBoxAscent;break;case"strikethrough":A=0,C=0;break}R=-M.width/2,E=M.width/2,e.lineWidth=Math.max(Math.floor(i._size/15),1),e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(R,A),e.lineTo(E,C),e.stroke()}e.restore()},getBoundingClientRect:function(i,t){let e=P.ctx;e.font=[i._style,i._weight,i._size+"px/"+i._leading+"px",i._family].join(" "),e.textAlign="center",e.textBaseline=i._baseline;let s=e.measureText(i._value).width*1.25,r=Math.max(i._size,i._leading)*1.25;this._linewidth&&!P.isHidden.test(this._stroke)&&(s+=this._linewidth*2,r+=this._linewidth*2);let n=s/2,a=r/2;switch(P.alignments[i._alignment]||i._alignment){case P.alignments.left:t.left=0,t.right=s;break;case P.alignments.right:t.left=-s,t.right=0;break;default:t.left=-n,t.right=n}switch(i._baseline){case"bottom":t.top=-r,t.bottom=0;break;case"top":t.top=0,t.bottom=r;break;default:t.top=-a,t.bottom=a}t.width=s,t.height=r,t.centroid||(t.centroid={}),t.centroid.x=n,t.centroid.y=a},render:function(i,t,e){if(!this._visible||!this._opacity)return this;this._update();let s=e||this.parent,r=t[this._renderer.type],n=s._matrix.manual||s._flagMatrix,a=this._matrix.manual||this._flagMatrix,o=this._renderer.parent!==s,h=this._flagVertices||this._flagFill||this._fill instanceof U&&(this._fill._flagSpread||this._fill._flagStops||this._fill._flagEndPoints)||this._fill instanceof D&&(this._fill._flagSpread||this._fill._flagStops||this._fill._flagRadius||this._fill._flagCenter||this._fill._flagFocal)||this._fill instanceof B&&(this._fill._flagLoaded&&this._fill.loaded||this._fill._flagImage||this._fill._flagVideo||this._fill._flagRepeat||this._fill._flagOffset||this._fill._flagScale)||this._stroke instanceof U&&(this._stroke._flagSpread||this._stroke._flagStops||this._stroke._flagEndPoints)||this._stroke instanceof D&&(this._stroke._flagSpread||this._stroke._flagStops||this._stroke._flagRadius||this._stroke._flagCenter||this._stroke._flagFocal)||this._stroke instanceof B&&(this._stroke._flagLoaded&&this._stroke.loaded||this._stroke._flagImage||this._stroke._flagVideo||this._stroke._flagRepeat||this._stroke._flagOffset||this._fill._flagScale)||this._flagStroke||this._flagLinewidth||this._flagOpacity||s._flagOpacity||this._flagVisible||this._flagScale||this._flagValue||this._flagFamily||this._flagSize||this._flagLeading||this._flagAlignment||this._flagBaseline||this._flagStyle||this._flagWeight||this._flagDecoration||this.dashes&&this.dashes.length>0||!this._renderer.texture;if((n||a||o)&&(this._renderer.matrix||(this._renderer.matrix=new xt(9)),this._matrix.toTransformArray(!0,Bt),Te(Bt,s._renderer.matrix,this._renderer.matrix),this._renderer.scale instanceof k||(this._renderer.scale=new k),this._scale instanceof k?(this._renderer.scale.x=this._scale.x*s._renderer.scale.x,this._renderer.scale.y=this._scale.y*s._renderer.scale.y):(this._renderer.scale.x=this._scale*s._renderer.scale.x,this._renderer.scale.y=this._scale*s._renderer.scale.y),o&&(this._renderer.parent=s)),this._mask&&(i.clear(i.STENCIL_BUFFER_BIT),i.enable(i.STENCIL_TEST),i.stencilFunc(i.ALWAYS,1,0),i.stencilOp(i.KEEP,i.KEEP,i.REPLACE),i.colorMask(!1,!1,!1,!1),P[this._mask._renderer.type].render.call(this._mask,i,t,this),i.stencilFunc(i.EQUAL,1,255),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.colorMask(!0,!0,!0,!0)),h?(this._renderer.rect||(this._renderer.rect={}),this._renderer.opacity=this._opacity*s._renderer.opacity,P.text.getBoundingClientRect(this,this._renderer.rect),P.updateTexture.call(P,i,this)):(this._fill&&this._fill._update&&this._fill._update(),this._stroke&&this._stroke._update&&this._stroke._update()),this._clip&&!e||!this._renderer.texture)return this;t.current!==r&&(i.useProgram(r),i.bindBuffer(i.ARRAY_BUFFER,t.buffers.position),i.vertexAttribPointer(r.position,2,i.FLOAT,!1,0,0),i.enableVertexAttribArray(r.position),i.bufferData(i.ARRAY_BUFFER,ni,i.STATIC_DRAW),t.resolution.flagged||i.uniform2f(i.getUniformLocation(r,"u_resolution"),t.resolution.width,t.resolution.height),t.current=r),t.resolution.flagged&&i.uniform2f(i.getUniformLocation(r,"u_resolution"),t.resolution.width,t.resolution.height),i.bindTexture(i.TEXTURE_2D,this._renderer.texture);let l=this._renderer.rect;return i.uniformMatrix3fv(r.matrix,!1,this._renderer.matrix),i.uniform4f(r.rect,l.left,l.top,l.right,l.bottom),i.drawArrays(i.TRIANGLES,0,6),this._mask&&i.disable(i.STENCIL_TEST),this.flagReset()}},"linear-gradient":{render:function(i,t){if(!(!i.canvas.getContext("2d")||!t)){if(this._update(),!this._renderer.effect||this._flagEndPoints||this._flagStops||this._flagUnits){let e,s=this.left._x,r=this.left._y,n=this.right._x,a=this.right._y;/objectBoundingBox/i.test(this._units)&&(e=t.getBoundingClientRect(!0),s=(s-.5)*e.width,r=(r-.5)*e.height,n=(n-.5)*e.width,a=(a-.5)*e.height),this._renderer.effect=i.createLinearGradient(s,r,n,a);for(let o=0;o