leafer-draw 1.9.5 → 1.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.js CHANGED
@@ -344,7 +344,7 @@ var LeaferUI = function(exports) {
344
344
  };
345
345
  }
346
346
  const {sin: sin$5, cos: cos$5, acos: acos, sqrt: sqrt$3} = Math;
347
- const {float: float$1} = MathHelper;
347
+ const {float: float$2} = MathHelper;
348
348
  const tempPoint$3 = {};
349
349
  function getWorld() {
350
350
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), {
@@ -583,12 +583,12 @@ var LeaferUI = function(exports) {
583
583
  const cosR = c / scaleY;
584
584
  rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
585
585
  }
586
- const cosR = float$1(cos$5(rotation));
586
+ const cosR = float$2(cos$5(rotation));
587
587
  const sinR = sin$5(rotation);
588
- scaleX = float$1(scaleX), scaleY = float$1(scaleY);
589
- skewX = cosR ? float$1((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
590
- skewY = cosR ? float$1((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
591
- rotation = float$1(rotation / OneRadian);
588
+ scaleX = float$2(scaleX), scaleY = float$2(scaleY);
589
+ skewX = cosR ? float$2((c / scaleY + sinR) / cosR / OneRadian, 9) : 0;
590
+ skewY = cosR ? float$2((b / scaleX - sinR) / cosR / OneRadian, 9) : 0;
591
+ rotation = float$2(rotation / OneRadian);
592
592
  } else {
593
593
  scaleX = a;
594
594
  scaleY = d;
@@ -1085,7 +1085,7 @@ var LeaferUI = function(exports) {
1085
1085
  };
1086
1086
  const {tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$2} = TwoPointBoundsHelper;
1087
1087
  const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1088
- const {float: float, fourNumber: fourNumber} = MathHelper;
1088
+ const {float: float$1, fourNumber: fourNumber} = MathHelper;
1089
1089
  const {floor: floor$2, ceil: ceil$2} = Math;
1090
1090
  let right$1, bottom$1, boundsRight, boundsBottom;
1091
1091
  const point = {};
@@ -1262,10 +1262,10 @@ var LeaferUI = function(exports) {
1262
1262
  }
1263
1263
  },
1264
1264
  float(t, maxLength) {
1265
- t.x = float(t.x, maxLength);
1266
- t.y = float(t.y, maxLength);
1267
- t.width = float(t.width, maxLength);
1268
- t.height = float(t.height, maxLength);
1265
+ t.x = float$1(t.x, maxLength);
1266
+ t.y = float$1(t.y, maxLength);
1267
+ t.width = float$1(t.width, maxLength);
1268
+ t.height = float$1(t.height, maxLength);
1269
1269
  },
1270
1270
  add(t, bounds, isPoint) {
1271
1271
  right$1 = t.x + t.width;
@@ -5105,6 +5105,7 @@ var LeaferUI = function(exports) {
5105
5105
  LeaferEvent.STOP = "leafer.stop";
5106
5106
  LeaferEvent.RESTART = "leafer.restart";
5107
5107
  LeaferEvent.END = "leafer.end";
5108
+ LeaferEvent.UPDATE_MODE = "leafer.update_mode";
5108
5109
  LeaferEvent.TRANSFORM = "leafer.transform";
5109
5110
  LeaferEvent.MOVE = "leafer.move";
5110
5111
  LeaferEvent.SCALE = "leafer.scale";
@@ -6350,7 +6351,7 @@ var LeaferUI = function(exports) {
6350
6351
  this.levelMap = null;
6351
6352
  }
6352
6353
  }
6353
- const version = "1.9.5";
6354
+ const version = "1.9.6";
6354
6355
  const debug$4 = Debug.get("LeaferCanvas");
6355
6356
  class LeaferCanvas extends LeaferCanvasBase {
6356
6357
  set zIndex(zIndex) {
@@ -7490,8 +7491,6 @@ var LeaferUI = function(exports) {
7490
7491
  if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
7491
7492
  box.set(value);
7492
7493
  if (boxLayout.strokeChanged) layout.strokeChange();
7493
- if (boxLayout.renderChanged) layout.renderChange();
7494
- box.__updateChange();
7495
7494
  } else if (box) {
7496
7495
  t.__box = box.parent = null;
7497
7496
  box.destroy();
@@ -7558,7 +7557,7 @@ var LeaferUI = function(exports) {
7558
7557
  __updateRenderSpread() {
7559
7558
  let width = 0;
7560
7559
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7561
- if (shadow) 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));
7560
+ if (shadow) width = Effect.getShadowSpread(this, shadow);
7562
7561
  if (blur) width = Math.max(width, blur);
7563
7562
  if (filter) width += Filter.getSpread(filter);
7564
7563
  if (renderSpread) width += renderSpread;
@@ -7570,36 +7569,67 @@ var LeaferUI = function(exports) {
7570
7569
  return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
7571
7570
  }
7572
7571
  };
7572
+ const {float: float} = MathHelper;
7573
+ const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
7573
7574
  const DragBoundsHelper = {
7575
+ limitMove(leaf, move) {
7576
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7577
+ if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
7578
+ D.axisMove(leaf, move);
7579
+ },
7580
+ limitScaleOf(leaf, origin, scale) {
7581
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7582
+ if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
7583
+ },
7584
+ axisMove(leaf, move) {
7585
+ const {draggable: draggable} = leaf;
7586
+ if (draggable === "x") move.y = 0;
7587
+ if (draggable === "y") move.x = 0;
7588
+ },
7589
+ getDragBounds(leaf) {
7590
+ const {dragBounds: dragBounds} = leaf;
7591
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
7592
+ },
7593
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
7594
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
7595
+ },
7574
7596
  getValidMove(content, dragBounds, dragBoundsType, move, change) {
7575
7597
  const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
7576
7598
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
7577
7599
  if (!change) move = Object.assign({}, move);
7578
- const isBiggerWidth = content.width > dragBounds.width;
7579
- const isBiggerHeight = content.height > dragBounds.height;
7580
- if (isBiggerWidth && dragBoundsType !== "outer") {
7600
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7581
7601
  if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
7582
7602
  } else {
7583
7603
  if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
7584
7604
  }
7585
- if (isBiggerHeight && dragBoundsType !== "outer") {
7605
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7586
7606
  if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
7587
7607
  } else {
7588
7608
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
7589
7609
  }
7590
- move.x = MathHelper.float(move.x);
7591
- move.y = MathHelper.float(move.y);
7610
+ move.x = float(move.x);
7611
+ move.y = float(move.y);
7592
7612
  return move;
7593
7613
  },
7594
- axisMove(leaf, move) {
7595
- const {draggable: draggable} = leaf;
7596
- if (draggable === "x") move.y = 0;
7597
- if (draggable === "y") move.x = 0;
7598
- },
7599
- limitMove(leaf, move) {
7600
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7601
- if (dragBounds) D.getValidMove(leaf.__localBoxBounds, dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds, dragBoundsType, move, true);
7602
- D.axisMove(leaf, move);
7614
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
7615
+ if (!change) scale = Object.assign({}, scale);
7616
+ let fitScaleX, fitScaleY;
7617
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
7618
+ tempMerge.set(tempContent).add(dragBounds);
7619
+ tempIntersect.set(tempContent).intersect(dragBounds);
7620
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7621
+ fitScaleX = tempMerge.width / tempContent.width;
7622
+ } else {
7623
+ fitScaleX = tempIntersect.width / tempContent.width;
7624
+ }
7625
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7626
+ fitScaleY = tempMerge.height / tempContent.height;
7627
+ } else {
7628
+ fitScaleY = tempIntersect.height / tempContent.height;
7629
+ }
7630
+ scale.x = float(tempIntersect.width) ? scale.x * fitScaleX : 1;
7631
+ scale.y = float(tempIntersect.height) ? scale.y * fitScaleY : 1;
7632
+ return scale;
7603
7633
  }
7604
7634
  };
7605
7635
  const D = DragBoundsHelper;
@@ -7614,7 +7644,7 @@ var LeaferUI = function(exports) {
7614
7644
  }
7615
7645
  if (data.__useEffect) {
7616
7646
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7617
- stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
7647
+ stintSet$1(data, "__isFastShadow", shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !Effect.isTransformShadow(shadow[0]) && fill && !data.__isTransparentFill && !(isArray(fill) && fill.length > 1) && (this.useFastShadow || !stroke || stroke && data.strokeAlign === "inside"));
7618
7648
  data.__useEffect = !!(shadow || otherEffect);
7619
7649
  }
7620
7650
  data.__checkSingle();
@@ -8166,7 +8196,9 @@ var LeaferUI = function(exports) {
8166
8196
  } else if (attrName === "zIndex") {
8167
8197
  this.canvas.zIndex = newValue;
8168
8198
  setTimeout(() => this.parent && this.parent.__updateSortChildren());
8169
- }
8199
+ } else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
8200
+ mode: newValue
8201
+ });
8170
8202
  }
8171
8203
  return super.__setAttr(attrName, newValue);
8172
8204
  }
@@ -8345,6 +8377,7 @@ var LeaferUI = function(exports) {
8345
8377
  exports.Leafer.list = new LeafList;
8346
8378
  __decorate([ dataProcessor(LeaferData) ], exports.Leafer.prototype, "__", void 0);
8347
8379
  __decorate([ boundsType() ], exports.Leafer.prototype, "pixelRatio", void 0);
8380
+ __decorate([ dataType("normal") ], exports.Leafer.prototype, "mode", void 0);
8348
8381
  exports.Leafer = Leafer_1 = __decorate([ registerUI() ], exports.Leafer);
8349
8382
  exports.Rect = class Rect extends exports.UI {
8350
8383
  get __tag() {
@@ -8504,45 +8537,8 @@ var LeaferUI = function(exports) {
8504
8537
  __decorate([ pathType(0) ], exports.Ellipse.prototype, "startAngle", void 0);
8505
8538
  __decorate([ pathType(0) ], exports.Ellipse.prototype, "endAngle", void 0);
8506
8539
  exports.Ellipse = __decorate([ registerUI() ], exports.Ellipse);
8507
- const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
8508
- const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8509
- exports.Line = class Line extends exports.UI {
8510
- get __tag() {
8511
- return "Line";
8512
- }
8513
- get toPoint() {
8514
- const {width: width, rotation: rotation} = this.__;
8515
- const to = getPointData();
8516
- if (width) to.x = width;
8517
- if (rotation) rotate$1(to, rotation);
8518
- return to;
8519
- }
8520
- set toPoint(value) {
8521
- this.width = getDistance$2(defaultPoint, value);
8522
- this.rotation = getAngle$1(defaultPoint, value);
8523
- if (this.height) this.height = 0;
8524
- }
8525
- __updatePath() {
8526
- const data = this.__;
8527
- const path = data.path = [];
8528
- if (data.points) {
8529
- drawPoints$1(path, data.points, data.curve, data.closed);
8530
- } else {
8531
- moveTo$2(path, 0, 0);
8532
- lineTo$2(path, this.width, 0);
8533
- }
8534
- }
8535
- };
8536
- __decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
8537
- __decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
8538
- __decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
8539
- __decorate([ pathType() ], exports.Line.prototype, "points", void 0);
8540
- __decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
8541
- __decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
8542
- exports.Line = __decorate([ registerUI() ], exports.Line);
8543
8540
  const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
8544
- const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints: drawPoints} = PathCommandDataHelper;
8545
- const line = exports.Line.prototype;
8541
+ const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
8546
8542
  exports.Polygon = class Polygon extends exports.UI {
8547
8543
  get __tag() {
8548
8544
  return "Polygon";
@@ -8551,29 +8547,25 @@ var LeaferUI = function(exports) {
8551
8547
  const data = this.__;
8552
8548
  const path = data.path = [];
8553
8549
  if (data.points) {
8554
- drawPoints(path, data.points, data.curve, true);
8550
+ drawPoints$1(path, data.points, data.curve, true);
8555
8551
  } else {
8556
8552
  const {width: width, height: height, sides: sides} = data;
8557
8553
  const rx = width / 2, ry = height / 2;
8558
- moveTo$1(path, rx, 0);
8554
+ moveTo$2(path, rx, 0);
8559
8555
  for (let i = 1; i < sides; i++) {
8560
- lineTo$1(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
8556
+ lineTo$2(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
8561
8557
  }
8562
8558
  closePath$1(path);
8563
8559
  }
8564
8560
  }
8565
- __updateRenderPath() {}
8566
- __updateBoxBounds() {}
8567
8561
  };
8568
8562
  __decorate([ dataProcessor(PolygonData) ], exports.Polygon.prototype, "__", void 0);
8569
8563
  __decorate([ pathType(3) ], exports.Polygon.prototype, "sides", void 0);
8570
8564
  __decorate([ pathType() ], exports.Polygon.prototype, "points", void 0);
8571
8565
  __decorate([ pathType(0) ], exports.Polygon.prototype, "curve", void 0);
8572
- __decorate([ rewrite(line.__updateRenderPath) ], exports.Polygon.prototype, "__updateRenderPath", null);
8573
- __decorate([ rewrite(line.__updateBoxBounds) ], exports.Polygon.prototype, "__updateBoxBounds", null);
8574
8566
  exports.Polygon = __decorate([ rewriteAble(), registerUI() ], exports.Polygon);
8575
8567
  const {sin: sin, cos: cos, PI: PI} = Math;
8576
- const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
8568
+ const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
8577
8569
  exports.Star = class Star extends exports.UI {
8578
8570
  get __tag() {
8579
8571
  return "Star";
@@ -8582,9 +8574,9 @@ var LeaferUI = function(exports) {
8582
8574
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
8583
8575
  const rx = width / 2, ry = height / 2;
8584
8576
  const path = this.__.path = [];
8585
- moveTo(path, rx, 0);
8577
+ moveTo$1(path, rx, 0);
8586
8578
  for (let i = 1; i < corners * 2; i++) {
8587
- lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
8579
+ lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
8588
8580
  }
8589
8581
  closePath(path);
8590
8582
  }
@@ -8593,6 +8585,42 @@ var LeaferUI = function(exports) {
8593
8585
  __decorate([ pathType(5) ], exports.Star.prototype, "corners", void 0);
8594
8586
  __decorate([ pathType(.382) ], exports.Star.prototype, "innerRadius", void 0);
8595
8587
  exports.Star = __decorate([ registerUI() ], exports.Star);
8588
+ const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
8589
+ const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8590
+ exports.Line = class Line extends exports.UI {
8591
+ get __tag() {
8592
+ return "Line";
8593
+ }
8594
+ get toPoint() {
8595
+ const {width: width, rotation: rotation} = this.__;
8596
+ const to = getPointData();
8597
+ if (width) to.x = width;
8598
+ if (rotation) rotate$1(to, rotation);
8599
+ return to;
8600
+ }
8601
+ set toPoint(value) {
8602
+ this.width = getDistance$2(defaultPoint, value);
8603
+ this.rotation = getAngle$1(defaultPoint, value);
8604
+ if (this.height) this.height = 0;
8605
+ }
8606
+ __updatePath() {
8607
+ const data = this.__;
8608
+ const path = data.path = [];
8609
+ if (data.points) {
8610
+ drawPoints(path, data.points, data.curve, data.closed);
8611
+ } else {
8612
+ moveTo(path, 0, 0);
8613
+ lineTo(path, this.width, 0);
8614
+ }
8615
+ }
8616
+ };
8617
+ __decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
8618
+ __decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
8619
+ __decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
8620
+ __decorate([ pathType() ], exports.Line.prototype, "points", void 0);
8621
+ __decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
8622
+ __decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
8623
+ exports.Line = __decorate([ registerUI() ], exports.Line);
8596
8624
  exports.Image = class Image extends exports.Rect {
8597
8625
  get __tag() {
8598
8626
  return "Image";
@@ -8725,10 +8753,6 @@ var LeaferUI = function(exports) {
8725
8753
  DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
8726
8754
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
8727
8755
  }
8728
- __onUpdateSize() {
8729
- if (this.__box) this.__box.__onUpdateSize();
8730
- super.__onUpdateSize();
8731
- }
8732
8756
  __updateRenderSpread() {
8733
8757
  let width = super.__updateRenderSpread();
8734
8758
  if (!width) width = this.isOverflow ? 1 : 0;
@@ -8739,6 +8763,11 @@ var LeaferUI = function(exports) {
8739
8763
  copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
8740
8764
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
8741
8765
  }
8766
+ __updateChange() {
8767
+ super.__updateChange();
8768
+ const box = this.__box;
8769
+ if (box) box.__onUpdateSize(), box.__updateChange();
8770
+ }
8742
8771
  __drawRenderPath(canvas) {
8743
8772
  canvas.font = this.__.__font;
8744
8773
  }
@@ -9717,11 +9746,16 @@ var LeaferUI = function(exports) {
9717
9746
  }
9718
9747
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
9719
9748
  }
9720
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9749
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9721
9750
  if (end && index < end) other.clearWorld(copyBounds);
9722
9751
  });
9723
9752
  other.recycle(copyBounds);
9724
9753
  }
9754
+ function getShadowSpread(_ui, shadow) {
9755
+ let width = 0;
9756
+ 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));
9757
+ return width;
9758
+ }
9725
9759
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
9726
9760
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
9727
9761
  if (Platform.fullImageShadow) {
@@ -9793,7 +9827,11 @@ var LeaferUI = function(exports) {
9793
9827
  shadow: shadow,
9794
9828
  innerShadow: innerShadow,
9795
9829
  blur: blur,
9796
- backgroundBlur: backgroundBlur
9830
+ backgroundBlur: backgroundBlur,
9831
+ getShadowSpread: getShadowSpread,
9832
+ isTransformShadow(_shadow) {
9833
+ return undefined;
9834
+ }
9797
9835
  };
9798
9836
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
9799
9837
  let usedGrayscaleAlpha;
@@ -10249,16 +10287,17 @@ var LeaferUI = function(exports) {
10249
10287
  row.data = null;
10250
10288
  }
10251
10289
  function decorationText(drawData, style) {
10252
- let type;
10290
+ let type, offset = 0;
10253
10291
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
10254
10292
  drawData.decorationHeight = fontSize / 11;
10255
10293
  if (isObject(textDecoration)) {
10256
10294
  type = textDecoration.type;
10257
10295
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
10296
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
10258
10297
  } else type = textDecoration;
10259
10298
  switch (type) {
10260
10299
  case "under":
10261
- drawData.decorationY = [ fontSize * .15 ];
10300
+ drawData.decorationY = [ fontSize * .15 + offset ];
10262
10301
  break;
10263
10302
 
10264
10303
  case "delete":
@@ -10266,7 +10305,7 @@ var LeaferUI = function(exports) {
10266
10305
  break;
10267
10306
 
10268
10307
  case "under-delete":
10269
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
10308
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
10270
10309
  }
10271
10310
  }
10272
10311
  const {top: top, right: right, bottom: bottom, left: left} = exports.Direction4;
package/dist/web.min.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const i=t.Debug.get("LeaferCanvas");class n extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(n.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(e){let n=t.isString(e)?document.getElementById(e):e;if(n)if(n instanceof HTMLCanvasElement)this.view=n;else{let t=n;if(n===window||n===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else i.error(`no id: ${e}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:e,height:i,pixelRatio:n}=this,{style:s}=this.view;if(this.unreal){const{config:e,autoWidthStr:i,autoHeightStr:n}=this;e.width?(t.isUndefined(i)&&(this.autoWidthStr=s.width||""),s.width=e.width+"px"):t.isUndefined(i)||(s.width=i),e.height?(t.isUndefined(n)&&(this.autoHeightStr=s.height||""),s.height=e.height+"px"):t.isUndefined(n)||(s.height=n)}else s.width=e+"px",s.height=i+"px",this.view.width=Math.ceil(e*n),this.view.height=Math.ceil(i*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),i.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(e){const i=this.view,{x:n,y:s,width:a,height:r}=this.autoBounds.getBoundsFrom(e),o={width:a,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(o)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(o)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&!t.isUndefined(this.width)&&this.resizeListener(new t.ResizeEvent(e,i))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:a}=t.FileHelper;function r(e,i){t.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const n=s(e),a=t.toDataURL(n,i);return"image/bmp"===n?a.replace("image/png;","image/bmp;"):a},canvasToBolb:(t,e,i)=>new Promise(n=>t.toBlob(n,s(e),i)),canvasSaveAs:(e,i,n)=>{const r=e.toDataURL(s(a(i)),n);return t.Platform.origin.download(r,i)},download:(t,e)=>new Promise(i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()}),loadImage:e=>new Promise((i,n)=>{const s=new t.Platform.origin.Image,{crossOrigin:a}=t.Platform.image;a&&(s.setAttribute("crossOrigin",a),s.crossOrigin=a),s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach(t=>{t.leafer&&e.add(t)}),e}return this.__updatedList}constructor(e,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:h,updateChange:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:m}=t.LeafHelper,w=t.Debug.get("Layouter");class y{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,l=this.getBlocks(s);l.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(a,l,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?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))})}(s,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach(s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||h(n[t])}h(i)}})}(this.__levelList),function(t){t.list.forEach(c)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,l,this.times)),n.emitEvent(new t.LayoutEvent(o,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),y.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new g([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new g(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_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(i.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),a=new t.Bounds(s);n.save(),s.spread(x.clipSpread).ceil(),n.clearWorld(s),n.clipWorld(s),this.__render(s,a),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,s=e.includes(this.target.__world),a=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),this.target.__render(n,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const i=this.requestTime=Date.now(),n=()=>{const e=1e3/(Date.now()-i),{maxFPS:s}=this.config;if(s&&e>s-.5)return t.Platform.requestRender(n);this.FPS=Math.min(120,Math.ceil(e)),this.requestTime=0,this.checkRender()};t.Platform.requestRender(n)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function b(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[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(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>s.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function E(t,e){t.__.__font?b(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function B(t,e,i){switch(e.__.strokeAlign){case"center":R(t,1,e,i);break;case"inside":L(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?R(t,2,e,i):L(t,"outside",e,i)}}function R(e,i,n,s){const a=n.__;t.isObject(e)?k(e,i,!0,n,s):(s.setStroke(e,a.__strokeWidth*i,a),S(n,s))}function L(e,i,n,s){const a=s.getSameCanvas(!0,!0);a.font=n.__.__font,R(e,2,n,a),a.blendMode="outside"===i?"destination-out":"destination-in",b(n,a),a.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,s,a),a.recycle(n.__nowWorld)}function S(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=n;s.forEach(i=>a.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}}function k(t,i,n,s,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*i,o);for(let d=0,h=t.length;d<h;d++)if(r=t[d],(!r.image||!e.PaintImage.checkImage(s,a,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*i,o,t):a.setStroke(r.style,o.__strokeWidth*i,o)}else a.strokeStyle=r.style;r.blendMode?(a.saveBlendMode(r.blendMode),n?S(s,a):a.stroke(),a.restoreBlendMode()):n?S(s,a):a.stroke()}}function P(e,i,n){const s=i.__;if(s.__strokeWidth)if(s.__font)B(e,i,n);else switch(s.strokeAlign){case"center":C(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),C(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const s=i.__;if(s.__fillAfterStroke)C(e,2,i,n);else{const{renderBounds:a}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),C(e,2,i,r),r.clipUI(s),r.clearWorld(a),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function C(i,n,s,a){const r=s.__;t.isObject(i)?k(i,n,!1,s,a):(a.setStroke(i,r.__strokeWidth*n,r),a.stroke()),r.__useArrow&&e.Paint.strokeArrow(i,s,a)}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:A,getOuterOf:O,getByMove:D,getIntersectData:W}=t.BoundsHelper;let T;const{stintSet:M}=t.DataHelper,{hasTransparent:I}=e.ColorConvert;function z(i,n,s){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let a;const{boxBounds:r}=s.__layout;switch(n.type){case"image":a=e.PaintImage.image(s,i,n,r,!T||!T[n.url]);break;case"linear":a=e.PaintGradient.linearGradient(n,r);break;case"radial":a=e.PaintGradient.radialGradient(n,r);break;case"angular":a=e.PaintGradient.conicGradient(n,r);break;case"solid":const{type:o,color:l,opacity:d}=n;a={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(n.r)||(a={type:"solid",style:e.ColorConvert.string(n)})}if(a){if(t.isString(a.style)&&I(a.style)&&(a.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;a.strokeStyle=n.style}n.editing&&(a.editing=n.editing),n.blendMode&&(a.blendMode=n.blendMode)}return a}const H={compute:function(i,n){const s=n.__,a=[];let r,o,l,d=s.__input[i];t.isArray(d)||(d=[d]),T=e.PaintImage.recycleImage(i,s);for(let t,e=0,s=d.length;e<s;e++)(t=z(i,d[e],n))&&(a.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));s["_"+i]=a.length?a:void 0,a.length&&a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(r=!0),o=!0),"fill"===i?(M(s,"__isAlphaPixelFill",r),M(s,"__isTransparentFill",o)):(M(s,"__isAlphaPixelStroke",r),M(s,"__isTransparentStroke",o),M(s,"__hasMultiStrokeStyle",l))},fill:function(t,e,i){i.fillStyle=t,E(e,i)},fills:function(t,i,n){let s;for(let a=0,r=t.length;a<r;a++){if(s=t[a],s.image){if(e.PaintImage.checkImage(i,n,s,!i.__.__font))continue;if(!s.style){!a&&s.image.isPlacehold&&i.drawImagePlaceholder(n,s.image);continue}}if(n.fillStyle=s.style,s.transform||s.scaleFixed){if(n.save(),s.transform&&n.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:e}=i.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&e>1)&&n.scale(1/t,1/e)}s.blendMode&&(n.blendMode=s.blendMode),E(i,n),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),E(i,n),n.restoreBlendMode()):E(i,n)}},fillPathOrText:E,fillText:b,stroke:P,strokes:function(t,e,i){P(t,e,i)},strokeText:B,drawTextStroke:S,shape:function(e,i,n){const s=i.getSameCanvas(),a=e.__nowWorld,r=i.bounds;let o,l,d,h,c,{scaleX:u,scaleY:f}=e.getRenderScaleData(!0);if(r.includes(a))c=s,o=h=a;else{const{renderShapeSpread:s}=e.__layout;let p;if(t.Platform.fullImageShadow)p=a;else{const t=s?A(r,u===f?s*u:[s*f,s*u]):r;p=W(t,a)}d=r.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(c=i.getSameCanvas(),e.__renderShape(c,n),u*=g,f*=_),h=O(a,d),o=D(h,-d.e,-d.f);const m=n.matrix;m?(l=new t.Matrix(d),l.multiply(m),g*=m.scaleX,_*=m.scaleY):l=d,l.withScale(g,_),n=Object.assign(Object.assign({},n),{matrix:l})}return e.__renderShape(s,n),{canvas:s,matrix:l,fitMatrix:d,bounds:o,worldCanvas:c,shapeBounds:h,scaleX:u,scaleY:f}}};let F={},U=t.getMatrixData();const{get:j,rotateOfOuter:G,translate:V,scaleOfOuter:Y,multiplyParent:N,scale:q,rotate:X,skew:Q}=t.MatrixHelper;function Z(t,e,i,n,s,a,r){const o=j();V(o,e.x+i,e.y+n),q(o,s,a),r&&G(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function $(t,e,i,n,s,a,r,o,l){const d=j();J(d,e,i,n,s,a,r,o),l&&(U.a=e.width/l.width,U.d=e.height/l.height,N(d,U)),t.transform=d}function K(t,e,i,n,s,a,r,o,l,d,h,c){const u=j();if(c)J(u,e,s,a,r,o,l,d);else{if(l)if("center"===h)G(u,{x:i/2,y:n/2},l);else switch(X(u,l),l){case 90:V(u,n,0);break;case 180:V(u,i,n);break;case 270:V(u,0,i)}F.x=e.x+s,F.y=e.y+a,V(u,F.x,F.y),r&&Y(u,F,r,o)}t.transform=u}function J(t,e,i,n,s,a,r,o){r&&X(t,r),o&&Q(t,o.x,o.y),s&&q(t,s,a),V(t,e.x+i,e.y+n)}const{get:tt,translate:et}=t.MatrixHelper,it=new t.Bounds,nt={},st={};function at(t,e,i,n){const{changeful:s,sync:a,scaleFixed:r}=i;s&&(t.changeful=s),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=rt(i,n,e)}function rt(e,i,n){e.padding&&(i=it.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:a}=n;const{opacity:r,mode:o,align:l,offset:d,scale:h,size:c,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,w=i.width===s&&i.height===a,y={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(st,0,0,v?a:s,v?s:a),o&&"cover"!==o&&"fit"!==o?((h||c)&&(t.MathHelper.getScaleData(h,c,n,nt),x=nt.scaleX,b=nt.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(st,x,b,!0),l&&t.AlignHelper.toPoint(l,st,i,st,!0,!0))):w&&!u||(x=b=t.BoundsHelper.getFitScale(i,st,"fit"!==o),t.BoundsHelper.put(i,n,l,x,!1,st),t.BoundsHelper.scale(st,x,b,!0)),d&&t.PointHelper.move(st,d),o){case"stretch":w||(s=i.width,a=i.height);break;case"normal":case"clip":(st.x||st.y||x||p||u||f)&&$(y,i,st.x,st.y,x,b,u,f,e.clipSize);break;case"repeat":(!w||x||u||f)&&K(y,i,s,a,st.x,st.y,x,b,u,f,l,e.freeTransform),g||(y.repeat="repeat");const n=t.isObject(g);(_||n)&&(y.gap=function(e,i,n,s,a){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:ot(r,n,a.width,i&&i.x),y:ot(o,s,a.height,i&&i.y)}}(_,n&&g,st.width,st.height,i));break;default:x&&Z(y,i,st.x,st.y,x,b,u)}return y.transform||(i.x||i.y)&&(y.transform=tt(),et(y.transform,i.x,i.y)),x&&"stretch"!==o&&(y.scaleX=x,y.scaleY=b),y.width=s,y.height=a,r&&(y.opacity=r),m&&(y.filters=m),g&&(y.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function ot(e,i,n,s){const a=t.isString(e)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):e;return"auto"===e&&a<0?0:a}let lt,dt=new t.Bounds;const{isSame:ht}=t.BoundsHelper;function ct(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||at(s,n,i,a),!0}function ut(e,i){gt(e,t.ImageEvent.LOAD,i)}function ft(e,i){gt(e,t.ImageEvent.LOADED,i)}function pt(e,i,n){i.error=n,e.forceUpdate("surface"),gt(e,t.ImageEvent.ERROR,i)}function gt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function _t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:mt,scale:wt,copy:yt}=t.MatrixHelper,{floor:vt,ceil:xt,max:bt,abs:Et}=Math;function Bt(e,i,n){let{scaleX:s,scaleY:a}=e.getRenderScaleData(!0,i.scaleFixed);const r=s+"-"+a+"-"+n;if(i.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=i;let d,h,{width:c,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;s*=n,a*=n,f&&(f=Et(f),p=Et(p),h=mt(),yt(h,g),wt(h,1/f,1/p),s*=f,a*=p),c*=s,u*=a;const w=c*u;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(o.isSVG){const t=c/o.width;t>1&&(d=t/xt(t))}else{const t=o.width*o.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,c/=d,u/=d),f&&(s/=f,a/=p);const v=m&&m.x*s,x=m&&m.y*a;if(g||1!==s||1!==a){const t=c+(v||0),e=u+(x||0);s/=t/bt(vt(t),1),a/=e/bt(vt(e),1),h||(h=mt(),g&&yt(h,g)),wt(h,1/s,1/a)}const b=o.getCanvas(c,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),E=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",h,i);return i.style=E,i.patternId=r,!0}}function Rt(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Lt={image:function(e,i,n,s,a){let r,o;const l=t.ImageManager.get(n);return lt&&n===lt.paint&&ht(s,lt.boxBounds)?r=lt.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),lt=l.use>1?{leafPaint:r,paint:n,boxBounds:dt.set(s)}:null),(a||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(ct(e,i,n,l,r,s),a&&(ut(e,o),ft(e,o))):l.error?a&&pt(e,o,l.error):(a&&(_t(e,!0),ut(e,o)),r.loadId=l.load(()=>{_t(e,!1),e.destroyed||(ct(e,i,n,l,r,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ft(e,o)),r.loadId=void 0},t=>{_t(e,!1),pt(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(i,n,s,a){const{scaleX:r,scaleY:o}=i.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=n,{data:d}=s;if(!d||s.patternId===r+"-"+o+"-"+l&&!e.Export.running)return!1;if(a)if(d.repeat)a=!1;else if(!(s.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(i)||e.Export.running)){let{width:e,height:i}=d;e*=r*l,i*=o*l,d.scaleX&&(e*=d.scaleX,i*=d.scaleY),a=e*i>t.Platform.image.maxCacheSize}return a?(i.__.__isFastShadow&&(n.fillStyle=s.style||"#000",n.fill()),function(t,e,i,n){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(i,n,s,d),!0):(!s.style||s.sync||e.Export.running?Bt(i,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add(()=>Rt(this,void 0,void 0,function*(){s.patternTask=null,n.bounds.hit(i.__nowWorld)&&Bt(i,s,l),i.forceUpdate("surface")}),300)),!1)},createPattern:Bt,recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let s,a,r,o,l;for(let d=0,h=n.length;d<h;d++)s=n[d],a=s.image,l=a&&a.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),a.unload(n[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:at,getPatternData:rt,fillOrFitMode:Z,clipMode:$,repeatMode:K},{toPoint:St}=t.AroundHelper,{hasTransparent:kt}=e.ColorConvert,Pt={},Ct={};function At(i,n,s,a){if(s){let r,o,l,d;for(let i=0,h=s.length;i<h;i++)r=s[i],t.isString(r)?(l=i/(h-1),o=e.ColorConvert.string(r,a)):(l=r.offset,o=e.ColorConvert.string(r.color,a)),n.addColorStop(l,o),!d&&kt(o)&&(d=!0);d&&(i.isTransparent=!0)}}const{getAngle:Ot,getDistance:Dt}=t.PointHelper,{get:Wt,rotateOfOuter:Tt,scaleOfOuter:Mt}=t.MatrixHelper,{toPoint:It}=t.AroundHelper,zt={},Ht={};function Ft(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=Ot(e,i);a=Wt(),s?(Mt(a,e,r/o*(n||1),1),Tt(a,e,t+90)):(Mt(a,e,1,r/o*(n||1)),Tt(a,e,t))}return a}const{getDistance:Ut}=t.PointHelper,{toPoint:jt}=t.AroundHelper,Gt={},Vt={};const Yt={linearGradient:function(e,i){let{from:n,to:s,type:a,opacity:r}=e;St(n||"top",i,Pt),St(s||"bottom",i,Ct);const o=t.Platform.canvas.createLinearGradient(Pt.x,Pt.y,Ct.x,Ct.y),l={type:a,style:o};return At(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;It(n||"center",i,zt),It(s||"bottom",i,Ht);const l=t.Platform.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,Dt(zt,Ht)),d={type:a,style:l};At(d,l,e.stops,r);const h=Ft(i,zt,Ht,o,!0);return h&&(d.transform=h),d},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;jt(n||"center",i,Gt),jt(s||"bottom",i,Vt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Gt.x,Gt.y):t.Platform.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,Ut(Gt,Vt)),d={type:a,style:l};At(d,l,e.stops,r);const h=Ft(i,Gt,Vt,o||1,t.Platform.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ft},{copy:Nt,toOffsetOutBounds:qt}=t.BoundsHelper,Xt={},Qt={};function Zt(e,i,n,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Nt(Xt,e.bounds),Xt.x+=i.x-r.x,Xt.y+=i.y-r.y,n){const{fitMatrix:t}=s;Xt.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Xt.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Xt.width*=n,Xt.height*=n}e.copyWorld(s.canvas,e.bounds,Xt)}else n&&(Nt(Xt,i),Xt.x-=i.width/2*(n-1),Xt.y-=i.height/2*(n-1),Xt.width*=n,Xt.height*=n),e.copyWorld(s.canvas,r,n?Xt:i)}const{toOffsetOutBounds:$t}=t.BoundsHelper,Kt={};const Jt={shadow:function(i,n,s){let a,r;const{__nowWorld:o,__layout:l}=i,{shadow:d}=i.__,{worldCanvas:h,bounds:c,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=d.length-1;qt(c,Qt),d.forEach((d,m)=>{let w=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(Qt.offsetX+d.x*f*w,Qt.offsetY+d.y*p*w,d.blur*f*w,e.ColorConvert.string(d.color)),r=d.spread?1+2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*w:0,Zt(g,Qt,r,s),a=c,d.box&&(g.restore(),g.save(),h&&(g.copyWorld(g,c,o,"copy"),a=o),h?g.copyWorld(h,o,o,"destination-out"):g.copyWorld(s.canvas,u,c,"destination-out")),t.LeafHelper.copyCanvasByWorld(i,n,g,a,d.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(i,n,s){let a,r;const{__nowWorld:o,__layout:l}=i,{innerShadow:d}=i.__,{worldCanvas:h,bounds:c,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=d.length-1;$t(c,Kt),d.forEach((d,m)=>{let w=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(Kt.offsetX+d.x*f*w,Kt.offsetY+d.y*p*w,d.blur*f*w),r=d.spread?1-2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*w:0,Zt(g,Kt,r,s),g.restore(),h?(g.copyWorld(g,c,o,"copy"),g.copyWorld(h,o,o,"source-out"),a=o):(g.copyWorld(s.canvas,u,c,"source-out"),a=c),g.fillWorld(a,e.ColorConvert.string(d.color),"source-in"),t.LeafHelper.copyCanvasByWorld(i,n,g,a,d.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){}},{excludeRenderBounds:te}=t.LeafBoundsHelper;let ee;function ie(t,e,i,n,s,a,r,o){switch(e){case"grayscale":ee||(ee=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),a&&n.recycle(r);se(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":se(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function ne(t){return t.getSameCanvas(!1,!0)}function se(t,e,i,n,s,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),a?i.recycle(r):i.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let i,n,s,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&&(ie(this,r,t,s,n,a,void 0,!0),n=s=null),a=i.__.opacity,ee=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=ne(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=ne(t)),s||(s=ne(t)),i.__render(n,e)),"clipping"!==o&&"clipping-path"!==o||te(i,e)||i.__render(t,e);continue}const h=1===a&&i.__.__blendMode;h&&ie(this,r,t,s,n,a,void 0,!1),te(i,e)||i.__render(s||t,e),h&&ie(this,r,t,s,n,a,h,!1)}ie(this,r,t,s,n,a,void 0,!0)};const ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",re=ae+"_#~&*+\\=|≮≯≈≠=…",oe=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 le(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const de=le("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),he=le("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ce=le(ae),ue=le(re),fe=le("- —/~|┆·");var pe;!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"}(pe||(pe={}));const{Letter:ge,Single:_e,Before:me,After:we,Symbol:ye,Break:ve}=pe;function xe(t){return de[t]?ge:fe[t]?ve:he[t]?me:ce[t]?we:ue[t]?ye:oe.test(t)?_e:ge}const be={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Ee(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:Be}=be,{Letter:Re,Single:Le,Before:Se,After:ke,Symbol:Pe,Break:Ce}=pe;let Ae,Oe,De,We,Te,Me,Ie,ze,He,Fe,Ue,je,Ge,Ve,Ye,Ne,qe,Xe=[];function Qe(t,e){He&&!ze&&(ze=He),Ae.data.push({char:t,width:e}),De+=e}function Ze(){We+=De,Ae.width=De,Oe.words.push(Ae),Ae={data:[]},De=0}function $e(){Ve&&(Ye.paraNumber++,Oe.paraStart=!0,Ve=!1),He&&(Oe.startCharSize=ze,Oe.endCharSize=He,ze=0),Oe.width=We,Ne.width?Be(Oe):qe&&Ke(),Xe.push(Oe),Oe={words:[]},We=0}function Ke(){We>(Ye.maxWidth||0)&&(Ye.maxWidth=We)}const{top:Je,right:ti,bottom:ei,left:ii}=t.Direction4;function ni(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const si={getDrawData:function(i,n){t.isString(i)||(i=String(i));let s=0,a=0,r=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:h}=n;h&&(r?(s=h[ii],r-=h[ti]+h[ii]):n.autoSizeAlign||(s=h[ii]),o?(a=h[Je],o-=h[Je]+h[ei]):n.autoSizeAlign||(a=h[Je]));const c={bounds:{x:s,y:a,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,i,n){Ye=e,Xe=e.rows,Ne=e.bounds,qe=!Ne.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=t.Platform,{width:l,height:d}=Ne;if(l||d||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Ve=!0,Ue=null,ze=Ie=He=De=We=0,Ae={data:[]},Oe={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)Me=i[n],"\n"===Me?(De&&Ze(),Oe.paraEnd=!0,$e(),Ve=!0):(Fe=xe(Me),Fe===Re&&"none"!==r&&(Me=Ee(Me,r,!De)),Ie=o.measureText(Me).width,s&&(s<0&&(He=Ie),Ie+=s),je=Fe===Le&&(Ue===Le||Ue===Re)||Ue===Le&&Fe!==ke,Ge=!(Fe!==Se&&Fe!==Le||Ue!==Pe&&Ue!==ke),Te=Ve&&a?l-a:l,t&&l&&We+De+Ie>Te&&(e?(De&&Ze(),We&&$e()):(Ge||(Ge=Fe===Re&&Ue==ke),je||Ge||Fe===Ce||Fe===Se||Fe===Le||De+Ie>Te?(De&&Ze(),We&&$e()):We&&$e()))," "===Me&&!0!==Ve&&We+De===0||(Fe===Ce?(" "===Me&&De&&Ze(),Qe(Me,Ie),Ze()):je||Ge?(De&&Ze(),Qe(Me,Ie)):Qe(Me,Ie)),Ue=Fe);De&&Ze(),We&&$e(),Xe.length>0&&(Xe[Xe.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ye.paraNumber++,We=o.measureText(t).width,Xe.push({x:a||0,text:t,width:We,paraStart:!0}),qe&&Ke()})}(c,i,n),h&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ni(e,"x",t[ii]);break;case"right":ni(e,"x",-t[ti])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ni(e,"y",t[Je]);break;case"bottom":ni(e,"y",-t[ei])}}(h,c,n,r,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,m=a*s+(c?c*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(h){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,h=s;r<h;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&c&&r>0&&(w+=c),y.y=w,w+=a,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,o<0&&(y.width<0?(x=-y.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=m}(c,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;n.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&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,n){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(c,n,r),c.overflow&&function(e,i,n,s){if(!s)return;const{rows:a,overflow:r}=e;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,h=n+s-d;("none"===i.textWrap?a:[a[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<h));n--){if(l<h&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(c,n,s,r),"none"!==l&&function(i,n){let s;const{fontSize:a,textDecoration:r}=n;switch(i.decorationHeight=a/11,t.isObject(r)?(s=r.type,r.color&&(i.decorationColor=e.ColorConvert.string(r.color))):s=r,s){case"under":i.decorationY=[.15*a];break;case"delete":i.decorationY=[.35*-a];break;case"under-delete":i.decorationY=[.15*a,.35*-a]}}(c,n),c}};const ai={string:function(i,n){const s=t.isNumber(n)&&n<1;if(t.isString(i)){if(!s||!e.ColorConvert.object)return i;i=e.ColorConvert.object(i)}let a=t.isUndefined(i.a)?1:i.a;s&&(a*=n);const r=i.r+","+i.g+","+i.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(e.TextConvert,si),Object.assign(e.ColorConvert,ai),Object.assign(e.Paint,H),Object.assign(e.PaintImage,Lt),Object.assign(e.PaintGradient,Yt),Object.assign(e.Effect,Jt),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=x,exports.Watcher=l,exports.useCanvas=r,Object.keys(t).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}),Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
1
+ "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");const i=t.Debug.get("LeaferCanvas");class n extends t.LeaferCanvasBase{set zIndex(t){const{style:e}=this.view;e.zIndex=t,this.setAbsolute(this.view)}set childIndex(t){const{view:e,parentView:i}=this;if(e&&i){const n=i.children[t];n?(this.setAbsolute(n),i.insertBefore(e,n)):i.appendChild(n)}}init(){const{config:e}=this,i=e.view||e.canvas;i?this.__createViewFrom(i):this.__createView();const{style:n}=this.view;if(n.display||(n.display="block"),this.parentView=this.view.parentElement,this.parentView){const t=this.parentView.style;t.webkitUserSelect=t.userSelect="none"}t.Platform.syncDomFont&&!this.parentView&&(n.display="none",document.body.appendChild(this.view)),this.__createContext(),this.autoLayout||this.resize(e)}set backgroundColor(t){this.view.style.backgroundColor=t}get backgroundColor(){return this.view.style.backgroundColor}set hittable(t){this.view.style.pointerEvents=t?"auto":"none"}get hittable(){return"none"!==this.view.style.pointerEvents}__createView(){this.view=document.createElement("canvas")}__createViewFrom(e){let n=t.isString(e)?document.getElementById(e):e;if(n)if(n instanceof HTMLCanvasElement)this.view=n;else{let t=n;if(n===window||n===document){const e=document.createElement("div"),{style:i}=e;i.position="absolute",i.top=i.bottom=i.left=i.right="0px",document.body.appendChild(e),t=e}this.__createView();const e=this.view;t.hasChildNodes()&&(this.setAbsolute(e),t.style.position||(t.style.position="relative")),t.appendChild(e)}else i.error(`no id: ${e}`),this.__createView()}setAbsolute(t){const{style:e}=t;e.position="absolute",e.top=e.left="0px"}updateViewSize(){const{width:e,height:i,pixelRatio:n}=this,{style:s}=this.view;if(this.unreal){const{config:e,autoWidthStr:i,autoHeightStr:n}=this;e.width?(t.isUndefined(i)&&(this.autoWidthStr=s.width||""),s.width=e.width+"px"):t.isUndefined(i)||(s.width=i),e.height?(t.isUndefined(n)&&(this.autoHeightStr=s.height||""),s.height=e.height+"px"):t.isUndefined(n)||(s.height=n)}else s.width=e+"px",s.height=i+"px",this.view.width=Math.ceil(e*n),this.view.height=Math.ceil(i*n)}updateClientBounds(){this.view.parentElement&&(this.clientBounds=this.view.getBoundingClientRect())}startAutoLayout(t,e){if(this.resizeListener=e,t){if(this.autoBounds=t,this.resizeObserver)return;try{this.resizeObserver=new ResizeObserver(t=>{this.updateClientBounds();for(const e of t)this.checkAutoBounds(e.contentRect)});const t=this.parentView;t?(this.resizeObserver.observe(t),this.checkAutoBounds(t.getBoundingClientRect())):(this.checkAutoBounds(this.view),i.warn("no parent"))}catch(t){this.imitateResizeObserver()}this.stopListenPixelRatio()}else this.listenPixelRatio(),this.unreal&&this.updateViewSize()}imitateResizeObserver(){this.autoLayout&&(this.parentView&&this.checkAutoBounds(this.parentView.getBoundingClientRect()),t.Platform.requestRender(this.imitateResizeObserver.bind(this)))}listenPixelRatio(){this.windowListener||window.addEventListener("resize",this.windowListener=()=>{const e=t.Platform.devicePixelRatio;if(!this.config.pixelRatio&&this.pixelRatio!==e){const{width:t,height:i}=this;this.emitResize({width:t,height:i,pixelRatio:e})}})}stopListenPixelRatio(){this.windowListener&&(window.removeEventListener("resize",this.windowListener),this.windowListener=null)}checkAutoBounds(e){const i=this.view,{x:n,y:s,width:a,height:r}=this.autoBounds.getBoundsFrom(e),o={width:a,height:r,pixelRatio:this.config.pixelRatio?this.pixelRatio:t.Platform.devicePixelRatio};if(!this.isSameSize(o)){const{style:t}=i;t.marginLeft=n+"px",t.marginTop=s+"px",this.emitResize(o)}}stopAutoLayout(){this.autoLayout=!1,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeListener=this.resizeObserver=null}emitResize(e){const i={};t.DataHelper.copyAttrs(i,this,t.canvasSizeAttrs),this.resize(e),this.resizeListener&&!t.isUndefined(this.width)&&this.resizeListener(new t.ResizeEvent(e,i))}unrealCanvas(){if(!this.unreal&&this.parentView){const t=this.view;t&&t.remove(),this.view=this.parentView,this.unreal=!0}}destroy(){if(this.view){if(this.stopAutoLayout(),this.stopListenPixelRatio(),!this.unreal){const t=this.view;t.parentElement&&t.remove()}super.destroy()}}}t.canvasPatch(CanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:s,fileType:a}=t.FileHelper;function r(e,i){t.Platform.origin={createCanvas(t,e){const i=document.createElement("canvas");return i.width=t,i.height=e,i},canvasToDataURL:(t,e,i)=>{const n=s(e),a=t.toDataURL(n,i);return"image/bmp"===n?a.replace("image/png;","image/bmp;"):a},canvasToBolb:(t,e,i)=>new Promise(n=>t.toBlob(n,s(e),i)),canvasSaveAs:(e,i,n)=>{const r=e.toDataURL(s(a(i)),n);return t.Platform.origin.download(r,i)},download:(t,e)=>new Promise(i=>{let n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),i()}),loadImage:e=>new Promise((i,n)=>{const s=new t.Platform.origin.Image,{crossOrigin:a}=t.Platform.image;a&&(s.setAttribute("crossOrigin",a),s.crossOrigin=a),s.onload=()=>{i(s)},s.onerror=t=>{n(t)},s.src=t.Platform.image.getRealURL(e)}),Image:Image,PointerEvent:PointerEvent,DragEvent:DragEvent},t.Platform.event={stopDefault(t){t.preventDefault()},stopNow(t){t.stopImmediatePropagation()},stop(t){t.stopPropagation()}},t.Platform.canvas=t.Creator.canvas(),t.Platform.conicGradientSupport=!!t.Platform.canvas.context.createConicGradient}Object.assign(t.Creator,{canvas:(t,e)=>new n(t,e),image:e=>new t.LeaferImage(e)}),t.Platform.name="web",t.Platform.isMobile="ontouchstart"in window,t.Platform.requestRender=function(t){window.requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>devicePixelRatio});const{userAgent:o}=navigator;o.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0,t.Platform.syncDomFont=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),o.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):o.indexOf("Mac")>-1?t.Platform.os="Mac":o.indexOf("Linux")>-1&&(t.Platform.os="Linux");class l{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach(t=>{t.leafer&&e.add(t)}),e}return this.__updatedList}constructor(e,i){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[t.PropertyEvent.CHANGE,this.__onAttrChange,this],[[t.ChildEvent.ADD,t.ChildEvent.REMOVE],this.__onChildEvent,this],[t.WatchEvent.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:d,updateBounds:h,updateChange:c}=t.LeafHelper,{pushAllChildBranch:u,pushAllParent:f}=t.BranchHelper;const{worldBounds:p}=t.LeafBoundsHelper;class g{constructor(e){this.updatedBounds=new t.Bounds,this.beforeBounds=new t.Bounds,this.afterBounds=new t.Bounds,t.isArray(e)&&(e=new t.LeafList(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,p)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,p),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:_,updateAllChange:m}=t.LeafHelper,w=t.Debug.get("Layouter");class y{constructor(e,i){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,i&&(this.config=t.DataHelper.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:e}=this;this.times=0;try{e.emit(t.LayoutEvent.START),this.layoutOnce(),e.emitEvent(new t.LayoutEvent(t.LayoutEvent.END,this.layoutedBlocks,this.times))}catch(t){w.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?w.warn("layouting"):this.times>3?w.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const i=t.Run.start("PartLayout"),{target:n,__updatedList:s}=this,{BEFORE:a,LAYOUT:r,AFTER:o}=t.LayoutEvent,l=this.getBlocks(s);l.forEach(t=>t.setBefore()),n.emitEvent(new t.LayoutEvent(a,l,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?(d(t,!0),e.add(t),t.isBranch&&u(t,e),f(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),f(t,e)))})}(s,this.__levelList),function(t){let e,i,n;t.sort(!0),t.levels.forEach(s=>{e=t.levelMap[s];for(let t=0,s=e.length;t<s;t++){if(i=e[t],i.isBranch&&i.__tempNumber){n=i.children;for(let t=0,e=n.length;t<e;t++)n[t].isBranch||h(n[t])}h(i)}})}(this.__levelList),function(t){t.list.forEach(c)}(s),this.extraBlock&&l.push(this.extraBlock),l.forEach(t=>t.setAfter()),n.emitEvent(new t.LayoutEvent(r,l,this.times)),n.emitEvent(new t.LayoutEvent(o,l,this.times)),this.addBlocks(l),this.__levelList.reset(),this.__updatedList=null,t.Run.end(i)}fullLayout(){const e=t.Run.start("FullLayout"),{target:i}=this,{BEFORE:n,LAYOUT:s,AFTER:a}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(i));i.emitEvent(new t.LayoutEvent(n,r,this.times)),y.fullLayout(i),r.forEach(t=>{t.setAfter()}),i.emitEvent(new t.LayoutEvent(s,r,this.times)),i.emitEvent(new t.LayoutEvent(a,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){_(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),m(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new g([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new g(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_([[t.LayoutEvent.REQUEST,this.layout,this],[t.LayoutEvent.AGAIN,this.layoutAgain,this],[t.WatchEvent.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const v=t.Debug.get("Renderer");class x{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,i,n){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.target=e,this.canvas=i,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(t.LayoutEvent.REQUEST)}checkRender(){if(this.running){const{target:e}=this;e.isApp&&(e.emit(t.RenderEvent.CHILD_START,e),e.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),e.emit(t.RenderEvent.CHILD_END,e)),this.changed&&this.canvas.view&&this.render(),this.target.emit(t.RenderEvent.NEXT)}}render(e){if(!this.running||!this.canvas.view)return this.update();const{target:i}=this;this.times=0,this.totalBounds=new t.Bounds,v.log(i.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,v.error(t)}v.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return v.warn("rendering");if(this.times>3)return v.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new t.Bounds,this.renderOptions={},e)this.emitRender(t.RenderEvent.BEFORE),e();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(t.RenderEvent.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(t.RenderEvent.RENDER,this.renderBounds,this.renderOptions),this.emitRender(t.RenderEvent.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(e){const i=t.Run.start("PartRender"),{canvas:n}=this,s=e.getIntersect(n.bounds),a=new t.Bounds(s);n.save(),s.spread(x.clipSpread).ceil(),n.clearWorld(s),n.clipWorld(s),this.__render(s,a),n.restore(),t.Run.end(i)}fullRender(){const e=t.Run.start("FullRender"),{canvas:i}=this;i.save(),i.clear(),this.__render(i.bounds),i.restore(),t.Run.end(e)}__render(e,i){const{canvas:n}=this,s=e.includes(this.target.__world),a=s?{includes:s}:{bounds:e,includes:s};this.needFill&&n.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(n,e),this.target.__render(n,a),this.renderBounds=i=i||e,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),n.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const i=new t.Bounds;i.setList(e),e.length=0,e.push(i)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const i=this.requestTime=Date.now(),n=()=>{const e=1e3/(Date.now()-i),{maxFPS:s}=this.config;if(s&&e>s-.5)return t.Platform.requestRender(n);this.FPS=Math.min(120,Math.ceil(e)),this.requestTime=0,this.checkRender()};t.Platform.requestRender(n)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:i,height:n}=e.old;if(!new t.Bounds(0,0,i,n).includes(this.target.__world)||this.needFill||!e.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new t.Bounds(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||v.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,i,n){this.target.emitEvent(new t.RenderEvent(e,this.times,i,n))}__listenEvents(){this.__eventIds=[this.target.on_([[t.RenderEvent.REQUEST,this.update,this],[t.LayoutEvent.END,this.__onLayoutEnd,this],[t.RenderEvent.AGAIN,this.renderAgain,this],[t.ResizeEvent.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function b(t,e){const i=t.__,{rows:n,decorationY:s}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=n.length;t<i;t++)a=n[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(s){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),n.forEach(t=>s.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function E(t,e){t.__.__font?b(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function B(t,e,i){switch(e.__.strokeAlign){case"center":R(t,1,e,i);break;case"inside":L(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?R(t,2,e,i):L(t,"outside",e,i)}}function R(e,i,n,s){const a=n.__;t.isObject(e)?k(e,i,!0,n,s):(s.setStroke(e,a.__strokeWidth*i,a),S(n,s))}function L(e,i,n,s){const a=s.getSameCanvas(!0,!0);a.font=n.__.__font,R(e,2,n,a),a.blendMode="outside"===i?"destination-out":"destination-in",b(n,a),a.blendMode="normal",t.LeafHelper.copyCanvasByWorld(n,s,a),a.recycle(n.__nowWorld)}function S(t,e){let i,n=t.__.__textDrawData;const{rows:s,decorationY:a}=n;for(let t=0,n=s.length;t<n;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=n;s.forEach(i=>a.forEach(n=>e.strokeRect(i.x,i.y+n,i.width,t)))}}function k(t,i,n,s,a){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*i,o);for(let d=0,h=t.length;d<h;d++)if(r=t[d],(!r.image||!e.PaintImage.checkImage(s,a,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*i,o,t):a.setStroke(r.style,o.__strokeWidth*i,o)}else a.strokeStyle=r.style;r.blendMode?(a.saveBlendMode(r.blendMode),n?S(s,a):a.stroke(),a.restoreBlendMode()):n?S(s,a):a.stroke()}}function P(e,i,n){const s=i.__;if(s.__strokeWidth)if(s.__font)B(e,i,n);else switch(s.strokeAlign){case"center":C(e,1,i,n);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),C(t,2,e,i),i.restore()}(e,i,n);break;case"outside":!function(e,i,n){const s=i.__;if(s.__fillAfterStroke)C(e,2,i,n);else{const{renderBounds:a}=i.__layout,r=n.getSameCanvas(!0,!0);i.__drawRenderPath(r),C(e,2,i,r),r.clipUI(s),r.clearWorld(a),t.LeafHelper.copyCanvasByWorld(i,n,r),r.recycle(i.__nowWorld)}}(e,i,n)}}function C(i,n,s,a){const r=s.__;t.isObject(i)?k(i,n,!1,s,a):(a.setStroke(i,r.__strokeWidth*n,r),a.stroke()),r.__useArrow&&e.Paint.strokeArrow(i,s,a)}x.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new l(t,e),layouter:(t,e)=>new y(t,e),renderer:(t,e,i)=>new x(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,n)=>{}}),t.Platform.layout=y.fullLayout;const{getSpread:A,getOuterOf:O,getByMove:M,getIntersectData:T}=t.BoundsHelper;let D;const{stintSet:W}=t.DataHelper,{hasTransparent:I}=e.ColorConvert;function z(i,n,s){if(!t.isObject(n)||!1===n.visible||0===n.opacity)return;let a;const{boxBounds:r}=s.__layout;switch(n.type){case"image":a=e.PaintImage.image(s,i,n,r,!D||!D[n.url]);break;case"linear":a=e.PaintGradient.linearGradient(n,r);break;case"radial":a=e.PaintGradient.radialGradient(n,r);break;case"angular":a=e.PaintGradient.conicGradient(n,r);break;case"solid":const{type:o,color:l,opacity:d}=n;a={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(n.r)||(a={type:"solid",style:e.ColorConvert.string(n)})}if(a){if(t.isString(a.style)&&I(a.style)&&(a.isTransparent=!0),n.style){if(0===n.style.strokeWidth)return;a.strokeStyle=n.style}n.editing&&(a.editing=n.editing),n.blendMode&&(a.blendMode=n.blendMode)}return a}const H={compute:function(i,n){const s=n.__,a=[];let r,o,l,d=s.__input[i];t.isArray(d)||(d=[d]),D=e.PaintImage.recycleImage(i,s);for(let t,e=0,s=d.length;e<s;e++)(t=z(i,d[e],n))&&(a.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));s["_"+i]=a.length?a:void 0,a.length&&a.every(t=>t.isTransparent)&&(a.some(t=>t.image)&&(r=!0),o=!0),"fill"===i?(W(s,"__isAlphaPixelFill",r),W(s,"__isTransparentFill",o)):(W(s,"__isAlphaPixelStroke",r),W(s,"__isTransparentStroke",o),W(s,"__hasMultiStrokeStyle",l))},fill:function(t,e,i){i.fillStyle=t,E(e,i)},fills:function(t,i,n){let s;for(let a=0,r=t.length;a<r;a++){if(s=t[a],s.image){if(e.PaintImage.checkImage(i,n,s,!i.__.__font))continue;if(!s.style){!a&&s.image.isPlacehold&&i.drawImagePlaceholder(n,s.image);continue}}if(n.fillStyle=s.style,s.transform||s.scaleFixed){if(n.save(),s.transform&&n.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:e}=i.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&e>1)&&n.scale(1/t,1/e)}s.blendMode&&(n.blendMode=s.blendMode),E(i,n),n.restore()}else s.blendMode?(n.saveBlendMode(s.blendMode),E(i,n),n.restoreBlendMode()):E(i,n)}},fillPathOrText:E,fillText:b,stroke:P,strokes:function(t,e,i){P(t,e,i)},strokeText:B,drawTextStroke:S,shape:function(e,i,n){const s=i.getSameCanvas(),a=e.__nowWorld,r=i.bounds;let o,l,d,h,c,{scaleX:u,scaleY:f}=e.getRenderScaleData(!0);if(r.includes(a))c=s,o=h=a;else{const{renderShapeSpread:s}=e.__layout;let p;if(t.Platform.fullImageShadow)p=a;else{const t=s?A(r,u===f?s*u:[s*f,s*u]):r;p=T(t,a)}d=r.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(c=i.getSameCanvas(),e.__renderShape(c,n),u*=g,f*=_),h=O(a,d),o=M(h,-d.e,-d.f);const m=n.matrix;m?(l=new t.Matrix(d),l.multiply(m),g*=m.scaleX,_*=m.scaleY):l=d,l.withScale(g,_),n=Object.assign(Object.assign({},n),{matrix:l})}return e.__renderShape(s,n),{canvas:s,matrix:l,fitMatrix:d,bounds:o,worldCanvas:c,shapeBounds:h,scaleX:u,scaleY:f}}};let F={},U=t.getMatrixData();const{get:j,rotateOfOuter:G,translate:V,scaleOfOuter:Y,multiplyParent:N,scale:q,rotate:X,skew:Q}=t.MatrixHelper;function Z(t,e,i,n,s,a,r){const o=j();V(o,e.x+i,e.y+n),q(o,s,a),r&&G(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function $(t,e,i,n,s,a,r,o,l){const d=j();J(d,e,i,n,s,a,r,o),l&&(U.a=e.width/l.width,U.d=e.height/l.height,N(d,U)),t.transform=d}function K(t,e,i,n,s,a,r,o,l,d,h,c){const u=j();if(c)J(u,e,s,a,r,o,l,d);else{if(l)if("center"===h)G(u,{x:i/2,y:n/2},l);else switch(X(u,l),l){case 90:V(u,n,0);break;case 180:V(u,i,n);break;case 270:V(u,0,i)}F.x=e.x+s,F.y=e.y+a,V(u,F.x,F.y),r&&Y(u,F,r,o)}t.transform=u}function J(t,e,i,n,s,a,r,o){r&&X(t,r),o&&Q(t,o.x,o.y),s&&q(t,s,a),V(t,e.x+i,e.y+n)}const{get:tt,translate:et}=t.MatrixHelper,it=new t.Bounds,nt={},st={};function at(t,e,i,n){const{changeful:s,sync:a,scaleFixed:r}=i;s&&(t.changeful=s),a&&(t.sync=a),r&&(t.scaleFixed=r),t.data=rt(i,n,e)}function rt(e,i,n){e.padding&&(i=it.set(i).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:s,height:a}=n;const{opacity:r,mode:o,align:l,offset:d,scale:h,size:c,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,w=i.width===s&&i.height===a,y={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(st,0,0,v?a:s,v?s:a),o&&"cover"!==o&&"fit"!==o?((h||c)&&(t.MathHelper.getScaleData(h,c,n,nt),x=nt.scaleX,b=nt.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(st,x,b,!0),l&&t.AlignHelper.toPoint(l,st,i,st,!0,!0))):w&&!u||(x=b=t.BoundsHelper.getFitScale(i,st,"fit"!==o),t.BoundsHelper.put(i,n,l,x,!1,st),t.BoundsHelper.scale(st,x,b,!0)),d&&t.PointHelper.move(st,d),o){case"stretch":w||(s=i.width,a=i.height);break;case"normal":case"clip":(st.x||st.y||x||p||u||f)&&$(y,i,st.x,st.y,x,b,u,f,e.clipSize);break;case"repeat":(!w||x||u||f)&&K(y,i,s,a,st.x,st.y,x,b,u,f,l,e.freeTransform),g||(y.repeat="repeat");const n=t.isObject(g);(_||n)&&(y.gap=function(e,i,n,s,a){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:ot(r,n,a.width,i&&i.x),y:ot(o,s,a.height,i&&i.y)}}(_,n&&g,st.width,st.height,i));break;default:x&&Z(y,i,st.x,st.y,x,b,u)}return y.transform||(i.x||i.y)&&(y.transform=tt(),et(y.transform,i.x,i.y)),x&&"stretch"!==o&&(y.scaleX=x,y.scaleY=b),y.width=s,y.height=a,r&&(y.opacity=r),m&&(y.filters=m),g&&(y.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function ot(e,i,n,s){const a=t.isString(e)||s?(s?n-s*i:n%i)/((s||Math.floor(n/i))-1):e;return"auto"===e&&a<0?0:a}let lt,dt=new t.Bounds;const{isSame:ht}=t.BoundsHelper;function ct(t,e,i,n,s,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=n.width/e.pixelRatio,e.__naturalHeight=n.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return s.data||at(s,n,i,a),!0}function ut(e,i){gt(e,t.ImageEvent.LOAD,i)}function ft(e,i){gt(e,t.ImageEvent.LOADED,i)}function pt(e,i,n){i.error=n,e.forceUpdate("surface"),gt(e,t.ImageEvent.ERROR,i)}function gt(e,i,n){e.hasEvent(i)&&e.emitEvent(new t.ImageEvent(i,n))}function _t(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:mt,scale:wt,copy:yt}=t.MatrixHelper,{floor:vt,ceil:xt,max:bt,abs:Et}=Math;function Bt(e,i,n){let{scaleX:s,scaleY:a}=e.getRenderScaleData(!0,i.scaleFixed);const r=s+"-"+a+"-"+n;if(i.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=i;let d,h,{width:c,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;s*=n,a*=n,f&&(f=Et(f),p=Et(p),h=mt(),yt(h,g),wt(h,1/f,1/p),s*=f,a*=p),c*=s,u*=a;const w=c*u;if(!_&&w>t.Platform.image.maxCacheSize)return!1;let y=t.Platform.image.maxPatternSize;if(o.isSVG){const t=c/o.width;t>1&&(d=t/xt(t))}else{const t=o.width*o.height;y>t&&(y=t)}w>y&&(d=Math.sqrt(w/y)),d&&(s/=d,a/=d,c/=d,u/=d),f&&(s/=f,a/=p);const v=m&&m.x*s,x=m&&m.y*a;if(g||1!==s||1!==a){const t=c+(v||0),e=u+(x||0);s/=t/bt(vt(t),1),a/=e/bt(vt(e),1),h||(h=mt(),g&&yt(h,g)),wt(h,1/s,1/a)}const b=o.getCanvas(c,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),E=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",h,i);return i.style=E,i.patternId=r,!0}}function Rt(t,e,i,n){return new(i||(i=Promise))(function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((n=n.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Lt={image:function(e,i,n,s,a){let r,o;const l=t.ImageManager.get(n);return lt&&n===lt.paint&&ht(s,lt.boxBounds)?r=lt.leafPaint:(r={type:n.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),lt=l.use>1?{leafPaint:r,paint:n,boxBounds:dt.set(s)}:null),(a||l.loading)&&(o={image:l,attrName:i,attrValue:n}),l.ready?(ct(e,i,n,l,r,s),a&&(ut(e,o),ft(e,o))):l.error?a&&pt(e,o,l.error):(a&&(_t(e,!0),ut(e,o)),r.loadId=l.load(()=>{_t(e,!1),e.destroyed||(ct(e,i,n,l,r,s)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ft(e,o)),r.loadId=void 0},t=>{_t(e,!1),pt(e,o,t),r.loadId=void 0}),e.placeholderColor&&(e.placeholderDelay?setTimeout(()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))},e.placeholderDelay):l.isPlacehold=!0)),r},checkImage:function(i,n,s,a){const{scaleX:r,scaleY:o}=i.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:l}=n,{data:d}=s;if(!d||s.patternId===r+"-"+o+"-"+l&&!e.Export.running)return!1;if(a)if(d.repeat)a=!1;else if(!(s.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(i)||e.Export.running)){let{width:e,height:i}=d;e*=r*l,i*=o*l,d.scaleX&&(e*=d.scaleX,i*=d.scaleY),a=e*i>t.Platform.image.maxCacheSize}return a?(i.__.__isFastShadow&&(n.fillStyle=s.style||"#000",n.fill()),function(t,e,i,n){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);n.opacity&&(e.opacity*=n.opacity);n.transform&&e.transform(n.transform);e.drawImage(i.image.getFull(n.filters),0,0,n.width,n.height),e.restore()}(i,n,s,d),!0):(!s.style||s.sync||e.Export.running?Bt(i,s,l):s.patternTask||(s.patternTask=t.ImageManager.patternTasker.add(()=>Rt(this,void 0,void 0,function*(){s.patternTask=null,n.bounds.hit(i.__nowWorld)&&Bt(i,s,l),i.forceUpdate("surface")}),300)),!1)},createPattern:Bt,recycleImage:function(e,i){const n=i["_"+e];if(t.isArray(n)){let s,a,r,o,l;for(let d=0,h=n.length;d<h;d++)s=n[d],a=s.image,l=a&&a.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(a),a.loading&&(o||(o=i.__input&&i.__input[e]||[],t.isArray(o)||(o=[o])),a.unload(n[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:at,getPatternData:rt,fillOrFitMode:Z,clipMode:$,repeatMode:K},{toPoint:St}=t.AroundHelper,{hasTransparent:kt}=e.ColorConvert,Pt={},Ct={};function At(i,n,s,a){if(s){let r,o,l,d;for(let i=0,h=s.length;i<h;i++)r=s[i],t.isString(r)?(l=i/(h-1),o=e.ColorConvert.string(r,a)):(l=r.offset,o=e.ColorConvert.string(r.color,a)),n.addColorStop(l,o),!d&&kt(o)&&(d=!0);d&&(i.isTransparent=!0)}}const{getAngle:Ot,getDistance:Mt}=t.PointHelper,{get:Tt,rotateOfOuter:Dt,scaleOfOuter:Wt}=t.MatrixHelper,{toPoint:It}=t.AroundHelper,zt={},Ht={};function Ft(t,e,i,n,s){let a;const{width:r,height:o}=t;if(r!==o||n){const t=Ot(e,i);a=Tt(),s?(Wt(a,e,r/o*(n||1),1),Dt(a,e,t+90)):(Wt(a,e,1,r/o*(n||1)),Dt(a,e,t))}return a}const{getDistance:Ut}=t.PointHelper,{toPoint:jt}=t.AroundHelper,Gt={},Vt={};const Yt={linearGradient:function(e,i){let{from:n,to:s,type:a,opacity:r}=e;St(n||"top",i,Pt),St(s||"bottom",i,Ct);const o=t.Platform.canvas.createLinearGradient(Pt.x,Pt.y,Ct.x,Ct.y),l={type:a,style:o};return At(l,o,e.stops,r),l},radialGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;It(n||"center",i,zt),It(s||"bottom",i,Ht);const l=t.Platform.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,Mt(zt,Ht)),d={type:a,style:l};At(d,l,e.stops,r);const h=Ft(i,zt,Ht,o,!0);return h&&(d.transform=h),d},conicGradient:function(e,i){let{from:n,to:s,type:a,opacity:r,stretch:o}=e;jt(n||"center",i,Gt),jt(s||"bottom",i,Vt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Gt.x,Gt.y):t.Platform.canvas.createRadialGradient(Gt.x,Gt.y,0,Gt.x,Gt.y,Ut(Gt,Vt)),d={type:a,style:l};At(d,l,e.stops,r);const h=Ft(i,Gt,Vt,o||1,t.Platform.conicGradientRotate90);return h&&(d.transform=h),d},getTransform:Ft},{copy:Nt,toOffsetOutBounds:qt}=t.BoundsHelper,Xt={},Qt={};function Zt(e,i,n,s){const{bounds:a,shapeBounds:r}=s;if(t.Platform.fullImageShadow){if(Nt(Xt,e.bounds),Xt.x+=i.x-r.x,Xt.y+=i.y-r.y,n){const{fitMatrix:t}=s;Xt.x-=(a.x+(t?t.e:0)+a.width/2)*(n-1),Xt.y-=(a.y+(t?t.f:0)+a.height/2)*(n-1),Xt.width*=n,Xt.height*=n}e.copyWorld(s.canvas,e.bounds,Xt)}else n&&(Nt(Xt,i),Xt.x-=i.width/2*(n-1),Xt.y-=i.height/2*(n-1),Xt.width*=n,Xt.height*=n),e.copyWorld(s.canvas,r,n?Xt:i)}const{toOffsetOutBounds:$t}=t.BoundsHelper,Kt={};const Jt={shadow:function(i,n,s){let a,r;const{__nowWorld:o,__layout:l}=i,{shadow:d}=i.__,{worldCanvas:h,bounds:c,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=d.length-1;qt(c,Qt),d.forEach((d,m)=>{let w=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.setWorldShadow(Qt.offsetX+d.x*f*w,Qt.offsetY+d.y*p*w,d.blur*f*w,e.ColorConvert.string(d.color)),r=d.spread?1+2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*w:0,Zt(g,Qt,r,s),a=c,d.box&&(g.restore(),g.save(),h&&(g.copyWorld(g,c,o,"copy"),a=o),h?g.copyWorld(h,o,o,"destination-out"):g.copyWorld(s.canvas,u,c,"destination-out")),e.Effect.isTransformShadow(d)?e.Effect.renderTransformShadow(i,n,g,a,d):t.LeafHelper.copyCanvasByWorld(i,n,g,a,d.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},innerShadow:function(i,n,s){let a,r;const{__nowWorld:o,__layout:l}=i,{innerShadow:d}=i.__,{worldCanvas:h,bounds:c,shapeBounds:u,scaleX:f,scaleY:p}=s,g=n.getSameCanvas(),_=d.length-1;$t(c,Kt),d.forEach((d,m)=>{let w=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(w=1/t)}g.save(),g.setWorldShadow(Kt.offsetX+d.x*f*w,Kt.offsetY+d.y*p*w,d.blur*f*w),r=d.spread?1-2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*w:0,Zt(g,Kt,r,s),g.restore(),h?(g.copyWorld(g,c,o,"copy"),g.copyWorld(h,o,o,"source-out"),a=o):(g.copyWorld(s.canvas,u,c,"source-out"),a=c),g.fillWorld(a,e.ColorConvert.string(d.color),"source-in"),t.LeafHelper.copyCanvasByWorld(i,n,g,a,d.blendMode),_&&m<_&&g.clearWorld(a)}),g.recycle(a)},blur:function(t,e,i){const{blur:n}=t.__;i.setWorldBlur(n*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:te}=t.LeafBoundsHelper;let ee;function ie(t,e,i,n,s,a,r,o){switch(e){case"grayscale":ee||(ee=!0,s.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,n,s,a){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(n,r),a&&n.recycle(r);se(t,e,i,1,s,a)}(t,i,n,s,r,o);break;case"opacity-path":se(t,i,n,a,r,o);break;case"path":o&&i.restore()}}function ne(t){return t.getSameCanvas(!1,!0)}function se(t,e,i,n,s,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=n,e.copyWorld(i,r,void 0,s),a?i.recycle(r):i.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let i,n,s,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&&(ie(this,r,t,s,n,a,void 0,!0),n=s=null),a=i.__.opacity,ee=!1,"path"===o||"clipping-path"===o?(a<1?(r="opacity-path",s||(s=ne(t))):(r="path",t.save()),i.__clip(s||t,e)):(r="grayscale"===o?"grayscale":"alpha",n||(n=ne(t)),s||(s=ne(t)),i.__render(n,e)),"clipping"!==o&&"clipping-path"!==o||te(i,e)||i.__render(t,e);continue}const h=1===a&&i.__.__blendMode;h&&ie(this,r,t,s,n,a,void 0,!1),te(i,e)||i.__render(s||t,e),h&&ie(this,r,t,s,n,a,h,!1)}ie(this,r,t,s,n,a,void 0,!0)};const ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",re=ae+"_#~&*+\\=|≮≯≈≠=…",oe=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 le(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const de=le("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),he=le("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ce=le(ae),ue=le(re),fe=le("- —/~|┆·");var pe;!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"}(pe||(pe={}));const{Letter:ge,Single:_e,Before:me,After:we,Symbol:ye,Break:ve}=pe;function xe(t){return de[t]?ge:fe[t]?ve:he[t]?me:ce[t]?we:ue[t]?ye:oe.test(t)?_e:ge}const be={trimRight(t){const{words:e}=t;let i,n=0,s=e.length;for(let a=s-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)n++,t.width-=i.width;n&&e.splice(s-n,n)}};function Ee(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:Be}=be,{Letter:Re,Single:Le,Before:Se,After:ke,Symbol:Pe,Break:Ce}=pe;let Ae,Oe,Me,Te,De,We,Ie,ze,He,Fe,Ue,je,Ge,Ve,Ye,Ne,qe,Xe=[];function Qe(t,e){He&&!ze&&(ze=He),Ae.data.push({char:t,width:e}),Me+=e}function Ze(){Te+=Me,Ae.width=Me,Oe.words.push(Ae),Ae={data:[]},Me=0}function $e(){Ve&&(Ye.paraNumber++,Oe.paraStart=!0,Ve=!1),He&&(Oe.startCharSize=ze,Oe.endCharSize=He,ze=0),Oe.width=Te,Ne.width?Be(Oe):qe&&Ke(),Xe.push(Oe),Oe={words:[]},Te=0}function Ke(){Te>(Ye.maxWidth||0)&&(Ye.maxWidth=Te)}const{top:Je,right:ti,bottom:ei,left:ii}=t.Direction4;function ni(t,e,i){const{bounds:n,rows:s}=t;n[e]+=i;for(let t=0;t<s.length;t++)s[t][e]+=i}const si={getDrawData:function(i,n){t.isString(i)||(i=String(i));let s=0,a=0,r=n.__getInput("width")||0,o=n.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:h}=n;h&&(r?(s=h[ii],r-=h[ti]+h[ii]):n.autoSizeAlign||(s=h[ii]),o?(a=h[Je],o-=h[Je]+h[ei]):n.autoSizeAlign||(a=h[Je]));const c={bounds:{x:s,y:a,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,i,n){Ye=e,Xe=e.rows,Ne=e.bounds,qe=!Ne.width&&!n.autoSizeAlign;const{__letterSpacing:s,paraIndent:a,textCase:r}=n,{canvas:o}=t.Platform,{width:l,height:d}=Ne;if(l||d||s||"none"!==r){const t="none"!==n.textWrap,e="break"===n.textWrap;Ve=!0,Ue=null,ze=Ie=He=Me=Te=0,Ae={data:[]},Oe={words:[]},s&&(i=[...i]);for(let n=0,d=i.length;n<d;n++)We=i[n],"\n"===We?(Me&&Ze(),Oe.paraEnd=!0,$e(),Ve=!0):(Fe=xe(We),Fe===Re&&"none"!==r&&(We=Ee(We,r,!Me)),Ie=o.measureText(We).width,s&&(s<0&&(He=Ie),Ie+=s),je=Fe===Le&&(Ue===Le||Ue===Re)||Ue===Le&&Fe!==ke,Ge=!(Fe!==Se&&Fe!==Le||Ue!==Pe&&Ue!==ke),De=Ve&&a?l-a:l,t&&l&&Te+Me+Ie>De&&(e?(Me&&Ze(),Te&&$e()):(Ge||(Ge=Fe===Re&&Ue==ke),je||Ge||Fe===Ce||Fe===Se||Fe===Le||Me+Ie>De?(Me&&Ze(),Te&&$e()):Te&&$e()))," "===We&&!0!==Ve&&Te+Me===0||(Fe===Ce?(" "===We&&Me&&Ze(),Qe(We,Ie),Ze()):je||Ge?(Me&&Ze(),Qe(We,Ie)):Qe(We,Ie)),Ue=Fe);Me&&Ze(),Te&&$e(),Xe.length>0&&(Xe[Xe.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Ye.paraNumber++,Te=o.measureText(t).width,Xe.push({x:a||0,text:t,width:Te,paraStart:!0}),qe&&Ke()})}(c,i,n),h&&function(t,e,i,n,s){if(!n&&i.autoSizeAlign)switch(i.textAlign){case"left":ni(e,"x",t[ii]);break;case"right":ni(e,"x",-t[ti])}if(!s&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ni(e,"y",t[Je]);break;case"bottom":ni(e,"y",-t[ei])}}(h,c,n,r,o),function(t,e){const{rows:i,bounds:n}=t,s=i.length,{__lineHeight:a,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:h,paraSpacing:c,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=n,m=a*s+(c?c*(t.paraNumber-1):0),w=r;if(l&&m>_)m=Math.max(_,a),s>1&&(t.overflow=s);else if(_||u)switch(h){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}w+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let r=0,h=s;r<h;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-y.width}y.paraStart&&c&&r>0&&(w+=c),y.y=w,w+=a,t.overflow>r&&w>m&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,o<0&&(y.width<0?(x=-y.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<n.x&&(n.x=v),x>n.width&&(n.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}n.y=p,n.height=m}(c,n),function(t,e,i){const{rows:n}=t,{textAlign:s,paraIndent:a,letterSpacing:r}=e;let o,l,d,h,c,u;n.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===s||"both"===s)&&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,n){return t.forEach(t=>{(n||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==s||i===u-1||(o+=l,t.width+=l)})),t.words=null)})}(c,n,r),c.overflow&&function(e,i,n,s){if(!s)return;const{rows:a,overflow:r}=e;let{textOverflow:o}=i;if(a.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,h=n+s-d;("none"===i.textWrap?a:[a[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let i=t.data.length-1;for(let n=i;n>-1&&(e=t.data[n],l=e.x+e.width,!(n===i&&l<h));n--){if(l<h&&" "!==e.char||!n){t.data.splice(n+1),t.width-=e.width;break}t.width-=e.width}t.width+=d,t.data.push({char:o,x:l}),t.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(t)}})}}(c,n,s,r),"none"!==l&&function(i,n){let s,a=0;const{fontSize:r,textDecoration:o}=n;switch(i.decorationHeight=r/11,t.isObject(o)?(s=o.type,o.color&&(i.decorationColor=e.ColorConvert.string(o.color)),o.offset&&(a=Math.min(.3*r,Math.max(o.offset,.15*-r)))):s=o,s){case"under":i.decorationY=[.15*r+a];break;case"delete":i.decorationY=[.35*-r];break;case"under-delete":i.decorationY=[.15*r+a,.35*-r]}}(c,n),c}};const ai={string:function(i,n){const s=t.isNumber(n)&&n<1;if(t.isString(i)){if(!s||!e.ColorConvert.object)return i;i=e.ColorConvert.object(i)}let a=t.isUndefined(i.a)?1:i.a;s&&(a*=n);const r=i.r+","+i.g+","+i.b;return 1===a?"rgb("+r+")":"rgba("+r+","+a+")"}};Object.assign(e.TextConvert,si),Object.assign(e.ColorConvert,ai),Object.assign(e.Paint,H),Object.assign(e.PaintImage,Lt),Object.assign(e.PaintGradient,Yt),Object.assign(e.Effect,Jt),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=y,exports.LeaferCanvas=n,exports.Renderer=x,exports.Watcher=l,exports.useCanvas=r,Object.keys(t).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}),Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
2
2
  //# sourceMappingURL=web.min.cjs.map