@leafer-ui/worker 1.0.0-rc.5 → 1.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.esm.js +158 -134
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +386 -235
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +386 -235
- package/dist/worker.module.min.js +1 -1
- package/package.json +6 -6
package/dist/worker.esm.js
CHANGED
|
@@ -558,7 +558,7 @@ class Renderer {
|
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
const { hitRadiusPoint } = BoundsHelper;
|
|
561
|
-
class
|
|
561
|
+
class Pather {
|
|
562
562
|
constructor(target, selector) {
|
|
563
563
|
this.target = target;
|
|
564
564
|
this.selector = selector;
|
|
@@ -678,117 +678,108 @@ class FindPath {
|
|
|
678
678
|
class Selector {
|
|
679
679
|
constructor(target, userConfig) {
|
|
680
680
|
this.config = {};
|
|
681
|
-
this.
|
|
682
|
-
this.
|
|
683
|
-
this.
|
|
684
|
-
|
|
681
|
+
this.innerIdMap = {};
|
|
682
|
+
this.idMap = {};
|
|
683
|
+
this.methods = {
|
|
684
|
+
id: (leaf, name) => leaf.id === name ? this.idMap[name] = leaf : 0,
|
|
685
|
+
innerId: (leaf, innerId) => leaf.innerId === innerId ? this.innerIdMap[innerId] = leaf : 0,
|
|
686
|
+
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
687
|
+
tag: (leaf, name) => leaf.__tag === name ? 1 : 0
|
|
688
|
+
};
|
|
685
689
|
this.target = target;
|
|
686
690
|
if (userConfig)
|
|
687
691
|
this.config = DataHelper.default(userConfig, this.config);
|
|
688
|
-
this.
|
|
692
|
+
this.pather = new Pather(target, this);
|
|
689
693
|
this.__listenEvents();
|
|
690
694
|
}
|
|
691
695
|
getByPoint(hitPoint, hitRadius, options) {
|
|
692
696
|
if (Platform.name === 'node')
|
|
693
697
|
this.target.emit(LayoutEvent.CHECK_UPDATE);
|
|
694
|
-
return this.
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
698
|
+
return this.pather.getByPoint(hitPoint, hitRadius, options);
|
|
699
|
+
}
|
|
700
|
+
getBy(condition, branch, one, options) {
|
|
701
|
+
switch (typeof condition) {
|
|
702
|
+
case 'number':
|
|
703
|
+
const leaf = this.getByInnerId(condition, branch);
|
|
704
|
+
return one ? leaf : (leaf ? [leaf] : []);
|
|
705
|
+
case 'string':
|
|
706
|
+
switch (condition[0]) {
|
|
707
|
+
case '#':
|
|
708
|
+
const leaf = this.getById(condition.substring(1), branch);
|
|
709
|
+
return one ? leaf : (leaf ? [leaf] : []);
|
|
710
|
+
case '.':
|
|
711
|
+
return this.getByMethod(this.methods.className, branch, one, condition.substring(1));
|
|
712
|
+
default:
|
|
713
|
+
return this.getByMethod(this.methods.tag, branch, one, condition);
|
|
714
|
+
}
|
|
715
|
+
case 'function':
|
|
716
|
+
return this.getByMethod(condition, branch, one, options);
|
|
708
717
|
}
|
|
709
718
|
}
|
|
710
|
-
getByInnerId(
|
|
711
|
-
|
|
719
|
+
getByInnerId(innerId, branch) {
|
|
720
|
+
const cache = this.innerIdMap[innerId];
|
|
712
721
|
if (cache)
|
|
713
722
|
return cache;
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
let find;
|
|
717
|
-
this.loopFind(branch, (leaf) => {
|
|
718
|
-
if (leaf.innerId === name) {
|
|
719
|
-
find = leaf;
|
|
720
|
-
this.innerIdList[name] = find;
|
|
721
|
-
return true;
|
|
722
|
-
}
|
|
723
|
-
else {
|
|
724
|
-
return false;
|
|
725
|
-
}
|
|
726
|
-
});
|
|
727
|
-
return find;
|
|
723
|
+
this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
|
|
724
|
+
return this.findLeaf;
|
|
728
725
|
}
|
|
729
|
-
getById(
|
|
730
|
-
|
|
731
|
-
if (cache)
|
|
726
|
+
getById(id, branch) {
|
|
727
|
+
const cache = this.idMap[id];
|
|
728
|
+
if (cache && LeafHelper.hasParent(cache, branch || this.target))
|
|
732
729
|
return cache;
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
let find;
|
|
736
|
-
this.loopFind(branch, (leaf) => {
|
|
737
|
-
if (leaf.id === name) {
|
|
738
|
-
find = leaf;
|
|
739
|
-
this.idList[name] = find;
|
|
740
|
-
return true;
|
|
741
|
-
}
|
|
742
|
-
else {
|
|
743
|
-
return false;
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
return find;
|
|
747
|
-
}
|
|
748
|
-
getByClassName(name, branch) {
|
|
749
|
-
if (!branch)
|
|
750
|
-
branch = this.target;
|
|
751
|
-
let find = [];
|
|
752
|
-
this.loopFind(branch, (leaf) => {
|
|
753
|
-
if (leaf.className === name)
|
|
754
|
-
find.push(leaf);
|
|
755
|
-
return false;
|
|
756
|
-
});
|
|
757
|
-
return find;
|
|
758
|
-
}
|
|
759
|
-
getByTagName(name, branch) {
|
|
760
|
-
if (!branch)
|
|
761
|
-
branch = this.target;
|
|
762
|
-
let find = [];
|
|
763
|
-
this.loopFind(branch, (leaf) => {
|
|
764
|
-
if (leaf.__tag === name)
|
|
765
|
-
find.push(leaf);
|
|
766
|
-
return false;
|
|
767
|
-
});
|
|
768
|
-
return find;
|
|
730
|
+
this.eachFind(this.toChildren(branch), this.methods.id, null, id);
|
|
731
|
+
return this.findLeaf;
|
|
769
732
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
733
|
+
getByClassName(className, branch) {
|
|
734
|
+
return this.getByMethod(this.methods.className, branch, false, className);
|
|
735
|
+
}
|
|
736
|
+
getByTag(tag, branch) {
|
|
737
|
+
return this.getByMethod(this.methods.tag, branch, false, tag);
|
|
738
|
+
}
|
|
739
|
+
getByMethod(method, branch, one, options) {
|
|
740
|
+
const list = one ? null : [];
|
|
741
|
+
this.eachFind(this.toChildren(branch), method, list, options);
|
|
742
|
+
return list || this.findLeaf;
|
|
743
|
+
}
|
|
744
|
+
eachFind(children, method, list, options) {
|
|
745
|
+
let child;
|
|
774
746
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
775
|
-
|
|
776
|
-
if (
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
747
|
+
child = children[i];
|
|
748
|
+
if (method(child, options)) {
|
|
749
|
+
if (list) {
|
|
750
|
+
list.push(child);
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
this.findLeaf = child;
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
if (child.isBranch)
|
|
758
|
+
this.eachFind(child.children, method, list, options);
|
|
780
759
|
}
|
|
781
760
|
}
|
|
761
|
+
toChildren(branch) {
|
|
762
|
+
this.findLeaf = null;
|
|
763
|
+
return [branch || this.target];
|
|
764
|
+
}
|
|
782
765
|
__onRemoveChild(event) {
|
|
783
|
-
const
|
|
784
|
-
if (this.
|
|
785
|
-
this.
|
|
786
|
-
if (this.
|
|
787
|
-
this.
|
|
766
|
+
const { id, innerId } = event.child;
|
|
767
|
+
if (this.idMap[id])
|
|
768
|
+
delete this.idMap[id];
|
|
769
|
+
if (this.innerIdMap[innerId])
|
|
770
|
+
delete this.innerIdMap[innerId];
|
|
771
|
+
}
|
|
772
|
+
__checkIdChange(event) {
|
|
773
|
+
if (event.attrName === 'id') {
|
|
774
|
+
const id = event.oldValue;
|
|
775
|
+
if (this.idMap[id])
|
|
776
|
+
delete this.idMap[id];
|
|
777
|
+
}
|
|
788
778
|
}
|
|
789
779
|
__listenEvents() {
|
|
790
780
|
this.__eventIds = [
|
|
791
|
-
this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this)
|
|
781
|
+
this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this),
|
|
782
|
+
this.target.on_(PropertyEvent.CHANGE, this.__checkIdChange, this)
|
|
792
783
|
];
|
|
793
784
|
}
|
|
794
785
|
__removeListenEvents() {
|
|
@@ -798,11 +789,10 @@ class Selector {
|
|
|
798
789
|
destroy() {
|
|
799
790
|
if (this.__eventIds.length) {
|
|
800
791
|
this.__removeListenEvents();
|
|
801
|
-
this.
|
|
802
|
-
this.
|
|
803
|
-
this.
|
|
804
|
-
this.
|
|
805
|
-
this.tagNameList = {};
|
|
792
|
+
this.pather.destroy();
|
|
793
|
+
this.findLeaf = null;
|
|
794
|
+
this.innerIdMap = {};
|
|
795
|
+
this.idMap = {};
|
|
806
796
|
}
|
|
807
797
|
}
|
|
808
798
|
}
|
|
@@ -1185,8 +1175,9 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1185
1175
|
if (!paint.patternTask) {
|
|
1186
1176
|
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
1187
1177
|
paint.patternTask = null;
|
|
1188
|
-
if (canvas.bounds.hit(ui.__world)
|
|
1189
|
-
ui.
|
|
1178
|
+
if (canvas.bounds.hit(ui.__world))
|
|
1179
|
+
createPattern(ui, paint, canvas.pixelRatio);
|
|
1180
|
+
ui.forceUpdate('surface');
|
|
1190
1181
|
}), 300);
|
|
1191
1182
|
}
|
|
1192
1183
|
}
|
|
@@ -1850,6 +1841,8 @@ function createRows(drawData, content, style) {
|
|
|
1850
1841
|
const { width, height } = bounds;
|
|
1851
1842
|
const charMode = width || height || __letterSpacing || (textCase !== 'none');
|
|
1852
1843
|
if (charMode) {
|
|
1844
|
+
const wrap = style.textWrap !== 'none';
|
|
1845
|
+
const breakAll = style.textWrap === 'break';
|
|
1853
1846
|
paraStart = true;
|
|
1854
1847
|
lastCharType = null;
|
|
1855
1848
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
@@ -1876,16 +1869,23 @@ function createRows(drawData, content, style) {
|
|
|
1876
1869
|
langBreak = (charType === Single && (lastCharType === Single || lastCharType === Letter)) || (lastCharType === Single && charType !== After);
|
|
1877
1870
|
afterBreak = ((charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After));
|
|
1878
1871
|
realWidth = paraStart && paraIndent ? width - paraIndent : width;
|
|
1879
|
-
if (width && rowWidth + wordWidth + charWidth > realWidth) {
|
|
1880
|
-
if (
|
|
1881
|
-
afterBreak = charType === Letter && lastCharType == After;
|
|
1882
|
-
if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
|
|
1872
|
+
if (wrap && (width && rowWidth + wordWidth + charWidth > realWidth)) {
|
|
1873
|
+
if (breakAll) {
|
|
1883
1874
|
if (wordWidth)
|
|
1884
1875
|
addWord();
|
|
1885
1876
|
addRow();
|
|
1886
1877
|
}
|
|
1887
1878
|
else {
|
|
1888
|
-
|
|
1879
|
+
if (!afterBreak)
|
|
1880
|
+
afterBreak = charType === Letter && lastCharType == After;
|
|
1881
|
+
if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
|
|
1882
|
+
if (wordWidth)
|
|
1883
|
+
addWord();
|
|
1884
|
+
addRow();
|
|
1885
|
+
}
|
|
1886
|
+
else {
|
|
1887
|
+
addRow();
|
|
1888
|
+
}
|
|
1889
1889
|
}
|
|
1890
1890
|
}
|
|
1891
1891
|
if (char === ' ' && paraStart !== true && (rowWidth + wordWidth) === 0) ;
|
|
@@ -1955,7 +1955,7 @@ function addRow() {
|
|
|
1955
1955
|
|
|
1956
1956
|
const CharMode = 0;
|
|
1957
1957
|
const WordMode = 1;
|
|
1958
|
-
const
|
|
1958
|
+
const TextMode = 2;
|
|
1959
1959
|
function layoutChar(drawData, style, width, _height) {
|
|
1960
1960
|
const { rows } = drawData;
|
|
1961
1961
|
const { textAlign, paraIndent, letterSpacing } = style;
|
|
@@ -1964,15 +1964,12 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
1964
1964
|
if (row.words) {
|
|
1965
1965
|
indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
|
|
1966
1966
|
addWordWidth = (width && textAlign === 'justify' && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
|
|
1967
|
-
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode :
|
|
1968
|
-
if (
|
|
1969
|
-
row.
|
|
1967
|
+
mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
|
|
1968
|
+
if (row.isOverflow && !letterSpacing)
|
|
1969
|
+
row.textMode = true;
|
|
1970
|
+
if (mode === TextMode) {
|
|
1970
1971
|
row.x += indentWidth;
|
|
1971
|
-
row
|
|
1972
|
-
word.data.forEach(char => {
|
|
1973
|
-
row.text += char.char;
|
|
1974
|
-
});
|
|
1975
|
-
});
|
|
1972
|
+
toTextChar$1(row);
|
|
1976
1973
|
}
|
|
1977
1974
|
else {
|
|
1978
1975
|
row.x += indentWidth;
|
|
@@ -1998,6 +1995,14 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
1998
1995
|
}
|
|
1999
1996
|
});
|
|
2000
1997
|
}
|
|
1998
|
+
function toTextChar$1(row) {
|
|
1999
|
+
row.text = '';
|
|
2000
|
+
row.words.forEach(word => {
|
|
2001
|
+
word.data.forEach(char => {
|
|
2002
|
+
row.text += char.char;
|
|
2003
|
+
});
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2001
2006
|
function toWordChar(data, charX, wordChar) {
|
|
2002
2007
|
data.forEach(char => {
|
|
2003
2008
|
wordChar.char += char.char;
|
|
@@ -2018,10 +2023,10 @@ function toChar(data, charX, rowData) {
|
|
|
2018
2023
|
|
|
2019
2024
|
function layoutText(drawData, style) {
|
|
2020
2025
|
const { rows, bounds } = drawData;
|
|
2021
|
-
const { __lineHeight, __baseLine, __letterSpacing, textAlign, verticalAlign, paraSpacing
|
|
2026
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
2022
2027
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
2023
2028
|
let starY = __baseLine;
|
|
2024
|
-
if (
|
|
2029
|
+
if (__clipText && realHeight > height) {
|
|
2025
2030
|
realHeight = Math.max(height, __lineHeight);
|
|
2026
2031
|
drawData.overflow = rows.length;
|
|
2027
2032
|
}
|
|
@@ -2070,39 +2075,58 @@ function layoutText(drawData, style) {
|
|
|
2070
2075
|
bounds.x = rowX;
|
|
2071
2076
|
if (rowWidth > bounds.width)
|
|
2072
2077
|
bounds.width = rowWidth;
|
|
2078
|
+
if (__clipText && width && width < rowWidth) {
|
|
2079
|
+
row.isOverflow = true;
|
|
2080
|
+
if (!drawData.overflow)
|
|
2081
|
+
drawData.overflow = rows.length;
|
|
2082
|
+
}
|
|
2073
2083
|
}
|
|
2074
2084
|
bounds.y = y;
|
|
2075
2085
|
bounds.height = realHeight;
|
|
2076
2086
|
}
|
|
2077
2087
|
|
|
2078
|
-
function clipText(drawData,
|
|
2088
|
+
function clipText(drawData, style) {
|
|
2079
2089
|
const { rows, overflow } = drawData;
|
|
2090
|
+
let { textOverflow } = style;
|
|
2080
2091
|
rows.splice(overflow);
|
|
2081
2092
|
if (textOverflow !== 'hide') {
|
|
2082
2093
|
if (textOverflow === 'ellipsis')
|
|
2083
2094
|
textOverflow = '...';
|
|
2095
|
+
let char, charRight;
|
|
2084
2096
|
const ellipsisWidth = Platform.canvas.measureText(textOverflow).width;
|
|
2085
|
-
const
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2097
|
+
const right = style.x + style.width - ellipsisWidth;
|
|
2098
|
+
const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
|
|
2099
|
+
list.forEach(row => {
|
|
2100
|
+
if (row.isOverflow && row.data) {
|
|
2101
|
+
let end = row.data.length - 1;
|
|
2102
|
+
for (let i = end; i > -1; i--) {
|
|
2103
|
+
char = row.data[i];
|
|
2104
|
+
charRight = char.x + char.width;
|
|
2105
|
+
if (i === end && charRight < right) {
|
|
2106
|
+
break;
|
|
2107
|
+
}
|
|
2108
|
+
else if (charRight < right && char.char !== ' ') {
|
|
2109
|
+
row.data.splice(i + 1);
|
|
2110
|
+
row.width -= char.width;
|
|
2111
|
+
break;
|
|
2112
|
+
}
|
|
2113
|
+
row.width -= char.width;
|
|
2114
|
+
}
|
|
2115
|
+
row.width += ellipsisWidth;
|
|
2116
|
+
row.data.push({ char: textOverflow, x: charRight });
|
|
2117
|
+
if (row.textMode)
|
|
2118
|
+
toTextChar(row);
|
|
2099
2119
|
}
|
|
2100
|
-
|
|
2101
|
-
}
|
|
2102
|
-
row.width += ellipsisWidth;
|
|
2103
|
-
row.data.push({ char: textOverflow, x: charRight });
|
|
2120
|
+
});
|
|
2104
2121
|
}
|
|
2105
2122
|
}
|
|
2123
|
+
function toTextChar(row) {
|
|
2124
|
+
row.text = '';
|
|
2125
|
+
row.data.forEach(char => {
|
|
2126
|
+
row.text += char.char;
|
|
2127
|
+
});
|
|
2128
|
+
row.data = null;
|
|
2129
|
+
}
|
|
2106
2130
|
|
|
2107
2131
|
function decorationText(drawData, style) {
|
|
2108
2132
|
const { fontSize } = style;
|
|
@@ -2123,7 +2147,7 @@ const TextConvert = {
|
|
|
2123
2147
|
let x = 0, y = 0;
|
|
2124
2148
|
let width = style.__getInput('width') || 0;
|
|
2125
2149
|
let height = style.__getInput('height') || 0;
|
|
2126
|
-
const { textDecoration,
|
|
2150
|
+
const { textDecoration, __font, padding } = style;
|
|
2127
2151
|
if (padding) {
|
|
2128
2152
|
const [top, right, bottom, left] = MathHelper.fourNumber(padding);
|
|
2129
2153
|
if (width) {
|
|
@@ -2145,7 +2169,7 @@ const TextConvert = {
|
|
|
2145
2169
|
layoutText(drawData, style);
|
|
2146
2170
|
layoutChar(drawData, style, width);
|
|
2147
2171
|
if (drawData.overflow)
|
|
2148
|
-
clipText(drawData,
|
|
2172
|
+
clipText(drawData, style);
|
|
2149
2173
|
if (textDecoration !== 'none')
|
|
2150
2174
|
decorationText(drawData, style);
|
|
2151
2175
|
return drawData;
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as r,LeafHelper as a,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as f,Run as _,ImageManager as g,Platform as p,AnimateEvent as y,ResizeEvent as w,Creator as m,LeaferCanvasBase as v,canvasPatch as x,LeaferImage as b,InteractionBase as B,FileHelper as R,MatrixHelper as L,ImageEvent as E,PointHelper as k,MathHelper as S,TaskProcessor as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as O,ImageManager as C,Paint as M,Effect as T,TextConvert as W,Export as I}from"@leafer-ui/core";export*from"@leafer-ui/core";class D{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,s&&(this.config=e.default(s,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(i.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===s.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(r.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:P,updateAllWorldOpacity:F}=a,{pushAllChildBranch:N,pushAllParent:Y}=o;const{worldBounds:U}=h,{setByListWithHandle:H}=l;class V{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){H(this.beforeBounds,this.updatedList.list,U)}setAfter(){H(this.afterBounds,this.updatedList.list,U),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:G,updateAllChange:j}=a,{pushAllBranchStack:q,updateWorldBoundsByBranchStack:X}=o,z=c.get("Layouter");class Q{constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,i&&(this.config=e.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(f.START),this.layoutOnce(),t.emitEvent(new f(f.END,this.layoutedBlocks,this.times))}catch(t){z.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?z.warn("layouting"):this.times>3?z.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=_.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:r,AFTER:a}=f,o=this.getBlocks(s);o.forEach((t=>{t.setBefore()})),i.emitEvent(new f(n,o,this.times)),s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(P(t),e.push(t),t.isBranch&&N(t,e),Y(t,e)):i.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),Y(t,e)))}))}(s,this.__levelList),function(t){let e,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber)for(let t=0,e=i.children.length;t<e;t++)i.children[t].isBranch||i.children[t].__updateWorldBounds();i.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&F(t),t.__updateChange()}))}(s),o.forEach((t=>t.setAfter())),i.emitEvent(new f(r,o,this.times)),i.emitEvent(new f(a,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,_.end(e)}fullLayout(){const e=_.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:r}=f,a=this.getBlocks(new t(i));i.emitEvent(new f(s,a,this.times)),Q.fullLayout(i),a.forEach((t=>{t.setAfter()})),i.emitEvent(new f(n,a,this.times)),i.emitEvent(new f(r,a,this.times)),this.addBlocks(a),_.end(e)}static fullLayout(t){if(G(t),t.isBranch){const e=[t];q(t,e),X(e)}else t.__updateWorldBounds();j(t)}createBlock(t){return new V(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.REQUEST,this.layout,this),t.on_(f.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const Z=c.get("Renderer");class K{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(f.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,Z.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),g.clearRecycled()}catch(t){this.rendering=!1,Z.error(t)}Z.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Z.warn("rendering"):this.times>3?Z.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Z.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=_.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),r=(new d).copy(s);i.save(),n&&!c.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,r),i.restore(),_.end(e)}fullRender(){const t=_.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),_.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(s),c.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new d;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(y.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new d(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||Z.warn(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(f.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(w.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:$}=l;class J{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],a.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.push(e),e=e.parent;return i.push(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.unshift(s),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=s.length;t<e;t++){n=s[t],r=s[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)i.push(a)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let r=t.length-1;r>-1;r--)i=t[r],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||$(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class tt{constructor(t,i){this.config={},this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={},this.target=t,i&&(this.config=e.default(i,this.config)),this.findPath=new J(t,this),this.__listenEvents()}getByPoint(t,e,i){return"node"===p.name&&this.target.emit(f.CHECK_UPDATE),this.findPath.getByPoint(t,e,i)}find(t,e){return"number"==typeof t?this.getByInnerId(t,e):t.startsWith("#")?this.getById(t.substring(1),e):t.startsWith(".")?this.getByClassName(t.substring(1),e):this.getByTagName(t,e)}getByInnerId(t,e){let i,s=this.innerIdList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.innerId===t&&(i=e,this.innerIdList[t]=i,!0))),i)}getById(t,e){let i,s=this.idList[t];return s||(e||(e=this.target),this.loopFind(e,(e=>e.id===t&&(i=e,this.idList[t]=i,!0))),i)}getByClassName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.className===t&&i.push(e),!1))),i}getByTagName(t,e){e||(e=this.target);let i=[];return this.loopFind(e,(e=>(e.__tag===t&&i.push(e),!1))),i}loopFind(t,e){if(e(t))return;const{children:i}=t;for(let s=0,n=i.length;s<n;s++){if(e(t=i[s]))return;t.isBranch&&this.loopFind(t,e)}}__onRemoveChild(t){const e=t.target;this.idList[e.id]&&(this.idList[e.id]=null),this.innerIdList[e.id]&&(this.innerIdList[e.innerId]=null)}__listenEvents(){this.__eventIds=[this.target.on_(s.REMOVE,this.__onRemoveChild,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.findPath.destroy(),this.innerIdList={},this.idList={},this.classNameList={},this.tagNameList={})}}Object.assign(m,{watcher:(t,e)=>new D(t,e),layouter:(t,e)=>new Q(t,e),renderer:(t,e,i)=>new K(t,e,i),selector:(t,e)=>new tt(t,e)}),p.layout=Q.fullLayout;class et extends v{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=t*i,this.view.height=e*i,this.clientBounds=this.bounds}}x(OffscreenCanvasRenderingContext2D.prototype),x(Path2D.prototype);const{mineType:it}=R;function st(t,e){p.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:it(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:it(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),loadImage:t=>new Promise(((e,i)=>{!t.startsWith("data:")&&p.imageSuffix&&(t+=(t.includes("?")?"&":"?")+p.imageSuffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{e(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},p.canvas=m.canvas(),p.conicGradientSupport=!!p.canvas.context.createConicGradient}Object.assign(m,{canvas:(t,e)=>new et(t,e),image:t=>new b(t),hitCanvas:(t,e)=>new et(t,e),interaction:(t,e,i,s)=>new B(t,e,i,s)}),p.name="web",p.isWorker=!0,p.requestRender=function(t){requestAnimationFrame(t)},p.devicePixelRatio=1,p.realtimeLayout=!0;const{userAgent:nt}=navigator;nt.indexOf("Firefox")>-1?(p.conicGradientRotate90=!0,p.intWheelDeltaY=!0):nt.indexOf("Safari")>-1&&-1===nt.indexOf("Chrome")&&(p.fullImageShadow=!0),nt.indexOf("Windows")>-1?(p.os="Windows",p.intWheelDeltaY=!0):nt.indexOf("Mac")>-1?p.os="Mac":nt.indexOf("Linux")>-1&&(p.os="Linux");const{get:rt,rotateOfOuter:at,translate:ot,scaleOfOuter:dt,scale:ht,rotate:lt}=L;const{get:ct,translate:ut}=L;function ft(t,e,i,s){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:h,rotation:l,blendMode:c}=i,u=s.width===n&&s.height===r;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(n=s.width,r=s.height),(s.x||s.y)&&(f.transform=ct(),ut(f.transform,s.x,s.y));break;case"clip":(d||h||l)&&function(t,e,i,s,n){const r=rt();ot(r,e.x,e.y),i&&ot(r,i.x,i.y),s&&("number"==typeof s?ht(r,s):ht(r,s.x,s.y),t.scaleX=r.a,t.scaleY=r.d),n&<(r,n),t.transform=r}(f,s,d,h,l);break;case"repeat":(!u||h||l)&&function(t,e,i,s,n,r){const a=rt();if(r)switch(lt(a,r),r){case 90:ot(a,s,0);break;case 180:ot(a,i,s);break;case 270:ot(a,0,i)}ot(a,e.x,e.y),n&&(dt(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(f,s,n,r,h,l);break;default:u&&!l||function(t,e,i,s,n,r){const a=rt(),o=r&&180!==r,d=i.width/(o?n:s),h=i.height/(o?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;ot(a,c,u),ht(a,l),r&&at(a,{x:i.x+i.width/2,y:i.y+i.height/2},r),t.scaleX=t.scaleY=l,t.transform=a}(f,o,s,n,r,l)}f.width=n,f.height=r,a&&(f.opacity=a)}function _t(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function gt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new E(t,e))}function pt(t,e,i,s){return new(i||(i=Promise))((function(n,r){function a(t){try{d(s.next(t))}catch(t){r(t)}}function o(t){try{d(s.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:yt,scale:wt,copy:mt}=L;function vt(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const r=s+"-"+n;if(e.patternId===r||t.destroyed)return!1;{e.patternId=r,s=Math.abs(s),n=Math.abs(n);const{image:t,data:a}=e,o=t.isSVG?4096:Math.min(t.width,4096),d=t.isSVG?4096:Math.min(t.height,4096);let h,l,{width:c,height:u,scaleX:f,scaleY:_,opacity:g,transform:y,mode:w}=a;f&&(l=yt(),mt(l,y),wt(l,1/f,1/_),s*=f,n*=_),s*=i,n*=i,c*=s,u*=n,(c>o||u>d)&&(h=Math.max(c/o,u/d)),h&&(s/=h,n/=h,c/=h,u/=h),f&&(s/=f,n/=_),(y||1!==s||1!==n)&&(l||(l=yt(),y&&mt(l,y)),wt(l,1/s,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,g),"repeat"===w?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function xt(t,e,i,s){const{scaleX:n,scaleY:r}=t.__world;if(i.data&&i.patternId!==n+"-"+r){if(s)if(i.image.isSVG&&"repeat"!==i.data.mode){let{width:t,height:a}=i.data;t*=n*e.pixelRatio,a*=r*e.pixelRatio,s=t>4096||a>4096}else s=!1;if(s){e.save(),e.clip();const{data:t}=i;return i.blendMode&&(e.blendMode=i.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(i.image.view,0,0,t.width,t.height),e.restore(),!0}return i.style?i.patternTask||(i.patternTask=g.patternTasker.add((()=>pt(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&vt(t,i,e.pixelRatio)&&t.forceUpdate("surface")}))),300)):vt(t,i,e.pixelRatio),!1}return!1}function bt(t,e){const i="fill"===t?e._fill:e._stroke;if(i instanceof Array){let s,n,r,a;for(let o=0,d=i.length;o<d;o++)s=i[o].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,g.recycle(s),s.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),s.unload(i[o].loadId,!r.some((t=>t.url===a)))));return n}return null}function Bt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,r)}function Rt(t,e,i,s){const{strokeAlign:n}=e.__,r="string"!=typeof t;switch(n){case"center":i.setStroke(r?void 0:t,e.__.strokeWidth,e.__),r?kt(t,!0,e,i):Et(e,i);break;case"inside":Lt("inside",t,r,e,i,s);break;case"outside":Lt("outside",t,r,e,i,s)}}function Lt(t,e,i,s,n,r){const{strokeWidth:a,__font:o}=s.__,d=n.getSameCanvas(!0);d.setStroke(i?void 0:e,2*a,s.__),d.font=o,i?kt(e,!0,s,d):Et(s,d),d.blendMode="outside"===t?"destination-out":"destination-in",Bt(s,d),d.blendMode="normal",s.__hasMirror||r.matrix?n.copyWorldByReset(d):n.copyWorldToInner(d,s.__world,s.__layout.renderBounds),d.recycle()}function Et(t,e){let i;const{rows:s,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,r)}function kt(t,e,i,s){let n;for(let r=0,a=t.length;r<a;r++)n=t[r],n.image&&xt(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Et(i,s):s.stroke(),s.restoreBlendMode()):e?Et(i,s):s.stroke())}const{getSpread:St,getOuterOf:At,getByMove:Ot,getIntersectData:Ct}=l;const Mt={x:.5,y:0},Tt={x:.5,y:1};function Wt(t,e,i){let s;for(let n=0,r=e.length;n<r;n++)s=e[n],t.addColorStop(s.offset,O.string(s.color,i))}const{set:It,getAngle:Dt,getDistance:Pt}=k,{get:Ft,rotateOfOuter:Nt,scaleOfOuter:Yt}=L,Ut={x:.5,y:.5},Ht={x:.5,y:1},Vt={},Gt={};const{set:jt,getAngle:qt,getDistance:Xt}=k,{get:zt,rotateOfOuter:Qt,scaleOfOuter:Zt}=L,Kt={x:.5,y:.5},$t={x:.5,y:1},Jt={},te={};let ee;function ie(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:r,color:a,opacity:o}=e;return{type:n,blendMode:r,style:O.string(a,o)};case"image":return function(t,e,i,s,n){const r={type:i.type},a=r.image=g.get(i),o=(n||a.loading)&&{target:t,image:a,attrName:e,attrValue:i};return a.ready?(_t(t,e,a)&&ft(r,a,i,s),n&&(gt(E.LOAD,o),gt(E.LOADED,o))):a.error?n&&(t.forceUpdate("surface"),o.error=a.error,gt(E.ERROR,o)):(n&>(E.LOAD,o),r.loadId=a.load((()=>{t.destroyed||(_t(t,e,a)&&(ft(r,a,i,s),t.forceUpdate("surface")),gt(E.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,gt(E.ERROR,o)}))),r}(i,t,e,s,!ee||!ee[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:r,opacity:a}=t;i||(i=Mt),s||(s=Tt);const o=p.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);Wt(o,t.stops,a);const d={type:n,style:o};return r&&(d.blendMode=r),d}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:r,blendMode:a,stretch:o}=t;i||(i=Ut),s||(s=Ht);const{x:d,y:h,width:l,height:c}=e;let u;It(Vt,d+i.x*l,h+i.y*c),It(Gt,d+s.x*l,h+s.y*c),(l!==c||o)&&(u=Ft(),Yt(u,Vt,l/c*(o||1),1),Nt(u,Vt,Dt(Vt,Gt)+90));const f=p.canvas.createRadialGradient(Vt.x,Vt.y,0,Vt.x,Vt.y,Pt(Vt,Gt));Wt(f,t.stops,r);const _={type:n,style:f,transform:u};return a&&(_.blendMode=a),_}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:r,blendMode:a,stretch:o}=t;i||(i=Kt),s||(s=$t);const{x:d,y:h,width:l,height:c}=e;jt(Jt,d+i.x*l,h+i.y*c),jt(te,d+s.x*l,h+s.y*c);const u=zt(),f=qt(Jt,te);p.conicGradientRotate90?(Zt(u,Jt,l/c*(o||1),1),Qt(u,Jt,f+90)):(Zt(u,Jt,1,l/c*(o||1)),Qt(u,Jt,f));const _=p.conicGradientSupport?p.canvas.createConicGradient(0,Jt.x,Jt.y):p.canvas.createRadialGradient(Jt.x,Jt.y,0,Jt.x,Jt.y,Xt(Jt,te));Wt(_,t.stops,r);const g={type:n,style:_,transform:u};return a&&(g.blendMode=a),g}(e,s);default:return e.r?{type:"solid",style:O.string(e)}:void 0}}var se=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,r,a=s.__input[t];a instanceof Array||(a=[a]),ee=bt(t,s);for(let s=0,r=a.length;s<r;s++)n=ie(t,a[s],e),n&&i.push(n);if(s["_"+t]=i.length?i:void 0,1===a.length){const t=a[0];"image"===t.type&&(r=C.isPixel(t))}"fill"===t?s.__pixelFill=r:s.__pixelStroke=r},drawTextStroke:Et,fill:function(t,e,i){i.fillStyle=t,e.__.__font?Bt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:Bt,fills:function(t,e,i){let s;const{windingRule:n,__font:r}=e.__;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&xt(e,i,s,!r)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),r?Bt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),r?Bt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):r?Bt(e,i):n?i.fill(n):i.fill())},recycleImage:bt,shape:function(t,e,i){const s=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,i.matrix))i.matrix?(h*=i.matrix.a,l*=i.matrix.d,n=a=At(d,i.matrix)):n=a=d,o=s;else{const{renderShapeSpread:s}=t.__layout,c=Ct(s?St(e.bounds,s*h,s*l):e.bounds,d,i.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,i),h*=r.a,l*=r.d),a=At(d,r),n=Ot(a,-r.e,-r.f),i.matrix&&r.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:r})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:h,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:r,strokeAlign:a,__font:o}=n;if(r)if(o)Rt(t,e,i,s);else switch(a){case"center":i.setStroke(t,r,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*r,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0);a.setStroke(t,2*r,e.__),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__hasMirror||s.matrix?i.copyWorldByReset(a):i.copyWorldToInner(a,e.__world,e.__layout.renderBounds),a.recycle()}},strokeText:Rt,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:r,strokeAlign:a,__font:o}=n;if(r)if(o)Rt(t,e,i,s);else switch(a){case"center":i.setStroke(void 0,r,n),kt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*r,n),n.windingRule?i.clip(n.windingRule):i.clip(),kt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0);e.__drawRenderPath(o),o.setStroke(void 0,2*r,e.__),kt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__hasMirror||s.matrix?i.copyWorldByReset(o):i.copyWorldToInner(o,e.__world,a),o.recycle()}}});const{copy:ne,toOffsetOutBounds:re}=l,ae={},oe={};function de(t,e,i,s){const{bounds:n,shapeBounds:r}=s;if(p.fullImageShadow){if(ne(ae,t.bounds),ae.x+=e.x-r.x,ae.y+=e.y-r.y,i){const{matrix:t}=s;ae.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),ae.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),ae.width*=i,ae.height*=i}t.copyWorld(s.canvas,t.bounds,ae)}else i&&(ne(ae,e),ae.x-=e.width/2*(i-1),ae.y-=e.height/2*(i-1),ae.width*=i,ae.height*=i),t.copyWorld(s.canvas,r,i?ae:e)}const{toOffsetOutBounds:he}=l,le={};var ce=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;he(l,le),d.forEach(((d,p)=>{_.save(),_.setWorldShadow(le.offsetX+d.x*u,le.offsetY+d.y*f,d.blur*u),r=d.spread?1-2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,de(_,le,r,i),_.restore(),h?(_.copyWorld(_,l,a,"copy"),_.copyWorld(h,a,a,"source-out"),n=a):(_.copyWorld(i.canvas,c,l,"source-out"),n=l),_.fillWorld(n,d.color,"source-in"),t.__hasMirror||s.matrix?e.copyWorldByReset(_,n,a,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()},shadow:function(t,e,i,s){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;re(l,oe),d.forEach(((d,p)=>{_.setWorldShadow(oe.offsetX+d.x*u,oe.offsetY+d.y*f,d.blur*u,d.color),r=d.spread?1+2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,de(_,oe,r,i),n=l,d.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,a,"copy"),n=a),h?_.copyWorld(h,a,a,"destination-out"):_.copyWorld(i.canvas,c,l,"destination-out")),t.__hasMirror||s.matrix?e.copyWorldByReset(_,n,a,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()}});const ue=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",fe=ue+"_#~&*+\\=|≮≯≈≠=…",_e=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ge(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const pe=ge("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ye=ge("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),we=ge(ue),me=ge(fe),ve=ge("- —/~|┆·");var xe;!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"}(xe||(xe={}));const{Letter:be,Single:Be,Before:Re,After:Le,Symbol:Ee,Break:ke}=xe;function Se(t){return pe[t]?be:ve[t]?ke:ye[t]?Re:we[t]?Le:me[t]?Ee:_e.test(t)?Be:be}const Ae={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let r=n-1;r>-1&&(i=e[r].data[0]," "===i.char);r--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Oe(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ce}=Ae,{Letter:Me,Single:Te,Before:We,After:Ie,Symbol:De,Break:Pe}=xe;let Fe,Ne,Ye,Ue,He,Ve,Ge,je,qe,Xe,ze,Qe,Ze,Ke,$e,Je,ti=[];function ei(t,e){qe&&!je&&(je=qe),Fe.data.push({char:t,width:e}),Ye+=e}function ii(){Ue+=Ye,Fe.width=Ye,Ne.words.push(Fe),Fe={data:[]},Ye=0}function si(){Ke&&($e.paraNumber++,Ne.paraStart=!0,Ke=!1),qe&&(Ne.startCharSize=je,Ne.endCharSize=qe,je=0),Ne.width=Ue,Je.width&&Ce(Ne),ti.push(Ne),Ne={words:[]},Ue=0}const ni={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,textOverflow:o,__font:d,padding:h}=e;if(h){const[t,e,a,o]=S.fourNumber(h);n&&(i=o,n-=e+o),r&&(s=t,r-=t+a)}const l={bounds:{x:i,y:s,width:n,height:r},rows:[],paraNumber:0,font:p.canvas.font=d};return function(t,e,i){$e=t,ti=t.rows,Je=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:r}=i,{canvas:a}=p,{width:o,height:d}=Je;if(o||d||s||"none"!==r){Ke=!0,ze=null,je=Ge=qe=Ye=Ue=0,Fe={data:[]},Ne={words:[]};for(let t=0,i=e.length;t<i;t++)Ve=e[t],"\n"===Ve?(Ye&&ii(),Ne.paraEnd=!0,si(),Ke=!0):(Xe=Se(Ve),Xe===Me&&"none"!==r&&(Ve=Oe(Ve,r,!Ye)),Ge=a.measureText(Ve).width,s&&(s<0&&(qe=Ge),Ge+=s),Qe=Xe===Te&&(ze===Te||ze===Me)||ze===Te&&Xe!==Ie,Ze=!(Xe!==We&&Xe!==Te||ze!==De&&ze!==Ie),He=Ke&&n?o-n:o,o&&Ue+Ye+Ge>He&&(Ze||(Ze=Xe===Me&&ze==Ie),Qe||Ze||Xe===Pe||Xe===We||Xe===Te||Ye+Ge>He?(Ye&&ii(),si()):si())," "===Ve&&!0!==Ke&&Ue+Ye===0||(Xe===Pe?(" "===Ve&&Ye&&ii(),ei(Ve,Ge),ii()):Qe||Ze?(Ye&&ii(),ei(Ve,Ge)):ei(Ve,Ge)),ze=Xe);Ye&&ii(),Ue&&si(),ti.length>0&&(ti[ti.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{$e.paraNumber++,ti.push({x:n||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(l,t,e),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:r,__letterSpacing:a,textAlign:o,verticalAlign:d,paraSpacing:h,textOverflow:l}=e;let c,u,f,{x:_,y:g,width:p,height:y}=s,w=n*i.length+(h?h*(t.paraNumber-1):0),m=r;if("show"!==l&&w>y)w=Math.max(y,n),t.overflow=i.length;else switch(d){case"middle":g+=(y-w)/2;break;case"bottom":g+=y-w}m+=g;for(let r=0,d=i.length;r<d;r++){switch(c=i[r],c.x=_,o){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&h&&r>0&&(m+=h),c.y=m,m+=n,t.overflow>r&&m>w&&(c.isOverflow=!0,t.overflow=r+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<s.x&&(s.x=u),f>s.width&&(s.width=f)}s.y=g,s.height=w}(l,e),function(t,e,i,s){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,h=i&&"justify"===r&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,2===c?(t.text="",t.x+=l,t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(l,e,n),l.overflow&&function(t,e){const{rows:i,overflow:s}=t;if(i.splice(s),"hide"!==e){"ellipsis"===e&&(e="...");const n=p.canvas.measureText(e).width,r=i[s-1];let a,o,d=r.data.length-1;const{x:h,width:l}=t.bounds,c=h+l-n;for(let t=d;t>-1&&(a=r.data[t],o=a.x+a.width,!(t===d&&o<c));t--){if(o<c&&" "!==a.char){r.data.splice(t+1),r.width-=a.width;break}r.width-=a.width}r.width+=n,r.data.push({char:e,x:o})}}(l,o),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(l,e),l}},ri={string(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},ai={export(t,e,i){return function(t){oi||(oi=new A);return new Promise((e=>{oi.add((()=>pt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:r}=t;r?r.waitViewCompleted((()=>pt(this,void 0,void 0,(function*(){let t,a,o,{canvas:d}=r,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(a=!0);break;case"number":t=i;break;case"boolean":a=i}o=e.includes(".")?yield d.saveAs(e,t):a?yield d.toBlob(e,t):yield d.toDataURL(e,t),s({data:o}),n(),h&&d.recycle()})))):(s({data:!1}),n())}))))}};let oi;Object.assign(M,se),Object.assign(T,ce),Object.assign(W,ni),Object.assign(O,ri),Object.assign(I,ai),st();export{Q as Layouter,et as LeaferCanvas,K as Renderer,tt as Selector,D as Watcher,st as useCanvas};
|
|
1
|
+
import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as r,LeafHelper as a,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,BoundsHelper as l,Debug as c,LeafLevelList as u,LayoutEvent as f,Run as _,ImageManager as g,Platform as p,AnimateEvent as y,ResizeEvent as w,Creator as m,LeaferCanvasBase as v,canvasPatch as x,LeaferImage as B,InteractionBase as b,FileHelper as R,MatrixHelper as E,ImageEvent as L,PointHelper as k,MathHelper as M,TaskProcessor as S}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as A,ImageManager as C,Paint as O,Effect as T,TextConvert as I,Export as W}from"@leafer-ui/core";export*from"@leafer-ui/core";class D{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.push(t)})),e}return this.__updatedList}constructor(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,s&&(this.config=e.default(s,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(i.REQUEST)}__onAttrChange(t){this.__updatedList.push(t.target),this.update()}__onChildEvent(t){t.type===s.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.push(t.parent)),this.update()}__pushChild(t){this.__updatedList.push(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(r.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllWorldMatrix:P,updateAllWorldOpacity:F}=a,{pushAllChildBranch:N,pushAllParent:Y}=o;const{worldBounds:H}=h,{setByListWithHandle:U}=l;class V{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){U(this.beforeBounds,this.updatedList.list,H)}setAfter(){U(this.afterBounds,this.updatedList.list,H),this.updatedBounds.setByList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.pushList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllWorldMatrix:G,updateAllChange:j}=a,{pushAllBranchStack:q,updateWorldBoundsByBranchStack:X}=o,z=c.get("Layouter");class Q{constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new u,this.target=t,i&&(this.config=e.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(f.START),this.layoutOnce(),t.emitEvent(new f(f.END,this.layoutedBlocks,this.times))}catch(t){z.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?z.warn("layouting"):this.times>3?z.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=_.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:r,AFTER:a}=f,o=this.getBlocks(s);o.forEach((t=>{t.setBefore()})),i.emitEvent(new f(n,o,this.times)),s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(P(t),e.push(t),t.isBranch&&N(t,e),Y(t,e)):i.boundsChanged&&(e.push(t),t.isBranch&&(t.__tempNumber=0),Y(t,e)))}))}(s,this.__levelList),function(t){let e,i;t.sort(!0),t.levels.forEach((s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber)for(let t=0,e=i.children.length;t<e;t++)i.children[t].isBranch||i.children[t].__updateWorldBounds();i.__updateWorldBounds()}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&F(t),t.__updateChange()}))}(s),o.forEach((t=>t.setAfter())),i.emitEvent(new f(r,o,this.times)),i.emitEvent(new f(a,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,_.end(e)}fullLayout(){const e=_.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:r}=f,a=this.getBlocks(new t(i));i.emitEvent(new f(s,a,this.times)),Q.fullLayout(i),a.forEach((t=>{t.setAfter()})),i.emitEvent(new f(n,a,this.times)),i.emitEvent(new f(r,a,this.times)),this.addBlocks(a),_.end(e)}static fullLayout(t){if(G(t),t.isBranch){const e=[t];q(t,e),X(e)}else t.__updateWorldBounds();j(t)}createBlock(t){return new V(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(f.REQUEST,this.layout,this),t.on_(f.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.config=null)}}const Z=c.get("Renderer");class K{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(f.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,Z.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),g.clearRecycled()}catch(t){this.rendering=!1,Z.error(t)}Z.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Z.warn("rendering"):this.times>3?Z.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Z.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=_.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),r=(new d).copy(s);i.save(),n&&!c.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,r),i.restore(),_.end(e)}fullRender(){const t=_.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),_.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),c.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),c.showHitView&&this.renderHitView(s),c.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new d;e.setByList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();p.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(y.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new d(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__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||Z.warn(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(f.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(w.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}const{hitRadiusPoint:$}=l;class J{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const r=this.findList,a=this.getBestMatchLeaf(),o=n?this.getPath(a):this.getHitablePath(a);return this.clear(),s?{path:o,leaf:a,throughPath:r.length?this.getThroughPath(r):o}:{path:o,leaf:a}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],a.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.push(e),e=e.parent;return i.push(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.unshift(s),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,r,a;for(let t=0,e=s.length;t<e;t++){n=s[t],r=s[t+1];for(let t=0,e=n.length;t<e&&(a=n.list[t],!r||!r.has(a));t++)i.push(a)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let r=t.length-1;r>-1;r--)i=t[r],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||$(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class tt{constructor(t,i){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?this.idMap[e]=t:0,innerId:(t,e)=>t.innerId===e?this.innerIdMap[e]=t:0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=t,i&&(this.config=e.default(i,this.config)),this.pather=new J(t,this),this.__listenEvents()}getByPoint(t,e,i){return"node"===p.name&&this.target.emit(f.CHECK_UPDATE),this.pather.getByPoint(t,e,i)}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&a.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n;for(let r=0,a=t.length;r<a;r++){if(n=t[r],e(n,s)){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(s.REMOVE,this.__onRemoveChild,this),this.target.on_(r.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.pather.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(m,{watcher:(t,e)=>new D(t,e),layouter:(t,e)=>new Q(t,e),renderer:(t,e,i)=>new K(t,e,i),selector:(t,e)=>new tt(t,e)}),p.layout=Q.fullLayout;class et extends v{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=p.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=t*i,this.view.height=e*i,this.clientBounds=this.bounds}}x(OffscreenCanvasRenderingContext2D.prototype),x(Path2D.prototype);const{mineType:it}=R;function st(t,e){p.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:it(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:it(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),loadImage:t=>new Promise(((e,i)=>{!t.startsWith("data:")&&p.imageSuffix&&(t+=(t.includes("?")?"&":"?")+p.imageSuffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{e(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},p.canvas=m.canvas(),p.conicGradientSupport=!!p.canvas.context.createConicGradient}Object.assign(m,{canvas:(t,e)=>new et(t,e),image:t=>new B(t),hitCanvas:(t,e)=>new et(t,e),interaction:(t,e,i,s)=>new b(t,e,i,s)}),p.name="web",p.isWorker=!0,p.requestRender=function(t){requestAnimationFrame(t)},p.devicePixelRatio=1,p.realtimeLayout=!0;const{userAgent:nt}=navigator;nt.indexOf("Firefox")>-1?(p.conicGradientRotate90=!0,p.intWheelDeltaY=!0):nt.indexOf("Safari")>-1&&-1===nt.indexOf("Chrome")&&(p.fullImageShadow=!0),nt.indexOf("Windows")>-1?(p.os="Windows",p.intWheelDeltaY=!0):nt.indexOf("Mac")>-1?p.os="Mac":nt.indexOf("Linux")>-1&&(p.os="Linux");const{get:rt,rotateOfOuter:at,translate:ot,scaleOfOuter:dt,scale:ht,rotate:lt}=E;const{get:ct,translate:ut}=E;function ft(t,e,i,s){let{width:n,height:r}=e;const{opacity:a,mode:o,offset:d,scale:h,rotation:l,blendMode:c}=i,u=s.width===n&&s.height===r;c&&(t.blendMode=c);const f=t.data={mode:o};switch(o){case"strench":u||(n=s.width,r=s.height),(s.x||s.y)&&(f.transform=ct(),ut(f.transform,s.x,s.y));break;case"clip":(d||h||l)&&function(t,e,i,s,n){const r=rt();ot(r,e.x,e.y),i&&ot(r,i.x,i.y),s&&("number"==typeof s?ht(r,s):ht(r,s.x,s.y),t.scaleX=r.a,t.scaleY=r.d),n&<(r,n),t.transform=r}(f,s,d,h,l);break;case"repeat":(!u||h||l)&&function(t,e,i,s,n,r){const a=rt();if(r)switch(lt(a,r),r){case 90:ot(a,s,0);break;case 180:ot(a,i,s);break;case 270:ot(a,0,i)}ot(a,e.x,e.y),n&&(dt(a,e,n),t.scaleX=t.scaleY=n),t.transform=a}(f,s,n,r,h,l);break;default:u&&!l||function(t,e,i,s,n,r){const a=rt(),o=r&&180!==r,d=i.width/(o?n:s),h=i.height/(o?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;ot(a,c,u),ht(a,l),r&&at(a,{x:i.x+i.width/2,y:i.y+i.height/2},r),t.scaleX=t.scaleY=l,t.transform=a}(f,o,s,n,r,l)}f.width=n,f.height=r,a&&(f.opacity=a)}function _t(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),!1}return!0}function gt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new L(t,e))}function pt(t,e,i,s){return new(i||(i=Promise))((function(n,r){function a(t){try{d(s.next(t))}catch(t){r(t)}}function o(t){try{d(s.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{get:yt,scale:wt,copy:mt}=E;function vt(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const r=s+"-"+n;if(e.patternId===r||t.destroyed)return!1;{e.patternId=r,s=Math.abs(s),n=Math.abs(n);const{image:t,data:a}=e,o=t.isSVG?4096:Math.min(t.width,4096),d=t.isSVG?4096:Math.min(t.height,4096);let h,l,{width:c,height:u,scaleX:f,scaleY:_,opacity:g,transform:y,mode:w}=a;f&&(l=yt(),mt(l,y),wt(l,1/f,1/_),s*=f,n*=_),s*=i,n*=i,c*=s,u*=n,(c>o||u>d)&&(h=Math.max(c/o,u/d)),h&&(s/=h,n/=h,c/=h,u/=h),f&&(s/=f,n/=_),(y||1!==s||1!==n)&&(l||(l=yt(),y&&mt(l,y)),wt(l,1/s,1/n));const m=p.canvas.createPattern(t.getCanvas(c<1?1:c,u<1?1:u,g),"repeat"===w?"repeat":p.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),l&&(m.setTransform?m.setTransform(l):e.transform=l)}catch(t){e.transform=l}return e.style=m,!0}}function xt(t,e,i,s){const{scaleX:n,scaleY:r}=t.__world;if(i.data&&i.patternId!==n+"-"+r){if(s)if(i.image.isSVG&&"repeat"!==i.data.mode){let{width:t,height:a}=i.data;t*=n*e.pixelRatio,a*=r*e.pixelRatio,s=t>4096||a>4096}else s=!1;if(s){e.save(),e.clip();const{data:t}=i;return i.blendMode&&(e.blendMode=i.blendMode),t.opacity&&(e.opacity*=t.opacity),t.transform&&e.transform(t.transform),e.drawImage(i.image.view,0,0,t.width,t.height),e.restore(),!0}return i.style?i.patternTask||(i.patternTask=g.patternTasker.add((()=>pt(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&vt(t,i,e.pixelRatio),t.forceUpdate("surface")}))),300)):vt(t,i,e.pixelRatio),!1}return!1}function Bt(t,e){const i="fill"===t?e._fill:e._stroke;if(i instanceof Array){let s,n,r,a;for(let o=0,d=i.length;o<d;o++)s=i[o].image,a=s&&s.url,a&&(n||(n={}),n[a]=!0,g.recycle(s),s.loading&&(r||(r=e.__input&&e.__input[t]||[],r instanceof Array||(r=[r])),s.unload(i[o].loadId,!r.some((t=>t.url===a)))));return n}return null}function bt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,r)}function Rt(t,e,i,s){const{strokeAlign:n}=e.__,r="string"!=typeof t;switch(n){case"center":i.setStroke(r?void 0:t,e.__.strokeWidth,e.__),r?kt(t,!0,e,i):Lt(e,i);break;case"inside":Et("inside",t,r,e,i,s);break;case"outside":Et("outside",t,r,e,i,s)}}function Et(t,e,i,s,n,r){const{strokeWidth:a,__font:o}=s.__,d=n.getSameCanvas(!0);d.setStroke(i?void 0:e,2*a,s.__),d.font=o,i?kt(e,!0,s,d):Lt(s,d),d.blendMode="outside"===t?"destination-out":"destination-in",bt(s,d),d.blendMode="normal",s.__hasMirror||r.matrix?n.copyWorldByReset(d):n.copyWorldToInner(d,s.__world,s.__layout.renderBounds),d.recycle()}function Lt(t,e){let i;const{rows:s,decorationY:n,decorationHeight:r}=t.__.__textDrawData;for(let t=0,a=s.length;t<a;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,r)}function kt(t,e,i,s){let n;for(let r=0,a=t.length;r<a;r++)n=t[r],n.image&&xt(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Lt(i,s):s.stroke(),s.restoreBlendMode()):e?Lt(i,s):s.stroke())}const{getSpread:Mt,getOuterOf:St,getByMove:At,getIntersectData:Ct}=l;const Ot={x:.5,y:0},Tt={x:.5,y:1};function It(t,e,i){let s;for(let n=0,r=e.length;n<r;n++)s=e[n],t.addColorStop(s.offset,A.string(s.color,i))}const{set:Wt,getAngle:Dt,getDistance:Pt}=k,{get:Ft,rotateOfOuter:Nt,scaleOfOuter:Yt}=E,Ht={x:.5,y:.5},Ut={x:.5,y:1},Vt={},Gt={};const{set:jt,getAngle:qt,getDistance:Xt}=k,{get:zt,rotateOfOuter:Qt,scaleOfOuter:Zt}=E,Kt={x:.5,y:.5},$t={x:.5,y:1},Jt={},te={};let ee;function ie(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:r,color:a,opacity:o}=e;return{type:n,blendMode:r,style:A.string(a,o)};case"image":return function(t,e,i,s,n){const r={type:i.type},a=r.image=g.get(i),o=(n||a.loading)&&{target:t,image:a,attrName:e,attrValue:i};return a.ready?(_t(t,e,a)&&ft(r,a,i,s),n&&(gt(L.LOAD,o),gt(L.LOADED,o))):a.error?n&&(t.forceUpdate("surface"),o.error=a.error,gt(L.ERROR,o)):(n&>(L.LOAD,o),r.loadId=a.load((()=>{t.destroyed||(_t(t,e,a)&&(ft(r,a,i,s),t.forceUpdate("surface")),gt(L.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,gt(L.ERROR,o)}))),r}(i,t,e,s,!ee||!ee[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:r,opacity:a}=t;i||(i=Ot),s||(s=Tt);const o=p.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);It(o,t.stops,a);const d={type:n,style:o};return r&&(d.blendMode=r),d}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:r,blendMode:a,stretch:o}=t;i||(i=Ht),s||(s=Ut);const{x:d,y:h,width:l,height:c}=e;let u;Wt(Vt,d+i.x*l,h+i.y*c),Wt(Gt,d+s.x*l,h+s.y*c),(l!==c||o)&&(u=Ft(),Yt(u,Vt,l/c*(o||1),1),Nt(u,Vt,Dt(Vt,Gt)+90));const f=p.canvas.createRadialGradient(Vt.x,Vt.y,0,Vt.x,Vt.y,Pt(Vt,Gt));It(f,t.stops,r);const _={type:n,style:f,transform:u};return a&&(_.blendMode=a),_}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:r,blendMode:a,stretch:o}=t;i||(i=Kt),s||(s=$t);const{x:d,y:h,width:l,height:c}=e;jt(Jt,d+i.x*l,h+i.y*c),jt(te,d+s.x*l,h+s.y*c);const u=zt(),f=qt(Jt,te);p.conicGradientRotate90?(Zt(u,Jt,l/c*(o||1),1),Qt(u,Jt,f+90)):(Zt(u,Jt,1,l/c*(o||1)),Qt(u,Jt,f));const _=p.conicGradientSupport?p.canvas.createConicGradient(0,Jt.x,Jt.y):p.canvas.createRadialGradient(Jt.x,Jt.y,0,Jt.x,Jt.y,Xt(Jt,te));It(_,t.stops,r);const g={type:n,style:_,transform:u};return a&&(g.blendMode=a),g}(e,s);default:return e.r?{type:"solid",style:A.string(e)}:void 0}}var se=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,r,a=s.__input[t];a instanceof Array||(a=[a]),ee=Bt(t,s);for(let s=0,r=a.length;s<r;s++)n=ie(t,a[s],e),n&&i.push(n);if(s["_"+t]=i.length?i:void 0,1===a.length){const t=a[0];"image"===t.type&&(r=C.isPixel(t))}"fill"===t?s.__pixelFill=r:s.__pixelStroke=r},drawTextStroke:Lt,fill:function(t,e,i){i.fillStyle=t,e.__.__font?bt(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:bt,fills:function(t,e,i){let s;const{windingRule:n,__font:r}=e.__;for(let a=0,o=t.length;a<o;a++)s=t[a],s.image&&xt(e,i,s,!r)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),r?bt(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),r?bt(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):r?bt(e,i):n?i.fill(n):i.fill())},recycleImage:Bt,shape:function(t,e,i){const s=e.getSameCanvas();let n,r,a,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,i.matrix))i.matrix?(h*=i.matrix.a,l*=i.matrix.d,n=a=St(d,i.matrix)):n=a=d,o=s;else{const{renderShapeSpread:s}=t.__layout,c=Ct(s?Mt(e.bounds,s*h,s*l):e.bounds,d,i.matrix);r=e.bounds.getFitMatrix(c),r.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,i),h*=r.a,l*=r.d),a=St(d,r),n=At(a,-r.e,-r.f),i.matrix&&r.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:r})}return t.__renderShape(s,i),{canvas:s,matrix:r,bounds:n,worldCanvas:o,shapeBounds:a,scaleX:h,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:r,strokeAlign:a,__font:o}=n;if(r)if(o)Rt(t,e,i,s);else switch(a){case"center":i.setStroke(t,r,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*r,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const a=i.getSameCanvas(!0);a.setStroke(t,2*r,e.__),e.__drawRenderPath(a),a.stroke(),n.windingRule?a.clip(n.windingRule):a.clip(),a.clearWorld(e.__layout.renderBounds),e.__hasMirror||s.matrix?i.copyWorldByReset(a):i.copyWorldToInner(a,e.__world,e.__layout.renderBounds),a.recycle()}},strokeText:Rt,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:r,strokeAlign:a,__font:o}=n;if(r)if(o)Rt(t,e,i,s);else switch(a){case"center":i.setStroke(void 0,r,n),kt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*r,n),n.windingRule?i.clip(n.windingRule):i.clip(),kt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:a}=e.__layout,o=i.getSameCanvas(!0);e.__drawRenderPath(o),o.setStroke(void 0,2*r,e.__),kt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(a),e.__hasMirror||s.matrix?i.copyWorldByReset(o):i.copyWorldToInner(o,e.__world,a),o.recycle()}}});const{copy:ne,toOffsetOutBounds:re}=l,ae={},oe={};function de(t,e,i,s){const{bounds:n,shapeBounds:r}=s;if(p.fullImageShadow){if(ne(ae,t.bounds),ae.x+=e.x-r.x,ae.y+=e.y-r.y,i){const{matrix:t}=s;ae.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),ae.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),ae.width*=i,ae.height*=i}t.copyWorld(s.canvas,t.bounds,ae)}else i&&(ne(ae,e),ae.x-=e.width/2*(i-1),ae.y-=e.height/2*(i-1),ae.width*=i,ae.height*=i),t.copyWorld(s.canvas,r,i?ae:e)}const{toOffsetOutBounds:he}=l,le={};var ce=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,r;const{__world:a,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;he(l,le),d.forEach(((d,p)=>{_.save(),_.setWorldShadow(le.offsetX+d.x*u,le.offsetY+d.y*f,d.blur*u),r=d.spread?1-2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,de(_,le,r,i),_.restore(),h?(_.copyWorld(_,l,a,"copy"),_.copyWorld(h,a,a,"source-out"),n=a):(_.copyWorld(i.canvas,c,l,"source-out"),n=l),_.fillWorld(n,d.color,"source-in"),t.__hasMirror||s.matrix?e.copyWorldByReset(_,n,a,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()},shadow:function(t,e,i,s){let n,r;const{__world:a,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;re(l,oe),d.forEach(((d,p)=>{_.setWorldShadow(oe.offsetX+d.x*u,oe.offsetY+d.y*f,d.blur*u,d.color),r=d.spread?1+2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,de(_,oe,r,i),n=l,d.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,a,"copy"),n=a),h?_.copyWorld(h,a,a,"destination-out"):_.copyWorld(i.canvas,c,l,"destination-out")),t.__hasMirror||s.matrix?e.copyWorldByReset(_,n,a,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()}});const ue=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",fe=ue+"_#~&*+\\=|≮≯≈≠=…",_e=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ge(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const pe=ge("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ye=ge("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),we=ge(ue),me=ge(fe),ve=ge("- —/~|┆·");var xe;!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"}(xe||(xe={}));const{Letter:Be,Single:be,Before:Re,After:Ee,Symbol:Le,Break:ke}=xe;function Me(t){return pe[t]?Be:ve[t]?ke:ye[t]?Re:we[t]?Ee:me[t]?Le:_e.test(t)?be:Be}const Se={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let r=n-1;r>-1&&(i=e[r].data[0]," "===i.char);r--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Ae(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Ce}=Se,{Letter:Oe,Single:Te,Before:Ie,After:We,Symbol:De,Break:Pe}=xe;let Fe,Ne,Ye,He,Ue,Ve,Ge,je,qe,Xe,ze,Qe,Ze,Ke,$e,Je,ti=[];function ei(t,e){qe&&!je&&(je=qe),Fe.data.push({char:t,width:e}),Ye+=e}function ii(){He+=Ye,Fe.width=Ye,Ne.words.push(Fe),Fe={data:[]},Ye=0}function si(){Ke&&($e.paraNumber++,Ne.paraStart=!0,Ke=!1),qe&&(Ne.startCharSize=je,Ne.endCharSize=qe,je=0),Ne.width=He,Je.width&&Ce(Ne),ti.push(Ne),Ne={words:[]},He=0}const ni={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,r=e.__getInput("height")||0;const{textDecoration:a,__font:o,padding:d}=e;if(d){const[t,e,a,o]=M.fourNumber(d);n&&(i=o,n-=e+o),r&&(s=t,r-=t+a)}const h={bounds:{x:i,y:s,width:n,height:r},rows:[],paraNumber:0,font:p.canvas.font=o};return function(t,e,i){$e=t,ti=t.rows,Je=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:r}=i,{canvas:a}=p,{width:o,height:d}=Je;if(o||d||s||"none"!==r){const t="none"!==i.textWrap,d="break"===i.textWrap;Ke=!0,ze=null,je=Ge=qe=Ye=He=0,Fe={data:[]},Ne={words:[]};for(let i=0,h=e.length;i<h;i++)Ve=e[i],"\n"===Ve?(Ye&&ii(),Ne.paraEnd=!0,si(),Ke=!0):(Xe=Me(Ve),Xe===Oe&&"none"!==r&&(Ve=Ae(Ve,r,!Ye)),Ge=a.measureText(Ve).width,s&&(s<0&&(qe=Ge),Ge+=s),Qe=Xe===Te&&(ze===Te||ze===Oe)||ze===Te&&Xe!==We,Ze=!(Xe!==Ie&&Xe!==Te||ze!==De&&ze!==We),Ue=Ke&&n?o-n:o,t&&o&&He+Ye+Ge>Ue&&(d?(Ye&&ii(),si()):(Ze||(Ze=Xe===Oe&&ze==We),Qe||Ze||Xe===Pe||Xe===Ie||Xe===Te||Ye+Ge>Ue?(Ye&&ii(),si()):si()))," "===Ve&&!0!==Ke&&He+Ye===0||(Xe===Pe?(" "===Ve&&Ye&&ii(),ei(Ve,Ge),ii()):Qe||Ze?(Ye&&ii(),ei(Ve,Ge)):ei(Ve,Ge)),ze=Xe);Ye&&ii(),He&&si(),ti.length>0&&(ti[ti.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{$e.paraNumber++,ti.push({x:n||0,text:t,width:a.measureText(t).width,paraStart:!0})}))}(h,t,e),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:r,__letterSpacing:a,__clipText:o,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:_,y:g,width:p,height:y}=s,w=n*i.length+(l?l*(t.paraNumber-1):0),m=r;if(o&&w>y)w=Math.max(y,n),t.overflow=i.length;else switch(h){case"middle":g+=(y-w)/2;break;case"bottom":g+=y-w}m+=g;for(let r=0,h=i.length;r<h;r++){switch(c=i[r],c.x=_,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&r>0&&(m+=l),c.y=m,m+=n,t.overflow>r&&m>w&&(c.isOverflow=!0,t.overflow=r+1),u=c.x,f=c.width,a<0&&(c.width<0?(f=-c.width+e.fontSize+a,u-=f,f+=e.fontSize):f-=a),u<s.x&&(s.x=u),f>s.width&&(s.width=f),o&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(h,e),function(t,e,i,s){const{rows:n}=t,{textAlign:r,paraIndent:a,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=a&&t.paraStart?a:0,h=i&&"justify"===r&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(h,e,n),h.overflow&&function(t,e){const{rows:i,overflow:s}=t;let{textOverflow:n}=e;if(i.splice(s),"hide"!==n){let t,r;"ellipsis"===n&&(n="...");const a=p.canvas.measureText(n).width,o=e.x+e.width-a;("none"===e.textWrap?i:[i[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],r=t.x+t.width,!(s===i&&r<o));s--){if(r<o&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=a,e.data.push({char:n,x:r}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,e),"none"!==a&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(h,e),h}},ri={string(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},ai={export(t,e,i){return function(t){oi||(oi=new S);return new Promise((e=>{oi.add((()=>pt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:r}=t;r?r.waitViewCompleted((()=>pt(this,void 0,void 0,(function*(){let t,a,o,{canvas:d}=r,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=r.config.fill,r.__render(d,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(a=!0);break;case"number":t=i;break;case"boolean":a=i}o=e.includes(".")?yield d.saveAs(e,t):a?yield d.toBlob(e,t):yield d.toDataURL(e,t),s({data:o}),n(),h&&d.recycle()})))):(s({data:!1}),n())}))))}};let oi;Object.assign(O,se),Object.assign(T,ce),Object.assign(I,ni),Object.assign(A,ri),Object.assign(W,ai),st();export{Q as Layouter,et as LeaferCanvas,K as Renderer,tt as Selector,D as Watcher,st as useCanvas};
|