@anu3ev/fabric-image-editor 0.8.6 → 0.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +1481 -1023
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -263,12 +263,12 @@ function R(e, t, n, r, i) {
263
263
  }
264
264
  var te = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ne = new Image();
265
265
  ne.src = te;
266
- function z(e, t, n, r, i) {
266
+ function re(e, t, n, r, i) {
267
267
  e.save(), e.translate(t, n), e.rotate(w.degreesToRadians(i.angle)), e.fillStyle = P, e.beginPath(), e.arc(0, 0, 16, 0, 2 * Math.PI), e.fill(), e.drawImage(ne, -16 / 2, -16 / 2, 16, 16), e.restore();
268
268
  }
269
269
  //#endregion
270
270
  //#region src/editor/customized-controls/default-controls.ts
271
- var re = {
271
+ var z = {
272
272
  tl: {
273
273
  render: L,
274
274
  sizeX: 12,
@@ -326,57 +326,57 @@ var re = {
326
326
  offsetY: 0
327
327
  },
328
328
  mtr: {
329
- render: z,
329
+ render: re,
330
330
  sizeX: 32,
331
331
  sizeY: 32,
332
332
  offsetX: 0,
333
333
  offsetY: -32
334
334
  }
335
- }, B = [
335
+ }, ie = [
336
336
  "tl",
337
337
  "tr",
338
338
  "bl",
339
339
  "br"
340
- ], ie = ({ transform: e }) => {
340
+ ], B = ({ transform: e }) => {
341
341
  let { originX: t, originY: n } = e;
342
342
  return (t === "center" || t === .5) && (n === "center" || n === .5);
343
- }, V = ({ transform: e, x: t, y: n }) => {
343
+ }, ae = ({ transform: e, x: t, y: n }) => {
344
344
  let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i, s = x.getLocalPoint(r, r.originX, r.originY, t, n), c = Math.sign(s.x || r.signX || 1), l = Math.sign(s.y || r.signY || 1);
345
345
  r.signX === void 0 && (r.signX = c), r.signY === void 0 && (r.signY = l);
346
346
  let u = i._getTransformedDimensions(), d = Math.abs(s.x * a / u.x), f = Math.abs(s.y * o / u.y);
347
- ie({ transform: r }) && (d *= 2, f *= 2);
347
+ B({ transform: r }) && (d *= 2, f *= 2);
348
348
  let p = !i.lockScalingX && (!i.lockScalingFlip || r.signX === c), m = !i.lockScalingY && (!i.lockScalingFlip || r.signY === l);
349
349
  return p && i.set("scaleX", d), m && i.set("scaleY", f), a !== i.scaleX || o !== i.scaleY;
350
- }, ae = () => {
351
- let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => V({
350
+ }, V = () => {
351
+ let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => ae({
352
352
  transform: t,
353
353
  x: n,
354
354
  y: r
355
355
  })));
356
356
  return (t, n, r, i) => {
357
357
  let { canvas: a } = n.target, o = !!t.shiftKey;
358
- if (!a || !o) return e(t, n, r, i);
358
+ if (!a || o) return e(t, n, r, i);
359
359
  let { uniformScaling: s } = a;
360
- a.uniformScaling = !1;
360
+ a.uniformScaling = !0;
361
361
  try {
362
362
  return x.scalingEqually(t, n, r, i);
363
363
  } finally {
364
364
  a.uniformScaling = s;
365
365
  }
366
366
  };
367
- }, H = ({ control: e }) => {
367
+ }, oe = ({ control: e }) => {
368
368
  let t = new r({
369
369
  ...e,
370
- actionHandler: ae()
370
+ actionHandler: V()
371
371
  });
372
372
  return t.shapeFreeScaleCornerControl = !0, t;
373
- }, oe = ({ target: e }) => {
373
+ }, H = ({ target: e }) => {
374
374
  let t = { ...e.controls }, n = !1;
375
- B.forEach((r) => {
375
+ ie.forEach((r) => {
376
376
  let i = e.controls[r];
377
- i && (i.shapeFreeScaleCornerControl || (t[r] = H({ control: i }), n = !0));
377
+ i && (i.shapeFreeScaleCornerControl || (t[r] = oe({ control: i }), n = !0));
378
378
  }), n && (e.controls = t);
379
- }, se = class t {
379
+ }, U = class t {
380
380
  static wrapWidthControl(e) {
381
381
  if (!e?.actionHandler) return;
382
382
  let t = e.actionHandler;
@@ -386,7 +386,7 @@ var re = {
386
386
  };
387
387
  }
388
388
  static applyControlOverrides(e) {
389
- Object.entries(re).forEach(([t, n]) => {
389
+ Object.entries(z).forEach(([t, n]) => {
390
390
  let r = e[t];
391
391
  r && (Object.assign(r, n), t === "mtr" && (r.cursorStyle = "grab", r.mouseDownHandler = (e, t, n, r) => {
392
392
  let i = t?.target;
@@ -469,14 +469,14 @@ var re = {
469
469
  }
470
470
  static applyActiveSelectionScalingRules({ selection: e, objects: t }) {
471
471
  let n = t.some((e) => e instanceof v), r = t.some((e) => e.shapeComposite === !0), i = n || r;
472
- e.set({ lockScalingFlip: i }), r && oe({ target: e }), e.setControlsVisibility({
472
+ e.set({ lockScalingFlip: i }), r && H({ target: e }), e.setControlsVisibility({
473
473
  mt: !n,
474
474
  mb: !n,
475
475
  ml: !0,
476
476
  mr: !0
477
477
  });
478
478
  }
479
- }, ce = class e {
479
+ }, se = class e {
480
480
  static {
481
481
  this.registeredFontKeys = /* @__PURE__ */ new Set();
482
482
  }
@@ -630,32 +630,32 @@ var re = {
630
630
  return Object.entries(e).filter(([, e]) => e != null && `${e}`.length > 0).map(([e, n]) => `${t[e] ?? e}: ${n};`);
631
631
  }
632
632
  };
633
- function U({ rounding: e }) {
633
+ function W({ rounding: e }) {
634
634
  return typeof e != "number" || !Number.isFinite(e) ? 0 : Math.min(100, Math.max(0, e));
635
635
  }
636
- function W({ rounding: e }) {
637
- return U({ rounding: e }) / 100;
636
+ function G({ rounding: e }) {
637
+ return W({ rounding: e }) / 100;
638
638
  }
639
639
  //#endregion
640
640
  //#region src/editor/shape-manager/shape-presets.ts
641
- var G = 180, le = {
641
+ var K = 180, ce = {
642
642
  top: 0,
643
643
  right: 0,
644
644
  bottom: 0,
645
645
  left: 0
646
- }, ue = .45, K = ({ value: e }) => Number(e.toFixed(4)), q = ({ width: e, height: t }) => {
647
- let n = G / Math.max(e, t);
646
+ }, le = .45, ue = ({ value: e }) => Number(e.toFixed(4)), q = ({ width: e, height: t }) => {
647
+ let n = K / Math.max(e, t);
648
648
  return {
649
- width: K({ value: e * n }),
650
- height: K({ value: t * n })
649
+ width: ue({ value: e * n }),
650
+ height: ue({ value: t * n })
651
651
  };
652
652
  }, de = ({ spikes: e, outerRadius: t = 50, innerRadius: n = 22, centerX: r = 50, centerY: i = 50, rotation: a = -Math.PI / 2 }) => {
653
653
  let o = [], s = e * 2;
654
654
  for (let c = 0; c < s; c += 1) {
655
655
  let s = c % 2 == 0 ? t : n, l = a + c * Math.PI / e;
656
656
  o.push({
657
- x: K({ value: r + s * Math.cos(l) }),
658
- y: K({ value: i + s * Math.sin(l) })
657
+ x: ue({ value: r + s * Math.cos(l) }),
658
+ y: ue({ value: i + s * Math.sin(l) })
659
659
  });
660
660
  }
661
661
  return o;
@@ -663,8 +663,8 @@ var G = 180, le = {
663
663
  {
664
664
  key: "circle",
665
665
  type: "ellipse",
666
- width: G,
667
- height: G,
666
+ width: K,
667
+ height: K,
668
668
  internalTextInset: {
669
669
  top: .05,
670
670
  right: .05,
@@ -698,14 +698,14 @@ var G = 180, le = {
698
698
  {
699
699
  key: "square",
700
700
  type: "rect",
701
- width: G,
702
- height: G
701
+ width: K,
702
+ height: K
703
703
  },
704
704
  {
705
705
  key: "diamond",
706
706
  type: "polygon",
707
- width: G,
708
- height: G,
707
+ width: K,
708
+ height: K,
709
709
  points: [
710
710
  {
711
711
  x: 50,
@@ -864,8 +864,8 @@ var G = 180, le = {
864
864
  {
865
865
  key: "star-16",
866
866
  type: "polygon",
867
- width: G,
868
- height: G,
867
+ width: K,
868
+ height: K,
869
869
  points: de({
870
870
  spikes: 16,
871
871
  outerRadius: 50,
@@ -882,8 +882,8 @@ var G = 180, le = {
882
882
  {
883
883
  key: "sparkle",
884
884
  type: "polygon",
885
- width: G,
886
- height: G,
885
+ width: K,
886
+ height: K,
887
887
  points: de({
888
888
  spikes: 4,
889
889
  outerRadius: 50,
@@ -919,7 +919,7 @@ var G = 180, le = {
919
919
  {
920
920
  key: "arrow-right-fat",
921
921
  type: "polygon",
922
- width: G,
922
+ width: K,
923
923
  height: 130,
924
924
  points: [
925
925
  {
@@ -952,9 +952,9 @@ var G = 180, le = {
952
952
  }
953
953
  ],
954
954
  internalTextInset: {
955
- top: .24,
955
+ top: .34,
956
956
  right: .42,
957
- bottom: .24,
957
+ bottom: .34,
958
958
  left: .16
959
959
  }
960
960
  },
@@ -962,7 +962,7 @@ var G = 180, le = {
962
962
  key: "arrow-up-fat",
963
963
  type: "polygon",
964
964
  width: 130,
965
- height: G,
965
+ height: K,
966
966
  points: [
967
967
  {
968
968
  x: 38,
@@ -1132,7 +1132,7 @@ var G = 180, le = {
1132
1132
  key: "arrow-down-fat",
1133
1133
  type: "polygon",
1134
1134
  width: 130,
1135
- height: G,
1135
+ height: K,
1136
1136
  points: [
1137
1137
  {
1138
1138
  x: 38,
@@ -1373,8 +1373,8 @@ var G = 180, le = {
1373
1373
  {
1374
1374
  key: "cross",
1375
1375
  type: "polygon",
1376
- width: G,
1377
- height: G,
1376
+ width: K,
1377
+ height: K,
1378
1378
  points: [
1379
1379
  {
1380
1380
  x: 67.6471,
@@ -1466,8 +1466,8 @@ var G = 180, le = {
1466
1466
  {
1467
1467
  key: "gear",
1468
1468
  type: "polygon",
1469
- width: G,
1470
- height: G,
1469
+ width: K,
1470
+ height: K,
1471
1471
  points: de({
1472
1472
  spikes: 14,
1473
1473
  outerRadius: 50,
@@ -1484,8 +1484,8 @@ var G = 180, le = {
1484
1484
  {
1485
1485
  key: "badge",
1486
1486
  type: "path",
1487
- width: G,
1488
- height: G,
1487
+ width: K,
1488
+ height: K,
1489
1489
  path: "M24 6 H76 L94 24 V76 L76 94 H24 L6 76 V24 Z",
1490
1490
  internalTextInset: {
1491
1491
  top: .1,
@@ -1496,7 +1496,7 @@ var G = 180, le = {
1496
1496
  key: "bookmark",
1497
1497
  type: "polygon",
1498
1498
  width: 130,
1499
- height: G,
1499
+ height: K,
1500
1500
  points: [
1501
1501
  {
1502
1502
  x: 18,
@@ -1524,7 +1524,7 @@ var G = 180, le = {
1524
1524
  {
1525
1525
  key: "tag",
1526
1526
  type: "path",
1527
- width: G,
1527
+ width: K,
1528
1528
  height: 130,
1529
1529
  path: "M4 20 L64 20 L96 50 L64 80 L4 80 Z",
1530
1530
  internalTextInset: { right: .28 }
@@ -1533,7 +1533,7 @@ var G = 180, le = {
1533
1533
  key: "moon",
1534
1534
  type: "path",
1535
1535
  width: 150,
1536
- height: G,
1536
+ height: K,
1537
1537
  path: [
1538
1538
  "M68 4 C36 4 10 30 10 62",
1539
1539
  "C10 94 36 120 68 120 C85 120 100 112 111 100",
@@ -1551,28 +1551,28 @@ for (let e = 0; e < fe.length; e += 1) {
1551
1551
  let t = fe[e];
1552
1552
  ge[t.key] = t;
1553
1553
  }
1554
- var _e = ge, ve = ({ presetKey: e }) => _e[e] ?? null, ye = ({ preset: e, rounding: t }) => U({ rounding: t }) <= 0 || e.type === "rect" ? e.key : e.roundedVariant ?? e.key;
1554
+ var _e = ge, ve = ({ presetKey: e }) => _e[e] ?? null, ye = ({ preset: e, rounding: t }) => W({ rounding: t }) <= 0 || e.type === "rect" ? e.key : e.roundedVariant ?? e.key;
1555
1555
  function be({ value: e, size: t }) {
1556
- let n = Number.isFinite(e) ? Math.min(Math.max(e, 0), ue) : 0;
1556
+ let n = Number.isFinite(e) ? Math.min(Math.max(e, 0), le) : 0;
1557
1557
  return (Number.isFinite(t) && t > 0 ? t : 0) * n;
1558
1558
  }
1559
1559
  var xe = ({ preset: e, width: t, height: n }) => {
1560
1560
  let r = e.internalTextInset ?? {};
1561
1561
  return {
1562
1562
  top: be({
1563
- value: r.top ?? le.top,
1563
+ value: r.top ?? ce.top,
1564
1564
  size: n
1565
1565
  }),
1566
1566
  right: be({
1567
- value: r.right ?? le.right,
1567
+ value: r.right ?? ce.right,
1568
1568
  size: t
1569
1569
  }),
1570
1570
  bottom: be({
1571
- value: r.bottom ?? le.bottom,
1571
+ value: r.bottom ?? ce.bottom,
1572
1572
  size: n
1573
1573
  }),
1574
1574
  left: be({
1575
- value: r.left ?? le.left,
1575
+ value: r.left ?? ce.left,
1576
1576
  size: t
1577
1577
  })
1578
1578
  };
@@ -1754,7 +1754,7 @@ var Ve = class e extends l {
1754
1754
  bottom: this.shapePaddingBottom,
1755
1755
  left: this.shapePaddingLeft
1756
1756
  } });
1757
- this.shapePaddingTop = e.top, this.shapePaddingRight = e.right, this.shapePaddingBottom = e.bottom, this.shapePaddingLeft = e.left, this._syncRoundability(), Pe({ group: this }), oe({ target: this });
1757
+ this.shapePaddingTop = e.top, this.shapePaddingRight = e.right, this.shapePaddingBottom = e.bottom, this.shapePaddingLeft = e.left, this._syncRoundability(), Pe({ group: this }), H({ target: this });
1758
1758
  let t = Le({ group: this });
1759
1759
  t && Fe({ text: t }), Ie({ group: this }), this.setCoords();
1760
1760
  }
@@ -1770,6 +1770,9 @@ var Ve = class e extends l {
1770
1770
  targets: c.getObjects()
1771
1771
  }), c.rehydrateRuntimeState(), c.setCoords(), c;
1772
1772
  }
1773
+ replaceShapeNode(e, t, n) {
1774
+ this._objects.splice(e, 1), this.exitGroup(t, !0), this._objects.splice(e, 0, n), this.enterGroup(n, !1), this._set("dirty", !0);
1775
+ }
1773
1776
  _syncRoundability() {
1774
1777
  if (typeof this.shapeCanRound == "boolean") return;
1775
1778
  let e = this.shapePresetKey;
@@ -3271,15 +3274,19 @@ var Nt = class {
3271
3274
  constructor({ editor: e }) {
3272
3275
  this.editor = e, this.options = e.options;
3273
3276
  }
3277
+ setAngle(e, t, { withoutSave: n } = {}) {
3278
+ let { canvas: r, historyManager: i } = this.editor;
3279
+ e && (e.rotate(t), e.setCoords(), r.renderAll(), n || i.saveState(), r.fire("editor:object-rotated", {
3280
+ object: e,
3281
+ withoutSave: n,
3282
+ angle: t
3283
+ }));
3284
+ }
3274
3285
  rotate(e = 90, { withoutSave: t } = {}) {
3275
- let { canvas: n, historyManager: r } = this.editor, i = n.getActiveObject();
3276
- if (!i) return;
3277
- let a = i.angle + e;
3278
- i.rotate(a), i.setCoords(), n.renderAll(), t || r.saveState(), n.fire("editor:object-rotated", {
3279
- object: i,
3280
- withoutSave: t,
3281
- angle: a
3282
- });
3286
+ let { canvas: n } = this.editor, r = n.getActiveObject();
3287
+ if (!r) return;
3288
+ let i = (r.angle ?? 0) + e;
3289
+ this.setAngle(r, i, { withoutSave: t });
3283
3290
  }
3284
3291
  flipX({ withoutSave: e } = {}) {
3285
3292
  let { canvas: t, historyManager: n } = this.editor, r = t.getActiveObject();
@@ -4199,10 +4206,21 @@ var Ut = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
4199
4206
  changed: !1
4200
4207
  };
4201
4208
  }, ln = ({ cleanup: e, lineCount: t, styles: n }) => {
4202
- if (!e || e.lineIndex >= t) return {
4209
+ if (!e) return {
4203
4210
  styles: n,
4204
4211
  changed: !1
4205
4212
  };
4213
+ if (e.lineIndex >= t) {
4214
+ if (!n[e.lineIndex]) return {
4215
+ styles: n,
4216
+ changed: !1
4217
+ };
4218
+ let t = { ...n };
4219
+ return delete t[e.lineIndex], {
4220
+ styles: t,
4221
+ changed: !0
4222
+ };
4223
+ }
4206
4224
  let r = n[e.lineIndex], i = !1;
4207
4225
  for (let t = 0; t < e.lineDefaults.length; t += 1) {
4208
4226
  let n = e.lineDefaults[t];
@@ -4540,7 +4558,7 @@ function X({ value: e }) {
4540
4558
  return Number(e.toFixed(4));
4541
4559
  }
4542
4560
  function Mn({ rounding: e }) {
4543
- return U({ rounding: e }) > 0;
4561
+ return W({ rounding: e }) > 0;
4544
4562
  }
4545
4563
  function Nn({ width: e, height: t, strokeWidth: n }) {
4546
4564
  let r = Math.max(0, n ?? 0);
@@ -4556,7 +4574,7 @@ function Pn({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
4556
4574
  strokeWidth: i
4557
4575
  });
4558
4576
  if (e instanceof _) {
4559
- let t = Math.min(a.width / 2, a.height / 2) * W({ rounding: r });
4577
+ let t = Math.min(a.width / 2, a.height / 2) * G({ rounding: r });
4560
4578
  e.set({
4561
4579
  width: a.width,
4562
4580
  height: a.height,
@@ -4687,7 +4705,7 @@ function Rn({ points: e, roundingRatio: t, closed: n }) {
4687
4705
  function zn({ points: e, rounding: t, closed: n }) {
4688
4706
  return new f(Rn({
4689
4707
  points: e,
4690
- roundingRatio: W({ rounding: t }),
4708
+ roundingRatio: G({ rounding: t }),
4691
4709
  closed: n
4692
4710
  }), {
4693
4711
  originX: "center",
@@ -4712,7 +4730,7 @@ function Bn({ rounding: e }) {
4712
4730
  y: 100
4713
4731
  }
4714
4732
  ],
4715
- rounding: U({ rounding: e }),
4733
+ rounding: W({ rounding: e }),
4716
4734
  closed: !0
4717
4735
  }) : new y({
4718
4736
  width: 100,
@@ -4761,7 +4779,7 @@ function Hn({ path: e, rounding: t }) {
4761
4779
  function Un({ path: e, rounding: t }) {
4762
4780
  return Mn({ rounding: t }) && Hn({
4763
4781
  path: e,
4764
- rounding: U({ rounding: t })
4782
+ rounding: W({ rounding: t })
4765
4783
  }) || Vn({ path: e });
4766
4784
  }
4767
4785
  function Wn({ points: e, type: t, rounding: n }) {
@@ -4778,7 +4796,7 @@ function Wn({ points: e, type: t, rounding: n }) {
4778
4796
  x: 100,
4779
4797
  y: 100
4780
4798
  }
4781
- ], i = U({ rounding: n });
4799
+ ], i = W({ rounding: n });
4782
4800
  if (i > 0) {
4783
4801
  if (t === "polygon" && r.length >= 3) return zn({
4784
4802
  points: r,
@@ -5053,9 +5071,9 @@ function rr({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
5053
5071
  }
5054
5072
  //#endregion
5055
5073
  //#region src/editor/shape-manager/layout/shape-layout.ts
5056
- var Z = 1, ir = .5, ar = 8, or = 20, sr = 16;
5074
+ var Z = 1, ir = .5, ar = 24, or = 20, sr = 16;
5057
5075
  function cr({ text: e, alignV: t, width: n, height: r, appliedPadding: i, appliedUserPadding: a }) {
5058
- let { frame: o, splitByGrapheme: s, textTop: c } = hr({
5076
+ let { frame: o, splitByGrapheme: s, textTop: c } = yr({
5059
5077
  text: e,
5060
5078
  width: n,
5061
5079
  height: r,
@@ -5073,7 +5091,7 @@ function cr({ text: e, alignV: t, width: n, height: r, appliedPadding: i, applie
5073
5091
  };
5074
5092
  }
5075
5093
  var lr = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTextInset: a, resolveInternalShapeTextInset: o, preserveAspectRatio: s, shapeTextAutoExpandEnabled: c, montageAreaWidth: l, expandShapeHeightToFitText: u = !0, changedPadding: d }) => {
5076
- let { width: f, height: p, appliedPadding: m, appliedUserPadding: h } = s ? fr({
5094
+ let { width: f, height: p, appliedPadding: m, appliedUserPadding: h } = s ? gr({
5077
5095
  text: e,
5078
5096
  width: t,
5079
5097
  height: n,
@@ -5084,7 +5102,7 @@ var lr = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTe
5084
5102
  montageAreaWidth: l,
5085
5103
  expandShapeHeightToFitText: u,
5086
5104
  changedPadding: d
5087
- }) : xr({
5105
+ }) : Tr({
5088
5106
  text: e,
5089
5107
  width: t,
5090
5108
  height: n,
@@ -5102,76 +5120,78 @@ var lr = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTe
5102
5120
  appliedPadding: m,
5103
5121
  appliedUserPadding: h
5104
5122
  });
5105
- }, ur = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTextInset: a, resolveInternalShapeTextInset: o, expandShapeHeightToFitText: s = !0, changedPadding: c }) => {
5106
- let l = Oe({ padding: i }), u = De({ padding: a }), d = Math.max(Z, t), f = Math.max(Z, n), p = rr({
5123
+ }, ur = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTextInset: a, resolveInternalShapeTextInset: o, expandShapeHeightToFitText: s = !0, changedPadding: c, measurementCache: l }) => {
5124
+ let u = Oe({ padding: i }), d = De({ padding: a }), f = Math.max(Z, t), p = Math.max(Z, n), m = rr({
5107
5125
  text: e,
5108
- width: d,
5109
- height: f,
5110
- padding: l,
5111
- internalShapeTextInset: br({
5112
- width: d,
5113
- height: f,
5114
- internalShapeTextInset: u,
5126
+ width: f,
5127
+ height: p,
5128
+ padding: u,
5129
+ internalShapeTextInset: wr({
5130
+ width: f,
5131
+ height: p,
5132
+ internalShapeTextInset: d,
5115
5133
  resolveInternalShapeTextInset: o
5116
5134
  }),
5117
5135
  expandShapeHeightToFitText: s,
5118
5136
  changedPadding: c,
5119
- measureTextboxHeightForFrame: Dr,
5120
- resolveMinimumTextFrameWidth: Or
5137
+ measureTextboxHeightForFrame: ({ text: e, frameWidth: t }) => Mr({
5138
+ text: e,
5139
+ frameWidth: t,
5140
+ measurementCache: l
5141
+ }),
5142
+ resolveMinimumTextFrameWidth: ({ text: e }) => Nr({
5143
+ text: e,
5144
+ measurementCache: l
5145
+ })
5121
5146
  });
5122
5147
  for (let t = 0; t < ar; t += 1) {
5123
- let t = Math.max(f, p.requiredHeight);
5124
- if (t <= f + ir) break;
5125
- f = t, p = rr({
5148
+ let t = Math.max(p, m.requiredHeight);
5149
+ if (t <= p + ir) break;
5150
+ p = t, m = rr({
5126
5151
  text: e,
5127
- width: d,
5128
- height: f,
5129
- padding: l,
5130
- internalShapeTextInset: br({
5131
- width: d,
5132
- height: f,
5133
- internalShapeTextInset: u,
5152
+ width: f,
5153
+ height: p,
5154
+ padding: u,
5155
+ internalShapeTextInset: wr({
5156
+ width: f,
5157
+ height: p,
5158
+ internalShapeTextInset: d,
5134
5159
  resolveInternalShapeTextInset: o
5135
5160
  }),
5136
5161
  expandShapeHeightToFitText: s,
5137
5162
  changedPadding: c,
5138
- measureTextboxHeightForFrame: Dr,
5139
- resolveMinimumTextFrameWidth: Or
5163
+ measureTextboxHeightForFrame: ({ text: e, frameWidth: t }) => Mr({
5164
+ text: e,
5165
+ frameWidth: t,
5166
+ measurementCache: l
5167
+ }),
5168
+ resolveMinimumTextFrameWidth: ({ text: e }) => Nr({
5169
+ text: e,
5170
+ measurementCache: l
5171
+ })
5140
5172
  });
5141
5173
  }
5142
5174
  return cr({
5143
5175
  text: e,
5144
5176
  alignV: r,
5145
- width: d,
5146
- height: f,
5147
- appliedPadding: p.appliedPadding,
5148
- appliedUserPadding: p.appliedUserPadding
5149
- });
5150
- }, dr = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s, internalShapeTextInset: c, resolveInternalShapeTextInset: l, preserveAspectRatio: u, shapeTextAutoExpandEnabled: d, montageAreaWidth: f, expandShapeHeightToFitText: p = !0, changedPadding: m }) => {
5151
- let h = Math.max(Z, e.shapeManualBaseWidth ?? r), g = Math.max(Z, e.shapeManualBaseHeight ?? i), { width: _, height: v, appliedUserPadding: y, frame: b, splitByGrapheme: x, textTop: S } = lr({
5152
- text: n,
5153
- width: r,
5154
- height: i,
5155
- alignV: o,
5156
- padding: s,
5157
- internalShapeTextInset: c,
5158
- resolveInternalShapeTextInset: l,
5159
- preserveAspectRatio: u,
5160
- shapeTextAutoExpandEnabled: d ?? e.shapeTextAutoExpand !== !1,
5161
- montageAreaWidth: f,
5162
- expandShapeHeightToFitText: p,
5163
- changedPadding: m
5177
+ width: f,
5178
+ height: p,
5179
+ appliedPadding: m.appliedPadding,
5180
+ appliedUserPadding: m.appliedUserPadding
5164
5181
  });
5182
+ };
5183
+ function dr({ group: e, shape: t, text: n, alignH: r, alignV: i, resolvedLayout: a }) {
5184
+ let o = Math.max(Z, e.shapeManualBaseWidth ?? a.width), s = Math.max(Z, e.shapeManualBaseHeight ?? a.height), { width: c, height: l, appliedUserPadding: u, frame: d, splitByGrapheme: f, textTop: p } = a;
5165
5185
  Pn({
5166
5186
  shape: t,
5167
- width: _,
5168
- height: v,
5187
+ width: c,
5188
+ height: l,
5169
5189
  rounding: e.shapeRounding,
5170
5190
  strokeWidth: e.shapeStrokeWidth
5171
5191
  }), n.set({
5172
5192
  autoExpand: !1,
5173
- width: b.width,
5174
- textAlign: a,
5193
+ width: d.width,
5194
+ textAlign: r,
5175
5195
  scaleX: 1,
5176
5196
  scaleY: 1,
5177
5197
  angle: 0,
@@ -5179,21 +5199,69 @@ var lr = ({ text: e, width: t, height: n, alignV: r, padding: i, internalShapeTe
5179
5199
  skewY: 0,
5180
5200
  flipX: !1,
5181
5201
  flipY: !1,
5182
- left: b.left,
5183
- top: S,
5202
+ left: d.left,
5203
+ top: p,
5184
5204
  originX: "left",
5185
5205
  originY: "top",
5186
- splitByGrapheme: x
5187
- }), n.initDimensions(), n.setCoords(), t.setCoords(), e.shapeBaseWidth = _, e.shapeBaseHeight = v, e.shapeManualBaseWidth = h, e.shapeManualBaseHeight = g, e.shapePaddingTop = y.top, e.shapePaddingRight = y.right, e.shapePaddingBottom = y.bottom, e.shapePaddingLeft = y.left, e.shapeAlignHorizontal = a, e.shapeAlignVertical = o, e.set({
5188
- width: _,
5189
- height: v,
5206
+ splitByGrapheme: f
5207
+ }), n.initDimensions(), n.setCoords(), t.setCoords(), e.shapeBaseWidth = c, e.shapeBaseHeight = l, e.shapeManualBaseWidth = o, e.shapeManualBaseHeight = s, e.shapePaddingTop = u.top, e.shapePaddingRight = u.right, e.shapePaddingBottom = u.bottom, e.shapePaddingLeft = u.left, e.shapeAlignHorizontal = r, e.shapeAlignVertical = i, e.set({
5208
+ width: c,
5209
+ height: l,
5190
5210
  scaleX: 1,
5191
5211
  scaleY: 1
5192
5212
  }), e.set("dirty", !0), e.setCoords();
5213
+ }
5214
+ function fr({ frameWidth: e }) {
5215
+ return String(Math.round(Math.max(Z, e) * 1e3) / 1e3);
5216
+ }
5217
+ function pr({ frameWidth: e, splitByGrapheme: t }) {
5218
+ return `${fr({ frameWidth: e })}:${t ? 1 : 0}`;
5219
+ }
5220
+ var mr = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s, internalShapeTextInset: c, resolveInternalShapeTextInset: l, preserveAspectRatio: u, shapeTextAutoExpandEnabled: d, montageAreaWidth: f, expandShapeHeightToFitText: p = !0, changedPadding: m }) => {
5221
+ dr({
5222
+ group: e,
5223
+ shape: t,
5224
+ text: n,
5225
+ alignH: a,
5226
+ alignV: o,
5227
+ resolvedLayout: lr({
5228
+ text: n,
5229
+ width: r,
5230
+ height: i,
5231
+ alignV: o,
5232
+ padding: s,
5233
+ internalShapeTextInset: c,
5234
+ resolveInternalShapeTextInset: l,
5235
+ preserveAspectRatio: u,
5236
+ shapeTextAutoExpandEnabled: d ?? e.shapeTextAutoExpand !== !1,
5237
+ montageAreaWidth: f,
5238
+ expandShapeHeightToFitText: p,
5239
+ changedPadding: m
5240
+ })
5241
+ });
5242
+ }, hr = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s, internalShapeTextInset: c, resolveInternalShapeTextInset: l, expandShapeHeightToFitText: u = !0, changedPadding: d }) => {
5243
+ dr({
5244
+ group: e,
5245
+ shape: t,
5246
+ text: n,
5247
+ alignH: a,
5248
+ alignV: o,
5249
+ resolvedLayout: ur({
5250
+ text: n,
5251
+ width: r,
5252
+ height: i,
5253
+ alignV: o,
5254
+ padding: s,
5255
+ internalShapeTextInset: c,
5256
+ resolveInternalShapeTextInset: l,
5257
+ expandShapeHeightToFitText: u,
5258
+ changedPadding: d
5259
+ })
5260
+ });
5193
5261
  };
5194
- function fr({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, resolveInternalShapeTextInset: a, shapeTextAutoExpandEnabled: o = !0, montageAreaWidth: s, expandShapeHeightToFitText: c = !0, changedPadding: l }) {
5262
+ function gr({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, resolveInternalShapeTextInset: a, shapeTextAutoExpandEnabled: o = !0, montageAreaWidth: s, expandShapeHeightToFitText: c = !0, changedPadding: l }) {
5195
5263
  let u = Math.max(Z, t), d = Math.max(Z, n), f = Number.isFinite(s) && (s ?? 0) > 0 ? Math.max(Z, s ?? Z) : null;
5196
- if (!_r({ text: e })) return xr({
5264
+ if (!xr({ text: e })) return Tr({
5197
5265
  text: e,
5198
5266
  width: u,
5199
5267
  height: d,
@@ -5204,7 +5272,7 @@ function fr({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
5204
5272
  changedPadding: l
5205
5273
  });
5206
5274
  let p = d / u, m = ({ width: t }) => {
5207
- let n = Math.max(Z, t * p), o = xr({
5275
+ let n = Math.max(Z, t * p), o = Tr({
5208
5276
  text: e,
5209
5277
  width: t,
5210
5278
  height: n,
@@ -5232,11 +5300,11 @@ function fr({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
5232
5300
  layoutResolution: n
5233
5301
  });
5234
5302
  }, t = f ? Math.max(u, f) : u;
5235
- e({ width: t }) || (t = Sr({
5303
+ e({ width: t }) || (t = Er({
5236
5304
  minimumWidth: t,
5237
5305
  isWidthValid: e
5238
5306
  }));
5239
- let { layoutResolution: n } = m({ width: Cr({
5307
+ let { layoutResolution: n } = m({ width: Dr({
5240
5308
  minimumWidth: u,
5241
5309
  maximumWidth: t,
5242
5310
  isWidthValid: e
@@ -5249,19 +5317,19 @@ function fr({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
5249
5317
  candidateWidth: t,
5250
5318
  candidateHeight: r,
5251
5319
  layoutResolution: a
5252
- }) || n !== void 0 && i < n - ir ? !1 : !Er({
5320
+ }) || n !== void 0 && i < n - ir ? !1 : !jr({
5253
5321
  text: e,
5254
5322
  frameWidth: i
5255
5323
  }).hasWrappedLines;
5256
- }, _ = f ? Math.max(u, f) : Sr({
5324
+ }, _ = f ? Math.max(u, f) : Er({
5257
5325
  minimumWidth: u,
5258
5326
  isWidthValid: ({ width: e }) => g({ width: e })
5259
- }), v = m({ width: _ }), y = Er({
5327
+ }), v = m({ width: _ }), y = jr({
5260
5328
  text: e,
5261
5329
  frameWidth: v.frameWidth
5262
5330
  });
5263
5331
  if (y.hasWrappedLines) return v.layoutResolution;
5264
- let b = Math.max(Z, y.longestLineWidth), { layoutResolution: x } = m({ width: Cr({
5332
+ let b = Math.max(Z, y.longestLineWidth), { layoutResolution: x } = m({ width: Dr({
5265
5333
  minimumWidth: u,
5266
5334
  maximumWidth: _,
5267
5335
  isWidthValid: ({ width: e }) => g({
@@ -5271,67 +5339,70 @@ function fr({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
5271
5339
  }) });
5272
5340
  return x;
5273
5341
  }
5274
- var pr = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWidth: i, resolvePaddingForWidth: a }) => {
5342
+ var _r = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWidth: i, resolvePaddingForWidth: a }) => {
5275
5343
  let o = Math.max(Z, t), s = Math.max(Z, n);
5276
- if (!_r({ text: e })) return s;
5344
+ if (!xr({ text: e })) return s;
5277
5345
  let c = Math.max(s, Number.isFinite(i) && i > 0 ? Math.max(Z, i) : Math.max(o, s)), l = Xn({
5278
5346
  width: c,
5279
- padding: vr({
5347
+ padding: Sr({
5280
5348
  width: c,
5281
5349
  padding: r,
5282
5350
  resolvePaddingForWidth: a
5283
5351
  })
5284
- }), u = c, d = Er({
5352
+ }), u = c, d = jr({
5285
5353
  text: e,
5286
5354
  frameWidth: l
5287
5355
  });
5288
5356
  if (d.hasWrappedLines) return u;
5289
5357
  let f = Math.max(Z, d.longestLineWidth);
5290
- return Cr({
5358
+ return Dr({
5291
5359
  minimumWidth: s,
5292
5360
  maximumWidth: u,
5293
5361
  isWidthValid: ({ width: t }) => {
5294
5362
  let n = Xn({
5295
5363
  width: t,
5296
- padding: vr({
5364
+ padding: Sr({
5297
5365
  width: t,
5298
5366
  padding: r,
5299
5367
  resolvePaddingForWidth: a
5300
5368
  })
5301
5369
  });
5302
- return n < f - ir ? !1 : !Er({
5370
+ return n < f - ir ? !1 : !jr({
5303
5371
  text: e,
5304
5372
  frameWidth: n
5305
5373
  }).hasWrappedLines;
5306
5374
  }
5307
5375
  });
5308
- }, mr = ({ text: e, padding: t, resolvePaddingForWidth: n }) => {
5309
- if (!_r({ text: e })) return Z;
5310
- let r = Or({ text: e }), i = Math.max(Z, r), a = ({ width: e }) => Xn({
5376
+ }, vr = ({ text: e, padding: t, resolvePaddingForWidth: n, measurementCache: r }) => {
5377
+ if (!xr({ text: e })) return Z;
5378
+ let i = Nr({
5379
+ text: e,
5380
+ measurementCache: r
5381
+ }), a = Math.max(Z, i), o = ({ width: e }) => Xn({
5311
5382
  width: e,
5312
- padding: vr({
5383
+ padding: Sr({
5313
5384
  width: e,
5314
5385
  padding: t,
5315
5386
  resolvePaddingForWidth: n
5316
5387
  })
5317
- }) >= r - ir;
5318
- return Cr({
5319
- minimumWidth: i,
5320
- maximumWidth: Sr({
5321
- minimumWidth: i,
5322
- isWidthValid: a
5388
+ }) >= i - ir;
5389
+ return Dr({
5390
+ minimumWidth: a,
5391
+ maximumWidth: Er({
5392
+ minimumWidth: a,
5393
+ isWidthValid: o
5323
5394
  }),
5324
- isWidthValid: a
5395
+ isWidthValid: o
5325
5396
  });
5326
- }, hr = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
5327
- let a = wr({
5397
+ }, yr = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
5398
+ let a = Or({
5328
5399
  width: Math.max(Z, t),
5329
5400
  height: Math.max(Z, n),
5330
5401
  padding: De({ padding: i })
5331
- }), o = jr({
5402
+ }), o = Ir({
5332
5403
  text: e,
5333
5404
  frameWidth: a.width
5334
- }), s = Dr({
5405
+ }), s = Mr({
5335
5406
  text: e,
5336
5407
  frameWidth: a.width,
5337
5408
  splitByGrapheme: o
@@ -5339,60 +5410,61 @@ var pr = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, montageAreaWi
5339
5410
  return {
5340
5411
  frame: a,
5341
5412
  splitByGrapheme: o,
5342
- textTop: Ar({
5413
+ textTop: Fr({
5343
5414
  alignV: r,
5344
5415
  frameHeight: a.height,
5345
5416
  frameTop: a.top,
5346
5417
  textHeight: s
5347
5418
  })
5348
5419
  };
5349
- }, gr = ({ text: e, width: t, height: n, padding: r, resolvePaddingForSize: i }) => {
5350
- let a = Math.max(Z, n);
5351
- if (!_r({ text: e })) return a;
5352
- let o = Math.max(Z, t), s = a;
5420
+ }, br = ({ text: e, width: t, height: n, padding: r, resolvePaddingForSize: i, measurementCache: a }) => {
5421
+ let o = Math.max(Z, n);
5422
+ if (!xr({ text: e })) return o;
5423
+ let s = Math.max(Z, t), c = o;
5353
5424
  for (let t = 0; t < ar; t += 1) {
5354
- let t = yr({
5355
- width: o,
5356
- height: s,
5425
+ let t = Cr({
5426
+ width: s,
5427
+ height: c,
5357
5428
  padding: r,
5358
5429
  resolvePaddingForSize: i
5359
- }), n = Dr({
5430
+ }), n = Mr({
5360
5431
  text: e,
5361
5432
  frameWidth: Xn({
5362
- width: o,
5433
+ width: s,
5363
5434
  padding: t
5364
- })
5365
- }), c = Math.max(a, n + t.top + t.bottom);
5366
- if (c <= s + ir) return c;
5367
- s = c;
5435
+ }),
5436
+ measurementCache: a
5437
+ }), l = Math.max(o, n + t.top + t.bottom);
5438
+ if (l <= c + ir) return l;
5439
+ c = l;
5368
5440
  }
5369
- return s;
5441
+ return c;
5370
5442
  };
5371
- function _r({ text: e }) {
5443
+ function xr({ text: e }) {
5372
5444
  return (e.text ?? "").trim().length > 0;
5373
5445
  }
5374
- function vr({ width: e, padding: t, resolvePaddingForWidth: n }) {
5446
+ function Sr({ width: e, padding: t, resolvePaddingForWidth: n }) {
5375
5447
  return De(n ? { padding: n({ width: Math.max(Z, e) }) } : { padding: t });
5376
5448
  }
5377
- function yr({ width: e, height: t, padding: n, resolvePaddingForSize: r }) {
5449
+ function Cr({ width: e, height: t, padding: n, resolvePaddingForSize: r }) {
5378
5450
  return De(r ? { padding: r({
5379
5451
  width: Math.max(Z, e),
5380
5452
  height: Math.max(Z, t)
5381
5453
  }) } : { padding: n });
5382
5454
  }
5383
- function br({ width: e, height: t, internalShapeTextInset: n, resolveInternalShapeTextInset: r }) {
5455
+ function wr({ width: e, height: t, internalShapeTextInset: n, resolveInternalShapeTextInset: r }) {
5384
5456
  return De(r ? { padding: r({
5385
5457
  width: Math.max(Z, e),
5386
5458
  height: Math.max(Z, t)
5387
5459
  }) } : { padding: n });
5388
5460
  }
5389
- function xr({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, resolveInternalShapeTextInset: a, expandShapeHeightToFitText: o = !0, changedPadding: s }) {
5461
+ function Tr({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, resolveInternalShapeTextInset: a, expandShapeHeightToFitText: o = !0, changedPadding: s }) {
5390
5462
  let c = Oe({ padding: r }), l = De({ padding: i }), u = Math.max(Z, t), d = Math.max(Z, n), f = rr({
5391
5463
  text: e,
5392
5464
  width: u,
5393
5465
  height: d,
5394
5466
  padding: c,
5395
- internalShapeTextInset: br({
5467
+ internalShapeTextInset: wr({
5396
5468
  width: u,
5397
5469
  height: d,
5398
5470
  internalShapeTextInset: l,
@@ -5400,8 +5472,8 @@ function xr({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
5400
5472
  }),
5401
5473
  expandShapeHeightToFitText: o,
5402
5474
  changedPadding: s,
5403
- measureTextboxHeightForFrame: Dr,
5404
- resolveMinimumTextFrameWidth: Or
5475
+ measureTextboxHeightForFrame: Mr,
5476
+ resolveMinimumTextFrameWidth: Nr
5405
5477
  });
5406
5478
  for (let t = 0; t < ar; t += 1) {
5407
5479
  let t = Math.max(u, f.requiredWidth), n = Math.max(d, f.requiredHeight);
@@ -5411,7 +5483,7 @@ function xr({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
5411
5483
  width: u,
5412
5484
  height: d,
5413
5485
  padding: c,
5414
- internalShapeTextInset: br({
5486
+ internalShapeTextInset: wr({
5415
5487
  width: u,
5416
5488
  height: d,
5417
5489
  internalShapeTextInset: l,
@@ -5419,8 +5491,8 @@ function xr({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
5419
5491
  }),
5420
5492
  expandShapeHeightToFitText: o,
5421
5493
  changedPadding: s,
5422
- measureTextboxHeightForFrame: Dr,
5423
- resolveMinimumTextFrameWidth: Or
5494
+ measureTextboxHeightForFrame: Mr,
5495
+ resolveMinimumTextFrameWidth: Nr
5424
5496
  });
5425
5497
  }
5426
5498
  return {
@@ -5430,13 +5502,13 @@ function xr({ text: e, width: t, height: n, padding: r, internalShapeTextInset:
5430
5502
  appliedUserPadding: f.appliedUserPadding
5431
5503
  };
5432
5504
  }
5433
- function Sr({ minimumWidth: e, isWidthValid: t }) {
5505
+ function Er({ minimumWidth: e, isWidthValid: t }) {
5434
5506
  let n = Math.max(Z, e);
5435
5507
  if (t({ width: n })) return n;
5436
5508
  for (let e = 0; e < sr; e += 1) if (n = Math.max(n + 1, n * 2), t({ width: n })) return n;
5437
5509
  return n;
5438
5510
  }
5439
- function Cr({ minimumWidth: e, maximumWidth: t, isWidthValid: n }) {
5511
+ function Dr({ minimumWidth: e, maximumWidth: t, isWidthValid: n }) {
5440
5512
  let r = Math.max(Z, e), i = Math.max(r, t);
5441
5513
  if (n({ width: r })) return r;
5442
5514
  if (!n({ width: i })) return i;
@@ -5450,7 +5522,7 @@ function Cr({ minimumWidth: e, maximumWidth: t, isWidthValid: n }) {
5450
5522
  }
5451
5523
  return i;
5452
5524
  }
5453
- function wr({ width: e, height: t, padding: n }) {
5525
+ function Or({ width: e, height: t, padding: n }) {
5454
5526
  let r = Math.max(0, n.left), i = Math.max(0, n.right), a = Math.max(0, n.top), o = Math.max(0, n.bottom);
5455
5527
  return {
5456
5528
  left: -e / 2 + r,
@@ -5459,7 +5531,7 @@ function wr({ width: e, height: t, padding: n }) {
5459
5531
  height: Math.max(Z, t - a - o)
5460
5532
  };
5461
5533
  }
5462
- function Tr({ text: e }) {
5534
+ function kr({ text: e }) {
5463
5535
  let { height: t } = e;
5464
5536
  if (typeof t == "number" && Number.isFinite(t)) return t;
5465
5537
  if (typeof e.calcTextHeight == "function") {
@@ -5468,100 +5540,138 @@ function Tr({ text: e }) {
5468
5540
  }
5469
5541
  return Z;
5470
5542
  }
5471
- function Er({ text: e, frameWidth: t }) {
5472
- let n = Nr({ text: e }), r = jr({
5543
+ function Ar({ text: e, frameWidth: t, splitByGrapheme: n, requiresGraphemeSplit: r, measurementCache: i }) {
5544
+ let a = Math.max(Z, t), o = pr({
5545
+ frameWidth: a,
5546
+ splitByGrapheme: n
5547
+ }), s = i?.measurementsByKey.get(o);
5548
+ if (s) return s;
5549
+ let c = Vr({ text: e }), l = r ?? Ir({
5473
5550
  text: e,
5474
- frameWidth: t
5475
- }), i = Ir({ text: e });
5551
+ frameWidth: a,
5552
+ measurementCache: i
5553
+ });
5476
5554
  e.set({
5477
5555
  autoExpand: !1,
5478
- width: Math.max(Z, t),
5479
- splitByGrapheme: r
5556
+ width: a,
5557
+ splitByGrapheme: n,
5558
+ scaleX: 1,
5559
+ scaleY: 1
5480
5560
  }), e.initDimensions();
5481
- let a = Pr({ text: e }) > n, o = Math.ceil(Mr({ text: e }));
5482
- return Lr({
5561
+ let u = zr({ text: e }), d = Rr({ text: e }), f = {
5562
+ measuredHeight: kr({ text: e }),
5563
+ renderedLineCount: u > 0 ? u : d,
5564
+ longestLineWidth: Math.ceil(Lr({ text: e })),
5565
+ requiresGraphemeSplit: l
5566
+ };
5567
+ return Hr({
5483
5568
  text: e,
5484
- state: i
5485
- }), {
5486
- hasWrappedLines: a,
5487
- longestLineWidth: o
5569
+ state: c
5570
+ }), i?.measurementsByKey.set(o, f), f;
5571
+ }
5572
+ function jr({ text: e, frameWidth: t, measurementCache: n }) {
5573
+ let r = Rr({ text: e }), i = Ir({
5574
+ text: e,
5575
+ frameWidth: t,
5576
+ measurementCache: n
5577
+ }), a = Ar({
5578
+ text: e,
5579
+ frameWidth: t,
5580
+ splitByGrapheme: i,
5581
+ requiresGraphemeSplit: i,
5582
+ measurementCache: n
5583
+ });
5584
+ return {
5585
+ hasWrappedLines: a.renderedLineCount > r,
5586
+ longestLineWidth: a.longestLineWidth
5488
5587
  };
5489
5588
  }
5490
- function Dr({ text: e, frameWidth: t, splitByGrapheme: n }) {
5491
- let r = Ir({ text: e }), i = n ?? jr({
5589
+ function Mr({ text: e, frameWidth: t, splitByGrapheme: n, measurementCache: r }) {
5590
+ let i = n ?? Ir({
5492
5591
  text: e,
5493
- frameWidth: t
5592
+ frameWidth: t,
5593
+ measurementCache: r
5494
5594
  });
5495
- e.set({
5496
- autoExpand: !1,
5497
- width: Math.max(Z, t),
5498
- splitByGrapheme: i
5499
- }), e.initDimensions();
5500
- let a = Tr({ text: e });
5501
- return Lr({
5595
+ return Ar({
5502
5596
  text: e,
5503
- state: r
5504
- }), a;
5597
+ frameWidth: t,
5598
+ splitByGrapheme: i,
5599
+ requiresGraphemeSplit: i,
5600
+ measurementCache: r
5601
+ }).measuredHeight;
5505
5602
  }
5506
- function Or({ text: e }) {
5507
- let t = kr({
5603
+ function Nr({ text: e, measurementCache: t }) {
5604
+ if (t?.minimumTextFrameWidth !== null && t?.minimumTextFrameWidth !== void 0) return t.minimumTextFrameWidth;
5605
+ let n = Pr({
5508
5606
  text: e,
5509
5607
  frameWidth: Z,
5510
- splitByGrapheme: !0
5511
- });
5512
- return Math.max(Z, t);
5608
+ splitByGrapheme: !0,
5609
+ measurementCache: t
5610
+ }), r = Math.max(Z, n);
5611
+ return t && (t.minimumTextFrameWidth = r), r;
5513
5612
  }
5514
- function kr({ text: e, frameWidth: t, splitByGrapheme: n }) {
5515
- let r = Ir({ text: e });
5613
+ function Pr({ text: e, frameWidth: t, splitByGrapheme: n, measurementCache: r }) {
5614
+ let i = r?.measurementsByKey.get(pr({
5615
+ frameWidth: t,
5616
+ splitByGrapheme: n
5617
+ }));
5618
+ if (i) return i.longestLineWidth;
5619
+ let a = Vr({ text: e });
5516
5620
  e.set({
5517
5621
  autoExpand: !1,
5518
5622
  width: Math.max(Z, t),
5519
- splitByGrapheme: n
5623
+ splitByGrapheme: n,
5624
+ scaleX: 1,
5625
+ scaleY: 1
5520
5626
  }), e.initDimensions();
5521
- let i = Mr({ text: e });
5522
- return Lr({
5627
+ let o = Lr({ text: e });
5628
+ return Hr({
5523
5629
  text: e,
5524
- state: r
5525
- }), i;
5630
+ state: a
5631
+ }), o;
5526
5632
  }
5527
- function Ar({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
5633
+ function Fr({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
5528
5634
  let i = Math.max(0, t - r);
5529
5635
  return e === "top" ? n : e === "bottom" ? n + i : n + i / 2;
5530
5636
  }
5531
- function jr({ text: e, frameWidth: t }) {
5532
- let n = Math.max(Z, t), r = Ir({ text: e });
5637
+ function Ir({ text: e, frameWidth: t, measurementCache: n }) {
5638
+ let r = Math.max(Z, t), i = fr({ frameWidth: r }), a = n?.splitByGraphemeByFrameWidth.get(i);
5639
+ if (typeof a == "boolean") return a;
5640
+ let o = Vr({ text: e });
5533
5641
  e.set({
5534
5642
  autoExpand: !1,
5535
- width: n,
5536
- splitByGrapheme: !1
5643
+ width: r,
5644
+ splitByGrapheme: !1,
5645
+ scaleX: 1,
5646
+ scaleY: 1
5537
5647
  }), e.initDimensions();
5538
- let i = Rr({ text: e }) > n + ir;
5539
- return Lr({
5648
+ let s = Ur({ text: e }) > r + ir;
5649
+ return Hr({
5540
5650
  text: e,
5541
- state: r
5542
- }), i;
5651
+ state: o
5652
+ }), n?.splitByGraphemeByFrameWidth.set(i, s), s;
5543
5653
  }
5544
- function Mr({ text: e }) {
5545
- let t = Pr({ text: e });
5546
- if (t > 0) return Fr({
5654
+ function Lr({ text: e }) {
5655
+ let t = zr({ text: e });
5656
+ if (t > 0) return Br({
5547
5657
  text: e,
5548
5658
  lineCount: t
5549
5659
  });
5550
5660
  let n = e.text ?? "";
5551
- return Fr({
5661
+ return Br({
5552
5662
  text: e,
5553
5663
  lineCount: Math.max(n.split("\n").length, 1)
5554
5664
  });
5555
5665
  }
5556
- function Nr({ text: e }) {
5666
+ function Rr({ text: e }) {
5557
5667
  let t = e.text ?? "";
5558
5668
  return Math.max(t.split("\n").length, 1);
5559
5669
  }
5560
- function Pr({ text: e }) {
5670
+ function zr({ text: e }) {
5561
5671
  let t = e;
5562
5672
  return Array.isArray(t.textLines) ? t.textLines.length : 0;
5563
5673
  }
5564
- function Fr({ text: e, lineCount: t }) {
5674
+ function Br({ text: e, lineCount: t }) {
5565
5675
  let n = Z;
5566
5676
  for (let r = 0; r < t; r += 1) {
5567
5677
  let t = e.getLineWidth(r);
@@ -5569,30 +5679,32 @@ function Fr({ text: e, lineCount: t }) {
5569
5679
  }
5570
5680
  return n;
5571
5681
  }
5572
- function Ir({ text: e }) {
5573
- let { autoExpand: t, splitByGrapheme: n, width: r } = e;
5682
+ function Vr({ text: e }) {
5683
+ let { autoExpand: t, splitByGrapheme: n, width: r, scaleX: i, scaleY: a } = e;
5574
5684
  return {
5575
5685
  autoExpand: t,
5576
5686
  splitByGrapheme: n,
5577
- width: typeof r == "number" ? r : void 0
5687
+ width: typeof r == "number" ? r : void 0,
5688
+ scaleX: typeof i == "number" ? i : void 0,
5689
+ scaleY: typeof a == "number" ? a : void 0
5578
5690
  };
5579
5691
  }
5580
- function Lr({ text: e, state: t }) {
5581
- let { autoExpand: n, splitByGrapheme: r, width: i } = t, a = {};
5582
- n !== void 0 && (a.autoExpand = n), r !== void 0 && (a.splitByGrapheme = r), typeof i == "number" && (a.width = i), Object.keys(a).length > 0 && (e.set(a), e.initDimensions());
5692
+ function Hr({ text: e, state: t }) {
5693
+ let { autoExpand: n, splitByGrapheme: r, width: i, scaleX: a, scaleY: o } = t, s = {};
5694
+ n !== void 0 && (s.autoExpand = n), r !== void 0 && (s.splitByGrapheme = r), typeof i == "number" && (s.width = i), typeof a == "number" && (s.scaleX = a), typeof o == "number" && (s.scaleY = o), Object.keys(s).length > 0 && (e.set(s), e.initDimensions());
5583
5695
  }
5584
- function Rr({ text: e }) {
5696
+ function Ur({ text: e }) {
5585
5697
  let { dynamicMinWidth: t } = e;
5586
5698
  return typeof t == "number" && Number.isFinite(t) ? t : 0;
5587
5699
  }
5588
5700
  //#endregion
5589
5701
  //#region src/editor/shape-manager/scaling/shape-scaling-transform.ts
5590
- var zr = ({ transform: e, key: t }) => {
5702
+ var Wr = ({ transform: e, key: t }) => {
5591
5703
  let n = e?.original;
5592
5704
  if (!n || typeof n != "object") return null;
5593
5705
  let r = n[t];
5594
5706
  return typeof r != "number" || !Number.isFinite(r) ? null : r;
5595
- }, Br = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, Vr = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, Hr = ({ transform: e }) => {
5707
+ }, Gr = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, Kr = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, qr = ({ transform: e }) => {
5596
5708
  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;
5597
5709
  return {
5598
5710
  canScaleWidth: o,
@@ -5600,37 +5712,37 @@ var zr = ({ transform: e, key: t }) => {
5600
5712
  isCornerScaleAction: r,
5601
5713
  isVerticalOnlyScale: s && !o
5602
5714
  };
5603
- }, Ur = ({ event: e, target: t, transform: n, canvas: r }) => {
5715
+ }, Jr = ({ event: e, target: t, transform: n, canvas: r }) => {
5604
5716
  if (!e) return null;
5605
5717
  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;
5606
5718
  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;
5607
- }, Wr = ({ group: e, originX: t, originY: n }) => {
5719
+ }, Yr = ({ group: e, originX: t, originY: n }) => {
5608
5720
  if (t === null || n === null) return null;
5609
5721
  let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
5610
5722
  return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
5611
- }, Gr = ({ state: e, transform: t }) => {
5723
+ }, Xr = ({ state: e, transform: t }) => {
5612
5724
  if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
5613
- let n = Br({ value: t.originX }), r = Vr({ value: t.originY });
5725
+ let n = Gr({ value: t.originX }), r = Kr({ value: t.originY });
5614
5726
  return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
5615
- }, Kr = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
5727
+ }, Zr = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
5616
5728
  //#endregion
5617
5729
  //#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
5618
- function qr({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
5730
+ function Qr({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
5619
5731
  let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
5620
5732
  return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
5621
5733
  }
5622
- function Jr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
5734
+ function $r({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
5623
5735
  let c = Math.max(0, e.shapeStrokeWidth ?? 0);
5624
5736
  Pn({
5625
5737
  shape: t,
5626
- width: qr({
5738
+ width: Qr({
5627
5739
  size: n,
5628
5740
  scale: i,
5629
5741
  strokeWidth: c,
5630
5742
  minSize: o,
5631
5743
  scaleEpsilon: s
5632
5744
  }),
5633
- height: qr({
5745
+ height: Qr({
5634
5746
  size: r,
5635
5747
  scale: a,
5636
5748
  strokeWidth: c,
@@ -5641,7 +5753,7 @@ function Jr({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
5641
5753
  strokeWidth: c
5642
5754
  });
5643
5755
  }
5644
- function Yr({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon: a }) {
5756
+ function ei({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon: a }) {
5645
5757
  let o = Math.max(a, Math.abs(r) || 1), s = Math.max(a, Math.abs(i) || 1), c = n ?? "center";
5646
5758
  e.set({
5647
5759
  autoExpand: !1,
@@ -5656,13 +5768,13 @@ function Yr({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon:
5656
5768
  scaleY: 1 / s
5657
5769
  }), e.initDimensions(), e.setCoords();
5658
5770
  }
5659
- var Xr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY: o, minSize: s, scaleEpsilon: c }) => {
5771
+ var ti = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY: o, minSize: s, scaleEpsilon: c }) => {
5660
5772
  let l = Math.max(c, Math.abs(a) || 1), u = Math.max(c, Math.abs(o) || 1);
5661
5773
  e.set({
5662
5774
  width: r.width / l,
5663
5775
  height: r.height / u,
5664
5776
  dirty: !0
5665
- }), Jr({
5777
+ }), $r({
5666
5778
  group: e,
5667
5779
  shape: t,
5668
5780
  width: r.width,
@@ -5671,7 +5783,7 @@ var Xr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
5671
5783
  scaleY: o,
5672
5784
  minSize: s,
5673
5785
  scaleEpsilon: c
5674
- }), Yr({
5786
+ }), ei({
5675
5787
  text: n,
5676
5788
  layout: r,
5677
5789
  alignH: i,
@@ -5679,8 +5791,17 @@ var Xr = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
5679
5791
  scaleY: o,
5680
5792
  scaleEpsilon: c
5681
5793
  });
5682
- }, Zr = 1e-4, Qr = .5;
5683
- function $r({ group: e }) {
5794
+ }, ni = 1e-4, ri = .5;
5795
+ function ii({ width: e, height: t }) {
5796
+ return `${Math.round(Math.max(1, e) * 1e6) / 1e6}:${Math.round(Math.max(1, t) * 1e6) / 1e6}`;
5797
+ }
5798
+ function ai({ width: e, padding: t }) {
5799
+ return Math.max(1, e - Math.max(0, t.left) - Math.max(0, t.right));
5800
+ }
5801
+ function oi({ height: e, padding: t }) {
5802
+ return Math.max(1, e - Math.max(0, t.top) - Math.max(0, t.bottom));
5803
+ }
5804
+ function si({ group: e }) {
5684
5805
  return Oe({ padding: {
5685
5806
  top: e.shapePaddingTop,
5686
5807
  right: e.shapePaddingRight,
@@ -5688,7 +5809,7 @@ function $r({ group: e }) {
5688
5809
  left: e.shapePaddingLeft
5689
5810
  } });
5690
5811
  }
5691
- function ei({ group: e, width: t, height: n }) {
5812
+ function ci({ group: e, width: t, height: n }) {
5692
5813
  let r = e.shapePresetKey ?? "", i = r ? ve({ presetKey: r }) : null;
5693
5814
  return Me({
5694
5815
  baseInset: i ? xe({
@@ -5700,61 +5821,124 @@ function ei({ group: e, width: t, height: n }) {
5700
5821
  strokeWidth: e.shapeStrokeWidth
5701
5822
  });
5702
5823
  }
5703
- function ti({ group: e, width: t, height: n }) {
5704
- return ei({
5824
+ function li({ group: e, width: t, height: n }) {
5825
+ return ci({
5705
5826
  group: e,
5706
5827
  width: Math.max(1, t ?? e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1),
5707
5828
  height: Math.max(1, n ?? e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1)
5708
5829
  });
5709
5830
  }
5710
- function ni({ group: e, text: t, width: n, padding: r }) {
5711
- return gr({
5831
+ function ui({ group: e, text: t, width: n, height: r, measurementCache: i, constraintCache: a }) {
5832
+ let o = Math.max(1, n), s = Math.max(1, r), c = ii({
5833
+ width: o,
5834
+ height: s
5835
+ }), l = a?.get(c);
5836
+ if (l) return l;
5837
+ let u = li({
5838
+ group: e,
5839
+ width: o,
5840
+ height: s
5841
+ }), d = ai({
5842
+ width: o,
5843
+ padding: u
5844
+ }), f = oi({
5845
+ height: s,
5846
+ padding: u
5847
+ }), p = Ar({
5848
+ text: t,
5849
+ frameWidth: d,
5850
+ splitByGrapheme: !1,
5851
+ measurementCache: i ?? void 0
5852
+ }), m = {
5853
+ ...p,
5854
+ isValid: !p.requiresGraphemeSplit && p.measuredHeight <= f + .5
5855
+ };
5856
+ return a?.set(c, m), m;
5857
+ }
5858
+ function di({ group: e, text: t, state: n }) {
5859
+ 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 }) => {
5860
+ let o = ui({
5861
+ group: e,
5862
+ text: t,
5863
+ width: Math.max(1, i * a),
5864
+ height: Math.max(1, r * a),
5865
+ measurementCache: n.previewTextMeasurementCache,
5866
+ constraintCache: n.proportionalTextConstraintCache
5867
+ });
5868
+ return {
5869
+ minimumHeight: o.measuredHeight,
5870
+ isValid: o.isValid
5871
+ };
5872
+ }, f = d({ scale: u });
5873
+ if (!f.isValid) return {
5874
+ scale: u,
5875
+ minimumHeight: f.minimumHeight
5876
+ };
5877
+ let p = l, m = u, h = u, g = f.minimumHeight;
5878
+ for (let e = 0; e < 24; e += 1) {
5879
+ let e = (p + m) / 2, t = d({ scale: e });
5880
+ if (t.isValid) {
5881
+ h = e, g = t.minimumHeight, m = e;
5882
+ continue;
5883
+ }
5884
+ p = e;
5885
+ }
5886
+ return {
5887
+ scale: h,
5888
+ minimumHeight: g
5889
+ };
5890
+ }
5891
+ function fi({ group: e, text: t, width: n, padding: r, measurementCache: i }) {
5892
+ return br({
5712
5893
  text: t,
5713
5894
  width: n,
5714
5895
  height: 1,
5715
5896
  padding: r,
5716
- resolvePaddingForSize: ({ width: t, height: n }) => ti({
5897
+ measurementCache: i ?? void 0,
5898
+ resolvePaddingForSize: ({ width: t, height: n }) => li({
5717
5899
  group: e,
5718
5900
  width: t,
5719
5901
  height: n
5720
5902
  })
5721
5903
  });
5722
5904
  }
5723
- function ri({ group: e, text: t, constraintPadding: n, startDimensions: r, appliedScaleX: i, appliedScaleY: a, minimumHeight: o }) {
5724
- let s = r.canScaleWidth ? Math.max(1, r.startWidth * i) : r.startWidth, c = r.canScaleHeight ? Math.max(1, r.startHeight * a) : r.startManualBaseHeight, l = o ?? gr({
5905
+ function pi({ group: e, text: t, constraintPadding: n, startDimensions: r, appliedScaleX: i, appliedScaleY: a, minimumHeight: o, measurementCache: s }) {
5906
+ 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 ?? br({
5725
5907
  text: t,
5726
- width: s,
5727
- height: c,
5908
+ width: c,
5909
+ height: l,
5728
5910
  padding: n,
5729
- resolvePaddingForSize: ({ width: t, height: n }) => ti({
5911
+ measurementCache: s ?? void 0,
5912
+ resolvePaddingForSize: ({ width: t, height: n }) => li({
5730
5913
  group: e,
5731
5914
  width: t,
5732
5915
  height: n
5733
5916
  })
5734
5917
  });
5735
5918
  return {
5736
- previewWidth: s,
5737
- previewHeight: Math.max(c, l)
5919
+ previewWidth: c,
5920
+ previewHeight: Math.max(l, u)
5738
5921
  };
5739
5922
  }
5740
- function ii({ group: e, text: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
5923
+ function mi({ group: e, text: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
5741
5924
  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;
5742
5925
  return ur({
5743
5926
  text: t,
5744
5927
  width: o,
5745
5928
  height: c,
5746
5929
  alignV: e.shapeAlignVertical ?? "middle",
5747
- padding: $r({ group: e }),
5930
+ padding: si({ group: e }),
5748
5931
  expandShapeHeightToFitText: l,
5749
- resolveInternalShapeTextInset: ({ width: t, height: n }) => ei({
5932
+ measurementCache: n.previewTextMeasurementCache ?? void 0,
5933
+ resolveInternalShapeTextInset: ({ width: t, height: n }) => ci({
5750
5934
  group: e,
5751
5935
  width: t,
5752
5936
  height: n
5753
5937
  })
5754
5938
  });
5755
5939
  }
5756
- function ai({ group: e, transform: t }) {
5757
- let { canScaleWidth: n, canScaleHeight: r } = Hr({ transform: t }), i = Math.max(1, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1), a = Math.max(1, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1);
5940
+ function hi({ group: e, transform: t }) {
5941
+ let { canScaleWidth: n, canScaleHeight: r } = qr({ transform: t }), i = Math.max(1, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1), a = Math.max(1, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1);
5758
5942
  return {
5759
5943
  startWidth: i,
5760
5944
  startHeight: a,
@@ -5764,33 +5948,38 @@ function ai({ group: e, transform: t }) {
5764
5948
  canScaleHeight: r
5765
5949
  };
5766
5950
  }
5767
- function oi({ scalingState: e, group: t, text: n, constraintPadding: r, transform: i }) {
5951
+ function gi({ scalingState: e, group: t, text: n, constraintPadding: r, transform: i }) {
5768
5952
  let a = e.get(t);
5769
5953
  if (a) return a;
5770
- let o = ai({
5954
+ let o = hi({
5771
5955
  group: t,
5772
5956
  transform: i
5773
- }), s = zr({
5957
+ }), s = Wr({
5774
5958
  transform: i,
5775
5959
  key: "scaleX"
5776
- }), c = zr({
5960
+ }), c = Wr({
5777
5961
  transform: i,
5778
5962
  key: "scaleY"
5779
- }), l = zr({
5963
+ }), l = Wr({
5780
5964
  transform: i,
5781
5965
  key: "left"
5782
- }), u = zr({
5966
+ }), u = Wr({
5783
5967
  transform: i,
5784
5968
  key: "top"
5785
- }), 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 = Br({ value: i?.original?.originX ?? i?.originX }), g = Vr({ value: i?.original?.originY ?? i?.originY }), _ = typeof i?.corner == "string" ? i.corner : null, v = Wr({
5969
+ }), 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 = Gr({ value: i?.original?.originX ?? i?.originX }), g = Kr({ value: i?.original?.originY ?? i?.originY }), _ = typeof i?.corner == "string" ? i.corner : null, v = Yr({
5786
5970
  group: t,
5787
5971
  originX: h,
5788
5972
  originY: g
5789
- }), y = ni({
5973
+ }), y = !o.canScaleWidth && o.canScaleHeight, b = {
5974
+ measurementsByKey: /* @__PURE__ */ new Map(),
5975
+ splitByGraphemeByFrameWidth: /* @__PURE__ */ new Map(),
5976
+ minimumTextFrameWidth: null
5977
+ }, x = /* @__PURE__ */ new Map(), S = fi({
5790
5978
  group: t,
5791
5979
  text: n,
5792
5980
  width: o.startWidth,
5793
- padding: r
5981
+ padding: r,
5982
+ measurementCache: b
5794
5983
  });
5795
5984
  return a = {
5796
5985
  startWidth: o.startWidth,
@@ -5799,7 +5988,7 @@ function oi({ scalingState: e, group: t, text: n, constraintPadding: r, transfor
5799
5988
  startManualBaseHeight: o.startManualBaseHeight,
5800
5989
  canScaleWidth: o.canScaleWidth,
5801
5990
  canScaleHeight: o.canScaleHeight,
5802
- cannotScaleDownAtStart: y >= o.startHeight - Zr,
5991
+ cannotScaleDownAtStart: S >= o.startHeight - ni,
5803
5992
  isProportionalScaling: !1,
5804
5993
  blockedScaleAttempt: !1,
5805
5994
  startLeft: p,
@@ -5819,18 +6008,23 @@ function oi({ scalingState: e, group: t, text: n, constraintPadding: r, transfor
5819
6008
  lastAllowedScaleX: d,
5820
6009
  lastAllowedScaleY: f,
5821
6010
  lastAllowedLeft: p,
5822
- lastAllowedTop: m
6011
+ lastAllowedTop: m,
6012
+ scaleDirectionX: null,
6013
+ scaleDirectionY: null,
6014
+ fixedWidthMinimumTextFitHeight: y ? S : null,
6015
+ previewTextMeasurementCache: b,
6016
+ proportionalTextConstraintCache: x
5823
6017
  }, e.set(t, a), a;
5824
6018
  }
5825
- function si({ group: e, text: t, constraintPadding: n, startDimensions: r, scaleX: i, scaleY: a }) {
5826
- let { previewWidth: o, previewHeight: s } = ri({
6019
+ function _i({ group: e, text: t, constraintPadding: n, startDimensions: r, scaleX: i, scaleY: a }) {
6020
+ let { previewWidth: o, previewHeight: s } = pi({
5827
6021
  group: e,
5828
6022
  text: t,
5829
6023
  constraintPadding: n,
5830
6024
  startDimensions: r,
5831
6025
  appliedScaleX: i,
5832
6026
  appliedScaleY: a
5833
- }), { startWidth: c, startHeight: l } = r, u = Math.abs(o - c) > Qr, d = Math.abs(s - l) > Qr;
6027
+ }), { startWidth: c, startHeight: l } = r, u = Math.abs(o - c) > ri, d = Math.abs(s - l) > ri;
5834
6028
  return {
5835
6029
  width: o,
5836
6030
  height: s,
@@ -5838,7 +6032,7 @@ function si({ group: e, text: t, constraintPadding: n, startDimensions: r, scale
5838
6032
  hasDimensionChange: u || d
5839
6033
  };
5840
6034
  }
5841
- function ci({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth: n, canScaleHeight: r, finalWidth: i, finalHeight: a }) {
6035
+ function vi({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth: n, canScaleHeight: r, finalWidth: i, finalHeight: a }) {
5842
6036
  let o = e;
5843
6037
  n && (o = i);
5844
6038
  let s = t;
@@ -5847,8 +6041,8 @@ function ci({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth:
5847
6041
  height: s
5848
6042
  };
5849
6043
  }
5850
- function li({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, startManualBaseWidth: s, startManualBaseHeight: c, canScaleWidth: l, canScaleHeight: u, hasWidthChange: d }) {
5851
- let f = ci({
6044
+ function yi({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, startManualBaseWidth: s, startManualBaseHeight: c, canScaleWidth: l, canScaleHeight: u, hasWidthChange: d }) {
6045
+ let f = vi({
5852
6046
  startManualBaseWidth: s,
5853
6047
  startManualBaseHeight: c,
5854
6048
  canScaleWidth: l,
@@ -5857,12 +6051,28 @@ function li({ group: e, shape: t, text: n, width: r, height: i, alignH: a, align
5857
6051
  finalHeight: i
5858
6052
  });
5859
6053
  e.shapeManualBaseWidth = f.width, e.shapeManualBaseHeight = f.height, l && d && (e.shapeTextAutoExpand = !1);
5860
- let p = $r({ group: e }), m = ei({
6054
+ let p = si({ group: e }), m = ci({
5861
6055
  group: e,
5862
6056
  width: r,
5863
6057
  height: i
5864
- }), h = !u;
5865
- dr({
6058
+ }), h = !u, g = ({ width: t, height: n }) => ci({
6059
+ group: e,
6060
+ width: t,
6061
+ height: n
6062
+ });
6063
+ !l && u ? hr({
6064
+ group: e,
6065
+ shape: t,
6066
+ text: n,
6067
+ width: r,
6068
+ height: i,
6069
+ alignH: a,
6070
+ alignV: o,
6071
+ padding: p,
6072
+ internalShapeTextInset: m,
6073
+ expandShapeHeightToFitText: h,
6074
+ resolveInternalShapeTextInset: g
6075
+ }) : mr({
5866
6076
  group: e,
5867
6077
  shape: t,
5868
6078
  text: n,
@@ -5874,12 +6084,8 @@ function li({ group: e, shape: t, text: n, width: r, height: i, alignH: a, align
5874
6084
  shapeTextAutoExpandEnabled: e.shapeTextAutoExpand !== !1,
5875
6085
  internalShapeTextInset: m,
5876
6086
  expandShapeHeightToFitText: h,
5877
- resolveInternalShapeTextInset: ({ width: t, height: n }) => ei({
5878
- group: e,
5879
- width: t,
5880
- height: n
5881
- })
5882
- }), e.shapeReplaceBoxWidth = Math.max(1, e.shapeBaseWidth ?? r), e.shapeReplaceBoxHeight = Math.max(1, e.shapeBaseHeight ?? i), n.set({
6087
+ resolveInternalShapeTextInset: g
6088
+ }), e.shapeReplaceBoxWidth = Math.max(1, r), e.shapeReplaceBoxHeight = Math.max(1, i), n.set({
5883
6089
  scaleX: 1,
5884
6090
  scaleY: 1
5885
6091
  }), e.set({
@@ -5889,76 +6095,85 @@ function li({ group: e, shape: t, text: n, width: r, height: i, alignH: a, align
5889
6095
  }
5890
6096
  //#endregion
5891
6097
  //#region src/editor/shape-manager/scaling/shape-active-selection-scaling.ts
5892
- var ui = class {
6098
+ var bi = class {
5893
6099
  constructor({ canvas: e, shapeScalingState: t }) {
5894
6100
  this.canvas = e, this.shapeScalingState = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.scalingSessions = /* @__PURE__ */ new WeakMap(), this.groupLayoutScales = /* @__PURE__ */ new WeakMap();
5895
6101
  }
5896
6102
  handleScalingPreview({ selection: e, transform: t, event: n }) {
5897
6103
  if (!t) return;
5898
- let { canScaleWidth: r, canScaleHeight: i } = Hr({ transform: t });
6104
+ let { canScaleWidth: r, canScaleHeight: i, isCornerScaleAction: a } = qr({ transform: t });
5899
6105
  if (!r && !i) return;
5900
- let a = this._collectPreviewItems({
6106
+ let o = this._collectPreviewItems({
5901
6107
  selection: e,
5902
6108
  transform: t
5903
6109
  });
5904
- if (!a.length) return;
5905
- let o = this._ensureScalingSession({
6110
+ if (!o.length) return;
6111
+ let s = this._ensureScalingSession({
5906
6112
  selection: e,
5907
6113
  transform: t,
5908
- items: a
5909
- }), s = Math.abs(e.scaleX ?? 1) || 1, c = Math.abs(e.scaleY ?? 1) || 1, l = this._resolveSelectionScale({
5910
- items: a,
5911
- session: o,
6114
+ items: o
6115
+ }), c = !!(n && "shiftKey" in n && n.shiftKey), l = a && !c, u = Math.abs(e.scaleX ?? 1) || 1, d = Math.abs(e.scaleY ?? 1) || 1, f = l && l && (u < .9999 || d < .9999) ? this._resolveProportionalLayoutResults({ items: o }) : null, p = this._resolveSelectionScale({
6116
+ items: o,
6117
+ session: s,
5912
6118
  transform: t,
5913
- scaleX: s,
5914
- scaleY: c,
6119
+ proportionalLayoutResults: f,
6120
+ scaleX: u,
6121
+ scaleY: d,
5915
6122
  event: n
5916
6123
  });
5917
- l = this._resolveSelectionScaleAtPointerBoundary({
6124
+ p = this._resolveSelectionScaleAtPointerBoundary({
5918
6125
  selection: e,
5919
- items: a,
5920
- session: o,
6126
+ items: o,
6127
+ session: s,
5921
6128
  transform: t,
5922
- selectionScale: l,
6129
+ selectionScale: p,
5923
6130
  event: n
5924
6131
  }), this._applySelectionScale({
5925
6132
  selection: e,
5926
6133
  transform: t,
5927
- scaleX: l.scaleX,
5928
- scaleY: l.scaleY
5929
- }), this.scalingState.set(e, l);
5930
- for (let e of a) {
5931
- let { group: t, shape: n, text: r, constraintPadding: i, state: a } = e, s = o.items.get(t), c = this._resolveShapeLayoutScale({
6134
+ scaleX: p.scaleX,
6135
+ scaleY: p.scaleY
6136
+ }), this.scalingState.set(e, p);
6137
+ for (let e of o) {
6138
+ let { group: t, shape: n, text: r, constraintPadding: i, state: a } = e, o = s.items.get(t), c, l;
6139
+ if (f) {
6140
+ let e = f.get(t), n = Math.max(p.scaleX, e.minimumScale);
6141
+ c = {
6142
+ scaleX: a.canScaleWidth ? n : 1,
6143
+ scaleY: a.canScaleHeight ? n : 1
6144
+ }, l = e.minimumHeight;
6145
+ } else c = this._resolveShapeLayoutScale({
5932
6146
  item: e,
5933
- selectionScale: l
5934
- }), u = ri({
6147
+ selectionScale: p
6148
+ }), l = pi({
5935
6149
  group: t,
5936
6150
  text: r,
5937
6151
  constraintPadding: i,
5938
6152
  startDimensions: a,
5939
6153
  appliedScaleX: c.scaleX,
5940
- appliedScaleY: c.scaleY
5941
- });
5942
- Xr({
6154
+ appliedScaleY: c.scaleY,
6155
+ measurementCache: a.previewTextMeasurementCache
6156
+ }).previewHeight;
6157
+ ti({
5943
6158
  group: t,
5944
6159
  shape: n,
5945
6160
  text: r,
5946
- layout: ii({
6161
+ layout: mi({
5947
6162
  group: t,
5948
6163
  text: r,
5949
6164
  state: a,
5950
6165
  appliedScaleX: c.scaleX,
5951
6166
  appliedScaleY: c.scaleY,
5952
- minimumHeight: u.previewHeight
6167
+ minimumHeight: l
5953
6168
  }),
5954
6169
  alignH: t.shapeAlignHorizontal ?? "center",
5955
- scaleX: l.scaleX,
5956
- scaleY: l.scaleY,
6170
+ scaleX: p.scaleX,
6171
+ scaleY: p.scaleY,
5957
6172
  minSize: 1,
5958
- scaleEpsilon: Zr
6173
+ scaleEpsilon: ni
5959
6174
  }), this.groupLayoutScales.set(t, c), this._positionShapeInSelection({
5960
6175
  group: t,
5961
- sessionItem: s
6176
+ sessionItem: o
5962
6177
  }), t.setCoords();
5963
6178
  }
5964
6179
  e.setCoords(), this.canvas.requestRenderAll();
@@ -5966,13 +6181,13 @@ var ui = class {
5966
6181
  commitGroupScaling({ group: e, scaleX: t, scaleY: n, transform: r }) {
5967
6182
  let { shape: i, text: a } = Y({ group: e });
5968
6183
  if (!i || !a) return this.shapeScalingState.delete(e), !1;
5969
- let o = this.shapeScalingState.get(e), s = o ?? ai({
6184
+ let o = this.shapeScalingState.get(e), s = o ?? hi({
5970
6185
  group: e,
5971
6186
  transform: r
5972
- }), c = r ? Hr({ 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 = ti({ group: e }), m = this.groupLayoutScales.get(e) ?? {
6187
+ }), c = r ? qr({ 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 = li({ group: e }), m = this.groupLayoutScales.get(e) ?? {
5973
6188
  scaleX: t,
5974
6189
  scaleY: n
5975
- }, { width: h, height: g, hasWidthChange: _, hasDimensionChange: v } = si({
6190
+ }, { width: h, height: g, hasWidthChange: _, hasDimensionChange: v } = _i({
5976
6191
  group: e,
5977
6192
  text: a,
5978
6193
  constraintPadding: p,
@@ -5984,7 +6199,7 @@ var ui = class {
5984
6199
  scaleX: m.scaleX,
5985
6200
  scaleY: m.scaleY
5986
6201
  });
5987
- return v ? (li({
6202
+ return v ? (yi({
5988
6203
  group: e,
5989
6204
  shape: i,
5990
6205
  text: a,
@@ -6020,7 +6235,7 @@ var ui = class {
6020
6235
  if (!J(r)) continue;
6021
6236
  let { shape: e, text: i } = Y({ group: r });
6022
6237
  if (!e || !i) continue;
6023
- let a = ti({ group: r }), o = oi({
6238
+ let a = li({ group: r }), o = gi({
6024
6239
  scalingState: this.shapeScalingState,
6025
6240
  group: r,
6026
6241
  text: i,
@@ -6040,7 +6255,7 @@ var ui = class {
6040
6255
  _ensureScalingSession({ selection: e, transform: t, items: n }) {
6041
6256
  let r = this.scalingSessions.get(e);
6042
6257
  if (r) return r;
6043
- let i = Br({ value: t.originX }) ?? "center", a = Vr({ value: t.originY }) ?? "center", o = n[0], s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = this._resolveShapeLocalBounds({ group: o.group });
6258
+ let i = Gr({ value: t.originX }) ?? "center", a = Kr({ value: t.originY }) ?? "center", o = n[0], s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = this._resolveShapeLocalBounds({ group: o.group });
6044
6259
  for (let { group: e } of n) {
6045
6260
  let t = this._resolveShapeLocalBounds({ group: e });
6046
6261
  s.set(e, t), l = this._mergeBounds({
@@ -6066,47 +6281,83 @@ var ui = class {
6066
6281
  };
6067
6282
  return this.scalingSessions.set(e, u), u;
6068
6283
  }
6069
- _resolveSelectionScale({ items: e, session: t, transform: n, scaleX: r, scaleY: i, event: a }) {
6070
- let { canScaleWidth: o, canScaleHeight: s, isCornerScaleAction: c } = Hr({ transform: n }), l = !!(a && "shiftKey" in a && a.shiftKey), u = r, d = i;
6071
- if (o && (u = this._resolveSelectionScaleX({
6284
+ _resolveSelectionScale({ items: e, session: t, transform: n, proportionalLayoutResults: r, scaleX: i, scaleY: a, event: o }) {
6285
+ let { canScaleWidth: s, canScaleHeight: c, isCornerScaleAction: l } = qr({ transform: n }), u = !!(o && "shiftKey" in o && o.shiftKey), d = l && !u, f = i, p = a;
6286
+ if (d) {
6287
+ let n = Math.max(i, a);
6288
+ if (!r) return {
6289
+ scaleX: n,
6290
+ scaleY: n
6291
+ };
6292
+ let o = this._resolveProportionalSelectionScale({
6293
+ items: e,
6294
+ session: t,
6295
+ proportionalLayoutResults: r,
6296
+ scale: n,
6297
+ allowGrowthX: c,
6298
+ allowGrowthY: s
6299
+ });
6300
+ return {
6301
+ scaleX: o,
6302
+ scaleY: o
6303
+ };
6304
+ }
6305
+ return s && (f = this._resolveSelectionScaleX({
6072
6306
  items: e,
6073
6307
  session: t,
6074
- scaleX: r,
6075
- scaleY: d,
6076
- allowGrowth: s
6077
- })), s && (d = this._resolveSelectionScaleY({
6308
+ scaleX: i,
6309
+ scaleY: p,
6310
+ allowGrowth: c
6311
+ })), c && (p = this._resolveSelectionScaleY({
6078
6312
  items: e,
6079
6313
  session: t,
6080
- scaleX: u,
6081
- scaleY: i,
6082
- allowGrowth: o
6083
- })), o && s && (u = this._resolveSelectionScaleX({
6314
+ scaleX: f,
6315
+ scaleY: a,
6316
+ allowGrowth: s
6317
+ })), s && c && (f = this._resolveSelectionScaleX({
6084
6318
  items: e,
6085
6319
  session: t,
6086
- scaleX: r,
6087
- scaleY: d,
6088
- allowGrowth: s
6089
- }), d = this._resolveSelectionScaleY({
6320
+ scaleX: i,
6321
+ scaleY: p,
6322
+ allowGrowth: c
6323
+ }), p = this._resolveSelectionScaleY({
6090
6324
  items: e,
6091
6325
  session: t,
6092
- scaleX: u,
6093
- scaleY: i,
6094
- allowGrowth: o
6095
- })), c && l) {
6096
- let e = Math.max(u, d);
6097
- return {
6098
- scaleX: e,
6099
- scaleY: e
6100
- };
6101
- }
6102
- return {
6103
- scaleX: u,
6104
- scaleY: d
6326
+ scaleX: f,
6327
+ scaleY: a,
6328
+ allowGrowth: s
6329
+ })), {
6330
+ scaleX: f,
6331
+ scaleY: p
6105
6332
  };
6106
6333
  }
6334
+ _resolveProportionalSelectionScale({ items: e, session: t, proportionalLayoutResults: n, scale: r, allowGrowthX: i, allowGrowthY: a }) {
6335
+ let o = r;
6336
+ for (let s of e) {
6337
+ let e = t.items.get(s.group), c = n.get(s.group).minimumScale, l = s.state.canScaleWidth ? Math.max(1, s.state.startWidth * c) : s.state.startWidth, u = s.state.canScaleHeight ? Math.max(1, s.state.startHeight * c) : s.state.startHeight, d = this._resolveSelectionAvailableWidth({
6338
+ selectionBounds: t.bounds,
6339
+ shapeBounds: e.bounds,
6340
+ originX: e.transformOriginX
6341
+ }), f = this._resolveSelectionAvailableHeight({
6342
+ selectionBounds: t.bounds,
6343
+ shapeBounds: e.bounds,
6344
+ verticalAttachment: e.verticalAttachment
6345
+ }), p = s.state.canScaleWidth ? this._resolveMinimumScaleForSize({
6346
+ minimumSize: l,
6347
+ startSize: d,
6348
+ allowGrowth: i
6349
+ }) : r, m = s.state.canScaleHeight ? this._resolveMinimumScaleForSize({
6350
+ minimumSize: u,
6351
+ startSize: f,
6352
+ allowGrowth: a
6353
+ }) : r;
6354
+ o = Math.max(o, p, m);
6355
+ }
6356
+ return o;
6357
+ }
6107
6358
  _resolveSelectionScaleAtPointerBoundary({ selection: e, items: t, session: n, transform: r, selectionScale: i, event: a }) {
6108
- let { canScaleWidth: o, canScaleHeight: s, isCornerScaleAction: c } = Hr({ transform: r }), l = !!(a && "shiftKey" in a && a.shiftKey);
6109
- if (c && l) return i;
6359
+ let { canScaleWidth: o, canScaleHeight: s, isCornerScaleAction: c } = qr({ transform: r }), l = !!(a && "shiftKey" in a && a.shiftKey);
6360
+ if (c && !l) return i;
6110
6361
  let u = o && this._hasPointerReachedSelectionScaleOrigin({
6111
6362
  selection: e,
6112
6363
  transform: r,
@@ -6124,6 +6375,7 @@ var ui = class {
6124
6375
  items: t,
6125
6376
  session: n,
6126
6377
  transform: r,
6378
+ proportionalLayoutResults: null,
6127
6379
  scaleX: f,
6128
6380
  scaleY: p,
6129
6381
  event: a
@@ -6220,12 +6472,28 @@ var ui = class {
6220
6472
  });
6221
6473
  return Math.max(n, a);
6222
6474
  }
6475
+ _resolveProportionalLayoutResults({ items: e }) {
6476
+ let t = /* @__PURE__ */ new Map();
6477
+ for (let n of e) {
6478
+ let e = di({
6479
+ group: n.group,
6480
+ text: n.text,
6481
+ state: n.state
6482
+ });
6483
+ t.set(n.group, {
6484
+ minimumScale: e.scale,
6485
+ minimumHeight: e.minimumHeight
6486
+ });
6487
+ }
6488
+ return t;
6489
+ }
6223
6490
  _resolveMinimumShapeWidth({ item: e, scaleY: t }) {
6224
6491
  let { group: n, text: r, constraintPadding: i, state: a } = e, o = Math.max(1, a.startHeight * t);
6225
- return mr({
6492
+ return vr({
6226
6493
  text: r,
6227
6494
  padding: i,
6228
- resolvePaddingForWidth: ({ width: e }) => ti({
6495
+ measurementCache: a.previewTextMeasurementCache ?? void 0,
6496
+ resolvePaddingForWidth: ({ width: e }) => li({
6229
6497
  group: n,
6230
6498
  width: e,
6231
6499
  height: o
@@ -6238,11 +6506,12 @@ var ui = class {
6238
6506
  }
6239
6507
  _resolveMinimumShapeHeight({ item: e, scaleX: t }) {
6240
6508
  let { group: n, text: r, constraintPadding: i, state: a } = e;
6241
- return ni({
6509
+ return fi({
6242
6510
  group: n,
6243
6511
  text: r,
6244
6512
  width: Math.max(1, a.startWidth * t),
6245
- padding: i
6513
+ padding: i,
6514
+ measurementCache: a.previewTextMeasurementCache
6246
6515
  });
6247
6516
  }
6248
6517
  _resolveSelectionAvailableWidth({ selectionBounds: e, shapeBounds: t, originX: n }) {
@@ -6276,7 +6545,7 @@ var ui = class {
6276
6545
  };
6277
6546
  }
6278
6547
  _resolveVerticalAttachment({ selectionBounds: e, shapeBounds: t }) {
6279
- let n = Math.max(0, t.top - e.top), r = Math.max(0, e.bottom - t.bottom), i = n <= Qr, a = r <= Qr;
6548
+ let n = Math.max(0, t.top - e.top), r = Math.max(0, e.bottom - t.bottom), i = n <= ri, a = r <= ri;
6280
6549
  return i && !a ? "top" : a && !i ? "bottom" : Math.abs(n - r) <= .5 ? "center" : n < r ? "top" : "bottom";
6281
6550
  }
6282
6551
  _resolveOriginOffset({ origin: e }) {
@@ -6297,7 +6566,7 @@ var ui = class {
6297
6566
  _hasPointerReachedSelectionScaleOrigin({ selection: e, transform: t, event: n, axis: r }) {
6298
6567
  let i = t, a = r === "x" ? i.signX : i.signY;
6299
6568
  if (typeof a != "number" || !Number.isFinite(a)) return !1;
6300
- let o = Ur({
6569
+ let o = Jr({
6301
6570
  target: e,
6302
6571
  transform: t,
6303
6572
  event: n,
@@ -6308,7 +6577,7 @@ var ui = class {
6308
6577
  _applySelectionScale({ selection: e, transform: t, scaleX: n, scaleY: r }) {
6309
6578
  let i = Math.abs(e.scaleX ?? 1) || 1, a = Math.abs(e.scaleY ?? 1) || 1;
6310
6579
  if (!(Math.abs(i - n) > 1e-4 || Math.abs(a - r) > 1e-4)) return;
6311
- let o = Br({ value: t.originX }), s = Vr({ value: t.originY }), c = o !== null && s !== null ? e.getPositionByOrigin(o, s) : null;
6580
+ let o = Gr({ value: t.originX }), s = Kr({ value: t.originY }), c = o !== null && s !== null ? e.getPositionByOrigin(o, s) : null;
6312
6581
  e.set({
6313
6582
  flipX: !1,
6314
6583
  flipY: !1,
@@ -6316,7 +6585,7 @@ var ui = class {
6316
6585
  scaleY: r
6317
6586
  }), c && o !== null && s !== null && e.setPositionByOrigin(c, o, s), e.setCoords();
6318
6587
  }
6319
- }, di = class {
6588
+ }, xi = class {
6320
6589
  constructor({ canvas: t }) {
6321
6590
  this.handleObjectScaling = (t) => {
6322
6591
  let { target: n, transform: r } = t;
@@ -6335,35 +6604,50 @@ var ui = class {
6335
6604
  lockScalingFlip: !0,
6336
6605
  centeredScaling: !1
6337
6606
  });
6338
- let s = ti({ group: i }), c = oi({
6607
+ let s = li({ group: i }), c = gi({
6339
6608
  scalingState: this.scalingState,
6340
6609
  group: i,
6341
6610
  text: o,
6342
6611
  constraintPadding: s,
6343
6612
  transform: r
6344
- }), { isCornerScaleAction: l } = Hr({ transform: r }), u = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
6345
- c.isProportionalScaling = l && u;
6613
+ }), l = c.canScaleWidth && c.canScaleHeight, u = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
6614
+ c.isProportionalScaling = l && !u, this._storeScaleDirectionsForCurrentTransform({
6615
+ group: i,
6616
+ state: c,
6617
+ event: t.e,
6618
+ transform: r
6619
+ });
6346
6620
  let d = i.left ?? 0, f = i.top ?? 0, p = !!i.flipX, m = !!i.flipY, h = i.shapeAlignHorizontal ?? "center", g = this._resolveScalingDecision({
6347
6621
  group: i,
6348
6622
  text: o,
6349
6623
  constraintPadding: s,
6350
6624
  state: c,
6351
6625
  transform: r
6352
- }), _ = ii({
6626
+ });
6627
+ if (g.shouldHandleAsNoop) {
6628
+ this._restoreBlockedScalingAttempt({
6629
+ group: i,
6630
+ shape: a,
6631
+ text: o,
6632
+ state: c
6633
+ });
6634
+ return;
6635
+ }
6636
+ let _ = mi({
6353
6637
  group: i,
6354
6638
  text: o,
6355
6639
  state: c,
6356
6640
  appliedScaleX: g.appliedScaleX,
6357
6641
  appliedScaleY: g.appliedScaleY,
6358
6642
  minimumHeight: g.previewHeight
6359
- }), v = Math.abs(i.scaleX ?? 1) || 1, y = Math.abs(i.scaleY ?? 1) || 1;
6360
- (g.shouldHandleAsNoop || g.shouldRestoreLastAllowedTransform || Math.abs(g.appliedScaleX - v) > 1e-4 || Math.abs(g.appliedScaleY - y) > 1e-4) && this._applyResolvedScalingState({
6643
+ }), v = Math.abs(i.scaleX ?? c.startScaleX) || c.startScaleX, y = Math.abs(i.scaleY ?? c.startScaleY) || c.startScaleY;
6644
+ (g.shouldRestoreLastAllowedTransform || Math.abs(g.appliedScaleX - v) > 1e-4 || Math.abs(g.appliedScaleY - y) > 1e-4) && this._applyResolvedScalingState({
6361
6645
  group: i,
6362
6646
  state: c,
6363
- shouldHandleAsNoop: g.shouldHandleAsNoop,
6647
+ shouldHandleAsNoop: !1,
6364
6648
  scaleX: g.appliedScaleX,
6365
6649
  scaleY: g.appliedScaleY
6366
- }), Xr({
6650
+ }), ti({
6367
6651
  group: i,
6368
6652
  shape: a,
6369
6653
  text: o,
@@ -6372,15 +6656,15 @@ var ui = class {
6372
6656
  scaleX: g.appliedScaleX,
6373
6657
  scaleY: g.appliedScaleY,
6374
6658
  minSize: 1,
6375
- scaleEpsilon: Zr
6659
+ scaleEpsilon: ni
6376
6660
  }), this._restoreScalingAnchorPosition({
6377
6661
  group: i,
6378
6662
  state: c
6379
6663
  }), !g.shouldHandleAsNoop && !g.shouldRestoreLastAllowedTransform && this._storeLastAllowedTransform({
6380
6664
  group: i,
6381
6665
  state: c,
6382
- scaleX: i.scaleX ?? 1,
6383
- scaleY: i.scaleY ?? 1,
6666
+ scaleX: g.appliedScaleX,
6667
+ scaleY: g.appliedScaleY,
6384
6668
  currentLeft: d,
6385
6669
  currentTop: f,
6386
6670
  currentFlipX: p,
@@ -6399,91 +6683,130 @@ var ui = class {
6399
6683
  return;
6400
6684
  }
6401
6685
  if (!J(r)) return;
6402
- let { canScaleHeight: i, canScaleWidth: a } = Hr({ transform: n });
6403
- if (!a && !i) return;
6404
- let o = r, s = this.scalingState.get(o);
6405
- if (!s || s.isProportionalScaling) return;
6406
- let { shape: c, text: l } = Y({ group: o });
6407
- if (!c || !l) return;
6408
- let u = ti({ group: o }), d = o.shapeAlignHorizontal ?? "center", f = Math.abs(o.scaleX ?? s.lastAllowedScaleX ?? 1) || 1, p = Math.abs(o.scaleY ?? s.lastAllowedScaleY ?? 1) || 1, m = {
6686
+ let i = r, a = this.scalingState.get(i);
6687
+ if (!a) return;
6688
+ let { shape: o, text: s } = Y({ group: i });
6689
+ if (!o || !s) return;
6690
+ let c = li({ group: i }), l = i.shapeAlignHorizontal ?? "center", { canScaleWidth: u, canScaleHeight: d } = a;
6691
+ if (!u && !d) return;
6692
+ 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({
6693
+ group: i,
6694
+ state: a
6695
+ }), g = {
6409
6696
  ...t,
6410
6697
  transform: n
6411
- }, h = f, g = p, _ = null, v = !1, y = !1;
6412
- if (a && this._hasPointerReachedScaleOrigin({
6413
- event: m,
6414
- group: o,
6415
- axis: "x"
6416
- })) {
6417
- let e = mr({
6418
- text: l,
6419
- padding: u,
6420
- resolvePaddingForWidth: ({ width: e }) => ti({
6421
- group: o,
6422
- width: e,
6423
- height: Math.max(1, s.startHeight * g)
6424
- })
6425
- }), t = Math.max(1 / s.startWidth, e / s.startWidth);
6426
- s.lastAllowedScaleX > t + 1e-4 && (h = t, v = !0, y = !0);
6427
- }
6428
- if (i && this._hasPointerReachedScaleOrigin({
6429
- event: m,
6430
- group: o,
6431
- axis: "y"
6432
- })) {
6433
- _ = ni({
6434
- group: o,
6435
- text: l,
6436
- width: Math.max(1, s.startWidth * h),
6437
- padding: u
6698
+ }, _ = m, v = h, y = null, b = !1, x = !1, S = !u && Math.abs(f - m) > 1e-4 || !d && Math.abs(p - h) > 1e-4, C = !u && d ? a.fixedWidthMinimumTextFitHeight : null;
6699
+ if (a.isProportionalScaling) {
6700
+ let e = u && this._hasPointerReachedScaleOrigin({
6701
+ event: g,
6702
+ group: i,
6703
+ state: a,
6704
+ axis: "x"
6705
+ }), t = d && this._hasPointerReachedScaleOrigin({
6706
+ event: g,
6707
+ group: i,
6708
+ state: a,
6709
+ axis: "y"
6710
+ });
6711
+ if (!e && !t) return;
6712
+ let n = di({
6713
+ group: i,
6714
+ text: s,
6715
+ state: a
6438
6716
  });
6439
- let e = Math.max(1 / s.startHeight, _ / s.startHeight);
6440
- s.lastAllowedScaleY > e + 1e-4 && (g = e, y = !0);
6441
- }
6442
- if (!y) return;
6443
- let b = ri({
6444
- group: o,
6445
- text: l,
6446
- constraintPadding: u,
6447
- startDimensions: s,
6448
- appliedScaleX: h,
6449
- appliedScaleY: g,
6450
- minimumHeight: v ? null : _
6451
- }), x = ii({
6452
- group: o,
6453
- text: l,
6454
- state: s,
6455
- appliedScaleX: h,
6456
- appliedScaleY: g,
6457
- minimumHeight: b.previewHeight
6717
+ _ = n.scale, v = n.scale, y = n.minimumHeight, x = Math.abs(m - _) > 1e-4 || Math.abs(h - v) > 1e-4;
6718
+ }
6719
+ if (!a.isProportionalScaling) {
6720
+ if (u && this._hasPointerReachedScaleOrigin({
6721
+ event: g,
6722
+ group: i,
6723
+ state: a,
6724
+ axis: "x"
6725
+ })) {
6726
+ let e = vr({
6727
+ text: s,
6728
+ padding: c,
6729
+ resolvePaddingForWidth: ({ width: e }) => li({
6730
+ group: i,
6731
+ width: e,
6732
+ height: Math.max(1, a.startHeight * v)
6733
+ })
6734
+ }), t = Math.max(1 / a.startWidth, e / a.startWidth);
6735
+ a.lastAllowedScaleX > t + 1e-4 && (_ = t, b = !0, x = !0);
6736
+ }
6737
+ if (d && this._hasPointerReachedScaleOrigin({
6738
+ event: g,
6739
+ group: i,
6740
+ state: a,
6741
+ axis: "y"
6742
+ })) {
6743
+ if (!u && a.cannotScaleDownAtStart) {
6744
+ this._restoreBlockedScalingAttempt({
6745
+ group: i,
6746
+ shape: o,
6747
+ text: s,
6748
+ state: a
6749
+ });
6750
+ return;
6751
+ }
6752
+ y = C ?? fi({
6753
+ group: i,
6754
+ text: s,
6755
+ width: Math.max(1, a.startWidth * _),
6756
+ padding: c,
6757
+ measurementCache: a.previewTextMeasurementCache
6758
+ });
6759
+ let e = Math.max(1 / a.startHeight, y / a.startHeight);
6760
+ a.lastAllowedScaleY > e + 1e-4 && (v = e, x = !0);
6761
+ }
6762
+ }
6763
+ if (!x && !S) return;
6764
+ y ??= C;
6765
+ let w = pi({
6766
+ group: i,
6767
+ text: s,
6768
+ constraintPadding: c,
6769
+ startDimensions: a,
6770
+ appliedScaleX: _,
6771
+ appliedScaleY: v,
6772
+ minimumHeight: b ? null : y,
6773
+ measurementCache: a.previewTextMeasurementCache
6774
+ }), T = mi({
6775
+ group: i,
6776
+ text: s,
6777
+ state: a,
6778
+ appliedScaleX: _,
6779
+ appliedScaleY: v,
6780
+ minimumHeight: w.previewHeight
6458
6781
  });
6459
6782
  this._applyResolvedScalingState({
6460
- group: o,
6461
- state: s,
6783
+ group: i,
6784
+ state: a,
6462
6785
  shouldHandleAsNoop: !1,
6463
- scaleX: h,
6464
- scaleY: g
6465
- }), Xr({
6466
- group: o,
6467
- shape: c,
6468
- text: l,
6469
- layout: x,
6470
- alignH: d,
6471
- scaleX: h,
6472
- scaleY: g,
6786
+ scaleX: _,
6787
+ scaleY: v
6788
+ }), ti({
6789
+ group: i,
6790
+ shape: o,
6791
+ text: s,
6792
+ layout: T,
6793
+ alignH: l,
6794
+ scaleX: _,
6795
+ scaleY: v,
6473
6796
  minSize: 1,
6474
- scaleEpsilon: Zr
6797
+ scaleEpsilon: ni
6475
6798
  }), this._restoreScalingAnchorPosition({
6476
- group: o,
6477
- state: s
6799
+ group: i,
6800
+ state: a
6478
6801
  }), this._storeLastAllowedTransform({
6479
- group: o,
6480
- state: s,
6481
- scaleX: h,
6482
- scaleY: g,
6483
- currentLeft: s.lastAllowedLeft,
6484
- currentTop: s.lastAllowedTop,
6485
- currentFlipX: s.lastAllowedFlipX,
6486
- currentFlipY: s.lastAllowedFlipY
6802
+ group: i,
6803
+ state: a,
6804
+ scaleX: _,
6805
+ scaleY: v,
6806
+ currentLeft: a.lastAllowedLeft,
6807
+ currentTop: a.lastAllowedTop,
6808
+ currentFlipX: a.lastAllowedFlipX,
6809
+ currentFlipY: a.lastAllowedFlipY
6487
6810
  }), this.canvas.requestRenderAll();
6488
6811
  }, this.handleObjectModified = (e) => {
6489
6812
  let { target: t } = e;
@@ -6493,11 +6816,20 @@ var ui = class {
6493
6816
  let o = r?.startWidth ?? Math.max(1, n.shapeBaseWidth ?? n.width ?? n.shapeManualBaseWidth ?? 1), s = r?.startHeight ?? Math.max(1, n.shapeBaseHeight ?? n.height ?? n.shapeManualBaseHeight ?? 1), c = r?.startManualBaseWidth ?? Math.max(1, n.shapeManualBaseWidth ?? o), l = r?.startManualBaseHeight ?? Math.max(1, n.shapeManualBaseHeight ?? s);
6494
6817
  if (r?.blockedScaleAttempt && r) {
6495
6818
  let { shape: e, text: t } = Y({ group: n });
6496
- this._restoreGroupTransformOnly({
6819
+ if (!e || !t) {
6820
+ n.shapeScalingNoopTransform = !1, this.scalingState.delete(n);
6821
+ return;
6822
+ }
6823
+ this._restoreShapeStateWithoutResize({
6497
6824
  group: n,
6498
6825
  shape: e,
6499
6826
  text: t,
6500
- state: r
6827
+ state: r,
6828
+ startWidth: o,
6829
+ startHeight: s,
6830
+ alignH: n.shapeAlignHorizontal,
6831
+ alignV: n.shapeAlignVertical,
6832
+ userPadding: si({ group: n })
6501
6833
  }), n.shapeScalingNoopTransform = !1, this.scalingState.delete(n), this.canvas.requestRenderAll();
6502
6834
  return;
6503
6835
  }
@@ -6506,23 +6838,44 @@ var ui = class {
6506
6838
  this.scalingState.delete(n);
6507
6839
  return;
6508
6840
  }
6509
- let f = n.shapeAlignHorizontal ?? "center", p = n.shapeAlignVertical ?? "middle", m = ti({ group: n }), h = e.transform ? Hr({ 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, b = mr({
6510
- text: d,
6511
- padding: m,
6512
- resolvePaddingForWidth: ({ width: e }) => ti({
6841
+ let f = n.shapeAlignHorizontal ?? "center", p = n.shapeAlignVertical ?? "middle", m = li({ group: n }), h = e.transform ? qr({ 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;
6842
+ if (r?.isProportionalScaling) {
6843
+ let t = this._hasPointerReachedScaleOrigin({
6844
+ event: e,
6513
6845
  group: n,
6514
- width: e,
6515
- height: Math.max(1, s * y)
6516
- })
6517
- });
6518
- if (!r?.isProportionalScaling) {
6846
+ state: r,
6847
+ axis: "x"
6848
+ }), o = this._hasPointerReachedScaleOrigin({
6849
+ event: e,
6850
+ group: n,
6851
+ state: r,
6852
+ axis: "y"
6853
+ });
6854
+ if (t || o) {
6855
+ let e = di({
6856
+ group: n,
6857
+ text: d,
6858
+ state: r
6859
+ });
6860
+ (i < e.scale - 1e-4 || a < e.scale - 1e-4) && (v = e.scale, y = e.scale);
6861
+ }
6862
+ } else {
6863
+ let t = vr({
6864
+ text: d,
6865
+ padding: m,
6866
+ resolvePaddingForWidth: ({ width: e }) => li({
6867
+ group: n,
6868
+ width: e,
6869
+ height: Math.max(1, s * y)
6870
+ })
6871
+ });
6519
6872
  this._shouldClampWidthToMinimum({
6520
6873
  event: e,
6521
6874
  group: n,
6522
- minimumWidth: b,
6875
+ minimumWidth: t,
6523
6876
  state: r
6524
- }) && (v = Math.max(1 / o, b / o));
6525
- let t = ni({
6877
+ }) && (v = Math.max(1 / o, t / o));
6878
+ let i = fi({
6526
6879
  group: n,
6527
6880
  text: d,
6528
6881
  width: Math.max(1, o * v),
@@ -6531,11 +6884,11 @@ var ui = class {
6531
6884
  this._shouldClampHeightToMinimum({
6532
6885
  event: e,
6533
6886
  group: n,
6534
- minimumHeight: t,
6887
+ minimumHeight: i,
6535
6888
  state: r
6536
- }) && (y = Math.max(1 / s, t / s));
6889
+ }) && (y = Math.max(1 / s, i / s));
6537
6890
  }
6538
- let { width: x, height: S, hasWidthChange: C, hasDimensionChange: w } = si({
6891
+ let { width: b, height: x, hasWidthChange: S, hasDimensionChange: C } = _i({
6539
6892
  group: n,
6540
6893
  text: d,
6541
6894
  constraintPadding: m,
@@ -6550,7 +6903,7 @@ var ui = class {
6550
6903
  scaleX: v,
6551
6904
  scaleY: y
6552
6905
  });
6553
- if (!w && r) {
6906
+ if (!C && r) {
6554
6907
  this._restoreShapeStateWithoutResize({
6555
6908
  group: n,
6556
6909
  shape: u,
@@ -6560,40 +6913,43 @@ var ui = class {
6560
6913
  startHeight: s,
6561
6914
  alignH: f,
6562
6915
  alignV: p,
6563
- userPadding: $r({ group: n })
6916
+ userPadding: si({ group: n })
6564
6917
  }), this.scalingState.delete(n), this.canvas.requestRenderAll();
6565
6918
  return;
6566
6919
  }
6567
6920
  r && n.set({
6568
6921
  left: r.lastAllowedLeft,
6569
6922
  top: r.lastAllowedTop
6570
- }), li({
6923
+ }), yi({
6571
6924
  group: n,
6572
6925
  shape: u,
6573
6926
  text: d,
6574
- width: x,
6575
- height: S,
6927
+ width: b,
6928
+ height: x,
6576
6929
  alignH: f,
6577
6930
  alignV: p,
6578
6931
  startManualBaseWidth: c,
6579
6932
  startManualBaseHeight: l,
6580
6933
  canScaleWidth: g,
6581
6934
  canScaleHeight: _,
6582
- hasWidthChange: C
6935
+ hasWidthChange: S
6583
6936
  }), r && this._restoreScalingAnchorPosition({
6584
6937
  group: n,
6585
6938
  state: r
6586
6939
  }), n.setCoords(), d.setCoords(), u.setCoords(), this.scalingState.delete(n), n.shapeScalingNoopTransform = !1, this.canvas.requestRenderAll();
6587
- }, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.activeSelectionScalingController = new ui({
6940
+ }, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.activeSelectionScalingController = new bi({
6588
6941
  canvas: t,
6589
6942
  shapeScalingState: this.scalingState
6590
6943
  });
6591
6944
  }
6592
6945
  _resolveScalingDecision({ group: e, text: t, constraintPadding: n, state: r, transform: i }) {
6593
- let a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = Math.abs(a) || 1, c = Math.abs(o) || 1, l = a < 0 || o < 0, u = Gr({
6946
+ let a = e.scaleX ?? 1, o = e.scaleY ?? 1, { scaleX: s, scaleY: c } = this._resolveCurrentDragScales({
6947
+ group: e,
6948
+ state: r
6949
+ }), l = r.canScaleWidth && a < 0 || r.canScaleHeight && o < 0, u = Xr({
6594
6950
  state: r,
6595
6951
  transform: i
6596
- }), d = Kr({
6952
+ }), d = Zr({
6597
6953
  state: r,
6598
6954
  transform: i
6599
6955
  });
@@ -6603,54 +6959,130 @@ var ui = class {
6603
6959
  text: t,
6604
6960
  constraintPadding: n,
6605
6961
  state: r,
6606
- transform: i,
6607
6962
  scaleX: s,
6608
6963
  scaleY: c
6609
- }), p = Math.abs(e.scaleX ?? 1) || 1, m = Math.abs(e.scaleY ?? 1) || 1, h = f.clampedScaleX ?? p, g = f.clampedScaleY ?? m;
6964
+ }), p = s, m = c, h = f.clampedScaleX ?? p, g = f.clampedScaleY ?? m;
6610
6965
  f.shouldRestoreLastAllowedTransform && (h = r.lastAllowedScaleX, g = r.lastAllowedScaleY), f.shouldHandleAsNoop && (h = r.startScaleX, g = r.startScaleY);
6611
- let _ = !f.shouldHandleAsNoop && !f.shouldRestoreLastAllowedTransform && f.clampedScaleX === null, v = ri({
6966
+ let _ = f.resolvedMinimumHeight, v = !r.canScaleWidth && r.canScaleHeight ? r.fixedWidthMinimumTextFitHeight : null;
6967
+ f.shouldHandleAsNoop ? _ = r.startHeight : _ ??= v;
6968
+ let { previewHeight: y } = pi({
6612
6969
  group: e,
6613
6970
  text: t,
6614
6971
  constraintPadding: n,
6615
6972
  startDimensions: r,
6616
6973
  appliedScaleX: h,
6617
6974
  appliedScaleY: g,
6618
- minimumHeight: _ ? f.resolvedMinimumHeight : null
6975
+ minimumHeight: _,
6976
+ measurementCache: r.previewTextMeasurementCache
6619
6977
  });
6620
6978
  return {
6621
6979
  appliedScaleX: h,
6622
6980
  appliedScaleY: g,
6623
- previewWidth: v.previewWidth,
6624
- previewHeight: v.previewHeight,
6981
+ previewHeight: y,
6625
6982
  shouldHandleAsNoop: f.shouldHandleAsNoop,
6626
6983
  shouldRestoreLastAllowedTransform: f.shouldRestoreLastAllowedTransform
6627
6984
  };
6628
6985
  }
6629
- _resolveScalingConstraintState({ group: e, text: t, constraintPadding: n, state: r, transform: i, scaleX: a, scaleY: o }) {
6630
- let { startHeight: s, startWidth: c, cannotScaleDownAtStart: l, crossedOppositeCorner: u, isProportionalScaling: d, lastAllowedScaleX: f, lastAllowedScaleY: p, startScaleY: m } = r, h = Math.max(1, c * a), g = Math.max(1, s * o), _ = a < f - Zr, v = o < p - Zr, y = o < m - Zr, { canScaleHeight: b, canScaleWidth: x, isVerticalOnlyScale: S } = Hr({ transform: i }), C = x && _ ? mr({
6986
+ _resolveScalingConstraintState({ group: e, text: t, constraintPadding: n, state: r, scaleX: i, scaleY: a }) {
6987
+ 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 - ni, b = a < m - ni, x = a < h - ni, S = g ? r.fixedWidthMinimumTextFitHeight : null, C = s && y ? vr({
6631
6988
  text: t,
6632
6989
  padding: n,
6633
- resolvePaddingForWidth: ({ width: t }) => ti({
6990
+ measurementCache: r.previewTextMeasurementCache ?? void 0,
6991
+ resolvePaddingForWidth: ({ width: t }) => li({
6634
6992
  group: e,
6635
6993
  width: t,
6636
- height: g
6994
+ height: v
6637
6995
  })
6638
- }) : null, w = b && v ? ni({
6996
+ }) : null, w = o && b ? S ?? fi({
6639
6997
  group: e,
6640
6998
  text: t,
6641
- width: h,
6642
- padding: n
6643
- }) : null, T = S && l && y, E = C !== null && h < C + 1e-4, D = w !== null && g < w + 1e-4, O = u || d && (E || D), k = null;
6644
- !d && C !== null && h < C + 1e-4 && (k = Math.max(1 / c, C / c));
6645
- let A = null;
6646
- return !d && w !== null && g < w + 1e-4 && (A = Math.max(1 / s, w / s)), {
6999
+ width: _,
7000
+ padding: n,
7001
+ measurementCache: r.previewTextMeasurementCache
7002
+ }) : null, T = g && u && x;
7003
+ if (f && s && o && (y || b)) {
7004
+ if (!ui({
7005
+ group: e,
7006
+ text: t,
7007
+ width: _,
7008
+ height: v,
7009
+ measurementCache: r.previewTextMeasurementCache,
7010
+ constraintCache: r.proportionalTextConstraintCache
7011
+ }).isValid) {
7012
+ let n = di({
7013
+ group: e,
7014
+ text: t,
7015
+ state: r
7016
+ });
7017
+ return {
7018
+ shouldHandleAsNoop: T,
7019
+ shouldRestoreLastAllowedTransform: d,
7020
+ clampedScaleX: n.scale,
7021
+ clampedScaleY: n.scale,
7022
+ resolvedMinimumHeight: n.minimumHeight
7023
+ };
7024
+ }
7025
+ return {
7026
+ shouldHandleAsNoop: T,
7027
+ shouldRestoreLastAllowedTransform: d,
7028
+ clampedScaleX: null,
7029
+ clampedScaleY: null,
7030
+ resolvedMinimumHeight: null
7031
+ };
7032
+ }
7033
+ let E = C !== null && _ < C + 1e-4, D = w !== null && v < w + 1e-4, O = E || D, k = d, A = null, j = null;
7034
+ if (f && O) {
7035
+ let n = di({
7036
+ group: e,
7037
+ text: t,
7038
+ state: r
7039
+ });
7040
+ return A = n.scale, j = n.scale, {
7041
+ shouldHandleAsNoop: T,
7042
+ shouldRestoreLastAllowedTransform: k,
7043
+ clampedScaleX: A,
7044
+ clampedScaleY: j,
7045
+ resolvedMinimumHeight: n.minimumHeight
7046
+ };
7047
+ }
7048
+ return C !== null && _ < C + 1e-4 && (A = Math.max(1 / l, C / l)), w !== null && v < w + 1e-4 && (j = Math.max(1 / c, w / c)), {
6647
7049
  shouldHandleAsNoop: T,
6648
- shouldRestoreLastAllowedTransform: O,
6649
- clampedScaleX: k,
6650
- clampedScaleY: A,
7050
+ shouldRestoreLastAllowedTransform: k,
7051
+ clampedScaleX: A,
7052
+ clampedScaleY: j,
6651
7053
  resolvedMinimumHeight: w
6652
7054
  };
6653
7055
  }
7056
+ _restoreBlockedScalingAttempt({ group: e, shape: t, text: n, state: r }) {
7057
+ let i = e.shapeAlignHorizontal ?? "center";
7058
+ this._applyResolvedScalingState({
7059
+ group: e,
7060
+ state: r,
7061
+ shouldHandleAsNoop: !0,
7062
+ scaleX: r.startScaleX,
7063
+ scaleY: r.startScaleY
7064
+ }), ti({
7065
+ group: e,
7066
+ shape: t,
7067
+ text: n,
7068
+ layout: mi({
7069
+ group: e,
7070
+ text: n,
7071
+ state: r,
7072
+ appliedScaleX: r.startScaleX,
7073
+ appliedScaleY: r.startScaleY,
7074
+ minimumHeight: r.startHeight
7075
+ }),
7076
+ alignH: i,
7077
+ scaleX: r.startScaleX,
7078
+ scaleY: r.startScaleY,
7079
+ minSize: 1,
7080
+ scaleEpsilon: ni
7081
+ }), this._restoreScalingAnchorPosition({
7082
+ group: e,
7083
+ state: r
7084
+ }), this.canvas.requestRenderAll();
7085
+ }
6654
7086
  _applyResolvedScalingState({ group: e, state: t, shouldHandleAsNoop: n, scaleX: r, scaleY: i }) {
6655
7087
  t.blockedScaleAttempt = n, e.shapeScalingNoopTransform = n;
6656
7088
  let a = n ? t.startScaleX : r, o = n ? t.startScaleY : i, s = n ? t.startLeft : t.lastAllowedLeft, c = n ? t.startTop : t.lastAllowedTop;
@@ -6677,44 +7109,74 @@ var ui = class {
6677
7109
  transform: r
6678
7110
  });
6679
7111
  }
7112
+ _resolveCurrentDragScales({ group: e, state: t }) {
7113
+ let n = Math.abs(e.scaleX ?? t.startScaleX) || t.startScaleX, r = Math.abs(e.scaleY ?? t.startScaleY) || t.startScaleY;
7114
+ return {
7115
+ scaleX: t.canScaleWidth ? n : t.startScaleX,
7116
+ scaleY: t.canScaleHeight ? r : t.startScaleY
7117
+ };
7118
+ }
6680
7119
  _shouldClampWidthToMinimum({ event: e, group: t, minimumWidth: n, state: r }) {
6681
7120
  if (!r) return !1;
6682
7121
  let { transform: i } = e;
6683
7122
  if (!i) return !1;
6684
- let { canScaleWidth: a } = Hr({ transform: i });
7123
+ let { canScaleWidth: a } = qr({ transform: i });
6685
7124
  if (!a || !this._hasPointerReachedScaleOrigin({
6686
7125
  event: e,
6687
7126
  group: t,
7127
+ state: r,
6688
7128
  axis: "x"
6689
7129
  })) return !1;
6690
7130
  let o = Math.max(1 / r.startWidth, n / r.startWidth);
6691
- return r.lastAllowedScaleX > o + Zr;
7131
+ return r.lastAllowedScaleX > o + ni;
6692
7132
  }
6693
7133
  _shouldClampHeightToMinimum({ event: e, group: t, minimumHeight: n, state: r }) {
6694
7134
  if (!r) return !1;
6695
7135
  let { transform: i } = e;
6696
7136
  if (!i) return !1;
6697
- let { canScaleHeight: a } = Hr({ transform: i });
7137
+ let { canScaleHeight: a } = qr({ transform: i });
6698
7138
  if (!a || !this._hasPointerReachedScaleOrigin({
6699
7139
  event: e,
6700
7140
  group: t,
7141
+ state: r,
6701
7142
  axis: "y"
6702
7143
  })) return !1;
6703
7144
  let o = Math.max(1 / r.startHeight, n / r.startHeight);
6704
- return r.lastAllowedScaleY > o + Zr;
7145
+ return r.lastAllowedScaleY > o + ni;
6705
7146
  }
6706
- _hasPointerReachedScaleOrigin({ event: e, group: t, axis: n }) {
6707
- let { transform: r } = e;
6708
- if (!r) return !1;
6709
- let i = r, a = n === "x" ? i.signX : i.signY;
6710
- if (typeof a != "number" || !Number.isFinite(a)) return !1;
6711
- let o = Ur({
7147
+ _hasPointerReachedScaleOrigin({ event: e, group: t, state: n, axis: r }) {
7148
+ let { transform: i } = e;
7149
+ if (!i) return !1;
7150
+ let a = i, o = r === "x" ? n?.scaleDirectionX ?? null : n?.scaleDirectionY ?? null, s = this._resolveScaleDirection({ value: r === "x" ? a.signX : a.signY }) ?? o;
7151
+ if (s === null) return !1;
7152
+ let c = Jr({
6712
7153
  event: e.e,
6713
7154
  target: t,
7155
+ transform: i,
7156
+ canvas: this.canvas
7157
+ });
7158
+ return c ? (r === "x" ? c.x : c.y) * s <= 0 : !1;
7159
+ }
7160
+ _storeScaleDirectionsForCurrentTransform({ group: e, state: t, event: n, transform: r }) {
7161
+ if (!r) return;
7162
+ let { canScaleHeight: i, canScaleWidth: a, isCornerScaleAction: o } = qr({ transform: r });
7163
+ if (!o) return;
7164
+ let s = !a || t.scaleDirectionX !== null, c = !i || t.scaleDirectionY !== null;
7165
+ if (s && c) return;
7166
+ let l = r;
7167
+ a && t.scaleDirectionX === null && (t.scaleDirectionX = this._resolveScaleDirection({ value: l.signX })), i && t.scaleDirectionY === null && (t.scaleDirectionY = this._resolveScaleDirection({ value: l.signY }));
7168
+ let u = !a || t.scaleDirectionX !== null, d = !i || t.scaleDirectionY !== null;
7169
+ if (u && d) return;
7170
+ let f = Jr({
7171
+ event: n,
7172
+ target: e,
6714
7173
  transform: r,
6715
7174
  canvas: this.canvas
6716
7175
  });
6717
- return o ? (n === "x" ? o.x : o.y) * a <= 0 : !1;
7176
+ f && (a && t.scaleDirectionX === null && (t.scaleDirectionX = this._resolveScaleDirection({ value: f.x })), i && t.scaleDirectionY === null && (t.scaleDirectionY = this._resolveScaleDirection({ value: f.y })));
7177
+ }
7178
+ _resolveScaleDirection({ value: e }) {
7179
+ return typeof e != "number" || !Number.isFinite(e) || e === 0 ? null : e > 0 ? 1 : -1;
6718
7180
  }
6719
7181
  clearState({ group: e }) {
6720
7182
  this.scalingState.delete(e);
@@ -6734,27 +7196,38 @@ var ui = class {
6734
7196
  e.setPositionByOrigin(new m(n, r), i, a), e.setCoords();
6735
7197
  }
6736
7198
  _restoreShapeStateWithoutResize({ group: e, shape: t, text: n, state: r, startWidth: i, startHeight: a, alignH: o, alignV: s, userPadding: c }) {
6737
- let l = Math.max(1, e.shapeBaseWidth ?? e.width ?? i), u = Math.max(1, e.shapeBaseHeight ?? e.height ?? a), d = ei({
7199
+ let l = Math.max(1, e.shapeBaseWidth ?? e.width ?? i), u = Math.max(1, e.shapeBaseHeight ?? e.height ?? a), d = ci({
6738
7200
  group: e,
6739
7201
  width: l,
6740
7202
  height: u
7203
+ }), f = o ?? "center", p = s ?? "middle", m = ({ width: t, height: n }) => ci({
7204
+ group: e,
7205
+ width: t,
7206
+ height: n
6741
7207
  });
6742
- dr({
7208
+ !r.canScaleWidth && r.canScaleHeight ? hr({
6743
7209
  group: e,
6744
7210
  shape: t,
6745
7211
  text: n,
6746
7212
  width: l,
6747
7213
  height: u,
6748
- alignH: o ?? "center",
6749
- alignV: s ?? "middle",
7214
+ alignH: f,
7215
+ alignV: p,
6750
7216
  padding: c,
6751
7217
  internalShapeTextInset: d,
6752
- resolveInternalShapeTextInset: ({ width: t, height: n }) => ei({
6753
- group: e,
6754
- width: t,
6755
- height: n
6756
- })
6757
- }), e.shapeReplaceBoxWidth = Math.max(1, e.shapeBaseWidth ?? l), e.shapeReplaceBoxHeight = Math.max(1, e.shapeBaseHeight ?? u), e.set({
7218
+ resolveInternalShapeTextInset: m
7219
+ }) : mr({
7220
+ group: e,
7221
+ shape: t,
7222
+ text: n,
7223
+ width: l,
7224
+ height: u,
7225
+ alignH: f,
7226
+ alignV: p,
7227
+ padding: c,
7228
+ internalShapeTextInset: d,
7229
+ resolveInternalShapeTextInset: m
7230
+ }), e.set({
6758
7231
  left: r.lastAllowedLeft,
6759
7232
  top: r.lastAllowedTop,
6760
7233
  flipX: r.lastAllowedFlipX,
@@ -6766,32 +7239,7 @@ var ui = class {
6766
7239
  state: r
6767
7240
  });
6768
7241
  }
6769
- _restoreGroupTransformOnly({ group: e, shape: t, text: n, state: r }) {
6770
- let i = Math.max(1, e.shapeBaseWidth ?? e.width ?? r.startWidth), a = Math.max(1, e.shapeBaseHeight ?? e.height ?? r.startHeight);
6771
- t && (Pn({
6772
- shape: t,
6773
- width: i,
6774
- height: a,
6775
- rounding: e.shapeRounding,
6776
- strokeWidth: e.shapeStrokeWidth
6777
- }), t.setCoords()), n && (n.set({
6778
- scaleX: 1 / Math.max(Zr, r.startScaleX),
6779
- scaleY: 1 / Math.max(Zr, r.startScaleY)
6780
- }), n.setCoords()), e.set({
6781
- width: i,
6782
- height: a,
6783
- left: r.startLeft,
6784
- top: r.startTop,
6785
- flipX: r.lastAllowedFlipX,
6786
- flipY: r.lastAllowedFlipY,
6787
- scaleX: r.startScaleX,
6788
- scaleY: r.startScaleY
6789
- }), this._restoreScalingAnchorPosition({
6790
- group: e,
6791
- state: r
6792
- });
6793
- }
6794
- }, fi = class {
7242
+ }, Si = class {
6795
7243
  constructor({ canvas: e }) {
6796
7244
  this.handleMouseDown = (e) => {
6797
7245
  let { target: t, e: n, subTargets: r = [] } = e, i = Ue({
@@ -6915,7 +7363,7 @@ var ui = class {
6915
7363
  let t = this.canvas;
6916
7364
  t.findTarget = e.findTarget, this.editingTargetResolverState = void 0;
6917
7365
  }
6918
- }, pi = class e {
7366
+ }, Ci = class e {
6919
7367
  constructor({ canvas: e }) {
6920
7368
  this.canvas = e, this.textEditingSnapshots = /* @__PURE__ */ new WeakMap(), this.pendingTextUpdates = /* @__PURE__ */ new WeakMap(), this.resizeStartSnapshots = /* @__PURE__ */ new Map(), this.pendingResizeUpdates = /* @__PURE__ */ new WeakMap();
6921
7369
  }
@@ -7111,7 +7559,7 @@ var ui = class {
7111
7559
  }
7112
7560
  }), I;
7113
7561
  }
7114
- }, mi = "#B4B7BD", hi = 0, gi = 1, _i = 1e-4, vi = class {
7562
+ }, wi = "#B4B7BD", Ti = 0, Ei = 1, Di = 1e-4, Oi = class {
7115
7563
  constructor({ editor: t }) {
7116
7564
  this._handleObjectScaling = (e) => {
7117
7565
  this._collectShapeGroupsFromTarget({
@@ -7186,7 +7634,7 @@ var ui = class {
7186
7634
  if (!(t instanceof v)) return;
7187
7635
  let n = t;
7188
7636
  this.lifecycleController.finishTextUpdate({ textNode: n });
7189
- }, this.editor = t, He(), this.scalingController = new di({ canvas: t.canvas }), this.editingController = new fi({ canvas: t.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new pi({ canvas: t.canvas }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
7637
+ }, this.editor = t, He(), this.scalingController = new xi({ canvas: t.canvas }), this.editingController = new Si({ canvas: t.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new Ci({ canvas: t.canvas }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
7190
7638
  }
7191
7639
  async add({ presetKey: e = pe, options: t = {} } = {}) {
7192
7640
  let n = ve({ presetKey: e });
@@ -7224,12 +7672,11 @@ var ui = class {
7224
7672
  return this.editor.canvas.fire("editor:shape-added", d), u;
7225
7673
  }
7226
7674
  async _createShapeGroupForAdd({ basePreset: e, options: t }) {
7227
- let { width: n, height: r, preserveAspectRatio: i, shapeTextAutoExpand: a, text: o, textStyle: s, alignH: c, alignV: l, textPadding: u, rounding: d, id: f } = t, p = U({ rounding: d }), m = ve({ presetKey: ye({
7675
+ let { width: n, height: r, preserveAspectRatio: i, shapeTextAutoExpand: a, text: o, textStyle: s, alignH: c, alignV: l, textPadding: u, rounding: d, id: f } = t, p = W({ rounding: d }), m = ve({ presetKey: ye({
7228
7676
  preset: e,
7229
7677
  rounding: p
7230
- }) }) ?? e, h = Ce({ preset: m }), g = h ? p : 0, { width: _, height: v } = m, y = !!i, b = Math.max(1, n ?? _), x = Math.max(1, r ?? v), S, C;
7678
+ }) }) ?? e, h = Ce({ preset: m }), g = h ? p : 0, { width: _, height: v } = m, y = !!i, b = Math.max(1, n ?? _), x = Math.max(1, r ?? v), S = n === void 0 ? void 0 : Math.max(1, n), C = r === void 0 ? void 0 : Math.max(1, r);
7231
7679
  if (y) {
7232
- S = n === void 0 ? void 0 : Math.max(1, n), C = r === void 0 ? void 0 : Math.max(1, r);
7233
7680
  let e = this._resolveAspectRatioFittedDimensions({
7234
7681
  targetWidth: S,
7235
7682
  targetHeight: C,
@@ -7320,55 +7767,55 @@ var ui = class {
7320
7767
  if (!r) return null;
7321
7768
  let i = r.shapePresetKey ?? "circle", a = t ?? i, o = ve({ presetKey: a });
7322
7769
  if (!o) return null;
7323
- let { left: s, top: c, originX: l, originY: u, width: d, height: f, preserveCurrentAspectRatio: p, shapeTextAutoExpand: m, text: h, textStyle: g, alignH: _, alignV: v, textPadding: y, rounding: b, withoutSelection: x, withoutSave: S } = n, C = this.editor.canvasManager.resolveObjectPlacement({
7770
+ let { left: s, top: c, originX: l, originY: u, width: d, height: f, preserveCurrentAspectRatio: p, shapeTextAutoExpand: m, text: h, textStyle: g, alignH: _, alignV: v, textPadding: y, rounding: b, withoutSelection: x, withoutSave: S, syncLineStylesWithText: C = !0 } = n, w = this.editor.canvasManager.resolveObjectPlacement({
7324
7771
  object: r,
7325
7772
  left: s,
7326
7773
  top: c,
7327
7774
  originX: l,
7328
7775
  originY: u
7329
- }), w = this._resolveCurrentDimensions({ group: r }), T = this._resolveManualDimensions({ group: r }), E = this._resolveReplaceBoxDimensions({ group: r }), D = this._isShapeTextAutoExpandEnabled({ group: r }), O = m === void 0 ? D : m !== !1, k = U(b === void 0 ? { rounding: r.shapeRounding } : { rounding: b }), A = ve({ presetKey: ye({
7776
+ }), T = this._resolveCurrentDimensions({ group: r }), E = this._resolveManualDimensions({ group: r }), D = this._resolveReplaceBoxDimensions({ group: r }), O = this._isShapeTextAutoExpandEnabled({ group: r }), k = m === void 0 ? O : m !== !1, A = W(b === void 0 ? { rounding: r.shapeRounding } : { rounding: b }), j = ve({ presetKey: ye({
7330
7777
  preset: o,
7331
- rounding: k
7332
- }) }) ?? o, j = Ce({ preset: A }), M = j ? k : 0, { width: N, height: P } = A, F = !!p, I = t !== void 0 && a !== i, L = I && !F, ee = L ? {
7333
- width: Math.max(1, d ?? E.width),
7334
- height: Math.max(1, f ?? E.height)
7335
- } : null, { width: R, height: te } = ee ? this._resolveAspectRatioFittedDimensions({
7336
- targetWidth: ee.width,
7337
- targetHeight: ee.height,
7338
- aspectWidth: N,
7339
- aspectHeight: P
7778
+ rounding: A
7779
+ }) }) ?? o, M = Ce({ preset: j }), N = M ? A : 0, { width: P, height: F } = j, I = !!p, L = t !== void 0 && a !== i, ee = L && !I, R = ee ? {
7780
+ width: Math.max(1, d ?? D.width),
7781
+ height: Math.max(1, f ?? D.height)
7782
+ } : null, { width: te, height: ne } = R ? this._resolveAspectRatioFittedDimensions({
7783
+ targetWidth: R.width,
7784
+ targetHeight: R.height,
7785
+ aspectWidth: P,
7786
+ aspectHeight: F
7340
7787
  }) : {
7341
- width: Math.max(1, d ?? w.width),
7342
- height: Math.max(1, f ?? w.height)
7343
- }, ne = _ ?? r.shapeAlignHorizontal ?? "center", z = v ?? r.shapeAlignVertical ?? "middle", re = this._resolveGroupUserPadding({ group: r }), B = Ne({ padding: y }), ie = Ae({
7344
- base: re,
7788
+ width: Math.max(1, d ?? T.width),
7789
+ height: Math.max(1, f ?? T.height)
7790
+ }, re = _ ?? r.shapeAlignHorizontal ?? "center", z = v ?? r.shapeAlignVertical ?? "middle", ie = this._resolveGroupUserPadding({ group: r }), B = Ne({ padding: y }), ae = Ae({
7791
+ base: ie,
7345
7792
  override: y
7346
7793
  }), V = this._resolveShapeStyle({
7347
7794
  options: n,
7348
7795
  fallback: r
7349
- }), ae = ({ width: e, height: t }) => Me({
7796
+ }), oe = ({ width: e, height: t }) => Me({
7350
7797
  baseInset: xe({
7351
- preset: A,
7798
+ preset: j,
7352
7799
  width: e,
7353
7800
  height: t
7354
7801
  }),
7355
7802
  stroke: V.stroke,
7356
7803
  strokeWidth: V.strokeWidth
7357
7804
  }), H = je({
7358
- base: ae({
7359
- width: R,
7360
- height: te
7805
+ base: oe({
7806
+ width: te,
7807
+ height: ne
7361
7808
  }),
7362
- addition: ie
7363
- }), oe = T.width, se = T.height;
7364
- I && (oe = R, se = te), !I && d !== void 0 && (oe = Math.max(1, d)), !I && f !== void 0 && (se = Math.max(1, f)), !I && d === void 0 && D && !O && (oe = w.width);
7365
- let { shape: ce, text: W } = Y({ group: r });
7366
- if (!ce || !W) return null;
7367
- let G = this.lifecycleController.createContext({
7809
+ addition: ae
7810
+ }), U = E.width, se = E.height;
7811
+ L && (U = te, se = ne), !L && d !== void 0 && (U = Math.max(1, d)), !L && f !== void 0 && (se = Math.max(1, f)), !L && d === void 0 && O && !k && (U = T.width);
7812
+ let { shape: G, text: K } = Y({ group: r });
7813
+ if (!G || !K) return null;
7814
+ let ce = this.lifecycleController.createContext({
7368
7815
  group: r,
7369
7816
  source: "update",
7370
7817
  target: e,
7371
- presetKey: A.key,
7818
+ presetKey: j.key,
7372
7819
  options: n,
7373
7820
  withoutSave: S
7374
7821
  }), le = {
@@ -7384,91 +7831,94 @@ var ui = class {
7384
7831
  top: 0,
7385
7832
  originX: "left",
7386
7833
  originY: "top"
7387
- }, ue = W, K = this._createTextNode({
7388
- text: ue.textCaseRaw ?? W.text ?? "",
7389
- textStyle: this._resolveCurrentTextStyle({ textNode: W }),
7390
- width: Math.max(1, W.width ?? w.width),
7391
- align: ne
7392
- });
7393
- K.set(le), this._applyTextUpdates({
7394
- textNode: K,
7834
+ }, ue = K, q = this._createTextNode({
7835
+ text: ue.textCaseRaw ?? K.text ?? "",
7836
+ textStyle: this._resolveCurrentTextStyle({ textNode: K }),
7837
+ width: Math.max(1, K.width ?? T.width),
7838
+ align: re
7839
+ });
7840
+ q.set(le), this._applyTextUpdates({
7841
+ textNode: q,
7395
7842
  text: h,
7396
7843
  textStyle: g,
7397
- align: ne
7398
- });
7399
- let q = d === void 0 && f === void 0 && !I && m === void 0 && b === void 0 && h === void 0 && !this._hasShapeTextSizeAffectingStyleChanges({ textStyle: g }), de = y !== void 0 && q, fe = R, pe = te;
7400
- q ? (fe = w.width, pe = w.height) : L || (fe = this._resolveShapeLayoutWidth({
7401
- text: K,
7402
- currentWidth: R,
7403
- manualWidth: oe,
7404
- shapeTextAutoExpandEnabled: O,
7844
+ align: re,
7845
+ syncLineStylesWithText: C
7846
+ });
7847
+ let de = d === void 0 && f === void 0 && !L && m === void 0 && b === void 0 && h === void 0 && !this._hasShapeTextSizeAffectingStyleChanges({ textStyle: g }), fe = y !== void 0 && de, pe = te, me = ne;
7848
+ de ? (pe = T.width, me = T.height) : ee || (pe = this._resolveShapeLayoutWidth({
7849
+ text: q,
7850
+ currentWidth: te,
7851
+ manualWidth: U,
7852
+ shapeTextAutoExpandEnabled: k,
7405
7853
  padding: H,
7406
7854
  resolvePaddingForWidth: ({ width: e }) => je({
7407
- base: ae({
7855
+ base: oe({
7408
7856
  width: e,
7409
- height: te
7857
+ height: ne
7410
7858
  }),
7411
- addition: ie
7859
+ addition: ae
7412
7860
  })
7413
7861
  }));
7414
- let me = ae({
7415
- width: fe,
7416
- height: pe
7417
- }), he = await qn({
7418
- preset: A,
7419
- width: fe,
7420
- height: pe,
7862
+ let he = oe({
7863
+ width: pe,
7864
+ height: me
7865
+ }), ge = await qn({
7866
+ preset: j,
7867
+ width: pe,
7868
+ height: me,
7421
7869
  style: V,
7422
- rounding: M
7423
- }), ge = r.getObjects().indexOf(ce);
7424
- if (ge < 0) return null;
7425
- let _e = () => {
7426
- this._detachShapeGroupAutoLayout({ group: r }), W.set(le), this._applyTextUpdates({
7427
- textNode: W,
7870
+ rounding: N
7871
+ }), _e = r.getObjects().indexOf(G);
7872
+ if (_e < 0) return null;
7873
+ let be = () => {
7874
+ this._detachShapeGroupAutoLayout({ group: r }), K.set(le), this._applyTextUpdates({
7875
+ textNode: K,
7428
7876
  text: h,
7429
7877
  textStyle: g,
7430
- align: ne
7431
- }), r.remove(ce), r.insertAt(ge, he), this._applyShapeGroupMetadata({
7878
+ align: re,
7879
+ syncLineStylesWithText: C
7880
+ }), r.replaceShapeNode(_e, G, ge);
7881
+ let e = R?.width ?? (d === void 0 ? D.width : Math.max(1, d)), t = R?.height ?? (f === void 0 ? D.height : Math.max(1, f));
7882
+ this._applyShapeGroupMetadata({
7432
7883
  group: r,
7433
- presetKey: A.key,
7434
- presetCanRound: j,
7435
- width: fe,
7436
- height: pe,
7437
- manualWidth: oe,
7884
+ presetKey: j.key,
7885
+ presetCanRound: M,
7886
+ width: pe,
7887
+ height: me,
7888
+ manualWidth: U,
7438
7889
  manualHeight: se,
7439
- replaceBoxWidth: ee?.width,
7440
- replaceBoxHeight: ee?.height,
7441
- shapeTextAutoExpand: O,
7442
- alignH: ne,
7890
+ replaceBoxWidth: e,
7891
+ replaceBoxHeight: t,
7892
+ shapeTextAutoExpand: k,
7893
+ alignH: re,
7443
7894
  alignV: z,
7444
- padding: ie,
7895
+ padding: ae,
7445
7896
  style: V,
7446
- rounding: M
7897
+ rounding: N
7447
7898
  }), this._applyCurrentLayout({
7448
7899
  group: r,
7449
- shape: he,
7450
- text: W,
7451
- placement: C,
7452
- width: fe,
7453
- height: pe,
7454
- alignH: ne,
7900
+ shape: ge,
7901
+ text: K,
7902
+ placement: w,
7903
+ width: pe,
7904
+ height: me,
7905
+ alignH: re,
7455
7906
  alignV: z,
7456
- internalShapeTextInset: me,
7457
- resolveInternalShapeTextInset: ae,
7458
- preserveAspectRatio: L,
7459
- minimumReplaceBox: ee ?? void 0,
7460
- expandShapeHeightToFitText: !de,
7907
+ internalShapeTextInset: he,
7908
+ resolveInternalShapeTextInset: oe,
7909
+ preserveAspectRatio: ee,
7910
+ expandShapeHeightToFitText: !fe,
7461
7911
  changedPadding: B
7462
- }), L && (r.shapeManualBaseWidth = Math.max(1, r.shapeBaseWidth ?? fe), r.shapeManualBaseHeight = Math.max(1, r.shapeBaseHeight ?? pe)), W.isEditing && this.editingPlacements.set(r, C);
7912
+ }), ee && (r.shapeManualBaseWidth = Math.max(1, r.shapeBaseWidth ?? pe), r.shapeManualBaseHeight = Math.max(1, r.shapeBaseHeight ?? me)), K.isEditing && this.editingPlacements.set(r, w);
7463
7913
  };
7464
- if (!this._isOnCanvas({ object: r })) return _e(), this.lifecycleController.fireBefore({ lifecycle: G }), this.lifecycleController.fireUpdated({ lifecycle: G }), r;
7914
+ if (!this._isOnCanvas({ object: r })) return be(), this.lifecycleController.fireBefore({ lifecycle: ce }), this.lifecycleController.fireUpdated({ lifecycle: ce }), r;
7465
7915
  this._beginMutation();
7466
7916
  try {
7467
- _e(), !W.isEditing && !x && this.editor.canvas.setActiveObject(r), this.lifecycleController.fireBefore({ lifecycle: G }), this.editor.canvas.requestRenderAll();
7917
+ be(), !K.isEditing && !x && this.editor.canvas.setActiveObject(r), this.lifecycleController.fireBefore({ lifecycle: ce }), this.editor.canvas.requestRenderAll();
7468
7918
  } finally {
7469
7919
  this._endMutation({ withoutSave: S });
7470
7920
  }
7471
- return this.lifecycleController.fireUpdated({ lifecycle: G }), r;
7921
+ return this.lifecycleController.fireUpdated({ lifecycle: ce }), r;
7472
7922
  }
7473
7923
  _resolveAspectRatioFittedDimensions({ targetWidth: e, targetHeight: t, aspectWidth: n, aspectHeight: r }) {
7474
7924
  let i = Math.max(1, n), a = Math.max(1, r), o = e === void 0 ? void 0 : Math.max(1, e), s = t === void 0 ? void 0 : Math.max(1, t);
@@ -7654,7 +8104,7 @@ var ui = class {
7654
8104
  async setRounding({ target: e, rounding: t, withoutSave: n }) {
7655
8105
  let r = this._resolveShapeGroup({ target: e });
7656
8106
  if (!r) return null;
7657
- let i = U({ rounding: t });
8107
+ let i = W({ rounding: t });
7658
8108
  if (r.shapeCanRound === !1) return r;
7659
8109
  let a = r.shapePresetKey ?? "circle";
7660
8110
  return this.update({
@@ -7693,9 +8143,8 @@ var ui = class {
7693
8143
  width: E.width,
7694
8144
  height: E.height,
7695
8145
  alignH: s,
7696
- alignV: c,
7697
- minimumReplaceBox: O
7698
- }), !0;
8146
+ alignV: c
8147
+ }), r.shapeReplaceBoxWidth = O.width, r.shapeReplaceBoxHeight = O.height, !0;
7699
8148
  }
7700
8149
  destroy() {
7701
8150
  let { canvas: e } = this.editor;
@@ -7709,7 +8158,7 @@ var ui = class {
7709
8158
  let r = t.getObjects(), i = r.filter((e) => J(e));
7710
8159
  if (!i.length) return;
7711
8160
  let { scaleX: a, scaleY: o } = this.scalingController.resolveActiveSelectionCommittedScale({ selection: t });
7712
- if (!(Math.abs(a - 1) > _i || Math.abs(o - 1) > _i)) {
8161
+ if (!(Math.abs(a - 1) > Di || Math.abs(o - 1) > Di)) {
7713
8162
  this.scalingController.clearActiveSelectionState({ selection: t });
7714
8163
  return;
7715
8164
  }
@@ -7747,13 +8196,15 @@ var ui = class {
7747
8196
  height: o,
7748
8197
  manualWidth: s,
7749
8198
  manualHeight: c,
8199
+ replaceBoxWidth: l,
8200
+ replaceBoxHeight: u,
7750
8201
  shapeTextAutoExpand: f,
7751
8202
  alignH: p,
7752
8203
  alignV: m,
7753
8204
  padding: h,
7754
8205
  style: y,
7755
8206
  rounding: b
7756
- }), x.rehydrateRuntimeState(), Ke({ group: x }), Fe({ text: i }), dr({
8207
+ }), x.rehydrateRuntimeState(), Ke({ group: x }), Fe({ text: i }), mr({
7757
8208
  group: x,
7758
8209
  shape: r,
7759
8210
  text: i,
@@ -7768,10 +8219,10 @@ var ui = class {
7768
8219
  resolveInternalShapeTextInset: _,
7769
8220
  montageAreaWidth: d ? this._resolveMontageAreaWidth() : void 0,
7770
8221
  changedPadding: v
7771
- }), d && (x.shapeManualBaseWidth = Math.max(1, x.shapeBaseWidth ?? a), x.shapeManualBaseHeight = Math.max(1, x.shapeBaseHeight ?? o)), x.shapeReplaceBoxWidth = Math.max(1, l ?? 0, x.shapeBaseWidth ?? a), x.shapeReplaceBoxHeight = Math.max(1, u ?? 0, x.shapeBaseHeight ?? o), this._detachShapeGroupAutoLayout({ group: x }), x;
8222
+ }), d && (x.shapeManualBaseWidth = Math.max(1, x.shapeBaseWidth ?? a), x.shapeManualBaseHeight = Math.max(1, x.shapeBaseHeight ?? o)), this._detachShapeGroupAutoLayout({ group: x }), x;
7772
8223
  }
7773
8224
  _applyShapeGroupMetadata({ group: e, presetKey: t, presetCanRound: n, width: r, height: i, manualWidth: a, manualHeight: o, replaceBoxWidth: s, replaceBoxHeight: c, shapeTextAutoExpand: l, alignH: u, alignV: d, padding: f, style: p, rounding: m }) {
7774
- let h = p.strokeDashArray ? p.strokeDashArray.slice() : p.strokeDashArray ?? null, g = n ? U({ rounding: m }) : 0;
8225
+ let h = p.strokeDashArray ? p.strokeDashArray.slice() : p.strokeDashArray ?? null, g = n ? W({ rounding: m }) : 0;
7775
8226
  e.set({
7776
8227
  shapeComposite: !0,
7777
8228
  shapePresetKey: t,
@@ -7820,24 +8271,25 @@ var ui = class {
7820
8271
  splitByGrapheme: !1
7821
8272
  }), Fe({ text: s }), s;
7822
8273
  }
7823
- _applyTextUpdates({ textNode: e, text: t, textStyle: n, align: r }) {
7824
- let i = {};
8274
+ _applyTextUpdates({ textNode: e, text: t, textStyle: n, align: r, syncLineStylesWithText: i }) {
8275
+ let a = {};
7825
8276
  if (n) {
7826
8277
  let e = Object.keys(n);
7827
8278
  for (let t = 0; t < e.length; t += 1) {
7828
8279
  let r = e[t];
7829
- i[r] = n[r];
8280
+ a[r] = n[r];
7830
8281
  }
7831
8282
  }
7832
- if (t !== void 0 && (i.text = t), r && (i.align = r), i.autoExpand = !1, i.splitByGrapheme = !1, Object.keys(i).length > 0) {
8283
+ if (t !== void 0 && (a.text = t), r && (a.align = r), a.autoExpand = !1, a.splitByGrapheme = !1, Object.keys(a).length > 0) {
7833
8284
  this.internalTextUpdates.add(e);
7834
8285
  try {
7835
8286
  this.editor.textManager.updateText({
7836
8287
  target: e,
7837
- style: i,
8288
+ style: a,
7838
8289
  skipRender: !0,
7839
8290
  withoutSave: !0,
7840
- emitLifecycleEvents: !1
8291
+ emitLifecycleEvents: !1,
8292
+ syncLineStylesWithText: i
7841
8293
  });
7842
8294
  } finally {
7843
8295
  this.internalTextUpdates.delete(e);
@@ -7928,7 +8380,7 @@ var ui = class {
7928
8380
  }
7929
8381
  _resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r, resolvePaddingForWidth: i }) {
7930
8382
  let a = this._resolveMontageAreaWidth();
7931
- return a ? pr({
8383
+ return a ? _r({
7932
8384
  text: e,
7933
8385
  currentWidth: t,
7934
8386
  minimumWidth: n,
@@ -7950,59 +8402,59 @@ var ui = class {
7950
8402
  let n = t?.align;
7951
8403
  return n === "left" || n === "center" || n === "right" || n === "justify" ? n : e.shapeAlignHorizontal ?? "center";
7952
8404
  }
7953
- _applyCurrentLayout({ group: e, shape: t, text: n, placement: r, width: i, height: a, alignH: o, alignV: s, internalShapeTextInset: c, resolveInternalShapeTextInset: l, preserveAspectRatio: u, minimumReplaceBox: d, expandShapeHeightToFitText: f = !0, changedPadding: p }) {
7954
- let m = this._resolveCurrentDimensions({ group: e }), h = this._resolveManualDimensions({ group: e }), g = this._resolveGroupUserPadding({ group: e }), _ = this._isShapeTextAutoExpandEnabled({ group: e }), v = l ?? (({ width: t, height: n }) => c ?? this._resolveGroupInternalShapeTextInset({
8405
+ _applyCurrentLayout({ group: e, shape: t, text: n, placement: r, width: i, height: a, alignH: o, alignV: s, internalShapeTextInset: c, resolveInternalShapeTextInset: l, preserveAspectRatio: u, expandShapeHeightToFitText: d = !0, changedPadding: f }) {
8406
+ let p = this._resolveCurrentDimensions({ group: e }), m = this._resolveManualDimensions({ group: e }), h = this._resolveGroupUserPadding({ group: e }), g = this._isShapeTextAutoExpandEnabled({ group: e }), _ = l ?? (({ width: t, height: n }) => c ?? this._resolveGroupInternalShapeTextInset({
7955
8407
  group: e,
7956
8408
  width: t,
7957
8409
  height: n
7958
- })), y = m.width;
7959
- if (i !== void 0) y = Math.max(1, i);
8410
+ })), v = p.width;
8411
+ if (i !== void 0) v = Math.max(1, i);
7960
8412
  else {
7961
- let e = Math.max(1, a ?? m.height);
7962
- y = this._resolveShapeLayoutWidth({
8413
+ let e = Math.max(1, a ?? p.height);
8414
+ v = this._resolveShapeLayoutWidth({
7963
8415
  text: n,
7964
- currentWidth: m.width,
7965
- manualWidth: h.width,
7966
- shapeTextAutoExpandEnabled: _,
8416
+ currentWidth: p.width,
8417
+ manualWidth: m.width,
8418
+ shapeTextAutoExpandEnabled: g,
7967
8419
  padding: je({
7968
- base: v({
7969
- width: y,
8420
+ base: _({
8421
+ width: v,
7970
8422
  height: e
7971
8423
  }),
7972
- addition: g
8424
+ addition: h
7973
8425
  }),
7974
8426
  resolvePaddingForWidth: ({ width: t }) => je({
7975
- base: v({
8427
+ base: _({
7976
8428
  width: t,
7977
8429
  height: e
7978
8430
  }),
7979
- addition: g
8431
+ addition: h
7980
8432
  })
7981
8433
  });
7982
8434
  }
7983
- let b = Math.max(1, a ?? m.height), x = v({
7984
- width: y,
7985
- height: b
7986
- }), S = r ?? this.editor.canvasManager.getObjectPlacement({ object: e }), C = u ? this._resolveMontageAreaWidth() : void 0;
7987
- dr({
8435
+ let y = Math.max(1, a ?? p.height), b = _({
8436
+ width: v,
8437
+ height: y
8438
+ }), x = r ?? this.editor.canvasManager.getObjectPlacement({ object: e }), S = u ? this._resolveMontageAreaWidth() : void 0;
8439
+ mr({
7988
8440
  group: e,
7989
8441
  shape: t,
7990
8442
  text: n,
7991
- width: y,
7992
- height: b,
8443
+ width: v,
8444
+ height: y,
7993
8445
  alignH: o ?? e.shapeAlignHorizontal ?? "center",
7994
8446
  alignV: s ?? e.shapeAlignVertical ?? "middle",
7995
- padding: g,
7996
- shapeTextAutoExpandEnabled: _,
7997
- internalShapeTextInset: x,
7998
- resolveInternalShapeTextInset: v,
8447
+ padding: h,
8448
+ shapeTextAutoExpandEnabled: g,
8449
+ internalShapeTextInset: b,
8450
+ resolveInternalShapeTextInset: _,
7999
8451
  preserveAspectRatio: u,
8000
- montageAreaWidth: C,
8001
- expandShapeHeightToFitText: f,
8002
- changedPadding: p
8003
- }), e.shapeReplaceBoxWidth = Math.max(1, d?.width ?? 0, e.shapeBaseWidth ?? y), e.shapeReplaceBoxHeight = Math.max(1, d?.height ?? 0, e.shapeBaseHeight ?? b), this.editor.canvasManager.applyObjectPlacement({
8452
+ montageAreaWidth: S,
8453
+ expandShapeHeightToFitText: d,
8454
+ changedPadding: f
8455
+ }), this.editor.canvasManager.applyObjectPlacement({
8004
8456
  object: e,
8005
- placement: S
8457
+ placement: x
8006
8458
  });
8007
8459
  }
8008
8460
  _syncShapeTextLayoutAfterTextMutation({ textNode: e, textStyle: t }) {
@@ -8047,11 +8499,11 @@ var ui = class {
8047
8499
  _resolveShapeStyle({ options: e, fallback: t }) {
8048
8500
  let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
8049
8501
  return {
8050
- fill: n ?? t?.shapeFill ?? mi,
8502
+ fill: n ?? t?.shapeFill ?? wi,
8051
8503
  stroke: r ?? t?.shapeStroke ?? null,
8052
- strokeWidth: i ?? t?.shapeStrokeWidth ?? hi,
8504
+ strokeWidth: i ?? t?.shapeStrokeWidth ?? Ti,
8053
8505
  strokeDashArray: s ?? null,
8054
- opacity: o ?? t?.shapeOpacity ?? gi
8506
+ opacity: o ?? t?.shapeOpacity ?? Ei
8055
8507
  };
8056
8508
  }
8057
8509
  _collectShapeGroupsFromTarget({ target: t, subTargets: n = [] }) {
@@ -8107,7 +8559,7 @@ var ui = class {
8107
8559
  }
8108
8560
  return null;
8109
8561
  }
8110
- }, yi = class {
8562
+ }, ki = class {
8111
8563
  constructor({ editor: e }) {
8112
8564
  this.editor = e, this.clipboard = null;
8113
8565
  }
@@ -8357,7 +8809,7 @@ var ui = class {
8357
8809
  }), !1;
8358
8810
  }
8359
8811
  }
8360
- }, bi = class t {
8812
+ }, Ai = class t {
8361
8813
  constructor({ editor: e }) {
8362
8814
  this.editor = e;
8363
8815
  }
@@ -8422,7 +8874,7 @@ var ui = class {
8422
8874
  !(n instanceof v) || !n.isEditing || n.exitEditing();
8423
8875
  }
8424
8876
  }
8425
- }, xi = class {
8877
+ }, ji = class {
8426
8878
  constructor({ editor: e }) {
8427
8879
  this.editor = e;
8428
8880
  }
@@ -8488,7 +8940,7 @@ var ui = class {
8488
8940
  i.resumeHistory(), n || i.saveState();
8489
8941
  }
8490
8942
  }
8491
- }, Si = class t {
8943
+ }, Mi = class t {
8492
8944
  constructor({ editor: e }) {
8493
8945
  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();
8494
8946
  }
@@ -8682,7 +9134,7 @@ var ui = class {
8682
9134
  let { options: e } = this.editor, { selectionKey: t } = e;
8683
9135
  return t === void 0 ? ["ctrlKey", "metaKey"] : t;
8684
9136
  }
8685
- }, Ci = class e {
9137
+ }, Ni = class e {
8686
9138
  constructor({ editor: e }) {
8687
9139
  this.editor = e;
8688
9140
  }
@@ -8722,7 +9174,7 @@ var ui = class {
8722
9174
  };
8723
9175
  return i.fire("editor:objects-deleted", l), l;
8724
9176
  }
8725
- }, wi = {
9177
+ }, Pi = {
8726
9178
  IMAGE_MANAGER: {
8727
9179
  INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
8728
9180
  INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
@@ -8760,7 +9212,7 @@ var ui = class {
8760
9212
  INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
8761
9213
  APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
8762
9214
  }
8763
- }, Ti = class e {
9215
+ }, Fi = class e {
8764
9216
  constructor({ editor: e }) {
8765
9217
  this._buffer = [], this.editor = e;
8766
9218
  }
@@ -8818,9 +9270,9 @@ var ui = class {
8818
9270
  }), this.editor.canvas.fire("editor:warning", s);
8819
9271
  }
8820
9272
  static isValidErrorCode(e) {
8821
- return e ? Object.values(wi).some((t) => Object.values(t).includes(e)) : !1;
9273
+ return e ? Object.values(Pi).some((t) => Object.values(t).includes(e)) : !1;
8822
9274
  }
8823
- }, Ei = class {
9275
+ }, Ii = class {
8824
9276
  constructor({ editor: e }) {
8825
9277
  this.currentBounds = null, this.editor = e;
8826
9278
  }
@@ -8869,32 +9321,32 @@ var ui = class {
8869
9321
  updateBounds() {
8870
9322
  this.currentBounds = this.calculatePanBounds();
8871
9323
  }
8872
- }, Di = ({ textbox: e }) => {
9324
+ }, Li = ({ textbox: e }) => {
8873
9325
  if (!e.isEditing) return null;
8874
9326
  let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
8875
9327
  return t === n ? null : {
8876
9328
  start: Math.min(t, n),
8877
9329
  end: Math.max(t, n)
8878
9330
  };
8879
- }, Oi = ({ textbox: e }) => {
9331
+ }, Ri = ({ textbox: e }) => {
8880
9332
  let t = e.text?.length ?? 0;
8881
9333
  return t <= 0 ? null : {
8882
9334
  start: 0,
8883
9335
  end: t
8884
9336
  };
8885
- }, ki = ({ textbox: e, range: t }) => {
9337
+ }, zi = ({ textbox: e, range: t }) => {
8886
9338
  if (!t) return !1;
8887
9339
  let n = e.text?.length ?? 0;
8888
9340
  return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
8889
- }, Ai = ({ textbox: e, styles: t, range: n }) => {
9341
+ }, Bi = ({ textbox: e, styles: t, range: n }) => {
8890
9342
  if (!t || !Object.keys(t).length) return !1;
8891
9343
  let { start: r, end: i } = n;
8892
9344
  return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
8893
- }, ji = ({ textbox: e, range: t, property: n }) => {
9345
+ }, Vi = ({ textbox: e, range: t, property: n }) => {
8894
9346
  if (!t) return;
8895
9347
  let r = e.getSelectionStyles(t.start, t.end, !0);
8896
9348
  if (r.length) return r[0]?.[n];
8897
- }, Mi = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", Ni = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Pi = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Fi = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), Ii = class e extends v {
9349
+ }, Hi = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", Ui = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Wi = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Gi = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), Ki = class e extends v {
8898
9350
  static {
8899
9351
  this.type = "background-textbox";
8900
9352
  }
@@ -9038,7 +9490,7 @@ var ui = class {
9038
9490
  this._removeShadow(e);
9039
9491
  }
9040
9492
  _getDecorationColorAt(e, t) {
9041
- let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Ni({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Mi({
9493
+ let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Ui({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Hi({
9042
9494
  strokeColor: i,
9043
9495
  width: r
9044
9496
  });
@@ -9054,22 +9506,22 @@ var ui = class {
9054
9506
  _getCornerRadii({ width: e, height: t }) {
9055
9507
  let n = e / 2, r = t / 2, i = Math.min(n, r);
9056
9508
  return {
9057
- bottomLeft: Fi({
9509
+ bottomLeft: Gi({
9058
9510
  value: this.radiusBottomLeft ?? 0,
9059
9511
  min: 0,
9060
9512
  max: i
9061
9513
  }),
9062
- bottomRight: Fi({
9514
+ bottomRight: Gi({
9063
9515
  value: this.radiusBottomRight ?? 0,
9064
9516
  min: 0,
9065
9517
  max: i
9066
9518
  }),
9067
- topLeft: Fi({
9519
+ topLeft: Gi({
9068
9520
  value: this.radiusTopLeft ?? 0,
9069
9521
  min: 0,
9070
9522
  max: i
9071
9523
  }),
9072
- topRight: Fi({
9524
+ topRight: Gi({
9073
9525
  value: this.radiusTopRight ?? 0,
9074
9526
  min: 0,
9075
9527
  max: i
@@ -9087,7 +9539,7 @@ var ui = class {
9087
9539
  _getEffectiveBackgroundFill() {
9088
9540
  let e = this.backgroundColor;
9089
9541
  if (!e) return null;
9090
- let t = Fi({
9542
+ let t = Gi({
9091
9543
  value: this.backgroundOpacity ?? 1,
9092
9544
  min: 0,
9093
9545
  max: 1
@@ -9100,19 +9552,19 @@ var ui = class {
9100
9552
  return r.setAlpha(t), r.toRgba();
9101
9553
  }
9102
9554
  static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
9103
- let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Fi({
9555
+ let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Gi({
9104
9556
  value: c,
9105
9557
  min: 0,
9106
9558
  max: a
9107
- }), p = Fi({
9559
+ }), p = Gi({
9108
9560
  value: l,
9109
9561
  min: 0,
9110
9562
  max: a
9111
- }), m = Fi({
9563
+ }), m = Gi({
9112
9564
  value: u,
9113
9565
  min: 0,
9114
9566
  max: a
9115
- }), h = Fi({
9567
+ }), h = Gi({
9116
9568
  value: d,
9117
9569
  min: 0,
9118
9570
  max: a
@@ -9123,20 +9575,20 @@ var ui = class {
9123
9575
  let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
9124
9576
  n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
9125
9577
  }
9126
- }, Li = () => {
9127
- b?.setClass && b.setClass(Ii, "background-textbox");
9128
- }, Ri = ({ transform: e }) => {
9578
+ }, qi = () => {
9579
+ b?.setClass && b.setClass(Ki, "background-textbox");
9580
+ }, Ji = ({ transform: e }) => {
9129
9581
  let { corner: t = "", action: n = "" } = e;
9130
9582
  return {
9131
9583
  isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
9132
9584
  isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
9133
9585
  isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
9134
9586
  };
9135
- }, zi = ({ textbox: e, transform: t, appliedWidth: n }) => {
9587
+ }, Yi = ({ textbox: e, transform: t, appliedWidth: n }) => {
9136
9588
  t.scaleX = 1, t.scaleY = 1;
9137
9589
  let r = t.original;
9138
9590
  r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
9139
- }, Bi = ({ textbox: e, transform: t, scenePoint: n }) => {
9591
+ }, Xi = ({ textbox: e, transform: t, scenePoint: n }) => {
9140
9592
  let { x: r, y: i } = e._getTransformedDimensions();
9141
9593
  if (r <= 0 || i <= 0) return null;
9142
9594
  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);
@@ -9146,27 +9598,27 @@ var ui = class {
9146
9598
  stepScaleX: l,
9147
9599
  stepScaleY: u
9148
9600
  };
9149
- }, Vi = 1e-4;
9150
- function Hi(e) {
9601
+ }, Zi = 1e-4;
9602
+ function Qi(e) {
9151
9603
  return !!e && e instanceof v;
9152
9604
  }
9153
- function Ui(e) {
9154
- if (!Hi(e)) return !1;
9605
+ function $i(e) {
9606
+ if (!Qi(e)) return !1;
9155
9607
  let t = e.group;
9156
9608
  return e.shapeNodeType === "text" && t?.shapeComposite === !0;
9157
9609
  }
9158
- var Wi = class {
9610
+ var ea = class {
9159
9611
  constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
9160
9612
  this.handleMouseMove = (e) => {
9161
9613
  let t = this.canvas._currentTransform;
9162
9614
  if (!t) return;
9163
9615
  let { target: n } = t;
9164
- if (!Hi(n) || Ui(n)) return;
9616
+ if (!Qi(n) || $i(n)) return;
9165
9617
  let r = this.scalingState.get(n);
9166
9618
  if (!r || !e.e) return;
9167
- let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = Ri({ transform: t });
9619
+ let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = Ji({ transform: t });
9168
9620
  if (!a && !o && !i) return;
9169
- let s = Bi({
9621
+ let s = Xi({
9170
9622
  textbox: n,
9171
9623
  transform: t,
9172
9624
  scenePoint: this.canvas.getScenePoint(e.e)
@@ -9189,18 +9641,18 @@ var Wi = class {
9189
9641
  }, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
9190
9642
  if (i) {
9191
9643
  let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
9192
- if (Math.abs(t - r.lastAllowedScaleX) <= Vi) return;
9644
+ if (Math.abs(t - r.lastAllowedScaleX) <= Zi) return;
9193
9645
  j = t, M = t;
9194
9646
  } else {
9195
9647
  if (a) {
9196
9648
  let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
9197
- Math.abs(t - r.lastAllowedScaleX) > Vi && (j = t);
9649
+ Math.abs(t - r.lastAllowedScaleX) > Zi && (j = t);
9198
9650
  }
9199
9651
  if (o) {
9200
9652
  let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
9201
- Math.abs(t - r.lastAllowedScaleY) > Vi && (M = t);
9653
+ Math.abs(t - r.lastAllowedScaleY) > Zi && (M = t);
9202
9654
  }
9203
- if (Math.abs(j - r.lastAllowedScaleX) <= Vi && Math.abs(M - r.lastAllowedScaleY) <= Vi) return;
9655
+ if (Math.abs(j - r.lastAllowedScaleX) <= Zi && Math.abs(M - r.lastAllowedScaleY) <= Zi) return;
9204
9656
  }
9205
9657
  let { appliedWidth: N, dimensionsRounded: P } = kn({
9206
9658
  textbox: n,
@@ -9216,7 +9668,7 @@ var Wi = class {
9216
9668
  shouldDisableAutoExpandOnHorizontalChange: a,
9217
9669
  shouldRoundDimensions: !i
9218
9670
  });
9219
- zi({
9671
+ Yi({
9220
9672
  textbox: n,
9221
9673
  transform: t,
9222
9674
  appliedWidth: N
@@ -9237,12 +9689,12 @@ var Wi = class {
9237
9689
  }), this.canvas.requestRenderAll();
9238
9690
  }, this.handleObjectScaling = (t) => {
9239
9691
  let { target: n, transform: r } = t;
9240
- if (n instanceof e || !Hi(n) || Ui(n) || !r) return;
9692
+ if (n instanceof e || !Qi(n) || $i(n) || !r) return;
9241
9693
  n.isScaling = !0;
9242
9694
  let i = this._ensureScalingState({
9243
9695
  textbox: n,
9244
9696
  transform: r
9245
- }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = Ri({ transform: r }), d = r.corner ?? "", f = c || u;
9697
+ }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = Ji({ transform: r }), d = r.corner ?? "", f = c || u;
9246
9698
  if (!l && !u && !c) return;
9247
9699
  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({
9248
9700
  object: n,
@@ -9271,7 +9723,7 @@ var Wi = class {
9271
9723
  shouldDisableAutoExpandOnHorizontalChange: l,
9272
9724
  shouldRoundDimensions: !c
9273
9725
  });
9274
- zi({
9726
+ Yi({
9275
9727
  textbox: n,
9276
9728
  transform: r,
9277
9729
  appliedWidth: L
@@ -9304,7 +9756,7 @@ var Wi = class {
9304
9756
  let { target: n } = t;
9305
9757
  if (n instanceof e) {
9306
9758
  let t = n.getObjects();
9307
- if (!t.some((e) => Hi(e))) return;
9759
+ if (!t.some((e) => Qi(e))) return;
9308
9760
  let { scaleX: r = 1, scaleY: i = 1 } = n;
9309
9761
  if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
9310
9762
  this.canvas.discardActiveObject(), t.forEach((e) => {
@@ -9314,7 +9766,7 @@ var Wi = class {
9314
9766
  this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
9315
9767
  return;
9316
9768
  }
9317
- if (!Hi(n) || Ui(n)) return;
9769
+ if (!Qi(n) || $i(n)) return;
9318
9770
  n.isScaling = !1;
9319
9771
  let r = this.scalingState.get(n);
9320
9772
  if (this.scalingState.delete(n), !r?.hasScalingChange) return;
@@ -9339,7 +9791,7 @@ var Wi = class {
9339
9791
  }, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
9340
9792
  }
9341
9793
  commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
9342
- if (!Hi(e) || Ui(e)) return !1;
9794
+ if (!Qi(e) || $i(e)) return !1;
9343
9795
  let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
9344
9796
  if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
9345
9797
  let i = En({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
@@ -9413,7 +9865,7 @@ var Wi = class {
9413
9865
  originY: a
9414
9866
  });
9415
9867
  }
9416
- }, Gi = class e {
9868
+ }, ta = class e {
9417
9869
  constructor({ editor: t }) {
9418
9870
  this._handleTextEditingEntered = (t) => {
9419
9871
  this.isTextEditingActive = !0;
@@ -9426,18 +9878,18 @@ var Wi = class {
9426
9878
  if (!e._isTextbox(n)) return;
9427
9879
  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 });
9428
9880
  if (s) {
9429
- let e = Pi({ value: l });
9881
+ let e = Wi({ value: l });
9430
9882
  e !== i && n.set({ text: e }), n.textCaseRaw = l;
9431
9883
  } else n.textCaseRaw = i;
9432
9884
  if (!r && o === void 0 && (n.autoExpand = !0), r) {
9433
- this._syncLineFontDefaultsOnTextChanged({ textbox: n });
9885
+ this._syncLineStylesWithText({ textbox: n });
9434
9886
  return;
9435
9887
  }
9436
9888
  this._normalizeTextboxAfterContentChange({
9437
9889
  textbox: n,
9438
9890
  placement: u,
9439
9891
  shouldAutoExpand: c
9440
- }), this._syncLineFontDefaultsOnTextChanged({ textbox: n });
9892
+ }), this._syncLineStylesWithText({ textbox: n });
9441
9893
  }, this._handleTextEditingExited = (t) => {
9442
9894
  let { target: n } = t;
9443
9895
  if (!e._isTextbox(n)) return;
@@ -9471,7 +9923,7 @@ var Wi = class {
9471
9923
  transform: r,
9472
9924
  event: i ?? null
9473
9925
  });
9474
- }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new Wi({
9926
+ }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new ea({
9475
9927
  canvas: t.canvas,
9476
9928
  canvasManager: t.canvasManager,
9477
9929
  persistScaledTextbox: ({ target: e, style: t }) => {
@@ -9480,12 +9932,12 @@ var Wi = class {
9480
9932
  style: t
9481
9933
  });
9482
9934
  }
9483
- }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), Li();
9935
+ }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), qi();
9484
9936
  }
9485
9937
  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 } = {}) {
9486
9938
  let { canvasManager: M, historyManager: N } = this.editor, { canvas: P } = this;
9487
9939
  N.suspendHistory();
9488
- let F = i ?? this._getDefaultFontFamily(), I = Ni({ width: m }), L = Mi({
9940
+ let F = i ?? this._getDefaultFontFamily(), I = Ui({ width: m }), L = Hi({
9489
9941
  strokeColor: p,
9490
9942
  width: I
9491
9943
  }), ee = {
@@ -9514,16 +9966,16 @@ var Wi = class {
9514
9966
  radiusBottomRight: w,
9515
9967
  radiusBottomLeft: T,
9516
9968
  ...E
9517
- }, R = new Ii(n, ee), te = r !== !1;
9969
+ }, R = new Ki(n, ee), te = r !== !1;
9518
9970
  R.autoExpand = te;
9519
9971
  let ne = E.left !== void 0 || E.top !== void 0;
9520
9972
  if (R.textCaseRaw = R.text ?? "", l) {
9521
- let e = Pi({ value: R.textCaseRaw });
9973
+ let e = Wi({ value: R.textCaseRaw });
9522
9974
  e !== R.text && R.set({ text: e });
9523
9975
  }
9524
9976
  Tn({ textbox: R }) && (R.dirty = !0);
9525
- let z;
9526
- ne && (z = M.resolveObjectPlacement({
9977
+ let re;
9978
+ ne && (re = M.resolveObjectPlacement({
9527
9979
  object: R,
9528
9980
  left: E.left,
9529
9981
  top: E.top,
@@ -9531,13 +9983,13 @@ var Wi = class {
9531
9983
  originY: E.originY,
9532
9984
  fallbackPoint: M.getMontageAreaSceneCenter()
9533
9985
  }));
9534
- let re = te && e._hasWrappedLinesBeyondExplicitBreaks(R);
9535
- return (ne || re) && this._normalizeTextboxAfterContentChange({
9986
+ let z = te && e._hasWrappedLinesBeyondExplicitBreaks(R);
9987
+ return (ne || z) && this._normalizeTextboxAfterContentChange({
9536
9988
  textbox: R,
9537
- placement: z,
9538
- shouldAutoExpand: re,
9989
+ placement: re,
9990
+ shouldAutoExpand: z,
9539
9991
  clampToMontage: ne
9540
- }), z || M.centerObjectToMontageArea({ object: R }), A || P.add(R), D || P.setActiveObject(R), P.requestRenderAll(), N.resumeHistory(), k || N.saveState(), j && P.fire("editor:text-added", {
9992
+ }), re || M.centerObjectToMontageArea({ object: R }), A || P.add(R), D || P.setActiveObject(R), P.requestRenderAll(), N.resumeHistory(), k || N.saveState(), j && P.fire("editor:text-added", {
9541
9993
  textbox: R,
9542
9994
  options: {
9543
9995
  ...ee,
@@ -9557,157 +10009,163 @@ var Wi = class {
9557
10009
  }
9558
10010
  }), R;
9559
10011
  }
9560
- updateText({ target: t, style: n = {}, withoutSave: r, skipRender: i, selectionRange: a, emitLifecycleEvents: o = !0 } = {}) {
9561
- let s = this._resolveTextObject(t);
9562
- if (!s) return null;
9563
- let { text: c = "" } = s, { historyManager: l } = this.editor, { canvasManager: u } = this.editor, { canvas: d } = this;
9564
- l.suspendHistory();
9565
- let f = e._getSnapshot(s), { text: p, autoExpand: m, fontFamily: h, fontSize: g, bold: _, italic: v, underline: y, uppercase: b, strikethrough: x, align: S, color: C, strokeColor: w, strokeWidth: T, opacity: E, backgroundColor: D, backgroundOpacity: O, paddingTop: k, paddingRight: A, paddingBottom: j, paddingLeft: M, radiusTopLeft: N, radiusTopRight: P, radiusBottomRight: F, radiusBottomLeft: I, left: L, top: ee, originX: R, originY: te, ...ne } = n, z = { ...ne }, re = u.resolveObjectPlacement({
9566
- object: s,
9567
- left: L,
9568
- top: ee,
9569
- originX: R,
9570
- originY: te
9571
- }), B = a === void 0 ? Di({ textbox: s }) : Yt({
9572
- text: c,
10012
+ updateText({ target: t, style: n = {}, withoutSave: r, skipRender: i, selectionRange: a, emitLifecycleEvents: o = !0, syncLineStylesWithText: s = !0 } = {}) {
10013
+ let c = this._resolveTextObject(t);
10014
+ if (!c) return null;
10015
+ let { text: l = "" } = c, { historyManager: u } = this.editor, { canvasManager: d } = this.editor, { canvas: f } = this;
10016
+ u.suspendHistory();
10017
+ let p = e._getSnapshot(c), { text: m, autoExpand: h, fontFamily: g, fontSize: _, bold: v, italic: y, underline: b, uppercase: x, strikethrough: S, align: C, color: w, strokeColor: T, strokeWidth: E, opacity: D, backgroundColor: O, backgroundOpacity: k, paddingTop: A, paddingRight: j, paddingBottom: M, paddingLeft: N, radiusTopLeft: P, radiusTopRight: F, radiusBottomRight: I, radiusBottomLeft: L, left: ee, top: R, originX: te, originY: ne, ...re } = n, z = { ...re }, ie = d.resolveObjectPlacement({
10018
+ object: c,
10019
+ left: ee,
10020
+ top: R,
10021
+ originX: te,
10022
+ originY: ne
10023
+ }), B = a === void 0 ? Li({ textbox: c }) : Yt({
10024
+ text: l,
9573
10025
  range: a
9574
- }), ie = B ? Xt({
9575
- textbox: s,
10026
+ }), ae = B ? Xt({
10027
+ textbox: c,
9576
10028
  range: B
9577
- }) : null, V = {}, ae = {}, H = {}, oe, se, ce, U, W = ki({
9578
- textbox: s,
10029
+ }) : null, V = {}, oe = {}, H = {}, U, se, W, G, K = zi({
10030
+ textbox: c,
9579
10031
  range: B
9580
- }), G = ki({
9581
- textbox: s,
9582
- range: ie
9583
- }), le = !B || W, ue = le || G, K = !B;
9584
- if (h !== void 0 && (ie && (ae.fontFamily = h), ue && (z.fontFamily = h, K && (H.fontFamily = h))), g !== void 0 && (ie && (ae.fontSize = g), ue && (z.fontSize = g, K && (H.fontSize = g))), _ !== void 0 && (oe = _ ? "bold" : "normal", B && (V.fontWeight = oe), le && (z.fontWeight = oe, K && (H.fontWeight = oe))), v !== void 0 && (se = v ? "italic" : "normal", B && (V.fontStyle = se), le && (z.fontStyle = se, K && (H.fontStyle = se))), y !== void 0 && (B && (V.underline = y), le && (z.underline = y, K && (H.underline = y))), x !== void 0 && (B && (V.linethrough = x), le && (z.linethrough = x, K && (H.linethrough = x))), S !== void 0 && (z.textAlign = S), C !== void 0 && (B && (V.fill = C), le && (z.fill = C, K && (H.fill = C))), w !== void 0 || T !== void 0) {
9585
- let e = B ? ji({
9586
- textbox: s,
10032
+ }), ce = zi({
10033
+ textbox: c,
10034
+ range: ae
10035
+ }), le = !B || K, ue = le || ce, q = !B;
10036
+ if (g !== void 0 && (ae && (oe.fontFamily = g), ue && (z.fontFamily = g, q && (H.fontFamily = g))), _ !== void 0 && (ae && (oe.fontSize = _), ue && (z.fontSize = _, q && (H.fontSize = _))), v !== void 0 && (U = v ? "bold" : "normal", B && (V.fontWeight = U), le && (z.fontWeight = U, q && (H.fontWeight = U))), y !== void 0 && (se = y ? "italic" : "normal", B && (V.fontStyle = se), le && (z.fontStyle = se, q && (H.fontStyle = se))), b !== void 0 && (B && (V.underline = b), le && (z.underline = b, q && (H.underline = b))), S !== void 0 && (B && (V.linethrough = S), le && (z.linethrough = S, q && (H.linethrough = S))), C !== void 0 && (z.textAlign = C), w !== void 0 && (B && (V.fill = w), le && (z.fill = w, q && (H.fill = w))), T !== void 0 || E !== void 0) {
10037
+ let e = B ? Vi({
10038
+ textbox: c,
9587
10039
  range: B,
9588
10040
  property: "strokeWidth"
9589
- }) : void 0, t = B ? ji({
9590
- textbox: s,
10041
+ }) : void 0, t = B ? Vi({
10042
+ textbox: c,
9591
10043
  range: B,
9592
10044
  property: "stroke"
9593
- }) : void 0, n = typeof e == "number" ? e : void 0, r = typeof t == "string" ? t : void 0, i = typeof s.stroke == "string" ? s.stroke : void 0;
9594
- U = Ni({ width: T ?? n ?? s.strokeWidth ?? 0 }), ce = Mi({
9595
- strokeColor: w ?? r ?? i,
9596
- width: U
9597
- }), B && (V.stroke = ce, V.strokeWidth = U), le && (z.stroke = ce, z.strokeWidth = U, K && (H.stroke = ce, H.strokeWidth = U));
9598
- }
9599
- E !== void 0 && (z.opacity = E), D !== void 0 && (z.backgroundColor = D), O !== void 0 && (z.backgroundOpacity = O), k !== void 0 && (z.paddingTop = k), A !== void 0 && (z.paddingRight = A), j !== void 0 && (z.paddingBottom = j), M !== void 0 && (z.paddingLeft = M), N !== void 0 && (z.radiusTopLeft = N), P !== void 0 && (z.radiusTopRight = P), F !== void 0 && (z.radiusBottomRight = F), I !== void 0 && (z.radiusBottomLeft = I);
9600
- let q = s.textCaseRaw ?? c, de = !!s.uppercase, fe = p !== void 0, pe = fe ? p ?? "" : q, me = b ?? de, he = me !== de;
9601
- fe || he ? (z.text = me ? Pi({ value: pe }) : pe, s.textCaseRaw = pe) : s.textCaseRaw === void 0 && (s.textCaseRaw = q);
9602
- let ge = wn({ stylesList: [
10045
+ }) : void 0, n = typeof e == "number" ? e : void 0, r = typeof t == "string" ? t : void 0, i = typeof c.stroke == "string" ? c.stroke : void 0;
10046
+ G = Ui({ width: E ?? n ?? c.strokeWidth ?? 0 }), W = Hi({
10047
+ strokeColor: T ?? r ?? i,
10048
+ width: G
10049
+ }), B && (V.stroke = W, V.strokeWidth = G), le && (z.stroke = W, z.strokeWidth = G, q && (H.stroke = W, H.strokeWidth = G));
10050
+ }
10051
+ D !== void 0 && (z.opacity = D), O !== void 0 && (z.backgroundColor = O), k !== void 0 && (z.backgroundOpacity = k), A !== void 0 && (z.paddingTop = A), j !== void 0 && (z.paddingRight = j), M !== void 0 && (z.paddingBottom = M), N !== void 0 && (z.paddingLeft = N), P !== void 0 && (z.radiusTopLeft = P), F !== void 0 && (z.radiusTopRight = F), I !== void 0 && (z.radiusBottomRight = I), L !== void 0 && (z.radiusBottomLeft = L);
10052
+ let de = c.textCaseRaw ?? l, fe = !!c.uppercase, pe = m !== void 0, me = pe ? m ?? "" : de, he = x ?? fe, ge = he !== fe, _e = c.text ?? "";
10053
+ pe || ge ? (z.text = he ? Wi({ value: me }) : me, c.textCaseRaw = me) : c.textCaseRaw === void 0 && (c.textCaseRaw = de);
10054
+ let ve = wn({ stylesList: [
9603
10055
  z,
9604
10056
  V,
9605
- ae,
10057
+ oe,
9606
10058
  H
9607
- ] }), _e = [
9608
- L,
10059
+ ] }), ye = [
9609
10060
  ee,
9610
10061
  R,
9611
- te
9612
- ], ve = [
9613
- k,
10062
+ te,
10063
+ ne
10064
+ ], be = [
9614
10065
  A,
9615
10066
  j,
9616
- M
9617
- ], ye = _e.some((e) => e !== void 0), be = ve.some((e) => e !== void 0), xe = Object.prototype.hasOwnProperty.call(z, "width"), Se = be && !ye && !fe && !he && !ge && !xe, Ce = null;
9618
- Se && (Ce = xn({
9619
- textbox: s,
9620
- originX: re.originX,
9621
- originY: re.originY
9622
- })), s.uppercase = me, s.set(z);
9623
- let we = !1;
10067
+ M,
10068
+ N
10069
+ ], xe = ye.some((e) => e !== void 0), Se = be.some((e) => e !== void 0), Ce = Object.prototype.hasOwnProperty.call(z, "width"), we = Se && !xe && !pe && !ge && !ve && !Ce, Te = null;
10070
+ we && (Te = xn({
10071
+ textbox: c,
10072
+ originX: ie.originX,
10073
+ originY: ie.originY
10074
+ })), c.uppercase = he, c.set(z);
10075
+ let Ee = !1;
9624
10076
  if (B) {
9625
- let e = Ai({
9626
- textbox: s,
10077
+ let e = Bi({
10078
+ textbox: c,
9627
10079
  styles: V,
9628
10080
  range: B
9629
- }), t = ie ? Ai({
9630
- textbox: s,
9631
- styles: ae,
9632
- range: ie
10081
+ }), t = ae ? Bi({
10082
+ textbox: c,
10083
+ styles: oe,
10084
+ range: ae
9633
10085
  }) : !1;
9634
- we = e || t;
10086
+ Ee = e || t;
9635
10087
  } else if (Object.keys(H).length) {
9636
- let e = Oi({ textbox: s });
9637
- e && (we = Ai({
9638
- textbox: s,
10088
+ let e = Ri({ textbox: c });
10089
+ e && (Ee = Bi({
10090
+ textbox: c,
9639
10091
  styles: H,
9640
10092
  range: e
9641
10093
  }));
9642
10094
  }
9643
- let Te = we && wn({ stylesList: [
10095
+ let De = Ee && wn({ stylesList: [
9644
10096
  V,
9645
- ae,
10097
+ oe,
9646
10098
  H
9647
10099
  ] });
9648
- if (we && (s.dirty = !0), ie && (h !== void 0 || g !== void 0)) {
10100
+ if (Ee && (c.dirty = !0), ae && (g !== void 0 || _ !== void 0)) {
9649
10101
  let e = Zt({
9650
- textbox: s,
9651
- range: ie
10102
+ textbox: c,
10103
+ range: ae
9652
10104
  }), t = {};
9653
- h !== void 0 && (t.fontFamily = h), g !== void 0 && (t.fontSize = g), sn({
9654
- textbox: s,
10105
+ g !== void 0 && (t.fontFamily = g), _ !== void 0 && (t.fontSize = _), sn({
10106
+ textbox: c,
9655
10107
  lineIndices: e,
9656
10108
  updates: t
9657
10109
  });
9658
10110
  }
9659
- if (B && (_ !== void 0 || v !== void 0 || y !== void 0 || x !== void 0 || C !== void 0 || w !== void 0 || T !== void 0)) {
10111
+ if (B && (v !== void 0 || y !== void 0 || b !== void 0 || S !== void 0 || w !== void 0 || T !== void 0 || E !== void 0)) {
9660
10112
  let e = Qt({
9661
- textbox: s,
10113
+ textbox: c,
9662
10114
  range: B
9663
10115
  }), t = {};
9664
- oe !== void 0 && (t.fontWeight = oe), se !== void 0 && (t.fontStyle = se), y !== void 0 && (t.underline = y), x !== void 0 && (t.linethrough = x), C !== void 0 && (t.fill = C), (w !== void 0 || T !== void 0) && (ce === null && (t.stroke = null), ce != null && (t.stroke = ce), U !== void 0 && (t.strokeWidth = U)), sn({
9665
- textbox: s,
10116
+ U !== void 0 && (t.fontWeight = U), se !== void 0 && (t.fontStyle = se), b !== void 0 && (t.underline = b), S !== void 0 && (t.linethrough = S), w !== void 0 && (t.fill = w), (T !== void 0 || E !== void 0) && (W === null && (t.stroke = null), W != null && (t.stroke = W), G !== void 0 && (t.strokeWidth = G)), sn({
10117
+ textbox: c,
9666
10118
  lineIndices: e,
9667
10119
  updates: t
9668
10120
  });
9669
10121
  }
9670
- Te && (s.initDimensions(), s.dirty = !0), [
9671
- D,
10122
+ De && (c.initDimensions(), c.dirty = !0), [
9672
10123
  O,
9673
- ...ve,
9674
- N,
10124
+ k,
10125
+ ...be,
9675
10126
  P,
9676
10127
  F,
9677
- I
9678
- ].some((e) => e !== void 0) && (s.dirty = !0);
9679
- let { autoExpand: Ee } = s, De = m !== void 0, Oe = (m ?? Ee) !== !1;
9680
- De ? s.autoExpand = m !== !1 : Ee === void 0 && (s.autoExpand = !0);
9681
- let ke = Oe && !xe && (fe || he || ge);
10128
+ I,
10129
+ L
10130
+ ].some((e) => e !== void 0) && (c.dirty = !0);
10131
+ let { autoExpand: Oe } = c, ke = h !== void 0, Ae = (h ?? Oe) !== !1;
10132
+ ke ? c.autoExpand = h !== !1 : Oe === void 0 && (c.autoExpand = !0);
10133
+ let je = c.text ?? "";
10134
+ s && _e !== je && this._syncLineStylesWithText({
10135
+ textbox: c,
10136
+ previousText: _e,
10137
+ currentText: je
10138
+ });
10139
+ let Me = Ae && !Ce && (pe || ge || ve);
9682
10140
  this._normalizeTextboxAfterContentChange({
9683
- textbox: s,
9684
- placement: re,
9685
- shouldAutoExpand: ke
9686
- }), Ce && this._restoreTextboxContentPlacement({
9687
- textbox: s,
9688
- contentPlacement: Ce
9689
- }), s.setCoords();
9690
- let Ae = {
10141
+ textbox: c,
10142
+ placement: ie,
10143
+ shouldAutoExpand: Me
10144
+ }), Te && this._restoreTextboxContentPlacement({
10145
+ textbox: c,
10146
+ contentPlacement: Te
10147
+ }), c.setCoords();
10148
+ let Ne = {
9691
10149
  withoutSave: !!r,
9692
10150
  skipRender: !!i
9693
- }, je = !!B && Object.keys(V).length > 0, Me = {
9694
- textbox: s,
10151
+ }, Pe = !!B && Object.keys(V).length > 0, Fe = {
10152
+ textbox: c,
9695
10153
  target: t,
9696
10154
  style: n,
9697
- options: Ae,
10155
+ options: Ne,
9698
10156
  updates: z,
9699
10157
  selectionRange: B ?? void 0,
9700
- selectionStyles: je ? V : void 0
10158
+ selectionStyles: Pe ? V : void 0
9701
10159
  };
9702
- o && d.fire("editor:before:text-updated", Me), i || d.requestRenderAll();
9703
- let Ne = e._getSnapshot(s);
9704
- l.resumeHistory(), r || l.saveState();
9705
- let Pe = {
9706
- ...Me,
9707
- before: f,
9708
- after: Ne
10160
+ o && f.fire("editor:before:text-updated", Fe), i || f.requestRenderAll();
10161
+ let Ie = e._getSnapshot(c);
10162
+ u.resumeHistory(), r || u.saveState();
10163
+ let Le = {
10164
+ ...Fe,
10165
+ before: p,
10166
+ after: Ie
9709
10167
  };
9710
- return o && d.fire("editor:text-updated", Pe), s;
10168
+ return o && f.fire("editor:text-updated", Le), c;
9711
10169
  }
9712
10170
  stylesFromArray(e, t) {
9713
10171
  return w.stylesFromArray(e, t);
@@ -9792,13 +10250,13 @@ var Wi = class {
9792
10250
  let { canvas: e } = this;
9793
10251
  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);
9794
10252
  }
9795
- _syncLineFontDefaultsOnTextChanged({ textbox: e }) {
9796
- let t = e.text ?? "", n = hn({
10253
+ _syncLineStylesWithText({ textbox: e, previousText: t, currentText: n }) {
10254
+ let r = n ?? e.text ?? "", i = hn({
9797
10255
  textbox: e,
9798
- previousText: e.__lineDefaultsPrevText ?? t,
9799
- currentText: t
10256
+ previousText: t ?? e.__lineDefaultsPrevText ?? r,
10257
+ currentText: r
9800
10258
  });
9801
- n.lineFontDefaultsChanged && n.lineFontDefaults && (e.lineFontDefaults = n.lineFontDefaults), n.stylesChanged && (e.styles = n.styles, e.dirty = !0), e.__lineDefaultsPrevText = t;
10259
+ i.lineFontDefaultsChanged && (e.lineFontDefaults = i.lineFontDefaults), i.stylesChanged && (e.styles = i.styles, e.dirty = !0), e.__lineDefaultsPrevText = r;
9802
10260
  }
9803
10261
  _autoExpandTextboxWidth(e, { placement: t, clampToMontage: n = !0 } = {}) {
9804
10262
  let { canvasManager: r, montageArea: i } = this.editor;
@@ -9878,7 +10336,7 @@ var Wi = class {
9878
10336
  _getDefaultFontFamily() {
9879
10337
  return this.fonts[0]?.family ?? "Arial";
9880
10338
  }
9881
- }, Ki = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, qi = (e) => {
10339
+ }, na = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, ra = (e) => {
9882
10340
  if (!e || typeof e != "object") return null;
9883
10341
  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) => ({
9884
10342
  color: typeof e.color == "string" ? e.color : "#000000",
@@ -9889,7 +10347,7 @@ var Wi = class {
9889
10347
  let { x1: e, y1: t, x2: r, y2: i } = n;
9890
10348
  if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
9891
10349
  type: "linear",
9892
- angle: Ki({
10350
+ angle: na({
9893
10351
  x1: e,
9894
10352
  y1: t,
9895
10353
  x2: r,
@@ -9917,7 +10375,7 @@ var Wi = class {
9917
10375
  };
9918
10376
  }
9919
10377
  return null;
9920
- }, Ji = "_templateAnchorX", Yi = "_templateAnchorY", Xi = class t {
10378
+ }, ia = "_templateAnchorX", aa = "_templateAnchorY", oa = class t {
9921
10379
  constructor({ editor: e }) {
9922
10380
  this.editor = e;
9923
10381
  }
@@ -9926,7 +10384,7 @@ var Wi = class {
9926
10384
  if (!p.length) return s.emitWarning({
9927
10385
  origin: "TemplateManager",
9928
10386
  method: "serializeSelection",
9929
- code: wi.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
10387
+ code: Pi.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
9930
10388
  message: "Нет объектов для сериализации шаблона"
9931
10389
  }), null;
9932
10390
  let m = t._getBounds(o), h = t._getMontageSize({
@@ -9955,14 +10413,14 @@ var Wi = class {
9955
10413
  if (!l?.length) return a.emitWarning({
9956
10414
  origin: "TemplateManager",
9957
10415
  method: "applyTemplate",
9958
- code: wi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
10416
+ code: Pi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
9959
10417
  message: "Шаблон не содержит объектов"
9960
10418
  }), null;
9961
10419
  let f = t._getBounds(r);
9962
10420
  if (!f) return a.emitWarning({
9963
10421
  origin: "TemplateManager",
9964
10422
  method: "applyTemplate",
9965
- code: wi.TEMPLATE_MANAGER.INVALID_TARGET,
10423
+ code: Pi.TEMPLATE_MANAGER.INVALID_TARGET,
9966
10424
  message: "Не удалось определить границы монтажной области"
9967
10425
  }), null;
9968
10426
  let p = t._getMontageSize({
@@ -9981,7 +10439,7 @@ var Wi = class {
9981
10439
  if (!r.length) return a.emitWarning({
9982
10440
  origin: "TemplateManager",
9983
10441
  method: "applyTemplate",
9984
- code: wi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
10442
+ code: Pi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
9985
10443
  message: "Не удалось создать объекты шаблона"
9986
10444
  }), null;
9987
10445
  let { backgroundObject: i, contentObjects: u } = t._extractBackgroundObject(r);
@@ -10019,7 +10477,7 @@ var Wi = class {
10019
10477
  return a.emitError({
10020
10478
  origin: "TemplateManager",
10021
10479
  method: "applyTemplate",
10022
- code: wi.TEMPLATE_MANAGER.APPLY_FAILED,
10480
+ code: Pi.TEMPLATE_MANAGER.APPLY_FAILED,
10023
10481
  message: "Ошибка применения шаблона",
10024
10482
  data: {
10025
10483
  templateId: d,
@@ -10173,8 +10631,8 @@ var Wi = class {
10173
10631
  baseHeight: a,
10174
10632
  scale: n,
10175
10633
  useRelativePositions: o,
10176
- anchorX: t._resolveAnchor(s, Ji),
10177
- anchorY: t._resolveAnchor(s, Yi)
10634
+ anchorX: t._resolveAnchor(s, ia),
10635
+ anchorY: t._resolveAnchor(s, aa)
10178
10636
  })
10179
10637
  }), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
10180
10638
  e.set({
@@ -10188,7 +10646,7 @@ var Wi = class {
10188
10646
  originX: _,
10189
10647
  originY: v
10190
10648
  }
10191
- }), delete s[Ji], delete s[Yi];
10649
+ }), delete s[ia], delete s[aa];
10192
10650
  }
10193
10651
  static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
10194
10652
  if (!a) return e;
@@ -10252,7 +10710,7 @@ var Wi = class {
10252
10710
  });
10253
10711
  if (!i || !s || !o) return;
10254
10712
  e.setCoords();
10255
- let c = e, l = t._resolveAnchor(c, Ji), u = typeof c.left == "number" ? c.left : null, d = e.originX ?? "center", f = e.originY ?? "center", p = e.getPointByOrigin(d, f), m = e.getBoundingRect(!1, !0), h = m.left + m.width;
10713
+ let c = e, l = t._resolveAnchor(c, ia), u = typeof c.left == "number" ? c.left : null, d = e.originX ?? "center", f = e.originY ?? "center", p = e.getPointByOrigin(d, f), m = e.getBoundingRect(!1, !0), h = m.left + m.width;
10256
10714
  e.set("width", i), e.initDimensions();
10257
10715
  let g = t._getLongestLineWidth({
10258
10716
  textbox: e,
@@ -10281,10 +10739,10 @@ var Wi = class {
10281
10739
  x: (p.left - o) / d,
10282
10740
  y: (p.top - s) / f
10283
10741
  }, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
10284
- return a[Ji] = t._detectAnchor({
10742
+ return a[ia] = t._detectAnchor({
10285
10743
  start: h,
10286
10744
  end: _
10287
- }), a[Yi] = t._detectAnchor({
10745
+ }), a[aa] = t._detectAnchor({
10288
10746
  start: g,
10289
10747
  end: v
10290
10748
  }), a.left = m.x, a.top = m.y, a;
@@ -10309,7 +10767,7 @@ var Wi = class {
10309
10767
  withoutSave: !0
10310
10768
  }), !0;
10311
10769
  if (a === "gradient") {
10312
- let e = qi(r);
10770
+ let e = ra(r);
10313
10771
  if (e) return n.setGradientBackground({
10314
10772
  gradient: e,
10315
10773
  customData: o,
@@ -10330,7 +10788,7 @@ var Wi = class {
10330
10788
  r.emitWarning({
10331
10789
  origin: "TemplateManager",
10332
10790
  method: "applyTemplate",
10333
- code: wi.TEMPLATE_MANAGER.APPLY_FAILED,
10791
+ code: Pi.TEMPLATE_MANAGER.APPLY_FAILED,
10334
10792
  message: "Не удалось применить фон из шаблона",
10335
10793
  data: e
10336
10794
  });
@@ -10366,29 +10824,29 @@ var Wi = class {
10366
10824
  enlivenObjectEnlivables(e) {
10367
10825
  return w.enlivenObjectEnlivables(e);
10368
10826
  }
10369
- }, Zi = "#3D8BF4", Qi = .5, $i = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, ea = ({ firstDistance: e, secondDistance: t }) => {
10370
- let n = $i({ distance: e }), r = $i({ distance: t });
10827
+ }, sa = "#3D8BF4", ca = .5, la = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, ua = ({ firstDistance: e, secondDistance: t }) => {
10828
+ let n = la({ distance: e }), r = la({ distance: t });
10371
10829
  return {
10372
10830
  firstDisplayDistance: n,
10373
10831
  secondDisplayDistance: r,
10374
10832
  displayDistanceDiff: Math.abs(n - r),
10375
10833
  commonDisplayDistance: Math.max(n, r)
10376
10834
  };
10377
- }, ta = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), na = ({ step: e }) => {
10835
+ }, da = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), fa = ({ step: e }) => {
10378
10836
  let t = Math.abs(e).toString(), n = t.indexOf(".");
10379
10837
  return n === -1 ? 0 : t.slice(n + 1).length;
10380
- }, ra = ({ value: e, step: t }) => {
10838
+ }, pa = ({ value: e, step: t }) => {
10381
10839
  if (t === 0) return e;
10382
- let n = na({ step: t }), r = Math.round(e / t) * t;
10840
+ let n = fa({ step: t }), r = Math.round(e / t) * t;
10383
10841
  return Number(r.toFixed(n));
10384
- }, ia = ({ value: e, step: t }) => {
10842
+ }, ma = ({ value: e, step: t }) => {
10385
10843
  if (t === 0) return !0;
10386
- let n = ra({
10844
+ let n = pa({
10387
10845
  value: e,
10388
10846
  step: t
10389
- }), r = 10 ** -(na({ step: t }) + 4);
10847
+ }), r = 10 ** -(fa({ step: t }) + 4);
10390
10848
  return Math.abs(n - e) <= r;
10391
- }, aa = ({ bounds: e, axis: t }) => {
10849
+ }, ha = ({ bounds: e, axis: t }) => {
10392
10850
  let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
10393
10851
  return t === "vertical" ? {
10394
10852
  start: i,
@@ -10397,7 +10855,7 @@ var Wi = class {
10397
10855
  start: n,
10398
10856
  end: r
10399
10857
  };
10400
- }, oa = ({ items: e, axis: t }) => {
10858
+ }, ga = ({ items: e, axis: t }) => {
10401
10859
  for (let n = 1; n < e.length; n += 1) {
10402
10860
  let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
10403
10861
  for (; o >= 0;) {
@@ -10407,10 +10865,10 @@ var Wi = class {
10407
10865
  }
10408
10866
  e[o + 1] = r;
10409
10867
  }
10410
- }, sa = ({ items: e, index: t, axis: n, direction: r }) => {
10868
+ }, _a = ({ items: e, index: t, axis: n, direction: r }) => {
10411
10869
  let i = e[t];
10412
10870
  if (!i) return null;
10413
- let { bounds: a } = i, { start: o, end: s } = aa({
10871
+ let { bounds: a } = i, { start: o, end: s } = ha({
10414
10872
  bounds: a,
10415
10873
  axis: n
10416
10874
  });
@@ -10418,7 +10876,7 @@ var Wi = class {
10418
10876
  for (let r = t - 1; r >= 0; --r) {
10419
10877
  let t = e[r];
10420
10878
  if (!t) continue;
10421
- let { bounds: i } = t, { end: a } = aa({
10879
+ let { bounds: i } = t, { end: a } = ha({
10422
10880
  bounds: i,
10423
10881
  axis: n
10424
10882
  });
@@ -10429,26 +10887,26 @@ var Wi = class {
10429
10887
  for (let r = t + 1; r < e.length; r += 1) {
10430
10888
  let t = e[r];
10431
10889
  if (!t) continue;
10432
- let { bounds: i } = t, { start: a } = aa({
10890
+ let { bounds: i } = t, { start: a } = ha({
10433
10891
  bounds: i,
10434
10892
  axis: n
10435
10893
  });
10436
10894
  if (a - s >= 0) return r;
10437
10895
  }
10438
10896
  return null;
10439
- }, ca = ({ items: e }) => {
10897
+ }, va = ({ items: e }) => {
10440
10898
  for (let t = 0; t < e.length; t += 1) {
10441
10899
  let { isActive: n } = e[t];
10442
10900
  if (n) return t;
10443
10901
  }
10444
10902
  return -1;
10445
- }, la = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
10903
+ }, ya = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
10446
10904
  let i = Math.min(t, n), a = Math.max(t, n);
10447
10905
  return e >= i - r && e <= a + r;
10448
- }, ua = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, da = ({ baseOption: e, candidateOption: t }) => {
10906
+ }, ba = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, xa = ({ baseOption: e, candidateOption: t }) => {
10449
10907
  let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
10450
10908
  return n === i && r === a;
10451
- }, fa = ({ options: e }) => {
10909
+ }, Sa = ({ options: e }) => {
10452
10910
  let t = e[0];
10453
10911
  for (let n = 1; n < e.length; n += 1) {
10454
10912
  let r = e[n];
@@ -10459,11 +10917,11 @@ var Wi = class {
10459
10917
  r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
10460
10918
  }
10461
10919
  return t;
10462
- }, pa = ({ currentOption: e, nextOption: t }) => {
10920
+ }, Ca = ({ currentOption: e, nextOption: t }) => {
10463
10921
  if (!e) return !0;
10464
10922
  let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
10465
10923
  return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
10466
- }, ma = ({ options: e }) => {
10924
+ }, wa = ({ options: e }) => {
10467
10925
  let t = [], n = null, r = null;
10468
10926
  for (let i of e) {
10469
10927
  let { kind: e, side: a } = i;
@@ -10471,18 +10929,18 @@ var Wi = class {
10471
10929
  t.push(i);
10472
10930
  continue;
10473
10931
  }
10474
- a === "before" && pa({
10932
+ a === "before" && Ca({
10475
10933
  currentOption: n,
10476
10934
  nextOption: i
10477
- }) && (n = i), a === "after" && pa({
10935
+ }) && (n = i), a === "after" && Ca({
10478
10936
  currentOption: r,
10479
10937
  nextOption: i
10480
10938
  }) && (r = i);
10481
10939
  }
10482
10940
  return n && t.push(n), r && t.push(r), t;
10483
- }, ha = ({ options: e, side: t, baseOption: n }) => {
10941
+ }, Ta = ({ options: e, side: t, baseOption: n }) => {
10484
10942
  let r = null;
10485
- for (let i of e) if (i.side === t && da({
10943
+ for (let i of e) if (i.side === t && xa({
10486
10944
  baseOption: n,
10487
10945
  candidateOption: i
10488
10946
  })) {
@@ -10493,63 +10951,63 @@ var Wi = class {
10493
10951
  !r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
10494
10952
  }
10495
10953
  return r;
10496
- }, ga = ({ option: e }) => {
10954
+ }, Ea = ({ option: e }) => {
10497
10955
  let { side: t, kind: n, guide: { distance: r } } = e;
10498
10956
  return {
10499
10957
  side: t,
10500
10958
  kind: n,
10501
10959
  distance: r
10502
10960
  };
10503
- }, _a = ({ option: e, context: t }) => {
10961
+ }, Da = ({ option: e, context: t }) => {
10504
10962
  let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
10505
10963
  return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
10506
- }, va = ({ options: e, context: t }) => {
10964
+ }, Oa = ({ options: e, context: t }) => {
10507
10965
  if (!t) return null;
10508
- for (let n of e) if (_a({
10966
+ for (let n of e) if (Da({
10509
10967
  option: n,
10510
10968
  context: t
10511
10969
  })) return n;
10512
10970
  return null;
10513
- }, ya = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
10514
- let i = va({
10971
+ }, ka = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
10972
+ let i = Oa({
10515
10973
  options: e,
10516
10974
  context: n
10517
10975
  });
10518
10976
  if (!i) return t;
10519
10977
  let a = Math.max(0, r);
10520
10978
  return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
10521
- }, ba = ({ guides: e, seenGuideKeys: t, guide: n }) => {
10979
+ }, Aa = ({ guides: e, seenGuideKeys: t, guide: n }) => {
10522
10980
  let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
10523
10981
  t.has(u) || (t.add(u), e.push(n));
10524
- }, xa = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
10982
+ }, ja = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
10525
10983
  if (!e.length) return {
10526
10984
  delta: 0,
10527
10985
  guides: [],
10528
10986
  context: null
10529
10987
  };
10530
- let r = ma({ options: e }), i = [];
10988
+ let r = wa({ options: e }), i = [];
10531
10989
  for (let e of r) e.kind === "reference" && i.push(e);
10532
- let a = i.length > 0, o = a ? i : r, s = ya({
10990
+ let a = i.length > 0, o = a ? i : r, s = ka({
10533
10991
  options: o,
10534
- bestOption: fa({ options: o }),
10992
+ bestOption: Sa({ options: o }),
10535
10993
  previousContext: t,
10536
10994
  switchDistance: n
10537
- }), c = ha({
10995
+ }), c = Ta({
10538
10996
  options: o,
10539
10997
  side: "before",
10540
10998
  baseOption: s
10541
- }), l = ha({
10999
+ }), l = Ta({
10542
11000
  options: o,
10543
11001
  side: "after",
10544
11002
  baseOption: s
10545
- }), u = ha({
11003
+ }), u = Ta({
10546
11004
  options: a ? r : o,
10547
11005
  side: "center",
10548
11006
  baseOption: s
10549
11007
  }), d = [];
10550
11008
  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);
10551
11009
  let f = [], p = /* @__PURE__ */ new Set();
10552
- for (let e of d) ba({
11010
+ for (let e of d) Aa({
10553
11011
  guides: f,
10554
11012
  seenGuideKeys: p,
10555
11013
  guide: e.guide
@@ -10557,15 +11015,15 @@ var Wi = class {
10557
11015
  return {
10558
11016
  delta: s.delta,
10559
11017
  guides: f,
10560
- context: ga({ option: s })
11018
+ context: Ea({ option: s })
10561
11019
  };
10562
- }, Sa = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
10563
- let s = n - (e - r), c = ra({
11020
+ }, Ma = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
11021
+ let s = n - (e - r), c = pa({
10564
11022
  value: s,
10565
11023
  step: o
10566
11024
  }), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
10567
11025
  for (let d = -l; d <= l; d += 1) {
10568
- let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = ea({
11026
+ let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = ua({
10569
11027
  firstDistance: m,
10570
11028
  secondDistance: h
10571
11029
  });
@@ -10580,13 +11038,13 @@ var Wi = class {
10580
11038
  });
10581
11039
  }
10582
11040
  return u;
10583
- }, Ca = ({ currentGap: e, referenceGap: t }) => {
10584
- let { secondDisplayDistance: n, displayDistanceDiff: r } = ea({
11041
+ }, Na = ({ currentGap: e, referenceGap: t }) => {
11042
+ let { secondDisplayDistance: n, displayDistanceDiff: r } = ua({
10585
11043
  firstDistance: e,
10586
11044
  secondDistance: t
10587
11045
  });
10588
11046
  return r > 1 ? null : n;
10589
- }, wa = ({ anchors: e, positions: t, threshold: n }) => {
11047
+ }, Pa = ({ anchors: e, positions: t, threshold: n }) => {
10590
11048
  let r = 0, i = n + 1, a = null;
10591
11049
  for (let o of t) for (let t of e) {
10592
11050
  let e = Math.abs(t - o);
@@ -10596,8 +11054,8 @@ var Wi = class {
10596
11054
  delta: r,
10597
11055
  guidePosition: a
10598
11056
  };
10599
- }, Ta = ({ activeBounds: e, threshold: t, anchors: n }) => {
10600
- let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = wa({
11057
+ }, Fa = ({ activeBounds: e, threshold: t, anchors: n }) => {
11058
+ let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Pa({
10601
11059
  anchors: n.vertical,
10602
11060
  positions: [
10603
11061
  r,
@@ -10605,7 +11063,7 @@ var Wi = class {
10605
11063
  i
10606
11064
  ],
10607
11065
  threshold: t
10608
- }), u = wa({
11066
+ }), u = Pa({
10609
11067
  anchors: n.horizontal,
10610
11068
  positions: [
10611
11069
  o,
@@ -10625,11 +11083,11 @@ var Wi = class {
10625
11083
  deltaY: u.delta,
10626
11084
  guides: d
10627
11085
  };
10628
- }, Ea = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11086
+ }, Ia = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
10629
11087
  let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
10630
11088
  for (let e of t) {
10631
11089
  let { left: t, right: n } = e;
10632
- ta({
11090
+ da({
10633
11091
  firstStart: t,
10634
11092
  firstEnd: n,
10635
11093
  secondStart: l,
@@ -10649,22 +11107,22 @@ var Wi = class {
10649
11107
  f.push({
10650
11108
  bounds: e,
10651
11109
  isActive: !0
10652
- }), oa({
11110
+ }), ga({
10653
11111
  items: f,
10654
11112
  axis: "top"
10655
11113
  });
10656
- let p = ca({ items: f });
11114
+ let p = va({ items: f });
10657
11115
  if (p === -1) return {
10658
11116
  delta: 0,
10659
11117
  guides: [],
10660
11118
  context: null
10661
11119
  };
10662
- let m = [], h = c - s, g = sa({
11120
+ let m = [], h = c - s, g = _a({
10663
11121
  items: f,
10664
11122
  index: p,
10665
11123
  axis: "vertical",
10666
11124
  direction: "prev"
10667
- }), _ = sa({
11125
+ }), _ = _a({
10668
11126
  items: f,
10669
11127
  index: p,
10670
11128
  axis: "vertical",
@@ -10673,19 +11131,19 @@ var Wi = class {
10673
11131
  if (v && y) {
10674
11132
  let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
10675
11133
  if (a >= 0) {
10676
- let e = ra({
11134
+ let e = pa({
10677
11135
  value: a / 2,
10678
11136
  step: 1
10679
11137
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
10680
11138
  if (Math.max(u, d) <= n) {
10681
- let t = Sa({
11139
+ let t = Ma({
10682
11140
  activeStart: s,
10683
11141
  activeEnd: c,
10684
11142
  targetGap: e,
10685
11143
  beforeEdge: r,
10686
11144
  afterEdge: i,
10687
11145
  threshold: n,
10688
- step: Qi
11146
+ step: ca
10689
11147
  });
10690
11148
  if (t) {
10691
11149
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -10722,16 +11180,16 @@ var Wi = class {
10722
11180
  }
10723
11181
  for (let e of r) {
10724
11182
  let { axis: t, start: r, end: i, distance: a } = e;
10725
- if (!ia({
11183
+ if (!ma({
10726
11184
  value: a,
10727
11185
  step: .5
10728
- }) || !la({
11186
+ }) || !ya({
10729
11187
  patternAxis: t,
10730
11188
  activeRangeStart: l,
10731
11189
  activeRangeEnd: u,
10732
11190
  tolerance: n
10733
11191
  })) continue;
10734
- let d = ua({
11192
+ let d = ba({
10735
11193
  patternStart: r,
10736
11194
  patternEnd: i,
10737
11195
  activeStart: s,
@@ -10739,12 +11197,12 @@ var Wi = class {
10739
11197
  });
10740
11198
  if (d) {
10741
11199
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
10742
- let e = ra({
11200
+ let e = pa({
10743
11201
  value: a - b,
10744
11202
  step: 1
10745
11203
  }), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
10746
11204
  if (u > n) continue;
10747
- let d = Ca({
11205
+ let d = Na({
10748
11206
  currentGap: l,
10749
11207
  referenceGap: a
10750
11208
  });
@@ -10768,12 +11226,12 @@ var Wi = class {
10768
11226
  });
10769
11227
  }
10770
11228
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
10771
- let e = ra({
11229
+ let e = pa({
10772
11230
  value: x - a,
10773
11231
  step: 1
10774
11232
  }), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
10775
11233
  if (u > n) continue;
10776
- let d = Ca({
11234
+ let d = Na({
10777
11235
  currentGap: l,
10778
11236
  referenceGap: a
10779
11237
  });
@@ -10798,16 +11256,16 @@ var Wi = class {
10798
11256
  }
10799
11257
  }
10800
11258
  }
10801
- return xa({
11259
+ return ja({
10802
11260
  options: m,
10803
11261
  previousContext: i,
10804
11262
  switchDistance: a
10805
11263
  });
10806
- }, Da = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11264
+ }, La = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
10807
11265
  let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
10808
11266
  for (let e of t) {
10809
11267
  let { top: t, bottom: n } = e;
10810
- ta({
11268
+ da({
10811
11269
  firstStart: t,
10812
11270
  firstEnd: n,
10813
11271
  secondStart: l,
@@ -10827,22 +11285,22 @@ var Wi = class {
10827
11285
  f.push({
10828
11286
  bounds: e,
10829
11287
  isActive: !0
10830
- }), oa({
11288
+ }), ga({
10831
11289
  items: f,
10832
11290
  axis: "left"
10833
11291
  });
10834
- let p = ca({ items: f });
11292
+ let p = va({ items: f });
10835
11293
  if (p === -1) return {
10836
11294
  delta: 0,
10837
11295
  guides: [],
10838
11296
  context: null
10839
11297
  };
10840
- let m = [], h = c - s, g = sa({
11298
+ let m = [], h = c - s, g = _a({
10841
11299
  items: f,
10842
11300
  index: p,
10843
11301
  axis: "horizontal",
10844
11302
  direction: "prev"
10845
- }), _ = sa({
11303
+ }), _ = _a({
10846
11304
  items: f,
10847
11305
  index: p,
10848
11306
  axis: "horizontal",
@@ -10851,19 +11309,19 @@ var Wi = class {
10851
11309
  if (v && y) {
10852
11310
  let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
10853
11311
  if (a >= 0) {
10854
- let e = ra({
11312
+ let e = pa({
10855
11313
  value: a / 2,
10856
11314
  step: 1
10857
11315
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
10858
11316
  if (Math.max(u, d) <= n) {
10859
- let t = Sa({
11317
+ let t = Ma({
10860
11318
  activeStart: s,
10861
11319
  activeEnd: c,
10862
11320
  targetGap: e,
10863
11321
  beforeEdge: r,
10864
11322
  afterEdge: i,
10865
11323
  threshold: n,
10866
- step: Qi
11324
+ step: ca
10867
11325
  });
10868
11326
  if (t) {
10869
11327
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -10900,16 +11358,16 @@ var Wi = class {
10900
11358
  }
10901
11359
  for (let e of r) {
10902
11360
  let { axis: t, start: r, end: i, distance: a } = e;
10903
- if (!ia({
11361
+ if (!ma({
10904
11362
  value: a,
10905
11363
  step: .5
10906
- }) || !la({
11364
+ }) || !ya({
10907
11365
  patternAxis: t,
10908
11366
  activeRangeStart: l,
10909
11367
  activeRangeEnd: u,
10910
11368
  tolerance: n
10911
11369
  })) continue;
10912
- let d = ua({
11370
+ let d = ba({
10913
11371
  patternStart: r,
10914
11372
  patternEnd: i,
10915
11373
  activeStart: s,
@@ -10917,12 +11375,12 @@ var Wi = class {
10917
11375
  });
10918
11376
  if (d) {
10919
11377
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
10920
- let e = ra({
11378
+ let e = pa({
10921
11379
  value: a - b,
10922
11380
  step: 1
10923
11381
  }), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
10924
11382
  if (u > n) continue;
10925
- let d = Ca({
11383
+ let d = Na({
10926
11384
  currentGap: l,
10927
11385
  referenceGap: a
10928
11386
  });
@@ -10946,12 +11404,12 @@ var Wi = class {
10946
11404
  });
10947
11405
  }
10948
11406
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
10949
- let e = ra({
11407
+ let e = pa({
10950
11408
  value: x - a,
10951
11409
  step: 1
10952
11410
  }), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
10953
11411
  if (u > n) continue;
10954
- let d = Ca({
11412
+ let d = Na({
10955
11413
  currentGap: l,
10956
11414
  referenceGap: a
10957
11415
  });
@@ -10976,20 +11434,20 @@ var Wi = class {
10976
11434
  }
10977
11435
  }
10978
11436
  }
10979
- return xa({
11437
+ return ja({
10980
11438
  options: m,
10981
11439
  previousContext: i,
10982
11440
  switchDistance: a
10983
11441
  });
10984
- }, Oa = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
10985
- let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Ea({
11442
+ }, Ra = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
11443
+ let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Ia({
10986
11444
  activeBounds: e,
10987
11445
  candidates: t,
10988
11446
  threshold: n,
10989
11447
  patterns: r.vertical,
10990
11448
  previousContext: o,
10991
11449
  switchDistance: a
10992
- }), l = Da({
11450
+ }), l = La({
10993
11451
  activeBounds: e,
10994
11452
  candidates: t,
10995
11453
  threshold: n,
@@ -11008,14 +11466,14 @@ var Wi = class {
11008
11466
  horizontal: l.context
11009
11467
  }
11010
11468
  };
11011
- }, ka = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
11469
+ }, za = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
11012
11470
  let o = Math.min(a, r / 2, i / 2);
11013
11471
  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();
11014
- }, Aa = ({ 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 }) => {
11472
+ }, Ba = ({ 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 }) => {
11015
11473
  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;
11016
11474
  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";
11017
11475
  let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
11018
- e.beginPath(), ka({
11476
+ e.beginPath(), za({
11019
11477
  context: e,
11020
11478
  x: w,
11021
11479
  y: T,
@@ -11023,11 +11481,11 @@ var Wi = class {
11023
11481
  height: C,
11024
11482
  radius: v
11025
11483
  }), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
11026
- }, ja = ({ context: e, guide: t, zoom: n }) => {
11027
- let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = $i({ distance: l }).toString();
11484
+ }, Va = ({ context: e, guide: t, zoom: n }) => {
11485
+ let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = la({ distance: l }).toString();
11028
11486
  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();
11029
- let d = Zi;
11030
- Aa({
11487
+ let d = sa;
11488
+ Ba({
11031
11489
  context: e,
11032
11490
  type: r,
11033
11491
  axis: i,
@@ -11037,7 +11495,7 @@ var Wi = class {
11037
11495
  zoom: n,
11038
11496
  color: d,
11039
11497
  lineWidth: 1
11040
- }), Aa({
11498
+ }), Ba({
11041
11499
  context: e,
11042
11500
  type: r,
11043
11501
  axis: i,
@@ -11048,10 +11506,10 @@ var Wi = class {
11048
11506
  color: d,
11049
11507
  lineWidth: 1
11050
11508
  });
11051
- }, Ma = ({ anchors: e, bounds: t }) => {
11509
+ }, Ha = ({ anchors: e, bounds: t }) => {
11052
11510
  let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
11053
11511
  e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
11054
- }, Na = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
11512
+ }, Ua = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
11055
11513
  let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
11056
11514
  for (let e = 0; e < s.length; e += 1) {
11057
11515
  let c = s[e], l = null, u = Infinity;
@@ -11072,35 +11530,35 @@ var Wi = class {
11072
11530
  });
11073
11531
  }
11074
11532
  return i;
11075
- }, Pa = ({ bounds: e }) => ({
11076
- vertical: Na({
11533
+ }, Wa = ({ bounds: e }) => ({
11534
+ vertical: Ua({
11077
11535
  bounds: e,
11078
11536
  axis: "centerX",
11079
11537
  type: "vertical",
11080
11538
  primaryStart: "top",
11081
11539
  primaryEnd: "bottom"
11082
11540
  }),
11083
- horizontal: Na({
11541
+ horizontal: Ua({
11084
11542
  bounds: e,
11085
11543
  axis: "centerY",
11086
11544
  type: "horizontal",
11087
11545
  primaryStart: "left",
11088
11546
  primaryEnd: "right"
11089
11547
  })
11090
- }), Fa = [
11548
+ }), Ga = [
11091
11549
  "montage-area",
11092
11550
  "background",
11093
11551
  "interaction-blocker"
11094
- ], Ia = ({ activeObject: t }) => {
11552
+ ], Ka = ({ activeObject: t }) => {
11095
11553
  let n = /* @__PURE__ */ new Set();
11096
11554
  return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
11097
- }, La = ({ object: e, excluded: t, ignoredIds: n = Fa }) => {
11555
+ }, qa = ({ object: e, excluded: t, ignoredIds: n = Ga }) => {
11098
11556
  if (t.has(e)) return !0;
11099
11557
  let { visible: r = !0 } = e;
11100
11558
  if (!r) return !0;
11101
11559
  let { id: i } = e;
11102
11560
  return !!(i && n.includes(i));
11103
- }, Ra = class e {
11561
+ }, Ja = class e {
11104
11562
  constructor({ editor: e }) {
11105
11563
  this.anchors = {
11106
11564
  vertical: [],
@@ -11153,7 +11611,7 @@ var Wi = class {
11153
11611
  this._clearSpacingContexts(), this._clearGuides();
11154
11612
  return;
11155
11613
  }
11156
- let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Ta({
11614
+ let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Fa({
11157
11615
  activeBounds: a,
11158
11616
  threshold: c,
11159
11617
  anchors: this.anchors
@@ -11165,7 +11623,7 @@ var Wi = class {
11165
11623
  top: t + u
11166
11624
  }), n.setCoords(), a = Vt({ object: n }) ?? a;
11167
11625
  }
11168
- let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = Oa({
11626
+ let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = Ra({
11169
11627
  activeBounds: a,
11170
11628
  candidates: d,
11171
11629
  threshold: f,
@@ -11186,11 +11644,11 @@ var Wi = class {
11186
11644
  target: n,
11187
11645
  transform: i
11188
11646
  });
11189
- let h = Vt({ object: n }) ?? a, g = Ta({
11647
+ let h = Vt({ object: n }) ?? a, g = Fa({
11190
11648
  activeBounds: h,
11191
11649
  threshold: c,
11192
11650
  anchors: this.anchors
11193
- }), _ = Oa({
11651
+ }), _ = Ra({
11194
11652
  activeBounds: h,
11195
11653
  candidates: d,
11196
11654
  threshold: c,
@@ -11421,9 +11879,9 @@ var Wi = class {
11421
11879
  let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
11422
11880
  if (!n) return;
11423
11881
  let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
11424
- n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = Zi, n.setLineDash([4, 4]);
11882
+ n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = sa, n.setLineDash([4, 4]);
11425
11883
  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();
11426
- for (let e of this.activeSpacingGuides) ja({
11884
+ for (let e of this.activeSpacingGuides) Va({
11427
11885
  context: n,
11428
11886
  guide: e,
11429
11887
  zoom: c
@@ -11634,14 +12092,14 @@ var Wi = class {
11634
12092
  }, r = [];
11635
12093
  for (let e of t) {
11636
12094
  let t = Vt({ object: e });
11637
- t && (Ma({
12095
+ t && (Ha({
11638
12096
  anchors: n,
11639
12097
  bounds: t
11640
12098
  }), r.push(t));
11641
12099
  }
11642
12100
  let { montageArea: i } = this.editor, a = Vt({ object: i });
11643
12101
  if (a) {
11644
- Ma({
12102
+ Ha({
11645
12103
  anchors: n,
11646
12104
  bounds: a
11647
12105
  });
@@ -11653,12 +12111,12 @@ var Wi = class {
11653
12111
  bottom: i
11654
12112
  };
11655
12113
  } else this.guideBounds = this._calculateViewportBounds();
11656
- this.anchors = n, this.spacingPatterns = Pa({ bounds: r }), this.cachedTargetBounds = r;
12114
+ this.anchors = n, this.spacingPatterns = Wa({ bounds: r }), this.cachedTargetBounds = r;
11657
12115
  }
11658
12116
  _collectTargets({ activeObject: e }) {
11659
- let t = Ia({ activeObject: e }), n = [];
12117
+ let t = Ka({ activeObject: e }), n = [];
11660
12118
  return this.canvas.forEachObject((e) => {
11661
- La({
12119
+ qa({
11662
12120
  object: e,
11663
12121
  excluded: t
11664
12122
  }) || n.push(e);
@@ -11681,7 +12139,7 @@ var Wi = class {
11681
12139
  bottom: (r - s) / a
11682
12140
  };
11683
12141
  }
11684
- }, za = "#3D8BF4", Ba = class e {
12142
+ }, Ya = "#3D8BF4", Xa = class e {
11685
12143
  constructor({ editor: e }) {
11686
12144
  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();
11687
12145
  }
@@ -11774,8 +12232,8 @@ var Wi = class {
11774
12232
  this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
11775
12233
  }
11776
12234
  static _resolveTarget({ event: e, activeObject: t }) {
11777
- let { target: n } = e, r = Ia({ activeObject: t });
11778
- return n && !La({
12235
+ let { target: n } = e, r = Ka({ activeObject: t });
12236
+ return n && !qa({
11779
12237
  object: n,
11780
12238
  excluded: r
11781
12239
  }) ? n : null;
@@ -11892,18 +12350,18 @@ var Wi = class {
11892
12350
  let { canvas: e } = this, t = e.getSelectionContext();
11893
12351
  if (!t) return;
11894
12352
  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;
11895
- t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = za, t.setLineDash([]);
12353
+ t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Ya, t.setLineDash([]);
11896
12354
  for (let e of this.activeGuides) {
11897
12355
  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;
11898
- t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Aa({
12356
+ t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Ba({
11899
12357
  context: t,
11900
12358
  type: n,
11901
12359
  axis: i,
11902
12360
  start: a,
11903
12361
  end: c,
11904
- text: $i({ distance: l }).toString(),
12362
+ text: la({ distance: l }).toString(),
11905
12363
  zoom: r,
11906
- color: za,
12364
+ color: Ya,
11907
12365
  lineWidth: 1,
11908
12366
  offsetAlongAxis: d,
11909
12367
  offsetPerpendicular: 0
@@ -11921,13 +12379,13 @@ var Wi = class {
11921
12379
  let { toolbar: e } = this.editor;
11922
12380
  e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
11923
12381
  }
11924
- }, Va = class e {
12382
+ }, Za = class e {
11925
12383
  constructor(e, t) {
11926
12384
  this.options = t, this.containerId = e, this.editorId = `${e}-${O()}`, this.init();
11927
12385
  }
11928
12386
  async init() {
11929
12387
  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;
11930
- if (se.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new j(), this.workerManager = new N(), this.errorManager = new Ti({ editor: this }), this.historyManager = new Ct({ editor: this }), this.toolbar = new Je({ editor: this }), this.transformManager = new Pt({ editor: this }), this.zoomManager = new Ft({ editor: this }), this.canvasManager = new Nt({ editor: this }), this.imageManager = new kt({ editor: this }), this.layerManager = new Kt({ editor: this }), this.shapeManager = new vi({ editor: this }), this.interactionBlocker = new Wt({ editor: this }), this.backgroundManager = new Gt({ editor: this }), this.clipboardManager = new yi({ editor: this }), this.objectLockManager = new bi({ editor: this }), this.groupingManager = new xi({ editor: this }), this.selectionManager = new Si({ editor: this }), this.deletionManager = new Ci({ editor: this }), this.panConstraintManager = new Ei({ editor: this }), this.snappingManager = new Ra({ editor: this }), this.measurementManager = new Ba({ editor: this }), this.fontManager = new ce(this.options.fonts ?? []), this.textManager = new Gi({ editor: this }), this.templateManager = new Xi({ editor: this }), u && (this.angleIndicator = new Ze({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new A({
12388
+ if (U.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new j(), this.workerManager = new N(), this.errorManager = new Fi({ editor: this }), this.historyManager = new Ct({ editor: this }), this.toolbar = new Je({ editor: this }), this.transformManager = new Pt({ editor: this }), this.zoomManager = new Ft({ editor: this }), this.canvasManager = new Nt({ editor: this }), this.imageManager = new kt({ editor: this }), this.layerManager = new Kt({ editor: this }), this.shapeManager = new Oi({ editor: this }), this.interactionBlocker = new Wt({ editor: this }), this.backgroundManager = new Gt({ editor: this }), this.clipboardManager = new ki({ editor: this }), this.objectLockManager = new Ai({ editor: this }), this.groupingManager = new ji({ editor: this }), this.selectionManager = new Mi({ editor: this }), this.deletionManager = new Ni({ editor: this }), this.panConstraintManager = new Ii({ editor: this }), this.snappingManager = new Ja({ editor: this }), this.measurementManager = new Xa({ editor: this }), this.fontManager = new se(this.options.fonts ?? []), this.textManager = new ta({ editor: this }), this.templateManager = new oa({ editor: this }), u && (this.angleIndicator = new Ze({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new A({
11931
12389
  editor: this,
11932
12390
  options: this.options
11933
12391
  }), 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) {
@@ -12035,7 +12493,7 @@ var Wi = class {
12035
12493
  "U+A640-A69F",
12036
12494
  "U+FE2E-FE2F",
12037
12495
  "U+2116"
12038
- ].join(", "), Ha = {
12496
+ ].join(", "), Qa = {
12039
12497
  preserveObjectStacking: !0,
12040
12498
  controlsAboveOverlay: !0,
12041
12499
  centeredRotation: !0,
@@ -12889,20 +13347,20 @@ var Wi = class {
12889
13347
  };
12890
13348
  //#endregion
12891
13349
  //#region src/main.ts
12892
- function Ua(e, t = {}) {
13350
+ function $a(e, t = {}) {
12893
13351
  let n = {
12894
- ...Ha,
13352
+ ...Qa,
12895
13353
  ...t
12896
13354
  }, r = document.getElementById(e);
12897
13355
  if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
12898
13356
  let i = document.createElement("canvas");
12899
13357
  return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
12900
13358
  n._onReadyCallback = t;
12901
- let r = new Va(i.id, n);
13359
+ let r = new Za(i.id, n);
12902
13360
  window[e] = r;
12903
13361
  });
12904
13362
  }
12905
13363
  //#endregion
12906
- export { Ua as default };
13364
+ export { $a as default };
12907
13365
 
12908
13366
  //# sourceMappingURL=main.js.map