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