@leafer-draw/miniapp 1.9.12 → 1.10.1

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(){if(this.unreal)return;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||(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:120},this.frames=[],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),t.Platform.render(this.target,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);this.requestTime=this.frameTime||Date.now();const i=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:n}=this.config;if(n&&e>n)return t.Platform.requestRender(i);const{frames:s}=this;s.length>30&&s.shift(),s.push(e),this.FPS=Math.round(s.reduce((t,e)=>t+e,0)/s.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(i)}__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.config={},this.target=this.canvas=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 S(t,e,i){switch(e.__.strokeAlign){case"center":b(t,1,e,i);break;case"inside":E(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?b(t,2,e,i):E(t,"outside",e,i)}}function b(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 E(e,i,n,s){const a=s.getSameCanvas(!0,!0);a.font=n.__.__font,b(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 L(e,i,n){const s=i.__;if(s.__strokeWidth)if(s.__font)S(e,i,n);else switch(s.strokeAlign){case"center":k(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),k(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const s=i.__;if(s.__fillAfterStroke)k(e,2,i,n);else{const{renderBounds:a}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),k(e,2,i,r),r.clipUI(s),r.clearWorld(a),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function k(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,t.Platform.render=function(e,i,n){const s=Object.assign(Object.assign({},n),{topRendering:!0});n.topList=new t.LeafList,e.__render(i,n),n.topList.length&&n.topList.forEach(t=>t.__render(i,s))};const{getSpread:P,copyAndSpread:A,toOuterOf:C,getOuterOf:T,getByMove:O,move:W,getIntersectData:M}=t.BoundsHelper,D={};let I;const{stintSet:z}=t.DataHelper,{hasTransparent:H}=e.ColorConvert;function F(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,!I||!I[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)&&H(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 j={compute:function(i,n){const s=n.__,a=[];let r,o,l,d=s.__input[i];t.isArray(d)||(d=[d]),I=e.PaintImage.recycleImage(i,s);for(let t,e=0,s=d.length;e<s;e++)(t=F(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?(z(s,"__isAlphaPixelFill",r),z(s,"__isTransparentFill",o)):(z(s,"__isAlphaPixelStroke",r),z(s,"__isTransparentStroke",o),z(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:L,strokes:function(t,e,i){L(t,e,i)},strokeText:S,drawTextStroke:B,shape:function(e,i,n){const s=i.getSameCanvas(),a=i.bounds,r=e.__nowWorld,o=e.__layout,l=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let d,c,h,u,f,p;C(o.strokeSpread?(A(D,o.boxBounds,o.strokeSpread),D):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=e.getRenderScaleData(!0);if(a.includes(l))p=s,d=f=l,c=r;else{let s;if(t.Platform.fullImageShadow)s=l;else{const e=o.renderShapeSpread?P(a,t.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,_)):a;s=M(e,l)}u=a.getFitMatrix(s);let{a:m,d:w}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,n),g*=m,_*=w),f=T(l,u),d=O(f,-u.e,-u.f),c=T(r,u),W(c,-u.e,-u.f);const y=n.matrix;y?(h=new t.Matrix(u),h.multiply(y),m*=y.scaleX,w*=y.scaleY):h=u,h.withScale(m,w),n=Object.assign(Object.assign({},n),{matrix:h})}return e.__renderShape(s,n),{canvas:s,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let U={},G=t.getMatrixData();const{get:N,set:Y,rotateOfOuter:q,translate:X,scaleOfOuter:V,multiplyParent:Q,scale:Z,rotate:$,skew:K}=t.MatrixHelper;function J(t,e,i,n){const s=N();X(s,e.x,e.y),i&&Z(s,i,n),t.transform=s}function tt(t,e,i,n,s,a,r){const o=N();X(o,e.x+i,e.y+n),Z(o,s,a),r&&q(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function et(t,e,i,n,s,a,r,o,l,d){const c=N();nt(c,e,i,n,s,a,r,o),l&&(r||o?(Y(G),V(G,e,l,d),Q(c,G)):V(c,e,l,d)),t.transform=c}function it(t,e,i,n,s,a,r,o,l,d,c,h){const u=N();if(h)nt(u,e,s,a,r,o,l,d);else{if(l)if("center"===c)q(u,{x:i/2,y:n/2},l);else switch($(u,l),l){case 90:X(u,n,0);break;case 180:X(u,i,n);break;case 270:X(u,0,i)}U.x=e.x+s,U.y=e.y+a,X(u,U.x,U.y),r&&V(u,U,r,o)}t.transform=u}function nt(t,e,i,n,s,a,r,o){r&&$(t,r),o&&K(t,o.x,o.y),s&&Z(t,s,a),X(t,e.x+i,e.y+n)}const{get:st,translate:at}=t.MatrixHelper,rt=new t.Bounds,ot={},lt={};function dt(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=ct(i,n,e)}function ct(e,i,n){e.padding&&(i=rt.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,S;switch(t.BoundsHelper.set(lt,0,0,v?a:s,v?s:a),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,n,ot),x=ot.scaleX,S=ot.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(lt,x,S,!0),l&&t.AlignHelper.toPoint(l,lt,i,lt,!0,!0))):w&&!u||(x=S=t.BoundsHelper.getFitScale(i,lt,"fit"!==o),t.BoundsHelper.put(i,n,l,x,!1,lt),t.BoundsHelper.scale(lt,x,S,!0)),d&&t.PointHelper.move(lt,d),o){case"stretch":w||(x=i.width/s,S=i.height/a,J(y,i,x,S));break;case"normal":case"clip":if(lt.x||lt.y||x||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),et(y,i,lt.x,lt.y,x,S,u,f,t,e),t&&(x=x?x*t:t,S=S?S*e:e)}break;case"repeat":(!w||x||u||f)&&it(y,i,s,a,lt.x,lt.y,x,S,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:ht(r,n,a.width,i&&i.x),y:ht(o,s,a.height,i&&i.y)}}(_,n&&g,lt.width,lt.height,i));break;default:x&&tt(y,i,lt.x,lt.y,x,S,u)}return y.transform||(i.x||i.y)&&at(y.transform=st(),i.x,i.y),y.width=s,y.height=a,x&&(y.scaleX=x,y.scaleY=S),r&&(y.opacity=r),m&&(y.filters=m),g&&(y.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function ht(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 ut,ft=new t.Bounds;const{isSame:pt}=t.BoundsHelper;function gt(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||dt(s,n,i,a),!0}function _t(e,i){yt(e,t.ImageEvent.LOAD,i)}function mt(e,i){yt(e,t.ImageEvent.LOADED,i)}function wt(e,i,n){i.error=n,e.forceUpdate("surface"),yt(e,t.ImageEvent.ERROR,i)}function yt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function vt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:xt,scale:St,copy:bt}=t.MatrixHelper,{floor:Et,ceil:Bt,max:Rt,abs:Lt}=Math;function kt(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:o,data:l}=i;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;s*=n,a*=n,f&&(f=Lt(f),p=Lt(p),c=xt(),bt(c,g),St(c,1/f,1/p),s*=f,a*=p),h*=s,u*=a;const w=h*u;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/Bt(t))}else{const t=o.width*o.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,h/=d,u/=d),f&&(s/=f,a/=p);const v=m&&m.x*s,x=m&&m.y*a;if(g||1!==s||1!==a){const t=h+(v||0),e=u+(x||0);s/=t/Rt(Et(t),1),a/=e/Rt(Et(e),1),c||(c=xt(),g&&bt(c,g)),St(c,1/s,1/a)}const S=o.getCanvas(h,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),b=o.getPattern(S,_||t.Platform.origin.noRepeat||"no-repeat",c,i);return i.style=b,i.patternId=r,!0}}function Pt(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 At={image:function(e,i,n,s,a){let r,o;const l=t.ImageManager.get(n);return ut&&n===ut.paint&&pt(s,ut.boxBounds)?r=ut.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),ut=l.use>1?{leafPaint:r,paint:n,boxBounds:ft.set(s)}:null),(a||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(gt(e,i,n,l,r,s),a&&(_t(e,o),mt(e,o))):l.error?a&&wt(e,o,l.error):(a&&(vt(e,!0),_t(e,o)),r.loadId=l.load(()=>{vt(e,!1),e.destroyed||(gt(e,i,n,l,r,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),mt(e,o)),r.loadId=void 0},t=>{vt(e,!1),wt(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?kt(i,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add(()=>Pt(this,void 0,void 0,function*(){s.patternTask=null,n.bounds.hit(i.__nowWorld)&&kt(i,s,l),i.forceUpdate("surface")}),300)),!1)},createPattern:kt,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:dt,getPatternData:ct,stretchMode:J,fillOrFitMode:tt,clipMode:et,repeatMode:it},{toPoint:Ct}=t.AroundHelper,{hasTransparent:Tt}=e.ColorConvert,Ot={},Wt={};function Mt(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&&Tt(o)&&(d=!0);d&&(i.isTransparent=!0)}}const{getAngle:Dt,getDistance:It}=t.PointHelper,{get:zt,rotateOfOuter:Ht,scaleOfOuter:Ft}=t.MatrixHelper,{toPoint:jt}=t.AroundHelper,Ut={},Gt={};function Nt(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=Dt(e,i);a=zt(),s?(Ft(a,e,r/o*(n||1),1),Ht(a,e,t+90)):(Ft(a,e,1,r/o*(n||1)),Ht(a,e,t))}return a}const{getDistance:Yt}=t.PointHelper,{toPoint:qt}=t.AroundHelper,Xt={},Vt={};const Qt={linearGradient:function(e,i){let{from:n,to:s,type:a,opacity:r}=e;Ct(n||"top",i,Ot),Ct(s||"bottom",i,Wt);const o=t.Platform.canvas.createLinearGradient(Ot.x,Ot.y,Wt.x,Wt.y),l={type:a,style:o};return Mt(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;jt(n||"center",i,Ut),jt(s||"bottom",i,Gt);const l=t.Platform.canvas.createRadialGradient(Ut.x,Ut.y,0,Ut.x,Ut.y,It(Ut,Gt)),d={type:a,style:l};Mt(d,l,e.stops,r);const c=Nt(i,Ut,Gt,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;qt(n||"center",i,Xt),qt(s||"bottom",i,Vt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Xt.x,Xt.y):t.Platform.canvas.createRadialGradient(Xt.x,Xt.y,0,Xt.x,Xt.y,Yt(Xt,Vt)),d={type:a,style:l};Mt(d,l,e.stops,r);const c=Nt(i,Xt,Vt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Nt},{copy:Zt,move:$t,toOffsetOutBounds:Kt}=t.BoundsHelper,{max:Jt,abs:te}=Math,ee={},ie=new t.Matrix,ne={};function se(t,e){let i,n,s,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,n=t.y||0,a=1.5*(t.blur||0),s=te(t.spread||0),r=Jt(r,s+a-n),o=Jt(o,s+a+i),l=Jt(l,s+a+n),d=Jt(d,s+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function ae(e,i,n){const{shapeBounds:s}=n;let a,r;t.Platform.fullImageShadow?(Zt(ee,e.bounds),$t(ee,i.x-s.x,i.y-s.y),a=e.bounds,r=ee):(a=s,r=i),e.copyWorld(n.canvas,a,r)}const{toOffsetOutBounds:re}=t.BoundsHelper,oe={};const le=se;const de={shadow:function(i,n,s){let a,r;const{__nowWorld:o}=i,{shadow:l}=i.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=l.length-1;Kt(c,ne,h),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(ne.offsetX+(l.x||0)*f*w,ne.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w,e.ColorConvert.string(l.color)),r=e.Effect.getShadowTransform(i,g,s,l,ne,w),r&&g.setTransform(r),ae(g,ne,s),r&&g.resetTransform(),a=h,l.box&&(g.restore(),g.save(),d&&(g.copyWorld(g,h,o,"copy"),a=o),d?g.copyWorld(d,o,o,"destination-out"):g.copyWorld(s.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(i,n,g,a,l.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(i,n,s){let a,r;const{__nowWorld:o}=i,{innerShadow:l}=i.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=l.length-1;re(c,oe,h),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(oe.offsetX+(l.x||0)*f*w,oe.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w),r=e.Effect.getShadowTransform(i,g,s,l,oe,w,!0),r&&g.setTransform(r),ae(g,oe,s),g.restore(),d?(g.copyWorld(g,h,o,"copy"),g.copyWorld(d,o,o,"source-out"),a=o):(g.copyWorld(s.canvas,u,c,"source-out"),a=h),g.fillWorld(a,e.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(i,n,g,a,l.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){},getShadowRenderSpread:se,getShadowTransform:function(t,e,i,n,s,a,r){if(n.spread){const i=2*n.spread*a*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return ie.set().scaleOfOuter({x:(s.x+s.width/2)*e.pixelRatio,y:(s.y+s.height/2)*e.pixelRatio},1+i/o,1+i/l),ie}},isTransformShadow(t){},getInnerShadowSpread:le},{excludeRenderBounds:ce}=t.LeafBoundsHelper;let he;function ue(t,e,i,n,s,a,r,o){switch(e){case"grayscale":he||(he=!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);pe(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":pe(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function fe(t){return t.getSameCanvas(!1,!0)}function pe(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&&(ue(this,r,t,s,n,a,void 0,!0),n=s=null),"clipping"!==o&&"clipping-path"!==o||ce(i,e)||i.__render(t,e),a=i.__.opacity,he=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=fe(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=fe(t)),s||(s=fe(t)),i.__render(n,e));continue}const c=1===a&&i.__.__blendMode;c&&ue(this,r,t,s,n,a,void 0,!1),ce(i,e)||i.__render(s||t,e),c&&ue(this,r,t,s,n,a,c,!1)}ue(this,r,t,s,n,a,void 0,!0)};const ge=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",_e=ge+"_#~&*+\\=|≮≯≈≠=…",me=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 we(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ye=we("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ve=we("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),xe=we(ge),Se=we(_e),be=we("- —/~|┆·");var Ee;!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"}(Ee||(Ee={}));const{Letter:Be,Single:Re,Before:Le,After:ke,Symbol:Pe,Break:Ae}=Ee;function Ce(t){return ye[t]?Be:be[t]?Ae:ve[t]?Le:xe[t]?ke:Se[t]?Pe:me.test(t)?Re:Be}const Te={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 Oe(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:We}=Te,{Letter:Me,Single:De,Before:Ie,After:ze,Symbol:He,Break:Fe}=Ee;let je,Ue,Ge,Ne,Ye,qe,Xe,Ve,Qe,Ze,$e,Ke,Je,ti,ei,ii,ni,si=[];function ai(t,e){Qe&&!Ve&&(Ve=Qe),je.data.push({char:t,width:e}),Ge+=e}function ri(){Ne+=Ge,je.width=Ge,Ue.words.push(je),je={data:[]},Ge=0}function oi(){ti&&(ei.paraNumber++,Ue.paraStart=!0,ti=!1),Qe&&(Ue.startCharSize=Ve,Ue.endCharSize=Qe,Ve=0),Ue.width=Ne,ii.width?We(Ue):ni&&li(),si.push(Ue),Ue={words:[]},Ne=0}function li(){Ne>(ei.maxWidth||0)&&(ei.maxWidth=Ne)}const{top:di,right:ci,bottom:hi,left:ui}=t.Direction4;function fi(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 pi={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[ui],r-=c[ci]+c[ui]):n.autoSizeAlign||(s=c[ui]),o?(a=c[di],o-=c[di]+c[hi]):n.autoSizeAlign||(a=c[di]));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){ei=e,si=e.rows,ii=e.bounds,ni=!ii.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=t.Platform,{width:l,height:d}=ii;if(l||d||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;ti=!0,$e=null,Ve=Xe=Qe=Ge=Ne=0,je={data:[]},Ue={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)qe=i[n],"\n"===qe?(Ge&&ri(),Ue.paraEnd=!0,oi(),ti=!0):(Ze=Ce(qe),Ze===Me&&"none"!==r&&(qe=Oe(qe,r,!Ge)),Xe=o.measureText(qe).width,s&&(s<0&&(Qe=Xe),Xe+=s),Ke=Ze===De&&($e===De||$e===Me)||$e===De&&Ze!==ze,Je=!(Ze!==Ie&&Ze!==De||$e!==He&&$e!==ze),Ye=ti&&a?l-a:l,t&&l&&Ne+Ge+Xe>Ye&&(e?(Ge&&ri(),Ne&&oi()):(Je||(Je=Ze===Me&&$e==ze),Ke||Je||Ze===Fe||Ze===Ie||Ze===De||Ge+Xe>Ye?(Ge&&ri(),Ne&&oi()):Ne&&oi()))," "===qe&&!0!==ti&&Ne+Ge===0||(Ze===Fe?(" "===qe&&Ge&&ri(),ai(qe,Xe),ri()):Ke||Je?(Ge&&ri(),ai(qe,Xe)):ai(qe,Xe)),$e=Ze);Ge&&ri(),Ne&&oi(),si.length>0&&(si[si.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{ei.paraNumber++,Ne=o.measureText(t).width,si.push({x:a||0,text:t,width:Ne,paraStart:!0}),ni&&li()})}(h,i,n),c&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":fi(e,"x",t[ui]);break;case"right":fi(e,"x",-t[ci])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":fi(e,"y",t[di]);break;case"bottom":fi(e,"y",-t[hi])}}(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,S=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+=(S-y.width)/2;break;case"right":y.x+=S-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,a=0;const{fontSize:r,textDecoration:o}=n;switch(i.decorationHeight=r/11,t.isObject(o)?(s=o.type,o.color&&(i.decorationColor=e.ColorConvert.string(o.color)),o.offset&&(a=Math.min(.3*r,Math.max(o.offset,.15*-r)))):s=o,s){case"under":i.decorationY=[.15*r+a];break;case"delete":i.decorationY=[.35*-r];break;case"under-delete":i.decorationY=[.15*r+a,.35*-r]}}(h,n),h}};const gi={string:function(i,n){if(!i)return"#000";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,pi),Object.assign(e.ColorConvert,gi),Object.assign(e.Paint,j),Object.assign(e.PaintImage,At),Object.assign(e.PaintGradient,Qt),Object.assign(e.Effect,de);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:a,pixelRatio:n}=this.config,s={width:i||e.width,height:a||e.height,pixelRatio:n};this.resize(s),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(e,i,a,n,s){this.context.roundRect(e,i,a,n,t.isNumber(s)?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;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||(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,a={width:t,height:e,pixelRatio:i};this.isSameSize(a)||this.emitResize(a)})},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:a,fileType:n}=t.FileHelper;function s(e,i){t.Platform.origin={createCanvas:(t,e,a)=>{const n={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(n):i.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(a(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(e,i,s)=>{let r=e.toDataURL(a(n(i)),s);return r=r.substring(r.indexOf("64,")+3),t.Platform.origin.download(r,i)},download:(e,a)=>new Promise((n,s)=>{let r;a.includes("/")||(a=`${i.env.USER_DATA_PATH}/`+a,r=!0);const o=i.getFileSystemManager();o.writeFile({filePath:a,data:e,encoding:"base64",success(){r?t.Platform.miniapp.saveToAlbum(a).then(()=>{o.unlink({filePath:a}),n()}):n()},fail(t){s(t)}})}),loadImage:e=>new Promise((i,a)=>{const n=t.Platform.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{a(t)},n.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:a=>{a.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:a,__updatedList:n}=this,{BEFORE:s,LAYOUT:r,AFTER:u}=t.LayoutEvent,f=this.getBlocks(n);f.forEach(t=>t.setBefore()),a.emitEvent(new t.LayoutEvent(s,f,this.times)),this.extraBlock=null,n.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)))})}(n,this.__levelList),function(t){let e,i,a;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){a=i.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||l(a[t])}l(i)}})}(this.__levelList),function(t){t.list.forEach(d)}(n),this.extraBlock&&f.push(this.extraBlock),f.forEach(t=>t.setAfter()),a.emitEvent(new t.LayoutEvent(r,f,this.times)),a.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:a,LAYOUT:n,AFTER:s}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(a,r,this.times)),m.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(n,r,this.times)),i.emitEvent(new t.LayoutEvent(s,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,a){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=e,this.canvas=i,a&&(this.config=t.DataHelper.default(a,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:a}=this,n=e.getIntersect(a.bounds),s=new t.Bounds(n);a.save(),n.spread(y.clipSpread).ceil(),a.clearWorld(n),a.clipWorld(n),this.__render(n,s),a.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:a}=this,n=e.includes(this.target.__world),s=n?{includes:n}:{bounds:e,includes:n};this.needFill&&a.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(a,e),t.Platform.render(this.target,a,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),a.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);this.requestTime=this.frameTime||Date.now();const i=()=>{const e=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:a}=this.config;if(a&&e>a)return t.Platform.requestRender(i);const{frames:n}=this;n.length>30&&n.shift(),n.push(e),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};t.Platform.requestRender(i)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:a}=e.old;if(!new t.Bounds(0,0,i,a).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,a){this.target.emitEvent(new t.RenderEvent(e,this.times,i,a))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function v(t,i,a){t.__.__font?e.Paint.fillText(t,i,a):t.__.windingRule?i.fill(t.__.windingRule):i.fill()}function x(i,a,n,s,r){const o=n.__;t.isObject(i)?e.Paint.drawStrokesStyle(i,a,!1,n,s,r):(s.setStroke(i,o.__strokeWidth*a,o),s.stroke()),o.__useArrow&&e.Paint.strokeArrow(i,n,s,r)}function S(i,a,n,s,r){const o=n.__;t.isObject(i)?e.Paint.drawStrokesStyle(i,a,!0,n,s,r):(s.setStroke(i,o.__strokeWidth*a,o),e.Paint.drawTextStroke(n,s,r))}function b(i,a,n,s,r){const o=s.getSameCanvas(!0,!0);o.font=n.__.__font,S(i,2,n,o,r),o.blendMode="outside"===a?"destination-out":"destination-in",e.Paint.fillText(n,o,r),o.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,s,o),o.recycle(n.__nowWorld)}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,a)=>{}}),t.Platform.layout=m.fullLayout,t.Platform.render=function(e,i,a){const n=Object.assign(Object.assign({},a),{topRendering:!0});a.topList=new t.LeafList,e.__render(i,a),a.topList.length&&a.topList.forEach(t=>t.__render(i,n))};const{getSpread:E,copyAndSpread:P,toOuterOf:B,getOuterOf:R,getByMove:k,move:L,getIntersectData:A}=t.BoundsHelper,C={};let T;const{stintSet:O}=t.DataHelper,{hasTransparent:I}=e.ColorConvert;function M(i,a,n){if(!t.isObject(a)||!1===a.visible||0===a.opacity)return;let s;const{boxBounds:r}=n.__layout;switch(a.type){case"image":s=e.PaintImage.image(n,i,a,r,!T||!T[a.url]);break;case"linear":s=e.PaintGradient.linearGradient(a,r);break;case"radial":s=e.PaintGradient.radialGradient(a,r);break;case"angular":s=e.PaintGradient.conicGradient(a,r);break;case"solid":const{type:o,color:l,opacity:d}=a;s={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(a.r)||(s={type:"solid",style:e.ColorConvert.string(a)})}if(s&&(s.originPaint=a,t.isString(s.style)&&I(s.style)&&(s.isTransparent=!0),a.style)){if(0===a.style.strokeWidth)return;s.strokeStyle=a.style}return s}const W={compute:function(i,a){const n=a.__,s=[];let r,o,l,d=n.__input[i];t.isArray(d)||(d=[d]),T=e.PaintImage.recycleImage(i,n);for(let t,e=0,n=d.length;e<n;e++)(t=M(i,d[e],a))&&(s.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));n["_"+i]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(r=!0),o=!0),"fill"===i?(O(n,"__isAlphaPixelFill",r),O(n,"__isTransparentFill",o)):(O(n,"__isAlphaPixelStroke",r),O(n,"__isTransparentStroke",o),O(n,"__hasMultiStrokeStyle",l))):n.__removePaint(i,!1)},fill:function(t,e,i,a){i.fillStyle=t,v(e,i,a)},fills:function(t,i,a,n){let s,r,o;for(let l=0,d=t.length;l<d;l++){if(s=t[l],r=s.originPaint,s.image){if(o?o++:o=1,e.PaintImage.checkImage(s,!i.__.__font,i,a,n))continue;if(!s.style){1===o&&s.image.isPlacehold&&i.drawImagePlaceholder(s,a,n);continue}}if(a.fillStyle=s.style,s.transform||r.scaleFixed){if(a.save(),s.transform&&a.transform(s.transform),r.scaleFixed){const{scaleX:t,scaleY:e}=i.getRenderScaleData(!0);(!0===r.scaleFixed||"zoom-in"===r.scaleFixed&&t>1&&e>1)&&a.scale(1/t,1/e)}r.blendMode&&(a.blendMode=r.blendMode),v(i,a,n),a.restore()}else r.blendMode?(a.saveBlendMode(r.blendMode),v(i,a,n),a.restoreBlendMode()):v(i,a,n)}},fillPathOrText:v,fillText:function(t,e,i){const a=t.__,{rows:n,decorationY:s}=a.__textDrawData;let r;a.__isPlacehold&&a.placeholderColor&&(e.fillStyle=a.placeholderColor);for(let t=0,i=n.length;t<i;t++)r=n[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(s){const{decorationColor:t,decorationHeight:i}=a.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>s.forEach(a=>e.fillRect(t.x,t.y+a,t.width,i)))}},stroke:function(i,a,n,s){const r=a.__;if(r.__strokeWidth)if(r.__font)e.Paint.strokeText(i,a,n,s);else switch(r.strokeAlign){case"center":x(i,1,a,n,s);break;case"inside":!function(t,e,i,a){i.save(),i.clipUI(e),x(t,2,e,i,a),i.restore()}(i,a,n,s);break;case"outside":!function(e,i,a,n){const s=i.__;if(s.__fillAfterStroke)x(e,2,i,a,n);else{const{renderBounds:r}=i.__layout,o=a.getSameCanvas(!0,!0);i.__drawRenderPath(o),x(e,2,i,o,n),o.clipUI(s),o.clearWorld(r),t.LeafHelper.copyCanvasByWorld(i,a,o),o.recycle(i.__nowWorld)}}(i,a,n,s)}},strokes:function(t,i,a,n){e.Paint.stroke(t,i,a,n)},strokeText:function(t,e,i,a){switch(e.__.strokeAlign){case"center":S(t,1,e,i,a);break;case"inside":b(t,"inside",e,i,a);break;case"outside":e.__.__fillAfterStroke?S(t,2,e,i,a):b(t,"outside",e,i,a)}},drawTextStroke:function(t,e,i){let a,n=t.__.__textDrawData;const{rows:s,decorationY:r}=n;for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.strokeText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.strokeText(t.char,t.x,a.y)});if(r){const{decorationHeight:t}=n;s.forEach(i=>r.forEach(a=>e.strokeRect(i.x,i.y+a,i.width,t)))}},drawStrokesStyle:function(t,i,a,n,s,r){let o;const l=n.__,{__hasMultiStrokeStyle:d}=l;d||s.setStroke(void 0,l.__strokeWidth*i,l);for(let c=0,h=t.length;c<h;c++)if(o=t[c],(!o.image||!e.PaintImage.checkImage(o,!1,n,s,r))&&o.style){if(d){const{strokeStyle:t}=o;t?s.setStroke(o.style,l.__getRealStrokeWidth(t)*i,l,t):s.setStroke(o.style,l.__strokeWidth*i,l)}else s.strokeStyle=o.style;o.originPaint.blendMode?(s.saveBlendMode(o.originPaint.blendMode),a?e.Paint.drawTextStroke(n,s,r):s.stroke(),s.restoreBlendMode()):a?e.Paint.drawTextStroke(n,s,r):s.stroke()}},shape:function(e,i,a){const n=i.getSameCanvas(),s=i.bounds,r=e.__nowWorld,o=e.__layout,l=e.__nowWorldShapeBounds||(e.__nowWorldShapeBounds={});let d,c,h,u,f,p;B(o.strokeSpread?(P(C,o.boxBounds,o.strokeSpread),C):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=e.getRenderScaleData(!0);if(s.includes(l))p=n,d=f=l,c=r;else{let n;if(t.Platform.fullImageShadow)n=l;else{const e=o.renderShapeSpread?E(s,t.FourNumberHelper.swapAndScale(o.renderShapeSpread,g,_)):s;n=A(e,l)}u=s.getFitMatrix(n);let{a:m,d:w}=u;u.a<1&&(p=i.getSameCanvas(),e.__renderShape(p,a),g*=m,_*=w),f=R(l,u),d=k(f,-u.e,-u.f),c=R(r,u),L(c,-u.e,-u.f);const y=a.matrix;y?(h=new t.Matrix(u),h.multiply(y),m*=y.scaleX,w*=y.scaleY):h=u,h.withScale(m,w),a=Object.assign(Object.assign({},a),{matrix:h})}return e.__renderShape(n,a),{canvas:n,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let D,H=new t.Bounds;const{isSame:z}=t.BoundsHelper;function F(t,i,a,n,s,r){if("fill"===i&&!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||e.PaintImage.createData(s,n,a,r),!0}function j(e,i){Y(e,t.ImageEvent.LOAD,i)}function U(e,i){Y(e,t.ImageEvent.LOADED,i)}function G(e,i,a){i.error=a,e.forceUpdate("surface"),Y(e,t.ImageEvent.ERROR,i)}function Y(e,i,a){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,a))}function N(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:X,translate:q}=t.MatrixHelper,V=new t.Bounds,Q={},Z={};function $(e,i,a,n){const s=t.isString(e)||n?(n?a-n*i:a%i)/((n||Math.floor(a/i))-1):e;return"auto"===e&&s<0?0:s}let K={},J=t.getMatrixData();const{get:tt,set:et,rotateOfOuter:it,translate:at,scaleOfOuter:nt,multiplyParent:st,scale:rt,rotate:ot,skew:lt}=t.MatrixHelper;function dt(t,e,i,a,n,s,r,o){r&&ot(t,r),o&&lt(t,o.x,o.y),n&&rt(t,n,s),at(t,e.x+i,e.y+a)}function ct(t,e,i,a){return new(i||(i=Promise))(function(n,s){function r(t){try{l(a.next(t))}catch(t){s(t)}}function o(t){try{l(a.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((a=a.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:ht,scale:ut,copy:ft}=t.MatrixHelper,{getFloorScale:pt}=t.MathHelper,{abs:gt}=Math;const _t={image:function(e,i,a,n,s){let r,o;const l=t.ImageManager.get(a);return D&&a===D.paint&&z(n,D.boxBounds)?r=D.leafPaint:(r={type:a.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),D=l.use>1?{leafPaint:r,paint:a,boxBounds:H.set(n)}:null),(s||l.loading)&&(o={image:l,attrName:i,attrValue:a}),l.ready?(F(e,i,a,l,r,n),s&&(j(e,o),U(e,o))):l.error?s&&G(e,o,l.error):(s&&(N(e,!0),j(e,o)),r.loadId=l.load(()=>{N(e,!1),e.destroyed||(F(e,i,a,l,r,n)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),U(e,o)),r.loadId=void 0},t=>{N(e,!1),G(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,a,n,s,r){const{scaleX:o,scaleY:l}=e.PaintImage.getImageRenderScaleData(i,n,s,r),{image:d,data:c,originPaint:h}=i,{exporting:u}=r;return!(!c||i.patternId===o+"-"+l&&!u)&&(a&&(c.repeat?a=!1:h.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(n)||u||(a=t.Platform.image.isLarge(d,o,l))),a?(n.__.__isFastShadow&&(s.fillStyle=i.style||"#000",s.fill()),e.PaintImage.drawImage(i,o,l,n,s,r),!0):(!i.style||h.sync||u?e.PaintImage.createPattern(i,n,s,r):e.PaintImage.createPatternTask(i,n,s,r),!1))},drawImage:function(t,e,i,a,n,s){const{data:r,image:o}=t,{blendMode:l}=t.originPaint,{opacity:d,transform:c}=r,h=o.getFull(r.filters),u=a.__;let f,{width:p,height:g}=o;(f=c&&!c.onlyScale||u.path||u.cornerRadius)||d||l?(n.save(),f&&n.clipUI(a),l&&(n.blendMode=l),d&&(n.opacity*=d),c&&n.transform(c),n.drawImage(h,0,0,p,g),n.restore()):(r.scaleX&&(p*=r.scaleX,g*=r.scaleY),n.drawImage(h,0,0,p,g))},getImageRenderScaleData:function(t,e,i,a){const n=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:s}=t;if(i){const{pixelRatio:t}=i;n.scaleX*=t,n.scaleY*=t}return s&&s.scaleX&&(n.scaleX*=Math.abs(s.scaleX),n.scaleY*=Math.abs(s.scaleY)),n},recycleImage:function(e,i){const a=i["_"+e];if(t.isArray(a)){let n,s,r,o,l;for(let d=0,c=a.length;d<c;d++)n=a[d],s=n.image,l=s&&s.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),s.unload(a[d].loadId,!o.some(t=>t.url===l))));return r}return null},createPatternTask:function(i,a,n,s){i.patternTask||(i.patternTask=t.ImageManager.patternTasker.add(()=>ct(this,void 0,void 0,function*(){i.patternTask=null,n.bounds.hit(a.__nowWorld)&&e.PaintImage.createPattern(i,a,n,s),a.forceUpdate("surface")}),300))},createPattern:function(i,a,n,s){let{scaleX:r,scaleY:o}=e.PaintImage.getImageRenderScaleData(i,a,n,s),l=r+"-"+o;if(i.patternId!==l&&!a.destroyed&&(!t.Platform.image.isLarge(i.image,r,o)||i.data.repeat)){const{image:n,data:s}=i,{transform:d,gap:c}=s,h=e.PaintImage.getPatternFixScale(i,r,o);let u,f,p,{width:g,height:_}=n;h&&(r*=h,o*=h),g*=r,_*=o,c&&(f=c.x*r/gt(s.scaleX||1),p=c.y*o/gt(s.scaleY||1)),(d||1!==r||1!==o)&&(r*=pt(g+(f||0)),o*=pt(_+(p||0)),u=ht(),d&&ft(u,d),ut(u,1/r,1/o));const m=n.getCanvas(g,_,s.opacity,s.filters,f,p,a.leafer&&a.leafer.config.smooth),w=n.getPattern(m,s.repeat||t.Platform.origin.noRepeat||"no-repeat",u,i);i.style=w,i.patternId=l}},getPatternFixScale:function(e,i,a){const{image:n}=e;let s,r=t.Platform.image.maxPatternSize,o=n.width*n.height;return n.isSVG?i>1&&(s=Math.ceil(i)/i):r>o&&(r=o),(o*=i*a)>r&&(s=Math.sqrt(r/o)),s},createData:function(t,i,a,n){t.data=e.PaintImage.getPatternData(a,n,i)},getPatternData:function(i,a,n){i.padding&&(a=V.set(a).shrink(i.padding)),"strench"===i.mode&&(i.mode="stretch");const{width:s,height:r}=n,{opacity:o,mode:l,align:d,offset:c,scale:h,size:u,rotation:f,skew:p,clipSize:g,repeat:_,gap:m,filters:w}=i,y=a.width===s&&a.height===r,v={mode:l},x="center"!==d&&(f||0)%180==90;let S,b;switch(t.BoundsHelper.set(Z,0,0,x?r:s,x?s:r),l&&"cover"!==l&&"fit"!==l?((h||u)&&(t.MathHelper.getScaleData(h,u,n,Q),S=Q.scaleX,b=Q.scaleY),(d||m||_)&&(S&&t.BoundsHelper.scale(Z,S,b,!0),d&&t.AlignHelper.toPoint(d,Z,a,Z,!0,!0))):y&&!f||(S=b=t.BoundsHelper.getFitScale(a,Z,"fit"!==l),t.BoundsHelper.put(a,n,d,S,!1,Z),t.BoundsHelper.scale(Z,S,b,!0)),c&&t.PointHelper.move(Z,c),l){case"stretch":y?S&&(S=b=void 0):(S=a.width/s,b=a.height/r,e.PaintImage.stretchMode(v,a,S,b));break;case"normal":case"clip":if(Z.x||Z.y||S||g||f||p){let t,i;g&&(t=a.width/g.width,i=a.height/g.height),e.PaintImage.clipMode(v,a,Z.x,Z.y,S,b,f,p,t,i),t&&(S=S?S*t:t,b=b?b*i:i)}break;case"repeat":(!y||S||f||p)&&e.PaintImage.repeatMode(v,a,s,r,Z.x,Z.y,S,b,f,p,d,i.freeTransform),_||(v.repeat="repeat");const n=t.isObject(_);(m||n)&&(v.gap=function(e,i,a,n,s){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:$(r,a,s.width,i&&i.x),y:$(o,n,s.height,i&&i.y)}}(m,n&&_,Z.width,Z.height,a));break;default:S&&e.PaintImage.fillOrFitMode(v,a,Z.x,Z.y,S,b,f)}return v.transform||(a.x||a.y)&&q(v.transform=X(),a.x,a.y),S&&(v.scaleX=S,v.scaleY=b),o&&o<1&&(v.opacity=o),w&&(v.filters=w),_&&(v.repeat=t.isString(_)?"x"===_?"repeat-x":"repeat-y":"repeat"),v},stretchMode:function(t,e,i,a){const n=tt(),{x:s,y:r}=e;s||r?at(n,s,r):n.onlyScale=!0,rt(n,i,a),t.transform=n},fillOrFitMode:function(t,e,i,a,n,s,r){const o=tt();at(o,e.x+i,e.y+a),rt(o,n,s),r&&it(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,a,n,s,r,o,l,d){const c=tt();dt(c,e,i,a,n,s,r,o),l&&(r||o?(et(J),nt(J,e,l,d),st(c,J)):nt(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,a,n,s,r,o,l,d,c,h){const u=tt();if(h)dt(u,e,n,s,r,o,l,d);else{if(l)if("center"===c)it(u,{x:i/2,y:a/2},l);else switch(ot(u,l),l){case 90:at(u,a,0);break;case 180:at(u,i,a);break;case 270:at(u,0,i)}K.x=e.x+n,K.y=e.y+s,at(u,K.x,K.y),r&&nt(u,K,r,o)}t.transform=u}},{toPoint:mt}=t.AroundHelper,{hasTransparent:wt}=e.ColorConvert,yt={},vt={};function xt(i,a,n,s){if(n){let r,o,l,d;for(let i=0,c=n.length;i<c;i++)r=n[i],t.isString(r)?(l=i/(c-1),o=e.ColorConvert.string(r,s)):(l=r.offset,o=e.ColorConvert.string(r.color,s)),a.addColorStop(l,o),!d&&wt(o)&&(d=!0);d&&(i.isTransparent=!0)}}const{getAngle:St,getDistance:bt}=t.PointHelper,{get:Et,rotateOfOuter:Pt,scaleOfOuter:Bt}=t.MatrixHelper,{toPoint:Rt}=t.AroundHelper,kt={},Lt={};function At(t,e,i,a,n){let s;const{width:r,height:o}=t;if(r!==o||a){const t=St(e,i);s=Et(),n?(Bt(s,e,r/o*(a||1),1),Pt(s,e,t+90)):(Bt(s,e,1,r/o*(a||1)),Pt(s,e,t))}return s}const{getDistance:Ct}=t.PointHelper,{toPoint:Tt}=t.AroundHelper,Ot={},It={};const Mt={linearGradient:function(e,i){let{from:a,to:n,type:s,opacity:r}=e;mt(a||"top",i,yt),mt(n||"bottom",i,vt);const o=t.Platform.canvas.createLinearGradient(yt.x,yt.y,vt.x,vt.y),l={type:s,style:o};return xt(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:a,to:n,type:s,opacity:r,stretch:o}=e;Rt(a||"center",i,kt),Rt(n||"bottom",i,Lt);const l=t.Platform.canvas.createRadialGradient(kt.x,kt.y,0,kt.x,kt.y,bt(kt,Lt)),d={type:s,style:l};xt(d,l,e.stops,r);const c=At(i,kt,Lt,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,i){let{from:a,to:n,type:s,opacity:r,stretch:o}=e;Tt(a||"center",i,Ot),Tt(n||"bottom",i,It);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ot.x,Ot.y):t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,Ct(Ot,It)),d={type:s,style:l};xt(d,l,e.stops,r);const c=At(i,Ot,It,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:At},{copy:Wt,move:Dt,toOffsetOutBounds:Ht}=t.BoundsHelper,{max:zt,abs:Ft}=Math,jt={},Ut=new t.Matrix,Gt={};function Yt(t,e){let i,a,n,s,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,a=t.y||0,s=1.5*(t.blur||0),n=Ft(t.spread||0),r=zt(r,n+s-a),o=zt(o,n+s+i),l=zt(l,n+s+a),d=zt(d,n+s-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Nt(e,i,a){const{shapeBounds:n}=a;let s,r;t.Platform.fullImageShadow?(Wt(jt,e.bounds),Dt(jt,i.x-n.x,i.y-n.y),s=e.bounds,r=jt):(s=n,r=i),e.copyWorld(a.canvas,s,r)}const{toOffsetOutBounds:Xt}=t.BoundsHelper,qt={};const Vt=Yt;const Qt={shadow:function(i,a,n){let s,r;const{__nowWorld:o}=i,{shadow:l}=i.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=n,g=a.getSameCanvas(),_=l.length-1;Ht(c,Gt,h),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(Gt.offsetX+(l.x||0)*f*w,Gt.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w,e.ColorConvert.string(l.color)),r=e.Effect.getShadowTransform(i,g,n,l,Gt,w),r&&g.setTransform(r),Nt(g,Gt,n),r&&g.resetTransform(),s=h,l.box&&(g.restore(),g.save(),d&&(g.copyWorld(g,h,o,"copy"),s=o),d?g.copyWorld(d,o,o,"destination-out"):g.copyWorld(n.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(i,a,g,s,l.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(i,a,n){let s,r;const{__nowWorld:o}=i,{innerShadow:l}=i.__,{worldCanvas:d,bounds:c,renderBounds:h,shapeBounds:u,scaleX:f,scaleY:p}=n,g=a.getSameCanvas(),_=l.length-1;Xt(c,qt,h),l.forEach((l,m)=>{let w=1;if(l.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(qt.offsetX+(l.x||0)*f*w,qt.offsetY+(l.y||0)*p*w,(l.blur||0)*f*w),r=e.Effect.getShadowTransform(i,g,n,l,qt,w,!0),r&&g.setTransform(r),Nt(g,qt,n),g.restore(),d?(g.copyWorld(g,h,o,"copy"),g.copyWorld(d,o,o,"source-out"),s=o):(g.copyWorld(n.canvas,u,c,"source-out"),s=h),g.fillWorld(s,e.ColorConvert.string(l.color),"source-in"),t.LeafHelper.copyCanvasByWorld(i,a,g,s,l.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:a}=t.__;i.setWorldBlur(a*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Yt,getShadowTransform:function(t,e,i,a,n,s,r){if(a.spread){const i=2*a.spread*s*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Ut.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},1+i/o,1+i/l),Ut}},isTransformShadow(t){},getInnerShadowSpread:Vt},{excludeRenderBounds:Zt}=t.LeafBoundsHelper;let $t;function Kt(t,e,i,a,n,s,r,o){switch(e){case"grayscale":$t||($t=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,a,n,s){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(a,r),s&&a.recycle(r);te(t,e,i,1,n,s)}(t,i,a,n,r,o);break;case"opacity-path":te(t,i,a,s,r,o);break;case"path":o&&i.restore()}}function Jt(t){return t.getSameCanvas(!1,!0)}function te(t,e,i,a,n,s){const r=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(i,r,void 0,n),s?i.recycle(r):i.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let i,a,n,s,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(Kt(this,r,t,n,a,s,void 0,!0),a=n=null),"clipping"!==o&&"clipping-path"!==o||Zt(i,e)||i.__render(t,e),s=i.__.opacity,$t=!1,"path"===o||"clipping-path"===o?(s<1?(r="opacity-path",n||(n=Jt(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",a||(a=Jt(t)),n||(n=Jt(t)),i.__render(a,e));continue}const c=1===s&&i.__.__blendMode;c&&Kt(this,r,t,n,a,s,void 0,!1),Zt(i,e)||i.__render(n||t,e),c&&Kt(this,r,t,n,a,s,c,!1)}Kt(this,r,t,n,a,s,void 0,!0)};const ee=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ie=ee+"_#~&*+\\=|≮≯≈≠=…",ae=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 ne(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const se=ne("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),re=ne("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),oe=ne(ee),le=ne(ie),de=ne("- —/~|┆·");var ce;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ce||(ce={}));const{Letter:he,Single:ue,Before:fe,After:pe,Symbol:ge,Break:_e}=ce;function me(t){return se[t]?he:de[t]?_e:re[t]?fe:oe[t]?pe:le[t]?ge:ae.test(t)?ue:he}const we={trimRight(t){const{words:e}=t;let i,a=0,n=e.length;for(let s=n-1;s>-1&&(i=e[s].data[0]," "===i.char);s--)a++,t.width-=i.width;a&&e.splice(n-a,a)}};function ye(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:ve}=we,{Letter:xe,Single:Se,Before:be,After:Ee,Symbol:Pe,Break:Be}=ce;let Re,ke,Le,Ae,Ce,Te,Oe,Ie,Me,We,De,He,ze,Fe,je,Ue,Ge,Ye=[];function Ne(t,e){Me&&!Ie&&(Ie=Me),Re.data.push({char:t,width:e}),Le+=e}function Xe(){Ae+=Le,Re.width=Le,ke.words.push(Re),Re={data:[]},Le=0}function qe(){Fe&&(je.paraNumber++,ke.paraStart=!0,Fe=!1),Me&&(ke.startCharSize=Ie,ke.endCharSize=Me,Ie=0),ke.width=Ae,Ue.width?ve(ke):Ge&&Ve(),Ye.push(ke),ke={words:[]},Ae=0}function Ve(){Ae>(je.maxWidth||0)&&(je.maxWidth=Ae)}const{top:Qe,right:Ze,bottom:$e,left:Ke}=t.Direction4;function Je(t,e,i){const{bounds:a,rows:n}=t;a[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const ti={getDrawData:function(i,a){t.isString(i)||(i=String(i));let n=0,s=0,r=a.__getInput("width")||0,o=a.__getInput("height")||0;const{__padding:l}=a;l&&(r?(n=l[Ke],r-=l[Ze]+l[Ke],!r&&(r=.01)):a.autoSizeAlign||(n=l[Ke]),o?(s=l[Qe],o-=l[Qe]+l[$e],!o&&(o=.01)):a.autoSizeAlign||(s=l[Qe]));const d={bounds:{x:n,y:s,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=a.__font};return function(e,i,a){je=e,Ye=e.rows,Ue=e.bounds,Ge=!Ue.width&&!a.autoSizeAlign;const{__letterSpacing:n,paraIndent:s,textCase:r}=a,{canvas:o}=t.Platform,{width:l}=Ue;if(a.__isCharMode){const t="none"!==a.textWrap,e="break"===a.textWrap;Fe=!0,De=null,Ie=Oe=Me=Le=Ae=0,Re={data:[]},ke={words:[]},n&&(i=[...i]);for(let a=0,d=i.length;a<d;a++)Te=i[a],"\n"===Te?(Le&&Xe(),ke.paraEnd=!0,qe(),Fe=!0):(We=me(Te),We===xe&&"none"!==r&&(Te=ye(Te,r,!Le)),Oe=o.measureText(Te).width,n&&(n<0&&(Me=Oe),Oe+=n),He=We===Se&&(De===Se||De===xe)||De===Se&&We!==Ee,ze=!(We!==be&&We!==Se||De!==Pe&&De!==Ee),Ce=Fe&&s?l-s:l,t&&l&&Ae+Le+Oe>Ce&&(e?(Le&&Xe(),Ae&&qe()):(ze||(ze=We===xe&&De==Ee),He||ze||We===Be||We===be||We===Se||Le+Oe>Ce?(Le&&Xe(),Ae&&qe()):Ae&&qe()))," "===Te&&!0!==Fe&&Ae+Le===0||(We===Be?(" "===Te&&Le&&Xe(),Ne(Te,Oe),Xe()):He||ze?(Le&&Xe(),Ne(Te,Oe)):Ne(Te,Oe)),De=We);Le&&Xe(),Ae&&qe(),Ye.length>0&&(Ye[Ye.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{je.paraNumber++,Ae=o.measureText(t).width,Ye.push({x:s||0,text:t,width:Ae,paraStart:!0}),Ge&&Ve()})}(d,i,a),l&&function(t,e,i,a,n){if(!a&&i.autoSizeAlign)switch(i.textAlign){case"left":Je(e,"x",t[Ke]);break;case"right":Je(e,"x",-t[Ze])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Je(e,"y",t[Qe]);break;case"bottom":Je(e,"y",-t[$e])}}(l,d,a,r,o),function(t,e){const{rows:i,bounds:a}=t,n=i.length,{__lineHeight:s,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=a,m=s*n+(h?h*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(_,s),n>1&&(t.overflow=n);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,S=g||u?g:t.maxWidth;for(let r=0,c=n;r<c;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(w+=h),y.y=w,w+=s,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<a.x&&(a.x=v),x>a.width&&(a.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}a.y=p,a.height=m}(d,a),a.__isCharMode&&function(t,e,i){const{rows:a}=t,{textAlign:n,paraIndent:s,letterSpacing:r}=e,o=i&&n.includes("both"),l=o||i&&n.includes("justify"),d=l&&n.includes("letter");let c,h,u,f,p,g,_,m,w,y;a.forEach(t=>{t.words&&(p=s&&t.paraStart?s:0,m=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-p,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?h/(m-1):0),g=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===g?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,a,n){return t.forEach(t=>{(a||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,n&&(e+=n)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(w=i===m-1,u?w||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(w?1:0))))})),t.words=null)})}(d,a,r),d.overflow&&function(e,i,a,n){if(!n)return;const{rows:s,overflow:r}=e;let{textOverflow:o}=i;if(s.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=a+n-d;("none"===i.textWrap?s:[s[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let a=i;a>-1&&(e=t.data[a],l=e.x+e.width,!(a===i&&l<c));a--){if(l<c&&" "!==e.char||!a){t.data.splice(a+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)}})}}(d,a,n,r),"none"!==a.textDecoration&&function(i,a){let n,s=0;const{fontSize:r,textDecoration:o}=a;switch(i.decorationHeight=r/11,t.isObject(o)?(n=o.type,o.color&&(i.decorationColor=e.ColorConvert.string(o.color)),o.offset&&(s=Math.min(.3*r,Math.max(o.offset,.15*-r)))):n=o,n){case"under":i.decorationY=[.15*r+s];break;case"delete":i.decorationY=[.35*-r];break;case"under-delete":i.decorationY=[.15*r+s,.35*-r]}}(d,a),d}};const ei={string:function(i,a){if(!i)return"#000";const n=t.isNumber(a)&&a<1;if(t.isString(i)){if(!n||!e.ColorConvert.object)return i;i=e.ColorConvert.object(i)}let s=t.isUndefined(i.a)?1:i.a;n&&(s*=a);const r=i.r+","+i.g+","+i.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}};Object.assign(e.TextConvert,ti),Object.assign(e.ColorConvert,ei),Object.assign(e.Paint,W),Object.assign(e.PaintImage,_t),Object.assign(e.PaintGradient,Mt),Object.assign(e.Effect,Qt);try{wx&&s(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=s,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