@leafer-ui/miniapp 1.6.1 → 1.6.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/core"),i=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let i=e.view||e.canvas;i?("string"==typeof 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,o={width:i||e.width,height:n||e.height,pixelRatio:s};this.resize(o),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio: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),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,i))}}const{mineType:s,fileType:o}=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(s(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(e,i,n)=>{let a=e.toDataURL(s(o(i)),n);return a=a.substring(a.indexOf("64,")+3),t.Platform.origin.download(a,i)},download:(e,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:e,encoding:"base64",success(){a?t.Platform.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(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 n(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.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=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:d,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper;class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,f),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:g,updateAllChange:_}=t.LeafHelper,w=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.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){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(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:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),n.emitEvent(new t.LayoutEvent(o,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?(l(t,!0),e.add(t),t.isBranch&&d(t,e),u(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(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||h(n[t])}h(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&c(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),n.emitEvent(new t.LayoutEvent(a,f,this.times)),n.emitEvent(new t.LayoutEvent(r,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:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,a,this.times)),m.fullLayout(i),a.forEach((t=>{t.setAfter()})),i.emitEvent(new t.LayoutEvent(s,a,this.times)),i.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new p([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class v{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,y.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,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=new t.Bounds(s);n.save(),s.spread(v.clipSpread).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0),this.__render(s,o),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),o=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,o),this.renderBounds=i=i||e,this.renderOptions=o,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||y.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(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}v.clipSpread=10;const{hitRadiusPoint:x}=t.BoundsHelper;class b{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,i,n){i||(i=0),n||(n={});const s=n.through||!1,o=n.ignoreHittable||!1,a=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,n.bottomList,o),h=o?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:h,target:l,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:l}}getBestMatchLeaf(e,i,n){if(e.length){let i;this.findList=new t.LeafList;const{x:s,y:o}=this.point,a={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=e.length;s<o;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,a),this.findList.length))return this.findList.list[0]}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren);t--);return s}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let s,o,a;for(let t=0,e=n.length;t<e;t++){s=n[t],o=n[t+1];for(let t=0,e=s.length;t<e&&(a=s.list[t],!o||!o.has(a));t++)i.add(a)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||x(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class E{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new b(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,i,n){const{target:s,picker:o}=this;return t.Platform.backgrounder&&s&&s.updateLayout(),o.getByPoint(e,i,n)}getBy(e,i,n,s){return this.finder?this.finder.getBy(e,i,n,s):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,i)=>new v(t,e,i),selector:(t,e)=>new E(t,e)}),t.Platform.layout=m.fullLayout;const L={convertTouch(t,i){const n=L.getTouch(t),s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class B extends e.InteractionBase{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){return void 0!==t.x?{x:t.x,y:t.y}:super.getLocal(t,e)}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=L.getTouch(t);this.pointerDown(L.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=L.getTouch(t);this.pointerMove(L.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=L.getTouch(t);this.pointerUp(L.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const i=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,i);n.length>1&&(this.multiTouch(e.InteractionHelper.getBase(t),n),this.touches=i)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})})),n}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function R(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(o){const{decorationColor:t,decorationHeight:i}=n;t&&(e.fillStyle=t),s.forEach((t=>o.forEach((n=>e.fillRect(t.x,t.y+n,t.width,i)))))}}function S(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?C(t,!0,e,i):P(e,i);break;case"inside":k("inside",t,s,e,i);break;case"outside":k("outside",t,s,e,i)}}function k(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?C(e,!0,n,r):P(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",R(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function P(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=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(o){const{decorationHeight:t}=n;s.forEach((i=>o.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function C(t,e,n,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&i.PaintImage.checkImage(n,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),e?P(n,s):s.stroke(),s.restoreBlendMode()):e?P(n,s):s.stroke())}function T(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:A,getOuterOf:M,getByMove:W,getIntersectData:O}=t.BoundsHelper;let I;function D(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:o,blendMode:a,color:r,opacity:l}=e;return{type:o,blendMode:a,style:i.ColorConvert.string(r,l)};case"image":return i.PaintImage.image(n,t,e,s,!I||!I[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const H={compute:function(t,e){const n=e.__,s=[];let o,a=n.__input[t];a instanceof Array||(a=[a]),I=i.PaintImage.recycleImage(t,n);for(let i,n=0,o=a.length;n<o;n++)i=D(t,a[n],e),i&&s.push(i);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=o:n.__pixelStroke=o},fill:function(t,e,i){i.fillStyle=t,e.__.__font?R(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,n){let s;const{windingRule:o,__font:a}=e.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&i.PaintImage.checkImage(e,n,s,!a)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),a?R(e,n):o?n.fill(o):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),a?R(e,n):o?n.fill(o):n.fill(),n.restoreBlendMode()):a?R(e,n):o?n.fill(o):n.fill())},fillText:R,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)S(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&T(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)S(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),C(t,!1,e,i),n.__useArrow&&T(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),C(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),C(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:S,drawTextStroke:P,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:h,scaleY:c}=s;if(h<0&&(h=-h),c<0&&(c=-c),e.bounds.includes(s))l=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,d=O(n?A(e.bounds,h===c?n*h:[n*c,n*h]):e.bounds,s);a=e.bounds.getFitMatrix(d);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),h*=u,c*=f),r=M(s,a),o=W(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:h,scaleY:c}}};let z={};const{get:F,rotateOfOuter:j,translate:G,scaleOfOuter:Y,scale:U,rotate:q}=t.MatrixHelper;function N(t,e,i,n,s,o,a){const r=F();G(r,e.x+i,e.y+n),U(r,s,o),a&&j(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function X(t,e,i,n,s,o,a){const r=F();G(r,e.x+i,e.y+n),s&&U(r,s,o),a&&q(r,a),t.transform=r}function V(t,e,i,n,s,o,a,r,l,h){const c=F();if(l)if("center"===h)j(c,{x:i/2,y:n/2},l);else switch(q(c,l),l){case 90:G(c,n,0);break;case 180:G(c,i,n);break;case 270:G(c,0,i)}z.x=e.x+s,z.y=e.y+o,G(c,z.x,z.y),a&&Y(c,z,a,r),t.transform=c}const{get:Q,translate:K}=t.MatrixHelper,Z=new t.Bounds,$={},J={};function tt(t,e,i,n){const{blendMode:s,changeful:o,sync:a}=i;s&&(t.blendMode=s),o&&(t.changeful=o),a&&(t.sync=a),t.data=et(i,n,e)}function et(e,i,n){let{width:s,height:o}=n;e.padding&&(i=Z.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:l,offset:h,scale:c,size:d,rotation:u,repeat:f,filters:p}=e,g=i.width===s&&i.height===o,_={mode:r},w="center"!==l&&(u||0)%180==90,m=w?o:s,y=w?s:o;let v,x,b=0,E=0;if(r&&"cover"!==r&&"fit"!==r)(c||d)&&(t.MathHelper.getScaleData(c,d,n,J),v=J.scaleX,x=J.scaleY);else if(!g||u){const t=i.width/m,e=i.height/y;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(i.width-s*v)/2,E+=(i.height-o*x)/2}if(l){const e={x:b,y:E,width:m,height:y};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(l,e,i,$,!0),b+=$.x,E+=$.y}switch(h&&(b+=h.x,E+=h.y),r){case"stretch":g||(s=i.width,o=i.height);break;case"normal":case"clip":(b||E||v||u)&&X(_,i,b,E,v,x,u);break;case"repeat":(!g||v||u)&&V(_,i,s,o,b,E,v,x,u,l),f||(_.repeat="repeat");break;default:v&&N(_,i,b,E,v,x,u)}return _.transform||(i.x||i.y)&&(_.transform=Q(),K(_.transform,i.x,i.y)),v&&"stretch"!==r&&(_.scaleX=v,_.scaleY=x),_.width=s,_.height=o,a&&(_.opacity=a),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let it,nt=new t.Bounds;const{isSame:st}=t.BoundsHelper;function ot(t,e,i,n,s,o){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||tt(s,n,i,o),!0}function at(e,i){ht(e,t.ImageEvent.LOAD,i)}function rt(e,i){ht(e,t.ImageEvent.LOADED,i)}function lt(e,i,n){i.error=n,e.forceUpdate("surface"),ht(e,t.ImageEvent.ERROR,i)}function ht(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function ct(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:dt,scale:ut,copy:ft}=t.MatrixHelper,{ceil:pt,abs:gt}=Math;function _t(e,i,n){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||e.destroyed)return!1;{s=gt(s),o=gt(o);const{image:e,data:r}=i;let l,h,{width:c,height:d,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(h=dt(),ft(h,p),ut(h,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,d*=o;const _=c*d;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}_>w&&(l=Math.sqrt(_/w)),l&&(s/=l,o/=l,c/=l,d/=l),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(h||(h=dt(),p&&ft(h,p)),ut(h,1/s,1/o));const m=e.getCanvas(pt(c)||1,pt(d)||1,r.opacity,r.filters),y=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",h,i);return i.style=y,i.patternId=a,!0}}function wt(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{l(n.next(t))}catch(t){o(t)}}function r(t){try{l(n.throw(t))}catch(t){o(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(a,r)}l((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:mt}=Math;const yt={image:function(e,i,n,s,o){let a,r;const l=t.ImageManager.get(n);return it&&n===it.paint&&st(s,it.boxBounds)?a=it.leafPaint:(a={type:n.type,image:l},it=l.use>1?{leafPaint:a,paint:n,boxBounds:nt.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:i,attrValue:n}),l.ready?(ot(e,i,n,l,a,s),o&&(at(e,r),rt(e,r))):l.error?o&&lt(e,r,l.error):(o&&(ct(e,!0),at(e,r)),a.loadId=l.load((()=>{ct(e,!1),e.destroyed||(ot(e,i,n,l,a,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),rt(e,r)),a.loadId=null}),(t=>{ct(e,!1),lt(e,r,t),a.loadId=null}))),a},checkImage:function(e,n,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:l}=n,{data:h}=s;if(!h||s.patternId===a+"-"+r+"-"+l&&!i.Export.running)return!1;if(o)if(h.repeat)o=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:i}=h;e*=mt(a)*l,i*=mt(r)*l,h.scaleX&&(e*=h.scaleX,i*=h.scaleY),o=e*i>t.Platform.image.maxCacheSize}return o?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),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()}(e,n,s,h),!0):(!s.style||s.sync||i.Export.running?_t(e,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>wt(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&_t(e,s,l),e.forceUpdate("surface")}))),300)),!1)},createPattern:_t,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){let s,o,a,r,l;for(let h=0,c=n.length;h<c;h++)s=n[h],o=s.image,l=o&&o.url,l&&(a||(a={}),a[l]=!0,t.ImageManager.recycle(o),o.loading&&(r||(r=i.__input&&i.__input[e]||[],r instanceof Array||(r=[r])),o.unload(n[h].loadId,!r.some((t=>t.url===l)))));return a}return null},createData:tt,getPatternData:et,fillOrFitMode:N,clipMode:X,repeatMode:V},{toPoint:vt}=t.AroundHelper,xt={},bt={};function Et(t,e,n){if(e){let s;for(let o=0,a=e.length;o<a;o++)s=e[o],"string"==typeof s?t.addColorStop(o/(a-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}}const{getAngle:Lt,getDistance:Bt}=t.PointHelper,{get:Rt,rotateOfOuter:St,scaleOfOuter:kt}=t.MatrixHelper,{toPoint:Pt}=t.AroundHelper,Ct={},Tt={};function At(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=Lt(e,i);o=Rt(),s?(kt(o,e,a/r*(n||1),1),St(o,e,t+90)):(kt(o,e,1,a/r*(n||1)),St(o,e,t))}return o}const{getDistance:Mt}=t.PointHelper,{toPoint:Wt}=t.AroundHelper,Ot={},It={};const Dt={linearGradient:function(e,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=e;vt(n||"top",i,xt),vt(s||"bottom",i,bt);const l=t.Platform.canvas.createLinearGradient(xt.x,xt.y,bt.x,bt.y);Et(l,e.stops,r);const h={type:o,style:l};return a&&(h.blendMode=a),h},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Pt(n||"center",i,Ct),Pt(s||"bottom",i,Tt);const h=t.Platform.canvas.createRadialGradient(Ct.x,Ct.y,0,Ct.x,Ct.y,Bt(Ct,Tt));Et(h,e.stops,a);const c={type:o,style:h},d=At(i,Ct,Tt,l,!0);return d&&(c.transform=d),r&&(c.blendMode=r),c},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Wt(n||"center",i,Ot),Wt(s||"bottom",i,It);const h=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,Mt(Ot,It));Et(h,e.stops,a);const c={type:o,style:h},d=At(i,Ot,It,l||1,t.Platform.conicGradientRotate90);return d&&(c.transform=d),r&&(c.blendMode=r),c},getTransform:At},{copy:Ht,toOffsetOutBounds:zt}=t.BoundsHelper,Ft={},jt={};function Gt(e,i,n,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Ht(Ft,e.bounds),Ft.x+=i.x-a.x,Ft.y+=i.y-a.y,n){const{matrix:t}=s;Ft.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Ft.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Ft.width*=n,Ft.height*=n}e.copyWorld(s.canvas,e.bounds,Ft)}else n&&(Ht(Ft,i),Ft.x-=i.width/2*(n-1),Ft.y-=i.height/2*(n-1),Ft.width*=n,Ft.height*=n),e.copyWorld(s.canvas,a,n?Ft:i)}const{toOffsetOutBounds:Yt}=t.BoundsHelper,Ut={};const qt={shadow:function(t,e,n){let s,o;const{__nowWorld:a,__layout:r}=t,{shadow:l}=t.__,{worldCanvas:h,bounds:c,shapeBounds:d,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;zt(c,jt),l.forEach(((l,_)=>{p.setWorldShadow(jt.offsetX+l.x*u,jt.offsetY+l.y*f,l.blur*u,i.ColorConvert.string(l.color)),o=l.spread?1+2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Gt(p,jt,o,n),s=c,l.box&&(p.restore(),p.save(),h&&(p.copyWorld(p,c,a,"copy"),s=a),h?p.copyWorld(h,a,a,"destination-out"):p.copyWorld(n.canvas,d,c,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,s,a,l.blendMode):e.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,e,n){let s,o;const{__nowWorld:a,__layout:r}=t,{innerShadow:l}=t.__,{worldCanvas:h,bounds:c,shapeBounds:d,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Yt(c,Ut),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Ut.offsetX+l.x*u,Ut.offsetY+l.y*f,l.blur*u),o=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Gt(p,Ut,o,n),p.restore(),h?(p.copyWorld(p,c,a,"copy"),p.copyWorld(h,a,a,"source-out"),s=a):(p.copyWorld(n.canvas,d,c,"source-out"),s=c),p.fillWorld(s,i.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(p,s,a,l.blendMode):e.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},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:Nt}=t.LeafBoundsHelper;function Xt(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Qt(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Qt(t,i,n,o);break;case"path":i.restore()}}function Vt(t){return t.getSameCanvas(!1,!0)}function Qt(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:l}=this;for(let h=0,c=l.length;h<c;h++)i=l[h],r=i.__.mask,r&&(a&&(Xt(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Vt(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=Vt(t)),s||(s=Vt(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Nt(i,e)||i.__render(s||t,e);Xt(this,a,t,s,n,o)};const Kt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Zt=Kt+"_#~&*+\\=|≮≯≈≠=…",$t=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 Jt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const te=Jt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ee=Jt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ie=Jt(Kt),ne=Jt(Zt),se=Jt("- —/~|┆·");var oe;!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"}(oe||(oe={}));const{Letter:ae,Single:re,Before:le,After:he,Symbol:ce,Break:de}=oe;function ue(t){return te[t]?ae:se[t]?de:ee[t]?le:ie[t]?he:ne[t]?ce:$t.test(t)?re:ae}const fe={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function pe(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:ge}=fe,{Letter:_e,Single:we,Before:me,After:ye,Symbol:ve,Break:xe}=oe;let be,Ee,Le,Be,Re,Se,ke,Pe,Ce,Te,Ae,Me,We,Oe,Ie,De,He,ze=[];function Fe(t,e){Ce&&!Pe&&(Pe=Ce),be.data.push({char:t,width:e}),Le+=e}function je(){Be+=Le,be.width=Le,Ee.words.push(be),be={data:[]},Le=0}function Ge(){Oe&&(Ie.paraNumber++,Ee.paraStart=!0,Oe=!1),Ce&&(Ee.startCharSize=Pe,Ee.endCharSize=Ce,Pe=0),Ee.width=Be,De.width?ge(Ee):He&&Ye(),ze.push(Ee),Ee={words:[]},Be=0}function Ye(){Be>(Ie.maxWidth||0)&&(Ie.maxWidth=Be)}const{top:Ue,right:qe,bottom:Ne,left:Xe}=t.Direction4;function Ve(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 Qe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let s=0,o=0,a=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:l,__font:h,__padding:c}=n;c&&(a?(s=c[Xe],a-=c[qe]+c[Xe]):n.autoSizeAlign||(s=c[Xe]),r?(o=c[Ue],r-=c[Ue]+c[Ne]):n.autoSizeAlign||(o=c[Ue]));const d={bounds:{x:s,y:o,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=h};return function(e,i,n){Ie=e,ze=e.rows,De=e.bounds,He=!De.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=t.Platform,{width:l,height:h}=De;if(l||h||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;Oe=!0,Ae=null,Pe=ke=Ce=Le=Be=0,be={data:[]},Ee={words:[]};for(let n=0,h=i.length;n<h;n++)Se=i[n],"\n"===Se?(Le&&je(),Ee.paraEnd=!0,Ge(),Oe=!0):(Te=ue(Se),Te===_e&&"none"!==a&&(Se=pe(Se,a,!Le)),ke=r.measureText(Se).width,s&&(s<0&&(Ce=ke),ke+=s),Me=Te===we&&(Ae===we||Ae===_e)||Ae===we&&Te!==ye,We=!(Te!==me&&Te!==we||Ae!==ve&&Ae!==ye),Re=Oe&&o?l-o:l,t&&l&&Be+Le+ke>Re&&(e?(Le&&je(),Be&&Ge()):(We||(We=Te===_e&&Ae==ye),Me||We||Te===xe||Te===me||Te===we||Le+ke>Re?(Le&&je(),Be&&Ge()):Be&&Ge()))," "===Se&&!0!==Oe&&Be+Le===0||(Te===xe?(" "===Se&&Le&&je(),Fe(Se,ke),je()):Me||We?(Le&&je(),Fe(Se,ke)):Fe(Se,ke)),Ae=Te);Le&&je(),Be&&Ge(),ze.length>0&&(ze[ze.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ie.paraNumber++,Be=r.measureText(t).width,ze.push({x:o||0,text:t,width:Be,paraStart:!0}),He&&Ye()}))}(d,e,n),c&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Ve(e,"x",t[Xe]);break;case"right":Ve(e,"x",-t[qe])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ve(e,"y",t[Ue]);break;case"bottom":Ve(e,"y",-t[Ne])}}(c,d,n,a,r),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:l,textAlign:h,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,w=o*s+(d?d*(t.paraNumber-1):0),m=a;if(l&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let a=0,c=s;a<c;a++){if(y=i[a],y.x=f,y.width<g||y.width>g&&!l)switch(h){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&d&&a>0&&(m+=d),y.y=m,m+=o,t.overflow>a&&m>w&&(y.isOverflow=!0,t.overflow=a+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<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=w}(d,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,l,h,c,d,u;n.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-h)/(u-1):0,c=a||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(d={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(d,n,a),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const h=r?t.Platform.canvas.measureText(r).width:0,c=n+s-h;("none"===i.textWrap?o:[o[a-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+=h,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,n,s,a),"none"!==l&&function(t,e){let n;const{fontSize:s,textDecoration:o}=e;switch(t.decorationHeight=s/11,"object"==typeof o?(n=o.type,o.color&&(t.decorationColor=i.ColorConvert.string(o.color))):n=o,n){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(d,n),d}};const Ke={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(i.TextConvert,Qe),Object.assign(i.ColorConvert,Ke),Object.assign(i.Paint,H),Object.assign(i.PaintImage,yt),Object.assign(i.PaintGradient,Dt),Object.assign(i.Effect,qt),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new B(t,e,i,n),hitCanvas:(t,e)=>new n(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),i.Leafer.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&a(0,wx)}catch(t){}Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=B,exports.Layouter=m,exports.LeaferCanvas=n,exports.Picker=b,exports.Renderer=v,exports.Selector=E,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/core"),i=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!1}init(){const{config:e}=this;let i=e.view||e.canvas;i?("string"==typeof 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,o={width:i||e.width,height:n||e.height,pixelRatio:s};this.resize(o),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,s){this.context.roundRect(t,e,i,n,"number"==typeof s?[s]:s)}),t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio: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),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,i))}}const{mineType:s,fileType:o}=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(s(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(e,i,n)=>{let a=e.toDataURL(s(o(i)),n);return a=a.substring(a.indexOf("64,")+3),t.Platform.origin.download(a,i)},download:(e,n)=>new Promise(((s,o)=>{let a;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:e,encoding:"base64",success(){a?t.Platform.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){o(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 n(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.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=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds:h,updateChange:c}=t.LeafHelper,{pushAllChildBranch:d,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper;class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,f),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:g,updateAllChange:_}=t.LeafHelper,w=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.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){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(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:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),n.emitEvent(new t.LayoutEvent(o,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?(l(t,!0),e.add(t),t.isBranch&&d(t,e),u(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(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||h(n[t])}h(i)}}))}(this.__levelList),function(t){t.list.forEach(c)}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),n.emitEvent(new t.LayoutEvent(a,f,this.times)),n.emitEvent(new t.LayoutEvent(r,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:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,a,this.times)),m.fullLayout(i),a.forEach((t=>{t.setAfter()})),i.emitEvent(new t.LayoutEvent(s,a,this.times)),i.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new p([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class v{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,y.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,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),o=new t.Bounds(s);n.save(),s.spread(v.clipSpread).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0),this.__render(s,o),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),o=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,o),this.renderBounds=i=i||e,this.renderOptions=o,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||y.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(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}v.clipSpread=10;const{hitRadiusPoint:x}=t.BoundsHelper;class b{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,i,n){i||(i=0),n||(n={});const s=n.through||!1,o=n.ignoreHittable||!1,a=n.target||this.target;this.exclude=n.exclude||null,this.point={x:e.x,y:e.y,radiusX:i,radiusY:i},this.findList=new t.LeafList(n.findList),n.findList||this.hitBranch(a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,n.bottomList,o),h=o?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:h,target:l,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:l}}getBestMatchLeaf(e,i,n){if(e.length){let i;this.findList=new t.LeafList;const{x:s,y:o}=this.point,a={x:s,y:o,radiusX:0,radiusY:0};for(let s=0,o=e.length;s<o;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,a),this.findList.length))return this.findList.list[0]}if(i)for(let t=0,e=i.length;t<e;t++)if(this.hitChild(i[t].target,this.point,i[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const i=new t.LeafList;for(;e;)i.add(e),e=e.parent;return this.target&&i.add(this.target),i}getHitablePath(e){const i=this.getPath(e&&e.hittable?e:null);let n,s=new t.LeafList;for(let t=i.list.length-1;t>-1&&(n=i.list[t],n.__.hittable)&&(s.addAt(n,0),n.__.hitChildren);t--);return s}getThroughPath(e){const i=new t.LeafList,n=[];for(let t=e.length-1;t>-1;t--)n.push(this.getPath(e[t]));let s,o,a;for(let t=0,e=n.length;t<e;t++){s=n[t],o=n[t+1];for(let t=0,e=s.length;t<e&&(a=s.list[t],!o||!o.has(a));t++)i.add(a)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||x(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class E{constructor(e,i){this.config={},i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new b(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,i,n){const{target:s,picker:o}=this;return t.Platform.backgrounder&&s&&s.updateLayout(),o.getByPoint(e,i,n)}getBy(e,i,n,s){return this.finder?this.finder.getBy(e,i,n,s):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,i)=>new v(t,e,i),selector:(t,e)=>new E(t,e)}),t.Platform.layout=m.fullLayout;const L={convertTouch(t,i){const n=L.getTouch(t),s=e.InteractionHelper.getBase(t);return Object.assign(Object.assign({},s),{x:i.x,y:i.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:n.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class B extends e.InteractionBase{__listenEvents(){super.__listenEvents(),this.config.eventer&&(this.config.eventer.receiveEvent=this.receive.bind(this))}receive(t){switch(t.type){case"touchstart":this.onTouchStart(t);break;case"touchmove":this.onTouchMove(t);break;case"touchend":this.onTouchEnd(t);break;case"touchcancel":this.onTouchCancel()}}getLocal(t,e){return void 0!==t.x?{x:t.x,y:t.y}:super.getLocal(t,e)}getTouches(t){return t}onTouchStart(t){this.multiTouchStart(t);const e=L.getTouch(t);this.pointerDown(L.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=L.getTouch(t);this.pointerMove(L.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=L.getTouch(t);this.pointerUp(L.convertTouch(t,this.getLocal(e)))}onTouchCancel(){this.pointerCancel()}multiTouchStart(t){this.useMultiTouch=t.touches.length>1,this.touches=this.useMultiTouch?this.getTouches(t.touches):void 0,this.useMultiTouch&&this.pointerCancel()}multiTouchMove(t){if(this.useMultiTouch&&t.touches.length>1){const i=this.getTouches(t.touches),n=this.getKeepTouchList(this.touches,i);n.length>1&&(this.multiTouch(e.InteractionHelper.getBase(t),n),this.touches=i)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const n=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&n.push({from:this.getLocal(t),to:this.getLocal(i)})})),n}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function R(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let o;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)o=n[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach((t=>{e.fillText(t.char,t.x,o.y)}));if(s){const{decorationColor:t,decorationHeight:o}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach((t=>s.forEach((i=>e.fillRect(t.x,t.y+i,t.width,o)))))}}function S(t,e){t.__.__font?R(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function k(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?T(t,!0,e,i):C(e,i);break;case"inside":P("inside",t,s,e,i);break;case"outside":P("outside",t,s,e,i)}}function P(t,e,i,n,s){const{__strokeWidth:o,__font:a}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,n.__),r.font=a,i?T(e,!0,n,r):C(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",R(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function C(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:o}=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(o){const{decorationHeight:t}=n;s.forEach((i=>o.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function T(t,e,n,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&i.PaintImage.checkImage(n,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),e?C(n,s):s.stroke(),s.restoreBlendMode()):e?C(n,s):s.stroke())}function A(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:M,getOuterOf:W,getByMove:O,getIntersectData:I}=t.BoundsHelper;let D;function H(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:o,blendMode:a,color:r,opacity:l}=e;return{type:o,blendMode:a,style:i.ColorConvert.string(r,l)};case"image":return i.PaintImage.image(n,t,e,s,!D||!D[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const z={compute:function(t,e){const n=e.__,s=[];let o,a=n.__input[t];a instanceof Array||(a=[a]),D=i.PaintImage.recycleImage(t,n);for(let i,n=0,o=a.length;n<o;n++)i=H(t,a[n],e),i&&s.push(i);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=o:n.__pixelStroke=o},fill:function(t,e,i){i.fillStyle=t,S(e,i)},fills:function(t,e,n){let s;for(let o=0,a=t.length;o<a;o++){if(s=t[o],s.image){if(i.PaintImage.checkImage(e,n,s,!e.__.__font))continue;if(!s.style){!o&&s.image.isPlacehold&&e.drawImagePlaceholder(n,s.image);continue}}n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),S(e,n),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),S(e,n),n.restoreBlendMode()):S(e,n)}},fillPathOrText:S,fillText:R,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)k(t,e,i);else switch(o){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&A(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*s,n),e.__drawRenderPath(o),o.stroke(),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=n;if(s)if(a)k(t,e,i);else switch(o){case"center":i.setStroke(void 0,s,n),T(t,!1,e,i),n.__useArrow&&A(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),T(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,n),T(t,!1,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:k,drawTextStroke:C,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:h,scaleY:c}=s;if(h<0&&(h=-h),c<0&&(c=-c),e.bounds.includes(s))l=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,d=I(n?M(e.bounds,h===c?n*h:[n*c,n*h]):e.bounds,s);a=e.bounds.getFitMatrix(d);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),h*=u,c*=f),r=W(s,a),o=O(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:h,scaleY:c}}};let F={};const{get:j,rotateOfOuter:G,translate:U,scaleOfOuter:Y,scale:q,rotate:N}=t.MatrixHelper;function X(t,e,i,n,s,o,a){const r=j();U(r,e.x+i,e.y+n),q(r,s,o),a&&G(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function V(t,e,i,n,s,o,a){const r=j();U(r,e.x+i,e.y+n),s&&q(r,s,o),a&&N(r,a),t.transform=r}function Q(t,e,i,n,s,o,a,r,l,h){const c=j();if(l)if("center"===h)G(c,{x:i/2,y:n/2},l);else switch(N(c,l),l){case 90:U(c,n,0);break;case 180:U(c,i,n);break;case 270:U(c,0,i)}F.x=e.x+s,F.y=e.y+o,U(c,F.x,F.y),a&&Y(c,F,a,r),t.transform=c}const{get:K,translate:Z}=t.MatrixHelper,$=new t.Bounds,J={},tt={};function et(t,e,i,n){const{blendMode:s,changeful:o,sync:a}=i;s&&(t.blendMode=s),o&&(t.changeful=o),a&&(t.sync=a),t.data=it(i,n,e)}function it(e,i,n){let{width:s,height:o}=n;e.padding&&(i=$.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:l,offset:h,scale:c,size:d,rotation:u,repeat:f,filters:p}=e,g=i.width===s&&i.height===o,_={mode:r},w="center"!==l&&(u||0)%180==90,m=w?o:s,y=w?s:o;let v,x,b=0,E=0;if(r&&"cover"!==r&&"fit"!==r)(c||d)&&(t.MathHelper.getScaleData(c,d,n,tt),v=tt.scaleX,x=tt.scaleY);else if(!g||u){const t=i.width/m,e=i.height/y;v=x="fit"===r?Math.min(t,e):Math.max(t,e),b+=(i.width-s*v)/2,E+=(i.height-o*x)/2}if(l){const e={x:b,y:E,width:m,height:y};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(l,e,i,J,!0),b+=J.x,E+=J.y}switch(h&&(b+=h.x,E+=h.y),r){case"stretch":g||(s=i.width,o=i.height);break;case"normal":case"clip":(b||E||v||u)&&V(_,i,b,E,v,x,u);break;case"repeat":(!g||v||u)&&Q(_,i,s,o,b,E,v,x,u,l),f||(_.repeat="repeat");break;default:v&&X(_,i,b,E,v,x,u)}return _.transform||(i.x||i.y)&&(_.transform=K(),Z(_.transform,i.x,i.y)),v&&"stretch"!==r&&(_.scaleX=v,_.scaleY=x),_.width=s,_.height=o,a&&(_.opacity=a),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let nt,st=new t.Bounds;const{isSame:ot}=t.BoundsHelper;function at(t,e,i,n,s,o){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||et(s,n,i,o),!0}function rt(e,i){ct(e,t.ImageEvent.LOAD,i)}function lt(e,i){ct(e,t.ImageEvent.LOADED,i)}function ht(e,i,n){i.error=n,e.forceUpdate("surface"),ct(e,t.ImageEvent.ERROR,i)}function ct(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function dt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ut,scale:ft,copy:pt}=t.MatrixHelper,{ceil:gt,abs:_t}=Math;function wt(e,i,n){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+n;if(i.patternId===a||e.destroyed)return!1;{s=_t(s),o=_t(o);const{image:e,data:r}=i;let l,h,{width:c,height:d,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(h=ut(),pt(h,p),ft(h,1/u,1/f),s*=u,o*=f),s*=n,o*=n,c*=s,d*=o;const _=c*d;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}_>w&&(l=Math.sqrt(_/w)),l&&(s/=l,o/=l,c/=l,d/=l),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(h||(h=ut(),p&&pt(h,p)),ft(h,1/s,1/o));const m=e.getCanvas(gt(c)||1,gt(d)||1,r.opacity,r.filters),y=e.getPattern(m,g||t.Platform.origin.noRepeat||"no-repeat",h,i);return i.style=y,i.patternId=a,!0}}function mt(t,e,i,n){return new(i||(i=Promise))((function(s,o){function a(t){try{l(n.next(t))}catch(t){o(t)}}function r(t){try{l(n.throw(t))}catch(t){o(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(a,r)}l((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:yt}=Math;const vt={image:function(e,i,n,s,o){let a,r;const l=t.ImageManager.get(n);return nt&&n===nt.paint&&ot(s,nt.boxBounds)?a=nt.leafPaint:(a={type:n.type,image:l},nt=l.use>1?{leafPaint:a,paint:n,boxBounds:st.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:i,attrValue:n}),l.ready?(at(e,i,n,l,a,s),o&&(rt(e,r),lt(e,r))):l.error?o&&ht(e,r,l.error):(o&&(dt(e,!0),rt(e,r)),a.loadId=l.load((()=>{dt(e,!1),e.destroyed||(at(e,i,n,l,a,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),lt(e,r)),a.loadId=null}),(t=>{dt(e,!1),ht(e,r,t),a.loadId=null})),e.placeholderColor&&setTimeout((()=>{l.ready||l.isPlacehold||(l.isPlacehold=!0,e.forceUpdate("surface"))}),100)),a},checkImage:function(e,n,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:l}=n,{data:h}=s;if(!h||s.patternId===a+"-"+r+"-"+l&&!i.Export.running)return!1;if(o)if(h.repeat)o=!1;else if(!(s.changeful||t.ResizeEvent.isResizing(e)||i.Export.running)){let{width:e,height:i}=h;e*=yt(a)*l,i*=yt(r)*l,h.scaleX&&(e*=h.scaleX,i*=h.scaleY),o=e*i>t.Platform.image.maxCacheSize}return o?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),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()}(e,n,s,h),!0):(!s.style||s.sync||i.Export.running?wt(e,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>mt(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&wt(e,s,l),e.forceUpdate("surface")}))),300)),!1)},createPattern:wt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){let s,o,a,r,l;for(let h=0,c=n.length;h<c;h++)s=n[h],o=s.image,l=o&&o.url,l&&(a||(a={}),a[l]=!0,t.ImageManager.recycle(o),o.loading&&(r||(r=i.__input&&i.__input[e]||[],r instanceof Array||(r=[r])),o.unload(n[h].loadId,!r.some((t=>t.url===l)))));return a}return null},createData:et,getPatternData:it,fillOrFitMode:X,clipMode:V,repeatMode:Q},{toPoint:xt}=t.AroundHelper,bt={},Et={};function Lt(t,e,n){if(e){let s;for(let o=0,a=e.length;o<a;o++)s=e[o],"string"==typeof s?t.addColorStop(o/(a-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}}const{getAngle:Bt,getDistance:Rt}=t.PointHelper,{get:St,rotateOfOuter:kt,scaleOfOuter:Pt}=t.MatrixHelper,{toPoint:Ct}=t.AroundHelper,Tt={},At={};function Mt(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=Bt(e,i);o=St(),s?(Pt(o,e,a/r*(n||1),1),kt(o,e,t+90)):(Pt(o,e,1,a/r*(n||1)),kt(o,e,t))}return o}const{getDistance:Wt}=t.PointHelper,{toPoint:Ot}=t.AroundHelper,It={},Dt={};const Ht={linearGradient:function(e,i){let{from:n,to:s,type:o,blendMode:a,opacity:r}=e;xt(n||"top",i,bt),xt(s||"bottom",i,Et);const l=t.Platform.canvas.createLinearGradient(bt.x,bt.y,Et.x,Et.y);Lt(l,e.stops,r);const h={type:o,style:l};return a&&(h.blendMode=a),h},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Ct(n||"center",i,Tt),Ct(s||"bottom",i,At);const h=t.Platform.canvas.createRadialGradient(Tt.x,Tt.y,0,Tt.x,Tt.y,Rt(Tt,At));Lt(h,e.stops,a);const c={type:o,style:h},d=Mt(i,Tt,At,l,!0);return d&&(c.transform=d),r&&(c.blendMode=r),c},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Ot(n||"center",i,It),Ot(s||"bottom",i,Dt);const h=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,It.x,It.y):t.Platform.canvas.createRadialGradient(It.x,It.y,0,It.x,It.y,Wt(It,Dt));Lt(h,e.stops,a);const c={type:o,style:h},d=Mt(i,It,Dt,l||1,t.Platform.conicGradientRotate90);return d&&(c.transform=d),r&&(c.blendMode=r),c},getTransform:Mt},{copy:zt,toOffsetOutBounds:Ft}=t.BoundsHelper,jt={},Gt={};function Ut(e,i,n,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(zt(jt,e.bounds),jt.x+=i.x-a.x,jt.y+=i.y-a.y,n){const{matrix:t}=s;jt.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),jt.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),jt.width*=n,jt.height*=n}e.copyWorld(s.canvas,e.bounds,jt)}else n&&(zt(jt,i),jt.x-=i.width/2*(n-1),jt.y-=i.height/2*(n-1),jt.width*=n,jt.height*=n),e.copyWorld(s.canvas,a,n?jt:i)}const{toOffsetOutBounds:Yt}=t.BoundsHelper,qt={};const Nt={shadow:function(t,e,n){let s,o;const{__nowWorld:a,__layout:r}=t,{shadow:l}=t.__,{worldCanvas:h,bounds:c,shapeBounds:d,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Ft(c,Gt),l.forEach(((l,_)=>{p.setWorldShadow(Gt.offsetX+l.x*u,Gt.offsetY+l.y*f,l.blur*u,i.ColorConvert.string(l.color)),o=l.spread?1+2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ut(p,Gt,o,n),s=c,l.box&&(p.restore(),p.save(),h&&(p.copyWorld(p,c,a,"copy"),s=a),h?p.copyWorld(h,a,a,"destination-out"):p.copyWorld(n.canvas,d,c,"destination-out")),t.__worldFlipped?e.copyWorldByReset(p,s,a,l.blendMode):e.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},innerShadow:function(t,e,n){let s,o;const{__nowWorld:a,__layout:r}=t,{innerShadow:l}=t.__,{worldCanvas:h,bounds:c,shapeBounds:d,scaleX:u,scaleY:f}=n,p=e.getSameCanvas(),g=l.length-1;Yt(c,qt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(qt.offsetX+l.x*u,qt.offsetY+l.y*f,l.blur*u),o=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ut(p,qt,o,n),p.restore(),h?(p.copyWorld(p,c,a,"copy"),p.copyWorld(h,a,a,"source-out"),s=a):(p.copyWorld(n.canvas,d,c,"source-out"),s=c),p.fillWorld(s,i.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(p,s,a,l.blendMode):e.copyWorldToInner(p,s,r.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(s,!0)})),p.recycle(s)},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:Xt}=t.LeafBoundsHelper;function Vt(t,e,i,n,s,o){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Kt(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Kt(t,i,n,o);break;case"path":i.restore()}}function Qt(t){return t.getSameCanvas(!1,!0)}function Kt(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let i,n,s,o,a,r;const{children:l}=this;for(let h=0,c=l.length;h<c;h++)i=l[h],r=i.__.mask,r&&(a&&(Vt(this,a,t,s,n,o),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,s||(s=Qt(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=Qt(t)),s||(s=Qt(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Xt(i,e)||i.__render(s||t,e);Vt(this,a,t,s,n,o)};const Zt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",$t=Zt+"_#~&*+\\=|≮≯≈≠=…",Jt=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 te(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ee=te("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ie=te("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ne=te(Zt),se=te($t),oe=te("- —/~|┆·");var ae;!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"}(ae||(ae={}));const{Letter:re,Single:le,Before:he,After:ce,Symbol:de,Break:ue}=ae;function fe(t){return ee[t]?re:oe[t]?ue:ie[t]?he:ne[t]?ce:se[t]?de:Jt.test(t)?le:re}const pe={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let o=s-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ge(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:_e}=pe,{Letter:we,Single:me,Before:ye,After:ve,Symbol:xe,Break:be}=ae;let Ee,Le,Be,Re,Se,ke,Pe,Ce,Te,Ae,Me,We,Oe,Ie,De,He,ze,Fe=[];function je(t,e){Te&&!Ce&&(Ce=Te),Ee.data.push({char:t,width:e}),Be+=e}function Ge(){Re+=Be,Ee.width=Be,Le.words.push(Ee),Ee={data:[]},Be=0}function Ue(){Ie&&(De.paraNumber++,Le.paraStart=!0,Ie=!1),Te&&(Le.startCharSize=Ce,Le.endCharSize=Te,Ce=0),Le.width=Re,He.width?_e(Le):ze&&Ye(),Fe.push(Le),Le={words:[]},Re=0}function Ye(){Re>(De.maxWidth||0)&&(De.maxWidth=Re)}const{top:qe,right:Ne,bottom:Xe,left:Ve}=t.Direction4;function Qe(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 Ke={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let s=0,o=0,a=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:l,__font:h,__padding:c}=n;c&&(a?(s=c[Ve],a-=c[Ne]+c[Ve]):n.autoSizeAlign||(s=c[Ve]),r?(o=c[qe],r-=c[qe]+c[Xe]):n.autoSizeAlign||(o=c[qe]));const d={bounds:{x:s,y:o,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=h};return function(e,i,n){De=e,Fe=e.rows,He=e.bounds,ze=!He.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=t.Platform,{width:l,height:h}=He;if(l||h||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;Ie=!0,Me=null,Ce=Pe=Te=Be=Re=0,Ee={data:[]},Le={words:[]};for(let n=0,h=i.length;n<h;n++)ke=i[n],"\n"===ke?(Be&&Ge(),Le.paraEnd=!0,Ue(),Ie=!0):(Ae=fe(ke),Ae===we&&"none"!==a&&(ke=ge(ke,a,!Be)),Pe=r.measureText(ke).width,s&&(s<0&&(Te=Pe),Pe+=s),We=Ae===me&&(Me===me||Me===we)||Me===me&&Ae!==ve,Oe=!(Ae!==ye&&Ae!==me||Me!==xe&&Me!==ve),Se=Ie&&o?l-o:l,t&&l&&Re+Be+Pe>Se&&(e?(Be&&Ge(),Re&&Ue()):(Oe||(Oe=Ae===we&&Me==ve),We||Oe||Ae===be||Ae===ye||Ae===me||Be+Pe>Se?(Be&&Ge(),Re&&Ue()):Re&&Ue()))," "===ke&&!0!==Ie&&Re+Be===0||(Ae===be?(" "===ke&&Be&&Ge(),je(ke,Pe),Ge()):We||Oe?(Be&&Ge(),je(ke,Pe)):je(ke,Pe)),Me=Ae);Be&&Ge(),Re&&Ue(),Fe.length>0&&(Fe[Fe.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{De.paraNumber++,Re=r.measureText(t).width,Fe.push({x:o||0,text:t,width:Re,paraStart:!0}),ze&&Ye()}))}(d,e,n),c&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Qe(e,"x",t[Ve]);break;case"right":Qe(e,"x",-t[Ne])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Qe(e,"y",t[qe]);break;case"bottom":Qe(e,"y",-t[Xe])}}(c,d,n,a,r),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:l,textAlign:h,verticalAlign:c,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,w=o*s+(d?d*(t.paraNumber-1):0),m=a;if(l&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let a=0,c=s;a<c;a++){if(y=i[a],y.x=f,y.width<g||y.width>g&&!l)switch(h){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&d&&a>0&&(m+=d),y.y=m,m+=o,t.overflow>a&&m>w&&(y.isOverflow=!0,t.overflow=a+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<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=w}(d,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,l,h,c,d,u;n.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-h)/(u-1):0,c=a||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===c?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(d={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(d,n,a),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const h=r?t.Platform.canvas.measureText(r).width:0,c=n+s-h;("none"===i.textWrap?o:[o[a-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+=h,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,n,s,a),"none"!==l&&function(t,e){let n;const{fontSize:s,textDecoration:o}=e;switch(t.decorationHeight=s/11,"object"==typeof o?(n=o.type,o.color&&(t.decorationColor=i.ColorConvert.string(o.color))):n=o,n){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(d,n),d}};const Ze={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}};Object.assign(i.TextConvert,Ke),Object.assign(i.ColorConvert,Ze),Object.assign(i.Paint,z),Object.assign(i.PaintImage,vt),Object.assign(i.PaintGradient,Ht),Object.assign(i.Effect,Nt),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new B(t,e,i,n),hitCanvas:(t,e)=>new n(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),i.Leafer.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&a(0,wx)}catch(t){}Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=B,exports.Layouter=m,exports.LeaferCanvas=n,exports.Picker=b,exports.Renderer=v,exports.Selector=E,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