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