@antv/g-canvas 2.0.50 → 2.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  * @antv/g-canvas
3
3
  * @description A renderer implemented by Canvas 2D API
4
- * @version 2.0.50
5
- * @date 10/13/2025, 12:20:42 PM
4
+ * @version 2.0.52
5
+ * @date 12/12/2025, 3:32:34 AM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  * @antv/g-canvas
3
3
  * @description A renderer implemented by Canvas 2D API
4
- * @version 2.0.50
5
- * @date 10/13/2025, 12:20:42 PM
4
+ * @version 2.0.52
5
+ * @date 12/12/2025, 3:32:34 AM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  * @antv/g-canvas
3
3
  * @description A renderer implemented by Canvas 2D API
4
- * @version 2.0.50
5
- * @date 10/13/2025, 12:20:42 PM
4
+ * @version 2.0.52
5
+ * @date 12/12/2025, 3:32:34 AM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
@@ -10,8 +10,8 @@
10
10
  /*!
11
11
  * @antv/g-plugin-canvas-path-generator
12
12
  * @description A G plugin of path generator with Canvas2D API
13
- * @version 2.1.24
14
- * @date 10/13/2025, 12:17:52 PM
13
+ * @version 2.1.26
14
+ * @date 12/12/2025, 3:29:45 AM
15
15
  * @author AntVis
16
16
  * @docs https://g.antv.antgroup.com/
17
17
  */function R(e,t){var n=t.cx,r=t.cy;e.arc(void 0===n?0:n,void 0===r?0:r,t.r,0,2*Math.PI,!1)}function L(e,t){var n=t.cx,r=void 0===n?0:n,a=t.cy,i=void 0===a?0:a,o=t.rx,l=t.ry;if(e.ellipse)e.ellipse(r,i,o,l,0,0,2*Math.PI,!1);else{var s=o>l?o:l,c=o>l?1:o/l,u=o>l?l/o:1;e.save(),e.scale(c,u),e.arc(r,i,s,0,2*Math.PI)}}function D(e,n){var r=n.x1,a=n.y1,i=n.x2,o=n.y2,l=n.markerStart,s=n.markerEnd,c=n.markerStartOffset,u=n.markerEndOffset,h=0,d=0,f=0,v=0,p=0;l&&t.isDisplayObject(l)&&c&&(h=Math.cos(p=Math.atan2(o-a,i-r))*(c||0),d=Math.sin(p)*(c||0)),s&&t.isDisplayObject(s)&&u&&(f=Math.cos(p=Math.atan2(a-o,r-i))*(u||0),v=Math.sin(p)*(u||0)),e.moveTo(r+h,a+d),e.lineTo(i+f,o+v)}function I(e,n){var r=n.markerStart,a=n.markerEnd,i=n.markerStartOffset,o=n.markerEndOffset,l=n.d,s=l.absolutePath,c=l.segments,u=0,h=0,d=0,f=0,v=0;if(r&&t.isDisplayObject(r)&&i){var p=y(r.parentNode.getStartTangent(),2),m=p[0],g=p[1];u=Math.cos(v=Math.atan2(m[1]-g[1],m[0]-g[0]))*(i||0),h=Math.sin(v)*(i||0)}if(a&&t.isDisplayObject(a)&&o){var b=y(a.parentNode.getEndTangent(),2),S=b[0],x=b[1];d=Math.cos(v=Math.atan2(S[1]-x[1],S[0]-x[0]))*(o||0),f=Math.sin(v)*(o||0)}for(var k=0;s.length>k;k++){var w=s[k],E=w[0],M=s[k+1],C=(k===s.length-1||M&&("M"===M[0]||"Z"===M[0]))&&0!==d&&0!==f,O=y(0===k&&(0!==u||0!==h)?[u,h]:[0,0],2),T=O[0],A=O[1],P=y(C?[d,f]:[0,0],2),R=P[0],L=P[1];switch(E){case"M":e.moveTo(w[1]+T,w[2]+A);break;case"L":e.lineTo(w[1]+R,w[2]+L);break;case"Q":e.quadraticCurveTo(w[1],w[2],w[3]+R,w[4]+L);break;case"C":e.bezierCurveTo(w[1],w[2],w[3],w[4],w[5]+R,w[6]+L);break;case"A":var D=c[k].arcParams,I=D.cx,N=D.cy,j=D.rx,F=D.ry,B=D.startAngle,G=D.endAngle,_=D.xRotation,W=D.sweepFlag;if(e.ellipse)e.ellipse(I,N,j,F,_,B,G,!!(1-W));else{var H=j>F?j:F,z=j>F?1:j/F,$=j>F?F/j:1;e.translate(I,N),e.rotate(_),e.scale(z,$),e.arc(0,0,H,B,G,!!(1-W)),e.scale(1/z,1/$),e.rotate(-_),e.translate(-I,-N)}C&&e.lineTo(w[6]+d,w[7]+f);break;case"Z":e.closePath()}}}function N(e,n){var r=n.markerStart,a=n.markerEnd,i=n.markerStartOffset,o=n.markerEndOffset,l=n.points.points,s=l.length,c=l[0][0],u=l[0][1],h=l[s-1][0],d=l[s-1][1],f=0,v=0,p=0,y=0,m=0;r&&t.isDisplayObject(r)&&i&&(f=Math.cos(m=Math.atan2(l[1][1]-l[0][1],l[1][0]-l[0][0]))*(i||0),v=Math.sin(m)*(i||0)),a&&t.isDisplayObject(a)&&o&&(p=Math.cos(m=Math.atan2(l[s-1][1]-l[0][1],l[s-1][0]-l[0][0]))*(o||0),y=Math.sin(m)*(o||0)),e.moveTo(c+(f||p),u+(v||y));for(var g=1;s-1>g;g++){var b=l[g];e.lineTo(b[0],b[1])}e.lineTo(h,d)}function j(e,n){var r=n.markerStart,a=n.markerEnd,i=n.markerStartOffset,o=n.markerEndOffset,l=n.points.points,s=l.length,c=l[0][0],u=l[0][1],h=l[s-1][0],d=l[s-1][1],f=0,v=0,p=0,y=0,m=0;r&&t.isDisplayObject(r)&&i&&(f=Math.cos(m=Math.atan2(l[1][1]-l[0][1],l[1][0]-l[0][0]))*(i||0),v=Math.sin(m)*(i||0)),a&&t.isDisplayObject(a)&&o&&(p=Math.cos(m=Math.atan2(l[s-2][1]-l[s-1][1],l[s-2][0]-l[s-1][0]))*(o||0),y=Math.sin(m)*(o||0)),e.moveTo(c+f,u+v);for(var g=1;s-1>g;g++){var b=l[g];e.lineTo(b[0],b[1])}e.lineTo(h+p,d+y)}function F(e,t){var n=t.x,r=void 0===n?0:n,a=t.y,i=void 0===a?0:a,o=t.radius,l=t.width,s=t.height,c=l,u=s;if(o&&o.some(function(e){return 0!==e})){var h=l>0?1:-1,d=s>0?1:-1,f=h+d===0,v=y(o.map(function(e){return b(e,0,Math.min(Math.abs(c)/2,Math.abs(u)/2))}),4),p=v[0],m=v[1],g=v[2],S=v[3];e.moveTo(h*p+r,i),e.lineTo(c-h*m+r,i),0!==m&&e.arc(c-h*m+r,d*m+i,m,-d*Math.PI/2,h>0?0:Math.PI,f),e.lineTo(c+r,u-d*g+i),0!==g&&e.arc(c-h*g+r,u-d*g+i,g,h>0?0:Math.PI,d>0?Math.PI/2:1.5*Math.PI,f),e.lineTo(h*S+r,u+i),0!==S&&e.arc(h*S+r,u-d*S+i,S,d>0?Math.PI/2:-Math.PI/2,h>0?Math.PI:0,f),e.lineTo(r,d*p+i),0!==p&&e.arc(h*p+r,d*p+i,p,h>0?Math.PI:0,d>0?1.5*Math.PI:Math.PI/2,f)}else e.rect(r,i,c,u)}C(),function(){var e,t=(e=new x(2),x!=Float32Array&&(e[0]=0,e[1]=0),e)}();var B=function(e){function n(){var e;o(this,n);for(var t=arguments.length,r=Array(t),a=0;t>a;a++)r[a]=arguments[a];return(e=u(this,n,[].concat(r))).name="canvas-path-generator",e}return d(n,e),i(n,[{key:"init",value:function(){var e,n=(f(f(f(f(f(f(f(f(f(f(e={},t.Shape.CIRCLE,R),t.Shape.ELLIPSE,L),t.Shape.RECT,F),t.Shape.LINE,D),t.Shape.POLYLINE,j),t.Shape.POLYGON,N),t.Shape.PATH,I),t.Shape.TEXT,void 0),t.Shape.GROUP,void 0),t.Shape.IMAGE,void 0),f(f(f(e,t.Shape.HTML,void 0),t.Shape.MESH,void 0),t.Shape.FRAGMENT,void 0));this.context.pathGeneratorFactory=n}},{key:"destroy",value:function(){delete this.context.pathGeneratorFactory}}])}(t.AbstractRendererPlugin),G=Object.freeze({__proto__:null,Plugin:B});function _(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=p(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return e.length>r?{done:!1,value:e[r++]}:{done:!0}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){l=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(l)throw i}}}}function W(e,t){this.v=e,this.k=t}function H(e,t,n,r){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}H=function(e,t,n,r){function i(t,n){H(e,t,function(e){return this._invoke(t,n,e)})}t?a?a(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},H(e,t,n,r)}function z(){
@@ -21,23 +21,23 @@ var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",a=n.toS
21
21
  * @antv/g-math
22
22
  * @description Geometry util
23
23
  * @version 3.0.1
24
- * @date 10/13/2025, 12:16:43 PM
24
+ * @date 12/12/2025, 3:28:35 AM
25
25
  * @author AntVis
26
26
  * @docs https://g.antv.antgroup.com/
27
27
  */function K(e,t,n,r){var a=e-n,i=t-r;return Math.sqrt(a*a+i*i)}function ee(e,t,n,r,a,i){var o=-1,l=1/0,s=[n,r],c=20;i&&i>200&&(c=i/10);for(var u=1/c,h=u/10,d=0;c>=d;d++){var f=d*u,v=[a.apply(void 0,J(e.concat([f]))),a.apply(void 0,J(t.concat([f])))],p=K(s[0],s[1],v[0],v[1]);l>p&&(o=f,l=p)}if(0===o)return{x:e[0],y:t[0]};if(1===o){var y=e.length;return{x:e[y-1],y:t[y-1]}}l=1/0;for(var m=0;32>m&&1e-4<=h;m++){var g=o-h,b=o+h,S=[a.apply(void 0,J(e.concat([g]))),a.apply(void 0,J(t.concat([g])))],x=K(s[0],s[1],S[0],S[1]);if(g>=0&&l>x)o=g,l=x;else{var k=[a.apply(void 0,J(e.concat([b]))),a.apply(void 0,J(t.concat([b])))],w=K(s[0],s[1],k[0],k[1]);1>=b&&l>w?(o=b,l=w):h*=.5}}return{x:a.apply(void 0,J(e.concat([o]))),y:a.apply(void 0,J(t.concat([o])))}}function te(e,t,n,r,a,i){var o=[n-e,r-t];if(function(e,t){return e[0]===t[0]&&e[1]===t[1]}(o,[0,0]))return Math.sqrt((a-e)*(a-e)+(i-t)*(i-t));var l=[-o[1],o[0]];return function(e,t){var n=t[0],r=t[1],a=n*n+r*r;a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a}(l,l),Math.abs(function(e,t){return e[0]*t[0]+e[1]*t[1]}([a-e,i-t],l))}function ne(e,t,n,r,a){var i=1-a;return i*i*i*e+3*t*a*i*i+3*n*a*a*i+r*a*a*a}function re(e,t,n,r,a,i,o,l,s,c,u){var h=function(e,t,n,r,a,i,o,l,s,c,u){return ee([e,n,a,o],[t,r,i,l],s,c,ne,u)}(e,t,n,r,a,i,o,l,s,c,u);return K(h.x,h.y,s,c)}function ae(e,t,n,r){var a=1-r;return a*a*e+2*r*a*t+r*r*n}function ie(e,t,n,r,a,i,o,l){var s=function(e,t,n,r,a,i,o,l){return ee([e,n,a],[t,r,i],o,l,ae)}(e,t,n,r,a,i,o,l);return K(s.x,s.y,o,l)}function oe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function le(e){for(var t=1;arguments.length>t;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?oe(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):oe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}
28
28
  /*!
29
29
  * @antv/g-plugin-canvas-picker
30
30
  * @description A G plugin for picking in canvas
31
- * @version 2.2.1
32
- * @date 10/13/2025, 12:19:56 PM
31
+ * @version 2.3.1
32
+ * @date 12/12/2025, 3:31:48 AM
33
33
  * @author AntVis
34
34
  * @docs https://g.antv.antgroup.com/
35
35
  */var se=C(),ce=C(),ue=C(),he=k(),de=function(){function e(){var n=this;o(this,e),this.isHit=function(e,r,a,i){var o,l,s,c,u,h,d,f,v,p,y,m,g,b,S,x,k,w,E,M,C,A,P,R,L,D,I,N,j,F,B,G=n.context.pointInPathPickerFactory[e.nodeName];if(G){var _=(o=he,(B=(E=(s=(l=a)[0])*(f=l[5])-(c=l[1])*(d=l[4]))*(F=(g=l[10])*(w=l[15])-(b=l[11])*(k=l[14]))-(M=s*(v=l[6])-(u=l[2])*d)*(j=(m=l[9])*w-b*(x=l[13]))+(C=s*(p=l[7])-(h=l[3])*d)*(N=m*k-g*x)+(A=c*v-u*f)*(I=(y=l[8])*w-b*(S=l[12]))-(P=c*p-h*f)*(D=y*k-g*S)+(R=u*p-h*v)*(L=y*x-m*S))?(o[0]=(f*F-v*j+p*N)*(B=1/B),o[1]=(u*j-c*F-h*N)*B,o[2]=(x*R-k*P+w*A)*B,o[3]=(g*P-m*R-b*A)*B,o[4]=(v*I-d*F-p*D)*B,o[5]=(s*F-u*I+h*D)*B,o[6]=(k*C-S*R-w*M)*B,o[7]=(y*R-g*C+b*M)*B,o[8]=(d*j-f*I+p*L)*B,o[9]=(c*I-s*j-h*L)*B,o[10]=(S*P-x*C+w*E)*B,o[11]=(m*C-y*P-b*E)*B,o[12]=(f*D-d*N-v*L)*B,o[13]=(s*N-c*D+u*L)*B,o[14]=(x*M-S*A-k*E)*B,o[15]=(y*A-m*M+g*E)*B,o):null),W=T(ce,O(ue,r[0],r[1],0),_);if(G(e,new t.Point(W[0],W[1]),i,n.isPointInPath,n.context,n.runtime))return!0}return!1},this.isPointInPath=function(e,t){var r=n.runtime.offscreenCanvasCreator.getOrCreateContext(n.context.config.offscreenCanvas),a=n.context.pathGeneratorFactory[e.nodeName];return a&&(r.beginPath(),a(r,e.parsedStyle),r.closePath()),r.isPointInPath(t.x,t.y)}}return i(e,[{key:"apply",value:function(t,n){var r,a=this,i=t.renderingService,o=t.renderingContext;this.context=t,this.runtime=n;var l=null===(r=o.root)||void 0===r?void 0:r.ownerDocument;i.hooks.pick.tapPromise(e.tag,function(){var e=Z(q().mark(function e(t){return q().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a.pick(l,t));case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()),i.hooks.pickSync.tap(e.tag,function(e){return a.pick(l,e)})}},{key:"pick",value:function(e,n){var r,a=n.topmost,i=n.position,o=O(se,i.x,i.y,0),l=[],s=_(e.elementsFromBBox(o[0],o[1],o[0],o[1]));try{for(s.s();!(r=s.n()).done;){var c=r.value,u=c.getWorldTransform();if(this.isHit(c,o,u,!1)){var h=t.findClosestClipPathTarget(c);if(h){var d=h.parsedStyle.clipPath;if(this.isHit(d,o,d.getWorldTransform(),!0)){if(a)return n.picked=[c],n;l.push(c)}}else{if(a)return n.picked=[c],n;l.push(c)}}}}catch(e){s.e(e)}finally{s.f()}return n.picked=l,n}}])}();function fe(e,n,r){var a=e.parsedStyle,i=a.cx,o=a.cy,l=a.r,s=a.fill,c=a.stroke,u=a.lineWidth,h=a.increasedLineWidthForHitTesting,d=a.pointerEvents,f=void 0===d?"auto":d,v=((void 0===u?1:u)+(void 0===h?0:h))/2,p=K(void 0===i?0:i,void 0===o?0:o,n.x,n.y),m=y(t.isFillOrStrokeAffected(f,s,c),2),g=m[0],b=m[1];return g&&b||r?l+v>=p:g?l>=p:!!b&&(p>=l-v&&l+v>=p)}function ve(e,t,n,r){return e/(n*n)+t/(r*r)}function pe(e,n,r){var a=e.parsedStyle,i=a.cx,o=void 0===i?0:i,l=a.cy,s=void 0===l?0:l,c=a.rx,u=a.ry,h=a.lineWidth,d=void 0===h?1:h,f=a.increasedLineWidthForHitTesting,v=void 0===f?0:f,p=a.pointerEvents,m=n.x,g=n.y,b=y(t.isFillOrStrokeAffected(void 0===p?"auto":p,a.fill,a.stroke),2),S=b[0],x=b[1],k=(d+v)/2,w=(m-o)*(m-o),E=(g-s)*(g-s);return S&&x||r?1>=ve(w,E,c+k,u+k):S?1>=ve(w,E,c,u):!!x&&(ve(w,E,c-k,u-k)>=1&&1>=ve(w,E,c+k,u+k))}function ye(e,t,n,r,a,i){return!(e>a||a>e+n||t>i||i>t+r)}function me(e,t,n,r,a,i,o,l){var s=(Math.atan2(l-t,o-e)+2*Math.PI)%(2*Math.PI),c={x:e+n*Math.cos(s),y:t+n*Math.sin(s)};return K(c.x,c.y,o,l)<=i/2}function ge(e,t,n,r,a,i,o){var l=a/2;return!(Math.min(e,n)-l>i||i>Math.max(e,n)+l||Math.min(t,r)-l>o||o>Math.max(t,r)+l)&&te(e,t,n,r,i,o)<=a/2}function be(e,t,n,r,a){var i=e.length;if(2>i)return!1;for(var o=0;i-1>o;o++){if(ge(e[o][0],e[o][1],e[o+1][0],e[o+1][1],t,n,r))return!0}if(a){var l=e[0],s=e[i-1];if(ge(l[0],l[1],s[0],s[1],t,n,r))return!0}return!1}de.tag="CanvasPicker";function Se(e){return 1e-6>Math.abs(e)?0:0>e?-1:1}function xe(e,t,n){return!((n[0]-e[0])*(t[1]-e[1])!==(t[0]-e[0])*(n[1]-e[1])||Math.min(e[0],t[0])>n[0]||n[0]>Math.max(e[0],t[0])||Math.min(e[1],t[1])>n[1]||n[1]>Math.max(e[1],t[1]))}function ke(e,t,n){var r=!1,a=e.length;if(2>=a)return!1;for(var i=0;a>i;i++){var o=e[i],l=e[(i+1)%a];if(xe(o,l,[t,n]))return!0;Se(o[1]-n)>0!=Se(l[1]-n)>0&&0>Se(t-(n-o[1])*(o[0]-l[0])/(o[1]-l[1])-o[0])&&(r=!r)}return r}function we(e,t,n){for(var r=!1,a=0;e.length>a;a++){if(r=ke(e[a],t,n))break}return r}function Ee(e,n,r){var a=e.parsedStyle,i=a.x1,o=a.y1,l=a.x2,s=a.y2,c=a.lineWidth,u=void 0===c?1:c,h=a.increasedLineWidthForHitTesting,d=void 0===h?0:h,f=a.pointerEvents;return!(!y(t.isFillOrStrokeAffected(void 0===f?"auto":f,a.fill,a.stroke),2)[1]&&!r||!u)&&ge(i,o,l,s,u+d,n.x,n.y)}function Me(e,n,r,a,i,o){var l=e.parsedStyle,s=l.lineWidth,c=void 0===s?1:s,u=l.increasedLineWidthForHitTesting,h=void 0===u?0:u,d=l.d,f=l.pointerEvents,v=d.segments,p=d.hasArc,m=d.polylines,g=d.polygons,b=y(t.isFillOrStrokeAffected(void 0===f?"auto":f,(null==g?void 0:g.length)&&l.fill,l.stroke),2),S=b[0],x=b[1],k=t.getOrCalculatePathTotalLength(e),w=!1;return S||r?w=p?a(e,n):we(g,n.x,n.y)||we(m,n.x,n.y):((x||r)&&(w=function(e,t,n,r,a){for(var i=!1,o=t/2,l=0;e.length>l;l++){var s=e[l],c=s.currentPoint,u=s.params,h=s.prePoint,d=s.box;if(!d||ye(d.x-o,d.y-o,d.width+t,d.height+t,n,r))switch(s.command){case"L":case"Z":if(i=ge(h[0],h[1],c[0],c[1],t,n,r))return!0;break;case"Q":if(i=t/2>=ie(h[0],h[1],u[1],u[2],u[3],u[4],n,r))return!0;break;case"C":if(i=t/2>=re(h[0],h[1],u[1],u[2],u[3],u[4],u[5],u[6],n,r,a))return!0;break;case"A":s.cubicParams||(s.cubicParams=P(h[0],h[1],u[1],u[2],u[3],u[4],u[5],u[6],u[7],void 0));for(var f=s.cubicParams,v=h,p=0;f.length>p;p+=6){var y=re(v[0],v[1],f[p],f[p+1],f[p+2],f[p+3],f[p+4],f[p+5],n,r,a);if(v=[f[p+4],f[p+5]],i=t/2>=y)return!0}}}return i}(v,c+h,n.x,n.y,k)),w)}function Ce(e,n,r){var a=e.parsedStyle,i=a.lineWidth,o=void 0===i?1:i,l=a.increasedLineWidthForHitTesting,s=void 0===l?0:l,c=a.points,u=a.pointerEvents,h=y(t.isFillOrStrokeAffected(void 0===u?"auto":u,a.fill,a.stroke),2),d=h[0],f=!1;return(h[1]||r)&&(f=be(c.points,o+s,n.x,n.y,!0)),f||!d&&!r||(f=ke(c.points,n.x,n.y)),f}function Oe(e,n,r){var a=e.parsedStyle,i=a.lineWidth,o=void 0===i?1:i,l=a.increasedLineWidthForHitTesting,s=void 0===l?0:l,c=a.points,u=a.pointerEvents;return!(!y(t.isFillOrStrokeAffected(void 0===u?"auto":u,a.fill,a.stroke),2)[1]&&!r||!o)&&be(c.points,o+s,n.x,n.y,!1)}function Te(e,n,r,a,i){var o=e.parsedStyle,l=o.radius,s=o.lineWidth,c=void 0===s?1:s,u=o.increasedLineWidthForHitTesting,h=void 0===u?0:u,d=o.x,f=void 0===d?0:d,v=o.y,p=void 0===v?0:v,m=o.width,g=o.height,S=o.pointerEvents,x=y(t.isFillOrStrokeAffected(void 0===S?"auto":S,o.fill,o.stroke),2),k=x[0],w=x[1],E=c+h;if(l&&l.some(function(e){return 0!==e})){var M=!1;return(w||r)&&(M=function(e,t,n,r,a,i,o,l){var s=y(a,4),c=s[0],u=s[1],h=s[2],d=s[3];return ge(e+c,t,e+n-u,t,i,o,l)||ge(e+n,t+u,e+n,t+r-h,i,o,l)||ge(e+n-h,t+r,e+d,t+r,i,o,l)||ge(e,t+r-d,e,t+c,i,o,l)||me(e+n-u,t+u,u,0,0,i,o,l)||me(e+n-h,t+r-h,h,0,0,i,o,l)||me(e+d,t+r-d,d,0,0,i,o,l)||me(e+c,t+c,c,0,0,i,o,l)}(f,p,m,g,l.map(function(e){return b(e,0,Math.min(Math.abs(m)/2,Math.abs(g)/2))}),E,n.x,n.y)),M||!k&&!r||(M=a(e,n)),M}var C=E/2;return k&&w||r?ye(f-C,p-C,m+C,g+C,n.x,n.y):k?ye(f,p,m,g,n.x,n.y):!!w&&function(e,t,n,r,a,i,o){var l=a/2;return ye(e-l,t-l,n,a,i,o)||ye(e+n-l,t-l,a,r,i,o)||ye(e+l,t+r-l,n,a,i,o)||ye(e-l,t+l,a,r,i,o)}(f,p,m,g,E,n.x,n.y)}function Ae(e,n,r,a,i,o){var l=e.parsedStyle,s=l.pointerEvents,c=l.x,u=void 0===c?0:c,h=l.y,d=void 0===h?0:h,f=l.width,v=l.height;if("non-transparent-pixel"===(void 0===s?"auto":s)){var p=i.config.offscreenCanvas,y=o.offscreenCanvasCreator.getOrCreateCanvas(p),m=o.offscreenCanvasCreator.getOrCreateContext(p,{willReadFrequently:!0});return y.width=f,y.height=v,i.defaultStyleRendererFactory[t.Shape.IMAGE].render(m,le(le({},e.parsedStyle),{},{x:0,y:0}),e,void 0,void 0,void 0),m.getImageData(n.x-u,n.y-d,1,1).data.every(function(e){return 0!==e})}return!0}function Pe(e,t,n,r){var a=e.getGeometryBounds();return!(a.min[0]>t.x||a.min[1]>t.y||t.x>a.max[0]||t.y>a.max[1])}var Re=function(e){function n(){var e;o(this,n);for(var t=arguments.length,r=Array(t),a=0;t>a;a++)r[a]=arguments[a];return(e=u(this,n,[].concat(r))).name="canvas-picker",e}return d(n,e),i(n,[{key:"init",value:function(){var e,n=(f(f(f(f(f(f(f(f(f(f(e={},t.Shape.CIRCLE,fe),t.Shape.ELLIPSE,pe),t.Shape.RECT,Te),t.Shape.LINE,Ee),t.Shape.POLYLINE,Oe),t.Shape.POLYGON,Ce),t.Shape.PATH,Me),t.Shape.TEXT,Pe),t.Shape.GROUP,null),t.Shape.IMAGE,Ae),f(f(e,t.Shape.HTML,null),t.Shape.MESH,null));this.context.pointInPathPickerFactory=n,this.addRenderingPlugin(new de)}},{key:"destroy",value:function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Le=Object.freeze({__proto__:null,Plugin:Re});function De(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var Ie=0;function Ne(e){return"__private_"+Ie+++"_"+e}
36
36
  /*!
37
37
  * @antv/g-plugin-image-loader
38
38
  * @description A G plugin for loading image
39
- * @version 2.2.1
40
- * @date 10/13/2025, 12:18:19 PM
39
+ * @version 2.3.1
40
+ * @date 12/12/2025, 3:30:11 AM
41
41
  * @author AntVis
42
42
  * @docs https://g.antv.antgroup.com/
43
43
  */var je=function(){return i(function e(){o(this,e),this.cacheStore=new Map},[{key:"onRefAdded",value:function(e){}},{key:"has",value:function(e){return this.cacheStore.has(e)}},{key:"put",value:function(e,t,n){return!this.cacheStore.has(e)&&(this.cacheStore.set(e,{value:t,counter:new Set([n.entity])}),this.onRefAdded(n),!0)}},{key:"get",value:function(e,t){var n=this.cacheStore.get(e);return n?(n.counter.has(t.entity)||(n.counter.add(t.entity),this.onRefAdded(t)),n.value):null}},{key:"update",value:function(e,t,n){var r=this.cacheStore.get(e);return!!r&&(r.value=le(le({},r.value),t),r.counter.has(n.entity)||(r.counter.add(n.entity),this.onRefAdded(n)),!0)}},{key:"release",value:function(e,t){var n=this.cacheStore.get(e);return!!n&&(n.counter.delete(t.entity),n.counter.size>0||this.cacheStore.delete(e),!0)}},{key:"releaseRef",value:function(e){var t=this;Array.from(this.cacheStore.keys()).forEach(function(n){t.release(n,e)})}},{key:"getSize",value:function(){return this.cacheStore.size}},{key:"clear",value:function(){this.cacheStore.clear()}}])}(),Fe=[],Be=[],Ge=function(){function e(){o(this,e)}return i(e,null,[{key:"stop",value:function(){e.rafId&&((arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api).cancelAnimationFrame(e.rafId),e.rafId=null)}},{key:"executeTask",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.api;(Fe.length>0||Be.length>0)&&(Be.forEach(function(e){return e()}),Be=Fe.splice(0,e.TASK_NUM_PER_FRAME),e.rafId=t.requestAnimationFrame(function(){e.executeTask(t)}))}},{key:"sliceImage",value:function(t,n,r,a){for(var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e.api,l=t.naturalWidth||t.width,s=t.naturalHeight||t.height,c=n-i,u=r-i,h=Math.ceil(l/c),d=Math.ceil(s/u),f={tileSize:[n,r],gridSize:[d,h],tiles:Array(d).fill(null).map(function(){return Array(h).fill(null)})},v=function(e){for(var i=function(i){Fe.push(function(){var h=i*c,d=e*u,v=[Math.min(n,l-h),Math.min(r,s-d)],p=v[0],y=v[1],m=o.createCanvas();m.width=n,m.height=r,m.getContext("2d").drawImage(t,h,d,p,y,0,0,p,y),f.tiles[e][i]={x:h,y:d,tileX:i,tileY:e,data:m},a()})},d=0;h>d;d++)i(d)},p=0;d>p;p++)v(p);return e.stop(),e.executeTask(),f}}])}();Ge.TASK_NUM_PER_FRAME=10;var _e=new je;_e.onRefAdded=function(e){var n=this;e.addEventListener(t.ElementEvent.DESTROY,function(){n.releaseRef(e)},{once:!0})};var We=function(){return i(function e(t,n){o(this,e),this.gradientCache={},this.patternCache={},this.context=t,this.runtime=n},[{key:"getImageSync",value:function(e,t,n){var r=g(e)?e:e.src;if(_e.has(r)){var a=_e.get(r,t);if(a.img.complete)return null==n||n(a),a}return this.getOrCreateImage(e,t).then(function(e){null==n||n(e)}).catch(function(e){console.error(e)}),null}},{key:"getOrCreateImage",value:function(e,t){var n=this,r=g(e)?e:e.src;if(!g(e)&&!_e.has(r)){var a={img:e,size:[e.naturalWidth||e.width,e.naturalHeight||e.height],tileSize:He(e)};_e.put(r,a,t)}if(_e.has(r)){var i=_e.get(r,t);return i.img.complete?Promise.resolve(i):new Promise(function(e,t){i.img.addEventListener("load",function(){i.size=[i.img.naturalWidth||i.img.width,i.img.naturalHeight||i.img.height],i.tileSize=He(i.img),e(i)}),i.img.addEventListener("error",function(e){t(e)})})}return new Promise(function(e,a){var i=n.context.config.createImage();if(i){var o={img:i,size:[0,0],tileSize:He(i)};_e.put(r,o,t),i.onload=function(){o.size=[i.naturalWidth||i.width,i.naturalHeight||i.height],o.tileSize=He(o.img),e(o)},i.onerror=function(e){a(e)},i.crossOrigin="Anonymous",i.src=r}})}},{key:"createDownSampledImage",value:(n=Z(q().mark(function e(t,n){var r,a,i,o,l,s,c,u,h,d,f,v,p,m;return q().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getOrCreateImage(t,n);case 1:if(void 0===(r=e.sent).downSamplingRate){e.next=2;break}return e.abrupt("return",r);case 2:if(l=void 0===(o=(i="boolean"==typeof(a=this.context.config.enableLargeImageOptimization)?{}:a).maxDownSampledImageSize)?2048:o,c=void 0===(s=i.downSamplingRateThreshold)?.5:s,u=this.runtime.globalThis.createImageBitmap,h=y(r.size,2),v=r.img,p=Math.min((l+l)/((d=h[0])+(f=h[1])),Math.max(.01,Math.min(c,.5))),m=le(le({},r),{},{downSamplingRate:p}),_e.update(r.img.src,m,n),!u){e.next=7;break}return e.prev=3,e.next=4,u(r.img,{resizeWidth:d*p,resizeHeight:f*p});case 4:v=e.sent,e.next=6;break;case 5:e.prev=5,e.catch(3),p=1;case 6:e.next=8;break;case 7:p=1;case 8:return m=le(le({},this.getImageSync(t,n)),{},{downSampled:v,downSamplingRate:p}),_e.update(r.img.src,m,n),e.abrupt("return",m);case 9:case"end":return e.stop()}},e,this,[[3,5]])})),function(e,t){return n.apply(this,arguments)})},{key:"createImageTiles",value:(e=Z(q().mark(function e(n,r,a,i){var o,l,s;return q().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,this.getOrCreateImage(n,i);case 1:return o=e.sent,Ge.api={requestAnimationFrame:(l=i.ownerDocument.defaultView).requestAnimationFrame,cancelAnimationFrame:l.cancelAnimationFrame,createCanvas:function(){return t.OffscreenCanvasCreator.createCanvas()}},s=le(le({},o),Ge.sliceImage(o.img,o.tileSize[0],o.tileSize[0],a)),_e.update(o.img.src,s,i),e.abrupt("return",s);case 2:case"end":return e.stop()}},e,this)})),function(t,n,r,a){return e.apply(this,arguments)})},{key:"releaseImage",value:function(e,t){_e.release(g(e)?e:e.src,t)}},{key:"releaseImageRef",value:function(e){_e.releaseRef(e)}},{key:"getOrCreatePatternSync",value:function(e,n,r,a,i,o,l){var s=this.generatePatternKey(n);if(s&&this.patternCache[s])return this.patternCache[s];var c,u=n.image,h=n.repetition,d=n.transform,f=!1;if(g(u)){var v=this.getImageSync(u,e,l);c=null==v?void 0:v.img}else a?(c=a,f=!0):c=u;var p,y,m=c&&r.createPattern(c,h);m&&(d?p=t.parsedTransformToMat4(t.parseTransform(d),new t.DisplayObject({})):((y=k())[0]=1,y[1]=0,y[2]=0,y[3]=0,y[4]=0,y[5]=1,y[6]=0,y[7]=0,y[8]=0,y[9]=0,y[10]=1,y[11]=0,y[12]=0,y[13]=0,y[14]=0,y[15]=1,p=y),f&&function(e,t,n){var r=n[0],a=n[1],i=n[2];e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*a,e[5]=t[5]*a,e[6]=t[6]*a,e[7]=t[7]*a,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]}(p,p,[1/i,1/i,1]),m.setTransform({a:p[0],b:p[1],c:p[4],d:p[5],e:p[12]+o[0],f:p[13]+o[1]}));return s&&m&&(this.patternCache[s]=m),m}},{key:"getOrCreateGradient",value:function(e,n){var r=this.generateGradientKey(e),a=e.type,i=e.steps,o=e.min,l=e.width,s=e.height,c=e.cx,u=e.cy,h=e.size;if(this.gradientCache[r])return this.gradientCache[r];var d=null;if(a===t.GradientType.LinearGradient){var f=t.computeLinearGradient(o,l,s,e.angle);d=n.createLinearGradient(f.x1,f.y1,f.x2,f.y2)}else if(a===t.GradientType.RadialGradient){var v=t.computeRadialGradient(o,l,s,c,u,h),p=v.x,y=v.y;d=n.createRadialGradient(p,y,0,p,y,v.r)}return d&&(i.forEach(function(e){var n,r=e.offset;r.unit===t.UnitType.kPercentage&&(null===(n=d)||void 0===n||n.addColorStop(r.value/100,""+e.color))}),this.gradientCache[r]=d),this.gradientCache[r]}},{key:"generateGradientKey",value:function(e){var t=e.min,n=e.width,r=e.height,a=e.steps,i=e.angle,o=e.cx,l=e.cy,s=e.size;return"gradient-".concat(e.type,"-").concat((null==i?void 0:""+i)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==l?void 0:""+l)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat(t[0],"-").concat(t[1],"-").concat(n,"-").concat(r,"-").concat(a.map(function(e){var t=e.color;return"".concat(e.offset).concat(t)}).join("-"))}},{key:"generatePatternKey",value:function(e){var t=e.image,n=e.repetition;return g(t)?"pattern-".concat(t,"-").concat(n):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(n):void 0}}]);var e,n}();function He(e){if(!e.complete)return[0,0];var t=e.naturalWidth||e.width,n=e.naturalHeight||e.height,r=256;return[256,512].forEach(function(e){1e3>Math.ceil(n/e)*Math.ceil(t/e)&&(r=e)}),[r,r]}We.isSupportTile=!!t.OffscreenCanvasCreator.createCanvas();var ze=function(){function e(){o(this,e)}return i(e,[{key:"apply",value:function(n){var r=n.renderingService,a=n.imagePool,i=n.renderingContext.root.ownerDocument.defaultView,o=function(e,t,n){var r=e.parsedStyle,a=r.width,i=r.height;a&&!i?e.setAttribute("height",n/t*a):!a&&i&&e.setAttribute("width",t/n*i)},l=function(e){var n=e.target,i=n.attributes;if(n.nodeName===t.Shape.IMAGE){var l=i.keepAspectRatio;a.getImageSync(i.src,n,function(e){var t=e.img;l&&o(n,t.width,t.height),n.dirty(),r.dirty()})}},s=function(e){var n=e.target,i=e.prevValue,l=e.newValue;n.nodeName===t.Shape.IMAGE&&"src"===e.attrName&&(i!==l&&a.releaseImage(i,n),g(l)&&a.getOrCreateImage(l,n).then(function(e){var t=e.img;n.attributes.keepAspectRatio&&o(n,t.width,t.height),n.dirty(),r.dirty()}).catch(function(){}))};r.hooks.init.tap(e.tag,function(){i.addEventListener(t.ElementEvent.MOUNTED,l),i.addEventListener(t.ElementEvent.ATTR_MODIFIED,s)}),r.hooks.destroy.tap(e.tag,function(){i.removeEventListener(t.ElementEvent.MOUNTED,l),i.removeEventListener(t.ElementEvent.ATTR_MODIFIED,s)})}}])}();ze.tag="LoadImage";var $e=function(e){function t(){var e;o(this,t);for(var n=arguments.length,r=Array(n),a=0;n>a;a++)r[a]=arguments[a];return(e=u(this,t,[].concat(r))).name="image-loader",e}return d(t,e),i(t,[{key:"init",value:function(e){this.context.imagePool=new We(this.context,e),this.addRenderingPlugin(new ze)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Ue=Object.freeze({__proto__:null,ImagePool:We,Plugin:$e}),Ye=Ne("renderState"),Ve=function(){function e(t){o(this,e),this.removedRBushNodeAABBs=[],this.renderQueue=[],Object.defineProperty(this,Ye,{writable:!0,value:{restoreStack:[],prevObject:null,currentContext:new Map}}),this.clearFullScreenLastFrame=!1,this.clearFullScreen=!1,this.vpMatrix=k(),this.dprMatrix=k(),this.tmpMat4=k(),this.vec3a=C(),this.vec3b=C(),this.vec3c=C(),this.vec3d=C(),this.canvasRendererPluginOptions=t}return i(e,[{key:"apply",value:function(n,r){var a=this;this.context=n;var i=this.context,o=i.config,l=i.camera,s=i.renderingService,c=i.renderingContext,u=i.rBushRoot,h=i.pathGeneratorFactory,d=o.renderer.getConfig().enableRenderingOptimization;o.renderer.getConfig().enableDirtyCheck=!1,o.renderer.getConfig().enableDirtyRectangleRendering=!1,this.rBush=u,this.pathGeneratorFactory=h;var f=n.contextService,v=c.root.ownerDocument.defaultView,p=function(e){var t=e.target.rBushNode;null!=t&&t.aabb&&a.removedRBushNodeAABBs.push(t.aabb)},y=function(e){var t=e.target.rBushNode;t.aabb&&a.removedRBushNodeAABBs.push(t.aabb)};s.hooks.init.tap(e.tag,function(){v.addEventListener(t.ElementEvent.UNMOUNTED,p),v.addEventListener(t.ElementEvent.CULLED,y);var e=f.getDPR(),n=o.width,r=o.height,i=f.getContext();a.clearRect(i,0,0,n*e,r*e,o.background)}),s.hooks.destroy.tap(e.tag,function(){v.removeEventListener(t.ElementEvent.UNMOUNTED,p),v.removeEventListener(t.ElementEvent.CULLED,y),a.renderQueue=[],a.removedRBushNodeAABBs=[],De(a,Ye)[Ye]={restoreStack:[],prevObject:null,currentContext:null}});var m=function(e,t){for(var n=[e];n.length>0;){var i,o=n.pop();o.isVisible()&&!o.isCulled()&&(d?a.renderDisplayObjectOptimized(o,t,a.context,De(a,Ye)[Ye],r):a.renderDisplayObject(o,t,a.context,De(a,Ye)[Ye],r));for(var l=(null===(i=o.sortable)||void 0===i||null===(i=i.sorted)||void 0===i?void 0:i.length)>0?o.sortable.sorted:o.childNodes,s=l.length-1;s>=0;s--)n.push(l[s])}};s.hooks.endFrame.tap(e.tag,function(){if(function(){var e,t=f.getContext(),n=f.getDPR(),r=o.width,i=o.height,l=a.canvasRendererPluginOptions,c=l.dirtyObjectNumThreshold,u=l.dirtyObjectRatioThreshold,h=s.getStats(),d=h.rendered,p=d/h.total;a.clearFullScreen=a.clearFullScreenLastFrame||!(null!==(e=v.context.renderingPlugins[1])&&void 0!==e&&e.isFirstTimeRenderingFinished)||s.disableDirtyRectangleRendering()||d>c&&p>u,t&&("function"==typeof t.resetTransform?t.resetTransform():t.setTransform(1,0,0,1,0,0),a.clearFullScreen&&a.clearRect(t,0,0,r*n,i*n,o.background))}(),0!==c.root.childNodes.length){d=o.renderer.getConfig().enableRenderingOptimization,De(a,Ye)[Ye]={restoreStack:[],prevObject:null,currentContext:De(a,Ye)[Ye].currentContext},De(a,Ye)[Ye].currentContext.clear(),a.clearFullScreenLastFrame=!1;var e,n,i=f.getContext(),u=f.getDPR();if((e=a.dprMatrix)[0]=(n=[u,u,1])[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=n[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,E(a.vpMatrix,a.dprMatrix,l.getOrthoMatrix()),a.clearFullScreen)d?(i.save(),m(c.root,i),i.restore()):m(c.root,i),a.removedRBushNodeAABBs=[];else{var h=a.safeMergeAABB.apply(a,[a.mergeDirtyAABBs(a.renderQueue)].concat(J(a.removedRBushNodeAABBs.map(function(e){var n=e.minX,r=e.minY,a=e.maxX,i=e.maxY,o=new t.AABB;return o.setMinMax([n,r,0],[a,i,0]),o}))));if(a.removedRBushNodeAABBs=[],t.AABB.isEmpty(h))return void(a.renderQueue=[]);var p=a.convertAABB2Rect(h),y=p.x,g=p.y,b=p.width,S=p.height,x=T(a.vec3a,[y,g,0],a.vpMatrix),k=T(a.vec3b,[y+b,g,0],a.vpMatrix),w=T(a.vec3c,[y,g+S,0],a.vpMatrix),M=T(a.vec3d,[y+b,g+S,0],a.vpMatrix),C=Math.min(x[0],k[0],M[0],w[0]),O=Math.min(x[1],k[1],M[1],w[1]),A=Math.max(x[0],k[0],M[0],w[0]),P=Math.max(x[1],k[1],M[1],w[1]),R=Math.floor(C),L=Math.floor(O),D=Math.ceil(A-C),I=Math.ceil(P-O);i.save(),a.clearRect(i,R,L,D,I,o.background),i.beginPath(),i.rect(R,L,D,I),i.clip(),i.setTransform(a.vpMatrix[0],a.vpMatrix[1],a.vpMatrix[4],a.vpMatrix[5],a.vpMatrix[12],a.vpMatrix[13]),o.renderer.getConfig().enableDirtyRectangleRenderingDebug&&v.dispatchEvent(new t.CustomEvent(t.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:R,y:L,width:D,height:I}})),a.searchDirtyObjects(h).sort(function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder}).forEach(function(e){e&&e.isVisible()&&!e.isCulled()&&a.renderDisplayObject(e,i,a.context,De(a,Ye)[Ye],r)}),i.restore(),a.renderQueue.forEach(function(e){a.saveDirtyAABB(e)}),a.renderQueue=[]}De(a,Ye)[Ye].restoreStack.forEach(function(){i.restore()}),De(a,Ye)[Ye].restoreStack=[]}else a.clearFullScreenLastFrame=!0}),s.hooks.render.tap(e.tag,function(e){a.clearFullScreen||a.renderQueue.push(e)})}},{key:"clearRect",value:function(e,t,n,r,a,i){e.clearRect(t,n,r,a),i&&(e.fillStyle=i,e.fillRect(t,n,r,a))}},{key:"renderDisplayObjectOptimized",value:function(e,n,r,a,i){var o=e.nodeName,l=!1,s=this.context.styleRendererFactory[o],c=this.pathGeneratorFactory[o],u=e.parsedStyle.clipPath;if(u){(!a.prevObject||!M(u.getWorldTransform(),a.prevObject.getWorldTransform()))&&(this.applyWorldTransform(n,u),a.prevObject=null);var h=this.pathGeneratorFactory[u.nodeName];h&&(n.save(),l=!0,n.beginPath(),h(n,u.parsedStyle),n.closePath(),n.clip())}if(s){(!a.prevObject||!M(e.getWorldTransform(),a.prevObject.getWorldTransform()))&&this.applyWorldTransform(n,e);var d=!a.prevObject;if(!d){var f=a.prevObject.nodeName;d=o===t.Shape.TEXT?f!==t.Shape.TEXT:o===t.Shape.IMAGE?f!==t.Shape.IMAGE:f===t.Shape.TEXT||f===t.Shape.IMAGE}s.applyStyleToContext(n,e,d,a),a.prevObject=e}c&&(n.beginPath(),c(n,e.parsedStyle),o!==t.Shape.LINE&&o!==t.Shape.PATH&&o!==t.Shape.POLYLINE&&n.closePath()),s&&s.drawToContext(n,e,De(this,Ye)[Ye],this,i),l&&n.restore(),e.dirty(!1)}},{key:"renderDisplayObject",value:function(e,n,r,a,i){var o=e.nodeName,l=a.restoreStack[a.restoreStack.length-1];!l||e.compareDocumentPosition(l)&t.Node.DOCUMENT_POSITION_CONTAINS||(n.restore(),a.restoreStack.pop());var s=this.context.styleRendererFactory[o],c=this.pathGeneratorFactory[o],u=e.parsedStyle.clipPath;if(u){this.applyWorldTransform(n,u);var h=this.pathGeneratorFactory[u.nodeName];h&&(n.save(),a.restoreStack.push(e),n.beginPath(),h(n,u.parsedStyle),n.closePath(),n.clip())}s&&(this.applyWorldTransform(n,e),n.save(),this.applyAttributesToContext(n,e)),c&&(n.beginPath(),c(n,e.parsedStyle),o!==t.Shape.LINE&&o!==t.Shape.PATH&&o!==t.Shape.POLYLINE&&n.closePath()),s&&(s.render(n,e.parsedStyle,e,r,this,i),n.restore()),e.dirty(!1)}},{key:"applyAttributesToContext",value:function(e,t){var n=t.parsedStyle,r=n.stroke,a=n.fill,i=n.opacity,o=n.lineDash,l=n.lineDashOffset;o&&e.setLineDash(o),m(l)||(e.lineDashOffset=l),m(i)||(e.globalAlpha*=i),m(r)||Array.isArray(r)||r.isNone||(e.strokeStyle=t.attributes.stroke),m(a)||Array.isArray(a)||a.isNone||(e.fillStyle=t.attributes.fill)}},{key:"convertAABB2Rect",value:function(e){var t=e.getMin(),n=e.getMax(),r=Math.floor(t[0]),a=Math.floor(t[1]);return{x:r,y:a,width:Math.ceil(n[0])-r,height:Math.ceil(n[1])-a}}},{key:"mergeDirtyAABBs",value:function(e){var n=new t.AABB;return e.forEach(function(e){var t=e.getRenderBounds();n.add(t);var r=e.renderable.dirtyRenderBounds;r&&n.add(r)}),n}},{key:"searchDirtyObjects",value:function(e){var t=y(e.getMin(),2),n=t[0],r=t[1],a=y(e.getMax(),2);return this.rBush.search({minX:n,minY:r,maxX:a[0],maxY:a[1]}).map(function(e){return e.displayObject})}},{key:"saveDirtyAABB",value:function(e){var n=e.renderable;n.dirtyRenderBounds||(n.dirtyRenderBounds=new t.AABB);var r=e.getRenderBounds();r&&n.dirtyRenderBounds.update(r.center,r.halfExtents)}},{key:"applyWorldTransform",value:function(e,t,n){n?(w(this.tmpMat4,t.getLocalTransform()),E(this.tmpMat4,n,this.tmpMat4),E(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(w(this.tmpMat4,t.getWorldTransform()),E(this.tmpMat4,this.vpMatrix,this.tmpMat4)),e.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])}},{key:"safeMergeAABB",value:function(){for(var e=new t.AABB,n=arguments.length,r=Array(n),a=0;n>a;a++)r[a]=arguments[a];return r.forEach(function(t){e.add(t)}),e}}])}();function Xe(e,t,n,r,a,i,o){var l,s;if("rect"===e.image.nodeName){var c=e.image.parsedStyle,u=c.width,h=c.height;s=r.contextService.getDPR();var d=r.config.offscreenCanvas;(l=i.offscreenCanvasCreator.getOrCreateCanvas(d)).width=u*s,l.height=h*s;var f=i.offscreenCanvasCreator.getOrCreateContext(d),v={restoreStack:[],prevObject:null,currentContext:new Map};e.image.forEach(function(e){a.renderDisplayObject(e,f,r,v,i)}),v.restoreStack.forEach(function(){f.restore()})}return o.getOrCreatePatternSync(t,e,n,l,s,t.getGeometryBounds().min,function(){t.dirty(),r.renderingService.dirty()})}function qe(e,n,r,a){var i;if(e.type===t.GradientType.LinearGradient||e.type===t.GradientType.RadialGradient){var o=n.getGeometryBounds(),l=o&&2*o.halfExtents[0]||1,s=o&&2*o.halfExtents[1]||1,c=o&&o.min||[0,0];i=a.getOrCreateGradient(le(le({type:e.type},e.value),{},{min:c,width:l,height:s}),r)}return i}Ve.tag="CanvasRenderer";var Qe=["shadowBlur","shadowOffsetX","shadowOffsetY"],Ze=["lineCap","lineJoin","miterLimit"],Je={globalAlpha:1,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"#000",filter:"none",globalCompositeOperation:"source-over",strokeStyle:"#000",strokeOpacity:1,lineWidth:1,lineDash:[],lineDashOffset:0,lineCap:"butt",lineJoin:"miter",miterLimit:10,fillStyle:"#000",fillOpacity:1},Ke={};function et(e,t,n,r){var a=r.has(t)?r.get(t):Je[t];return a!==n&&("lineDash"===t?e.setLineDash(n):e[t]=n,r.set(t,n)),a}var tt=function(){return i(function e(t){o(this,e),this.imagePool=t},[{key:"applyAttributesToContext",value:function(e,t){}},{key:"render",value:function(e,t,n,r,a,i){}},{key:"applyCommonStyleToContext",value:function(e,t,n,r){var a=n?Ke:r.prevObject.parsedStyle,i=t.parsedStyle;(n||i.opacity!==a.opacity)&&et(e,"globalAlpha",m(i.opacity)?Je.globalAlpha:i.opacity,r.currentContext),(n||i.blend!==a.blend)&&et(e,"globalCompositeOperation",m(i.blend)?Je.globalCompositeOperation:i.blend,r.currentContext)}},{key:"applyStrokeFillStyleToContext",value:function(e,t,n,r){var a=n?Ke:r.prevObject.parsedStyle,i=t.parsedStyle,o=i.lineWidth,l=i.fill&&!i.fill.isNone;if(i.stroke&&!i.stroke.isNone&&(void 0===o?Je.lineWidth:o)>0){if(n||t.attributes.stroke!==r.prevObject.attributes.stroke)et(e,"strokeStyle",m(i.stroke)||Array.isArray(i.stroke)||i.stroke.isNone?Je.strokeStyle:t.attributes.stroke,r.currentContext);(n||i.lineWidth!==a.lineWidth)&&et(e,"lineWidth",m(i.lineWidth)?Je.lineWidth:i.lineWidth,r.currentContext),(n||i.lineDash!==a.lineDash)&&et(e,"lineDash",i.lineDash||Je.lineDash,r.currentContext),(n||i.lineDashOffset!==a.lineDashOffset)&&et(e,"lineDashOffset",m(i.lineDashOffset)?Je.lineDashOffset:i.lineDashOffset,r.currentContext);for(var s=0;Ze.length>s;s++){var c=Ze[s];(n||i[c]!==a[c])&&et(e,c,m(i[c])?Je[c]:i[c],r.currentContext)}}l&&(n||t.attributes.fill!==r.prevObject.attributes.fill)&&et(e,"fillStyle",m(i.fill)||Array.isArray(i.fill)||i.fill.isNone?Je.fillStyle:t.attributes.fill,r.currentContext)}},{key:"applyStyleToContext",value:function(e,n,r,a){var i=n.nodeName;this.applyCommonStyleToContext(e,n,r,a),i===t.Shape.IMAGE||this.applyStrokeFillStyleToContext(e,n,r,a)}},{key:"applyShadowAndFilterStyleToContext",value:function(e,t,n,r){var a=t.parsedStyle;if(n){et(e,"shadowColor",""+a.shadowColor,r.currentContext);for(var i=0;Qe.length>i;i++){var o=Qe[i];et(e,o,a[o]||Je[o],r.currentContext)}}a.filter&&a.filter.length&&et(e,"filter",t.attributes.filter,r.currentContext)}},{key:"clearShadowAndFilterStyleForContext",value:function(e,t,n,r){var a=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(t){et(e,"shadowColor",Je.shadowColor,r.currentContext);for(var i=0;Qe.length>i;i++){var o=Qe[i];et(e,o,Je[o],r.currentContext)}}if(n)if(t&&a){var l=e.filter;!m(l)&&l.indexOf("drop-shadow")>-1&&et(e,"filter",l.replace(/drop-shadow\([^)]*\)/,"").trim()||Je.filter,r.currentContext)}else et(e,"filter",Je.filter,r.currentContext)}},{key:"fillToContext",value:function(e,n,r,a,i){var o=this,l=n.parsedStyle,s=l.fill,c=l.fillRule,u=null;if(Array.isArray(s)&&s.length>0)s.forEach(function(t){var a=et(e,"fillStyle",qe(t,n,e,o.imagePool),r.currentContext);u=null!=u?u:a,c?e.fill(c):e.fill()});else{if(t.isPattern(s)){var h=Xe(s,n,e,n.ownerDocument.defaultView.context,a,i,this.imagePool);h&&(e.fillStyle=h,u=!0)}c?e.fill(c):e.fill()}null!==u&&et(e,"fillStyle",u,r.currentContext)}},{key:"strokeToContext",value:function(e,n,r,a,i){var o=this,l=n.parsedStyle.stroke,s=null;if(Array.isArray(l)&&l.length>0)l.forEach(function(t){var a=et(e,"strokeStyle",qe(t,n,e,o.imagePool),r.currentContext);s=null!=s?s:a,e.stroke()});else{if(t.isPattern(l)){var c=Xe(l,n,e,n.ownerDocument.defaultView.context,a,i,this.imagePool);if(c){var u=et(e,"strokeStyle",c,r.currentContext);s=null!=s?s:u}}e.stroke()}null!==s&&et(e,"strokeStyle",s,r.currentContext)}},{key:"drawToContext",value:function(e,n,r,a,i){var o,l=n.nodeName,s=n.parsedStyle,c=s.opacity,u=void 0===c?Je.globalAlpha:c,h=s.fillOpacity,d=void 0===h?Je.fillOpacity:h,f=s.strokeOpacity,v=void 0===f?Je.strokeOpacity:f,p=s.lineWidth,y=s.fill&&!s.fill.isNone,g=s.stroke&&!s.stroke.isNone&&(void 0===p?Je.lineWidth:p)>0;if(y||g){var b=!m(s.shadowColor)&&s.shadowBlur>0,S="inner"===s.shadowType,x=0===(null===(o=s.fill)||void 0===o?void 0:o.alpha),k=!(!s.filter||!s.filter.length),w=b&&g&&(l===t.Shape.PATH||l===t.Shape.LINE||l===t.Shape.POLYLINE||x||S),E=null;if(y)w||this.applyShadowAndFilterStyleToContext(e,n,b,r),E=et(e,"globalAlpha",u*d,r.currentContext),this.fillToContext(e,n,r,a,i),w||this.clearShadowAndFilterStyleForContext(e,b,k,r);if(g){var M=!1,C=et(e,"globalAlpha",u*v,r.currentContext);if(E=y?E:C,w&&(this.applyShadowAndFilterStyleToContext(e,n,b,r),M=!0,S)){var O=e.globalCompositeOperation;e.globalCompositeOperation="source-atop",this.strokeToContext(e,n,r,a,i),e.globalCompositeOperation=O,this.clearShadowAndFilterStyleForContext(e,b,k,r,!0)}this.strokeToContext(e,n,r,a,i),M&&this.clearShadowAndFilterStyleForContext(e,b,k,r)}null!==E&&et(e,"globalAlpha",E,r.currentContext)}}}])}(),nt=function(e){function n(){return o(this,n),u(this,n,arguments)}return d(n,e),i(n,[{key:"render",value:function(e,n,r,a,i,o){var l=n.fill,s=n.fillRule,c=n.opacity,u=void 0===c?1:c,h=n.fillOpacity,d=void 0===h?1:h,f=n.stroke,v=n.strokeOpacity,p=void 0===v?1:v,y=n.lineWidth,g=void 0===y?1:y,b=n.lineCap,S=n.lineJoin,x=n.shadowType,k=n.shadowBlur,w=n.filter,E=n.miterLimit,M=l&&!l.isNone,C=f&&!f.isNone&&g>0,O=0===(null==l?void 0:l.alpha),T=!(!w||!w.length),A=!m(n.shadowColor)&&k>0,P=r.nodeName,R="inner"===x,L=C&&A&&(P===t.Shape.PATH||P===t.Shape.LINE||P===t.Shape.POLYLINE||O||R);M&&(e.globalAlpha=u*d,L||rt(r,e,A),at(e,r,l,s,a,i,o,this.imagePool),L||this.clearShadowAndFilter(e,T,A)),C&&(e.globalAlpha=u*p,e.lineWidth=g,m(E)||(e.miterLimit=E),m(b)||(e.lineCap=b),m(S)||(e.lineJoin=S),L&&(R&&(e.globalCompositeOperation="source-atop"),rt(r,e,!0),R&&(it(e,r,f,a,i,o,this.imagePool),e.globalCompositeOperation=Je.globalCompositeOperation,this.clearShadowAndFilter(e,T,!0))),it(e,r,f,a,i,o,this.imagePool))}},{key:"clearShadowAndFilter",value:function(e,t,n){if(n&&(e.shadowColor="transparent",e.shadowBlur=0),t){var r=e.filter;!m(r)&&r.indexOf("drop-shadow")>-1&&(e.filter=r.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}}}])}(tt);function rt(e,t,n){var r=e.parsedStyle,a=r.filter,i=r.shadowColor,o=r.shadowBlur,l=r.shadowOffsetX,s=r.shadowOffsetY;a&&a.length&&(t.filter=e.style.filter),n&&(t.shadowColor=""+i,t.shadowBlur=o||0,t.shadowOffsetX=l||0,t.shadowOffsetY=s||0)}function at(e,n,r,a,i,o,l,s){var c=arguments.length>8&&void 0!==arguments[8]&&arguments[8];Array.isArray(r)?r.forEach(function(t){e.fillStyle=qe(t,n,e,s),c||(a?e.fill(a):e.fill())}):(t.isPattern(r)&&(e.fillStyle=Xe(r,n,e,i,o,l,s)),c||(a?e.fill(a):e.fill()))}function it(e,n,r,a,i,o,l){var s=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Array.isArray(r)?r.forEach(function(t){e.strokeStyle=qe(t,n,e,l),s||e.stroke()}):(t.isPattern(r)&&(e.strokeStyle=Xe(r,n,e,a,i,o,l)),s||e.stroke())}var ot=function(e){function t(){return o(this,t),u(this,t,arguments)}return d(t,e),i(t,[{key:"renderDownSampled",value:function(e,t,n,r){var a=r.src,i=r.imageCache;i.downSampled?e.drawImage(i.downSampled,Math.floor(r.drawRect[0]),Math.floor(r.drawRect[1]),Math.ceil(r.drawRect[2]),Math.ceil(r.drawRect[3])):this.imagePool.createDownSampledImage(a,n).then(function(){n.ownerDocument&&(n.dirty(),n.ownerDocument.defaultView.context.renderingService.dirty())}).catch(function(e){console.error(e)})}},{key:"renderTile",value:function(e,t,n,r){var a=r.src,i=r.imageCache,o=r.imageRect,l=r.drawRect,s=i.size,c=e.getTransform(),u=c.a,h=c.b,d=c.c,f=c.d,v=c.e,p=c.f;if(e.resetTransform(),null!=i&&i.gridSize){for(var y=[s[0]/o[2],s[1]/o[3]],m=[i.tileSize[0]/y[0],i.tileSize[1]/y[1]],g=[Math.floor((l[0]-o[0])/m[0]),Math.ceil((l[0]+l[2]-o[0])/m[0])],b=g[0],S=g[1],x=[Math.floor((l[1]-o[1])/m[1]),Math.ceil((l[1]+l[3]-o[1])/m[1])],k=x[1],w=x[0];k>=w;w++)for(var E=b;S>=E;E++){var M=i.tiles[w][E];if(M){var C=[Math.floor(o[0]+M.tileX*m[0]),Math.floor(o[1]+M.tileY*m[1]),Math.ceil(m[0]),Math.ceil(m[1])];e.drawImage(M.data,C[0],C[1],C[2],C[3])}}e.setTransform(u,h,d,f,v,p)}else this.imagePool.createImageTiles(a,[],function(){n.ownerDocument&&(n.dirty(),n.ownerDocument.defaultView.context.renderingService.dirty())},n).catch(function(e){console.error(e)})}},{key:"render",value:function(e,n,r){var a=n.x,i=void 0===a?0:a,o=n.y,l=void 0===o?0:o,s=n.width,c=n.height,u=n.src,h=n.shadowColor,d=n.shadowBlur,f=this.imagePool.getImageSync(u,r),v=null==f?void 0:f.img,p=s,g=c;if(v){var b,S,k,w,E,M,O,A,P,R,L,D,I,N,j,F,B,G,_,W,H,z,$,U,Y,V,X,q,Q,Z,J,K,ee,te,ne,re,ae,ie;p||(p=v.width),g||(g=v.height),rt(r,e,!m(h)&&d>0);try{var oe=r.ownerDocument.defaultView.getContextService().getDomElement(),le=oe.width,se=oe.height,ce=e.getTransform(),ue=(z=ce.a,$=ce.c,U=0,Y=0,V=ce.b,X=ce.d,q=0,Q=0,Z=0,J=0,K=1,ee=0,te=ce.e,ne=ce.f,re=0,ae=1,(ie=new x(16))[0]=z,ie[1]=$,ie[2]=U,ie[3]=Y,ie[4]=V,ie[5]=X,ie[6]=q,ie[7]=Q,ie[8]=Z,ie[9]=J,ie[10]=K,ie[11]=ee,ie[12]=te,ie[13]=ne,ie[14]=re,ie[15]=ae,ie),he=(F=[i,l,p,g],B=ue,G=T(C(),[F[0],F[1],0],B),_=T(C(),[F[0]+F[2],F[1],0],B),W=T(C(),[F[0],F[1]+F[3],0],B),H=T(C(),[F[0]+F[2],F[1]+F[3],0],B),[Math.min(G[0],_[0],W[0],H[0]),Math.min(G[1],_[1],W[1],H[1]),Math.max(G[0],_[0],W[0],H[0])-Math.min(G[0],_[0],W[0],H[0]),Math.max(G[1],_[1],W[1],H[1])-Math.min(G[1],_[1],W[1],H[1])]),de=(b=he,S=y([0,0,le,se],4),k=S[0],w=S[1],E=S[2],M=S[3],O=y(b,4),P=O[1],R=O[2],L=O[3],D=Math.max(k,A=O[0]),I=Math.max(w,P),N=Math.min(k+E,A+R),j=Math.min(w+M,P+L),N>D&&j>I?[D,I,N-D,j-I]:null);if(!de)return;if(!r.ownerDocument.defaultView.getConfig().enableLargeImageOptimization)return void t.renderFull(e,n,r,{image:v,drawRect:[i,l,p,g]});if((f.downSamplingRate||.5)>he[2]/f.size[0])return void this.renderDownSampled(e,n,r,{src:u,imageCache:f,drawRect:[i,l,p,g]});if(!We.isSupportTile)return void t.renderFull(e,n,r,{image:v,drawRect:[i,l,p,g]});this.renderTile(e,n,r,{src:u,imageCache:f,imageRect:he,drawRect:de})}catch(e){}}}},{key:"drawToContext",value:function(e,t,n,r,a){this.render(e,t.parsedStyle,t)}}],[{key:"renderFull",value:function(e,t,n,r){e.drawImage(r.image,Math.floor(r.drawRect[0]),Math.floor(r.drawRect[1]),Math.ceil(r.drawRect[2]),Math.ceil(r.drawRect[3]))}}])}(nt),lt=function(e){function t(){return o(this,t),u(this,t,arguments)}return d(t,e),i(t,[{key:"render",value:function(e,t,n,r,a,i){n.getBounds();var o=t.lineWidth,l=void 0===o?1:o,s=t.textAlign,c=void 0===s?"start":s,u=t.textBaseline,h=void 0===u?"alphabetic":u,d=t.lineJoin,f=void 0===d?"miter":d,v=t.miterLimit,p=void 0===v?10:v,y=t.letterSpacing,g=void 0===y?0:y,b=t.stroke,S=t.fill,x=t.fillRule,k=t.fillOpacity,w=void 0===k?1:k,E=t.strokeOpacity,M=void 0===E?1:E,C=t.opacity,O=void 0===C?1:C,T=t.metrics,A=t.x,P=void 0===A?0:A,R=t.y,L=void 0===R?0:R,D=t.dx,I=t.dy,N=t.shadowColor,j=t.shadowBlur,F=t.textDecorationLine,B=T.lines,G=T.height,_=T.lineHeight,W=T.lineMetrics;e.font=T.font,e.lineWidth=l,e.textAlign="middle"===c?"center":c;var H=h;"alphabetic"===H&&(H="bottom"),e.lineJoin=f,m(p)||(e.miterLimit=p);var z=L;"middle"===h?z+=-G/2-_/2:"bottom"===h||"alphabetic"===h||"ideographic"===h?z+=-G:"top"!==h&&"hanging"!==h||(z+=-_);var $=P+(D||0);z+=I||0,1===B.length&&("bottom"===H?(H="middle",z-=.5*G):"top"===H&&(H="middle",z+=.5*G)),e.textBaseline=H,rt(n,e,!m(N)&&j>0);for(var U=0;B.length>U;U++){var Y=l/2+$;z+=_,m(b)||b.isNone||!l||this.drawLetterSpacing(e,n,B[U],W[U],c,Y,z,g,S,x,w,b,M,O,!0,r,a,i),m(S)||this.drawLetterSpacing(e,n,B[U],W[U],c,Y,z,g,S,x,w,b,M,O,!1,r,a,i)}F&&"none"!==F&&this.drawTextDecorations(e,t,n,B,_,$,L+(I||0),r,a,i)}},{key:"drawLetterSpacing",value:function(e,t,n,r,a,i,o,l,s,c,u,h,d,f,v,p,y,m){if(0!==l){var g=e.textAlign;e.textAlign="left";var b=i;"center"===a||"middle"===a?b=i-r.width/2:"right"!==a&&"end"!==a||(b=i-r.width);for(var S=Array.from(n),x=e.measureText(n).width,k=0,w=0;S.length>w;++w){var E=S[w];v?this.strokeText(e,t,E,b,o,h,d,p,y,m):this.fillText(e,t,E,b,o,s,c,u,f,p,y,m),b+=x-(k=e.measureText(n.substring(w+1)).width)+l,x=k}e.textAlign=g}else v?this.strokeText(e,t,n,i,o,h,d,p,y,m):this.fillText(e,t,n,i,o,s,c,u,f,p,y,m)}},{key:"fillText",value:function(e,t,n,r,a,i,o,l,s,c,u,h){var d;at(e,t,i,o,c,u,h,this.imagePool,!0);var f=!m(l)&&1!==l;f&&(d=e.globalAlpha,e.globalAlpha=l*s),e.fillText(n,r,a),f&&(e.globalAlpha=d)}},{key:"strokeText",value:function(e,t,n,r,a,i,o,l,s,c){var u;it(e,t,i,l,s,c,this.imagePool,!0);var h=!m(o)&&1!==o;h&&(u=e.globalAlpha,e.globalAlpha=o),e.strokeText(n,r,a),h&&(e.globalAlpha=u)}},{key:"drawTextDecorations",value:function(e,t,n,r,a,i,o,l,s,c){var u=t.textDecorationLine,h=t.textDecorationColor,d=t.textDecorationStyle,f=t.textDecorationThickness,v=void 0===f?1:f,p=t.textAlign,y=void 0===p?"start":p,m=t.lineWidth,g=void 0===m?1:m,b=t.metrics;if(u&&"none"!==u){var S=b.lineMetrics,x=u.split(" ");switch(e.lineWidth=v,h&&(e.strokeStyle="rgba(".concat(h.r,", ").concat(h.g,", ").concat(h.b,", ").concat(h.alpha,")")),d){case"dashed":e.setLineDash([5,5]);break;case"dotted":e.setLineDash([2,2]);break;default:e.setLineDash([])}var k=o,w=t.textBaseline,E=void 0===w?"alphabetic":w;"middle"===E?k+=-b.height/2-a/2:"bottom"===E||"alphabetic"===E||"ideographic"===E?k+=-b.height:"top"!==E&&"hanging"!==E||(k+=-a);for(var M=0;r.length>M;M++){k+=a;var C=S[M];if(C){var O=g/2,T=i,A=i+C.width;"center"===y||"middle"===y?(T=i-C.width/2,A=i+C.width/2):"right"!==y&&"end"!==y||(T=i-C.width,A=i),T+=O,A+=O;var P,R=_(x);try{for(R.s();!(P=R.n()).done;){var L=k;switch(P.value){case"underline":L+=2;break;case"overline":L-=a-2;break;case"line-through":L-=a/2;break;default:continue}"wavy"===d?this.drawWavyLine(e,T,A,L):(e.beginPath(),e.moveTo(T,L),e.lineTo(A,L),e.stroke())}}catch(e){R.e(e)}finally{R.f()}}}e.setLineDash([])}}},{key:"drawWavyLine",value:function(e,t,n,r){var a=10,i=Math.floor((n-t)/a);e.beginPath(),e.moveTo(t,r);for(var o=0;i>o;o++){e.quadraticCurveTo(t+o*a+2.5,r+2,t+o*a+5,r),e.quadraticCurveTo(t+o*a+7.5,r-2,t+(o+1)*a,r)}e.stroke()}},{key:"drawToContext",value:function(e,t,n,r,a){this.render(e,t.parsedStyle,t,t.ownerDocument.defaultView.context,r,a)}}])}(nt),st=function(e){function n(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return o(this,n),(e=u(this,n)).name="canvas-renderer",e.options=t,e}return d(n,e),i(n,[{key:"init",value:function(){var e,n=le({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),r=this.context.imagePool,a=new nt(r),i=(f(f(f(f(f(f(f(f(f(f(e={},t.Shape.CIRCLE,a),t.Shape.ELLIPSE,a),t.Shape.RECT,a),t.Shape.IMAGE,new ot(r)),t.Shape.TEXT,new lt(r)),t.Shape.LINE,a),t.Shape.POLYLINE,a),t.Shape.POLYGON,a),t.Shape.PATH,a),t.Shape.GROUP,void 0),f(f(f(e,t.Shape.HTML,void 0),t.Shape.MESH,void 0),t.Shape.FRAGMENT,void 0));this.context.defaultStyleRendererFactory=i,this.context.styleRendererFactory=i,this.addRenderingPlugin(new Ve(n))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory}}])}(t.AbstractRendererPlugin),ct=Object.freeze({__proto__:null,CircleRenderer:nt,DefaultRenderer:nt,EllipseRenderer:nt,ImageRenderer:ot,LineRenderer:nt,PathRenderer:nt,Plugin:st,PolygonRenderer:nt,PolylineRenderer:nt,RectRenderer:nt,TextRenderer:lt}),ut=function(){function e(){o(this,e)}return i(e,[{key:"apply",value:function(t,n){var r=this,a=t.renderingService,i=t.renderingContext,o=t.config;this.context=t;var l=i.root.ownerDocument.defaultView,s=function(e){a.hooks.pointerMove.call(e)},c=function(e){a.hooks.pointerUp.call(e)},u=function(e){a.hooks.pointerDown.call(e)},h=function(e){a.hooks.pointerOver.call(e)},d=function(e){a.hooks.pointerOut.call(e)},f=function(e){a.hooks.pointerCancel.call(e)},v=function(e){a.hooks.pointerWheel.call(e)},p=function(e){a.hooks.click.call(e)};a.hooks.init.tap(e.tag,function(){var e=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="none",e.style.msTouchAction="none"):l.supportsPointerEvents&&(e.style.touchAction="none"),l.supportsPointerEvents?function(e){n.globalThis.document.addEventListener("pointermove",s,!0),e.addEventListener("pointerdown",u,!0),e.addEventListener("pointerleave",d,!0),e.addEventListener("pointerover",h,!0),n.globalThis.addEventListener("pointerup",c,!0),n.globalThis.addEventListener("pointercancel",f,!0)}(e):function(e){n.globalThis.document.addEventListener("mousemove",s,!0),e.addEventListener("mousedown",u,!0),e.addEventListener("mouseout",d,!0),e.addEventListener("mouseover",h,!0),n.globalThis.addEventListener("mouseup",c,!0)}(e),l.supportsTouchEvents&&function(e){e.addEventListener("touchstart",u,!0),e.addEventListener("touchend",c,!0),e.addEventListener("touchmove",s,!0),e.addEventListener("touchcancel",f,!0)}(e),o.useNativeClickEvent&&e.addEventListener("click",p,!0),e.addEventListener("wheel",v,{passive:!0,capture:!0})}),a.hooks.destroy.tap(e.tag,function(){var e=r.context.contextService.getDomElement();n.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="",e.style.msTouchAction=""):l.supportsPointerEvents&&(e.style.touchAction=""),l.supportsPointerEvents?function(e){n.globalThis.document.removeEventListener("pointermove",s,!0),e.removeEventListener("pointerdown",u,!0),e.removeEventListener("pointerleave",d,!0),e.removeEventListener("pointerover",h,!0),n.globalThis.removeEventListener("pointerup",c,!0),n.globalThis.removeEventListener("pointercancel",f,!0)}(e):function(e){n.globalThis.document.removeEventListener("mousemove",s,!0),e.removeEventListener("mousedown",u,!0),e.removeEventListener("mouseout",d,!0),e.removeEventListener("mouseover",h,!0),n.globalThis.removeEventListener("mouseup",c,!0)}(e),l.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",u,!0),e.removeEventListener("touchend",c,!0),e.removeEventListener("touchmove",s,!0),e.removeEventListener("touchcancel",f,!0)}(e),o.useNativeClickEvent&&e.removeEventListener("click",p,!0),e.removeEventListener("wheel",v,!0)})}}])}();ut.tag="DOMInteraction";var ht=function(e){function t(){var e;o(this,t);for(var n=arguments.length,r=Array(n),a=0;n>a;a++)r[a]=arguments[a];return(e=u(this,t,[].concat(r))).name="dom-interaction",e}return d(t,e),i(t,[{key:"init",value:function(){this.addRenderingPlugin(new ut)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),dt=Object.freeze({__proto__:null,Plugin:ht}),ft=function(){function e(){o(this,e),this.displayObjectHTMLElementMap=new WeakMap}return i(e,[{key:"joinTransformMatrix",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0];return"matrix(".concat([e[0],e[1],e[4],e[5],e[12]+t[0],e[13]+t[1]].join(","),")")}},{key:"apply",value:function(n,r){var a=this,i=n.camera,o=n.renderingContext,l=n.renderingService;this.context=n;var s=o.root.ownerDocument.defaultView,c=s.context.eventService.nativeHTMLMap,u=function(e,t){t.style.transform=a.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())},h=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){a.$camera||(a.$camera=a.createCamera(i));var r=a.getOrCreateEl(n);a.$camera.appendChild(r),Object.keys(n.attributes).forEach(function(e){a.updateAttribute(e,n)}),u(n,r),c.set(r,n)}},d=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML&&a.$camera){var r=a.getOrCreateEl(n);r&&(r.remove(),c.delete(r))}},f=function(e){var n=e.target;n.nodeName===t.Shape.HTML&&a.updateAttribute(e.attrName,n)},v=function(e){for(var n=e.detail,r=0;n.length>r;r++){var i=n[r].target;(i.nodeName===t.Shape.FRAGMENT?i.childNodes:[i]).forEach(function(e){if(e.nodeName===t.Shape.HTML){var n=a.getOrCreateEl(e);u(e,n)}})}},p=function(){if(a.$camera){var e=a.context.config,t=e.height;a.$camera.parentElement.style.width="".concat(e.width||0,"px"),a.$camera.parentElement.style.height="".concat(t||0,"px")}};l.hooks.init.tap(e.tag,function(){s.addEventListener(t.CanvasEvent.RESIZE,p),s.addEventListener(t.ElementEvent.MOUNTED,h),s.addEventListener(t.ElementEvent.UNMOUNTED,d),s.addEventListener(t.ElementEvent.ATTR_MODIFIED,f),s.addEventListener(t.ElementEvent.BOUNDS_CHANGED,v)}),l.hooks.endFrame.tap(e.tag,function(){a.$camera&&o.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(a.$camera.style.transform=a.joinTransformMatrix(i.getOrthoMatrix()))}),l.hooks.destroy.tap(e.tag,function(){a.$camera&&a.$camera.remove(),s.removeEventListener(t.CanvasEvent.RESIZE,p),s.removeEventListener(t.ElementEvent.MOUNTED,h),s.removeEventListener(t.ElementEvent.UNMOUNTED,d),s.removeEventListener(t.ElementEvent.ATTR_MODIFIED,f),s.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,v)})}},{key:"createCamera",value:function(e){var t=this.context.config,n=t.document,r=t.width,a=t.height,i=this.context.contextService.getDomElement(),o=i.parentNode;if(o){var l="g-canvas-camera",s=o.querySelector("#".concat(l));if(!s){var c=(n||document).createElement("div");c.style.overflow="hidden",c.style.pointerEvents="none",c.style.position="absolute",c.style.left="0px",c.style.top="0px",c.style.width="".concat(r||0,"px"),c.style.height="".concat(a||0,"px");var u=(n||document).createElement("div");s=u,u.id=l,u.style.position="absolute",u.style.left="".concat(i.offsetLeft||0,"px"),u.style.top="".concat(i.offsetTop||0,"px"),u.style.transformOrigin="left top",u.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),u.style.pointerEvents="none",u.style.width="100%",u.style.height="100%",c.appendChild(u),o.appendChild(c)}return s}return null}},{key:"getOrCreateEl",value:function(e){var t=this.context.config.document,n=this.displayObjectHTMLElementMap.get(e);return n||(n=(t||document).createElement("div"),e.parsedStyle.$el=n,this.displayObjectHTMLElementMap.set(e,n),e.id&&(n.id=e.id),e.name&&n.setAttribute("name",e.name),e.className&&(n.className=e.className),n.style.position="absolute",n.style["will-change"]="transform",n.style.transform=this.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())),n}},{key:"updateAttribute",value:function(e,n){var r=this.getOrCreateEl(n);switch(e){case"innerHTML":var a=n.parsedStyle.innerHTML;g(a)?r.innerHTML=a:(r.innerHTML="",r.appendChild(a));break;case"x":r.style.left="".concat(n.parsedStyle.x,"px");break;case"y":r.style.top="".concat(n.parsedStyle.y,"px");break;case"transformOrigin":var i=n.parsedStyle.transformOrigin;r.style["transform-origin"]="".concat(i[0].buildCSSText(null,null,"")," ").concat(i[1].buildCSSText(null,null,""));break;case"width":var o=n.parsedStyle.width;r.style.width=S(o)?"".concat(o,"px"):""+o;break;case"height":var l=n.parsedStyle.height;r.style.height=S(l)?"".concat(l,"px"):""+l;break;case"zIndex":r.style["z-index"]="".concat(n.parsedStyle.zIndex);break;case"visibility":r.style.visibility=n.parsedStyle.visibility;break;case"pointerEvents":var s=n.parsedStyle.pointerEvents;r.style.pointerEvents=void 0===s?"auto":s;break;case"opacity":r.style.opacity="".concat(n.parsedStyle.opacity);break;case"fill":var c=n.parsedStyle.fill,u="";t.isCSSRGB(c)?u=c.isNone?"transparent":n.getAttribute("fill"):Array.isArray(c)?u=n.getAttribute("fill"):t.isPattern(c),r.style.background=u;break;case"stroke":var h=n.parsedStyle.stroke,d="";t.isCSSRGB(h)?d=h.isNone?"transparent":n.getAttribute("stroke"):Array.isArray(h)?d=n.getAttribute("stroke"):t.isPattern(h),r.style["border-color"]=d,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;break;default:m(n.style[e])||""===n.style[e]||(r.style[e]=n.style[e])}}}])}();ft.tag="HTMLRendering";var vt=function(e){function t(){var e;o(this,t);for(var n=arguments.length,r=Array(n),a=0;n>a;a++)r[a]=arguments[a];return(e=u(this,t,[].concat(r))).name="html-renderer",e}return d(t,e),i(t,[{key:"init",value:function(){this.addRenderingPlugin(new ft)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),pt=Object.freeze({__proto__:null,Plugin:vt}),yt=function(){return i(function e(t){o(this,e),this.renderingContext=t.renderingContext,this.canvasConfig=t.config},[{key:"init",value:function(){var e=this.canvasConfig,t=e.container,n=e.canvas;if(n)this.$canvas=n,t&&n.parentElement!==t&&t.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=g(t)?document.getElementById(t):t,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)}},{key:"getContext",value:function(){return this.context}},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getDPR",value:function(){return this.dpr}},{key:"getBoundingClientRect",value:function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)}},{key:"resize",value:function(e,n){this.dpr=this.canvasConfig.devicePixelRatio,this.$canvas&&(this.$canvas.width=this.dpr*e,this.$canvas.height=this.dpr*n,t.setDOMSize(this.$canvas,e,n)),this.renderingContext.renderReasons.add(t.RenderReason.CAMERA_CHANGED)}},{key:"applyCursorStyle",value:function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)}},{key:"toDataURL",value:(e=Z(q().mark(function e(){var t,n=arguments;return q().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.context.canvas.toDataURL((t=n.length>0&&void 0!==n[0]?n[0]:{}).type,t.encoderOptions));case 1:case"end":return e.stop()}},e,this)})),function(){return e.apply(this,arguments)})}]);var e}(),mt=function(e){function t(){var e;o(this,t);for(var n=arguments.length,r=Array(n),a=0;n>a;a++)r[a]=arguments[a];return(e=u(this,t,[].concat(r))).name="canvas-context-register",e}return d(t,e),i(t,[{key:"init",value:function(){this.context.ContextService=yt}},{key:"destroy",value:function(){delete this.context.ContextService}}])}(t.AbstractRendererPlugin),gt=function(e){function t(e){var n;return o(this,t),(n=u(this,t,[e])).registerPlugin(new mt),n.registerPlugin(new $e),n.registerPlugin(new B),n.registerPlugin(new st),n.registerPlugin(new ht),n.registerPlugin(new Re),n.registerPlugin(new vt),n}return d(t,e),i(t)}(t.AbstractRenderer);e.CanvasPathGenerator=G,e.CanvasPicker=Le,e.CanvasRenderer=ct,e.DomInteraction=dt,e.HTMLRenderer=pt,e.ImageLoader=Ue,e.Renderer=gt});