leafer-draw 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/web.cjs +32 -24
- package/dist/web.esm.js +32 -24
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +77 -62
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +77 -62
- package/dist/web.module.min.js +1 -1
- package/package.json +5 -5
package/dist/web.js
CHANGED
|
@@ -4486,15 +4486,16 @@ var LeaferUI = (function (exports) {
|
|
|
4486
4486
|
}
|
|
4487
4487
|
getLayoutBounds(type, relative = 'world', unscale) {
|
|
4488
4488
|
const { leaf } = this;
|
|
4489
|
-
let point, matrix, bounds = this.getInnerBounds(type);
|
|
4489
|
+
let point, matrix, layoutBounds, bounds = this.getInnerBounds(type);
|
|
4490
4490
|
switch (relative) {
|
|
4491
4491
|
case 'world':
|
|
4492
4492
|
point = leaf.getWorldPoint(bounds);
|
|
4493
4493
|
matrix = leaf.__world;
|
|
4494
4494
|
break;
|
|
4495
4495
|
case 'local':
|
|
4496
|
+
const { scaleX, scaleY, rotation, skewX, skewY } = leaf.__;
|
|
4497
|
+
layoutBounds = { scaleX, scaleY, rotation, skewX, skewY };
|
|
4496
4498
|
point = leaf.getLocalPointByInner(bounds);
|
|
4497
|
-
matrix = leaf.__localMatrix;
|
|
4498
4499
|
break;
|
|
4499
4500
|
case 'inner':
|
|
4500
4501
|
point = bounds;
|
|
@@ -4506,7 +4507,8 @@ var LeaferUI = (function (exports) {
|
|
|
4506
4507
|
point = leaf.getWorldPoint(bounds, relative);
|
|
4507
4508
|
matrix = getRelativeWorld$1(leaf, relative, true);
|
|
4508
4509
|
}
|
|
4509
|
-
|
|
4510
|
+
if (!layoutBounds)
|
|
4511
|
+
layoutBounds = MatrixHelper.getLayout(matrix);
|
|
4510
4512
|
copy$5(layoutBounds, bounds);
|
|
4511
4513
|
PointHelper.copy(layoutBounds, point);
|
|
4512
4514
|
if (unscale) {
|
|
@@ -4756,6 +4758,7 @@ var LeaferUI = (function (exports) {
|
|
|
4756
4758
|
}
|
|
4757
4759
|
}
|
|
4758
4760
|
RenderEvent.REQUEST = 'render.request';
|
|
4761
|
+
RenderEvent.CHILD_START = 'render.child_start';
|
|
4759
4762
|
RenderEvent.START = 'render.start';
|
|
4760
4763
|
RenderEvent.BEFORE = 'render.before';
|
|
4761
4764
|
RenderEvent.RENDER = 'render';
|
|
@@ -4931,7 +4934,7 @@ var LeaferUI = (function (exports) {
|
|
|
4931
4934
|
const debug$6 = Debug.get('setAttr');
|
|
4932
4935
|
const LeafDataProxy = {
|
|
4933
4936
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
4934
|
-
if (this.
|
|
4937
|
+
if (this.leaferIsCreated) {
|
|
4935
4938
|
const oldValue = this.__.__getInput(name);
|
|
4936
4939
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
4937
4940
|
debug$6.warn(this.innerName, name, newValue);
|
|
@@ -5003,7 +5006,7 @@ var LeaferUI = (function (exports) {
|
|
|
5003
5006
|
|
|
5004
5007
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5005
5008
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5006
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
5009
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4 } = BoundsHelper;
|
|
5007
5010
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
5008
5011
|
const LeafBounds = {
|
|
5009
5012
|
__updateWorldBounds() {
|
|
@@ -5086,7 +5089,7 @@ var LeaferUI = (function (exports) {
|
|
|
5086
5089
|
const b = this.__layout.boxBounds;
|
|
5087
5090
|
const data = this.__;
|
|
5088
5091
|
if (data.__pathInputed) {
|
|
5089
|
-
toBounds$2(data.
|
|
5092
|
+
toBounds$2(data.path, b);
|
|
5090
5093
|
}
|
|
5091
5094
|
else {
|
|
5092
5095
|
b.x = 0;
|
|
@@ -5098,7 +5101,7 @@ var LeaferUI = (function (exports) {
|
|
|
5098
5101
|
__updateAutoLayout() {
|
|
5099
5102
|
this.__layout.matrixChanged = true;
|
|
5100
5103
|
if (this.isBranch) {
|
|
5101
|
-
if (this.
|
|
5104
|
+
if (this.leaferIsReady)
|
|
5102
5105
|
this.leafer.layouter.addExtra(this);
|
|
5103
5106
|
if (this.__.flow) {
|
|
5104
5107
|
if (this.__layout.boxChanged)
|
|
@@ -5124,11 +5127,11 @@ var LeaferUI = (function (exports) {
|
|
|
5124
5127
|
},
|
|
5125
5128
|
__updateStrokeBounds() {
|
|
5126
5129
|
const layout = this.__layout;
|
|
5127
|
-
copyAndSpread$
|
|
5130
|
+
copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5128
5131
|
},
|
|
5129
5132
|
__updateRenderBounds() {
|
|
5130
5133
|
const layout = this.__layout;
|
|
5131
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5134
|
+
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$4(layout.renderBounds, layout.strokeBounds);
|
|
5132
5135
|
}
|
|
5133
5136
|
};
|
|
5134
5137
|
|
|
@@ -5233,6 +5236,8 @@ var LeaferUI = (function (exports) {
|
|
|
5233
5236
|
get innerName() { return this.__.name || this.tag + this.innerId; }
|
|
5234
5237
|
get __DataProcessor() { return LeafData; }
|
|
5235
5238
|
get __LayoutProcessor() { return LeafLayout; }
|
|
5239
|
+
get leaferIsCreated() { return this.leafer && this.leafer.created; }
|
|
5240
|
+
get leaferIsReady() { return this.leafer && this.leafer.ready; }
|
|
5236
5241
|
get isLeafer() { return false; }
|
|
5237
5242
|
get isBranch() { return false; }
|
|
5238
5243
|
get isBranchLeaf() { return false; }
|
|
@@ -5674,6 +5679,7 @@ var LeaferUI = (function (exports) {
|
|
|
5674
5679
|
add(child, index) {
|
|
5675
5680
|
if (child === this)
|
|
5676
5681
|
return;
|
|
5682
|
+
child.__ || (child = UICreator.get(child.tag, child));
|
|
5677
5683
|
if (child.parent)
|
|
5678
5684
|
child.parent.remove(child);
|
|
5679
5685
|
child.parent = this;
|
|
@@ -5696,10 +5702,14 @@ var LeaferUI = (function (exports) {
|
|
|
5696
5702
|
}
|
|
5697
5703
|
remove(child, destroy) {
|
|
5698
5704
|
if (child) {
|
|
5699
|
-
if (child.
|
|
5700
|
-
|
|
5705
|
+
if (child.__) {
|
|
5706
|
+
if (child.animationOut)
|
|
5707
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5708
|
+
else
|
|
5709
|
+
this.__remove(child, destroy);
|
|
5710
|
+
}
|
|
5701
5711
|
else
|
|
5702
|
-
this.
|
|
5712
|
+
this.find(child).forEach(item => this.remove(item, destroy));
|
|
5703
5713
|
}
|
|
5704
5714
|
else if (child === undefined) {
|
|
5705
5715
|
super.remove(null, destroy);
|
|
@@ -5917,7 +5927,7 @@ var LeaferUI = (function (exports) {
|
|
|
5917
5927
|
}
|
|
5918
5928
|
}
|
|
5919
5929
|
|
|
5920
|
-
const version = "1.0.
|
|
5930
|
+
const version = "1.0.5";
|
|
5921
5931
|
|
|
5922
5932
|
const debug$5 = Debug.get('LeaferCanvas');
|
|
5923
5933
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6559,6 +6569,7 @@ var LeaferUI = (function (exports) {
|
|
|
6559
6569
|
this.totalBounds = new Bounds();
|
|
6560
6570
|
debug$3.log(target.innerName, '--->');
|
|
6561
6571
|
try {
|
|
6572
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6562
6573
|
this.emitRender(RenderEvent.START);
|
|
6563
6574
|
this.renderOnce(callback);
|
|
6564
6575
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -7295,12 +7306,7 @@ var LeaferUI = (function (exports) {
|
|
|
7295
7306
|
this.__drawPathByData(canvas, this.__.path);
|
|
7296
7307
|
}
|
|
7297
7308
|
__drawPathByData(drawer, data) {
|
|
7298
|
-
|
|
7299
|
-
PathDrawer.drawPathByData(drawer, data);
|
|
7300
|
-
}
|
|
7301
|
-
else {
|
|
7302
|
-
this.__drawPathByBox(drawer);
|
|
7303
|
-
}
|
|
7309
|
+
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
|
|
7304
7310
|
}
|
|
7305
7311
|
__drawPathByBox(drawer) {
|
|
7306
7312
|
const { x, y, width, height } = this.__layout.boxBounds;
|
|
@@ -7308,9 +7314,8 @@ var LeaferUI = (function (exports) {
|
|
|
7308
7314
|
const { cornerRadius } = this.__;
|
|
7309
7315
|
drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
|
|
7310
7316
|
}
|
|
7311
|
-
else
|
|
7317
|
+
else
|
|
7312
7318
|
drawer.rect(x, y, width, height);
|
|
7313
|
-
}
|
|
7314
7319
|
}
|
|
7315
7320
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7316
7321
|
return needPlugin('animate');
|
|
@@ -7319,10 +7324,10 @@ var LeaferUI = (function (exports) {
|
|
|
7319
7324
|
export(filename, options) {
|
|
7320
7325
|
return Export.export(this, filename, options);
|
|
7321
7326
|
}
|
|
7322
|
-
clone(
|
|
7327
|
+
clone(data) {
|
|
7323
7328
|
const json = this.toJSON();
|
|
7324
|
-
if (
|
|
7325
|
-
Object.assign(json,
|
|
7329
|
+
if (data)
|
|
7330
|
+
Object.assign(json, data);
|
|
7326
7331
|
return UI_1.one(json);
|
|
7327
7332
|
}
|
|
7328
7333
|
static one(data, x, y, width, height) {
|
|
@@ -7993,10 +7998,9 @@ var LeaferUI = (function (exports) {
|
|
|
7993
7998
|
registerUI()
|
|
7994
7999
|
], exports.Rect);
|
|
7995
8000
|
|
|
7996
|
-
const
|
|
7997
|
-
const group = exports.Group.prototype;
|
|
8001
|
+
const { copy: copy$2, add, includes: includes$1 } = BoundsHelper;
|
|
8002
|
+
const rect = exports.Rect.prototype, group = exports.Group.prototype;
|
|
7998
8003
|
const childrenRenderBounds = {};
|
|
7999
|
-
const { copy: copy$2, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8000
8004
|
exports.Box = class Box extends exports.Group {
|
|
8001
8005
|
get __tag() { return 'Box'; }
|
|
8002
8006
|
get isBranchLeaf() { return true; }
|
|
@@ -8010,29 +8014,27 @@ var LeaferUI = (function (exports) {
|
|
|
8010
8014
|
return this.__updateRectRenderSpread() || -1;
|
|
8011
8015
|
}
|
|
8012
8016
|
__updateRectBoxBounds() { }
|
|
8013
|
-
__updateBoxBounds(
|
|
8017
|
+
__updateBoxBounds(_secondLayout) {
|
|
8014
8018
|
const data = this.__;
|
|
8015
8019
|
if (this.children.length) {
|
|
8016
8020
|
if (data.__autoSide) {
|
|
8017
|
-
if (this.leafer && this.leafer.ready)
|
|
8018
|
-
this.leafer.layouter.addExtra(this);
|
|
8019
8021
|
super.__updateBoxBounds();
|
|
8020
8022
|
const { boxBounds } = this.__layout;
|
|
8021
8023
|
if (!data.__autoSize) {
|
|
8022
|
-
if (data.__autoWidth)
|
|
8023
|
-
boxBounds.width += boxBounds.x, boxBounds.
|
|
8024
|
-
|
|
8025
|
-
|
|
8024
|
+
if (data.__autoWidth) {
|
|
8025
|
+
boxBounds.width += boxBounds.x, boxBounds.x = 0;
|
|
8026
|
+
boxBounds.height = data.height, boxBounds.y = 0;
|
|
8027
|
+
}
|
|
8028
|
+
else {
|
|
8029
|
+
boxBounds.height += boxBounds.y, boxBounds.y = 0;
|
|
8030
|
+
boxBounds.width = data.width, boxBounds.x = 0;
|
|
8031
|
+
}
|
|
8026
8032
|
}
|
|
8027
|
-
if (secondLayout && data.flow && data.padding)
|
|
8028
|
-
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8029
8033
|
this.__updateNaturalSize();
|
|
8030
8034
|
}
|
|
8031
8035
|
else {
|
|
8032
8036
|
this.__updateRectBoxBounds();
|
|
8033
8037
|
}
|
|
8034
|
-
if (data.flow)
|
|
8035
|
-
this.__updateContentBounds();
|
|
8036
8038
|
}
|
|
8037
8039
|
else {
|
|
8038
8040
|
this.__updateRectBoxBounds();
|
|
@@ -8098,6 +8100,9 @@ var LeaferUI = (function (exports) {
|
|
|
8098
8100
|
__decorate([
|
|
8099
8101
|
dataType(false)
|
|
8100
8102
|
], exports.Box.prototype, "resizeChildren", void 0);
|
|
8103
|
+
__decorate([
|
|
8104
|
+
dataType(false)
|
|
8105
|
+
], exports.Box.prototype, "textBox", void 0);
|
|
8101
8106
|
__decorate([
|
|
8102
8107
|
affectRenderBoundsType('show')
|
|
8103
8108
|
], exports.Box.prototype, "overflow", void 0);
|
|
@@ -8627,6 +8632,9 @@ var LeaferUI = (function (exports) {
|
|
|
8627
8632
|
__decorate([
|
|
8628
8633
|
boundsType('top')
|
|
8629
8634
|
], exports.Text.prototype, "verticalAlign", void 0);
|
|
8635
|
+
__decorate([
|
|
8636
|
+
boundsType(true)
|
|
8637
|
+
], exports.Text.prototype, "autoSizeAlign", void 0);
|
|
8630
8638
|
__decorate([
|
|
8631
8639
|
boundsType('normal')
|
|
8632
8640
|
], exports.Text.prototype, "textWrap", void 0);
|
|
@@ -9168,9 +9176,10 @@ var LeaferUI = (function (exports) {
|
|
|
9168
9176
|
onLoadError(ui, event, image.error);
|
|
9169
9177
|
}
|
|
9170
9178
|
else {
|
|
9171
|
-
|
|
9172
|
-
|
|
9179
|
+
if (firstUse) {
|
|
9180
|
+
ignoreRender(ui, true);
|
|
9173
9181
|
onLoad(ui, event);
|
|
9182
|
+
}
|
|
9174
9183
|
leafPaint.loadId = image.load(() => {
|
|
9175
9184
|
ignoreRender(ui, false);
|
|
9176
9185
|
if (!ui.destroyed) {
|
|
@@ -9782,11 +9791,12 @@ var LeaferUI = (function (exports) {
|
|
|
9782
9791
|
const { Letter, Single, Before, After, Symbol, Break } = CharType;
|
|
9783
9792
|
let word, row, wordWidth, rowWidth, realWidth;
|
|
9784
9793
|
let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
|
|
9785
|
-
let textDrawData, rows = [], bounds;
|
|
9794
|
+
let textDrawData, rows = [], bounds, findMaxWidth;
|
|
9786
9795
|
function createRows(drawData, content, style) {
|
|
9787
9796
|
textDrawData = drawData;
|
|
9788
9797
|
rows = drawData.rows;
|
|
9789
9798
|
bounds = drawData.bounds;
|
|
9799
|
+
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
9790
9800
|
const { __letterSpacing, paraIndent, textCase } = style;
|
|
9791
9801
|
const { canvas } = Platform;
|
|
9792
9802
|
const { width, height } = bounds;
|
|
@@ -9871,7 +9881,10 @@ var LeaferUI = (function (exports) {
|
|
|
9871
9881
|
else {
|
|
9872
9882
|
content.split('\n').forEach(content => {
|
|
9873
9883
|
textDrawData.paraNumber++;
|
|
9874
|
-
|
|
9884
|
+
rowWidth = canvas.measureText(content).width;
|
|
9885
|
+
rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
|
|
9886
|
+
if (findMaxWidth)
|
|
9887
|
+
setMaxWidth();
|
|
9875
9888
|
});
|
|
9876
9889
|
}
|
|
9877
9890
|
}
|
|
@@ -9902,10 +9915,16 @@ var LeaferUI = (function (exports) {
|
|
|
9902
9915
|
row.width = rowWidth;
|
|
9903
9916
|
if (bounds.width)
|
|
9904
9917
|
trimRight(row);
|
|
9918
|
+
else if (findMaxWidth)
|
|
9919
|
+
setMaxWidth();
|
|
9905
9920
|
rows.push(row);
|
|
9906
9921
|
row = { words: [] };
|
|
9907
9922
|
rowWidth = 0;
|
|
9908
9923
|
}
|
|
9924
|
+
function setMaxWidth() {
|
|
9925
|
+
if (rowWidth > (textDrawData.maxWidth || 0))
|
|
9926
|
+
textDrawData.maxWidth = rowWidth;
|
|
9927
|
+
}
|
|
9909
9928
|
|
|
9910
9929
|
const CharMode = 0;
|
|
9911
9930
|
const WordMode = 1;
|
|
@@ -9977,34 +9996,32 @@ var LeaferUI = (function (exports) {
|
|
|
9977
9996
|
|
|
9978
9997
|
function layoutText(drawData, style) {
|
|
9979
9998
|
const { rows, bounds } = drawData;
|
|
9980
|
-
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
9999
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
9981
10000
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
9982
10001
|
let starY = __baseLine;
|
|
9983
10002
|
if (__clipText && realHeight > height) {
|
|
9984
10003
|
realHeight = Math.max(height, __lineHeight);
|
|
9985
10004
|
drawData.overflow = rows.length;
|
|
9986
10005
|
}
|
|
9987
|
-
else {
|
|
10006
|
+
else if (height || autoSizeAlign) {
|
|
9988
10007
|
switch (verticalAlign) {
|
|
9989
10008
|
case 'middle':
|
|
9990
10009
|
y += (height - realHeight) / 2;
|
|
9991
10010
|
break;
|
|
9992
|
-
case 'bottom':
|
|
9993
|
-
y += (height - realHeight);
|
|
10011
|
+
case 'bottom': y += (height - realHeight);
|
|
9994
10012
|
}
|
|
9995
10013
|
}
|
|
9996
10014
|
starY += y;
|
|
9997
|
-
let row, rowX, rowWidth;
|
|
10015
|
+
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
9998
10016
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
9999
10017
|
row = rows[i];
|
|
10000
10018
|
row.x = x;
|
|
10001
10019
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
10002
10020
|
switch (textAlign) {
|
|
10003
10021
|
case 'center':
|
|
10004
|
-
row.x += (
|
|
10022
|
+
row.x += (layoutWidth - row.width) / 2;
|
|
10005
10023
|
break;
|
|
10006
|
-
case 'right':
|
|
10007
|
-
row.x += width - row.width;
|
|
10024
|
+
case 'right': row.x += layoutWidth - row.width;
|
|
10008
10025
|
}
|
|
10009
10026
|
}
|
|
10010
10027
|
if (row.paraStart && paraSpacing && i > 0)
|
|
@@ -10109,14 +10126,14 @@ var LeaferUI = (function (exports) {
|
|
|
10109
10126
|
let height = style.__getInput('height') || 0;
|
|
10110
10127
|
const { textDecoration, __font, __padding: padding } = style;
|
|
10111
10128
|
if (padding) {
|
|
10112
|
-
if (width)
|
|
10129
|
+
if (width)
|
|
10130
|
+
x = padding[left], width -= (padding[right] + padding[left]);
|
|
10131
|
+
else if (!style.autoSizeAlign)
|
|
10113
10132
|
x = padding[left];
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
if (
|
|
10133
|
+
if (height)
|
|
10134
|
+
y = padding[top], height -= (padding[top] + padding[bottom]);
|
|
10135
|
+
else if (!style.autoSizeAlign)
|
|
10117
10136
|
y = padding[top];
|
|
10118
|
-
height -= (padding[top] + padding[bottom]);
|
|
10119
|
-
}
|
|
10120
10137
|
}
|
|
10121
10138
|
const drawData = {
|
|
10122
10139
|
bounds: { x, y, width, height },
|
|
@@ -10136,22 +10153,20 @@ var LeaferUI = (function (exports) {
|
|
|
10136
10153
|
return drawData;
|
|
10137
10154
|
}
|
|
10138
10155
|
function padAutoText(padding, drawData, style, width, height) {
|
|
10139
|
-
if (!width) {
|
|
10156
|
+
if (!width && style.autoSizeAlign) {
|
|
10140
10157
|
switch (style.textAlign) {
|
|
10141
10158
|
case 'left':
|
|
10142
10159
|
offsetText(drawData, 'x', padding[left]);
|
|
10143
10160
|
break;
|
|
10144
|
-
case 'right':
|
|
10145
|
-
offsetText(drawData, 'x', -padding[right]);
|
|
10161
|
+
case 'right': offsetText(drawData, 'x', -padding[right]);
|
|
10146
10162
|
}
|
|
10147
10163
|
}
|
|
10148
|
-
if (!height) {
|
|
10164
|
+
if (!height && style.autoSizeAlign) {
|
|
10149
10165
|
switch (style.verticalAlign) {
|
|
10150
10166
|
case 'top':
|
|
10151
10167
|
offsetText(drawData, 'y', padding[top]);
|
|
10152
10168
|
break;
|
|
10153
|
-
case 'bottom':
|
|
10154
|
-
offsetText(drawData, 'y', -padding[bottom]);
|
|
10169
|
+
case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
|
|
10155
10170
|
}
|
|
10156
10171
|
}
|
|
10157
10172
|
}
|
package/dist/web.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const e=t.Platform.devicePixelRatio;if(this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(e),r={width:o,height:a,pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>t.toDataURL(s(e),n),canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const a=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(a,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)}))},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):r.indexOf("Safari")>-1&&-1===r.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),r.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):r.indexOf("Mac")>-1?t.Platform.os="Mac":r.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:w,updateAllChange:m}=t.LeafHelper,v=t.Debug.get("Layouter");class y{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){v.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?v.warn("layouting"):this.times>3?v.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||c(i[t])}c(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),y.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class b{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);i.save(),o&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){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||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function B(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function E(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?k(t,!0,e,n):L(e,n);break;case"inside":R("inside",t,s,e,n);break;case"outside":R("outside",t,s,e,n)}}function R(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?k(e,!0,i,r):L(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",B(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function L(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function k(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?L(i,s):s.stroke(),s.restoreBlendMode()):n?L(i,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:P,getOuterOf:S,getByMove:C,getIntersectData:O}=t.BoundsHelper;let A;function W(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:a,color:r,opacity:l}=n;return{type:o,blendMode:a,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,s,!A||!A[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const M={compute:function(t,n){const i=n.__,s=[];let o,a=i.__input[t];a instanceof Array||(a=[a]),A=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=a.length;i<o;i++)e=W(t,a[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?B(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:a}=n.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):a?B(n,i):o?i.fill(o):i.fill())},fillText:B,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,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:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),k(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),k(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),k(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:E,drawTextStroke:L,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=O(i?P(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=S(s,a),o=C(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let T={};const{get:D,rotateOfOuter:I,translate:F,scaleOfOuter:H,scale:z,rotate:V}=t.MatrixHelper;function Y(t,e,n,i,s,o,a){const r=D();F(r,e.x+n,e.y+i),z(r,s,o),a&&I(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function j(t,e,n,i,s,o,a){const r=D();F(r,e.x+n,e.y+i),s&&z(r,s,o),a&&V(r,a),t.transform=r}function G(t,e,n,i,s,o,a,r,l,d){const c=D();if(l)if("center"===d)I(c,{x:n/2,y:i/2},l);else switch(V(c,l),l){case 90:F(c,i,0);break;case 180:F(c,n,i);break;case 270:F(c,0,n)}T.x=e.x+s,T.y=e.y+o,F(c,T.x,T.y),a&&H(c,T,a,r),t.transform=c}const{get:U,translate:X}=t.MatrixHelper,N=new t.Bounds,q={},Q={};function J(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Z(n,i,e)}function Z(e,n,i){let{width:s,height:o}=i;e.padding&&(n=N.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===s&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:s,m=_?s:o;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,Q),v=Q.scaleX,y=Q.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*v)/2,b+=(n.height-o*y)/2}if(l){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),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||(s=n.width,o=n.height);break;case"normal":case"clip":(x||b||v||u)&&j(g,n,x,b,v,y,u);break;case"repeat":(!p||v||u)&&G(g,n,s,o,x,b,v,y,u,l),f||(g.repeat="repeat");break;default:v&&Y(g,n,x,b,v,y,u)}return g.transform||(n.x||n.y)&&(g.transform=U(),X(g.transform,n.x,n.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=o,a&&(g.opacity=a),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let $,K=new t.Bounds;const{isSame:tt}=t.BoundsHelper;function et(t,e,n,i,s,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 s.data||J(s,i,n,o),!0}function nt(e,n){ot(e,t.ImageEvent.LOAD,n)}function it(e,n){ot(e,t.ImageEvent.LOADED,n)}function st(e,n,i){n.error=i,e.forceUpdate("surface"),ot(e,t.ImageEvent.ERROR,n)}function ot(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function at(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:rt,scale:lt,copy:dt}=t.MatrixHelper,{ceil:ct,abs:ht}=Math;function ut(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=ht(s),o=ht(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=rt(),dt(d,g),lt(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,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&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(d||(d=rt(),g&&dt(d,g)),lt(d,1/s,1/o));const v=e.getCanvas(ct(c)||1,ct(h)||1,p),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function ft(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(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?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:pt}=Math;const gt={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return $&&i===$.paint&&tt(s,$.boxBounds)?a=$.leafPaint:(a={type:i.type,image:l},$=l.use>1?{leafPaint:a,paint:i,boxBounds:K.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(et(e,n,i,l,a,s),o&&(nt(e,r),it(e,r))):l.error?o&&st(e,r,l.error):(at(e,!0),o&&nt(e,r),a.loadId=l.load((()=>{at(e,!1),e.destroyed||(et(e,n,i,l,a,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),it(e,r)),a.loadId=null}),(t=>{at(e,!1),st(e,r,t),a.loadId=null}))),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!s.data||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=s;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=pt(a)*l,i*=pt(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||e.Export.running?ut(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>ft(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ut(n,s,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ut,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),s.unload(i[l].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:J,getPatternData:Z,fillOrFitMode:Y,clipMode:j,repeatMode:G},{toPoint:_t}=t.AroundHelper,wt={},mt={};function vt(t,n,i){if(n){let s;for(let o=0,a=n.length;o<a;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(a-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:yt,getDistance:xt}=t.PointHelper,{get:bt,rotateOfOuter:Bt,scaleOfOuter:Et}=t.MatrixHelper,{toPoint:Rt}=t.AroundHelper,Lt={},kt={};function Pt(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=yt(e,n);o=bt(),s?(Et(o,e,a/r*(i||1),1),Bt(o,e,t+90)):(Et(o,e,1,a/r*(i||1)),Bt(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:Ct}=t.AroundHelper,Ot={},At={};const Wt={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=e;_t(i||"top",n,wt),_t(s||"bottom",n,mt);const l=t.Platform.canvas.createLinearGradient(wt.x,wt.y,mt.x,mt.y);vt(l,e.stops,r);const d={type:o,style:l};return a&&(d.blendMode=a),d},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Rt(i||"center",n,Lt),Rt(s||"bottom",n,kt);const d=t.Platform.canvas.createRadialGradient(Lt.x,Lt.y,0,Lt.x,Lt.y,xt(Lt,kt));vt(d,e.stops,a);const c={type:o,style:d},h=Pt(n,Lt,kt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Ct(i||"center",n,Ot),Ct(s||"bottom",n,At);const d=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Ot.x,Ot.y):t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,St(Ot,At));vt(d,e.stops,a);const c={type:o,style:d},h=Pt(n,Ot,At,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Pt},{copy:Mt,toOffsetOutBounds:Tt}=t.BoundsHelper,Dt={},It={};function Ft(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Mt(Dt,e.bounds),Dt.x+=n.x-a.x,Dt.y+=n.y-a.y,i){const{matrix:t}=s;Dt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Dt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Dt.width*=i,Dt.height*=i}e.copyWorld(s.canvas,e.bounds,Dt)}else i&&(Mt(Dt,n),Dt.x-=n.width/2*(i-1),Dt.y-=n.height/2*(i-1),Dt.width*=i,Dt.height*=i),e.copyWorld(s.canvas,a,i?Dt:n)}const{toOffsetOutBounds:Ht}=t.BoundsHelper,zt={};const Vt={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=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),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ft(f,It,s,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,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ht(d,zt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(zt.offsetX+r.x*h,zt.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ft(f,zt,s,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,a.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:Yt}=t.LeafBoundsHelper;function jt(t,e,n,i,s,o){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Ut(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Ut(t,n,i,o);break;case"path":n.restore()}}function Gt(t){return t.getSameCanvas(!1,!0)}function Ut(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a;const{children:r}=this;for(let l=0,d=r.length;l<d;l++)n=r[l],n.__.mask&&(a&&(jt(this,a,t,s,i,o),i=s=null),"path"===n.__.mask?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Gt(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=Gt(t)),s||(s=Gt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Yt(n,e)||n.__render(s||t,e);jt(this,a,t,s,i,o)};const Xt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nt=Xt+"_#~&*+\\=|≮≯≈≠=…",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 Qt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Jt=Qt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Zt=Qt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),$t=Qt(Xt),Kt=Qt(Nt),te=Qt("- —/~|┆·");var ee;!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"}(ee||(ee={}));const{Letter:ne,Single:ie,Before:se,After:oe,Symbol:ae,Break:re}=ee;function le(t){return Jt[t]?ne:te[t]?re:Zt[t]?se:$t[t]?oe:Kt[t]?ae:qt.test(t)?ie:ne}const de={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function ce(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:he}=de,{Letter:ue,Single:fe,Before:pe,After:ge,Symbol:_e,Break:we}=ee;let me,ve,ye,xe,be,Be,Ee,Re,Le,ke,Pe,Se,Ce,Oe,Ae,We,Me=[];function Te(t,e){Le&&!Re&&(Re=Le),me.data.push({char:t,width:e}),ye+=e}function De(){xe+=ye,me.width=ye,ve.words.push(me),me={data:[]},ye=0}function Ie(){Oe&&(Ae.paraNumber++,ve.paraStart=!0,Oe=!1),Le&&(ve.startCharSize=Re,ve.endCharSize=Le,Re=0),ve.width=xe,We.width&&he(ve),Me.push(ve),ve={words:[]},xe=0}const Fe=0,He=1,ze=2;const{top:Ve,right:Ye,bottom:je,left:Ge}=t.Direction4;function Ue(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const Xe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o&&(i=d[Ge],o-=d[Ye]+d[Ge]),a&&(s=d[Ve],a-=d[Ve]+d[je]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Ae=e,Me=e.rows,We=e.bounds;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=We;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;Oe=!0,Pe=null,Re=Ee=Le=ye=xe=0,me={data:[]},ve={words:[]};for(let i=0,d=n.length;i<d;i++)Be=n[i],"\n"===Be?(ye&&De(),ve.paraEnd=!0,Ie(),Oe=!0):(ke=le(Be),ke===ue&&"none"!==a&&(Be=ce(Be,a,!ye)),Ee=r.measureText(Be).width,s&&(s<0&&(Le=Ee),Ee+=s),Se=ke===fe&&(Pe===fe||Pe===ue)||Pe===fe&&ke!==ge,Ce=!(ke!==pe&&ke!==fe||Pe!==_e&&Pe!==ge),be=Oe&&o?l-o:l,t&&l&&xe+ye+Ee>be&&(e?(ye&&De(),xe&&Ie()):(Ce||(Ce=ke===ue&&Pe==ge),Se||Ce||ke===we||ke===pe||ke===fe||ye+Ee>be?(ye&&De(),xe&&Ie()):xe&&Ie()))," "===Be&&!0!==Oe&&xe+ye===0||(ke===we?(" "===Be&&ye&&De(),Te(Be,Ee),De()):Se||Ce?(ye&&De(),Te(Be,Ee)):Te(Be,Ee)),Pe=ke);ye&&De(),xe&&Ie(),Me.length>0&&(Me[Me.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Ae.paraNumber++,Me.push({x:o||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(c,e,n),d&&function(t,e,n,i,s){if(!i)switch(n.textAlign){case"left":Ue(e,"x",t[Ge]);break;case"right":Ue(e,"x",-t[Ye])}if(!s)switch(n.verticalAlign){case"top":Ue(e,"y",t[Ve]);break;case"bottom":Ue(e,"y",-t[je])}}(d,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c}=e;let h,u,f,{x:p,y:g,width:_,height:w}=i,m=s*n.length+(c?c*(t.paraNumber-1):0),v=o;if(r&&m>w)m=Math.max(w,s),t.overflow=n.length;else switch(d){case"middle":g+=(w-m)/2;break;case"bottom":g+=w-m}v+=g;for(let o=0,d=n.length;o<d;o++){if(h=n[o],h.x=p,h.width<_||h.width>_&&!r)switch(l){case"center":h.x+=(_-h.width)/2;break;case"right":h.x+=_-h.width}h.paraStart&&c&&o>0&&(v+=c),h.y=v,v+=s,t.overflow>o&&v>m&&(h.isOverflow=!0,t.overflow=o+1),u=h.x,f=h.width,a<0&&(h.width<0?(f=-h.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<i.x&&(i.x=u),f>i.width&&(i.width=f),r&&_&&_<f&&(h.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=g,i.height=m}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let l,d,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a: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?He:ze,t.isOverflow&&!r&&(t.textMode=!0),h===ze?(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===He?(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,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?o:[o[a-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 Ne={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 s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}},{setPoint:qe,addPoint:Qe,toBounds:Je}=t.TwoPointBoundsHelper;const Ze={export(e,n,i){this.running=!0;const s=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((()=>ft(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const l=t=>{a(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===s)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===s)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(Ke(e),h.waitViewCompleted((()=>ft(this,void 0,void 0,(function*(){let s,o,a=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,v=c&&m&&void 0===i.fill?e.fill:i.fill,y=t.FileHelper.isOpaqueImage(n)||v,x=new t.Matrix;if(m)s=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(a=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),a/=e.scaleX,r/=e.scaleY;break;case"world":a=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;a/=a/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(s).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/a*b.scaleX,1/r*b.scaleY)};let S,C=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(S=e,S.__worldOpacity=0,e=h,P.bounds=C.bounds),C.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(C,P),e.fill=t}else e.__render(C,P);if(C.restore(),S&&S.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let o,a,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(o=l%n,a=(l-o)/n,r?Qe(r,o,a):qe(r={},o,a)),l++;const d=new t.Bounds;return Je(r,d),d.scale(1/e.pixelRatio).ceil()}(C);const e=C,{width:n,height:i}=o,s={x:0,y:0,width:n,height:i,pixelRatio:B};C=t.Creator.canvas(s),C.copyWorld(e,o,s)}y&&C.fillWorld(C.bounds,v||"#FFFFFF","destination-over"),g&&g(C);const O="canvas"===n?C:yield C.export(n,i);l({data:O,width:C.pixelWidth,height:C.pixelHeight,renderBounds:s,trimBounds:o})}))))):l({data:!1})}))))}};let $e;function Ke(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>Ke(t)))}const tn=t.LeaferCanvasBase.prototype,en=t.Debug.get("@leafer-ui/export");tn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},tn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{en.error(t),i(null)}))}))},tn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},tn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{en.error(t),i(!1)}))}))},Object.assign(e.TextConvert,Xe),Object.assign(e.ColorConvert,Ne),Object.assign(e.Paint,M),Object.assign(e.PaintImage,gt),Object.assign(e.PaintGradient,Wt),Object.assign(e.Effect,Vt),Object.assign(e.Export,Ze),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=b,exports.Watcher=l,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");const n=t.Debug.get("LeaferCanvas");class i extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:n}=this;if(e&&n){const i=n.children[t];i?(this.setAbsolute(i),n.insertBefore(e,i)):n.appendChild(i)}}init(){const{config:e}=this,n=e.view||e.canvas;n?this.__createViewFrom(n):this.__createView();const{style:i}=this.view;if(i.display||(i.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(i.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(t){let e="string"==typeof t?document.getElementById(t):t;if(e)if(e instanceof HTMLCanvasElement)this.view=e;else{let t=e;if(e===window||e===document){const e=document.createElement("div"),{style:n}=e;n.position="absolute",n.top=n.bottom=n.left=n.right="0px",document.body.appendChild(e),t=e}this.__createView();const n=this.view;t.hasChildNodes()&&(this.setAbsolute(n),t.style.position||(t.style.position="relative")),t.appendChild(n)}else n.error(`no id: ${t}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this,{style:i}=this.view;i.width=t+"px",i.height=e+"px",this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n)}updateClientBounds(){this.clientBounds=this.view.getBoundingClientRect()}startAutoLayout(e,i){if(this.resizeListener=i,e){this.autoBounds=e;try{this.resizeObserver=new ResizeObserver((t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)}));const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),n.warn("no parent"))}catch(t){this.imitateResizeObserver()}}else window.addEventListener("resize",(()=>{const e=t.Platform.devicePixelRatio;if(this.pixelRatio!==e){const{width:t,height:n}=this;this.emitResize({width:t,height:n,pixelRatio:e})}}))}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}checkAutoBounds(e){const n=this.view,{x:i,y:s,width:o,height:a}=this.autoBounds.getBoundsFrom(e),r={width:o,height:a,pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(r)){const{style:t}=n;t.marginLeft=i+"px",t.marginTop=s+"px",this.emitResize(r)}}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}emitResize(e){const n={};t.DataHelper.copyAttrs(n,this,t.canvasSizeAttrs),this.resize(e),void 0!==this.width&&this.resizeListener(new t.ResizeEvent(e,n))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:o}=t.FileHelper;function a(e,n){t.Platform.origin={createCanvas(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n},canvasToDataURL:(t,e,n)=>t.toDataURL(s(e),n),canvasToBolb:(t,e,n)=>new Promise((i=>t.toBlob(i,s(e),n))),canvasSaveAs:(e,n,i)=>{const a=e.toDataURL(s(o(n)),i);return t.Platform.origin.download(a,n)},download:(t,e)=>new Promise((n=>{let i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),n()})),loadImage:e=>new Promise(((n,i)=>{const s=new Image,{crossOrigin:o}=t.Platform.image;o&&(s.setAttribute("crossOrigin",o),s.crossOrigin=o),s.onload=()=>{n(s)},s.onerror=t=>{i(t)},s.src=t.Platform.image.getRealURL(e)}))},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new i(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>Math.max(1,devicePixelRatio)});const{userAgent:r}=navigator;r.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):r.indexOf("Safari")>-1&&-1===r.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),r.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):r.indexOf("Mac")>-1?t.Platform.os="Mac":r.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.PropertyEvent.CHANGE,this.__onAttrChange,this),e.on_([t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this),e.on_(t.WatchEvent.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:c,updateAllWorldOpacity:h}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper,g={x:0,y:0,width:1e5,height:1e5};class _{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,e instanceof Array&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(g):this.afterBounds.setListWithFn(t,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:w,updateAllChange:m}=t.LeafHelper,v=t.Debug.get("Layouter");class y{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){v.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?v.warn("layouting"):this.times>3?v.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:o,LAYOUT:a,AFTER:r}=t.LayoutEvent,l=this.getBlocks(s);l.forEach((t=>t.setBefore())),i.emitEvent(new t.LayoutEvent(o,l,this.times)),this.extraBlock=null,s.sort(),function(t,e){let n;t.list.forEach((t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))}))}(s,this.__levelList),function(t){let e,n,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(n=e[t],n.isBranch&&n.__tempNumber){i=n.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||c(i[t])}c(n)}}))}(this.__levelList),function(t){let e;t.list.forEach((t=>{e=t.__layout,e.opacityChanged&&h(t),e.stateStyleChanged&&setTimeout((()=>e.stateStyleChanged&&t.updateState())),t.__updateChange()}))}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach((t=>t.setAfter())),i.emitEvent(new t.LayoutEvent(a,l,this.times)),i.emitEvent(new t.LayoutEvent(r,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:i,LAYOUT:s,AFTER:o}=t.LayoutEvent,a=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(i,a,this.times)),y.fullLayout(n),a.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(s,a,this.times)),n.emitEvent(new t.LayoutEvent(o,a,this.times)),this.addBlocks(a),t.Run.end(e)}static fullLayout(e){w(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new _([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new _(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.LayoutEvent.REQUEST,this.layout,this),e.on_(t.LayoutEvent.AGAIN,this.layoutAgain,this),e.on_(t.WatchEvent.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const x=t.Debug.get("Renderer");class b{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=e,this.canvas=n,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}render(e){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:n}=this;this.times=0,this.totalBounds=new t.Bounds,x.log(n.innerName,"---\x3e");try{n.app.emit(t.RenderEvent.CHILD_START,n),this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,x.error(t)}x.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return x.warn("rendering");if(this.times>3)return x.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return x.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const n=t.Run.start("PartRender"),{canvas:i}=this,s=e.getIntersect(i.bounds),o=e.includes(this.target.__world),a=new t.Bounds(s);i.save(),o&&!t.Debug.showRepaint?i.clear():(s.spread(10+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,o,a),i.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds,!0),n.restore(),t.Run.end(e)}__render(e,n,i){const s=e.includes(this.target.__world)?{includes:n}:{bounds:e,includes:n};this.needFill&&this.canvas.fillWorld(e,this.config.fill),t.Debug.showRepaint&&this.canvas.strokeWorld(e,"red"),this.target.__render(this.canvas,s),this.renderBounds=i=i||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),t.Debug.showHitView&&this.renderHitView(s),t.Debug.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender(i)}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){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||x.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(e,n,i){this.target.emitEvent(new t.RenderEvent(e,this.times,n,i))}__listenEvents(){const{target:e}=this;this.__eventIds=[e.on_(t.RenderEvent.REQUEST,this.update,this),e.on_(t.LayoutEvent.END,this.__onLayoutEnd,this),e.on_(t.RenderEvent.AGAIN,this.renderAgain,this),e.on_(t.ResizeEvent.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.canvas=this.config=null)}}function B(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.fillText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.fillText(t.char,t.x,n.y)})),s&&e.fillRect(n.x,n.y+s,n.width,o)}function E(t,e,n){const{strokeAlign:i}=e.__,s="string"!=typeof t;switch(i){case"center":n.setStroke(s?void 0:t,e.__.strokeWidth,e.__),s?k(t,!0,e,n):L(e,n);break;case"inside":R("inside",t,s,e,n);break;case"outside":R("outside",t,s,e,n)}}function R(t,e,n,i,s){const{__strokeWidth:o,__font:a}=i.__,r=s.getSameCanvas(!0,!0);r.setStroke(n?void 0:e,2*o,i.__),r.font=a,n?k(e,!0,i,r):L(i,r),r.blendMode="outside"===t?"destination-out":"destination-in",B(i,r),r.blendMode="normal",i.__worldFlipped?s.copyWorldByReset(r,i.__nowWorld):s.copyWorldToInner(r,i.__nowWorld,i.__layout.renderBounds),r.recycle(i.__nowWorld)}function L(t,e){let n;const{rows:i,decorationY:s,decorationHeight:o}=t.__.__textDrawData;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach((t=>{e.strokeText(t.char,t.x,n.y)})),s&&e.strokeRect(n.x,n.y+s,n.width,o)}function k(t,n,i,s){let o;for(let a=0,r=t.length;a<r;a++)o=t[a],o.image&&e.PaintImage.checkImage(i,s,o,!1)||o.style&&(s.strokeStyle=o.style,o.blendMode?(s.saveBlendMode(o.blendMode),n?L(i,s):s.stroke(),s.restoreBlendMode()):n?L(i,s):s.stroke())}Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,n)=>new b(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,i)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:P,getOuterOf:S,getByMove:C,getIntersectData:A}=t.BoundsHelper;let O;function W(t,n,i){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;const{boxBounds:s}=i.__layout;switch(n.type){case"solid":let{type:o,blendMode:a,color:r,opacity:l}=n;return{type:o,blendMode:a,style:e.ColorConvert.string(r,l)};case"image":return e.PaintImage.image(i,t,n,s,!O||!O[n.url]);case"linear":return e.PaintGradient.linearGradient(n,s);case"radial":return e.PaintGradient.radialGradient(n,s);case"angular":return e.PaintGradient.conicGradient(n,s);default:return void 0!==n.r?{type:"solid",style:e.ColorConvert.string(n)}:void 0}}const M={compute:function(t,n){const i=n.__,s=[];let o,a=i.__input[t];a instanceof Array||(a=[a]),O=e.PaintImage.recycleImage(t,i);for(let e,i=0,o=a.length;i<o;i++)e=W(t,a[i],n),e&&s.push(e);i["_"+t]=s.length?s:void 0,s.length&&s[0].image&&(o=s[0].image.hasOpacityPixel),"fill"===t?i.__pixelFill=o:i.__pixelStroke=o},fill:function(t,e,n){n.fillStyle=t,e.__.__font?B(e,n):e.__.windingRule?n.fill(e.__.windingRule):n.fill()},fills:function(t,n,i){let s;const{windingRule:o,__font:a}=n.__;for(let r=0,l=t.length;r<l;r++)s=t[r],s.image&&e.PaintImage.checkImage(n,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?B(n,i):o?i.fill(o):i.fill(),i.restoreBlendMode()):a?B(n,i):o?i.fill(o):i.fill())},fillText:B,stroke:function(t,e,n){const i=e.__,{__strokeWidth:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(t,s,i),n.stroke();break;case"inside":n.save(),n.setStroke(t,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),n.stroke(),n.restore();break;case"outside":const o=n.getSameCanvas(!0,!0);o.setStroke(t,2*s,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:s,strokeAlign:o,__font:a}=i;if(s)if(a)E(t,e,n);else switch(o){case"center":n.setStroke(void 0,s,i),k(t,!1,e,n);break;case"inside":n.save(),n.setStroke(void 0,2*s,i),i.windingRule?n.clip(i.windingRule):n.clip(),k(t,!1,e,n),n.restore();break;case"outside":const{renderBounds:o}=e.__layout,a=n.getSameCanvas(!0,!0);e.__drawRenderPath(a),a.setStroke(void 0,2*s,i),k(t,!1,e,a),i.windingRule?a.clip(i.windingRule):a.clip(),a.clearWorld(o),e.__worldFlipped?n.copyWorldByReset(a,e.__nowWorld):n.copyWorldToInner(a,e.__nowWorld,o),a.recycle(e.__nowWorld)}},strokeText:E,drawTextStroke:L,shape:function(t,e,n){const i=e.getSameCanvas(),s=t.__nowWorld;let o,a,r,l,{scaleX:d,scaleY:c}=s;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(s))l=i,o=r=s;else{const{renderShapeSpread:i}=t.__layout,h=A(i?P(e.bounds,d===c?i*d:[i*c,i*d]):e.bounds,s);a=e.bounds.getFitMatrix(h);let{a:u,d:f}=a;if(a.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),r=S(s,a),o=C(r,-a.e,-a.f),n.matrix){const{matrix:t}=n;a.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:a.withScale(u,f)})}return t.__renderShape(i,n),{canvas:i,matrix:a,bounds:o,worldCanvas:l,shapeBounds:r,scaleX:d,scaleY:c}}};let T={};const{get:D,rotateOfOuter:I,translate:H,scaleOfOuter:F,scale:z,rotate:V}=t.MatrixHelper;function Y(t,e,n,i,s,o,a){const r=D();H(r,e.x+n,e.y+i),z(r,s,o),a&&I(r,{x:e.x+e.width/2,y:e.y+e.height/2},a),t.transform=r}function j(t,e,n,i,s,o,a){const r=D();H(r,e.x+n,e.y+i),s&&z(r,s,o),a&&V(r,a),t.transform=r}function G(t,e,n,i,s,o,a,r,l,d){const c=D();if(l)if("center"===d)I(c,{x:n/2,y:i/2},l);else switch(V(c,l),l){case 90:H(c,i,0);break;case 180:H(c,n,i);break;case 270:H(c,0,n)}T.x=e.x+s,T.y=e.y+o,H(c,T.x,T.y),a&&F(c,T,a,r),t.transform=c}const{get:U,translate:X}=t.MatrixHelper,N=new t.Bounds,q={},Q={};function J(t,e,n,i){const{blendMode:s,sync:o}=n;s&&(t.blendMode=s),o&&(t.sync=o),t.data=Z(n,i,e)}function Z(e,n,i){let{width:s,height:o}=i;e.padding&&(n=N.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");const{opacity:a,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f}=e,p=n.width===s&&n.height===o,g={mode:r},_="center"!==l&&(u||0)%180==90,w=_?o:s,m=_?s:o;let v,y,x=0,b=0;if(r&&"cover"!==r&&"fit"!==r)(c||h)&&(t.MathHelper.getScaleData(c,h,i,Q),v=Q.scaleX,y=Q.scaleY);else if(!p||u){const t=n.width/w,e=n.height/m;v=y="fit"===r?Math.min(t,e):Math.max(t,e),x+=(n.width-s*v)/2,b+=(n.height-o*y)/2}if(l){const e={x:x,y:b,width:w,height:m};v&&(e.width*=v,e.height*=y),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||(s=n.width,o=n.height);break;case"normal":case"clip":(x||b||v||u)&&j(g,n,x,b,v,y,u);break;case"repeat":(!p||v||u)&&G(g,n,s,o,x,b,v,y,u,l),f||(g.repeat="repeat");break;default:v&&Y(g,n,x,b,v,y,u)}return g.transform||(n.x||n.y)&&(g.transform=U(),X(g.transform,n.x,n.y)),v&&"stretch"!==r&&(g.scaleX=v,g.scaleY=y),g.width=s,g.height=o,a&&(g.opacity=a),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),g}let $,K=new t.Bounds;const{isSame:tt}=t.BoundsHelper;function et(t,e,n,i,s,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 s.data||J(s,i,n,o),!0}function nt(e,n){ot(e,t.ImageEvent.LOAD,n)}function it(e,n){ot(e,t.ImageEvent.LOADED,n)}function st(e,n,i){n.error=i,e.forceUpdate("surface"),ot(e,t.ImageEvent.ERROR,n)}function ot(e,n,i){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,i))}function at(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:rt,scale:lt,copy:dt}=t.MatrixHelper,{ceil:ct,abs:ht}=Math;function ut(e,n,i){let{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const a=s+"-"+o+"-"+i;if(n.patternId===a||e.destroyed)return!1;{s=ht(s),o=ht(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=rt(),dt(d,g),lt(d,1/u,1/f),s*=u,o*=f),s*=i,o*=i,c*=s,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&&(s/=l,o/=l,c/=l,h/=l),u&&(s/=u,o/=f),(g||1!==s||1!==o)&&(d||(d=rt(),g&&dt(d,g)),lt(d,1/s,1/o));const v=e.getCanvas(ct(c)||1,ct(h)||1,p),y=e.getPattern(v,_||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=y,n.patternId=a,!0}}function ft(t,e,n,i){return new(n||(n=Promise))((function(s,o){function a(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?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,r)}l((i=i.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:pt}=Math;const gt={image:function(e,n,i,s,o){let a,r;const l=t.ImageManager.get(i);return $&&i===$.paint&&tt(s,$.boxBounds)?a=$.leafPaint:(a={type:i.type,image:l},$=l.use>1?{leafPaint:a,paint:i,boxBounds:K.set(s)}:null),(o||l.loading)&&(r={image:l,attrName:n,attrValue:i}),l.ready?(et(e,n,i,l,a,s),o&&(nt(e,r),it(e,r))):l.error?o&&st(e,r,l.error):(o&&(at(e,!0),nt(e,r)),a.loadId=l.load((()=>{at(e,!1),e.destroyed||(et(e,n,i,l,a,s)&&(l.hasOpacityPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),it(e,r)),a.loadId=null}),(t=>{at(e,!1),st(e,r,t),a.loadId=null}))),a},checkImage:function(n,i,s,o){const{scaleX:a,scaleY:r}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=i;if(!s.data||s.patternId===a+"-"+r+"-"+l&&!e.Export.running)return!1;{const{data:d}=s;if(o)if(d.repeat)o=!1;else{let{width:n,height:i}=d;n*=pt(a)*l,i*=pt(r)*l,d.scaleX&&(n*=d.scaleX,i*=d.scaleY),o=n*i>t.Platform.image.maxCacheSize||e.Export.running}return o?(i.save(),i.clip(),s.blendMode&&(i.blendMode=s.blendMode),d.opacity&&(i.opacity*=d.opacity),d.transform&&i.transform(d.transform),i.drawImage(s.image.view,0,0,d.width,d.height),i.restore(),!0):(!s.style||s.sync||e.Export.running?ut(n,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add((()=>ft(this,void 0,void 0,(function*(){s.patternTask=null,i.bounds.hit(n.__nowWorld)&&ut(n,s,l),n.forceUpdate("surface")}))),300)),!1)}},createPattern:ut,recycleImage:function(e,n){const i=n["_"+e];if(i instanceof Array){let s,o,a,r;for(let l=0,d=i.length;l<d;l++)s=i[l].image,r=s&&s.url,r&&(o||(o={}),o[r]=!0,t.ImageManager.recycle(s),s.loading&&(a||(a=n.__input&&n.__input[e]||[],a instanceof Array||(a=[a])),s.unload(i[l].loadId,!a.some((t=>t.url===r)))));return o}return null},createData:J,getPatternData:Z,fillOrFitMode:Y,clipMode:j,repeatMode:G},{toPoint:_t}=t.AroundHelper,wt={},mt={};function vt(t,n,i){if(n){let s;for(let o=0,a=n.length;o<a;o++)s=n[o],"string"==typeof s?t.addColorStop(o/(a-1),e.ColorConvert.string(s,i)):t.addColorStop(s.offset,e.ColorConvert.string(s.color,i))}}const{getAngle:yt,getDistance:xt}=t.PointHelper,{get:bt,rotateOfOuter:Bt,scaleOfOuter:Et}=t.MatrixHelper,{toPoint:Rt}=t.AroundHelper,Lt={},kt={};function Pt(t,e,n,i,s){let o;const{width:a,height:r}=t;if(a!==r||i){const t=yt(e,n);o=bt(),s?(Et(o,e,a/r*(i||1),1),Bt(o,e,t+90)):(Et(o,e,1,a/r*(i||1)),Bt(o,e,t))}return o}const{getDistance:St}=t.PointHelper,{toPoint:Ct}=t.AroundHelper,At={},Ot={};const Wt={linearGradient:function(e,n){let{from:i,to:s,type:o,blendMode:a,opacity:r}=e;_t(i||"top",n,wt),_t(s||"bottom",n,mt);const l=t.Platform.canvas.createLinearGradient(wt.x,wt.y,mt.x,mt.y);vt(l,e.stops,r);const d={type:o,style:l};return a&&(d.blendMode=a),d},radialGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Rt(i||"center",n,Lt),Rt(s||"bottom",n,kt);const d=t.Platform.canvas.createRadialGradient(Lt.x,Lt.y,0,Lt.x,Lt.y,xt(Lt,kt));vt(d,e.stops,a);const c={type:o,style:d},h=Pt(n,Lt,kt,l,!0);return h&&(c.transform=h),r&&(c.blendMode=r),c},conicGradient:function(e,n){let{from:i,to:s,type:o,opacity:a,blendMode:r,stretch:l}=e;Ct(i||"center",n,At),Ct(s||"bottom",n,Ot);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,Ot));vt(d,e.stops,a);const c={type:o,style:d},h=Pt(n,At,Ot,l||1,t.Platform.conicGradientRotate90);return h&&(c.transform=h),r&&(c.blendMode=r),c},getTransform:Pt},{copy:Mt,toOffsetOutBounds:Tt}=t.BoundsHelper,Dt={},It={};function Ht(e,n,i,s){const{bounds:o,shapeBounds:a}=s;if(t.Platform.fullImageShadow){if(Mt(Dt,e.bounds),Dt.x+=n.x-a.x,Dt.y+=n.y-a.y,i){const{matrix:t}=s;Dt.x-=(o.x+(t?t.e:0)+o.width/2)*(i-1),Dt.y-=(o.y+(t?t.f:0)+o.height/2)*(i-1),Dt.width*=i,Dt.height*=i}e.copyWorld(s.canvas,e.bounds,Dt)}else i&&(Mt(Dt,n),Dt.x-=n.width/2*(i-1),Dt.y-=n.height/2*(i-1),Dt.width*=i,Dt.height*=i),e.copyWorld(s.canvas,a,i?Dt:n)}const{toOffsetOutBounds:Ft}=t.BoundsHelper,zt={};const Vt={shadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=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),s=r.spread?1+2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ht(f,It,s,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,a.renderBounds,r.blendMode),p&&g<p&&f.clearWorld(i,!0)})),f.recycle(i)},innerShadow:function(t,e,n){let i,s;const{__nowWorld:o,__layout:a}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:d,shapeBounds:c,scaleX:h,scaleY:u}=n,f=e.getSameCanvas(),p=r.length-1;Ft(d,zt),r.forEach(((r,g)=>{f.save(),f.setWorldShadow(zt.offsetX+r.x*h,zt.offsetY+r.y*u,r.blur*h),s=r.spread?1-2*r.spread/(a.boxBounds.width+2*(a.strokeBoxSpread||0)):0,Ht(f,zt,s,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,a.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:Yt}=t.LeafBoundsHelper;function jt(t,e,n,i,s,o){switch(e){case"alpha":!function(t,e,n,i){const s=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(i,s),i.recycle(s),Ut(t,e,n,1)}(t,n,i,s);break;case"opacity-path":Ut(t,n,i,o);break;case"path":n.restore()}}function Gt(t){return t.getSameCanvas(!1,!0)}function Ut(t,e,n,i){const s=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(n,s),n.recycle(s)}e.Group.prototype.__renderMask=function(t,e){let n,i,s,o,a;const{children:r}=this;for(let l=0,d=r.length;l<d;l++)n=r[l],n.__.mask&&(a&&(jt(this,a,t,s,i,o),i=s=null),"path"===n.__.mask?(n.opacity<1?(a="opacity-path",o=n.opacity,s||(s=Gt(t))):(a="path",t.save()),n.__clip(s||t,e)):(a="alpha",i||(i=Gt(t)),s||(s=Gt(t)),n.__render(i,e)),"clipping"!==n.__.mask)||Yt(n,e)||n.__render(s||t,e);jt(this,a,t,s,i,o)};const Xt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Nt=Xt+"_#~&*+\\=|≮≯≈≠=…",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 Qt(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const Jt=Qt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Zt=Qt("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),$t=Qt(Xt),Kt=Qt(Nt),te=Qt("- —/~|┆·");var ee;!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"}(ee||(ee={}));const{Letter:ne,Single:ie,Before:se,After:oe,Symbol:ae,Break:re}=ee;function le(t){return Jt[t]?ne:te[t]?re:Zt[t]?se:$t[t]?oe:Kt[t]?ae:qt.test(t)?ie:ne}const de={trimRight(t){const{words:e}=t;let n,i=0,s=e.length;for(let o=s-1;o>-1&&(n=e[o].data[0]," "===n.char);o--)i++,t.width-=n.width;i&&e.splice(s-i,i)}};function ce(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:he}=de,{Letter:ue,Single:fe,Before:pe,After:ge,Symbol:_e,Break:we}=ee;let me,ve,ye,xe,be,Be,Ee,Re,Le,ke,Pe,Se,Ce,Ae,Oe,We,Me,Te=[];function De(t,e){Le&&!Re&&(Re=Le),me.data.push({char:t,width:e}),ye+=e}function Ie(){xe+=ye,me.width=ye,ve.words.push(me),me={data:[]},ye=0}function He(){Ae&&(Oe.paraNumber++,ve.paraStart=!0,Ae=!1),Le&&(ve.startCharSize=Re,ve.endCharSize=Le,Re=0),ve.width=xe,We.width?he(ve):Me&&Fe(),Te.push(ve),ve={words:[]},xe=0}function Fe(){xe>(Oe.maxWidth||0)&&(Oe.maxWidth=xe)}const ze=0,Ve=1,Ye=2;const{top:je,right:Ge,bottom:Ue,left:Xe}=t.Direction4;function Ne(t,e,n){const{bounds:i,rows:s}=t;i[e]+=n;for(let t=0;t<s.length;t++)s[t][e]+=n}const qe={getDrawData:function(e,n){"string"!=typeof e&&(e=String(e));let i=0,s=0,o=n.__getInput("width")||0,a=n.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=n;d&&(o?(i=d[Xe],o-=d[Ge]+d[Xe]):n.autoSizeAlign||(i=d[Xe]),a?(s=d[je],a-=d[je]+d[Ue]):n.autoSizeAlign||(s=d[je]));const c={bounds:{x:i,y:s,width:o,height:a},rows:[],paraNumber:0,font:t.Platform.canvas.font=l};return function(e,n,i){Oe=e,Te=e.rows,We=e.bounds,Me=!We.width&&!i.autoSizeAlign;const{__letterSpacing:s,paraIndent:o,textCase:a}=i,{canvas:r}=t.Platform,{width:l,height:d}=We;if(l||d||s||"none"!==a){const t="none"!==i.textWrap,e="break"===i.textWrap;Ae=!0,Pe=null,Re=Ee=Le=ye=xe=0,me={data:[]},ve={words:[]};for(let i=0,d=n.length;i<d;i++)Be=n[i],"\n"===Be?(ye&&Ie(),ve.paraEnd=!0,He(),Ae=!0):(ke=le(Be),ke===ue&&"none"!==a&&(Be=ce(Be,a,!ye)),Ee=r.measureText(Be).width,s&&(s<0&&(Le=Ee),Ee+=s),Se=ke===fe&&(Pe===fe||Pe===ue)||Pe===fe&&ke!==ge,Ce=!(ke!==pe&&ke!==fe||Pe!==_e&&Pe!==ge),be=Ae&&o?l-o:l,t&&l&&xe+ye+Ee>be&&(e?(ye&&Ie(),xe&&He()):(Ce||(Ce=ke===ue&&Pe==ge),Se||Ce||ke===we||ke===pe||ke===fe||ye+Ee>be?(ye&&Ie(),xe&&He()):xe&&He()))," "===Be&&!0!==Ae&&xe+ye===0||(ke===we?(" "===Be&&ye&&Ie(),De(Be,Ee),Ie()):Se||Ce?(ye&&Ie(),De(Be,Ee)):De(Be,Ee)),Pe=ke);ye&&Ie(),xe&&He(),Te.length>0&&(Te[Te.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{Oe.paraNumber++,xe=r.measureText(t).width,Te.push({x:o||0,text:t,width:xe,paraStart:!0}),Me&&Fe()}))}(c,e,n),d&&function(t,e,n,i,s){if(!i&&n.autoSizeAlign)switch(n.textAlign){case"left":Ne(e,"x",t[Xe]);break;case"right":Ne(e,"x",-t[Ge])}if(!s&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ne(e,"y",t[je]);break;case"bottom":Ne(e,"y",-t[Ue])}}(d,c,n,o,a),function(t,e){const{rows:n,bounds:i}=t,{__lineHeight:s,__baseLine:o,__letterSpacing:a,__clipText:r,textAlign:l,verticalAlign:d,paraSpacing:c,autoSizeAlign:h}=e;let{x:u,y:f,width:p,height:g}=i,_=s*n.length+(c?c*(t.paraNumber-1):0),w=o;if(r&&_>g)_=Math.max(g,s),t.overflow=n.length;else if(g||h)switch(d){case"middle":f+=(g-_)/2;break;case"bottom":f+=g-_}w+=f;let m,v,y,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+=s,t.overflow>o&&w>_&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,y=m.width,a<0&&(m.width<0?(y=-m.width+e.fontSize+a,v-=y,y+=e.fontSize):y-=a),v<i.x&&(i.x=v),y>i.width&&(i.width=y),r&&p&&p<y&&(m.isOverflow=!0,t.overflow||(t.overflow=n.length))}i.y=f,i.height=_}(c,n),function(t,e,n,i){const{rows:s}=t,{textAlign:o,paraIndent:a,letterSpacing:r}=e;let l,d,c,h,u;s.forEach((t=>{t.words&&(c=a&&t.paraStart?a:0,d=n&&"justify"===o&&t.words.length>1?(n-t.width-c)/(t.words.length-1):0,h=r||t.isOverflow?ze:d>.01?Ve:Ye,t.isOverflow&&!r&&(t.textMode=!0),h===Ye?(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===Ve?(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,s){if(!s)return;const{rows:o,overflow:a}=e;let{textOverflow:r}=n;if(o.splice(a),r&&"show"!==r){let e,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?t.Platform.canvas.measureText(r).width:0,c=i+s-d;("none"===n.textWrap?o:[o[a-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 Qe={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 s=void 0===t.a?1:t.a;i&&(s*=n);const o=t.r+","+t.g+","+t.b;return 1===s?"rgb("+o+")":"rgba("+o+","+s+")"}},{setPoint:Je,addPoint:Ze,toBounds:$e}=t.TwoPointBoundsHelper;const Ke={export(e,n,i){this.running=!0;const s=t.FileHelper.fileType(n),o=n.includes(".");return i=t.FileHelper.getExportOptions(i),function(e){tn||(tn=new t.TaskProcessor);return new Promise((t=>{tn.add((()=>ft(this,void 0,void 0,(function*(){return yield e(t)}))),{parallel:!1})}))}((a=>new Promise((r=>{const l=t=>{a(t),r(),this.running=!1},{toURL:d}=t.Platform,{download:c}=t.Platform.origin;if("json"===s)return o&&c(d(JSON.stringify(e.toJSON(i.json)),"text"),n),l({data:!!o||e.toJSON(i.json)});if("svg"===s)return o&&c(d(e.toSVG(),"svg"),n),l({data:!!o||e.toSVG()});const{leafer:h}=e;h?(en(e),h.waitViewCompleted((()=>ft(this,void 0,void 0,(function*(){let s,o,a=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,v=c&&m&&void 0===i.fill?e.fill:i.fill,y=t.FileHelper.isOpaqueImage(n)||v,x=new t.Matrix;if(m)s=!0===m?c?h.canvas.bounds:e.worldRenderBounds:m;else{let t=i.relative||(c?"inner":"local");switch(a=d.scaleX,r=d.scaleY,t){case"inner":x.set(d);break;case"local":x.set(d).divide(e.localTransform),a/=e.scaleX,r/=e.scaleY;break;case"world":a=1,r=1;break;case"page":t=e.leafer;default:x.set(d).divide(e.getTransform(t));const n=t.worldTransform;a/=a/n.scaleX,r/=r/n.scaleY}s=e.getBounds("render",t)}const b={scaleX:1,scaleY:1};t.MathHelper.getScaleData(i.scale,i.size,s,b);let B=i.pixelRatio||1;e.isApp&&(b.scaleX*=B,b.scaleY*=B,B=e.app.pixelRatio);const{x:E,y:R,width:L,height:k}=new t.Bounds(s).scale(b.scaleX,b.scaleY),P={matrix:x.scale(1/b.scaleX,1/b.scaleY).invert().translate(-E,-R).withScale(1/a*b.scaleX,1/r*b.scaleY)};let S,C=t.Creator.canvas({width:Math.round(L),height:Math.round(k),pixelRatio:B,smooth:_,contextSettings:w});if(f&&(S=e,S.__worldOpacity=0,e=h,P.bounds=C.bounds),C.save(),u&&void 0!==v){const t=e.get("fill");e.fill="",e.__render(C,P),e.fill=t}else e.__render(C,P);if(C.restore(),S&&S.__updateWorldOpacity(),p){o=function(e){const{width:n,height:i}=e.view,{data:s}=e.context.getImageData(0,0,n,i);let o,a,r,l=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(o=l%n,a=(l-o)/n,r?Ze(r,o,a):Je(r={},o,a)),l++;const d=new t.Bounds;return $e(r,d),d.scale(1/e.pixelRatio).ceil()}(C);const e=C,{width:n,height:i}=o,s={x:0,y:0,width:n,height:i,pixelRatio:B};C=t.Creator.canvas(s),C.copyWorld(e,o,s)}y&&C.fillWorld(C.bounds,v||"#FFFFFF","destination-over"),g&&g(C);const A="canvas"===n?C:yield C.export(n,i);l({data:A,width:C.pixelWidth,height:C.pixelHeight,renderBounds:s,trimBounds:o})}))))):l({data:!1})}))))}};let tn;function en(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach((t=>en(t)))}const nn=t.LeaferCanvasBase.prototype,sn=t.Debug.get("@leafer-ui/export");nn.export=function(e,n){const{quality:i,blob:s}=t.FileHelper.getExportOptions(n);return e.includes(".")?this.saveAs(e,i):s?this.toBlob(e,i):this.toDataURL(e,i)},nn.toBlob=function(e,n){return new Promise((i=>{t.Platform.origin.canvasToBolb(this.view,e,n).then((t=>{i(t)})).catch((t=>{sn.error(t),i(null)}))}))},nn.toDataURL=function(e,n){return t.Platform.origin.canvasToDataURL(this.view,e,n)},nn.saveAs=function(e,n){return new Promise((i=>{t.Platform.origin.canvasSaveAs(this.view,e,n).then((()=>{i(!0)})).catch((t=>{sn.error(t),i(!1)}))}))},Object.assign(e.TextConvert,qe),Object.assign(e.ColorConvert,Qe),Object.assign(e.Paint,M),Object.assign(e.PaintImage,gt),Object.assign(e.PaintGradient,Wt),Object.assign(e.Effect,Vt),Object.assign(e.Export,Ke),a(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=i,exports.Renderer=b,exports.Watcher=l,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]}})}));
|