@leafer-ui/node 1.0.0-rc.10 → 1.0.0-rc.12
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 +11 -13
- package/dist/node.esm.js +7 -9
- package/dist/node.esm.min.js +1 -1
- package/dist/node.min.cjs +1 -1
- package/package.json +8 -8
package/dist/node.cjs
CHANGED
|
@@ -918,9 +918,6 @@ Object.assign(core.Creator, {
|
|
|
918
918
|
});
|
|
919
919
|
core.Platform.layout = Layouter.fullLayout;
|
|
920
920
|
|
|
921
|
-
const PaintImage = {};
|
|
922
|
-
const PaintGradient = {};
|
|
923
|
-
|
|
924
921
|
function fillText(ui, canvas) {
|
|
925
922
|
let row;
|
|
926
923
|
const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
|
|
@@ -948,7 +945,7 @@ function fills(fills, ui, canvas) {
|
|
|
948
945
|
const { windingRule, __font } = ui.__;
|
|
949
946
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
950
947
|
item = fills[i];
|
|
951
|
-
if (item.image && PaintImage.checkImage(ui, canvas, item, !__font))
|
|
948
|
+
if (item.image && draw.PaintImage.checkImage(ui, canvas, item, !__font))
|
|
952
949
|
continue;
|
|
953
950
|
if (item.style) {
|
|
954
951
|
canvas.fillStyle = item.style;
|
|
@@ -1028,7 +1025,7 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
|
1028
1025
|
let item;
|
|
1029
1026
|
for (let i = 0, len = strokes.length; i < len; i++) {
|
|
1030
1027
|
item = strokes[i];
|
|
1031
|
-
if (item.image && PaintImage.checkImage(ui, canvas, item, false))
|
|
1028
|
+
if (item.image && draw.PaintImage.checkImage(ui, canvas, item, false))
|
|
1032
1029
|
continue;
|
|
1033
1030
|
if (item.style) {
|
|
1034
1031
|
canvas.strokeStyle = item.style;
|
|
@@ -1172,7 +1169,7 @@ function compute(attrName, ui) {
|
|
|
1172
1169
|
let paints = data.__input[attrName], hasOpacityPixel;
|
|
1173
1170
|
if (!(paints instanceof Array))
|
|
1174
1171
|
paints = [paints];
|
|
1175
|
-
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
1172
|
+
recycleMap = draw.PaintImage.recycleImage(attrName, data);
|
|
1176
1173
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1177
1174
|
item = getLeafPaint(attrName, paints[i], ui);
|
|
1178
1175
|
if (item)
|
|
@@ -1197,13 +1194,13 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1197
1194
|
let { type, blendMode, color, opacity } = paint;
|
|
1198
1195
|
return { type, blendMode, style: draw.ColorConvert.string(color, opacity) };
|
|
1199
1196
|
case 'image':
|
|
1200
|
-
return PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
1197
|
+
return draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
1201
1198
|
case 'linear':
|
|
1202
|
-
return PaintGradient.linearGradient(paint, boxBounds);
|
|
1199
|
+
return draw.PaintGradient.linearGradient(paint, boxBounds);
|
|
1203
1200
|
case 'radial':
|
|
1204
|
-
return PaintGradient.radialGradient(paint, boxBounds);
|
|
1201
|
+
return draw.PaintGradient.radialGradient(paint, boxBounds);
|
|
1205
1202
|
case 'angular':
|
|
1206
|
-
return PaintGradient.conicGradient(paint, boxBounds);
|
|
1203
|
+
return draw.PaintGradient.conicGradient(paint, boxBounds);
|
|
1207
1204
|
default:
|
|
1208
1205
|
return paint.r ? { type: 'solid', style: draw.ColorConvert.string(paint) } : undefined;
|
|
1209
1206
|
}
|
|
@@ -2375,7 +2372,8 @@ const ExportModule = {
|
|
|
2375
2372
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
2376
2373
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
2377
2374
|
options = core.FileHelper.getExportOptions(options);
|
|
2378
|
-
const { scale,
|
|
2375
|
+
const { scale, slice, trim } = options;
|
|
2376
|
+
const pixelRatio = options.pixelRatio || 1;
|
|
2379
2377
|
const screenshot = options.screenshot || leaf.isApp;
|
|
2380
2378
|
const fill = options.fill === undefined ? ((leaf.isLeafer && screenshot) ? leaf.fill : '') : options.fill;
|
|
2381
2379
|
const needFill = core.FileHelper.isOpaqueImage(filename) || fill, matrix = new core.Matrix();
|
|
@@ -2395,7 +2393,7 @@ const ExportModule = {
|
|
|
2395
2393
|
width *= scale, height *= scale;
|
|
2396
2394
|
scaleX *= scale, scaleY *= scale;
|
|
2397
2395
|
}
|
|
2398
|
-
let canvas = core.Creator.canvas({ width, height, pixelRatio });
|
|
2396
|
+
let canvas = core.Creator.canvas({ width: Math.ceil(width), height: Math.ceil(height), pixelRatio });
|
|
2399
2397
|
const renderOptions = { matrix: matrix.translate(-x, -y).withScale(scaleX, scaleY) };
|
|
2400
2398
|
if (slice) {
|
|
2401
2399
|
leaf = leafer;
|
|
@@ -2414,7 +2412,7 @@ const ExportModule = {
|
|
|
2414
2412
|
if (needFill)
|
|
2415
2413
|
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
2416
2414
|
const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
|
|
2417
|
-
over({ data, renderBounds, trimBounds });
|
|
2415
|
+
over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
|
|
2418
2416
|
}));
|
|
2419
2417
|
}
|
|
2420
2418
|
else {
|
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 { ColorConvert, Export, Group, TextConvert, Paint,
|
|
7
|
+
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect } from '@leafer-ui/draw';
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
10
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -919,9 +919,6 @@ Object.assign(Creator, {
|
|
|
919
919
|
});
|
|
920
920
|
Platform.layout = Layouter.fullLayout;
|
|
921
921
|
|
|
922
|
-
const PaintImage = {};
|
|
923
|
-
const PaintGradient = {};
|
|
924
|
-
|
|
925
922
|
function fillText(ui, canvas) {
|
|
926
923
|
let row;
|
|
927
924
|
const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
|
|
@@ -2376,7 +2373,8 @@ const ExportModule = {
|
|
|
2376
2373
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
2377
2374
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
2378
2375
|
options = FileHelper.getExportOptions(options);
|
|
2379
|
-
const { scale,
|
|
2376
|
+
const { scale, slice, trim } = options;
|
|
2377
|
+
const pixelRatio = options.pixelRatio || 1;
|
|
2380
2378
|
const screenshot = options.screenshot || leaf.isApp;
|
|
2381
2379
|
const fill = options.fill === undefined ? ((leaf.isLeafer && screenshot) ? leaf.fill : '') : options.fill;
|
|
2382
2380
|
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
@@ -2396,7 +2394,7 @@ const ExportModule = {
|
|
|
2396
2394
|
width *= scale, height *= scale;
|
|
2397
2395
|
scaleX *= scale, scaleY *= scale;
|
|
2398
2396
|
}
|
|
2399
|
-
let canvas = Creator.canvas({ width, height, pixelRatio });
|
|
2397
|
+
let canvas = Creator.canvas({ width: Math.ceil(width), height: Math.ceil(height), pixelRatio });
|
|
2400
2398
|
const renderOptions = { matrix: matrix.translate(-x, -y).withScale(scaleX, scaleY) };
|
|
2401
2399
|
if (slice) {
|
|
2402
2400
|
leaf = leafer;
|
|
@@ -2415,7 +2413,7 @@ const ExportModule = {
|
|
|
2415
2413
|
if (needFill)
|
|
2416
2414
|
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
2417
2415
|
const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
|
|
2418
|
-
over({ data, renderBounds, trimBounds });
|
|
2416
|
+
over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
|
|
2419
2417
|
}));
|
|
2420
2418
|
}
|
|
2421
2419
|
else {
|
|
@@ -2436,8 +2434,8 @@ function addTask(task) {
|
|
|
2436
2434
|
Object.assign(TextConvert, TextConvertModule);
|
|
2437
2435
|
Object.assign(ColorConvert, ColorConvertModule);
|
|
2438
2436
|
Object.assign(Paint, PaintModule);
|
|
2439
|
-
Object.assign(PaintImage
|
|
2440
|
-
Object.assign(PaintGradient
|
|
2437
|
+
Object.assign(PaintImage, PaintImageModule);
|
|
2438
|
+
Object.assign(PaintGradient, PaintGradientModule);
|
|
2441
2439
|
Object.assign(Effect, EffectModule);
|
|
2442
2440
|
Object.assign(Export, ExportModule);
|
|
2443
2441
|
|
package/dist/node.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as s,LeaferImage as n,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as _,LeafBoundsHelper as g,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as B,BoundsHelper as b,Answer as R,MatrixHelper as k,ImageEvent as E,PointHelper as L,Direction4 as S,TwoPointBoundsHelper as M,TaskProcessor as A,Matrix as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as I}from"fs";import{InteractionBase as T,HitCanvasManager as W}from"@leafer-ui/core";export*from"@leafer-ui/core";import{ColorConvert as O,Export as P,Group as F,TextConvert as D,Paint as N,PaintImage as Y,PaintGradient as U,Effect as X}from"@leafer-ui/draw";function G(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{d(s.next(t))}catch(t){a(t)}}function r(t){try{d(s.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class H 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:V,fileType:j}=a;function q(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),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}),loadImage:s},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURL(V(e),i),canvasToBolb:(t,e,i)=>G(this,void 0,void 0,(function*(){return t.toBuffer(V(e),i)})),canvasSaveAs:(t,e,i)=>G(this,void 0,void 0,(function*(){return I(e,t.toBuffer(V(j(e)),i))})),loadImage:s}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new H(t,e),image:t=>new n(t)}),e.name="node",e.requestRender=function(t){setTimeout(t)},e.devicePixelRatio=1,e.conicGradientSupport=!0;class z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;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 o,this.target=t,e&&(this.config=r.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(d.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 l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.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:Q,updateBounds:Z,updateAllWorldOpacity:K}=u,{pushAllChildBranch:$,pushAllParent:J}=f;const{worldBounds:tt}=g,et={x:0,y:0,width:1e5,height:1e5};class it{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,tt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(et):this.afterBounds.setListWithFn(t,tt),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:st,updateAllChange:nt}=u,at=p.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.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(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){at.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?at.warn("layouting"):this.times>3?at.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(l.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=m.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new y(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(Q(t,!0),e.add(t),t.isBranch&&$(t,e),J(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),J(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Z(s[t])}Z(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&K(t),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(a,r,this.times)),i.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(i,a,this.times)),ot.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(s,a,this.times)),e.emitEvent(new y(n,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){st(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),nt(t)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new it([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}createBlock(t){return new it(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_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const rt=p.get("Renderer");class dt{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=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,rt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,rt.error(t)}rt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?rt.warn("rendering"):this.times>3?rt.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t?(this.emitRender(d.BEFORE),t()):(this.requestLayout(),this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return rt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),a=new _(s);i.save(),n&&!p.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,a),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(s),p.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new _(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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||rt.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 d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.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=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:ht}=b;class lt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=i.findList||[],i.findList||this.eachFind(a.children,a.__onlyHitMask);const o=this.findList,r=this.getBestMatchLeaf(),d=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:d,target:r,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],u.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ht(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:ct,NoAndSkip:ut,YesAndSkip:ft}=R;class _t{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new lt(t,this),this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(y.CHECK_UPDATE),this.picker.getByPoint(t,i,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&u.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,a;for(let o=0,r=t.length;o<r;o++){if(n=t[o],a=e(n,s),a===ct||a===ft){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&a<ut&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(c.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(s,{watcher:(t,e)=>new z(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new _t(t,e)}),e.layout=ot.fullLayout;const gt={},pt={};function wt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,a)}function yt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?xt(t,!0,e,i):vt(e,i);break;case"inside":mt("inside",t,n,e,i);break;case"outside":mt("outside",t,n,e,i)}}function mt(t,e,i,s,n){const{__strokeWidth:a,__font:o}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,s.__),r.font=o,i?xt(e,!0,s,r):vt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",wt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function vt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,a)}function xt(t,e,i,s){let n;for(let a=0,o=t.length;a<o;a++)n=t[a],n.image&>.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?vt(i,s):s.stroke(),s.restoreBlendMode()):e?vt(i,s):s.stroke())}const{getSpread:Bt,getOuterOf:bt,getByMove:Rt,getIntersectData:kt}=b;let Et;function Lt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:a,color:o,opacity:r}=e;return{type:n,blendMode:a,style:O.string(o,r)};case"image":return gt.image(i,t,e,s,!Et||!Et[e.url]);case"linear":return pt.linearGradient(e,s);case"radial":return pt.radialGradient(e,s);case"angular":return pt.conicGradient(e,s);default:return e.r?{type:"solid",style:O.string(e)}:void 0}}const St={compute:function(t,e){const i=e.__,s=[];let n,a=i.__input[t];a instanceof Array||(a=[a]),Et=gt.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)i=Lt(t,a[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?wt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&>.checkImage(e,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?wt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?wt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):a?wt(e,i):n?i.fill(n):i.fill())},fillText:wt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)yt(t,e,i);else switch(a){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*n,s),e.__drawRenderPath(a),a.stroke(),s.windingRule?a.clip(s.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 s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)yt(t,e,i);else switch(a){case"center":i.setStroke(void 0,n,s),xt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),xt(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*n,s),xt(t,!1,e,o),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:yt,drawTextStroke:vt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,d,{scaleX:h,scaleY:l}=n;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(n))d=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,c=kt(s?Bt(e.bounds,s*h,s*l):e.bounds,n);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),h*=u,l*=f),r=bt(n,o),a=Rt(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(s,i),{canvas:s,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:h,scaleY:l}}};let Mt={};const{get:At,rotateOfOuter:Ct,translate:It,scaleOfOuter:Tt,scale:Wt,rotate:Ot}=k;function Pt(t,e,i,s,n,a){const o=At(),r=a&&180!==a,d=i.width/(r?n:s),h=i.height/(r?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;It(o,c,u),Wt(o,l),a&&Ct(o,{x:i.x+i.width/2,y:i.y+i.height/2},a),t.scaleX=t.scaleY=l,t.transform=o}function Ft(t,e,i,s,n,a,o){const r=At();It(r,e.x,e.y),(i||s)&&It(r,i,s),n&&(Wt(r,n,a),t.scaleX=r.a,t.scaleY=r.d),o&&Ot(r,o),t.transform=r}function Dt(t,e,i,s,n,a,o,r,d){const h=At();if(d)switch(Ot(h,d),d){case 90:It(h,s,0);break;case 180:It(h,i,s);break;case 270:It(h,0,i)}Mt.x=e.x,Mt.y=e.y,(n||a)&&(Mt.x+=n,Mt.y+=a),It(h,Mt.x,Mt.y),o&&(Tt(h,Mt,o,r),t.scaleX=o,t.scaleY=r),t.transform=h}const{get:Nt,translate:Yt}=k;function Ut(t,e,i,s){let{width:n,height:a}=e;const{opacity:o,mode:r,offset:d,scale:h,size:l,rotation:c,blendMode:u,repeat:f}=i,_=s.width===n&&s.height===a;u&&(t.blendMode=u);const g=t.data={mode:r};let p,w,y,m;switch(d&&(p=d.x,w=d.y),l?(y=("number"==typeof l?l:l.width)/n,m=("number"==typeof l?l:l.height)/a):h&&(y="number"==typeof h?h:h.x,m="number"==typeof h?h:h.y),r){case"strench":_||(n=s.width,a=s.height),(s.x||s.y)&&(g.transform=Nt(),Yt(g.transform,s.x,s.y));break;case"clip":(d||y||c)&&Ft(g,s,p,w,y,m,c);break;case"repeat":(!_||y||c)&&Dt(g,s,n,a,p,w,y,m,c),f||(g.repeat="repeat");break;default:_&&!c||Pt(g,r,s,n,a,c)}g.width=n,g.height=a,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Xt,Gt=new _;const{isSame:Ht}=b;function Vt(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,e.__autoWidth||e.__autoHeight)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Ut(n,s,i,a),!0}function jt(t,e){Qt(t,E.LOAD,e)}function qt(t,e){Qt(t,E.LOADED,e)}function zt(t,e,i){e.error=i,t.forceUpdate("surface"),Qt(t,E.ERROR,e)}function Qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}const{get:Zt,scale:Kt,copy:$t}=k,{round:Jt,abs:te}=Math;function ee(t,i,s){let{scaleX:n,scaleY:a}=t.__world;const o=n+"-"+a;if(i.patternId===o||t.destroyed)return!1;{n=te(n),a=te(a);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:_,transform:g,repeat:p}=r;u&&(h=Zt(),$t(h,g),Kt(h,1/u,1/f),n*=u,a*=f),n*=s,a*=s,l*=n,c*=a;const w=l*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&&(n/=d,a/=d,l/=d,c/=d),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(h||(h=Zt(),g&&$t(h,g)),Kt(h,1/n,1/a));const m=t.getCanvas(l<1?1:Jt(l),c<1?1:Jt(c),_),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=v,i.patternId=o,!0}}const{abs:ie}=Math;const se={image:function(t,e,i,s,n){let a,o;const r=v.get(i);return Xt&&i===Xt.paint&&Ht(s,Xt.boxBounds)?a=Xt.leafPaint:(a={type:i.type},a.image=r,Xt=r.use>1?{leafPaint:a,paint:i,boxBounds:Gt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Vt(t,e,i,r,a,s),n&&(jt(t,o),qt(t,o))):r.error?n&&zt(t,o,r.error):(n&&jt(t,o),a.loadId=r.load((()=>{t.destroyed||(Vt(t,e,i,r,a,s)&&t.forceUpdate("surface"),qt(t,o)),a.loadId=null}),(e=>{zt(t,o,e),a.loadId=null}))),a},createData:Ut,fillOrFitMode:Pt,clipMode:Ft,repeatMode:Dt,createPattern:ee,checkImage:function(t,i,s,n){const{scaleX:a,scaleY:o}=t.__world;if(s.data&&s.patternId!==a+"-"+o){const{data:r}=s;if(n)if(r.repeat)n=!1;else{let{width:t,height:s}=r;t*=ie(a)*i.pixelRatio,s*=ie(o)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,s*=r.scaleY),n=t*s>e.image.maxCacheSize}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(s.image.view,0,0,r.width,r.height),i.restore(),!0):(!s.style||P.running?ee(t,s,i.pixelRatio):s.patternTask||(s.patternTask=v.patternTasker.add((()=>G(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__world)&&ee(t,s,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,o;for(let r=0,d=i.length;r<d;r++)s=i[r].image,o=s&&s.url,o&&(n||(n={}),n[o]=!0,v.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(i[r].loadId,!a.some((t=>t.url===o)))));return n}return null}},ne={x:.5,y:0},ae={x:.5,y:1};function oe(t,e,i){let s;for(let n=0,a=e.length;n<a;n++)s=e[n],t.addColorStop(s.offset,O.string(s.color,i))}const{set:re,getAngle:de,getDistance:he}=L,{get:le,rotateOfOuter:ce,scaleOfOuter:ue}=k,fe={x:.5,y:.5},_e={x:.5,y:1},ge={},pe={};const{set:we,getAngle:ye,getDistance:me}=L,{get:ve,rotateOfOuter:xe,scaleOfOuter:Be}=k,be={x:.5,y:.5},Re={x:.5,y:1},ke={},Ee={};const Le={linearGradient:function(t,i){let{from:s,to:n,type:a,blendMode:o,opacity:r}=t;s||(s=ne),n||(n=ae);const d=e.canvas.createLinearGradient(i.x+s.x*i.width,i.y+s.y*i.height,i.x+n.x*i.width,i.y+n.y*i.height);oe(d,t.stops,r);const h={type:a,style:d};return o&&(h.blendMode=o),h},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;s||(s=fe),n||(n=_e);const{x:h,y:l,width:c,height:u}=i;let f;re(ge,h+s.x*c,l+s.y*u),re(pe,h+n.x*c,l+n.y*u),(c!==u||d)&&(f=le(),ue(f,ge,c/u*(d||1),1),ce(f,ge,de(ge,pe)+90));const _=e.canvas.createRadialGradient(ge.x,ge.y,0,ge.x,ge.y,he(ge,pe));oe(_,t.stops,o);const g={type:a,style:_,transform:f};return r&&(g.blendMode=r),g},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;s||(s=be),n||(n=Re);const{x:h,y:l,width:c,height:u}=i;we(ke,h+s.x*c,l+s.y*u),we(Ee,h+n.x*c,l+n.y*u);const f=ve(),_=ye(ke,Ee);e.conicGradientRotate90?(Be(f,ke,c/u*(d||1),1),xe(f,ke,_+90)):(Be(f,ke,1,c/u*(d||1)),xe(f,ke,_));const g=e.conicGradientSupport?e.canvas.createConicGradient(0,ke.x,ke.y):e.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,me(ke,Ee));oe(g,t.stops,o);const p={type:a,style:g,transform:f};return r&&(p.blendMode=r),p}},{copy:Se,toOffsetOutBounds:Me}=b,Ae={},Ce={};function Ie(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(Se(Ae,t.bounds),Ae.x+=i.x-o.x,Ae.y+=i.y-o.y,s){const{matrix:t}=n;Ae.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Ae.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Ae.width*=s,Ae.height*=s}t.copyWorld(n.canvas,t.bounds,Ae)}else s&&(Se(Ae,i),Ae.x-=i.width/2*(s-1),Ae.y-=i.height/2*(s-1),Ae.width*=s,Ae.height*=s),t.copyWorld(n.canvas,o,s?Ae:i)}const{toOffsetOutBounds:Te}=b,We={};const Oe={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Me(h,Ce),r.forEach(((r,g)=>{f.setWorldShadow(Ce.offsetX+r.x*c,Ce.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ie(f,Ce,n,i),s=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,a,"copy"),s=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Te(h,We),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(We.offsetX+r.x*c,We.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ie(f,We,n,i),f.restore(),d?(f.copyWorld(f,h,a,"copy"),f.copyWorld(d,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,l,h,"source-out"),s=h),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Pe}=g;function Fe(t,e,i,s,n,a){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ne(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ne(t,i,s,a);break;case"path":i.restore()}}function De(t){return t.getSameCanvas(!1,!0)}function Ne(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}F.prototype.__renderMask=function(t,e){let i,s,n,a,o;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(o&&(Fe(this,o,t,n,s,a),s=n=null),"path"===i.__.maskType?(i.opacity<1?(o="opacity-path",a=i.opacity,n||(n=De(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="alpha",s||(s=De(t)),n||(n=De(t)),i.__render(s,e)),"clipping"!==i.__.maskType)||Pe(i,e)||i.__render(n||t,e);Fe(this,o,t,n,s,a)};const Ye=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ue=Ye+"_#~&*+\\=|≮≯≈≠=…",Xe=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 Ge(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const He=Ge("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ve=Ge("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),je=Ge(Ye),qe=Ge(Ue),ze=Ge("- —/~|┆·");var Qe;!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"}(Qe||(Qe={}));const{Letter:Ze,Single:Ke,Before:$e,After:Je,Symbol:ti,Break:ei}=Qe;function ii(t){return He[t]?Ze:ze[t]?ei:Ve[t]?$e:je[t]?Je:qe[t]?ti:Xe.test(t)?Ke:Ze}const si={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ni(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:ai}=si,{Letter:oi,Single:ri,Before:di,After:hi,Symbol:li,Break:ci}=Qe;let ui,fi,_i,gi,pi,wi,yi,mi,vi,xi,Bi,bi,Ri,ki,Ei,Li,Si=[];function Mi(t,e){vi&&!mi&&(mi=vi),ui.data.push({char:t,width:e}),_i+=e}function Ai(){gi+=_i,ui.width=_i,fi.words.push(ui),ui={data:[]},_i=0}function Ci(){ki&&(Ei.paraNumber++,fi.paraStart=!0,ki=!1),vi&&(fi.startCharSize=mi,fi.endCharSize=vi,mi=0),fi.width=gi,Li.width&&ai(fi),Si.push(fi),fi={words:[]},gi=0}const Ii=0,Ti=1,Wi=2;const{top:Oi,right:Pi,bottom:Fi,left:Di}=S;function Ni(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Yi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:h}=i;h&&(a&&(s=h[Di],a-=h[Pi]+h[Di]),o&&(n=h[Oi],o-=h[Oi]+h[Fi]));const l={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,s){Ei=t,Si=t.rows,Li=t.bounds;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:d,height:h}=Li;if(d||h||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;ki=!0,Bi=null,mi=yi=vi=_i=gi=0,ui={data:[]},fi={words:[]};for(let s=0,h=i.length;s<h;s++)wi=i[s],"\n"===wi?(_i&&Ai(),fi.paraEnd=!0,Ci(),ki=!0):(xi=ii(wi),xi===oi&&"none"!==o&&(wi=ni(wi,o,!_i)),yi=r.measureText(wi).width,n&&(n<0&&(vi=yi),yi+=n),bi=xi===ri&&(Bi===ri||Bi===oi)||Bi===ri&&xi!==hi,Ri=!(xi!==di&&xi!==ri||Bi!==li&&Bi!==hi),pi=ki&&a?d-a:d,t&&d&&gi+_i+yi>pi&&(e?(_i&&Ai(),Ci()):(Ri||(Ri=xi===oi&&Bi==hi),bi||Ri||xi===ci||xi===di||xi===ri||_i+yi>pi?(_i&&Ai(),Ci()):Ci()))," "===wi&&!0!==ki&&gi+_i===0||(xi===ci?(" "===wi&&_i&&Ai(),Mi(wi,yi),Ai()):bi||Ri?(_i&&Ai(),Mi(wi,yi)):Mi(wi,yi)),Bi=xi);_i&&Ai(),gi&&Ci(),Si.length>0&&(Si[Si.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ei.paraNumber++,Si.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Ni(e,"x",t[Di]);break;case"right":Ni(e,"x",-t[Pi])}if(!n)switch(i.verticalAlign){case"top":Ni(e,"y",t[Oi]);break;case"bottom":Ni(e,"y",-t[Fi])}}(h,l,i,a,o),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:_,y:g,width:p,height:w}=s,y=n*i.length+(l?l*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(h){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=_,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=n,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<s.x&&(s.x=u),f>s.width&&(s.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(l,i),function(t,e,i,s){const{rows:n}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Ii:h>.01?Ti:Wi,t.isOverflow&&!r&&(t.textMode=!0),c===Wi?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Ti?(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)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,a),l.overflow&&function(t,i){const{rows:s,overflow:n}=t;let{textOverflow:a}=i;if(s.splice(n),"hide"!==a){let t,o;"ellipsis"===a&&(a="...");const r=e.canvas.measureText(a).width,d=i.x+i.width-r;("none"===i.textWrap?s:[s[n-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],o=t.x+t.width,!(s===i&&o<d));s--){if(o<d&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,i),l}};const Ui={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},{setPoint:Xi,addPoint:Gi,toBounds:Hi}=M;const Vi={export(t,e,i){return this.running=!0,function(t){ji||(ji=new A);return new Promise((e=>{ji.add((()=>G(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((o=>{const r=t=>{n(t),o(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>G(this,void 0,void 0,(function*(){let n,o,h=1,l=1;i=a.getExportOptions(i);const{scale:c,pixelRatio:u,slice:f,trim:g}=i,p=i.screenshot||t.isApp,w=void 0===i.fill?t.isLeafer&&p?t.fill:"":i.fill,y=a.isOpaqueImage(e)||w,m=new C;if(p)n=!0===p?t.isLeafer?d.canvas.bounds:t.worldRenderBounds:p;else{const{localTransform:e,__world:i}=t;m.set(i).divide(e).invert(),h=1/(i.scaleX/t.scaleX),l=1/(i.scaleY/t.scaleY),n=t.getBounds("render","local")}let{x:v,y:x,width:B,height:b}=n;c&&(m.scale(c),B*=c,b*=c,h*=c,l*=c);let R=s.canvas({width:B,height:b,pixelRatio:u});const k={matrix:m.translate(-v,-x).withScale(h,l)};if(f&&(t=d,k.bounds=R.bounds),R.save(),t.__render(R,k),R.restore(),g){o=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,a,o,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,a=(r-n)/e,o?Gi(o,n,a):Xi(o={},n,a)),r++;const d=new _;return Hi(o,d),d.scale(1/t.pixelRatio).ceil()}(R);const t=R,{width:e,height:i}=o,n={x:0,y:0,width:e,height:i,pixelRatio:u};R=s.canvas(n),R.copyWorld(t,o,n)}y&&R.fillWorld(R.bounds,w||"#FFFFFF","destination-over");const E="canvas"===e?R:yield R.export(e,i);r({data:E,renderBounds:n,trimBounds:o})})))):r({data:!1})}))))}};let ji;Object.assign(D,Yi),Object.assign(O,Ui),Object.assign(N,St),Object.assign(Y,se),Object.assign(U,Le),Object.assign(X,Oe),Object.assign(P,Vi),Object.assign(s,{interaction:(t,e,i,s)=>new T(t,e,i,s),hitCanvas:(t,e)=>new H(t,e),hitCanvasManager:()=>new W});export{ot as Layouter,H as LeaferCanvas,dt as Renderer,_t as Selector,z as Watcher,q as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as s,LeaferImage as n,FileHelper as a,LeafList as o,DataHelper as r,RenderEvent as d,ChildEvent as h,WatchEvent as l,PropertyEvent as c,LeafHelper as u,BranchHelper as f,Bounds as _,LeafBoundsHelper as g,Debug as p,LeafLevelList as w,LayoutEvent as y,Run as m,ImageManager as v,AnimateEvent as x,ResizeEvent as B,BoundsHelper as b,Answer as R,MatrixHelper as k,ImageEvent as E,PointHelper as L,Direction4 as S,TwoPointBoundsHelper as M,TaskProcessor as A,Matrix as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as W}from"fs";import{InteractionBase as T,HitCanvasManager as I}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as O,ColorConvert as P,PaintGradient as F,Export as D,Group as N,TextConvert as Y,Paint as H,Effect as U}from"@leafer-ui/draw";function X(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{d(s.next(t))}catch(t){a(t)}}function r(t){try{d(s.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class G 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:V,fileType:j}=a;function q(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),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}),loadImage:s},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURL(V(e),i),canvasToBolb:(t,e,i)=>X(this,void 0,void 0,(function*(){return t.toBuffer(V(e),i)})),canvasSaveAs:(t,e,i)=>X(this,void 0,void 0,(function*(){return W(e,t.toBuffer(V(j(e)),i))})),loadImage:s}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new G(t,e),image:t=>new n(t)}),e.name="node",e.requestRender=function(t){setTimeout(t)},e.devicePixelRatio=1,e.conicGradientSupport=!0;class z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new o;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 o,this.target=t,e&&(this.config=r.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(d.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 l(l.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(c.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(l.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:Q,updateBounds:Z,updateAllWorldOpacity:K}=u,{pushAllChildBranch:$,pushAllParent:J}=f;const{worldBounds:tt}=g,et={x:0,y:0,width:1e5,height:1e5};class it{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,tt)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(et):this.afterBounds.setListWithFn(t,tt),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:st,updateAllChange:nt}=u,at=p.get("Layouter");class ot{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new w,this.target=t,e&&(this.config=r.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(y.START),this.layoutOnce(),t.emitEvent(new y(y.END,this.layoutedBlocks,this.times))}catch(t){at.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?at.warn("layouting"):this.times>3?at.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(l.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=m.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=y,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new y(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(Q(t,!0),e.add(t),t.isBranch&&$(t,e),J(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),J(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||Z(s[t])}Z(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&K(t),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new y(a,r,this.times)),i.emitEvent(new y(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,m.end(e)}fullLayout(){const t=m.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=y,a=this.getBlocks(new o(e));e.emitEvent(new y(i,a,this.times)),ot.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new y(s,a,this.times)),e.emitEvent(new y(n,a,this.times)),this.addBlocks(a),m.end(t)}static fullLayout(t){st(t,!0),t.isBranch?f.updateBounds(t):u.updateBounds(t),nt(t)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new it([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}createBlock(t){return new it(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_(y.REQUEST,this.layout,this),t.on_(y.AGAIN,this.layoutAgain,this),t.on_(l.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const rt=p.get("Renderer");class dt{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=r.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(y.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new _,rt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),v.clearRecycled()}catch(t){this.rendering=!1,rt.error(t)}rt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?rt.warn("rendering"):this.times>3?rt.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t?(this.emitRender(d.BEFORE),t()):(this.requestLayout(),this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return rt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=m.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),a=new _(s);i.save(),n&&!p.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,a),i.restore(),m.end(e)}fullRender(){const t=m.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),m.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),p.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),p.showHitView&&this.renderHitView(s),p.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.running&&(this.target.emit(x.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new _(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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||rt.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 d(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(d.REQUEST,this.update,this),t.on_(y.END,this.__onLayoutEnd,this),t.on_(d.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=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:ht}=b;class lt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=i.findList||[],i.findList||this.eachFind(a.children,a.__onlyHitMask);const o=this.findList,r=this.getBestMatchLeaf(),d=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:d,target:r,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],u.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return e.add(this.target),e}getHitablePath(t){const e=this.getPath(t);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,o=i.length;t<o;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ht(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:ct,NoAndSkip:ut,YesAndSkip:ft}=R;class _t{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=t,e&&(this.config=r.default(e,this.config)),this.picker=new lt(t,this),this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,i,s){return"node"===e.name&&this.target.emit(y.CHECK_UPDATE),this.picker.getByPoint(t,i,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&u.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,a;for(let o=0,r=t.length;o<r;o++){if(n=t[o],a=e(n,s),a===ct||a===ft){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&a<ut&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(c.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function gt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,a)}function pt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?mt(t,!0,e,i):yt(e,i);break;case"inside":wt("inside",t,n,e,i);break;case"outside":wt("outside",t,n,e,i)}}function wt(t,e,i,s,n){const{__strokeWidth:a,__font:o}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,s.__),r.font=o,i?mt(e,!0,s,r):yt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",gt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function yt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,a)}function mt(t,e,i,s){let n;for(let a=0,o=t.length;a<o;a++)n=t[a],n.image&&O.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?yt(i,s):s.stroke(),s.restoreBlendMode()):e?yt(i,s):s.stroke())}Object.assign(s,{watcher:(t,e)=>new z(t,e),layouter:(t,e)=>new ot(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>new _t(t,e)}),e.layout=ot.fullLayout;const{getSpread:vt,getOuterOf:xt,getByMove:Bt,getIntersectData:bt}=b;let Rt;function kt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:a,color:o,opacity:r}=e;return{type:n,blendMode:a,style:P.string(o,r)};case"image":return O.image(i,t,e,s,!Rt||!Rt[e.url]);case"linear":return F.linearGradient(e,s);case"radial":return F.radialGradient(e,s);case"angular":return F.conicGradient(e,s);default:return e.r?{type:"solid",style:P.string(e)}:void 0}}const Et={compute:function(t,e){const i=e.__,s=[];let n,a=i.__input[t];a instanceof Array||(a=[a]),Rt=O.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)i=kt(t,a[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?gt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&O.checkImage(e,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?gt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?gt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):a?gt(e,i):n?i.fill(n):i.fill())},fillText:gt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)pt(t,e,i);else switch(a){case"center":i.setStroke(t,n,s),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*n,s),e.__drawRenderPath(a),a.stroke(),s.windingRule?a.clip(s.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 s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)pt(t,e,i);else switch(a){case"center":i.setStroke(void 0,n,s),mt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),mt(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*n,s),mt(t,!1,e,o),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:pt,drawTextStroke:yt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,d,{scaleX:h,scaleY:l}=n;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(n))d=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,c=bt(s?vt(e.bounds,s*h,s*l):e.bounds,n);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),h*=u,l*=f),r=xt(n,o),a=Bt(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(s,i),{canvas:s,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:h,scaleY:l}}};let Lt={};const{get:St,rotateOfOuter:Mt,translate:At,scaleOfOuter:Ct,scale:Wt,rotate:Tt}=k;function It(t,e,i,s,n,a){const o=St(),r=a&&180!==a,d=i.width/(r?n:s),h=i.height/(r?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;At(o,c,u),Wt(o,l),a&&Mt(o,{x:i.x+i.width/2,y:i.y+i.height/2},a),t.scaleX=t.scaleY=l,t.transform=o}function Ot(t,e,i,s,n,a,o){const r=St();At(r,e.x,e.y),(i||s)&&At(r,i,s),n&&(Wt(r,n,a),t.scaleX=r.a,t.scaleY=r.d),o&&Tt(r,o),t.transform=r}function Pt(t,e,i,s,n,a,o,r,d){const h=St();if(d)switch(Tt(h,d),d){case 90:At(h,s,0);break;case 180:At(h,i,s);break;case 270:At(h,0,i)}Lt.x=e.x,Lt.y=e.y,(n||a)&&(Lt.x+=n,Lt.y+=a),At(h,Lt.x,Lt.y),o&&(Ct(h,Lt,o,r),t.scaleX=o,t.scaleY=r),t.transform=h}const{get:Ft,translate:Dt}=k;function Nt(t,e,i,s){let{width:n,height:a}=e;const{opacity:o,mode:r,offset:d,scale:h,size:l,rotation:c,blendMode:u,repeat:f}=i,_=s.width===n&&s.height===a;u&&(t.blendMode=u);const g=t.data={mode:r};let p,w,y,m;switch(d&&(p=d.x,w=d.y),l?(y=("number"==typeof l?l:l.width)/n,m=("number"==typeof l?l:l.height)/a):h&&(y="number"==typeof h?h:h.x,m="number"==typeof h?h:h.y),r){case"strench":_||(n=s.width,a=s.height),(s.x||s.y)&&(g.transform=Ft(),Dt(g.transform,s.x,s.y));break;case"clip":(d||y||c)&&Ot(g,s,p,w,y,m,c);break;case"repeat":(!_||y||c)&&Pt(g,s,n,a,p,w,y,m,c),f||(g.repeat="repeat");break;default:_&&!c||It(g,r,s,n,a,c)}g.width=n,g.height=a,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let Yt,Ht=new _;const{isSame:Ut}=b;function Xt(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width,e.__naturalHeight=s.height,e.__autoWidth||e.__autoHeight)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Nt(n,s,i,a),!0}function Gt(t,e){qt(t,E.LOAD,e)}function Vt(t,e){qt(t,E.LOADED,e)}function jt(t,e,i){e.error=i,t.forceUpdate("surface"),qt(t,E.ERROR,e)}function qt(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}const{get:zt,scale:Qt,copy:Zt}=k,{round:Kt,abs:$t}=Math;function Jt(t,i,s){let{scaleX:n,scaleY:a}=t.__world;const o=n+"-"+a;if(i.patternId===o||t.destroyed)return!1;{n=$t(n),a=$t(a);const{image:t,data:r}=i;let d,h,{width:l,height:c,scaleX:u,scaleY:f,opacity:_,transform:g,repeat:p}=r;u&&(h=zt(),Zt(h,g),Qt(h,1/u,1/f),n*=u,a*=f),n*=s,a*=s,l*=n,c*=a;const w=l*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&&(n/=d,a/=d,l/=d,c/=d),u&&(n/=u,a/=f),(g||1!==n||1!==a)&&(h||(h=zt(),g&&Zt(h,g)),Qt(h,1/n,1/a));const m=t.getCanvas(l<1?1:Kt(l),c<1?1:Kt(c),_),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",h,i);return i.style=v,i.patternId=o,!0}}const{abs:te}=Math;const ee={image:function(t,e,i,s,n){let a,o;const r=v.get(i);return Yt&&i===Yt.paint&&Ut(s,Yt.boxBounds)?a=Yt.leafPaint:(a={type:i.type},a.image=r,Yt=r.use>1?{leafPaint:a,paint:i,boxBounds:Ht.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Xt(t,e,i,r,a,s),n&&(Gt(t,o),Vt(t,o))):r.error?n&&jt(t,o,r.error):(n&&Gt(t,o),a.loadId=r.load((()=>{t.destroyed||(Xt(t,e,i,r,a,s)&&t.forceUpdate("surface"),Vt(t,o)),a.loadId=null}),(e=>{jt(t,o,e),a.loadId=null}))),a},createData:Nt,fillOrFitMode:It,clipMode:Ot,repeatMode:Pt,createPattern:Jt,checkImage:function(t,i,s,n){const{scaleX:a,scaleY:o}=t.__world;if(s.data&&s.patternId!==a+"-"+o){const{data:r}=s;if(n)if(r.repeat)n=!1;else{let{width:t,height:s}=r;t*=te(a)*i.pixelRatio,s*=te(o)*i.pixelRatio,r.scaleX&&(t*=r.scaleX,s*=r.scaleY),n=t*s>e.image.maxCacheSize}return n?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),r.opacity&&(i.opacity*=r.opacity),r.transform&&i.transform(r.transform),i.drawImage(s.image.view,0,0,r.width,r.height),i.restore(),!0):(!s.style||D.running?Jt(t,s,i.pixelRatio):s.patternTask||(s.patternTask=v.patternTasker.add((()=>X(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__world)&&Jt(t,s,i.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,o;for(let r=0,d=i.length;r<d;r++)s=i[r].image,o=s&&s.url,o&&(n||(n={}),n[o]=!0,v.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(i[r].loadId,!a.some((t=>t.url===o)))));return n}return null}},ie={x:.5,y:0},se={x:.5,y:1};function ne(t,e,i){let s;for(let n=0,a=e.length;n<a;n++)s=e[n],t.addColorStop(s.offset,P.string(s.color,i))}const{set:ae,getAngle:oe,getDistance:re}=L,{get:de,rotateOfOuter:he,scaleOfOuter:le}=k,ce={x:.5,y:.5},ue={x:.5,y:1},fe={},_e={};const{set:ge,getAngle:pe,getDistance:we}=L,{get:ye,rotateOfOuter:me,scaleOfOuter:ve}=k,xe={x:.5,y:.5},Be={x:.5,y:1},be={},Re={};const ke={linearGradient:function(t,i){let{from:s,to:n,type:a,blendMode:o,opacity:r}=t;s||(s=ie),n||(n=se);const d=e.canvas.createLinearGradient(i.x+s.x*i.width,i.y+s.y*i.height,i.x+n.x*i.width,i.y+n.y*i.height);ne(d,t.stops,r);const h={type:a,style:d};return o&&(h.blendMode=o),h},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;s||(s=ce),n||(n=ue);const{x:h,y:l,width:c,height:u}=i;let f;ae(fe,h+s.x*c,l+s.y*u),ae(_e,h+n.x*c,l+n.y*u),(c!==u||d)&&(f=de(),le(f,fe,c/u*(d||1),1),he(f,fe,oe(fe,_e)+90));const _=e.canvas.createRadialGradient(fe.x,fe.y,0,fe.x,fe.y,re(fe,_e));ne(_,t.stops,o);const g={type:a,style:_,transform:f};return r&&(g.blendMode=r),g},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;s||(s=xe),n||(n=Be);const{x:h,y:l,width:c,height:u}=i;ge(be,h+s.x*c,l+s.y*u),ge(Re,h+n.x*c,l+n.y*u);const f=ye(),_=pe(be,Re);e.conicGradientRotate90?(ve(f,be,c/u*(d||1),1),me(f,be,_+90)):(ve(f,be,1,c/u*(d||1)),me(f,be,_));const g=e.conicGradientSupport?e.canvas.createConicGradient(0,be.x,be.y):e.canvas.createRadialGradient(be.x,be.y,0,be.x,be.y,we(be,Re));ne(g,t.stops,o);const p={type:a,style:g,transform:f};return r&&(p.blendMode=r),p}},{copy:Ee,toOffsetOutBounds:Le}=b,Se={},Me={};function Ae(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(Ee(Se,t.bounds),Se.x+=i.x-o.x,Se.y+=i.y-o.y,s){const{matrix:t}=n;Se.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Se.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Se.width*=s,Se.height*=s}t.copyWorld(n.canvas,t.bounds,Se)}else s&&(Ee(Se,i),Se.x-=i.width/2*(s-1),Se.y-=i.height/2*(s-1),Se.width*=s,Se.height*=s),t.copyWorld(n.canvas,o,s?Se:i)}const{toOffsetOutBounds:Ce}=b,We={};const Te={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Le(h,Me),r.forEach(((r,g)=>{f.setWorldShadow(Me.offsetX+r.x*c,Me.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ae(f,Me,n,i),s=h,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,h,a,"copy"),s=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,l,h,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:h,shapeBounds:l,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),_=r.length-1;Ce(h,We),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(We.offsetX+r.x*c,We.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ae(f,We,n,i),f.restore(),d?(f.copyWorld(f,h,a,"copy"),f.copyWorld(d,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,l,h,"source-out"),s=h),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),_&&g<_&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ie}=g;function Oe(t,e,i,s,n,a){switch(e){case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Fe(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Fe(t,i,s,a);break;case"path":i.restore()}}function Pe(t){return t.getSameCanvas(!1,!0)}function Fe(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}N.prototype.__renderMask=function(t,e){let i,s,n,a,o;const{children:r}=this;for(let d=0,h=r.length;d<h;d++)i=r[d],i.__.mask&&(o&&(Oe(this,o,t,n,s,a),s=n=null),"path"===i.__.maskType?(i.opacity<1?(o="opacity-path",a=i.opacity,n||(n=Pe(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="alpha",s||(s=Pe(t)),n||(n=Pe(t)),i.__render(s,e)),"clipping"!==i.__.maskType)||Ie(i,e)||i.__render(n||t,e);Oe(this,o,t,n,s,a)};const De=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ne=De+"_#~&*+\\=|≮≯≈≠=…",Ye=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function He(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ue=He("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Xe=He("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ge=He(De),Ve=He(Ne),je=He("- —/~|┆·");var qe;!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"}(qe||(qe={}));const{Letter:ze,Single:Qe,Before:Ze,After:Ke,Symbol:$e,Break:Je}=qe;function ti(t){return Ue[t]?ze:je[t]?Je:Xe[t]?Ze:Ge[t]?Ke:Ve[t]?$e:Ye.test(t)?Qe:ze}const ei={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ii(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:si}=ei,{Letter:ni,Single:ai,Before:oi,After:ri,Symbol:di,Break:hi}=qe;let li,ci,ui,fi,_i,gi,pi,wi,yi,mi,vi,xi,Bi,bi,Ri,ki,Ei=[];function Li(t,e){yi&&!wi&&(wi=yi),li.data.push({char:t,width:e}),ui+=e}function Si(){fi+=ui,li.width=ui,ci.words.push(li),li={data:[]},ui=0}function Mi(){bi&&(Ri.paraNumber++,ci.paraStart=!0,bi=!1),yi&&(ci.startCharSize=wi,ci.endCharSize=yi,wi=0),ci.width=fi,ki.width&&si(ci),Ei.push(ci),ci={words:[]},fi=0}const Ai=0,Ci=1,Wi=2;const{top:Ti,right:Ii,bottom:Oi,left:Pi}=S;function Fi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Di={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:h}=i;h&&(a&&(s=h[Pi],a-=h[Ii]+h[Pi]),o&&(n=h[Ti],o-=h[Ti]+h[Oi]));const l={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,s){Ri=t,Ei=t.rows,ki=t.bounds;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:d,height:h}=ki;if(d||h||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;bi=!0,vi=null,wi=pi=yi=ui=fi=0,li={data:[]},ci={words:[]};for(let s=0,h=i.length;s<h;s++)gi=i[s],"\n"===gi?(ui&&Si(),ci.paraEnd=!0,Mi(),bi=!0):(mi=ti(gi),mi===ni&&"none"!==o&&(gi=ii(gi,o,!ui)),pi=r.measureText(gi).width,n&&(n<0&&(yi=pi),pi+=n),xi=mi===ai&&(vi===ai||vi===ni)||vi===ai&&mi!==ri,Bi=!(mi!==oi&&mi!==ai||vi!==di&&vi!==ri),_i=bi&&a?d-a:d,t&&d&&fi+ui+pi>_i&&(e?(ui&&Si(),Mi()):(Bi||(Bi=mi===ni&&vi==ri),xi||Bi||mi===hi||mi===oi||mi===ai||ui+pi>_i?(ui&&Si(),Mi()):Mi()))," "===gi&&!0!==bi&&fi+ui===0||(mi===hi?(" "===gi&&ui&&Si(),Li(gi,pi),Si()):xi||Bi?(ui&&Si(),Li(gi,pi)):Li(gi,pi)),vi=mi);ui&&Si(),fi&&Mi(),Ei.length>0&&(Ei[Ei.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ri.paraNumber++,Ei.push({x:a||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(l,t,i),h&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":Fi(e,"x",t[Pi]);break;case"right":Fi(e,"x",-t[Ii])}if(!n)switch(i.verticalAlign){case"top":Fi(e,"y",t[Ti]);break;case"bottom":Fi(e,"y",-t[Oi])}}(h,l,i,a,o),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:_,y:g,width:p,height:w}=s,y=n*i.length+(l?l*(t.paraNumber-1):0),m=a;if(r&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(h){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=_,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=n,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,o<0&&(c.width<0?(f=-c.width+e.fontSize+o,u-=f,f+=e.fontSize):f-=o),u<s.x&&(s.x=u),f>s.width&&(s.width=f),r&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(l,i),function(t,e,i,s){const{rows:n}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=o&&t.paraStart?o:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=r||t.isOverflow?Ai:h>.01?Ci:Wi,t.isOverflow&&!r&&(t.textMode=!0),c===Wi?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{c===Ci?(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)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,i,a),l.overflow&&function(t,i){const{rows:s,overflow:n}=t;let{textOverflow:a}=i;if(s.splice(n),"hide"!==a){let t,o;"ellipsis"===a&&(a="...");const r=e.canvas.measureText(a).width,d=i.x+i.width-r;("none"===i.textWrap?s:[s[n-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],o=t.x+t.width,!(s===i&&o<d));s--){if(o<d&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:a,x:o}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(l,i),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,i),l}};const Ni={string:function(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},{setPoint:Yi,addPoint:Hi,toBounds:Ui}=M;const Xi={export(t,e,i){return this.running=!0,function(t){Gi||(Gi=new A);return new Promise((e=>{Gi.add((()=>X(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((o=>{const r=t=>{n(t),o(),this.running=!1},{leafer:d}=t;d?d.waitViewCompleted((()=>X(this,void 0,void 0,(function*(){let n,o,h=1,l=1;i=a.getExportOptions(i);const{scale:c,slice:u,trim:f}=i,g=i.pixelRatio||1,p=i.screenshot||t.isApp,w=void 0===i.fill?t.isLeafer&&p?t.fill:"":i.fill,y=a.isOpaqueImage(e)||w,m=new C;if(p)n=!0===p?t.isLeafer?d.canvas.bounds:t.worldRenderBounds:p;else{const{localTransform:e,__world:i}=t;m.set(i).divide(e).invert(),h=1/(i.scaleX/t.scaleX),l=1/(i.scaleY/t.scaleY),n=t.getBounds("render","local")}let{x:v,y:x,width:B,height:b}=n;c&&(m.scale(c),B*=c,b*=c,h*=c,l*=c);let R=s.canvas({width:Math.ceil(B),height:Math.ceil(b),pixelRatio:g});const k={matrix:m.translate(-v,-x).withScale(h,l)};if(u&&(t=d,k.bounds=R.bounds),R.save(),t.__render(R,k),R.restore(),f){o=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,a,o,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,a=(r-n)/e,o?Hi(o,n,a):Yi(o={},n,a)),r++;const d=new _;return Ui(o,d),d.scale(1/t.pixelRatio).ceil()}(R);const t=R,{width:e,height:i}=o,n={x:0,y:0,width:e,height:i,pixelRatio:g};R=s.canvas(n),R.copyWorld(t,o,n)}y&&R.fillWorld(R.bounds,w||"#FFFFFF","destination-over");const E="canvas"===e?R:yield R.export(e,i);r({data:E,width:R.pixelWidth,height:R.pixelHeight,renderBounds:n,trimBounds:o})})))):r({data:!1})}))))}};let Gi;Object.assign(Y,Di),Object.assign(P,Ni),Object.assign(H,Et),Object.assign(O,ee),Object.assign(F,ke),Object.assign(U,Te),Object.assign(D,Xi),Object.assign(s,{interaction:(t,e,i,s)=>new T(t,e,i,s),hitCanvas:(t,e)=>new G(t,e),hitCanvasManager:()=>new I});export{ot as Layouter,G as LeaferCanvas,dt as Renderer,_t as Selector,z as Watcher,q 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 s(t,e,n,i){return new(n||(n=Promise))((function(s,a){function r(t){try{d(i.next(t))}catch(t){a(t)}}function o(t){try{d(i.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a 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:r,fileType:o}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new a(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0;class d{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:l,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:y,updateAllChange:w}=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:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,d=this.getBlocks(s);d.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,d,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(l(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)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||h(i[t])}h(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(s),this.extraBlock&&d.push(this.extraBlock),d.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,d,this.times)),i.emitEvent(new t.LayoutEvent(o,d,this.times)),this.addBlocks(d),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),v.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,r,this.times)),n.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){y(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new _([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}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(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){return this.rendering?x.warn("rendering"):this.times>3?x.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e?(this.emitRender(t.RenderEvent.BEFORE),e()):(this.requestLayout(),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,void(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,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),r=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,r),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal&&(e.bigger||!e.samePixelRatio)){const{width:n,height:i}=e.old;new t.Bounds(0,0,n,i).includes(this.target.__world)&&!this.needFill&&e.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:b}=t.BoundsHelper;class E{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,n){e||(e=0),n||(n={});const i=n.through||!1,s=n.ignoreHittable||!1,a=n.target||this.target;this.exclude=n.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=n.findList||[],n.findList||this.eachFind(a.children,a.__onlyHitMask);const r=this.findList,o=this.getBestMatchLeaf(),d=s?this.getPath(o):this.getHitablePath(o);return this.clear(),i?{path:d,target:o,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:o}}getBestMatchLeaf(){const{findList:e}=this;if(e.length>1){let n;this.findList=[];const{x:i,y:s}=this.point,a={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=e.length;i<s;i++)if(n=e[i],t.LeafHelper.worldHittable(n)&&(this.hitChild(n,a),this.findList.length))return this.findList[0]}return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return n.add(this.target),n}getHitablePath(e){const n=this.getPath(e);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,r;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!a||!a.has(r));t++)n.add(r)}return n}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&!this.findList.length&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:L,NoAndSkip:R,YesAndSkip:k}=t.Answer;class C{constructor(e,n){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new E(e,this),this.__listenEvents()}getBy(t,e,n,i){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return n?s:s?[s]:[];case"string":switch(t[0]){case"#":const i=this.getById(t.substring(1),e);return n?i:i?[i]:[];case".":return this.getByMethod(this.methods.className,e,n,t.substring(1));default:return this.getByMethod(this.methods.tag,e,n,t)}case"function":return this.getByMethod(t,e,n,i)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let r=0,o=t.length;r<o;r++){if(s=t[r],a=e(s,i),a===L||a===k){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<R&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(t.Creator,{watcher:(t,e)=>new d(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new B(t,e,n),selector:(t,e)=>new C(t,e)}),t.Platform.layout=v.fullLayout;const M={},P={};function S(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function A(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?W(t,!0,e,n):O(e,n);break;case"inside":I("inside",t,s,e,n);break;case"outside":I("outside",t,s,e,n)}}function I(t,e,n,i,s){const{__strokeWidth:a,__font:r}=i.__,o=s.getSameCanvas(!0,!0);o.setStroke(n?void 0:e,2*a,i.__),o.font=r,n?W(e,!0,i,o):O(i,o),o.blendMode="outside"===t?"destination-out":"destination-in",S(i,o),o.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(o,i.__nowWorld):s.copyWorldToInner(o,i.__nowWorld,i.__layout.renderBounds),o.recycle(i.__nowWorld)}function O(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function W(t,e,n,i){let s;for(let a=0,r=t.length;a<r;a++)s=t[a],s.image&&M.checkImage(n,i,s,!1)||s.style&&(i.strokeStyle=s.style,s.blendMode?(i.saveBlendMode(s.blendMode),e?O(n,i):i.stroke(),i.restoreBlendMode()):e?O(n,i):i.stroke())}const{getSpread:T,getOuterOf:D,getByMove:H,getIntersectData:F}=t.BoundsHelper;let N;function Y(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:a,blendMode:r,color:o,opacity:d}=e;return{type:a,blendMode:r,style:i.ColorConvert.string(o,d)};case"image":return M.image(n,t,e,s,!N||!N[e.url]);case"linear":return P.linearGradient(e,s);case"radial":return P.radialGradient(e,s);case"angular":return P.conicGradient(e,s);default:return e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const j={compute:function(t,e){const n=e.__,i=[];let s,a=n.__input[t];a instanceof Array||(a=[a]),N=M.recycleImage(t,n);for(let n,s=0,r=a.length;s<r;s++)n=Y(t,a[s],e),n&&i.push(n);n["_"+t]=i.length?i:void 0,i.length&&i[0].image&&(s=i[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?S(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let i;const{windingRule:s,__font:a}=e.__;for(let r=0,o=t.length;r<o;r++)i=t[r],i.image&&M.checkImage(e,n,i,!a)||i.style&&(n.fillStyle=i.style,i.transform?(n.save(),n.transform(i.transform),i.blendMode&&(n.blendMode=i.blendMode),a?S(e,n):s?n.fill(s):n.fill(),n.restore()):i.blendMode?(n.saveBlendMode(i.blendMode),a?S(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):a?S(e,n):s?n.fill(s):n.fill())},fillText:S,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)A(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)A(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),W(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),W(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,i),W(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,a),r.recycle(e.__nowWorld)}},strokeText:A,drawTextStroke:O,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,r,o,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,a=o=s;else{const{renderShapeSpread:i}=t.__layout,c=F(i?T(e.bounds,i*l,i*h):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),o=D(s,r),a=H(o,-r.e,-r.f),n.matrix){const{matrix:t}=n;r.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:r.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:r,bounds:a,worldCanvas:d,shapeBounds:o,scaleX:l,scaleY:h}}};let G={};const{get:U,rotateOfOuter:X,translate:q,scaleOfOuter:V,scale:z,rotate:Q}=t.MatrixHelper;function Z(t,e,n,i,s,a){const r=U(),o=a&&180!==a,d=n.width/(o?s:i),l=n.height/(o?i:s),h="fit"===e?Math.min(d,l):Math.max(d,l),c=n.x+(n.width-i*h)/2,u=n.y+(n.height-s*h)/2;q(r,c,u),z(r,h),a&&X(r,{x:n.x+n.width/2,y:n.y+n.height/2},a),t.scaleX=t.scaleY=h,t.transform=r}function K(t,e,n,i,s,a,r){const o=U();q(o,e.x,e.y),(n||i)&&q(o,n,i),s&&(z(o,s,a),t.scaleX=o.a,t.scaleY=o.d),r&&Q(o,r),t.transform=o}function $(t,e,n,i,s,a,r,o,d){const l=U();if(d)switch(Q(l,d),d){case 90:q(l,i,0);break;case 180:q(l,n,i);break;case 270:q(l,0,n)}G.x=e.x,G.y=e.y,(s||a)&&(G.x+=s,G.y+=a),q(l,G.x,G.y),r&&(V(l,G,r,o),t.scaleX=r,t.scaleY=o),t.transform=l}const{get:J,translate:tt}=t.MatrixHelper;function et(t,e,n,i){let{width:s,height:a}=e;const{opacity:r,mode:o,offset:d,scale:l,size:h,rotation:c,blendMode:u,repeat:f}=n,p=i.width===s&&i.height===a;u&&(t.blendMode=u);const g=t.data={mode:o};let _,y,w,m;switch(d&&(_=d.x,y=d.y),h?(w=("number"==typeof h?h:h.width)/s,m=("number"==typeof h?h:h.height)/a):l&&(w="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),o){case"strench":p||(s=i.width,a=i.height),(i.x||i.y)&&(g.transform=J(),tt(g.transform,i.x,i.y));break;case"clip":(d||w||c)&&K(g,i,_,y,w,m,c);break;case"repeat":(!p||w||c)&&$(g,i,s,a,_,y,w,m,c),f||(g.repeat="repeat");break;default:p&&!c||Z(g,o,i,s,a,c)}g.width=s,g.height=a,r&&(g.opacity=r),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let nt,it=new t.Bounds;const{isSame:st}=t.BoundsHelper;function at(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,e.__autoWidth||e.__autoHeight)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||et(s,i,n,a),!0}function rt(e,n){lt(e,t.ImageEvent.LOAD,n)}function ot(e,n){lt(e,t.ImageEvent.LOADED,n)}function dt(e,n,i){n.error=i,e.forceUpdate("surface"),lt(e,t.ImageEvent.ERROR,n)}function lt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}const{get:ht,scale:ct,copy:ut}=t.MatrixHelper,{round:ft,abs:pt}=Math;function gt(e,n,i){let{scaleX:s,scaleY:a}=e.__world;const r=s+"-"+a;if(n.patternId===r||e.destroyed)return!1;{s=pt(s),a=pt(a);const{image:e,data:o}=n;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=o;u&&(l=ht(),ut(l,g),ct(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const y=h*c;if(!_&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(g||1!==s||1!==a)&&(l||(l=ht(),g&&ut(l,g)),ct(l,1/s,1/a));const m=e.getCanvas(h<1?1:ft(h),c<1?1:ft(c),p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=r,!0}}const{abs:_t}=Math;const yt={image:function(e,n,i,s,a){let r,o;const d=t.ImageManager.get(i);return nt&&i===nt.paint&&st(s,nt.boxBounds)?r=nt.leafPaint:(r={type:i.type},r.image=d,nt=d.use>1?{leafPaint:r,paint:i,boxBounds:it.set(s)}:null),(a||d.loading)&&(o={image:d,attrName:n,attrValue:i}),d.ready?(at(e,n,i,d,r,s),a&&(rt(e,o),ot(e,o))):d.error?a&&dt(e,o,d.error):(a&&rt(e,o),r.loadId=d.load((()=>{e.destroyed||(at(e,n,i,d,r,s)&&e.forceUpdate("surface"),ot(e,o)),r.loadId=null}),(t=>{dt(e,o,t),r.loadId=null}))),r},createData:et,fillOrFitMode:Z,clipMode:K,repeatMode:$,createPattern:gt,checkImage:function(e,n,a,r){const{scaleX:o,scaleY:d}=e.__world;if(a.data&&a.patternId!==o+"-"+d){const{data:l}=a;if(r)if(l.repeat)r=!1;else{let{width:e,height:i}=l;e*=_t(o)*n.pixelRatio,i*=_t(d)*n.pixelRatio,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),r=e*i>t.Platform.image.maxCacheSize}return r?(n.save(),n.clip(),a.blendMode&&(n.blendMode=a.blendMode),l.opacity&&(n.opacity*=l.opacity),l.transform&&n.transform(l.transform),n.drawImage(a.image.view,0,0,l.width,l.height),n.restore(),!0):(!a.style||i.Export.running?gt(e,a,n.pixelRatio):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>s(this,void 0,void 0,(function*(){a.patternTask=null,n.bounds.hit(e.__world)&>(e,a,n.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,r,o;for(let d=0,l=i.length;d<l;d++)s=i[d].image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,t.ImageManager.recycle(s),s.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===o)))));return a}return null}},wt={x:.5,y:0},mt={x:.5,y:1};function vt(t,e,n){let s;for(let a=0,r=e.length;a<r;a++)s=e[a],t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}const{set:xt,getAngle:Bt,getDistance:bt}=t.PointHelper,{get:Et,rotateOfOuter:Lt,scaleOfOuter:Rt}=t.MatrixHelper,kt={x:.5,y:.5},Ct={x:.5,y:1},Mt={},Pt={};const{set:St,getAngle:At,getDistance:It}=t.PointHelper,{get:Ot,rotateOfOuter:Wt,scaleOfOuter:Tt}=t.MatrixHelper,Dt={x:.5,y:.5},Ht={x:.5,y:1},Ft={},Nt={};const Yt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:r,opacity:o}=e;i||(i=wt),s||(s=mt);const d=t.Platform.canvas.createLinearGradient(n.x+i.x*n.width,n.y+i.y*n.height,n.x+s.x*n.width,n.y+s.y*n.height);vt(d,e.stops,o);const l={type:a,style:d};return r&&(l.blendMode=r),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;i||(i=kt),s||(s=Ct);const{x:l,y:h,width:c,height:u}=n;let f;xt(Mt,l+i.x*c,h+i.y*u),xt(Pt,l+s.x*c,h+s.y*u),(c!==u||d)&&(f=Et(),Rt(f,Mt,c/u*(d||1),1),Lt(f,Mt,Bt(Mt,Pt)+90));const p=t.Platform.canvas.createRadialGradient(Mt.x,Mt.y,0,Mt.x,Mt.y,bt(Mt,Pt));vt(p,e.stops,r);const g={type:a,style:p,transform:f};return o&&(g.blendMode=o),g},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;i||(i=Dt),s||(s=Ht);const{x:l,y:h,width:c,height:u}=n;St(Ft,l+i.x*c,h+i.y*u),St(Nt,l+s.x*c,h+s.y*u);const f=Ot(),p=At(Ft,Nt);t.Platform.conicGradientRotate90?(Tt(f,Ft,c/u*(d||1),1),Wt(f,Ft,p+90)):(Tt(f,Ft,1,c/u*(d||1)),Wt(f,Ft,p));const g=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ft.x,Ft.y):t.Platform.canvas.createRadialGradient(Ft.x,Ft.y,0,Ft.x,Ft.y,It(Ft,Nt));vt(g,e.stops,r);const _={type:a,style:g,transform:f};return o&&(_.blendMode=o),_}},{copy:jt,toOffsetOutBounds:Gt}=t.BoundsHelper,Ut={},Xt={};function qt(e,n,i,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(jt(Ut,e.bounds),Ut.x+=n.x-r.x,Ut.y+=n.y-r.y,i){const{matrix:t}=s;Ut.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Ut.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Ut.width*=i,Ut.height*=i}e.copyWorld(s.canvas,e.bounds,Ut)}else i&&(jt(Ut,n),Ut.x-=n.width/2*(i-1),Ut.y-=n.height/2*(i-1),Ut.width*=i,Ut.height*=i),e.copyWorld(s.canvas,r,i?Ut:n)}const{toOffsetOutBounds:Vt}=t.BoundsHelper,zt={};const Qt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),p=o.length-1;Gt(l,Xt),o.forEach(((o,g)=>{f.setWorldShadow(Xt.offsetX+o.x*c,Xt.offsetY+o.y*u,o.blur*c,o.color),s=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,qt(f,Xt,s,n),i=l,o.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),p=o.length-1;Vt(l,zt),o.forEach(((o,g)=>{f.save(),f.setWorldShadow(zt.offsetX+o.x*c,zt.offsetY+o.y*u,o.blur*c),s=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,qt(f,zt,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,l,"source-out"),i=l),f.fillWorld(i,o.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__world.a),n.copyWorldToInner(e,t.__world,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Zt}=t.LeafBoundsHelper;function Kt(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Jt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Jt(t,n,i,a);break;case"path":n.restore()}}function $t(t){return t.getSameCanvas(!1,!0)}function Jt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let n,i,s,a,r;const{children:o}=this;for(let d=0,l=o.length;d<l;d++)n=o[d],n.__.mask&&(r&&(Kt(this,r,t,s,i,a),i=s=null),"path"===n.__.maskType?(n.opacity<1?(r="opacity-path",a=n.opacity,s||(s=$t(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="alpha",i||(i=$t(t)),s||(s=$t(t)),n.__render(i,e)),"clipping"!==n.__.maskType)||Zt(n,e)||n.__render(s||t,e);Kt(this,r,t,s,i,a)};const te=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ee=te+"_#~&*+\\=|≮≯≈≠=…",ne=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ie(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const se=ie("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ae=ie("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),re=ie(te),oe=ie(ee),de=ie("- —/~|┆·");var le;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(le||(le={}));const{Letter:he,Single:ce,Before:ue,After:fe,Symbol:pe,Break:ge}=le;function _e(t){return se[t]?he:de[t]?ge:ae[t]?ue:re[t]?fe:oe[t]?pe:ne.test(t)?ce:he}const ye={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function we(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:me}=ye,{Letter:ve,Single:xe,Before:Be,After:be,Symbol:Ee,Break:Le}=le;let Re,ke,Ce,Me,Pe,Se,Ae,Ie,Oe,We,Te,De,He,Fe,Ne,Ye,je=[];function Ge(t,e){Oe&&!Ie&&(Ie=Oe),Re.data.push({char:t,width:e}),Ce+=e}function Ue(){Me+=Ce,Re.width=Ce,ke.words.push(Re),Re={data:[]},Ce=0}function Xe(){Fe&&(Ne.paraNumber++,ke.paraStart=!0,Fe=!1),Oe&&(ke.startCharSize=Ie,ke.endCharSize=Oe,Ie=0),ke.width=Me,Ye.width&&me(ke),je.push(ke),ke={words:[]},Me=0}const qe=0,Ve=1,ze=2;const{top:Qe,right:Ze,bottom:Ke,left:$e}=t.Direction4;function Je(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const tn={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:o,__font:d,__padding:l}=n;l&&(a&&(i=l[$e],a-=l[Ze]+l[$e]),r&&(s=l[Qe],r-=l[Qe]+l[Ke]));const h={bounds:{x:i,y:s,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){Ne=e,je=e.rows,Ye=e.bounds;const{__letterSpacing:s,paraIndent:a,textCase:r}=i,{canvas:o}=t.Platform,{width:d,height:l}=Ye;if(d||l||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;Fe=!0,Te=null,Ie=Ae=Oe=Ce=Me=0,Re={data:[]},ke={words:[]};for(let i=0,l=n.length;i<l;i++)Se=n[i],"\n"===Se?(Ce&&Ue(),ke.paraEnd=!0,Xe(),Fe=!0):(We=_e(Se),We===ve&&"none"!==r&&(Se=we(Se,r,!Ce)),Ae=o.measureText(Se).width,s&&(s<0&&(Oe=Ae),Ae+=s),De=We===xe&&(Te===xe||Te===ve)||Te===xe&&We!==be,He=!(We!==Be&&We!==xe||Te!==Ee&&Te!==be),Pe=Fe&&a?d-a:d,t&&d&&Me+Ce+Ae>Pe&&(e?(Ce&&Ue(),Xe()):(He||(He=We===ve&&Te==be),De||He||We===Le||We===Be||We===xe||Ce+Ae>Pe?(Ce&&Ue(),Xe()):Xe()))," "===Se&&!0!==Fe&&Me+Ce===0||(We===Le?(" "===Se&&Ce&&Ue(),Ge(Se,Ae),Ue()):De||He?(Ce&&Ue(),Ge(Se,Ae)):Ge(Se,Ae)),Te=We);Ce&&Ue(),Me&&Xe(),je.length>0&&(je[je.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ne.paraNumber++,je.push({x:a||0,text:t,width:o.measureText(t).width,paraStart:!0})}))}(h,e,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":Je(e,"x",t[$e]);break;case"right":Je(e,"x",-t[Ze])}if(!s)switch(n.verticalAlign){case"top":Je(e,"y",t[Qe]);break;case"bottom":Je(e,"y",-t[Ke])}}(l,h,n,a,r),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:l,paraSpacing:h}=e;let c,u,f,{x:p,y:g,width:_,height:y}=i,w=s*n.length+(h?h*(t.paraNumber-1):0),m=a;if(o&&w>y)w=Math.max(y,s),t.overflow=n.length;else switch(l){case"middle":g+=(y-w)/2;break;case"bottom":g+=y-w}m+=g;for(let a=0,l=n.length;a<l;a++){switch(c=n[a],c.x=p,d){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&h&&a>0&&(m+=h),c.y=m,m+=s,t.overflow>a&&m>w&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,r<0&&(c.width<0?(f=-c.width+e.fontSize+r,u-=f,f+=e.fontSize):f-=r),u<i.x&&(i.x=u),f>i.width&&(i.width=f),o&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=g,i.height=w}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:r,letterSpacing:o}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=r&&t.paraStart?r:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?qe:l>.01?Ve:ze,t.isOverflow&&!o&&(t.textMode=!0),c===ze?(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===Ve?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,n){return t.forEach((t=>{" "!==t.char&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,n,a),h.overflow&&function(e,n){const{rows:i,overflow:s}=e;let{textOverflow:a}=n;if(i.splice(s),"hide"!==a){let e,r;"ellipsis"===a&&(a="...");const o=t.Platform.canvas.measureText(a).width,d=n.x+n.width-o;("none"===n.textWrap?i:[i[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],r=e.x+e.width,!(i===n&&r<d));i--){if(r<d&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=o,t.data.push({char:a,x:r}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n),"none"!==o&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const en={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:nn,addPoint:sn,toBounds:an}=t.TwoPointBoundsHelper;const rn={export(e,n,i){return this.running=!0,function(e){on||(on=new t.TaskProcessor);return new Promise((t=>{on.add((()=>s(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const o=t=>{a(t),r(),this.running=!1},{leafer:d}=e;d?d.waitViewCompleted((()=>s(this,void 0,void 0,(function*(){let s,a,r=1,l=1;i=t.FileHelper.getExportOptions(i);const{scale:h,pixelRatio:c,slice:u,trim:f}=i,p=i.screenshot||e.isApp,g=void 0===i.fill?e.isLeafer&&p?e.fill:"":i.fill,_=t.FileHelper.isOpaqueImage(n)||g,y=new t.Matrix;if(p)s=!0===p?e.isLeafer?d.canvas.bounds:e.worldRenderBounds:p;else{const{localTransform:t,__world:n}=e;y.set(n).divide(t).invert(),r=1/(n.scaleX/e.scaleX),l=1/(n.scaleY/e.scaleY),s=e.getBounds("render","local")}let{x:w,y:m,width:v,height:x}=s;h&&(y.scale(h),v*=h,x*=h,r*=h,l*=h);let B=t.Creator.canvas({width:v,height:x,pixelRatio:c});const b={matrix:y.translate(-w,-m).withScale(r,l)};if(u&&(e=d,b.bounds=B.bounds),B.save(),e.__render(B,b),B.restore(),f){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,r,o,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,r=(d-a)/n,o?sn(o,a,r):nn(o={},a,r)),d++;const l=new t.Bounds;return an(o,l),l.scale(1/e.pixelRatio).ceil()}(B);const e=B,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:c};B=t.Creator.canvas(s),B.copyWorld(e,a,s)}_&&B.fillWorld(B.bounds,g||"#FFFFFF","destination-over");const E="canvas"===n?B:yield B.export(n,i);o({data:E,renderBounds:s,trimBounds:a})})))):o({data:!1})}))))}};let on;Object.assign(i.TextConvert,tn),Object.assign(i.ColorConvert,en),Object.assign(i.Paint,j),Object.assign(i.PaintImage,yt),Object.assign(i.PaintGradient,Yt),Object.assign(i.Effect,Qt),Object.assign(i.Export,rn),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new n.InteractionBase(t,e,i,s),hitCanvas:(t,e)=>new a(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=a,exports.Renderer=B,exports.Selector=C,exports.Watcher=d,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}),loadImage:n},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:a}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(r(e),n),canvasToBolb:(t,e,n)=>s(this,void 0,void 0,(function*(){return t.toBuffer(r(e),n)})),canvasSaveAs:(t,n,i)=>s(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(r(o(n)),i))})),loadImage:a}}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 s(t,e,n,i){return new(n||(n=Promise))((function(s,a){function r(t){try{d(i.next(t))}catch(t){a(t)}}function o(t){try{d(i.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,o)}d((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a 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:r,fileType:o}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new a(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t)},t.Platform.devicePixelRatio=1,t.Platform.conicGradientSupport=!0;class d{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:l,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:y,updateAllChange:w}=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:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,d=this.getBlocks(s);d.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,d,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(l(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)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||h(i[t])}h(n)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&c(t),t.__updateChange()}))}(s),this.extraBlock&&d.push(this.extraBlock),d.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(r,d,this.times)),i.emitEvent(new t.LayoutEvent(o,d,this.times)),this.addBlocks(d),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,r,this.times)),v.fullLayout(n),r.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,r,this.times)),n.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){y(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),w(e)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new _([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}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(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){return this.rendering?x.warn("rendering"):this.times>3?x.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e?(this.emitRender(t.RenderEvent.BEFORE),e()):(this.requestLayout(),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,void(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,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),r=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,r),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.target.emit(t.AnimateEvent.FRAME),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal&&(e.bigger||!e.samePixelRatio)){const{width:n,height:i}=e.old;new t.Bounds(0,0,n,i).includes(this.target.__world)&&!this.needFill&&e.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("surface"))}}__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=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:b}=t.BoundsHelper;class E{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,n){e||(e=0),n||(n={});const i=n.through||!1,s=n.ignoreHittable||!1,a=n.target||this.target;this.exclude=n.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=n.findList||[],n.findList||this.eachFind(a.children,a.__onlyHitMask);const r=this.findList,o=this.getBestMatchLeaf(),d=s?this.getPath(o):this.getHitablePath(o);return this.clear(),i?{path:d,target:o,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:o}}getBestMatchLeaf(){const{findList:e}=this;if(e.length>1){let n;this.findList=[];const{x:i,y:s}=this.point,a={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=e.length;i<s;i++)if(n=e[i],t.LeafHelper.worldHittable(n)&&(this.hitChild(n,a),this.findList.length))return this.findList[0]}return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return n.add(this.target),n}getHitablePath(e){const n=this.getPath(e);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,r;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(r=s.list[t],!a||!a.has(r));t++)n.add(r)}return n}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&!this.findList.length&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:L,NoAndSkip:R,YesAndSkip:k}=t.Answer;class P{constructor(e,n){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new E(e,this),this.__listenEvents()}getBy(t,e,n,i){switch(typeof t){case"number":const s=this.getByInnerId(t,e);return n?s:s?[s]:[];case"string":switch(t[0]){case"#":const i=this.getById(t.substring(1),e);return n?i:i?[i]:[];case".":return this.getByMethod(this.methods.className,e,n,t.substring(1));default:return this.getByMethod(this.methods.tag,e,n,t)}case"function":return this.getByMethod(t,e,n,i)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let r=0,o=t.length;r<o;r++){if(s=t[r],a=e(s,i),a===L||a===k){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<R&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function M(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function C(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?A(t,!0,e,n):I(e,n);break;case"inside":S("inside",t,s,e,n);break;case"outside":S("outside",t,s,e,n)}}function S(t,e,n,i,s){const{__strokeWidth:a,__font:r}=i.__,o=s.getSameCanvas(!0,!0);o.setStroke(n?void 0:e,2*a,i.__),o.font=r,n?A(e,!0,i,o):I(i,o),o.blendMode="outside"===t?"destination-out":"destination-in",M(i,o),o.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(o,i.__nowWorld):s.copyWorldToInner(o,i.__nowWorld,i.__layout.renderBounds),o.recycle(i.__nowWorld)}function I(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=i.length;t<r;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function A(t,e,n,s){let a;for(let r=0,o=t.length;r<o;r++)a=t[r],a.image&&i.PaintImage.checkImage(n,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?I(n,s):s.stroke(),s.restoreBlendMode()):e?I(n,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new d(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new B(t,e,n),selector:(t,e)=>new P(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:O,getOuterOf:W,getByMove:T,getIntersectData:D}=t.BoundsHelper;let H;function F(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:a,blendMode:r,color:o,opacity:d}=e;return{type:a,blendMode:r,style:i.ColorConvert.string(o,d)};case"image":return i.PaintImage.image(n,t,e,s,!H||!H[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const N={compute:function(t,e){const n=e.__,s=[];let a,r=n.__input[t];r instanceof Array||(r=[r]),H=i.PaintImage.recycleImage(t,n);for(let n,i=0,a=r.length;i<a;i++)n=F(t,r[i],e),n&&s.push(n);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=a:n.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?M(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let s;const{windingRule:a,__font:r}=e.__;for(let o=0,d=t.length;o<d;o++)s=t[o],s.image&&i.PaintImage.checkImage(e,n,s,!r)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),r?M(e,n):a?n.fill(a):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),r?M(e,n):a?n.fill(a):n.fill(),n.restoreBlendMode()):r?M(e,n):a?n.fill(a):n.fill())},fillText:M,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)C(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:r}=i;if(s)if(r)C(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),A(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),A(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,r=n.getSameCanvas(!0,!0);e.__drawRenderPath(r),r.setStroke(void 0,2*s,i),A(t,!1,e,r),i.windingRule?r.clip(i.windingRule):r.clip(),r.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(r,e.__nowWorld):n.copyWorldToInner(r,e.__nowWorld,a),r.recycle(e.__nowWorld)}},strokeText:C,drawTextStroke:I,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,r,o,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=i,a=o=s;else{const{renderShapeSpread:i}=t.__layout,c=D(i?O(e.bounds,i*l,i*h):e.bounds,s);r=e.bounds.getFitMatrix(c);let{a:u,d:f}=r;if(r.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,n),l*=u,h*=f),o=W(s,r),a=T(o,-r.e,-r.f),n.matrix){const{matrix:t}=n;r.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:r.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:r,bounds:a,worldCanvas:d,shapeBounds:o,scaleX:l,scaleY:h}}};let Y={};const{get:G,rotateOfOuter:j,translate:U,scaleOfOuter:X,scale:q,rotate:V}=t.MatrixHelper;function z(t,e,n,i,s,a){const r=G(),o=a&&180!==a,d=n.width/(o?s:i),l=n.height/(o?i:s),h="fit"===e?Math.min(d,l):Math.max(d,l),c=n.x+(n.width-i*h)/2,u=n.y+(n.height-s*h)/2;U(r,c,u),q(r,h),a&&j(r,{x:n.x+n.width/2,y:n.y+n.height/2},a),t.scaleX=t.scaleY=h,t.transform=r}function Q(t,e,n,i,s,a,r){const o=G();U(o,e.x,e.y),(n||i)&&U(o,n,i),s&&(q(o,s,a),t.scaleX=o.a,t.scaleY=o.d),r&&V(o,r),t.transform=o}function Z(t,e,n,i,s,a,r,o,d){const l=G();if(d)switch(V(l,d),d){case 90:U(l,i,0);break;case 180:U(l,n,i);break;case 270:U(l,0,n)}Y.x=e.x,Y.y=e.y,(s||a)&&(Y.x+=s,Y.y+=a),U(l,Y.x,Y.y),r&&(X(l,Y,r,o),t.scaleX=r,t.scaleY=o),t.transform=l}const{get:K,translate:$}=t.MatrixHelper;function J(t,e,n,i){let{width:s,height:a}=e;const{opacity:r,mode:o,offset:d,scale:l,size:h,rotation:c,blendMode:u,repeat:f}=n,p=i.width===s&&i.height===a;u&&(t.blendMode=u);const g=t.data={mode:o};let _,y,w,m;switch(d&&(_=d.x,y=d.y),h?(w=("number"==typeof h?h:h.width)/s,m=("number"==typeof h?h:h.height)/a):l&&(w="number"==typeof l?l:l.x,m="number"==typeof l?l:l.y),o){case"strench":p||(s=i.width,a=i.height),(i.x||i.y)&&(g.transform=K(),$(g.transform,i.x,i.y));break;case"clip":(d||w||c)&&Q(g,i,_,y,w,m,c);break;case"repeat":(!p||w||c)&&Z(g,i,s,a,_,y,w,m,c),f||(g.repeat="repeat");break;default:p&&!c||z(g,o,i,s,a,c)}g.width=s,g.height=a,r&&(g.opacity=r),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}let tt,et=new t.Bounds;const{isSame:nt}=t.BoundsHelper;function it(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,e.__autoWidth||e.__autoHeight)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||J(s,i,n,a),!0}function st(e,n){ot(e,t.ImageEvent.LOAD,n)}function at(e,n){ot(e,t.ImageEvent.LOADED,n)}function rt(e,n,i){n.error=i,e.forceUpdate("surface"),ot(e,t.ImageEvent.ERROR,n)}function ot(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}const{get:dt,scale:lt,copy:ht}=t.MatrixHelper,{round:ct,abs:ut}=Math;function ft(e,n,i){let{scaleX:s,scaleY:a}=e.__world;const r=s+"-"+a;if(n.patternId===r||e.destroyed)return!1;{s=ut(s),a=ut(a);const{image:e,data:o}=n;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=o;u&&(l=dt(),ht(l,g),lt(l,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const y=h*c;if(!_&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(g||1!==s||1!==a)&&(l||(l=dt(),g&&ht(l,g)),lt(l,1/s,1/a));const m=e.getCanvas(h<1?1:ct(h),c<1?1:ct(c),p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",l,n);return n.style=v,n.patternId=r,!0}}const{abs:pt}=Math;const gt={image:function(e,n,i,s,a){let r,o;const d=t.ImageManager.get(i);return tt&&i===tt.paint&&nt(s,tt.boxBounds)?r=tt.leafPaint:(r={type:i.type},r.image=d,tt=d.use>1?{leafPaint:r,paint:i,boxBounds:et.set(s)}:null),(a||d.loading)&&(o={image:d,attrName:n,attrValue:i}),d.ready?(it(e,n,i,d,r,s),a&&(st(e,o),at(e,o))):d.error?a&&rt(e,o,d.error):(a&&st(e,o),r.loadId=d.load((()=>{e.destroyed||(it(e,n,i,d,r,s)&&e.forceUpdate("surface"),at(e,o)),r.loadId=null}),(t=>{rt(e,o,t),r.loadId=null}))),r},createData:J,fillOrFitMode:z,clipMode:Q,repeatMode:Z,createPattern:ft,checkImage:function(e,n,a,r){const{scaleX:o,scaleY:d}=e.__world;if(a.data&&a.patternId!==o+"-"+d){const{data:l}=a;if(r)if(l.repeat)r=!1;else{let{width:e,height:i}=l;e*=pt(o)*n.pixelRatio,i*=pt(d)*n.pixelRatio,l.scaleX&&(e*=l.scaleX,i*=l.scaleY),r=e*i>t.Platform.image.maxCacheSize}return r?(n.save(),n.clip(),a.blendMode&&(n.blendMode=a.blendMode),l.opacity&&(n.opacity*=l.opacity),l.transform&&n.transform(l.transform),n.drawImage(a.image.view,0,0,l.width,l.height),n.restore(),!0):(!a.style||i.Export.running?ft(e,a,n.pixelRatio):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>s(this,void 0,void 0,(function*(){a.patternTask=null,n.bounds.hit(e.__world)&&ft(e,a,n.pixelRatio),e.forceUpdate("surface")}))),300)),!1)}return!1},recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,r,o;for(let d=0,l=i.length;d<l;d++)s=i[d].image,o=s&&s.url,o&&(a||(a={}),a[o]=!0,t.ImageManager.recycle(s),s.loading&&(r||(r=n.__input&&n.__input[e]||[],r instanceof Array||(r=[r])),s.unload(i[d].loadId,!r.some((t=>t.url===o)))));return a}return null}},_t={x:.5,y:0},yt={x:.5,y:1};function wt(t,e,n){let s;for(let a=0,r=e.length;a<r;a++)s=e[a],t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}const{set:mt,getAngle:vt,getDistance:xt}=t.PointHelper,{get:Bt,rotateOfOuter:bt,scaleOfOuter:Et}=t.MatrixHelper,Lt={x:.5,y:.5},Rt={x:.5,y:1},kt={},Pt={};const{set:Mt,getAngle:Ct,getDistance:St}=t.PointHelper,{get:It,rotateOfOuter:At,scaleOfOuter:Ot}=t.MatrixHelper,Wt={x:.5,y:.5},Tt={x:.5,y:1},Dt={},Ht={};const Ft={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:r,opacity:o}=e;i||(i=_t),s||(s=yt);const d=t.Platform.canvas.createLinearGradient(n.x+i.x*n.width,n.y+i.y*n.height,n.x+s.x*n.width,n.y+s.y*n.height);wt(d,e.stops,o);const l={type:a,style:d};return r&&(l.blendMode=r),l},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;i||(i=Lt),s||(s=Rt);const{x:l,y:h,width:c,height:u}=n;let f;mt(kt,l+i.x*c,h+i.y*u),mt(Pt,l+s.x*c,h+s.y*u),(c!==u||d)&&(f=Bt(),Et(f,kt,c/u*(d||1),1),bt(f,kt,vt(kt,Pt)+90));const p=t.Platform.canvas.createRadialGradient(kt.x,kt.y,0,kt.x,kt.y,xt(kt,Pt));wt(p,e.stops,r);const g={type:a,style:p,transform:f};return o&&(g.blendMode=o),g},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:r,blendMode:o,stretch:d}=e;i||(i=Wt),s||(s=Tt);const{x:l,y:h,width:c,height:u}=n;Mt(Dt,l+i.x*c,h+i.y*u),Mt(Ht,l+s.x*c,h+s.y*u);const f=It(),p=Ct(Dt,Ht);t.Platform.conicGradientRotate90?(Ot(f,Dt,c/u*(d||1),1),At(f,Dt,p+90)):(Ot(f,Dt,1,c/u*(d||1)),At(f,Dt,p));const g=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Dt.x,Dt.y):t.Platform.canvas.createRadialGradient(Dt.x,Dt.y,0,Dt.x,Dt.y,St(Dt,Ht));wt(g,e.stops,r);const _={type:a,style:g,transform:f};return o&&(_.blendMode=o),_}},{copy:Nt,toOffsetOutBounds:Yt}=t.BoundsHelper,Gt={},jt={};function Ut(e,n,i,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Nt(Gt,e.bounds),Gt.x+=n.x-r.x,Gt.y+=n.y-r.y,i){const{matrix:t}=s;Gt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Gt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Gt.width*=i,Gt.height*=i}e.copyWorld(s.canvas,e.bounds,Gt)}else i&&(Nt(Gt,n),Gt.x-=n.width/2*(i-1),Gt.y-=n.height/2*(i-1),Gt.width*=i,Gt.height*=i),e.copyWorld(s.canvas,r,i?Gt:n)}const{toOffsetOutBounds:Xt}=t.BoundsHelper,qt={};const Vt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),p=o.length-1;Yt(l,jt),o.forEach(((o,g)=>{f.setWorldShadow(jt.offsetX+o.x*c,jt.offsetY+o.y*u,o.blur*c,o.color),s=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ut(f,jt,s,n),i=l,o.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),i=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(n.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),p=o.length-1;Xt(l,qt),o.forEach(((o,g)=>{f.save(),f.setWorldShadow(qt.offsetX+o.x*c,qt.offsetY+o.y*u,o.blur*c),s=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0)):0,Ut(f,qt,s,n),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,l,"source-out"),i=l),f.fillWorld(i,o.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,o.blendMode):e.copyWorldToInner(f,i,r.renderBounds,o.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__world.a),n.copyWorldToInner(e,t.__world,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:zt}=t.LeafBoundsHelper;function Qt(t,e,n,i,s,a){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Kt(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Kt(t,n,i,a);break;case"path":n.restore()}}function Zt(t){return t.getSameCanvas(!1,!0)}function Kt(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let n,i,s,a,r;const{children:o}=this;for(let d=0,l=o.length;d<l;d++)n=o[d],n.__.mask&&(r&&(Qt(this,r,t,s,i,a),i=s=null),"path"===n.__.maskType?(n.opacity<1?(r="opacity-path",a=n.opacity,s||(s=Zt(t))):(r="path",t.save()),n.__clip(s||t,e)):(r="alpha",i||(i=Zt(t)),s||(s=Zt(t)),n.__render(i,e)),"clipping"!==n.__.maskType)||zt(n,e)||n.__render(s||t,e);Qt(this,r,t,s,i,a)};const $t=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Jt=$t+"_#~&*+\\=|≮≯≈≠=…",te=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 ee(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ne=ee("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ie=ee("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),se=ee($t),ae=ee(Jt),re=ee("- —/~|┆·");var oe;!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"}(oe||(oe={}));const{Letter:de,Single:le,Before:he,After:ce,Symbol:ue,Break:fe}=oe;function pe(t){return ne[t]?de:re[t]?fe:ie[t]?he:se[t]?ce:ae[t]?ue:te.test(t)?le:de}const ge={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function _e(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ye}=ge,{Letter:we,Single:me,Before:ve,After:xe,Symbol:Be,Break:be}=oe;let Ee,Le,Re,ke,Pe,Me,Ce,Se,Ie,Ae,Oe,We,Te,De,He,Fe,Ne=[];function Ye(t,e){Ie&&!Se&&(Se=Ie),Ee.data.push({char:t,width:e}),Re+=e}function Ge(){ke+=Re,Ee.width=Re,Le.words.push(Ee),Ee={data:[]},Re=0}function je(){De&&(He.paraNumber++,Le.paraStart=!0,De=!1),Ie&&(Le.startCharSize=Se,Le.endCharSize=Ie,Se=0),Le.width=ke,Fe.width&&ye(Le),Ne.push(Le),Le={words:[]},ke=0}const Ue=0,Xe=1,qe=2;const{top:Ve,right:ze,bottom:Qe,left:Ze}=t.Direction4;function Ke(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const $e={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,r=n.__getInput("height")||0;const{textDecoration:o,__font:d,__padding:l}=n;l&&(a&&(i=l[Ze],a-=l[ze]+l[Ze]),r&&(s=l[Ve],r-=l[Ve]+l[Qe]));const h={bounds:{x:i,y:s,width:a,height:r},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,i){He=e,Ne=e.rows,Fe=e.bounds;const{__letterSpacing:s,paraIndent:a,textCase:r}=i,{canvas:o}=t.Platform,{width:d,height:l}=Fe;if(d||l||s||"none"!==r){const t="none"!==i.textWrap,e="break"===i.textWrap;De=!0,Oe=null,Se=Ce=Ie=Re=ke=0,Ee={data:[]},Le={words:[]};for(let i=0,l=n.length;i<l;i++)Me=n[i],"\n"===Me?(Re&&Ge(),Le.paraEnd=!0,je(),De=!0):(Ae=pe(Me),Ae===we&&"none"!==r&&(Me=_e(Me,r,!Re)),Ce=o.measureText(Me).width,s&&(s<0&&(Ie=Ce),Ce+=s),We=Ae===me&&(Oe===me||Oe===we)||Oe===me&&Ae!==xe,Te=!(Ae!==ve&&Ae!==me||Oe!==Be&&Oe!==xe),Pe=De&&a?d-a:d,t&&d&&ke+Re+Ce>Pe&&(e?(Re&&Ge(),je()):(Te||(Te=Ae===we&&Oe==xe),We||Te||Ae===be||Ae===ve||Ae===me||Re+Ce>Pe?(Re&&Ge(),je()):je()))," "===Me&&!0!==De&&ke+Re===0||(Ae===be?(" "===Me&&Re&&Ge(),Ye(Me,Ce),Ge()):We||Te?(Re&&Ge(),Ye(Me,Ce)):Ye(Me,Ce)),Oe=Ae);Re&&Ge(),ke&&je(),Ne.length>0&&(Ne[Ne.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{He.paraNumber++,Ne.push({x:a||0,text:t,width:o.measureText(t).width,paraStart:!0})}))}(h,e,n),l&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":Ke(e,"x",t[Ze]);break;case"right":Ke(e,"x",-t[ze])}if(!s)switch(n.verticalAlign){case"top":Ke(e,"y",t[Ve]);break;case"bottom":Ke(e,"y",-t[Qe])}}(l,h,n,a,r),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:l,paraSpacing:h}=e;let c,u,f,{x:p,y:g,width:_,height:y}=i,w=s*n.length+(h?h*(t.paraNumber-1):0),m=a;if(o&&w>y)w=Math.max(y,s),t.overflow=n.length;else switch(l){case"middle":g+=(y-w)/2;break;case"bottom":g+=y-w}m+=g;for(let a=0,l=n.length;a<l;a++){switch(c=n[a],c.x=p,d){case"center":c.x+=(_-c.width)/2;break;case"right":c.x+=_-c.width}c.paraStart&&h&&a>0&&(m+=h),c.y=m,m+=s,t.overflow>a&&m>w&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,r<0&&(c.width<0?(f=-c.width+e.fontSize+r,u-=f,f+=e.fontSize):f-=r),u<i.x&&(i.x=u),f>i.width&&(i.width=f),o&&_&&_<f&&(c.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=g,i.height=w}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:r,letterSpacing:o}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=r&&t.paraStart?r:0,l=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=o||t.isOverflow?Ue:l>.01?Xe:qe,t.isOverflow&&!o&&(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,d=t.x,t.data=[],t.words.forEach((e=>{c===Xe?(u={char:"",x:d},d=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,n){return t.forEach((t=>{" "!==t.char&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,n,a),h.overflow&&function(e,n){const{rows:i,overflow:s}=e;let{textOverflow:a}=n;if(i.splice(s),"hide"!==a){let e,r;"ellipsis"===a&&(a="...");const o=t.Platform.canvas.measureText(a).width,d=n.x+n.width-o;("none"===n.textWrap?i:[i[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],r=e.x+e.width,!(i===n&&r<d));i--){if(r<d&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=o,t.data.push({char:a,x:r}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n),"none"!==o&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const Je={string:function(t,e){if("string"==typeof t)return t;let n=void 0===t.a?1:t.a;e&&(n*=e);const i=t.r+","+t.g+","+t.b;return 1===n?"rgb("+i+")":"rgba("+i+","+n+")"}},{setPoint:tn,addPoint:en,toBounds:nn}=t.TwoPointBoundsHelper;const sn={export(e,n,i){return this.running=!0,function(e){an||(an=new t.TaskProcessor);return new Promise((t=>{an.add((()=>s(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const o=t=>{a(t),r(),this.running=!1},{leafer:d}=e;d?d.waitViewCompleted((()=>s(this,void 0,void 0,(function*(){let s,a,r=1,l=1;i=t.FileHelper.getExportOptions(i);const{scale:h,slice:c,trim:u}=i,f=i.pixelRatio||1,p=i.screenshot||e.isApp,g=void 0===i.fill?e.isLeafer&&p?e.fill:"":i.fill,_=t.FileHelper.isOpaqueImage(n)||g,y=new t.Matrix;if(p)s=!0===p?e.isLeafer?d.canvas.bounds:e.worldRenderBounds:p;else{const{localTransform:t,__world:n}=e;y.set(n).divide(t).invert(),r=1/(n.scaleX/e.scaleX),l=1/(n.scaleY/e.scaleY),s=e.getBounds("render","local")}let{x:w,y:m,width:v,height:x}=s;h&&(y.scale(h),v*=h,x*=h,r*=h,l*=h);let B=t.Creator.canvas({width:Math.ceil(v),height:Math.ceil(x),pixelRatio:f});const b={matrix:y.translate(-w,-m).withScale(r,l)};if(c&&(e=d,b.bounds=B.bounds),B.save(),e.__render(B,b),B.restore(),u){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,r,o,d=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=d%n,r=(d-a)/n,o?en(o,a,r):tn(o={},a,r)),d++;const l=new t.Bounds;return nn(o,l),l.scale(1/e.pixelRatio).ceil()}(B);const e=B,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:f};B=t.Creator.canvas(s),B.copyWorld(e,a,s)}_&&B.fillWorld(B.bounds,g||"#FFFFFF","destination-over");const E="canvas"===n?B:yield B.export(n,i);o({data:E,width:B.pixelWidth,height:B.pixelHeight,renderBounds:s,trimBounds:a})})))):o({data:!1})}))))}};let an;Object.assign(i.TextConvert,$e),Object.assign(i.ColorConvert,Je),Object.assign(i.Paint,N),Object.assign(i.PaintImage,gt),Object.assign(i.PaintGradient,Ft),Object.assign(i.Effect,Vt),Object.assign(i.Export,sn),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new n.InteractionBase(t,e,i,s),hitCanvas:(t,e)=>new a(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=a,exports.Renderer=B,exports.Selector=P,exports.Watcher=d,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}),loadImage:n},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:a}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(r(e),n),canvasToBolb:(t,e,n)=>s(this,void 0,void 0,(function*(){return t.toBuffer(r(e),n)})),canvasSaveAs:(t,n,i)=>s(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(r(o(n)),i))})),loadImage:a}}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.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.12",
|
|
4
4
|
"description": "@leafer-ui/node",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"leaferjs"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@leafer/core": "1.0.0-rc.
|
|
34
|
-
"@leafer/node": "1.0.0-rc.
|
|
35
|
-
"@leafer/partner": "1.0.0-rc.
|
|
36
|
-
"@leafer-ui/core": "1.0.0-rc.
|
|
37
|
-
"@leafer-ui/partner": "1.0.0-rc.
|
|
38
|
-
"@leafer-ui/interface": "1.0.0-rc.
|
|
39
|
-
"leafer-in": "1.0.0-rc.
|
|
33
|
+
"@leafer/core": "1.0.0-rc.12",
|
|
34
|
+
"@leafer/node": "1.0.0-rc.12",
|
|
35
|
+
"@leafer/partner": "1.0.0-rc.12",
|
|
36
|
+
"@leafer-ui/core": "1.0.0-rc.12",
|
|
37
|
+
"@leafer-ui/partner": "1.0.0-rc.12",
|
|
38
|
+
"@leafer-ui/interface": "1.0.0-rc.12",
|
|
39
|
+
"leafer-in": "1.0.0-rc.12"
|
|
40
40
|
}
|
|
41
41
|
}
|