@leafer-ui/node 1.6.1 → 1.6.3
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.cjs +211 -209
- package/dist/node.esm.js +221 -219
- package/dist/node.esm.min.js +1 -1
- package/dist/node.esm.min.js.map +1 -1
- package/dist/node.min.cjs +1 -1
- package/dist/node.min.cjs.map +1 -1
- package/package.json +12 -12
- package/dist/node.cjs.map +0 -1
- package/dist/node.esm.js.map +0 -1
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,s){function o(t){try{l(i.next(t))}catch(t){s(t)}}function r(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:o,fileType:r}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new s(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){setTimeout(t,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1}),t.Platform.conicGradientSupport=!0;class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds: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:s,LAYOUT:o,AFTER:r}=t.LayoutEvent,l=this.getBlocks(a);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(s,l,this.times)),this.extraBlock=null,a.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||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(o,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:s}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),m.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,o,this.times)),n.emitEvent(new t.LayoutEvent(s,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){_(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(){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),s=new t.Bounds(a);i.save(),a.spread(x.clipSpread).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0),this.__render(a,s),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),s=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,s),this.renderBounds=n=n||e,this.renderOptions=s,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,s=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),a?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:a,y:s}=this.point,o={x:a,y:s,radiusX:0,radiusY:0};for(let a=0,s=e.length;a<s;a++)if(n=e[a],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,o),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return this.target&&n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,a=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(a.addAt(i,0),i.__.hitChildren);t--);return a}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let a,s,o;for(let t=0,e=i.length;t<e;t++){a=i[t],s=i[t+1];for(let t=0,e=a.length;t<e&&(o=a.list[t],!s||!s.has(o));t++)n.add(o)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:a}=this;for(let s=t.length-1;s>-1;s--)n=t[s],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,a),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,a)):i&&this.hitChild(n,a))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class E{constructor(e,n){this.config={},n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new B(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,n,i){const{target:a,picker:s}=this;return t.Platform.backgrounder&&a&&a.updateLayout(),s.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:s}=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(s){const{decorationColor:t,decorationHeight:n}=i;t&&(e.fillStyle=t),a.forEach((t=>s.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:s,__font:o}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*s,i.__),r.font=o,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:s}=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(s){const{decorationHeight:t}=i;a.forEach((n=>s.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function S(t,e,n,a){let s;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&i.PaintImage.checkImage(n,a,s,!1)||s.style&&(a.strokeStyle=s.style,s.blendMode?(a.saveBlendMode(s.blendMode),e?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:s,blendMode:o,color:r,opacity:l}=e;return{type:s,blendMode:o,style:i.ColorConvert.string(r,l)};case"image":return i.PaintImage.image(n,t,e,a,!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 s,o=n.__input[t];o instanceof Array||(o=[o]),M=i.PaintImage.recycleImage(t,n);for(let n,i=0,s=o.length;i<s;i++)n=I(t,o[i],e),n&&a.push(n);n["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(s=a[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?L(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let a;const{windingRule:s,__font:o}=e.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&i.PaintImage.checkImage(e,n,a,!o)||a.style&&(n.fillStyle=a.style,a.transform?(n.save(),n.transform(a.transform),a.blendMode&&(n.blendMode=a.blendMode),o?L(e,n):s?n.fill(s):n.fill(),n.restore()):a.blendMode?(n.saveBlendMode(a.blendMode),o?L(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?L(e,n):s?n.fill(s):n.fill())},fillText:L,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)R(t,e,n);else switch(s){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 s=n.getSameCanvas(!0,!0);s.setStroke(t,2*a,i),e.__drawRenderPath(s),s.stroke(),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,e.__layout.renderBounds),s.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)R(t,e,n);else switch(s){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:s}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*a,i),S(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(s),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,s),o.recycle(e.__nowWorld)}},strokeText:R,drawTextStroke:P,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let s,o,r,l,{scaleX:d,scaleY:c}=a;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(a))l=i,s=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);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=W(a,o),s=O(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:s,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let H={};const{get:F,rotateOfOuter:Y,translate:j,scaleOfOuter:U,scale:G,rotate:X}=t.MatrixHelper;function q(t,e,n,i,a,s,o){const r=F();j(r,e.x+n,e.y+i),G(r,a,s),o&&Y(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function z(t,e,n,i,a,s,o){const r=F();j(r,e.x+n,e.y+i),a&&G(r,a,s),o&&X(r,o),t.transform=r}function N(t,e,n,i,a,s,o,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+s,j(c,H.x,H.y),o&&U(c,H,o,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:s,sync:o}=n;a&&(t.blendMode=a),s&&(t.changeful=s),o&&(t.sync=o),t.data=tt(n,i,e)}function tt(e,n,i){let{width:a,height:s}=i;e.padding&&(n=J.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===a&&n.height===s,_={mode:r},y="center"!==l&&(u||0)%180==90,w=y?s:a,m=y?a:s;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-s*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,s=n.height);break;case"normal":case"clip":(b||B||v||u)&&z(_,n,b,B,v,x,u);break;case"repeat":(!g||v||u)&&N(_,n,a,s,b,B,v,x,u,l),f||(_.repeat="repeat");break;default:v&&q(_,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=s,o&&(_.opacity=o),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,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||$(a,i,n,s),!0}function st(e,n){lt(e,t.ImageEvent.LOAD,n)}function ot(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:s}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=a+"-"+s+"-"+i;if(n.patternId===o||e.destroyed)return!1;{a=pt(a),s=pt(s);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,s*=f),a*=i,s*=i,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=ct(),p&&ut(d,p)),ht(d,1/a,1/s));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=o,!0}}const{abs:_t}=Math;const yt={image:function(e,n,i,a,s){let o,r;const l=t.ImageManager.get(i);return et&&i===et.paint&&it(a,et.boxBounds)?o=et.leafPaint:(o={type:i.type,image:l},et=l.use>1?{leafPaint:o,paint:i,boxBounds:nt.set(a)}:null),(s||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(at(e,n,i,l,o,a),s&&(st(e,r),ot(e,r))):l.error?s&&rt(e,r,l.error):(s&&(dt(e,!0),st(e,r)),o.loadId=l.load((()=>{dt(e,!1),e.destroyed||(at(e,n,i,l,o,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ot(e,r)),o.loadId=null}),(t=>{dt(e,!1),rt(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,s,o){const{scaleX:r,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=n,{data:c}=s;if(!c||s.patternId===r+"-"+l+"-"+d&&!i.Export.running)return!1;if(o)if(c.repeat)o=!1;else if(!(s.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),o=e*n>t.Platform.image.maxCacheSize}return o?(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,s,c),!0):(!s.style||s.sync||i.Export.running?gt(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>a(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&>(e,s,d),e.forceUpdate("surface")}))),300)),!1)},createPattern:gt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,s,o,r,l;for(let d=0,c=i.length;d<c;d++)a=i[d],s=a.image,l=s&&s.url,l&&(o||(o={}),o[l]=!0,t.ImageManager.recycle(s),s.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===l)))));return o}return null},createData:$,getPatternData:tt,fillOrFitMode:q,clipMode:z,repeatMode:N},{toPoint:wt}=t.AroundHelper,mt={},vt={};function xt(t,e,n){if(e){let a;for(let s=0,o=e.length;s<o;s++)a=e[s],"string"==typeof a?t.addColorStop(s/(o-1),i.ColorConvert.string(a,n)):t.addColorStop(a.offset,i.ColorConvert.string(a.color,n))}}const{getAngle:bt,getDistance: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 s;const{width:o,height:r}=t;if(o!==r||i){const t=bt(e,n);s=Et(),a?(Rt(s,e,o/r*(i||1),1),Lt(s,e,t+90)):(Rt(s,e,1,o/r*(i||1)),Lt(s,e,t))}return s}const{getDistance:At}=t.PointHelper,{toPoint:Wt}=t.AroundHelper,Ot={},Tt={};const Mt={linearGradient:function(e,n){let{from:i,to:a,type:s,blendMode:o,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:s,style:l};return o&&(d.blendMode=o),d},radialGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:l}=e;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,o);const c={type:s,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:s,opacity:o,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,o);const c={type:s,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:s,shapeBounds:o}=a;if(t.Platform.fullImageShadow){if(It(Ht,e.bounds),Ht.x+=n.x-o.x,Ht.y+=n.y-o.y,i){const{matrix:t}=a;Ht.x-=(s.x+(t?t.e:0)+s.width/2)*(i-1),Ht.y-=(s.y+(t?t.f:0)+s.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,o,i?Ht:n)}const{toOffsetOutBounds:jt}=t.BoundsHelper,Ut={};const Gt={shadow:function(t,e,n){let a,s;const{__nowWorld:o,__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)),s=l.spread?1+2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Yt(p,Ft,s,n),a=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,o,"copy"),a=o),d?p.copyWorld(d,o,o,"destination-out"):p.copyWorld(n.canvas,h,c,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,a,o,l.blendMode):e.copyWorldToInner(p,a,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(a,!0)})),p.recycle(a)},innerShadow:function(t,e,n){let a,s;const{__nowWorld:o,__layout:r}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds: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),s=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Yt(p,Ut,s,n),p.restore(),d?(p.copyWorld(p,c,o,"copy"),p.copyWorld(d,o,o,"source-out"),a=o):(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,o,l.blendMode):e.copyWorldToInner(p,a,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(a,!0)})),p.recycle(a)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Xt}=t.LeafBoundsHelper;function qt(t,e,n,i,a,s){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Nt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Nt(t,n,i,s);break;case"path":n.restore()}}function zt(t){return t.getSameCanvas(!1,!0)}function Nt(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}i.Group.prototype.__renderMask=function(t,e){let n,i,a,s,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(o&&(qt(this,o,t,a,i,s),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",s=n.opacity,a||(a=zt(t))):(o="path",t.save()),n.__clip(a||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=zt(t)),a||(a=zt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Xt(n,e)||n.__render(a||t,e);qt(this,o,t,a,i,s)};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:se,Before:oe,After:re,Symbol:le,Break:de}=ie;function ce(t){return Kt[t]?ae:ne[t]?de:$t[t]?oe:te[t]?re:ee[t]?le:Jt.test(t)?se:ae}const he={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let s=a-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function 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:qe}=t.Direction4;function ze(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const Ne={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let a=0,s=0,o=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=n;c&&(o?(a=c[qe],o-=c[Ge]+c[qe]):n.autoSizeAlign||(a=c[qe]),r?(s=c[Ue],r-=c[Ue]+c[Xe]):n.autoSizeAlign||(s=c[Ue]));const h={bounds:{x:a,y:s,width:o,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:s,textCase:o}=i,{canvas:r}=t.Platform,{width:l,height:d}=Me;if(l||d||a||"none"!==o){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"!==o&&(Le=ue(Le,o,!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&&s?l-s: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:s||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":ze(e,"x",t[qe]);break;case"right":ze(e,"x",-t[Ge])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":ze(e,"y",t[Ue]);break;case"bottom":ze(e,"y",-t[Xe])}}(c,h,n,o,r),function(t,e){const{rows:n,bounds:i}=t,a=n.length,{__lineHeight:s,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,y=s*a+(h?h*(t.paraNumber-1):0),w=o;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}w+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=a;o<c;o++){if(m=n[o],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&&o>0&&(w+=h),m.y=w,w+=s,t.overflow>o&&w>y&&(m.isOverflow=!0,t.overflow=o+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:s,letterSpacing:o}=e;let r,l,d,c,h,u;i.forEach((t=>{t.words&&(d=s&&t.paraStart?s:0,u=t.words.length,l=n&&("justify"===a||"both"===a)&&u>1?(n-t.width-d)/(u-1):0,c=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(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,o),h.overflow&&function(e,n,i,a){if(!a)return;const{rows:s,overflow:o}=e;let{textOverflow:r}=n;if(s.splice(o),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+a-d;("none"===n.textWrap?s:[s[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<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,o),"none"!==l&&function(t,e){let n;const{fontSize:a,textDecoration:s}=e;switch(t.decorationHeight=a/11,"object"==typeof s?(n=s.type,s.color&&(t.decorationColor=i.ColorConvert.string(s.color))):n=s,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 s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(i.TextConvert,Ne),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 s=i.FileHelper.fileType(e),o=e.includes(".");n=i.FileHelper.getExportOptions(n);const{toURL:r}=i.Platform,{download:l}=i.Platform.origin;if("json"===s)o&&l(r(JSON.stringify(t.toJSON(n.json)),"text"),e),a={data:!!o||t.toJSON(n.json)};else if("svg"===s)o&&l(r(t.toSVG(),"svg"),e),a={data:!!o||t.toSVG()};else{let s,o,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)s=!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}s=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};i.MathHelper.getScaleData(n.scale,n.size,s,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(s).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){o=function(t){const{width:e,height:n}=t.view,{data:a}=t.context.getImageData(0,0,e,n);let s,o,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(s=l%e,o=(l-s)/e,r?Je(r,s,o):Qe(r={},s,o)),l++;const d=new i.Bounds;return Ze(r,d),d.scale(1/t.pixelRatio).ceil()}(A);const t=A,{width:e,height:n}=o,a={x:0,y:0,width:e,height:n,pixelRatio:E};A=i.Creator.canvas(a),A.copyWorld(t,o,a)}if(g){const[t,e,n,a]=i.MathHelper.fourNumber(g),s=A,{width:o,height:r}=s;A=i.Creator.canvas({width:o+a+e,height:r+t+n,pixelRatio:E}),A.copyWorld(s,s.bounds,{x:a,y:t,width:o,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:s,trimBounds:o}}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})}))}((s=>new Promise((o=>{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),s(a),o()}));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 s(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=s,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:s}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(o(e),n),canvasToBolb:(t,e,n)=>a(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,i)=>a(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(r(n)),i))})),download(t,e){},loadImage:e=>s(t.Platform.image.getRealURL(e))}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/core"),i=require("@leafer-ui/draw");function a(t,e,n,i){return new(n||(n=Promise))((function(a,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function o(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,o)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType: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,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=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 w{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.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 n=t.Run.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:s,LAYOUT:r,AFTER:o}=t.LayoutEvent,l=this.getBlocks(a);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(s,l,this.times)),this.extraBlock=null,a.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||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(o,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:s}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),w.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,r,this.times)),n.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: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(){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,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),s=new t.Bounds(a);i.save(),a.spread(x.clipSpread).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0),this.__render(a,s),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),s=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,s),this.renderBounds=n=n||e,this.renderOptions=s,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(){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,n,i){n||(n=0),i||(i={});const a=i.through||!1,s=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:o}=this.findList,l=this.getBestMatchLeaf(o,i.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,n,i){if(e.length){let n;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(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,s,r;for(let t=0,e=i.length;t<e;t++){a=i[t],s=i[t+1];for(let t=0,e=a.length;t<e&&(r=a.list[t],!s||!s.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 s=t.length-1;s>-1;s--)n=t[s],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,a),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,a)):i&&this.hitChild(n,a))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class E{constructor(e,n){this.config={},n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new B(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,n,i){const{target:a,picker:s}=this;return t.Platform.backgrounder&&a&&a.updateLayout(),s.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 s;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=i.length;t<n;t++)s=i[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}=n.__textDrawData;t&&(e.fillStyle=t),i.forEach((t=>a.forEach((n=>e.fillRect(t.x,t.y+n,t.width,s)))))}}function R(t,e){t.__.__font?L(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new w(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>new E(t,e)}),t.Platform.layout=w.fullLayout;const P={};function k(t,e,n){switch(e.__.strokeAlign){case"center":S(t,1,e,n);break;case"inside":C(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?S(t,2,e,n):C(t,"outside",e,n)}}function S(t,e,n,i){const a=n.__;i.setStroke(!a.__isStrokes&&t,a.strokeWidth*e,a),a.__isStrokes?T(t,!0,n,i):A(n,i)}function C(t,e,i,a){const s=a.getSameCanvas(!0,!0);s.font=i.__.__font,S(t,2,i,s),s.blendMode="outside"===e?"destination-out":"destination-in",L(i,s),s.blendMode="normal",i.__worldFlipped||n.Platform.fullImageShadow?a.copyWorldByReset(s,i.__nowWorld):a.copyWorldToInner(s,i.__nowWorld,i.__layout.renderBounds),s.recycle(i.__nowWorld)}function A(t,e){let n,i=t.__.__textDrawData;const{rows:a,decorationY:s}=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(s){const{decorationHeight:t}=i;a.forEach((n=>s.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function T(t,e,n,a){let s;for(let r=0,o=t.length;r<o;r++)s=t[r],s.image&&i.PaintImage.checkImage(n,a,s,!1)||s.style&&(a.strokeStyle=s.style,s.blendMode?(a.saveBlendMode(s.blendMode),e?A(n,a):a.stroke(),a.restoreBlendMode()):e?A(n,a):a.stroke())}function O(t,e,i){const a=e.__;if(a.__strokeWidth)if(a.__font)k(t,e,i);else switch(a.strokeAlign){case"center":W(t,1,e,i);break;case"inside":!function(t,e,n){const i=e.__;n.save(),i.windingRule?n.clip(i.windingRule):n.clip(),W(t,2,e,n),n.restore()}(t,e,i);break;case"outside":!function(t,e,i){const a=e.__;if(a.__fillAfterStroke)W(t,2,e,i);else{const{renderBounds:s}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),W(t,2,e,r),a.windingRule?r.clip(a.windingRule):r.clip(),r.clearWorld(s),e.__worldFlipped||n.Platform.fullImageShadow?i.copyWorldByReset(r,e.__nowWorld):i.copyWorldToInner(r,e.__nowWorld,s),r.recycle(e.__nowWorld)}}(t,e,i)}}function W(t,e,n,i){const a=n.__;i.setStroke(!a.__isStrokes&&t,a.__strokeWidth*e,a),a.__isStrokes?T(t,!1,n,i):i.stroke(),a.__useArrow&&P.strokeArrow(t,n,i)}const{getSpread:M,getOuterOf:I,getByMove:D,getIntersectData:H}=t.BoundsHelper;let F;const{stintSet:Y}=t.DataHelper,{hasTransparent:j}=i.ColorConvert;function U(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let a;const{boxBounds:s}=n.__layout;switch(e.type){case"image":a=i.PaintImage.image(n,t,e,s,!F||!F[e.url]);break;case"linear":a=i.PaintGradient.linearGradient(e,s);break;case"radial":a=i.PaintGradient.radialGradient(e,s);break;case"angular":a=i.PaintGradient.conicGradient(e,s);break;case"solid":const{type:r,blendMode:o,color:l,opacity:d}=e;a={type:r,blendMode:o,style:i.ColorConvert.string(l,d)};break;default:void 0!==e.r&&(a={type:"solid",style:i.ColorConvert.string(e)})}return a&&("string"==typeof a.style&&j(a.style)&&(a.isTransparent=!0),e.blendMode&&(a.blendMode=e.blendMode)),a}const G={compute:function(t,e){const n=e.__,a=[];let s,r,o=n.__input[t];o instanceof Array||(o=[o]),F=i.PaintImage.recycleImage(t,n);for(let n,i=0,s=o.length;i<s;i++)n=U(t,o[i],e),n&&a.push(n);n["_"+t]=a.length?a:void 0,a.length&&a.every((t=>t.isTransparent))&&(a.some((t=>t.image))&&(s=!0),r=!0),"fill"===t?(Y(n,"__isAlphaPixelFill",s),Y(n,"__isTransparentFill",r)):(Y(n,"__isAlphaPixelStroke",s),Y(n,"__isTransparentStroke",r))},fill:function(t,e,n){n.fillStyle=t,R(e,n)},fills:function(t,e,n){let a;for(let s=0,r=t.length;s<r;s++){if(a=t[s],a.image){if(i.PaintImage.checkImage(e,n,a,!e.__.__font))continue;if(!a.style){!s&&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:O,strokes:function(t,e,n){O(t,e,n)},strokeText:k,drawTextStroke:A,shape:function(t,e,n){const i=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=i,s=o=a;else{const{renderShapeSpread:i}=t.__layout,h=H(i?M(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),o=I(a,r),s=D(o,-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:s,worldCanvas:l,shapeBounds:o,scaleX:d,scaleY:c}}};let X={};const{get:q,rotateOfOuter:z,translate:N,scaleOfOuter:V,scale:Q,rotate:J}=t.MatrixHelper;function Z(t,e,n,i,a,s,r){const o=q();N(o,e.x+n,e.y+i),Q(o,a,s),r&&z(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function K(t,e,n,i,a,s,r){const o=q();N(o,e.x+n,e.y+i),a&&Q(o,a,s),r&&J(o,r),t.transform=o}function $(t,e,n,i,a,s,r,o,l,d){const c=q();if(l)if("center"===d)z(c,{x:n/2,y:i/2},l);else switch(J(c,l),l){case 90:N(c,i,0);break;case 180:N(c,n,i);break;case 270:N(c,0,n)}X.x=e.x+a,X.y=e.y+s,N(c,X.x,X.y),r&&V(c,X,r,o),t.transform=c}const{get:tt,translate:et}=t.MatrixHelper,nt=new t.Bounds,it={},at={};function st(t,e,n,i){const{changeful:a,sync:s}=n;a&&(t.changeful=a),s&&(t.sync=s),t.data=rt(n,i,e)}function rt(e,n,i){e.padding&&(n=nt.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:a,height:s}=i;const{opacity:r,mode:o,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===a&&n.height===s,_={mode:o},y="center"!==l&&(u||0)%180==90;let m,w;switch(t.BoundsHelper.set(at,0,0,y?s:a,y?a:s),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,i,it),m=it.scaleX,w=it.scaleY),l&&(m&&t.BoundsHelper.scale(at,m,w,!0),t.AlignHelper.toPoint(l,at,n,at,!0,!0))):g&&!u||(m=w=t.BoundsHelper.getFitScale(n,at,"fit"!==o),t.BoundsHelper.put(n,i,l,m,!1,at),t.BoundsHelper.scale(at,m,w,!0)),d&&t.PointHelper.move(at,d),o){case"stretch":g||(a=n.width,s=n.height);break;case"normal":case"clip":(at.x||at.y||m||u)&&K(_,n,at.x,at.y,m,w,u);break;case"repeat":(!g||m||u)&&$(_,n,a,s,at.x,at.y,m,w,u,l),f||(_.repeat="repeat");break;default:m&&Z(_,n,at.x,at.y,m,w,u)}return _.transform||(n.x||n.y)&&(_.transform=tt(),et(_.transform,n.x,n.y)),m&&"stretch"!==o&&(_.scaleX=m,_.scaleY=w),_.width=a,_.height=s,r&&(_.opacity=r),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let ot,lt=new t.Bounds;const{isSame:dt}=t.BoundsHelper;function ct(t,e,n,i,a,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||st(a,i,n,s),!0}function ht(e,n){pt(e,t.ImageEvent.LOAD,n)}function ut(e,n){pt(e,t.ImageEvent.LOADED,n)}function ft(e,n,i){n.error=i,e.forceUpdate("surface"),pt(e,t.ImageEvent.ERROR,n)}function pt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function gt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:_t,scale:yt,copy:mt}=t.MatrixHelper,{ceil:wt,abs:vt}=Math;function xt(e,n,i){let{scaleX:a,scaleY:s}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=a+"-"+s+"-"+i;if(n.patternId===r||e.destroyed)return!1;{a=vt(a),s=vt(s);const{image:e,data:o}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=o;u&&(d=_t(),mt(d,p),yt(d,1/u,1/f),a*=u,s*=f),a*=i,s*=i,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=_t(),p&&mt(d,p)),yt(d,1/a,1/s));const m=e.getCanvas(wt(c)||1,wt(h)||1,o.opacity,o.filters),w=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=w,n.patternId=r,!0}}const{abs:bt}=Math;const Bt={image:function(e,n,i,a,s){let r,o;const l=t.ImageManager.get(i);return ot&&i===ot.paint&&dt(a,ot.boxBounds)?r=ot.leafPaint:(r={type:i.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),ot=l.use>1?{leafPaint:r,paint:i,boxBounds:lt.set(a)}:null),(s||l.loading)&&(o={image:l,attrName:n,attrValue:i}),l.ready?(ct(e,n,i,l,r,a),s&&(ht(e,o),ut(e,o))):l.error?s&&ft(e,o,l.error):(s&&(gt(e,!0),ht(e,o)),r.loadId=l.load((()=>{gt(e,!1),e.destroyed||(ct(e,n,i,l,r,a)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ut(e,o)),r.loadId=null}),(t=>{gt(e,!1),ft(e,o,t),r.loadId=null})),e.placeholderColor&&(e.placeholderDelay?setTimeout((()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))}),e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(e,n,s,r){const{scaleX:o,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=n,{data:c}=s;if(!c||s.patternId===o+"-"+l+"-"+d&&!i.Export.running)return!1;if(r)if(c.repeat)r=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:n}=c;e*=bt(o)*d,n*=bt(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,s,c),!0):(!s.style||s.sync||i.Export.running?xt(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>a(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&xt(e,s,d),e.forceUpdate("surface")}))),300)),!1)},createPattern:xt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,s,r,o,l;for(let d=0,c=i.length;d<c;d++)a=i[d],s=a.image,l=s&&s.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),s.unload(i[d].loadId,!o.some((t=>t.url===l)))));return r}return null},createData:st,getPatternData:rt,fillOrFitMode:Z,clipMode:K,repeatMode:$},{toPoint:Et}=t.AroundHelper,{hasTransparent:Lt}=i.ColorConvert,Rt={},Pt={};function kt(t,e,n,a){if(n){let s,r,o,l;for(let t=0,d=n.length;t<d;t++)s=n[t],"string"==typeof s?(o=t/(d-1),r=i.ColorConvert.string(s,a)):(o=s.offset,r=i.ColorConvert.string(s.color,a)),e.addColorStop(o,r),!l&&Lt(r)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:St,getDistance:Ct}=t.PointHelper,{get:At,rotateOfOuter:Tt,scaleOfOuter:Ot}=t.MatrixHelper,{toPoint:Wt}=t.AroundHelper,Mt={},It={};function Dt(t,e,n,i,a){let s;const{width:r,height:o}=t;if(r!==o||i){const t=St(e,n);s=At(),a?(Ot(s,e,r/o*(i||1),1),Tt(s,e,t+90)):(Ot(s,e,1,r/o*(i||1)),Tt(s,e,t))}return s}const{getDistance:Ht}=t.PointHelper,{toPoint:Ft}=t.AroundHelper,Yt={},jt={};const Ut={linearGradient:function(e,n){let{from:i,to:a,type:s,opacity:r}=e;Et(i||"top",n,Rt),Et(a||"bottom",n,Pt);const o=t.Platform.canvas.createLinearGradient(Rt.x,Rt.y,Pt.x,Pt.y),l={type:s,style:o};return kt(l,o,e.stops,r),l},radialGradient:function(e,n){let{from:i,to:a,type:s,opacity:r,stretch:o}=e;Wt(i||"center",n,Mt),Wt(a||"bottom",n,It);const l=t.Platform.canvas.createRadialGradient(Mt.x,Mt.y,0,Mt.x,Mt.y,Ct(Mt,It)),d={type:s,style:l};kt(d,l,e.stops,r);const c=Dt(n,Mt,It,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:i,to:a,type:s,opacity:r,stretch:o}=e;Ft(i||"center",n,Yt),Ft(a||"bottom",n,jt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Yt.x,Yt.y):t.Platform.canvas.createRadialGradient(Yt.x,Yt.y,0,Yt.x,Yt.y,Ht(Yt,jt)),d={type:s,style:l};kt(d,l,e.stops,r);const c=Dt(n,Yt,jt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Dt},{copy:Gt,toOffsetOutBounds:Xt}=t.BoundsHelper,qt={},zt={};function Nt(e,n,i,a){const{bounds:s,shapeBounds:r}=a;if(t.Platform.fullImageShadow){if(Gt(qt,e.bounds),qt.x+=n.x-r.x,qt.y+=n.y-r.y,i){const{matrix:t}=a;qt.x-=(s.x+(t?t.e:0)+s.width/2)*(i-1),qt.y-=(s.y+(t?t.f:0)+s.height/2)*(i-1),qt.width*=i,qt.height*=i}e.copyWorld(a.canvas,e.bounds,qt)}else i&&(Gt(qt,n),qt.x-=n.width/2*(i-1),qt.y-=n.height/2*(i-1),qt.width*=i,qt.height*=i),e.copyWorld(a.canvas,r,i?qt:n)}const{toOffsetOutBounds:Vt}=t.BoundsHelper,Qt={};const Jt={shadow:function(t,e,n){let a,s;const{__nowWorld:r,__layout:o}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Xt(c,zt),l.forEach(((l,_)=>{p.setWorldShadow(zt.offsetX+l.x*u,zt.offsetY+l.y*f,l.blur*u,i.ColorConvert.string(l.color)),s=l.spread?1+2*l.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Nt(p,zt,s,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,o.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(a,!0)})),p.recycle(a)},innerShadow:function(t,e,n){let a,s;const{__nowWorld:r,__layout:o}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Vt(c,Qt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Qt.offsetX+l.x*u,Qt.offsetY+l.y*f,l.blur*u),s=l.spread?1-2*l.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Nt(p,Qt,s,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,o.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:Zt}=t.LeafBoundsHelper;function Kt(t,e,n,i,a,s){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),te(t,e,n,1)}(t,n,i,a);break;case"opacity-path":te(t,n,i,s);break;case"path":n.restore()}}function $t(t){return t.getSameCanvas(!1,!0)}function te(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}i.Group.prototype.__renderMask=function(t,e){let n,i,a,s,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],o=n.__.mask,o&&(r&&(Kt(this,r,t,a,i,s),i=a=null),"path"===o||"clipping-path"===o?(n.opacity<1?(r="opacity-path",s=n.opacity,a||(a=$t(t))):(r="path",t.save()),n.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",i||(i=$t(t)),a||(a=$t(t)),n.__render(i,e)),"clipping"!==o&&"clipping-path"!==o)||Zt(n,e)||n.__render(a||t,e);Kt(this,r,t,a,i,s)};const ee=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ne=ee+"_#~&*+\\=|≮≯≈≠=…",ie=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 ae(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const se=ae("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),re=ae("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),oe=ae(ee),le=ae(ne),de=ae("- —/~|┆·");var ce;!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"}(ce||(ce={}));const{Letter:he,Single:ue,Before:fe,After:pe,Symbol:ge,Break:_e}=ce;function ye(t){return se[t]?he:de[t]?_e:re[t]?fe:oe[t]?pe:le[t]?ge:ie.test(t)?ue:he}const me={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let s=a-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function we(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:ve}=me,{Letter:xe,Single:be,Before:Be,After:Ee,Symbol:Le,Break:Re}=ce;let Pe,ke,Se,Ce,Ae,Te,Oe,We,Me,Ie,De,He,Fe,Ye,je,Ue,Ge,Xe=[];function qe(t,e){Me&&!We&&(We=Me),Pe.data.push({char:t,width:e}),Se+=e}function ze(){Ce+=Se,Pe.width=Se,ke.words.push(Pe),Pe={data:[]},Se=0}function Ne(){Ye&&(je.paraNumber++,ke.paraStart=!0,Ye=!1),Me&&(ke.startCharSize=We,ke.endCharSize=Me,We=0),ke.width=Ce,Ue.width?ve(ke):Ge&&Ve(),Xe.push(ke),ke={words:[]},Ce=0}function Ve(){Ce>(je.maxWidth||0)&&(je.maxWidth=Ce)}const{top:Qe,right:Je,bottom:Ze,left:Ke}=t.Direction4;function $e(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 tn={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let a=0,s=0,r=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=n;c&&(r?(a=c[Ke],r-=c[Je]+c[Ke]):n.autoSizeAlign||(a=c[Ke]),o?(s=c[Qe],o-=c[Qe]+c[Ze]):n.autoSizeAlign||(s=c[Qe]));const h={bounds:{x:a,y:s,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){je=e,Xe=e.rows,Ue=e.bounds,Ge=!Ue.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:s,textCase:r}=i,{canvas:o}=t.Platform,{width:l,height:d}=Ue;if(l||d||a||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Ye=!0,De=null,We=Oe=Me=Se=Ce=0,Pe={data:[]},ke={words:[]},a&&(n=[...n]);for(let i=0,d=n.length;i<d;i++)Te=n[i],"\n"===Te?(Se&&ze(),ke.paraEnd=!0,Ne(),Ye=!0):(Ie=ye(Te),Ie===xe&&"none"!==r&&(Te=we(Te,r,!Se)),Oe=o.measureText(Te).width,a&&(a<0&&(Me=Oe),Oe+=a),He=Ie===be&&(De===be||De===xe)||De===be&&Ie!==Ee,Fe=!(Ie!==Be&&Ie!==be||De!==Le&&De!==Ee),Ae=Ye&&s?l-s:l,t&&l&&Ce+Se+Oe>Ae&&(e?(Se&&ze(),Ce&&Ne()):(Fe||(Fe=Ie===xe&&De==Ee),He||Fe||Ie===Re||Ie===Be||Ie===be||Se+Oe>Ae?(Se&&ze(),Ce&&Ne()):Ce&&Ne()))," "===Te&&!0!==Ye&&Ce+Se===0||(Ie===Re?(" "===Te&&Se&&ze(),qe(Te,Oe),ze()):He||Fe?(Se&&ze(),qe(Te,Oe)):qe(Te,Oe)),De=Ie);Se&&ze(),Ce&&Ne(),Xe.length>0&&(Xe[Xe.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{je.paraNumber++,Ce=o.measureText(t).width,Xe.push({x:s||0,text:t,width:Ce,paraStart:!0}),Ge&&Ve()}))}(h,e,n),c&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":$e(e,"x",t[Ke]);break;case"right":$e(e,"x",-t[Je])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":$e(e,"y",t[Qe]);break;case"bottom":$e(e,"y",-t[Ze])}}(c,h,n,r,o),function(t,e){const{rows:n,bounds:i}=t,a=n.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:_}=i,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=n[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<i.x&&(i.x=v),x>i.width&&(i.width=x),l&&g&&g<x&&(w.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:s,letterSpacing:r}=e;let o,l,d,c,h,u;i.forEach((t=>{t.words&&(d=s&&t.paraStart?s:0,u=t.words.length,l=n&&("justify"===a||"both"===a)&&u>1?(n-t.width-d)/(u-1):0,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,n)=>{1===c?(h={char:"",x:o},o=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==a||n===u-1||(o+=l,t.width+=l)}))),t.words=null)}))}(h,n,r),h.overflow&&function(e,n,i,a){if(!a)return;const{rows:s,overflow:r}=e;let{textOverflow:o}=n;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=i+a-d;("none"===n.textWrap?s:[s[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:o,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:s}=e;switch(t.decorationHeight=a/11,"object"==typeof s?(n=s.type,s.color&&(t.decorationColor=i.ColorConvert.string(s.color))):n=s,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 en={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;n&&(a*=e);const s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(i.TextConvert,tn),Object.assign(i.ColorConvert,en),Object.assign(i.Paint,G),Object.assign(i.PaintImage,Bt),Object.assign(i.PaintGradient,Ut),Object.assign(i.Effect,Jt);const{setPoint:nn,addPoint:an,toBounds:sn}=i.TwoPointBoundsHelper;const rn={syncExport(t,e,n){let a;this.running=!0;const s=i.FileHelper.fileType(e),r=e.includes(".");n=i.FileHelper.getExportOptions(n);const{toURL:o}=i.Platform,{download:l}=i.Platform.origin;if("json"===s)r&&l(o(JSON.stringify(t.toJSON(n.json)),"text"),e),a={data:!!r||t.toJSON(n.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}=n,w=void 0===n.smooth?!h||h.config.smooth:n.smooth,v=n.contextSettings||(h?h.config.contextSettings:void 0),x=c&&_&&void 0===n.fill?t.fill:n.fill,b=i.FileHelper.isOpaqueImage(e)||x,B=new i.Matrix;if(_)s=!0===_?c?h.canvas.bounds:t.worldRenderBounds:_;else{let e=n.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 n=e.worldTransform;o/=o/n.scaleX,l/=l/n.scaleY}s=t.getBounds("render",e)}const E={scaleX:1,scaleY:1};i.MathHelper.getScaleData(n.scale,n.size,s,E);let L=n.pixelRatio||1,{x:R,y:P,width:k,height:S}=new i.Bounds(s).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/o*E.scaleX,1/l*E.scaleY)};let A,T=i.Creator.canvas({width:Math.floor(k),height:Math.floor(S),pixelRatio:L,smooth:w,contextSettings:v});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:n}=t.view,{data:a}=t.context.getImageData(0,0,e,n);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?an(o,s,r):nn(o={},s,r)),l++;const d=new i.Bounds;return sn(o,d),d.scale(1/t.pixelRatio).ceil()}(T);const t=T,{width:e,height:n}=r,a={x:0,y:0,width:e,height:n,pixelRatio:L};T=i.Creator.canvas(a),T.copyWorld(t,r,a)}if(y){const[t,e,n,a]=i.MathHelper.fourNumber(y),s=T,{width:r,height:o}=s;T=i.Creator.canvas({width:r+a+e,height:o+t+n,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,n),width:T.pixelWidth,height:T.pixelHeight,renderBounds:s,trimBounds:r}}return this.running=!1,a},export(t,e,n){return this.running=!0,function(t){on||(on=new i.TaskProcessor);return new Promise((e=>{on.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(!i.Resource.isComplete)return i.Platform.requestRender(o);const a=rn.syncExport(t,e,n);a.data instanceof Promise&&(a.data=yield a.data),s(a),r()}));t.updateLayout(),ln(t);const{leafer:l}=t;l?l.waitViewCompleted(o):o()}))))}};let on;function ln(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>ln(t)))}const dn=i.LeaferCanvasBase.prototype,cn=i.Debug.get("@leafer-in/export");dn.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)},dn.toBlob=function(t,e){return new Promise((n=>{i.Platform.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{cn.error(t),n(null)}))}))},dn.toDataURL=function(t,e){return i.Platform.origin.canvasToDataURL(this.view,t,e)},dn.saveAs=function(t,e){return new Promise((n=>{i.Platform.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{cn.error(t),n(!1)}))}))},i.Plugin.add("export"),Object.assign(i.Export,rn),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 s(t,e),hitCanvasManager:()=>new n.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(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:e=>n(t.Platform.image.getRealURL(e))},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:s}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(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(o(n)),i))})),download(t,e){},loadImage:e=>s(t.Platform.image.getRealURL(e))}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
|
|
2
2
|
//# sourceMappingURL=node.min.cjs.map
|