@leafer-ui/miniapp 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniapp.cjs +171 -172
- package/dist/miniapp.esm.js +175 -176
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +536 -408
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +12 -12
package/dist/miniapp.min.cjs
CHANGED
|
@@ -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,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]}})}));
|
|
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=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:l,updateBounds: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,m=t.Debug.get("Layouter");class w{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){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&&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)),w.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(){this.__eventIds=[this.target.on_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,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(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}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 w(t,e),renderer:(t,e,i)=>new v(t,e,i),selector:(t,e)=>new E(t,e)}),t.Platform.layout=w.fullLayout;const B={convertTouch(t,i){const n=B.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 L 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=B.getTouch(t);this.pointerDown(B.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=B.getTouch(t);this.pointerMove(B.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=B.getTouch(t);this.pointerUp(B.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()}const k={};function P(t,e,i){switch(e.__.strokeAlign){case"center":T(t,1,e,i);break;case"inside":C(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?T(t,2,e,i):C(t,"outside",e,i)}}function T(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?M(t,!0,i,n):A(i,n)}function C(t,i,n,s){const o=s.getSameCanvas(!0,!0);o.font=n.__.__font,T(t,2,n,o),o.blendMode="outside"===i?"destination-out":"destination-in",R(n,o),o.blendMode="normal",n.__worldFlipped||e.Platform.fullImageShadow?s.copyWorldByReset(o,n.__nowWorld):s.copyWorldToInner(o,n.__nowWorld,n.__layout.renderBounds),o.recycle(n.__nowWorld)}function A(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 M(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?A(n,s):s.stroke(),s.restoreBlendMode()):e?A(n,s):s.stroke())}function W(t,i,n){const s=i.__;if(s.__strokeWidth)if(s.__font)P(t,i,n);else switch(s.strokeAlign){case"center":O(t,1,i,n);break;case"inside":!function(t,e,i){const n=e.__;i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),O(t,2,e,i),i.restore()}(t,i,n);break;case"outside":!function(t,i,n){const s=i.__;if(s.__fillAfterStroke)O(t,2,i,n);else{const{renderBounds:o}=i.__layout,a=n.getSameCanvas(!0,!0);i.__drawRenderPath(a),O(t,2,i,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),i.__worldFlipped||e.Platform.fullImageShadow?n.copyWorldByReset(a,i.__nowWorld):n.copyWorldToInner(a,i.__nowWorld,o),a.recycle(i.__nowWorld)}}(t,i,n)}}function O(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.__strokeWidth*e,s),s.__isStrokes?M(t,!1,i,n):n.stroke(),s.__useArrow&&k.strokeArrow(t,i,n)}const{getSpread:I,getOuterOf:D,getByMove:H,getIntersectData:z}=t.BoundsHelper;let F;const{stintSet:j}=t.DataHelper,{hasTransparent:G}=i.ColorConvert;function U(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:o}=n.__layout;switch(e.type){case"image":s=i.PaintImage.image(n,t,e,o,!F||!F[e.url]);break;case"linear":s=i.PaintGradient.linearGradient(e,o);break;case"radial":s=i.PaintGradient.radialGradient(e,o);break;case"angular":s=i.PaintGradient.conicGradient(e,o);break;case"solid":const{type:a,blendMode:r,color:l,opacity:h}=e;s={type:a,blendMode:r,style:i.ColorConvert.string(l,h)};break;default:void 0!==e.r&&(s={type:"solid",style:i.ColorConvert.string(e)})}return s&&("string"==typeof s.style&&G(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const Y={compute:function(t,e){const n=e.__,s=[];let o,a,r=n.__input[t];r instanceof Array||(r=[r]),F=i.PaintImage.recycleImage(t,n);for(let i,n=0,o=r.length;n<o;n++)i=U(t,r[n],e),i&&s.push(i);n["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(o=!0),a=!0),"fill"===t?(j(n,"__isAlphaPixelFill",o),j(n,"__isTransparentFill",a)):(j(n,"__isAlphaPixelStroke",o),j(n,"__isTransparentStroke",a))},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:W,strokes:function(t,e,i){W(t,e,i)},strokeText:P,drawTextStroke:A,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=z(n?I(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=D(s,a),o=H(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 q={};const{get:N,rotateOfOuter:X,translate:V,scaleOfOuter:Q,scale:K,rotate:Z}=t.MatrixHelper;function $(t,e,i,n,s,o,a){const r=N();V(r,e.x+i,e.y+n),K(r,s,o),a&&X(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function J(t,e,i,n,s,o,a){const r=N();V(r,e.x+i,e.y+n),s&&K(r,s,o),a&&Z(r,a),t.transform=r}function tt(t,e,i,n,s,o,a,r,l,h){const c=N();if(l)if("center"===h)X(c,{x:i/2,y:n/2},l);else switch(Z(c,l),l){case 90:V(c,n,0);break;case 180:V(c,i,n);break;case 270:V(c,0,i)}q.x=e.x+s,q.y=e.y+o,V(c,q.x,q.y),a&&Q(c,q,a,r),t.transform=c}const{get:et,translate:it}=t.MatrixHelper,nt=new t.Bounds,st={},ot={};function at(t,e,i,n){const{changeful:s,sync:o}=i;s&&(t.changeful=s),o&&(t.sync=o),t.data=rt(i,n,e)}function rt(e,i,n){e.padding&&(i=nt.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:o}=n;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},m="center"!==l&&(u||0)%180==90;let w,y;switch(t.BoundsHelper.set(ot,0,0,m?o:s,m?s:o),r&&"cover"!==r&&"fit"!==r?((c||d)&&(t.MathHelper.getScaleData(c,d,n,st),w=st.scaleX,y=st.scaleY),l&&(w&&t.BoundsHelper.scale(ot,w,y,!0),t.AlignHelper.toPoint(l,ot,i,ot,!0,!0))):g&&!u||(w=y=t.BoundsHelper.getFitScale(i,ot,"fit"!==r),t.BoundsHelper.put(i,n,l,w,!1,ot),t.BoundsHelper.scale(ot,w,y,!0)),h&&t.PointHelper.move(ot,h),r){case"stretch":g||(s=i.width,o=i.height);break;case"normal":case"clip":(ot.x||ot.y||w||u)&&J(_,i,ot.x,ot.y,w,y,u);break;case"repeat":(!g||w||u)&&tt(_,i,s,o,ot.x,ot.y,w,y,u,l),f||(_.repeat="repeat");break;default:w&&$(_,i,ot.x,ot.y,w,y,u)}return _.transform||(i.x||i.y)&&(_.transform=et(),it(_.transform,i.x,i.y)),w&&"stretch"!==r&&(_.scaleX=w,_.scaleY=y),_.width=s,_.height=o,a&&(_.opacity=a),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let lt,ht=new t.Bounds;const{isSame:ct}=t.BoundsHelper;function dt(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||at(s,n,i,o),!0}function ut(e,i){gt(e,t.ImageEvent.LOAD,i)}function ft(e,i){gt(e,t.ImageEvent.LOADED,i)}function pt(e,i,n){i.error=n,e.forceUpdate("surface"),gt(e,t.ImageEvent.ERROR,i)}function gt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function _t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:mt,scale:wt,copy:yt}=t.MatrixHelper,{ceil:vt,abs:xt}=Math;function bt(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=xt(s),o=xt(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=mt(),yt(h,p),wt(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 m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}_>m&&(l=Math.sqrt(_/m)),l&&(s/=l,o/=l,c/=l,d/=l),u&&(s/=u,o/=f),(p||1!==s||1!==o)&&(h||(h=mt(),p&&yt(h,p)),wt(h,1/s,1/o));const w=e.getCanvas(vt(c)||1,vt(d)||1,r.opacity,r.filters),y=e.getPattern(w,g||t.Platform.origin.noRepeat||"no-repeat",h,i);return i.style=y,i.patternId=a,!0}}function Et(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:Bt}=Math;const Lt={image:function(e,i,n,s,o){let a,r;const l=t.ImageManager.get(n);return lt&&n===lt.paint&&ct(s,lt.boxBounds)?a=lt.leafPaint:(a={type:n.type,image:l},l.hasAlphaPixel&&(a.isTransparent=!0),lt=l.use>1?{leafPaint:a,paint:n,boxBounds:ht.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:i,attrValue:n}),l.ready?(dt(e,i,n,l,a,s),o&&(ut(e,r),ft(e,r))):l.error?o&&pt(e,r,l.error):(o&&(_t(e,!0),ut(e,r)),a.loadId=l.load((()=>{_t(e,!1),e.destroyed||(dt(e,i,n,l,a,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ft(e,r)),a.loadId=null}),(t=>{_t(e,!1),pt(e,r,t),a.loadId=null})),e.placeholderColor&&(e.placeholderDelay?setTimeout((()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))}),e.placeholderDelay):l.isPlacehold=!0)),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*=Bt(a)*l,i*=Bt(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?bt(e,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>Et(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&bt(e,s,l),e.forceUpdate("surface")}))),300)),!1)},createPattern:bt,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:at,getPatternData:rt,fillOrFitMode:$,clipMode:J,repeatMode:tt},{toPoint:Rt}=t.AroundHelper,{hasTransparent:St}=i.ColorConvert,kt={},Pt={};function Tt(t,e,n,s){if(n){let o,a,r,l;for(let t=0,h=n.length;t<h;t++)o=n[t],"string"==typeof o?(r=t/(h-1),a=i.ColorConvert.string(o,s)):(r=o.offset,a=i.ColorConvert.string(o.color,s)),e.addColorStop(r,a),!l&&St(a)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:Ct,getDistance:At}=t.PointHelper,{get:Mt,rotateOfOuter:Wt,scaleOfOuter:Ot}=t.MatrixHelper,{toPoint:It}=t.AroundHelper,Dt={},Ht={};function zt(t,e,i,n,s){let o;const{width:a,height:r}=t;if(a!==r||n){const t=Ct(e,i);o=Mt(),s?(Ot(o,e,a/r*(n||1),1),Wt(o,e,t+90)):(Ot(o,e,1,a/r*(n||1)),Wt(o,e,t))}return o}const{getDistance:Ft}=t.PointHelper,{toPoint:jt}=t.AroundHelper,Gt={},Ut={};const Yt={linearGradient:function(e,i){let{from:n,to:s,type:o,opacity:a}=e;Rt(n||"top",i,kt),Rt(s||"bottom",i,Pt);const r=t.Platform.canvas.createLinearGradient(kt.x,kt.y,Pt.x,Pt.y),l={type:o,style:r};return Tt(l,r,e.stops,a),l},radialGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,stretch:r}=e;It(n||"center",i,Dt),It(s||"bottom",i,Ht);const l=t.Platform.canvas.createRadialGradient(Dt.x,Dt.y,0,Dt.x,Dt.y,At(Dt,Ht)),h={type:o,style:l};Tt(h,l,e.stops,a);const c=zt(i,Dt,Ht,r,!0);return c&&(h.transform=c),h},conicGradient:function(e,i){let{from:n,to:s,type:o,opacity:a,stretch:r}=e;jt(n||"center",i,Gt),jt(s||"bottom",i,Ut);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Gt.x,Gt.y):t.Platform.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,Ft(Gt,Ut)),h={type:o,style:l};Tt(h,l,e.stops,a);const c=zt(i,Gt,Ut,r||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),h},getTransform:zt},{copy:qt,toOffsetOutBounds:Nt}=t.BoundsHelper,Xt={},Vt={};function Qt(e,i,n,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(qt(Xt,e.bounds),Xt.x+=i.x-a.x,Xt.y+=i.y-a.y,n){const{matrix:t}=s;Xt.x-=(o.x+(t?t.e:0)+o.width/2)*(n-1),Xt.y-=(o.y+(t?t.f:0)+o.height/2)*(n-1),Xt.width*=n,Xt.height*=n}e.copyWorld(s.canvas,e.bounds,Xt)}else n&&(qt(Xt,i),Xt.x-=i.width/2*(n-1),Xt.y-=i.height/2*(n-1),Xt.width*=n,Xt.height*=n),e.copyWorld(s.canvas,a,n?Xt:i)}const{toOffsetOutBounds:Kt}=t.BoundsHelper,Zt={};const $t={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;Nt(c,Vt),l.forEach(((l,_)=>{p.setWorldShadow(Vt.offsetX+l.x*u,Vt.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,Qt(p,Vt,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;Kt(c,Zt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Zt.offsetX+l.x*u,Zt.offsetY+l.y*f,l.blur*u),o=l.spread?1-2*l.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Qt(p,Zt,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:Jt}=t.LeafBoundsHelper;function te(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),ie(t,e,i,1)}(t,i,n,s);break;case"opacity-path":ie(t,i,n,o);break;case"path":i.restore()}}function ee(t){return t.getSameCanvas(!1,!0)}function ie(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&&(te(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=ee(t))):(a="path",t.save()),i.__clip(s||t,e)):(a="grayscale"===r?"grayscale":"alpha",n||(n=ee(t)),s||(s=ee(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Jt(i,e)||i.__render(s||t,e);te(this,a,t,s,n,o)};const ne=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",se=ne+"_#~&*+\\=|≮≯≈≠=…",oe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ae(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const re=ae("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),le=ae("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),he=ae(ne),ce=ae(se),de=ae("- —/~|┆·");var ue;!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"}(ue||(ue={}));const{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:me,Break:we}=ue;function ye(t){return re[t]?fe:de[t]?we:le[t]?ge:he[t]?_e:ce[t]?me:oe.test(t)?pe:fe}const ve={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 xe(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:be}=ve,{Letter:Ee,Single:Be,Before:Le,After:Re,Symbol:Se,Break:ke}=ue;let Pe,Te,Ce,Ae,Me,We,Oe,Ie,De,He,ze,Fe,je,Ge,Ue,Ye,qe,Ne=[];function Xe(t,e){De&&!Ie&&(Ie=De),Pe.data.push({char:t,width:e}),Ce+=e}function Ve(){Ae+=Ce,Pe.width=Ce,Te.words.push(Pe),Pe={data:[]},Ce=0}function Qe(){Ge&&(Ue.paraNumber++,Te.paraStart=!0,Ge=!1),De&&(Te.startCharSize=Ie,Te.endCharSize=De,Ie=0),Te.width=Ae,Ye.width?be(Te):qe&&Ke(),Ne.push(Te),Te={words:[]},Ae=0}function Ke(){Ae>(Ue.maxWidth||0)&&(Ue.maxWidth=Ae)}const{top:Ze,right:$e,bottom:Je,left:ti}=t.Direction4;function ei(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 ii={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[ti],a-=c[$e]+c[ti]):n.autoSizeAlign||(s=c[ti]),r?(o=c[Ze],r-=c[Ze]+c[Je]):n.autoSizeAlign||(o=c[Ze]));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){Ue=e,Ne=e.rows,Ye=e.bounds,qe=!Ye.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=n,{canvas:r}=t.Platform,{width:l,height:h}=Ye;if(l||h||s||"none"!==a){const t="none"!==n.textWrap,e="break"===n.textWrap;Ge=!0,ze=null,Ie=Oe=De=Ce=Ae=0,Pe={data:[]},Te={words:[]},s&&(i=[...i]);for(let n=0,h=i.length;n<h;n++)We=i[n],"\n"===We?(Ce&&Ve(),Te.paraEnd=!0,Qe(),Ge=!0):(He=ye(We),He===Ee&&"none"!==a&&(We=xe(We,a,!Ce)),Oe=r.measureText(We).width,s&&(s<0&&(De=Oe),Oe+=s),Fe=He===Be&&(ze===Be||ze===Ee)||ze===Be&&He!==Re,je=!(He!==Le&&He!==Be||ze!==Se&&ze!==Re),Me=Ge&&o?l-o:l,t&&l&&Ae+Ce+Oe>Me&&(e?(Ce&&Ve(),Ae&&Qe()):(je||(je=He===Ee&&ze==Re),Fe||je||He===ke||He===Le||He===Be||Ce+Oe>Me?(Ce&&Ve(),Ae&&Qe()):Ae&&Qe()))," "===We&&!0!==Ge&&Ae+Ce===0||(He===ke?(" "===We&&Ce&&Ve(),Xe(We,Oe),Ve()):Fe||je?(Ce&&Ve(),Xe(We,Oe)):Xe(We,Oe)),ze=He);Ce&&Ve(),Ae&&Qe(),Ne.length>0&&(Ne[Ne.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ue.paraNumber++,Ae=r.measureText(t).width,Ne.push({x:o||0,text:t,width:Ae,paraStart:!0}),qe&&Ke()}))}(d,e,n),c&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ei(e,"x",t[ti]);break;case"right":ei(e,"x",-t[$e])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ei(e,"y",t[Ze]);break;case"bottom":ei(e,"y",-t[Je])}}(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,m=o*s+(d?d*(t.paraNumber-1):0),w=a;if(l&&m>_)m=Math.max(_,o),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let 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&&(w+=d),y.y=w,w+=o,t.overflow>a&&w>m&&(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=m}(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 ni={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,ii),Object.assign(i.ColorConvert,ni),Object.assign(i.Paint,Y),Object.assign(i.PaintImage,Lt),Object.assign(i.PaintGradient,Yt),Object.assign(i.Effect,$t),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new L(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=L,exports.Layouter=w,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
|