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