leafer-ui 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +179 -1
- package/dist/web.cjs +20 -67
- package/dist/web.esm.js +20 -67
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +140 -420
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +140 -418
- package/dist/web.module.min.js +1 -1
- package/package.json +11 -11
package/dist/web.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),i=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class s extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(n.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:n}=this.view;n.width=t+"px",n.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const e=t.Platform.devicePixelRatio;if(this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const i=this.view,{x:n,y:s,width:o,height:r}=this.autoBounds.getBoundsFrom(e),a={width:o,height:r,pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,i))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:o,fileType:r}=t.FileHelper;function a(e,i){t.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(o(e),i),canvasToBolb:(t,e,i)=>new Promise((n=>t.toBlob(n,o(e),i))),canvasSaveAs:(e,i,n)=>{const s=e.toDataURL(o(r(i)),n);return t.Platform.origin.download(s,i)},download:(t,e)=>new Promise((i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()})),loadImage:e=>new Promise(((i,n)=>{const s=new Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)}))},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new s(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:h}=navigator;h.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):h.indexOf("Safari")>-1&&-1===h.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),h.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):h.indexOf("Mac")>-1?t.Platform.os="Mac":h.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateAllWorldOpacity:u}=t.LeafHelper,{pushAllChildBranch:p,pushAllParent:f}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper,_={x:0,y:0,width:1e5,height:1e5};class w{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,g)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(_):this.afterBounds.setListWithFn(t,g),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:v,updateAllChange:m}=t.LeafHelper,y=t.Debug.get("Layouter");class x{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:o,LAYOUT:r,AFTER:a}=t.LayoutEvent,h=this.getBlocks(s);h.forEach((t=>t.setBefore())),n.emitEvent(new t.LayoutEvent(o,h,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&p(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||c(n[t])}c(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&u(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&h.push(this.extraBlock),h.forEach((t=>t.setAfter())),n.emitEvent(new t.LayoutEvent(r,h,this.times)),n.emitEvent(new t.LayoutEvent(a,h,this.times)),this.addBlocks(h),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:o}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),x.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(o,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){v(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new w([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new w(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const b=t.Debug.get("Renderer");class B{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,b.log(i.innerName,"---\x3e");try{i.isApp||i.app.emit(t.RenderEvent.CHILD_START,i),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,b.error(t)}b.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return b.warn("rendering");if(this.times>3)return b.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return b.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=e.includes(this.target.__world),r=new t.Bounds(s);n.save(),o&&!t.Debug.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,o,r),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds,!0),i.restore(),t.Run.end(e)}__render(e,i,n){const s=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||b.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:E}=t.BoundsHelper;class L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,i,n){i||(i=0),n||(n={});const s=n.through||!1,o=n.ignoreHittable||!1,r=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(r);const{list:a}=this.findList,h=this.getBestMatchLeaf(a,n.bottomList,o),l=o?this.getPath(h):this.getHitablePath(h);return this.clear(),s?{path:l,target:h,throughPath:a.length?this.getThroughPath(a):l}:{path:l,target:h}}getBestMatchLeaf(e,i,n){if(e.length){let i;this.findList=new t.LeafList;const{x:s,y:o}=this.point,r={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=e.length;s<o;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,r),this.findList.length))return this.findList.list[0]}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren);t--);return s}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let s,o,r;for(let t=0,e=n.length;t<e;t++){s=n[t],o=n[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!o||!o.has(r));t++)i.add(r)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||E(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:P,NoAndSkip:R,YesAndSkip:M}=t.Answer,C={},k={},T={};class S{constructor(e,i){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new L(e,this),e&&this.__listenEvents()}getBy(e,i,n,s){switch(typeof e){case"number":const o=this.getByInnerId(e,i);return n?o:o?[o]:[];case"string":switch(e[0]){case"#":C.id=e.substring(1),e=C;break;case".":k.className=e.substring(1),e=k;break;default:T.tag=e,e=T}case"object":if(void 0!==e.id){const t=this.getById(e.id,i);return n?t:t?[t]:[]}if(e.tag){const{tag:s}=e,o=s instanceof Array;return this.getByMethod(o?this.methods.tags:this.methods.tag,i,n,o?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,i,n,e.className);case"function":return this.getByMethod(e,i,n,s)}}getByPoint(e,i,n){return"node"===t.Platform.name&&this.target&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,i,n)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,i){const n=this.idMap[e];return n&&t.LeafHelper.hasParent(n,i||this.target)?n:(this.eachFind(this.toChildren(i),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,o;for(let r=0,a=t.length;r<a;r++){if(s=t[r],o=e(s,n),o===P||o===M){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&o<R&&this.eachFind(s.children,e,i,n)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new x(t,e),renderer:(t,e,i)=>new B(t,e,i),selector:(t,e)=>new S(t,e)}),t.Platform.layout=x.fullLayout;const A={convert(t,i){const n=e.InteractionHelper.getBase(t),s=Object.assign(Object.assign({},n),{x:i.x,y:i.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,i){const n=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},n),{x:i.x,y:i.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,i){const n=A.getTouch(t),s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},D={getMove(t,e){let{moveSpeed:i}=e,{deltaX:n,deltaY:s}=t;return t.shiftKey&&!n&&(n=s,s=0),n>50&&(n=Math.max(50,n/3)),s>50&&(s=Math.max(50,s/3)),{x:-n*i*2,y:-s*i*2}},getScale(e,i){let n,s=1,{zoomMode:o,zoomSpeed:r}=i;const a=e.deltaY||e.deltaX;if(o?(n="mouse"===o||!e.deltaX&&(t.Platform.intWheelDeltaY?Math.abs(a)>17:Math.ceil(a)!==a),(e.shiftKey||e.metaKey||e.ctrlKey)&&(n=!0)):n=!e.shiftKey&&(e.metaKey||e.ctrlKey),n){r=t.MathHelper.within(r,0,1);s=1-a/(4*(e.deltaY?i.delta.y:i.delta.x))*r,s<.5&&(s=.5),s>=1.5&&(s=1.5)}return s}},O={convert(t){const i=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},i),{code:t.code,key:t.key})}},{getMoveEventData:W,getZoomEventData:I,getRotateEventData:H,pathCanDrag:F}=e.InteractionHelper;class z extends e.InteractionBase{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,n=t.length;i<n;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(O.convert(t))}onKeyUp(t){this.keyUp(O.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(A.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||(this.usePointer||(this.usePointer=!0),this.pointerDown(A.convert(t,this.getLocal(t))))}onPointerMove(t){this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||(this.usePointer||(this.usePointer=!0),this.pointerMove(A.convert(t,this.getLocal(t,!0))))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(A.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(A.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(A.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(A.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){const e=A.getTouch(t),i=this.getLocal(e,!0),{preventDefault:n}=this.config.touch;(!0===n||"auto"===n&&F(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.usePointer||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(A.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=A.getTouch(t);this.pointerMove(A.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.usePointer||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=A.getTouch(t);this.pointerUp(A.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const i=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,i);n.length>1&&(this.multiTouch(e.InteractionHelper.getBase(t),n),this.touches=i)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})})),n}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}onWheel(t){this.preventDefaultWheel(t);const{wheel:i}=this.config;if(i.disabled)return;const n=i.getScale?i.getScale(t,i):D.getScale(t,i),s=this.getLocal(t),o=e.InteractionHelper.getBase(t);1!==n?this.zoom(I(s,n,o)):this.move(W(s,i.getMove?i.getMove(t,i):D.getMove(t,i),o))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(i){if(this.useMultiTouch)return;this.preventDefaultWheel(i);const n=this.getLocal(i),s=e.InteractionHelper.getBase(i),o=i.scale/this.lastGestureScale,r=i.rotation-this.lastGestureRotation;let{rotateSpeed:a}=this.config.wheel;a=t.MathHelper.within(a,0,1),this.zoom(I(n,o*o,s)),this.rotate(H(n,r/Math.PI*180*(a/4+.1),s)),this.lastGestureScale=i.scale,this.lastGestureRotation=i.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.canvas.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,i,n=0){if(n++,t instanceof Array)t.forEach((t=>this.eachCursor(t,i,n)));else{const s="string"==typeof t&&e.Cursor.get(t);s&&n<2?this.eachCursor(s,i,n):i.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function G(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=n.length;t<r;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function j(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?V(t,!0,e,i):U(e,i);break;case"inside":Y("inside",t,s,e,i);break;case"outside":Y("outside",t,s,e,i)}}function Y(t,e,i,n,s){const{__strokeWidth:o,__font:r}=n.__,a=s.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,n.__),a.font=r,i?V(e,!0,n,a):U(n,a),a.blendMode="outside"===t?"destination-out":"destination-in",G(n,a),a.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(a,n.__nowWorld):s.copyWorldToInner(a,n.__nowWorld,n.__layout.renderBounds),a.recycle(n.__nowWorld)}function U(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=n.length;t<r;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function V(t,e,n,s){let o;for(let r=0,a=t.length;r<a;r++)o=t[r],o.image&&i.PaintImage.checkImage(n,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),e?U(n,s):s.stroke(),s.restoreBlendMode()):e?U(n,s):s.stroke())}function N(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:X,getOuterOf:q,getByMove:K,getIntersectData:Q}=t.BoundsHelper;let $;function J(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:o,blendMode:r,color:a,opacity:h}=e;return{type:o,blendMode:r,style:i.ColorConvert.string(a,h)};case"image":return i.PaintImage.image(n,t,e,s,!$||!$[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const Z={compute:function(t,e){const n=e.__,s=[];let o,r=n.__input[t];r instanceof Array||(r=[r]),$=i.PaintImage.recycleImage(t,n);for(let i,n=0,o=r.length;n<o;n++)i=J(t,r[n],e),i&&s.push(i);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=o:n.__pixelStroke=o},fill:function(t,e,i){i.fillStyle=t,e.__.__font?G(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,n){let s;const{windingRule:o,__font:r}=e.__;for(let a=0,h=t.length;a<h;a++)s=t[a],s.image&&i.PaintImage.checkImage(e,n,s,!r)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),r?G(e,n):o?n.fill(o):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),r?G(e,n):o?n.fill(o):n.fill(),n.restoreBlendMode()):r?G(e,n):o?n.fill(o):n.fill())},fillText:G,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=n;if(s)if(r)j(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&N(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=n;if(s)if(r)j(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),V(t,!1,e,i),n.__useArrow&&N(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),V(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,n),V(t,!1,e,r),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:j,drawTextStroke:U,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:d}=s;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(s))h=n,o=a=s;else{const{renderShapeSpread:n}=t.__layout,c=Q(n?X(e.bounds,l===d?n*l:[n*d,n*l]):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:p}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=p),a=q(s,r),o=K(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,p)})}return t.__renderShape(n,i),{canvas:n,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:d}}};let tt={};const{get:et,rotateOfOuter:it,translate:nt,scaleOfOuter:st,scale:ot,rotate:rt}=t.MatrixHelper;function at(t,e,i,n,s,o,r){const a=et();nt(a,e.x+i,e.y+n),ot(a,s,o),r&&it(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function ht(t,e,i,n,s,o,r){const a=et();nt(a,e.x+i,e.y+n),s&&ot(a,s,o),r&&rt(a,r),t.transform=a}function lt(t,e,i,n,s,o,r,a,h,l){const d=et();if(h)if("center"===l)it(d,{x:i/2,y:n/2},h);else switch(rt(d,h),h){case 90:nt(d,n,0);break;case 180:nt(d,i,n);break;case 270:nt(d,0,i)}tt.x=e.x+s,tt.y=e.y+o,nt(d,tt.x,tt.y),r&&st(d,tt,r,a),t.transform=d}const{get:dt,translate:ct}=t.MatrixHelper,ut=new t.Bounds,pt={},ft={};function gt(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=_t(i,n,e)}function _t(e,i,n){let{width:s,height:o}=n;e.padding&&(i=ut.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:r,mode:a,align:h,offset:l,scale:d,size:c,rotation:u,repeat:p}=e,f=i.width===s&&i.height===o,g={mode:a},_="center"!==h&&(u||0)%180==90,w=_?o:s,v=_?s:o;let m,y,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(d||c)&&(t.MathHelper.getScaleData(d,c,n,ft),m=ft.scaleX,y=ft.scaleY);else if(!f||u){const t=i.width/w,e=i.height/v;m=y="fit"===a?Math.min(t,e):Math.max(t,e),x+=(i.width-s*m)/2,b+=(i.height-o*y)/2}if(h){const e={x:x,y:b,width:w,height:v};m&&(e.width*=m,e.height*=y),t.AlignHelper.toPoint(h,e,i,pt,!0),x+=pt.x,b+=pt.y}switch(l&&(x+=l.x,b+=l.y),a){case"stretch":f||(s=i.width,o=i.height);break;case"normal":case"clip":(x||b||m||u)&&ht(g,i,x,b,m,y,u);break;case"repeat":(!f||m||u)&<(g,i,s,o,x,b,m,y,u,h),p||(g.repeat="repeat");break;default:m&&at(g,i,x,b,m,y,u)}return g.transform||(i.x||i.y)&&(g.transform=dt(),ct(g.transform,i.x,i.y)),m&&"stretch"!==a&&(g.scaleX=m,g.scaleY=y),g.width=s,g.height=o,r&&(g.opacity=r),p&&(g.repeat="string"==typeof p?"x"===p?"repeat-x":"repeat-y":"repeat"),g}let wt,vt=new t.Bounds;const{isSame:mt}=t.BoundsHelper;function yt(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||gt(s,n,i,o),!0}function xt(e,i){Et(e,t.ImageEvent.LOAD,i)}function bt(e,i){Et(e,t.ImageEvent.LOADED,i)}function Bt(e,i,n){i.error=n,e.forceUpdate("surface"),Et(e,t.ImageEvent.ERROR,i)}function Et(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function Lt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Pt,scale:Rt,copy:Mt}=t.MatrixHelper,{ceil:Ct,abs:kt}=Math;function Tt(e,i,n){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+o+"-"+n;if(i.patternId===r||e.destroyed)return!1;{s=kt(s),o=kt(o);const{image:e,data:a}=i;let h,l,{width:d,height:c,scaleX:u,scaleY:p,opacity:f,transform:g,repeat:_}=a;u&&(l=Pt(),Mt(l,g),Rt(l,1/u,1/p),s*=u,o*=p),s*=n,o*=n,d*=s,c*=o;const w=d*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let v=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;v>t&&(v=t)}w>v&&(h=Math.sqrt(w/v)),h&&(s/=h,o/=h,d/=h,c/=h),u&&(s/=u,o/=p),(g||1!==s||1!==o)&&(l||(l=Pt(),g&&Mt(l,g)),Rt(l,1/s,1/o));const m=e.getCanvas(Ct(d)||1,Ct(c)||1,f),y=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,i);return i.style=y,i.patternId=r,!0}}function St(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:At}=Math;const Dt={image:function(e,i,n,s,o){let r,a;const h=t.ImageManager.get(n);return wt&&n===wt.paint&&mt(s,wt.boxBounds)?r=wt.leafPaint:(r={type:n.type,image:h},wt=h.use>1?{leafPaint:r,paint:n,boxBounds:vt.set(s)}:null),(o||h.loading)&&(a={image:h,attrName:i,attrValue:n}),h.ready?(yt(e,i,n,h,r,s),o&&(xt(e,a),bt(e,a))):h.error?o&&Bt(e,a,h.error):(o&&(Lt(e,!0),xt(e,a)),r.loadId=h.load((()=>{Lt(e,!1),e.destroyed||(yt(e,i,n,h,r,s)&&(h.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),bt(e,a)),r.loadId=null}),(t=>{Lt(e,!1),Bt(e,a,t),r.loadId=null}))),r},checkImage:function(e,n,s,o){const{scaleX:r,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:h}=n;if(!s.data||s.patternId===r+"-"+a+"-"+h&&!i.Export.running)return!1;{const{data:l}=s;if(o)if(l.repeat)o=!1;else{let{width:e,height:n}=l;e*=At(r)*h,n*=At(a)*h,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),e.windingRule?n.clip(e.windingRule):n.clip(),s.blendMode&&(n.blendMode=s.blendMode),l.opacity&&(n.opacity*=l.opacity),l.transform&&n.transform(l.transform),n.drawImage(s.image.view,0,0,l.width,l.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?Tt(e,s,h):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>St(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&Tt(e,s,h),e.forceUpdate("surface")}))),300)),!1)}},createPattern:Tt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){let s,o,r,a;for(let h=0,l=n.length;h<l;h++)s=n[h].image,a=s&&s.url,a&&(o||(o={}),o[a]=!0,t.ImageManager.recycle(s),s.loading&&(r||(r=i.__input&&i.__input[e]||[],r instanceof Array||(r=[r])),s.unload(n[h].loadId,!r.some((t=>t.url===a)))));return o}return null},createData:gt,getPatternData:_t,fillOrFitMode:at,clipMode:ht,repeatMode:lt},{toPoint:Ot}=t.AroundHelper,Wt={},It={};function Ht(t,e,n){if(e){let s;for(let o=0,r=e.length;o<r;o++)s=e[o],"string"==typeof s?t.addColorStop(o/(r-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}}const{getAngle:Ft,getDistance:zt}=t.PointHelper,{get:Gt,rotateOfOuter:jt,scaleOfOuter:Yt}=t.MatrixHelper,{toPoint:Ut}=t.AroundHelper,Vt={},Nt={};function Xt(t,e,i,n,s){let o;const{width:r,height:a}=t;if(r!==a||n){const t=Ft(e,i);o=Gt(),s?(Yt(o,e,r/a*(n||1),1),jt(o,e,t+90)):(Yt(o,e,1,r/a*(n||1)),jt(o,e,t))}return o}const{getDistance:qt}=t.PointHelper,{toPoint:Kt}=t.AroundHelper,Qt={},$t={};const Jt={linearGradient:function(e,i){let{from:n,to:s,type:o,blendMode:r,opacity:a}=e;Ot(n||"top",i,Wt),Ot(s||"bottom",i,It);const h=t.Platform.canvas.createLinearGradient(Wt.x,Wt.y,It.x,It.y);Ht(h,e.stops,a);const l={type:o,style:h};return r&&(l.blendMode=r),l},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,blendMode:a,stretch:h}=e;Ut(n||"center",i,Vt),Ut(s||"bottom",i,Nt);const l=t.Platform.canvas.createRadialGradient(Vt.x,Vt.y,0,Vt.x,Vt.y,zt(Vt,Nt));Ht(l,e.stops,r);const d={type:o,style:l},c=Xt(i,Vt,Nt,h,!0);return c&&(d.transform=c),a&&(d.blendMode=a),d},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,blendMode:a,stretch:h}=e;Kt(n||"center",i,Qt),Kt(s||"bottom",i,$t);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Qt.x,Qt.y):t.Platform.canvas.createRadialGradient(Qt.x,Qt.y,0,Qt.x,Qt.y,qt(Qt,$t));Ht(l,e.stops,r);const d={type:o,style:l},c=Xt(i,Qt,$t,h||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),a&&(d.blendMode=a),d},getTransform:Xt},{copy:Zt,toOffsetOutBounds:te}=t.BoundsHelper,ee={},ie={};function ne(e,i,n,s){const{bounds:o,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Zt(ee,e.bounds),ee.x+=i.x-r.x,ee.y+=i.y-r.y,n){const{matrix:t}=s;ee.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),ee.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),ee.width*=n,ee.height*=n}e.copyWorld(s.canvas,e.bounds,ee)}else n&&(Zt(ee,i),ee.x-=i.width/2*(n-1),ee.y-=i.height/2*(n-1),ee.width*=n,ee.height*=n),e.copyWorld(s.canvas,r,n?ee:i)}const{toOffsetOutBounds:se}=t.BoundsHelper,oe={};const re={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;te(l,ie),a.forEach(((a,g)=>{p.setWorldShadow(ie.offsetX+a.x*c,ie.offsetY+a.y*u,a.blur*c,a.color),s=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,ne(p,ie,s,i),n=l,a.box&&(p.restore(),p.save(),h&&(p.copyWorld(p,l,o,"copy"),n=o),h?p.copyWorld(h,o,o,"destination-out"):p.copyWorld(i.canvas,d,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,n,o,a.blendMode):e.copyWorldToInner(p,n,r.renderBounds,a.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;se(l,oe),a.forEach(((a,g)=>{p.save(),p.setWorldShadow(oe.offsetX+a.x*c,oe.offsetY+a.y*u,a.blur*c),s=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,ne(p,oe,s,i),p.restore(),h?(p.copyWorld(p,l,o,"copy"),p.copyWorld(h,o,o,"source-out"),n=o):(p.copyWorld(i.canvas,d,l,"source-out"),n=l),p.fillWorld(n,a.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(p,n,o,a.blendMode):e.copyWorldToInner(p,n,r.renderBounds,a.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:ae}=t.LeafBoundsHelper;function he(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),de(t,e,i,1)}(t,i,n,s);break;case"opacity-path":de(t,i,n,o);break;case"path":i.restore()}}function le(t){return t.getSameCanvas(!1,!0)}function de(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let i,n,s,o,r,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++)i=h[l],a=i.__.mask,a&&(r&&(he(this,r,t,s,n,o),n=s=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,s||(s=le(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",n||(n=le(t)),s||(s=le(t)),i.__render(n,e)),"clipping"!==a&&"clipping-path"!==a)||ae(i,e)||i.__render(s||t,e);he(this,r,t,s,n,o)};const ce=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ue=ce+"_#~&*+\\=|≮≯≈≠=…",pe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function fe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ge=fe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),_e=fe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),we=fe(ce),ve=fe(ue),me=fe("- —/~|┆·");var ye;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ye||(ye={}));const{Letter:xe,Single:be,Before:Be,After:Ee,Symbol:Le,Break:Pe}=ye;function Re(t){return ge[t]?xe:me[t]?Pe:_e[t]?Be:we[t]?Ee:ve[t]?Le:pe.test(t)?be:xe}const Me={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Ce(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ke}=Me,{Letter:Te,Single:Se,Before:Ae,After:De,Symbol:Oe,Break:We}=ye;let Ie,He,Fe,ze,Ge,je,Ye,Ue,Ve,Ne,Xe,qe,Ke,Qe,$e,Je,Ze,ti=[];function ei(t,e){Ve&&!Ue&&(Ue=Ve),Ie.data.push({char:t,width:e}),Fe+=e}function ii(){ze+=Fe,Ie.width=Fe,He.words.push(Ie),Ie={data:[]},Fe=0}function ni(){Qe&&($e.paraNumber++,He.paraStart=!0,Qe=!1),Ve&&(He.startCharSize=Ue,He.endCharSize=Ve,Ue=0),He.width=ze,Je.width?ke(He):Ze&&si(),ti.push(He),He={words:[]},ze=0}function si(){ze>($e.maxWidth||0)&&($e.maxWidth=ze)}const oi=0,ri=1,ai=2;const{top:hi,right:li,bottom:di,left:ci}=t.Direction4;function ui(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const pi={getDrawData:function(e,i){"string"!=typeof e&&(e=String(e));let n=0,s=0,o=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:a,__font:h,__padding:l}=i;l&&(o?(n=l[ci],o-=l[li]+l[ci]):i.autoSizeAlign||(n=l[ci]),r?(s=l[hi],r-=l[hi]+l[di]):i.autoSizeAlign||(s=l[hi]));const d={bounds:{x:n,y:s,width:o,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=h};return function(e,i,n){$e=e,ti=e.rows,Je=e.bounds,Ze=!Je.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=n,{canvas:a}=t.Platform,{width:h,height:l}=Je;if(h||l||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Qe=!0,Xe=null,Ue=Ye=Ve=Fe=ze=0,Ie={data:[]},He={words:[]};for(let n=0,l=i.length;n<l;n++)je=i[n],"\n"===je?(Fe&&ii(),He.paraEnd=!0,ni(),Qe=!0):(Ne=Re(je),Ne===Te&&"none"!==r&&(je=Ce(je,r,!Fe)),Ye=a.measureText(je).width,s&&(s<0&&(Ve=Ye),Ye+=s),qe=Ne===Se&&(Xe===Se||Xe===Te)||Xe===Se&&Ne!==De,Ke=!(Ne!==Ae&&Ne!==Se||Xe!==Oe&&Xe!==De),Ge=Qe&&o?h-o:h,t&&h&&ze+Fe+Ye>Ge&&(e?(Fe&&ii(),ze&&ni()):(Ke||(Ke=Ne===Te&&Xe==De),qe||Ke||Ne===We||Ne===Ae||Ne===Se||Fe+Ye>Ge?(Fe&&ii(),ze&&ni()):ze&&ni()))," "===je&&!0!==Qe&&ze+Fe===0||(Ne===We?(" "===je&&Fe&&ii(),ei(je,Ye),ii()):qe||Ke?(Fe&&ii(),ei(je,Ye)):ei(je,Ye)),Xe=Ne);Fe&&ii(),ze&&ni(),ti.length>0&&(ti[ti.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{$e.paraNumber++,ze=a.measureText(t).width,ti.push({x:o||0,text:t,width:ze,paraStart:!0}),Ze&&si()}))}(d,e,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ui(e,"x",t[ci]);break;case"right":ui(e,"x",-t[li])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ui(e,"y",t[hi]);break;case"bottom":ui(e,"y",-t[di])}}(l,d,i,o,r),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:r,__clipText:a,textAlign:h,verticalAlign:l,paraSpacing:d,autoSizeAlign:c}=e;let{x:u,y:p,width:f,height:g}=n,_=s*i.length+(d?d*(t.paraNumber-1):0),w=o;if(a&&_>g)_=Math.max(g,s),t.overflow=i.length;else if(g||c)switch(l){case"middle":p+=(g-_)/2;break;case"bottom":p+=g-_}w+=p;let v,m,y,x=f||c?f:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(v=i[o],v.x=u,v.width<f||v.width>f&&!a)switch(h){case"center":v.x+=(x-v.width)/2;break;case"right":v.x+=x-v.width}v.paraStart&&d&&o>0&&(w+=d),v.y=w,w+=s,t.overflow>o&&w>_&&(v.isOverflow=!0,t.overflow=o+1),m=v.x,y=v.width,r<0&&(v.width<0?(y=-v.width+e.fontSize+r,m-=y,y+=e.fontSize):y-=r),m<n.x&&(n.x=m),y>n.width&&(n.width=y),a&&f&&f<y&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=_}(d,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,l,d,c,u;s.forEach((t=>{t.words&&(d=r&&t.paraStart?r:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-d)/(t.words.length-1):0,c=a||t.isOverflow?oi:l>.01?ri:ai,t.isOverflow&&!a&&(t.textMode=!0),c===ai?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,h=t.x,t.data=[],t.words.forEach((e=>{c===ri?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&l&&(h+=l,t.width+=l)}))),t.words=null)}))}(d,i,o),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=i;if(o.splice(r),a&&"show"!==a){let e,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.Platform.canvas.measureText(a).width:0,d=n+s-l;("none"===i.textWrap?o:[o[r-1]]).forEach((t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],h=e.x+e.width,!(n===i&&h<d));n--){if(h<d&&" "!==e.char){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:a,x:h}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,i,n,o),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(d,i),d}};const fi={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}},{setPoint:gi,addPoint:_i,toBounds:wi}=t.TwoPointBoundsHelper;const vi={export(e,i,n){this.running=!0;const s=t.FileHelper.fileType(i),o=i.includes(".");return n=t.FileHelper.getExportOptions(n),function(e){mi||(mi=new t.TaskProcessor);return new Promise((t=>{mi.add((()=>St(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((r=>new Promise((a=>{const h=t=>{r(t),a(),this.running=!1},{toURL:l}=t.Platform,{download:d}=t.Platform.origin;if("json"===s)return o&&d(l(JSON.stringify(e.toJSON(n.json)),"text"),i),h({data:!!o||e.toJSON(n.json)});if("svg"===s)return o&&d(l(e.toSVG(),"svg"),i),h({data:!!o||e.toSVG()});const{leafer:c}=e;c?(yi(e),c.waitViewCompleted((()=>St(this,void 0,void 0,(function*(){let s,o,r=1,a=1;const{worldTransform:l,isLeafer:d,isFrame:u}=e,{slice:p,trim:f,onCanvas:g}=n,_=void 0===n.smooth?c.config.smooth:n.smooth,w=n.contextSettings||c.config.contextSettings,v=n.screenshot||e.isApp,m=d&&v&&void 0===n.fill?e.fill:n.fill,y=t.FileHelper.isOpaqueImage(i)||m,x=new t.Matrix;if(v)s=!0===v?d?c.canvas.bounds:e.worldRenderBounds:v;else{let t=n.relative||(d?"inner":"local");switch(r=l.scaleX,a=l.scaleY,t){case"inner":x.set(l);break;case"local":x.set(l).divide(e.localTransform),r/=e.scaleX,a/=e.scaleY;break;case"world":r=1,a=1;break;case"page":t=e.leafer;default:x.set(l).divide(e.getTransform(t));const i=t.worldTransform;r/=r/i.scaleX,a/=a/i.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(n.scale,n.size,s,b);let B=n.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:L,width:P,height:R}=new t.Bounds(s).scale(b.scaleX,b.scaleY),M={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-L).withScale(1/r*b.scaleX,1/a*b.scaleY)};let C,k=t.Creator.canvas({width:Math.round(P),height:Math.round(R),pixelRatio:B,smooth:_,contextSettings:w});if(p&&(C=e,C.__worldOpacity=0,e=c,M.bounds=k.bounds),k.save(),u&&void 0!==m){const t=e.get("fill");e.fill="",e.__render(k,M),e.fill=t}else e.__render(k,M);if(k.restore(),C&&C.__updateWorldOpacity(),f){o=function(e){const{width:i,height:n}=e.view,{data:s}=e.context.getImageData(0,0,i,n);let o,r,a,h=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(o=h%i,r=(h-o)/i,a?_i(a,o,r):gi(a={},o,r)),h++;const l=new t.Bounds;return wi(a,l),l.scale(1/e.pixelRatio).ceil()}(k);const e=k,{width:i,height:n}=o,s={x:0,y:0,width:i,height:n,pixelRatio:B};k=t.Creator.canvas(s),k.copyWorld(e,o,s)}y&&k.fillWorld(k.bounds,m||"#FFFFFF","destination-over"),g&&g(k);const T="canvas"===i?k:yield k.export(i,n);h({data:T,width:k.pixelWidth,height:k.pixelHeight,renderBounds:s,trimBounds:o})}))))):h({data:!1})}))))}};let mi;function yi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>yi(t)))}const xi=t.LeaferCanvasBase.prototype,bi=t.Debug.get("@leafer-ui/export");xi.export=function(e,i){const{quality:n,blob:s}=t.FileHelper.getExportOptions(i);return e.includes(".")?this.saveAs(e,n):s?this.toBlob(e,n):this.toDataURL(e,n)},xi.toBlob=function(e,i){return new Promise((n=>{t.Platform.origin.canvasToBolb(this.view,e,i).then((t=>{n(t)})).catch((t=>{bi.error(t),n(null)}))}))},xi.toDataURL=function(e,i){return t.Platform.origin.canvasToDataURL(this.view,e,i)},xi.saveAs=function(e,i){return new Promise((n=>{t.Platform.origin.canvasSaveAs(this.view,e,i).then((()=>{n(!0)})).catch((t=>{bi.error(t),n(!1)}))}))},Object.assign(i.TextConvert,pi),Object.assign(i.ColorConvert,fi),Object.assign(i.Paint,Z),Object.assign(i.PaintImage,Dt),Object.assign(i.PaintGradient,Jt),Object.assign(i.Effect,re),Object.assign(i.Export,vi),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new z(t,e,i,n),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=z,exports.Layouter=x,exports.LeaferCanvas=s,exports.Renderer=B,exports.Selector=S,exports.Watcher=l,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),i=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class s extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(n.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const i=this.view;t.hasChildNodes()&&(this.setAbsolute(i),t.style.position||(t.style.position="relative")),t.appendChild(i)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this,{style:n}=this.view;n.width=t+"px",n.height=e+"px",this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const e=t.Platform.devicePixelRatio;if(this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const i=this.view,{x:n,y:s,width:o,height:r}=this.autoBounds.getBoundsFrom(e),a={width:o,height:r,pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(a)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(a)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,i))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:o,fileType:r}=t.FileHelper;function a(e,i){t.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>t.toDataURL(o(e),i),canvasToBolb:(t,e,i)=>new Promise((n=>t.toBlob(n,o(e),i))),canvasSaveAs:(e,i,n)=>{const s=e.toDataURL(o(r(i)),n);return t.Platform.origin.download(s,i)},download:(t,e)=>new Promise((i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()})),loadImage:e=>new Promise(((i,n)=>{const s=new Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)}))},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new s(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:h}=navigator;h.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):h.indexOf("Safari")>-1&&-1===h.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),h.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):h.indexOf("Mac")>-1?t.Platform.os="Mac":h.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateAllWorldOpacity:u}=t.LeafHelper,{pushAllChildBranch:p,pushAllParent:f}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper,_={x:0,y:0,width:1e5,height:1e5};class w{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,g)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(_):this.afterBounds.setListWithFn(t,g),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:v,updateAllChange:m}=t.LeafHelper,y=t.Debug.get("Layouter");class x{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:o,LAYOUT:r,AFTER:a}=t.LayoutEvent,h=this.getBlocks(s);h.forEach((t=>t.setBefore())),n.emitEvent(new t.LayoutEvent(o,h,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&p(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||c(n[t])}c(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&u(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&h.push(this.extraBlock),h.forEach((t=>t.setAfter())),n.emitEvent(new t.LayoutEvent(r,h,this.times)),n.emitEvent(new t.LayoutEvent(a,h,this.times)),this.addBlocks(h),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:o}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),x.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(o,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){v(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new w([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new w(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const b=t.Debug.get("Renderer");class B{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,b.log(i.innerName,"---\x3e");try{i.isApp||i.app.emit(t.RenderEvent.CHILD_START,i),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,b.error(t)}b.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return b.warn("rendering");if(this.times>3)return b.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return b.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=e.includes(this.target.__world),r=new t.Bounds(s);n.save(),o&&!t.Debug.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,o,r),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds,!0),i.restore(),t.Run.end(e)}__render(e,i,n){const s=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||b.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:L}=t.BoundsHelper;class E{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,i,n){i||(i=0),n||(n={});const s=n.through||!1,o=n.ignoreHittable||!1,r=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(r);const{list:a}=this.findList,h=this.getBestMatchLeaf(a,n.bottomList,o),l=o?this.getPath(h):this.getHitablePath(h);return this.clear(),s?{path:l,target:h,throughPath:a.length?this.getThroughPath(a):l}:{path:l,target:h}}getBestMatchLeaf(e,i,n){if(e.length){let i;this.findList=new t.LeafList;const{x:s,y:o}=this.point,r={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=e.length;s<o;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,r),this.findList.length))return this.findList.list[0]}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren);t--);return s}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let s,o,r;for(let t=0,e=n.length;t<e;t++){s=n[t],o=n[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!o||!o.has(r));t++)i.add(r)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||L(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:P,NoAndSkip:R,YesAndSkip:C}=t.Answer,k={},M={},T={};class S{constructor(e,i){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new E(e,this),e&&this.__listenEvents()}getBy(e,i,n,s){switch(typeof e){case"number":const o=this.getByInnerId(e,i);return n?o:o?[o]:[];case"string":switch(e[0]){case"#":k.id=e.substring(1),e=k;break;case".":M.className=e.substring(1),e=M;break;default:T.tag=e,e=T}case"object":if(void 0!==e.id){const t=this.getById(e.id,i);return n?t:t?[t]:[]}if(e.tag){const{tag:s}=e,o=s instanceof Array;return this.getByMethod(o?this.methods.tags:this.methods.tag,i,n,o?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,i,n,e.className);case"function":return this.getByMethod(e,i,n,s)}}getByPoint(e,i,n){return"node"===t.Platform.name&&this.target&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,i,n)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,i){const n=this.idMap[e];return n&&t.LeafHelper.hasParent(n,i||this.target)?n:(this.eachFind(this.toChildren(i),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,o;for(let r=0,a=t.length;r<a;r++){if(s=t[r],o=e(s,n),o===P||o===C){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&o<R&&this.eachFind(s.children,e,i,n)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new x(t,e),renderer:(t,e,i)=>new B(t,e,i),selector:(t,e)=>new S(t,e)}),t.Platform.layout=x.fullLayout;const O={convert(t,i){const n=e.InteractionHelper.getBase(t),s=Object.assign(Object.assign({},n),{x:i.x,y:i.y,width:t.width,height:t.height,pointerType:t.pointerType,pressure:t.pressure});return"pen"===s.pointerType&&(s.tangentialPressure=t.tangentialPressure,s.tiltX=t.tiltX,s.tiltY=t.tiltY,s.twist=t.twist),s},convertMouse(t,i){const n=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},n),{x:i.x,y:i.y,width:1,height:1,pointerType:"mouse",pressure:.5})},convertTouch(t,i){const n=O.getTouch(t),s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force})},getTouch:t=>t.targetTouches[0]||t.changedTouches[0]},A={convert(t){const i=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},i),{code:t.code,key:t.key})}},{pathCanDrag:D}=e.InteractionHelper;class W extends e.InteractionBase{__listenEvents(){super.__listenEvents();const t=this.view=this.canvas.view;this.viewEvents={pointerdown:this.onPointerDown,mousedown:this.onMouseDown,touchstart:this.onTouchStart,contextmenu:this.onContextMenu,wheel:this.onWheel,gesturestart:this.onGesturestart,gesturechange:this.onGesturechange,gestureend:this.onGestureend},this.windowEvents={pointermove:this.onPointerMove,pointerup:this.onPointerUp,pointercancel:this.onPointerCancel,mousemove:this.onMouseMove,mouseup:this.onMouseUp,touchmove:this.onTouchMove,touchend:this.onTouchEnd,touchcancel:this.onTouchCancel,keydown:this.onKeyDown,keyup:this.onKeyUp,scroll:this.onScroll};const{viewEvents:e,windowEvents:i}=this;for(let i in e)e[i]=e[i].bind(this),t.addEventListener(i,e[i]);for(let t in i)i[t]=i[t].bind(this),window.addEventListener(t,i[t])}__removeListenEvents(){super.__removeListenEvents();const{viewEvents:t,windowEvents:e}=this;for(let e in t)this.view.removeEventListener(e,t[e]),this.viewEvents={};for(let t in e)window.removeEventListener(t,e[t]),this.windowEvents={}}getTouches(t){const e=[];for(let i=0,n=t.length;i<n;i++)e.push(t[i]);return e}preventDefaultPointer(t){const{pointer:e}=this.config;e.preventDefault&&t.preventDefault()}preventDefaultWheel(t){const{wheel:e}=this.config;e.preventDefault&&t.preventDefault()}preventWindowPointer(t){return!this.downData&&t.target!==this.view}onKeyDown(t){this.keyDown(A.convert(t))}onKeyUp(t){this.keyUp(A.convert(t))}onContextMenu(t){this.config.pointer.preventDefaultMenu&&t.preventDefault(),this.menu(O.convert(t,this.getLocal(t)))}onScroll(){this.canvas.updateClientBounds()}onPointerDown(t){this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||(this.usePointer||(this.usePointer=!0),this.pointerDown(O.convert(t,this.getLocal(t))))}onPointerMove(t){this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||(this.usePointer||(this.usePointer=!0),this.pointerMove(O.convert(t,this.getLocal(t,!0))))}onPointerUp(t){this.downData&&this.preventDefaultPointer(t),this.config.pointer.touch||this.useMultiTouch||this.preventWindowPointer(t)||this.pointerUp(O.convert(t,this.getLocal(t)))}onPointerCancel(){this.useMultiTouch||this.pointerCancel()}onMouseDown(t){this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.pointerDown(O.convertMouse(t,this.getLocal(t)))}onMouseMove(t){this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerMove(O.convertMouse(t,this.getLocal(t,!0)))}onMouseUp(t){this.downData&&this.preventDefaultPointer(t),this.useTouch||this.usePointer||this.preventWindowPointer(t)||this.pointerUp(O.convertMouse(t,this.getLocal(t)))}onMouseCancel(){this.useTouch||this.usePointer||this.pointerCancel()}onTouchStart(t){const e=O.getTouch(t),i=this.getLocal(e,!0),{preventDefault:n}=this.config.touch;(!0===n||"auto"===n&&D(this.findPath(i)))&&t.preventDefault(),this.multiTouchStart(t),this.usePointer||(this.touchTimer&&(window.clearTimeout(this.touchTimer),this.touchTimer=0),this.useTouch=!0,this.pointerDown(O.convertTouch(t,i)))}onTouchMove(t){if(this.multiTouchMove(t),this.usePointer||this.preventWindowPointer(t))return;const e=O.getTouch(t);this.pointerMove(O.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){if(this.multiTouchEnd(),this.usePointer||this.preventWindowPointer(t))return;this.touchTimer&&clearTimeout(this.touchTimer),this.touchTimer=setTimeout((()=>{this.useTouch=!1}),500);const e=O.getTouch(t);this.pointerUp(O.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.usePointer||this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const i=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,i);n.length>1&&(this.multiTouch(e.InteractionHelper.getBase(t),n),this.touches=i)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})})),n}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}onWheel(t){this.preventDefaultWheel(t),this.wheel(Object.assign(Object.assign(Object.assign({},e.InteractionHelper.getBase(t)),this.getLocal(t)),{deltaX:t.deltaX,deltaY:t.deltaY}))}onGesturestart(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.lastGestureScale=1,this.lastGestureRotation=0)}onGesturechange(i){if(this.useMultiTouch)return;this.preventDefaultWheel(i);const n=e.InteractionHelper.getBase(i);Object.assign(n,this.getLocal(i));const s=i.scale/this.lastGestureScale,o=(i.rotation-this.lastGestureRotation)/Math.PI*180*(t.MathHelper.within(this.config.wheel.rotateSpeed,0,1)/4+.1);this.zoom(Object.assign(Object.assign({},n),{scale:s*s})),this.rotate(Object.assign(Object.assign({},n),{rotation:o})),this.lastGestureScale=i.scale,this.lastGestureRotation=i.rotation}onGestureend(t){this.useMultiTouch||(this.preventDefaultWheel(t),this.transformEnd())}setCursor(t){super.setCursor(t);const e=[];this.eachCursor(t,e),"object"==typeof e[e.length-1]&&e.push("default"),this.canvas.view.style.cursor=e.map((t=>"object"==typeof t?`url(${t.url}) ${t.x||0} ${t.y||0}`:t)).join(",")}eachCursor(t,i,n=0){if(n++,t instanceof Array)t.forEach((t=>this.eachCursor(t,i,n)));else{const s="string"==typeof t&&e.Cursor.get(t);s&&n<2?this.eachCursor(s,i,n):i.push(t)}}destroy(){this.view&&(super.destroy(),this.view=null,this.touches=null)}}function I(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=n.length;t<r;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}function H(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?z(t,!0,e,i):j(e,i);break;case"inside":F("inside",t,s,e,i);break;case"outside":F("outside",t,s,e,i)}}function F(t,e,i,n,s){const{__strokeWidth:o,__font:r}=n.__,a=s.getSameCanvas(!0,!0);a.setStroke(i?void 0:e,2*o,n.__),a.font=r,i?z(e,!0,n,a):j(n,a),a.blendMode="outside"===t?"destination-out":"destination-in",I(n,a),a.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(a,n.__nowWorld):s.copyWorldToInner(a,n.__nowWorld,n.__layout.renderBounds),a.recycle(n.__nowWorld)}function j(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,r=n.length;t<r;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}function z(t,e,n,s){let o;for(let r=0,a=t.length;r<a;r++)o=t[r],o.image&&i.PaintImage.checkImage(n,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),e?j(n,s):s.stroke(),s.restoreBlendMode()):e?j(n,s):s.stroke())}function G(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:Y,getOuterOf:U,getByMove:V,getIntersectData:N}=t.BoundsHelper;let X;function q(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:o,blendMode:r,color:a,opacity:h}=e;return{type:o,blendMode:r,style:i.ColorConvert.string(a,h)};case"image":return i.PaintImage.image(n,t,e,s,!X||!X[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const K={compute:function(t,e){const n=e.__,s=[];let o,r=n.__input[t];r instanceof Array||(r=[r]),X=i.PaintImage.recycleImage(t,n);for(let i,n=0,o=r.length;n<o;n++)i=q(t,r[n],e),i&&s.push(i);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=o:n.__pixelStroke=o},fill:function(t,e,i){i.fillStyle=t,e.__.__font?I(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,n){let s;const{windingRule:o,__font:r}=e.__;for(let a=0,h=t.length;a<h;a++)s=t[a],s.image&&i.PaintImage.checkImage(e,n,s,!r)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),r?I(e,n):o?n.fill(o):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),r?I(e,n):o?n.fill(o):n.fill(),n.restoreBlendMode()):r?I(e,n):o?n.fill(o):n.fill())},fillText:I,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=n;if(s)if(r)H(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&G(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:r}=n;if(s)if(r)H(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),z(t,!1,e,i),n.__useArrow&&G(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),z(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,n),z(t,!1,e,r),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:H,drawTextStroke:j,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,r,a,h,{scaleX:l,scaleY:d}=s;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(s))h=n,o=a=s;else{const{renderShapeSpread:n}=t.__layout,c=N(n?Y(e.bounds,l===d?n*l:[n*d,n*l]):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:p}=r;if(r.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=p),a=U(s,r),o=V(a,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,p*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,p)})}return t.__renderShape(n,i),{canvas:n,matrix:r,bounds:o,worldCanvas:h,shapeBounds:a,scaleX:l,scaleY:d}}};let Q={};const{get:$,rotateOfOuter:J,translate:Z,scaleOfOuter:tt,scale:et,rotate:it}=t.MatrixHelper;function nt(t,e,i,n,s,o,r){const a=$();Z(a,e.x+i,e.y+n),et(a,s,o),r&&J(a,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=a}function st(t,e,i,n,s,o,r){const a=$();Z(a,e.x+i,e.y+n),s&&et(a,s,o),r&&it(a,r),t.transform=a}function ot(t,e,i,n,s,o,r,a,h,l){const d=$();if(h)if("center"===l)J(d,{x:i/2,y:n/2},h);else switch(it(d,h),h){case 90:Z(d,n,0);break;case 180:Z(d,i,n);break;case 270:Z(d,0,i)}Q.x=e.x+s,Q.y=e.y+o,Z(d,Q.x,Q.y),r&&tt(d,Q,r,a),t.transform=d}const{get:rt,translate:at}=t.MatrixHelper,ht=new t.Bounds,lt={},dt={};function ct(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),t.data=ut(i,n,e)}function ut(e,i,n){let{width:s,height:o}=n;e.padding&&(i=ht.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:r,mode:a,align:h,offset:l,scale:d,size:c,rotation:u,repeat:p}=e,f=i.width===s&&i.height===o,g={mode:a},_="center"!==h&&(u||0)%180==90,w=_?o:s,v=_?s:o;let m,y,x=0,b=0;if(a&&"cover"!==a&&"fit"!==a)(d||c)&&(t.MathHelper.getScaleData(d,c,n,dt),m=dt.scaleX,y=dt.scaleY);else if(!f||u){const t=i.width/w,e=i.height/v;m=y="fit"===a?Math.min(t,e):Math.max(t,e),x+=(i.width-s*m)/2,b+=(i.height-o*y)/2}if(h){const e={x:x,y:b,width:w,height:v};m&&(e.width*=m,e.height*=y),t.AlignHelper.toPoint(h,e,i,lt,!0),x+=lt.x,b+=lt.y}switch(l&&(x+=l.x,b+=l.y),a){case"stretch":f||(s=i.width,o=i.height);break;case"normal":case"clip":(x||b||m||u)&&st(g,i,x,b,m,y,u);break;case"repeat":(!f||m||u)&&ot(g,i,s,o,x,b,m,y,u,h),p||(g.repeat="repeat");break;default:m&&nt(g,i,x,b,m,y,u)}return g.transform||(i.x||i.y)&&(g.transform=rt(),at(g.transform,i.x,i.y)),m&&"stretch"!==a&&(g.scaleX=m,g.scaleY=y),g.width=s,g.height=o,r&&(g.opacity=r),p&&(g.repeat="string"==typeof p?"x"===p?"repeat-x":"repeat-y":"repeat"),g}let pt,ft=new t.Bounds;const{isSame:gt}=t.BoundsHelper;function _t(t,e,i,n,s,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||ct(s,n,i,o),!0}function wt(e,i){yt(e,t.ImageEvent.LOAD,i)}function vt(e,i){yt(e,t.ImageEvent.LOADED,i)}function mt(e,i,n){i.error=n,e.forceUpdate("surface"),yt(e,t.ImageEvent.ERROR,i)}function yt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function xt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:bt,scale:Bt,copy:Lt}=t.MatrixHelper,{ceil:Et,abs:Pt}=Math;function Rt(e,i,n){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+o+"-"+n;if(i.patternId===r||e.destroyed)return!1;{s=Pt(s),o=Pt(o);const{image:e,data:a}=i;let h,l,{width:d,height:c,scaleX:u,scaleY:p,opacity:f,transform:g,repeat:_}=a;u&&(l=bt(),Lt(l,g),Bt(l,1/u,1/p),s*=u,o*=p),s*=n,o*=n,d*=s,c*=o;const w=d*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let v=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;v>t&&(v=t)}w>v&&(h=Math.sqrt(w/v)),h&&(s/=h,o/=h,d/=h,c/=h),u&&(s/=u,o/=p),(g||1!==s||1!==o)&&(l||(l=bt(),g&&Lt(l,g)),Bt(l,1/s,1/o));const m=e.getCanvas(Et(d)||1,Et(c)||1,f),y=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,i);return i.style=y,i.patternId=r,!0}}function Ct(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}h((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:kt}=Math;const Mt={image:function(e,i,n,s,o){let r,a;const h=t.ImageManager.get(n);return pt&&n===pt.paint&>(s,pt.boxBounds)?r=pt.leafPaint:(r={type:n.type,image:h},pt=h.use>1?{leafPaint:r,paint:n,boxBounds:ft.set(s)}:null),(o||h.loading)&&(a={image:h,attrName:i,attrValue:n}),h.ready?(_t(e,i,n,h,r,s),o&&(wt(e,a),vt(e,a))):h.error?o&&mt(e,a,h.error):(o&&(xt(e,!0),wt(e,a)),r.loadId=h.load((()=>{xt(e,!1),e.destroyed||(_t(e,i,n,h,r,s)&&(h.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),vt(e,a)),r.loadId=null}),(t=>{xt(e,!1),mt(e,a,t),r.loadId=null}))),r},checkImage:function(e,n,s,o){const{scaleX:r,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:h}=n;if(!s.data||s.patternId===r+"-"+a+"-"+h&&!i.Export.running)return!1;{const{data:l}=s;if(o)if(l.repeat)o=!1;else{let{width:e,height:n}=l;e*=kt(r)*h,n*=kt(a)*h,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),e.windingRule?n.clip(e.windingRule):n.clip(),s.blendMode&&(n.blendMode=s.blendMode),l.opacity&&(n.opacity*=l.opacity),l.transform&&n.transform(l.transform),n.drawImage(s.image.view,0,0,l.width,l.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?Rt(e,s,h):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>Ct(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&Rt(e,s,h),e.forceUpdate("surface")}))),300)),!1)}},createPattern:Rt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){let s,o,r,a;for(let h=0,l=n.length;h<l;h++)s=n[h].image,a=s&&s.url,a&&(o||(o={}),o[a]=!0,t.ImageManager.recycle(s),s.loading&&(r||(r=i.__input&&i.__input[e]||[],r instanceof Array||(r=[r])),s.unload(n[h].loadId,!r.some((t=>t.url===a)))));return o}return null},createData:ct,getPatternData:ut,fillOrFitMode:nt,clipMode:st,repeatMode:ot},{toPoint:Tt}=t.AroundHelper,St={},Ot={};function At(t,e,n){if(e){let s;for(let o=0,r=e.length;o<r;o++)s=e[o],"string"==typeof s?t.addColorStop(o/(r-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}}const{getAngle:Dt,getDistance:Wt}=t.PointHelper,{get:It,rotateOfOuter:Ht,scaleOfOuter:Ft}=t.MatrixHelper,{toPoint:jt}=t.AroundHelper,zt={},Gt={};function Yt(t,e,i,n,s){let o;const{width:r,height:a}=t;if(r!==a||n){const t=Dt(e,i);o=It(),s?(Ft(o,e,r/a*(n||1),1),Ht(o,e,t+90)):(Ft(o,e,1,r/a*(n||1)),Ht(o,e,t))}return o}const{getDistance:Ut}=t.PointHelper,{toPoint:Vt}=t.AroundHelper,Nt={},Xt={};const qt={linearGradient:function(e,i){let{from:n,to:s,type:o,blendMode:r,opacity:a}=e;Tt(n||"top",i,St),Tt(s||"bottom",i,Ot);const h=t.Platform.canvas.createLinearGradient(St.x,St.y,Ot.x,Ot.y);At(h,e.stops,a);const l={type:o,style:h};return r&&(l.blendMode=r),l},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,blendMode:a,stretch:h}=e;jt(n||"center",i,zt),jt(s||"bottom",i,Gt);const l=t.Platform.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,Wt(zt,Gt));At(l,e.stops,r);const d={type:o,style:l},c=Yt(i,zt,Gt,h,!0);return c&&(d.transform=c),a&&(d.blendMode=a),d},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:r,blendMode:a,stretch:h}=e;Vt(n||"center",i,Nt),Vt(s||"bottom",i,Xt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Nt.x,Nt.y):t.Platform.canvas.createRadialGradient(Nt.x,Nt.y,0,Nt.x,Nt.y,Ut(Nt,Xt));At(l,e.stops,r);const d={type:o,style:l},c=Yt(i,Nt,Xt,h||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),a&&(d.blendMode=a),d},getTransform:Yt},{copy:Kt,toOffsetOutBounds:Qt}=t.BoundsHelper,$t={},Jt={};function Zt(e,i,n,s){const{bounds:o,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Kt($t,e.bounds),$t.x+=i.x-r.x,$t.y+=i.y-r.y,n){const{matrix:t}=s;$t.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),$t.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),$t.width*=n,$t.height*=n}e.copyWorld(s.canvas,e.bounds,$t)}else n&&(Kt($t,i),$t.x-=i.width/2*(n-1),$t.y-=i.height/2*(n-1),$t.width*=n,$t.height*=n),e.copyWorld(s.canvas,r,n?$t:i)}const{toOffsetOutBounds:te}=t.BoundsHelper,ee={};const ie={shadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:r}=t,{shadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;Qt(l,Jt),a.forEach(((a,g)=>{p.setWorldShadow(Jt.offsetX+a.x*c,Jt.offsetY+a.y*u,a.blur*c,a.color),s=a.spread?1+2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Zt(p,Jt,s,i),n=l,a.box&&(p.restore(),p.save(),h&&(p.copyWorld(p,l,o,"copy"),n=o),h?p.copyWorld(h,o,o,"destination-out"):p.copyWorld(i.canvas,d,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,n,o,a.blendMode):e.copyWorldToInner(p,n,r.renderBounds,a.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:o,__layout:r}=t,{innerShadow:a}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,p=e.getSameCanvas(),f=a.length-1;te(l,ee),a.forEach(((a,g)=>{p.save(),p.setWorldShadow(ee.offsetX+a.x*c,ee.offsetY+a.y*u,a.blur*c),s=a.spread?1-2*a.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Zt(p,ee,s,i),p.restore(),h?(p.copyWorld(p,l,o,"copy"),p.copyWorld(h,o,o,"source-out"),n=o):(p.copyWorld(i.canvas,d,l,"source-out"),n=l),p.fillWorld(n,a.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(p,n,o,a.blendMode):e.copyWorldToInner(p,n,r.renderBounds,a.blendMode),f&&g<f&&p.clearWorld(n,!0)})),p.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:ne}=t.LeafBoundsHelper;function se(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),re(t,e,i,1)}(t,i,n,s);break;case"opacity-path":re(t,i,n,o);break;case"path":i.restore()}}function oe(t){return t.getSameCanvas(!1,!0)}function re(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let i,n,s,o,r,a;const{children:h}=this;for(let l=0,d=h.length;l<d;l++)i=h[l],a=i.__.mask,a&&(r&&(se(this,r,t,s,n,o),n=s=null),"path"===a||"clipping-path"===a?(i.opacity<1?(r="opacity-path",o=i.opacity,s||(s=oe(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===a?"grayscale":"alpha",n||(n=oe(t)),s||(s=oe(t)),i.__render(n,e)),"clipping"!==a&&"clipping-path"!==a)||ne(i,e)||i.__render(s||t,e);se(this,r,t,s,n,o)};const ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",he=ae+"_#~&*+\\=|≮≯≈≠=…",le=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function de(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ce=de("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ue=de("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),pe=de(ae),fe=de(he),ge=de("- —/~|┆·");var _e;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(_e||(_e={}));const{Letter:we,Single:ve,Before:me,After:ye,Symbol:xe,Break:be}=_e;function Be(t){return ce[t]?we:ge[t]?be:ue[t]?me:pe[t]?ye:fe[t]?xe:le.test(t)?ve:we}const Le={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Ee(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Pe}=Le,{Letter:Re,Single:Ce,Before:ke,After:Me,Symbol:Te,Break:Se}=_e;let Oe,Ae,De,We,Ie,He,Fe,je,ze,Ge,Ye,Ue,Ve,Ne,Xe,qe,Ke,Qe=[];function $e(t,e){ze&&!je&&(je=ze),Oe.data.push({char:t,width:e}),De+=e}function Je(){We+=De,Oe.width=De,Ae.words.push(Oe),Oe={data:[]},De=0}function Ze(){Ne&&(Xe.paraNumber++,Ae.paraStart=!0,Ne=!1),ze&&(Ae.startCharSize=je,Ae.endCharSize=ze,je=0),Ae.width=We,qe.width?Pe(Ae):Ke&&ti(),Qe.push(Ae),Ae={words:[]},We=0}function ti(){We>(Xe.maxWidth||0)&&(Xe.maxWidth=We)}const ei=0,ii=1,ni=2;const{top:si,right:oi,bottom:ri,left:ai}=t.Direction4;function hi(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const li={getDrawData:function(e,i){"string"!=typeof e&&(e=String(e));let n=0,s=0,o=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:a,__font:h,__padding:l}=i;l&&(o?(n=l[ai],o-=l[oi]+l[ai]):i.autoSizeAlign||(n=l[ai]),r?(s=l[si],r-=l[si]+l[ri]):i.autoSizeAlign||(s=l[si]));const d={bounds:{x:n,y:s,width:o,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=h};return function(e,i,n){Xe=e,Qe=e.rows,qe=e.bounds,Ke=!qe.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:r}=n,{canvas:a}=t.Platform,{width:h,height:l}=qe;if(h||l||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Ne=!0,Ye=null,je=Fe=ze=De=We=0,Oe={data:[]},Ae={words:[]};for(let n=0,l=i.length;n<l;n++)He=i[n],"\n"===He?(De&&Je(),Ae.paraEnd=!0,Ze(),Ne=!0):(Ge=Be(He),Ge===Re&&"none"!==r&&(He=Ee(He,r,!De)),Fe=a.measureText(He).width,s&&(s<0&&(ze=Fe),Fe+=s),Ue=Ge===Ce&&(Ye===Ce||Ye===Re)||Ye===Ce&&Ge!==Me,Ve=!(Ge!==ke&&Ge!==Ce||Ye!==Te&&Ye!==Me),Ie=Ne&&o?h-o:h,t&&h&&We+De+Fe>Ie&&(e?(De&&Je(),We&&Ze()):(Ve||(Ve=Ge===Re&&Ye==Me),Ue||Ve||Ge===Se||Ge===ke||Ge===Ce||De+Fe>Ie?(De&&Je(),We&&Ze()):We&&Ze()))," "===He&&!0!==Ne&&We+De===0||(Ge===Se?(" "===He&&De&&Je(),$e(He,Fe),Je()):Ue||Ve?(De&&Je(),$e(He,Fe)):$e(He,Fe)),Ye=Ge);De&&Je(),We&&Ze(),Qe.length>0&&(Qe[Qe.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Xe.paraNumber++,We=a.measureText(t).width,Qe.push({x:o||0,text:t,width:We,paraStart:!0}),Ke&&ti()}))}(d,e,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":hi(e,"x",t[ai]);break;case"right":hi(e,"x",-t[oi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":hi(e,"y",t[si]);break;case"bottom":hi(e,"y",-t[ri])}}(l,d,i,o,r),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:r,__clipText:a,textAlign:h,verticalAlign:l,paraSpacing:d,autoSizeAlign:c}=e;let{x:u,y:p,width:f,height:g}=n,_=s*i.length+(d?d*(t.paraNumber-1):0),w=o;if(a&&_>g)_=Math.max(g,s),t.overflow=i.length;else if(g||c)switch(l){case"middle":p+=(g-_)/2;break;case"bottom":p+=g-_}w+=p;let v,m,y,x=f||c?f:t.maxWidth;for(let o=0,l=i.length;o<l;o++){if(v=i[o],v.x=u,v.width<f||v.width>f&&!a)switch(h){case"center":v.x+=(x-v.width)/2;break;case"right":v.x+=x-v.width}v.paraStart&&d&&o>0&&(w+=d),v.y=w,w+=s,t.overflow>o&&w>_&&(v.isOverflow=!0,t.overflow=o+1),m=v.x,y=v.width,r<0&&(v.width<0?(y=-v.width+e.fontSize+r,m-=y,y+=e.fontSize):y-=r),m<n.x&&(n.x=m),y>n.width&&(n.width=y),a&&f&&f<y&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=_}(d,i),function(t,e,i,n){const{rows:s}=t,{textAlign:o,paraIndent:r,letterSpacing:a}=e;let h,l,d,c,u;s.forEach((t=>{t.words&&(d=r&&t.paraStart?r:0,l=i&&"justify"===o&&t.words.length>1?(i-t.width-d)/(t.words.length-1):0,c=a||t.isOverflow?ei:l>.01?ii:ni,t.isOverflow&&!a&&(t.textMode=!0),c===ni?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,h=t.x,t.data=[],t.words.forEach((e=>{c===ii?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&l&&(h+=l,t.width+=l)}))),t.words=null)}))}(d,i,o),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:o,overflow:r}=e;let{textOverflow:a}=i;if(o.splice(r),a&&"show"!==a){let e,h;"hide"===a?a="":"ellipsis"===a&&(a="...");const l=a?t.Platform.canvas.measureText(a).width:0,d=n+s-l;("none"===i.textWrap?o:[o[r-1]]).forEach((t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],h=e.x+e.width,!(n===i&&h<d));n--){if(h<d&&" "!==e.char){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:a,x:h}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,i,n,o),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(d,i),d}};const di={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}},{setPoint:ci,addPoint:ui,toBounds:pi}=t.TwoPointBoundsHelper;const fi={export(e,i,n){this.running=!0;const s=t.FileHelper.fileType(i),o=i.includes(".");return n=t.FileHelper.getExportOptions(n),function(e){gi||(gi=new t.TaskProcessor);return new Promise((t=>{gi.add((()=>Ct(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((r=>new Promise((a=>{const h=t=>{r(t),a(),this.running=!1},{toURL:l}=t.Platform,{download:d}=t.Platform.origin;if("json"===s)return o&&d(l(JSON.stringify(e.toJSON(n.json)),"text"),i),h({data:!!o||e.toJSON(n.json)});if("svg"===s)return o&&d(l(e.toSVG(),"svg"),i),h({data:!!o||e.toSVG()});const{leafer:c}=e;c?(_i(e),c.waitViewCompleted((()=>Ct(this,void 0,void 0,(function*(){let s,o,r=1,a=1;const{worldTransform:l,isLeafer:d,isFrame:u}=e,{slice:p,trim:f,onCanvas:g}=n,_=void 0===n.smooth?c.config.smooth:n.smooth,w=n.contextSettings||c.config.contextSettings,v=n.screenshot||e.isApp,m=d&&v&&void 0===n.fill?e.fill:n.fill,y=t.FileHelper.isOpaqueImage(i)||m,x=new t.Matrix;if(v)s=!0===v?d?c.canvas.bounds:e.worldRenderBounds:v;else{let t=n.relative||(d?"inner":"local");switch(r=l.scaleX,a=l.scaleY,t){case"inner":x.set(l);break;case"local":x.set(l).divide(e.localTransform),r/=e.scaleX,a/=e.scaleY;break;case"world":r=1,a=1;break;case"page":t=e.leafer;default:x.set(l).divide(e.getTransform(t));const i=t.worldTransform;r/=r/i.scaleX,a/=a/i.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(n.scale,n.size,s,b);let B=n.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:L,y:E,width:P,height:R}=new t.Bounds(s).scale(b.scaleX,b.scaleY),C={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-L,-E).withScale(1/r*b.scaleX,1/a*b.scaleY)};let k,M=t.Creator.canvas({width:Math.round(P),height:Math.round(R),pixelRatio:B,smooth:_,contextSettings:w});if(p&&(k=e,k.__worldOpacity=0,e=c,C.bounds=M.bounds),M.save(),u&&void 0!==m){const t=e.get("fill");e.fill="",e.__render(M,C),e.fill=t}else e.__render(M,C);if(M.restore(),k&&k.__updateWorldOpacity(),f){o=function(e){const{width:i,height:n}=e.view,{data:s}=e.context.getImageData(0,0,i,n);let o,r,a,h=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(o=h%i,r=(h-o)/i,a?ui(a,o,r):ci(a={},o,r)),h++;const l=new t.Bounds;return pi(a,l),l.scale(1/e.pixelRatio).ceil()}(M);const e=M,{width:i,height:n}=o,s={x:0,y:0,width:i,height:n,pixelRatio:B};M=t.Creator.canvas(s),M.copyWorld(e,o,s)}y&&M.fillWorld(M.bounds,m||"#FFFFFF","destination-over"),g&&g(M);const T="canvas"===i?M:yield M.export(i,n);h({data:T,width:M.pixelWidth,height:M.pixelHeight,renderBounds:s,trimBounds:o})}))))):h({data:!1})}))))}};let gi;function _i(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>_i(t)))}const wi=t.LeaferCanvasBase.prototype,vi=t.Debug.get("@leafer-ui/export");wi.export=function(e,i){const{quality:n,blob:s}=t.FileHelper.getExportOptions(i);return e.includes(".")?this.saveAs(e,n):s?this.toBlob(e,n):this.toDataURL(e,n)},wi.toBlob=function(e,i){return new Promise((n=>{t.Platform.origin.canvasToBolb(this.view,e,i).then((t=>{n(t)})).catch((t=>{vi.error(t),n(null)}))}))},wi.toDataURL=function(e,i){return t.Platform.origin.canvasToDataURL(this.view,e,i)},wi.saveAs=function(e,i){return new Promise((n=>{t.Platform.origin.canvasSaveAs(this.view,e,i).then((()=>{n(!0)})).catch((t=>{vi.error(t),n(!1)}))}))},Object.assign(i.TextConvert,li),Object.assign(i.ColorConvert,di),Object.assign(i.Paint,K),Object.assign(i.PaintImage,Mt),Object.assign(i.PaintGradient,qt),Object.assign(i.Effect,ie),Object.assign(i.Export,fi),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new W(t,e,i,n),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=W,exports.Layouter=x,exports.LeaferCanvas=s,exports.Renderer=B,exports.Selector=S,exports.Watcher=l,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|