@leafer-ui/miniapp 1.5.1 → 1.5.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:h,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};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(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,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:_,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{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){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const 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?(h(t,!0),e.add(t),t.isBranch&&c(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||l(n[t])}l(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),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)),y.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){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(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 v=t.Debug.get("Renderer");class x{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)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(i.innerName,"---\x3e");try{i.isApp||i.app.emit(t.RenderEvent.CHILD_START,i),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.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=e.includes(this.target.__world),a=new t.Bounds(s);n.save(),o&&!t.Debug.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,o,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,!0),i.restore(),t.Run.end(e)}__render(e,i,n){const s=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}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(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__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||v.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)}}const{hitRadiusPoint:b}=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,h=this.getBestMatchLeaf(r,n.bottomList,o),l=o?this.getPath(h):this.getHitablePath(h);return this.clear(),s?{path:l,target:h,throughPath:r.length?this.getThroughPath(r):l}:{path:l,target:h}}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||b(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 L{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 y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>new L(t,e)}),t.Platform.layout=y.fullLayout;const E={convertTouch(t,i){const n=E.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 R 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=E.getTouch(t);this.pointerDown(E.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=E.getTouch(t);this.pointerMove(E.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=E.getTouch(t);this.pointerUp(E.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 S(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[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)})),s&&e.fillRect(i.x,i.y+s,i.width,o)}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?C(t,!0,e,i):T(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?C(e,!0,n,r):T(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",S(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 T(t,e){let i;const{rows:n,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=n.length;t<a;t++)i=n[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)})),s&&e.strokeRect(i.x,i.y+s,i.width,o)}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?T(n,s):s.stroke(),s.restoreBlendMode()):e?T(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:h}=e;return{type:o,blendMode:a,style:i.ColorConvert.string(r,h)};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,e.__.__font?S(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,h=t.length;r<h;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?S(e,n):o?n.fill(o):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),a?S(e,n):o?n.fill(o):n.fill(),n.restoreBlendMode()):a?S(e,n):o?n.fill(o):n.fill())},fillText:S,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),C(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(),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:k,drawTextStroke:T,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,h,{scaleX:l,scaleY:d}=s;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(s))h=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,c=I(n?M(e.bounds,l===d?n*l:[n*d,n*l]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=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:h,shapeBounds:r,scaleX:l,scaleY:d}}};let F={};const{get:j,rotateOfOuter:G,translate:U,scaleOfOuter:Y,scale:V,rotate:q}=t.MatrixHelper;function N(t,e,i,n,s,o,a){const r=j();U(r,e.x+i,e.y+n),V(r,s,o),a&&G(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=j();U(r,e.x+i,e.y+n),s&&V(r,s,o),a&&q(r,a),t.transform=r}function Q(t,e,i,n,s,o,a,r,h,l){const d=j();if(h)if("center"===l)G(d,{x:i/2,y:n/2},h);else switch(q(d,h),h){case 90:U(d,n,0);break;case 180:U(d,i,n);break;case 270:U(d,0,i)}F.x=e.x+s,F.y=e.y+o,U(d,F.x,F.y),a&&Y(d,F,a,r),t.transform=d}const{get:K,translate:Z}=t.MatrixHelper,$=new t.Bounds,J={},tt={};function et(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),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:h,offset:l,scale:d,size:c,rotation:u,repeat:f,filters:g}=e,p=i.width===s&&i.height===o,_={mode:r},w="center"!==h&&(u||0)%180==90,m=w?o:s,y=w?s:o;let v,x,b=0,B=0;if(r&&"cover"!==r&&"fit"!==r)(d||c)&&(t.MathHelper.getScaleData(d,c,n,tt),v=tt.scaleX,x=tt.scaleY);else if(!p||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,B+=(i.height-o*x)/2}if(h){const e={x:b,y:B,width:m,height:y};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(h,e,i,J,!0),b+=J.x,B+=J.y}switch(l&&(b+=l.x,B+=l.y),r){case"stretch":p||(s=i.width,o=i.height);break;case"normal":case"clip":(b||B||v||u)&&X(_,i,b,B,v,x,u);break;case"repeat":(!p||v||u)&&Q(_,i,s,o,b,B,v,x,u,h),f||(_.repeat="repeat");break;default:v&&N(_,i,b,B,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),g&&(_.filters=g),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){dt(e,t.ImageEvent.LOAD,i)}function ht(e,i){dt(e,t.ImageEvent.LOADED,i)}function lt(e,i,n){i.error=n,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,i)}function dt(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:ut,scale:ft,copy:gt}=t.MatrixHelper,{ceil:pt,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 h,l,{width:d,height:c,scaleX:u,scaleY:f,transform:g,repeat:p}=r;u&&(l=ut(),gt(l,g),ft(l,1/u,1/f),s*=u,o*=f),s*=n,o*=n,d*=s,c*=o;const _=d*c;if(!p&&_>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&&(h=Math.sqrt(_/w)),h&&(s/=h,o/=h,d/=h,c/=h),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(l||(l=ut(),g&&gt(l,g)),ft(l,1/s,1/o));const m=e.getCanvas(pt(d)||1,pt(c)||1,r.opacity,r.filters),y=e.getPattern(m,p||t.Platform.origin.noRepeat||"no-repeat",l,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{h(n.next(t))}catch(t){o(t)}}function r(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((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 h=t.ImageManager.get(n);return nt&&n===nt.paint&&ot(s,nt.boxBounds)?a=nt.leafPaint:(a={type:n.type,image:h},nt=h.use>1?{leafPaint:a,paint:n,boxBounds:st.set(s)}:null),(o||h.loading)&&(r={image:h,attrName:i,attrValue:n}),h.ready?(at(e,i,n,h,a,s),o&&(rt(e,r),ht(e,r))):h.error?o&&lt(e,r,h.error):(o&&(ct(e,!0),rt(e,r)),a.loadId=h.load((()=>{ct(e,!1),e.destroyed||(at(e,i,n,h,a,s)&&(h.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ht(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:h}=n;if(!s.data||s.patternId===a+"-"+r+"-"+h&&!i.Export.running)return!1;{const{data:l}=s;if(o)if(l.repeat)o=!1;else{let{width:e,height:n}=l;e*=yt(a)*h,n*=yt(r)*h,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),e.windingRule?n.clip(e.windingRule):n.clip(),s.blendMode&&(n.blendMode=s.blendMode),l.opacity&&(n.opacity*=l.opacity),l.transform&&n.transform(l.transform),n.drawImage(s.image.getFull(l.filters),0,0,l.width,l.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?wt(e,s,h):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,h),e.forceUpdate("surface")}))),300)),!1)}},createPattern:wt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){let s,o,a,r;for(let h=0,l=n.length;h<l;h++)s=n[h].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=i.__input&&i.__input[e]||[],a instanceof Array||(a=[a])),s.unload(n[h].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:et,getPatternData:it,fillOrFitMode:N,clipMode:X,repeatMode:Q},{toPoint:xt}=t.AroundHelper,bt={},Bt={};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:Et,getDistance:Rt}=t.PointHelper,{get:St,rotateOfOuter:kt,scaleOfOuter:Pt}=t.MatrixHelper,{toPoint:Tt}=t.AroundHelper,Ct={},At={};function Mt(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=Et(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,Bt);const h=t.Platform.canvas.createLinearGradient(bt.x,bt.y,Bt.x,Bt.y);Lt(h,e.stops,r);const l={type:o,style:h};return a&&(l.blendMode=a),l},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:h}=e;Tt(n||"center",i,Ct),Tt(s||"bottom",i,At);const l=t.Platform.canvas.createRadialGradient(Ct.x,Ct.y,0,Ct.x,Ct.y,Rt(Ct,At));Lt(l,e.stops,a);const d={type:o,style:l},c=Mt(i,Ct,At,h,!0);return c&&(d.transform=c),r&&(d.blendMode=r),d},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,blendMode:r,stretch:h}=e;Ot(n||"center",i,It),Ot(s||"bottom",i,Dt);const l=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(l,e.stops,a);const d={type:o,style:l},c=Mt(i,It,Dt,h||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),r&&(d.blendMode=r),d},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,Vt={};const qt={shadow:function(t,e,n){let s,o;const{__nowWorld:a,__layout:r}=t,{shadow:h}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:u,scaleY:f}=n,g=e.getSameCanvas(),p=h.length-1;Ft(d,Gt),h.forEach(((h,_)=>{g.setWorldShadow(Gt.offsetX+h.x*u,Gt.offsetY+h.y*f,h.blur*u,i.ColorConvert.string(h.color)),o=h.spread?1+2*h.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ut(g,Gt,o,n),s=d,h.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,d,a,"copy"),s=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(g,s,a,h.blendMode):e.copyWorldToInner(g,s,r.renderBounds,h.blendMode),p&&_<p&&g.clearWorld(s,!0)})),g.recycle(s)},innerShadow:function(t,e,n){let s,o;const{__nowWorld:a,__layout:r}=t,{innerShadow:h}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:u,scaleY:f}=n,g=e.getSameCanvas(),p=h.length-1;Yt(d,Vt),h.forEach(((h,_)=>{g.save(),g.setWorldShadow(Vt.offsetX+h.x*u,Vt.offsetY+h.y*f,h.blur*u),o=h.spread?1-2*h.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ut(g,Vt,o,n),g.restore(),l?(g.copyWorld(g,d,a,"copy"),g.copyWorld(l,a,a,"source-out"),s=a):(g.copyWorld(n.canvas,c,d,"source-out"),s=d),g.fillWorld(s,i.ColorConvert.string(h.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(g,s,a,h.blendMode):e.copyWorldToInner(g,s,r.renderBounds,h.blendMode),p&&_<p&&g.clearWorld(s,!0)})),g.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),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:h}=this;for(let l=0,d=h.length;l<d;l++)i=h[l],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=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)||Nt(i,e)||i.__render(s||t,e);Xt(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:he,Before:le,After:de,Symbol:ce,Break:ue}=ae;function fe(t){return ee[t]?re:oe[t]?ue:ie[t]?le:ne[t]?de:se[t]?ce:Jt.test(t)?he:re}const ge={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:_e}=ge,{Letter:we,Single:me,Before:ye,After:ve,Symbol:xe,Break:be}=ae;let Be,Le,Ee,Re,Se,ke,Pe,Te,Ce,Ae,Me,We,Oe,Ie,De,He,ze,Fe=[];function je(t,e){Ce&&!Te&&(Te=Ce),Be.data.push({char:t,width:e}),Ee+=e}function Ge(){Re+=Ee,Be.width=Ee,Le.words.push(Be),Be={data:[]},Ee=0}function Ue(){Ie&&(De.paraNumber++,Le.paraStart=!0,Ie=!1),Ce&&(Le.startCharSize=Te,Le.endCharSize=Ce,Te=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:Ve,right:qe,bottom:Ne,left:Xe}=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,i){"string"!=typeof e&&(e=String(e));let n=0,s=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:l}=i;l&&(o?(n=l[Xe],o-=l[qe]+l[Xe]):i.autoSizeAlign||(n=l[Xe]),a?(s=l[Ve],a-=l[Ve]+l[Ne]):i.autoSizeAlign||(s=l[Ve]));const d={bounds:{x:n,y:s,width:o,height:a},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:h,height:l}=He;if(h||l||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;Ie=!0,Me=null,Te=Pe=Ce=Ee=Re=0,Be={data:[]},Le={words:[]};for(let n=0,l=i.length;n<l;n++)ke=i[n],"\n"===ke?(Ee&&Ge(),Le.paraEnd=!0,Ue(),Ie=!0):(Ae=fe(ke),Ae===we&&"none"!==a&&(ke=pe(ke,a,!Ee)),Pe=r.measureText(ke).width,s&&(s<0&&(Ce=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?h-o:h,t&&h&&Re+Ee+Pe>Se&&(e?(Ee&&Ge(),Re&&Ue()):(Oe||(Oe=Ae===we&&Me==ve),We||Oe||Ae===be||Ae===ye||Ae===me||Ee+Pe>Se?(Ee&&Ge(),Re&&Ue()):Re&&Ue()))," "===ke&&!0!==Ie&&Re+Ee===0||(Ae===be?(" "===ke&&Ee&&Ge(),je(ke,Pe),Ge()):We||Oe?(Ee&&Ge(),je(ke,Pe)):je(ke,Pe)),Me=Ae);Ee&&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,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Qe(e,"x",t[Xe]);break;case"right":Qe(e,"x",-t[qe])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Qe(e,"y",t[Ve]);break;case"bottom":Qe(e,"y",-t[Ne])}}(l,d,i,o,a),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:o,__baseLine:a,__letterSpacing:r,__clipText:h,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=n,w=o*s+(c?c*(t.paraNumber-1):0),m=a;if(h&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(d){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}m+=g;let y,v,x,b=p||u?p:t.maxWidth;for(let a=0,d=s;a<d;a++){if(y=i[a],y.x=f,y.width<p||y.width>p&&!h)switch(l){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&c&&a>0&&(m+=c),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),h&&p&&p<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=w}(d,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,h,l,d,c,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,u=t.words.length,h=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-l)/(u-1):0,d=a||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===d?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===d?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):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),!h||t.paraEnd&&"both"!==s||i===u-1||(r+=h,t.width+=h)}))),t.words=null)}))}(d,i,o),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,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?t.Platform.canvas.measureText(r).width:0,d=n+s-l;("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],h=e.x+e.width,!(n===i&&h<d));n--){if(h<d&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:r,x:h}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(d,i,n,o),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(d,i),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,qt),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new R(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=R,exports.Layouter=y,exports.LeaferCanvas=n,exports.Picker=B,exports.Renderer=x,exports.Selector=L,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,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};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(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,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:_,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{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){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const 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&&c(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&&d(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)),y.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){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(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 v=t.Debug.get("Renderer");class x{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)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(i.innerName,"---\x3e");try{i.isApp||i.app.emit(t.RenderEvent.CHILD_START,i),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.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=e.includes(this.target.__world),a=new t.Bounds(s);n.save(),o&&!t.Debug.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,o,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,!0),i.restore(),t.Run.end(e)}__render(e,i,n){const s=e.includes(this.target.__world)?{includes:i}:{bounds:e,includes:i};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(n)}renderHitView(t){}renderBoundsView(t){}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(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__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||v.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)}}const{hitRadiusPoint:b}=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||b(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 L{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 y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>new L(t,e)}),t.Platform.layout=y.fullLayout;const E={convertTouch(t,i){const n=E.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 R 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=E.getTouch(t);this.pointerDown(E.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=E.getTouch(t);this.pointerMove(E.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=E.getTouch(t);this.pointerUp(E.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 S(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 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",S(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,e.__.__font?S(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?S(e,n):o?n.fill(o):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),a?S(e,n):o?n.fill(o):n.fill(),n.restoreBlendMode()):a?S(e,n):o?n.fill(o):n.fill())},fillText:S,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:d}=s;if(h<0&&(h=-h),d<0&&(d=-d),e.bounds.includes(s))l=n,o=r=s;else{const{renderShapeSpread:n}=t.__layout,c=I(n?M(e.bounds,h===d?n*h:[n*d,n*h]):e.bounds,s);a=e.bounds.getFitMatrix(c);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),h*=u,d*=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:d}}};let F={};const{get:j,rotateOfOuter:G,translate:Y,scaleOfOuter:U,scale:V,rotate:q}=t.MatrixHelper;function N(t,e,i,n,s,o,a){const r=j();Y(r,e.x+i,e.y+n),V(r,s,o),a&&G(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=j();Y(r,e.x+i,e.y+n),s&&V(r,s,o),a&&q(r,a),t.transform=r}function Q(t,e,i,n,s,o,a,r,l,h){const d=j();if(l)if("center"===h)G(d,{x:i/2,y:n/2},l);else switch(q(d,l),l){case 90:Y(d,n,0);break;case 180:Y(d,i,n);break;case 270:Y(d,0,i)}F.x=e.x+s,F.y=e.y+o,Y(d,F.x,F.y),a&&U(d,F,a,r),t.transform=d}const{get:K,translate:Z}=t.MatrixHelper,$=new t.Bounds,J={},tt={};function et(t,e,i,n){const{blendMode:s,sync:o}=i;s&&(t.blendMode=s),o&&(t.sync=o),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:d,size:c,rotation:u,repeat:f,filters:g}=e,p=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,B=0;if(r&&"cover"!==r&&"fit"!==r)(d||c)&&(t.MathHelper.getScaleData(d,c,n,tt),v=tt.scaleX,x=tt.scaleY);else if(!p||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,B+=(i.height-o*x)/2}if(l){const e={x:b,y:B,width:m,height:y};v&&(e.width*=v,e.height*=x),t.AlignHelper.toPoint(l,e,i,J,!0),b+=J.x,B+=J.y}switch(h&&(b+=h.x,B+=h.y),r){case"stretch":p||(s=i.width,o=i.height);break;case"normal":case"clip":(b||B||v||u)&&X(_,i,b,B,v,x,u);break;case"repeat":(!p||v||u)&&Q(_,i,s,o,b,B,v,x,u,l),f||(_.repeat="repeat");break;default:v&&N(_,i,b,B,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),g&&(_.filters=g),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){dt(e,t.ImageEvent.LOAD,i)}function lt(e,i){dt(e,t.ImageEvent.LOADED,i)}function ht(e,i,n){i.error=n,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,i)}function dt(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:ut,scale:ft,copy:gt}=t.MatrixHelper,{ceil:pt,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:d,height:c,scaleX:u,scaleY:f,transform:g,repeat:p}=r;u&&(h=ut(),gt(h,g),ft(h,1/u,1/f),s*=u,o*=f),s*=n,o*=n,d*=s,c*=o;const _=d*c;if(!p&&_>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,d/=l,c/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(h||(h=ut(),g&&gt(h,g)),ft(h,1/s,1/o));const m=e.getCanvas(pt(d)||1,pt(c)||1,r.opacity,r.filters),y=e.getPattern(m,p||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&&(ct(e,!0),rt(e,r)),a.loadId=l.load((()=>{ct(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=>{ct(e,!1),ht(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;if(!s.data||s.patternId===a+"-"+r+"-"+l&&!i.Export.running)return!1;{const{data:h}=s;if(o)if(h.repeat)o=!1;else{let{width:e,height:n}=h;e*=yt(a)*l,n*=yt(r)*l,h.scaleX&&(e*=h.scaleX,n*=h.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),e.windingRule?n.clip(e.windingRule):n.clip(),s.blendMode&&(n.blendMode=s.blendMode),h.opacity&&(n.opacity*=h.opacity),h.transform&&n.transform(h.transform),n.drawImage(s.image.getFull(h.filters),0,0,h.width,h.height),n.restore(),!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;for(let l=0,h=n.length;l<h;l++)s=n[l].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading?(a||(a=i.__input&&i.__input[e]||[],a instanceof Array||(a=[a])),s.unload(n[l].loadId,!a.some((t=>t.url===r)))):n[l].style=null);return o}return null},createData:et,getPatternData:it,fillOrFitMode:N,clipMode:X,repeatMode:Q},{toPoint:xt}=t.AroundHelper,bt={},Bt={};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:Et,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=Et(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,Bt);const l=t.Platform.canvas.createLinearGradient(bt.x,bt.y,Bt.x,Bt.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 d={type:o,style:h},c=Mt(i,Tt,At,l,!0);return c&&(d.transform=c),r&&(d.blendMode=r),d},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 d={type:o,style:h},c=Mt(i,It,Dt,l||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),r&&(d.blendMode=r),d},getTransform:Mt},{copy:zt,toOffsetOutBounds:Ft}=t.BoundsHelper,jt={},Gt={};function Yt(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:Ut}=t.BoundsHelper,Vt={};const qt={shadow:function(t,e,n){let s,o;const{__nowWorld:a,__layout:r}=t,{shadow:l}=t.__,{worldCanvas:h,bounds:d,shapeBounds:c,scaleX:u,scaleY:f}=n,g=e.getSameCanvas(),p=l.length-1;Ft(d,Gt),l.forEach(((l,_)=>{g.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,Yt(g,Gt,o,n),s=d,l.box&&(g.restore(),g.save(),h&&(g.copyWorld(g,d,a,"copy"),s=a),h?g.copyWorld(h,a,a,"destination-out"):g.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(g,s,a,l.blendMode):e.copyWorldToInner(g,s,r.renderBounds,l.blendMode),p&&_<p&&g.clearWorld(s,!0)})),g.recycle(s)},innerShadow:function(t,e,n){let s,o;const{__nowWorld:a,__layout:r}=t,{innerShadow:l}=t.__,{worldCanvas:h,bounds:d,shapeBounds:c,scaleX:u,scaleY:f}=n,g=e.getSameCanvas(),p=l.length-1;Ut(d,Vt),l.forEach(((l,_)=>{g.save(),g.setWorldShadow(Vt.offsetX+l.x*u,Vt.offsetY+l.y*f,l.blur*u),o=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Yt(g,Vt,o,n),g.restore(),h?(g.copyWorld(g,d,a,"copy"),g.copyWorld(h,a,a,"source-out"),s=a):(g.copyWorld(n.canvas,c,d,"source-out"),s=d),g.fillWorld(s,i.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(g,s,a,l.blendMode):e.copyWorldToInner(g,s,r.renderBounds,l.blendMode),p&&_<p&&g.clearWorld(s,!0)})),g.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),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,d=l.length;h<d;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=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)||Nt(i,e)||i.__render(s||t,e);Xt(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:de,Symbol:ce,Break:ue}=ae;function fe(t){return ee[t]?re:oe[t]?ue:ie[t]?he:ne[t]?de:se[t]?ce:Jt.test(t)?le:re}const ge={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:_e}=ge,{Letter:we,Single:me,Before:ye,After:ve,Symbol:xe,Break:be}=ae;let Be,Le,Ee,Re,Se,ke,Pe,Ce,Te,Ae,Me,We,Oe,Ie,De,He,ze,Fe=[];function je(t,e){Te&&!Ce&&(Ce=Te),Be.data.push({char:t,width:e}),Ee+=e}function Ge(){Re+=Ee,Be.width=Ee,Le.words.push(Be),Be={data:[]},Ee=0}function Ye(){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&&Ue(),Fe.push(Le),Le={words:[]},Re=0}function Ue(){Re>(De.maxWidth||0)&&(De.maxWidth=Re)}const{top:Ve,right:qe,bottom:Ne,left:Xe}=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:d}=n;d&&(a?(s=d[Xe],a-=d[qe]+d[Xe]):n.autoSizeAlign||(s=d[Xe]),r?(o=d[Ve],r-=d[Ve]+d[Ne]):n.autoSizeAlign||(o=d[Ve]));const c={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=Ee=Re=0,Be={data:[]},Le={words:[]};for(let n=0,h=i.length;n<h;n++)ke=i[n],"\n"===ke?(Ee&&Ge(),Le.paraEnd=!0,Ye(),Ie=!0):(Ae=fe(ke),Ae===we&&"none"!==a&&(ke=pe(ke,a,!Ee)),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+Ee+Pe>Se&&(e?(Ee&&Ge(),Re&&Ye()):(Oe||(Oe=Ae===we&&Me==ve),We||Oe||Ae===be||Ae===ye||Ae===me||Ee+Pe>Se?(Ee&&Ge(),Re&&Ye()):Re&&Ye()))," "===ke&&!0!==Ie&&Re+Ee===0||(Ae===be?(" "===ke&&Ee&&Ge(),je(ke,Pe),Ge()):We||Oe?(Ee&&Ge(),je(ke,Pe)):je(ke,Pe)),Me=Ae);Ee&&Ge(),Re&&Ye(),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&&Ue()}))}(c,e,n),d&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Qe(e,"x",t[Xe]);break;case"right":Qe(e,"x",-t[qe])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Qe(e,"y",t[Ve]);break;case"bottom":Qe(e,"y",-t[Ne])}}(d,c,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:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=n,w=o*s+(c?c*(t.paraNumber-1):0),m=a;if(l&&w>_)w=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(d){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}m+=g;let y,v,x,b=p||u?p:t.maxWidth;for(let a=0,d=s;a<d;a++){if(y=i[a],y.x=f,y.width<p||y.width>p&&!l)switch(h){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&c&&a>0&&(m+=c),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&&p&&p<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=g,n.height=w}(c,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:o,letterSpacing:a}=e;let r,l,h,d,c,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,d=a||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!a&&(t.textMode=!0),2===d?(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===d?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):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)}))}(c,n,a),c.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,d=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<d));n--){if(l<d&&" "!==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)}}))}}(c,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]}}(c,n),c}};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,qt),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new R(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=R,exports.Layouter=y,exports.LeaferCanvas=n,exports.Picker=B,exports.Renderer=x,exports.Selector=L,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