@leafer-draw/worker 2.2.9 → 2.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.cjs CHANGED
@@ -771,7 +771,7 @@ function fills(fills, ui, canvas, renderOptions) {
771
771
  if (scaleX !== 1) canvas.scale(scaleX, scaleY);
772
772
  }
773
773
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
774
- fillPathOrText(ui, canvas, renderOptions);
774
+ fillPathOrText(ui, canvas, renderOptions, true);
775
775
  canvas.restore();
776
776
  } else {
777
777
  if (originPaint.blendMode) {
@@ -783,25 +783,46 @@ function fills(fills, ui, canvas, renderOptions) {
783
783
  }
784
784
  }
785
785
 
786
- function fillPathOrText(ui, canvas, renderOptions) {
787
- ui.__.__font ? draw.Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
786
+ function fillPathOrText(ui, canvas, renderOptions, complexPaint) {
787
+ ui.__.__font ? draw.Paint.fillText(ui, canvas, renderOptions, complexPaint) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
788
788
  }
789
789
 
790
- function fillText(ui, canvas, renderOptions) {
791
- if (ui.motionText) return draw.Paint.fillMotionText(ui, canvas, renderOptions);
792
- const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
790
+ function fillText(ui, canvas, renderOptions, complexPaint) {
791
+ const data = ui.__;
793
792
  if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
794
- let row;
795
- for (let i = 0, len = rows.length; i < len; i++) {
796
- row = rows[i];
797
- if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
798
- canvas.fillText(charData.char, charData.x, row.y);
799
- });
793
+ let originCanvas;
794
+ if (complexPaint) {
795
+ originCanvas = canvas;
796
+ canvas = canvas.getSameCanvas(true, true);
797
+ canvas.font = ui.__.__font;
798
+ canvas.fillStyle = "#000";
799
+ }
800
+ if (ui.motionText) {
801
+ draw.Paint.fillMotionText(ui, canvas, renderOptions);
802
+ } else {
803
+ let row;
804
+ const {rows: rows, decorationY: decorationY} = data.__textDrawData;
805
+ for (let i = 0, len = rows.length; i < len; i++) {
806
+ row = rows[i];
807
+ if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
808
+ canvas.fillText(charData.char, charData.x, row.y);
809
+ });
810
+ }
811
+ if (decorationY) {
812
+ const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
813
+ if (decorationColor) canvas.fillStyle = decorationColor;
814
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
815
+ }
800
816
  }
801
- if (decorationY) {
802
- const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
803
- if (decorationColor) canvas.fillStyle = decorationColor;
804
- rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
817
+ if (complexPaint) {
818
+ canvas.beginPath();
819
+ ui.__drawPathByBox(canvas, "render");
820
+ canvas.fillStyle = originCanvas.fillStyle;
821
+ canvas.setTransform(originCanvas.getTransform());
822
+ canvas.blendMode = "source-in";
823
+ canvas.fill();
824
+ originCanvas.copyWorldByReset(canvas, ui.__nowWorld);
825
+ canvas.recycle(ui.__nowWorld);
805
826
  }
806
827
  }
807
828
 
@@ -1921,9 +1942,9 @@ const symbolChar = afterChar + "_#~&*+\\=|" + langSymbol;
1921
1942
 
1922
1943
  const breakChar = "- " + langBreak$1;
1923
1944
 
1924
- const cjkRangeList = [ [ 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 ] ];
1945
+ const cjkRangeList = [ [ 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 ], [ 4352, 4607 ], [ 12352, 12447 ], [ 12448, 12543 ], [ 12544, 12591 ], [ 12592, 12687 ], [ 12688, 12703 ], [ 12704, 12735 ], [ 12784, 12799 ], [ 12736, 12783 ], [ 12800, 13055 ], [ 13056, 13311 ], [ 63744, 64255 ], [ 65072, 65103 ], [ 127488, 127743 ], [ 194560, 195103 ] ];
1925
1946
 
1926
- const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u${start.toString(16)}-\\u${end.toString(16)}]`).join("|"));
1947
+ const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u{${start.toString(16)}}-\\u{${end.toString(16)}}]`).join("|"), "u");
1927
1948
 
1928
1949
  function mapChar(str) {
1929
1950
  const map = {};
@@ -2020,11 +2041,13 @@ function createRows(drawData, content, style) {
2020
2041
  rows = drawData.rows;
2021
2042
  bounds = drawData.bounds;
2022
2043
  findMaxWidth = !bounds.width && !style.autoSizeAlign;
2023
- const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
2044
+ const {paraIndent: paraIndent, textCase: textCase} = style;
2024
2045
  const {canvas: canvas} = core.Platform, {width: width} = bounds;
2025
2046
  if (style.__isCharMode) {
2026
2047
  const wrap = style.textWrap !== "none";
2027
2048
  const breakAll = style.textWrap === "break";
2049
+ const letterSpacing = style.__letterSpacing;
2050
+ const wordSpacing = style.__wordSpacing;
2028
2051
  paraStart = true;
2029
2052
  lastCharType = null;
2030
2053
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
@@ -2045,9 +2068,9 @@ function createRows(drawData, content, style) {
2045
2068
  charType = getCharType(char);
2046
2069
  if (charType === Letter && textCase !== "none") char = getTextCase(char, textCase, !wordWidth);
2047
2070
  charWidth = canvas.measureText(char).width;
2048
- if (__letterSpacing) {
2049
- if (__letterSpacing < 0) charSize = charWidth;
2050
- charWidth += __letterSpacing;
2071
+ if (letterSpacing) {
2072
+ if (letterSpacing < 0) charSize = charWidth;
2073
+ charWidth += letterSpacing;
2051
2074
  }
2052
2075
  langBreak = charType === Single && (lastCharType === Single || lastCharType === Letter) || lastCharType === Single && charType !== After;
2053
2076
  afterBreak = (charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After);
@@ -2068,11 +2091,11 @@ function createRows(drawData, content, style) {
2068
2091
  }
2069
2092
  if (char === " " && paraStart !== true && rowWidth + wordWidth === 0) ; else {
2070
2093
  if (charType === Break) {
2071
- if (char === " " && wordWidth) addWord();
2094
+ if (char === " " && wordWidth) addWord(wordSpacing);
2072
2095
  addChar(char, charWidth);
2073
2096
  addWord();
2074
2097
  } else if (langBreak || afterBreak) {
2075
- if (wordWidth) addWord();
2098
+ if (wordWidth) addWord(wordSpacing);
2076
2099
  addChar(char, charWidth);
2077
2100
  } else {
2078
2101
  addChar(char, charWidth);
@@ -2108,7 +2131,11 @@ function addChar(char, width) {
2108
2131
  wordWidth += width;
2109
2132
  }
2110
2133
 
2111
- function addWord() {
2134
+ function addWord(wordSpacing) {
2135
+ if (wordSpacing) {
2136
+ rowWidth += wordSpacing;
2137
+ word.addWidth = wordSpacing;
2138
+ }
2112
2139
  rowWidth += wordWidth;
2113
2140
  word.width = wordWidth;
2114
2141
  row.words.push(word);
@@ -2152,6 +2179,7 @@ function layoutChar(drawData, style, width, _height) {
2152
2179
  const {rows: rows} = drawData;
2153
2180
  const {textAlign: textAlign, paraIndent: paraIndent} = style;
2154
2181
  const useLetter = style.__letterSpacing || style.motionText;
2182
+ const wordSpacing = style.__wordSpacing;
2155
2183
  const justifyLast = width && textAlign.includes("both");
2156
2184
  const justify = justifyLast || width && textAlign.includes("justify");
2157
2185
  const justifyLetter = justify && textAlign.includes("letter");
@@ -2164,7 +2192,7 @@ function layoutChar(drawData, style, width, _height) {
2164
2192
  remainingWidth = width - row.width - indentWidth;
2165
2193
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
2166
2194
  }
2167
- mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
2195
+ mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth || wordSpacing ? WordMode : TextMode;
2168
2196
  if (row.isOverflow && !useLetter) row.textMode = true;
2169
2197
  if (mode === TextMode) {
2170
2198
  row.x += indentWidth;
@@ -2184,6 +2212,7 @@ function layoutChar(drawData, style, width, _height) {
2184
2212
  } else {
2185
2213
  charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
2186
2214
  }
2215
+ if (word.addWidth) charX += word.addWidth;
2187
2216
  if (canJustify) {
2188
2217
  isLastWord = index === wordsLength - 1;
2189
2218
  if (addWordWidth) {
@@ -775,7 +775,7 @@ function fills(fills, ui, canvas, renderOptions) {
775
775
  if (scaleX !== 1) canvas.scale(scaleX, scaleY);
776
776
  }
777
777
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
778
- fillPathOrText(ui, canvas, renderOptions);
778
+ fillPathOrText(ui, canvas, renderOptions, true);
779
779
  canvas.restore();
780
780
  } else {
781
781
  if (originPaint.blendMode) {
@@ -787,25 +787,46 @@ function fills(fills, ui, canvas, renderOptions) {
787
787
  }
788
788
  }
789
789
 
790
- function fillPathOrText(ui, canvas, renderOptions) {
791
- ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
790
+ function fillPathOrText(ui, canvas, renderOptions, complexPaint) {
791
+ ui.__.__font ? Paint.fillText(ui, canvas, renderOptions, complexPaint) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
792
792
  }
793
793
 
794
- function fillText(ui, canvas, renderOptions) {
795
- if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
796
- const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
794
+ function fillText(ui, canvas, renderOptions, complexPaint) {
795
+ const data = ui.__;
797
796
  if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
798
- let row;
799
- for (let i = 0, len = rows.length; i < len; i++) {
800
- row = rows[i];
801
- if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
802
- canvas.fillText(charData.char, charData.x, row.y);
803
- });
797
+ let originCanvas;
798
+ if (complexPaint) {
799
+ originCanvas = canvas;
800
+ canvas = canvas.getSameCanvas(true, true);
801
+ canvas.font = ui.__.__font;
802
+ canvas.fillStyle = "#000";
803
+ }
804
+ if (ui.motionText) {
805
+ Paint.fillMotionText(ui, canvas, renderOptions);
806
+ } else {
807
+ let row;
808
+ const {rows: rows, decorationY: decorationY} = data.__textDrawData;
809
+ for (let i = 0, len = rows.length; i < len; i++) {
810
+ row = rows[i];
811
+ if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
812
+ canvas.fillText(charData.char, charData.x, row.y);
813
+ });
814
+ }
815
+ if (decorationY) {
816
+ const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
817
+ if (decorationColor) canvas.fillStyle = decorationColor;
818
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
819
+ }
804
820
  }
805
- if (decorationY) {
806
- const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
807
- if (decorationColor) canvas.fillStyle = decorationColor;
808
- rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
821
+ if (complexPaint) {
822
+ canvas.beginPath();
823
+ ui.__drawPathByBox(canvas, "render");
824
+ canvas.fillStyle = originCanvas.fillStyle;
825
+ canvas.setTransform(originCanvas.getTransform());
826
+ canvas.blendMode = "source-in";
827
+ canvas.fill();
828
+ originCanvas.copyWorldByReset(canvas, ui.__nowWorld);
829
+ canvas.recycle(ui.__nowWorld);
809
830
  }
810
831
  }
811
832
 
@@ -1925,9 +1946,9 @@ const symbolChar = afterChar + "_#~&*+\\=|" + langSymbol;
1925
1946
 
1926
1947
  const breakChar = "- " + langBreak$1;
1927
1948
 
1928
- const cjkRangeList = [ [ 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 ] ];
1949
+ const cjkRangeList = [ [ 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 ], [ 4352, 4607 ], [ 12352, 12447 ], [ 12448, 12543 ], [ 12544, 12591 ], [ 12592, 12687 ], [ 12688, 12703 ], [ 12704, 12735 ], [ 12784, 12799 ], [ 12736, 12783 ], [ 12800, 13055 ], [ 13056, 13311 ], [ 63744, 64255 ], [ 65072, 65103 ], [ 127488, 127743 ], [ 194560, 195103 ] ];
1929
1950
 
1930
- const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u${start.toString(16)}-\\u${end.toString(16)}]`).join("|"));
1951
+ const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u{${start.toString(16)}}-\\u{${end.toString(16)}}]`).join("|"), "u");
1931
1952
 
1932
1953
  function mapChar(str) {
1933
1954
  const map = {};
@@ -2024,11 +2045,13 @@ function createRows(drawData, content, style) {
2024
2045
  rows = drawData.rows;
2025
2046
  bounds = drawData.bounds;
2026
2047
  findMaxWidth = !bounds.width && !style.autoSizeAlign;
2027
- const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
2048
+ const {paraIndent: paraIndent, textCase: textCase} = style;
2028
2049
  const {canvas: canvas} = Platform, {width: width} = bounds;
2029
2050
  if (style.__isCharMode) {
2030
2051
  const wrap = style.textWrap !== "none";
2031
2052
  const breakAll = style.textWrap === "break";
2053
+ const letterSpacing = style.__letterSpacing;
2054
+ const wordSpacing = style.__wordSpacing;
2032
2055
  paraStart = true;
2033
2056
  lastCharType = null;
2034
2057
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
@@ -2049,9 +2072,9 @@ function createRows(drawData, content, style) {
2049
2072
  charType = getCharType(char);
2050
2073
  if (charType === Letter && textCase !== "none") char = getTextCase(char, textCase, !wordWidth);
2051
2074
  charWidth = canvas.measureText(char).width;
2052
- if (__letterSpacing) {
2053
- if (__letterSpacing < 0) charSize = charWidth;
2054
- charWidth += __letterSpacing;
2075
+ if (letterSpacing) {
2076
+ if (letterSpacing < 0) charSize = charWidth;
2077
+ charWidth += letterSpacing;
2055
2078
  }
2056
2079
  langBreak = charType === Single && (lastCharType === Single || lastCharType === Letter) || lastCharType === Single && charType !== After;
2057
2080
  afterBreak = (charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After);
@@ -2072,11 +2095,11 @@ function createRows(drawData, content, style) {
2072
2095
  }
2073
2096
  if (char === " " && paraStart !== true && rowWidth + wordWidth === 0) ; else {
2074
2097
  if (charType === Break) {
2075
- if (char === " " && wordWidth) addWord();
2098
+ if (char === " " && wordWidth) addWord(wordSpacing);
2076
2099
  addChar(char, charWidth);
2077
2100
  addWord();
2078
2101
  } else if (langBreak || afterBreak) {
2079
- if (wordWidth) addWord();
2102
+ if (wordWidth) addWord(wordSpacing);
2080
2103
  addChar(char, charWidth);
2081
2104
  } else {
2082
2105
  addChar(char, charWidth);
@@ -2112,7 +2135,11 @@ function addChar(char, width) {
2112
2135
  wordWidth += width;
2113
2136
  }
2114
2137
 
2115
- function addWord() {
2138
+ function addWord(wordSpacing) {
2139
+ if (wordSpacing) {
2140
+ rowWidth += wordSpacing;
2141
+ word.addWidth = wordSpacing;
2142
+ }
2116
2143
  rowWidth += wordWidth;
2117
2144
  word.width = wordWidth;
2118
2145
  row.words.push(word);
@@ -2156,6 +2183,7 @@ function layoutChar(drawData, style, width, _height) {
2156
2183
  const {rows: rows} = drawData;
2157
2184
  const {textAlign: textAlign, paraIndent: paraIndent} = style;
2158
2185
  const useLetter = style.__letterSpacing || style.motionText;
2186
+ const wordSpacing = style.__wordSpacing;
2159
2187
  const justifyLast = width && textAlign.includes("both");
2160
2188
  const justify = justifyLast || width && textAlign.includes("justify");
2161
2189
  const justifyLetter = justify && textAlign.includes("letter");
@@ -2168,7 +2196,7 @@ function layoutChar(drawData, style, width, _height) {
2168
2196
  remainingWidth = width - row.width - indentWidth;
2169
2197
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
2170
2198
  }
2171
- mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
2199
+ mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth || wordSpacing ? WordMode : TextMode;
2172
2200
  if (row.isOverflow && !useLetter) row.textMode = true;
2173
2201
  if (mode === TextMode) {
2174
2202
  row.x += indentWidth;
@@ -2188,6 +2216,7 @@ function layoutChar(drawData, style, width, _height) {
2188
2216
  } else {
2189
2217
  charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
2190
2218
  }
2219
+ if (word.addWidth) charX += word.addWidth;
2191
2220
  if (canJustify) {
2192
2221
  isLastWord = index === wordsLength - 1;
2193
2222
  if (addWordWidth) {
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as s,LeaferImage as a,defineKey as n,FileHelper as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as m,Debug as w,LeafLevelList as y,LayoutEvent as x,Run as v,ImageManager as S,ResizeEvent as b,isObject as k,BoundsHelper as B,FourNumberHelper as R,Matrix as E,isUndefined as L,isString as T,ImageEvent as A,MatrixHelper as P,MathHelper as O,AlignHelper as C,PointHelper as M,isNumber as W,getMatrixData as D,AroundHelper as I,OneRadian as F,Direction4 as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{Paint as X,PaintImage as U,ColorConvert as G,PaintGradient as q,Effect as z,Group as N,TextConvert as j}from"@leafer-ui/draw";export*from"@leafer-ui/draw";var H;function V(t,e,i,s){return new(i||(i=Promise))(function(a,n){function r(t){try{l(s.next(t))}catch(t){n(t)}}function o(t){try{l(s.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(H||(H={})),"function"==typeof SuppressedError&&SuppressedError;class Q extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}function Z(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,a)=>{t.convertToBlob({type:r.mimeType(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>a(t),e.readAsDataURL(t)}).catch(t=>{a(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:r.mimeType(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:(t,i,s)=>new Promise((i,s)=>{let a=new XMLHttpRequest;a.open("GET",e.image.getRealURL(t),!0),a.responseType="blob",a.onload=()=>{createImageBitmap(a.response).then(t=>{i(t)}).catch(t=>{s(t)})},a.onerror=t=>s(t),a.send()}),loadContent(t){return V(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})}},e.canvas=s.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype),Object.assign(s,{canvas:(t,e)=>new Q(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},n(e,"devicePixelRatio",{get:()=>1});const{userAgent:$}=navigator;$.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),$.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):$.indexOf("Mac")>-1?e.os="Mac":$.indexOf("Linux")>-1&&(e.os="Linux");class J{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.changed=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed<100&&(this.changed++,this.running&&this.target.emit(d.REQUEST))}__onAttrChange(t){this.add(t.target)}add(t){this.config.usePartLayout&&this.__updatedList.add(t),this.update()}addChild(t,e,i){this.config.usePartLayout&&(i===c.ADD?(this.hasAdd=!0,this.__pushChild(t)):(this.hasRemove=!0,this.__updatedList.add(e))),this.update()}__onChildEvent(t){this.addChild(t.child,t.parent,t.type)}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.hasVisible=this.hasRemove=this.hasAdd=!1,this.changed=0}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:tt,updateChange:et}=f,{pushAllChildBranch:it,pushAllParent:st}=g,at={updateMatrix(t,e){let i,s,a=0;const{list:n}=t;for(;a<n.length;)i=n[a],s=i.__layout,e.without(i)&&!s.proxyZoom&&(s.matrixChanged?(K(i,!0),i.isBranch&&it(i,e),nt(i,e)):s.boundsChanged&&(i.isBranch&&(i.__tempNumber=0),nt(i,e))),a++},updateBounds(t){let e,i,s,a,n=0;const{levels:r,levelMap:o}=t;for(t.sort(!0);n<r.length;){e=r[n],i=o[e];for(let t=0,e=i.length;t<e;t++){if(s=i[t],s.isBranch&&s.__tempNumber){a=s.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||tt(a[t])}tt(s)}n++}},updateChange(t){t.list.forEach(et)},push:nt};function nt(t,e){e.add(t),st(t,e)}const{worldBounds:rt}=p;class ot{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,m(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,rt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,rt),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:lt,updateAllChange:dt}=f,ct=w.get("Layouter");class ht{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){ct.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ct.warn("layouting"):this.times>3?ct.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:n,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(a,o,this.times)),this.extraBlock=null,s.sort(),at.updateMatrix(s,this.__levelList),at.updateBounds(this.__levelList),at.updateChange(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(n,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=x,n=this.getBlocks(new o(e));e.emitEvent(new x(i,n,this.times)),ht.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,n,this.times)),e.emitEvent(new x(a,n,this.times)),this.addBlocks(n),v.end(t)}static fullLayout(t){lt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),dt(t)}addExtra(t,e){if(!this.__updatedList.has(t)){const{updatedList:i,beforeBounds:s}=this.extraBlock||(this.extraBlock=new ot([]));if(i.length?s.add(t.__world):s.set(t.__world),i.add(t),e){const e=this.__levelList;at.push(t,e),e.sort(!0)}}}createBlock(t){return new ot(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ut=w.get("Renderer");class ft{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,ut.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),S.clearRecycled()}catch(t){this.rendering=!1,ut.error(t)}ut.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ut.warn("rendering");if(this.times>3)return ut.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),a=new _(s);i.save(),s.spread(ft.clipSpread).ceil();const{ceilPartPixel:n}=this.config;i.clipWorld(s,n),i.clearWorld(s,n),this.__render(s,a),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:s,target:a}=this,n=t.includes(a.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(s,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.render(a,s,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(i);const{frames:a}=this;a.length>30&&a.shift(),a.push(t),this.FPS=Math.round(a.reduce((t,e)=>t+e,0)/a.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ut.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function gt(t,e,i){t.__.__font?X.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function pt(t,e,i,s,a){const n=i.__;k(t)?X.drawStrokesStyle(t,e,!1,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&X.strokeArrow(t,i,s,a)}function _t(t,e,i,s,a){const n=i.__;k(t)?X.drawStrokesStyle(t,e,!0,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),X.drawTextStroke(i,s,a))}function mt(t,e,i,s,a){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,_t(t,2,i,n,a),n.blendMode="outside"===e?"destination-out":"destination-in",X.fillText(i,n,a),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}ft.clipSpread=10,Object.assign(s,{watcher:(t,e)=>new J(t,e),layouter:(t,e)=>new ht(t,e),renderer:(t,e,i)=>new ft(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),e.layout=ht.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:wt,copyAndSpread:yt,toOuterOf:xt,getOuterOf:vt,getByMove:St,move:bt,getIntersectData:kt}=B,Bt={};let Rt;const{stintSet:Et}=l,{hasTransparent:Lt}=G;function Tt(t,e,i){if(!k(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:a}=i.__layout,{type:n}=e;switch(n){case"image":case"film":case"video":if(!e.url)return;s=U.image(i,t,e,a,!Rt||!Rt[e.url]),"image"!==n&&U[n](s);break;case"linear":s=q.linearGradient(e,a);break;case"radial":s=q.radialGradient(e,a);break;case"angular":s=q.conicGradient(e,a);break;case"solid":const{color:r,opacity:o}=e;s={type:n,style:G.string(r,o)};break;default:L(e.r)||(s={type:"solid",style:G.string(e)})}if(s&&(s.originPaint=e,T(s.style)&&Lt(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}const At={compute:function(t,e){const i=e.__,s=[];let a,n,r,o=i.__input[t];m(o)||(o=[o]),Rt=U.recycleImage(t,i);for(let i,a=0,n=o.length;a<n;a++)(i=Tt(t,o[a],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));s.length?(i["_"+t]=s,s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(a=!0),n=!0),"fill"===t?(Et(i,"__isAlphaPixelFill",a),Et(i,"__isTransparentFill",n)):(Et(i,"__isAlphaPixelStroke",a),Et(i,"__isTransparentStroke",n),Et(i,"__hasMultiStrokeStyle",r))):(i.__removePaint(t,!1),i["_"+t]="")},fill:function(t,e,i,s){i.fillStyle=t,gt(e,i,s)},fills:function(t,e,i,s){let a,n,r;for(let o=0,l=t.length;o<l;o++){if(a=t[o],n=a.originPaint,a.image){if(r?r++:r=1,U.checkImage(a,!e.__.__font,e,i,s))continue;if(!a.style){1===r&&a.image.isPlacehold&&e.drawImagePlaceholder(a,i,s);continue}}if(i.fillStyle=a.style,a.transform||n.scaleFixed){if(i.save(),a.transform&&i.transform(a.transform),n.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0,n.scaleFixed,!1);1!==t&&i.scale(t,s)}n.blendMode&&(i.blendMode=n.blendMode),gt(e,i,s),i.restore()}else n.blendMode?(i.saveBlendMode(n.blendMode),gt(e,i,s),i.restoreBlendMode()):gt(e,i,s)}},fillPathOrText:gt,fillText:function(t,e,i){if(t.motionText)return X.fillMotionText(t,e,i);const s=t.__,{rows:a,decorationY:n}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=a.length;t<i;t++)r=a[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(n){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const a=e.__;if(a.__strokeWidth)if(a.__font)X.strokeText(t,e,i,s);else if(a.__pathForStroke)X.fillStroke(t,e,i,s);else switch(a.strokeAlign){case"center":pt(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),pt(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const a=e.__;if(a.__fillAfterStroke)pt(t,2,e,i,s);else{const{renderBounds:n}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),pt(t,2,e,r,s),r.clipUI(a),r.clearWorld(n),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){X.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":_t(t,1,e,i,s);break;case"inside":mt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?_t(t,2,e,i,s):mt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,a=t.__.__textDrawData;const{rows:n,decorationY:r}=a;for(let t=0,i=n.length;t<i;t++)s=n[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=a;n.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,a,n){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!U.checkImage(r,!1,s,a,n))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):a.setStroke(r.style,o.__strokeWidth*e,o)}else a.strokeStyle=r.style;r.originPaint.blendMode?(a.saveBlendMode(r.originPaint.blendMode),i?X.drawTextStroke(s,a,n):a.stroke(),a.restoreBlendMode()):i?X.drawTextStroke(s,a,n):a.stroke()}},shape:function(t,i,s){const a=i.getSameCanvas(),n=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;xt(o.strokeSpread?(yt(Bt,o.boxBounds,o.strokeSpread),Bt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))g=a,d=f=l,c=r;else{let a;if(e.fullImageShadow)a=l;else{const t=o.renderShapeSpread?wt(n,R.swapAndScale(o.renderShapeSpread,p,_)):n;a=kt(t,l)}u=n.getFitMatrix(a);let{a:m,d:w}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=m,_*=w),f=vt(l,u),d=St(f,-u.e,-u.f),c=vt(r,u),bt(c,-u.e,-u.f);const y=s.matrix;y?(h=new E(u),h.multiply(y),m*=y.scaleX,w*=y.scaleY):h=u,h.withScale(m,w),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(a,s),{canvas:a,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Pt,Ot=new _;const{isSame:Ct}=B;function Mt(t,e,i,s,a,n){let r=!0;const o=t.__;if("fill"!==e||o.__naturalWidth||(o.__naturalWidth=s.width/o.pixelRatio,o.__naturalHeight=s.height/o.pixelRatio,o.__autoSide&&(t.forceUpdate(),f.updateBounds(t,!0),t.__layout.boundsChanged=!0,t.__proxyData&&(t.setProxyAttr("width",o.width),t.setProxyAttr("height",o.height)),r=!1)),"brush"===i.mode&&U.brush(t,e,a),!a.data){U.createData(a,s,i,n);const{transform:t}=a.data,{opacity:e}=i,r=(t&&!t.onlyScale||o.path||o.cornerRadius)&&!a.brush;(r||e&&e<1||i.blendMode)&&(a.complex=!r||2)}return i.filter&&U.applyFilter(a,s,i.filter,t),r}function Wt(t,e){Ft(t,A.LOAD,e)}function Dt(t,e){Ft(t,A.LOADED,e)}function It(t,e,i){e.error=i,t.forceUpdate("surface"),Ft(t,A.ERROR,e)}function Ft(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Yt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Xt,translate:Ut}=P,Gt=new _,qt={},zt={};function Nt(t,e,i,s){const a=T(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&a<0?0:a}let jt={},Ht=D();const{get:Vt,set:Qt,rotateOfOuter:Zt,translate:$t,scaleOfOuter:Jt,multiplyParent:Kt,scale:te,rotate:ee,skew:ie}=P;function se(t,e,i,s,a,n,r,o){r&&ee(t,r),o&&ie(t,o.x,o.y),a&&te(t,a,n),$t(t,e.x+i,e.y+s)}const{get:ae,scale:ne,copy:re}=P,{getFloorScale:oe}=O,{abs:le}=Math;const de={image:function(t,e,i,s,a){let n,r;const o=S.get(i,i.type);return Pt&&i===Pt.paint&&Ct(s,Pt.boxBounds)?n=Pt.leafPaint:(n={type:i.type,image:o},o.hasAlphaPixel&&(n.isTransparent=!0),Pt=o.use>1?{leafPaint:n,paint:i,boxBounds:Ot.set(s)}:null),(a||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Mt(t,e,i,o,n,s),a&&(Wt(t,r),Dt(t,r))):o.error?a&&It(t,r,o.error):(a&&(Yt(t,!0),Wt(t,r)),n.loadId=o.load(()=>{Yt(t,!1),t.destroyed||(Mt(t,e,i,o,n,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Dt(t,r)),n.loadId=void 0},e=>{Yt(t,!1),It(t,r,e),n.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),n},checkImage:function(t,i,s,a,n){const{scaleX:r,scaleY:o}=U.getImageRenderScaleData(t,s,a,n),l=t.film?t.nowIndex:r+"-"+o,{image:d,brush:c,data:h,originPaint:u}=t,{exporting:f,snapshot:g}=n;if(!h||t.patternId===l&&!f||g){if(!c||!t.style)return!1}else if(i&&(h.repeat?i=!1:u.changeful||t.film||"miniapp"===e.name||f||(i=e.image.isLarge(d,r,o)||d.width*r>8096||d.height*o>8096)),i)s.__.__isFastShadow&&(a.fillStyle=t.style||"#000",a.fill());else if(!t.style||u.sync||f?U.createPattern(t,s,a,n):U.createPatternTask(t,s,a,n),!c||!t.style)return!1;return U.drawImage(t,r,o,s,a,n),!0},drawImage:function(t,e,i,s,a,n){const{data:r,image:o,brush:l,complex:d}=t;let{width:c,height:h}=o,u=l||o;if(d){const{blendMode:n,opacity:o}=t.originPaint,{transform:l}=r;a.save(),2===d&&a.clipUI(s),n&&(a.blendMode=n),o&&(a.opacity*=o),l&&a.transform(l),u.render(a,0,0,c,h,s,t,e,i),a.restore()}else r.scaleX&&(c*=r.scaleX,h*=r.scaleY),u.render(a,0,0,c,h,s,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const a=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(t.brush&&U.addBrushScale(a,t,e),i){const{pixelRatio:t}=i;a.scaleX*=t,a.scaleY*=t}return n&&n.scaleX&&(a.scaleX*=Math.abs(n.scaleX),a.scaleY*=Math.abs(n.scaleY)),a},recycleImage:function(t,e){const i=e["_"+t];if(m(i)){let s,a,n,r,o;const l=e.__leaf;for(let d=0,c=i.length;d<c;d++)s=i[d],a=s.image,o=a&&a.url,o&&(n||(n={}),n[o]=!0,S.recyclePaint(s),s.brush&&U.recycleBrush(s,l),e.__willDestroy&&a.parent&&U.recycleFilter(a,l),a.loading&&(r||(r=e.__input&&e.__input[t]||[],m(r)||(r=[r])),a.unload(i[d].loadId,!r.some(t=>t.url===o))));return n}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=S.patternTasker.add(()=>V(this,void 0,void 0,function*(){U.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,i,s,a){let{scaleX:n,scaleY:r}=U.getImageRenderScaleData(t,i,s,a),o=t.film?t.nowIndex:n+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:l,brush:d,data:c}=t,{transform:h,gap:u}=c,f=U.getPatternFixScale(t,n,r);let g,p,_,{width:m,height:w}=l,{opacity:y}=t.originPaint;(d||1===y)&&(y=void 0),f&&(n*=f,r*=f),m*=n,w*=r,u&&!d&&(p=u.x*n/le(c.scaleX||1),_=u.y*r/le(c.scaleY||1)),(h||1!==n||1!==r)&&(n*=oe(m+(p||0)),r*=oe(w+(_||0)),g=ae(),h&&re(g,h),ne(g,1/n,1/r));const x=l.getCanvas(m,w,y,void 0,p,_,i.leafer&&i.leafer.config.smooth,c.interlace);d?(t.style=x,U.cacheBrush(t,i,s,a)):t.style=l.getPattern(x,c.repeat||e.origin.noRepeat||"no-repeat",g,t),t.patternId=o}},getPatternFixScale:function(t,i,s){const{image:a}=t;let n,r=e.image.maxPatternSize,o=a.width*a.height;return a.isSVG?i>1&&(n=Math.ceil(i)/i):r>o&&(r=o),(o*=i*s)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,s){t.data=U.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=Gt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:a}=i,{mode:n,align:r,offset:o,scale:l,size:d,rotation:c,skew:h,clipSize:u,repeat:f,gap:g,interlace:p}=t,_=e.width===s&&e.height===a,m={mode:n},w="center"!==r&&(c||0)%180==90;let y,x;switch(B.set(zt,0,0,w?a:s,w?s:a),n&&"cover"!==n&&"fit"!==n?((l||d)&&(O.getScaleData(l,d,i,qt),y=qt.scaleX,x=qt.scaleY),(r||g||f)&&(y&&B.scale(zt,y,x,!0),r&&C.toPoint(r,zt,e,zt,!0,!0))):_&&!c||(y=x=B.getFitScale(e,zt,"fit"!==n),B.put(e,i,r,y,!1,zt),B.scale(zt,y,x,!0)),o&&M.move(zt,o),n){case"stretch":_?y&&(y=x=void 0):(y=e.width/s,x=e.height/a,U.stretchMode(m,e,y,x));break;case"normal":case"clip":if(zt.x||zt.y||y||u||c||h){let t,i;u&&(t=e.width/u.width,i=e.height/u.height),U.clipMode(m,e,zt.x,zt.y,y,x,c,h,t,i),t&&(y=y?y*t:t,x=x?x*i:i)}break;case"repeat":(!_||y||c||h)&&U.repeatMode(m,e,s,a,zt.x,zt.y,y,x,c,h,r,t.freeTransform);case"brush":f||(m.repeat="repeat");const i=k(f);(g||i)&&(m.gap=function(t,e,i,s,a){let n,r;k(t)?(n=t.x,r=t.y):n=r=t;return{x:Nt(n,i,a.width,e&&e.x),y:Nt(r,s,a.height,e&&e.y)}}(g,i&&f,zt.width,zt.height,e));break;default:y&&U.fillOrFitMode(m,e,zt.x,zt.y,y,x,c)}return m.transform||"brush"===n||(e.x||e.y)&&Ut(m.transform=Xt(),e.x,e.y),y&&(m.scaleX=y,m.scaleY=x),f&&(m.repeat=T(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),p&&(m.interlace=W(p)||"percent"===p.type?{type:"x",offset:p}:p),m},stretchMode:function(t,e,i,s){const a=Vt(),{x:n,y:r}=e;n||r?$t(a,n,r):i>0&&s>0&&(a.onlyScale=!0),te(a,i,s),t.transform=a},fillOrFitMode:function(t,e,i,s,a,n,r){const o=Vt();$t(o,e.x+i,e.y+s),te(o,a,n),r&&Zt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,a,n,r,o,l,d){const c=Vt();se(c,e,i,s,a,n,r,o),l&&(r||o?(Qt(Ht),Jt(Ht,e,l,d),Kt(c,Ht)):Jt(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,s,a,n,r,o,l,d,c,h){const u=Vt();if(h)se(u,e,a,n,r,o,l,d);else{if(l)if("center"===c)Zt(u,{x:i/2,y:s/2},l);else switch(ee(u,l),l){case 90:$t(u,s,0);break;case 180:$t(u,i,s);break;case 270:$t(u,0,i)}jt.x=e.x+a,jt.y=e.y+n,$t(u,jt.x,jt.y),r&&Jt(u,jt,r,o)}t.transform=u}},{toPoint:ce}=I,{hasTransparent:he}=G,ue={},fe={};function ge(t,e,i,s){if(i){let a,n,r,o;for(let t=0,l=i.length;t<l;t++)a=i[t],T(a)?(r=t/(l-1),n=G.string(a,s)):(r=a.offset,n=G.string(a.color,s)),e.addColorStop(r,n),!o&&he(n)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:pe,getDistance:_e}=M,{get:me,rotateOfOuter:we,scaleOfOuter:ye}=P,{toPoint:xe}=I,ve={},Se={};function be(t,e,i,s,a){let n;const{width:r,height:o}=t;if(r!==o||s){const t=pe(e,i);n=me(),a?(ye(n,e,r/o*(s||1),1),we(n,e,t+90)):(ye(n,e,1,r/o*(s||1)),we(n,e,t))}return n}const{getDistance:ke}=M,{toPoint:Be}=I,Re={},Ee={};const Le={linearGradient:function(t,i){let{from:s,to:a,type:n,opacity:r}=t;ce(s||"top",i,ue),ce(a||"bottom",i,fe);const o=e.canvas.createLinearGradient(ue.x,ue.y,fe.x,fe.y),l={type:n,style:o};return ge(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:a,type:n,opacity:r,stretch:o}=t;xe(s||"center",i,ve),xe(a||"bottom",i,Se);const l=e.canvas.createRadialGradient(ve.x,ve.y,0,ve.x,ve.y,_e(ve,Se)),d={type:n,style:l};ge(d,l,t.stops,r);const c=be(i,ve,Se,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:s,to:a,type:n,opacity:r,rotation:o,stretch:l}=t;Be(s||"center",i,Re),Be(a||"bottom",i,Ee);const d=e.conicGradientSupport?e.canvas.createConicGradient(o?o*F:0,Re.x,Re.y):e.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,ke(Re,Ee)),c={type:n,style:d};ge(c,d,t.stops,r);const h=be(i,Re,Ee,l||1,e.conicGradientRotate90);return h&&(c.transform=h),c},getTransform:be},{copy:Te,move:Ae,toOffsetOutBounds:Pe}=B,{max:Oe,abs:Ce}=Math,Me={},We=new E,De={};function Ie(t,e){let i,s,a,n,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=1.5*(t.blur||0),a=Ce(t.spread||0),r=Oe(r,a+n-s),o=Oe(o,a+n+i),l=Oe(l,a+n+s),d=Oe(d,a+n-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Fe(t,i,s){const{shapeBounds:a}=s;let n,r;e.fullImageShadow?(Te(Me,t.bounds),Ae(Me,i.x-a.x,i.y-a.y),n=t.bounds,r=Me):(n=a,r=i),t.copyWorld(s.canvas,n,r)}const{toOffsetOutBounds:Ye}=B,Xe={};const Ue=Ie;const Ge={shadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Pe(l,De,d),r.forEach((r,_)=>{let m=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(m=1/t)}g.setWorldShadow(De.offsetX+(r.x||0)*h*m,De.offsetY+(r.y||0)*u*m,(r.blur||0)*h*m,G.string(r.color)),a=z.getShadowTransform(t,g,i,r,De,m),a&&g.setTransform(a),Fe(g,De,i),a&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,n,"copy"),s=n),o?g.copyWorld(o,n,n,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ye(l,Xe,d),r.forEach((r,_)=>{let m=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(m=1/t)}g.save(),g.setWorldShadow(Xe.offsetX+(r.x||0)*h*m,Xe.offsetY+(r.y||0)*u*m,(r.blur||0)*h*m),a=z.getShadowTransform(t,g,i,r,Xe,m,!0),a&&g.setTransform(a),Fe(g,Xe,i),g.restore(),o?(g.copyWorld(g,d,n,"copy"),g.copyWorld(o,n,n,"source-out"),s=n):(g.copyWorld(i.canvas,c,l,"source-out"),s=d),g.fillWorld(s,G.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Ie,getShadowTransform:function(t,e,i,s,a,n,r){if(s.spread){const i=2*s.spread*n*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return We.set().scaleOfOuter({x:(a.x+a.width/2)*e.pixelRatio,y:(a.y+a.height/2)*e.pixelRatio},1+i/o,1+i/l),We}},isTransformShadow(t){},getInnerShadowSpread:Ue},{excludeRenderBounds:qe}=p;let ze;function Ne(t,e,i,s,a,n,r,o){switch(e){case"grayscale":ze||(ze=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,a,n){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),n&&s.recycle(r);He(t,e,i,1,a,n)}(t,i,s,a,r,o);break;case"opacity-path":He(t,i,s,n,r,o);break;case"path":o&&i.restore()}}function je(t){return t.getSameCanvas(!1,!0)}function He(t,e,i,s,a,n){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,a),n?i.recycle(r):i.clearWorld(r)}N.prototype.__renderMask=function(t,e){let i,s,a,n,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(Ne(this,r,t,a,s,n,void 0,!0),s=a=null),"clipping"!==o&&"clipping-path"!==o||qe(i,e)||i.__render(t,e),n=i.__.opacity,ze=!1,"path"===o||"clipping-path"===o?(n<1?(r="opacity-path",a||(a=je(t))):(r="path",t.save()),i.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=je(t)),a||(a=je(t)),i.__render(s,e));continue}const c=1===n&&i.__.__blendMode;c&&Ne(this,r,t,a,s,n,void 0,!1),qe(i,e)||i.__render(a||t,e),c&&Ne(this,r,t,a,s,n,c,!1)}Ne(this,r,t,a,s,n,void 0,!0)};const Ve=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qe=Ve+"_#~&*+\\=|≮≯≈≠=…",Ze=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 $e(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Je=$e("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ke=$e("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ti=$e(Ve),ei=$e(Qe),ii=$e("- —/~|┆·");var si;!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"}(si||(si={}));const{Letter:ai,Single:ni,Before:ri,After:oi,Symbol:li,Break:di}=si;function ci(t){return Je[t]?ai:ii[t]?di:Ke[t]?ri:ti[t]?oi:ei[t]?li:Ze.test(t)?ni:ai}const hi={trimRight(t){const{words:e}=t;let i,s=0,a=e.length;for(let n=a-1;n>-1&&(i=e[n].data[0]," "===i.char);n--)s++,t.width-=i.width;s&&e.splice(a-s,s)}};function ui(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:fi}=hi,{Letter:gi,Single:pi,Before:_i,After:mi,Symbol:wi,Break:yi}=si;let xi,vi,Si,bi,ki,Bi,Ri,Ei,Li,Ti,Ai,Pi,Oi,Ci,Mi,Wi,Di,Ii=[];function Fi(t,e){Li&&!Ei&&(Ei=Li),xi.data.push({char:t,width:e}),Si+=e}function Yi(){bi+=Si,xi.width=Si,vi.words.push(xi),xi={data:[]},Si=0}function Xi(){Ci&&(Mi.paraNumber++,vi.paraStart=!0,Ci=!1),Li&&(vi.startCharSize=Ei,vi.endCharSize=Li,Ei=0),vi.width=bi,Wi.width?fi(vi):Di&&Ui(),Ii.push(vi),vi={words:[]},bi=0}function Ui(){bi>(Mi.maxWidth||0)&&(Mi.maxWidth=bi)}const{top:Gi,right:qi,bottom:zi,left:Ni}=Y;function ji(t,e,i){const{bounds:s,rows:a}=t;s[e]+=i;for(let t=0;t<a.length;t++)a[t][e]+=i}const Hi={getDrawData:function(t,i){T(t)||(t=String(t));let s=0,a=0,n=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;i.motionText&&(n=r=0),o&&(n?(s=o[Ni],n-=o[qi]+o[Ni],!n&&(n=.01)):i.autoSizeAlign||(s=o[Ni]),r?(a=o[Gi],r-=o[Gi]+o[zi],!r&&(r=.01)):i.autoSizeAlign||(a=o[Gi]));const l={bounds:{x:s,y:a,width:n,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,s){Mi=t,Ii=t.rows,Wi=t.bounds,Di=!Wi.width&&!s.autoSizeAlign;const{__letterSpacing:a,paraIndent:n,textCase:r}=s,{canvas:o}=e,{width:l}=Wi;if(s.__isCharMode){const t="none"!==s.textWrap,e="break"===s.textWrap;Ci=!0,Ai=null,Ei=Ri=Li=Si=bi=0,xi={data:[]},vi={words:[]};for(let s=0,d=(i=[...i]).length;s<d;s++)Bi=i[s],"\n"===Bi?(Si&&Yi(),vi.paraEnd=!0,Xi(),Ci=!0):(Ti=ci(Bi),Ti===gi&&"none"!==r&&(Bi=ui(Bi,r,!Si)),Ri=o.measureText(Bi).width,a&&(a<0&&(Li=Ri),Ri+=a),Pi=Ti===pi&&(Ai===pi||Ai===gi)||Ai===pi&&Ti!==mi,Oi=!(Ti!==_i&&Ti!==pi||Ai!==wi&&Ai!==mi),ki=Ci&&n?l-n:l,t&&l&&bi+Si+Ri>ki&&(e?(Si&&Yi(),bi&&Xi()):(Oi||(Oi=Ti===gi&&Ai==mi),Pi||Oi||Ti===yi||Ti===_i||Ti===pi||Si+Ri>ki?(Si&&Yi(),bi&&Xi()):bi&&Xi()))," "===Bi&&!0!==Ci&&bi+Si===0||(Ti===yi?(" "===Bi&&Si&&Yi(),Fi(Bi,Ri),Yi()):Pi||Oi?(Si&&Yi(),Fi(Bi,Ri)):Fi(Bi,Ri)),Ai=Ti);Si&&Yi(),bi&&Xi(),Ii.length>0&&(Ii[Ii.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Mi.paraNumber++,bi=o.measureText(t).width,Ii.push({x:n||0,text:t,width:bi,paraStart:!0}),Di&&Ui()})}(l,t,i),o&&function(t,e,i,s,a){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ji(e,"x",t[Ni]);break;case"right":ji(e,"x",-t[qi])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ji(e,"y",t[Gi]);break;case"bottom":ji(e,"y",-t[zi])}}(o,l,i,n,r),function(t,e){const{rows:i,bounds:s}=t,a=i.length,{__lineHeight:n,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,m=n*a+(h?h*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(e.__autoHeight?m:_,n),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":g+=(_-m)/2;break;case"bottom":g+=_-m}w+=g;let y,x,v,S=p||u?p:t.maxWidth;for(let r=0,c=a;r<c;r++){if(y=i[r],y.x=f,y.width<p||y.width>p&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(w+=h),y.y=w,w+=n,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=m}(l,i),i.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:a,paraIndent:n}=e,r=e.__letterSpacing||e.motionText,o=i&&a.includes("both"),l=o||i&&a.includes("justify"),d=l&&a.includes("letter");let c,h,u,f,g,p,_,m,w,y;s.forEach(t=>{t.words&&(g=n&&t.paraStart?n:0,m=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-g,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=m>1?h/(m-1):0),p=r||t.isOverflow||d?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===p?(t.x+=g,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=g,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===p?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,s,a){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,a&&(e+=a)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(w=i===m-1,u?w||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(w?1:0))))})),t.words=null)})}(l,i,n),l.overflow&&function(t,i,s,a){const{rows:n,overflow:r}=t;let{textOverflow:o}=i;if(r&&n.splice(r),a&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=s+a-d;("none"===i.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<c));s--){if(l<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,s,n),"none"!==i.textDecoration&&function(t,e){let i,s=0;const{fontSize:a,textDecoration:n}=e;switch(t.decorationHeight=a/11,k(n)?(i=n.type,n.color&&(t.decorationColor=G.string(n.color)),n.offset&&(s=Math.min(.3*a,Math.max(n.offset,.15*-a)))):i=n,i){case"under":t.decorationY=[.15*a+s];break;case"delete":t.decorationY=[.35*-a];break;case"under-delete":t.decorationY=[.15*a+s,.35*-a]}}(l,i),l}};const Vi={string:function(t,e){if(!t)return"#000";const i=W(e)&&e<1;if(T(t)){if(!i||!G.object)return t;t=G.object(t)}let s=L(t.a)?1:t.a;i&&(s*=e);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}};Object.assign(j,Hi),Object.assign(G,Vi),Object.assign(X,At),Object.assign(U,de),Object.assign(q,Le),Object.assign(z,Ge),Z();export{ht as Layouter,at as LayouterHelper,Q as LeaferCanvas,H as PathNodeHandleType,ft as Renderer,J as Watcher,Z as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,Creator as s,LeaferImage as a,defineKey as n,FileHelper as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as m,Debug as w,LeafLevelList as y,LayoutEvent as x,Run as v,ImageManager as S,ResizeEvent as b,isObject as k,BoundsHelper as B,FourNumberHelper as R,Matrix as E,isUndefined as T,isString as L,ImageEvent as A,MatrixHelper as P,MathHelper as C,AlignHelper as O,PointHelper as W,isNumber as M,getMatrixData as D,AroundHelper as I,OneRadian as F,Direction4 as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferFilm,LeaferImage,LeaferVideo}from"@leafer/core";import{Paint as X,PaintImage as U,ColorConvert as G,PaintGradient as q,Effect as z,Group as N,TextConvert as j}from"@leafer-ui/draw";export*from"@leafer-ui/draw";var H;function V(t,e,i,s){return new(i||(i=Promise))(function(a,n){function r(t){try{l(s.next(t))}catch(t){n(t)}}function o(t){try{l(s.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}!function(t){t[t.none=1]="none",t[t.free=2]="free",t[t.mirrorAngle=3]="mirrorAngle",t[t.mirror=4]="mirror"}(H||(H={})),"function"==typeof SuppressedError&&SuppressedError;class Q extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}function Z(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,a)=>{t.convertToBlob({type:r.mimeType(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>a(t),e.readAsDataURL(t)}).catch(t=>{a(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:r.mimeType(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:(t,i,s)=>new Promise((i,s)=>{let a=new XMLHttpRequest;a.open("GET",e.image.getRealURL(t),!0),a.responseType="blob",a.onload=()=>{createImageBitmap(a.response).then(t=>{i(t)}).catch(t=>{s(t)})},a.onerror=t=>s(t),a.send()}),loadContent(t){return V(this,arguments,void 0,function*(t,e="text"){const i=yield fetch(t);if(!i.ok)throw new Error(`${i.status}`);return yield i[e]()})}},e.canvas=s.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype),Object.assign(s,{canvas:(t,e)=>new Q(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},n(e,"devicePixelRatio",{get:()=>1});const{userAgent:$}=navigator;$.indexOf("Firefox")>-1?(e.conicGradientRotate90=!0,e.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(e.fullImageShadow=!0),$.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):$.indexOf("Mac")>-1?e.os="Mac":$.indexOf("Linux")>-1&&(e.os="Linux");class J{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove&&this.config.usePartLayout){const t=new o;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.changed=0,this.config={},this.__updatedList=new o,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed<100&&(this.changed++,this.running&&this.target.emit(d.REQUEST))}__onAttrChange(t){this.add(t.target)}add(t){this.config.usePartLayout&&this.__updatedList.add(t),this.update()}addChild(t,e,i){this.config.usePartLayout&&(i===c.ADD?(this.hasAdd=!0,this.__pushChild(t)):(this.hasRemove=!0,this.__updatedList.add(e))),this.update()}__onChildEvent(t){this.addChild(t.child,t.parent,t.type)}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.hasVisible=this.hasRemove=this.hasAdd=!1,this.changed=0}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:tt,updateChange:et}=f,{pushAllChildBranch:it,pushAllParent:st}=g,at={updateMatrix(t,e){let i,s,a=0;const{list:n}=t;for(;a<n.length;)i=n[a],s=i.__layout,e.without(i)&&!s.proxyZoom&&(s.matrixChanged?(K(i,!0),i.isBranch&&it(i,e),nt(i,e)):s.boundsChanged&&(i.isBranch&&(i.__tempNumber=0),nt(i,e))),a++},updateBounds(t){let e,i,s,a,n=0;const{levels:r,levelMap:o}=t;for(t.sort(!0);n<r.length;){e=r[n],i=o[e];for(let t=0,e=i.length;t<e;t++){if(s=i[t],s.isBranch&&s.__tempNumber){a=s.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||tt(a[t])}tt(s)}n++}},updateChange(t){t.list.forEach(et)},push:nt};function nt(t,e){e.add(t),st(t,e)}const{worldBounds:rt}=p;class ot{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,m(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,rt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,rt),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:lt,updateAllChange:dt}=f,ct=w.get("Layouter");class ht{constructor(t,e){this.totalTimes=0,this.config={usePartLayout:!0},this.__levelList=new y,this.target=t,e&&(this.config=l.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(x.START),this.layoutOnce(),t.emitEvent(new x(x.END,this.layoutedBlocks,this.times))}catch(t){ct.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ct.warn("layouting"):this.times>3?ct.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.REQUEST),this.totalTimes>1&&this.config.usePartLayout?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:n,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(a,o,this.times)),this.extraBlock=null,s.sort(),at.updateMatrix(s,this.__levelList),at.updateBounds(this.__levelList),at.updateChange(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(n,o,this.times)),i.emitEvent(new x(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,v.end(e)}fullLayout(){const t=v.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=x,n=this.getBlocks(new o(e));e.emitEvent(new x(i,n,this.times)),ht.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,n,this.times)),e.emitEvent(new x(a,n,this.times)),this.addBlocks(n),v.end(t)}static fullLayout(t){lt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),dt(t)}addExtra(t,e){if(!this.__updatedList.has(t)){const{updatedList:i,beforeBounds:s}=this.extraBlock||(this.extraBlock=new ot([]));if(i.length?s.add(t.__world):s.set(t.__world),i.add(t),e){const e=this.__levelList;at.push(t,e),e.sort(!0)}}}createBlock(t){return new ot(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[x.REQUEST,this.layout,this],[x.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ut=w.get("Renderer");class ft{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,ceilPartPixel:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=l.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.requestTime||this.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,ut.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),S.clearRecycled()}catch(t){this.rendering=!1,ut.error(t)}ut.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ut.warn("rendering");if(this.times>3)return ut.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=v.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),a=new _(s);i.save(),s.spread(ft.clipSpread).ceil();const{ceilPartPixel:n}=this.config;i.clipWorld(s,n),i.clearWorld(s,n),this.__render(s,a),i.restore(),v.end(e)}fullRender(){const t=v.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),v.end(t)}__render(t,i){const{canvas:s,target:a}=this,n=t.includes(a.__world),r=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),w.showRepaint&&w.drawRepaint(s,t),this.config.useCellRender&&(r.cellList=this.getCellList()),e.render(a,s,r),this.renderBounds=i=i||t,this.renderOptions=r,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}getCellList(){}addBlock(t,e){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const i=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return e.requestRender(i);const{frames:a}=this;a.length>30&&a.shift(),a.push(t),this.FPS=Math.round(a.reduce((t,e)=>t+e,0)/a.length),this.requestTime=0,this.checkRender()};e.requestRender(i)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;const{updatedList:i}=t;i&&i.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ut.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds,i)})}emitRender(t,e,i){this.target.emitEvent(new d(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[b.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function gt(t,e,i,s){t.__.__font?X.fillText(t,e,i,s):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function pt(t,e,i,s,a){const n=i.__;k(t)?X.drawStrokesStyle(t,e,!1,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&X.strokeArrow(t,i,s,a)}function _t(t,e,i,s,a){const n=i.__;k(t)?X.drawStrokesStyle(t,e,!0,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),X.drawTextStroke(i,s,a))}function mt(t,e,i,s,a){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,_t(t,2,i,n,a),n.blendMode="outside"===e?"destination-out":"destination-in",X.fillText(i,n,a),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}ft.clipSpread=10,Object.assign(s,{watcher:(t,e)=>new J(t,e),layouter:(t,e)=>new ht(t,e),renderer:(t,e,i)=>new ft(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),e.layout=ht.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new o,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:wt,copyAndSpread:yt,toOuterOf:xt,getOuterOf:vt,getByMove:St,move:bt,getIntersectData:kt}=B,Bt={};let Rt;const{stintSet:Et}=l,{hasTransparent:Tt}=G;function Lt(t,e,i){if(!k(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:a}=i.__layout,{type:n}=e;switch(n){case"image":case"film":case"video":if(!e.url)return;s=U.image(i,t,e,a,!Rt||!Rt[e.url]),"image"!==n&&U[n](s);break;case"linear":s=q.linearGradient(e,a);break;case"radial":s=q.radialGradient(e,a);break;case"angular":s=q.conicGradient(e,a);break;case"solid":const{color:r,opacity:o}=e;s={type:n,style:G.string(r,o)};break;default:T(e.r)||(s={type:"solid",style:G.string(e)})}if(s&&(s.originPaint=e,L(s.style)&&Tt(s.style)&&(s.isTransparent=!0),e.style)){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}return s}const At={compute:function(t,e){const i=e.__,s=[];let a,n,r,o=i.__input[t];m(o)||(o=[o]),Rt=U.recycleImage(t,i);for(let i,a=0,n=o.length;a<n;a++)(i=Lt(t,o[a],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));s.length?(i["_"+t]=s,s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(a=!0),n=!0),"fill"===t?(Et(i,"__isAlphaPixelFill",a),Et(i,"__isTransparentFill",n)):(Et(i,"__isAlphaPixelStroke",a),Et(i,"__isTransparentStroke",n),Et(i,"__hasMultiStrokeStyle",r))):(i.__removePaint(t,!1),i["_"+t]="")},fill:function(t,e,i,s){i.fillStyle=t,gt(e,i,s)},fills:function(t,e,i,s){let a,n,r;for(let o=0,l=t.length;o<l;o++){if(a=t[o],n=a.originPaint,a.image){if(r?r++:r=1,U.checkImage(a,!e.__.__font,e,i,s))continue;if(!a.style){1===r&&a.image.isPlacehold&&e.drawImagePlaceholder(a,i,s);continue}}if(i.fillStyle=a.style,a.transform||n.scaleFixed){if(i.save(),a.transform&&i.transform(a.transform),n.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0,n.scaleFixed,!1);1!==t&&i.scale(t,s)}n.blendMode&&(i.blendMode=n.blendMode),gt(e,i,s,!0),i.restore()}else n.blendMode?(i.saveBlendMode(n.blendMode),gt(e,i,s),i.restoreBlendMode()):gt(e,i,s)}},fillPathOrText:gt,fillText:function(t,e,i,s){const a=t.__;let n;if(a.__isPlacehold&&a.placeholderColor&&(e.fillStyle=a.placeholderColor),s&&(n=e,(e=e.getSameCanvas(!0,!0)).font=t.__.__font,e.fillStyle="#000"),t.motionText)X.fillMotionText(t,e,i);else{let t;const{rows:i,decorationY:s}=a.__textDrawData;for(let s=0,a=i.length;s<a;s++)t=i[s],t.text?e.fillText(t.text,t.x,t.y):t.data&&t.data.forEach(i=>{e.fillText(i.char,i.x,t.y)});if(s){const{decorationColor:t,decorationHeight:n}=a.__textDrawData;t&&(e.fillStyle=t),i.forEach(t=>s.forEach(i=>e.fillRect(t.x,t.y+i,t.width,n)))}}s&&(e.beginPath(),t.__drawPathByBox(e,"render"),e.fillStyle=n.fillStyle,e.setTransform(n.getTransform()),e.blendMode="source-in",e.fill(),n.copyWorldByReset(e,t.__nowWorld),e.recycle(t.__nowWorld))},stroke:function(t,e,i,s){const a=e.__;if(a.__strokeWidth)if(a.__font)X.strokeText(t,e,i,s);else if(a.__pathForStroke)X.fillStroke(t,e,i,s);else switch(a.strokeAlign){case"center":pt(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),pt(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const a=e.__;if(a.__fillAfterStroke)pt(t,2,e,i,s);else{const{renderBounds:n}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),pt(t,2,e,r,s),r.clipUI(a),r.clearWorld(n),f.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){X.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":_t(t,1,e,i,s);break;case"inside":mt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?_t(t,2,e,i,s):mt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,a=t.__.__textDrawData;const{rows:n,decorationY:r}=a;for(let t=0,i=n.length;t<i;t++)s=n[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(r){const{decorationHeight:t}=a;n.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,a,n){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*e,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!U.checkImage(r,!1,s,a,n))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):a.setStroke(r.style,o.__strokeWidth*e,o)}else a.strokeStyle=r.style;r.originPaint.blendMode?(a.saveBlendMode(r.originPaint.blendMode),i?X.drawTextStroke(s,a,n):a.stroke(),a.restoreBlendMode()):i?X.drawTextStroke(s,a,n):a.stroke()}},shape:function(t,i,s){const a=i.getSameCanvas(),n=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,g;xt(o.strokeSpread?(yt(Bt,o.boxBounds,o.strokeSpread),Bt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))g=a,d=f=l,c=r;else{let a;if(e.fullImageShadow)a=l;else{const t=o.renderShapeSpread?wt(n,R.swapAndScale(o.renderShapeSpread,p,_)):n;a=kt(t,l)}u=n.getFitMatrix(a);let{a:m,d:w}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=m,_*=w),f=vt(l,u),d=St(f,-u.e,-u.f),c=vt(r,u),bt(c,-u.e,-u.f);const y=s.matrix;y?(h=new E(u),h.multiply(y),m*=y.scaleX,w*=y.scaleY):h=u,h.withScale(m,w),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(a,s),{canvas:a,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Pt,Ct=new _;const{isSame:Ot}=B;function Wt(t,e,i,s,a,n){let r=!0;const o=t.__;if("fill"!==e||o.__naturalWidth||(o.__naturalWidth=s.width/o.pixelRatio,o.__naturalHeight=s.height/o.pixelRatio,o.__autoSide&&(t.forceUpdate(),f.updateBounds(t,!0),t.__layout.boundsChanged=!0,t.__proxyData&&(t.setProxyAttr("width",o.width),t.setProxyAttr("height",o.height)),r=!1)),"brush"===i.mode&&U.brush(t,e,a),!a.data){U.createData(a,s,i,n);const{transform:t}=a.data,{opacity:e}=i,r=(t&&!t.onlyScale||o.path||o.cornerRadius)&&!a.brush;(r||e&&e<1||i.blendMode)&&(a.complex=!r||2)}return i.filter&&U.applyFilter(a,s,i.filter,t),r}function Mt(t,e){Ft(t,A.LOAD,e)}function Dt(t,e){Ft(t,A.LOADED,e)}function It(t,e,i){e.error=i,t.forceUpdate("surface"),Ft(t,A.ERROR,e)}function Ft(t,e,i){t.hasEvent(e)&&t.emitEvent(new A(e,i))}function Yt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:Xt,translate:Ut}=P,Gt=new _,qt={},zt={};function Nt(t,e,i,s){const a=L(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&a<0?0:a}let jt={},Ht=D();const{get:Vt,set:Qt,rotateOfOuter:Zt,translate:$t,scaleOfOuter:Jt,multiplyParent:Kt,scale:te,rotate:ee,skew:ie}=P;function se(t,e,i,s,a,n,r,o){r&&ee(t,r),o&&ie(t,o.x,o.y),a&&te(t,a,n),$t(t,e.x+i,e.y+s)}const{get:ae,scale:ne,copy:re}=P,{getFloorScale:oe}=C,{abs:le}=Math;const de={image:function(t,e,i,s,a){let n,r;const o=S.get(i,i.type);return Pt&&i===Pt.paint&&Ot(s,Pt.boxBounds)?n=Pt.leafPaint:(n={type:i.type,image:o},o.hasAlphaPixel&&(n.isTransparent=!0),Pt=o.use>1?{leafPaint:n,paint:i,boxBounds:Ct.set(s)}:null),(a||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Wt(t,e,i,o,n,s),a&&(Mt(t,r),Dt(t,r))):o.error?a&&It(t,r,o.error):(a&&(Yt(t,!0),Mt(t,r)),n.loadId=o.load(()=>{Yt(t,!1),t.destroyed||(Wt(t,e,i,o,n,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Dt(t,r)),n.loadId=void 0},e=>{Yt(t,!1),It(t,r,e),n.loadId=void 0},i.lod&&o.getThumbSize(i.lod)),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),n},checkImage:function(t,i,s,a,n){const{scaleX:r,scaleY:o}=U.getImageRenderScaleData(t,s,a,n),l=t.film?t.nowIndex:r+"-"+o,{image:d,brush:c,data:h,originPaint:u}=t,{exporting:f,snapshot:g}=n;if(!h||t.patternId===l&&!f||g){if(!c||!t.style)return!1}else if(i&&(h.repeat?i=!1:u.changeful||t.film||"miniapp"===e.name||f||(i=e.image.isLarge(d,r,o)||d.width*r>8096||d.height*o>8096)),i)s.__.__isFastShadow&&(a.fillStyle=t.style||"#000",a.fill());else if(!t.style||u.sync||f?U.createPattern(t,s,a,n):U.createPatternTask(t,s,a,n),!c||!t.style)return!1;return U.drawImage(t,r,o,s,a,n),!0},drawImage:function(t,e,i,s,a,n){const{data:r,image:o,brush:l,complex:d}=t;let{width:c,height:h}=o,u=l||o;if(d){const{blendMode:n,opacity:o}=t.originPaint,{transform:l}=r;a.save(),2===d&&a.clipUI(s),n&&(a.blendMode=n),o&&(a.opacity*=o),l&&a.transform(l),u.render(a,0,0,c,h,s,t,e,i),a.restore()}else r.scaleX&&(c*=r.scaleX,h*=r.scaleY),u.render(a,0,0,c,h,s,t,e,i)},getImageRenderScaleData:function(t,e,i,s){const a=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(t.brush&&U.addBrushScale(a,t,e),i){const{pixelRatio:t}=i;a.scaleX*=t,a.scaleY*=t}return n&&n.scaleX&&(a.scaleX*=Math.abs(n.scaleX),a.scaleY*=Math.abs(n.scaleY)),a},recycleImage:function(t,e){const i=e["_"+t];if(m(i)){let s,a,n,r,o;const l=e.__leaf;for(let d=0,c=i.length;d<c;d++)s=i[d],a=s.image,o=a&&a.url,o&&(n||(n={}),n[o]=!0,S.recyclePaint(s),s.brush&&U.recycleBrush(s,l),e.__willDestroy&&a.parent&&U.recycleFilter(a,l),a.loading&&(r||(r=e.__input&&e.__input[t]||[],m(r)||(r=[r])),a.unload(i[d].loadId,!r.some(t=>t.url===o))));return n}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=S.patternTasker.add(()=>V(this,void 0,void 0,function*(){U.createPattern(t,e,i,s),e.forceUpdate("surface")}),0,()=>(t.patternTask=null,i.bounds.hit(e.__nowWorld))))},createPattern:function(t,i,s,a){let{scaleX:n,scaleY:r}=U.getImageRenderScaleData(t,i,s,a),o=t.film?t.nowIndex:n+"-"+r;if(t.patternId!==o&&!i.destroyed&&(!e.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:l,brush:d,data:c}=t,{transform:h,gap:u}=c,f=U.getPatternFixScale(t,n,r);let g,p,_,{width:m,height:w}=l,{opacity:y}=t.originPaint;(d||1===y)&&(y=void 0),f&&(n*=f,r*=f),m*=n,w*=r,u&&!d&&(p=u.x*n/le(c.scaleX||1),_=u.y*r/le(c.scaleY||1)),(h||1!==n||1!==r)&&(n*=oe(m+(p||0)),r*=oe(w+(_||0)),g=ae(),h&&re(g,h),ne(g,1/n,1/r));const x=l.getCanvas(m,w,y,void 0,p,_,i.leafer&&i.leafer.config.smooth,c.interlace);d?(t.style=x,U.cacheBrush(t,i,s,a)):t.style=l.getPattern(x,c.repeat||e.origin.noRepeat||"no-repeat",g,t),t.patternId=o}},getPatternFixScale:function(t,i,s){const{image:a}=t;let n,r=e.image.maxPatternSize,o=a.width*a.height;return a.isSVG?i>1&&(n=Math.ceil(i)/i):r>o&&(r=o),(o*=i*s)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,s){t.data=U.getPatternData(i,s,e)},getPatternData:function(t,e,i){t.padding&&(e=Gt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:s,height:a}=i,{mode:n,align:r,offset:o,scale:l,size:d,rotation:c,skew:h,clipSize:u,repeat:f,gap:g,interlace:p}=t,_=e.width===s&&e.height===a,m={mode:n},w="center"!==r&&(c||0)%180==90;let y,x;switch(B.set(zt,0,0,w?a:s,w?s:a),n&&"cover"!==n&&"fit"!==n?((l||d)&&(C.getScaleData(l,d,i,qt),y=qt.scaleX,x=qt.scaleY),(r||g||f)&&(y&&B.scale(zt,y,x,!0),r&&O.toPoint(r,zt,e,zt,!0,!0))):_&&!c||(y=x=B.getFitScale(e,zt,"fit"!==n),B.put(e,i,r,y,!1,zt),B.scale(zt,y,x,!0)),o&&W.move(zt,o),n){case"stretch":_?y&&(y=x=void 0):(y=e.width/s,x=e.height/a,U.stretchMode(m,e,y,x));break;case"normal":case"clip":if(zt.x||zt.y||y||u||c||h){let t,i;u&&(t=e.width/u.width,i=e.height/u.height),U.clipMode(m,e,zt.x,zt.y,y,x,c,h,t,i),t&&(y=y?y*t:t,x=x?x*i:i)}break;case"repeat":(!_||y||c||h)&&U.repeatMode(m,e,s,a,zt.x,zt.y,y,x,c,h,r,t.freeTransform);case"brush":f||(m.repeat="repeat");const i=k(f);(g||i)&&(m.gap=function(t,e,i,s,a){let n,r;k(t)?(n=t.x,r=t.y):n=r=t;return{x:Nt(n,i,a.width,e&&e.x),y:Nt(r,s,a.height,e&&e.y)}}(g,i&&f,zt.width,zt.height,e));break;default:y&&U.fillOrFitMode(m,e,zt.x,zt.y,y,x,c)}return m.transform||"brush"===n||(e.x||e.y)&&Ut(m.transform=Xt(),e.x,e.y),y&&(m.scaleX=y,m.scaleY=x),f&&(m.repeat=L(f)?"x"===f?"repeat-x":"repeat-y":"repeat"),p&&(m.interlace=M(p)||"percent"===p.type?{type:"x",offset:p}:p),m},stretchMode:function(t,e,i,s){const a=Vt(),{x:n,y:r}=e;n||r?$t(a,n,r):i>0&&s>0&&(a.onlyScale=!0),te(a,i,s),t.transform=a},fillOrFitMode:function(t,e,i,s,a,n,r){const o=Vt();$t(o,e.x+i,e.y+s),te(o,a,n),r&&Zt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,a,n,r,o,l,d){const c=Vt();se(c,e,i,s,a,n,r,o),l&&(r||o?(Qt(Ht),Jt(Ht,e,l,d),Kt(c,Ht)):Jt(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,s,a,n,r,o,l,d,c,h){const u=Vt();if(h)se(u,e,a,n,r,o,l,d);else{if(l)if("center"===c)Zt(u,{x:i/2,y:s/2},l);else switch(ee(u,l),l){case 90:$t(u,s,0);break;case 180:$t(u,i,s);break;case 270:$t(u,0,i)}jt.x=e.x+a,jt.y=e.y+n,$t(u,jt.x,jt.y),r&&Jt(u,jt,r,o)}t.transform=u}},{toPoint:ce}=I,{hasTransparent:he}=G,ue={},fe={};function ge(t,e,i,s){if(i){let a,n,r,o;for(let t=0,l=i.length;t<l;t++)a=i[t],L(a)?(r=t/(l-1),n=G.string(a,s)):(r=a.offset,n=G.string(a.color,s)),e.addColorStop(r,n),!o&&he(n)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:pe,getDistance:_e}=W,{get:me,rotateOfOuter:we,scaleOfOuter:ye}=P,{toPoint:xe}=I,ve={},Se={};function be(t,e,i,s,a){let n;const{width:r,height:o}=t;if(r!==o||s){const t=pe(e,i);n=me(),a?(ye(n,e,r/o*(s||1),1),we(n,e,t+90)):(ye(n,e,1,r/o*(s||1)),we(n,e,t))}return n}const{getDistance:ke}=W,{toPoint:Be}=I,Re={},Ee={};const Te={linearGradient:function(t,i){let{from:s,to:a,type:n,opacity:r}=t;ce(s||"top",i,ue),ce(a||"bottom",i,fe);const o=e.canvas.createLinearGradient(ue.x,ue.y,fe.x,fe.y),l={type:n,style:o};return ge(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:a,type:n,opacity:r,stretch:o}=t;xe(s||"center",i,ve),xe(a||"bottom",i,Se);const l=e.canvas.createRadialGradient(ve.x,ve.y,0,ve.x,ve.y,_e(ve,Se)),d={type:n,style:l};ge(d,l,t.stops,r);const c=be(i,ve,Se,o,!0);return c&&(d.transform=c),d},conicGradient:function(t,i){let{from:s,to:a,type:n,opacity:r,rotation:o,stretch:l}=t;Be(s||"center",i,Re),Be(a||"bottom",i,Ee);const d=e.conicGradientSupport?e.canvas.createConicGradient(o?o*F:0,Re.x,Re.y):e.canvas.createRadialGradient(Re.x,Re.y,0,Re.x,Re.y,ke(Re,Ee)),c={type:n,style:d};ge(c,d,t.stops,r);const h=be(i,Re,Ee,l||1,e.conicGradientRotate90);return h&&(c.transform=h),c},getTransform:be},{copy:Le,move:Ae,toOffsetOutBounds:Pe}=B,{max:Ce,abs:Oe}=Math,We={},Me=new E,De={};function Ie(t,e){let i,s,a,n,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=1.5*(t.blur||0),a=Oe(t.spread||0),r=Ce(r,a+n-s),o=Ce(o,a+n+i),l=Ce(l,a+n+s),d=Ce(d,a+n-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Fe(t,i,s){const{shapeBounds:a}=s;let n,r;e.fullImageShadow?(Le(We,t.bounds),Ae(We,i.x-a.x,i.y-a.y),n=t.bounds,r=We):(n=a,r=i),t.copyWorld(s.canvas,n,r)}const{toOffsetOutBounds:Ye}=B,Xe={};const Ue=Ie;const Ge={shadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Pe(l,De,d),r.forEach((r,_)=>{let m=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(m=1/t)}g.setWorldShadow(De.offsetX+(r.x||0)*h*m,De.offsetY+(r.y||0)*u*m,(r.blur||0)*h*m,G.string(r.color)),a=z.getShadowTransform(t,g,i,r,De,m),a&&g.setTransform(a),Fe(g,De,i),a&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,n,"copy"),s=n),o?g.copyWorld(o,n,n,"destination-out"):g.copyWorld(i.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;Ye(l,Xe,d),r.forEach((r,_)=>{let m=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(m=1/t)}g.save(),g.setWorldShadow(Xe.offsetX+(r.x||0)*h*m,Xe.offsetY+(r.y||0)*u*m,(r.blur||0)*h*m),a=z.getShadowTransform(t,g,i,r,Xe,m,!0),a&&g.setTransform(a),Fe(g,Xe,i),g.restore(),o?(g.copyWorld(g,d,n,"copy"),g.copyWorld(o,n,n,"source-out"),s=n):(g.copyWorld(i.canvas,c,l,"source-out"),s=d),g.fillWorld(s,G.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,r.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Ie,getShadowTransform:function(t,e,i,s,a,n,r){if(s.spread){const i=2*s.spread*n*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Me.set().scaleOfOuter({x:(a.x+a.width/2)*e.pixelRatio,y:(a.y+a.height/2)*e.pixelRatio},1+i/o,1+i/l),Me}},isTransformShadow(t){},getInnerShadowSpread:Ue},{excludeRenderBounds:qe}=p;let ze;function Ne(t,e,i,s,a,n,r,o){switch(e){case"grayscale":ze||(ze=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,a,n){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),n&&s.recycle(r);He(t,e,i,1,a,n)}(t,i,s,a,r,o);break;case"opacity-path":He(t,i,s,n,r,o);break;case"path":o&&i.restore()}}function je(t){return t.getSameCanvas(!1,!0)}function He(t,e,i,s,a,n){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,a),n?i.recycle(r):i.clearWorld(r)}N.prototype.__renderMask=function(t,e){let i,s,a,n,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],o=i.__.mask,o){r&&(Ne(this,r,t,a,s,n,void 0,!0),s=a=null),"clipping"!==o&&"clipping-path"!==o||qe(i,e)||i.__render(t,e),n=i.__.opacity,ze=!1,"path"===o||"clipping-path"===o?(n<1?(r="opacity-path",a||(a=je(t))):(r="path",t.save()),i.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=je(t)),a||(a=je(t)),i.__render(s,e));continue}const c=1===n&&i.__.__blendMode;c&&Ne(this,r,t,a,s,n,void 0,!1),qe(i,e)||i.__render(a||t,e),c&&Ne(this,r,t,a,s,n,c,!1)}Ne(this,r,t,a,s,n,void 0,!0)};const Ve=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qe=Ve+"_#~&*+\\=|≮≯≈≠=…",Ze=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],[4352,4607],[12352,12447],[12448,12543],[12544,12591],[12592,12687],[12688,12703],[12704,12735],[12784,12799],[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("|"),"u");function $e(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Je=$e("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ke=$e("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ti=$e(Ve),ei=$e(Qe),ii=$e("- —/~|┆·");var si;!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"}(si||(si={}));const{Letter:ai,Single:ni,Before:ri,After:oi,Symbol:li,Break:di}=si;function ci(t){return Je[t]?ai:ii[t]?di:Ke[t]?ri:ti[t]?oi:ei[t]?li:Ze.test(t)?ni:ai}const hi={trimRight(t){const{words:e}=t;let i,s=0,a=e.length;for(let n=a-1;n>-1&&(i=e[n].data[0]," "===i.char);n--)s++,t.width-=i.width;s&&e.splice(a-s,s)}};function ui(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:fi}=hi,{Letter:gi,Single:pi,Before:_i,After:mi,Symbol:wi,Break:yi}=si;let xi,vi,Si,bi,ki,Bi,Ri,Ei,Ti,Li,Ai,Pi,Ci,Oi,Wi,Mi,Di,Ii=[];function Fi(t,e){Ti&&!Ei&&(Ei=Ti),xi.data.push({char:t,width:e}),Si+=e}function Yi(t){t&&(bi+=t,xi.addWidth=t),bi+=Si,xi.width=Si,vi.words.push(xi),xi={data:[]},Si=0}function Xi(){Oi&&(Wi.paraNumber++,vi.paraStart=!0,Oi=!1),Ti&&(vi.startCharSize=Ei,vi.endCharSize=Ti,Ei=0),vi.width=bi,Mi.width?fi(vi):Di&&Ui(),Ii.push(vi),vi={words:[]},bi=0}function Ui(){bi>(Wi.maxWidth||0)&&(Wi.maxWidth=bi)}const{top:Gi,right:qi,bottom:zi,left:Ni}=Y;function ji(t,e,i){const{bounds:s,rows:a}=t;s[e]+=i;for(let t=0;t<a.length;t++)a[t][e]+=i}const Hi={getDrawData:function(t,i){L(t)||(t=String(t));let s=0,a=0,n=i.__getInput("width")||0,r=i.__getInput("height")||0;const{__padding:o}=i;i.motionText&&(n=r=0),o&&(n?(s=o[Ni],n-=o[qi]+o[Ni],!n&&(n=.01)):i.autoSizeAlign||(s=o[Ni]),r?(a=o[Gi],r-=o[Gi]+o[zi],!r&&(r=.01)):i.autoSizeAlign||(a=o[Gi]));const l={bounds:{x:s,y:a,width:n,height:r},rows:[],paraNumber:0,font:e.canvas.font=i.__font};return function(t,i,s){Wi=t,Ii=t.rows,Mi=t.bounds,Di=!Mi.width&&!s.autoSizeAlign;const{paraIndent:a,textCase:n}=s,{canvas:r}=e,{width:o}=Mi;if(s.__isCharMode){const t="none"!==s.textWrap,e="break"===s.textWrap,l=s.__letterSpacing,d=s.__wordSpacing;Oi=!0,Ai=null,Ei=Ri=Ti=Si=bi=0,xi={data:[]},vi={words:[]};for(let s=0,c=(i=[...i]).length;s<c;s++)Bi=i[s],"\n"===Bi?(Si&&Yi(),vi.paraEnd=!0,Xi(),Oi=!0):(Li=ci(Bi),Li===gi&&"none"!==n&&(Bi=ui(Bi,n,!Si)),Ri=r.measureText(Bi).width,l&&(l<0&&(Ti=Ri),Ri+=l),Pi=Li===pi&&(Ai===pi||Ai===gi)||Ai===pi&&Li!==mi,Ci=!(Li!==_i&&Li!==pi||Ai!==wi&&Ai!==mi),ki=Oi&&a?o-a:o,t&&o&&bi+Si+Ri>ki&&(e?(Si&&Yi(),bi&&Xi()):(Ci||(Ci=Li===gi&&Ai==mi),Pi||Ci||Li===yi||Li===_i||Li===pi||Si+Ri>ki?(Si&&Yi(),bi&&Xi()):bi&&Xi()))," "===Bi&&!0!==Oi&&bi+Si===0||(Li===yi?(" "===Bi&&Si&&Yi(d),Fi(Bi,Ri),Yi()):Pi||Ci?(Si&&Yi(d),Fi(Bi,Ri)):Fi(Bi,Ri)),Ai=Li);Si&&Yi(),bi&&Xi(),Ii.length>0&&(Ii[Ii.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Wi.paraNumber++,bi=r.measureText(t).width,Ii.push({x:a||0,text:t,width:bi,paraStart:!0}),Di&&Ui()})}(l,t,i),o&&function(t,e,i,s,a){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ji(e,"x",t[Ni]);break;case"right":ji(e,"x",-t[qi])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ji(e,"y",t[Gi]);break;case"bottom":ji(e,"y",-t[zi])}}(o,l,i,n,r),function(t,e){const{rows:i,bounds:s}=t,a=i.length,{__lineHeight:n,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,m=n*a+(h?h*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(e.__autoHeight?m:_,n),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":g+=(_-m)/2;break;case"bottom":g+=_-m}w+=g;let y,x,v,S=p||u?p:t.maxWidth;for(let r=0,c=a;r<c;r++){if(y=i[r],y.x=f,y.width<p||y.width>p&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(w+=h),y.y=w,w+=n,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),x=y.x,v=y.width,o<0&&(y.width<0?(v=-y.width+e.fontSize+o,x-=v,v+=e.fontSize):v-=o),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&p&&p<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=m}(l,i),i.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:a,paraIndent:n}=e,r=e.__letterSpacing||e.motionText,o=e.__wordSpacing,l=i&&a.includes("both"),d=l||i&&a.includes("justify"),c=d&&a.includes("letter");let h,u,f,g,p,_,m,w,y,x;s.forEach(t=>{t.words&&(p=n&&t.paraStart?n:0,w=t.words.length,d&&(x=!t.paraEnd||l,u=i-t.width-p,c?g=u/(t.words.reduce((t,e)=>t+e.data.length,0)-1):f=w>1?u/(w-1):0),_=r||t.isOverflow||c?0:f||o?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===_?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,h=t.x,t.data=[],t.words.forEach((e,i)=>{1===_?(m={char:"",x:h},h=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,h,m),(t.isOverflow||" "!==m.char)&&t.data.push(m)):h=function(t,e,i,s,a){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,a&&(e+=a)}),e}(e.data,h,t.data,t.isOverflow,x&&g),e.addWidth&&(h+=e.addWidth),x&&(y=i===w-1,f?y||(h+=f,t.width+=f):g&&(t.width+=g*(e.data.length-(y?1:0))))})),t.words=null)})}(l,i,n),l.overflow&&function(t,i,s,a){const{rows:n,overflow:r}=t;let{textOverflow:o}=i;if(r&&n.splice(r),a&&o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,c=s+a-d;("none"===i.textWrap?n:[n[r-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<c));s--){if(l<c&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,e.data.push({char:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(l,i,s,n),"none"!==i.textDecoration&&function(t,e){let i,s=0;const{fontSize:a,textDecoration:n}=e;switch(t.decorationHeight=a/11,k(n)?(i=n.type,n.color&&(t.decorationColor=G.string(n.color)),n.offset&&(s=Math.min(.3*a,Math.max(n.offset,.15*-a)))):i=n,i){case"under":t.decorationY=[.15*a+s];break;case"delete":t.decorationY=[.35*-a];break;case"under-delete":t.decorationY=[.15*a+s,.35*-a]}}(l,i),l}};const Vi={string:function(t,e){if(!t)return"#000";const i=M(e)&&e<1;if(L(t)){if(!i||!G.object)return t;t=G.object(t)}let s=T(t.a)?1:t.a;i&&(s*=e);const a=t.r+","+t.g+","+t.b;return 1===s?"rgb("+a+")":"rgba("+a+","+s+")"}};Object.assign(j,Hi),Object.assign(G,Vi),Object.assign(X,At),Object.assign(U,de),Object.assign(q,Te),Object.assign(z,Ge),Z();export{ht as Layouter,at as LayouterHelper,Q as LeaferCanvas,H as PathNodeHandleType,ft as Renderer,J as Watcher,Z as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map