@leafer-ui/worker 1.0.6 → 1.0.7
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/worker.cjs +7 -5
- package/dist/worker.esm.js +7 -5
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +18 -17
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +18 -17
- package/dist/worker.module.min.js +1 -1
- package/package.json +9 -9
package/dist/worker.cjs
CHANGED
|
@@ -721,7 +721,8 @@ class Picker {
|
|
|
721
721
|
path.add(leaf);
|
|
722
722
|
leaf = leaf.parent;
|
|
723
723
|
}
|
|
724
|
-
|
|
724
|
+
if (this.target)
|
|
725
|
+
path.add(this.target);
|
|
725
726
|
return path;
|
|
726
727
|
}
|
|
727
728
|
getHitablePath(leaf) {
|
|
@@ -807,8 +808,8 @@ class Selector {
|
|
|
807
808
|
this.innerIdMap = {};
|
|
808
809
|
this.idMap = {};
|
|
809
810
|
this.methods = {
|
|
810
|
-
id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
|
|
811
|
-
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
|
|
811
|
+
id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
|
|
812
|
+
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
|
|
812
813
|
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
813
814
|
tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
|
|
814
815
|
tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
|
|
@@ -817,7 +818,8 @@ class Selector {
|
|
|
817
818
|
if (userConfig)
|
|
818
819
|
this.config = core.DataHelper.default(userConfig, this.config);
|
|
819
820
|
this.picker = new Picker(target, this);
|
|
820
|
-
|
|
821
|
+
if (target)
|
|
822
|
+
this.__listenEvents();
|
|
821
823
|
}
|
|
822
824
|
getBy(condition, branch, one, options) {
|
|
823
825
|
switch (typeof condition) {
|
|
@@ -852,7 +854,7 @@ class Selector {
|
|
|
852
854
|
}
|
|
853
855
|
}
|
|
854
856
|
getByPoint(hitPoint, hitRadius, options) {
|
|
855
|
-
if (core.Platform.name === 'node')
|
|
857
|
+
if (core.Platform.name === 'node' && this.target)
|
|
856
858
|
this.target.emit(core.LayoutEvent.CHECK_UPDATE);
|
|
857
859
|
return this.picker.getByPoint(hitPoint, hitRadius, options);
|
|
858
860
|
}
|
package/dist/worker.esm.js
CHANGED
|
@@ -722,7 +722,8 @@ class Picker {
|
|
|
722
722
|
path.add(leaf);
|
|
723
723
|
leaf = leaf.parent;
|
|
724
724
|
}
|
|
725
|
-
|
|
725
|
+
if (this.target)
|
|
726
|
+
path.add(this.target);
|
|
726
727
|
return path;
|
|
727
728
|
}
|
|
728
729
|
getHitablePath(leaf) {
|
|
@@ -808,8 +809,8 @@ class Selector {
|
|
|
808
809
|
this.innerIdMap = {};
|
|
809
810
|
this.idMap = {};
|
|
810
811
|
this.methods = {
|
|
811
|
-
id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
|
|
812
|
-
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
|
|
812
|
+
id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
|
|
813
|
+
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
|
|
813
814
|
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
814
815
|
tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
|
|
815
816
|
tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
|
|
@@ -818,7 +819,8 @@ class Selector {
|
|
|
818
819
|
if (userConfig)
|
|
819
820
|
this.config = DataHelper.default(userConfig, this.config);
|
|
820
821
|
this.picker = new Picker(target, this);
|
|
821
|
-
|
|
822
|
+
if (target)
|
|
823
|
+
this.__listenEvents();
|
|
822
824
|
}
|
|
823
825
|
getBy(condition, branch, one, options) {
|
|
824
826
|
switch (typeof condition) {
|
|
@@ -853,7 +855,7 @@ class Selector {
|
|
|
853
855
|
}
|
|
854
856
|
}
|
|
855
857
|
getByPoint(hitPoint, hitRadius, options) {
|
|
856
|
-
if (Platform.name === 'node')
|
|
858
|
+
if (Platform.name === 'node' && this.target)
|
|
857
859
|
this.target.emit(LayoutEvent.CHECK_UPDATE);
|
|
858
860
|
return this.picker.getByPoint(hitPoint, hitRadius, options);
|
|
859
861
|
}
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,defineKey as a,FileHelper as o,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,Bounds as _,LeafBoundsHelper as p,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Answer as k,MatrixHelper as R,MathHelper as S,AlignHelper as E,ImageEvent as L,AroundHelper as M,PointHelper as A,Direction4 as W,TwoPointBoundsHelper as C,TaskProcessor as O,Matrix as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionBase as I,HitCanvasManager as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as D,ColorConvert as F,PaintGradient as Y,Export as N,Group as X,TextConvert as G,Paint as U,Effect as j}from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__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),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:z}=o;function V(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:z(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:z(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new H(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},a(e,"devicePixelRatio",{get:()=>1});const{userAgent:q}=navigator;q.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):q.indexOf("Safari")>-1&&-1===q.indexOf("Chrome")&&(e.fullImageShadow=!0),q.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):q.indexOf("Mac")>-1?e.os="Mac":q.indexOf("Linux")>-1&&(e.os="Linux");class Q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=d.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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.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:J,updateBounds:Z,updateAllWorldOpacity:K}=f,{pushAllChildBranch:$,pushAllParent:tt}=g;const{worldBounds:et}=p,it={x:0,y:0,width:1e5,height:1e5};class nt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,et)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(it):this.afterBounds.setListWithFn(t,et),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:st,updateAllChange:at}=f,ot=w.get("Layouter");class rt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.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(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&$(t,e),tt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),tt(t,e)))}))}(n,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||Z(n[t])}Z(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&K(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),rt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){st(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(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_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=w.get("Renderer");class lt{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=d.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,dt.log(e.innerName,"---\x3e");try{e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.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 dt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),a=new _(n);i.save(),s&&!w.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,a),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),w.showHitView&&this.renderHitView(n),w.showBoundsView&&this.renderBoundsView(n),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 _;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(l.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 _(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 _(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||dt.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 l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.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:ht}=B;class ct{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,a),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 r;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}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||ht(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:ut,NoAndSkip:ft,YesAndSkip:gt}=k,_t={},pt={},wt={};class yt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(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=d.default(e,this.config)),this.picker=new ct(t,this),this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return i?s:s?[s]:[];case"string":switch(t[0]){case"#":_t.id=t.substring(1),t=_t;break;case".":pt.className=t.substring(1),t=pt;break;default:wt.tag=t,t=wt}case"object":if(void 0!==t.id){const n=this.getById(t.id,e);return i?n:n?[n]:[]}if(t.tag){const{tag:n}=t,s=n instanceof Array;return this.getByMethod(s?this.methods.tags:this.methods.tag,e,i,s?d.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,n){return"node"===e.name&&this.target.emit(m.CHECK_UPDATE),this.picker.getByPoint(t,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(t,e){const i=this.idMap[t];return i&&f.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,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===ut||a===gt){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&a<ft&&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_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(u.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={})}}function mt(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 vt(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?Bt(t,!0,e,i):bt(e,i);break;case"inside":xt("inside",t,s,e,i);break;case"outside":xt("outside",t,s,e,i)}}function xt(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?Bt(e,!0,n,r):bt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",mt(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 bt(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 Bt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&D.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?bt(i,n):n.stroke(),n.restoreBlendMode()):e?bt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new Q(t,e),layouter:(t,e)=>new rt(t,e),renderer:(t,e,i)=>new lt(t,e,i),selector:(t,e)=>new yt(t,e)}),e.layout=rt.fullLayout;const{getSpread:kt,getOuterOf:Rt,getByMove:St,getIntersectData:Et}=B;let Lt;function Mt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:F.string(o,r)};case"image":return D.image(i,t,e,n,!Lt||!Lt[e.url]);case"linear":return Y.linearGradient(e,n);case"radial":return Y.radialGradient(e,n);case"angular":return Y.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:F.string(e)}:void 0}}const At={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Lt=D.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=Mt(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?mt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&D.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?mt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?mt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?mt(e,i):s?i.fill(s):i.fill())},fillText:mt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)vt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke();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)vt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),Bt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),Bt(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),Bt(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:vt,drawTextStroke:bt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Et(n?kt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=Rt(s,o),a=St(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:d,shapeBounds:r,scaleX:l,scaleY:h}}};let Wt={};const{get:Ct,rotateOfOuter:Ot,translate:Tt,scaleOfOuter:It,scale:Pt,rotate:Dt}=R;function Ft(t,e,i,n,s,a,o){const r=Ct();Tt(r,e.x+i,e.y+n),Pt(r,s,a),o&&Ot(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Yt(t,e,i,n,s,a,o){const r=Ct();Tt(r,e.x+i,e.y+n),s&&Pt(r,s,a),o&&Dt(r,o),t.transform=r}function Nt(t,e,i,n,s,a,o,r,d,l){const h=Ct();if(d)if("center"===l)Ot(h,{x:i/2,y:n/2},d);else switch(Dt(h,d),d){case 90:Tt(h,n,0);break;case 180:Tt(h,i,n);break;case 270:Tt(h,0,i)}Wt.x=e.x+s,Wt.y=e.y+a,Tt(h,Wt.x,Wt.y),o&&It(h,Wt,o,r),t.transform=h}const{get:Xt,translate:Gt}=R,Ut=new _,jt={},Ht={};function zt(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=Vt(i,n,e)}function Vt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Ut.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:a,mode:o,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u}=t,f=e.width===n&&e.height===s,g={mode:o},_="center"!==r&&(c||0)%180==90,p=_?s:n,w=_?n:s;let y,m,v=0,x=0;if(o&&"cover"!==o&&"fit"!==o)(l||h)&&(S.getScaleData(l,h,i,Ht),y=Ht.scaleX,m=Ht.scaleY);else if(!f||c){const t=e.width/p,i=e.height/w;y=m="fit"===o?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:p,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,jt,!0),v+=jt.x,x+=jt.y}switch(d&&(v+=d.x,x+=d.y),o){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||c)&&Yt(g,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Nt(g,e,n,s,v,x,y,m,c,r),u||(g.repeat="repeat");break;default:y&&Ft(g,e,v,x,y,m,c)}return g.transform||(e.x||e.y)&&(g.transform=Xt(),Gt(g.transform,e.x,e.y)),y&&"stretch"!==o&&(g.scaleX=y,g.scaleY=m),g.width=n,g.height=s,a&&(g.opacity=a),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let qt,Qt=new _;const{isSame:Jt}=B;function Zt(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||zt(s,n,i,a),!0}function Kt(t,e){ee(t,L.LOAD,e)}function $t(t,e){ee(t,L.LOADED,e)}function te(t,e,i){e.error=i,t.forceUpdate("surface"),ee(t,L.ERROR,e)}function ee(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function ie(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ne,scale:se,copy:ae}=R,{ceil:oe,abs:re}=Math;function de(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=re(s),a=re(a);const{image:t,data:r}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(l=ne(),ae(l,_),se(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,h*=s,c*=a;const w=h*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(l||(l=ne(),_&&ae(l,_)),se(l,1/s,1/a));const m=t.getCanvas(oe(h)||1,oe(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=o,!0}}function le(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:he}=Math;const ce={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return qt&&i===qt.paint&&Jt(n,qt.boxBounds)?a=qt.leafPaint:(a={type:i.type,image:r},qt=r.use>1?{leafPaint:a,paint:i,boxBounds:Qt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Zt(t,e,i,r,a,n),s&&(Kt(t,o),$t(t,o))):r.error?s&&te(t,o,r.error):(s&&(ie(t,!0),Kt(t,o)),a.loadId=r.load((()=>{ie(t,!1),t.destroyed||(Zt(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),$t(t,o)),a.loadId=null}),(e=>{ie(t,!1),te(t,o,e),a.loadId=null}))),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===a+"-"+o+"-"+r&&!N.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=he(a)*r,i*=he(o)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||N.running}return s?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||N.running?de(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>le(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&de(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:de,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,x.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null},createData:zt,getPatternData:Vt,fillOrFitMode:Ft,clipMode:Yt,repeatMode:Nt},{toPoint:ue}=M,fe={},ge={};function _e(t,e,i){if(e){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),F.string(n,i)):t.addColorStop(n.offset,F.string(n.color,i))}}const{getAngle:pe,getDistance:we}=A,{get:ye,rotateOfOuter:me,scaleOfOuter:ve}=R,{toPoint:xe}=M,be={},Be={};function ke(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=pe(e,i);a=ye(),s?(ve(a,e,o/r*(n||1),1),me(a,e,t+90)):(ve(a,e,1,o/r*(n||1)),me(a,e,t))}return a}const{getDistance:Re}=A,{toPoint:Se}=M,Ee={},Le={};const Me={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;ue(n||"top",i,fe),ue(s||"bottom",i,ge);const d=e.canvas.createLinearGradient(fe.x,fe.y,ge.x,ge.y);_e(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;xe(n||"center",i,be),xe(s||"bottom",i,Be);const l=e.canvas.createRadialGradient(be.x,be.y,0,be.x,be.y,we(be,Be));_e(l,t.stops,o);const h={type:a,style:l},c=ke(i,be,Be,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;Se(n||"center",i,Ee),Se(s||"bottom",i,Le);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ee.x,Ee.y):e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,Re(Ee,Le));_e(l,t.stops,o);const h={type:a,style:l},c=ke(i,Ee,Le,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:ke},{copy:Ae,toOffsetOutBounds:We}=B,Ce={},Oe={};function Te(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Ae(Ce,t.bounds),Ce.x+=i.x-o.x,Ce.y+=i.y-o.y,n){const{matrix:t}=s;Ce.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Ce.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Ce.width*=n,Ce.height*=n}t.copyWorld(s.canvas,t.bounds,Ce)}else n&&(Ae(Ce,i),Ce.x-=i.width/2*(n-1),Ce.y-=i.height/2*(n-1),Ce.width*=n,Ce.height*=n),t.copyWorld(s.canvas,o,n?Ce:i)}const{toOffsetOutBounds:Ie}=B,Pe={};const De={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;We(l,Oe),r.forEach(((r,_)=>{f.setWorldShadow(Oe.offsetX+r.x*c,Oe.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Te(f,Oe,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<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:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ie(l,Pe),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Pe.offsetX+r.x*c,Pe.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Te(f,Pe,s,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,h,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&&_<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:Fe}=p;function Ye(t,e,i,n,s,a){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Xe(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Xe(t,i,n,a);break;case"path":i.restore()}}function Ne(t){return t.getSameCanvas(!1,!0)}function Xe(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}X.prototype.__renderMask=function(t,e){let i,n,s,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(o&&(Ye(this,o,t,s,n,a),n=s=null),"path"===i.__.mask?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ne(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="alpha",n||(n=Ne(t)),s||(s=Ne(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Fe(i,e)||i.__render(s||t,e);Ye(this,o,t,s,n,a)};const Ge=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ue=Ge+"_#~&*+\\=|≮≯≈≠=…",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 He(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ze=He("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ve=He("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),qe=He(Ge),Qe=He(Ue),Je=He("- —/~|┆·");var Ze;!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"}(Ze||(Ze={}));const{Letter:Ke,Single:$e,Before:ti,After:ei,Symbol:ii,Break:ni}=Ze;function si(t){return ze[t]?Ke:Je[t]?ni:Ve[t]?ti:qe[t]?ei:Qe[t]?ii:je.test(t)?$e:Ke}const ai={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 oi(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:ri}=ai,{Letter:di,Single:li,Before:hi,After:ci,Symbol:ui,Break:fi}=Ze;let gi,_i,pi,wi,yi,mi,vi,xi,bi,Bi,ki,Ri,Si,Ei,Li,Mi,Ai,Wi=[];function Ci(t,e){bi&&!xi&&(xi=bi),gi.data.push({char:t,width:e}),pi+=e}function Oi(){wi+=pi,gi.width=pi,_i.words.push(gi),gi={data:[]},pi=0}function Ti(){Ei&&(Li.paraNumber++,_i.paraStart=!0,Ei=!1),bi&&(_i.startCharSize=xi,_i.endCharSize=bi,xi=0),_i.width=wi,Mi.width?ri(_i):Ai&&Ii(),Wi.push(_i),_i={words:[]},wi=0}function Ii(){wi>(Li.maxWidth||0)&&(Li.maxWidth=wi)}const Pi=0,Di=1,Fi=2;const{top:Yi,right:Ni,bottom:Xi,left:Gi}=W;function Ui(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 ji={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a?(n=l[Gi],a-=l[Ni]+l[Gi]):i.autoSizeAlign||(n=l[Gi]),o?(s=l[Yi],o-=l[Yi]+l[Xi]):i.autoSizeAlign||(s=l[Yi]));const h={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Li=t,Wi=t.rows,Mi=t.bounds,Ai=!Mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:l}=Mi;if(d||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Ei=!0,ki=null,xi=vi=bi=pi=wi=0,gi={data:[]},_i={words:[]};for(let n=0,l=i.length;n<l;n++)mi=i[n],"\n"===mi?(pi&&Oi(),_i.paraEnd=!0,Ti(),Ei=!0):(Bi=si(mi),Bi===di&&"none"!==o&&(mi=oi(mi,o,!pi)),vi=r.measureText(mi).width,s&&(s<0&&(bi=vi),vi+=s),Ri=Bi===li&&(ki===li||ki===di)||ki===li&&Bi!==ci,Si=!(Bi!==hi&&Bi!==li||ki!==ui&&ki!==ci),yi=Ei&&a?d-a:d,t&&d&&wi+pi+vi>yi&&(e?(pi&&Oi(),wi&&Ti()):(Si||(Si=Bi===di&&ki==ci),Ri||Si||Bi===fi||Bi===hi||Bi===li||pi+vi>yi?(pi&&Oi(),wi&&Ti()):wi&&Ti()))," "===mi&&!0!==Ei&&wi+pi===0||(Bi===fi?(" "===mi&&pi&&Oi(),Ci(mi,vi),Oi()):Ri||Si?(pi&&Oi(),Ci(mi,vi)):Ci(mi,vi)),ki=Bi);pi&&Oi(),wi&&Ti(),Wi.length>0&&(Wi[Wi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Li.paraNumber++,wi=r.measureText(t).width,Wi.push({x:a||0,text:t,width:wi,paraStart:!0}),Ai&&Ii()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Ui(e,"x",t[Gi]);break;case"right":Ui(e,"x",-t[Ni])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ui(e,"y",t[Yi]);break;case"bottom":Ui(e,"y",-t[Xi])}}(l,h,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:_}=n,p=s*i.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&p>_)p=Math.max(_,s),t.overflow=i.length;else if(_||c)switch(l){case"middle":f+=(_-p)/2;break;case"bottom":f+=_-p}w+=f;let y,m,v,x=g||c?g:t.maxWidth;for(let a=0,l=i.length;a<l;a++){if(y=i[a],y.x=u,y.width<g||y.width>g&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=s,t.overflow>a&&w>p&&(y.isOverflow=!0,t.overflow=a+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<n.x&&(n.x=m),v>n.width&&(n.width=v),r&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=p}(h,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,l=i&&"justify"===a&&t.words.length>1?(i-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Pi:l>.01?Di:Fi,t.isOverflow&&!r&&(t.textMode=!0),c===Fi?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Di?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,h=n+s-l;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<h));n--){if(d<h&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,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}}(h,i),h}};const Hi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!F.object)return t;t=F.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}},{setPoint:zi,addPoint:Vi,toBounds:qi}=C;const Qi={export(t,i,s){this.running=!0;const a=o.fileType(i),r=i.includes(".");return s=o.getExportOptions(s),function(t){Ji||(Ji=new O);return new Promise((e=>{Ji.add((()=>le(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((d=>new Promise((l=>{const h=t=>{d(t),l(),this.running=!1},{toURL:c}=e,{download:u}=e.origin;if("json"===a)return r&&u(c(JSON.stringify(t.toJSON(s.json)),"text"),i),h({data:!!r||t.toJSON(s.json)});if("svg"===a)return r&&u(c(t.toSVG(),"svg"),i),h({data:!!r||t.toSVG()});const{leafer:f}=t;f?(Zi(t),f.waitViewCompleted((()=>le(this,void 0,void 0,(function*(){let e,a,r=1,d=1;const{worldTransform:l,isLeafer:c,isFrame:u}=t,{slice:g,trim:p,onCanvas:w}=s,y=void 0===s.smooth?f.config.smooth:s.smooth,m=s.contextSettings||f.config.contextSettings,v=s.screenshot||t.isApp,x=c&&v&&void 0===s.fill?t.fill:s.fill,b=o.isOpaqueImage(i)||x,B=new T;if(v)e=!0===v?c?f.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(c?"inner":"local");switch(r=l.scaleX,d=l.scaleY,i){case"inner":B.set(l);break;case"local":B.set(l).divide(t.localTransform),r/=t.scaleX,d/=t.scaleY;break;case"world":r=1,d=1;break;case"page":i=t.leafer;default:B.set(l).divide(t.getTransform(i));const e=i.worldTransform;r/=r/e.scaleX,d/=d/e.scaleY}e=t.getBounds("render",i)}const k={scaleX:1,scaleY:1};S.getScaleData(s.scale,s.size,e,k);let R=s.pixelRatio||1;t.isApp&&(k.scaleX*=R,k.scaleY*=R,R=t.app.pixelRatio);const{x:E,y:L,width:M,height:A}=new _(e).scale(k.scaleX,k.scaleY),W={matrix:B.scale(1/k.scaleX,1/k.scaleY).invert().translate(-E,-L).withScale(1/r*k.scaleX,1/d*k.scaleY)};let C,O=n.canvas({width:Math.round(M),height:Math.round(A),pixelRatio:R,smooth:y,contextSettings:m});if(g&&(C=t,C.__worldOpacity=0,t=f,W.bounds=O.bounds),O.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(O,W),t.fill=e}else t.__render(O,W);if(O.restore(),C&&C.__updateWorldOpacity(),p){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?Vi(o,s,a):zi(o={},s,a)),r++;const d=new _;return qi(o,d),d.scale(1/t.pixelRatio).ceil()}(O);const t=O,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:R};O=n.canvas(s),O.copyWorld(t,a,s)}b&&O.fillWorld(O.bounds,x||"#FFFFFF","destination-over"),w&&w(O);const I="canvas"===i?O:yield O.export(i,s);h({data:I,width:O.pixelWidth,height:O.pixelHeight,renderBounds:e,trimBounds:a})}))))):h({data:!1})}))))}};let Ji;function Zi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Zi(t)))}const Ki=t.prototype,$i=w.get("@leafer-ui/export");Ki.export=function(t,e){const{quality:i,blob:n}=o.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Ki.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{$i.error(t),n(null)}))}))},Ki.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Ki.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{$i.error(t),n(!1)}))}))},Object.assign(G,ji),Object.assign(F,Hi),Object.assign(U,At),Object.assign(D,ce),Object.assign(Y,Me),Object.assign(j,De),Object.assign(N,Qi),Object.assign(n,{interaction:(t,e,i,n)=>new I(t,e,i,n),hitCanvas:(t,e)=>new H(t,e),hitCanvasManager:()=>new P}),V();export{rt as Layouter,H as LeaferCanvas,lt as Renderer,yt as Selector,Q as Watcher,V as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,defineKey as a,FileHelper as o,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,Bounds as _,LeafBoundsHelper as p,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Answer as k,MatrixHelper as R,MathHelper as S,AlignHelper as E,ImageEvent as L,AroundHelper as M,PointHelper as A,Direction4 as W,TwoPointBoundsHelper as C,TaskProcessor as O,Matrix as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{InteractionBase as I,HitCanvasManager as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as D,ColorConvert as F,PaintGradient as Y,Export as N,Group as X,TextConvert as G,Paint as U,Effect as j}from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__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),this.clientBounds=this.bounds}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:z}=o;function V(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((n,s)=>{t.convertToBlob({type:z(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>n(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)})).catch((t=>{s(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:z(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),download(t,e){},loadImage:t=>new Promise(((i,n)=>{let s=new XMLHttpRequest;s.open("GET",e.image.getRealURL(t),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{i(t)})).catch((t=>{n(t)}))},s.onerror=t=>n(t),s.send()}))},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new H(t,e),image:t=>new s(t)}),e.name="web",e.isWorker=!0,e.requestRender=function(t){requestAnimationFrame(t)},a(e,"devicePixelRatio",{get:()=>1});const{userAgent:q}=navigator;q.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):q.indexOf("Safari")>-1&&-1===q.indexOf("Chrome")&&(e.fullImageShadow=!0),q.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):q.indexOf("Mac")>-1?e.os="Mac":q.indexOf("Linux")>-1&&(e.os="Linux");class Q{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=d.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(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.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:J,updateBounds:Z,updateAllWorldOpacity:K}=f,{pushAllChildBranch:$,pushAllParent:tt}=g;const{worldBounds:et}=p,it={x:0,y:0,width:1e5,height:1e5};class nt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,et)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(it):this.afterBounds.setListWithFn(t,et),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:st,updateAllChange:at}=f,ot=w.get("Layouter");class rt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.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(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.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=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&$(t,e),tt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),tt(t,e)))}))}(n,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||Z(n[t])}Z(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&K(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),rt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){st(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),at(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(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_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=w.get("Renderer");class lt{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=d.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,dt.log(e.innerName,"---\x3e");try{e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.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 dt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),a=new _(n);i.save(),s&&!w.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,a),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),w.showHitView&&this.renderHitView(n),w.showBoundsView&&this.renderBoundsView(n),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 _;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(l.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 _(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 _(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||dt.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 l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.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:ht}=B;class ct{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,a),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 r;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,n=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}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||ht(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:ut,NoAndSkip:ft,YesAndSkip:gt}=k,_t={},pt={},wt={};class yt{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=d.default(e,this.config)),this.picker=new ct(t,this),t&&this.__listenEvents()}getBy(t,e,i,n){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return i?s:s?[s]:[];case"string":switch(t[0]){case"#":_t.id=t.substring(1),t=_t;break;case".":pt.className=t.substring(1),t=pt;break;default:wt.tag=t,t=wt}case"object":if(void 0!==t.id){const n=this.getById(t.id,e);return i?n:n?[n]:[]}if(t.tag){const{tag:n}=t,s=n instanceof Array;return this.getByMethod(s?this.methods.tags:this.methods.tag,e,i,s?d.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,n){return"node"===e.name&&this.target&&this.target.emit(m.CHECK_UPDATE),this.picker.getByPoint(t,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(t,e){const i=this.idMap[t];return i&&f.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,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===ut||a===gt){if(!i)return void(this.findLeaf=s);i.push(s)}s.isBranch&&a<ft&&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_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(u.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={})}}function mt(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 vt(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?Bt(t,!0,e,i):bt(e,i);break;case"inside":xt("inside",t,s,e,i);break;case"outside":xt("outside",t,s,e,i)}}function xt(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?Bt(e,!0,n,r):bt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",mt(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 bt(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 Bt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&D.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?bt(i,n):n.stroke(),n.restoreBlendMode()):e?bt(i,n):n.stroke())}Object.assign(n,{watcher:(t,e)=>new Q(t,e),layouter:(t,e)=>new rt(t,e),renderer:(t,e,i)=>new lt(t,e,i),selector:(t,e)=>new yt(t,e)}),e.layout=rt.fullLayout;const{getSpread:kt,getOuterOf:Rt,getByMove:St,getIntersectData:Et}=B;let Lt;function Mt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:F.string(o,r)};case"image":return D.image(i,t,e,n,!Lt||!Lt[e.url]);case"linear":return Y.linearGradient(e,n);case"radial":return Y.radialGradient(e,n);case"angular":return Y.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:F.string(e)}:void 0}}const At={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Lt=D.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=Mt(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?mt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&D.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?mt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?mt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?mt(e,i):s?i.fill(s):i.fill())},fillText:mt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)vt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke();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)vt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),Bt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),Bt(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),Bt(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:vt,drawTextStroke:bt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Et(n?kt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=Rt(s,o),a=St(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:d,shapeBounds:r,scaleX:l,scaleY:h}}};let Wt={};const{get:Ct,rotateOfOuter:Ot,translate:Tt,scaleOfOuter:It,scale:Pt,rotate:Dt}=R;function Ft(t,e,i,n,s,a,o){const r=Ct();Tt(r,e.x+i,e.y+n),Pt(r,s,a),o&&Ot(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Yt(t,e,i,n,s,a,o){const r=Ct();Tt(r,e.x+i,e.y+n),s&&Pt(r,s,a),o&&Dt(r,o),t.transform=r}function Nt(t,e,i,n,s,a,o,r,d,l){const h=Ct();if(d)if("center"===l)Ot(h,{x:i/2,y:n/2},d);else switch(Dt(h,d),d){case 90:Tt(h,n,0);break;case 180:Tt(h,i,n);break;case 270:Tt(h,0,i)}Wt.x=e.x+s,Wt.y=e.y+a,Tt(h,Wt.x,Wt.y),o&&It(h,Wt,o,r),t.transform=h}const{get:Xt,translate:Gt}=R,Ut=new _,jt={},Ht={};function zt(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=Vt(i,n,e)}function Vt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Ut.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:a,mode:o,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u}=t,f=e.width===n&&e.height===s,g={mode:o},_="center"!==r&&(c||0)%180==90,p=_?s:n,w=_?n:s;let y,m,v=0,x=0;if(o&&"cover"!==o&&"fit"!==o)(l||h)&&(S.getScaleData(l,h,i,Ht),y=Ht.scaleX,m=Ht.scaleY);else if(!f||c){const t=e.width/p,i=e.height/w;y=m="fit"===o?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:p,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,jt,!0),v+=jt.x,x+=jt.y}switch(d&&(v+=d.x,x+=d.y),o){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||c)&&Yt(g,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Nt(g,e,n,s,v,x,y,m,c,r),u||(g.repeat="repeat");break;default:y&&Ft(g,e,v,x,y,m,c)}return g.transform||(e.x||e.y)&&(g.transform=Xt(),Gt(g.transform,e.x,e.y)),y&&"stretch"!==o&&(g.scaleX=y,g.scaleY=m),g.width=n,g.height=s,a&&(g.opacity=a),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let qt,Qt=new _;const{isSame:Jt}=B;function Zt(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||zt(s,n,i,a),!0}function Kt(t,e){ee(t,L.LOAD,e)}function $t(t,e){ee(t,L.LOADED,e)}function te(t,e,i){e.error=i,t.forceUpdate("surface"),ee(t,L.ERROR,e)}function ee(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function ie(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ne,scale:se,copy:ae}=R,{ceil:oe,abs:re}=Math;function de(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=re(s),a=re(a);const{image:t,data:r}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(l=ne(),ae(l,_),se(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,h*=s,c*=a;const w=h*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(l||(l=ne(),_&&ae(l,_)),se(l,1/s,1/a));const m=t.getCanvas(oe(h)||1,oe(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=o,!0}}function le(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:he}=Math;const ce={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return qt&&i===qt.paint&&Jt(n,qt.boxBounds)?a=qt.leafPaint:(a={type:i.type,image:r},qt=r.use>1?{leafPaint:a,paint:i,boxBounds:Qt.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Zt(t,e,i,r,a,n),s&&(Kt(t,o),$t(t,o))):r.error?s&&te(t,o,r.error):(s&&(ie(t,!0),Kt(t,o)),a.loadId=r.load((()=>{ie(t,!1),t.destroyed||(Zt(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),$t(t,o)),a.loadId=null}),(e=>{ie(t,!1),te(t,o,e),a.loadId=null}))),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===a+"-"+o+"-"+r&&!N.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=he(a)*r,i*=he(o)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||N.running}return s?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||N.running?de(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>le(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&de(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:de,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,x.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null},createData:zt,getPatternData:Vt,fillOrFitMode:Ft,clipMode:Yt,repeatMode:Nt},{toPoint:ue}=M,fe={},ge={};function _e(t,e,i){if(e){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),F.string(n,i)):t.addColorStop(n.offset,F.string(n.color,i))}}const{getAngle:pe,getDistance:we}=A,{get:ye,rotateOfOuter:me,scaleOfOuter:ve}=R,{toPoint:xe}=M,be={},Be={};function ke(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=pe(e,i);a=ye(),s?(ve(a,e,o/r*(n||1),1),me(a,e,t+90)):(ve(a,e,1,o/r*(n||1)),me(a,e,t))}return a}const{getDistance:Re}=A,{toPoint:Se}=M,Ee={},Le={};const Me={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;ue(n||"top",i,fe),ue(s||"bottom",i,ge);const d=e.canvas.createLinearGradient(fe.x,fe.y,ge.x,ge.y);_e(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;xe(n||"center",i,be),xe(s||"bottom",i,Be);const l=e.canvas.createRadialGradient(be.x,be.y,0,be.x,be.y,we(be,Be));_e(l,t.stops,o);const h={type:a,style:l},c=ke(i,be,Be,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;Se(n||"center",i,Ee),Se(s||"bottom",i,Le);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ee.x,Ee.y):e.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,Re(Ee,Le));_e(l,t.stops,o);const h={type:a,style:l},c=ke(i,Ee,Le,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:ke},{copy:Ae,toOffsetOutBounds:We}=B,Ce={},Oe={};function Te(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Ae(Ce,t.bounds),Ce.x+=i.x-o.x,Ce.y+=i.y-o.y,n){const{matrix:t}=s;Ce.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Ce.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Ce.width*=n,Ce.height*=n}t.copyWorld(s.canvas,t.bounds,Ce)}else n&&(Ae(Ce,i),Ce.x-=i.width/2*(n-1),Ce.y-=i.height/2*(n-1),Ce.width*=n,Ce.height*=n),t.copyWorld(s.canvas,o,n?Ce:i)}const{toOffsetOutBounds:Ie}=B,Pe={};const De={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;We(l,Oe),r.forEach(((r,_)=>{f.setWorldShadow(Oe.offsetX+r.x*c,Oe.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Te(f,Oe,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<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:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ie(l,Pe),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Pe.offsetX+r.x*c,Pe.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Te(f,Pe,s,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,h,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&&_<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:Fe}=p;function Ye(t,e,i,n,s,a){switch(e){case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Xe(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Xe(t,i,n,a);break;case"path":i.restore()}}function Ne(t){return t.getSameCanvas(!1,!0)}function Xe(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}X.prototype.__renderMask=function(t,e){let i,n,s,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)i=r[d],i.__.mask&&(o&&(Ye(this,o,t,s,n,a),n=s=null),"path"===i.__.mask?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ne(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="alpha",n||(n=Ne(t)),s||(s=Ne(t)),i.__render(n,e)),"clipping"!==i.__.mask)||Fe(i,e)||i.__render(s||t,e);Ye(this,o,t,s,n,a)};const Ge=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ue=Ge+"_#~&*+\\=|≮≯≈≠=…",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 He(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ze=He("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ve=He("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),qe=He(Ge),Qe=He(Ue),Je=He("- —/~|┆·");var Ze;!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"}(Ze||(Ze={}));const{Letter:Ke,Single:$e,Before:ti,After:ei,Symbol:ii,Break:ni}=Ze;function si(t){return ze[t]?Ke:Je[t]?ni:Ve[t]?ti:qe[t]?ei:Qe[t]?ii:je.test(t)?$e:Ke}const ai={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 oi(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:ri}=ai,{Letter:di,Single:li,Before:hi,After:ci,Symbol:ui,Break:fi}=Ze;let gi,_i,pi,wi,yi,mi,vi,xi,bi,Bi,ki,Ri,Si,Ei,Li,Mi,Ai,Wi=[];function Ci(t,e){bi&&!xi&&(xi=bi),gi.data.push({char:t,width:e}),pi+=e}function Oi(){wi+=pi,gi.width=pi,_i.words.push(gi),gi={data:[]},pi=0}function Ti(){Ei&&(Li.paraNumber++,_i.paraStart=!0,Ei=!1),bi&&(_i.startCharSize=xi,_i.endCharSize=bi,xi=0),_i.width=wi,Mi.width?ri(_i):Ai&&Ii(),Wi.push(_i),_i={words:[]},wi=0}function Ii(){wi>(Li.maxWidth||0)&&(Li.maxWidth=wi)}const Pi=0,Di=1,Fi=2;const{top:Yi,right:Ni,bottom:Xi,left:Gi}=W;function Ui(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 ji={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a?(n=l[Gi],a-=l[Ni]+l[Gi]):i.autoSizeAlign||(n=l[Gi]),o?(s=l[Yi],o-=l[Yi]+l[Xi]):i.autoSizeAlign||(s=l[Yi]));const h={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Li=t,Wi=t.rows,Mi=t.bounds,Ai=!Mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:l}=Mi;if(d||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Ei=!0,ki=null,xi=vi=bi=pi=wi=0,gi={data:[]},_i={words:[]};for(let n=0,l=i.length;n<l;n++)mi=i[n],"\n"===mi?(pi&&Oi(),_i.paraEnd=!0,Ti(),Ei=!0):(Bi=si(mi),Bi===di&&"none"!==o&&(mi=oi(mi,o,!pi)),vi=r.measureText(mi).width,s&&(s<0&&(bi=vi),vi+=s),Ri=Bi===li&&(ki===li||ki===di)||ki===li&&Bi!==ci,Si=!(Bi!==hi&&Bi!==li||ki!==ui&&ki!==ci),yi=Ei&&a?d-a:d,t&&d&&wi+pi+vi>yi&&(e?(pi&&Oi(),wi&&Ti()):(Si||(Si=Bi===di&&ki==ci),Ri||Si||Bi===fi||Bi===hi||Bi===li||pi+vi>yi?(pi&&Oi(),wi&&Ti()):wi&&Ti()))," "===mi&&!0!==Ei&&wi+pi===0||(Bi===fi?(" "===mi&&pi&&Oi(),Ci(mi,vi),Oi()):Ri||Si?(pi&&Oi(),Ci(mi,vi)):Ci(mi,vi)),ki=Bi);pi&&Oi(),wi&&Ti(),Wi.length>0&&(Wi[Wi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Li.paraNumber++,wi=r.measureText(t).width,Wi.push({x:a||0,text:t,width:wi,paraStart:!0}),Ai&&Ii()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Ui(e,"x",t[Gi]);break;case"right":Ui(e,"x",-t[Ni])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ui(e,"y",t[Yi]);break;case"bottom":Ui(e,"y",-t[Xi])}}(l,h,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:_}=n,p=s*i.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&p>_)p=Math.max(_,s),t.overflow=i.length;else if(_||c)switch(l){case"middle":f+=(_-p)/2;break;case"bottom":f+=_-p}w+=f;let y,m,v,x=g||c?g:t.maxWidth;for(let a=0,l=i.length;a<l;a++){if(y=i[a],y.x=u,y.width<g||y.width>g&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=s,t.overflow>a&&w>p&&(y.isOverflow=!0,t.overflow=a+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<n.x&&(n.x=m),v>n.width&&(n.width=v),r&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=p}(h,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,l=i&&"justify"===a&&t.words.length>1?(i-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Pi:l>.01?Di:Fi,t.isOverflow&&!r&&(t.textMode=!0),c===Fi?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Di?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,h=n+s-l;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<h));n--){if(d<h&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,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}}(h,i),h}};const Hi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!F.object)return t;t=F.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}},{setPoint:zi,addPoint:Vi,toBounds:qi}=C;const Qi={export(t,i,s){this.running=!0;const a=o.fileType(i),r=i.includes(".");return s=o.getExportOptions(s),function(t){Ji||(Ji=new O);return new Promise((e=>{Ji.add((()=>le(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((d=>new Promise((l=>{const h=t=>{d(t),l(),this.running=!1},{toURL:c}=e,{download:u}=e.origin;if("json"===a)return r&&u(c(JSON.stringify(t.toJSON(s.json)),"text"),i),h({data:!!r||t.toJSON(s.json)});if("svg"===a)return r&&u(c(t.toSVG(),"svg"),i),h({data:!!r||t.toSVG()});const{leafer:f}=t;f?(Zi(t),f.waitViewCompleted((()=>le(this,void 0,void 0,(function*(){let e,a,r=1,d=1;const{worldTransform:l,isLeafer:c,isFrame:u}=t,{slice:g,trim:p,onCanvas:w}=s,y=void 0===s.smooth?f.config.smooth:s.smooth,m=s.contextSettings||f.config.contextSettings,v=s.screenshot||t.isApp,x=c&&v&&void 0===s.fill?t.fill:s.fill,b=o.isOpaqueImage(i)||x,B=new T;if(v)e=!0===v?c?f.canvas.bounds:t.worldRenderBounds:v;else{let i=s.relative||(c?"inner":"local");switch(r=l.scaleX,d=l.scaleY,i){case"inner":B.set(l);break;case"local":B.set(l).divide(t.localTransform),r/=t.scaleX,d/=t.scaleY;break;case"world":r=1,d=1;break;case"page":i=t.leafer;default:B.set(l).divide(t.getTransform(i));const e=i.worldTransform;r/=r/e.scaleX,d/=d/e.scaleY}e=t.getBounds("render",i)}const k={scaleX:1,scaleY:1};S.getScaleData(s.scale,s.size,e,k);let R=s.pixelRatio||1;t.isApp&&(k.scaleX*=R,k.scaleY*=R,R=t.app.pixelRatio);const{x:E,y:L,width:M,height:A}=new _(e).scale(k.scaleX,k.scaleY),W={matrix:B.scale(1/k.scaleX,1/k.scaleY).invert().translate(-E,-L).withScale(1/r*k.scaleX,1/d*k.scaleY)};let C,O=n.canvas({width:Math.round(M),height:Math.round(A),pixelRatio:R,smooth:y,contextSettings:m});if(g&&(C=t,C.__worldOpacity=0,t=f,W.bounds=O.bounds),O.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(O,W),t.fill=e}else t.__render(O,W);if(O.restore(),C&&C.__updateWorldOpacity(),p){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?Vi(o,s,a):zi(o={},s,a)),r++;const d=new _;return qi(o,d),d.scale(1/t.pixelRatio).ceil()}(O);const t=O,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:R};O=n.canvas(s),O.copyWorld(t,a,s)}b&&O.fillWorld(O.bounds,x||"#FFFFFF","destination-over"),w&&w(O);const I="canvas"===i?O:yield O.export(i,s);h({data:I,width:O.pixelWidth,height:O.pixelHeight,renderBounds:e,trimBounds:a})}))))):h({data:!1})}))))}};let Ji;function Zi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Zi(t)))}const Ki=t.prototype,$i=w.get("@leafer-ui/export");Ki.export=function(t,e){const{quality:i,blob:n}=o.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},Ki.toBlob=function(t,i){return new Promise((n=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{n(t)})).catch((t=>{$i.error(t),n(null)}))}))},Ki.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},Ki.saveAs=function(t,i){return new Promise((n=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{n(!0)})).catch((t=>{$i.error(t),n(!1)}))}))},Object.assign(G,ji),Object.assign(F,Hi),Object.assign(U,At),Object.assign(D,ce),Object.assign(Y,Me),Object.assign(j,De),Object.assign(N,Qi),Object.assign(n,{interaction:(t,e,i,n)=>new I(t,e,i,n),hitCanvas:(t,e)=>new H(t,e),hitCanvasManager:()=>new P}),V();export{rt as Layouter,H as LeaferCanvas,lt as Renderer,yt as Selector,Q as Watcher,V as useCanvas};
|
package/dist/worker.js
CHANGED
|
@@ -4429,13 +4429,10 @@ var LeaferUI = (function (exports) {
|
|
|
4429
4429
|
update() {
|
|
4430
4430
|
const { leafer } = this.leaf;
|
|
4431
4431
|
if (leafer) {
|
|
4432
|
-
if (leafer.ready)
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
}
|
|
4436
|
-
else {
|
|
4432
|
+
if (leafer.ready)
|
|
4433
|
+
leafer.watcher.changed && leafer.layouter.layout();
|
|
4434
|
+
else
|
|
4437
4435
|
leafer.start();
|
|
4438
|
-
}
|
|
4439
4436
|
}
|
|
4440
4437
|
else {
|
|
4441
4438
|
let root = this.leaf;
|
|
@@ -5962,7 +5959,7 @@ var LeaferUI = (function (exports) {
|
|
|
5962
5959
|
}
|
|
5963
5960
|
}
|
|
5964
5961
|
|
|
5965
|
-
const version = "1.0.
|
|
5962
|
+
const version = "1.0.7";
|
|
5966
5963
|
|
|
5967
5964
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5968
5965
|
get allowBackgroundColor() { return true; }
|
|
@@ -6681,7 +6678,8 @@ var LeaferUI = (function (exports) {
|
|
|
6681
6678
|
path.add(leaf);
|
|
6682
6679
|
leaf = leaf.parent;
|
|
6683
6680
|
}
|
|
6684
|
-
|
|
6681
|
+
if (this.target)
|
|
6682
|
+
path.add(this.target);
|
|
6685
6683
|
return path;
|
|
6686
6684
|
}
|
|
6687
6685
|
getHitablePath(leaf) {
|
|
@@ -6767,8 +6765,8 @@ var LeaferUI = (function (exports) {
|
|
|
6767
6765
|
this.innerIdMap = {};
|
|
6768
6766
|
this.idMap = {};
|
|
6769
6767
|
this.methods = {
|
|
6770
|
-
id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
|
|
6771
|
-
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
|
|
6768
|
+
id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
|
|
6769
|
+
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
|
|
6772
6770
|
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
6773
6771
|
tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
|
|
6774
6772
|
tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
|
|
@@ -6777,7 +6775,8 @@ var LeaferUI = (function (exports) {
|
|
|
6777
6775
|
if (userConfig)
|
|
6778
6776
|
this.config = DataHelper.default(userConfig, this.config);
|
|
6779
6777
|
this.picker = new Picker(target, this);
|
|
6780
|
-
|
|
6778
|
+
if (target)
|
|
6779
|
+
this.__listenEvents();
|
|
6781
6780
|
}
|
|
6782
6781
|
getBy(condition, branch, one, options) {
|
|
6783
6782
|
switch (typeof condition) {
|
|
@@ -6812,7 +6811,7 @@ var LeaferUI = (function (exports) {
|
|
|
6812
6811
|
}
|
|
6813
6812
|
}
|
|
6814
6813
|
getByPoint(hitPoint, hitRadius, options) {
|
|
6815
|
-
if (Platform.name === 'node')
|
|
6814
|
+
if (Platform.name === 'node' && this.target)
|
|
6816
6815
|
this.target.emit(LayoutEvent.CHECK_UPDATE);
|
|
6817
6816
|
return this.picker.getByPoint(hitPoint, hitRadius, options);
|
|
6818
6817
|
}
|
|
@@ -8654,9 +8653,8 @@ var LeaferUI = (function (exports) {
|
|
|
8654
8653
|
layout.renderChanged = true;
|
|
8655
8654
|
setList(data.__textBoxBounds = {}, [b, bounds]);
|
|
8656
8655
|
}
|
|
8657
|
-
else
|
|
8656
|
+
else
|
|
8658
8657
|
data.__textBoxBounds = contentBounds;
|
|
8659
|
-
}
|
|
8660
8658
|
}
|
|
8661
8659
|
__updateRenderSpread() {
|
|
8662
8660
|
let width = super.__updateRenderSpread();
|
|
@@ -10330,17 +10328,20 @@ var LeaferUI = (function (exports) {
|
|
|
10330
10328
|
};
|
|
10331
10329
|
|
|
10332
10330
|
const ui = exports.UI.prototype, group = exports.Group.prototype;
|
|
10331
|
+
function getSelector(ui) {
|
|
10332
|
+
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
10333
|
+
}
|
|
10333
10334
|
ui.find = function (condition, options) {
|
|
10334
|
-
return this.
|
|
10335
|
+
return getSelector(this).getBy(condition, this, false, options);
|
|
10335
10336
|
};
|
|
10336
10337
|
ui.findOne = function (condition, options) {
|
|
10337
|
-
return this.
|
|
10338
|
+
return getSelector(this).getBy(condition, this, true, options);
|
|
10338
10339
|
};
|
|
10339
10340
|
group.pick = function (hitPoint, options) {
|
|
10340
10341
|
this.__layout.update();
|
|
10341
10342
|
if (!options)
|
|
10342
10343
|
options = {};
|
|
10343
|
-
return this.
|
|
10344
|
+
return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
|
|
10344
10345
|
};
|
|
10345
10346
|
|
|
10346
10347
|
const canvas$1 = LeaferCanvasBase.prototype;
|
package/dist/worker.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),n=require("@leafer-ui/draw");class i extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,a)=>{t.convertToBlob({type:s(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>a(t),e.readAsDataURL(t)})).catch((t=>{a(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:s(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",t.Platform.image.getRealURL(e),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):o.indexOf("Safari")>-1&&-1===o.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");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,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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,n=e.length;t<n;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:d,updateBounds:l,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,f),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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 n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:o,AFTER:r}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&c(t,e),u(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,f,this.times)),i.emitEvent(new t.LayoutEvent(r,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),y.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,o,this.times)),n.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:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,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:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return v.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),o=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};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=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.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:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__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:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).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||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__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,n,i){n||(n=0),i||(i={});const s=i.through||!1,a=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,d=this.getBestMatchLeaf(r,i.bottomList,a),l=a?this.getPath(d):this.getHitablePath(d);return this.clear(),s?{path:l,target:d,throughPath:r.length?this.getThroughPath(r):l}:{path:l,target:d}}getBestMatchLeaf(e,n,i){if(e.length){let n;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(n=e[s],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,o),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,o;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(o=s.list[t],!a||!a.has(o));t++)n.add(o)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||B(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:E,NoAndSkip:L,YesAndSkip:R}=t.Answer,k={},P={},S={};class C{constructor(e,n){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(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,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new b(e,this),this.__listenEvents()}getBy(e,n,i,s){switch(typeof e){case"number":const a=this.getByInnerId(e,n);return i?a:a?[a]:[];case"string":switch(e[0]){case"#":k.id=e.substring(1),e=k;break;case".":P.className=e.substring(1),e=P;break;default:S.tag=e,e=S}case"object":if(void 0!==e.id){const t=this.getById(e.id,n);return i?t:t?[t]:[]}if(e.tag){const{tag:s}=e,a=s instanceof Array;return this.getByMethod(a?this.methods.tags:this.methods.tag,n,i,a?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,n,i,e.className);case"function":return this.getByMethod(e,n,i,s)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),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,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,i),a===E||a===R){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<L&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__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={})}}function M(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function A(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?I(t,!0,e,n):W(e,n);break;case"inside":O("inside",t,s,e,n);break;case"outside":O("outside",t,s,e,n)}}function O(t,e,n,i,s){const{__strokeWidth:a,__font:o}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,i.__),r.font=o,n?I(e,!0,i,r):W(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",M(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function W(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function I(t,e,i,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&n.PaintImage.checkImage(i,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?W(i,s):s.stroke(),s.restoreBlendMode()):e?W(i,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>new C(t,e)}),t.Platform.layout=y.fullLayout;const{getSpread:T,getOuterOf:D,getByMove:H,getIntersectData:F}=t.BoundsHelper;let Y;function N(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:a,blendMode:o,color:r,opacity:d}=e;return{type:a,blendMode:o,style:n.ColorConvert.string(r,d)};case"image":return n.PaintImage.image(i,t,e,s,!Y||!Y[e.url]);case"linear":return n.PaintGradient.linearGradient(e,s);case"radial":return n.PaintGradient.radialGradient(e,s);case"angular":return n.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:n.ColorConvert.string(e)}:void 0}}const j={compute:function(t,e){const i=e.__,s=[];let a,o=i.__input[t];o instanceof Array||(o=[o]),Y=n.PaintImage.recycleImage(t,i);for(let n,i=0,a=o.length;i<a;i++)n=N(t,o[i],e),n&&s.push(n);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=a:i.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?M(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,i){let s;const{windingRule:a,__font:o}=e.__;for(let r=0,d=t.length;r<d;r++)s=t[r],s.image&&n.PaintImage.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?M(e,i):a?i.fill(a):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),o?M(e,i):a?i.fill(a):i.fill(),i.restoreBlendMode()):o?M(e,i):a?i.fill(a):i.fill())},fillText:M,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)A(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)A(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),I(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),I(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,i),I(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:A,drawTextStroke:W,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,c=F(i?T(e.bounds,l===h?i*l:[i*h,i*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),r=D(s,o),a=H(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let G={};const{get:X,rotateOfOuter:U,translate:z,scaleOfOuter:q,scale:V,rotate:Q}=t.MatrixHelper;function J(t,e,n,i,s,a,o){const r=X();z(r,e.x+n,e.y+i),V(r,s,a),o&&U(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function K(t,e,n,i,s,a,o){const r=X();z(r,e.x+n,e.y+i),s&&V(r,s,a),o&&Q(r,o),t.transform=r}function Z(t,e,n,i,s,a,o,r,d,l){const h=X();if(d)if("center"===l)U(h,{x:n/2,y:i/2},d);else switch(Q(h,d),d){case 90:z(h,i,0);break;case 180:z(h,n,i);break;case 270:z(h,0,n)}G.x=e.x+s,G.y=e.y+a,z(h,G.x,G.y),o&&q(h,G,o,r),t.transform=h}const{get:$,translate:tt}=t.MatrixHelper,et=new t.Bounds,nt={},it={};function st(t,e,n,i){const{blendMode:s,sync:a}=n;s&&(t.blendMode=s),a&&(t.sync=a),t.data=at(n,i,e)}function at(e,n,i){let{width:s,height:a}=i;e.padding&&(n=et.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:d,offset:l,scale:h,size:c,rotation:u,repeat:f}=e,g=n.width===s&&n.height===a,p={mode:r},_="center"!==d&&(u||0)%180==90,w=_?a:s,m=_?s:a;let y,v,x=0,B=0;if(r&&"cover"!==r&&"fit"!==r)(h||c)&&(t.MathHelper.getScaleData(h,c,i,it),y=it.scaleX,v=it.scaleY);else if(!g||u){const t=n.width/w,e=n.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*y)/2,B+=(n.height-a*v)/2}if(d){const e={x:x,y:B,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(d,e,n,nt,!0),x+=nt.x,B+=nt.y}switch(l&&(x+=l.x,B+=l.y),r){case"stretch":g||(s=n.width,a=n.height);break;case"normal":case"clip":(x||B||y||u)&&K(p,n,x,B,y,v,u);break;case"repeat":(!g||y||u)&&Z(p,n,s,a,x,B,y,v,u,d),f||(p.repeat="repeat");break;default:y&&J(p,n,x,B,y,v,u)}return p.transform||(n.x||n.y)&&(p.transform=$(),tt(p.transform,n.x,n.y)),y&&"stretch"!==r&&(p.scaleX=y,p.scaleY=v),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 ot,rt=new t.Bounds;const{isSame:dt}=t.BoundsHelper;function lt(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.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||st(s,i,n,a),!0}function ht(e,n){ft(e,t.ImageEvent.LOAD,n)}function ct(e,n){ft(e,t.ImageEvent.LOADED,n)}function ut(e,n,i){n.error=i,e.forceUpdate("surface"),ft(e,t.ImageEvent.ERROR,n)}function ft(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function gt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:pt,scale:_t,copy:wt}=t.MatrixHelper,{ceil:mt,abs:yt}=Math;function vt(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=s+"-"+a+"-"+i;if(n.patternId===o||e.destroyed)return!1;{s=yt(s),a=yt(a);const{image:e,data:r}=n;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(l=pt(),wt(l,p),_t(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const w=h*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&&(d=Math.sqrt(w/m)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=pt(),p&&wt(l,p)),_t(l,1/s,1/a));const y=e.getCanvas(mt(h)||1,mt(c)||1,g),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=o,!0}}function xt(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{d(i.next(t))}catch(t){a(t)}}function r(t){try{d(i.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Bt}=Math;const bt={image:function(e,n,i,s,a){let o,r;const d=t.ImageManager.get(i);return ot&&i===ot.paint&&dt(s,ot.boxBounds)?o=ot.leafPaint:(o={type:i.type,image:d},ot=d.use>1?{leafPaint:o,paint:i,boxBounds:rt.set(s)}:null),(a||d.loading)&&(r={image:d,attrName:n,attrValue:i}),d.ready?(lt(e,n,i,d,o,s),a&&(ht(e,r),ct(e,r))):d.error?a&&ut(e,r,d.error):(a&&(gt(e,!0),ht(e,r)),o.loadId=d.load((()=>{gt(e,!1),e.destroyed||(lt(e,n,i,d,o,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ct(e,r)),o.loadId=null}),(t=>{gt(e,!1),ut(e,r,t),o.loadId=null}))),o},checkImage:function(e,i,s,a){const{scaleX:o,scaleY:r}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=i;if(!s.data||s.patternId===o+"-"+r+"-"+d&&!n.Export.running)return!1;{const{data:l}=s;if(a)if(l.repeat)a=!1;else{let{width:e,height:i}=l;e*=Bt(o)*d,i*=Bt(r)*d,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),a=e*i>t.Platform.image.maxCacheSize||n.Export.running}return a?(i.save(),e.windingRule?i.clip(e.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),l.opacity&&(i.opacity*=l.opacity),l.transform&&i.transform(l.transform),i.drawImage(s.image.view,0,0,l.width,l.height),i.restore(),!0):(!s.style||s.sync||n.Export.running?vt(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>xt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&vt(e,s,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:vt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,o,r;for(let d=0,l=i.length;d<l;d++)s=i[d].image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),s.unload(i[d].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:st,getPatternData:at,fillOrFitMode:J,clipMode:K,repeatMode:Z},{toPoint:Et}=t.AroundHelper,Lt={},Rt={};function kt(t,e,i){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),n.ColorConvert.string(s,i)):t.addColorStop(s.offset,n.ColorConvert.string(s.color,i))}}const{getAngle:Pt,getDistance:St}=t.PointHelper,{get:Ct,rotateOfOuter:Mt,scaleOfOuter:At}=t.MatrixHelper,{toPoint:Ot}=t.AroundHelper,Wt={},It={};function Tt(t,e,n,i,s){let a;const{width:o,height:r}=t;if(o!==r||i){const t=Pt(e,n);a=Ct(),s?(At(a,e,o/r*(i||1),1),Mt(a,e,t+90)):(At(a,e,1,o/r*(i||1)),Mt(a,e,t))}return a}const{getDistance:Dt}=t.PointHelper,{toPoint:Ht}=t.AroundHelper,Ft={},Yt={};const Nt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:o,opacity:r}=e;Et(i||"top",n,Lt),Et(s||"bottom",n,Rt);const d=t.Platform.canvas.createLinearGradient(Lt.x,Lt.y,Rt.x,Rt.y);kt(d,e.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=e;Ot(i||"center",n,Wt),Ot(s||"bottom",n,It);const l=t.Platform.canvas.createRadialGradient(Wt.x,Wt.y,0,Wt.x,Wt.y,St(Wt,It));kt(l,e.stops,o);const h={type:a,style:l},c=Tt(n,Wt,It,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:d}=e;Ht(i||"center",n,Ft),Ht(s||"bottom",n,Yt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ft.x,Ft.y):t.Platform.canvas.createRadialGradient(Ft.x,Ft.y,0,Ft.x,Ft.y,Dt(Ft,Yt));kt(l,e.stops,o);const h={type:a,style:l},c=Tt(n,Ft,Yt,d||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Tt},{copy:jt,toOffsetOutBounds:Gt}=t.BoundsHelper,Xt={},Ut={};function zt(e,n,i,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(jt(Xt,e.bounds),Xt.x+=n.x-o.x,Xt.y+=n.y-o.y,i){const{matrix:t}=s;Xt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Xt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Xt.width*=i,Xt.height*=i}e.copyWorld(s.canvas,e.bounds,Xt)}else i&&(jt(Xt,n),Xt.x-=n.width/2*(i-1),Xt.y-=n.height/2*(i-1),Xt.width*=i,Xt.height*=i),e.copyWorld(s.canvas,o,i?Xt:n)}const{toOffsetOutBounds:qt}=t.BoundsHelper,Vt={};const Qt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=r.length-1;Gt(l,Ut),r.forEach(((r,p)=>{f.setWorldShadow(Ut.offsetX+r.x*c,Ut.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,zt(f,Ut,s,n),i=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=r.length-1;qt(l,Vt),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Vt.offsetX+r.x*c,Vt.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,zt(f,Vt,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,l,"source-out"),i=l),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Jt}=t.LeafBoundsHelper;function Kt(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),$t(t,e,n,1)}(t,n,i,s);break;case"opacity-path":$t(t,n,i,a);break;case"path":n.restore()}}function Zt(t){return t.getSameCanvas(!1,!0)}function $t(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}n.Group.prototype.__renderMask=function(t,e){let n,i,s,a,o;const{children:r}=this;for(let d=0,l=r.length;d<l;d++)n=r[d],n.__.mask&&(o&&(Kt(this,o,t,s,i,a),i=s=null),"path"===n.__.mask?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=Zt(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="alpha",i||(i=Zt(t)),s||(s=Zt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Jt(n,e)||n.__render(s||t,e);Kt(this,o,t,s,i,a)};const te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ee=te+"_#~&*+\\=|≮≯≈≠=…",ne=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 ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const se=ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ae=ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),oe=ie(te),re=ie(ee),de=ie("- —/~|┆·");var le;!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"}(le||(le={}));const{Letter:he,Single:ce,Before:ue,After:fe,Symbol:ge,Break:pe}=le;function _e(t){return se[t]?he:de[t]?pe:ae[t]?ue:oe[t]?fe:re[t]?ge:ne.test(t)?ce:he}const we={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function me(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ye}=we,{Letter:ve,Single:xe,Before:Be,After:be,Symbol:Ee,Break:Le}=le;let Re,ke,Pe,Se,Ce,Me,Ae,Oe,We,Ie,Te,De,He,Fe,Ye,Ne,je,Ge=[];function Xe(t,e){We&&!Oe&&(Oe=We),Re.data.push({char:t,width:e}),Pe+=e}function Ue(){Se+=Pe,Re.width=Pe,ke.words.push(Re),Re={data:[]},Pe=0}function ze(){Fe&&(Ye.paraNumber++,ke.paraStart=!0,Fe=!1),We&&(ke.startCharSize=Oe,ke.endCharSize=We,Oe=0),ke.width=Se,Ne.width?ye(ke):je&&qe(),Ge.push(ke),ke={words:[]},Se=0}function qe(){Se>(Ye.maxWidth||0)&&(Ye.maxWidth=Se)}const Ve=0,Qe=1,Je=2;const{top:Ke,right:Ze,bottom:$e,left:tn}=t.Direction4;function en(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const nn={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=n;l&&(a?(i=l[tn],a-=l[Ze]+l[tn]):n.autoSizeAlign||(i=l[tn]),o?(s=l[Ke],o-=l[Ke]+l[$e]):n.autoSizeAlign||(s=l[Ke]));const h={bounds:{x:i,y:s,width:a,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Ye=e,Ge=e.rows,Ne=e.bounds,je=!Ne.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=t.Platform,{width:d,height:l}=Ne;if(d||l||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Fe=!0,Te=null,Oe=Ae=We=Pe=Se=0,Re={data:[]},ke={words:[]};for(let i=0,l=n.length;i<l;i++)Me=n[i],"\n"===Me?(Pe&&Ue(),ke.paraEnd=!0,ze(),Fe=!0):(Ie=_e(Me),Ie===ve&&"none"!==o&&(Me=me(Me,o,!Pe)),Ae=r.measureText(Me).width,s&&(s<0&&(We=Ae),Ae+=s),De=Ie===xe&&(Te===xe||Te===ve)||Te===xe&&Ie!==be,He=!(Ie!==Be&&Ie!==xe||Te!==Ee&&Te!==be),Ce=Fe&&a?d-a:d,t&&d&&Se+Pe+Ae>Ce&&(e?(Pe&&Ue(),Se&&ze()):(He||(He=Ie===ve&&Te==be),De||He||Ie===Le||Ie===Be||Ie===xe||Pe+Ae>Ce?(Pe&&Ue(),Se&&ze()):Se&&ze()))," "===Me&&!0!==Fe&&Se+Pe===0||(Ie===Le?(" "===Me&&Pe&&Ue(),Xe(Me,Ae),Ue()):De||He?(Pe&&Ue(),Xe(Me,Ae)):Xe(Me,Ae)),Te=Ie);Pe&&Ue(),Se&&ze(),Ge.length>0&&(Ge[Ge.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ye.paraNumber++,Se=r.measureText(t).width,Ge.push({x:a||0,text:t,width:Se,paraStart:!0}),je&&qe()}))}(h,e,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":en(e,"x",t[tn]);break;case"right":en(e,"x",-t[Ze])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":en(e,"y",t[Ke]);break;case"bottom":en(e,"y",-t[$e])}}(l,h,n,a,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:p}=i,_=s*n.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&_>p)_=Math.max(p,s),t.overflow=n.length;else if(p||c)switch(l){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let m,y,v,x=g||c?g:t.maxWidth;for(let a=0,l=n.length;a<l;a++){if(m=n[a],m.x=u,m.width<g||m.width>g&&!r)switch(d){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&h&&a>0&&(w+=h),m.y=w,w+=s,t.overflow>a&&w>_&&(m.isOverflow=!0,t.overflow=a+1),y=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,y-=v,v+=e.fontSize):v-=o),y<i.x&&(i.x=y),v>i.width&&(i.width=v),r&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Ve:l>.01?Qe:Je,t.isOverflow&&!r&&(t.textMode=!0),c===Je?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Qe?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,n,a),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:a,overflow:o}=e;let{textOverflow:r}=n;if(a.splice(o),r&&"show"!==r){let e,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?t.Platform.canvas.measureText(r).width:0,h=i+s-l;("none"===n.textWrap?a:[a[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],d=e.x+e.width,!(i===n&&d<h));i--){if(d<h&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:r,x:d}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,i,a),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const sn={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!n.ColorConvert.object)return t;t=n.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}},{setPoint:an,addPoint:on,toBounds:rn}=t.TwoPointBoundsHelper;const dn={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),a=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){ln||(ln=new t.TaskProcessor);return new Promise((t=>{ln.add((()=>xt(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((o=>new Promise((r=>{const d=t=>{o(t),r(),this.running=!1},{toURL:l}=t.Platform,{download:h}=t.Platform.origin;if("json"===s)return a&&h(l(JSON.stringify(e.toJSON(i.json)),"text"),n),d({data:!!a||e.toJSON(i.json)});if("svg"===s)return a&&h(l(e.toSVG(),"svg"),n),d({data:!!a||e.toSVG()});const{leafer:c}=e;c?(hn(e),c.waitViewCompleted((()=>xt(this,void 0,void 0,(function*(){let s,a,o=1,r=1;const{worldTransform:l,isLeafer:h,isFrame:u}=e,{slice:f,trim:g,onCanvas:p}=i,_=void 0===i.smooth?c.config.smooth:i.smooth,w=i.contextSettings||c.config.contextSettings,m=i.screenshot||e.isApp,y=h&&m&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)s=!0===m?h?c.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(h?"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 n=t.worldTransform;o/=o/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const B={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,B);let b=i.pixelRatio||1;e.isApp&&(B.scaleX*=b,B.scaleY*=b,b=e.app.pixelRatio);const{x:E,y:L,width:R,height:k}=new t.Bounds(s).scale(B.scaleX,B.scaleY),P={matrix:x.scale(1/B.scaleX,1/B.scaleY).invert().translate(-E,-L).withScale(1/o*B.scaleX,1/r*B.scaleY)};let S,C=t.Creator.canvas({width:Math.round(R),height:Math.round(k),pixelRatio:b,smooth:_,contextSettings:w});if(f&&(S=e,S.__worldOpacity=0,e=c,P.bounds=C.bounds),C.save(),u&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(C,P),e.fill=t}else e.__render(C,P);if(C.restore(),S&&S.__updateWorldOpacity(),g){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,o,r,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,o=(d-a)/n,r?on(r,a,o):an(r={},a,o)),d++;const l=new t.Bounds;return rn(r,l),l.scale(1/e.pixelRatio).ceil()}(C);const e=C,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:b};C=t.Creator.canvas(s),C.copyWorld(e,a,s)}v&&C.fillWorld(C.bounds,y||"#FFFFFF","destination-over"),p&&p(C);const M="canvas"===n?C:yield C.export(n,i);d({data:M,width:C.pixelWidth,height:C.pixelHeight,renderBounds:s,trimBounds:a})}))))):d({data:!1})}))))}};let ln;function hn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>hn(t)))}const cn=t.LeaferCanvasBase.prototype,un=t.Debug.get("@leafer-ui/export");cn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},cn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{un.error(t),i(null)}))}))},cn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},cn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{un.error(t),i(!1)}))}))},Object.assign(n.TextConvert,nn),Object.assign(n.ColorConvert,sn),Object.assign(n.Paint,j),Object.assign(n.PaintImage,bt),Object.assign(n.PaintGradient,Nt),Object.assign(n.Effect,Qt),Object.assign(n.Export,dn),Object.assign(t.Creator,{interaction:(t,n,i,s)=>new e.InteractionBase(t,n,i,s),hitCanvas:(t,e)=>new i(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=x,exports.Selector=C,exports.Watcher=r,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/core"),n=require("@leafer-ui/draw");class i extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((i,a)=>{t.convertToBlob({type:s(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>a(t),e.readAsDataURL(t)})).catch((t=>{a(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:s(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((n,i)=>{let s=new XMLHttpRequest;s.open("GET",t.Platform.image.getRealURL(e),!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{n(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):r.indexOf("Safari")>-1&&-1===r.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),r.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):r.indexOf("Mac")>-1?t.Platform.os="Mac":r.indexOf("Linux")>-1&&(t.Platform.os="Linux");class o{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,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,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,n=e.length;t<n;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:d,updateBounds:l,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:u}=t.BranchHelper;const{worldBounds:f}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,f)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,f),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:w}=t.LeafHelper,m=t.Debug.get("Layouter");class y{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,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 n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,f=this.getBlocks(s);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,f,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&c(t,e),u(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),u(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||l(i[t])}l(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,f,this.times)),i.emitEvent(new t.LayoutEvent(o,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),y.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,r,this.times)),n.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),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:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,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:n}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(n.innerName,"---\x3e");try{n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return v.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),r=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,r),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};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=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.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:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__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:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).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||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__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,n,i){n||(n=0),i||(i={});const s=i.through||!1,a=i.ignoreHittable||!1,r=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(r);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,a),l=a?this.getPath(d):this.getHitablePath(d);return this.clear(),s?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:s,y:a}=this.point,r={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=e.length;s<a;s++)if(n=e[s],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,r),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return this.target&&n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,r;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!a||!a.has(r));t++)n.add(r)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||B(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:E,NoAndSkip:L,YesAndSkip:R}=t.Answer,k={},P={},S={};class C{constructor(e,n){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,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new b(e,this),e&&this.__listenEvents()}getBy(e,n,i,s){switch(typeof e){case"number":const a=this.getByInnerId(e,n);return i?a:a?[a]:[];case"string":switch(e[0]){case"#":k.id=e.substring(1),e=k;break;case".":P.className=e.substring(1),e=P;break;default:S.tag=e,e=S}case"object":if(void 0!==e.id){const t=this.getById(e.id,n);return i?t:t?[t]:[]}if(e.tag){const{tag:s}=e,a=s instanceof Array;return this.getByMethod(a?this.methods.tags:this.methods.tag,n,i,a?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,n,i,e.className);case"function":return this.getByMethod(e,n,i,s)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),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,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let r=0,o=t.length;r<o;r++){if(s=t[r],a=e(s,i),a===E||a===R){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<L&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__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={})}}function M(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function A(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?I(t,!0,e,n):W(e,n);break;case"inside":O("inside",t,s,e,n);break;case"outside":O("outside",t,s,e,n)}}function O(t,e,n,i,s){const{__strokeWidth:a,__font:r}=i.__,o=s.getSameCanvas(!0,!0);o.setStroke(n?void 0:e,2*a,i.__),o.font=r,n?I(e,!0,i,o):W(i,o),o.blendMode="outside"===t?"destination-out":"destination-in",M(i,o),o.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(o,i.__nowWorld):s.copyWorldToInner(o,i.__nowWorld,i.__layout.renderBounds),o.recycle(i.__nowWorld)}function W(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function I(t,e,i,s){let a;for(let r=0,o=t.length;r<o;r++)a=t[r],a.image&&n.PaintImage.checkImage(i,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?W(i,s):s.stroke(),s.restoreBlendMode()):e?W(i,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new o(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new x(t,e,n),selector:(t,e)=>new C(t,e)}),t.Platform.layout=y.fullLayout;const{getSpread:T,getOuterOf:D,getByMove:H,getIntersectData:F}=t.BoundsHelper;let Y;function N(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:a,blendMode:r,color:o,opacity:d}=e;return{type:a,blendMode:r,style:n.ColorConvert.string(o,d)};case"image":return n.PaintImage.image(i,t,e,s,!Y||!Y[e.url]);case"linear":return n.PaintGradient.linearGradient(e,s);case"radial":return n.PaintGradient.radialGradient(e,s);case"angular":return n.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:n.ColorConvert.string(e)}:void 0}}const j={compute:function(t,e){const i=e.__,s=[];let a,r=i.__input[t];r instanceof Array||(r=[r]),Y=n.PaintImage.recycleImage(t,i);for(let n,i=0,a=r.length;i<a;i++)n=N(t,r[i],e),n&&s.push(n);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=a:i.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?M(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,i){let s;const{windingRule:a,__font:r}=e.__;for(let o=0,d=t.length;o<d;o++)s=t[o],s.image&&n.PaintImage.checkImage(e,i,s,!r)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),r?M(e,i):a?i.fill(a):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),r?M(e,i):a?i.fill(a):i.fill(),i.restoreBlendMode()):r?M(e,i):a?i.fill(a):i.fill())},fillText:M,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)A(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)A(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),I(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),I(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,i),I(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,a),r.recycle(e.__nowWorld)}},strokeText:A,drawTextStroke:W,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,r,o,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,a=o=s;else{const{renderShapeSpread:i}=t.__layout,c=F(i?T(e.bounds,l===h?i*l:[i*h,i*l]):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),o=D(s,r),a=H(o,-r.e,-r.f),n.matrix){const{matrix:t}=n;r.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:r.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:r,bounds:a,worldCanvas:d,shapeBounds:o,scaleX:l,scaleY:h}}};let G={};const{get:X,rotateOfOuter:U,translate:z,scaleOfOuter:q,scale:V,rotate:Q}=t.MatrixHelper;function J(t,e,n,i,s,a,r){const o=X();z(o,e.x+n,e.y+i),V(o,s,a),r&&U(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function K(t,e,n,i,s,a,r){const o=X();z(o,e.x+n,e.y+i),s&&V(o,s,a),r&&Q(o,r),t.transform=o}function Z(t,e,n,i,s,a,r,o,d,l){const h=X();if(d)if("center"===l)U(h,{x:n/2,y:i/2},d);else switch(Q(h,d),d){case 90:z(h,i,0);break;case 180:z(h,n,i);break;case 270:z(h,0,n)}G.x=e.x+s,G.y=e.y+a,z(h,G.x,G.y),r&&q(h,G,r,o),t.transform=h}const{get:$,translate:tt}=t.MatrixHelper,et=new t.Bounds,nt={},it={};function st(t,e,n,i){const{blendMode:s,sync:a}=n;s&&(t.blendMode=s),a&&(t.sync=a),t.data=at(n,i,e)}function at(e,n,i){let{width:s,height:a}=i;e.padding&&(n=et.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:r,mode:o,align:d,offset:l,scale:h,size:c,rotation:u,repeat:f}=e,g=n.width===s&&n.height===a,p={mode:o},_="center"!==d&&(u||0)%180==90,w=_?a:s,m=_?s:a;let y,v,x=0,B=0;if(o&&"cover"!==o&&"fit"!==o)(h||c)&&(t.MathHelper.getScaleData(h,c,i,it),y=it.scaleX,v=it.scaleY);else if(!g||u){const t=n.width/w,e=n.height/m;y=v="fit"===o?Math.min(t,e):Math.max(t,e),x+=(n.width-s*y)/2,B+=(n.height-a*v)/2}if(d){const e={x:x,y:B,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(d,e,n,nt,!0),x+=nt.x,B+=nt.y}switch(l&&(x+=l.x,B+=l.y),o){case"stretch":g||(s=n.width,a=n.height);break;case"normal":case"clip":(x||B||y||u)&&K(p,n,x,B,y,v,u);break;case"repeat":(!g||y||u)&&Z(p,n,s,a,x,B,y,v,u,d),f||(p.repeat="repeat");break;default:y&&J(p,n,x,B,y,v,u)}return p.transform||(n.x||n.y)&&(p.transform=$(),tt(p.transform,n.x,n.y)),y&&"stretch"!==o&&(p.scaleX=y,p.scaleY=v),p.width=s,p.height=a,r&&(p.opacity=r),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),p}let rt,ot=new t.Bounds;const{isSame:dt}=t.BoundsHelper;function lt(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.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||st(s,i,n,a),!0}function ht(e,n){ft(e,t.ImageEvent.LOAD,n)}function ct(e,n){ft(e,t.ImageEvent.LOADED,n)}function ut(e,n,i){n.error=i,e.forceUpdate("surface"),ft(e,t.ImageEvent.ERROR,n)}function ft(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function gt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:pt,scale:_t,copy:wt}=t.MatrixHelper,{ceil:mt,abs:yt}=Math;function vt(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const r=s+"-"+a+"-"+i;if(n.patternId===r||e.destroyed)return!1;{s=yt(s),a=yt(a);const{image:e,data:o}=n;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=o;u&&(l=pt(),wt(l,p),_t(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const w=h*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&&(d=Math.sqrt(w/m)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(l||(l=pt(),p&&wt(l,p)),_t(l,1/s,1/a));const y=e.getCanvas(mt(h)||1,mt(c)||1,g),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=r,!0}}function xt(t,e,n,i){return new(n||(n=Promise))((function(s,a){function r(t){try{d(i.next(t))}catch(t){a(t)}}function o(t){try{d(i.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:Bt}=Math;const bt={image:function(e,n,i,s,a){let r,o;const d=t.ImageManager.get(i);return rt&&i===rt.paint&&dt(s,rt.boxBounds)?r=rt.leafPaint:(r={type:i.type,image:d},rt=d.use>1?{leafPaint:r,paint:i,boxBounds:ot.set(s)}:null),(a||d.loading)&&(o={image:d,attrName:n,attrValue:i}),d.ready?(lt(e,n,i,d,r,s),a&&(ht(e,o),ct(e,o))):d.error?a&&ut(e,o,d.error):(a&&(gt(e,!0),ht(e,o)),r.loadId=d.load((()=>{gt(e,!1),e.destroyed||(lt(e,n,i,d,r,s)&&(d.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ct(e,o)),r.loadId=null}),(t=>{gt(e,!1),ut(e,o,t),r.loadId=null}))),r},checkImage:function(e,i,s,a){const{scaleX:r,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=i;if(!s.data||s.patternId===r+"-"+o+"-"+d&&!n.Export.running)return!1;{const{data:l}=s;if(a)if(l.repeat)a=!1;else{let{width:e,height:i}=l;e*=Bt(r)*d,i*=Bt(o)*d,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),a=e*i>t.Platform.image.maxCacheSize||n.Export.running}return a?(i.save(),e.windingRule?i.clip(e.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),l.opacity&&(i.opacity*=l.opacity),l.transform&&i.transform(l.transform),i.drawImage(s.image.view,0,0,l.width,l.height),i.restore(),!0):(!s.style||s.sync||n.Export.running?vt(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>xt(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(e.__nowWorld)&&vt(e,s,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:vt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,r,o;for(let d=0,l=i.length;d<l;d++)s=i[d].image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,t.ImageManager.recycle(s),s.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===o)))));return a}return null},createData:st,getPatternData:at,fillOrFitMode:J,clipMode:K,repeatMode:Z},{toPoint:Et}=t.AroundHelper,Lt={},Rt={};function kt(t,e,i){if(e){let s;for(let a=0,r=e.length;a<r;a++)s=e[a],"string"==typeof s?t.addColorStop(a/(r-1),n.ColorConvert.string(s,i)):t.addColorStop(s.offset,n.ColorConvert.string(s.color,i))}}const{getAngle:Pt,getDistance:St}=t.PointHelper,{get:Ct,rotateOfOuter:Mt,scaleOfOuter:At}=t.MatrixHelper,{toPoint:Ot}=t.AroundHelper,Wt={},It={};function Tt(t,e,n,i,s){let a;const{width:r,height:o}=t;if(r!==o||i){const t=Pt(e,n);a=Ct(),s?(At(a,e,r/o*(i||1),1),Mt(a,e,t+90)):(At(a,e,1,r/o*(i||1)),Mt(a,e,t))}return a}const{getDistance:Dt}=t.PointHelper,{toPoint:Ht}=t.AroundHelper,Ft={},Yt={};const Nt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:r,opacity:o}=e;Et(i||"top",n,Lt),Et(s||"bottom",n,Rt);const d=t.Platform.canvas.createLinearGradient(Lt.x,Lt.y,Rt.x,Rt.y);kt(d,e.stops,o);const l={type:a,style:d};return r&&(l.blendMode=r),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;Ot(i||"center",n,Wt),Ot(s||"bottom",n,It);const l=t.Platform.canvas.createRadialGradient(Wt.x,Wt.y,0,Wt.x,Wt.y,St(Wt,It));kt(l,e.stops,r);const h={type:a,style:l},c=Tt(n,Wt,It,d,!0);return c&&(h.transform=c),o&&(h.blendMode=o),h},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;Ht(i||"center",n,Ft),Ht(s||"bottom",n,Yt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ft.x,Ft.y):t.Platform.canvas.createRadialGradient(Ft.x,Ft.y,0,Ft.x,Ft.y,Dt(Ft,Yt));kt(l,e.stops,r);const h={type:a,style:l},c=Tt(n,Ft,Yt,d||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),o&&(h.blendMode=o),h},getTransform:Tt},{copy:jt,toOffsetOutBounds:Gt}=t.BoundsHelper,Xt={},Ut={};function zt(e,n,i,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(jt(Xt,e.bounds),Xt.x+=n.x-r.x,Xt.y+=n.y-r.y,i){const{matrix:t}=s;Xt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Xt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Xt.width*=i,Xt.height*=i}e.copyWorld(s.canvas,e.bounds,Xt)}else i&&(jt(Xt,n),Xt.x-=n.width/2*(i-1),Xt.y-=n.height/2*(i-1),Xt.width*=i,Xt.height*=i),e.copyWorld(s.canvas,r,i?Xt:n)}const{toOffsetOutBounds:qt}=t.BoundsHelper,Vt={};const Qt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;Gt(l,Ut),o.forEach(((o,p)=>{f.setWorldShadow(Ut.offsetX+o.x*c,Ut.offsetY+o.y*u,o.blur*c,o.color),s=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,zt(f,Ut,s,n),i=l,o.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=o.length-1;qt(l,Vt),o.forEach(((o,p)=>{f.save(),f.setWorldShadow(Vt.offsetX+o.x*c,Vt.offsetY+o.y*u,o.blur*c),s=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,zt(f,Vt,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,l,"source-out"),i=l),f.fillWorld(i,o.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Jt}=t.LeafBoundsHelper;function Kt(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),$t(t,e,n,1)}(t,n,i,s);break;case"opacity-path":$t(t,n,i,a);break;case"path":n.restore()}}function Zt(t){return t.getSameCanvas(!1,!0)}function $t(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}n.Group.prototype.__renderMask=function(t,e){let n,i,s,a,r;const{children:o}=this;for(let d=0,l=o.length;d<l;d++)n=o[d],n.__.mask&&(r&&(Kt(this,r,t,s,i,a),i=s=null),"path"===n.__.mask?(n.opacity<1?(r="opacity-path",a=n.opacity,s||(s=Zt(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="alpha",i||(i=Zt(t)),s||(s=Zt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Jt(n,e)||n.__render(s||t,e);Kt(this,r,t,s,i,a)};const te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ee=te+"_#~&*+\\=|≮≯≈≠=…",ne=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 ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const se=ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ae=ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),re=ie(te),oe=ie(ee),de=ie("- —/~|┆·");var le;!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"}(le||(le={}));const{Letter:he,Single:ce,Before:ue,After:fe,Symbol:ge,Break:pe}=le;function _e(t){return se[t]?he:de[t]?pe:ae[t]?ue:re[t]?fe:oe[t]?ge:ne.test(t)?ce:he}const we={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function me(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ye}=we,{Letter:ve,Single:xe,Before:Be,After:be,Symbol:Ee,Break:Le}=le;let Re,ke,Pe,Se,Ce,Me,Ae,Oe,We,Ie,Te,De,He,Fe,Ye,Ne,je,Ge=[];function Xe(t,e){We&&!Oe&&(Oe=We),Re.data.push({char:t,width:e}),Pe+=e}function Ue(){Se+=Pe,Re.width=Pe,ke.words.push(Re),Re={data:[]},Pe=0}function ze(){Fe&&(Ye.paraNumber++,ke.paraStart=!0,Fe=!1),We&&(ke.startCharSize=Oe,ke.endCharSize=We,Oe=0),ke.width=Se,Ne.width?ye(ke):je&&qe(),Ge.push(ke),ke={words:[]},Se=0}function qe(){Se>(Ye.maxWidth||0)&&(Ye.maxWidth=Se)}const Ve=0,Qe=1,Je=2;const{top:Ke,right:Ze,bottom:$e,left:tn}=t.Direction4;function en(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const nn={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:o,__font:d,__padding:l}=n;l&&(a?(i=l[tn],a-=l[Ze]+l[tn]):n.autoSizeAlign||(i=l[tn]),r?(s=l[Ke],r-=l[Ke]+l[$e]):n.autoSizeAlign||(s=l[Ke]));const h={bounds:{x:i,y:s,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Ye=e,Ge=e.rows,Ne=e.bounds,je=!Ne.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=i,{canvas:o}=t.Platform,{width:d,height:l}=Ne;if(d||l||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Fe=!0,Te=null,Oe=Ae=We=Pe=Se=0,Re={data:[]},ke={words:[]};for(let i=0,l=n.length;i<l;i++)Me=n[i],"\n"===Me?(Pe&&Ue(),ke.paraEnd=!0,ze(),Fe=!0):(Ie=_e(Me),Ie===ve&&"none"!==r&&(Me=me(Me,r,!Pe)),Ae=o.measureText(Me).width,s&&(s<0&&(We=Ae),Ae+=s),De=Ie===xe&&(Te===xe||Te===ve)||Te===xe&&Ie!==be,He=!(Ie!==Be&&Ie!==xe||Te!==Ee&&Te!==be),Ce=Fe&&a?d-a:d,t&&d&&Se+Pe+Ae>Ce&&(e?(Pe&&Ue(),Se&&ze()):(He||(He=Ie===ve&&Te==be),De||He||Ie===Le||Ie===Be||Ie===xe||Pe+Ae>Ce?(Pe&&Ue(),Se&&ze()):Se&&ze()))," "===Me&&!0!==Fe&&Se+Pe===0||(Ie===Le?(" "===Me&&Pe&&Ue(),Xe(Me,Ae),Ue()):De||He?(Pe&&Ue(),Xe(Me,Ae)):Xe(Me,Ae)),Te=Ie);Pe&&Ue(),Se&&ze(),Ge.length>0&&(Ge[Ge.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ye.paraNumber++,Se=o.measureText(t).width,Ge.push({x:a||0,text:t,width:Se,paraStart:!0}),je&&qe()}))}(h,e,n),l&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":en(e,"x",t[tn]);break;case"right":en(e,"x",-t[Ze])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":en(e,"y",t[Ke]);break;case"bottom":en(e,"y",-t[$e])}}(l,h,n,a,r),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:p}=i,_=s*n.length+(h?h*(t.paraNumber-1):0),w=a;if(o&&_>p)_=Math.max(p,s),t.overflow=n.length;else if(p||c)switch(l){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let m,y,v,x=g||c?g:t.maxWidth;for(let a=0,l=n.length;a<l;a++){if(m=n[a],m.x=u,m.width<g||m.width>g&&!o)switch(d){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&h&&a>0&&(w+=h),m.y=w,w+=s,t.overflow>a&&w>_&&(m.isOverflow=!0,t.overflow=a+1),y=m.x,v=m.width,r<0&&(m.width<0?(v=-m.width+e.fontSize+r,y-=v,v+=e.fontSize):v-=r),y<i.x&&(i.x=y),v>i.width&&(i.width=v),o&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:r,letterSpacing:o}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=r&&t.paraStart?r:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?Ve:l>.01?Qe:Je,t.isOverflow&&!o&&(t.textMode=!0),c===Je?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Qe?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,n,a),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:a,overflow:r}=e;let{textOverflow:o}=n;if(a.splice(r),o&&"show"!==o){let e,d;"hide"===o?o="":"ellipsis"===o&&(o="...");const l=o?t.Platform.canvas.measureText(o).width:0,h=i+s-l;("none"===n.textWrap?a:[a[r-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],d=e.x+e.width,!(i===n&&d<h));i--){if(d<h&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=l,t.data.push({char:o,x:d}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,i,a),"none"!==o&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const sn={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!n.ColorConvert.object)return t;t=n.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}},{setPoint:an,addPoint:rn,toBounds:on}=t.TwoPointBoundsHelper;const dn={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),a=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){ln||(ln=new t.TaskProcessor);return new Promise((t=>{ln.add((()=>xt(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((r=>new Promise((o=>{const d=t=>{r(t),o(),this.running=!1},{toURL:l}=t.Platform,{download:h}=t.Platform.origin;if("json"===s)return a&&h(l(JSON.stringify(e.toJSON(i.json)),"text"),n),d({data:!!a||e.toJSON(i.json)});if("svg"===s)return a&&h(l(e.toSVG(),"svg"),n),d({data:!!a||e.toSVG()});const{leafer:c}=e;c?(hn(e),c.waitViewCompleted((()=>xt(this,void 0,void 0,(function*(){let s,a,r=1,o=1;const{worldTransform:l,isLeafer:h,isFrame:u}=e,{slice:f,trim:g,onCanvas:p}=i,_=void 0===i.smooth?c.config.smooth:i.smooth,w=i.contextSettings||c.config.contextSettings,m=i.screenshot||e.isApp,y=h&&m&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)s=!0===m?h?c.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(h?"inner":"local");switch(r=l.scaleX,o=l.scaleY,t){case"inner":x.set(l);break;case"local":x.set(l).divide(e.localTransform),r/=e.scaleX,o/=e.scaleY;break;case"world":r=1,o=1;break;case"page":t=e.leafer;default:x.set(l).divide(e.getTransform(t));const n=t.worldTransform;r/=r/n.scaleX,o/=o/n.scaleY}s=e.getBounds("render",t)}const B={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,B);let b=i.pixelRatio||1;e.isApp&&(B.scaleX*=b,B.scaleY*=b,b=e.app.pixelRatio);const{x:E,y:L,width:R,height:k}=new t.Bounds(s).scale(B.scaleX,B.scaleY),P={matrix:x.scale(1/B.scaleX,1/B.scaleY).invert().translate(-E,-L).withScale(1/r*B.scaleX,1/o*B.scaleY)};let S,C=t.Creator.canvas({width:Math.round(R),height:Math.round(k),pixelRatio:b,smooth:_,contextSettings:w});if(f&&(S=e,S.__worldOpacity=0,e=c,P.bounds=C.bounds),C.save(),u&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(C,P),e.fill=t}else e.__render(C,P);if(C.restore(),S&&S.__updateWorldOpacity(),g){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,r,o,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,r=(d-a)/n,o?rn(o,a,r):an(o={},a,r)),d++;const l=new t.Bounds;return on(o,l),l.scale(1/e.pixelRatio).ceil()}(C);const e=C,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:b};C=t.Creator.canvas(s),C.copyWorld(e,a,s)}v&&C.fillWorld(C.bounds,y||"#FFFFFF","destination-over"),p&&p(C);const M="canvas"===n?C:yield C.export(n,i);d({data:M,width:C.pixelWidth,height:C.pixelHeight,renderBounds:s,trimBounds:a})}))))):d({data:!1})}))))}};let ln;function hn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>hn(t)))}const cn=t.LeaferCanvasBase.prototype,un=t.Debug.get("@leafer-ui/export");cn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},cn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{un.error(t),i(null)}))}))},cn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},cn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{un.error(t),i(!1)}))}))},Object.assign(n.TextConvert,nn),Object.assign(n.ColorConvert,sn),Object.assign(n.Paint,j),Object.assign(n.PaintImage,bt),Object.assign(n.PaintGradient,Nt),Object.assign(n.Effect,Qt),Object.assign(n.Export,dn),Object.assign(t.Creator,{interaction:(t,n,i,s)=>new e.InteractionBase(t,n,i,s),hitCanvas:(t,e)=>new i(t,e),hitCanvasManager:()=>new e.HitCanvasManager}),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=x,exports.Selector=C,exports.Watcher=o,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|