@anu3ev/fabric-image-editor 0.8.13 → 0.8.15

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.
Files changed (2) hide show
  1. package/dist/main.js +459 -435
  2. package/package.json +3 -2
package/dist/main.js CHANGED
@@ -1899,8 +1899,16 @@ var qe = class e extends l {
1899
1899
  copyPaste: async (e, t) => {
1900
1900
  e.clipboardManager.copyPaste(t ?? void 0);
1901
1901
  },
1902
- delete: (e, t) => {
1903
- e.deletionManager.deleteSelectedObjects({ objects: t ? [t] : void 0 });
1902
+ delete: (t, n) => {
1903
+ if (n instanceof e) {
1904
+ t.deletionManager.deleteSelectedObjects({ objects: n.getObjects() });
1905
+ return;
1906
+ }
1907
+ if (!n) {
1908
+ t.deletionManager.deleteSelectedObjects();
1909
+ return;
1910
+ }
1911
+ t.deletionManager.deleteSelectedObjects({ objects: [n] });
1904
1912
  },
1905
1913
  lock: (e, t) => {
1906
1914
  e.objectLockManager.lockObject({ object: t ?? void 0 });
@@ -5191,7 +5199,7 @@ var dr = ({ transform: e, key: t }) => {
5191
5199
  if (!n || typeof n != "object") return null;
5192
5200
  let r = n[t];
5193
5201
  return typeof r != "number" || !Number.isFinite(r) ? null : r;
5194
- }, fr = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, pr = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, mr = ({ transform: e }) => {
5202
+ }, fr = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, pr = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, Y = ({ transform: e }) => {
5195
5203
  let t = e?.action ?? "", n = typeof e?.corner == "string" ? e.corner : "", r = n === "tl" || n === "tr" || n === "bl" || n === "br", i = t === "scaleX" || n === "ml" || n === "mr", a = t === "scaleY" || n === "mt" || n === "mb", o = i || r, s = a || r;
5196
5204
  return {
5197
5205
  canScaleWidth: o,
@@ -5199,37 +5207,37 @@ var dr = ({ transform: e, key: t }) => {
5199
5207
  isCornerScaleAction: r,
5200
5208
  isVerticalOnlyScale: s && !o
5201
5209
  };
5202
- }, hr = ({ event: e, target: t, transform: n, canvas: r }) => {
5210
+ }, mr = ({ event: e, target: t, transform: n, canvas: r }) => {
5203
5211
  if (!e) return null;
5204
5212
  let i = t.canvas ?? r, a = i.getScenePoint(e), o = t.getRelativeCenterPoint(), s = t.translateToGivenOrigin(o, "center", "center", n.originX, n.originY), c = t.angle ?? 0, l = (c === 0 ? a : a.rotate(-c * Math.PI / 180, o)).subtract(s), u = t.controls[n.corner], d = i.getZoom() || 1, f = (t.padding ?? 0) / d;
5205
5213
  return l.x >= f && (l.x -= f), l.x <= -f && (l.x += f), l.y >= f && (l.y -= f), l.y <= -f && (l.y += f), l.x -= u?.offsetX ?? 0, l.y -= u?.offsetY ?? 0, l;
5206
- }, gr = ({ group: e, originX: t, originY: n }) => {
5214
+ }, hr = ({ group: e, originX: t, originY: n }) => {
5207
5215
  if (t === null || n === null) return null;
5208
5216
  let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
5209
5217
  return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
5210
- }, _r = ({ state: e, transform: t }) => {
5218
+ }, gr = ({ state: e, transform: t }) => {
5211
5219
  if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
5212
5220
  let n = fr({ value: t.originX }), r = pr({ value: t.originY });
5213
5221
  return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
5214
- }, vr = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
5222
+ }, _r = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
5215
5223
  //#endregion
5216
5224
  //#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
5217
- function yr({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
5225
+ function vr({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
5218
5226
  let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
5219
5227
  return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
5220
5228
  }
5221
- function br({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
5229
+ function yr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
5222
5230
  let c = Math.max(0, e.shapeStrokeWidth ?? 0);
5223
5231
  tn({
5224
5232
  shape: t,
5225
- width: yr({
5233
+ width: vr({
5226
5234
  size: n,
5227
5235
  scale: i,
5228
5236
  strokeWidth: c,
5229
5237
  minSize: o,
5230
5238
  scaleEpsilon: s
5231
5239
  }),
5232
- height: yr({
5240
+ height: vr({
5233
5241
  size: r,
5234
5242
  scale: a,
5235
5243
  strokeWidth: c,
@@ -5240,7 +5248,7 @@ function br({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
5240
5248
  strokeWidth: c
5241
5249
  });
5242
5250
  }
5243
- function xr({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon: a }) {
5251
+ function br({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon: a }) {
5244
5252
  let o = Math.max(a, Math.abs(r) || 1), s = Math.max(a, Math.abs(i) || 1), c = n ?? "center";
5245
5253
  e.set({
5246
5254
  autoExpand: !1,
@@ -5255,13 +5263,13 @@ function xr({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon:
5255
5263
  scaleY: 1 / s
5256
5264
  }), e.initDimensions(), e.setCoords();
5257
5265
  }
5258
- var Sr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY: o, minSize: s, scaleEpsilon: c }) => {
5266
+ var xr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY: o, minSize: s, scaleEpsilon: c }) => {
5259
5267
  let l = Math.max(c, Math.abs(a) || 1), u = Math.max(c, Math.abs(o) || 1);
5260
5268
  e.set({
5261
5269
  width: r.width / l,
5262
5270
  height: r.height / u,
5263
5271
  dirty: !0
5264
- }), br({
5272
+ }), yr({
5265
5273
  group: e,
5266
5274
  shape: t,
5267
5275
  width: r.width,
@@ -5270,7 +5278,7 @@ var Sr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
5270
5278
  scaleY: o,
5271
5279
  minSize: s,
5272
5280
  scaleEpsilon: c
5273
- }), xr({
5281
+ }), br({
5274
5282
  text: n,
5275
5283
  layout: r,
5276
5284
  alignH: i,
@@ -5278,17 +5286,29 @@ var Sr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
5278
5286
  scaleY: o,
5279
5287
  scaleEpsilon: c
5280
5288
  });
5281
- }, Y = 1e-4, Cr = .5;
5282
- function wr({ width: e, height: t }) {
5289
+ }, X = 1e-4, Sr = .5;
5290
+ function Cr({ width: e, height: t }) {
5283
5291
  return `${Math.round(Math.max(1, e) * 1e6) / 1e6}:${Math.round(Math.max(1, t) * 1e6) / 1e6}`;
5284
5292
  }
5285
- function Tr({ width: e, padding: t }) {
5293
+ function wr({ width: e, padding: t }) {
5286
5294
  return Math.max(1, e - Math.max(0, t.left) - Math.max(0, t.right));
5287
5295
  }
5288
- function Er({ height: e, padding: t }) {
5296
+ function Tr({ height: e, padding: t }) {
5289
5297
  return Math.max(1, e - Math.max(0, t.top) - Math.max(0, t.bottom));
5290
5298
  }
5291
- function Dr({ group: e }) {
5299
+ function Er({ text: e }) {
5300
+ return (e.text ?? "").trim().length > 0;
5301
+ }
5302
+ function Dr({ height: e }) {
5303
+ return {
5304
+ measuredHeight: e,
5305
+ renderedLineCount: 0,
5306
+ longestLineWidth: 0,
5307
+ requiresGraphemeSplit: !1,
5308
+ isValid: !0
5309
+ };
5310
+ }
5311
+ function Or({ group: e }) {
5292
5312
  return Pe({ padding: {
5293
5313
  top: e.shapePaddingTop,
5294
5314
  right: e.shapePaddingRight,
@@ -5296,7 +5316,7 @@ function Dr({ group: e }) {
5296
5316
  left: e.shapePaddingLeft
5297
5317
  } });
5298
5318
  }
5299
- function Or({ group: e, width: t, height: n }) {
5319
+ function kr({ group: e, width: t, height: n }) {
5300
5320
  let r = e.shapePresetKey ?? "", i = r ? Te({ presetKey: r }) : null;
5301
5321
  return Re({
5302
5322
  baseInset: i ? Oe({
@@ -5308,27 +5328,31 @@ function Or({ group: e, width: t, height: n }) {
5308
5328
  strokeWidth: e.shapeStrokeWidth
5309
5329
  });
5310
5330
  }
5311
- function X({ group: e, width: t, height: n }) {
5312
- return Or({
5331
+ function Z({ group: e, width: t, height: n }) {
5332
+ return kr({
5313
5333
  group: e,
5314
5334
  width: Math.max(1, t ?? e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1),
5315
5335
  height: Math.max(1, n ?? e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1)
5316
5336
  });
5317
5337
  }
5318
- function kr({ group: e, text: t, width: n, height: r, measurementCache: i, constraintCache: a }) {
5319
- let o = Math.max(1, n), s = Math.max(1, r), c = wr({
5338
+ function Ar({ group: e, text: t, width: n, height: r, measurementCache: i, constraintCache: a }) {
5339
+ let o = Math.max(1, n), s = Math.max(1, r), c = Cr({
5320
5340
  width: o,
5321
5341
  height: s
5322
5342
  }), l = a?.get(c);
5323
5343
  if (l) return l;
5324
- let u = X({
5344
+ if (!Er({ text: t })) {
5345
+ let e = Dr({ height: s });
5346
+ return a?.set(c, e), e;
5347
+ }
5348
+ let u = Z({
5325
5349
  group: e,
5326
5350
  width: o,
5327
5351
  height: s
5328
- }), d = Tr({
5352
+ }), d = wr({
5329
5353
  width: o,
5330
5354
  padding: u
5331
- }), f = Er({
5355
+ }), f = Tr({
5332
5356
  height: s,
5333
5357
  padding: u
5334
5358
  }), p = Zn({
@@ -5342,9 +5366,9 @@ function kr({ group: e, text: t, width: n, height: r, measurementCache: i, const
5342
5366
  };
5343
5367
  return a?.set(c, m), m;
5344
5368
  }
5345
- function Ar({ group: e, text: t, state: n }) {
5369
+ function jr({ group: e, text: t, state: n }) {
5346
5370
  let { startHeight: r, startWidth: i, startScaleX: a, startScaleY: o, lastAllowedScaleX: s, lastAllowedScaleY: c } = n, l = Math.max(1 / i, 1 / r), u = Math.max(l, a, o, s, c), d = ({ scale: a }) => {
5347
- let o = kr({
5371
+ let o = Ar({
5348
5372
  group: e,
5349
5373
  text: t,
5350
5374
  width: Math.max(1, i * a),
@@ -5375,28 +5399,28 @@ function Ar({ group: e, text: t, state: n }) {
5375
5399
  minimumHeight: g
5376
5400
  };
5377
5401
  }
5378
- function jr({ group: e, text: t, width: n, padding: r, measurementCache: i }) {
5402
+ function Mr({ group: e, text: t, width: n, padding: r, measurementCache: i }) {
5379
5403
  return Vn({
5380
5404
  text: t,
5381
5405
  width: n,
5382
5406
  height: 1,
5383
5407
  padding: r,
5384
5408
  measurementCache: i ?? void 0,
5385
- resolvePaddingForSize: ({ width: t, height: n }) => X({
5409
+ resolvePaddingForSize: ({ width: t, height: n }) => Z({
5386
5410
  group: e,
5387
5411
  width: t,
5388
5412
  height: n
5389
5413
  })
5390
5414
  });
5391
5415
  }
5392
- function Mr({ group: e, text: t, constraintPadding: n, startDimensions: r, appliedScaleX: i, appliedScaleY: a, minimumHeight: o, measurementCache: s }) {
5416
+ function Nr({ group: e, text: t, constraintPadding: n, startDimensions: r, appliedScaleX: i, appliedScaleY: a, minimumHeight: o, measurementCache: s }) {
5393
5417
  let c = r.canScaleWidth ? Math.max(1, r.startWidth * i) : r.startWidth, l = r.canScaleHeight ? Math.max(1, r.startHeight * a) : r.startManualBaseHeight, u = o ?? Vn({
5394
5418
  text: t,
5395
5419
  width: c,
5396
5420
  height: l,
5397
5421
  padding: n,
5398
5422
  measurementCache: s ?? void 0,
5399
- resolvePaddingForSize: ({ width: t, height: n }) => X({
5423
+ resolvePaddingForSize: ({ width: t, height: n }) => Z({
5400
5424
  group: e,
5401
5425
  width: t,
5402
5426
  height: n
@@ -5407,25 +5431,25 @@ function Mr({ group: e, text: t, constraintPadding: n, startDimensions: r, appli
5407
5431
  previewHeight: Math.max(l, u)
5408
5432
  };
5409
5433
  }
5410
- function Nr({ group: e, text: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
5434
+ function Pr({ group: e, text: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
5411
5435
  let o = n.canScaleWidth ? Math.max(1, n.startWidth * r) : n.startWidth, s = n.canScaleHeight ? Math.max(1, n.startHeight * i) : n.startManualBaseHeight, c = a == null ? s : Math.max(s, a), l = !n.canScaleHeight;
5412
5436
  return jn({
5413
5437
  text: t,
5414
5438
  width: o,
5415
5439
  height: c,
5416
5440
  alignV: e.shapeAlignVertical ?? "middle",
5417
- padding: Dr({ group: e }),
5441
+ padding: Or({ group: e }),
5418
5442
  expandShapeHeightToFitText: l,
5419
5443
  measurementCache: n.previewTextMeasurementCache ?? void 0,
5420
- resolveInternalShapeTextInset: ({ width: t, height: n }) => Or({
5444
+ resolveInternalShapeTextInset: ({ width: t, height: n }) => kr({
5421
5445
  group: e,
5422
5446
  width: t,
5423
5447
  height: n
5424
5448
  })
5425
5449
  });
5426
5450
  }
5427
- function Pr({ group: e, transform: t }) {
5428
- let { canScaleWidth: n, canScaleHeight: r } = mr({ transform: t }), i = Math.max(1, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1), a = Math.max(1, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1);
5451
+ function Fr({ group: e, transform: t }) {
5452
+ let { canScaleWidth: n, canScaleHeight: r } = Y({ transform: t }), i = Math.max(1, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1), a = Math.max(1, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1);
5429
5453
  return {
5430
5454
  startWidth: i,
5431
5455
  startHeight: a,
@@ -5435,10 +5459,10 @@ function Pr({ group: e, transform: t }) {
5435
5459
  canScaleHeight: r
5436
5460
  };
5437
5461
  }
5438
- function Fr({ scalingState: e, group: t, text: n, constraintPadding: r, transform: i }) {
5462
+ function Ir({ scalingState: e, group: t, text: n, constraintPadding: r, transform: i }) {
5439
5463
  let a = e.get(t);
5440
5464
  if (a) return a;
5441
- let o = Pr({
5465
+ let o = Fr({
5442
5466
  group: t,
5443
5467
  transform: i
5444
5468
  }), s = dr({
@@ -5453,7 +5477,7 @@ function Fr({ scalingState: e, group: t, text: n, constraintPadding: r, transfor
5453
5477
  }), u = dr({
5454
5478
  transform: i,
5455
5479
  key: "top"
5456
- }), d = Math.abs(s ?? t.scaleX ?? 1) || 1, f = Math.abs(c ?? t.scaleY ?? 1) || 1, p = l ?? t.left ?? 0, m = u ?? t.top ?? 0, h = fr({ value: i?.original?.originX ?? i?.originX }), g = pr({ value: i?.original?.originY ?? i?.originY }), _ = typeof i?.corner == "string" ? i.corner : null, v = gr({
5480
+ }), d = Math.abs(s ?? t.scaleX ?? 1) || 1, f = Math.abs(c ?? t.scaleY ?? 1) || 1, p = l ?? t.left ?? 0, m = u ?? t.top ?? 0, h = fr({ value: i?.original?.originX ?? i?.originX }), g = pr({ value: i?.original?.originY ?? i?.originY }), _ = typeof i?.corner == "string" ? i.corner : null, v = hr({
5457
5481
  group: t,
5458
5482
  originX: h,
5459
5483
  originY: g
@@ -5461,7 +5485,7 @@ function Fr({ scalingState: e, group: t, text: n, constraintPadding: r, transfor
5461
5485
  measurementsByKey: /* @__PURE__ */ new Map(),
5462
5486
  splitByGraphemeByFrameWidth: /* @__PURE__ */ new Map(),
5463
5487
  minimumTextFrameWidth: null
5464
- }, x = /* @__PURE__ */ new Map(), S = jr({
5488
+ }, x = /* @__PURE__ */ new Map(), S = Mr({
5465
5489
  group: t,
5466
5490
  text: n,
5467
5491
  width: o.startWidth,
@@ -5475,7 +5499,7 @@ function Fr({ scalingState: e, group: t, text: n, constraintPadding: r, transfor
5475
5499
  startManualBaseHeight: o.startManualBaseHeight,
5476
5500
  canScaleWidth: o.canScaleWidth,
5477
5501
  canScaleHeight: o.canScaleHeight,
5478
- cannotScaleDownAtStart: S >= o.startHeight - Y,
5502
+ cannotScaleDownAtStart: S >= o.startHeight - X,
5479
5503
  isProportionalScaling: !1,
5480
5504
  blockedScaleAttempt: !1,
5481
5505
  startLeft: p,
@@ -5503,15 +5527,15 @@ function Fr({ scalingState: e, group: t, text: n, constraintPadding: r, transfor
5503
5527
  proportionalTextConstraintCache: x
5504
5528
  }, e.set(t, a), a;
5505
5529
  }
5506
- function Ir({ group: e, text: t, constraintPadding: n, startDimensions: r, scaleX: i, scaleY: a }) {
5507
- let { previewWidth: o, previewHeight: s } = Mr({
5530
+ function Lr({ group: e, text: t, constraintPadding: n, startDimensions: r, scaleX: i, scaleY: a }) {
5531
+ let { previewWidth: o, previewHeight: s } = Nr({
5508
5532
  group: e,
5509
5533
  text: t,
5510
5534
  constraintPadding: n,
5511
5535
  startDimensions: r,
5512
5536
  appliedScaleX: i,
5513
5537
  appliedScaleY: a
5514
- }), { startWidth: c, startHeight: l } = r, u = Math.abs(o - c) > Cr, d = Math.abs(s - l) > Cr;
5538
+ }), { startWidth: c, startHeight: l } = r, u = Math.abs(o - c) > Sr, d = Math.abs(s - l) > Sr;
5515
5539
  return {
5516
5540
  width: o,
5517
5541
  height: s,
@@ -5519,7 +5543,7 @@ function Ir({ group: e, text: t, constraintPadding: n, startDimensions: r, scale
5519
5543
  hasDimensionChange: u || d
5520
5544
  };
5521
5545
  }
5522
- function Lr({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth: n, canScaleHeight: r, finalWidth: i, finalHeight: a }) {
5546
+ function Rr({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth: n, canScaleHeight: r, finalWidth: i, finalHeight: a }) {
5523
5547
  let o = e;
5524
5548
  n && (o = i);
5525
5549
  let s = t;
@@ -5528,8 +5552,8 @@ function Lr({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth:
5528
5552
  height: s
5529
5553
  };
5530
5554
  }
5531
- function Rr({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, startManualBaseWidth: s, startManualBaseHeight: c, canScaleWidth: l, canScaleHeight: u, hasWidthChange: d }) {
5532
- let f = Lr({
5555
+ function zr({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, startManualBaseWidth: s, startManualBaseHeight: c, canScaleWidth: l, canScaleHeight: u, hasWidthChange: d }) {
5556
+ let f = Rr({
5533
5557
  startManualBaseWidth: s,
5534
5558
  startManualBaseHeight: c,
5535
5559
  canScaleWidth: l,
@@ -5538,11 +5562,11 @@ function Rr({ group: e, shape: t, text: n, width: r, height: i, alignH: a, align
5538
5562
  finalHeight: i
5539
5563
  });
5540
5564
  e.shapeManualBaseWidth = f.width, e.shapeManualBaseHeight = f.height, l && d && (e.shapeTextAutoExpand = !1);
5541
- let p = Dr({ group: e }), m = Or({
5565
+ let p = Or({ group: e }), m = kr({
5542
5566
  group: e,
5543
5567
  width: r,
5544
5568
  height: i
5545
- }), h = !u, g = ({ width: t, height: n }) => Or({
5569
+ }), h = !u, g = ({ width: t, height: n }) => kr({
5546
5570
  group: e,
5547
5571
  width: t,
5548
5572
  height: n
@@ -5582,13 +5606,13 @@ function Rr({ group: e, shape: t, text: n, width: r, height: i, alignH: a, align
5582
5606
  }
5583
5607
  //#endregion
5584
5608
  //#region src/editor/shape-manager/scaling/shape-active-selection-scaling.ts
5585
- var zr = class {
5609
+ var Br = class {
5586
5610
  constructor({ canvas: e, shapeScalingState: t }) {
5587
5611
  this.canvas = e, this.shapeScalingState = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.scalingSessions = /* @__PURE__ */ new WeakMap(), this.groupLayoutScales = /* @__PURE__ */ new WeakMap();
5588
5612
  }
5589
5613
  handleScalingPreview({ selection: e, transform: t, event: n }) {
5590
5614
  if (!t) return;
5591
- let { canScaleWidth: r, canScaleHeight: i, isCornerScaleAction: a } = mr({ transform: t });
5615
+ let { canScaleWidth: r, canScaleHeight: i, isCornerScaleAction: a } = Y({ transform: t });
5592
5616
  if (!r && !i) return;
5593
5617
  let o = this._collectPreviewItems({
5594
5618
  selection: e,
@@ -5632,7 +5656,7 @@ var zr = class {
5632
5656
  } else c = this._resolveShapeLayoutScale({
5633
5657
  item: e,
5634
5658
  selectionScale: p
5635
- }), l = Mr({
5659
+ }), l = Nr({
5636
5660
  group: t,
5637
5661
  text: r,
5638
5662
  constraintPadding: i,
@@ -5641,11 +5665,11 @@ var zr = class {
5641
5665
  appliedScaleY: c.scaleY,
5642
5666
  measurementCache: a.previewTextMeasurementCache
5643
5667
  }).previewHeight;
5644
- Sr({
5668
+ xr({
5645
5669
  group: t,
5646
5670
  shape: n,
5647
5671
  text: r,
5648
- layout: Nr({
5672
+ layout: Pr({
5649
5673
  group: t,
5650
5674
  text: r,
5651
5675
  state: a,
@@ -5657,7 +5681,7 @@ var zr = class {
5657
5681
  scaleX: p.scaleX,
5658
5682
  scaleY: p.scaleY,
5659
5683
  minSize: 1,
5660
- scaleEpsilon: Y
5684
+ scaleEpsilon: X
5661
5685
  }), this.groupLayoutScales.set(t, c), this._positionShapeInSelection({
5662
5686
  group: t,
5663
5687
  sessionItem: o
@@ -5668,13 +5692,13 @@ var zr = class {
5668
5692
  commitGroupScaling({ group: e, scaleX: t, scaleY: n, transform: r }) {
5669
5693
  let { shape: i, text: a } = U({ group: e });
5670
5694
  if (!i || !a) return this.shapeScalingState.delete(e), !1;
5671
- let o = this.shapeScalingState.get(e), s = o ?? Pr({
5695
+ let o = this.shapeScalingState.get(e), s = o ?? Fr({
5672
5696
  group: e,
5673
5697
  transform: r
5674
- }), c = r ? mr({ transform: r }) : null, l = o?.canScaleWidth ?? c?.canScaleWidth ?? Math.abs(t - 1) > 1e-4, u = o?.canScaleHeight ?? c?.canScaleHeight ?? Math.abs(n - 1) > 1e-4, d = e.shapeAlignHorizontal ?? "center", f = e.shapeAlignVertical ?? "middle", p = X({ group: e }), m = this.groupLayoutScales.get(e) ?? {
5698
+ }), c = r ? Y({ transform: r }) : null, l = o?.canScaleWidth ?? c?.canScaleWidth ?? Math.abs(t - 1) > 1e-4, u = o?.canScaleHeight ?? c?.canScaleHeight ?? Math.abs(n - 1) > 1e-4, d = e.shapeAlignHorizontal ?? "center", f = e.shapeAlignVertical ?? "middle", p = Z({ group: e }), m = this.groupLayoutScales.get(e) ?? {
5675
5699
  scaleX: t,
5676
5700
  scaleY: n
5677
- }, { width: h, height: g, hasWidthChange: _, hasDimensionChange: v } = Ir({
5701
+ }, { width: h, height: g, hasWidthChange: _, hasDimensionChange: v } = Lr({
5678
5702
  group: e,
5679
5703
  text: a,
5680
5704
  constraintPadding: p,
@@ -5686,7 +5710,7 @@ var zr = class {
5686
5710
  scaleX: m.scaleX,
5687
5711
  scaleY: m.scaleY
5688
5712
  });
5689
- return v ? (Rr({
5713
+ return v ? (zr({
5690
5714
  group: e,
5691
5715
  shape: i,
5692
5716
  text: a,
@@ -5722,7 +5746,7 @@ var zr = class {
5722
5746
  if (!H(r)) continue;
5723
5747
  let { shape: e, text: i } = U({ group: r });
5724
5748
  if (!e || !i) continue;
5725
- let a = X({ group: r }), o = Fr({
5749
+ let a = Z({ group: r }), o = Ir({
5726
5750
  scalingState: this.shapeScalingState,
5727
5751
  group: r,
5728
5752
  text: i,
@@ -5769,7 +5793,7 @@ var zr = class {
5769
5793
  return this.scalingSessions.set(e, u), u;
5770
5794
  }
5771
5795
  _resolveSelectionScale({ items: e, session: t, transform: n, proportionalLayoutResults: r, scaleX: i, scaleY: a, event: o }) {
5772
- let { canScaleWidth: s, canScaleHeight: c, isCornerScaleAction: l } = mr({ transform: n }), u = !!(o && "shiftKey" in o && o.shiftKey), d = l && !u, f = i, p = a;
5796
+ let { canScaleWidth: s, canScaleHeight: c, isCornerScaleAction: l } = Y({ transform: n }), u = !!(o && "shiftKey" in o && o.shiftKey), d = l && !u, f = i, p = a;
5773
5797
  if (d) {
5774
5798
  let n = Math.max(i, a);
5775
5799
  if (!r) return {
@@ -5843,7 +5867,7 @@ var zr = class {
5843
5867
  return o;
5844
5868
  }
5845
5869
  _resolveSelectionScaleAtPointerBoundary({ selection: e, items: t, session: n, transform: r, selectionScale: i, event: a }) {
5846
- let { canScaleWidth: o, canScaleHeight: s, isCornerScaleAction: c } = mr({ transform: r }), l = !!(a && "shiftKey" in a && a.shiftKey);
5870
+ let { canScaleWidth: o, canScaleHeight: s, isCornerScaleAction: c } = Y({ transform: r }), l = !!(a && "shiftKey" in a && a.shiftKey);
5847
5871
  if (c && !l) return i;
5848
5872
  let u = o && this._hasPointerReachedSelectionScaleOrigin({
5849
5873
  selection: e,
@@ -5962,7 +5986,7 @@ var zr = class {
5962
5986
  _resolveProportionalLayoutResults({ items: e }) {
5963
5987
  let t = /* @__PURE__ */ new Map();
5964
5988
  for (let n of e) {
5965
- let e = Ar({
5989
+ let e = jr({
5966
5990
  group: n.group,
5967
5991
  text: n.text,
5968
5992
  state: n.state
@@ -5980,7 +6004,7 @@ var zr = class {
5980
6004
  text: r,
5981
6005
  padding: i,
5982
6006
  measurementCache: a.previewTextMeasurementCache ?? void 0,
5983
- resolvePaddingForWidth: ({ width: e }) => X({
6007
+ resolvePaddingForWidth: ({ width: e }) => Z({
5984
6008
  group: n,
5985
6009
  width: e,
5986
6010
  height: o
@@ -5993,7 +6017,7 @@ var zr = class {
5993
6017
  }
5994
6018
  _resolveMinimumShapeHeight({ item: e, scaleX: t }) {
5995
6019
  let { group: n, text: r, constraintPadding: i, state: a } = e;
5996
- return jr({
6020
+ return Mr({
5997
6021
  group: n,
5998
6022
  text: r,
5999
6023
  width: Math.max(1, a.startWidth * t),
@@ -6032,7 +6056,7 @@ var zr = class {
6032
6056
  };
6033
6057
  }
6034
6058
  _resolveVerticalAttachment({ selectionBounds: e, shapeBounds: t }) {
6035
- let n = Math.max(0, t.top - e.top), r = Math.max(0, e.bottom - t.bottom), i = n <= Cr, a = r <= Cr;
6059
+ let n = Math.max(0, t.top - e.top), r = Math.max(0, e.bottom - t.bottom), i = n <= Sr, a = r <= Sr;
6036
6060
  return i && !a ? "top" : a && !i ? "bottom" : Math.abs(n - r) <= .5 ? "center" : n < r ? "top" : "bottom";
6037
6061
  }
6038
6062
  _resolveOriginOffset({ origin: e }) {
@@ -6053,7 +6077,7 @@ var zr = class {
6053
6077
  _hasPointerReachedSelectionScaleOrigin({ selection: e, transform: t, event: n, axis: r }) {
6054
6078
  let i = t, a = r === "x" ? i.signX : i.signY;
6055
6079
  if (typeof a != "number" || !Number.isFinite(a)) return !1;
6056
- let o = hr({
6080
+ let o = mr({
6057
6081
  target: e,
6058
6082
  transform: t,
6059
6083
  event: n,
@@ -6072,7 +6096,7 @@ var zr = class {
6072
6096
  scaleY: r
6073
6097
  }), c && o !== null && s !== null && e.setPositionByOrigin(c, o, s), e.setCoords();
6074
6098
  }
6075
- }, Br = class {
6099
+ }, Vr = class {
6076
6100
  constructor({ canvas: t }) {
6077
6101
  this.handleObjectScaling = (t) => {
6078
6102
  let { target: n, transform: r } = t;
@@ -6091,7 +6115,7 @@ var zr = class {
6091
6115
  lockScalingFlip: !0,
6092
6116
  centeredScaling: !1
6093
6117
  });
6094
- let s = X({ group: i }), c = Fr({
6118
+ let s = Z({ group: i }), c = Ir({
6095
6119
  scalingState: this.scalingState,
6096
6120
  group: i,
6097
6121
  text: o,
@@ -6120,7 +6144,7 @@ var zr = class {
6120
6144
  });
6121
6145
  return;
6122
6146
  }
6123
- let _ = Nr({
6147
+ let _ = Pr({
6124
6148
  group: i,
6125
6149
  text: o,
6126
6150
  state: c,
@@ -6134,7 +6158,7 @@ var zr = class {
6134
6158
  shouldHandleAsNoop: !1,
6135
6159
  scaleX: g.appliedScaleX,
6136
6160
  scaleY: g.appliedScaleY
6137
- }), Sr({
6161
+ }), xr({
6138
6162
  group: i,
6139
6163
  shape: a,
6140
6164
  text: o,
@@ -6143,7 +6167,7 @@ var zr = class {
6143
6167
  scaleX: g.appliedScaleX,
6144
6168
  scaleY: g.appliedScaleY,
6145
6169
  minSize: 1,
6146
- scaleEpsilon: Y
6170
+ scaleEpsilon: X
6147
6171
  }), this._restoreScalingAnchorPosition({
6148
6172
  group: i,
6149
6173
  state: c
@@ -6174,7 +6198,7 @@ var zr = class {
6174
6198
  if (!a) return;
6175
6199
  let { shape: o, text: s } = U({ group: i });
6176
6200
  if (!o || !s) return;
6177
- let c = X({ group: i }), l = i.shapeAlignHorizontal ?? "center", { canScaleWidth: u, canScaleHeight: d } = a;
6201
+ let c = Z({ group: i }), l = i.shapeAlignHorizontal ?? "center", { canScaleWidth: u, canScaleHeight: d } = a;
6178
6202
  if (!u && !d) return;
6179
6203
  let f = Math.abs(i.scaleX ?? a.startScaleX) || a.startScaleX, p = Math.abs(i.scaleY ?? a.startScaleY) || a.startScaleY, { scaleX: m, scaleY: h } = this._resolveCurrentDragScales({
6180
6204
  group: i,
@@ -6196,7 +6220,7 @@ var zr = class {
6196
6220
  axis: "y"
6197
6221
  });
6198
6222
  if (!e && !t) return;
6199
- let n = Ar({
6223
+ let n = jr({
6200
6224
  group: i,
6201
6225
  text: s,
6202
6226
  state: a
@@ -6213,7 +6237,7 @@ var zr = class {
6213
6237
  let e = zn({
6214
6238
  text: s,
6215
6239
  padding: c,
6216
- resolvePaddingForWidth: ({ width: e }) => X({
6240
+ resolvePaddingForWidth: ({ width: e }) => Z({
6217
6241
  group: i,
6218
6242
  width: e,
6219
6243
  height: Math.max(1, a.startHeight * v)
@@ -6236,7 +6260,7 @@ var zr = class {
6236
6260
  });
6237
6261
  return;
6238
6262
  }
6239
- y = C ?? jr({
6263
+ y = C ?? Mr({
6240
6264
  group: i,
6241
6265
  text: s,
6242
6266
  width: Math.max(1, a.startWidth * _),
@@ -6249,7 +6273,7 @@ var zr = class {
6249
6273
  }
6250
6274
  if (!x && !S) return;
6251
6275
  y ??= C;
6252
- let w = Mr({
6276
+ let w = Nr({
6253
6277
  group: i,
6254
6278
  text: s,
6255
6279
  constraintPadding: c,
@@ -6258,7 +6282,7 @@ var zr = class {
6258
6282
  appliedScaleY: v,
6259
6283
  minimumHeight: b ? null : y,
6260
6284
  measurementCache: a.previewTextMeasurementCache
6261
- }), T = Nr({
6285
+ }), T = Pr({
6262
6286
  group: i,
6263
6287
  text: s,
6264
6288
  state: a,
@@ -6272,7 +6296,7 @@ var zr = class {
6272
6296
  shouldHandleAsNoop: !1,
6273
6297
  scaleX: _,
6274
6298
  scaleY: v
6275
- }), Sr({
6299
+ }), xr({
6276
6300
  group: i,
6277
6301
  shape: o,
6278
6302
  text: s,
@@ -6281,7 +6305,7 @@ var zr = class {
6281
6305
  scaleX: _,
6282
6306
  scaleY: v,
6283
6307
  minSize: 1,
6284
- scaleEpsilon: Y
6308
+ scaleEpsilon: X
6285
6309
  }), this._restoreScalingAnchorPosition({
6286
6310
  group: i,
6287
6311
  state: a
@@ -6316,7 +6340,7 @@ var zr = class {
6316
6340
  startHeight: s,
6317
6341
  alignH: n.shapeAlignHorizontal,
6318
6342
  alignV: n.shapeAlignVertical,
6319
- userPadding: Dr({ group: n })
6343
+ userPadding: Or({ group: n })
6320
6344
  }), n.shapeScalingNoopTransform = !1, this.scalingState.delete(n), this.canvas.requestRenderAll();
6321
6345
  return;
6322
6346
  }
@@ -6325,7 +6349,7 @@ var zr = class {
6325
6349
  this.scalingState.delete(n);
6326
6350
  return;
6327
6351
  }
6328
- let f = n.shapeAlignHorizontal ?? "center", p = n.shapeAlignVertical ?? "middle", m = X({ group: n }), h = e.transform ? mr({ transform: e.transform }) : null, g = r?.canScaleWidth ?? h?.canScaleWidth ?? Math.abs(i - 1) > 1e-4, _ = r?.canScaleHeight ?? h?.canScaleHeight ?? Math.abs(a - 1) > 1e-4, v = r?.lastAllowedScaleX ?? i, y = r?.lastAllowedScaleY ?? a;
6352
+ let f = n.shapeAlignHorizontal ?? "center", p = n.shapeAlignVertical ?? "middle", m = Z({ group: n }), h = e.transform ? Y({ transform: e.transform }) : null, g = r?.canScaleWidth ?? h?.canScaleWidth ?? Math.abs(i - 1) > 1e-4, _ = r?.canScaleHeight ?? h?.canScaleHeight ?? Math.abs(a - 1) > 1e-4, v = r?.lastAllowedScaleX ?? i, y = r?.lastAllowedScaleY ?? a;
6329
6353
  if (r?.isProportionalScaling) {
6330
6354
  let t = this._hasPointerReachedScaleOrigin({
6331
6355
  event: e,
@@ -6339,7 +6363,7 @@ var zr = class {
6339
6363
  axis: "y"
6340
6364
  });
6341
6365
  if (t || o) {
6342
- let e = Ar({
6366
+ let e = jr({
6343
6367
  group: n,
6344
6368
  text: d,
6345
6369
  state: r
@@ -6350,7 +6374,7 @@ var zr = class {
6350
6374
  let t = zn({
6351
6375
  text: d,
6352
6376
  padding: m,
6353
- resolvePaddingForWidth: ({ width: e }) => X({
6377
+ resolvePaddingForWidth: ({ width: e }) => Z({
6354
6378
  group: n,
6355
6379
  width: e,
6356
6380
  height: Math.max(1, s * y)
@@ -6362,7 +6386,7 @@ var zr = class {
6362
6386
  minimumWidth: t,
6363
6387
  state: r
6364
6388
  }) && (v = Math.max(1 / o, t / o));
6365
- let i = jr({
6389
+ let i = Mr({
6366
6390
  group: n,
6367
6391
  text: d,
6368
6392
  width: Math.max(1, o * v),
@@ -6375,7 +6399,7 @@ var zr = class {
6375
6399
  state: r
6376
6400
  }) && (y = Math.max(1 / s, i / s));
6377
6401
  }
6378
- let { width: b, height: x, hasWidthChange: S, hasDimensionChange: C } = Ir({
6402
+ let { width: b, height: x, hasWidthChange: S, hasDimensionChange: C } = Lr({
6379
6403
  group: n,
6380
6404
  text: d,
6381
6405
  constraintPadding: m,
@@ -6400,14 +6424,14 @@ var zr = class {
6400
6424
  startHeight: s,
6401
6425
  alignH: f,
6402
6426
  alignV: p,
6403
- userPadding: Dr({ group: n })
6427
+ userPadding: Or({ group: n })
6404
6428
  }), this.scalingState.delete(n), this.canvas.requestRenderAll();
6405
6429
  return;
6406
6430
  }
6407
6431
  r && n.set({
6408
6432
  left: r.lastAllowedLeft,
6409
6433
  top: r.lastAllowedTop
6410
- }), Rr({
6434
+ }), zr({
6411
6435
  group: n,
6412
6436
  shape: u,
6413
6437
  text: d,
@@ -6424,7 +6448,7 @@ var zr = class {
6424
6448
  group: n,
6425
6449
  state: r
6426
6450
  }), n.setCoords(), d.setCoords(), u.setCoords(), this.scalingState.delete(n), n.shapeScalingNoopTransform = !1, this.canvas.requestRenderAll();
6427
- }, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.activeSelectionScalingController = new zr({
6451
+ }, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.activeSelectionScalingController = new Br({
6428
6452
  canvas: t,
6429
6453
  shapeScalingState: this.scalingState
6430
6454
  });
@@ -6433,10 +6457,10 @@ var zr = class {
6433
6457
  let a = e.scaleX ?? 1, o = e.scaleY ?? 1, { scaleX: s, scaleY: c } = this._resolveCurrentDragScales({
6434
6458
  group: e,
6435
6459
  state: r
6436
- }), l = r.canScaleWidth && a < 0 || r.canScaleHeight && o < 0, u = _r({
6460
+ }), l = r.canScaleWidth && a < 0 || r.canScaleHeight && o < 0, u = gr({
6437
6461
  state: r,
6438
6462
  transform: i
6439
- }), d = vr({
6463
+ }), d = _r({
6440
6464
  state: r,
6441
6465
  transform: i
6442
6466
  });
@@ -6452,7 +6476,7 @@ var zr = class {
6452
6476
  f.shouldRestoreLastAllowedTransform && (h = r.lastAllowedScaleX, g = r.lastAllowedScaleY), f.shouldHandleAsNoop && (h = r.startScaleX, g = r.startScaleY);
6453
6477
  let _ = f.resolvedMinimumHeight, v = !r.canScaleWidth && r.canScaleHeight ? r.fixedWidthMinimumTextFitHeight : null;
6454
6478
  f.shouldHandleAsNoop ? _ = r.startHeight : _ ??= v;
6455
- let { previewHeight: y } = Mr({
6479
+ let { previewHeight: y } = Nr({
6456
6480
  group: e,
6457
6481
  text: t,
6458
6482
  constraintPadding: n,
@@ -6471,16 +6495,16 @@ var zr = class {
6471
6495
  };
6472
6496
  }
6473
6497
  _resolveScalingConstraintState({ group: e, text: t, constraintPadding: n, state: r, scaleX: i, scaleY: a }) {
6474
- let { canScaleHeight: o, canScaleWidth: s, startHeight: c, startWidth: l, cannotScaleDownAtStart: u, crossedOppositeCorner: d, isProportionalScaling: f, lastAllowedScaleX: p, lastAllowedScaleY: m, startScaleY: h } = r, g = o && !s, _ = s ? Math.max(1, l * i) : l, v = o ? Math.max(1, c * a) : c, y = i < p - Y, b = a < m - Y, x = a < h - Y, S = g ? r.fixedWidthMinimumTextFitHeight : null, C = s && y ? zn({
6498
+ let { canScaleHeight: o, canScaleWidth: s, startHeight: c, startWidth: l, cannotScaleDownAtStart: u, crossedOppositeCorner: d, isProportionalScaling: f, lastAllowedScaleX: p, lastAllowedScaleY: m, startScaleY: h } = r, g = o && !s, _ = s ? Math.max(1, l * i) : l, v = o ? Math.max(1, c * a) : c, y = i < p - X, b = a < m - X, x = a < h - X, S = g ? r.fixedWidthMinimumTextFitHeight : null, C = s && y ? zn({
6475
6499
  text: t,
6476
6500
  padding: n,
6477
6501
  measurementCache: r.previewTextMeasurementCache ?? void 0,
6478
- resolvePaddingForWidth: ({ width: t }) => X({
6502
+ resolvePaddingForWidth: ({ width: t }) => Z({
6479
6503
  group: e,
6480
6504
  width: t,
6481
6505
  height: v
6482
6506
  })
6483
- }) : null, w = o && b ? S ?? jr({
6507
+ }) : null, w = o && b ? S ?? Mr({
6484
6508
  group: e,
6485
6509
  text: t,
6486
6510
  width: _,
@@ -6488,7 +6512,7 @@ var zr = class {
6488
6512
  measurementCache: r.previewTextMeasurementCache
6489
6513
  }) : null, T = g && u && x;
6490
6514
  if (f && s && o && (y || b)) {
6491
- if (!kr({
6515
+ if (!Ar({
6492
6516
  group: e,
6493
6517
  text: t,
6494
6518
  width: _,
@@ -6496,7 +6520,7 @@ var zr = class {
6496
6520
  measurementCache: r.previewTextMeasurementCache,
6497
6521
  constraintCache: r.proportionalTextConstraintCache
6498
6522
  }).isValid) {
6499
- let n = Ar({
6523
+ let n = jr({
6500
6524
  group: e,
6501
6525
  text: t,
6502
6526
  state: r
@@ -6519,7 +6543,7 @@ var zr = class {
6519
6543
  }
6520
6544
  let E = C !== null && _ < C + 1e-4, D = w !== null && v < w + 1e-4, O = E || D, k = d, A = null, j = null;
6521
6545
  if (f && O) {
6522
- let n = Ar({
6546
+ let n = jr({
6523
6547
  group: e,
6524
6548
  text: t,
6525
6549
  state: r
@@ -6548,11 +6572,11 @@ var zr = class {
6548
6572
  shouldHandleAsNoop: !0,
6549
6573
  scaleX: r.startScaleX,
6550
6574
  scaleY: r.startScaleY
6551
- }), Sr({
6575
+ }), xr({
6552
6576
  group: e,
6553
6577
  shape: t,
6554
6578
  text: n,
6555
- layout: Nr({
6579
+ layout: Pr({
6556
6580
  group: e,
6557
6581
  text: n,
6558
6582
  state: r,
@@ -6564,7 +6588,7 @@ var zr = class {
6564
6588
  scaleX: r.startScaleX,
6565
6589
  scaleY: r.startScaleY,
6566
6590
  minSize: 1,
6567
- scaleEpsilon: Y
6591
+ scaleEpsilon: X
6568
6592
  }), this._restoreScalingAnchorPosition({
6569
6593
  group: e,
6570
6594
  state: r
@@ -6607,7 +6631,7 @@ var zr = class {
6607
6631
  if (!r) return !1;
6608
6632
  let { transform: i } = e;
6609
6633
  if (!i) return !1;
6610
- let { canScaleWidth: a } = mr({ transform: i });
6634
+ let { canScaleWidth: a } = Y({ transform: i });
6611
6635
  if (!a || !this._hasPointerReachedScaleOrigin({
6612
6636
  event: e,
6613
6637
  group: t,
@@ -6615,13 +6639,13 @@ var zr = class {
6615
6639
  axis: "x"
6616
6640
  })) return !1;
6617
6641
  let o = Math.max(1 / r.startWidth, n / r.startWidth);
6618
- return r.lastAllowedScaleX > o + Y;
6642
+ return r.lastAllowedScaleX > o + X;
6619
6643
  }
6620
6644
  _shouldClampHeightToMinimum({ event: e, group: t, minimumHeight: n, state: r }) {
6621
6645
  if (!r) return !1;
6622
6646
  let { transform: i } = e;
6623
6647
  if (!i) return !1;
6624
- let { canScaleHeight: a } = mr({ transform: i });
6648
+ let { canScaleHeight: a } = Y({ transform: i });
6625
6649
  if (!a || !this._hasPointerReachedScaleOrigin({
6626
6650
  event: e,
6627
6651
  group: t,
@@ -6629,14 +6653,14 @@ var zr = class {
6629
6653
  axis: "y"
6630
6654
  })) return !1;
6631
6655
  let o = Math.max(1 / r.startHeight, n / r.startHeight);
6632
- return r.lastAllowedScaleY > o + Y;
6656
+ return r.lastAllowedScaleY > o + X;
6633
6657
  }
6634
6658
  _hasPointerReachedScaleOrigin({ event: e, group: t, state: n, axis: r }) {
6635
6659
  let { transform: i } = e;
6636
6660
  if (!i) return !1;
6637
6661
  let a = i, o = r === "x" ? n?.scaleDirectionX ?? null : n?.scaleDirectionY ?? null, s = this._resolveScaleDirection({ value: r === "x" ? a.signX : a.signY }) ?? o;
6638
6662
  if (s === null) return !1;
6639
- let c = hr({
6663
+ let c = mr({
6640
6664
  event: e.e,
6641
6665
  target: t,
6642
6666
  transform: i,
@@ -6646,7 +6670,7 @@ var zr = class {
6646
6670
  }
6647
6671
  _storeScaleDirectionsForCurrentTransform({ group: e, state: t, event: n, transform: r }) {
6648
6672
  if (!r) return;
6649
- let { canScaleHeight: i, canScaleWidth: a, isCornerScaleAction: o } = mr({ transform: r });
6673
+ let { canScaleHeight: i, canScaleWidth: a, isCornerScaleAction: o } = Y({ transform: r });
6650
6674
  if (!o) return;
6651
6675
  let s = !a || t.scaleDirectionX !== null, c = !i || t.scaleDirectionY !== null;
6652
6676
  if (s && c) return;
@@ -6654,7 +6678,7 @@ var zr = class {
6654
6678
  a && t.scaleDirectionX === null && (t.scaleDirectionX = this._resolveScaleDirection({ value: l.signX })), i && t.scaleDirectionY === null && (t.scaleDirectionY = this._resolveScaleDirection({ value: l.signY }));
6655
6679
  let u = !a || t.scaleDirectionX !== null, d = !i || t.scaleDirectionY !== null;
6656
6680
  if (u && d) return;
6657
- let f = hr({
6681
+ let f = mr({
6658
6682
  event: n,
6659
6683
  target: e,
6660
6684
  transform: r,
@@ -6683,11 +6707,11 @@ var zr = class {
6683
6707
  e.setPositionByOrigin(new m(n, r), i, a), e.setCoords();
6684
6708
  }
6685
6709
  _restoreShapeStateWithoutResize({ group: e, shape: t, text: n, state: r, startWidth: i, startHeight: a, alignH: o, alignV: s, userPadding: c }) {
6686
- let l = Math.max(1, e.shapeBaseWidth ?? e.width ?? i), u = Math.max(1, e.shapeBaseHeight ?? e.height ?? a), d = Or({
6710
+ let l = Math.max(1, e.shapeBaseWidth ?? e.width ?? i), u = Math.max(1, e.shapeBaseHeight ?? e.height ?? a), d = kr({
6687
6711
  group: e,
6688
6712
  width: l,
6689
6713
  height: u
6690
- }), f = o ?? "center", p = s ?? "middle", m = ({ width: t, height: n }) => Or({
6714
+ }), f = o ?? "center", p = s ?? "middle", m = ({ width: t, height: n }) => kr({
6691
6715
  group: e,
6692
6716
  width: t,
6693
6717
  height: n
@@ -6726,7 +6750,7 @@ var zr = class {
6726
6750
  state: r
6727
6751
  });
6728
6752
  }
6729
- }, Vr = class {
6753
+ }, Hr = class {
6730
6754
  constructor({ canvas: e }) {
6731
6755
  this.handleMouseDown = (e) => {
6732
6756
  let { target: t, e: n, subTargets: r = [] } = e, i = Ye({
@@ -6850,7 +6874,7 @@ var zr = class {
6850
6874
  let t = this.canvas;
6851
6875
  t.findTarget = e.findTarget, this.editingTargetResolverState = void 0;
6852
6876
  }
6853
- }, Hr = 1e-4, Ur = class {
6877
+ }, Ur = 1e-4, Wr = class {
6854
6878
  constructor({ runtime: t }) {
6855
6879
  this._handleObjectScaling = (e) => {
6856
6880
  this.runtime.collectShapeGroupsFromTarget({
@@ -6935,7 +6959,7 @@ var zr = class {
6935
6959
  let r = t.getObjects(), i = r.filter((e) => H(e));
6936
6960
  if (!i.length) return;
6937
6961
  let { scaleX: a, scaleY: o } = this.runtime.scalingController.resolveActiveSelectionCommittedScale({ selection: t });
6938
- if (!(Math.abs(a - 1) > Hr || Math.abs(o - 1) > Hr)) {
6962
+ if (!(Math.abs(a - 1) > Ur || Math.abs(o - 1) > Ur)) {
6939
6963
  this.runtime.scalingController.clearActiveSelectionState({ selection: t });
6940
6964
  return;
6941
6965
  }
@@ -6953,7 +6977,7 @@ var zr = class {
6953
6977
  }), e.setCoords());
6954
6978
  }), this.runtime.scalingController.clearActiveSelectionState({ selection: t }), s.setActiveObject(new e(r, { canvas: s })), s.requestRenderAll();
6955
6979
  }
6956
- }, Wr = class {
6980
+ }, Gr = class {
6957
6981
  constructor({ editor: e }) {
6958
6982
  this.editor = e;
6959
6983
  }
@@ -7104,7 +7128,7 @@ var zr = class {
7104
7128
  resolvePaddingForWidth: i
7105
7129
  }) : Math.max(1, t, n);
7106
7130
  }
7107
- }, Gr = class e {
7131
+ }, Kr = class e {
7108
7132
  constructor({ canvas: e }) {
7109
7133
  this.canvas = e, this.textEditingSnapshots = /* @__PURE__ */ new WeakMap(), this.pendingTextUpdates = /* @__PURE__ */ new WeakMap(), this.resizeStartSnapshots = /* @__PURE__ */ new Map(), this.pendingResizeUpdates = /* @__PURE__ */ new WeakMap();
7110
7134
  }
@@ -7300,7 +7324,7 @@ var zr = class {
7300
7324
  }
7301
7325
  }), I;
7302
7326
  }
7303
- }, Kr = .01, qr = ({ textbox: e }) => {
7327
+ }, qr = .01, Jr = ({ textbox: e }) => {
7304
7328
  let t = e.text ?? "";
7305
7329
  if (!t.length) return [];
7306
7330
  let n = t.split("\n"), r = [], i = 0;
@@ -7312,7 +7336,7 @@ var zr = class {
7312
7336
  });
7313
7337
  }
7314
7338
  return r;
7315
- }, Jr = ({ range: e, text: t }) => {
7339
+ }, Yr = ({ range: e, text: t }) => {
7316
7340
  if (!e) return null;
7317
7341
  let n = t.length;
7318
7342
  if (n <= 0) return null;
@@ -7321,8 +7345,8 @@ var zr = class {
7321
7345
  start: l,
7322
7346
  end: u
7323
7347
  };
7324
- }, Yr = ({ textbox: e, range: t }) => {
7325
- let n = qr({ textbox: e });
7348
+ }, Xr = ({ textbox: e, range: t }) => {
7349
+ let n = Jr({ textbox: e });
7326
7350
  if (!n.length) return t;
7327
7351
  let { start: r } = t, { end: i } = t;
7328
7352
  for (let e = 0; e < n.length; e += 1) {
@@ -7335,7 +7359,7 @@ var zr = class {
7335
7359
  start: r,
7336
7360
  end: i
7337
7361
  };
7338
- }, Xr = ({ textbox: e, range: t }) => {
7362
+ }, Zr = ({ textbox: e, range: t }) => {
7339
7363
  let n = e.text ?? "";
7340
7364
  if (!n.length) return [];
7341
7365
  let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
@@ -7344,7 +7368,7 @@ var zr = class {
7344
7368
  i > n && r < c && o.push(e), s = c + 1;
7345
7369
  }
7346
7370
  return o;
7347
- }, Zr = ({ textbox: e, range: t }) => {
7371
+ }, Qr = ({ textbox: e, range: t }) => {
7348
7372
  let n = e.text ?? "";
7349
7373
  if (!n.length) return [];
7350
7374
  let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
@@ -7353,21 +7377,21 @@ var zr = class {
7353
7377
  r <= n && i >= c && o.push(e), s = c + 1;
7354
7378
  }
7355
7379
  return o;
7356
- }, Qr = ({ previous: e, next: t }) => {
7380
+ }, $r = ({ previous: e, next: t }) => {
7357
7381
  let n = Math.min(e.length, t.length);
7358
7382
  for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
7359
7383
  return n;
7360
- }, $r = ({ text: e, charIndex: t }) => {
7384
+ }, ei = ({ text: e, charIndex: t }) => {
7361
7385
  let n = Math.max(0, Math.min(t, e.length)), r = 0;
7362
7386
  for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
7363
7387
  return r;
7364
- }, ei = ({ text: e, lineIndex: t }) => {
7388
+ }, ti = ({ text: e, lineIndex: t }) => {
7365
7389
  if (t <= 0) return 0;
7366
7390
  let n = 0;
7367
7391
  for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
7368
7392
  return e.length;
7369
- }, ti = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousText: i }) => {
7370
- let a = ei({
7393
+ }, ni = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousText: i }) => {
7394
+ let a = ti({
7371
7395
  text: i,
7372
7396
  lineIndex: r
7373
7397
  }), o = r + 1;
@@ -7386,7 +7410,7 @@ var zr = class {
7386
7410
  lineFontDefaults: s,
7387
7411
  changed: !0
7388
7412
  };
7389
- }, ni = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousLines: i, previousText: a }) => {
7413
+ }, ri = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousLines: i, previousText: a }) => {
7390
7414
  let o = Math.abs(e), s = r;
7391
7415
  a[t] === "\n" && (i[r] ?? "").length > 0 && (s = r + 1);
7392
7416
  let c = s + o - 1, l = {}, u = [];
@@ -7409,7 +7433,7 @@ var zr = class {
7409
7433
  lineDefaults: u
7410
7434
  }
7411
7435
  };
7412
- }, ri = ({ lineFontDefaults: e, previousText: t, currentText: n }) => {
7436
+ }, ii = ({ lineFontDefaults: e, previousText: t, currentText: n }) => {
7413
7437
  if (!e || !Object.keys(e).length) return {
7414
7438
  lineFontDefaults: e,
7415
7439
  changed: !1
@@ -7419,20 +7443,20 @@ var zr = class {
7419
7443
  lineFontDefaults: e,
7420
7444
  changed: !1
7421
7445
  };
7422
- let a = Qr({
7446
+ let a = $r({
7423
7447
  previous: t,
7424
7448
  next: n
7425
- }), o = $r({
7449
+ }), o = ei({
7426
7450
  text: t,
7427
7451
  charIndex: a
7428
7452
  });
7429
- return i > 0 ? ti({
7453
+ return i > 0 ? ni({
7430
7454
  deltaLines: i,
7431
7455
  diffIndex: a,
7432
7456
  lineFontDefaults: e,
7433
7457
  lineIndexOld: o,
7434
7458
  previousText: t
7435
- }) : ni({
7459
+ }) : ri({
7436
7460
  deltaLines: i,
7437
7461
  diffIndex: a,
7438
7462
  lineFontDefaults: e,
@@ -7440,10 +7464,10 @@ var zr = class {
7440
7464
  previousLines: r,
7441
7465
  previousText: t
7442
7466
  });
7443
- }, ii = ({ lineDefaults: e }) => {
7467
+ }, ai = ({ lineDefaults: e }) => {
7444
7468
  let t = {};
7445
7469
  return e.fontFamily !== void 0 && (t.fontFamily = e.fontFamily), e.fontSize !== void 0 && (t.fontSize = e.fontSize), e.fontWeight !== void 0 && (t.fontWeight = e.fontWeight), e.fontStyle !== void 0 && (t.fontStyle = e.fontStyle), e.underline !== void 0 && (t.underline = e.underline), e.linethrough !== void 0 && (t.linethrough = e.linethrough), e.fill !== void 0 && (t.fill = e.fill), e.stroke !== void 0 && (t.stroke = e.stroke), e.strokeWidth !== void 0 && (t.strokeWidth = e.strokeWidth), t;
7446
- }, ai = ({ textbox: e, lineIndices: t, updates: n }) => {
7470
+ }, oi = ({ textbox: e, lineIndices: t, updates: n }) => {
7447
7471
  if (!t.length) return !1;
7448
7472
  let { fill: r, fontFamily: i, fontSize: a, fontStyle: o, fontWeight: s, linethrough: c, stroke: l, strokeWidth: u, underline: d } = n;
7449
7473
  if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0 || l !== void 0 || u !== void 0 || d !== void 0)) return !1;
@@ -7455,12 +7479,12 @@ var zr = class {
7455
7479
  i !== void 0 && g?.fontFamily !== i && (_.fontFamily = i, v = !0), a !== void 0 && g?.fontSize !== a && (_.fontSize = a, v = !0), s !== void 0 && g?.fontWeight !== s && (_.fontWeight = s, v = !0), o !== void 0 && g?.fontStyle !== o && (_.fontStyle = o, v = !0), d !== void 0 && g?.underline !== d && (_.underline = d, v = !0), c !== void 0 && g?.linethrough !== c && (_.linethrough = c, v = !0), r !== void 0 && g?.fill !== r && (_.fill = r, v = !0), l !== void 0 && (l === null && g?.stroke !== void 0 && (delete _.stroke, v = !0), l !== null && g?.stroke !== l && (_.stroke = l, v = !0)), u !== void 0 && g?.strokeWidth !== u && (_.strokeWidth = u, v = !0), v && (h ||= (p = { ...p }, !0), p[n] = _, m = !0);
7456
7480
  }
7457
7481
  return m && (e.lineFontDefaults = p), m;
7458
- }, oi = ({ lineStyles: e, lineDefaults: t }) => {
7482
+ }, si = ({ lineStyles: e, lineDefaults: t }) => {
7459
7483
  if (!e) return {
7460
7484
  lineStyles: e,
7461
7485
  changed: !1
7462
7486
  };
7463
- let n = ii({ lineDefaults: t }), r = Object.keys(n);
7487
+ let n = ai({ lineDefaults: t }), r = Object.keys(n);
7464
7488
  if (!r.length) return {
7465
7489
  lineStyles: e,
7466
7490
  changed: !1
@@ -7484,7 +7508,7 @@ var zr = class {
7484
7508
  lineStyles: e,
7485
7509
  changed: !1
7486
7510
  };
7487
- }, si = ({ cleanup: e, lineCount: t, styles: n }) => {
7511
+ }, ci = ({ cleanup: e, lineCount: t, styles: n }) => {
7488
7512
  if (!e) return {
7489
7513
  styles: n,
7490
7514
  changed: !1
@@ -7504,7 +7528,7 @@ var zr = class {
7504
7528
  for (let t = 0; t < e.lineDefaults.length; t += 1) {
7505
7529
  let n = e.lineDefaults[t];
7506
7530
  if (!n) continue;
7507
- let a = oi({
7531
+ let a = si({
7508
7532
  lineStyles: r,
7509
7533
  lineDefaults: n
7510
7534
  });
@@ -7519,19 +7543,19 @@ var zr = class {
7519
7543
  styles: a,
7520
7544
  changed: !0
7521
7545
  };
7522
- }, ci = ({ textbox: e }) => {
7546
+ }, li = ({ textbox: e }) => {
7523
7547
  let { fontFamily: t, fontSize: n, fontStyle: r, fontWeight: i, fill: a, stroke: o, strokeWidth: s, linethrough: c, underline: l } = e, u = {}, d = typeof a == "string" ? a : void 0, f = typeof o == "string" ? o : void 0;
7524
7548
  return t !== void 0 && (u.fontFamily = t), n !== void 0 && (u.fontSize = n), i !== void 0 && (u.fontWeight = i), r !== void 0 && (u.fontStyle = r), l !== void 0 && (u.underline = l), c !== void 0 && (u.linethrough = c), d !== void 0 && (u.fill = d), f !== void 0 && (u.stroke = f), s !== void 0 && (u.strokeWidth = s), u;
7525
- }, li = ({ sourceDefaults: e, globalLineDefaults: t }) => {
7549
+ }, ui = ({ sourceDefaults: e, globalLineDefaults: t }) => {
7526
7550
  let n = {};
7527
7551
  return e?.fontFamily === void 0 ? t.fontFamily !== void 0 && (n.fontFamily = t.fontFamily) : n.fontFamily = e.fontFamily, e?.fontSize === void 0 ? t.fontSize !== void 0 && (n.fontSize = t.fontSize) : n.fontSize = e.fontSize, e?.fontWeight === void 0 ? t.fontWeight !== void 0 && (n.fontWeight = t.fontWeight) : n.fontWeight = e.fontWeight, e?.fontStyle === void 0 ? t.fontStyle !== void 0 && (n.fontStyle = t.fontStyle) : n.fontStyle = e.fontStyle, e?.underline === void 0 ? t.underline !== void 0 && (n.underline = t.underline) : n.underline = e.underline, e?.linethrough === void 0 ? t.linethrough !== void 0 && (n.linethrough = t.linethrough) : n.linethrough = e.linethrough, e?.fill === void 0 ? t.fill !== void 0 && (n.fill = t.fill) : n.fill = e.fill, e?.stroke === void 0 ? t.stroke !== void 0 && (n.stroke = t.stroke) : n.stroke = e.stroke, e?.strokeWidth === void 0 ? n.stroke !== void 0 && t.strokeWidth !== void 0 && (n.strokeWidth = t.strokeWidth) : n.strokeWidth = e.strokeWidth, n;
7528
- }, ui = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
7552
+ }, di = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
7529
7553
  let r = e.length;
7530
7554
  if (r === 0) return {
7531
7555
  lineStyles: t,
7532
7556
  changed: !1
7533
7557
  };
7534
- let i = ii({ lineDefaults: n }), a = Object.keys(i);
7558
+ let i = ai({ lineDefaults: n }), a = Object.keys(i);
7535
7559
  if (!a.length) return {
7536
7560
  lineStyles: t,
7537
7561
  changed: !1
@@ -7557,8 +7581,8 @@ var zr = class {
7557
7581
  lineStyles: o,
7558
7582
  changed: s
7559
7583
  };
7560
- }, di = ({ deletedLineDefaultsCleanup: e, globalLineDefaults: t, lineFontDefaults: n, lines: r, styles: i }) => {
7561
- let a = n, o = !1, s = !1, c = i, l = !1, u = !1, d, f = si({
7584
+ }, fi = ({ deletedLineDefaultsCleanup: e, globalLineDefaults: t, lineFontDefaults: n, lines: r, styles: i }) => {
7585
+ let a = n, o = !1, s = !1, c = i, l = !1, u = !1, d, f = ci({
7562
7586
  styles: c ?? {},
7563
7587
  lineCount: r.length,
7564
7588
  cleanup: e
@@ -7569,7 +7593,7 @@ var zr = class {
7569
7593
  if (i && (d = i), n.length !== 0) {
7570
7594
  let t = i;
7571
7595
  if (!t && d && (t = { ...d }, a || (a = {}, s = !0), s ||= (a = { ...a }, !0), a[e] = t, o = !0), t) {
7572
- let r = ui({
7596
+ let r = di({
7573
7597
  lineText: n,
7574
7598
  lineStyles: c ? c[e] : void 0,
7575
7599
  lineDefaults: t
@@ -7578,12 +7602,12 @@ var zr = class {
7578
7602
  }
7579
7603
  continue;
7580
7604
  }
7581
- let f = li({
7605
+ let f = ui({
7582
7606
  sourceDefaults: i ?? d,
7583
7607
  globalLineDefaults: t
7584
7608
  });
7585
7609
  !i && Object.keys(f).length && (a || (a = {}, s = !0), s ||= (a = { ...a }, !0), a[e] = f, o = !0, d = f), i && (d = i);
7586
- let p = ii({ lineDefaults: f }), m = Object.keys(p).length > 0;
7610
+ let p = ai({ lineDefaults: f }), m = Object.keys(p).length > 0;
7587
7611
  (m || c && c[e]) && (c || (c = {}, u = !0), u ||= (c = { ...c }, !0), m && (c[e] = { 0: p }), !m && c[e] && delete c[e], l = !0);
7588
7612
  }
7589
7613
  return {
@@ -7593,8 +7617,8 @@ var zr = class {
7593
7617
  stylesChanged: l
7594
7618
  };
7595
7619
  };
7596
- function fi({ textbox: e }) {
7597
- let t = (e.text ?? "").split("\n"), n = ci({ textbox: e }), r = di({
7620
+ function pi({ textbox: e }) {
7621
+ let t = (e.text ?? "").split("\n"), n = li({ textbox: e }), r = fi({
7598
7622
  lines: t,
7599
7623
  styles: e.styles,
7600
7624
  lineFontDefaults: e.lineFontDefaults,
@@ -7606,7 +7630,7 @@ function fi({ textbox: e }) {
7606
7630
  if (!Number.isInteger(t) || t < 0) continue;
7607
7631
  let o = r.styles[e];
7608
7632
  if (!o) continue;
7609
- let s = oi({
7633
+ let s = si({
7610
7634
  lineStyles: o,
7611
7635
  lineDefaults: i?.[t] ?? n
7612
7636
  });
@@ -7617,31 +7641,31 @@ function fi({ textbox: e }) {
7617
7641
  styles: a
7618
7642
  };
7619
7643
  }
7620
- var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7621
- let r = ri({
7644
+ var mi = ({ currentText: e, previousText: t, textbox: n }) => {
7645
+ let r = ii({
7622
7646
  lineFontDefaults: n.lineFontDefaults,
7623
7647
  previousText: t,
7624
7648
  currentText: e
7625
- }), i = di({
7649
+ }), i = fi({
7626
7650
  lines: e.split("\n"),
7627
7651
  styles: n.styles,
7628
7652
  lineFontDefaults: r.lineFontDefaults,
7629
7653
  deletedLineDefaultsCleanup: r.deletedLineDefaultsCleanup,
7630
- globalLineDefaults: ci({ textbox: n })
7654
+ globalLineDefaults: li({ textbox: n })
7631
7655
  });
7632
7656
  return {
7633
7657
  ...i,
7634
7658
  lineFontDefaultsChanged: r.changed || i.lineFontDefaultsChanged
7635
7659
  };
7636
- }, mi = ({ textbox: e }) => {
7637
- let t = di({
7660
+ }, hi = ({ textbox: e }) => {
7661
+ let t = fi({
7638
7662
  lines: (e.text ?? "").split("\n"),
7639
7663
  styles: e.styles,
7640
7664
  lineFontDefaults: e.lineFontDefaults,
7641
- globalLineDefaults: ci({ textbox: e })
7665
+ globalLineDefaults: li({ textbox: e })
7642
7666
  }), n = !1;
7643
7667
  return t.lineFontDefaultsChanged && (e.lineFontDefaults = t.lineFontDefaults, n = !0), t.stylesChanged && (e.styles = t.styles, e.dirty = !0, n = !0), n;
7644
- }, hi = ({ lineFontDefaults: e }) => {
7668
+ }, gi = ({ lineFontDefaults: e }) => {
7645
7669
  if (!e) return;
7646
7670
  let t = {};
7647
7671
  for (let n in e) {
@@ -7652,7 +7676,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7652
7676
  i && (t[r] = { ...i });
7653
7677
  }
7654
7678
  return t;
7655
- }, gi = ({ lineFontDefaults: e, scale: t }) => {
7679
+ }, _i = ({ lineFontDefaults: e, scale: t }) => {
7656
7680
  if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
7657
7681
  let n = {}, r = !1, i = !1;
7658
7682
  for (let a in e) {
@@ -7669,18 +7693,18 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7669
7693
  n[o] = c, r = !0;
7670
7694
  }
7671
7695
  if (!(!r || !i)) return n;
7672
- }, _i = ({ textbox: e, text: t }) => {
7696
+ }, vi = ({ textbox: e, text: t }) => {
7673
7697
  let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
7674
7698
  for (let t = 0; t < r; t += 1) {
7675
7699
  let n = e.getLineWidth(t);
7676
7700
  n > i && (i = n);
7677
7701
  }
7678
7702
  return i;
7679
- }, vi = ({ origin: e, size: t }) => e === "left" || e === "top" || e === 0 ? 0 : e === "right" || e === "bottom" || e === 1 ? t : t / 2, yi = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
7680
- let r = e.width ?? e.calcTextWidth() ?? 0, i = e.height ?? e.calcTextHeight() ?? 0, a = e.paddingTop ?? 0, o = e.paddingRight ?? 0, s = e.paddingBottom ?? 0, c = e.paddingLeft ?? 0, l = -r / 2 + (c - o) / 2, u = -i / 2 + (a - s) / 2, d = new m(l + vi({
7703
+ }, yi = ({ origin: e, size: t }) => e === "left" || e === "top" || e === 0 ? 0 : e === "right" || e === "bottom" || e === 1 ? t : t / 2, bi = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
7704
+ let r = e.width ?? e.calcTextWidth() ?? 0, i = e.height ?? e.calcTextHeight() ?? 0, a = e.paddingTop ?? 0, o = e.paddingRight ?? 0, s = e.paddingBottom ?? 0, c = e.paddingLeft ?? 0, l = -r / 2 + (c - o) / 2, u = -i / 2 + (a - s) / 2, d = new m(l + yi({
7681
7705
  origin: t,
7682
7706
  size: r
7683
- }), u + vi({
7707
+ }), u + yi({
7684
7708
  origin: n,
7685
7709
  size: i
7686
7710
  })), f = e.getPointByOrigin("center", "center"), p = e, h = typeof p.calcTransformMatrix == "function" ? p.calcTransformMatrix() : null, g = Array.isArray(h) ? new m(d.x * h[0] + d.y * h[2] + f.x, d.x * h[1] + d.y * h[3] + f.y) : new m(f.x + d.x, f.y + d.y);
@@ -7690,13 +7714,13 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7690
7714
  originX: t,
7691
7715
  originY: n
7692
7716
  };
7693
- }, bi = ({ textbox: e, montageLeft: t, montageRight: n }) => {
7717
+ }, xi = ({ textbox: e, montageLeft: t, montageRight: n }) => {
7694
7718
  e.setCoords();
7695
7719
  let r = e.getBoundingRect(), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
7696
7720
  if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
7697
7721
  let s = 0;
7698
7722
  return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
7699
- }, xi = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Si = ({ stylesList: e }) => {
7723
+ }, Si = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Ci = ({ stylesList: e }) => {
7700
7724
  let t = e.length;
7701
7725
  if (!t) return !1;
7702
7726
  for (let n = 0; n < t; n += 1) {
@@ -7706,16 +7730,16 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7706
7730
  if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
7707
7731
  }
7708
7732
  return !1;
7709
- }, Ci = ({ textbox: e }) => {
7710
- let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s = xi({
7733
+ }, wi = ({ textbox: e }) => {
7734
+ let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s = Si({
7711
7735
  rawValue: t,
7712
7736
  calculatedValue: a
7713
- }), c = xi({
7737
+ }), c = Si({
7714
7738
  rawValue: n,
7715
7739
  calculatedValue: o
7716
7740
  }), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
7717
7741
  return l !== null && l !== s && (d.width = Math.max(0, l)), u !== null && u !== c && (d.height = Math.max(0, u)), Object.keys(d).length ? (e.set(d), !0) : !1;
7718
- }, wi = ({ textbox: e }) => {
7742
+ }, Ti = ({ textbox: e }) => {
7719
7743
  let t = e.width ?? e.calcTextWidth(), n = e.fontSize ?? 16, { styles: r = {} } = e, { lineFontDefaults: i } = e, { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0 } = e, { radiusTopLeft: l = 0, radiusTopRight: u = 0, radiusBottomRight: d = 0, radiusBottomLeft: f = 0 } = e;
7720
7744
  return {
7721
7745
  width: t,
@@ -7733,9 +7757,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7733
7757
  bottomLeft: f
7734
7758
  },
7735
7759
  styles: JSON.parse(JSON.stringify(r)),
7736
- lineFontDefaults: hi({ lineFontDefaults: i })
7760
+ lineFontDefaults: gi({ lineFontDefaults: i })
7737
7761
  };
7738
- }, Ti = ({ base: e }) => {
7762
+ }, Ei = ({ base: e }) => {
7739
7763
  let t = 1 / Math.max(1, e.width), n = [e.fontSize];
7740
7764
  Object.values(e.styles).forEach((e) => {
7741
7765
  Object.values(e).forEach((e) => {
@@ -7752,7 +7776,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7752
7776
  fontScale: r,
7753
7777
  proportionalScale: Math.max(t, r)
7754
7778
  };
7755
- }, Ei = ({ textbox: e, base: t, scale: n, shouldScaleFontSize: r = !0, shouldScalePadding: i = !0, shouldScaleRadii: a = !0 }) => {
7779
+ }, Di = ({ textbox: e, base: t, scale: n, shouldScaleFontSize: r = !0, shouldScalePadding: i = !0, shouldScaleRadii: a = !0 }) => {
7756
7780
  let { fontSize: o, padding: s, radii: c, styles: l, lineFontDefaults: u } = t, d = Math.max(Math.min(8, o), o * n), f = Object.keys(l).length > 0, p;
7757
7781
  if (r && f) {
7758
7782
  let e = {};
@@ -7771,7 +7795,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7771
7795
  }), Object.keys(e).length && (p = e);
7772
7796
  }
7773
7797
  let m;
7774
- r && (m = gi({
7798
+ r && (m = _i({
7775
7799
  lineFontDefaults: u,
7776
7800
  scale: n
7777
7801
  }));
@@ -7797,9 +7821,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7797
7821
  radiusBottomRight: g.bottomRight,
7798
7822
  radiusBottomLeft: g.bottomLeft
7799
7823
  });
7800
- }, Di = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, anchorPlacement: o, shouldScaleFontSize: s, shouldScalePadding: c, shouldScaleRadii: l, shouldDisableAutoExpandOnHorizontalChange: u = !1, shouldRoundDimensions: d = !0 }) => {
7801
- let { width: f } = n, p = Math.max(1, f * r), h = d ? Math.max(1, Math.round(p)) : p, g = e.width ?? f, _ = Math.abs(h - g) > Kr;
7802
- u && _ && (e.autoExpand = !1), Ei({
7824
+ }, Oi = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, anchorPlacement: o, shouldScaleFontSize: s, shouldScalePadding: c, shouldScaleRadii: l, shouldDisableAutoExpandOnHorizontalChange: u = !1, shouldRoundDimensions: d = !0 }) => {
7825
+ let { width: f } = n, p = Math.max(1, f * r), h = d ? Math.max(1, Math.round(p)) : p, g = e.width ?? f, _ = Math.abs(h - g) > qr;
7826
+ u && _ && (e.autoExpand = !1), Di({
7803
7827
  textbox: e,
7804
7828
  base: n,
7805
7829
  scale: i,
@@ -7818,7 +7842,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7818
7842
  } finally {
7819
7843
  e.shouldRoundDimensionsOnInit = v;
7820
7844
  }
7821
- let y = d ? Ci({ textbox: e }) : !1;
7845
+ let y = d ? wi({ textbox: e }) : !1;
7822
7846
  return y && (e.dirty = !0), o ? (e.set({
7823
7847
  originX: a.originX,
7824
7848
  originY: a.originY
@@ -7832,7 +7856,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7832
7856
  appliedWidth: e.width ?? h,
7833
7857
  dimensionsRounded: y
7834
7858
  });
7835
- }, Oi = {
7859
+ }, ki = {
7836
7860
  angle: 0,
7837
7861
  skewX: 0,
7838
7862
  skewY: 0,
@@ -7845,7 +7869,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
7845
7869
  top: 0,
7846
7870
  originX: "left",
7847
7871
  originY: "top"
7848
- }, ki = class {
7872
+ }, Ai = class {
7849
7873
  constructor({ runtime: e }) {
7850
7874
  this.runtime = e;
7851
7875
  }
@@ -8073,9 +8097,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8073
8097
  }
8074
8098
  _applyRehydratedTextScale({ group: e, text: t, textScale: n }) {
8075
8099
  let r = Number.isFinite(n) && n > 0 ? n : 1;
8076
- Math.abs(r - 1) <= 1e-4 || (Ei({
8100
+ Math.abs(r - 1) <= 1e-4 || (Di({
8077
8101
  textbox: t,
8078
- base: wi({ textbox: t }),
8102
+ base: Ti({ textbox: t }),
8079
8103
  scale: r
8080
8104
  }), e.shapePaddingTop = Math.max(0, (e.shapePaddingTop ?? 0) * r), e.shapePaddingRight = Math.max(0, (e.shapePaddingRight ?? 0) * r), e.shapePaddingBottom = Math.max(0, (e.shapePaddingBottom ?? 0) * r), e.shapePaddingLeft = Math.max(0, (e.shapePaddingLeft ?? 0) * r));
8081
8105
  }
@@ -8303,7 +8327,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8303
8327
  width: Math.max(1, e.width ?? t),
8304
8328
  align: n
8305
8329
  });
8306
- return s.set(Oi), this.runtime.applyTextUpdates({
8330
+ return s.set(ki), this.runtime.applyTextUpdates({
8307
8331
  textNode: s,
8308
8332
  text: r,
8309
8333
  textStyle: i,
@@ -8345,7 +8369,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8345
8369
  }
8346
8370
  _applyPreparedTextState({ preparedUpdate: e }) {
8347
8371
  let { currentGroup: t, currentTextNode: n, text: r, textStyle: i, horizontalAlign: a, syncLineStylesWithText: o } = e;
8348
- this.runtime.detachShapeGroupAutoLayout({ group: t }), n.set(Oi), this.runtime.applyTextUpdates({
8372
+ this.runtime.detachShapeGroupAutoLayout({ group: t }), n.set(ki), this.runtime.applyTextUpdates({
8349
8373
  textNode: n,
8350
8374
  text: r,
8351
8375
  textStyle: i,
@@ -8399,9 +8423,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8399
8423
  let { currentGroup: t, currentTextNode: n, placement: r, resolvedLayoutWidth: i, resolvedLayoutHeight: a, shouldFitReplacementToPreset: o } = e;
8400
8424
  o && (t.shapeManualBaseWidth = Math.max(1, t.shapeBaseWidth ?? i), t.shapeManualBaseHeight = Math.max(1, t.shapeBaseHeight ?? a)), n.isEditing && this.runtime.editingPlacements.set(t, r);
8401
8425
  }
8402
- }, Ai = "#B4B7BD", ji = 0, Mi = 1, Ni = class {
8426
+ }, ji = "#B4B7BD", Mi = 0, Ni = 1, Pi = class {
8403
8427
  constructor({ editor: e }) {
8404
- this.editor = e, Je(), this.scalingController = new Br({ canvas: e.canvas }), this.editingController = new Vr({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new Gr({ canvas: e.canvas }), this.layoutController = new Wr({ editor: this.editor }), this.mutationController = new ki({ runtime: {
8428
+ this.editor = e, Je(), this.scalingController = new Vr({ canvas: e.canvas }), this.editingController = new Hr({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new Kr({ canvas: e.canvas }), this.layoutController = new Gr({ editor: this.editor }), this.mutationController = new Ai({ runtime: {
8405
8429
  editor: this.editor,
8406
8430
  lifecycleController: this.lifecycleController,
8407
8431
  editingPlacements: this.editingPlacements,
@@ -8425,7 +8449,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8425
8449
  beginMutation: () => this._beginMutation(),
8426
8450
  endMutation: (e) => this._endMutation(e),
8427
8451
  isOnCanvas: (e) => this._isOnCanvas(e)
8428
- } }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this.eventController = new Ur({ runtime: {
8452
+ } }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this.eventController = new Wr({ runtime: {
8429
8453
  editor: this.editor,
8430
8454
  scalingController: this.scalingController,
8431
8455
  editingController: this.editingController,
@@ -8908,11 +8932,11 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8908
8932
  _resolveShapeStyle({ options: e, fallback: t }) {
8909
8933
  let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
8910
8934
  return {
8911
- fill: n ?? t?.shapeFill ?? Ai,
8935
+ fill: n ?? t?.shapeFill ?? ji,
8912
8936
  stroke: r ?? t?.shapeStroke ?? null,
8913
- strokeWidth: i ?? t?.shapeStrokeWidth ?? ji,
8937
+ strokeWidth: i ?? t?.shapeStrokeWidth ?? Mi,
8914
8938
  strokeDashArray: s ?? null,
8915
- opacity: o ?? t?.shapeOpacity ?? Mi
8939
+ opacity: o ?? t?.shapeOpacity ?? Ni
8916
8940
  };
8917
8941
  }
8918
8942
  _collectShapeGroupsFromTarget({ target: t, subTargets: n = [] }) {
@@ -8968,7 +8992,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8968
8992
  }
8969
8993
  return null;
8970
8994
  }
8971
- }, Pi = ({ rootObject: t, enableEvented: n = !0 }) => {
8995
+ }, Fi = ({ rootObject: t, enableEvented: n = !0 }) => {
8972
8996
  let r = [{
8973
8997
  object: t,
8974
8998
  enableEvented: n
@@ -8982,7 +9006,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
8982
9006
  enableEvented: o
8983
9007
  });
8984
9008
  }
8985
- }, Fi = class {
9009
+ }, Ii = class {
8986
9010
  constructor({ editor: e }) {
8987
9011
  this.editor = e, this.clipboard = null;
8988
9012
  }
@@ -9140,7 +9164,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9140
9164
  if (!n || n.locked) return !1;
9141
9165
  try {
9142
9166
  let e = await n.clone(Pt);
9143
- return Pi({ rootObject: e }), e.set({
9167
+ return Fi({ rootObject: e }), e.set({
9144
9168
  left: e.left + 10,
9145
9169
  top: e.top + 10
9146
9170
  }), this._materializeCloneGeometry({ clonedObject: e }), this._addClonedObjectToCanvas(e), t.fire("editor:object-duplicated", {
@@ -9207,7 +9231,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9207
9231
  if (!this.clipboard) return !1;
9208
9232
  try {
9209
9233
  let t = await this.clipboard.clone(Pt);
9210
- return e.discardActiveObject(), Pi({ rootObject: t }), t.set({
9234
+ return e.discardActiveObject(), Fi({ rootObject: t }), t.set({
9211
9235
  left: t.left + 10,
9212
9236
  top: t.top + 10
9213
9237
  }), this._materializeCloneGeometry({ clonedObject: t }), this._addClonedObjectToCanvas(t), e.fire("editor:object-pasted", {
@@ -9226,7 +9250,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9226
9250
  }), !1;
9227
9251
  }
9228
9252
  }
9229
- }, Ii = class t {
9253
+ }, Li = class t {
9230
9254
  constructor({ editor: e }) {
9231
9255
  this.editor = e;
9232
9256
  }
@@ -9291,7 +9315,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9291
9315
  !(n instanceof v) || !n.isEditing || n.exitEditing();
9292
9316
  }
9293
9317
  }
9294
- }, Li = class {
9318
+ }, Ri = class {
9295
9319
  constructor({ editor: e }) {
9296
9320
  this.editor = e;
9297
9321
  }
@@ -9357,7 +9381,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9357
9381
  i.resumeHistory(), n || i.saveState();
9358
9382
  }
9359
9383
  }
9360
- }, Ri = class t {
9384
+ }, zi = class t {
9361
9385
  constructor({ editor: e }) {
9362
9386
  this.lastSelection = [], this.isCtrlSelectionBoxActive = !1, this.isSelectionMergeInProgress = !1, this.editor = e, this.selectionKey = this._resolveSelectionKey(), this.handleTextEditingEnteredBound = this._handleTextEditingEntered.bind(this), this.handleTextEditingExitedBound = this._handleTextEditingExited.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.handleSelectionMergeBound = this._handleSelectionMerge.bind(this), this.handleSelectionChangeBound = this._handleSelectionChange.bind(this), this.handleSelectionClearedBound = this._handleSelectionCleared.bind(this), this.handleSelectionBoxStartBound = this._handleSelectionBoxStart.bind(this), this.handleSelectionBoxEndBound = this._handleSelectionBoxEnd.bind(this), this._applySelectionKey({ selectionKey: this.selectionKey }), this._bindEvents();
9363
9387
  }
@@ -9551,7 +9575,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9551
9575
  let { options: e } = this.editor, { selectionKey: t } = e;
9552
9576
  return t === void 0 ? ["ctrlKey", "metaKey"] : t;
9553
9577
  }
9554
- }, zi = class e {
9578
+ }, Bi = class e {
9555
9579
  constructor({ editor: e }) {
9556
9580
  this.editor = e;
9557
9581
  }
@@ -9591,7 +9615,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9591
9615
  };
9592
9616
  return i.fire("editor:objects-deleted", l), l;
9593
9617
  }
9594
- }, Bi = {
9618
+ }, Vi = {
9595
9619
  IMAGE_MANAGER: {
9596
9620
  INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
9597
9621
  INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
@@ -9629,7 +9653,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9629
9653
  INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
9630
9654
  APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
9631
9655
  }
9632
- }, Vi = class e {
9656
+ }, Hi = class e {
9633
9657
  constructor({ editor: e }) {
9634
9658
  this._buffer = [], this.editor = e;
9635
9659
  }
@@ -9687,9 +9711,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9687
9711
  }), this.editor.canvas.fire("editor:warning", s);
9688
9712
  }
9689
9713
  static isValidErrorCode(e) {
9690
- return e ? Object.values(Bi).some((t) => Object.values(t).includes(e)) : !1;
9714
+ return e ? Object.values(Vi).some((t) => Object.values(t).includes(e)) : !1;
9691
9715
  }
9692
- }, Hi = class {
9716
+ }, Ui = class {
9693
9717
  constructor({ editor: e }) {
9694
9718
  this.currentBounds = null, this.editor = e;
9695
9719
  }
@@ -9738,32 +9762,32 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9738
9762
  updateBounds() {
9739
9763
  this.currentBounds = this.calculatePanBounds();
9740
9764
  }
9741
- }, Ui = ({ textbox: e }) => {
9765
+ }, Wi = ({ textbox: e }) => {
9742
9766
  if (!e.isEditing) return null;
9743
9767
  let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
9744
9768
  return t === n ? null : {
9745
9769
  start: Math.min(t, n),
9746
9770
  end: Math.max(t, n)
9747
9771
  };
9748
- }, Wi = ({ textbox: e }) => {
9772
+ }, Gi = ({ textbox: e }) => {
9749
9773
  let t = e.text?.length ?? 0;
9750
9774
  return t <= 0 ? null : {
9751
9775
  start: 0,
9752
9776
  end: t
9753
9777
  };
9754
- }, Gi = ({ textbox: e, range: t }) => {
9778
+ }, Ki = ({ textbox: e, range: t }) => {
9755
9779
  if (!t) return !1;
9756
9780
  let n = e.text?.length ?? 0;
9757
9781
  return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
9758
- }, Ki = ({ textbox: e, styles: t, range: n }) => {
9782
+ }, qi = ({ textbox: e, styles: t, range: n }) => {
9759
9783
  if (!t || !Object.keys(t).length) return !1;
9760
9784
  let { start: r, end: i } = n;
9761
9785
  return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
9762
- }, qi = ({ textbox: e, range: t, property: n }) => {
9786
+ }, Ji = ({ textbox: e, range: t, property: n }) => {
9763
9787
  if (!t) return;
9764
9788
  let r = e.getSelectionStyles(t.start, t.end, !0);
9765
9789
  if (r.length) return r[0]?.[n];
9766
- }, Ji = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", Yi = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Xi = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Z = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), Zi = class e extends v {
9790
+ }, Yi = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", Xi = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Zi = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Qi = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), $i = class e extends v {
9767
9791
  static {
9768
9792
  this.type = "background-textbox";
9769
9793
  }
@@ -9800,7 +9824,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9800
9824
  ];
9801
9825
  }
9802
9826
  constructor(e, t = {}) {
9803
- if (super(e, t), this.backgroundOpacity = t.backgroundOpacity ?? 1, this.lineFontDefaults = t.lineFontDefaults ?? void 0, this.paddingTop = t.paddingTop ?? 0, this.paddingRight = t.paddingRight ?? 0, this.paddingBottom = t.paddingBottom ?? 0, this.paddingLeft = t.paddingLeft ?? 0, this.radiusTopLeft = t.radiusTopLeft ?? 0, this.radiusTopRight = t.radiusTopRight ?? 0, this.radiusBottomRight = t.radiusBottomRight ?? 0, this.radiusBottomLeft = t.radiusBottomLeft ?? 0, mi({ textbox: this })) {
9827
+ if (super(e, t), this.backgroundOpacity = t.backgroundOpacity ?? 1, this.lineFontDefaults = t.lineFontDefaults ?? void 0, this.paddingTop = t.paddingTop ?? 0, this.paddingRight = t.paddingRight ?? 0, this.paddingBottom = t.paddingBottom ?? 0, this.paddingLeft = t.paddingLeft ?? 0, this.radiusTopLeft = t.radiusTopLeft ?? 0, this.radiusTopRight = t.radiusTopRight ?? 0, this.radiusBottomRight = t.radiusBottomRight ?? 0, this.radiusBottomLeft = t.radiusBottomLeft ?? 0, hi({ textbox: this })) {
9804
9828
  this.initDimensions(), this.dirty = !0;
9805
9829
  return;
9806
9830
  }
@@ -9839,7 +9863,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9839
9863
  });
9840
9864
  }
9841
9865
  toObject(e = []) {
9842
- let t = super.toObject(e), { lineFontDefaults: n, styles: r } = fi({ textbox: this });
9866
+ let t = super.toObject(e), { lineFontDefaults: n, styles: r } = pi({ textbox: this });
9843
9867
  return {
9844
9868
  ...t,
9845
9869
  backgroundOpacity: this.backgroundOpacity,
@@ -9907,7 +9931,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9907
9931
  this._removeShadow(e);
9908
9932
  }
9909
9933
  _getDecorationColorAt(e, t) {
9910
- let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Yi({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Ji({
9934
+ let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Xi({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Yi({
9911
9935
  strokeColor: i,
9912
9936
  width: r
9913
9937
  });
@@ -9923,22 +9947,22 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9923
9947
  _getCornerRadii({ width: e, height: t }) {
9924
9948
  let n = e / 2, r = t / 2, i = Math.min(n, r);
9925
9949
  return {
9926
- bottomLeft: Z({
9950
+ bottomLeft: Qi({
9927
9951
  value: this.radiusBottomLeft ?? 0,
9928
9952
  min: 0,
9929
9953
  max: i
9930
9954
  }),
9931
- bottomRight: Z({
9955
+ bottomRight: Qi({
9932
9956
  value: this.radiusBottomRight ?? 0,
9933
9957
  min: 0,
9934
9958
  max: i
9935
9959
  }),
9936
- topLeft: Z({
9960
+ topLeft: Qi({
9937
9961
  value: this.radiusTopLeft ?? 0,
9938
9962
  min: 0,
9939
9963
  max: i
9940
9964
  }),
9941
- topRight: Z({
9965
+ topRight: Qi({
9942
9966
  value: this.radiusTopRight ?? 0,
9943
9967
  min: 0,
9944
9968
  max: i
@@ -9956,7 +9980,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9956
9980
  _getEffectiveBackgroundFill() {
9957
9981
  let e = this.backgroundColor;
9958
9982
  if (!e) return null;
9959
- let t = Z({
9983
+ let t = Qi({
9960
9984
  value: this.backgroundOpacity ?? 1,
9961
9985
  min: 0,
9962
9986
  max: 1
@@ -9969,19 +9993,19 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9969
9993
  return r.setAlpha(t), r.toRgba();
9970
9994
  }
9971
9995
  static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
9972
- let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Z({
9996
+ let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Qi({
9973
9997
  value: c,
9974
9998
  min: 0,
9975
9999
  max: a
9976
- }), p = Z({
10000
+ }), p = Qi({
9977
10001
  value: l,
9978
10002
  min: 0,
9979
10003
  max: a
9980
- }), m = Z({
10004
+ }), m = Qi({
9981
10005
  value: u,
9982
10006
  min: 0,
9983
10007
  max: a
9984
- }), h = Z({
10008
+ }), h = Qi({
9985
10009
  value: d,
9986
10010
  min: 0,
9987
10011
  max: a
@@ -9992,9 +10016,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
9992
10016
  let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
9993
10017
  n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
9994
10018
  }
9995
- }, Qi = () => {
9996
- b?.setClass && b.setClass(Zi, "background-textbox");
9997
- }, $i = class {
10019
+ }, ea = () => {
10020
+ b?.setClass && b.setClass($i, "background-textbox");
10021
+ }, ta = class {
9998
10022
  constructor({ runtime: e }) {
9999
10023
  this.runtime = e;
10000
10024
  }
@@ -10058,16 +10082,16 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10058
10082
  };
10059
10083
  }
10060
10084
  _createSelectionContext({ textbox: e, currentText: t, selectionRangeOverride: n }) {
10061
- let r = n === void 0 ? Ui({ textbox: e }) : Jr({
10085
+ let r = n === void 0 ? Wi({ textbox: e }) : Yr({
10062
10086
  text: t,
10063
10087
  range: n
10064
- }), i = r ? Yr({
10088
+ }), i = r ? Xr({
10065
10089
  textbox: e,
10066
10090
  range: r
10067
- }) : null, a = Gi({
10091
+ }) : null, a = Ki({
10068
10092
  textbox: e,
10069
10093
  range: r
10070
- }), o = Gi({
10094
+ }), o = Ki({
10071
10095
  textbox: e,
10072
10096
  range: i
10073
10097
  }), s = !r || a;
@@ -10155,17 +10179,17 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10155
10179
  t.resolvedStrokeColor = i.stroke, t.resolvedStrokeWidth = i.strokeWidth, r.selectionRange && (t.selectionStyles.stroke = i.stroke, t.selectionStyles.strokeWidth = i.strokeWidth), r.shouldUpdateWholeObject && (t.updates.stroke = i.stroke, t.updates.strokeWidth = i.strokeWidth, r.shouldApplyWholeTextStyles && (t.wholeTextStyles.stroke = i.stroke, t.wholeTextStyles.strokeWidth = i.strokeWidth));
10156
10180
  }
10157
10181
  _resolveStrokeUpdate({ textbox: e, selectionRange: t, strokeColor: n, strokeWidth: r }) {
10158
- let i = t ? qi({
10182
+ let i = t ? Ji({
10159
10183
  textbox: e,
10160
10184
  range: t,
10161
10185
  property: "strokeWidth"
10162
- }) : void 0, a = t ? qi({
10186
+ }) : void 0, a = t ? Ji({
10163
10187
  textbox: e,
10164
10188
  range: t,
10165
10189
  property: "stroke"
10166
- }) : void 0, o = typeof i == "number" ? i : void 0, s = typeof a == "string" ? a : void 0, c = typeof e.stroke == "string" ? e.stroke : void 0, l = Yi({ width: r ?? o ?? e.strokeWidth ?? 0 });
10190
+ }) : void 0, o = typeof i == "number" ? i : void 0, s = typeof a == "string" ? a : void 0, c = typeof e.stroke == "string" ? e.stroke : void 0, l = Xi({ width: r ?? o ?? e.strokeWidth ?? 0 });
10167
10191
  return {
10168
- stroke: Ji({
10192
+ stroke: Yi({
10169
10193
  strokeColor: n ?? s ?? c,
10170
10194
  width: l
10171
10195
  }) ?? null,
@@ -10177,14 +10201,14 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10177
10201
  }
10178
10202
  _applyTextContentUpdate({ textbox: e, style: t, updates: n, currentText: r }) {
10179
10203
  let i = e.textCaseRaw ?? r, a = !!e.uppercase, o = t.text !== void 0, s = o ? t.text ?? "" : i, c = t.uppercase ?? a, l = c !== a, u = e.text ?? "";
10180
- return o || l ? (n.text = c ? Xi({ value: s }) : s, e.textCaseRaw = s) : e.textCaseRaw === void 0 && (e.textCaseRaw = i), e.uppercase = c, {
10204
+ return o || l ? (n.text = c ? Zi({ value: s }) : s, e.textCaseRaw = s) : e.textCaseRaw === void 0 && (e.textCaseRaw = i), e.uppercase = c, {
10181
10205
  hasTextUpdate: o,
10182
10206
  uppercaseChanged: l,
10183
10207
  previousRenderedText: u
10184
10208
  };
10185
10209
  }
10186
10210
  _resolveContentPlacement({ textbox: e, style: t, updates: n, placement: r, styleMaps: i, contentUpdate: a }) {
10187
- let o = Si({ stylesList: [
10211
+ let o = Ci({ stylesList: [
10188
10212
  n,
10189
10213
  i.selectionStyles,
10190
10214
  i.lineSelectionStyles,
@@ -10200,7 +10224,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10200
10224
  t.paddingBottom,
10201
10225
  t.paddingLeft
10202
10226
  ].some((e) => e !== void 0), l = Object.prototype.hasOwnProperty.call(n, "width");
10203
- return c && !s && !a.hasTextUpdate && !a.uppercaseChanged && !o && !l ? yi({
10227
+ return c && !s && !a.hasTextUpdate && !a.uppercaseChanged && !o && !l ? bi({
10204
10228
  textbox: e,
10205
10229
  originX: r.originX,
10206
10230
  originY: r.originY
@@ -10233,24 +10257,24 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10233
10257
  }
10234
10258
  _applyWholeTextStyles({ textbox: e, selection: t, styleMaps: n }) {
10235
10259
  if (t.selectionRange || Object.keys(n.wholeTextStyles).length === 0) return;
10236
- let r = Wi({ textbox: e });
10237
- r && Ki({
10260
+ let r = Gi({ textbox: e });
10261
+ r && qi({
10238
10262
  textbox: e,
10239
10263
  styles: n.wholeTextStyles,
10240
10264
  range: r
10241
- }) && (e.dirty = !0, Si({ stylesList: [n.wholeTextStyles] }) && (e.initDimensions(), e.dirty = !0));
10265
+ }) && (e.dirty = !0, Ci({ stylesList: [n.wholeTextStyles] }) && (e.initDimensions(), e.dirty = !0));
10242
10266
  }
10243
10267
  _applySelectionStyles({ textbox: e, selection: t, styleMaps: n }) {
10244
10268
  if (!t.selectionRange) return;
10245
- let r = Ki({
10269
+ let r = qi({
10246
10270
  textbox: e,
10247
10271
  styles: n.selectionStyles,
10248
10272
  range: t.selectionRange
10249
- }), i = t.fontSelectionRange ? Ki({
10273
+ }), i = t.fontSelectionRange ? qi({
10250
10274
  textbox: e,
10251
10275
  styles: n.lineSelectionStyles,
10252
10276
  range: t.fontSelectionRange
10253
- }) : !1, a = Si({ stylesList: [
10277
+ }) : !1, a = Ci({ stylesList: [
10254
10278
  n.selectionStyles,
10255
10279
  n.lineSelectionStyles,
10256
10280
  n.wholeTextStyles
@@ -10272,9 +10296,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10272
10296
  _applyFontLineDefaultUpdates({ textbox: e, style: t, selection: n }) {
10273
10297
  if (!n.fontSelectionRange || t.fontFamily === void 0 && t.fontSize === void 0) return;
10274
10298
  let r = {};
10275
- t.fontFamily !== void 0 && (r.fontFamily = t.fontFamily), t.fontSize !== void 0 && (r.fontSize = t.fontSize), ai({
10299
+ t.fontFamily !== void 0 && (r.fontFamily = t.fontFamily), t.fontSize !== void 0 && (r.fontSize = t.fontSize), oi({
10276
10300
  textbox: e,
10277
- lineIndices: Xr({
10301
+ lineIndices: Zr({
10278
10302
  textbox: e,
10279
10303
  range: n.fontSelectionRange
10280
10304
  }),
@@ -10284,9 +10308,9 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10284
10308
  _applyDecorationLineDefaultUpdates({ textbox: e, style: t, selection: n, styleMaps: r }) {
10285
10309
  if (!n.selectionRange || !(t.bold !== void 0 || t.italic !== void 0 || t.underline !== void 0 || t.strikethrough !== void 0 || t.color !== void 0 || t.strokeColor !== void 0 || t.strokeWidth !== void 0)) return;
10286
10310
  let i = {};
10287
- r.resolvedFontWeight !== void 0 && (i.fontWeight = r.resolvedFontWeight), r.resolvedFontStyle !== void 0 && (i.fontStyle = r.resolvedFontStyle), t.underline !== void 0 && (i.underline = t.underline), t.strikethrough !== void 0 && (i.linethrough = t.strikethrough), t.color !== void 0 && (i.fill = t.color), (t.strokeColor !== void 0 || t.strokeWidth !== void 0) && (r.resolvedStrokeColor === null && (i.stroke = null), r.resolvedStrokeColor !== null && r.resolvedStrokeColor !== void 0 && (i.stroke = r.resolvedStrokeColor), r.resolvedStrokeWidth !== void 0 && (i.strokeWidth = r.resolvedStrokeWidth)), ai({
10311
+ r.resolvedFontWeight !== void 0 && (i.fontWeight = r.resolvedFontWeight), r.resolvedFontStyle !== void 0 && (i.fontStyle = r.resolvedFontStyle), t.underline !== void 0 && (i.underline = t.underline), t.strikethrough !== void 0 && (i.linethrough = t.strikethrough), t.color !== void 0 && (i.fill = t.color), (t.strokeColor !== void 0 || t.strokeWidth !== void 0) && (r.resolvedStrokeColor === null && (i.stroke = null), r.resolvedStrokeColor !== null && r.resolvedStrokeColor !== void 0 && (i.stroke = r.resolvedStrokeColor), r.resolvedStrokeWidth !== void 0 && (i.strokeWidth = r.resolvedStrokeWidth)), oi({
10288
10312
  textbox: e,
10289
- lineIndices: Zr({
10313
+ lineIndices: Qr({
10290
10314
  textbox: e,
10291
10315
  range: n.selectionRange
10292
10316
  }),
@@ -10332,7 +10356,7 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10332
10356
  ].some((e) => e !== void 0);
10333
10357
  }
10334
10358
  _resolveShouldAutoExpand({ textbox: e, style: t, styleMaps: n, contentUpdate: r }) {
10335
- let i = t.autoExpand ?? e.autoExpand, a = Si({ stylesList: [
10359
+ let i = t.autoExpand ?? e.autoExpand, a = Ci({ stylesList: [
10336
10360
  n.updates,
10337
10361
  n.selectionStyles,
10338
10362
  n.lineSelectionStyles,
@@ -10377,18 +10401,18 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10377
10401
  };
10378
10402
  this.runtime.canvas.fire("editor:text-updated", m);
10379
10403
  }
10380
- }, ea = ({ transform: e }) => {
10404
+ }, na = ({ transform: e }) => {
10381
10405
  let { corner: t = "", action: n = "" } = e;
10382
10406
  return {
10383
10407
  isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
10384
10408
  isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
10385
10409
  isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
10386
10410
  };
10387
- }, ta = ({ textbox: e, transform: t, appliedWidth: n }) => {
10411
+ }, ra = ({ textbox: e, transform: t, appliedWidth: n }) => {
10388
10412
  t.scaleX = 1, t.scaleY = 1;
10389
10413
  let r = t.original;
10390
10414
  r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
10391
- }, na = ({ textbox: e, transform: t, scenePoint: n }) => {
10415
+ }, ia = ({ textbox: e, transform: t, scenePoint: n }) => {
10392
10416
  let { x: r, y: i } = e._getTransformedDimensions();
10393
10417
  if (r <= 0 || i <= 0) return null;
10394
10418
  let a = x.getLocalPoint(t, t.originX, t.originY, n.x, n.y), o = t, s = typeof o.signX == "number" && a.x * o.signX <= 0, c = typeof o.signY == "number" && a.y * o.signY <= 0, l = Math.abs(a.x / r), u = Math.abs(a.y / i);
@@ -10398,27 +10422,27 @@ var pi = ({ currentText: e, previousText: t, textbox: n }) => {
10398
10422
  stepScaleX: l,
10399
10423
  stepScaleY: u
10400
10424
  };
10401
- }, ra = 1e-4;
10402
- function ia(e) {
10425
+ }, aa = 1e-4;
10426
+ function oa(e) {
10403
10427
  return !!e && e instanceof v;
10404
10428
  }
10405
- function aa(e) {
10406
- if (!ia(e)) return !1;
10429
+ function sa(e) {
10430
+ if (!oa(e)) return !1;
10407
10431
  let t = e.group;
10408
10432
  return e.shapeNodeType === "text" && t?.shapeComposite === !0;
10409
10433
  }
10410
- var oa = class {
10434
+ var ca = class {
10411
10435
  constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
10412
10436
  this.handleMouseMove = (e) => {
10413
10437
  let t = this.canvas._currentTransform;
10414
10438
  if (!t) return;
10415
10439
  let { target: n } = t;
10416
- if (!ia(n) || aa(n)) return;
10440
+ if (!oa(n) || sa(n)) return;
10417
10441
  let r = this.scalingState.get(n);
10418
10442
  if (!r || !e.e) return;
10419
- let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = ea({ transform: t });
10443
+ let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = na({ transform: t });
10420
10444
  if (!a && !o && !i) return;
10421
- let s = na({
10445
+ let s = ia({
10422
10446
  textbox: n,
10423
10447
  transform: t,
10424
10448
  scenePoint: this.canvas.getScenePoint(e.e)
@@ -10441,20 +10465,20 @@ var oa = class {
10441
10465
  }, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
10442
10466
  if (i) {
10443
10467
  let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
10444
- if (Math.abs(t - r.lastAllowedScaleX) <= ra) return;
10468
+ if (Math.abs(t - r.lastAllowedScaleX) <= aa) return;
10445
10469
  j = t, M = t;
10446
10470
  } else {
10447
10471
  if (a) {
10448
10472
  let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
10449
- Math.abs(t - r.lastAllowedScaleX) > ra && (j = t);
10473
+ Math.abs(t - r.lastAllowedScaleX) > aa && (j = t);
10450
10474
  }
10451
10475
  if (o) {
10452
10476
  let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
10453
- Math.abs(t - r.lastAllowedScaleY) > ra && (M = t);
10477
+ Math.abs(t - r.lastAllowedScaleY) > aa && (M = t);
10454
10478
  }
10455
- if (Math.abs(j - r.lastAllowedScaleX) <= ra && Math.abs(M - r.lastAllowedScaleY) <= ra) return;
10479
+ if (Math.abs(j - r.lastAllowedScaleX) <= aa && Math.abs(M - r.lastAllowedScaleY) <= aa) return;
10456
10480
  }
10457
- let { appliedWidth: N, dimensionsRounded: P } = Di({
10481
+ let { appliedWidth: N, dimensionsRounded: P } = Oi({
10458
10482
  textbox: n,
10459
10483
  canvasManager: this.canvasManager,
10460
10484
  base: r.startBase,
@@ -10468,7 +10492,7 @@ var oa = class {
10468
10492
  shouldDisableAutoExpandOnHorizontalChange: a,
10469
10493
  shouldRoundDimensions: !i
10470
10494
  });
10471
- ta({
10495
+ ra({
10472
10496
  textbox: n,
10473
10497
  transform: t,
10474
10498
  appliedWidth: N
@@ -10489,12 +10513,12 @@ var oa = class {
10489
10513
  }), this.canvas.requestRenderAll();
10490
10514
  }, this.handleObjectScaling = (t) => {
10491
10515
  let { target: n, transform: r } = t;
10492
- if (n instanceof e || !ia(n) || aa(n) || !r) return;
10516
+ if (n instanceof e || !oa(n) || sa(n) || !r) return;
10493
10517
  n.isScaling = !0;
10494
10518
  let i = this._ensureScalingState({
10495
10519
  textbox: n,
10496
10520
  transform: r
10497
- }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = ea({ transform: r }), d = r.corner ?? "", f = c || u;
10521
+ }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = na({ transform: r }), d = r.corner ?? "", f = c || u;
10498
10522
  if (!l && !u && !c) return;
10499
10523
  let p = n.scaleX ?? r.scaleX ?? 1, m = n.scaleY ?? r.scaleY ?? 1, h = Math.abs(p) || 1, g = Math.abs(m) || 1, _ = r.originX ?? n.originX ?? "center", v = r.originY ?? n.originY ?? "center", y = this.canvasManager.getObjectPlacement({
10500
10524
  object: n,
@@ -10509,7 +10533,7 @@ var oa = class {
10509
10533
  N = e, P = e;
10510
10534
  }
10511
10535
  } else l && (N = Math.max(i.minimumWidthScale, i.lastAllowedScaleX * h)), u && (P = Math.max(i.minimumFontScale, i.lastAllowedScaleY * g));
10512
- let { appliedWidth: ee, dimensionsRounded: te } = Di({
10536
+ let { appliedWidth: ee, dimensionsRounded: te } = Oi({
10513
10537
  textbox: n,
10514
10538
  canvasManager: this.canvasManager,
10515
10539
  base: a,
@@ -10523,7 +10547,7 @@ var oa = class {
10523
10547
  shouldDisableAutoExpandOnHorizontalChange: l,
10524
10548
  shouldRoundDimensions: !c
10525
10549
  });
10526
- ta({
10550
+ ra({
10527
10551
  textbox: n,
10528
10552
  transform: r,
10529
10553
  appliedWidth: ee
@@ -10556,7 +10580,7 @@ var oa = class {
10556
10580
  let { target: n } = t;
10557
10581
  if (n instanceof e) {
10558
10582
  let t = n.getObjects();
10559
- if (!t.some((e) => ia(e))) return;
10583
+ if (!t.some((e) => oa(e))) return;
10560
10584
  let { scaleX: r = 1, scaleY: i = 1 } = n;
10561
10585
  if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
10562
10586
  this.canvas.discardActiveObject(), t.forEach((e) => {
@@ -10566,7 +10590,7 @@ var oa = class {
10566
10590
  this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
10567
10591
  return;
10568
10592
  }
10569
- if (!ia(n) || aa(n)) return;
10593
+ if (!oa(n) || sa(n)) return;
10570
10594
  n.isScaling = !1;
10571
10595
  let r = this.scalingState.get(n);
10572
10596
  if (this.scalingState.delete(n), !r?.hasScalingChange) return;
@@ -10591,11 +10615,11 @@ var oa = class {
10591
10615
  }, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
10592
10616
  }
10593
10617
  commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
10594
- if (!ia(e) || aa(e)) return !1;
10618
+ if (!oa(e) || sa(e)) return !1;
10595
10619
  let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
10596
10620
  if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
10597
- let i = wi({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
10598
- return Di({
10621
+ let i = Ti({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
10622
+ return Oi({
10599
10623
  textbox: e,
10600
10624
  canvasManager: this.canvasManager,
10601
10625
  base: i,
@@ -10611,7 +10635,7 @@ var oa = class {
10611
10635
  _ensureScalingState({ textbox: e, transform: t }) {
10612
10636
  let n = this.scalingState.get(e);
10613
10637
  if (!n) {
10614
- let r = wi({ textbox: e }), i = this.canvasManager.getObjectPlacement({ object: e }), a = Ti({ base: r }), o = t.original?.originX ?? t.originX ?? e.originX ?? "center", s = t.original?.originY ?? t.originY ?? e.originY ?? "center";
10638
+ let r = Ti({ textbox: e }), i = this.canvasManager.getObjectPlacement({ object: e }), a = Ei({ base: r }), o = t.original?.originX ?? t.originX ?? e.originX ?? "center", s = t.original?.originY ?? t.originY ?? e.originY ?? "center";
10615
10639
  n = {
10616
10640
  startBase: r,
10617
10641
  startObjectPlacement: i,
@@ -10644,7 +10668,7 @@ var oa = class {
10644
10668
  topRight: e.radiusTopRight ?? 0,
10645
10669
  bottomRight: e.radiusBottomRight ?? 0,
10646
10670
  bottomLeft: e.radiusBottomLeft ?? 0
10647
- }, v = Math.abs(n - o) > Kr, y = Math.abs(h - r) > Kr, b = Math.abs(g.top - i.top) > .01 || Math.abs(g.right - i.right) > .01 || Math.abs(g.bottom - i.bottom) > .01 || Math.abs(g.left - i.left) > .01, x = Math.abs(_.topLeft - a.topLeft) > .01 || Math.abs(_.topRight - a.topRight) > .01 || Math.abs(_.bottomRight - a.bottomRight) > .01 || Math.abs(_.bottomLeft - a.bottomLeft) > .01, S = t.lastAllowedScaleX, C = t.lastAllowedScaleY;
10671
+ }, v = Math.abs(n - o) > qr, y = Math.abs(h - r) > qr, b = Math.abs(g.top - i.top) > .01 || Math.abs(g.right - i.right) > .01 || Math.abs(g.bottom - i.bottom) > .01 || Math.abs(g.left - i.left) > .01, x = Math.abs(_.topLeft - a.topLeft) > .01 || Math.abs(_.topRight - a.topRight) > .01 || Math.abs(_.bottomRight - a.bottomRight) > .01 || Math.abs(_.bottomLeft - a.bottomLeft) > .01, S = t.lastAllowedScaleX, C = t.lastAllowedScaleY;
10648
10672
  if (c) {
10649
10673
  let e = h / Math.max(1, m);
10650
10674
  S = e, C = e;
@@ -10665,7 +10689,7 @@ var oa = class {
10665
10689
  originY: a
10666
10690
  });
10667
10691
  }
10668
- }, sa = class e {
10692
+ }, la = class e {
10669
10693
  constructor({ editor: t }) {
10670
10694
  this._handleTextEditingEntered = (t) => {
10671
10695
  this.isTextEditingActive = !0;
@@ -10678,7 +10702,7 @@ var oa = class {
10678
10702
  if (!e._isTextbox(n)) return;
10679
10703
  let r = e._isShapeOwnedTextbox(n), { text: i = "", uppercase: a, autoExpand: o } = n, s = !!a, c = o !== !1, l = i.toLocaleLowerCase(), u = r ? null : this.editingPlacementState?.get(n) ?? this.editor.canvasManager.getObjectPlacement({ object: n });
10680
10704
  if (s) {
10681
- let e = Xi({ value: l });
10705
+ let e = Zi({ value: l });
10682
10706
  e !== i && n.set({ text: e }), n.textCaseRaw = l;
10683
10707
  } else n.textCaseRaw = i;
10684
10708
  if (!r && o === void 0 && (n.autoExpand = !0), r) {
@@ -10696,7 +10720,7 @@ var oa = class {
10696
10720
  let r = e._isShapeOwnedTextbox(n);
10697
10721
  this.editingPlacementState?.delete(n), delete n.__lineDefaultsPrevText;
10698
10722
  let i = n.text ?? "";
10699
- n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (Ci({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
10723
+ n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (wi({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
10700
10724
  lockMovementX: !1,
10701
10725
  lockMovementY: !1
10702
10726
  }));
@@ -10723,7 +10747,7 @@ var oa = class {
10723
10747
  transform: r,
10724
10748
  event: i ?? null
10725
10749
  });
10726
- }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new oa({
10750
+ }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new ca({
10727
10751
  canvas: t.canvas,
10728
10752
  canvasManager: t.canvasManager,
10729
10753
  persistScaledTextbox: ({ target: e, style: t }) => {
@@ -10732,7 +10756,7 @@ var oa = class {
10732
10756
  style: t
10733
10757
  });
10734
10758
  }
10735
- }), this.updateController = new $i({ runtime: {
10759
+ }), this.updateController = new ta({ runtime: {
10736
10760
  canvas: this.canvas,
10737
10761
  canvasManager: t.canvasManager,
10738
10762
  historyManager: t.historyManager,
@@ -10741,12 +10765,12 @@ var oa = class {
10741
10765
  restoreTextboxContentPlacement: (e) => this._restoreTextboxContentPlacement(e),
10742
10766
  syncLineStylesWithText: (e) => this._syncLineStylesWithText(e),
10743
10767
  getSnapshot: (t) => e._getSnapshot(t)
10744
- } }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), Qi();
10768
+ } }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), ea();
10745
10769
  }
10746
10770
  addText({ id: t = `background-textbox-${O()}`, text: n = "Новый текст", autoExpand: r = !0, fontFamily: i, fontSize: a = 48, bold: o = !1, italic: s = !1, underline: c = !1, uppercase: l = !1, strikethrough: u = !1, align: d = "left", color: f = "#000000", strokeColor: p, strokeWidth: m = 0, opacity: h = 1, backgroundColor: g, backgroundOpacity: _ = 1, paddingTop: v = 0, paddingRight: y = 0, paddingBottom: b = 0, paddingLeft: x = 0, radiusTopLeft: S = 0, radiusTopRight: C = 0, radiusBottomRight: w = 0, radiusBottomLeft: T = 0, ...E } = {}, { withoutSelection: D = !1, withoutSave: k = !1, withoutAdding: A = !1, emitLifecycleEvents: j = !0 } = {}) {
10747
10771
  let { canvasManager: M, historyManager: N } = this.editor, { canvas: P } = this;
10748
10772
  N.suspendHistory();
10749
- let F = i ?? this._getDefaultFontFamily(), I = Yi({ width: m }), ee = Ji({
10773
+ let F = i ?? this._getDefaultFontFamily(), I = Xi({ width: m }), ee = Yi({
10750
10774
  strokeColor: p,
10751
10775
  width: I
10752
10776
  }), te = {
@@ -10775,14 +10799,14 @@ var oa = class {
10775
10799
  radiusBottomRight: w,
10776
10800
  radiusBottomLeft: T,
10777
10801
  ...E
10778
- }, L = new Zi(n, te), ne = r !== !1;
10802
+ }, L = new $i(n, te), ne = r !== !1;
10779
10803
  L.autoExpand = ne;
10780
10804
  let re = E.left !== void 0 || E.top !== void 0;
10781
10805
  if (L.textCaseRaw = L.text ?? "", l) {
10782
- let e = Xi({ value: L.textCaseRaw });
10806
+ let e = Zi({ value: L.textCaseRaw });
10783
10807
  e !== L.text && L.set({ text: e });
10784
10808
  }
10785
- Ci({ textbox: L }) && (L.dirty = !0);
10809
+ wi({ textbox: L }) && (L.dirty = !0);
10786
10810
  let ie;
10787
10811
  re && (ie = M.resolveObjectPlacement({
10788
10812
  object: L,
@@ -10887,7 +10911,7 @@ var oa = class {
10887
10911
  clampToMontage: r
10888
10912
  }));
10889
10913
  let a = !1;
10890
- i || (a = Ci({ textbox: e }));
10914
+ i || (a = wi({ textbox: e }));
10891
10915
  let o = !1;
10892
10916
  return !i && t && (this.editor.canvasManager.applyObjectPlacement({
10893
10917
  object: e,
@@ -10895,7 +10919,7 @@ var oa = class {
10895
10919
  }), o = !0), (i || a) && (e.dirty = !0), (i || a || o) && e.setCoords(), i || a;
10896
10920
  }
10897
10921
  _restoreTextboxContentPlacement({ textbox: e, contentPlacement: t }) {
10898
- let n = yi({
10922
+ let n = bi({
10899
10923
  textbox: e,
10900
10924
  originX: t.originX,
10901
10925
  originY: t.originY
@@ -10913,7 +10937,7 @@ var oa = class {
10913
10937
  e.on("object:scaling", this.scalingController.handleObjectScaling), e.on("object:resizing", this._handleObjectResizing), e.on("object:modified", this.scalingController.handleObjectModified), e.on("mouse:move", this.scalingController.handleMouseMove), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged);
10914
10938
  }
10915
10939
  _syncLineStylesWithText({ textbox: e, previousText: t, currentText: n }) {
10916
- let r = n ?? e.text ?? "", i = pi({
10940
+ let r = n ?? e.text ?? "", i = mi({
10917
10941
  textbox: e,
10918
10942
  previousText: t ?? e.__lineDefaultsPrevText ?? r,
10919
10943
  currentText: r
@@ -10931,16 +10955,16 @@ var oa = class {
10931
10955
  if (!Number.isFinite(f) || f <= 0) return !1;
10932
10956
  let p = a.split("\n").length, m = !1;
10933
10957
  Math.abs((e.width ?? 0) - f) > .01 && (e.set({ width: f }), m = !0), e.initDimensions();
10934
- let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(_i({
10958
+ let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(vi({
10935
10959
  textbox: e,
10936
10960
  text: a
10937
10961
  })), v = Math.min(e.minWidth ?? 1, f), y = Math.min(f, Math.max(_, v));
10938
- g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), Ci({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
10962
+ g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), wi({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
10939
10963
  object: e,
10940
10964
  placement: t
10941
10965
  });
10942
10966
  let b = !1;
10943
- return n && (b = bi({
10967
+ return n && (b = xi({
10944
10968
  textbox: e,
10945
10969
  montageLeft: o,
10946
10970
  montageRight: o + s
@@ -10998,7 +11022,7 @@ var oa = class {
10998
11022
  _getDefaultFontFamily() {
10999
11023
  return this.fonts[0]?.family ?? "Arial";
11000
11024
  }
11001
- }, ca = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, la = (e) => {
11025
+ }, ua = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, da = (e) => {
11002
11026
  if (!e || typeof e != "object") return null;
11003
11027
  let { type: t, coords: n, colorStops: r } = e, i = Array.isArray(r) ? r : [], a = i[0], o = i[i.length - 1], s = typeof a?.color == "string" ? a.color : void 0, c = typeof o?.color == "string" ? o.color : s, l = typeof a?.offset == "number" ? a.offset * 100 : void 0, u = typeof o?.offset == "number" ? o.offset * 100 : void 0, d = i.map((e) => ({
11004
11028
  color: typeof e.color == "string" ? e.color : "#000000",
@@ -11009,7 +11033,7 @@ var oa = class {
11009
11033
  let { x1: e, y1: t, x2: r, y2: i } = n;
11010
11034
  if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
11011
11035
  type: "linear",
11012
- angle: ca({
11036
+ angle: ua({
11013
11037
  x1: e,
11014
11038
  y1: t,
11015
11039
  x2: r,
@@ -11037,7 +11061,7 @@ var oa = class {
11037
11061
  };
11038
11062
  }
11039
11063
  return null;
11040
- }, ua = "_templateAnchorX", da = "_templateAnchorY", fa = class t {
11064
+ }, fa = "_templateAnchorX", pa = "_templateAnchorY", ma = class t {
11041
11065
  constructor({ editor: e }) {
11042
11066
  this.editor = e;
11043
11067
  }
@@ -11046,7 +11070,7 @@ var oa = class {
11046
11070
  if (!p.length) return s.emitWarning({
11047
11071
  origin: "TemplateManager",
11048
11072
  method: "serializeSelection",
11049
- code: Bi.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
11073
+ code: Vi.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
11050
11074
  message: "Нет объектов для сериализации шаблона"
11051
11075
  }), null;
11052
11076
  let m = t._getBounds(o), h = t._getMontageSize({
@@ -11075,14 +11099,14 @@ var oa = class {
11075
11099
  if (!l?.length) return a.emitWarning({
11076
11100
  origin: "TemplateManager",
11077
11101
  method: "applyTemplate",
11078
- code: Bi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
11102
+ code: Vi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
11079
11103
  message: "Шаблон не содержит объектов"
11080
11104
  }), null;
11081
11105
  let f = t._getBounds(r);
11082
11106
  if (!f) return a.emitWarning({
11083
11107
  origin: "TemplateManager",
11084
11108
  method: "applyTemplate",
11085
- code: Bi.TEMPLATE_MANAGER.INVALID_TARGET,
11109
+ code: Vi.TEMPLATE_MANAGER.INVALID_TARGET,
11086
11110
  message: "Не удалось определить границы монтажной области"
11087
11111
  }), null;
11088
11112
  let p = t._getMontageSize({
@@ -11101,7 +11125,7 @@ var oa = class {
11101
11125
  if (!r.length) return a.emitWarning({
11102
11126
  origin: "TemplateManager",
11103
11127
  method: "applyTemplate",
11104
- code: Bi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
11128
+ code: Vi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
11105
11129
  message: "Не удалось создать объекты шаблона"
11106
11130
  }), null;
11107
11131
  let { backgroundObject: i, contentObjects: u } = t._extractBackgroundObject(r);
@@ -11123,7 +11147,7 @@ var oa = class {
11123
11147
  }), c.commitStandaloneTextScale({ target: e }), s.commitRehydratedShapeLayout({
11124
11148
  target: e,
11125
11149
  textScale: h
11126
- }), Gt({ object: e }), Pi({ rootObject: e }), n.add(e), e));
11150
+ }), Gt({ object: e }), Fi({ rootObject: e }), n.add(e), e));
11127
11151
  return !d.length && !v ? null : (_ = d.length > 0 || v, d.length && t._activateObjects({
11128
11152
  canvas: n,
11129
11153
  objects: d
@@ -11136,7 +11160,7 @@ var oa = class {
11136
11160
  return a.emitError({
11137
11161
  origin: "TemplateManager",
11138
11162
  method: "applyTemplate",
11139
- code: Bi.TEMPLATE_MANAGER.APPLY_FAILED,
11163
+ code: Vi.TEMPLATE_MANAGER.APPLY_FAILED,
11140
11164
  message: "Ошибка применения шаблона",
11141
11165
  data: {
11142
11166
  templateId: d,
@@ -11293,8 +11317,8 @@ var oa = class {
11293
11317
  baseHeight: a,
11294
11318
  scale: n,
11295
11319
  useRelativePositions: o,
11296
- anchorX: t._resolveAnchor(s, ua),
11297
- anchorY: t._resolveAnchor(s, da)
11320
+ anchorX: t._resolveAnchor(s, fa),
11321
+ anchorY: t._resolveAnchor(s, pa)
11298
11322
  })
11299
11323
  }), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
11300
11324
  e.set({
@@ -11369,7 +11393,7 @@ var oa = class {
11369
11393
  });
11370
11394
  if (!i || !a) return;
11371
11395
  e.setCoords();
11372
- let o = e, s = t._resolveAnchor(o, ua), c = typeof e.left == "number" ? e.left : null, l = e.originX ?? "center", u = e.originY ?? "center", d = e.getPointByOrigin(l, u), f = t._getBoundingRect(e), p = f.left + f.width / 2, m = f.left + f.width;
11396
+ let o = e, s = t._resolveAnchor(o, fa), c = typeof e.left == "number" ? e.left : null, l = e.originX ?? "center", u = e.originY ?? "center", d = e.getPointByOrigin(l, u), f = t._getBoundingRect(e), p = f.left + f.width / 2, m = f.left + f.width;
11373
11397
  e.set("width", i), e.initDimensions();
11374
11398
  let h = t._getLongestLineWidth({
11375
11399
  textbox: e,
@@ -11398,10 +11422,10 @@ var oa = class {
11398
11422
  x: (p.left - o) / d,
11399
11423
  y: (p.top - s) / f
11400
11424
  }, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
11401
- return a[ua] = t._detectAnchor({
11425
+ return a[fa] = t._detectAnchor({
11402
11426
  start: h,
11403
11427
  end: _
11404
- }), a[da] = t._detectAnchor({
11428
+ }), a[pa] = t._detectAnchor({
11405
11429
  start: g,
11406
11430
  end: v
11407
11431
  }), a.left = m.x, a.top = m.y, a;
@@ -11426,7 +11450,7 @@ var oa = class {
11426
11450
  withoutSave: !0
11427
11451
  }), !0;
11428
11452
  if (a === "gradient") {
11429
- let e = la(r);
11453
+ let e = da(r);
11430
11454
  if (e) return n.setGradientBackground({
11431
11455
  gradient: e,
11432
11456
  customData: o,
@@ -11447,7 +11471,7 @@ var oa = class {
11447
11471
  r.emitWarning({
11448
11472
  origin: "TemplateManager",
11449
11473
  method: "applyTemplate",
11450
- code: Bi.TEMPLATE_MANAGER.APPLY_FAILED,
11474
+ code: Vi.TEMPLATE_MANAGER.APPLY_FAILED,
11451
11475
  message: "Не удалось применить фон из шаблона",
11452
11476
  data: e
11453
11477
  });
@@ -11483,29 +11507,29 @@ var oa = class {
11483
11507
  enlivenObjectEnlivables(e) {
11484
11508
  return w.enlivenObjectEnlivables(e);
11485
11509
  }
11486
- }, pa = "#3D8BF4", ma = .5, ha = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, ga = ({ firstDistance: e, secondDistance: t }) => {
11487
- let n = ha({ distance: e }), r = ha({ distance: t });
11510
+ }, ha = "#3D8BF4", ga = .5, _a = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, va = ({ firstDistance: e, secondDistance: t }) => {
11511
+ let n = _a({ distance: e }), r = _a({ distance: t });
11488
11512
  return {
11489
11513
  firstDisplayDistance: n,
11490
11514
  secondDisplayDistance: r,
11491
11515
  displayDistanceDiff: Math.abs(n - r),
11492
11516
  commonDisplayDistance: Math.max(n, r)
11493
11517
  };
11494
- }, _a = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), va = ({ step: e }) => {
11518
+ }, ya = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), ba = ({ step: e }) => {
11495
11519
  let t = Math.abs(e).toString(), n = t.indexOf(".");
11496
11520
  return n === -1 ? 0 : t.slice(n + 1).length;
11497
- }, ya = ({ value: e, step: t }) => {
11521
+ }, xa = ({ value: e, step: t }) => {
11498
11522
  if (t === 0) return e;
11499
- let n = va({ step: t }), r = Math.round(e / t) * t;
11523
+ let n = ba({ step: t }), r = Math.round(e / t) * t;
11500
11524
  return Number(r.toFixed(n));
11501
- }, ba = ({ value: e, step: t }) => {
11525
+ }, Sa = ({ value: e, step: t }) => {
11502
11526
  if (t === 0) return !0;
11503
- let n = ya({
11527
+ let n = xa({
11504
11528
  value: e,
11505
11529
  step: t
11506
- }), r = 10 ** -(va({ step: t }) + 4);
11530
+ }), r = 10 ** -(ba({ step: t }) + 4);
11507
11531
  return Math.abs(n - e) <= r;
11508
- }, xa = ({ bounds: e, axis: t }) => {
11532
+ }, Ca = ({ bounds: e, axis: t }) => {
11509
11533
  let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
11510
11534
  return t === "vertical" ? {
11511
11535
  start: i,
@@ -11514,7 +11538,7 @@ var oa = class {
11514
11538
  start: n,
11515
11539
  end: r
11516
11540
  };
11517
- }, Sa = ({ items: e, axis: t }) => {
11541
+ }, wa = ({ items: e, axis: t }) => {
11518
11542
  for (let n = 1; n < e.length; n += 1) {
11519
11543
  let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
11520
11544
  for (; o >= 0;) {
@@ -11524,10 +11548,10 @@ var oa = class {
11524
11548
  }
11525
11549
  e[o + 1] = r;
11526
11550
  }
11527
- }, Ca = ({ items: e, index: t, axis: n, direction: r }) => {
11551
+ }, Ta = ({ items: e, index: t, axis: n, direction: r }) => {
11528
11552
  let i = e[t];
11529
11553
  if (!i) return null;
11530
- let { bounds: a } = i, { start: o, end: s } = xa({
11554
+ let { bounds: a } = i, { start: o, end: s } = Ca({
11531
11555
  bounds: a,
11532
11556
  axis: n
11533
11557
  });
@@ -11535,7 +11559,7 @@ var oa = class {
11535
11559
  for (let r = t - 1; r >= 0; --r) {
11536
11560
  let t = e[r];
11537
11561
  if (!t) continue;
11538
- let { bounds: i } = t, { end: a } = xa({
11562
+ let { bounds: i } = t, { end: a } = Ca({
11539
11563
  bounds: i,
11540
11564
  axis: n
11541
11565
  });
@@ -11546,26 +11570,26 @@ var oa = class {
11546
11570
  for (let r = t + 1; r < e.length; r += 1) {
11547
11571
  let t = e[r];
11548
11572
  if (!t) continue;
11549
- let { bounds: i } = t, { start: a } = xa({
11573
+ let { bounds: i } = t, { start: a } = Ca({
11550
11574
  bounds: i,
11551
11575
  axis: n
11552
11576
  });
11553
11577
  if (a - s >= 0) return r;
11554
11578
  }
11555
11579
  return null;
11556
- }, wa = ({ items: e }) => {
11580
+ }, Ea = ({ items: e }) => {
11557
11581
  for (let t = 0; t < e.length; t += 1) {
11558
11582
  let { isActive: n } = e[t];
11559
11583
  if (n) return t;
11560
11584
  }
11561
11585
  return -1;
11562
- }, Ta = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
11586
+ }, Da = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
11563
11587
  let i = Math.min(t, n), a = Math.max(t, n);
11564
11588
  return e >= i - r && e <= a + r;
11565
- }, Ea = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Da = ({ baseOption: e, candidateOption: t }) => {
11589
+ }, Oa = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, ka = ({ baseOption: e, candidateOption: t }) => {
11566
11590
  let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
11567
11591
  return n === i && r === a;
11568
- }, Oa = ({ options: e }) => {
11592
+ }, Aa = ({ options: e }) => {
11569
11593
  let t = e[0];
11570
11594
  for (let n = 1; n < e.length; n += 1) {
11571
11595
  let r = e[n];
@@ -11576,11 +11600,11 @@ var oa = class {
11576
11600
  r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
11577
11601
  }
11578
11602
  return t;
11579
- }, ka = ({ currentOption: e, nextOption: t }) => {
11603
+ }, ja = ({ currentOption: e, nextOption: t }) => {
11580
11604
  if (!e) return !0;
11581
11605
  let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
11582
11606
  return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
11583
- }, Aa = ({ options: e }) => {
11607
+ }, Ma = ({ options: e }) => {
11584
11608
  let t = [], n = null, r = null;
11585
11609
  for (let i of e) {
11586
11610
  let { kind: e, side: a } = i;
@@ -11588,18 +11612,18 @@ var oa = class {
11588
11612
  t.push(i);
11589
11613
  continue;
11590
11614
  }
11591
- a === "before" && ka({
11615
+ a === "before" && ja({
11592
11616
  currentOption: n,
11593
11617
  nextOption: i
11594
- }) && (n = i), a === "after" && ka({
11618
+ }) && (n = i), a === "after" && ja({
11595
11619
  currentOption: r,
11596
11620
  nextOption: i
11597
11621
  }) && (r = i);
11598
11622
  }
11599
11623
  return n && t.push(n), r && t.push(r), t;
11600
- }, ja = ({ options: e, side: t, baseOption: n }) => {
11624
+ }, Na = ({ options: e, side: t, baseOption: n }) => {
11601
11625
  let r = null;
11602
- for (let i of e) if (i.side === t && Da({
11626
+ for (let i of e) if (i.side === t && ka({
11603
11627
  baseOption: n,
11604
11628
  candidateOption: i
11605
11629
  })) {
@@ -11610,63 +11634,63 @@ var oa = class {
11610
11634
  !r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
11611
11635
  }
11612
11636
  return r;
11613
- }, Ma = ({ option: e }) => {
11637
+ }, Pa = ({ option: e }) => {
11614
11638
  let { side: t, kind: n, guide: { distance: r } } = e;
11615
11639
  return {
11616
11640
  side: t,
11617
11641
  kind: n,
11618
11642
  distance: r
11619
11643
  };
11620
- }, Na = ({ option: e, context: t }) => {
11644
+ }, Fa = ({ option: e, context: t }) => {
11621
11645
  let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
11622
11646
  return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
11623
- }, Pa = ({ options: e, context: t }) => {
11647
+ }, Ia = ({ options: e, context: t }) => {
11624
11648
  if (!t) return null;
11625
- for (let n of e) if (Na({
11649
+ for (let n of e) if (Fa({
11626
11650
  option: n,
11627
11651
  context: t
11628
11652
  })) return n;
11629
11653
  return null;
11630
- }, Fa = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
11631
- let i = Pa({
11654
+ }, La = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
11655
+ let i = Ia({
11632
11656
  options: e,
11633
11657
  context: n
11634
11658
  });
11635
11659
  if (!i) return t;
11636
11660
  let a = Math.max(0, r);
11637
11661
  return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
11638
- }, Ia = ({ guides: e, seenGuideKeys: t, guide: n }) => {
11662
+ }, Ra = ({ guides: e, seenGuideKeys: t, guide: n }) => {
11639
11663
  let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
11640
11664
  t.has(u) || (t.add(u), e.push(n));
11641
- }, La = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
11665
+ }, za = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
11642
11666
  if (!e.length) return {
11643
11667
  delta: 0,
11644
11668
  guides: [],
11645
11669
  context: null
11646
11670
  };
11647
- let r = Aa({ options: e }), i = [];
11671
+ let r = Ma({ options: e }), i = [];
11648
11672
  for (let e of r) e.kind === "reference" && i.push(e);
11649
- let a = i.length > 0, o = a ? i : r, s = Fa({
11673
+ let a = i.length > 0, o = a ? i : r, s = La({
11650
11674
  options: o,
11651
- bestOption: Oa({ options: o }),
11675
+ bestOption: Aa({ options: o }),
11652
11676
  previousContext: t,
11653
11677
  switchDistance: n
11654
- }), c = ja({
11678
+ }), c = Na({
11655
11679
  options: o,
11656
11680
  side: "before",
11657
11681
  baseOption: s
11658
- }), l = ja({
11682
+ }), l = Na({
11659
11683
  options: o,
11660
11684
  side: "after",
11661
11685
  baseOption: s
11662
- }), u = ja({
11686
+ }), u = Na({
11663
11687
  options: a ? r : o,
11664
11688
  side: "center",
11665
11689
  baseOption: s
11666
11690
  }), d = [];
11667
11691
  c && l ? d.push(c, l) : (d.push(s), s.side === "before" && l && d.push(l), s.side === "after" && c && d.push(c), s.side === "center" && (c && !l && d.push(c), l && !c && d.push(l)), a && s.side === "before" && !l && u && d.push(u), a && s.side === "after" && !c && u && d.push(u)), !d.length && u && d.push(u);
11668
11692
  let f = [], p = /* @__PURE__ */ new Set();
11669
- for (let e of d) Ia({
11693
+ for (let e of d) Ra({
11670
11694
  guides: f,
11671
11695
  seenGuideKeys: p,
11672
11696
  guide: e.guide
@@ -11674,15 +11698,15 @@ var oa = class {
11674
11698
  return {
11675
11699
  delta: s.delta,
11676
11700
  guides: f,
11677
- context: Ma({ option: s })
11701
+ context: Pa({ option: s })
11678
11702
  };
11679
- }, Ra = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
11680
- let s = n - (e - r), c = ya({
11703
+ }, Ba = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
11704
+ let s = n - (e - r), c = xa({
11681
11705
  value: s,
11682
11706
  step: o
11683
11707
  }), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
11684
11708
  for (let d = -l; d <= l; d += 1) {
11685
- let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = ga({
11709
+ let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = va({
11686
11710
  firstDistance: m,
11687
11711
  secondDistance: h
11688
11712
  });
@@ -11697,13 +11721,13 @@ var oa = class {
11697
11721
  });
11698
11722
  }
11699
11723
  return u;
11700
- }, za = ({ currentGap: e, referenceGap: t }) => {
11701
- let { secondDisplayDistance: n, displayDistanceDiff: r } = ga({
11724
+ }, Va = ({ currentGap: e, referenceGap: t }) => {
11725
+ let { secondDisplayDistance: n, displayDistanceDiff: r } = va({
11702
11726
  firstDistance: e,
11703
11727
  secondDistance: t
11704
11728
  });
11705
11729
  return r > 1 ? null : n;
11706
- }, Ba = ({ anchors: e, positions: t, threshold: n }) => {
11730
+ }, Ha = ({ anchors: e, positions: t, threshold: n }) => {
11707
11731
  let r = 0, i = n + 1, a = null;
11708
11732
  for (let o of t) for (let t of e) {
11709
11733
  let e = Math.abs(t - o);
@@ -11713,8 +11737,8 @@ var oa = class {
11713
11737
  delta: r,
11714
11738
  guidePosition: a
11715
11739
  };
11716
- }, Va = ({ activeBounds: e, threshold: t, anchors: n }) => {
11717
- let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Ba({
11740
+ }, Ua = ({ activeBounds: e, threshold: t, anchors: n }) => {
11741
+ let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Ha({
11718
11742
  anchors: n.vertical,
11719
11743
  positions: [
11720
11744
  r,
@@ -11722,7 +11746,7 @@ var oa = class {
11722
11746
  i
11723
11747
  ],
11724
11748
  threshold: t
11725
- }), u = Ba({
11749
+ }), u = Ha({
11726
11750
  anchors: n.horizontal,
11727
11751
  positions: [
11728
11752
  o,
@@ -11742,11 +11766,11 @@ var oa = class {
11742
11766
  deltaY: u.delta,
11743
11767
  guides: d
11744
11768
  };
11745
- }, Ha = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11769
+ }, Wa = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11746
11770
  let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
11747
11771
  for (let e of t) {
11748
11772
  let { left: t, right: n } = e;
11749
- _a({
11773
+ ya({
11750
11774
  firstStart: t,
11751
11775
  firstEnd: n,
11752
11776
  secondStart: l,
@@ -11766,22 +11790,22 @@ var oa = class {
11766
11790
  f.push({
11767
11791
  bounds: e,
11768
11792
  isActive: !0
11769
- }), Sa({
11793
+ }), wa({
11770
11794
  items: f,
11771
11795
  axis: "top"
11772
11796
  });
11773
- let p = wa({ items: f });
11797
+ let p = Ea({ items: f });
11774
11798
  if (p === -1) return {
11775
11799
  delta: 0,
11776
11800
  guides: [],
11777
11801
  context: null
11778
11802
  };
11779
- let m = [], h = c - s, g = Ca({
11803
+ let m = [], h = c - s, g = Ta({
11780
11804
  items: f,
11781
11805
  index: p,
11782
11806
  axis: "vertical",
11783
11807
  direction: "prev"
11784
- }), _ = Ca({
11808
+ }), _ = Ta({
11785
11809
  items: f,
11786
11810
  index: p,
11787
11811
  axis: "vertical",
@@ -11790,19 +11814,19 @@ var oa = class {
11790
11814
  if (v && y) {
11791
11815
  let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
11792
11816
  if (a >= 0) {
11793
- let e = ya({
11817
+ let e = xa({
11794
11818
  value: a / 2,
11795
11819
  step: 1
11796
11820
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
11797
11821
  if (Math.max(u, d) <= n) {
11798
- let t = Ra({
11822
+ let t = Ba({
11799
11823
  activeStart: s,
11800
11824
  activeEnd: c,
11801
11825
  targetGap: e,
11802
11826
  beforeEdge: r,
11803
11827
  afterEdge: i,
11804
11828
  threshold: n,
11805
- step: ma
11829
+ step: ga
11806
11830
  });
11807
11831
  if (t) {
11808
11832
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -11839,16 +11863,16 @@ var oa = class {
11839
11863
  }
11840
11864
  for (let e of r) {
11841
11865
  let { axis: t, start: r, end: i, distance: a } = e;
11842
- if (!ba({
11866
+ if (!Sa({
11843
11867
  value: a,
11844
11868
  step: .5
11845
- }) || !Ta({
11869
+ }) || !Da({
11846
11870
  patternAxis: t,
11847
11871
  activeRangeStart: l,
11848
11872
  activeRangeEnd: u,
11849
11873
  tolerance: n
11850
11874
  })) continue;
11851
- let d = Ea({
11875
+ let d = Oa({
11852
11876
  patternStart: r,
11853
11877
  patternEnd: i,
11854
11878
  activeStart: s,
@@ -11856,12 +11880,12 @@ var oa = class {
11856
11880
  });
11857
11881
  if (d) {
11858
11882
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
11859
- let e = ya({
11883
+ let e = xa({
11860
11884
  value: a - b,
11861
11885
  step: 1
11862
11886
  }), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
11863
11887
  if (u > n) continue;
11864
- let d = za({
11888
+ let d = Va({
11865
11889
  currentGap: l,
11866
11890
  referenceGap: a
11867
11891
  });
@@ -11885,12 +11909,12 @@ var oa = class {
11885
11909
  });
11886
11910
  }
11887
11911
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
11888
- let e = ya({
11912
+ let e = xa({
11889
11913
  value: x - a,
11890
11914
  step: 1
11891
11915
  }), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
11892
11916
  if (u > n) continue;
11893
- let d = za({
11917
+ let d = Va({
11894
11918
  currentGap: l,
11895
11919
  referenceGap: a
11896
11920
  });
@@ -11915,16 +11939,16 @@ var oa = class {
11915
11939
  }
11916
11940
  }
11917
11941
  }
11918
- return La({
11942
+ return za({
11919
11943
  options: m,
11920
11944
  previousContext: i,
11921
11945
  switchDistance: a
11922
11946
  });
11923
- }, Ua = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11947
+ }, Ga = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11924
11948
  let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
11925
11949
  for (let e of t) {
11926
11950
  let { top: t, bottom: n } = e;
11927
- _a({
11951
+ ya({
11928
11952
  firstStart: t,
11929
11953
  firstEnd: n,
11930
11954
  secondStart: l,
@@ -11944,22 +11968,22 @@ var oa = class {
11944
11968
  f.push({
11945
11969
  bounds: e,
11946
11970
  isActive: !0
11947
- }), Sa({
11971
+ }), wa({
11948
11972
  items: f,
11949
11973
  axis: "left"
11950
11974
  });
11951
- let p = wa({ items: f });
11975
+ let p = Ea({ items: f });
11952
11976
  if (p === -1) return {
11953
11977
  delta: 0,
11954
11978
  guides: [],
11955
11979
  context: null
11956
11980
  };
11957
- let m = [], h = c - s, g = Ca({
11981
+ let m = [], h = c - s, g = Ta({
11958
11982
  items: f,
11959
11983
  index: p,
11960
11984
  axis: "horizontal",
11961
11985
  direction: "prev"
11962
- }), _ = Ca({
11986
+ }), _ = Ta({
11963
11987
  items: f,
11964
11988
  index: p,
11965
11989
  axis: "horizontal",
@@ -11968,19 +11992,19 @@ var oa = class {
11968
11992
  if (v && y) {
11969
11993
  let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
11970
11994
  if (a >= 0) {
11971
- let e = ya({
11995
+ let e = xa({
11972
11996
  value: a / 2,
11973
11997
  step: 1
11974
11998
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
11975
11999
  if (Math.max(u, d) <= n) {
11976
- let t = Ra({
12000
+ let t = Ba({
11977
12001
  activeStart: s,
11978
12002
  activeEnd: c,
11979
12003
  targetGap: e,
11980
12004
  beforeEdge: r,
11981
12005
  afterEdge: i,
11982
12006
  threshold: n,
11983
- step: ma
12007
+ step: ga
11984
12008
  });
11985
12009
  if (t) {
11986
12010
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -12017,16 +12041,16 @@ var oa = class {
12017
12041
  }
12018
12042
  for (let e of r) {
12019
12043
  let { axis: t, start: r, end: i, distance: a } = e;
12020
- if (!ba({
12044
+ if (!Sa({
12021
12045
  value: a,
12022
12046
  step: .5
12023
- }) || !Ta({
12047
+ }) || !Da({
12024
12048
  patternAxis: t,
12025
12049
  activeRangeStart: l,
12026
12050
  activeRangeEnd: u,
12027
12051
  tolerance: n
12028
12052
  })) continue;
12029
- let d = Ea({
12053
+ let d = Oa({
12030
12054
  patternStart: r,
12031
12055
  patternEnd: i,
12032
12056
  activeStart: s,
@@ -12034,12 +12058,12 @@ var oa = class {
12034
12058
  });
12035
12059
  if (d) {
12036
12060
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
12037
- let e = ya({
12061
+ let e = xa({
12038
12062
  value: a - b,
12039
12063
  step: 1
12040
12064
  }), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
12041
12065
  if (u > n) continue;
12042
- let d = za({
12066
+ let d = Va({
12043
12067
  currentGap: l,
12044
12068
  referenceGap: a
12045
12069
  });
@@ -12063,12 +12087,12 @@ var oa = class {
12063
12087
  });
12064
12088
  }
12065
12089
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
12066
- let e = ya({
12090
+ let e = xa({
12067
12091
  value: x - a,
12068
12092
  step: 1
12069
12093
  }), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
12070
12094
  if (u > n) continue;
12071
- let d = za({
12095
+ let d = Va({
12072
12096
  currentGap: l,
12073
12097
  referenceGap: a
12074
12098
  });
@@ -12093,20 +12117,20 @@ var oa = class {
12093
12117
  }
12094
12118
  }
12095
12119
  }
12096
- return La({
12120
+ return za({
12097
12121
  options: m,
12098
12122
  previousContext: i,
12099
12123
  switchDistance: a
12100
12124
  });
12101
- }, Wa = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
12102
- let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Ha({
12125
+ }, Ka = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
12126
+ let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Wa({
12103
12127
  activeBounds: e,
12104
12128
  candidates: t,
12105
12129
  threshold: n,
12106
12130
  patterns: r.vertical,
12107
12131
  previousContext: o,
12108
12132
  switchDistance: a
12109
- }), l = Ua({
12133
+ }), l = Ga({
12110
12134
  activeBounds: e,
12111
12135
  candidates: t,
12112
12136
  threshold: n,
@@ -12125,14 +12149,14 @@ var oa = class {
12125
12149
  horizontal: l.context
12126
12150
  }
12127
12151
  };
12128
- }, Ga = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
12152
+ }, qa = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
12129
12153
  let o = Math.min(a, r / 2, i / 2);
12130
12154
  e.moveTo(t + o, n), e.lineTo(t + r - o, n), e.quadraticCurveTo(t + r, n, t + r, n + o), e.lineTo(t + r, n + i - o), e.quadraticCurveTo(t + r, n + i, t + r - o, n + i), e.lineTo(t + o, n + i), e.quadraticCurveTo(t, n + i, t, n + i - o), e.lineTo(t, n + o), e.quadraticCurveTo(t, n, t + o, n), e.closePath();
12131
- }, Ka = ({ context: e, type: t, axis: n, start: r, end: i, text: a, zoom: o, color: s, textColor: c = "#ffffff", fontFamily: l = "sans-serif", lineWidth: u = 1, padding: d = 4, radius: f = 4, offsetAlongAxis: p = 0, offsetPerpendicular: m = 0 }) => {
12155
+ }, Ja = ({ context: e, type: t, axis: n, start: r, end: i, text: a, zoom: o, color: s, textColor: c = "#ffffff", fontFamily: l = "sans-serif", lineWidth: u = 1, padding: d = 4, radius: f = 4, offsetAlongAxis: p = 0, offsetPerpendicular: m = 0 }) => {
12132
12156
  let h = o || 1, g = 12 / h, _ = d / h, v = f / h, y = (r + i) / 2 + p, b = t === "vertical" ? n + m : y, x = t === "vertical" ? y : n + m;
12133
12157
  e.save(), e.setLineDash([]), e.fillStyle = s, e.strokeStyle = s, e.lineWidth = u / h, e.font = `${g}px ${l}`, e.textAlign = "center", e.textBaseline = "middle";
12134
12158
  let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
12135
- e.beginPath(), Ga({
12159
+ e.beginPath(), qa({
12136
12160
  context: e,
12137
12161
  x: w,
12138
12162
  y: T,
@@ -12140,11 +12164,11 @@ var oa = class {
12140
12164
  height: C,
12141
12165
  radius: v
12142
12166
  }), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
12143
- }, qa = ({ context: e, guide: t, zoom: n }) => {
12144
- let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = ha({ distance: l }).toString();
12167
+ }, Ya = ({ context: e, guide: t, zoom: n }) => {
12168
+ let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = _a({ distance: l }).toString();
12145
12169
  e.beginPath(), r === "vertical" ? (e.moveTo(i, a), e.lineTo(i, o), e.moveTo(i, s), e.lineTo(i, c)) : (e.moveTo(a, i), e.lineTo(o, i), e.moveTo(s, i), e.lineTo(c, i)), e.stroke();
12146
- let d = pa;
12147
- Ka({
12170
+ let d = ha;
12171
+ Ja({
12148
12172
  context: e,
12149
12173
  type: r,
12150
12174
  axis: i,
@@ -12154,7 +12178,7 @@ var oa = class {
12154
12178
  zoom: n,
12155
12179
  color: d,
12156
12180
  lineWidth: 1
12157
- }), Ka({
12181
+ }), Ja({
12158
12182
  context: e,
12159
12183
  type: r,
12160
12184
  axis: i,
@@ -12165,10 +12189,10 @@ var oa = class {
12165
12189
  color: d,
12166
12190
  lineWidth: 1
12167
12191
  });
12168
- }, Ja = ({ anchors: e, bounds: t }) => {
12192
+ }, Xa = ({ anchors: e, bounds: t }) => {
12169
12193
  let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
12170
12194
  e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
12171
- }, Ya = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
12195
+ }, Za = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
12172
12196
  let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
12173
12197
  for (let e = 0; e < s.length; e += 1) {
12174
12198
  let c = s[e], l = null, u = Infinity;
@@ -12189,35 +12213,35 @@ var oa = class {
12189
12213
  });
12190
12214
  }
12191
12215
  return i;
12192
- }, Xa = ({ bounds: e }) => ({
12193
- vertical: Ya({
12216
+ }, Qa = ({ bounds: e }) => ({
12217
+ vertical: Za({
12194
12218
  bounds: e,
12195
12219
  axis: "centerX",
12196
12220
  type: "vertical",
12197
12221
  primaryStart: "top",
12198
12222
  primaryEnd: "bottom"
12199
12223
  }),
12200
- horizontal: Ya({
12224
+ horizontal: Za({
12201
12225
  bounds: e,
12202
12226
  axis: "centerY",
12203
12227
  type: "horizontal",
12204
12228
  primaryStart: "left",
12205
12229
  primaryEnd: "right"
12206
12230
  })
12207
- }), Za = [
12231
+ }), $a = [
12208
12232
  "montage-area",
12209
12233
  "background",
12210
12234
  "interaction-blocker"
12211
- ], Qa = ({ activeObject: t }) => {
12235
+ ], eo = ({ activeObject: t }) => {
12212
12236
  let n = /* @__PURE__ */ new Set();
12213
12237
  return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
12214
- }, $a = ({ object: e, excluded: t, ignoredIds: n = Za }) => {
12238
+ }, to = ({ object: e, excluded: t, ignoredIds: n = $a }) => {
12215
12239
  if (t.has(e)) return !0;
12216
12240
  let { visible: r = !0 } = e;
12217
12241
  if (!r) return !0;
12218
12242
  let { id: i } = e;
12219
12243
  return !!(i && n.includes(i));
12220
- }, eo = class e {
12244
+ }, no = class e {
12221
12245
  constructor({ editor: e }) {
12222
12246
  this.anchors = {
12223
12247
  vertical: [],
@@ -12270,7 +12294,7 @@ var oa = class {
12270
12294
  this._clearSpacingContexts(), this._clearGuides();
12271
12295
  return;
12272
12296
  }
12273
- let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Va({
12297
+ let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Ua({
12274
12298
  activeBounds: a,
12275
12299
  threshold: c,
12276
12300
  anchors: this.anchors
@@ -12282,7 +12306,7 @@ var oa = class {
12282
12306
  top: t + u
12283
12307
  }), n.setCoords(), a = G({ object: n }) ?? a;
12284
12308
  }
12285
- let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = Wa({
12309
+ let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = Ka({
12286
12310
  activeBounds: a,
12287
12311
  candidates: d,
12288
12312
  threshold: f,
@@ -12303,11 +12327,11 @@ var oa = class {
12303
12327
  target: n,
12304
12328
  transform: i
12305
12329
  });
12306
- let h = G({ object: n }) ?? a, g = Va({
12330
+ let h = G({ object: n }) ?? a, g = Ua({
12307
12331
  activeBounds: h,
12308
12332
  threshold: c,
12309
12333
  anchors: this.anchors
12310
- }), _ = Wa({
12334
+ }), _ = Ka({
12311
12335
  activeBounds: h,
12312
12336
  candidates: d,
12313
12337
  threshold: c,
@@ -12538,9 +12562,9 @@ var oa = class {
12538
12562
  let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
12539
12563
  if (!n) return;
12540
12564
  let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
12541
- n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = pa, n.setLineDash([4, 4]);
12565
+ n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = ha, n.setLineDash([4, 4]);
12542
12566
  for (let e of this.activeGuides) n.beginPath(), e.type === "vertical" ? (n.moveTo(e.position, a), n.lineTo(e.position, o)) : (n.moveTo(r, e.position), n.lineTo(i, e.position)), n.stroke();
12543
- for (let e of this.activeSpacingGuides) qa({
12567
+ for (let e of this.activeSpacingGuides) Ya({
12544
12568
  context: n,
12545
12569
  guide: e,
12546
12570
  zoom: c
@@ -12751,14 +12775,14 @@ var oa = class {
12751
12775
  }, r = [];
12752
12776
  for (let e of t) {
12753
12777
  let t = G({ object: e });
12754
- t && (Ja({
12778
+ t && (Xa({
12755
12779
  anchors: n,
12756
12780
  bounds: t
12757
12781
  }), r.push(t));
12758
12782
  }
12759
12783
  let { montageArea: i } = this.editor, a = G({ object: i });
12760
12784
  if (a) {
12761
- Ja({
12785
+ Xa({
12762
12786
  anchors: n,
12763
12787
  bounds: a
12764
12788
  });
@@ -12770,12 +12794,12 @@ var oa = class {
12770
12794
  bottom: i
12771
12795
  };
12772
12796
  } else this.guideBounds = this._calculateViewportBounds();
12773
- this.anchors = n, this.spacingPatterns = Xa({ bounds: r }), this.cachedTargetBounds = r;
12797
+ this.anchors = n, this.spacingPatterns = Qa({ bounds: r }), this.cachedTargetBounds = r;
12774
12798
  }
12775
12799
  _collectTargets({ activeObject: e }) {
12776
- let t = Qa({ activeObject: e }), n = [];
12800
+ let t = eo({ activeObject: e }), n = [];
12777
12801
  return this.canvas.forEachObject((e) => {
12778
- $a({
12802
+ to({
12779
12803
  object: e,
12780
12804
  excluded: t
12781
12805
  }) || n.push(e);
@@ -12798,7 +12822,7 @@ var oa = class {
12798
12822
  bottom: (r - s) / a
12799
12823
  };
12800
12824
  }
12801
- }, to = "#3D8BF4", no = class e {
12825
+ }, ro = "#3D8BF4", io = class e {
12802
12826
  constructor({ editor: e }) {
12803
12827
  this.activeGuides = [], this.isAltPressed = !1, this.pendingEvent = null, this.frameRequest = null, this.isToolbarHidden = !1, this.isTargetMontageArea = !1, this.lastMouseEvent = null, this.editor = e, this.canvas = e.canvas, this._onMouseMove = this._handleMouseMove.bind(this), this._onBeforeRender = this._handleBeforeRender.bind(this), this._onAfterRender = this._handleAfterRender.bind(this), this._onSelectionCleared = this._handleSelectionCleared.bind(this), this._onKeyDown = this._handleKeyDown.bind(this), this._onKeyUp = this._handleKeyUp.bind(this), this._onWindowBlur = this._handleWindowBlur.bind(this), this._bindEvents();
12804
12828
  }
@@ -12891,8 +12915,8 @@ var oa = class {
12891
12915
  this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
12892
12916
  }
12893
12917
  static _resolveTarget({ event: e, activeObject: t }) {
12894
- let { target: n } = e, r = Qa({ activeObject: t });
12895
- return n && !$a({
12918
+ let { target: n } = e, r = eo({ activeObject: t });
12919
+ return n && !to({
12896
12920
  object: n,
12897
12921
  excluded: r
12898
12922
  }) ? n : null;
@@ -13009,18 +13033,18 @@ var oa = class {
13009
13033
  let { canvas: e } = this, t = e.getSelectionContext();
13010
13034
  if (!t) return;
13011
13035
  let { viewportTransform: n } = e, r = e.getZoom() || 1, i = this.activeGuides.some((e) => e.type === "vertical"), a = this.activeGuides.some((e) => e.type === "horizontal"), o = i && a && !this.isTargetMontageArea, s = o ? 12 / r : 0;
13012
- t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = to, t.setLineDash([]);
13036
+ t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = ro, t.setLineDash([]);
13013
13037
  for (let e of this.activeGuides) {
13014
13038
  let { type: n, axis: i, start: a, end: c, distance: l } = e, u = Math.abs(c - a), d = o ? (a <= c ? -1 : 1) * (u / 2 + s) : 0;
13015
- t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Ka({
13039
+ t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Ja({
13016
13040
  context: t,
13017
13041
  type: n,
13018
13042
  axis: i,
13019
13043
  start: a,
13020
13044
  end: c,
13021
- text: ha({ distance: l }).toString(),
13045
+ text: _a({ distance: l }).toString(),
13022
13046
  zoom: r,
13023
- color: to,
13047
+ color: ro,
13024
13048
  lineWidth: 1,
13025
13049
  offsetAlongAxis: d,
13026
13050
  offsetPerpendicular: 0
@@ -13038,13 +13062,13 @@ var oa = class {
13038
13062
  let { toolbar: e } = this.editor;
13039
13063
  e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
13040
13064
  }
13041
- }, ro = class e {
13065
+ }, ao = class e {
13042
13066
  constructor(e, t) {
13043
13067
  this.options = t, this.containerId = e, this.editorId = `${e}-${O()}`, this.init();
13044
13068
  }
13045
13069
  async init() {
13046
13070
  let { editorContainerWidth: e, editorContainerHeight: n, canvasWrapperWidth: r, canvasWrapperHeight: i, canvasCSSWidth: a, canvasCSSHeight: o, initialImage: s, initialState: c, scaleType: l, showRotationAngle: u, _onReadyCallback: d } = this.options;
13047
- if (fe.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new j(), this.workerManager = new N(), this.errorManager = new Vi({ editor: this }), this.historyManager = new kt({ editor: this }), this.toolbar = new et({ editor: this }), this.transformManager = new Bt({ editor: this }), this.zoomManager = new Vt({ editor: this }), this.canvasManager = new zt({ editor: this }), this.imageManager = new Ft({ editor: this }), this.layerManager = new Xt({ editor: this }), this.shapeManager = new Ni({ editor: this }), this.interactionBlocker = new Jt({ editor: this }), this.backgroundManager = new Yt({ editor: this }), this.clipboardManager = new Fi({ editor: this }), this.objectLockManager = new Ii({ editor: this }), this.groupingManager = new Li({ editor: this }), this.selectionManager = new Ri({ editor: this }), this.deletionManager = new zi({ editor: this }), this.panConstraintManager = new Hi({ editor: this }), this.snappingManager = new eo({ editor: this }), this.measurementManager = new no({ editor: this }), this.fontManager = new pe(this.options.fonts ?? []), this.textManager = new sa({ editor: this }), this.templateManager = new fa({ editor: this }), u && (this.angleIndicator = new rt({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new A({
13071
+ if (fe.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new j(), this.workerManager = new N(), this.errorManager = new Hi({ editor: this }), this.historyManager = new kt({ editor: this }), this.toolbar = new et({ editor: this }), this.transformManager = new Bt({ editor: this }), this.zoomManager = new Vt({ editor: this }), this.canvasManager = new zt({ editor: this }), this.imageManager = new Ft({ editor: this }), this.layerManager = new Xt({ editor: this }), this.shapeManager = new Pi({ editor: this }), this.interactionBlocker = new Jt({ editor: this }), this.backgroundManager = new Yt({ editor: this }), this.clipboardManager = new Ii({ editor: this }), this.objectLockManager = new Li({ editor: this }), this.groupingManager = new Ri({ editor: this }), this.selectionManager = new zi({ editor: this }), this.deletionManager = new Bi({ editor: this }), this.panConstraintManager = new Ui({ editor: this }), this.snappingManager = new no({ editor: this }), this.measurementManager = new io({ editor: this }), this.fontManager = new pe(this.options.fonts ?? []), this.textManager = new la({ editor: this }), this.templateManager = new ma({ editor: this }), u && (this.angleIndicator = new rt({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new A({
13048
13072
  editor: this,
13049
13073
  options: this.options
13050
13074
  }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(n), this.canvasManager.setCanvasWrapperWidth(r), this.canvasManager.setCanvasWrapperHeight(i), this.canvasManager.setCanvasCSSWidth(a), this.canvasManager.setCanvasCSSHeight(o), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), await this.fontManager.loadFonts(), c) {
@@ -13152,7 +13176,7 @@ var oa = class {
13152
13176
  "U+A640-A69F",
13153
13177
  "U+FE2E-FE2F",
13154
13178
  "U+2116"
13155
- ].join(", "), io = {
13179
+ ].join(", "), oo = {
13156
13180
  preserveObjectStacking: !0,
13157
13181
  controlsAboveOverlay: !0,
13158
13182
  centeredRotation: !0,
@@ -14006,20 +14030,20 @@ var oa = class {
14006
14030
  };
14007
14031
  //#endregion
14008
14032
  //#region src/main.ts
14009
- function ao(e, t = {}) {
14033
+ function so(e, t = {}) {
14010
14034
  let n = {
14011
- ...io,
14035
+ ...oo,
14012
14036
  ...t
14013
14037
  }, r = document.getElementById(e);
14014
14038
  if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
14015
14039
  let i = document.createElement("canvas");
14016
14040
  return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
14017
14041
  n._onReadyCallback = t;
14018
- let r = new ro(i.id, n);
14042
+ let r = new ao(i.id, n);
14019
14043
  window[e] = r;
14020
14044
  });
14021
14045
  }
14022
14046
  //#endregion
14023
- export { ao as default };
14047
+ export { so as default };
14024
14048
 
14025
14049
  //# sourceMappingURL=main.js.map