@leafer-ui/node 1.9.7 → 1.9.8

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