/*! * i2djs * (c) 2024 Narayana Swamy (narayanaswamy14@gmail.com) * @license BSD-3-Clause */ import{i as r,R as n,e,f as a,P as t,b as c,p as X}from"./dependencies-bundle-esm.js";let o=null,i=[];const K={},P=[];let s,u,m,l=[];function d(r,n,e){this.executable=n,this.duration=n.duration?n.duration:0,this.delay=n.delay?n.delay:0,this.lastTime=0-(n.delay?n.delay:0),this.loopTracker=0,this.loop=n.loop?n.loop:0,this.direction=n.direction,this.easying=e,this.end=n.end?n.end:null,"reverse"===this.direction?this.factor=1:this.factor=0}function g(){}"undefined"==typeof window&&(global.window={setTimeout:setTimeout,clearTimeout:clearTimeout},global.performance={now:function(){return Date.now()}},global.document={}),window.requestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(r){return window.setTimeout(r,1e3/60)},window.cancelAnimFrame=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(r){return window.clearTimeout(r)},d.prototype.execute=function(r){this.executable.run(r)},d.prototype.resetCallBack=function(r){"function"==typeof r&&(this.callBack=r)},g.prototype={startAnimeFrames:function(){s||(s=window.requestAnimationFrame(C))},stopAnimeFrame:function(){s&&(window.cancelAnimFrame(s),s=null)},add:function(r,n,e){const a=new d(r,n,e);a.currTime=performance.now(),i.push(a),this.startAnimeFrames()},remove:function(r){const n=i.indexOf(r);-1!==n&&i.splice(n,1)},onRequestFrame:function(r){if("function"!=typeof r)throw new Error("Wrong input");l.push(r),l.length>0&&!s&&this.startAnimeFrames()},removeRequestFrameCall:function(r){if("function"!=typeof r)throw new Error("Wrong input");const n=l.indexOf(r);-1!==n&&l.splice(n,1)},clearAll:function(){i=[],l=[]}},g.prototype.interruptNodeAnimations=function(r){i=i.filter((n=>(n?.executable?.target??null)!==r))},g.prototype.addVdom=function(r){const n=P.length+1;return K[n]=r,P.push(n),this.startAnimeFrames(),n},g.prototype.removeVdom=function(r){const n=P.indexOf(r);i=i.filter((n=>(n?.executable?.target?.vDomIndex??null)!==r)),-1!==n&&(P.splice(n,1),K[r].root.destroy(),delete K[r]),0===P.length&&0===i.length&&0===l.length&&this.stopAnimeFrame()},g.prototype.vDomChanged=function(r){if(K[r]&&void 0!==K[r].stateModified)K[r].stateModified=!0,K[r].root.stateModified=!0;else if("string"==typeof r){const n=r.split(":");if(K[n[0]]&&void 0!==K[n[0]].stateModified){K[n[0]].stateModified=!0,K[n[0]].root.stateModified=!0;const r=K[n[0]].root.fetchEl("#"+n[1]);r&&(r.stateModified=!0)}}},g.prototype.execute=function(){this.startAnimeFrames()},g.prototype.vDomUpdates=function(){for(let r=0,n=P.length;r=0?(u.execute(h(u.factor-u.easying(u.lastTime,u.duration))),f[A++]=u):u.lastTime>u.duration?W(u)&&(f[A++]=u):f[A++]=u;i=f,l.length>0&&function(r){for(let n=0;n=r.loop-1){r.execute(1-r.factor),r.end&&r.end();const n=r.executable?.target?.animList;if(n){const e=n.indexOf(r);-1!==e&&n.splice(e,1)}return!1}return r.loopTracker+=1,r.lastTime=r.lastTime-r.duration,r.lastTime=r.lastTime%r.duration,r.factor="alternate"===r.direction?1-r.factor:"reverse"===r.direction?1:0,r.execute(h(r.factor-r.easying(r.lastTime,r.duration))),!0}o=new g;var B=o;function v(){}const N=B;function x(r,n){let e=0,a=0,t=1,c=1;const X=n;if(r.attr.transform&&r.attr.transform.translate&&([e,a]=r.attr.transform.translate,X.x-=e,X.y-=a),r.attr.transform&&r.attr.transform.scale&&(t=void 0!==r.attr.transform.scale[0]?r.attr.transform.scale[0]:1,c=void 0!==r.attr.transform.scale[1]?r.attr.transform.scale[1]:t,X.x/=t,X.y/=c),r.attr.transform&&r.attr.transform.rotate){const n=r.attr.transform.rotate[0],e={x:r.attr.transform.rotate[1],y:r.attr.transform.rotate[2]},a=X.x,t=X.y,c=e.x,P=e.y;var o=Math.PI/180*n,i=Math.cos(o),K=Math.sin(o);X.x=i*(a-c)+K*(t-P)+c,X.y=i*(t-P)-K*(a-c)+P}}v.prototype.execute=function(){if(!document.body.contains(this.root.container))return N.removeVdom(this.root.vDomIndex),void(this.stateModified=!1);this.root.execute(),this.stateModified=!1},v.prototype.rootNode=function(r){this.root=r,this.stateModified=!0},v.prototype.eventsCheck=function(r,n,e){const a=this;let t,c;for(var X=0;X<=r.length-1;X+=1){var o=r[X],i={x:n.x,y:n.y};x(o,i),o.in({x:i.x,y:i.y})&&(o.children&&o.children.length>0?(c=a.eventsCheck(o.children,{x:i.x,y:i.y},e),c&&(t=c)):t=o)}return t},v.prototype.transformCoOr=x;const y=Math.sqrt,p=Math.sin,O=Math.cos,T=Math.abs,k=Math.atan2,Y=Math.tan,b=Math.PI,U=Math.ceil,w=Math.max;function R(r,n){let e=1;if(0===n)return e;for(let a=1;a<=n;a+=1)e*=r;return e}function V(r,n){let e=0;for(const a in r)e+=R(n[a]-r[a],2);if(isNaN(e))throw new Error("error");return y(e)}function D(r,n,e){const a=R(e,3),t=R(e,2);return{x:n.ax*a+n.bx*t+n.cx*e+r.x,y:n.ay*a+n.by*t+n.cy*e+r.y}}const L=function(r,n){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return function(r,n){const e=[];let a,t=!0,c=!1;try{for(var X,o=r[Symbol.iterator]();!(t=(X=o.next()).done)&&(e.push(X.value),!n||e.length!==n);t=!0);}catch(r){c=!0,a=r}finally{try{!t&&o.return&&o.return()}finally{c&&console.log("Error -"+a)}}return e}(r,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")},S=2*b,q=function(r,n,e,a,t,c,X){let{x:o,y:i}=r;o*=n,i*=e;return{x:a*o-t*i+c,y:t*o+a*i+X}},E=function(r,n){const e=4/3*Y(n/4),a=O(r),t=p(r),c=O(r+n),X=p(r+n);return[{x:a-t*e,y:t+a*e},{x:c+X*e,y:X-c*e},{x:c,y:X}]},F=function(r,n,e,a){const t=r*a-n*e<0?-1:1;let c=(r*e+n*a)/(y(r*r+n*n)*y(r*r+n*n));return c>1&&(c=1),c<-1&&(c=-1),t*Math.acos(c)};function z(r,n,e){const a=r.x,t=r.y,c=n.x,X=n.y;var o=b/180*e,i=O(-o),K=p(-o);return{x:i*(a-c)+K*(t-X)+c,y:i*(t-X)-K*(a-c)+X}}function I(){}I.prototype={pow:R,getAngle:function(r,n){return k(n.x-r.x,n.y-r.y)},getDistance:V,scaleAlongOrigin:function(r,n){const e={};for(const a in r)e[a]=r[a]*n;return e},scaleAlongPoint:function(r,n,e){const a=(r.y-n.y)/(r.x-n.x),t=r.x*e;return{x:t,y:(a*(t-n.x)+n.y)*e}},linearTransitionBetweenPoints:function(r,n,e){return{x:r.x+(n.x-r.x)*e,y:r.y+(n.y-r.y)*e}},bezierTransition:function(r,n,e,a){return{x:(r.x-2*n.x+e.x)*a*a+(2*n.x-2*r.x)*a+r.x,y:(r.y-2*n.y+e.y)*a*a+(2*n.y-2*r.y)*a+r.y}},bezierLength:function(r,n,e){const a={},t={};a.x=r.x+e.x-2*n.x,a.y=r.y+e.y-2*n.y,t.x=2*n.x-2*r.x,t.y=2*n.y-2*r.y;const c=4*(a.x*a.x+a.y*a.y),X=4*(a.x*t.x+a.y*t.y),o=t.x*t.x+t.y*t.y,i=2*y(c+X+o),K=y(c),P=2*c*K,s=2*y(o),u=X/K;let m=(2*K+u+i)/(u+s);return m=isNaN(m)||T(m)===1/0?1:m,(P*i+K*X*(i-s)+(4*o*c-X*X)*Math.log(m))/(4*P)},cubicBezierTransition:D,cubicBezierLength:function(r,n){const e=.001;let a=0;const t=D.bind(null,r,n);let c,X;for(let r=0;r<=1;r+=e)c=t(r),X=t(r+e),a+=y(R((X.x-c.x)/e,2)+R((X.y-c.y)/e,2))*e;return a},cubicBezierCoefficients:function(r){const n=3*(r.cntrl1.x-r.p0.x),e=3*(r.cntrl2.x-r.cntrl1.x)-n,a=r.p1.x-r.p0.x-n-e,t=3*(r.cntrl1.y-r.p0.y),c=3*(r.cntrl2.y-r.cntrl1.y)-t;return{cx:n,bx:e,ax:a,cy:t,by:c,ay:r.p1.y-r.p0.y-t-c}},arcToBezier:function(r){let{px:n,py:e,cx:a,cy:t,rx:c,ry:X}=r;const o=r.xAxisRotation,i=void 0===o?0:o,K=r.largeArcFlag,P=void 0===K?0:K,s=r.sweepFlag,u=void 0===s?0:s,m=[];if(0===c||0===X)return[];const l=p(i*S/360),d=O(i*S/360),g=d*(n-a)/2+l*(e-t)/2,h=-l*(n-a)/2+d*(e-t)/2;if(0===g&&0===h)return[];c=T(c),X=T(X);const A=R(g,2)/R(c,2)+R(h,2)/R(X,2);A>1&&(c*=y(A),X*=y(A));const f=function(r,n,e,a,t,c,X,o,i,K,P,s){const u=R(t,2),m=R(c,2),l=R(P,2),d=R(s,2);let g=u*m-u*d-m*l;g<0&&(g=0),g/=u*d+m*l,g=y(g)*(X===o?-1:1);const h=g*t/c*s,A=g*-c/t*P,f=K*h-i*A+(r+e)/2,C=i*h+K*A+(n+a)/2,W=(P-h)/t,B=(s-A)/c,v=(-P-h)/t,N=(-s-A)/c,x=F(1,0,W,B);let p=F(W,B,v,N);return 0===o&&p>0&&(p-=S),1===o&&p<0&&(p+=S),[f,C,x,p]}(n,e,a,t,c,X,P,u,l,d,g,h),C=L(f,4),W=C[0],B=C[1];let v=C[2],N=C[3];const x=w(U(T(N)/(S/4)),1);N/=x;for(let r=0;r{const n=q(r[0],c,X,d,l,W,B),e=n.x,a=n.y,t=q(r[1],c,X,d,l,W,B),o=t.x,i=t.y,K=q(r[2],c,X,d,l,W,B);return{x1:e,y1:a,x2:o,y2:i,x:K.x,y:K.y}}))},intermediateValue:function(r,n,e){return r+(n-r)*e},toCubicCurves:function(r){if(!r.length)return;const n=r,e=[];for(let r=0;r0&&(i.x+=X[0],i.y+=X[1]),e=z(e,i,K,V(e,i)),a=z(a,i,K,V(a,i)),t=z(t,i,K,V(t,i)),c=z(c,i,K,V(c,i));const P=[e.x,a.x,t.x,c.x].sort(((r,n)=>r-n)),s=[e.y,a.y,t.y,c.y].sort(((r,n)=>r-n));return{x:P[0],y:s[0],width:P[3]-P[0],height:s[3]-s[0]}}};var G=new I;const M=G;function _(r,n){return r/n}function J(r,n){const e=r/n;return 1-(1-e)*Math.sin(e*n*.002*Math.PI*2+Math.PI/2)/Math.exp(8*e)}function j(r,n){const e=r/n,a=e/100;return 1-(1-e)*Math.abs(Math.sin(e*n*a*Math.PI*2+Math.PI/2))/Math.exp(10*e)}function H(r,n){const e=r/n;return e*e}function Q(r,n){const e=r/n;return e*(2-e)}function Z(r,n){const e=r/n;return e<.5?2*e*e:(4-2*e)*e-1}function $(r,n){const e=r/n;return M.pow(e,3)}function rr(r,n){let e=r/n;return e-=1,e*e*e+1}function nr(r,n){const e=r/n;return e<.5?4*M.pow(e,3):(e-1)*(2*e-2)*(2*e-2)+1}function er(r,n){const e=r/n;return 1-Math.cos(e*Math.PI/2)}function ar(r,n){const e=r/n;return Math.cos(e*Math.PI/2)}function tr(r,n){const e=r/n;return(1-Math.cos(Math.PI*e))/2}function cr(r){let n;if("function"==typeof r)return function(n,e){return r(n/e)};switch(r){case"easeOutQuad":n=Q;break;case"easeInQuad":n=H;break;case"easeInOutQuad":n=Z;break;case"easeInCubic":n=$;break;case"easeOutCubic":n=rr;break;case"easeInOutCubic":n=nr;break;case"easeInSin":n=er;break;case"easeOutSin":n=ar;break;case"easeInOutSin":n=tr;break;case"bounce":n=j;break;case"linear":default:n=_;break;case"elastic":n=J}return n}let Xr=0,or=0;function ir(){return Xr+=1,Xr}function Kr(){return or+=1,or}const Pr=cr;function sr(r){return this.easying=Pr(r),this.transition=r,this}function ur(r){if(1!==arguments.length)throw new Error("arguments mis match");return this.durationP=r,this}function mr(r){if(1!==arguments.length)throw new Error("arguments mis match");return this.delayValue=r,this}function lr(r){if(1!==arguments.length)throw new Error("arguments mis match");return this.loopValue=r,this}function dr(r){if(1!==arguments.length)throw new Error("arguments mis match");return this.directionV=r,this}function gr(r){if(1!==arguments.length)throw new Error("arguments mis match");return this.data=r,"CANVAS"===this.data.nodeName&&(this.canvasStack=[]),this}function hr(r){return"function"!=typeof r?null:(this.callbckExe=r,this)}function Ar(r){return this.end=r,this}function fr(r){return this.endExe=r,this}function Cr(){this.start()}function Wr(){this.queue=B,this.sequenceQueue=[],this.lengthV=0,this.currPos=0,this.ID=ir(),this.loopCounter=0}function Br(){this.queue=B,this.group=[],this.currPos=0,this.delay=0,this.ID=ir(),this.loopCounter=1}Wr.prototype={delay:mr,duration:ur,loop:lr,callbck:hr,bind:gr,child:Ar,ease:sr,end:fr,commit:Cr,reset:function(r){return this.resetV=r,this},direction:dr},Wr.prototype.add=function(r){const n=this;return Array.isArray(r)||"function"==typeof r||(r=[r]),Array.isArray(r)&&r.map((r=>(n.lengthV+=r.length?r.length:0,r))),0===this.sequenceQueue.length&&this.delayValue&&r.length>0&&(r[0].delay+=this.delayValue),this.sequenceQueue=this.sequenceQueue.concat(r),this},Wr.prototype.easyingGlobal=function(r,n){return r/n},Wr.prototype.start=function(){const r=this;if("alternate"===r.directionV)r.factor=r.factor?-1*r.factor:1,r.currPos=r.factor<0?this.sequenceQueue.length-1:0;else if("reverse"===r.directionV){for(let n=0;nr/n))),this},Wr.prototype.triggerEnd=function(r){const n=this;if(n.currPos+=n.factor,r.end&&n.triggerChild(r),n.sequenceQueue.length===n.currPos||n.currPos<0)return n.endExe&&n.endExe(),n.loopCounter+=1,void(n.loopCounter{r.end.commit()}),0):r.end()},Br.prototype={delay:mr,duration:ur,loop:lr,callbck:hr,bind:gr,child:Ar,ease:sr,end:fr,commit:Cr,direction:dr},Br.prototype.add=function(r){const n=this;return Array.isArray(r)||(r=[r]),r.forEach((r=>{r.delay+=n.delayValue||0})),this.group=this.group.concat(r),this.group.forEach((r=>{r.durationP=r.durationP?r.durationP:n.durationP})),this},Br.prototype.execute=function(){const r=this;r.currPos=0;for(let n=0,e=r.group.length;nn+n+e+e+a+a));const n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);return new pr(parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16),255)}function Tr(r){const n=r.replace(/[^0-9.,]+/g,"").split(","),e={},a=["r","g","b","a"];for(let r=0;r1&&(e-=1),e<1/6?r+6*(n-r)*e:e<.5?n:e<2/3?r+(n-r)*(2/3-e)*6:r},P=o<.5?o*(1+X):o+X-o*X,s=2*o-P;n=255*K(s,P,c+1/3),e=255*K(s,P,c),a=255*K(s,P,c-1/3)}return new pr(n,e,a,t=void 0===t?255:t)}function Yr(r){return r instanceof pr?r:r.startsWith("#")?Or(r):r.startsWith("rgb")?Tr(r):r.startsWith("hsl")?kr(r):{r:0,g:0,b:0,a:255}}pr.prototype.normalize=function(){return this.normalFlag||(this.r/=255,this.g/=255,this.b/=255,this.a/=255,this.normalFlag=!0),this};var br={nameToHex:function(r){return Nr[r]?`#${Nr[r]}`:"#000"},hexToRgb:Or,rgbToHex:function(r){const n=r.substring(r.lastIndexOf("(")+1,r.lastIndexOf(")")).split(",");return`#${((1<<24)+(parseInt(n[0],10)<<16)+(parseInt(n[1],10)<<8)+parseInt(n[2],10)).toString(16).slice(1)}`},hslToRgb:kr,transition:function(r,n){return n=n||yr,r=Yr(r=r||yr),n=Yr(n),function(e){return new pr(xr(r.r+(n.r-r.r)*e),xr(r.g+(n.g-r.g)*e),xr(r.b+(n.b-r.b)*e),xr(r.a+(n.a-r.a)*e))}},colorToRGB:Yr,rgba:function(r,n,e,a){return new pr(r,n,e,a)},isTypeColor:function(r){return r instanceof pr||r.startsWith("#")||r.startsWith("rgb")||r.startsWith("hsl")},RGBAInstanceCheck:function(r){return r instanceof pr},colorToRGBPdf:function(r){const n=r instanceof pr?r:r.startsWith("#")?Or(r):r.startsWith("rgb")?Tr(r):r.startsWith("hsl")?kr(r):{r:0,g:0,b:0,a:255};return[n.r,n.g,n.b]}};let Ur=0;const wr=G,Rr=B,Vr=cr;function Dr(r,n,e,a){const t=r=>{e.minX=Math.min(e.minX,r.x),e.maxX=Math.max(e.maxX,r.x),e.minY=Math.min(e.minY,r.y),e.maxY=Math.max(e.maxY,r.y)};if(["V","H","L","v","h","l"].includes(r.type))[r.p0||n.p1,r.p1].forEach(t);else if(["Q","C","q","c"].includes(r.type)){const n=wr.cubicBezierCoefficients(r),e=wr.cubicBezierTransition.bind(null,r.p0,n);for(let r=0;r<=1;r+=.05)t(e(r))}else t(r.p0);Object.assign(a,{x:e.minX,y:e.minY,width:e.maxX-e.minX,height:e.maxY-e.minY})}function Lr(r,n){return{x:r.x+n.x,y:r.y+n.y}}function Sr(r,n){return{x:r.x-n.x,y:r.y-n.y}}function qr(r,n,e){return r?e:n}function Er(r){this.stack=[],this.length=0,this.stackGroup=[],this.BBox={x:0,y:0,width:0,height:0},this.minMax={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},r&&this.parse(r)}function Fr(r){return["S","C","V","L","H","Q"].indexOf(r)>-1}Er.prototype={z:function(){return this.cp=this.start,this.segmentLength=wr.getDistance(this.pp,this.cp),this.stack.push({p0:this.pp,p1:this.cp,type:"Z",length:this.segmentLength,pointAt(r){return wr.linearTransitionBetweenPoints(this.p0,this.p1,r)}}),this.length+=this.segmentLength,this.pp=this.cp,Dr(this.stack[this.stack.length-1],this.stack[this.stack.length-2],this.minMax,this.BBox),this},m:function(r,n){const e=qr(r,this.pp?this.pp:{x:0,y:0},{x:0,y:0});return this.cntrl=null,this.cp=Lr(n,e),this.start=this.cp,this.segmentLength=0,this.length=this.segmentLength,0!==this.currPathArr&&this.pp?(this.stackGroup.push(this.stack),this.stack=[]):this.stackGroup.push(this.stack),this.stack.push({type:"M",p0:this.cp,length:this.segmentLength,pointAt(){return this.p0}}),this.pp=this.cp,Dr(this.stack[this.stack.length-1],this.stack[this.stack.length-2],this.minMax,this.BBox),this},v:function(r,n){const e=qr(r,this.pp,{x:this.pp.x,y:0});return this.cntrl=null,this.cp=Lr(n,e),this.segmentLength=wr.getDistance(this.pp,this.cp),this.stack.push({type:"V",p0:this.pp,p1:this.cp,length:this.segmentLength,pointAt(r){return wr.linearTransitionBetweenPoints(this.p0,this.p1,r)}}),this.length+=this.segmentLength,this.pp=this.cp,Dr(this.stack[this.stack.length-1],this.stack[this.stack.length-2],this.minMax,this.BBox),this},h:function(r,n){const e=qr(r,this.pp,{x:0,y:this.pp.y});return this.cp=Lr(n,e),this.cntrl=null,this.segmentLength=wr.getDistance(this.pp,this.cp),this.stack.push({type:r?"H":"h",p0:this.pp,p1:this.cp,length:this.segmentLength,relative:{p1:n},pointAt(r){return wr.linearTransitionBetweenPoints(this.p0,this.p1,r)}}),this.length+=this.segmentLength,this.pp=this.cp,Dr(this.stack[this.stack.length-1],this.stack[this.stack.length-2],this.minMax,this.BBox),this},l:function(r,n){const e=qr(r,this.pp,{x:0,y:0});return this.cntrl=null,this.cp=Lr(n,e),this.segmentLength=wr.getDistance(this.pp,this.cp),this.stack.push({type:r?"L":"l",p0:this.pp,p1:this.cp,relative:{p1:n},length:this.segmentLength,pointAt(r){return wr.linearTransitionBetweenPoints(this.p0,this.p1,r)}}),this.length+=this.segmentLength,this.pp=this.cp,Dr(this.stack[this.stack.length-1],this.stack[this.stack.length-2],this.minMax,this.BBox),this},q:function(r,n,e){const a=qr(r,this.pp,{x:0,y:0}),t=Lr(n,a),c=Lr(e,a);return this.cp=c,this.segmentLength=wr.bezierLength(this.pp,t,this.cp),this.cp=c,this.stack.push({type:r?"Q":"q",p0:this.pp,cntrl1:t,cntrl2:t,p1:this.cp,relative:{cntrl1:n,p1:e},length:this.segmentLength,pointAt(r){return wr.bezierTransition(this.p0,this.cntrl1,this.p1,r)}}),this.length+=this.segmentLength,this.pp=this.cp,this.cntrl=t,Dr(this.stack[this.stack.length-1],this.stack[this.stack.length-2],this.minMax,this.BBox),this},s:function(r,n,e){const a=qr(r,this.pp,{x:0,y:0}),t=Lr(n,a),c=this.cntrl?Lr(this.pp,Sr(this.pp,this.cntrl?this.cntrl:this.pp)):t,X=Lr(e,a);this.cp=X;const o=wr.cubicBezierCoefficients({p0:this.pp,cntrl1:c,cntrl2:t,p1:X});return this.segmentLength=wr.cubicBezierLength(this.pp,o),this.stack.push({type:r?"S":"s",p0:this.pp,cntrl1:c,cntrl2:t,p1:this.cp,co:o,length:this.segmentLength,relative:{cntrl2:n,p1:e},pointAt(r){return wr.cubicBezierTransition(this.p0,this.co,r)}}),Dr(this.stack[this.stack.length-1],this.stack[this.stack.length-2],this.minMax,this.BBox),this.length+=this.segmentLength,this.pp=this.cp,this.cntrl=t,this},c:function(r,n,e,a){const t=this,c=qr(r,this.pp,{x:0,y:0}),X=Lr(n,c),o=Lr(e,c),i=Lr(a,c),K=wr.cubicBezierCoefficients({p0:this.pp,cntrl1:X,cntrl2:o,p1:i});return this.cntrl=o,this.cp=i,this.segmentLength=wr.cubicBezierLength(this.pp,K),this.stack.push({type:r?"C":"c",p0:this.pp,cntrl1:X,cntrl2:o,p1:this.cp,length:this.segmentLength,co:K,relative:{cntrl1:n,cntrl2:e,p1:a},pointAt(r){return wr.cubicBezierTransition(this.p0,this.co,r)}}),this.length+=this.segmentLength,this.pp=this.cp,Dr(t.stack[t.stack.length-1],t.stack[t.stack.length-2],t.minMax,t.BBox),this},a:function(r,n,e,a,t,c,X){const o=qr(r,this.pp,{x:0,y:0}),i=this,K=Lr(X,o);this.cp=K;const P=wr.arcToBezier({px:this.pp.x,py:this.pp.y,cx:K.x,cy:K.y,rx:n,ry:e,xAxisRotation:a,largeArcFlag:t,sweepFlag:c});return P.forEach(((r,n)=>{const e=0===n?i.pp:{x:P[0].x,y:P[0].y},a={x:r.x1,y:r.y1},t={x:r.x2,y:r.y2},c={x:r.x,y:r.y},X=wr.cubicBezierLength(e,wr.cubicBezierCoefficients({p0:e,cntrl1:a,cntrl2:t,p1:c}));i.stack.push({type:"C",p0:e,cntrl1:a,cntrl2:t,p1:c,length:X,pointAt(r){return wr.bezierTransition(this.p0,this.cntrl1,this.cntrl2,this.p1,r)}}),i.length+=X,Dr(i.stack[i.stack.length-1],i.stack[i.stack.length-2],i.minMax,i.BBox)})),this.pp=this.cp,this.cntrl=null,this},fetchXY:function(){return{x:parseFloat(this.pathArr[this.currPathArr+=1]),y:parseFloat(this.pathArr[this.currPathArr+=1])}}},Er.prototype.points=function(r){if(void 0===this.f&&(this.f=.3),void 0===this.t&&(this.t=.6),0===r.length)return;this.m(!0,{x:r[0].x,y:r[0].y});var n=0,e=0,a=0;let t=0,c=0;for(var X=r[0],o=1;o""!==r&&","!==r)).map((r=>r.replace(/\$/g,"e-")));for(let r=0;r2){const e=n[r].split("."),a=[`${e[0]}.${e[1]}`];for(let r=2;rthis.length)return null;const e=this.getPointAtLength(r),a=this.getPointAtLength(r+("src"===n?-1*r*.01:.01*r));return Math.atan2(a.y-e.y,a.x-e.x)},Er.prototype.getPointAtLength=function(r){let n={x:0,y:0},e=r;return this.stack.every((r=>(e-=r.length,Math.floor(e)>=0||(n=r.pointAt((r.length+e)/(0===r.length?1:r.length)),!1)))),n},Er.prototype.execute=function(r,n){let e;n||r.beginPath();for(let n=0;nr=r.concat(n)),[]),d=[];for(let r=0;r=0;X-=1){var o=r[X],i={x:n.x,y:n.y};if(o.bbox&&(en(o,i),o.in({x:i.x,y:i.y})&&(o.children&&o.children.length>0?(c=nn(o.children,{x:i.x,y:i.y},e,a),c&&(t=c)):t=o,o.events[a]&&"function"==typeof o.events[a]&&o.events[a](e),t)))break}return t||"rootNode"!==o.attr.id||(t=o,o.events[a]&&"function"==typeof o.events[a]&&o.events[a](e)),t}function en(r,n){let e=0,a=0,t=1,c=1;const X=n;if(r.attr.transform&&r.attr.transform.translate&&([e,a]=r.attr.transform.translate,X.x-=e,X.y-=a),r.attr.transform&&r.attr.transform.scale&&(t=void 0!==r.attr.transform.scale[0]?r.attr.transform.scale[0]:1,c=void 0!==r.attr.transform.scale[1]?r.attr.transform.scale[1]:t,X.x/=t,X.y/=c),r.attr.transform&&r.attr.transform.rotate){const n=r.attr.transform.rotate[0],e={x:r.attr.transform.rotate[1],y:r.attr.transform.rotate[2]},a=X.x,t=X.y,c=e.x,P=e.y;var o=Math.PI/180*n,i=Math.cos(o),K=Math.sin(o);X.x=i*(a-c)+K*(t-P)+c,X.y=i*(t-P)-K*(a-c)+P}}Hr.prototype.wheelEventCheck=function(r){const n=this;if(this.wheelNode)this.wheelNode.events.zoom.zoomExecute(this.wheelNode,r,n),$r+=1,this.wheelHndl&&(clearTimeout(this.wheelHndl),this.wheelHndl=null,rn=$r),this.wheelHndl=setTimeout((function(){rn!==$r?rn=$r:(n.wheelHndl=null,n.wheelNode.events.zoom.onZoomEnd(n.wheelNode,r,n),n.wheelNode=null,$r=0)}),100);else{let e=nn([this.vDom],{x:r.offsetX,y:r.offsetY},r,"wheel");e=e||this.vDom,e&&e.events.zoom&&(e.events.zoom.disableWheel||(e.events.zoom.zoomExecute(e,r,n),this.wheelNode=e))}};const an={fill:"fillStyle",stroke:"strokeStyle",lineDash:"setLineDash",opacity:"globalAlpha","stroke-width":"lineWidth","stroke-dasharray":"setLineDash"},tn={fillStyle:"fill",strokeStyle:"stroke",lineDash:"stroke-dasharray",globalAlpha:"opacity",lineWidth:"stroke-width",setLineDash:"stroke-dasharray"},cn=["Courier","Courier-Bold","Courier-Oblique","Courier-BoldOblique","Helvetica","Helvetica-Bold","Helvetica-Oblique","Helvetica-BoldOblique","Symbol","Times-Roman","Times-Bold","Times-Italic","Times-BoldItalic","ZapfDingbats"];let Xn=0;const on=G,Kn=cr,Pn=B,sn=window.ResizeObserver||n;const un=function(r,n,e){return function(a){r.attr[n]=e.call(r,a)}},mn=function(r,n,e,a){const t=[];return"function"==typeof a?function(e){r[n](a.call(r,e))}:(a.forEach(((r,a)=>{let c;c=e&&void 0!==e[a]?e[a]:"scale"===n?1:0,t.push(on.intermediateValue.bind(null,c,r))})),function(e){r[n](t.map((r=>r(e))))})},ln=function(r,n,e,a){return function(t){r.attr[n]=on.intermediateValue(e,a,t)}},dn=function(r,n,e,a){let t,c,X;if("function"==typeof a)return function(e){r.style[n]=a.call(r,r.dataObj,e)};if(t=e,isNaN(a)){if(br.isTypeColor(a)){const e=br.transition(t,a);return function(a){r.style[n]=e(a)}}t=t.match(/(\d+)/g),X=a.match(/(\d+)/g),c=a.match(/\D+$/),t=parseInt(t.length>0?t[0]:0,10),X=parseInt(X.length>0?X[0]:0,10),c=c.length>0?c[0]:"px"}else t=void 0!==e?e:1,X=a,c=0;return function(e){r.style[n]=on.intermediateValue(t,X,e)+c}};function gn(r,n){let e={},a=null;for(let t in r)a=r[t],t=n[t]||t,e[t]=a;return e}const hn=function(r,n,e){const a=e.attr||{};let t=e.style||{};const c=n.attr||{};let X=n.style||{};const o=[],i=["WEBGL","canvas"].includes(r.nodeType)?an:tn;if(X=gn(X,i),t=gn(t,i),"function"!=typeof a)for(const n in a)if("transform"!==n){const t=a[n];"function"==typeof t?o[o.length]=function(e){r.attr[n]=t.call(r,e)}:"d"===n?r.morphTo(e):"points"===n?console.log("write points mapper"):o[o.length]=ln(r,n,c[n],a[n])}else{const e=a[n];if("function"==typeof e)o[o.length]=un(r,n,e);else{let n=c.transform;n||(r.setAttr("transform",{}),n={});const e=Object.keys(a.transform);for(let t=0,c=e.length;t{const t=a.indexOf(e(r,n));return-1!==t&&(a[t]=null,!0)})),t}const fn={};fn.push={value:function(r){"[object Array]"!==Object.prototype.toString.call(r)&&(r=[r]);for(let n=0,e=r.length;n{if(!r)return!1;const a="."===t?r.attr?.class:"#"===t?r.attr?.id:r.nodeName;return(!n||n.includes(r.dataObj))&&a===e};for(let r=0;r{if(!r)return!1;const t=r.attr||{},c="."===a?t.class:"#"===a?t.id:r.nodeName;return(!n||r.dataObj===n)&&c===e};for(let n of this.children){if(c(n,"."===a||"#"===a?t:"group"===r?"g":r)){e=n;break}}return e},Cn.prototype.join=Wn,Cn.prototype.data=function(r){return r?(this.dataObj=r,this):this.dataObj},Cn.prototype.interrupt=function(){if(!this.ctx||"pdf"!==this.ctx.type_)return Pn.interruptNodeAnimations(this),this},Cn.prototype.animateTo=function(r,n){if(!this.ctx||"pdf"!==this.ctx.type_)return Pn.add((Xn+=1,Xn),hn(this,n||this,r),Kn(r.ease)),this},Cn.prototype.animateExe=function(r,n){if(!this.ctx||"pdf"!==this.ctx.type_)return hn(this,n||this,r)};function vn(r,n,e,a){let t,c;n||(n=[]);const X=e&&e.attr?Object.keys(e.attr):[],o=e&&e.style?Object.keys(e.style):[],i=!e||(void 0===e.bbox||e.bbox);return this.stack=n.map(((n,K)=>{const P=this.createNode(r.ctx,{el:e.el,bbox:i},a);for(let r=0,a=o.length;r{const t="function"==typeof e?e.call(r,r.dataObj,a):e;r.setAttr(n,t)};for(let a=0,t=this.stack.length;a1?e(t,r,n,a):"function"==typeof r?t.setAttr(r.call(t,t.dataObj,a)):"object"==typeof r&&null!==r&&Object.entries(r).forEach((([r,n])=>{e(t,r,n,a)}))}return this},fetchEls:function(r,n){let e;const a=[];for(let t=0;t{const t="function"==typeof e?e.call(r,r.dataObj,a):e;r.setStyle(n,t)};for(let a=0,t=this.stack.length;a1?e(t,r,n,a):"function"==typeof r?t.setStyle(r.call(t,t.dataObj,a)):"object"==typeof r&&Object.entries(r).forEach((([r,n])=>{e(t,r,n,a)}))}return this},translate:function(r){let n;for(let e=0,a=this.stack.length;e"push"===a?(...a)=>(Pn.vDomChanged(n.vDomIndex),e&&(n.BBoxUpdate=!0),r.push(...a)):"pop"===a?(...a)=>(Pn.vDomChanged(n.vDomIndex),e&&(n.BBoxUpdate=!0),r.pop(...a)):r[a],set:(r,a,t)=>(r[a]=t,Pn.vDomChanged(n.vDomIndex),e&&(n.BBoxUpdate=!0),!0),deleteProperty(){return Pn.vDomChanged(n.vDomIndex),e&&(n.BBoxUpdate=!0),Reflect.deleteProperty(...arguments)}};return new Proxy(r||[],a)}const On=B;let Tn=0;function kn(){return Tn+=1,Tn}const Yn=function(){vn.apply(this,arguments)};function bn(r,n={}){this.pDom=r;const e=n.id?n.id:"mask-"+Math.ceil(1e3*Math.random());this.id=n.id||e,n.id=e,this.defs||(this.defs=r.createEl({el:"defs"})),this.mask=this.defs.createEl({el:"mask",attr:n,style:{}})}function Un(r,n={}){this.pDom=r;const e=n.id?n.id:"clip-"+Math.ceil(1e3*Math.random());this.id=n.id||e,n.id=e,this.defs||(this.defs=r.createEl({el:"defs"})),this.clip=this.defs.createEl({el:"clipPath",attr:n,style:{}})}function wn(r,n={}){this.pDom=r;const e=n.id?n.id:"pattern-"+Math.ceil(1e3*Math.random());this.id=n.id||e,n.id=e,this.defs||(this.defs=r.createEl({el:"defs"})),this.pattern=this.defs.createEl({el:"pattern",attr:n,style:{}})}function Rn(r){let n="";for(const e in r)"rotate"===e?n+=`${e}(${r.rotate[0]+" "+(r.rotate[1]||0)+" "+(r.rotate[2]||0)}) `:"skew"===e?(r.skew[0]&&(n+=`skewX(${r[e][0]}) `),r.skew[1]&&(n+=`skewY(${r[e][1]}) `)):r[e].length>1?n+=`${e}(${r[e].join(" ")}) `:n+=`${e}(${r[e]}) `;return n}function Vn(r,n,e){const a={set:(n,a,t)=>(null!==t?("points"===a&&(t=function(r){if("[object Array]"!==Object.prototype.toString.call(r))return;return r.reduce((function(r,n){return r+n.x+","+n.y+" "}),"")}(t)),"attr"===r?("transform"===a&&(t=Vn("transform",t,e)),e.changedAttribute[a]=t,e.attrChanged=!0):"style"===r?(br.RGBAInstanceCheck(t)&&(t=t.rgba),e.changedStyles[a]=t,e.styleChanged=!0):"transform"===r&&("translate"===a||"scale"===a||"skew"===a?t=Array.isArray(t)&&t.length>0?[t[0],t[1]?t[1]:t[0]]:[0,0]:"rotate"===a&&(t=Array.isArray(t)&&t.length>0?[t[0]||0,t[1]||0,t[2]||0]:[0,0,0]),e.changedStyles.transform=n,e.attrChanged=!0),n[a]=t,On.vDomChanged(e.vDomIndex)):delete n[a],!0),deleteProperty:(r,n)=>(n in r&&(delete r[n],On.vDomChanged(e.vDomIndex)),!0)};return new Proxy(Object.assign({},n),a)}function Dn(r,n,e){this.config=r,this.type=n||"linear",this.pDom=e,this.defs=this.pDom.createEl({el:"defs"})}(Yn.prototype=new vn).constructor=Yn,Yn.prototype.createNode=function(r,n,e){return En(n,e)},bn.prototype.exe=function(){return`url(#${this.id})`},Un.prototype.exe=function(){return`url(#${this.id})`},wn.prototype.exe=function(){return`url(#${this.id})`},Dn.prototype.exe=function(){return`url(#${this.config.id})`},Dn.prototype.linearGradient=function(){const r=this;return this.linearEl=this.defs.join([1],"linearGradient",{action:{enter(n){const e=this.createEls(n.linearGradient,{el:"linearGradient"}).setAttr({id:r.config.id,x1:`${r.config.x1}%`,y1:`${r.config.y1}%`,x2:`${r.config.x2}%`,y2:`${r.config.y2}%`,spreadMethod:r.config.spreadMethod||"pad",gradientUnits:r.config.gradientUnits||"objectBoundingBox"});r.config.gradientTransform&&e.setAttr("gradientTransform",Rn(r.config.gradientTransform))},exit(r){r.linearGradient.remove()},update(n){n.linearGradient.setAttr({id:r.config.id,x1:`${r.config.x1}%`,y1:`${r.config.y1}%`,x2:`${r.config.x2}%`,y2:`${r.config.y2}%`,spreadMethod:r.config.spreadMethod||"pad",gradientUnits:r.config.gradientUnits||"objectBoundingBox"}),r.config.gradientTransform&&n.linearGradient.setAttr("gradientTransform",Rn(r.config.gradientTransform))}}}),this.linearEl=this.linearEl.fetchEl("linearGradient"),this.linearEl.fetchEls("stop").remove(),this.linearEl.createEls(this.config.colorStops,{el:"stop",attr:{offset:r=>`${r.offset}%`,"stop-color":function(r){return r.color}}}),this},Dn.prototype.radialGradient=function(){const r=this,{innerCircle:n={},outerCircle:e={}}=this.config;return this.defs||(this.defs=this.pDom.createEl({el:"defs"})),this.radialEl=this.defs.join([1],"radialGradient",{action:{enter(a){const t=this.createEls(a.radialGradient,{el:"radialGradient"}).setAttr({id:r.config.id,cx:`${n.x}%`,cy:`${n.y}%`,r:`${n.r}%`,fx:`${e.x}%`,fy:`${e.y}%`,spreadMethod:r.config.spreadMethod||"pad",gradientUnits:r.config.gradientUnits||"objectBoundingBox"});r.config.gradientTransform&&t.setAttr("gradientTransform",Rn(r.config.gradientTransform))},exit(r){r.radialGradient.remove()},update(a){a.radialGradient.setAttr({id:r.config.id,cx:`${n.x}%`,cy:`${n.y}%`,r:`${n.r}%`,fx:`${e.x}%`,fy:`${e.y}%`,spreadMethod:r.config.spreadMethod||"pad",gradientUnits:r.config.gradientUnits||"objectBoundingBox"}),r.config.gradientTransform&&a.radialGradient.setAttr("gradientTransform",Rn(r.config.gradientTransform))}}}),this.radialEl=this.radialEl.fetchEl("radialGradient"),this.radialEl.fetchEls("stop").remove(),this.radialEl.createEls(this.config.colorStops,{el:"stop",attr:{offset:r=>`${r.offset}%`,"stop-color":function(r){return r.color}}}),this},Dn.prototype.colorStops=function(r){return"[object Array]"===Object.prototype.toString.call(r)&&(this.config.colorStops=r,"linear"===this.type?this.linearGradient():"radial"===this.type&&this.radialGradient())};const Ln={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml"},Sn=function(r){return document.createElementNS(Ln.svg,r)},qn=function(r,n){return document.createElementNS(Ln[r],n)};function En(r,n){let e=null;const a=r.el.indexOf(":");if(a>=0)e=qn(r.el.slice(0,a),r.el.slice(a+1));else if("group"===r.el)e=Sn("g");else e=Sn(r.el);const t=new Fn(e,r,kn(),n);return r.dataObj&&(e.dataObj=r.dataObj),t}const Fn=function(r,n,e,a){this.dom=r,this.nodeName=r.nodeName,this.changedAttribute={},this.changedStyles={},this.id=e,this.nodeType="svg",this.dom.nodeId=e,this.children=[],this.vDomIndex=a,this.events={},this.style=Vn("style",{},this),this.attr=Vn("attr",{},this),n.style&&this.setStyle(n.style),n.attr&&this.setAttr(n.attr)};function zn(r,n){const e=n.indexOf(":"),a=r.changedAttribute[n];e>=0?r.dom.setAttributeNS(Ln[n.slice(0,e)],n.slice(e+1),a):"text"===n?r.dom.textContent=a:"d"===n?Jr(a)?r.dom.setAttribute(n,a.fetchPathString()):r.dom.setAttribute(n,a):"onerror"===n||"onload"===n?r.dom[n]=function(n){a.call(r,n)}:r.dom.setAttribute(n,a)}function In(r){r.dom.setAttribute("transform",Rn(r.attr.transform))}function Gn(r){if(r.deleted=!0,!r.deleted)for(let n=0;n{d.addPointer(r),r.target.drag_&&(r.target.drag_(r,"pointerdown",d),h=r.target)})),l.dom.addEventListener("pointerup",(r=>{h&&(h.drag_(r,"pointerup",d),h=null),d.removePointer(r)})),l.dom.addEventListener("pointermove",(r=>{r.preventDefault(),h&&h.drag_(r,"pointermove",d)})),On.execute(),X&&xn(l,g),l}function _n(r){let n;switch(r){case"point":n={vertexShader:"#version 300 es\n precision highp float;\n in vec2 a_position;\n in vec4 a_color;\n in float a_size;\n in mat3 a_transformMatrix;\n out vec4 v_color;\n void main() {\n gl_Position = vec4(a_transformMatrix * vec3(a_position, 1), 1);\n gl_PointSize = a_size;\n v_color = a_color;\n }\n ",fragmentShader:"#version 300 es\n precision mediump float;\n in vec4 v_color;\n out vec4 fragColor;\n void main() {\n fragColor = v_color;\n }\n "};break;case"circle":n={vertexShader:"#version 300 es\n precision highp float;\n in vec2 a_position;\n in vec4 a_color;\n in float a_radius;\n in mat3 a_transformMatrix;\n out vec4 v_color;\n\n void main() {\n gl_Position = vec4(a_transformMatrix * vec3(a_position, 1), 1);\n gl_PointSize = a_radius; // * a_transform.z * u_transform.z;\n v_color = a_color;\n }\n ",fragmentShader:"#version 300 es\n precision mediump float;\n in vec4 v_color;\n out vec4 fragColor;\n void main() {\n float r = 0.0, delta = 0.0, alpha = 1.0;\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n r = dot(cxy, cxy);\n if(r > 1.0) {\n discard;\n }\n delta = 0.09;\n alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);\n fragColor = v_color * alpha;\n }\n "};break;case"image":n={vertexShader:"#version 300 es\n precision highp float;\n in vec2 a_position;\n in vec2 a_texCoord;\n uniform mat3 u_transformMatrix;\n out vec2 v_texCoord;\n\n void main() {\n gl_Position = vec4(u_transformMatrix * vec3(a_position, 1), 1);\n v_texCoord = a_texCoord;\n }\n ",fragmentShader:"#version 300 es\n precision mediump float;\n uniform sampler2D u_image;\n uniform float u_opacity;\n in vec2 v_texCoord;\n out vec4 fragColor;\n void main() {\n vec4 col = texture(u_image, v_texCoord);\n if (col.a == 0.0) {\n discard;\n } else {\n fragColor = col;\n fragColor.a *= u_opacity;\n }\n }\n "};break;case"polyline":case"polygon":n={vertexShader:"#version 300 es\n precision highp float;\n in vec2 a_position;\n uniform mat3 u_transformMatrix;\n\n void main() {\n gl_Position = vec4(u_transformMatrix * vec3(a_position, 1), 1);\n }\n ",fragmentShader:"#version 300 es\n precision mediump float;\n uniform vec4 u_color;\n out vec4 fragColor;\n void main() {\n fragColor = u_color;\n }\n "};break;case"rect":default:n={vertexShader:"#version 300 es\n precision highp float;\n in vec2 a_position;\n in vec4 a_color;\n in mat3 a_transformMatrix;\n out vec4 v_color;\n\n void main() {\n gl_Position = vec4(a_transformMatrix * vec3(a_position, 1), 1);\n v_color = a_color;\n }\n ",fragmentShader:"#version 300 es\n precision mediump float;\n in vec4 v_color;\n out vec4 fragColor;\n void main() {\n fragColor = v_color;\n }\n "};break;case"line":n={vertexShader:"#version 300 es\n precision highp float;\n in vec2 a_position;\n in vec4 a_color;\n in mat3 a_transformMatrix;\n out vec4 v_color;\n\n void main() {\n gl_Position = vec4(a_transformMatrix * vec3(a_position, 1), 1);\n v_color = a_color;\n }\n ",fragmentShader:"#version 300 es\n precision mediump float;\n in vec4 v_color;\n out vec4 fragColor;\n void main() {\n fragColor = v_color;\n }\n "}}return n}Fn.prototype=new Cn,Fn.prototype.node=function(){return this.execute(),this.dom},Fn.prototype.transFormAttributes=function(){const r=this;for(const n in r.changedAttribute)"transform"!==n?zn(r,n):In(r);this.changedAttribute={}},Fn.prototype.scale=function(r){return this.attr.transform||(this.attr.transform=Vn("transform",{},this)),this.attr.transform.scale=r,this},Fn.prototype.skew=function(r){return this.attr.transform||(this.attr.transform=Vn("transform",{},this)),this.attr.transform.skew=r,this},Fn.prototype.translate=function(r){return this.attr.transform||(this.attr.transform=Vn("transform",{},this)),this.attr.transform.translate=r,this},Fn.prototype.rotate=function(r){return this.attr.transform||(this.attr.transform=Vn("transform",{},this)),this.attr.transform.rotate=r,this},Fn.prototype.setStyle=function(r,n){if(2===arguments.length)this.style[r]=n;else if(1===arguments.length&&"object"==typeof r)for(const n in r)this.style[n]=r[n];return this},Fn.prototype.setAttr=function(r,n){if(2===arguments.length)this.attr[r]=n;else if(1===arguments.length&&"object"==typeof r)for(const n in r)this.attr[n]=r[n];return this},Fn.prototype.execute=function(){if(this.styleChanged||this.attrChanged){this.transFormAttributes();for(let r=0,n=this.children.length;r=r[0][0]*n&&a[0]<=r[1][0]*n&&a[1]>=r[0][1]*e&&a[1]<=r[1][1]*e}(a,[c,X],[t[0]+n,t[1]+e])&&(n/=c,e/=X,r.dx=n,r.dy=e,t[0]/=c,t[1]/=X,t[0]+=n,t[1]+=e,t[0]*=c,t[1]*=X),r}const $n=function(){const r=this;this.dragStartFlag=!1,this.dragExtent=[[-1/0,-1/0],[1/0,1/0]],this.event={x:0,y:0,dx:0,dy:0,transform:{translate:[0,0],scale:[1,1]}},this.onDragStart=function(n,e){r.event.x=e.offsetX,r.event.y=e.offsetY,r.event.dx=0,r.event.dy=0,r.dragStartFlag=!0},this.onDrag=function(){},this.onDragEnd=function(){r.event.x=event.offsetX,r.event.y=event.offsetY,r.event.dx=0,r.event.dy=0,r.dragStartFlag=!1}};function re(r,n){return n<=r[0]?r[0]:n>=r[1]?r[1]:n}function ne(r,n,e,a){return r.translate[0]/=n,r.translate[1]/=n,r.translate[0]-=a[0]/n-a[0]/e,r.translate[1]-=a[1]/n-a[1]/e,r.scale=[e,e],r.translate[0]*=e,r.translate[1]*=e,r}$n.prototype={dragExtent:function(r){return this.dragExtent=r,this},dragStart:function(r){const n=this;return"function"==typeof r&&(this.onDragStart=function(e,a){n.event.x=a.offsetX,n.event.y=a.offsetY,n.event.dx=0,n.event.dy=0,r.call(e,n.event),n.dragStartFlag=!0}),this},drag:function(r){const n=this;return"function"==typeof r&&(this.onDrag=function(e,a){const t=a.offsetX-n.event.x,c=a.offsetY-n.event.y;n.event.x=a.offsetX,n.event.y=a.offsetY,n.event=Zn(this.event,{dx:t,dy:c},n.dragExtent),r.call(e,n.event)}),this},dragEnd:function(r){const n=this;return"function"==typeof r&&(this.onDragEnd=function(e,a){n.dragStartFlag=!1,n.event.x=a.offsetX,n.event.y=a.offsetY,n.event.dx=0,n.event.dy=0,r.call(e,n.event)}),this},bindMethods:function(r){const n=this;r.dragTo=function(e,a){n.dragTo(r,e,a)}},execute:function(r,n,e){const a=this;this.event.e=n,n.preventDefault&&n.preventDefault(),this.dragStartFlag||"mousedown"!==e&&"pointerdown"!==e?this.onDragEnd&&this.dragStartFlag&&("mouseup"===e||"mouseleave"===e||"pointerleave"===e||"pointerup"===e)?a.onDragEnd(r,n):this.dragStartFlag&&this.onDrag&&a.onDrag(r,n):a.onDragStart(r,n)}};const ee=function(){const r=this;this.event={x:0,y:0,dx:0,dy:0,distance:0},this.event.pointers=[],this.event.transform={translate:[0,0],scale:[1,1]},this.zoomBy_=.001,this.zoomExtent_=[0,1/0],this.zoomStartFlag=!1,this.zoomDuration=250,this.onZoomStart=function(n,e){r.event.x=e.offsetX,r.event.y=e.offsetY,r.event.dx=0,r.event.dy=0,r.zoomStartFlag=!0,r.event.distance=0},this.onZoom=function(n,e){r.event.x=e.offsetX,r.event.y=e.offsetY},this.onZoomEnd=function(n,e){r.event.x=e.offsetX,r.event.y=e.offsetY,r.event.dx=0,r.event.dy=0,r.zoomStartFlag=!1,r.event.distance=0},this.onPanStart=function(){},this.onPan=function(){},this.onPanEnd=function(){},this.disableWheel=!1,this.disableDbclick=!1};ee.prototype.zoomStart=function(r){const n=this;return"function"==typeof r&&(this.zoomStartExe=r,this.onZoomStart=function(e,a,t){if(t.pointers&&2===t.pointers.length){const r=t.pointers;a={x:r[0].offsetX+.5*(r[1].offsetX-r[0].offsetX),y:r[0].offsetY+.5*(r[1].offsetY-r[0].offsetY)}}n.event.x=a.offsetX,n.event.y=a.offsetY,n.event.dx=0,n.event.dy=0,n.zoomStartFlag||r.call(e,n.event),n.zoomStartFlag=!0,n.event.distance=0}),this},ee.prototype.zoom=function(r){const n=this;return"function"==typeof r&&(this.zoomExe=r,this.onZoom=function(e,a){const t=n.event.transform,c=t.scale[0];let X=c;const o=a.deltaY,i=a.offsetX,K=a.offsetY;X=re(n.zoomExtent_,X+-1*o*n.zoomBy_),n.event.transform=ne(t,c,X,[i,K]),n.event.x=i,n.event.y=K,r.call(e,n.event)}),this},ee.prototype.zoomEnd=function(r){const n=this;return"function"==typeof r&&(this.zoomEndExe=r,this.onZoomEnd=function(e,a){n.event.x=a.offsetX,n.event.y=a.offsetY,n.event.dx=0,n.event.dy=0,n.zoomStartFlag=!1,r.call(e,n.event),n.event.distance=0}),this},ee.prototype.zoomTransition=function(){},ee.prototype.zoomExecute=function(r,n,e){this.eventType="zoom",n.preventDefault&&n.preventDefault(),this.zoomStartFlag?this.onZoom(r,n):this.onZoomStart(r,n,e)},ee.prototype.zoomPinch=function(r,n,e){const a=e.pointers;if(n.preventDefault&&n.preventDefault(),2===e.pointers.length)if(this.zoomStartFlag){const e=this.event.distance;for(var t=0;t0&&(n.translateX=r.translate[0],n.translateY=r.translate[1]),r.scale&&r.scale.length>0&&(n.scaleX=r.scale[0],n.scaleY=r.scale[1]||n.scaleX),r.rotate&&r.rotate.length>0&&(n.angle=r.rotate[0])),n}function ue(){const r=this,{transform:n,points:e=[]}=r.attr,{translateX:a,translateY:t,scaleX:c,scaleY:X}=se(n);if(e&&e.length>0){let n=e[0].x,o=e[0].x,i=e[0].y,K=e[0].y;for(let r=1;re[r].x&&(n=e[r].x),oe[r].y&&(i=e[r].y),K0&&(c=de("transform",c,e,a),e.children.forEach((function(r){r.applyTransformationMatrix(e.dom.transformMatrix)}))),n[t]=c,e&&e.dom&&e.dom.setAttr(t,c),a&&(e.BBoxUpdate=!0);else if("style"===r){let r=an[t]||t;"fillStyle"!==r&&"strokeStyle"!==r||br.RGBAInstanceCheck(c)||(c=br.colorToRGB(c)),e&&e.dom&&e.dom.setStyle(r,c),n[r]=c}else"transform"===r&&("translate"===t||"scale"===t||"skew"===t?c=Array.isArray(c)&&c.length>0?[c[0],c[1]?c[1]:c[0]]:[0,0]:"rotate"===t&&(c=Array.isArray(c)&&c.length>0?[c[0]||0,c[1]||0,c[2]||0]:[0,0,0]),n[t]=c,e&&e.dom&&e.dom.setAttr("transform",n),a&&(e.BBoxUpdate=!0));Xe.vDomChanged(e.vDomIndex)}else delete n[t];return!0},deleteProperty:(n,t)=>(t in n&&(delete n[t],Xe.vDomChanged(e.vDomIndex),"attr"===r&&a&&(e.BBoxUpdate=!0)),!0)};return new Proxy(Object.assign({},n),t)}function ge(r,n){const e=n.x||0,a=n.y||0,t=e+(n.width||0),c=a+(n.height||0);r[0]=r[4]=r[6]=e,r[1]=r[3]=r[9]=a,r[2]=r[8]=r[10]=t,r[5]=r[7]=r[11]=c}const he=function(){vn.apply(this,arguments)};function Ae(r,n,e){var a=r.createShader(e);if(r.shaderSource(a,n),r.compileShader(a),!r.getShaderParameter(a,r.COMPILE_STATUS)){var t=r.getShaderInfoLog(a);return console.error("*** Error compiling shader '"+a+"':"+t),r.deleteShader(a),null}return a}function fe(r,n){return function(r,n){var e=r.createProgram();if(n.forEach((function(n){r.attachShader(e,n)})),r.linkProgram(e),!r.getProgramParameter(e,r.LINK_STATUS)){var a=r.getProgramInfoLog(e);return console.error("Error in program linking:"+a),r.deleteProgram(e),null}return e}(r,[Ae(r,n.vertexShader,r.VERTEX_SHADER),Ae(r,n.fragmentShader,r.FRAGMENT_SHADER)])}function Ce(){this.BBox={x:0,y:0,width:0,height:0},this.BBoxHit={x:0,y:0,width:0,height:0}}function We(r,n,e){this.ctx=r,this.attr=Object.assign({},n),this.style=Object.assign({},e),this.projectionMatrix=me.projection(this.ctx.canvas.width/ce,this.ctx.canvas.height/ce),this.transformMatrix=me.multiply(this.projectionMatrix,me.identity()),this.attr.transform&&this.exec(le,null)}function Be(r,n,e){this.ctx=r,this.attr=Object.assign({},n),this.style=Object.assign({},e),this.projectionMatrix=me.projection(this.ctx.canvas.width/ce,this.ctx.canvas.height/ce),this.transformMatrix=me.multiply(this.projectionMatrix,me.identity()),this.attr.transform&&this.exec(le,null)}function ve(r,n,e){const a=this;this.ctx=r,this.attr=Object.assign({},n),this.style=Object.assign({},e),this.pointsGeometry=[],this.transform=[0,0,1,1],this.positionArray=new Float32Array(12),this.projectionMatrix=me.projection(this.ctx.canvas.width/ce,this.ctx.canvas.height/ce),this.transformMatrix=me.multiply(this.projectionMatrix,me.identity());for(let r in a.attr)this.setAttr(r,a.attr[r])}function Ne(r,n,e){this.ctx=r,this.attr=Object.assign({},n||{}),this.style=Object.assign({},e||{}),this.points=[],this.transform=[0,0,1,1];const a=[];if(this.projectionMatrix=me.projection(this.ctx.canvas.width/ce,this.ctx.canvas.height/ce),this.attr.points){const r=this.attr.points;for(let n=0,e=r.length;n=n&&r.x<=n+a&&r.y>=e&&r.y<=e+a},We.prototype.updateBBox=function(){const r=this,{transform:n,x:e=0,y:a=0,size:t=0}=r.attr,{translateX:c,translateY:X,scaleX:o,scaleY:i}=se(n);r.BBox={x:c+e*o,y:X+a*i,width:t*o,height:t*i},n&&n.rotate?r.BBoxHit=te.rotateBBox(this.BBox,n):r.BBoxHit=this.BBox},Be.prototype=new Ce,Be.prototype.constructor=Be,Be.prototype.setShader=function(r){this.shader=r,this.shader&&(this.shader.addVertex(this.attr.x||0,this.attr.y||0,this.attr.width||0,this.attr.height||0,this.pindex),this.shader.addColors(this.style.fillStyle||De,this.pindex),this.shader.addTransform(this.transformMatrix,this.pindex))},Be.prototype.applyTransformationMatrix=function(r){this.p_matrix=r,this.exec(le,r),this.shader&&this.shader.addTransform(this.transformMatrix,this.pindex)},Be.prototype.setAttr=function(r,n){this.attr[r]=n,"transform"===r&&this.exec(le,this.p_matrix),this.shader&&("x"===r||"width"===r||"y"===r||"height"===r?this.shader.updateVertex(this.pindex,this.attr.x||0,this.attr.y||0,this.attr.width||0,this.attr.height||0):"transform"===r&&this.shader.updateTransform(this.pindex,this.transformMatrix))},Be.prototype.in=function(r){const{x:n=0,y:e=0,width:a=0,height:t=0}=this.attr;return r.x>=n&&r.x<=n+a&&r.y>=e&&r.y<=e+t},Be.prototype.updateBBox=function(){const r=this,{transform:n,x:e=0,y:a=0,width:t=0,height:c=0}=r.attr,{translateX:X,translateY:o,scaleX:i,scaleY:K}=se(n);r.BBox={x:X+e*i,y:o+a*K,width:t*i,height:c*K},n&&n.rotate?r.BBoxHit=te.rotateBBox(this.BBox,n):r.BBoxHit=this.BBox},ve.prototype=new Ce,ve.prototype.constructor=ve,ve.prototype.setShader=function(r){this.shader=r},ve.prototype.applyTransformationMatrix=function(r){this.p_matrix=r,this.exec(le,r)},ve.prototype.setAttr=function(r,n){if(this.attr[r]=n,null!==n)if("d"===r){Jr(n)?(this.path=n,this.attr.d=n.fetchPathString()):this.path=jr(this.attr.d);let r=this.path.BBox,e=this.path.getPathTexture(this.style,!0);this.textureNode?this.textureNode.setAttr("src",e):this.textureNode=new ma(this.ctx,{src:e},this.vDomIndex),ge(this.positionArray,{x:0,y:0,height:r?.height??0,width:r?.width??0})}else"transform"===r&&this.exec(le,this.p_matrix?this.p_matrix:this.projectionMatrix);else delete this.attr[r]},ve.prototype.setStyle=function(r,n){null!==n?(this.style[r]=n,this.path&&this.textureNode.setAttr("src",this.path.getPathTexture(this.style,!0))):delete this.style[r]},ve.prototype.in=function(r){const{x:n=0,y:e=0}=r;let a=this.path.ctx,t=!1;return a.save(),t=a.isPointInPath(this.path.pathNode,n,e),a.restore(),t},ve.prototype.updateBBox=function(){const r=this,{transform:n}=r.attr,{translateX:e,translateY:a,scaleX:t,scaleY:c}=se(n);r.BBox=r.path?r.path.BBox:{x:0,y:0,width:0,height:0},r.BBox.x=e+r.BBox.x*t,r.BBox.y=a+r.BBox.y*c,r.BBox.width*=t,r.BBox.height*=c,n&&n.rotate?r.BBoxHit=te.rotateBBox(this.BBox,n):r.BBoxHit=this.BBox},Ne.prototype=new Ce,Ne.prototype.constructor=Ne,Ne.prototype.setShader=function(r){this.shader=r},Ne.prototype.applyTransformationMatrix=function(r){this.p_matrix=r,this.exec(le,r)},Ne.prototype.setAttr=function(r,n){if(this.attr[r]=n,"points"===r){const r=this.attr.points,n=[];for(let e=0,a=r.length;e=a&&r.x<=a+n&&r.y>=t&&r.y<=t+e},we.prototype.updateBBox=function(){const r=this,{transform:n,x:e=0,y:a=0,width:t=0,height:c=0}=r.attr,{translateX:X,translateY:o,scaleX:i,scaleY:K}=se(n);r.BBox={x:(X+e)*i,y:(o+a)*K,width:t*i,height:c*K},n&&n.rotate?r.BBoxHit=te.rotateBBox(this.BBox,n):r.BBoxHit=this.BBox},Re.prototype=new Ce,Re.prototype.constructor=Re,Re.prototype.setShader=function(r){this.shader=r},Re.prototype.applyTransformationMatrix=function(r){this.p_matrix=r,this.exec(le,r)},Re.prototype.setAttr=function(r,n){this.attr[r]=n,null!==n?"src"===r&&"string"==typeof n?n&&!Te[n]?(this.textureNode=new ma(this.ctx,{src:n},this.vDomIndex),Te[n]=this.textureNode):n&&Te[n]&&(this.textureNode=Te[n]):"src"===r&&n instanceof Cn?this.textureNode=new ma(this.ctx,{src:n},this.vDomIndex):"src"===r&&n instanceof ma?this.textureNode=n:"x"===r||"width"===r||"y"===r||"height"===r?ge(this.positionArray,this.attr):"transform"===r&&this.exec(le,this.p_matrix):delete this.attr[r]},Re.prototype.setStyle=function(r,n){n?this.style[r]=n:this.style[r]&&delete this.style[r]},Re.prototype.in=function(r){const{width:n=0,height:e=0,x:a=0,y:t=0}=this.attr;return r.x>=a&&r.x<=a+n&&r.y>=t&&r.y<=t+e},Re.prototype.updateBBox=function(){const r=this,{transform:n,x:e=0,y:a=0,width:t=0,height:c=0}=r.attr,{translateX:X,translateY:o,scaleX:i,scaleY:K}=se(n);r.BBox={x:(X+e)*i,y:(o+a)*K,width:t*i,height:c*K},n&&n.rotate?r.BBoxHit=te.rotateBBox(this.BBox,n):r.BBoxHit=this.BBox},Ve.prototype=new Ce,Ve.prototype.constructor=Ve,Ve.prototype.applyTransformationMatrix=function(r){this.p_matrix=r,this.exec(le,r),this.transformMatrix=me.multiply(this.transformMatrix,r)},Ve.prototype.setAttr=function(r,n){this.attr[r]=n,"shaderType"===r&&(this.shader=oa(this.ctx,this.attr,this.style,n,this.renderTarget,this.vDomIndex)),"transform"===r&&this.exec(le,this.p_matrix)},Ve.prototype.setShader=function(){},Ve.prototype.in=function(r){const n=r.x,e=r.y,{BBox:a}=this,{transform:t}=this.attr,{translateX:c,translateY:X,scaleX:o,scaleY:i}=se(t);return n>=(a.x-c)/o&&n<=(a.x-c+a.width)/o&&e>=(a.y-X)/i&&e<=(a.y-X+a.height)/i},Ve.prototype.updateBBox=function(r){const n=this;let e,a,t,c;const{transform:X}=n.attr,{translateX:o,translateY:i,scaleX:K,scaleY:P}=se(X);if(n.BBox={},r&&r.length>0){let n,X,o;for(let i=0;iX?X:e,t=void 0===t||t>o?o:t,a=void 0===a||a0?Array.from(r.transformTyped):r.transform,r.transformTyped=null;const t=n*e*9;let c=0;for(;c0?Array.from(r.typedPositionArray):r.positionArray,r.typedPositionArray=null;const t=n*e*2;let c=0;for(;c0?Array.from(r.typedColorArray):r.colorArray,r.typedColorArray=null;const t=n*e*4;let c=0;for(a=br.colorToRGB(a);c=2?2:Math.floor(u),P.setAttribute("height",t*ce),P.setAttribute("width",c*ce),P.style.height=`${t}px`,P.style.width=`${c}px`,P.style.position="absolute";let l,d,g=999999;a&&(a.appendChild(P),m=new v,i&&(g=Xe.addVdom(m)));const h=new ia(s,{el:"group",attr:{id:"rootNode"},ctx:function(r){r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.clearColor(X.r,X.g,X.b,X.a)}},Pe(),g);m&&m.rootNode(h);const A=h.execute.bind(h);h.container=a,h.domEl=P,h.height=t,h.width=c,h.type="WEBGL",h.ctx.pixelRatio=ce;let f=function(r){r.viewport(0,0,r.canvas.width,r.canvas.height),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)};h.execute=function(){f(this.ctx),this.updateBBox(),this.ctx.enable(this.ctx.BLEND),this.ctx.blendFunc(this.ctx.SRC_ALPHA,this.ctx.ONE_MINUS_SRC_ALPHA),A()},h.update=function(){this.execute()},h.getPixels=function(r,n,e,a){const t=new Uint8Array(e*a*4);return this.ctx.readPixels(r,n,e,a,this.ctx.RGBA,this.ctx.UNSIGNED_BYTE,t),t},h.putPixels=function(r,n,e){return this.ctx.putImageData(r,n,e)},h.clear=function(){f(this.ctx)},h.setClearColor=function(r){X=r},h.setClear=function(r){f=r};const C=function(n){if(r instanceof HTMLElement&&!document.body.contains(r)||r instanceof String&&!document.querySelector(r))return yn(h),void h.destroy();t=n.height,c=n.width,h.width=c,h.height=t,W(h.domEl,c,t),f(h.ctx),l&&l(),h.execute(),P.style.height=`${t}px`,P.style.width=`${c}px`},W=function(r,n,e){r.width=Math.floor(n*ce),r.height=Math.floor(e*ce),r.style.height=e+"px",r.style.width=n+"px"};if(h.onResize=function(r){l=r},h.destroy=function(){document.body.contains(this.container)&&this.container.contains(this.domEl)&&this.container.removeChild(this.domEl),Xe.removeVdom(g),yn(h,C)},h.onChange=function(r){d=r},h.invokeOnChange=function(){d&&d()},h.setPixelRatio=function(r){ce=r,this.ctx.pixelRatio=ce,W(this.domEl,this.width,this.height)},h.setSize=function(r,n){this.width=r,this.height=n,t=n,c=r,W(this.domEl,this.width,this.height),this.execute()},h.setViewBox=function(){},h.setStyle=function(r,n){this.domEl.style[r]=n},h.setAttr=function(r,n){"viewBox"===r&&this.setViewBox.apply(this,n.split(",")),P.setAttribute(r,n)},h.setContext=function(r,n){this.ctx[r]&&"function"==typeof this.ctx[r]?this.ctx[r].apply(null,n):this.ctx[r]&&(this.ctx[r]=n)},h.MeshGeometry=function(){return new ga(this.ctx)},h.PointsGeometry=function(){return new ha(this.ctx)},h.LineGeometry=function(){return new Aa(this.ctx)},h.createWebglTexture=function(r){return new ma(this.ctx,r,this.vDomIndex)},h.RenderTarget=function(r){return new la(this.ctx,r,this.vDomIndex)},o){const r=new Hr(h);P.addEventListener("mousemove",(n=>{n.preventDefault(),r.mousemoveCheck(n)})),P.addEventListener("mousedown",(n=>{r.mousedownCheck(n)})),P.addEventListener("mouseup",(n=>{r.mouseupCheck(n)})),P.addEventListener("mouseleave",(n=>{r.mouseleaveCheck(n)})),P.addEventListener("contextmenu",(n=>{r.contextmenuCheck(n)})),P.addEventListener("touchstart",(n=>{r.touchstartCheck(n)})),P.addEventListener("touchend",(n=>{r.touchendCheck(n)})),P.addEventListener("touchmove",(n=>{n.preventDefault(),r.touchmoveCheck(n)})),P.addEventListener("touchcancel",(n=>{r.touchcancelCheck(n)})),P.addEventListener("wheel",(n=>{r.wheelEventCheck(n)})),P.addEventListener("pointerdown",(n=>{r.addPointer(n),r.pointerdownCheck(n)})),P.addEventListener("pointerup",(n=>{r.removePointer(n),r.pointerupCheck(n)})),P.addEventListener("pointermove",(n=>{n.preventDefault(),r.pointermoveCheck(n)}))}return Xe.execute(),K&&h.container&&xn(h,C),h}function sa(r){const n=new Image;return n.crossOrigin="anonymous",n.onload=function(){r.update(),r.updated=!0,Xe.vDomChanged(r.vDomIndex)},n.onerror=function(r){},n}function ua(r,n){return new Uint8Array(new ArrayBuffer(r*n*4))}function ma(r,n,e){const a=this,t=r.getParameter(r.MAX_TEXTURE_SIZE);this.ctx=r,this.texture=r.createTexture(),this.type="TEXTURE_2D",this.width=n.width>t?t:n.width,this.height=n.height>t?t:n.height,this.border=n.border?n.border:0,this.format=n.format?n.format:"RGBA",this.type=n.type?n.type:"UNSIGNED_BYTE",this.warpS=n.warpS?n.warpS:"CLAMP_TO_EDGE",this.warpT=n.warpT?n.warpT:"CLAMP_TO_EDGE",this.magFilter=n.magFilter?n.magFilter:"LINEAR",this.minFilter=n.minFilter?n.minFilter:"LINEAR",this.mipMap=n.mipMap,this.updated=!1,this.image=null,this.vDomIndex=e,"string"==typeof n.src?(a.image=sa(a),a.image.src=n.src):n.src instanceof HTMLImageElement||n.src instanceof SVGImageElement||n.src instanceof HTMLCanvasElement||n.src instanceof Uint8Array?(a.image=n.src,a.update(),a.updated=!0):n.src instanceof Cn?(a.image=n.src.domEl,a.update(),a.updated=!0):(this.width&&this.height&&(a.image=ua(this.width,this.height),a.update()),a.updated=!0),Xe.vDomChanged(a.vDomIndex)}function la(r,n){this.ctx=r,this.fbo=r.createFramebuffer(),this.texture=n.texture,this.texture.updated||this.texture.update()}function da(){}function ga(){this.attributes={},this.drawType="TRIANGLES",this.indexes=null,this.drawRange=[0,0]}function ha(){this.attributes={},this.drawType="POINTS",this.indexes=null,this.drawRange=[0,0]}function Aa(){this.attributes={},this.drawType="LINES",this.indexes=null,this.drawRange=[0,0]}qe.prototype=new Ee,qe.prototype.constructor=qe,qe.prototype.applyAttributeToVao=function(r,n){this.ctx.bindVertexArray(this.vao),"a_transformMatrix"===r?(this.ctx.enableVertexAttribArray(n.attributeLocation+0),this.ctx.enableVertexAttribArray(n.attributeLocation+1),this.ctx.enableVertexAttribArray(n.attributeLocation+2),this.ctx.bindBuffer(n.bufferType,n.buffer),this.ctx.bufferData(n.bufferType,n.value,n.drawType),this.ctx.vertexAttribPointer(n.attributeLocation+0,n.size,n.valueType,!1,4*n.size*3,0),this.ctx.vertexAttribPointer(n.attributeLocation+1,n.size,n.valueType,!1,4*n.size*3,12),this.ctx.vertexAttribPointer(n.attributeLocation+2,n.size,n.valueType,!1,4*n.size*3,24)):(this.ctx.enableVertexAttribArray(n.attributeLocation),this.ctx.bindBuffer(n.bufferType,n.buffer),this.ctx.bufferData(n.bufferType,n.value,n.drawType),this.ctx.vertexAttribPointer(n.attributeLocation,n.size,n.valueType,!1,0,0))},qe.prototype.useProgram=function(){this.ctx.useProgram(this.program)},qe.prototype.applyUniforms=function(){for(const r in this.uniforms)this.uniforms[r].matrix?this.ctx[this.uniforms[r].type](this.uniforms[r].uniformLocation,this.uniforms[r].transpose,this.uniforms[r].value):this.uniforms[r].value instanceof ma?(this.ctx[this.uniforms[r].type](this.uniforms[r].uniformLocation,this.uniforms[r].value.texture),this.uniforms[r].value.loadTexture()):this.ctx[this.uniforms[r].type](this.uniforms[r].uniformLocation,this.uniforms[r].value)},qe.prototype.applyIndexes=function(){const r=this.indexesObj;this.ctx.bindBuffer(r.bufferType,r.buffer),this.ctx.bufferData(r.bufferType,r.value,r.drawType)},qe.prototype.draw=function(){this.ctx.drawArrays(this.ctx[this.geometry.drawType],this.geometry.drawRange[0],this.geometry.drawRange[1])},qe.prototype.drawElements=function(){this.ctx.drawElements(this.ctx[this.geometry.drawType],this.indexesObj.count,this.indexesObj.type?this.indexesObj.type:this.ctx.UNSIGNED_SHORT,this.indexesObj.offset)},qe.prototype.updateBBox=function(){return!0},qe.prototype.execute=function(){this.ctx.useProgram(this.program),this.applyUniforms(),this.ctx.bindVertexArray(this.vao),this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.update(),this.indexesObj?(this.applyIndexes(),this.drawElements()):this.draw(),this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.clear(),this.ctx.bindVertexArray(null)},qe.prototype.addUniform=function(r,n){this.uniforms[r]=Se(this.ctx,this.program,r,n),Xe.vDomChanged(this.vDomIndex)},qe.prototype.addAttribute=function(r,n){this.attributes[r]=n,this.attrObjs[r]=Le(this.ctx,this.program,r,n),this.applyAttributeToVao(r,this.attrObjs[r]),Xe.vDomChanged(this.vDomIndex)},qe.prototype.setAttributeData=function(r,n){const e=this.attrObjs[r];this.attributes[r].value=n,this.attrObjs[r].value=n,this.ctx.bindBuffer(e.bufferType,e.buffer),this.ctx.bufferData(e.bufferType,e.value,e.drawType),Xe.vDomChanged(this.vDomIndex)},qe.prototype.applyAttributeData=function(r,n){this.attributes[r].value=n,this.attrObjs[r].value=n;const e=this.attrObjs[r];this.ctx.bindBuffer(e.bufferType,e.buffer),this.ctx.bufferData(e.bufferType,this.attributes[e.attr].value,e.drawType),this.ctx.enableVertexAttribArray(e.attributeLocation),this.ctx.vertexAttribPointer(e.attributeLocation,e.size,e.valueType,!1,0,0)},qe.prototype.setUniformData=function(r,n){this.uniforms[r].value=n,Xe.vDomChanged(this.vDomIndex)},qe.prototype.applyUniformData=function(r,n){this.uniforms[r].value=n,this.uniforms[r].matrix?this.ctx[this.uniforms[r].type](this.uniforms[r].uniformLocation,this.uniforms[r].transpose,this.uniforms[r].value):this.ctx[this.uniforms[r].type](this.uniforms[r].uniformLocation,this.uniforms[r].value)},Ee.prototype.setAttr=function(r,n){if(this.attr[r]=n,"transform"===r){const{translateX:r,translateY:n,scaleX:e,scaleY:a}=se(this.attr.transform);this.selftransform=new Float32Array([r,n,e,a])}},Ee.prototype.translate=function(r){this.attr.transform.translate=r},Ee.prototype.scale=function(r){this.attr.transform.scale=r},Ee.prototype.rotate=function(r){this.attr.transform.rotate=r},ra.prototype=new Ee,ra.prototype.constructor=ra,ra.prototype.clear=function(r){Ze(this,r,1),Je(this,r,1),Ie(this,r,1);(this.sizeUpdate?this.pointsSize:this.typedSizeArray)[r]=void 0,this.filterSizeFlag=!0},ra.prototype.addTransform=function(r,n){Fe(this,n,1,r)},ra.prototype.updateTransform=function(r,n){ze(this,r,1,n)},ra.prototype.updateVertex=function(r,n,e){_e(this,r,1,[n,e])},ra.prototype.updateSize=function(r,n){(this.sizeUpdate?this.pointsSize:this.typedSizeArray)[r]=n},ra.prototype.updateColor=function(r,n){Qe(this,r,1,n)},ra.prototype.addVertex=function(r,n,e){Me(this,e,1,[r,n])},ra.prototype.addSize=function(r,n){this.pointsSize=this.typedSizeArray&&this.typedSizeArray.length>0?Array.from(this.typedSizeArray):this.pointsSize,this.pointsSize[n]=r,this.sizeUpdate=!0},ra.prototype.addColors=function(r,n){He(this,n,1,r)},ra.prototype.execute=function(){this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.update(),je(this),$e(this),Ge(this),this.sizeUpdate&&(this.filterSizeFlag&&(this.pointsSize=this.pointsSize.filter((function(r){return!isNaN(r)})),this.filterSizeFlag=!1),this.typedSizeArray=new Float32Array(this.pointsSize),this.pointsSize=[],this.sizeUpdate=!1),this.filterSizeFlag&&(this.typedSizeArray=this.typedSizeArray.filter((function(r){return!isNaN(r)})),this.filterSizeFlag=!1),this.shaderInstance.setAttributeData("a_size",this.typedSizeArray),this.geometry.setDrawRange(0,(this.typedPositionArray?.length??0)/2),this.shaderInstance.execute(),this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.update()},na.prototype=new Ee,na.prototype.constructor=na,na.prototype.clear=function(r){Ze(this,r,6),Je(this,r,6),Ie(this,r,6)},na.prototype.updateVertex=function(r,n,e,a,t){const c=n+a,X=e+t;_e(this,r,6,[n,e,c,e,n,X,n,X,c,e,c,X])},na.prototype.updateTransform=function(r,n){ze(this,r,6,n)},na.prototype.addTransform=function(r,n){Fe(this,n,6,r)},na.prototype.updateColor=function(r,n){Qe(this,r,6,n)},na.prototype.addVertex=function(r,n,e,a,t){const c=r+e,X=n+a;Me(this,t,6,[r,n,c,n,r,X,r,X,c,n,c,X])},na.prototype.addColors=function(r,n){He(this,n,6,r)},na.prototype.execute=function(){this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.update(),$e(this),Ge(this),je(this),this.geometry.setDrawRange(0,(this.typedPositionArray?.length??0)/2),this.shaderInstance.execute(),this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.clear()},ea.prototype=new Ee,ea.prototype.constructor=ea,ea.prototype.clear=function(r){Ze(this,r,2),Je(this,r,2)},ea.prototype.updateTransform=function(r,n){ze(this,r,2,n)},ea.prototype.addTransform=function(r,n){Fe(this,n,2,r)},ea.prototype.updateVertex=function(r,n,e,a,t){_e(this,r,2,[n,e,a,t])},ea.prototype.updateColor=function(r,n){Qe(this,r,2,n)},ea.prototype.addVertex=function(r,n,e,a,t){Me(this,t,2,[r,n,e,a])},ea.prototype.addColors=function(r,n){He(this,n,2,r)},ea.prototype.execute=function(){this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.update(),je(this),$e(this),Ge(this),this.geometry.setDrawRange(0,(this.typedPositionArray?.length??0)/2),this.shaderInstance.execute(),this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.clear()},aa.prototype=new Ee,aa.prototype.constructor=aa,aa.prototype.execute=function(r){this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.update();for(let n=0,e=r.length;n0?Array.from(this.typedSizeArray):this.pointsSize,this.pointsSize[n]=r,this.sizeUpdate=!0},ca.prototype.addColors=function(r,n){He(this,n,1,r)},ca.prototype.execute=function(){this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.update(),je(this),$e(this),Ge(this),this.sizeUpdate&&(this.filterSizeFlag&&(this.pointsSize=this.pointsSize.filter((function(r){return!isNaN(r)})),this.filterSizeFlag=!1),this.typedSizeArray=new Float32Array(this.pointsSize),this.pointsSize=[],this.sizeUpdate=!1),this.filterSizeFlag&&(this.typedSizeArray=this.typedSizeArray.filter((function(r){return!isNaN(r)})),this.filterSizeFlag=!1),this.shaderInstance.setAttributeData("a_radius",this.typedSizeArray),this.geometry.setDrawRange(0,(this.typedPositionArray?.length??0)/2),this.shaderInstance.execute(),this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.clear()},Xa.prototype=new Ee,Xa.prototype.constructor=Xa,Xa.prototype.execute=function(r){this.renderTarget&&this.renderTarget instanceof la&&this.renderTarget.update(),this.shaderInstance.useProgram(),this.shaderInstance.applyAttributeData("a_texCoord",this.textCoor);const n=void 0!==this.style.opacity?this.style.opacity:1;let e;for(let a=0,t=r.length;ar},fill:{prop:"fillColor",getValue:r=>r},strokeStyle:{prop:"strokeColor",getValue:r=>r},stroke:{prop:"strokeColor",getValue:r=>r},globalAlpha:{prop:"opacity",getValue:r=>r},lineDash:{prop:"dash",getValue:r=>r[0]},textAlign:{prop:"align",getValue:r=>r},font:{prop:"font",getValue:r=>{const n=r.match(/\b[A-Za-z]+[0-9]*[A-Za-z0-9]*\b/gm);return n&&n.length>0&&-1!==cn.indexOf(n[0])?n[0]:"Helvetica"}}},Wa=B,Ba=G;let va=0;const Na=ae.zoom(),xa=ae.drag();function ya(){return va+=1,va}function pa(r,n,e,a){const t={set(n,t,c){if(null===c)return delete n[t],!0;if("transform"===r&&["translate","scale","skew","rotate"].includes(t)?c=function(r,n){return["translate","scale","skew"].includes(r)?Array.isArray(n)&&n.length>0?[n[0],n[1]||n[0]]:[0,0]:"rotate"===r?Array.isArray(n)&&n.length>0?[n[0]||0,n[1]||0,n[2]||0]:[0,0,0]:void 0}(t,c):"style"===r&&(c=function(r){return br.RGBAInstanceCheck(r)&&(r=r.rgba),"#000"===r||"#000000"===r||"black"===r?"#010101":r}(c)),"transform"===t&&(c=pa("transform",c,e,a)),n[t]=c,e&&e.dom){const n="transform"===r?"setAttr":"style"===r?"setStyle":"setAttr";e.dom[n](t,c)}return!a||"attr"!==r&&"transform"!==r||(e.BBoxUpdate=!0),Wa.vDomChanged(e.vDomIndex),!0},deleteProperty:(n,t)=>(t in n&&(delete n[t],Wa.vDomChanged(e.vDomIndex),"attr"===r&&a&&(e.BBoxUpdate=!0)),!0)};return new Proxy(Object.assign({},n),t)}const Oa=function(){vn.apply(this,arguments)};function Ta(r){const n={translateX:0,translateY:0,scaleX:1,scaleY:1};return r&&(r.translate&&r.translate.length>0&&(n.translateX=r.translate[0],n.translateY=r.translate[1]),r.scale&&r.scale.length>0&&(n.scaleX=r.scale[0],n.scaleY=r.scale[1]||n.scaleX)),n}function ka(){const r=this,{transform:n,points:e=[]}=r.attr,{translateX:a,translateY:t,scaleX:c,scaleY:X}=Ta(n);let o=0;if(e&&e.length>0){let n=e[0].x,i=e[0].x,K=e[0].y,P=e[0].y;for(let r=1;re[r].x&&(n=e[r].x),ie[r].y&&(K=e[r].y),P{t.stop((r.offset||0)/100,r.color,r.opacity)})),t},Ya.prototype.linearGradient=function(r,n){const e=r.createLinearGradient(n.x+n.width*((this.config.x1||0)/100),n.y+n.height*((this.config.y1||0)/100),n.x+n.width*((this.config.x2||0)/100),n.y+n.height*((this.config.y2||0)/100));return(this.config.colorStops??[]).forEach((r=>{e.addColorStop((r.offset||0)/100,r.color)})),e},Ya.prototype.absoluteLinearGradient=function(r){const n=r.createLinearGradient(this.config.x1||0,this.config.y1||0,this.config.x2||0,this.config.y2||0);return(this.config.colorStops??[]).forEach((r=>{n.addColorStop(r.offset||0,r.color)})),n},Ya.prototype.absoluteLinearGradientPdf=function(r,n){const{translate:e=[0,0]}=n,a=r.linearGradient(e[0]+this.config.x1||0,e[1]+this.config.y1||0,e[0]+this.config.x2||0,e[1]+this.config.y2||0);return(this.config.colorStops??[]).forEach((r=>{a.stop(r.offset||0,r.color,r.opacity)})),a},Ya.prototype.radialGradient=function(r,n){const{innerCircle:e={},outerCircle:a={}}=this.config,t=r.createRadialGradient(n.x+n.width*(e.x||0)/100,n.y+n.height*(e.y||0)/100,n.width>n.height?n.width*(e.r||0)/100:n.height*(e.r||0)/100,n.x+n.width*(a.x||0)/100,n.y+n.height*(a.y||0)/100,n.width>n.height?n.width*(a.r||0)/100:n.height*(a.r||0)/100);return(this.config.colorStops??[]).forEach((r=>{t.addColorStop((r.offset||0)/100,r.color)})),t},Ya.prototype.radialGradientPdf=function(r,n,e){const{translate:a=[0,0]}=e,{innerCircle:t={},outerCircle:c={}}=this.config,X=r.radialGradient(a[0]+n.x+n.width*(t.x||0)/100,a[1]+0+n.height*(t.y||0)/100,t.r||0,a[0]+n.x+n.width*(c.x||0)/100,a[1]+0+n.height*(c.y||0)/100,c.r2||0);return(this.config.colorStops??[]).forEach((r=>{X.stop((r.offset||0)/100,r.color,r.opacity)})),X},Ya.prototype.absoluteRadialGradient=function(r){const{innerCircle:n={},outerCircle:e={}}=this.config,a=r.createRadialGradient(n.x||0,n.y||0,n.r||0,e.x||0,e.y||0,e.r||0);return(this.config.colorStops??[]).forEach((r=>{a.addColorStop((r.offset||0)/100,r.color)})),a},Ya.prototype.absoluteRadialGradientPdf=function(r,n,e){const{translate:a=[0,0]}=e,{innerCircle:t={},outerCircle:c={}}=this.config,X=r.radialGradient(a[0]+t.x||0,a[1]+t.y||0,t.r||0,a[0]+c.x||0,a[1]+c.y||0,c.r||0);return(this.config.colorStops??[]).forEach((r=>{X.stop((r.offset||0)/100,r.color)})),X},Ya.prototype.colorStops=function(r){return"[object Array]"===Object.prototype.toString.call(r)&&(this.config.colorStops=r,this)},wa.prototype.get=function(r){const n=this.imageData?this.imageData.pixels:[],e=(r.y-1)*(4*this.width)+4*(r.x-1);return"rgba("+n[e]+", "+n[e+1]+", "+n[e+2]+", "+n[e+3]+")"},wa.prototype.put=function(r,n){const e=(r.y-1)*(4*this.width)+4*(r.x-1);return this.imageData.pixels[e]=n[0],this.imageData.pixels[e+1]=n[1],this.imageData.pixels[e+2]=n[2],this.imageData.pixels[e+3]=n[3],this},Ra.prototype.setAttr=function(r,n){this.config[r]=n},Ra.prototype.exe=function(){return this.mask.execute(),this.mask.dom.ctx.globalCompositeOperation=this.config.globalCompositeOperation||"destination-atop",!0},Da.prototype.exe=function(){return this.clip.dom.ctx.beginPath(),this.clip.execute(),this.clip.dom.ctx.clip(),!0},Sa.prototype.repeat=function(r){this.repeatInd=r},Sa.prototype.exe=function(){return this.patternObj},Ea.prototype={render:function(r){const n=this;if(r.transform){const{transform:e}=r,{scale:a=[1,1],skew:t=[0,0],translate:c=[0,0]}=e,[X=1,o=X]=a,[i=0,K=i]=t,[P=0,s=P]=c;n.ctx.transform(X,i,K,o,P,s),e.rotate&&e.rotate.length>0&&(n.ctx.translate(e.rotate[1]||0,e.rotate[2]||0),n.ctx.rotate(e.rotate[0]*(Math.PI/180)),n.ctx.translate(-e.rotate[1]||0,-e.rotate[2]||0))}for(let r=0;r0&&(n.translate(t.rotate[1]||0,t.rotate[2]||0),n.rotate(t.rotate[0]*(Math.PI/180)),n.translate(-t.rotate[1]||0,-t.rotate[2]||0));for(let r=0;r=a&&r.x<=a+n&&r.y>=t&&r.y<=t+e},Ia.prototype=new Ea,Ia.prototype.constructor=Ia,Ia.prototype.setAttr=function(r,n){null==n&&null!=this.attr[r]?delete this.attr[r]:(this.attr[r]=n,("width"===r||"text"===r)&&this.attr.width&&this.attr.text&&this.fitWidth())},Ia.prototype.setStyle=function(r,n){null==n&&null!=this.style[r]?delete this.style[r]:(this.style[r]=n,"font"===r&&this.attr&&this.attr.width&&this.attr.text&&this.fitWidth())},Ia.prototype.fitWidth=function(){this.style.font&&(this.ctx.font=this.style.font);const r=this.attr.width,n=[];let e="",a=0;const t=this.attr.text.toString().split("\n").reduce(((n,e)=>(e.split(/( )/g).forEach((e=>{this.ctx.measureText(e).width0&&" "!==e&&n.push(e),e=t[a]),a++;e&&" "!==e&&n.push(e),this.textList=n},Ia.prototype.text=function(r){this.attr.text=r,this.attr.width&&this.fitWidth()},Ia.prototype.updateBBox=function(){const r=this;let n=1,e=0,{x:a=0,y:t=0,transform:c}=r.attr;const{translateX:X,translateY:o,scaleX:i,scaleY:K}=Ta(c),{doc:P}=r.ctx;if(this.style.font?(this.ctx.font=this.style.font,n=parseInt(this.style.font.replace(/[^\d.]/g,""),10)||1,r.textHeight=n+3):(r.textHeight=this.ctx.measureText("I2DJS-Z").fontBoundingBoxAscent,n=r.textHeight+7),this.attr.width&&this.textList&&this.textList.length>0?(e=this.attr.width,n*=this.textList.length):e=this.ctx.measureText(this.attr.text).width,"center"===this.style.textAlign?a-=e/2:"right"===this.style.textAlign&&(a-=e),P){const r=this.style.align??this.style.textAlign,e={...this.attr.width&&{width:this.attr.width},...this.style.lineGap&&{lineGap:this.style.lineGap},...this.style.textBaseline&&{textBaseline:this.style.textBaseline},...r&&{align:r}};this.style.font&&P.fontSize(parseInt(this.style.font.replace(/[^\d.]/g,""),10)||10),n=P.heightOfString(this.attr.text,e)}Object.assign(r,{width:e,height:n,x:a,y:t}),r.width=e,r.height=n,r.x=a,r.y=t,r.BBox={x:(X+a)*i,y:(o+t)*K,width:e*i,height:n*K},r.abYposition=t,c&&c.rotate?r.BBoxHit=Ba.rotateBBox(this.BBox,c):r.BBoxHit=this.BBox},Ia.prototype.execute=function(){if(void 0!==this.attr.text&&null!==this.attr.text)if(this.textList&&this.textList.length>0)for(var r=0;r=n&&r.x<=n+a&&r.y>=e&&r.y<=e+t};const Ga=function(r,n,e){const a=this;a.ctx=r,a.attr=Object.assign({},n),a.style=Object.assign({},e),a.nodeName="circle",a.stack=[a]};(Ga.prototype=new Ea).constructor=Ga,Ga.prototype.updateBBox=function(){const r=this,{transform:n,r:e=0,cx:a=0,cy:t=0}=r.attr,{translateX:c,translateY:X,scaleX:o,scaleY:i}=Ta(n);r.BBox={x:c+(a-e)*o,y:X+(t-e)*i,width:2*e*o,height:2*e*i},n&&n.rotate?r.BBoxHit=Ba.rotateBBox(this.BBox,n):r.BBoxHit=this.BBox,r.abYposition=t},Ga.prototype.execute=function(){const{r:r=0,cx:n=0,cy:e=0}=this.attr;this.ctx.beginPath(),this.ctx.arc(n,e,r,0,2*Math.PI,!1),this.applyStyles(),this.ctx.closePath()},Ga.prototype.executePdf=function(r,n){const{r:e=0,cx:a=0,cy:t=0}=this.attr;n||r.translate(0,-this.abYposition),r.circle(parseInt(a),parseInt(t),parseInt(e)),this.applyStylesPdf(r)},Ga.prototype.in=function(r){const{r:n=0,cx:e=0,cy:a=0}=this.attr;return Math.sqrt((r.x-e)*(r.x-e)+(r.y-a)*(r.y-a))<=n};const Ma=function(r,n,e){const a=this;a.ctx=r,a.attr=Object.assign({},n),a.style=Object.assign({},e),a.nodeName="line",a.stack=[a]};function _a(r,n,e){const a=this;a.ctx=r,a.attr=Object.assign({},n),a.style=Object.assign({},e),a.nodeName="polyline",a.stack=[a]}(Ma.prototype=new Ea).constructor=Ma,Ma.prototype.updateBBox=function(){const r=this,{transform:n,x1:e=0,y1:a=0,x2:t=0,y2:c=0}=r.attr,{translateX:X,translateY:o,scaleX:i,scaleY:K}=Ta(n);r.BBox={x:X+(e[r.x,r.y])),execute:function(r){r.beginPath();const n=this.points;r.moveTo(n[0].x,n[0].y);for(let e=1;e=n&&r.x<=n+a&&r.y>=e&&r.y<=e+t};const rt=function(r,n,e){const a=this;return a.nodeName="g",a.ctx=r,a.attr=Object.assign({},n),a.style=Object.assign({},e),a.stack=new Array(0),this};(rt.prototype=new Ea).constructor=rt,rt.prototype.updateBBox=function(r){if(!r||0===r.length)return this.BBox={x:0,y:0,width:0,height:0},void(this.BBoxHit=this.BBox);let n=Math.min,e=Math.max,a=Math.abs;const{transform:t}=this.attr,{translateX:c,translateY:X,scaleX:o,scaleY:i}=Ta(t);let{x:K,y:P,width:s,height:u}=r[0].dom.BBoxHit,m=K+s,l=P+u;for(let a=1;a{r.dom.parent=n,r.vDomIndex=n.vDomIndex,n.stack[n.stack.length]=r})):console.log("wrong Object")},rt.prototype.in=function(r){const n=r.x,e=r.y,{BBox:a}=this,{transform:t}=this.attr,{translateX:c,translateY:X,scaleX:o,scaleY:i}=Ta(t);return n>=(a.x-c)/o&&n<=(a.x-c+a.width)/o&&e>=(a.y-X)/i&&e<=(a.y-X+a.height)/i};const nt=function(r,n,e,a){switch(this.id=e,this.nodeName=n.el,this.nodeType="CANVAS",this.children=pn([],this,!0),this.events={},this.ctx=r,this.vDomIndex=a,this.bbox=void 0===n.bbox||n.bbox,this.BBoxUpdate=!0,this.block=n.block||!1,this.style=pa("style",{},this,!0),this.attr=pa("attr",{},this,!0),n.style&&this.setStyle(n.style),n.attr&&this.setAttr(n.attr),n.el){case"circle":this.dom=new Ga(this.ctx,this.attr,this.style);break;case"rect":this.dom=new Za(this.ctx,this.attr,this.style);break;case"line":this.dom=new Ma(this.ctx,this.attr,this.style);break;case"polyline":this.dom=new _a(this.ctx,this.attr,this.style);break;case"path":this.dom=new Ja(this.ctx,this.attr,this.style);break;case"group":case"g":this.dom=new rt(this.ctx,this.attr,this.style);break;case"text":this.dom=new Ia(this.ctx,this.attr,this.style);break;case"image":this.dom=new za(this.ctx,this.attr,this.style,n.onload,n.onerror,this);break;case"polygon":this.dom=new Ha(this.ctx,this.attr,this.style);break;case"ellipse":this.dom=new Qa(this.ctx,this.attr,this.style);break;default:this.dom=new Fa(this.ctx,this.attr,this.style),this.bbox=!1,this.BBoxUpdate=!1}this.dom.nodeExe=this};function et(r){if(r.deleted=!0,r.dom instanceof rt&&!r.deleted)for(let n=0;n{const e=r.dom&&r.dom.abTransform?r.dom.abTransform:{translate:[0,0]},a=r.dom.BBox,t=n.dom&&n.dom.abTransform?n.dom.abTransform:{translate:[0,0]},c=n.dom.BBox;return e.translate[1]+a.height+r.dom.abYposition-(t.translate[1]+c.height+n.dom.abYposition)})),o=0;let i=r.bufferedPageRange().count-1;function K(r,n,e){return(r.translate[1]+n||0)-e}X.forEach((e=>{const X=e.dom.abTransform,P=e.dom.BBox.height||0,s=e.dom.abYposition||0;let u=K(X,s,o);(function(r,e,X){return n.autoPagination&&!(ec-t-a})(0,u,P)&&(o+=c-a-t,u=K(X,s,o),o+=u,u=0,r.addPage({margin:this.margin,margins:this.margins,size:[this.width,this.height]}),this.pageTemplate&&this.pageTemplate.executePdf(r),i+=1),e.dom.abTransform={translate:[X.translate[0],u+a]};const m=e.executePdf.bind(e);var l;e.executePdf=(l=i,function(r){r.switchToPage(l),m(r)})})),this.executePdf(r)},e.addTemplate=function(r){this.pageTemplate=r,this.pageTemplate.updateBBox(),this.pageTemplate.updateABBox(),function(r){const n=it(r);n.forEach((r=>{const n=r.dom.abTransform,e=r.dom.abYposition||0,a=n.translate[1]+e||0;r.dom.abTransform={translate:[n.translate[0],a]}}))}(this.pageTemplate)},e.createTexture=function(r={}){return new Xt(this,r)},e.createAsyncTexture=function(r){return new Promise((n=>{const e=new Xt(this,r);e.onLoad((function(){n(e)}))}))},e}function it(r){const n=[];let e=[r];for(;e.length>0;){const r=e.shift();r.block||r.children&&0===r.children.length&&"g"!==r.nodeName&&"group"!==r.nodeName?n.push(r):r.children&&e.push(...r.children)}return n}function Kt(r,n={},e={}){const a="string"==typeof r?document.querySelector(r):r instanceof HTMLElement?r:null;let t=a?.clientHeight||0,c=a?.clientWidth||0;const X=document.createElement("canvas"),o=X.getContext("2d",n);let i=function(r){const n=(window.devicePixelRatio||1)/(r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||r.backingStorePixelRatio||1);return n<1?1:n}(o);o.pixelRatio=i;let K=function(r){r.clearRect(0,0,c*i,t*i)};X.setAttribute("height",t*i),X.setAttribute("width",c*i),X.style.height=`${t}px`,X.style.width=`${c}px`,X.style.position="absolute";let P,s,u,m,l,{enableEvents:d=!0,autoUpdate:g=!0,enableResize:h=!0}=e,A=999999;a?(a.appendChild(X),P=new v,g&&(A=Wa.addVdom(P))):d=!1;const f=ot(o,A),C=function(n){if(r instanceof HTMLElement&&!document.body.contains(r)||r instanceof String&&!document.querySelector(r))return yn(f),void f.destroy();t=s||n.height,c=u||n.width,f.width=c,f.height=t,B(f.domEl,c,t),m&&m(),f.execute()};P&&P.rootNode(f);const W=f.execute.bind(f);f.container=a,f.domEl=X,f.height=t,f.width=c,f.type="CANVAS",f.ctx=o,f.clear=function(){K(o)},f.setAttr=function(r,n){"viewBox"===r&&this.setViewBox.apply(this,n.split(",")),X.setAttribute(r,n),this.attr[r]=n},f.setClear=function(r){K=r},f.setSize=function(r,n){s=n,u=r,c=r,t=n,this.width=c,this.height=t,B(this.domEl,c,t),this.execute()},f.onResize=function(r){m=r},f.getPixels=function(r,n,e,a){return new wa(this.ctx.getImageData(r,n,e,a),e,a)},f.putPixels=function(r,n,e){if(r instanceof wa)return this.ctx.putImageData(r.imageData,n,e)},f.execute=function(){K(o),o.setTransform(i,0,0,i,0,0),this.updateBBox(),W(),l&&this.stateModified&&l(),this.stateModified=!1},f.onChange=function(r){l=r};const B=function(r,n,e){r.setAttribute("height",e*i),r.setAttribute("width",n*i),r.style.height=`${e}px`,r.style.width=`${n}px`};if(f.setPixelRatio=function(r){i=r,this.ctx.pixelRatio=i,B(this.domEl,this.width,this.height)},f.destroy=function(){document.body.contains(this.container)&&this.container.contains(this.domEl)&&this.container.removeChild(this.domEl),Wa.removeVdom(A),yn(f,C)},d){const r=new Hr(f);X.addEventListener("mousemove",(n=>{n.preventDefault(),r.mousemoveCheck(n)})),X.addEventListener("mousedown",(n=>{r.mousedownCheck(n)})),X.addEventListener("mouseup",(n=>{r.mouseupCheck(n)})),X.addEventListener("mouseleave",(n=>{r.mouseleaveCheck(n)})),X.addEventListener("contextmenu",(n=>{r.contextmenuCheck(n)})),X.addEventListener("touchstart",(n=>{r.touchstartCheck(n)})),X.addEventListener("touchend",(n=>{r.touchendCheck(n)})),X.addEventListener("touchmove",(n=>{n.preventDefault(),r.touchmoveCheck(n)})),X.addEventListener("touchcancel",(n=>{r.touchcancelCheck(n)})),X.addEventListener("wheel",(n=>{r.wheelEventCheck(n)})),X.addEventListener("pointerdown",(n=>{r.addPointer(n),r.pointerdownCheck(n)})),X.addEventListener("pointerup",(n=>{r.removePointer(n),r.pointerupCheck(n)})),X.addEventListener("pointermove",(n=>{n.preventDefault(),r.pointermoveCheck(n)}))}return Wa.execute(),h&&f.container&&xn(f,C),f}if(nt.prototype=new Cn,nt.prototype.node=function(){return this.updateBBox(),this.dom},nt.prototype.stylesExe=function(){const{style:r,ctx:n,dom:e,dataObj:a}=this;this.resolvedStyle={};for(let t in r){let c=r[t];if("function"==typeof c)c=c.call(this,a);else if("object"==typeof c&&null!==c){(c instanceof Ya||c instanceof Sa||c instanceof Da||c instanceof Ra)&&(c=c.exe(n,e.BBox))}else if("string"!=typeof c&&"number"!=typeof c){console.log("Unknown Style");continue}const X=an[t]||t;"function"==typeof n[X]?n[X](c):n[X]=c,this.resolvedStyle[X]=c}},nt.prototype.stylesExePdf=function(r){if(!r)return;const n=this.style;let e;for(let a in n)"string"==typeof n[a]||"number"==typeof n[a]?e=n[a]:"object"==typeof n[a]?e=n[a]instanceof Ya||n[a]instanceof Sa||n[a]instanceof Da||n[a]instanceof Ra?n[a].exePdf(r,this.dom.BBox,this.dom.abTransform):n[a]:"function"==typeof n[a]?(n[a]=n[a].call(this,this.dataObj),e=n[a]):console.log("unkonwn Style"),Ca[a]&&(e=Ca[a].getValue(e),a=Ca[a].prop),"fillColor"!==a&&"strokeColor"!==a||"string"!=typeof e||(e=br.colorToRGBPdf(e)),"function"!=typeof r[a]?r[a]=e:"function"==typeof r[a]?r[a](e):console.log("junk comp")},nt.prototype.attributesExe=function(){this.dom.render(this.attr)},nt.prototype.attributesExePdf=function(r,n){this.dom.renderPdf(this.attr,r,n)},nt.prototype.setStyle=function(r,n){if(2===arguments.length)this.style[r]=n;else if(1===arguments.length&&"object"==typeof r){const n=Object.keys(r);for(let e=0,a=n.length;e{const a=tt(null,r);a.onload=function(){n(this)},a.onerror=function(r){e(r)}}))}));Promise.all(r).then((function(r){e.image=r,e.imageObj=r[e.seekIndex],e.attr&&e.attr.onload&&"function"==typeof e.attr.onload&&e.attr.onload.call(e,r),e.asyncOnLoad&&"function"==typeof e.asyncOnLoad&&e.asyncOnLoad(r),ct(e)}))}else"string"==typeof n?(e.image||(e.image=tt(e,n)),e.image.src!==n&&(e.image.src=n)):n instanceof HTMLImageElement||n instanceof SVGImageElement||n instanceof HTMLCanvasElement?(e.imageObj=n,e.attr.height=e.attr.height?e.attr.height:n.height,e.attr.width=e.attr.width?e.attr.width:n.width,ct(e)):(n instanceof nt||n instanceof Xt)&&(e.imageObj=n.domEl,e.attr.height=e.attr.height?e.attr.height:n.attr.height,e.attr.width=e.attr.width?e.attr.width:n.attr.width,ct(e));return this.attr[r]=n,"height"!==r&&"width"!==r||(this.rImageObj.setAttr(r,n),ct(e)),"clip"!==r&&"filter"!==r||ct(e),e},Xt.prototype.onLoad=function(r){this.asyncOnLoad=r},Xt.prototype.clone=function(){const r=Object.assign({},this.attr),n=Object.assign({},this.style);return r.src=this,new Xt(this.nodeExe,{attr:r,style:n})},Xt.prototype.execute=function(){const{width:r=0,height:n=0}=this.attr,e=this.attr.draw||{},a=this.attr.scale||1;this.ctx.clearRect(0,0,r*a,n*a),this.ctx.drawImage(this.imageObj,e.x||0,e.y||0,(e.width||r)*a,(e.height||n)*a)},Xt.prototype.exportAsDataUrl=function(r="image/png",n=1){return this.rImageObj?this.rImageObj.canvas.toDataURL(r,n):this},Xt.prototype.next=function(r){Array.isArray(this.image)&&(r=0?this.seekIndex=r:this.seekIndex0)for(let r in fa)a.writeFileSync("/data/"+r,fa[r]);function Pt(r,n={}){return{...n,autoFirstPage:!1,bufferPages:!0,...void 0!==r.margin&&{margin:r.margin},...void 0!==r.margins&&{margins:r.margins},...void 0!==r.defaultFont&&{font:r.defaultFont},...void 0!==r.encryption&&{...r.encryption}}}function st(r){this.pages=[],this.ctx=r.ctx,this.domEl=r.layer,this.vDomIndex=r.vDomIndex,this.container=r.res,this.height=r.height,this.width=r.width,this.pdfConfig=r.pdfConfig,this.pdfInfo=r.pdfInfo,this.fontRegister=r.fontRegister,this.fallBackPage=r.fallBackPage,this.layerConfig=r.layerConfig}function ut(r,n={},e={}){const a="string"==typeof r?document.querySelector(r):r instanceof HTMLElement?r:null;let c=a?.clientHeight||0,X=a?.clientWidth||0,{height:o=c,width:i=X}=n,K=Pt(n),{autoUpdate:P=!0,onUpdate:s,autoPagination:u=!0}=e;const m=document.createElement("canvas");m.setAttribute("height",o),m.setAttribute("width",i);const l=m.getContext("2d");let d=n.fontRegister||{},g=n.info||{title:"I2Djs-PDF"},h=999999;l.type_="pdf",l.doc=new t({size:[i,o],...K}),l.doc.addPage();const A=new v;P&&(h=B.addVdom(A));const f=new st({ctx:l,layer:m,vDomIndex:h,res:a,height:o,width:i,pdfConfig:K,pdfInfo:g,fontRegister:d,fallBackPage:ot(l,h),layerConfig:{autoUpdate:P,autoPagination:u}});return f.onChange(s),A&&A.rootNode(f),f}async function mt(r){return new Promise(((n,e)=>{(async()=>{try{const e=Pt(r),a=new t({size:[this.width,this.height],...e}),X=a.pipe(c()),o=r.fontRegister||{},i=r.info||{title:"I2Djs-PDF"};if(o)for(const r in o){-1===cn.indexOf(r)&&cn.push(r);const n=await fetch(o[r]),e=await n.arrayBuffer();a.registerFont(r,e)}a.info={Title:i.title||"",Author:i.author||"",Subject:i.subject||"",Keywords:i.keywords||"",CreationDate:i.creationDate||new Date},this.updateBBox(),this.updateABBox(),a.addPage(),this.exportPdf(a,{}),a.end(),X.on("finish",(function(){n(X.toBlobURL("application/pdf"))}))}catch(r){e(r)}})()}))}function lt(r,n){return mt.call(r,n)}st.prototype.flush=function(){this.pages.forEach((function(r){r.flush()})),this.pages=[],this.doc&&this.doc.flushPages()},st.prototype.setConfig=function(r={}){const n=Pt(r,this.pdfConfig);return r.fontRegister&&(this.fontRegister={...r.fontRegister||{}}),this.pdfInfo=r.info||this.pdfInfo||{title:"I2Djs-PDF"},this.height=r.height||this.height,this.width=r.width||this.width,this.layer.setAttribute("height",1*this.height),this.layer.setAttribute("width",1*this.width),this.pdfConfig=n,this.execute(),this},st.prototype.setPageTemplate=function(r){this.pageDefaultTemplate=r},st.prototype.setSize=function(r=0,n=0){return this.width=r,this.height=n,this.pdfConfig=Pt({height:n,width:r},this.pdfConfig),this.pages.forEach((e=>{let a=e.pageConfig;e.height=a.height||n,e.width=a.width||r})),this.execute(),this},st.prototype.execute=function(){let r=this;this.exportPdf(this.onUpdateExe||function(n){r.container.setAttribute("src",n)},this.pdfConfig)},st.prototype.onChange=function(r){this.onUpdateExe=r},st.prototype.addPage=function(r={}){const n=ot(this.ctx,this.vDomIndex);Object.assign(n,{domEl:this.layer,pageConfig:r,height:r.height||this.height,width:r.width||this.width,margin:r.margin||this.pdfConfig.margin||0,margins:r.margins||this.pdfConfig.margins||{top:0,bottom:0,left:0,right:0},type:"CANVAS",EXEType:"pdf",ctx:this.ctx});const e=r.pageTemplate||this.pageDefaultTemplate;return e&&n.addTemplate(e),this.pages.push(n),n},st.prototype.removePage=function(r){const n=this.pages.indexOf(r);let e=null;return-1!==n&&(e=this.pages.splice(n,1)),e},st.prototype.createTemplate=function(){return ot(this.ctx,this.vDomIndex)},st.prototype.exportPdf=async function(r,n={}){let e=this;const a=new t({...n}),X=a.pipe(c());if(this.fontRegister)for(const r in this.fontRegister){-1===cn.indexOf(r)&&cn.push(r);const n=await fetch(this.fontRegister[r]),e=await n.arrayBuffer();a.registerFont(r,e)}this.pdfInfo&&(a.info.Title=this.pdfInfo.title||"",a.info.Author=this.pdfInfo.author||"",a.info.Subject=this.pdfInfo.subject||"",a.info.Keywords=this.pdfInfo.keywords||"",a.info.CreationDate=this.pdfInfo.creationDate||new Date),this.doc=a,this.pages.forEach((function(r){r.updateBBox(),a.addPage({margin:r.margin||0,size:[r.width,r.height]}),r.pageTemplate&&r.pageTemplate.executePdf(a),r.exportPdf(a,{autoPagination:e.layerConfig.autoPagination})})),this.doc.end(),X.on("finish",(function(){r(X.toBlobURL("application/pdf"))}))},st.prototype.destroy=function(){document.body.contains(this.container)&&this.container.contains(this.domEl)&&this.container.removeChild(this.domEl),this.flush(),B.removeVdom(this.vDomIndex)},st.prototype.exec=function(r){r.call(this,this.dataObj)},st.prototype.data=function(r){return r?(this.dataObj=r,this):this.dataObj},st.prototype.createTexture=function(r={}){return this.fallBackPage.createTexture(r)},st.prototype.createAsyncTexture=function(r={}){return this.fallBackPage.createAsyncTexture(r)};var dt={blur:function(r=1){return function(n){return X(n,0,0,n.width,n.height,r)}},greyScale:function(r){let n=null;switch(r){case"grey-1":n=function(r){const n=r.data;let e;for(let a=0,t=n.length;a>>3),r.data[a]=e,r.data[a+1]=e,r.data[a+2]=e;return r};break;default:n=function(r){const n=r.data;let e;for(let a=0,t=n.length;a