@leafer-ui/node 1.6.0 → 1.6.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/dist/node.min.cjs CHANGED
@@ -1,2 +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,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(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(s,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class o 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:s,fileType:r}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new o(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:c,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{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(){this.afterBounds.setListWithFn(this.updatedList.list,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:_,updateAllChange:y}=t.LeafHelper,w=t.Debug.get("Layouter");class m{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){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.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:o,LAYOUT:s,AFTER:r}=t.LayoutEvent,l=this.getBlocks(a);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,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||c(i[t])}c(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(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(s,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:o}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,s,this.times)),m.fullLayout(n),s.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,s,this.times)),n.emitEvent(new t.LayoutEvent(o,s,this.times)),this.addBlocks(s),t.Run.end(e)}static fullLayout(e){_(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 g([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new g(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 v=t.Debug.get("Renderer");class x{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)}checkRender(){this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.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),o=new t.Bounds(a);i.save(),a.spread(x.clipSpread).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0),this.__render(a,e.includes(this.target.__world),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{canvas:a}=this,o=n?{includes:n}:{bounds:e,includes:n};this.needFill&&a.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(a,e),this.target.__render(a,o),this.renderBounds=i=i||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),a.updateRender(i)}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(){const e=this.target;if(e.parentApp)return e.parentApp.renderer.update(!1);if(this.requestTime)return;const n=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),e.emit(t.RenderEvent.CHILD_END,e)),this.checkRender()}))}__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||v.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)}}x.clipSpread=10;const{hitRadiusPoint:b}=t.BoundsHelper;class B{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const a=i.through||!1,o=i.ignoreHittable||!1,s=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(s);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,o),d=o?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:o}=this.point,s={x:a,y:o,radiusX:0,radiusY:0};for(let a=0,o=e.length;a<o;a++)if(n=e[a],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,s),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,o,s;for(let t=0,e=i.length;t<e;t++){a=i[t],o=i[t+1];for(let t=0,e=a.length;t<e&&(s=a.list[t],!o||!o.has(s));t++)n.add(s)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:a}=this;for(let o=t.length-1;o>-1;o--)n=t[o],!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 B(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,n,i){const{target:a,picker:o}=this;return t.Platform.backgrounder&&a&&a.updateLayout(),o.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 L(t,e){let n,i=t.__.__textDrawData;const{rows:a,decorationY:o}=i;for(let t=0,i=a.length;t<i;t++)n=a[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)}));if(o){const{decorationColor:t,decorationHeight:n}=i;t&&(e.fillStyle=t),a.forEach((t=>o.forEach((i=>e.fillRect(t.x,t.y+i,t.width,n)))))}}function R(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?S(t,!0,e,n):P(e,n);break;case"inside":k("inside",t,a,e,n);break;case"outside":k("outside",t,a,e,n)}}function k(t,e,n,i,a){const{__strokeWidth:o,__font:s}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=s,n?S(e,!0,i,r):P(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",L(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 P(t,e){let n,i=t.__.__textDrawData;const{rows:a,decorationY:o}=i;for(let t=0,i=a.length;t<i;t++)n=a[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)}));if(o){const{decorationHeight:t}=i;a.forEach((n=>o.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function S(t,e,n,a){let o;for(let s=0,r=t.length;s<r;s++)o=t[s],o.image&&i.PaintImage.checkImage(n,a,o,!1)||o.style&&(a.strokeStyle=o.style,o.blendMode?(a.saveBlendMode(o.blendMode),e?P(n,a):a.stroke(),a.restoreBlendMode()):e?P(n,a):a.stroke())}function C(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 m(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>new E(t,e)}),t.Platform.layout=m.fullLayout;const{getSpread:A,getOuterOf:W,getByMove:O,getIntersectData:T}=t.BoundsHelper;let M;function I(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:o,blendMode:s,color:r,opacity:l}=e;return{type:o,blendMode:s,style:i.ColorConvert.string(r,l)};case"image":return i.PaintImage.image(n,t,e,a,!M||!M[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 D={compute:function(t,e){const n=e.__,a=[];let o,s=n.__input[t];s instanceof Array||(s=[s]),M=i.PaintImage.recycleImage(t,n);for(let n,i=0,o=s.length;i<o;i++)n=I(t,s[i],e),n&&a.push(n);n["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(o=a[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=o:n.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?L(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let a;const{windingRule:o,__font:s}=e.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&i.PaintImage.checkImage(e,n,a,!s)||a.style&&(n.fillStyle=a.style,a.transform?(n.save(),n.transform(a.transform),a.blendMode&&(n.blendMode=a.blendMode),s?L(e,n):o?n.fill(o):n.fill(),n.restore()):a.blendMode?(n.saveBlendMode(a.blendMode),s?L(e,n):o?n.fill(o):n.fill(),n.restoreBlendMode()):s?L(e,n):o?n.fill(o):n.fill())},fillText:L,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)R(t,e,n);else switch(o){case"center":n.setStroke(t,a,i),n.stroke(),i.__useArrow&&C(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 o=n.getSameCanvas(!0,!0);o.setStroke(t,2*a,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)R(t,e,n);else switch(o){case"center":n.setStroke(void 0,a,i),S(t,!1,e,n),i.__useArrow&&C(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),S(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,s=n.getSameCanvas(!0,!0);e.__drawRenderPath(s),s.setStroke(void 0,2*a,i),S(t,!1,e,s),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,o),s.recycle(e.__nowWorld)}},strokeText:R,drawTextStroke:P,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let o,s,r,l,{scaleX:d,scaleY:c}=a;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(a))l=i,o=r=a;else{const{renderShapeSpread:i}=t.__layout,h=T(i?A(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,a);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=W(a,s),o=O(r,-s.e,-s.f),n.matrix){const{matrix:t}=n;s.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:s.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:s,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let H={};const{get:F,rotateOfOuter:Y,translate:j,scaleOfOuter:U,scale:G,rotate:X}=t.MatrixHelper;function z(t,e,n,i,a,o,s){const r=F();j(r,e.x+n,e.y+i),G(r,a,o),s&&Y(r,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=r}function N(t,e,n,i,a,o,s){const r=F();j(r,e.x+n,e.y+i),a&&G(r,a,o),s&&X(r,s),t.transform=r}function q(t,e,n,i,a,o,s,r,l,d){const c=F();if(l)if("center"===d)Y(c,{x:n/2,y:i/2},l);else switch(X(c,l),l){case 90:j(c,i,0);break;case 180:j(c,n,i);break;case 270:j(c,0,n)}H.x=e.x+a,H.y=e.y+o,j(c,H.x,H.y),s&&U(c,H,s,r),t.transform=c}const{get:V,translate:Q}=t.MatrixHelper,J=new t.Bounds,Z={},K={};function $(t,e,n,i){const{blendMode:a,changeful:o,sync:s}=n;a&&(t.blendMode=a),o&&(t.changeful=o),s&&(t.sync=s),t.data=tt(n,i,e)}function tt(e,n,i){let{width:a,height:o}=i;e.padding&&(n=J.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:s,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===a&&n.height===o,_={mode:r},y="center"!==l&&(u||0)%180==90,w=y?o:a,m=y?a:o;let v,x,b=0,B=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,K),v=K.scaleX,x=K.scaleY);else if(!g||u){const t=n.width/w,e=n.height/m;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(n.width-a*v)/2,B+=(n.height-o*x)/2}if(l){const e={x:b,y:B,width:w,height:m};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(l,e,n,Z,!0),b+=Z.x,B+=Z.y}switch(d&&(b+=d.x,B+=d.y),r){case"stretch":g||(a=n.width,o=n.height);break;case"normal":case"clip":(b||B||v||u)&&N(_,n,b,B,v,x,u);break;case"repeat":(!g||v||u)&&q(_,n,a,o,b,B,v,x,u,l),f||(_.repeat="repeat");break;default:v&&z(_,n,b,B,v,x,u)}return _.transform||(n.x||n.y)&&(_.transform=V(),Q(_.transform,n.x,n.y)),v&&"stretch"!==r&&(_.scaleX=v,_.scaleY=x),_.width=a,_.height=o,s&&(_.opacity=s),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let et,nt=new t.Bounds;const{isSame:it}=t.BoundsHelper;function at(t,e,n,i,a,o){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||$(a,i,n,o),!0}function ot(e,n){lt(e,t.ImageEvent.LOAD,n)}function st(e,n){lt(e,t.ImageEvent.LOADED,n)}function rt(e,n,i){n.error=i,e.forceUpdate("surface"),lt(e,t.ImageEvent.ERROR,n)}function lt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function dt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ct,scale:ht,copy:ut}=t.MatrixHelper,{ceil:ft,abs:pt}=Math;function gt(e,n,i){let{scaleX:a,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=a+"-"+o+"-"+i;if(n.patternId===s||e.destroyed)return!1;{a=pt(a),o=pt(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(d=ct(),ut(d,p),ht(d,1/u,1/f),a*=u,o*=f),a*=i,o*=i,c*=a,h*=o;const _=c*h;if(!g&&_>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)}_>y&&(l=Math.sqrt(_/y)),l&&(a/=l,o/=l,c/=l,h/=l),u&&(a/=u,o/=f),(p||1!==a||1!==o)&&(d||(d=ct(),p&&ut(d,p)),ht(d,1/a,1/o));const w=e.getCanvas(ft(c)||1,ft(h)||1,r.opacity,r.filters),m=e.getPattern(w,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=m,n.patternId=s,!0}}const{abs:_t}=Math;const yt={image:function(e,n,i,a,o){let s,r;const l=t.ImageManager.get(i);return et&&i===et.paint&&it(a,et.boxBounds)?s=et.leafPaint:(s={type:i.type,image:l},et=l.use>1?{leafPaint:s,paint:i,boxBounds:nt.set(a)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(at(e,n,i,l,s,a),o&&(ot(e,r),st(e,r))):l.error?o&&rt(e,r,l.error):(o&&(dt(e,!0),ot(e,r)),s.loadId=l.load((()=>{dt(e,!1),e.destroyed||(at(e,n,i,l,s,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),st(e,r)),s.loadId=null}),(t=>{dt(e,!1),rt(e,r,t),s.loadId=null}))),s},checkImage:function(e,n,o,s){const{scaleX:r,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=n,{data:c}=o;if(!c||o.patternId===r+"-"+l+"-"+d&&!i.Export.running)return!1;if(s)if(c.repeat)s=!1;else if(!(o.changeful||t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:n}=c;e*=_t(r)*d,n*=_t(l)*d,c.scaleX&&(e*=c.scaleX,n*=c.scaleY),s=e*n>t.Platform.image.maxCacheSize}return s?(function(t,e,n,i){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(e,n,o,c),!0):(!o.style||o.sync||i.Export.running?gt(e,o,d):o.patternTask||(o.patternTask=t.ImageManager.patternTasker.add((()=>a(this,void 0,void 0,(function*(){o.patternTask=null,n.bounds.hit(e.__nowWorld)&&gt(e,o,d),e.forceUpdate("surface")}))),300)),!1)},createPattern:gt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,o,s,r,l;for(let d=0,c=i.length;d<c;d++)a=i[d],o=a.image,l=o&&o.url,l&&(s||(s={}),s[l]=!0,t.ImageManager.recycle(o),o.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),o.unload(i[d].loadId,!r.some((t=>t.url===l)))));return s}return null},createData:$,getPatternData:tt,fillOrFitMode:z,clipMode:N,repeatMode:q},{toPoint:wt}=t.AroundHelper,mt={},vt={};function xt(t,e,n){if(e){let a;for(let o=0,s=e.length;o<s;o++)a=e[o],"string"==typeof a?t.addColorStop(o/(s-1),i.ColorConvert.string(a,n)):t.addColorStop(a.offset,i.ColorConvert.string(a.color,n))}}const{getAngle:bt,getDistance:Bt}=t.PointHelper,{get:Et,rotateOfOuter:Lt,scaleOfOuter:Rt}=t.MatrixHelper,{toPoint:kt}=t.AroundHelper,Pt={},St={};function Ct(t,e,n,i,a){let o;const{width:s,height:r}=t;if(s!==r||i){const t=bt(e,n);o=Et(),a?(Rt(o,e,s/r*(i||1),1),Lt(o,e,t+90)):(Rt(o,e,1,s/r*(i||1)),Lt(o,e,t))}return o}const{getDistance:At}=t.PointHelper,{toPoint:Wt}=t.AroundHelper,Ot={},Tt={};const Mt={linearGradient:function(e,n){let{from:i,to:a,type:o,blendMode:s,opacity:r}=e;wt(i||"top",n,mt),wt(a||"bottom",n,vt);const l=t.Platform.canvas.createLinearGradient(mt.x,mt.y,vt.x,vt.y);xt(l,e.stops,r);const d={type:o,style:l};return s&&(d.blendMode=s),d},radialGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;kt(i||"center",n,Pt),kt(a||"bottom",n,St);const d=t.Platform.canvas.createRadialGradient(Pt.x,Pt.y,0,Pt.x,Pt.y,Bt(Pt,St));xt(d,e.stops,s);const c={type:o,style:d},h=Ct(n,Pt,St,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Wt(i||"center",n,Ot),Wt(a||"bottom",n,Tt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ot.x,Ot.y):t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,At(Ot,Tt));xt(d,e.stops,s);const c={type:o,style:d},h=Ct(n,Ot,Tt,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Ct},{copy:It,toOffsetOutBounds:Dt}=t.BoundsHelper,Ht={},Ft={};function Yt(e,n,i,a){const{bounds:o,shapeBounds:s}=a;if(t.Platform.fullImageShadow){if(It(Ht,e.bounds),Ht.x+=n.x-s.x,Ht.y+=n.y-s.y,i){const{matrix:t}=a;Ht.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Ht.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Ht.width*=i,Ht.height*=i}e.copyWorld(a.canvas,e.bounds,Ht)}else i&&(It(Ht,n),Ht.x-=n.width/2*(i-1),Ht.y-=n.height/2*(i-1),Ht.width*=i,Ht.height*=i),e.copyWorld(a.canvas,s,i?Ht:n)}const{toOffsetOutBounds:jt}=t.BoundsHelper,Ut={};const Gt={shadow:function(t,e,n){let a,o;const{__nowWorld:s,__layout:r}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Dt(c,Ft),l.forEach(((l,_)=>{p.setWorldShadow(Ft.offsetX+l.x*u,Ft.offsetY+l.y*f,l.blur*u,i.ColorConvert.string(l.color)),o=l.spread?1+2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Yt(p,Ft,o,n),a=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,s,"copy"),a=s),d?p.copyWorld(d,s,s,"destination-out"):p.copyWorld(n.canvas,h,c,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,a,s,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,o;const{__nowWorld:s,__layout:r}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;jt(c,Ut),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Ut.offsetX+l.x*u,Ut.offsetY+l.y*f,l.blur*u),o=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Yt(p,Ut,o,n),p.restore(),d?(p.copyWorld(p,c,s,"copy"),p.copyWorld(d,s,s,"source-out"),a=s):(p.copyWorld(n.canvas,h,c,"source-out"),a=c),p.fillWorld(a,i.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(p,a,s,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:Xt}=t.LeafBoundsHelper;function zt(t,e,n,i,a,o){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),qt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":qt(t,n,i,o);break;case"path":n.restore()}}function Nt(t){return t.getSameCanvas(!1,!0)}function qt(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,o,s,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(s&&(zt(this,s,t,a,i,o),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(s="opacity-path",o=n.opacity,a||(a=Nt(t))):(s="path",t.save()),n.__clip(a||t,e)):(s="grayscale"===r?"grayscale":"alpha",i||(i=Nt(t)),a||(a=Nt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Xt(n,e)||n.__render(a||t,e);zt(this,s,t,a,i,o)};const Vt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qt=Vt+"_#~&*+\\=|≮≯≈≠=…",Jt=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 Zt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Kt=Zt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$t=Zt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),te=Zt(Vt),ee=Zt(Qt),ne=Zt("- —/~|┆·");var ie;!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"}(ie||(ie={}));const{Letter:ae,Single:oe,Before:se,After:re,Symbol:le,Break:de}=ie;function ce(t){return Kt[t]?ae:ne[t]?de:$t[t]?se:te[t]?re:ee[t]?le:Jt.test(t)?oe:ae}const he={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let o=a-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function ue(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:fe}=he,{Letter:pe,Single:ge,Before:_e,After:ye,Symbol:we,Break:me}=ie;let ve,xe,be,Be,Ee,Le,Re,ke,Pe,Se,Ce,Ae,We,Oe,Te,Me,Ie,De=[];function He(t,e){Pe&&!ke&&(ke=Pe),ve.data.push({char:t,width:e}),be+=e}function Fe(){Be+=be,ve.width=be,xe.words.push(ve),ve={data:[]},be=0}function Ye(){Oe&&(Te.paraNumber++,xe.paraStart=!0,Oe=!1),Pe&&(xe.startCharSize=ke,xe.endCharSize=Pe,ke=0),xe.width=Be,Me.width?fe(xe):Ie&&je(),De.push(xe),xe={words:[]},Be=0}function je(){Be>(Te.maxWidth||0)&&(Te.maxWidth=Be)}const{top:Ue,right:Ge,bottom:Xe,left:ze}=t.Direction4;function Ne(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 qe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let a=0,o=0,s=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=n;c&&(s?(a=c[ze],s-=c[Ge]+c[ze]):n.autoSizeAlign||(a=c[ze]),r?(o=c[Ue],r-=c[Ue]+c[Xe]):n.autoSizeAlign||(o=c[Ue]));const h={bounds:{x:a,y:o,width:s,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Te=e,De=e.rows,Me=e.bounds,Ie=!Me.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:o,textCase:s}=i,{canvas:r}=t.Platform,{width:l,height:d}=Me;if(l||d||a||"none"!==s){const t="none"!==i.textWrap,e="break"===i.textWrap;Oe=!0,Ce=null,ke=Re=Pe=be=Be=0,ve={data:[]},xe={words:[]};for(let i=0,d=n.length;i<d;i++)Le=n[i],"\n"===Le?(be&&Fe(),xe.paraEnd=!0,Ye(),Oe=!0):(Se=ce(Le),Se===pe&&"none"!==s&&(Le=ue(Le,s,!be)),Re=r.measureText(Le).width,a&&(a<0&&(Pe=Re),Re+=a),Ae=Se===ge&&(Ce===ge||Ce===pe)||Ce===ge&&Se!==ye,We=!(Se!==_e&&Se!==ge||Ce!==we&&Ce!==ye),Ee=Oe&&o?l-o:l,t&&l&&Be+be+Re>Ee&&(e?(be&&Fe(),Be&&Ye()):(We||(We=Se===pe&&Ce==ye),Ae||We||Se===me||Se===_e||Se===ge||be+Re>Ee?(be&&Fe(),Be&&Ye()):Be&&Ye()))," "===Le&&!0!==Oe&&Be+be===0||(Se===me?(" "===Le&&be&&Fe(),He(Le,Re),Fe()):Ae||We?(be&&Fe(),He(Le,Re)):He(Le,Re)),Ce=Se);be&&Fe(),Be&&Ye(),De.length>0&&(De[De.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Te.paraNumber++,Be=r.measureText(t).width,De.push({x:o||0,text:t,width:Be,paraStart:!0}),Ie&&je()}))}(h,e,n),c&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ne(e,"x",t[ze]);break;case"right":Ne(e,"x",-t[Ge])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ne(e,"y",t[Ue]);break;case"bottom":Ne(e,"y",-t[Xe])}}(c,h,n,s,r),function(t,e){const{rows:n,bounds:i}=t,a=n.length,{__lineHeight:o,__baseLine:s,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,y=o*a+(h?h*(t.paraNumber-1):0),w=s;if(l&&y>_)y=Math.max(_,o),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":p+=(_-y)/2;break;case"bottom":p+=_-y}w+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let s=0,c=a;s<c;s++){if(m=n[s],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&s>0&&(w+=h),m.y=w,w+=o,t.overflow>s&&w>y&&(m.isOverflow=!0,t.overflow=s+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<i.x&&(i.x=v),x>i.width&&(i.width=x),l&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=y}(h,n),function(t,e,n){const{rows:i}=t,{textAlign:a,paraIndent:o,letterSpacing:s}=e;let r,l,d,c,h,u;i.forEach((t=>{t.words&&(d=o&&t.paraStart?o:0,u=t.words.length,l=n&&("justify"===a||"both"===a)&&u>1?(n-t.width-d)/(u-1):0,c=s||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!s&&(t.textMode=!0),2===c?(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===c?(h={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):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:o,overflow:s}=e;let{textOverflow:r}=n;if(o.splice(s),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+a-d;("none"===n.textWrap?o:[o[s-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<c));i--){if(l<c&&" "!==e.char||!i){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,a,s),"none"!==l&&function(t,e){let n;const{fontSize:a,textDecoration:o}=e;switch(t.decorationHeight=a/11,"object"==typeof o?(n=o.type,o.color&&(t.decorationColor=i.ColorConvert.string(o.color))):n=o,n){case"under":t.decorationY=[.15*a];break;case"delete":t.decorationY=[.35*-a];break;case"under-delete":t.decorationY=[.15*a,.35*-a]}}(h,n),h}};const Ve={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 o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}};Object.assign(i.TextConvert,qe),Object.assign(i.ColorConvert,Ve),Object.assign(i.Paint,D),Object.assign(i.PaintImage,yt),Object.assign(i.PaintGradient,Mt),Object.assign(i.Effect,Gt);const{setPoint:Qe,addPoint:Je,toBounds:Ze}=i.TwoPointBoundsHelper;const Ke={syncExport(t,e,n){let a;this.running=!0;const o=i.FileHelper.fileType(e),s=e.includes(".");n=i.FileHelper.getExportOptions(n);const{toURL:r}=i.Platform,{download:l}=i.Platform.origin;if("json"===o)s&&l(r(JSON.stringify(t.toJSON(n.json)),"text"),e),a={data:!!s||t.toJSON(n.json)};else if("svg"===o)s&&l(r(t.toSVG(),"svg"),e),a={data:!!s||t.toSVG()};else{let o,s,r=1,l=1;const{worldTransform:d,isLeafer:c,leafer:h,isFrame:u}=t,{slice:f,trim:p,padding:g,onCanvas:_}=n,y=void 0===n.smooth?!h||h.config.smooth:n.smooth,w=n.contextSettings||(h?h.config.contextSettings:void 0),m=n.screenshot||t.isApp,v=c&&m&&void 0===n.fill?t.fill:n.fill,x=i.FileHelper.isOpaqueImage(e)||v,b=new i.Matrix;if(m)o=!0===m?c?h.canvas.bounds:t.worldRenderBounds:m;else{let e=n.relative||(c?"inner":"local");switch(r=d.scaleX,l=d.scaleY,e){case"inner":b.set(d);break;case"local":b.set(d).divide(t.localTransform),r/=t.scaleX,l/=t.scaleY;break;case"world":r=1,l=1;break;case"page":e=h||t;default:b.set(d).divide(t.getTransform(e));const n=e.worldTransform;r/=r/n.scaleX,l/=l/n.scaleY}o=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};i.MathHelper.getScaleData(n.scale,n.size,o,B);let E=n.pixelRatio||1;t.isApp&&(B.scaleX*=E,B.scaleY*=E,E=t.app.pixelRatio);const{x:L,y:R,width:k,height:P}=new i.Bounds(o).scale(B.scaleX,B.scaleY),S={matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-L,-R).withScale(1/r*B.scaleX,1/l*B.scaleY)};let C,A=i.Creator.canvas({width:Math.floor(k),height:Math.floor(P),pixelRatio:E,smooth:y,contextSettings:w});if(f&&(C=t,C.__worldOpacity=0,t=h||t,S.bounds=A.bounds),A.save(),u&&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 o,s,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(o=l%e,s=(l-o)/e,r?Je(r,o,s):Qe(r={},o,s)),l++;const d=new i.Bounds;return Ze(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:E};A=i.Creator.canvas(a),A.copyWorld(t,s,a)}if(g){const[t,e,n,a]=i.MathHelper.fourNumber(g),o=A,{width:s,height:r}=o;A=i.Creator.canvas({width:s+a+e,height:r+t+n,pixelRatio:E}),A.copyWorld(o,o.bounds,{x:a,y:t,width:s,height:r})}x&&A.fillWorld(A.bounds,v||"#FFFFFF","destination-over"),_&&_(A);a={data:"canvas"===e?A:A.export(e,n),width:A.pixelWidth,height:A.pixelHeight,renderBounds:o,trimBounds:s}}return this.running=!1,a},export(t,e,n){return this.running=!0,function(t){$e||($e=new i.TaskProcessor);return new Promise((e=>{$e.add((()=>a(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((o=>new Promise((s=>{const r=()=>a(this,void 0,void 0,(function*(){if(!i.Resource.isComplete)return i.Platform.requestRender(r);const a=Ke.syncExport(t,e,n);a.data instanceof Promise&&(a.data=yield a.data),o(a),s()}));t.updateLayout(),tn(t);const{leafer:l}=t;l?l.waitViewCompleted(r):r()}))))}};let $e;function tn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>tn(t)))}const en=i.LeaferCanvasBase.prototype,nn=i.Debug.get("@leafer-in/export");en.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)},en.toBlob=function(t,e){return new Promise((n=>{i.Platform.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{nn.error(t),n(null)}))}))},en.toDataURL=function(t,e){return i.Platform.origin.canvasToDataURL(this.view,t,e)},en.saveAs=function(t,e){return new Promise((n=>{i.Platform.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{nn.error(t),n(!1)}))}))},i.Plugin.add("export"),Object.assign(i.Export,Ke),i.UI.prototype.export=function(t,e){return i.Export.export(this,t,e)},i.UI.prototype.syncExport=function(t,e){return i.Export.syncExport(this,t,e)},Object.assign(t.Creator,{interaction:(t,e,i,a)=>new n.InteractionBase(t,e,i,a),hitCanvas:(t,e)=>new o(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=o,exports.Picker=B,exports.Renderer=x,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:o}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(s(e),n),canvasToBolb:(t,e,n)=>a(this,void 0,void 0,(function*(){return t.toBuffer(s(e),n)})),canvasSaveAs:(t,n,i)=>a(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(s(r(n)),i))})),download(t,e){},loadImage:e=>o(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,o){function r(t){try{l(i.next(t))}catch(t){o(t)}}function s(t){try{l(i.throw(t))}catch(t){o(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(r,s)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class o 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:r,fileType:s}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new o(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:c,updateChange:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{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(){this.afterBounds.setListWithFn(this.updatedList.list,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:_,updateAllChange:w}=t.LeafHelper,y=t.Debug.get("Layouter");class m{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){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 n=t.Run.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:o,LAYOUT:r,AFTER:s}=t.LayoutEvent,l=this.getBlocks(a);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,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||c(i[t])}c(n)}}))}(this.__levelList),function(t){t.list.forEach(h)}(a),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,l,this.times)),i.emitEvent(new t.LayoutEvent(s,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:o}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),m.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,r,this.times)),n.emitEvent(new t.LayoutEvent(o,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new g([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new g(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 v=t.Debug.get("Renderer");class x{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)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.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),o=new t.Bounds(a);i.save(),a.spread(x.clipSpread).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0),this.__render(a,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),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:i}=this,a=e.includes(this.target.__world),o=a?{includes:a}:{bounds:e,includes:a};this.needFill&&i.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(i,e),this.target.__render(i,o),this.renderBounds=n=n||e,this.renderOptions=o,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),i.updateRender(n)}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(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,this.checkRender()}))}__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||v.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)}}x.clipSpread=10;const{hitRadiusPoint:b}=t.BoundsHelper;class B{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const a=i.through||!1,o=i.ignoreHittable||!1,r=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(r);const{list:s}=this.findList,l=this.getBestMatchLeaf(s,i.bottomList,o),d=o?this.getPath(l):this.getHitablePath(l);return this.clear(),a?{path:d,target:l,throughPath:s.length?this.getThroughPath(s):d}:{path:d,target:l}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:a,y:o}=this.point,r={x:a,y:o,radiusX:0,radiusY:0};for(let a=0,o=e.length;a<o;a++)if(n=e[a],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,r),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,o,r;for(let t=0,e=i.length;t<e;t++){a=i[t],o=i[t+1];for(let t=0,e=a.length;t<e&&(r=a.list[t],!o||!o.has(r));t++)n.add(r)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:a}=this;for(let o=t.length-1;o>-1;o--)n=t[o],!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 B(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,n,i){const{target:a,picker:o}=this;return t.Platform.backgrounder&&a&&a.updateLayout(),o.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 L(t,e){const n=t.__,{rows:i,decorationY:a}=n.__textDrawData;let o;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=i.length;t<n;t++)o=i[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach((t=>{e.fillText(t.char,t.x,o.y)}));if(a){const{decorationColor:t,decorationHeight:o}=n.__textDrawData;t&&(e.fillStyle=t),i.forEach((t=>a.forEach((n=>e.fillRect(t.x,t.y+n,t.width,o)))))}}function R(t,e){t.__.__font?L(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function P(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":k("inside",t,a,e,n);break;case"outside":k("outside",t,a,e,n)}}function k(t,e,n,i,a){const{__strokeWidth:o,__font:r}=i.__,s=a.getSameCanvas(!0,!0);s.setStroke(n?void 0:e,2*o,i.__),s.font=r,n?C(e,!0,i,s):S(i,s),s.blendMode="outside"===t?"destination-out":"destination-in",L(i,s),s.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(s,i.__nowWorld):a.copyWorldToInner(s,i.__nowWorld,i.__layout.renderBounds),s.recycle(i.__nowWorld)}function S(t,e){let n,i=t.__.__textDrawData;const{rows:a,decorationY:o}=i;for(let t=0,i=a.length;t<i;t++)n=a[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)}));if(o){const{decorationHeight:t}=i;a.forEach((n=>o.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function C(t,e,n,a){let o;for(let r=0,s=t.length;r<s;r++)o=t[r],o.image&&i.PaintImage.checkImage(n,a,o,!1)||o.style&&(a.strokeStyle=o.style,o.blendMode?(a.saveBlendMode(o.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 m(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>new E(t,e)}),t.Platform.layout=m.fullLayout;const{getSpread:W,getOuterOf:T,getByMove:O,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:o,blendMode:r,color:s,opacity:l}=e;return{type:o,blendMode:r,style:i.ColorConvert.string(s,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 o,r=n.__input[t];r instanceof Array||(r=[r]),I=i.PaintImage.recycleImage(t,n);for(let n,i=0,o=r.length;i<o;i++)n=D(t,r[i],e),n&&a.push(n);n["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(o=a[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=o:n.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,R(e,n)},fills:function(t,e,n){let a;for(let o=0,r=t.length;o<r;o++){if(a=t[o],a.image){if(i.PaintImage.checkImage(e,n,a,!e.__.__font))continue;if(!a.style){!o&&a.image.isPlacehold&&e.drawImagePlaceholder(n,a.image);continue}}n.fillStyle=a.style,a.transform?(n.save(),n.transform(a.transform),a.blendMode&&(n.blendMode=a.blendMode),R(e,n),n.restore()):a.blendMode?(n.saveBlendMode(a.blendMode),R(e,n),n.restoreBlendMode()):R(e,n)}},fillPathOrText:R,fillText:L,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:r}=i;if(a)if(r)P(t,e,n);else switch(o){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 o=n.getSameCanvas(!0,!0);o.setStroke(t,2*a,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:r}=i;if(a)if(r)P(t,e,n);else switch(o){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:o}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*a,i),C(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,o),r.recycle(e.__nowWorld)}},strokeText:P,drawTextStroke:S,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let o,r,s,l,{scaleX:d,scaleY:c}=a;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(a))l=i,o=s=a;else{const{renderShapeSpread:i}=t.__layout,h=M(i?W(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,a);r=e.bounds.getFitMatrix(h);let{a:u,d:f}=r;if(r.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),s=T(a,r),o=O(s,-r.e,-r.f),n.matrix){const{matrix:t}=n;r.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:r.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:r,bounds:o,worldCanvas:l,shapeBounds:s,scaleX:d,scaleY:c}}};let F={};const{get:Y,rotateOfOuter:j,translate:U,scaleOfOuter:G,scale:X,rotate:q}=t.MatrixHelper;function z(t,e,n,i,a,o,r){const s=Y();U(s,e.x+n,e.y+i),X(s,a,o),r&&j(s,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=s}function N(t,e,n,i,a,o,r){const s=Y();U(s,e.x+n,e.y+i),a&&X(s,a,o),r&&q(s,r),t.transform=s}function V(t,e,n,i,a,o,r,s,l,d){const c=Y();if(l)if("center"===d)j(c,{x:n/2,y:i/2},l);else switch(q(c,l),l){case 90:U(c,i,0);break;case 180:U(c,n,i);break;case 270:U(c,0,n)}F.x=e.x+a,F.y=e.y+o,U(c,F.x,F.y),r&&G(c,F,r,s),t.transform=c}const{get:Q,translate:J}=t.MatrixHelper,Z=new t.Bounds,K={},$={};function tt(t,e,n,i){const{blendMode:a,changeful:o,sync:r}=n;a&&(t.blendMode=a),o&&(t.changeful=o),r&&(t.sync=r),t.data=et(n,i,e)}function et(e,n,i){let{width:a,height:o}=i;e.padding&&(n=Z.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:r,mode:s,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===a&&n.height===o,_={mode:s},w="center"!==l&&(u||0)%180==90,y=w?o:a,m=w?a:o;let v,x,b=0,B=0;if(s&&"cover"!==s&&"fit"!==s)(c||h)&&(t.MathHelper.getScaleData(c,h,i,$),v=$.scaleX,x=$.scaleY);else if(!g||u){const t=n.width/y,e=n.height/m;v=x="fit"===s?Math.min(t,e):Math.max(t,e),b+=(n.width-a*v)/2,B+=(n.height-o*x)/2}if(l){const e={x:b,y:B,width:y,height:m};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(l,e,n,K,!0),b+=K.x,B+=K.y}switch(d&&(b+=d.x,B+=d.y),s){case"stretch":g||(a=n.width,o=n.height);break;case"normal":case"clip":(b||B||v||u)&&N(_,n,b,B,v,x,u);break;case"repeat":(!g||v||u)&&V(_,n,a,o,b,B,v,x,u,l),f||(_.repeat="repeat");break;default:v&&z(_,n,b,B,v,x,u)}return _.transform||(n.x||n.y)&&(_.transform=Q(),J(_.transform,n.x,n.y)),v&&"stretch"!==s&&(_.scaleX=v,_.scaleY=x),_.width=a,_.height=o,r&&(_.opacity=r),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let nt,it=new t.Bounds;const{isSame:at}=t.BoundsHelper;function ot(t,e,n,i,a,o){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,o),!0}function rt(e,n){dt(e,t.ImageEvent.LOAD,n)}function st(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 ct(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ht,scale:ut,copy:ft}=t.MatrixHelper,{ceil:pt,abs:gt}=Math;function _t(e,n,i){let{scaleX:a,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=a+"-"+o+"-"+i;if(n.patternId===r||e.destroyed)return!1;{a=gt(a),o=gt(o);const{image:e,data:s}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=s;u&&(d=ht(),ft(d,p),ut(d,1/u,1/f),a*=u,o*=f),a*=i,o*=i,c*=a,h*=o;const _=c*h;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}_>w&&(l=Math.sqrt(_/w)),l&&(a/=l,o/=l,c/=l,h/=l),u&&(a/=u,o/=f),(p||1!==a||1!==o)&&(d||(d=ht(),p&&ft(d,p)),ut(d,1/a,1/o));const y=e.getCanvas(pt(c)||1,pt(h)||1,s.opacity,s.filters),m=e.getPattern(y,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=m,n.patternId=r,!0}}const{abs:wt}=Math;const yt={image:function(e,n,i,a,o){let r,s;const l=t.ImageManager.get(i);return nt&&i===nt.paint&&at(a,nt.boxBounds)?r=nt.leafPaint:(r={type:i.type,image:l},nt=l.use>1?{leafPaint:r,paint:i,boxBounds:it.set(a)}:null),(o||l.loading)&&(s={image:l,attrName:n,attrValue:i}),l.ready?(ot(e,n,i,l,r,a),o&&(rt(e,s),st(e,s))):l.error?o&&lt(e,s,l.error):(o&&(ct(e,!0),rt(e,s)),r.loadId=l.load((()=>{ct(e,!1),e.destroyed||(ot(e,n,i,l,r,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),st(e,s)),r.loadId=null}),(t=>{ct(e,!1),lt(e,s,t),r.loadId=null})),e.placeholderColor&&setTimeout((()=>{l.ready||l.isPlacehold||(l.isPlacehold=!0,e.forceUpdate("surface"))}),100)),r},checkImage:function(e,n,o,r){const{scaleX:s,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=n,{data:c}=o;if(!c||o.patternId===s+"-"+l+"-"+d&&!i.Export.running)return!1;if(r)if(c.repeat)r=!1;else if(!(o.changeful||t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:n}=c;e*=wt(s)*d,n*=wt(l)*d,c.scaleX&&(e*=c.scaleX,n*=c.scaleY),r=e*n>t.Platform.image.maxCacheSize}return r?(function(t,e,n,i){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(e,n,o,c),!0):(!o.style||o.sync||i.Export.running?_t(e,o,d):o.patternTask||(o.patternTask=t.ImageManager.patternTasker.add((()=>a(this,void 0,void 0,(function*(){o.patternTask=null,n.bounds.hit(e.__nowWorld)&&_t(e,o,d),e.forceUpdate("surface")}))),300)),!1)},createPattern:_t,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,o,r,s,l;for(let d=0,c=i.length;d<c;d++)a=i[d],o=a.image,l=o&&o.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(o),o.loading&&(s||(s=n.__input&&n.__input[e]||[],s instanceof Array||(s=[s])),o.unload(i[d].loadId,!s.some((t=>t.url===l)))));return r}return null},createData:tt,getPatternData:et,fillOrFitMode:z,clipMode:N,repeatMode:V},{toPoint:mt}=t.AroundHelper,vt={},xt={};function bt(t,e,n){if(e){let a;for(let o=0,r=e.length;o<r;o++)a=e[o],"string"==typeof a?t.addColorStop(o/(r-1),i.ColorConvert.string(a,n)):t.addColorStop(a.offset,i.ColorConvert.string(a.color,n))}}const{getAngle:Bt,getDistance:Et}=t.PointHelper,{get:Lt,rotateOfOuter:Rt,scaleOfOuter:Pt}=t.MatrixHelper,{toPoint:kt}=t.AroundHelper,St={},Ct={};function At(t,e,n,i,a){let o;const{width:r,height:s}=t;if(r!==s||i){const t=Bt(e,n);o=Lt(),a?(Pt(o,e,r/s*(i||1),1),Rt(o,e,t+90)):(Pt(o,e,1,r/s*(i||1)),Rt(o,e,t))}return o}const{getDistance:Wt}=t.PointHelper,{toPoint:Tt}=t.AroundHelper,Ot={},Mt={};const It={linearGradient:function(e,n){let{from:i,to:a,type:o,blendMode:r,opacity:s}=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,s);const d={type:o,style:l};return r&&(d.blendMode=r),d},radialGradient:function(e,n){let{from:i,to:a,type:o,opacity:r,blendMode:s,stretch:l}=e;kt(i||"center",n,St),kt(a||"bottom",n,Ct);const d=t.Platform.canvas.createRadialGradient(St.x,St.y,0,St.x,St.y,Et(St,Ct));bt(d,e.stops,r);const c={type:o,style:d},h=At(n,St,Ct,l,!0);return h&&(c.transform=h),s&&(c.blendMode=s),c},conicGradient:function(e,n){let{from:i,to:a,type:o,opacity:r,blendMode:s,stretch:l}=e;Tt(i||"center",n,Ot),Tt(a||"bottom",n,Mt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ot.x,Ot.y):t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,Wt(Ot,Mt));bt(d,e.stops,r);const c={type:o,style:d},h=At(n,Ot,Mt,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),s&&(c.blendMode=s),c},getTransform:At},{copy:Dt,toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={},Yt={};function jt(e,n,i,a){const{bounds:o,shapeBounds:r}=a;if(t.Platform.fullImageShadow){if(Dt(Ft,e.bounds),Ft.x+=n.x-r.x,Ft.y+=n.y-r.y,i){const{matrix:t}=a;Ft.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Ft.y-=(o.y+(t?t.f:0)+o.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,r,i?Ft:n)}const{toOffsetOutBounds:Ut}=t.BoundsHelper,Gt={};const Xt={shadow:function(t,e,n){let a,o;const{__nowWorld:r,__layout:s}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Ht(c,Yt),l.forEach(((l,_)=>{p.setWorldShadow(Yt.offsetX+l.x*u,Yt.offsetY+l.y*f,l.blur*u,i.ColorConvert.string(l.color)),o=l.spread?1+2*l.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,jt(p,Yt,o,n),a=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,r,"copy"),a=r),d?p.copyWorld(d,r,r,"destination-out"):p.copyWorld(n.canvas,h,c,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,a,r,l.blendMode):e.copyWorldToInner(p,a,s.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(a,!0)})),p.recycle(a)},innerShadow:function(t,e,n){let a,o;const{__nowWorld:r,__layout:s}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Ut(c,Gt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Gt.offsetX+l.x*u,Gt.offsetY+l.y*f,l.blur*u),o=l.spread?1-2*l.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,jt(p,Gt,o,n),p.restore(),d?(p.copyWorld(p,c,r,"copy"),p.copyWorld(d,r,r,"source-out"),a=r):(p.copyWorld(n.canvas,h,c,"source-out"),a=c),p.fillWorld(a,i.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(p,a,r,l.blendMode):e.copyWorldToInner(p,a,s.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:qt}=t.LeafBoundsHelper;function zt(t,e,n,i,a,o){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,o);break;case"path":n.restore()}}function Nt(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,o,r,s;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],s=n.__.mask,s&&(r&&(zt(this,r,t,a,i,o),i=a=null),"path"===s||"clipping-path"===s?(n.opacity<1?(r="opacity-path",o=n.opacity,a||(a=Nt(t))):(r="path",t.save()),n.__clip(a||t,e)):(r="grayscale"===s?"grayscale":"alpha",i||(i=Nt(t)),a||(a=Nt(t)),n.__render(i,e)),"clipping"!==s&&"clipping-path"!==s)||qt(n,e)||n.__render(a||t,e);zt(this,r,t,a,i,o)};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:oe,Single:re,Before:se,After:le,Symbol:de,Break:ce}=ae;function he(t){return $t[t]?oe:ie[t]?ce:te[t]?se:ee[t]?le:ne[t]?de:Zt.test(t)?re:oe}const ue={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let o=a-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)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,Ee,Le,Re,Pe,ke,Se,Ce,Ae,We,Te,Oe,Me,Ie,De,He=[];function Fe(t,e){Se&&!ke&&(ke=Se),xe.data.push({char:t,width:e}),Be+=e}function Ye(){Ee+=Be,xe.width=Be,be.words.push(xe),xe={data:[]},Be=0}function je(){Oe&&(Me.paraNumber++,be.paraStart=!0,Oe=!1),Se&&(be.startCharSize=ke,be.endCharSize=Se,ke=0),be.width=Ee,Ie.width?pe(be):De&&Ue(),He.push(be),be={words:[]},Ee=0}function Ue(){Ee>(Me.maxWidth||0)&&(Me.maxWidth=Ee)}const{top:Ge,right:Xe,bottom:qe,left:ze}=t.Direction4;function Ne(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 a=0,o=0,r=n.__getInput("width")||0,s=n.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=n;c&&(r?(a=c[ze],r-=c[Xe]+c[ze]):n.autoSizeAlign||(a=c[ze]),s?(o=c[Ge],s-=c[Ge]+c[qe]):n.autoSizeAlign||(o=c[Ge]));const h={bounds:{x:a,y:o,width:r,height:s},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Me=e,He=e.rows,Ie=e.bounds,De=!Ie.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:o,textCase:r}=i,{canvas:s}=t.Platform,{width:l,height:d}=Ie;if(l||d||a||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Oe=!0,Ae=null,ke=Pe=Se=Be=Ee=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(),Oe=!0):(Ce=he(Re),Ce===ge&&"none"!==r&&(Re=fe(Re,r,!Be)),Pe=s.measureText(Re).width,a&&(a<0&&(Se=Pe),Pe+=a),We=Ce===_e&&(Ae===_e||Ae===ge)||Ae===_e&&Ce!==ye,Te=!(Ce!==we&&Ce!==_e||Ae!==me&&Ae!==ye),Le=Oe&&o?l-o:l,t&&l&&Ee+Be+Pe>Le&&(e?(Be&&Ye(),Ee&&je()):(Te||(Te=Ce===ge&&Ae==ye),We||Te||Ce===ve||Ce===we||Ce===_e||Be+Pe>Le?(Be&&Ye(),Ee&&je()):Ee&&je()))," "===Re&&!0!==Oe&&Ee+Be===0||(Ce===ve?(" "===Re&&Be&&Ye(),Fe(Re,Pe),Ye()):We||Te?(Be&&Ye(),Fe(Re,Pe)):Fe(Re,Pe)),Ae=Ce);Be&&Ye(),Ee&&je(),He.length>0&&(He[He.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Me.paraNumber++,Ee=s.measureText(t).width,He.push({x:o||0,text:t,width:Ee,paraStart:!0}),De&&Ue()}))}(h,e,n),c&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ne(e,"x",t[ze]);break;case"right":Ne(e,"x",-t[Xe])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ne(e,"y",t[Ge]);break;case"bottom":Ne(e,"y",-t[qe])}}(c,h,n,r,s),function(t,e){const{rows:n,bounds:i}=t,a=n.length,{__lineHeight:o,__baseLine:r,__letterSpacing:s,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,w=o*a+(h?h*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,o),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=a;r<c;r++){if(m=n[r],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&r>0&&(y+=h),m.y=y,y+=o,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),v=m.x,x=m.width,s<0&&(m.width<0?(x=-m.width+e.fontSize+s,v-=x,x+=e.fontSize):x-=s),v<i.x&&(i.x=v),x>i.width&&(i.width=x),l&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=w}(h,n),function(t,e,n){const{rows:i}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let s,l,d,c,h,u;i.forEach((t=>{t.words&&(d=o&&t.paraStart?o:0,u=t.words.length,l=n&&("justify"===a||"both"===a)&&u>1?(n-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,s=t.x,t.data=[],t.words.forEach(((e,n)=>{1===c?(h={char:"",x:s},s=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,s,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):s=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,s,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==a||n===u-1||(s+=l,t.width+=l)}))),t.words=null)}))}(h,n,r),h.overflow&&function(e,n,i,a){if(!a)return;const{rows:o,overflow:r}=e;let{textOverflow:s}=n;if(o.splice(r),s&&"show"!==s){let e,l;"hide"===s?s="":"ellipsis"===s&&(s="...");const d=s?t.Platform.canvas.measureText(s).width:0,c=i+a-d;("none"===n.textWrap?o:[o[r-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<c));i--){if(l<c&&" "!==e.char||!i){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:s,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,a,r),"none"!==l&&function(t,e){let n;const{fontSize:a,textDecoration:o}=e;switch(t.decorationHeight=a/11,"object"==typeof o?(n=o.type,o.color&&(t.decorationColor=i.ColorConvert.string(o.color))):n=o,n){case"under":t.decorationY=[.15*a];break;case"delete":t.decorationY=[.35*-a];break;case"under-delete":t.decorationY=[.15*a,.35*-a]}}(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 o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+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={syncExport(t,e,n){let a;this.running=!0;const o=i.FileHelper.fileType(e),r=e.includes(".");n=i.FileHelper.getExportOptions(n);const{toURL:s}=i.Platform,{download:l}=i.Platform.origin;if("json"===o)r&&l(s(JSON.stringify(t.toJSON(n.json)),"text"),e),a={data:!!r||t.toJSON(n.json)};else if("svg"===o)r&&l(s(t.toSVG(),"svg"),e),a={data:!!r||t.toSVG()};else{let o,r,s=1,l=1;const{worldTransform:d,isLeafer:c,leafer:h,isFrame:u}=t,{slice:f,clip:p,trim:g,padding:_,onCanvas:w}=n,y=void 0===n.smooth?!h||h.config.smooth:n.smooth,m=n.contextSettings||(h?h.config.contextSettings:void 0),v=n.screenshot||t.isApp,x=c&&v&&void 0===n.fill?t.fill:n.fill,b=i.FileHelper.isOpaqueImage(e)||x,B=new i.Matrix;if(v)o=!0===v?c?h.canvas.bounds:t.worldRenderBounds:v;else{let e=n.relative||(c?"inner":"local");switch(s=d.scaleX,l=d.scaleY,e){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),s/=t.scaleX,l/=t.scaleY;break;case"world":s=1,l=1;break;case"page":e=h||t;default:B.set(d).divide(t.getTransform(e));const n=e.worldTransform;s/=s/n.scaleX,l/=l/n.scaleY}o=t.getBounds("render",e)}const E={scaleX:1,scaleY:1};i.MathHelper.getScaleData(n.scale,n.size,o,E);let L=n.pixelRatio||1;t.isApp&&(E.scaleX*=L,E.scaleY*=L,L=t.app.pixelRatio);let{x:R,y:P,width:k,height:S}=new i.Bounds(o).scale(E.scaleX,E.scaleY);p&&(R+=p.x,P+=p.y,k=p.width,S=p.height);const C={matrix:B.scale(1/E.scaleX,1/E.scaleY).invert().translate(-R,-P).withScale(1/s*E.scaleX,1/l*E.scaleY)};let A,W=i.Creator.canvas({width:Math.floor(k),height:Math.floor(S),pixelRatio:L,smooth:y,contextSettings:m});if(f&&(A=t,A.__worldOpacity=0,t=h||t,C.bounds=W.bounds),W.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(W,C),t.fill=e}else t.__render(W,C);if(W.restore(),A&&A.__updateWorldOpacity(),g){r=function(t){const{width:e,height:n}=t.view,{data:a}=t.context.getImageData(0,0,e,n);let o,r,s,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(o=l%e,r=(l-o)/e,s?Ze(s,o,r):Je(s={},o,r)),l++;const d=new i.Bounds;return Ke(s,d),d.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:n}=r,a={x:0,y:0,width:e,height:n,pixelRatio:L};W=i.Creator.canvas(a),W.copyWorld(t,r,a)}if(_){const[t,e,n,a]=i.MathHelper.fourNumber(_),o=W,{width:r,height:s}=o;W=i.Creator.canvas({width:r+a+e,height:s+t+n,pixelRatio:L}),W.copyWorld(o,o.bounds,{x:a,y:t,width:r,height:s})}b&&W.fillWorld(W.bounds,x||"#FFFFFF","destination-over"),w&&w(W);a={data:"canvas"===e?W:W.export(e,n),width:W.pixelWidth,height:W.pixelHeight,renderBounds:o,trimBounds:r}}return this.running=!1,a},export(t,e,n){return this.running=!0,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})}))}((o=>new Promise((r=>{const s=()=>a(this,void 0,void 0,(function*(){if(!i.Resource.isComplete)return i.Platform.requestRender(s);const a=$e.syncExport(t,e,n);a.data instanceof Promise&&(a.data=yield a.data),o(a),r()}));t.updateLayout(),en(t);const{leafer:l}=t;l?l.waitViewCompleted(s):s()}))))}};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)},i.UI.prototype.syncExport=function(t,e){return i.Export.syncExport(this,t,e)},Object.assign(t.Creator,{interaction:(t,e,i,a)=>new n.InteractionBase(t,e,i,a),hitCanvas:(t,e)=>new o(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=o,exports.Picker=B,exports.Renderer=x,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:o}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(r(e),n),canvasToBolb:(t,e,n)=>a(this,void 0,void 0,(function*(){return t.toBuffer(r(e),n)})),canvasSaveAs:(t,n,i)=>a(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(r(s(n)),i))})),download(t,e){},loadImage:e=>o(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
2
  //# sourceMappingURL=node.min.cjs.map