@antv/g-canvas
Version:
A renderer implemented by Canvas 2D API
41 lines • 73.5 kB
JavaScript
/*!
* @antv/g-canvas
* @description A renderer implemented by Canvas 2D API
* @version 2.0.44
* @date 5/30/2025, 2:57:07 AM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.Canvas2D={}),e.window.G)}(this,(function(e,t){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t||"default");if("object"!=r(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}function a(e,t){for(var r=0;t.length>r;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,n(a.key),a)}}function i(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(s=function(){return!!e})()}function c(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function u(e,t,r){return t=l(t),c(e,s()?Reflect.construct(t,r||[],l(e).constructor):t.apply(e,r))}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function d(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);t>r;r++)n[r]=e[r];return n}function p(e,t){if(e){if("string"==typeof e)return v(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(e,t):void 0}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,l=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(l.push(n.value),l.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(c)throw a}}return l}}(e,t)||p(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){return null==e}function m(e){return"string"==typeof e}var b=function(e,t,r){return t>e?t:e>r?r:e};function x(e){return"number"==typeof e}var S="undefined"!=typeof Float32Array?Float32Array:Array;function w(){var e=new S(16);return S!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function E(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function k(e,t,r){var n=t[0],a=t[1],i=t[2],o=t[3],l=t[4],s=t[5],c=t[6],u=t[7],h=t[8],f=t[9],d=t[10],v=t[11],p=t[12],y=t[13],g=t[14],m=t[15],b=r[0],x=r[1],S=r[2],w=r[3];return e[0]=b*n+x*l+S*h+w*p,e[1]=b*a+x*s+S*f+w*y,e[2]=b*i+x*c+S*d+w*g,e[3]=b*o+x*u+S*v+w*m,e[4]=(b=r[4])*n+(x=r[5])*l+(S=r[6])*h+(w=r[7])*p,e[5]=b*a+x*s+S*f+w*y,e[6]=b*i+x*c+S*d+w*g,e[7]=b*o+x*u+S*v+w*m,e[8]=(b=r[8])*n+(x=r[9])*l+(S=r[10])*h+(w=r[11])*p,e[9]=b*a+x*s+S*f+w*y,e[10]=b*i+x*c+S*d+w*g,e[11]=b*o+x*u+S*v+w*m,e[12]=(b=r[12])*n+(x=r[13])*l+(S=r[14])*h+(w=r[15])*p,e[13]=b*a+x*s+S*f+w*y,e[14]=b*i+x*c+S*d+w*g,e[15]=b*o+x*u+S*v+w*m,e}function M(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function C(){var e=new S(3);return S!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function O(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function T(e,t,r){var n=t[0],a=t[1],i=t[2],o=r[3]*n+r[7]*a+r[11]*i+r[15];return e[0]=(r[0]*n+r[4]*a+r[8]*i+r[12])/(o=o||1),e[1]=(r[1]*n+r[5]*a+r[9]*i+r[13])/o,e[2]=(r[2]*n+r[6]*a+r[10]*i+r[14])/o,e}function A(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function P(e,t,r,n,a,i,o,l,s,c){var u,h,f,d,v,p=e,y=t,g=r,m=n,b=l,x=s,S=120*Math.PI/180,w=Math.PI/180*(+a||0),E=[];if(c)h=c[0],f=c[1],d=c[2],v=c[3];else{y=(u=A(p,y,-w)).y;var k=((p=u.x)-(b=(u=A(b,x,-w)).x))/2,M=(y-(x=u.y))/2,C=k*k/(g*g)+M*M/(m*m);C>1&&(g*=C=Math.sqrt(C),m*=C);var O=g*g,T=m*m,R=(i===o?-1:1)*Math.sqrt(Math.abs((O*T-O*M*M-T*k*k)/(O*M*M+T*k*k)));d=R*g*M/m+(p+b)/2,h=Math.asin(((y-(v=R*-m*k/g+(y+x)/2))/m*1e9|0)/1e9),f=Math.asin(((x-v)/m*1e9|0)/1e9),0>(h=d>p?Math.PI-h:h)&&(h=2*Math.PI+h),0>(f=d>b?Math.PI-f:f)&&(f=2*Math.PI+f),o&&h>f&&(h-=2*Math.PI),!o&&f>h&&(f-=2*Math.PI)}var L=f-h;if(Math.abs(L)>S){var I=f,D=b,N=x;E=P(b=d+g*Math.cos(f=h+S*(o&&f>h?1:-1)),x=v+m*Math.sin(f),g,m,a,0,o,D,N,[f,I,d,v])}L=f-h;var j=Math.cos(h),F=Math.sin(h),B=Math.cos(f),_=Math.sin(f),G=Math.tan(L/4),W=4/3*g*G,H=4/3*m*G,z=[p,y],$=[p+W*F,y-H*j],U=[b+W*_,x-H*B],Y=[b,x];if($[0]=2*z[0]-$[0],$[1]=2*z[1]-$[1],c)return $.concat(U,Y,E);for(var V=[],X=0,q=(E=$.concat(U,Y,E)).length;q>X;X+=1)V[X]=X%2?A(E[X-1],E[X],w).y:A(E[X],E[X+1],w).x;return V}
/*!
* @antv/g-plugin-canvas-path-generator
* @description A G plugin of path generator with Canvas2D API
* @version 2.1.19
* @date 5/30/2025, 2:54:19 AM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/function R(e,t){var r=t.cx,n=t.cy;e.arc(void 0===r?0:r,void 0===n?0:n,t.r,0,2*Math.PI,!1)}function L(e,t){var r=t.cx,n=void 0===r?0:r,a=t.cy,i=void 0===a?0:a,o=t.rx,l=t.ry;if(e.ellipse)e.ellipse(n,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(n,i,s,0,2*Math.PI)}}function I(e,r){var n=r.x1,a=r.y1,i=r.x2,o=r.y2,l=r.markerStart,s=r.markerEnd,c=r.markerStartOffset,u=r.markerEndOffset,h=0,f=0,d=0,v=0,p=0;l&&t.isDisplayObject(l)&&c&&(h=Math.cos(p=Math.atan2(o-a,i-n))*(c||0),f=Math.sin(p)*(c||0)),s&&t.isDisplayObject(s)&&u&&(d=Math.cos(p=Math.atan2(a-o,n-i))*(u||0),v=Math.sin(p)*(u||0)),e.moveTo(n+h,a+f),e.lineTo(i+d,o+v)}function D(e,r){var n=r.markerStart,a=r.markerEnd,i=r.markerStartOffset,o=r.markerEndOffset,l=r.d,s=l.absolutePath,c=l.segments,u=0,h=0,f=0,d=0,v=0;if(n&&t.isDisplayObject(n)&&i){var p=y(n.parentNode.getStartTangent(),2),g=p[0],m=p[1];u=Math.cos(v=Math.atan2(g[1]-m[1],g[0]-m[0]))*(i||0),h=Math.sin(v)*(i||0)}if(a&&t.isDisplayObject(a)&&o){var b=y(a.parentNode.getEndTangent(),2),x=b[0],S=b[1];f=Math.cos(v=Math.atan2(x[1]-S[1],x[0]-S[0]))*(o||0),d=Math.sin(v)*(o||0)}for(var w=0;s.length>w;w++){var E=s[w],k=E[0],M=s[w+1],C=(w===s.length-1||M&&("M"===M[0]||"Z"===M[0]))&&0!==f&&0!==d,O=y(0===w&&(0!==u||0!==h)?[u,h]:[0,0],2),T=O[0],A=O[1],P=y(C?[f,d]:[0,0],2),R=P[0],L=P[1];switch(k){case"M":e.moveTo(E[1]+T,E[2]+A);break;case"L":e.lineTo(E[1]+R,E[2]+L);break;case"Q":e.quadraticCurveTo(E[1],E[2],E[3]+R,E[4]+L);break;case"C":e.bezierCurveTo(E[1],E[2],E[3],E[4],E[5]+R,E[6]+L);break;case"A":var I=c[w].arcParams,D=I.cx,N=I.cy,j=I.rx,F=I.ry,B=I.startAngle,_=I.endAngle,G=I.xRotation,W=I.sweepFlag;if(e.ellipse)e.ellipse(D,N,j,F,G,B,_,!!(1-W));else{var H=j>F?j:F,z=j>F?1:j/F,$=j>F?F/j:1;e.translate(D,N),e.rotate(G),e.scale(z,$),e.arc(0,0,H,B,_,!!(1-W)),e.scale(1/z,1/$),e.rotate(-G),e.translate(-D,-N)}C&&e.lineTo(E[6]+f,E[7]+d);break;case"Z":e.closePath()}}}function N(e,r){var n=r.markerStart,a=r.markerEnd,i=r.markerStartOffset,o=r.markerEndOffset,l=r.points.points,s=l.length,c=l[0][0],u=l[0][1],h=l[s-1][0],f=l[s-1][1],d=0,v=0,p=0,y=0,g=0;n&&t.isDisplayObject(n)&&i&&(d=Math.cos(g=Math.atan2(l[1][1]-l[0][1],l[1][0]-l[0][0]))*(i||0),v=Math.sin(g)*(i||0)),a&&t.isDisplayObject(a)&&o&&(p=Math.cos(g=Math.atan2(l[s-1][1]-l[0][1],l[s-1][0]-l[0][0]))*(o||0),y=Math.sin(g)*(o||0)),e.moveTo(c+(d||p),u+(v||y));for(var m=1;s-1>m;m++){var b=l[m];e.lineTo(b[0],b[1])}e.lineTo(h,f)}function j(e,r){var n=r.markerStart,a=r.markerEnd,i=r.markerStartOffset,o=r.markerEndOffset,l=r.points.points,s=l.length,c=l[0][0],u=l[0][1],h=l[s-1][0],f=l[s-1][1],d=0,v=0,p=0,y=0,g=0;n&&t.isDisplayObject(n)&&i&&(d=Math.cos(g=Math.atan2(l[1][1]-l[0][1],l[1][0]-l[0][0]))*(i||0),v=Math.sin(g)*(i||0)),a&&t.isDisplayObject(a)&&o&&(p=Math.cos(g=Math.atan2(l[s-2][1]-l[s-1][1],l[s-2][0]-l[s-1][0]))*(o||0),y=Math.sin(g)*(o||0)),e.moveTo(c+d,u+v);for(var m=1;s-1>m;m++){var b=l[m];e.lineTo(b[0],b[1])}e.lineTo(h+p,f+y)}function F(e,t){var r=t.x,n=void 0===r?0:r,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,f=s>0?1:-1,d=h+f===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],g=v[1],m=v[2],x=v[3];e.moveTo(h*p+n,i),e.lineTo(c-h*g+n,i),0!==g&&e.arc(c-h*g+n,f*g+i,g,-f*Math.PI/2,h>0?0:Math.PI,d),e.lineTo(c+n,u-f*m+i),0!==m&&e.arc(c-h*m+n,u-f*m+i,m,h>0?0:Math.PI,f>0?Math.PI/2:1.5*Math.PI,d),e.lineTo(h*x+n,u+i),0!==x&&e.arc(h*x+n,u-f*x+i,x,f>0?Math.PI/2:-Math.PI/2,h>0?Math.PI:0,d),e.lineTo(n,f*p+i),0!==p&&e.arc(h*p+n,f*p+i,p,h>0?Math.PI:0,f>0?1.5*Math.PI:Math.PI/2,d)}else e.rect(n,i,c,u)}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),C(),function(){var e,t=(e=new S(2),S!=Float32Array&&(e[0]=0,e[1]=0),e)}();var B=function(e){function r(){var e;o(this,r);for(var t=arguments.length,n=Array(t),a=0;t>a;a++)n[a]=arguments[a];return(e=u(this,r,[].concat(n))).name="canvas-path-generator",e}return f(r,e),i(r,[{key:"init",value:function(){var e,r=(d(d(d(d(d(d(d(d(d(d(e={},t.Shape.CIRCLE,R),t.Shape.ELLIPSE,L),t.Shape.RECT,F),t.Shape.LINE,I),t.Shape.POLYLINE,j),t.Shape.POLYGON,N),t.Shape.PATH,D),t.Shape.TEXT,void 0),t.Shape.GROUP,void 0),t.Shape.IMAGE,void 0),d(d(d(e,t.Shape.HTML,void 0),t.Shape.MESH,void 0),t.Shape.FRAGMENT,void 0));this.context.pathGeneratorFactory=r}},{key:"destroy",value:function(){delete this.context.pathGeneratorFactory}}])}(t.AbstractRendererPlugin),_=Object.freeze({__proto__:null,Plugin:B});function G(){G=function(){return t};var e,t={},n=Object.prototype,a=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",l=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r,n){Object.defineProperty(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n})}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(t,r,n,a){var i=Object.create((r&&r.prototype instanceof d?r:d).prototype);return c(i,"_invoke",function(t,r,n){var a=1;return function(i,o){if(3===a)throw Error("Generator is already running");if(4===a){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var l=n.delegate;if(l){var s=w(l,n);if(s){if(s===f)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===a)throw a=4,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=3;var c=h(t,r,n);if("normal"===c.type){if(a=n.done?4:2,c.arg===f)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(a=4,n.method="throw",n.arg=c.arg)}}}(t,n,new M(a||[])),!0),i}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f={};function d(){}function v(){}function p(){}var y={};c(y,o,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(C([])));m&&m!==n&&a.call(m,o)&&(y=m);var b=p.prototype=d.prototype=Object.create(y);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(i,o,l,s){var c=h(e[i],e,o);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==r(f)&&a.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,l,s)}),(function(e){n("throw",e,l,s)})):t.resolve(f).then((function(e){u.value=e,l(u)}),(function(e){return n("throw",e,l,s)}))}s(c.arg)}var i;c(this,"_invoke",(function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return i=i?i.then(a,a):a()}),!0)}function w(t,r){var n=r.method,a=t.i[n];if(a===e)return r.delegate=null,"throw"===n&&t.i.return&&(r.method="return",r.arg=e,w(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var i=h(a,t.i,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,f;var o=i.arg;return o?o.done?(r[t.r]=o.value,r.next=t.n,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,f):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function E(e){this.tryEntries.push(e)}function k(t){var r=t[4]||{};r.type="normal",r.arg=e,t[4]=r}function M(e){this.tryEntries=[[-1]],e.forEach(E,this),this.reset(!0)}function C(t){if(null!=t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,l=function r(){for(;++i<t.length;)if(a.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return l.next=l}}throw new TypeError(r(t)+" is not iterable")}return v.prototype=p,c(b,"constructor",p),c(p,"constructor",v),c(p,s,v.displayName="GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,c(e,s,"GeneratorFunction")),e.prototype=Object.create(b),e},t.awrap=function(e){return{__await:e}},x(S.prototype),c(S.prototype,l,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new S(u(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},x(b),c(b,s,"Generator"),c(b,o,(function(){return this})),c(b,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},t.values=C,M.prototype={constructor:M,reset:function(t){if(this.prev=this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(k),!t)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0][4];if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e){o.type="throw",o.arg=t,r.next=e}for(var a=r.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],o=i[4],l=this.prev,s=i[1],c=i[2];if(-1===i[0])return n("end"),!1;if(!s&&!c)throw Error("try statement without catch or finally");if(null!=i[0]&&l>=i[0]){if(s>l)return this.method="next",this.arg=e,n(s),!0;if(c>l)return n(c),!1}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n[0]>-1&&this.prev>=n[0]&&n[2]>this.prev){var a=n;break}}a&&("break"===e||"continue"===e)&&t>=a[0]&&a[2]>=t&&(a=null);var i=a?a[4]:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a[2],f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r[2]===e)return this.complete(r[4],r[3]),k(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r[0]===e){var n=r[4];if("throw"===n.type){var a=n.arg;k(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={i:C(t),r:r,n:n},"next"===this.method&&(this.arg=e),f}},t}function W(e,t,r,n,a,i,o){try{var l=e[i](o),s=l.value}catch(e){return void r(e)}l.done?t(s):Promise.resolve(s).then(n,a)}function H(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){W(i,n,a,o,l,"next",e)}function l(e){W(i,n,a,o,l,"throw",e)}o(void 0)}))}}function z(e){return function(e){if(Array.isArray(e))return v(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}
/*!
* @antv/g-math
* @description Geometry util
* @version 3.0.1
* @date 5/30/2025, 2:53:11 AM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/function $(e,t,r,n){var a=e-r,i=t-n;return Math.sqrt(a*a+i*i)}function U(e,t,r,n,a,i){var o=-1,l=1/0,s=[r,n],c=20;i&&i>200&&(c=i/10);for(var u=1/c,h=u/10,f=0;c>=f;f++){var d=f*u,v=[a.apply(void 0,z(e.concat([d]))),a.apply(void 0,z(t.concat([d])))],p=$(s[0],s[1],v[0],v[1]);l>p&&(o=d,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 g=0;32>g&&1e-4<=h;g++){var m=o-h,b=o+h,x=[a.apply(void 0,z(e.concat([m]))),a.apply(void 0,z(t.concat([m])))],S=$(s[0],s[1],x[0],x[1]);if(m>=0&&l>S)o=m,l=S;else{var w=[a.apply(void 0,z(e.concat([b]))),a.apply(void 0,z(t.concat([b])))],E=$(s[0],s[1],w[0],w[1]);1>=b&&l>E?(o=b,l=E):h*=.5}}return{x:a.apply(void 0,z(e.concat([o]))),y:a.apply(void 0,z(t.concat([o])))}}function Y(e,t,r,n,a,i){var o=[r-e,n-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 r=t[0],n=t[1],a=r*r+n*n;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 V(e,t,r,n,a){var i=1-a;return i*i*i*e+3*t*a*i*i+3*r*a*a*i+n*a*a*a}function X(e,t,r,n,a,i,o,l,s,c,u){var h=function(e,t,r,n,a,i,o,l,s,c,u){return U([e,r,a,o],[t,n,i,l],s,c,V,u)}(e,t,r,n,a,i,o,l,s,c,u);return $(h.x,h.y,s,c)}function q(e,t,r,n){var a=1-n;return a*a*e+2*n*a*t+n*n*r}function Q(e,t,r,n,a,i,o,l){var s=function(e,t,r,n,a,i,o,l){return U([e,r,a],[t,n,i],o,l,q)}(e,t,r,n,a,i,o,l);return $(s.x,s.y,o,l)}function Z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function J(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Z(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Z(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}
/*!
* @antv/g-plugin-canvas-picker
* @description A G plugin for picking in canvas
* @version 2.1.23
* @date 5/30/2025, 2:56:22 AM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/var K=C(),ee=C(),te=C(),re=w(),ne=function(){function e(){var r=this;o(this,e),this.isHit=function(e,n,a,i){var o,l,s,c,u,h,f,d,v,p,y,g,m,b,x,S,w,E,k,M,C,A,P,R,L,I,D,N,j,F,B,_=r.context.pointInPathPickerFactory[e.nodeName];if(_){var G=(o=re,(B=(k=(s=(l=a)[0])*(d=l[5])-(c=l[1])*(f=l[4]))*(F=(m=l[10])*(E=l[15])-(b=l[11])*(w=l[14]))-(M=s*(v=l[6])-(u=l[2])*f)*(j=(g=l[9])*E-b*(S=l[13]))+(C=s*(p=l[7])-(h=l[3])*f)*(N=g*w-m*S)+(A=c*v-u*d)*(D=(y=l[8])*E-b*(x=l[12]))-(P=c*p-h*d)*(I=y*w-m*x)+(R=u*p-h*v)*(L=y*S-g*x))?(o[0]=(d*F-v*j+p*N)*(B=1/B),o[1]=(u*j-c*F-h*N)*B,o[2]=(S*R-w*P+E*A)*B,o[3]=(m*P-g*R-b*A)*B,o[4]=(v*D-f*F-p*I)*B,o[5]=(s*F-u*D+h*I)*B,o[6]=(w*C-x*R-E*M)*B,o[7]=(y*R-m*C+b*M)*B,o[8]=(f*j-d*D+p*L)*B,o[9]=(c*D-s*j-h*L)*B,o[10]=(x*P-S*C+E*k)*B,o[11]=(g*C-y*P-b*k)*B,o[12]=(d*I-f*N-v*L)*B,o[13]=(s*N-c*I+u*L)*B,o[14]=(S*M-x*A-w*k)*B,o[15]=(y*A-g*M+m*k)*B,o):null),W=T(ee,O(te,n[0],n[1],0),G);if(_(e,new t.Point(W[0],W[1]),i,r.isPointInPath,r.context,r.runtime))return!0}return!1},this.isPointInPath=function(e,t){var n=r.runtime.offscreenCanvasCreator.getOrCreateContext(r.context.config.offscreenCanvas),a=r.context.pathGeneratorFactory[e.nodeName];return a&&(n.beginPath(),a(n,e.parsedStyle),n.closePath()),n.isPointInPath(t.x,t.y)}}return i(e,[{key:"apply",value:function(t,r){var n,a=this,i=t.renderingService,o=t.renderingContext;this.context=t,this.runtime=r;var l=null===(n=o.root)||void 0===n?void 0:n.ownerDocument;i.hooks.pick.tapPromise(e.tag,function(){var e=H(G().mark((function e(t){return G().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,r){var n,a=r.topmost,i=r.position,o=O(K,i.x,i.y,0),l=[],s=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=p(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return e.length>n?{done:!1,value:e[n++]}:{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(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){l=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw i}}}}(e.elementsFromBBox(o[0],o[1],o[0],o[1]));try{for(s.s();!(n=s.n()).done;){var c=n.value,u=c.getWorldTransform();if(this.isHit(c,o,u,!1)){var h=t.findClosestClipPathTarget(c);if(h){var f=h.parsedStyle.clipPath;if(this.isHit(f,o,f.getWorldTransform(),!0)){if(a)return r.picked=[c],r;l.push(c)}}else{if(a)return r.picked=[c],r;l.push(c)}}}}catch(e){s.e(e)}finally{s.f()}return r.picked=l,r}}])}();function ae(e,r,n){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,f=a.pointerEvents,d=void 0===f?"auto":f,v=((void 0===u?1:u)+(void 0===h?0:h))/2,p=$(void 0===i?0:i,void 0===o?0:o,r.x,r.y),g=y(t.isFillOrStrokeAffected(d,s,c),2),m=g[0],b=g[1];return m&&b||n?l+v>=p:m?l>=p:!!b&&(p>=l-v&&l+v>=p)}function ie(e,t,r,n){return e/(r*r)+t/(n*n)}function oe(e,r,n){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,f=void 0===h?1:h,d=a.increasedLineWidthForHitTesting,v=void 0===d?0:d,p=a.pointerEvents,g=r.x,m=r.y,b=y(t.isFillOrStrokeAffected(void 0===p?"auto":p,a.fill,a.stroke),2),x=b[0],S=b[1],w=(f+v)/2,E=(g-o)*(g-o),k=(m-s)*(m-s);return x&&S||n?1>=ie(E,k,c+w,u+w):x?1>=ie(E,k,c,u):!!S&&(ie(E,k,c-w,u-w)>=1&&1>=ie(E,k,c+w,u+w))}function le(e,t,r,n,a,i){return!(e>a||a>e+r||t>i||i>t+n)}function se(e,t,r,n,a,i,o,l){var s=(Math.atan2(l-t,o-e)+2*Math.PI)%(2*Math.PI),c={x:e+r*Math.cos(s),y:t+r*Math.sin(s)};return $(c.x,c.y,o,l)<=i/2}function ce(e,t,r,n,a,i,o){var l=a/2;return!(Math.min(e,r)-l>i||i>Math.max(e,r)+l||Math.min(t,n)-l>o||o>Math.max(t,n)+l)&&Y(e,t,r,n,i,o)<=a/2}function ue(e,t,r,n,a){var i=e.length;if(2>i)return!1;for(var o=0;i-1>o;o++){if(ce(e[o][0],e[o][1],e[o+1][0],e[o+1][1],t,r,n))return!0}if(a){var l=e[0],s=e[i-1];if(ce(l[0],l[1],s[0],s[1],t,r,n))return!0}return!1}ne.tag="CanvasPicker";function he(e){return 1e-6>Math.abs(e)?0:0>e?-1:1}function fe(e,t,r){return!((r[0]-e[0])*(t[1]-e[1])!==(t[0]-e[0])*(r[1]-e[1])||Math.min(e[0],t[0])>r[0]||r[0]>Math.max(e[0],t[0])||Math.min(e[1],t[1])>r[1]||r[1]>Math.max(e[1],t[1]))}function de(e,t,r){var n=!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(fe(o,l,[t,r]))return!0;he(o[1]-r)>0!=he(l[1]-r)>0&&0>he(t-(r-o[1])*(o[0]-l[0])/(o[1]-l[1])-o[0])&&(n=!n)}return n}function ve(e,t,r){for(var n=!1,a=0;e.length>a;a++){if(n=de(e[a],t,r))break}return n}function pe(e,r,n){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,f=void 0===h?0:h,d=a.pointerEvents;return!(!y(t.isFillOrStrokeAffected(void 0===d?"auto":d,a.fill,a.stroke),2)[1]&&!n||!u)&&ce(i,o,l,s,u+f,r.x,r.y)}function ye(e,r,n,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,f=l.d,d=l.pointerEvents,v=f.segments,p=f.hasArc,g=f.polylines,m=f.polygons,b=y(t.isFillOrStrokeAffected(void 0===d?"auto":d,(null==m?void 0:m.length)&&l.fill,l.stroke),2),x=b[0],S=b[1],w=t.getOrCalculatePathTotalLength(e),E=!1;return x||n?E=p?a(e,r):ve(m,r.x,r.y)||ve(g,r.x,r.y):((S||n)&&(E=function(e,t,r,n,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,f=s.box;if(!f||le(f.x-o,f.y-o,f.width+t,f.height+t,r,n))switch(s.command){case"L":case"Z":if(i=ce(h[0],h[1],c[0],c[1],t,r,n))return!0;break;case"Q":if(i=t/2>=Q(h[0],h[1],u[1],u[2],u[3],u[4],r,n))return!0;break;case"C":if(i=t/2>=X(h[0],h[1],u[1],u[2],u[3],u[4],u[5],u[6],r,n,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 d=s.cubicParams,v=h,p=0;d.length>p;p+=6){var y=X(v[0],v[1],d[p],d[p+1],d[p+2],d[p+3],d[p+4],d[p+5],r,n,a);if(v=[d[p+4],d[p+5]],i=t/2>=y)return!0}}}return i}(v,c+h,r.x,r.y,w)),E)}function ge(e,r,n){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),f=h[0],d=!1;return(h[1]||n)&&(d=ue(c.points,o+s,r.x,r.y,!0)),d||!f&&!n||(d=de(c.points,r.x,r.y)),d}function me(e,r,n){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]&&!n||!o)&&ue(c.points,o+s,r.x,r.y,!1)}function be(e,r,n,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,f=o.x,d=void 0===f?0:f,v=o.y,p=void 0===v?0:v,g=o.width,m=o.height,x=o.pointerEvents,S=y(t.isFillOrStrokeAffected(void 0===x?"auto":x,o.fill,o.stroke),2),w=S[0],E=S[1],k=c+h;if(l&&l.some((function(e){return 0!==e}))){var M=!1;return(E||n)&&(M=function(e,t,r,n,a,i,o,l){var s=y(a,4),c=s[0],u=s[1],h=s[2],f=s[3];return ce(e+c,t,e+r-u,t,i,o,l)||ce(e+r,t+u,e+r,t+n-h,i,o,l)||ce(e+r-h,t+n,e+f,t+n,i,o,l)||ce(e,t+n-f,e,t+c,i,o,l)||se(e+r-u,t+u,u,0,0,i,o,l)||se(e+r-h,t+n-h,h,0,0,i,o,l)||se(e+f,t+n-f,f,0,0,i,o,l)||se(e+c,t+c,c,0,0,i,o,l)}(d,p,g,m,l.map((function(e){return b(e,0,Math.min(Math.abs(g)/2,Math.abs(m)/2))})),k,r.x,r.y)),M||!w&&!n||(M=a(e,r)),M}var C=k/2;return w&&E||n?le(d-C,p-C,g+C,m+C,r.x,r.y):w?le(d,p,g,m,r.x,r.y):!!E&&function(e,t,r,n,a,i,o){var l=a/2;return le(e-l,t-l,r,a,i,o)||le(e+r-l,t-l,a,n,i,o)||le(e+l,t+n-l,r,a,i,o)||le(e-l,t+l,a,n,i,o)}(d,p,g,m,k,r.x,r.y)}function xe(e,r,n,a,i,o){var l=e.parsedStyle,s=l.pointerEvents,c=l.x,u=void 0===c?0:c,h=l.y,f=void 0===h?0:h,d=l.width,v=l.height;if("non-transparent-pixel"===(void 0===s?"auto":s)){var p=i.config.offscreenCanvas,y=o.offscreenCanvasCreator.getOrCreateCanvas(p),g=o.offscreenCanvasCreator.getOrCreateContext(p,{willReadFrequently:!0});return y.width=d,y.height=v,i.defaultStyleRendererFactory[t.Shape.IMAGE].render(g,J(J({},e.parsedStyle),{},{x:0,y:0}),e,void 0,void 0,void 0),g.getImageData(r.x-u,r.y-f,1,1).data.every((function(e){return 0!==e}))}return!0}function Se(e,t,r,n){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 we=function(e){function r(){var e;o(this,r);for(var t=arguments.length,n=Array(t),a=0;t>a;a++)n[a]=arguments[a];return(e=u(this,r,[].concat(n))).name="canvas-picker",e}return f(r,e),i(r,[{key:"init",value:function(){var e,r=(d(d(d(d(d(d(d(d(d(d(e={},t.Shape.CIRCLE,ae),t.Shape.ELLIPSE,oe),t.Shape.RECT,be),t.Shape.LINE,pe),t.Shape.POLYLINE,me),t.Shape.POLYGON,ge),t.Shape.PATH,ye),t.Shape.TEXT,Se),t.Shape.GROUP,null),t.Shape.IMAGE,xe),d(d(e,t.Shape.HTML,null),t.Shape.MESH,null));this.context.pointInPathPickerFactory=r,this.addRenderingPlugin(new ne)}},{key:"destroy",value:function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),Ee=Object.freeze({__proto__:null,Plugin:we});function ke(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var Me=0;function Ce(e){return"__private_"+Me+++"_"+e}
/*!
* @antv/g-plugin-image-loader
* @description A G plugin for loading image
* @version 2.1.23
* @date 5/30/2025, 2:54:46 AM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/var Oe=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,r){return!this.cacheStore.has(e)&&(this.cacheStore.set(e,{value:t,counter:new Set([r.entity])}),this.onRefAdded(r),!0)}},{key:"get",value:function(e,t){var r=this.cacheStore.get(e);return r?(r.counter.has(t.entity)||(r.counter.add(t.entity),this.onRefAdded(t)),r.value):null}},{key:"update",value:function(e,t,r){var n=this.cacheStore.get(e);return!!n&&(n.value=J(J({},n.value),t),n.counter.has(r.entity)||(n.counter.add(r.entity),this.onRefAdded(r)),!0)}},{key:"release",value:function(e,t){var r=this.cacheStore.get(e);return!!r&&(r.counter.delete(t.entity),r.counter.size>0||this.cacheStore.delete(e),!0)}},{key:"releaseRef",value:function(e){var t=this;Array.from(this.cacheStore.keys()).forEach((function(r){t.release(r,e)}))}},{key:"getSize",value:function(){return this.cacheStore.size}},{key:"clear",value:function(){this.cacheStore.clear()}}])}(),Te=[],Ae=[],Pe=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;(Te.length>0||Ae.length>0)&&(Ae.forEach((function(e){return e()})),Ae=Te.splice(0,e.TASK_NUM_PER_FRAME),e.rafId=t.requestAnimationFrame((function(){e.executeTask(t)})))}},{key:"sliceImage",value:function(t,r,n,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=r-i,u=n-i,h=Math.ceil(l/c),f=Math.ceil(s/u),d={tileSize:[r,n],gridSize:[f,h],tiles:Array(f).fill(null).map((function(){return Array(h).fill(null)}))},v=function(e){for(var i=function(i){Te.push((function(){var h=i*c,f=e*u,v=[Math.min(r,l-h),Math.min(n,s-f)],p=v[0],y=v[1],g=o.createCanvas();g.width=r,g.height=n,g.getContext("2d").drawImage(t,h,f,p,y,0,0,p,y),d.tiles[e][i]={x:h,y:f,tileX:i,tileY:e,data:g},a()}))},f=0;h>f;f++)i(f)},p=0;f>p;p++)v(p);return e.stop(),e.executeTask(),d}}])}();Pe.TASK_NUM_PER_FRAME=10;var Re=new Oe;Re.onRefAdded=function(e){var r=this;e.addEventListener(t.ElementEvent.DESTROY,(function(){r.releaseRef(e)}),{once:!0})};var Le=function(){return i((function e(t,r){o(this,e),this.gradientCache={},this.patternCache={},this.context=t,this.runtime=r}),[{key:"getImageSync",value:function(e,t,r){var n=m(e)?e:e.src;if(Re.has(n)){var a=Re.get(n,t);if(a.img.complete)return null==r||r(a),a}return this.getOrCreateImage(e,t).then((function(e){null==r||r(e)})).catch((function(e){console.error(e)})),null}},{key:"getOrCreateImage",value:function(e,t){var r=this,n=m(e)?e:e.src;if(!m(e)&&!Re.has(n)){var a={img:e,size:[e.naturalWidth||e.width,e.naturalHeight||e.height],tileSize:Ie(e)};Re.put(n,a,t)}if(Re.has(n)){var i=Re.get(n,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=Ie(i.img),e(i)})),i.img.addEventListener("error",(function(e){t(e)}))}))}return new Promise((function(e,a){var i=r.context.config.createImage();if(i){var o={img:i,size:[0,0],tileSize:Ie(i)};Re.put(n,o,t),i.onload=function(){o.size=[i.naturalWidth||i.width,i.naturalHeight||i.height],o.tileSize=Ie(o.img),e(o)},i.onerror=function(e){a(e)},i.crossOrigin="Anonymous",i.src=n}}))}},{key:"createDownSampledImage",value:(r=H(G().mark((function e(t,r){var n,a,i,o,l,s,c,u,h,f,d,v,p,g;return G().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getOrCreateImage(t,r);case 2:if(void 0===(n=e.sent).downSamplingRate){e.next=5;break}return e.abrupt("return",n);case 5: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(n.size,2),v=n.img,p=Math.min((l+l)/((f=h[0])+(d=h[1])),Math.max(.01,Math.min(c,.5))),g=J(J({},n),{},{downSamplingRate:p}),Re.update(n.img.src,g,r),!u){e.next=25;break}return e.prev=14,e.next=17,u(n.img,{resizeWidth:f*p,resizeHeight:d*p});case 17:v=e.sent,e.next=23;break;case 20:e.prev=20,e.t0=e.catch(14),p=1;case 23:e.next=26;break;case 25:p=1;case 26:return g=J(J({},this.getImageSync(t,r)),{},{downSampled:v,downSamplingRate:p}),Re.update(n.img.src,g,r),e.abrupt("return",g);case 29:case"end":return e.stop()}}),e,this,[[14,20]])}))),function(e,t){return r.apply(this,arguments)})},{key:"createImageTiles",value:(e=H(G().mark((function e(r,n,a,i){var o,l,s;return G().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getOrCreateImage(r,i);case 2:return o=e.sent,Pe.api={requestAnimationFrame:(l=i.ownerDocument.defaultView).requestAnimationFrame,cancelAnimationFrame:l.cancelAnimationFrame,createCanvas:function(){return t.OffscreenCanvasCreator.createCanvas()}},s=J(J({},o),Pe.sliceImage(o.img,o.tileSize[0],o.tileSize[0],a)),Re.update(o.img.src,s,i),e.abrupt("return",s);case 8:case"end":return e.stop()}}),e,this)}))),function(t,r,n,a){return e.apply(this,arguments)})},{key:"releaseImage",value:function(e,t){Re.release(m(e)?e:e.src,t)}},{key:"releaseImageRef",value:function(e){Re.releaseRef(e)}},{key:"getOrCreatePatternSync",value:function(e,r,n,a,i,o,l){var s=this.generatePatternKey(r);if(s&&this.patternCache[s])return this.patternCache[s];var c,u=r.image,h=r.repetition,f=r.transform,d=!1;if(m(u)){var v=this.getImageSync(u,e,l);c=null==v?void 0:v.img}else a?(c=a,d=!0):c=u;var p,y,g=c&&n.createPattern(c,h);g&&(f?p=t.parsedTransformToMat4(t.parseTransform(f),new t.DisplayObject({})):((y=w())[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),d&&function(e,t,r){var n=r[0],a=r[1],i=r[2];e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,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]),g.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&&g&&(this.patternCache[s]=g),g}},{key:"getOrCreateGradient",value:function(e,r){var n=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[n])return this.gradientCache[n];var f=null;if(a===t.GradientType.LinearGradient){var d=t.computeLinearGradient(o,l,s,e.angle);f=r.createLinearGradient(d.x1,d.y1,d.x2,d.y2)}else if(a===t.GradientType.RadialGradient){var v=t.computeRadialGradient(o,l,s,c,u,h),p=v.x,y=v.y;f=r.createRadialGradient(p,y,0,p,y,v.r)}return f&&(i.forEach((function(e){var r,n=e.offset;n.unit===t.UnitType.kPercentage&&(null===(r=f)||void 0===r||r.addColorStop(n.value/100,""+e.color))})),this.gradientCache[n]=f),this.gradientCache[n]}},{key:"generateGradientKey",value:function(e){var t=e.min,r=e.width,n=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(r,"-").concat(n,"-").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,r=e.repetition;return m(t)?"pattern-".concat(t,"-").concat(r):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(r):void 0}}]);var e,r}();function Ie(e){if(!e.complete)return[0,0];var t=e.naturalWidth||e.width,r=e.naturalHeight||e.height,n=256;return[256,512].forEach((function(e){1e3>Math.ceil(r/e)*Math.ceil(t/e)&&(n=e)})),[n,n]}Le.isSupportTile=!!t.OffscreenCanvasCreator.createCanvas();var De=function(){function e(){o(this,e)}return i(e,[{key:"apply",value:function(r){var n=r.renderingService,a=r.imagePool,i=r.renderingContext.root.ownerDocument.defaultView,o=function(e,t,r){var n=e.parsedStyle,a=n.width,i=n.height;a&&!i?e.setAttribute("height",r/t*a):!a&&i&&e.setAttribute("width",t/r*i)},l=function(e){var r=e.target,i=r.attributes;if(r.nodeName===t.Shape.IMAGE){var l=i.keepAspectRatio;a.getImageSync(i.src,r,(function(e){var t=e.img;l&&o(r,t.width,t.height),r.renderable.dirty=!0,n.dirtify()}))}},s=function(e){var r=e.target,i=e.prevValue,l=e.newValue;r.nodeName===t.Shape.IMAGE&&"src"===e.attrName&&(i!==l&&a.releaseImage(i,r),m(l)&&a.getOrCreateImage(l,r).then((function(e){var t=e.img;r.attributes.keepAspectRatio&&o(r,t.width,t.height),r.renderable.dirty=!0,n.dirtify()})).catch((function(){})))};n.hooks.init.tap(e.tag,(function(){i.addEventListener(t.ElementEvent.MOUNTED,l),i.addEventListener(t.ElementEvent.ATTR_MODIFIED,s)})),n.hooks.destroy.tap(e.tag,(function(){i.removeEventListener(t.ElementEvent.MOUNTED,l),i.removeEventListener(t.ElementEvent.ATTR_MODIFIED,s)}))}}])}();De.tag="LoadImage";var Ne=function(e){function t(){var e;o(this,t);for(var r=arguments.length,n=Array(r),a=0;r>a;a++)n[a]=arguments[a];return(e=u(this,t,[].concat(n))).name="image-loader",e}return f(t,e),i(t,[{key:"init",value:function(e){this.context.imagePool=new Le(this.context,e),this.addRenderingPlugin(new De)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin),je=Object.freeze({__proto__:null,ImagePool:Le,Plugin:Ne}),Fe=Ce("renderState"),Be=function(){function e(t){o(this,e),this.removedRBushNodeAABBs=[],this.renderQueue=[],Object.defineProperty(this,Fe,{writable:!0,value:{restoreStack:[],prevObject:null,currentContext:new Map}}),this.clearFullScreenLastFrame=!1,this.clearFullScreen=!1,this.vpMatrix=w(),this.dprMatrix=w(),this.tmpMat4=w(),this.vec3a=C(),this.vec3b=C(),this.vec3c=C(),this.vec3d=C(),this.canvasRendererPluginOptions=t}return i(e,[{key:"apply",value:function(r,n){var a=this;this.context=r;var i=this.context,o=i.config,l=i.camera,s=i.renderingService,c=i.renderingContext,u=i.rBushRoot,h=i.pathGeneratorFactory,f=o.renderer.getConfig().enableRenderingOptimization;o.renderer.getConfig().enableDirtyCheck=!1,o.renderer.getConfig().enableDirtyRectangleRendering=!1,this.rBush=u,this.pathGeneratorFactory=h;var d=r.contextService,v=c.root.ownerDocument.defaultView,p=function(e){var t=e.target.rBushNode;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=d.getDPR(),r=o.width,n=o.height,i=d.getContext();a.clearRect(i,0,0,r*e,n*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=[],ke(a,Fe)[Fe]={restoreStack:[],prevObject:null,currentContext:null}})),s.hooks.beginFrame.tap(e.tag,(function(){var e,t=d.getContext(),r=d.getDPR(),n=o.width,i=o.height,l=a.canvasRendererPluginOptions,c=l.dirtyObjectNumThreshold,u=l.dirtyObjectRatioThreshold,h=s.getStats(),f=h.rendered,p=f/h.total;a.clearFullScreen=a.clearFullScreenLastFrame||!(null!==(e=v.context.renderingPlugins[1])&&void 0!==e&&e.isFirstTimeRenderingFinished)||s.disableDirtyRectangleRendering()||f>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,n*r,i*r,o.background))}));var g=function(e,t){for(var r=[e];r.length>0;){var i,o=r.pop();o.isVisible()&&!o.isCulled()&&(f?a.renderDisplayObjectOptimized(o,t,a.context,ke(a,Fe)[Fe],n):a.renderDisplayObject(o,t,a.context,ke(a,Fe)[Fe],n));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--)r.push(l[s])}};s.hooks.endFrame.tap(e.tag,(function(){if(0!==c.root.childNodes.length){f=o.renderer.getConfig().enableRenderingOptimization,ke(a,Fe)[Fe]={restoreStack:[],prevObject:null,currentContext:ke(a,Fe)[Fe].currentContext},ke(a,Fe)[Fe].currentContext.clear(),a.clearFullScreenLastFrame=!1;var e,r,i=d.getContext(),s=d.getDPR();if((e=a.dprMatrix)[0]=(r=[s,s,1])[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=r[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,k(a.vpMatrix,a.dprMatrix,l.getOrthoMatrix()),a.clearFullScreen)f?(i.save(),g(c.root,i),i.restore()):g(c.root,i),a.removedRBushNodeAABBs=[];else{var u=a.safeMergeAABB.apply(a,[a.mergeDirtyAABBs(a.renderQueue)].concat(z(a.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,a=e.maxX,i=e.maxY,o=new t.AABB;return o.setMinMax([r,n,0],[a,i,0]),o})))));if(a.removedRBushNodeAABBs=[],t.AABB.isEmpty(u))return void(a.renderQueue=[]);var h=a.convertAABB2Rect(u),p=h.x,y=h.y,m=h.width,b=h.height,x=T(a.vec3a,[p,y,0],a.vpMatrix),S=T(a.vec3b,[p+m,y,0],a.vpMatrix),w=T(a.vec3c,[p,y+b,0],a.vpMatrix),E=T(a.vec3d,[p+m,y+b,0],a.vpMatrix),M=Math.min(x[0],S[0],E[0],w[0]),C=Math.min(x[1],S[1],E[1],w[1]),O=Math.max(x[0],S[0],E[0],w[0]),A=Math.max(x[1],S[1],E[1],w[1]),P=Math.floor(M),R=Math.floor(C),L=Math.ceil(O-M),I=Math.ceil(A-C);i.save(),a.clearRect(i,P,R,L,I,o.background),i.beginPath(),i.rect(P,R,L,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:P,y:R,width:L,height:I}})),a.searchDirtyObjects(u).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,ke(a,Fe)[Fe],n)})),i.restore(),a.renderQueue.forEach((function(e){a.saveDirtyAABB(e)})),a.renderQueue=[]}ke(a,Fe)[Fe].restoreStack.forEach((function(){i.restore()})),ke(a,Fe)[Fe].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,r,n,a,i){e.clearRect(t,r,n,a),i&&(e.fillStyle=i,e.fillRect(t,r,n,a))}},{key:"renderDisplayObjectOptimized",value:function(e,r,n,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(r,u),a.prevObject=null);var h=this.pathGeneratorFactory[u.nodeName];h&&(r.save(),l=!0,r.beginPath(),h(r,u.parsedStyle),r.closePath(),r.clip())}if(s){(!a.prevObject||!M(e.getWorldTransform(),a.prevObject.getWorldTransform()))&&this.applyWorldTransform(r,e);var f=!a.prevObject;if(!f){var d=a.prevObject.nodeName;f=o===t.Shape.TEXT?d!==t.Shape.TEXT:o===t.Shape.IMAGE?d!==t.Shape.IMAGE:d===t.Shape.TEXT||d===t.Shape.IMAGE}s.applyStyleToContext(r,e,f,a),a.prevObject=e}c&&(r.beginPath(),c(r,e.parsedStyle),o!==t.Shape.LINE&&o!==t.Shape.PATH&&o!==t.Shape.POLYLINE&&r.closePath()),s&&s.drawToContext(r,e,ke(this,Fe)[Fe],this,i),l&&r.restore(),e.renderable.dirty=!1}},{key:"renderDisplayObject",value:function(e,r,n,a,i){var o=e.nodeName,l=a.restoreStack[a.restoreStack.length-1];!l||e.compareDocumentPosition(l)&t.Node.DOCUMENT_POSITION_CONTAINS||(r.restore(),a.restoreStack.pop());var s=this.context.styleRendererFactory[o],c=this.pathGeneratorFactory[o],u=e.parsedStyle.clipPath;if(u){this.applyWorldTransform(r,u);var h=this.pathGeneratorFactory[u.nodeName];h&&(r.save(),a.restoreStack.push(e),r.beginPath(),h(r,u.parsedStyle),r.closePath(),r.clip())}s&&(this.applyWorldTransform(r,e),r.save(),this.applyAttributesToContext(r,e)),c&&(r.beginPath(),c(r,e.parsedStyle),o!==t.Shape.LINE&&o!==t.Shape.PATH&&o!==t.Shape.POLYLINE&&r.closePath()),s&&(s.render(r,e.parsedStyle,e,n,this,i),r.restore()),e.renderable.dirty=!1}},{key:"applyAttributesToContext",value:function(e,t){var r=t.parsedStyle,n=r.stroke,a=r.fill,i=r.opacity,o=r.lineDash,l=r.lineDashOffset;o&&e.setLineDash(o),g(l)||(e.lineDashOffset=l),g(i)||(e.globalAlpha*=i),g(n)||Array.isArray(n)||n.isNone||(e.strokeStyle=t.attributes.stroke),g(a)||Array.isArray(a)||a.isNone||(e.fillStyle=t.attributes.fill)}},{key:"convertAABB2Rect",value:function(e){var t=e.getMin(),r=e.getMax(),n=Math.floor(t[0]),a=Math.floor(t[1]);return{x:n,y:a,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-a}}},{key:"mergeDirtyAABBs",value:function(e){var r=new t.AABB;return e.forEach((function(e){var t=e.getRenderBounds();r.add(t);var n=e.renderable.dirtyRenderBounds;n&&r.add(n)})),r}},{key:"searchDirtyObjects",value:function(e){var t=y(e.getMin(),2),r=t[0],n=t[1],a=y(e.getMax(),2);return this.rBush.search({minX:r,minY:n,maxX:a[0],maxY:a[1]}).map((function(e){return e.displayObject}))}},{key:"saveDirtyAABB",value:function(e){var r=e.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new t.AABB);var n=e.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)}},{key:"applyWorldTransform",value:function(e,t,r){r?(E(this.tmpMat4,t.getLocalTransform()),k(this.tmpMat4,r,this.tmpMat4),k(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(E(this.tmpMat4,t.getWorldTransform()),k(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,r=arguments.length,n=Array(r),a=0;r>a;a++)n[a]=arguments[a];return n.forEach((function(t){e.add(t)})),e}}])}();function _e(e,t,r,n,a,i,o){var l,s;if("rect"===e.image.nodeName){var c=e.image.parsedStyle,u=c.width,h=c.height;s=n.contextService.getDPR();var f=n.config.offscreenCanvas;(l=i.offscreenCanvasCreator.getOrCreateCanvas(f)).width=u*s,l.height=h*s;var d=i.offscreenCanvasCreator.getOrCreateContext(f),v={restoreStack:[],prevObject:null,currentContext:new Map};e.image.forEach((function(e){a.renderDisplayObject(e,d,n,v,i)})),v.restoreStack.forEach((function(){d.restore()}))}return o.getOrCreatePatternSync(t,e,r,l,s,t.getGeometryBounds().min,(function(){t.renderable.dirty=!0,n.renderingService.dirtify()}))}function Ge(e,r,n,a){var i;if(e.type===t.GradientType.LinearGradient||e.type===t.GradientType.RadialGradient){var o=r.getGeometryBounds(),l=o&&2*o.halfExtents[0]||1,s=o&&2*o.halfExtents[1]||1,c=o&&o.min||[0,0];i=a.getOrCreateGradient(J(J({type:e.type},e.value),{},{min:c,width:l,height:s}),n)}return i}Be.tag="CanvasRenderer";var We=["shadowBlur","shadowOffsetX","shadowOffsetY"],He=["lineCap","lineJoin","miterLimit"],ze={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},$e={};function Ue(e,t,r,n){var a=n.has(t)?n.get(t):ze[t];return a!==r&&("lineDash"===t?e.setLineDash(r):e[t]=r,n.set(t,r)),a}var Ye=function(){return i((function e(t){o(this,e),this.imagePool=t}),[{key:"applyAttributesToContext",value:function(e,t){}},{key:"render",value:function(e,t,r,n,a,i){}},{key:"applyCommonStyleToContext",value:function(e,t,r,n){var a=r?$e:n.prevObject.parsedStyle,i=t.parsedStyle;(r||i.opacity!==a.opacity)&&Ue(e,"globalAlpha",g(i.opacity)?ze.globalAlpha:i.opacity,n.currentContext),(r||i.blend!==a.blend)&&Ue(e,"globalCompositeOperation",g(i.blend)?ze.globalCompositeOperation:i.blend,n.currentContext)}},{key:"applyStrokeFillStyleToContext",value:function(e,t,r,n){var a=r?$e:n.prevObject.parsedStyle,i=t.parsedStyle,o=i.lineWidth,l=i.fill&&!i.fill.isNone;if(i.stroke&&!i.stroke.isNone&&(void 0===o?ze.lineWidth:o)>0){if(r||t.attributes.stroke!==n.prevObject.attributes.stroke)Ue(e,"strokeStyle",g(i.stroke)||Array.isArray(i.stroke)||i.stroke.isNone?ze.strokeStyle:t.attributes.stroke,n.currentContext);(r||i.lineWidth!==a.lineWidth)&&Ue(e,"lineWidth",g(i.lineWidth)?ze.lineWidth:i.lineWidth,n.currentContext),(r||i.lineDash!==a.lineDash)&&Ue(e,"lineDash",i.lineDash||ze.lineDash,n.currentContext),(r||i.lineDashOffset!==a.li