@anu3ev/fabric-image-editor 0.8.11 → 0.8.12

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 +231 -226
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -8577,7 +8577,21 @@ var bi = class {
8577
8577
  }
8578
8578
  return null;
8579
8579
  }
8580
- }, ki = class {
8580
+ }, ki = ({ rootObject: t, enableEvented: n = !0 }) => {
8581
+ let r = [{
8582
+ object: t,
8583
+ enableEvented: n
8584
+ }];
8585
+ for (let t = 0; t < r.length; t += 1) {
8586
+ let n = r[t], i = { id: `${n.object.type}-${O()}` };
8587
+ n.enableEvented && (i.evented = !0), n.object.set(i);
8588
+ let a = null, o = !1;
8589
+ if (n.object instanceof e ? (a = n.object.getObjects(), o = !0) : n.object instanceof l && (a = n.object.getObjects()), a) for (let e = 0; e < a.length; e += 1) r.push({
8590
+ object: a[e],
8591
+ enableEvented: o
8592
+ });
8593
+ }
8594
+ }, Ai = class {
8581
8595
  constructor({ editor: e }) {
8582
8596
  this.editor = e, this.clipboard = null;
8583
8597
  }
@@ -8680,16 +8694,6 @@ var bi = class {
8680
8694
  }
8681
8695
  r.commitStandaloneTextScale({ target: t }), n.commitRehydratedShapeLayout({ target: t });
8682
8696
  }
8683
- _materializeCloneIdentity({ clonedObject: t, enableEvented: n = !0 }) {
8684
- t.set({ id: `${t.type}-${O()}` }), n && t.set({ evented: !0 });
8685
- let r = t instanceof e;
8686
- (r || t instanceof l) && t.getObjects().forEach((e) => {
8687
- this._materializeCloneIdentity({
8688
- clonedObject: e,
8689
- enableEvented: r
8690
- });
8691
- });
8692
- }
8693
8697
  async _handleImageImport(e) {
8694
8698
  let { canvas: t, errorManager: n } = this.editor, r = !1, i = !1, a = null, o = null, s = new Promise((e, t) => {
8695
8699
  a = (t) => {
@@ -8710,6 +8714,10 @@ var bi = class {
8710
8714
  }
8711
8715
  try {
8712
8716
  let t = await s;
8717
+ if (t === null) {
8718
+ await this._importExternalImage({ source: e });
8719
+ return;
8720
+ }
8713
8721
  await this._importExternalImage({
8714
8722
  source: e,
8715
8723
  importOptions: t
@@ -8741,7 +8749,7 @@ var bi = class {
8741
8749
  if (!n || n.locked) return !1;
8742
8750
  try {
8743
8751
  let e = await n.clone(Ot);
8744
- return this._materializeCloneIdentity({ clonedObject: e }), e.set({
8752
+ return ki({ rootObject: e }), e.set({
8745
8753
  left: e.left + 10,
8746
8754
  top: e.top + 10
8747
8755
  }), this._materializeCloneGeometry({ clonedObject: e }), this._addClonedObjectToCanvas(e), t.fire("editor:object-duplicated", {
@@ -8808,7 +8816,7 @@ var bi = class {
8808
8816
  if (!this.clipboard) return !1;
8809
8817
  try {
8810
8818
  let t = await this.clipboard.clone(Ot);
8811
- return e.discardActiveObject(), this._materializeCloneIdentity({ clonedObject: t }), t.set({
8819
+ return e.discardActiveObject(), ki({ rootObject: t }), t.set({
8812
8820
  left: t.left + 10,
8813
8821
  top: t.top + 10
8814
8822
  }), this._materializeCloneGeometry({ clonedObject: t }), this._addClonedObjectToCanvas(t), e.fire("editor:object-pasted", {
@@ -8827,7 +8835,7 @@ var bi = class {
8827
8835
  }), !1;
8828
8836
  }
8829
8837
  }
8830
- }, Ai = class t {
8838
+ }, ji = class t {
8831
8839
  constructor({ editor: e }) {
8832
8840
  this.editor = e;
8833
8841
  }
@@ -8892,7 +8900,7 @@ var bi = class {
8892
8900
  !(n instanceof v) || !n.isEditing || n.exitEditing();
8893
8901
  }
8894
8902
  }
8895
- }, ji = class {
8903
+ }, Mi = class {
8896
8904
  constructor({ editor: e }) {
8897
8905
  this.editor = e;
8898
8906
  }
@@ -8958,7 +8966,7 @@ var bi = class {
8958
8966
  i.resumeHistory(), n || i.saveState();
8959
8967
  }
8960
8968
  }
8961
- }, Mi = class t {
8969
+ }, Ni = class t {
8962
8970
  constructor({ editor: e }) {
8963
8971
  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();
8964
8972
  }
@@ -9152,7 +9160,7 @@ var bi = class {
9152
9160
  let { options: e } = this.editor, { selectionKey: t } = e;
9153
9161
  return t === void 0 ? ["ctrlKey", "metaKey"] : t;
9154
9162
  }
9155
- }, Ni = class e {
9163
+ }, Pi = class e {
9156
9164
  constructor({ editor: e }) {
9157
9165
  this.editor = e;
9158
9166
  }
@@ -9192,7 +9200,7 @@ var bi = class {
9192
9200
  };
9193
9201
  return i.fire("editor:objects-deleted", l), l;
9194
9202
  }
9195
- }, Pi = {
9203
+ }, Fi = {
9196
9204
  IMAGE_MANAGER: {
9197
9205
  INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
9198
9206
  INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
@@ -9230,7 +9238,7 @@ var bi = class {
9230
9238
  INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
9231
9239
  APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
9232
9240
  }
9233
- }, Fi = class e {
9241
+ }, Ii = class e {
9234
9242
  constructor({ editor: e }) {
9235
9243
  this._buffer = [], this.editor = e;
9236
9244
  }
@@ -9288,9 +9296,9 @@ var bi = class {
9288
9296
  }), this.editor.canvas.fire("editor:warning", s);
9289
9297
  }
9290
9298
  static isValidErrorCode(e) {
9291
- return e ? Object.values(Pi).some((t) => Object.values(t).includes(e)) : !1;
9299
+ return e ? Object.values(Fi).some((t) => Object.values(t).includes(e)) : !1;
9292
9300
  }
9293
- }, Ii = class {
9301
+ }, Li = class {
9294
9302
  constructor({ editor: e }) {
9295
9303
  this.currentBounds = null, this.editor = e;
9296
9304
  }
@@ -9339,32 +9347,32 @@ var bi = class {
9339
9347
  updateBounds() {
9340
9348
  this.currentBounds = this.calculatePanBounds();
9341
9349
  }
9342
- }, Li = ({ textbox: e }) => {
9350
+ }, Ri = ({ textbox: e }) => {
9343
9351
  if (!e.isEditing) return null;
9344
9352
  let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
9345
9353
  return t === n ? null : {
9346
9354
  start: Math.min(t, n),
9347
9355
  end: Math.max(t, n)
9348
9356
  };
9349
- }, Ri = ({ textbox: e }) => {
9357
+ }, zi = ({ textbox: e }) => {
9350
9358
  let t = e.text?.length ?? 0;
9351
9359
  return t <= 0 ? null : {
9352
9360
  start: 0,
9353
9361
  end: t
9354
9362
  };
9355
- }, zi = ({ textbox: e, range: t }) => {
9363
+ }, Bi = ({ textbox: e, range: t }) => {
9356
9364
  if (!t) return !1;
9357
9365
  let n = e.text?.length ?? 0;
9358
9366
  return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
9359
- }, Bi = ({ textbox: e, styles: t, range: n }) => {
9367
+ }, Vi = ({ textbox: e, styles: t, range: n }) => {
9360
9368
  if (!t || !Object.keys(t).length) return !1;
9361
9369
  let { start: r, end: i } = n;
9362
9370
  return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
9363
- }, Vi = ({ textbox: e, range: t, property: n }) => {
9371
+ }, Hi = ({ textbox: e, range: t, property: n }) => {
9364
9372
  if (!t) return;
9365
9373
  let r = e.getSelectionStyles(t.start, t.end, !0);
9366
9374
  if (r.length) return r[0]?.[n];
9367
- }, 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 {
9375
+ }, Ui = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", Wi = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Gi = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Ki = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), qi = class e extends v {
9368
9376
  static {
9369
9377
  this.type = "background-textbox";
9370
9378
  }
@@ -9508,7 +9516,7 @@ var bi = class {
9508
9516
  this._removeShadow(e);
9509
9517
  }
9510
9518
  _getDecorationColorAt(e, t) {
9511
- 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({
9519
+ let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = Wi({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Ui({
9512
9520
  strokeColor: i,
9513
9521
  width: r
9514
9522
  });
@@ -9524,22 +9532,22 @@ var bi = class {
9524
9532
  _getCornerRadii({ width: e, height: t }) {
9525
9533
  let n = e / 2, r = t / 2, i = Math.min(n, r);
9526
9534
  return {
9527
- bottomLeft: Gi({
9535
+ bottomLeft: Ki({
9528
9536
  value: this.radiusBottomLeft ?? 0,
9529
9537
  min: 0,
9530
9538
  max: i
9531
9539
  }),
9532
- bottomRight: Gi({
9540
+ bottomRight: Ki({
9533
9541
  value: this.radiusBottomRight ?? 0,
9534
9542
  min: 0,
9535
9543
  max: i
9536
9544
  }),
9537
- topLeft: Gi({
9545
+ topLeft: Ki({
9538
9546
  value: this.radiusTopLeft ?? 0,
9539
9547
  min: 0,
9540
9548
  max: i
9541
9549
  }),
9542
- topRight: Gi({
9550
+ topRight: Ki({
9543
9551
  value: this.radiusTopRight ?? 0,
9544
9552
  min: 0,
9545
9553
  max: i
@@ -9557,7 +9565,7 @@ var bi = class {
9557
9565
  _getEffectiveBackgroundFill() {
9558
9566
  let e = this.backgroundColor;
9559
9567
  if (!e) return null;
9560
- let t = Gi({
9568
+ let t = Ki({
9561
9569
  value: this.backgroundOpacity ?? 1,
9562
9570
  min: 0,
9563
9571
  max: 1
@@ -9570,19 +9578,19 @@ var bi = class {
9570
9578
  return r.setAlpha(t), r.toRgba();
9571
9579
  }
9572
9580
  static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
9573
- let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Gi({
9581
+ let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Ki({
9574
9582
  value: c,
9575
9583
  min: 0,
9576
9584
  max: a
9577
- }), p = Gi({
9585
+ }), p = Ki({
9578
9586
  value: l,
9579
9587
  min: 0,
9580
9588
  max: a
9581
- }), m = Gi({
9589
+ }), m = Ki({
9582
9590
  value: u,
9583
9591
  min: 0,
9584
9592
  max: a
9585
- }), h = Gi({
9593
+ }), h = Ki({
9586
9594
  value: d,
9587
9595
  min: 0,
9588
9596
  max: a
@@ -9593,20 +9601,20 @@ var bi = class {
9593
9601
  let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
9594
9602
  n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
9595
9603
  }
9596
- }, qi = () => {
9597
- b?.setClass && b.setClass(Ki, "background-textbox");
9598
- }, Ji = ({ transform: e }) => {
9604
+ }, Ji = () => {
9605
+ b?.setClass && b.setClass(qi, "background-textbox");
9606
+ }, Yi = ({ transform: e }) => {
9599
9607
  let { corner: t = "", action: n = "" } = e;
9600
9608
  return {
9601
9609
  isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
9602
9610
  isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
9603
9611
  isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
9604
9612
  };
9605
- }, Yi = ({ textbox: e, transform: t, appliedWidth: n }) => {
9613
+ }, Xi = ({ textbox: e, transform: t, appliedWidth: n }) => {
9606
9614
  t.scaleX = 1, t.scaleY = 1;
9607
9615
  let r = t.original;
9608
9616
  r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
9609
- }, Xi = ({ textbox: e, transform: t, scenePoint: n }) => {
9617
+ }, Zi = ({ textbox: e, transform: t, scenePoint: n }) => {
9610
9618
  let { x: r, y: i } = e._getTransformedDimensions();
9611
9619
  if (r <= 0 || i <= 0) return null;
9612
9620
  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);
@@ -9616,27 +9624,27 @@ var bi = class {
9616
9624
  stepScaleX: l,
9617
9625
  stepScaleY: u
9618
9626
  };
9619
- }, Zi = 1e-4;
9620
- function Qi(e) {
9627
+ }, Qi = 1e-4;
9628
+ function $i(e) {
9621
9629
  return !!e && e instanceof v;
9622
9630
  }
9623
- function $i(e) {
9624
- if (!Qi(e)) return !1;
9631
+ function ea(e) {
9632
+ if (!$i(e)) return !1;
9625
9633
  let t = e.group;
9626
9634
  return e.shapeNodeType === "text" && t?.shapeComposite === !0;
9627
9635
  }
9628
- var ea = class {
9636
+ var ta = class {
9629
9637
  constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
9630
9638
  this.handleMouseMove = (e) => {
9631
9639
  let t = this.canvas._currentTransform;
9632
9640
  if (!t) return;
9633
9641
  let { target: n } = t;
9634
- if (!Qi(n) || $i(n)) return;
9642
+ if (!$i(n) || ea(n)) return;
9635
9643
  let r = this.scalingState.get(n);
9636
9644
  if (!r || !e.e) return;
9637
- let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = Ji({ transform: t });
9645
+ let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = Yi({ transform: t });
9638
9646
  if (!a && !o && !i) return;
9639
- let s = Xi({
9647
+ let s = Zi({
9640
9648
  textbox: n,
9641
9649
  transform: t,
9642
9650
  scenePoint: this.canvas.getScenePoint(e.e)
@@ -9659,18 +9667,18 @@ var ea = class {
9659
9667
  }, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
9660
9668
  if (i) {
9661
9669
  let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
9662
- if (Math.abs(t - r.lastAllowedScaleX) <= Zi) return;
9670
+ if (Math.abs(t - r.lastAllowedScaleX) <= Qi) return;
9663
9671
  j = t, M = t;
9664
9672
  } else {
9665
9673
  if (a) {
9666
9674
  let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
9667
- Math.abs(t - r.lastAllowedScaleX) > Zi && (j = t);
9675
+ Math.abs(t - r.lastAllowedScaleX) > Qi && (j = t);
9668
9676
  }
9669
9677
  if (o) {
9670
9678
  let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
9671
- Math.abs(t - r.lastAllowedScaleY) > Zi && (M = t);
9679
+ Math.abs(t - r.lastAllowedScaleY) > Qi && (M = t);
9672
9680
  }
9673
- if (Math.abs(j - r.lastAllowedScaleX) <= Zi && Math.abs(M - r.lastAllowedScaleY) <= Zi) return;
9681
+ if (Math.abs(j - r.lastAllowedScaleX) <= Qi && Math.abs(M - r.lastAllowedScaleY) <= Qi) return;
9674
9682
  }
9675
9683
  let { appliedWidth: N, dimensionsRounded: P } = kn({
9676
9684
  textbox: n,
@@ -9686,7 +9694,7 @@ var ea = class {
9686
9694
  shouldDisableAutoExpandOnHorizontalChange: a,
9687
9695
  shouldRoundDimensions: !i
9688
9696
  });
9689
- Yi({
9697
+ Xi({
9690
9698
  textbox: n,
9691
9699
  transform: t,
9692
9700
  appliedWidth: N
@@ -9707,12 +9715,12 @@ var ea = class {
9707
9715
  }), this.canvas.requestRenderAll();
9708
9716
  }, this.handleObjectScaling = (t) => {
9709
9717
  let { target: n, transform: r } = t;
9710
- if (n instanceof e || !Qi(n) || $i(n) || !r) return;
9718
+ if (n instanceof e || !$i(n) || ea(n) || !r) return;
9711
9719
  n.isScaling = !0;
9712
9720
  let i = this._ensureScalingState({
9713
9721
  textbox: n,
9714
9722
  transform: r
9715
- }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = Ji({ transform: r }), d = r.corner ?? "", f = c || u;
9723
+ }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = Yi({ transform: r }), d = r.corner ?? "", f = c || u;
9716
9724
  if (!l && !u && !c) return;
9717
9725
  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({
9718
9726
  object: n,
@@ -9741,7 +9749,7 @@ var ea = class {
9741
9749
  shouldDisableAutoExpandOnHorizontalChange: l,
9742
9750
  shouldRoundDimensions: !c
9743
9751
  });
9744
- Yi({
9752
+ Xi({
9745
9753
  textbox: n,
9746
9754
  transform: r,
9747
9755
  appliedWidth: L
@@ -9774,7 +9782,7 @@ var ea = class {
9774
9782
  let { target: n } = t;
9775
9783
  if (n instanceof e) {
9776
9784
  let t = n.getObjects();
9777
- if (!t.some((e) => Qi(e))) return;
9785
+ if (!t.some((e) => $i(e))) return;
9778
9786
  let { scaleX: r = 1, scaleY: i = 1 } = n;
9779
9787
  if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
9780
9788
  this.canvas.discardActiveObject(), t.forEach((e) => {
@@ -9784,7 +9792,7 @@ var ea = class {
9784
9792
  this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
9785
9793
  return;
9786
9794
  }
9787
- if (!Qi(n) || $i(n)) return;
9795
+ if (!$i(n) || ea(n)) return;
9788
9796
  n.isScaling = !1;
9789
9797
  let r = this.scalingState.get(n);
9790
9798
  if (this.scalingState.delete(n), !r?.hasScalingChange) return;
@@ -9809,7 +9817,7 @@ var ea = class {
9809
9817
  }, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
9810
9818
  }
9811
9819
  commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
9812
- if (!Qi(e) || $i(e)) return !1;
9820
+ if (!$i(e) || ea(e)) return !1;
9813
9821
  let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
9814
9822
  if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
9815
9823
  let i = En({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
@@ -9883,7 +9891,7 @@ var ea = class {
9883
9891
  originY: a
9884
9892
  });
9885
9893
  }
9886
- }, ta = class e {
9894
+ }, na = class e {
9887
9895
  constructor({ editor: t }) {
9888
9896
  this._handleTextEditingEntered = (t) => {
9889
9897
  this.isTextEditingActive = !0;
@@ -9896,7 +9904,7 @@ var ea = class {
9896
9904
  if (!e._isTextbox(n)) return;
9897
9905
  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 });
9898
9906
  if (s) {
9899
- let e = Wi({ value: l });
9907
+ let e = Gi({ value: l });
9900
9908
  e !== i && n.set({ text: e }), n.textCaseRaw = l;
9901
9909
  } else n.textCaseRaw = i;
9902
9910
  if (!r && o === void 0 && (n.autoExpand = !0), r) {
@@ -9941,7 +9949,7 @@ var ea = class {
9941
9949
  transform: r,
9942
9950
  event: i ?? null
9943
9951
  });
9944
- }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new ea({
9952
+ }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new ta({
9945
9953
  canvas: t.canvas,
9946
9954
  canvasManager: t.canvasManager,
9947
9955
  persistScaledTextbox: ({ target: e, style: t }) => {
@@ -9950,12 +9958,12 @@ var ea = class {
9950
9958
  style: t
9951
9959
  });
9952
9960
  }
9953
- }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), qi();
9961
+ }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), Ji();
9954
9962
  }
9955
9963
  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 } = {}) {
9956
9964
  let { canvasManager: M, historyManager: N } = this.editor, { canvas: P } = this;
9957
9965
  N.suspendHistory();
9958
- let F = i ?? this._getDefaultFontFamily(), I = Ui({ width: m }), L = Hi({
9966
+ let F = i ?? this._getDefaultFontFamily(), I = Wi({ width: m }), L = Ui({
9959
9967
  strokeColor: p,
9960
9968
  width: I
9961
9969
  }), ee = {
@@ -9984,11 +9992,11 @@ var ea = class {
9984
9992
  radiusBottomRight: w,
9985
9993
  radiusBottomLeft: T,
9986
9994
  ...E
9987
- }, R = new Ki(n, ee), te = r !== !1;
9995
+ }, R = new qi(n, ee), te = r !== !1;
9988
9996
  R.autoExpand = te;
9989
9997
  let ne = E.left !== void 0 || E.top !== void 0;
9990
9998
  if (R.textCaseRaw = R.text ?? "", l) {
9991
- let e = Wi({ value: R.textCaseRaw });
9999
+ let e = Gi({ value: R.textCaseRaw });
9992
10000
  e !== R.text && R.set({ text: e });
9993
10001
  }
9994
10002
  Tn({ textbox: R }) && (R.dirty = !0);
@@ -10038,37 +10046,37 @@ var ea = class {
10038
10046
  top: R,
10039
10047
  originX: te,
10040
10048
  originY: ne
10041
- }), B = a === void 0 ? Li({ textbox: c }) : Yt({
10049
+ }), B = a === void 0 ? Ri({ textbox: c }) : Yt({
10042
10050
  text: l,
10043
10051
  range: a
10044
10052
  }), ae = B ? Xt({
10045
10053
  textbox: c,
10046
10054
  range: B
10047
- }) : null, V = {}, oe = {}, H = {}, U, se, W, G, K = zi({
10055
+ }) : null, V = {}, oe = {}, H = {}, U, se, W, G, K = Bi({
10048
10056
  textbox: c,
10049
10057
  range: B
10050
- }), ce = zi({
10058
+ }), ce = Bi({
10051
10059
  textbox: c,
10052
10060
  range: ae
10053
10061
  }), le = !B || K, ue = le || ce, q = !B;
10054
10062
  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) {
10055
- let e = B ? Vi({
10063
+ let e = B ? Hi({
10056
10064
  textbox: c,
10057
10065
  range: B,
10058
10066
  property: "strokeWidth"
10059
- }) : void 0, t = B ? Vi({
10067
+ }) : void 0, t = B ? Hi({
10060
10068
  textbox: c,
10061
10069
  range: B,
10062
10070
  property: "stroke"
10063
10071
  }) : 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;
10064
- G = Ui({ width: E ?? n ?? c.strokeWidth ?? 0 }), W = Hi({
10072
+ G = Wi({ width: E ?? n ?? c.strokeWidth ?? 0 }), W = Ui({
10065
10073
  strokeColor: T ?? r ?? i,
10066
10074
  width: G
10067
10075
  }), B && (V.stroke = W, V.strokeWidth = G), le && (z.stroke = W, z.strokeWidth = G, q && (H.stroke = W, H.strokeWidth = G));
10068
10076
  }
10069
10077
  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);
10070
10078
  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 ?? "";
10071
- pe || ge ? (z.text = he ? Wi({ value: me }) : me, c.textCaseRaw = me) : c.textCaseRaw === void 0 && (c.textCaseRaw = de);
10079
+ pe || ge ? (z.text = he ? Gi({ value: me }) : me, c.textCaseRaw = me) : c.textCaseRaw === void 0 && (c.textCaseRaw = de);
10072
10080
  let ve = wn({ stylesList: [
10073
10081
  z,
10074
10082
  V,
@@ -10092,19 +10100,19 @@ var ea = class {
10092
10100
  })), c.uppercase = he, c.set(z);
10093
10101
  let Ee = !1;
10094
10102
  if (B) {
10095
- let e = Bi({
10103
+ let e = Vi({
10096
10104
  textbox: c,
10097
10105
  styles: V,
10098
10106
  range: B
10099
- }), t = ae ? Bi({
10107
+ }), t = ae ? Vi({
10100
10108
  textbox: c,
10101
10109
  styles: oe,
10102
10110
  range: ae
10103
10111
  }) : !1;
10104
10112
  Ee = e || t;
10105
10113
  } else if (Object.keys(H).length) {
10106
- let e = Ri({ textbox: c });
10107
- e && (Ee = Bi({
10114
+ let e = zi({ textbox: c });
10115
+ e && (Ee = Vi({
10108
10116
  textbox: c,
10109
10117
  styles: H,
10110
10118
  range: e
@@ -10354,7 +10362,7 @@ var ea = class {
10354
10362
  _getDefaultFontFamily() {
10355
10363
  return this.fonts[0]?.family ?? "Arial";
10356
10364
  }
10357
- }, na = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, ra = (e) => {
10365
+ }, ra = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, ia = (e) => {
10358
10366
  if (!e || typeof e != "object") return null;
10359
10367
  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) => ({
10360
10368
  color: typeof e.color == "string" ? e.color : "#000000",
@@ -10365,7 +10373,7 @@ var ea = class {
10365
10373
  let { x1: e, y1: t, x2: r, y2: i } = n;
10366
10374
  if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
10367
10375
  type: "linear",
10368
- angle: na({
10376
+ angle: ra({
10369
10377
  x1: e,
10370
10378
  y1: t,
10371
10379
  x2: r,
@@ -10393,7 +10401,7 @@ var ea = class {
10393
10401
  };
10394
10402
  }
10395
10403
  return null;
10396
- }, ia = "_templateAnchorX", aa = "_templateAnchorY", oa = class t {
10404
+ }, aa = "_templateAnchorX", oa = "_templateAnchorY", sa = class t {
10397
10405
  constructor({ editor: e }) {
10398
10406
  this.editor = e;
10399
10407
  }
@@ -10402,7 +10410,7 @@ var ea = class {
10402
10410
  if (!p.length) return s.emitWarning({
10403
10411
  origin: "TemplateManager",
10404
10412
  method: "serializeSelection",
10405
- code: Pi.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
10413
+ code: Fi.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
10406
10414
  message: "Нет объектов для сериализации шаблона"
10407
10415
  }), null;
10408
10416
  let m = t._getBounds(o), h = t._getMontageSize({
@@ -10431,14 +10439,14 @@ var ea = class {
10431
10439
  if (!l?.length) return a.emitWarning({
10432
10440
  origin: "TemplateManager",
10433
10441
  method: "applyTemplate",
10434
- code: Pi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
10442
+ code: Fi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
10435
10443
  message: "Шаблон не содержит объектов"
10436
10444
  }), null;
10437
10445
  let f = t._getBounds(r);
10438
10446
  if (!f) return a.emitWarning({
10439
10447
  origin: "TemplateManager",
10440
10448
  method: "applyTemplate",
10441
- code: Pi.TEMPLATE_MANAGER.INVALID_TARGET,
10449
+ code: Fi.TEMPLATE_MANAGER.INVALID_TARGET,
10442
10450
  message: "Не удалось определить границы монтажной области"
10443
10451
  }), null;
10444
10452
  let p = t._getMontageSize({
@@ -10457,7 +10465,7 @@ var ea = class {
10457
10465
  if (!r.length) return a.emitWarning({
10458
10466
  origin: "TemplateManager",
10459
10467
  method: "applyTemplate",
10460
- code: Pi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
10468
+ code: Fi.TEMPLATE_MANAGER.INVALID_TEMPLATE,
10461
10469
  message: "Не удалось создать объекты шаблона"
10462
10470
  }), null;
10463
10471
  let { backgroundObject: i, contentObjects: u } = t._extractBackgroundObject(r);
@@ -10479,10 +10487,7 @@ var ea = class {
10479
10487
  }), c.commitStandaloneTextScale({ target: e }), s.commitRehydratedShapeLayout({
10480
10488
  target: e,
10481
10489
  textScale: h
10482
- }), Bt({ object: e }), e.set({
10483
- id: `${e.type}-${O()}`,
10484
- evented: !0
10485
- }), n.add(e), e));
10490
+ }), Bt({ object: e }), ki({ rootObject: e }), n.add(e), e));
10486
10491
  return !d.length && !v ? null : (_ = d.length > 0 || v, d.length && t._activateObjects({
10487
10492
  canvas: n,
10488
10493
  objects: d
@@ -10495,7 +10500,7 @@ var ea = class {
10495
10500
  return a.emitError({
10496
10501
  origin: "TemplateManager",
10497
10502
  method: "applyTemplate",
10498
- code: Pi.TEMPLATE_MANAGER.APPLY_FAILED,
10503
+ code: Fi.TEMPLATE_MANAGER.APPLY_FAILED,
10499
10504
  message: "Ошибка применения шаблона",
10500
10505
  data: {
10501
10506
  templateId: d,
@@ -10652,8 +10657,8 @@ var ea = class {
10652
10657
  baseHeight: a,
10653
10658
  scale: n,
10654
10659
  useRelativePositions: o,
10655
- anchorX: t._resolveAnchor(s, ia),
10656
- anchorY: t._resolveAnchor(s, aa)
10660
+ anchorX: t._resolveAnchor(s, aa),
10661
+ anchorY: t._resolveAnchor(s, oa)
10657
10662
  })
10658
10663
  }), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
10659
10664
  e.set({
@@ -10728,7 +10733,7 @@ var ea = class {
10728
10733
  });
10729
10734
  if (!i || !a) return;
10730
10735
  e.setCoords();
10731
- let o = e, s = t._resolveAnchor(o, ia), c = typeof e.left == "number" ? e.left : null, l = e.originX ?? "center", u = e.originY ?? "center", d = e.getPointByOrigin(l, u), f = t._getBoundingRect(e), p = f.left + f.width / 2, m = f.left + f.width;
10736
+ let o = e, s = t._resolveAnchor(o, aa), c = typeof e.left == "number" ? e.left : null, l = e.originX ?? "center", u = e.originY ?? "center", d = e.getPointByOrigin(l, u), f = t._getBoundingRect(e), p = f.left + f.width / 2, m = f.left + f.width;
10732
10737
  e.set("width", i), e.initDimensions();
10733
10738
  let h = t._getLongestLineWidth({
10734
10739
  textbox: e,
@@ -10757,10 +10762,10 @@ var ea = class {
10757
10762
  x: (p.left - o) / d,
10758
10763
  y: (p.top - s) / f
10759
10764
  }, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
10760
- return a[ia] = t._detectAnchor({
10765
+ return a[aa] = t._detectAnchor({
10761
10766
  start: h,
10762
10767
  end: _
10763
- }), a[aa] = t._detectAnchor({
10768
+ }), a[oa] = t._detectAnchor({
10764
10769
  start: g,
10765
10770
  end: v
10766
10771
  }), a.left = m.x, a.top = m.y, a;
@@ -10785,7 +10790,7 @@ var ea = class {
10785
10790
  withoutSave: !0
10786
10791
  }), !0;
10787
10792
  if (a === "gradient") {
10788
- let e = ra(r);
10793
+ let e = ia(r);
10789
10794
  if (e) return n.setGradientBackground({
10790
10795
  gradient: e,
10791
10796
  customData: o,
@@ -10806,7 +10811,7 @@ var ea = class {
10806
10811
  r.emitWarning({
10807
10812
  origin: "TemplateManager",
10808
10813
  method: "applyTemplate",
10809
- code: Pi.TEMPLATE_MANAGER.APPLY_FAILED,
10814
+ code: Fi.TEMPLATE_MANAGER.APPLY_FAILED,
10810
10815
  message: "Не удалось применить фон из шаблона",
10811
10816
  data: e
10812
10817
  });
@@ -10842,29 +10847,29 @@ var ea = class {
10842
10847
  enlivenObjectEnlivables(e) {
10843
10848
  return w.enlivenObjectEnlivables(e);
10844
10849
  }
10845
- }, sa = "#3D8BF4", ca = .5, la = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, ua = ({ firstDistance: e, secondDistance: t }) => {
10846
- let n = la({ distance: e }), r = la({ distance: t });
10850
+ }, ca = "#3D8BF4", la = .5, ua = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, da = ({ firstDistance: e, secondDistance: t }) => {
10851
+ let n = ua({ distance: e }), r = ua({ distance: t });
10847
10852
  return {
10848
10853
  firstDisplayDistance: n,
10849
10854
  secondDisplayDistance: r,
10850
10855
  displayDistanceDiff: Math.abs(n - r),
10851
10856
  commonDisplayDistance: Math.max(n, r)
10852
10857
  };
10853
- }, da = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), fa = ({ step: e }) => {
10858
+ }, fa = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), pa = ({ step: e }) => {
10854
10859
  let t = Math.abs(e).toString(), n = t.indexOf(".");
10855
10860
  return n === -1 ? 0 : t.slice(n + 1).length;
10856
- }, pa = ({ value: e, step: t }) => {
10861
+ }, ma = ({ value: e, step: t }) => {
10857
10862
  if (t === 0) return e;
10858
- let n = fa({ step: t }), r = Math.round(e / t) * t;
10863
+ let n = pa({ step: t }), r = Math.round(e / t) * t;
10859
10864
  return Number(r.toFixed(n));
10860
- }, ma = ({ value: e, step: t }) => {
10865
+ }, ha = ({ value: e, step: t }) => {
10861
10866
  if (t === 0) return !0;
10862
- let n = pa({
10867
+ let n = ma({
10863
10868
  value: e,
10864
10869
  step: t
10865
- }), r = 10 ** -(fa({ step: t }) + 4);
10870
+ }), r = 10 ** -(pa({ step: t }) + 4);
10866
10871
  return Math.abs(n - e) <= r;
10867
- }, ha = ({ bounds: e, axis: t }) => {
10872
+ }, ga = ({ bounds: e, axis: t }) => {
10868
10873
  let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
10869
10874
  return t === "vertical" ? {
10870
10875
  start: i,
@@ -10873,7 +10878,7 @@ var ea = class {
10873
10878
  start: n,
10874
10879
  end: r
10875
10880
  };
10876
- }, ga = ({ items: e, axis: t }) => {
10881
+ }, _a = ({ items: e, axis: t }) => {
10877
10882
  for (let n = 1; n < e.length; n += 1) {
10878
10883
  let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
10879
10884
  for (; o >= 0;) {
@@ -10883,10 +10888,10 @@ var ea = class {
10883
10888
  }
10884
10889
  e[o + 1] = r;
10885
10890
  }
10886
- }, _a = ({ items: e, index: t, axis: n, direction: r }) => {
10891
+ }, va = ({ items: e, index: t, axis: n, direction: r }) => {
10887
10892
  let i = e[t];
10888
10893
  if (!i) return null;
10889
- let { bounds: a } = i, { start: o, end: s } = ha({
10894
+ let { bounds: a } = i, { start: o, end: s } = ga({
10890
10895
  bounds: a,
10891
10896
  axis: n
10892
10897
  });
@@ -10894,7 +10899,7 @@ var ea = class {
10894
10899
  for (let r = t - 1; r >= 0; --r) {
10895
10900
  let t = e[r];
10896
10901
  if (!t) continue;
10897
- let { bounds: i } = t, { end: a } = ha({
10902
+ let { bounds: i } = t, { end: a } = ga({
10898
10903
  bounds: i,
10899
10904
  axis: n
10900
10905
  });
@@ -10905,26 +10910,26 @@ var ea = class {
10905
10910
  for (let r = t + 1; r < e.length; r += 1) {
10906
10911
  let t = e[r];
10907
10912
  if (!t) continue;
10908
- let { bounds: i } = t, { start: a } = ha({
10913
+ let { bounds: i } = t, { start: a } = ga({
10909
10914
  bounds: i,
10910
10915
  axis: n
10911
10916
  });
10912
10917
  if (a - s >= 0) return r;
10913
10918
  }
10914
10919
  return null;
10915
- }, va = ({ items: e }) => {
10920
+ }, ya = ({ items: e }) => {
10916
10921
  for (let t = 0; t < e.length; t += 1) {
10917
10922
  let { isActive: n } = e[t];
10918
10923
  if (n) return t;
10919
10924
  }
10920
10925
  return -1;
10921
- }, ya = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
10926
+ }, ba = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
10922
10927
  let i = Math.min(t, n), a = Math.max(t, n);
10923
10928
  return e >= i - r && e <= a + r;
10924
- }, ba = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, xa = ({ baseOption: e, candidateOption: t }) => {
10929
+ }, xa = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Sa = ({ baseOption: e, candidateOption: t }) => {
10925
10930
  let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
10926
10931
  return n === i && r === a;
10927
- }, Sa = ({ options: e }) => {
10932
+ }, Ca = ({ options: e }) => {
10928
10933
  let t = e[0];
10929
10934
  for (let n = 1; n < e.length; n += 1) {
10930
10935
  let r = e[n];
@@ -10935,11 +10940,11 @@ var ea = class {
10935
10940
  r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
10936
10941
  }
10937
10942
  return t;
10938
- }, Ca = ({ currentOption: e, nextOption: t }) => {
10943
+ }, wa = ({ currentOption: e, nextOption: t }) => {
10939
10944
  if (!e) return !0;
10940
10945
  let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
10941
10946
  return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
10942
- }, wa = ({ options: e }) => {
10947
+ }, Ta = ({ options: e }) => {
10943
10948
  let t = [], n = null, r = null;
10944
10949
  for (let i of e) {
10945
10950
  let { kind: e, side: a } = i;
@@ -10947,18 +10952,18 @@ var ea = class {
10947
10952
  t.push(i);
10948
10953
  continue;
10949
10954
  }
10950
- a === "before" && Ca({
10955
+ a === "before" && wa({
10951
10956
  currentOption: n,
10952
10957
  nextOption: i
10953
- }) && (n = i), a === "after" && Ca({
10958
+ }) && (n = i), a === "after" && wa({
10954
10959
  currentOption: r,
10955
10960
  nextOption: i
10956
10961
  }) && (r = i);
10957
10962
  }
10958
10963
  return n && t.push(n), r && t.push(r), t;
10959
- }, Ta = ({ options: e, side: t, baseOption: n }) => {
10964
+ }, Ea = ({ options: e, side: t, baseOption: n }) => {
10960
10965
  let r = null;
10961
- for (let i of e) if (i.side === t && xa({
10966
+ for (let i of e) if (i.side === t && Sa({
10962
10967
  baseOption: n,
10963
10968
  candidateOption: i
10964
10969
  })) {
@@ -10969,63 +10974,63 @@ var ea = class {
10969
10974
  !r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
10970
10975
  }
10971
10976
  return r;
10972
- }, Ea = ({ option: e }) => {
10977
+ }, Da = ({ option: e }) => {
10973
10978
  let { side: t, kind: n, guide: { distance: r } } = e;
10974
10979
  return {
10975
10980
  side: t,
10976
10981
  kind: n,
10977
10982
  distance: r
10978
10983
  };
10979
- }, Da = ({ option: e, context: t }) => {
10984
+ }, Oa = ({ option: e, context: t }) => {
10980
10985
  let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
10981
10986
  return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
10982
- }, Oa = ({ options: e, context: t }) => {
10987
+ }, ka = ({ options: e, context: t }) => {
10983
10988
  if (!t) return null;
10984
- for (let n of e) if (Da({
10989
+ for (let n of e) if (Oa({
10985
10990
  option: n,
10986
10991
  context: t
10987
10992
  })) return n;
10988
10993
  return null;
10989
- }, ka = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
10990
- let i = Oa({
10994
+ }, Aa = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
10995
+ let i = ka({
10991
10996
  options: e,
10992
10997
  context: n
10993
10998
  });
10994
10999
  if (!i) return t;
10995
11000
  let a = Math.max(0, r);
10996
11001
  return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
10997
- }, Aa = ({ guides: e, seenGuideKeys: t, guide: n }) => {
11002
+ }, ja = ({ guides: e, seenGuideKeys: t, guide: n }) => {
10998
11003
  let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
10999
11004
  t.has(u) || (t.add(u), e.push(n));
11000
- }, ja = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
11005
+ }, Ma = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
11001
11006
  if (!e.length) return {
11002
11007
  delta: 0,
11003
11008
  guides: [],
11004
11009
  context: null
11005
11010
  };
11006
- let r = wa({ options: e }), i = [];
11011
+ let r = Ta({ options: e }), i = [];
11007
11012
  for (let e of r) e.kind === "reference" && i.push(e);
11008
- let a = i.length > 0, o = a ? i : r, s = ka({
11013
+ let a = i.length > 0, o = a ? i : r, s = Aa({
11009
11014
  options: o,
11010
- bestOption: Sa({ options: o }),
11015
+ bestOption: Ca({ options: o }),
11011
11016
  previousContext: t,
11012
11017
  switchDistance: n
11013
- }), c = Ta({
11018
+ }), c = Ea({
11014
11019
  options: o,
11015
11020
  side: "before",
11016
11021
  baseOption: s
11017
- }), l = Ta({
11022
+ }), l = Ea({
11018
11023
  options: o,
11019
11024
  side: "after",
11020
11025
  baseOption: s
11021
- }), u = Ta({
11026
+ }), u = Ea({
11022
11027
  options: a ? r : o,
11023
11028
  side: "center",
11024
11029
  baseOption: s
11025
11030
  }), d = [];
11026
11031
  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);
11027
11032
  let f = [], p = /* @__PURE__ */ new Set();
11028
- for (let e of d) Aa({
11033
+ for (let e of d) ja({
11029
11034
  guides: f,
11030
11035
  seenGuideKeys: p,
11031
11036
  guide: e.guide
@@ -11033,15 +11038,15 @@ var ea = class {
11033
11038
  return {
11034
11039
  delta: s.delta,
11035
11040
  guides: f,
11036
- context: Ea({ option: s })
11041
+ context: Da({ option: s })
11037
11042
  };
11038
- }, Ma = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
11039
- let s = n - (e - r), c = pa({
11043
+ }, Na = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
11044
+ let s = n - (e - r), c = ma({
11040
11045
  value: s,
11041
11046
  step: o
11042
11047
  }), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
11043
11048
  for (let d = -l; d <= l; d += 1) {
11044
- let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = ua({
11049
+ let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = da({
11045
11050
  firstDistance: m,
11046
11051
  secondDistance: h
11047
11052
  });
@@ -11056,13 +11061,13 @@ var ea = class {
11056
11061
  });
11057
11062
  }
11058
11063
  return u;
11059
- }, Na = ({ currentGap: e, referenceGap: t }) => {
11060
- let { secondDisplayDistance: n, displayDistanceDiff: r } = ua({
11064
+ }, Pa = ({ currentGap: e, referenceGap: t }) => {
11065
+ let { secondDisplayDistance: n, displayDistanceDiff: r } = da({
11061
11066
  firstDistance: e,
11062
11067
  secondDistance: t
11063
11068
  });
11064
11069
  return r > 1 ? null : n;
11065
- }, Pa = ({ anchors: e, positions: t, threshold: n }) => {
11070
+ }, Fa = ({ anchors: e, positions: t, threshold: n }) => {
11066
11071
  let r = 0, i = n + 1, a = null;
11067
11072
  for (let o of t) for (let t of e) {
11068
11073
  let e = Math.abs(t - o);
@@ -11072,8 +11077,8 @@ var ea = class {
11072
11077
  delta: r,
11073
11078
  guidePosition: a
11074
11079
  };
11075
- }, Fa = ({ activeBounds: e, threshold: t, anchors: n }) => {
11076
- let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Pa({
11080
+ }, Ia = ({ activeBounds: e, threshold: t, anchors: n }) => {
11081
+ let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Fa({
11077
11082
  anchors: n.vertical,
11078
11083
  positions: [
11079
11084
  r,
@@ -11081,7 +11086,7 @@ var ea = class {
11081
11086
  i
11082
11087
  ],
11083
11088
  threshold: t
11084
- }), u = Pa({
11089
+ }), u = Fa({
11085
11090
  anchors: n.horizontal,
11086
11091
  positions: [
11087
11092
  o,
@@ -11101,11 +11106,11 @@ var ea = class {
11101
11106
  deltaY: u.delta,
11102
11107
  guides: d
11103
11108
  };
11104
- }, Ia = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11109
+ }, La = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11105
11110
  let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
11106
11111
  for (let e of t) {
11107
11112
  let { left: t, right: n } = e;
11108
- da({
11113
+ fa({
11109
11114
  firstStart: t,
11110
11115
  firstEnd: n,
11111
11116
  secondStart: l,
@@ -11125,22 +11130,22 @@ var ea = class {
11125
11130
  f.push({
11126
11131
  bounds: e,
11127
11132
  isActive: !0
11128
- }), ga({
11133
+ }), _a({
11129
11134
  items: f,
11130
11135
  axis: "top"
11131
11136
  });
11132
- let p = va({ items: f });
11137
+ let p = ya({ items: f });
11133
11138
  if (p === -1) return {
11134
11139
  delta: 0,
11135
11140
  guides: [],
11136
11141
  context: null
11137
11142
  };
11138
- let m = [], h = c - s, g = _a({
11143
+ let m = [], h = c - s, g = va({
11139
11144
  items: f,
11140
11145
  index: p,
11141
11146
  axis: "vertical",
11142
11147
  direction: "prev"
11143
- }), _ = _a({
11148
+ }), _ = va({
11144
11149
  items: f,
11145
11150
  index: p,
11146
11151
  axis: "vertical",
@@ -11149,19 +11154,19 @@ var ea = class {
11149
11154
  if (v && y) {
11150
11155
  let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
11151
11156
  if (a >= 0) {
11152
- let e = pa({
11157
+ let e = ma({
11153
11158
  value: a / 2,
11154
11159
  step: 1
11155
11160
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
11156
11161
  if (Math.max(u, d) <= n) {
11157
- let t = Ma({
11162
+ let t = Na({
11158
11163
  activeStart: s,
11159
11164
  activeEnd: c,
11160
11165
  targetGap: e,
11161
11166
  beforeEdge: r,
11162
11167
  afterEdge: i,
11163
11168
  threshold: n,
11164
- step: ca
11169
+ step: la
11165
11170
  });
11166
11171
  if (t) {
11167
11172
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -11198,16 +11203,16 @@ var ea = class {
11198
11203
  }
11199
11204
  for (let e of r) {
11200
11205
  let { axis: t, start: r, end: i, distance: a } = e;
11201
- if (!ma({
11206
+ if (!ha({
11202
11207
  value: a,
11203
11208
  step: .5
11204
- }) || !ya({
11209
+ }) || !ba({
11205
11210
  patternAxis: t,
11206
11211
  activeRangeStart: l,
11207
11212
  activeRangeEnd: u,
11208
11213
  tolerance: n
11209
11214
  })) continue;
11210
- let d = ba({
11215
+ let d = xa({
11211
11216
  patternStart: r,
11212
11217
  patternEnd: i,
11213
11218
  activeStart: s,
@@ -11215,12 +11220,12 @@ var ea = class {
11215
11220
  });
11216
11221
  if (d) {
11217
11222
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
11218
- let e = pa({
11223
+ let e = ma({
11219
11224
  value: a - b,
11220
11225
  step: 1
11221
11226
  }), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
11222
11227
  if (u > n) continue;
11223
- let d = Na({
11228
+ let d = Pa({
11224
11229
  currentGap: l,
11225
11230
  referenceGap: a
11226
11231
  });
@@ -11244,12 +11249,12 @@ var ea = class {
11244
11249
  });
11245
11250
  }
11246
11251
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
11247
- let e = pa({
11252
+ let e = ma({
11248
11253
  value: x - a,
11249
11254
  step: 1
11250
11255
  }), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
11251
11256
  if (u > n) continue;
11252
- let d = Na({
11257
+ let d = Pa({
11253
11258
  currentGap: l,
11254
11259
  referenceGap: a
11255
11260
  });
@@ -11274,16 +11279,16 @@ var ea = class {
11274
11279
  }
11275
11280
  }
11276
11281
  }
11277
- return ja({
11282
+ return Ma({
11278
11283
  options: m,
11279
11284
  previousContext: i,
11280
11285
  switchDistance: a
11281
11286
  });
11282
- }, La = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11287
+ }, Ra = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
11283
11288
  let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
11284
11289
  for (let e of t) {
11285
11290
  let { top: t, bottom: n } = e;
11286
- da({
11291
+ fa({
11287
11292
  firstStart: t,
11288
11293
  firstEnd: n,
11289
11294
  secondStart: l,
@@ -11303,22 +11308,22 @@ var ea = class {
11303
11308
  f.push({
11304
11309
  bounds: e,
11305
11310
  isActive: !0
11306
- }), ga({
11311
+ }), _a({
11307
11312
  items: f,
11308
11313
  axis: "left"
11309
11314
  });
11310
- let p = va({ items: f });
11315
+ let p = ya({ items: f });
11311
11316
  if (p === -1) return {
11312
11317
  delta: 0,
11313
11318
  guides: [],
11314
11319
  context: null
11315
11320
  };
11316
- let m = [], h = c - s, g = _a({
11321
+ let m = [], h = c - s, g = va({
11317
11322
  items: f,
11318
11323
  index: p,
11319
11324
  axis: "horizontal",
11320
11325
  direction: "prev"
11321
- }), _ = _a({
11326
+ }), _ = va({
11322
11327
  items: f,
11323
11328
  index: p,
11324
11329
  axis: "horizontal",
@@ -11327,19 +11332,19 @@ var ea = class {
11327
11332
  if (v && y) {
11328
11333
  let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
11329
11334
  if (a >= 0) {
11330
- let e = pa({
11335
+ let e = ma({
11331
11336
  value: a / 2,
11332
11337
  step: 1
11333
11338
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
11334
11339
  if (Math.max(u, d) <= n) {
11335
- let t = Ma({
11340
+ let t = Na({
11336
11341
  activeStart: s,
11337
11342
  activeEnd: c,
11338
11343
  targetGap: e,
11339
11344
  beforeEdge: r,
11340
11345
  afterEdge: i,
11341
11346
  threshold: n,
11342
- step: ca
11347
+ step: la
11343
11348
  });
11344
11349
  if (t) {
11345
11350
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -11376,16 +11381,16 @@ var ea = class {
11376
11381
  }
11377
11382
  for (let e of r) {
11378
11383
  let { axis: t, start: r, end: i, distance: a } = e;
11379
- if (!ma({
11384
+ if (!ha({
11380
11385
  value: a,
11381
11386
  step: .5
11382
- }) || !ya({
11387
+ }) || !ba({
11383
11388
  patternAxis: t,
11384
11389
  activeRangeStart: l,
11385
11390
  activeRangeEnd: u,
11386
11391
  tolerance: n
11387
11392
  })) continue;
11388
- let d = ba({
11393
+ let d = xa({
11389
11394
  patternStart: r,
11390
11395
  patternEnd: i,
11391
11396
  activeStart: s,
@@ -11393,12 +11398,12 @@ var ea = class {
11393
11398
  });
11394
11399
  if (d) {
11395
11400
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
11396
- let e = pa({
11401
+ let e = ma({
11397
11402
  value: a - b,
11398
11403
  step: 1
11399
11404
  }), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
11400
11405
  if (u > n) continue;
11401
- let d = Na({
11406
+ let d = Pa({
11402
11407
  currentGap: l,
11403
11408
  referenceGap: a
11404
11409
  });
@@ -11422,12 +11427,12 @@ var ea = class {
11422
11427
  });
11423
11428
  }
11424
11429
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
11425
- let e = pa({
11430
+ let e = ma({
11426
11431
  value: x - a,
11427
11432
  step: 1
11428
11433
  }), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
11429
11434
  if (u > n) continue;
11430
- let d = Na({
11435
+ let d = Pa({
11431
11436
  currentGap: l,
11432
11437
  referenceGap: a
11433
11438
  });
@@ -11452,20 +11457,20 @@ var ea = class {
11452
11457
  }
11453
11458
  }
11454
11459
  }
11455
- return ja({
11460
+ return Ma({
11456
11461
  options: m,
11457
11462
  previousContext: i,
11458
11463
  switchDistance: a
11459
11464
  });
11460
- }, Ra = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
11461
- let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Ia({
11465
+ }, za = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
11466
+ let { vertical: o = null, horizontal: s = null } = i ?? {}, c = La({
11462
11467
  activeBounds: e,
11463
11468
  candidates: t,
11464
11469
  threshold: n,
11465
11470
  patterns: r.vertical,
11466
11471
  previousContext: o,
11467
11472
  switchDistance: a
11468
- }), l = La({
11473
+ }), l = Ra({
11469
11474
  activeBounds: e,
11470
11475
  candidates: t,
11471
11476
  threshold: n,
@@ -11484,14 +11489,14 @@ var ea = class {
11484
11489
  horizontal: l.context
11485
11490
  }
11486
11491
  };
11487
- }, za = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
11492
+ }, Ba = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
11488
11493
  let o = Math.min(a, r / 2, i / 2);
11489
11494
  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();
11490
- }, 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 }) => {
11495
+ }, Va = ({ 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 }) => {
11491
11496
  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;
11492
11497
  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";
11493
11498
  let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
11494
- e.beginPath(), za({
11499
+ e.beginPath(), Ba({
11495
11500
  context: e,
11496
11501
  x: w,
11497
11502
  y: T,
@@ -11499,11 +11504,11 @@ var ea = class {
11499
11504
  height: C,
11500
11505
  radius: v
11501
11506
  }), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
11502
- }, Va = ({ context: e, guide: t, zoom: n }) => {
11503
- let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = la({ distance: l }).toString();
11507
+ }, Ha = ({ context: e, guide: t, zoom: n }) => {
11508
+ let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = ua({ distance: l }).toString();
11504
11509
  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();
11505
- let d = sa;
11506
- Ba({
11510
+ let d = ca;
11511
+ Va({
11507
11512
  context: e,
11508
11513
  type: r,
11509
11514
  axis: i,
@@ -11513,7 +11518,7 @@ var ea = class {
11513
11518
  zoom: n,
11514
11519
  color: d,
11515
11520
  lineWidth: 1
11516
- }), Ba({
11521
+ }), Va({
11517
11522
  context: e,
11518
11523
  type: r,
11519
11524
  axis: i,
@@ -11524,10 +11529,10 @@ var ea = class {
11524
11529
  color: d,
11525
11530
  lineWidth: 1
11526
11531
  });
11527
- }, Ha = ({ anchors: e, bounds: t }) => {
11532
+ }, Ua = ({ anchors: e, bounds: t }) => {
11528
11533
  let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
11529
11534
  e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
11530
- }, Ua = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
11535
+ }, Wa = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
11531
11536
  let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
11532
11537
  for (let e = 0; e < s.length; e += 1) {
11533
11538
  let c = s[e], l = null, u = Infinity;
@@ -11548,35 +11553,35 @@ var ea = class {
11548
11553
  });
11549
11554
  }
11550
11555
  return i;
11551
- }, Wa = ({ bounds: e }) => ({
11552
- vertical: Ua({
11556
+ }, Ga = ({ bounds: e }) => ({
11557
+ vertical: Wa({
11553
11558
  bounds: e,
11554
11559
  axis: "centerX",
11555
11560
  type: "vertical",
11556
11561
  primaryStart: "top",
11557
11562
  primaryEnd: "bottom"
11558
11563
  }),
11559
- horizontal: Ua({
11564
+ horizontal: Wa({
11560
11565
  bounds: e,
11561
11566
  axis: "centerY",
11562
11567
  type: "horizontal",
11563
11568
  primaryStart: "left",
11564
11569
  primaryEnd: "right"
11565
11570
  })
11566
- }), Ga = [
11571
+ }), Ka = [
11567
11572
  "montage-area",
11568
11573
  "background",
11569
11574
  "interaction-blocker"
11570
- ], Ka = ({ activeObject: t }) => {
11575
+ ], qa = ({ activeObject: t }) => {
11571
11576
  let n = /* @__PURE__ */ new Set();
11572
11577
  return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
11573
- }, qa = ({ object: e, excluded: t, ignoredIds: n = Ga }) => {
11578
+ }, Ja = ({ object: e, excluded: t, ignoredIds: n = Ka }) => {
11574
11579
  if (t.has(e)) return !0;
11575
11580
  let { visible: r = !0 } = e;
11576
11581
  if (!r) return !0;
11577
11582
  let { id: i } = e;
11578
11583
  return !!(i && n.includes(i));
11579
- }, Ja = class e {
11584
+ }, Ya = class e {
11580
11585
  constructor({ editor: e }) {
11581
11586
  this.anchors = {
11582
11587
  vertical: [],
@@ -11629,7 +11634,7 @@ var ea = class {
11629
11634
  this._clearSpacingContexts(), this._clearGuides();
11630
11635
  return;
11631
11636
  }
11632
- let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Fa({
11637
+ let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Ia({
11633
11638
  activeBounds: a,
11634
11639
  threshold: c,
11635
11640
  anchors: this.anchors
@@ -11641,7 +11646,7 @@ var ea = class {
11641
11646
  top: t + u
11642
11647
  }), n.setCoords(), a = Vt({ object: n }) ?? a;
11643
11648
  }
11644
- let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = Ra({
11649
+ let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = za({
11645
11650
  activeBounds: a,
11646
11651
  candidates: d,
11647
11652
  threshold: f,
@@ -11662,11 +11667,11 @@ var ea = class {
11662
11667
  target: n,
11663
11668
  transform: i
11664
11669
  });
11665
- let h = Vt({ object: n }) ?? a, g = Fa({
11670
+ let h = Vt({ object: n }) ?? a, g = Ia({
11666
11671
  activeBounds: h,
11667
11672
  threshold: c,
11668
11673
  anchors: this.anchors
11669
- }), _ = Ra({
11674
+ }), _ = za({
11670
11675
  activeBounds: h,
11671
11676
  candidates: d,
11672
11677
  threshold: c,
@@ -11897,9 +11902,9 @@ var ea = class {
11897
11902
  let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
11898
11903
  if (!n) return;
11899
11904
  let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
11900
- n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = sa, n.setLineDash([4, 4]);
11905
+ n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = ca, n.setLineDash([4, 4]);
11901
11906
  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();
11902
- for (let e of this.activeSpacingGuides) Va({
11907
+ for (let e of this.activeSpacingGuides) Ha({
11903
11908
  context: n,
11904
11909
  guide: e,
11905
11910
  zoom: c
@@ -12110,14 +12115,14 @@ var ea = class {
12110
12115
  }, r = [];
12111
12116
  for (let e of t) {
12112
12117
  let t = Vt({ object: e });
12113
- t && (Ha({
12118
+ t && (Ua({
12114
12119
  anchors: n,
12115
12120
  bounds: t
12116
12121
  }), r.push(t));
12117
12122
  }
12118
12123
  let { montageArea: i } = this.editor, a = Vt({ object: i });
12119
12124
  if (a) {
12120
- Ha({
12125
+ Ua({
12121
12126
  anchors: n,
12122
12127
  bounds: a
12123
12128
  });
@@ -12129,12 +12134,12 @@ var ea = class {
12129
12134
  bottom: i
12130
12135
  };
12131
12136
  } else this.guideBounds = this._calculateViewportBounds();
12132
- this.anchors = n, this.spacingPatterns = Wa({ bounds: r }), this.cachedTargetBounds = r;
12137
+ this.anchors = n, this.spacingPatterns = Ga({ bounds: r }), this.cachedTargetBounds = r;
12133
12138
  }
12134
12139
  _collectTargets({ activeObject: e }) {
12135
- let t = Ka({ activeObject: e }), n = [];
12140
+ let t = qa({ activeObject: e }), n = [];
12136
12141
  return this.canvas.forEachObject((e) => {
12137
- qa({
12142
+ Ja({
12138
12143
  object: e,
12139
12144
  excluded: t
12140
12145
  }) || n.push(e);
@@ -12157,7 +12162,7 @@ var ea = class {
12157
12162
  bottom: (r - s) / a
12158
12163
  };
12159
12164
  }
12160
- }, Ya = "#3D8BF4", Xa = class e {
12165
+ }, Xa = "#3D8BF4", Za = class e {
12161
12166
  constructor({ editor: e }) {
12162
12167
  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();
12163
12168
  }
@@ -12250,8 +12255,8 @@ var ea = class {
12250
12255
  this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
12251
12256
  }
12252
12257
  static _resolveTarget({ event: e, activeObject: t }) {
12253
- let { target: n } = e, r = Ka({ activeObject: t });
12254
- return n && !qa({
12258
+ let { target: n } = e, r = qa({ activeObject: t });
12259
+ return n && !Ja({
12255
12260
  object: n,
12256
12261
  excluded: r
12257
12262
  }) ? n : null;
@@ -12368,18 +12373,18 @@ var ea = class {
12368
12373
  let { canvas: e } = this, t = e.getSelectionContext();
12369
12374
  if (!t) return;
12370
12375
  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;
12371
- t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Ya, t.setLineDash([]);
12376
+ t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Xa, t.setLineDash([]);
12372
12377
  for (let e of this.activeGuides) {
12373
12378
  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;
12374
- t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Ba({
12379
+ t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Va({
12375
12380
  context: t,
12376
12381
  type: n,
12377
12382
  axis: i,
12378
12383
  start: a,
12379
12384
  end: c,
12380
- text: la({ distance: l }).toString(),
12385
+ text: ua({ distance: l }).toString(),
12381
12386
  zoom: r,
12382
- color: Ya,
12387
+ color: Xa,
12383
12388
  lineWidth: 1,
12384
12389
  offsetAlongAxis: d,
12385
12390
  offsetPerpendicular: 0
@@ -12397,13 +12402,13 @@ var ea = class {
12397
12402
  let { toolbar: e } = this.editor;
12398
12403
  e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
12399
12404
  }
12400
- }, Za = class e {
12405
+ }, Qa = class e {
12401
12406
  constructor(e, t) {
12402
12407
  this.options = t, this.containerId = e, this.editorId = `${e}-${O()}`, this.init();
12403
12408
  }
12404
12409
  async init() {
12405
12410
  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;
12406
- 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({
12411
+ if (U.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new j(), this.workerManager = new N(), this.errorManager = new Ii({ 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 Ai({ editor: this }), this.objectLockManager = new ji({ editor: this }), this.groupingManager = new Mi({ editor: this }), this.selectionManager = new Ni({ editor: this }), this.deletionManager = new Pi({ editor: this }), this.panConstraintManager = new Li({ editor: this }), this.snappingManager = new Ya({ editor: this }), this.measurementManager = new Za({ editor: this }), this.fontManager = new se(this.options.fonts ?? []), this.textManager = new na({ editor: this }), this.templateManager = new sa({ editor: this }), u && (this.angleIndicator = new Ze({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new A({
12407
12412
  editor: this,
12408
12413
  options: this.options
12409
12414
  }), 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) {
@@ -12511,7 +12516,7 @@ var ea = class {
12511
12516
  "U+A640-A69F",
12512
12517
  "U+FE2E-FE2F",
12513
12518
  "U+2116"
12514
- ].join(", "), Qa = {
12519
+ ].join(", "), $a = {
12515
12520
  preserveObjectStacking: !0,
12516
12521
  controlsAboveOverlay: !0,
12517
12522
  centeredRotation: !0,
@@ -13365,20 +13370,20 @@ var ea = class {
13365
13370
  };
13366
13371
  //#endregion
13367
13372
  //#region src/main.ts
13368
- function $a(e, t = {}) {
13373
+ function eo(e, t = {}) {
13369
13374
  let n = {
13370
- ...Qa,
13375
+ ...$a,
13371
13376
  ...t
13372
13377
  }, r = document.getElementById(e);
13373
13378
  if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
13374
13379
  let i = document.createElement("canvas");
13375
13380
  return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
13376
13381
  n._onReadyCallback = t;
13377
- let r = new Za(i.id, n);
13382
+ let r = new Qa(i.id, n);
13378
13383
  window[e] = r;
13379
13384
  });
13380
13385
  }
13381
13386
  //#endregion
13382
- export { $a as default };
13387
+ export { eo as default };
13383
13388
 
13384
13389
  //# sourceMappingURL=main.js.map