@leafer-draw/worker 1.6.7 → 1.7.0

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
@@ -46,7 +46,7 @@ var LeaferUI = (function (exports) {
46
46
  };
47
47
  const I$1 = IncrementId;
48
48
 
49
- const { round: round$3, pow: pow$1, PI: PI$4 } = Math;
49
+ const { round: round$3, pow: pow$1, PI: PI$3 } = Math;
50
50
  const MathHelper = {
51
51
  within(value, min, max) {
52
52
  if (typeof min === 'object')
@@ -142,9 +142,9 @@ var LeaferUI = (function (exports) {
142
142
  function randInt(num) {
143
143
  return Math.round(Math.random() * num);
144
144
  }
145
- const OneRadian = PI$4 / 180;
146
- const PI2 = PI$4 * 2;
147
- const PI_2 = PI$4 / 2;
145
+ const OneRadian = PI$3 / 180;
146
+ const PI2 = PI$3 * 2;
147
+ const PI_2 = PI$3 / 2;
148
148
  function getPointData() { return { x: 0, y: 0 }; }
149
149
  function getBoundsData() { return { x: 0, y: 0, width: 0, height: 0 }; }
150
150
  function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
@@ -439,7 +439,7 @@ var LeaferUI = (function (exports) {
439
439
  const M$6 = MatrixHelper;
440
440
 
441
441
  const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
442
- const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2, PI: PI$3 } = Math;
442
+ const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2 } = Math;
443
443
  const PointHelper = {
444
444
  defaultPoint: getPointData(),
445
445
  tempPoint: {},
@@ -552,10 +552,11 @@ var LeaferUI = (function (exports) {
552
552
  getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
553
553
  if (toOriginX === undefined)
554
554
  toOriginX = originX, toOriginY = originY;
555
- let fromAngle = atan2$2(fromY - originY, fromX - originX);
556
- let toAngle = atan2$2(toY - toOriginY, toX - toOriginX);
557
- const radian = toAngle - fromAngle;
558
- return radian < -PI$3 ? radian + PI2 : radian;
555
+ const a = fromX - originX;
556
+ const b = fromY - originY;
557
+ const c = toX - toOriginX;
558
+ const d = toY - toOriginY;
559
+ return Math.atan2(a * d - b * c, a * c + b * d);
559
560
  },
560
561
  getAtan2(t, to) {
561
562
  return atan2$2(to.y - t.y, to.x - t.x);
@@ -3342,7 +3343,7 @@ var LeaferUI = (function (exports) {
3342
3343
  const { arcTo } = PathCommandDataHelper;
3343
3344
  const PathCorner = {
3344
3345
  smooth(data, cornerRadius, _cornerSmoothing) {
3345
- let command, commandLen;
3346
+ let command, lastCommand, commandLen;
3346
3347
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3347
3348
  const len = data.length;
3348
3349
  const smooth = [];
@@ -3380,8 +3381,10 @@ var LeaferUI = (function (exports) {
3380
3381
  lastY = y;
3381
3382
  break;
3382
3383
  case Z:
3383
- arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3384
- smooth.push(Z);
3384
+ if (lastCommand !== Z) {
3385
+ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3386
+ smooth.push(Z);
3387
+ }
3385
3388
  i += 1;
3386
3389
  break;
3387
3390
  default:
@@ -3390,6 +3393,7 @@ var LeaferUI = (function (exports) {
3390
3393
  smooth.push(data[i + j]);
3391
3394
  i += commandLen;
3392
3395
  }
3396
+ lastCommand = command;
3393
3397
  }
3394
3398
  if (command !== Z) {
3395
3399
  smooth[1] = startX;
@@ -3886,12 +3890,12 @@ var LeaferUI = (function (exports) {
3886
3890
  try {
3887
3891
  if (transform && pattern.setTransform) {
3888
3892
  pattern.setTransform(transform);
3889
- transform = null;
3893
+ transform = undefined;
3890
3894
  }
3891
3895
  }
3892
3896
  catch (_a) { }
3893
3897
  if (paint)
3894
- paint.transform = transform;
3898
+ DataHelper.stintSet(paint, 'transform', transform);
3895
3899
  return pattern;
3896
3900
  }
3897
3901
  destroy() {
@@ -3996,10 +4000,14 @@ var LeaferUI = (function (exports) {
3996
4000
  }));
3997
4001
  }
3998
4002
  const pathType = boundsType;
3999
- function affectStrokeBoundsType(defaultValue) {
4003
+ function affectStrokeBoundsType(defaultValue, useStroke) {
4000
4004
  return decorateLeafAttr(defaultValue, (key) => attr({
4001
4005
  set(value) {
4002
- this.__setAttr(key, value) && doStrokeType(this);
4006
+ if (this.__setAttr(key, value)) {
4007
+ doStrokeType(this);
4008
+ if (useStroke)
4009
+ this.__.__useStroke = true;
4010
+ }
4003
4011
  }
4004
4012
  }));
4005
4013
  }
@@ -5425,6 +5433,8 @@ var LeaferUI = (function (exports) {
5425
5433
 
5426
5434
  const LeafRender = {
5427
5435
  __render(canvas, options) {
5436
+ if (options.shape)
5437
+ return this.__renderShape(canvas, options);
5428
5438
  if (this.__worldOpacity) {
5429
5439
  const data = this.__;
5430
5440
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
@@ -5434,12 +5444,10 @@ var LeaferUI = (function (exports) {
5434
5444
  return this.__renderEraser(canvas, options);
5435
5445
  const tempCanvas = canvas.getSameCanvas(true, true);
5436
5446
  this.__draw(tempCanvas, options, canvas);
5437
- if (this.__worldFlipped) {
5447
+ if (this.__worldFlipped)
5438
5448
  canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
5439
- }
5440
- else {
5449
+ else
5441
5450
  canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
5442
- }
5443
5451
  tempCanvas.recycle(this.__nowWorld);
5444
5452
  }
5445
5453
  else {
@@ -5449,6 +5457,12 @@ var LeaferUI = (function (exports) {
5449
5457
  Debug.drawBounds(this, canvas, options);
5450
5458
  }
5451
5459
  },
5460
+ __renderShape(canvas, options) {
5461
+ if (this.__worldOpacity) {
5462
+ canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5463
+ this.__drawShape(canvas, options);
5464
+ }
5465
+ },
5452
5466
  __clip(canvas, options) {
5453
5467
  if (this.__worldOpacity) {
5454
5468
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
@@ -5868,7 +5882,8 @@ var LeaferUI = (function (exports) {
5868
5882
  __drawFast(_canvas, _options) { }
5869
5883
  __draw(_canvas, _options, _originCanvas) { }
5870
5884
  __clip(_canvas, _options) { }
5871
- __renderShape(_canvas, _options, _ignoreFill, _ignoreStroke) { }
5885
+ __renderShape(_canvas, _options) { }
5886
+ __drawShape(_canvas, _options) { }
5872
5887
  __updateWorldOpacity() { }
5873
5888
  __updateChange() { }
5874
5889
  __drawPath(_canvas) { }
@@ -6236,7 +6251,7 @@ var LeaferUI = (function (exports) {
6236
6251
  }
6237
6252
  }
6238
6253
 
6239
- const version = "1.6.7";
6254
+ const version = "1.7.0";
6240
6255
 
6241
6256
  class LeaferCanvas extends LeaferCanvasBase {
6242
6257
  get allowBackgroundColor() { return true; }
@@ -6996,13 +7011,9 @@ var LeaferUI = (function (exports) {
6996
7011
  else
6997
7012
  return strokeWidth;
6998
7013
  }
6999
- get __hasStroke() { return this.stroke && this.strokeWidth; }
7000
- get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
7001
7014
  get __hasMultiPaint() {
7002
7015
  const t = this;
7003
- if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
7004
- return true;
7005
- return t.fill && this.__hasStroke;
7016
+ return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect;
7006
7017
  }
7007
7018
  get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
7008
7019
  get __hasSurface() { const t = this; return (t.fill || t.stroke); }
@@ -7293,15 +7304,18 @@ var LeaferUI = (function (exports) {
7293
7304
  const UIRender = {
7294
7305
  __updateChange() {
7295
7306
  const data = this.__;
7307
+ if (data.__useStroke) {
7308
+ const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
7309
+ stintSet$1(this.__world, 'half', useStroke && data.strokeAlign === 'center' && data.strokeWidth % 2);
7310
+ stintSet$1(data, '__fillAfterStroke', useStroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7311
+ }
7296
7312
  if (data.__useEffect) {
7297
7313
  const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7298
7314
  stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
7299
7315
  data.__useEffect = !!(shadow || otherEffect);
7300
7316
  }
7301
- stintSet$1(this.__world, 'half', data.__hasHalf);
7302
- stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7303
7317
  data.__checkSingle();
7304
- stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7318
+ stintSet$1(data, '__complex', (data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect));
7305
7319
  },
7306
7320
  __drawFast(canvas, options) {
7307
7321
  drawFast(this, canvas, options);
@@ -7359,18 +7373,15 @@ var LeaferUI = (function (exports) {
7359
7373
  this.__drawFast(canvas, options);
7360
7374
  }
7361
7375
  },
7362
- __renderShape(canvas, options, ignoreFill, ignoreStroke) {
7363
- if (this.__worldOpacity) {
7364
- canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
7365
- const { fill, stroke } = this.__;
7366
- this.__drawRenderPath(canvas);
7367
- if (fill && !ignoreFill)
7368
- this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7369
- if (this.__.__isCanvas)
7370
- this.__drawAfterFill(canvas, options);
7371
- if (stroke && !ignoreStroke)
7372
- this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7373
- }
7376
+ __drawShape(canvas, options) {
7377
+ this.__drawRenderPath(canvas);
7378
+ const data = this.__, { fill, stroke } = data;
7379
+ if (fill && !options.ignoreFill)
7380
+ data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7381
+ if (data.__isCanvas)
7382
+ this.__drawAfterFill(canvas, options);
7383
+ if (stroke && !options.ignoreStroke)
7384
+ data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7374
7385
  },
7375
7386
  __drawAfterFill(canvas, options) {
7376
7387
  if (this.__.__clipAfterFill) {
@@ -7495,12 +7506,14 @@ var LeaferUI = (function (exports) {
7495
7506
  }
7496
7507
  }
7497
7508
  __updateRenderPath() {
7498
- if (this.__.path) {
7499
- const data = this.__;
7509
+ const data = this.__;
7510
+ if (data.path) {
7500
7511
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
7501
7512
  if (data.__useArrow)
7502
7513
  PathArrow.addArrows(this, !data.cornerRadius);
7503
7514
  }
7515
+ else
7516
+ data.__pathForRender && (data.__pathForRender = undefined);
7504
7517
  }
7505
7518
  __drawRenderPath(canvas) {
7506
7519
  canvas.beginPath();
@@ -7711,13 +7724,13 @@ var LeaferUI = (function (exports) {
7711
7724
  surfaceType()
7712
7725
  ], exports.UI.prototype, "fill", void 0);
7713
7726
  __decorate([
7714
- strokeType()
7727
+ strokeType(undefined, true)
7715
7728
  ], exports.UI.prototype, "stroke", void 0);
7716
7729
  __decorate([
7717
7730
  strokeType('inside')
7718
7731
  ], exports.UI.prototype, "strokeAlign", void 0);
7719
7732
  __decorate([
7720
- strokeType(1)
7733
+ strokeType(1, true)
7721
7734
  ], exports.UI.prototype, "strokeWidth", void 0);
7722
7735
  __decorate([
7723
7736
  strokeType(false)
@@ -8144,7 +8157,7 @@ var LeaferUI = (function (exports) {
8144
8157
  list.push(item);
8145
8158
  this.requestRender();
8146
8159
  }
8147
- zoom(_zoomType, _padding, _fixedScale, _transition) {
8160
+ zoom(_zoomType, _optionsOrPadding, _scroll, _transition) {
8148
8161
  return Plugin.need('view');
8149
8162
  }
8150
8163
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
@@ -8189,7 +8202,7 @@ var LeaferUI = (function (exports) {
8189
8202
  Leafer_1.list.remove(this);
8190
8203
  try {
8191
8204
  this.stop();
8192
- this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
8205
+ this.emitLeafer(LeaferEvent.END);
8193
8206
  this.__removeListenEvents();
8194
8207
  this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
8195
8208
  this.__controllers.length = 0;
@@ -8317,7 +8330,7 @@ var LeaferUI = (function (exports) {
8317
8330
  }
8318
8331
  __drawContent(canvas, options) {
8319
8332
  this.__renderGroup(canvas, options);
8320
- if (this.__.__hasStroke) {
8333
+ if (this.__.__useStroke) {
8321
8334
  canvas.setWorld(this.__nowWorld);
8322
8335
  this.__drawRenderPath(canvas);
8323
8336
  }
@@ -8537,8 +8550,8 @@ var LeaferUI = (function (exports) {
8537
8550
  for (let i = 1; i < sides; i++) {
8538
8551
  lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
8539
8552
  }
8553
+ closePath$1(path);
8540
8554
  }
8541
- closePath$1(path);
8542
8555
  }
8543
8556
  __updateRenderPath() { }
8544
8557
  __updateBoxBounds() { }
@@ -8776,6 +8789,11 @@ var LeaferUI = (function (exports) {
8776
8789
  return;
8777
8790
  super.__draw(canvas, options, originCanvas);
8778
8791
  }
8792
+ __drawShape(canvas, options) {
8793
+ if (options.shape)
8794
+ this.__box && this.__box.__drawShape(canvas, options);
8795
+ super.__drawShape(canvas, options);
8796
+ }
8779
8797
  destroy() {
8780
8798
  if (this.boxStyle)
8781
8799
  this.boxStyle = null;
@@ -9236,7 +9254,7 @@ var LeaferUI = (function (exports) {
9236
9254
  };
9237
9255
 
9238
9256
  let origin = {};
9239
- const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
9257
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
9240
9258
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
9241
9259
  const transform = get$3();
9242
9260
  translate$1(transform, box.x + x, box.y + y);
@@ -9245,13 +9263,15 @@ var LeaferUI = (function (exports) {
9245
9263
  rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
9246
9264
  data.transform = transform;
9247
9265
  }
9248
- function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
9266
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
9249
9267
  const transform = get$3();
9250
- translate$1(transform, box.x + x, box.y + y);
9251
- if (scaleX)
9252
- scaleHelper(transform, scaleX, scaleY);
9253
9268
  if (rotation)
9254
9269
  rotate(transform, rotation);
9270
+ if (skew)
9271
+ skewHelper(transform, skew.x, skew.y);
9272
+ if (scaleX)
9273
+ scaleHelper(transform, scaleX, scaleY);
9274
+ translate$1(transform, box.x + x, box.y + y);
9255
9275
  data.transform = transform;
9256
9276
  }
9257
9277
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -9288,11 +9308,13 @@ var LeaferUI = (function (exports) {
9288
9308
  const tempScaleData = {};
9289
9309
  const tempImage = {};
9290
9310
  function createData(leafPaint, image, paint, box) {
9291
- const { changeful, sync } = paint;
9311
+ const { changeful, sync, editing } = paint;
9292
9312
  if (changeful)
9293
9313
  leafPaint.changeful = changeful;
9294
9314
  if (sync)
9295
9315
  leafPaint.sync = sync;
9316
+ if (editing)
9317
+ leafPaint.editing = editing;
9296
9318
  leafPaint.data = getPatternData(paint, box, image);
9297
9319
  }
9298
9320
  function getPatternData(paint, box, image) {
@@ -9301,7 +9323,7 @@ var LeaferUI = (function (exports) {
9301
9323
  if (paint.mode === 'strench')
9302
9324
  paint.mode = 'stretch';
9303
9325
  let { width, height } = image;
9304
- const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
9326
+ const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
9305
9327
  const sameBox = box.width === width && box.height === height;
9306
9328
  const data = { mode };
9307
9329
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -9335,8 +9357,8 @@ var LeaferUI = (function (exports) {
9335
9357
  break;
9336
9358
  case 'normal':
9337
9359
  case 'clip':
9338
- if (tempImage.x || tempImage.y || scaleX || rotation)
9339
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
9360
+ if (tempImage.x || tempImage.y || scaleX || rotation || skew)
9361
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
9340
9362
  break;
9341
9363
  case 'repeat':
9342
9364
  if (!sameBox || scaleX || rotation)
@@ -9413,11 +9435,11 @@ var LeaferUI = (function (exports) {
9413
9435
  }
9414
9436
  onLoadSuccess(ui, event);
9415
9437
  }
9416
- leafPaint.loadId = null;
9438
+ leafPaint.loadId = undefined;
9417
9439
  }, (error) => {
9418
9440
  ignoreRender(ui, false);
9419
9441
  onLoadError(ui, event, error);
9420
- leafPaint.loadId = null;
9442
+ leafPaint.loadId = undefined;
9421
9443
  });
9422
9444
  if (ui.placeholderColor) {
9423
9445
  if (!ui.placeholderDelay)
@@ -9483,6 +9505,8 @@ var LeaferUI = (function (exports) {
9483
9505
  const { image, data } = paint;
9484
9506
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
9485
9507
  if (sx) {
9508
+ sx = abs$1(sx);
9509
+ sy = abs$1(sy);
9486
9510
  imageMatrix = get$1();
9487
9511
  copy$1(imageMatrix, transform);
9488
9512
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -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 r(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((r,i)=>{t.convertToBlob({type:a(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>r(t.target.result),e.onerror=t=>i(t),e.readAsDataURL(t)})).catch((t=>{i(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 r=new XMLHttpRequest;r.open("GET",t.Platform.image.getRealURL(e),!0),r.responseType="blob",r.onload=()=>{createImageBitmap(r.response).then((t=>{n(t)})).catch((t=>{a(t)}))},r.onerror=t=>a(t),r.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:i}=navigator;i.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):i.indexOf("Safari")>-1&&-1===i.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),i.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):i.indexOf("Mac")>-1?t.Platform.os="Mac":i.indexOf("Linux")>-1&&(t.Platform.os="Linux");class s{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,e instanceof Array&&(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:r}=this,{BEFORE:i,LAYOUT:s,AFTER:u}=t.LayoutEvent,f=this.getBlocks(r);f.forEach((t=>t.setBefore())),a.emitEvent(new t.LayoutEvent(i,f,this.times)),this.extraBlock=null,r.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)))}))}(r,this.__levelList),function(t){let e,n,a;t.sort(!0),t.levels.forEach((r=>{e=t.levelMap[r];for(let t=0,r=e.length;t<r;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)}(r),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),a.emitEvent(new t.LayoutEvent(s,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:r,AFTER:i}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(a,s,this.times)),m.fullLayout(n),s.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(r,s,this.times)),n.emitEvent(new t.LayoutEvent(i,s,this.times)),this.addBlocks(s),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:60},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,r=e.getIntersect(a.bounds),i=new t.Bounds(r);a.save(),r.spread(w.clipSpread).ceil(),a.clearWorld(r,!0),a.clipWorld(r,!0),this.__render(r,i),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,r=e.includes(this.target.__world),i=r?{includes:r}:{bounds:e,includes:r};this.needFill&&a.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(a,e),this.target.__render(a,i),this.renderBounds=n=n||e,this.renderOptions=i,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();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,this.checkRender()}))}__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.target=this.canvas=this.config=null)}}function v(t,e){const n=t.__,{rows:a,decorationY:r}=n.__textDrawData;let i;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=a.length;t<n;t++)i=a[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(r){const{decorationColor:t,decorationHeight:i}=n.__textDrawData;t&&(e.fillStyle=t),a.forEach((t=>r.forEach((n=>e.fillRect(t.x,t.y+n,t.width,i)))))}}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(t,e,n,a){const r=n.__;a.setStroke(!r.__isStrokes&&t,r.strokeWidth*e,r),r.__isStrokes?k(t,!0,n,a):L(n,a)}function B(t,e,n,a){const r=a.getSameCanvas(!0,!0);r.font=n.__.__font,E(t,2,n,r),r.blendMode="outside"===e?"destination-out":"destination-in",v(n,r),r.blendMode="normal",R(a,r,n),r.recycle(n.__nowWorld)}function R(e,n,a){a.__worldFlipped||t.Platform.fullImageShadow?e.copyWorldByReset(n,a.__nowWorld):e.copyWorldToInner(n,a.__nowWorld,a.__layout.renderBounds)}function L(t,e){let n,a=t.__.__textDrawData;const{rows:r,decorationY:i}=a;for(let t=0,a=r.length;t<a;t++)n=r[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(i){const{decorationHeight:t}=a;r.forEach((n=>i.forEach((a=>e.strokeRect(n.x,n.y+a,n.width,t)))))}}function k(t,n,a,r){let i;for(let s=0,o=t.length;s<o;s++)i=t[s],i.image&&e.PaintImage.checkImage(a,r,i,!1)||i.style&&(r.strokeStyle=i.style,i.blendMode?(r.saveBlendMode(i.blendMode),n?L(a,r):r.stroke(),r.restoreBlendMode()):n?L(a,r):r.stroke())}function S(t,e,n){const a=e.__;if(a.__strokeWidth)if(a.__font)b(t,e,n);else switch(a.strokeAlign){case"center":P(t,1,e,n);break;case"inside":!function(t,e,n){n.save(),n.clipUI(e),P(t,2,e,n),n.restore()}(t,e,n);break;case"outside":!function(t,e,n){const a=e.__;if(a.__fillAfterStroke)P(t,2,e,n);else{const{renderBounds:r}=e.__layout,i=n.getSameCanvas(!0,!0);e.__drawRenderPath(i),P(t,2,e,i),i.clipUI(a),i.clearWorld(r),R(n,i,e),i.recycle(e.__nowWorld)}}(t,e,n)}}function P(t,n,a,r){const i=a.__;r.setStroke(!i.__isStrokes&&t,i.__strokeWidth*n,i),i.__isStrokes?k(t,!1,a,r):r.stroke(),i.__useArrow&&e.Paint.strokeArrow(t,a,r)}w.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new s(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:C,getOuterOf:A,getByMove:O,getIntersectData:T}=t.BoundsHelper;let W;const{stintSet:I}=t.DataHelper,{hasTransparent:M}=e.ColorConvert;function D(t,n,a){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;let r;const{boxBounds:i}=a.__layout;switch(n.type){case"image":r=e.PaintImage.image(a,t,n,i,!W||!W[n.url]);break;case"linear":r=e.PaintGradient.linearGradient(n,i);break;case"radial":r=e.PaintGradient.radialGradient(n,i);break;case"angular":r=e.PaintGradient.conicGradient(n,i);break;case"solid":const{type:s,color:o,opacity:l}=n;r={type:s,style:e.ColorConvert.string(o,l)};break;default:void 0!==n.r&&(r={type:"solid",style:e.ColorConvert.string(n)})}return r&&("string"==typeof r.style&&M(r.style)&&(r.isTransparent=!0),n.blendMode&&(r.blendMode=n.blendMode)),r}const H={compute:function(t,n){const a=n.__,r=[];let i,s,o=a.__input[t];o instanceof Array||(o=[o]),W=e.PaintImage.recycleImage(t,a);for(let e,a=0,i=o.length;a<i;a++)(e=D(t,o[a],n))&&r.push(e);a["_"+t]=r.length?r:void 0,r.length&&r.every((t=>t.isTransparent))&&(r.some((t=>t.image))&&(i=!0),s=!0),"fill"===t?(I(a,"__isAlphaPixelFill",i),I(a,"__isTransparentFill",s)):(I(a,"__isAlphaPixelStroke",i),I(a,"__isTransparentStroke",s))},fill:function(t,e,n){n.fillStyle=t,x(e,n)},fills:function(t,n,a){let r;for(let i=0,s=t.length;i<s;i++){if(r=t[i],r.image){if(e.PaintImage.checkImage(n,a,r,!n.__.__font))continue;if(!r.style){!i&&r.image.isPlacehold&&n.drawImagePlaceholder(a,r.image);continue}}a.fillStyle=r.style,r.transform?(a.save(),a.transform(r.transform),r.blendMode&&(a.blendMode=r.blendMode),x(n,a),a.restore()):r.blendMode?(a.saveBlendMode(r.blendMode),x(n,a),a.restoreBlendMode()):x(n,a)}},fillPathOrText:x,fillText:v,stroke:S,strokes:function(t,e,n){S(t,e,n)},strokeText:b,drawTextStroke:L,shape:function(t,e,n){const a=e.getSameCanvas(),r=t.__nowWorld;let i,s,o,l,{scaleX:d,scaleY:c}=r;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(r))l=a,i=o=r;else{const{renderShapeSpread:a}=t.__layout,h=T(a?C(e.bounds,d===c?a*d:[a*c,a*d]):e.bounds,r);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),o=A(r,s),i=O(o,-s.e,-s.f),n.matrix){const{matrix:t}=n;s.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:s.withScale(u,f)})}return t.__renderShape(a,n),{canvas:a,matrix:s,bounds:i,worldCanvas:l,shapeBounds:o,scaleX:d,scaleY:c}}};let F={};const{get:G,rotateOfOuter:j,translate:z,scaleOfOuter:U,scale:Y,rotate:q}=t.MatrixHelper;function N(t,e,n,a,r,i,s){const o=G();z(o,e.x+n,e.y+a),Y(o,r,i),s&&j(o,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=o}function X(t,e,n,a,r,i,s){const o=G();z(o,e.x+n,e.y+a),r&&Y(o,r,i),s&&q(o,s),t.transform=o}function V(t,e,n,a,r,i,s,o,l,d){const c=G();if(l)if("center"===d)j(c,{x:n/2,y:a/2},l);else switch(q(c,l),l){case 90:z(c,a,0);break;case 180:z(c,n,a);break;case 270:z(c,0,n)}F.x=e.x+r,F.y=e.y+i,z(c,F.x,F.y),s&&U(c,F,s,o),t.transform=c}const{get:Q,translate:Z}=t.MatrixHelper,K=new t.Bounds,$={},J={};function tt(t,e,n,a){const{changeful:r,sync:i}=n;r&&(t.changeful=r),i&&(t.sync=i),t.data=et(n,a,e)}function et(e,n,a){e.padding&&(n=K.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:r,height:i}=a;const{opacity:s,mode:o,align:l,offset:d,scale:c,size:h,rotation:u,repeat:f,filters:p}=e,g=n.width===r&&n.height===i,_={mode:o},m="center"!==l&&(u||0)%180==90;let y,w;switch(t.BoundsHelper.set(J,0,0,m?i:r,m?r:i),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,a,$),y=$.scaleX,w=$.scaleY),l&&(y&&t.BoundsHelper.scale(J,y,w,!0),t.AlignHelper.toPoint(l,J,n,J,!0,!0))):g&&!u||(y=w=t.BoundsHelper.getFitScale(n,J,"fit"!==o),t.BoundsHelper.put(n,a,l,y,!1,J),t.BoundsHelper.scale(J,y,w,!0)),d&&t.PointHelper.move(J,d),o){case"stretch":g||(r=n.width,i=n.height);break;case"normal":case"clip":(J.x||J.y||y||u)&&X(_,n,J.x,J.y,y,w,u);break;case"repeat":(!g||y||u)&&V(_,n,r,i,J.x,J.y,y,w,u,l),f||(_.repeat="repeat");break;default:y&&N(_,n,J.x,J.y,y,w,u)}return _.transform||(n.x||n.y)&&(_.transform=Q(),Z(_.transform,n.x,n.y)),y&&"stretch"!==o&&(_.scaleX=y,_.scaleY=w),_.width=r,_.height=i,s&&(_.opacity=s),p&&(_.filters=p),f&&(_.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat"),_}let nt,at=new t.Bounds;const{isSame:rt}=t.BoundsHelper;function it(t,e,n,a,r,i){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 r.data||tt(r,a,n,i),!0}function st(e,n){dt(e,t.ImageEvent.LOAD,n)}function ot(e,n){dt(e,t.ImageEvent.LOADED,n)}function lt(e,n,a){n.error=a,e.forceUpdate("surface"),dt(e,t.ImageEvent.ERROR,n)}function dt(e,n,a){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,a))}function ct(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ht,scale:ut,copy:ft}=t.MatrixHelper,{ceil:pt,abs:gt}=Math;function _t(e,n,a){let{scaleX:r,scaleY:i}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=r+"-"+i+"-"+a;if(n.patternId===s||e.destroyed)return!1;{r=gt(r),i=gt(i);const{image:e,data:o}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=o;u&&(d=ht(),ft(d,p),ut(d,1/u,1/f),r*=u,i*=f),r*=a,i*=a,c*=r,h*=i;const _=c*h;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}_>m&&(l=Math.sqrt(_/m)),l&&(r/=l,i/=l,c/=l,h/=l),u&&(r/=u,i/=f),(p||1!==r||1!==i)&&(d||(d=ht(),p&&ft(d,p)),ut(d,1/r,1/i));const y=e.getCanvas(pt(c)||1,pt(h)||1,o.opacity,o.filters),w=e.getPattern(y,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=w,n.patternId=s,!0}}function mt(t,e,n,a){return new(n||(n=Promise))((function(r,i){function s(t){try{l(a.next(t))}catch(t){i(t)}}function o(t){try{l(a.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,o)}l((a=a.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:yt}=Math;const wt={image:function(e,n,a,r,i){let s,o;const l=t.ImageManager.get(a);return nt&&a===nt.paint&&rt(r,nt.boxBounds)?s=nt.leafPaint:(s={type:a.type,image:l},l.hasAlphaPixel&&(s.isTransparent=!0),nt=l.use>1?{leafPaint:s,paint:a,boxBounds:at.set(r)}:null),(i||l.loading)&&(o={image:l,attrName:n,attrValue:a}),l.ready?(it(e,n,a,l,s,r),i&&(st(e,o),ot(e,o))):l.error?i&&lt(e,o,l.error):(i&&(ct(e,!0),st(e,o)),s.loadId=l.load((()=>{ct(e,!1),e.destroyed||(it(e,n,a,l,s,r)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),ot(e,o)),s.loadId=null}),(t=>{ct(e,!1),lt(e,o,t),s.loadId=null})),e.placeholderColor&&(e.placeholderDelay?setTimeout((()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))}),e.placeholderDelay):l.isPlacehold=!0)),s},checkImage:function(n,a,r,i){const{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=a,{data:d}=r;if(!d||r.patternId===s+"-"+o+"-"+l&&!e.Export.running)return!1;if(i)if(d.repeat)i=!1;else if(!(r.changeful||t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=yt(s)*l,n*=yt(o)*l,d.scaleX&&(e*=d.scaleX,n*=d.scaleY),i=e*n>t.Platform.image.maxCacheSize}return i?(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,r,d),!0):(!r.style||r.sync||e.Export.running?_t(n,r,l):r.patternTask||(r.patternTask=t.ImageManager.patternTasker.add((()=>mt(this,void 0,void 0,(function*(){r.patternTask=null,a.bounds.hit(n.__nowWorld)&&_t(n,r,l),n.forceUpdate("surface")}))),300)),!1)},createPattern:_t,recycleImage:function(e,n){const a=n["_"+e];if(a instanceof Array){let r,i,s,o,l;for(let d=0,c=a.length;d<c;d++)r=a[d],i=r.image,l=i&&i.url,l&&(s||(s={}),s[l]=!0,t.ImageManager.recycle(i),i.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),i.unload(a[d].loadId,!o.some((t=>t.url===l)))));return s}return null},createData:tt,getPatternData:et,fillOrFitMode:N,clipMode:X,repeatMode:V},{toPoint:vt}=t.AroundHelper,{hasTransparent:xt}=e.ColorConvert,bt={},Et={};function Bt(t,n,a,r){if(a){let i,s,o,l;for(let t=0,d=a.length;t<d;t++)i=a[t],"string"==typeof i?(o=t/(d-1),s=e.ColorConvert.string(i,r)):(o=i.offset,s=e.ColorConvert.string(i.color,r)),n.addColorStop(o,s),!l&&xt(s)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:Rt,getDistance:Lt}=t.PointHelper,{get:kt,rotateOfOuter:St,scaleOfOuter:Pt}=t.MatrixHelper,{toPoint:Ct}=t.AroundHelper,At={},Ot={};function Tt(t,e,n,a,r){let i;const{width:s,height:o}=t;if(s!==o||a){const t=Rt(e,n);i=kt(),r?(Pt(i,e,s/o*(a||1),1),St(i,e,t+90)):(Pt(i,e,1,s/o*(a||1)),St(i,e,t))}return i}const{getDistance:Wt}=t.PointHelper,{toPoint:It}=t.AroundHelper,Mt={},Dt={};const Ht={linearGradient:function(e,n){let{from:a,to:r,type:i,opacity:s}=e;vt(a||"top",n,bt),vt(r||"bottom",n,Et);const o=t.Platform.canvas.createLinearGradient(bt.x,bt.y,Et.x,Et.y),l={type:i,style:o};return Bt(l,o,e.stops,s),l},radialGradient:function(e,n){let{from:a,to:r,type:i,opacity:s,stretch:o}=e;Ct(a||"center",n,At),Ct(r||"bottom",n,Ot);const l=t.Platform.canvas.createRadialGradient(At.x,At.y,0,At.x,At.y,Lt(At,Ot)),d={type:i,style:l};Bt(d,l,e.stops,s);const c=Tt(n,At,Ot,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:a,to:r,type:i,opacity:s,stretch:o}=e;It(a||"center",n,Mt),It(r||"bottom",n,Dt);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Mt.x,Mt.y):t.Platform.canvas.createRadialGradient(Mt.x,Mt.y,0,Mt.x,Mt.y,Wt(Mt,Dt)),d={type:i,style:l};Bt(d,l,e.stops,s);const c=Tt(n,Mt,Dt,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Tt},{copy:Ft,toOffsetOutBounds:Gt}=t.BoundsHelper,jt={},zt={};function Ut(e,n,a,r){const{bounds:i,shapeBounds:s}=r;if(t.Platform.fullImageShadow){if(Ft(jt,e.bounds),jt.x+=n.x-s.x,jt.y+=n.y-s.y,a){const{matrix:t}=r;jt.x-=(i.x+(t?t.e:0)+i.width/2)*(a-1),jt.y-=(i.y+(t?t.f:0)+i.height/2)*(a-1),jt.width*=a,jt.height*=a}e.copyWorld(r.canvas,e.bounds,jt)}else a&&(Ft(jt,n),jt.x-=n.width/2*(a-1),jt.y-=n.height/2*(a-1),jt.width*=a,jt.height*=a),e.copyWorld(r.canvas,s,a?jt:n)}const{toOffsetOutBounds:Yt}=t.BoundsHelper,qt={};const Nt={shadow:function(t,n,a){let r,i;const{__nowWorld:s,__layout:o}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=a,p=n.getSameCanvas(),g=l.length-1;Gt(c,zt),l.forEach(((l,_)=>{p.setWorldShadow(zt.offsetX+l.x*u,zt.offsetY+l.y*f,l.blur*u,e.ColorConvert.string(l.color)),i=l.spread?1+2*l.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ut(p,zt,i,a),r=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,s,"copy"),r=s),d?p.copyWorld(d,s,s,"destination-out"):p.copyWorld(a.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,r,s,l.blendMode):n.copyWorldToInner(p,r,o.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(r,!0)})),p.recycle(r)},innerShadow:function(t,n,a){let r,i;const{__nowWorld:s,__layout:o}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=a,p=n.getSameCanvas(),g=l.length-1;Yt(c,qt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(qt.offsetX+l.x*u,qt.offsetY+l.y*f,l.blur*u),i=l.spread?1-2*l.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Ut(p,qt,i,a),p.restore(),d?(p.copyWorld(p,c,s,"copy"),p.copyWorld(d,s,s,"source-out"),r=s):(p.copyWorld(a.canvas,h,c,"source-out"),r=c),p.fillWorld(r,e.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,r,s,l.blendMode):n.copyWorldToInner(p,r,o.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(r,!0)})),p.recycle(r)},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:Xt}=t.LeafBoundsHelper;function Vt(t,e,n,a,r,i){switch(e){case"grayscale":r.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,a){const r=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(a,r),a.recycle(r),Zt(t,e,n,1)}(t,n,a,r);break;case"opacity-path":Zt(t,n,a,i);break;case"path":n.restore()}}function Qt(t){return t.getSameCanvas(!1,!0)}function Zt(t,e,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(n,r),n.recycle(r)}e.Group.prototype.__renderMask=function(t,e){let n,a,r,i,s,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],o=n.__.mask,o&&(s&&(Vt(this,s,t,r,a,i),a=r=null),"path"===o||"clipping-path"===o?(n.opacity<1?(s="opacity-path",i=n.opacity,r||(r=Qt(t))):(s="path",t.save()),n.__clip(r||t,e)):(s="grayscale"===o?"grayscale":"alpha",a||(a=Qt(t)),r||(r=Qt(t)),n.__render(a,e)),"clipping"!==o&&"clipping-path"!==o)||Xt(n,e)||n.__render(r||t,e);Vt(this,s,t,r,a,i)};const Kt=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",$t=Kt+"_#~&*+\\=|≮≯≈≠=…",Jt=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 te(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ee=te("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ne=te("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ae=te(Kt),re=te($t),ie=te("- —/~|┆·");var se;!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"}(se||(se={}));const{Letter:oe,Single:le,Before:de,After:ce,Symbol:he,Break:ue}=se;function fe(t){return ee[t]?oe:ie[t]?ue:ne[t]?de:ae[t]?ce:re[t]?he:Jt.test(t)?le:oe}const pe={trimRight(t){const{words:e}=t;let n,a=0,r=e.length;for(let i=r-1;i>-1&&(n=e[i].data[0]," "===n.char);i--)a++,t.width-=n.width;a&&e.splice(r-a,a)}};function ge(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:_e}=pe,{Letter:me,Single:ye,Before:we,After:ve,Symbol:xe,Break:be}=se;let Ee,Be,Re,Le,ke,Se,Pe,Ce,Ae,Oe,Te,We,Ie,Me,De,He,Fe,Ge=[];function je(t,e){Ae&&!Ce&&(Ce=Ae),Ee.data.push({char:t,width:e}),Re+=e}function ze(){Le+=Re,Ee.width=Re,Be.words.push(Ee),Ee={data:[]},Re=0}function Ue(){Me&&(De.paraNumber++,Be.paraStart=!0,Me=!1),Ae&&(Be.startCharSize=Ce,Be.endCharSize=Ae,Ce=0),Be.width=Le,He.width?_e(Be):Fe&&Ye(),Ge.push(Be),Be={words:[]},Le=0}function Ye(){Le>(De.maxWidth||0)&&(De.maxWidth=Le)}const{top:qe,right:Ne,bottom:Xe,left:Ve}=t.Direction4;function Qe(t,e,n){const{bounds:a,rows:r}=t;a[e]+=n;for(let t=0;t<r.length;t++)r[t][e]+=n}const Ze={getDrawData:function(n,a){"string"!=typeof n&&(n=String(n));let r=0,i=0,s=a.__getInput("width")||0,o=a.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=a;c&&(s?(r=c[Ve],s-=c[Ne]+c[Ve]):a.autoSizeAlign||(r=c[Ve]),o?(i=c[qe],o-=c[qe]+c[Xe]):a.autoSizeAlign||(i=c[qe]));const h={bounds:{x:r,y:i,width:s,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,a){De=e,Ge=e.rows,He=e.bounds,Fe=!He.width&&!a.autoSizeAlign;const{__letterSpacing:r,paraIndent:i,textCase:s}=a,{canvas:o}=t.Platform,{width:l,height:d}=He;if(l||d||r||"none"!==s){const t="none"!==a.textWrap,e="break"===a.textWrap;Me=!0,Te=null,Ce=Pe=Ae=Re=Le=0,Ee={data:[]},Be={words:[]},r&&(n=[...n]);for(let a=0,d=n.length;a<d;a++)Se=n[a],"\n"===Se?(Re&&ze(),Be.paraEnd=!0,Ue(),Me=!0):(Oe=fe(Se),Oe===me&&"none"!==s&&(Se=ge(Se,s,!Re)),Pe=o.measureText(Se).width,r&&(r<0&&(Ae=Pe),Pe+=r),We=Oe===ye&&(Te===ye||Te===me)||Te===ye&&Oe!==ve,Ie=!(Oe!==we&&Oe!==ye||Te!==xe&&Te!==ve),ke=Me&&i?l-i:l,t&&l&&Le+Re+Pe>ke&&(e?(Re&&ze(),Le&&Ue()):(Ie||(Ie=Oe===me&&Te==ve),We||Ie||Oe===be||Oe===we||Oe===ye||Re+Pe>ke?(Re&&ze(),Le&&Ue()):Le&&Ue()))," "===Se&&!0!==Me&&Le+Re===0||(Oe===be?(" "===Se&&Re&&ze(),je(Se,Pe),ze()):We||Ie?(Re&&ze(),je(Se,Pe)):je(Se,Pe)),Te=Oe);Re&&ze(),Le&&Ue(),Ge.length>0&&(Ge[Ge.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{De.paraNumber++,Le=o.measureText(t).width,Ge.push({x:i||0,text:t,width:Le,paraStart:!0}),Fe&&Ye()}))}(h,n,a),c&&function(t,e,n,a,r){if(!a&&n.autoSizeAlign)switch(n.textAlign){case"left":Qe(e,"x",t[Ve]);break;case"right":Qe(e,"x",-t[Ne])}if(!r&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Qe(e,"y",t[qe]);break;case"bottom":Qe(e,"y",-t[Xe])}}(c,h,a,s,o),function(t,e){const{rows:n,bounds:a}=t,r=n.length,{__lineHeight:i,__baseLine:s,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=a,m=i*r+(h?h*(t.paraNumber-1):0),y=s;if(l&&m>_)m=Math.max(_,i),r>1&&(t.overflow=r);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 s=0,c=r;s<c;s++){if(w=n[s],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&&s>0&&(y+=h),w.y=y,y+=i,t.overflow>s&&y>m&&(w.isOverflow=!0,t.overflow=s+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:r,paraIndent:i,letterSpacing:s}=e;let o,l,d,c,h,u;a.forEach((t=>{t.words&&(d=i&&t.paraStart?i:0,u=t.words.length,l=n&&("justify"===r||"both"===r)&&u>1?(n-t.width-d)/(u-1):0,c=s||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!s&&(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"!==r||n===u-1||(o+=l,t.width+=l)}))),t.words=null)}))}(h,a,s),h.overflow&&function(e,n,a,r){if(!r)return;const{rows:i,overflow:s}=e;let{textOverflow:o}=n;if(i.splice(s),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=a+r-d;("none"===n.textWrap?i:[i[s-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,r,s),"none"!==l&&function(t,n){let a;const{fontSize:r,textDecoration:i}=n;switch(t.decorationHeight=r/11,"object"==typeof i?(a=i.type,i.color&&(t.decorationColor=e.ColorConvert.string(i.color))):a=i,a){case"under":t.decorationY=[.15*r];break;case"delete":t.decorationY=[.35*-r];break;case"under-delete":t.decorationY=[.15*r,.35*-r]}}(h,a),h}};const Ke={string:function(t,n){const a="number"==typeof n&&1!==n;if("string"==typeof t){if(!a||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let r=void 0===t.a?1:t.a;a&&(r*=n);const i=t.r+","+t.g+","+t.b;return 1===r?"rgb("+i+")":"rgba("+i+","+r+")"}};Object.assign(e.TextConvert,Ze),Object.assign(e.ColorConvert,Ke),Object.assign(e.Paint,H),Object.assign(e.PaintImage,wt),Object.assign(e.PaintGradient,Ht),Object.assign(e.Effect,Nt),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=w,exports.Watcher=s,exports.useCanvas=r,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
1
+ "use strict";var t=require("@leafer/core"),e=require("@leafer-ui/draw");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 r(e,n){t.Platform.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,n)=>new Promise(((r,i)=>{t.convertToBlob({type:a(e),quality:n}).then((t=>{var e=new FileReader;e.onload=t=>r(t.target.result),e.onerror=t=>i(t),e.readAsDataURL(t)})).catch((t=>{i(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 r=new XMLHttpRequest;r.open("GET",t.Platform.image.getRealURL(e),!0),r.responseType="blob",r.onload=()=>{createImageBitmap(r.response).then((t=>{n(t)})).catch((t=>{a(t)}))},r.onerror=t=>a(t),r.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:i}=navigator;i.indexOf("Firefox")>-1?(t.Platform.conicGradientRotate90=!0,t.Platform.intWheelDeltaY=!0):i.indexOf("Safari")>-1&&-1===i.indexOf("Chrome")&&(t.Platform.fullImageShadow=!0),i.indexOf("Windows")>-1?(t.Platform.os="Windows",t.Platform.intWheelDeltaY=!0):i.indexOf("Mac")>-1?t.Platform.os="Mac":i.indexOf("Linux")>-1&&(t.Platform.os="Linux");class s{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,e instanceof Array&&(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:r}=this,{BEFORE:i,LAYOUT:s,AFTER:u}=t.LayoutEvent,f=this.getBlocks(r);f.forEach((t=>t.setBefore())),a.emitEvent(new t.LayoutEvent(i,f,this.times)),this.extraBlock=null,r.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)))}))}(r,this.__levelList),function(t){let e,n,a;t.sort(!0),t.levels.forEach((r=>{e=t.levelMap[r];for(let t=0,r=e.length;t<r;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)}(r),this.extraBlock&&f.push(this.extraBlock),f.forEach((t=>t.setAfter())),a.emitEvent(new t.LayoutEvent(s,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:r,AFTER:i}=t.LayoutEvent,s=this.getBlocks(new t.LeafList(n));n.emitEvent(new t.LayoutEvent(a,s,this.times)),m.fullLayout(n),s.forEach((t=>{t.setAfter()})),n.emitEvent(new t.LayoutEvent(r,s,this.times)),n.emitEvent(new t.LayoutEvent(i,s,this.times)),this.addBlocks(s),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:60},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,r=e.getIntersect(a.bounds),i=new t.Bounds(r);a.save(),r.spread(w.clipSpread).ceil(),a.clearWorld(r,!0),a.clipWorld(r,!0),this.__render(r,i),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,r=e.includes(this.target.__world),i=r?{includes:r}:{bounds:e,includes:r};this.needFill&&a.fillWorld(e,this.config.fill),t.Debug.showRepaint&&t.Debug.drawRepaint(a,e),this.target.__render(a,i),this.renderBounds=n=n||e,this.renderOptions=i,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();t.Platform.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-n))),this.requestTime=0,this.checkRender()}))}__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.target=this.canvas=this.config=null)}}function v(t,e){const n=t.__,{rows:a,decorationY:r}=n.__textDrawData;let i;n.__isPlacehold&&n.placeholderColor&&(e.fillStyle=n.placeholderColor);for(let t=0,n=a.length;t<n;t++)i=a[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)}));if(r){const{decorationColor:t,decorationHeight:i}=n.__textDrawData;t&&(e.fillStyle=t),a.forEach((t=>r.forEach((n=>e.fillRect(t.x,t.y+n,t.width,i)))))}}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(t,e,n,a){const r=n.__;a.setStroke(!r.__isStrokes&&t,r.strokeWidth*e,r),r.__isStrokes?k(t,!0,n,a):L(n,a)}function B(t,e,n,a){const r=a.getSameCanvas(!0,!0);r.font=n.__.__font,E(t,2,n,r),r.blendMode="outside"===e?"destination-out":"destination-in",v(n,r),r.blendMode="normal",R(a,r,n),r.recycle(n.__nowWorld)}function R(e,n,a){a.__worldFlipped||t.Platform.fullImageShadow?e.copyWorldByReset(n,a.__nowWorld):e.copyWorldToInner(n,a.__nowWorld,a.__layout.renderBounds)}function L(t,e){let n,a=t.__.__textDrawData;const{rows:r,decorationY:i}=a;for(let t=0,a=r.length;t<a;t++)n=r[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(i){const{decorationHeight:t}=a;r.forEach((n=>i.forEach((a=>e.strokeRect(n.x,n.y+a,n.width,t)))))}}function k(t,n,a,r){let i;for(let s=0,o=t.length;s<o;s++)i=t[s],i.image&&e.PaintImage.checkImage(a,r,i,!1)||i.style&&(r.strokeStyle=i.style,i.blendMode?(r.saveBlendMode(i.blendMode),n?L(a,r):r.stroke(),r.restoreBlendMode()):n?L(a,r):r.stroke())}function S(t,e,n){const a=e.__;if(a.__strokeWidth)if(a.__font)b(t,e,n);else switch(a.strokeAlign){case"center":P(t,1,e,n);break;case"inside":!function(t,e,n){n.save(),n.clipUI(e),P(t,2,e,n),n.restore()}(t,e,n);break;case"outside":!function(t,e,n){const a=e.__;if(a.__fillAfterStroke)P(t,2,e,n);else{const{renderBounds:r}=e.__layout,i=n.getSameCanvas(!0,!0);e.__drawRenderPath(i),P(t,2,e,i),i.clipUI(a),i.clearWorld(r),R(n,i,e),i.recycle(e.__nowWorld)}}(t,e,n)}}function P(t,n,a,r){const i=a.__;r.setStroke(!i.__isStrokes&&t,i.__strokeWidth*n,i),i.__isStrokes?k(t,!1,a,r):r.stroke(),i.__useArrow&&e.Paint.strokeArrow(t,a,r)}w.clipSpread=10,Object.assign(t.Creator,{watcher:(t,e)=>new s(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:C,getOuterOf:A,getByMove:O,getIntersectData:T}=t.BoundsHelper;let W;const{stintSet:I}=t.DataHelper,{hasTransparent:M}=e.ColorConvert;function D(t,n,a){if("object"!=typeof n||!1===n.visible||0===n.opacity)return;let r;const{boxBounds:i}=a.__layout;switch(n.type){case"image":r=e.PaintImage.image(a,t,n,i,!W||!W[n.url]);break;case"linear":r=e.PaintGradient.linearGradient(n,i);break;case"radial":r=e.PaintGradient.radialGradient(n,i);break;case"angular":r=e.PaintGradient.conicGradient(n,i);break;case"solid":const{type:s,color:o,opacity:l}=n;r={type:s,style:e.ColorConvert.string(o,l)};break;default:void 0!==n.r&&(r={type:"solid",style:e.ColorConvert.string(n)})}return r&&("string"==typeof r.style&&M(r.style)&&(r.isTransparent=!0),n.blendMode&&(r.blendMode=n.blendMode)),r}const H={compute:function(t,n){const a=n.__,r=[];let i,s,o=a.__input[t];o instanceof Array||(o=[o]),W=e.PaintImage.recycleImage(t,a);for(let e,a=0,i=o.length;a<i;a++)(e=D(t,o[a],n))&&r.push(e);a["_"+t]=r.length?r:void 0,r.length&&r.every((t=>t.isTransparent))&&(r.some((t=>t.image))&&(i=!0),s=!0),"fill"===t?(I(a,"__isAlphaPixelFill",i),I(a,"__isTransparentFill",s)):(I(a,"__isAlphaPixelStroke",i),I(a,"__isTransparentStroke",s))},fill:function(t,e,n){n.fillStyle=t,x(e,n)},fills:function(t,n,a){let r;for(let i=0,s=t.length;i<s;i++){if(r=t[i],r.image){if(e.PaintImage.checkImage(n,a,r,!n.__.__font))continue;if(!r.style){!i&&r.image.isPlacehold&&n.drawImagePlaceholder(a,r.image);continue}}a.fillStyle=r.style,r.transform?(a.save(),a.transform(r.transform),r.blendMode&&(a.blendMode=r.blendMode),x(n,a),a.restore()):r.blendMode?(a.saveBlendMode(r.blendMode),x(n,a),a.restoreBlendMode()):x(n,a)}},fillPathOrText:x,fillText:v,stroke:S,strokes:function(t,e,n){S(t,e,n)},strokeText:b,drawTextStroke:L,shape:function(t,e,n){const a=e.getSameCanvas(),r=t.__nowWorld;let i,s,o,l,{scaleX:d,scaleY:c}=r;if(d<0&&(d=-d),c<0&&(c=-c),e.bounds.includes(r))l=a,i=o=r;else{const{renderShapeSpread:a}=t.__layout,h=T(a?C(e.bounds,d===c?a*d:[a*c,a*d]):e.bounds,r);s=e.bounds.getFitMatrix(h);let{a:u,d:f}=s;if(s.a<1&&(l=e.getSameCanvas(),t.__renderShape(l,n),d*=u,c*=f),o=A(r,s),i=O(o,-s.e,-s.f),n.matrix){const{matrix:t}=n;s.multiply(t),u*=t.scaleX,f*=t.scaleY}n=Object.assign(Object.assign({},n),{matrix:s.withScale(u,f)})}return t.__renderShape(a,n),{canvas:a,matrix:s,bounds:i,worldCanvas:l,shapeBounds:o,scaleX:d,scaleY:c}}};let F={};const{get:G,rotateOfOuter:j,translate:z,scaleOfOuter:U,scale:Y,rotate:q,skew:N}=t.MatrixHelper;function X(t,e,n,a,r,i,s){const o=G();z(o,e.x+n,e.y+a),Y(o,r,i),s&&j(o,{x:e.x+e.width/2,y:e.y+e.height/2},s),t.transform=o}function V(t,e,n,a,r,i,s,o){const l=G();s&&q(l,s),o&&N(l,o.x,o.y),r&&Y(l,r,i),z(l,e.x+n,e.y+a),t.transform=l}function Q(t,e,n,a,r,i,s,o,l,d){const c=G();if(l)if("center"===d)j(c,{x:n/2,y:a/2},l);else switch(q(c,l),l){case 90:z(c,a,0);break;case 180:z(c,n,a);break;case 270:z(c,0,n)}F.x=e.x+r,F.y=e.y+i,z(c,F.x,F.y),s&&U(c,F,s,o),t.transform=c}const{get:Z,translate:K}=t.MatrixHelper,$=new t.Bounds,J={},tt={};function et(t,e,n,a){const{changeful:r,sync:i,editing:s}=n;r&&(t.changeful=r),i&&(t.sync=i),s&&(t.editing=s),t.data=nt(n,a,e)}function nt(e,n,a){e.padding&&(n=$.set(n).shrink(e.padding)),"strench"===e.mode&&(e.mode="stretch");let{width:r,height:i}=a;const{opacity:s,mode:o,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,repeat:p,filters:g}=e,_=n.width===r&&n.height===i,m={mode:o},y="center"!==l&&(u||0)%180==90;let w,v;switch(t.BoundsHelper.set(tt,0,0,y?i:r,y?r:i),o&&"cover"!==o&&"fit"!==o?((c||h)&&(t.MathHelper.getScaleData(c,h,a,J),w=J.scaleX,v=J.scaleY),l&&(w&&t.BoundsHelper.scale(tt,w,v,!0),t.AlignHelper.toPoint(l,tt,n,tt,!0,!0))):_&&!u||(w=v=t.BoundsHelper.getFitScale(n,tt,"fit"!==o),t.BoundsHelper.put(n,a,l,w,!1,tt),t.BoundsHelper.scale(tt,w,v,!0)),d&&t.PointHelper.move(tt,d),o){case"stretch":_||(r=n.width,i=n.height);break;case"normal":case"clip":(tt.x||tt.y||w||u||f)&&V(m,n,tt.x,tt.y,w,v,u,f);break;case"repeat":(!_||w||u)&&Q(m,n,r,i,tt.x,tt.y,w,v,u,l),p||(m.repeat="repeat");break;default:w&&X(m,n,tt.x,tt.y,w,v,u)}return m.transform||(n.x||n.y)&&(m.transform=Z(),K(m.transform,n.x,n.y)),w&&"stretch"!==o&&(m.scaleX=w,m.scaleY=v),m.width=r,m.height=i,s&&(m.opacity=s),g&&(m.filters=g),p&&(m.repeat="string"==typeof p?"x"===p?"repeat-x":"repeat-y":"repeat"),m}let at,rt=new t.Bounds;const{isSame:it}=t.BoundsHelper;function st(t,e,n,a,r,i){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 r.data||et(r,a,n,i),!0}function ot(e,n){ct(e,t.ImageEvent.LOAD,n)}function lt(e,n){ct(e,t.ImageEvent.LOADED,n)}function dt(e,n,a){n.error=a,e.forceUpdate("surface"),ct(e,t.ImageEvent.ERROR,n)}function ct(e,n,a){e.hasEvent(n)&&e.emitEvent(new t.ImageEvent(n,a))}function ht(t,e){const{leafer:n}=t;n&&n.viewReady&&(n.renderer.ignore=e)}const{get:ut,scale:ft,copy:pt}=t.MatrixHelper,{ceil:gt,abs:_t}=Math;function mt(e,n,a){let{scaleX:r,scaleY:i}=t.ImageManager.patternLocked?e.__world:e.__nowWorld;const s=r+"-"+i+"-"+a;if(n.patternId===s||e.destroyed)return!1;{r=_t(r),i=_t(i);const{image:e,data:o}=n;let l,d,{width:c,height:h,scaleX:u,scaleY:f,transform:p,repeat:g}=o;u&&(u=_t(u),f=_t(f),d=ut(),pt(d,p),ft(d,1/u,1/f),r*=u,i*=f),r*=a,i*=a,c*=r,h*=i;const _=c*h;if(!g&&_>t.Platform.image.maxCacheSize)return!1;let m=t.Platform.image.maxPatternSize;if(!e.isSVG){const t=e.width*e.height;m>t&&(m=t)}_>m&&(l=Math.sqrt(_/m)),l&&(r/=l,i/=l,c/=l,h/=l),u&&(r/=u,i/=f),(p||1!==r||1!==i)&&(d||(d=ut(),p&&pt(d,p)),ft(d,1/r,1/i));const y=e.getCanvas(gt(c)||1,gt(h)||1,o.opacity,o.filters),w=e.getPattern(y,g||t.Platform.origin.noRepeat||"no-repeat",d,n);return n.style=w,n.patternId=s,!0}}function yt(t,e,n,a){return new(n||(n=Promise))((function(r,i){function s(t){try{l(a.next(t))}catch(t){i(t)}}function o(t){try{l(a.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,o)}l((a=a.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const{abs:wt}=Math;const vt={image:function(e,n,a,r,i){let s,o;const l=t.ImageManager.get(a);return at&&a===at.paint&&it(r,at.boxBounds)?s=at.leafPaint:(s={type:a.type,image:l},l.hasAlphaPixel&&(s.isTransparent=!0),at=l.use>1?{leafPaint:s,paint:a,boxBounds:rt.set(r)}:null),(i||l.loading)&&(o={image:l,attrName:n,attrValue:a}),l.ready?(st(e,n,a,l,s,r),i&&(ot(e,o),lt(e,o))):l.error?i&&dt(e,o,l.error):(i&&(ht(e,!0),ot(e,o)),s.loadId=l.load((()=>{ht(e,!1),e.destroyed||(st(e,n,a,l,s,r)&&(l.hasAlphaPixel&&(e.__layout.hitCanvasChanged=!0),e.forceUpdate("surface")),lt(e,o)),s.loadId=void 0}),(t=>{ht(e,!1),dt(e,o,t),s.loadId=void 0})),e.placeholderColor&&(e.placeholderDelay?setTimeout((()=>{l.ready||(l.isPlacehold=!0,e.forceUpdate("surface"))}),e.placeholderDelay):l.isPlacehold=!0)),s},checkImage:function(n,a,r,i){const{scaleX:s,scaleY:o}=t.ImageManager.patternLocked?n.__world:n.__nowWorld,{pixelRatio:l}=a,{data:d}=r;if(!d||r.patternId===s+"-"+o+"-"+l&&!e.Export.running)return!1;if(i)if(d.repeat)i=!1;else if(!(r.changeful||t.ResizeEvent.isResizing(n)||e.Export.running)){let{width:e,height:n}=d;e*=wt(s)*l,n*=wt(o)*l,d.scaleX&&(e*=d.scaleX,n*=d.scaleY),i=e*n>t.Platform.image.maxCacheSize}return i?(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,r,d),!0):(!r.style||r.sync||e.Export.running?mt(n,r,l):r.patternTask||(r.patternTask=t.ImageManager.patternTasker.add((()=>yt(this,void 0,void 0,(function*(){r.patternTask=null,a.bounds.hit(n.__nowWorld)&&mt(n,r,l),n.forceUpdate("surface")}))),300)),!1)},createPattern:mt,recycleImage:function(e,n){const a=n["_"+e];if(a instanceof Array){let r,i,s,o,l;for(let d=0,c=a.length;d<c;d++)r=a[d],i=r.image,l=i&&i.url,l&&(s||(s={}),s[l]=!0,t.ImageManager.recycle(i),i.loading&&(o||(o=n.__input&&n.__input[e]||[],o instanceof Array||(o=[o])),i.unload(a[d].loadId,!o.some((t=>t.url===l)))));return s}return null},createData:et,getPatternData:nt,fillOrFitMode:X,clipMode:V,repeatMode:Q},{toPoint:xt}=t.AroundHelper,{hasTransparent:bt}=e.ColorConvert,Et={},Bt={};function Rt(t,n,a,r){if(a){let i,s,o,l;for(let t=0,d=a.length;t<d;t++)i=a[t],"string"==typeof i?(o=t/(d-1),s=e.ColorConvert.string(i,r)):(o=i.offset,s=e.ColorConvert.string(i.color,r)),n.addColorStop(o,s),!l&&bt(s)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:Lt,getDistance:kt}=t.PointHelper,{get:St,rotateOfOuter:Pt,scaleOfOuter:Ct}=t.MatrixHelper,{toPoint:At}=t.AroundHelper,Ot={},Tt={};function Wt(t,e,n,a,r){let i;const{width:s,height:o}=t;if(s!==o||a){const t=Lt(e,n);i=St(),r?(Ct(i,e,s/o*(a||1),1),Pt(i,e,t+90)):(Ct(i,e,1,s/o*(a||1)),Pt(i,e,t))}return i}const{getDistance:It}=t.PointHelper,{toPoint:Mt}=t.AroundHelper,Dt={},Ht={};const Ft={linearGradient:function(e,n){let{from:a,to:r,type:i,opacity:s}=e;xt(a||"top",n,Et),xt(r||"bottom",n,Bt);const o=t.Platform.canvas.createLinearGradient(Et.x,Et.y,Bt.x,Bt.y),l={type:i,style:o};return Rt(l,o,e.stops,s),l},radialGradient:function(e,n){let{from:a,to:r,type:i,opacity:s,stretch:o}=e;At(a||"center",n,Ot),At(r||"bottom",n,Tt);const l=t.Platform.canvas.createRadialGradient(Ot.x,Ot.y,0,Ot.x,Ot.y,kt(Ot,Tt)),d={type:i,style:l};Rt(d,l,e.stops,s);const c=Wt(n,Ot,Tt,o,!0);return c&&(d.transform=c),d},conicGradient:function(e,n){let{from:a,to:r,type:i,opacity:s,stretch:o}=e;Mt(a||"center",n,Dt),Mt(r||"bottom",n,Ht);const l=t.Platform.conicGradientSupport?t.Platform.canvas.createConicGradient(0,Dt.x,Dt.y):t.Platform.canvas.createRadialGradient(Dt.x,Dt.y,0,Dt.x,Dt.y,It(Dt,Ht)),d={type:i,style:l};Rt(d,l,e.stops,s);const c=Wt(n,Dt,Ht,o||1,t.Platform.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Wt},{copy:Gt,toOffsetOutBounds:jt}=t.BoundsHelper,zt={},Ut={};function Yt(e,n,a,r){const{bounds:i,shapeBounds:s}=r;if(t.Platform.fullImageShadow){if(Gt(zt,e.bounds),zt.x+=n.x-s.x,zt.y+=n.y-s.y,a){const{matrix:t}=r;zt.x-=(i.x+(t?t.e:0)+i.width/2)*(a-1),zt.y-=(i.y+(t?t.f:0)+i.height/2)*(a-1),zt.width*=a,zt.height*=a}e.copyWorld(r.canvas,e.bounds,zt)}else a&&(Gt(zt,n),zt.x-=n.width/2*(a-1),zt.y-=n.height/2*(a-1),zt.width*=a,zt.height*=a),e.copyWorld(r.canvas,s,a?zt:n)}const{toOffsetOutBounds:qt}=t.BoundsHelper,Nt={};const Xt={shadow:function(t,n,a){let r,i;const{__nowWorld:s,__layout:o}=t,{shadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=a,p=n.getSameCanvas(),g=l.length-1;jt(c,Ut),l.forEach(((l,_)=>{p.setWorldShadow(Ut.offsetX+l.x*u,Ut.offsetY+l.y*f,l.blur*u,e.ColorConvert.string(l.color)),i=l.spread?1+2*l.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Yt(p,Ut,i,a),r=c,l.box&&(p.restore(),p.save(),d&&(p.copyWorld(p,c,s,"copy"),r=s),d?p.copyWorld(d,s,s,"destination-out"):p.copyWorld(a.canvas,h,c,"destination-out")),t.__worldFlipped?n.copyWorldByReset(p,r,s,l.blendMode):n.copyWorldToInner(p,r,o.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(r,!0)})),p.recycle(r)},innerShadow:function(t,n,a){let r,i;const{__nowWorld:s,__layout:o}=t,{innerShadow:l}=t.__,{worldCanvas:d,bounds:c,shapeBounds:h,scaleX:u,scaleY:f}=a,p=n.getSameCanvas(),g=l.length-1;qt(c,Nt),l.forEach(((l,_)=>{p.save(),p.setWorldShadow(Nt.offsetX+l.x*u,Nt.offsetY+l.y*f,l.blur*u),i=l.spread?1-2*l.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,Yt(p,Nt,i,a),p.restore(),d?(p.copyWorld(p,c,s,"copy"),p.copyWorld(d,s,s,"source-out"),r=s):(p.copyWorld(a.canvas,h,c,"source-out"),r=c),p.fillWorld(r,e.ColorConvert.string(l.color),"source-in"),t.__worldFlipped?n.copyWorldByReset(p,r,s,l.blendMode):n.copyWorldToInner(p,r,o.renderBounds,l.blendMode),g&&_<g&&p.clearWorld(r,!0)})),p.recycle(r)},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:Vt}=t.LeafBoundsHelper;function Qt(t,e,n,a,r,i){switch(e){case"grayscale":r.useGrayscaleAlpha(t.__nowWorld);case"alpha":!function(t,e,n,a){const r=t.__nowWorld;n.resetTransform(),n.opacity=1,n.useMask(a,r),a.recycle(r),Kt(t,e,n,1)}(t,n,a,r);break;case"opacity-path":Kt(t,n,a,i);break;case"path":n.restore()}}function Zt(t){return t.getSameCanvas(!1,!0)}function Kt(t,e,n,a){const r=t.__nowWorld;e.resetTransform(),e.opacity=a,e.copyWorld(n,r),n.recycle(r)}e.Group.prototype.__renderMask=function(t,e){let n,a,r,i,s,o;const{children:l}=this;for(let d=0,c=l.length;d<c;d++)n=l[d],o=n.__.mask,o&&(s&&(Qt(this,s,t,r,a,i),a=r=null),"path"===o||"clipping-path"===o?(n.opacity<1?(s="opacity-path",i=n.opacity,r||(r=Zt(t))):(s="path",t.save()),n.__clip(r||t,e)):(s="grayscale"===o?"grayscale":"alpha",a||(a=Zt(t)),r||(r=Zt(t)),n.__render(a,e)),"clipping"!==o&&"clipping-path"!==o)||Vt(n,e)||n.__render(r||t,e);Qt(this,s,t,r,a,i)};const $t=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Jt=$t+"_#~&*+\\=|≮≯≈≠=…",te=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 ee(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ne=ee("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),ae=ee("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),re=ee($t),ie=ee(Jt),se=ee("- —/~|┆·");var oe;!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"}(oe||(oe={}));const{Letter:le,Single:de,Before:ce,After:he,Symbol:ue,Break:fe}=oe;function pe(t){return ne[t]?le:se[t]?fe:ae[t]?ce:re[t]?he:ie[t]?ue:te.test(t)?de:le}const ge={trimRight(t){const{words:e}=t;let n,a=0,r=e.length;for(let i=r-1;i>-1&&(n=e[i].data[0]," "===n.char);i--)a++,t.width-=n.width;a&&e.splice(r-a,a)}};function _e(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:me}=ge,{Letter:ye,Single:we,Before:ve,After:xe,Symbol:be,Break:Ee}=oe;let Be,Re,Le,ke,Se,Pe,Ce,Ae,Oe,Te,We,Ie,Me,De,He,Fe,Ge,je=[];function ze(t,e){Oe&&!Ae&&(Ae=Oe),Be.data.push({char:t,width:e}),Le+=e}function Ue(){ke+=Le,Be.width=Le,Re.words.push(Be),Be={data:[]},Le=0}function Ye(){De&&(He.paraNumber++,Re.paraStart=!0,De=!1),Oe&&(Re.startCharSize=Ae,Re.endCharSize=Oe,Ae=0),Re.width=ke,Fe.width?me(Re):Ge&&qe(),je.push(Re),Re={words:[]},ke=0}function qe(){ke>(He.maxWidth||0)&&(He.maxWidth=ke)}const{top:Ne,right:Xe,bottom:Ve,left:Qe}=t.Direction4;function Ze(t,e,n){const{bounds:a,rows:r}=t;a[e]+=n;for(let t=0;t<r.length;t++)r[t][e]+=n}const Ke={getDrawData:function(n,a){"string"!=typeof n&&(n=String(n));let r=0,i=0,s=a.__getInput("width")||0,o=a.__getInput("height")||0;const{textDecoration:l,__font:d,__padding:c}=a;c&&(s?(r=c[Qe],s-=c[Xe]+c[Qe]):a.autoSizeAlign||(r=c[Qe]),o?(i=c[Ne],o-=c[Ne]+c[Ve]):a.autoSizeAlign||(i=c[Ne]));const h={bounds:{x:r,y:i,width:s,height:o},rows:[],paraNumber:0,font:t.Platform.canvas.font=d};return function(e,n,a){He=e,je=e.rows,Fe=e.bounds,Ge=!Fe.width&&!a.autoSizeAlign;const{__letterSpacing:r,paraIndent:i,textCase:s}=a,{canvas:o}=t.Platform,{width:l,height:d}=Fe;if(l||d||r||"none"!==s){const t="none"!==a.textWrap,e="break"===a.textWrap;De=!0,We=null,Ae=Ce=Oe=Le=ke=0,Be={data:[]},Re={words:[]},r&&(n=[...n]);for(let a=0,d=n.length;a<d;a++)Pe=n[a],"\n"===Pe?(Le&&Ue(),Re.paraEnd=!0,Ye(),De=!0):(Te=pe(Pe),Te===ye&&"none"!==s&&(Pe=_e(Pe,s,!Le)),Ce=o.measureText(Pe).width,r&&(r<0&&(Oe=Ce),Ce+=r),Ie=Te===we&&(We===we||We===ye)||We===we&&Te!==xe,Me=!(Te!==ve&&Te!==we||We!==be&&We!==xe),Se=De&&i?l-i:l,t&&l&&ke+Le+Ce>Se&&(e?(Le&&Ue(),ke&&Ye()):(Me||(Me=Te===ye&&We==xe),Ie||Me||Te===Ee||Te===ve||Te===we||Le+Ce>Se?(Le&&Ue(),ke&&Ye()):ke&&Ye()))," "===Pe&&!0!==De&&ke+Le===0||(Te===Ee?(" "===Pe&&Le&&Ue(),ze(Pe,Ce),Ue()):Ie||Me?(Le&&Ue(),ze(Pe,Ce)):ze(Pe,Ce)),We=Te);Le&&Ue(),ke&&Ye(),je.length>0&&(je[je.length-1].paraEnd=!0)}else n.split("\n").forEach((t=>{He.paraNumber++,ke=o.measureText(t).width,je.push({x:i||0,text:t,width:ke,paraStart:!0}),Ge&&qe()}))}(h,n,a),c&&function(t,e,n,a,r){if(!a&&n.autoSizeAlign)switch(n.textAlign){case"left":Ze(e,"x",t[Qe]);break;case"right":Ze(e,"x",-t[Xe])}if(!r&&n.autoSizeAlign)switch(n.verticalAlign){case"top":Ze(e,"y",t[Ne]);break;case"bottom":Ze(e,"y",-t[Ve])}}(c,h,a,s,o),function(t,e){const{rows:n,bounds:a}=t,r=n.length,{__lineHeight:i,__baseLine:s,__letterSpacing:o,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=a,m=i*r+(h?h*(t.paraNumber-1):0),y=s;if(l&&m>_)m=Math.max(_,i),r>1&&(t.overflow=r);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 s=0,c=r;s<c;s++){if(w=n[s],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&&s>0&&(y+=h),w.y=y,y+=i,t.overflow>s&&y>m&&(w.isOverflow=!0,t.overflow=s+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:r,paraIndent:i,letterSpacing:s}=e;let o,l,d,c,h,u;a.forEach((t=>{t.words&&(d=i&&t.paraStart?i:0,u=t.words.length,l=n&&("justify"===r||"both"===r)&&u>1?(n-t.width-d)/(u-1):0,c=s||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!s&&(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"!==r||n===u-1||(o+=l,t.width+=l)}))),t.words=null)}))}(h,a,s),h.overflow&&function(e,n,a,r){if(!r)return;const{rows:i,overflow:s}=e;let{textOverflow:o}=n;if(i.splice(s),o&&"show"!==o){let e,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const d=o?t.Platform.canvas.measureText(o).width:0,c=a+r-d;("none"===n.textWrap?i:[i[s-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,r,s),"none"!==l&&function(t,n){let a;const{fontSize:r,textDecoration:i}=n;switch(t.decorationHeight=r/11,"object"==typeof i?(a=i.type,i.color&&(t.decorationColor=e.ColorConvert.string(i.color))):a=i,a){case"under":t.decorationY=[.15*r];break;case"delete":t.decorationY=[.35*-r];break;case"under-delete":t.decorationY=[.15*r,.35*-r]}}(h,a),h}};const $e={string:function(t,n){const a="number"==typeof n&&1!==n;if("string"==typeof t){if(!a||!e.ColorConvert.object)return t;t=e.ColorConvert.object(t)}let r=void 0===t.a?1:t.a;a&&(r*=n);const i=t.r+","+t.g+","+t.b;return 1===r?"rgb("+i+")":"rgba("+i+","+r+")"}};Object.assign(e.TextConvert,Ke),Object.assign(e.ColorConvert,$e),Object.assign(e.Paint,H),Object.assign(e.PaintImage,vt),Object.assign(e.PaintGradient,Ft),Object.assign(e.Effect,Xt),r(),Object.defineProperty(exports,"LeaferImage",{enumerable:!0,get:function(){return t.LeaferImage}}),exports.Layouter=m,exports.LeaferCanvas=n,exports.Renderer=w,exports.Watcher=s,exports.useCanvas=r,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})}));
2
2
  //# sourceMappingURL=worker.min.cjs.map