@leafer-ui/miniapp 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniapp.cjs +13 -12
- package/dist/miniapp.esm.js +13 -12
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.module.js +130 -360
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +10 -10
package/dist/miniapp.cjs
CHANGED
|
@@ -587,25 +587,25 @@ class Renderer {
|
|
|
587
587
|
if (userConfig)
|
|
588
588
|
this.config = core.DataHelper.default(userConfig, this.config);
|
|
589
589
|
this.__listenEvents();
|
|
590
|
-
this.__requestRender();
|
|
591
590
|
}
|
|
592
591
|
start() {
|
|
593
592
|
this.running = true;
|
|
593
|
+
this.update(false);
|
|
594
594
|
}
|
|
595
595
|
stop() {
|
|
596
596
|
this.running = false;
|
|
597
597
|
}
|
|
598
|
-
update() {
|
|
599
|
-
this.changed
|
|
598
|
+
update(change = true) {
|
|
599
|
+
if (!this.changed)
|
|
600
|
+
this.changed = change;
|
|
601
|
+
this.__requestRender();
|
|
600
602
|
}
|
|
601
603
|
requestLayout() {
|
|
602
604
|
this.target.emit(core.LayoutEvent.REQUEST);
|
|
603
605
|
}
|
|
604
606
|
render(callback) {
|
|
605
|
-
if (!(this.running && this.canvas.view))
|
|
606
|
-
this.
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
607
|
+
if (!(this.running && this.canvas.view))
|
|
608
|
+
return this.update();
|
|
609
609
|
const { target } = this;
|
|
610
610
|
this.times = 0;
|
|
611
611
|
this.totalBounds = new core.Bounds();
|
|
@@ -739,16 +739,17 @@ class Renderer {
|
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
741
|
__requestRender() {
|
|
742
|
-
|
|
742
|
+
if (this.requestTime)
|
|
743
|
+
return;
|
|
744
|
+
const requestTime = this.requestTime = Date.now();
|
|
743
745
|
core.Platform.requestRender(() => {
|
|
744
|
-
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() -
|
|
746
|
+
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
747
|
+
this.requestTime = 0;
|
|
745
748
|
if (this.running) {
|
|
746
749
|
if (this.changed && this.canvas.view)
|
|
747
750
|
this.render();
|
|
748
751
|
this.target.emit(core.RenderEvent.NEXT);
|
|
749
752
|
}
|
|
750
|
-
if (this.target)
|
|
751
|
-
this.__requestRender();
|
|
752
753
|
});
|
|
753
754
|
}
|
|
754
755
|
__onResize(e) {
|
|
@@ -764,7 +765,7 @@ class Renderer {
|
|
|
764
765
|
}
|
|
765
766
|
}
|
|
766
767
|
this.addBlock(new core.Bounds(0, 0, 1, 1));
|
|
767
|
-
this.
|
|
768
|
+
this.update();
|
|
768
769
|
}
|
|
769
770
|
__onLayoutEnd(event) {
|
|
770
771
|
if (event.data)
|
package/dist/miniapp.esm.js
CHANGED
|
@@ -588,25 +588,25 @@ class Renderer {
|
|
|
588
588
|
if (userConfig)
|
|
589
589
|
this.config = DataHelper.default(userConfig, this.config);
|
|
590
590
|
this.__listenEvents();
|
|
591
|
-
this.__requestRender();
|
|
592
591
|
}
|
|
593
592
|
start() {
|
|
594
593
|
this.running = true;
|
|
594
|
+
this.update(false);
|
|
595
595
|
}
|
|
596
596
|
stop() {
|
|
597
597
|
this.running = false;
|
|
598
598
|
}
|
|
599
|
-
update() {
|
|
600
|
-
this.changed
|
|
599
|
+
update(change = true) {
|
|
600
|
+
if (!this.changed)
|
|
601
|
+
this.changed = change;
|
|
602
|
+
this.__requestRender();
|
|
601
603
|
}
|
|
602
604
|
requestLayout() {
|
|
603
605
|
this.target.emit(LayoutEvent.REQUEST);
|
|
604
606
|
}
|
|
605
607
|
render(callback) {
|
|
606
|
-
if (!(this.running && this.canvas.view))
|
|
607
|
-
this.
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
608
|
+
if (!(this.running && this.canvas.view))
|
|
609
|
+
return this.update();
|
|
610
610
|
const { target } = this;
|
|
611
611
|
this.times = 0;
|
|
612
612
|
this.totalBounds = new Bounds();
|
|
@@ -740,16 +740,17 @@ class Renderer {
|
|
|
740
740
|
}
|
|
741
741
|
}
|
|
742
742
|
__requestRender() {
|
|
743
|
-
|
|
743
|
+
if (this.requestTime)
|
|
744
|
+
return;
|
|
745
|
+
const requestTime = this.requestTime = Date.now();
|
|
744
746
|
Platform.requestRender(() => {
|
|
745
|
-
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() -
|
|
747
|
+
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
748
|
+
this.requestTime = 0;
|
|
746
749
|
if (this.running) {
|
|
747
750
|
if (this.changed && this.canvas.view)
|
|
748
751
|
this.render();
|
|
749
752
|
this.target.emit(RenderEvent.NEXT);
|
|
750
753
|
}
|
|
751
|
-
if (this.target)
|
|
752
|
-
this.__requestRender();
|
|
753
754
|
});
|
|
754
755
|
}
|
|
755
756
|
__onResize(e) {
|
|
@@ -765,7 +766,7 @@ class Renderer {
|
|
|
765
766
|
}
|
|
766
767
|
}
|
|
767
768
|
this.addBlock(new Bounds(0, 0, 1, 1));
|
|
768
|
-
this.
|
|
769
|
+
this.update();
|
|
769
770
|
}
|
|
770
771
|
__onLayoutEnd(event) {
|
|
771
772
|
if (event.data)
|
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as h,FileHelper as d,LeafList as l,RenderEvent as c,ChildEvent as u,WatchEvent as g,PropertyEvent as f,LeafHelper as p,BranchHelper as _,Bounds as w,LeafBoundsHelper as m,Debug as y,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as R,Answer as S,MatrixHelper as k,MathHelper as L,AlignHelper as E,ImageEvent as T,AroundHelper as A,PointHelper as M,Direction4 as C,TwoPointBoundsHelper as W,TaskProcessor as O,Matrix as P}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as I,InteractionBase as D,HitCanvasManager as F}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as z,ColorConvert as N,PaintGradient as Y,Export as U,Group as V,TextConvert as X,Paint as j,Effect as G,Leafer as H}from"@leafer-ui/draw";class q extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:s,height:n,pixelRatio:o}=this.config,a={width:s||t.width,height:n||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__))}__createView(){this.view=e.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(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:Q,fileType:J}=d;function K(t,i){e.origin={createCanvas:(t,e,s)=>{const n={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(n):i.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(Q(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(Q(J(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s}),n()})):n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.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:s=>{s.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)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new q(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},h(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class Z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new l;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new l,this.target=t,e&&(this.config=s.default(e,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(c.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.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 g(g.DATA,{updatedList:this.updatedList})),this.__updatedList=new l,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(g.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:$,updateBounds:tt,updateAllWorldOpacity:et}=p,{pushAllChildBranch:it,pushAllParent:st}=_;const{worldBounds:nt}=m,ot={x:0,y:0,width:1e5,height:1e5};class at{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new l(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,nt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(ot):this.afterBounds.setListWithFn(t,nt),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:rt,updateAllChange:ht}=p,dt=y.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.default(e,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:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(g.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,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?($(t,!0),e.add(t),t.isBranch&&it(t,e),st(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),st(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||tt(s[t])}tt(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&et(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new l(e));e.emitEvent(new x(i,o,this.times)),lt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?_.updateBounds(t):p.updateBounds(t),ht(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new at([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new at(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:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(g.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=y.get("Renderer");class ut{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new w,ct.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(c.CHILD_START,e),this.emitRender(c.START),this.renderOnce(t),this.emitRender(c.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new w,this.renderOptions={},t)this.emitRender(c.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(c.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(c.RENDER,this.renderBounds,this.renderOptions),this.emitRender(c.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;if(!e)return ct.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new w(s);i.save(),n&&!y.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),y.showHitView&&this.renderHitView(s),y.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(c.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new w(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new w(0,0,1,1)),this.changed=!0}}__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||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new c(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(c.AGAIN,this.renderAgain,this),t.on_(o.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:gt}=R;class ft{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new l(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,r=this.getBestMatchLeaf(a,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target:r}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new l;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||p.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new l;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new l;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new l,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||gt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.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()}}const{Yes:pt,NoAndSkip:_t,YesAndSkip:wt}=S,mt={},yt={},vt={};class xt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=s.default(e,this.config)),this.picker=new ft(t,this),t&&this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const o=this.getByInnerId(t,e);return i?o:o?[o]:[];case"string":switch(t[0]){case"#":mt.id=t.substring(1),t=mt;break;case".":yt.className=t.substring(1),t=yt;break;default:vt.tag=t,t=vt}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:n}=t,o=n instanceof Array;return this.getByMethod(o?this.methods.tags:this.methods.tag,e,i,o?s.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,s){return"node"===e.name&&this.target&&this.target.emit(x.CHECK_UPDATE),this.picker.getByPoint(t,i,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&p.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let a=0,r=t.length;a<r;a++){if(n=t[a],o=e(n,s),o===pt||o===wt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<_t&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(u.REMOVE,this.__onRemoveChild,this),this.target.on_(f.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(a,{watcher:(t,e)=>new Z(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>new xt(t,e)}),e.layout=lt.fullLayout;const bt={convertTouch(t,e){const i=bt.getTouch(t),s=I.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class Bt extends D{__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=bt.getTouch(t);this.pointerDown(bt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=bt.getTouch(t);this.pointerMove(bt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=bt.getTouch(t);this.pointerUp(bt.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 e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(I.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function Rt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function St(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Et(t,!0,e,i):Lt(e,i);break;case"inside":kt("inside",t,n,e,i);break;case"outside":kt("outside",t,n,e,i)}}function kt(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?Et(e,!0,s,r):Lt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",Rt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function Lt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Et(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&z.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Lt(i,s):s.stroke(),s.restoreBlendMode()):e?Lt(i,s):s.stroke())}function Tt(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:At,getOuterOf:Mt,getByMove:Ct,getIntersectData:Wt}=R;let Ot;function Pt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:a,opacity:r}=e;return{type:n,blendMode:o,style:N.string(a,r)};case"image":return z.image(i,t,e,s,!Ot||!Ot[e.url]);case"linear":return Y.linearGradient(e,s);case"radial":return Y.radialGradient(e,s);case"angular":return Y.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:N.string(e)}:void 0}}const It={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Ot=z.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=Pt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?Rt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&z.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?Rt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?Rt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?Rt(e,i):n?i.fill(n):i.fill())},fillText:Rt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)St(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&Tt(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.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 s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)St(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Et(t,!1,e,i),s.__useArrow&&Tt(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Et(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*n,s),Et(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:St,drawTextStroke:Lt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:d,scaleY:l}=n;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,c=Wt(s?At(e.bounds,d===l?s*d:[s*l,s*d]):e.bounds,n);a=e.bounds.getFitMatrix(c);let{a:u,d:g}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),d*=u,l*=g),r=Mt(n,a),o=Ct(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,g*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,g)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:d,scaleY:l}}};let Dt={};const{get:Ft,rotateOfOuter:zt,translate:Nt,scaleOfOuter:Yt,scale:Ut,rotate:Vt}=k;function Xt(t,e,i,s,n,o,a){const r=Ft();Nt(r,e.x+i,e.y+s),Ut(r,n,o),a&&zt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function jt(t,e,i,s,n,o,a){const r=Ft();Nt(r,e.x+i,e.y+s),n&&Ut(r,n,o),a&&Vt(r,a),t.transform=r}function Gt(t,e,i,s,n,o,a,r,h,d){const l=Ft();if(h)if("center"===d)zt(l,{x:i/2,y:s/2},h);else switch(Vt(l,h),h){case 90:Nt(l,s,0);break;case 180:Nt(l,i,s);break;case 270:Nt(l,0,i)}Dt.x=e.x+n,Dt.y=e.y+o,Nt(l,Dt.x,Dt.y),a&&Yt(l,Dt,a,r),t.transform=l}const{get:Ht,translate:qt}=k,Qt=new w,Jt={},Kt={};function Zt(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=$t(i,s,e)}function $t(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:h,scale:d,size:l,rotation:c,repeat:u}=t,g=e.width===s&&e.height===n,f={mode:a},p="center"!==r&&(c||0)%180==90,_=p?n:s,w=p?s:n;let m,y,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(d||l)&&(L.getScaleData(d,l,i,Kt),m=Kt.scaleX,y=Kt.scaleY);else if(!g||c){const t=e.width/_,i=e.height/w;m=y="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-s*m)/2,x+=(e.height-n*y)/2}if(r){const t={x:v,y:x,width:_,height:w};m&&(t.width*=m,t.height*=y),E.toPoint(r,t,e,Jt,!0),v+=Jt.x,x+=Jt.y}switch(h&&(v+=h.x,x+=h.y),a){case"stretch":g||(s=e.width,n=e.height);break;case"normal":case"clip":(v||x||m||c)&&jt(f,e,v,x,m,y,c);break;case"repeat":(!g||m||c)&&Gt(f,e,s,n,v,x,m,y,c,r),u||(f.repeat="repeat");break;default:m&&Xt(f,e,v,x,m,y,c)}return f.transform||(e.x||e.y)&&(f.transform=Ht(),qt(f.transform,e.x,e.y)),m&&"stretch"!==a&&(f.scaleX=m,f.scaleY=y),f.width=s,f.height=n,o&&(f.opacity=o),u&&(f.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),f}let te,ee=new w;const{isSame:ie}=R;function se(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Zt(n,s,i,o),!0}function ne(t,e){re(t,T.LOAD,e)}function oe(t,e){re(t,T.LOADED,e)}function ae(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,T.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new T(e,i))}function he(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:de,scale:le,copy:ce}=k,{ceil:ue,abs:ge}=Math;function fe(t,i,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(i.patternId===a||t.destroyed)return!1;{n=ge(n),o=ge(o);const{image:t,data:r}=i;let h,d,{width:l,height:c,scaleX:u,scaleY:g,opacity:f,transform:p,repeat:_}=r;u&&(d=de(),ce(d,p),le(d,1/u,1/g),n*=u,o*=g),n*=s,o*=s,l*=n,c*=o;const w=l*c;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}w>m&&(h=Math.sqrt(w/m)),h&&(n/=h,o/=h,l/=h,c/=h),u&&(n/=u,o/=g),(p||1!==n||1!==o)&&(d||(d=de(),p&&ce(d,p)),le(d,1/n,1/o));const y=t.getCanvas(ue(l)||1,ue(c)||1,f),v=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=v,i.patternId=a,!0}}function pe(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function r(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:_e}=Math;const we={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return te&&i===te.paint&&ie(s,te.boxBounds)?o=te.leafPaint:(o={type:i.type,image:r},te=r.use>1?{leafPaint:o,paint:i,boxBounds:ee.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(se(t,e,i,r,o,s),n&&(ne(t,a),oe(t,a))):r.error?n&&ae(t,a,r.error):(n&&(he(t,!0),ne(t,a)),o.loadId=r.load((()=>{he(t,!1),t.destroyed||(se(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),oe(t,a)),o.loadId=null}),(e=>{he(t,!1),ae(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,s,n){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!s.data||s.patternId===o+"-"+a+"-"+r&&!U.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:t,height:i}=h;t*=_e(o)*r,i*=_e(a)*r,h.scaleX&&(t*=h.scaleX,i*=h.scaleY),n=t*i>e.image.maxCacheSize||U.running}return n?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),h.opacity&&(i.opacity*=h.opacity),h.transform&&i.transform(h.transform),i.drawImage(s.image.view,0,0,h.width,h.height),i.restore(),!0):(!s.style||s.sync||U.running?fe(t,s,r):s.patternTask||(s.patternTask=B.patternTasker.add((()=>pe(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&fe(t,s,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:fe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a;for(let r=0,h=i.length;r<h;r++)s=i[r].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,B.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[r].loadId,!o.some((t=>t.url===a)))));return n}return null},createData:Zt,getPatternData:$t,fillOrFitMode:Xt,clipMode:jt,repeatMode:Gt},{toPoint:me}=A,ye={},ve={};function xe(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),N.string(s,i)):t.addColorStop(s.offset,N.string(s.color,i))}}const{getAngle:be,getDistance:Be}=M,{get:Re,rotateOfOuter:Se,scaleOfOuter:ke}=k,{toPoint:Le}=A,Ee={},Te={};function Ae(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=be(e,i);o=Re(),n?(ke(o,e,a/r*(s||1),1),Se(o,e,t+90)):(ke(o,e,1,a/r*(s||1)),Se(o,e,t))}return o}const{getDistance:Me}=M,{toPoint:Ce}=A,We={},Oe={};const Pe={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;me(s||"top",i,ye),me(n||"bottom",i,ve);const h=e.canvas.createLinearGradient(ye.x,ye.y,ve.x,ve.y);xe(h,t.stops,r);const d={type:o,style:h};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Le(s||"center",i,Ee),Le(n||"bottom",i,Te);const d=e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,Be(Ee,Te));xe(d,t.stops,a);const l={type:o,style:d},c=Ae(i,Ee,Te,h,!0);return c&&(l.transform=c),r&&(l.blendMode=r),l},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Ce(s||"center",i,We),Ce(n||"bottom",i,Oe);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,We.x,We.y):e.canvas.createRadialGradient(We.x,We.y,0,We.x,We.y,Me(We,Oe));xe(d,t.stops,a);const l={type:o,style:d},c=Ae(i,We,Oe,h||1,e.conicGradientRotate90);return c&&(l.transform=c),r&&(l.blendMode=r),l},getTransform:Ae},{copy:Ie,toOffsetOutBounds:De}=R,Fe={},ze={};function Ne(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(Ie(Fe,t.bounds),Fe.x+=i.x-a.x,Fe.y+=i.y-a.y,s){const{matrix:t}=n;Fe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Fe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Fe.width*=s,Fe.height*=s}t.copyWorld(n.canvas,t.bounds,Fe)}else s&&(Ie(Fe,i),Fe.x-=i.width/2*(s-1),Fe.y-=i.height/2*(s-1),Fe.width*=s,Fe.height*=s),t.copyWorld(n.canvas,a,s?Fe:i)}const{toOffsetOutBounds:Ye}=R,Ue={};const Ve={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),f=r.length-1;De(d,ze),r.forEach(((r,p)=>{g.setWorldShadow(ze.offsetX+r.x*c,ze.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ne(g,ze,n,i),s=d,r.box&&(g.restore(),g.save(),h&&(g.copyWorld(g,d,o,"copy"),s=o),h?g.copyWorld(h,o,o,"destination-out"):g.copyWorld(i.canvas,l,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(g,s,o,r.blendMode):e.copyWorldToInner(g,s,a.renderBounds,r.blendMode),f&&p<f&&g.clearWorld(s,!0)})),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),f=r.length-1;Ye(d,Ue),r.forEach(((r,p)=>{g.save(),g.setWorldShadow(Ue.offsetX+r.x*c,Ue.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ne(g,Ue,n,i),g.restore(),h?(g.copyWorld(g,d,o,"copy"),g.copyWorld(h,o,o,"source-out"),s=o):(g.copyWorld(i.canvas,l,d,"source-out"),s=d),g.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(g,s,o,r.blendMode):e.copyWorldToInner(g,s,a.renderBounds,r.blendMode),f&&p<f&&g.clearWorld(s,!0)})),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Xe}=m;function je(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),He(t,e,i,1)}(t,i,s,n);break;case"opacity-path":He(t,i,s,o);break;case"path":i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function He(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}V.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:h}=this;for(let d=0,l=h.length;d<l;d++)i=h[d],r=i.__.mask,r&&(a&&(je(this,a,t,n,s,o),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=Ge(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=Ge(t)),n||(n=Ge(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||Xe(i,e)||i.__render(n||t,e);je(this,a,t,n,s,o)};const qe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qe=qe+"_#~&*+\\=|≮≯≈≠=…",Je=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 Ke(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ze=Ke("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Ke("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ti=Ke(qe),ei=Ke(Qe),ii=Ke("- —/~|┆·");var si;!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"}(si||(si={}));const{Letter:ni,Single:oi,Before:ai,After:ri,Symbol:hi,Break:di}=si;function li(t){return Ze[t]?ni:ii[t]?di:$e[t]?ai:ti[t]?ri:ei[t]?hi:Je.test(t)?oi:ni}const ci={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ui(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:gi}=ci,{Letter:fi,Single:pi,Before:_i,After:wi,Symbol:mi,Break:yi}=si;let vi,xi,bi,Bi,Ri,Si,ki,Li,Ei,Ti,Ai,Mi,Ci,Wi,Oi,Pi,Ii,Di=[];function Fi(t,e){Ei&&!Li&&(Li=Ei),vi.data.push({char:t,width:e}),bi+=e}function zi(){Bi+=bi,vi.width=bi,xi.words.push(vi),vi={data:[]},bi=0}function Ni(){Wi&&(Oi.paraNumber++,xi.paraStart=!0,Wi=!1),Ei&&(xi.startCharSize=Li,xi.endCharSize=Ei,Li=0),xi.width=Bi,Pi.width?gi(xi):Ii&&Yi(),Di.push(xi),xi={words:[]},Bi=0}function Yi(){Bi>(Oi.maxWidth||0)&&(Oi.maxWidth=Bi)}const Ui=0,Vi=1,Xi=2;const{top:ji,right:Gi,bottom:Hi,left:qi}=C;function Qi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Ji={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:d}=i;d&&(o?(s=d[qi],o-=d[Gi]+d[qi]):i.autoSizeAlign||(s=d[qi]),a?(n=d[ji],a-=d[ji]+d[Hi]):i.autoSizeAlign||(n=d[ji]));const l={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Oi=t,Di=t.rows,Pi=t.bounds,Ii=!Pi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:d}=Pi;if(h||d||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Wi=!0,Ai=null,Li=ki=Ei=bi=Bi=0,vi={data:[]},xi={words:[]};for(let s=0,d=i.length;s<d;s++)Si=i[s],"\n"===Si?(bi&&zi(),xi.paraEnd=!0,Ni(),Wi=!0):(Ti=li(Si),Ti===fi&&"none"!==a&&(Si=ui(Si,a,!bi)),ki=r.measureText(Si).width,n&&(n<0&&(Ei=ki),ki+=n),Mi=Ti===pi&&(Ai===pi||Ai===fi)||Ai===pi&&Ti!==wi,Ci=!(Ti!==_i&&Ti!==pi||Ai!==mi&&Ai!==wi),Ri=Wi&&o?h-o:h,t&&h&&Bi+bi+ki>Ri&&(e?(bi&&zi(),Bi&&Ni()):(Ci||(Ci=Ti===fi&&Ai==wi),Mi||Ci||Ti===yi||Ti===_i||Ti===pi||bi+ki>Ri?(bi&&zi(),Bi&&Ni()):Bi&&Ni()))," "===Si&&!0!==Wi&&Bi+bi===0||(Ti===yi?(" "===Si&&bi&&zi(),Fi(Si,ki),zi()):Mi||Ci?(bi&&zi(),Fi(Si,ki)):Fi(Si,ki)),Ai=Ti);bi&&zi(),Bi&&Ni(),Di.length>0&&(Di[Di.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Oi.paraNumber++,Bi=r.measureText(t).width,Di.push({x:o||0,text:t,width:Bi,paraStart:!0}),Ii&&Yi()}))}(l,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Qi(e,"x",t[qi]);break;case"right":Qi(e,"x",-t[Gi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Qi(e,"y",t[ji]);break;case"bottom":Qi(e,"y",-t[Hi])}}(d,l,i,o,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:h,verticalAlign:d,paraSpacing:l,autoSizeAlign:c}=e;let{x:u,y:g,width:f,height:p}=s,_=n*i.length+(l?l*(t.paraNumber-1):0),w=o;if(r&&_>p)_=Math.max(p,n),t.overflow=i.length;else if(p||c)switch(d){case"middle":g+=(p-_)/2;break;case"bottom":g+=p-_}w+=g;let m,y,v,x=f||c?f:t.maxWidth;for(let o=0,d=i.length;o<d;o++){if(m=i[o],m.x=u,m.width<f||m.width>f&&!r)switch(h){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&l&&o>0&&(w+=l),m.y=w,w+=n,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,a<0&&(m.width<0?(v=-m.width+e.fontSize+a,y-=v,v+=e.fontSize):v-=a),y<s.x&&(s.x=y),v>s.width&&(s.width=v),r&&f&&f<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=_}(l,i),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Ui:d>.01?Vi:Xi,t.isOverflow&&!r&&(t.textMode=!0),c===Xi?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,h=t.x,t.data=[],t.words.forEach((e=>{c===Vi?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(l,i,o),l.overflow&&function(t,i,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,l=s+n-d;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<l));s--){if(h<l&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:h}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i,s,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}}(l,i),l}};const Ki={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!N.object)return t;t=N.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}},{setPoint:Zi,addPoint:$i,toBounds:ts}=W;const es={export(t,i,s){this.running=!0;const n=d.fileType(i),o=i.includes(".");return s=d.getExportOptions(s),function(t){is||(is=new O);return new Promise((e=>{is.add((()=>pe(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((h=>{const l=t=>{r(t),h(),this.running=!1},{toURL:c}=e,{download:u}=e.origin;if("json"===n)return o&&u(c(JSON.stringify(t.toJSON(s.json)),"text"),i),l({data:!!o||t.toJSON(s.json)});if("svg"===n)return o&&u(c(t.toSVG(),"svg"),i),l({data:!!o||t.toSVG()});const{leafer:g}=t;g?(ss(t),g.waitViewCompleted((()=>pe(this,void 0,void 0,(function*(){let e,n,o=1,r=1;const{worldTransform:h,isLeafer:c,isFrame:u}=t,{slice:f,trim:p,onCanvas:_}=s,m=void 0===s.smooth?g.config.smooth:s.smooth,y=s.contextSettings||g.config.contextSettings,v=s.screenshot||t.isApp,x=c&&v&&void 0===s.fill?t.fill:s.fill,b=d.isOpaqueImage(i)||x,B=new P;if(v)e=!0===v?c?g.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(c?"inner":"local");switch(o=h.scaleX,r=h.scaleY,i){case"inner":B.set(h);break;case"local":B.set(h).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":i=t.leafer;default:B.set(h).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,r/=r/e.scaleY}e=t.getBounds("render",i)}const R={scaleX:1,scaleY:1};L.getScaleData(s.scale,s.size,e,R);let S=s.pixelRatio||1;t.isApp&&(R.scaleX*=S,R.scaleY*=S,S=t.app.pixelRatio);const{x:k,y:E,width:T,height:A}=new w(e).scale(R.scaleX,R.scaleY),M={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-k,-E).withScale(1/o*R.scaleX,1/r*R.scaleY)};let C,W=a.canvas({width:Math.round(T),height:Math.round(A),pixelRatio:S,smooth:m,contextSettings:y});if(f&&(C=t,C.__worldOpacity=0,t=g,M.bounds=W.bounds),W.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(W,M),t.fill=e}else t.__render(W,M);if(W.restore(),C&&C.__updateWorldOpacity(),p){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,a,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,o=(r-n)/e,a?$i(a,n,o):Zi(a={},n,o)),r++;const h=new w;return ts(a,h),h.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:S};W=a.canvas(s),W.copyWorld(t,n,s)}b&&W.fillWorld(W.bounds,x||"#FFFFFF","destination-over"),_&&_(W);const O="canvas"===i?W:yield W.export(i,s);l({data:O,width:W.pixelWidth,height:W.pixelHeight,renderBounds:e,trimBounds:n})}))))):l({data:!1})}))))}};let is;function ss(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>ss(t)))}const ns=t.prototype,os=y.get("@leafer-ui/export");ns.export=function(t,e){const{quality:i,blob:s}=d.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},ns.toBlob=function(t,i){return new Promise((s=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{s(t)})).catch((t=>{os.error(t),s(null)}))}))},ns.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},ns.saveAs=function(t,i){return new Promise((s=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{s(!0)})).catch((t=>{os.error(t),s(!1)}))}))},Object.assign(X,Ji),Object.assign(N,Ki),Object.assign(j,It),Object.assign(z,we),Object.assign(Y,Pe),Object.assign(G,Ve),Object.assign(U,es),Object.assign(a,{interaction:(t,e,i,s)=>new Bt(t,e,i,s),hitCanvas:(t,e)=>new q(t,e),hitCanvasManager:()=>new F}),H.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&K(0,wx)}catch(t){}"ios"===wx.getSystemInfoSync().platform&&(r.prototype.getPattern=function(t,i,s,n){const o=e.canvas.createPattern(this.view,i),{width:a,height:r}=t;this.width===a&&this.height===r||(s||(s=k.get()),k.scale(s,a/this.width,r/this.height));try{s&&o.setTransform&&(o.setTransform(s),s=null)}catch(t){}return n&&(n.transform=s),o});export{Bt as Interaction,lt as Layouter,q as LeaferCanvas,ut as Renderer,xt as Selector,Z as Watcher,K as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,DataHelper as s,canvasSizeAttrs as n,ResizeEvent as o,Creator as a,LeaferImage as r,defineKey as h,FileHelper as d,LeafList as l,RenderEvent as c,ChildEvent as u,WatchEvent as g,PropertyEvent as f,LeafHelper as p,BranchHelper as _,Bounds as w,LeafBoundsHelper as m,Debug as y,LeafLevelList as v,LayoutEvent as x,Run as b,ImageManager as B,BoundsHelper as S,Answer as R,MatrixHelper as k,MathHelper as L,AlignHelper as T,ImageEvent as E,AroundHelper as A,PointHelper as M,Direction4 as C,TwoPointBoundsHelper as W,TaskProcessor as O,Matrix as P}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionHelper as I,InteractionBase as D,HitCanvasManager as F}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as z,ColorConvert as N,PaintGradient as Y,Export as U,Group as V,TextConvert as X,Paint as j,Effect as G,Leafer as H}from"@leafer-ui/draw";class q extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let i=t.view||t.canvas;i?("string"==typeof i?("#"!==i[0]&&(i="#"+i),this.viewSelect=e.miniapp.select(i)):i.fields?this.viewSelect=i:this.initView(i),this.viewSelect&&e.miniapp.getSizeView(this.viewSelect).then((t=>{this.initView(t)}))):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:s,height:n,pixelRatio:o}=this.config,a={width:s||t.width,height:n||t.height,pixelRatio:o};this.resize(a),this.context&&(this.viewSelect&&(e.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,s,n){this.context.roundRect(t,e,i,s,"number"==typeof n?[n]:n)}),i(this.context.__proto__))}__createView(){this.view=e.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(t){this.viewSelect&&e.miniapp.getBounds(this.viewSelect).then((e=>{this.clientBounds=e,t&&t()}))}startAutoLayout(t,i){this.resizeListener=i,t&&(this.checkSize=this.checkSize.bind(this),e.miniapp.onWindowResize(this.checkSize))}checkSize(){this.viewSelect&&setTimeout((()=>{this.updateClientBounds((()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)}))}),500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,e.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};s.copyAttrs(e,this,n),this.resize(t),void 0!==this.width&&this.resizeListener(new o(t,e))}}const{mineType:Q,fileType:J}=d;function K(t,i){e.origin={createCanvas:(t,e,s)=>{const n={type:"2d",width:t,height:e};return i.createOffscreenCanvas?i.createOffscreenCanvas(n):i.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(Q(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,i,s)=>{let n=t.toDataURL(Q(J(i)),s);return n=n.substring(n.indexOf("64,")+3),e.origin.download(n,i)},download:(t,s)=>new Promise(((n,o)=>{let a;s.includes("/")||(s=`${i.env.USER_DATA_PATH}/`+s,a=!0);const r=i.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){a?e.miniapp.saveToAlbum(s).then((()=>{r.unlink({filePath:s}),n()})):n()},fail(t){o(t)}})})),loadImage:t=>new Promise(((i,s)=>{const n=e.canvas.view.createImage();n.onload=()=>{i(n)},n.onerror=t=>{s(t)},n.src=e.image.getRealURL(t)})),noRepeat:"repeat-x"},e.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:s=>{s.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)}},e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=a.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(a,{canvas:(t,e)=>new q(t,e),image:t=>new r(t)}),e.name="miniapp",e.requestRender=function(t){const{view:i}=e.renderCanvas||e.canvas;i.requestAnimationFrame?i.requestAnimationFrame(t):setTimeout(t,16)},h(e,"devicePixelRatio",{get:()=>Math.max(1,wx.getSystemInfoSync().pixelRatio)});class Z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new l;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new l,this.target=t,e&&(this.config=s.default(e,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(c.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===u.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.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 g(g.DATA,{updatedList:this.updatedList})),this.__updatedList=new l,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.CHANGE,this.__onAttrChange,this),t.on_([u.ADD,u.REMOVE],this.__onChildEvent,this),t.on_(g.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:$,updateBounds:tt,updateAllWorldOpacity:et}=p,{pushAllChildBranch:it,pushAllParent:st}=_;const{worldBounds:nt}=m,ot={x:0,y:0,width:1e5,height:1e5};class at{constructor(t){this.updatedBounds=new w,this.beforeBounds=new w,this.afterBounds=new w,t instanceof Array&&(t=new l(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,nt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(ot):this.afterBounds.setListWithFn(t,nt),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:rt,updateAllChange:ht}=p,dt=y.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new v,this.target=t,e&&(this.config=s.default(e,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:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(g.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=b.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:o,AFTER:a}=x,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new x(n,r,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?($(t,!0),e.add(t),t.isBranch&&it(t,e),st(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),st(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||tt(s[t])}tt(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&et(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new x(o,r,this.times)),i.emitEvent(new x(a,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,b.end(e)}fullLayout(){const t=b.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=x,o=this.getBlocks(new l(e));e.emitEvent(new x(i,o,this.times)),lt.fullLayout(e),o.forEach((t=>{t.setAfter()})),e.emitEvent(new x(s,o,this.times)),e.emitEvent(new x(n,o,this.times)),this.addBlocks(o),b.end(t)}static fullLayout(t){rt(t,!0),t.isBranch?_.updateBounds(t):p.updateBounds(t),ht(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new at([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new at(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:t}=this;this.__eventIds=[t.on_(x.REQUEST,this.layout,this),t.on_(x.AGAIN,this.layoutAgain,this),t.on_(g.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=y.get("Renderer");class ut{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=s.default(i,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(x.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new w,ct.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(c.CHILD_START,e),this.emitRender(c.START),this.renderOnce(t),this.emitRender(c.END,this.totalBounds),B.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new w,this.renderOptions={},t)this.emitRender(c.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(c.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(c.RENDER,this.renderBounds,this.renderOptions),this.emitRender(c.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;if(!e)return ct.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=b.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),o=new w(s);i.save(),n&&!y.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,o),i.restore(),b.end(e)}fullRender(){const t=b.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),b.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),y.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),y.showHitView&&this.renderHitView(s),y.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new w;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(c.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new w(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new w(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||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new c(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.REQUEST,this.update,this),t.on_(x.END,this.__onLayoutEnd,this),t.on_(c.AGAIN,this.renderAgain,this),t.on_(o.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:gt}=S;class ft{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new l(i.findList),i.findList||this.hitBranch(o);const{list:a}=this.findList,r=this.getBestMatchLeaf(a,i.bottomList,n),h=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:h,target:r,throughPath:a.length?this.getThroughPath(a):h}:{path:h,target:r}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new l;const{x:s,y:n}=this.point,o={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||p.worldHittable(e))&&(this.hitChild(e,o),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new l;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new l;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new l,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,o;for(let t=0,a=i.length;t<a;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(o=s.list[t],!n||!n.has(o));t++)e.add(o)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let o=t.length-1;o>-1;o--)i=t[o],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||gt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.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()}}const{Yes:pt,NoAndSkip:_t,YesAndSkip:wt}=R,mt={},yt={},vt={};class xt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=s.default(e,this.config)),this.picker=new ft(t,this),t&&this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const o=this.getByInnerId(t,e);return i?o:o?[o]:[];case"string":switch(t[0]){case"#":mt.id=t.substring(1),t=mt;break;case".":yt.className=t.substring(1),t=yt;break;default:vt.tag=t,t=vt}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:n}=t,o=n instanceof Array;return this.getByMethod(o?this.methods.tags:this.methods.tag,e,i,o?s.toMap(n):n)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,n)}}getByPoint(t,i,s){return"node"===e.name&&this.target&&this.target.emit(x.CHECK_UPDATE),this.picker.getByPoint(t,i,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&p.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,o;for(let a=0,r=t.length;a<r;a++){if(n=t[a],o=e(n,s),o===pt||o===wt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&o<_t&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(u.REMOVE,this.__onRemoveChild,this),this.target.on_(f.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(a,{watcher:(t,e)=>new Z(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>new xt(t,e)}),e.layout=lt.fullLayout;const bt={convertTouch(t,e){const i=bt.getTouch(t),s=I.getBase(t);return Object.assign(Object.assign({},s),{x:e.x,y:e.y,width:1,height:1,pointerType:"touch",multiTouch:t.touches.length>1,pressure:i.force||1})},getTouch:t=>t.touches[0]||t.changedTouches[0]};class Bt extends D{__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=bt.getTouch(t);this.pointerDown(bt.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=bt.getTouch(t);this.pointerMove(bt.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=bt.getTouch(t);this.pointerUp(bt.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 e=this.getTouches(t.touches),i=this.getKeepTouchList(this.touches,e);i.length>1&&(this.multiTouch(I.getBase(t),i),this.touches=e)}}multiTouchEnd(){this.touches=null,this.useMultiTouch=!1,this.transformEnd()}getKeepTouchList(t,e){let i;const s=[];return t.forEach((t=>{i=e.find((e=>e.identifier===t.identifier)),i&&s.push({from:this.getLocal(t),to:this.getLocal(i)})})),s}getLocalTouchs(t){return t.map((t=>this.getLocal(t)))}destroy(){super.destroy(),this.touches=null}}function St(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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)})),n&&e.fillRect(i.x,i.y+n,i.width,o)}function Rt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?Tt(t,!0,e,i):Lt(e,i);break;case"inside":kt("inside",t,n,e,i);break;case"outside":kt("outside",t,n,e,i)}}function kt(t,e,i,s,n){const{__strokeWidth:o,__font:a}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*o,s.__),r.font=a,i?Tt(e,!0,s,r):Lt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",St(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function Lt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;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)})),n&&e.strokeRect(i.x,i.y+n,i.width,o)}function Tt(t,e,i,s){let n;for(let o=0,a=t.length;o<a;o++)n=t[o],n.image&&z.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Lt(i,s):s.stroke(),s.restoreBlendMode()):e?Lt(i,s):s.stroke())}function Et(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:At,getOuterOf:Mt,getByMove:Ct,getIntersectData:Wt}=S;let Ot;function Pt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:o,color:a,opacity:r}=e;return{type:n,blendMode:o,style:N.string(a,r)};case"image":return z.image(i,t,e,s,!Ot||!Ot[e.url]);case"linear":return Y.linearGradient(e,s);case"radial":return Y.radialGradient(e,s);case"angular":return Y.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:N.string(e)}:void 0}}const It={compute:function(t,e){const i=e.__,s=[];let n,o=i.__input[t];o instanceof Array||(o=[o]),Ot=z.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)i=Pt(t,o[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?St(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:o}=e.__;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&z.checkImage(e,i,s,!o)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),o?St(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?St(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):o?St(e,i):n?i.fill(n):i.fill())},fillText:St,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)Rt(t,e,i);else switch(o){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&Et(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const o=i.getSameCanvas(!0,!0);o.setStroke(t,2*n,s),e.__drawRenderPath(o),o.stroke(),s.windingRule?o.clip(s.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 s=e.__,{__strokeWidth:n,strokeAlign:o,__font:a}=s;if(n)if(a)Rt(t,e,i);else switch(o){case"center":i.setStroke(void 0,n,s),Tt(t,!1,e,i),s.__useArrow&&Et(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),Tt(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*n,s),Tt(t,!1,e,a),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:Rt,drawTextStroke:Lt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let o,a,r,h,{scaleX:d,scaleY:l}=n;if(d<0&&(d=-d),l<0&&(l=-l),e.bounds.includes(n))h=s,o=r=n;else{const{renderShapeSpread:s}=t.__layout,c=Wt(s?At(e.bounds,d===l?s*d:[s*l,s*d]):e.bounds,n);a=e.bounds.getFitMatrix(c);let{a:u,d:g}=a;if(a.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),d*=u,l*=g),r=Mt(n,a),o=Ct(r,-a.e,-a.f),i.matrix){const{matrix:t}=i;a.multiply(t),u*=t.scaleX,g*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:a.withScale(u,g)})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:o,worldCanvas:h,shapeBounds:r,scaleX:d,scaleY:l}}};let Dt={};const{get:Ft,rotateOfOuter:zt,translate:Nt,scaleOfOuter:Yt,scale:Ut,rotate:Vt}=k;function Xt(t,e,i,s,n,o,a){const r=Ft();Nt(r,e.x+i,e.y+s),Ut(r,n,o),a&&zt(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function jt(t,e,i,s,n,o,a){const r=Ft();Nt(r,e.x+i,e.y+s),n&&Ut(r,n,o),a&&Vt(r,a),t.transform=r}function Gt(t,e,i,s,n,o,a,r,h,d){const l=Ft();if(h)if("center"===d)zt(l,{x:i/2,y:s/2},h);else switch(Vt(l,h),h){case 90:Nt(l,s,0);break;case 180:Nt(l,i,s);break;case 270:Nt(l,0,i)}Dt.x=e.x+n,Dt.y=e.y+o,Nt(l,Dt.x,Dt.y),a&&Yt(l,Dt,a,r),t.transform=l}const{get:Ht,translate:qt}=k,Qt=new w,Jt={},Kt={};function Zt(t,e,i,s){const{blendMode:n,sync:o}=i;n&&(t.blendMode=n),o&&(t.sync=o),t.data=$t(i,s,e)}function $t(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:o,mode:a,align:r,offset:h,scale:d,size:l,rotation:c,repeat:u}=t,g=e.width===s&&e.height===n,f={mode:a},p="center"!==r&&(c||0)%180==90,_=p?n:s,w=p?s:n;let m,y,v=0,x=0;if(a&&"cover"!==a&&"fit"!==a)(d||l)&&(L.getScaleData(d,l,i,Kt),m=Kt.scaleX,y=Kt.scaleY);else if(!g||c){const t=e.width/_,i=e.height/w;m=y="fit"===a?Math.min(t,i):Math.max(t,i),v+=(e.width-s*m)/2,x+=(e.height-n*y)/2}if(r){const t={x:v,y:x,width:_,height:w};m&&(t.width*=m,t.height*=y),T.toPoint(r,t,e,Jt,!0),v+=Jt.x,x+=Jt.y}switch(h&&(v+=h.x,x+=h.y),a){case"stretch":g||(s=e.width,n=e.height);break;case"normal":case"clip":(v||x||m||c)&&jt(f,e,v,x,m,y,c);break;case"repeat":(!g||m||c)&&Gt(f,e,s,n,v,x,m,y,c,r),u||(f.repeat="repeat");break;default:m&&Xt(f,e,v,x,m,y,c)}return f.transform||(e.x||e.y)&&(f.transform=Ht(),qt(f.transform,e.x,e.y)),m&&"stretch"!==a&&(f.scaleX=m,f.scaleY=y),f.width=s,f.height=n,o&&(f.opacity=o),u&&(f.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),f}let te,ee=new w;const{isSame:ie}=S;function se(t,e,i,s,n,o){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Zt(n,s,i,o),!0}function ne(t,e){re(t,E.LOAD,e)}function oe(t,e){re(t,E.LOADED,e)}function ae(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,E.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function he(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:de,scale:le,copy:ce}=k,{ceil:ue,abs:ge}=Math;function fe(t,i,s){let{scaleX:n,scaleY:o}=B.patternLocked?t.__world:t.__nowWorld;const a=n+"-"+o+"-"+s;if(i.patternId===a||t.destroyed)return!1;{n=ge(n),o=ge(o);const{image:t,data:r}=i;let h,d,{width:l,height:c,scaleX:u,scaleY:g,opacity:f,transform:p,repeat:_}=r;u&&(d=de(),ce(d,p),le(d,1/u,1/g),n*=u,o*=g),n*=s,o*=s,l*=n,c*=o;const w=l*c;if(!_&&w>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;m>e&&(m=e)}w>m&&(h=Math.sqrt(w/m)),h&&(n/=h,o/=h,l/=h,c/=h),u&&(n/=u,o/=g),(p||1!==n||1!==o)&&(d||(d=de(),p&&ce(d,p)),le(d,1/n,1/o));const y=t.getCanvas(ue(l)||1,ue(c)||1,f),v=t.getPattern(y,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=v,i.patternId=a,!0}}function pe(t,e,i,s){return new(i||(i=Promise))((function(n,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function r(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,r)}h((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:_e}=Math;const we={image:function(t,e,i,s,n){let o,a;const r=B.get(i);return te&&i===te.paint&&ie(s,te.boxBounds)?o=te.leafPaint:(o={type:i.type,image:r},te=r.use>1?{leafPaint:o,paint:i,boxBounds:ee.set(s)}:null),(n||r.loading)&&(a={image:r,attrName:e,attrValue:i}),r.ready?(se(t,e,i,r,o,s),n&&(ne(t,a),oe(t,a))):r.error?n&&ae(t,a,r.error):(n&&(he(t,!0),ne(t,a)),o.loadId=r.load((()=>{he(t,!1),t.destroyed||(se(t,e,i,r,o,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),oe(t,a)),o.loadId=null}),(e=>{he(t,!1),ae(t,a,e),o.loadId=null}))),o},checkImage:function(t,i,s,n){const{scaleX:o,scaleY:a}=B.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!s.data||s.patternId===o+"-"+a+"-"+r&&!U.running)return!1;{const{data:h}=s;if(n)if(h.repeat)n=!1;else{let{width:t,height:i}=h;t*=_e(o)*r,i*=_e(a)*r,h.scaleX&&(t*=h.scaleX,i*=h.scaleY),n=t*i>e.image.maxCacheSize||U.running}return n?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),h.opacity&&(i.opacity*=h.opacity),h.transform&&i.transform(h.transform),i.drawImage(s.image.view,0,0,h.width,h.height),i.restore(),!0):(!s.style||s.sync||U.running?fe(t,s,r):s.patternTask||(s.patternTask=B.patternTasker.add((()=>pe(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&fe(t,s,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:fe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,o,a;for(let r=0,h=i.length;r<h;r++)s=i[r].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,B.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[r].loadId,!o.some((t=>t.url===a)))));return n}return null},createData:Zt,getPatternData:$t,fillOrFitMode:Xt,clipMode:jt,repeatMode:Gt},{toPoint:me}=A,ye={},ve={};function xe(t,e,i){if(e){let s;for(let n=0,o=e.length;n<o;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(o-1),N.string(s,i)):t.addColorStop(s.offset,N.string(s.color,i))}}const{getAngle:be,getDistance:Be}=M,{get:Se,rotateOfOuter:Re,scaleOfOuter:ke}=k,{toPoint:Le}=A,Te={},Ee={};function Ae(t,e,i,s,n){let o;const{width:a,height:r}=t;if(a!==r||s){const t=be(e,i);o=Se(),n?(ke(o,e,a/r*(s||1),1),Re(o,e,t+90)):(ke(o,e,1,a/r*(s||1)),Re(o,e,t))}return o}const{getDistance:Me}=M,{toPoint:Ce}=A,We={},Oe={};const Pe={linearGradient:function(t,i){let{from:s,to:n,type:o,blendMode:a,opacity:r}=t;me(s||"top",i,ye),me(n||"bottom",i,ve);const h=e.canvas.createLinearGradient(ye.x,ye.y,ve.x,ve.y);xe(h,t.stops,r);const d={type:o,style:h};return a&&(d.blendMode=a),d},radialGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Le(s||"center",i,Te),Le(n||"bottom",i,Ee);const d=e.canvas.createRadialGradient(Te.x,Te.y,0,Te.x,Te.y,Be(Te,Ee));xe(d,t.stops,a);const l={type:o,style:d},c=Ae(i,Te,Ee,h,!0);return c&&(l.transform=c),r&&(l.blendMode=r),l},conicGradient:function(t,i){let{from:s,to:n,type:o,opacity:a,blendMode:r,stretch:h}=t;Ce(s||"center",i,We),Ce(n||"bottom",i,Oe);const d=e.conicGradientSupport?e.canvas.createConicGradient(0,We.x,We.y):e.canvas.createRadialGradient(We.x,We.y,0,We.x,We.y,Me(We,Oe));xe(d,t.stops,a);const l={type:o,style:d},c=Ae(i,We,Oe,h||1,e.conicGradientRotate90);return c&&(l.transform=c),r&&(l.blendMode=r),l},getTransform:Ae},{copy:Ie,toOffsetOutBounds:De}=S,Fe={},ze={};function Ne(t,i,s,n){const{bounds:o,shapeBounds:a}=n;if(e.fullImageShadow){if(Ie(Fe,t.bounds),Fe.x+=i.x-a.x,Fe.y+=i.y-a.y,s){const{matrix:t}=n;Fe.x-=(o.x+(t?t.e:0)+o.width/2)*(s-1),Fe.y-=(o.y+(t?t.f:0)+o.height/2)*(s-1),Fe.width*=s,Fe.height*=s}t.copyWorld(n.canvas,t.bounds,Fe)}else s&&(Ie(Fe,i),Fe.x-=i.width/2*(s-1),Fe.y-=i.height/2*(s-1),Fe.width*=s,Fe.height*=s),t.copyWorld(n.canvas,a,s?Fe:i)}const{toOffsetOutBounds:Ye}=S,Ue={};const Ve={shadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),f=r.length-1;De(d,ze),r.forEach(((r,p)=>{g.setWorldShadow(ze.offsetX+r.x*c,ze.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ne(g,ze,n,i),s=d,r.box&&(g.restore(),g.save(),h&&(g.copyWorld(g,d,o,"copy"),s=o),h?g.copyWorld(h,o,o,"destination-out"):g.copyWorld(i.canvas,l,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(g,s,o,r.blendMode):e.copyWorldToInner(g,s,a.renderBounds,r.blendMode),f&&p<f&&g.clearWorld(s,!0)})),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:d,shapeBounds:l,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),f=r.length-1;Ye(d,Ue),r.forEach(((r,p)=>{g.save(),g.setWorldShadow(Ue.offsetX+r.x*c,Ue.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ne(g,Ue,n,i),g.restore(),h?(g.copyWorld(g,d,o,"copy"),g.copyWorld(h,o,o,"source-out"),s=o):(g.copyWorld(i.canvas,l,d,"source-out"),s=d),g.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(g,s,o,r.blendMode):e.copyWorldToInner(g,s,a.renderBounds,r.blendMode),f&&p<f&&g.clearWorld(s,!0)})),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Xe}=m;function je(t,e,i,s,n,o){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),He(t,e,i,1)}(t,i,s,n);break;case"opacity-path":He(t,i,s,o);break;case"path":i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function He(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}V.prototype.__renderMask=function(t,e){let i,s,n,o,a,r;const{children:h}=this;for(let d=0,l=h.length;d<l;d++)i=h[d],r=i.__.mask,r&&(a&&(je(this,a,t,n,s,o),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(a="opacity-path",o=i.opacity,n||(n=Ge(t))):(a="path",t.save()),i.__clip(n||t,e)):(a="grayscale"===r?"grayscale":"alpha",s||(s=Ge(t)),n||(n=Ge(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||Xe(i,e)||i.__render(n||t,e);je(this,a,t,n,s,o)};const qe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qe=qe+"_#~&*+\\=|≮≯≈≠=…",Je=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 Ke(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ze=Ke("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Ke("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ti=Ke(qe),ei=Ke(Qe),ii=Ke("- —/~|┆·");var si;!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"}(si||(si={}));const{Letter:ni,Single:oi,Before:ai,After:ri,Symbol:hi,Break:di}=si;function li(t){return Ze[t]?ni:ii[t]?di:$e[t]?ai:ti[t]?ri:ei[t]?hi:Je.test(t)?oi:ni}const ci={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let o=n-1;o>-1&&(i=e[o].data[0]," "===i.char);o--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ui(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:gi}=ci,{Letter:fi,Single:pi,Before:_i,After:wi,Symbol:mi,Break:yi}=si;let vi,xi,bi,Bi,Si,Ri,ki,Li,Ti,Ei,Ai,Mi,Ci,Wi,Oi,Pi,Ii,Di=[];function Fi(t,e){Ti&&!Li&&(Li=Ti),vi.data.push({char:t,width:e}),bi+=e}function zi(){Bi+=bi,vi.width=bi,xi.words.push(vi),vi={data:[]},bi=0}function Ni(){Wi&&(Oi.paraNumber++,xi.paraStart=!0,Wi=!1),Ti&&(xi.startCharSize=Li,xi.endCharSize=Ti,Li=0),xi.width=Bi,Pi.width?gi(xi):Ii&&Yi(),Di.push(xi),xi={words:[]},Bi=0}function Yi(){Bi>(Oi.maxWidth||0)&&(Oi.maxWidth=Bi)}const Ui=0,Vi=1,Xi=2;const{top:ji,right:Gi,bottom:Hi,left:qi}=C;function Qi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Ji={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,o=i.__getInput("width")||0,a=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:d}=i;d&&(o?(s=d[qi],o-=d[Gi]+d[qi]):i.autoSizeAlign||(s=d[qi]),a?(n=d[ji],a-=d[ji]+d[Hi]):i.autoSizeAlign||(n=d[ji]));const l={bounds:{x:s,y:n,width:o,height:a},rows:[],paraNumber:0,font:e.canvas.font=h};return function(t,i,s){Oi=t,Di=t.rows,Pi=t.bounds,Ii=!Pi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:o,textCase:a}=s,{canvas:r}=e,{width:h,height:d}=Pi;if(h||d||n||"none"!==a){const t="none"!==s.textWrap,e="break"===s.textWrap;Wi=!0,Ai=null,Li=ki=Ti=bi=Bi=0,vi={data:[]},xi={words:[]};for(let s=0,d=i.length;s<d;s++)Ri=i[s],"\n"===Ri?(bi&&zi(),xi.paraEnd=!0,Ni(),Wi=!0):(Ei=li(Ri),Ei===fi&&"none"!==a&&(Ri=ui(Ri,a,!bi)),ki=r.measureText(Ri).width,n&&(n<0&&(Ti=ki),ki+=n),Mi=Ei===pi&&(Ai===pi||Ai===fi)||Ai===pi&&Ei!==wi,Ci=!(Ei!==_i&&Ei!==pi||Ai!==mi&&Ai!==wi),Si=Wi&&o?h-o:h,t&&h&&Bi+bi+ki>Si&&(e?(bi&&zi(),Bi&&Ni()):(Ci||(Ci=Ei===fi&&Ai==wi),Mi||Ci||Ei===yi||Ei===_i||Ei===pi||bi+ki>Si?(bi&&zi(),Bi&&Ni()):Bi&&Ni()))," "===Ri&&!0!==Wi&&Bi+bi===0||(Ei===yi?(" "===Ri&&bi&&zi(),Fi(Ri,ki),zi()):Mi||Ci?(bi&&zi(),Fi(Ri,ki)):Fi(Ri,ki)),Ai=Ei);bi&&zi(),Bi&&Ni(),Di.length>0&&(Di[Di.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Oi.paraNumber++,Bi=r.measureText(t).width,Di.push({x:o||0,text:t,width:Bi,paraStart:!0}),Ii&&Yi()}))}(l,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Qi(e,"x",t[qi]);break;case"right":Qi(e,"x",-t[Gi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Qi(e,"y",t[ji]);break;case"bottom":Qi(e,"y",-t[Hi])}}(d,l,i,o,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:h,verticalAlign:d,paraSpacing:l,autoSizeAlign:c}=e;let{x:u,y:g,width:f,height:p}=s,_=n*i.length+(l?l*(t.paraNumber-1):0),w=o;if(r&&_>p)_=Math.max(p,n),t.overflow=i.length;else if(p||c)switch(d){case"middle":g+=(p-_)/2;break;case"bottom":g+=p-_}w+=g;let m,y,v,x=f||c?f:t.maxWidth;for(let o=0,d=i.length;o<d;o++){if(m=i[o],m.x=u,m.width<f||m.width>f&&!r)switch(h){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&l&&o>0&&(w+=l),m.y=w,w+=n,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,a<0&&(m.width<0?(v=-m.width+e.fontSize+a,y-=v,v+=e.fontSize):v-=a),y<s.x&&(s.x=y),v>s.width&&(s.width=v),r&&f&&f<v&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=_}(l,i),function(t,e,i,s){const{rows:n}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let h,d,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,d=i&&"justify"===o&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Ui:d>.01?Vi:Xi,t.isOverflow&&!r&&(t.textMode=!0),c===Xi?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,h=t.x,t.data=[],t.words.forEach((e=>{c===Vi?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&d&&(h+=d,t.width+=d)}))),t.words=null)}))}(l,i,o),l.overflow&&function(t,i,s,n){if(!n)return;const{rows:o,overflow:a}=t;let{textOverflow:r}=i;if(o.splice(a),r&&"show"!==r){let t,h;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,l=s+n-d;("none"===i.textWrap?o:[o[a-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],h=t.x+t.width,!(s===i&&h<l));s--){if(h<l&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:h}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i,s,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}}(l,i),l}};const Ki={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!N.object)return t;t=N.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}},{setPoint:Zi,addPoint:$i,toBounds:ts}=W;const es={export(t,i,s){this.running=!0;const n=d.fileType(i),o=i.includes(".");return s=d.getExportOptions(s),function(t){is||(is=new O);return new Promise((e=>{is.add((()=>pe(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((h=>{const l=t=>{r(t),h(),this.running=!1},{toURL:c}=e,{download:u}=e.origin;if("json"===n)return o&&u(c(JSON.stringify(t.toJSON(s.json)),"text"),i),l({data:!!o||t.toJSON(s.json)});if("svg"===n)return o&&u(c(t.toSVG(),"svg"),i),l({data:!!o||t.toSVG()});const{leafer:g}=t;g?(ss(t),g.waitViewCompleted((()=>pe(this,void 0,void 0,(function*(){let e,n,o=1,r=1;const{worldTransform:h,isLeafer:c,isFrame:u}=t,{slice:f,trim:p,onCanvas:_}=s,m=void 0===s.smooth?g.config.smooth:s.smooth,y=s.contextSettings||g.config.contextSettings,v=s.screenshot||t.isApp,x=c&&v&&void 0===s.fill?t.fill:s.fill,b=d.isOpaqueImage(i)||x,B=new P;if(v)e=!0===v?c?g.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(c?"inner":"local");switch(o=h.scaleX,r=h.scaleY,i){case"inner":B.set(h);break;case"local":B.set(h).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":i=t.leafer;default:B.set(h).divide(t.getTransform(i));const e=i.worldTransform;o/=o/e.scaleX,r/=r/e.scaleY}e=t.getBounds("render",i)}const S={scaleX:1,scaleY:1};L.getScaleData(s.scale,s.size,e,S);let R=s.pixelRatio||1;t.isApp&&(S.scaleX*=R,S.scaleY*=R,R=t.app.pixelRatio);const{x:k,y:T,width:E,height:A}=new w(e).scale(S.scaleX,S.scaleY),M={matrix:B.scale(1/S.scaleX,1/S.scaleY).invert().translate(-k,-T).withScale(1/o*S.scaleX,1/r*S.scaleY)};let C,W=a.canvas({width:Math.round(E),height:Math.round(A),pixelRatio:R,smooth:m,contextSettings:y});if(f&&(C=t,C.__worldOpacity=0,t=g,M.bounds=W.bounds),W.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(W,M),t.fill=e}else t.__render(W,M);if(W.restore(),C&&C.__updateWorldOpacity(),p){n=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,o,a,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,o=(r-n)/e,a?$i(a,n,o):Zi(a={},n,o)),r++;const h=new w;return ts(a,h),h.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=n,s={x:0,y:0,width:e,height:i,pixelRatio:R};W=a.canvas(s),W.copyWorld(t,n,s)}b&&W.fillWorld(W.bounds,x||"#FFFFFF","destination-over"),_&&_(W);const O="canvas"===i?W:yield W.export(i,s);l({data:O,width:W.pixelWidth,height:W.pixelHeight,renderBounds:e,trimBounds:n})}))))):l({data:!1})}))))}};let is;function ss(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>ss(t)))}const ns=t.prototype,os=y.get("@leafer-ui/export");ns.export=function(t,e){const{quality:i,blob:s}=d.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},ns.toBlob=function(t,i){return new Promise((s=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{s(t)})).catch((t=>{os.error(t),s(null)}))}))},ns.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},ns.saveAs=function(t,i){return new Promise((s=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{s(!0)})).catch((t=>{os.error(t),s(!1)}))}))},Object.assign(X,Ji),Object.assign(N,Ki),Object.assign(j,It),Object.assign(z,we),Object.assign(Y,Pe),Object.assign(G,Ve),Object.assign(U,es),Object.assign(a,{interaction:(t,e,i,s)=>new Bt(t,e,i,s),hitCanvas:(t,e)=>new q(t,e),hitCanvasManager:()=>new F}),H.prototype.receiveEvent=function(t){this.interaction&&this.interaction.receive(t)};try{wx&&K(0,wx)}catch(t){}"ios"===wx.getSystemInfoSync().platform&&(r.prototype.getPattern=function(t,i,s,n){const o=e.canvas.createPattern(this.view,i),{width:a,height:r}=t;this.width===a&&this.height===r||(s||(s=k.get()),k.scale(s,a/this.width,r/this.height));try{s&&o.setTransform&&(o.setTransform(s),s=null)}catch(t){}return n&&(n.transform=s),o});export{Bt as Interaction,lt as Layouter,q as LeaferCanvas,ut as Renderer,xt as Selector,Z as Watcher,K as useCanvas};
|
package/dist/miniapp.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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,a={width:i||e.width,height:n||e.height,pixelRatio:s};this.resize(a),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(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:a}=t.FileHelper;function o(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 o=e.toDataURL(s(a(i)),n);return o=o.substring(o.indexOf("64,")+3),t.Platform.origin.download(o,i)},download:(e,n)=>new Promise(((s,a)=>{let o;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,o=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:e,encoding:"base64",success(){o?t.Platform.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){a(t)}})})),loadImage:e=>new Promise(((i,n)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)})),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new 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 v{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:a,LAYOUT:o,AFTER:r}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),n.emitEvent(new t.LayoutEvent(a,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(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(o,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:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,o,this.times)),v.fullLayout(i),o.forEach((t=>{t.setAfter()})),i.emitEvent(new t.LayoutEvent(s,o,this.times)),i.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),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 y=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(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,y.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,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;if(!e)return y.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),a=e.includes(this.target.__world),o=new t.Bounds(s);n.save(),a&&!t.Debug.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,a,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,!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(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__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.changed=!0}}__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)}}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,a=n.ignoreHittable||!1,o=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(o);const{list:r}=this.findList,h=this.getBestMatchLeaf(r,n.bottomList,a),l=a?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:a}=this.point,o={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=e.length;s<a;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,o),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,a,o;for(let t=0,e=n.length;t<e;t++){s=n[t],a=n[t+1];for(let t=0,e=s.length;t<e&&(o=s.list[t],!a||!a.has(o));t++)i.add(o)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!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()}}const{Yes:L,NoAndSkip:E,YesAndSkip:R}=t.Answer,S={},P={},k={};class T{constructor(e,i){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new B(e,this),e&&this.__listenEvents()}getBy(e,i,n,s){switch(typeof e){case"number":const a=this.getByInnerId(e,i);return n?a:a?[a]:[];case"string":switch(e[0]){case"#":S.id=e.substring(1),e=S;break;case".":P.className=e.substring(1),e=P;break;default:k.tag=e,e=k}case"object":if(void 0!==e.id){const t=this.getById(e.id,i);return n?t:t?[t]:[]}if(e.tag){const{tag:s}=e,a=s instanceof Array;return this.getByMethod(a?this.methods.tags:this.methods.tag,i,n,a?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,i,n,e.className);case"function":return this.getByMethod(e,i,n,s)}}getByPoint(e,i,n){return"node"===t.Platform.name&&this.target&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,i,n)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,i){const n=this.idMap[e];return n&&t.LeafHelper.hasParent(n,i||this.target)?n:(this.eachFind(this.toChildren(i),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,n),a===L||a===R){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&a<E&&this.eachFind(s.children,e,i,n)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>new T(t,e)}),t.Platform.layout=v.fullLayout;const C={convertTouch(t,i){const n=C.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 M 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=C.getTouch(t);this.pointerDown(C.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=C.getTouch(t);this.pointerMove(C.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=C.getTouch(t);this.pointerUp(C.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 A(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;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,a)}function I(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?H(t,!0,e,i):O(e,i);break;case"inside":W("inside",t,s,e,i);break;case"outside":W("outside",t,s,e,i)}}function W(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?H(e,!0,n,r):O(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",A(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 O(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;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,a)}function H(t,e,n,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&i.PaintImage.checkImage(n,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?O(n,s):s.stroke(),s.restoreBlendMode()):e?O(n,s):s.stroke())}function D(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:F,getOuterOf:z,getByMove:N,getIntersectData:Y}=t.BoundsHelper;let j;function G(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:a,blendMode:o,color:r,opacity:h}=e;return{type:a,blendMode:o,style:i.ColorConvert.string(r,h)};case"image":return i.PaintImage.image(n,t,e,s,!j||!j[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 U={compute:function(t,e){const n=e.__,s=[];let a,o=n.__input[t];o instanceof Array||(o=[o]),j=i.PaintImage.recycleImage(t,n);for(let i,n=0,a=o.length;n<a;n++)i=G(t,o[n],e),i&&s.push(i);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=a:n.__pixelStroke=a},fill:function(t,e,i){i.fillStyle=t,e.__.__font?A(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,n){let s;const{windingRule:a,__font:o}=e.__;for(let r=0,h=t.length;r<h;r++)s=t[r],s.image&&i.PaintImage.checkImage(e,n,s,!o)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restoreBlendMode()):o?A(e,n):a?n.fill(a):n.fill())},fillText:A,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)I(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&D(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 a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)I(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),H(t,!1,e,i),n.__useArrow&&D(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),H(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),H(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:I,drawTextStroke:O,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,h,{scaleX:l,scaleY:d}=s;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(s))h=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Y(n?F(e.bounds,l===d?n*l:[n*d,n*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=f),r=z(s,o),a=N(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:h,shapeBounds:r,scaleX:l,scaleY:d}}};let V={};const{get:X,rotateOfOuter:q,translate:Q,scaleOfOuter:K,scale:J,rotate:Z}=t.MatrixHelper;function $(t,e,i,n,s,a,o){const r=X();Q(r,e.x+i,e.y+n),J(r,s,a),o&&q(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function tt(t,e,i,n,s,a,o){const r=X();Q(r,e.x+i,e.y+n),s&&J(r,s,a),o&&Z(r,o),t.transform=r}function et(t,e,i,n,s,a,o,r,h,l){const d=X();if(h)if("center"===l)q(d,{x:i/2,y:n/2},h);else switch(Z(d,h),h){case 90:Q(d,n,0);break;case 180:Q(d,i,n);break;case 270:Q(d,0,i)}V.x=e.x+s,V.y=e.y+a,Q(d,V.x,V.y),o&&K(d,V,o,r),t.transform=d}const{get:it,translate:nt}=t.MatrixHelper,st=new t.Bounds,at={},ot={};function rt(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=ht(i,n,e)}function ht(e,i,n){let{width:s,height:a}=n;e.padding&&(i=st.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:h,offset:l,scale:d,size:c,rotation:u,repeat:f}=e,g=i.width===s&&i.height===a,p={mode:r},_="center"!==h&&(u||0)%180==90,w=_?a:s,m=_?s:a;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(d||c)&&(t.MathHelper.getScaleData(d,c,n,ot),v=ot.scaleX,y=ot.scaleY);else if(!g||u){const t=i.width/w,e=i.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(i.width-s*v)/2,b+=(i.height-a*y)/2}if(h){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),t.AlignHelper.toPoint(h,e,i,at,!0),x+=at.x,b+=at.y}switch(l&&(x+=l.x,b+=l.y),r){case"stretch":g||(s=i.width,a=i.height);break;case"normal":case"clip":(x||b||v||u)&&tt(p,i,x,b,v,y,u);break;case"repeat":(!g||v||u)&&et(p,i,s,a,x,b,v,y,u,h),f||(p.repeat="repeat");break;default:v&&$(p,i,x,b,v,y,u)}return p.transform||(i.x||i.y)&&(p.transform=it(),nt(p.transform,i.x,i.y)),v&&"stretch"!==r&&(p.scaleX=v,p.scaleY=y),p.width=s,p.height=a,o&&(p.opacity=o),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),p}let lt,dt=new t.Bounds;const{isSame:ct}=t.BoundsHelper;function ut(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||rt(s,n,i,a),!0}function ft(e,i){_t(e,t.ImageEvent.LOAD,i)}function gt(e,i){_t(e,t.ImageEvent.LOADED,i)}function pt(e,i,n){i.error=n,e.forceUpdate("surface"),_t(e,t.ImageEvent.ERROR,i)}function _t(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function wt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:mt,scale:vt,copy:yt}=t.MatrixHelper,{ceil:xt,abs:bt}=Math;function Bt(e,i,n){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||e.destroyed)return!1;{s=bt(s),a=bt(a);const{image:e,data:r}=i;let h,l,{width:d,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(l=mt(),yt(l,p),vt(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,d*=s,c*=a;const w=d*c;if(!_&&w>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)}w>m&&(h=Math.sqrt(w/m)),h&&(s/=h,a/=h,d/=h,c/=h),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=mt(),p&&yt(l,p)),vt(l,1/s,1/a));const v=e.getCanvas(xt(d)||1,xt(c)||1,g),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",l,i);return i.style=y,i.patternId=o,!0}}function Lt(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{h(n.next(t))}catch(t){a(t)}}function r(t){try{h(n.throw(t))}catch(t){a(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(o,r)}h((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Et}=Math;const Rt={image:function(e,i,n,s,a){let o,r;const h=t.ImageManager.get(n);return lt&&n===lt.paint&&ct(s,lt.boxBounds)?o=lt.leafPaint:(o={type:n.type,image:h},lt=h.use>1?{leafPaint:o,paint:n,boxBounds:dt.set(s)}:null),(a||h.loading)&&(r={image:h,attrName:i,attrValue:n}),h.ready?(ut(e,i,n,h,o,s),a&&(ft(e,r),gt(e,r))):h.error?a&&pt(e,r,h.error):(a&&(wt(e,!0),ft(e,r)),o.loadId=h.load((()=>{wt(e,!1),e.destroyed||(ut(e,i,n,h,o,s)&&(h.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),gt(e,r)),o.loadId=null}),(t=>{wt(e,!1),pt(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,s,a){const{scaleX:o,scaleY:r}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:h}=n;if(!s.data||s.patternId===o+"-"+r+"-"+h&&!i.Export.running)return!1;{const{data:l}=s;if(a)if(l.repeat)a=!1;else{let{width:e,height:n}=l;e*=Et(o)*h,n*=Et(r)*h,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),a=e*n>t.Platform.image.maxCacheSize||i.Export.running}return a?(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.view,0,0,l.width,l.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?Bt(e,s,h):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>Lt(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&Bt(e,s,h),e.forceUpdate("surface")}))),300)),!1)}},createPattern:Bt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){let s,a,o,r;for(let h=0,l=n.length;h<l;h++)s=n[h].image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=i.__input&&i.__input[e]||[],o instanceof Array||(o=[o])),s.unload(n[h].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:rt,getPatternData:ht,fillOrFitMode:$,clipMode:tt,repeatMode:et},{toPoint:St}=t.AroundHelper,Pt={},kt={};function Tt(t,e,n){if(e){let s;for(let a=0,o=e.length;a<o;a++)s=e[a],"string"==typeof s?t.addColorStop(a/(o-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}}const{getAngle:Ct,getDistance:Mt}=t.PointHelper,{get:At,rotateOfOuter:It,scaleOfOuter:Wt}=t.MatrixHelper,{toPoint:Ot}=t.AroundHelper,Ht={},Dt={};function Ft(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=Ct(e,i);a=At(),s?(Wt(a,e,o/r*(n||1),1),It(a,e,t+90)):(Wt(a,e,1,o/r*(n||1)),It(a,e,t))}return a}const{getDistance:zt}=t.PointHelper,{toPoint:Nt}=t.AroundHelper,Yt={},jt={};const Gt={linearGradient:function(e,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=e;St(n||"top",i,Pt),St(s||"bottom",i,kt);const h=t.Platform.canvas.createLinearGradient(Pt.x,Pt.y,kt.x,kt.y);Tt(h,e.stops,r);const l={type:a,style:h};return o&&(l.blendMode=o),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:h}=e;Ot(n||"center",i,Ht),Ot(s||"bottom",i,Dt);const l=t.Platform.canvas.createRadialGradient(Ht.x,Ht.y,0,Ht.x,Ht.y,Mt(Ht,Dt));Tt(l,e.stops,o);const d={type:a,style:l},c=Ft(i,Ht,Dt,h,!0);return c&&(d.transform=c),r&&(d.blendMode=r),d},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:h}=e;Nt(n||"center",i,Yt),Nt(s||"bottom",i,jt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Yt.x,Yt.y):t.Platform.canvas.createRadialGradient(Yt.x,Yt.y,0,Yt.x,Yt.y,zt(Yt,jt));Tt(l,e.stops,o);const d={type:a,style:l},c=Ft(i,Yt,jt,h||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),r&&(d.blendMode=r),d},getTransform:Ft},{copy:Ut,toOffsetOutBounds:Vt}=t.BoundsHelper,Xt={},qt={};function Qt(e,i,n,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(Ut(Xt,e.bounds),Xt.x+=i.x-o.x,Xt.y+=i.y-o.y,n){const{matrix:t}=s;Xt.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Xt.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Xt.width*=n,Xt.height*=n}e.copyWorld(s.canvas,e.bounds,Xt)}else n&&(Ut(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,o,n?Xt:i)}const{toOffsetOutBounds:Kt}=t.BoundsHelper,Jt={};const Zt={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Vt(l,qt),r.forEach(((r,p)=>{f.setWorldShadow(qt.offsetX+r.x*c,qt.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Qt(f,qt,s,i),n=l,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,l,a,"copy"),n=a),h?f.copyWorld(h,a,a,"destination-out"):f.copyWorld(i.canvas,d,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Kt(l,Jt),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Jt.offsetX+r.x*c,Jt.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Qt(f,Jt,s,i),f.restore(),h?(f.copyWorld(f,l,a,"copy"),f.copyWorld(h,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,d,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:$t}=t.LeafBoundsHelper;function te(t,e,i,n,s,a){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,a);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,a,o,r;const{children:h}=this;for(let l=0,d=h.length;l<d;l++)i=h[l],r=i.__.mask,r&&(o&&(te(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=ee(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=ee(t)),s||(s=ee(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||$t(i,e)||i.__render(s||t,e);te(this,o,t,s,n,a)};const ne=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",se=ne+"_#~&*+\\=|≮≯≈≠=…",ae=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function oe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const re=oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),he=oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),le=oe(ne),de=oe(se),ce=oe("- —/~|┆·");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:ge,Before:pe,After:_e,Symbol:we,Break:me}=ue;function ve(t){return re[t]?fe:ce[t]?me:he[t]?pe:le[t]?_e:de[t]?we:ae.test(t)?ge:fe}const ye={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function 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}=ye,{Letter:Be,Single:Le,Before:Ee,After:Re,Symbol:Se,Break:Pe}=ue;let ke,Te,Ce,Me,Ae,Ie,We,Oe,He,De,Fe,ze,Ne,Ye,je,Ge,Ue,Ve=[];function Xe(t,e){He&&!Oe&&(Oe=He),ke.data.push({char:t,width:e}),Ce+=e}function qe(){Me+=Ce,ke.width=Ce,Te.words.push(ke),ke={data:[]},Ce=0}function Qe(){Ye&&(je.paraNumber++,Te.paraStart=!0,Ye=!1),He&&(Te.startCharSize=Oe,Te.endCharSize=He,Oe=0),Te.width=Me,Ge.width?be(Te):Ue&&Ke(),Ve.push(Te),Te={words:[]},Me=0}function Ke(){Me>(je.maxWidth||0)&&(je.maxWidth=Me)}const Je=0,Ze=1,$e=2;const{top:ti,right:ei,bottom:ii,left:ni}=t.Direction4;function si(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 ai={getDrawData:function(e,i){"string"!=typeof e&&(e=String(e));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:l}=i;l&&(a?(n=l[ni],a-=l[ei]+l[ni]):i.autoSizeAlign||(n=l[ni]),o?(s=l[ti],o-=l[ti]+l[ii]):i.autoSizeAlign||(s=l[ti]));const d={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=h};return function(e,i,n){je=e,Ve=e.rows,Ge=e.bounds,Ue=!Ge.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=t.Platform,{width:h,height:l}=Ge;if(h||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Ye=!0,Fe=null,Oe=We=He=Ce=Me=0,ke={data:[]},Te={words:[]};for(let n=0,l=i.length;n<l;n++)Ie=i[n],"\n"===Ie?(Ce&&qe(),Te.paraEnd=!0,Qe(),Ye=!0):(De=ve(Ie),De===Be&&"none"!==o&&(Ie=xe(Ie,o,!Ce)),We=r.measureText(Ie).width,s&&(s<0&&(He=We),We+=s),ze=De===Le&&(Fe===Le||Fe===Be)||Fe===Le&&De!==Re,Ne=!(De!==Ee&&De!==Le||Fe!==Se&&Fe!==Re),Ae=Ye&&a?h-a:h,t&&h&&Me+Ce+We>Ae&&(e?(Ce&&qe(),Me&&Qe()):(Ne||(Ne=De===Be&&Fe==Re),ze||Ne||De===Pe||De===Ee||De===Le||Ce+We>Ae?(Ce&&qe(),Me&&Qe()):Me&&Qe()))," "===Ie&&!0!==Ye&&Me+Ce===0||(De===Pe?(" "===Ie&&Ce&&qe(),Xe(Ie,We),qe()):ze||Ne?(Ce&&qe(),Xe(Ie,We)):Xe(Ie,We)),Fe=De);Ce&&qe(),Me&&Qe(),Ve.length>0&&(Ve[Ve.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{je.paraNumber++,Me=r.measureText(t).width,Ve.push({x:a||0,text:t,width:Me,paraStart:!0}),Ue&&Ke()}))}(d,e,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":si(e,"x",t[ni]);break;case"right":si(e,"x",-t[ei])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":si(e,"y",t[ti]);break;case"bottom":si(e,"y",-t[ii])}}(l,d,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:h,verticalAlign:l,paraSpacing:d,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:p}=n,_=s*i.length+(d?d*(t.paraNumber-1):0),w=a;if(r&&_>p)_=Math.max(p,s),t.overflow=i.length;else if(p||c)switch(l){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let m,v,y,x=g||c?g:t.maxWidth;for(let a=0,l=i.length;a<l;a++){if(m=i[a],m.x=u,m.width<g||m.width>g&&!r)switch(h){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&d&&a>0&&(w+=d),m.y=w,w+=s,t.overflow>a&&w>_&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,y=m.width,o<0&&(m.width<0?(y=-m.width+e.fontSize+o,v-=y,y+=e.fontSize):y-=o),v<n.x&&(n.x=v),y>n.width&&(n.width=y),r&&g&&g<y&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=_}(d,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let h,l,d,c,u;s.forEach((t=>{t.words&&(d=o&&t.paraStart?o:0,l=i&&"justify"===a&&t.words.length>1?(i-t.width-d)/(t.words.length-1):0,c=r||t.isOverflow?Je:l>.01?Ze:$e,t.isOverflow&&!r&&(t.textMode=!0),c===$e?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,h=t.x,t.data=[],t.words.forEach((e=>{c===Ze?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&l&&(h+=l,t.width+=l)}))),t.words=null)}))}(d,i,a),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:a,overflow:o}=e;let{textOverflow:r}=i;if(a.splice(o),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?a:[a[o-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){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,a),"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 oi={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 a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}},{setPoint:ri,addPoint:hi,toBounds:li}=t.TwoPointBoundsHelper;const di={export(e,i,n){this.running=!0;const s=t.FileHelper.fileType(i),a=i.includes(".");return n=t.FileHelper.getExportOptions(n),function(e){ci||(ci=new t.TaskProcessor);return new Promise((t=>{ci.add((()=>Lt(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((o=>new Promise((r=>{const h=t=>{o(t),r(),this.running=!1},{toURL:l}=t.Platform,{download:d}=t.Platform.origin;if("json"===s)return a&&d(l(JSON.stringify(e.toJSON(n.json)),"text"),i),h({data:!!a||e.toJSON(n.json)});if("svg"===s)return a&&d(l(e.toSVG(),"svg"),i),h({data:!!a||e.toSVG()});const{leafer:c}=e;c?(ui(e),c.waitViewCompleted((()=>Lt(this,void 0,void 0,(function*(){let s,a,o=1,r=1;const{worldTransform:l,isLeafer:d,isFrame:u}=e,{slice:f,trim:g,onCanvas:p}=n,_=void 0===n.smooth?c.config.smooth:n.smooth,w=n.contextSettings||c.config.contextSettings,m=n.screenshot||e.isApp,v=d&&m&&void 0===n.fill?e.fill:n.fill,y=t.FileHelper.isOpaqueImage(i)||v,x=new t.Matrix;if(m)s=!0===m?d?c.canvas.bounds:e.worldRenderBounds:m;else{let t=n.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,t){case"inner":x.set(l);break;case"local":x.set(l).divide(e.localTransform),o/=e.scaleX,r/=e.scaleY;break;case"world":o=1,r=1;break;case"page":t=e.leafer;default:x.set(l).divide(e.getTransform(t));const i=t.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(n.scale,n.size,s,b);let B=n.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:L,y:E,width:R,height:S}=new t.Bounds(s).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-L,-E).withScale(1/o*b.scaleX,1/r*b.scaleY)};let k,T=t.Creator.canvas({width:Math.round(R),height:Math.round(S),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(k=e,k.__worldOpacity=0,e=c,P.bounds=T.bounds),T.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(T,P),e.fill=t}else e.__render(T,P);if(T.restore(),k&&k.__updateWorldOpacity(),g){a=function(e){const{width:i,height:n}=e.view,{data:s}=e.context.getImageData(0,0,i,n);let a,o,r,h=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=h%i,o=(h-a)/i,r?hi(r,a,o):ri(r={},a,o)),h++;const l=new t.Bounds;return li(r,l),l.scale(1/e.pixelRatio).ceil()}(T);const e=T,{width:i,height:n}=a,s={x:0,y:0,width:i,height:n,pixelRatio:B};T=t.Creator.canvas(s),T.copyWorld(e,a,s)}y&&T.fillWorld(T.bounds,v||"#FFFFFF","destination-over"),p&&p(T);const C="canvas"===i?T:yield T.export(i,n);h({data:C,width:T.pixelWidth,height:T.pixelHeight,renderBounds:s,trimBounds:a})}))))):h({data:!1})}))))}};let ci;function ui(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>ui(t)))}const fi=t.LeaferCanvasBase.prototype,gi=t.Debug.get("@leafer-ui/export");fi.export=function(e,i){const{quality:n,blob:s}=t.FileHelper.getExportOptions(i);return e.includes(".")?this.saveAs(e,n):s?this.toBlob(e,n):this.toDataURL(e,n)},fi.toBlob=function(e,i){return new Promise((n=>{t.Platform.origin.canvasToBolb(this.view,e,i).then((t=>{n(t)})).catch((t=>{gi.error(t),n(null)}))}))},fi.toDataURL=function(e,i){return t.Platform.origin.canvasToDataURL(this.view,e,i)},fi.saveAs=function(e,i){return new Promise((n=>{t.Platform.origin.canvasSaveAs(this.view,e,i).then((()=>{n(!0)})).catch((t=>{gi.error(t),n(!1)}))}))},Object.assign(i.TextConvert,ai),Object.assign(i.ColorConvert,oi),Object.assign(i.Paint,U),Object.assign(i.PaintImage,Rt),Object.assign(i.PaintGradient,Gt),Object.assign(i.Effect,Zt),Object.assign(i.Export,di),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new M(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&&o(0,wx)}catch(t){}"ios"===wx.getSystemInfoSync().platform&&(t.LeaferImage.prototype.getPattern=function(e,i,n,s){const a=t.Platform.canvas.createPattern(this.view,i),{width:o,height:r}=e;this.width===o&&this.height===r||(n||(n=t.MatrixHelper.get()),t.MatrixHelper.scale(n,o/this.width,r/this.height));try{n&&a.setTransform&&(a.setTransform(n),n=null)}catch(t){}return s&&(s.transform=n),a}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=M,exports.Layouter=v,exports.LeaferCanvas=n,exports.Renderer=x,exports.Selector=T,exports.Watcher=r,exports.useCanvas=o,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,a={width:i||e.width,height:n||e.height,pixelRatio:s};this.resize(a),this.context&&(this.viewSelect&&(t.Platform.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(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:a}=t.FileHelper;function o(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 o=e.toDataURL(s(a(i)),n);return o=o.substring(o.indexOf("64,")+3),t.Platform.origin.download(o,i)},download:(e,n)=>new Promise(((s,a)=>{let o;n.includes("/")||(n=`${i.env.USER_DATA_PATH}/`+n,o=!0);const r=i.getFileSystemManager();r.writeFile({filePath:n,data:e,encoding:"base64",success(){o?t.Platform.miniapp.saveToAlbum(n).then((()=>{r.unlink({filePath:n}),s()})):s()},fail(t){a(t)}})})),loadImage:e=>new Promise(((i,n)=>{const s=t.Platform.canvas.view.createImage();s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)})),noRepeat:"repeat-x"},t.Platform.miniapp={select:t=>i.createSelectorQuery().select(t),getBounds:t=>new Promise((e=>{t.boundingClientRect().exec((t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})}))})),getSizeView:t=>new Promise((e=>{t.fields({node:!0,size:!0}).exec((t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})}))})),saveToAlbum:t=>new Promise((e=>{i.getSetting({success:n=>{n.authSetting["scope.writePhotosAlbum"]?i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}}):i.authorize({scope:"scope.writePhotosAlbum",success:()=>{i.saveImageToPhotosAlbum({filePath:t,success(){e(!0)}})},fail:()=>{}})}})})),onWindowResize(t){i.onWindowResize(t)},offWindowResize(t){i.offWindowResize(t)}},t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new 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 v{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:a,LAYOUT:o,AFTER:r}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),n.emitEvent(new t.LayoutEvent(a,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(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(o,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:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,o,this.times)),v.fullLayout(i),o.forEach((t=>{t.setAfter()})),i.emitEvent(new t.LayoutEvent(s,o,this.times)),i.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),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 y=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,y.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,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;if(!e)return y.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),a=e.includes(this.target.__world),o=new t.Bounds(s);n.save(),a&&!t.Debug.showRepaint?n.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),n.clearWorld(s,!0),n.clipWorld(s,!0)),this.__render(s,a,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,!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||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)}}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,a=n.ignoreHittable||!1,o=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(o);const{list:r}=this.findList,h=this.getBestMatchLeaf(r,n.bottomList,a),l=a?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:a}=this.point,o={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=e.length;s<a;s++)if(i=e[s],(n||t.LeafHelper.worldHittable(i))&&(this.hitChild(i,o),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,a,o;for(let t=0,e=n.length;t<e;t++){s=n[t],a=n[t+1];for(let t=0,e=s.length;t<e&&(o=s.list[t],!a||!a.has(o));t++)i.add(o)}return i}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!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()}}const{Yes:L,NoAndSkip:E,YesAndSkip:R}=t.Answer,S={},P={},k={};class T{constructor(e,i){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.picker=new B(e,this),e&&this.__listenEvents()}getBy(e,i,n,s){switch(typeof e){case"number":const a=this.getByInnerId(e,i);return n?a:a?[a]:[];case"string":switch(e[0]){case"#":S.id=e.substring(1),e=S;break;case".":P.className=e.substring(1),e=P;break;default:k.tag=e,e=k}case"object":if(void 0!==e.id){const t=this.getById(e.id,i);return n?t:t?[t]:[]}if(e.tag){const{tag:s}=e,a=s instanceof Array;return this.getByMethod(a?this.methods.tags:this.methods.tag,i,n,a?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,i,n,e.className);case"function":return this.getByMethod(e,i,n,s)}}getByPoint(e,i,n){return"node"===t.Platform.name&&this.target&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,i,n)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,i){const n=this.idMap[e];return n&&t.LeafHelper.hasParent(n,i||this.target)?n:(this.eachFind(this.toChildren(i),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,n){const s=i?null:[];return this.eachFind(this.toChildren(e),t,s,n),s||this.findLeaf}eachFind(t,e,i,n){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,n),a===L||a===R){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&a<E&&this.eachFind(s.children,e,i,n)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>new T(t,e)}),t.Platform.layout=v.fullLayout;const C={convertTouch(t,i){const n=C.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 M 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=C.getTouch(t);this.pointerDown(C.convertTouch(t,this.getLocal(e,!0)))}onTouchMove(t){if(this.multiTouchMove(t),this.useMultiTouch)return;const e=C.getTouch(t);this.pointerMove(C.convertTouch(t,this.getLocal(e)))}onTouchEnd(t){this.multiTouchEnd();const e=C.getTouch(t);this.pointerUp(C.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 A(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;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,a)}function I(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?H(t,!0,e,i):O(e,i);break;case"inside":W("inside",t,s,e,i);break;case"outside":W("outside",t,s,e,i)}}function W(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?H(e,!0,n,r):O(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",A(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 O(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;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,a)}function H(t,e,n,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&i.PaintImage.checkImage(n,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?O(n,s):s.stroke(),s.restoreBlendMode()):e?O(n,s):s.stroke())}function D(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}const{getSpread:F,getOuterOf:z,getByMove:N,getIntersectData:Y}=t.BoundsHelper;let j;function G(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:a,blendMode:o,color:r,opacity:h}=e;return{type:a,blendMode:o,style:i.ColorConvert.string(r,h)};case"image":return i.PaintImage.image(n,t,e,s,!j||!j[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 U={compute:function(t,e){const n=e.__,s=[];let a,o=n.__input[t];o instanceof Array||(o=[o]),j=i.PaintImage.recycleImage(t,n);for(let i,n=0,a=o.length;n<a;n++)i=G(t,o[n],e),i&&s.push(i);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=a:n.__pixelStroke=a},fill:function(t,e,i){i.fillStyle=t,e.__.__font?A(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,n){let s;const{windingRule:a,__font:o}=e.__;for(let r=0,h=t.length;r<h;r++)s=t[r],s.image&&i.PaintImage.checkImage(e,n,s,!o)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restoreBlendMode()):o?A(e,n):a?n.fill(a):n.fill())},fillText:A,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)I(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&D(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 a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)I(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),H(t,!1,e,i),n.__useArrow&&D(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),H(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),H(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:I,drawTextStroke:O,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,h,{scaleX:l,scaleY:d}=s;if(l<0&&(l=-l),d<0&&(d=-d),e.bounds.includes(s))h=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Y(n?F(e.bounds,l===d?n*l:[n*d,n*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(h=e.getSameCanvas(),t.__renderShape(h,i),l*=u,d*=f),r=z(s,o),a=N(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:h,shapeBounds:r,scaleX:l,scaleY:d}}};let V={};const{get:X,rotateOfOuter:q,translate:Q,scaleOfOuter:K,scale:J,rotate:Z}=t.MatrixHelper;function $(t,e,i,n,s,a,o){const r=X();Q(r,e.x+i,e.y+n),J(r,s,a),o&&q(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function tt(t,e,i,n,s,a,o){const r=X();Q(r,e.x+i,e.y+n),s&&J(r,s,a),o&&Z(r,o),t.transform=r}function et(t,e,i,n,s,a,o,r,h,l){const d=X();if(h)if("center"===l)q(d,{x:i/2,y:n/2},h);else switch(Z(d,h),h){case 90:Q(d,n,0);break;case 180:Q(d,i,n);break;case 270:Q(d,0,i)}V.x=e.x+s,V.y=e.y+a,Q(d,V.x,V.y),o&&K(d,V,o,r),t.transform=d}const{get:it,translate:nt}=t.MatrixHelper,st=new t.Bounds,at={},ot={};function rt(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=ht(i,n,e)}function ht(e,i,n){let{width:s,height:a}=n;e.padding&&(i=st.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:h,offset:l,scale:d,size:c,rotation:u,repeat:f}=e,g=i.width===s&&i.height===a,p={mode:r},_="center"!==h&&(u||0)%180==90,w=_?a:s,m=_?s:a;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(d||c)&&(t.MathHelper.getScaleData(d,c,n,ot),v=ot.scaleX,y=ot.scaleY);else if(!g||u){const t=i.width/w,e=i.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(i.width-s*v)/2,b+=(i.height-a*y)/2}if(h){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),t.AlignHelper.toPoint(h,e,i,at,!0),x+=at.x,b+=at.y}switch(l&&(x+=l.x,b+=l.y),r){case"stretch":g||(s=i.width,a=i.height);break;case"normal":case"clip":(x||b||v||u)&&tt(p,i,x,b,v,y,u);break;case"repeat":(!g||v||u)&&et(p,i,s,a,x,b,v,y,u,h),f||(p.repeat="repeat");break;default:v&&$(p,i,x,b,v,y,u)}return p.transform||(i.x||i.y)&&(p.transform=it(),nt(p.transform,i.x,i.y)),v&&"stretch"!==r&&(p.scaleX=v,p.scaleY=y),p.width=s,p.height=a,o&&(p.opacity=o),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),p}let lt,dt=new t.Bounds;const{isSame:ct}=t.BoundsHelper;function ut(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||rt(s,n,i,a),!0}function ft(e,i){_t(e,t.ImageEvent.LOAD,i)}function gt(e,i){_t(e,t.ImageEvent.LOADED,i)}function pt(e,i,n){i.error=n,e.forceUpdate("surface"),_t(e,t.ImageEvent.ERROR,i)}function _t(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function wt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:mt,scale:vt,copy:yt}=t.MatrixHelper,{ceil:xt,abs:bt}=Math;function Bt(e,i,n){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||e.destroyed)return!1;{s=bt(s),a=bt(a);const{image:e,data:r}=i;let h,l,{width:d,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(l=mt(),yt(l,p),vt(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,d*=s,c*=a;const w=d*c;if(!_&&w>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)}w>m&&(h=Math.sqrt(w/m)),h&&(s/=h,a/=h,d/=h,c/=h),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=mt(),p&&yt(l,p)),vt(l,1/s,1/a));const v=e.getCanvas(xt(d)||1,xt(c)||1,g),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",l,i);return i.style=y,i.patternId=o,!0}}function Lt(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{h(n.next(t))}catch(t){a(t)}}function r(t){try{h(n.throw(t))}catch(t){a(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(o,r)}h((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Et}=Math;const Rt={image:function(e,i,n,s,a){let o,r;const h=t.ImageManager.get(n);return lt&&n===lt.paint&&ct(s,lt.boxBounds)?o=lt.leafPaint:(o={type:n.type,image:h},lt=h.use>1?{leafPaint:o,paint:n,boxBounds:dt.set(s)}:null),(a||h.loading)&&(r={image:h,attrName:i,attrValue:n}),h.ready?(ut(e,i,n,h,o,s),a&&(ft(e,r),gt(e,r))):h.error?a&&pt(e,r,h.error):(a&&(wt(e,!0),ft(e,r)),o.loadId=h.load((()=>{wt(e,!1),e.destroyed||(ut(e,i,n,h,o,s)&&(h.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),gt(e,r)),o.loadId=null}),(t=>{wt(e,!1),pt(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,s,a){const{scaleX:o,scaleY:r}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:h}=n;if(!s.data||s.patternId===o+"-"+r+"-"+h&&!i.Export.running)return!1;{const{data:l}=s;if(a)if(l.repeat)a=!1;else{let{width:e,height:n}=l;e*=Et(o)*h,n*=Et(r)*h,l.scaleX&&(e*=l.scaleX,n*=l.scaleY),a=e*n>t.Platform.image.maxCacheSize||i.Export.running}return a?(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.view,0,0,l.width,l.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?Bt(e,s,h):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>Lt(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&Bt(e,s,h),e.forceUpdate("surface")}))),300)),!1)}},createPattern:Bt,recycleImage:function(e,i){const n=i["_"+e];if(n instanceof Array){let s,a,o,r;for(let h=0,l=n.length;h<l;h++)s=n[h].image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=i.__input&&i.__input[e]||[],o instanceof Array||(o=[o])),s.unload(n[h].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:rt,getPatternData:ht,fillOrFitMode:$,clipMode:tt,repeatMode:et},{toPoint:St}=t.AroundHelper,Pt={},kt={};function Tt(t,e,n){if(e){let s;for(let a=0,o=e.length;a<o;a++)s=e[a],"string"==typeof s?t.addColorStop(a/(o-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}}const{getAngle:Ct,getDistance:Mt}=t.PointHelper,{get:At,rotateOfOuter:It,scaleOfOuter:Wt}=t.MatrixHelper,{toPoint:Ot}=t.AroundHelper,Ht={},Dt={};function Ft(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=Ct(e,i);a=At(),s?(Wt(a,e,o/r*(n||1),1),It(a,e,t+90)):(Wt(a,e,1,o/r*(n||1)),It(a,e,t))}return a}const{getDistance:zt}=t.PointHelper,{toPoint:Nt}=t.AroundHelper,Yt={},jt={};const Gt={linearGradient:function(e,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=e;St(n||"top",i,Pt),St(s||"bottom",i,kt);const h=t.Platform.canvas.createLinearGradient(Pt.x,Pt.y,kt.x,kt.y);Tt(h,e.stops,r);const l={type:a,style:h};return o&&(l.blendMode=o),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:h}=e;Ot(n||"center",i,Ht),Ot(s||"bottom",i,Dt);const l=t.Platform.canvas.createRadialGradient(Ht.x,Ht.y,0,Ht.x,Ht.y,Mt(Ht,Dt));Tt(l,e.stops,o);const d={type:a,style:l},c=Ft(i,Ht,Dt,h,!0);return c&&(d.transform=c),r&&(d.blendMode=r),d},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:h}=e;Nt(n||"center",i,Yt),Nt(s||"bottom",i,jt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Yt.x,Yt.y):t.Platform.canvas.createRadialGradient(Yt.x,Yt.y,0,Yt.x,Yt.y,zt(Yt,jt));Tt(l,e.stops,o);const d={type:a,style:l},c=Ft(i,Yt,jt,h||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),r&&(d.blendMode=r),d},getTransform:Ft},{copy:Ut,toOffsetOutBounds:Vt}=t.BoundsHelper,Xt={},qt={};function Qt(e,i,n,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(Ut(Xt,e.bounds),Xt.x+=i.x-o.x,Xt.y+=i.y-o.y,n){const{matrix:t}=s;Xt.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Xt.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Xt.width*=n,Xt.height*=n}e.copyWorld(s.canvas,e.bounds,Xt)}else n&&(Ut(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,o,n?Xt:i)}const{toOffsetOutBounds:Kt}=t.BoundsHelper,Jt={};const Zt={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Vt(l,qt),r.forEach(((r,p)=>{f.setWorldShadow(qt.offsetX+r.x*c,qt.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Qt(f,qt,s,i),n=l,r.box&&(f.restore(),f.save(),h&&(f.copyWorld(f,l,a,"copy"),n=a),h?f.copyWorld(h,a,a,"destination-out"):f.copyWorld(i.canvas,d,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:h,bounds:l,shapeBounds:d,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Kt(l,Jt),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Jt.offsetX+r.x*c,Jt.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Qt(f,Jt,s,i),f.restore(),h?(f.copyWorld(f,l,a,"copy"),f.copyWorld(h,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,d,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:$t}=t.LeafBoundsHelper;function te(t,e,i,n,s,a){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,a);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,a,o,r;const{children:h}=this;for(let l=0,d=h.length;l<d;l++)i=h[l],r=i.__.mask,r&&(o&&(te(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=ee(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=ee(t)),s||(s=ee(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||$t(i,e)||i.__render(s||t,e);te(this,o,t,s,n,a)};const ne=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",se=ne+"_#~&*+\\=|≮≯≈≠=…",ae=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function oe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const re=oe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),he=oe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),le=oe(ne),de=oe(se),ce=oe("- —/~|┆·");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:ge,Before:pe,After:_e,Symbol:we,Break:me}=ue;function ve(t){return re[t]?fe:ce[t]?me:he[t]?pe:le[t]?_e:de[t]?we:ae.test(t)?ge:fe}const ye={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function 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}=ye,{Letter:Be,Single:Le,Before:Ee,After:Re,Symbol:Se,Break:Pe}=ue;let ke,Te,Ce,Me,Ae,Ie,We,Oe,He,De,Fe,ze,Ne,Ye,je,Ge,Ue,Ve=[];function Xe(t,e){He&&!Oe&&(Oe=He),ke.data.push({char:t,width:e}),Ce+=e}function qe(){Me+=Ce,ke.width=Ce,Te.words.push(ke),ke={data:[]},Ce=0}function Qe(){Ye&&(je.paraNumber++,Te.paraStart=!0,Ye=!1),He&&(Te.startCharSize=Oe,Te.endCharSize=He,Oe=0),Te.width=Me,Ge.width?be(Te):Ue&&Ke(),Ve.push(Te),Te={words:[]},Me=0}function Ke(){Me>(je.maxWidth||0)&&(je.maxWidth=Me)}const Je=0,Ze=1,$e=2;const{top:ti,right:ei,bottom:ii,left:ni}=t.Direction4;function si(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 ai={getDrawData:function(e,i){"string"!=typeof e&&(e=String(e));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:h,__padding:l}=i;l&&(a?(n=l[ni],a-=l[ei]+l[ni]):i.autoSizeAlign||(n=l[ni]),o?(s=l[ti],o-=l[ti]+l[ii]):i.autoSizeAlign||(s=l[ti]));const d={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=h};return function(e,i,n){je=e,Ve=e.rows,Ge=e.bounds,Ue=!Ge.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=t.Platform,{width:h,height:l}=Ge;if(h||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Ye=!0,Fe=null,Oe=We=He=Ce=Me=0,ke={data:[]},Te={words:[]};for(let n=0,l=i.length;n<l;n++)Ie=i[n],"\n"===Ie?(Ce&&qe(),Te.paraEnd=!0,Qe(),Ye=!0):(De=ve(Ie),De===Be&&"none"!==o&&(Ie=xe(Ie,o,!Ce)),We=r.measureText(Ie).width,s&&(s<0&&(He=We),We+=s),ze=De===Le&&(Fe===Le||Fe===Be)||Fe===Le&&De!==Re,Ne=!(De!==Ee&&De!==Le||Fe!==Se&&Fe!==Re),Ae=Ye&&a?h-a:h,t&&h&&Me+Ce+We>Ae&&(e?(Ce&&qe(),Me&&Qe()):(Ne||(Ne=De===Be&&Fe==Re),ze||Ne||De===Pe||De===Ee||De===Le||Ce+We>Ae?(Ce&&qe(),Me&&Qe()):Me&&Qe()))," "===Ie&&!0!==Ye&&Me+Ce===0||(De===Pe?(" "===Ie&&Ce&&qe(),Xe(Ie,We),qe()):ze||Ne?(Ce&&qe(),Xe(Ie,We)):Xe(Ie,We)),Fe=De);Ce&&qe(),Me&&Qe(),Ve.length>0&&(Ve[Ve.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{je.paraNumber++,Me=r.measureText(t).width,Ve.push({x:a||0,text:t,width:Me,paraStart:!0}),Ue&&Ke()}))}(d,e,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":si(e,"x",t[ni]);break;case"right":si(e,"x",-t[ei])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":si(e,"y",t[ti]);break;case"bottom":si(e,"y",-t[ii])}}(l,d,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:h,verticalAlign:l,paraSpacing:d,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:p}=n,_=s*i.length+(d?d*(t.paraNumber-1):0),w=a;if(r&&_>p)_=Math.max(p,s),t.overflow=i.length;else if(p||c)switch(l){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let m,v,y,x=g||c?g:t.maxWidth;for(let a=0,l=i.length;a<l;a++){if(m=i[a],m.x=u,m.width<g||m.width>g&&!r)switch(h){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&d&&a>0&&(w+=d),m.y=w,w+=s,t.overflow>a&&w>_&&(m.isOverflow=!0,t.overflow=a+1),v=m.x,y=m.width,o<0&&(m.width<0?(y=-m.width+e.fontSize+o,v-=y,y+=e.fontSize):y-=o),v<n.x&&(n.x=v),y>n.width&&(n.width=y),r&&g&&g<y&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=_}(d,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let h,l,d,c,u;s.forEach((t=>{t.words&&(d=o&&t.paraStart?o:0,l=i&&"justify"===a&&t.words.length>1?(i-t.width-d)/(t.words.length-1):0,c=r||t.isOverflow?Je:l>.01?Ze:$e,t.isOverflow&&!r&&(t.textMode=!0),c===$e?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,h=t.x,t.data=[],t.words.forEach((e=>{c===Ze?(u={char:"",x:h},h=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,h,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):h=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,h,t.data,t.isOverflow),!t.paraEnd&&l&&(h+=l,t.width+=l)}))),t.words=null)}))}(d,i,a),d.overflow&&function(e,i,n,s){if(!s)return;const{rows:a,overflow:o}=e;let{textOverflow:r}=i;if(a.splice(o),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?a:[a[o-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){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,a),"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 oi={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 a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}},{setPoint:ri,addPoint:hi,toBounds:li}=t.TwoPointBoundsHelper;const di={export(e,i,n){this.running=!0;const s=t.FileHelper.fileType(i),a=i.includes(".");return n=t.FileHelper.getExportOptions(n),function(e){ci||(ci=new t.TaskProcessor);return new Promise((t=>{ci.add((()=>Lt(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((o=>new Promise((r=>{const h=t=>{o(t),r(),this.running=!1},{toURL:l}=t.Platform,{download:d}=t.Platform.origin;if("json"===s)return a&&d(l(JSON.stringify(e.toJSON(n.json)),"text"),i),h({data:!!a||e.toJSON(n.json)});if("svg"===s)return a&&d(l(e.toSVG(),"svg"),i),h({data:!!a||e.toSVG()});const{leafer:c}=e;c?(ui(e),c.waitViewCompleted((()=>Lt(this,void 0,void 0,(function*(){let s,a,o=1,r=1;const{worldTransform:l,isLeafer:d,isFrame:u}=e,{slice:f,trim:g,onCanvas:p}=n,_=void 0===n.smooth?c.config.smooth:n.smooth,w=n.contextSettings||c.config.contextSettings,m=n.screenshot||e.isApp,v=d&&m&&void 0===n.fill?e.fill:n.fill,y=t.FileHelper.isOpaqueImage(i)||v,x=new t.Matrix;if(m)s=!0===m?d?c.canvas.bounds:e.worldRenderBounds:m;else{let t=n.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,t){case"inner":x.set(l);break;case"local":x.set(l).divide(e.localTransform),o/=e.scaleX,r/=e.scaleY;break;case"world":o=1,r=1;break;case"page":t=e.leafer;default:x.set(l).divide(e.getTransform(t));const i=t.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(n.scale,n.size,s,b);let B=n.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:L,y:E,width:R,height:S}=new t.Bounds(s).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-L,-E).withScale(1/o*b.scaleX,1/r*b.scaleY)};let k,T=t.Creator.canvas({width:Math.round(R),height:Math.round(S),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(k=e,k.__worldOpacity=0,e=c,P.bounds=T.bounds),T.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(T,P),e.fill=t}else e.__render(T,P);if(T.restore(),k&&k.__updateWorldOpacity(),g){a=function(e){const{width:i,height:n}=e.view,{data:s}=e.context.getImageData(0,0,i,n);let a,o,r,h=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=h%i,o=(h-a)/i,r?hi(r,a,o):ri(r={},a,o)),h++;const l=new t.Bounds;return li(r,l),l.scale(1/e.pixelRatio).ceil()}(T);const e=T,{width:i,height:n}=a,s={x:0,y:0,width:i,height:n,pixelRatio:B};T=t.Creator.canvas(s),T.copyWorld(e,a,s)}y&&T.fillWorld(T.bounds,v||"#FFFFFF","destination-over"),p&&p(T);const C="canvas"===i?T:yield T.export(i,n);h({data:C,width:T.pixelWidth,height:T.pixelHeight,renderBounds:s,trimBounds:a})}))))):h({data:!1})}))))}};let ci;function ui(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>ui(t)))}const fi=t.LeaferCanvasBase.prototype,gi=t.Debug.get("@leafer-ui/export");fi.export=function(e,i){const{quality:n,blob:s}=t.FileHelper.getExportOptions(i);return e.includes(".")?this.saveAs(e,n):s?this.toBlob(e,n):this.toDataURL(e,n)},fi.toBlob=function(e,i){return new Promise((n=>{t.Platform.origin.canvasToBolb(this.view,e,i).then((t=>{n(t)})).catch((t=>{gi.error(t),n(null)}))}))},fi.toDataURL=function(e,i){return t.Platform.origin.canvasToDataURL(this.view,e,i)},fi.saveAs=function(e,i){return new Promise((n=>{t.Platform.origin.canvasSaveAs(this.view,e,i).then((()=>{n(!0)})).catch((t=>{gi.error(t),n(!1)}))}))},Object.assign(i.TextConvert,ai),Object.assign(i.ColorConvert,oi),Object.assign(i.Paint,U),Object.assign(i.PaintImage,Rt),Object.assign(i.PaintGradient,Gt),Object.assign(i.Effect,Zt),Object.assign(i.Export,di),Object.assign(t.Creator,{interaction:(t,e,i,n)=>new M(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&&o(0,wx)}catch(t){}"ios"===wx.getSystemInfoSync().platform&&(t.LeaferImage.prototype.getPattern=function(e,i,n,s){const a=t.Platform.canvas.createPattern(this.view,i),{width:o,height:r}=e;this.width===o&&this.height===r||(n||(n=t.MatrixHelper.get()),t.MatrixHelper.scale(n,o/this.width,r/this.height));try{n&&a.setTransform&&(a.setTransform(n),n=null)}catch(t){}return s&&(s.transform=n),a}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Interaction=M,exports.Layouter=v,exports.LeaferCanvas=n,exports.Renderer=x,exports.Selector=T,exports.Watcher=r,exports.useCanvas=o,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]}})}));
|