@leafer-ui/node 1.3.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.min.cjs CHANGED
@@ -1 +1,2 @@
1
- "use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/core"),i=require("@leafer-ui/draw");function a(t,e,n,i){return new(n||(n=Promise))((function(a,s){function o(t){try{l(i.next(t))}catch(t){s(t)}}function r(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:o,fileType:r}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new s(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){setTimeout(t,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1}),t.Platform.conicGradientSupport=!0;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,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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,n=e.length;t<n;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:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{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,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),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:w,updateAllChange:y}=t.LeafHelper,m=t.Debug.get("Layouter");class v{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.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 n=t.Run.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:s,LAYOUT:o,AFTER:r}=t.LayoutEvent,l=this.getBlocks(a);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(s,l,this.times)),this.extraBlock=null,a.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||h(i[t])}h(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&c(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(a),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:s}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),v.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,o,this.times)),n.emitEvent(new t.LayoutEvent(s,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),y(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(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 x=t.Debug.get("Renderer");class b{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,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:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.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;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,a=e.getIntersect(i.bounds),s=e.includes(this.target.__world),o=new t.Bounds(a);i.save(),s&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,s,o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const a=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__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:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).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||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__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:B}=t.BoundsHelper;class L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const a=i.through||!1,s=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),a?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:a,y:s}=this.point,o={x:a,y:s,radiusX:0,radiusY:0};for(let a=0,s=e.length;a<s;a++)if(n=e[a],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,o),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return this.target&&n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,a=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(a.addAt(i,0),i.__.hitChildren);t--);return a}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let a,s,o;for(let t=0,e=i.length;t<e;t++){a=i[t],s=i[t+1];for(let t=0,e=a.length;t<e&&(o=a.list[t],!s||!s.has(o));t++)n.add(o)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:a}=this;for(let s=t.length-1;s>-1;s--)n=t[s],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||B(n.__world,a),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,a)):i&&this.hitChild(n,a))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class E{constructor(e,n){this.config={},n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new L(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,n,i){return t.Platform.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(e,n,i)}getBy(e,n,i,a){return this.finder?this.finder.getBy(e,n,i,a):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function R(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),a&&e.fillRect(n.x,n.y+a,n.width,s)}function k(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?C(t,!0,e,n):S(e,n);break;case"inside":P("inside",t,a,e,n);break;case"outside":P("outside",t,a,e,n)}}function P(t,e,n,i,a){const{__strokeWidth:s,__font:o}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*s,i.__),r.font=o,n?C(e,!0,i,r):S(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",R(i,r),r.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(r,i.__nowWorld):a.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function S(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),a&&e.strokeRect(n.x,n.y+a,n.width,s)}function C(t,e,n,a){let s;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&i.PaintImage.checkImage(n,a,s,!1)||s.style&&(a.strokeStyle=s.style,s.blendMode?(a.saveBlendMode(s.blendMode),e?S(n,a):a.stroke(),a.restoreBlendMode()):e?S(n,a):a.stroke())}function A(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>new E(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:W,getOuterOf:O,getByMove:T,getIntersectData:M}=t.BoundsHelper;let I;function D(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:a}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:r,opacity:l}=e;return{type:s,blendMode:o,style:i.ColorConvert.string(r,l)};case"image":return i.PaintImage.image(n,t,e,a,!I||!I[e.url]);case"linear":return i.PaintGradient.linearGradient(e,a);case"radial":return i.PaintGradient.radialGradient(e,a);case"angular":return i.PaintGradient.conicGradient(e,a);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const H={compute:function(t,e){const n=e.__,a=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),I=i.PaintImage.recycleImage(t,n);for(let n,i=0,s=o.length;i<s;i++)n=D(t,o[i],e),n&&a.push(n);n["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(s=a[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?R(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let a;const{windingRule:s,__font:o}=e.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&i.PaintImage.checkImage(e,n,a,!o)||a.style&&(n.fillStyle=a.style,a.transform?(n.save(),n.transform(a.transform),a.blendMode&&(n.blendMode=a.blendMode),o?R(e,n):s?n.fill(s):n.fill(),n.restore()):a.blendMode?(n.saveBlendMode(a.blendMode),o?R(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?R(e,n):s?n.fill(s):n.fill())},fillText:R,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)k(t,e,n);else switch(s){case"center":n.setStroke(t,a,i),n.stroke(),i.__useArrow&&A(e,n);break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const s=n.getSameCanvas(!0,!0);s.setStroke(t,2*a,i),e.__drawRenderPath(s),s.stroke(),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,e.__layout.renderBounds),s.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)k(t,e,n);else switch(s){case"center":n.setStroke(void 0,a,i),C(t,!1,e,n),i.__useArrow&&A(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),C(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:s}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*a,i),C(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(s),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,s),o.recycle(e.__nowWorld)}},strokeText:k,drawTextStroke:S,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let s,o,r,l,{scaleX:d,scaleY:h}=a;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(a))l=i,s=r=a;else{const{renderShapeSpread:i}=t.__layout,c=M(i?W(e.bounds,d===h?i*d:[i*h,i*d]):e.bounds,a);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,h*=f),r=O(a,o),s=T(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:s,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:h}}};let F={};const{get:Y,rotateOfOuter:j,translate:U,scaleOfOuter:G,scale:X,rotate:N}=t.MatrixHelper;function q(t,e,n,i,a,s,o){const r=Y();U(r,e.x+n,e.y+i),X(r,a,s),o&&j(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function z(t,e,n,i,a,s,o){const r=Y();U(r,e.x+n,e.y+i),a&&X(r,a,s),o&&N(r,o),t.transform=r}function V(t,e,n,i,a,s,o,r,l,d){const h=Y();if(l)if("center"===d)j(h,{x:n/2,y:i/2},l);else switch(N(h,l),l){case 90:U(h,i,0);break;case 180:U(h,n,i);break;case 270:U(h,0,n)}F.x=e.x+a,F.y=e.y+s,U(h,F.x,F.y),o&&G(h,F,o,r),t.transform=h}const{get:Q,translate:J}=t.MatrixHelper,Z=new t.Bounds,K={},$={};function tt(t,e,n,i){const{blendMode:a,sync:s}=n;a&&(t.blendMode=a),s&&(t.sync=s),t.data=et(n,i,e)}function et(e,n,i){let{width:a,height:s}=i;e.padding&&(n=Z.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:l,offset:d,scale:h,size:c,rotation:u,repeat:f}=e,p=n.width===a&&n.height===s,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?s:a,y=_?a:s;let m,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(h||c)&&(t.MathHelper.getScaleData(h,c,i,$),m=$.scaleX,v=$.scaleY);else if(!p||u){const t=n.width/w,e=n.height/y;m=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-a*m)/2,b+=(n.height-s*v)/2}if(l){const e={x:x,y:b,width:w,height:y};m&&(e.width*=m,e.height*=v),t.AlignHelper.toPoint(l,e,n,K,!0),x+=K.x,b+=K.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(a=n.width,s=n.height);break;case"normal":case"clip":(x||b||m||u)&&z(g,n,x,b,m,v,u);break;case"repeat":(!p||m||u)&&V(g,n,a,s,x,b,m,v,u,l),f||(g.repeat="repeat");break;default:m&&q(g,n,x,b,m,v,u)}return g.transform||(n.x||n.y)&&(g.transform=Q(),J(g.transform,n.x,n.y)),m&&"stretch"!==r&&(g.scaleX=m,g.scaleY=v),g.width=a,g.height=s,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let nt,it=new t.Bounds;const{isSame:at}=t.BoundsHelper;function st(t,e,n,i,a,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||tt(a,i,n,s),!0}function ot(e,n){dt(e,t.ImageEvent.LOAD,n)}function rt(e,n){dt(e,t.ImageEvent.LOADED,n)}function lt(e,n,i){n.error=i,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,n)}function dt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ht(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ct,scale:ut,copy:ft}=t.MatrixHelper,{ceil:pt,abs:gt}=Math;function _t(e,n,i){let{scaleX:a,scaleY:s}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=a+"-"+s+"-"+i;if(n.patternId===o||e.destroyed)return!1;{a=gt(a),s=gt(s);const{image:e,data:r}=n;let l,d,{width:h,height:c,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=ct(),ft(d,g),ut(d,1/u,1/f),a*=u,s*=f),a*=i,s*=i,h*=a,c*=s;const w=h*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(l=Math.sqrt(w/y)),l&&(a/=l,s/=l,h/=l,c/=l),u&&(a/=u,s/=f),(g||1!==a||1!==s)&&(d||(d=ct(),g&&ft(d,g)),ut(d,1/a,1/s));const m=e.getCanvas(pt(h)||1,pt(c)||1,p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=o,!0}}const{abs:wt}=Math;const yt={image:function(e,n,i,a,s){let o,r;const l=t.ImageManager.get(i);return nt&&i===nt.paint&&at(a,nt.boxBounds)?o=nt.leafPaint:(o={type:i.type,image:l},nt=l.use>1?{leafPaint:o,paint:i,boxBounds:it.set(a)}:null),(s||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(st(e,n,i,l,o,a),s&&(ot(e,r),rt(e,r))):l.error?s&&lt(e,r,l.error):(s&&(ht(e,!0),ot(e,r)),o.loadId=l.load((()=>{ht(e,!1),e.destroyed||(st(e,n,i,l,o,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),rt(e,r)),o.loadId=null}),(t=>{ht(e,!1),lt(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,s,o){const{scaleX:r,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=n;if(!s.data||s.patternId===r+"-"+l+"-"+d&&!i.Export.running)return!1;{const{data:h}=s;if(o)if(h.repeat)o=!1;else{let{width:e,height:n}=h;e*=wt(r)*d,n*=wt(l)*d,h.scaleX&&(e*=h.scaleX,n*=h.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),h.opacity&&(n.opacity*=h.opacity),h.transform&&n.transform(h.transform),n.drawImage(s.image.view,0,0,h.width,h.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?_t(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>a(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&_t(e,s,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:_t,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,s,o,r;for(let l=0,d=i.length;l<d;l++)a=i[l].image,r=a&&a.url,r&&(s||(s={}),s[r]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),a.unload(i[l].loadId,!o.some((t=>t.url===r)))));return s}return null},createData:tt,getPatternData:et,fillOrFitMode:q,clipMode:z,repeatMode:V},{toPoint:mt}=t.AroundHelper,vt={},xt={};function bt(t,e,n){if(e){let a;for(let s=0,o=e.length;s<o;s++)a=e[s],"string"==typeof a?t.addColorStop(s/(o-1),i.ColorConvert.string(a,n)):t.addColorStop(a.offset,i.ColorConvert.string(a.color,n))}}const{getAngle:Bt,getDistance:Lt}=t.PointHelper,{get:Et,rotateOfOuter:Rt,scaleOfOuter:kt}=t.MatrixHelper,{toPoint:Pt}=t.AroundHelper,St={},Ct={};function At(t,e,n,i,a){let s;const{width:o,height:r}=t;if(o!==r||i){const t=Bt(e,n);s=Et(),a?(kt(s,e,o/r*(i||1),1),Rt(s,e,t+90)):(kt(s,e,1,o/r*(i||1)),Rt(s,e,t))}return s}const{getDistance:Wt}=t.PointHelper,{toPoint:Ot}=t.AroundHelper,Tt={},Mt={};const It={linearGradient:function(e,n){let{from:i,to:a,type:s,blendMode:o,opacity:r}=e;mt(i||"top",n,vt),mt(a||"bottom",n,xt);const l=t.Platform.canvas.createLinearGradient(vt.x,vt.y,xt.x,xt.y);bt(l,e.stops,r);const d={type:s,style:l};return o&&(d.blendMode=o),d},radialGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:l}=e;Pt(i||"center",n,St),Pt(a||"bottom",n,Ct);const d=t.Platform.canvas.createRadialGradient(St.x,St.y,0,St.x,St.y,Lt(St,Ct));bt(d,e.stops,o);const h={type:s,style:d},c=At(n,St,Ct,l,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:l}=e;Ot(i||"center",n,Tt),Ot(a||"bottom",n,Mt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Tt.x,Tt.y):t.Platform.canvas.createRadialGradient(Tt.x,Tt.y,0,Tt.x,Tt.y,Wt(Tt,Mt));bt(d,e.stops,o);const h={type:s,style:d},c=At(n,Tt,Mt,l||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:At},{copy:Dt,toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={},Yt={};function jt(e,n,i,a){const{bounds:s,shapeBounds:o}=a;if(t.Platform.fullImageShadow){if(Dt(Ft,e.bounds),Ft.x+=n.x-o.x,Ft.y+=n.y-o.y,i){const{matrix:t}=a;Ft.x-=(s.x+(t?t.e:0)+s.width/2)*(i-1),Ft.y-=(s.y+(t?t.f:0)+s.height/2)*(i-1),Ft.width*=i,Ft.height*=i}e.copyWorld(a.canvas,e.bounds,Ft)}else i&&(Dt(Ft,n),Ft.x-=n.width/2*(i-1),Ft.y-=n.height/2*(i-1),Ft.width*=i,Ft.height*=i),e.copyWorld(a.canvas,o,i?Ft:n)}const{toOffsetOutBounds:Ut}=t.BoundsHelper,Gt={};const Xt={shadow:function(t,e,n){let a,s;const{__nowWorld:o,__layout:r}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Ht(h,Yt),l.forEach(((l,_)=>{p.setWorldShadow(Yt.offsetX+l.x*u,Yt.offsetY+l.y*f,l.blur*u,i.ColorConvert.string(l.color)),s=l.spread?1+2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,jt(p,Yt,s,n),a=h,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,h,o,"copy"),a=o),d?p.copyWorld(d,o,o,"destination-out"):p.copyWorld(n.canvas,c,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,a,o,l.blendMode):e.copyWorldToInner(p,a,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(a,!0)})),p.recycle(a)},innerShadow:function(t,e,n){let a,s;const{__nowWorld:o,__layout:r}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Ut(h,Gt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Gt.offsetX+l.x*u,Gt.offsetY+l.y*f,l.blur*u),s=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,jt(p,Gt,s,n),p.restore(),d?(p.copyWorld(p,h,o,"copy"),p.copyWorld(d,o,o,"source-out"),a=o):(p.copyWorld(n.canvas,c,h,"source-out"),a=h),p.fillWorld(a,i.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(p,a,o,l.blendMode):e.copyWorldToInner(p,a,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(a,!0)})),p.recycle(a)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Nt}=t.LeafBoundsHelper;function qt(t,e,n,i,a,s){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Vt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Vt(t,n,i,s);break;case"path":n.restore()}}function zt(t){return t.getSameCanvas(!1,!0)}function Vt(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}i.Group.prototype.__renderMask=function(t,e){let n,i,a,s,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)n=l[d],r=n.__.mask,r&&(o&&(qt(this,o,t,a,i,s),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",s=n.opacity,a||(a=zt(t))):(o="path",t.save()),n.__clip(a||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=zt(t)),a||(a=zt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Nt(n,e)||n.__render(a||t,e);qt(this,o,t,a,i,s)};const Qt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Jt=Qt+"_#~&*+\\=|≮≯≈≠=…",Zt=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 Kt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $t=Kt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),te=Kt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ee=Kt(Qt),ne=Kt(Jt),ie=Kt("- —/~|┆·");var ae;!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"}(ae||(ae={}));const{Letter:se,Single:oe,Before:re,After:le,Symbol:de,Break:he}=ae;function ce(t){return $t[t]?se:ie[t]?he:te[t]?re:ee[t]?le:ne[t]?de:Zt.test(t)?oe:se}const ue={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let s=a-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function fe(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:pe}=ue,{Letter:ge,Single:_e,Before:we,After:ye,Symbol:me,Break:ve}=ae;let xe,be,Be,Le,Ee,Re,ke,Pe,Se,Ce,Ae,We,Oe,Te,Me,Ie,De,He=[];function Fe(t,e){Se&&!Pe&&(Pe=Se),xe.data.push({char:t,width:e}),Be+=e}function Ye(){Le+=Be,xe.width=Be,be.words.push(xe),xe={data:[]},Be=0}function je(){Te&&(Me.paraNumber++,be.paraStart=!0,Te=!1),Se&&(be.startCharSize=Pe,be.endCharSize=Se,Pe=0),be.width=Le,Ie.width?pe(be):De&&Ue(),He.push(be),be={words:[]},Le=0}function Ue(){Le>(Me.maxWidth||0)&&(Me.maxWidth=Le)}const{top:Ge,right:Xe,bottom:Ne,left:qe}=t.Direction4;function ze(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const Ve={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,s=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(s?(i=d[qe],s-=d[Xe]+d[qe]):n.autoSizeAlign||(i=d[qe]),o?(a=d[Ge],o-=d[Ge]+d[Ne]):n.autoSizeAlign||(a=d[Ge]));const h={bounds:{x:i,y:a,width:s,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Me=e,He=e.rows,Ie=e.bounds,De=!Ie.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:s,textCase:o}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ie;if(l||d||a||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Te=!0,Ae=null,Pe=ke=Se=Be=Le=0,xe={data:[]},be={words:[]};for(let i=0,d=n.length;i<d;i++)Re=n[i],"\n"===Re?(Be&&Ye(),be.paraEnd=!0,je(),Te=!0):(Ce=ce(Re),Ce===ge&&"none"!==o&&(Re=fe(Re,o,!Be)),ke=r.measureText(Re).width,a&&(a<0&&(Se=ke),ke+=a),We=Ce===_e&&(Ae===_e||Ae===ge)||Ae===_e&&Ce!==ye,Oe=!(Ce!==we&&Ce!==_e||Ae!==me&&Ae!==ye),Ee=Te&&s?l-s:l,t&&l&&Le+Be+ke>Ee&&(e?(Be&&Ye(),Le&&je()):(Oe||(Oe=Ce===ge&&Ae==ye),We||Oe||Ce===ve||Ce===we||Ce===_e||Be+ke>Ee?(Be&&Ye(),Le&&je()):Le&&je()))," "===Re&&!0!==Te&&Le+Be===0||(Ce===ve?(" "===Re&&Be&&Ye(),Fe(Re,ke),Ye()):We||Oe?(Be&&Ye(),Fe(Re,ke)):Fe(Re,ke)),Ae=Ce);Be&&Ye(),Le&&je(),He.length>0&&(He[He.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Me.paraNumber++,Le=r.measureText(t).width,He.push({x:s||0,text:t,width:Le,paraStart:!0}),De&&Ue()}))}(h,e,n),d&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":ze(e,"x",t[qe]);break;case"right":ze(e,"x",-t[Xe])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":ze(e,"y",t[Ge]);break;case"bottom":ze(e,"y",-t[Ne])}}(d,h,n,s,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:s,__letterSpacing:o,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:p,height:g}=i,_=a*n.length+(h?h*(t.paraNumber-1):0),w=s;if(r&&_>g)_=Math.max(g,a),t.overflow=n.length;else if(g||c)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let y,m,v,x=p||c?p:t.maxWidth;for(let s=0,d=n.length;s<d;s++){if(y=n[s],y.x=u,y.width<p||y.width>p&&!r)switch(l){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&s>0&&(w+=h),y.y=w,w+=a,t.overflow>s&&w>_&&(y.isOverflow=!0,t.overflow=s+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n){const{rows:i}=t,{textAlign:a,paraIndent:s,letterSpacing:o}=e;let r,l,d,h,c;i.forEach((t=>{t.words&&(d=s&&t.paraStart?s:0,l=n&&("justify"===a||"both"===a)&&t.words.length>1?(n-t.width-d)/(t.words.length-1):0,h=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach((e=>{1===h?(c={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==a||(r+=l,t.width+=l)}))),t.words=null)}))}(h,n,s),h.overflow&&function(e,n,i,a){if(!a)return;const{rows:s,overflow:o}=e;let{textOverflow:r}=n;if(s.splice(o),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,h=i+a-d;("none"===n.textWrap?s:[s[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<h));i--){if(l<h&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,i,s),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const Qe={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 a=void 0===t.a?1:t.a;n&&(a*=e);const s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(i.TextConvert,Ve),Object.assign(i.ColorConvert,Qe),Object.assign(i.Paint,H),Object.assign(i.PaintImage,yt),Object.assign(i.PaintGradient,It),Object.assign(i.Effect,Xt);const{setPoint:Je,addPoint:Ze,toBounds:Ke}=i.TwoPointBoundsHelper;const $e={export(t,e,n){this.running=!0;const s=i.FileHelper.fileType(e),o=e.includes(".");return n=i.FileHelper.getExportOptions(n),function(t){tn||(tn=new i.TaskProcessor);return new Promise((e=>{tn.add((()=>a(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((l=>{const d=t=>{r(t),l(),this.running=!1},{toURL:h}=i.Platform,{download:c}=i.Platform.origin;if("json"===s)return o&&c(h(JSON.stringify(t.toJSON(n.json)),"text"),e),d({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&c(h(t.toSVG(),"svg"),e),d({data:!!o||t.toSVG()});const{leafer:u}=t;u?(en(t),u.waitViewCompleted((()=>a(this,void 0,void 0,(function*(){let a,s,o=1,r=1;const{worldTransform:l,isLeafer:h,isFrame:c}=t,{slice:f,trim:p,padding:g,onCanvas:_}=n,w=void 0===n.smooth?u.config.smooth:n.smooth,y=n.contextSettings||u.config.contextSettings,m=n.screenshot||t.isApp,v=h&&m&&void 0===n.fill?t.fill:n.fill,x=i.FileHelper.isOpaqueImage(e)||v,b=new i.Matrix;if(m)a=!0===m?h?u.canvas.bounds:t.worldRenderBounds:m;else{let e=n.relative||(h?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=t.leafer;default:b.set(l).divide(t.getTransform(e));const n=e.worldTransform;o/=o/n.scaleX,r/=r/n.scaleY}a=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};i.MathHelper.getScaleData(n.scale,n.size,a,B);let L=n.pixelRatio||1;t.isApp&&(B.scaleX*=L,B.scaleY*=L,L=t.app.pixelRatio);const{x:E,y:R,width:k,height:P}=new i.Bounds(a).scale(B.scaleX,B.scaleY),S={matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-E,-R).withScale(1/o*B.scaleX,1/r*B.scaleY)};let C,A=i.Creator.canvas({width:Math.round(k),height:Math.round(P),pixelRatio:L,smooth:w,contextSettings:y});if(f&&(C=t,C.__worldOpacity=0,t=u,S.bounds=A.bounds),A.save(),c&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(A,S),t.fill=e}else t.__render(A,S);if(A.restore(),C&&C.__updateWorldOpacity(),p){s=function(t){const{width:e,height:n}=t.view,{data:a}=t.context.getImageData(0,0,e,n);let s,o,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(s=l%e,o=(l-s)/e,r?Ze(r,s,o):Je(r={},s,o)),l++;const d=new i.Bounds;return Ke(r,d),d.scale(1/t.pixelRatio).ceil()}(A);const t=A,{width:e,height:n}=s,a={x:0,y:0,width:e,height:n,pixelRatio:L};A=i.Creator.canvas(a),A.copyWorld(t,s,a)}if(g){const[t,e,n,a]=i.MathHelper.fourNumber(g),s=A,{width:o,height:r}=s;A=i.Creator.canvas({width:o+a+e,height:r+t+n,pixelRatio:L}),A.copyWorld(s,s.bounds,{x:a,y:t,width:o,height:r})}x&&A.fillWorld(A.bounds,v||"#FFFFFF","destination-over"),_&&_(A);const W="canvas"===e?A:yield A.export(e,n);d({data:W,width:A.pixelWidth,height:A.pixelHeight,renderBounds:a,trimBounds:s})}))))):d({data:!1})}))))}};let tn;function en(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>en(t)))}const nn=i.LeaferCanvasBase.prototype,an=i.Debug.get("@leafer-in/export");nn.export=function(t,e){const{quality:n,blob:a}=i.FileHelper.getExportOptions(e);return t.includes(".")?this.saveAs(t,n):a?this.toBlob(t,n):this.toDataURL(t,n)},nn.toBlob=function(t,e){return new Promise((n=>{i.Platform.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{an.error(t),n(null)}))}))},nn.toDataURL=function(t,e){return i.Platform.origin.canvasToDataURL(this.view,t,e)},nn.saveAs=function(t,e){return new Promise((n=>{i.Platform.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{an.error(t),n(!1)}))}))},i.Plugin.add("export"),Object.assign(i.Export,$e),i.UI.prototype.export=function(t,e){return i.Export.export(this,t,e)},Object.assign(t.Creator,{interaction:(t,e,i,a)=>new n.InteractionBase(t,e,i,a),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=s,exports.Picker=L,exports.Renderer=b,exports.Selector=E,exports.Watcher=l,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:e=>n(t.Platform.image.getRealURL(e))},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:s}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(o(e),n),canvasToBolb:(t,e,n)=>a(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,i)=>a(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(r(n)),i))})),download(t,e){},loadImage:e=>s(t.Platform.image.getRealURL(e))}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},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(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/core"),i=require("@leafer-ui/draw");function a(t,e,n,i){return new(n||(n=Promise))((function(a,s){function o(t){try{l(i.next(t))}catch(t){s(t)}}function r(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:o,fileType:r}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new s(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){setTimeout(t,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1}),t.Platform.conicGradientSupport=!0;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,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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,n=e.length;t<n;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:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{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,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),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:w,updateAllChange:y}=t.LeafHelper,m=t.Debug.get("Layouter");class v{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.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 n=t.Run.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:s,LAYOUT:o,AFTER:r}=t.LayoutEvent,l=this.getBlocks(a);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(s,l,this.times)),this.extraBlock=null,a.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||h(i[t])}h(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&c(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(a),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:s}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),v.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,o,this.times)),n.emitEvent(new t.LayoutEvent(s,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),y(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(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 x=t.Debug.get("Renderer");class b{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,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:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.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;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,a=e.getIntersect(i.bounds),s=e.includes(this.target.__world),o=new t.Bounds(a);i.save(),s&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,s,o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const a=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__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:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).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||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__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:B}=t.BoundsHelper;class L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const a=i.through||!1,s=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),a?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:a,y:s}=this.point,o={x:a,y:s,radiusX:0,radiusY:0};for(let a=0,s=e.length;a<s;a++)if(n=e[a],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,o),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return this.target&&n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,a=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(a.addAt(i,0),i.__.hitChildren);t--);return a}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let a,s,o;for(let t=0,e=i.length;t<e;t++){a=i[t],s=i[t+1];for(let t=0,e=a.length;t<e&&(o=a.list[t],!s||!s.has(o));t++)n.add(o)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:a}=this;for(let s=t.length-1;s>-1;s--)n=t[s],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||B(n.__world,a),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,a)):i&&this.hitChild(n,a))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class E{constructor(e,n){this.config={},n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new L(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,n,i){return t.Platform.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(e,n,i)}getBy(e,n,i,a){return this.finder?this.finder.getBy(e,n,i,a):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function R(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),a&&e.fillRect(n.x,n.y+a,n.width,s)}function k(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?C(t,!0,e,n):S(e,n);break;case"inside":P("inside",t,a,e,n);break;case"outside":P("outside",t,a,e,n)}}function P(t,e,n,i,a){const{__strokeWidth:s,__font:o}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*s,i.__),r.font=o,n?C(e,!0,i,r):S(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",R(i,r),r.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(r,i.__nowWorld):a.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function S(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),a&&e.strokeRect(n.x,n.y+a,n.width,s)}function C(t,e,n,a){let s;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&i.PaintImage.checkImage(n,a,s,!1)||s.style&&(a.strokeStyle=s.style,s.blendMode?(a.saveBlendMode(s.blendMode),e?S(n,a):a.stroke(),a.restoreBlendMode()):e?S(n,a):a.stroke())}function A(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>new E(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:W,getOuterOf:O,getByMove:T,getIntersectData:M}=t.BoundsHelper;let I;function D(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:a}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:r,opacity:l}=e;return{type:s,blendMode:o,style:i.ColorConvert.string(r,l)};case"image":return i.PaintImage.image(n,t,e,a,!I||!I[e.url]);case"linear":return i.PaintGradient.linearGradient(e,a);case"radial":return i.PaintGradient.radialGradient(e,a);case"angular":return i.PaintGradient.conicGradient(e,a);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const H={compute:function(t,e){const n=e.__,a=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),I=i.PaintImage.recycleImage(t,n);for(let n,i=0,s=o.length;i<s;i++)n=D(t,o[i],e),n&&a.push(n);n["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(s=a[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?R(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let a;const{windingRule:s,__font:o}=e.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&i.PaintImage.checkImage(e,n,a,!o)||a.style&&(n.fillStyle=a.style,a.transform?(n.save(),n.transform(a.transform),a.blendMode&&(n.blendMode=a.blendMode),o?R(e,n):s?n.fill(s):n.fill(),n.restore()):a.blendMode?(n.saveBlendMode(a.blendMode),o?R(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?R(e,n):s?n.fill(s):n.fill())},fillText:R,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)k(t,e,n);else switch(s){case"center":n.setStroke(t,a,i),n.stroke(),i.__useArrow&&A(e,n);break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const s=n.getSameCanvas(!0,!0);s.setStroke(t,2*a,i),e.__drawRenderPath(s),s.stroke(),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,e.__layout.renderBounds),s.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)k(t,e,n);else switch(s){case"center":n.setStroke(void 0,a,i),C(t,!1,e,n),i.__useArrow&&A(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),C(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:s}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*a,i),C(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(s),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,s),o.recycle(e.__nowWorld)}},strokeText:k,drawTextStroke:S,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let s,o,r,l,{scaleX:d,scaleY:h}=a;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(a))l=i,s=r=a;else{const{renderShapeSpread:i}=t.__layout,c=M(i?W(e.bounds,d===h?i*d:[i*h,i*d]):e.bounds,a);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,h*=f),r=O(a,o),s=T(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:s,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:h}}};let F={};const{get:Y,rotateOfOuter:j,translate:U,scaleOfOuter:G,scale:X,rotate:N}=t.MatrixHelper;function q(t,e,n,i,a,s,o){const r=Y();U(r,e.x+n,e.y+i),X(r,a,s),o&&j(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function z(t,e,n,i,a,s,o){const r=Y();U(r,e.x+n,e.y+i),a&&X(r,a,s),o&&N(r,o),t.transform=r}function V(t,e,n,i,a,s,o,r,l,d){const h=Y();if(l)if("center"===d)j(h,{x:n/2,y:i/2},l);else switch(N(h,l),l){case 90:U(h,i,0);break;case 180:U(h,n,i);break;case 270:U(h,0,n)}F.x=e.x+a,F.y=e.y+s,U(h,F.x,F.y),o&&G(h,F,o,r),t.transform=h}const{get:Q,translate:J}=t.MatrixHelper,Z=new t.Bounds,K={},$={};function tt(t,e,n,i){const{blendMode:a,sync:s}=n;a&&(t.blendMode=a),s&&(t.sync=s),t.data=et(n,i,e)}function et(e,n,i){let{width:a,height:s}=i;e.padding&&(n=Z.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:l,offset:d,scale:h,size:c,rotation:u,repeat:f}=e,p=n.width===a&&n.height===s,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?s:a,y=_?a:s;let m,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(h||c)&&(t.MathHelper.getScaleData(h,c,i,$),m=$.scaleX,v=$.scaleY);else if(!p||u){const t=n.width/w,e=n.height/y;m=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-a*m)/2,b+=(n.height-s*v)/2}if(l){const e={x:x,y:b,width:w,height:y};m&&(e.width*=m,e.height*=v),t.AlignHelper.toPoint(l,e,n,K,!0),x+=K.x,b+=K.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(a=n.width,s=n.height);break;case"normal":case"clip":(x||b||m||u)&&z(g,n,x,b,m,v,u);break;case"repeat":(!p||m||u)&&V(g,n,a,s,x,b,m,v,u,l),f||(g.repeat="repeat");break;default:m&&q(g,n,x,b,m,v,u)}return g.transform||(n.x||n.y)&&(g.transform=Q(),J(g.transform,n.x,n.y)),m&&"stretch"!==r&&(g.scaleX=m,g.scaleY=v),g.width=a,g.height=s,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let nt,it=new t.Bounds;const{isSame:at}=t.BoundsHelper;function st(t,e,n,i,a,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||tt(a,i,n,s),!0}function ot(e,n){dt(e,t.ImageEvent.LOAD,n)}function rt(e,n){dt(e,t.ImageEvent.LOADED,n)}function lt(e,n,i){n.error=i,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,n)}function dt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ht(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ct,scale:ut,copy:ft}=t.MatrixHelper,{ceil:pt,abs:gt}=Math;function _t(e,n,i){let{scaleX:a,scaleY:s}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=a+"-"+s+"-"+i;if(n.patternId===o||e.destroyed)return!1;{a=gt(a),s=gt(s);const{image:e,data:r}=n;let l,d,{width:h,height:c,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=ct(),ft(d,g),ut(d,1/u,1/f),a*=u,s*=f),a*=i,s*=i,h*=a,c*=s;const w=h*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(l=Math.sqrt(w/y)),l&&(a/=l,s/=l,h/=l,c/=l),u&&(a/=u,s/=f),(g||1!==a||1!==s)&&(d||(d=ct(),g&&ft(d,g)),ut(d,1/a,1/s));const m=e.getCanvas(pt(h)||1,pt(c)||1,p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=o,!0}}const{abs:wt}=Math;const yt={image:function(e,n,i,a,s){let o,r;const l=t.ImageManager.get(i);return nt&&i===nt.paint&&at(a,nt.boxBounds)?o=nt.leafPaint:(o={type:i.type,image:l},nt=l.use>1?{leafPaint:o,paint:i,boxBounds:it.set(a)}:null),(s||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(st(e,n,i,l,o,a),s&&(ot(e,r),rt(e,r))):l.error?s&&lt(e,r,l.error):(s&&(ht(e,!0),ot(e,r)),o.loadId=l.load((()=>{ht(e,!1),e.destroyed||(st(e,n,i,l,o,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),rt(e,r)),o.loadId=null}),(t=>{ht(e,!1),lt(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,s,o){const{scaleX:r,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=n;if(!s.data||s.patternId===r+"-"+l+"-"+d&&!i.Export.running)return!1;{const{data:h}=s;if(o)if(h.repeat)o=!1;else{let{width:e,height:n}=h;e*=wt(r)*d,n*=wt(l)*d,h.scaleX&&(e*=h.scaleX,n*=h.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),h.opacity&&(n.opacity*=h.opacity),h.transform&&n.transform(h.transform),n.drawImage(s.image.view,0,0,h.width,h.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?_t(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>a(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&_t(e,s,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:_t,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,s,o,r;for(let l=0,d=i.length;l<d;l++)a=i[l].image,r=a&&a.url,r&&(s||(s={}),s[r]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),a.unload(i[l].loadId,!o.some((t=>t.url===r)))));return s}return null},createData:tt,getPatternData:et,fillOrFitMode:q,clipMode:z,repeatMode:V},{toPoint:mt}=t.AroundHelper,vt={},xt={};function bt(t,e,n){if(e){let a;for(let s=0,o=e.length;s<o;s++)a=e[s],"string"==typeof a?t.addColorStop(s/(o-1),i.ColorConvert.string(a,n)):t.addColorStop(a.offset,i.ColorConvert.string(a.color,n))}}const{getAngle:Bt,getDistance:Lt}=t.PointHelper,{get:Et,rotateOfOuter:Rt,scaleOfOuter:kt}=t.MatrixHelper,{toPoint:Pt}=t.AroundHelper,St={},Ct={};function At(t,e,n,i,a){let s;const{width:o,height:r}=t;if(o!==r||i){const t=Bt(e,n);s=Et(),a?(kt(s,e,o/r*(i||1),1),Rt(s,e,t+90)):(kt(s,e,1,o/r*(i||1)),Rt(s,e,t))}return s}const{getDistance:Wt}=t.PointHelper,{toPoint:Ot}=t.AroundHelper,Tt={},Mt={};const It={linearGradient:function(e,n){let{from:i,to:a,type:s,blendMode:o,opacity:r}=e;mt(i||"top",n,vt),mt(a||"bottom",n,xt);const l=t.Platform.canvas.createLinearGradient(vt.x,vt.y,xt.x,xt.y);bt(l,e.stops,r);const d={type:s,style:l};return o&&(d.blendMode=o),d},radialGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:l}=e;Pt(i||"center",n,St),Pt(a||"bottom",n,Ct);const d=t.Platform.canvas.createRadialGradient(St.x,St.y,0,St.x,St.y,Lt(St,Ct));bt(d,e.stops,o);const h={type:s,style:d},c=At(n,St,Ct,l,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:l}=e;Ot(i||"center",n,Tt),Ot(a||"bottom",n,Mt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Tt.x,Tt.y):t.Platform.canvas.createRadialGradient(Tt.x,Tt.y,0,Tt.x,Tt.y,Wt(Tt,Mt));bt(d,e.stops,o);const h={type:s,style:d},c=At(n,Tt,Mt,l||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:At},{copy:Dt,toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={},Yt={};function jt(e,n,i,a){const{bounds:s,shapeBounds:o}=a;if(t.Platform.fullImageShadow){if(Dt(Ft,e.bounds),Ft.x+=n.x-o.x,Ft.y+=n.y-o.y,i){const{matrix:t}=a;Ft.x-=(s.x+(t?t.e:0)+s.width/2)*(i-1),Ft.y-=(s.y+(t?t.f:0)+s.height/2)*(i-1),Ft.width*=i,Ft.height*=i}e.copyWorld(a.canvas,e.bounds,Ft)}else i&&(Dt(Ft,n),Ft.x-=n.width/2*(i-1),Ft.y-=n.height/2*(i-1),Ft.width*=i,Ft.height*=i),e.copyWorld(a.canvas,o,i?Ft:n)}const{toOffsetOutBounds:Ut}=t.BoundsHelper,Gt={};const Xt={shadow:function(t,e,n){let a,s;const{__nowWorld:o,__layout:r}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Ht(h,Yt),l.forEach(((l,_)=>{p.setWorldShadow(Yt.offsetX+l.x*u,Yt.offsetY+l.y*f,l.blur*u,i.ColorConvert.string(l.color)),s=l.spread?1+2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,jt(p,Yt,s,n),a=h,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,h,o,"copy"),a=o),d?p.copyWorld(d,o,o,"destination-out"):p.copyWorld(n.canvas,c,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,a,o,l.blendMode):e.copyWorldToInner(p,a,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(a,!0)})),p.recycle(a)},innerShadow:function(t,e,n){let a,s;const{__nowWorld:o,__layout:r}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:h,shapeBounds:c,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Ut(h,Gt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Gt.offsetX+l.x*u,Gt.offsetY+l.y*f,l.blur*u),s=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,jt(p,Gt,s,n),p.restore(),d?(p.copyWorld(p,h,o,"copy"),p.copyWorld(d,o,o,"source-out"),a=o):(p.copyWorld(n.canvas,c,h,"source-out"),a=h),p.fillWorld(a,i.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(p,a,o,l.blendMode):e.copyWorldToInner(p,a,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(a,!0)})),p.recycle(a)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Nt}=t.LeafBoundsHelper;function qt(t,e,n,i,a,s){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Vt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Vt(t,n,i,s);break;case"path":n.restore()}}function zt(t){return t.getSameCanvas(!1,!0)}function Vt(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}i.Group.prototype.__renderMask=function(t,e){let n,i,a,s,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)n=l[d],r=n.__.mask,r&&(o&&(qt(this,o,t,a,i,s),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",s=n.opacity,a||(a=zt(t))):(o="path",t.save()),n.__clip(a||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=zt(t)),a||(a=zt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Nt(n,e)||n.__render(a||t,e);qt(this,o,t,a,i,s)};const Qt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Jt=Qt+"_#~&*+\\=|≮≯≈≠=…",Zt=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 Kt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $t=Kt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),te=Kt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ee=Kt(Qt),ne=Kt(Jt),ie=Kt("- —/~|┆·");var ae;!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"}(ae||(ae={}));const{Letter:se,Single:oe,Before:re,After:le,Symbol:de,Break:he}=ae;function ce(t){return $t[t]?se:ie[t]?he:te[t]?re:ee[t]?le:ne[t]?de:Zt.test(t)?oe:se}const ue={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let s=a-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function fe(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:pe}=ue,{Letter:ge,Single:_e,Before:we,After:ye,Symbol:me,Break:ve}=ae;let xe,be,Be,Le,Ee,Re,ke,Pe,Se,Ce,Ae,We,Oe,Te,Me,Ie,De,He=[];function Fe(t,e){Se&&!Pe&&(Pe=Se),xe.data.push({char:t,width:e}),Be+=e}function Ye(){Le+=Be,xe.width=Be,be.words.push(xe),xe={data:[]},Be=0}function je(){Te&&(Me.paraNumber++,be.paraStart=!0,Te=!1),Se&&(be.startCharSize=Pe,be.endCharSize=Se,Pe=0),be.width=Le,Ie.width?pe(be):De&&Ue(),He.push(be),be={words:[]},Le=0}function Ue(){Le>(Me.maxWidth||0)&&(Me.maxWidth=Le)}const{top:Ge,right:Xe,bottom:Ne,left:qe}=t.Direction4;function ze(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const Ve={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,s=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(s?(i=d[qe],s-=d[Xe]+d[qe]):n.autoSizeAlign||(i=d[qe]),o?(a=d[Ge],o-=d[Ge]+d[Ne]):n.autoSizeAlign||(a=d[Ge]));const h={bounds:{x:i,y:a,width:s,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Me=e,He=e.rows,Ie=e.bounds,De=!Ie.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:s,textCase:o}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ie;if(l||d||a||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Te=!0,Ae=null,Pe=ke=Se=Be=Le=0,xe={data:[]},be={words:[]};for(let i=0,d=n.length;i<d;i++)Re=n[i],"\n"===Re?(Be&&Ye(),be.paraEnd=!0,je(),Te=!0):(Ce=ce(Re),Ce===ge&&"none"!==o&&(Re=fe(Re,o,!Be)),ke=r.measureText(Re).width,a&&(a<0&&(Se=ke),ke+=a),We=Ce===_e&&(Ae===_e||Ae===ge)||Ae===_e&&Ce!==ye,Oe=!(Ce!==we&&Ce!==_e||Ae!==me&&Ae!==ye),Ee=Te&&s?l-s:l,t&&l&&Le+Be+ke>Ee&&(e?(Be&&Ye(),Le&&je()):(Oe||(Oe=Ce===ge&&Ae==ye),We||Oe||Ce===ve||Ce===we||Ce===_e||Be+ke>Ee?(Be&&Ye(),Le&&je()):Le&&je()))," "===Re&&!0!==Te&&Le+Be===0||(Ce===ve?(" "===Re&&Be&&Ye(),Fe(Re,ke),Ye()):We||Oe?(Be&&Ye(),Fe(Re,ke)):Fe(Re,ke)),Ae=Ce);Be&&Ye(),Le&&je(),He.length>0&&(He[He.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Me.paraNumber++,Le=r.measureText(t).width,He.push({x:s||0,text:t,width:Le,paraStart:!0}),De&&Ue()}))}(h,e,n),d&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":ze(e,"x",t[qe]);break;case"right":ze(e,"x",-t[Xe])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":ze(e,"y",t[Ge]);break;case"bottom":ze(e,"y",-t[Ne])}}(d,h,n,s,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:s,__letterSpacing:o,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:p,height:g}=i,_=a*n.length+(h?h*(t.paraNumber-1):0),w=s;if(r&&_>g)_=Math.max(g,a),t.overflow=n.length;else if(g||c)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let y,m,v,x=p||c?p:t.maxWidth;for(let s=0,d=n.length;s<d;s++){if(y=n[s],y.x=u,y.width<p||y.width>p&&!r)switch(l){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&s>0&&(w+=h),y.y=w,w+=a,t.overflow>s&&w>_&&(y.isOverflow=!0,t.overflow=s+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n){const{rows:i}=t,{textAlign:a,paraIndent:s,letterSpacing:o}=e;let r,l,d,h,c,u;i.forEach((t=>{t.words&&(d=s&&t.paraStart?s:0,u=t.words.length,l=n&&("justify"===a||"both"===a)&&u>1?(n-t.width-d)/(u-1):0,h=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,n)=>{1===h?(c={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==a||n===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(h,n,s),h.overflow&&function(e,n,i,a){if(!a)return;const{rows:s,overflow:o}=e;let{textOverflow:r}=n;if(s.splice(o),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,h=i+a-d;("none"===n.textWrap?s:[s[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<h));i--){if(l<h&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,i,s),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const Qe={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 a=void 0===t.a?1:t.a;n&&(a*=e);const s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(i.TextConvert,Ve),Object.assign(i.ColorConvert,Qe),Object.assign(i.Paint,H),Object.assign(i.PaintImage,yt),Object.assign(i.PaintGradient,It),Object.assign(i.Effect,Xt);const{setPoint:Je,addPoint:Ze,toBounds:Ke}=i.TwoPointBoundsHelper;const $e={export(t,e,n){this.running=!0;const s=i.FileHelper.fileType(e),o=e.includes(".");return n=i.FileHelper.getExportOptions(n),function(t){tn||(tn=new i.TaskProcessor);return new Promise((e=>{tn.add((()=>a(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((l=>{const d=t=>{r(t),l(),this.running=!1},{toURL:h}=i.Platform,{download:c}=i.Platform.origin;if("json"===s)return o&&c(h(JSON.stringify(t.toJSON(n.json)),"text"),e),d({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&c(h(t.toSVG(),"svg"),e),d({data:!!o||t.toSVG()});const{leafer:u}=t;u?(en(t),u.waitViewCompleted((()=>a(this,void 0,void 0,(function*(){let a,s,o=1,r=1;const{worldTransform:l,isLeafer:h,isFrame:c}=t,{slice:f,trim:p,padding:g,onCanvas:_}=n,w=void 0===n.smooth?u.config.smooth:n.smooth,y=n.contextSettings||u.config.contextSettings,m=n.screenshot||t.isApp,v=h&&m&&void 0===n.fill?t.fill:n.fill,x=i.FileHelper.isOpaqueImage(e)||v,b=new i.Matrix;if(m)a=!0===m?h?u.canvas.bounds:t.worldRenderBounds:m;else{let e=n.relative||(h?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=t.leafer;default:b.set(l).divide(t.getTransform(e));const n=e.worldTransform;o/=o/n.scaleX,r/=r/n.scaleY}a=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};i.MathHelper.getScaleData(n.scale,n.size,a,B);let L=n.pixelRatio||1;t.isApp&&(B.scaleX*=L,B.scaleY*=L,L=t.app.pixelRatio);const{x:E,y:R,width:k,height:P}=new i.Bounds(a).scale(B.scaleX,B.scaleY),S={matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-E,-R).withScale(1/o*B.scaleX,1/r*B.scaleY)};let C,A=i.Creator.canvas({width:Math.round(k),height:Math.round(P),pixelRatio:L,smooth:w,contextSettings:y});if(f&&(C=t,C.__worldOpacity=0,t=u,S.bounds=A.bounds),A.save(),c&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(A,S),t.fill=e}else t.__render(A,S);if(A.restore(),C&&C.__updateWorldOpacity(),p){s=function(t){const{width:e,height:n}=t.view,{data:a}=t.context.getImageData(0,0,e,n);let s,o,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(s=l%e,o=(l-s)/e,r?Ze(r,s,o):Je(r={},s,o)),l++;const d=new i.Bounds;return Ke(r,d),d.scale(1/t.pixelRatio).ceil()}(A);const t=A,{width:e,height:n}=s,a={x:0,y:0,width:e,height:n,pixelRatio:L};A=i.Creator.canvas(a),A.copyWorld(t,s,a)}if(g){const[t,e,n,a]=i.MathHelper.fourNumber(g),s=A,{width:o,height:r}=s;A=i.Creator.canvas({width:o+a+e,height:r+t+n,pixelRatio:L}),A.copyWorld(s,s.bounds,{x:a,y:t,width:o,height:r})}x&&A.fillWorld(A.bounds,v||"#FFFFFF","destination-over"),_&&_(A);const W="canvas"===e?A:yield A.export(e,n);d({data:W,width:A.pixelWidth,height:A.pixelHeight,renderBounds:a,trimBounds:s})}))))):d({data:!1})}))))}};let tn;function en(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>en(t)))}const nn=i.LeaferCanvasBase.prototype,an=i.Debug.get("@leafer-in/export");nn.export=function(t,e){const{quality:n,blob:a}=i.FileHelper.getExportOptions(e);return t.includes(".")?this.saveAs(t,n):a?this.toBlob(t,n):this.toDataURL(t,n)},nn.toBlob=function(t,e){return new Promise((n=>{i.Platform.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{an.error(t),n(null)}))}))},nn.toDataURL=function(t,e){return i.Platform.origin.canvasToDataURL(this.view,t,e)},nn.saveAs=function(t,e){return new Promise((n=>{i.Platform.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{an.error(t),n(!1)}))}))},i.Plugin.add("export"),Object.assign(i.Export,$e),i.UI.prototype.export=function(t,e){return i.Export.export(this,t,e)},Object.assign(t.Creator,{interaction:(t,e,i,a)=>new n.InteractionBase(t,e,i,a),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=s,exports.Picker=L,exports.Renderer=b,exports.Selector=E,exports.Watcher=l,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:e=>n(t.Platform.image.getRealURL(e))},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:s}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(o(e),n),canvasToBolb:(t,e,n)=>a(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,i)=>a(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(r(n)),i))})),download(t,e){},loadImage:e=>s(t.Platform.image.getRealURL(e))}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},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(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
2
+ //# sourceMappingURL=node.min.cjs.map