@leafer-ui/node 1.6.3 → 1.6.5
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 +17 -26
- package/dist/node.esm.js +25 -34
- package/dist/node.esm.min.js +1 -1
- package/dist/node.esm.min.js.map +1 -1
- package/dist/node.min.cjs +1 -1
- package/dist/node.min.cjs.map +1 -1
- package/package.json +12 -12
package/dist/node.cjs
CHANGED
|
@@ -891,8 +891,6 @@ function fillPathOrText(ui, canvas) {
|
|
|
891
891
|
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
892
892
|
}
|
|
893
893
|
|
|
894
|
-
const Paint = {};
|
|
895
|
-
|
|
896
894
|
function strokeText(stroke, ui, canvas) {
|
|
897
895
|
switch (ui.__.strokeAlign) {
|
|
898
896
|
case 'center':
|
|
@@ -918,11 +916,14 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
918
916
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
919
917
|
fillText(ui, out);
|
|
920
918
|
out.blendMode = 'normal';
|
|
921
|
-
|
|
919
|
+
copyWorld(canvas, out, ui);
|
|
920
|
+
out.recycle(ui.__nowWorld);
|
|
921
|
+
}
|
|
922
|
+
function copyWorld(canvas, out, ui) {
|
|
923
|
+
if (ui.__worldFlipped || core.Platform.fullImageShadow)
|
|
922
924
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
923
925
|
else
|
|
924
926
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
925
|
-
out.recycle(ui.__nowWorld);
|
|
926
927
|
}
|
|
927
928
|
function drawTextStroke(ui, canvas) {
|
|
928
929
|
let row, data = ui.__.__textDrawData;
|
|
@@ -988,12 +989,11 @@ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
|
988
989
|
canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
989
990
|
data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
|
|
990
991
|
if (data.__useArrow)
|
|
991
|
-
Paint.strokeArrow(stroke, ui, canvas);
|
|
992
|
+
draw.Paint.strokeArrow(stroke, ui, canvas);
|
|
992
993
|
}
|
|
993
994
|
function drawInside(stroke, ui, canvas) {
|
|
994
|
-
const data = ui.__;
|
|
995
995
|
canvas.save();
|
|
996
|
-
|
|
996
|
+
canvas.clipUI(ui);
|
|
997
997
|
drawCenter(stroke, 2, ui, canvas);
|
|
998
998
|
canvas.restore();
|
|
999
999
|
}
|
|
@@ -1007,12 +1007,9 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
1007
1007
|
const out = canvas.getSameCanvas(true, true);
|
|
1008
1008
|
ui.__drawRenderPath(out);
|
|
1009
1009
|
drawCenter(stroke, 2, ui, out);
|
|
1010
|
-
|
|
1010
|
+
out.clipUI(data);
|
|
1011
1011
|
out.clearWorld(renderBounds);
|
|
1012
|
-
|
|
1013
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1014
|
-
else
|
|
1015
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
1012
|
+
copyWorld(canvas, out, ui);
|
|
1016
1013
|
out.recycle(ui.__nowWorld);
|
|
1017
1014
|
}
|
|
1018
1015
|
}
|
|
@@ -1068,9 +1065,7 @@ function compute(attrName, ui) {
|
|
|
1068
1065
|
paints = [paints];
|
|
1069
1066
|
recycleMap = draw.PaintImage.recycleImage(attrName, data);
|
|
1070
1067
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1071
|
-
item = getLeafPaint(attrName, paints[i], ui);
|
|
1072
|
-
if (item)
|
|
1073
|
-
leafPaints.push(item);
|
|
1068
|
+
(item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
|
|
1074
1069
|
}
|
|
1075
1070
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1076
1071
|
if (leafPaints.length) {
|
|
@@ -1108,8 +1103,8 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1108
1103
|
data = draw.PaintGradient.conicGradient(paint, boxBounds);
|
|
1109
1104
|
break;
|
|
1110
1105
|
case 'solid':
|
|
1111
|
-
const { type,
|
|
1112
|
-
data = { type,
|
|
1106
|
+
const { type, color, opacity } = paint;
|
|
1107
|
+
data = { type, style: draw.ColorConvert.string(color, opacity) };
|
|
1113
1108
|
break;
|
|
1114
1109
|
default:
|
|
1115
1110
|
if (paint.r !== undefined)
|
|
@@ -1486,7 +1481,7 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1486
1481
|
}
|
|
1487
1482
|
function drawImage(ui, canvas, paint, data) {
|
|
1488
1483
|
canvas.save();
|
|
1489
|
-
|
|
1484
|
+
canvas.clipUI(ui);
|
|
1490
1485
|
if (paint.blendMode)
|
|
1491
1486
|
canvas.blendMode = paint.blendMode;
|
|
1492
1487
|
if (data.opacity)
|
|
@@ -1651,12 +1646,10 @@ function shadow(ui, current, shape) {
|
|
|
1651
1646
|
}
|
|
1652
1647
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1653
1648
|
}
|
|
1654
|
-
if (ui.__worldFlipped)
|
|
1649
|
+
if (ui.__worldFlipped)
|
|
1655
1650
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1656
|
-
|
|
1657
|
-
else {
|
|
1651
|
+
else
|
|
1658
1652
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1659
|
-
}
|
|
1660
1653
|
if (end && index < end)
|
|
1661
1654
|
other.clearWorld(copyBounds, true);
|
|
1662
1655
|
});
|
|
@@ -1715,12 +1708,10 @@ function innerShadow(ui, current, shape) {
|
|
|
1715
1708
|
copyBounds = bounds;
|
|
1716
1709
|
}
|
|
1717
1710
|
other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
|
|
1718
|
-
if (ui.__worldFlipped)
|
|
1711
|
+
if (ui.__worldFlipped)
|
|
1719
1712
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1720
|
-
|
|
1721
|
-
else {
|
|
1713
|
+
else
|
|
1722
1714
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1723
|
-
}
|
|
1724
1715
|
if (end && index < end)
|
|
1725
1716
|
other.clearWorld(copyBounds, true);
|
|
1726
1717
|
});
|
package/dist/node.esm.js
CHANGED
|
@@ -2,9 +2,9 @@ import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferIma
|
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
export { LeaferImage } from '@leafer/core';
|
|
4
4
|
import { writeFileSync } from 'fs';
|
|
5
|
-
import {
|
|
5
|
+
import { HitCanvasManager, InteractionBase } from '@leafer-ui/core';
|
|
6
6
|
export * from '@leafer-ui/core';
|
|
7
|
-
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert,
|
|
7
|
+
import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Group, TextConvert, Effect, TwoPointBoundsHelper, Bounds as Bounds$1, FileHelper as FileHelper$1, Platform as Platform$1, Matrix, MathHelper as MathHelper$1, Creator as Creator$1, TaskProcessor, Resource, LeaferCanvasBase as LeaferCanvasBase$1, Debug as Debug$1, Plugin as Plugin$1, UI } from '@leafer-ui/draw';
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
10
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -892,8 +892,6 @@ function fillPathOrText(ui, canvas) {
|
|
|
892
892
|
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
893
893
|
}
|
|
894
894
|
|
|
895
|
-
const Paint = {};
|
|
896
|
-
|
|
897
895
|
function strokeText(stroke, ui, canvas) {
|
|
898
896
|
switch (ui.__.strokeAlign) {
|
|
899
897
|
case 'center':
|
|
@@ -919,11 +917,14 @@ function drawAlign(stroke, align, ui, canvas) {
|
|
|
919
917
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
920
918
|
fillText(ui, out);
|
|
921
919
|
out.blendMode = 'normal';
|
|
922
|
-
|
|
920
|
+
copyWorld(canvas, out, ui);
|
|
921
|
+
out.recycle(ui.__nowWorld);
|
|
922
|
+
}
|
|
923
|
+
function copyWorld(canvas, out, ui) {
|
|
924
|
+
if (ui.__worldFlipped || Platform.fullImageShadow)
|
|
923
925
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
924
926
|
else
|
|
925
927
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
926
|
-
out.recycle(ui.__nowWorld);
|
|
927
928
|
}
|
|
928
929
|
function drawTextStroke(ui, canvas) {
|
|
929
930
|
let row, data = ui.__.__textDrawData;
|
|
@@ -992,9 +993,8 @@ function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
|
992
993
|
Paint.strokeArrow(stroke, ui, canvas);
|
|
993
994
|
}
|
|
994
995
|
function drawInside(stroke, ui, canvas) {
|
|
995
|
-
const data = ui.__;
|
|
996
996
|
canvas.save();
|
|
997
|
-
|
|
997
|
+
canvas.clipUI(ui);
|
|
998
998
|
drawCenter(stroke, 2, ui, canvas);
|
|
999
999
|
canvas.restore();
|
|
1000
1000
|
}
|
|
@@ -1008,12 +1008,9 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
1008
1008
|
const out = canvas.getSameCanvas(true, true);
|
|
1009
1009
|
ui.__drawRenderPath(out);
|
|
1010
1010
|
drawCenter(stroke, 2, ui, out);
|
|
1011
|
-
|
|
1011
|
+
out.clipUI(data);
|
|
1012
1012
|
out.clearWorld(renderBounds);
|
|
1013
|
-
|
|
1014
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1015
|
-
else
|
|
1016
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
1013
|
+
copyWorld(canvas, out, ui);
|
|
1017
1014
|
out.recycle(ui.__nowWorld);
|
|
1018
1015
|
}
|
|
1019
1016
|
}
|
|
@@ -1069,9 +1066,7 @@ function compute(attrName, ui) {
|
|
|
1069
1066
|
paints = [paints];
|
|
1070
1067
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
1071
1068
|
for (let i = 0, len = paints.length, item; i < len; i++) {
|
|
1072
|
-
item = getLeafPaint(attrName, paints[i], ui);
|
|
1073
|
-
if (item)
|
|
1074
|
-
leafPaints.push(item);
|
|
1069
|
+
(item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
|
|
1075
1070
|
}
|
|
1076
1071
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1077
1072
|
if (leafPaints.length) {
|
|
@@ -1109,8 +1104,8 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
1109
1104
|
data = PaintGradient.conicGradient(paint, boxBounds);
|
|
1110
1105
|
break;
|
|
1111
1106
|
case 'solid':
|
|
1112
|
-
const { type,
|
|
1113
|
-
data = { type,
|
|
1107
|
+
const { type, color, opacity } = paint;
|
|
1108
|
+
data = { type, style: ColorConvert.string(color, opacity) };
|
|
1114
1109
|
break;
|
|
1115
1110
|
default:
|
|
1116
1111
|
if (paint.r !== undefined)
|
|
@@ -1487,7 +1482,7 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1487
1482
|
}
|
|
1488
1483
|
function drawImage(ui, canvas, paint, data) {
|
|
1489
1484
|
canvas.save();
|
|
1490
|
-
|
|
1485
|
+
canvas.clipUI(ui);
|
|
1491
1486
|
if (paint.blendMode)
|
|
1492
1487
|
canvas.blendMode = paint.blendMode;
|
|
1493
1488
|
if (data.opacity)
|
|
@@ -1652,12 +1647,10 @@ function shadow(ui, current, shape) {
|
|
|
1652
1647
|
}
|
|
1653
1648
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1654
1649
|
}
|
|
1655
|
-
if (ui.__worldFlipped)
|
|
1650
|
+
if (ui.__worldFlipped)
|
|
1656
1651
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1657
|
-
|
|
1658
|
-
else {
|
|
1652
|
+
else
|
|
1659
1653
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1660
|
-
}
|
|
1661
1654
|
if (end && index < end)
|
|
1662
1655
|
other.clearWorld(copyBounds, true);
|
|
1663
1656
|
});
|
|
@@ -1716,12 +1709,10 @@ function innerShadow(ui, current, shape) {
|
|
|
1716
1709
|
copyBounds = bounds;
|
|
1717
1710
|
}
|
|
1718
1711
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
|
|
1719
|
-
if (ui.__worldFlipped)
|
|
1712
|
+
if (ui.__worldFlipped)
|
|
1720
1713
|
current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
|
|
1721
|
-
|
|
1722
|
-
else {
|
|
1714
|
+
else
|
|
1723
1715
|
current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
|
|
1724
|
-
}
|
|
1725
1716
|
if (end && index < end)
|
|
1726
1717
|
other.clearWorld(copyBounds, true);
|
|
1727
1718
|
});
|
|
@@ -2357,7 +2348,7 @@ const ColorConvertModule = {
|
|
|
2357
2348
|
|
|
2358
2349
|
Object.assign(TextConvert, TextConvertModule);
|
|
2359
2350
|
Object.assign(ColorConvert, ColorConvertModule);
|
|
2360
|
-
Object.assign(Paint
|
|
2351
|
+
Object.assign(Paint, PaintModule);
|
|
2361
2352
|
Object.assign(PaintImage, PaintImageModule);
|
|
2362
2353
|
Object.assign(PaintGradient, PaintGradientModule);
|
|
2363
2354
|
Object.assign(Effect, EffectModule);
|
|
@@ -2387,8 +2378,8 @@ const ExportModule = {
|
|
|
2387
2378
|
const fileType = FileHelper$1.fileType(filename);
|
|
2388
2379
|
const isDownload = filename.includes('.');
|
|
2389
2380
|
options = FileHelper$1.getExportOptions(options);
|
|
2390
|
-
const { toURL } = Platform$
|
|
2391
|
-
const { download } = Platform$
|
|
2381
|
+
const { toURL } = Platform$1;
|
|
2382
|
+
const { download } = Platform$1.origin;
|
|
2392
2383
|
if (fileType === 'json') {
|
|
2393
2384
|
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
2394
2385
|
result = { data: isDownload ? true : leaf.toJSON(options.json) };
|
|
@@ -2491,7 +2482,7 @@ const ExportModule = {
|
|
|
2491
2482
|
return addTask((success) => new Promise((resolve) => {
|
|
2492
2483
|
const getResult = () => __awaiter(this, void 0, void 0, function* () {
|
|
2493
2484
|
if (!Resource.isComplete)
|
|
2494
|
-
return Platform$
|
|
2485
|
+
return Platform$1.requestRender(getResult);
|
|
2495
2486
|
const result = ExportModule.syncExport(leaf, filename, options);
|
|
2496
2487
|
if (result.data instanceof Promise)
|
|
2497
2488
|
result.data = yield result.data;
|
|
@@ -2536,7 +2527,7 @@ canvas.export = function (filename, options) {
|
|
|
2536
2527
|
};
|
|
2537
2528
|
canvas.toBlob = function (type, quality) {
|
|
2538
2529
|
return new Promise((resolve) => {
|
|
2539
|
-
Platform$
|
|
2530
|
+
Platform$1.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
2540
2531
|
resolve(blob);
|
|
2541
2532
|
}).catch((e) => {
|
|
2542
2533
|
debug.error(e);
|
|
@@ -2545,11 +2536,11 @@ canvas.toBlob = function (type, quality) {
|
|
|
2545
2536
|
});
|
|
2546
2537
|
};
|
|
2547
2538
|
canvas.toDataURL = function (type, quality) {
|
|
2548
|
-
return Platform$
|
|
2539
|
+
return Platform$1.origin.canvasToDataURL(this.view, type, quality);
|
|
2549
2540
|
};
|
|
2550
2541
|
canvas.saveAs = function (filename, quality) {
|
|
2551
2542
|
return new Promise((resolve) => {
|
|
2552
|
-
Platform$
|
|
2543
|
+
Platform$1.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
2553
2544
|
resolve(true);
|
|
2554
2545
|
}).catch((e) => {
|
|
2555
2546
|
debug.error(e);
|
package/dist/node.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as n,Creator as s,LeaferImage as a,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Plugin as k,MatrixHelper as R,MathHelper as S,AlignHelper as E,PointHelper as L,ImageEvent as A,AroundHelper as T,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as W}from"fs";import{Platform as O,HitCanvasManager as P,InteractionBase as M}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as D,ColorConvert as I,PaintGradient as F,Export as Y,Group as U,TextConvert as X,Paint as N,Effect as j,TwoPointBoundsHelper as z,Bounds as G,FileHelper as q,Platform as H,Matrix as V,MathHelper as Q,Creator as J,TaskProcessor as Z,Resource as $,LeaferCanvasBase as K,Debug as tt,Plugin as et,UI as it}from"@leafer-ui/draw";function nt(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}l((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class st 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:at,fileType:ot}=n;function rt(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(at(e),i),canvasToBolb:(t,e,i)=>nt(this,void 0,void 0,(function*(){return t.toBuffer(at(e),i)})),canvasSaveAs:(t,e,i)=>nt(this,void 0,void 0,(function*(){return W(e,t.toBuffer(at(ot(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new st(t,e),image:t=>new a(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class lt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=l.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===c.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 h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:dt,updateBounds:ct,updateChange:ht}=f,{pushAllChildBranch:ut,pushAllParent:ft}=p;const{worldBounds:pt}=g;class gt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,pt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,pt),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_t,updateAllChange:wt}=f,yt=w.get("Layouter");class mt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){yt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?yt.warn("layouting"):this.times>3?yt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(dt(t,!0),e.add(t),t.isBranch&&ut(t,e),ft(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ft(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||ct(n[t])}ct(i)}}))}(this.__levelList),function(t){t.list.forEach(ht)}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),mt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){_t(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),wt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new gt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new gt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[m.REQUEST,this.layout,this],[m.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const vt=w.get("Renderer");class xt{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=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,vt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,vt.error(t)}vt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return vt.warn("rendering");if(this.times>3)return vt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);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,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=new _(n);i.save(),n.spread(xt.clipSpread).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0),this.__render(n,s),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,e){const{canvas:i}=this,n=t.includes(this.target.__world),s=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,s),this.renderBounds=e=e||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}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=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||vt.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(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[m.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}xt.clipSpread=10;const{hitRadiusPoint:bt}=B;class Bt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),n?{path:d,target:l,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:l}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||bt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class kt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new Bt(this.target=t,this),this.finder=s.finder&&s.finder()}getByPoint(t,i,n){const{target:s,picker:a}=this;return e.backgrounder&&s&&s.updateLayout(),a.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Rt(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach((t=>s.forEach((i=>e.fillRect(t.x,t.y+i,t.width,a)))))}}function St(t,e){t.__.__font?Rt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}Object.assign(s,{watcher:(t,e)=>new lt(t,e),layouter:(t,e)=>new mt(t,e),renderer:(t,e,i)=>new xt(t,e,i),selector:(t,e)=>new kt(t,e)}),e.layout=mt.fullLayout;const Et={};function Lt(t,e,i){switch(e.__.strokeAlign){case"center":At(t,1,e,i);break;case"inside":Tt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?At(t,2,e,i):Tt(t,"outside",e,i)}}function At(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.strokeWidth*e,s),s.__isStrokes?Wt(t,!0,i,n):Ct(i,n)}function Tt(t,e,i,n){const s=n.getSameCanvas(!0,!0);s.font=i.__.__font,At(t,2,i,s),s.blendMode="outside"===e?"destination-out":"destination-in",Rt(i,s),s.blendMode="normal",i.__worldFlipped||O.fullImageShadow?n.copyWorldByReset(s,i.__nowWorld):n.copyWorldToInner(s,i.__nowWorld,i.__layout.renderBounds),s.recycle(i.__nowWorld)}function Ct(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(a){const{decorationHeight:t}=n;s.forEach((i=>a.forEach((n=>e.strokeRect(i.x,i.y+n,i.width,t)))))}}function Wt(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&D.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?Ct(i,n):n.stroke(),n.restoreBlendMode()):e?Ct(i,n):n.stroke())}function Ot(t,e,i){const n=e.__;if(n.__strokeWidth)if(n.__font)Lt(t,e,i);else switch(n.strokeAlign){case"center":Pt(t,1,e,i);break;case"inside":!function(t,e,i){const n=e.__;i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),Pt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const n=e.__;if(n.__fillAfterStroke)Pt(t,2,e,i);else{const{renderBounds:s}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Pt(t,2,e,a),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(s),e.__worldFlipped||O.fullImageShadow?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,s),a.recycle(e.__nowWorld)}}(t,e,i)}}function Pt(t,e,i,n){const s=i.__;n.setStroke(!s.__isStrokes&&t,s.__strokeWidth*e,s),s.__isStrokes?Wt(t,!1,i,n):n.stroke(),s.__useArrow&&Et.strokeArrow(t,i,n)}const{getSpread:Mt,getOuterOf:Dt,getByMove:It,getIntersectData:Ft}=B;let Yt;const{stintSet:Ut}=l,{hasTransparent:Xt}=I;function Nt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let n;const{boxBounds:s}=i.__layout;switch(e.type){case"image":n=D.image(i,t,e,s,!Yt||!Yt[e.url]);break;case"linear":n=F.linearGradient(e,s);break;case"radial":n=F.radialGradient(e,s);break;case"angular":n=F.conicGradient(e,s);break;case"solid":const{type:a,blendMode:o,color:r,opacity:l}=e;n={type:a,blendMode:o,style:I.string(r,l)};break;default:void 0!==e.r&&(n={type:"solid",style:I.string(e)})}return n&&("string"==typeof n.style&&Xt(n.style)&&(n.isTransparent=!0),e.blendMode&&(n.blendMode=e.blendMode)),n}const jt={compute:function(t,e){const i=e.__,n=[];let s,a,o=i.__input[t];o instanceof Array||(o=[o]),Yt=D.recycleImage(t,i);for(let i,s=0,a=o.length;s<a;s++)i=Nt(t,o[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n.every((t=>t.isTransparent))&&(n.some((t=>t.image))&&(s=!0),a=!0),"fill"===t?(Ut(i,"__isAlphaPixelFill",s),Ut(i,"__isTransparentFill",a)):(Ut(i,"__isAlphaPixelStroke",s),Ut(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,St(e,i)},fills:function(t,e,i){let n;for(let s=0,a=t.length;s<a;s++){if(n=t[s],n.image){if(D.checkImage(e,i,n,!e.__.__font))continue;if(!n.style){!s&&n.image.isPlacehold&&e.drawImagePlaceholder(i,n.image);continue}}i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),St(e,i),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),St(e,i),i.restoreBlendMode()):St(e,i)}},fillPathOrText:St,fillText:Rt,stroke:Ot,strokes:function(t,e,i){Ot(t,e,i)},strokeText:Lt,drawTextStroke:Ct,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,h=Ft(n?Mt(e.bounds,d===c?n*d:[n*c,n*d]):e.bounds,s);o=e.bounds.getFitMatrix(h);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,c*=f),r=Dt(s,o),a=It(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let zt={};const{get:Gt,rotateOfOuter:qt,translate:Ht,scaleOfOuter:Vt,scale:Qt,rotate:Jt}=R;function Zt(t,e,i,n,s,a,o){const r=Gt();Ht(r,e.x+i,e.y+n),Qt(r,s,a),o&&qt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function $t(t,e,i,n,s,a,o){const r=Gt();Ht(r,e.x+i,e.y+n),s&&Qt(r,s,a),o&&Jt(r,o),t.transform=r}function Kt(t,e,i,n,s,a,o,r,l,d){const c=Gt();if(l)if("center"===d)qt(c,{x:i/2,y:n/2},l);else switch(Jt(c,l),l){case 90:Ht(c,n,0);break;case 180:Ht(c,i,n);break;case 270:Ht(c,0,i)}zt.x=e.x+s,zt.y=e.y+a,Ht(c,zt.x,zt.y),o&&Vt(c,zt,o,r),t.transform=c}const{get:te,translate:ee}=R,ie=new _,ne={},se={};function ae(t,e,i,n){const{changeful:s,sync:a}=i;s&&(t.changeful=s),a&&(t.sync=a),t.data=oe(i,n,e)}function oe(t,e,i){t.padding&&(e=ie.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:s}=i;const{opacity:a,mode:o,align:r,offset:l,scale:d,size:c,rotation:h,repeat:u,filters:f}=t,p=e.width===n&&e.height===s,g={mode:o},_="center"!==r&&(h||0)%180==90;let w,y;switch(B.set(se,0,0,_?s:n,_?n:s),o&&"cover"!==o&&"fit"!==o?((d||c)&&(S.getScaleData(d,c,i,ne),w=ne.scaleX,y=ne.scaleY),r&&(w&&B.scale(se,w,y,!0),E.toPoint(r,se,e,se,!0,!0))):p&&!h||(w=y=B.getFitScale(e,se,"fit"!==o),B.put(e,i,r,w,!1,se),B.scale(se,w,y,!0)),l&&L.move(se,l),o){case"stretch":p||(n=e.width,s=e.height);break;case"normal":case"clip":(se.x||se.y||w||h)&&$t(g,e,se.x,se.y,w,y,h);break;case"repeat":(!p||w||h)&&Kt(g,e,n,s,se.x,se.y,w,y,h,r),u||(g.repeat="repeat");break;default:w&&Zt(g,e,se.x,se.y,w,y,h)}return g.transform||(e.x||e.y)&&(g.transform=te(),ee(g.transform,e.x,e.y)),w&&"stretch"!==o&&(g.scaleX=w,g.scaleY=y),g.width=n,g.height=s,a&&(g.opacity=a),f&&(g.filters=f),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let re,le=new _;const{isSame:de}=B;function ce(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||ae(s,n,i,a),!0}function he(t,e){pe(t,A.LOAD,e)}function ue(t,e){pe(t,A.LOADED,e)}function fe(t,e,i){e.error=i,t.forceUpdate("surface"),pe(t,A.ERROR,e)}function pe(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function ge(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:_e,scale:we,copy:ye}=R,{ceil:me,abs:ve}=Math;function xe(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=ve(s),a=ve(a);const{image:t,data:r}=i;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(d=_e(),ye(d,p),we(d,1/u,1/f),s*=u,a*=f),s*=n,a*=n,c*=s,h*=a;const _=c*h;if(!g&&_>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(l=Math.sqrt(_/w)),l&&(s/=l,a/=l,c/=l,h/=l),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(d||(d=_e(),p&&ye(d,p)),we(d,1/s,1/a));const y=t.getCanvas(me(c)||1,me(h)||1,r.opacity,r.filters),m=t.getPattern(y,g||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=o,!0}}const{abs:be}=Math;const Be={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return re&&i===re.paint&&de(n,re.boxBounds)?a=re.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),re=r.use>1?{leafPaint:a,paint:i,boxBounds:le.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ce(t,e,i,r,a,n),s&&(he(t,o),ue(t,o))):r.error?s&&fe(t,o,r.error):(s&&(ge(t,!0),he(t,o)),a.loadId=r.load((()=>{ge(t,!1),t.destroyed||(ce(t,e,i,r,a,n)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ue(t,o)),a.loadId=null}),(e=>{ge(t,!1),fe(t,o,e),a.loadId=null})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i,{data:l}=n;if(!l||n.patternId===a+"-"+o+"-"+r&&!Y.running)return!1;if(s)if(l.repeat)s=!1;else if(!(n.changeful||b.isResizing(t)||Y.running)){let{width:t,height:i}=l;t*=be(a)*r,i*=be(o)*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),s=t*i>e.image.maxCacheSize}return s?(function(t,e,i,n){e.save(),t.windingRule?e.clip(t.windingRule):e.clip(),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(t,i,n,l),!0):(!n.style||n.sync||Y.running?xe(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>nt(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&xe(t,n,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:xe,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o,r;for(let l=0,d=i.length;l<d;l++)n=i[l],s=n.image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,x.recycle(s),s.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),s.unload(i[l].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:ae,getPatternData:oe,fillOrFitMode:Zt,clipMode:$t,repeatMode:Kt},{toPoint:ke}=T,{hasTransparent:Re}=I,Se={},Ee={};function Le(t,e,i,n){if(i){let s,a,o,r;for(let t=0,l=i.length;t<l;t++)s=i[t],"string"==typeof s?(o=t/(l-1),a=I.string(s,n)):(o=s.offset,a=I.string(s.color,n)),e.addColorStop(o,a),!r&&Re(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Ae,getDistance:Te}=L,{get:Ce,rotateOfOuter:We,scaleOfOuter:Oe}=R,{toPoint:Pe}=T,Me={},De={};function Ie(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=Ae(e,i);a=Ce(),s?(Oe(a,e,o/r*(n||1),1),We(a,e,t+90)):(Oe(a,e,1,o/r*(n||1)),We(a,e,t))}return a}const{getDistance:Fe}=L,{toPoint:Ye}=T,Ue={},Xe={};const Ne={linearGradient:function(t,i){let{from:n,to:s,type:a,opacity:o}=t;ke(n||"top",i,Se),ke(s||"bottom",i,Ee);const r=e.canvas.createLinearGradient(Se.x,Se.y,Ee.x,Ee.y),l={type:a,style:r};return Le(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,stretch:r}=t;Pe(n||"center",i,Me),Pe(s||"bottom",i,De);const l=e.canvas.createRadialGradient(Me.x,Me.y,0,Me.x,Me.y,Te(Me,De)),d={type:a,style:l};Le(d,l,t.stops,o);const c=Ie(i,Me,De,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,stretch:r}=t;Ye(n||"center",i,Ue),Ye(s||"bottom",i,Xe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ue.x,Ue.y):e.canvas.createRadialGradient(Ue.x,Ue.y,0,Ue.x,Ue.y,Fe(Ue,Xe)),d={type:a,style:l};Le(d,l,t.stops,o);const c=Ie(i,Ue,Xe,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ie},{copy:je,toOffsetOutBounds:ze}=B,Ge={},qe={};function He(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(je(Ge,t.bounds),Ge.x+=i.x-o.x,Ge.y+=i.y-o.y,n){const{matrix:t}=s;Ge.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Ge.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Ge.width*=n,Ge.height*=n}t.copyWorld(s.canvas,t.bounds,Ge)}else n&&(je(Ge,i),Ge.x-=i.width/2*(n-1),Ge.y-=i.height/2*(n-1),Ge.width*=n,Ge.height*=n),t.copyWorld(s.canvas,o,n?Ge:i)}const{toOffsetOutBounds:Ve}=B,Qe={};const Je={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;ze(d,qe),r.forEach(((r,g)=>{f.setWorldShadow(qe.offsetX+r.x*h,qe.offsetY+r.y*u,r.blur*h,I.string(r.color)),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,He(f,qe,s,i),n=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),n=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ve(d,Qe),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Qe.offsetX+r.x*h,Qe.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,He(f,Qe,s,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,c,d,"source-out"),n=d),f.fillWorld(n,I.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Ze}=g;function $e(t,e,i,n,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),ti(t,e,i,1)}(t,i,n,s);break;case"opacity-path":ti(t,i,n,a);break;case"path":i.restore()}}function Ke(t){return t.getSameCanvas(!1,!0)}function ti(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}U.prototype.__renderMask=function(t,e){let i,n,s,a,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)i=l[d],r=i.__.mask,r&&(o&&($e(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ke(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=Ke(t)),s||(s=Ke(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||Ze(i,e)||i.__render(s||t,e);$e(this,o,t,s,n,a)};const ei=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ii=ei+"_#~&*+\\=|≮≯≈≠=…",ni=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 si(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ai=si("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),oi=si("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ri=si(ei),li=si(ii),di=si("- —/~|┆·");var ci;!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"}(ci||(ci={}));const{Letter:hi,Single:ui,Before:fi,After:pi,Symbol:gi,Break:_i}=ci;function wi(t){return ai[t]?hi:di[t]?_i:oi[t]?fi:ri[t]?pi:li[t]?gi:ni.test(t)?ui:hi}const yi={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function mi(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:vi}=yi,{Letter:xi,Single:bi,Before:Bi,After:ki,Symbol:Ri,Break:Si}=ci;let Ei,Li,Ai,Ti,Ci,Wi,Oi,Pi,Mi,Di,Ii,Fi,Yi,Ui,Xi,Ni,ji,zi=[];function Gi(t,e){Mi&&!Pi&&(Pi=Mi),Ei.data.push({char:t,width:e}),Ai+=e}function qi(){Ti+=Ai,Ei.width=Ai,Li.words.push(Ei),Ei={data:[]},Ai=0}function Hi(){Ui&&(Xi.paraNumber++,Li.paraStart=!0,Ui=!1),Mi&&(Li.startCharSize=Pi,Li.endCharSize=Mi,Pi=0),Li.width=Ti,Ni.width?vi(Li):ji&&Vi(),zi.push(Li),Li={words:[]},Ti=0}function Vi(){Ti>(Xi.maxWidth||0)&&(Xi.maxWidth=Ti)}const{top:Qi,right:Ji,bottom:Zi,left:$i}=C;function Ki(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const tn={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=i;d&&(a?(n=d[$i],a-=d[Ji]+d[$i]):i.autoSizeAlign||(n=d[$i]),o?(s=d[Qi],o-=d[Qi]+d[Zi]):i.autoSizeAlign||(s=d[Qi]));const c={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,n){Xi=t,zi=t.rows,Ni=t.bounds,ji=!Ni.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:l,height:d}=Ni;if(l||d||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Ui=!0,Ii=null,Pi=Oi=Mi=Ai=Ti=0,Ei={data:[]},Li={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)Wi=i[n],"\n"===Wi?(Ai&&qi(),Li.paraEnd=!0,Hi(),Ui=!0):(Di=wi(Wi),Di===xi&&"none"!==o&&(Wi=mi(Wi,o,!Ai)),Oi=r.measureText(Wi).width,s&&(s<0&&(Mi=Oi),Oi+=s),Fi=Di===bi&&(Ii===bi||Ii===xi)||Ii===bi&&Di!==ki,Yi=!(Di!==Bi&&Di!==bi||Ii!==Ri&&Ii!==ki),Ci=Ui&&a?l-a:l,t&&l&&Ti+Ai+Oi>Ci&&(e?(Ai&&qi(),Ti&&Hi()):(Yi||(Yi=Di===xi&&Ii==ki),Fi||Yi||Di===Si||Di===Bi||Di===bi||Ai+Oi>Ci?(Ai&&qi(),Ti&&Hi()):Ti&&Hi()))," "===Wi&&!0!==Ui&&Ti+Ai===0||(Di===Si?(" "===Wi&&Ai&&qi(),Gi(Wi,Oi),qi()):Fi||Yi?(Ai&&qi(),Gi(Wi,Oi)):Gi(Wi,Oi)),Ii=Di);Ai&&qi(),Ti&&Hi(),zi.length>0&&(zi[zi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Xi.paraNumber++,Ti=r.measureText(t).width,zi.push({x:a||0,text:t,width:Ti,paraStart:!0}),ji&&Vi()}))}(c,t,i),d&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Ki(e,"x",t[$i]);break;case"right":Ki(e,"x",-t[Ji])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ki(e,"y",t[Qi]);break;case"bottom":Ki(e,"y",-t[Zi])}}(d,c,i,a,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,w=a*s+(h?h*(t.paraNumber-1):0),y=o;if(l&&w>_)w=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=s;o<c;o++){if(m=i[o],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&o>0&&(y+=h),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=w}(c,i),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:o}=e;let r,l,d,c,h,u;n.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&u>1?(i-t.width-d)/(u-1):0,c=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===c?(h={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(c,i,a),c.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=n+s-d;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],l=t.x+t.width,!(n===i&&l<c));n--){if(l<c&&" "!==t.char||!n){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(c,i,n,a),"none"!==r&&function(t,e){let i;const{fontSize:n,textDecoration:s}=e;switch(t.decorationHeight=n/11,"object"==typeof s?(i=s.type,s.color&&(t.decorationColor=I.string(s.color))):i=s,i){case"under":t.decorationY=[.15*n];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n,.35*-n]}}(c,i),c}};const en={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!I.object)return t;t=I.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(X,tn),Object.assign(I,en),Object.assign(N,jt),Object.assign(D,Be),Object.assign(F,Ne),Object.assign(j,Je);const{setPoint:nn,addPoint:sn,toBounds:an}=z;const on={syncExport(t,e,i){let n;this.running=!0;const s=q.fileType(e),a=e.includes(".");i=q.getExportOptions(i);const{toURL:o}=H,{download:r}=H.origin;if("json"===s)a&&r(o(JSON.stringify(t.toJSON(i.json)),"text"),e),n={data:!!a||t.toJSON(i.json)};else if("svg"===s)a&&r(o(t.toSVG(),"svg"),e),n={data:!!a||t.toSVG()};else{let s,a,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=i,y=void 0===i.smooth?!c||c.config.smooth:i.smooth,m=i.contextSettings||(c?c.config.contextSettings:void 0),v=d&&g&&void 0===i.fill?t.fill:i.fill,x=q.isOpaqueImage(e)||v,b=new V;if(g)s=!0===g?d?c.canvas.bounds:t.worldRenderBounds:g;else{let e=i.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}s=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};Q.getScaleData(i.scale,i.size,s,B);let k=i.pixelRatio||1,{x:R,y:S,width:E,height:L}=new G(s).scale(B.scaleX,B.scaleY);f&&(R+=f.x,S+=f.y,E=f.width,L=f.height);const A={matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-R,-S).withScale(1/o*B.scaleX,1/r*B.scaleY)};let T,C=J.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:k,smooth:y,contextSettings:m});if(u&&(T=t,T.__worldOpacity=0,t=c||t,A.bounds=C.bounds),C.save(),h&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(C,A),t.fill=e}else t.__render(C,A);if(C.restore(),T&&T.__updateWorldOpacity(),p){a=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?sn(o,s,a):nn(o={},s,a)),r++;const l=new G;return an(o,l),l.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:i}=a,n={x:0,y:0,width:e,height:i,pixelRatio:k};C=J.canvas(n),C.copyWorld(t,a,n)}if(_){const[t,e,i,n]=Q.fourNumber(_),s=C,{width:a,height:o}=s;C=J.canvas({width:a+n+e,height:o+t+i,pixelRatio:k}),C.copyWorld(s,s.bounds,{x:n,y:t,width:a,height:o})}x&&C.fillWorld(C.bounds,v||"#FFFFFF","destination-over"),w&&w(C);n={data:"canvas"===e?C:C.export(e,i),width:C.pixelWidth,height:C.pixelHeight,renderBounds:s,trimBounds:a}}return this.running=!1,n},export(t,e,i){return this.running=!0,function(t){rn||(rn=new Z);return new Promise((e=>{rn.add((()=>nt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((n=>new Promise((s=>{const a=()=>nt(this,void 0,void 0,(function*(){if(!$.isComplete)return H.requestRender(a);const o=on.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),n(o),s()}));t.updateLayout(),ln(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))))}};let rn;function ln(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>ln(t)))}const dn=K.prototype,cn=tt.get("@leafer-in/export");dn.export=function(t,e){const{quality:i,blob:n}=q.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},dn.toBlob=function(t,e){return new Promise((i=>{H.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{cn.error(t),i(null)}))}))},dn.toDataURL=function(t,e){return H.origin.canvasToDataURL(this.view,t,e)},dn.saveAs=function(t,e){return new Promise((i=>{H.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{cn.error(t),i(!1)}))}))},et.add("export"),Object.assign(Y,on),it.prototype.export=function(t,e){return Y.export(this,t,e)},it.prototype.syncExport=function(t,e){return Y.syncExport(this,t,e)},Object.assign(s,{interaction:(t,e,i,n)=>new M(t,e,i,n),hitCanvas:(t,e)=>new st(t,e),hitCanvasManager:()=>new P});export{mt as Layouter,st as LeaferCanvas,Bt as Picker,xt as Renderer,kt as Selector,lt as Watcher,rt as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Plugin as k,MatrixHelper as S,MathHelper as R,AlignHelper as E,PointHelper as L,ImageEvent as A,AroundHelper as T,Direction4 as C}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as O}from"fs";import{HitCanvasManager as W,InteractionBase as P}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as M,Paint as D,ColorConvert as I,PaintGradient as F,Export as U,Group as Y,TextConvert as X,Effect as N,TwoPointBoundsHelper as j,Bounds as z,FileHelper as G,Platform as q,Matrix as H,MathHelper as V,Creator as Q,TaskProcessor as J,Resource as Z,LeaferCanvasBase as $,Debug as K,Plugin as tt,UI as et}from"@leafer-ui/draw";function it(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{l(s.next(t))}catch(t){a(t)}}function r(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}l((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class st extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:nt,fileType:at}=s;function ot(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}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))},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(nt(e),i),canvasToBolb:(t,e,i)=>it(this,void 0,void 0,(function*(){return t.toBuffer(nt(e),i)})),canvasSaveAs:(t,e,i)=>it(this,void 0,void 0,(function*(){return O(e,t.toBuffer(nt(at(e)),i))})),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new st(t,e),image:t=>new a(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class rt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=l.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 c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:lt,updateBounds:dt,updateChange:ht}=f,{pushAllChildBranch:ct,pushAllParent:ut}=p;const{worldBounds:ft}=g;class pt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ft)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,ft),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:gt,updateAllChange:_t}=f,wt=w.get("Layouter");class yt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.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.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){wt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?wt.warn("layouting"):this.times>3?wt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(s);r.forEach((t=>t.setBefore())),i.emitEvent(new m(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?(lt(t,!0),e.add(t),t.isBranch&&ct(t,e),ut(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ut(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||dt(s[t])}dt(i)}}))}(this.__levelList),function(t){t.list.forEach(ht)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),yt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(s,a,this.times)),e.emitEvent(new m(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){gt(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),_t(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new pt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new pt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[m.REQUEST,this.layout,this],[m.AGAIN,this.layoutAgain,this],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const mt=w.get("Renderer");class vt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach((t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()})),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,mt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,mt.error(t)}mt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return mt.warn("rendering");if(this.times>3)return mt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);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,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)})))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(vt.clipSpread).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0),this.__render(s,n),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,e){const{canvas:i}=this,s=t.includes(this.target.__world),n=s?{includes:s}:{bounds:t,includes:s};this.needFill&&i.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(i,t),this.target.__render(i,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),i.updateRender(e)}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=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-i))),this.requestTime=0,this.checkRender()}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||mt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[m.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}vt.clipSpread=10;const{hitRadiusPoint:xt}=B;class bt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const 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=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,l=this.getBestMatchLeaf(o,i.bottomList,n),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:o.length?this.getThroughPath(o):d}:{path:d,target:l}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:s,y:n}=this.point,a={x:s,y:n,radiusX:0,radiusY:0};for(let s=0,n=t.length;s<n;s++)if(e=t[s],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new r;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 r,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}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}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||xt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Bt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new bt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):k.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function kt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach((t=>{e.fillText(t.char,t.x,a.y)}));if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach((t=>n.forEach((i=>e.fillRect(t.x,t.y+i,t.width,a)))))}}function St(t,e){t.__.__font?kt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Rt(t,e,i){switch(e.__.strokeAlign){case"center":Et(t,1,e,i);break;case"inside":Lt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?Et(t,2,e,i):Lt(t,"outside",e,i)}}function Et(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.strokeWidth*e,n),n.__isStrokes?Ct(t,!0,i,s):Tt(i,s)}function Lt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,Et(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",kt(i,n),n.blendMode="normal",At(s,n,i),n.recycle(i.__nowWorld)}function At(t,i,s){s.__worldFlipped||e.fullImageShadow?t.copyWorldByReset(i,s.__nowWorld):t.copyWorldToInner(i,s.__nowWorld,s.__layout.renderBounds)}function Tt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)}));if(a){const{decorationHeight:t}=s;n.forEach((i=>a.forEach((s=>e.strokeRect(i.x,i.y+s,i.width,t)))))}}function Ct(t,e,i,s){let n;for(let a=0,o=t.length;a<o;a++)n=t[a],n.image&&M.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Tt(i,s):s.stroke(),s.restoreBlendMode()):e?Tt(i,s):s.stroke())}function Ot(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Rt(t,e,i);else switch(s.strokeAlign){case"center":Wt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Wt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Wt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Wt(t,2,e,a),a.clipUI(s),a.clearWorld(n),At(i,a,e),a.recycle(e.__nowWorld)}}(t,e,i)}}function Wt(t,e,i,s){const n=i.__;s.setStroke(!n.__isStrokes&&t,n.__strokeWidth*e,n),n.__isStrokes?Ct(t,!1,i,s):s.stroke(),n.__useArrow&&D.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new rt(t,e),layouter:(t,e)=>new yt(t,e),renderer:(t,e,i)=>new vt(t,e,i),selector:(t,e)=>new Bt(t,e)}),e.layout=yt.fullLayout;const{getSpread:Pt,getOuterOf:Mt,getByMove:Dt,getIntersectData:It}=B;let Ft;const{stintSet:Ut}=l,{hasTransparent:Yt}=I;function Xt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=M.image(i,t,e,n,!Ft||!Ft[e.url]);break;case"linear":s=F.linearGradient(e,n);break;case"radial":s=F.radialGradient(e,n);break;case"angular":s=F.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;s={type:a,style:I.string(o,r)};break;default:void 0!==e.r&&(s={type:"solid",style:I.string(e)})}return s&&("string"==typeof s.style&&Yt(s.style)&&(s.isTransparent=!0),e.blendMode&&(s.blendMode=e.blendMode)),s}const Nt={compute:function(t,e){const i=e.__,s=[];let n,a,o=i.__input[t];o instanceof Array||(o=[o]),Ft=M.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Xt(t,o[n],e))&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s.every((t=>t.isTransparent))&&(s.some((t=>t.image))&&(n=!0),a=!0),"fill"===t?(Ut(i,"__isAlphaPixelFill",n),Ut(i,"__isTransparentFill",a)):(Ut(i,"__isAlphaPixelStroke",n),Ut(i,"__isTransparentStroke",a))},fill:function(t,e,i){i.fillStyle=t,St(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(M.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),St(e,i),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),St(e,i),i.restoreBlendMode()):St(e,i)}},fillPathOrText:St,fillText:kt,stroke:Ot,strokes:function(t,e,i){Ot(t,e,i)},strokeText:Rt,drawTextStroke:Tt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:h}=n;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(n))l=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,c=It(s?Pt(e.bounds,d===h?s*d:[s*h,s*d]):e.bounds,n);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,i),d*=u,h*=f),r=Mt(n,o),a=Dt(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:l,shapeBounds:r,scaleX:d,scaleY:h}}};let jt={};const{get:zt,rotateOfOuter:Gt,translate:qt,scaleOfOuter:Ht,scale:Vt,rotate:Qt}=S;function Jt(t,e,i,s,n,a,o){const r=zt();qt(r,e.x+i,e.y+s),Vt(r,n,a),o&&Gt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Zt(t,e,i,s,n,a,o){const r=zt();qt(r,e.x+i,e.y+s),n&&Vt(r,n,a),o&&Qt(r,o),t.transform=r}function $t(t,e,i,s,n,a,o,r,l,d){const h=zt();if(l)if("center"===d)Gt(h,{x:i/2,y:s/2},l);else switch(Qt(h,l),l){case 90:qt(h,s,0);break;case 180:qt(h,i,s);break;case 270:qt(h,0,i)}jt.x=e.x+n,jt.y=e.y+a,qt(h,jt.x,jt.y),o&&Ht(h,jt,o,r),t.transform=h}const{get:Kt,translate:te}=S,ee=new _,ie={},se={};function ne(t,e,i,s){const{changeful:n,sync:a}=i;n&&(t.changeful=n),a&&(t.sync=a),t.data=ae(i,s,e)}function ae(t,e,i){t.padding&&(e=ee.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:o,align:r,offset:l,scale:d,size:h,rotation:c,repeat:u,filters:f}=t,p=e.width===s&&e.height===n,g={mode:o},_="center"!==r&&(c||0)%180==90;let w,y;switch(B.set(se,0,0,_?n:s,_?s:n),o&&"cover"!==o&&"fit"!==o?((d||h)&&(R.getScaleData(d,h,i,ie),w=ie.scaleX,y=ie.scaleY),r&&(w&&B.scale(se,w,y,!0),E.toPoint(r,se,e,se,!0,!0))):p&&!c||(w=y=B.getFitScale(e,se,"fit"!==o),B.put(e,i,r,w,!1,se),B.scale(se,w,y,!0)),l&&L.move(se,l),o){case"stretch":p||(s=e.width,n=e.height);break;case"normal":case"clip":(se.x||se.y||w||c)&&Zt(g,e,se.x,se.y,w,y,c);break;case"repeat":(!p||w||c)&&$t(g,e,s,n,se.x,se.y,w,y,c,r),u||(g.repeat="repeat");break;default:w&&Jt(g,e,se.x,se.y,w,y,c)}return g.transform||(e.x||e.y)&&(g.transform=Kt(),te(g.transform,e.x,e.y)),w&&"stretch"!==o&&(g.scaleX=w,g.scaleY=y),g.width=s,g.height=n,a&&(g.opacity=a),f&&(g.filters=f),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let oe,re=new _;const{isSame:le}=B;function de(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||ne(n,s,i,a),!0}function he(t,e){fe(t,A.LOAD,e)}function ce(t,e){fe(t,A.LOADED,e)}function ue(t,e,i){e.error=i,t.forceUpdate("surface"),fe(t,A.ERROR,e)}function fe(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function pe(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ge,scale:_e,copy:we}=S,{ceil:ye,abs:me}=Math;function ve(t,i,s){let{scaleX:n,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=n+"-"+a+"-"+s;if(i.patternId===o||t.destroyed)return!1;{n=me(n),a=me(a);const{image:t,data:r}=i;let l,d,{width:h,height:c,scaleX:u,scaleY:f,transform:p,repeat:g}=r;u&&(d=ge(),we(d,p),_e(d,1/u,1/f),n*=u,a*=f),n*=s,a*=s,h*=n,c*=a;const _=h*c;if(!g&&_>e.image.maxCacheSize)return!1;let w=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}_>w&&(l=Math.sqrt(_/w)),l&&(n/=l,a/=l,h/=l,c/=l),u&&(n/=u,a/=f),(p||1!==n||1!==a)&&(d||(d=ge(),p&&we(d,p)),_e(d,1/n,1/a));const y=t.getCanvas(ye(h)||1,ye(c)||1,r.opacity,r.filters),m=t.getPattern(y,g||e.origin.noRepeat||"no-repeat",d,i);return i.style=m,i.patternId=o,!0}}const{abs:xe}=Math;const be={image:function(t,e,i,s,n){let a,o;const r=x.get(i);return oe&&i===oe.paint&&le(s,oe.boxBounds)?a=oe.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),oe=r.use>1?{leafPaint:a,paint:i,boxBounds:re.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(de(t,e,i,r,a,s),n&&(he(t,o),ce(t,o))):r.error?n&&ue(t,o,r.error):(n&&(pe(t,!0),he(t,o)),a.loadId=r.load((()=>{pe(t,!1),t.destroyed||(de(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ce(t,o)),a.loadId=null}),(e=>{pe(t,!1),ue(t,o,e),a.loadId=null})),t.placeholderColor&&(t.placeholderDelay?setTimeout((()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))}),t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i,{data:l}=s;if(!l||s.patternId===a+"-"+o+"-"+r&&!U.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||b.isResizing(t)||U.running)){let{width:t,height:i}=l;t*=xe(a)*r,i*=xe(o)*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||U.running?ve(t,s,r):s.patternTask||(s.patternTask=x.patternTasker.add((()=>it(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ve(t,s,r),t.forceUpdate("surface")}))),300)),!1)},createPattern:ve,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,x.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],o instanceof Array||(o=[o])),n.unload(i[l].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:ne,getPatternData:ae,fillOrFitMode:Jt,clipMode:Zt,repeatMode:$t},{toPoint:Be}=T,{hasTransparent:ke}=I,Se={},Re={};function Ee(t,e,i,s){if(i){let n,a,o,r;for(let t=0,l=i.length;t<l;t++)n=i[t],"string"==typeof n?(o=t/(l-1),a=I.string(n,s)):(o=n.offset,a=I.string(n.color,s)),e.addColorStop(o,a),!r&&ke(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Le,getDistance:Ae}=L,{get:Te,rotateOfOuter:Ce,scaleOfOuter:Oe}=S,{toPoint:We}=T,Pe={},Me={};function De(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=Le(e,i);a=Te(),n?(Oe(a,e,o/r*(s||1),1),Ce(a,e,t+90)):(Oe(a,e,1,o/r*(s||1)),Ce(a,e,t))}return a}const{getDistance:Ie}=L,{toPoint:Fe}=T,Ue={},Ye={};const Xe={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:o}=t;Be(s||"top",i,Se),Be(n||"bottom",i,Re);const r=e.canvas.createLinearGradient(Se.x,Se.y,Re.x,Re.y),l={type:a,style:r};return Ee(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;We(s||"center",i,Pe),We(n||"bottom",i,Me);const l=e.canvas.createRadialGradient(Pe.x,Pe.y,0,Pe.x,Pe.y,Ae(Pe,Me)),d={type:a,style:l};Ee(d,l,t.stops,o);const h=De(i,Pe,Me,r,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Fe(s||"center",i,Ue),Fe(n||"bottom",i,Ye);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ue.x,Ue.y):e.canvas.createRadialGradient(Ue.x,Ue.y,0,Ue.x,Ue.y,Ie(Ue,Ye)),d={type:a,style:l};Ee(d,l,t.stops,o);const h=De(i,Ue,Ye,r||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:De},{copy:Ne,toOffsetOutBounds:je}=B,ze={},Ge={};function qe(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(Ne(ze,t.bounds),ze.x+=i.x-o.x,ze.y+=i.y-o.y,s){const{matrix:t}=n;ze.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),ze.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),ze.width*=s,ze.height*=s}t.copyWorld(n.canvas,t.bounds,ze)}else s&&(Ne(ze,i),ze.x-=i.width/2*(s-1),ze.y-=i.height/2*(s-1),ze.width*=s,ze.height*=s),t.copyWorld(n.canvas,o,s?ze:i)}const{toOffsetOutBounds:He}=B,Ve={};const Qe={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;je(d,Ge),r.forEach(((r,g)=>{f.setWorldShadow(Ge.offsetX+r.x*c,Ge.offsetY+r.y*u,r.blur*c,I.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,qe(f,Ge,n,i),s=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),s=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),p&&g<p&&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:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;He(d,Ve),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ve.offsetX+r.x*c,Ve.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,qe(f,Ve,n,i),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,h,d,"source-out"),s=d),f.fillWorld(s,I.string(r.color),"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(s,!0)})),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:Je}=g;function Ze(t,e,i,s,n,a){switch(e){case"grayscale":n.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,s){const n=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,n),s.recycle(n),Ke(t,e,i,1)}(t,i,s,n);break;case"opacity-path":Ke(t,i,s,a);break;case"path":i.restore()}}function $e(t){return t.getSameCanvas(!1,!0)}function Ke(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}Y.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)i=l[d],r=i.__.mask,r&&(o&&(Ze(this,o,t,n,s,a),s=n=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,n||(n=$e(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=$e(t)),n||(n=$e(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||Je(i,e)||i.__render(n||t,e);Ze(this,o,t,n,s,a)};const ti=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ei=ti+"_#~&*+\\=|≮≯≈≠=…",ii=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 si(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ni=si("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ai=si("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),oi=si(ti),ri=si(ei),li=si("- —/~|┆·");var di;!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"}(di||(di={}));const{Letter:hi,Single:ci,Before:ui,After:fi,Symbol:pi,Break:gi}=di;function _i(t){return ni[t]?hi:li[t]?gi:ai[t]?ui:oi[t]?fi:ri[t]?pi:ii.test(t)?ci:hi}const wi={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 yi(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:mi}=wi,{Letter:vi,Single:xi,Before:bi,After:Bi,Symbol:ki,Break:Si}=di;let Ri,Ei,Li,Ai,Ti,Ci,Oi,Wi,Pi,Mi,Di,Ii,Fi,Ui,Yi,Xi,Ni,ji=[];function zi(t,e){Pi&&!Wi&&(Wi=Pi),Ri.data.push({char:t,width:e}),Li+=e}function Gi(){Ai+=Li,Ri.width=Li,Ei.words.push(Ri),Ri={data:[]},Li=0}function qi(){Ui&&(Yi.paraNumber++,Ei.paraStart=!0,Ui=!1),Pi&&(Ei.startCharSize=Wi,Ei.endCharSize=Pi,Wi=0),Ei.width=Ai,Xi.width?mi(Ei):Ni&&Hi(),ji.push(Ei),Ei={words:[]},Ai=0}function Hi(){Ai>(Yi.maxWidth||0)&&(Yi.maxWidth=Ai)}const{top:Vi,right:Qi,bottom:Ji,left:Zi}=C;function $i(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 Ki={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:l,__padding:d}=i;d&&(a?(s=d[Zi],a-=d[Qi]+d[Zi]):i.autoSizeAlign||(s=d[Zi]),o?(n=d[Vi],o-=d[Vi]+d[Ji]):i.autoSizeAlign||(n=d[Vi]));const h={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Yi=t,ji=t.rows,Xi=t.bounds,Ni=!Xi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:l,height:d}=Xi;if(l||d||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Ui=!0,Di=null,Wi=Oi=Pi=Li=Ai=0,Ri={data:[]},Ei={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Ci=i[s],"\n"===Ci?(Li&&Gi(),Ei.paraEnd=!0,qi(),Ui=!0):(Mi=_i(Ci),Mi===vi&&"none"!==o&&(Ci=yi(Ci,o,!Li)),Oi=r.measureText(Ci).width,n&&(n<0&&(Pi=Oi),Oi+=n),Ii=Mi===xi&&(Di===xi||Di===vi)||Di===xi&&Mi!==Bi,Fi=!(Mi!==bi&&Mi!==xi||Di!==ki&&Di!==Bi),Ti=Ui&&a?l-a:l,t&&l&&Ai+Li+Oi>Ti&&(e?(Li&&Gi(),Ai&&qi()):(Fi||(Fi=Mi===vi&&Di==Bi),Ii||Fi||Mi===Si||Mi===bi||Mi===xi||Li+Oi>Ti?(Li&&Gi(),Ai&&qi()):Ai&&qi()))," "===Ci&&!0!==Ui&&Ai+Li===0||(Mi===Si?(" "===Ci&&Li&&Gi(),zi(Ci,Oi),Gi()):Ii||Fi?(Li&&Gi(),zi(Ci,Oi)):zi(Ci,Oi)),Di=Mi);Li&&Gi(),Ai&&qi(),ji.length>0&&(ji[ji.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Yi.paraNumber++,Ai=r.measureText(t).width,ji.push({x:a||0,text:t,width:Ai,paraStart:!0}),Ni&&Hi()}))}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":$i(e,"x",t[Zi]);break;case"right":$i(e,"x",-t[Qi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":$i(e,"y",t[Vi]);break;case"bottom":$i(e,"y",-t[Ji])}}(d,h,i,a,o),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=o;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let o=0,h=n;o<h;o++){if(m=i[o],m.x=f,m.width<g||m.width>g&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&o>0&&(y+=c),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&g&&g<x&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,d,h,c,u;s.forEach((t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach(((e,i)=>{1===h?(c={char:"",x:r},r=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,r,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):r=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(r+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,h=s+n-d;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,s,a),"none"!==r&&function(t,e){let i;const{fontSize:s,textDecoration:n}=e;switch(t.decorationHeight=s/11,"object"==typeof n?(i=n.type,n.color&&(t.decorationColor=I.string(n.color))):i=n,i){case"under":t.decorationY=[.15*s];break;case"delete":t.decorationY=[.35*-s];break;case"under-delete":t.decorationY=[.15*s,.35*-s]}}(h,i),h}};const ts={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!I.object)return t;t=I.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(X,Ki),Object.assign(I,ts),Object.assign(D,Nt),Object.assign(M,be),Object.assign(F,Xe),Object.assign(N,Qe);const{setPoint:es,addPoint:is,toBounds:ss}=j;const ns={syncExport(t,e,i){let s;this.running=!0;const n=G.fileType(e),a=e.includes(".");i=G.getExportOptions(i);const{toURL:o}=q,{download:r}=q.origin;if("json"===n)a&&r(o(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!a||t.toJSON(i.json)};else if("svg"===n)a&&r(o(t.toSVG(),"svg"),e),s={data:!!a||t.toSVG()};else{let n,a,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:h,isFrame:c}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=i,y=void 0===i.smooth?!h||h.config.smooth:i.smooth,m=i.contextSettings||(h?h.config.contextSettings:void 0),v=d&&g&&void 0===i.fill?t.fill:i.fill,x=G.isOpaqueImage(e)||v,b=new H;if(g)n=!0===g?d?h.canvas.bounds:t.worldRenderBounds:g;else{let e=i.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=h||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}n=t.getBounds("render",e)}const B={scaleX:1,scaleY:1};V.getScaleData(i.scale,i.size,n,B);let k=i.pixelRatio||1,{x:S,y:R,width:E,height:L}=new z(n).scale(B.scaleX,B.scaleY);f&&(S+=f.x,R+=f.y,E=f.width,L=f.height);const A={matrix:b.scale(1/B.scaleX,1/B.scaleY).invert().translate(-S,-R).withScale(1/o*B.scaleX,1/r*B.scaleY)};let T,C=Q.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:k,smooth:y,contextSettings:m});if(u&&(T=t,T.__worldOpacity=0,t=h||t,A.bounds=C.bounds),C.save(),c&&void 0!==v){const e=t.get("fill");t.fill="",t.__render(C,A),t.fill=e}else t.__render(C,A);if(C.restore(),T&&T.__updateWorldOpacity(),p){a=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?is(o,n,a):es(o={},n,a)),r++;const l=new z;return ss(o,l),l.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:k};C=Q.canvas(s),C.copyWorld(t,a,s)}if(_){const[t,e,i,s]=V.fourNumber(_),n=C,{width:a,height:o}=n;C=Q.canvas({width:a+s+e,height:o+t+i,pixelRatio:k}),C.copyWorld(n,n.bounds,{x:s,y:t,width:a,height:o})}x&&C.fillWorld(C.bounds,v||"#FFFFFF","destination-over"),w&&w(C);s={data:"canvas"===e?C:C.export(e,i),width:C.pixelWidth,height:C.pixelHeight,renderBounds:n,trimBounds:a}}return this.running=!1,s},export(t,e,i){return this.running=!0,function(t){as||(as=new J);return new Promise((e=>{as.add((()=>it(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const a=()=>it(this,void 0,void 0,(function*(){if(!Z.isComplete)return q.requestRender(a);const o=ns.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),n()}));t.updateLayout(),os(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))))}};let as;function os(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>os(t)))}const rs=$.prototype,ls=K.get("@leafer-in/export");rs.export=function(t,e){const{quality:i,blob:s}=G.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},rs.toBlob=function(t,e){return new Promise((i=>{q.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{ls.error(t),i(null)}))}))},rs.toDataURL=function(t,e){return q.origin.canvasToDataURL(this.view,t,e)},rs.saveAs=function(t,e){return new Promise((i=>{q.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{ls.error(t),i(!1)}))}))},tt.add("export"),Object.assign(U,ns),et.prototype.export=function(t,e){return U.export(this,t,e)},et.prototype.syncExport=function(t,e){return U.syncExport(this,t,e)},Object.assign(n,{interaction:(t,e,i,s)=>new P(t,e,i,s),hitCanvas:(t,e)=>new st(t,e),hitCanvasManager:()=>new W});export{yt as Layouter,st as LeaferCanvas,bt as Picker,vt as Renderer,Bt as Selector,rt as Watcher,ot as useCanvas};
|
|
2
2
|
//# sourceMappingURL=node.esm.min.js.map
|