@leafer-draw/worker 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/worker.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
  class LeaferCanvas extends LeaferCanvasBase {
6355
6356
  get allowBackgroundColor() {
6356
6357
  return true;
@@ -7284,8 +7285,6 @@ var LeaferUI = function(exports) {
7284
7285
  if (!boxStyle) box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
7285
7286
  box.set(value);
7286
7287
  if (boxLayout.strokeChanged) layout.strokeChange();
7287
- if (boxLayout.renderChanged) layout.renderChange();
7288
- box.__updateChange();
7289
7288
  } else if (box) {
7290
7289
  t.__box = box.parent = null;
7291
7290
  box.destroy();
@@ -7352,7 +7351,7 @@ var LeaferUI = function(exports) {
7352
7351
  __updateRenderSpread() {
7353
7352
  let width = 0;
7354
7353
  const {shadow: shadow, innerShadow: innerShadow, blur: blur, backgroundBlur: backgroundBlur, filter: filter, renderSpread: renderSpread} = this.__;
7355
- 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));
7354
+ if (shadow) width = Effect.getShadowSpread(this, shadow);
7356
7355
  if (blur) width = Math.max(width, blur);
7357
7356
  if (filter) width += Filter.getSpread(filter);
7358
7357
  if (renderSpread) width += renderSpread;
@@ -7364,36 +7363,67 @@ var LeaferUI = function(exports) {
7364
7363
  return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
7365
7364
  }
7366
7365
  };
7366
+ const {float: float} = MathHelper;
7367
+ const tempContent = new Bounds, tempMerge = new Bounds, tempIntersect = new Bounds;
7367
7368
  const DragBoundsHelper = {
7369
+ limitMove(leaf, move) {
7370
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7371
+ if (dragBounds) D.getValidMove(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, move, true);
7372
+ D.axisMove(leaf, move);
7373
+ },
7374
+ limitScaleOf(leaf, origin, scale) {
7375
+ const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7376
+ if (dragBounds) D.getValidScaleOf(leaf.__localBoxBounds, D.getDragBounds(leaf), dragBoundsType, leaf.getLocalPointByInner(leaf.getInnerPointByBox(origin)), scale, true);
7377
+ },
7378
+ axisMove(leaf, move) {
7379
+ const {draggable: draggable} = leaf;
7380
+ if (draggable === "x") move.y = 0;
7381
+ if (draggable === "y") move.x = 0;
7382
+ },
7383
+ getDragBounds(leaf) {
7384
+ const {dragBounds: dragBounds} = leaf;
7385
+ return dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds;
7386
+ },
7387
+ isInnerMode(content, dragBounds, dragBoundsType, sideType) {
7388
+ return dragBoundsType === "inner" || dragBoundsType === "auto" && content[sideType] > dragBounds[sideType];
7389
+ },
7368
7390
  getValidMove(content, dragBounds, dragBoundsType, move, change) {
7369
7391
  const x = content.x + move.x, y = content.y + move.y, right = x + content.width, bottom = y + content.height;
7370
7392
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
7371
7393
  if (!change) move = Object.assign({}, move);
7372
- const isBiggerWidth = content.width > dragBounds.width;
7373
- const isBiggerHeight = content.height > dragBounds.height;
7374
- if (isBiggerWidth && dragBoundsType !== "outer") {
7394
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7375
7395
  if (x > dragBounds.x) move.x += dragBounds.x - x; else if (right < boundsRight) move.x += boundsRight - right;
7376
7396
  } else {
7377
7397
  if (x < dragBounds.x) move.x += dragBounds.x - x; else if (right > boundsRight) move.x += boundsRight - right;
7378
7398
  }
7379
- if (isBiggerHeight && dragBoundsType !== "outer") {
7399
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7380
7400
  if (y > dragBounds.y) move.y += dragBounds.y - y; else if (bottom < boundsBottom) move.y += boundsBottom - bottom;
7381
7401
  } else {
7382
7402
  if (y < dragBounds.y) move.y += dragBounds.y - y; else if (bottom > boundsBottom) move.y += boundsBottom - bottom;
7383
7403
  }
7384
- move.x = MathHelper.float(move.x);
7385
- move.y = MathHelper.float(move.y);
7404
+ move.x = float(move.x);
7405
+ move.y = float(move.y);
7386
7406
  return move;
7387
7407
  },
7388
- axisMove(leaf, move) {
7389
- const {draggable: draggable} = leaf;
7390
- if (draggable === "x") move.y = 0;
7391
- if (draggable === "y") move.x = 0;
7392
- },
7393
- limitMove(leaf, move) {
7394
- const {dragBounds: dragBounds, dragBoundsType: dragBoundsType} = leaf;
7395
- if (dragBounds) D.getValidMove(leaf.__localBoxBounds, dragBounds === "parent" ? leaf.parent.boxBounds : dragBounds, dragBoundsType, move, true);
7396
- D.axisMove(leaf, move);
7408
+ getValidScaleOf(content, dragBounds, dragBoundsType, origin, scale, change) {
7409
+ if (!change) scale = Object.assign({}, scale);
7410
+ let fitScaleX, fitScaleY;
7411
+ tempContent.set(content).scaleOf(origin, scale.x, scale.y).unsign();
7412
+ tempMerge.set(tempContent).add(dragBounds);
7413
+ tempIntersect.set(tempContent).intersect(dragBounds);
7414
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
7415
+ fitScaleX = tempMerge.width / tempContent.width;
7416
+ } else {
7417
+ fitScaleX = tempIntersect.width / tempContent.width;
7418
+ }
7419
+ if (D.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
7420
+ fitScaleY = tempMerge.height / tempContent.height;
7421
+ } else {
7422
+ fitScaleY = tempIntersect.height / tempContent.height;
7423
+ }
7424
+ scale.x = float(tempIntersect.width) ? scale.x * fitScaleX : 1;
7425
+ scale.y = float(tempIntersect.height) ? scale.y * fitScaleY : 1;
7426
+ return scale;
7397
7427
  }
7398
7428
  };
7399
7429
  const D = DragBoundsHelper;
@@ -7408,7 +7438,7 @@ var LeaferUI = function(exports) {
7408
7438
  }
7409
7439
  if (data.__useEffect) {
7410
7440
  const {shadow: shadow, fill: fill, stroke: stroke} = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7411
- 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"));
7441
+ 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"));
7412
7442
  data.__useEffect = !!(shadow || otherEffect);
7413
7443
  }
7414
7444
  data.__checkSingle();
@@ -7960,7 +7990,9 @@ var LeaferUI = function(exports) {
7960
7990
  } else if (attrName === "zIndex") {
7961
7991
  this.canvas.zIndex = newValue;
7962
7992
  setTimeout(() => this.parent && this.parent.__updateSortChildren());
7963
- }
7993
+ } else if (attrName === "mode") this.emit(LeaferEvent.UPDATE_MODE, {
7994
+ mode: newValue
7995
+ });
7964
7996
  }
7965
7997
  return super.__setAttr(attrName, newValue);
7966
7998
  }
@@ -8139,6 +8171,7 @@ var LeaferUI = function(exports) {
8139
8171
  exports.Leafer.list = new LeafList;
8140
8172
  __decorate([ dataProcessor(LeaferData) ], exports.Leafer.prototype, "__", void 0);
8141
8173
  __decorate([ boundsType() ], exports.Leafer.prototype, "pixelRatio", void 0);
8174
+ __decorate([ dataType("normal") ], exports.Leafer.prototype, "mode", void 0);
8142
8175
  exports.Leafer = Leafer_1 = __decorate([ registerUI() ], exports.Leafer);
8143
8176
  exports.Rect = class Rect extends exports.UI {
8144
8177
  get __tag() {
@@ -8298,45 +8331,8 @@ var LeaferUI = function(exports) {
8298
8331
  __decorate([ pathType(0) ], exports.Ellipse.prototype, "startAngle", void 0);
8299
8332
  __decorate([ pathType(0) ], exports.Ellipse.prototype, "endAngle", void 0);
8300
8333
  exports.Ellipse = __decorate([ registerUI() ], exports.Ellipse);
8301
- const {moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1} = PathCommandDataHelper;
8302
- const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8303
- exports.Line = class Line extends exports.UI {
8304
- get __tag() {
8305
- return "Line";
8306
- }
8307
- get toPoint() {
8308
- const {width: width, rotation: rotation} = this.__;
8309
- const to = getPointData();
8310
- if (width) to.x = width;
8311
- if (rotation) rotate$1(to, rotation);
8312
- return to;
8313
- }
8314
- set toPoint(value) {
8315
- this.width = getDistance$2(defaultPoint, value);
8316
- this.rotation = getAngle$1(defaultPoint, value);
8317
- if (this.height) this.height = 0;
8318
- }
8319
- __updatePath() {
8320
- const data = this.__;
8321
- const path = data.path = [];
8322
- if (data.points) {
8323
- drawPoints$1(path, data.points, data.curve, data.closed);
8324
- } else {
8325
- moveTo$2(path, 0, 0);
8326
- lineTo$2(path, this.width, 0);
8327
- }
8328
- }
8329
- };
8330
- __decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
8331
- __decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
8332
- __decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
8333
- __decorate([ pathType() ], exports.Line.prototype, "points", void 0);
8334
- __decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
8335
- __decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
8336
- exports.Line = __decorate([ registerUI() ], exports.Line);
8337
8334
  const {sin: sin$1, cos: cos$1, PI: PI$1} = Math;
8338
- const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints: drawPoints} = PathCommandDataHelper;
8339
- const line = exports.Line.prototype;
8335
+ const {moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1} = PathCommandDataHelper;
8340
8336
  exports.Polygon = class Polygon extends exports.UI {
8341
8337
  get __tag() {
8342
8338
  return "Polygon";
@@ -8345,29 +8341,25 @@ var LeaferUI = function(exports) {
8345
8341
  const data = this.__;
8346
8342
  const path = data.path = [];
8347
8343
  if (data.points) {
8348
- drawPoints(path, data.points, data.curve, true);
8344
+ drawPoints$1(path, data.points, data.curve, true);
8349
8345
  } else {
8350
8346
  const {width: width, height: height, sides: sides} = data;
8351
8347
  const rx = width / 2, ry = height / 2;
8352
- moveTo$1(path, rx, 0);
8348
+ moveTo$2(path, rx, 0);
8353
8349
  for (let i = 1; i < sides; i++) {
8354
- lineTo$1(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
8350
+ lineTo$2(path, rx + rx * sin$1(i * 2 * PI$1 / sides), ry - ry * cos$1(i * 2 * PI$1 / sides));
8355
8351
  }
8356
8352
  closePath$1(path);
8357
8353
  }
8358
8354
  }
8359
- __updateRenderPath() {}
8360
- __updateBoxBounds() {}
8361
8355
  };
8362
8356
  __decorate([ dataProcessor(PolygonData) ], exports.Polygon.prototype, "__", void 0);
8363
8357
  __decorate([ pathType(3) ], exports.Polygon.prototype, "sides", void 0);
8364
8358
  __decorate([ pathType() ], exports.Polygon.prototype, "points", void 0);
8365
8359
  __decorate([ pathType(0) ], exports.Polygon.prototype, "curve", void 0);
8366
- __decorate([ rewrite(line.__updateRenderPath) ], exports.Polygon.prototype, "__updateRenderPath", null);
8367
- __decorate([ rewrite(line.__updateBoxBounds) ], exports.Polygon.prototype, "__updateBoxBounds", null);
8368
8360
  exports.Polygon = __decorate([ rewriteAble(), registerUI() ], exports.Polygon);
8369
8361
  const {sin: sin, cos: cos, PI: PI} = Math;
8370
- const {moveTo: moveTo, lineTo: lineTo, closePath: closePath} = PathCommandDataHelper;
8362
+ const {moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath} = PathCommandDataHelper;
8371
8363
  exports.Star = class Star extends exports.UI {
8372
8364
  get __tag() {
8373
8365
  return "Star";
@@ -8376,9 +8368,9 @@ var LeaferUI = function(exports) {
8376
8368
  const {width: width, height: height, corners: corners, innerRadius: innerRadius} = this.__;
8377
8369
  const rx = width / 2, ry = height / 2;
8378
8370
  const path = this.__.path = [];
8379
- moveTo(path, rx, 0);
8371
+ moveTo$1(path, rx, 0);
8380
8372
  for (let i = 1; i < corners * 2; i++) {
8381
- lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin(i * PI / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos(i * PI / corners));
8373
+ 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));
8382
8374
  }
8383
8375
  closePath(path);
8384
8376
  }
@@ -8387,6 +8379,42 @@ var LeaferUI = function(exports) {
8387
8379
  __decorate([ pathType(5) ], exports.Star.prototype, "corners", void 0);
8388
8380
  __decorate([ pathType(.382) ], exports.Star.prototype, "innerRadius", void 0);
8389
8381
  exports.Star = __decorate([ registerUI() ], exports.Star);
8382
+ const {moveTo: moveTo, lineTo: lineTo, drawPoints: drawPoints} = PathCommandDataHelper;
8383
+ const {rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint: defaultPoint} = PointHelper;
8384
+ exports.Line = class Line extends exports.UI {
8385
+ get __tag() {
8386
+ return "Line";
8387
+ }
8388
+ get toPoint() {
8389
+ const {width: width, rotation: rotation} = this.__;
8390
+ const to = getPointData();
8391
+ if (width) to.x = width;
8392
+ if (rotation) rotate$1(to, rotation);
8393
+ return to;
8394
+ }
8395
+ set toPoint(value) {
8396
+ this.width = getDistance$2(defaultPoint, value);
8397
+ this.rotation = getAngle$1(defaultPoint, value);
8398
+ if (this.height) this.height = 0;
8399
+ }
8400
+ __updatePath() {
8401
+ const data = this.__;
8402
+ const path = data.path = [];
8403
+ if (data.points) {
8404
+ drawPoints(path, data.points, data.curve, data.closed);
8405
+ } else {
8406
+ moveTo(path, 0, 0);
8407
+ lineTo(path, this.width, 0);
8408
+ }
8409
+ }
8410
+ };
8411
+ __decorate([ dataProcessor(LineData) ], exports.Line.prototype, "__", void 0);
8412
+ __decorate([ affectStrokeBoundsType("center") ], exports.Line.prototype, "strokeAlign", void 0);
8413
+ __decorate([ boundsType(0) ], exports.Line.prototype, "height", void 0);
8414
+ __decorate([ pathType() ], exports.Line.prototype, "points", void 0);
8415
+ __decorate([ pathType(0) ], exports.Line.prototype, "curve", void 0);
8416
+ __decorate([ pathType(false) ], exports.Line.prototype, "closed", void 0);
8417
+ exports.Line = __decorate([ registerUI() ], exports.Line);
8390
8418
  exports.Image = class Image extends exports.Rect {
8391
8419
  get __tag() {
8392
8420
  return "Image";
@@ -8519,10 +8547,6 @@ var LeaferUI = function(exports) {
8519
8547
  DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
8520
8548
  if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
8521
8549
  }
8522
- __onUpdateSize() {
8523
- if (this.__box) this.__box.__onUpdateSize();
8524
- super.__onUpdateSize();
8525
- }
8526
8550
  __updateRenderSpread() {
8527
8551
  let width = super.__updateRenderSpread();
8528
8552
  if (!width) width = this.isOverflow ? 1 : 0;
@@ -8533,6 +8557,11 @@ var LeaferUI = function(exports) {
8533
8557
  copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
8534
8558
  if (this.__box) this.__box.__layout.renderBounds = renderBounds;
8535
8559
  }
8560
+ __updateChange() {
8561
+ super.__updateChange();
8562
+ const box = this.__box;
8563
+ if (box) box.__onUpdateSize(), box.__updateChange();
8564
+ }
8536
8565
  __drawRenderPath(canvas) {
8537
8566
  canvas.font = this.__.__font;
8538
8567
  }
@@ -9511,11 +9540,16 @@ var LeaferUI = function(exports) {
9511
9540
  }
9512
9541
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
9513
9542
  }
9514
- LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9543
+ if (Effect.isTransformShadow(item)) Effect.renderTransformShadow(ui, current, other, copyBounds, item); else LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
9515
9544
  if (end && index < end) other.clearWorld(copyBounds);
9516
9545
  });
9517
9546
  other.recycle(copyBounds);
9518
9547
  }
9548
+ function getShadowSpread(_ui, shadow) {
9549
+ let width = 0;
9550
+ 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));
9551
+ return width;
9552
+ }
9519
9553
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
9520
9554
  const {bounds: bounds, shapeBounds: shapeBounds} = shape;
9521
9555
  if (Platform.fullImageShadow) {
@@ -9587,7 +9621,11 @@ var LeaferUI = function(exports) {
9587
9621
  shadow: shadow,
9588
9622
  innerShadow: innerShadow,
9589
9623
  blur: blur,
9590
- backgroundBlur: backgroundBlur
9624
+ backgroundBlur: backgroundBlur,
9625
+ getShadowSpread: getShadowSpread,
9626
+ isTransformShadow(_shadow) {
9627
+ return undefined;
9628
+ }
9591
9629
  };
9592
9630
  const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
9593
9631
  let usedGrayscaleAlpha;
@@ -10043,16 +10081,17 @@ var LeaferUI = function(exports) {
10043
10081
  row.data = null;
10044
10082
  }
10045
10083
  function decorationText(drawData, style) {
10046
- let type;
10084
+ let type, offset = 0;
10047
10085
  const {fontSize: fontSize, textDecoration: textDecoration} = style;
10048
10086
  drawData.decorationHeight = fontSize / 11;
10049
10087
  if (isObject(textDecoration)) {
10050
10088
  type = textDecoration.type;
10051
10089
  if (textDecoration.color) drawData.decorationColor = ColorConvert.string(textDecoration.color);
10090
+ if (textDecoration.offset) offset = Math.min(fontSize * .3, Math.max(textDecoration.offset, -fontSize * .15));
10052
10091
  } else type = textDecoration;
10053
10092
  switch (type) {
10054
10093
  case "under":
10055
- drawData.decorationY = [ fontSize * .15 ];
10094
+ drawData.decorationY = [ fontSize * .15 + offset ];
10056
10095
  break;
10057
10096
 
10058
10097
  case "delete":
@@ -10060,7 +10099,7 @@ var LeaferUI = function(exports) {
10060
10099
  break;
10061
10100
 
10062
10101
  case "under-delete":
10063
- drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
10102
+ drawData.decorationY = [ fontSize * .15 + offset, -fontSize * .35 ];
10064
10103
  }
10065
10104
  }
10066
10105
  const {top: top, right: right, bottom: bottom, left: left} = exports.Direction4;
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:a}=t.FileHelper;function i(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise((i,s)=>{t.convertToBlob({type:a(e),quality:n}).then(t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)}).catch(t=>{s(t)})}),canvasToBolb:(t,e,n)=>t.convertToBlob({type:a(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise(t=>t()),download(t,e){},loadImage:e=>new Promise((n,a)=>{let i=new XMLHttpRequest;i.open("GET",t.Platform.image.getRealURL(e),!0),i.responseType="blob",i.onload=()=>{createImageBitmap(i.response).then(t=>{n(t)}).catch(t=>{a(t)})},i.onerror=t=>a(t),i.send()})},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.isWorker=!0,t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:s}=navigator;s.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),s.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):s.indexOf("Mac")>-1?t.Platform.os="Mac":s.indexOf("Linux")>-1&&(t.Platform.os="Linux");class r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach(t=>{t.leafer&&e.add(t)}),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=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:o,updateBounds:l,updateChange:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper;class f{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,u)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,u),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:p,updateAllChange:g}=t.LeafHelper,_=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.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){_.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?_.warn("layouting"):this.times>3?_.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:a,__updatedList:i}=this,{BEFORE:s,LAYOUT:r,AFTER:u}=t.LayoutEvent,f=this.getBlocks(i);f.forEach(t=>t.setBefore()),a.emitEvent(new t.LayoutEvent(s,f,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach(t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(o(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))})}(i,this.__levelList),function(t){let e,n,a;t.sort(!0),t.levels.forEach(i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(n=e[t],n.isBranch&&n.__tempNumber){a=n.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||l(a[t])}l(n)}})}(this.__levelList),function(t){t.list.forEach(d)}(i),this.extraBlock&&f.push(this.extraBlock),f.forEach(t=>t.setAfter()),a.emitEvent(new t.LayoutEvent(r,f,this.times)),a.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:a,LAYOUT:i,AFTER:s}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(a,r,this.times)),m.fullLayout(n),r.forEach(t=>{t.setAfter()}),n.emitEvent(new t.LayoutEvent(i,r,this.times)),n.emitEvent(new t.LayoutEvent(s,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){p(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),g(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new f([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new f(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 y=t.Debug.get("Renderer");class w{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,a){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.target=e,this.canvas=n,a&&(this.config=t.DataHelper.default(a,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:n}=this;this.times=0,this.totalBounds=new t.Bounds,y.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.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 n=t.Run.start("PartRender"),{canvas:a}=this,i=e.getIntersect(a.bounds),s=new t.Bounds(i);a.save(),i.spread(w.clipSpread).ceil(),a.clearWorld(i),a.clipWorld(i),this.__render(i,s),a.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:a}=this,i=e.includes(this.target.__world),s=i?{includes:i}:{bounds:e,includes:i};this.needFill&&a.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(a,e),this.target.__render(a,s),this.renderBounds=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),a.updateRender(n)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now(),a=()=>{const e=1e3/(Date.now()-n),{maxFPS:i}=this.config;if(i&&e>i-.5)return t.Platform.requestRender(a);this.FPS=Math.min(120,Math.ceil(e)),this.requestTime=0,this.checkRender()};t.Platform.requestRender(a)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:a}=e.old;if(!new t.Bounds(0,0,n,a).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||y.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,n,a){this.target.emitEvent(new t.RenderEvent(e,this.times,n,a))}__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 v(t,e){const n=t.__,{rows:a,decorationY:i}=n.__textDrawData;let s;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=a.length;t<n;t++)s=a[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.fillText(t.char,t.x,s.y)});if(i){const{decorationColor:t,decorationHeight:s}=n.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>i.forEach(n=>e.fillRect(t.x,t.y+n,t.width,s)))}}function x(t,e){t.__.__font?v(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function b(t,e,n){switch(e.__.strokeAlign){case"center":E(t,1,e,n);break;case"inside":B(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?E(t,2,e,n):B(t,"outside",e,n)}}function E(e,n,a,i){const s=a.__;t.isObject(e)?R(e,n,!0,a,i):(i.setStroke(e,s.__strokeWidth*n,s),S(a,i))}function B(e,n,a,i){const s=i.getSameCanvas(!0,!0);s.font=a.__.__font,E(e,2,a,s),s.blendMode="outside"===n?"destination-out":"destination-in",v(a,s),s.blendMode="normal",t.LeafHelper.copyCanvasByWorld(a,i,s),s.recycle(a.__nowWorld)}function S(t,e){let n,a=t.__.__textDrawData;const{rows:i,decorationY:s}=a;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach(t=>{e.strokeText(t.char,t.x,n.y)});if(s){const{decorationHeight:t}=a;i.forEach(n=>s.forEach(a=>e.strokeRect(n.x,n.y+a,n.width,t)))}}function R(t,n,a,i,s){let r;const o=i.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*n,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!e.PaintImage.checkImage(i,s,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*n,o,t):s.setStroke(r.style,o.__strokeWidth*n,o)}else s.strokeStyle=r.style;r.blendMode?(s.saveBlendMode(r.blendMode),a?S(i,s):s.stroke(),s.restoreBlendMode()):a?S(i,s):s.stroke()}}function k(e,n,a){const i=n.__;if(i.__strokeWidth)if(i.__font)b(e,n,a);else switch(i.strokeAlign){case"center":L(e,1,n,a);break;case"inside":!function(t,e,n){n.save(),n.clipUI(e),L(t,2,e,n),n.restore()}(e,n,a);break;case"outside":!function(e,n,a){const i=n.__;if(i.__fillAfterStroke)L(e,2,n,a);else{const{renderBounds:s}=n.__layout,r=a.getSameCanvas(!0,!0);n.__drawRenderPath(r),L(e,2,n,r),r.clipUI(i),r.clearWorld(s),t.LeafHelper.copyCanvasByWorld(n,a,r),r.recycle(n.__nowWorld)}}(e,n,a)}}function L(n,a,i,s){const r=i.__;t.isObject(n)?R(n,a,!1,i,s):(s.setStroke(n,r.__strokeWidth*a,r),s.stroke()),r.__useArrow&&e.Paint.strokeArrow(n,i,s)}w.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new w(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,a)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:P,getOuterOf:C,getByMove:A,getIntersectData:O}=t.BoundsHelper;let T;const{stintSet:W}=t.DataHelper,{hasTransparent:M}=e.ColorConvert;function D(n,a,i){if(!t.isObject(a)||!1===a.visible||0===a.opacity)return;let s;const{boxBounds:r}=i.__layout;switch(a.type){case"image":s=e.PaintImage.image(i,n,a,r,!T||!T[a.url]);break;case"linear":s=e.PaintGradient.linearGradient(a,r);break;case"radial":s=e.PaintGradient.radialGradient(a,r);break;case"angular":s=e.PaintGradient.conicGradient(a,r);break;case"solid":const{type:o,color:l,opacity:d}=a;s={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(a.r)||(s={type:"solid",style:e.ColorConvert.string(a)})}if(s){if(t.isString(s.style)&&M(s.style)&&(s.isTransparent=!0),a.style){if(0===a.style.strokeWidth)return;s.strokeStyle=a.style}a.editing&&(s.editing=a.editing),a.blendMode&&(s.blendMode=a.blendMode)}return s}const I={compute:function(n,a){const i=a.__,s=[];let r,o,l,d=i.__input[n];t.isArray(d)||(d=[d]),T=e.PaintImage.recycleImage(n,i);for(let t,e=0,i=d.length;e<i;e++)(t=D(n,d[e],a))&&(s.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));i["_"+n]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(r=!0),o=!0),"fill"===n?(W(i,"__isAlphaPixelFill",r),W(i,"__isTransparentFill",o)):(W(i,"__isAlphaPixelStroke",r),W(i,"__isTransparentStroke",o),W(i,"__hasMultiStrokeStyle",l))},fill:function(t,e,n){n.fillStyle=t,x(e,n)},fills:function(t,n,a){let i;for(let s=0,r=t.length;s<r;s++){if(i=t[s],i.image){if(e.PaintImage.checkImage(n,a,i,!n.__.__font))continue;if(!i.style){!s&&i.image.isPlacehold&&n.drawImagePlaceholder(a,i.image);continue}}if(a.fillStyle=i.style,i.transform||i.scaleFixed){if(a.save(),i.transform&&a.transform(i.transform),i.scaleFixed){const{scaleX:t,scaleY:e}=n.getRenderScaleData(!0);(!0===i.scaleFixed||"zoom-in"===i.scaleFixed&&t>1&&e>1)&&a.scale(1/t,1/e)}i.blendMode&&(a.blendMode=i.blendMode),x(n,a),a.restore()}else i.blendMode?(a.saveBlendMode(i.blendMode),x(n,a),a.restoreBlendMode()):x(n,a)}},fillPathOrText:x,fillText:v,stroke:k,strokes:function(t,e,n){k(t,e,n)},strokeText:b,drawTextStroke:S,shape:function(e,n,a){const i=n.getSameCanvas(),s=e.__nowWorld,r=n.bounds;let o,l,d,c,h,{scaleX:u,scaleY:f}=e.getRenderScaleData(!0);if(r.includes(s))h=i,o=c=s;else{const{renderShapeSpread:i}=e.__layout;let p;if(t.Platform.fullImageShadow)p=s;else{const t=i?P(r,u===f?i*u:[i*f,i*u]):r;p=O(t,s)}d=r.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(h=n.getSameCanvas(),e.__renderShape(h,a),u*=g,f*=_),c=C(s,d),o=A(c,-d.e,-d.f);const m=a.matrix;m?(l=new t.Matrix(d),l.multiply(m),g*=m.scaleX,_*=m.scaleY):l=d,l.withScale(g,_),a=Object.assign(Object.assign({},a),{matrix:l})}return e.__renderShape(i,a),{canvas:i,matrix:l,fitMatrix:d,bounds:o,worldCanvas:h,shapeBounds:c,scaleX:u,scaleY:f}}};let H={},F=t.getMatrixData();const{get:j,rotateOfOuter:G,translate:z,scaleOfOuter:U,multiplyParent:Y,scale:q,rotate:N,skew:X}=t.MatrixHelper;function V(t,e,n,a,i,s,r){const o=j();z(o,e.x+n,e.y+a),q(o,i,s),r&&G(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Q(t,e,n,a,i,s,r,o,l){const d=j();K(d,e,n,a,i,s,r,o),l&&(F.a=e.width/l.width,F.d=e.height/l.height,Y(d,F)),t.transform=d}function Z(t,e,n,a,i,s,r,o,l,d,c,h){const u=j();if(h)K(u,e,i,s,r,o,l,d);else{if(l)if("center"===c)G(u,{x:n/2,y:a/2},l);else switch(N(u,l),l){case 90:z(u,a,0);break;case 180:z(u,n,a);break;case 270:z(u,0,n)}H.x=e.x+i,H.y=e.y+s,z(u,H.x,H.y),r&&U(u,H,r,o)}t.transform=u}function K(t,e,n,a,i,s,r,o){r&&N(t,r),o&&X(t,o.x,o.y),i&&q(t,i,s),z(t,e.x+n,e.y+a)}const{get:$,translate:J}=t.MatrixHelper,tt=new t.Bounds,et={},nt={};function at(t,e,n,a){const{changeful:i,sync:s,scaleFixed:r}=n;i&&(t.changeful=i),s&&(t.sync=s),r&&(t.scaleFixed=r),t.data=it(n,a,e)}function it(e,n,a){e.padding&&(n=tt.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:i,height:s}=a;const{opacity:r,mode:o,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,y=n.width===i&&n.height===s,w={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(nt,0,0,v?s:i,v?i:s),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,a,et),x=et.scaleX,b=et.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(nt,x,b,!0),l&&t.AlignHelper.toPoint(l,nt,n,nt,!0,!0))):y&&!u||(x=b=t.BoundsHelper.getFitScale(n,nt,"fit"!==o),t.BoundsHelper.put(n,a,l,x,!1,nt),t.BoundsHelper.scale(nt,x,b,!0)),d&&t.PointHelper.move(nt,d),o){case"stretch":y||(i=n.width,s=n.height);break;case"normal":case"clip":(nt.x||nt.y||x||p||u||f)&&Q(w,n,nt.x,nt.y,x,b,u,f,e.clipSize);break;case"repeat":(!y||x||u||f)&&Z(w,n,i,s,nt.x,nt.y,x,b,u,f,l,e.freeTransform),g||(w.repeat="repeat");const a=t.isObject(g);(_||a)&&(w.gap=function(e,n,a,i,s){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:st(r,a,s.width,n&&n.x),y:st(o,i,s.height,n&&n.y)}}(_,a&&g,nt.width,nt.height,n));break;default:x&&V(w,n,nt.x,nt.y,x,b,u)}return w.transform||(n.x||n.y)&&(w.transform=$(),J(w.transform,n.x,n.y)),x&&"stretch"!==o&&(w.scaleX=x,w.scaleY=b),w.width=i,w.height=s,r&&(w.opacity=r),m&&(w.filters=m),g&&(w.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w}function st(e,n,a,i){const s=t.isString(e)||i?(i?a-i*n:a%n)/((i||Math.floor(a/n))-1):e;return"auto"===e&&s<0?0:s}let rt,ot=new t.Bounds;const{isSame:lt}=t.BoundsHelper;function dt(t,e,n,a,i,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=a.width/e.pixelRatio,e.__naturalHeight=a.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||at(i,a,n,s),!0}function ct(e,n){ft(e,t.ImageEvent.LOAD,n)}function ht(e,n){ft(e,t.ImageEvent.LOADED,n)}function ut(e,n,a){n.error=a,e.forceUpdate("surface"),ft(e,t.ImageEvent.ERROR,n)}function ft(e,n,a){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,a))}function pt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:gt,scale:_t,copy:mt}=t.MatrixHelper,{floor:yt,ceil:wt,max:vt,abs:xt}=Math;function bt(e,n,a){let{scaleX:i,scaleY:s}=e.getRenderScaleData(!0,n.scaleFixed);const r=i+"-"+s+"-"+a;if(n.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=n;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;i*=a,s*=a,f&&(f=xt(f),p=xt(p),c=gt(),mt(c,g),_t(c,1/f,1/p),i*=f,s*=p),h*=i,u*=s;const y=h*u;if(!_&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/wt(t))}else{const t=o.width*o.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(i/=d,s/=d,h/=d,u/=d),f&&(i/=f,s/=p);const v=m&&m.x*i,x=m&&m.y*s;if(g||1!==i||1!==s){const t=h+(v||0),e=u+(x||0);i/=t/vt(yt(t),1),s/=e/vt(yt(e),1),c||(c=gt(),g&&mt(c,g)),_t(c,1/i,1/s)}const b=o.getCanvas(h,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),E=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",c,n);return n.style=E,n.patternId=r,!0}}function Et(t,e,n,a){return new(n||(n=Promise))(function(i,s){function r(t){try{l(a.next(t))}catch(t){s(t)}}function o(t){try{l(a.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,o)}l((a=a.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Bt={image:function(e,n,a,i,s){let r,o;const l=t.ImageManager.get(a);return rt&&a===rt.paint&&lt(i,rt.boxBounds)?r=rt.leafPaint:(r={type:a.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),rt=l.use>1?{leafPaint:r,paint:a,boxBounds:ot.set(i)}:null),(s||l.loading)&&(o={image:l,attrName:n,attrValue:a}),l.ready?(dt(e,n,a,l,r,i),s&&(ct(e,o),ht(e,o))):l.error?s&&ut(e,o,l.error):(s&&(pt(e,!0),ct(e,o)),r.loadId=l.load(()=>{pt(e,!1),e.destroyed||(dt(e,n,a,l,r,i)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ht(e,o)),r.loadId=void 0},t=>{pt(e,!1),ut(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(n,a,i,s){const{scaleX:r,scaleY:o}=n.getRenderScaleData(!0,i.scaleFixed),{pixelRatio:l}=a,{data:d}=i;if(!d||i.patternId===r+"-"+o+"-"+l&&!e.Export.running)return!1;if(s)if(d.repeat)s=!1;else if(!(i.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=r*l,n*=o*l,d.scaleX&&(e*=d.scaleX,n*=d.scaleY),s=e*n>t.Platform.image.maxCacheSize}return s?(n.__.__isFastShadow&&(a.fillStyle=i.style||"#000",a.fill()),function(t,e,n,a){e.save(),e.clipUI(t),n.blendMode&&(e.blendMode=n.blendMode);a.opacity&&(e.opacity*=a.opacity);a.transform&&e.transform(a.transform);e.drawImage(n.image.getFull(a.filters),0,0,a.width,a.height),e.restore()}(n,a,i,d),!0):(!i.style||i.sync||e.Export.running?bt(n,i,l):i.patternTask||(i.patternTask=t.ImageManager.patternTasker.add(()=>Et(this,void 0,void 0,function*(){i.patternTask=null,a.bounds.hit(n.__nowWorld)&&bt(n,i,l),n.forceUpdate("surface")}),300)),!1)},createPattern:bt,recycleImage:function(e,n){const a=n["_"+e];if(t.isArray(a)){let i,s,r,o,l;for(let d=0,c=a.length;d<c;d++)i=a[d],s=i.image,l=s&&s.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],t.isArray(o)||(o=[o])),s.unload(a[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:at,getPatternData:it,fillOrFitMode:V,clipMode:Q,repeatMode:Z},{toPoint:St}=t.AroundHelper,{hasTransparent:Rt}=e.ColorConvert,kt={},Lt={};function Pt(n,a,i,s){if(i){let r,o,l,d;for(let n=0,c=i.length;n<c;n++)r=i[n],t.isString(r)?(l=n/(c-1),o=e.ColorConvert.string(r,s)):(l=r.offset,o=e.ColorConvert.string(r.color,s)),a.addColorStop(l,o),!d&&Rt(o)&&(d=!0);d&&(n.isTransparent=!0)}}const{getAngle:Ct,getDistance:At}=t.PointHelper,{get:Ot,rotateOfOuter:Tt,scaleOfOuter:Wt}=t.MatrixHelper,{toPoint:Mt}=t.AroundHelper,Dt={},It={};function Ht(t,e,n,a,i){let s;const{width:r,height:o}=t;if(r!==o||a){const t=Ct(e,n);s=Ot(),i?(Wt(s,e,r/o*(a||1),1),Tt(s,e,t+90)):(Wt(s,e,1,r/o*(a||1)),Tt(s,e,t))}return s}const{getDistance:Ft}=t.PointHelper,{toPoint:jt}=t.AroundHelper,Gt={},zt={};const Ut={linearGradient:function(e,n){let{from:a,to:i,type:s,opacity:r}=e;St(a||"top",n,kt),St(i||"bottom",n,Lt);const o=t.Platform.canvas.createLinearGradient(kt.x,kt.y,Lt.x,Lt.y),l={type:s,style:o};return Pt(l,o,e.stops,r),l},radialGradient:function(e,n){let{from:a,to:i,type:s,opacity:r,stretch:o}=e;Mt(a||"center",n,Dt),Mt(i||"bottom",n,It);const l=t.Platform.canvas.createRadialGradient(Dt.x,Dt.y,0,Dt.x,Dt.y,At(Dt,It)),d={type:s,style:l};Pt(d,l,e.stops,r);const c=Ht(n,Dt,It,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:a,to:i,type:s,opacity:r,stretch:o}=e;jt(a||"center",n,Gt),jt(i||"bottom",n,zt);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,Ft(Gt,zt)),d={type:s,style:l};Pt(d,l,e.stops,r);const c=Ht(n,Gt,zt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ht},{copy:Yt,toOffsetOutBounds:qt}=t.BoundsHelper,Nt={},Xt={};function Vt(e,n,a,i){const{bounds:s,shapeBounds:r}=i;if(t.Platform.fullImageShadow){if(Yt(Nt,e.bounds),Nt.x+=n.x-r.x,Nt.y+=n.y-r.y,a){const{fitMatrix:t}=i;Nt.x-=(s.x+(t?t.e:0)+s.width/2)*(a-1),Nt.y-=(s.y+(t?t.f:0)+s.height/2)*(a-1),Nt.width*=a,Nt.height*=a}e.copyWorld(i.canvas,e.bounds,Nt)}else a&&(Yt(Nt,n),Nt.x-=n.width/2*(a-1),Nt.y-=n.height/2*(a-1),Nt.width*=a,Nt.height*=a),e.copyWorld(i.canvas,r,a?Nt:n)}const{toOffsetOutBounds:Qt}=t.BoundsHelper,Zt={};const Kt={shadow:function(n,a,i){let s,r;const{__nowWorld:o,__layout:l}=n,{shadow:d}=n.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=i,g=a.getSameCanvas(),_=d.length-1;qt(h,Xt),d.forEach((d,m)=>{let y=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.setWorldShadow(Xt.offsetX+d.x*f*y,Xt.offsetY+d.y*p*y,d.blur*f*y,e.ColorConvert.string(d.color)),r=d.spread?1+2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*y:0,Vt(g,Xt,r,i),s=h,d.box&&(g.restore(),g.save(),c&&(g.copyWorld(g,h,o,"copy"),s=o),c?g.copyWorld(c,o,o,"destination-out"):g.copyWorld(i.canvas,u,h,"destination-out")),t.LeafHelper.copyCanvasByWorld(n,a,g,s,d.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(n,a,i){let s,r;const{__nowWorld:o,__layout:l}=n,{innerShadow:d}=n.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=i,g=a.getSameCanvas(),_=d.length-1;Qt(h,Zt),d.forEach((d,m)=>{let y=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(Zt.offsetX+d.x*f*y,Zt.offsetY+d.y*p*y,d.blur*f*y),r=d.spread?1-2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*y:0,Vt(g,Zt,r,i),g.restore(),c?(g.copyWorld(g,h,o,"copy"),g.copyWorld(c,o,o,"source-out"),s=o):(g.copyWorld(i.canvas,u,h,"source-out"),s=h),g.fillWorld(s,e.ColorConvert.string(d.color),"source-in"),t.LeafHelper.copyCanvasByWorld(n,a,g,s,d.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,n){const{blur:a}=t.__;n.setWorldBlur(a*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){}},{excludeRenderBounds:$t}=t.LeafBoundsHelper;let Jt;function te(t,e,n,a,i,s,r,o){switch(e){case"grayscale":Jt||(Jt=!0,i.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,n,a,i,s){const r=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(a,r),s&&a.recycle(r);ne(t,e,n,1,i,s)}(t,n,a,i,r,o);break;case"opacity-path":ne(t,n,a,s,r,o);break;case"path":o&&n.restore()}}function ee(t){return t.getSameCanvas(!1,!0)}function ne(t,e,n,a,i,s){const r=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(n,r,void 0,i),s?n.recycle(r):n.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let n,a,i,s,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(n=l[d],o=n.__.mask,o){r&&(te(this,r,t,i,a,s,void 0,!0),a=i=null),s=n.__.opacity,Jt=!1,"path"===o||"clipping-path"===o?(s<1?(r="opacity-path",i||(i=ee(t))):(r="path",t.save()),n.__clip(i||t,e)):(r="grayscale"===o?"grayscale":"alpha",a||(a=ee(t)),i||(i=ee(t)),n.__render(a,e)),"clipping"!==o&&"clipping-path"!==o||$t(n,e)||n.__render(t,e);continue}const c=1===s&&n.__.__blendMode;c&&te(this,r,t,i,a,s,void 0,!1),$t(n,e)||n.__render(i||t,e),c&&te(this,r,t,i,a,s,c,!1)}te(this,r,t,i,a,s,void 0,!0)};const ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ie=ae+"_#~&*+\\=|≮≯≈≠=…",se=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 re(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const oe=re("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),le=re("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),de=re(ae),ce=re(ie),he=re("- —/~|┆·");var ue;!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"}(ue||(ue={}));const{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:me,Break:ye}=ue;function we(t){return oe[t]?fe:he[t]?ye:le[t]?ge:de[t]?_e:ce[t]?me:se.test(t)?pe:fe}const ve={trimRight(t){const{words:e}=t;let n,a=0,i=e.length;for(let s=i-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)a++,t.width-=n.width;a&&e.splice(i-a,a)}};function xe(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:be}=ve,{Letter:Ee,Single:Be,Before:Se,After:Re,Symbol:ke,Break:Le}=ue;let Pe,Ce,Ae,Oe,Te,We,Me,De,Ie,He,Fe,je,Ge,ze,Ue,Ye,qe,Ne=[];function Xe(t,e){Ie&&!De&&(De=Ie),Pe.data.push({char:t,width:e}),Ae+=e}function Ve(){Oe+=Ae,Pe.width=Ae,Ce.words.push(Pe),Pe={data:[]},Ae=0}function Qe(){ze&&(Ue.paraNumber++,Ce.paraStart=!0,ze=!1),Ie&&(Ce.startCharSize=De,Ce.endCharSize=Ie,De=0),Ce.width=Oe,Ye.width?be(Ce):qe&&Ze(),Ne.push(Ce),Ce={words:[]},Oe=0}function Ze(){Oe>(Ue.maxWidth||0)&&(Ue.maxWidth=Oe)}const{top:Ke,right:$e,bottom:Je,left:tn}=t.Direction4;function en(t,e,n){const{bounds:a,rows:i}=t;a[e]+=n;for(let t=0;t<i.length;t++)i[t][e]+=n}const nn={getDrawData:function(n,a){t.isString(n)||(n=String(n));let i=0,s=0,r=a.__getInput("width")||0,o=a.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=a;c&&(r?(i=c[tn],r-=c[$e]+c[tn]):a.autoSizeAlign||(i=c[tn]),o?(s=c[Ke],o-=c[Ke]+c[Je]):a.autoSizeAlign||(s=c[Ke]));const h={bounds:{x:i,y:s,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,a){Ue=e,Ne=e.rows,Ye=e.bounds,qe=!Ye.width&&!a.autoSizeAlign;const{__letterSpacing:i,paraIndent:s,textCase:r}=a,{canvas:o}=t.Platform,{width:l,height:d}=Ye;if(l||d||i||"none"!==r){const t="none"!==a.textWrap,e="break"===a.textWrap;ze=!0,Fe=null,De=Me=Ie=Ae=Oe=0,Pe={data:[]},Ce={words:[]},i&&(n=[...n]);for(let a=0,d=n.length;a<d;a++)We=n[a],"\n"===We?(Ae&&Ve(),Ce.paraEnd=!0,Qe(),ze=!0):(He=we(We),He===Ee&&"none"!==r&&(We=xe(We,r,!Ae)),Me=o.measureText(We).width,i&&(i<0&&(Ie=Me),Me+=i),je=He===Be&&(Fe===Be||Fe===Ee)||Fe===Be&&He!==Re,Ge=!(He!==Se&&He!==Be||Fe!==ke&&Fe!==Re),Te=ze&&s?l-s:l,t&&l&&Oe+Ae+Me>Te&&(e?(Ae&&Ve(),Oe&&Qe()):(Ge||(Ge=He===Ee&&Fe==Re),je||Ge||He===Le||He===Se||He===Be||Ae+Me>Te?(Ae&&Ve(),Oe&&Qe()):Oe&&Qe()))," "===We&&!0!==ze&&Oe+Ae===0||(He===Le?(" "===We&&Ae&&Ve(),Xe(We,Me),Ve()):je||Ge?(Ae&&Ve(),Xe(We,Me)):Xe(We,Me)),Fe=He);Ae&&Ve(),Oe&&Qe(),Ne.length>0&&(Ne[Ne.length-1].paraEnd=!0)}else n.split("\n").forEach(t=>{Ue.paraNumber++,Oe=o.measureText(t).width,Ne.push({x:s||0,text:t,width:Oe,paraStart:!0}),qe&&Ze()})}(h,n,a),c&&function(t,e,n,a,i){if(!a&&n.autoSizeAlign)switch(n.textAlign){case"left":en(e,"x",t[tn]);break;case"right":en(e,"x",-t[$e])}if(!i&&n.autoSizeAlign)switch(n.verticalAlign){case"top":en(e,"y",t[Ke]);break;case"bottom":en(e,"y",-t[Je])}}(c,h,a,r,o),function(t,e){const{rows:n,bounds:a}=t,i=n.length,{__lineHeight:s,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=a,m=s*i+(h?h*(t.paraNumber-1):0),y=r;if(l&&m>_)m=Math.max(_,s),i>1&&(t.overflow=i);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}y+=p;let w,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=i;r<c;r++){if(w=n[r],w.x=f,w.width<g||w.width>g&&!l)switch(d){case"center":w.x+=(b-w.width)/2;break;case"right":w.x+=b-w.width}w.paraStart&&h&&r>0&&(y+=h),w.y=y,y+=s,t.overflow>r&&y>m&&(w.isOverflow=!0,t.overflow=r+1),v=w.x,x=w.width,o<0&&(w.width<0?(x=-w.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<a.x&&(a.x=v),x>a.width&&(a.width=x),l&&g&&g<x&&(w.isOverflow=!0,t.overflow||(t.overflow=n.length))}a.y=p,a.height=m}(h,a),function(t,e,n){const{rows:a}=t,{textAlign:i,paraIndent:s,letterSpacing:r}=e;let o,l,d,c,h,u;a.forEach(t=>{t.words&&(d=s&&t.paraStart?s:0,u=t.words.length,l=n&&("justify"===i||"both"===i)&&u>1?(n-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(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,n)=>{1===c?(h={char:"",x:o},o=function(t,e,n){return t.forEach(t=>{n.char+=t.char,e+=t.width}),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,n,a){return t.forEach(t=>{(a||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==i||n===u-1||(o+=l,t.width+=l)})),t.words=null)})}(h,a,r),h.overflow&&function(e,n,a,i){if(!i)return;const{rows:s,overflow:r}=e;let{textOverflow:o}=n;if(s.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=a+i-d;("none"===n.textWrap?s:[s[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let a=n;a>-1&&(e=t.data[a],l=e.x+e.width,!(a===n&&l<c));a--){if(l<c&&" "!==e.char||!a){t.data.splice(a+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)}})}}(h,a,i,r),"none"!==l&&function(n,a){let i;const{fontSize:s,textDecoration:r}=a;switch(n.decorationHeight=s/11,t.isObject(r)?(i=r.type,r.color&&(n.decorationColor=e.ColorConvert.string(r.color))):i=r,i){case"under":n.decorationY=[.15*s];break;case"delete":n.decorationY=[.35*-s];break;case"under-delete":n.decorationY=[.15*s,.35*-s]}}(h,a),h}};const an={string:function(n,a){const i=t.isNumber(a)&&a<1;if(t.isString(n)){if(!i||!e.ColorConvert.object)return n;n=e.ColorConvert.object(n)}let s=t.isUndefined(n.a)?1:n.a;i&&(s*=a);const r=n.r+","+n.g+","+n.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}};Object.assign(e.TextConvert,nn),Object.assign(e.ColorConvert,an),Object.assign(e.Paint,I),Object.assign(e.PaintImage,Bt),Object.assign(e.PaintGradient,Ut),Object.assign(e.Effect,Kt),i(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=w,exports.Watcher=r,exports.useCanvas=i,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");class n extends t.LeaferCanvasBase{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=t.Platform.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:n}=this;this.view.width=Math.ceil(t*n),this.view.height=Math.ceil(e*n),this.clientBounds=this.bounds}}t.canvasPatch(OffscreenCanvasRenderingContext2D.prototype),t.canvasPatch(Path2D.prototype);const{mineType:a}=t.FileHelper;function i(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise((i,s)=>{t.convertToBlob({type:a(e),quality:n}).then(t=>{var e=new FileReader;e.onload=t=>i(t.target.result),e.onerror=t=>s(t),e.readAsDataURL(t)}).catch(t=>{s(t)})}),canvasToBolb:(t,e,n)=>t.convertToBlob({type:a(e),quality:n}),canvasSaveAs:(t,e,n)=>new Promise(t=>t()),download(t,e){},loadImage:e=>new Promise((n,a)=>{let i=new XMLHttpRequest;i.open("GET",t.Platform.image.getRealURL(e),!0),i.responseType="blob",i.onload=()=>{createImageBitmap(i.response).then(t=>{n(t)}).catch(t=>{a(t)})},i.onerror=t=>a(t),i.send()})},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.isWorker=!0,t.Platform.backgrounder=!0,t.Platform.requestRender=function(t){requestAnimationFrame(t)},t.defineKey(t.Platform,"devicePixelRatio",{get:()=>1});const{userAgent:s}=navigator;s.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):(/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent))&&(t.Platform.fullImageShadow=!0),s.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):s.indexOf("Mac")>-1?t.Platform.os="Mac":s.indexOf("Linux")>-1&&(t.Platform.os="Linux");class r{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t.LeafList;return this.__updatedList.list.forEach(t=>{t.leafer&&e.add(t)}),e}return this.__updatedList}constructor(e,n){this.totalTimes=0,this.config={},this.__updatedList=new t.LeafList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(t.RenderEvent.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(e){e.type===t.ChildEvent.ADD?(this.hasAdd=!0,this.__pushChild(e.child)):(this.hasRemove=!0,this.__updatedList.add(e.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,n=e.length;t<n;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new t.WatchEvent(t.WatchEvent.DATA,{updatedList:this.updatedList})),this.__updatedList=new t.LeafList,this.totalTimes++,this.changed=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:o,updateBounds:l,updateChange:d}=t.LeafHelper,{pushAllChildBranch:c,pushAllParent:h}=t.BranchHelper;const{worldBounds:u}=t.LeafBoundsHelper;class f{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,u)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,u),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:p,updateAllChange:g}=t.LeafHelper,_=t.Debug.get("Layouter");class m{constructor(e,n){this.totalTimes=0,this.config={},this.__levelList=new t.LeafLevelList,this.target=e,n&&(this.config=t.DataHelper.default(n,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.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){_.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?_.warn("layouting"):this.times>3?_.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(t.WatchEvent.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var e;if(!(null===(e=this.__updatedList)||void 0===e?void 0:e.length))return;const n=t.Run.start("PartLayout"),{target:a,__updatedList:i}=this,{BEFORE:s,LAYOUT:r,AFTER:u}=t.LayoutEvent,f=this.getBlocks(i);f.forEach(t=>t.setBefore()),a.emitEvent(new t.LayoutEvent(s,f,this.times)),this.extraBlock=null,i.sort(),function(t,e){let n;t.list.forEach(t=>{n=t.__layout,e.without(t)&&!n.proxyZoom&&(n.matrixChanged?(o(t,!0),e.add(t),t.isBranch&&c(t,e),h(t,e)):n.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),h(t,e)))})}(i,this.__levelList),function(t){let e,n,a;t.sort(!0),t.levels.forEach(i=>{e=t.levelMap[i];for(let t=0,i=e.length;t<i;t++){if(n=e[t],n.isBranch&&n.__tempNumber){a=n.children;for(let t=0,e=a.length;t<e;t++)a[t].isBranch||l(a[t])}l(n)}})}(this.__levelList),function(t){t.list.forEach(d)}(i),this.extraBlock&&f.push(this.extraBlock),f.forEach(t=>t.setAfter()),a.emitEvent(new t.LayoutEvent(r,f,this.times)),a.emitEvent(new t.LayoutEvent(u,f,this.times)),this.addBlocks(f),this.__levelList.reset(),this.__updatedList=null,t.Run.end(n)}fullLayout(){const e=t.Run.start("FullLayout"),{target:n}=this,{BEFORE:a,LAYOUT:i,AFTER:s}=t.LayoutEvent,r=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(a,r,this.times)),m.fullLayout(n),r.forEach(t=>{t.setAfter()}),n.emitEvent(new t.LayoutEvent(i,r,this.times)),n.emitEvent(new t.LayoutEvent(s,r,this.times)),this.addBlocks(r),t.Run.end(e)}static fullLayout(e){p(e,!0),e.isBranch?t.BranchHelper.updateBounds(e):t.LeafHelper.updateBounds(e),g(e)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:n}=this.extraBlock||(this.extraBlock=new f([]));e.length?n.add(t.__world):n.set(t.__world),e.add(t)}}createBlock(t){return new f(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 y=t.Debug.get("Renderer");class w{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(e,n,a){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.target=e,this.canvas=n,a&&(this.config=t.DataHelper.default(a,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:n}=this;this.times=0,this.totalBounds=new t.Bounds,y.log(n.innerName,"---\x3e");try{this.emitRender(t.RenderEvent.START),this.renderOnce(e),this.emitRender(t.RenderEvent.END,this.totalBounds),t.ImageManager.clearRecycled()}catch(t){this.rendering=!1,y.error(t)}y.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(e){if(this.rendering)return y.warn("rendering");if(this.times>3)return y.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 n=t.Run.start("PartRender"),{canvas:a}=this,i=e.getIntersect(a.bounds),s=new t.Bounds(i);a.save(),i.spread(w.clipSpread).ceil(),a.clearWorld(i),a.clipWorld(i),this.__render(i,s),a.restore(),t.Run.end(n)}fullRender(){const e=t.Run.start("FullRender"),{canvas:n}=this;n.save(),n.clear(),this.__render(n.bounds),n.restore(),t.Run.end(e)}__render(e,n){const{canvas:a}=this,i=e.includes(this.target.__world),s=i?{includes:i}:{bounds:e,includes:i};this.needFill&&a.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(a,e),this.target.__render(a,s),this.renderBounds=n=n||e,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=n:this.totalBounds.add(n),a.updateRender(n)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:e}=this;if(e){const n=new t.Bounds;n.setList(e),e.length=0,e.push(n)}}__requestRender(){const e=this.target;if(this.requestTime||!e)return;if(e.parentApp)return e.parentApp.requestRender(!1);const n=this.requestTime=Date.now(),a=()=>{const e=1e3/(Date.now()-n),{maxFPS:i}=this.config;if(i&&e>i-.5)return t.Platform.requestRender(a);this.FPS=Math.min(120,Math.ceil(e)),this.requestTime=0,this.checkRender()};t.Platform.requestRender(a)}__onResize(e){if(!this.canvas.unreal){if(e.bigger||!e.samePixelRatio){const{width:n,height:a}=e.old;if(!new t.Bounds(0,0,n,a).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||y.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(e,n,a){this.target.emitEvent(new t.RenderEvent(e,this.times,n,a))}__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 v(t,e){const n=t.__,{rows:a,decorationY:i}=n.__textDrawData;let s;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=a.length;t<n;t++)s=a[t],s.text?e.fillText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.fillText(t.char,t.x,s.y)});if(i){const{decorationColor:t,decorationHeight:s}=n.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>i.forEach(n=>e.fillRect(t.x,t.y+n,t.width,s)))}}function x(t,e){t.__.__font?v(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function b(t,e,n){switch(e.__.strokeAlign){case"center":E(t,1,e,n);break;case"inside":B(t,"inside",e,n);break;case"outside":e.__.__fillAfterStroke?E(t,2,e,n):B(t,"outside",e,n)}}function E(e,n,a,i){const s=a.__;t.isObject(e)?R(e,n,!0,a,i):(i.setStroke(e,s.__strokeWidth*n,s),S(a,i))}function B(e,n,a,i){const s=i.getSameCanvas(!0,!0);s.font=a.__.__font,E(e,2,a,s),s.blendMode="outside"===n?"destination-out":"destination-in",v(a,s),s.blendMode="normal",t.LeafHelper.copyCanvasByWorld(a,i,s),s.recycle(a.__nowWorld)}function S(t,e){let n,a=t.__.__textDrawData;const{rows:i,decorationY:s}=a;for(let t=0,a=i.length;t<a;t++)n=i[t],n.text?e.strokeText(n.text,n.x,n.y):n.data&&n.data.forEach(t=>{e.strokeText(t.char,t.x,n.y)});if(s){const{decorationHeight:t}=a;i.forEach(n=>s.forEach(a=>e.strokeRect(n.x,n.y+a,n.width,t)))}}function R(t,n,a,i,s){let r;const o=i.__,{__hasMultiStrokeStyle:l}=o;l||s.setStroke(void 0,o.__strokeWidth*n,o);for(let d=0,c=t.length;d<c;d++)if(r=t[d],(!r.image||!e.PaintImage.checkImage(i,s,r,!1))&&r.style){if(l){const{strokeStyle:t}=r;t?s.setStroke(r.style,o.__getRealStrokeWidth(t)*n,o,t):s.setStroke(r.style,o.__strokeWidth*n,o)}else s.strokeStyle=r.style;r.blendMode?(s.saveBlendMode(r.blendMode),a?S(i,s):s.stroke(),s.restoreBlendMode()):a?S(i,s):s.stroke()}}function k(e,n,a){const i=n.__;if(i.__strokeWidth)if(i.__font)b(e,n,a);else switch(i.strokeAlign){case"center":L(e,1,n,a);break;case"inside":!function(t,e,n){n.save(),n.clipUI(e),L(t,2,e,n),n.restore()}(e,n,a);break;case"outside":!function(e,n,a){const i=n.__;if(i.__fillAfterStroke)L(e,2,n,a);else{const{renderBounds:s}=n.__layout,r=a.getSameCanvas(!0,!0);n.__drawRenderPath(r),L(e,2,n,r),r.clipUI(i),r.clearWorld(s),t.LeafHelper.copyCanvasByWorld(n,a,r),r.recycle(n.__nowWorld)}}(e,n,a)}}function L(n,a,i,s){const r=i.__;t.isObject(n)?R(n,a,!1,i,s):(s.setStroke(n,r.__strokeWidth*a,r),s.stroke()),r.__useArrow&&e.Paint.strokeArrow(n,i,s)}w.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new r(t,e),layouter:(t,e)=>new m(t,e),renderer:(t,e,n)=>new w(t,e,n),selector:(t,e)=>{},interaction:(t,e,n,a)=>{}}),t.Platform.layout=m.fullLayout;const{getSpread:P,getOuterOf:C,getByMove:A,getIntersectData:O}=t.BoundsHelper;let T;const{stintSet:M}=t.DataHelper,{hasTransparent:W}=e.ColorConvert;function D(n,a,i){if(!t.isObject(a)||!1===a.visible||0===a.opacity)return;let s;const{boxBounds:r}=i.__layout;switch(a.type){case"image":s=e.PaintImage.image(i,n,a,r,!T||!T[a.url]);break;case"linear":s=e.PaintGradient.linearGradient(a,r);break;case"radial":s=e.PaintGradient.radialGradient(a,r);break;case"angular":s=e.PaintGradient.conicGradient(a,r);break;case"solid":const{type:o,color:l,opacity:d}=a;s={type:o,style:e.ColorConvert.string(l,d)};break;default:t.isUndefined(a.r)||(s={type:"solid",style:e.ColorConvert.string(a)})}if(s){if(t.isString(s.style)&&W(s.style)&&(s.isTransparent=!0),a.style){if(0===a.style.strokeWidth)return;s.strokeStyle=a.style}a.editing&&(s.editing=a.editing),a.blendMode&&(s.blendMode=a.blendMode)}return s}const I={compute:function(n,a){const i=a.__,s=[];let r,o,l,d=i.__input[n];t.isArray(d)||(d=[d]),T=e.PaintImage.recycleImage(n,i);for(let t,e=0,i=d.length;e<i;e++)(t=D(n,d[e],a))&&(s.push(t),t.strokeStyle&&(l||(l=1),t.strokeStyle.strokeWidth&&(l=Math.max(l,t.strokeStyle.strokeWidth))));i["_"+n]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(r=!0),o=!0),"fill"===n?(M(i,"__isAlphaPixelFill",r),M(i,"__isTransparentFill",o)):(M(i,"__isAlphaPixelStroke",r),M(i,"__isTransparentStroke",o),M(i,"__hasMultiStrokeStyle",l))},fill:function(t,e,n){n.fillStyle=t,x(e,n)},fills:function(t,n,a){let i;for(let s=0,r=t.length;s<r;s++){if(i=t[s],i.image){if(e.PaintImage.checkImage(n,a,i,!n.__.__font))continue;if(!i.style){!s&&i.image.isPlacehold&&n.drawImagePlaceholder(a,i.image);continue}}if(a.fillStyle=i.style,i.transform||i.scaleFixed){if(a.save(),i.transform&&a.transform(i.transform),i.scaleFixed){const{scaleX:t,scaleY:e}=n.getRenderScaleData(!0);(!0===i.scaleFixed||"zoom-in"===i.scaleFixed&&t>1&&e>1)&&a.scale(1/t,1/e)}i.blendMode&&(a.blendMode=i.blendMode),x(n,a),a.restore()}else i.blendMode?(a.saveBlendMode(i.blendMode),x(n,a),a.restoreBlendMode()):x(n,a)}},fillPathOrText:x,fillText:v,stroke:k,strokes:function(t,e,n){k(t,e,n)},strokeText:b,drawTextStroke:S,shape:function(e,n,a){const i=n.getSameCanvas(),s=e.__nowWorld,r=n.bounds;let o,l,d,c,h,{scaleX:u,scaleY:f}=e.getRenderScaleData(!0);if(r.includes(s))h=i,o=c=s;else{const{renderShapeSpread:i}=e.__layout;let p;if(t.Platform.fullImageShadow)p=s;else{const t=i?P(r,u===f?i*u:[i*f,i*u]):r;p=O(t,s)}d=r.getFitMatrix(p);let{a:g,d:_}=d;d.a<1&&(h=n.getSameCanvas(),e.__renderShape(h,a),u*=g,f*=_),c=C(s,d),o=A(c,-d.e,-d.f);const m=a.matrix;m?(l=new t.Matrix(d),l.multiply(m),g*=m.scaleX,_*=m.scaleY):l=d,l.withScale(g,_),a=Object.assign(Object.assign({},a),{matrix:l})}return e.__renderShape(i,a),{canvas:i,matrix:l,fitMatrix:d,bounds:o,worldCanvas:h,shapeBounds:c,scaleX:u,scaleY:f}}};let H={},F=t.getMatrixData();const{get:j,rotateOfOuter:G,translate:z,scaleOfOuter:U,multiplyParent:Y,scale:q,rotate:N,skew:X}=t.MatrixHelper;function V(t,e,n,a,i,s,r){const o=j();z(o,e.x+n,e.y+a),q(o,i,s),r&&G(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o}function Q(t,e,n,a,i,s,r,o,l){const d=j();K(d,e,n,a,i,s,r,o),l&&(F.a=e.width/l.width,F.d=e.height/l.height,Y(d,F)),t.transform=d}function Z(t,e,n,a,i,s,r,o,l,d,c,h){const u=j();if(h)K(u,e,i,s,r,o,l,d);else{if(l)if("center"===c)G(u,{x:n/2,y:a/2},l);else switch(N(u,l),l){case 90:z(u,a,0);break;case 180:z(u,n,a);break;case 270:z(u,0,n)}H.x=e.x+i,H.y=e.y+s,z(u,H.x,H.y),r&&U(u,H,r,o)}t.transform=u}function K(t,e,n,a,i,s,r,o){r&&N(t,r),o&&X(t,o.x,o.y),i&&q(t,i,s),z(t,e.x+n,e.y+a)}const{get:$,translate:J}=t.MatrixHelper,tt=new t.Bounds,et={},nt={};function at(t,e,n,a){const{changeful:i,sync:s,scaleFixed:r}=n;i&&(t.changeful=i),s&&(t.sync=s),r&&(t.scaleFixed=r),t.data=it(n,a,e)}function it(e,n,a){e.padding&&(n=tt.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:i,height:s}=a;const{opacity:r,mode:o,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:m}=e,y=n.width===i&&n.height===s,w={mode:o},v="center"!==l&&(u||0)%180==90;let x,b;switch(t.BoundsHelper.set(nt,0,0,v?s:i,v?i:s),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,a,et),x=et.scaleX,b=et.scaleY),(l||_||g)&&(x&&t.BoundsHelper.scale(nt,x,b,!0),l&&t.AlignHelper.toPoint(l,nt,n,nt,!0,!0))):y&&!u||(x=b=t.BoundsHelper.getFitScale(n,nt,"fit"!==o),t.BoundsHelper.put(n,a,l,x,!1,nt),t.BoundsHelper.scale(nt,x,b,!0)),d&&t.PointHelper.move(nt,d),o){case"stretch":y||(i=n.width,s=n.height);break;case"normal":case"clip":(nt.x||nt.y||x||p||u||f)&&Q(w,n,nt.x,nt.y,x,b,u,f,e.clipSize);break;case"repeat":(!y||x||u||f)&&Z(w,n,i,s,nt.x,nt.y,x,b,u,f,l,e.freeTransform),g||(w.repeat="repeat");const a=t.isObject(g);(_||a)&&(w.gap=function(e,n,a,i,s){let r,o;t.isObject(e)?(r=e.x,o=e.y):r=o=e;return{x:st(r,a,s.width,n&&n.x),y:st(o,i,s.height,n&&n.y)}}(_,a&&g,nt.width,nt.height,n));break;default:x&&V(w,n,nt.x,nt.y,x,b,u)}return w.transform||(n.x||n.y)&&(w.transform=$(),J(w.transform,n.x,n.y)),x&&"stretch"!==o&&(w.scaleX=x,w.scaleY=b),w.width=i,w.height=s,r&&(w.opacity=r),m&&(w.filters=m),g&&(w.repeat=t.isString(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),w}function st(e,n,a,i){const s=t.isString(e)||i?(i?a-i*n:a%n)/((i||Math.floor(a/n))-1):e;return"auto"===e&&s<0?0:s}let rt,ot=new t.Bounds;const{isSame:lt}=t.BoundsHelper;function dt(t,e,n,a,i,s){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=a.width/e.pixelRatio,e.__naturalHeight=a.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return i.data||at(i,a,n,s),!0}function ct(e,n){ft(e,t.ImageEvent.LOAD,n)}function ht(e,n){ft(e,t.ImageEvent.LOADED,n)}function ut(e,n,a){n.error=a,e.forceUpdate("surface"),ft(e,t.ImageEvent.ERROR,n)}function ft(e,n,a){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,a))}function pt(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:gt,scale:_t,copy:mt}=t.MatrixHelper,{floor:yt,ceil:wt,max:vt,abs:xt}=Math;function bt(e,n,a){let{scaleX:i,scaleY:s}=e.getRenderScaleData(!0,n.scaleFixed);const r=i+"-"+s+"-"+a;if(n.patternId===r||e.destroyed)return!1;{const{image:o,data:l}=n;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:m}=l;i*=a,s*=a,f&&(f=xt(f),p=xt(p),c=gt(),mt(c,g),_t(c,1/f,1/p),i*=f,s*=p),h*=i,u*=s;const y=h*u;if(!_&&y>t.Platform.image.maxCacheSize)return!1;let w=t.Platform.image.maxPatternSize;if(o.isSVG){const t=h/o.width;t>1&&(d=t/wt(t))}else{const t=o.width*o.height;w>t&&(w=t)}y>w&&(d=Math.sqrt(y/w)),d&&(i/=d,s/=d,h/=d,u/=d),f&&(i/=f,s/=p);const v=m&&m.x*i,x=m&&m.y*s;if(g||1!==i||1!==s){const t=h+(v||0),e=u+(x||0);i/=t/vt(yt(t),1),s/=e/vt(yt(e),1),c||(c=gt(),g&&mt(c,g)),_t(c,1/i,1/s)}const b=o.getCanvas(h,u,l.opacity,l.filters,v,x,e.leafer&&e.leafer.config.smooth),E=o.getPattern(b,_||t.Platform.origin.noRepeat||"no-repeat",c,n);return n.style=E,n.patternId=r,!0}}function Et(t,e,n,a){return new(n||(n=Promise))(function(i,s){function r(t){try{l(a.next(t))}catch(t){s(t)}}function o(t){try{l(a.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(r,o)}l((a=a.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Bt={image:function(e,n,a,i,s){let r,o;const l=t.ImageManager.get(a);return rt&&a===rt.paint&&lt(i,rt.boxBounds)?r=rt.leafPaint:(r={type:a.type,image:l},l.hasAlphaPixel&&(r.isTransparent=!0),rt=l.use>1?{leafPaint:r,paint:a,boxBounds:ot.set(i)}:null),(s||l.loading)&&(o={image:l,attrName:n,attrValue:a}),l.ready?(dt(e,n,a,l,r,i),s&&(ct(e,o),ht(e,o))):l.error?s&&ut(e,o,l.error):(s&&(pt(e,!0),ct(e,o)),r.loadId=l.load(()=>{pt(e,!1),e.destroyed||(dt(e,n,a,l,r,i)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ht(e,o)),r.loadId=void 0},t=>{pt(e,!1),ut(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(n,a,i,s){const{scaleX:r,scaleY:o}=n.getRenderScaleData(!0,i.scaleFixed),{pixelRatio:l}=a,{data:d}=i;if(!d||i.patternId===r+"-"+o+"-"+l&&!e.Export.running)return!1;if(s)if(d.repeat)s=!1;else if(!(i.changeful||"miniapp"===t.Platform.name&&t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=r*l,n*=o*l,d.scaleX&&(e*=d.scaleX,n*=d.scaleY),s=e*n>t.Platform.image.maxCacheSize}return s?(n.__.__isFastShadow&&(a.fillStyle=i.style||"#000",a.fill()),function(t,e,n,a){e.save(),e.clipUI(t),n.blendMode&&(e.blendMode=n.blendMode);a.opacity&&(e.opacity*=a.opacity);a.transform&&e.transform(a.transform);e.drawImage(n.image.getFull(a.filters),0,0,a.width,a.height),e.restore()}(n,a,i,d),!0):(!i.style||i.sync||e.Export.running?bt(n,i,l):i.patternTask||(i.patternTask=t.ImageManager.patternTasker.add(()=>Et(this,void 0,void 0,function*(){i.patternTask=null,a.bounds.hit(n.__nowWorld)&&bt(n,i,l),n.forceUpdate("surface")}),300)),!1)},createPattern:bt,recycleImage:function(e,n){const a=n["_"+e];if(t.isArray(a)){let i,s,r,o,l;for(let d=0,c=a.length;d<c;d++)i=a[d],s=i.image,l=s&&s.url,l&&(r||(r={}),r[l]=!0,t.ImageManager.recycle(s),s.loading&&(o||(o=n.__input&&n.__input[e]||[],t.isArray(o)||(o=[o])),s.unload(a[d].loadId,!o.some(t=>t.url===l))));return r}return null},createData:at,getPatternData:it,fillOrFitMode:V,clipMode:Q,repeatMode:Z},{toPoint:St}=t.AroundHelper,{hasTransparent:Rt}=e.ColorConvert,kt={},Lt={};function Pt(n,a,i,s){if(i){let r,o,l,d;for(let n=0,c=i.length;n<c;n++)r=i[n],t.isString(r)?(l=n/(c-1),o=e.ColorConvert.string(r,s)):(l=r.offset,o=e.ColorConvert.string(r.color,s)),a.addColorStop(l,o),!d&&Rt(o)&&(d=!0);d&&(n.isTransparent=!0)}}const{getAngle:Ct,getDistance:At}=t.PointHelper,{get:Ot,rotateOfOuter:Tt,scaleOfOuter:Mt}=t.MatrixHelper,{toPoint:Wt}=t.AroundHelper,Dt={},It={};function Ht(t,e,n,a,i){let s;const{width:r,height:o}=t;if(r!==o||a){const t=Ct(e,n);s=Ot(),i?(Mt(s,e,r/o*(a||1),1),Tt(s,e,t+90)):(Mt(s,e,1,r/o*(a||1)),Tt(s,e,t))}return s}const{getDistance:Ft}=t.PointHelper,{toPoint:jt}=t.AroundHelper,Gt={},zt={};const Ut={linearGradient:function(e,n){let{from:a,to:i,type:s,opacity:r}=e;St(a||"top",n,kt),St(i||"bottom",n,Lt);const o=t.Platform.canvas.createLinearGradient(kt.x,kt.y,Lt.x,Lt.y),l={type:s,style:o};return Pt(l,o,e.stops,r),l},radialGradient:function(e,n){let{from:a,to:i,type:s,opacity:r,stretch:o}=e;Wt(a||"center",n,Dt),Wt(i||"bottom",n,It);const l=t.Platform.canvas.createRadialGradient(Dt.x,Dt.y,0,Dt.x,Dt.y,At(Dt,It)),d={type:s,style:l};Pt(d,l,e.stops,r);const c=Ht(n,Dt,It,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:a,to:i,type:s,opacity:r,stretch:o}=e;jt(a||"center",n,Gt),jt(i||"bottom",n,zt);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,Ft(Gt,zt)),d={type:s,style:l};Pt(d,l,e.stops,r);const c=Ht(n,Gt,zt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ht},{copy:Yt,toOffsetOutBounds:qt}=t.BoundsHelper,Nt={},Xt={};function Vt(e,n,a,i){const{bounds:s,shapeBounds:r}=i;if(t.Platform.fullImageShadow){if(Yt(Nt,e.bounds),Nt.x+=n.x-r.x,Nt.y+=n.y-r.y,a){const{fitMatrix:t}=i;Nt.x-=(s.x+(t?t.e:0)+s.width/2)*(a-1),Nt.y-=(s.y+(t?t.f:0)+s.height/2)*(a-1),Nt.width*=a,Nt.height*=a}e.copyWorld(i.canvas,e.bounds,Nt)}else a&&(Yt(Nt,n),Nt.x-=n.width/2*(a-1),Nt.y-=n.height/2*(a-1),Nt.width*=a,Nt.height*=a),e.copyWorld(i.canvas,r,a?Nt:n)}const{toOffsetOutBounds:Qt}=t.BoundsHelper,Zt={};const Kt={shadow:function(n,a,i){let s,r;const{__nowWorld:o,__layout:l}=n,{shadow:d}=n.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=i,g=a.getSameCanvas(),_=d.length-1;qt(h,Xt),d.forEach((d,m)=>{let y=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.setWorldShadow(Xt.offsetX+d.x*f*y,Xt.offsetY+d.y*p*y,d.blur*f*y,e.ColorConvert.string(d.color)),r=d.spread?1+2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*y:0,Vt(g,Xt,r,i),s=h,d.box&&(g.restore(),g.save(),c&&(g.copyWorld(g,h,o,"copy"),s=o),c?g.copyWorld(c,o,o,"destination-out"):g.copyWorld(i.canvas,u,h,"destination-out")),e.Effect.isTransformShadow(d)?e.Effect.renderTransformShadow(n,a,g,s,d):t.LeafHelper.copyCanvasByWorld(n,a,g,s,d.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},innerShadow:function(n,a,i){let s,r;const{__nowWorld:o,__layout:l}=n,{innerShadow:d}=n.__,{worldCanvas:c,bounds:h,shapeBounds:u,scaleX:f,scaleY:p}=i,g=a.getSameCanvas(),_=d.length-1;Qt(h,Zt),d.forEach((d,m)=>{let y=1;if(d.scaleFixed){const t=Math.abs(o.scaleX);t>1&&(y=1/t)}g.save(),g.setWorldShadow(Zt.offsetX+d.x*f*y,Zt.offsetY+d.y*p*y,d.blur*f*y),r=d.spread?1-2*d.spread/(l.boxBounds.width+2*(l.strokeBoxSpread||0))*y:0,Vt(g,Zt,r,i),g.restore(),c?(g.copyWorld(g,h,o,"copy"),g.copyWorld(c,o,o,"source-out"),s=o):(g.copyWorld(i.canvas,u,h,"source-out"),s=h),g.fillWorld(s,e.ColorConvert.string(d.color),"source-in"),t.LeafHelper.copyCanvasByWorld(n,a,g,s,d.blendMode),_&&m<_&&g.clearWorld(s)}),g.recycle(s)},blur:function(t,e,n){const{blur:a}=t.__;n.setWorldBlur(a*t.__nowWorld.a),n.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),n.filter="none"},backgroundBlur:function(t,e,n){},getShadowSpread:function(t,e){let n=0;return e.forEach(t=>n=Math.max(n,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread>0?t.spread:0)+1.5*t.blur)),n},isTransformShadow(t){}},{excludeRenderBounds:$t}=t.LeafBoundsHelper;let Jt;function te(t,e,n,a,i,s,r,o){switch(e){case"grayscale":Jt||(Jt=!0,i.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,n,a,i,s){const r=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(a,r),s&&a.recycle(r);ne(t,e,n,1,i,s)}(t,n,a,i,r,o);break;case"opacity-path":ne(t,n,a,s,r,o);break;case"path":o&&n.restore()}}function ee(t){return t.getSameCanvas(!1,!0)}function ne(t,e,n,a,i,s){const r=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(n,r,void 0,i),s?n.recycle(r):n.clearWorld(r)}e.Group.prototype.__renderMask=function(t,e){let n,a,i,s,r,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(n=l[d],o=n.__.mask,o){r&&(te(this,r,t,i,a,s,void 0,!0),a=i=null),s=n.__.opacity,Jt=!1,"path"===o||"clipping-path"===o?(s<1?(r="opacity-path",i||(i=ee(t))):(r="path",t.save()),n.__clip(i||t,e)):(r="grayscale"===o?"grayscale":"alpha",a||(a=ee(t)),i||(i=ee(t)),n.__render(a,e)),"clipping"!==o&&"clipping-path"!==o||$t(n,e)||n.__render(t,e);continue}const c=1===s&&n.__.__blendMode;c&&te(this,r,t,i,a,s,void 0,!1),$t(n,e)||n.__render(i||t,e),c&&te(this,r,t,i,a,s,c,!1)}te(this,r,t,i,a,s,void 0,!0)};const ae=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ie=ae+"_#~&*+\\=|≮≯≈≠=…",se=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 re(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const oe=re("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),le=re("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),de=re(ae),ce=re(ie),he=re("- —/~|┆·");var ue;!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"}(ue||(ue={}));const{Letter:fe,Single:pe,Before:ge,After:_e,Symbol:me,Break:ye}=ue;function we(t){return oe[t]?fe:he[t]?ye:le[t]?ge:de[t]?_e:ce[t]?me:se.test(t)?pe:fe}const ve={trimRight(t){const{words:e}=t;let n,a=0,i=e.length;for(let s=i-1;s>-1&&(n=e[s].data[0]," "===n.char);s--)a++,t.width-=n.width;a&&e.splice(i-a,a)}};function xe(t,e,n){switch(e){case"title":return n?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:be}=ve,{Letter:Ee,Single:Be,Before:Se,After:Re,Symbol:ke,Break:Le}=ue;let Pe,Ce,Ae,Oe,Te,Me,We,De,Ie,He,Fe,je,Ge,ze,Ue,Ye,qe,Ne=[];function Xe(t,e){Ie&&!De&&(De=Ie),Pe.data.push({char:t,width:e}),Ae+=e}function Ve(){Oe+=Ae,Pe.width=Ae,Ce.words.push(Pe),Pe={data:[]},Ae=0}function Qe(){ze&&(Ue.paraNumber++,Ce.paraStart=!0,ze=!1),Ie&&(Ce.startCharSize=De,Ce.endCharSize=Ie,De=0),Ce.width=Oe,Ye.width?be(Ce):qe&&Ze(),Ne.push(Ce),Ce={words:[]},Oe=0}function Ze(){Oe>(Ue.maxWidth||0)&&(Ue.maxWidth=Oe)}const{top:Ke,right:$e,bottom:Je,left:tn}=t.Direction4;function en(t,e,n){const{bounds:a,rows:i}=t;a[e]+=n;for(let t=0;t<i.length;t++)i[t][e]+=n}const nn={getDrawData:function(n,a){t.isString(n)||(n=String(n));let i=0,s=0,r=a.__getInput("width")||0,o=a.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=a;c&&(r?(i=c[tn],r-=c[$e]+c[tn]):a.autoSizeAlign||(i=c[tn]),o?(s=c[Ke],o-=c[Ke]+c[Je]):a.autoSizeAlign||(s=c[Ke]));const h={bounds:{x:i,y:s,width:r,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,a){Ue=e,Ne=e.rows,Ye=e.bounds,qe=!Ye.width&&!a.autoSizeAlign;const{__letterSpacing:i,paraIndent:s,textCase:r}=a,{canvas:o}=t.Platform,{width:l,height:d}=Ye;if(l||d||i||"none"!==r){const t="none"!==a.textWrap,e="break"===a.textWrap;ze=!0,Fe=null,De=We=Ie=Ae=Oe=0,Pe={data:[]},Ce={words:[]},i&&(n=[...n]);for(let a=0,d=n.length;a<d;a++)Me=n[a],"\n"===Me?(Ae&&Ve(),Ce.paraEnd=!0,Qe(),ze=!0):(He=we(Me),He===Ee&&"none"!==r&&(Me=xe(Me,r,!Ae)),We=o.measureText(Me).width,i&&(i<0&&(Ie=We),We+=i),je=He===Be&&(Fe===Be||Fe===Ee)||Fe===Be&&He!==Re,Ge=!(He!==Se&&He!==Be||Fe!==ke&&Fe!==Re),Te=ze&&s?l-s:l,t&&l&&Oe+Ae+We>Te&&(e?(Ae&&Ve(),Oe&&Qe()):(Ge||(Ge=He===Ee&&Fe==Re),je||Ge||He===Le||He===Se||He===Be||Ae+We>Te?(Ae&&Ve(),Oe&&Qe()):Oe&&Qe()))," "===Me&&!0!==ze&&Oe+Ae===0||(He===Le?(" "===Me&&Ae&&Ve(),Xe(Me,We),Ve()):je||Ge?(Ae&&Ve(),Xe(Me,We)):Xe(Me,We)),Fe=He);Ae&&Ve(),Oe&&Qe(),Ne.length>0&&(Ne[Ne.length-1].paraEnd=!0)}else n.split("\n").forEach(t=>{Ue.paraNumber++,Oe=o.measureText(t).width,Ne.push({x:s||0,text:t,width:Oe,paraStart:!0}),qe&&Ze()})}(h,n,a),c&&function(t,e,n,a,i){if(!a&&n.autoSizeAlign)switch(n.textAlign){case"left":en(e,"x",t[tn]);break;case"right":en(e,"x",-t[$e])}if(!i&&n.autoSizeAlign)switch(n.verticalAlign){case"top":en(e,"y",t[Ke]);break;case"bottom":en(e,"y",-t[Je])}}(c,h,a,r,o),function(t,e){const{rows:n,bounds:a}=t,i=n.length,{__lineHeight:s,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=a,m=s*i+(h?h*(t.paraNumber-1):0),y=r;if(l&&m>_)m=Math.max(_,s),i>1&&(t.overflow=i);else if(_||u)switch(c){case"middle":p+=(_-m)/2;break;case"bottom":p+=_-m}y+=p;let w,v,x,b=g||u?g:t.maxWidth;for(let r=0,c=i;r<c;r++){if(w=n[r],w.x=f,w.width<g||w.width>g&&!l)switch(d){case"center":w.x+=(b-w.width)/2;break;case"right":w.x+=b-w.width}w.paraStart&&h&&r>0&&(y+=h),w.y=y,y+=s,t.overflow>r&&y>m&&(w.isOverflow=!0,t.overflow=r+1),v=w.x,x=w.width,o<0&&(w.width<0?(x=-w.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<a.x&&(a.x=v),x>a.width&&(a.width=x),l&&g&&g<x&&(w.isOverflow=!0,t.overflow||(t.overflow=n.length))}a.y=p,a.height=m}(h,a),function(t,e,n){const{rows:a}=t,{textAlign:i,paraIndent:s,letterSpacing:r}=e;let o,l,d,c,h,u;a.forEach(t=>{t.words&&(d=s&&t.paraStart?s:0,u=t.words.length,l=n&&("justify"===i||"both"===i)&&u>1?(n-t.width-d)/(u-1):0,c=r||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===c?(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,n)=>{1===c?(h={char:"",x:o},o=function(t,e,n){return t.forEach(t=>{n.char+=t.char,e+=t.width}),e}(e.data,o,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):o=function(t,e,n,a){return t.forEach(t=>{(a||" "!==t.char)&&(t.x=e,n.push(t)),e+=t.width}),e}(e.data,o,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==i||n===u-1||(o+=l,t.width+=l)})),t.words=null)})}(h,a,r),h.overflow&&function(e,n,a,i){if(!i)return;const{rows:s,overflow:r}=e;let{textOverflow:o}=n;if(s.splice(r),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=a+i-d;("none"===n.textWrap?s:[s[r-1]]).forEach(t=>{if(t.isOverflow&&t.data){let n=t.data.length-1;for(let a=n;a>-1&&(e=t.data[a],l=e.x+e.width,!(a===n&&l<c));a--){if(l<c&&" "!==e.char||!a){t.data.splice(a+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)}})}}(h,a,i,r),"none"!==l&&function(n,a){let i,s=0;const{fontSize:r,textDecoration:o}=a;switch(n.decorationHeight=r/11,t.isObject(o)?(i=o.type,o.color&&(n.decorationColor=e.ColorConvert.string(o.color)),o.offset&&(s=Math.min(.3*r,Math.max(o.offset,.15*-r)))):i=o,i){case"under":n.decorationY=[.15*r+s];break;case"delete":n.decorationY=[.35*-r];break;case"under-delete":n.decorationY=[.15*r+s,.35*-r]}}(h,a),h}};const an={string:function(n,a){const i=t.isNumber(a)&&a<1;if(t.isString(n)){if(!i||!e.ColorConvert.object)return n;n=e.ColorConvert.object(n)}let s=t.isUndefined(n.a)?1:n.a;i&&(s*=a);const r=n.r+","+n.g+","+n.b;return 1===s?"rgb("+r+")":"rgba("+r+","+s+")"}};Object.assign(e.TextConvert,nn),Object.assign(e.ColorConvert,an),Object.assign(e.Paint,I),Object.assign(e.PaintImage,Bt),Object.assign(e.PaintGradient,Ut),Object.assign(e.Effect,Kt),i(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=w,exports.Watcher=r,exports.useCanvas=i,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=worker.min.cjs.map