@leafer-draw/miniapp 1.9.1 → 1.9.2

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