varVi=!a.canvasSupported,Bi={},Fi={};varGi=function(){functiont(t,e,n){vari=this;this._sleepAfterStill=10,this._stillFrameAccum=0,this._needsRefresh=!0,this._needsRefreshHover=!0,this._darkMode=!1,n=n||{},this.dom=e,this.id=t;varr=newSe,o=n.renderer||"canvas";if(Vi)thrownewError("IE8 support has been dropped since 5.0");if(Bi[o]||(o=E(Bi)[0]),!Bi[o])thrownewError("Renderer '"+o+"' is not imported. Please import it first.");n.useDirtyRect=null!=n.useDirtyRect&&n.useDirtyRect;vars=newBi[o](e,r,n,t);this.storage=r,this.painter=s;varl=a.node||a.worker?null:newNn(s.getViewportRoot(),s.root);this.handler=newce(r,s,l,s.root),this.animation=newmn({stage:{update:function(){returni._flush(!0)}}}),this.animation.start()}returnt.prototype.add=function(t){t&&(this.storage.addRoot(t),t.addSelfToZr(this),this.refresh())},t.prototype.remove=function(t){t&&(this.storage.delRoot(t),t.removeSelfFromZr(this),this.refresh())},t.prototype.configLayer=function(t,e){this.painter.configLayer&&this.painter.configLayer(t,e),this.refresh()},t.prototype.setBackgroundColor=function(t){this.painter.setBackgroundColor&&this.painter.setBackgroundColor(t),this.refresh(),this._backgroundColor=t,this._darkMode=function(t){if(!t)return!1;if("string"==typeoft)returnQe(t,1)<.4;if(t.colorStops){for(vare=t.colorStops,n=0,i=e.length,r=0;r<i;r++)n+=Qe(e[r].color,1);return(n/=i)<.4}return!1}(t)},t.prototype.getBackgroundColor=function(){returnthis._backgroundColor},t.prototype.setDarkMode=function(t){this._darkMode=t},t.prototype.isDarkMode=function(){returnthis._darkMode},t.prototype.refreshImmediately=function(t){t||this.animation.update(!0),this._needsRefresh=!1,this.painter.refresh(),this._needsRefresh=!1},t.prototype.refresh=function(){this._needsRefresh=!0,this.animation.start()},t.prototype.flush=function(){this._flush(!1)},t.prototype._flush=function(t){vare,n=(newDate).getTime();this._needsRefresh&&(e=!0,this.refreshImmediately(t)),this._needsRefreshHover&&(e=!0,this.refreshHoverImmediately());vari=(newDate).getTime();e?(this._stillFrameAccum=0,this.trigger("rendered",{elapsedTime:i-n})):this._sleepAfterStill>0&&(this._stillFrameAccum++,this._stillFrameAccum>this._sleepAfterStill&&this.animation.stop())},t.prototype.setSleepAfterStill=function(t){this._sleepAfterStill=t},t.prototype.wakeUp=function(){this.animation.start(),this._stillFrameAccum=0},t.prototype.addHover=function(t){},t.prototype.removeHover=function(t){},t.prototype.clearHover=function(){},t.prototype.refreshHover=function(){this._needsRefreshHover=!0},t.prototype.refreshHoverImmediately=function(){this._needsRefreshHover=!1,this.painter.refreshHover&&"canvas"===this.painter.getType()&&this.painter.refreshHover()},t.prototype.resize=function(t){t=t||{},this.painter.resize(t.width,t.height),this.handler.resize()},t.prototype.clearAnimation=function(){this.animation.clear()},t.prototype.getWidth=function(){returnthis.painter.getWidth()},t.prototype.getHeight=function(){returnthis.painter.getHeight()},t.prototype.pathToImage=function(t,e){if(this.painter.pathToImage)returnthis.painter.pathToImage(t,e)},t.prototype.setCursorStyle=function(t){this.handler.setCursorStyle(t)},t.prototype.findHover=function(t,e){returnthis.handler.findHover(t,e)},t.prototype.on=function(t,e,n){returnthis.handler.on(t,e,n),this},t.prototype.off=function(t,e){this.handler.off(t,e)},t.prototype.trigger=function(t,e){this.handler.trigger(t,e)},t.prototype.clear=function(){for(vart=this.storage.getRoots(),e=0;e<t.length;e++)t[e]instanceofEi&&t[e].removeSelfFromZr(this);this.storage.delAllRoots(),this.painter.clear()},t.prototype.dispose=function(){vart;this.animation.stop(),this.clear(),this.storage.dispose(),this.painter.dispose(),this.handler.dispose(),this.animation=this.storage=this.painter=this.handler=null,t=this.id,deleteFi[t]},t}();functionHi(t,e){varn=newGi(x(),t,e);returnFi[n.id]=n,n}functionWi(t,e){Bi[t]=e}varUi=Object.freeze({__proto__:null,init:Hi,dispose:function(t){t.dispose()},disposeAll:function(){for(vartinFi)Fi.hasOwnProperty(t)&&Fi[t].dispose();Fi={}},get