Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/g-plugin-canvas-renderer

Package Overview
Dependencies
Maintainers
0
Versions
262
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-plugin-canvas-renderer - npm Package Compare versions

Comparing version 2.2.16 to 2.2.17

13

dist/index.esm.js
/*!
* @antv/g-plugin-canvas-renderer
* @description A G plugin of renderer implementation with Canvas2D API
* @version 2.2.16
* @date 1/2/2025, 2:56:41 AM
* @version 2.2.17
* @date 1/17/2025, 2:07:56 PM
* @author AntVis

@@ -825,5 +825,4 @@ * @docs https://g.antv.antgroup.com/

fill.forEach(function (gradient) {
var _resetStyle;
var prevStyle = updateContextIfNotHitCache(context, 'fillStyle', getColor(gradient, object, context, _this.imagePool), renderState.currentContext);
resetStyle = (_resetStyle = resetStyle) !== null && _resetStyle !== void 0 ? _resetStyle : prevStyle;
resetStyle = resetStyle !== null && resetStyle !== void 0 ? resetStyle : prevStyle;
if (fillRule) {

@@ -861,5 +860,4 @@ context.fill(fillRule);

stroke.forEach(function (gradient) {
var _resetStyle2;
var prevStyle = updateContextIfNotHitCache(context, 'strokeStyle', getColor(gradient, object, context, _this2.imagePool), renderState.currentContext);
resetStyle = (_resetStyle2 = resetStyle) !== null && _resetStyle2 !== void 0 ? _resetStyle2 : prevStyle;
resetStyle = resetStyle !== null && resetStyle !== void 0 ? resetStyle : prevStyle;
context.stroke();

@@ -871,5 +869,4 @@ });

if (pattern) {
var _resetStyle3;
var prevStyle = updateContextIfNotHitCache(context, 'strokeStyle', pattern, renderState.currentContext);
resetStyle = (_resetStyle3 = resetStyle) !== null && _resetStyle3 !== void 0 ? _resetStyle3 : prevStyle;
resetStyle = resetStyle !== null && resetStyle !== void 0 ? resetStyle : prevStyle;
}

@@ -876,0 +873,0 @@ }

/*!
* @antv/g-plugin-canvas-renderer
* @description A G plugin of renderer implementation with Canvas2D API
* @version 2.2.16
* @date 1/2/2025, 2:56:41 AM
* @version 2.2.17
* @date 1/17/2025, 2:07:56 PM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite"),require("@antv/g-plugin-image-loader")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite","@antv/g-plugin-image-loader"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.CanvasRenderer={}),e.window.G,e.window.G.ImageLoader)}(this,(function(e,t,r){"use strict";function n(e){return n="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},n(e)}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function o(e,t,r){return(t=i(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(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 l(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function u(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(h=function(){return!!e})()}function f(e,t){if(t&&("object"==n(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 p(e,t,r){return t=d(t),f(e,h()?Reflect.construct(t,r||[],d(e).constructor):t.apply(e,r))}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function v(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&&y(e,t)}function m(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 g(e,t){if(e){if("string"==typeof e)return m(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)?m(e,t):void 0}}function b(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,i,o,a,l=[],s=!0,c=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=o.call(r)).done)&&(l.push(n.value),l.length!==t);s=!0);}catch(e){c=!0,i=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return l}}(e,t)||g(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 S(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(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.")}()}function w(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var x=0;function O(e){return"__private_"+x+++"_"+e}var C="undefined"!=typeof Float32Array?Float32Array:Array;function A(){var e=new C(16);return C!=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 k(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 M(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],l=t[4],s=t[5],c=t[6],u=t[7],d=t[8],h=t[9],f=t[10],p=t[11],y=t[12],v=t[13],m=t[14],g=t[15],b=r[0],S=r[1],w=r[2],x=r[3];return e[0]=b*n+S*l+w*d+x*y,e[1]=b*i+S*s+w*h+x*v,e[2]=b*o+S*c+w*f+x*m,e[3]=b*a+S*u+w*p+x*g,e[4]=(b=r[4])*n+(S=r[5])*l+(w=r[6])*d+(x=r[7])*y,e[5]=b*i+S*s+w*h+x*v,e[6]=b*o+S*c+w*f+x*m,e[7]=b*a+S*u+w*p+x*g,e[8]=(b=r[8])*n+(S=r[9])*l+(w=r[10])*d+(x=r[11])*y,e[9]=b*i+S*s+w*h+x*v,e[10]=b*o+S*c+w*f+x*m,e[11]=b*a+S*u+w*p+x*g,e[12]=(b=r[12])*n+(S=r[13])*l+(w=r[14])*d+(x=r[15])*y,e[13]=b*i+S*s+w*h+x*v,e[14]=b*o+S*c+w*f+x*m,e[15]=b*a+S*u+w*p+x*g,e}function T(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 R(){var e=new C(3);return C!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function P(e,t,r){var n=t[0],i=t[1],o=t[2],a=r[3]*n+r[7]*i+r[11]*o+r[15];return e[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/(a=a||1),e[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/a,e[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/a,e}function B(e){return null==e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),R();var E=O("renderState"),D=function(){function e(t){s(this,e),this.removedRBushNodeAABBs=[],this.renderQueue=[],Object.defineProperty(this,E,{writable:!0,value:{restoreStack:[],prevObject:null,currentContext:new Map}}),this.clearFullScreenLastFrame=!1,this.clearFullScreen=!1,this.vpMatrix=A(),this.dprMatrix=A(),this.tmpMat4=A(),this.vec3a=R(),this.vec3b=R(),this.vec3c=R(),this.vec3d=R(),this.canvasRendererPluginOptions=t}return u(e,[{key:"apply",value:function(r,n){var i=this;this.context=r;var o=this.context,a=o.config,l=o.camera,s=o.renderingService,c=o.renderingContext,u=o.rBushRoot,d=o.pathGeneratorFactory,h=a.renderer.getConfig().enableRenderingOptimization;a.renderer.getConfig().enableDirtyCheck=!1,a.renderer.getConfig().enableDirtyRectangleRendering=!1,this.rBush=u,this.pathGeneratorFactory=d;var f=r.contextService,p=c.root.ownerDocument.defaultView,y=function(e){var t=e.target.rBushNode;t.aabb&&i.removedRBushNodeAABBs.push(t.aabb)},v=function(e){var t=e.target.rBushNode;t.aabb&&i.removedRBushNodeAABBs.push(t.aabb)};s.hooks.init.tap(e.tag,(function(){p.addEventListener(t.ElementEvent.UNMOUNTED,y),p.addEventListener(t.ElementEvent.CULLED,v);var e=f.getDPR(),r=a.width,n=a.height,o=f.getContext();i.clearRect(o,0,0,r*e,n*e,a.background)})),s.hooks.destroy.tap(e.tag,(function(){p.removeEventListener(t.ElementEvent.UNMOUNTED,y),p.removeEventListener(t.ElementEvent.CULLED,v),i.renderQueue=[],i.removedRBushNodeAABBs=[],w(i,E)[E]={restoreStack:[],prevObject:null,currentContext:null}})),s.hooks.beginFrame.tap(e.tag,(function(){var e,t=f.getContext(),r=f.getDPR(),n=a.width,o=a.height,l=i.canvasRendererPluginOptions,c=l.dirtyObjectNumThreshold,u=l.dirtyObjectRatioThreshold,d=s.getStats(),h=d.rendered,y=h/d.total;i.clearFullScreen=i.clearFullScreenLastFrame||!(null!==(e=p.context.renderingPlugins[1])&&void 0!==e&&e.isFirstTimeRenderingFinished)||s.disableDirtyRectangleRendering()||h>c&&y>u,t&&("function"==typeof t.resetTransform?t.resetTransform():t.setTransform(1,0,0,1,0,0),i.clearFullScreen&&i.clearRect(t,0,0,n*r,o*r,a.background))}));var m=function(e,t){for(var r=[e];r.length>0;){var o=r.pop();o.isVisible()&&!o.isCulled()&&(h?i.renderDisplayObjectOptimized(o,t,i.context,w(i,E)[E],n):i.renderDisplayObject(o,t,i.context,w(i,E)[E],n));for(var a=o.sortable.sorted||o.childNodes,l=a.length-1;l>=0;l--)r.push(a[l])}};s.hooks.endFrame.tap(e.tag,(function(){if(0!==c.root.childNodes.length){h=a.renderer.getConfig().enableRenderingOptimization,w(i,E)[E]={restoreStack:[],prevObject:null,currentContext:w(i,E)[E].currentContext},w(i,E)[E].currentContext.clear(),i.clearFullScreenLastFrame=!1;var e,r,o=f.getContext(),s=f.getDPR();if((e=i.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,M(i.vpMatrix,i.dprMatrix,l.getOrthoMatrix()),i.clearFullScreen)h?(o.save(),m(c.root,o),o.restore()):m(c.root,o),i.removedRBushNodeAABBs=[];else{var u=i.safeMergeAABB.apply(i,[i.mergeDirtyAABBs(i.renderQueue)].concat(S(i.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,i=e.maxX,o=e.maxY,a=new t.AABB;return a.setMinMax([r,n,0],[i,o,0]),a})))));if(i.removedRBushNodeAABBs=[],t.AABB.isEmpty(u))return void(i.renderQueue=[]);var d=i.convertAABB2Rect(u),y=d.x,v=d.y,g=d.width,b=d.height,x=P(i.vec3a,[y,v,0],i.vpMatrix),O=P(i.vec3b,[y+g,v,0],i.vpMatrix),C=P(i.vec3c,[y,v+b,0],i.vpMatrix),A=P(i.vec3d,[y+g,v+b,0],i.vpMatrix),k=Math.min(x[0],O[0],A[0],C[0]),T=Math.min(x[1],O[1],A[1],C[1]),R=Math.max(x[0],O[0],A[0],C[0]),B=Math.max(x[1],O[1],A[1],C[1]),D=Math.floor(k),j=Math.floor(T),N=Math.ceil(R-k),F=Math.ceil(B-T);o.save(),i.clearRect(o,D,j,N,F,a.background),o.beginPath(),o.rect(D,j,N,F),o.clip(),o.setTransform(i.vpMatrix[0],i.vpMatrix[1],i.vpMatrix[4],i.vpMatrix[5],i.vpMatrix[12],i.vpMatrix[13]),a.renderer.getConfig().enableDirtyRectangleRenderingDebug&&p.dispatchEvent(new t.CustomEvent(t.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:D,y:j,width:N,height:F}})),i.searchDirtyObjects(u).sort((function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder})).forEach((function(e){e&&e.isVisible()&&!e.isCulled()&&i.renderDisplayObject(e,o,i.context,w(i,E)[E],n)})),o.restore(),i.renderQueue.forEach((function(e){i.saveDirtyAABB(e)})),i.renderQueue=[]}w(i,E)[E].restoreStack.forEach((function(){o.restore()})),w(i,E)[E].restoreStack=[]}else i.clearFullScreenLastFrame=!0})),s.hooks.render.tap(e.tag,(function(e){i.clearFullScreen||i.renderQueue.push(e)}))}},{key:"clearRect",value:function(e,t,r,n,i,o){e.clearRect(t,r,n,i),o&&(e.fillStyle=o,e.fillRect(t,r,n,i))}},{key:"renderDisplayObjectOptimized",value:function(e,r,n,i,o){var a=e.nodeName,l=!1,s=this.context.styleRendererFactory[a],c=this.pathGeneratorFactory[a],u=e.parsedStyle.clipPath;if(u){(!i.prevObject||!T(u.getWorldTransform(),i.prevObject.getWorldTransform()))&&(this.applyWorldTransform(r,u),i.prevObject=null);var d=this.pathGeneratorFactory[u.nodeName];d&&(r.save(),l=!0,r.beginPath(),d(r,u.parsedStyle),r.closePath(),r.clip())}if(s){(!i.prevObject||!T(e.getWorldTransform(),i.prevObject.getWorldTransform()))&&this.applyWorldTransform(r,e);var h=!i.prevObject;if(!h){var f=i.prevObject.nodeName;h=a===t.Shape.TEXT?f!==t.Shape.TEXT:a===t.Shape.IMAGE?f!==t.Shape.IMAGE:f===t.Shape.TEXT||f===t.Shape.IMAGE}s.applyStyleToContext(r,e,h,i),i.prevObject=e}c&&(r.beginPath(),c(r,e.parsedStyle),a!==t.Shape.LINE&&a!==t.Shape.PATH&&a!==t.Shape.POLYLINE&&r.closePath()),s&&s.drawToContext(r,e,w(this,E)[E],this,o),l&&r.restore(),e.renderable.dirty=!1}},{key:"renderDisplayObject",value:function(e,r,n,i,o){var a=e.nodeName,l=i.restoreStack[i.restoreStack.length-1];!l||e.compareDocumentPosition(l)&t.Node.DOCUMENT_POSITION_CONTAINS||(r.restore(),i.restoreStack.pop());var s=this.context.styleRendererFactory[a],c=this.pathGeneratorFactory[a],u=e.parsedStyle.clipPath;if(u){this.applyWorldTransform(r,u);var d=this.pathGeneratorFactory[u.nodeName];d&&(r.save(),i.restoreStack.push(e),r.beginPath(),d(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),a!==t.Shape.LINE&&a!==t.Shape.PATH&&a!==t.Shape.POLYLINE&&r.closePath()),s&&(s.render(r,e.parsedStyle,e,n,this,o),r.restore()),e.renderable.dirty=!1}},{key:"applyAttributesToContext",value:function(e,t){var r=t.parsedStyle,n=r.stroke,i=r.fill,o=r.opacity,a=r.lineDash,l=r.lineDashOffset;a&&e.setLineDash(a),B(l)||(e.lineDashOffset=l),B(o)||(e.globalAlpha*=o),B(n)||Array.isArray(n)||n.isNone||(e.strokeStyle=t.attributes.stroke),B(i)||Array.isArray(i)||i.isNone||(e.fillStyle=t.attributes.fill)}},{key:"convertAABB2Rect",value:function(e){var t=e.getMin(),r=e.getMax(),n=Math.floor(t[0]),i=Math.floor(t[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}}},{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=b(e.getMin(),2),r=t[0],n=t[1],i=b(e.getMax(),2);return this.rBush.search({minX:r,minY:n,maxX:i[0],maxY:i[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?(k(this.tmpMat4,t.getLocalTransform()),M(this.tmpMat4,r,this.tmpMat4),M(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(k(this.tmpMat4,t.getWorldTransform()),M(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),i=0;r>i;i++)n[i]=arguments[i];return n.forEach((function(t){e.add(t)})),e}}])}();function j(e,t,r,n,i,o,a){var l,s;if("rect"===e.image.nodeName){var c=e.image.parsedStyle,u=c.width,d=c.height;s=n.contextService.getDPR();var h=n.config.offscreenCanvas;(l=o.offscreenCanvasCreator.getOrCreateCanvas(h)).width=u*s,l.height=d*s;var f=o.offscreenCanvasCreator.getOrCreateContext(h),p={restoreStack:[],prevObject:null,currentContext:new Map};e.image.forEach((function(e){i.renderDisplayObject(e,f,n,p,o)})),p.restoreStack.forEach((function(){f.restore()}))}return a.getOrCreatePatternSync(t,e,r,l,s,t.getGeometryBounds().min,(function(){t.renderable.dirty=!0,n.renderingService.dirtify()}))}function N(e,r,n,i){var o;if(e.type===t.GradientType.LinearGradient||e.type===t.GradientType.RadialGradient){var a=r.getGeometryBounds(),s=a&&2*a.halfExtents[0]||1,c=a&&2*a.halfExtents[1]||1,u=a&&a.min||[0,0];o=i.getOrCreateGradient(l(l({type:e.type},e.value),{},{min:u,width:s,height:c}),n)}return o}D.tag="CanvasRenderer";var F=["shadowBlur","shadowOffsetX","shadowOffsetY"],L=["lineCap","lineJoin","miterLimit"],I={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},G={};function W(e,t,r,n){var i=n.has(t)?n.get(t):I[t];return i!==r&&("lineDash"===t?e.setLineDash(r):e[t]=r,n.set(t,r)),i}var Y=function(){return u((function e(t){s(this,e),this.imagePool=t}),[{key:"applyAttributesToContext",value:function(e,t){}},{key:"render",value:function(e,t,r,n,i,o){}},{key:"applyCommonStyleToContext",value:function(e,t,r,n){var i=r?G:n.prevObject.parsedStyle,o=t.parsedStyle;(r||o.opacity!==i.opacity)&&W(e,"globalAlpha",B(o.opacity)?I.globalAlpha:o.opacity,n.currentContext),(r||o.blend!==i.blend)&&W(e,"globalCompositeOperation",B(o.blend)?I.globalCompositeOperation:o.blend,n.currentContext)}},{key:"applyStrokeFillStyleToContext",value:function(e,t,r,n){var i=r?G:n.prevObject.parsedStyle,o=t.parsedStyle,a=o.lineWidth,l=o.fill&&!o.fill.isNone;if(o.stroke&&!o.stroke.isNone&&(void 0===a?I.lineWidth:a)>0){if(r||t.attributes.stroke!==n.prevObject.attributes.stroke)W(e,"strokeStyle",B(o.stroke)||Array.isArray(o.stroke)||o.stroke.isNone?I.strokeStyle:t.attributes.stroke,n.currentContext);(r||o.lineWidth!==i.lineWidth)&&W(e,"lineWidth",B(o.lineWidth)?I.lineWidth:o.lineWidth,n.currentContext),(r||o.lineDash!==i.lineDash)&&W(e,"lineDash",o.lineDash||I.lineDash,n.currentContext),(r||o.lineDashOffset!==i.lineDashOffset)&&W(e,"lineDashOffset",B(o.lineDashOffset)?I.lineDashOffset:o.lineDashOffset,n.currentContext);for(var s=0;L.length>s;s++){var c=L[s];(r||o[c]!==i[c])&&W(e,c,B(o[c])?I[c]:o[c],n.currentContext)}}l&&(r||t.attributes.fill!==n.prevObject.attributes.fill)&&W(e,"fillStyle",B(o.fill)||Array.isArray(o.fill)||o.fill.isNone?I.fillStyle:t.attributes.fill,n.currentContext)}},{key:"applyStyleToContext",value:function(e,r,n,i){var o=r.nodeName;this.applyCommonStyleToContext(e,r,n,i),o===t.Shape.IMAGE||this.applyStrokeFillStyleToContext(e,r,n,i)}},{key:"applyShadowAndFilterStyleToContext",value:function(e,t,r,n){var i=t.parsedStyle;if(r){W(e,"shadowColor",""+i.shadowColor,n.currentContext);for(var o=0;F.length>o;o++){var a=F[o];W(e,a,i[a]||I[a],n.currentContext)}}i.filter&&i.filter.length&&W(e,"filter",t.attributes.filter,n.currentContext)}},{key:"clearShadowAndFilterStyleForContext",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(t){W(e,"shadowColor",I.shadowColor,n.currentContext);for(var o=0;F.length>o;o++){var a=F[o];W(e,a,I[a],n.currentContext)}}if(r)if(t&&i){var l=e.filter;!B(l)&&l.indexOf("drop-shadow")>-1&&W(e,"filter",l.replace(/drop-shadow\([^)]*\)/,"").trim()||I.filter,n.currentContext)}else W(e,"filter",I.filter,n.currentContext)}},{key:"fillToContext",value:function(e,r,n,i,o){var a=this,l=r.parsedStyle,s=l.fill,c=l.fillRule,u=null;if(Array.isArray(s)&&s.length>0)s.forEach((function(t){var i,o=W(e,"fillStyle",N(t,r,e,a.imagePool),n.currentContext);u=null!==(i=u)&&void 0!==i?i:o,c?e.fill(c):e.fill()}));else{if(t.isPattern(s)){var d=j(s,r,e,r.ownerDocument.defaultView.context,i,o,this.imagePool);d&&(e.fillStyle=d,u=!0)}c?e.fill(c):e.fill()}null!==u&&W(e,"fillStyle",u,n.currentContext)}},{key:"strokeToContext",value:function(e,r,n,i,o){var a=this,l=r.parsedStyle.stroke,s=null;if(Array.isArray(l)&&l.length>0)l.forEach((function(t){var i,o=W(e,"strokeStyle",N(t,r,e,a.imagePool),n.currentContext);s=null!==(i=s)&&void 0!==i?i:o,e.stroke()}));else{if(t.isPattern(l)){var c=j(l,r,e,r.ownerDocument.defaultView.context,i,o,this.imagePool);if(c){var u,d=W(e,"strokeStyle",c,n.currentContext);s=null!==(u=s)&&void 0!==u?u:d}}e.stroke()}null!==s&&W(e,"strokeStyle",s,n.currentContext)}},{key:"drawToContext",value:function(e,r,n,i,o){var a,l=r.nodeName,s=r.parsedStyle,c=s.opacity,u=void 0===c?I.globalAlpha:c,d=s.fillOpacity,h=void 0===d?I.fillOpacity:d,f=s.strokeOpacity,p=void 0===f?I.strokeOpacity:f,y=s.lineWidth,v=s.fill&&!s.fill.isNone,m=s.stroke&&!s.stroke.isNone&&(void 0===y?I.lineWidth:y)>0;if(v||m){var g=!B(s.shadowColor)&&s.shadowBlur>0,b="inner"===s.shadowType,S=0===(null===(a=s.fill)||void 0===a?void 0:a.alpha),w=!(!s.filter||!s.filter.length),x=g&&m&&(l===t.Shape.PATH||l===t.Shape.LINE||l===t.Shape.POLYLINE||S||b),O=null;if(v)x||this.applyShadowAndFilterStyleToContext(e,r,g,n),O=W(e,"globalAlpha",u*h,n.currentContext),this.fillToContext(e,r,n,i,o),x||this.clearShadowAndFilterStyleForContext(e,g,w,n);if(m){var C=!1,A=W(e,"globalAlpha",u*p,n.currentContext);if(O=v?O:A,x&&(this.applyShadowAndFilterStyleToContext(e,r,g,n),C=!0,b)){var k=e.globalCompositeOperation;e.globalCompositeOperation="source-atop",this.strokeToContext(e,r,n,i,o),e.globalCompositeOperation=k,this.clearShadowAndFilterStyleForContext(e,g,w,n,!0)}this.strokeToContext(e,r,n,i,o),C&&this.clearShadowAndFilterStyleForContext(e,g,w,n)}null!==O&&W(e,"globalAlpha",O,n.currentContext)}}}])}(),_=function(e){function r(){return s(this,r),p(this,r,arguments)}return v(r,e),u(r,[{key:"render",value:function(e,r,n,i,o,a){var l=r.fill,s=r.fillRule,c=r.opacity,u=void 0===c?1:c,d=r.fillOpacity,h=void 0===d?1:d,f=r.stroke,p=r.strokeOpacity,y=void 0===p?1:p,v=r.lineWidth,m=void 0===v?1:v,g=r.lineCap,b=r.lineJoin,S=r.shadowType,w=r.shadowBlur,x=r.filter,O=r.miterLimit,C=l&&!l.isNone,A=f&&!f.isNone&&m>0,k=0===(null==l?void 0:l.alpha),M=!(!x||!x.length),T=!B(r.shadowColor)&&w>0,R=n.nodeName,P="inner"===S,E=A&&T&&(R===t.Shape.PATH||R===t.Shape.LINE||R===t.Shape.POLYLINE||k||P);C&&(e.globalAlpha=u*h,E||X(n,e,T),z(e,n,l,s,i,o,a,this.imagePool),E||this.clearShadowAndFilter(e,M,T)),A&&(e.globalAlpha=u*y,e.lineWidth=m,B(O)||(e.miterLimit=O),B(g)||(e.lineCap=g),B(b)||(e.lineJoin=b),E&&(P&&(e.globalCompositeOperation="source-atop"),X(n,e,!0),P&&(V(e,n,f,i,o,a,this.imagePool),e.globalCompositeOperation=I.globalCompositeOperation,this.clearShadowAndFilter(e,M,!0))),V(e,n,f,i,o,a,this.imagePool))}},{key:"clearShadowAndFilter",value:function(e,t,r){if(r&&(e.shadowColor="transparent",e.shadowBlur=0),t){var n=e.filter;!B(n)&&n.indexOf("drop-shadow")>-1&&(e.filter=n.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}}}])}(Y);function X(e,t,r){var n=e.parsedStyle,i=n.filter,o=n.shadowColor,a=n.shadowBlur,l=n.shadowOffsetX,s=n.shadowOffsetY;i&&i.length&&(t.filter=e.style.filter),r&&(t.shadowColor=""+o,t.shadowBlur=a||0,t.shadowOffsetX=l||0,t.shadowOffsetY=s||0)}function z(e,r,n,i,o,a,l,s){var c=arguments.length>8&&void 0!==arguments[8]&&arguments[8];Array.isArray(n)?n.forEach((function(t){e.fillStyle=N(t,r,e,s),c||(i?e.fill(i):e.fill())})):(t.isPattern(n)&&(e.fillStyle=j(n,r,e,o,a,l,s)),c||(i?e.fill(i):e.fill()))}function V(e,r,n,i,o,a,l){var s=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Array.isArray(n)?n.forEach((function(t){e.strokeStyle=N(t,r,e,l),s||e.stroke()})):(t.isPattern(n)&&(e.strokeStyle=j(n,r,e,i,o,a,l)),s||e.stroke())}var U=function(e){function t(){return s(this,t),p(this,t,arguments)}return v(t,e),u(t,[{key:"renderDownSampled",value:function(e,t,r,n){var i=n.src,o=n.imageCache;o.downSampled?e.drawImage(o.downSampled,Math.floor(n.drawRect[0]),Math.floor(n.drawRect[1]),Math.ceil(n.drawRect[2]),Math.ceil(n.drawRect[3])):this.imagePool.createDownSampledImage(i,r).then((function(e){r.renderable.dirty=!0,r.ownerDocument.defaultView.context.renderingService.dirtify()})).catch((function(){}))}},{key:"renderTile",value:function(e,t,r,n){var i=n.src,o=n.imageCache,a=n.imageRect,l=n.drawRect,s=o.size,c=e.getTransform(),u=c.a,d=c.b,h=c.c,f=c.d,p=c.e,y=c.f;if(e.resetTransform(),null!=o&&o.gridSize){for(var v=[s[0]/a[2],s[1]/a[3]],m=[o.tileSize[0]/v[0],o.tileSize[1]/v[1]],g=[Math.floor((l[0]-a[0])/m[0]),Math.ceil((l[0]+l[2]-a[0])/m[0])],b=g[0],S=g[1],w=[Math.floor((l[1]-a[1])/m[1]),Math.ceil((l[1]+l[3]-a[1])/m[1])],x=w[1],O=w[0];x>=O;O++)for(var C=b;S>=C;C++){var A=o.tiles[O][C];if(A){var k=[Math.floor(a[0]+A.tileX*m[0]),Math.floor(a[1]+A.tileY*m[1]),Math.ceil(m[0]),Math.ceil(m[1])];e.drawImage(A.data,k[0],k[1],k[2],k[3])}}e.setTransform(u,d,h,f,p,y)}else this.imagePool.createImageTiles(i,[],(function(){r.renderable.dirty=!0,r.ownerDocument.defaultView.context.renderingService.dirtify()}),r).catch((function(){}))}},{key:"render",value:function(e,n,i){var o=n.x,a=void 0===o?0:o,l=n.y,s=void 0===l?0:l,c=n.width,u=n.height,d=n.src,h=n.shadowColor,f=n.shadowBlur,p=this.imagePool.getImageSync(d,i),y=null==p?void 0:p.img,v=c,m=u;if(y){var g,S,w,x,O,A,k,M,T,E,D,j,N,F,L,I,G,W,Y,_,z,V,U,H,Q,J,q,$,K,Z,ee,te,re,ne,ie,oe,ae,le;v||(v=y.width),m||(m=y.height),X(i,e,!B(h)&&f>0);try{var se=i.ownerDocument.defaultView.getContextService().getDomElement(),ce=se.width,ue=se.height,de=e.getTransform(),he=(V=de.a,U=de.c,H=0,Q=0,J=de.b,q=de.d,$=0,K=0,Z=0,ee=0,te=1,re=0,ne=de.e,ie=de.f,oe=0,ae=1,(le=new C(16))[0]=V,le[1]=U,le[2]=H,le[3]=Q,le[4]=J,le[5]=q,le[6]=$,le[7]=K,le[8]=Z,le[9]=ee,le[10]=te,le[11]=re,le[12]=ne,le[13]=ie,le[14]=oe,le[15]=ae,le),fe=(I=[a,s,v,m],G=he,W=P(R(),[I[0],I[1],0],G),Y=P(R(),[I[0]+I[2],I[1],0],G),_=P(R(),[I[0],I[1]+I[3],0],G),z=P(R(),[I[0]+I[2],I[1]+I[3],0],G),[Math.min(W[0],Y[0],_[0],z[0]),Math.min(W[1],Y[1],_[1],z[1]),Math.max(W[0],Y[0],_[0],z[0])-Math.min(W[0],Y[0],_[0],z[0]),Math.max(W[1],Y[1],_[1],z[1])-Math.min(W[1],Y[1],_[1],z[1])]),pe=(g=fe,S=b([0,0,ce,ue],4),w=S[0],x=S[1],O=S[2],A=S[3],k=b(g,4),T=k[1],E=k[2],D=k[3],j=Math.max(w,M=k[0]),N=Math.max(x,T),F=Math.min(w+O,M+E),L=Math.min(x+A,T+D),F>j&&L>N?[j,N,F-j,L-N]:null);if(!pe)return;if(!i.ownerDocument.defaultView.getConfig().enableLargeImageOptimization)return void t.renderFull(e,n,i,{image:y,drawRect:[a,s,v,m]});if((p.downSamplingRate||.5)>fe[2]/p.size[0])return void this.renderDownSampled(e,n,i,{src:d,imageCache:p,drawRect:[a,s,v,m]});if(!r.ImagePool.isSupportTile)return void t.renderFull(e,n,i,{image:y,drawRect:[a,s,v,m]});this.renderTile(e,n,i,{src:d,imageCache:p,imageRect:fe,drawRect:pe})}catch(e){}}}},{key:"drawToContext",value:function(e,t,r,n,i){this.render(e,t.parsedStyle,t)}}],[{key:"renderFull",value:function(e,t,r,n){e.drawImage(n.image,Math.floor(n.drawRect[0]),Math.floor(n.drawRect[1]),Math.ceil(n.drawRect[2]),Math.ceil(n.drawRect[3]))}}])}(_),H=function(e){function t(){return s(this,t),p(this,t,arguments)}return v(t,e),u(t,[{key:"render",value:function(e,t,r,n,i,o){r.getBounds();var a=t.lineWidth,l=void 0===a?1:a,s=t.textAlign,c=void 0===s?"start":s,u=t.textBaseline,d=void 0===u?"alphabetic":u,h=t.lineJoin,f=void 0===h?"miter":h,p=t.miterLimit,y=void 0===p?10:p,v=t.letterSpacing,m=void 0===v?0:v,g=t.stroke,b=t.fill,S=t.fillRule,w=t.fillOpacity,x=void 0===w?1:w,O=t.strokeOpacity,C=void 0===O?1:O,A=t.opacity,k=void 0===A?1:A,M=t.metrics,T=t.x,R=void 0===T?0:T,P=t.y,E=void 0===P?0:P,D=t.dx,j=t.dy,N=t.shadowColor,F=t.shadowBlur,L=M.lines,I=M.height,G=M.lineHeight,W=M.lineMetrics;e.font=M.font,e.lineWidth=l,e.textAlign="middle"===c?"center":c;var Y=d;"alphabetic"===Y&&(Y="bottom"),e.lineJoin=f,B(y)||(e.miterLimit=y);var _=E;"middle"===d?_+=-I/2-G/2:"bottom"===d||"alphabetic"===d||"ideographic"===d?_+=-I:"top"!==d&&"hanging"!==d||(_+=-G);var z=R+(D||0);_+=j||0,1===L.length&&("bottom"===Y?(Y="middle",_-=.5*I):"top"===Y&&(Y="middle",_+=.5*I)),e.textBaseline=Y,X(r,e,!B(N)&&F>0);for(var V=0;L.length>V;V++){var U=l/2+z;_+=G,B(g)||g.isNone||!l||this.drawLetterSpacing(e,r,L[V],W[V],c,U,_,m,b,S,x,g,C,k,!0,n,i,o),B(b)||this.drawLetterSpacing(e,r,L[V],W[V],c,U,_,m,b,S,x,g,C,k,!1,n,i,o)}}},{key:"drawLetterSpacing",value:function(e,t,r,n,i,o,a,l,s,c,u,d,h,f,p,y,v,m){if(0!==l){var g=e.textAlign;e.textAlign="left";var b=o;"center"===i||"middle"===i?b=o-n.width/2:"right"!==i&&"end"!==i||(b=o-n.width);for(var S=Array.from(r),w=e.measureText(r).width,x=0,O=0;S.length>O;++O){var C=S[O];p?this.strokeText(e,t,C,b,a,d,h,y,v,m):this.fillText(e,t,C,b,a,s,c,u,f,y,v,m),b+=w-(x=e.measureText(r.substring(O+1)).width)+l,w=x}e.textAlign=g}else p?this.strokeText(e,t,r,o,a,d,h,y,v,m):this.fillText(e,t,r,o,a,s,c,u,f,y,v,m)}},{key:"fillText",value:function(e,t,r,n,i,o,a,l,s,c,u,d){var h;z(e,t,o,a,c,u,d,this.imagePool,!0);var f=!B(l)&&1!==l;f&&(h=e.globalAlpha,e.globalAlpha=l*s),e.fillText(r,n,i),f&&(e.globalAlpha=h)}},{key:"strokeText",value:function(e,t,r,n,i,o,a,l,s,c){var u;V(e,t,o,l,s,c,this.imagePool,!0);var d=!B(a)&&1!==a;d&&(u=e.globalAlpha,e.globalAlpha=a),e.strokeText(r,n,i),d&&(e.globalAlpha=u)}},{key:"drawToContext",value:function(e,t,r,n,i){this.render(e,t.parsedStyle,t,t.ownerDocument.defaultView.context,n,i)}}])}(_),Q=function(e){function r(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s(this,r),(e=p(this,r)).name="canvas-renderer",e.options=t,e}return v(r,e),u(r,[{key:"init",value:function(){var e,r=l({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new _(n),a=(o(o(o(o(o(o(o(o(o(o(e={},t.Shape.CIRCLE,i),t.Shape.ELLIPSE,i),t.Shape.RECT,i),t.Shape.IMAGE,new U(n)),t.Shape.TEXT,new H(n)),t.Shape.LINE,i),t.Shape.POLYLINE,i),t.Shape.POLYGON,i),t.Shape.PATH,i),t.Shape.GROUP,void 0),o(o(o(e,t.Shape.HTML,void 0),t.Shape.MESH,void 0),t.Shape.FRAGMENT,void 0));this.context.defaultStyleRendererFactory=a,this.context.styleRendererFactory=a,this.addRenderingPlugin(new D(r))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory}}])}(t.AbstractRendererPlugin);e.CircleRenderer=_,e.DefaultRenderer=_,e.EllipseRenderer=_,e.ImageRenderer=U,e.LineRenderer=_,e.PathRenderer=_,e.Plugin=Q,e.PolygonRenderer=_,e.PolylineRenderer=_,e.RectRenderer=_,e.TextRenderer=H}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite"),require("@antv/g-plugin-image-loader")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite","@antv/g-plugin-image-loader"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.CanvasRenderer={}),e.window.G,e.window.G.ImageLoader)}(this,(function(e,t,r){"use strict";function n(e){return n="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},n(e)}function i(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function o(e,t,r){return(t=i(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(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 l(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,i(n.key),n)}}function u(e,t,r){return t&&c(e.prototype,t),r&&c(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(h=function(){return!!e})()}function f(e,t){if(t&&("object"==n(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 p(e,t,r){return t=d(t),f(e,h()?Reflect.construct(t,r||[],d(e).constructor):t.apply(e,r))}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function v(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&&y(e,t)}function m(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 g(e,t){if(e){if("string"==typeof e)return m(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)?m(e,t):void 0}}function b(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,i,o,a,l=[],s=!0,c=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=o.call(r)).done)&&(l.push(n.value),l.length!==t);s=!0);}catch(e){c=!0,i=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return l}}(e,t)||g(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 S(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(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.")}()}function w(e,t){if(!{}.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var x=0;function O(e){return"__private_"+x+++"_"+e}var C="undefined"!=typeof Float32Array?Float32Array:Array;function A(){var e=new C(16);return C!=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 k(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 M(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],l=t[4],s=t[5],c=t[6],u=t[7],d=t[8],h=t[9],f=t[10],p=t[11],y=t[12],v=t[13],m=t[14],g=t[15],b=r[0],S=r[1],w=r[2],x=r[3];return e[0]=b*n+S*l+w*d+x*y,e[1]=b*i+S*s+w*h+x*v,e[2]=b*o+S*c+w*f+x*m,e[3]=b*a+S*u+w*p+x*g,e[4]=(b=r[4])*n+(S=r[5])*l+(w=r[6])*d+(x=r[7])*y,e[5]=b*i+S*s+w*h+x*v,e[6]=b*o+S*c+w*f+x*m,e[7]=b*a+S*u+w*p+x*g,e[8]=(b=r[8])*n+(S=r[9])*l+(w=r[10])*d+(x=r[11])*y,e[9]=b*i+S*s+w*h+x*v,e[10]=b*o+S*c+w*f+x*m,e[11]=b*a+S*u+w*p+x*g,e[12]=(b=r[12])*n+(S=r[13])*l+(w=r[14])*d+(x=r[15])*y,e[13]=b*i+S*s+w*h+x*v,e[14]=b*o+S*c+w*f+x*m,e[15]=b*a+S*u+w*p+x*g,e}function T(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 R(){var e=new C(3);return C!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function P(e,t,r){var n=t[0],i=t[1],o=t[2],a=r[3]*n+r[7]*i+r[11]*o+r[15];return e[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/(a=a||1),e[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/a,e[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/a,e}function B(e){return null==e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),R();var E=O("renderState"),D=function(){function e(t){s(this,e),this.removedRBushNodeAABBs=[],this.renderQueue=[],Object.defineProperty(this,E,{writable:!0,value:{restoreStack:[],prevObject:null,currentContext:new Map}}),this.clearFullScreenLastFrame=!1,this.clearFullScreen=!1,this.vpMatrix=A(),this.dprMatrix=A(),this.tmpMat4=A(),this.vec3a=R(),this.vec3b=R(),this.vec3c=R(),this.vec3d=R(),this.canvasRendererPluginOptions=t}return u(e,[{key:"apply",value:function(r,n){var i=this;this.context=r;var o=this.context,a=o.config,l=o.camera,s=o.renderingService,c=o.renderingContext,u=o.rBushRoot,d=o.pathGeneratorFactory,h=a.renderer.getConfig().enableRenderingOptimization;a.renderer.getConfig().enableDirtyCheck=!1,a.renderer.getConfig().enableDirtyRectangleRendering=!1,this.rBush=u,this.pathGeneratorFactory=d;var f=r.contextService,p=c.root.ownerDocument.defaultView,y=function(e){var t=e.target.rBushNode;t.aabb&&i.removedRBushNodeAABBs.push(t.aabb)},v=function(e){var t=e.target.rBushNode;t.aabb&&i.removedRBushNodeAABBs.push(t.aabb)};s.hooks.init.tap(e.tag,(function(){p.addEventListener(t.ElementEvent.UNMOUNTED,y),p.addEventListener(t.ElementEvent.CULLED,v);var e=f.getDPR(),r=a.width,n=a.height,o=f.getContext();i.clearRect(o,0,0,r*e,n*e,a.background)})),s.hooks.destroy.tap(e.tag,(function(){p.removeEventListener(t.ElementEvent.UNMOUNTED,y),p.removeEventListener(t.ElementEvent.CULLED,v),i.renderQueue=[],i.removedRBushNodeAABBs=[],w(i,E)[E]={restoreStack:[],prevObject:null,currentContext:null}})),s.hooks.beginFrame.tap(e.tag,(function(){var e,t=f.getContext(),r=f.getDPR(),n=a.width,o=a.height,l=i.canvasRendererPluginOptions,c=l.dirtyObjectNumThreshold,u=l.dirtyObjectRatioThreshold,d=s.getStats(),h=d.rendered,y=h/d.total;i.clearFullScreen=i.clearFullScreenLastFrame||!(null!==(e=p.context.renderingPlugins[1])&&void 0!==e&&e.isFirstTimeRenderingFinished)||s.disableDirtyRectangleRendering()||h>c&&y>u,t&&("function"==typeof t.resetTransform?t.resetTransform():t.setTransform(1,0,0,1,0,0),i.clearFullScreen&&i.clearRect(t,0,0,n*r,o*r,a.background))}));var m=function(e,t){for(var r=[e];r.length>0;){var o=r.pop();o.isVisible()&&!o.isCulled()&&(h?i.renderDisplayObjectOptimized(o,t,i.context,w(i,E)[E],n):i.renderDisplayObject(o,t,i.context,w(i,E)[E],n));for(var a=o.sortable.sorted||o.childNodes,l=a.length-1;l>=0;l--)r.push(a[l])}};s.hooks.endFrame.tap(e.tag,(function(){if(0!==c.root.childNodes.length){h=a.renderer.getConfig().enableRenderingOptimization,w(i,E)[E]={restoreStack:[],prevObject:null,currentContext:w(i,E)[E].currentContext},w(i,E)[E].currentContext.clear(),i.clearFullScreenLastFrame=!1;var e,r,o=f.getContext(),s=f.getDPR();if((e=i.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,M(i.vpMatrix,i.dprMatrix,l.getOrthoMatrix()),i.clearFullScreen)h?(o.save(),m(c.root,o),o.restore()):m(c.root,o),i.removedRBushNodeAABBs=[];else{var u=i.safeMergeAABB.apply(i,[i.mergeDirtyAABBs(i.renderQueue)].concat(S(i.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,i=e.maxX,o=e.maxY,a=new t.AABB;return a.setMinMax([r,n,0],[i,o,0]),a})))));if(i.removedRBushNodeAABBs=[],t.AABB.isEmpty(u))return void(i.renderQueue=[]);var d=i.convertAABB2Rect(u),y=d.x,v=d.y,g=d.width,b=d.height,x=P(i.vec3a,[y,v,0],i.vpMatrix),O=P(i.vec3b,[y+g,v,0],i.vpMatrix),C=P(i.vec3c,[y,v+b,0],i.vpMatrix),A=P(i.vec3d,[y+g,v+b,0],i.vpMatrix),k=Math.min(x[0],O[0],A[0],C[0]),T=Math.min(x[1],O[1],A[1],C[1]),R=Math.max(x[0],O[0],A[0],C[0]),B=Math.max(x[1],O[1],A[1],C[1]),D=Math.floor(k),j=Math.floor(T),N=Math.ceil(R-k),F=Math.ceil(B-T);o.save(),i.clearRect(o,D,j,N,F,a.background),o.beginPath(),o.rect(D,j,N,F),o.clip(),o.setTransform(i.vpMatrix[0],i.vpMatrix[1],i.vpMatrix[4],i.vpMatrix[5],i.vpMatrix[12],i.vpMatrix[13]),a.renderer.getConfig().enableDirtyRectangleRenderingDebug&&p.dispatchEvent(new t.CustomEvent(t.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:{x:D,y:j,width:N,height:F}})),i.searchDirtyObjects(u).sort((function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder})).forEach((function(e){e&&e.isVisible()&&!e.isCulled()&&i.renderDisplayObject(e,o,i.context,w(i,E)[E],n)})),o.restore(),i.renderQueue.forEach((function(e){i.saveDirtyAABB(e)})),i.renderQueue=[]}w(i,E)[E].restoreStack.forEach((function(){o.restore()})),w(i,E)[E].restoreStack=[]}else i.clearFullScreenLastFrame=!0})),s.hooks.render.tap(e.tag,(function(e){i.clearFullScreen||i.renderQueue.push(e)}))}},{key:"clearRect",value:function(e,t,r,n,i,o){e.clearRect(t,r,n,i),o&&(e.fillStyle=o,e.fillRect(t,r,n,i))}},{key:"renderDisplayObjectOptimized",value:function(e,r,n,i,o){var a=e.nodeName,l=!1,s=this.context.styleRendererFactory[a],c=this.pathGeneratorFactory[a],u=e.parsedStyle.clipPath;if(u){(!i.prevObject||!T(u.getWorldTransform(),i.prevObject.getWorldTransform()))&&(this.applyWorldTransform(r,u),i.prevObject=null);var d=this.pathGeneratorFactory[u.nodeName];d&&(r.save(),l=!0,r.beginPath(),d(r,u.parsedStyle),r.closePath(),r.clip())}if(s){(!i.prevObject||!T(e.getWorldTransform(),i.prevObject.getWorldTransform()))&&this.applyWorldTransform(r,e);var h=!i.prevObject;if(!h){var f=i.prevObject.nodeName;h=a===t.Shape.TEXT?f!==t.Shape.TEXT:a===t.Shape.IMAGE?f!==t.Shape.IMAGE:f===t.Shape.TEXT||f===t.Shape.IMAGE}s.applyStyleToContext(r,e,h,i),i.prevObject=e}c&&(r.beginPath(),c(r,e.parsedStyle),a!==t.Shape.LINE&&a!==t.Shape.PATH&&a!==t.Shape.POLYLINE&&r.closePath()),s&&s.drawToContext(r,e,w(this,E)[E],this,o),l&&r.restore(),e.renderable.dirty=!1}},{key:"renderDisplayObject",value:function(e,r,n,i,o){var a=e.nodeName,l=i.restoreStack[i.restoreStack.length-1];!l||e.compareDocumentPosition(l)&t.Node.DOCUMENT_POSITION_CONTAINS||(r.restore(),i.restoreStack.pop());var s=this.context.styleRendererFactory[a],c=this.pathGeneratorFactory[a],u=e.parsedStyle.clipPath;if(u){this.applyWorldTransform(r,u);var d=this.pathGeneratorFactory[u.nodeName];d&&(r.save(),i.restoreStack.push(e),r.beginPath(),d(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),a!==t.Shape.LINE&&a!==t.Shape.PATH&&a!==t.Shape.POLYLINE&&r.closePath()),s&&(s.render(r,e.parsedStyle,e,n,this,o),r.restore()),e.renderable.dirty=!1}},{key:"applyAttributesToContext",value:function(e,t){var r=t.parsedStyle,n=r.stroke,i=r.fill,o=r.opacity,a=r.lineDash,l=r.lineDashOffset;a&&e.setLineDash(a),B(l)||(e.lineDashOffset=l),B(o)||(e.globalAlpha*=o),B(n)||Array.isArray(n)||n.isNone||(e.strokeStyle=t.attributes.stroke),B(i)||Array.isArray(i)||i.isNone||(e.fillStyle=t.attributes.fill)}},{key:"convertAABB2Rect",value:function(e){var t=e.getMin(),r=e.getMax(),n=Math.floor(t[0]),i=Math.floor(t[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}}},{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=b(e.getMin(),2),r=t[0],n=t[1],i=b(e.getMax(),2);return this.rBush.search({minX:r,minY:n,maxX:i[0],maxY:i[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?(k(this.tmpMat4,t.getLocalTransform()),M(this.tmpMat4,r,this.tmpMat4),M(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(k(this.tmpMat4,t.getWorldTransform()),M(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),i=0;r>i;i++)n[i]=arguments[i];return n.forEach((function(t){e.add(t)})),e}}])}();function j(e,t,r,n,i,o,a){var l,s;if("rect"===e.image.nodeName){var c=e.image.parsedStyle,u=c.width,d=c.height;s=n.contextService.getDPR();var h=n.config.offscreenCanvas;(l=o.offscreenCanvasCreator.getOrCreateCanvas(h)).width=u*s,l.height=d*s;var f=o.offscreenCanvasCreator.getOrCreateContext(h),p={restoreStack:[],prevObject:null,currentContext:new Map};e.image.forEach((function(e){i.renderDisplayObject(e,f,n,p,o)})),p.restoreStack.forEach((function(){f.restore()}))}return a.getOrCreatePatternSync(t,e,r,l,s,t.getGeometryBounds().min,(function(){t.renderable.dirty=!0,n.renderingService.dirtify()}))}function N(e,r,n,i){var o;if(e.type===t.GradientType.LinearGradient||e.type===t.GradientType.RadialGradient){var a=r.getGeometryBounds(),s=a&&2*a.halfExtents[0]||1,c=a&&2*a.halfExtents[1]||1,u=a&&a.min||[0,0];o=i.getOrCreateGradient(l(l({type:e.type},e.value),{},{min:u,width:s,height:c}),n)}return o}D.tag="CanvasRenderer";var F=["shadowBlur","shadowOffsetX","shadowOffsetY"],L=["lineCap","lineJoin","miterLimit"],I={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},G={};function W(e,t,r,n){var i=n.has(t)?n.get(t):I[t];return i!==r&&("lineDash"===t?e.setLineDash(r):e[t]=r,n.set(t,r)),i}var Y=function(){return u((function e(t){s(this,e),this.imagePool=t}),[{key:"applyAttributesToContext",value:function(e,t){}},{key:"render",value:function(e,t,r,n,i,o){}},{key:"applyCommonStyleToContext",value:function(e,t,r,n){var i=r?G:n.prevObject.parsedStyle,o=t.parsedStyle;(r||o.opacity!==i.opacity)&&W(e,"globalAlpha",B(o.opacity)?I.globalAlpha:o.opacity,n.currentContext),(r||o.blend!==i.blend)&&W(e,"globalCompositeOperation",B(o.blend)?I.globalCompositeOperation:o.blend,n.currentContext)}},{key:"applyStrokeFillStyleToContext",value:function(e,t,r,n){var i=r?G:n.prevObject.parsedStyle,o=t.parsedStyle,a=o.lineWidth,l=o.fill&&!o.fill.isNone;if(o.stroke&&!o.stroke.isNone&&(void 0===a?I.lineWidth:a)>0){if(r||t.attributes.stroke!==n.prevObject.attributes.stroke)W(e,"strokeStyle",B(o.stroke)||Array.isArray(o.stroke)||o.stroke.isNone?I.strokeStyle:t.attributes.stroke,n.currentContext);(r||o.lineWidth!==i.lineWidth)&&W(e,"lineWidth",B(o.lineWidth)?I.lineWidth:o.lineWidth,n.currentContext),(r||o.lineDash!==i.lineDash)&&W(e,"lineDash",o.lineDash||I.lineDash,n.currentContext),(r||o.lineDashOffset!==i.lineDashOffset)&&W(e,"lineDashOffset",B(o.lineDashOffset)?I.lineDashOffset:o.lineDashOffset,n.currentContext);for(var s=0;L.length>s;s++){var c=L[s];(r||o[c]!==i[c])&&W(e,c,B(o[c])?I[c]:o[c],n.currentContext)}}l&&(r||t.attributes.fill!==n.prevObject.attributes.fill)&&W(e,"fillStyle",B(o.fill)||Array.isArray(o.fill)||o.fill.isNone?I.fillStyle:t.attributes.fill,n.currentContext)}},{key:"applyStyleToContext",value:function(e,r,n,i){var o=r.nodeName;this.applyCommonStyleToContext(e,r,n,i),o===t.Shape.IMAGE||this.applyStrokeFillStyleToContext(e,r,n,i)}},{key:"applyShadowAndFilterStyleToContext",value:function(e,t,r,n){var i=t.parsedStyle;if(r){W(e,"shadowColor",""+i.shadowColor,n.currentContext);for(var o=0;F.length>o;o++){var a=F[o];W(e,a,i[a]||I[a],n.currentContext)}}i.filter&&i.filter.length&&W(e,"filter",t.attributes.filter,n.currentContext)}},{key:"clearShadowAndFilterStyleForContext",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(t){W(e,"shadowColor",I.shadowColor,n.currentContext);for(var o=0;F.length>o;o++){var a=F[o];W(e,a,I[a],n.currentContext)}}if(r)if(t&&i){var l=e.filter;!B(l)&&l.indexOf("drop-shadow")>-1&&W(e,"filter",l.replace(/drop-shadow\([^)]*\)/,"").trim()||I.filter,n.currentContext)}else W(e,"filter",I.filter,n.currentContext)}},{key:"fillToContext",value:function(e,r,n,i,o){var a=this,l=r.parsedStyle,s=l.fill,c=l.fillRule,u=null;if(Array.isArray(s)&&s.length>0)s.forEach((function(t){var i=W(e,"fillStyle",N(t,r,e,a.imagePool),n.currentContext);u=null!=u?u:i,c?e.fill(c):e.fill()}));else{if(t.isPattern(s)){var d=j(s,r,e,r.ownerDocument.defaultView.context,i,o,this.imagePool);d&&(e.fillStyle=d,u=!0)}c?e.fill(c):e.fill()}null!==u&&W(e,"fillStyle",u,n.currentContext)}},{key:"strokeToContext",value:function(e,r,n,i,o){var a=this,l=r.parsedStyle.stroke,s=null;if(Array.isArray(l)&&l.length>0)l.forEach((function(t){var i=W(e,"strokeStyle",N(t,r,e,a.imagePool),n.currentContext);s=null!=s?s:i,e.stroke()}));else{if(t.isPattern(l)){var c=j(l,r,e,r.ownerDocument.defaultView.context,i,o,this.imagePool);if(c){var u=W(e,"strokeStyle",c,n.currentContext);s=null!=s?s:u}}e.stroke()}null!==s&&W(e,"strokeStyle",s,n.currentContext)}},{key:"drawToContext",value:function(e,r,n,i,o){var a,l=r.nodeName,s=r.parsedStyle,c=s.opacity,u=void 0===c?I.globalAlpha:c,d=s.fillOpacity,h=void 0===d?I.fillOpacity:d,f=s.strokeOpacity,p=void 0===f?I.strokeOpacity:f,y=s.lineWidth,v=s.fill&&!s.fill.isNone,m=s.stroke&&!s.stroke.isNone&&(void 0===y?I.lineWidth:y)>0;if(v||m){var g=!B(s.shadowColor)&&s.shadowBlur>0,b="inner"===s.shadowType,S=0===(null===(a=s.fill)||void 0===a?void 0:a.alpha),w=!(!s.filter||!s.filter.length),x=g&&m&&(l===t.Shape.PATH||l===t.Shape.LINE||l===t.Shape.POLYLINE||S||b),O=null;if(v)x||this.applyShadowAndFilterStyleToContext(e,r,g,n),O=W(e,"globalAlpha",u*h,n.currentContext),this.fillToContext(e,r,n,i,o),x||this.clearShadowAndFilterStyleForContext(e,g,w,n);if(m){var C=!1,A=W(e,"globalAlpha",u*p,n.currentContext);if(O=v?O:A,x&&(this.applyShadowAndFilterStyleToContext(e,r,g,n),C=!0,b)){var k=e.globalCompositeOperation;e.globalCompositeOperation="source-atop",this.strokeToContext(e,r,n,i,o),e.globalCompositeOperation=k,this.clearShadowAndFilterStyleForContext(e,g,w,n,!0)}this.strokeToContext(e,r,n,i,o),C&&this.clearShadowAndFilterStyleForContext(e,g,w,n)}null!==O&&W(e,"globalAlpha",O,n.currentContext)}}}])}(),_=function(e){function r(){return s(this,r),p(this,r,arguments)}return v(r,e),u(r,[{key:"render",value:function(e,r,n,i,o,a){var l=r.fill,s=r.fillRule,c=r.opacity,u=void 0===c?1:c,d=r.fillOpacity,h=void 0===d?1:d,f=r.stroke,p=r.strokeOpacity,y=void 0===p?1:p,v=r.lineWidth,m=void 0===v?1:v,g=r.lineCap,b=r.lineJoin,S=r.shadowType,w=r.shadowBlur,x=r.filter,O=r.miterLimit,C=l&&!l.isNone,A=f&&!f.isNone&&m>0,k=0===(null==l?void 0:l.alpha),M=!(!x||!x.length),T=!B(r.shadowColor)&&w>0,R=n.nodeName,P="inner"===S,E=A&&T&&(R===t.Shape.PATH||R===t.Shape.LINE||R===t.Shape.POLYLINE||k||P);C&&(e.globalAlpha=u*h,E||X(n,e,T),z(e,n,l,s,i,o,a,this.imagePool),E||this.clearShadowAndFilter(e,M,T)),A&&(e.globalAlpha=u*y,e.lineWidth=m,B(O)||(e.miterLimit=O),B(g)||(e.lineCap=g),B(b)||(e.lineJoin=b),E&&(P&&(e.globalCompositeOperation="source-atop"),X(n,e,!0),P&&(V(e,n,f,i,o,a,this.imagePool),e.globalCompositeOperation=I.globalCompositeOperation,this.clearShadowAndFilter(e,M,!0))),V(e,n,f,i,o,a,this.imagePool))}},{key:"clearShadowAndFilter",value:function(e,t,r){if(r&&(e.shadowColor="transparent",e.shadowBlur=0),t){var n=e.filter;!B(n)&&n.indexOf("drop-shadow")>-1&&(e.filter=n.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}}}])}(Y);function X(e,t,r){var n=e.parsedStyle,i=n.filter,o=n.shadowColor,a=n.shadowBlur,l=n.shadowOffsetX,s=n.shadowOffsetY;i&&i.length&&(t.filter=e.style.filter),r&&(t.shadowColor=""+o,t.shadowBlur=a||0,t.shadowOffsetX=l||0,t.shadowOffsetY=s||0)}function z(e,r,n,i,o,a,l,s){var c=arguments.length>8&&void 0!==arguments[8]&&arguments[8];Array.isArray(n)?n.forEach((function(t){e.fillStyle=N(t,r,e,s),c||(i?e.fill(i):e.fill())})):(t.isPattern(n)&&(e.fillStyle=j(n,r,e,o,a,l,s)),c||(i?e.fill(i):e.fill()))}function V(e,r,n,i,o,a,l){var s=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Array.isArray(n)?n.forEach((function(t){e.strokeStyle=N(t,r,e,l),s||e.stroke()})):(t.isPattern(n)&&(e.strokeStyle=j(n,r,e,i,o,a,l)),s||e.stroke())}var U=function(e){function t(){return s(this,t),p(this,t,arguments)}return v(t,e),u(t,[{key:"renderDownSampled",value:function(e,t,r,n){var i=n.src,o=n.imageCache;o.downSampled?e.drawImage(o.downSampled,Math.floor(n.drawRect[0]),Math.floor(n.drawRect[1]),Math.ceil(n.drawRect[2]),Math.ceil(n.drawRect[3])):this.imagePool.createDownSampledImage(i,r).then((function(e){r.renderable.dirty=!0,r.ownerDocument.defaultView.context.renderingService.dirtify()})).catch((function(){}))}},{key:"renderTile",value:function(e,t,r,n){var i=n.src,o=n.imageCache,a=n.imageRect,l=n.drawRect,s=o.size,c=e.getTransform(),u=c.a,d=c.b,h=c.c,f=c.d,p=c.e,y=c.f;if(e.resetTransform(),null!=o&&o.gridSize){for(var v=[s[0]/a[2],s[1]/a[3]],m=[o.tileSize[0]/v[0],o.tileSize[1]/v[1]],g=[Math.floor((l[0]-a[0])/m[0]),Math.ceil((l[0]+l[2]-a[0])/m[0])],b=g[0],S=g[1],w=[Math.floor((l[1]-a[1])/m[1]),Math.ceil((l[1]+l[3]-a[1])/m[1])],x=w[1],O=w[0];x>=O;O++)for(var C=b;S>=C;C++){var A=o.tiles[O][C];if(A){var k=[Math.floor(a[0]+A.tileX*m[0]),Math.floor(a[1]+A.tileY*m[1]),Math.ceil(m[0]),Math.ceil(m[1])];e.drawImage(A.data,k[0],k[1],k[2],k[3])}}e.setTransform(u,d,h,f,p,y)}else this.imagePool.createImageTiles(i,[],(function(){r.renderable.dirty=!0,r.ownerDocument.defaultView.context.renderingService.dirtify()}),r).catch((function(){}))}},{key:"render",value:function(e,n,i){var o=n.x,a=void 0===o?0:o,l=n.y,s=void 0===l?0:l,c=n.width,u=n.height,d=n.src,h=n.shadowColor,f=n.shadowBlur,p=this.imagePool.getImageSync(d,i),y=null==p?void 0:p.img,v=c,m=u;if(y){var g,S,w,x,O,A,k,M,T,E,D,j,N,F,L,I,G,W,Y,_,z,V,U,H,Q,J,q,$,K,Z,ee,te,re,ne,ie,oe,ae,le;v||(v=y.width),m||(m=y.height),X(i,e,!B(h)&&f>0);try{var se=i.ownerDocument.defaultView.getContextService().getDomElement(),ce=se.width,ue=se.height,de=e.getTransform(),he=(V=de.a,U=de.c,H=0,Q=0,J=de.b,q=de.d,$=0,K=0,Z=0,ee=0,te=1,re=0,ne=de.e,ie=de.f,oe=0,ae=1,(le=new C(16))[0]=V,le[1]=U,le[2]=H,le[3]=Q,le[4]=J,le[5]=q,le[6]=$,le[7]=K,le[8]=Z,le[9]=ee,le[10]=te,le[11]=re,le[12]=ne,le[13]=ie,le[14]=oe,le[15]=ae,le),fe=(I=[a,s,v,m],G=he,W=P(R(),[I[0],I[1],0],G),Y=P(R(),[I[0]+I[2],I[1],0],G),_=P(R(),[I[0],I[1]+I[3],0],G),z=P(R(),[I[0]+I[2],I[1]+I[3],0],G),[Math.min(W[0],Y[0],_[0],z[0]),Math.min(W[1],Y[1],_[1],z[1]),Math.max(W[0],Y[0],_[0],z[0])-Math.min(W[0],Y[0],_[0],z[0]),Math.max(W[1],Y[1],_[1],z[1])-Math.min(W[1],Y[1],_[1],z[1])]),pe=(g=fe,S=b([0,0,ce,ue],4),w=S[0],x=S[1],O=S[2],A=S[3],k=b(g,4),T=k[1],E=k[2],D=k[3],j=Math.max(w,M=k[0]),N=Math.max(x,T),F=Math.min(w+O,M+E),L=Math.min(x+A,T+D),F>j&&L>N?[j,N,F-j,L-N]:null);if(!pe)return;if(!i.ownerDocument.defaultView.getConfig().enableLargeImageOptimization)return void t.renderFull(e,n,i,{image:y,drawRect:[a,s,v,m]});if((p.downSamplingRate||.5)>fe[2]/p.size[0])return void this.renderDownSampled(e,n,i,{src:d,imageCache:p,drawRect:[a,s,v,m]});if(!r.ImagePool.isSupportTile)return void t.renderFull(e,n,i,{image:y,drawRect:[a,s,v,m]});this.renderTile(e,n,i,{src:d,imageCache:p,imageRect:fe,drawRect:pe})}catch(e){}}}},{key:"drawToContext",value:function(e,t,r,n,i){this.render(e,t.parsedStyle,t)}}],[{key:"renderFull",value:function(e,t,r,n){e.drawImage(n.image,Math.floor(n.drawRect[0]),Math.floor(n.drawRect[1]),Math.ceil(n.drawRect[2]),Math.ceil(n.drawRect[3]))}}])}(_),H=function(e){function t(){return s(this,t),p(this,t,arguments)}return v(t,e),u(t,[{key:"render",value:function(e,t,r,n,i,o){r.getBounds();var a=t.lineWidth,l=void 0===a?1:a,s=t.textAlign,c=void 0===s?"start":s,u=t.textBaseline,d=void 0===u?"alphabetic":u,h=t.lineJoin,f=void 0===h?"miter":h,p=t.miterLimit,y=void 0===p?10:p,v=t.letterSpacing,m=void 0===v?0:v,g=t.stroke,b=t.fill,S=t.fillRule,w=t.fillOpacity,x=void 0===w?1:w,O=t.strokeOpacity,C=void 0===O?1:O,A=t.opacity,k=void 0===A?1:A,M=t.metrics,T=t.x,R=void 0===T?0:T,P=t.y,E=void 0===P?0:P,D=t.dx,j=t.dy,N=t.shadowColor,F=t.shadowBlur,L=M.lines,I=M.height,G=M.lineHeight,W=M.lineMetrics;e.font=M.font,e.lineWidth=l,e.textAlign="middle"===c?"center":c;var Y=d;"alphabetic"===Y&&(Y="bottom"),e.lineJoin=f,B(y)||(e.miterLimit=y);var _=E;"middle"===d?_+=-I/2-G/2:"bottom"===d||"alphabetic"===d||"ideographic"===d?_+=-I:"top"!==d&&"hanging"!==d||(_+=-G);var z=R+(D||0);_+=j||0,1===L.length&&("bottom"===Y?(Y="middle",_-=.5*I):"top"===Y&&(Y="middle",_+=.5*I)),e.textBaseline=Y,X(r,e,!B(N)&&F>0);for(var V=0;L.length>V;V++){var U=l/2+z;_+=G,B(g)||g.isNone||!l||this.drawLetterSpacing(e,r,L[V],W[V],c,U,_,m,b,S,x,g,C,k,!0,n,i,o),B(b)||this.drawLetterSpacing(e,r,L[V],W[V],c,U,_,m,b,S,x,g,C,k,!1,n,i,o)}}},{key:"drawLetterSpacing",value:function(e,t,r,n,i,o,a,l,s,c,u,d,h,f,p,y,v,m){if(0!==l){var g=e.textAlign;e.textAlign="left";var b=o;"center"===i||"middle"===i?b=o-n.width/2:"right"!==i&&"end"!==i||(b=o-n.width);for(var S=Array.from(r),w=e.measureText(r).width,x=0,O=0;S.length>O;++O){var C=S[O];p?this.strokeText(e,t,C,b,a,d,h,y,v,m):this.fillText(e,t,C,b,a,s,c,u,f,y,v,m),b+=w-(x=e.measureText(r.substring(O+1)).width)+l,w=x}e.textAlign=g}else p?this.strokeText(e,t,r,o,a,d,h,y,v,m):this.fillText(e,t,r,o,a,s,c,u,f,y,v,m)}},{key:"fillText",value:function(e,t,r,n,i,o,a,l,s,c,u,d){var h;z(e,t,o,a,c,u,d,this.imagePool,!0);var f=!B(l)&&1!==l;f&&(h=e.globalAlpha,e.globalAlpha=l*s),e.fillText(r,n,i),f&&(e.globalAlpha=h)}},{key:"strokeText",value:function(e,t,r,n,i,o,a,l,s,c){var u;V(e,t,o,l,s,c,this.imagePool,!0);var d=!B(a)&&1!==a;d&&(u=e.globalAlpha,e.globalAlpha=a),e.strokeText(r,n,i),d&&(e.globalAlpha=u)}},{key:"drawToContext",value:function(e,t,r,n,i){this.render(e,t.parsedStyle,t,t.ownerDocument.defaultView.context,n,i)}}])}(_),Q=function(e){function r(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s(this,r),(e=p(this,r)).name="canvas-renderer",e.options=t,e}return v(r,e),u(r,[{key:"init",value:function(){var e,r=l({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new _(n),a=(o(o(o(o(o(o(o(o(o(o(e={},t.Shape.CIRCLE,i),t.Shape.ELLIPSE,i),t.Shape.RECT,i),t.Shape.IMAGE,new U(n)),t.Shape.TEXT,new H(n)),t.Shape.LINE,i),t.Shape.POLYLINE,i),t.Shape.POLYGON,i),t.Shape.PATH,i),t.Shape.GROUP,void 0),o(o(o(e,t.Shape.HTML,void 0),t.Shape.MESH,void 0),t.Shape.FRAGMENT,void 0));this.context.defaultStyleRendererFactory=a,this.context.styleRendererFactory=a,this.addRenderingPlugin(new D(r))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory}}])}(t.AbstractRendererPlugin);e.CircleRenderer=_,e.DefaultRenderer=_,e.EllipseRenderer=_,e.ImageRenderer=U,e.LineRenderer=_,e.PathRenderer=_,e.Plugin=Q,e.PolygonRenderer=_,e.PolylineRenderer=_,e.RectRenderer=_,e.TextRenderer=H}));
//# sourceMappingURL=index.umd.min.js.map
{
"name": "@antv/g-plugin-canvas-renderer",
"version": "2.2.16",
"version": "2.2.17",
"description": "A G plugin of renderer implementation with Canvas2D API",

@@ -40,6 +40,6 @@ "keywords": [

"tslib": "^2.5.3",
"@antv/g-lite": "2.2.14",
"@antv/g-lite": "2.2.15",
"@antv/g-math": "3.0.0",
"@antv/g-plugin-canvas-path-generator": "2.1.14",
"@antv/g-plugin-image-loader": "2.1.16"
"@antv/g-plugin-image-loader": "2.1.17",
"@antv/g-plugin-canvas-path-generator": "2.1.15"
},

@@ -46,0 +46,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc