@antv/g-canvas 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.Canvas2D={}),t.window.G)}(this,(function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+e+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;r>n;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function a(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(t){try{c(r.next(t))}catch(t){a(t)}}function s(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,s)}c((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&i[3]>s[1])){o.label=s[1];break}if(6===s[0]&&i[1]>o.label){o.label=i[1],i=s;break}if(i&&i[2]>o.label){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function s(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,a=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=a.next()).done;)o.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return o}var c={}.toString,l=function(t,e){return c.call(t)==="[object "+e+"]"},h=function(t,e,n){return e>t?e:t>n?n:t};function u(t,e){var n=e.r;t.arc(n,n,n,0,2*Math.PI,!1)}function d(t,e){var n=e.rx,r=e.ry;if(t.ellipse)t.ellipse(n,r,n,r,0,0,2*Math.PI,!1);else{var i=n>r?n:r,a=n>r?1:n/r,o=n>r?r/n:1;t.save(),t.scale(a,o),t.arc(0,0,i,0,2*Math.PI)}}function f(t,n){var r=n.x1,i=n.y1,a=n.x2,o=n.y2,s=n.defX,c=void 0===s?0:s,l=n.defY,h=void 0===l?0:l,u=n.markerStart,d=n.markerEnd,f=n.markerStartOffset,p=n.markerEndOffset,v=0,y=0,g=0,m=0,E=0;u&&e.isDisplayObject(u)&&f&&(v=Math.cos(E=Math.atan2(o-i,a-r))*(f||0),y=Math.sin(E)*(f||0)),d&&e.isDisplayObject(d)&&p&&(g=Math.cos(E=Math.atan2(i-o,r-a))*(p||0),m=Math.sin(E)*(p||0)),t.moveTo(r-c+v,i-h+y),t.lineTo(a-c+g,o-h+m)}function p(t,n){var r=n.defX,i=void 0===r?0:r,a=n.defY,o=void 0===a?0:a,c=n.markerStart,l=n.markerEnd,h=n.markerStartOffset,u=n.markerEndOffset,d=n.path,f=d.absolutePath,p=d.segments,v=0,y=0,g=0,m=0,E=0;if(c&&e.isDisplayObject(c)&&h){var M=s(c.parentNode.getStartTangent(),2);v=Math.cos(E=Math.atan2((x=M[0])[1]-(b=M[1])[1],x[0]-b[0]))*(h||0),y=Math.sin(E)*(h||0)}if(l&&e.isDisplayObject(l)&&u){var x,b,S=s(l.parentNode.getEndTangent(),2);g=Math.cos(E=Math.atan2((x=S[0])[1]-(b=S[1])[1],x[0]-b[0]))*(u||0),m=Math.sin(E)*(u||0)}for(var P=0;f.length>P;P++){var T=f[P],C=f[P+1],A=0===P&&(0!==v||0!==y),w=(P===f.length-1||C&&("M"===C[0]||"Z"===C[0]))&&0!==g&&0!==m;switch(T[0]){case"M":A?(t.moveTo(T[1]-i+v,T[2]-o+y),t.lineTo(T[1]-i,T[2]-o)):t.moveTo(T[1]-i,T[2]-o);break;case"L":w?t.lineTo(T[1]-i+g,T[2]-o+m):t.lineTo(T[1]-i,T[2]-o);break;case"Q":t.quadraticCurveTo(T[1]-i,T[2]-o,T[3]-i,T[4]-o),w&&t.lineTo(T[3]-i+g,T[4]-o+m);break;case"C":t.bezierCurveTo(T[1]-i,T[2]-o,T[3]-i,T[4]-o,T[5]-i,T[6]-o),w&&t.lineTo(T[5]-i+g,T[6]-o+m);break;case"A":var O=p[P].arcParams,k=O.cx,L=O.cy,R=O.rx,I=O.ry,N=O.startAngle,D=O.endAngle,B=O.xRotation,F=O.sweepFlag;if(t.ellipse)t.ellipse(k-i,L-o,R,I,B,N,D,!!(1-F));else{var G=R>I?R:I,j=R>I?1:R/I,_=R>I?I/R:1;t.translate(k-i,L-o),t.rotate(B),t.scale(j,_),t.arc(0,0,G,N,D,!!(1-F)),t.scale(1/j,1/_),t.rotate(-B),t.translate(-(k-i),-(L-o))}w&&t.lineTo(T[6]-i+g,T[7]-o+m);break;case"Z":t.closePath()}}}function v(t,n){var r=n.defX,i=void 0===r?0:r,a=n.defY,o=void 0===a?0:a,s=n.markerStart,c=n.markerEnd,l=n.markerStartOffset,h=n.markerEndOffset,u=n.points.points,d=u.length,f=u[0][0]-i,p=u[0][1]-o,v=u[d-1][0]-i,y=u[d-1][1]-o,g=0,m=0,E=0,M=0,x=0;s&&e.isDisplayObject(s)&&l&&(g=Math.cos(x=Math.atan2(u[1][1]-u[0][1],u[1][0]-u[0][0]))*(l||0),m=Math.sin(x)*(l||0)),c&&e.isDisplayObject(c)&&h&&(E=Math.cos(x=Math.atan2(u[d-1][1]-u[0][1],u[d-1][0]-u[0][0]))*(h||0),M=Math.sin(x)*(h||0)),t.moveTo(f+(g||E),p+(m||M));for(var b=1;d-1>b;b++){var S=u[b];t.lineTo(S[0]-i,S[1]-o)}t.lineTo(v,y)}function y(t,n){var r=n.defX,i=void 0===r?0:r,a=n.defY,o=void 0===a?0:a,s=n.markerStart,c=n.markerEnd,l=n.markerStartOffset,h=n.markerEndOffset,u=n.points.points,d=u.length,f=u[0][0]-i,p=u[0][1]-o,v=u[d-1][0]-i,y=u[d-1][1]-o,g=0,m=0,E=0,M=0,x=0;s&&e.isDisplayObject(s)&&l&&(g=Math.cos(x=Math.atan2(u[1][1]-u[0][1],u[1][0]-u[0][0]))*(l||0),m=Math.sin(x)*(l||0)),c&&e.isDisplayObject(c)&&h&&(E=Math.cos(x=Math.atan2(u[d-2][1]-u[d-1][1],u[d-2][0]-u[d-1][0]))*(h||0),M=Math.sin(x)*(h||0)),t.moveTo(f+g,p+m);for(var b=1;d-1>b;b++){var S=u[b];t.lineTo(S[0]-i,S[1]-o)}t.lineTo(v+E,y+M)}function g(t,e){var n=e.radius,r=e.width,i=e.height,a=r,o=i;if(n&&n.some((function(t){return 0!==t}))){var c=r>0?1:-1,l=i>0?1:-1,u=c+l===0,d=s(n.map((function(t){return h(t,0,Math.min(Math.abs(a)/2,Math.abs(o)/2))})),4),f=d[0],p=d[1],v=d[2],y=d[3];t.moveTo(c*f,0),t.lineTo(a-c*p,0),0!==p&&t.arc(a-c*p,l*p,p,-l*Math.PI/2,c>0?0:Math.PI,u),t.lineTo(a,o-l*v),0!==v&&t.arc(a-c*v,o-l*v,v,c>0?0:Math.PI,l>0?Math.PI/2:1.5*Math.PI,u),t.lineTo(c*y,o),0!==y&&t.arc(c*y,o-l*y,y,l>0?Math.PI/2:-Math.PI/2,c>0?Math.PI:0,u),t.lineTo(0,l*f),0!==f&&t.arc(c*f,l*f,f,c>0?Math.PI:0,l>0?1.5*Math.PI:Math.PI/2,u)}else t.rect(0,0,a,o)}var m=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="canvas-path-generator",e}return r(n,t),n.prototype.init=function(){var t,n=((t={})[e.Shape.CIRCLE]=u,t[e.Shape.ELLIPSE]=d,t[e.Shape.RECT]=g,t[e.Shape.LINE]=f,t[e.Shape.POLYLINE]=y,t[e.Shape.POLYGON]=v,t[e.Shape.PATH]=p,t[e.Shape.TEXT]=void 0,t[e.Shape.GROUP]=void 0,t[e.Shape.IMAGE]=void 0,t[e.Shape.HTML]=void 0,t[e.Shape.MESH]=void 0,t);this.context.pathGeneratorFactory=n},n.prototype.destroy=function(){delete this.context.pathGeneratorFactory},n}(e.AbstractRendererPlugin),E=Object.freeze({__proto__:null,Plugin:m}),M="undefined"!=typeof Float32Array?Float32Array:Array;function x(){var t=new M(16);return M!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function b(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function S(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],d=e[9],f=e[10],p=e[11],v=e[12],y=e[13],g=e[14],m=e[15],E=n[0],M=n[1],x=n[2],b=n[3];return t[0]=E*r+M*s+x*u+b*v,t[1]=E*i+M*c+x*d+b*y,t[2]=E*a+M*l+x*f+b*g,t[3]=E*o+M*h+x*p+b*m,t[4]=(E=n[4])*r+(M=n[5])*s+(x=n[6])*u+(b=n[7])*v,t[5]=E*i+M*c+x*d+b*y,t[6]=E*a+M*l+x*f+b*g,t[7]=E*o+M*h+x*p+b*m,t[8]=(E=n[8])*r+(M=n[9])*s+(x=n[10])*u+(b=n[11])*v,t[9]=E*i+M*c+x*d+b*y,t[10]=E*a+M*l+x*f+b*g,t[11]=E*o+M*h+x*p+b*m,t[12]=(E=n[12])*r+(M=n[13])*s+(x=n[14])*u+(b=n[15])*v,t[13]=E*i+M*c+x*d+b*y,t[14]=E*a+M*l+x*f+b*g,t[15]=E*o+M*h+x*p+b*m,t}function P(t,e,n){var r,i,a,o,s,c,l,h,u,d,f,p,v=n[0],y=n[1],g=n[2];return e===t?(t[12]=e[0]*v+e[4]*y+e[8]*g+e[12],t[13]=e[1]*v+e[5]*y+e[9]*g+e[13],t[14]=e[2]*v+e[6]*y+e[10]*g+e[14],t[15]=e[3]*v+e[7]*y+e[11]*g+e[15]):(i=e[1],a=e[2],o=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],d=e[9],f=e[10],p=e[11],t[0]=r=e[0],t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=h,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=r*v+s*y+u*g+e[12],t[13]=i*v+c*y+d*g+e[13],t[14]=a*v+l*y+f*g+e[14],t[15]=o*v+h*y+p*g+e[15]),t}function T(){var t=new M(3);return M!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function C(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function A(t,e,n){var r=e[0],i=e[1],a=e[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return t[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/(o=o||1),t[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,t[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,t}function w(t,e,n,r){var i=t-n,a=e-r;return Math.sqrt(i*i+a*a)}function O(t,e,n,r,i,a){var o=[n-t,r-e];if(function(t,e){return t[0]===e[0]&&t[1]===e[1]}(o,[0,0]))return Math.sqrt((i-t)*(i-t)+(a-e)*(a-e));var s=[-o[1],o[0]];return function(t,e){var n=e[0],r=e[1],i=n*n+r*r;i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i}(s,s),Math.abs(function(t,e){return t[0]*e[0]+t[1]*e[1]}([i-t,a-e],s))}function k(t,e,n,r,i,a,o,s,c,l,h){var u=this.nearestPoint(t,e,n,r,i,a,o,s,c,l,h);return w(u.x,u.y,c,l)}function L(t,e,n,r,i,a,o,s){var c=this.nearestPoint(t,e,n,r,i,a,o,s);return w(c.x,c.y,o,s)}function R(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function I(t,e,n,r,i,a,o,s,c,l){var h,u,d,f,p,v=t,y=e,g=n,m=r,E=s,M=c,x=120*Math.PI/180,b=Math.PI/180*(+i||0),S=[];if(l)u=l[0],d=l[1],f=l[2],p=l[3];else{y=(h=R(v,y,-b)).y;var P=((v=h.x)-(E=(h=R(E,M,-b)).x))/2,T=(y-(M=h.y))/2,C=P*P/(g*g)+T*T/(m*m);C>1&&(g*=C=Math.sqrt(C),m*=C);var A=g*g,w=m*m,O=(a===o?-1:1)*Math.sqrt(Math.abs((A*w-A*T*T-w*P*P)/(A*T*T+w*P*P)));f=O*g*T/m+(v+E)/2,u=Math.asin(((y-(p=O*-m*P/g+(y+M)/2))/m*1e9>>0)/1e9),d=Math.asin(((M-p)/m*1e9>>0)/1e9),0>(u=f>v?Math.PI-u:u)&&(u=2*Math.PI+u),0>(d=f>E?Math.PI-d:d)&&(d=2*Math.PI+d),o&&u>d&&(u-=2*Math.PI),!o&&d>u&&(d-=2*Math.PI)}var k=d-u;if(Math.abs(k)>x){var L=d,N=E,D=M;S=I(E=f+g*Math.cos(d=u+x*(o&&d>u?1:-1)),M=p+m*Math.sin(d),g,m,i,0,o,N,D,[d,L,f,p])}k=d-u;var B=Math.cos(u),F=Math.sin(u),G=Math.cos(d),j=Math.sin(d),_=Math.tan(k/4),H=4/3*g*_,$=4/3*m*_,W=[v,y],U=[v+H*F,y-$*B],Y=[E+H*j,M-$*G],X=[E,M];if(U[0]=2*W[0]-U[0],U[1]=2*W[1]-U[1],l)return U.concat(Y,X,S);for(var z=[],q=0,Q=(S=U.concat(Y,X,S)).length;Q>q;q+=1)z[q]=q%2?R(S[q-1],S[q],b).y:R(S[q],S[q+1],b).x;return z}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),T(),function(){var t,e=(t=new M(2),M!=Float32Array&&(t[0]=0,t[1]=0),t)}();var N=function(t){return null==t},D={}.toString,B=function(t,e){return D.call(t)==="[object "+e+"]"},F=function(t){return B(t,"String")},G=function(t,e,n){return e>t?e:t>n?n:t},j=function(t){return B(t,"Number")},_=T(),H=T(),$=T(),W=x(),U=function(){function t(){var t=this;this.isHit=function(n,r,i,a){var o,s,c,l,h,u,d,f,p,v,y,g,m,E,M,x,b,S,P,T,w,O,k,L,R,I,N,D,B,F,G,j=t.context.pointInPathPickerFactory[n.nodeName];if(j){var _=(o=W,(G=(P=(c=(s=i)[0])*(f=s[5])-(l=s[1])*(d=s[4]))*(F=(m=s[10])*(S=s[15])-(E=s[11])*(b=s[14]))-(T=c*(p=s[6])-(h=s[2])*d)*(B=(g=s[9])*S-E*(x=s[13]))+(w=c*(v=s[7])-(u=s[3])*d)*(D=g*b-m*x)+(O=l*p-h*f)*(N=(y=s[8])*S-E*(M=s[12]))-(k=l*v-u*f)*(I=y*b-m*M)+(L=h*v-u*p)*(R=y*x-g*M))?(o[0]=(f*F-p*B+v*D)*(G=1/G),o[1]=(h*B-l*F-u*D)*G,o[2]=(x*L-b*k+S*O)*G,o[3]=(m*k-g*L-E*O)*G,o[4]=(p*N-d*F-v*I)*G,o[5]=(c*F-h*N+u*I)*G,o[6]=(b*w-M*L-S*T)*G,o[7]=(y*L-m*w+E*T)*G,o[8]=(d*B-f*N+v*R)*G,o[9]=(l*N-c*B-u*R)*G,o[10]=(M*k-x*w+S*P)*G,o[11]=(g*w-y*k-E*P)*G,o[12]=(f*I-d*D-p*R)*G,o[13]=(c*D-l*I+h*R)*G,o[14]=(x*T-M*O-b*P)*G,o[15]=(y*O-g*T+m*P)*G,o):null),U=A(H,C($,r[0],r[1],0),_),Y=n.getGeometryBounds().halfExtents,X=n.parsedStyle.anchor;if(U[0]+=(X&&X[0]||0)*Y[0]*2,U[1]+=(X&&X[1]||0)*Y[1]*2,j(n,new e.Point(U[0],U[1]),a,t.isPointInPath,t.context,t.runtime))return!0}return!1},this.isPointInPath=function(e,n){var r=t.runtime.offscreenCanvas.getOrCreateContext(t.context.config.offscreenCanvas),i=t.context.pathGeneratorFactory[e.nodeName];return i&&(r.beginPath(),i(r,e.parsedStyle),r.closePath()),r.isPointInPath(n.x,n.y)}}return t.prototype.apply=function(e,n){var r,i=this,s=e.renderingService,c=e.renderingContext;this.context=e,this.runtime=n;var l=null===(r=c.root)||void 0===r?void 0:r.ownerDocument;s.hooks.pick.tapPromise(t.tag,(function(t){return a(i,void 0,void 0,(function(){return o(this,(function(e){return[2,this.pick(l,t)]}))}))})),s.hooks.pickSync.tap(t.tag,(function(t){return i.pick(l,t)}))},t.prototype.pick=function(t,n){var r,i,a,o=n.topmost,s=(r=n.position).x,c=C(_,s,r.y,0),l=t.elementsFromBBox(c[0],c[1],c[0],c[1]),h=[];try{for(var u=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(l),d=u.next();!d.done;d=u.next()){var f=d.value,p=f.getWorldTransform();if(this.isHit(f,c,p,!1)){var v=e.findClosestClipPathTarget(f);if(v){var y=v.parsedStyle.clipPath;if(this.isHit(y,c,y.getWorldTransform(),!0)){if(o)return n.picked=[f],n;h.push(f)}}else{if(o)return n.picked=[f],n;h.push(f)}}}}catch(t){i={error:t}}finally{try{d&&!d.done&&(a=u.return)&&a.call(u)}finally{if(i)throw i.error}}return n.picked=h,n},t.tag="CanvasPicker",t}();function Y(t,n,r){var i=t.parsedStyle,a=i.r,o=i.fill,c=i.stroke,l=i.pointerEvents,h=((i.lineWidth||0)+(i.increasedLineWidthForHitTesting||0))/2,u=w(a,a,n.x,n.y),d=s(e.isFillOrStrokeAffected(l,o,c),2),f=d[0],p=d[1];return f&&p||r?a+h>=u:f?a>=u:!!p&&(u>=a-h&&a+h>=u)}function X(t,e,n,r){return t/(n*n)+e/(r*r)}function z(t,n,r){var i=t.parsedStyle,a=i.rx,o=i.ry,c=i.lineWidth,l=i.increasedLineWidthForHitTesting,h=n.x,u=n.y,d=s(e.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke),2),f=d[0],p=d[1],v=((c||0)+(l||0))/2,y=(h-a)*(h-a),g=(u-o)*(u-o);return f&&p||r?1>=X(y,g,a+v,o+v):f?1>=X(y,g,a,o):!!p&&(X(y,g,a-v,o-v)>=1&&1>=X(y,g,a+v,o+v))}function q(t,e,n,r,i,a){return!(t>i||i>t+n||e>a||a>e+r)}function Q(t,e,n,r,i,a,o,s){var c=(Math.atan2(s-e,o-t)+2*Math.PI)%(2*Math.PI),l={x:t+n*Math.cos(c),y:e+n*Math.sin(c)};return w(l.x,l.y,o,s)<=a/2}function V(t,e,n,r,i,a,o){var s=i/2;return!(Math.min(t,n)-s>a||a>Math.max(t,n)+s||Math.min(e,r)-s>o||o>Math.max(e,r)+s)&&O(t,e,n,r,a,o)<=i/2}function Z(t,e,n,r,i){var a=t.length;if(2>a)return!1;for(var o=0;a-1>o;o++){if(V(t[o][0],t[o][1],t[o+1][0],t[o+1][1],e,n,r))return!0}if(i){var s=t[0],c=t[a-1];if(V(s[0],s[1],c[0],c[1],e,n,r))return!0}return!1}var J=1e-6;function K(t){return J>Math.abs(t)?0:0>t?-1:1}function tt(t,e,n){return!((n[0]-t[0])*(e[1]-t[1])!=(e[0]-t[0])*(n[1]-t[1])||Math.min(t[0],e[0])>n[0]||n[0]>Math.max(t[0],e[0])||Math.min(t[1],e[1])>n[1]||n[1]>Math.max(t[1],e[1]))}function et(t,e,n){var r=!1,i=t.length;if(2>=i)return!1;for(var a=0;i>a;a++){var o=t[a],s=t[(a+1)%i];if(tt(o,s,[e,n]))return!0;K(o[1]-n)>0!=K(s[1]-n)>0&&0>K(e-(n-o[1])*(o[0]-s[0])/(o[1]-s[1])-o[0])&&(r=!r)}return r}function nt(t,e,n){for(var r=!1,i=0;t.length>i;i++){if(r=et(t[i],e,n))break}return r}function rt(t,n,r){var i=t.parsedStyle,a=i.x1,o=i.y1,c=i.x2,l=i.y2,h=i.lineWidth,u=i.increasedLineWidthForHitTesting,d=i.defX,f=void 0===d?0:d,p=i.defY,v=void 0===p?0:p;return!(!s(e.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke),2)[1]&&!r||!h)&&V(a,o,c,l,(h||0)+(u||0),n.x+f,n.y+v)}function it(t,n,r,i,a,o){var c=t.parsedStyle,l=c.lineWidth,h=c.increasedLineWidthForHitTesting,u=c.defX,d=void 0===u?0:u,f=c.defY,p=void 0===f?0:f,v=c.path,y=v.segments,g=v.hasArc,m=v.polylines,E=v.polygons,M=s(e.isFillOrStrokeAffected(c.pointerEvents,(null==E?void 0:E.length)&&c.fill,c.stroke),2),x=M[0],b=M[1],S=e.getOrCalculatePathTotalLength(t),P=!1;return x||r?P=g?i(t,n):nt(E,n.x+d,n.y+p)||nt(m,n.x+d,n.y+p):((b||r)&&(P=function(t,e,n,r,i){for(var a=!1,o=e/2,s=0;t.length>s;s++){var c=t[s],l=c.currentPoint,h=c.params,u=c.prePoint,d=c.box;if(!d||q(d.x-o,d.y-o,d.width+e,d.height+e,n,r))switch(c.command){case"L":case"Z":if(a=V(u[0],u[1],l[0],l[1],e,n,r))return!0;break;case"Q":if(a=e/2>=L(u[0],u[1],h[1],h[2],h[3],h[4],n,r))return!0;break;case"C":if(a=e/2>=k(u[0],u[1],h[1],h[2],h[3],h[4],h[5],h[6],n,r,i))return!0;break;case"A":c.cubicParams||(c.cubicParams=I(u[0],u[1],h[1],h[2],h[3],h[4],h[5],h[6],h[7],void 0));for(var f=c.cubicParams,p=u,v=0;f.length>v;v+=6){var y=k(p[0],p[1],f[v],f[v+1],f[v+2],f[v+3],f[v+4],f[v+5],n,r,i);if(p=[f[v+4],f[v+5]],a=e/2>=y)return!0}}}return a}(y,(l||0)+(h||0),n.x+d,n.y+p,S)),P)}function at(t,n,r){var i=t.parsedStyle,a=i.lineWidth,o=i.increasedLineWidthForHitTesting,c=i.points,l=i.defX,h=void 0===l?0:l,u=i.defY,d=void 0===u?0:u,f=s(e.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke),2),p=f[0],v=!1;return(f[1]||r)&&(v=Z(c.points,(a||0)+(o||0),n.x+h,n.y+d,!0)),v||!p&&!r||(v=et(c.points,n.x+h,n.y+d)),v}function ot(t,n,r){var i=t.parsedStyle,a=i.lineWidth,o=i.increasedLineWidthForHitTesting,c=i.points,l=i.defX,h=void 0===l?0:l,u=i.defY,d=void 0===u?0:u;return!(!s(e.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke),2)[1]&&!r||!a)&&Z(c.points,(a||0)+(o||0),n.x+h,n.y+d,!1)}function st(t,n,r,i,a){var o=t.parsedStyle,c=o.radius,l=o.lineWidth,h=o.increasedLineWidthForHitTesting,u=o.width,d=o.height,f=s(e.isFillOrStrokeAffected(o.pointerEvents,o.fill,o.stroke),2),p=f[0],v=f[1],y=(l||0)+(h||0);if(c&&c.some((function(t){return 0!==t}))){var g=!1;return(v||r)&&(g=function(t,e,n,r,i,a,o,c){var l=s(i,4),h=l[0],u=l[1],d=l[2],f=l[3];return V(t+h,e,t+n-u,e,a,o,c)||V(t+n,e+u,t+n,e+r-d,a,o,c)||V(t+n-d,e+r,t+f,e+r,a,o,c)||V(t,e+r-f,t,e+h,a,o,c)||Q(t+n-u,e+u,u,0,0,a,o,c)||Q(t+n-d,e+r-d,d,0,0,a,o,c)||Q(t+f,e+r-f,f,0,0,a,o,c)||Q(t+h,e+h,h,0,0,a,o,c)}(0,0,u,d,c.map((function(t){return G(t,0,Math.min(Math.abs(u)/2,Math.abs(d)/2))})),y,n.x,n.y)),g||!p&&!r||(g=i(t,n)),g}var m=y/2;return p&&v||r?q(0-m,0-m,u+m,d+m,n.x,n.y):p?q(0,0,u,d,n.x,n.y):!!v&&function(t,e,n,r,i,a,o){var s=i/2;return q(t-s,e-s,n,i,a,o)||q(t+n-s,e-s,i,r,a,o)||q(t+s,e+r-s,n,i,a,o)||q(t-s,e+s,i,r,a,o)}(0,0,u,d,y,n.x,n.y)}function ct(t,n,r,i,a,o){var s=t.parsedStyle,c=s.width,l=s.height;if("non-transparent-pixel"===s.pointerEvents){var h=a.config.offscreenCanvas,u=o.offscreenCanvas.getOrCreateCanvas(h),d=o.offscreenCanvas.getOrCreateContext(h,{willReadFrequently:!0});return u.width=c,u.height=l,a.defaultStyleRendererFactory[e.Shape.IMAGE].render(d,t.parsedStyle,t,void 0,void 0,void 0),d.getImageData(n.x,n.y,1,1).data.every((function(t){return 0!==t}))}return!0}var lt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="canvas-picker",e}return r(n,t),n.prototype.init=function(){var t,n=((t={})[e.Shape.CIRCLE]=Y,t[e.Shape.ELLIPSE]=z,t[e.Shape.RECT]=st,t[e.Shape.LINE]=rt,t[e.Shape.POLYLINE]=ot,t[e.Shape.POLYGON]=at,t[e.Shape.PATH]=it,t[e.Shape.TEXT]=function(){return!0},t[e.Shape.GROUP]=null,t[e.Shape.IMAGE]=ct,t[e.Shape.HTML]=null,t[e.Shape.MESH]=null,t);this.context.pointInPathPickerFactory=n,this.addRenderingPlugin(new U)},n.prototype.destroy=function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()},n}(e.AbstractRendererPlugin),ht=Object.freeze({__proto__:null,Plugin:lt}),ut=function(){function t(t){this.canvasRendererPluginOptions=t,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=x(),this.dprMatrix=x(),this.tmpMat4=x(),this.vec3a=T(),this.vec3b=T(),this.vec3c=T(),this.vec3d=T()}return t.prototype.apply=function(n,r){var i=this;this.context=n;var a=n.config,o=n.camera,c=n.renderingService,l=n.renderingContext,h=n.pathGeneratorFactory;this.rBush=n.rBushRoot,this.pathGeneratorFactory=h;var u=n.contextService,d=l.root.ownerDocument.defaultView,f=function(t){var e=t.target.rBushNode;e.aabb&&i.removedRBushNodeAABBs.push(e.aabb)},p=function(t){var e=t.target.rBushNode;e.aabb&&i.removedRBushNodeAABBs.push(e.aabb)};c.hooks.init.tap(t.tag,(function(){d.addEventListener(e.ElementEvent.UNMOUNTED,f),d.addEventListener(e.ElementEvent.CULLED,p);var t=u.getDPR(),n=a.width,r=a.height,o=u.getContext();i.clearRect(o,0,0,n*t,r*t,a.background)})),c.hooks.destroy.tap(t.tag,(function(){d.removeEventListener(e.ElementEvent.UNMOUNTED,f),d.removeEventListener(e.ElementEvent.CULLED,p)})),c.hooks.beginFrame.tap(t.tag,(function(){var t,e,n=u.getContext(),r=u.getDPR(),o=a.width,s=a.height,l=(t=i.canvasRendererPluginOptions).dirtyObjectNumThreshold,h=t.dirtyObjectRatioThreshold,d=(e=c.getStats()).total,f=e.rendered,p=f/d;i.clearFullScreen=c.disableDirtyRectangleRendering()||f>l&&p>h,n&&(n.resetTransform?n.resetTransform():n.setTransform(1,0,0,1,0,0),i.clearFullScreen&&i.clearRect(n,0,0,o*r,s*r,a.background))}));var v=function(t,e){t.isVisible()&&!t.isCulled()&&(i.renderDisplayObject(t,e,i.context,i.restoreStack,r),i.saveDirtyAABB(t)),(t.sortable.sorted||t.childNodes).forEach((function(t){v(t,e)}))};c.hooks.endFrame.tap(t.tag,(function(){var t,n,c=u.getContext(),h=u.getDPR();if((t=i.dprMatrix)[0]=(n=[h,h,1])[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=n[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,S(i.vpMatrix,i.dprMatrix,o.getOrthoMatrix()),i.clearFullScreen)v(l.root,c);else{var f=i.safeMergeAABB.apply(i,function(t,e,n){if(n||2===arguments.length)for(var r,i=0,a=e.length;a>i;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}([i.mergeDirtyAABBs(i.renderQueue)],s(i.removedRBushNodeAABBs.map((function(t){var n=t.minX,r=t.minY,i=t.maxX,a=t.maxY,o=new e.AABB;return o.setMinMax([n,r,0],[i,a,0]),o}))),!1));if(i.removedRBushNodeAABBs=[],e.AABB.isEmpty(f))return void(i.renderQueue=[]);var p=i.convertAABB2Rect(f),y=p.x,g=p.y,m=p.width,E=p.height,M=A(i.vec3a,[y,g,0],i.vpMatrix),x=A(i.vec3b,[y+m,g,0],i.vpMatrix),b=A(i.vec3c,[y,g+E,0],i.vpMatrix),P=A(i.vec3d,[y+m,g+E,0],i.vpMatrix),T=Math.min(M[0],x[0],P[0],b[0]),C=Math.min(M[1],x[1],P[1],b[1]),w=Math.max(M[0],x[0],P[0],b[0]),O=Math.max(M[1],x[1],P[1],b[1]),k=Math.floor(T),L=Math.floor(C),R=Math.ceil(w-T),I=Math.ceil(O-C);c.save(),i.clearRect(c,k,L,R,I,a.background),c.beginPath(),c.rect(k,L,R,I),c.clip(),c.setTransform(i.vpMatrix[0],i.vpMatrix[1],i.vpMatrix[4],i.vpMatrix[5],i.vpMatrix[12],i.vpMatrix[13]),a.renderer.getConfig().enableDirtyRectangleRenderingDebug&&d.dispatchEvent(new e.CustomEvent(e.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:k,y:L,width:R,height:I}})),i.searchDirtyObjects(f).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&i.renderDisplayObject(t,c,i.context,i.restoreStack,r)})),c.restore(),i.renderQueue.forEach((function(t){i.saveDirtyAABB(t)})),i.renderQueue=[]}i.restoreStack.forEach((function(){c.restore()})),i.restoreStack=[]})),c.hooks.render.tap(t.tag,(function(t){i.clearFullScreen||i.renderQueue.push(t)}))},t.prototype.clearRect=function(t,e,n,r,i,a){t.clearRect(e,n,r,i),a&&(t.fillStyle=a,t.fillRect(e,n,r,i))},t.prototype.renderDisplayObject=function(t,n,r,i,a){var o=t.nodeName,s=i[i.length-1];!s||t.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_CONTAINS||(n.restore(),i.pop());var c=this.context.styleRendererFactory[o],l=this.pathGeneratorFactory[o],h=t.parsedStyle.clipPath;if(h){this.applyWorldTransform(n,h);var u=this.pathGeneratorFactory[h.nodeName];u&&(n.save(),i.push(t),n.beginPath(),u(n,h.parsedStyle),n.closePath(),n.clip())}c&&(this.applyWorldTransform(n,t),n.save(),this.applyAttributesToContext(n,t)),l&&(n.beginPath(),l(n,t.parsedStyle),t.nodeName!==e.Shape.LINE&&t.nodeName!==e.Shape.PATH&&t.nodeName!==e.Shape.POLYLINE&&n.closePath()),c&&(c.render(n,t.parsedStyle,t,r,this,a),n.restore()),t.renderable.dirty=!1},t.prototype.convertAABB2Rect=function(t){var e=t.getMin(),n=t.getMax(),r=Math.floor(e[0]),i=Math.floor(e[1]);return{x:r,y:i,width:Math.ceil(n[0])-r,height:Math.ceil(n[1])-i}},t.prototype.mergeDirtyAABBs=function(t){var n=new e.AABB;return t.forEach((function(t){var e=t.getRenderBounds();n.add(e);var r=t.renderable.dirtyRenderBounds;r&&n.add(r)})),n},t.prototype.searchDirtyObjects=function(t){var e,n,r=(e=s(t.getMin(),2))[0],i=e[1],a=(n=s(t.getMax(),2))[0];return this.rBush.search({minX:r,minY:i,maxX:a,maxY:n[1]}).map((function(t){return t.displayObject}))},t.prototype.saveDirtyAABB=function(t){var n=t.renderable;n.dirtyRenderBounds||(n.dirtyRenderBounds=new e.AABB);var r=t.getRenderBounds();r&&n.dirtyRenderBounds.update(r.center,r.halfExtents)},t.prototype.applyAttributesToContext=function(t,e){var n,r=(n=e.parsedStyle).stroke,i=n.fill,a=n.opacity,o=n.lineDash,s=n.lineDashOffset;o&&t.setLineDash(o),N(s)||(t.lineDashOffset=s),N(a)||(t.globalAlpha*=a),N(r)||Array.isArray(r)||r.isNone||(t.strokeStyle=e.attributes.stroke),N(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},t.prototype.applyWorldTransform=function(t,e,n){var r=0,i=0,a=(e.parsedStyle||{}).anchor,o=a&&a[0]||0,s=a&&a[1]||0;if(0!==o||0!==s){var c=e.geometry.contentBounds;r=-o*(c&&2*c.halfExtents[0]||0),i=-s*(c&&2*c.halfExtents[1]||0)}n?(b(this.tmpMat4,e.getLocalTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,P(this.tmpMat4,this.tmpMat4,this.vec3a),S(this.tmpMat4,n,this.tmpMat4),S(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(b(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,P(this.tmpMat4,this.tmpMat4,this.vec3a),S(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},t.prototype.safeMergeAABB=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];var r=new e.AABB;return t.forEach((function(t){r.add(t)})),r},t.tag="CanvasRenderer",t}(),dt=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,n,r,i,a,o){var s=n.fill,c=n.fillRule,l=n.opacity,h=n.fillOpacity,u=n.stroke,d=n.strokeOpacity,f=n.lineWidth,p=n.lineCap,v=n.lineJoin,y=n.shadowType,g=n.shadowColor,m=n.shadowBlur,E=n.filter,M=n.miterLimit,x=!N(s)&&!s.isNone,b=!N(u)&&!u.isNone&&f>0,S=0===s.alpha,P=!(!E||!E.length),T=!N(g)&&m>0,C=r.nodeName,A="inner"===y,w=b&&T&&(C===e.Shape.PATH||C===e.Shape.LINE||C===e.Shape.POLYLINE||S||A);x&&(t.globalAlpha=l*h,w||ft(r,t,T),this.fill(t,r,s,c,i,a,o),w||this.clearShadowAndFilter(t,P,T)),b&&(t.globalAlpha=l*d,t.lineWidth=f,N(M)||(t.miterLimit=M),N(p)||(t.lineCap=p),N(v)||(t.lineJoin=v),w&&(A&&(t.globalCompositeOperation="source-atop"),ft(r,t,!0),A&&(this.stroke(t,r,u,i,a,o),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,P,!0))),this.stroke(t,r,u,i,a,o))},t.prototype.clearShadowAndFilter=function(t,e,n){if(n&&(t.shadowColor="transparent",t.shadowBlur=0),e){var r=t.filter;!N(r)&&r.indexOf("drop-shadow")>-1&&(t.filter=r.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},t.prototype.fill=function(t,n,r,i,a,o,s){var c=this;Array.isArray(r)?r.forEach((function(e){t.fillStyle=c.getColor(e,n,t),i?t.fill(i):t.fill()})):(e.isPattern(r)&&(t.fillStyle=this.getPattern(r,n,t,a,o,s)),i?t.fill(i):t.fill())},t.prototype.stroke=function(t,n,r,i,a,o){var s=this;Array.isArray(r)?r.forEach((function(e){t.strokeStyle=s.getColor(e,n,t),t.stroke()})):(e.isPattern(r)&&(t.strokeStyle=this.getPattern(r,n,t,i,a,o)),t.stroke())},t.prototype.getPattern=function(t,e,n,r,i,a){var o,s;if("rect"===t.image.nodeName){var c=t.image.parsedStyle,l=c.width,h=c.height;s=r.contextService.getDPR();var u=r.config.offscreenCanvas;(o=a.offscreenCanvas.getOrCreateCanvas(u)).width=l*s,o.height=h*s;var d=a.offscreenCanvas.getOrCreateContext(u),f=[];t.image.forEach((function(t){i.renderDisplayObject(t,d,r,f,a)})),f.forEach((function(){d.restore()}))}return this.imagePool.getOrCreatePatternSync(t,n,o,s,(function(){e.renderable.dirty=!0,r.renderingService.dirtify()}))},t.prototype.getColor=function(t,n,r){var a;if(t.type===e.GradientType.LinearGradient||t.type===e.GradientType.RadialGradient){var o=n.getGeometryBounds(),s=o&&2*o.halfExtents[0]||1,c=o&&2*o.halfExtents[1]||1;a=this.imagePool.getOrCreateGradient(i(i({type:t.type},t.value),{width:s,height:c}),r)}return a},t}();function ft(t,e,n){var r=t.parsedStyle,i=r.filter,a=r.shadowColor,o=r.shadowBlur,s=r.shadowOffsetX,c=r.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),n&&(e.shadowColor=""+a,e.shadowBlur=o||0,e.shadowOffsetX=s||0,e.shadowOffsetY=c||0)}var pt=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,n){var r,i=e.img,a=e.shadowColor,o=e.shadowBlur,s=e.width,c=e.height;if(F(i)?r=this.imagePool.getImageSync(i):(s||(s=i.width),c||(c=i.height),r=i),r){ft(n,t,!N(a)&&o>0);try{t.drawImage(r,0,0,s,c)}catch(t){}}},t}(),vt=function(){function t(){}return t.prototype.render=function(t,n,r){var i=n.lineWidth,a=n.textAlign,o=n.textBaseline,s=n.lineJoin,c=n.miterLimit,l=n.letterSpacing,h=n.stroke,u=n.fill,d=n.fillOpacity,f=n.strokeOpacity,p=n.opacity,v=n.metrics,y=n.dx,g=n.dy,m=n.shadowColor,E=n.shadowBlur,M=v.lines,x=v.height,b=v.lineHeight,S=v.lineMetrics;t.font=v.font,t.lineWidth=i,t.textAlign="middle"===a?"center":a;var P=o;e.runtime.enableCSSParsing||"alphabetic"!==P||(P="bottom"),t.lineJoin=s,N(c)||(t.miterLimit=c);var T=0;"middle"===o?T=-x/2-b/2:"bottom"===o||"alphabetic"===o||"ideographic"===o?T=-x:"top"!==o&&"hanging"!==o||(T=-b);var C=y||0;T+=g||0,1===M.length&&("bottom"===P?(P="middle",T-=.5*x):"top"===P&&(P="middle",T+=.5*x)),t.textBaseline=P,ft(r,t,!N(m)&&E>0);for(var A=0;M.length>A;A++){var w=i/2+C;T+=b,N(h)||h.isNone||!i||this.drawLetterSpacing(t,M[A],S[A],a,w,T,l,d,f,p,!0),N(u)||this.drawLetterSpacing(t,M[A],S[A],a,w,T,l,d,f,p)}},t.prototype.drawLetterSpacing=function(t,e,n,r,i,a,o,s,c,l,h){if(void 0===h&&(h=!1),0!==o){var u=t.textAlign;t.textAlign="left";var d=i;"center"===r||"middle"===r?d=i-n.width/2:"right"!==r&&"end"!==r||(d=i-n.width);for(var f=Array.from(e),p=t.measureText(e).width,v=0,y=0;f.length>y;++y){var g=f[y];h?this.strokeText(t,g,d,a,c):this.fillText(t,g,d,a,s,l),d+=p-(v=t.measureText(e.substring(y+1)).width)+o,p=v}t.textAlign=u}else h?this.strokeText(t,e,i,a,c):this.fillText(t,e,i,a,s,l)},t.prototype.fillText=function(t,e,n,r,i,a){var o,s=!N(i)&&1!==i;s&&(o=t.globalAlpha,t.globalAlpha=i*a),t.fillText(e,n,r),s&&(t.globalAlpha=o)},t.prototype.strokeText=function(t,e,n,r,i){var a,o=!N(i)&&1!==i;o&&(a=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,n,r),o&&(t.globalAlpha=a)},t}(),yt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),gt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),mt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),Et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),Mt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),xt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),St=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="canvas-renderer",n}return r(n,t),n.prototype.init=function(){var t,n=i({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),r=this.context.imagePool,a=new dt(r),o=((t={})[e.Shape.CIRCLE]=a,t[e.Shape.ELLIPSE]=a,t[e.Shape.RECT]=a,t[e.Shape.IMAGE]=new pt(r),t[e.Shape.TEXT]=new vt,t[e.Shape.LINE]=a,t[e.Shape.POLYLINE]=a,t[e.Shape.POLYGON]=a,t[e.Shape.PATH]=a,t[e.Shape.GROUP]=void 0,t[e.Shape.HTML]=void 0,t[e.Shape.MESH]=void 0,t);this.context.defaultStyleRendererFactory=o,this.context.styleRendererFactory=o,this.addRenderingPlugin(new ut(n))},n.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},n}(e.AbstractRendererPlugin),Pt=Object.freeze({__proto__:null,CircleRenderer:gt,EllipseRenderer:mt,ImageRenderer:pt,LineRenderer:Et,PathRenderer:bt,Plugin:St,PolygonRenderer:xt,PolylineRenderer:Mt,RectRenderer:yt,TextRenderer:vt}),Tt=function(){function t(){}return t.prototype.apply=function(e,n){var r=this,i=e.renderingService,a=e.renderingContext,o=e.config;this.context=e;var s=a.root.ownerDocument.defaultView,c=function(t){i.hooks.pointerMove.call(t)},l=function(t){i.hooks.pointerUp.call(t)},h=function(t){i.hooks.pointerDown.call(t)},u=function(t){i.hooks.pointerOver.call(t)},d=function(t){i.hooks.pointerOut.call(t)},f=function(t){i.hooks.pointerCancel.call(t)},p=function(t){i.hooks.pointerWheel.call(t)},v=function(t){i.hooks.click.call(t)};i.hooks.init.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="none",t.style.msTouchAction="none"):s.supportsPointerEvents&&(t.style.touchAction="none"),s.supportsPointerEvents?function(t){n.globalThis.document.addEventListener("pointermove",c,!0),t.addEventListener("pointerdown",h,!0),t.addEventListener("pointerleave",d,!0),t.addEventListener("pointerover",u,!0),n.globalThis.addEventListener("pointerup",l,!0),n.globalThis.addEventListener("pointercancel",f,!0)}(t):function(t){n.globalThis.document.addEventListener("mousemove",c,!0),t.addEventListener("mousedown",h,!0),t.addEventListener("mouseout",d,!0),t.addEventListener("mouseover",u,!0),n.globalThis.addEventListener("mouseup",l,!0)}(t),s.supportsTouchEvents&&function(t){t.addEventListener("touchstart",h,!0),t.addEventListener("touchend",l,!0),t.addEventListener("touchmove",c,!0),t.addEventListener("touchcancel",f,!0)}(t),o.useNativeClickEvent&&t.addEventListener("click",v,!0),t.addEventListener("wheel",p,{passive:!0,capture:!0})})),i.hooks.destroy.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="",t.style.msTouchAction=""):s.supportsPointerEvents&&(t.style.touchAction=""),s.supportsPointerEvents?function(t){n.globalThis.document.removeEventListener("pointermove",c,!0),t.removeEventListener("pointerdown",h,!0),t.removeEventListener("pointerleave",d,!0),t.removeEventListener("pointerover",u,!0),n.globalThis.removeEventListener("pointerup",l,!0)}(t):function(t){n.globalThis.document.removeEventListener("mousemove",c,!0),t.removeEventListener("mousedown",h,!0),t.removeEventListener("mouseout",d,!0),t.removeEventListener("mouseover",u,!0),n.globalThis.removeEventListener("mouseup",l,!0)}(t),s.supportsTouchEvents&&function(t){t.removeEventListener("touchstart",h,!0),t.removeEventListener("touchend",l,!0),t.removeEventListener("touchmove",c,!0),t.removeEventListener("touchcancel",f,!0)}(t),o.useNativeClickEvent&&t.removeEventListener("click",v,!0),t.removeEventListener("wheel",p,!0)}))},t.tag="DOMInteraction",t}(),Ct=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="dom-interaction",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new Tt)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(e.AbstractRendererPlugin),At=Object.freeze({__proto__:null,Plugin:Ct}),wt=function(){function t(){}return t.prototype.joinTransformMatrix=function(t){return"matrix(".concat([t[0],t[1],t[4],t[5],t[12],t[13]].join(","),")")},t.prototype.apply=function(n){var r=this,i=n.camera,a=n.renderingContext,o=n.renderingService;this.context=n;var s=a.root.ownerDocument.defaultView,c=function(t,e){e.style.transform=r.joinTransformMatrix(t.getWorldTransform())},l=function(t){var n=t.target;if(n.nodeName===e.Shape.HTML){r.$camera||(r.$camera=r.createCamera(i));var a=r.getOrCreateEl(n);r.$camera.appendChild(a);var o=n.ownerDocument.documentElement.attributes;Object.keys(o).forEach((function(t){a.style[t]=o[t]})),Object.keys(n.attributes).forEach((function(t){r.updateAttribute(t,n)})),c(n,a),e.runtime.nativeHTMLMap.set(a,n)}},h=function(t){var n=t.target;if(n.nodeName===e.Shape.HTML&&r.$camera){var i=r.getOrCreateEl(n);i&&(i.remove(),e.runtime.nativeHTMLMap.delete(i))}},u=function(t){var n=t.target;n.nodeName===e.Shape.HTML&&r.updateAttribute(t.attrName,n)},d=function(t){var n=t.target;if(n.nodeName===e.Shape.HTML){var i=r.getOrCreateEl(n);c(n,i)}},f=function(){if(r.$camera){var t=r.context.config,e=t.height;r.$camera.style.width="".concat(t.width||0,"px"),r.$camera.style.height="".concat(e||0,"px")}};o.hooks.init.tap(t.tag,(function(){s.addEventListener(e.CanvasEvent.RESIZE,f),s.addEventListener(e.ElementEvent.MOUNTED,l),s.addEventListener(e.ElementEvent.UNMOUNTED,h),s.addEventListener(e.ElementEvent.ATTR_MODIFIED,u),s.addEventListener(e.ElementEvent.BOUNDS_CHANGED,d)})),o.hooks.endFrame.tap(t.tag,(function(){r.$camera&&a.renderReasons.has(e.RenderReason.CAMERA_CHANGED)&&(r.$camera.style.transform=r.joinTransformMatrix(i.getOrthoMatrix()))})),o.hooks.destroy.tap(t.tag,(function(){r.$camera&&r.$camera.remove(),s.removeEventListener(e.CanvasEvent.RESIZE,f),s.removeEventListener(e.ElementEvent.MOUNTED,l),s.removeEventListener(e.ElementEvent.UNMOUNTED,h),s.removeEventListener(e.ElementEvent.ATTR_MODIFIED,u),s.removeEventListener(e.ElementEvent.BOUNDS_CHANGED,d)}))},t.prototype.getId=function(t){return t.id||"g-html-"+t.entity},t.prototype.createCamera=function(t){var e,n=(e=this.context.config).document,r=e.width,i=e.height,a=this.context.contextService.getDomElement(),o=a.parentNode;if(o){var s="g-canvas-camera",c=o.querySelector("#"+s);if(!c){var l=(n||document).createElement("div");c=l,l.id=s,l.style.position="absolute",l.style.left="".concat(a.offsetLeft||0,"px"),l.style.top="".concat(a.offsetTop||0,"px"),l.style.transformOrigin="left top",l.style.transform=this.joinTransformMatrix(t.getOrthoMatrix()),l.style.overflow="hidden",l.style.pointerEvents="none",l.style.width="".concat(r||0,"px"),l.style.height="".concat(i||0,"px"),o.appendChild(l)}return c}return null},t.prototype.getOrCreateEl=function(t){var e=this.context.config.document,n=this.getId(t),r=this.$camera.querySelector("#"+n);return r||(r=(e||document).createElement("div"),t.parsedStyle.$el=r,r.id=n,t.name&&r.setAttribute("name",t.name),t.className&&(r.className=t.className),r.style.position="absolute",r.style.left="0px",r.style.top="0px",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(t.getWorldTransform())),r},t.prototype.updateAttribute=function(t,n){var r=this.getOrCreateEl(n);switch(t){case"innerHTML":var i=n.parsedStyle.innerHTML;F(i)?r.innerHTML=i:(r.innerHTML="",r.appendChild(i));break;case"transformOrigin":var a=n.parsedStyle.transformOrigin;r.style["transform-origin"]="".concat(a[0].value," ").concat(a[1].value);break;case"width":if(e.runtime.enableCSSParsing){var o=n.computedStyleMap().get("width");r.style.width=""+o}else{r.style.width=j(o=n.parsedStyle.width)?"".concat(o,"px"):""+o}break;case"height":if(e.runtime.enableCSSParsing){var s=n.computedStyleMap().get("height");r.style.height=""+s}else{r.style.height=j(s=n.parsedStyle.height)?"".concat(s,"px"):""+s}break;case"zIndex":r.style["z-index"]="".concat(n.parsedStyle.zIndex);break;case"visibility":r.style.visibility=n.parsedStyle.visibility;break;case"pointerEvents":r.style.pointerEvents=n.parsedStyle.pointerEvents;break;case"opacity":r.style.opacity="".concat(n.parsedStyle.opacity);break;case"fill":var c=n.parsedStyle.fill,l="";e.isCSSRGB(c)?l=c.isNone?"transparent":n.getAttribute("fill"):Array.isArray(c)?l=n.getAttribute("fill"):e.isPattern(c),r.style.background=l;break;case"stroke":var h=n.parsedStyle.stroke,u="";e.isCSSRGB(h)?u=h.isNone?"transparent":n.getAttribute("stroke"):Array.isArray(h)?u=n.getAttribute("stroke"):e.isPattern(h),r.style["border-color"]=u,r.style["border-style"]="solid";break;case"lineWidth":r.style["border-width"]="".concat(n.parsedStyle.lineWidth||0,"px");break;case"lineDash":r.style["border-style"]="dashed";break;case"filter":r.style.filter=n.style.filter}},t.tag="HTMLRendering",t}(),Ot=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="html-renderer",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new wt)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(e.AbstractRendererPlugin),kt=Object.freeze({__proto__:null,Plugin:Ot}),Lt=function(){function t(t){this.canvasConfig=t,this.imageCache={},this.gradientCache={},this.patternCache={}}return t.prototype.getImageSync=function(t,e){return this.imageCache[t]?e&&e():this.getOrCreateImage(t).then((function(){e&&e()})),this.imageCache[t]},t.prototype.getOrCreateImage=function(t){var n=this;if(this.imageCache[t])return Promise.resolve(this.imageCache[t]);var r=this.canvasConfig.createImage;return new Promise((function(i,a){var o;r?o=r(t):e.isBrowser&&(o=new window.Image),o&&(o.onload=function(){n.imageCache[t]=o,i(o)},o.onerror=function(t){a(t)},o.crossOrigin="Anonymous",o.src=t)}))},t.prototype.getOrCreatePatternSync=function(t,n,r,i,a){var o=this.generatePatternKey(t);if(o&&this.patternCache[o])return this.patternCache[o];var s,c=t.image,l=t.repetition,h=t.transform,u=!1;F(c)?s=this.getImageSync(c,a):r?(s=r,u=!0):s=c;var d,f=s&&n.createPattern(s,l);if(f){var p=void 0;h?p=e.parsedTransformToMat4(e.parseTransform(h),new e.DisplayObject({})):((d=x())[0]=1,d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[5]=1,d[6]=0,d[7]=0,d[8]=0,d[9]=0,d[10]=1,d[11]=0,d[12]=0,d[13]=0,d[14]=0,d[15]=1,p=d),u&&function(t,e,n){var r=n[0],i=n[1],a=n[2];t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]}(p,p,[1/i,1/i,1]),f.setTransform({a:p[0],b:p[1],c:p[4],d:p[5],e:p[12],f:p[13]})}return o&&f&&(this.patternCache[o]=f),f},t.prototype.getOrCreateGradient=function(t,n){var r=this.generateGradientKey(t),i=t.type,a=t.steps,o=t.width,s=t.height,c=t.cx,l=t.cy,h=t.size;if(this.gradientCache[r])return this.gradientCache[r];var u=null;if(i===e.GradientType.LinearGradient){var d=e.computeLinearGradient(o,s,t.angle);u=n.createLinearGradient(d.x1,d.y1,d.x2,d.y2)}else if(i===e.GradientType.RadialGradient){var f=e.computeRadialGradient(o,s,c,l,h),p=f.x,v=f.y;u=n.createRadialGradient(p,v,0,p,v,f.r)}return u&&(a.forEach((function(t){var n=t.offset;n.unit===e.UnitType.kPercentage&&(null==u||u.addColorStop(n.value/100,""+t.color))})),this.gradientCache[r]=u),this.gradientCache[r]},t.prototype.generateGradientKey=function(t){var e=t.width,n=t.height,r=t.steps,i=t.angle,a=t.cx,o=t.cy,s=t.size;return"gradient-".concat(t.type,"-").concat((null==i?void 0:""+i)||0,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat(e,"-").concat(n,"-").concat(r.map((function(t){var e=t.color;return"".concat(t.offset).concat(e)})).join("-"))},t.prototype.generatePatternKey=function(t){var e=t.image,n=t.repetition;return F(e)?"pattern-".concat(e,"-").concat(n):"rect"===e.nodeName?"pattern-".concat(e.entity,"-").concat(n):void 0},t}(),Rt=function(){function t(){}return t.prototype.apply=function(n){var r=n.renderingService,i=n.imagePool,a=n.renderingContext.root.ownerDocument.defaultView,o=function(t){var n=t.target;if(n.nodeName===e.Shape.IMAGE){var a=n.attributes.img;F(a)&&i.getImageSync(a,(function(){n.renderable.dirty=!0,r.dirtify()}))}},s=function(t){var n=t.target,a=t.newValue;n.nodeName===e.Shape.IMAGE&&"img"===t.attrName&&F(a)&&i.getOrCreateImage(a).then((function(){n.renderable.dirty=!0,r.dirtify()}))};r.hooks.init.tap(t.tag,(function(){a.addEventListener(e.ElementEvent.MOUNTED,o),a.addEventListener(e.ElementEvent.ATTR_MODIFIED,s)})),r.hooks.destroy.tap(t.tag,(function(){a.removeEventListener(e.ElementEvent.MOUNTED,o),a.removeEventListener(e.ElementEvent.ATTR_MODIFIED,s)}))},t.tag="LoadImage",t}(),It=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="image-loader",e}return r(e,t),e.prototype.init=function(){this.context.imagePool=new Lt(this.context.config),this.addRenderingPlugin(new Rt)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(e.AbstractRendererPlugin),Nt=Object.freeze({__proto__:null,ImagePool:Lt,Plugin:It}),Dt=function(){function t(t){this.renderingContext=t.renderingContext,this.canvasConfig=t.config}return t.prototype.init=function(){var t=this.canvasConfig,e=t.container,n=t.canvas;if(n)this.$canvas=n,e&&n.parentElement!==e&&e.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(e&&(this.$container=l(e,"String")?document.getElementById(e):e,this.$container)){var r=document.createElement("canvas");this.$container.appendChild(r),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=r}this.context=this.$canvas.getContext("2d"),this.resize(this.canvasConfig.width,this.canvasConfig.height)},t.prototype.getContext=function(){return this.context},t.prototype.getDomElement=function(){return this.$canvas},t.prototype.getDPR=function(){return this.dpr},t.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},t.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},t.prototype.resize=function(t,n){var r=this.canvasConfig.devicePixelRatio||e.isBrowser&&window.devicePixelRatio||1;this.dpr=r=1>r?1:Math.ceil(r),this.$canvas&&(this.$canvas.width=this.dpr*t,this.$canvas.height=this.dpr*n,e.setDOMSize(this.$canvas,t,n)),this.renderingContext.renderReasons.add(e.RenderReason.CAMERA_CHANGED)},t.prototype.applyCursorStyle=function(t){this.$container&&this.$container.style&&(this.$container.style.cursor=t)},t.prototype.toDataURL=function(t){return void 0===t&&(t={}),a(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.context.canvas.toDataURL(t.type,t.encoderOptions)]}))}))},t}(),Bt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="canvas-context-register",e}return r(e,t),e.prototype.init=function(){this.context.ContextService=Dt},e.prototype.destroy=function(){delete this.context.ContextService},e}(e.AbstractRendererPlugin),Ft=function(t){function e(e){var n=t.call(this,e)||this;return n.registerPlugin(new Bt),n.registerPlugin(new It),n.registerPlugin(new m),n.registerPlugin(new St),n.registerPlugin(new Ct),n.registerPlugin(new lt),n.registerPlugin(new Ot),n}return r(e,t),e}(e.AbstractRenderer);t.CanvasPathGenerator=E,t.CanvasPicker=ht,t.CanvasRenderer=Pt,t.DomInteraction=At,t.HTMLRenderer=kt,t.ImageLoader=Nt,t.Renderer=Ft}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.Canvas2D={}),t.window.G)}(this,(function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+e+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;r>n;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function a(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(t){try{c(r.next(t))}catch(t){a(t)}}function s(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,s)}c((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&i[3]>s[1])){o.label=s[1];break}if(6===s[0]&&i[1]>o.label){o.label=i[1],i=s;break}if(i&&i[2]>o.label){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function s(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,a=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=a.next()).done;)o.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return o}var c={}.toString,l=function(t,e){return c.call(t)==="[object "+e+"]"},h=function(t,e,n){return e>t?e:t>n?n:t};function u(t,e){var n=e.r;t.arc(n,n,n,0,2*Math.PI,!1)}function d(t,e){var n=e.rx,r=e.ry;if(t.ellipse)t.ellipse(n,r,n,r,0,0,2*Math.PI,!1);else{var i=n>r?n:r,a=n>r?1:n/r,o=n>r?r/n:1;t.save(),t.scale(a,o),t.arc(0,0,i,0,2*Math.PI)}}function f(t,n){var r=n.x1,i=n.y1,a=n.x2,o=n.y2,s=n.defX,c=void 0===s?0:s,l=n.defY,h=void 0===l?0:l,u=n.markerStart,d=n.markerEnd,f=n.markerStartOffset,p=n.markerEndOffset,v=0,y=0,g=0,m=0,E=0;u&&e.isDisplayObject(u)&&f&&(v=Math.cos(E=Math.atan2(o-i,a-r))*(f||0),y=Math.sin(E)*(f||0)),d&&e.isDisplayObject(d)&&p&&(g=Math.cos(E=Math.atan2(i-o,r-a))*(p||0),m=Math.sin(E)*(p||0)),t.moveTo(r-c+v,i-h+y),t.lineTo(a-c+g,o-h+m)}function p(t,n){var r=n.defX,i=void 0===r?0:r,a=n.defY,o=void 0===a?0:a,c=n.markerStart,l=n.markerEnd,h=n.markerStartOffset,u=n.markerEndOffset,d=n.path,f=d.absolutePath,p=d.segments,v=0,y=0,g=0,m=0,E=0;if(c&&e.isDisplayObject(c)&&h){var M=s(c.parentNode.getStartTangent(),2);v=Math.cos(E=Math.atan2((x=M[0])[1]-(b=M[1])[1],x[0]-b[0]))*(h||0),y=Math.sin(E)*(h||0)}if(l&&e.isDisplayObject(l)&&u){var x,b,S=s(l.parentNode.getEndTangent(),2);g=Math.cos(E=Math.atan2((x=S[0])[1]-(b=S[1])[1],x[0]-b[0]))*(u||0),m=Math.sin(E)*(u||0)}for(var P=0;f.length>P;P++){var T=f[P],C=f[P+1],A=0===P&&(0!==v||0!==y),w=(P===f.length-1||C&&("M"===C[0]||"Z"===C[0]))&&0!==g&&0!==m;switch(T[0]){case"M":A?(t.moveTo(T[1]-i+v,T[2]-o+y),t.lineTo(T[1]-i,T[2]-o)):t.moveTo(T[1]-i,T[2]-o);break;case"L":w?t.lineTo(T[1]-i+g,T[2]-o+m):t.lineTo(T[1]-i,T[2]-o);break;case"Q":t.quadraticCurveTo(T[1]-i,T[2]-o,T[3]-i,T[4]-o),w&&t.lineTo(T[3]-i+g,T[4]-o+m);break;case"C":t.bezierCurveTo(T[1]-i,T[2]-o,T[3]-i,T[4]-o,T[5]-i,T[6]-o),w&&t.lineTo(T[5]-i+g,T[6]-o+m);break;case"A":var O=p[P].arcParams,k=O.cx,L=O.cy,R=O.rx,I=O.ry,N=O.startAngle,D=O.endAngle,B=O.xRotation,F=O.sweepFlag;if(t.ellipse)t.ellipse(k-i,L-o,R,I,B,N,D,!!(1-F));else{var G=R>I?R:I,j=R>I?1:R/I,_=R>I?I/R:1;t.translate(k-i,L-o),t.rotate(B),t.scale(j,_),t.arc(0,0,G,N,D,!!(1-F)),t.scale(1/j,1/_),t.rotate(-B),t.translate(-(k-i),-(L-o))}w&&t.lineTo(T[6]-i+g,T[7]-o+m);break;case"Z":t.closePath()}}}function v(t,n){var r=n.defX,i=void 0===r?0:r,a=n.defY,o=void 0===a?0:a,s=n.markerStart,c=n.markerEnd,l=n.markerStartOffset,h=n.markerEndOffset,u=n.points.points,d=u.length,f=u[0][0]-i,p=u[0][1]-o,v=u[d-1][0]-i,y=u[d-1][1]-o,g=0,m=0,E=0,M=0,x=0;s&&e.isDisplayObject(s)&&l&&(g=Math.cos(x=Math.atan2(u[1][1]-u[0][1],u[1][0]-u[0][0]))*(l||0),m=Math.sin(x)*(l||0)),c&&e.isDisplayObject(c)&&h&&(E=Math.cos(x=Math.atan2(u[d-1][1]-u[0][1],u[d-1][0]-u[0][0]))*(h||0),M=Math.sin(x)*(h||0)),t.moveTo(f+(g||E),p+(m||M));for(var b=1;d-1>b;b++){var S=u[b];t.lineTo(S[0]-i,S[1]-o)}t.lineTo(v,y)}function y(t,n){var r=n.defX,i=void 0===r?0:r,a=n.defY,o=void 0===a?0:a,s=n.markerStart,c=n.markerEnd,l=n.markerStartOffset,h=n.markerEndOffset,u=n.points.points,d=u.length,f=u[0][0]-i,p=u[0][1]-o,v=u[d-1][0]-i,y=u[d-1][1]-o,g=0,m=0,E=0,M=0,x=0;s&&e.isDisplayObject(s)&&l&&(g=Math.cos(x=Math.atan2(u[1][1]-u[0][1],u[1][0]-u[0][0]))*(l||0),m=Math.sin(x)*(l||0)),c&&e.isDisplayObject(c)&&h&&(E=Math.cos(x=Math.atan2(u[d-2][1]-u[d-1][1],u[d-2][0]-u[d-1][0]))*(h||0),M=Math.sin(x)*(h||0)),t.moveTo(f+g,p+m);for(var b=1;d-1>b;b++){var S=u[b];t.lineTo(S[0]-i,S[1]-o)}t.lineTo(v+E,y+M)}function g(t,e){var n=e.radius,r=e.width,i=e.height,a=r,o=i;if(n&&n.some((function(t){return 0!==t}))){var c=r>0?1:-1,l=i>0?1:-1,u=c+l===0,d=s(n.map((function(t){return h(t,0,Math.min(Math.abs(a)/2,Math.abs(o)/2))})),4),f=d[0],p=d[1],v=d[2],y=d[3];t.moveTo(c*f,0),t.lineTo(a-c*p,0),0!==p&&t.arc(a-c*p,l*p,p,-l*Math.PI/2,c>0?0:Math.PI,u),t.lineTo(a,o-l*v),0!==v&&t.arc(a-c*v,o-l*v,v,c>0?0:Math.PI,l>0?Math.PI/2:1.5*Math.PI,u),t.lineTo(c*y,o),0!==y&&t.arc(c*y,o-l*y,y,l>0?Math.PI/2:-Math.PI/2,c>0?Math.PI:0,u),t.lineTo(0,l*f),0!==f&&t.arc(c*f,l*f,f,c>0?Math.PI:0,l>0?1.5*Math.PI:Math.PI/2,u)}else t.rect(0,0,a,o)}var m=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="canvas-path-generator",e}return r(n,t),n.prototype.init=function(){var t,n=((t={})[e.Shape.CIRCLE]=u,t[e.Shape.ELLIPSE]=d,t[e.Shape.RECT]=g,t[e.Shape.LINE]=f,t[e.Shape.POLYLINE]=y,t[e.Shape.POLYGON]=v,t[e.Shape.PATH]=p,t[e.Shape.TEXT]=void 0,t[e.Shape.GROUP]=void 0,t[e.Shape.IMAGE]=void 0,t[e.Shape.HTML]=void 0,t[e.Shape.MESH]=void 0,t);this.context.pathGeneratorFactory=n},n.prototype.destroy=function(){delete this.context.pathGeneratorFactory},n}(e.AbstractRendererPlugin),E=Object.freeze({__proto__:null,Plugin:m}),M="undefined"!=typeof Float32Array?Float32Array:Array;function x(){var t=new M(16);return M!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function b(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function S(t,e,n){var r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],d=e[9],f=e[10],p=e[11],v=e[12],y=e[13],g=e[14],m=e[15],E=n[0],M=n[1],x=n[2],b=n[3];return t[0]=E*r+M*s+x*u+b*v,t[1]=E*i+M*c+x*d+b*y,t[2]=E*a+M*l+x*f+b*g,t[3]=E*o+M*h+x*p+b*m,t[4]=(E=n[4])*r+(M=n[5])*s+(x=n[6])*u+(b=n[7])*v,t[5]=E*i+M*c+x*d+b*y,t[6]=E*a+M*l+x*f+b*g,t[7]=E*o+M*h+x*p+b*m,t[8]=(E=n[8])*r+(M=n[9])*s+(x=n[10])*u+(b=n[11])*v,t[9]=E*i+M*c+x*d+b*y,t[10]=E*a+M*l+x*f+b*g,t[11]=E*o+M*h+x*p+b*m,t[12]=(E=n[12])*r+(M=n[13])*s+(x=n[14])*u+(b=n[15])*v,t[13]=E*i+M*c+x*d+b*y,t[14]=E*a+M*l+x*f+b*g,t[15]=E*o+M*h+x*p+b*m,t}function P(t,e,n){var r,i,a,o,s,c,l,h,u,d,f,p,v=n[0],y=n[1],g=n[2];return e===t?(t[12]=e[0]*v+e[4]*y+e[8]*g+e[12],t[13]=e[1]*v+e[5]*y+e[9]*g+e[13],t[14]=e[2]*v+e[6]*y+e[10]*g+e[14],t[15]=e[3]*v+e[7]*y+e[11]*g+e[15]):(i=e[1],a=e[2],o=e[3],s=e[4],c=e[5],l=e[6],h=e[7],u=e[8],d=e[9],f=e[10],p=e[11],t[0]=r=e[0],t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=h,t[8]=u,t[9]=d,t[10]=f,t[11]=p,t[12]=r*v+s*y+u*g+e[12],t[13]=i*v+c*y+d*g+e[13],t[14]=a*v+l*y+f*g+e[14],t[15]=o*v+h*y+p*g+e[15]),t}function T(){var t=new M(3);return M!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function C(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function A(t,e,n){var r=e[0],i=e[1],a=e[2],o=n[3]*r+n[7]*i+n[11]*a+n[15];return t[0]=(n[0]*r+n[4]*i+n[8]*a+n[12])/(o=o||1),t[1]=(n[1]*r+n[5]*i+n[9]*a+n[13])/o,t[2]=(n[2]*r+n[6]*i+n[10]*a+n[14])/o,t}function w(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function O(t,e,n,r,i,a,o,s,c,l){var h,u,d,f,p,v=t,y=e,g=n,m=r,E=s,M=c,x=120*Math.PI/180,b=Math.PI/180*(+i||0),S=[];if(l)u=l[0],d=l[1],f=l[2],p=l[3];else{y=(h=w(v,y,-b)).y;var P=((v=h.x)-(E=(h=w(E,M,-b)).x))/2,T=(y-(M=h.y))/2,C=P*P/(g*g)+T*T/(m*m);C>1&&(g*=C=Math.sqrt(C),m*=C);var A=g*g,k=m*m,L=(a===o?-1:1)*Math.sqrt(Math.abs((A*k-A*T*T-k*P*P)/(A*T*T+k*P*P)));f=L*g*T/m+(v+E)/2,u=Math.asin(((y-(p=L*-m*P/g+(y+M)/2))/m*1e9>>0)/1e9),d=Math.asin(((M-p)/m*1e9>>0)/1e9),0>(u=f>v?Math.PI-u:u)&&(u=2*Math.PI+u),0>(d=f>E?Math.PI-d:d)&&(d=2*Math.PI+d),o&&u>d&&(u-=2*Math.PI),!o&&d>u&&(d-=2*Math.PI)}var R=d-u;if(Math.abs(R)>x){var I=d,N=E,D=M;S=O(E=f+g*Math.cos(d=u+x*(o&&d>u?1:-1)),M=p+m*Math.sin(d),g,m,i,0,o,N,D,[d,I,f,p])}R=d-u;var B=Math.cos(u),F=Math.sin(u),G=Math.cos(d),j=Math.sin(d),_=Math.tan(R/4),H=4/3*g*_,$=4/3*m*_,W=[v,y],U=[v+H*F,y-$*B],Y=[E+H*j,M-$*G],X=[E,M];if(U[0]=2*W[0]-U[0],U[1]=2*W[1]-U[1],l)return U.concat(Y,X,S);for(var z=[],q=0,Q=(S=U.concat(Y,X,S)).length;Q>q;q+=1)z[q]=q%2?w(S[q-1],S[q],b).y:w(S[q],S[q+1],b).x;return z}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),T(),function(){var t,e=(t=new M(2),M!=Float32Array&&(t[0]=0,t[1]=0),t)}();var k=function(t){return null==t},L={}.toString,R=function(t,e){return L.call(t)==="[object "+e+"]"},I=function(t){return R(t,"String")},N=function(t,e,n){return e>t?e:t>n?n:t},D=function(t){return R(t,"Number")};function B(t,e,n,r){var i=t-n,a=e-r;return Math.sqrt(i*i+a*a)}function F(t,e,n,r,i,a){var o=[n-t,r-e];if(function(t,e){return t[0]===e[0]&&t[1]===e[1]}(o,[0,0]))return Math.sqrt((i-t)*(i-t)+(a-e)*(a-e));var s=[-o[1],o[0]];return function(t,e){var n=e[0],r=e[1],i=n*n+r*r;i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i}(s,s),Math.abs(function(t,e){return t[0]*e[0]+t[1]*e[1]}([i-t,a-e],s))}function G(t,e,n,r,i,a,o,s,c,l,h){var u=this.nearestPoint(t,e,n,r,i,a,o,s,c,l,h);return B(u.x,u.y,c,l)}function j(t,e,n,r,i,a,o,s){var c=this.nearestPoint(t,e,n,r,i,a,o,s);return B(c.x,c.y,o,s)}var _=T(),H=T(),$=T(),W=x(),U=function(){function t(){var t=this;this.isHit=function(n,r,i,a){var o,s,c,l,h,u,d,f,p,v,y,g,m,E,M,x,b,S,P,T,w,O,k,L,R,I,N,D,B,F,G,j=t.context.pointInPathPickerFactory[n.nodeName];if(j){var _=(o=W,(G=(P=(c=(s=i)[0])*(f=s[5])-(l=s[1])*(d=s[4]))*(F=(m=s[10])*(S=s[15])-(E=s[11])*(b=s[14]))-(T=c*(p=s[6])-(h=s[2])*d)*(B=(g=s[9])*S-E*(x=s[13]))+(w=c*(v=s[7])-(u=s[3])*d)*(D=g*b-m*x)+(O=l*p-h*f)*(N=(y=s[8])*S-E*(M=s[12]))-(k=l*v-u*f)*(I=y*b-m*M)+(L=h*v-u*p)*(R=y*x-g*M))?(o[0]=(f*F-p*B+v*D)*(G=1/G),o[1]=(h*B-l*F-u*D)*G,o[2]=(x*L-b*k+S*O)*G,o[3]=(m*k-g*L-E*O)*G,o[4]=(p*N-d*F-v*I)*G,o[5]=(c*F-h*N+u*I)*G,o[6]=(b*w-M*L-S*T)*G,o[7]=(y*L-m*w+E*T)*G,o[8]=(d*B-f*N+v*R)*G,o[9]=(l*N-c*B-u*R)*G,o[10]=(M*k-x*w+S*P)*G,o[11]=(g*w-y*k-E*P)*G,o[12]=(f*I-d*D-p*R)*G,o[13]=(c*D-l*I+h*R)*G,o[14]=(x*T-M*O-b*P)*G,o[15]=(y*O-g*T+m*P)*G,o):null),U=A(H,C($,r[0],r[1],0),_),Y=n.getGeometryBounds().halfExtents,X=n.parsedStyle.anchor;if(U[0]+=(X&&X[0]||0)*Y[0]*2,U[1]+=(X&&X[1]||0)*Y[1]*2,j(n,new e.Point(U[0],U[1]),a,t.isPointInPath,t.context,t.runtime))return!0}return!1},this.isPointInPath=function(e,n){var r=t.runtime.offscreenCanvas.getOrCreateContext(t.context.config.offscreenCanvas),i=t.context.pathGeneratorFactory[e.nodeName];return i&&(r.beginPath(),i(r,e.parsedStyle),r.closePath()),r.isPointInPath(n.x,n.y)}}return t.prototype.apply=function(e,n){var r,i=this,s=e.renderingService,c=e.renderingContext;this.context=e,this.runtime=n;var l=null===(r=c.root)||void 0===r?void 0:r.ownerDocument;s.hooks.pick.tapPromise(t.tag,(function(t){return a(i,void 0,void 0,(function(){return o(this,(function(e){return[2,this.pick(l,t)]}))}))})),s.hooks.pickSync.tap(t.tag,(function(t){return i.pick(l,t)}))},t.prototype.pick=function(t,n){var r,i,a,o=n.topmost,s=(r=n.position).x,c=C(_,s,r.y,0),l=t.elementsFromBBox(c[0],c[1],c[0],c[1]),h=[];try{for(var u=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(l),d=u.next();!d.done;d=u.next()){var f=d.value,p=f.getWorldTransform();if(this.isHit(f,c,p,!1)){var v=e.findClosestClipPathTarget(f);if(v){var y=v.parsedStyle.clipPath;if(this.isHit(y,c,y.getWorldTransform(),!0)){if(o)return n.picked=[f],n;h.push(f)}}else{if(o)return n.picked=[f],n;h.push(f)}}}}catch(t){i={error:t}}finally{try{d&&!d.done&&(a=u.return)&&a.call(u)}finally{if(i)throw i.error}}return n.picked=h,n},t.tag="CanvasPicker",t}();function Y(t,n,r){var i=t.parsedStyle,a=i.r,o=i.fill,c=i.stroke,l=i.pointerEvents,h=((i.lineWidth||0)+(i.increasedLineWidthForHitTesting||0))/2,u=B(a,a,n.x,n.y),d=s(e.isFillOrStrokeAffected(l,o,c),2),f=d[0],p=d[1];return f&&p||r?a+h>=u:f?a>=u:!!p&&(u>=a-h&&a+h>=u)}function X(t,e,n,r){return t/(n*n)+e/(r*r)}function z(t,n,r){var i=t.parsedStyle,a=i.rx,o=i.ry,c=i.lineWidth,l=i.increasedLineWidthForHitTesting,h=n.x,u=n.y,d=s(e.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke),2),f=d[0],p=d[1],v=((c||0)+(l||0))/2,y=(h-a)*(h-a),g=(u-o)*(u-o);return f&&p||r?1>=X(y,g,a+v,o+v):f?1>=X(y,g,a,o):!!p&&(X(y,g,a-v,o-v)>=1&&1>=X(y,g,a+v,o+v))}function q(t,e,n,r,i,a){return!(t>i||i>t+n||e>a||a>e+r)}function Q(t,e,n,r,i,a,o,s){var c=(Math.atan2(s-e,o-t)+2*Math.PI)%(2*Math.PI),l={x:t+n*Math.cos(c),y:e+n*Math.sin(c)};return B(l.x,l.y,o,s)<=a/2}function V(t,e,n,r,i,a,o){var s=i/2;return!(Math.min(t,n)-s>a||a>Math.max(t,n)+s||Math.min(e,r)-s>o||o>Math.max(e,r)+s)&&F(t,e,n,r,a,o)<=i/2}function Z(t,e,n,r,i){var a=t.length;if(2>a)return!1;for(var o=0;a-1>o;o++){if(V(t[o][0],t[o][1],t[o+1][0],t[o+1][1],e,n,r))return!0}if(i){var s=t[0],c=t[a-1];if(V(s[0],s[1],c[0],c[1],e,n,r))return!0}return!1}var J=1e-6;function K(t){return J>Math.abs(t)?0:0>t?-1:1}function tt(t,e,n){return!((n[0]-t[0])*(e[1]-t[1])!=(e[0]-t[0])*(n[1]-t[1])||Math.min(t[0],e[0])>n[0]||n[0]>Math.max(t[0],e[0])||Math.min(t[1],e[1])>n[1]||n[1]>Math.max(t[1],e[1]))}function et(t,e,n){var r=!1,i=t.length;if(2>=i)return!1;for(var a=0;i>a;a++){var o=t[a],s=t[(a+1)%i];if(tt(o,s,[e,n]))return!0;K(o[1]-n)>0!=K(s[1]-n)>0&&0>K(e-(n-o[1])*(o[0]-s[0])/(o[1]-s[1])-o[0])&&(r=!r)}return r}function nt(t,e,n){for(var r=!1,i=0;t.length>i;i++){if(r=et(t[i],e,n))break}return r}function rt(t,n,r){var i=t.parsedStyle,a=i.x1,o=i.y1,c=i.x2,l=i.y2,h=i.lineWidth,u=i.increasedLineWidthForHitTesting,d=i.defX,f=void 0===d?0:d,p=i.defY,v=void 0===p?0:p;return!(!s(e.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke),2)[1]&&!r||!h)&&V(a,o,c,l,(h||0)+(u||0),n.x+f,n.y+v)}function it(t,n,r,i,a,o){var c=t.parsedStyle,l=c.lineWidth,h=c.increasedLineWidthForHitTesting,u=c.defX,d=void 0===u?0:u,f=c.defY,p=void 0===f?0:f,v=c.path,y=v.segments,g=v.hasArc,m=v.polylines,E=v.polygons,M=s(e.isFillOrStrokeAffected(c.pointerEvents,(null==E?void 0:E.length)&&c.fill,c.stroke),2),x=M[0],b=M[1],S=e.getOrCalculatePathTotalLength(t),P=!1;return x||r?P=g?i(t,n):nt(E,n.x+d,n.y+p)||nt(m,n.x+d,n.y+p):((b||r)&&(P=function(t,e,n,r,i){for(var a=!1,o=e/2,s=0;t.length>s;s++){var c=t[s],l=c.currentPoint,h=c.params,u=c.prePoint,d=c.box;if(!d||q(d.x-o,d.y-o,d.width+e,d.height+e,n,r))switch(c.command){case"L":case"Z":if(a=V(u[0],u[1],l[0],l[1],e,n,r))return!0;break;case"Q":if(a=e/2>=j(u[0],u[1],h[1],h[2],h[3],h[4],n,r))return!0;break;case"C":if(a=e/2>=G(u[0],u[1],h[1],h[2],h[3],h[4],h[5],h[6],n,r,i))return!0;break;case"A":c.cubicParams||(c.cubicParams=O(u[0],u[1],h[1],h[2],h[3],h[4],h[5],h[6],h[7],void 0));for(var f=c.cubicParams,p=u,v=0;f.length>v;v+=6){var y=G(p[0],p[1],f[v],f[v+1],f[v+2],f[v+3],f[v+4],f[v+5],n,r,i);if(p=[f[v+4],f[v+5]],a=e/2>=y)return!0}}}return a}(y,(l||0)+(h||0),n.x+d,n.y+p,S)),P)}function at(t,n,r){var i=t.parsedStyle,a=i.lineWidth,o=i.increasedLineWidthForHitTesting,c=i.points,l=i.defX,h=void 0===l?0:l,u=i.defY,d=void 0===u?0:u,f=s(e.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke),2),p=f[0],v=!1;return(f[1]||r)&&(v=Z(c.points,(a||0)+(o||0),n.x+h,n.y+d,!0)),v||!p&&!r||(v=et(c.points,n.x+h,n.y+d)),v}function ot(t,n,r){var i=t.parsedStyle,a=i.lineWidth,o=i.increasedLineWidthForHitTesting,c=i.points,l=i.defX,h=void 0===l?0:l,u=i.defY,d=void 0===u?0:u;return!(!s(e.isFillOrStrokeAffected(i.pointerEvents,i.fill,i.stroke),2)[1]&&!r||!a)&&Z(c.points,(a||0)+(o||0),n.x+h,n.y+d,!1)}function st(t,n,r,i,a){var o=t.parsedStyle,c=o.radius,l=o.lineWidth,h=o.increasedLineWidthForHitTesting,u=o.width,d=o.height,f=s(e.isFillOrStrokeAffected(o.pointerEvents,o.fill,o.stroke),2),p=f[0],v=f[1],y=(l||0)+(h||0);if(c&&c.some((function(t){return 0!==t}))){var g=!1;return(v||r)&&(g=function(t,e,n,r,i,a,o,c){var l=s(i,4),h=l[0],u=l[1],d=l[2],f=l[3];return V(t+h,e,t+n-u,e,a,o,c)||V(t+n,e+u,t+n,e+r-d,a,o,c)||V(t+n-d,e+r,t+f,e+r,a,o,c)||V(t,e+r-f,t,e+h,a,o,c)||Q(t+n-u,e+u,u,0,0,a,o,c)||Q(t+n-d,e+r-d,d,0,0,a,o,c)||Q(t+f,e+r-f,f,0,0,a,o,c)||Q(t+h,e+h,h,0,0,a,o,c)}(0,0,u,d,c.map((function(t){return N(t,0,Math.min(Math.abs(u)/2,Math.abs(d)/2))})),y,n.x,n.y)),g||!p&&!r||(g=i(t,n)),g}var m=y/2;return p&&v||r?q(0-m,0-m,u+m,d+m,n.x,n.y):p?q(0,0,u,d,n.x,n.y):!!v&&function(t,e,n,r,i,a,o){var s=i/2;return q(t-s,e-s,n,i,a,o)||q(t+n-s,e-s,i,r,a,o)||q(t+s,e+r-s,n,i,a,o)||q(t-s,e+s,i,r,a,o)}(0,0,u,d,y,n.x,n.y)}function ct(t,n,r,i,a,o){var s=t.parsedStyle,c=s.width,l=s.height;if("non-transparent-pixel"===s.pointerEvents){var h=a.config.offscreenCanvas,u=o.offscreenCanvas.getOrCreateCanvas(h),d=o.offscreenCanvas.getOrCreateContext(h,{willReadFrequently:!0});return u.width=c,u.height=l,a.defaultStyleRendererFactory[e.Shape.IMAGE].render(d,t.parsedStyle,t,void 0,void 0,void 0),d.getImageData(n.x,n.y,1,1).data.every((function(t){return 0!==t}))}return!0}var lt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="canvas-picker",e}return r(n,t),n.prototype.init=function(){var t,n=((t={})[e.Shape.CIRCLE]=Y,t[e.Shape.ELLIPSE]=z,t[e.Shape.RECT]=st,t[e.Shape.LINE]=rt,t[e.Shape.POLYLINE]=ot,t[e.Shape.POLYGON]=at,t[e.Shape.PATH]=it,t[e.Shape.TEXT]=function(){return!0},t[e.Shape.GROUP]=null,t[e.Shape.IMAGE]=ct,t[e.Shape.HTML]=null,t[e.Shape.MESH]=null,t);this.context.pointInPathPickerFactory=n,this.addRenderingPlugin(new U)},n.prototype.destroy=function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()},n}(e.AbstractRendererPlugin),ht=Object.freeze({__proto__:null,Plugin:lt}),ut=function(){function t(t){this.canvasRendererPluginOptions=t,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=x(),this.dprMatrix=x(),this.tmpMat4=x(),this.vec3a=T(),this.vec3b=T(),this.vec3c=T(),this.vec3d=T()}return t.prototype.apply=function(n,r){var i=this;this.context=n;var a=n.config,o=n.camera,c=n.renderingService,l=n.renderingContext,h=n.pathGeneratorFactory;this.rBush=n.rBushRoot,this.pathGeneratorFactory=h;var u=n.contextService,d=l.root.ownerDocument.defaultView,f=function(t){var e=t.target.rBushNode;e.aabb&&i.removedRBushNodeAABBs.push(e.aabb)},p=function(t){var e=t.target.rBushNode;e.aabb&&i.removedRBushNodeAABBs.push(e.aabb)};c.hooks.init.tap(t.tag,(function(){d.addEventListener(e.ElementEvent.UNMOUNTED,f),d.addEventListener(e.ElementEvent.CULLED,p);var t=u.getDPR(),n=a.width,r=a.height,o=u.getContext();i.clearRect(o,0,0,n*t,r*t,a.background)})),c.hooks.destroy.tap(t.tag,(function(){d.removeEventListener(e.ElementEvent.UNMOUNTED,f),d.removeEventListener(e.ElementEvent.CULLED,p)})),c.hooks.beginFrame.tap(t.tag,(function(){var t,e,n=u.getContext(),r=u.getDPR(),o=a.width,s=a.height,l=(t=i.canvasRendererPluginOptions).dirtyObjectNumThreshold,h=t.dirtyObjectRatioThreshold,d=(e=c.getStats()).total,f=e.rendered,p=f/d;i.clearFullScreen=c.disableDirtyRectangleRendering()||f>l&&p>h,n&&(n.resetTransform?n.resetTransform():n.setTransform(1,0,0,1,0,0),i.clearFullScreen&&i.clearRect(n,0,0,o*r,s*r,a.background))}));var v=function(t,e){t.isVisible()&&!t.isCulled()&&(i.renderDisplayObject(t,e,i.context,i.restoreStack,r),i.saveDirtyAABB(t)),(t.sortable.sorted||t.childNodes).forEach((function(t){v(t,e)}))};c.hooks.endFrame.tap(t.tag,(function(){var t,n,c=u.getContext(),h=u.getDPR();if((t=i.dprMatrix)[0]=(n=[h,h,1])[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=n[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,S(i.vpMatrix,i.dprMatrix,o.getOrthoMatrix()),i.clearFullScreen)v(l.root,c);else{var f=i.safeMergeAABB.apply(i,function(t,e,n){if(n||2===arguments.length)for(var r,i=0,a=e.length;a>i;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}([i.mergeDirtyAABBs(i.renderQueue)],s(i.removedRBushNodeAABBs.map((function(t){var n=t.minX,r=t.minY,i=t.maxX,a=t.maxY,o=new e.AABB;return o.setMinMax([n,r,0],[i,a,0]),o}))),!1));if(i.removedRBushNodeAABBs=[],e.AABB.isEmpty(f))return void(i.renderQueue=[]);var p=i.convertAABB2Rect(f),y=p.x,g=p.y,m=p.width,E=p.height,M=A(i.vec3a,[y,g,0],i.vpMatrix),x=A(i.vec3b,[y+m,g,0],i.vpMatrix),b=A(i.vec3c,[y,g+E,0],i.vpMatrix),P=A(i.vec3d,[y+m,g+E,0],i.vpMatrix),T=Math.min(M[0],x[0],P[0],b[0]),C=Math.min(M[1],x[1],P[1],b[1]),w=Math.max(M[0],x[0],P[0],b[0]),O=Math.max(M[1],x[1],P[1],b[1]),k=Math.floor(T),L=Math.floor(C),R=Math.ceil(w-T),I=Math.ceil(O-C);c.save(),i.clearRect(c,k,L,R,I,a.background),c.beginPath(),c.rect(k,L,R,I),c.clip(),c.setTransform(i.vpMatrix[0],i.vpMatrix[1],i.vpMatrix[4],i.vpMatrix[5],i.vpMatrix[12],i.vpMatrix[13]),a.renderer.getConfig().enableDirtyRectangleRenderingDebug&&d.dispatchEvent(new e.CustomEvent(e.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:k,y:L,width:R,height:I}})),i.searchDirtyObjects(f).sort((function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&i.renderDisplayObject(t,c,i.context,i.restoreStack,r)})),c.restore(),i.renderQueue.forEach((function(t){i.saveDirtyAABB(t)})),i.renderQueue=[]}i.restoreStack.forEach((function(){c.restore()})),i.restoreStack=[]})),c.hooks.render.tap(t.tag,(function(t){i.clearFullScreen||i.renderQueue.push(t)}))},t.prototype.clearRect=function(t,e,n,r,i,a){t.clearRect(e,n,r,i),a&&(t.fillStyle=a,t.fillRect(e,n,r,i))},t.prototype.renderDisplayObject=function(t,n,r,i,a){var o=t.nodeName,s=i[i.length-1];!s||t.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_CONTAINS||(n.restore(),i.pop());var c=this.context.styleRendererFactory[o],l=this.pathGeneratorFactory[o],h=t.parsedStyle.clipPath;if(h){this.applyWorldTransform(n,h);var u=this.pathGeneratorFactory[h.nodeName];u&&(n.save(),i.push(t),n.beginPath(),u(n,h.parsedStyle),n.closePath(),n.clip())}c&&(this.applyWorldTransform(n,t),n.save(),this.applyAttributesToContext(n,t)),l&&(n.beginPath(),l(n,t.parsedStyle),t.nodeName!==e.Shape.LINE&&t.nodeName!==e.Shape.PATH&&t.nodeName!==e.Shape.POLYLINE&&n.closePath()),c&&(c.render(n,t.parsedStyle,t,r,this,a),n.restore()),t.renderable.dirty=!1},t.prototype.convertAABB2Rect=function(t){var e=t.getMin(),n=t.getMax(),r=Math.floor(e[0]),i=Math.floor(e[1]);return{x:r,y:i,width:Math.ceil(n[0])-r,height:Math.ceil(n[1])-i}},t.prototype.mergeDirtyAABBs=function(t){var n=new e.AABB;return t.forEach((function(t){var e=t.getRenderBounds();n.add(e);var r=t.renderable.dirtyRenderBounds;r&&n.add(r)})),n},t.prototype.searchDirtyObjects=function(t){var e,n,r=(e=s(t.getMin(),2))[0],i=e[1],a=(n=s(t.getMax(),2))[0];return this.rBush.search({minX:r,minY:i,maxX:a,maxY:n[1]}).map((function(t){return t.displayObject}))},t.prototype.saveDirtyAABB=function(t){var n=t.renderable;n.dirtyRenderBounds||(n.dirtyRenderBounds=new e.AABB);var r=t.getRenderBounds();r&&n.dirtyRenderBounds.update(r.center,r.halfExtents)},t.prototype.applyAttributesToContext=function(t,e){var n,r=(n=e.parsedStyle).stroke,i=n.fill,a=n.opacity,o=n.lineDash,s=n.lineDashOffset;o&&t.setLineDash(o),k(s)||(t.lineDashOffset=s),k(a)||(t.globalAlpha*=a),k(r)||Array.isArray(r)||r.isNone||(t.strokeStyle=e.attributes.stroke),k(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)},t.prototype.applyWorldTransform=function(t,e,n){var r=0,i=0,a=(e.parsedStyle||{}).anchor,o=a&&a[0]||0,s=a&&a[1]||0;if(0!==o||0!==s){var c=e.geometry.contentBounds;r=-o*(c&&2*c.halfExtents[0]||0),i=-s*(c&&2*c.halfExtents[1]||0)}n?(b(this.tmpMat4,e.getLocalTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,P(this.tmpMat4,this.tmpMat4,this.vec3a),S(this.tmpMat4,n,this.tmpMat4),S(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(b(this.tmpMat4,e.getWorldTransform()),this.vec3a[0]=r,this.vec3a[1]=i,this.vec3a[2]=0,P(this.tmpMat4,this.tmpMat4,this.vec3a),S(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},t.prototype.safeMergeAABB=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];var r=new e.AABB;return t.forEach((function(t){r.add(t)})),r},t.tag="CanvasRenderer",t}(),dt=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,n,r,i,a,o){var s=n.fill,c=n.fillRule,l=n.opacity,h=n.fillOpacity,u=n.stroke,d=n.strokeOpacity,f=n.lineWidth,p=n.lineCap,v=n.lineJoin,y=n.shadowType,g=n.shadowColor,m=n.shadowBlur,E=n.filter,M=n.miterLimit,x=!k(s)&&!s.isNone,b=!k(u)&&!u.isNone&&f>0,S=0===s.alpha,P=!(!E||!E.length),T=!k(g)&&m>0,C=r.nodeName,A="inner"===y,w=b&&T&&(C===e.Shape.PATH||C===e.Shape.LINE||C===e.Shape.POLYLINE||S||A);x&&(t.globalAlpha=l*h,w||ft(r,t,T),this.fill(t,r,s,c,i,a,o),w||this.clearShadowAndFilter(t,P,T)),b&&(t.globalAlpha=l*d,t.lineWidth=f,k(M)||(t.miterLimit=M),k(p)||(t.lineCap=p),k(v)||(t.lineJoin=v),w&&(A&&(t.globalCompositeOperation="source-atop"),ft(r,t,!0),A&&(this.stroke(t,r,u,i,a,o),t.globalCompositeOperation="source-over",this.clearShadowAndFilter(t,P,!0))),this.stroke(t,r,u,i,a,o))},t.prototype.clearShadowAndFilter=function(t,e,n){if(n&&(t.shadowColor="transparent",t.shadowBlur=0),e){var r=t.filter;!k(r)&&r.indexOf("drop-shadow")>-1&&(t.filter=r.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},t.prototype.fill=function(t,n,r,i,a,o,s){var c=this;Array.isArray(r)?r.forEach((function(e){t.fillStyle=c.getColor(e,n,t),i?t.fill(i):t.fill()})):(e.isPattern(r)&&(t.fillStyle=this.getPattern(r,n,t,a,o,s)),i?t.fill(i):t.fill())},t.prototype.stroke=function(t,n,r,i,a,o){var s=this;Array.isArray(r)?r.forEach((function(e){t.strokeStyle=s.getColor(e,n,t),t.stroke()})):(e.isPattern(r)&&(t.strokeStyle=this.getPattern(r,n,t,i,a,o)),t.stroke())},t.prototype.getPattern=function(t,e,n,r,i,a){var o,s;if("rect"===t.image.nodeName){var c=t.image.parsedStyle,l=c.width,h=c.height;s=r.contextService.getDPR();var u=r.config.offscreenCanvas;(o=a.offscreenCanvas.getOrCreateCanvas(u)).width=l*s,o.height=h*s;var d=a.offscreenCanvas.getOrCreateContext(u),f=[];t.image.forEach((function(t){i.renderDisplayObject(t,d,r,f,a)})),f.forEach((function(){d.restore()}))}return this.imagePool.getOrCreatePatternSync(t,n,o,s,(function(){e.renderable.dirty=!0,r.renderingService.dirtify()}))},t.prototype.getColor=function(t,n,r){var a;if(t.type===e.GradientType.LinearGradient||t.type===e.GradientType.RadialGradient){var o=n.getGeometryBounds(),s=o&&2*o.halfExtents[0]||1,c=o&&2*o.halfExtents[1]||1;a=this.imagePool.getOrCreateGradient(i(i({type:t.type},t.value),{width:s,height:c}),r)}return a},t}();function ft(t,e,n){var r=t.parsedStyle,i=r.filter,a=r.shadowColor,o=r.shadowBlur,s=r.shadowOffsetX,c=r.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),n&&(e.shadowColor=""+a,e.shadowBlur=o||0,e.shadowOffsetX=s||0,e.shadowOffsetY=c||0)}var pt=function(){function t(t){this.imagePool=t}return t.prototype.render=function(t,e,n){var r,i=e.img,a=e.shadowColor,o=e.shadowBlur,s=e.width,c=e.height;if(I(i)?r=this.imagePool.getImageSync(i):(s||(s=i.width),c||(c=i.height),r=i),r){ft(n,t,!k(a)&&o>0);try{t.drawImage(r,0,0,s,c)}catch(t){}}},t}(),vt=function(){function t(){}return t.prototype.render=function(t,n,r){var i=n.lineWidth,a=n.textAlign,o=n.textBaseline,s=n.lineJoin,c=n.miterLimit,l=n.letterSpacing,h=n.stroke,u=n.fill,d=n.fillOpacity,f=n.strokeOpacity,p=n.opacity,v=n.metrics,y=n.dx,g=n.dy,m=n.shadowColor,E=n.shadowBlur,M=v.lines,x=v.height,b=v.lineHeight,S=v.lineMetrics;t.font=v.font,t.lineWidth=i,t.textAlign="middle"===a?"center":a;var P=o;e.runtime.enableCSSParsing||"alphabetic"!==P||(P="bottom"),t.lineJoin=s,k(c)||(t.miterLimit=c);var T=0;"middle"===o?T=-x/2-b/2:"bottom"===o||"alphabetic"===o||"ideographic"===o?T=-x:"top"!==o&&"hanging"!==o||(T=-b);var C=y||0;T+=g||0,1===M.length&&("bottom"===P?(P="middle",T-=.5*x):"top"===P&&(P="middle",T+=.5*x)),t.textBaseline=P,ft(r,t,!k(m)&&E>0);for(var A=0;M.length>A;A++){var w=i/2+C;T+=b,k(h)||h.isNone||!i||this.drawLetterSpacing(t,M[A],S[A],a,w,T,l,d,f,p,!0),k(u)||this.drawLetterSpacing(t,M[A],S[A],a,w,T,l,d,f,p)}},t.prototype.drawLetterSpacing=function(t,e,n,r,i,a,o,s,c,l,h){if(void 0===h&&(h=!1),0!==o){var u=t.textAlign;t.textAlign="left";var d=i;"center"===r||"middle"===r?d=i-n.width/2:"right"!==r&&"end"!==r||(d=i-n.width);for(var f=Array.from(e),p=t.measureText(e).width,v=0,y=0;f.length>y;++y){var g=f[y];h?this.strokeText(t,g,d,a,c):this.fillText(t,g,d,a,s,l),d+=p-(v=t.measureText(e.substring(y+1)).width)+o,p=v}t.textAlign=u}else h?this.strokeText(t,e,i,a,c):this.fillText(t,e,i,a,s,l)},t.prototype.fillText=function(t,e,n,r,i,a){var o,s=!k(i)&&1!==i;s&&(o=t.globalAlpha,t.globalAlpha=i*a),t.fillText(e,n,r),s&&(t.globalAlpha=o)},t.prototype.strokeText=function(t,e,n,r,i){var a,o=!k(i)&&1!==i;o&&(a=t.globalAlpha,t.globalAlpha=i),t.strokeText(e,n,r),o&&(t.globalAlpha=a)},t}(),yt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),gt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),mt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),Et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),Mt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),xt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(dt),St=function(t){function n(e){void 0===e&&(e={});var n=t.call(this)||this;return n.options=e,n.name="canvas-renderer",n}return r(n,t),n.prototype.init=function(){var t,n=i({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),r=this.context.imagePool,a=new dt(r),o=((t={})[e.Shape.CIRCLE]=a,t[e.Shape.ELLIPSE]=a,t[e.Shape.RECT]=a,t[e.Shape.IMAGE]=new pt(r),t[e.Shape.TEXT]=new vt,t[e.Shape.LINE]=a,t[e.Shape.POLYLINE]=a,t[e.Shape.POLYGON]=a,t[e.Shape.PATH]=a,t[e.Shape.GROUP]=void 0,t[e.Shape.HTML]=void 0,t[e.Shape.MESH]=void 0,t);this.context.defaultStyleRendererFactory=o,this.context.styleRendererFactory=o,this.addRenderingPlugin(new ut(n))},n.prototype.destroy=function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory},n}(e.AbstractRendererPlugin),Pt=Object.freeze({__proto__:null,CircleRenderer:gt,EllipseRenderer:mt,ImageRenderer:pt,LineRenderer:Et,PathRenderer:bt,Plugin:St,PolygonRenderer:xt,PolylineRenderer:Mt,RectRenderer:yt,TextRenderer:vt}),Tt=function(){function t(){}return t.prototype.apply=function(e,n){var r=this,i=e.renderingService,a=e.renderingContext,o=e.config;this.context=e;var s=a.root.ownerDocument.defaultView,c=function(t){i.hooks.pointerMove.call(t)},l=function(t){i.hooks.pointerUp.call(t)},h=function(t){i.hooks.pointerDown.call(t)},u=function(t){i.hooks.pointerOver.call(t)},d=function(t){i.hooks.pointerOut.call(t)},f=function(t){i.hooks.pointerCancel.call(t)},p=function(t){i.hooks.pointerWheel.call(t)},v=function(t){i.hooks.click.call(t)};i.hooks.init.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="none",t.style.msTouchAction="none"):s.supportsPointerEvents&&(t.style.touchAction="none"),s.supportsPointerEvents?function(t){n.globalThis.document.addEventListener("pointermove",c,!0),t.addEventListener("pointerdown",h,!0),t.addEventListener("pointerleave",d,!0),t.addEventListener("pointerover",u,!0),n.globalThis.addEventListener("pointerup",l,!0),n.globalThis.addEventListener("pointercancel",f,!0)}(t):function(t){n.globalThis.document.addEventListener("mousemove",c,!0),t.addEventListener("mousedown",h,!0),t.addEventListener("mouseout",d,!0),t.addEventListener("mouseover",u,!0),n.globalThis.addEventListener("mouseup",l,!0)}(t),s.supportsTouchEvents&&function(t){t.addEventListener("touchstart",h,!0),t.addEventListener("touchend",l,!0),t.addEventListener("touchmove",c,!0),t.addEventListener("touchcancel",f,!0)}(t),o.useNativeClickEvent&&t.addEventListener("click",v,!0),t.addEventListener("wheel",p,{passive:!0,capture:!0})})),i.hooks.destroy.tap(t.tag,(function(){var t=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(t.style.msContentZooming="",t.style.msTouchAction=""):s.supportsPointerEvents&&(t.style.touchAction=""),s.supportsPointerEvents?function(t){n.globalThis.document.removeEventListener("pointermove",c,!0),t.removeEventListener("pointerdown",h,!0),t.removeEventListener("pointerleave",d,!0),t.removeEventListener("pointerover",u,!0),n.globalThis.removeEventListener("pointerup",l,!0)}(t):function(t){n.globalThis.document.removeEventListener("mousemove",c,!0),t.removeEventListener("mousedown",h,!0),t.removeEventListener("mouseout",d,!0),t.removeEventListener("mouseover",u,!0),n.globalThis.removeEventListener("mouseup",l,!0)}(t),s.supportsTouchEvents&&function(t){t.removeEventListener("touchstart",h,!0),t.removeEventListener("touchend",l,!0),t.removeEventListener("touchmove",c,!0),t.removeEventListener("touchcancel",f,!0)}(t),o.useNativeClickEvent&&t.removeEventListener("click",v,!0),t.removeEventListener("wheel",p,!0)}))},t.tag="DOMInteraction",t}(),Ct=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="dom-interaction",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new Tt)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(e.AbstractRendererPlugin),At=Object.freeze({__proto__:null,Plugin:Ct}),wt=function(){function t(){}return t.prototype.joinTransformMatrix=function(t){return"matrix(".concat([t[0],t[1],t[4],t[5],t[12],t[13]].join(","),")")},t.prototype.apply=function(n){var r=this,i=n.camera,a=n.renderingContext,o=n.renderingService;this.context=n;var s=a.root.ownerDocument.defaultView,c=function(t,e){e.style.transform=r.joinTransformMatrix(t.getWorldTransform())},l=function(t){var n=t.target;if(n.nodeName===e.Shape.HTML){r.$camera||(r.$camera=r.createCamera(i));var a=r.getOrCreateEl(n);r.$camera.appendChild(a);var o=n.ownerDocument.documentElement.attributes;Object.keys(o).forEach((function(t){a.style[t]=o[t]})),Object.keys(n.attributes).forEach((function(t){r.updateAttribute(t,n)})),c(n,a),e.runtime.nativeHTMLMap.set(a,n)}},h=function(t){var n=t.target;if(n.nodeName===e.Shape.HTML&&r.$camera){var i=r.getOrCreateEl(n);i&&(i.remove(),e.runtime.nativeHTMLMap.delete(i))}},u=function(t){var n=t.target;n.nodeName===e.Shape.HTML&&r.updateAttribute(t.attrName,n)},d=function(t){var n=t.target;if(n.nodeName===e.Shape.HTML){var i=r.getOrCreateEl(n);c(n,i)}},f=function(){if(r.$camera){var t=r.context.config,e=t.height;r.$camera.style.width="".concat(t.width||0,"px"),r.$camera.style.height="".concat(e||0,"px")}};o.hooks.init.tap(t.tag,(function(){s.addEventListener(e.CanvasEvent.RESIZE,f),s.addEventListener(e.ElementEvent.MOUNTED,l),s.addEventListener(e.ElementEvent.UNMOUNTED,h),s.addEventListener(e.ElementEvent.ATTR_MODIFIED,u),s.addEventListener(e.ElementEvent.BOUNDS_CHANGED,d)})),o.hooks.endFrame.tap(t.tag,(function(){r.$camera&&a.renderReasons.has(e.RenderReason.CAMERA_CHANGED)&&(r.$camera.style.transform=r.joinTransformMatrix(i.getOrthoMatrix()))})),o.hooks.destroy.tap(t.tag,(function(){r.$camera&&r.$camera.remove(),s.removeEventListener(e.CanvasEvent.RESIZE,f),s.removeEventListener(e.ElementEvent.MOUNTED,l),s.removeEventListener(e.ElementEvent.UNMOUNTED,h),s.removeEventListener(e.ElementEvent.ATTR_MODIFIED,u),s.removeEventListener(e.ElementEvent.BOUNDS_CHANGED,d)}))},t.prototype.getId=function(t){return t.id||"g-html-"+t.entity},t.prototype.createCamera=function(t){var e,n=(e=this.context.config).document,r=e.width,i=e.height,a=this.context.contextService.getDomElement(),o=a.parentNode;if(o){var s="g-canvas-camera",c=o.querySelector("#"+s);if(!c){var l=(n||document).createElement("div");c=l,l.id=s,l.style.position="absolute",l.style.left="".concat(a.offsetLeft||0,"px"),l.style.top="".concat(a.offsetTop||0,"px"),l.style.transformOrigin="left top",l.style.transform=this.joinTransformMatrix(t.getOrthoMatrix()),l.style.overflow="hidden",l.style.pointerEvents="none",l.style.width="".concat(r||0,"px"),l.style.height="".concat(i||0,"px"),o.appendChild(l)}return c}return null},t.prototype.getOrCreateEl=function(t){var e=this.context.config.document,n=this.getId(t),r=this.$camera.querySelector("#"+n);return r||(r=(e||document).createElement("div"),t.parsedStyle.$el=r,r.id=n,t.name&&r.setAttribute("name",t.name),t.className&&(r.className=t.className),r.style.position="absolute",r.style.left="0px",r.style.top="0px",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(t.getWorldTransform())),r},t.prototype.updateAttribute=function(t,n){var r=this.getOrCreateEl(n);switch(t){case"innerHTML":var i=n.parsedStyle.innerHTML;I(i)?r.innerHTML=i:(r.innerHTML="",r.appendChild(i));break;case"transformOrigin":var a=n.parsedStyle.transformOrigin;r.style["transform-origin"]="".concat(a[0].value," ").concat(a[1].value);break;case"width":if(e.runtime.enableCSSParsing){var o=n.computedStyleMap().get("width");r.style.width=""+o}else{r.style.width=D(o=n.parsedStyle.width)?"".concat(o,"px"):""+o}break;case"height":if(e.runtime.enableCSSParsing){var s=n.computedStyleMap().get("height");r.style.height=""+s}else{r.style.height=D(s=n.parsedStyle.height)?"".concat(s,"px"):""+s}break;case"zIndex":r.style["z-index"]="".concat(n.parsedStyle.zIndex);break;case"visibility":r.style.visibility=n.parsedStyle.visibility;break;case"pointerEvents":r.style.pointerEvents=n.parsedStyle.pointerEvents;break;case"opacity":r.style.opacity="".concat(n.parsedStyle.opacity);break;case"fill":var c=n.parsedStyle.fill,l="";e.isCSSRGB(c)?l=c.isNone?"transparent":n.getAttribute("fill"):Array.isArray(c)?l=n.getAttribute("fill"):e.isPattern(c),r.style.background=l;break;case"stroke":var h=n.parsedStyle.stroke,u="";e.isCSSRGB(h)?u=h.isNone?"transparent":n.getAttribute("stroke"):Array.isArray(h)?u=n.getAttribute("stroke"):e.isPattern(h),r.style["border-color"]=u,r.style["border-style"]="solid";break;case"lineWidth":r.style["border-width"]="".concat(n.parsedStyle.lineWidth||0,"px");break;case"lineDash":r.style["border-style"]="dashed";break;case"filter":r.style.filter=n.style.filter}},t.tag="HTMLRendering",t}(),Ot=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="html-renderer",e}return r(e,t),e.prototype.init=function(){this.addRenderingPlugin(new wt)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(e.AbstractRendererPlugin),kt=Object.freeze({__proto__:null,Plugin:Ot}),Lt=function(){function t(t){this.canvasConfig=t,this.imageCache={},this.gradientCache={},this.patternCache={}}return t.prototype.getImageSync=function(t,e){return this.imageCache[t]?e&&e():this.getOrCreateImage(t).then((function(){e&&e()})),this.imageCache[t]},t.prototype.getOrCreateImage=function(t){var n=this;if(this.imageCache[t])return Promise.resolve(this.imageCache[t]);var r=this.canvasConfig.createImage;return new Promise((function(i,a){var o;r?o=r(t):e.isBrowser&&(o=new window.Image),o&&(o.onload=function(){n.imageCache[t]=o,i(o)},o.onerror=function(t){a(t)},o.crossOrigin="Anonymous",o.src=t)}))},t.prototype.getOrCreatePatternSync=function(t,n,r,i,a){var o=this.generatePatternKey(t);if(o&&this.patternCache[o])return this.patternCache[o];var s,c=t.image,l=t.repetition,h=t.transform,u=!1;I(c)?s=this.getImageSync(c,a):r?(s=r,u=!0):s=c;var d,f=s&&n.createPattern(s,l);if(f){var p=void 0;h?p=e.parsedTransformToMat4(e.parseTransform(h),new e.DisplayObject({})):((d=x())[0]=1,d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[5]=1,d[6]=0,d[7]=0,d[8]=0,d[9]=0,d[10]=1,d[11]=0,d[12]=0,d[13]=0,d[14]=0,d[15]=1,p=d),u&&function(t,e,n){var r=n[0],i=n[1],a=n[2];t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]}(p,p,[1/i,1/i,1]),f.setTransform({a:p[0],b:p[1],c:p[4],d:p[5],e:p[12],f:p[13]})}return o&&f&&(this.patternCache[o]=f),f},t.prototype.getOrCreateGradient=function(t,n){var r=this.generateGradientKey(t),i=t.type,a=t.steps,o=t.width,s=t.height,c=t.cx,l=t.cy,h=t.size;if(this.gradientCache[r])return this.gradientCache[r];var u=null;if(i===e.GradientType.LinearGradient){var d=e.computeLinearGradient(o,s,t.angle);u=n.createLinearGradient(d.x1,d.y1,d.x2,d.y2)}else if(i===e.GradientType.RadialGradient){var f=e.computeRadialGradient(o,s,c,l,h),p=f.x,v=f.y;u=n.createRadialGradient(p,v,0,p,v,f.r)}return u&&(a.forEach((function(t){var n=t.offset;n.unit===e.UnitType.kPercentage&&(null==u||u.addColorStop(n.value/100,""+t.color))})),this.gradientCache[r]=u),this.gradientCache[r]},t.prototype.generateGradientKey=function(t){var e=t.width,n=t.height,r=t.steps,i=t.angle,a=t.cx,o=t.cy,s=t.size;return"gradient-".concat(t.type,"-").concat((null==i?void 0:""+i)||0,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat(e,"-").concat(n,"-").concat(r.map((function(t){var e=t.color;return"".concat(t.offset).concat(e)})).join("-"))},t.prototype.generatePatternKey=function(t){var e=t.image,n=t.repetition;return I(e)?"pattern-".concat(e,"-").concat(n):"rect"===e.nodeName?"pattern-".concat(e.entity,"-").concat(n):void 0},t}(),Rt=function(){function t(){}return t.prototype.apply=function(n){var r=n.renderingService,i=n.imagePool,a=n.renderingContext.root.ownerDocument.defaultView,o=function(t){var n=t.target;if(n.nodeName===e.Shape.IMAGE){var a=n.attributes.img;I(a)&&i.getImageSync(a,(function(){n.renderable.dirty=!0,r.dirtify()}))}},s=function(t){var n=t.target,a=t.newValue;n.nodeName===e.Shape.IMAGE&&"img"===t.attrName&&I(a)&&i.getOrCreateImage(a).then((function(){n.renderable.dirty=!0,r.dirtify()}))};r.hooks.init.tap(t.tag,(function(){a.addEventListener(e.ElementEvent.MOUNTED,o),a.addEventListener(e.ElementEvent.ATTR_MODIFIED,s)})),r.hooks.destroy.tap(t.tag,(function(){a.removeEventListener(e.ElementEvent.MOUNTED,o),a.removeEventListener(e.ElementEvent.ATTR_MODIFIED,s)}))},t.tag="LoadImage",t}(),It=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="image-loader",e}return r(e,t),e.prototype.init=function(){this.context.imagePool=new Lt(this.context.config),this.addRenderingPlugin(new Rt)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(e.AbstractRendererPlugin),Nt=Object.freeze({__proto__:null,ImagePool:Lt,Plugin:It}),Dt=function(){function t(t){this.renderingContext=t.renderingContext,this.canvasConfig=t.config}return t.prototype.init=function(){var t=this.canvasConfig,e=t.container,n=t.canvas;if(n)this.$canvas=n,e&&n.parentElement!==e&&e.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(e&&(this.$container=l(e,"String")?document.getElementById(e):e,this.$container)){var r=document.createElement("canvas");this.$container.appendChild(r),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=r}this.context=this.$canvas.getContext("2d"),this.resize(this.canvasConfig.width,this.canvasConfig.height)},t.prototype.getContext=function(){return this.context},t.prototype.getDomElement=function(){return this.$canvas},t.prototype.getDPR=function(){return this.dpr},t.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},t.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},t.prototype.resize=function(t,n){var r=this.canvasConfig.devicePixelRatio||e.isBrowser&&window.devicePixelRatio||1;this.dpr=r=1>r?1:Math.ceil(r),this.$canvas&&(this.$canvas.width=this.dpr*t,this.$canvas.height=this.dpr*n,e.setDOMSize(this.$canvas,t,n)),this.renderingContext.renderReasons.add(e.RenderReason.CAMERA_CHANGED)},t.prototype.applyCursorStyle=function(t){this.$container&&this.$container.style&&(this.$container.style.cursor=t)},t.prototype.toDataURL=function(t){return void 0===t&&(t={}),a(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.context.canvas.toDataURL(t.type,t.encoderOptions)]}))}))},t}(),Bt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="canvas-context-register",e}return r(e,t),e.prototype.init=function(){this.context.ContextService=Dt},e.prototype.destroy=function(){delete this.context.ContextService},e}(e.AbstractRendererPlugin),Ft=function(t){function e(e){var n=t.call(this,e)||this;return n.registerPlugin(new Bt),n.registerPlugin(new It),n.registerPlugin(new m),n.registerPlugin(new St),n.registerPlugin(new Ct),n.registerPlugin(new lt),n.registerPlugin(new Ot),n}return r(e,t),e}(e.AbstractRenderer);t.CanvasPathGenerator=E,t.CanvasPicker=ht,t.CanvasRenderer=Pt,t.DomInteraction=At,t.HTMLRenderer=kt,t.ImageLoader=Nt,t.Renderer=Ft}));
2
2
  //# sourceMappingURL=index.umd.min.js.map