@leafer-ui/node 1.2.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node.cjs +40 -150
- package/dist/node.esm.js +40 -151
- package/dist/node.esm.min.js +1 -1
- package/dist/node.min.cjs +1 -1
- package/package.json +11 -10
- package/src/index.ts +2 -0
- package/types/index.d.ts +1 -0
package/dist/node.cjs
CHANGED
|
@@ -100,6 +100,7 @@ function useCanvas(canvasType, power) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
core.Platform.name = 'node';
|
|
103
|
+
core.Platform.backgrounder = true;
|
|
103
104
|
core.Platform.requestRender = function (render) { setTimeout(render, 16); };
|
|
104
105
|
core.defineKey(core.Platform, 'devicePixelRatio', { get() { return 1; } });
|
|
105
106
|
core.Platform.conicGradientSupport = true;
|
|
@@ -815,143 +816,26 @@ class Picker {
|
|
|
815
816
|
}
|
|
816
817
|
}
|
|
817
818
|
|
|
818
|
-
const { Yes, NoAndSkip, YesAndSkip } = core.Answer;
|
|
819
|
-
const idCondition = {}, classNameCondition = {}, tagCondition = {};
|
|
820
819
|
class Selector {
|
|
821
820
|
constructor(target, userConfig) {
|
|
822
821
|
this.config = {};
|
|
823
|
-
this.innerIdMap = {};
|
|
824
|
-
this.idMap = {};
|
|
825
|
-
this.methods = {
|
|
826
|
-
id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
|
|
827
|
-
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
|
|
828
|
-
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
829
|
-
tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
|
|
830
|
-
tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
|
|
831
|
-
};
|
|
832
|
-
this.target = target;
|
|
833
822
|
if (userConfig)
|
|
834
823
|
this.config = core.DataHelper.default(userConfig, this.config);
|
|
835
|
-
this.picker = new Picker(target, this);
|
|
836
|
-
|
|
837
|
-
this.__listenEvents();
|
|
838
|
-
}
|
|
839
|
-
getBy(condition, branch, one, options) {
|
|
840
|
-
switch (typeof condition) {
|
|
841
|
-
case 'number':
|
|
842
|
-
const leaf = this.getByInnerId(condition, branch);
|
|
843
|
-
return one ? leaf : (leaf ? [leaf] : []);
|
|
844
|
-
case 'string':
|
|
845
|
-
switch (condition[0]) {
|
|
846
|
-
case '#':
|
|
847
|
-
idCondition.id = condition.substring(1), condition = idCondition;
|
|
848
|
-
break;
|
|
849
|
-
case '.':
|
|
850
|
-
classNameCondition.className = condition.substring(1), condition = classNameCondition;
|
|
851
|
-
break;
|
|
852
|
-
default:
|
|
853
|
-
tagCondition.tag = condition, condition = tagCondition;
|
|
854
|
-
}
|
|
855
|
-
case 'object':
|
|
856
|
-
if (condition.id !== undefined) {
|
|
857
|
-
const leaf = this.getById(condition.id, branch);
|
|
858
|
-
return one ? leaf : (leaf ? [leaf] : []);
|
|
859
|
-
}
|
|
860
|
-
else if (condition.tag) {
|
|
861
|
-
const { tag } = condition, isArray = tag instanceof Array;
|
|
862
|
-
return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? core.DataHelper.toMap(tag) : tag);
|
|
863
|
-
}
|
|
864
|
-
else {
|
|
865
|
-
return this.getByMethod(this.methods.className, branch, one, condition.className);
|
|
866
|
-
}
|
|
867
|
-
case 'function':
|
|
868
|
-
return this.getByMethod(condition, branch, one, options);
|
|
869
|
-
}
|
|
824
|
+
this.picker = new Picker(this.target = target, this);
|
|
825
|
+
this.finder = core.Creator.finder && core.Creator.finder();
|
|
870
826
|
}
|
|
871
827
|
getByPoint(hitPoint, hitRadius, options) {
|
|
872
|
-
if (core.Platform.
|
|
873
|
-
this.target.
|
|
828
|
+
if (core.Platform.backgrounder && this.target)
|
|
829
|
+
this.target.updateLayout();
|
|
874
830
|
return this.picker.getByPoint(hitPoint, hitRadius, options);
|
|
875
831
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
if (cache)
|
|
879
|
-
return cache;
|
|
880
|
-
this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
|
|
881
|
-
return this.findLeaf;
|
|
882
|
-
}
|
|
883
|
-
getById(id, branch) {
|
|
884
|
-
const cache = this.idMap[id];
|
|
885
|
-
if (cache && core.LeafHelper.hasParent(cache, branch || this.target))
|
|
886
|
-
return cache;
|
|
887
|
-
this.eachFind(this.toChildren(branch), this.methods.id, null, id);
|
|
888
|
-
return this.findLeaf;
|
|
889
|
-
}
|
|
890
|
-
getByClassName(className, branch) {
|
|
891
|
-
return this.getByMethod(this.methods.className, branch, false, className);
|
|
892
|
-
}
|
|
893
|
-
getByTag(tag, branch) {
|
|
894
|
-
return this.getByMethod(this.methods.tag, branch, false, tag);
|
|
895
|
-
}
|
|
896
|
-
getByMethod(method, branch, one, options) {
|
|
897
|
-
const list = one ? null : [];
|
|
898
|
-
this.eachFind(this.toChildren(branch), method, list, options);
|
|
899
|
-
return list || this.findLeaf;
|
|
900
|
-
}
|
|
901
|
-
eachFind(children, method, list, options) {
|
|
902
|
-
let child, result;
|
|
903
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
904
|
-
child = children[i];
|
|
905
|
-
result = method(child, options);
|
|
906
|
-
if (result === Yes || result === YesAndSkip) {
|
|
907
|
-
if (list) {
|
|
908
|
-
list.push(child);
|
|
909
|
-
}
|
|
910
|
-
else {
|
|
911
|
-
this.findLeaf = child;
|
|
912
|
-
return;
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
if (child.isBranch && result < NoAndSkip)
|
|
916
|
-
this.eachFind(child.children, method, list, options);
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
toChildren(branch) {
|
|
920
|
-
this.findLeaf = null;
|
|
921
|
-
return [branch || this.target];
|
|
922
|
-
}
|
|
923
|
-
__onRemoveChild(event) {
|
|
924
|
-
const { id, innerId } = event.child;
|
|
925
|
-
if (this.idMap[id])
|
|
926
|
-
delete this.idMap[id];
|
|
927
|
-
if (this.innerIdMap[innerId])
|
|
928
|
-
delete this.innerIdMap[innerId];
|
|
929
|
-
}
|
|
930
|
-
__checkIdChange(event) {
|
|
931
|
-
if (event.attrName === 'id') {
|
|
932
|
-
const id = event.oldValue;
|
|
933
|
-
if (this.idMap[id])
|
|
934
|
-
delete this.idMap[id];
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
__listenEvents() {
|
|
938
|
-
this.__eventIds = [
|
|
939
|
-
this.target.on_(core.ChildEvent.REMOVE, this.__onRemoveChild, this),
|
|
940
|
-
this.target.on_(core.PropertyEvent.CHANGE, this.__checkIdChange, this)
|
|
941
|
-
];
|
|
942
|
-
}
|
|
943
|
-
__removeListenEvents() {
|
|
944
|
-
this.target.off_(this.__eventIds);
|
|
945
|
-
this.__eventIds.length = 0;
|
|
832
|
+
getBy(condition, branch, one, options) {
|
|
833
|
+
return this.finder ? this.finder.getBy(condition, branch, one, options) : core.Plugin.need('find');
|
|
946
834
|
}
|
|
947
835
|
destroy() {
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
this.
|
|
951
|
-
this.findLeaf = null;
|
|
952
|
-
this.innerIdMap = {};
|
|
953
|
-
this.idMap = {};
|
|
954
|
-
}
|
|
836
|
+
this.picker.destroy();
|
|
837
|
+
if (this.finder)
|
|
838
|
+
this.finder.destroy();
|
|
955
839
|
}
|
|
956
840
|
}
|
|
957
841
|
|
|
@@ -2442,7 +2326,14 @@ const ColorConvertModule = {
|
|
|
2442
2326
|
string
|
|
2443
2327
|
};
|
|
2444
2328
|
|
|
2445
|
-
|
|
2329
|
+
Object.assign(draw.TextConvert, TextConvertModule);
|
|
2330
|
+
Object.assign(draw.ColorConvert, ColorConvertModule);
|
|
2331
|
+
Object.assign(draw.Paint, PaintModule);
|
|
2332
|
+
Object.assign(draw.PaintImage, PaintImageModule);
|
|
2333
|
+
Object.assign(draw.PaintGradient, PaintGradientModule);
|
|
2334
|
+
Object.assign(draw.Effect, EffectModule);
|
|
2335
|
+
|
|
2336
|
+
const { setPoint, addPoint, toBounds } = draw.TwoPointBoundsHelper;
|
|
2446
2337
|
function getTrimBounds(canvas) {
|
|
2447
2338
|
const { width, height } = canvas.view;
|
|
2448
2339
|
const { data } = canvas.context.getImageData(0, 0, width, height);
|
|
@@ -2455,7 +2346,7 @@ function getTrimBounds(canvas) {
|
|
|
2455
2346
|
}
|
|
2456
2347
|
index++;
|
|
2457
2348
|
}
|
|
2458
|
-
const bounds = new
|
|
2349
|
+
const bounds = new draw.Bounds();
|
|
2459
2350
|
toBounds(pointBounds, bounds);
|
|
2460
2351
|
return bounds.scale(1 / canvas.pixelRatio).ceil();
|
|
2461
2352
|
}
|
|
@@ -2463,17 +2354,17 @@ function getTrimBounds(canvas) {
|
|
|
2463
2354
|
const ExportModule = {
|
|
2464
2355
|
export(leaf, filename, options) {
|
|
2465
2356
|
this.running = true;
|
|
2466
|
-
const fileType =
|
|
2357
|
+
const fileType = draw.FileHelper.fileType(filename);
|
|
2467
2358
|
const isDownload = filename.includes('.');
|
|
2468
|
-
options =
|
|
2359
|
+
options = draw.FileHelper.getExportOptions(options);
|
|
2469
2360
|
return addTask((success) => new Promise((resolve) => {
|
|
2470
2361
|
const over = (result) => {
|
|
2471
2362
|
success(result);
|
|
2472
2363
|
resolve();
|
|
2473
2364
|
this.running = false;
|
|
2474
2365
|
};
|
|
2475
|
-
const { toURL } =
|
|
2476
|
-
const { download } =
|
|
2366
|
+
const { toURL } = draw.Platform;
|
|
2367
|
+
const { download } = draw.Platform.origin;
|
|
2477
2368
|
if (fileType === 'json') {
|
|
2478
2369
|
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
2479
2370
|
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
@@ -2493,7 +2384,7 @@ const ExportModule = {
|
|
|
2493
2384
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
2494
2385
|
const screenshot = options.screenshot || leaf.isApp;
|
|
2495
2386
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
2496
|
-
const needFill =
|
|
2387
|
+
const needFill = draw.FileHelper.isOpaqueImage(filename) || fill, matrix = new draw.Matrix();
|
|
2497
2388
|
if (screenshot) {
|
|
2498
2389
|
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
2499
2390
|
}
|
|
@@ -2525,16 +2416,16 @@ const ExportModule = {
|
|
|
2525
2416
|
renderBounds = leaf.getBounds('render', relative);
|
|
2526
2417
|
}
|
|
2527
2418
|
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
2528
|
-
|
|
2419
|
+
draw.MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
2529
2420
|
let pixelRatio = options.pixelRatio || 1;
|
|
2530
2421
|
if (leaf.isApp) {
|
|
2531
2422
|
scaleData.scaleX *= pixelRatio;
|
|
2532
2423
|
scaleData.scaleY *= pixelRatio;
|
|
2533
2424
|
pixelRatio = leaf.app.pixelRatio;
|
|
2534
2425
|
}
|
|
2535
|
-
const { x, y, width, height } = new
|
|
2426
|
+
const { x, y, width, height } = new draw.Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
2536
2427
|
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
2537
|
-
let canvas =
|
|
2428
|
+
let canvas = draw.Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
2538
2429
|
let sliceLeaf;
|
|
2539
2430
|
if (slice) {
|
|
2540
2431
|
sliceLeaf = leaf;
|
|
@@ -2559,7 +2450,7 @@ const ExportModule = {
|
|
|
2559
2450
|
trimBounds = getTrimBounds(canvas);
|
|
2560
2451
|
const old = canvas, { width, height } = trimBounds;
|
|
2561
2452
|
const config = { x: 0, y: 0, width, height, pixelRatio };
|
|
2562
|
-
canvas =
|
|
2453
|
+
canvas = draw.Creator.canvas(config);
|
|
2563
2454
|
canvas.copyWorld(old, trimBounds, config);
|
|
2564
2455
|
}
|
|
2565
2456
|
if (needFill)
|
|
@@ -2579,7 +2470,7 @@ const ExportModule = {
|
|
|
2579
2470
|
let tasker;
|
|
2580
2471
|
function addTask(task) {
|
|
2581
2472
|
if (!tasker)
|
|
2582
|
-
tasker = new
|
|
2473
|
+
tasker = new draw.TaskProcessor();
|
|
2583
2474
|
return new Promise((resolve) => {
|
|
2584
2475
|
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
2585
2476
|
});
|
|
@@ -2591,10 +2482,10 @@ function checkLazy(leaf) {
|
|
|
2591
2482
|
leaf.children.forEach(child => checkLazy(child));
|
|
2592
2483
|
}
|
|
2593
2484
|
|
|
2594
|
-
const canvas =
|
|
2595
|
-
const debug =
|
|
2485
|
+
const canvas = draw.LeaferCanvasBase.prototype;
|
|
2486
|
+
const debug = draw.Debug.get('@leafer-in/export');
|
|
2596
2487
|
canvas.export = function (filename, options) {
|
|
2597
|
-
const { quality, blob } =
|
|
2488
|
+
const { quality, blob } = draw.FileHelper.getExportOptions(options);
|
|
2598
2489
|
if (filename.includes('.'))
|
|
2599
2490
|
return this.saveAs(filename, quality);
|
|
2600
2491
|
else if (blob)
|
|
@@ -2604,7 +2495,7 @@ canvas.export = function (filename, options) {
|
|
|
2604
2495
|
};
|
|
2605
2496
|
canvas.toBlob = function (type, quality) {
|
|
2606
2497
|
return new Promise((resolve) => {
|
|
2607
|
-
|
|
2498
|
+
draw.Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
2608
2499
|
resolve(blob);
|
|
2609
2500
|
}).catch((e) => {
|
|
2610
2501
|
debug.error(e);
|
|
@@ -2613,11 +2504,11 @@ canvas.toBlob = function (type, quality) {
|
|
|
2613
2504
|
});
|
|
2614
2505
|
};
|
|
2615
2506
|
canvas.toDataURL = function (type, quality) {
|
|
2616
|
-
return
|
|
2507
|
+
return draw.Platform.origin.canvasToDataURL(this.view, type, quality);
|
|
2617
2508
|
};
|
|
2618
2509
|
canvas.saveAs = function (filename, quality) {
|
|
2619
2510
|
return new Promise((resolve) => {
|
|
2620
|
-
|
|
2511
|
+
draw.Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
2621
2512
|
resolve(true);
|
|
2622
2513
|
}).catch((e) => {
|
|
2623
2514
|
debug.error(e);
|
|
@@ -2626,13 +2517,11 @@ canvas.saveAs = function (filename, quality) {
|
|
|
2626
2517
|
});
|
|
2627
2518
|
};
|
|
2628
2519
|
|
|
2629
|
-
|
|
2630
|
-
Object.assign(draw.ColorConvert, ColorConvertModule);
|
|
2631
|
-
Object.assign(draw.Paint, PaintModule);
|
|
2632
|
-
Object.assign(draw.PaintImage, PaintImageModule);
|
|
2633
|
-
Object.assign(draw.PaintGradient, PaintGradientModule);
|
|
2634
|
-
Object.assign(draw.Effect, EffectModule);
|
|
2520
|
+
draw.Plugin.add('export');
|
|
2635
2521
|
Object.assign(draw.Export, ExportModule);
|
|
2522
|
+
draw.UI.prototype.export = function (filename, options) {
|
|
2523
|
+
return draw.Export.export(this, filename, options);
|
|
2524
|
+
};
|
|
2636
2525
|
|
|
2637
2526
|
Object.assign(core.Creator, {
|
|
2638
2527
|
interaction: (target, canvas, selector, options) => { return new core$1.InteractionBase(target, canvas, selector, options); },
|
|
@@ -2646,6 +2535,7 @@ Object.defineProperty(exports, "LeaferImage", {
|
|
|
2646
2535
|
});
|
|
2647
2536
|
exports.Layouter = Layouter;
|
|
2648
2537
|
exports.LeaferCanvas = LeaferCanvas;
|
|
2538
|
+
exports.Picker = Picker;
|
|
2649
2539
|
exports.Renderer = Renderer;
|
|
2650
2540
|
exports.Selector = Selector;
|
|
2651
2541
|
exports.Watcher = Watcher;
|
package/dist/node.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, BoundsHelper,
|
|
1
|
+
import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, BoundsHelper, Plugin, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4 } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
export { LeaferImage } from '@leafer/core';
|
|
4
4
|
import { writeFileSync } from 'fs';
|
|
5
5
|
import { InteractionBase, HitCanvasManager } from '@leafer-ui/core';
|
|
6
6
|
export * from '@leafer-ui/core';
|
|
7
|
-
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect } from '@leafer-ui/draw';
|
|
7
|
+
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect, Bounds as Bounds$1, TwoPointBoundsHelper, FileHelper as FileHelper$1, TaskProcessor, Platform as Platform$1, Matrix, MathHelper as MathHelper$1, Creator as Creator$1, LeaferCanvasBase as LeaferCanvasBase$1, Debug as Debug$1, Plugin as Plugin$1, UI } from '@leafer-ui/draw';
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
10
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -101,6 +101,7 @@ function useCanvas(canvasType, power) {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
Platform.name = 'node';
|
|
104
|
+
Platform.backgrounder = true;
|
|
104
105
|
Platform.requestRender = function (render) { setTimeout(render, 16); };
|
|
105
106
|
defineKey(Platform, 'devicePixelRatio', { get() { return 1; } });
|
|
106
107
|
Platform.conicGradientSupport = true;
|
|
@@ -816,143 +817,26 @@ class Picker {
|
|
|
816
817
|
}
|
|
817
818
|
}
|
|
818
819
|
|
|
819
|
-
const { Yes, NoAndSkip, YesAndSkip } = Answer;
|
|
820
|
-
const idCondition = {}, classNameCondition = {}, tagCondition = {};
|
|
821
820
|
class Selector {
|
|
822
821
|
constructor(target, userConfig) {
|
|
823
822
|
this.config = {};
|
|
824
|
-
this.innerIdMap = {};
|
|
825
|
-
this.idMap = {};
|
|
826
|
-
this.methods = {
|
|
827
|
-
id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
|
|
828
|
-
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
|
|
829
|
-
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
830
|
-
tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
|
|
831
|
-
tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
|
|
832
|
-
};
|
|
833
|
-
this.target = target;
|
|
834
823
|
if (userConfig)
|
|
835
824
|
this.config = DataHelper.default(userConfig, this.config);
|
|
836
|
-
this.picker = new Picker(target, this);
|
|
837
|
-
|
|
838
|
-
this.__listenEvents();
|
|
839
|
-
}
|
|
840
|
-
getBy(condition, branch, one, options) {
|
|
841
|
-
switch (typeof condition) {
|
|
842
|
-
case 'number':
|
|
843
|
-
const leaf = this.getByInnerId(condition, branch);
|
|
844
|
-
return one ? leaf : (leaf ? [leaf] : []);
|
|
845
|
-
case 'string':
|
|
846
|
-
switch (condition[0]) {
|
|
847
|
-
case '#':
|
|
848
|
-
idCondition.id = condition.substring(1), condition = idCondition;
|
|
849
|
-
break;
|
|
850
|
-
case '.':
|
|
851
|
-
classNameCondition.className = condition.substring(1), condition = classNameCondition;
|
|
852
|
-
break;
|
|
853
|
-
default:
|
|
854
|
-
tagCondition.tag = condition, condition = tagCondition;
|
|
855
|
-
}
|
|
856
|
-
case 'object':
|
|
857
|
-
if (condition.id !== undefined) {
|
|
858
|
-
const leaf = this.getById(condition.id, branch);
|
|
859
|
-
return one ? leaf : (leaf ? [leaf] : []);
|
|
860
|
-
}
|
|
861
|
-
else if (condition.tag) {
|
|
862
|
-
const { tag } = condition, isArray = tag instanceof Array;
|
|
863
|
-
return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
|
|
864
|
-
}
|
|
865
|
-
else {
|
|
866
|
-
return this.getByMethod(this.methods.className, branch, one, condition.className);
|
|
867
|
-
}
|
|
868
|
-
case 'function':
|
|
869
|
-
return this.getByMethod(condition, branch, one, options);
|
|
870
|
-
}
|
|
825
|
+
this.picker = new Picker(this.target = target, this);
|
|
826
|
+
this.finder = Creator.finder && Creator.finder();
|
|
871
827
|
}
|
|
872
828
|
getByPoint(hitPoint, hitRadius, options) {
|
|
873
|
-
if (Platform.
|
|
874
|
-
this.target.
|
|
829
|
+
if (Platform.backgrounder && this.target)
|
|
830
|
+
this.target.updateLayout();
|
|
875
831
|
return this.picker.getByPoint(hitPoint, hitRadius, options);
|
|
876
832
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
if (cache)
|
|
880
|
-
return cache;
|
|
881
|
-
this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
|
|
882
|
-
return this.findLeaf;
|
|
883
|
-
}
|
|
884
|
-
getById(id, branch) {
|
|
885
|
-
const cache = this.idMap[id];
|
|
886
|
-
if (cache && LeafHelper.hasParent(cache, branch || this.target))
|
|
887
|
-
return cache;
|
|
888
|
-
this.eachFind(this.toChildren(branch), this.methods.id, null, id);
|
|
889
|
-
return this.findLeaf;
|
|
890
|
-
}
|
|
891
|
-
getByClassName(className, branch) {
|
|
892
|
-
return this.getByMethod(this.methods.className, branch, false, className);
|
|
893
|
-
}
|
|
894
|
-
getByTag(tag, branch) {
|
|
895
|
-
return this.getByMethod(this.methods.tag, branch, false, tag);
|
|
896
|
-
}
|
|
897
|
-
getByMethod(method, branch, one, options) {
|
|
898
|
-
const list = one ? null : [];
|
|
899
|
-
this.eachFind(this.toChildren(branch), method, list, options);
|
|
900
|
-
return list || this.findLeaf;
|
|
901
|
-
}
|
|
902
|
-
eachFind(children, method, list, options) {
|
|
903
|
-
let child, result;
|
|
904
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
905
|
-
child = children[i];
|
|
906
|
-
result = method(child, options);
|
|
907
|
-
if (result === Yes || result === YesAndSkip) {
|
|
908
|
-
if (list) {
|
|
909
|
-
list.push(child);
|
|
910
|
-
}
|
|
911
|
-
else {
|
|
912
|
-
this.findLeaf = child;
|
|
913
|
-
return;
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
if (child.isBranch && result < NoAndSkip)
|
|
917
|
-
this.eachFind(child.children, method, list, options);
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
toChildren(branch) {
|
|
921
|
-
this.findLeaf = null;
|
|
922
|
-
return [branch || this.target];
|
|
923
|
-
}
|
|
924
|
-
__onRemoveChild(event) {
|
|
925
|
-
const { id, innerId } = event.child;
|
|
926
|
-
if (this.idMap[id])
|
|
927
|
-
delete this.idMap[id];
|
|
928
|
-
if (this.innerIdMap[innerId])
|
|
929
|
-
delete this.innerIdMap[innerId];
|
|
930
|
-
}
|
|
931
|
-
__checkIdChange(event) {
|
|
932
|
-
if (event.attrName === 'id') {
|
|
933
|
-
const id = event.oldValue;
|
|
934
|
-
if (this.idMap[id])
|
|
935
|
-
delete this.idMap[id];
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
__listenEvents() {
|
|
939
|
-
this.__eventIds = [
|
|
940
|
-
this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this),
|
|
941
|
-
this.target.on_(PropertyEvent.CHANGE, this.__checkIdChange, this)
|
|
942
|
-
];
|
|
943
|
-
}
|
|
944
|
-
__removeListenEvents() {
|
|
945
|
-
this.target.off_(this.__eventIds);
|
|
946
|
-
this.__eventIds.length = 0;
|
|
833
|
+
getBy(condition, branch, one, options) {
|
|
834
|
+
return this.finder ? this.finder.getBy(condition, branch, one, options) : Plugin.need('find');
|
|
947
835
|
}
|
|
948
836
|
destroy() {
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
this.
|
|
952
|
-
this.findLeaf = null;
|
|
953
|
-
this.innerIdMap = {};
|
|
954
|
-
this.idMap = {};
|
|
955
|
-
}
|
|
837
|
+
this.picker.destroy();
|
|
838
|
+
if (this.finder)
|
|
839
|
+
this.finder.destroy();
|
|
956
840
|
}
|
|
957
841
|
}
|
|
958
842
|
|
|
@@ -2443,6 +2327,13 @@ const ColorConvertModule = {
|
|
|
2443
2327
|
string
|
|
2444
2328
|
};
|
|
2445
2329
|
|
|
2330
|
+
Object.assign(TextConvert, TextConvertModule);
|
|
2331
|
+
Object.assign(ColorConvert, ColorConvertModule);
|
|
2332
|
+
Object.assign(Paint, PaintModule);
|
|
2333
|
+
Object.assign(PaintImage, PaintImageModule);
|
|
2334
|
+
Object.assign(PaintGradient, PaintGradientModule);
|
|
2335
|
+
Object.assign(Effect, EffectModule);
|
|
2336
|
+
|
|
2446
2337
|
const { setPoint, addPoint, toBounds } = TwoPointBoundsHelper;
|
|
2447
2338
|
function getTrimBounds(canvas) {
|
|
2448
2339
|
const { width, height } = canvas.view;
|
|
@@ -2456,7 +2347,7 @@ function getTrimBounds(canvas) {
|
|
|
2456
2347
|
}
|
|
2457
2348
|
index++;
|
|
2458
2349
|
}
|
|
2459
|
-
const bounds = new Bounds();
|
|
2350
|
+
const bounds = new Bounds$1();
|
|
2460
2351
|
toBounds(pointBounds, bounds);
|
|
2461
2352
|
return bounds.scale(1 / canvas.pixelRatio).ceil();
|
|
2462
2353
|
}
|
|
@@ -2464,17 +2355,17 @@ function getTrimBounds(canvas) {
|
|
|
2464
2355
|
const ExportModule = {
|
|
2465
2356
|
export(leaf, filename, options) {
|
|
2466
2357
|
this.running = true;
|
|
2467
|
-
const fileType = FileHelper.fileType(filename);
|
|
2358
|
+
const fileType = FileHelper$1.fileType(filename);
|
|
2468
2359
|
const isDownload = filename.includes('.');
|
|
2469
|
-
options = FileHelper.getExportOptions(options);
|
|
2360
|
+
options = FileHelper$1.getExportOptions(options);
|
|
2470
2361
|
return addTask((success) => new Promise((resolve) => {
|
|
2471
2362
|
const over = (result) => {
|
|
2472
2363
|
success(result);
|
|
2473
2364
|
resolve();
|
|
2474
2365
|
this.running = false;
|
|
2475
2366
|
};
|
|
2476
|
-
const { toURL } = Platform;
|
|
2477
|
-
const { download } = Platform.origin;
|
|
2367
|
+
const { toURL } = Platform$1;
|
|
2368
|
+
const { download } = Platform$1.origin;
|
|
2478
2369
|
if (fileType === 'json') {
|
|
2479
2370
|
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
2480
2371
|
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
@@ -2494,7 +2385,7 @@ const ExportModule = {
|
|
|
2494
2385
|
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
2495
2386
|
const screenshot = options.screenshot || leaf.isApp;
|
|
2496
2387
|
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
2497
|
-
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
2388
|
+
const needFill = FileHelper$1.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
2498
2389
|
if (screenshot) {
|
|
2499
2390
|
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
2500
2391
|
}
|
|
@@ -2526,16 +2417,16 @@ const ExportModule = {
|
|
|
2526
2417
|
renderBounds = leaf.getBounds('render', relative);
|
|
2527
2418
|
}
|
|
2528
2419
|
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
2529
|
-
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
2420
|
+
MathHelper$1.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
2530
2421
|
let pixelRatio = options.pixelRatio || 1;
|
|
2531
2422
|
if (leaf.isApp) {
|
|
2532
2423
|
scaleData.scaleX *= pixelRatio;
|
|
2533
2424
|
scaleData.scaleY *= pixelRatio;
|
|
2534
2425
|
pixelRatio = leaf.app.pixelRatio;
|
|
2535
2426
|
}
|
|
2536
|
-
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
2427
|
+
const { x, y, width, height } = new Bounds$1(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
2537
2428
|
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
2538
|
-
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
2429
|
+
let canvas = Creator$1.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
2539
2430
|
let sliceLeaf;
|
|
2540
2431
|
if (slice) {
|
|
2541
2432
|
sliceLeaf = leaf;
|
|
@@ -2560,7 +2451,7 @@ const ExportModule = {
|
|
|
2560
2451
|
trimBounds = getTrimBounds(canvas);
|
|
2561
2452
|
const old = canvas, { width, height } = trimBounds;
|
|
2562
2453
|
const config = { x: 0, y: 0, width, height, pixelRatio };
|
|
2563
|
-
canvas = Creator.canvas(config);
|
|
2454
|
+
canvas = Creator$1.canvas(config);
|
|
2564
2455
|
canvas.copyWorld(old, trimBounds, config);
|
|
2565
2456
|
}
|
|
2566
2457
|
if (needFill)
|
|
@@ -2592,10 +2483,10 @@ function checkLazy(leaf) {
|
|
|
2592
2483
|
leaf.children.forEach(child => checkLazy(child));
|
|
2593
2484
|
}
|
|
2594
2485
|
|
|
2595
|
-
const canvas = LeaferCanvasBase.prototype;
|
|
2596
|
-
const debug = Debug.get('@leafer-
|
|
2486
|
+
const canvas = LeaferCanvasBase$1.prototype;
|
|
2487
|
+
const debug = Debug$1.get('@leafer-in/export');
|
|
2597
2488
|
canvas.export = function (filename, options) {
|
|
2598
|
-
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
2489
|
+
const { quality, blob } = FileHelper$1.getExportOptions(options);
|
|
2599
2490
|
if (filename.includes('.'))
|
|
2600
2491
|
return this.saveAs(filename, quality);
|
|
2601
2492
|
else if (blob)
|
|
@@ -2605,7 +2496,7 @@ canvas.export = function (filename, options) {
|
|
|
2605
2496
|
};
|
|
2606
2497
|
canvas.toBlob = function (type, quality) {
|
|
2607
2498
|
return new Promise((resolve) => {
|
|
2608
|
-
Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
2499
|
+
Platform$1.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
2609
2500
|
resolve(blob);
|
|
2610
2501
|
}).catch((e) => {
|
|
2611
2502
|
debug.error(e);
|
|
@@ -2614,11 +2505,11 @@ canvas.toBlob = function (type, quality) {
|
|
|
2614
2505
|
});
|
|
2615
2506
|
};
|
|
2616
2507
|
canvas.toDataURL = function (type, quality) {
|
|
2617
|
-
return Platform.origin.canvasToDataURL(this.view, type, quality);
|
|
2508
|
+
return Platform$1.origin.canvasToDataURL(this.view, type, quality);
|
|
2618
2509
|
};
|
|
2619
2510
|
canvas.saveAs = function (filename, quality) {
|
|
2620
2511
|
return new Promise((resolve) => {
|
|
2621
|
-
Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
2512
|
+
Platform$1.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
2622
2513
|
resolve(true);
|
|
2623
2514
|
}).catch((e) => {
|
|
2624
2515
|
debug.error(e);
|
|
@@ -2627,13 +2518,11 @@ canvas.saveAs = function (filename, quality) {
|
|
|
2627
2518
|
});
|
|
2628
2519
|
};
|
|
2629
2520
|
|
|
2630
|
-
|
|
2631
|
-
Object.assign(ColorConvert, ColorConvertModule);
|
|
2632
|
-
Object.assign(Paint, PaintModule);
|
|
2633
|
-
Object.assign(PaintImage, PaintImageModule);
|
|
2634
|
-
Object.assign(PaintGradient, PaintGradientModule);
|
|
2635
|
-
Object.assign(Effect, EffectModule);
|
|
2521
|
+
Plugin$1.add('export');
|
|
2636
2522
|
Object.assign(Export, ExportModule);
|
|
2523
|
+
UI.prototype.export = function (filename, options) {
|
|
2524
|
+
return Export.export(this, filename, options);
|
|
2525
|
+
};
|
|
2637
2526
|
|
|
2638
2527
|
Object.assign(Creator, {
|
|
2639
2528
|
interaction: (target, canvas, selector, options) => { return new InteractionBase(target, canvas, selector, options); },
|
|
@@ -2641,4 +2530,4 @@ Object.assign(Creator, {
|
|
|
2641
2530
|
hitCanvasManager: () => new HitCanvasManager()
|
|
2642
2531
|
});
|
|
2643
2532
|
|
|
2644
|
-
export { Layouter, LeaferCanvas, Renderer, Selector, Watcher, useCanvas };
|
|
2533
|
+
export { Layouter, LeaferCanvas, Picker, Renderer, Selector, Watcher, useCanvas };
|
package/dist/node.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as s,LeaferImage as n,defineKey as a,FileHelper as o,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,Bounds as _,LeafBoundsHelper as p,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Answer as R,MatrixHelper as k,MathHelper as S,AlignHelper as E,ImageEvent as L,AroundHelper as A,PointHelper as M,Direction4 as C,TwoPointBoundsHelper as T,TaskProcessor as W,Matrix as O}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as I}from"fs";import{InteractionBase as P,HitCanvasManager as D}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as F,ColorConvert as N,PaintGradient as Y,Export as U,Group as X,TextConvert as j,Paint as G,Effect as z}from"@leafer-ui/draw";function H(t,e,i,s){return new(i||(i=Promise))((function(n,a){function o(t){try{d(s.next(t))}catch(t){a(t)}}function r(t){try{d(s.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class V 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:q,fileType:Q}=o;function J(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(q(e),i),canvasToBolb:(t,e,i)=>H(this,void 0,void 0,(function*(){return t.toBuffer(q(e),i)})),canvasSaveAs:(t,e,i)=>H(this,void 0,void 0,(function*(){return I(e,t.toBuffer(q(Q(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=s.canvas()}}Object.assign(s,{canvas:(t,e)=>new V(t,e),image:t=>new n(t)}),e.name="node",e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class Z{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:$,updateAllWorldOpacity:tt}=f,{pushAllChildBranch:et,pushAllParent:it}=g;const{worldBounds:st}=p,nt={x:0,y:0,width:1e5,height:1e5};class at{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,st)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(nt):this.afterBounds.setListWithFn(t,st),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:ot,updateAllChange:rt}=f,dt=w.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){dt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?dt.warn("layouting"):this.times>3?dt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(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?(K(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(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||$(s[t])}$(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&tt(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new 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)),lt.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){ot(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new at([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new at(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ht=w.get("Renderer");class ct{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,ht.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,ht.error(t)}ht.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ht.warn("rendering");if(this.times>3)return ht.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return ht.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),a=new _(s);i.save(),n&&!w.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,a),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),w.showHitView&&this.renderHitView(s),w.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ht.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:ut}=B;class ft{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,n),l=n?this.getPath(d):this.getHitablePath(d);return this.clear(),s?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(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||ut(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask&&!s.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:gt,NoAndSkip:_t,YesAndSkip:pt}=R,wt={},yt={},mt={};class vt{constructor(t,e){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=t,e&&(this.config=d.default(e,this.config)),this.picker=new ft(t,this),t&&this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":wt.id=t.substring(1),t=wt;break;case".":yt.className=t.substring(1),t=yt;break;default:mt.tag=t,t=mt}case"object":if(void 0!==t.id){const s=this.getById(t.id,e);return i?s:s?[s]:[]}if(t.tag){const{tag:s}=t,n=s instanceof Array;return this.getByMethod(n?this.methods.tags:this.methods.tag,e,i,n?d.toMap(s):s)}return this.getByMethod(this.methods.className,e,i,t.className);case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,i,s){return"node"===e.name&&this.target&&this.target.emit(m.CHECK_UPDATE),this.picker.getByPoint(t,i,s)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&f.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,a;for(let o=0,r=t.length;o<r;o++){if(n=t[o],a=e(n,s),a===gt||a===pt){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&a<_t&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(h.REMOVE,this.__onRemoveChild,this),this.target.on_(u.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function xt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,a)}function bt(t,e,i){const{strokeAlign:s}=e.__,n="string"!=typeof t;switch(s){case"center":i.setStroke(n?void 0:t,e.__.strokeWidth,e.__),n?kt(t,!0,e,i):Rt(e,i);break;case"inside":Bt("inside",t,n,e,i);break;case"outside":Bt("outside",t,n,e,i)}}function Bt(t,e,i,s,n){const{__strokeWidth:a,__font:o}=s.__,r=n.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,s.__),r.font=o,i?kt(e,!0,s,r):Rt(s,r),r.blendMode="outside"===t?"destination-out":"destination-in",xt(s,r),r.blendMode="normal",s.__worldFlipped?n.copyWorldByReset(r,s.__nowWorld):n.copyWorldToInner(r,s.__nowWorld,s.__layout.renderBounds),r.recycle(s.__nowWorld)}function Rt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=s.length;t<o;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,a)}function kt(t,e,i,s){let n;for(let a=0,o=t.length;a<o;a++)n=t[a],n.image&&F.checkImage(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Rt(i,s):s.stroke(),s.restoreBlendMode()):e?Rt(i,s):s.stroke())}function St(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(s,{watcher:(t,e)=>new Z(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new ct(t,e,i),selector:(t,e)=>new vt(t,e)}),e.layout=lt.fullLayout;const{getSpread:Et,getOuterOf:Lt,getByMove:At,getIntersectData:Mt}=B;let Ct;function Tt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:a,color:o,opacity:r}=e;return{type:n,blendMode:a,style:N.string(o,r)};case"image":return F.image(i,t,e,s,!Ct||!Ct[e.url]);case"linear":return Y.linearGradient(e,s);case"radial":return Y.radialGradient(e,s);case"angular":return Y.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:N.string(e)}:void 0}}const Wt={compute:function(t,e){const i=e.__,s=[];let n,a=i.__input[t];a instanceof Array||(a=[a]),Ct=F.recycleImage(t,i);for(let i,n=0,o=a.length;n<o;n++)i=Tt(t,a[n],e),i&&s.push(i);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(n=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=n:i.__pixelStroke=n},fill:function(t,e,i){i.fillStyle=t,e.__.__font?xt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let s;const{windingRule:n,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&F.checkImage(e,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?xt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?xt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):a?xt(e,i):n?i.fill(n):i.fill())},fillText:xt,stroke:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)bt(t,e,i);else switch(a){case"center":i.setStroke(t,n,s),i.stroke(),s.__useArrow&&St(e,i);break;case"inside":i.save(),i.setStroke(t,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*n,s),e.__drawRenderPath(a),a.stroke(),s.windingRule?a.clip(s.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const s=e.__,{__strokeWidth:n,strokeAlign:a,__font:o}=s;if(n)if(o)bt(t,e,i);else switch(a){case"center":i.setStroke(void 0,n,s),kt(t,!1,e,i),s.__useArrow&&St(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*n,s),s.windingRule?i.clip(s.windingRule):i.clip(),kt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*n,s),kt(t,!1,e,o),s.windingRule?o.clip(s.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:bt,drawTextStroke:Rt,shape:function(t,e,i){const s=e.getSameCanvas(),n=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=n;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(n))d=s,a=r=n;else{const{renderShapeSpread:s}=t.__layout,c=Mt(s?Et(e.bounds,l===h?s*l:[s*h,s*l]):e.bounds,n);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=Lt(n,o),a=At(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(s,i),{canvas:s,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let Ot={};const{get:It,rotateOfOuter:Pt,translate:Dt,scaleOfOuter:Ft,scale:Nt,rotate:Yt}=k;function Ut(t,e,i,s,n,a,o){const r=It();Dt(r,e.x+i,e.y+s),Nt(r,n,a),o&&Pt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Xt(t,e,i,s,n,a,o){const r=It();Dt(r,e.x+i,e.y+s),n&&Nt(r,n,a),o&&Yt(r,o),t.transform=r}function jt(t,e,i,s,n,a,o,r,d,l){const h=It();if(d)if("center"===l)Pt(h,{x:i/2,y:s/2},d);else switch(Yt(h,d),d){case 90:Dt(h,s,0);break;case 180:Dt(h,i,s);break;case 270:Dt(h,0,i)}Ot.x=e.x+n,Ot.y=e.y+a,Dt(h,Ot.x,Ot.y),o&&Ft(h,Ot,o,r),t.transform=h}const{get:Gt,translate:zt}=k,Ht=new _,Vt={},qt={};function Qt(t,e,i,s){const{blendMode:n,sync:a}=i;n&&(t.blendMode=n),a&&(t.sync=a),t.data=Jt(i,s,e)}function Jt(t,e,i){let{width:s,height:n}=i;t.padding&&(e=Ht.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:a,mode:o,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u}=t,f=e.width===s&&e.height===n,g={mode:o},_="center"!==r&&(c||0)%180==90,p=_?n:s,w=_?s:n;let y,m,v=0,x=0;if(o&&"cover"!==o&&"fit"!==o)(l||h)&&(S.getScaleData(l,h,i,qt),y=qt.scaleX,m=qt.scaleY);else if(!f||c){const t=e.width/p,i=e.height/w;y=m="fit"===o?Math.min(t,i):Math.max(t,i),v+=(e.width-s*y)/2,x+=(e.height-n*m)/2}if(r){const t={x:v,y:x,width:p,height:w};y&&(t.width*=y,t.height*=m),E.toPoint(r,t,e,Vt,!0),v+=Vt.x,x+=Vt.y}switch(d&&(v+=d.x,x+=d.y),o){case"stretch":f||(s=e.width,n=e.height);break;case"normal":case"clip":(v||x||y||c)&&Xt(g,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&jt(g,e,s,n,v,x,y,m,c,r),u||(g.repeat="repeat");break;default:y&&Ut(g,e,v,x,y,m,c)}return g.transform||(e.x||e.y)&&(g.transform=Gt(),zt(g.transform,e.x,e.y)),y&&"stretch"!==o&&(g.scaleX=y,g.scaleY=m),g.width=s,g.height=n,a&&(g.opacity=a),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let Zt,Kt=new _;const{isSame:$t}=B;function te(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||Qt(n,s,i,a),!0}function ee(t,e){ne(t,L.LOAD,e)}function ie(t,e){ne(t,L.LOADED,e)}function se(t,e,i){e.error=i,t.forceUpdate("surface"),ne(t,L.ERROR,e)}function ne(t,e,i){t.hasEvent(e)&&t.emitEvent(new L(e,i))}function ae(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:oe,scale:re,copy:de}=k,{ceil:le,abs:he}=Math;function ce(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=he(n),a=he(a);const{image:t,data:r}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(l=oe(),de(l,_),re(l,1/u,1/f),n*=u,a*=f),n*=s,a*=s,h*=n,c*=a;const w=h*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(n/=d,a/=d,h/=d,c/=d),u&&(n/=u,a/=f),(_||1!==n||1!==a)&&(l||(l=oe(),_&&de(l,_)),re(l,1/n,1/a));const m=t.getCanvas(le(h)||1,le(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=o,!0}}const{abs:ue}=Math;const fe={image:function(t,e,i,s,n){let a,o;const r=x.get(i);return Zt&&i===Zt.paint&&$t(s,Zt.boxBounds)?a=Zt.leafPaint:(a={type:i.type,image:r},Zt=r.use>1?{leafPaint:a,paint:i,boxBounds:Kt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(te(t,e,i,r,a,s),n&&(ee(t,o),ie(t,o))):r.error?n&&se(t,o,r.error):(n&&(ae(t,!0),ee(t,o)),a.loadId=r.load((()=>{ae(t,!1),t.destroyed||(te(t,e,i,r,a,s)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ie(t,o)),a.loadId=null}),(e=>{ae(t,!1),se(t,o,e),a.loadId=null}))),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!s.data||s.patternId===a+"-"+o+"-"+r&&!U.running)return!1;{const{data:d}=s;if(n)if(d.repeat)n=!1;else{let{width:t,height:i}=d;t*=ue(a)*r,i*=ue(o)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),n=t*i>e.image.maxCacheSize||U.running}return n?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||U.running?ce(t,s,r):s.patternTask||(s.patternTask=x.patternTasker.add((()=>H(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ce(t,s,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:ce,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,o;for(let r=0,d=i.length;r<d;r++)s=i[r].image,o=s&&s.url,o&&(n||(n={}),n[o]=!0,x.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(i[r].loadId,!a.some((t=>t.url===o)))));return n}return null},createData:Qt,getPatternData:Jt,fillOrFitMode:Ut,clipMode:Xt,repeatMode:jt},{toPoint:ge}=A,_e={},pe={};function we(t,e,i){if(e){let s;for(let n=0,a=e.length;n<a;n++)s=e[n],"string"==typeof s?t.addColorStop(n/(a-1),N.string(s,i)):t.addColorStop(s.offset,N.string(s.color,i))}}const{getAngle:ye,getDistance:me}=M,{get:ve,rotateOfOuter:xe,scaleOfOuter:be}=k,{toPoint:Be}=A,Re={},ke={};function Se(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=ye(e,i);a=ve(),n?(be(a,e,o/r*(s||1),1),xe(a,e,t+90)):(be(a,e,1,o/r*(s||1)),xe(a,e,t))}return a}const{getDistance:Ee}=M,{toPoint:Le}=A,Ae={},Me={};const Ce={linearGradient:function(t,i){let{from:s,to:n,type:a,blendMode:o,opacity:r}=t;ge(s||"top",i,_e),ge(n||"bottom",i,pe);const d=e.canvas.createLinearGradient(_e.x,_e.y,pe.x,pe.y);we(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;Be(s||"center",i,Re),Be(n||"bottom",i,ke);const l=e.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,me(Re,ke));we(l,t.stops,o);const h={type:a,style:l},c=Se(i,Re,ke,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,blendMode:r,stretch:d}=t;Le(s||"center",i,Ae),Le(n||"bottom",i,Me);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ae.x,Ae.y):e.canvas.createRadialGradient(Ae.x,Ae.y,0,Ae.x,Ae.y,Ee(Ae,Me));we(l,t.stops,o);const h={type:a,style:l},c=Se(i,Ae,Me,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Se},{copy:Te,toOffsetOutBounds:We}=B,Oe={},Ie={};function Pe(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(Te(Oe,t.bounds),Oe.x+=i.x-o.x,Oe.y+=i.y-o.y,s){const{matrix:t}=n;Oe.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Oe.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Oe.width*=s,Oe.height*=s}t.copyWorld(n.canvas,t.bounds,Oe)}else s&&(Te(Oe,i),Oe.x-=i.width/2*(s-1),Oe.y-=i.height/2*(s-1),Oe.width*=s,Oe.height*=s),t.copyWorld(n.canvas,o,s?Oe:i)}const{toOffsetOutBounds:De}=B,Fe={};const Ne={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;We(l,Ie),r.forEach(((r,_)=>{f.setWorldShadow(Ie.offsetX+r.x*c,Ie.offsetY+r.y*u,r.blur*c,r.color),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Pe(f,Ie,n,i),s=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),s=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(s,!0)})),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;De(l,Fe),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Fe.offsetX+r.x*c,Fe.offsetY+r.y*u,r.blur*c),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Pe(f,Fe,n,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,h,l,"source-out"),s=l),f.fillWorld(s,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,s,a,r.blendMode):e.copyWorldToInner(f,s,o.renderBounds,r.blendMode),g&&_<g&&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:Ye}=p;function Ue(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),je(t,e,i,1)}(t,i,s,n);break;case"opacity-path":je(t,i,s,a);break;case"path":i.restore()}}function Xe(t){return t.getSameCanvas(!1,!0)}function je(t,e,i,s){const n=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,n),i.recycle(n)}X.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(o&&(Ue(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=Xe(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=Xe(t)),n||(n=Xe(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r)||Ye(i,e)||i.__render(n||t,e);Ue(this,o,t,n,s,a)};const Ge=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ze=Ge+"_#~&*+\\=|≮≯≈≠=…",He=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 Ve(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const qe=Ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Qe=Ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Je=Ve(Ge),Ze=Ve(ze),Ke=Ve("- —/~|┆·");var $e;!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"}($e||($e={}));const{Letter:ti,Single:ei,Before:ii,After:si,Symbol:ni,Break:ai}=$e;function oi(t){return qe[t]?ti:Ke[t]?ai:Qe[t]?ii:Je[t]?si:Ze[t]?ni:He.test(t)?ei:ti}const ri={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 di(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:li}=ri,{Letter:hi,Single:ci,Before:ui,After:fi,Symbol:gi,Break:_i}=$e;let pi,wi,yi,mi,vi,xi,bi,Bi,Ri,ki,Si,Ei,Li,Ai,Mi,Ci,Ti,Wi=[];function Oi(t,e){Ri&&!Bi&&(Bi=Ri),pi.data.push({char:t,width:e}),yi+=e}function Ii(){mi+=yi,pi.width=yi,wi.words.push(pi),pi={data:[]},yi=0}function Pi(){Ai&&(Mi.paraNumber++,wi.paraStart=!0,Ai=!1),Ri&&(wi.startCharSize=Bi,wi.endCharSize=Ri,Bi=0),wi.width=mi,Ci.width?li(wi):Ti&&Di(),Wi.push(wi),wi={words:[]},mi=0}function Di(){mi>(Mi.maxWidth||0)&&(Mi.maxWidth=mi)}const Fi=0,Ni=1,Yi=2;const{top:Ui,right:Xi,bottom:ji,left:Gi}=C;function zi(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 Hi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a?(s=l[Gi],a-=l[Xi]+l[Gi]):i.autoSizeAlign||(s=l[Gi]),o?(n=l[Ui],o-=l[Ui]+l[ji]):i.autoSizeAlign||(n=l[Ui]));const h={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,s){Mi=t,Wi=t.rows,Ci=t.bounds,Ti=!Ci.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:d,height:l}=Ci;if(d||l||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Ai=!0,Si=null,Bi=bi=Ri=yi=mi=0,pi={data:[]},wi={words:[]};for(let s=0,l=i.length;s<l;s++)xi=i[s],"\n"===xi?(yi&&Ii(),wi.paraEnd=!0,Pi(),Ai=!0):(ki=oi(xi),ki===hi&&"none"!==o&&(xi=di(xi,o,!yi)),bi=r.measureText(xi).width,n&&(n<0&&(Ri=bi),bi+=n),Ei=ki===ci&&(Si===ci||Si===hi)||Si===ci&&ki!==fi,Li=!(ki!==ui&&ki!==ci||Si!==gi&&Si!==fi),vi=Ai&&a?d-a:d,t&&d&&mi+yi+bi>vi&&(e?(yi&&Ii(),mi&&Pi()):(Li||(Li=ki===hi&&Si==fi),Ei||Li||ki===_i||ki===ui||ki===ci||yi+bi>vi?(yi&&Ii(),mi&&Pi()):mi&&Pi()))," "===xi&&!0!==Ai&&mi+yi===0||(ki===_i?(" "===xi&&yi&&Ii(),Oi(xi,bi),Ii()):Ei||Li?(yi&&Ii(),Oi(xi,bi)):Oi(xi,bi)),Si=ki);yi&&Ii(),mi&&Pi(),Wi.length>0&&(Wi[Wi.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Mi.paraNumber++,mi=r.measureText(t).width,Wi.push({x:a||0,text:t,width:mi,paraStart:!0}),Ti&&Di()}))}(h,t,i),l&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":zi(e,"x",t[Gi]);break;case"right":zi(e,"x",-t[Xi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":zi(e,"y",t[Ui]);break;case"bottom":zi(e,"y",-t[ji])}}(l,h,i,a,o),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:_}=s,p=n*i.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&p>_)p=Math.max(_,n),t.overflow=i.length;else if(_||c)switch(l){case"middle":f+=(_-p)/2;break;case"bottom":f+=_-p}w+=f;let y,m,v,x=g||c?g:t.maxWidth;for(let a=0,l=i.length;a<l;a++){if(y=i[a],y.x=u,y.width<g||y.width>g&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=n,t.overflow>a&&w>p&&(y.isOverflow=!0,t.overflow=a+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<s.x&&(s.x=m),v>s.width&&(s.width=v),r&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=f,s.height=p}(h,i),function(t,e,i,s){const{rows:n}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,h,c,u;n.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,l=i&&"justify"===a&&t.words.length>1?(i-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Fi:l>.01?Ni:Yi,t.isOverflow&&!r&&(t.textMode=!0),c===Yi?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Ni?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,s){return t.forEach((t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,h=s+n-l;("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],d=t.x+t.width,!(s===i&&d<h));s--){if(d<h&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,s,a),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(h,i),h}};const Vi={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!N.object)return t;t=N.object(t)}let s=void 0===t.a?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}},{setPoint:qi,addPoint:Qi,toBounds:Ji}=T;const Zi={export(t,i,n){this.running=!0;const a=o.fileType(i),r=i.includes(".");return n=o.getExportOptions(n),function(t){Ki||(Ki=new W);return new Promise((e=>{Ki.add((()=>H(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((d=>new Promise((l=>{const h=t=>{d(t),l(),this.running=!1},{toURL:c}=e,{download:u}=e.origin;if("json"===a)return r&&u(c(JSON.stringify(t.toJSON(n.json)),"text"),i),h({data:!!r||t.toJSON(n.json)});if("svg"===a)return r&&u(c(t.toSVG(),"svg"),i),h({data:!!r||t.toSVG()});const{leafer:f}=t;f?($i(t),f.waitViewCompleted((()=>H(this,void 0,void 0,(function*(){let e,a,r=1,d=1;const{worldTransform:l,isLeafer:c,isFrame:u}=t,{slice:g,trim:p,onCanvas:w}=n,y=void 0===n.smooth?f.config.smooth:n.smooth,m=n.contextSettings||f.config.contextSettings,v=n.screenshot||t.isApp,x=c&&v&&void 0===n.fill?t.fill:n.fill,b=o.isOpaqueImage(i)||x,B=new O;if(v)e=!0===v?c?f.canvas.bounds:t.worldRenderBounds:v;else{let i=n.relative||(c?"inner":"local");switch(r=l.scaleX,d=l.scaleY,i){case"inner":B.set(l);break;case"local":B.set(l).divide(t.localTransform),r/=t.scaleX,d/=t.scaleY;break;case"world":r=1,d=1;break;case"page":i=t.leafer;default:B.set(l).divide(t.getTransform(i));const e=i.worldTransform;r/=r/e.scaleX,d/=d/e.scaleY}e=t.getBounds("render",i)}const R={scaleX:1,scaleY:1};S.getScaleData(n.scale,n.size,e,R);let k=n.pixelRatio||1;t.isApp&&(R.scaleX*=k,R.scaleY*=k,k=t.app.pixelRatio);const{x:E,y:L,width:A,height:M}=new _(e).scale(R.scaleX,R.scaleY),C={matrix:B.scale(1/R.scaleX,1/R.scaleY).invert().translate(-E,-L).withScale(1/r*R.scaleX,1/d*R.scaleY)};let T,W=s.canvas({width:Math.round(A),height:Math.round(M),pixelRatio:k,smooth:y,contextSettings:m});if(g&&(T=t,T.__worldOpacity=0,t=f,C.bounds=W.bounds),W.save(),u&&void 0!==x){const e=t.get("fill");t.fill="",t.__render(W,C),t.fill=e}else t.__render(W,C);if(W.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?Qi(o,n,a):qi(o={},n,a)),r++;const d=new _;return Ji(o,d),d.scale(1/t.pixelRatio).ceil()}(W);const t=W,{width:e,height:i}=a,n={x:0,y:0,width:e,height:i,pixelRatio:k};W=s.canvas(n),W.copyWorld(t,a,n)}b&&W.fillWorld(W.bounds,x||"#FFFFFF","destination-over"),w&&w(W);const I="canvas"===i?W:yield W.export(i,n);h({data:I,width:W.pixelWidth,height:W.pixelHeight,renderBounds:e,trimBounds:a})}))))):h({data:!1})}))))}};let Ki;function $i(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>$i(t)))}const ts=t.prototype,es=w.get("@leafer-ui/export");ts.export=function(t,e){const{quality:i,blob:s}=o.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},ts.toBlob=function(t,i){return new Promise((s=>{e.origin.canvasToBolb(this.view,t,i).then((t=>{s(t)})).catch((t=>{es.error(t),s(null)}))}))},ts.toDataURL=function(t,i){return e.origin.canvasToDataURL(this.view,t,i)},ts.saveAs=function(t,i){return new Promise((s=>{e.origin.canvasSaveAs(this.view,t,i).then((()=>{s(!0)})).catch((t=>{es.error(t),s(!1)}))}))},Object.assign(j,Hi),Object.assign(N,Vi),Object.assign(G,Wt),Object.assign(F,fe),Object.assign(Y,Ce),Object.assign(z,Ne),Object.assign(U,Zi),Object.assign(s,{interaction:(t,e,i,s)=>new P(t,e,i,s),hitCanvas:(t,e)=>new V(t,e),hitCanvasManager:()=>new D});export{lt as Layouter,V as LeaferCanvas,ct as Renderer,vt as Selector,Z as Watcher,J as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as n,LeaferImage as s,defineKey as a,FileHelper as o,LeafList as r,DataHelper as d,RenderEvent as l,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,Bounds as _,LeafBoundsHelper as p,Debug as w,LeafLevelList as y,LayoutEvent as m,Run as v,ImageManager as x,ResizeEvent as b,BoundsHelper as B,Plugin as R,MatrixHelper as k,MathHelper as S,AlignHelper as L,ImageEvent as E,AroundHelper as A,PointHelper as W,Direction4 as T}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as O}from"fs";import{InteractionBase as C,HitCanvasManager as M}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as P,ColorConvert as D,PaintGradient as I,Export as F,Group as Y,TextConvert as U,Paint as X,Effect as N,Bounds as j,TwoPointBoundsHelper as z,FileHelper as G,TaskProcessor as H,Platform as q,Matrix as V,MathHelper as Q,Creator as J,LeaferCanvasBase as Z,Debug as $,Plugin as K,UI as tt}from"@leafer-ui/draw";function et(t,e,i,n){return new(i||(i=Promise))((function(s,a){function o(t){try{d(n.next(t))}catch(t){a(t)}}function r(t){try{d(n.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,r)}d((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class it extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:nt,fileType:st}=o;function at(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:n}=i;e.origin={createCanvas:(e,i,n)=>new t(e,i,n),canvasToDataURL:(t,e,i)=>t.toDataURL(nt(e),i),canvasToBolb:(t,e,i)=>et(this,void 0,void 0,(function*(){return t.toBuffer(nt(e),i)})),canvasSaveAs:(t,e,i)=>et(this,void 0,void 0,(function*(){return O(e,t.toBuffer(nt(st(e)),i))})),download(t,e){},loadImage:t=>n(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new it(t,e),image:t=>new s(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},a(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class ot{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;return this.__updatedList.list.forEach((e=>{e.leafer&&t.add(e)})),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new r,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(l.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.CHANGE,this.__onAttrChange,this),t.on_([h.ADD,h.REMOVE],this.__onChildEvent,this),t.on_(c.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:rt,updateBounds:dt,updateAllWorldOpacity:lt}=f,{pushAllChildBranch:ht,pushAllParent:ct}=g;const{worldBounds:ut}=p,ft={x:0,y:0,width:1e5,height:1e5};class gt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,t instanceof Array&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,ut)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(ft):this.afterBounds.setListWithFn(t,ut),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_t,updateAllChange:pt}=f,wt=w.get("Layouter");class yt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=d.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(m.START),this.layoutOnce(),t.emitEvent(new m(m.END,this.layoutedBlocks,this.times))}catch(t){wt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?wt.warn("layouting"):this.times>3?wt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:n}=this,{BEFORE:s,LAYOUT:a,AFTER:o}=m,r=this.getBlocks(n);r.forEach((t=>t.setBefore())),i.emitEvent(new m(s,r,this.times)),this.extraBlock=null,n.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(rt(t,!0),e.add(t),t.isBranch&&ht(t,e),ct(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),ct(t,e)))}))}(n,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||dt(n[t])}dt(i)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&<(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(n),this.extraBlock&&r.push(this.extraBlock),r.forEach((t=>t.setAfter())),i.emitEvent(new m(a,r,this.times)),i.emitEvent(new m(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:n,AFTER:s}=m,a=this.getBlocks(new r(e));e.emitEvent(new m(i,a,this.times)),yt.fullLayout(e),a.forEach((t=>{t.setAfter()})),e.emitEvent(new m(n,a,this.times)),e.emitEvent(new m(s,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){_t(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),pt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new gt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new gt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(m.REQUEST,this.layout,this),t.on_(m.AGAIN,this.layoutAgain,this),t.on_(c.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const mt=w.get("Renderer");class vt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=e,i&&(this.config=d.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(m.REQUEST)}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,mt.log(e.innerName,"---\x3e");try{e.isApp||e.app.emit(l.CHILD_START,e),this.emitRender(l.START),this.renderOnce(t),this.emitRender(l.END,this.totalBounds),x.clearRecycled()}catch(t){this.rendering=!1,mt.error(t)}mt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return mt.warn("rendering");if(this.times>3)return mt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(l.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(l.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(l.RENDER,this.renderBounds,this.renderOptions),this.emitRender(l.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return mt.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,n=t.getIntersect(i.bounds),s=t.includes(this.target.__world),a=new _(n);i.save(),s&&!w.showRepaint?i.clear():(n.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(n,!0),i.clipWorld(n,!0)),this.__render(n,s,a),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),v.end(t)}__render(t,e,i){const n=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),w.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,n),this.renderBounds=i=i||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),w.showHitView&&this.renderHitView(n),w.showBoundsView&&this.renderBoundsView(n),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){if(this.requestTime)return;const t=this.requestTime=Date.now();e.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(l.NEXT))}))}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||mt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,i){this.target.emitEvent(new l(t,this.times,e,i))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(l.REQUEST,this.update,this),t.on_(m.END,this.__onLayoutEnd,this),t.on_(l.AGAIN,this.renderAgain,this),t.on_(b.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:xt}=B;class bt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const n=i.through||!1,s=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new r(i.findList),i.findList||this.hitBranch(a);const{list:o}=this.findList,d=this.getBestMatchLeaf(o,i.bottomList,s),l=s?this.getPath(d):this.getHitablePath(d);return this.clear(),n?{path:l,target:d,throughPath:o.length?this.getThroughPath(o):l}:{path:l,target:d}}getBestMatchLeaf(t,e,i){if(t.length){let e;this.findList=new r;const{x:n,y:s}=this.point,a={x:n,y:s,radiusX:0,radiusY:0};for(let n=0,s=t.length;n<s;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,a),this.findList.length))return this.findList.list[0]}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),this.findList.length)return this.findList.list[0];return t[0]}getPath(t){const e=new r;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,n=new r;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(n.addAt(i,0),i.__.hitChildren);t--);return n}getThroughPath(t){const e=new r,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let n,s,a;for(let t=0,o=i.length;t<o;t++){n=i[t],s=i[t+1];for(let t=0,i=n.length;t<i&&(a=n.list[t],!s||!s.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,n;const{point:s}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(n=!!i.__.hitRadius||xt(i.__world,s),i.isBranch?(n||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,s)):n&&this.hitChild(i,s))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:n}=t;if(n&&n.__hasMask&&!t.__.mask&&!n.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class Bt{constructor(t,e){this.config={},e&&(this.config=d.default(e,this.config)),this.picker=new bt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,n){return e.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(t,i,n)}getBy(t,e,i,n){return this.finder?this.finder.getBy(t,e,i,n):R.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function Rt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),s&&e.fillRect(i.x,i.y+s,i.width,a)}function kt(t,e,i){const{strokeAlign:n}=e.__,s="string"!=typeof t;switch(n){case"center":i.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?Et(t,!0,e,i):Lt(e,i);break;case"inside":St("inside",t,s,e,i);break;case"outside":St("outside",t,s,e,i)}}function St(t,e,i,n,s){const{__strokeWidth:a,__font:o}=n.__,r=s.getSameCanvas(!0,!0);r.setStroke(i?void 0:e,2*a,n.__),r.font=o,i?Et(e,!0,n,r):Lt(n,r),r.blendMode="outside"===t?"destination-out":"destination-in",Rt(n,r),r.blendMode="normal",n.__worldFlipped?s.copyWorldByReset(r,n.__nowWorld):s.copyWorldToInner(r,n.__nowWorld,n.__layout.renderBounds),r.recycle(n.__nowWorld)}function Lt(t,e){let i;const{rows:n,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=n.length;t<o;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),s&&e.strokeRect(i.x,i.y+s,i.width,a)}function Et(t,e,i,n){let s;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&P.checkImage(i,n,s,!1)||s.style&&(n.strokeStyle=s.style,s.blendMode?(n.saveBlendMode(s.blendMode),e?Lt(i,n):n.stroke(),n.restoreBlendMode()):e?Lt(i,n):n.stroke())}function At(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(n,{watcher:(t,e)=>new ot(t,e),layouter:(t,e)=>new yt(t,e),renderer:(t,e,i)=>new vt(t,e,i),selector:(t,e)=>new Bt(t,e)}),e.layout=yt.fullLayout;const{getSpread:Wt,getOuterOf:Tt,getByMove:Ot,getIntersectData:Ct}=B;let Mt;function Pt(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:n}=i.__layout;switch(e.type){case"solid":let{type:s,blendMode:a,color:o,opacity:r}=e;return{type:s,blendMode:a,style:D.string(o,r)};case"image":return P.image(i,t,e,n,!Mt||!Mt[e.url]);case"linear":return I.linearGradient(e,n);case"radial":return I.radialGradient(e,n);case"angular":return I.conicGradient(e,n);default:return void 0!==e.r?{type:"solid",style:D.string(e)}:void 0}}const Dt={compute:function(t,e){const i=e.__,n=[];let s,a=i.__input[t];a instanceof Array||(a=[a]),Mt=P.recycleImage(t,i);for(let i,s=0,o=a.length;s<o;s++)i=Pt(t,a[s],e),i&&n.push(i);i["_"+t]=n.length?n:void 0,n.length&&n[0].image&&(s=n[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=s:i.__pixelStroke=s},fill:function(t,e,i){i.fillStyle=t,e.__.__font?Rt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fills:function(t,e,i){let n;const{windingRule:s,__font:a}=e.__;for(let o=0,r=t.length;o<r;o++)n=t[o],n.image&&P.checkImage(e,i,n,!a)||n.style&&(i.fillStyle=n.style,n.transform?(i.save(),i.transform(n.transform),n.blendMode&&(i.blendMode=n.blendMode),a?Rt(e,i):s?i.fill(s):i.fill(),i.restore()):n.blendMode?(i.saveBlendMode(n.blendMode),a?Rt(e,i):s?i.fill(s):i.fill(),i.restoreBlendMode()):a?Rt(e,i):s?i.fill(s):i.fill())},fillText:Rt,stroke:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)kt(t,e,i);else switch(a){case"center":i.setStroke(t,s,n),i.stroke(),n.__useArrow&&At(e,i);break;case"inside":i.save(),i.setStroke(t,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0,!0);a.setStroke(t,2*s,n),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?i.copyWorldByReset(a,e.__nowWorld):i.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,i){const n=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=n;if(s)if(o)kt(t,e,i);else switch(a){case"center":i.setStroke(void 0,s,n),Et(t,!1,e,i),n.__useArrow&&At(e,i);break;case"inside":i.save(),i.setStroke(void 0,2*s,n),n.windingRule?i.clip(n.windingRule):i.clip(),Et(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,n),Et(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?i.copyWorldByReset(o,e.__nowWorld):i.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:kt,drawTextStroke:Lt,shape:function(t,e,i){const n=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,d,{scaleX:l,scaleY:h}=s;if(l<0&&(l=-l),h<0&&(h=-h),e.bounds.includes(s))d=n,a=r=s;else{const{renderShapeSpread:n}=t.__layout,c=Ct(n?Wt(e.bounds,l===h?n*l:[n*h,n*l]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,i),l*=u,h*=f),r=Tt(s,o),a=Ot(r,-o.e,-o.f),i.matrix){const{matrix:t}=i;o.multiply(t),u*=t.scaleX,f*=t.scaleY}i=Object.assign(Object.assign({},i),{matrix:o.withScale(u,f)})}return t.__renderShape(n,i),{canvas:n,matrix:o,bounds:a,worldCanvas:d,shapeBounds:r,scaleX:l,scaleY:h}}};let It={};const{get:Ft,rotateOfOuter:Yt,translate:Ut,scaleOfOuter:Xt,scale:Nt,rotate:jt}=k;function zt(t,e,i,n,s,a,o){const r=Ft();Ut(r,e.x+i,e.y+n),Nt(r,s,a),o&&Yt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Gt(t,e,i,n,s,a,o){const r=Ft();Ut(r,e.x+i,e.y+n),s&&Nt(r,s,a),o&&jt(r,o),t.transform=r}function Ht(t,e,i,n,s,a,o,r,d,l){const h=Ft();if(d)if("center"===l)Yt(h,{x:i/2,y:n/2},d);else switch(jt(h,d),d){case 90:Ut(h,n,0);break;case 180:Ut(h,i,n);break;case 270:Ut(h,0,i)}It.x=e.x+s,It.y=e.y+a,Ut(h,It.x,It.y),o&&Xt(h,It,o,r),t.transform=h}const{get:qt,translate:Vt}=k,Qt=new _,Jt={},Zt={};function $t(t,e,i,n){const{blendMode:s,sync:a}=i;s&&(t.blendMode=s),a&&(t.sync=a),t.data=Kt(i,n,e)}function Kt(t,e,i){let{width:n,height:s}=i;t.padding&&(e=Qt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{opacity:a,mode:o,align:r,offset:d,scale:l,size:h,rotation:c,repeat:u}=t,f=e.width===n&&e.height===s,g={mode:o},_="center"!==r&&(c||0)%180==90,p=_?s:n,w=_?n:s;let y,m,v=0,x=0;if(o&&"cover"!==o&&"fit"!==o)(l||h)&&(S.getScaleData(l,h,i,Zt),y=Zt.scaleX,m=Zt.scaleY);else if(!f||c){const t=e.width/p,i=e.height/w;y=m="fit"===o?Math.min(t,i):Math.max(t,i),v+=(e.width-n*y)/2,x+=(e.height-s*m)/2}if(r){const t={x:v,y:x,width:p,height:w};y&&(t.width*=y,t.height*=m),L.toPoint(r,t,e,Jt,!0),v+=Jt.x,x+=Jt.y}switch(d&&(v+=d.x,x+=d.y),o){case"stretch":f||(n=e.width,s=e.height);break;case"normal":case"clip":(v||x||y||c)&&Gt(g,e,v,x,y,m,c);break;case"repeat":(!f||y||c)&&Ht(g,e,n,s,v,x,y,m,c,r),u||(g.repeat="repeat");break;default:y&&zt(g,e,v,x,y,m,c)}return g.transform||(e.x||e.y)&&(g.transform=qt(),Vt(g.transform,e.x,e.y)),y&&"stretch"!==o&&(g.scaleX=y,g.scaleY=m),g.width=n,g.height=s,a&&(g.opacity=a),u&&(g.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat"),g}let te,ee=new _;const{isSame:ie}=B;function ne(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||$t(s,n,i,a),!0}function se(t,e){re(t,E.LOAD,e)}function ae(t,e){re(t,E.LOADED,e)}function oe(t,e,i){e.error=i,t.forceUpdate("surface"),re(t,E.ERROR,e)}function re(t,e,i){t.hasEvent(e)&&t.emitEvent(new E(e,i))}function de(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:le,scale:he,copy:ce}=k,{ceil:ue,abs:fe}=Math;function ge(t,i,n){let{scaleX:s,scaleY:a}=x.patternLocked?t.__world:t.__nowWorld;const o=s+"-"+a+"-"+n;if(i.patternId===o||t.destroyed)return!1;{s=fe(s),a=fe(a);const{image:t,data:r}=i;let d,l,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:_,repeat:p}=r;u&&(l=le(),ce(l,_),he(l,1/u,1/f),s*=u,a*=f),s*=n,a*=n,h*=s,c*=a;const w=h*c;if(!p&&w>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,h/=d,c/=d),u&&(s/=u,a/=f),(_||1!==s||1!==a)&&(l||(l=le(),_&&ce(l,_)),he(l,1/s,1/a));const m=t.getCanvas(ue(h)||1,ue(c)||1,g),v=t.getPattern(m,p||e.origin.noRepeat||"no-repeat",l,i);return i.style=v,i.patternId=o,!0}}const{abs:_e}=Math;const pe={image:function(t,e,i,n,s){let a,o;const r=x.get(i);return te&&i===te.paint&&ie(n,te.boxBounds)?a=te.leafPaint:(a={type:i.type,image:r},te=r.use>1?{leafPaint:a,paint:i,boxBounds:ee.set(n)}:null),(s||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ne(t,e,i,r,a,n),s&&(se(t,o),ae(t,o))):r.error?s&&oe(t,o,r.error):(s&&(de(t,!0),se(t,o)),a.loadId=r.load((()=>{de(t,!1),t.destroyed||(ne(t,e,i,r,a,n)&&(r.hasOpacityPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ae(t,o)),a.loadId=null}),(e=>{de(t,!1),oe(t,o,e),a.loadId=null}))),a},checkImage:function(t,i,n,s){const{scaleX:a,scaleY:o}=x.patternLocked?t.__world:t.__nowWorld,{pixelRatio:r}=i;if(!n.data||n.patternId===a+"-"+o+"-"+r&&!F.running)return!1;{const{data:d}=n;if(s)if(d.repeat)s=!1;else{let{width:t,height:i}=d;t*=_e(a)*r,i*=_e(o)*r,d.scaleX&&(t*=d.scaleX,i*=d.scaleY),s=t*i>e.image.maxCacheSize||F.running}return s?(i.save(),t.windingRule?i.clip(t.windingRule):i.clip(),n.blendMode&&(i.blendMode=n.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(n.image.view,0,0,d.width,d.height),i.restore(),!0):(!n.style||n.sync||F.running?ge(t,n,r):n.patternTask||(n.patternTask=x.patternTasker.add((()=>et(this,void 0,void 0,(function*(){n.patternTask=null,i.bounds.hit(t.__nowWorld)&&ge(t,n,r),t.forceUpdate("surface")}))),300)),!1)}},createPattern:ge,recycleImage:function(t,e){const i=e["_"+t];if(i instanceof Array){let n,s,a,o;for(let r=0,d=i.length;r<d;r++)n=i[r].image,o=n&&n.url,o&&(s||(s={}),s[o]=!0,x.recycle(n),n.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),n.unload(i[r].loadId,!a.some((t=>t.url===o)))));return s}return null},createData:$t,getPatternData:Kt,fillOrFitMode:zt,clipMode:Gt,repeatMode:Ht},{toPoint:we}=A,ye={},me={};function ve(t,e,i){if(e){let n;for(let s=0,a=e.length;s<a;s++)n=e[s],"string"==typeof n?t.addColorStop(s/(a-1),D.string(n,i)):t.addColorStop(n.offset,D.string(n.color,i))}}const{getAngle:xe,getDistance:be}=W,{get:Be,rotateOfOuter:Re,scaleOfOuter:ke}=k,{toPoint:Se}=A,Le={},Ee={};function Ae(t,e,i,n,s){let a;const{width:o,height:r}=t;if(o!==r||n){const t=xe(e,i);a=Be(),s?(ke(a,e,o/r*(n||1),1),Re(a,e,t+90)):(ke(a,e,1,o/r*(n||1)),Re(a,e,t))}return a}const{getDistance:We}=W,{toPoint:Te}=A,Oe={},Ce={};const Me={linearGradient:function(t,i){let{from:n,to:s,type:a,blendMode:o,opacity:r}=t;we(n||"top",i,ye),we(s||"bottom",i,me);const d=e.canvas.createLinearGradient(ye.x,ye.y,me.x,me.y);ve(d,t.stops,r);const l={type:a,style:d};return o&&(l.blendMode=o),l},radialGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;Se(n||"center",i,Le),Se(s||"bottom",i,Ee);const l=e.canvas.createRadialGradient(Le.x,Le.y,0,Le.x,Le.y,be(Le,Ee));ve(l,t.stops,o);const h={type:a,style:l},c=Ae(i,Le,Ee,d,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(t,i){let{from:n,to:s,type:a,opacity:o,blendMode:r,stretch:d}=t;Te(n||"center",i,Oe),Te(s||"bottom",i,Ce);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Oe.x,Oe.y):e.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,We(Oe,Ce));ve(l,t.stops,o);const h={type:a,style:l},c=Ae(i,Oe,Ce,d||1,e.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Ae},{copy:Pe,toOffsetOutBounds:De}=B,Ie={},Fe={};function Ye(t,i,n,s){const{bounds:a,shapeBounds:o}=s;if(e.fullImageShadow){if(Pe(Ie,t.bounds),Ie.x+=i.x-o.x,Ie.y+=i.y-o.y,n){const{matrix:t}=s;Ie.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Ie.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Ie.width*=n,Ie.height*=n}t.copyWorld(s.canvas,t.bounds,Ie)}else n&&(Pe(Ie,i),Ie.x-=i.width/2*(n-1),Ie.y-=i.height/2*(n-1),Ie.width*=n,Ie.height*=n),t.copyWorld(s.canvas,o,n?Ie:i)}const{toOffsetOutBounds:Ue}=B,Xe={};const Ne={shadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;De(l,Fe),r.forEach(((r,_)=>{f.setWorldShadow(Fe.offsetX+r.x*c,Fe.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ye(f,Fe,s,i),n=l,r.box&&(f.restore(),f.save(),d&&(f.copyWorld(f,l,a,"copy"),n=a),d?f.copyWorld(d,a,a,"destination-out"):f.copyWorld(i.canvas,h,l,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},innerShadow:function(t,e,i){let n,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:d,bounds:l,shapeBounds:h,scaleX:c,scaleY:u}=i,f=e.getSameCanvas(),g=r.length-1;Ue(l,Xe),r.forEach(((r,_)=>{f.save(),f.setWorldShadow(Xe.offsetX+r.x*c,Xe.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ye(f,Xe,s,i),f.restore(),d?(f.copyWorld(f,l,a,"copy"),f.copyWorld(d,a,a,"source-out"),n=a):(f.copyWorld(i.canvas,h,l,"source-out"),n=l),f.fillWorld(n,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,n,a,r.blendMode):e.copyWorldToInner(f,n,o.renderBounds,r.blendMode),g&&_<g&&f.clearWorld(n,!0)})),f.recycle(n)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:je}=p;function ze(t,e,i,n,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,i,n){const s=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,s),n.recycle(s),He(t,e,i,1)}(t,i,n,s);break;case"opacity-path":He(t,i,n,a);break;case"path":i.restore()}}function Ge(t){return t.getSameCanvas(!1,!0)}function He(t,e,i,n){const s=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,s),i.recycle(s)}Y.prototype.__renderMask=function(t,e){let i,n,s,a,o,r;const{children:d}=this;for(let l=0,h=d.length;l<h;l++)i=d[l],r=i.__.mask,r&&(o&&(ze(this,o,t,s,n,a),n=s=null),"path"===r||"clipping-path"===r?(i.opacity<1?(o="opacity-path",a=i.opacity,s||(s=Ge(t))):(o="path",t.save()),i.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",n||(n=Ge(t)),s||(s=Ge(t)),i.__render(n,e)),"clipping"!==r&&"clipping-path"!==r)||je(i,e)||i.__render(s||t,e);ze(this,o,t,s,n,a)};const qe=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ve=qe+"_#~&*+\\=|≮≯≈≠=…",Qe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Je(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Ze=Je("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Je("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Ke=Je(qe),ti=Je(Ve),ei=Je("- —/~|┆·");var ii;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ii||(ii={}));const{Letter:ni,Single:si,Before:ai,After:oi,Symbol:ri,Break:di}=ii;function li(t){return Ze[t]?ni:ei[t]?di:$e[t]?ai:Ke[t]?oi:ti[t]?ri:Qe.test(t)?si:ni}const hi={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function ci(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ui}=hi,{Letter:fi,Single:gi,Before:_i,After:pi,Symbol:wi,Break:yi}=ii;let mi,vi,xi,bi,Bi,Ri,ki,Si,Li,Ei,Ai,Wi,Ti,Oi,Ci,Mi,Pi,Di=[];function Ii(t,e){Li&&!Si&&(Si=Li),mi.data.push({char:t,width:e}),xi+=e}function Fi(){bi+=xi,mi.width=xi,vi.words.push(mi),mi={data:[]},xi=0}function Yi(){Oi&&(Ci.paraNumber++,vi.paraStart=!0,Oi=!1),Li&&(vi.startCharSize=Si,vi.endCharSize=Li,Si=0),vi.width=bi,Mi.width?ui(vi):Pi&&Ui(),Di.push(vi),vi={words:[]},bi=0}function Ui(){bi>(Ci.maxWidth||0)&&(Ci.maxWidth=bi)}const Xi=0,Ni=1,ji=2;const{top:zi,right:Gi,bottom:Hi,left:qi}=T;function Vi(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const Qi={getDrawData:function(t,i){"string"!=typeof t&&(t=String(t));let n=0,s=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:d,__padding:l}=i;l&&(a?(n=l[qi],a-=l[Gi]+l[qi]):i.autoSizeAlign||(n=l[qi]),o?(s=l[zi],o-=l[zi]+l[Hi]):i.autoSizeAlign||(s=l[zi]));const h={bounds:{x:n,y:s,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=d};return function(t,i,n){Ci=t,Di=t.rows,Mi=t.bounds,Pi=!Mi.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=n,{canvas:r}=e,{width:d,height:l}=Mi;if(d||l||s||"none"!==o){const t="none"!==n.textWrap,e="break"===n.textWrap;Oi=!0,Ai=null,Si=ki=Li=xi=bi=0,mi={data:[]},vi={words:[]};for(let n=0,l=i.length;n<l;n++)Ri=i[n],"\n"===Ri?(xi&&Fi(),vi.paraEnd=!0,Yi(),Oi=!0):(Ei=li(Ri),Ei===fi&&"none"!==o&&(Ri=ci(Ri,o,!xi)),ki=r.measureText(Ri).width,s&&(s<0&&(Li=ki),ki+=s),Wi=Ei===gi&&(Ai===gi||Ai===fi)||Ai===gi&&Ei!==pi,Ti=!(Ei!==_i&&Ei!==gi||Ai!==wi&&Ai!==pi),Bi=Oi&&a?d-a:d,t&&d&&bi+xi+ki>Bi&&(e?(xi&&Fi(),bi&&Yi()):(Ti||(Ti=Ei===fi&&Ai==pi),Wi||Ti||Ei===yi||Ei===_i||Ei===gi||xi+ki>Bi?(xi&&Fi(),bi&&Yi()):bi&&Yi()))," "===Ri&&!0!==Oi&&bi+xi===0||(Ei===yi?(" "===Ri&&xi&&Fi(),Ii(Ri,ki),Fi()):Wi||Ti?(xi&&Fi(),Ii(Ri,ki)):Ii(Ri,ki)),Ai=Ei);xi&&Fi(),bi&&Yi(),Di.length>0&&(Di[Di.length-1].paraEnd=!0)}else i.split("\n").forEach((t=>{Ci.paraNumber++,bi=r.measureText(t).width,Di.push({x:a||0,text:t,width:bi,paraStart:!0}),Pi&&Ui()}))}(h,t,i),l&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":Vi(e,"x",t[qi]);break;case"right":Vi(e,"x",-t[Gi])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Vi(e,"y",t[zi]);break;case"bottom":Vi(e,"y",-t[Hi])}}(l,h,i,a,o),function(t,e){const{rows:i,bounds:n}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:d,verticalAlign:l,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:_}=n,p=s*i.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&p>_)p=Math.max(_,s),t.overflow=i.length;else if(_||c)switch(l){case"middle":f+=(_-p)/2;break;case"bottom":f+=_-p}w+=f;let y,m,v,x=g||c?g:t.maxWidth;for(let a=0,l=i.length;a<l;a++){if(y=i[a],y.x=u,y.width<g||y.width>g&&!r)switch(d){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&a>0&&(w+=h),y.y=w,w+=s,t.overflow>a&&w>p&&(y.isOverflow=!0,t.overflow=a+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<n.x&&(n.x=m),v>n.width&&(n.width=v),r&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=f,n.height=p}(h,i),function(t,e,i,n){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let d,l,h,c,u;s.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,l=i&&"justify"===a&&t.words.length>1?(i-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Xi:l>.01?Ni:ji,t.isOverflow&&!r&&(t.textMode=!0),c===ji?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,d=t.x,t.data=[],t.words.forEach((e=>{c===Ni?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):d=function(t,e,i,n){return t.forEach((t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data,t.isOverflow),!t.paraEnd&&l&&(d+=l,t.width+=l)}))),t.words=null)}))}(h,i,a),h.overflow&&function(t,i,n,s){if(!s)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,d;"hide"===r?r="":"ellipsis"===r&&(r="...");const l=r?e.canvas.measureText(r).width:0,h=n+s-l;("none"===i.textWrap?a:[a[o-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let n=i;n>-1&&(t=e.data[n],d=t.x+t.width,!(n===i&&d<h));n--){if(d<h&&" "!==t.char){e.data.splice(n+1),e.width-=t.width;break}e.width-=t.width}e.width+=l,e.data.push({char:r,x:d}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,i,n,a),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(h,i),h}};const Ji={string:function(t,e){const i="number"==typeof e&&1!==e;if("string"==typeof t){if(!i||!D.object)return t;t=D.object(t)}let n=void 0===t.a?1:t.a;i&&(n*=e);const s=t.r+","+t.g+","+t.b;return 1===n?"rgb("+s+")":"rgba("+s+","+n+")"}};Object.assign(U,Qi),Object.assign(D,Ji),Object.assign(X,Dt),Object.assign(P,pe),Object.assign(I,Me),Object.assign(N,Ne);const{setPoint:Zi,addPoint:$i,toBounds:Ki}=z;const tn={export(t,e,i){this.running=!0;const n=G.fileType(e),s=e.includes(".");return i=G.getExportOptions(i),function(t){en||(en=new H);return new Promise((e=>{en.add((()=>et(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((a=>new Promise((o=>{const r=t=>{a(t),o(),this.running=!1},{toURL:d}=q,{download:l}=q.origin;if("json"===n)return s&&l(d(JSON.stringify(t.toJSON(i.json)),"text"),e),r({data:!!s||t.toJSON(i.json)});if("svg"===n)return s&&l(d(t.toSVG(),"svg"),e),r({data:!!s||t.toSVG()});const{leafer:h}=t;h?(nn(t),h.waitViewCompleted((()=>et(this,void 0,void 0,(function*(){let n,s,a=1,o=1;const{worldTransform:d,isLeafer:l,isFrame:c}=t,{slice:u,trim:f,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,p=i.contextSettings||h.config.contextSettings,w=i.screenshot||t.isApp,y=l&&w&&void 0===i.fill?t.fill:i.fill,m=G.isOpaqueImage(e)||y,v=new V;if(w)n=!0===w?l?h.canvas.bounds:t.worldRenderBounds:w;else{let e=i.relative||(l?"inner":"local");switch(a=d.scaleX,o=d.scaleY,e){case"inner":v.set(d);break;case"local":v.set(d).divide(t.localTransform),a/=t.scaleX,o/=t.scaleY;break;case"world":a=1,o=1;break;case"page":e=t.leafer;default:v.set(d).divide(t.getTransform(e));const i=e.worldTransform;a/=a/i.scaleX,o/=o/i.scaleY}n=t.getBounds("render",e)}const x={scaleX:1,scaleY:1};Q.getScaleData(i.scale,i.size,n,x);let b=i.pixelRatio||1;t.isApp&&(x.scaleX*=b,x.scaleY*=b,b=t.app.pixelRatio);const{x:B,y:R,width:k,height:S}=new j(n).scale(x.scaleX,x.scaleY),L={matrix:v.scale(1/x.scaleX,1/x.scaleY).invert().translate(-B,-R).withScale(1/a*x.scaleX,1/o*x.scaleY)};let E,A=J.canvas({width:Math.round(k),height:Math.round(S),pixelRatio:b,smooth:_,contextSettings:p});if(u&&(E=t,E.__worldOpacity=0,t=h,L.bounds=A.bounds),A.save(),c&&void 0!==y){const e=t.get("fill");t.fill="",t.__render(A,L),t.fill=e}else t.__render(A,L);if(A.restore(),E&&E.__updateWorldOpacity(),f){s=function(t){const{width:e,height:i}=t.view,{data:n}=t.context.getImageData(0,0,e,i);let s,a,o,r=0;for(let t=0;t<n.length;t+=4)0!==n[t+3]&&(s=r%e,a=(r-s)/e,o?$i(o,s,a):Zi(o={},s,a)),r++;const d=new j;return Ki(o,d),d.scale(1/t.pixelRatio).ceil()}(A);const t=A,{width:e,height:i}=s,n={x:0,y:0,width:e,height:i,pixelRatio:b};A=J.canvas(n),A.copyWorld(t,s,n)}m&&A.fillWorld(A.bounds,y||"#FFFFFF","destination-over"),g&&g(A);const W="canvas"===e?A:yield A.export(e,i);r({data:W,width:A.pixelWidth,height:A.pixelHeight,renderBounds:n,trimBounds:s})}))))):r({data:!1})}))))}};let en;function nn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>nn(t)))}const sn=Z.prototype,an=$.get("@leafer-in/export");sn.export=function(t,e){const{quality:i,blob:n}=G.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):n?this.toBlob(t,i):this.toDataURL(t,i)},sn.toBlob=function(t,e){return new Promise((i=>{q.origin.canvasToBolb(this.view,t,e).then((t=>{i(t)})).catch((t=>{an.error(t),i(null)}))}))},sn.toDataURL=function(t,e){return q.origin.canvasToDataURL(this.view,t,e)},sn.saveAs=function(t,e){return new Promise((i=>{q.origin.canvasSaveAs(this.view,t,e).then((()=>{i(!0)})).catch((t=>{an.error(t),i(!1)}))}))},K.add("export"),Object.assign(F,tn),tt.prototype.export=function(t,e){return F.export(this,t,e)},Object.assign(n,{interaction:(t,e,i,n)=>new C(t,e,i,n),hitCanvas:(t,e)=>new it(t,e),hitCanvasManager:()=>new M});export{yt as Layouter,it as LeaferCanvas,bt as Picker,vt as Renderer,Bt as Selector,ot as Watcher,at as useCanvas};
|
package/dist/node.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/core"),i=require("@leafer-ui/draw");function s(t,e,n,i){return new(n||(n=Promise))((function(s,a){function o(t){try{l(i.next(t))}catch(t){a(t)}}function r(t){try{l(i.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:o,fileType:r}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new a(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.requestRender=function(t){setTimeout(t,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1}),t.Platform.conicGradientSupport=!0;class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:g}=t.LeafBoundsHelper,p={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,g)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(p):this.afterBounds.setListWithFn(t,g),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:w,updateAllChange:m}=t.LeafHelper,y=t.Debug.get("Layouter");class v{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){y.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?y.warn("layouting"):this.times>3?y.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:o,AFTER:r}=t.LayoutEvent,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(a,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||h(i[t])}h(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&c(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),v.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,o,this.times)),n.emitEvent(new t.LayoutEvent(a,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class B{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),a=e.includes(this.target.__world),o=new t.Bounds(s);i.save(),a&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,a,o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:b}=t.BoundsHelper;class L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const s=i.through||!1,a=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,a),d=a?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:s,y:a}=this.point,o={x:s,y:a,radiusX:0,radiusY:0};for(let s=0,a=e.length;s<a;s++)if(n=e[s],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,o),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return this.target&&n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,s=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren);t--);return s}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let s,a,o;for(let t=0,e=i.length;t<e;t++){s=i[t],a=i[t+1];for(let t=0,e=s.length;t<e&&(o=s.list[t],!a||!a.has(o));t++)n.add(o)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:s}=this;for(let a=t.length-1;a>-1;a--)n=t[a],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||b(n.__world,s),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,s)):i&&this.hitChild(n,s))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:E,NoAndSkip:R,YesAndSkip:k}=t.Answer,P={},S={},C={};class M{constructor(e,n){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.target&&(this.idMap[e]=t),1):0,innerId:(t,e)=>t.innerId===e?(this.target&&(this.innerIdMap[e]=t),1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0,tags:(t,e)=>e[t.__tag]?1:0},this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new L(e,this),e&&this.__listenEvents()}getBy(e,n,i,s){switch(typeof e){case"number":const a=this.getByInnerId(e,n);return i?a:a?[a]:[];case"string":switch(e[0]){case"#":P.id=e.substring(1),e=P;break;case".":S.className=e.substring(1),e=S;break;default:C.tag=e,e=C}case"object":if(void 0!==e.id){const t=this.getById(e.id,n);return i?t:t?[t]:[]}if(e.tag){const{tag:s}=e,a=s instanceof Array;return this.getByMethod(a?this.methods.tags:this.methods.tag,n,i,a?t.DataHelper.toMap(s):s)}return this.getByMethod(this.methods.className,n,i,e.className);case"function":return this.getByMethod(e,n,i,s)}}getByPoint(e,n,i){return"node"===t.Platform.name&&this.target&&this.target.emit(t.LayoutEvent.CHECK_UPDATE),this.picker.getByPoint(e,n,i)}getByInnerId(t,e){const n=this.innerIdMap[t];return n||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(e,n){const i=this.idMap[e];return i&&t.LeafHelper.hasParent(i,n||this.target)?i:(this.eachFind(this.toChildren(n),this.methods.id,null,e),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,n,i){const s=n?null:[];return this.eachFind(this.toChildren(e),t,s,i),s||this.findLeaf}eachFind(t,e,n,i){let s,a;for(let o=0,r=t.length;o<r;o++){if(s=t[o],a=e(s,i),a===E||a===k){if(!n)return void(this.findLeaf=s);n.push(s)}s.isBranch&&a<R&&this.eachFind(s.children,e,n,i)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:n}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[n]&&delete this.innerIdMap[n]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(t.ChildEvent.REMOVE,this.__onRemoveChild,this),this.target.on_(t.PropertyEvent.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.picker.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}function A(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,a)}function I(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?O(t,!0,e,n):T(e,n);break;case"inside":W("inside",t,s,e,n);break;case"outside":W("outside",t,s,e,n)}}function W(t,e,n,i,s){const{__strokeWidth:a,__font:o}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*a,i.__),r.font=o,n?O(e,!0,i,r):T(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",A(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function T(t,e){let n;const{rows:i,decorationY:s,decorationHeight:a}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,a)}function O(t,e,n,s){let a;for(let o=0,r=t.length;o<r;o++)a=t[o],a.image&&i.PaintImage.checkImage(n,s,a,!1)||a.style&&(s.strokeStyle=a.style,a.blendMode?(s.saveBlendMode(a.blendMode),e?T(n,s):s.stroke(),s.restoreBlendMode()):e?T(n,s):s.stroke())}function D(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new B(t,e,n),selector:(t,e)=>new M(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:H,getOuterOf:F,getByMove:N,getIntersectData:Y}=t.BoundsHelper;let j;function G(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=n.__layout;switch(e.type){case"solid":let{type:a,blendMode:o,color:r,opacity:l}=e;return{type:a,blendMode:o,style:i.ColorConvert.string(r,l)};case"image":return i.PaintImage.image(n,t,e,s,!j||!j[e.url]);case"linear":return i.PaintGradient.linearGradient(e,s);case"radial":return i.PaintGradient.radialGradient(e,s);case"angular":return i.PaintGradient.conicGradient(e,s);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const U={compute:function(t,e){const n=e.__,s=[];let a,o=n.__input[t];o instanceof Array||(o=[o]),j=i.PaintImage.recycleImage(t,n);for(let n,i=0,a=o.length;i<a;i++)n=G(t,o[i],e),n&&s.push(n);n["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(a=s[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=a:n.__pixelStroke=a},fill:function(t,e,n){n.fillStyle=t,e.__.__font?A(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let s;const{windingRule:a,__font:o}=e.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&i.PaintImage.checkImage(e,n,s,!o)||s.style&&(n.fillStyle=s.style,s.transform?(n.save(),n.transform(s.transform),s.blendMode&&(n.blendMode=s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restore()):s.blendMode?(n.saveBlendMode(s.blendMode),o?A(e,n):a?n.fill(a):n.fill(),n.restoreBlendMode()):o?A(e,n):a?n.fill(a):n.fill())},fillText:A,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)I(t,e,n);else switch(a){case"center":n.setStroke(t,s,i),n.stroke(),i.__useArrow&&D(e,n);break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const a=n.getSameCanvas(!0,!0);a.setStroke(t,2*s,i),e.__drawRenderPath(a),a.stroke(),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,e.__layout.renderBounds),a.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:a,__font:o}=i;if(s)if(o)I(t,e,n);else switch(a){case"center":n.setStroke(void 0,s,i),O(t,!1,e,n),i.__useArrow&&D(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),O(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*s,i),O(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(a),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,a),o.recycle(e.__nowWorld)}},strokeText:I,drawTextStroke:T,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let a,o,r,l,{scaleX:d,scaleY:h}=s;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(s))l=i,a=r=s;else{const{renderShapeSpread:i}=t.__layout,c=Y(i?H(e.bounds,d===h?i*d:[i*h,i*d]):e.bounds,s);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,h*=f),r=F(s,o),a=N(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:a,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:h}}};let X={};const{get:q,rotateOfOuter:z,translate:V,scaleOfOuter:Q,scale:J,rotate:K}=t.MatrixHelper;function Z(t,e,n,i,s,a,o){const r=q();V(r,e.x+n,e.y+i),J(r,s,a),o&&z(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function $(t,e,n,i,s,a,o){const r=q();V(r,e.x+n,e.y+i),s&&J(r,s,a),o&&K(r,o),t.transform=r}function tt(t,e,n,i,s,a,o,r,l,d){const h=q();if(l)if("center"===d)z(h,{x:n/2,y:i/2},l);else switch(K(h,l),l){case 90:V(h,i,0);break;case 180:V(h,n,i);break;case 270:V(h,0,n)}X.x=e.x+s,X.y=e.y+a,V(h,X.x,X.y),o&&Q(h,X,o,r),t.transform=h}const{get:et,translate:nt}=t.MatrixHelper,it=new t.Bounds,st={},at={};function ot(t,e,n,i){const{blendMode:s,sync:a}=n;s&&(t.blendMode=s),a&&(t.sync=a),t.data=rt(n,i,e)}function rt(e,n,i){let{width:s,height:a}=i;e.padding&&(n=it.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:l,offset:d,scale:h,size:c,rotation:u,repeat:f}=e,g=n.width===s&&n.height===a,p={mode:r},_="center"!==l&&(u||0)%180==90,w=_?a:s,m=_?s:a;let y,v,x=0,B=0;if(r&&"cover"!==r&&"fit"!==r)(h||c)&&(t.MathHelper.getScaleData(h,c,i,at),y=at.scaleX,v=at.scaleY);else if(!g||u){const t=n.width/w,e=n.height/m;y=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*y)/2,B+=(n.height-a*v)/2}if(l){const e={x:x,y:B,width:w,height:m};y&&(e.width*=y,e.height*=v),t.AlignHelper.toPoint(l,e,n,st,!0),x+=st.x,B+=st.y}switch(d&&(x+=d.x,B+=d.y),r){case"stretch":g||(s=n.width,a=n.height);break;case"normal":case"clip":(x||B||y||u)&&$(p,n,x,B,y,v,u);break;case"repeat":(!g||y||u)&&tt(p,n,s,a,x,B,y,v,u,l),f||(p.repeat="repeat");break;default:y&&Z(p,n,x,B,y,v,u)}return p.transform||(n.x||n.y)&&(p.transform=et(),nt(p.transform,n.x,n.y)),y&&"stretch"!==r&&(p.scaleX=y,p.scaleY=v),p.width=s,p.height=a,o&&(p.opacity=o),f&&(p.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),p}let lt,dt=new t.Bounds;const{isSame:ht}=t.BoundsHelper;function ct(t,e,n,i,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||ot(s,i,n,a),!0}function ut(e,n){pt(e,t.ImageEvent.LOAD,n)}function ft(e,n){pt(e,t.ImageEvent.LOADED,n)}function gt(e,n,i){n.error=i,e.forceUpdate("surface"),pt(e,t.ImageEvent.ERROR,n)}function pt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function _t(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:wt,scale:mt,copy:yt}=t.MatrixHelper,{ceil:vt,abs:xt}=Math;function Bt(e,n,i){let{scaleX:s,scaleY:a}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=s+"-"+a+"-"+i;if(n.patternId===o||e.destroyed)return!1;{s=xt(s),a=xt(a);const{image:e,data:r}=n;let l,d,{width:h,height:c,scaleX:u,scaleY:f,opacity:g,transform:p,repeat:_}=r;u&&(d=wt(),yt(d,p),mt(d,1/u,1/f),s*=u,a*=f),s*=i,a*=i,h*=s,c*=a;const w=h*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}w>m&&(l=Math.sqrt(w/m)),l&&(s/=l,a/=l,h/=l,c/=l),u&&(s/=u,a/=f),(p||1!==s||1!==a)&&(d||(d=wt(),p&&yt(d,p)),mt(d,1/s,1/a));const y=e.getCanvas(vt(h)||1,vt(c)||1,g),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=o,!0}}const{abs:bt}=Math;const Lt={image:function(e,n,i,s,a){let o,r;const l=t.ImageManager.get(i);return lt&&i===lt.paint&&ht(s,lt.boxBounds)?o=lt.leafPaint:(o={type:i.type,image:l},lt=l.use>1?{leafPaint:o,paint:i,boxBounds:dt.set(s)}:null),(a||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(ct(e,n,i,l,o,s),a&&(ut(e,r),ft(e,r))):l.error?a&>(e,r,l.error):(a&&(_t(e,!0),ut(e,r)),o.loadId=l.load((()=>{_t(e,!1),e.destroyed||(ct(e,n,i,l,o,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ft(e,r)),o.loadId=null}),(t=>{_t(e,!1),gt(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,a,o){const{scaleX:r,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=n;if(!a.data||a.patternId===r+"-"+l+"-"+d&&!i.Export.running)return!1;{const{data:h}=a;if(o)if(h.repeat)o=!1;else{let{width:e,height:n}=h;e*=bt(r)*d,n*=bt(l)*d,h.scaleX&&(e*=h.scaleX,n*=h.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),e.windingRule?n.clip(e.windingRule):n.clip(),a.blendMode&&(n.blendMode=a.blendMode),h.opacity&&(n.opacity*=h.opacity),h.transform&&n.transform(h.transform),n.drawImage(a.image.view,0,0,h.width,h.height),n.restore(),!0):(!a.style||a.sync||i.Export.running?Bt(e,a,d):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>s(this,void 0,void 0,(function*(){a.patternTask=null,n.bounds.hit(e.__nowWorld)&&Bt(e,a,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:Bt,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,a,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(a||(a={}),a[r]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),s.unload(i[l].loadId,!o.some((t=>t.url===r)))));return a}return null},createData:ot,getPatternData:rt,fillOrFitMode:Z,clipMode:$,repeatMode:tt},{toPoint:Et}=t.AroundHelper,Rt={},kt={};function Pt(t,e,n){if(e){let s;for(let a=0,o=e.length;a<o;a++)s=e[a],"string"==typeof s?t.addColorStop(a/(o-1),i.ColorConvert.string(s,n)):t.addColorStop(s.offset,i.ColorConvert.string(s.color,n))}}const{getAngle:St,getDistance:Ct}=t.PointHelper,{get:Mt,rotateOfOuter:At,scaleOfOuter:It}=t.MatrixHelper,{toPoint:Wt}=t.AroundHelper,Tt={},Ot={};function Dt(t,e,n,i,s){let a;const{width:o,height:r}=t;if(o!==r||i){const t=St(e,n);a=Mt(),s?(It(a,e,o/r*(i||1),1),At(a,e,t+90)):(It(a,e,1,o/r*(i||1)),At(a,e,t))}return a}const{getDistance:Ht}=t.PointHelper,{toPoint:Ft}=t.AroundHelper,Nt={},Yt={};const jt={linearGradient:function(e,n){let{from:i,to:s,type:a,blendMode:o,opacity:r}=e;Et(i||"top",n,Rt),Et(s||"bottom",n,kt);const l=t.Platform.canvas.createLinearGradient(Rt.x,Rt.y,kt.x,kt.y);Pt(l,e.stops,r);const d={type:a,style:l};return o&&(d.blendMode=o),d},radialGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:l}=e;Wt(i||"center",n,Tt),Wt(s||"bottom",n,Ot);const d=t.Platform.canvas.createRadialGradient(Tt.x,Tt.y,0,Tt.x,Tt.y,Ct(Tt,Ot));Pt(d,e.stops,o);const h={type:a,style:d},c=Dt(n,Tt,Ot,l,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(e,n){let{from:i,to:s,type:a,opacity:o,blendMode:r,stretch:l}=e;Ft(i||"center",n,Nt),Ft(s||"bottom",n,Yt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Nt.x,Nt.y):t.Platform.canvas.createRadialGradient(Nt.x,Nt.y,0,Nt.x,Nt.y,Ht(Nt,Yt));Pt(d,e.stops,o);const h={type:a,style:d},c=Dt(n,Nt,Yt,l||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:Dt},{copy:Gt,toOffsetOutBounds:Ut}=t.BoundsHelper,Xt={},qt={};function zt(e,n,i,s){const{bounds:a,shapeBounds:o}=s;if(t.Platform.fullImageShadow){if(Gt(Xt,e.bounds),Xt.x+=n.x-o.x,Xt.y+=n.y-o.y,i){const{matrix:t}=s;Xt.x-=(a.x+(t?t.e:0)+a.width/2)*(i-1),Xt.y-=(a.y+(t?t.f:0)+a.height/2)*(i-1),Xt.width*=i,Xt.height*=i}e.copyWorld(s.canvas,e.bounds,Xt)}else i&&(Gt(Xt,n),Xt.x-=n.width/2*(i-1),Xt.y-=n.height/2*(i-1),Xt.width*=i,Xt.height*=i),e.copyWorld(s.canvas,o,i?Xt:n)}const{toOffsetOutBounds:Vt}=t.BoundsHelper,Qt={};const Jt={shadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=r.length-1;Ut(d,qt),r.forEach(((r,p)=>{f.setWorldShadow(qt.offsetX+r.x*c,qt.offsetY+r.y*u,r.blur*c,r.color),s=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,zt(f,qt,s,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,a,"copy"),i=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(n.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),g=r.length-1;Vt(d,Qt),r.forEach(((r,p)=>{f.save(),f.setWorldShadow(Qt.offsetX+r.x*c,Qt.offsetY+r.y*u,r.blur*c),s=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,zt(f,Qt,s,n),f.restore(),l?(f.copyWorld(f,d,a,"copy"),f.copyWorld(l,a,a,"source-out"),i=a):(f.copyWorld(n.canvas,h,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,a,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),g&&p<g&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:Kt}=t.LeafBoundsHelper;function Zt(t,e,n,i,s,a){switch(e){case"grayscale":s.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),te(t,e,n,1)}(t,n,i,s);break;case"opacity-path":te(t,n,i,a);break;case"path":n.restore()}}function $t(t){return t.getSameCanvas(!1,!0)}function te(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}i.Group.prototype.__renderMask=function(t,e){let n,i,s,a,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)n=l[d],r=n.__.mask,r&&(o&&(Zt(this,o,t,s,i,a),i=s=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",a=n.opacity,s||(s=$t(t))):(o="path",t.save()),n.__clip(s||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=$t(t)),s||(s=$t(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Kt(n,e)||n.__render(s||t,e);Zt(this,o,t,s,i,a)};const ee=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ne=ee+"_#~&*+\\=|≮≯≈≠=…",ie=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 se(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ae=se("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),oe=se("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),re=se(ee),le=se(ne),de=se("- —/~|┆·");var he;!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"}(he||(he={}));const{Letter:ce,Single:ue,Before:fe,After:ge,Symbol:pe,Break:_e}=he;function we(t){return ae[t]?ce:de[t]?_e:oe[t]?fe:re[t]?ge:le[t]?pe:ie.test(t)?ue:ce}const me={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let a=s-1;a>-1&&(n=e[a].data[0]," "===n.char);a--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function ye(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ve}=me,{Letter:xe,Single:Be,Before:be,After:Le,Symbol:Ee,Break:Re}=he;let ke,Pe,Se,Ce,Me,Ae,Ie,We,Te,Oe,De,He,Fe,Ne,Ye,je,Ge,Ue=[];function Xe(t,e){Te&&!We&&(We=Te),ke.data.push({char:t,width:e}),Se+=e}function qe(){Ce+=Se,ke.width=Se,Pe.words.push(ke),ke={data:[]},Se=0}function ze(){Ne&&(Ye.paraNumber++,Pe.paraStart=!0,Ne=!1),Te&&(Pe.startCharSize=We,Pe.endCharSize=Te,We=0),Pe.width=Ce,je.width?ve(Pe):Ge&&Ve(),Ue.push(Pe),Pe={words:[]},Ce=0}function Ve(){Ce>(Ye.maxWidth||0)&&(Ye.maxWidth=Ce)}const Qe=0,Je=1,Ke=2;const{top:Ze,right:$e,bottom:tn,left:en}=t.Direction4;function nn(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const sn={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,a=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(a?(i=d[en],a-=d[$e]+d[en]):n.autoSizeAlign||(i=d[en]),o?(s=d[Ze],o-=d[Ze]+d[tn]):n.autoSizeAlign||(s=d[Ze]));const h={bounds:{x:i,y:s,width:a,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ye=e,Ue=e.rows,je=e.bounds,Ge=!je.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:o}=i,{canvas:r}=t.Platform,{width:l,height:d}=je;if(l||d||s||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Ne=!0,De=null,We=Ie=Te=Se=Ce=0,ke={data:[]},Pe={words:[]};for(let i=0,d=n.length;i<d;i++)Ae=n[i],"\n"===Ae?(Se&&qe(),Pe.paraEnd=!0,ze(),Ne=!0):(Oe=we(Ae),Oe===xe&&"none"!==o&&(Ae=ye(Ae,o,!Se)),Ie=r.measureText(Ae).width,s&&(s<0&&(Te=Ie),Ie+=s),He=Oe===Be&&(De===Be||De===xe)||De===Be&&Oe!==Le,Fe=!(Oe!==be&&Oe!==Be||De!==Ee&&De!==Le),Me=Ne&&a?l-a:l,t&&l&&Ce+Se+Ie>Me&&(e?(Se&&qe(),Ce&&ze()):(Fe||(Fe=Oe===xe&&De==Le),He||Fe||Oe===Re||Oe===be||Oe===Be||Se+Ie>Me?(Se&&qe(),Ce&&ze()):Ce&&ze()))," "===Ae&&!0!==Ne&&Ce+Se===0||(Oe===Re?(" "===Ae&&Se&&qe(),Xe(Ae,Ie),qe()):He||Fe?(Se&&qe(),Xe(Ae,Ie)):Xe(Ae,Ie)),De=Oe);Se&&qe(),Ce&&ze(),Ue.length>0&&(Ue[Ue.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ye.paraNumber++,Ce=r.measureText(t).width,Ue.push({x:a||0,text:t,width:Ce,paraStart:!0}),Ge&&Ve()}))}(h,e,n),d&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":nn(e,"x",t[en]);break;case"right":nn(e,"x",-t[$e])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":nn(e,"y",t[Ze]);break;case"bottom":nn(e,"y",-t[tn])}}(d,h,n,a,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:a,__letterSpacing:o,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:g,height:p}=i,_=s*n.length+(h?h*(t.paraNumber-1):0),w=a;if(r&&_>p)_=Math.max(p,s),t.overflow=n.length;else if(p||c)switch(d){case"middle":f+=(p-_)/2;break;case"bottom":f+=p-_}w+=f;let m,y,v,x=g||c?g:t.maxWidth;for(let a=0,d=n.length;a<d;a++){if(m=n[a],m.x=u,m.width<g||m.width>g&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&h&&a>0&&(w+=h),m.y=w,w+=s,t.overflow>a&&w>_&&(m.isOverflow=!0,t.overflow=a+1),y=m.x,v=m.width,o<0&&(m.width<0?(v=-m.width+e.fontSize+o,y-=v,v+=e.fontSize):v-=o),y<i.x&&(i.x=y),v>i.width&&(i.width=v),r&&g&&g<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n,i){const{rows:s}=t,{textAlign:a,paraIndent:o,letterSpacing:r}=e;let l,d,h,c,u;s.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,d=n&&"justify"===a&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Qe:d>.01?Je:Ke,t.isOverflow&&!r&&(t.textMode=!0),c===Ke?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,l=t.x,t.data=[],t.words.forEach((e=>{c===Je?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(h,n,a),h.overflow&&function(e,n,i,s){if(!s)return;const{rows:a,overflow:o}=e;let{textOverflow:r}=n;if(a.splice(o),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,h=i+s-d;("none"===n.textWrap?a:[a[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<h));i--){if(l<h&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,i,a),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const an={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let s=void 0===t.a?1:t.a;n&&(s*=e);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}},{setPoint:on,addPoint:rn,toBounds:ln}=t.TwoPointBoundsHelper;const dn={export(e,n,i){this.running=!0;const a=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){hn||(hn=new t.TaskProcessor);return new Promise((t=>{hn.add((()=>s(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((r=>new Promise((l=>{const d=t=>{r(t),l(),this.running=!1},{toURL:h}=t.Platform,{download:c}=t.Platform.origin;if("json"===a)return o&&c(h(JSON.stringify(e.toJSON(i.json)),"text"),n),d({data:!!o||e.toJSON(i.json)});if("svg"===a)return o&&c(h(e.toSVG(),"svg"),n),d({data:!!o||e.toSVG()});const{leafer:u}=e;u?(cn(e),u.waitViewCompleted((()=>s(this,void 0,void 0,(function*(){let s,a,o=1,r=1;const{worldTransform:l,isLeafer:h,isFrame:c}=e,{slice:f,trim:g,onCanvas:p}=i,_=void 0===i.smooth?u.config.smooth:i.smooth,w=i.contextSettings||u.config.contextSettings,m=i.screenshot||e.isApp,y=h&&m&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)s=!0===m?h?u.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(h?"inner":"local");switch(o=l.scaleX,r=l.scaleY,t){case"inner":x.set(l);break;case"local":x.set(l).divide(e.localTransform),o/=e.scaleX,r/=e.scaleY;break;case"world":o=1,r=1;break;case"page":t=e.leafer;default:x.set(l).divide(e.getTransform(t));const n=t.worldTransform;o/=o/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const B={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,B);let b=i.pixelRatio||1;e.isApp&&(B.scaleX*=b,B.scaleY*=b,b=e.app.pixelRatio);const{x:L,y:E,width:R,height:k}=new t.Bounds(s).scale(B.scaleX,B.scaleY),P={matrix:x.scale(1/B.scaleX,1/B.scaleY).invert().translate(-L,-E).withScale(1/o*B.scaleX,1/r*B.scaleY)};let S,C=t.Creator.canvas({width:Math.round(R),height:Math.round(k),pixelRatio:b,smooth:_,contextSettings:w});if(f&&(S=e,S.__worldOpacity=0,e=u,P.bounds=C.bounds),C.save(),c&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(C,P),e.fill=t}else e.__render(C,P);if(C.restore(),S&&S.__updateWorldOpacity(),g){a=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let a,o,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(a=l%n,o=(l-a)/n,r?rn(r,a,o):on(r={},a,o)),l++;const d=new t.Bounds;return ln(r,d),d.scale(1/e.pixelRatio).ceil()}(C);const e=C,{width:n,height:i}=a,s={x:0,y:0,width:n,height:i,pixelRatio:b};C=t.Creator.canvas(s),C.copyWorld(e,a,s)}v&&C.fillWorld(C.bounds,y||"#FFFFFF","destination-over"),p&&p(C);const M="canvas"===n?C:yield C.export(n,i);d({data:M,width:C.pixelWidth,height:C.pixelHeight,renderBounds:s,trimBounds:a})}))))):d({data:!1})}))))}};let hn;function cn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>cn(t)))}const un=t.LeaferCanvasBase.prototype,fn=t.Debug.get("@leafer-ui/export");un.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},un.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{fn.error(t),i(null)}))}))},un.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},un.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{fn.error(t),i(!1)}))}))},Object.assign(i.TextConvert,sn),Object.assign(i.ColorConvert,an),Object.assign(i.Paint,U),Object.assign(i.PaintImage,Lt),Object.assign(i.PaintGradient,jt),Object.assign(i.Effect,Jt),Object.assign(i.Export,dn),Object.assign(t.Creator,{interaction:(t,e,i,s)=>new n.InteractionBase(t,e,i,s),hitCanvas:(t,e)=>new a(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=a,exports.Renderer=B,exports.Selector=M,exports.Watcher=l,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:e=>n(t.Platform.image.getRealURL(e))},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:a}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(o(e),n),canvasToBolb:(t,e,n)=>s(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,i)=>s(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(r(n)),i))})),download(t,e){},loadImage:e=>a(t.Platform.image.getRealURL(e))}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("fs"),n=require("@leafer-ui/core"),i=require("@leafer-ui/draw");function a(t,e,n,i){return new(n||(n=Promise))((function(a,s){function o(t){try{l(i.next(t))}catch(t){s(t)}}function r(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class s extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),t.Platform.roundRectPatch&&(this.context.__proto__.roundRect=null,t.canvasPatch(this.context.__proto__))}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}const{mineType:o,fileType:r}=t.FileHelper;Object.assign(t.Creator,{canvas:(t,e)=>new s(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="node",t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){setTimeout(t,16)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1}),t.Platform.conicGradientSupport=!0;class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:h,updateAllWorldOpacity:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:w,updateAllChange:y}=t.LeafHelper,m=t.Debug.get("Layouter");class v{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){m.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?m.warn("layouting"):this.times>3?m.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:a}=this,{BEFORE:s,LAYOUT:o,AFTER:r}=t.LayoutEvent,l=this.getBlocks(a);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(s,l,this.times)),this.extraBlock=null,a.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(a,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||h(i[t])}h(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&c(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(a),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:s}=t.LayoutEvent,o=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,o,this.times)),v.fullLayout(n),o.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,o,this.times)),n.emitEvent(new t.LayoutEvent(s,o,this.times)),this.addBlocks(o),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),y(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class b{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.isApp||n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,a=e.getIntersect(i.bounds),s=e.includes(this.target.__world),o=new t.Bounds(a);i.save(),s&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,s,o),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const a=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(a),t.Debug.showBoundsView&&this.renderBoundsView(a),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){if(this.requestTime)return;const e=this.requestTime=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.requestTime=0,this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT))}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}const{hitRadiusPoint:B}=t.BoundsHelper;class L{constructor(t,e){this.target=t,this.selector=e}getByPoint(e,n,i){n||(n=0),i||(i={});const a=i.through||!1,s=i.ignoreHittable||!1,o=i.target||this.target;this.exclude=i.exclude||null,this.point={x:e.x,y:e.y,radiusX:n,radiusY:n},this.findList=new t.LeafList(i.findList),i.findList||this.hitBranch(o);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,s),d=s?this.getPath(l):this.getHitablePath(l);return this.clear(),a?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}getBestMatchLeaf(e,n,i){if(e.length){let n;this.findList=new t.LeafList;const{x:a,y:s}=this.point,o={x:a,y:s,radiusX:0,radiusY:0};for(let a=0,s=e.length;a<s;a++)if(n=e[a],(i||t.LeafHelper.worldHittable(n))&&(this.hitChild(n,o),this.findList.length))return this.findList.list[0]}if(n)for(let t=0,e=n.length;t<e;t++)if(this.hitChild(n[t].target,this.point,n[t].proxy),this.findList.length)return this.findList.list[0];return e[0]}getPath(e){const n=new t.LeafList;for(;e;)n.add(e),e=e.parent;return this.target&&n.add(this.target),n}getHitablePath(e){const n=this.getPath(e&&e.hittable?e:null);let i,a=new t.LeafList;for(let t=n.list.length-1;t>-1&&(i=n.list[t],i.__.hittable)&&(a.addAt(i,0),i.__.hitChildren);t--);return a}getThroughPath(e){const n=new t.LeafList,i=[];for(let t=e.length-1;t>-1;t--)i.push(this.getPath(e[t]));let a,s,o;for(let t=0,e=i.length;t<e;t++){a=i[t],s=i[t+1];for(let t=0,e=a.length;t<e&&(o=a.list[t],!s||!s.has(o));t++)n.add(o)}return n}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let n,i;const{point:a}=this;for(let s=t.length-1;s>-1;s--)n=t[s],!n.__.visible||e&&!n.__.mask||(i=!!n.__.hitRadius||B(n.__world,a),n.isBranch?(i||n.__ignoreHitWorld)&&(this.eachFind(n.children,n.__onlyHitMask),n.isBranchLeaf&&this.hitChild(n,a)):i&&this.hitChild(n,a))}hitChild(t,e,n){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:i}=t;if(i&&i.__hasMask&&!t.__.mask&&!i.children.some((t=>t.__.mask&&t.__hitWorld(e))))return;this.findList.add(n||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class E{constructor(e,n){this.config={},n&&(this.config=t.DataHelper.default(n,this.config)),this.picker=new L(this.target=e,this),this.finder=t.Creator.finder&&t.Creator.finder()}getByPoint(e,n,i){return t.Platform.backgrounder&&this.target&&this.target.updateLayout(),this.picker.getByPoint(e,n,i)}getBy(e,n,i,a){return this.finder?this.finder.getBy(e,n,i,a):t.Plugin.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function R(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),a&&e.fillRect(n.x,n.y+a,n.width,s)}function k(t,e,n){const{strokeAlign:i}=e.__,a="string"!=typeof t;switch(i){case"center":n.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?C(t,!0,e,n):S(e,n);break;case"inside":P("inside",t,a,e,n);break;case"outside":P("outside",t,a,e,n)}}function P(t,e,n,i,a){const{__strokeWidth:s,__font:o}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*s,i.__),r.font=o,n?C(e,!0,i,r):S(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",R(i,r),r.blendMode="normal",i.__worldFlipped?a.copyWorldByReset(r,i.__nowWorld):a.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function S(t,e){let n;const{rows:i,decorationY:a,decorationHeight:s}=t.__.__textDrawData;for(let t=0,o=i.length;t<o;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),a&&e.strokeRect(n.x,n.y+a,n.width,s)}function C(t,e,n,a){let s;for(let o=0,r=t.length;o<r;o++)s=t[o],s.image&&i.PaintImage.checkImage(n,a,s,!1)||s.style&&(a.strokeStyle=s.style,s.blendMode?(a.saveBlendMode(s.blendMode),e?S(n,a):a.stroke(),a.restoreBlendMode()):e?S(n,a):a.stroke())}function A(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new v(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>new E(t,e)}),t.Platform.layout=v.fullLayout;const{getSpread:W,getOuterOf:O,getByMove:T,getIntersectData:M}=t.BoundsHelper;let I;function D(t,e,n){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:a}=n.__layout;switch(e.type){case"solid":let{type:s,blendMode:o,color:r,opacity:l}=e;return{type:s,blendMode:o,style:i.ColorConvert.string(r,l)};case"image":return i.PaintImage.image(n,t,e,a,!I||!I[e.url]);case"linear":return i.PaintGradient.linearGradient(e,a);case"radial":return i.PaintGradient.radialGradient(e,a);case"angular":return i.PaintGradient.conicGradient(e,a);default:return void 0!==e.r?{type:"solid",style:i.ColorConvert.string(e)}:void 0}}const H={compute:function(t,e){const n=e.__,a=[];let s,o=n.__input[t];o instanceof Array||(o=[o]),I=i.PaintImage.recycleImage(t,n);for(let n,i=0,s=o.length;i<s;i++)n=D(t,o[i],e),n&&a.push(n);n["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(s=a[0].image.hasOpacityPixel),"fill"===t?n.__pixelFill=s:n.__pixelStroke=s},fill:function(t,e,n){n.fillStyle=t,e.__.__font?R(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,e,n){let a;const{windingRule:s,__font:o}=e.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&i.PaintImage.checkImage(e,n,a,!o)||a.style&&(n.fillStyle=a.style,a.transform?(n.save(),n.transform(a.transform),a.blendMode&&(n.blendMode=a.blendMode),o?R(e,n):s?n.fill(s):n.fill(),n.restore()):a.blendMode?(n.saveBlendMode(a.blendMode),o?R(e,n):s?n.fill(s):n.fill(),n.restoreBlendMode()):o?R(e,n):s?n.fill(s):n.fill())},fillText:R,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)k(t,e,n);else switch(s){case"center":n.setStroke(t,a,i),n.stroke(),i.__useArrow&&A(e,n);break;case"inside":n.save(),n.setStroke(t,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const s=n.getSameCanvas(!0,!0);s.setStroke(t,2*a,i),e.__drawRenderPath(s),s.stroke(),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,e.__layout.renderBounds),s.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:s,__font:o}=i;if(a)if(o)k(t,e,n);else switch(s){case"center":n.setStroke(void 0,a,i),C(t,!1,e,n),i.__useArrow&&A(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),C(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:s}=e.__layout,o=n.getSameCanvas(!0,!0);e.__drawRenderPath(o),o.setStroke(void 0,2*a,i),C(t,!1,e,o),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(s),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,s),o.recycle(e.__nowWorld)}},strokeText:k,drawTextStroke:S,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let s,o,r,l,{scaleX:d,scaleY:h}=a;if(d<0&&(d=-d),h<0&&(h=-h),e.bounds.includes(a))l=i,s=r=a;else{const{renderShapeSpread:i}=t.__layout,c=M(i?W(e.bounds,d===h?i*d:[i*h,i*d]):e.bounds,a);o=e.bounds.getFitMatrix(c);let{a:u,d:f}=o;if(o.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,h*=f),r=O(a,o),s=T(r,-o.e,-o.f),n.matrix){const{matrix:t}=n;o.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:o.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:o,bounds:s,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:h}}};let F={};const{get:Y,rotateOfOuter:j,translate:U,scaleOfOuter:G,scale:X,rotate:q}=t.MatrixHelper;function z(t,e,n,i,a,s,o){const r=Y();U(r,e.x+n,e.y+i),X(r,a,s),o&&j(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function N(t,e,n,i,a,s,o){const r=Y();U(r,e.x+n,e.y+i),a&&X(r,a,s),o&&q(r,o),t.transform=r}function V(t,e,n,i,a,s,o,r,l,d){const h=Y();if(l)if("center"===d)j(h,{x:n/2,y:i/2},l);else switch(q(h,l),l){case 90:U(h,i,0);break;case 180:U(h,n,i);break;case 270:U(h,0,n)}F.x=e.x+a,F.y=e.y+s,U(h,F.x,F.y),o&&G(h,F,o,r),t.transform=h}const{get:Q,translate:J}=t.MatrixHelper,Z=new t.Bounds,K={},$={};function tt(t,e,n,i){const{blendMode:a,sync:s}=n;a&&(t.blendMode=a),s&&(t.sync=s),t.data=et(n,i,e)}function et(e,n,i){let{width:a,height:s}=i;e.padding&&(n=Z.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:o,mode:r,align:l,offset:d,scale:h,size:c,rotation:u,repeat:f}=e,p=n.width===a&&n.height===s,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?s:a,y=_?a:s;let m,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(h||c)&&(t.MathHelper.getScaleData(h,c,i,$),m=$.scaleX,v=$.scaleY);else if(!p||u){const t=n.width/w,e=n.height/y;m=v="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-a*m)/2,b+=(n.height-s*v)/2}if(l){const e={x:x,y:b,width:w,height:y};m&&(e.width*=m,e.height*=v),t.AlignHelper.toPoint(l,e,n,K,!0),x+=K.x,b+=K.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(a=n.width,s=n.height);break;case"normal":case"clip":(x||b||m||u)&&N(g,n,x,b,m,v,u);break;case"repeat":(!p||m||u)&&V(g,n,a,s,x,b,m,v,u,l),f||(g.repeat="repeat");break;default:m&&z(g,n,x,b,m,v,u)}return g.transform||(n.x||n.y)&&(g.transform=Q(),J(g.transform,n.x,n.y)),m&&"stretch"!==r&&(g.scaleX=m,g.scaleY=v),g.width=a,g.height=s,o&&(g.opacity=o),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let nt,it=new t.Bounds;const{isSame:at}=t.BoundsHelper;function st(t,e,n,i,a,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return a.data||tt(a,i,n,s),!0}function ot(e,n){dt(e,t.ImageEvent.LOAD,n)}function rt(e,n){dt(e,t.ImageEvent.LOADED,n)}function lt(e,n,i){n.error=i,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,n)}function dt(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ht(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ct,scale:ut,copy:ft}=t.MatrixHelper,{ceil:pt,abs:gt}=Math;function _t(e,n,i){let{scaleX:a,scaleY:s}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const o=a+"-"+s+"-"+i;if(n.patternId===o||e.destroyed)return!1;{a=gt(a),s=gt(s);const{image:e,data:r}=n;let l,d,{width:h,height:c,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=ct(),ft(d,g),ut(d,1/u,1/f),a*=u,s*=f),a*=i,s*=i,h*=a,c*=s;const w=h*c;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;y>t&&(y=t)}w>y&&(l=Math.sqrt(w/y)),l&&(a/=l,s/=l,h/=l,c/=l),u&&(a/=u,s/=f),(g||1!==a||1!==s)&&(d||(d=ct(),g&&ft(d,g)),ut(d,1/a,1/s));const m=e.getCanvas(pt(h)||1,pt(c)||1,p),v=e.getPattern(m,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=o,!0}}const{abs:wt}=Math;const yt={image:function(e,n,i,a,s){let o,r;const l=t.ImageManager.get(i);return nt&&i===nt.paint&&at(a,nt.boxBounds)?o=nt.leafPaint:(o={type:i.type,image:l},nt=l.use>1?{leafPaint:o,paint:i,boxBounds:it.set(a)}:null),(s||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(st(e,n,i,l,o,a),s&&(ot(e,r),rt(e,r))):l.error?s&<(e,r,l.error):(s&&(ht(e,!0),ot(e,r)),o.loadId=l.load((()=>{ht(e,!1),e.destroyed||(st(e,n,i,l,o,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),rt(e,r)),o.loadId=null}),(t=>{ht(e,!1),lt(e,r,t),o.loadId=null}))),o},checkImage:function(e,n,s,o){const{scaleX:r,scaleY:l}=t.ImageManager.patternLocked?e.__world:e.__nowWorld,{pixelRatio:d}=n;if(!s.data||s.patternId===r+"-"+l+"-"+d&&!i.Export.running)return!1;{const{data:h}=s;if(o)if(h.repeat)o=!1;else{let{width:e,height:n}=h;e*=wt(r)*d,n*=wt(l)*d,h.scaleX&&(e*=h.scaleX,n*=h.scaleY),o=e*n>t.Platform.image.maxCacheSize||i.Export.running}return o?(n.save(),e.windingRule?n.clip(e.windingRule):n.clip(),s.blendMode&&(n.blendMode=s.blendMode),h.opacity&&(n.opacity*=h.opacity),h.transform&&n.transform(h.transform),n.drawImage(s.image.view,0,0,h.width,h.height),n.restore(),!0):(!s.style||s.sync||i.Export.running?_t(e,s,d):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>a(this,void 0,void 0,(function*(){s.patternTask=null,n.bounds.hit(e.__nowWorld)&&_t(e,s,d),e.forceUpdate("surface")}))),300)),!1)}},createPattern:_t,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,s,o,r;for(let l=0,d=i.length;l<d;l++)a=i[l].image,r=a&&a.url,r&&(s||(s={}),s[r]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),a.unload(i[l].loadId,!o.some((t=>t.url===r)))));return s}return null},createData:tt,getPatternData:et,fillOrFitMode:z,clipMode:N,repeatMode:V},{toPoint:mt}=t.AroundHelper,vt={},xt={};function bt(t,e,n){if(e){let a;for(let s=0,o=e.length;s<o;s++)a=e[s],"string"==typeof a?t.addColorStop(s/(o-1),i.ColorConvert.string(a,n)):t.addColorStop(a.offset,i.ColorConvert.string(a.color,n))}}const{getAngle:Bt,getDistance:Lt}=t.PointHelper,{get:Et,rotateOfOuter:Rt,scaleOfOuter:kt}=t.MatrixHelper,{toPoint:Pt}=t.AroundHelper,St={},Ct={};function At(t,e,n,i,a){let s;const{width:o,height:r}=t;if(o!==r||i){const t=Bt(e,n);s=Et(),a?(kt(s,e,o/r*(i||1),1),Rt(s,e,t+90)):(kt(s,e,1,o/r*(i||1)),Rt(s,e,t))}return s}const{getDistance:Wt}=t.PointHelper,{toPoint:Ot}=t.AroundHelper,Tt={},Mt={};const It={linearGradient:function(e,n){let{from:i,to:a,type:s,blendMode:o,opacity:r}=e;mt(i||"top",n,vt),mt(a||"bottom",n,xt);const l=t.Platform.canvas.createLinearGradient(vt.x,vt.y,xt.x,xt.y);bt(l,e.stops,r);const d={type:s,style:l};return o&&(d.blendMode=o),d},radialGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:l}=e;Pt(i||"center",n,St),Pt(a||"bottom",n,Ct);const d=t.Platform.canvas.createRadialGradient(St.x,St.y,0,St.x,St.y,Lt(St,Ct));bt(d,e.stops,o);const h={type:s,style:d},c=At(n,St,Ct,l,!0);return c&&(h.transform=c),r&&(h.blendMode=r),h},conicGradient:function(e,n){let{from:i,to:a,type:s,opacity:o,blendMode:r,stretch:l}=e;Ot(i||"center",n,Tt),Ot(a||"bottom",n,Mt);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Tt.x,Tt.y):t.Platform.canvas.createRadialGradient(Tt.x,Tt.y,0,Tt.x,Tt.y,Wt(Tt,Mt));bt(d,e.stops,o);const h={type:s,style:d},c=At(n,Tt,Mt,l||1,t.Platform.conicGradientRotate90);return c&&(h.transform=c),r&&(h.blendMode=r),h},getTransform:At},{copy:Dt,toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={},Yt={};function jt(e,n,i,a){const{bounds:s,shapeBounds:o}=a;if(t.Platform.fullImageShadow){if(Dt(Ft,e.bounds),Ft.x+=n.x-o.x,Ft.y+=n.y-o.y,i){const{matrix:t}=a;Ft.x-=(s.x+(t?t.e:0)+s.width/2)*(i-1),Ft.y-=(s.y+(t?t.f:0)+s.height/2)*(i-1),Ft.width*=i,Ft.height*=i}e.copyWorld(a.canvas,e.bounds,Ft)}else i&&(Dt(Ft,n),Ft.x-=n.width/2*(i-1),Ft.y-=n.height/2*(i-1),Ft.width*=i,Ft.height*=i),e.copyWorld(a.canvas,o,i?Ft:n)}const{toOffsetOutBounds:Ut}=t.BoundsHelper,Gt={};const Xt={shadow:function(t,e,n){let i,a;const{__nowWorld:s,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(d,Yt),r.forEach(((r,g)=>{f.setWorldShadow(Yt.offsetX+r.x*c,Yt.offsetY+r.y*u,r.blur*c,r.color),a=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,jt(f,Yt,a,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,s,"copy"),i=s),l?f.copyWorld(l,s,s,"destination-out"):f.copyWorld(n.canvas,h,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,s,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,a;const{__nowWorld:s,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:h,scaleX:c,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ut(d,Gt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Gt.offsetX+r.x*c,Gt.offsetY+r.y*u,r.blur*c),a=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,jt(f,Gt,a,n),f.restore(),l?(f.copyWorld(f,d,s,"copy"),f.copyWorld(l,s,s,"source-out"),i=s):(f.copyWorld(n.canvas,h,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,s,r.blendMode):e.copyWorldToInner(f,i,o.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},blur:function(t,e,n){const{blur:i}=t.__;n.setWorldBlur(i*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:qt}=t.LeafBoundsHelper;function zt(t,e,n,i,a,s){switch(e){case"grayscale":a.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,i){const a=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,a),i.recycle(a),Vt(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Vt(t,n,i,s);break;case"path":n.restore()}}function Nt(t){return t.getSameCanvas(!1,!0)}function Vt(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}i.Group.prototype.__renderMask=function(t,e){let n,i,a,s,o,r;const{children:l}=this;for(let d=0,h=l.length;d<h;d++)n=l[d],r=n.__.mask,r&&(o&&(zt(this,o,t,a,i,s),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(o="opacity-path",s=n.opacity,a||(a=Nt(t))):(o="path",t.save()),n.__clip(a||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=Nt(t)),a||(a=Nt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||qt(n,e)||n.__render(a||t,e);zt(this,o,t,a,i,s)};const Qt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Jt=Qt+"_#~&*+\\=|≮≯≈≠=…",Zt=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function Kt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const $t=Kt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),te=Kt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ee=Kt(Qt),ne=Kt(Jt),ie=Kt("- —/~|┆·");var ae;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ae||(ae={}));const{Letter:se,Single:oe,Before:re,After:le,Symbol:de,Break:he}=ae;function ce(t){return $t[t]?se:ie[t]?he:te[t]?re:ee[t]?le:ne[t]?de:Zt.test(t)?oe:se}const ue={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let s=a-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function fe(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:pe}=ue,{Letter:ge,Single:_e,Before:we,After:ye,Symbol:me,Break:ve}=ae;let xe,be,Be,Le,Ee,Re,ke,Pe,Se,Ce,Ae,We,Oe,Te,Me,Ie,De,He=[];function Fe(t,e){Se&&!Pe&&(Pe=Se),xe.data.push({char:t,width:e}),Be+=e}function Ye(){Le+=Be,xe.width=Be,be.words.push(xe),xe={data:[]},Be=0}function je(){Te&&(Me.paraNumber++,be.paraStart=!0,Te=!1),Se&&(be.startCharSize=Pe,be.endCharSize=Se,Pe=0),be.width=Le,Ie.width?pe(be):De&&Ue(),He.push(be),be={words:[]},Le=0}function Ue(){Le>(Me.maxWidth||0)&&(Me.maxWidth=Le)}const Ge=0,Xe=1,qe=2;const{top:ze,right:Ne,bottom:Ve,left:Qe}=t.Direction4;function Je(t,e,n){const{bounds:i,rows:a}=t;i[e]+=n;for(let t=0;t<a.length;t++)a[t][e]+=n}const Ze={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,s=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(s?(i=d[Qe],s-=d[Ne]+d[Qe]):n.autoSizeAlign||(i=d[Qe]),o?(a=d[ze],o-=d[ze]+d[Ve]):n.autoSizeAlign||(a=d[ze]));const h={bounds:{x:i,y:a,width:s,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Me=e,He=e.rows,Ie=e.bounds,De=!Ie.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:s,textCase:o}=i,{canvas:r}=t.Platform,{width:l,height:d}=Ie;if(l||d||a||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;Te=!0,Ae=null,Pe=ke=Se=Be=Le=0,xe={data:[]},be={words:[]};for(let i=0,d=n.length;i<d;i++)Re=n[i],"\n"===Re?(Be&&Ye(),be.paraEnd=!0,je(),Te=!0):(Ce=ce(Re),Ce===ge&&"none"!==o&&(Re=fe(Re,o,!Be)),ke=r.measureText(Re).width,a&&(a<0&&(Se=ke),ke+=a),We=Ce===_e&&(Ae===_e||Ae===ge)||Ae===_e&&Ce!==ye,Oe=!(Ce!==we&&Ce!==_e||Ae!==me&&Ae!==ye),Ee=Te&&s?l-s:l,t&&l&&Le+Be+ke>Ee&&(e?(Be&&Ye(),Le&&je()):(Oe||(Oe=Ce===ge&&Ae==ye),We||Oe||Ce===ve||Ce===we||Ce===_e||Be+ke>Ee?(Be&&Ye(),Le&&je()):Le&&je()))," "===Re&&!0!==Te&&Le+Be===0||(Ce===ve?(" "===Re&&Be&&Ye(),Fe(Re,ke),Ye()):We||Oe?(Be&&Ye(),Fe(Re,ke)):Fe(Re,ke)),Ae=Ce);Be&&Ye(),Le&&je(),He.length>0&&(He[He.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Me.paraNumber++,Le=r.measureText(t).width,He.push({x:s||0,text:t,width:Le,paraStart:!0}),De&&Ue()}))}(h,e,n),d&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Je(e,"x",t[Qe]);break;case"right":Je(e,"x",-t[Ne])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Je(e,"y",t[ze]);break;case"bottom":Je(e,"y",-t[Ve])}}(d,h,n,s,o),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:s,__letterSpacing:o,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:h,autoSizeAlign:c}=e;let{x:u,y:f,width:p,height:g}=i,_=a*n.length+(h?h*(t.paraNumber-1):0),w=s;if(r&&_>g)_=Math.max(g,a),t.overflow=n.length;else if(g||c)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let y,m,v,x=p||c?p:t.maxWidth;for(let s=0,d=n.length;s<d;s++){if(y=n[s],y.x=u,y.width<p||y.width>p&&!r)switch(l){case"center":y.x+=(x-y.width)/2;break;case"right":y.x+=x-y.width}y.paraStart&&h&&s>0&&(w+=h),y.y=w,w+=a,t.overflow>s&&w>_&&(y.isOverflow=!0,t.overflow=s+1),m=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,m-=v,v+=e.fontSize):v-=o),m<i.x&&(i.x=m),v>i.width&&(i.width=v),r&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(h,n),function(t,e,n,i){const{rows:a}=t,{textAlign:s,paraIndent:o,letterSpacing:r}=e;let l,d,h,c,u;a.forEach((t=>{t.words&&(h=o&&t.paraStart?o:0,d=n&&"justify"===s&&t.words.length>1?(n-t.width-h)/(t.words.length-1):0,c=r||t.isOverflow?Ge:d>.01?Xe:qe,t.isOverflow&&!r&&(t.textMode=!0),c===qe?(t.x+=h,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=h,l=t.x,t.data=[],t.words.forEach((e=>{c===Xe?(u={char:"",x:l},l=function(t,e,n){return t.forEach((t=>{n.char+=t.char,e+=t.width})),e}(e.data,l,u),(t.isOverflow||" "!==u.char)&&t.data.push(u)):l=function(t,e,n,i){return t.forEach((t=>{(i||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width})),e}(e.data,l,t.data,t.isOverflow),!t.paraEnd&&d&&(l+=d,t.width+=d)}))),t.words=null)}))}(h,n,s),h.overflow&&function(e,n,i,a){if(!a)return;const{rows:s,overflow:o}=e;let{textOverflow:r}=n;if(s.splice(o),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,h=i+a-d;("none"===n.textWrap?s:[s[o-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<h));i--){if(l<h&&" "!==e.char){t.data.splice(i+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:r,x:l}),t.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(t)}}))}}(h,n,i,s),"none"!==r&&function(t,e){const{fontSize:n}=e;switch(t.decorationHeight=n/11,e.textDecoration){case"under":t.decorationY=.15*n;break;case"delete":t.decorationY=.35*-n}}(h,n),h}};const Ke={string:function(t,e){const n="number"==typeof e&&1!==e;if("string"==typeof t){if(!n||!i.ColorConvert.object)return t;t=i.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;n&&(a*=e);const s=t.r+","+t.g+","+t.b;return 1===a?"rgb("+s+")":"rgba("+s+","+a+")"}};Object.assign(i.TextConvert,Ze),Object.assign(i.ColorConvert,Ke),Object.assign(i.Paint,H),Object.assign(i.PaintImage,yt),Object.assign(i.PaintGradient,It),Object.assign(i.Effect,Xt);const{setPoint:$e,addPoint:tn,toBounds:en}=i.TwoPointBoundsHelper;const nn={export(t,e,n){this.running=!0;const s=i.FileHelper.fileType(e),o=e.includes(".");return n=i.FileHelper.getExportOptions(n),function(t){an||(an=new i.TaskProcessor);return new Promise((e=>{an.add((()=>a(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((r=>new Promise((l=>{const d=t=>{r(t),l(),this.running=!1},{toURL:h}=i.Platform,{download:c}=i.Platform.origin;if("json"===s)return o&&c(h(JSON.stringify(t.toJSON(n.json)),"text"),e),d({data:!!o||t.toJSON(n.json)});if("svg"===s)return o&&c(h(t.toSVG(),"svg"),e),d({data:!!o||t.toSVG()});const{leafer:u}=t;u?(sn(t),u.waitViewCompleted((()=>a(this,void 0,void 0,(function*(){let a,s,o=1,r=1;const{worldTransform:l,isLeafer:h,isFrame:c}=t,{slice:f,trim:p,onCanvas:g}=n,_=void 0===n.smooth?u.config.smooth:n.smooth,w=n.contextSettings||u.config.contextSettings,y=n.screenshot||t.isApp,m=h&&y&&void 0===n.fill?t.fill:n.fill,v=i.FileHelper.isOpaqueImage(e)||m,x=new i.Matrix;if(y)a=!0===y?h?u.canvas.bounds:t.worldRenderBounds:y;else{let e=n.relative||(h?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":x.set(l);break;case"local":x.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=t.leafer;default:x.set(l).divide(t.getTransform(e));const n=e.worldTransform;o/=o/n.scaleX,r/=r/n.scaleY}a=t.getBounds("render",e)}const b={scaleX:1,scaleY:1};i.MathHelper.getScaleData(n.scale,n.size,a,b);let B=n.pixelRatio||1;t.isApp&&(b.scaleX*=B,b.scaleY*=B,B=t.app.pixelRatio);const{x:L,y:E,width:R,height:k}=new i.Bounds(a).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-L,-E).withScale(1/o*b.scaleX,1/r*b.scaleY)};let S,C=i.Creator.canvas({width:Math.round(R),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(S=t,S.__worldOpacity=0,t=u,P.bounds=C.bounds),C.save(),c&&void 0!==m){const e=t.get("fill");t.fill="",t.__render(C,P),t.fill=e}else t.__render(C,P);if(C.restore(),S&&S.__updateWorldOpacity(),p){s=function(t){const{width:e,height:n}=t.view,{data:a}=t.context.getImageData(0,0,e,n);let s,o,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(s=l%e,o=(l-s)/e,r?tn(r,s,o):$e(r={},s,o)),l++;const d=new i.Bounds;return en(r,d),d.scale(1/t.pixelRatio).ceil()}(C);const t=C,{width:e,height:n}=s,a={x:0,y:0,width:e,height:n,pixelRatio:B};C=i.Creator.canvas(a),C.copyWorld(t,s,a)}v&&C.fillWorld(C.bounds,m||"#FFFFFF","destination-over"),g&&g(C);const A="canvas"===e?C:yield C.export(e,n);d({data:A,width:C.pixelWidth,height:C.pixelHeight,renderBounds:a,trimBounds:s})}))))):d({data:!1})}))))}};let an;function sn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>sn(t)))}const on=i.LeaferCanvasBase.prototype,rn=i.Debug.get("@leafer-in/export");on.export=function(t,e){const{quality:n,blob:a}=i.FileHelper.getExportOptions(e);return t.includes(".")?this.saveAs(t,n):a?this.toBlob(t,n):this.toDataURL(t,n)},on.toBlob=function(t,e){return new Promise((n=>{i.Platform.origin.canvasToBolb(this.view,t,e).then((t=>{n(t)})).catch((t=>{rn.error(t),n(null)}))}))},on.toDataURL=function(t,e){return i.Platform.origin.canvasToDataURL(this.view,t,e)},on.saveAs=function(t,e){return new Promise((n=>{i.Platform.origin.canvasSaveAs(this.view,t,e).then((()=>{n(!0)})).catch((t=>{rn.error(t),n(!1)}))}))},i.Plugin.add("export"),Object.assign(i.Export,nn),i.UI.prototype.export=function(t,e){return i.Export.export(this,t,e)},Object.assign(t.Creator,{interaction:(t,e,i,a)=>new n.InteractionBase(t,e,i,a),hitCanvas:(t,e)=>new s(t,e),hitCanvasManager:()=>new n.HitCanvasManager}),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=v,exports.LeaferCanvas=s,exports.Picker=L,exports.Renderer=b,exports.Selector=E,exports.Watcher=l,exports.useCanvas=function(n,i){if(t.Platform.canvasType=n,!t.Platform.origin){if("skia"===n){const{Canvas:e,loadImage:n}=i;t.Platform.origin={createCanvas:(t,n,i)=>new e(t,n,i),canvasToDataURL:(t,e,n)=>t.toDataURLSync(e,{quality:n}),canvasToBolb:(t,e,n)=>t.toBuffer(e,{quality:n}),canvasSaveAs:(t,e,n)=>t.saveAs(e,{quality:n}),download(t,e){},loadImage:e=>n(t.Platform.image.getRealURL(e))},t.Platform.roundRectPatch=!0}else if("napi"===n){const{Canvas:n,loadImage:s}=i;t.Platform.origin={createCanvas:(t,e,i)=>new n(t,e,i),canvasToDataURL:(t,e,n)=>t.toDataURL(o(e),n),canvasToBolb:(t,e,n)=>a(this,void 0,void 0,(function*(){return t.toBuffer(o(e),n)})),canvasSaveAs:(t,n,i)=>a(this,void 0,void 0,(function*(){return e.writeFileSync(n,t.toBuffer(o(r(n)),i))})),download(t,e){},loadImage:e=>s(t.Platform.image.getRealURL(e))}}t.Platform.ellipseToCurve=!0,t.Platform.event={stopDefault(t){},stopNow(t){},stop(t){}},t.Platform.canvas=t.Creator.canvas()}},Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(n).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return n[t]}})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-ui/node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "@leafer-ui/node",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,14 +32,15 @@
|
|
|
32
32
|
"leaferjs"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@leafer/core": "1.
|
|
36
|
-
"@leafer/node": "1.
|
|
37
|
-
"@leafer/partner": "1.
|
|
38
|
-
"@leafer/interface": "1.
|
|
39
|
-
"@leafer-ui/draw": "1.
|
|
40
|
-
"@leafer-ui/core": "1.
|
|
41
|
-
"@leafer-ui/partner": "1.
|
|
42
|
-
"@leafer-ui/interface": "1.
|
|
43
|
-
"@leafer-in/
|
|
35
|
+
"@leafer/core": "1.3.1",
|
|
36
|
+
"@leafer/node": "1.3.1",
|
|
37
|
+
"@leafer/partner": "1.3.1",
|
|
38
|
+
"@leafer/interface": "1.3.1",
|
|
39
|
+
"@leafer-ui/draw": "1.3.1",
|
|
40
|
+
"@leafer-ui/core": "1.3.1",
|
|
41
|
+
"@leafer-ui/partner": "1.3.1",
|
|
42
|
+
"@leafer-ui/interface": "1.3.1",
|
|
43
|
+
"@leafer-in/export": "1.3.1",
|
|
44
|
+
"@leafer-in/interface": "1.3.1"
|
|
44
45
|
}
|
|
45
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,8 @@ export * from '@leafer/partner'
|
|
|
6
6
|
export * from '@leafer-ui/core'
|
|
7
7
|
export * from '@leafer-ui/partner'
|
|
8
8
|
|
|
9
|
+
export * from '@leafer-in/export'
|
|
10
|
+
|
|
9
11
|
import { ICreator } from '@leafer/interface'
|
|
10
12
|
import { Creator, LeaferCanvas } from '@leafer/node'
|
|
11
13
|
import { InteractionBase, HitCanvasManager } from '@leafer-ui/core'
|
package/types/index.d.ts
CHANGED