@leafer-ui/worker 1.9.7 → 1.9.8

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.
@@ -1,4 +1,4 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, BoundsHelper, Plugin, isObject, Matrix, isUndefined, isString, getMatrixData, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4, isNumber } from "@leafer/core";
1
+ import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, BoundsHelper, Plugin, isObject, FourNumberHelper, Matrix, isUndefined, isString, getMatrixData, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4, isNumber } from "@leafer/core";
2
2
 
3
3
  export * from "@leafer/core";
4
4
 
@@ -8,7 +8,7 @@ import { HitCanvasManager, InteractionBase } from "@leafer-ui/core";
8
8
 
9
9
  export * from "@leafer-ui/core";
10
10
 
11
- import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Effect, Group, TextConvert } from "@leafer-ui/draw";
11
+ import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Group, TextConvert, Effect } from "@leafer-ui/draw";
12
12
 
13
13
  class LeaferCanvas extends LeaferCanvasBase {
14
14
  get allowBackgroundColor() {
@@ -433,6 +433,7 @@ class Renderer {
433
433
  usePartRender: true,
434
434
  maxFPS: 120
435
435
  };
436
+ this.frames = [];
436
437
  this.target = target;
437
438
  this.canvas = canvas;
438
439
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -585,12 +586,15 @@ class Renderer {
585
586
  const target = this.target;
586
587
  if (this.requestTime || !target) return;
587
588
  if (target.parentApp) return target.parentApp.requestRender(false);
588
- const requestTime = this.requestTime = Date.now();
589
+ this.requestTime = this.frameTime || Date.now();
589
590
  const render = () => {
590
- const nowFPS = 1e3 / (Date.now() - requestTime);
591
+ const nowFPS = 1e3 / ((this.frameTime = Date.now()) - this.requestTime);
591
592
  const {maxFPS: maxFPS} = this.config;
592
- if (maxFPS && nowFPS > maxFPS - .5) return Platform.requestRender(render);
593
- this.FPS = Math.min(120, Math.ceil(nowFPS));
593
+ if (maxFPS && nowFPS > maxFPS) return Platform.requestRender(render);
594
+ const {frames: frames} = this;
595
+ if (frames.length > 30) frames.shift();
596
+ frames.push(nowFPS);
597
+ this.FPS = Math.round(frames.reduce((a, b) => a + b, 0) / frames.length);
594
598
  this.requestTime = 0;
595
599
  this.checkRender();
596
600
  };
@@ -1040,24 +1044,29 @@ function drawOutside(stroke, ui, canvas) {
1040
1044
  }
1041
1045
  }
1042
1046
 
1043
- const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = BoundsHelper;
1047
+ const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
1048
+
1049
+ const tempBounds$1 = {};
1044
1050
 
1045
1051
  function shape(ui, current, options) {
1046
1052
  const canvas = current.getSameCanvas();
1047
- const nowWorld = ui.__nowWorld, currentBounds = current.bounds;
1048
- let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
1053
+ const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
1054
+ const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
1055
+ toOuterOf(layout.strokeSpread ? (copyAndSpread(tempBounds$1, layout.boxBounds, layout.strokeSpread),
1056
+ tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
1057
+ let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
1049
1058
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
1050
- if (currentBounds.includes(nowWorld)) {
1059
+ if (currentBounds.includes(nowWorldShapeBounds)) {
1051
1060
  worldCanvas = canvas;
1052
- bounds = shapeBounds = nowWorld;
1061
+ bounds = shapeBounds = nowWorldShapeBounds;
1062
+ renderBounds = nowWorld;
1053
1063
  } else {
1054
- const {renderShapeSpread: spread} = ui.__layout;
1055
1064
  let worldClipBounds;
1056
1065
  if (Platform.fullImageShadow) {
1057
- worldClipBounds = nowWorld;
1066
+ worldClipBounds = nowWorldShapeBounds;
1058
1067
  } else {
1059
- const spreadBounds = spread ? getSpread(currentBounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : currentBounds;
1060
- worldClipBounds = getIntersectData(spreadBounds, nowWorld);
1068
+ const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds;
1069
+ worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds);
1061
1070
  }
1062
1071
  fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
1063
1072
  let {a: fitScaleX, d: fitScaleY} = fitMatrix;
@@ -1067,8 +1076,10 @@ function shape(ui, current, options) {
1067
1076
  scaleX *= fitScaleX;
1068
1077
  scaleY *= fitScaleY;
1069
1078
  }
1070
- shapeBounds = getOuterOf(nowWorld, fitMatrix);
1079
+ shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix);
1071
1080
  bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
1081
+ renderBounds = getOuterOf(nowWorld, fitMatrix);
1082
+ move$1(renderBounds, -fitMatrix.e, -fitMatrix.f);
1072
1083
  const userMatrix = options.matrix;
1073
1084
  if (userMatrix) {
1074
1085
  matrix = new Matrix(fitMatrix);
@@ -1087,6 +1098,7 @@ function shape(ui, current, options) {
1087
1098
  matrix: matrix,
1088
1099
  fitMatrix: fitMatrix,
1089
1100
  bounds: bounds,
1101
+ renderBounds: renderBounds,
1090
1102
  worldCanvas: worldCanvas,
1091
1103
  shapeBounds: shapeBounds,
1092
1104
  scaleX: scaleX,
@@ -1190,7 +1202,7 @@ const PaintModule = {
1190
1202
  shape: shape
1191
1203
  };
1192
1204
 
1193
- let origin = {}, tempMatrix = getMatrixData();
1205
+ let origin = {}, tempMatrix$1 = getMatrixData();
1194
1206
 
1195
1207
  const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
1196
1208
 
@@ -1205,12 +1217,12 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1205
1217
  data.transform = transform;
1206
1218
  }
1207
1219
 
1208
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
1220
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
1209
1221
  const transform = get$3();
1210
1222
  layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
1211
- if (clipSize) {
1212
- tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
1213
- multiplyParent(transform, tempMatrix);
1223
+ if (clipScaleX) {
1224
+ tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
1225
+ multiplyParent(transform, tempMatrix$1);
1214
1226
  }
1215
1227
  data.transform = transform;
1216
1228
  }
@@ -1311,7 +1323,12 @@ function getPatternData(paint, box, image) {
1311
1323
 
1312
1324
  case "normal":
1313
1325
  case "clip":
1314
- if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
1326
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
1327
+ let clipScaleX, clipScaleY;
1328
+ if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
1329
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
1330
+ if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
1331
+ }
1315
1332
  break;
1316
1333
 
1317
1334
  case "repeat":
@@ -1469,7 +1486,7 @@ function ignoreRender(ui, value) {
1469
1486
 
1470
1487
  const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
1471
1488
 
1472
- const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
1489
+ const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
1473
1490
 
1474
1491
  function createPattern(ui, paint, pixelRatio) {
1475
1492
  let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
@@ -1518,8 +1535,8 @@ function createPattern(ui, paint, pixelRatio) {
1518
1535
  if (transform || scaleX !== 1 || scaleY !== 1) {
1519
1536
  const canvasWidth = width + (xGap || 0);
1520
1537
  const canvasHeight = height + (yGap || 0);
1521
- scaleX /= canvasWidth / max(floor(canvasWidth), 1);
1522
- scaleY /= canvasHeight / max(floor(canvasHeight), 1);
1538
+ scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
1539
+ scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
1523
1540
  if (!imageMatrix) {
1524
1541
  imageMatrix = get$1();
1525
1542
  if (transform) copy$1(imageMatrix, transform);
@@ -1578,17 +1595,15 @@ function checkImage(ui, canvas, paint, allowDraw) {
1578
1595
  if (allowDraw) {
1579
1596
  if (data.repeat) {
1580
1597
  allowDraw = false;
1581
- } else {
1582
- if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
1583
- let {width: width, height: height} = data;
1584
- width *= scaleX * pixelRatio;
1585
- height *= scaleY * pixelRatio;
1586
- if (data.scaleX) {
1587
- width *= data.scaleX;
1588
- height *= data.scaleY;
1589
- }
1590
- allowDraw = width * height > Platform.image.maxCacheSize;
1598
+ } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
1599
+ let {width: width, height: height} = data;
1600
+ width *= scaleX * pixelRatio;
1601
+ height *= scaleY * pixelRatio;
1602
+ if (data.scaleX) {
1603
+ width *= data.scaleX;
1604
+ height *= data.scaleY;
1591
1605
  }
1606
+ allowDraw = width * height > Platform.image.maxCacheSize;
1592
1607
  }
1593
1608
  }
1594
1609
  if (allowDraw) {
@@ -1768,20 +1783,20 @@ const PaintGradientModule = {
1768
1783
  getTransform: getTransform
1769
1784
  };
1770
1785
 
1771
- const {copy: copy, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper;
1786
+ const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
1772
1787
 
1773
- const tempBounds = {};
1788
+ const tempBounds = {}, tempMatrix = new Matrix;
1774
1789
 
1775
1790
  const offsetOutBounds$1 = {};
1776
1791
 
1777
1792
  function shadow(ui, current, shape) {
1778
- let copyBounds, spreadScale;
1779
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
1793
+ let copyBounds, transform;
1794
+ const {__nowWorld: nowWorld} = ui;
1780
1795
  const {shadow: shadow} = ui.__;
1781
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
1796
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
1782
1797
  const other = current.getSameCanvas();
1783
1798
  const end = shadow.length - 1;
1784
- toOffsetOutBounds$1(bounds, offsetOutBounds$1);
1799
+ toOffsetOutBounds$1(bounds, offsetOutBounds$1, renderBounds);
1785
1800
  shadow.forEach((item, index) => {
1786
1801
  let otherScale = 1;
1787
1802
  if (item.scaleFixed) {
@@ -1789,54 +1804,61 @@ function shadow(ui, current, shape) {
1789
1804
  if (sx > 1) otherScale = 1 / sx;
1790
1805
  }
1791
1806
  other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
1792
- spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
1793
- drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
1794
- copyBounds = bounds;
1807
+ transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
1808
+ if (transform) other.setTransform(transform);
1809
+ drawWorldShadow(other, offsetOutBounds$1, shape);
1810
+ if (transform) other.resetTransform();
1811
+ copyBounds = renderBounds;
1795
1812
  if (item.box) {
1796
1813
  other.restore();
1797
1814
  other.save();
1798
1815
  if (worldCanvas) {
1799
- other.copyWorld(other, bounds, nowWorld, "copy");
1816
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
1800
1817
  copyBounds = nowWorld;
1801
1818
  }
1802
1819
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
1803
1820
  }
1804
- if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1821
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1805
1822
  if (end && index < end) other.clearWorld(copyBounds);
1806
1823
  });
1807
1824
  other.recycle(copyBounds);
1808
1825
  }
1809
1826
 
1810
- function getShadowSpread(_ui, shadow) {
1811
- let width = 0;
1812
- shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
1813
- return width;
1827
+ function getShadowRenderSpread(_ui, shadow) {
1828
+ let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
1829
+ shadow.forEach(item => {
1830
+ x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
1831
+ top = max(top, spread + blur - y);
1832
+ right = max(right, spread + blur + x);
1833
+ bottom = max(bottom, spread + blur + y);
1834
+ left = max(left, spread + blur - x);
1835
+ });
1836
+ return top === right && right === bottom && bottom === left ? top : [ top, right, bottom, left ];
1837
+ }
1838
+
1839
+ function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
1840
+ if (shadow.spread) {
1841
+ const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
1842
+ tempMatrix.set().scaleOfOuter({
1843
+ x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
1844
+ y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
1845
+ }, spreadScale);
1846
+ return tempMatrix;
1847
+ }
1848
+ return undefined;
1814
1849
  }
1815
1850
 
1816
- function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
1817
- const {bounds: bounds, shapeBounds: shapeBounds} = shape;
1851
+ function drawWorldShadow(canvas, outBounds, shape) {
1852
+ const {shapeBounds: shapeBounds} = shape;
1853
+ let from, to;
1818
1854
  if (Platform.fullImageShadow) {
1819
1855
  copy(tempBounds, canvas.bounds);
1820
- tempBounds.x += outBounds.x - shapeBounds.x;
1821
- tempBounds.y += outBounds.y - shapeBounds.y;
1822
- if (spreadScale) {
1823
- const {fitMatrix: fitMatrix} = shape;
1824
- tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
1825
- tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
1826
- tempBounds.width *= spreadScale;
1827
- tempBounds.height *= spreadScale;
1828
- }
1829
- canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
1856
+ move(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
1857
+ from = canvas.bounds, to = tempBounds;
1830
1858
  } else {
1831
- if (spreadScale) {
1832
- copy(tempBounds, outBounds);
1833
- tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
1834
- tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
1835
- tempBounds.width *= spreadScale;
1836
- tempBounds.height *= spreadScale;
1837
- }
1838
- canvas.copyWorld(shape.canvas, shapeBounds, spreadScale ? tempBounds : outBounds);
1859
+ from = shapeBounds, to = outBounds;
1839
1860
  }
1861
+ canvas.copyWorld(shape.canvas, from, to);
1840
1862
  }
1841
1863
 
1842
1864
  const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
@@ -1844,13 +1866,13 @@ const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
1844
1866
  const offsetOutBounds = {};
1845
1867
 
1846
1868
  function innerShadow(ui, current, shape) {
1847
- let copyBounds, spreadScale;
1848
- const {__nowWorld: nowWorld, __layout: __layout} = ui;
1869
+ let copyBounds, transform;
1870
+ const {__nowWorld: nowWorld} = ui;
1849
1871
  const {innerShadow: innerShadow} = ui.__;
1850
- const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
1872
+ const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
1851
1873
  const other = current.getSameCanvas();
1852
1874
  const end = innerShadow.length - 1;
1853
- toOffsetOutBounds(bounds, offsetOutBounds);
1875
+ toOffsetOutBounds(bounds, offsetOutBounds, renderBounds);
1854
1876
  innerShadow.forEach((item, index) => {
1855
1877
  let otherScale = 1;
1856
1878
  if (item.scaleFixed) {
@@ -1859,16 +1881,17 @@ function innerShadow(ui, current, shape) {
1859
1881
  }
1860
1882
  other.save();
1861
1883
  other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
1862
- spreadScale = item.spread ? 1 - item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
1863
- drawWorldShadow(other, offsetOutBounds, spreadScale, shape);
1884
+ transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
1885
+ if (transform) other.setTransform(transform);
1886
+ drawWorldShadow(other, offsetOutBounds, shape);
1864
1887
  other.restore();
1865
1888
  if (worldCanvas) {
1866
- other.copyWorld(other, bounds, nowWorld, "copy");
1889
+ other.copyWorld(other, renderBounds, nowWorld, "copy");
1867
1890
  other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
1868
1891
  copyBounds = nowWorld;
1869
1892
  } else {
1870
1893
  other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
1871
- copyBounds = bounds;
1894
+ copyBounds = renderBounds;
1872
1895
  }
1873
1896
  other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
1874
1897
  LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
@@ -1877,6 +1900,8 @@ function innerShadow(ui, current, shape) {
1877
1900
  other.recycle(copyBounds);
1878
1901
  }
1879
1902
 
1903
+ const getInnerShadowSpread = getShadowRenderSpread;
1904
+
1880
1905
  function blur(ui, current, origin) {
1881
1906
  const {blur: blur} = ui.__;
1882
1907
  origin.setWorldBlur(blur * ui.__nowWorld.a);
@@ -1891,10 +1916,12 @@ const EffectModule = {
1891
1916
  innerShadow: innerShadow,
1892
1917
  blur: blur,
1893
1918
  backgroundBlur: backgroundBlur,
1894
- getShadowSpread: getShadowSpread,
1919
+ getShadowRenderSpread: getShadowRenderSpread,
1920
+ getShadowTransform: getShadowTransform,
1895
1921
  isTransformShadow(_shadow) {
1896
1922
  return undefined;
1897
- }
1923
+ },
1924
+ getInnerShadowSpread: getInnerShadowSpread
1898
1925
  };
1899
1926
 
1900
1927
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
@@ -1911,6 +1938,7 @@ Group.prototype.__renderMask = function(canvas, options) {
1911
1938
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
1912
1939
  maskCanvas = contentCanvas = null;
1913
1940
  }
1941
+ if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
1914
1942
  maskOpacity = child.__.opacity;
1915
1943
  usedGrayscaleAlpha = false;
1916
1944
  if (mask === "path" || mask === "clipping-path") {
@@ -1928,7 +1956,6 @@ Group.prototype.__renderMask = function(canvas, options) {
1928
1956
  if (!contentCanvas) contentCanvas = getCanvas(canvas);
1929
1957
  child.__render(maskCanvas, options);
1930
1958
  }
1931
- if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
1932
1959
  continue;
1933
1960
  }
1934
1961
  const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
@@ -1,2 +1,2 @@
1
- import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as h,ChildEvent as d,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as k,BoundsHelper as B,Plugin as S,isObject as E,Matrix as R,isUndefined as L,isString as A,getMatrixData as T,MatrixHelper as C,MathHelper as M,AlignHelper as O,PointHelper as W,ImageEvent as P,AroundHelper as D,Direction4 as F,isNumber as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as Y,InteractionBase as z}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as U,Paint as G,ColorConvert as X,PaintGradient as q,Export as N,Effect as j,Group as H,TextConvert as V}from"@leafer-ui/draw";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}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:Z}=s;function $(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:Z(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:Z(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{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)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:J}=navigator;J.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),J.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):J.indexOf("Mac")>-1?e.os="Mac":J.indexOf("Linux")>-1&&(e.os="Linux");class K{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){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.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=!0,this.running&&this.target.emit(h.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===d.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[d.ADD,d.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:tt,updateBounds:et,updateChange:it}=f,{pushAllChildBranch:st,pushAllParent:nt}=g;const{worldBounds:at}=p;class rt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new o(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,at)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,at),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:ot,updateAllChange:lt}=f,ht=y.get("Layouter");class dt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,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){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(tt(t,!0),e.add(t),t.isBranch&&st(t,e),nt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),nt(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||et(s[t])}et(i)}})}(this.__levelList),function(t){t.list.forEach(it)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,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:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),dt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),lt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new rt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new rt(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],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=y.get("Renderer");class ut{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},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.__requestRender()}requestLayout(){this.target.emit(x.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(h.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(h.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(h.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,ct.log(e.innerName,"---\x3e");try{this.emitRender(h.START),this.renderOnce(t),this.emitRender(h.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(h.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(h.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(h.RENDER,this.renderBounds,this.renderOptions),this.emitRender(h.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),n=new _(s);i.save(),s.spread(ut.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),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}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(s,t),e.render(this.target,s,a),this.renderBounds=i=i||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const i=this.requestTime=Date.now(),s=()=>{const t=1e3/(Date.now()-i),{maxFPS:n}=this.config;if(n&&t>n-.5)return e.requestRender(s);this.FPS=Math.min(120,Math.ceil(t)),this.requestTime=0,this.checkRender()};e.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new h(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[h.REQUEST,this.update,this],[x.END,this.__onLayoutEnd,this],[h.AGAIN,this.renderAgain,this],[k.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}ut.clipSpread=10;const{hitRadiusPoint:ft}=B;class gt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n),h=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:h,target:l,throughPath:r.length?this.getThroughPath(r):h}:{path:h,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new o;if(t.length){let e;const{x:n,y:a}=this.point,r={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){s.reset();break}return s.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),s.length)return s.list[0];return i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||ft(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:a}=s;for(let s=0,r=a.length;s<r;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class pt{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new gt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):S.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function _t(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function wt(t,e){t.__.__font?_t(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function yt(t,e,i){switch(e.__.strokeAlign){case"center":mt(t,1,e,i);break;case"inside":xt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?mt(t,2,e,i):xt(t,"outside",e,i)}}function mt(t,e,i,s){const n=i.__;E(t)?bt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),vt(i,s))}function xt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,mt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",_t(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function vt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function bt(t,e,i,s,n){let a;const r=s.__,{__hasMultiStrokeStyle:o}=r;o||n.setStroke(void 0,r.__strokeWidth*e,r);for(let l=0,h=t.length;l<h;l++)if(a=t[l],(!a.image||!U.checkImage(s,n,a,!1))&&a.style){if(o){const{strokeStyle:t}=a;t?n.setStroke(a.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(a.style,r.__strokeWidth*e,r)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?vt(s,n):n.stroke(),n.restoreBlendMode()):i?vt(s,n):n.stroke()}}function kt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)yt(t,e,i);else switch(s.strokeAlign){case"center":Bt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Bt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Bt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Bt(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function Bt(t,e,i,s){const n=i.__;E(t)?bt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&G.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new K(t,e),layouter:(t,e)=>new dt(t,e),renderer:(t,e,i)=>new ut(t,e,i),selector:(t,e)=>new pt(t,e)}),e.layout=dt.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:St,getOuterOf:Et,getByMove:Rt,getIntersectData:Lt}=B;let At;const{stintSet:Tt}=l,{hasTransparent:Ct}=X;function Mt(t,e,i){if(!E(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=U.image(i,t,e,n,!At||!At[e.url]);break;case"linear":s=q.linearGradient(e,n);break;case"radial":s=q.radialGradient(e,n);break;case"angular":s=q.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:X.string(r,o)};break;default:L(e.r)||(s={type:"solid",style:X.string(e)})}if(s){if(A(s.style)&&Ct(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Ot={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];w(o)||(o=[o]),At=U.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Mt(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Tt(i,"__isAlphaPixelFill",n),Tt(i,"__isTransparentFill",a)):(Tt(i,"__isAlphaPixelStroke",n),Tt(i,"__isTransparentStroke",a),Tt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,wt(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(U.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),wt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),wt(e,i),i.restoreBlendMode()):wt(e,i)}},fillPathOrText:wt,fillText:_t,stroke:kt,strokes:function(t,e,i){kt(t,e,i)},strokeText:yt,drawTextStroke:vt,shape:function(t,i,s){const n=i.getSameCanvas(),a=t.__nowWorld,r=i.bounds;let o,l,h,d,c,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(r.includes(a))c=n,o=d=a;else{const{renderShapeSpread:n}=t.__layout;let g;if(e.fullImageShadow)g=a;else{const t=n?St(r,u===f?n*u:[n*f,n*u]):r;g=Lt(t,a)}h=r.getFitMatrix(g);let{a:p,d:_}=h;h.a<1&&(c=i.getSameCanvas(),t.__renderShape(c,s),u*=p,f*=_),d=Et(a,h),o=Rt(d,-h.e,-h.f);const w=s.matrix;w?(l=new R(h),l.multiply(w),p*=w.scaleX,_*=w.scaleY):l=h,l.withScale(p,_),s=Object.assign(Object.assign({},s),{matrix:l})}return t.__renderShape(n,s),{canvas:n,matrix:l,fitMatrix:h,bounds:o,worldCanvas:c,shapeBounds:d,scaleX:u,scaleY:f}}};let Wt={},Pt=T();const{get:Dt,rotateOfOuter:Ft,translate:It,scaleOfOuter:Yt,multiplyParent:zt,scale:Ut,rotate:Gt,skew:Xt}=C;function qt(t,e,i,s,n,a,r){const o=Dt();It(o,e.x+i,e.y+s),Ut(o,n,a),r&&Ft(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Nt(t,e,i,s,n,a,r,o,l){const h=Dt();Ht(h,e,i,s,n,a,r,o),l&&(Pt.a=e.width/l.width,Pt.d=e.height/l.height,zt(h,Pt)),t.transform=h}function jt(t,e,i,s,n,a,r,o,l,h,d,c){const u=Dt();if(c)Ht(u,e,n,a,r,o,l,h);else{if(l)if("center"===d)Ft(u,{x:i/2,y:s/2},l);else switch(Gt(u,l),l){case 90:It(u,s,0);break;case 180:It(u,i,s);break;case 270:It(u,0,i)}Wt.x=e.x+n,Wt.y=e.y+a,It(u,Wt.x,Wt.y),r&&Yt(u,Wt,r,o)}t.transform=u}function Ht(t,e,i,s,n,a,r,o){r&&Gt(t,r),o&&Xt(t,o.x,o.y),n&&Ut(t,n,a),It(t,e.x+i,e.y+s)}const{get:Vt,translate:Qt}=C,Zt=new _,$t={},Jt={};function Kt(t,e,i,s){const{changeful:n,sync:a,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=te(i,s,e)}function te(t,e,i){t.padding&&(e=Zt.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:h,size:d,rotation:c,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,w=e.width===s&&e.height===n,y={mode:r},m="center"!==o&&(c||0)%180==90;let x,v;switch(B.set(Jt,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((h||d)&&(M.getScaleData(h,d,i,$t),x=$t.scaleX,v=$t.scaleY),(o||p||g)&&(x&&B.scale(Jt,x,v,!0),o&&O.toPoint(o,Jt,e,Jt,!0,!0))):w&&!c||(x=v=B.getFitScale(e,Jt,"fit"!==r),B.put(e,i,o,x,!1,Jt),B.scale(Jt,x,v,!0)),l&&W.move(Jt,l),r){case"stretch":w||(s=e.width,n=e.height);break;case"normal":case"clip":(Jt.x||Jt.y||x||f||c||u)&&Nt(y,e,Jt.x,Jt.y,x,v,c,u,t.clipSize);break;case"repeat":(!w||x||c||u)&&jt(y,e,s,n,Jt.x,Jt.y,x,v,c,u,o,t.freeTransform),g||(y.repeat="repeat");const i=E(g);(p||i)&&(y.gap=function(t,e,i,s,n){let a,r;E(t)?(a=t.x,r=t.y):a=r=t;return{x:ee(a,i,n.width,e&&e.x),y:ee(r,s,n.height,e&&e.y)}}(p,i&&g,Jt.width,Jt.height,e));break;default:x&&qt(y,e,Jt.x,Jt.y,x,v,c)}return y.transform||(e.x||e.y)&&(y.transform=Vt(),Qt(y.transform,e.x,e.y)),x&&"stretch"!==r&&(y.scaleX=x,y.scaleY=v),y.width=s,y.height=n,a&&(y.opacity=a),_&&(y.filters=_),g&&(y.repeat=A(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function ee(t,e,i,s){const n=A(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let ie,se=new _;const{isSame:ne}=B;function ae(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Kt(n,s,i,a),!0}function re(t,e){he(t,P.LOAD,e)}function oe(t,e){he(t,P.LOADED,e)}function le(t,e,i){e.error=i,t.forceUpdate("surface"),he(t,P.ERROR,e)}function he(t,e,i){t.hasEvent(e)&&t.emitEvent(new P(e,i))}function de(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:ce,scale:ue,copy:fe}=C,{floor:ge,ceil:pe,max:_e,abs:we}=Math;function ye(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{const{image:o,data:l}=i;let h,d,{width:c,height:u,scaleX:f,scaleY:g,transform:p,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=we(f),g=we(g),d=ce(),fe(d,p),ue(d,1/f,1/g),n*=f,a*=g),c*=n,u*=a;const y=c*u;if(!_&&y>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(o.isSVG){const t=c/o.width;t>1&&(h=t/pe(t))}else{const t=o.width*o.height;m>t&&(m=t)}y>m&&(h=Math.sqrt(y/m)),h&&(n/=h,a/=h,c/=h,u/=h),f&&(n/=f,a/=g);const x=w&&w.x*n,v=w&&w.y*a;if(p||1!==n||1!==a){const t=c+(x||0),e=u+(v||0);n/=t/_e(ge(t),1),a/=e/_e(ge(e),1),d||(d=ce(),p&&fe(d,p)),ue(d,1/n,1/a)}const b=o.getCanvas(c,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),k=o.getPattern(b,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=k,i.patternId=r,!0}}function me(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(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"==typeof SuppressedError&&SuppressedError;const xe={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return ie&&i===ie.paint&&ne(s,ie.boxBounds)?a=ie.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),ie=o.use>1?{leafPaint:a,paint:i,boxBounds:se.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(ae(t,e,i,o,a,s),n&&(re(t,r),oe(t,r))):o.error?n&&le(t,r,o.error):(n&&(de(t,!0),re(t,r)),a.loadId=o.load(()=>{de(t,!1),t.destroyed||(ae(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),oe(t,r)),a.loadId=void 0},e=>{de(t,!1),le(t,r,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!N.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&k.isResizing(t)||N.running)){let{width:t,height:i}=l;t*=a*o,i*=r*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||N.running?ye(t,s,o):s.patternTask||(s.patternTask=b.patternTasker.add(()=>me(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ye(t,s,o),t.forceUpdate("surface")}),300)),!1)},createPattern:ye,recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,n,a,r,o;for(let l=0,h=i.length;l<h;l++)s=i[l],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,b.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),n.unload(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:Kt,getPatternData:te,fillOrFitMode:qt,clipMode:Nt,repeatMode:jt},{toPoint:ve}=D,{hasTransparent:be}=X,ke={},Be={};function Se(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],A(n)?(r=t/(l-1),a=X.string(n,s)):(r=n.offset,a=X.string(n.color,s)),e.addColorStop(r,a),!o&&be(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Ee,getDistance:Re}=W,{get:Le,rotateOfOuter:Ae,scaleOfOuter:Te}=C,{toPoint:Ce}=D,Me={},Oe={};function We(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=Ee(e,i);a=Le(),n?(Te(a,e,r/o*(s||1),1),Ae(a,e,t+90)):(Te(a,e,1,r/o*(s||1)),Ae(a,e,t))}return a}const{getDistance:Pe}=W,{toPoint:De}=D,Fe={},Ie={};const Ye={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;ve(s||"top",i,ke),ve(n||"bottom",i,Be);const o=e.canvas.createLinearGradient(ke.x,ke.y,Be.x,Be.y),l={type:a,style:o};return Se(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Ce(s||"center",i,Me),Ce(n||"bottom",i,Oe);const l=e.canvas.createRadialGradient(Me.x,Me.y,0,Me.x,Me.y,Re(Me,Oe)),h={type:a,style:l};Se(h,l,t.stops,r);const d=We(i,Me,Oe,o,!0);return d&&(h.transform=d),h},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;De(s||"center",i,Fe),De(n||"bottom",i,Ie);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Fe.x,Fe.y):e.canvas.createRadialGradient(Fe.x,Fe.y,0,Fe.x,Fe.y,Pe(Fe,Ie)),h={type:a,style:l};Se(h,l,t.stops,r);const d=We(i,Fe,Ie,o||1,e.conicGradientRotate90);return d&&(h.transform=d),h},getTransform:We},{copy:ze,toOffsetOutBounds:Ue}=B,Ge={},Xe={};function qe(t,i,s,n){const{bounds:a,shapeBounds:r}=n;if(e.fullImageShadow){if(ze(Ge,t.bounds),Ge.x+=i.x-r.x,Ge.y+=i.y-r.y,s){const{fitMatrix:t}=n;Ge.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),Ge.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),Ge.width*=s,Ge.height*=s}t.copyWorld(n.canvas,t.bounds,Ge)}else s&&(ze(Ge,i),Ge.x-=i.width/2*(s-1),Ge.y-=i.height/2*(s-1),Ge.width*=s,Ge.height*=s),t.copyWorld(n.canvas,r,s?Ge:i)}const{toOffsetOutBounds:Ne}=B,je={};const He={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{shadow:o}=t.__,{worldCanvas:l,bounds:h,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=o.length-1;Ue(h,Xe),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.setWorldShadow(Xe.offsetX+o.x*c*w,Xe.offsetY+o.y*u*w,o.blur*c*w,X.string(o.color)),n=o.spread?1+2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*w:0,qe(g,Xe,n,i),s=h,o.box&&(g.restore(),g.save(),l&&(g.copyWorld(g,h,a,"copy"),s=a),l?g.copyWorld(l,a,a,"destination-out"):g.copyWorld(i.canvas,d,h,"destination-out")),j.isTransformShadow(o)?j.renderTransformShadow(t,e,g,s,o):f.copyCanvasByWorld(t,e,g,s,o.blendMode),p&&_<p&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:r}=t,{innerShadow:o}=t.__,{worldCanvas:l,bounds:h,shapeBounds:d,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=o.length-1;Ne(h,je),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(je.offsetX+o.x*c*w,je.offsetY+o.y*u*w,o.blur*c*w),n=o.spread?1-2*o.spread/(r.boxBounds.width+2*(r.strokeBoxSpread||0))*w:0,qe(g,je,n,i),g.restore(),l?(g.copyWorld(g,h,a,"copy"),g.copyWorld(l,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,d,h,"source-out"),s=h),g.fillWorld(s,X.string(o.color),"source-in"),f.copyCanvasByWorld(t,e,g,s,o.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){},getShadowSpread:function(t,e){let i=0;return e.forEach(t=>i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread>0?t.spread:0)+1.5*t.blur)),i},isTransformShadow(t){}},{excludeRenderBounds:Ve}=p;let Qe;function Ze(t,e,i,s,n,a,r,o){switch(e){case"grayscale":Qe||(Qe=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);Je(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":Je(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function $e(t){return t.getSameCanvas(!1,!0)}function Je(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}H.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let h=0,d=l.length;h<d;h++){if(i=l[h],o=i.__.mask,o){r&&(Ze(this,r,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,Qe=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=$e(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=$e(t)),n||(n=$e(t)),i.__render(s,e)),"clipping"!==o&&"clipping-path"!==o||Ve(i,e)||i.__render(t,e);continue}const d=1===a&&i.__.__blendMode;d&&Ze(this,r,t,n,s,a,void 0,!1),Ve(i,e)||i.__render(n||t,e),d&&Ze(this,r,t,n,s,a,d,!1)}Ze(this,r,t,n,s,a,void 0,!0)};const Ke=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ti=Ke+"_#~&*+\\=|≮≯≈≠=…",ei=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 ii(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const si=ii("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ni=ii("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ai=ii(Ke),ri=ii(ti),oi=ii("- —/~|┆·");var li;!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"}(li||(li={}));const{Letter:hi,Single:di,Before:ci,After:ui,Symbol:fi,Break:gi}=li;function pi(t){return si[t]?hi:oi[t]?gi:ni[t]?ci:ai[t]?ui:ri[t]?fi:ei.test(t)?di:hi}const _i={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function wi(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:yi}=_i,{Letter:mi,Single:xi,Before:vi,After:bi,Symbol:ki,Break:Bi}=li;let Si,Ei,Ri,Li,Ai,Ti,Ci,Mi,Oi,Wi,Pi,Di,Fi,Ii,Yi,zi,Ui,Gi=[];function Xi(t,e){Oi&&!Mi&&(Mi=Oi),Si.data.push({char:t,width:e}),Ri+=e}function qi(){Li+=Ri,Si.width=Ri,Ei.words.push(Si),Si={data:[]},Ri=0}function Ni(){Ii&&(Yi.paraNumber++,Ei.paraStart=!0,Ii=!1),Oi&&(Ei.startCharSize=Mi,Ei.endCharSize=Oi,Mi=0),Ei.width=Li,zi.width?yi(Ei):Ui&&ji(),Gi.push(Ei),Ei={words:[]},Li=0}function ji(){Li>(Yi.maxWidth||0)&&(Yi.maxWidth=Li)}const{top:Hi,right:Vi,bottom:Qi,left:Zi}=F;function $i(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Ji={getDrawData:function(t,i){A(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:h}=i;h&&(a?(s=h[Zi],a-=h[Vi]+h[Zi]):i.autoSizeAlign||(s=h[Zi]),r?(n=h[Hi],r-=h[Hi]+h[Qi]):i.autoSizeAlign||(n=h[Hi]));const d={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Yi=t,Gi=t.rows,zi=t.bounds,Ui=!zi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:h}=zi;if(l||h||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Ii=!0,Pi=null,Mi=Ci=Oi=Ri=Li=0,Si={data:[]},Ei={words:[]},n&&(i=[...i]);for(let s=0,h=i.length;s<h;s++)Ti=i[s],"\n"===Ti?(Ri&&qi(),Ei.paraEnd=!0,Ni(),Ii=!0):(Wi=pi(Ti),Wi===mi&&"none"!==r&&(Ti=wi(Ti,r,!Ri)),Ci=o.measureText(Ti).width,n&&(n<0&&(Oi=Ci),Ci+=n),Di=Wi===xi&&(Pi===xi||Pi===mi)||Pi===xi&&Wi!==bi,Fi=!(Wi!==vi&&Wi!==xi||Pi!==ki&&Pi!==bi),Ai=Ii&&a?l-a:l,t&&l&&Li+Ri+Ci>Ai&&(e?(Ri&&qi(),Li&&Ni()):(Fi||(Fi=Wi===mi&&Pi==bi),Di||Fi||Wi===Bi||Wi===vi||Wi===xi||Ri+Ci>Ai?(Ri&&qi(),Li&&Ni()):Li&&Ni()))," "===Ti&&!0!==Ii&&Li+Ri===0||(Wi===Bi?(" "===Ti&&Ri&&qi(),Xi(Ti,Ci),qi()):Di||Fi?(Ri&&qi(),Xi(Ti,Ci)):Xi(Ti,Ci)),Pi=Wi);Ri&&qi(),Li&&Ni(),Gi.length>0&&(Gi[Gi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Yi.paraNumber++,Li=o.measureText(t).width,Gi.push({x:a||0,text:t,width:Li,paraStart:!0}),Ui&&ji()})}(d,t,i),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":$i(e,"x",t[Zi]);break;case"right":$i(e,"x",-t[Vi])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":$i(e,"y",t[Hi]);break;case"bottom":$i(e,"y",-t[Qi])}}(h,d,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:h,verticalAlign:d,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(d){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,d=n;r<d;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(h){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.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&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(d,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,h,d,c,u;s.forEach(t=>{t.words&&(h=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-h)/(u-1):0,d=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===d?(t.x+=h,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=h,o=t.x,t.data=[],t.words.forEach((e,i)=>{1===d?(c={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(d,i,a),d.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const h=o?e.canvas.measureText(o).width:0,d=s+n-h;("none"===i.textWrap?a:[a[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<d));s--){if(l<d&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=h,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)}})}}(d,i,s,a),"none"!==o&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,E(a)?(i=a.type,a.color&&(t.decorationColor=X.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(d,i),d}};const Ki={string:function(t,e){const i=I(e)&&e<1;if(A(t)){if(!i||!X.object)return t;t=X.object(t)}let s=L(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(V,Ji),Object.assign(X,Ki),Object.assign(G,Ot),Object.assign(U,xe),Object.assign(q,Ye),Object.assign(j,He),Object.assign(n,{interaction:(t,e,i,s)=>new z(t,e,i,s),hitCanvas:(t,e)=>new Q(t,e),hitCanvasManager:()=>new Y}),$();export{dt as Layouter,Q as LeaferCanvas,gt as Picker,ut as Renderer,pt as Selector,K as Watcher,$ as useCanvas};
1
+ import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as r,LeafList as o,DataHelper as l,RenderEvent as d,ChildEvent as h,WatchEvent as c,PropertyEvent as u,LeafHelper as f,BranchHelper as g,LeafBoundsHelper as p,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as x,Run as v,ImageManager as b,ResizeEvent as k,BoundsHelper as B,Plugin as S,isObject as E,FourNumberHelper as R,Matrix as L,isUndefined as A,isString as T,getMatrixData as C,MatrixHelper as O,MathHelper as W,AlignHelper as P,PointHelper as M,ImageEvent as D,AroundHelper as F,Direction4 as I,isNumber as Y}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{HitCanvasManager as z,InteractionBase as U}from"@leafer-ui/core";export*from"@leafer-ui/core";import{PaintImage as G,Paint as X,ColorConvert as q,PaintGradient as N,Export as j,Group as H,TextConvert as V,Effect as Q}from"@leafer-ui/draw";class Z 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}}i(OffscreenCanvasRenderingContext2D.prototype),i(Path2D.prototype);const{mineType:$}=s;function J(t,i){e.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise((s,n)=>{t.convertToBlob({type:$(e),quality:i}).then(t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)}).catch(t=>{n(t)})}),canvasToBolb:(t,e,i)=>t.convertToBlob({type:$(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise(t=>t()),download(t,e){},loadImage:t=>new Promise((i,s)=>{let n=new XMLHttpRequest;n.open("GET",e.image.getRealURL(t),!0),n.responseType="blob",n.onload=()=>{createImageBitmap(n.response).then(t=>{i(t)}).catch(t=>{s(t)})},n.onerror=t=>s(t),n.send()})},e.canvas=n.canvas(),e.conicGradientSupport=!!e.canvas.context.createConicGradient}Object.assign(n,{canvas:(t,e)=>new Z(t,e),image:t=>new a(t)}),e.name="web",e.isWorker=!0,e.backgrounder=!0,e.requestRender=function(t){requestAnimationFrame(t)},r(e,"devicePixelRatio",{get:()=>1});const{userAgent:K}=navigator;K.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),K.indexOf("Windows")>-1?(e.os="Windows",e.intWheelDeltaY=!0):K.indexOf("Mac")>-1?e.os="Mac":K.indexOf("Linux")>-1&&(e.os="Linux");class tt{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){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.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=!0,this.running&&this.target.emit(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===h.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new c(c.DATA,{updatedList:this.updatedList})),this.__updatedList=new o,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[h.ADD,h.REMOVE],this.__onChildEvent,this],[c.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:et,updateBounds:it,updateChange:st}=f,{pushAllChildBranch:nt,pushAllParent:at}=g;const{worldBounds:rt}=p;class ot{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(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,ht=y.get("Layouter");class ct{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,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){ht.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ht.warn("layouting"):this.times>3?ht.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(c.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=v.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=x,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new x(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(et(t,!0),e.add(t),t.isBranch&&nt(t,e),at(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),at(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||it(s[t])}it(i)}})}(this.__levelList),function(t){t.list.forEach(st)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new x(a,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:n}=x,a=this.getBlocks(new o(e));e.emitEvent(new x(i,a,this.times)),ct.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new x(s,a,this.times)),e.emitEvent(new x(n,a,this.times)),this.addBlocks(a),v.end(t)}static fullLayout(t){lt(t,!0),t.isBranch?g.updateBounds(t):f.updateBounds(t),dt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new ot([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}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],[c.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ut=y.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,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.__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),b.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),n=new _(s);i.save(),s.spread(ft.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),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}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),y.showRepaint&&y.drawRepaint(s,t),e.render(this.target,s,a),this.renderBounds=i=i||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;e.setList(t),t.length=0,t.push(e)}}__requestRender(){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:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.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;t.updatedList&&t.updatedList.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)})}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],[k.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}ft.clipSpread=10;const{hitRadiusPoint:gt}=B;class pt{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1,a=i.target||this.target;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=new o(i.findList),i.findList||this.hitBranch(a.isBranchLeaf?{children:[a]}:a);const{list:r}=this.findList,l=this.getBestMatchLeaf(r,i.bottomList,n),d=n?this.getPath(l):this.getHitablePath(l);return this.clear(),s?{path:d,target:l,throughPath:r.length?this.getThroughPath(r):d}:{path:d,target:l}}hitPoint(t,e,i){return!!this.getByPoint(t,e,i).target}getBestMatchLeaf(t,e,i){const s=this.findList=new o;if(t.length){let e;const{x:n,y:a}=this.point,r={x:n,y:a,radiusX:0,radiusY:0};for(let n=0,a=t.length;n<a;n++)if(e=t[n],(i||f.worldHittable(e))&&(this.hitChild(e,r),s.length)){if(e.isBranchLeaf&&t.some(t=>t!==e&&f.hasParent(t,e))){s.reset();break}return s.list[0]}}if(e)for(let t=0,i=e.length;t<i;t++)if(this.hitChild(e[t].target,this.point,e[t].proxy),s.length)return s.list[0];return i?t[0]:t.find(t=>f.worldHittable(t))}getPath(t){const e=new o;for(;t;)e.add(t),t=t.parent;return this.target&&e.add(this.target),e}getHitablePath(t){const e=this.getPath(t&&t.hittable?t:null);let i,s=new o;for(let t=e.list.length-1;t>-1&&(i=e.list[t],i.__.hittable)&&(s.addAt(i,0),i.__.hitChildren&&(!i.isLeafer||"draw"!==i.mode));t--);return s}getThroughPath(t){const e=new o,i=[];for(let e=t.length-1;e>-1;e--)i.push(this.getPath(t[e]));let s,n,a;for(let t=0,r=i.length;t<r;t++){s=i[t],n=i[t+1];for(let t=0,i=s.length;t<i&&(a=s.list[t],!n||!n.has(a));t++)e.add(a)}return e}hitBranch(t){this.eachFind(t.children,t.__onlyHitMask)}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.mask||(s=!!i.__.hitRadius||gt(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(i.topChildren&&this.eachFind(i.topChildren,!1),this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e,i){if((!this.exclude||!this.exclude.has(t))&&t.__hitWorld(e)){const{parent:s}=t;if(s&&s.__hasMask&&!t.__.mask){let i,n=[];const{children:a}=s;for(let s=0,r=a.length;s<r;s++)if(i=a[s],i.__.mask&&n.push(i),i===t){if(n&&!n.every(t=>t.__hitWorld(e)))return;break}}this.findList.add(i||t)}}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}class _t{constructor(t,e){this.config={},e&&(this.config=l.default(e,this.config)),this.picker=new pt(this.target=t,this),this.finder=n.finder&&n.finder()}getByPoint(t,i,s){const{target:n,picker:a}=this;return e.backgrounder&&n&&n.updateLayout(),a.getByPoint(t,i,s)}hitPoint(t,e,i){return this.picker.hitPoint(t,e,i)}getBy(t,e,i,s){return this.finder?this.finder.getBy(t,e,i,s):S.need("find")}destroy(){this.picker.destroy(),this.finder&&this.finder.destroy()}}function wt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function yt(t,e){t.__.__font?wt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function mt(t,e,i){switch(e.__.strokeAlign){case"center":xt(t,1,e,i);break;case"inside":vt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?xt(t,2,e,i):vt(t,"outside",e,i)}}function xt(t,e,i,s){const n=i.__;E(t)?kt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),bt(i,s))}function vt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,xt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",wt(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function bt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function kt(t,e,i,s,n){let a;const r=s.__,{__hasMultiStrokeStyle:o}=r;o||n.setStroke(void 0,r.__strokeWidth*e,r);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!G.checkImage(s,n,a,!1))&&a.style){if(o){const{strokeStyle:t}=a;t?n.setStroke(a.style,r.__getRealStrokeWidth(t)*e,r,t):n.setStroke(a.style,r.__strokeWidth*e,r)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?bt(s,n):n.stroke(),n.restoreBlendMode()):i?bt(s,n):n.stroke()}}function Bt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)mt(t,e,i);else switch(s.strokeAlign){case"center":St(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),St(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)St(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),St(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function St(t,e,i,s){const n=i.__;E(t)?kt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&X.strokeArrow(t,i,s)}Object.assign(n,{watcher:(t,e)=>new tt(t,e),layouter:(t,e)=>new ct(t,e),renderer:(t,e,i)=>new ft(t,e,i),selector:(t,e)=>new _t(t,e)}),e.layout=ct.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:Et,copyAndSpread:Rt,toOuterOf:Lt,getOuterOf:At,getByMove:Tt,move:Ct,getIntersectData:Ot}=B,Wt={};let Pt;const{stintSet:Mt}=l,{hasTransparent:Dt}=q;function Ft(t,e,i){if(!E(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=G.image(i,t,e,n,!Pt||!Pt[e.url]);break;case"linear":s=N.linearGradient(e,n);break;case"radial":s=N.radialGradient(e,n);break;case"angular":s=N.conicGradient(e,n);break;case"solid":const{type:a,color:r,opacity:o}=e;s={type:a,style:q.string(r,o)};break;default:A(e.r)||(s={type:"solid",style:q.string(e)})}if(s){if(T(s.style)&&Dt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const It={compute:function(t,e){const i=e.__,s=[];let n,a,r,o=i.__input[t];w(o)||(o=[o]),Pt=G.recycleImage(t,i);for(let i,n=0,a=o.length;n<a;n++)(i=Ft(t,o[n],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Mt(i,"__isAlphaPixelFill",n),Mt(i,"__isTransparentFill",a)):(Mt(i,"__isAlphaPixelStroke",n),Mt(i,"__isTransparentStroke",a),Mt(i,"__hasMultiStrokeStyle",r))},fill:function(t,e,i){i.fillStyle=t,yt(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(G.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),yt(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),yt(e,i),i.restoreBlendMode()):yt(e,i)}},fillPathOrText:yt,fillText:wt,stroke:Bt,strokes:function(t,e,i){Bt(t,e,i)},strokeText:mt,drawTextStroke:bt,shape:function(t,i,s){const n=i.getSameCanvas(),a=i.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,h,c,u,f,g;Lt(o.strokeSpread?(Rt(Wt,o.boxBounds,o.strokeSpread),Wt):o.boxBounds,r,l);let{scaleX:p,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))g=n,d=f=l,h=r;else{let n;if(e.fullImageShadow)n=l;else{const t=o.renderShapeSpread?Et(a,R.swapAndScale(o.renderShapeSpread,p,_)):a;n=Ot(t,l)}u=a.getFitMatrix(n);let{a:w,d:y}=u;u.a<1&&(g=i.getSameCanvas(),t.__renderShape(g,s),p*=w,_*=y),f=At(l,u),d=Tt(f,-u.e,-u.f),h=At(r,u),Ct(h,-u.e,-u.f);const m=s.matrix;m?(c=new L(u),c.multiply(m),w*=m.scaleX,y*=m.scaleY):c=u,c.withScale(w,y),s=Object.assign(Object.assign({},s),{matrix:c})}return t.__renderShape(n,s),{canvas:n,matrix:c,fitMatrix:u,bounds:d,renderBounds:h,worldCanvas:g,shapeBounds:f,scaleX:p,scaleY:_}}};let Yt={},zt=C();const{get:Ut,rotateOfOuter:Gt,translate:Xt,scaleOfOuter:qt,multiplyParent:Nt,scale:jt,rotate:Ht,skew:Vt}=O;function Qt(t,e,i,s,n,a,r){const o=Ut();Xt(o,e.x+i,e.y+s),jt(o,n,a),r&&Gt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Zt(t,e,i,s,n,a,r,o,l,d){const h=Ut();Jt(h,e,i,s,n,a,r,o),l&&(zt.a=l,zt.d=d,Nt(h,zt)),t.transform=h}function $t(t,e,i,s,n,a,r,o,l,d,h,c){const u=Ut();if(c)Jt(u,e,n,a,r,o,l,d);else{if(l)if("center"===h)Gt(u,{x:i/2,y:s/2},l);else switch(Ht(u,l),l){case 90:Xt(u,s,0);break;case 180:Xt(u,i,s);break;case 270:Xt(u,0,i)}Yt.x=e.x+n,Yt.y=e.y+a,Xt(u,Yt.x,Yt.y),r&&qt(u,Yt,r,o)}t.transform=u}function Jt(t,e,i,s,n,a,r,o){r&&Ht(t,r),o&&Vt(t,o.x,o.y),n&&jt(t,n,a),Xt(t,e.x+i,e.y+s)}const{get:Kt,translate:te}=O,ee=new _,ie={},se={};function ne(t,e,i,s){const{changeful:n,sync:a,scaleFixed:r}=i;n&&(t.changeful=n),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=ae(i,s,e)}function ae(t,e,i){t.padding&&(e=ee.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:r,align:o,offset:l,scale:d,size:h,rotation:c,skew:u,clipSize:f,repeat:g,gap:p,filters:_}=t,w=e.width===s&&e.height===n,y={mode:r},m="center"!==o&&(c||0)%180==90;let x,v;switch(B.set(se,0,0,m?n:s,m?s:n),r&&"cover"!==r&&"fit"!==r?((d||h)&&(W.getScaleData(d,h,i,ie),x=ie.scaleX,v=ie.scaleY),(o||p||g)&&(x&&B.scale(se,x,v,!0),o&&P.toPoint(o,se,e,se,!0,!0))):w&&!c||(x=v=B.getFitScale(e,se,"fit"!==r),B.put(e,i,o,x,!1,se),B.scale(se,x,v,!0)),l&&M.move(se,l),r){case"stretch":w||(s=e.width,n=e.height);break;case"normal":case"clip":if(se.x||se.y||x||f||c||u){let t,i;f&&(t=e.width/f.width,i=e.height/f.height),Zt(y,e,se.x,se.y,x,v,c,u,t,i),t&&(x=x?x*t:x,v=v?v*i:i)}break;case"repeat":(!w||x||c||u)&&$t(y,e,s,n,se.x,se.y,x,v,c,u,o,t.freeTransform),g||(y.repeat="repeat");const i=E(g);(p||i)&&(y.gap=function(t,e,i,s,n){let a,r;E(t)?(a=t.x,r=t.y):a=r=t;return{x:re(a,i,n.width,e&&e.x),y:re(r,s,n.height,e&&e.y)}}(p,i&&g,se.width,se.height,e));break;default:x&&Qt(y,e,se.x,se.y,x,v,c)}return y.transform||(e.x||e.y)&&(y.transform=Kt(),te(y.transform,e.x,e.y)),x&&"stretch"!==r&&(y.scaleX=x,y.scaleY=v),y.width=s,y.height=n,a&&(y.opacity=a),_&&(y.filters=_),g&&(y.repeat=T(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function re(t,e,i,s){const n=T(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let oe,le=new _;const{isSame:de}=B;function he(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||ne(n,s,i,a),!0}function ce(t,e){ge(t,D.LOAD,e)}function ue(t,e){ge(t,D.LOADED,e)}function fe(t,e,i){e.error=i,t.forceUpdate("surface"),ge(t,D.ERROR,e)}function ge(t,e,i){t.hasEvent(e)&&t.emitEvent(new D(e,i))}function pe(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:_e,scale:we,copy:ye}=O,{floor:me,ceil:xe,max:ve,abs:be}=Math;function ke(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const r=n+"-"+a+"-"+s;if(i.patternId===r||t.destroyed)return!1;{const{image:o,data:l}=i;let d,h,{width:c,height:u,scaleX:f,scaleY:g,transform:p,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=be(f),g=be(g),h=_e(),ye(h,p),we(h,1/f,1/g),n*=f,a*=g),c*=n,u*=a;const y=c*u;if(!_&&y>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(o.isSVG){const t=c/o.width;t>1&&(d=t/xe(t))}else{const t=o.width*o.height;m>t&&(m=t)}y>m&&(d=Math.sqrt(y/m)),d&&(n/=d,a/=d,c/=d,u/=d),f&&(n/=f,a/=g);const x=w&&w.x*n,v=w&&w.y*a;if(p||1!==n||1!==a){const t=c+(x||0),e=u+(v||0);n/=t/ve(me(t),1),a/=e/ve(me(e),1),h||(h=_e(),p&&ye(h,p)),we(h,1/n,1/a)}const b=o.getCanvas(c,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),k=o.getPattern(b,_||e.origin.noRepeat||"no-repeat",h,i);return i.style=k,i.patternId=r,!0}}function Be(t,e,i,s){return new(i||(i=Promise))(function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(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"==typeof SuppressedError&&SuppressedError;const Se={image:function(t,e,i,s,n){let a,r;const o=b.get(i);return oe&&i===oe.paint&&de(s,oe.boxBounds)?a=oe.leafPaint:(a={type:i.type,image:o},o.hasAlphaPixel&&(a.isTransparent=!0),oe=o.use>1?{leafPaint:a,paint:i,boxBounds:le.set(s)}:null),(n||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(he(t,e,i,o,a,s),n&&(ce(t,r),ue(t,r))):o.error?n&&fe(t,r,o.error):(n&&(pe(t,!0),ce(t,r)),a.loadId=o.load(()=>{pe(t,!1),t.destroyed||(he(t,e,i,o,a,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ue(t,r)),a.loadId=void 0},e=>{pe(t,!1),fe(t,r,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),a},checkImage:function(t,i,s,n){const{scaleX:a,scaleY:r}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:o}=i,{data:l}=s;if(!l||s.patternId===a+"-"+r+"-"+o&&!j.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&k.isResizing(t)||j.running)){let{width:t,height:i}=l;t*=a*o,i*=r*o,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,i,s,l),!0):(!s.style||s.sync||j.running?ke(t,s,o):s.patternTask||(s.patternTask=b.patternTasker.add(()=>Be(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&ke(t,s,o),t.forceUpdate("surface")}),300)),!1)},createPattern:ke,recycleImage:function(t,e){const i=e["_"+t];if(w(i)){let s,n,a,r,o;for(let l=0,d=i.length;l<d;l++)s=i[l],n=s.image,o=n&&n.url,o&&(a||(a={}),a[o]=!0,b.recycle(n),n.loading&&(r||(r=e.__input&&e.__input[t]||[],w(r)||(r=[r])),n.unload(i[l].loadId,!r.some(t=>t.url===o))));return a}return null},createData:ne,getPatternData:ae,fillOrFitMode:Qt,clipMode:Zt,repeatMode:$t},{toPoint:Ee}=F,{hasTransparent:Re}=q,Le={},Ae={};function Te(t,e,i,s){if(i){let n,a,r,o;for(let t=0,l=i.length;t<l;t++)n=i[t],T(n)?(r=t/(l-1),a=q.string(n,s)):(r=n.offset,a=q.string(n.color,s)),e.addColorStop(r,a),!o&&Re(a)&&(o=!0);o&&(t.isTransparent=!0)}}const{getAngle:Ce,getDistance:Oe}=M,{get:We,rotateOfOuter:Pe,scaleOfOuter:Me}=O,{toPoint:De}=F,Fe={},Ie={};function Ye(t,e,i,s,n){let a;const{width:r,height:o}=t;if(r!==o||s){const t=Ce(e,i);a=We(),n?(Me(a,e,r/o*(s||1),1),Pe(a,e,t+90)):(Me(a,e,1,r/o*(s||1)),Pe(a,e,t))}return a}const{getDistance:ze}=M,{toPoint:Ue}=F,Ge={},Xe={};const qe={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:r}=t;Ee(s||"top",i,Le),Ee(n||"bottom",i,Ae);const o=e.canvas.createLinearGradient(Le.x,Le.y,Ae.x,Ae.y),l={type:a,style:o};return Te(l,o,t.stops,r),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;De(s||"center",i,Fe),De(n||"bottom",i,Ie);const l=e.canvas.createRadialGradient(Fe.x,Fe.y,0,Fe.x,Fe.y,Oe(Fe,Ie)),d={type:a,style:l};Te(d,l,t.stops,r);const h=Ye(i,Fe,Ie,o,!0);return h&&(d.transform=h),d},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:r,stretch:o}=t;Ue(s||"center",i,Ge),Ue(n||"bottom",i,Xe);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ge.x,Ge.y):e.canvas.createRadialGradient(Ge.x,Ge.y,0,Ge.x,Ge.y,ze(Ge,Xe)),d={type:a,style:l};Te(d,l,t.stops,r);const h=Ye(i,Ge,Xe,o||1,e.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ye},{copy:Ne,move:je,toOffsetOutBounds:He}=B,{max:Ve}=Math,Qe={},Ze=new L,$e={};function Je(t,e){let i,s,n,a,r=0,o=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=t.spread||0,a=1.5*(t.blur||0),r=Ve(r,n+a-s),o=Ve(o,n+a+i),l=Ve(l,n+a+s),d=Ve(d,n+a-i)}),r===o&&o===l&&l===d?r:[r,o,l,d]}function Ke(t,e,i,s,n,a,r){if(s.spread){const i=1+2*s.spread/t.__layout.strokeBounds.width*a*(r?-1:1);return Ze.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},i),Ze}}function ti(t,i,s){const{shapeBounds:n}=s;let a,r;e.fullImageShadow?(Ne(Qe,t.bounds),je(Qe,i.x-n.x,i.y-n.y),a=t.bounds,r=Qe):(a=n,r=i),t.copyWorld(s.canvas,a,r)}const{toOffsetOutBounds:ei}=B,ii={};const si=Je;const ni={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;He(l,$e,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.setWorldShadow($e.offsetX+r.x*c*w,$e.offsetY+r.y*u*w,r.blur*c*w,q.string(r.color)),n=Ke(t,g,i,r,$e,w),n&&g.setTransform(n),ti(g,$e,i),n&&g.resetTransform(),s=d,r.box&&(g.restore(),g.save(),o&&(g.copyWorld(g,d,a,"copy"),s=a),o?g.copyWorld(o,a,a,"destination-out"):g.copyWorld(i.canvas,h,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,n;const{__nowWorld:a}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:d,shapeBounds:h,scaleX:c,scaleY:u}=i,g=e.getSameCanvas(),p=r.length-1;ei(l,ii,d),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(ii.offsetX+r.x*c*w,ii.offsetY+r.y*u*w,r.blur*c*w),n=Ke(t,g,0,r,ii,w,!0),n&&g.setTransform(n),ti(g,ii,i),g.restore(),o?(g.copyWorld(g,d,a,"copy"),g.copyWorld(o,a,a,"source-out"),s=a):(g.copyWorld(i.canvas,h,l,"source-out"),s=d),g.fillWorld(s,q.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:Je,getShadowTransform:Ke,isTransformShadow(t){},getInnerShadowSpread:si},{excludeRenderBounds:ai}=p;let ri;function oi(t,e,i,s,n,a,r,o){switch(e){case"grayscale":ri||(ri=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),a&&s.recycle(r);di(t,e,i,1,n,a)}(t,i,s,n,r,o);break;case"opacity-path":di(t,i,s,a,r,o);break;case"path":o&&i.restore()}}function li(t){return t.getSameCanvas(!1,!0)}function di(t,e,i,s,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,n),a?i.recycle(r):i.clearWorld(r)}H.prototype.__renderMask=function(t,e){let i,s,n,a,r,o;const{children:l}=this;for(let d=0,h=l.length;d<h;d++){if(i=l[d],o=i.__.mask,o){r&&(oi(this,r,t,n,s,a,void 0,!0),s=n=null),"clipping"!==o&&"clipping-path"!==o||ai(i,e)||i.__render(t,e),a=i.__.opacity,ri=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",n||(n=li(t))):(r="path",t.save()),i.__clip(n||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=li(t)),n||(n=li(t)),i.__render(s,e));continue}const h=1===a&&i.__.__blendMode;h&&oi(this,r,t,n,s,a,void 0,!1),ai(i,e)||i.__render(n||t,e),h&&oi(this,r,t,n,s,a,h,!1)}oi(this,r,t,n,s,a,void 0,!0)};const hi=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ci=hi+"_#~&*+\\=|≮≯≈≠=…",ui=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 fi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const gi=fi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),pi=fi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),_i=fi(hi),wi=fi(ci),yi=fi("- —/~|┆·");var mi;!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"}(mi||(mi={}));const{Letter:xi,Single:vi,Before:bi,After:ki,Symbol:Bi,Break:Si}=mi;function Ei(t){return gi[t]?xi:yi[t]?Si:pi[t]?bi:_i[t]?ki:wi[t]?Bi:ui.test(t)?vi:xi}const Ri={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function Li(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:Ai}=Ri,{Letter:Ti,Single:Ci,Before:Oi,After:Wi,Symbol:Pi,Break:Mi}=mi;let Di,Fi,Ii,Yi,zi,Ui,Gi,Xi,qi,Ni,ji,Hi,Vi,Qi,Zi,$i,Ji,Ki=[];function ts(t,e){qi&&!Xi&&(Xi=qi),Di.data.push({char:t,width:e}),Ii+=e}function es(){Yi+=Ii,Di.width=Ii,Fi.words.push(Di),Di={data:[]},Ii=0}function is(){Qi&&(Zi.paraNumber++,Fi.paraStart=!0,Qi=!1),qi&&(Fi.startCharSize=Xi,Fi.endCharSize=qi,Xi=0),Fi.width=Yi,$i.width?Ai(Fi):Ji&&ss(),Ki.push(Fi),Fi={words:[]},Yi=0}function ss(){Yi>(Zi.maxWidth||0)&&(Zi.maxWidth=Yi)}const{top:ns,right:as,bottom:rs,left:os}=I;function ls(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const ds={getDrawData:function(t,i){T(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,r=i.__getInput("height")||0;const{textDecoration:o,__font:l,__padding:d}=i;d&&(a?(s=d[os],a-=d[as]+d[os]):i.autoSizeAlign||(s=d[os]),r?(n=d[ns],r-=d[ns]+d[rs]):i.autoSizeAlign||(n=d[ns]));const h={bounds:{x:s,y:n,width:a,height:r},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Zi=t,Ki=t.rows,$i=t.bounds,Ji=!$i.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:r}=s,{canvas:o}=e,{width:l,height:d}=$i;if(l||d||n||"none"!==r){const t="none"!==s.textWrap,e="break"===s.textWrap;Qi=!0,ji=null,Xi=Gi=qi=Ii=Yi=0,Di={data:[]},Fi={words:[]},n&&(i=[...i]);for(let s=0,d=i.length;s<d;s++)Ui=i[s],"\n"===Ui?(Ii&&es(),Fi.paraEnd=!0,is(),Qi=!0):(Ni=Ei(Ui),Ni===Ti&&"none"!==r&&(Ui=Li(Ui,r,!Ii)),Gi=o.measureText(Ui).width,n&&(n<0&&(qi=Gi),Gi+=n),Hi=Ni===Ci&&(ji===Ci||ji===Ti)||ji===Ci&&Ni!==Wi,Vi=!(Ni!==Oi&&Ni!==Ci||ji!==Pi&&ji!==Wi),zi=Qi&&a?l-a:l,t&&l&&Yi+Ii+Gi>zi&&(e?(Ii&&es(),Yi&&is()):(Vi||(Vi=Ni===Ti&&ji==Wi),Hi||Vi||Ni===Mi||Ni===Oi||Ni===Ci||Ii+Gi>zi?(Ii&&es(),Yi&&is()):Yi&&is()))," "===Ui&&!0!==Qi&&Yi+Ii===0||(Ni===Mi?(" "===Ui&&Ii&&es(),ts(Ui,Gi),es()):Hi||Vi?(Ii&&es(),ts(Ui,Gi)):ts(Ui,Gi)),ji=Ni);Ii&&es(),Yi&&is(),Ki.length>0&&(Ki[Ki.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Zi.paraNumber++,Yi=o.measureText(t).width,Ki.push({x:a||0,text:t,width:Yi,paraStart:!0}),Ji&&ss()})}(h,t,i),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ls(e,"x",t[os]);break;case"right":ls(e,"x",-t[as])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ls(e,"y",t[ns]);break;case"bottom":ls(e,"y",-t[rs])}}(d,h,i,a,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:g,width:p,height:_}=s,w=a*n+(c?c*(t.paraNumber-1):0),y=r;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":g+=(_-w)/2;break;case"bottom":g+=_-w}y+=g;let m,x,v,b=p||u?p:t.maxWidth;for(let r=0,h=n;r<h;r++){if(m=i[r],m.x=f,m.width<p||m.width>p&&!l)switch(d){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&c&&r>0&&(y+=c),m.y=y,y+=a,t.overflow>r&&y>w&&(m.isOverflow=!0,t.overflow=r+1),x=m.x,v=m.width,o<0&&(m.width<0?(v=-m.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&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(h,i),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;s.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-d)/(u-1):0,h=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===h?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,o=t.x,t.data=[],t.words.forEach((e,i)=>{1===h?(c={char:"",x:o},o=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,o,c),(t.isOverflow||" "!==c.char)&&t.data.push(c)):o=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(h,i,a),h.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:r}=t;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?e.canvas.measureText(o).width:0,h=s+n-d;("none"===i.textWrap?a:[a[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<h));s--){if(l<h&&" "!==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)}})}}(h,i,s,a),"none"!==o&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,E(a)?(i=a.type,a.color&&(t.decorationColor=q.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(h,i),h}};const hs={string:function(t,e){const i=Y(e)&&e<1;if(T(t)){if(!i||!q.object)return t;t=q.object(t)}let s=A(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(V,ds),Object.assign(q,hs),Object.assign(X,It),Object.assign(G,Se),Object.assign(N,qe),Object.assign(Q,ni),Object.assign(n,{interaction:(t,e,i,s)=>new U(t,e,i,s),hitCanvas:(t,e)=>new Z(t,e),hitCanvasManager:()=>new z}),J();export{ct as Layouter,Z as LeaferCanvas,pt as Picker,ft as Renderer,_t as Selector,tt as Watcher,J as useCanvas};
2
2
  //# sourceMappingURL=worker.esm.min.js.map