@leafer-ui/node 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node.cjs +4 -3
- package/dist/node.esm.js +5 -4
- package/dist/node.esm.min.js +1 -1
- package/dist/node.min.cjs +1 -1
- package/package.json +11 -11
package/dist/node.cjs
CHANGED
|
@@ -547,7 +547,7 @@ class Renderer {
|
|
|
547
547
|
partRender() {
|
|
548
548
|
const { canvas, updateBlocks: list } = this;
|
|
549
549
|
if (!list)
|
|
550
|
-
return
|
|
550
|
+
return;
|
|
551
551
|
this.mergeBlocks();
|
|
552
552
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
553
553
|
this.clipRender(block); });
|
|
@@ -2062,7 +2062,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2062
2062
|
rows.forEach(row => {
|
|
2063
2063
|
if (row.words) {
|
|
2064
2064
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2065
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2065
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2066
2066
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2067
2067
|
if (row.isOverflow && !letterSpacing)
|
|
2068
2068
|
row.textMode = true;
|
|
@@ -2084,7 +2084,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2084
2084
|
else {
|
|
2085
2085
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
2086
2086
|
}
|
|
2087
|
-
if (!row.paraEnd
|
|
2087
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
2088
2088
|
charX += addWordWidth;
|
|
2089
2089
|
row.width += addWordWidth;
|
|
2090
2090
|
}
|
|
@@ -2517,6 +2517,7 @@ canvas.saveAs = function (filename, quality) {
|
|
|
2517
2517
|
});
|
|
2518
2518
|
};
|
|
2519
2519
|
|
|
2520
|
+
draw.Plugin.add('export');
|
|
2520
2521
|
Object.assign(draw.Export, ExportModule);
|
|
2521
2522
|
draw.UI.prototype.export = function (filename, options) {
|
|
2522
2523
|
return draw.Export.export(this, filename, options);
|
package/dist/node.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ export { LeaferImage } from '@leafer/core';
|
|
|
4
4
|
import { writeFileSync } from 'fs';
|
|
5
5
|
import { InteractionBase, HitCanvasManager } from '@leafer-ui/core';
|
|
6
6
|
export * from '@leafer-ui/core';
|
|
7
|
-
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect, Bounds as Bounds$1, TwoPointBoundsHelper, FileHelper as FileHelper$1, TaskProcessor, Platform as Platform$1, Matrix, MathHelper as MathHelper$1, Creator as Creator$1, LeaferCanvasBase as LeaferCanvasBase$1, Debug as Debug$1, UI } from '@leafer-ui/draw';
|
|
7
|
+
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect, Bounds as Bounds$1, TwoPointBoundsHelper, FileHelper as FileHelper$1, TaskProcessor, Platform as Platform$1, Matrix, MathHelper as MathHelper$1, Creator as Creator$1, LeaferCanvasBase as LeaferCanvasBase$1, Debug as Debug$1, Plugin as Plugin$1, UI } from '@leafer-ui/draw';
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
10
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -548,7 +548,7 @@ class Renderer {
|
|
|
548
548
|
partRender() {
|
|
549
549
|
const { canvas, updateBlocks: list } = this;
|
|
550
550
|
if (!list)
|
|
551
|
-
return
|
|
551
|
+
return;
|
|
552
552
|
this.mergeBlocks();
|
|
553
553
|
list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
|
|
554
554
|
this.clipRender(block); });
|
|
@@ -2063,7 +2063,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2063
2063
|
rows.forEach(row => {
|
|
2064
2064
|
if (row.words) {
|
|
2065
2065
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
2066
|
-
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2066
|
+
addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
2067
2067
|
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
2068
2068
|
if (row.isOverflow && !letterSpacing)
|
|
2069
2069
|
row.textMode = true;
|
|
@@ -2085,7 +2085,7 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
2085
2085
|
else {
|
|
2086
2086
|
charX = toChar(word.data, charX, row.data, row.isOverflow);
|
|
2087
2087
|
}
|
|
2088
|
-
if (!row.paraEnd
|
|
2088
|
+
if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
|
|
2089
2089
|
charX += addWordWidth;
|
|
2090
2090
|
row.width += addWordWidth;
|
|
2091
2091
|
}
|
|
@@ -2518,6 +2518,7 @@ canvas.saveAs = function (filename, quality) {
|
|
|
2518
2518
|
});
|
|
2519
2519
|
};
|
|
2520
2520
|
|
|
2521
|
+
Plugin$1.add('export');
|
|
2521
2522
|
Object.assign(Export, ExportModule);
|
|
2522
2523
|
UI.prototype.export = function (filename, options) {
|
|
2523
2524
|
return Export.export(this, filename, options);
|
package/dist/node.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,Plugin as R,MatrixHelper as k,MathHelper as S,AlignHelper as L,ImageEvent as E,AroundHelper as A,PointHelper as W,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as O}from"fs";import{InteractionBase as C,HitCanvasManager as M}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as P,ColorConvert as D,PaintGradient as I,Export as F,Group as Y,TextConvert as U,Paint as X,Effect as N,Bounds as j,TwoPointBoundsHelper as z,FileHelper as G,TaskProcessor as H,Platform as q,Matrix as V,MathHelper as Q,Creator as J,LeaferCanvasBase as Z,Debug as $,UI as K}from"@leafer-ui/draw";function tt(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;class et extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:it,fileType:nt}=o;function st(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(it(e),i),canvasToBolb:(t,e,i)=>tt(this,void 0,void 0,(function*(){return t.toBuffer(it(e),i)})),canvasSaveAs:(t,e,i)=>tt(this,void 0,void 0,(function*(){return O(e,t.toBuffer(it(nt(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new et(t,e),image:t=>new s(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class at{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:ot,updateBounds:rt,updateAllWorldOpacity:dt}=f,{pushAllChildBranch:lt,pushAllParent:ht}=g;const{worldBounds:ct}=p,ut={x:0,y:0,width:1e5,height:1e5};class ft{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,ct)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(ut):this.afterBounds.setListWithFn(t,ct),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:gt,updateAllChange:_t}=f,pt=w.get("Layouter");class wt{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){pt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?pt.warn("layouting"):this.times>3?pt.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?(ot(t,!0),e.add(t),t.isBranch&<(t,e),ht(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ht(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||rt(n[t])}rt(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&dt(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)),wt.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){gt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),_t(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ft([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new ft(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 yt=w.get("Renderer");class mt{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()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,yt.log(e.innerName,"---\x3e");try{e.isApp||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,yt.error(t)}yt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return yt.warn("rendering");if(this.times>3)return yt.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 yt.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(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}))}__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.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||yt.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:vt}=B;class xt{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||vt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class bt{constructor(t,e){this.config={},e&&(this.config=d.default(e,this.config)),this.picker=new xt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,n){return e.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):R.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}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.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 Rt(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?Lt(t,!0,e,i):St(e,i);break;case"inside":kt("inside",t,s,e,i);break;case"outside":kt("outside",t,s,e,i)}}function kt(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?Lt(e,!0,n,r):St(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",Bt(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 St(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 Lt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?St(i,n):n.stroke(),n.restoreBlendMode()):e?St(i,n):n.stroke())}function Et(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(n,{watcher:(t,e)=>new at(t,e),layouter:(t,e)=>new wt(t,e),renderer:(t,e,i)=>new mt(t,e,i),selector:(t,e)=>new bt(t,e)}),e.layout=wt.fullLayout;const{getSpread:At,getOuterOf:Wt,getByMove:Tt,getIntersectData:Ot}=B;let Ct;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:D.string(o,r)};case"image":return P.image(i,t,e,n,!Ct||!Ct[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const Pt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Ct=P.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?Bt(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&&P.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?Bt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?Bt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?Bt(e,i):s?i.fill(s):i.fill())},fillText:Bt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)Rt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&Et(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)Rt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),Lt(t,!1,e,i),n.__useArrow&&Et(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),Lt(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),Lt(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:Rt,drawTextStroke:St,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=Ot(n?At(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=Wt(s,o),a=Tt(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 Dt={};const{get:It,rotateOfOuter:Ft,translate:Yt,scaleOfOuter:Ut,scale:Xt,rotate:Nt}=k;function jt(t,e,i,n,s,a,o){const r=It();Yt(r,e.x+i,e.y+n),Xt(r,s,a),o&&Ft(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function zt(t,e,i,n,s,a,o){const r=It();Yt(r,e.x+i,e.y+n),s&&Xt(r,s,a),o&&Nt(r,o),t.transform=r}function Gt(t,e,i,n,s,a,o,r,d,l){const h=It();if(d)if("center"===l)Ft(h,{x:i/2,y:n/2},d);else switch(Nt(h,d),d){case 90:Yt(h,n,0);break;case 180:Yt(h,i,n);break;case 270:Yt(h,0,i)}Dt.x=e.x+s,Dt.y=e.y+a,Yt(h,Dt.x,Dt.y),o&&Ut(h,Dt,o,r),t.transform=h}const{get:Ht,translate:qt}=k,Vt=new _,Qt={},Jt={};function Zt(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=$t(i,n,e)}function $t(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Vt.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,Jt),y=Jt.scaleX,m=Jt.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),L.toPoint(r,t,e,Qt,!0),v+=Qt.x,x+=Qt.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)&&zt(g,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Gt(g,e,n,s,v,x,y,m,c,r),u||(g.repeat="repeat");break;default:y&&jt(g,e,v,x,y,m,c)}return g.transform||(e.x||e.y)&&(g.transform=Ht(),qt(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 Kt,te=new _;const{isSame:ee}=B;function ie(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 ne(t,e){oe(t,E.LOAD,e)}function se(t,e){oe(t,E.LOADED,e)}function ae(t,e,i){e.error=i,t.forceUpdate("surface"),oe(t,E.ERROR,e)}function oe(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function re(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:de,scale:le,copy:he}=k,{ceil:ce,abs:ue}=Math;function fe(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=ue(s),a=ue(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=de(),he(l,_),le(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=de(),_&&he(l,_)),le(l,1/s,1/a));const m=t.getCanvas(ce(h)||1,ce(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=o,!0}}const{abs:ge}=Math;const _e={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return Kt&&i===Kt.paint&&ee(n,Kt.boxBounds)?a=Kt.leafPaint:(a={type:i.type,image:r},Kt=r.use>1?{leafPaint:a,paint:i,boxBounds:te.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ie(t,e,i,r,a,n),s&&(ne(t,o),se(t,o))):r.error?s&&ae(t,o,r.error):(s&&(re(t,!0),ne(t,o)),a.loadId=r.load((()=>{re(t,!1),t.destroyed||(ie(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),se(t,o)),a.loadId=null}),(e=>{re(t,!1),ae(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&&!F.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=ge(a)*r,i*=ge(o)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||F.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||F.running?fe(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>tt(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&fe(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:fe,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:$t,fillOrFitMode:jt,clipMode:zt,repeatMode:Gt},{toPoint:pe}=A,we={},ye={};function me(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),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:ve,getDistance:xe}=W,{get:be,rotateOfOuter:Be,scaleOfOuter:Re}=k,{toPoint:ke}=A,Se={},Le={};function Ee(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=ve(e,i);a=be(),s?(Re(a,e,o/r*(n||1),1),Be(a,e,t+90)):(Re(a,e,1,o/r*(n||1)),Be(a,e,t))}return a}const{getDistance:Ae}=W,{toPoint:We}=A,Te={},Oe={};const Ce={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;pe(n||"top",i,we),pe(s||"bottom",i,ye);const d=e.canvas.createLinearGradient(we.x,we.y,ye.x,ye.y);me(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;ke(n||"center",i,Se),ke(s||"bottom",i,Le);const l=e.canvas.createRadialGradient(Se.x,Se.y,0,Se.x,Se.y,xe(Se,Le));me(l,t.stops,o);const h={type:a,style:l},c=Ee(i,Se,Le,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;We(n||"center",i,Te),We(s||"bottom",i,Oe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Te.x,Te.y):e.canvas.createRadialGradient(Te.x,Te.y,0,Te.x,Te.y,Ae(Te,Oe));me(l,t.stops,o);const h={type:a,style:l},c=Ee(i,Te,Oe,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Ee},{copy:Me,toOffsetOutBounds:Pe}=B,De={},Ie={};function Fe(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Me(De,t.bounds),De.x+=i.x-o.x,De.y+=i.y-o.y,n){const{matrix:t}=s;De.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),De.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),De.width*=n,De.height*=n}t.copyWorld(s.canvas,t.bounds,De)}else n&&(Me(De,i),De.x-=i.width/2*(n-1),De.y-=i.height/2*(n-1),De.width*=n,De.height*=n),t.copyWorld(s.canvas,o,n?De:i)}const{toOffsetOutBounds:Ye}=B,Ue={};const Xe={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;Pe(l,Ie),r.forEach(((r,_)=>{f.setWorldShadow(Ie.offsetX+r.x*c,Ie.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Fe(f,Ie,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;Ye(l,Ue),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Ue.offsetX+r.x*c,Ue.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Fe(f,Ue,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:Ne}=p;function je(t,e,i,n,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),Ge(t,e,i,1)}(t,i,n,s);break;case"opacity-path":Ge(t,i,n,a);break;case"path":i.restore()}}function ze(t){return t.getSameCanvas(!1,!0)}function Ge(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,a,o,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(o&&(je(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=ze(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=ze(t)),s||(s=ze(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Ne(i,e)||i.__render(s||t,e);je(this,o,t,s,n,a)};const He=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",qe=He+"_#~&*+\\=|≮≯≈≠=…",Ve=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 Qe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Je=Qe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ze=Qe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),$e=Qe(He),Ke=Qe(qe),ti=Qe("- —/~|┆·");var ei;!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"}(ei||(ei={}));const{Letter:ii,Single:ni,Before:si,After:ai,Symbol:oi,Break:ri}=ei;function di(t){return Je[t]?ii:ti[t]?ri:Ze[t]?si:$e[t]?ai:Ke[t]?oi:Ve.test(t)?ni:ii}const li={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 hi(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:ci}=li,{Letter:ui,Single:fi,Before:gi,After:_i,Symbol:pi,Break:wi}=ei;let yi,mi,vi,xi,bi,Bi,Ri,ki,Si,Li,Ei,Ai,Wi,Ti,Oi,Ci,Mi,Pi=[];function Di(t,e){Si&&!ki&&(ki=Si),yi.data.push({char:t,width:e}),vi+=e}function Ii(){xi+=vi,yi.width=vi,mi.words.push(yi),yi={data:[]},vi=0}function Fi(){Ti&&(Oi.paraNumber++,mi.paraStart=!0,Ti=!1),Si&&(mi.startCharSize=ki,mi.endCharSize=Si,ki=0),mi.width=xi,Ci.width?ci(mi):Mi&&Yi(),Pi.push(mi),mi={words:[]},xi=0}function Yi(){xi>(Oi.maxWidth||0)&&(Oi.maxWidth=xi)}const Ui=0,Xi=1,Ni=2;const{top:ji,right:zi,bottom:Gi,left:Hi}=T;function qi(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 Vi={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[Hi],a-=l[zi]+l[Hi]):i.autoSizeAlign||(n=l[Hi]),o?(s=l[ji],o-=l[ji]+l[Gi]):i.autoSizeAlign||(s=l[ji]));const h={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Oi=t,Pi=t.rows,Ci=t.bounds,Mi=!Ci.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:l}=Ci;if(d||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Ti=!0,Ei=null,ki=Ri=Si=vi=xi=0,yi={data:[]},mi={words:[]};for(let n=0,l=i.length;n<l;n++)Bi=i[n],"\n"===Bi?(vi&&Ii(),mi.paraEnd=!0,Fi(),Ti=!0):(Li=di(Bi),Li===ui&&"none"!==o&&(Bi=hi(Bi,o,!vi)),Ri=r.measureText(Bi).width,s&&(s<0&&(Si=Ri),Ri+=s),Ai=Li===fi&&(Ei===fi||Ei===ui)||Ei===fi&&Li!==_i,Wi=!(Li!==gi&&Li!==fi||Ei!==pi&&Ei!==_i),bi=Ti&&a?d-a:d,t&&d&&xi+vi+Ri>bi&&(e?(vi&&Ii(),xi&&Fi()):(Wi||(Wi=Li===ui&&Ei==_i),Ai||Wi||Li===wi||Li===gi||Li===fi||vi+Ri>bi?(vi&&Ii(),xi&&Fi()):xi&&Fi()))," "===Bi&&!0!==Ti&&xi+vi===0||(Li===wi?(" "===Bi&&vi&&Ii(),Di(Bi,Ri),Ii()):Ai||Wi?(vi&&Ii(),Di(Bi,Ri)):Di(Bi,Ri)),Ei=Li);vi&&Ii(),xi&&Fi(),Pi.length>0&&(Pi[Pi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Oi.paraNumber++,xi=r.measureText(t).width,Pi.push({x:a||0,text:t,width:xi,paraStart:!0}),Mi&&Yi()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":qi(e,"x",t[Hi]);break;case"right":qi(e,"x",-t[zi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":qi(e,"y",t[ji]);break;case"bottom":qi(e,"y",-t[Gi])}}(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?Ui:l>.01?Xi:Ni,t.isOverflow&&!r&&(t.textMode=!0),c===Ni?(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===Xi?(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 Qi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.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+")"}};Object.assign(U,Vi),Object.assign(D,Qi),Object.assign(X,Pt),Object.assign(P,_e),Object.assign(I,Ce),Object.assign(N,Xe);const{setPoint:Ji,addPoint:Zi,toBounds:$i}=z;const Ki={export(t,e,i){this.running=!0;const n=G.fileType(e),s=e.includes(".");return i=G.getExportOptions(i),function(t){tn||(tn=new H);return new Promise((e=>{tn.add((()=>tt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((a=>new Promise((o=>{const r=t=>{a(t),o(),this.running=!1},{toURL:d}=q,{download:l}=q.origin;if("json"===n)return s&&l(d(JSON.stringify(t.toJSON(i.json)),"text"),e),r({data:!!s||t.toJSON(i.json)});if("svg"===n)return s&&l(d(t.toSVG(),"svg"),e),r({data:!!s||t.toSVG()});const{leafer:h}=t;h?(en(t),h.waitViewCompleted((()=>tt(this,void 0,void 0,(function*(){let n,s,a=1,o=1;const{worldTransform:d,isLeafer:l,isFrame:c}=t,{slice:u,trim:f,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,p=i.contextSettings||h.config.contextSettings,w=i.screenshot||t.isApp,y=l&&w&&void 0===i.fill?t.fill:i.fill,m=G.isOpaqueImage(e)||y,v=new V;if(w)n=!0===w?l?h.canvas.bounds:t.worldRenderBounds:w;else{let e=i.relative||(l?"inner":"local");switch(a=d.scaleX,o=d.scaleY,e){case"inner":v.set(d);break;case"local":v.set(d).divide(t.localTransform),a/=t.scaleX,o/=t.scaleY;break;case"world":a=1,o=1;break;case"page":e=t.leafer;default:v.set(d).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,o/=o/i.scaleY}n=t.getBounds("render",e)}const x={scaleX:1,scaleY:1};Q.getScaleData(i.scale,i.size,n,x);let b=i.pixelRatio||1;t.isApp&&(x.scaleX*=b,x.scaleY*=b,b=t.app.pixelRatio);const{x:B,y:R,width:k,height:S}=new j(n).scale(x.scaleX,x.scaleY),L={matrix:v.scale(1/x.scaleX,1/x.scaleY).invert().translate(-B,-R).withScale(1/a*x.scaleX,1/o*x.scaleY)};let E,A=J.canvas({width:Math.round(k),height:Math.round(S),pixelRatio:b,smooth:_,contextSettings:p});if(u&&(E=t,E.__worldOpacity=0,t=h,L.bounds=A.bounds),A.save(),c&&void 0!==y){const e=t.get("fill");t.fill="",t.__render(A,L),t.fill=e}else t.__render(A,L);if(A.restore(),E&&E.__updateWorldOpacity(),f){s=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?Zi(o,s,a):Ji(o={},s,a)),r++;const d=new j;return $i(o,d),d.scale(1/t.pixelRatio).ceil()}(A);const t=A,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:b};A=J.canvas(n),A.copyWorld(t,s,n)}m&&A.fillWorld(A.bounds,y||"#FFFFFF","destination-over"),g&&g(A);const W="canvas"===e?A:yield A.export(e,i);r({data:W,width:A.pixelWidth,height:A.pixelHeight,renderBounds:n,trimBounds:s})}))))):r({data:!1})}))))}};let tn;function en(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>en(t)))}const nn=Z.prototype,sn=$.get("@leafer-in/export");nn.export=function(t,e){const{quality:i,blob:n}=G.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},nn.toBlob=function(t,e){return new Promise((i=>{q.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{sn.error(t),i(null)}))}))},nn.toDataURL=function(t,e){return q.origin.canvasToDataURL(this.view,t,e)},nn.saveAs=function(t,e){return new Promise((i=>{q.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{sn.error(t),i(!1)}))}))},Object.assign(F,Ki),K.prototype.export=function(t,e){return F.export(this,t,e)},Object.assign(n,{interaction:(t,e,i,n)=>new C(t,e,i,n),hitCanvas:(t,e)=>new et(t,e),hitCanvasManager:()=>new M});export{wt as Layouter,et as LeaferCanvas,xt as Picker,mt as Renderer,bt as Selector,at as Watcher,st 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,Plugin as R,MatrixHelper as k,MathHelper as S,AlignHelper as L,ImageEvent as E,AroundHelper as A,PointHelper as W,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as O}from"fs";import{InteractionBase as C,HitCanvasManager as M}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as P,ColorConvert as D,PaintGradient as I,Export as F,Group as Y,TextConvert as U,Paint as X,Effect as N,Bounds as j,TwoPointBoundsHelper as z,FileHelper as G,TaskProcessor as H,Platform as q,Matrix as V,MathHelper as Q,Creator as J,LeaferCanvasBase as Z,Debug as $,Plugin as K,UI as tt}from"@leafer-ui/draw";function et(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;class it extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:nt,fileType:st}=o;function at(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(nt(e),i),canvasToBolb:(t,e,i)=>et(this,void 0,void 0,(function*(){return t.toBuffer(nt(e),i)})),canvasSaveAs:(t,e,i)=>et(this,void 0,void 0,(function*(){return O(e,t.toBuffer(nt(st(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new it(t,e),image:t=>new s(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class ot{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:rt,updateBounds:dt,updateAllWorldOpacity:lt}=f,{pushAllChildBranch:ht,pushAllParent:ct}=g;const{worldBounds:ut}=p,ft={x:0,y:0,width:1e5,height:1e5};class gt{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,ut)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(ft):this.afterBounds.setListWithFn(t,ut),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:_t,updateAllChange:pt}=f,wt=w.get("Layouter");class yt{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){wt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?wt.warn("layouting"):this.times>3?wt.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?(rt(t,!0),e.add(t),t.isBranch&&ht(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(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||dt(n[t])}dt(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&<(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)),yt.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){_t(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),pt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new gt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new gt(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 mt=w.get("Renderer");class vt{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()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,mt.log(e.innerName,"---\x3e");try{e.isApp||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,mt.error(t)}mt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return mt.warn("rendering");if(this.times>3)return mt.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;e&&(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(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}))}__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.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||mt.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:xt}=B;class bt{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||xt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Bt{constructor(t,e){this.config={},e&&(this.config=d.default(e,this.config)),this.picker=new bt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,n){return e.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):R.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Rt(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 kt(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?Et(t,!0,e,i):Lt(e,i);break;case"inside":St("inside",t,s,e,i);break;case"outside":St("outside",t,s,e,i)}}function St(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?Et(e,!0,n,r):Lt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",Rt(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 Lt(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 Et(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?Lt(i,n):n.stroke(),n.restoreBlendMode()):e?Lt(i,n):n.stroke())}function At(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(n,{watcher:(t,e)=>new ot(t,e),layouter:(t,e)=>new yt(t,e),renderer:(t,e,i)=>new vt(t,e,i),selector:(t,e)=>new Bt(t,e)}),e.layout=yt.fullLayout;const{getSpread:Wt,getOuterOf:Tt,getByMove:Ot,getIntersectData:Ct}=B;let Mt;function Pt(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:D.string(o,r)};case"image":return P.image(i,t,e,n,!Mt||!Mt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const Dt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Mt=P.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=Pt(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?Rt(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&&P.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?Rt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?Rt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?Rt(e,i):s?i.fill(s):i.fill())},fillText:Rt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)kt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&At(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)kt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),Et(t,!1,e,i),n.__useArrow&&At(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),Et(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),Et(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:kt,drawTextStroke:Lt,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=Ct(n?Wt(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=Tt(s,o),a=Ot(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 It={};const{get:Ft,rotateOfOuter:Yt,translate:Ut,scaleOfOuter:Xt,scale:Nt,rotate:jt}=k;function zt(t,e,i,n,s,a,o){const r=Ft();Ut(r,e.x+i,e.y+n),Nt(r,s,a),o&&Yt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Gt(t,e,i,n,s,a,o){const r=Ft();Ut(r,e.x+i,e.y+n),s&&Nt(r,s,a),o&&jt(r,o),t.transform=r}function Ht(t,e,i,n,s,a,o,r,d,l){const h=Ft();if(d)if("center"===l)Yt(h,{x:i/2,y:n/2},d);else switch(jt(h,d),d){case 90:Ut(h,n,0);break;case 180:Ut(h,i,n);break;case 270:Ut(h,0,i)}It.x=e.x+s,It.y=e.y+a,Ut(h,It.x,It.y),o&&Xt(h,It,o,r),t.transform=h}const{get:qt,translate:Vt}=k,Qt=new _,Jt={},Zt={};function $t(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=Kt(i,n,e)}function Kt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Qt.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,Zt),y=Zt.scaleX,m=Zt.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),L.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)&&Gt(g,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Ht(g,e,n,s,v,x,y,m,c,r),u||(g.repeat="repeat");break;default:y&&zt(g,e,v,x,y,m,c)}return g.transform||(e.x||e.y)&&(g.transform=qt(),Vt(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 te,ee=new _;const{isSame:ie}=B;function ne(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||$t(s,n,i,a),!0}function se(t,e){re(t,E.LOAD,e)}function ae(t,e){re(t,E.LOADED,e)}function oe(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,E.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function de(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:le,scale:he,copy:ce}=k,{ceil:ue,abs:fe}=Math;function ge(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=fe(s),a=fe(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=le(),ce(l,_),he(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=le(),_&&ce(l,_)),he(l,1/s,1/a));const m=t.getCanvas(ue(h)||1,ue(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=o,!0}}const{abs:_e}=Math;const pe={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return te&&i===te.paint&&ie(n,te.boxBounds)?a=te.leafPaint:(a={type:i.type,image:r},te=r.use>1?{leafPaint:a,paint:i,boxBounds:ee.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ne(t,e,i,r,a,n),s&&(se(t,o),ae(t,o))):r.error?s&&oe(t,o,r.error):(s&&(de(t,!0),se(t,o)),a.loadId=r.load((()=>{de(t,!1),t.destroyed||(ne(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ae(t,o)),a.loadId=null}),(e=>{de(t,!1),oe(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&&!F.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=_e(a)*r,i*=_e(o)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||F.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||F.running?ge(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>et(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&ge(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:ge,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:$t,getPatternData:Kt,fillOrFitMode:zt,clipMode:Gt,repeatMode:Ht},{toPoint:we}=A,ye={},me={};function ve(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),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:xe,getDistance:be}=W,{get:Be,rotateOfOuter:Re,scaleOfOuter:ke}=k,{toPoint:Se}=A,Le={},Ee={};function Ae(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=xe(e,i);a=Be(),s?(ke(a,e,o/r*(n||1),1),Re(a,e,t+90)):(ke(a,e,1,o/r*(n||1)),Re(a,e,t))}return a}const{getDistance:We}=W,{toPoint:Te}=A,Oe={},Ce={};const Me={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;we(n||"top",i,ye),we(s||"bottom",i,me);const d=e.canvas.createLinearGradient(ye.x,ye.y,me.x,me.y);ve(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;Se(n||"center",i,Le),Se(s||"bottom",i,Ee);const l=e.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,be(Le,Ee));ve(l,t.stops,o);const h={type:a,style:l},c=Ae(i,Le,Ee,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;Te(n||"center",i,Oe),Te(s||"bottom",i,Ce);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Oe.x,Oe.y):e.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,We(Oe,Ce));ve(l,t.stops,o);const h={type:a,style:l},c=Ae(i,Oe,Ce,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Ae},{copy:Pe,toOffsetOutBounds:De}=B,Ie={},Fe={};function Ye(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Pe(Ie,t.bounds),Ie.x+=i.x-o.x,Ie.y+=i.y-o.y,n){const{matrix:t}=s;Ie.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Ie.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Ie.width*=n,Ie.height*=n}t.copyWorld(s.canvas,t.bounds,Ie)}else n&&(Pe(Ie,i),Ie.x-=i.width/2*(n-1),Ie.y-=i.height/2*(n-1),Ie.width*=n,Ie.height*=n),t.copyWorld(s.canvas,o,n?Ie:i)}const{toOffsetOutBounds:Ue}=B,Xe={};const Ne={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;De(l,Fe),r.forEach(((r,_)=>{f.setWorldShadow(Fe.offsetX+r.x*c,Fe.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ye(f,Fe,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;Ue(l,Xe),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Xe.offsetX+r.x*c,Xe.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ye(f,Xe,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:je}=p;function ze(t,e,i,n,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),He(t,e,i,1)}(t,i,n,s);break;case"opacity-path":He(t,i,n,a);break;case"path":i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function He(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,a,o,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(o&&(ze(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ge(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=Ge(t)),s||(s=Ge(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||je(i,e)||i.__render(s||t,e);ze(this,o,t,s,n,a)};const qe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ve=qe+"_#~&*+\\=|≮≯≈≠=…",Qe=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 Je(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ze=Je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Je(qe),ti=Je(Ve),ei=Je("- —/~|┆·");var ii;!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"}(ii||(ii={}));const{Letter:ni,Single:si,Before:ai,After:oi,Symbol:ri,Break:di}=ii;function li(t){return Ze[t]?ni:ei[t]?di:$e[t]?ai:Ke[t]?oi:ti[t]?ri:Qe.test(t)?si:ni}const hi={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 ci(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:ui}=hi,{Letter:fi,Single:gi,Before:_i,After:pi,Symbol:wi,Break:yi}=ii;let mi,vi,xi,bi,Bi,Ri,ki,Si,Li,Ei,Ai,Wi,Ti,Oi,Ci,Mi,Pi,Di=[];function Ii(t,e){Li&&!Si&&(Si=Li),mi.data.push({char:t,width:e}),xi+=e}function Fi(){bi+=xi,mi.width=xi,vi.words.push(mi),mi={data:[]},xi=0}function Yi(){Oi&&(Ci.paraNumber++,vi.paraStart=!0,Oi=!1),Li&&(vi.startCharSize=Si,vi.endCharSize=Li,Si=0),vi.width=bi,Mi.width?ui(vi):Pi&&Ui(),Di.push(vi),vi={words:[]},bi=0}function Ui(){bi>(Ci.maxWidth||0)&&(Ci.maxWidth=bi)}const Xi=0,Ni=1,ji=2;const{top:zi,right:Gi,bottom:Hi,left:qi}=T;function Vi(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 Qi={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[qi],a-=l[Gi]+l[qi]):i.autoSizeAlign||(n=l[qi]),o?(s=l[zi],o-=l[zi]+l[Hi]):i.autoSizeAlign||(s=l[zi]));const h={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Ci=t,Di=t.rows,Mi=t.bounds,Pi=!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;Oi=!0,Ai=null,Si=ki=Li=xi=bi=0,mi={data:[]},vi={words:[]};for(let n=0,l=i.length;n<l;n++)Ri=i[n],"\n"===Ri?(xi&&Fi(),vi.paraEnd=!0,Yi(),Oi=!0):(Ei=li(Ri),Ei===fi&&"none"!==o&&(Ri=ci(Ri,o,!xi)),ki=r.measureText(Ri).width,s&&(s<0&&(Li=ki),ki+=s),Wi=Ei===gi&&(Ai===gi||Ai===fi)||Ai===gi&&Ei!==pi,Ti=!(Ei!==_i&&Ei!==gi||Ai!==wi&&Ai!==pi),Bi=Oi&&a?d-a:d,t&&d&&bi+xi+ki>Bi&&(e?(xi&&Fi(),bi&&Yi()):(Ti||(Ti=Ei===fi&&Ai==pi),Wi||Ti||Ei===yi||Ei===_i||Ei===gi||xi+ki>Bi?(xi&&Fi(),bi&&Yi()):bi&&Yi()))," "===Ri&&!0!==Oi&&bi+xi===0||(Ei===yi?(" "===Ri&&xi&&Fi(),Ii(Ri,ki),Fi()):Wi||Ti?(xi&&Fi(),Ii(Ri,ki)):Ii(Ri,ki)),Ai=Ei);xi&&Fi(),bi&&Yi(),Di.length>0&&(Di[Di.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ci.paraNumber++,bi=r.measureText(t).width,Di.push({x:a||0,text:t,width:bi,paraStart:!0}),Pi&&Ui()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Vi(e,"x",t[qi]);break;case"right":Vi(e,"x",-t[Gi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Vi(e,"y",t[zi]);break;case"bottom":Vi(e,"y",-t[Hi])}}(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||"both"===a)&&t.words.length>1?(i-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Xi:l>.01?Ni:ji,t.isOverflow&&!r&&(t.textMode=!0),c===ji?(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===Ni?(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),!l||t.paraEnd&&"both"!==a||(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 Ji={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.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+")"}};Object.assign(U,Qi),Object.assign(D,Ji),Object.assign(X,Dt),Object.assign(P,pe),Object.assign(I,Me),Object.assign(N,Ne);const{setPoint:Zi,addPoint:$i,toBounds:Ki}=z;const tn={export(t,e,i){this.running=!0;const n=G.fileType(e),s=e.includes(".");return i=G.getExportOptions(i),function(t){en||(en=new H);return new Promise((e=>{en.add((()=>et(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((a=>new Promise((o=>{const r=t=>{a(t),o(),this.running=!1},{toURL:d}=q,{download:l}=q.origin;if("json"===n)return s&&l(d(JSON.stringify(t.toJSON(i.json)),"text"),e),r({data:!!s||t.toJSON(i.json)});if("svg"===n)return s&&l(d(t.toSVG(),"svg"),e),r({data:!!s||t.toSVG()});const{leafer:h}=t;h?(nn(t),h.waitViewCompleted((()=>et(this,void 0,void 0,(function*(){let n,s,a=1,o=1;const{worldTransform:d,isLeafer:l,isFrame:c}=t,{slice:u,trim:f,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,p=i.contextSettings||h.config.contextSettings,w=i.screenshot||t.isApp,y=l&&w&&void 0===i.fill?t.fill:i.fill,m=G.isOpaqueImage(e)||y,v=new V;if(w)n=!0===w?l?h.canvas.bounds:t.worldRenderBounds:w;else{let e=i.relative||(l?"inner":"local");switch(a=d.scaleX,o=d.scaleY,e){case"inner":v.set(d);break;case"local":v.set(d).divide(t.localTransform),a/=t.scaleX,o/=t.scaleY;break;case"world":a=1,o=1;break;case"page":e=t.leafer;default:v.set(d).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,o/=o/i.scaleY}n=t.getBounds("render",e)}const x={scaleX:1,scaleY:1};Q.getScaleData(i.scale,i.size,n,x);let b=i.pixelRatio||1;t.isApp&&(x.scaleX*=b,x.scaleY*=b,b=t.app.pixelRatio);const{x:B,y:R,width:k,height:S}=new j(n).scale(x.scaleX,x.scaleY),L={matrix:v.scale(1/x.scaleX,1/x.scaleY).invert().translate(-B,-R).withScale(1/a*x.scaleX,1/o*x.scaleY)};let E,A=J.canvas({width:Math.round(k),height:Math.round(S),pixelRatio:b,smooth:_,contextSettings:p});if(u&&(E=t,E.__worldOpacity=0,t=h,L.bounds=A.bounds),A.save(),c&&void 0!==y){const e=t.get("fill");t.fill="",t.__render(A,L),t.fill=e}else t.__render(A,L);if(A.restore(),E&&E.__updateWorldOpacity(),f){s=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?$i(o,s,a):Zi(o={},s,a)),r++;const d=new j;return Ki(o,d),d.scale(1/t.pixelRatio).ceil()}(A);const t=A,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:b};A=J.canvas(n),A.copyWorld(t,s,n)}m&&A.fillWorld(A.bounds,y||"#FFFFFF","destination-over"),g&&g(A);const W="canvas"===e?A:yield A.export(e,i);r({data:W,width:A.pixelWidth,height:A.pixelHeight,renderBounds:n,trimBounds:s})}))))):r({data:!1})}))))}};let en;function nn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>nn(t)))}const sn=Z.prototype,an=$.get("@leafer-in/export");sn.export=function(t,e){const{quality:i,blob:n}=G.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},sn.toBlob=function(t,e){return new Promise((i=>{q.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{an.error(t),i(null)}))}))},sn.toDataURL=function(t,e){return q.origin.canvasToDataURL(this.view,t,e)},sn.saveAs=function(t,e){return new Promise((i=>{q.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{an.error(t),i(!1)}))}))},K.add("export"),Object.assign(F,tn),tt.prototype.export=function(t,e){return F.export(this,t,e)},Object.assign(n,{interaction:(t,e,i,n)=>new C(t,e,i,n),hitCanvas:(t,e)=>new it(t,e),hitCanvasManager:()=>new M});export{yt as Layouter,it as LeaferCanvas,bt as Picker,vt as Renderer,Bt as Selector,ot as Watcher,at as useCanvas};
|
package/dist/node.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/core"),i=require("@leafer-ui/draw");function a(t,e,n,i){return new(n||(n=Promise))((function(a,s){function o(t){try{l(i.next(t))}catch(t){s(t)}}function r(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__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}}const{mineType:o,fileType:r}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new s(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){setTimeout(t,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1}),t.Platform.conicGradientSupport=!0;class l{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:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{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,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),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:w,updateAllChange:y}=t.LeafHelper,m=t.Debug.get("Layouter");class v{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:a}=this,{BEFORE:s,LAYOUT:o,AFTER:r}=t.LayoutEvent,l=this.getBlocks(a);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(s,l,this.times)),this.extraBlock=null,a.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&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;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||h(i[t])}h(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&c(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(a),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:s}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),v.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,o,this.times)),n.emitEvent(new t.LayoutEvent(s,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),y(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(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 x=t.Debug.get("Renderer");class b{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()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.isApp||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,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.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 x.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,a=e.getIntersect(i.bounds),s=e.includes(this.target.__world),o=new t.Bounds(a);i.save(),s&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,s,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 a=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,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),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(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width: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.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.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 L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const a=i.through||!1,s=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,l=this.getBestMatchLeaf(r,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),a?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:a,y:s}=this.point,o={x:a,y:s,radiusX:0,radiusY:0};for(let a=0,s=e.length;a<s;a++)if(n=e[a],(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 this.target&&n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,a=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(a.addAt(i,0),i.__.hitChildren);t--);return a}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let a,s,o;for(let t=0,e=i.length;t<e;t++){a=i[t],s=i[t+1];for(let t=0,e=a.length;t<e&&(o=a.list[t],!s||!s.has(o));t++)n.add(o)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:a}=this;for(let s=t.length-1;s>-1;s--)n=t[s],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||B(n.__world,a),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,a)):i&&this.hitChild(n,a))}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()}}class E{constructor(e,n){this.config={},n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new L(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,n,i){return t.Platform.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(e,n,i)}getBy(e,n,i,a){return this.finder?this.finder.getBy(e,n,i,a):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function R(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=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)})),a&&e.fillRect(n.x,n.y+a,n.width,s)}function k(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?C(t,!0,e,n):S(e,n);break;case"inside":P("inside",t,a,e,n);break;case"outside":P("outside",t,a,e,n)}}function P(t,e,n,i,a){const{__strokeWidth:s,__font:o}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*s,i.__),r.font=o,n?C(e,!0,i,r):S(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",R(i,r),r.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(r,i.__nowWorld):a.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function S(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=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)})),a&&e.strokeRect(n.x,n.y+a,n.width,s)}function C(t,e,n,a){let s;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&i.PaintImage.checkImage(n,a,s,!1)||s.style&&(a.strokeStyle=s.style,s.blendMode?(a.saveBlendMode(s.blendMode),e?S(n,a):a.stroke(),a.restoreBlendMode()):e?S(n,a):a.stroke())}function A(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>new E(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:W,getOuterOf:O,getByMove:T,getIntersectData:M}=t.BoundsHelper;let I;function D(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:a}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:r,opacity:l}=e;return{type:s,blendMode:o,style:i.ColorConvert.string(r,l)};case"image":return i.PaintImage.image(n,t,e,a,!I||!I[e.url]);case"linear":return i.PaintGradient.linearGradient(e,a);case"radial":return i.PaintGradient.radialGradient(e,a);case"angular":return i.PaintGradient.conicGradient(e,a);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const H={compute:function(t,e){const n=e.__,a=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),I=i.PaintImage.recycleImage(t,n);for(let n,i=0,s=o.length;i<s;i++)n=D(t,o[i],e),n&&a.push(n);n["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(s=a[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?R(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let a;const{windingRule:s,__font:o}=e.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&i.PaintImage.checkImage(e,n,a,!o)||a.style&&(n.fillStyle=a.style,a.transform?(n.save(),n.transform(a.transform),a.blendMode&&(n.blendMode=a.blendMode),o?R(e,n):s?n.fill(s):n.fill(),n.restore()):a.blendMode?(n.saveBlendMode(a.blendMode),o?R(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?R(e,n):s?n.fill(s):n.fill())},fillText:R,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)k(t,e,n);else switch(s){case"center":n.setStroke(t,a,i),n.stroke(),i.__useArrow&&A(e,n);break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const s=n.getSameCanvas(!0,!0);s.setStroke(t,2*a,i),e.__drawRenderPath(s),s.stroke(),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,e.__layout.renderBounds),s.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)k(t,e,n);else switch(s){case"center":n.setStroke(void 0,a,i),C(t,!1,e,n),i.__useArrow&&A(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),C(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:s}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*a,i),C(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(s),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,s),o.recycle(e.__nowWorld)}},strokeText:k,drawTextStroke:S,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let s,o,r,l,{scaleX:d,scaleY:h}=a;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(a))l=i,s=r=a;else{const{renderShapeSpread:i}=t.__layout,c=M(i?W(e.bounds,d===h?i*d:[i*h,i*d]):e.bounds,a);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,h*=f),r=O(a,o),s=T(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:s,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:h}}};let F={};const{get:Y,rotateOfOuter:j,translate:U,scaleOfOuter:G,scale:X,rotate:q}=t.MatrixHelper;function z(t,e,n,i,a,s,o){const r=Y();U(r,e.x+n,e.y+i),X(r,a,s),o&&j(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function N(t,e,n,i,a,s,o){const r=Y();U(r,e.x+n,e.y+i),a&&X(r,a,s),o&&q(r,o),t.transform=r}function V(t,e,n,i,a,s,o,r,l,d){const h=Y();if(l)if("center"===d)j(h,{x:n/2,y:i/2},l);else switch(q(h,l),l){case 90:U(h,i,0);break;case 180:U(h,n,i);break;case 270:U(h,0,n)}F.x=e.x+a,F.y=e.y+s,U(h,F.x,F.y),o&&G(h,F,o,r),t.transform=h}const{get:Q,translate:J}=t.MatrixHelper,Z=new t.Bounds,K={},$={};function tt(t,e,n,i){const{blendMode:a,sync:s}=n;a&&(t.blendMode=a),s&&(t.sync=s),t.data=et(n,i,e)}function et(e,n,i){let{width:a,height:s}=i;e.padding&&(n=Z.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:l,offset:d,scale:h,size:c,rotation:u,repeat:f}=e,p=n.width===a&&n.height===s,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?s:a,y=_?a:s;let m,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(h||c)&&(t.MathHelper.getScaleData(h,c,i,$),m=$.scaleX,v=$.scaleY);else if(!p||u){const t=n.width/w,e=n.height/y;m=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-a*m)/2,b+=(n.height-s*v)/2}if(l){const e={x:x,y:b,width:w,height:y};m&&(e.width*=m,e.height*=v),t.AlignHelper.toPoint(l,e,n,K,!0),x+=K.x,b+=K.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(a=n.width,s=n.height);break;case"normal":case"clip":(x||b||m||u)&&N(g,n,x,b,m,v,u);break;case"repeat":(!p||m||u)&&V(g,n,a,s,x,b,m,v,u,l),f||(g.repeat="repeat");break;default:m&&z(g,n,x,b,m,v,u)}return g.transform||(n.x||n.y)&&(g.transform=Q(),J(g.transform,n.x,n.y)),m&&"stretch"!==r&&(g.scaleX=m,g.scaleY=v),g.width=a,g.height=s,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let nt,it=new t.Bounds;const{isSame:at}=t.BoundsHelper;function st(t,e,n,i,a,s){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 a.data||tt(a,i,n,s),!0}function ot(e,n){dt(e,t.ImageEvent.LOAD,n)}function rt(e,n){dt(e,t.ImageEvent.LOADED,n)}function lt(e,n,i){n.error=i,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,n)}function dt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ht(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ct,scale:ut,copy:ft}=t.MatrixHelper,{ceil:pt,abs:gt}=Math;function _t(e,n,i){let{scaleX:a,scaleY:s}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=a+"-"+s+"-"+i;if(n.patternId===o||e.destroyed)return!1;{a=gt(a),s=gt(s);const{image:e,data:r}=n;let l,d,{width:h,height:c,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=ct(),ft(d,g),ut(d,1/u,1/f),a*=u,s*=f),a*=i,s*=i,h*=a,c*=s;const w=h*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(l=Math.sqrt(w/y)),l&&(a/=l,s/=l,h/=l,c/=l),u&&(a/=u,s/=f),(g||1!==a||1!==s)&&(d||(d=ct(),g&&ft(d,g)),ut(d,1/a,1/s));const m=e.getCanvas(pt(h)||1,pt(c)||1,p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=o,!0}}const{abs:wt}=Math;const yt={image:function(e,n,i,a,s){let o,r;const l=t.ImageManager.get(i);return nt&&i===nt.paint&&at(a,nt.boxBounds)?o=nt.leafPaint:(o={type:i.type,image:l},nt=l.use>1?{leafPaint:o,paint:i,boxBounds:it.set(a)}:null),(s||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(st(e,n,i,l,o,a),s&&(ot(e,r),rt(e,r))):l.error?s&<(e,r,l.error):(s&&(ht(e,!0),ot(e,r)),o.loadId=l.load((()=>{ht(e,!1),e.destroyed||(st(e,n,i,l,o,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),rt(e,r)),o.loadId=null}),(t=>{ht(e,!1),lt(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,s,o){const{scaleX:r,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=n;if(!s.data||s.patternId===r+"-"+l+"-"+d&&!i.Export.running)return!1;{const{data:h}=s;if(o)if(h.repeat)o=!1;else{let{width:e,height:n}=h;e*=wt(r)*d,n*=wt(l)*d,h.scaleX&&(e*=h.scaleX,n*=h.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),e.windingRule?n.clip(e.windingRule):n.clip(),s.blendMode&&(n.blendMode=s.blendMode),h.opacity&&(n.opacity*=h.opacity),h.transform&&n.transform(h.transform),n.drawImage(s.image.view,0,0,h.width,h.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?_t(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>a(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&_t(e,s,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:_t,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,s,o,r;for(let l=0,d=i.length;l<d;l++)a=i[l].image,r=a&&a.url,r&&(s||(s={}),s[r]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),a.unload(i[l].loadId,!o.some((t=>t.url===r)))));return s}return null},createData:tt,getPatternData:et,fillOrFitMode:z,clipMode:N,repeatMode:V},{toPoint:mt}=t.AroundHelper,vt={},xt={};function bt(t,e,n){if(e){let a;for(let s=0,o=e.length;s<o;s++)a=e[s],"string"==typeof a?t.addColorStop(s/(o-1),i.ColorConvert.string(a,n)):t.addColorStop(a.offset,i.ColorConvert.string(a.color,n))}}const{getAngle:Bt,getDistance:Lt}=t.PointHelper,{get:Et,rotateOfOuter:Rt,scaleOfOuter:kt}=t.MatrixHelper,{toPoint:Pt}=t.AroundHelper,St={},Ct={};function At(t,e,n,i,a){let s;const{width:o,height:r}=t;if(o!==r||i){const t=Bt(e,n);s=Et(),a?(kt(s,e,o/r*(i||1),1),Rt(s,e,t+90)):(kt(s,e,1,o/r*(i||1)),Rt(s,e,t))}return s}const{getDistance:Wt}=t.PointHelper,{toPoint:Ot}=t.AroundHelper,Tt={},Mt={};const It={linearGradient:function(e,n){let{from:i,to:a,type:s,blendMode:o,opacity:r}=e;mt(i||"top",n,vt),mt(a||"bottom",n,xt);const l=t.Platform.canvas.createLinearGradient(vt.x,vt.y,xt.x,xt.y);bt(l,e.stops,r);const d={type:s,style:l};return o&&(d.blendMode=o),d},radialGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:l}=e;Pt(i||"center",n,St),Pt(a||"bottom",n,Ct);const d=t.Platform.canvas.createRadialGradient(St.x,St.y,0,St.x,St.y,Lt(St,Ct));bt(d,e.stops,o);const h={type:s,style:d},c=At(n,St,Ct,l,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:l}=e;Ot(i||"center",n,Tt),Ot(a||"bottom",n,Mt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Tt.x,Tt.y):t.Platform.canvas.createRadialGradient(Tt.x,Tt.y,0,Tt.x,Tt.y,Wt(Tt,Mt));bt(d,e.stops,o);const h={type:s,style:d},c=At(n,Tt,Mt,l||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:At},{copy:Dt,toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={},Yt={};function jt(e,n,i,a){const{bounds:s,shapeBounds:o}=a;if(t.Platform.fullImageShadow){if(Dt(Ft,e.bounds),Ft.x+=n.x-o.x,Ft.y+=n.y-o.y,i){const{matrix:t}=a;Ft.x-=(s.x+(t?t.e:0)+s.width/2)*(i-1),Ft.y-=(s.y+(t?t.f:0)+s.height/2)*(i-1),Ft.width*=i,Ft.height*=i}e.copyWorld(a.canvas,e.bounds,Ft)}else i&&(Dt(Ft,n),Ft.x-=n.width/2*(i-1),Ft.y-=n.height/2*(i-1),Ft.width*=i,Ft.height*=i),e.copyWorld(a.canvas,o,i?Ft:n)}const{toOffsetOutBounds:Ut}=t.BoundsHelper,Gt={};const Xt={shadow:function(t,e,n){let i,a;const{__nowWorld:s,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(d,Yt),r.forEach(((r,g)=>{f.setWorldShadow(Yt.offsetX+r.x*c,Yt.offsetY+r.y*u,r.blur*c,r.color),a=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,jt(f,Yt,a,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,s,"copy"),i=s),l?f.copyWorld(l,s,s,"destination-out"):f.copyWorld(n.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,s,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,a;const{__nowWorld:s,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ut(d,Gt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Gt.offsetX+r.x*c,Gt.offsetY+r.y*u,r.blur*c),a=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,jt(f,Gt,a,n),f.restore(),l?(f.copyWorld(f,d,s,"copy"),f.copyWorld(l,s,s,"source-out"),i=s):(f.copyWorld(n.canvas,h,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,s,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&g<p&&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:qt}=t.LeafBoundsHelper;function zt(t,e,n,i,a,s){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Vt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Vt(t,n,i,s);break;case"path":n.restore()}}function Nt(t){return t.getSameCanvas(!1,!0)}function Vt(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}i.Group.prototype.__renderMask=function(t,e){let n,i,a,s,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)n=l[d],r=n.__.mask,r&&(o&&(zt(this,o,t,a,i,s),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",s=n.opacity,a||(a=Nt(t))):(o="path",t.save()),n.__clip(a||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=Nt(t)),a||(a=Nt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||qt(n,e)||n.__render(a||t,e);zt(this,o,t,a,i,s)};const Qt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Jt=Qt+"_#~&*+\\=|≮≯≈≠=…",Zt=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 Kt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $t=Kt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),te=Kt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ee=Kt(Qt),ne=Kt(Jt),ie=Kt("- —/~|┆·");var ae;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ae||(ae={}));const{Letter:se,Single:oe,Before:re,After:le,Symbol:de,Break:he}=ae;function ce(t){return $t[t]?se:ie[t]?he:te[t]?re:ee[t]?le:ne[t]?de:Zt.test(t)?oe:se}const ue={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let s=a-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function fe(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:pe}=ue,{Letter:ge,Single:_e,Before:we,After:ye,Symbol:me,Break:ve}=ae;let xe,be,Be,Le,Ee,Re,ke,Pe,Se,Ce,Ae,We,Oe,Te,Me,Ie,De,He=[];function Fe(t,e){Se&&!Pe&&(Pe=Se),xe.data.push({char:t,width:e}),Be+=e}function Ye(){Le+=Be,xe.width=Be,be.words.push(xe),xe={data:[]},Be=0}function je(){Te&&(Me.paraNumber++,be.paraStart=!0,Te=!1),Se&&(be.startCharSize=Pe,be.endCharSize=Se,Pe=0),be.width=Le,Ie.width?pe(be):De&&Ue(),He.push(be),be={words:[]},Le=0}function Ue(){Le>(Me.maxWidth||0)&&(Me.maxWidth=Le)}const Ge=0,Xe=1,qe=2;const{top:ze,right:Ne,bottom:Ve,left:Qe}=t.Direction4;function Je(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const Ze={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,s=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(s?(i=d[Qe],s-=d[Ne]+d[Qe]):n.autoSizeAlign||(i=d[Qe]),o?(a=d[ze],o-=d[ze]+d[Ve]):n.autoSizeAlign||(a=d[ze]));const h={bounds:{x:i,y:a,width:s,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Me=e,He=e.rows,Ie=e.bounds,De=!Ie.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:s,textCase:o}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ie;if(l||d||a||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Te=!0,Ae=null,Pe=ke=Se=Be=Le=0,xe={data:[]},be={words:[]};for(let i=0,d=n.length;i<d;i++)Re=n[i],"\n"===Re?(Be&&Ye(),be.paraEnd=!0,je(),Te=!0):(Ce=ce(Re),Ce===ge&&"none"!==o&&(Re=fe(Re,o,!Be)),ke=r.measureText(Re).width,a&&(a<0&&(Se=ke),ke+=a),We=Ce===_e&&(Ae===_e||Ae===ge)||Ae===_e&&Ce!==ye,Oe=!(Ce!==we&&Ce!==_e||Ae!==me&&Ae!==ye),Ee=Te&&s?l-s:l,t&&l&&Le+Be+ke>Ee&&(e?(Be&&Ye(),Le&&je()):(Oe||(Oe=Ce===ge&&Ae==ye),We||Oe||Ce===ve||Ce===we||Ce===_e||Be+ke>Ee?(Be&&Ye(),Le&&je()):Le&&je()))," "===Re&&!0!==Te&&Le+Be===0||(Ce===ve?(" "===Re&&Be&&Ye(),Fe(Re,ke),Ye()):We||Oe?(Be&&Ye(),Fe(Re,ke)):Fe(Re,ke)),Ae=Ce);Be&&Ye(),Le&&je(),He.length>0&&(He[He.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Me.paraNumber++,Le=r.measureText(t).width,He.push({x:s||0,text:t,width:Le,paraStart:!0}),De&&Ue()}))}(h,e,n),d&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Je(e,"x",t[Qe]);break;case"right":Je(e,"x",-t[Ne])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Je(e,"y",t[ze]);break;case"bottom":Je(e,"y",-t[Ve])}}(d,h,n,s,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:s,__letterSpacing:o,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:p,height:g}=i,_=a*n.length+(h?h*(t.paraNumber-1):0),w=s;if(r&&_>g)_=Math.max(g,a),t.overflow=n.length;else if(g||c)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let y,m,v,x=p||c?p:t.maxWidth;for(let s=0,d=n.length;s<d;s++){if(y=n[s],y.x=u,y.width<p||y.width>p&&!r)switch(l){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&s>0&&(w+=h),y.y=w,w+=a,t.overflow>s&&w>_&&(y.isOverflow=!0,t.overflow=s+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<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n,i){const{rows:a}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let l,d,h,c,u;a.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,d=n&&"justify"===s&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Ge:d>.01?Xe:qe,t.isOverflow&&!r&&(t.textMode=!0),c===qe?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,l=t.x,t.data=[],t.words.forEach((e=>{c===Xe?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(h,n,s),h.overflow&&function(e,n,i,a){if(!a)return;const{rows:s,overflow:o}=e;let{textOverflow:r}=n;if(s.splice(o),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,h=i+a-d;("none"===n.textWrap?s:[s[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],l=e.x+e.width,!(i===n&&l<h));i--){if(l<h&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,i,s),"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 Ke={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;n&&(a*=e);const s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(i.TextConvert,Ze),Object.assign(i.ColorConvert,Ke),Object.assign(i.Paint,H),Object.assign(i.PaintImage,yt),Object.assign(i.PaintGradient,It),Object.assign(i.Effect,Xt);const{setPoint:$e,addPoint:tn,toBounds:en}=i.TwoPointBoundsHelper;const nn={export(t,e,n){this.running=!0;const s=i.FileHelper.fileType(e),o=e.includes(".");return n=i.FileHelper.getExportOptions(n),function(t){an||(an=new i.TaskProcessor);return new Promise((e=>{an.add((()=>a(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((l=>{const d=t=>{r(t),l(),this.running=!1},{toURL:h}=i.Platform,{download:c}=i.Platform.origin;if("json"===s)return o&&c(h(JSON.stringify(t.toJSON(n.json)),"text"),e),d({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&c(h(t.toSVG(),"svg"),e),d({data:!!o||t.toSVG()});const{leafer:u}=t;u?(sn(t),u.waitViewCompleted((()=>a(this,void 0,void 0,(function*(){let a,s,o=1,r=1;const{worldTransform:l,isLeafer:h,isFrame:c}=t,{slice:f,trim:p,onCanvas:g}=n,_=void 0===n.smooth?u.config.smooth:n.smooth,w=n.contextSettings||u.config.contextSettings,y=n.screenshot||t.isApp,m=h&&y&&void 0===n.fill?t.fill:n.fill,v=i.FileHelper.isOpaqueImage(e)||m,x=new i.Matrix;if(y)a=!0===y?h?u.canvas.bounds:t.worldRenderBounds:y;else{let e=n.relative||(h?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":x.set(l);break;case"local":x.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=t.leafer;default:x.set(l).divide(t.getTransform(e));const n=e.worldTransform;o/=o/n.scaleX,r/=r/n.scaleY}a=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};i.MathHelper.getScaleData(n.scale,n.size,a,b);let B=n.pixelRatio||1;t.isApp&&(b.scaleX*=B,b.scaleY*=B,B=t.app.pixelRatio);const{x:L,y:E,width:R,height:k}=new i.Bounds(a).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-L,-E).withScale(1/o*b.scaleX,1/r*b.scaleY)};let S,C=i.Creator.canvas({width:Math.round(R),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(S=t,S.__worldOpacity=0,t=u,P.bounds=C.bounds),C.save(),c&&void 0!==m){const e=t.get("fill");t.fill="",t.__render(C,P),t.fill=e}else t.__render(C,P);if(C.restore(),S&&S.__updateWorldOpacity(),p){s=function(t){const{width:e,height:n}=t.view,{data:a}=t.context.getImageData(0,0,e,n);let s,o,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(s=l%e,o=(l-s)/e,r?tn(r,s,o):$e(r={},s,o)),l++;const d=new i.Bounds;return en(r,d),d.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:n}=s,a={x:0,y:0,width:e,height:n,pixelRatio:B};C=i.Creator.canvas(a),C.copyWorld(t,s,a)}v&&C.fillWorld(C.bounds,m||"#FFFFFF","destination-over"),g&&g(C);const A="canvas"===e?C:yield C.export(e,n);d({data:A,width:C.pixelWidth,height:C.pixelHeight,renderBounds:a,trimBounds:s})}))))):d({data:!1})}))))}};let an;function sn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>sn(t)))}const on=i.LeaferCanvasBase.prototype,rn=i.Debug.get("@leafer-in/export");on.export=function(t,e){const{quality:n,blob:a}=i.FileHelper.getExportOptions(e);return t.includes(".")?this.saveAs(t,n):a?this.toBlob(t,n):this.toDataURL(t,n)},on.toBlob=function(t,e){return new Promise((n=>{i.Platform.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{rn.error(t),n(null)}))}))},on.toDataURL=function(t,e){return i.Platform.origin.canvasToDataURL(this.view,t,e)},on.saveAs=function(t,e){return new Promise((n=>{i.Platform.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{rn.error(t),n(!1)}))}))},Object.assign(i.Export,nn),i.UI.prototype.export=function(t,e){return i.Export.export(this,t,e)},Object.assign(t.Creator,{interaction:(t,e,i,a)=>new n.InteractionBase(t,e,i,a),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=s,exports.Picker=L,exports.Renderer=b,exports.Selector=E,exports.Watcher=l,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:e=>n(t.Platform.image.getRealURL(e))},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:s}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(o(e),n),canvasToBolb:(t,e,n)=>a(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,i)=>a(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(r(n)),i))})),download(t,e){},loadImage:e=>s(t.Platform.image.getRealURL(e))}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},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(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/core"),i=require("@leafer-ui/draw");function a(t,e,n,i){return new(n||(n=Promise))((function(a,s){function o(t){try{l(i.next(t))}catch(t){s(t)}}function r(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__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}}const{mineType:o,fileType:r}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new s(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){setTimeout(t,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1}),t.Platform.conicGradientSupport=!0;class l{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:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{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,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),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:w,updateAllChange:y}=t.LeafHelper,m=t.Debug.get("Layouter");class v{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:a}=this,{BEFORE:s,LAYOUT:o,AFTER:r}=t.LayoutEvent,l=this.getBlocks(a);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(s,l,this.times)),this.extraBlock=null,a.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&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;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||h(i[t])}h(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&c(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(a),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:s}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),v.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,o,this.times)),n.emitEvent(new t.LayoutEvent(s,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),y(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(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 x=t.Debug.get("Renderer");class b{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()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.isApp||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,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,a=e.getIntersect(i.bounds),s=e.includes(this.target.__world),o=new t.Bounds(a);i.save(),s&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,s,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 a=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,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),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(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width: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.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.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 L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const a=i.through||!1,s=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,l=this.getBestMatchLeaf(r,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),a?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:a,y:s}=this.point,o={x:a,y:s,radiusX:0,radiusY:0};for(let a=0,s=e.length;a<s;a++)if(n=e[a],(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 this.target&&n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,a=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(a.addAt(i,0),i.__.hitChildren);t--);return a}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let a,s,o;for(let t=0,e=i.length;t<e;t++){a=i[t],s=i[t+1];for(let t=0,e=a.length;t<e&&(o=a.list[t],!s||!s.has(o));t++)n.add(o)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:a}=this;for(let s=t.length-1;s>-1;s--)n=t[s],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||B(n.__world,a),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,a)):i&&this.hitChild(n,a))}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()}}class E{constructor(e,n){this.config={},n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new L(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,n,i){return t.Platform.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(e,n,i)}getBy(e,n,i,a){return this.finder?this.finder.getBy(e,n,i,a):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function R(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=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)})),a&&e.fillRect(n.x,n.y+a,n.width,s)}function k(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?C(t,!0,e,n):S(e,n);break;case"inside":P("inside",t,a,e,n);break;case"outside":P("outside",t,a,e,n)}}function P(t,e,n,i,a){const{__strokeWidth:s,__font:o}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*s,i.__),r.font=o,n?C(e,!0,i,r):S(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",R(i,r),r.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(r,i.__nowWorld):a.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function S(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=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)})),a&&e.strokeRect(n.x,n.y+a,n.width,s)}function C(t,e,n,a){let s;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&i.PaintImage.checkImage(n,a,s,!1)||s.style&&(a.strokeStyle=s.style,s.blendMode?(a.saveBlendMode(s.blendMode),e?S(n,a):a.stroke(),a.restoreBlendMode()):e?S(n,a):a.stroke())}function A(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>new E(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:W,getOuterOf:O,getByMove:T,getIntersectData:M}=t.BoundsHelper;let I;function D(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:a}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:r,opacity:l}=e;return{type:s,blendMode:o,style:i.ColorConvert.string(r,l)};case"image":return i.PaintImage.image(n,t,e,a,!I||!I[e.url]);case"linear":return i.PaintGradient.linearGradient(e,a);case"radial":return i.PaintGradient.radialGradient(e,a);case"angular":return i.PaintGradient.conicGradient(e,a);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const H={compute:function(t,e){const n=e.__,a=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),I=i.PaintImage.recycleImage(t,n);for(let n,i=0,s=o.length;i<s;i++)n=D(t,o[i],e),n&&a.push(n);n["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(s=a[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?R(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let a;const{windingRule:s,__font:o}=e.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&i.PaintImage.checkImage(e,n,a,!o)||a.style&&(n.fillStyle=a.style,a.transform?(n.save(),n.transform(a.transform),a.blendMode&&(n.blendMode=a.blendMode),o?R(e,n):s?n.fill(s):n.fill(),n.restore()):a.blendMode?(n.saveBlendMode(a.blendMode),o?R(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?R(e,n):s?n.fill(s):n.fill())},fillText:R,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)k(t,e,n);else switch(s){case"center":n.setStroke(t,a,i),n.stroke(),i.__useArrow&&A(e,n);break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const s=n.getSameCanvas(!0,!0);s.setStroke(t,2*a,i),e.__drawRenderPath(s),s.stroke(),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,e.__layout.renderBounds),s.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)k(t,e,n);else switch(s){case"center":n.setStroke(void 0,a,i),C(t,!1,e,n),i.__useArrow&&A(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),C(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:s}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*a,i),C(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(s),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,s),o.recycle(e.__nowWorld)}},strokeText:k,drawTextStroke:S,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let s,o,r,l,{scaleX:d,scaleY:h}=a;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(a))l=i,s=r=a;else{const{renderShapeSpread:i}=t.__layout,c=M(i?W(e.bounds,d===h?i*d:[i*h,i*d]):e.bounds,a);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,h*=f),r=O(a,o),s=T(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:s,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:h}}};let F={};const{get:Y,rotateOfOuter:j,translate:U,scaleOfOuter:G,scale:X,rotate:q}=t.MatrixHelper;function z(t,e,n,i,a,s,o){const r=Y();U(r,e.x+n,e.y+i),X(r,a,s),o&&j(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function N(t,e,n,i,a,s,o){const r=Y();U(r,e.x+n,e.y+i),a&&X(r,a,s),o&&q(r,o),t.transform=r}function V(t,e,n,i,a,s,o,r,l,d){const h=Y();if(l)if("center"===d)j(h,{x:n/2,y:i/2},l);else switch(q(h,l),l){case 90:U(h,i,0);break;case 180:U(h,n,i);break;case 270:U(h,0,n)}F.x=e.x+a,F.y=e.y+s,U(h,F.x,F.y),o&&G(h,F,o,r),t.transform=h}const{get:Q,translate:J}=t.MatrixHelper,Z=new t.Bounds,K={},$={};function tt(t,e,n,i){const{blendMode:a,sync:s}=n;a&&(t.blendMode=a),s&&(t.sync=s),t.data=et(n,i,e)}function et(e,n,i){let{width:a,height:s}=i;e.padding&&(n=Z.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:l,offset:d,scale:h,size:c,rotation:u,repeat:f}=e,p=n.width===a&&n.height===s,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?s:a,y=_?a:s;let m,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(h||c)&&(t.MathHelper.getScaleData(h,c,i,$),m=$.scaleX,v=$.scaleY);else if(!p||u){const t=n.width/w,e=n.height/y;m=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-a*m)/2,b+=(n.height-s*v)/2}if(l){const e={x:x,y:b,width:w,height:y};m&&(e.width*=m,e.height*=v),t.AlignHelper.toPoint(l,e,n,K,!0),x+=K.x,b+=K.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(a=n.width,s=n.height);break;case"normal":case"clip":(x||b||m||u)&&N(g,n,x,b,m,v,u);break;case"repeat":(!p||m||u)&&V(g,n,a,s,x,b,m,v,u,l),f||(g.repeat="repeat");break;default:m&&z(g,n,x,b,m,v,u)}return g.transform||(n.x||n.y)&&(g.transform=Q(),J(g.transform,n.x,n.y)),m&&"stretch"!==r&&(g.scaleX=m,g.scaleY=v),g.width=a,g.height=s,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let nt,it=new t.Bounds;const{isSame:at}=t.BoundsHelper;function st(t,e,n,i,a,s){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 a.data||tt(a,i,n,s),!0}function ot(e,n){dt(e,t.ImageEvent.LOAD,n)}function rt(e,n){dt(e,t.ImageEvent.LOADED,n)}function lt(e,n,i){n.error=i,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,n)}function dt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ht(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ct,scale:ut,copy:ft}=t.MatrixHelper,{ceil:pt,abs:gt}=Math;function _t(e,n,i){let{scaleX:a,scaleY:s}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=a+"-"+s+"-"+i;if(n.patternId===o||e.destroyed)return!1;{a=gt(a),s=gt(s);const{image:e,data:r}=n;let l,d,{width:h,height:c,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=ct(),ft(d,g),ut(d,1/u,1/f),a*=u,s*=f),a*=i,s*=i,h*=a,c*=s;const w=h*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(l=Math.sqrt(w/y)),l&&(a/=l,s/=l,h/=l,c/=l),u&&(a/=u,s/=f),(g||1!==a||1!==s)&&(d||(d=ct(),g&&ft(d,g)),ut(d,1/a,1/s));const m=e.getCanvas(pt(h)||1,pt(c)||1,p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=o,!0}}const{abs:wt}=Math;const yt={image:function(e,n,i,a,s){let o,r;const l=t.ImageManager.get(i);return nt&&i===nt.paint&&at(a,nt.boxBounds)?o=nt.leafPaint:(o={type:i.type,image:l},nt=l.use>1?{leafPaint:o,paint:i,boxBounds:it.set(a)}:null),(s||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(st(e,n,i,l,o,a),s&&(ot(e,r),rt(e,r))):l.error?s&<(e,r,l.error):(s&&(ht(e,!0),ot(e,r)),o.loadId=l.load((()=>{ht(e,!1),e.destroyed||(st(e,n,i,l,o,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),rt(e,r)),o.loadId=null}),(t=>{ht(e,!1),lt(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,s,o){const{scaleX:r,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=n;if(!s.data||s.patternId===r+"-"+l+"-"+d&&!i.Export.running)return!1;{const{data:h}=s;if(o)if(h.repeat)o=!1;else{let{width:e,height:n}=h;e*=wt(r)*d,n*=wt(l)*d,h.scaleX&&(e*=h.scaleX,n*=h.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),e.windingRule?n.clip(e.windingRule):n.clip(),s.blendMode&&(n.blendMode=s.blendMode),h.opacity&&(n.opacity*=h.opacity),h.transform&&n.transform(h.transform),n.drawImage(s.image.view,0,0,h.width,h.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?_t(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>a(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&_t(e,s,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:_t,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,s,o,r;for(let l=0,d=i.length;l<d;l++)a=i[l].image,r=a&&a.url,r&&(s||(s={}),s[r]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),a.unload(i[l].loadId,!o.some((t=>t.url===r)))));return s}return null},createData:tt,getPatternData:et,fillOrFitMode:z,clipMode:N,repeatMode:V},{toPoint:mt}=t.AroundHelper,vt={},xt={};function bt(t,e,n){if(e){let a;for(let s=0,o=e.length;s<o;s++)a=e[s],"string"==typeof a?t.addColorStop(s/(o-1),i.ColorConvert.string(a,n)):t.addColorStop(a.offset,i.ColorConvert.string(a.color,n))}}const{getAngle:Bt,getDistance:Lt}=t.PointHelper,{get:Et,rotateOfOuter:Rt,scaleOfOuter:kt}=t.MatrixHelper,{toPoint:Pt}=t.AroundHelper,St={},Ct={};function At(t,e,n,i,a){let s;const{width:o,height:r}=t;if(o!==r||i){const t=Bt(e,n);s=Et(),a?(kt(s,e,o/r*(i||1),1),Rt(s,e,t+90)):(kt(s,e,1,o/r*(i||1)),Rt(s,e,t))}return s}const{getDistance:Wt}=t.PointHelper,{toPoint:Ot}=t.AroundHelper,Tt={},Mt={};const It={linearGradient:function(e,n){let{from:i,to:a,type:s,blendMode:o,opacity:r}=e;mt(i||"top",n,vt),mt(a||"bottom",n,xt);const l=t.Platform.canvas.createLinearGradient(vt.x,vt.y,xt.x,xt.y);bt(l,e.stops,r);const d={type:s,style:l};return o&&(d.blendMode=o),d},radialGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:l}=e;Pt(i||"center",n,St),Pt(a||"bottom",n,Ct);const d=t.Platform.canvas.createRadialGradient(St.x,St.y,0,St.x,St.y,Lt(St,Ct));bt(d,e.stops,o);const h={type:s,style:d},c=At(n,St,Ct,l,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:l}=e;Ot(i||"center",n,Tt),Ot(a||"bottom",n,Mt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Tt.x,Tt.y):t.Platform.canvas.createRadialGradient(Tt.x,Tt.y,0,Tt.x,Tt.y,Wt(Tt,Mt));bt(d,e.stops,o);const h={type:s,style:d},c=At(n,Tt,Mt,l||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:At},{copy:Dt,toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={},Yt={};function jt(e,n,i,a){const{bounds:s,shapeBounds:o}=a;if(t.Platform.fullImageShadow){if(Dt(Ft,e.bounds),Ft.x+=n.x-o.x,Ft.y+=n.y-o.y,i){const{matrix:t}=a;Ft.x-=(s.x+(t?t.e:0)+s.width/2)*(i-1),Ft.y-=(s.y+(t?t.f:0)+s.height/2)*(i-1),Ft.width*=i,Ft.height*=i}e.copyWorld(a.canvas,e.bounds,Ft)}else i&&(Dt(Ft,n),Ft.x-=n.width/2*(i-1),Ft.y-=n.height/2*(i-1),Ft.width*=i,Ft.height*=i),e.copyWorld(a.canvas,o,i?Ft:n)}const{toOffsetOutBounds:Ut}=t.BoundsHelper,Gt={};const Xt={shadow:function(t,e,n){let i,a;const{__nowWorld:s,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(d,Yt),r.forEach(((r,g)=>{f.setWorldShadow(Yt.offsetX+r.x*c,Yt.offsetY+r.y*u,r.blur*c,r.color),a=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,jt(f,Yt,a,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,s,"copy"),i=s),l?f.copyWorld(l,s,s,"destination-out"):f.copyWorld(n.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,s,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,a;const{__nowWorld:s,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ut(d,Gt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Gt.offsetX+r.x*c,Gt.offsetY+r.y*u,r.blur*c),a=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,jt(f,Gt,a,n),f.restore(),l?(f.copyWorld(f,d,s,"copy"),f.copyWorld(l,s,s,"source-out"),i=s):(f.copyWorld(n.canvas,h,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,s,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&g<p&&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:qt}=t.LeafBoundsHelper;function zt(t,e,n,i,a,s){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Vt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Vt(t,n,i,s);break;case"path":n.restore()}}function Nt(t){return t.getSameCanvas(!1,!0)}function Vt(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}i.Group.prototype.__renderMask=function(t,e){let n,i,a,s,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)n=l[d],r=n.__.mask,r&&(o&&(zt(this,o,t,a,i,s),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",s=n.opacity,a||(a=Nt(t))):(o="path",t.save()),n.__clip(a||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=Nt(t)),a||(a=Nt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||qt(n,e)||n.__render(a||t,e);zt(this,o,t,a,i,s)};const Qt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Jt=Qt+"_#~&*+\\=|≮≯≈≠=…",Zt=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 Kt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $t=Kt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),te=Kt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ee=Kt(Qt),ne=Kt(Jt),ie=Kt("- —/~|┆·");var ae;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ae||(ae={}));const{Letter:se,Single:oe,Before:re,After:le,Symbol:de,Break:he}=ae;function ce(t){return $t[t]?se:ie[t]?he:te[t]?re:ee[t]?le:ne[t]?de:Zt.test(t)?oe:se}const ue={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let s=a-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function fe(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:pe}=ue,{Letter:ge,Single:_e,Before:we,After:ye,Symbol:me,Break:ve}=ae;let xe,be,Be,Le,Ee,Re,ke,Pe,Se,Ce,Ae,We,Oe,Te,Me,Ie,De,He=[];function Fe(t,e){Se&&!Pe&&(Pe=Se),xe.data.push({char:t,width:e}),Be+=e}function Ye(){Le+=Be,xe.width=Be,be.words.push(xe),xe={data:[]},Be=0}function je(){Te&&(Me.paraNumber++,be.paraStart=!0,Te=!1),Se&&(be.startCharSize=Pe,be.endCharSize=Se,Pe=0),be.width=Le,Ie.width?pe(be):De&&Ue(),He.push(be),be={words:[]},Le=0}function Ue(){Le>(Me.maxWidth||0)&&(Me.maxWidth=Le)}const Ge=0,Xe=1,qe=2;const{top:ze,right:Ne,bottom:Ve,left:Qe}=t.Direction4;function Je(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const Ze={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,s=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(s?(i=d[Qe],s-=d[Ne]+d[Qe]):n.autoSizeAlign||(i=d[Qe]),o?(a=d[ze],o-=d[ze]+d[Ve]):n.autoSizeAlign||(a=d[ze]));const h={bounds:{x:i,y:a,width:s,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Me=e,He=e.rows,Ie=e.bounds,De=!Ie.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:s,textCase:o}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ie;if(l||d||a||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Te=!0,Ae=null,Pe=ke=Se=Be=Le=0,xe={data:[]},be={words:[]};for(let i=0,d=n.length;i<d;i++)Re=n[i],"\n"===Re?(Be&&Ye(),be.paraEnd=!0,je(),Te=!0):(Ce=ce(Re),Ce===ge&&"none"!==o&&(Re=fe(Re,o,!Be)),ke=r.measureText(Re).width,a&&(a<0&&(Se=ke),ke+=a),We=Ce===_e&&(Ae===_e||Ae===ge)||Ae===_e&&Ce!==ye,Oe=!(Ce!==we&&Ce!==_e||Ae!==me&&Ae!==ye),Ee=Te&&s?l-s:l,t&&l&&Le+Be+ke>Ee&&(e?(Be&&Ye(),Le&&je()):(Oe||(Oe=Ce===ge&&Ae==ye),We||Oe||Ce===ve||Ce===we||Ce===_e||Be+ke>Ee?(Be&&Ye(),Le&&je()):Le&&je()))," "===Re&&!0!==Te&&Le+Be===0||(Ce===ve?(" "===Re&&Be&&Ye(),Fe(Re,ke),Ye()):We||Oe?(Be&&Ye(),Fe(Re,ke)):Fe(Re,ke)),Ae=Ce);Be&&Ye(),Le&&je(),He.length>0&&(He[He.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Me.paraNumber++,Le=r.measureText(t).width,He.push({x:s||0,text:t,width:Le,paraStart:!0}),De&&Ue()}))}(h,e,n),d&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Je(e,"x",t[Qe]);break;case"right":Je(e,"x",-t[Ne])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Je(e,"y",t[ze]);break;case"bottom":Je(e,"y",-t[Ve])}}(d,h,n,s,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:s,__letterSpacing:o,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:p,height:g}=i,_=a*n.length+(h?h*(t.paraNumber-1):0),w=s;if(r&&_>g)_=Math.max(g,a),t.overflow=n.length;else if(g||c)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let y,m,v,x=p||c?p:t.maxWidth;for(let s=0,d=n.length;s<d;s++){if(y=n[s],y.x=u,y.width<p||y.width>p&&!r)switch(l){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&s>0&&(w+=h),y.y=w,w+=a,t.overflow>s&&w>_&&(y.isOverflow=!0,t.overflow=s+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<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n,i){const{rows:a}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let l,d,h,c,u;a.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,d=n&&("justify"===s||"both"===s)&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Ge:d>.01?Xe:qe,t.isOverflow&&!r&&(t.textMode=!0),c===qe?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,l=t.x,t.data=[],t.words.forEach((e=>{c===Xe?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!d||t.paraEnd&&"both"!==s||(l+=d,t.width+=d)}))),t.words=null)}))}(h,n,s),h.overflow&&function(e,n,i,a){if(!a)return;const{rows:s,overflow:o}=e;let{textOverflow:r}=n;if(s.splice(o),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,h=i+a-d;("none"===n.textWrap?s:[s[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],l=e.x+e.width,!(i===n&&l<h));i--){if(l<h&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,i,s),"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 Ke={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;n&&(a*=e);const s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(i.TextConvert,Ze),Object.assign(i.ColorConvert,Ke),Object.assign(i.Paint,H),Object.assign(i.PaintImage,yt),Object.assign(i.PaintGradient,It),Object.assign(i.Effect,Xt);const{setPoint:$e,addPoint:tn,toBounds:en}=i.TwoPointBoundsHelper;const nn={export(t,e,n){this.running=!0;const s=i.FileHelper.fileType(e),o=e.includes(".");return n=i.FileHelper.getExportOptions(n),function(t){an||(an=new i.TaskProcessor);return new Promise((e=>{an.add((()=>a(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((l=>{const d=t=>{r(t),l(),this.running=!1},{toURL:h}=i.Platform,{download:c}=i.Platform.origin;if("json"===s)return o&&c(h(JSON.stringify(t.toJSON(n.json)),"text"),e),d({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&c(h(t.toSVG(),"svg"),e),d({data:!!o||t.toSVG()});const{leafer:u}=t;u?(sn(t),u.waitViewCompleted((()=>a(this,void 0,void 0,(function*(){let a,s,o=1,r=1;const{worldTransform:l,isLeafer:h,isFrame:c}=t,{slice:f,trim:p,onCanvas:g}=n,_=void 0===n.smooth?u.config.smooth:n.smooth,w=n.contextSettings||u.config.contextSettings,y=n.screenshot||t.isApp,m=h&&y&&void 0===n.fill?t.fill:n.fill,v=i.FileHelper.isOpaqueImage(e)||m,x=new i.Matrix;if(y)a=!0===y?h?u.canvas.bounds:t.worldRenderBounds:y;else{let e=n.relative||(h?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":x.set(l);break;case"local":x.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=t.leafer;default:x.set(l).divide(t.getTransform(e));const n=e.worldTransform;o/=o/n.scaleX,r/=r/n.scaleY}a=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};i.MathHelper.getScaleData(n.scale,n.size,a,b);let B=n.pixelRatio||1;t.isApp&&(b.scaleX*=B,b.scaleY*=B,B=t.app.pixelRatio);const{x:L,y:E,width:R,height:k}=new i.Bounds(a).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-L,-E).withScale(1/o*b.scaleX,1/r*b.scaleY)};let S,C=i.Creator.canvas({width:Math.round(R),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(S=t,S.__worldOpacity=0,t=u,P.bounds=C.bounds),C.save(),c&&void 0!==m){const e=t.get("fill");t.fill="",t.__render(C,P),t.fill=e}else t.__render(C,P);if(C.restore(),S&&S.__updateWorldOpacity(),p){s=function(t){const{width:e,height:n}=t.view,{data:a}=t.context.getImageData(0,0,e,n);let s,o,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(s=l%e,o=(l-s)/e,r?tn(r,s,o):$e(r={},s,o)),l++;const d=new i.Bounds;return en(r,d),d.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:n}=s,a={x:0,y:0,width:e,height:n,pixelRatio:B};C=i.Creator.canvas(a),C.copyWorld(t,s,a)}v&&C.fillWorld(C.bounds,m||"#FFFFFF","destination-over"),g&&g(C);const A="canvas"===e?C:yield C.export(e,n);d({data:A,width:C.pixelWidth,height:C.pixelHeight,renderBounds:a,trimBounds:s})}))))):d({data:!1})}))))}};let an;function sn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>sn(t)))}const on=i.LeaferCanvasBase.prototype,rn=i.Debug.get("@leafer-in/export");on.export=function(t,e){const{quality:n,blob:a}=i.FileHelper.getExportOptions(e);return t.includes(".")?this.saveAs(t,n):a?this.toBlob(t,n):this.toDataURL(t,n)},on.toBlob=function(t,e){return new Promise((n=>{i.Platform.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{rn.error(t),n(null)}))}))},on.toDataURL=function(t,e){return i.Platform.origin.canvasToDataURL(this.view,t,e)},on.saveAs=function(t,e){return new Promise((n=>{i.Platform.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{rn.error(t),n(!1)}))}))},i.Plugin.add("export"),Object.assign(i.Export,nn),i.UI.prototype.export=function(t,e){return i.Export.export(this,t,e)},Object.assign(t.Creator,{interaction:(t,e,i,a)=>new n.InteractionBase(t,e,i,a),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=s,exports.Picker=L,exports.Renderer=b,exports.Selector=E,exports.Watcher=l,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:e=>n(t.Platform.image.getRealURL(e))},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:s}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(o(e),n),canvasToBolb:(t,e,n)=>a(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,i)=>a(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(r(n)),i))})),download(t,e){},loadImage:e=>s(t.Platform.image.getRealURL(e))}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},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(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/node",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "@leafer-ui/node",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"leaferjs"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@leafer/core": "1.3.
|
|
36
|
-
"@leafer/node": "1.3.
|
|
37
|
-
"@leafer/partner": "1.3.
|
|
38
|
-
"@leafer/interface": "1.3.
|
|
39
|
-
"@leafer-ui/draw": "1.3.
|
|
40
|
-
"@leafer-ui/core": "1.3.
|
|
41
|
-
"@leafer-ui/partner": "1.3.
|
|
42
|
-
"@leafer-ui/interface": "1.3.
|
|
43
|
-
"@leafer-in/export": "1.3.
|
|
44
|
-
"@leafer-in/interface": "1.3.
|
|
35
|
+
"@leafer/core": "1.3.2",
|
|
36
|
+
"@leafer/node": "1.3.2",
|
|
37
|
+
"@leafer/partner": "1.3.2",
|
|
38
|
+
"@leafer/interface": "1.3.2",
|
|
39
|
+
"@leafer-ui/draw": "1.3.2",
|
|
40
|
+
"@leafer-ui/core": "1.3.2",
|
|
41
|
+
"@leafer-ui/partner": "1.3.2",
|
|
42
|
+
"@leafer-ui/interface": "1.3.2",
|
|
43
|
+
"@leafer-in/export": "1.3.2",
|
|
44
|
+
"@leafer-in/interface": "1.3.2"
|
|
45
45
|
}
|
|
46
46
|
}
|