@leafer-ui/node 1.8.0 → 1.9.1

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"),i=require("@leafer-ui/core"),n=require("@leafer-ui/draw");function a(t,e,i,n){return new(i||(i=Promise))((function(a,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function o(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}l((n=n.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:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:r,fileType:o}=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,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=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:y}=t.LeafHelper,m=t.Debug.get("Layouter");class v{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!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 i=t.Run.start("PartLayout"),{target:n,__updatedList:a}=this,{BEFORE:s,LAYOUT:r,AFTER:o}=t.LayoutEvent,l=this.getBlocks(a);l.forEach((t=>t.setBefore())),n.emitEvent(new t.LayoutEvent(s,l,this.times)),this.extraBlock=null,a.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(a,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||c(n[t])}c(i)}}))}(this.__levelList),function(t){t.list.forEach(h)}(a),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),n.emitEvent(new t.LayoutEvent(r,l,this.times)),n.emitEvent(new t.LayoutEvent(o,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:a,AFTER:s}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),v.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new t.LayoutEvent(a,r,this.times)),i.emitEvent(new t.LayoutEvent(s,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),y(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new g([]));e.length?i.add(t.__world):i.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(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[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 w=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}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:i}=this;this.times=0,this.totalBounds=new t.Bounds,w.log(i.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,w.error(t)}w.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return w.warn("rendering");if(this.times>3)return w.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 i=t.Run.start("PartRender"),{canvas:n}=this,a=e.getIntersect(n.bounds),s=new t.Bounds(a);n.save(),a.spread(x.clipSpread).ceil(),n.clearWorld(a,!0),n.clipWorld(a,!0),this.__render(a,s),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,a=e.includes(this.target.__world),s=a?{includes:a}:{bounds:e,includes:a};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),this.target.__render(n,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const i=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||w.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[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,i,n){i||(i=0),n||(n={});const a=n.through||!1,s=n.ignoreHittable||!1,r=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(r);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,n.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),a?{path:d,target:l,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:l}}getBestMatchLeaf(e,i,n){if(e.length){let i;this.findList=new t.LeafList;const{x:a,y:s}=this.point,r={x:a,y:s,radiusX:0,radiusY:0};for(let a=0,s=e.length;a<s;a++)if(i=e[a],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,r),this.findList.length))return this.findList.list[0]}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,a=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(a.addAt(n,0),n.__.hitChildren);t--);return a}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let a,s,r;for(let t=0,e=n.length;t<e;t++){a=n[t],s=n[t+1];for(let t=0,e=a.length;t<e&&(r=a.list[t],!s||!s.has(r));t++)i.add(r)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:a}=this;for(let s=t.length-1;s>-1;s--)i=t[s],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||b(i.__world,a),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,a)):n&&this.hitChild(i,a))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class E{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new B(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,i,n){const{target:a,picker:s}=this;return t.Platform.backgrounder&&a&&a.updateLayout(),s.getByPoint(e,i,n)}getBy(e,i,n,a){return this.finder?this.finder.getBy(e,i,n,a):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function L(t,e){const i=t.__,{rows:n,decorationY:a}=i.__textDrawData;let s;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)s=n[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach((t=>{e.fillText(t.char,t.x,s.y)}));if(a){const{decorationColor:t,decorationHeight:s}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach((t=>a.forEach((i=>e.fillRect(t.x,t.y+i,t.width,s)))))}}function R(t,e){t.__.__font?L(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function k(t,e,i){switch(e.__.strokeAlign){case"center":S(t,1,e,i);break;case"inside":P(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?S(t,2,e,i):P(t,"outside",e,i)}}function S(t,e,i,n){const a=i.__;"object"==typeof t?A(t,e,!0,i,n):(n.setStroke(t,a.__strokeWidth*e,a),C(i,n))}function P(e,i,n,a){const s=a.getSameCanvas(!0,!0);s.font=n.__.__font,S(e,2,n,s),s.blendMode="outside"===i?"destination-out":"destination-in",L(n,s),s.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,a,s),s.recycle(n.__nowWorld)}function C(t,e){let i,n=t.__.__textDrawData;const{rows:a,decorationY:s}=n;for(let t=0,n=a.length;t<n;t++)i=a[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(s){const{decorationHeight:t}=n;a.forEach((i=>s.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function A(t,e,i,a,s){let r;const o=a.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!n.PaintImage.checkImage(a,s,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):s.setStroke(r.style,o.__strokeWidth*e,o)}else s.strokeStyle=r.style;r.blendMode?(s.saveBlendMode(r.blendMode),i?C(a,s):s.stroke(),s.restoreBlendMode()):i?C(a,s):s.stroke()}}function T(e,i,n){const a=i.__;if(a.__strokeWidth)if(a.__font)k(e,i,n);else switch(a.strokeAlign){case"center":O(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),O(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const a=i.__;if(a.__fillAfterStroke)O(e,2,i,n);else{const{renderBounds:s}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),O(e,2,i,r),r.clipUI(a),r.clearWorld(s),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function O(t,e,i,a){const s=i.__;"object"==typeof t?A(t,e,!1,i,a):(a.setStroke(t,s.__strokeWidth*e,s),a.stroke()),s.__useArrow&&n.Paint.strokeArrow(t,i,a)}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>new E(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:W,getOuterOf:D,getByMove:M,getIntersectData:H}=t.BoundsHelper;let I;const{stintSet:F}=t.DataHelper,{hasTransparent:U}=n.ColorConvert;function j(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let a;const{boxBounds:s}=i.__layout;switch(e.type){case"image":a=n.PaintImage.image(i,t,e,s,!I||!I[e.url]);break;case"linear":a=n.PaintGradient.linearGradient(e,s);break;case"radial":a=n.PaintGradient.radialGradient(e,s);break;case"angular":a=n.PaintGradient.conicGradient(e,s);break;case"solid":const{type:r,color:o,opacity:l}=e;a={type:r,style:n.ColorConvert.string(o,l)};break;default:void 0!==e.r&&(a={type:"solid",style:n.ColorConvert.string(e)})}if(a){if("string"==typeof a.style&&U(a.style)&&(a.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;a.strokeStyle=e.style}e.blendMode&&(a.blendMode=e.blendMode)}return a}const Y={compute:function(t,e){const i=e.__,a=[];let s,r,o,l=i.__input[t];l instanceof Array||(l=[l]),I=n.PaintImage.recycleImage(t,i);for(let i,n=0,s=l.length;n<s;n++)(i=j(t,l[n],e))&&(a.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=a.length?a:void 0,a.length&&a.every((t=>t.isTransparent))&&(a.some((t=>t.image))&&(s=!0),r=!0),"fill"===t?(F(i,"__isAlphaPixelFill",s),F(i,"__isTransparentFill",r)):(F(i,"__isAlphaPixelStroke",s),F(i,"__isTransparentStroke",r),F(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,R(e,i)},fills:function(t,e,i){let a;for(let s=0,r=t.length;s<r;s++){if(a=t[s],a.image){if(n.PaintImage.checkImage(e,i,a,!e.__.__font))continue;if(!a.style){!s&&a.image.isPlacehold&&e.drawImagePlaceholder(i,a.image);continue}}if(i.fillStyle=a.style,a.transform||a.scaleFixed){if(i.save(),a.transform&&i.transform(a.transform),a.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);i.scale(1/t,1/n)}a.blendMode&&(i.blendMode=a.blendMode),R(e,i),i.restore()}else a.blendMode?(i.saveBlendMode(a.blendMode),R(e,i),i.restoreBlendMode()):R(e,i)}},fillPathOrText:R,fillText:L,stroke:T,strokes:function(t,e,i){T(t,e,i)},strokeText:k,drawTextStroke:C,shape:function(t,e,i){const n=e.getSameCanvas(),a=t.__nowWorld;let s,r,o,l,{scaleX:d,scaleY:c}=a;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(a))l=n,s=o=a;else{const{renderShapeSpread:n}=t.__layout,h=H(n?W(e.bounds,d===c?n*d:[n*c,n*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,i),d*=u,c*=f),o=D(a,r),s=M(o,-r.e,-r.f),i.matrix){const{matrix:t}=i;r.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:r.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:r,bounds:s,worldCanvas:l,shapeBounds:o,scaleX:d,scaleY:c}}};let z={},G=t.getMatrixData();const{get:X,rotateOfOuter:q,translate:N,scaleOfOuter:V,multiplyParent:Q,scale:J,rotate:Z,skew:K}=t.MatrixHelper;function $(t,e,i,n,a,s,r){const o=X();N(o,e.x+i,e.y+n),J(o,a,s),r&&q(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function tt(t,e,i,n,a,s,r,o,l){const d=X();r&&Z(d,r),o&&K(d,o.x,o.y),a&&J(d,a,s),N(d,e.x+i,e.y+n),l&&(G.a=e.width/l.width,G.d=e.height/l.height,Q(d,G)),t.transform=d}function et(t,e,i,n,a,s,r,o,l,d){const c=X();if(l)if("center"===d)q(c,{x:i/2,y:n/2},l);else switch(Z(c,l),l){case 90:N(c,n,0);break;case 180:N(c,i,n);break;case 270:N(c,0,i)}z.x=e.x+a,z.y=e.y+s,N(c,z.x,z.y),r&&V(c,z,r,o),t.transform=c}const{get:it,translate:nt}=t.MatrixHelper,at=new t.Bounds,st={},rt={};function ot(t,e,i,n){const{changeful:a,sync:s,editing:r,scaleFixed:o}=i;a&&(t.changeful=a),s&&(t.sync=s),r&&(t.editing=r),o&&(t.scaleFixed=o),t.data=lt(i,n,e)}function lt(e,i,n){e.padding&&(i=at.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:a,height:s}=n;const{opacity:r,mode:o,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,clipSize:p,repeat:g,filters:_}=e,y=i.width===a&&i.height===s,m={mode:o},v="center"!==l&&(u||0)%180==90;let w,x;switch(t.BoundsHelper.set(rt,0,0,v?s:a,v?a:s),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,n,st),w=st.scaleX,x=st.scaleY),l&&(w&&t.BoundsHelper.scale(rt,w,x,!0),t.AlignHelper.toPoint(l,rt,i,rt,!0,!0))):y&&!u||(w=x=t.BoundsHelper.getFitScale(i,rt,"fit"!==o),t.BoundsHelper.put(i,n,l,w,!1,rt),t.BoundsHelper.scale(rt,w,x,!0)),d&&t.PointHelper.move(rt,d),o){case"stretch":y||(a=i.width,s=i.height);break;case"normal":case"clip":(rt.x||rt.y||w||p||u||f)&&tt(m,i,rt.x,rt.y,w,x,u,f,e.clipSize);break;case"repeat":(!y||w||u)&&et(m,i,a,s,rt.x,rt.y,w,x,u,l),g||(m.repeat="repeat");break;default:w&&$(m,i,rt.x,rt.y,w,x,u)}return m.transform||(i.x||i.y)&&(m.transform=it(),nt(m.transform,i.x,i.y)),w&&"stretch"!==o&&(m.scaleX=w,m.scaleY=x),m.width=a,m.height=s,r&&(m.opacity=r),_&&(m.filters=_),g&&(m.repeat="string"==typeof g?"x"===g?"repeat-x":"repeat-y":"repeat"),m}let dt,ct=new t.Bounds;const{isSame:ht}=t.BoundsHelper;function ut(t,e,i,n,a,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||ot(a,n,i,s),!0}function ft(e,i){_t(e,t.ImageEvent.LOAD,i)}function pt(e,i){_t(e,t.ImageEvent.LOADED,i)}function gt(e,i,n){i.error=n,e.forceUpdate("surface"),_t(e,t.ImageEvent.ERROR,i)}function _t(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function yt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:mt,scale:vt,copy:wt}=t.MatrixHelper,{ceil:xt,abs:bt}=Math;function Bt(e,i,n){let{scaleX:a,scaleY:s}=e.getRenderScaleData(!0,i.scaleFixed);const r=a+"-"+s+"-"+n;if(i.patternId===r||e.destroyed)return!1;{const{image:e,data:o}=i;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=o;u&&(u=bt(u),f=bt(f),d=mt(),wt(d,p),vt(d,1/u,1/f),a*=u,s*=f),a*=n,s*=n,c*=a,h*=s;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,s/=l,c/=l,h/=l),u&&(a/=u,s/=f),(p||1!==a||1!==s)&&(d||(d=mt(),p&&wt(d,p)),vt(d,1/a,1/s));const m=e.getCanvas(xt(c)||1,xt(h)||1,o.opacity,o.filters),v=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",d,i);return i.style=v,i.patternId=r,!0}}const Et={image:function(e,i,n,a,s){let r,o;const l=t.ImageManager.get(n);return dt&&n===dt.paint&&ht(a,dt.boxBounds)?r=dt.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),dt=l.use>1?{leafPaint:r,paint:n,boxBounds:ct.set(a)}:null),(s||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(ut(e,i,n,l,r,a),s&&(ft(e,o),pt(e,o))):l.error?s&&gt(e,o,l.error):(s&&(yt(e,!0),ft(e,o)),r.loadId=l.load((()=>{yt(e,!1),e.destroyed||(ut(e,i,n,l,r,a)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),pt(e,o)),r.loadId=void 0}),(t=>{yt(e,!1),gt(e,o,t),r.loadId=void 0})),e.placeholderColor&&(e.placeholderDelay?setTimeout((()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))}),e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(e,i,s,r){const{scaleX:o,scaleY:l}=e.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:d}=i,{data:c}=s;if(!c||s.patternId===o+"-"+l+"-"+d&&!n.Export.running)return!1;if(r)if(c.repeat)r=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(e)||n.Export.running)){let{width:e,height:i}=c;e*=o*d,i*=l*d,c.scaleX&&(e*=c.scaleX,i*=c.scaleY),r=e*i>t.Platform.image.maxCacheSize}return r?(e.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,n){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(e,i,s,c),!0):(!s.style||s.sync||n.Export.running?Bt(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>a(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&Bt(e,s,d),e.forceUpdate("surface")}))),300)),!1)},createPattern:Bt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){let a,s,r,o,l;for(let d=0,c=n.length;d<c;d++)a=n[d],s=a.image,l=s&&s.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=i.__input&&i.__input[e]||[],o instanceof Array||(o=[o])),s.unload(n[d].loadId,!o.some((t=>t.url===l)))));return r}return null},createData:ot,getPatternData:lt,fillOrFitMode:$,clipMode:tt,repeatMode:et},{toPoint:Lt}=t.AroundHelper,{hasTransparent:Rt}=n.ColorConvert,kt={},St={};function Pt(t,e,i,a){if(i){let s,r,o,l;for(let t=0,d=i.length;t<d;t++)s=i[t],"string"==typeof s?(o=t/(d-1),r=n.ColorConvert.string(s,a)):(o=s.offset,r=n.ColorConvert.string(s.color,a)),e.addColorStop(o,r),!l&&Rt(r)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:Ct,getDistance:At}=t.PointHelper,{get:Tt,rotateOfOuter:Ot,scaleOfOuter:Wt}=t.MatrixHelper,{toPoint:Dt}=t.AroundHelper,Mt={},Ht={};function It(t,e,i,n,a){let s;const{width:r,height:o}=t;if(r!==o||n){const t=Ct(e,i);s=Tt(),a?(Wt(s,e,r/o*(n||1),1),Ot(s,e,t+90)):(Wt(s,e,1,r/o*(n||1)),Ot(s,e,t))}return s}const{getDistance:Ft}=t.PointHelper,{toPoint:Ut}=t.AroundHelper,jt={},Yt={};const zt={linearGradient:function(e,i){let{from:n,to:a,type:s,opacity:r}=e;Lt(n||"top",i,kt),Lt(a||"bottom",i,St);const o=t.Platform.canvas.createLinearGradient(kt.x,kt.y,St.x,St.y),l={type:s,style:o};return Pt(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:a,type:s,opacity:r,stretch:o}=e;Dt(n||"center",i,Mt),Dt(a||"bottom",i,Ht);const l=t.Platform.canvas.createRadialGradient(Mt.x,Mt.y,0,Mt.x,Mt.y,At(Mt,Ht)),d={type:s,style:l};Pt(d,l,e.stops,r);const c=It(i,Mt,Ht,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,i){let{from:n,to:a,type:s,opacity:r,stretch:o}=e;Ut(n||"center",i,jt),Ut(a||"bottom",i,Yt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,jt.x,jt.y):t.Platform.canvas.createRadialGradient(jt.x,jt.y,0,jt.x,jt.y,Ft(jt,Yt)),d={type:s,style:l};Pt(d,l,e.stops,r);const c=It(i,jt,Yt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:It},{copy:Gt,toOffsetOutBounds:Xt}=t.BoundsHelper,qt={},Nt={};function Vt(e,i,n,a){const{bounds:s,shapeBounds:r}=a;if(t.Platform.fullImageShadow){if(Gt(qt,e.bounds),qt.x+=i.x-r.x,qt.y+=i.y-r.y,n){const{matrix:t}=a;qt.x-=(s.x+(t?t.e:0)+s.width/2)*(n-1),qt.y-=(s.y+(t?t.f:0)+s.height/2)*(n-1),qt.width*=n,qt.height*=n}e.copyWorld(a.canvas,e.bounds,qt)}else n&&(Gt(qt,i),qt.x-=i.width/2*(n-1),qt.y-=i.height/2*(n-1),qt.width*=n,qt.height*=n),e.copyWorld(a.canvas,r,n?qt:i)}const{toOffsetOutBounds:Qt}=t.BoundsHelper,Jt={};const Zt={shadow:function(e,i,a){let s,r;const{__nowWorld:o,__layout:l}=e,{shadow:d}=e.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=a,g=i.getSameCanvas(),_=d.length-1;Xt(h,Nt),d.forEach(((d,y)=>{g.setWorldShadow(Nt.offsetX+d.x*f,Nt.offsetY+d.y*p,d.blur*f,n.ColorConvert.string(d.color)),r=d.spread?1+2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0)):0,Vt(g,Nt,r,a),s=h,d.box&&(g.restore(),g.save(),c&&(g.copyWorld(g,h,o,"copy"),s=o),c?g.copyWorld(c,o,o,"destination-out"):g.copyWorld(a.canvas,u,h,"destination-out")),t.LeafHelper.copyCanvasByWorld(e,i,g,s,d.blendMode),_&&y<_&&g.clearWorld(s,!0)})),g.recycle(s)},innerShadow:function(e,i,a){let s,r;const{__nowWorld:o,__layout:l}=e,{innerShadow:d}=e.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=a,g=i.getSameCanvas(),_=d.length-1;Qt(h,Jt),d.forEach(((d,y)=>{g.save(),g.setWorldShadow(Jt.offsetX+d.x*f,Jt.offsetY+d.y*p,d.blur*f),r=d.spread?1-2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0)):0,Vt(g,Jt,r,a),g.restore(),c?(g.copyWorld(g,h,o,"copy"),g.copyWorld(c,o,o,"source-out"),s=o):(g.copyWorld(a.canvas,u,h,"source-out"),s=h),g.fillWorld(s,n.ColorConvert.string(d.color),"source-in"),t.LeafHelper.copyCanvasByWorld(e,i,g,s,d.blendMode),_&&y<_&&g.clearWorld(s,!0)})),g.recycle(s)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Kt}=t.LeafBoundsHelper;function $t(t,e,i,n,a,s){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const a=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,a),n.recycle(a),ee(t,e,i,1)}(t,i,n,a);break;case"opacity-path":ee(t,i,n,s);break;case"path":i.restore()}}function te(t){return t.getSameCanvas(!1,!0)}function ee(t,e,i,n){const a=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,a),i.recycle(a)}n.Group.prototype.__renderMask=function(t,e){let i,n,a,s,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)i=l[d],o=i.__.mask,o?(r&&($t(this,r,t,a,n,s),n=a=null),"path"===o||"clipping-path"===o?(i.opacity<1?(r="opacity-path",s=i.opacity,a||(a=te(t))):(r="path",t.save()),i.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=te(t)),a||(a=te(t)),i.__render(n,e)),"clipping"!==o&&"clipping-path"!==o||Kt(i,e)||i.__render(t,e)):Kt(i,e)||i.__render(a||t,e);$t(this,r,t,a,n,s)};const ie=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ne=ie+"_#~&*+\\=|≮≯≈≠=…",ae=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 se(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const re=se("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),oe=se("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),le=se(ie),de=se(ne),ce=se("- —/~|┆·");var he;!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"}(he||(he={}));const{Letter:ue,Single:fe,Before:pe,After:ge,Symbol:_e,Break:ye}=he;function me(t){return re[t]?ue:ce[t]?ye:oe[t]?pe:le[t]?ge:de[t]?_e:ae.test(t)?fe:ue}const ve={trimRight(t){const{words:e}=t;let i,n=0,a=e.length;for(let s=a-1;s>-1&&(i=e[s].data[0]," "===i.char);s--)n++,t.width-=i.width;n&&e.splice(a-n,n)}};function we(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:xe}=ve,{Letter:be,Single:Be,Before:Ee,After:Le,Symbol:Re,Break:ke}=he;let Se,Pe,Ce,Ae,Te,Oe,We,De,Me,He,Ie,Fe,Ue,je,Ye,ze,Ge,Xe=[];function qe(t,e){Me&&!De&&(De=Me),Se.data.push({char:t,width:e}),Ce+=e}function Ne(){Ae+=Ce,Se.width=Ce,Pe.words.push(Se),Se={data:[]},Ce=0}function Ve(){je&&(Ye.paraNumber++,Pe.paraStart=!0,je=!1),Me&&(Pe.startCharSize=De,Pe.endCharSize=Me,De=0),Pe.width=Ae,ze.width?xe(Pe):Ge&&Qe(),Xe.push(Pe),Pe={words:[]},Ae=0}function Qe(){Ae>(Ye.maxWidth||0)&&(Ye.maxWidth=Ae)}const{top:Je,right:Ze,bottom:Ke,left:$e}=t.Direction4;function ti(t,e,i){const{bounds:n,rows:a}=t;n[e]+=i;for(let t=0;t<a.length;t++)a[t][e]+=i}const ei={getDrawData:function(e,i){"string"!=typeof e&&(e=String(e));let a=0,s=0,r=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=i;c&&(r?(a=c[$e],r-=c[Ze]+c[$e]):i.autoSizeAlign||(a=c[$e]),o?(s=c[Je],o-=c[Je]+c[Ke]):i.autoSizeAlign||(s=c[Je]));const h={bounds:{x:a,y:s,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,i,n){Ye=e,Xe=e.rows,ze=e.bounds,Ge=!ze.width&&!n.autoSizeAlign;const{__letterSpacing:a,paraIndent:s,textCase:r}=n,{canvas:o}=t.Platform,{width:l,height:d}=ze;if(l||d||a||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;je=!0,Ie=null,De=We=Me=Ce=Ae=0,Se={data:[]},Pe={words:[]},a&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)Oe=i[n],"\n"===Oe?(Ce&&Ne(),Pe.paraEnd=!0,Ve(),je=!0):(He=me(Oe),He===be&&"none"!==r&&(Oe=we(Oe,r,!Ce)),We=o.measureText(Oe).width,a&&(a<0&&(Me=We),We+=a),Fe=He===Be&&(Ie===Be||Ie===be)||Ie===Be&&He!==Le,Ue=!(He!==Ee&&He!==Be||Ie!==Re&&Ie!==Le),Te=je&&s?l-s:l,t&&l&&Ae+Ce+We>Te&&(e?(Ce&&Ne(),Ae&&Ve()):(Ue||(Ue=He===be&&Ie==Le),Fe||Ue||He===ke||He===Ee||He===Be||Ce+We>Te?(Ce&&Ne(),Ae&&Ve()):Ae&&Ve()))," "===Oe&&!0!==je&&Ae+Ce===0||(He===ke?(" "===Oe&&Ce&&Ne(),qe(Oe,We),Ne()):Fe||Ue?(Ce&&Ne(),qe(Oe,We)):qe(Oe,We)),Ie=He);Ce&&Ne(),Ae&&Ve(),Xe.length>0&&(Xe[Xe.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ye.paraNumber++,Ae=o.measureText(t).width,Xe.push({x:s||0,text:t,width:Ae,paraStart:!0}),Ge&&Qe()}))}(h,e,i),c&&function(t,e,i,n,a){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ti(e,"x",t[$e]);break;case"right":ti(e,"x",-t[Ze])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ti(e,"y",t[Je]);break;case"bottom":ti(e,"y",-t[Ke])}}(c,h,i,r,o),function(t,e){const{rows:i,bounds:n}=t,a=i.length,{__lineHeight:s,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,y=s*a+(h?h*(t.paraNumber-1):0),m=r;if(l&&y>_)y=Math.max(_,s),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":p+=(_-y)/2;break;case"bottom":p+=_-y}m+=p;let v,w,x,b=g||u?g:t.maxWidth;for(let r=0,c=a;r<c;r++){if(v=i[r],v.x=f,v.width<g||v.width>g&&!l)switch(d){case"center":v.x+=(b-v.width)/2;break;case"right":v.x+=b-v.width}v.paraStart&&h&&r>0&&(m+=h),v.y=m,m+=s,t.overflow>r&&m>y&&(v.isOverflow=!0,t.overflow=r+1),w=v.x,x=v.width,o<0&&(v.width<0?(x=-v.width+e.fontSize+o,w-=x,x+=e.fontSize):x-=o),w<n.x&&(n.x=w),x>n.width&&(n.width=x),l&&g&&g<x&&(v.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=y}(h,i),function(t,e,i){const{rows:n}=t,{textAlign:a,paraIndent:s,letterSpacing:r}=e;let o,l,d,c,h,u;n.forEach((t=>{t.words&&(d=s&&t.paraStart?s:0,u=t.words.length,l=i&&("justify"===a||"both"===a)&&u>1?(i-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,o=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(h={char:"",x:o},o=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==a||i===u-1||(o+=l,t.width+=l)}))),t.words=null)}))}(h,i,r),h.overflow&&function(e,i,n,a){if(!a)return;const{rows:s,overflow:r}=e;let{textOverflow:o}=i;if(s.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=n+a-d;("none"===i.textWrap?s:[s[r-1]]).forEach((t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<c));n--){if(l<c&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,i,a,r),"none"!==l&&function(t,e){let i;const{fontSize:a,textDecoration:s}=e;switch(t.decorationHeight=a/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=n.ColorConvert.string(s.color))):i=s,i){case"under":t.decorationY=[.15*a];break;case"delete":t.decorationY=[.35*-a];break;case"under-delete":t.decorationY=[.15*a,.35*-a]}}(h,i),h}};const ii={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!n.ColorConvert.object)return t;t=n.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;i&&(a*=e);const s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(n.TextConvert,ei),Object.assign(n.ColorConvert,ii),Object.assign(n.Paint,Y),Object.assign(n.PaintImage,Et),Object.assign(n.PaintGradient,zt),Object.assign(n.Effect,Zt);const{setPoint:ni,addPoint:ai,toBounds:si}=n.TwoPointBoundsHelper;const ri={syncExport(t,e,i){let a;n.Export.running=!0;try{const s=n.FileHelper.fileType(e),r=e.includes(".");i=n.FileHelper.getExportOptions(i);const{toURL:o}=n.Platform,{download:l}=n.Platform.origin;if("json"===s)r&&l(o(JSON.stringify(t.toJSON(i.json)),"text"),e),a={data:!!r||t.toJSON(i.json)};else if("svg"===s)r&&l(o(t.toSVG(),"svg"),e),a={data:!!r||t.toSVG()};else{let s,r,o=1,l=1;const{worldTransform:d,isLeafer:c,leafer:h,isFrame:u}=t,{slice:f,clip:p,trim:g,screenshot:_,padding:y,onCanvas:m}=i,v=void 0===i.smooth?!h||h.config.smooth:i.smooth,w=i.contextSettings||(h?h.config.contextSettings:void 0),x=c&&_&&void 0===i.fill?t.fill:i.fill,b=n.FileHelper.isOpaqueImage(e)||x,B=new n.Matrix;if(_)s=!0===_?c?h.canvas.bounds:t.worldRenderBounds:_;else{let e=i.relative||(c?"inner":"local");switch(o=d.scaleX,l=d.scaleY,e){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,l/=t.scaleY;break;case"world":o=1,l=1;break;case"page":e=h||t;default:B.set(d).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,l/=l/i.scaleY}s=t.getBounds("render",e)}const E={scaleX:1,scaleY:1};n.MathHelper.getScaleData(i.scale,i.size,s,E);let L=i.pixelRatio||1,{x:R,y:k,width:S,height:P}=new n.Bounds(s).scale(E.scaleX,E.scaleY);p&&(R+=p.x,k+=p.y,S=p.width,P=p.height);const C={exporting:!0,matrix:B.scale(1/E.scaleX,1/E.scaleY).invert().translate(-R,-k).withScale(1/o*E.scaleX,1/l*E.scaleY)};let A,T=n.Creator.canvas({width:Math.floor(S),height:Math.floor(P),pixelRatio:L,smooth:v,contextSettings:w});if(f&&(A=t,A.__worldOpacity=0,t=h||t,C.bounds=T.bounds),T.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(T,C),t.fill=e}else t.__render(T,C);if(T.restore(),A&&A.__updateWorldOpacity(),g){r=function(t){const{width:e,height:i}=t.view,{data:a}=t.context.getImageData(0,0,e,i);let s,r,o,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(s=l%e,r=(l-s)/e,o?ai(o,s,r):ni(o={},s,r)),l++;const d=new n.Bounds;return o&&(si(o,d),d.scale(1/t.pixelRatio).ceil()),d}(T);const t=T,{width:e,height:i}=r,a={x:0,y:0,width:e,height:i,pixelRatio:L};T=n.Creator.canvas(a),T.copyWorld(t,r,a)}if(y){const[t,e,i,a]=n.MathHelper.fourNumber(y),s=T,{width:r,height:o}=s;T=n.Creator.canvas({width:r+a+e,height:o+t+i,pixelRatio:L}),T.copyWorld(s,s.bounds,{x:a,y:t,width:r,height:o})}b&&T.fillWorld(T.bounds,x||"#FFFFFF","destination-over"),m&&m(T);a={data:"canvas"===e?T:T.export(e,i),width:T.pixelWidth,height:T.pixelHeight,renderBounds:s,trimBounds:r}}}catch(t){a={data:"",error:t}}return n.Export.running=!1,a},export(t,e,i){return n.Export.running=!0,function(t){oi||(oi=new n.TaskProcessor);return new Promise((e=>{oi.add((()=>a(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((r=>{const o=()=>a(this,void 0,void 0,(function*(){if(!n.Resource.isComplete)return n.Platform.requestRender(o);const a=n.Export.syncExport(t,e,i);a.data instanceof Promise&&(a.data=yield a.data),s(a),r()}));t.updateLayout(),li(t);const{leafer:l}=t;l?l.waitViewCompleted(o):o()}))))}};let oi;function li(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>li(t)))}const di=n.LeaferCanvasBase.prototype,ci=n.Debug.get("@leafer-in/export");di.export=function(t,e){const{quality:i,blob:a}=n.FileHelper.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):a?this.toBlob(t,i):this.toDataURL(t,i)},di.toBlob=function(t,e){return new Promise((i=>{n.Platform.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{ci.error(t),i(null)}))}))},di.toDataURL=function(t,e){return n.Platform.origin.canvasToDataURL(this.view,t,e)},di.saveAs=function(t,e){return new Promise((i=>{n.Platform.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{ci.error(t),i(!1)}))}))},n.Plugin.add("export"),Object.assign(n.Export,ri),n.UI.prototype.export=function(t,e){return n.Export.export(this,t,e)},n.UI.prototype.syncExport=function(t,e){return n.Export.syncExport(this,t,e)},Object.assign(t.Creator,{interaction:(t,e,n,a)=>new i.InteractionBase(t,e,n,a),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new i.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=s,exports.Picker=B,exports.Renderer=x,exports.Selector=E,exports.Watcher=l,exports.useCanvas=function(i,n){if(t.Platform.canvasType=i,!t.Platform.origin){if("skia"===i){const{Canvas:e,loadImage:i}=n;t.Platform.origin={createCanvas:(t,i,n)=>new e(t,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:e=>i(t.Platform.image.getRealURL(e))},t.Platform.roundRectPatch=!0}else if("napi"===i){const{Canvas:i,loadImage:s}=n;t.Platform.origin={createCanvas:(t,e,n)=>new i(t,e,n),canvasToDataURL:(t,e,i)=>t.toDataURL(r(e),i),canvasToBolb:(t,e,i)=>a(this,void 0,void 0,(function*(){return t.toBuffer(r(e),i)})),canvasSaveAs:(t,i,n)=>a(this,void 0,void 0,(function*(){return e.writeFileSync(i,t.toBuffer(r(o(i)),n))})),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(i).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return i[t]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("fs"),i=require("@leafer-ui/core"),n=require("@leafer-ui/draw");function a(t,e,i,n){return new(i||(i=Promise))(function(a,s){function r(t){try{l(n.next(t))}catch(t){s(t)}}function o(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.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:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:r,fileType:o}=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,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=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,t.isArray(e)&&(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,m=t.Debug.get("Layouter");class w{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!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 i=t.Run.start("PartLayout"),{target:n,__updatedList:a}=this,{BEFORE:s,LAYOUT:r,AFTER:o}=t.LayoutEvent,l=this.getBlocks(a);l.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(s,l,this.times)),this.extraBlock=null,a.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))})}(a,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach(a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||c(n[t])}c(i)}})}(this.__levelList),function(t){t.list.forEach(h)}(a),this.extraBlock&&l.push(this.extraBlock),l.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,l,this.times)),n.emitEvent(new t.LayoutEvent(o,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:a,AFTER:s}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),w.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(a,r,this.times)),i.emitEvent(new t.LayoutEvent(s,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),y(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new g([]));e.length?i.add(t.__world):i.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(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[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,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}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:i}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(i.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 i=t.Run.start("PartRender"),{canvas:n}=this,a=e.getIntersect(n.bounds),s=new t.Bounds(a);n.save(),a.spread(x.clipSpread).ceil(),n.clearWorld(a,!0),n.clipWorld(a,!0),this.__render(a,s),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,a=e.includes(this.target.__world),s=a?{includes:a}:{bounds:e,includes:a};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),this.target.__render(n,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const i=this.requestTime=Date.now();t.Platform.requestRender(()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()})}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[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,i,n){i||(i=0),n||(n={});const a=n.through||!1,s=n.ignoreHittable||!1,r=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(r.isBranchLeaf?{children:[r]}:r);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,n.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),a?{path:d,target:l,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(e,i,n){const a=this.findList=new t.LeafList;if(e.length){let i;const{x:s,y:r}=this.point,o={x:s,y:r,radiusX:0,radiusY:0};for(let s=0,r=e.length;s<r;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,o),a.length)){if(i.isBranchLeaf&&e.some(e=>e!==i&&t.LeafHelper.hasParent(e,i))){a.reset();break}return a.list[0]}}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),a.length)return a.list[0];return n?e[0]:e.find(e=>t.LeafHelper.worldHittable(e))}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,a=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(a.addAt(n,0),n.__.hitChildren);t--);return a}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let a,s,r;for(let t=0,e=n.length;t<e;t++){a=n[t],s=n[t+1];for(let t=0,e=a.length;t<e&&(r=a.list[t],!s||!s.has(r));t++)i.add(r)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:a}=this;for(let s=t.length-1;s>-1;s--)i=t[s],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||b(i.__world,a),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,a)):n&&this.hitChild(i,a))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask){let i,a=[];const{children:s}=n;for(let n=0,r=s.length;n<r;n++)if(i=s[n],i.__.mask&&a.push(i),i===t){if(a&&!a.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class E{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new B(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,i,n){const{target:a,picker:s}=this;return t.Platform.backgrounder&&a&&a.updateLayout(),s.getByPoint(e,i,n)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(e,i,n,a){return this.finder?this.finder.getBy(e,i,n,a):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function L(t,e){const i=t.__,{rows:n,decorationY:a}=i.__textDrawData;let s;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)s=n[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.fillText(t.char,t.x,s.y)});if(a){const{decorationColor:t,decorationHeight:s}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>a.forEach(i=>e.fillRect(t.x,t.y+i,t.width,s)))}}function k(t,e){t.__.__font?L(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function R(t,e,i){switch(e.__.strokeAlign){case"center":S(t,1,e,i);break;case"inside":P(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?S(t,2,e,i):P(t,"outside",e,i)}}function S(e,i,n,a){const s=n.__;t.isObject(e)?A(e,i,!0,n,a):(a.setStroke(e,s.__strokeWidth*i,s),C(n,a))}function P(e,i,n,a){const s=a.getSameCanvas(!0,!0);s.font=n.__.__font,S(e,2,n,s),s.blendMode="outside"===i?"destination-out":"destination-in",L(n,s),s.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,a,s),s.recycle(n.__nowWorld)}function C(t,e){let i,n=t.__.__textDrawData;const{rows:a,decorationY:s}=n;for(let t=0,n=a.length;t<n;t++)i=a[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(s){const{decorationHeight:t}=n;a.forEach(i=>s.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}}function A(t,e,i,a,s){let r;const o=a.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!n.PaintImage.checkImage(a,s,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):s.setStroke(r.style,o.__strokeWidth*e,o)}else s.strokeStyle=r.style;r.blendMode?(s.saveBlendMode(r.blendMode),i?C(a,s):s.stroke(),s.restoreBlendMode()):i?C(a,s):s.stroke()}}function T(e,i,n){const a=i.__;if(a.__strokeWidth)if(a.__font)R(e,i,n);else switch(a.strokeAlign){case"center":O(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),O(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const a=i.__;if(a.__fillAfterStroke)O(e,2,i,n);else{const{renderBounds:s}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),O(e,2,i,r),r.clipUI(a),r.clearWorld(s),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function O(e,i,a,s){const r=a.__;t.isObject(e)?A(e,i,!1,a,s):(s.setStroke(e,r.__strokeWidth*i,r),s.stroke()),r.__useArrow&&n.Paint.strokeArrow(e,a,s)}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new w(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>new E(t,e)}),t.Platform.layout=w.fullLayout;const{getSpread:M,getOuterOf:W,getByMove:D,getIntersectData:H}=t.BoundsHelper;let I;const{stintSet:F}=t.DataHelper,{hasTransparent:U}=n.ColorConvert;function j(e,i,a){if(!t.isObject(i)||!1===i.visible||0===i.opacity)return;let s;const{boxBounds:r}=a.__layout;switch(i.type){case"image":s=n.PaintImage.image(a,e,i,r,!I||!I[i.url]);break;case"linear":s=n.PaintGradient.linearGradient(i,r);break;case"radial":s=n.PaintGradient.radialGradient(i,r);break;case"angular":s=n.PaintGradient.conicGradient(i,r);break;case"solid":const{type:o,color:l,opacity:d}=i;s={type:o,style:n.ColorConvert.string(l,d)};break;default:t.isUndefined(i.r)||(s={type:"solid",style:n.ColorConvert.string(i)})}if(s){if(t.isString(s.style)&&U(s.style)&&(s.isTransparent=!0),i.style){if(0===i.style.strokeWidth)return;s.strokeStyle=i.style}i.editing&&(s.editing=i.editing),i.blendMode&&(s.blendMode=i.blendMode)}return s}const Y={compute:function(e,i){const a=i.__,s=[];let r,o,l,d=a.__input[e];t.isArray(d)||(d=[d]),I=n.PaintImage.recycleImage(e,a);for(let t,n=0,a=d.length;n<a;n++)(t=j(e,d[n],i))&&(s.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));a["_"+e]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(r=!0),o=!0),"fill"===e?(F(a,"__isAlphaPixelFill",r),F(a,"__isTransparentFill",o)):(F(a,"__isAlphaPixelStroke",r),F(a,"__isTransparentStroke",o),F(a,"__hasMultiStrokeStyle",l))},fill:function(t,e,i){i.fillStyle=t,k(e,i)},fills:function(t,e,i){let a;for(let s=0,r=t.length;s<r;s++){if(a=t[s],a.image){if(n.PaintImage.checkImage(e,i,a,!e.__.__font))continue;if(!a.style){!s&&a.image.isPlacehold&&e.drawImagePlaceholder(i,a.image);continue}}if(i.fillStyle=a.style,a.transform||a.scaleFixed){if(i.save(),a.transform&&i.transform(a.transform),a.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===a.scaleFixed||"zoom-in"===a.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}a.blendMode&&(i.blendMode=a.blendMode),k(e,i),i.restore()}else a.blendMode?(i.saveBlendMode(a.blendMode),k(e,i),i.restoreBlendMode()):k(e,i)}},fillPathOrText:k,fillText:L,stroke:T,strokes:function(t,e,i){T(t,e,i)},strokeText:R,drawTextStroke:C,shape:function(e,i,n){const a=i.getSameCanvas(),s=e.__nowWorld,r=i.bounds;let o,l,d,c,h,{scaleX:u,scaleY:f}=e.getRenderScaleData(!0);if(r.includes(s))h=a,o=c=s;else{const{renderShapeSpread:a}=e.__layout;let p;if(t.Platform.fullImageShadow)p=s;else{const t=a?M(r,u===f?a*u:[a*f,a*u]):r;p=H(t,s)}d=r.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(h=i.getSameCanvas(),e.__renderShape(h,n),u*=g,f*=_),c=W(s,d),o=D(c,-d.e,-d.f);const y=n.matrix;y?(l=new t.Matrix(d),l.multiply(y),g*=y.scaleX,_*=y.scaleY):l=d,l.withScale(g,_),n=Object.assign(Object.assign({},n),{matrix:l})}return e.__renderShape(a,n),{canvas:a,matrix:l,fitMatrix:d,bounds:o,worldCanvas:h,shapeBounds:c,scaleX:u,scaleY:f}}};let X={},z=t.getMatrixData();const{get:G,rotateOfOuter:N,translate:q,scaleOfOuter:V,multiplyParent:Q,scale:J,rotate:Z,skew:K}=t.MatrixHelper;function $(t,e,i,n,a,s,r){const o=G();q(o,e.x+i,e.y+n),J(o,a,s),r&&N(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function tt(t,e,i,n,a,s,r,o,l){const d=G();it(d,e,i,n,a,s,r,o),l&&(z.a=e.width/l.width,z.d=e.height/l.height,Q(d,z)),t.transform=d}function et(t,e,i,n,a,s,r,o,l,d,c,h){const u=G();if(h)it(u,e,a,s,r,o,l,d);else{if(l)if("center"===c)N(u,{x:i/2,y:n/2},l);else switch(Z(u,l),l){case 90:q(u,n,0);break;case 180:q(u,i,n);break;case 270:q(u,0,i)}X.x=e.x+a,X.y=e.y+s,q(u,X.x,X.y),r&&V(u,X,r,o)}t.transform=u}function it(t,e,i,n,a,s,r,o){r&&Z(t,r),o&&K(t,o.x,o.y),a&&J(t,a,s),q(t,e.x+i,e.y+n)}const{get:nt,translate:at}=t.MatrixHelper,st=new t.Bounds,rt={},ot={};function lt(t,e,i,n){const{changeful:a,sync:s,scaleFixed:r}=i;a&&(t.changeful=a),s&&(t.sync=s),r&&(t.scaleFixed=r),t.data=dt(i,n,e)}function dt(e,i,n){e.padding&&(i=st.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:a,height:s}=n;const{opacity:r,mode:o,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:y}=e,m=i.width===a&&i.height===s,w={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(ot,0,0,v?s:a,v?a:s),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,n,rt),x=rt.scaleX,b=rt.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(ot,x,b,!0),l&&t.AlignHelper.toPoint(l,ot,i,ot,!0,!0))):m&&!u||(x=b=t.BoundsHelper.getFitScale(i,ot,"fit"!==o),t.BoundsHelper.put(i,n,l,x,!1,ot),t.BoundsHelper.scale(ot,x,b,!0)),d&&t.PointHelper.move(ot,d),o){case"stretch":m||(a=i.width,s=i.height);break;case"normal":case"clip":(ot.x||ot.y||x||p||u||f)&&tt(w,i,ot.x,ot.y,x,b,u,f,e.clipSize);break;case"repeat":(!m||x||u||f)&&et(w,i,a,s,ot.x,ot.y,x,b,u,f,l,e.freeTransform),g||(w.repeat="repeat");const n=t.isObject(g);(_||n)&&(w.gap=function(e,i,n,a,s){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:ct(r,n,s.width,i&&i.x),y:ct(o,a,s.height,i&&i.y)}}(_,n&&g,ot.width,ot.height,i));break;default:x&&$(w,i,ot.x,ot.y,x,b,u)}return w.transform||(i.x||i.y)&&(w.transform=nt(),at(w.transform,i.x,i.y)),x&&"stretch"!==o&&(w.scaleX=x,w.scaleY=b),w.width=a,w.height=s,r&&(w.opacity=r),y&&(w.filters=y),g&&(w.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w}function ct(e,i,n,a){const s=t.isString(e)||a?(a?n-a*i:n%i)/((a||Math.floor(n/i))-1):e;return"auto"===e&&s<0?0:s}let ht,ut=new t.Bounds;const{isSame:ft}=t.BoundsHelper;function pt(t,e,i,n,a,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||lt(a,n,i,s),!0}function gt(e,i){mt(e,t.ImageEvent.LOAD,i)}function _t(e,i){mt(e,t.ImageEvent.LOADED,i)}function yt(e,i,n){i.error=n,e.forceUpdate("surface"),mt(e,t.ImageEvent.ERROR,i)}function mt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function wt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:vt,scale:xt,copy:bt}=t.MatrixHelper,{floor:Bt,max:Et,abs:Lt}=Math;function kt(e,i,n){let{scaleX:a,scaleY:s}=e.getRenderScaleData(!0,i.scaleFixed);const r=a+"-"+s+"-"+n;if(i.patternId===r||e.destroyed)return!1;{const{image:e,data:o}=i;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g,gap:_}=o;a*=n,s*=n;const y=_&&_.x*a,m=_&&_.y*s;u&&(u=Lt(u),f=Lt(f),d=vt(),bt(d,p),xt(d,1/u,1/f),a*=u,s*=f),c*=a,h*=s;const w=c*h;if(!g&&w>t.Platform.image.maxCacheSize)return!1;let v=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;v>t&&(v=t)}if(w>v&&(l=Math.sqrt(w/v)),l&&(a/=l,s/=l,c/=l,h/=l),u&&(a/=u,s/=f),(p||1!==a||1!==s)&&(d||(d=vt(),p&&bt(d,p)),xt(d,1/a,1/s)),d){const t=c+(y||0),e=h+(m||0);xt(d,t/Et(Bt(t),1),e/Et(Bt(e),1))}const x=e.getCanvas(c,h,o.opacity,o.filters,y,m),b=e.getPattern(x,g||t.Platform.origin.noRepeat||"no-repeat",d,i);return i.style=b,i.patternId=r,!0}}const Rt={image:function(e,i,n,a,s){let r,o;const l=t.ImageManager.get(n);return ht&&n===ht.paint&&ft(a,ht.boxBounds)?r=ht.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),ht=l.use>1?{leafPaint:r,paint:n,boxBounds:ut.set(a)}:null),(s||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(pt(e,i,n,l,r,a),s&&(gt(e,o),_t(e,o))):l.error?s&&yt(e,o,l.error):(s&&(wt(e,!0),gt(e,o)),r.loadId=l.load(()=>{wt(e,!1),e.destroyed||(pt(e,i,n,l,r,a)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),_t(e,o)),r.loadId=void 0},t=>{wt(e,!1),yt(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(e,i,s,r){const{scaleX:o,scaleY:l}=e.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:d}=i,{data:c}=s;if(!c||s.patternId===o+"-"+l+"-"+d&&!n.Export.running)return!1;if(r)if(c.repeat)r=!1;else if(!(s.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(e)||n.Export.running)){let{width:e,height:i}=c;e*=o*d,i*=l*d,c.scaleX&&(e*=c.scaleX,i*=c.scaleY),r=e*i>t.Platform.image.maxCacheSize}return r?(e.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,n){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(e,i,s,c),!0):(!s.style||s.sync||n.Export.running?kt(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add(()=>a(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&kt(e,s,d),e.forceUpdate("surface")}),300)),!1)},createPattern:kt,recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let a,s,r,o,l;for(let d=0,c=n.length;d<c;d++)a=n[d],s=a.image,l=s&&s.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),s.unload(n[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:lt,getPatternData:dt,fillOrFitMode:$,clipMode:tt,repeatMode:et},{toPoint:St}=t.AroundHelper,{hasTransparent:Pt}=n.ColorConvert,Ct={},At={};function Tt(e,i,a,s){if(a){let r,o,l,d;for(let e=0,c=a.length;e<c;e++)r=a[e],t.isString(r)?(l=e/(c-1),o=n.ColorConvert.string(r,s)):(l=r.offset,o=n.ColorConvert.string(r.color,s)),i.addColorStop(l,o),!d&&Pt(o)&&(d=!0);d&&(e.isTransparent=!0)}}const{getAngle:Ot,getDistance:Mt}=t.PointHelper,{get:Wt,rotateOfOuter:Dt,scaleOfOuter:Ht}=t.MatrixHelper,{toPoint:It}=t.AroundHelper,Ft={},Ut={};function jt(t,e,i,n,a){let s;const{width:r,height:o}=t;if(r!==o||n){const t=Ot(e,i);s=Wt(),a?(Ht(s,e,r/o*(n||1),1),Dt(s,e,t+90)):(Ht(s,e,1,r/o*(n||1)),Dt(s,e,t))}return s}const{getDistance:Yt}=t.PointHelper,{toPoint:Xt}=t.AroundHelper,zt={},Gt={};const Nt={linearGradient:function(e,i){let{from:n,to:a,type:s,opacity:r}=e;St(n||"top",i,Ct),St(a||"bottom",i,At);const o=t.Platform.canvas.createLinearGradient(Ct.x,Ct.y,At.x,At.y),l={type:s,style:o};return Tt(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:a,type:s,opacity:r,stretch:o}=e;It(n||"center",i,Ft),It(a||"bottom",i,Ut);const l=t.Platform.canvas.createRadialGradient(Ft.x,Ft.y,0,Ft.x,Ft.y,Mt(Ft,Ut)),d={type:s,style:l};Tt(d,l,e.stops,r);const c=jt(i,Ft,Ut,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,i){let{from:n,to:a,type:s,opacity:r,stretch:o}=e;Xt(n||"center",i,zt),Xt(a||"bottom",i,Gt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,zt.x,zt.y):t.Platform.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,Yt(zt,Gt)),d={type:s,style:l};Tt(d,l,e.stops,r);const c=jt(i,zt,Gt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:jt},{copy:qt,toOffsetOutBounds:Vt}=t.BoundsHelper,Qt={},Jt={};function Zt(e,i,n,a){const{bounds:s,shapeBounds:r}=a;if(t.Platform.fullImageShadow){if(qt(Qt,e.bounds),Qt.x+=i.x-r.x,Qt.y+=i.y-r.y,n){const{fitMatrix:t}=a;Qt.x-=(s.x+(t?t.e:0)+s.width/2)*(n-1),Qt.y-=(s.y+(t?t.f:0)+s.height/2)*(n-1),Qt.width*=n,Qt.height*=n}e.copyWorld(a.canvas,e.bounds,Qt)}else n&&(qt(Qt,i),Qt.x-=i.width/2*(n-1),Qt.y-=i.height/2*(n-1),Qt.width*=n,Qt.height*=n),e.copyWorld(a.canvas,r,n?Qt:i)}const{toOffsetOutBounds:Kt}=t.BoundsHelper,$t={};const te={shadow:function(e,i,a){let s,r;const{__nowWorld:o,__layout:l}=e,{shadow:d}=e.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=a,g=i.getSameCanvas(),_=d.length-1;Vt(h,Jt),d.forEach((d,y)=>{let m=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(m=1/t)}g.setWorldShadow(Jt.offsetX+d.x*f*m,Jt.offsetY+d.y*p*m,d.blur*f*m,n.ColorConvert.string(d.color)),r=d.spread?1+2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*m:0,Zt(g,Jt,r,a),s=h,d.box&&(g.restore(),g.save(),c&&(g.copyWorld(g,h,o,"copy"),s=o),c?g.copyWorld(c,o,o,"destination-out"):g.copyWorld(a.canvas,u,h,"destination-out")),t.LeafHelper.copyCanvasByWorld(e,i,g,s,d.blendMode),_&&y<_&&g.clearWorld(s,!0)}),g.recycle(s)},innerShadow:function(e,i,a){let s,r;const{__nowWorld:o,__layout:l}=e,{innerShadow:d}=e.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=a,g=i.getSameCanvas(),_=d.length-1;Kt(h,$t),d.forEach((d,y)=>{let m=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(m=1/t)}g.save(),g.setWorldShadow($t.offsetX+d.x*f*m,$t.offsetY+d.y*p*m,d.blur*f*m),r=d.spread?1-2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*m:0,Zt(g,$t,r,a),g.restore(),c?(g.copyWorld(g,h,o,"copy"),g.copyWorld(c,o,o,"source-out"),s=o):(g.copyWorld(a.canvas,u,h,"source-out"),s=h),g.fillWorld(s,n.ColorConvert.string(d.color),"source-in"),t.LeafHelper.copyCanvasByWorld(e,i,g,s,d.blendMode),_&&y<_&&g.clearWorld(s,!0)}),g.recycle(s)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:ee}=t.LeafBoundsHelper;let ie;function ne(t,e,i,n,a,s,r,o){switch(e){case"grayscale":ie||(ie=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,a,s){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),s&&n.recycle(r);se(t,e,i,1,a,s)}(t,i,n,a,r,o);break;case"opacity-path":se(t,i,n,s,r,o);break;case"path":o&&i.restore()}}function ae(t){return t.getSameCanvas(!1,!0)}function se(t,e,i,n,a,s){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,a),s?i.recycle(r):i.clearWorld(r,!0)}n.Group.prototype.__renderMask=function(t,e){let i,n,a,s,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(ne(this,r,t,a,n,s,void 0,!0),n=a=null),s=i.__.opacity,ie=!1,"path"===o||"clipping-path"===o?(s<1?(r="opacity-path",a||(a=ae(t))):(r="path",t.save()),i.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=ae(t)),a||(a=ae(t)),i.__render(n,e)),"clipping"!==o&&"clipping-path"!==o||ee(i,e)||i.__render(t,e);continue}const c=1===s&&i.__.__blendMode;c&&ne(this,r,t,a,n,s,void 0,!1),ee(i,e)||i.__render(a||t,e),c&&ne(this,r,t,a,n,s,c,!1)}ne(this,r,t,a,n,s,void 0,!0)};const re=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",oe=re+"_#~&*+\\=|≮≯≈≠=…",le=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function de(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ce=de("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),he=de("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ue=de(re),fe=de(oe),pe=de("- —/~|┆·");var ge;!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"}(ge||(ge={}));const{Letter:_e,Single:ye,Before:me,After:we,Symbol:ve,Break:xe}=ge;function be(t){return ce[t]?_e:pe[t]?xe:he[t]?me:ue[t]?we:fe[t]?ve:le.test(t)?ye:_e}const Be={trimRight(t){const{words:e}=t;let i,n=0,a=e.length;for(let s=a-1;s>-1&&(i=e[s].data[0]," "===i.char);s--)n++,t.width-=i.width;n&&e.splice(a-n,n)}};function Ee(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Le}=Be,{Letter:ke,Single:Re,Before:Se,After:Pe,Symbol:Ce,Break:Ae}=ge;let Te,Oe,Me,We,De,He,Ie,Fe,Ue,je,Ye,Xe,ze,Ge,Ne,qe,Ve,Qe=[];function Je(t,e){Ue&&!Fe&&(Fe=Ue),Te.data.push({char:t,width:e}),Me+=e}function Ze(){We+=Me,Te.width=Me,Oe.words.push(Te),Te={data:[]},Me=0}function Ke(){Ge&&(Ne.paraNumber++,Oe.paraStart=!0,Ge=!1),Ue&&(Oe.startCharSize=Fe,Oe.endCharSize=Ue,Fe=0),Oe.width=We,qe.width?Le(Oe):Ve&&$e(),Qe.push(Oe),Oe={words:[]},We=0}function $e(){We>(Ne.maxWidth||0)&&(Ne.maxWidth=We)}const{top:ti,right:ei,bottom:ii,left:ni}=t.Direction4;function ai(t,e,i){const{bounds:n,rows:a}=t;n[e]+=i;for(let t=0;t<a.length;t++)a[t][e]+=i}const si={getDrawData:function(e,i){t.isString(e)||(e=String(e));let a=0,s=0,r=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=i;c&&(r?(a=c[ni],r-=c[ei]+c[ni]):i.autoSizeAlign||(a=c[ni]),o?(s=c[ti],o-=c[ti]+c[ii]):i.autoSizeAlign||(s=c[ti]));const h={bounds:{x:a,y:s,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,i,n){Ne=e,Qe=e.rows,qe=e.bounds,Ve=!qe.width&&!n.autoSizeAlign;const{__letterSpacing:a,paraIndent:s,textCase:r}=n,{canvas:o}=t.Platform,{width:l,height:d}=qe;if(l||d||a||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Ge=!0,Ye=null,Fe=Ie=Ue=Me=We=0,Te={data:[]},Oe={words:[]},a&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)He=i[n],"\n"===He?(Me&&Ze(),Oe.paraEnd=!0,Ke(),Ge=!0):(je=be(He),je===ke&&"none"!==r&&(He=Ee(He,r,!Me)),Ie=o.measureText(He).width,a&&(a<0&&(Ue=Ie),Ie+=a),Xe=je===Re&&(Ye===Re||Ye===ke)||Ye===Re&&je!==Pe,ze=!(je!==Se&&je!==Re||Ye!==Ce&&Ye!==Pe),De=Ge&&s?l-s:l,t&&l&&We+Me+Ie>De&&(e?(Me&&Ze(),We&&Ke()):(ze||(ze=je===ke&&Ye==Pe),Xe||ze||je===Ae||je===Se||je===Re||Me+Ie>De?(Me&&Ze(),We&&Ke()):We&&Ke()))," "===He&&!0!==Ge&&We+Me===0||(je===Ae?(" "===He&&Me&&Ze(),Je(He,Ie),Ze()):Xe||ze?(Me&&Ze(),Je(He,Ie)):Je(He,Ie)),Ye=je);Me&&Ze(),We&&Ke(),Qe.length>0&&(Qe[Qe.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ne.paraNumber++,We=o.measureText(t).width,Qe.push({x:s||0,text:t,width:We,paraStart:!0}),Ve&&$e()})}(h,e,i),c&&function(t,e,i,n,a){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ai(e,"x",t[ni]);break;case"right":ai(e,"x",-t[ei])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ai(e,"y",t[ti]);break;case"bottom":ai(e,"y",-t[ii])}}(c,h,i,r,o),function(t,e){const{rows:i,bounds:n}=t,a=i.length,{__lineHeight:s,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,y=s*a+(h?h*(t.paraNumber-1):0),m=r;if(l&&y>_)y=Math.max(_,s),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":p+=(_-y)/2;break;case"bottom":p+=_-y}m+=p;let w,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=a;r<c;r++){if(w=i[r],w.x=f,w.width<g||w.width>g&&!l)switch(d){case"center":w.x+=(b-w.width)/2;break;case"right":w.x+=b-w.width}w.paraStart&&h&&r>0&&(m+=h),w.y=m,m+=s,t.overflow>r&&m>y&&(w.isOverflow=!0,t.overflow=r+1),v=w.x,x=w.width,o<0&&(w.width<0?(x=-w.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(w.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=y}(h,i),function(t,e,i){const{rows:n}=t,{textAlign:a,paraIndent:s,letterSpacing:r}=e;let o,l,d,c,h,u;n.forEach(t=>{t.words&&(d=s&&t.paraStart?s:0,u=t.words.length,l=i&&("justify"===a||"both"===a)&&u>1?(i-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,o=t.x,t.data=[],t.words.forEach((e,i)=>{1===c?(h={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,i,n){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==a||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(h,i,r),h.overflow&&function(e,i,n,a){if(!a)return;const{rows:s,overflow:r}=e;let{textOverflow:o}=i;if(s.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=n+a-d;("none"===i.textWrap?s:[s[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<c));n--){if(l<c&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(h,i,a,r),"none"!==l&&function(e,i){let a;const{fontSize:s,textDecoration:r}=i;switch(e.decorationHeight=s/11,t.isObject(r)?(a=r.type,r.color&&(e.decorationColor=n.ColorConvert.string(r.color))):a=r,a){case"under":e.decorationY=[.15*s];break;case"delete":e.decorationY=[.35*-s];break;case"under-delete":e.decorationY=[.15*s,.35*-s]}}(h,i),h}};const ri={string:function(e,i){const a=t.isNumber(i)&&i<1;if(t.isString(e)){if(!a||!n.ColorConvert.object)return e;e=n.ColorConvert.object(e)}let s=t.isUndefined(e.a)?1:e.a;a&&(s*=i);const r=e.r+","+e.g+","+e.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}};Object.assign(n.TextConvert,si),Object.assign(n.ColorConvert,ri),Object.assign(n.Paint,Y),Object.assign(n.PaintImage,Rt),Object.assign(n.PaintGradient,Nt),Object.assign(n.Effect,te);const{setPoint:oi,addPoint:li,toBounds:di}=n.TwoPointBoundsHelper;const ci={syncExport(t,e,i){let a;n.Export.running=!0;try{const s=n.FileHelper.fileType(e),r=e.includes(".");i=n.FileHelper.getExportOptions(i);const{toURL:o}=n.Platform,{download:l}=n.Platform.origin;if("json"===s)r&&l(o(JSON.stringify(t.toJSON(i.json)),"text"),e),a={data:!!r||t.toJSON(i.json)};else if("svg"===s)r&&l(o(t.toSVG(),"svg"),e),a={data:!!r||t.toSVG()};else{let s,r,o=1,l=1;const{worldTransform:d,isLeafer:c,leafer:h,isFrame:u}=t,{slice:f,clip:p,trim:g,screenshot:_,padding:y,onCanvas:m}=i,w=n.isUndefined(i.smooth)?!h||h.config.smooth:i.smooth,v=i.contextSettings||(h?h.config.contextSettings:void 0),x=c&&_&&n.isUndefined(i.fill)?t.fill:i.fill,b=n.FileHelper.isOpaqueImage(e)||x,B=new n.Matrix;if(_)s=!0===_?c?h.canvas.bounds:t.worldRenderBounds:_;else{let e=i.relative||(c?"inner":"local");switch(o=d.scaleX,l=d.scaleY,e){case"inner":B.set(d);break;case"local":B.set(d).divide(t.localTransform),o/=t.scaleX,l/=t.scaleY;break;case"world":o=1,l=1;break;case"page":e=h||t;default:B.set(d).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,l/=l/i.scaleY}s=t.getBounds("render",e)}const E={scaleX:1,scaleY:1};n.MathHelper.getScaleData(i.scale,i.size,s,E);let L=i.pixelRatio||1,{x:k,y:R,width:S,height:P}=new n.Bounds(s).scale(E.scaleX,E.scaleY);p&&(k+=p.x,R+=p.y,S=p.width,P=p.height);const C={exporting:!0,matrix:B.scale(1/E.scaleX,1/E.scaleY).invert().translate(-k,-R).withScale(1/o*E.scaleX,1/l*E.scaleY)};let A,T=n.Creator.canvas({width:Math.floor(S),height:Math.floor(P),pixelRatio:L,smooth:w,contextSettings:v});if(f&&(A=t,A.__worldOpacity=0,t=h||t,C.bounds=T.bounds),T.save(),u&&!n.isUndefined(x)){const e=t.get("fill");t.fill="",t.__render(T,C),t.fill=e}else t.__render(T,C);if(T.restore(),A&&A.__updateWorldOpacity(),g){r=function(t){const{width:e,height:i}=t.view,{data:a}=t.context.getImageData(0,0,e,i);let s,r,o,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(s=l%e,r=(l-s)/e,o?li(o,s,r):oi(o={},s,r)),l++;const d=new n.Bounds;return o&&(di(o,d),d.scale(1/t.pixelRatio).ceil()),d}(T);const t=T,{width:e,height:i}=r,a={x:0,y:0,width:e,height:i,pixelRatio:L};T=n.Creator.canvas(a),T.copyWorld(t,r,a),t.destroy()}if(y){const[t,e,i,a]=n.MathHelper.fourNumber(y),s=T,{width:r,height:o}=s;T=n.Creator.canvas({width:r+a+e,height:o+t+i,pixelRatio:L}),T.copyWorld(s,s.bounds,{x:a,y:t,width:r,height:o}),s.destroy()}b&&T.fillWorld(T.bounds,x||"#FFFFFF","destination-over"),m&&m(T);a={data:"canvas"===e?T:T.export(e,i),width:T.pixelWidth,height:T.pixelHeight,renderBounds:s,trimBounds:r}}}catch(t){a={data:"",error:t}}return n.Export.running=!1,a},export(t,e,i){return n.Export.running=!0,function(t){hi||(hi=new n.TaskProcessor);return new Promise(e=>{hi.add(()=>a(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(r=>{const o=()=>a(this,void 0,void 0,function*(){if(!n.Resource.isComplete)return n.Platform.requestRender(o);const a=n.Export.syncExport(t,e,i);a.data instanceof Promise&&(a.data=yield a.data),s(a),r()});t.updateLayout(),ui(t);const{leafer:l}=t;l?l.waitViewCompleted(o):o()}))}};let hi;function ui(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>ui(t))}const fi=n.LeaferCanvasBase.prototype,pi=n.Debug.get("@leafer-in/export");fi.export=function(t,e){const{quality:i,blob:a}=n.FileHelper.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):a?this.toBlob(t,i):this.toDataURL(t,i)},fi.toBlob=function(t,e){return new Promise(i=>{n.Platform.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{pi.error(t),i(null)})})},fi.toDataURL=function(t,e){return n.Platform.origin.canvasToDataURL(this.view,t,e)},fi.saveAs=function(t,e){return new Promise(i=>{n.Platform.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{pi.error(t),i(!1)})})},n.Plugin.add("export"),Object.assign(n.Export,ci),n.UI.prototype.export=function(t,e){return n.Export.export(this,t,e)},n.UI.prototype.syncExport=function(t,e){return n.Export.syncExport(this,t,e)},Object.assign(t.Creator,{interaction:(t,e,n,a)=>new i.InteractionBase(t,e,n,a),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new i.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=w,exports.LeaferCanvas=s,exports.Picker=B,exports.Renderer=x,exports.Selector=E,exports.Watcher=l,exports.useCanvas=function(i,n){if(t.Platform.canvasType=i,!t.Platform.origin){if("skia"===i){const{Canvas:e,loadImage:i}=n;t.Platform.origin={createCanvas:(t,i,n)=>new e(t,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:e=>i(t.Platform.image.getRealURL(e))},t.Platform.roundRectPatch=!0}else if("napi"===i){const{Canvas:i,loadImage:s}=n;t.Platform.origin={createCanvas:(t,e,n)=>new i(t,e,n),canvasToDataURL:(t,e,i)=>t.toDataURL(r(e),i),canvasToBolb:(t,e,i)=>a(this,void 0,void 0,function*(){return t.toBuffer(r(e),i)}),canvasSaveAs:(t,i,n)=>a(this,void 0,void 0,function*(){return e.writeFileSync(i,t.toBuffer(r(o(i)),n))}),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(i).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return i[t]}})});
2
2
  //# sourceMappingURL=node.min.cjs.map