@leafer-draw/worker 1.1.0 → 1.1.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/worker.cjs +13 -12
- package/dist/worker.esm.js +13 -12
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +89 -70
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +89 -70
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.js
CHANGED
|
@@ -1377,7 +1377,7 @@ var LeaferUI = (function (exports) {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
const D$4 = Debug;
|
|
1379
1379
|
|
|
1380
|
-
const debug$
|
|
1380
|
+
const debug$e = Debug.get('RunTime');
|
|
1381
1381
|
const Run = {
|
|
1382
1382
|
currentId: 0,
|
|
1383
1383
|
currentName: '',
|
|
@@ -1395,7 +1395,7 @@ var LeaferUI = (function (exports) {
|
|
|
1395
1395
|
const time = R.idMap[id], name = R.nameMap[id];
|
|
1396
1396
|
const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
|
|
1397
1397
|
R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
|
|
1398
|
-
debug$
|
|
1398
|
+
debug$e.log(name, duration, 'ms');
|
|
1399
1399
|
},
|
|
1400
1400
|
endOfName(name, microsecond) {
|
|
1401
1401
|
const id = R.nameToIdMap[name];
|
|
@@ -1409,18 +1409,18 @@ var LeaferUI = (function (exports) {
|
|
|
1409
1409
|
console.error('need plugin: @leafer-in/' + name);
|
|
1410
1410
|
}
|
|
1411
1411
|
|
|
1412
|
-
const debug$
|
|
1412
|
+
const debug$d = Debug.get('UICreator');
|
|
1413
1413
|
const UICreator = {
|
|
1414
1414
|
list: {},
|
|
1415
1415
|
register(UI) {
|
|
1416
1416
|
const { __tag: tag } = UI.prototype;
|
|
1417
1417
|
if (list$1[tag])
|
|
1418
|
-
debug$
|
|
1418
|
+
debug$d.repeat(tag);
|
|
1419
1419
|
list$1[tag] = UI;
|
|
1420
1420
|
},
|
|
1421
1421
|
get(tag, data, x, y, width, height) {
|
|
1422
1422
|
if (!list$1[tag])
|
|
1423
|
-
debug$
|
|
1423
|
+
debug$d.error('not register ' + tag);
|
|
1424
1424
|
const ui = new list$1[tag](data);
|
|
1425
1425
|
if (x !== undefined) {
|
|
1426
1426
|
ui.x = x;
|
|
@@ -1436,7 +1436,7 @@ var LeaferUI = (function (exports) {
|
|
|
1436
1436
|
};
|
|
1437
1437
|
const { list: list$1 } = UICreator;
|
|
1438
1438
|
|
|
1439
|
-
const debug$
|
|
1439
|
+
const debug$c = Debug.get('EventCreator');
|
|
1440
1440
|
const EventCreator = {
|
|
1441
1441
|
nameList: {},
|
|
1442
1442
|
register(Event) {
|
|
@@ -1444,7 +1444,7 @@ var LeaferUI = (function (exports) {
|
|
|
1444
1444
|
Object.keys(Event).forEach(key => {
|
|
1445
1445
|
name = Event[key];
|
|
1446
1446
|
if (typeof name === 'string')
|
|
1447
|
-
nameList[name] && debug$
|
|
1447
|
+
nameList[name] && debug$c.repeat(name), nameList[name] = Event;
|
|
1448
1448
|
});
|
|
1449
1449
|
},
|
|
1450
1450
|
changeName(oldName, newName) {
|
|
@@ -1516,17 +1516,19 @@ var LeaferUI = (function (exports) {
|
|
|
1516
1516
|
assign(t, defaultData);
|
|
1517
1517
|
return t;
|
|
1518
1518
|
},
|
|
1519
|
-
assign(t, merge) {
|
|
1519
|
+
assign(t, merge, exclude) {
|
|
1520
1520
|
let value;
|
|
1521
1521
|
Object.keys(merge).forEach(key => {
|
|
1522
|
-
var _a;
|
|
1522
|
+
var _a, _b;
|
|
1523
1523
|
value = merge[key];
|
|
1524
|
-
if ((value === null || value === void 0 ? void 0 : value.constructor) === Object)
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1524
|
+
if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object)
|
|
1525
|
+
return assign(t[key], merge[key], exclude && exclude[key]);
|
|
1526
|
+
if (exclude && (key in exclude)) {
|
|
1527
|
+
if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object)
|
|
1528
|
+
assign(t[key] = {}, merge[key], exclude[key]);
|
|
1529
|
+
return;
|
|
1529
1530
|
}
|
|
1531
|
+
t[key] = merge[key];
|
|
1530
1532
|
});
|
|
1531
1533
|
},
|
|
1532
1534
|
copyAttrs(t, from, include) {
|
|
@@ -2598,7 +2600,7 @@ var LeaferUI = (function (exports) {
|
|
|
2598
2600
|
const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
|
|
2599
2601
|
const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
|
|
2600
2602
|
const { ellipticalArc } = EllipseHelper;
|
|
2601
|
-
const debug$
|
|
2603
|
+
const debug$b = Debug.get('PathConvert');
|
|
2602
2604
|
const setEndPoint$1 = {};
|
|
2603
2605
|
const PathConvert = {
|
|
2604
2606
|
current: { dot: 0 },
|
|
@@ -2839,7 +2841,7 @@ var LeaferUI = (function (exports) {
|
|
|
2839
2841
|
i += 6;
|
|
2840
2842
|
break;
|
|
2841
2843
|
default:
|
|
2842
|
-
debug$
|
|
2844
|
+
debug$b.error(`command: ${command} [index:${i}]`, old);
|
|
2843
2845
|
return data;
|
|
2844
2846
|
}
|
|
2845
2847
|
lastCommand = command;
|
|
@@ -3064,7 +3066,7 @@ var LeaferUI = (function (exports) {
|
|
|
3064
3066
|
}
|
|
3065
3067
|
|
|
3066
3068
|
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
|
|
3067
|
-
const debug$
|
|
3069
|
+
const debug$a = Debug.get('PathDrawer');
|
|
3068
3070
|
const PathDrawer = {
|
|
3069
3071
|
drawPathByData(drawer, data) {
|
|
3070
3072
|
if (!data)
|
|
@@ -3127,7 +3129,7 @@ var LeaferUI = (function (exports) {
|
|
|
3127
3129
|
i += 6;
|
|
3128
3130
|
break;
|
|
3129
3131
|
default:
|
|
3130
|
-
debug$
|
|
3132
|
+
debug$a.error(`command: ${command} [index:${i}]`, data);
|
|
3131
3133
|
return;
|
|
3132
3134
|
}
|
|
3133
3135
|
}
|
|
@@ -3137,7 +3139,7 @@ var LeaferUI = (function (exports) {
|
|
|
3137
3139
|
const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F: F$1, O, P, U } = PathCommandMap;
|
|
3138
3140
|
const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
|
|
3139
3141
|
const { addPointBounds, copy: copy$7, addPoint: addPoint$1, setPoint: setPoint$1, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
|
|
3140
|
-
const debug$
|
|
3142
|
+
const debug$9 = Debug.get('PathBounds');
|
|
3141
3143
|
let radius, radiusX, radiusY;
|
|
3142
3144
|
const tempPointBounds = {};
|
|
3143
3145
|
const setPointBounds = {};
|
|
@@ -3245,7 +3247,7 @@ var LeaferUI = (function (exports) {
|
|
|
3245
3247
|
i += 6;
|
|
3246
3248
|
break;
|
|
3247
3249
|
default:
|
|
3248
|
-
debug$
|
|
3250
|
+
debug$9.error(`command: ${command} [index:${i}]`, data);
|
|
3249
3251
|
return;
|
|
3250
3252
|
}
|
|
3251
3253
|
}
|
|
@@ -3361,7 +3363,7 @@ var LeaferUI = (function (exports) {
|
|
|
3361
3363
|
const F = FileHelper;
|
|
3362
3364
|
F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3363
3365
|
|
|
3364
|
-
const debug$
|
|
3366
|
+
const debug$8 = Debug.get('TaskProcessor');
|
|
3365
3367
|
class TaskItem {
|
|
3366
3368
|
constructor(task) {
|
|
3367
3369
|
this.parallel = true;
|
|
@@ -3376,7 +3378,7 @@ var LeaferUI = (function (exports) {
|
|
|
3376
3378
|
yield this.task();
|
|
3377
3379
|
}
|
|
3378
3380
|
catch (error) {
|
|
3379
|
-
debug$
|
|
3381
|
+
debug$8.error(error);
|
|
3380
3382
|
}
|
|
3381
3383
|
});
|
|
3382
3384
|
}
|
|
@@ -3894,6 +3896,8 @@ var LeaferUI = (function (exports) {
|
|
|
3894
3896
|
return decorateLeafAttr(defaultValue, (key) => attr({
|
|
3895
3897
|
set(value) {
|
|
3896
3898
|
this.__setAttr(key, value) && (this.__layout.opacityChanged || this.__layout.opacityChange());
|
|
3899
|
+
if (this.mask)
|
|
3900
|
+
checkMask(this);
|
|
3897
3901
|
}
|
|
3898
3902
|
}));
|
|
3899
3903
|
}
|
|
@@ -3910,9 +3914,20 @@ var LeaferUI = (function (exports) {
|
|
|
3910
3914
|
this.__runAnimation('in');
|
|
3911
3915
|
}
|
|
3912
3916
|
doVisible(this, key, value, oldValue);
|
|
3917
|
+
if (this.mask)
|
|
3918
|
+
checkMask(this);
|
|
3913
3919
|
}
|
|
3914
3920
|
}));
|
|
3915
3921
|
}
|
|
3922
|
+
function checkMask(leaf) {
|
|
3923
|
+
const { parent } = leaf;
|
|
3924
|
+
if (parent) {
|
|
3925
|
+
const { __hasMask } = parent;
|
|
3926
|
+
parent.__updateMask();
|
|
3927
|
+
if (__hasMask !== parent.__hasMask)
|
|
3928
|
+
parent.forceUpdate();
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3916
3931
|
function doVisible(leaf, key, value, oldValue) {
|
|
3917
3932
|
if (leaf.__setAttr(key, value)) {
|
|
3918
3933
|
leaf.__layout.opacityChanged || leaf.__layout.opacityChange();
|
|
@@ -4050,7 +4065,7 @@ var LeaferUI = (function (exports) {
|
|
|
4050
4065
|
defineKey(data, key, property);
|
|
4051
4066
|
}
|
|
4052
4067
|
|
|
4053
|
-
const debug$
|
|
4068
|
+
const debug$7 = new Debug('rewrite');
|
|
4054
4069
|
const list = [];
|
|
4055
4070
|
const excludeNames = ['destroy', 'constructor'];
|
|
4056
4071
|
function rewrite(method) {
|
|
@@ -4067,7 +4082,7 @@ var LeaferUI = (function (exports) {
|
|
|
4067
4082
|
if (list.length) {
|
|
4068
4083
|
list.forEach(item => {
|
|
4069
4084
|
if (error)
|
|
4070
|
-
debug$
|
|
4085
|
+
debug$7.error(item.name, '需在Class上装饰@rewriteAble()');
|
|
4071
4086
|
item.run();
|
|
4072
4087
|
});
|
|
4073
4088
|
list.length = 0;
|
|
@@ -4975,13 +4990,13 @@ var LeaferUI = (function (exports) {
|
|
|
4975
4990
|
const LeafEventer = { on, on_, off, off_, once, emit: emit$1, emitEvent, hasEvent, destroyEventer: destroy };
|
|
4976
4991
|
|
|
4977
4992
|
const { isFinite } = Number;
|
|
4978
|
-
const debug$
|
|
4993
|
+
const debug$6 = Debug.get('setAttr');
|
|
4979
4994
|
const LeafDataProxy = {
|
|
4980
4995
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
4981
4996
|
if (this.leaferIsCreated) {
|
|
4982
4997
|
const oldValue = this.__.__getInput(name);
|
|
4983
4998
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
4984
|
-
debug$
|
|
4999
|
+
debug$6.warn(this.innerName, name, newValue);
|
|
4985
5000
|
newValue = undefined;
|
|
4986
5001
|
}
|
|
4987
5002
|
if (typeof newValue === 'object' || oldValue !== newValue) {
|
|
@@ -5437,8 +5452,8 @@ var LeaferUI = (function (exports) {
|
|
|
5437
5452
|
canvas.clearRect(r.x, r.y, r.width, r.height);
|
|
5438
5453
|
canvas.restore();
|
|
5439
5454
|
}
|
|
5440
|
-
__updateMask(
|
|
5441
|
-
this.__hasMask =
|
|
5455
|
+
__updateMask(_value) {
|
|
5456
|
+
this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
|
|
5442
5457
|
}
|
|
5443
5458
|
__renderMask(_canvas, _options) { }
|
|
5444
5459
|
__getNowWorld(options) {
|
|
@@ -5681,6 +5696,7 @@ var LeaferUI = (function (exports) {
|
|
|
5681
5696
|
const { setListWithFn } = BoundsHelper;
|
|
5682
5697
|
const { sort } = BranchHelper;
|
|
5683
5698
|
const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
|
|
5699
|
+
const debug$5 = new Debug('Branch');
|
|
5684
5700
|
exports.Branch = class Branch extends exports.Leaf {
|
|
5685
5701
|
__updateStrokeSpread() {
|
|
5686
5702
|
const { children } = this;
|
|
@@ -5721,8 +5737,8 @@ var LeaferUI = (function (exports) {
|
|
|
5721
5737
|
}
|
|
5722
5738
|
}
|
|
5723
5739
|
add(child, index) {
|
|
5724
|
-
if (child === this)
|
|
5725
|
-
return;
|
|
5740
|
+
if (child === this || child.destroyed)
|
|
5741
|
+
return debug$5.warn('add self or destroyed');
|
|
5726
5742
|
const noIndex = index === undefined;
|
|
5727
5743
|
if (!child.__) {
|
|
5728
5744
|
if (child instanceof Array)
|
|
@@ -5736,8 +5752,9 @@ var LeaferUI = (function (exports) {
|
|
|
5736
5752
|
noIndex ? this.children.push(child) : this.children.splice(index, 0, child);
|
|
5737
5753
|
if (child.isBranch)
|
|
5738
5754
|
this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
|
|
5739
|
-
|
|
5740
|
-
|
|
5755
|
+
const childLayout = child.__layout;
|
|
5756
|
+
childLayout.boxChanged || childLayout.boxChange();
|
|
5757
|
+
childLayout.matrixChanged || childLayout.matrixChange();
|
|
5741
5758
|
if (child.__bubbleMap)
|
|
5742
5759
|
child.__emitLifeEvent(ChildEvent.ADD);
|
|
5743
5760
|
if (this.leafer) {
|
|
@@ -5975,7 +5992,7 @@ var LeaferUI = (function (exports) {
|
|
|
5975
5992
|
}
|
|
5976
5993
|
}
|
|
5977
5994
|
|
|
5978
|
-
const version = "1.1.
|
|
5995
|
+
const version = "1.1.1";
|
|
5979
5996
|
|
|
5980
5997
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5981
5998
|
get allowBackgroundColor() { return true; }
|
|
@@ -6420,25 +6437,25 @@ var LeaferUI = (function (exports) {
|
|
|
6420
6437
|
if (userConfig)
|
|
6421
6438
|
this.config = DataHelper.default(userConfig, this.config);
|
|
6422
6439
|
this.__listenEvents();
|
|
6423
|
-
this.__requestRender();
|
|
6424
6440
|
}
|
|
6425
6441
|
start() {
|
|
6426
6442
|
this.running = true;
|
|
6443
|
+
this.update(false);
|
|
6427
6444
|
}
|
|
6428
6445
|
stop() {
|
|
6429
6446
|
this.running = false;
|
|
6430
6447
|
}
|
|
6431
|
-
update() {
|
|
6432
|
-
this.changed
|
|
6448
|
+
update(change = true) {
|
|
6449
|
+
if (!this.changed)
|
|
6450
|
+
this.changed = change;
|
|
6451
|
+
this.__requestRender();
|
|
6433
6452
|
}
|
|
6434
6453
|
requestLayout() {
|
|
6435
6454
|
this.target.emit(LayoutEvent.REQUEST);
|
|
6436
6455
|
}
|
|
6437
6456
|
render(callback) {
|
|
6438
|
-
if (!(this.running && this.canvas.view))
|
|
6439
|
-
this.
|
|
6440
|
-
return;
|
|
6441
|
-
}
|
|
6457
|
+
if (!(this.running && this.canvas.view))
|
|
6458
|
+
return this.update();
|
|
6442
6459
|
const { target } = this;
|
|
6443
6460
|
this.times = 0;
|
|
6444
6461
|
this.totalBounds = new Bounds();
|
|
@@ -6572,16 +6589,17 @@ var LeaferUI = (function (exports) {
|
|
|
6572
6589
|
}
|
|
6573
6590
|
}
|
|
6574
6591
|
__requestRender() {
|
|
6575
|
-
|
|
6592
|
+
if (this.requestTime)
|
|
6593
|
+
return;
|
|
6594
|
+
const requestTime = this.requestTime = Date.now();
|
|
6576
6595
|
Platform.requestRender(() => {
|
|
6577
|
-
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() -
|
|
6596
|
+
this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
|
|
6597
|
+
this.requestTime = 0;
|
|
6578
6598
|
if (this.running) {
|
|
6579
6599
|
if (this.changed && this.canvas.view)
|
|
6580
6600
|
this.render();
|
|
6581
6601
|
this.target.emit(RenderEvent.NEXT);
|
|
6582
6602
|
}
|
|
6583
|
-
if (this.target)
|
|
6584
|
-
this.__requestRender();
|
|
6585
6603
|
});
|
|
6586
6604
|
}
|
|
6587
6605
|
__onResize(e) {
|
|
@@ -6597,7 +6615,7 @@ var LeaferUI = (function (exports) {
|
|
|
6597
6615
|
}
|
|
6598
6616
|
}
|
|
6599
6617
|
this.addBlock(new Bounds(0, 0, 1, 1));
|
|
6600
|
-
this.
|
|
6618
|
+
this.update();
|
|
6601
6619
|
}
|
|
6602
6620
|
__onLayoutEnd(event) {
|
|
6603
6621
|
if (event.data)
|
|
@@ -6732,7 +6750,7 @@ var LeaferUI = (function (exports) {
|
|
|
6732
6750
|
return true;
|
|
6733
6751
|
return t.fill && this.__hasStroke;
|
|
6734
6752
|
}
|
|
6735
|
-
get __clipAfterFill() { return (
|
|
6753
|
+
get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
|
|
6736
6754
|
get __autoWidth() { return !this._width; }
|
|
6737
6755
|
get __autoHeight() { return !this._height; }
|
|
6738
6756
|
get __autoSide() { return !this._width || !this._height; }
|
|
@@ -6846,7 +6864,7 @@ var LeaferUI = (function (exports) {
|
|
|
6846
6864
|
|
|
6847
6865
|
class BoxData extends GroupData {
|
|
6848
6866
|
get __boxStroke() { return !this.__pathInputed; }
|
|
6849
|
-
get __drawAfterFill() { return
|
|
6867
|
+
get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
|
|
6850
6868
|
get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
|
|
6851
6869
|
}
|
|
6852
6870
|
|
|
@@ -7506,20 +7524,10 @@ var LeaferUI = (function (exports) {
|
|
|
7506
7524
|
constructor(userConfig, data) {
|
|
7507
7525
|
super(data);
|
|
7508
7526
|
this.config = {
|
|
7509
|
-
type: 'design',
|
|
7510
7527
|
start: true,
|
|
7511
7528
|
hittable: true,
|
|
7512
7529
|
smooth: true,
|
|
7513
|
-
lazySpeard: 100
|
|
7514
|
-
zoom: {
|
|
7515
|
-
min: 0.01,
|
|
7516
|
-
max: 256
|
|
7517
|
-
},
|
|
7518
|
-
move: {
|
|
7519
|
-
holdSpaceKey: true,
|
|
7520
|
-
holdMiddleKey: true,
|
|
7521
|
-
autoDistance: 2
|
|
7522
|
-
}
|
|
7530
|
+
lazySpeard: 100
|
|
7523
7531
|
};
|
|
7524
7532
|
this.leafs = 0;
|
|
7525
7533
|
this.__eventIds = [];
|
|
@@ -7536,23 +7544,27 @@ var LeaferUI = (function (exports) {
|
|
|
7536
7544
|
init(userConfig, parentApp) {
|
|
7537
7545
|
if (this.canvas)
|
|
7538
7546
|
return;
|
|
7539
|
-
this.__setLeafer(this);
|
|
7540
|
-
if (userConfig)
|
|
7541
|
-
DataHelper.assign(this.config, userConfig);
|
|
7542
7547
|
let start;
|
|
7543
7548
|
const { config } = this;
|
|
7544
|
-
this.
|
|
7549
|
+
this.__setLeafer(this);
|
|
7550
|
+
if (parentApp) {
|
|
7551
|
+
this.parentApp = parentApp;
|
|
7552
|
+
this.__bindApp(parentApp);
|
|
7553
|
+
start = parentApp.running;
|
|
7554
|
+
}
|
|
7555
|
+
if (userConfig) {
|
|
7556
|
+
this.parent = parentApp;
|
|
7557
|
+
this.initType(userConfig.type);
|
|
7558
|
+
this.parent = undefined;
|
|
7559
|
+
DataHelper.assign(config, userConfig);
|
|
7560
|
+
}
|
|
7545
7561
|
const canvas = this.canvas = Creator.canvas(config);
|
|
7546
7562
|
this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
|
|
7547
7563
|
if (this.isApp)
|
|
7548
7564
|
this.__setApp();
|
|
7549
7565
|
this.__checkAutoLayout(config, parentApp);
|
|
7550
7566
|
this.view = canvas.view;
|
|
7551
|
-
if (parentApp) {
|
|
7552
|
-
this.__bindApp(parentApp);
|
|
7553
|
-
start = parentApp.running;
|
|
7554
|
-
}
|
|
7555
|
-
else {
|
|
7567
|
+
if (!parentApp) {
|
|
7556
7568
|
this.selector = Creator.selector(this);
|
|
7557
7569
|
this.interaction = Creator.interaction(this, canvas, this.selector, config);
|
|
7558
7570
|
if (this.interaction) {
|
|
@@ -7609,7 +7621,11 @@ var LeaferUI = (function (exports) {
|
|
|
7609
7621
|
forceRender(bounds) {
|
|
7610
7622
|
this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
|
|
7611
7623
|
if (this.viewReady)
|
|
7612
|
-
this.renderer.
|
|
7624
|
+
this.renderer.render();
|
|
7625
|
+
}
|
|
7626
|
+
requestRender(change = false) {
|
|
7627
|
+
if (this.renderer)
|
|
7628
|
+
this.renderer.update(change);
|
|
7613
7629
|
}
|
|
7614
7630
|
updateCursor(cursor) {
|
|
7615
7631
|
const i = this.interaction;
|
|
@@ -7717,8 +7733,10 @@ var LeaferUI = (function (exports) {
|
|
|
7717
7733
|
const { imageReady } = this;
|
|
7718
7734
|
if (imageReady && !this.viewCompleted)
|
|
7719
7735
|
this.__checkViewCompleted();
|
|
7720
|
-
if (!imageReady)
|
|
7736
|
+
if (!imageReady) {
|
|
7721
7737
|
this.viewCompleted = false;
|
|
7738
|
+
this.requestRender();
|
|
7739
|
+
}
|
|
7722
7740
|
}
|
|
7723
7741
|
}
|
|
7724
7742
|
__checkViewCompleted(emit = true) {
|
|
@@ -7776,6 +7794,7 @@ var LeaferUI = (function (exports) {
|
|
|
7776
7794
|
}
|
|
7777
7795
|
else
|
|
7778
7796
|
list.push(item);
|
|
7797
|
+
this.requestRender();
|
|
7779
7798
|
}
|
|
7780
7799
|
zoom(_zoomType, _padding, _fixedScale) {
|
|
7781
7800
|
return needPlugin('view');
|
|
@@ -7829,7 +7848,7 @@ var LeaferUI = (function (exports) {
|
|
|
7829
7848
|
this.canvasManager.destroy();
|
|
7830
7849
|
}
|
|
7831
7850
|
this.canvas.destroy();
|
|
7832
|
-
this.config.view = this.view = null;
|
|
7851
|
+
this.config.view = this.view = this.parentApp = null;
|
|
7833
7852
|
if (this.userConfig)
|
|
7834
7853
|
this.userConfig.view = null;
|
|
7835
7854
|
super.destroy();
|
package/dist/worker.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:i}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((a,o)=>{t.convertToBlob({type:i(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>a(t.target.result),e.onerror=t=>o(t),e.readAsDataURL(t)})).catch((t=>{o(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:i(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((n,i)=>{let a=new XMLHttpRequest;a.open("GET",t.Platform.image.getRealURL(e),!0),a.responseType="blob",a.onload=()=>{createImageBitmap(a.response).then((t=>{n(t)})).catch((t=>{i(t)}))},a.onerror=t=>i(t),a.send()}))},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):o.indexOf("Safari")>-1&&-1===o.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class s{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:r,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper,f={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(f):this.afterBounds.setListWithFn(t,u),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:g,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class m{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){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.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:o,LAYOUT:s,AFTER:u}=t.LayoutEvent,f=this.getBlocks(a);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,f,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?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(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||l(i[t])}l(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(a),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(s,f,this.times)),i.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:o}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,s,this.times)),m.fullLayout(n),s.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,s,this.times)),n.emitEvent(new t.LayoutEvent(o,s,this.times)),this.addBlocks(s),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class v{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,y.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,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.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 y.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),o=e.includes(this.target.__world),s=new t.Bounds(a);i.save(),o&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,o,s),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(){const e=Date.now();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-e))),this.running&&(this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)),this.target&&this.__requestRender()}))}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:i}=e.old;if(!new t.Bounds(0,0,n,i).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.changed=!0}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||y.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)}}function x(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;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,o)}function b(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?R(t,!0,e,n):E(e,n);break;case"inside":B("inside",t,a,e,n);break;case"outside":B("outside",t,a,e,n)}}function B(t,e,n,i,a){const{__strokeWidth:o,__font:s}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=s,n?R(e,!0,i,r):E(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",x(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 E(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;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,o)}function R(t,n,i,a){let o;for(let s=0,r=t.length;s<r;s++)o=t[s],o.image&&e.PaintImage.checkImage(i,a,o,!1)||o.style&&(a.strokeStyle=o.style,o.blendMode?(a.saveBlendMode(o.blendMode),n?E(i,a):a.stroke(),a.restoreBlendMode()):n?E(i,a):a.stroke())}function L(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new s(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new v(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:k,getOuterOf:S,getByMove:P,getIntersectData:A}=t.BoundsHelper;let C;function O(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:a}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:s,color:r,opacity:l}=n;return{type:o,blendMode:s,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,a,!C||!C[n.url]);case"linear":return e.PaintGradient.linearGradient(n,a);case"radial":return e.PaintGradient.radialGradient(n,a);case"angular":return e.PaintGradient.conicGradient(n,a);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const W={compute:function(t,n){const i=n.__,a=[];let o,s=i.__input[t];s instanceof Array||(s=[s]),C=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=s.length;i<o;i++)e=O(t,s[i],n),e&&a.push(e);i["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(o=a[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?x(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let a;const{windingRule:o,__font:s}=n.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&e.PaintImage.checkImage(n,i,a,!s)||a.style&&(i.fillStyle=a.style,a.transform?(i.save(),i.transform(a.transform),a.blendMode&&(i.blendMode=a.blendMode),s?x(n,i):o?i.fill(o):i.fill(),i.restore()):a.blendMode?(i.saveBlendMode(a.blendMode),s?x(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):s?x(n,i):o?i.fill(o):i.fill())},fillText:x,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(t,a,i),n.stroke(),i.__useArrow&&L(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 o=n.getSameCanvas(!0,!0);o.setStroke(t,2*a,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(void 0,a,i),R(t,!1,e,n),i.__useArrow&&L(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),R(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,s=n.getSameCanvas(!0,!0);e.__drawRenderPath(s),s.setStroke(void 0,2*a,i),R(t,!1,e,s),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,o),s.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:E,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let o,s,r,l,{scaleX:d,scaleY:c}=a;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(a))l=i,o=r=a;else{const{renderShapeSpread:i}=t.__layout,h=A(i?k(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,a);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=S(a,s),o=P(r,-s.e,-s.f),n.matrix){const{matrix:t}=n;s.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:s.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:s,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let M={};const{get:T,rotateOfOuter:I,translate:D,scaleOfOuter:H,scale:F,rotate:Y}=t.MatrixHelper;function G(t,e,n,i,a,o,s){const r=T();D(r,e.x+n,e.y+i),F(r,a,o),s&&I(r,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=r}function j(t,e,n,i,a,o,s){const r=T();D(r,e.x+n,e.y+i),a&&F(r,a,o),s&&Y(r,s),t.transform=r}function X(t,e,n,i,a,o,s,r,l,d){const c=T();if(l)if("center"===d)I(c,{x:n/2,y:i/2},l);else switch(Y(c,l),l){case 90:D(c,i,0);break;case 180:D(c,n,i);break;case 270:D(c,0,n)}M.x=e.x+a,M.y=e.y+o,D(c,M.x,M.y),s&&H(c,M,s,r),t.transform=c}const{get:U,translate:z}=t.MatrixHelper,N=new t.Bounds,q={},V={};function Q(t,e,n,i){const{blendMode:a,sync:o}=n;a&&(t.blendMode=a),o&&(t.sync=o),t.data=J(n,i,e)}function J(e,n,i){let{width:a,height:o}=i;e.padding&&(n=N.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:s,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===a&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:a,m=_?a:o;let y,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,V),y=V.scaleX,v=V.scaleY);else if(!p||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-a*y)/2,b+=(n.height-o*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,q,!0),x+=q.x,b+=q.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(a=n.width,o=n.height);break;case"normal":case"clip":(x||b||y||u)&&j(g,n,x,b,y,v,u);break;case"repeat":(!p||y||u)&&X(g,n,a,o,x,b,y,v,u,l),f||(g.repeat="repeat");break;default:y&&G(g,n,x,b,y,v,u)}return g.transform||(n.x||n.y)&&(g.transform=U(),z(g.transform,n.x,n.y)),y&&"stretch"!==r&&(g.scaleX=y,g.scaleY=v),g.width=a,g.height=o,s&&(g.opacity=s),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let Z,K=new t.Bounds;const{isSame:$}=t.BoundsHelper;function tt(t,e,n,i,a,o){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||Q(a,i,n,o),!0}function et(e,n){at(e,t.ImageEvent.LOAD,n)}function nt(e,n){at(e,t.ImageEvent.LOADED,n)}function it(e,n,i){n.error=i,e.forceUpdate("surface"),at(e,t.ImageEvent.ERROR,n)}function at(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ot(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:st,scale:rt,copy:lt}=t.MatrixHelper,{ceil:dt,abs:ct}=Math;function ht(e,n,i){let{scaleX:a,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=a+"-"+o+"-"+i;if(n.patternId===s||e.destroyed)return!1;{a=ct(a),o=ct(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=st(),lt(d,g),rt(d,1/u,1/f),a*=u,o*=f),a*=i,o*=i,c*=a,h*=o;const w=c*h;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&&(a/=l,o/=l,c/=l,h/=l),u&&(a/=u,o/=f),(g||1!==a||1!==o)&&(d||(d=st(),g&<(d,g)),rt(d,1/a,1/o));const y=e.getCanvas(dt(c)||1,dt(h)||1,p),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=s,!0}}function ut(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(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(s,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ft}=Math;const pt={image:function(e,n,i,a,o){let s,r;const l=t.ImageManager.get(i);return Z&&i===Z.paint&&$(a,Z.boxBounds)?s=Z.leafPaint:(s={type:i.type,image:l},Z=l.use>1?{leafPaint:s,paint:i,boxBounds:K.set(a)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(tt(e,n,i,l,s,a),o&&(et(e,r),nt(e,r))):l.error?o&&it(e,r,l.error):(o&&(ot(e,!0),et(e,r)),s.loadId=l.load((()=>{ot(e,!1),e.destroyed||(tt(e,n,i,l,s,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),nt(e,r)),s.loadId=null}),(t=>{ot(e,!1),it(e,r,t),s.loadId=null}))),s},checkImage:function(n,i,a,o){const{scaleX:s,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!a.data||a.patternId===s+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=a;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=ft(s)*l,i*=ft(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),a.blendMode&&(i.blendMode=a.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(a.image.view,0,0,d.width,d.height),i.restore(),!0):(!a.style||a.sync||e.Export.running?ht(n,a,l):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>ut(this,void 0,void 0,(function*(){a.patternTask=null,i.bounds.hit(n.__nowWorld)&&ht(n,a,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ht,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,o,s,r;for(let l=0,d=i.length;l<d;l++)a=i[l].image,r=a&&a.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(a),a.loading&&(s||(s=n.__input&&n.__input[e]||[],s instanceof Array||(s=[s])),a.unload(i[l].loadId,!s.some((t=>t.url===r)))));return o}return null},createData:Q,getPatternData:J,fillOrFitMode:G,clipMode:j,repeatMode:X},{toPoint:gt}=t.AroundHelper,_t={},wt={};function mt(t,n,i){if(n){let a;for(let o=0,s=n.length;o<s;o++)a=n[o],"string"==typeof a?t.addColorStop(o/(s-1),e.ColorConvert.string(a,i)):t.addColorStop(a.offset,e.ColorConvert.string(a.color,i))}}const{getAngle:yt,getDistance:vt}=t.PointHelper,{get:xt,rotateOfOuter:bt,scaleOfOuter:Bt}=t.MatrixHelper,{toPoint:Et}=t.AroundHelper,Rt={},Lt={};function kt(t,e,n,i,a){let o;const{width:s,height:r}=t;if(s!==r||i){const t=yt(e,n);o=xt(),a?(Bt(o,e,s/r*(i||1),1),bt(o,e,t+90)):(Bt(o,e,1,s/r*(i||1)),bt(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:Pt}=t.AroundHelper,At={},Ct={};const Ot={linearGradient:function(e,n){let{from:i,to:a,type:o,blendMode:s,opacity:r}=e;gt(i||"top",n,_t),gt(a||"bottom",n,wt);const l=t.Platform.canvas.createLinearGradient(_t.x,_t.y,wt.x,wt.y);mt(l,e.stops,r);const d={type:o,style:l};return s&&(d.blendMode=s),d},radialGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Et(i||"center",n,Rt),Et(a||"bottom",n,Lt);const d=t.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,vt(Rt,Lt));mt(d,e.stops,s);const c={type:o,style:d},h=kt(n,Rt,Lt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Pt(i||"center",n,At),Pt(a||"bottom",n,Ct);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,At.x,At.y):t.Platform.canvas.createRadialGradient(At.x,At.y,0,At.x,At.y,St(At,Ct));mt(d,e.stops,s);const c={type:o,style:d},h=kt(n,At,Ct,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:kt},{copy:Wt,toOffsetOutBounds:Mt}=t.BoundsHelper,Tt={},It={};function Dt(e,n,i,a){const{bounds:o,shapeBounds:s}=a;if(t.Platform.fullImageShadow){if(Wt(Tt,e.bounds),Tt.x+=n.x-s.x,Tt.y+=n.y-s.y,i){const{matrix:t}=a;Tt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Tt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Tt.width*=i,Tt.height*=i}e.copyWorld(a.canvas,e.bounds,Tt)}else i&&(Wt(Tt,n),Tt.x-=n.width/2*(i-1),Tt.y-=n.height/2*(i-1),Tt.width*=i,Tt.height*=i),e.copyWorld(a.canvas,s,i?Tt:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={};const Yt={shadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Mt(d,It),r.forEach(((r,g)=>{f.setWorldShadow(It.offsetX+r.x*h,It.offsetY+r.y*u,r.blur*h,r.color),a=r.spread?1+2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Dt(f,It,a,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(d,Ft),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h),a=r.spread?1-2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Dt(f,Ft,a,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.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:Gt}=t.LeafBoundsHelper;function jt(t,e,n,i,a,o){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),Ut(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Ut(t,n,i,o);break;case"path":n.restore()}}function Xt(t){return t.getSameCanvas(!1,!0)}function Ut(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}e.Group.prototype.__renderMask=function(t,e){let n,i,a,o,s,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(s&&(jt(this,s,t,a,i,o),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(s="opacity-path",o=n.opacity,a||(a=Xt(t))):(s="path",t.save()),n.__clip(a||t,e)):(s="grayscale"===r?"grayscale":"alpha",i||(i=Xt(t)),a||(a=Xt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Gt(n,e)||n.__render(a||t,e);jt(this,s,t,a,i,o)};const zt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nt=zt+"_#~&*+\\=|≮≯≈≠=…",qt=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 Vt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Qt=Vt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Jt=Vt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Zt=Vt(zt),Kt=Vt(Nt),$t=Vt("- —/~|┆·");var te;!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"}(te||(te={}));const{Letter:ee,Single:ne,Before:ie,After:ae,Symbol:oe,Break:se}=te;function re(t){return Qt[t]?ee:$t[t]?se:Jt[t]?ie:Zt[t]?ae:Kt[t]?oe:qt.test(t)?ne:ee}const le={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let o=a-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function de(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:ce}=le,{Letter:he,Single:ue,Before:fe,After:pe,Symbol:ge,Break:_e}=te;let we,me,ye,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,Ae,Ce,Oe,We,Me=[];function Te(t,e){Re&&!Ee&&(Ee=Re),we.data.push({char:t,width:e}),ye+=e}function Ie(){ve+=ye,we.width=ye,me.words.push(we),we={data:[]},ye=0}function De(){Ae&&(Ce.paraNumber++,me.paraStart=!0,Ae=!1),Re&&(me.startCharSize=Ee,me.endCharSize=Re,Ee=0),me.width=ve,Oe.width?ce(me):We&&He(),Me.push(me),me={words:[]},ve=0}function He(){ve>(Ce.maxWidth||0)&&(Ce.maxWidth=ve)}const Fe=0,Ye=1,Ge=2;const{top:je,right:Xe,bottom:Ue,left:ze}=t.Direction4;function Ne(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 qe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,o=n.__getInput("width")||0,s=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[ze],o-=d[Xe]+d[ze]):n.autoSizeAlign||(i=d[ze]),s?(a=d[je],s-=d[je]+d[Ue]):n.autoSizeAlign||(a=d[je]));const c={bounds:{x:i,y:a,width:o,height:s},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ce=e,Me=e.rows,Oe=e.bounds,We=!Oe.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:o,textCase:s}=i,{canvas:r}=t.Platform,{width:l,height:d}=Oe;if(l||d||a||"none"!==s){const t="none"!==i.textWrap,e="break"===i.textWrap;Ae=!0,ke=null,Ee=Be=Re=ye=ve=0,we={data:[]},me={words:[]};for(let i=0,d=n.length;i<d;i++)be=n[i],"\n"===be?(ye&&Ie(),me.paraEnd=!0,De(),Ae=!0):(Le=re(be),Le===he&&"none"!==s&&(be=de(be,s,!ye)),Be=r.measureText(be).width,a&&(a<0&&(Re=Be),Be+=a),Se=Le===ue&&(ke===ue||ke===he)||ke===ue&&Le!==pe,Pe=!(Le!==fe&&Le!==ue||ke!==ge&&ke!==pe),xe=Ae&&o?l-o:l,t&&l&&ve+ye+Be>xe&&(e?(ye&&Ie(),ve&&De()):(Pe||(Pe=Le===he&&ke==pe),Se||Pe||Le===_e||Le===fe||Le===ue||ye+Be>xe?(ye&&Ie(),ve&&De()):ve&&De()))," "===be&&!0!==Ae&&ve+ye===0||(Le===_e?(" "===be&&ye&&Ie(),Te(be,Be),Ie()):Se||Pe?(ye&&Ie(),Te(be,Be)):Te(be,Be)),ke=Le);ye&&Ie(),ve&&De(),Me.length>0&&(Me[Me.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ce.paraNumber++,ve=r.measureText(t).width,Me.push({x:o||0,text:t,width:ve,paraStart:!0}),We&&He()}))}(c,e,n),d&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ne(e,"x",t[ze]);break;case"right":Ne(e,"x",-t[Xe])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ne(e,"y",t[je]);break;case"bottom":Ne(e,"y",-t[Ue])}}(d,c,n,o,s),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:o,__letterSpacing:s,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=a*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,a),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,y,v,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=a,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,s<0&&(m.width<0?(v=-m.width+e.fontSize+s,y-=v,v+=e.fontSize):v-=s),y<i.x&&(i.x=y),v>i.width&&(i.width=v),r&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:a}=t,{textAlign:o,paraIndent:s,letterSpacing:r}=e;let l,d,c,h,u;a.forEach((t=>{t.words&&(c=s&&t.paraStart?s:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Fe:d>.01?Ye:Ge,t.isOverflow&&!r&&(t.textMode=!0),h===Ge?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===Ye?(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)}))}(c,n,o),c.overflow&&function(e,n,i,a){if(!a)return;const{rows:o,overflow:s}=e;let{textOverflow:r}=n;if(o.splice(s),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+a-d;("none"===n.textWrap?o:[o[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==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)}}))}}(c,n,i,o),"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}}(c,n),c}};const Ve={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;i&&(a*=n);const o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}},{setPoint:Qe,addPoint:Je,toBounds:Ze}=t.TwoPointBoundsHelper;const Ke={export(e,n,i){this.running=!0;const a=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){$e||($e=new t.TaskProcessor);return new Promise((t=>{$e.add((()=>ut(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((s=>new Promise((r=>{const l=t=>{s(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===a)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===a)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(tn(e),h.waitViewCompleted((()=>ut(this,void 0,void 0,(function*(){let a,o,s=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,y=c&&m&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)a=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(s=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),s/=e.scaleX,r/=e.scaleY;break;case"world":s=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;s/=s/n.scaleX,r/=r/n.scaleY}a=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,a,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(a).scale(b.scaleX,b.scaleY),S={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/s*b.scaleX,1/r*b.scaleY)};let P,A=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(P=e,P.__worldOpacity=0,e=h,S.bounds=A.bounds),A.save(),u&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(A,S),e.fill=t}else e.__render(A,S);if(A.restore(),P&&P.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:a}=e.context.getImageData(0,0,n,i);let o,s,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(o=l%n,s=(l-o)/n,r?Je(r,o,s):Qe(r={},o,s)),l++;const d=new t.Bounds;return Ze(r,d),d.scale(1/e.pixelRatio).ceil()}(A);const e=A,{width:n,height:i}=o,a={x:0,y:0,width:n,height:i,pixelRatio:B};A=t.Creator.canvas(a),A.copyWorld(e,o,a)}v&&A.fillWorld(A.bounds,y||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===n?A:yield A.export(n,i);l({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:a,trimBounds:o})}))))):l({data:!1})}))))}};let $e;function tn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>tn(t)))}const en=t.LeaferCanvasBase.prototype,nn=t.Debug.get("@leafer-ui/export");en.export=function(e,n){const{quality:i,blob:a}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):a?this.toBlob(e,i):this.toDataURL(e,i)},en.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{nn.error(t),i(null)}))}))},en.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},en.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{nn.error(t),i(!1)}))}))},Object.assign(e.TextConvert,qe),Object.assign(e.ColorConvert,Ve),Object.assign(e.Paint,W),Object.assign(e.PaintImage,pt),Object.assign(e.PaintGradient,Ot),Object.assign(e.Effect,Yt),Object.assign(e.Export,Ke),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=v,exports.Watcher=s,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|
|
1
|
+
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:i}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((a,o)=>{t.convertToBlob({type:i(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>a(t.target.result),e.onerror=t=>o(t),e.readAsDataURL(t)})).catch((t=>{o(t)}))})),canvasToBolb:(t,e,n)=>t.convertToBlob({type:i(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise((t=>t())),download(t,e){},loadImage:e=>new Promise(((n,i)=>{let a=new XMLHttpRequest;a.open("GET",t.Platform.image.getRealURL(e),!0),a.responseType="blob",a.onload=()=>{createImageBitmap(a.response).then((t=>{n(t)})).catch((t=>{i(t)}))},a.onerror=t=>i(t),a.send()}))},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isWorker=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):o.indexOf("Safari")>-1&&-1===o.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class s{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:r,updateBounds:l,updateAllWorldOpacity:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper,f={x:0,y:0,width:1e5,height:1e5};class p{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,u)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(f):this.afterBounds.setListWithFn(t,u),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:g,updateAllChange:_}=t.LeafHelper,w=t.Debug.get("Layouter");class m{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){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.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:o,LAYOUT:s,AFTER:u}=t.LayoutEvent,f=this.getBlocks(a);f.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,f,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?(r(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(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||l(i[t])}l(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&d(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(a),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(s,f,this.times)),i.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:a,AFTER:o}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,s,this.times)),m.fullLayout(n),s.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(a,s,this.times)),n.emitEvent(new t.LayoutEvent(o,s,this.times)),this.addBlocks(s),t.Run.end(e)}static fullLayout(e){g(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),_(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new p([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new p(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const y=t.Debug.get("Renderer");class v{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,y.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,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.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 y.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),o=e.includes(this.target.__world),s=new t.Bounds(a);i.save(),o&&!t.Debug.showRepaint?i.clear():(a.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(a,!0),i.clipWorld(a,!0)),this.__render(a,o,s),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||y.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)}}function x(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;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,o)}function b(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?R(t,!0,e,n):E(e,n);break;case"inside":B("inside",t,a,e,n);break;case"outside":B("outside",t,a,e,n)}}function B(t,e,n,i,a){const{__strokeWidth:o,__font:s}=i.__,r=a.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=s,n?R(e,!0,i,r):E(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",x(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 E(t,e){let n;const{rows:i,decorationY:a,decorationHeight:o}=t.__.__textDrawData;for(let t=0,s=i.length;t<s;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,o)}function R(t,n,i,a){let o;for(let s=0,r=t.length;s<r;s++)o=t[s],o.image&&e.PaintImage.checkImage(i,a,o,!1)||o.style&&(a.strokeStyle=o.style,o.blendMode?(a.saveBlendMode(o.blendMode),n?E(i,a):a.stroke(),a.restoreBlendMode()):n?E(i,a):a.stroke())}function L(t,e){t.__.dashPattern&&(e.beginPath(),t.__drawPathByData(e,t.__.__pathForArrow),e.dashPattern=null,e.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new s(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new v(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:k,getOuterOf:S,getByMove:P,getIntersectData:A}=t.BoundsHelper;let C;function O(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:a}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:s,color:r,opacity:l}=n;return{type:o,blendMode:s,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,a,!C||!C[n.url]);case"linear":return e.PaintGradient.linearGradient(n,a);case"radial":return e.PaintGradient.radialGradient(n,a);case"angular":return e.PaintGradient.conicGradient(n,a);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const W={compute:function(t,n){const i=n.__,a=[];let o,s=i.__input[t];s instanceof Array||(s=[s]),C=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=s.length;i<o;i++)e=O(t,s[i],n),e&&a.push(e);i["_"+t]=a.length?a:void 0,a.length&&a[0].image&&(o=a[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?x(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let a;const{windingRule:o,__font:s}=n.__;for(let r=0,l=t.length;r<l;r++)a=t[r],a.image&&e.PaintImage.checkImage(n,i,a,!s)||a.style&&(i.fillStyle=a.style,a.transform?(i.save(),i.transform(a.transform),a.blendMode&&(i.blendMode=a.blendMode),s?x(n,i):o?i.fill(o):i.fill(),i.restore()):a.blendMode?(i.saveBlendMode(a.blendMode),s?x(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):s?x(n,i):o?i.fill(o):i.fill())},fillText:x,stroke:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(t,a,i),n.stroke(),i.__useArrow&&L(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 o=n.getSameCanvas(!0,!0);o.setStroke(t,2*a,i),e.__drawRenderPath(o),o.stroke(),i.windingRule?o.clip(i.windingRule):o.clip(),o.clearWorld(e.__layout.renderBounds),e.__worldFlipped?n.copyWorldByReset(o,e.__nowWorld):n.copyWorldToInner(o,e.__nowWorld,e.__layout.renderBounds),o.recycle(e.__nowWorld)}},strokes:function(t,e,n){const i=e.__,{__strokeWidth:a,strokeAlign:o,__font:s}=i;if(a)if(s)b(t,e,n);else switch(o){case"center":n.setStroke(void 0,a,i),R(t,!1,e,n),i.__useArrow&&L(e,n);break;case"inside":n.save(),n.setStroke(void 0,2*a,i),i.windingRule?n.clip(i.windingRule):n.clip(),R(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,s=n.getSameCanvas(!0,!0);e.__drawRenderPath(s),s.setStroke(void 0,2*a,i),R(t,!1,e,s),i.windingRule?s.clip(i.windingRule):s.clip(),s.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(s,e.__nowWorld):n.copyWorldToInner(s,e.__nowWorld,o),s.recycle(e.__nowWorld)}},strokeText:b,drawTextStroke:E,shape:function(t,e,n){const i=e.getSameCanvas(),a=t.__nowWorld;let o,s,r,l,{scaleX:d,scaleY:c}=a;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(a))l=i,o=r=a;else{const{renderShapeSpread:i}=t.__layout,h=A(i?k(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,a);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=S(a,s),o=P(r,-s.e,-s.f),n.matrix){const{matrix:t}=n;s.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:s.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:s,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let T={};const{get:M,rotateOfOuter:I,translate:D,scaleOfOuter:H,scale:F,rotate:Y}=t.MatrixHelper;function G(t,e,n,i,a,o,s){const r=M();D(r,e.x+n,e.y+i),F(r,a,o),s&&I(r,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=r}function j(t,e,n,i,a,o,s){const r=M();D(r,e.x+n,e.y+i),a&&F(r,a,o),s&&Y(r,s),t.transform=r}function X(t,e,n,i,a,o,s,r,l,d){const c=M();if(l)if("center"===d)I(c,{x:n/2,y:i/2},l);else switch(Y(c,l),l){case 90:D(c,i,0);break;case 180:D(c,n,i);break;case 270:D(c,0,n)}T.x=e.x+a,T.y=e.y+o,D(c,T.x,T.y),s&&H(c,T,s,r),t.transform=c}const{get:U,translate:z}=t.MatrixHelper,q=new t.Bounds,N={},V={};function Q(t,e,n,i){const{blendMode:a,sync:o}=n;a&&(t.blendMode=a),o&&(t.sync=o),t.data=J(n,i,e)}function J(e,n,i){let{width:a,height:o}=i;e.padding&&(n=q.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:s,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===a&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:a,m=_?a:o;let y,v,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,V),y=V.scaleX,v=V.scaleY);else if(!p||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-a*y)/2,b+=(n.height-o*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,N,!0),x+=N.x,b+=N.y}switch(d&&(x+=d.x,b+=d.y),r){case"stretch":p||(a=n.width,o=n.height);break;case"normal":case"clip":(x||b||y||u)&&j(g,n,x,b,y,v,u);break;case"repeat":(!p||y||u)&&X(g,n,a,o,x,b,y,v,u,l),f||(g.repeat="repeat");break;default:y&&G(g,n,x,b,y,v,u)}return g.transform||(n.x||n.y)&&(g.transform=U(),z(g.transform,n.x,n.y)),y&&"stretch"!==r&&(g.scaleX=y,g.scaleY=v),g.width=a,g.height=o,s&&(g.opacity=s),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let Z,K=new t.Bounds;const{isSame:$}=t.BoundsHelper;function tt(t,e,n,i,a,o){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||Q(a,i,n,o),!0}function et(e,n){at(e,t.ImageEvent.LOAD,n)}function nt(e,n){at(e,t.ImageEvent.LOADED,n)}function it(e,n,i){n.error=i,e.forceUpdate("surface"),at(e,t.ImageEvent.ERROR,n)}function at(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function ot(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:st,scale:rt,copy:lt}=t.MatrixHelper,{ceil:dt,abs:ct}=Math;function ht(e,n,i){let{scaleX:a,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=a+"-"+o+"-"+i;if(n.patternId===s||e.destroyed)return!1;{a=ct(a),o=ct(o);const{image:e,data:r}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,opacity:p,transform:g,repeat:_}=r;u&&(d=st(),lt(d,g),rt(d,1/u,1/f),a*=u,o*=f),a*=i,o*=i,c*=a,h*=o;const w=c*h;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&&(a/=l,o/=l,c/=l,h/=l),u&&(a/=u,o/=f),(g||1!==a||1!==o)&&(d||(d=st(),g&<(d,g)),rt(d,1/a,1/o));const y=e.getCanvas(dt(c)||1,dt(h)||1,p),v=e.getPattern(y,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=v,n.patternId=s,!0}}function ut(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function r(t){try{l(i.throw(t))}catch(t){o(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(s,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:ft}=Math;const pt={image:function(e,n,i,a,o){let s,r;const l=t.ImageManager.get(i);return Z&&i===Z.paint&&$(a,Z.boxBounds)?s=Z.leafPaint:(s={type:i.type,image:l},Z=l.use>1?{leafPaint:s,paint:i,boxBounds:K.set(a)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(tt(e,n,i,l,s,a),o&&(et(e,r),nt(e,r))):l.error?o&&it(e,r,l.error):(o&&(ot(e,!0),et(e,r)),s.loadId=l.load((()=>{ot(e,!1),e.destroyed||(tt(e,n,i,l,s,a)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),nt(e,r)),s.loadId=null}),(t=>{ot(e,!1),it(e,r,t),s.loadId=null}))),s},checkImage:function(n,i,a,o){const{scaleX:s,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!a.data||a.patternId===s+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=a;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=ft(s)*l,i*=ft(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),n.windingRule?i.clip(n.windingRule):i.clip(),a.blendMode&&(i.blendMode=a.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(a.image.view,0,0,d.width,d.height),i.restore(),!0):(!a.style||a.sync||e.Export.running?ht(n,a,l):a.patternTask||(a.patternTask=t.ImageManager.patternTasker.add((()=>ut(this,void 0,void 0,(function*(){a.patternTask=null,i.bounds.hit(n.__nowWorld)&&ht(n,a,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ht,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let a,o,s,r;for(let l=0,d=i.length;l<d;l++)a=i[l].image,r=a&&a.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(a),a.loading&&(s||(s=n.__input&&n.__input[e]||[],s instanceof Array||(s=[s])),a.unload(i[l].loadId,!s.some((t=>t.url===r)))));return o}return null},createData:Q,getPatternData:J,fillOrFitMode:G,clipMode:j,repeatMode:X},{toPoint:gt}=t.AroundHelper,_t={},wt={};function mt(t,n,i){if(n){let a;for(let o=0,s=n.length;o<s;o++)a=n[o],"string"==typeof a?t.addColorStop(o/(s-1),e.ColorConvert.string(a,i)):t.addColorStop(a.offset,e.ColorConvert.string(a.color,i))}}const{getAngle:yt,getDistance:vt}=t.PointHelper,{get:xt,rotateOfOuter:bt,scaleOfOuter:Bt}=t.MatrixHelper,{toPoint:Et}=t.AroundHelper,Rt={},Lt={};function kt(t,e,n,i,a){let o;const{width:s,height:r}=t;if(s!==r||i){const t=yt(e,n);o=xt(),a?(Bt(o,e,s/r*(i||1),1),bt(o,e,t+90)):(Bt(o,e,1,s/r*(i||1)),bt(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:Pt}=t.AroundHelper,At={},Ct={};const Ot={linearGradient:function(e,n){let{from:i,to:a,type:o,blendMode:s,opacity:r}=e;gt(i||"top",n,_t),gt(a||"bottom",n,wt);const l=t.Platform.canvas.createLinearGradient(_t.x,_t.y,wt.x,wt.y);mt(l,e.stops,r);const d={type:o,style:l};return s&&(d.blendMode=s),d},radialGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Et(i||"center",n,Rt),Et(a||"bottom",n,Lt);const d=t.Platform.canvas.createRadialGradient(Rt.x,Rt.y,0,Rt.x,Rt.y,vt(Rt,Lt));mt(d,e.stops,s);const c={type:o,style:d},h=kt(n,Rt,Lt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:a,type:o,opacity:s,blendMode:r,stretch:l}=e;Pt(i||"center",n,At),Pt(a||"bottom",n,Ct);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,At.x,At.y):t.Platform.canvas.createRadialGradient(At.x,At.y,0,At.x,At.y,St(At,Ct));mt(d,e.stops,s);const c={type:o,style:d},h=kt(n,At,Ct,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:kt},{copy:Wt,toOffsetOutBounds:Tt}=t.BoundsHelper,Mt={},It={};function Dt(e,n,i,a){const{bounds:o,shapeBounds:s}=a;if(t.Platform.fullImageShadow){if(Wt(Mt,e.bounds),Mt.x+=n.x-s.x,Mt.y+=n.y-s.y,i){const{matrix:t}=a;Mt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Mt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Mt.width*=i,Mt.height*=i}e.copyWorld(a.canvas,e.bounds,Mt)}else i&&(Wt(Mt,n),Mt.x-=n.width/2*(i-1),Mt.y-=n.height/2*(i-1),Mt.width*=i,Mt.height*=i),e.copyWorld(a.canvas,s,i?Mt:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,Ft={};const Yt={shadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Tt(d,It),r.forEach(((r,g)=>{f.setWorldShadow(It.offsetX+r.x*h,It.offsetY+r.y*u,r.blur*h,r.color),a=r.spread?1+2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Dt(f,It,a,n),i=d,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,d,o,"copy"),i=o),l?f.copyWorld(l,o,o,"destination-out"):f.copyWorld(n.canvas,c,d,"destination-out")),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,a;const{__nowWorld:o,__layout:s}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(d,Ft),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(Ft.offsetX+r.x*h,Ft.offsetY+r.y*u,r.blur*h),a=r.spread?1-2*r.spread/(s.boxBounds.width+2*(s.strokeBoxSpread||0)):0,Dt(f,Ft,a,n),f.restore(),l?(f.copyWorld(f,d,o,"copy"),f.copyWorld(l,o,o,"source-out"),i=o):(f.copyWorld(n.canvas,c,d,"source-out"),i=d),f.fillWorld(i,r.color,"source-in"),t.__worldFlipped?e.copyWorldByReset(f,i,o,r.blendMode):e.copyWorldToInner(f,i,s.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:Gt}=t.LeafBoundsHelper;function jt(t,e,n,i,a,o){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),Ut(t,e,n,1)}(t,n,i,a);break;case"opacity-path":Ut(t,n,i,o);break;case"path":n.restore()}}function Xt(t){return t.getSameCanvas(!1,!0)}function Ut(t,e,n,i){const a=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,a),n.recycle(a)}e.Group.prototype.__renderMask=function(t,e){let n,i,a,o,s,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],r=n.__.mask,r&&(s&&(jt(this,s,t,a,i,o),i=a=null),"path"===r||"clipping-path"===r?(n.opacity<1?(s="opacity-path",o=n.opacity,a||(a=Xt(t))):(s="path",t.save()),n.__clip(a||t,e)):(s="grayscale"===r?"grayscale":"alpha",i||(i=Xt(t)),a||(a=Xt(t)),n.__render(i,e)),"clipping"!==r&&"clipping-path"!==r)||Gt(n,e)||n.__render(a||t,e);jt(this,s,t,a,i,o)};const zt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",qt=zt+"_#~&*+\\=|≮≯≈≠=…",Nt=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 Vt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Qt=Vt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Jt=Vt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Zt=Vt(zt),Kt=Vt(qt),$t=Vt("- —/~|┆·");var te;!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"}(te||(te={}));const{Letter:ee,Single:ne,Before:ie,After:ae,Symbol:oe,Break:se}=te;function re(t){return Qt[t]?ee:$t[t]?se:Jt[t]?ie:Zt[t]?ae:Kt[t]?oe:Nt.test(t)?ne:ee}const le={trimRight(t){const{words:e}=t;let n,i=0,a=e.length;for(let o=a-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(a-i,i)}};function de(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:ce}=le,{Letter:he,Single:ue,Before:fe,After:pe,Symbol:ge,Break:_e}=te;let we,me,ye,ve,xe,be,Be,Ee,Re,Le,ke,Se,Pe,Ae,Ce,Oe,We,Te=[];function Me(t,e){Re&&!Ee&&(Ee=Re),we.data.push({char:t,width:e}),ye+=e}function Ie(){ve+=ye,we.width=ye,me.words.push(we),we={data:[]},ye=0}function De(){Ae&&(Ce.paraNumber++,me.paraStart=!0,Ae=!1),Re&&(me.startCharSize=Ee,me.endCharSize=Re,Ee=0),me.width=ve,Oe.width?ce(me):We&&He(),Te.push(me),me={words:[]},ve=0}function He(){ve>(Ce.maxWidth||0)&&(Ce.maxWidth=ve)}const Fe=0,Ye=1,Ge=2;const{top:je,right:Xe,bottom:Ue,left:ze}=t.Direction4;function qe(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 Ne={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,a=0,o=n.__getInput("width")||0,s=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[ze],o-=d[Xe]+d[ze]):n.autoSizeAlign||(i=d[ze]),s?(a=d[je],s-=d[je]+d[Ue]):n.autoSizeAlign||(a=d[je]));const c={bounds:{x:i,y:a,width:o,height:s},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ce=e,Te=e.rows,Oe=e.bounds,We=!Oe.width&&!i.autoSizeAlign;const{__letterSpacing:a,paraIndent:o,textCase:s}=i,{canvas:r}=t.Platform,{width:l,height:d}=Oe;if(l||d||a||"none"!==s){const t="none"!==i.textWrap,e="break"===i.textWrap;Ae=!0,ke=null,Ee=Be=Re=ye=ve=0,we={data:[]},me={words:[]};for(let i=0,d=n.length;i<d;i++)be=n[i],"\n"===be?(ye&&Ie(),me.paraEnd=!0,De(),Ae=!0):(Le=re(be),Le===he&&"none"!==s&&(be=de(be,s,!ye)),Be=r.measureText(be).width,a&&(a<0&&(Re=Be),Be+=a),Se=Le===ue&&(ke===ue||ke===he)||ke===ue&&Le!==pe,Pe=!(Le!==fe&&Le!==ue||ke!==ge&&ke!==pe),xe=Ae&&o?l-o:l,t&&l&&ve+ye+Be>xe&&(e?(ye&&Ie(),ve&&De()):(Pe||(Pe=Le===he&&ke==pe),Se||Pe||Le===_e||Le===fe||Le===ue||ye+Be>xe?(ye&&Ie(),ve&&De()):ve&&De()))," "===be&&!0!==Ae&&ve+ye===0||(Le===_e?(" "===be&&ye&&Ie(),Me(be,Be),Ie()):Se||Pe?(ye&&Ie(),Me(be,Be)):Me(be,Be)),ke=Le);ye&&Ie(),ve&&De(),Te.length>0&&(Te[Te.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ce.paraNumber++,ve=r.measureText(t).width,Te.push({x:o||0,text:t,width:ve,paraStart:!0}),We&&He()}))}(c,e,n),d&&function(t,e,n,i,a){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":qe(e,"x",t[ze]);break;case"right":qe(e,"x",-t[Xe])}if(!a&&n.autoSizeAlign)switch(n.verticalAlign){case"top":qe(e,"y",t[je]);break;case"bottom":qe(e,"y",-t[Ue])}}(d,c,n,o,s),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:a,__baseLine:o,__letterSpacing:s,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=a*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,a),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,y,v,x=p||h?p:t.maxWidth;for(let o=0,d=n.length;o<d;o++){if(m=n[o],m.x=u,m.width<p||m.width>p&&!r)switch(l){case"center":m.x+=(x-m.width)/2;break;case"right":m.x+=x-m.width}m.paraStart&&c&&o>0&&(w+=c),m.y=w,w+=a,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),y=m.x,v=m.width,s<0&&(m.width<0?(v=-m.width+e.fontSize+s,y-=v,v+=e.fontSize):v-=s),y<i.x&&(i.x=y),v>i.width&&(i.width=v),r&&p&&p<v&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:a}=t,{textAlign:o,paraIndent:s,letterSpacing:r}=e;let l,d,c,h,u;a.forEach((t=>{t.words&&(c=s&&t.paraStart?s:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?Fe:d>.01?Ye:Ge,t.isOverflow&&!r&&(t.textMode=!0),h===Ge?(t.x+=c,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=c,l=t.x,t.data=[],t.words.forEach((e=>{h===Ye?(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)}))}(c,n,o),c.overflow&&function(e,n,i,a){if(!a)return;const{rows:o,overflow:s}=e;let{textOverflow:r}=n;if(o.splice(s),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+a-d;("none"===n.textWrap?o:[o[s-1]]).forEach((t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let i=n;i>-1&&(e=t.data[i],l=e.x+e.width,!(i===n&&l<c));i--){if(l<c&&" "!==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)}}))}}(c,n,i,o),"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}}(c,n),c}};const Ve={string:function(t,n){const i="number"==typeof n&&1!==n;if("string"==typeof t){if(!i||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let a=void 0===t.a?1:t.a;i&&(a*=n);const o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}},{setPoint:Qe,addPoint:Je,toBounds:Ze}=t.TwoPointBoundsHelper;const Ke={export(e,n,i){this.running=!0;const a=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){$e||($e=new t.TaskProcessor);return new Promise((t=>{$e.add((()=>ut(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((s=>new Promise((r=>{const l=t=>{s(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===a)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===a)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(tn(e),h.waitViewCompleted((()=>ut(this,void 0,void 0,(function*(){let a,o,s=1,r=1;const{worldTransform:d,isLeafer:c,isFrame:u}=e,{slice:f,trim:p,onCanvas:g}=i,_=void 0===i.smooth?h.config.smooth:i.smooth,w=i.contextSettings||h.config.contextSettings,m=i.screenshot||e.isApp,y=c&&m&&void 0===i.fill?e.fill:i.fill,v=t.FileHelper.isOpaqueImage(n)||y,x=new t.Matrix;if(m)a=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(s=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),s/=e.scaleX,r/=e.scaleY;break;case"world":s=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;s/=s/n.scaleX,r/=r/n.scaleY}a=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,a,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(a).scale(b.scaleX,b.scaleY),S={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/s*b.scaleX,1/r*b.scaleY)};let P,A=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(P=e,P.__worldOpacity=0,e=h,S.bounds=A.bounds),A.save(),u&&void 0!==y){const t=e.get("fill");e.fill="",e.__render(A,S),e.fill=t}else e.__render(A,S);if(A.restore(),P&&P.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:a}=e.context.getImageData(0,0,n,i);let o,s,r,l=0;for(let t=0;t<a.length;t+=4)0!==a[t+3]&&(o=l%n,s=(l-o)/n,r?Je(r,o,s):Qe(r={},o,s)),l++;const d=new t.Bounds;return Ze(r,d),d.scale(1/e.pixelRatio).ceil()}(A);const e=A,{width:n,height:i}=o,a={x:0,y:0,width:n,height:i,pixelRatio:B};A=t.Creator.canvas(a),A.copyWorld(e,o,a)}v&&A.fillWorld(A.bounds,y||"#FFFFFF","destination-over"),g&&g(A);const C="canvas"===n?A:yield A.export(n,i);l({data:C,width:A.pixelWidth,height:A.pixelHeight,renderBounds:a,trimBounds:o})}))))):l({data:!1})}))))}};let $e;function tn(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>tn(t)))}const en=t.LeaferCanvasBase.prototype,nn=t.Debug.get("@leafer-ui/export");en.export=function(e,n){const{quality:i,blob:a}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):a?this.toBlob(e,i):this.toDataURL(e,i)},en.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{nn.error(t),i(null)}))}))},en.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},en.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{nn.error(t),i(!1)}))}))},Object.assign(e.TextConvert,Ne),Object.assign(e.ColorConvert,Ve),Object.assign(e.Paint,W),Object.assign(e.PaintImage,pt),Object.assign(e.PaintGradient,Ot),Object.assign(e.Effect,Yt),Object.assign(e.Export,Ke),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=v,exports.Watcher=s,exports.useCanvas=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
|