@leafer-draw/miniapp 1.6.1 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let n=e.view||e.canvas;n?("string"==typeof n?("#"!==n[0]&&(n="#"+n),this.viewSelect=t.Platform.miniapp.select(n)):n.fields?this.viewSelect=n:this.initView(n),this.viewSelect&&t.Platform.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(e){e?this.view=e.view||e:(e={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:i,pixelRatio:s}=this.config,a={width:n||e.width,height:i||e.height,pixelRatio:s};this.resize(a),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,n,i,s){this.context.roundRect(t,e,n,i,"number"==typeof s?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(e){this.viewSelect&&t.Platform.miniapp.getBounds(this.viewSelect).then((t=>{this.clientBounds=t,e&&e()}))}startAutoLayout(e,n){this.resizeListener=n,e&&(this.checkSize=this.checkSize.bind(this),t.Platform.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:n}=this,i={width:t,height:e,pixelRatio:n};this.isSameSize(i)||this.emitResize(i)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,t.Platform.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}}const{mineType:i,fileType:s}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas:(t,e,i)=>{const s={type:"2d",width:t,height:e};return n.createOffscreenCanvas?n.createOffscreenCanvas(s):n.createOffScreenCanvas(s)},canvasToDataURL:(t,e,n)=>t.toDataURL(i(e),n),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(e,n,a)=>{let o=e.toDataURL(i(s(n)),a);return o=o.substring(o.indexOf("64,")+3),t.Platform.origin.download(o,n)},download:(e,i)=>new Promise(((s,a)=>{let o;i.includes("/")||(i=`${n.env.USER_DATA_PATH}/`+i,o=!0);const r=n.getFileSystemManager();r.writeFile({filePath:i,data:e,encoding:"base64",success(){o?t.Platform.miniapp.saveToAlbum(i).then((()=>{r.unlink({filePath:i}),s()})):s()},fail(t){a(t)}})})),loadImage:e=>new Promise(((n,i)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>n.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const n=t[1];e({x:n.top,y:n.left,width:n.width,height:n.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const n=t[0];e({view:n.node,width:n.width,height:n.height})}))})),saveToAlbum:t=>new Promise((e=>{n.getSetting({success:i=>{i.authSetting["scope.writePhotosAlbum"]?n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):n.authorize({scope:"scope.writePhotosAlbum",success:()=>{n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){n.onWindowResize(t)},offWindowResize(t){n.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="miniapp",t.Platform.requestRender=function(e){const{view:n}=t.Platform.renderCanvas||t.Platform.canvas;n.requestAnimationFrame?n.requestAnimationFrame(e):setTimeout(e,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class o{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:r,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper;class f{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,u),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:p,updateAllChange:g}=t.LeafHelper,_=t.Debug.get("Layouter");class w{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){_.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?_.warn("layouting"):this.times>3?_.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:o,AFTER:u}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),i.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),w.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,o,this.times)),n.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){p(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),g(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new f([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new f(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const m=t.Debug.get("Renderer");class y{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,m.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,m.error(t)}m.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return m.warn("rendering");if(this.times>3)return m.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=new t.Bounds(s);i.save(),s.spread(y.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:i}=this,s=e.includes(this.target.__world),a=s?{includes:s}:{bounds:e,includes:s};this.needFill&&i.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(i,e),this.target.__render(i,a),this.renderBounds=n=n||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),i.updateRender(n)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,this.checkRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||m.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function v(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:a}=i;for(let t=0,i=s.length;t<i;t++)n=s[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)}));if(a){const{decorationColor:t,decorationHeight:n}=i;t&&(e.fillStyle=t),s.forEach((t=>a.forEach((i=>e.fillRect(t.x,t.y+i,t.width,n)))))}}function x(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?R(t,!0,e,n):E(e,n);break;case"inside":b("inside",t,s,e,n);break;case"outside":b("outside",t,s,e,n)}}function b(t,e,n,i,s){const{__strokeWidth:a,__font:o}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,i.__),r.font=o,n?R(e,!0,i,r):E(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",v(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function E(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:a}=i;for(let t=0,i=s.length;t<i;t++)n=s[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(a){const{decorationHeight:t}=i;s.forEach((n=>a.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function R(t,n,i,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&e.PaintImage.checkImage(i,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),n?E(i,s):s.stroke(),s.restoreBlendMode()):n?E(i,s):s.stroke())}function B(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}y.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new o(t,e),layouter:(t,e)=>new w(t,e),renderer:(t,e,n)=>new y(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=w.fullLayout;const{getSpread:S,getOuterOf:L,getByMove:k,getIntersectData:P}=t.BoundsHelper;let A;function C(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:a,blendMode:o,color:r,opacity:l}=n;return{type:a,blendMode:o,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,s,!A||!A[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const W={compute:function(t,n){const i=n.__,s=[];let a,o=i.__input[t];o instanceof Array||(o=[o]),A=e.PaintImage.recycleImage(t,i);for(let e,i=0,a=o.length;i<a;i++)e=C(t,o[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=a:i.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?v(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:a,__font:o}=n.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?v(n,i):a?i.fill(a):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?v(n,i):a?i.fill(a):i.fill(),i.restoreBlendMode()):o?v(n,i):a?i.fill(a):i.fill())},fillText:v,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)x(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&B(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)x(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),R(t,!1,e,n),i.__useArrow&&B(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),R(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,i),R(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:x,drawTextStroke:E,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,h=P(i?S(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=L(s,o),a=k(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let O={};const{get:T,rotateOfOuter:M,translate:I,scaleOfOuter:D,scale:z,rotate:H}=t.MatrixHelper;function F(t,e,n,i,s,a,o){const r=T();I(r,e.x+n,e.y+i),z(r,s,a),o&&M(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function G(t,e,n,i,s,a,o){const r=T();I(r,e.x+n,e.y+i),s&&z(r,s,a),o&&H(r,o),t.transform=r}function j(t,e,n,i,s,a,o,r,l,d){const c=T();if(l)if("center"===d)M(c,{x:n/2,y:i/2},l);else switch(H(c,l),l){case 90:I(c,i,0);break;case 180:I(c,n,i);break;case 270:I(c,0,n)}O.x=e.x+s,O.y=e.y+a,I(c,O.x,O.y),o&&D(c,O,o,r),t.transform=c}const{get:U,translate:Y}=t.MatrixHelper,N=new t.Bounds,q={},X={};function V(t,e,n,i){const{blendMode:s,changeful:a,sync:o}=n;s&&(t.blendMode=s),a&&(t.changeful=a),o&&(t.sync=o),t.data=Q(n,i,e)}function Q(e,n,i){let{width:s,height:a}=i;e.padding&&(n=N.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===s&&n.height===a,_={mode:r},w="center"!==l&&(u||0)%180==90,m=w?a:s,y=w?s:a;let v,x,b=0,E=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,X),v=X.scaleX,x=X.scaleY);else if(!g||u){const t=n.width/m,e=n.height/y;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(n.width-s*v)/2,E+=(n.height-a*x)/2}if(l){const e={x:b,y:E,width:m,height:y};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(l,e,n,q,!0),b+=q.x,E+=q.y}switch(d&&(b+=d.x,E+=d.y),r){case"stretch":g||(s=n.width,a=n.height);break;case"normal":case"clip":(b||E||v||u)&&G(_,n,b,E,v,x,u);break;case"repeat":(!g||v||u)&&j(_,n,s,a,b,E,v,x,u,l),f||(_.repeat="repeat");break;default:v&&F(_,n,b,E,v,x,u)}return _.transform||(n.x||n.y)&&(_.transform=U(),Y(_.transform,n.x,n.y)),v&&"stretch"!==r&&(_.scaleX=v,_.scaleY=x),_.width=s,_.height=a,o&&(_.opacity=o),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let Z,$=new t.Bounds;const{isSame:K}=t.BoundsHelper;function J(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||V(s,i,n,a),!0}function tt(e,n){it(e,t.ImageEvent.LOAD,n)}function et(e,n){it(e,t.ImageEvent.LOADED,n)}function nt(e,n,i){n.error=i,e.forceUpdate("surface"),it(e,t.ImageEvent.ERROR,n)}function it(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function st(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:at,scale:ot,copy:rt}=t.MatrixHelper,{ceil:lt,abs:dt}=Math;function ct(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=s+"-"+a+"-"+i;if(n.patternId===o||e.destroyed)return!1;{s=dt(s),a=dt(a);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(d=at(),rt(d,p),ot(d,1/u,1/f),s*=u,a*=f),s*=i,a*=i,c*=s,h*=a;const _=c*h;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}_>w&&(l=Math.sqrt(_/w)),l&&(s/=l,a/=l,c/=l,h/=l),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(d||(d=at(),p&&rt(d,p)),ot(d,1/s,1/a));const m=e.getCanvas(lt(c)||1,lt(h)||1,r.opacity,r.filters),y=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=o,!0}}function ht(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{l(i.next(t))}catch(t){a(t)}}function r(t){try{l(i.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ut}=Math;const ft={image:function(e,n,i,s,a){let o,r;const l=t.ImageManager.get(i);return Z&&i===Z.paint&&K(s,Z.boxBounds)?o=Z.leafPaint:(o={type:i.type,image:l},Z=l.use>1?{leafPaint:o,paint:i,boxBounds:$.set(s)}:null),(a||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(J(e,n,i,l,o,s),a&&(tt(e,r),et(e,r))):l.error?a&&nt(e,r,l.error):(a&&(st(e,!0),tt(e,r)),o.loadId=l.load((()=>{st(e,!1),e.destroyed||(J(e,n,i,l,o,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),et(e,r)),o.loadId=null}),(t=>{st(e,!1),nt(e,r,t),o.loadId=null}))),o},checkImage:function(n,i,s,a){const{scaleX:o,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i,{data:d}=s;if(!d||s.patternId===o+"-"+r+"-"+l&&!e.Export.running)return!1;if(a)if(d.repeat)a=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=ut(o)*l,n*=ut(r)*l,d.scaleX&&(e*=d.scaleX,n*=d.scaleY),a=e*n>t.Platform.image.maxCacheSize}return a?(function(t,e,n,i){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(n,i,s,d),!0):(!s.style||s.sync||e.Export.running?ct(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>ht(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ct(n,s,l),n.forceUpdate("surface")}))),300)),!1)},createPattern:ct,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,o,r,l;for(let d=0,c=i.length;d<c;d++)s=i[d],a=s.image,l=a&&a.url,l&&(o||(o={}),o[l]=!0,t.ImageManager.recycle(a),a.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),a.unload(i[d].loadId,!r.some((t=>t.url===l)))));return o}return null},createData:V,getPatternData:Q,fillOrFitMode:F,clipMode:G,repeatMode:j},{toPoint:pt}=t.AroundHelper,gt={},_t={};function wt(t,n,i){if(n){let s;for(let a=0,o=n.length;a<o;a++)s=n[a],"string"==typeof s?t.addColorStop(a/(o-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:mt,getDistance:yt}=t.PointHelper,{get:vt,rotateOfOuter:xt,scaleOfOuter:bt}=t.MatrixHelper,{toPoint:Et}=t.AroundHelper,Rt={},Bt={};function St(t,e,n,i,s){let a;const{width:o,height:r}=t;if(o!==r||i){const t=mt(e,n);a=vt(),s?(bt(a,e,o/r*(i||1),1),xt(a,e,t+90)):(bt(a,e,1,o/r*(i||1)),xt(a,e,t))}return a}const{getDistance:Lt}=t.PointHelper,{toPoint:kt}=t.AroundHelper,Pt={},At={};const Ct={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:o,opacity:r}=e;pt(i||"top",n,gt),pt(s||"bottom",n,_t);const l=t.Platform.canvas.createLinearGradient(gt.x,gt.y,_t.x,_t.y);wt(l,e.stops,r);const d={type:a,style:l};return o&&(d.blendMode=o),d},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:l}=e;Et(i||"center",n,Rt),Et(s||"bottom",n,Bt);const d=t.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,yt(Rt,Bt));wt(d,e.stops,o);const c={type:a,style:d},h=St(n,Rt,Bt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:l}=e;kt(i||"center",n,Pt),kt(s||"bottom",n,At);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Pt.x,Pt.y):t.Platform.canvas.createRadialGradient(Pt.x,Pt.y,0,Pt.x,Pt.y,Lt(Pt,At));wt(d,e.stops,o);const c={type:a,style:d},h=St(n,Pt,At,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:St},{copy:Wt,toOffsetOutBounds:Ot}=t.BoundsHelper,Tt={},Mt={};function It(e,n,i,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(Wt(Tt,e.bounds),Tt.x+=n.x-o.x,Tt.y+=n.y-o.y,i){const{matrix:t}=s;Tt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Tt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Tt.width*=i,Tt.height*=i}e.copyWorld(s.canvas,e.bounds,Tt)}else i&&(Wt(Tt,n),Tt.x-=n.width/2*(i-1),Tt.y-=n.height/2*(i-1),Tt.width*=i,Tt.height*=i),e.copyWorld(s.canvas,o,i?Tt:n)}const{toOffsetOutBounds:Dt}=t.BoundsHelper,zt={};const Ht={shadow:function(t,n,i){let s,a;const{__nowWorld:o,__layout:r}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;Ot(c,Mt),l.forEach(((l,_)=>{p.setWorldShadow(Mt.offsetX+l.x*u,Mt.offsetY+l.y*f,l.blur*u,e.ColorConvert.string(l.color)),a=l.spread?1+2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,It(p,Mt,a,i),s=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,o,"copy"),s=o),d?p.copyWorld(d,o,o,"destination-out"):p.copyWorld(i.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,s,o,l.blendMode):n.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,n,i){let s,a;const{__nowWorld:o,__layout:r}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;Dt(c,zt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(zt.offsetX+l.x*u,zt.offsetY+l.y*f,l.blur*u),a=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,It(p,zt,a,i),p.restore(),d?(p.copyWorld(p,c,o,"copy"),p.copyWorld(d,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,h,c,"source-out"),s=c),p.fillWorld(s,e.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,s,o,l.blendMode):n.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Ft}=t.LeafBoundsHelper;function Gt(t,e,n,i,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Ut(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Ut(t,n,i,a);break;case"path":n.restore()}}function jt(t){return t.getSameCanvas(!1,!0)}function Ut(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,a,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(o&&(Gt(this,o,t,s,i,a),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=jt(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=jt(t)),s||(s=jt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Ft(n,e)||n.__render(s||t,e);Gt(this,o,t,s,i,a)};const Yt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nt=Yt+"_#~&*+\\=|≮≯≈≠=…",qt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Xt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Vt=Xt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Qt=Xt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Zt=Xt(Yt),$t=Xt(Nt),Kt=Xt("- —/~|┆·");var Jt;!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"}(Jt||(Jt={}));const{Letter:te,Single:ee,Before:ne,After:ie,Symbol:se,Break:ae}=Jt;function oe(t){return Vt[t]?te:Kt[t]?ae:Qt[t]?ne:Zt[t]?ie:$t[t]?se:qt.test(t)?ee:te}const re={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function le(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:de}=re,{Letter:ce,Single:he,Before:ue,After:fe,Symbol:pe,Break:ge}=Jt;let _e,we,me,ye,ve,xe,be,Ee,Re,Be,Se,Le,ke,Pe,Ae,Ce,We,Oe=[];function Te(t,e){Re&&!Ee&&(Ee=Re),_e.data.push({char:t,width:e}),me+=e}function Me(){ye+=me,_e.width=me,we.words.push(_e),_e={data:[]},me=0}function Ie(){Pe&&(Ae.paraNumber++,we.paraStart=!0,Pe=!1),Re&&(we.startCharSize=Ee,we.endCharSize=Re,Ee=0),we.width=ye,Ce.width?de(we):We&&De(),Oe.push(we),we={words:[]},ye=0}function De(){ye>(Ae.maxWidth||0)&&(Ae.maxWidth=ye)}const{top:ze,right:He,bottom:Fe,left:Ge}=t.Direction4;function je(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Ue={getDrawData:function(n,i){"string"!=typeof n&&(n=String(n));let s=0,a=0,o=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=i;c&&(o?(s=c[Ge],o-=c[He]+c[Ge]):i.autoSizeAlign||(s=c[Ge]),r?(a=c[ze],r-=c[ze]+c[Fe]):i.autoSizeAlign||(a=c[ze]));const h={bounds:{x:s,y:a,width:o,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Ae=e,Oe=e.rows,Ce=e.bounds,We=!Ce.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ce;if(l||d||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Pe=!0,Se=null,Ee=be=Re=me=ye=0,_e={data:[]},we={words:[]};for(let i=0,d=n.length;i<d;i++)xe=n[i],"\n"===xe?(me&&Me(),we.paraEnd=!0,Ie(),Pe=!0):(Be=oe(xe),Be===ce&&"none"!==o&&(xe=le(xe,o,!me)),be=r.measureText(xe).width,s&&(s<0&&(Re=be),be+=s),Le=Be===he&&(Se===he||Se===ce)||Se===he&&Be!==fe,ke=!(Be!==ue&&Be!==he||Se!==pe&&Se!==fe),ve=Pe&&a?l-a:l,t&&l&&ye+me+be>ve&&(e?(me&&Me(),ye&&Ie()):(ke||(ke=Be===ce&&Se==fe),Le||ke||Be===ge||Be===ue||Be===he||me+be>ve?(me&&Me(),ye&&Ie()):ye&&Ie()))," "===xe&&!0!==Pe&&ye+me===0||(Be===ge?(" "===xe&&me&&Me(),Te(xe,be),Me()):Le||ke?(me&&Me(),Te(xe,be)):Te(xe,be)),Se=Be);me&&Me(),ye&&Ie(),Oe.length>0&&(Oe[Oe.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ae.paraNumber++,ye=r.measureText(t).width,Oe.push({x:a||0,text:t,width:ye,paraStart:!0}),We&&De()}))}(h,n,i),c&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":je(e,"x",t[Ge]);break;case"right":je(e,"x",-t[He])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":je(e,"y",t[ze]);break;case"bottom":je(e,"y",-t[Fe])}}(c,h,i,o,r),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,w=a*s+(h?h*(t.paraNumber-1):0),m=o;if(l&&w>_)w=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=s;o<c;o++){if(y=n[o],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&o>0&&(m+=h),y.y=m,m+=a,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<i.x&&(i.x=v),x>i.width&&(i.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=w}(h,i),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:a,letterSpacing:o}=e;let r,l,d,c,h,u;i.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-d)/(u-1):0,c=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,n)=>{1===c?(h={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||n===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(h,i,o),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:a,overflow:o}=e;let{textOverflow:r}=n;if(a.splice(o),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?a:[a[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char||!i){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,i,s,o),"none"!==l&&function(t,n){let i;const{fontSize:s,textDecoration:a}=n;switch(t.decorationHeight=s/11,"object"==typeof a?(i=a.type,a.color&&(t.decorationColor=e.ColorConvert.string(a.color))):i=a,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};const Ye={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}};Object.assign(e.TextConvert,Ue),Object.assign(e.ColorConvert,Ye),Object.assign(e.Paint,W),Object.assign(e.PaintImage,ft),Object.assign(e.PaintGradient,Ct),Object.assign(e.Effect,Ht);try{wx&&a(0,wx)}catch(t){}Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=w,exports.LeaferCanvas=n,exports.Renderer=y,exports.Watcher=o,exports.useCanvas=a,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(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw"),n=require("@leafer-ui/core");class i extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let n=e.view||e.canvas;n?("string"==typeof n?("#"!==n[0]&&(n="#"+n),this.viewSelect=t.Platform.miniapp.select(n)):n.fields?this.viewSelect=n:this.initView(n),this.viewSelect&&t.Platform.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(e){e?this.view=e.view||e:(e={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:n,height:i,pixelRatio:s}=this.config,a={width:n||e.width,height:i||e.height,pixelRatio:s};this.resize(a),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,n,i,s){this.context.roundRect(t,e,n,i,"number"==typeof s?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(e){this.viewSelect&&t.Platform.miniapp.getBounds(this.viewSelect).then((t=>{this.clientBounds=t,e&&e()}))}startAutoLayout(e,n){this.resizeListener=n,e&&(this.checkSize=this.checkSize.bind(this),t.Platform.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:n}=this,i={width:t,height:e,pixelRatio:n};this.isSameSize(i)||this.emitResize(i)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,t.Platform.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}}const{mineType:s,fileType:a}=t.FileHelper;function o(e,n){t.Platform.origin={createCanvas:(t,e,i)=>{const s={type:"2d",width:t,height:e};return n.createOffscreenCanvas?n.createOffscreenCanvas(s):n.createOffScreenCanvas(s)},canvasToDataURL:(t,e,n)=>t.toDataURL(s(e),n),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(e,n,i)=>{let o=e.toDataURL(s(a(n)),i);return o=o.substring(o.indexOf("64,")+3),t.Platform.origin.download(o,n)},download:(e,i)=>new Promise(((s,a)=>{let o;i.includes("/")||(i=`${n.env.USER_DATA_PATH}/`+i,o=!0);const r=n.getFileSystemManager();r.writeFile({filePath:i,data:e,encoding:"base64",success(){o?t.Platform.miniapp.saveToAlbum(i).then((()=>{r.unlink({filePath:i}),s()})):s()},fail(t){a(t)}})})),loadImage:e=>new Promise(((n,i)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)})),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>n.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const n=t[1];e({x:n.top,y:n.left,width:n.width,height:n.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const n=t[0];e({view:n.node,width:n.width,height:n.height})}))})),saveToAlbum:t=>new Promise((e=>{n.getSetting({success:i=>{i.authSetting["scope.writePhotosAlbum"]?n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):n.authorize({scope:"scope.writePhotosAlbum",success:()=>{n.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){n.onWindowResize(t)},offWindowResize(t){n.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="miniapp",t.Platform.requestRender=function(e){const{view:n}=t.Platform.renderCanvas||t.Platform.canvas;n.requestAnimationFrame?n.requestAnimationFrame(e):setTimeout(e,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=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,e instanceof Array&&(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(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:_}=t.LeafHelper,m=t.Debug.get("Layouter");class w{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:o,AFTER:r}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(l(t,!0),e.add(t),t.isBranch&&h(t,e),u(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||d(i[t])}d(n)}}))}(this.__levelList),function(t){t.list.forEach(c)}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),i.emitEvent(new t.LayoutEvent(r,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),w.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,o,this.times)),n.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.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_([[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 y=t.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,y.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=new t.Bounds(s);i.save(),s.spread(v.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:i}=this,s=e.includes(this.target.__world),a=s?{includes:s}:{bounds:e,includes:s};this.needFill&&i.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(i,e),this.target.__render(i,a),this.renderBounds=n=n||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),i.updateRender(n)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,this.checkRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||y.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function x(t,e){const n=t.__,{rows:i,decorationY:s}=n.__textDrawData;let a;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=i.length;t<n;t++)a=i[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(s){const{decorationColor:t,decorationHeight:a}=n.__textDrawData;t&&(e.fillStyle=t),i.forEach((t=>s.forEach((n=>e.fillRect(t.x,t.y+n,t.width,a)))))}}function b(t,e){t.__.__font?x(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}v.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new w(t,e),renderer:(t,e,n)=>new v(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=w.fullLayout;const E={};function B(t,e,n){switch(e.__.strokeAlign){case"center":R(t,1,e,n);break;case"inside":S(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?R(t,2,e,n):S(t,"outside",e,n)}}function R(t,e,n,i){const s=n.__;i.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?k(t,!0,n,i):L(n,i)}function S(t,e,i,s){const a=s.getSameCanvas(!0,!0);a.font=i.__.__font,R(t,2,i,a),a.blendMode="outside"===e?"destination-out":"destination-in",x(i,a),a.blendMode="normal",i.__worldFlipped||n.Platform.fullImageShadow?s.copyWorldByReset(a,i.__nowWorld):s.copyWorldToInner(a,i.__nowWorld,i.__layout.renderBounds),a.recycle(i.__nowWorld)}function L(t,e){let n,i=t.__.__textDrawData;const{rows:s,decorationY:a}=i;for(let t=0,i=s.length;t<i;t++)n=s[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(a){const{decorationHeight:t}=i;s.forEach((n=>a.forEach((i=>e.strokeRect(n.x,n.y+i,n.width,t)))))}}function k(t,n,i,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&e.PaintImage.checkImage(i,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),n?L(i,s):s.stroke(),s.restoreBlendMode()):n?L(i,s):s.stroke())}function P(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)B(t,e,i);else switch(s.strokeAlign){case"center":A(t,1,e,i);break;case"inside":!function(t,e,n){const i=e.__;n.save(),i.windingRule?n.clip(i.windingRule):n.clip(),A(t,2,e,n),n.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)A(t,2,e,i);else{const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),A(t,2,e,o),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped||n.Platform.fullImageShadow?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}}(t,e,i)}}function A(t,e,n,i){const s=n.__;i.setStroke(!s.__isStrokes&&t,s.__strokeWidth*e,s),s.__isStrokes?k(t,!1,n,i):i.stroke(),s.__useArrow&&E.strokeArrow(t,n,i)}const{getSpread:C,getOuterOf:T,getByMove:W,getIntersectData:O}=t.BoundsHelper;let I;const{stintSet:M}=t.DataHelper,{hasTransparent:D}=e.ColorConvert;function z(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;let s;const{boxBounds:a}=i.__layout;switch(n.type){case"image":s=e.PaintImage.image(i,t,n,a,!I||!I[n.url]);break;case"linear":s=e.PaintGradient.linearGradient(n,a);break;case"radial":s=e.PaintGradient.radialGradient(n,a);break;case"angular":s=e.PaintGradient.conicGradient(n,a);break;case"solid":const{type:o,blendMode:r,color:l,opacity:d}=n;s={type:o,blendMode:r,style:e.ColorConvert.string(l,d)};break;default:void 0!==n.r&&(s={type:"solid",style:e.ColorConvert.string(n)})}return s&&("string"==typeof s.style&&D(s.style)&&(s.isTransparent=!0),n.blendMode&&(s.blendMode=n.blendMode)),s}const H={compute:function(t,n){const i=n.__,s=[];let a,o,r=i.__input[t];r instanceof Array||(r=[r]),I=e.PaintImage.recycleImage(t,i);for(let e,i=0,a=r.length;i<a;i++)e=z(t,r[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(a=!0),o=!0),"fill"===t?(M(i,"__isAlphaPixelFill",a),M(i,"__isTransparentFill",o)):(M(i,"__isAlphaPixelStroke",a),M(i,"__isTransparentStroke",o))},fill:function(t,e,n){n.fillStyle=t,b(e,n)},fills:function(t,n,i){let s;for(let a=0,o=t.length;a<o;a++){if(s=t[a],s.image){if(e.PaintImage.checkImage(n,i,s,!n.__.__font))continue;if(!s.style){!a&&s.image.isPlacehold&&n.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),b(n,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),b(n,i),i.restoreBlendMode()):b(n,i)}},fillPathOrText:b,fillText:x,stroke:P,strokes:function(t,e,n){P(t,e,n)},strokeText:B,drawTextStroke:L,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,h=O(i?C(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=T(s,o),a=W(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let F={};const{get:G,rotateOfOuter:j,translate:U,scaleOfOuter:Y,scale:q,rotate:N}=t.MatrixHelper;function X(t,e,n,i,s,a,o){const r=G();U(r,e.x+n,e.y+i),q(r,s,a),o&&j(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function V(t,e,n,i,s,a,o){const r=G();U(r,e.x+n,e.y+i),s&&q(r,s,a),o&&N(r,o),t.transform=r}function Q(t,e,n,i,s,a,o,r,l,d){const c=G();if(l)if("center"===d)j(c,{x:n/2,y:i/2},l);else switch(N(c,l),l){case 90:U(c,i,0);break;case 180:U(c,n,i);break;case 270:U(c,0,n)}F.x=e.x+s,F.y=e.y+a,U(c,F.x,F.y),o&&Y(c,F,o,r),t.transform=c}const{get:Z,translate:$}=t.MatrixHelper,K=new t.Bounds,J={},tt={};function et(t,e,n,i){const{changeful:s,sync:a}=n;s&&(t.changeful=s),a&&(t.sync=a),t.data=nt(n,i,e)}function nt(e,n,i){e.padding&&(n=K.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:a}=i;const{opacity:o,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===s&&n.height===a,_={mode:r},m="center"!==l&&(u||0)%180==90;let w,y;switch(t.BoundsHelper.set(tt,0,0,m?a:s,m?s:a),r&&"cover"!==r&&"fit"!==r?((c||h)&&(t.MathHelper.getScaleData(c,h,i,J),w=J.scaleX,y=J.scaleY),l&&(w&&t.BoundsHelper.scale(tt,w,y,!0),t.AlignHelper.toPoint(l,tt,n,tt,!0,!0))):g&&!u||(w=y=t.BoundsHelper.getFitScale(n,tt,"fit"!==r),t.BoundsHelper.put(n,i,l,w,!1,tt),t.BoundsHelper.scale(tt,w,y,!0)),d&&t.PointHelper.move(tt,d),r){case"stretch":g||(s=n.width,a=n.height);break;case"normal":case"clip":(tt.x||tt.y||w||u)&&V(_,n,tt.x,tt.y,w,y,u);break;case"repeat":(!g||w||u)&&Q(_,n,s,a,tt.x,tt.y,w,y,u,l),f||(_.repeat="repeat");break;default:w&&X(_,n,tt.x,tt.y,w,y,u)}return _.transform||(n.x||n.y)&&(_.transform=Z(),$(_.transform,n.x,n.y)),w&&"stretch"!==r&&(_.scaleX=w,_.scaleY=y),_.width=s,_.height=a,o&&(_.opacity=o),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let it,st=new t.Bounds;const{isSame:at}=t.BoundsHelper;function ot(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||et(s,i,n,a),!0}function rt(e,n){ct(e,t.ImageEvent.LOAD,n)}function lt(e,n){ct(e,t.ImageEvent.LOADED,n)}function dt(e,n,i){n.error=i,e.forceUpdate("surface"),ct(e,t.ImageEvent.ERROR,n)}function ct(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ht(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ut,scale:ft,copy:pt}=t.MatrixHelper,{ceil:gt,abs:_t}=Math;function mt(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=s+"-"+a+"-"+i;if(n.patternId===o||e.destroyed)return!1;{s=_t(s),a=_t(a);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(d=ut(),pt(d,p),ft(d,1/u,1/f),s*=u,a*=f),s*=i,a*=i,c*=s,h*=a;const _=c*h;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}_>m&&(l=Math.sqrt(_/m)),l&&(s/=l,a/=l,c/=l,h/=l),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(d||(d=ut(),p&&pt(d,p)),ft(d,1/s,1/a));const w=e.getCanvas(gt(c)||1,gt(h)||1,r.opacity,r.filters),y=e.getPattern(w,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=o,!0}}function wt(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{l(i.next(t))}catch(t){a(t)}}function r(t){try{l(i.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:yt}=Math;const vt={image:function(e,n,i,s,a){let o,r;const l=t.ImageManager.get(i);return it&&i===it.paint&&at(s,it.boxBounds)?o=it.leafPaint:(o={type:i.type,image:l},l.hasAlphaPixel&&(o.isTransparent=!0),it=l.use>1?{leafPaint:o,paint:i,boxBounds:st.set(s)}:null),(a||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(ot(e,n,i,l,o,s),a&&(rt(e,r),lt(e,r))):l.error?a&&dt(e,r,l.error):(a&&(ht(e,!0),rt(e,r)),o.loadId=l.load((()=>{ht(e,!1),e.destroyed||(ot(e,n,i,l,o,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),lt(e,r)),o.loadId=null}),(t=>{ht(e,!1),dt(e,r,t),o.loadId=null})),e.placeholderColor&&(e.placeholderDelay?setTimeout((()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))}),e.placeholderDelay):l.isPlacehold=!0)),o},checkImage:function(n,i,s,a){const{scaleX:o,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i,{data:d}=s;if(!d||s.patternId===o+"-"+r+"-"+l&&!e.Export.running)return!1;if(a)if(d.repeat)a=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=yt(o)*l,n*=yt(r)*l,d.scaleX&&(e*=d.scaleX,n*=d.scaleY),a=e*n>t.Platform.image.maxCacheSize}return a?(function(t,e,n,i){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),n.blendMode&&(e.blendMode=n.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(n.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(n,i,s,d),!0):(!s.style||s.sync||e.Export.running?mt(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>wt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&mt(n,s,l),n.forceUpdate("surface")}))),300)),!1)},createPattern:mt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,o,r,l;for(let d=0,c=i.length;d<c;d++)s=i[d],a=s.image,l=a&&a.url,l&&(o||(o={}),o[l]=!0,t.ImageManager.recycle(a),a.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),a.unload(i[d].loadId,!r.some((t=>t.url===l)))));return o}return null},createData:et,getPatternData:nt,fillOrFitMode:X,clipMode:V,repeatMode:Q},{toPoint:xt}=t.AroundHelper,{hasTransparent:bt}=e.ColorConvert,Et={},Bt={};function Rt(t,n,i,s){if(i){let a,o,r,l;for(let t=0,d=i.length;t<d;t++)a=i[t],"string"==typeof a?(r=t/(d-1),o=e.ColorConvert.string(a,s)):(r=a.offset,o=e.ColorConvert.string(a.color,s)),n.addColorStop(r,o),!l&&bt(o)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:St,getDistance:Lt}=t.PointHelper,{get:kt,rotateOfOuter:Pt,scaleOfOuter:At}=t.MatrixHelper,{toPoint:Ct}=t.AroundHelper,Tt={},Wt={};function Ot(t,e,n,i,s){let a;const{width:o,height:r}=t;if(o!==r||i){const t=St(e,n);a=kt(),s?(At(a,e,o/r*(i||1),1),Pt(a,e,t+90)):(At(a,e,1,o/r*(i||1)),Pt(a,e,t))}return a}const{getDistance:It}=t.PointHelper,{toPoint:Mt}=t.AroundHelper,Dt={},zt={};const Ht={linearGradient:function(e,n){let{from:i,to:s,type:a,opacity:o}=e;xt(i||"top",n,Et),xt(s||"bottom",n,Bt);const r=t.Platform.canvas.createLinearGradient(Et.x,Et.y,Bt.x,Bt.y),l={type:a,style:r};return Rt(l,r,e.stops,o),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,stretch:r}=e;Ct(i||"center",n,Tt),Ct(s||"bottom",n,Wt);const l=t.Platform.canvas.createRadialGradient(Tt.x,Tt.y,0,Tt.x,Tt.y,Lt(Tt,Wt)),d={type:a,style:l};Rt(d,l,e.stops,o);const c=Ot(n,Tt,Wt,r,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,stretch:r}=e;Mt(i||"center",n,Dt),Mt(s||"bottom",n,zt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Dt.x,Dt.y):t.Platform.canvas.createRadialGradient(Dt.x,Dt.y,0,Dt.x,Dt.y,It(Dt,zt)),d={type:a,style:l};Rt(d,l,e.stops,o);const c=Ot(n,Dt,zt,r||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ot},{copy:Ft,toOffsetOutBounds:Gt}=t.BoundsHelper,jt={},Ut={};function Yt(e,n,i,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(Ft(jt,e.bounds),jt.x+=n.x-o.x,jt.y+=n.y-o.y,i){const{matrix:t}=s;jt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),jt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),jt.width*=i,jt.height*=i}e.copyWorld(s.canvas,e.bounds,jt)}else i&&(Ft(jt,n),jt.x-=n.width/2*(i-1),jt.y-=n.height/2*(i-1),jt.width*=i,jt.height*=i),e.copyWorld(s.canvas,o,i?jt:n)}const{toOffsetOutBounds:qt}=t.BoundsHelper,Nt={};const Xt={shadow:function(t,n,i){let s,a;const{__nowWorld:o,__layout:r}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;Gt(c,Ut),l.forEach(((l,_)=>{p.setWorldShadow(Ut.offsetX+l.x*u,Ut.offsetY+l.y*f,l.blur*u,e.ColorConvert.string(l.color)),a=l.spread?1+2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Yt(p,Ut,a,i),s=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,o,"copy"),s=o),d?p.copyWorld(d,o,o,"destination-out"):p.copyWorld(i.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,s,o,l.blendMode):n.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,n,i){let s,a;const{__nowWorld:o,__layout:r}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=i,p=n.getSameCanvas(),g=l.length-1;qt(c,Nt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Nt.offsetX+l.x*u,Nt.offsetY+l.y*f,l.blur*u),a=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Yt(p,Nt,a,i),p.restore(),d?(p.copyWorld(p,c,o,"copy"),p.copyWorld(d,o,o,"source-out"),s=o):(p.copyWorld(i.canvas,h,c,"source-out"),s=c),p.fillWorld(s,e.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,s,o,l.blendMode):n.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Vt}=t.LeafBoundsHelper;function Qt(t,e,n,i,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),$t(t,e,n,1)}(t,n,i,s);break;case"opacity-path":$t(t,n,i,a);break;case"path":n.restore()}}function Zt(t){return t.getSameCanvas(!1,!0)}function $t(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,a,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(o&&(Qt(this,o,t,s,i,a),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=Zt(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=Zt(t)),s||(s=Zt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Vt(n,e)||n.__render(s||t,e);Qt(this,o,t,s,i,a)};const Kt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Jt=Kt+"_#~&*+\\=|≮≯≈≠=…",te=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 ee(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ne=ee("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ie=ee("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),se=ee(Kt),ae=ee(Jt),oe=ee("- —/~|┆·");var re;!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"}(re||(re={}));const{Letter:le,Single:de,Before:ce,After:he,Symbol:ue,Break:fe}=re;function pe(t){return ne[t]?le:oe[t]?fe:ie[t]?ce:se[t]?he:ae[t]?ue:te.test(t)?de:le}const ge={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function _e(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:me}=ge,{Letter:we,Single:ye,Before:ve,After:xe,Symbol:be,Break:Ee}=re;let Be,Re,Se,Le,ke,Pe,Ae,Ce,Te,We,Oe,Ie,Me,De,ze,He,Fe,Ge=[];function je(t,e){Te&&!Ce&&(Ce=Te),Be.data.push({char:t,width:e}),Se+=e}function Ue(){Le+=Se,Be.width=Se,Re.words.push(Be),Be={data:[]},Se=0}function Ye(){De&&(ze.paraNumber++,Re.paraStart=!0,De=!1),Te&&(Re.startCharSize=Ce,Re.endCharSize=Te,Ce=0),Re.width=Le,He.width?me(Re):Fe&&qe(),Ge.push(Re),Re={words:[]},Le=0}function qe(){Le>(ze.maxWidth||0)&&(ze.maxWidth=Le)}const{top:Ne,right:Xe,bottom:Ve,left:Qe}=t.Direction4;function Ze(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const $e={getDrawData:function(n,i){"string"!=typeof n&&(n=String(n));let s=0,a=0,o=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=i;c&&(o?(s=c[Qe],o-=c[Xe]+c[Qe]):i.autoSizeAlign||(s=c[Qe]),r?(a=c[Ne],r-=c[Ne]+c[Ve]):i.autoSizeAlign||(a=c[Ne]));const h={bounds:{x:s,y:a,width:o,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){ze=e,Ge=e.rows,He=e.bounds,Fe=!He.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=t.Platform,{width:l,height:d}=He;if(l||d||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;De=!0,Oe=null,Ce=Ae=Te=Se=Le=0,Be={data:[]},Re={words:[]},s&&(n=[...n]);for(let i=0,d=n.length;i<d;i++)Pe=n[i],"\n"===Pe?(Se&&Ue(),Re.paraEnd=!0,Ye(),De=!0):(We=pe(Pe),We===we&&"none"!==o&&(Pe=_e(Pe,o,!Se)),Ae=r.measureText(Pe).width,s&&(s<0&&(Te=Ae),Ae+=s),Ie=We===ye&&(Oe===ye||Oe===we)||Oe===ye&&We!==xe,Me=!(We!==ve&&We!==ye||Oe!==be&&Oe!==xe),ke=De&&a?l-a:l,t&&l&&Le+Se+Ae>ke&&(e?(Se&&Ue(),Le&&Ye()):(Me||(Me=We===we&&Oe==xe),Ie||Me||We===Ee||We===ve||We===ye||Se+Ae>ke?(Se&&Ue(),Le&&Ye()):Le&&Ye()))," "===Pe&&!0!==De&&Le+Se===0||(We===Ee?(" "===Pe&&Se&&Ue(),je(Pe,Ae),Ue()):Ie||Me?(Se&&Ue(),je(Pe,Ae)):je(Pe,Ae)),Oe=We);Se&&Ue(),Le&&Ye(),Ge.length>0&&(Ge[Ge.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{ze.paraNumber++,Le=r.measureText(t).width,Ge.push({x:a||0,text:t,width:Le,paraStart:!0}),Fe&&qe()}))}(h,n,i),c&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ze(e,"x",t[Qe]);break;case"right":Ze(e,"x",-t[Xe])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ze(e,"y",t[Ne]);break;case"bottom":Ze(e,"y",-t[Ve])}}(c,h,i,o,r),function(t,e){const{rows:n,bounds:i}=t,s=n.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,m=a*s+(h?h*(t.paraNumber-1):0),w=o;if(l&&m>_)m=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=s;o<c;o++){if(y=n[o],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&h&&o>0&&(w+=h),y.y=w,w+=a,t.overflow>o&&w>m&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<i.x&&(i.x=v),x>i.width&&(i.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=p,i.height=m}(h,i),function(t,e,n){const{rows:i}=t,{textAlign:s,paraIndent:a,letterSpacing:o}=e;let r,l,d,c,h,u;i.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=n&&("justify"===s||"both"===s)&&u>1?(n-t.width-d)/(u-1):0,c=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,n)=>{1===c?(h={char:"",x:r},r=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||n===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(h,i,o),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:a,overflow:o}=e;let{textOverflow:r}=n;if(a.splice(o),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?a:[a[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==e.char||!i){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,i,s,o),"none"!==l&&function(t,n){let i;const{fontSize:s,textDecoration:a}=n;switch(t.decorationHeight=s/11,"object"==typeof a?(i=a.type,a.color&&(t.decorationColor=e.ColorConvert.string(a.color))):i=a,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};const Ke={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=n);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}};Object.assign(e.TextConvert,$e),Object.assign(e.ColorConvert,Ke),Object.assign(e.Paint,H),Object.assign(e.PaintImage,vt),Object.assign(e.PaintGradient,Ht),Object.assign(e.Effect,Xt);try{wx&&o(0,wx)}catch(t){}Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=w,exports.LeaferCanvas=i,exports.Renderer=v,exports.Watcher=r,exports.useCanvas=o,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(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
2
2
  //# sourceMappingURL=miniapp.min.cjs.map