@anu3ev/fabric-image-editor 0.9.14 → 0.9.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +823 -701
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -5976,7 +5976,7 @@ var ci = ({ transform: e, key: t }) => {
5976
5976
  if (!n || typeof n != "object") return null;
5977
5977
  let r = n[t];
5978
5978
  return typeof r != "number" || !Number.isFinite(r) ? null : r;
5979
- }, li = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, ui = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, Y = ({ transform: e }) => {
5979
+ }, li = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, ui = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, di = ({ transform: e }) => {
5980
5980
  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;
5981
5981
  return {
5982
5982
  canScaleWidth: o,
@@ -5984,37 +5984,37 @@ var ci = ({ transform: e, key: t }) => {
5984
5984
  isCornerScaleAction: r,
5985
5985
  isVerticalOnlyScale: s && !o
5986
5986
  };
5987
- }, di = ({ event: e, target: t, transform: n, canvas: r }) => {
5987
+ }, fi = ({ event: e, target: t, transform: n, canvas: r }) => {
5988
5988
  if (!e) return null;
5989
5989
  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;
5990
5990
  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;
5991
- }, fi = ({ group: e, originX: t, originY: n }) => {
5991
+ }, pi = ({ group: e, originX: t, originY: n }) => {
5992
5992
  if (t === null || n === null) return null;
5993
5993
  let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
5994
5994
  return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
5995
- }, pi = ({ state: e, transform: t }) => {
5995
+ }, mi = ({ state: e, transform: t }) => {
5996
5996
  if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
5997
5997
  let n = li({ value: t.originX }), r = ui({ value: t.originY });
5998
5998
  return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
5999
- }, mi = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
5999
+ }, hi = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
6000
6000
  //#endregion
6001
6001
  //#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
6002
- function hi({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
6002
+ function gi({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
6003
6003
  let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
6004
6004
  return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
6005
6005
  }
6006
- function gi({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
6006
+ function _i({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
6007
6007
  let c = Math.max(0, e.shapeStrokeWidth ?? 0);
6008
6008
  Gn({
6009
6009
  shape: t,
6010
- width: hi({
6010
+ width: gi({
6011
6011
  size: n,
6012
6012
  scale: i,
6013
6013
  strokeWidth: c,
6014
6014
  minSize: o,
6015
6015
  scaleEpsilon: s
6016
6016
  }),
6017
- height: hi({
6017
+ height: gi({
6018
6018
  size: r,
6019
6019
  scale: a,
6020
6020
  strokeWidth: c,
@@ -6025,7 +6025,7 @@ function gi({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
6025
6025
  strokeWidth: c
6026
6026
  });
6027
6027
  }
6028
- function _i({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon: a }) {
6028
+ function vi({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon: a }) {
6029
6029
  let o = Math.max(a, Math.abs(r) || 1), s = Math.max(a, Math.abs(i) || 1), c = n ?? "center";
6030
6030
  e.set({
6031
6031
  autoExpand: !1,
@@ -6040,13 +6040,13 @@ function _i({ text: e, layout: t, alignH: n, scaleX: r, scaleY: i, scaleEpsilon:
6040
6040
  scaleY: 1 / s
6041
6041
  }), e.initDimensions(), e.setCoords();
6042
6042
  }
6043
- var vi = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY: o, minSize: s, scaleEpsilon: c }) => {
6043
+ var yi = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY: o, minSize: s, scaleEpsilon: c }) => {
6044
6044
  let l = Math.max(c, Math.abs(a) || 1), u = Math.max(c, Math.abs(o) || 1);
6045
6045
  e.set({
6046
6046
  width: r.width / l,
6047
6047
  height: r.height / u,
6048
6048
  dirty: !0
6049
- }), gi({
6049
+ }), _i({
6050
6050
  group: e,
6051
6051
  shape: t,
6052
6052
  width: r.width,
@@ -6055,7 +6055,7 @@ var vi = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
6055
6055
  scaleY: o,
6056
6056
  minSize: s,
6057
6057
  scaleEpsilon: c
6058
- }), _i({
6058
+ }), vi({
6059
6059
  text: n,
6060
6060
  layout: r,
6061
6061
  alignH: i,
@@ -6063,23 +6063,23 @@ var vi = ({ group: e, shape: t, text: n, layout: r, alignH: i, scaleX: a, scaleY
6063
6063
  scaleY: o,
6064
6064
  scaleEpsilon: c
6065
6065
  });
6066
- }, X = 1e-4, yi = .5;
6067
- function bi({ isProportionalScaling: e, startTextSplitByGrapheme: t }) {
6066
+ }, Y = 1e-4, bi = .5;
6067
+ function xi({ isProportionalScaling: e, startTextSplitByGrapheme: t }) {
6068
6068
  if (e && !t) return "words-only";
6069
6069
  }
6070
- function xi({ width: e, height: t }) {
6070
+ function Si({ width: e, height: t }) {
6071
6071
  return `${Math.round(Math.max(1, e) * 1e6) / 1e6}:${Math.round(Math.max(1, t) * 1e6) / 1e6}`;
6072
6072
  }
6073
- function Si({ width: e, padding: t }) {
6073
+ function Ci({ width: e, padding: t }) {
6074
6074
  return Math.max(1, e - Math.max(0, t.left) - Math.max(0, t.right));
6075
6075
  }
6076
- function Ci({ height: e, padding: t }) {
6076
+ function wi({ height: e, padding: t }) {
6077
6077
  return Math.max(1, e - Math.max(0, t.top) - Math.max(0, t.bottom));
6078
6078
  }
6079
- function wi({ text: e }) {
6079
+ function Ti({ text: e }) {
6080
6080
  return (e.text ?? "").trim().length > 0;
6081
6081
  }
6082
- function Ti({ height: e }) {
6082
+ function Ei({ height: e }) {
6083
6083
  return {
6084
6084
  measuredHeight: e,
6085
6085
  renderedLineCount: 0,
@@ -6088,7 +6088,7 @@ function Ti({ height: e }) {
6088
6088
  isValid: !0
6089
6089
  };
6090
6090
  }
6091
- function Ei({ group: e }) {
6091
+ function Di({ group: e }) {
6092
6092
  return ze({ padding: {
6093
6093
  top: e.shapePaddingTop,
6094
6094
  right: e.shapePaddingRight,
@@ -6096,7 +6096,7 @@ function Ei({ group: e }) {
6096
6096
  left: e.shapePaddingLeft
6097
6097
  } });
6098
6098
  }
6099
- function Di({ group: e, width: t, height: n }) {
6099
+ function Oi({ group: e, width: t, height: n }) {
6100
6100
  let r = e.shapePresetKey ?? "", i = r ? Ae({ presetKey: r }) : null;
6101
6101
  return Ue({
6102
6102
  baseInset: i ? Ne({
@@ -6108,31 +6108,31 @@ function Di({ group: e, width: t, height: n }) {
6108
6108
  strokeWidth: e.shapeStrokeWidth
6109
6109
  });
6110
6110
  }
6111
- function Z({ group: e, width: t, height: n }) {
6112
- return Di({
6111
+ function X({ group: e, width: t, height: n }) {
6112
+ return Oi({
6113
6113
  group: e,
6114
6114
  width: Math.max(1, t ?? e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1),
6115
6115
  height: Math.max(1, n ?? e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1)
6116
6116
  });
6117
6117
  }
6118
- function Oi({ group: e, text: t, width: n, height: r, measurementCache: i, constraintCache: a }) {
6119
- let o = Math.max(1, n), s = Math.max(1, r), c = xi({
6118
+ function ki({ group: e, text: t, width: n, height: r, measurementCache: i, constraintCache: a }) {
6119
+ let o = Math.max(1, n), s = Math.max(1, r), c = Si({
6120
6120
  width: o,
6121
6121
  height: s
6122
6122
  }), l = a?.get(c);
6123
6123
  if (l) return l;
6124
- if (!wi({ text: t })) {
6125
- let e = Ti({ height: s });
6124
+ if (!Ti({ text: t })) {
6125
+ let e = Ei({ height: s });
6126
6126
  return a?.set(c, e), e;
6127
6127
  }
6128
- let u = Z({
6128
+ let u = X({
6129
6129
  group: e,
6130
6130
  width: o,
6131
6131
  height: s
6132
- }), d = Si({
6132
+ }), d = Ci({
6133
6133
  width: o,
6134
6134
  padding: u
6135
- }), f = Ci({
6135
+ }), f = wi({
6136
6136
  height: s,
6137
6137
  padding: u
6138
6138
  }), p = Cr({
@@ -6146,9 +6146,9 @@ function Oi({ group: e, text: t, width: n, height: r, measurementCache: i, const
6146
6146
  };
6147
6147
  return a?.set(c, m), m;
6148
6148
  }
6149
- function ki({ group: e, text: t, state: n }) {
6149
+ function Ai({ group: e, text: t, state: n }) {
6150
6150
  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 }) => {
6151
- let o = Oi({
6151
+ let o = ki({
6152
6152
  group: e,
6153
6153
  text: t,
6154
6154
  width: Math.max(1, i * a),
@@ -6179,7 +6179,7 @@ function ki({ group: e, text: t, state: n }) {
6179
6179
  minimumHeight: g
6180
6180
  };
6181
6181
  }
6182
- function Ai({ group: e, text: t, width: n, padding: r, wrapPolicy: i, measurementCache: a }) {
6182
+ function ji({ group: e, text: t, width: n, padding: r, wrapPolicy: i, measurementCache: a }) {
6183
6183
  return $r({
6184
6184
  text: t,
6185
6185
  width: n,
@@ -6187,14 +6187,14 @@ function Ai({ group: e, text: t, width: n, padding: r, wrapPolicy: i, measuremen
6187
6187
  padding: r,
6188
6188
  wrapPolicy: i,
6189
6189
  measurementCache: a ?? void 0,
6190
- resolvePaddingForSize: ({ width: t, height: n }) => Z({
6190
+ resolvePaddingForSize: ({ width: t, height: n }) => X({
6191
6191
  group: e,
6192
6192
  width: t,
6193
6193
  height: n
6194
6194
  })
6195
6195
  });
6196
6196
  }
6197
- function ji({ group: e, text: t, constraintPadding: n, startDimensions: r, appliedScaleX: i, appliedScaleY: a, minimumHeight: o, wrapPolicy: s, measurementCache: c }) {
6197
+ function Mi({ group: e, text: t, constraintPadding: n, startDimensions: r, appliedScaleX: i, appliedScaleY: a, minimumHeight: o, wrapPolicy: s, measurementCache: c }) {
6198
6198
  let l = r.canScaleWidth ? Math.max(1, r.startWidth * i) : r.startWidth, u = r.canScaleHeight ? Math.max(1, r.startHeight * a) : r.startManualBaseHeight, d = o ?? $r({
6199
6199
  text: t,
6200
6200
  width: l,
@@ -6202,7 +6202,7 @@ function ji({ group: e, text: t, constraintPadding: n, startDimensions: r, appli
6202
6202
  padding: n,
6203
6203
  wrapPolicy: s,
6204
6204
  measurementCache: c ?? void 0,
6205
- resolvePaddingForSize: ({ width: t, height: n }) => Z({
6205
+ resolvePaddingForSize: ({ width: t, height: n }) => X({
6206
6206
  group: e,
6207
6207
  width: t,
6208
6208
  height: n
@@ -6213,8 +6213,8 @@ function ji({ group: e, text: t, constraintPadding: n, startDimensions: r, appli
6213
6213
  previewHeight: Math.max(u, d)
6214
6214
  };
6215
6215
  }
6216
- function Mi({ group: e, text: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
6217
- 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, u = bi({
6216
+ function Ni({ group: e, text: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
6217
+ 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, u = xi({
6218
6218
  isProportionalScaling: n.isProportionalScaling,
6219
6219
  startTextSplitByGrapheme: n.startTextSplitByGrapheme
6220
6220
  });
@@ -6223,19 +6223,19 @@ function Mi({ group: e, text: t, state: n, appliedScaleX: r, appliedScaleY: i, m
6223
6223
  width: o,
6224
6224
  height: c,
6225
6225
  alignV: e.shapeAlignVertical ?? "middle",
6226
- padding: Ei({ group: e }),
6226
+ padding: Di({ group: e }),
6227
6227
  wrapPolicy: u,
6228
6228
  expandShapeHeightToFitText: l,
6229
6229
  measurementCache: n.previewTextMeasurementCache ?? void 0,
6230
- resolveInternalShapeTextInset: ({ width: t, height: n }) => Di({
6230
+ resolveInternalShapeTextInset: ({ width: t, height: n }) => Oi({
6231
6231
  group: e,
6232
6232
  width: t,
6233
6233
  height: n
6234
6234
  })
6235
6235
  });
6236
6236
  }
6237
- function Ni({ group: e, transform: t }) {
6238
- let { canScaleWidth: n, canScaleHeight: r } = Y({ transform: t }), i = Math.max(1, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1), a = Math.max(1, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1);
6237
+ function Pi({ group: e, transform: t }) {
6238
+ let { canScaleWidth: n, canScaleHeight: r } = di({ transform: t }), i = Math.max(1, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? 1), a = Math.max(1, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? 1);
6239
6239
  return {
6240
6240
  startWidth: i,
6241
6241
  startHeight: a,
@@ -6245,7 +6245,7 @@ function Ni({ group: e, transform: t }) {
6245
6245
  canScaleHeight: r
6246
6246
  };
6247
6247
  }
6248
- function Pi({ group: e, transform: t }) {
6248
+ function Fi({ group: e, transform: t }) {
6249
6249
  let n = ci({
6250
6250
  transform: t,
6251
6251
  key: "scaleX"
@@ -6258,7 +6258,7 @@ function Pi({ group: e, transform: t }) {
6258
6258
  }), a = ci({
6259
6259
  transform: t,
6260
6260
  key: "top"
6261
- }), o = li({ value: t?.original?.originX ?? t?.originX }), s = ui({ value: t?.original?.originY ?? t?.originY }), c = fi({
6261
+ }), o = li({ value: t?.original?.originX ?? t?.originX }), s = ui({ value: t?.original?.originY ?? t?.originY }), c = pi({
6262
6262
  group: e,
6263
6263
  originX: o,
6264
6264
  originY: s
@@ -6275,18 +6275,18 @@ function Pi({ group: e, transform: t }) {
6275
6275
  scalingAnchorY: c?.y ?? null
6276
6276
  };
6277
6277
  }
6278
- function Fi({ group: e, text: t, constraintPadding: n, transform: r }) {
6279
- let i = Ni({
6278
+ function Ii({ group: e, text: t, constraintPadding: n, transform: r }) {
6279
+ let i = Pi({
6280
6280
  group: e,
6281
6281
  transform: r
6282
- }), a = Pi({
6282
+ }), a = Fi({
6283
6283
  group: e,
6284
6284
  transform: r
6285
6285
  }), o = !i.canScaleWidth && i.canScaleHeight, s = {
6286
6286
  measurementsByKey: /* @__PURE__ */ new Map(),
6287
6287
  splitByGraphemeByFrameWidth: /* @__PURE__ */ new Map(),
6288
6288
  minimumTextFrameWidth: null
6289
- }, c = /* @__PURE__ */ new Map(), l = Ai({
6289
+ }, c = /* @__PURE__ */ new Map(), l = ji({
6290
6290
  group: e,
6291
6291
  text: t,
6292
6292
  width: i.startWidth,
@@ -6295,7 +6295,7 @@ function Fi({ group: e, text: t, constraintPadding: n, transform: r }) {
6295
6295
  });
6296
6296
  return {
6297
6297
  ...i,
6298
- cannotScaleDownAtStart: l >= i.startHeight - X,
6298
+ cannotScaleDownAtStart: l >= i.startHeight - Y,
6299
6299
  startTextSplitByGrapheme: !!t.splitByGrapheme,
6300
6300
  isProportionalScaling: !1,
6301
6301
  blockedScaleAttempt: !1,
@@ -6316,17 +6316,17 @@ function Fi({ group: e, text: t, constraintPadding: n, transform: r }) {
6316
6316
  proportionalTextConstraintCache: c
6317
6317
  };
6318
6318
  }
6319
- function Ii({ scalingState: e, group: t, text: n, constraintPadding: r, transform: i }) {
6319
+ function Li({ scalingState: e, group: t, text: n, constraintPadding: r, transform: i }) {
6320
6320
  let a = e.get(t);
6321
- return a || (a = Fi({
6321
+ return a || (a = Ii({
6322
6322
  group: t,
6323
6323
  text: n,
6324
6324
  constraintPadding: r,
6325
6325
  transform: i
6326
6326
  }), e.set(t, a), a);
6327
6327
  }
6328
- function Li({ group: e, text: t, constraintPadding: n, startDimensions: r, scaleX: i, scaleY: a, wrapPolicy: o }) {
6329
- let { previewWidth: s, previewHeight: c } = ji({
6328
+ function Ri({ group: e, text: t, constraintPadding: n, startDimensions: r, scaleX: i, scaleY: a, wrapPolicy: o }) {
6329
+ let { previewWidth: s, previewHeight: c } = Mi({
6330
6330
  group: e,
6331
6331
  text: t,
6332
6332
  constraintPadding: n,
@@ -6334,7 +6334,7 @@ function Li({ group: e, text: t, constraintPadding: n, startDimensions: r, scale
6334
6334
  appliedScaleX: i,
6335
6335
  appliedScaleY: a,
6336
6336
  wrapPolicy: o
6337
- }), { startWidth: l, startHeight: u } = r, d = Math.abs(s - l) > yi, f = Math.abs(c - u) > yi;
6337
+ }), { startWidth: l, startHeight: u } = r, d = Math.abs(s - l) > bi, f = Math.abs(c - u) > bi;
6338
6338
  return {
6339
6339
  width: s,
6340
6340
  height: c,
@@ -6342,7 +6342,7 @@ function Li({ group: e, text: t, constraintPadding: n, startDimensions: r, scale
6342
6342
  hasDimensionChange: d || f
6343
6343
  };
6344
6344
  }
6345
- function Ri({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth: n, canScaleHeight: r, finalWidth: i, finalHeight: a }) {
6345
+ function zi({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth: n, canScaleHeight: r, finalWidth: i, finalHeight: a }) {
6346
6346
  let o = e;
6347
6347
  n && (o = i);
6348
6348
  let s = t;
@@ -6351,8 +6351,8 @@ function Ri({ startManualBaseWidth: e, startManualBaseHeight: t, canScaleWidth:
6351
6351
  height: s
6352
6352
  };
6353
6353
  }
6354
- function zi({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, startManualBaseWidth: s, startManualBaseHeight: c, canScaleWidth: l, canScaleHeight: u, hasWidthChange: d, wrapPolicy: f }) {
6355
- let p = Ri({
6354
+ function Bi({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, startManualBaseWidth: s, startManualBaseHeight: c, canScaleWidth: l, canScaleHeight: u, hasWidthChange: d, wrapPolicy: f }) {
6355
+ let p = zi({
6356
6356
  startManualBaseWidth: s,
6357
6357
  startManualBaseHeight: c,
6358
6358
  canScaleWidth: l,
@@ -6361,11 +6361,11 @@ function zi({ group: e, shape: t, text: n, width: r, height: i, alignH: a, align
6361
6361
  finalHeight: i
6362
6362
  });
6363
6363
  e.shapeManualBaseWidth = p.width, e.shapeManualBaseHeight = p.height, l && d && (e.shapeTextAutoExpand = !1);
6364
- let m = Ei({ group: e }), h = Di({
6364
+ let m = Di({ group: e }), h = Oi({
6365
6365
  group: e,
6366
6366
  width: r,
6367
6367
  height: i
6368
- }), g = !u, _ = ({ width: t, height: n }) => Di({
6368
+ }), g = !u, _ = ({ width: t, height: n }) => Oi({
6369
6369
  group: e,
6370
6370
  width: t,
6371
6371
  height: n
@@ -6407,13 +6407,13 @@ function zi({ group: e, shape: t, text: n, width: r, height: i, alignH: a, align
6407
6407
  }
6408
6408
  //#endregion
6409
6409
  //#region src/editor/shape-manager/scaling/active-selection-scaling-controller.ts
6410
- var Bi = class {
6410
+ var Vi = class {
6411
6411
  constructor({ canvas: e, shapeScalingState: t }) {
6412
6412
  this.canvas = e, this.shapeScalingState = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.scalingSessions = /* @__PURE__ */ new WeakMap(), this.groupLayoutScales = /* @__PURE__ */ new WeakMap();
6413
6413
  }
6414
6414
  handleScalingPreview({ selection: e, transform: t, event: n }) {
6415
6415
  if (!t) return;
6416
- let { canScaleWidth: r, canScaleHeight: i, isCornerScaleAction: a } = Y({ transform: t });
6416
+ let { canScaleWidth: r, canScaleHeight: i, isCornerScaleAction: a } = di({ transform: t });
6417
6417
  if (!r && !i) return;
6418
6418
  let o = this._collectPreviewItems({
6419
6419
  selection: e,
@@ -6459,24 +6459,24 @@ var Bi = class {
6459
6459
  } else c = this._resolveShapeLayoutScale({
6460
6460
  item: e,
6461
6461
  selectionScale: p
6462
- }), u = ji({
6462
+ }), u = Mi({
6463
6463
  group: t,
6464
6464
  text: r,
6465
6465
  constraintPadding: i,
6466
6466
  startDimensions: a,
6467
6467
  appliedScaleX: c.scaleX,
6468
6468
  appliedScaleY: c.scaleY,
6469
- wrapPolicy: bi({
6469
+ wrapPolicy: xi({
6470
6470
  isProportionalScaling: a.isProportionalScaling,
6471
6471
  startTextSplitByGrapheme: a.startTextSplitByGrapheme
6472
6472
  }),
6473
6473
  measurementCache: a.previewTextMeasurementCache
6474
6474
  }).previewHeight;
6475
- vi({
6475
+ yi({
6476
6476
  group: t,
6477
6477
  shape: n,
6478
6478
  text: r,
6479
- layout: Mi({
6479
+ layout: Ni({
6480
6480
  group: t,
6481
6481
  text: r,
6482
6482
  state: a,
@@ -6488,7 +6488,7 @@ var Bi = class {
6488
6488
  scaleX: p.scaleX,
6489
6489
  scaleY: p.scaleY,
6490
6490
  minSize: 1,
6491
- scaleEpsilon: X
6491
+ scaleEpsilon: Y
6492
6492
  }), this.groupLayoutScales.set(t, c), this._positionShapeInSelection({
6493
6493
  group: t,
6494
6494
  sessionItem: o
@@ -6499,13 +6499,13 @@ var Bi = class {
6499
6499
  commitGroupScaling({ group: e, scaleX: t, scaleY: n, transform: r }) {
6500
6500
  let { shape: i, text: a } = H({ group: e });
6501
6501
  if (!i || !a) return this.shapeScalingState.delete(e), !1;
6502
- let o = this.shapeScalingState.get(e), s = o ?? Ni({
6502
+ let o = this.shapeScalingState.get(e), s = o ?? Pi({
6503
6503
  group: e,
6504
6504
  transform: r
6505
- }), c = r ? Y({ transform: r }) : null, l = o?.canScaleWidth ?? c?.canScaleWidth ?? Math.abs(t - 1) > 1e-4, u = o?.canScaleHeight ?? c?.canScaleHeight ?? Math.abs(n - 1) > 1e-4, d = e.shapeAlignHorizontal ?? "center", f = e.shapeAlignVertical ?? "middle", p = Z({ group: e }), m = this.groupLayoutScales.get(e) ?? {
6505
+ }), c = r ? di({ transform: r }) : null, l = o?.canScaleWidth ?? c?.canScaleWidth ?? Math.abs(t - 1) > 1e-4, u = o?.canScaleHeight ?? c?.canScaleHeight ?? Math.abs(n - 1) > 1e-4, d = e.shapeAlignHorizontal ?? "center", f = e.shapeAlignVertical ?? "middle", p = X({ group: e }), m = this.groupLayoutScales.get(e) ?? {
6506
6506
  scaleX: t,
6507
6507
  scaleY: n
6508
- }, { width: h, height: g, hasWidthChange: _, hasDimensionChange: v } = Li({
6508
+ }, { width: h, height: g, hasWidthChange: _, hasDimensionChange: v } = Ri({
6509
6509
  group: e,
6510
6510
  text: a,
6511
6511
  constraintPadding: p,
@@ -6516,12 +6516,12 @@ var Bi = class {
6516
6516
  },
6517
6517
  scaleX: m.scaleX,
6518
6518
  scaleY: m.scaleY,
6519
- wrapPolicy: bi({
6519
+ wrapPolicy: xi({
6520
6520
  isProportionalScaling: o?.isProportionalScaling,
6521
6521
  startTextSplitByGrapheme: o?.startTextSplitByGrapheme
6522
6522
  })
6523
6523
  });
6524
- return v ? (zi({
6524
+ return v ? (Bi({
6525
6525
  group: e,
6526
6526
  shape: i,
6527
6527
  text: a,
@@ -6534,7 +6534,7 @@ var Bi = class {
6534
6534
  canScaleWidth: l,
6535
6535
  canScaleHeight: u,
6536
6536
  hasWidthChange: _,
6537
- wrapPolicy: bi({
6537
+ wrapPolicy: xi({
6538
6538
  isProportionalScaling: o?.isProportionalScaling,
6539
6539
  startTextSplitByGrapheme: o?.startTextSplitByGrapheme
6540
6540
  })
@@ -6561,7 +6561,7 @@ var Bi = class {
6561
6561
  if (!U(r)) continue;
6562
6562
  let { shape: e, text: i } = H({ group: r });
6563
6563
  if (!e || !i) continue;
6564
- let a = Z({ group: r }), o = Ii({
6564
+ let a = X({ group: r }), o = Li({
6565
6565
  scalingState: this.shapeScalingState,
6566
6566
  group: r,
6567
6567
  text: i,
@@ -6608,7 +6608,7 @@ var Bi = class {
6608
6608
  return this.scalingSessions.set(e, u), u;
6609
6609
  }
6610
6610
  _resolveSelectionScale({ items: e, session: t, transform: n, proportionalLayoutResults: r, scaleX: i, scaleY: a, event: o }) {
6611
- let { canScaleWidth: s, canScaleHeight: c, isCornerScaleAction: l } = Y({ transform: n }), u = !!(o && "shiftKey" in o && o.shiftKey), d = l && !u, f = i, p = a;
6611
+ let { canScaleWidth: s, canScaleHeight: c, isCornerScaleAction: l } = di({ transform: n }), u = !!(o && "shiftKey" in o && o.shiftKey), d = l && !u, f = i, p = a;
6612
6612
  if (d) {
6613
6613
  let n = Math.max(i, a);
6614
6614
  if (!r) return {
@@ -6682,7 +6682,7 @@ var Bi = class {
6682
6682
  return o;
6683
6683
  }
6684
6684
  _resolveSelectionScaleAtPointerBoundary({ selection: e, items: t, session: n, transform: r, selectionScale: i, event: a }) {
6685
- let { canScaleWidth: o, canScaleHeight: s, isCornerScaleAction: c } = Y({ transform: r }), l = !!(a && "shiftKey" in a && a.shiftKey);
6685
+ let { canScaleWidth: o, canScaleHeight: s, isCornerScaleAction: c } = di({ transform: r }), l = !!(a && "shiftKey" in a && a.shiftKey);
6686
6686
  if (c && !l) return i;
6687
6687
  let u = o && this._hasPointerReachedSelectionScaleOrigin({
6688
6688
  selection: e,
@@ -6801,7 +6801,7 @@ var Bi = class {
6801
6801
  _resolveProportionalLayoutResults({ items: e }) {
6802
6802
  let t = /* @__PURE__ */ new Map();
6803
6803
  for (let n of e) {
6804
- let e = ki({
6804
+ let e = Ai({
6805
6805
  group: n.group,
6806
6806
  text: n.text,
6807
6807
  state: n.state
@@ -6819,7 +6819,7 @@ var Bi = class {
6819
6819
  text: r,
6820
6820
  padding: i,
6821
6821
  measurementCache: a.previewTextMeasurementCache ?? void 0,
6822
- resolvePaddingForWidth: ({ width: e }) => Z({
6822
+ resolvePaddingForWidth: ({ width: e }) => X({
6823
6823
  group: n,
6824
6824
  width: e,
6825
6825
  height: o
@@ -6832,7 +6832,7 @@ var Bi = class {
6832
6832
  }
6833
6833
  _resolveMinimumShapeHeight({ item: e, scaleX: t }) {
6834
6834
  let { group: n, text: r, constraintPadding: i, state: a } = e;
6835
- return Ai({
6835
+ return ji({
6836
6836
  group: n,
6837
6837
  text: r,
6838
6838
  width: Math.max(1, a.startWidth * t),
@@ -6871,7 +6871,7 @@ var Bi = class {
6871
6871
  };
6872
6872
  }
6873
6873
  _resolveVerticalAttachment({ selectionBounds: e, shapeBounds: t }) {
6874
- let n = Math.max(0, t.top - e.top), r = Math.max(0, e.bottom - t.bottom), i = n <= yi, a = r <= yi;
6874
+ let n = Math.max(0, t.top - e.top), r = Math.max(0, e.bottom - t.bottom), i = n <= bi, a = r <= bi;
6875
6875
  return i && !a ? "top" : a && !i ? "bottom" : Math.abs(n - r) <= .5 ? "center" : n < r ? "top" : "bottom";
6876
6876
  }
6877
6877
  _resolveOriginOffset({ origin: e }) {
@@ -6892,7 +6892,7 @@ var Bi = class {
6892
6892
  _hasPointerReachedSelectionScaleOrigin({ selection: e, transform: t, event: n, axis: r }) {
6893
6893
  let i = t, a = r === "x" ? i.signX : i.signY;
6894
6894
  if (typeof a != "number" || !Number.isFinite(a)) return !1;
6895
- let o = di({
6895
+ let o = fi({
6896
6896
  target: e,
6897
6897
  transform: t,
6898
6898
  event: n,
@@ -6911,7 +6911,7 @@ var Bi = class {
6911
6911
  scaleY: r
6912
6912
  }), c && o !== null && s !== null && e.setPositionByOrigin(c, o, s), e.setCoords();
6913
6913
  }
6914
- }, Vi = class {
6914
+ }, Hi = class {
6915
6915
  constructor({ canvas: t }) {
6916
6916
  this.handleObjectScaling = (t) => {
6917
6917
  let { target: n, transform: r } = t;
@@ -6930,7 +6930,7 @@ var Bi = class {
6930
6930
  lockScalingFlip: !0,
6931
6931
  centeredScaling: !1
6932
6932
  });
6933
- let s = Z({ group: i }), c = Ii({
6933
+ let s = X({ group: i }), c = Li({
6934
6934
  scalingState: this.scalingState,
6935
6935
  group: i,
6936
6936
  text: o,
@@ -6959,7 +6959,7 @@ var Bi = class {
6959
6959
  });
6960
6960
  return;
6961
6961
  }
6962
- let _ = Mi({
6962
+ let _ = Ni({
6963
6963
  group: i,
6964
6964
  text: o,
6965
6965
  state: c,
@@ -6973,7 +6973,7 @@ var Bi = class {
6973
6973
  shouldHandleAsNoop: !1,
6974
6974
  scaleX: g.appliedScaleX,
6975
6975
  scaleY: g.appliedScaleY
6976
- }), vi({
6976
+ }), yi({
6977
6977
  group: i,
6978
6978
  shape: a,
6979
6979
  text: o,
@@ -6982,7 +6982,7 @@ var Bi = class {
6982
6982
  scaleX: g.appliedScaleX,
6983
6983
  scaleY: g.appliedScaleY,
6984
6984
  minSize: 1,
6985
- scaleEpsilon: X
6985
+ scaleEpsilon: Y
6986
6986
  }), this._restoreScalingAnchorPosition({
6987
6987
  group: i,
6988
6988
  state: c
@@ -7013,7 +7013,7 @@ var Bi = class {
7013
7013
  if (!a) return;
7014
7014
  let { shape: o, text: s } = H({ group: i });
7015
7015
  if (!o || !s) return;
7016
- let c = Z({ group: i }), l = i.shapeAlignHorizontal ?? "center", { canScaleWidth: u, canScaleHeight: d } = a;
7016
+ let c = X({ group: i }), l = i.shapeAlignHorizontal ?? "center", { canScaleWidth: u, canScaleHeight: d } = a;
7017
7017
  if (!u && !d) return;
7018
7018
  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({
7019
7019
  group: i,
@@ -7035,7 +7035,7 @@ var Bi = class {
7035
7035
  axis: "y"
7036
7036
  });
7037
7037
  if (!e && !t) return;
7038
- let n = ki({
7038
+ let n = Ai({
7039
7039
  group: i,
7040
7040
  text: s,
7041
7041
  state: a
@@ -7052,7 +7052,7 @@ var Bi = class {
7052
7052
  let e = Zr({
7053
7053
  text: s,
7054
7054
  padding: c,
7055
- resolvePaddingForWidth: ({ width: e }) => Z({
7055
+ resolvePaddingForWidth: ({ width: e }) => X({
7056
7056
  group: i,
7057
7057
  width: e,
7058
7058
  height: Math.max(1, a.startHeight * v)
@@ -7075,7 +7075,7 @@ var Bi = class {
7075
7075
  });
7076
7076
  return;
7077
7077
  }
7078
- y = C ?? Ai({
7078
+ y = C ?? ji({
7079
7079
  group: i,
7080
7080
  text: s,
7081
7081
  width: Math.max(1, a.startWidth * _),
@@ -7088,7 +7088,7 @@ var Bi = class {
7088
7088
  }
7089
7089
  if (!x && !S) return;
7090
7090
  y ??= C;
7091
- let w = ji({
7091
+ let w = Mi({
7092
7092
  group: i,
7093
7093
  text: s,
7094
7094
  constraintPadding: c,
@@ -7097,7 +7097,7 @@ var Bi = class {
7097
7097
  appliedScaleY: v,
7098
7098
  minimumHeight: b ? null : y,
7099
7099
  measurementCache: a.previewTextMeasurementCache
7100
- }), T = Mi({
7100
+ }), T = Ni({
7101
7101
  group: i,
7102
7102
  text: s,
7103
7103
  state: a,
@@ -7111,7 +7111,7 @@ var Bi = class {
7111
7111
  shouldHandleAsNoop: !1,
7112
7112
  scaleX: _,
7113
7113
  scaleY: v
7114
- }), vi({
7114
+ }), yi({
7115
7115
  group: i,
7116
7116
  shape: o,
7117
7117
  text: s,
@@ -7120,7 +7120,7 @@ var Bi = class {
7120
7120
  scaleX: _,
7121
7121
  scaleY: v,
7122
7122
  minSize: 1,
7123
- scaleEpsilon: X
7123
+ scaleEpsilon: Y
7124
7124
  }), this._restoreScalingAnchorPosition({
7125
7125
  group: i,
7126
7126
  state: a
@@ -7155,7 +7155,7 @@ var Bi = class {
7155
7155
  startHeight: s,
7156
7156
  alignH: n.shapeAlignHorizontal,
7157
7157
  alignV: n.shapeAlignVertical,
7158
- userPadding: Ei({ group: n })
7158
+ userPadding: Di({ group: n })
7159
7159
  }), n.shapeScalingNoopTransform = !1, this.scalingState.delete(n), this.canvas.requestRenderAll();
7160
7160
  return;
7161
7161
  }
@@ -7164,7 +7164,7 @@ var Bi = class {
7164
7164
  this.scalingState.delete(n);
7165
7165
  return;
7166
7166
  }
7167
- let f = n.shapeAlignHorizontal ?? "center", p = n.shapeAlignVertical ?? "middle", m = Z({ group: n }), h = e.transform ? Y({ transform: e.transform }) : null, g = r?.canScaleWidth ?? h?.canScaleWidth ?? Math.abs(i - 1) > 1e-4, _ = r?.canScaleHeight ?? h?.canScaleHeight ?? Math.abs(a - 1) > 1e-4, v = r?.lastAllowedScaleX ?? i, y = r?.lastAllowedScaleY ?? a;
7167
+ let f = n.shapeAlignHorizontal ?? "center", p = n.shapeAlignVertical ?? "middle", m = X({ group: n }), h = e.transform ? di({ 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;
7168
7168
  if (r?.isProportionalScaling) {
7169
7169
  let t = this._hasPointerReachedScaleOrigin({
7170
7170
  event: e,
@@ -7178,7 +7178,7 @@ var Bi = class {
7178
7178
  axis: "y"
7179
7179
  });
7180
7180
  if (t || o) {
7181
- let e = ki({
7181
+ let e = Ai({
7182
7182
  group: n,
7183
7183
  text: d,
7184
7184
  state: r
@@ -7189,7 +7189,7 @@ var Bi = class {
7189
7189
  let t = Zr({
7190
7190
  text: d,
7191
7191
  padding: m,
7192
- resolvePaddingForWidth: ({ width: e }) => Z({
7192
+ resolvePaddingForWidth: ({ width: e }) => X({
7193
7193
  group: n,
7194
7194
  width: e,
7195
7195
  height: Math.max(1, s * y)
@@ -7201,7 +7201,7 @@ var Bi = class {
7201
7201
  minimumWidth: t,
7202
7202
  state: r
7203
7203
  }) && (v = Math.max(1 / o, t / o));
7204
- let i = Ai({
7204
+ let i = ji({
7205
7205
  group: n,
7206
7206
  text: d,
7207
7207
  width: Math.max(1, o * v),
@@ -7214,7 +7214,7 @@ var Bi = class {
7214
7214
  state: r
7215
7215
  }) && (y = Math.max(1 / s, i / s));
7216
7216
  }
7217
- let { width: b, height: x, hasWidthChange: S, hasDimensionChange: C } = Li({
7217
+ let { width: b, height: x, hasWidthChange: S, hasDimensionChange: C } = Ri({
7218
7218
  group: n,
7219
7219
  text: d,
7220
7220
  constraintPadding: m,
@@ -7228,7 +7228,7 @@ var Bi = class {
7228
7228
  },
7229
7229
  scaleX: v,
7230
7230
  scaleY: y,
7231
- wrapPolicy: bi({
7231
+ wrapPolicy: xi({
7232
7232
  isProportionalScaling: r?.isProportionalScaling,
7233
7233
  startTextSplitByGrapheme: r?.startTextSplitByGrapheme
7234
7234
  })
@@ -7243,14 +7243,14 @@ var Bi = class {
7243
7243
  startHeight: s,
7244
7244
  alignH: f,
7245
7245
  alignV: p,
7246
- userPadding: Ei({ group: n })
7246
+ userPadding: Di({ group: n })
7247
7247
  }), this.scalingState.delete(n), this.canvas.requestRenderAll();
7248
7248
  return;
7249
7249
  }
7250
7250
  r && n.set({
7251
7251
  left: r.lastAllowedLeft,
7252
7252
  top: r.lastAllowedTop
7253
- }), zi({
7253
+ }), Bi({
7254
7254
  group: n,
7255
7255
  shape: u,
7256
7256
  text: d,
@@ -7263,7 +7263,7 @@ var Bi = class {
7263
7263
  canScaleWidth: g,
7264
7264
  canScaleHeight: _,
7265
7265
  hasWidthChange: S,
7266
- wrapPolicy: bi({
7266
+ wrapPolicy: xi({
7267
7267
  isProportionalScaling: r?.isProportionalScaling,
7268
7268
  startTextSplitByGrapheme: r?.startTextSplitByGrapheme
7269
7269
  })
@@ -7271,7 +7271,7 @@ var Bi = class {
7271
7271
  group: n,
7272
7272
  state: r
7273
7273
  }), n.setCoords(), d.setCoords(), u.setCoords(), this.scalingState.delete(n), n.shapeScalingNoopTransform = !1, this.canvas.requestRenderAll();
7274
- }, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.activeSelectionScalingController = new Bi({
7274
+ }, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap(), this.activeSelectionScalingController = new Vi({
7275
7275
  canvas: t,
7276
7276
  shapeScalingState: this.scalingState
7277
7277
  });
@@ -7280,10 +7280,10 @@ var Bi = class {
7280
7280
  let a = e.scaleX ?? 1, o = e.scaleY ?? 1, { scaleX: s, scaleY: c } = this._resolveCurrentDragScales({
7281
7281
  group: e,
7282
7282
  state: r
7283
- }), l = r.canScaleWidth && a < 0 || r.canScaleHeight && o < 0, u = pi({
7283
+ }), l = r.canScaleWidth && a < 0 || r.canScaleHeight && o < 0, u = mi({
7284
7284
  state: r,
7285
7285
  transform: i
7286
- }), d = mi({
7286
+ }), d = hi({
7287
7287
  state: r,
7288
7288
  transform: i
7289
7289
  });
@@ -7299,7 +7299,7 @@ var Bi = class {
7299
7299
  f.shouldRestoreLastAllowedTransform && (h = r.lastAllowedScaleX, g = r.lastAllowedScaleY), f.shouldHandleAsNoop && (h = r.startScaleX, g = r.startScaleY);
7300
7300
  let _ = f.resolvedMinimumHeight, v = !r.canScaleWidth && r.canScaleHeight ? r.fixedWidthMinimumTextFitHeight : null;
7301
7301
  f.shouldHandleAsNoop ? _ = r.startHeight : _ ??= v;
7302
- let { previewHeight: y } = ji({
7302
+ let { previewHeight: y } = Mi({
7303
7303
  group: e,
7304
7304
  text: t,
7305
7305
  constraintPadding: n,
@@ -7318,16 +7318,16 @@ var Bi = class {
7318
7318
  };
7319
7319
  }
7320
7320
  _resolveScalingConstraintState({ group: e, text: t, constraintPadding: n, state: r, scaleX: i, scaleY: a }) {
7321
- let { canScaleHeight: o, canScaleWidth: s, startHeight: c, startWidth: l, cannotScaleDownAtStart: u, crossedOppositeCorner: d, isProportionalScaling: f, lastAllowedScaleX: p, lastAllowedScaleY: m, startScaleY: h } = r, g = o && !s, _ = s ? Math.max(1, l * i) : l, v = o ? Math.max(1, c * a) : c, y = i < p - X, b = a < m - X, x = a < h - X, S = g ? r.fixedWidthMinimumTextFitHeight : null, C = s && y ? Zr({
7321
+ let { canScaleHeight: o, canScaleWidth: s, startHeight: c, startWidth: l, cannotScaleDownAtStart: u, crossedOppositeCorner: d, isProportionalScaling: f, lastAllowedScaleX: p, lastAllowedScaleY: m, startScaleY: h } = r, g = o && !s, _ = s ? Math.max(1, l * i) : l, v = o ? Math.max(1, c * a) : c, y = i < p - Y, b = a < m - Y, x = a < h - Y, S = g ? r.fixedWidthMinimumTextFitHeight : null, C = s && y ? Zr({
7322
7322
  text: t,
7323
7323
  padding: n,
7324
7324
  measurementCache: r.previewTextMeasurementCache ?? void 0,
7325
- resolvePaddingForWidth: ({ width: t }) => Z({
7325
+ resolvePaddingForWidth: ({ width: t }) => X({
7326
7326
  group: e,
7327
7327
  width: t,
7328
7328
  height: v
7329
7329
  })
7330
- }) : null, w = o && b ? S ?? Ai({
7330
+ }) : null, w = o && b ? S ?? ji({
7331
7331
  group: e,
7332
7332
  text: t,
7333
7333
  width: _,
@@ -7335,7 +7335,7 @@ var Bi = class {
7335
7335
  measurementCache: r.previewTextMeasurementCache
7336
7336
  }) : null, T = g && u && x;
7337
7337
  if (f && s && o && (y || b)) {
7338
- if (!Oi({
7338
+ if (!ki({
7339
7339
  group: e,
7340
7340
  text: t,
7341
7341
  width: _,
@@ -7343,7 +7343,7 @@ var Bi = class {
7343
7343
  measurementCache: r.previewTextMeasurementCache,
7344
7344
  constraintCache: r.proportionalTextConstraintCache
7345
7345
  }).isValid) {
7346
- let n = ki({
7346
+ let n = Ai({
7347
7347
  group: e,
7348
7348
  text: t,
7349
7349
  state: r
@@ -7366,7 +7366,7 @@ var Bi = class {
7366
7366
  }
7367
7367
  let E = C !== null && _ < C + 1e-4, D = w !== null && v < w + 1e-4, O = E || D, k = d, A = null, j = null;
7368
7368
  if (f && O) {
7369
- let n = ki({
7369
+ let n = Ai({
7370
7370
  group: e,
7371
7371
  text: t,
7372
7372
  state: r
@@ -7395,11 +7395,11 @@ var Bi = class {
7395
7395
  shouldHandleAsNoop: !0,
7396
7396
  scaleX: r.startScaleX,
7397
7397
  scaleY: r.startScaleY
7398
- }), vi({
7398
+ }), yi({
7399
7399
  group: e,
7400
7400
  shape: t,
7401
7401
  text: n,
7402
- layout: Mi({
7402
+ layout: Ni({
7403
7403
  group: e,
7404
7404
  text: n,
7405
7405
  state: r,
@@ -7411,7 +7411,7 @@ var Bi = class {
7411
7411
  scaleX: r.startScaleX,
7412
7412
  scaleY: r.startScaleY,
7413
7413
  minSize: 1,
7414
- scaleEpsilon: X
7414
+ scaleEpsilon: Y
7415
7415
  }), this._restoreScalingAnchorPosition({
7416
7416
  group: e,
7417
7417
  state: r
@@ -7454,7 +7454,7 @@ var Bi = class {
7454
7454
  if (!r) return !1;
7455
7455
  let { transform: i } = e;
7456
7456
  if (!i) return !1;
7457
- let { canScaleWidth: a } = Y({ transform: i });
7457
+ let { canScaleWidth: a } = di({ transform: i });
7458
7458
  if (!a || !this._hasPointerReachedScaleOrigin({
7459
7459
  event: e,
7460
7460
  group: t,
@@ -7462,13 +7462,13 @@ var Bi = class {
7462
7462
  axis: "x"
7463
7463
  })) return !1;
7464
7464
  let o = Math.max(1 / r.startWidth, n / r.startWidth);
7465
- return r.lastAllowedScaleX > o + X;
7465
+ return r.lastAllowedScaleX > o + Y;
7466
7466
  }
7467
7467
  _shouldClampHeightToMinimum({ event: e, group: t, minimumHeight: n, state: r }) {
7468
7468
  if (!r) return !1;
7469
7469
  let { transform: i } = e;
7470
7470
  if (!i) return !1;
7471
- let { canScaleHeight: a } = Y({ transform: i });
7471
+ let { canScaleHeight: a } = di({ transform: i });
7472
7472
  if (!a || !this._hasPointerReachedScaleOrigin({
7473
7473
  event: e,
7474
7474
  group: t,
@@ -7476,14 +7476,14 @@ var Bi = class {
7476
7476
  axis: "y"
7477
7477
  })) return !1;
7478
7478
  let o = Math.max(1 / r.startHeight, n / r.startHeight);
7479
- return r.lastAllowedScaleY > o + X;
7479
+ return r.lastAllowedScaleY > o + Y;
7480
7480
  }
7481
7481
  _hasPointerReachedScaleOrigin({ event: e, group: t, state: n, axis: r }) {
7482
7482
  let { transform: i } = e;
7483
7483
  if (!i) return !1;
7484
7484
  let a = i, o = r === "x" ? n?.scaleDirectionX ?? null : n?.scaleDirectionY ?? null, s = this._resolveScaleDirection({ value: r === "x" ? a.signX : a.signY }) ?? o;
7485
7485
  if (s === null) return !1;
7486
- let c = di({
7486
+ let c = fi({
7487
7487
  event: e.e,
7488
7488
  target: t,
7489
7489
  transform: i,
@@ -7493,7 +7493,7 @@ var Bi = class {
7493
7493
  }
7494
7494
  _storeScaleDirectionsForCurrentTransform({ group: e, state: t, event: n, transform: r }) {
7495
7495
  if (!r) return;
7496
- let { canScaleHeight: i, canScaleWidth: a, isCornerScaleAction: o } = Y({ transform: r });
7496
+ let { canScaleHeight: i, canScaleWidth: a, isCornerScaleAction: o } = di({ transform: r });
7497
7497
  if (!o) return;
7498
7498
  let s = !a || t.scaleDirectionX !== null, c = !i || t.scaleDirectionY !== null;
7499
7499
  if (s && c) return;
@@ -7501,7 +7501,7 @@ var Bi = class {
7501
7501
  a && t.scaleDirectionX === null && (t.scaleDirectionX = this._resolveScaleDirection({ value: l.signX })), i && t.scaleDirectionY === null && (t.scaleDirectionY = this._resolveScaleDirection({ value: l.signY }));
7502
7502
  let u = !a || t.scaleDirectionX !== null, d = !i || t.scaleDirectionY !== null;
7503
7503
  if (u && d) return;
7504
- let f = di({
7504
+ let f = fi({
7505
7505
  event: n,
7506
7506
  target: e,
7507
7507
  transform: r,
@@ -7530,14 +7530,14 @@ var Bi = class {
7530
7530
  e.setPositionByOrigin(new m(n, r), i, a), e.setCoords();
7531
7531
  }
7532
7532
  _restoreShapeStateWithoutResize({ group: e, shape: t, text: n, state: r, startWidth: i, startHeight: a, alignH: o, alignV: s, userPadding: c }) {
7533
- let l = Math.max(1, e.shapeBaseWidth ?? e.width ?? i), u = Math.max(1, e.shapeBaseHeight ?? e.height ?? a), d = Di({
7533
+ let l = Math.max(1, e.shapeBaseWidth ?? e.width ?? i), u = Math.max(1, e.shapeBaseHeight ?? e.height ?? a), d = Oi({
7534
7534
  group: e,
7535
7535
  width: l,
7536
7536
  height: u
7537
- }), f = o ?? "center", p = s ?? "middle", m = bi({
7537
+ }), f = o ?? "center", p = s ?? "middle", m = xi({
7538
7538
  isProportionalScaling: r.isProportionalScaling,
7539
7539
  startTextSplitByGrapheme: r.startTextSplitByGrapheme
7540
- }), h = ({ width: t, height: n }) => Di({
7540
+ }), h = ({ width: t, height: n }) => Oi({
7541
7541
  group: e,
7542
7542
  width: t,
7543
7543
  height: n
@@ -7578,7 +7578,7 @@ var Bi = class {
7578
7578
  state: r
7579
7579
  });
7580
7580
  }
7581
- }, Hi = class {
7581
+ }, Ui = class {
7582
7582
  constructor({ canvas: e }) {
7583
7583
  this.handleMouseDown = (e) => {
7584
7584
  let { target: t, e: n, subTargets: r = [] } = e, i = nt({
@@ -7702,7 +7702,7 @@ var Bi = class {
7702
7702
  let t = this.canvas;
7703
7703
  t.findTarget = e.findTarget, this.editingTargetResolverState = void 0;
7704
7704
  }
7705
- }, Ui = 1e-4, Wi = class {
7705
+ }, Wi = 1e-4, Gi = class {
7706
7706
  constructor({ runtime: t }) {
7707
7707
  this._handleObjectScaling = (e) => {
7708
7708
  this.runtime.collectShapeGroupsFromTarget({
@@ -7787,7 +7787,7 @@ var Bi = class {
7787
7787
  let r = t.getObjects(), i = r.filter((e) => U(e));
7788
7788
  if (!i.length) return;
7789
7789
  let { scaleX: a, scaleY: o } = this.runtime.scalingController.resolveActiveSelectionCommittedScale({ selection: t });
7790
- if (!(Math.abs(a - 1) > Ui || Math.abs(o - 1) > Ui)) {
7790
+ if (!(Math.abs(a - 1) > Wi || Math.abs(o - 1) > Wi)) {
7791
7791
  this.runtime.scalingController.clearActiveSelectionState({ selection: t });
7792
7792
  return;
7793
7793
  }
@@ -7805,7 +7805,7 @@ var Bi = class {
7805
7805
  }), e.setCoords());
7806
7806
  }), this.runtime.scalingController.clearActiveSelectionState({ selection: t }), s.setActiveObject(new e(r, { canvas: s })), s.requestRenderAll();
7807
7807
  }
7808
- }, Gi = class {
7808
+ }, Ki = class {
7809
7809
  constructor({ editor: e }) {
7810
7810
  this.editor = e;
7811
7811
  }
@@ -7957,7 +7957,7 @@ var Bi = class {
7957
7957
  resolvePaddingForWidth: i
7958
7958
  }) : Math.max(1, t, n);
7959
7959
  }
7960
- }, Ki = class e {
7960
+ }, qi = class e {
7961
7961
  constructor({ canvas: e }) {
7962
7962
  this.canvas = e, this.textEditingSnapshots = /* @__PURE__ */ new WeakMap(), this.pendingTextUpdates = /* @__PURE__ */ new WeakMap(), this.resizeStartSnapshots = /* @__PURE__ */ new Map(), this.pendingResizeUpdates = /* @__PURE__ */ new WeakMap();
7963
7963
  }
@@ -8153,7 +8153,7 @@ var Bi = class {
8153
8153
  }
8154
8154
  }), I;
8155
8155
  }
8156
- }, qi = .01, Ji = ({ textbox: e }) => {
8156
+ }, Ji = .01, Yi = ({ textbox: e }) => {
8157
8157
  let t = e.text ?? "";
8158
8158
  if (!t.length) return [];
8159
8159
  let n = t.split("\n"), r = [], i = 0;
@@ -8165,7 +8165,7 @@ var Bi = class {
8165
8165
  });
8166
8166
  }
8167
8167
  return r;
8168
- }, Yi = ({ range: e, text: t }) => {
8168
+ }, Xi = ({ range: e, text: t }) => {
8169
8169
  if (!e) return null;
8170
8170
  let n = t.length;
8171
8171
  if (n <= 0) return null;
@@ -8174,8 +8174,8 @@ var Bi = class {
8174
8174
  start: l,
8175
8175
  end: u
8176
8176
  };
8177
- }, Xi = ({ textbox: e, range: t }) => {
8178
- let n = Ji({ textbox: e });
8177
+ }, Zi = ({ textbox: e, range: t }) => {
8178
+ let n = Yi({ textbox: e });
8179
8179
  if (!n.length) return t;
8180
8180
  let { start: r } = t, { end: i } = t;
8181
8181
  for (let e = 0; e < n.length; e += 1) {
@@ -8188,7 +8188,7 @@ var Bi = class {
8188
8188
  start: r,
8189
8189
  end: i
8190
8190
  };
8191
- }, Zi = ({ textbox: e, range: t }) => {
8191
+ }, Qi = ({ textbox: e, range: t }) => {
8192
8192
  let n = e.text ?? "";
8193
8193
  if (!n.length) return [];
8194
8194
  let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
@@ -8197,7 +8197,7 @@ var Bi = class {
8197
8197
  i > n && r < c && o.push(e), s = c + 1;
8198
8198
  }
8199
8199
  return o;
8200
- }, Qi = ({ textbox: e, range: t }) => {
8200
+ }, $i = ({ textbox: e, range: t }) => {
8201
8201
  let n = e.text ?? "";
8202
8202
  if (!n.length) return [];
8203
8203
  let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
@@ -8206,21 +8206,21 @@ var Bi = class {
8206
8206
  r <= n && i >= c && o.push(e), s = c + 1;
8207
8207
  }
8208
8208
  return o;
8209
- }, $i = ({ previous: e, next: t }) => {
8209
+ }, ea = ({ previous: e, next: t }) => {
8210
8210
  let n = Math.min(e.length, t.length);
8211
8211
  for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
8212
8212
  return n;
8213
- }, ea = ({ text: e, charIndex: t }) => {
8213
+ }, ta = ({ text: e, charIndex: t }) => {
8214
8214
  let n = Math.max(0, Math.min(t, e.length)), r = 0;
8215
8215
  for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
8216
8216
  return r;
8217
- }, ta = ({ text: e, lineIndex: t }) => {
8217
+ }, na = ({ text: e, lineIndex: t }) => {
8218
8218
  if (t <= 0) return 0;
8219
8219
  let n = 0;
8220
8220
  for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
8221
8221
  return e.length;
8222
- }, na = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousText: i }) => {
8223
- let a = ta({
8222
+ }, ra = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousText: i }) => {
8223
+ let a = na({
8224
8224
  text: i,
8225
8225
  lineIndex: r
8226
8226
  }), o = r + 1;
@@ -8239,7 +8239,7 @@ var Bi = class {
8239
8239
  lineFontDefaults: s,
8240
8240
  changed: !0
8241
8241
  };
8242
- }, ra = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousLines: i, previousText: a }) => {
8242
+ }, ia = ({ deltaLines: e, diffIndex: t, lineFontDefaults: n, lineIndexOld: r, previousLines: i, previousText: a }) => {
8243
8243
  let o = Math.abs(e), s = r;
8244
8244
  a[t] === "\n" && (i[r] ?? "").length > 0 && (s = r + 1);
8245
8245
  let c = s + o - 1, l = {}, u = [];
@@ -8262,7 +8262,7 @@ var Bi = class {
8262
8262
  lineDefaults: u
8263
8263
  }
8264
8264
  };
8265
- }, ia = ({ lineFontDefaults: e, previousText: t, currentText: n }) => {
8265
+ }, aa = ({ lineFontDefaults: e, previousText: t, currentText: n }) => {
8266
8266
  if (!e || !Object.keys(e).length) return {
8267
8267
  lineFontDefaults: e,
8268
8268
  changed: !1
@@ -8272,20 +8272,20 @@ var Bi = class {
8272
8272
  lineFontDefaults: e,
8273
8273
  changed: !1
8274
8274
  };
8275
- let a = $i({
8275
+ let a = ea({
8276
8276
  previous: t,
8277
8277
  next: n
8278
- }), o = ea({
8278
+ }), o = ta({
8279
8279
  text: t,
8280
8280
  charIndex: a
8281
8281
  });
8282
- return i > 0 ? na({
8282
+ return i > 0 ? ra({
8283
8283
  deltaLines: i,
8284
8284
  diffIndex: a,
8285
8285
  lineFontDefaults: e,
8286
8286
  lineIndexOld: o,
8287
8287
  previousText: t
8288
- }) : ra({
8288
+ }) : ia({
8289
8289
  deltaLines: i,
8290
8290
  diffIndex: a,
8291
8291
  lineFontDefaults: e,
@@ -8293,10 +8293,10 @@ var Bi = class {
8293
8293
  previousLines: r,
8294
8294
  previousText: t
8295
8295
  });
8296
- }, aa = ({ lineDefaults: e }) => {
8296
+ }, oa = ({ lineDefaults: e }) => {
8297
8297
  let t = {};
8298
8298
  return e.fontFamily !== void 0 && (t.fontFamily = e.fontFamily), e.fontSize !== void 0 && (t.fontSize = e.fontSize), e.fontWeight !== void 0 && (t.fontWeight = e.fontWeight), e.fontStyle !== void 0 && (t.fontStyle = e.fontStyle), e.underline !== void 0 && (t.underline = e.underline), e.linethrough !== void 0 && (t.linethrough = e.linethrough), e.fill !== void 0 && (t.fill = e.fill), e.stroke !== void 0 && (t.stroke = e.stroke), e.strokeWidth !== void 0 && (t.strokeWidth = e.strokeWidth), t;
8299
- }, oa = ({ textbox: e, lineIndices: t, updates: n }) => {
8299
+ }, sa = ({ textbox: e, lineIndices: t, updates: n }) => {
8300
8300
  if (!t.length) return !1;
8301
8301
  let { fill: r, fontFamily: i, fontSize: a, fontStyle: o, fontWeight: s, linethrough: c, stroke: l, strokeWidth: u, underline: d } = n;
8302
8302
  if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0 || l !== void 0 || u !== void 0 || d !== void 0)) return !1;
@@ -8308,12 +8308,12 @@ var Bi = class {
8308
8308
  i !== void 0 && g?.fontFamily !== i && (_.fontFamily = i, v = !0), a !== void 0 && g?.fontSize !== a && (_.fontSize = a, v = !0), s !== void 0 && g?.fontWeight !== s && (_.fontWeight = s, v = !0), o !== void 0 && g?.fontStyle !== o && (_.fontStyle = o, v = !0), d !== void 0 && g?.underline !== d && (_.underline = d, v = !0), c !== void 0 && g?.linethrough !== c && (_.linethrough = c, v = !0), r !== void 0 && g?.fill !== r && (_.fill = r, v = !0), l !== void 0 && (l === null && g?.stroke !== void 0 && (delete _.stroke, v = !0), l !== null && g?.stroke !== l && (_.stroke = l, v = !0)), u !== void 0 && g?.strokeWidth !== u && (_.strokeWidth = u, v = !0), v && (h ||= (p = { ...p }, !0), p[n] = _, m = !0);
8309
8309
  }
8310
8310
  return m && (e.lineFontDefaults = p), m;
8311
- }, sa = ({ lineStyles: e, lineDefaults: t }) => {
8311
+ }, ca = ({ lineStyles: e, lineDefaults: t }) => {
8312
8312
  if (!e) return {
8313
8313
  lineStyles: e,
8314
8314
  changed: !1
8315
8315
  };
8316
- let n = aa({ lineDefaults: t }), r = Object.keys(n);
8316
+ let n = oa({ lineDefaults: t }), r = Object.keys(n);
8317
8317
  if (!r.length) return {
8318
8318
  lineStyles: e,
8319
8319
  changed: !1
@@ -8337,7 +8337,7 @@ var Bi = class {
8337
8337
  lineStyles: e,
8338
8338
  changed: !1
8339
8339
  };
8340
- }, ca = ({ cleanup: e, lineCount: t, styles: n }) => {
8340
+ }, la = ({ cleanup: e, lineCount: t, styles: n }) => {
8341
8341
  if (!e) return {
8342
8342
  styles: n,
8343
8343
  changed: !1
@@ -8357,7 +8357,7 @@ var Bi = class {
8357
8357
  for (let t = 0; t < e.lineDefaults.length; t += 1) {
8358
8358
  let n = e.lineDefaults[t];
8359
8359
  if (!n) continue;
8360
- let a = sa({
8360
+ let a = ca({
8361
8361
  lineStyles: r,
8362
8362
  lineDefaults: n
8363
8363
  });
@@ -8372,19 +8372,19 @@ var Bi = class {
8372
8372
  styles: a,
8373
8373
  changed: !0
8374
8374
  };
8375
- }, la = ({ textbox: e }) => {
8375
+ }, ua = ({ textbox: e }) => {
8376
8376
  let { fontFamily: t, fontSize: n, fontStyle: r, fontWeight: i, fill: a, stroke: o, strokeWidth: s, linethrough: c, underline: l } = e, u = {}, d = typeof a == "string" ? a : void 0, f = typeof o == "string" ? o : void 0;
8377
8377
  return t !== void 0 && (u.fontFamily = t), n !== void 0 && (u.fontSize = n), i !== void 0 && (u.fontWeight = i), r !== void 0 && (u.fontStyle = r), l !== void 0 && (u.underline = l), c !== void 0 && (u.linethrough = c), d !== void 0 && (u.fill = d), f !== void 0 && (u.stroke = f), s !== void 0 && (u.strokeWidth = s), u;
8378
- }, ua = ({ sourceDefaults: e, globalLineDefaults: t }) => {
8378
+ }, da = ({ sourceDefaults: e, globalLineDefaults: t }) => {
8379
8379
  let n = {};
8380
8380
  return e?.fontFamily === void 0 ? t.fontFamily !== void 0 && (n.fontFamily = t.fontFamily) : n.fontFamily = e.fontFamily, e?.fontSize === void 0 ? t.fontSize !== void 0 && (n.fontSize = t.fontSize) : n.fontSize = e.fontSize, e?.fontWeight === void 0 ? t.fontWeight !== void 0 && (n.fontWeight = t.fontWeight) : n.fontWeight = e.fontWeight, e?.fontStyle === void 0 ? t.fontStyle !== void 0 && (n.fontStyle = t.fontStyle) : n.fontStyle = e.fontStyle, e?.underline === void 0 ? t.underline !== void 0 && (n.underline = t.underline) : n.underline = e.underline, e?.linethrough === void 0 ? t.linethrough !== void 0 && (n.linethrough = t.linethrough) : n.linethrough = e.linethrough, e?.fill === void 0 ? t.fill !== void 0 && (n.fill = t.fill) : n.fill = e.fill, e?.stroke === void 0 ? t.stroke !== void 0 && (n.stroke = t.stroke) : n.stroke = e.stroke, e?.strokeWidth === void 0 ? n.stroke !== void 0 && t.strokeWidth !== void 0 && (n.strokeWidth = t.strokeWidth) : n.strokeWidth = e.strokeWidth, n;
8381
- }, da = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
8381
+ }, fa = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
8382
8382
  let r = e.length;
8383
8383
  if (r === 0) return {
8384
8384
  lineStyles: t,
8385
8385
  changed: !1
8386
8386
  };
8387
- let i = aa({ lineDefaults: n }), a = Object.keys(i);
8387
+ let i = oa({ lineDefaults: n }), a = Object.keys(i);
8388
8388
  if (!a.length) return {
8389
8389
  lineStyles: t,
8390
8390
  changed: !1
@@ -8410,8 +8410,8 @@ var Bi = class {
8410
8410
  lineStyles: o,
8411
8411
  changed: s
8412
8412
  };
8413
- }, fa = ({ deletedLineDefaultsCleanup: e, globalLineDefaults: t, lineFontDefaults: n, lines: r, styles: i }) => {
8414
- let a = n, o = !1, s = !1, c = i, l = !1, u = !1, d, f = ca({
8413
+ }, pa = ({ deletedLineDefaultsCleanup: e, globalLineDefaults: t, lineFontDefaults: n, lines: r, styles: i }) => {
8414
+ let a = n, o = !1, s = !1, c = i, l = !1, u = !1, d, f = la({
8415
8415
  styles: c ?? {},
8416
8416
  lineCount: r.length,
8417
8417
  cleanup: e
@@ -8422,7 +8422,7 @@ var Bi = class {
8422
8422
  if (i && (d = i), n.length !== 0) {
8423
8423
  let t = i;
8424
8424
  if (!t && d && (t = { ...d }, a || (a = {}, s = !0), s ||= (a = { ...a }, !0), a[e] = t, o = !0), t) {
8425
- let r = da({
8425
+ let r = fa({
8426
8426
  lineText: n,
8427
8427
  lineStyles: c ? c[e] : void 0,
8428
8428
  lineDefaults: t
@@ -8431,12 +8431,12 @@ var Bi = class {
8431
8431
  }
8432
8432
  continue;
8433
8433
  }
8434
- let f = ua({
8434
+ let f = da({
8435
8435
  sourceDefaults: i ?? d,
8436
8436
  globalLineDefaults: t
8437
8437
  });
8438
8438
  !i && Object.keys(f).length && (a || (a = {}, s = !0), s ||= (a = { ...a }, !0), a[e] = f, o = !0, d = f), i && (d = i);
8439
- let p = aa({ lineDefaults: f }), m = Object.keys(p).length > 0;
8439
+ let p = oa({ lineDefaults: f }), m = Object.keys(p).length > 0;
8440
8440
  (m || c && c[e]) && (c || (c = {}, u = !0), u ||= (c = { ...c }, !0), m && (c[e] = { 0: p }), !m && c[e] && delete c[e], l = !0);
8441
8441
  }
8442
8442
  return {
@@ -8446,8 +8446,8 @@ var Bi = class {
8446
8446
  stylesChanged: l
8447
8447
  };
8448
8448
  };
8449
- function pa({ textbox: e }) {
8450
- let t = (e.text ?? "").split("\n"), n = la({ textbox: e }), r = fa({
8449
+ function ma({ textbox: e }) {
8450
+ let t = (e.text ?? "").split("\n"), n = ua({ textbox: e }), r = pa({
8451
8451
  lines: t,
8452
8452
  styles: e.styles,
8453
8453
  lineFontDefaults: e.lineFontDefaults,
@@ -8459,7 +8459,7 @@ function pa({ textbox: e }) {
8459
8459
  if (!Number.isInteger(t) || t < 0) continue;
8460
8460
  let o = r.styles[e];
8461
8461
  if (!o) continue;
8462
- let s = sa({
8462
+ let s = ca({
8463
8463
  lineStyles: o,
8464
8464
  lineDefaults: i?.[t] ?? n
8465
8465
  });
@@ -8470,31 +8470,31 @@ function pa({ textbox: e }) {
8470
8470
  styles: a
8471
8471
  };
8472
8472
  }
8473
- var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8474
- let r = ia({
8473
+ var ha = ({ currentText: e, previousText: t, textbox: n }) => {
8474
+ let r = aa({
8475
8475
  lineFontDefaults: n.lineFontDefaults,
8476
8476
  previousText: t,
8477
8477
  currentText: e
8478
- }), i = fa({
8478
+ }), i = pa({
8479
8479
  lines: e.split("\n"),
8480
8480
  styles: n.styles,
8481
8481
  lineFontDefaults: r.lineFontDefaults,
8482
8482
  deletedLineDefaultsCleanup: r.deletedLineDefaultsCleanup,
8483
- globalLineDefaults: la({ textbox: n })
8483
+ globalLineDefaults: ua({ textbox: n })
8484
8484
  });
8485
8485
  return {
8486
8486
  ...i,
8487
8487
  lineFontDefaultsChanged: r.changed || i.lineFontDefaultsChanged
8488
8488
  };
8489
- }, ha = ({ textbox: e }) => {
8490
- let t = fa({
8489
+ }, ga = ({ textbox: e }) => {
8490
+ let t = pa({
8491
8491
  lines: (e.text ?? "").split("\n"),
8492
8492
  styles: e.styles,
8493
8493
  lineFontDefaults: e.lineFontDefaults,
8494
- globalLineDefaults: la({ textbox: e })
8494
+ globalLineDefaults: ua({ textbox: e })
8495
8495
  }), n = !1;
8496
8496
  return t.lineFontDefaultsChanged && (e.lineFontDefaults = t.lineFontDefaults, n = !0), t.stylesChanged && (e.styles = t.styles, e.dirty = !0, n = !0), n;
8497
- }, ga = ({ lineFontDefaults: e }) => {
8497
+ }, _a = ({ lineFontDefaults: e }) => {
8498
8498
  if (!e) return;
8499
8499
  let t = {};
8500
8500
  for (let n in e) {
@@ -8505,7 +8505,7 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8505
8505
  i && (t[r] = { ...i });
8506
8506
  }
8507
8507
  return t;
8508
- }, _a = ({ lineFontDefaults: e, scale: t }) => {
8508
+ }, va = ({ lineFontDefaults: e, scale: t }) => {
8509
8509
  if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
8510
8510
  let n = {}, r = !1, i = !1;
8511
8511
  for (let a in e) {
@@ -8522,18 +8522,18 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8522
8522
  n[o] = c, r = !0;
8523
8523
  }
8524
8524
  if (!(!r || !i)) return n;
8525
- }, va = ({ textbox: e, text: t }) => {
8525
+ }, ya = ({ textbox: e, text: t }) => {
8526
8526
  let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
8527
8527
  for (let t = 0; t < r; t += 1) {
8528
8528
  let n = e.getLineWidth(t);
8529
8529
  n > i && (i = n);
8530
8530
  }
8531
8531
  return i;
8532
- }, ya = ({ origin: e, size: t }) => e === "left" || e === "top" || e === 0 ? 0 : e === "right" || e === "bottom" || e === 1 ? t : t / 2, ba = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
8533
- let r = e.width ?? e.calcTextWidth() ?? 0, i = e.height ?? e.calcTextHeight() ?? 0, a = e.paddingTop ?? 0, o = e.paddingRight ?? 0, s = e.paddingBottom ?? 0, c = e.paddingLeft ?? 0, l = -r / 2 + (c - o) / 2, u = -i / 2 + (a - s) / 2, d = new m(l + ya({
8532
+ }, ba = ({ origin: e, size: t }) => e === "left" || e === "top" || e === 0 ? 0 : e === "right" || e === "bottom" || e === 1 ? t : t / 2, xa = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
8533
+ let r = e.width ?? e.calcTextWidth() ?? 0, i = e.height ?? e.calcTextHeight() ?? 0, a = e.paddingTop ?? 0, o = e.paddingRight ?? 0, s = e.paddingBottom ?? 0, c = e.paddingLeft ?? 0, l = -r / 2 + (c - o) / 2, u = -i / 2 + (a - s) / 2, d = new m(l + ba({
8534
8534
  origin: t,
8535
8535
  size: r
8536
- }), u + ya({
8536
+ }), u + ba({
8537
8537
  origin: n,
8538
8538
  size: i
8539
8539
  })), f = e.getPointByOrigin("center", "center"), p = e, h = typeof p.calcTransformMatrix == "function" ? p.calcTransformMatrix() : null, g = Array.isArray(h) ? new m(d.x * h[0] + d.y * h[2] + f.x, d.x * h[1] + d.y * h[3] + f.y) : new m(f.x + d.x, f.y + d.y);
@@ -8543,13 +8543,13 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8543
8543
  originX: t,
8544
8544
  originY: n
8545
8545
  };
8546
- }, xa = ({ textbox: e, montageLeft: t, montageRight: n }) => {
8546
+ }, Sa = ({ textbox: e, montageLeft: t, montageRight: n }) => {
8547
8547
  e.setCoords();
8548
8548
  let r = e.getBoundingRect(), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
8549
8549
  if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
8550
8550
  let s = 0;
8551
8551
  return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
8552
- }, Sa = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Ca = ({ stylesList: e }) => {
8552
+ }, Ca = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, wa = ({ stylesList: e }) => {
8553
8553
  let t = e.length;
8554
8554
  if (!t) return !1;
8555
8555
  for (let n = 0; n < t; n += 1) {
@@ -8559,19 +8559,19 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8559
8559
  if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
8560
8560
  }
8561
8561
  return !1;
8562
- }, wa = ({ textbox: e }) => {
8563
- let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s = Sa({
8562
+ }, Ta = ({ textbox: e }) => {
8563
+ let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s = Ca({
8564
8564
  rawValue: t,
8565
8565
  calculatedValue: a
8566
- }), c = Sa({
8566
+ }), c = Ca({
8567
8567
  rawValue: n,
8568
8568
  calculatedValue: o
8569
8569
  }), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
8570
8570
  return l !== null && l !== s && (d.width = Math.max(0, l)), u !== null && u !== c && (d.height = Math.max(0, u)), Object.keys(d).length ? (e.set(d), !0) : !1;
8571
- }, Ta = ({ text: e }) => Math.max((typeof e == "string" ? e : "").split("\n").length, 1), Ea = ({ textbox: e, fallbackLineCount: t }) => {
8571
+ }, Ea = ({ text: e }) => Math.max((typeof e == "string" ? e : "").split("\n").length, 1), Da = ({ textbox: e, fallbackLineCount: t }) => {
8572
8572
  let { textLines: n } = e;
8573
8573
  return Array.isArray(n) && n.length > 0 ? n.length : t;
8574
- }, Da = ({ textbox: e, shouldRoundDimensions: t }) => {
8574
+ }, Oa = ({ textbox: e, shouldRoundDimensions: t }) => {
8575
8575
  let n = e.shouldRoundDimensionsOnInit;
8576
8576
  e.shouldRoundDimensionsOnInit = t;
8577
8577
  try {
@@ -8579,35 +8579,35 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8579
8579
  } finally {
8580
8580
  e.shouldRoundDimensionsOnInit = n;
8581
8581
  }
8582
- }, Oa = ({ textbox: e, canvasManager: t }) => {
8582
+ }, ka = ({ textbox: e, canvasManager: t }) => {
8583
8583
  let { width: n } = t.getMontageAreaSceneBounds(), r = Math.abs(e.scaleX ?? 1) || 1, i = e.paddingLeft ?? 0, a = e.paddingRight ?? 0, o = e.strokeWidth ?? 0;
8584
8584
  return Math.max(1, n / r - i - a - o);
8585
- }, ka = ({ textbox: e, canvasManager: t, base: n, committedWidth: r, shouldScaleFontSize: i, shouldRoundDimensions: a }) => {
8585
+ }, Aa = ({ textbox: e, canvasManager: t, base: n, committedWidth: r, shouldScaleFontSize: i, shouldRoundDimensions: a }) => {
8586
8586
  if (!i || e.autoExpand === !1) return;
8587
- let o = n.explicitLineCount ?? Ta({ text: e.text });
8588
- if ((n.renderedLineCount ?? o) > o || Ea({
8587
+ let o = n.explicitLineCount ?? Ea({ text: e.text });
8588
+ if ((n.renderedLineCount ?? o) > o || Da({
8589
8589
  textbox: e,
8590
8590
  fallbackLineCount: o
8591
8591
  }) <= o) return;
8592
- let s = e.width ?? r, c = Oa({
8592
+ let s = e.width ?? r, c = ka({
8593
8593
  textbox: e,
8594
8594
  canvasManager: t
8595
8595
  });
8596
8596
  if (c <= s + .01) return;
8597
- e.set({ width: c }), Da({
8597
+ e.set({ width: c }), Oa({
8598
8598
  textbox: e,
8599
8599
  shouldRoundDimensions: a
8600
8600
  });
8601
- let l = typeof e.text == "string" ? e.text : "", u = Math.min(c, Math.max(s, Math.ceil(va({
8601
+ let l = typeof e.text == "string" ? e.text : "", u = Math.min(c, Math.max(s, Math.ceil(ya({
8602
8602
  textbox: e,
8603
8603
  text: l
8604
8604
  }))));
8605
- e.set({ width: u }), Da({
8605
+ e.set({ width: u }), Oa({
8606
8606
  textbox: e,
8607
8607
  shouldRoundDimensions: a
8608
8608
  });
8609
- }, Aa = ({ textbox: e }) => {
8610
- let t = e.width ?? e.calcTextWidth(), n = e.fontSize ?? 16, r = Ta({ text: e.text }), i = Ea({
8609
+ }, ja = ({ textbox: e }) => {
8610
+ let t = e.width ?? e.calcTextWidth(), n = e.fontSize ?? 16, r = Ea({ text: e.text }), i = Da({
8611
8611
  textbox: e,
8612
8612
  fallbackLineCount: r
8613
8613
  }), { styles: a = {} } = e, { lineFontDefaults: o } = e, { paddingTop: s = 0, paddingRight: c = 0, paddingBottom: l = 0, paddingLeft: u = 0 } = e, { radiusTopLeft: d = 0, radiusTopRight: f = 0, radiusBottomRight: p = 0, radiusBottomLeft: m = 0 } = e;
@@ -8629,9 +8629,9 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8629
8629
  bottomLeft: m
8630
8630
  },
8631
8631
  styles: JSON.parse(JSON.stringify(a)),
8632
- lineFontDefaults: ga({ lineFontDefaults: o })
8632
+ lineFontDefaults: _a({ lineFontDefaults: o })
8633
8633
  };
8634
- }, ja = ({ base: e }) => {
8634
+ }, Ma = ({ base: e }) => {
8635
8635
  let t = 1 / Math.max(1, e.width), n = [e.fontSize];
8636
8636
  Object.values(e.styles).forEach((e) => {
8637
8637
  Object.values(e).forEach((e) => {
@@ -8648,7 +8648,7 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8648
8648
  fontScale: r,
8649
8649
  proportionalScale: Math.max(t, r)
8650
8650
  };
8651
- }, Ma = ({ textbox: e, base: t, scale: n, shouldScaleFontSize: r = !0, shouldScalePadding: i = !0, shouldScaleRadii: a = !0 }) => {
8651
+ }, Na = ({ textbox: e, base: t, scale: n, shouldScaleFontSize: r = !0, shouldScalePadding: i = !0, shouldScaleRadii: a = !0 }) => {
8652
8652
  let { fontSize: o, padding: s, radii: c, styles: l, lineFontDefaults: u } = t, d = Math.max(Math.min(8, o), o * n), f = Object.keys(l).length > 0, p;
8653
8653
  if (r && f) {
8654
8654
  let e = {};
@@ -8667,7 +8667,7 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8667
8667
  }), Object.keys(e).length && (p = e);
8668
8668
  }
8669
8669
  let m;
8670
- r && (m = _a({
8670
+ r && (m = va({
8671
8671
  lineFontDefaults: u,
8672
8672
  scale: n
8673
8673
  }));
@@ -8693,9 +8693,9 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8693
8693
  radiusBottomRight: g.bottomRight,
8694
8694
  radiusBottomLeft: g.bottomLeft
8695
8695
  });
8696
- }, Na = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, anchorPlacement: o, shouldScaleFontSize: s, shouldScalePadding: c, shouldScaleRadii: l, shouldDisableAutoExpandOnHorizontalChange: u = !1, shouldRoundDimensions: d = !0 }) => {
8697
- let { width: f } = n, p = Math.max(1, f * r), h = d ? Math.max(1, Math.round(p)) : p, g = e.width ?? f, _ = Math.abs(h - g) > qi;
8698
- u && _ && (e.autoExpand = !1), Ma({
8696
+ }, Pa = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, anchorPlacement: o, shouldScaleFontSize: s, shouldScalePadding: c, shouldScaleRadii: l, shouldDisableAutoExpandOnHorizontalChange: u = !1, shouldRoundDimensions: d = !0 }) => {
8697
+ let { width: f } = n, p = Math.max(1, f * r), h = d ? Math.max(1, Math.round(p)) : p, g = e.width ?? f, _ = Math.abs(h - g) > Ji;
8698
+ u && _ && (e.autoExpand = !1), Na({
8699
8699
  textbox: e,
8700
8700
  base: n,
8701
8701
  scale: i,
@@ -8706,10 +8706,10 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8706
8706
  width: h,
8707
8707
  scaleX: 1,
8708
8708
  scaleY: 1
8709
- }), Da({
8709
+ }), Oa({
8710
8710
  textbox: e,
8711
8711
  shouldRoundDimensions: d
8712
- }), ka({
8712
+ }), Aa({
8713
8713
  textbox: e,
8714
8714
  canvasManager: t,
8715
8715
  base: n,
@@ -8717,7 +8717,7 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8717
8717
  shouldScaleFontSize: s,
8718
8718
  shouldRoundDimensions: d
8719
8719
  });
8720
- let v = d ? wa({ textbox: e }) : !1;
8720
+ let v = d ? Ta({ textbox: e }) : !1;
8721
8721
  return v && (e.dirty = !0), o ? (e.set({
8722
8722
  originX: a.originX,
8723
8723
  originY: a.originY
@@ -8734,7 +8734,7 @@ var ma = ({ currentText: e, previousText: t, textbox: n }) => {
8734
8734
  };
8735
8735
  //#endregion
8736
8736
  //#region src/editor/shape-manager/mutation/shape-rehydration.ts
8737
- function Pa({ group: e }) {
8737
+ function Fa({ group: e }) {
8738
8738
  let t = Math.abs(e.scaleX ?? 1) || 1, n = Math.abs(e.scaleY ?? 1) || 1, r = Math.max(1, e.shapeBaseWidth ?? e.width ?? 1), i = Math.max(1, e.shapeBaseHeight ?? e.height ?? 1);
8739
8739
  return {
8740
8740
  currentDimensions: {
@@ -8751,17 +8751,17 @@ function Pa({ group: e }) {
8751
8751
  }
8752
8752
  };
8753
8753
  }
8754
- function Fa({ group: e, text: t, textScale: n }) {
8754
+ function Ia({ group: e, text: t, textScale: n }) {
8755
8755
  let r = Number.isFinite(n) && n > 0 ? n : 1;
8756
- Math.abs(r - 1) <= 1e-4 || (Ma({
8756
+ Math.abs(r - 1) <= 1e-4 || (Na({
8757
8757
  textbox: t,
8758
- base: Aa({ textbox: t }),
8758
+ base: ja({ textbox: t }),
8759
8759
  scale: r
8760
8760
  }), e.shapePaddingTop = Math.max(0, (e.shapePaddingTop ?? 0) * r), e.shapePaddingRight = Math.max(0, (e.shapePaddingRight ?? 0) * r), e.shapePaddingBottom = Math.max(0, (e.shapePaddingBottom ?? 0) * r), e.shapePaddingLeft = Math.max(0, (e.shapePaddingLeft ?? 0) * r));
8761
8761
  }
8762
8762
  //#endregion
8763
8763
  //#region src/editor/shape-manager/mutation/shape-update-pipeline.ts
8764
- var Ia = {
8764
+ var La = {
8765
8765
  angle: 0,
8766
8766
  skewX: 0,
8767
8767
  skewY: 0,
@@ -8774,7 +8774,7 @@ var Ia = {
8774
8774
  top: 0,
8775
8775
  originX: "left",
8776
8776
  originY: "top"
8777
- }, La = class {
8777
+ }, Ra = class {
8778
8778
  constructor({ runtime: e }) {
8779
8779
  this.runtime = e;
8780
8780
  }
@@ -9072,7 +9072,7 @@ var Ia = {
9072
9072
  width: Math.max(1, e.width ?? t),
9073
9073
  align: n
9074
9074
  });
9075
- return s.set(Ia), this.runtime.applyTextUpdates({
9075
+ return s.set(La), this.runtime.applyTextUpdates({
9076
9076
  textNode: s,
9077
9077
  text: r,
9078
9078
  textStyle: i,
@@ -9134,9 +9134,9 @@ var Ia = {
9134
9134
  shouldPreserveCurrentWidth: r
9135
9135
  };
9136
9136
  }
9137
- }, Ra = class {
9137
+ }, za = class {
9138
9138
  constructor({ runtime: e }) {
9139
- this.runtime = e, this.updatePipeline = new La({ runtime: e });
9139
+ this.runtime = e, this.updatePipeline = new Ra({ runtime: e });
9140
9140
  }
9141
9141
  async update({ target: e, presetKey: t, options: n = {} } = {}) {
9142
9142
  let r = await this.updatePipeline.prepare({
@@ -9312,8 +9312,8 @@ var Ia = {
9312
9312
  if (!r) return !1;
9313
9313
  let { shape: i, text: a } = H({ group: r });
9314
9314
  if (!i || !a) return !1;
9315
- let o = this.runtime.editor.canvasManager.getObjectPlacement({ object: r }), { currentDimensions: s, manualDimensions: c, replaceBoxDimensions: l } = Pa({ group: r });
9316
- return Fa({
9315
+ let o = this.runtime.editor.canvasManager.getObjectPlacement({ object: r }), { currentDimensions: s, manualDimensions: c, replaceBoxDimensions: l } = Fa({ group: r });
9316
+ return Ia({
9317
9317
  group: r,
9318
9318
  text: a,
9319
9319
  textScale: t
@@ -9382,7 +9382,7 @@ var Ia = {
9382
9382
  }
9383
9383
  _applyPreparedTextState({ preparedUpdate: e }) {
9384
9384
  let { current: t, text: n } = e;
9385
- this.runtime.detachShapeGroupAutoLayout({ group: t.group }), t.text.set(Ia), this.runtime.applyTextUpdates({
9385
+ this.runtime.detachShapeGroupAutoLayout({ group: t.group }), t.text.set(La), this.runtime.applyTextUpdates({
9386
9386
  textNode: t.text,
9387
9387
  text: n.value,
9388
9388
  textStyle: n.style,
@@ -9436,9 +9436,9 @@ var Ia = {
9436
9436
  let { current: t, next: n, layout: r, placement: i } = e;
9437
9437
  n.shouldFitReplacementToPreset && (t.group.shapeManualBaseWidth = Math.max(1, t.group.shapeBaseWidth ?? r.width), t.group.shapeManualBaseHeight = Math.max(1, t.group.shapeBaseHeight ?? r.height)), t.text.isEditing && this.runtime.editingPlacements.set(t.group, i);
9438
9438
  }
9439
- }, za = class {
9439
+ }, Ba = class {
9440
9440
  constructor({ editor: e }) {
9441
- this.editor = e, tt(), this.scalingController = new Vi({ canvas: e.canvas }), this.editingController = new Hi({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new Ki({ canvas: e.canvas }), this.layoutController = new Gi({ editor: this.editor }), this.mutationController = new Ra({ runtime: {
9441
+ this.editor = e, tt(), this.scalingController = new Hi({ canvas: e.canvas }), this.editingController = new Ui({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new qi({ canvas: e.canvas }), this.layoutController = new Ki({ editor: this.editor }), this.mutationController = new za({ runtime: {
9442
9442
  editor: this.editor,
9443
9443
  lifecycleController: this.lifecycleController,
9444
9444
  editingPlacements: this.editingPlacements,
@@ -9462,7 +9462,7 @@ var Ia = {
9462
9462
  beginMutation: () => this._beginMutation(),
9463
9463
  endMutation: (e) => this._endMutation(e),
9464
9464
  isOnCanvas: (e) => this._isOnCanvas(e)
9465
- } }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this.eventController = new Wi({ runtime: {
9465
+ } }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this.eventController = new Gi({ runtime: {
9466
9466
  editor: this.editor,
9467
9467
  scalingController: this.scalingController,
9468
9468
  editingController: this.editingController,
@@ -9996,7 +9996,7 @@ var Ia = {
9996
9996
  }
9997
9997
  return null;
9998
9998
  }
9999
- }, Ba = ({ rootObject: t, enableEvented: n = !0 }) => {
9999
+ }, Va = ({ rootObject: t, enableEvented: n = !0 }) => {
10000
10000
  let r = [{
10001
10001
  object: t,
10002
10002
  enableEvented: n
@@ -10010,7 +10010,7 @@ var Ia = {
10010
10010
  enableEvented: o
10011
10011
  });
10012
10012
  }
10013
- }, Va = class {
10013
+ }, Ha = class {
10014
10014
  constructor({ editor: e }) {
10015
10015
  this.editor = e, this.clipboard = null;
10016
10016
  }
@@ -10174,7 +10174,7 @@ var Ia = {
10174
10174
  if (!n || n.locked) return !1;
10175
10175
  try {
10176
10176
  let e = await n.clone(qt);
10177
- return Ba({ rootObject: e }), e.set({
10177
+ return Va({ rootObject: e }), e.set({
10178
10178
  left: e.left + 10,
10179
10179
  top: e.top + 10
10180
10180
  }), this._materializeCloneGeometry({ clonedObject: e }), this._addClonedObjectToCanvas(e), t.fire("editor:object-duplicated", {
@@ -10262,7 +10262,7 @@ var Ia = {
10262
10262
  if (!this.clipboard) return !1;
10263
10263
  try {
10264
10264
  let t = await this.clipboard.clone(qt);
10265
- return e.discardActiveObject(), Ba({ rootObject: t }), t.set({
10265
+ return e.discardActiveObject(), Va({ rootObject: t }), t.set({
10266
10266
  left: t.left + 10,
10267
10267
  top: t.top + 10
10268
10268
  }), this._materializeCloneGeometry({ clonedObject: t }), this._addClonedObjectToCanvas(t), e.fire("editor:object-pasted", {
@@ -10281,7 +10281,7 @@ var Ia = {
10281
10281
  }), !1;
10282
10282
  }
10283
10283
  }
10284
- }, Ha = class t {
10284
+ }, Ua = class t {
10285
10285
  constructor({ editor: e }) {
10286
10286
  this.editor = e;
10287
10287
  }
@@ -10346,7 +10346,7 @@ var Ia = {
10346
10346
  !(n instanceof v) || !n.isEditing || n.exitEditing();
10347
10347
  }
10348
10348
  }
10349
- }, Ua = class {
10349
+ }, Wa = class {
10350
10350
  constructor({ editor: e }) {
10351
10351
  this.editor = e;
10352
10352
  }
@@ -10418,7 +10418,7 @@ var Ia = {
10418
10418
  i.resumeHistory(), n || i.saveState();
10419
10419
  }
10420
10420
  }
10421
- }, Wa = class t {
10421
+ }, Ga = class t {
10422
10422
  constructor({ editor: e }) {
10423
10423
  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();
10424
10424
  }
@@ -10612,7 +10612,7 @@ var Ia = {
10612
10612
  let { options: e } = this.editor, { selectionKey: t } = e;
10613
10613
  return t === void 0 ? ["ctrlKey", "metaKey"] : t;
10614
10614
  }
10615
- }, Ga = class e {
10615
+ }, Ka = class e {
10616
10616
  constructor({ editor: e }) {
10617
10617
  this.editor = e;
10618
10618
  }
@@ -10652,7 +10652,7 @@ var Ia = {
10652
10652
  };
10653
10653
  return i.fire("editor:objects-deleted", l), l;
10654
10654
  }
10655
- }, Ka = {
10655
+ }, qa = {
10656
10656
  IMAGE_MANAGER: {
10657
10657
  INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
10658
10658
  INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
@@ -10695,7 +10695,7 @@ var Ia = {
10695
10695
  INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
10696
10696
  APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
10697
10697
  }
10698
- }, qa = class e {
10698
+ }, Ja = class e {
10699
10699
  constructor({ editor: e }) {
10700
10700
  this._buffer = [], this.editor = e;
10701
10701
  }
@@ -10753,9 +10753,9 @@ var Ia = {
10753
10753
  }), this.editor.canvas.fire("editor:warning", s);
10754
10754
  }
10755
10755
  static isValidErrorCode(e) {
10756
- return e ? Object.values(Ka).some((t) => Object.values(t).includes(e)) : !1;
10756
+ return e ? Object.values(qa).some((t) => Object.values(t).includes(e)) : !1;
10757
10757
  }
10758
- }, Ja = 48, Ya = class e {
10758
+ }, Ya = 48, Xa = class e {
10759
10759
  constructor({ editor: e }) {
10760
10760
  this.currentBounds = null, this.editor = e;
10761
10761
  }
@@ -10859,7 +10859,7 @@ var Ia = {
10859
10859
  };
10860
10860
  }
10861
10861
  static _getScrollDistance({ contentSize: e, viewportSize: t }) {
10862
- let n = Math.max(1, t - Ja * 2);
10862
+ let n = Math.max(1, t - Ya * 2);
10863
10863
  return Math.max(0, e - n);
10864
10864
  }
10865
10865
  static _createLockedAxisState({ contentSize: e, current: t, viewportSize: n }) {
@@ -10891,32 +10891,32 @@ var Ia = {
10891
10891
  updateBounds() {
10892
10892
  this.currentBounds = this.calculatePanBounds();
10893
10893
  }
10894
- }, Xa = ({ textbox: e }) => {
10894
+ }, Za = ({ textbox: e }) => {
10895
10895
  if (!e.isEditing) return null;
10896
10896
  let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
10897
10897
  return t === n ? null : {
10898
10898
  start: Math.min(t, n),
10899
10899
  end: Math.max(t, n)
10900
10900
  };
10901
- }, Za = ({ textbox: e }) => {
10901
+ }, Qa = ({ textbox: e }) => {
10902
10902
  let t = e.text?.length ?? 0;
10903
10903
  return t <= 0 ? null : {
10904
10904
  start: 0,
10905
10905
  end: t
10906
10906
  };
10907
- }, Qa = ({ textbox: e, range: t }) => {
10907
+ }, $a = ({ textbox: e, range: t }) => {
10908
10908
  if (!t) return !1;
10909
10909
  let n = e.text?.length ?? 0;
10910
10910
  return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
10911
- }, $a = ({ textbox: e, styles: t, range: n }) => {
10911
+ }, eo = ({ textbox: e, styles: t, range: n }) => {
10912
10912
  if (!t || !Object.keys(t).length) return !1;
10913
10913
  let { start: r, end: i } = n;
10914
10914
  return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
10915
- }, eo = ({ textbox: e, range: t, property: n }) => {
10915
+ }, to = ({ textbox: e, range: t, property: n }) => {
10916
10916
  if (!t) return;
10917
10917
  let r = e.getSelectionStyles(t.start, t.end, !0);
10918
10918
  if (r.length) return r[0]?.[n];
10919
- }, to = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", no = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, ro = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", io = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), ao = class e extends v {
10919
+ }, no = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", ro = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, io = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", ao = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), oo = class e extends v {
10920
10920
  static {
10921
10921
  this.type = "background-textbox";
10922
10922
  }
@@ -10953,7 +10953,7 @@ var Ia = {
10953
10953
  ];
10954
10954
  }
10955
10955
  constructor(e, t = {}) {
10956
- if (super(e, t), this.backgroundOpacity = t.backgroundOpacity ?? 1, this.lineFontDefaults = t.lineFontDefaults ?? void 0, this.paddingTop = t.paddingTop ?? 0, this.paddingRight = t.paddingRight ?? 0, this.paddingBottom = t.paddingBottom ?? 0, this.paddingLeft = t.paddingLeft ?? 0, this.radiusTopLeft = t.radiusTopLeft ?? 0, this.radiusTopRight = t.radiusTopRight ?? 0, this.radiusBottomRight = t.radiusBottomRight ?? 0, this.radiusBottomLeft = t.radiusBottomLeft ?? 0, ha({ textbox: this })) {
10956
+ if (super(e, t), this.backgroundOpacity = t.backgroundOpacity ?? 1, this.lineFontDefaults = t.lineFontDefaults ?? void 0, this.paddingTop = t.paddingTop ?? 0, this.paddingRight = t.paddingRight ?? 0, this.paddingBottom = t.paddingBottom ?? 0, this.paddingLeft = t.paddingLeft ?? 0, this.radiusTopLeft = t.radiusTopLeft ?? 0, this.radiusTopRight = t.radiusTopRight ?? 0, this.radiusBottomRight = t.radiusBottomRight ?? 0, this.radiusBottomLeft = t.radiusBottomLeft ?? 0, ga({ textbox: this })) {
10957
10957
  this.initDimensions(), this.dirty = !0;
10958
10958
  return;
10959
10959
  }
@@ -10992,7 +10992,7 @@ var Ia = {
10992
10992
  });
10993
10993
  }
10994
10994
  toObject(e = []) {
10995
- let t = super.toObject(e), { lineFontDefaults: n, styles: r } = pa({ textbox: this });
10995
+ let t = super.toObject(e), { lineFontDefaults: n, styles: r } = ma({ textbox: this });
10996
10996
  return {
10997
10997
  ...t,
10998
10998
  backgroundOpacity: this.backgroundOpacity,
@@ -11060,7 +11060,7 @@ var Ia = {
11060
11060
  this._removeShadow(e);
11061
11061
  }
11062
11062
  _getDecorationColorAt(e, t) {
11063
- let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = no({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : to({
11063
+ let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = ro({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : no({
11064
11064
  strokeColor: i,
11065
11065
  width: r
11066
11066
  });
@@ -11076,22 +11076,22 @@ var Ia = {
11076
11076
  _getCornerRadii({ width: e, height: t }) {
11077
11077
  let n = e / 2, r = t / 2, i = Math.min(n, r);
11078
11078
  return {
11079
- bottomLeft: io({
11079
+ bottomLeft: ao({
11080
11080
  value: this.radiusBottomLeft ?? 0,
11081
11081
  min: 0,
11082
11082
  max: i
11083
11083
  }),
11084
- bottomRight: io({
11084
+ bottomRight: ao({
11085
11085
  value: this.radiusBottomRight ?? 0,
11086
11086
  min: 0,
11087
11087
  max: i
11088
11088
  }),
11089
- topLeft: io({
11089
+ topLeft: ao({
11090
11090
  value: this.radiusTopLeft ?? 0,
11091
11091
  min: 0,
11092
11092
  max: i
11093
11093
  }),
11094
- topRight: io({
11094
+ topRight: ao({
11095
11095
  value: this.radiusTopRight ?? 0,
11096
11096
  min: 0,
11097
11097
  max: i
@@ -11109,7 +11109,7 @@ var Ia = {
11109
11109
  _getEffectiveBackgroundFill() {
11110
11110
  let e = this.backgroundColor;
11111
11111
  if (!e) return null;
11112
- let t = io({
11112
+ let t = ao({
11113
11113
  value: this.backgroundOpacity ?? 1,
11114
11114
  min: 0,
11115
11115
  max: 1
@@ -11122,19 +11122,19 @@ var Ia = {
11122
11122
  return r.setAlpha(t), r.toRgba();
11123
11123
  }
11124
11124
  static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
11125
- let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = io({
11125
+ let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = ao({
11126
11126
  value: c,
11127
11127
  min: 0,
11128
11128
  max: a
11129
- }), p = io({
11129
+ }), p = ao({
11130
11130
  value: l,
11131
11131
  min: 0,
11132
11132
  max: a
11133
- }), m = io({
11133
+ }), m = ao({
11134
11134
  value: u,
11135
11135
  min: 0,
11136
11136
  max: a
11137
- }), h = io({
11137
+ }), h = ao({
11138
11138
  value: d,
11139
11139
  min: 0,
11140
11140
  max: a
@@ -11145,9 +11145,9 @@ var Ia = {
11145
11145
  let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
11146
11146
  n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
11147
11147
  }
11148
- }, oo = () => {
11149
- b?.setClass && b.setClass(ao, "background-textbox");
11150
- }, so = class {
11148
+ }, so = () => {
11149
+ b?.setClass && b.setClass(oo, "background-textbox");
11150
+ }, co = class {
11151
11151
  constructor({ runtime: e }) {
11152
11152
  this.runtime = e;
11153
11153
  }
@@ -11211,16 +11211,16 @@ var Ia = {
11211
11211
  };
11212
11212
  }
11213
11213
  _createSelectionContext({ textbox: e, currentText: t, selectionRangeOverride: n }) {
11214
- let r = n === void 0 ? Xa({ textbox: e }) : Yi({
11214
+ let r = n === void 0 ? Za({ textbox: e }) : Xi({
11215
11215
  text: t,
11216
11216
  range: n
11217
- }), i = r ? Xi({
11217
+ }), i = r ? Zi({
11218
11218
  textbox: e,
11219
11219
  range: r
11220
- }) : null, a = Qa({
11220
+ }) : null, a = $a({
11221
11221
  textbox: e,
11222
11222
  range: r
11223
- }), o = Qa({
11223
+ }), o = $a({
11224
11224
  textbox: e,
11225
11225
  range: i
11226
11226
  }), s = !r || a;
@@ -11308,17 +11308,17 @@ var Ia = {
11308
11308
  t.resolvedStrokeColor = i.stroke, t.resolvedStrokeWidth = i.strokeWidth, r.selectionRange && (t.selectionStyles.stroke = i.stroke, t.selectionStyles.strokeWidth = i.strokeWidth), r.shouldUpdateWholeObject && (t.updates.stroke = i.stroke, t.updates.strokeWidth = i.strokeWidth, r.shouldApplyWholeTextStyles && (t.wholeTextStyles.stroke = i.stroke, t.wholeTextStyles.strokeWidth = i.strokeWidth));
11309
11309
  }
11310
11310
  _resolveStrokeUpdate({ textbox: e, selectionRange: t, strokeColor: n, strokeWidth: r }) {
11311
- let i = t ? eo({
11311
+ let i = t ? to({
11312
11312
  textbox: e,
11313
11313
  range: t,
11314
11314
  property: "strokeWidth"
11315
- }) : void 0, a = t ? eo({
11315
+ }) : void 0, a = t ? to({
11316
11316
  textbox: e,
11317
11317
  range: t,
11318
11318
  property: "stroke"
11319
- }) : void 0, o = typeof i == "number" ? i : void 0, s = typeof a == "string" ? a : void 0, c = typeof e.stroke == "string" ? e.stroke : void 0, l = no({ width: r ?? o ?? e.strokeWidth ?? 0 });
11319
+ }) : void 0, o = typeof i == "number" ? i : void 0, s = typeof a == "string" ? a : void 0, c = typeof e.stroke == "string" ? e.stroke : void 0, l = ro({ width: r ?? o ?? e.strokeWidth ?? 0 });
11320
11320
  return {
11321
- stroke: to({
11321
+ stroke: no({
11322
11322
  strokeColor: n ?? s ?? c,
11323
11323
  width: l
11324
11324
  }) ?? null,
@@ -11330,14 +11330,14 @@ var Ia = {
11330
11330
  }
11331
11331
  _applyTextContentUpdate({ textbox: e, style: t, updates: n, currentText: r }) {
11332
11332
  let i = e.textCaseRaw ?? r, a = !!e.uppercase, o = t.text !== void 0, s = o ? t.text ?? "" : i, c = t.uppercase ?? a, l = c !== a, u = e.text ?? "";
11333
- return o || l ? (n.text = c ? ro({ value: s }) : s, e.textCaseRaw = s) : e.textCaseRaw === void 0 && (e.textCaseRaw = i), e.uppercase = c, {
11333
+ return o || l ? (n.text = c ? io({ value: s }) : s, e.textCaseRaw = s) : e.textCaseRaw === void 0 && (e.textCaseRaw = i), e.uppercase = c, {
11334
11334
  hasTextUpdate: o,
11335
11335
  uppercaseChanged: l,
11336
11336
  previousRenderedText: u
11337
11337
  };
11338
11338
  }
11339
11339
  _resolveContentPlacement({ textbox: e, style: t, updates: n, placement: r, styleMaps: i, contentUpdate: a }) {
11340
- let o = Ca({ stylesList: [
11340
+ let o = wa({ stylesList: [
11341
11341
  n,
11342
11342
  i.selectionStyles,
11343
11343
  i.lineSelectionStyles,
@@ -11353,7 +11353,7 @@ var Ia = {
11353
11353
  t.paddingBottom,
11354
11354
  t.paddingLeft
11355
11355
  ].some((e) => e !== void 0), l = Object.prototype.hasOwnProperty.call(n, "width");
11356
- return c && !s && !a.hasTextUpdate && !a.uppercaseChanged && !o && !l ? ba({
11356
+ return c && !s && !a.hasTextUpdate && !a.uppercaseChanged && !o && !l ? xa({
11357
11357
  textbox: e,
11358
11358
  originX: r.originX,
11359
11359
  originY: r.originY
@@ -11386,24 +11386,24 @@ var Ia = {
11386
11386
  }
11387
11387
  _applyWholeTextStyles({ textbox: e, selection: t, styleMaps: n }) {
11388
11388
  if (t.selectionRange || Object.keys(n.wholeTextStyles).length === 0) return;
11389
- let r = Za({ textbox: e });
11390
- r && $a({
11389
+ let r = Qa({ textbox: e });
11390
+ r && eo({
11391
11391
  textbox: e,
11392
11392
  styles: n.wholeTextStyles,
11393
11393
  range: r
11394
- }) && (e.dirty = !0, Ca({ stylesList: [n.wholeTextStyles] }) && (e.initDimensions(), e.dirty = !0));
11394
+ }) && (e.dirty = !0, wa({ stylesList: [n.wholeTextStyles] }) && (e.initDimensions(), e.dirty = !0));
11395
11395
  }
11396
11396
  _applySelectionStyles({ textbox: e, selection: t, styleMaps: n }) {
11397
11397
  if (!t.selectionRange) return;
11398
- let r = $a({
11398
+ let r = eo({
11399
11399
  textbox: e,
11400
11400
  styles: n.selectionStyles,
11401
11401
  range: t.selectionRange
11402
- }), i = t.fontSelectionRange ? $a({
11402
+ }), i = t.fontSelectionRange ? eo({
11403
11403
  textbox: e,
11404
11404
  styles: n.lineSelectionStyles,
11405
11405
  range: t.fontSelectionRange
11406
- }) : !1, a = Ca({ stylesList: [
11406
+ }) : !1, a = wa({ stylesList: [
11407
11407
  n.selectionStyles,
11408
11408
  n.lineSelectionStyles,
11409
11409
  n.wholeTextStyles
@@ -11425,9 +11425,9 @@ var Ia = {
11425
11425
  _applyFontLineDefaultUpdates({ textbox: e, style: t, selection: n }) {
11426
11426
  if (!n.fontSelectionRange || t.fontFamily === void 0 && t.fontSize === void 0) return;
11427
11427
  let r = {};
11428
- t.fontFamily !== void 0 && (r.fontFamily = t.fontFamily), t.fontSize !== void 0 && (r.fontSize = t.fontSize), oa({
11428
+ t.fontFamily !== void 0 && (r.fontFamily = t.fontFamily), t.fontSize !== void 0 && (r.fontSize = t.fontSize), sa({
11429
11429
  textbox: e,
11430
- lineIndices: Zi({
11430
+ lineIndices: Qi({
11431
11431
  textbox: e,
11432
11432
  range: n.fontSelectionRange
11433
11433
  }),
@@ -11437,9 +11437,9 @@ var Ia = {
11437
11437
  _applyDecorationLineDefaultUpdates({ textbox: e, style: t, selection: n, styleMaps: r }) {
11438
11438
  if (!n.selectionRange || !(t.bold !== void 0 || t.italic !== void 0 || t.underline !== void 0 || t.strikethrough !== void 0 || t.color !== void 0 || t.strokeColor !== void 0 || t.strokeWidth !== void 0)) return;
11439
11439
  let i = {};
11440
- r.resolvedFontWeight !== void 0 && (i.fontWeight = r.resolvedFontWeight), r.resolvedFontStyle !== void 0 && (i.fontStyle = r.resolvedFontStyle), t.underline !== void 0 && (i.underline = t.underline), t.strikethrough !== void 0 && (i.linethrough = t.strikethrough), t.color !== void 0 && (i.fill = t.color), (t.strokeColor !== void 0 || t.strokeWidth !== void 0) && (r.resolvedStrokeColor === null && (i.stroke = null), r.resolvedStrokeColor !== null && r.resolvedStrokeColor !== void 0 && (i.stroke = r.resolvedStrokeColor), r.resolvedStrokeWidth !== void 0 && (i.strokeWidth = r.resolvedStrokeWidth)), oa({
11440
+ r.resolvedFontWeight !== void 0 && (i.fontWeight = r.resolvedFontWeight), r.resolvedFontStyle !== void 0 && (i.fontStyle = r.resolvedFontStyle), t.underline !== void 0 && (i.underline = t.underline), t.strikethrough !== void 0 && (i.linethrough = t.strikethrough), t.color !== void 0 && (i.fill = t.color), (t.strokeColor !== void 0 || t.strokeWidth !== void 0) && (r.resolvedStrokeColor === null && (i.stroke = null), r.resolvedStrokeColor !== null && r.resolvedStrokeColor !== void 0 && (i.stroke = r.resolvedStrokeColor), r.resolvedStrokeWidth !== void 0 && (i.strokeWidth = r.resolvedStrokeWidth)), sa({
11441
11441
  textbox: e,
11442
- lineIndices: Qi({
11442
+ lineIndices: $i({
11443
11443
  textbox: e,
11444
11444
  range: n.selectionRange
11445
11445
  }),
@@ -11492,7 +11492,7 @@ var Ia = {
11492
11492
  return (t.autoExpand ?? e.autoExpand) !== !1 && !Object.prototype.hasOwnProperty.call(n.updates, "width") && r;
11493
11493
  }
11494
11494
  _shouldRefreshDimensions({ contentUpdate: e, styleMaps: t }) {
11495
- return e.hasTextUpdate || e.uppercaseChanged || Ca({ stylesList: [
11495
+ return e.hasTextUpdate || e.uppercaseChanged || wa({ stylesList: [
11496
11496
  t.updates,
11497
11497
  t.selectionStyles,
11498
11498
  t.lineSelectionStyles,
@@ -11536,18 +11536,18 @@ var Ia = {
11536
11536
  };
11537
11537
  this.runtime.canvas.fire("editor:text-updated", m);
11538
11538
  }
11539
- }, co = ({ transform: e }) => {
11539
+ }, lo = ({ transform: e }) => {
11540
11540
  let { corner: t = "", action: n = "" } = e;
11541
11541
  return {
11542
11542
  isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
11543
11543
  isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
11544
11544
  isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
11545
11545
  };
11546
- }, lo = ({ textbox: e, transform: t, appliedWidth: n }) => {
11546
+ }, uo = ({ textbox: e, transform: t, appliedWidth: n }) => {
11547
11547
  t.scaleX = 1, t.scaleY = 1;
11548
11548
  let r = t.original;
11549
11549
  r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
11550
- }, uo = ({ textbox: e, transform: t, scenePoint: n }) => {
11550
+ }, fo = ({ textbox: e, transform: t, scenePoint: n }) => {
11551
11551
  let { x: r, y: i } = e._getTransformedDimensions();
11552
11552
  if (r <= 0 || i <= 0) return null;
11553
11553
  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);
@@ -11557,27 +11557,27 @@ var Ia = {
11557
11557
  stepScaleX: l,
11558
11558
  stepScaleY: u
11559
11559
  };
11560
- }, fo = 1e-4;
11561
- function po(e) {
11560
+ }, po = 1e-4;
11561
+ function mo(e) {
11562
11562
  return !!e && e instanceof v;
11563
11563
  }
11564
- function mo(e) {
11565
- if (!po(e)) return !1;
11564
+ function ho(e) {
11565
+ if (!mo(e)) return !1;
11566
11566
  let t = e.group;
11567
11567
  return e.shapeNodeType === "text" && t?.shapeComposite === !0;
11568
11568
  }
11569
- var ho = class {
11569
+ var go = class {
11570
11570
  constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
11571
11571
  this.handleMouseMove = (e) => {
11572
11572
  let t = this.canvas._currentTransform;
11573
11573
  if (!t) return;
11574
11574
  let { target: n } = t;
11575
- if (!po(n) || mo(n)) return;
11575
+ if (!mo(n) || ho(n)) return;
11576
11576
  let r = this.scalingState.get(n);
11577
11577
  if (!r || !e.e) return;
11578
- let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = co({ transform: t });
11578
+ let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = lo({ transform: t });
11579
11579
  if (!a && !o && !i) return;
11580
- let s = uo({
11580
+ let s = fo({
11581
11581
  textbox: n,
11582
11582
  transform: t,
11583
11583
  scenePoint: this.canvas.getScenePoint(e.e)
@@ -11600,20 +11600,20 @@ var ho = class {
11600
11600
  }, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
11601
11601
  if (i) {
11602
11602
  let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
11603
- if (Math.abs(t - r.lastAllowedScaleX) <= fo) return;
11603
+ if (Math.abs(t - r.lastAllowedScaleX) <= po) return;
11604
11604
  j = t, M = t;
11605
11605
  } else {
11606
11606
  if (a) {
11607
11607
  let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
11608
- Math.abs(t - r.lastAllowedScaleX) > fo && (j = t);
11608
+ Math.abs(t - r.lastAllowedScaleX) > po && (j = t);
11609
11609
  }
11610
11610
  if (o) {
11611
11611
  let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
11612
- Math.abs(t - r.lastAllowedScaleY) > fo && (M = t);
11612
+ Math.abs(t - r.lastAllowedScaleY) > po && (M = t);
11613
11613
  }
11614
- if (Math.abs(j - r.lastAllowedScaleX) <= fo && Math.abs(M - r.lastAllowedScaleY) <= fo) return;
11614
+ if (Math.abs(j - r.lastAllowedScaleX) <= po && Math.abs(M - r.lastAllowedScaleY) <= po) return;
11615
11615
  }
11616
- let { appliedWidth: N, dimensionsRounded: P } = Na({
11616
+ let { appliedWidth: N, dimensionsRounded: P } = Pa({
11617
11617
  textbox: n,
11618
11618
  canvasManager: this.canvasManager,
11619
11619
  base: r.startBase,
@@ -11627,7 +11627,7 @@ var ho = class {
11627
11627
  shouldDisableAutoExpandOnHorizontalChange: a,
11628
11628
  shouldRoundDimensions: !i
11629
11629
  });
11630
- lo({
11630
+ uo({
11631
11631
  textbox: n,
11632
11632
  transform: t,
11633
11633
  appliedWidth: N
@@ -11648,12 +11648,12 @@ var ho = class {
11648
11648
  }), this.canvas.requestRenderAll();
11649
11649
  }, this.handleObjectScaling = (t) => {
11650
11650
  let { target: n, transform: r } = t;
11651
- if (n instanceof e || !po(n) || mo(n) || !r) return;
11651
+ if (n instanceof e || !mo(n) || ho(n) || !r) return;
11652
11652
  n.isScaling = !0;
11653
11653
  let i = this._ensureScalingState({
11654
11654
  textbox: n,
11655
11655
  transform: r
11656
- }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = co({ transform: r }), d = r.corner ?? "", f = c || u;
11656
+ }), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = lo({ transform: r }), d = r.corner ?? "", f = c || u;
11657
11657
  if (!l && !u && !c) return;
11658
11658
  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({
11659
11659
  object: n,
@@ -11668,7 +11668,7 @@ var ho = class {
11668
11668
  N = e, P = e;
11669
11669
  }
11670
11670
  } else l && (N = Math.max(i.minimumWidthScale, i.lastAllowedScaleX * h)), u && (P = Math.max(i.minimumFontScale, i.lastAllowedScaleY * g));
11671
- let { appliedWidth: ee, dimensionsRounded: te } = Na({
11671
+ let { appliedWidth: ee, dimensionsRounded: te } = Pa({
11672
11672
  textbox: n,
11673
11673
  canvasManager: this.canvasManager,
11674
11674
  base: a,
@@ -11682,7 +11682,7 @@ var ho = class {
11682
11682
  shouldDisableAutoExpandOnHorizontalChange: l,
11683
11683
  shouldRoundDimensions: !c
11684
11684
  });
11685
- lo({
11685
+ uo({
11686
11686
  textbox: n,
11687
11687
  transform: r,
11688
11688
  appliedWidth: ee
@@ -11715,7 +11715,7 @@ var ho = class {
11715
11715
  let { target: n } = t;
11716
11716
  if (n instanceof e) {
11717
11717
  let t = n.getObjects();
11718
- if (!t.some((e) => po(e))) return;
11718
+ if (!t.some((e) => mo(e))) return;
11719
11719
  let { scaleX: r = 1, scaleY: i = 1 } = n;
11720
11720
  if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
11721
11721
  this.canvas.discardActiveObject(), t.forEach((e) => {
@@ -11725,7 +11725,7 @@ var ho = class {
11725
11725
  this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
11726
11726
  return;
11727
11727
  }
11728
- if (!po(n) || mo(n)) return;
11728
+ if (!mo(n) || ho(n)) return;
11729
11729
  n.isScaling = !1;
11730
11730
  let r = this.scalingState.get(n);
11731
11731
  if (this.scalingState.delete(n), !r?.hasScalingChange) return;
@@ -11750,11 +11750,11 @@ var ho = class {
11750
11750
  }, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
11751
11751
  }
11752
11752
  commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
11753
- if (!po(e) || mo(e)) return !1;
11753
+ if (!mo(e) || ho(e)) return !1;
11754
11754
  let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
11755
11755
  if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
11756
- let i = Aa({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
11757
- return Na({
11756
+ let i = ja({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
11757
+ return Pa({
11758
11758
  textbox: e,
11759
11759
  canvasManager: this.canvasManager,
11760
11760
  base: i,
@@ -11770,7 +11770,7 @@ var ho = class {
11770
11770
  _ensureScalingState({ textbox: e, transform: t }) {
11771
11771
  let n = this.scalingState.get(e);
11772
11772
  if (!n) {
11773
- let r = Aa({ textbox: e }), i = this.canvasManager.getObjectPlacement({ object: e }), a = ja({ base: r }), o = t.original?.originX ?? t.originX ?? e.originX ?? "center", s = t.original?.originY ?? t.originY ?? e.originY ?? "center";
11773
+ let r = ja({ textbox: e }), i = this.canvasManager.getObjectPlacement({ object: e }), a = Ma({ base: r }), o = t.original?.originX ?? t.originX ?? e.originX ?? "center", s = t.original?.originY ?? t.originY ?? e.originY ?? "center";
11774
11774
  n = {
11775
11775
  startBase: r,
11776
11776
  startObjectPlacement: i,
@@ -11803,7 +11803,7 @@ var ho = class {
11803
11803
  topRight: e.radiusTopRight ?? 0,
11804
11804
  bottomRight: e.radiusBottomRight ?? 0,
11805
11805
  bottomLeft: e.radiusBottomLeft ?? 0
11806
- }, v = Math.abs(n - o) > qi, y = Math.abs(h - r) > qi, b = Math.abs(g.top - i.top) > .01 || Math.abs(g.right - i.right) > .01 || Math.abs(g.bottom - i.bottom) > .01 || Math.abs(g.left - i.left) > .01, x = Math.abs(_.topLeft - a.topLeft) > .01 || Math.abs(_.topRight - a.topRight) > .01 || Math.abs(_.bottomRight - a.bottomRight) > .01 || Math.abs(_.bottomLeft - a.bottomLeft) > .01, S = t.lastAllowedScaleX, C = t.lastAllowedScaleY;
11806
+ }, v = Math.abs(n - o) > Ji, y = Math.abs(h - r) > Ji, b = Math.abs(g.top - i.top) > .01 || Math.abs(g.right - i.right) > .01 || Math.abs(g.bottom - i.bottom) > .01 || Math.abs(g.left - i.left) > .01, x = Math.abs(_.topLeft - a.topLeft) > .01 || Math.abs(_.topRight - a.topRight) > .01 || Math.abs(_.bottomRight - a.bottomRight) > .01 || Math.abs(_.bottomLeft - a.bottomLeft) > .01, S = t.lastAllowedScaleX, C = t.lastAllowedScaleY;
11807
11807
  if (c) {
11808
11808
  let e = h / Math.max(1, m);
11809
11809
  S = e, C = e;
@@ -11824,7 +11824,7 @@ var ho = class {
11824
11824
  originY: a
11825
11825
  });
11826
11826
  }
11827
- }, go = class e {
11827
+ }, _o = class e {
11828
11828
  constructor({ editor: t }) {
11829
11829
  this._handleTextEditingEntered = (t) => {
11830
11830
  this.isTextEditingActive = !0;
@@ -11837,7 +11837,7 @@ var ho = class {
11837
11837
  if (!e._isTextbox(n)) return;
11838
11838
  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 });
11839
11839
  if (s) {
11840
- let e = ro({ value: l });
11840
+ let e = io({ value: l });
11841
11841
  e !== i && n.set({ text: e }), n.textCaseRaw = l;
11842
11842
  } else n.textCaseRaw = i;
11843
11843
  if (!r && o === void 0 && (n.autoExpand = !0), r) {
@@ -11856,7 +11856,7 @@ var ho = class {
11856
11856
  let r = e._isShapeOwnedTextbox(n);
11857
11857
  this.editingPlacementState?.delete(n), delete n.__lineDefaultsPrevText;
11858
11858
  let i = n.text ?? "";
11859
- n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (wa({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
11859
+ n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (Ta({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
11860
11860
  lockMovementX: !1,
11861
11861
  lockMovementY: !1
11862
11862
  }));
@@ -11883,7 +11883,7 @@ var ho = class {
11883
11883
  transform: r,
11884
11884
  event: i ?? null
11885
11885
  });
11886
- }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new ho({
11886
+ }, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new go({
11887
11887
  canvas: t.canvas,
11888
11888
  canvasManager: t.canvasManager,
11889
11889
  persistScaledTextbox: ({ target: e, style: t }) => {
@@ -11892,7 +11892,7 @@ var ho = class {
11892
11892
  style: t
11893
11893
  });
11894
11894
  }
11895
- }), this.updateController = new so({ runtime: {
11895
+ }), this.updateController = new co({ runtime: {
11896
11896
  canvas: this.canvas,
11897
11897
  canvasManager: t.canvasManager,
11898
11898
  historyManager: t.historyManager,
@@ -11901,12 +11901,12 @@ var ho = class {
11901
11901
  restoreTextboxContentPlacement: (e) => this._restoreTextboxContentPlacement(e),
11902
11902
  syncLineStylesWithText: (e) => this.syncLineStylesWithText(e),
11903
11903
  getSnapshot: (t) => e._getSnapshot(t)
11904
- } }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), oo();
11904
+ } }), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), so();
11905
11905
  }
11906
11906
  addText({ id: t = `background-textbox-${D()}`, 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: O = !1, withoutSave: k = !1, withoutAdding: A = !1, emitLifecycleEvents: j = !0 } = {}) {
11907
11907
  let { canvasManager: M, historyManager: N } = this.editor, { canvas: P } = this;
11908
11908
  N.suspendHistory();
11909
- let F = i ?? this._getDefaultFontFamily(), I = no({ width: m }), ee = to({
11909
+ let F = i ?? this._getDefaultFontFamily(), I = ro({ width: m }), ee = no({
11910
11910
  strokeColor: p,
11911
11911
  width: I
11912
11912
  }), te = {
@@ -11935,14 +11935,14 @@ var ho = class {
11935
11935
  radiusBottomRight: w,
11936
11936
  radiusBottomLeft: T,
11937
11937
  ...E
11938
- }, L = new ao(n, te), ne = r !== !1;
11938
+ }, L = new oo(n, te), ne = r !== !1;
11939
11939
  L.autoExpand = ne;
11940
11940
  let re = E.left !== void 0 || E.top !== void 0;
11941
11941
  if (L.textCaseRaw = L.text ?? "", l) {
11942
- let e = ro({ value: L.textCaseRaw });
11942
+ let e = io({ value: L.textCaseRaw });
11943
11943
  e !== L.text && L.set({ text: e });
11944
11944
  }
11945
- wa({ textbox: L }) && (L.dirty = !0);
11945
+ Ta({ textbox: L }) && (L.dirty = !0);
11946
11946
  let ie;
11947
11947
  re && (ie = M.resolveObjectPlacement({
11948
11948
  object: L,
@@ -12051,7 +12051,7 @@ var ho = class {
12051
12051
  let t = e.width ?? 0, n = e.height ?? 0;
12052
12052
  e.initDimensions(), o = Math.abs((e.width ?? 0) - t) > .01 || Math.abs((e.height ?? 0) - n) > .01;
12053
12053
  }
12054
- a || (s = wa({ textbox: e }));
12054
+ a || (s = Ta({ textbox: e }));
12055
12055
  let c = !1;
12056
12056
  return !a && t && (this.editor.canvasManager.applyObjectPlacement({
12057
12057
  object: e,
@@ -12059,7 +12059,7 @@ var ho = class {
12059
12059
  }), c = !0), (a || o || s) && (e.dirty = !0), (a || o || s || c) && e.setCoords(), a || o || s;
12060
12060
  }
12061
12061
  _restoreTextboxContentPlacement({ textbox: e, contentPlacement: t }) {
12062
- let n = ba({
12062
+ let n = xa({
12063
12063
  textbox: e,
12064
12064
  originX: t.originX,
12065
12065
  originY: t.originY
@@ -12077,7 +12077,7 @@ var ho = class {
12077
12077
  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);
12078
12078
  }
12079
12079
  syncLineStylesWithText({ textbox: e, previousText: t, currentText: n }) {
12080
- let r = n ?? e.text ?? "", i = ma({
12080
+ let r = n ?? e.text ?? "", i = ha({
12081
12081
  textbox: e,
12082
12082
  previousText: t ?? e.__lineDefaultsPrevText ?? r,
12083
12083
  currentText: r
@@ -12095,16 +12095,16 @@ var ho = class {
12095
12095
  if (!Number.isFinite(f) || f <= 0) return !1;
12096
12096
  let p = a.split("\n").length, m = !1;
12097
12097
  Math.abs((e.width ?? 0) - f) > .01 && (e.set({ width: f }), m = !0), e.initDimensions();
12098
- let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(va({
12098
+ let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(ya({
12099
12099
  textbox: e,
12100
12100
  text: a
12101
12101
  })), v = Math.min(e.minWidth ?? 1, f), y = Math.min(f, Math.max(_, v));
12102
- g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), wa({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
12102
+ g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), Ta({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
12103
12103
  object: e,
12104
12104
  placement: t
12105
12105
  });
12106
12106
  let b = !1;
12107
- return n && (b = xa({
12107
+ return n && (b = Sa({
12108
12108
  textbox: e,
12109
12109
  montageLeft: o,
12110
12110
  montageRight: o + s
@@ -12162,7 +12162,7 @@ var ho = class {
12162
12162
  _getDefaultFontFamily() {
12163
12163
  return this.fonts[0]?.family ?? "Arial";
12164
12164
  }
12165
- }, _o = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, vo = (e) => {
12165
+ }, vo = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, yo = (e) => {
12166
12166
  if (!e || typeof e != "object") return null;
12167
12167
  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) => ({
12168
12168
  color: typeof e.color == "string" ? e.color : "#000000",
@@ -12173,7 +12173,7 @@ var ho = class {
12173
12173
  let { x1: e, y1: t, x2: r, y2: i } = n;
12174
12174
  if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
12175
12175
  type: "linear",
12176
- angle: _o({
12176
+ angle: vo({
12177
12177
  x1: e,
12178
12178
  y1: t,
12179
12179
  x2: r,
@@ -12201,7 +12201,7 @@ var ho = class {
12201
12201
  };
12202
12202
  }
12203
12203
  return null;
12204
- }, yo = "_templateAnchorX", bo = "_templateAnchorY", xo = class t {
12204
+ }, bo = "_templateAnchorX", xo = "_templateAnchorY", So = class t {
12205
12205
  constructor({ editor: e }) {
12206
12206
  this.editor = e;
12207
12207
  }
@@ -12210,7 +12210,7 @@ var ho = class {
12210
12210
  if (!p.length) return s.emitWarning({
12211
12211
  origin: "TemplateManager",
12212
12212
  method: "serializeSelection",
12213
- code: Ka.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
12213
+ code: qa.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
12214
12214
  message: "Нет объектов для сериализации шаблона"
12215
12215
  }), null;
12216
12216
  let m = t._getBounds(o), h = t._getMontageSize({
@@ -12239,14 +12239,14 @@ var ho = class {
12239
12239
  if (!l?.length) return a.emitWarning({
12240
12240
  origin: "TemplateManager",
12241
12241
  method: "applyTemplate",
12242
- code: Ka.TEMPLATE_MANAGER.INVALID_TEMPLATE,
12242
+ code: qa.TEMPLATE_MANAGER.INVALID_TEMPLATE,
12243
12243
  message: "Шаблон не содержит объектов"
12244
12244
  }), null;
12245
12245
  let f = t._getBounds(r);
12246
12246
  if (!f) return a.emitWarning({
12247
12247
  origin: "TemplateManager",
12248
12248
  method: "applyTemplate",
12249
- code: Ka.TEMPLATE_MANAGER.INVALID_TARGET,
12249
+ code: qa.TEMPLATE_MANAGER.INVALID_TARGET,
12250
12250
  message: "Не удалось определить границы монтажной области"
12251
12251
  }), null;
12252
12252
  let p = t._getMontageSize({
@@ -12270,7 +12270,7 @@ var ho = class {
12270
12270
  if (!r.length) return a.emitWarning({
12271
12271
  origin: "TemplateManager",
12272
12272
  method: "applyTemplate",
12273
- code: Ka.TEMPLATE_MANAGER.INVALID_TEMPLATE,
12273
+ code: qa.TEMPLATE_MANAGER.INVALID_TEMPLATE,
12274
12274
  message: "Не удалось создать объекты шаблона"
12275
12275
  }), null;
12276
12276
  let { backgroundObject: i, contentObjects: u } = t._extractBackgroundObject(r);
@@ -12292,7 +12292,7 @@ var ho = class {
12292
12292
  }), c.commitStandaloneTextScale({ target: e }), s.commitRehydratedShapeLayout({
12293
12293
  target: e,
12294
12294
  textScale: h
12295
- }), an({ object: e }), Ba({ rootObject: e }), n.add(e), e));
12295
+ }), an({ object: e }), Va({ rootObject: e }), n.add(e), e));
12296
12296
  return !d.length && !v ? null : (_ = d.length > 0 || v, d.length && t._activateObjects({
12297
12297
  canvas: n,
12298
12298
  objects: d
@@ -12305,7 +12305,7 @@ var ho = class {
12305
12305
  return a.emitError({
12306
12306
  origin: "TemplateManager",
12307
12307
  method: "applyTemplate",
12308
- code: Ka.TEMPLATE_MANAGER.APPLY_FAILED,
12308
+ code: qa.TEMPLATE_MANAGER.APPLY_FAILED,
12309
12309
  message: "Ошибка применения шаблона",
12310
12310
  data: {
12311
12311
  templateId: d,
@@ -12583,8 +12583,8 @@ var ho = class {
12583
12583
  baseHeight: a,
12584
12584
  scale: n,
12585
12585
  useRelativePositions: o,
12586
- anchorX: t._resolveAnchor(s, yo),
12587
- anchorY: t._resolveAnchor(s, bo)
12586
+ anchorX: t._resolveAnchor(s, bo),
12587
+ anchorY: t._resolveAnchor(s, xo)
12588
12588
  })
12589
12589
  }), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
12590
12590
  e.set({
@@ -12659,7 +12659,7 @@ var ho = class {
12659
12659
  });
12660
12660
  if (!i || !a) return;
12661
12661
  e.setCoords();
12662
- let o = e, s = t._resolveAnchor(o, yo), 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;
12662
+ let o = e, s = t._resolveAnchor(o, bo), 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;
12663
12663
  e.set("width", i), e.initDimensions();
12664
12664
  let h = t._getLongestLineWidth({
12665
12665
  textbox: e,
@@ -12688,10 +12688,10 @@ var ho = class {
12688
12688
  x: (p.left - o) / d,
12689
12689
  y: (p.top - s) / f
12690
12690
  }, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
12691
- return a[yo] = t._detectAnchor({
12691
+ return a[bo] = t._detectAnchor({
12692
12692
  start: h,
12693
12693
  end: _
12694
- }), a[bo] = t._detectAnchor({
12694
+ }), a[xo] = t._detectAnchor({
12695
12695
  start: g,
12696
12696
  end: v
12697
12697
  }), a.left = m.x, a.top = m.y, a;
@@ -12716,7 +12716,7 @@ var ho = class {
12716
12716
  withoutSave: !0
12717
12717
  }), !0;
12718
12718
  if (a === "gradient") {
12719
- let e = vo(r);
12719
+ let e = yo(r);
12720
12720
  if (e) return n.setGradientBackground({
12721
12721
  gradient: e,
12722
12722
  customData: o,
@@ -12737,7 +12737,7 @@ var ho = class {
12737
12737
  r.emitWarning({
12738
12738
  origin: "TemplateManager",
12739
12739
  method: "applyTemplate",
12740
- code: Ka.TEMPLATE_MANAGER.APPLY_FAILED,
12740
+ code: qa.TEMPLATE_MANAGER.APPLY_FAILED,
12741
12741
  message: "Не удалось применить фон из шаблона",
12742
12742
  data: e
12743
12743
  });
@@ -12773,29 +12773,29 @@ var ho = class {
12773
12773
  enlivenObjectEnlivables(e) {
12774
12774
  return w.enlivenObjectEnlivables(e);
12775
12775
  }
12776
- }, So = "#3D8BF4", Co = .5, wo = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, To = ({ firstDistance: e, secondDistance: t }) => {
12777
- let n = wo({ distance: e }), r = wo({ distance: t });
12776
+ }, Co = "#3D8BF4", wo = .5, To = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, Eo = ({ firstDistance: e, secondDistance: t }) => {
12777
+ let n = To({ distance: e }), r = To({ distance: t });
12778
12778
  return {
12779
12779
  firstDisplayDistance: n,
12780
12780
  secondDisplayDistance: r,
12781
12781
  displayDistanceDiff: Math.abs(n - r),
12782
12782
  commonDisplayDistance: Math.max(n, r)
12783
12783
  };
12784
- }, Eo = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), Do = ({ step: e }) => {
12784
+ }, Do = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), Oo = ({ step: e }) => {
12785
12785
  let t = Math.abs(e).toString(), n = t.indexOf(".");
12786
12786
  return n === -1 ? 0 : t.slice(n + 1).length;
12787
- }, Oo = ({ value: e, step: t }) => {
12787
+ }, ko = ({ value: e, step: t }) => {
12788
12788
  if (t === 0) return e;
12789
- let n = Do({ step: t }), r = Math.round(e / t) * t;
12789
+ let n = Oo({ step: t }), r = Math.round(e / t) * t;
12790
12790
  return Number(r.toFixed(n));
12791
- }, ko = ({ value: e, step: t }) => {
12791
+ }, Ao = ({ value: e, step: t }) => {
12792
12792
  if (t === 0) return !0;
12793
- let n = Oo({
12793
+ let n = ko({
12794
12794
  value: e,
12795
12795
  step: t
12796
- }), r = 10 ** -(Do({ step: t }) + 4);
12796
+ }), r = 10 ** -(Oo({ step: t }) + 4);
12797
12797
  return Math.abs(n - e) <= r;
12798
- }, Ao = ({ bounds: e, axis: t }) => {
12798
+ }, jo = ({ bounds: e, axis: t }) => {
12799
12799
  let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
12800
12800
  return t === "vertical" ? {
12801
12801
  start: i,
@@ -12804,7 +12804,7 @@ var ho = class {
12804
12804
  start: n,
12805
12805
  end: r
12806
12806
  };
12807
- }, jo = ({ items: e, axis: t }) => {
12807
+ }, Mo = ({ items: e, axis: t }) => {
12808
12808
  for (let n = 1; n < e.length; n += 1) {
12809
12809
  let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
12810
12810
  for (; o >= 0;) {
@@ -12814,10 +12814,10 @@ var ho = class {
12814
12814
  }
12815
12815
  e[o + 1] = r;
12816
12816
  }
12817
- }, Mo = ({ items: e, index: t, axis: n, direction: r }) => {
12817
+ }, No = ({ items: e, index: t, axis: n, direction: r }) => {
12818
12818
  let i = e[t];
12819
12819
  if (!i) return null;
12820
- let { bounds: a } = i, { start: o, end: s } = Ao({
12820
+ let { bounds: a } = i, { start: o, end: s } = jo({
12821
12821
  bounds: a,
12822
12822
  axis: n
12823
12823
  });
@@ -12825,7 +12825,7 @@ var ho = class {
12825
12825
  for (let r = t - 1; r >= 0; --r) {
12826
12826
  let t = e[r];
12827
12827
  if (!t) continue;
12828
- let { bounds: i } = t, { end: a } = Ao({
12828
+ let { bounds: i } = t, { end: a } = jo({
12829
12829
  bounds: i,
12830
12830
  axis: n
12831
12831
  });
@@ -12836,26 +12836,26 @@ var ho = class {
12836
12836
  for (let r = t + 1; r < e.length; r += 1) {
12837
12837
  let t = e[r];
12838
12838
  if (!t) continue;
12839
- let { bounds: i } = t, { start: a } = Ao({
12839
+ let { bounds: i } = t, { start: a } = jo({
12840
12840
  bounds: i,
12841
12841
  axis: n
12842
12842
  });
12843
12843
  if (a - s >= 0) return r;
12844
12844
  }
12845
12845
  return null;
12846
- }, No = ({ items: e }) => {
12846
+ }, Po = ({ items: e }) => {
12847
12847
  for (let t = 0; t < e.length; t += 1) {
12848
12848
  let { isActive: n } = e[t];
12849
12849
  if (n) return t;
12850
12850
  }
12851
12851
  return -1;
12852
- }, Po = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
12852
+ }, Fo = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
12853
12853
  let i = Math.min(t, n), a = Math.max(t, n);
12854
12854
  return e >= i - r && e <= a + r;
12855
- }, Fo = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Io = ({ baseOption: e, candidateOption: t }) => {
12855
+ }, Io = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Lo = ({ baseOption: e, candidateOption: t }) => {
12856
12856
  let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
12857
12857
  return n === i && r === a;
12858
- }, Lo = ({ options: e }) => {
12858
+ }, Ro = ({ options: e }) => {
12859
12859
  let t = e[0];
12860
12860
  for (let n = 1; n < e.length; n += 1) {
12861
12861
  let r = e[n];
@@ -12866,11 +12866,11 @@ var ho = class {
12866
12866
  r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
12867
12867
  }
12868
12868
  return t;
12869
- }, Ro = ({ currentOption: e, nextOption: t }) => {
12869
+ }, zo = ({ currentOption: e, nextOption: t }) => {
12870
12870
  if (!e) return !0;
12871
12871
  let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
12872
12872
  return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
12873
- }, zo = ({ options: e }) => {
12873
+ }, Bo = ({ options: e }) => {
12874
12874
  let t = [], n = null, r = null;
12875
12875
  for (let i of e) {
12876
12876
  let { kind: e, side: a } = i;
@@ -12878,18 +12878,18 @@ var ho = class {
12878
12878
  t.push(i);
12879
12879
  continue;
12880
12880
  }
12881
- a === "before" && Ro({
12881
+ a === "before" && zo({
12882
12882
  currentOption: n,
12883
12883
  nextOption: i
12884
- }) && (n = i), a === "after" && Ro({
12884
+ }) && (n = i), a === "after" && zo({
12885
12885
  currentOption: r,
12886
12886
  nextOption: i
12887
12887
  }) && (r = i);
12888
12888
  }
12889
12889
  return n && t.push(n), r && t.push(r), t;
12890
- }, Bo = ({ options: e, side: t, baseOption: n }) => {
12890
+ }, Vo = ({ options: e, side: t, baseOption: n }) => {
12891
12891
  let r = null;
12892
- for (let i of e) if (i.side === t && Io({
12892
+ for (let i of e) if (i.side === t && Lo({
12893
12893
  baseOption: n,
12894
12894
  candidateOption: i
12895
12895
  })) {
@@ -12900,63 +12900,63 @@ var ho = class {
12900
12900
  !r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
12901
12901
  }
12902
12902
  return r;
12903
- }, Vo = ({ option: e }) => {
12903
+ }, Ho = ({ option: e }) => {
12904
12904
  let { side: t, kind: n, guide: { distance: r } } = e;
12905
12905
  return {
12906
12906
  side: t,
12907
12907
  kind: n,
12908
12908
  distance: r
12909
12909
  };
12910
- }, Ho = ({ option: e, context: t }) => {
12910
+ }, Uo = ({ option: e, context: t }) => {
12911
12911
  let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
12912
12912
  return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
12913
- }, Uo = ({ options: e, context: t }) => {
12913
+ }, Wo = ({ options: e, context: t }) => {
12914
12914
  if (!t) return null;
12915
- for (let n of e) if (Ho({
12915
+ for (let n of e) if (Uo({
12916
12916
  option: n,
12917
12917
  context: t
12918
12918
  })) return n;
12919
12919
  return null;
12920
- }, Wo = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
12921
- let i = Uo({
12920
+ }, Go = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
12921
+ let i = Wo({
12922
12922
  options: e,
12923
12923
  context: n
12924
12924
  });
12925
12925
  if (!i) return t;
12926
12926
  let a = Math.max(0, r);
12927
12927
  return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
12928
- }, Go = ({ guides: e, seenGuideKeys: t, guide: n }) => {
12928
+ }, Ko = ({ guides: e, seenGuideKeys: t, guide: n }) => {
12929
12929
  let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
12930
12930
  t.has(u) || (t.add(u), e.push(n));
12931
- }, Ko = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
12931
+ }, qo = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
12932
12932
  if (!e.length) return {
12933
12933
  delta: 0,
12934
12934
  guides: [],
12935
12935
  context: null
12936
12936
  };
12937
- let r = zo({ options: e }), i = [];
12937
+ let r = Bo({ options: e }), i = [];
12938
12938
  for (let e of r) e.kind === "reference" && i.push(e);
12939
- let a = i.length > 0, o = a ? i : r, s = Wo({
12939
+ let a = i.length > 0, o = a ? i : r, s = Go({
12940
12940
  options: o,
12941
- bestOption: Lo({ options: o }),
12941
+ bestOption: Ro({ options: o }),
12942
12942
  previousContext: t,
12943
12943
  switchDistance: n
12944
- }), c = Bo({
12944
+ }), c = Vo({
12945
12945
  options: o,
12946
12946
  side: "before",
12947
12947
  baseOption: s
12948
- }), l = Bo({
12948
+ }), l = Vo({
12949
12949
  options: o,
12950
12950
  side: "after",
12951
12951
  baseOption: s
12952
- }), u = Bo({
12952
+ }), u = Vo({
12953
12953
  options: a ? r : o,
12954
12954
  side: "center",
12955
12955
  baseOption: s
12956
12956
  }), d = [];
12957
12957
  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);
12958
12958
  let f = [], p = /* @__PURE__ */ new Set();
12959
- for (let e of d) Go({
12959
+ for (let e of d) Ko({
12960
12960
  guides: f,
12961
12961
  seenGuideKeys: p,
12962
12962
  guide: e.guide
@@ -12964,15 +12964,15 @@ var ho = class {
12964
12964
  return {
12965
12965
  delta: s.delta,
12966
12966
  guides: f,
12967
- context: Vo({ option: s })
12967
+ context: Ho({ option: s })
12968
12968
  };
12969
- }, qo = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
12970
- let s = n - (e - r), c = Oo({
12969
+ }, Jo = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
12970
+ let s = n - (e - r), c = ko({
12971
12971
  value: s,
12972
12972
  step: o
12973
12973
  }), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
12974
12974
  for (let d = -l; d <= l; d += 1) {
12975
- let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = To({
12975
+ let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = Eo({
12976
12976
  firstDistance: m,
12977
12977
  secondDistance: h
12978
12978
  });
@@ -12987,13 +12987,13 @@ var ho = class {
12987
12987
  });
12988
12988
  }
12989
12989
  return u;
12990
- }, Jo = ({ currentGap: e, referenceGap: t }) => {
12991
- let { secondDisplayDistance: n, displayDistanceDiff: r } = To({
12990
+ }, Yo = ({ currentGap: e, referenceGap: t }) => {
12991
+ let { secondDisplayDistance: n, displayDistanceDiff: r } = Eo({
12992
12992
  firstDistance: e,
12993
12993
  secondDistance: t
12994
12994
  });
12995
12995
  return r > 1 ? null : n;
12996
- }, Yo = ({ anchors: e, positions: t, threshold: n }) => {
12996
+ }, Xo = ({ anchors: e, positions: t, threshold: n }) => {
12997
12997
  let r = 0, i = n + 1, a = null;
12998
12998
  for (let o of t) for (let t of e) {
12999
12999
  let e = Math.abs(t - o);
@@ -13003,8 +13003,8 @@ var ho = class {
13003
13003
  delta: r,
13004
13004
  guidePosition: a
13005
13005
  };
13006
- }, Xo = ({ activeBounds: e, threshold: t, anchors: n }) => {
13007
- let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Yo({
13006
+ }, Zo = ({ activeBounds: e, threshold: t, anchors: n }) => {
13007
+ let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Xo({
13008
13008
  anchors: n.vertical,
13009
13009
  positions: [
13010
13010
  r,
@@ -13012,7 +13012,7 @@ var ho = class {
13012
13012
  i
13013
13013
  ],
13014
13014
  threshold: t
13015
- }), u = Yo({
13015
+ }), u = Xo({
13016
13016
  anchors: n.horizontal,
13017
13017
  positions: [
13018
13018
  o,
@@ -13032,11 +13032,11 @@ var ho = class {
13032
13032
  deltaY: u.delta,
13033
13033
  guides: d
13034
13034
  };
13035
- }, Zo = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
13035
+ }, Qo = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
13036
13036
  let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
13037
13037
  for (let e of t) {
13038
13038
  let { left: t, right: n } = e;
13039
- Eo({
13039
+ Do({
13040
13040
  firstStart: t,
13041
13041
  firstEnd: n,
13042
13042
  secondStart: l,
@@ -13056,22 +13056,22 @@ var ho = class {
13056
13056
  f.push({
13057
13057
  bounds: e,
13058
13058
  isActive: !0
13059
- }), jo({
13059
+ }), Mo({
13060
13060
  items: f,
13061
13061
  axis: "top"
13062
13062
  });
13063
- let p = No({ items: f });
13063
+ let p = Po({ items: f });
13064
13064
  if (p === -1) return {
13065
13065
  delta: 0,
13066
13066
  guides: [],
13067
13067
  context: null
13068
13068
  };
13069
- let m = [], h = c - s, g = Mo({
13069
+ let m = [], h = c - s, g = No({
13070
13070
  items: f,
13071
13071
  index: p,
13072
13072
  axis: "vertical",
13073
13073
  direction: "prev"
13074
- }), _ = Mo({
13074
+ }), _ = No({
13075
13075
  items: f,
13076
13076
  index: p,
13077
13077
  axis: "vertical",
@@ -13080,19 +13080,19 @@ var ho = class {
13080
13080
  if (v && y) {
13081
13081
  let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
13082
13082
  if (a >= 0) {
13083
- let e = Oo({
13083
+ let e = ko({
13084
13084
  value: a / 2,
13085
13085
  step: 1
13086
13086
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
13087
13087
  if (Math.max(u, d) <= n) {
13088
- let t = qo({
13088
+ let t = Jo({
13089
13089
  activeStart: s,
13090
13090
  activeEnd: c,
13091
13091
  targetGap: e,
13092
13092
  beforeEdge: r,
13093
13093
  afterEdge: i,
13094
13094
  threshold: n,
13095
- step: Co
13095
+ step: wo
13096
13096
  });
13097
13097
  if (t) {
13098
13098
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -13129,16 +13129,16 @@ var ho = class {
13129
13129
  }
13130
13130
  for (let e of r) {
13131
13131
  let { axis: t, start: r, end: i, distance: a } = e;
13132
- if (!ko({
13132
+ if (!Ao({
13133
13133
  value: a,
13134
13134
  step: .5
13135
- }) || !Po({
13135
+ }) || !Fo({
13136
13136
  patternAxis: t,
13137
13137
  activeRangeStart: l,
13138
13138
  activeRangeEnd: u,
13139
13139
  tolerance: n
13140
13140
  })) continue;
13141
- let d = Fo({
13141
+ let d = Io({
13142
13142
  patternStart: r,
13143
13143
  patternEnd: i,
13144
13144
  activeStart: s,
@@ -13146,12 +13146,12 @@ var ho = class {
13146
13146
  });
13147
13147
  if (d) {
13148
13148
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
13149
- let e = Oo({
13149
+ let e = ko({
13150
13150
  value: a - b,
13151
13151
  step: 1
13152
13152
  }), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
13153
13153
  if (u > n) continue;
13154
- let d = Jo({
13154
+ let d = Yo({
13155
13155
  currentGap: l,
13156
13156
  referenceGap: a
13157
13157
  });
@@ -13175,12 +13175,12 @@ var ho = class {
13175
13175
  });
13176
13176
  }
13177
13177
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
13178
- let e = Oo({
13178
+ let e = ko({
13179
13179
  value: x - a,
13180
13180
  step: 1
13181
13181
  }), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
13182
13182
  if (u > n) continue;
13183
- let d = Jo({
13183
+ let d = Yo({
13184
13184
  currentGap: l,
13185
13185
  referenceGap: a
13186
13186
  });
@@ -13205,16 +13205,16 @@ var ho = class {
13205
13205
  }
13206
13206
  }
13207
13207
  }
13208
- return Ko({
13208
+ return qo({
13209
13209
  options: m,
13210
13210
  previousContext: i,
13211
13211
  switchDistance: a
13212
13212
  });
13213
- }, Qo = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
13213
+ }, $o = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
13214
13214
  let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
13215
13215
  for (let e of t) {
13216
13216
  let { top: t, bottom: n } = e;
13217
- Eo({
13217
+ Do({
13218
13218
  firstStart: t,
13219
13219
  firstEnd: n,
13220
13220
  secondStart: l,
@@ -13234,22 +13234,22 @@ var ho = class {
13234
13234
  f.push({
13235
13235
  bounds: e,
13236
13236
  isActive: !0
13237
- }), jo({
13237
+ }), Mo({
13238
13238
  items: f,
13239
13239
  axis: "left"
13240
13240
  });
13241
- let p = No({ items: f });
13241
+ let p = Po({ items: f });
13242
13242
  if (p === -1) return {
13243
13243
  delta: 0,
13244
13244
  guides: [],
13245
13245
  context: null
13246
13246
  };
13247
- let m = [], h = c - s, g = Mo({
13247
+ let m = [], h = c - s, g = No({
13248
13248
  items: f,
13249
13249
  index: p,
13250
13250
  axis: "horizontal",
13251
13251
  direction: "prev"
13252
- }), _ = Mo({
13252
+ }), _ = No({
13253
13253
  items: f,
13254
13254
  index: p,
13255
13255
  axis: "horizontal",
@@ -13258,19 +13258,19 @@ var ho = class {
13258
13258
  if (v && y) {
13259
13259
  let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
13260
13260
  if (a >= 0) {
13261
- let e = Oo({
13261
+ let e = ko({
13262
13262
  value: a / 2,
13263
13263
  step: 1
13264
13264
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
13265
13265
  if (Math.max(u, d) <= n) {
13266
- let t = qo({
13266
+ let t = Jo({
13267
13267
  activeStart: s,
13268
13268
  activeEnd: c,
13269
13269
  targetGap: e,
13270
13270
  beforeEdge: r,
13271
13271
  afterEdge: i,
13272
13272
  threshold: n,
13273
- step: Co
13273
+ step: wo
13274
13274
  });
13275
13275
  if (t) {
13276
13276
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -13307,16 +13307,16 @@ var ho = class {
13307
13307
  }
13308
13308
  for (let e of r) {
13309
13309
  let { axis: t, start: r, end: i, distance: a } = e;
13310
- if (!ko({
13310
+ if (!Ao({
13311
13311
  value: a,
13312
13312
  step: .5
13313
- }) || !Po({
13313
+ }) || !Fo({
13314
13314
  patternAxis: t,
13315
13315
  activeRangeStart: l,
13316
13316
  activeRangeEnd: u,
13317
13317
  tolerance: n
13318
13318
  })) continue;
13319
- let d = Fo({
13319
+ let d = Io({
13320
13320
  patternStart: r,
13321
13321
  patternEnd: i,
13322
13322
  activeStart: s,
@@ -13324,12 +13324,12 @@ var ho = class {
13324
13324
  });
13325
13325
  if (d) {
13326
13326
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
13327
- let e = Oo({
13327
+ let e = ko({
13328
13328
  value: a - b,
13329
13329
  step: 1
13330
13330
  }), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
13331
13331
  if (u > n) continue;
13332
- let d = Jo({
13332
+ let d = Yo({
13333
13333
  currentGap: l,
13334
13334
  referenceGap: a
13335
13335
  });
@@ -13353,12 +13353,12 @@ var ho = class {
13353
13353
  });
13354
13354
  }
13355
13355
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
13356
- let e = Oo({
13356
+ let e = ko({
13357
13357
  value: x - a,
13358
13358
  step: 1
13359
13359
  }), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
13360
13360
  if (u > n) continue;
13361
- let d = Jo({
13361
+ let d = Yo({
13362
13362
  currentGap: l,
13363
13363
  referenceGap: a
13364
13364
  });
@@ -13383,20 +13383,20 @@ var ho = class {
13383
13383
  }
13384
13384
  }
13385
13385
  }
13386
- return Ko({
13386
+ return qo({
13387
13387
  options: m,
13388
13388
  previousContext: i,
13389
13389
  switchDistance: a
13390
13390
  });
13391
- }, $o = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
13392
- let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Zo({
13391
+ }, es = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
13392
+ let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Qo({
13393
13393
  activeBounds: e,
13394
13394
  candidates: t,
13395
13395
  threshold: n,
13396
13396
  patterns: r.vertical,
13397
13397
  previousContext: o,
13398
13398
  switchDistance: a
13399
- }), l = Qo({
13399
+ }), l = $o({
13400
13400
  activeBounds: e,
13401
13401
  candidates: t,
13402
13402
  threshold: n,
@@ -13415,14 +13415,14 @@ var ho = class {
13415
13415
  horizontal: l.context
13416
13416
  }
13417
13417
  };
13418
- }, es = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
13418
+ }, ts = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
13419
13419
  let o = Math.min(a, r / 2, i / 2);
13420
13420
  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();
13421
- }, ts = ({ 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 }) => {
13421
+ }, ns = ({ 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 }) => {
13422
13422
  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;
13423
13423
  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";
13424
13424
  let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
13425
- e.beginPath(), es({
13425
+ e.beginPath(), ts({
13426
13426
  context: e,
13427
13427
  x: w,
13428
13428
  y: T,
@@ -13430,11 +13430,11 @@ var ho = class {
13430
13430
  height: C,
13431
13431
  radius: v
13432
13432
  }), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
13433
- }, ns = ({ context: e, guide: t, zoom: n }) => {
13434
- let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = wo({ distance: l }).toString();
13433
+ }, rs = ({ context: e, guide: t, zoom: n }) => {
13434
+ let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = To({ distance: l }).toString();
13435
13435
  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();
13436
- let d = So;
13437
- ts({
13436
+ let d = Co;
13437
+ ns({
13438
13438
  context: e,
13439
13439
  type: r,
13440
13440
  axis: i,
@@ -13444,7 +13444,7 @@ var ho = class {
13444
13444
  zoom: n,
13445
13445
  color: d,
13446
13446
  lineWidth: 1
13447
- }), ts({
13447
+ }), ns({
13448
13448
  context: e,
13449
13449
  type: r,
13450
13450
  axis: i,
@@ -13458,31 +13458,31 @@ var ho = class {
13458
13458
  };
13459
13459
  //#endregion
13460
13460
  //#region src/editor/snapping-manager/pixel-grid.ts
13461
- function rs({ target: e }) {
13461
+ function is({ target: e }) {
13462
13462
  let t = typeof e.type == "string" ? e.type.toLowerCase() : "", n = e instanceof v || t === "textbox" || t === "background-textbox";
13463
13463
  return !(e instanceof a) && !n;
13464
13464
  }
13465
- function is({ target: e, transform: t }) {
13465
+ function as({ target: e, transform: t }) {
13466
13466
  let { left: n = 0, top: r = 0 } = e, i = Math.round(n / 1) * 1, a = Math.round(r / 1) * 1, o = typeof t?.original?.left == "number" ? t.original.left : null, s = typeof t?.original?.top == "number" ? t.original.top : null, c = o === null || o !== n, l = s === null || s !== r, u = {};
13467
13467
  c && i !== n && (u.left = i), l && a !== r && (u.top = a), !(!("left" in u) && !("top" in u)) && (e.set(u), e.setCoords());
13468
13468
  }
13469
- function as({ target: e }) {
13469
+ function os({ target: e }) {
13470
13470
  let { width: t = 0, height: n = 0, paddingTop: r = 0, paddingRight: i = 0, paddingBottom: a = 0, paddingLeft: o = 0, strokeWidth: s = 0 } = e;
13471
13471
  return {
13472
13472
  width: t + o + i + s,
13473
13473
  height: n + r + a + s
13474
13474
  };
13475
13475
  }
13476
- function os({ target: e }) {
13477
- if (e instanceof v) return as({ target: e });
13476
+ function ss({ target: e }) {
13477
+ if (e instanceof v) return os({ target: e });
13478
13478
  let { width: t = 0, height: n = 0, strokeWidth: r = 0, strokeUniform: i = !1 } = e, a = i ? 0 : r;
13479
13479
  return {
13480
13480
  width: t + a,
13481
13481
  height: n + a
13482
13482
  };
13483
13483
  }
13484
- function ss({ target: e, transform: t }) {
13485
- let { scaleX: n = 1, scaleY: r = 1 } = e, { width: i, height: a } = os({ target: e }), o = n === r, s = n, c = r;
13484
+ function cs({ target: e, transform: t }) {
13485
+ let { scaleX: n = 1, scaleY: r = 1 } = e, { width: i, height: a } = ss({ target: e }), o = n === r, s = n, c = r;
13486
13486
  if (o) {
13487
13487
  let e = i > 0 ? Math.max(1, Math.round(i * n)) / i : n, t = a > 0 ? Math.max(1, Math.round(a * r)) / a : r, o = Math.abs(e - n) <= Math.abs(t - r) ? e : t;
13488
13488
  s = o, c = o;
@@ -13494,10 +13494,10 @@ function ss({ target: e, transform: t }) {
13494
13494
  }
13495
13495
  //#endregion
13496
13496
  //#region src/editor/snapping-manager/utils.ts
13497
- var cs = ({ anchors: e, bounds: t }) => {
13497
+ var ls = ({ anchors: e, bounds: t }) => {
13498
13498
  let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
13499
13499
  e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
13500
- }, ls = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
13500
+ }, us = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
13501
13501
  let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
13502
13502
  for (let e = 0; e < s.length; e += 1) {
13503
13503
  let c = s[e], l = null, u = Infinity;
@@ -13518,35 +13518,35 @@ var cs = ({ anchors: e, bounds: t }) => {
13518
13518
  });
13519
13519
  }
13520
13520
  return i;
13521
- }, us = ({ bounds: e }) => ({
13522
- vertical: ls({
13521
+ }, ds = ({ bounds: e }) => ({
13522
+ vertical: us({
13523
13523
  bounds: e,
13524
13524
  axis: "centerX",
13525
13525
  type: "vertical",
13526
13526
  primaryStart: "top",
13527
13527
  primaryEnd: "bottom"
13528
13528
  }),
13529
- horizontal: ls({
13529
+ horizontal: us({
13530
13530
  bounds: e,
13531
13531
  axis: "centerY",
13532
13532
  type: "horizontal",
13533
13533
  primaryStart: "left",
13534
13534
  primaryEnd: "right"
13535
13535
  })
13536
- }), ds = [
13536
+ }), fs = [
13537
13537
  "montage-area",
13538
13538
  "background",
13539
13539
  "interaction-blocker"
13540
- ], fs = ({ activeObject: t }) => {
13540
+ ], ps = ({ activeObject: t }) => {
13541
13541
  let n = /* @__PURE__ */ new Set();
13542
13542
  return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
13543
- }, ps = ({ object: e, excluded: t, ignoredIds: n = ds }) => {
13543
+ }, ms = ({ object: e, excluded: t, ignoredIds: n = fs }) => {
13544
13544
  if (t.has(e)) return !0;
13545
13545
  let { visible: r = !0 } = e;
13546
13546
  if (!r) return !0;
13547
13547
  let { id: i } = e;
13548
13548
  return !!(i && n.includes(i));
13549
- }, ms = class e {
13549
+ }, hs = class e {
13550
13550
  constructor({ editor: e }) {
13551
13551
  this.anchors = {
13552
13552
  vertical: [],
@@ -13590,7 +13590,7 @@ var cs = ({ anchors: e, bounds: t }) => {
13590
13590
  target: t,
13591
13591
  event: e
13592
13592
  })) return;
13593
- is({
13593
+ as({
13594
13594
  target: t,
13595
13595
  transform: n
13596
13596
  }), !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: t });
@@ -13599,7 +13599,7 @@ var cs = ({ anchors: e, bounds: t }) => {
13599
13599
  this._clearSpacingContexts(), this._clearGuides();
13600
13600
  return;
13601
13601
  }
13602
- let i = 5 / (this.canvas.getZoom() || 1), a = Xo({
13602
+ let i = 5 / (this.canvas.getZoom() || 1), a = Zo({
13603
13603
  activeBounds: r,
13604
13604
  threshold: i,
13605
13605
  anchors: this.anchors
@@ -13622,7 +13622,7 @@ var cs = ({ anchors: e, bounds: t }) => {
13622
13622
  activeBounds: r,
13623
13623
  deltaX: s.deltaX,
13624
13624
  deltaY: s.deltaY
13625
- }), c || is({
13625
+ }), c || as({
13626
13626
  target: t,
13627
13627
  transform: n
13628
13628
  });
@@ -13639,7 +13639,7 @@ var cs = ({ anchors: e, bounds: t }) => {
13639
13639
  this._clearGuides();
13640
13640
  return;
13641
13641
  }
13642
- let i = rs({ target: n });
13642
+ let i = is({ target: n });
13643
13643
  if (this._shouldAbortObjectScaling({
13644
13644
  target: n,
13645
13645
  transform: r,
@@ -13698,7 +13698,7 @@ var cs = ({ anchors: e, bounds: t }) => {
13698
13698
  originX: p,
13699
13699
  originY: m,
13700
13700
  plan: v
13701
- }), i && ss({
13701
+ }), i && cs({
13702
13702
  target: n,
13703
13703
  transform: r
13704
13704
  }), this._applyGuides({
@@ -13713,10 +13713,10 @@ var cs = ({ anchors: e, bounds: t }) => {
13713
13713
  });
13714
13714
  }
13715
13715
  _shouldAbortObjectScaling({ target: e, transform: t, event: n, canApplyPixelScalingStep: r }) {
13716
- return n.e?.ctrlKey ? (this._clearGuides(), r && ss({
13716
+ return n.e?.ctrlKey ? (this._clearGuides(), r && cs({
13717
13717
  target: e,
13718
13718
  transform: t
13719
- }), !0) : (r && ss({
13719
+ }), !0) : (r && cs({
13720
13720
  target: e,
13721
13721
  transform: t
13722
13722
  }), this._shouldHideOverflowingCropFrameGuides({ target: e }));
@@ -13733,7 +13733,7 @@ var cs = ({ anchors: e, bounds: t }) => {
13733
13733
  }), e.setCoords(), G({ object: e }) ?? t;
13734
13734
  }
13735
13735
  _calculateSpacingResult({ activeBounds: e, candidateBounds: t, threshold: n }) {
13736
- return $o({
13736
+ return es({
13737
13737
  activeBounds: e,
13738
13738
  candidates: t,
13739
13739
  threshold: this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / (this.canvas.getZoom() || 1) : n,
@@ -13743,11 +13743,11 @@ var cs = ({ anchors: e, bounds: t }) => {
13743
13743
  });
13744
13744
  }
13745
13745
  _applyMovementVisualGuides({ activeBounds: e, candidateBounds: t, threshold: n }) {
13746
- let r = Xo({
13746
+ let r = Zo({
13747
13747
  activeBounds: e,
13748
13748
  threshold: n,
13749
13749
  anchors: this.anchors
13750
- }), i = $o({
13750
+ }), i = es({
13751
13751
  activeBounds: e,
13752
13752
  candidates: t,
13753
13753
  threshold: n,
@@ -13859,9 +13859,9 @@ var cs = ({ anchors: e, bounds: t }) => {
13859
13859
  let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
13860
13860
  if (!n) return;
13861
13861
  let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
13862
- n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = So, n.setLineDash([4, 4]);
13862
+ n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = Co, n.setLineDash([4, 4]);
13863
13863
  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();
13864
- for (let e of this.activeSpacingGuides) ns({
13864
+ for (let e of this.activeSpacingGuides) rs({
13865
13865
  context: n,
13866
13866
  guide: e,
13867
13867
  zoom: c
@@ -14141,14 +14141,14 @@ var cs = ({ anchors: e, bounds: t }) => {
14141
14141
  }, r = [];
14142
14142
  for (let e of t) {
14143
14143
  let t = G({ object: e });
14144
- t && (cs({
14144
+ t && (ls({
14145
14145
  anchors: n,
14146
14146
  bounds: t
14147
14147
  }), r.push(t));
14148
14148
  }
14149
14149
  let { montageArea: i } = this.editor, a = G({ object: i });
14150
14150
  if (a) {
14151
- cs({
14151
+ ls({
14152
14152
  anchors: n,
14153
14153
  bounds: a
14154
14154
  });
@@ -14160,12 +14160,12 @@ var cs = ({ anchors: e, bounds: t }) => {
14160
14160
  bottom: i
14161
14161
  };
14162
14162
  } else this.guideBounds = this._calculateViewportBounds();
14163
- this.anchors = n, this.spacingPatterns = us({ bounds: r }), this.cachedTargetBounds = r;
14163
+ this.anchors = n, this.spacingPatterns = ds({ bounds: r }), this.cachedTargetBounds = r;
14164
14164
  }
14165
14165
  _collectTargets({ activeObject: e }) {
14166
- let t = fs({ activeObject: e }), n = [];
14166
+ let t = ps({ activeObject: e }), n = [];
14167
14167
  return this.canvas.forEachObject((e) => {
14168
- ps({
14168
+ ms({
14169
14169
  object: e,
14170
14170
  excluded: t
14171
14171
  }) || n.push(e);
@@ -14188,7 +14188,7 @@ var cs = ({ anchors: e, bounds: t }) => {
14188
14188
  bottom: (r - s) / a
14189
14189
  };
14190
14190
  }
14191
- }, hs = "#3D8BF4", gs = class e {
14191
+ }, gs = "#3D8BF4", _s = class e {
14192
14192
  constructor({ editor: e }) {
14193
14193
  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();
14194
14194
  }
@@ -14281,8 +14281,8 @@ var cs = ({ anchors: e, bounds: t }) => {
14281
14281
  this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
14282
14282
  }
14283
14283
  static _resolveTarget({ event: e, activeObject: t }) {
14284
- let { target: n } = e, r = fs({ activeObject: t });
14285
- return n && !ps({
14284
+ let { target: n } = e, r = ps({ activeObject: t });
14285
+ return n && !ms({
14286
14286
  object: n,
14287
14287
  excluded: r
14288
14288
  }) ? n : null;
@@ -14399,18 +14399,18 @@ var cs = ({ anchors: e, bounds: t }) => {
14399
14399
  let { canvas: e } = this, t = e.getSelectionContext();
14400
14400
  if (!t) return;
14401
14401
  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;
14402
- t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = hs, t.setLineDash([]);
14402
+ t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = gs, t.setLineDash([]);
14403
14403
  for (let e of this.activeGuides) {
14404
14404
  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;
14405
- t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), ts({
14405
+ t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), ns({
14406
14406
  context: t,
14407
14407
  type: n,
14408
14408
  axis: i,
14409
14409
  start: a,
14410
14410
  end: c,
14411
- text: wo({ distance: l }).toString(),
14411
+ text: To({ distance: l }).toString(),
14412
14412
  zoom: r,
14413
- color: hs,
14413
+ color: gs,
14414
14414
  lineWidth: 1,
14415
14415
  offsetAlongAxis: d,
14416
14416
  offsetPerpendicular: 0
@@ -14428,13 +14428,13 @@ var cs = ({ anchors: e, bounds: t }) => {
14428
14428
  let { toolbar: e } = this.editor;
14429
14429
  e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
14430
14430
  }
14431
- }, _s = 16, vs = 16, ys = Wt, bs = Gt, xs = _s;
14432
- function Ss({ sourceSize: e, size: t, aspectRatio: n, allowOverflow: r }) {
14433
- return t ? ks({
14431
+ }, vs = 16, ys = 16, bs = Wt, xs = Gt, Ss = vs;
14432
+ function Cs({ sourceSize: e, size: t, aspectRatio: n, allowOverflow: r }) {
14433
+ return t ? As({
14434
14434
  size: t,
14435
14435
  sourceSize: e,
14436
14436
  allowOverflow: r
14437
- }) : n ? Os({
14437
+ }) : n ? ks({
14438
14438
  aspectRatio: n,
14439
14439
  sourceSize: e
14440
14440
  }) : {
@@ -14442,7 +14442,7 @@ function Ss({ sourceSize: e, size: t, aspectRatio: n, allowOverflow: r }) {
14442
14442
  height: e.height
14443
14443
  };
14444
14444
  }
14445
- function Cs({ source: e }) {
14445
+ function Z({ source: e }) {
14446
14446
  return {
14447
14447
  width: e.width,
14448
14448
  height: e.height
@@ -14450,18 +14450,27 @@ function Cs({ source: e }) {
14450
14450
  }
14451
14451
  function ws({ source: e, frame: t }) {
14452
14452
  let n = e.calcTransformMatrix(), r = w.invertTransform(n), i = t.calcTransformMatrix();
14453
- return Es({ points: Ds({ frame: t }).map((e) => e.transform(i).transform(r)) });
14453
+ return Ds({ points: Os({ frame: t }).map((e) => e.transform(i).transform(r)) });
14454
14454
  }
14455
14455
  function Ts({ source: e, frame: t }) {
14456
- As({
14456
+ js({
14457
+ source: e,
14458
+ frame: t
14459
+ }), Ns({
14460
+ source: e,
14461
+ frame: t
14462
+ });
14463
+ }
14464
+ function Es({ source: e, frame: t }) {
14465
+ Ms({
14457
14466
  source: e,
14458
14467
  frame: t
14459
- }), js({
14468
+ }), Ns({
14460
14469
  source: e,
14461
14470
  frame: t
14462
14471
  });
14463
14472
  }
14464
- function Es({ points: e }) {
14473
+ function Ds({ points: e }) {
14465
14474
  let t = Math.min(...e.map((e) => e.x)), n = Math.min(...e.map((e) => e.y)), r = Math.max(...e.map((e) => e.x)), i = Math.max(...e.map((e) => e.y));
14466
14475
  return {
14467
14476
  left: t,
@@ -14470,7 +14479,7 @@ function Es({ points: e }) {
14470
14479
  height: i - n
14471
14480
  };
14472
14481
  }
14473
- function Ds({ frame: e }) {
14482
+ function Os({ frame: e }) {
14474
14483
  let t = e.width / 2, n = e.height / 2;
14475
14484
  return [
14476
14485
  new m(-t, -n),
@@ -14479,7 +14488,7 @@ function Ds({ frame: e }) {
14479
14488
  new m(-t, n)
14480
14489
  ];
14481
14490
  }
14482
- function Os({ sourceSize: e, aspectRatio: t }) {
14491
+ function ks({ sourceSize: e, aspectRatio: t }) {
14483
14492
  let n = e.width / e.height, r = t.width / t.height;
14484
14493
  return r >= n ? {
14485
14494
  width: e.width,
@@ -14489,39 +14498,49 @@ function Os({ sourceSize: e, aspectRatio: t }) {
14489
14498
  height: e.height
14490
14499
  };
14491
14500
  }
14492
- function ks({ size: e, sourceSize: t, allowOverflow: n }) {
14493
- let r = n ? ys : Math.min(t.width, ys), i = n ? bs : Math.min(t.height, bs);
14501
+ function As({ size: e, sourceSize: t, allowOverflow: n }) {
14502
+ let r = n ? bs : Math.min(t.width, bs), i = n ? xs : Math.min(t.height, xs);
14494
14503
  return {
14495
- width: Fs({
14504
+ width: Ls({
14496
14505
  value: e.width,
14497
- min: _s,
14506
+ min: vs,
14498
14507
  max: r
14499
14508
  }),
14500
- height: Fs({
14509
+ height: Ls({
14501
14510
  value: e.height,
14502
- min: vs,
14511
+ min: ys,
14503
14512
  max: i
14504
14513
  })
14505
14514
  };
14506
14515
  }
14507
- function As({ source: e, frame: t }) {
14516
+ function js({ source: e, frame: t }) {
14508
14517
  let n = ws({
14509
14518
  source: e,
14510
14519
  frame: t
14511
- }), r = Cs({ source: e }), i = r.width / Math.max(n.width, _s), a = r.height / Math.max(n.height, vs);
14520
+ }), r = Z({ source: e }), i = r.width / Math.max(n.width, vs), a = r.height / Math.max(n.height, ys);
14512
14521
  i < 1 && t.set({ scaleX: (t.scaleX ?? 1) * i }), a < 1 && t.set({ scaleY: (t.scaleY ?? 1) * a }), t.setCoords();
14513
14522
  }
14514
- function js({ source: e, frame: t }) {
14523
+ function Ms({ source: e, frame: t }) {
14524
+ let n = ws({
14525
+ source: e,
14526
+ frame: t
14527
+ }), r = Z({ source: e }), i = r.width / Math.max(n.width, vs), a = r.height / Math.max(n.height, ys), o = Math.min(i, a);
14528
+ o < 1 && t.set({
14529
+ scaleX: (t.scaleX ?? 1) * o,
14530
+ scaleY: (t.scaleY ?? 1) * o
14531
+ }), t.setCoords();
14532
+ }
14533
+ function Ns({ source: e, frame: t }) {
14515
14534
  let n = ws({
14516
14535
  source: e,
14517
14536
  frame: t
14518
- }), r = Ms({ sourceSize: Cs({ source: e }) }), i = Ns({ rect: n }), a = Ps({
14537
+ }), r = Ps({ sourceSize: Z({ source: e }) }), i = Fs({ rect: n }), a = Is({
14519
14538
  rect: n,
14520
14539
  sourceBounds: r
14521
14540
  }), o = new m(i.x + a.x, i.y + a.y).transform(e.calcTransformMatrix());
14522
14541
  t.setPositionByOrigin(o, "center", "center"), t.setCoords();
14523
14542
  }
14524
- function Ms({ sourceSize: e }) {
14543
+ function Ps({ sourceSize: e }) {
14525
14544
  return {
14526
14545
  left: -e.width / 2,
14527
14546
  top: -e.height / 2,
@@ -14529,19 +14548,19 @@ function Ms({ sourceSize: e }) {
14529
14548
  height: e.height
14530
14549
  };
14531
14550
  }
14532
- function Ns({ rect: e }) {
14551
+ function Fs({ rect: e }) {
14533
14552
  return new m(e.left + e.width / 2, e.top + e.height / 2);
14534
14553
  }
14535
- function Ps({ rect: e, sourceBounds: t }) {
14554
+ function Is({ rect: e, sourceBounds: t }) {
14536
14555
  let n = t.left + t.width, r = t.top + t.height, i = 0, a = 0;
14537
14556
  return e.left < t.left && (i = t.left - e.left), e.left + e.width > n && (i = n - e.left - e.width), e.top < t.top && (a = t.top - e.top), e.top + e.height > r && (a = r - e.top - e.height), new m(i, a);
14538
14557
  }
14539
- function Fs({ value: e, min: t, max: n }) {
14558
+ function Ls({ value: e, min: t, max: n }) {
14540
14559
  return Math.max(t, Math.min(n, e));
14541
14560
  }
14542
14561
  //#endregion
14543
14562
  //#region src/editor/crop-manager/domain/crop-frame-size.ts
14544
- function Is({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 }) {
14563
+ function Rs({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 }) {
14545
14564
  let r = Math.abs(e.cropSourceScaleX ?? 1) || 1, i = Math.abs(e.cropSourceScaleY ?? 1) || 1;
14546
14565
  return {
14547
14566
  width: Math.max(1, e.width * Math.abs(t) / r),
@@ -14549,132 +14568,153 @@ function Is({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 })
14549
14568
  };
14550
14569
  }
14551
14570
  //#endregion
14571
+ //#region src/editor/crop-manager/domain/crop-proportional-source-scale.ts
14572
+ var zs = 1;
14573
+ function Bs({ sourceSize: e, startRect: t, anchorX: n, anchorY: r }) {
14574
+ let i = Vs({
14575
+ sourceSize: e,
14576
+ rect: t,
14577
+ axis: "x",
14578
+ anchor: n
14579
+ }), a = Vs({
14580
+ sourceSize: e,
14581
+ rect: t,
14582
+ axis: "y",
14583
+ anchor: r
14584
+ }), o = Math.max(1, t.width), s = Math.max(1, t.height), c = Math.min(i / o, a / s), l = Math.min(e.width / o, e.height / s), u = Math.min(c, l);
14585
+ return (u - 1) * Math.min(o, s) <= zs ? 1 : Math.max(1, u);
14586
+ }
14587
+ function Vs({ sourceSize: e, rect: t, axis: n, anchor: r }) {
14588
+ let i = n === "x" ? e.width : e.height, a = n === "x" ? t.left : t.top, o = n === "x" ? t.width : t.height, s = -i / 2, c = i / 2, l = a + o, u = a + o / 2;
14589
+ return r === "min" ? c - a : r === "max" ? l - s : Math.min(u - s, c - u) * 2;
14590
+ }
14591
+ //#endregion
14552
14592
  //#region src/editor/crop-manager/interaction/crop-controls.ts
14553
- var Ls = .001, Rs = [
14593
+ var Hs = .001, Us = [
14554
14594
  "tl",
14555
14595
  "tr",
14556
14596
  "bl",
14557
14597
  "br"
14558
- ], zs = [
14598
+ ], Ws = [
14559
14599
  "ml",
14560
14600
  "mr",
14561
14601
  "mt",
14562
14602
  "mb"
14563
- ], Bs = {
14603
+ ], Gs = {
14564
14604
  ml: "w-resize",
14565
14605
  mr: "e-resize",
14566
14606
  mt: "n-resize",
14567
14607
  mb: "s-resize"
14568
14608
  };
14569
- function Vs({ transform: e }) {
14609
+ function Ks({ transform: e }) {
14570
14610
  let { originX: t, originY: n } = e;
14571
14611
  return (t === "center" || t === .5) && (n === "center" || n === .5);
14572
14612
  }
14573
- function Hs({ transform: e, x: t, y: n }) {
14613
+ function qs({ transform: e, x: t, y: n }) {
14574
14614
  let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i;
14575
- if (Ks({
14615
+ if (Zs({
14576
14616
  transform: r,
14577
14617
  x: t,
14578
14618
  y: n
14579
- })) return qs({ transform: r }), !0;
14619
+ })) return Qs({ transform: r }), !0;
14580
14620
  let s = x.getLocalPoint(r, r.originX, r.originY, t, n);
14581
- return Ys({ transform: r }), $s({
14621
+ return ec({ transform: r }), ic({
14582
14622
  transform: r,
14583
14623
  localPoint: s
14584
14624
  }), a !== i.scaleX || o !== i.scaleY;
14585
14625
  }
14586
- function Us({ transform: e, x: t, y: n }) {
14626
+ function Js({ transform: e, x: t, y: n }) {
14587
14627
  let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i;
14588
- if (Ks({
14628
+ if (Zs({
14589
14629
  transform: r,
14590
14630
  x: t,
14591
14631
  y: n
14592
- })) return qs({ transform: r }), !0;
14632
+ })) return Qs({ transform: r }), !0;
14593
14633
  let s = x.getLocalPoint(r, r.originX, r.originY, t, n);
14594
- return Ys({ transform: r }), rc({
14634
+ return ec({ transform: r }), cc({
14595
14635
  transform: r,
14596
14636
  localPoint: s
14597
14637
  }), a !== i.scaleX || o !== i.scaleY;
14598
14638
  }
14599
- function Ws({ transform: e, axis: t, x: n, y: r }) {
14639
+ function Ys({ transform: e, axis: t, x: n, y: r }) {
14600
14640
  let i = e, { target: a } = i, o = t === "x" ? a.scaleX ?? 1 : a.scaleY ?? 1;
14601
- if (Ks({
14641
+ if (Zs({
14602
14642
  transform: i,
14603
14643
  x: n,
14604
14644
  y: r
14605
- })) return Js({
14645
+ })) return $s({
14606
14646
  transform: i,
14607
14647
  axis: t
14608
14648
  }), !0;
14609
14649
  let s = x.getLocalPoint(i, i.originX, i.originY, n, r);
14610
- return Ys({ transform: i }), ec({
14650
+ return ec({ transform: i }), ac({
14611
14651
  transform: i,
14612
14652
  axis: t,
14613
14653
  localPoint: s
14614
14654
  }), t === "x" ? o !== a.scaleX : o !== a.scaleY;
14615
14655
  }
14616
- function Gs({ transform: e, axis: t, x: n, y: r }) {
14656
+ function Xs({ transform: e, axis: t, x: n, y: r }) {
14617
14657
  let i = e, { target: a } = i, { scaleX: o = 1, scaleY: s = 1 } = a;
14618
- if (Ks({
14658
+ if (Zs({
14619
14659
  transform: i,
14620
14660
  x: n,
14621
14661
  y: r
14622
- })) return qs({ transform: i }), !0;
14662
+ })) return Qs({ transform: i }), !0;
14623
14663
  let c = x.getLocalPoint(i, i.originX, i.originY, n, r);
14624
- return Ys({ transform: i }), tc({
14664
+ return ec({ transform: i }), oc({
14625
14665
  transform: i,
14626
14666
  axis: t,
14627
14667
  localPoint: c
14628
14668
  }), o !== a.scaleX || s !== a.scaleY;
14629
14669
  }
14630
- function Ks({ transform: e, x: t, y: n }) {
14631
- return Math.abs(t - e.ex) <= Ls && Math.abs(n - e.ey) <= Ls;
14670
+ function Zs({ transform: e, x: t, y: n }) {
14671
+ return Math.abs(t - e.ex) <= Hs && Math.abs(n - e.ey) <= Hs;
14632
14672
  }
14633
- function qs({ transform: e }) {
14673
+ function Qs({ transform: e }) {
14634
14674
  e.target.set({
14635
14675
  scaleX: e.original.scaleX,
14636
14676
  scaleY: e.original.scaleY
14637
14677
  });
14638
14678
  }
14639
- function Js({ transform: e, axis: t }) {
14679
+ function $s({ transform: e, axis: t }) {
14640
14680
  if (t === "x") {
14641
14681
  e.target.set("scaleX", e.original.scaleX);
14642
14682
  return;
14643
14683
  }
14644
14684
  e.target.set("scaleY", e.original.scaleY);
14645
14685
  }
14646
- function Ys({ transform: e }) {
14647
- let { signX: t, signY: n } = Xs({ controlKey: e.corner });
14686
+ function ec({ transform: e }) {
14687
+ let { signX: t, signY: n } = tc({ controlKey: e.corner });
14648
14688
  e.signX === void 0 && (e.signX = t), e.signY === void 0 && (e.signY = n);
14649
14689
  }
14650
- function Xs({ controlKey: e }) {
14690
+ function tc({ controlKey: e }) {
14651
14691
  return {
14652
- signX: Zs({ controlKey: e }),
14653
- signY: Qs({ controlKey: e })
14692
+ signX: nc({ controlKey: e }),
14693
+ signY: rc({ controlKey: e })
14654
14694
  };
14655
14695
  }
14656
- function Zs({ controlKey: e }) {
14696
+ function nc({ controlKey: e }) {
14657
14697
  return e === "tl" || e === "bl" || e === "ml" ? -1 : 1;
14658
14698
  }
14659
- function Qs({ controlKey: e }) {
14699
+ function rc({ controlKey: e }) {
14660
14700
  return e === "tl" || e === "tr" || e === "mt" ? -1 : 1;
14661
14701
  }
14662
- function $s({ transform: e, localPoint: t }) {
14663
- let { target: n } = e, r = nc({
14702
+ function ic({ transform: e, localPoint: t }) {
14703
+ let { target: n } = e, r = sc({
14664
14704
  transform: e,
14665
14705
  axis: "x",
14666
14706
  localPoint: t
14667
- }), i = nc({
14707
+ }), i = sc({
14668
14708
  transform: e,
14669
14709
  axis: "y",
14670
14710
  localPoint: t
14671
14711
  });
14672
14712
  n.lockScalingX || n.set("scaleX", r), n.lockScalingY || n.set("scaleY", i);
14673
14713
  }
14674
- function ec({ transform: e, axis: t, localPoint: n }) {
14714
+ function ac({ transform: e, axis: t, localPoint: n }) {
14675
14715
  let { target: r } = e;
14676
14716
  if (t === "x" && r.lockScalingX || t === "y" && r.lockScalingY) return;
14677
- let i = nc({
14717
+ let i = sc({
14678
14718
  transform: e,
14679
14719
  axis: t,
14680
14720
  localPoint: n
@@ -14685,18 +14725,18 @@ function ec({ transform: e, axis: t, localPoint: n }) {
14685
14725
  }
14686
14726
  r.set("scaleY", i);
14687
14727
  }
14688
- function tc({ transform: e, axis: t, localPoint: n }) {
14728
+ function oc({ transform: e, axis: t, localPoint: n }) {
14689
14729
  let { target: r } = e;
14690
14730
  if (r.lockScalingX || r.lockScalingY) return;
14691
- let i = nc({
14731
+ let i = sc({
14692
14732
  transform: e,
14693
14733
  axis: t,
14694
14734
  localPoint: n
14695
- }), a = t === "x" ? e.original.scaleX : e.original.scaleY, o = sc({
14735
+ }), a = t === "x" ? e.original.scaleX : e.original.scaleY, o = fc({
14696
14736
  target: r,
14697
14737
  transform: e,
14698
14738
  scale: a > 0 ? i / a : 1,
14699
- forceMinimum: lc({
14739
+ forceMinimum: vc({
14700
14740
  transform: e,
14701
14741
  axis: t,
14702
14742
  localPoint: n
@@ -14704,139 +14744,173 @@ function tc({ transform: e, axis: t, localPoint: n }) {
14704
14744
  });
14705
14745
  r.set("scaleX", o.scaleX), r.set("scaleY", o.scaleY);
14706
14746
  }
14707
- function nc({ transform: e, axis: t, localPoint: n }) {
14708
- let { target: r } = e, i = oc({ target: r }), a = cc({ target: r }), o = t === "x" ? r.scaleX ?? 1 : r.scaleY ?? 1, s = t === "x" ? n.x : n.y, c = t === "x" ? i.x : i.y, l = t === "x" ? a.minScaleX : a.minScaleY, u = t === "x" ? a.maxScaleX : a.maxScaleY;
14709
- if (lc({
14747
+ function sc({ transform: e, axis: t, localPoint: n }) {
14748
+ let { target: r } = e, i = dc({ target: r }), a = _c({ target: r }), o = t === "x" ? r.scaleX ?? 1 : r.scaleY ?? 1, s = t === "x" ? n.x : n.y, c = t === "x" ? i.x : i.y, l = t === "x" ? a.minScaleX : a.minScaleY, u = t === "x" ? a.maxScaleX : a.maxScaleY;
14749
+ if (vc({
14710
14750
  transform: e,
14711
14751
  axis: t,
14712
14752
  localPoint: n
14713
14753
  })) return l;
14714
14754
  let d = Math.abs((s || 0) * o / c);
14715
- return Vs({ transform: e }) && (d *= 2), mc({
14755
+ return Ks({ transform: e }) && (d *= 2), Cc({
14716
14756
  value: d,
14717
14757
  min: l,
14718
14758
  max: u
14719
14759
  });
14720
14760
  }
14721
- function rc({ transform: e, localPoint: t }) {
14761
+ function cc({ transform: e, localPoint: t }) {
14722
14762
  let { target: n } = e;
14723
14763
  if (n.lockScalingX || n.lockScalingY) return;
14724
- let r = sc({
14764
+ let r = fc({
14725
14765
  target: n,
14726
14766
  transform: e,
14727
- scale: ic({
14767
+ scale: lc({
14728
14768
  transform: e,
14729
14769
  localPoint: t,
14730
- dimensions: oc({ target: n })
14770
+ dimensions: dc({ target: n })
14731
14771
  }),
14732
- forceMinimum: uc({
14772
+ forceMinimum: yc({
14733
14773
  transform: e,
14734
14774
  localPoint: t
14735
14775
  })
14736
14776
  });
14737
14777
  n.set("scaleX", r.scaleX), n.set("scaleY", r.scaleY);
14738
14778
  }
14739
- function ic({ transform: e, localPoint: t, dimensions: n }) {
14779
+ function lc({ transform: e, localPoint: t, dimensions: n }) {
14740
14780
  let r = "gestureScale" in e && typeof e.gestureScale == "number" ? e.gestureScale : null;
14741
14781
  if (r !== null) return r;
14742
- let i = Math.abs(t.x) + Math.abs(t.y), a = ac({
14782
+ let i = Math.abs(t.x) + Math.abs(t.y), a = uc({
14743
14783
  transform: e,
14744
14784
  dimensions: n
14745
14785
  }), o = a > 0 ? i / a : 1;
14746
- return Vs({ transform: e }) && (o *= 2), o;
14786
+ return Ks({ transform: e }) && (o *= 2), o;
14747
14787
  }
14748
- function ac({ transform: e, dimensions: t }) {
14788
+ function uc({ transform: e, dimensions: t }) {
14749
14789
  let { target: n, original: r } = e, i = n.scaleX ?? 1, a = n.scaleY ?? 1;
14750
14790
  return Math.abs(t.x * r.scaleX / i) + Math.abs(t.y * r.scaleY / a);
14751
14791
  }
14752
- function oc({ target: e }) {
14792
+ function dc({ target: e }) {
14753
14793
  let t = Math.abs(e.scaleX ?? 1), n = Math.abs(e.scaleY ?? 1);
14754
14794
  return {
14755
14795
  x: Math.max(1, e.width * t),
14756
14796
  y: Math.max(1, e.height * n)
14757
14797
  };
14758
14798
  }
14759
- function sc({ target: e, transform: t, scale: n, forceMinimum: r }) {
14760
- let i = Is({
14799
+ function fc({ target: e, transform: t, scale: n, forceMinimum: r }) {
14800
+ let i = Rs({
14761
14801
  frame: e,
14762
14802
  scaleX: t.original.scaleX,
14763
14803
  scaleY: t.original.scaleY
14764
- }), a = Math.max(_s / i.width, vs / i.height), o = Math.min(ys / i.width, bs / i.height), s = r ? a : mc({
14804
+ }), a = Math.max(vs / i.width, ys / i.height), o = Math.min(bs / i.width, xs / i.height), s = pc({
14805
+ target: e,
14806
+ transform: t
14807
+ }), c = Math.max(a, Math.min(o, s ?? o));
14808
+ t.cropSourceScaleClamped = !r && n > c;
14809
+ let l = a;
14810
+ return r || (l = Cc({
14765
14811
  value: n,
14766
14812
  min: a,
14767
- max: o
14768
- });
14769
- return {
14770
- scaleX: t.original.scaleX * s,
14771
- scaleY: t.original.scaleY * s
14813
+ max: c
14814
+ })), {
14815
+ scaleX: t.original.scaleX * l,
14816
+ scaleY: t.original.scaleY * l
14772
14817
  };
14773
14818
  }
14774
- function cc({ target: e }) {
14819
+ function pc({ target: e, transform: t }) {
14820
+ let n = mc({
14821
+ target: e,
14822
+ transform: t
14823
+ });
14824
+ return n ? Bs({
14825
+ sourceSize: n.sourceSize,
14826
+ startRect: n.startRect,
14827
+ anchorX: hc({ transform: t }),
14828
+ anchorY: gc({ transform: t })
14829
+ }) : null;
14830
+ }
14831
+ function mc({ target: e, transform: t }) {
14832
+ if (t.cropProportionalSourceBounds !== void 0) return t.cropProportionalSourceBounds;
14833
+ let n = e;
14834
+ return n.cropAllowFrameOverflow !== !1 || !n.cropSource ? (t.cropProportionalSourceBounds = null, null) : (t.cropProportionalSourceBounds = {
14835
+ sourceSize: Z({ source: n.cropSource }),
14836
+ startRect: ws({
14837
+ source: n.cropSource,
14838
+ frame: n
14839
+ })
14840
+ }, t.cropProportionalSourceBounds);
14841
+ }
14842
+ function hc({ transform: e }) {
14843
+ return e.corner === "tl" || e.corner === "bl" || e.corner === "ml" ? "max" : e.corner === "tr" || e.corner === "br" || e.corner === "mr" || e.originX === "left" || e.originX === 0 ? "min" : e.originX === "right" || e.originX === 1 ? "max" : "center";
14844
+ }
14845
+ function gc({ transform: e }) {
14846
+ return e.corner === "tl" || e.corner === "tr" || e.corner === "mt" ? "max" : e.corner === "bl" || e.corner === "br" || e.corner === "mb" || e.originY === "top" || e.originY === 0 ? "min" : e.originY === "bottom" || e.originY === 1 ? "max" : "center";
14847
+ }
14848
+ function _c({ target: e }) {
14775
14849
  let t = e, n = Math.abs(t.cropSourceScaleX ?? 1) || 1, r = Math.abs(t.cropSourceScaleY ?? 1) || 1, i = Math.max(1, e.width), a = Math.max(1, e.height);
14776
14850
  return {
14777
- minScaleX: _s * n / i,
14778
- maxScaleX: ys * n / i,
14779
- minScaleY: vs * r / a,
14780
- maxScaleY: bs * r / a
14851
+ minScaleX: vs * n / i,
14852
+ maxScaleX: bs * n / i,
14853
+ minScaleY: ys * r / a,
14854
+ maxScaleY: xs * r / a
14781
14855
  };
14782
14856
  }
14783
- function lc({ transform: e, axis: t, localPoint: n }) {
14857
+ function vc({ transform: e, axis: t, localPoint: n }) {
14784
14858
  let { target: r } = e;
14785
14859
  if (!r.lockScalingFlip) return !1;
14786
14860
  let i = t === "x" ? e.signX ?? 1 : e.signY ?? 1, a = t === "x" ? n.x : n.y;
14787
14861
  return i !== Math.sign(a || i);
14788
14862
  }
14789
- function uc({ transform: e, localPoint: t }) {
14790
- return lc({
14863
+ function yc({ transform: e, localPoint: t }) {
14864
+ return vc({
14791
14865
  transform: e,
14792
14866
  axis: "x",
14793
14867
  localPoint: t
14794
- }) || lc({
14868
+ }) || vc({
14795
14869
  transform: e,
14796
14870
  axis: "y",
14797
14871
  localPoint: t
14798
14872
  });
14799
14873
  }
14800
- function dc({ eventData: e, target: t }) {
14874
+ function bc({ eventData: e, target: t }) {
14801
14875
  let n = t.preserveAspectRatio ?? !0;
14802
14876
  return e.shiftKey ? !n : n;
14803
14877
  }
14804
- function fc() {
14805
- let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => Hs({
14878
+ function xc() {
14879
+ let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => qs({
14806
14880
  transform: t,
14807
14881
  x: n,
14808
14882
  y: r
14809
- }))), t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => Us({
14883
+ }))), t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => Js({
14810
14884
  transform: t,
14811
14885
  x: n,
14812
14886
  y: r
14813
14887
  })));
14814
- return (n, r, i, a) => dc({
14888
+ return (n, r, i, a) => bc({
14815
14889
  eventData: n,
14816
14890
  target: r.target
14817
14891
  }) ? t(n, r, i, a) : e(n, r, i, a);
14818
14892
  }
14819
- function pc({ axis: e }) {
14820
- let t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => Ws({
14893
+ function Sc({ axis: e }) {
14894
+ let t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => Ys({
14821
14895
  transform: n,
14822
14896
  axis: e,
14823
14897
  x: r,
14824
14898
  y: i
14825
- }))), n = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => Gs({
14899
+ }))), n = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => Xs({
14826
14900
  transform: n,
14827
14901
  axis: e,
14828
14902
  x: r,
14829
14903
  y: i
14830
14904
  })));
14831
- return (e, r, i, a) => dc({
14905
+ return (e, r, i, a) => bc({
14832
14906
  eventData: e,
14833
14907
  target: r.target
14834
14908
  }) ? n(e, r, i, a) : t(e, r, i, a);
14835
14909
  }
14836
- function mc({ value: e, min: t, max: n }) {
14910
+ function Cc({ value: e, min: t, max: n }) {
14837
14911
  return Math.max(t, Math.min(n, e));
14838
14912
  }
14839
- function hc({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName: i }) {
14913
+ function wc({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName: i }) {
14840
14914
  let a = {
14841
14915
  ...e,
14842
14916
  actionHandler: t
@@ -14845,64 +14919,64 @@ function hc({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName
14845
14919
  let o = new r(a);
14846
14920
  return o.cropResizeControl = !0, o;
14847
14921
  }
14848
- function gc({ controlKey: e }) {
14849
- return Bs[e];
14922
+ function Tc({ controlKey: e }) {
14923
+ return Gs[e];
14850
14924
  }
14851
- function _c({ axis: e }) {
14925
+ function Ec({ axis: e }) {
14852
14926
  return e === "x" ? "scaleX" : "scaleY";
14853
14927
  }
14854
- function vc({ target: e }) {
14855
- let t = { ...e.controls }, n = !1, r = fc(), i = pc({ axis: "x" }), a = pc({ axis: "y" });
14856
- Rs.forEach((i) => {
14928
+ function Dc({ target: e }) {
14929
+ let t = { ...e.controls }, n = !1, r = xc(), i = Sc({ axis: "x" }), a = Sc({ axis: "y" });
14930
+ Us.forEach((i) => {
14857
14931
  let a = e.controls[i];
14858
- a && (a.cropResizeControl || (t[i] = hc({
14932
+ a && (a.cropResizeControl || (t[i] = wc({
14859
14933
  control: a,
14860
14934
  actionHandler: r
14861
14935
  }), n = !0));
14862
- }), zs.forEach((r) => {
14936
+ }), Ws.forEach((r) => {
14863
14937
  let o = e.controls[r];
14864
14938
  if (!o || o.cropResizeControl) return;
14865
14939
  let s = r === "ml" || r === "mr", c = s ? i : a, l = s ? "x" : "y";
14866
- t[r] = hc({
14940
+ t[r] = wc({
14867
14941
  control: o,
14868
14942
  actionHandler: c,
14869
- cursorStyleHandler: () => gc({ controlKey: r }),
14870
- getActionName: () => _c({ axis: l })
14943
+ cursorStyleHandler: () => Tc({ controlKey: r }),
14944
+ getActionName: () => Ec({ axis: l })
14871
14945
  }), n = !0;
14872
14946
  }), n && (e.controls = t);
14873
14947
  }
14874
14948
  //#endregion
14875
14949
  //#region src/editor/crop-manager/domain/crop-frame.ts
14876
- var yc = "rgba(47, 128, 237, 0.42)", bc = class extends _ {
14950
+ var Oc = "rgba(47, 128, 237, 0.42)", kc = class extends _ {
14877
14951
  constructor(e) {
14878
- let { showGrid: t, sourceScaleX: n = 1, sourceScaleY: r = 1, preserveAspectRatio: i = !0, ...a } = e;
14879
- super(a), this._showGrid = t, this.cropSourceScaleX = n, this.cropSourceScaleY = r, this.preserveAspectRatio = i;
14952
+ let { showGrid: t, source: n = null, allowFrameOverflow: r = !0, sourceScaleX: i = 1, sourceScaleY: a = 1, preserveAspectRatio: o = !0, ...s } = e;
14953
+ super(s), this._showGrid = t, this.cropSource = n, this.cropAllowFrameOverflow = r, this.cropSourceScaleX = i, this.cropSourceScaleY = a, this.preserveAspectRatio = o;
14880
14954
  }
14881
14955
  _render(e) {
14882
- super._render(e), this._showGrid && Sc({
14956
+ super._render(e), this._showGrid && jc({
14883
14957
  ctx: e,
14884
14958
  width: this.width,
14885
14959
  height: this.height
14886
14960
  });
14887
14961
  }
14888
14962
  getObjectDisplaySize() {
14889
- return Is({ frame: this });
14963
+ return Rs({ frame: this });
14890
14964
  }
14891
14965
  getObjectSnappingBounds() {
14892
- return wc({ frame: this });
14966
+ return Nc({ frame: this });
14893
14967
  }
14894
14968
  };
14895
- function xc({ source: e, cropSize: t, showGrid: n, preserveAspectRatio: r }) {
14896
- let i = e.getCenterPoint(), a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = new bc({
14969
+ function Ac({ source: e, cropSize: t, showGrid: n, allowFrameOverflow: r, preserveAspectRatio: i }) {
14970
+ let a = e.getCenterPoint(), o = e.scaleX ?? 1, s = e.scaleY ?? 1, c = new kc({
14897
14971
  id: `crop-frame-${D()}`,
14898
- left: i.x,
14899
- top: i.y,
14972
+ left: a.x,
14973
+ top: a.y,
14900
14974
  width: t.width,
14901
14975
  height: t.height,
14902
14976
  originX: "center",
14903
14977
  originY: "center",
14904
- scaleX: a,
14905
- scaleY: o,
14978
+ scaleX: o,
14979
+ scaleY: s,
14906
14980
  angle: e.angle ?? 0,
14907
14981
  fill: "rgba(47, 128, 237, 0.08)",
14908
14982
  stroke: "#2f80ed",
@@ -14919,22 +14993,24 @@ function xc({ source: e, cropSize: t, showGrid: n, preserveAspectRatio: r }) {
14919
14993
  lockSkewingY: !0,
14920
14994
  excludeFromExport: !0,
14921
14995
  showGrid: n,
14922
- preserveAspectRatio: r,
14923
- sourceScaleX: a,
14924
- sourceScaleY: o
14996
+ source: e,
14997
+ allowFrameOverflow: r,
14998
+ preserveAspectRatio: i,
14999
+ sourceScaleX: o,
15000
+ sourceScaleY: s
14925
15001
  });
14926
- return s.setControlsVisibility({ mtr: !1 }), vc({ target: s }), s;
15002
+ return c.setControlsVisibility({ mtr: !1 }), Dc({ target: c }), c;
14927
15003
  }
14928
- function Sc({ ctx: e, width: t, height: n }) {
15004
+ function jc({ ctx: e, width: t, height: n }) {
14929
15005
  if (!(t <= 0 || n <= 0)) {
14930
- e.save(), e.strokeStyle = yc, e.lineWidth = 1, e.setLineDash([]);
15006
+ e.save(), e.strokeStyle = Oc, e.lineWidth = 1, e.setLineDash([]);
14931
15007
  for (let r = 1; r <= 2; r += 1) {
14932
15008
  let i = -t / 2 + t * r / 3, a = -n / 2 + n * r / 3;
14933
- Cc({
15009
+ Mc({
14934
15010
  ctx: e,
14935
15011
  x: i,
14936
15012
  height: n
14937
- }), Ec({
15013
+ }), Fc({
14938
15014
  ctx: e,
14939
15015
  y: a,
14940
15016
  width: t
@@ -14943,19 +15019,19 @@ function Sc({ ctx: e, width: t, height: n }) {
14943
15019
  e.restore();
14944
15020
  }
14945
15021
  }
14946
- function Cc({ ctx: e, x: t, height: n }) {
15022
+ function Mc({ ctx: e, x: t, height: n }) {
14947
15023
  e.beginPath(), e.moveTo(t, -n / 2), e.lineTo(t, n / 2), e.stroke();
14948
15024
  }
14949
- function wc({ frame: e }) {
15025
+ function Nc({ frame: e }) {
14950
15026
  let t = e.calcTransformMatrix(), n = e.width / 2, r = e.height / 2;
14951
- return Tc({ points: [
15027
+ return Pc({ points: [
14952
15028
  new m(-n, -r),
14953
15029
  new m(n, -r),
14954
15030
  new m(n, r),
14955
15031
  new m(-n, r)
14956
15032
  ].map((e) => e.transform(t)) });
14957
15033
  }
14958
- function Tc({ points: e }) {
15034
+ function Pc({ points: e }) {
14959
15035
  let t = Math.min(...e.map((e) => e.x)), n = Math.max(...e.map((e) => e.x)), r = Math.min(...e.map((e) => e.y)), i = Math.max(...e.map((e) => e.y));
14960
15036
  return {
14961
15037
  left: t,
@@ -14966,18 +15042,18 @@ function Tc({ points: e }) {
14966
15042
  centerY: r + (i - r) / 2
14967
15043
  };
14968
15044
  }
14969
- function Ec({ ctx: e, y: t, width: n }) {
15045
+ function Fc({ ctx: e, y: t, width: n }) {
14970
15046
  e.beginPath(), e.moveTo(-n / 2, t), e.lineTo(n / 2, t), e.stroke();
14971
15047
  }
14972
15048
  //#endregion
14973
15049
  //#region src/editor/crop-manager/domain/crop-result.ts
14974
- function Dc({ session: e }) {
14975
- return e.mode === "canvas" ? Ac({ session: e }) : jc({
15050
+ function Ic({ session: e }) {
15051
+ return e.mode === "canvas" ? zc({ session: e }) : Bc({
14976
15052
  target: e.target,
14977
15053
  frame: e.frame
14978
15054
  });
14979
15055
  }
14980
- function Oc({ rect: e }) {
15056
+ function Lc({ rect: e }) {
14981
15057
  return {
14982
15058
  left: Math.round(e.left),
14983
15059
  top: Math.round(e.top),
@@ -14985,14 +15061,14 @@ function Oc({ rect: e }) {
14985
15061
  height: Math.round(e.height)
14986
15062
  };
14987
15063
  }
14988
- function kc({ rect: e }) {
14989
- return e.width >= xs && e.height >= xs;
15064
+ function Rc({ rect: e }) {
15065
+ return e.width >= Ss && e.height >= Ss;
14990
15066
  }
14991
- function Ac({ session: e }) {
15067
+ function zc({ session: e }) {
14992
15068
  let t = ws({
14993
15069
  source: e.source,
14994
15070
  frame: e.frame
14995
- }), n = Cs({ source: e.source });
15071
+ }), n = Z({ source: e.source });
14996
15072
  return {
14997
15073
  left: t.left + n.width / 2,
14998
15074
  top: t.top + n.height / 2,
@@ -15000,7 +15076,7 @@ function Ac({ session: e }) {
15000
15076
  height: t.height
15001
15077
  };
15002
15078
  }
15003
- function jc({ target: e, frame: t }) {
15079
+ function Bc({ target: e, frame: t }) {
15004
15080
  let n = ws({
15005
15081
  source: e,
15006
15082
  frame: t
@@ -15014,8 +15090,8 @@ function jc({ target: e, frame: t }) {
15014
15090
  }
15015
15091
  //#endregion
15016
15092
  //#region src/editor/crop-manager/mutation/crop-apply.ts
15017
- function Mc({ editor: e, frame: t, rect: n }) {
15018
- return kc({ rect: n }) ? (Bc({
15093
+ function Vc({ editor: e, frame: t, rect: n }) {
15094
+ return Rc({ rect: n }) ? (Yc({
15019
15095
  editor: e,
15020
15096
  frame: t,
15021
15097
  offset: new m(-n.left, -n.top)
@@ -15025,9 +15101,9 @@ function Mc({ editor: e, frame: t, rect: n }) {
15025
15101
  rect: n
15026
15102
  }) : null;
15027
15103
  }
15028
- function Nc({ editor: e, target: t, frame: n, rect: r }) {
15029
- if (!kc({ rect: r })) return null;
15030
- let i = Pc({
15104
+ function Hc({ editor: e, target: t, frame: n, rect: r }) {
15105
+ if (!Rc({ rect: r })) return null;
15106
+ let i = Uc({
15031
15107
  target: t,
15032
15108
  frame: n,
15033
15109
  rect: r
@@ -15038,21 +15114,21 @@ function Nc({ editor: e, target: t, frame: n, rect: r }) {
15038
15114
  rect: i
15039
15115
  }) : null;
15040
15116
  }
15041
- function Pc({ target: e, frame: t, rect: n }) {
15042
- let r = Math.max(xs, n.width), i = Math.max(xs, n.height), a = {
15117
+ function Uc({ target: e, frame: t, rect: n }) {
15118
+ let r = Math.max(Ss, n.width), i = Math.max(Ss, n.height), a = {
15043
15119
  width: r,
15044
15120
  height: i
15045
15121
  };
15046
- if (Fc({
15122
+ if (Wc({
15047
15123
  target: e,
15048
15124
  rect: n
15049
- })) Ic({
15125
+ })) Gc({
15050
15126
  target: e,
15051
15127
  size: a,
15052
15128
  rect: n
15053
15129
  });
15054
15130
  else {
15055
- let t = Lc({
15131
+ let t = Kc({
15056
15132
  target: e,
15057
15133
  size: a,
15058
15134
  rect: n
@@ -15072,10 +15148,10 @@ function Pc({ target: e, frame: t, rect: n }) {
15072
15148
  height: i
15073
15149
  };
15074
15150
  }
15075
- function Fc({ target: e, rect: t }) {
15151
+ function Wc({ target: e, rect: t }) {
15076
15152
  return t.left >= 0 && t.top >= 0 && t.left + t.width <= e.width && t.top + t.height <= e.height;
15077
15153
  }
15078
- function Ic({ target: e, size: t, rect: n }) {
15154
+ function Gc({ target: e, size: t, rect: n }) {
15079
15155
  let r = (e.cropX ?? 0) + n.left, i = (e.cropY ?? 0) + n.top;
15080
15156
  e.set({
15081
15157
  cropX: r,
@@ -15084,25 +15160,25 @@ function Ic({ target: e, size: t, rect: n }) {
15084
15160
  height: t.height
15085
15161
  });
15086
15162
  }
15087
- function Lc({ target: e, size: t, rect: n }) {
15088
- let r = e.getElement(), i = Rc({ target: e });
15163
+ function Kc({ target: e, size: t, rect: n }) {
15164
+ let r = e.getElement(), i = qc({ target: e });
15089
15165
  if (!r || !i) return null;
15090
15166
  let a = i.createElement("canvas");
15091
15167
  a.width = Math.round(t.width), a.height = Math.round(t.height);
15092
15168
  let o = a.getContext("2d");
15093
15169
  if (!o) return null;
15094
- let s = zc({
15170
+ let s = Jc({
15095
15171
  target: e,
15096
15172
  size: t,
15097
15173
  rect: n
15098
15174
  });
15099
15175
  return s && o.drawImage(r, s.sourceX, s.sourceY, s.sourceWidth, s.sourceHeight, s.destinationX, s.destinationY, s.sourceWidth, s.sourceHeight), a;
15100
15176
  }
15101
- function Rc({ target: e }) {
15177
+ function qc({ target: e }) {
15102
15178
  let t = e.canvas?.getElement();
15103
15179
  return t?.ownerDocument ? t.ownerDocument : typeof document < "u" ? document : null;
15104
15180
  }
15105
- function zc({ target: e, size: t, rect: n }) {
15181
+ function Jc({ target: e, size: t, rect: n }) {
15106
15182
  let r = Math.max(0, n.left), i = Math.max(0, n.top), a = Math.min(e.width, n.left + t.width), o = Math.min(e.height, n.top + t.height), s = a - r, c = o - i;
15107
15183
  return s <= 0 || c <= 0 ? null : {
15108
15184
  sourceX: (e.cropX ?? 0) + r,
@@ -15113,7 +15189,7 @@ function zc({ target: e, size: t, rect: n }) {
15113
15189
  destinationY: i - n.top
15114
15190
  };
15115
15191
  }
15116
- function Bc({ editor: e, frame: t, offset: n }) {
15192
+ function Yc({ editor: e, frame: t, offset: n }) {
15117
15193
  e.canvasManager.getObjects().forEach((e) => {
15118
15194
  e !== t && (e.set({
15119
15195
  left: (e.left ?? 0) + n.x,
@@ -15123,19 +15199,35 @@ function Bc({ editor: e, frame: t, offset: n }) {
15123
15199
  }
15124
15200
  //#endregion
15125
15201
  //#region src/editor/crop-manager/index.ts
15126
- var Vc = {
15202
+ var Xc = {
15127
15203
  allowFrameOverflow: !0,
15128
15204
  showGrid: !0,
15129
15205
  cancelOnSelectionClear: !0,
15130
15206
  preserveAspectRatio: !0
15131
- }, Hc = class {
15207
+ }, Zc = class {
15132
15208
  constructor({ editor: e }) {
15133
- this._handleCropFrameChangedBound = () => {
15134
- this._handleCropFrameChanged();
15135
- }, this._handleCanvasSelectionChangedBound = () => {
15136
- this._handleCanvasSelectionChanged();
15137
- }, this._handleCanvasMouseDownBeforeBound = (e) => {
15138
- this._handleCanvasMouseDownBefore(e);
15209
+ this._handleCropFrameChanged = (e) => {
15210
+ let { _session: t } = this;
15211
+ if (!t) return;
15212
+ let n = this._restoreSourceBoundFrameIfNeeded({
15213
+ session: t,
15214
+ event: e
15215
+ });
15216
+ this._clampFrameIfNeeded({
15217
+ session: t,
15218
+ preserveAspectRatio: this._isSourceScaleClamped({ event: e })
15219
+ }), n || this._rememberSourceBoundFrameIfNeeded({
15220
+ session: t,
15221
+ event: e
15222
+ }), this.editor.canvas.fire("editor:crop:changed", this.getState()), this.editor.canvas.requestRenderAll();
15223
+ }, this._handleCanvasSelectionChanged = () => {
15224
+ let { _session: e } = this;
15225
+ e && e.options.cancelOnSelectionClear && (this._isSpacePanActive() || this.editor.canvas.getActiveObject() !== e.frame && this.cancel());
15226
+ }, this._handleCanvasMouseDownBefore = ({ target: e }) => {
15227
+ let { _session: t } = this;
15228
+ if (!t || !t.options.cancelOnSelectionClear || this._isSpacePanActive() || e === t.frame) return;
15229
+ let n = null;
15230
+ t.mode === "image" && (n = t.target), this._cancelFromPointerDown({ nextActiveObject: n });
15139
15231
  }, this.editor = e, this._session = null;
15140
15232
  }
15141
15233
  get isActive() {
@@ -15148,7 +15240,7 @@ var Vc = {
15148
15240
  frame: e.frame,
15149
15241
  options: e.options,
15150
15242
  target: e.target,
15151
- rect: Dc({ session: e })
15243
+ rect: Ic({ session: e })
15152
15244
  } : null;
15153
15245
  }
15154
15246
  isFrameOverflowingSource({ target: e }) {
@@ -15157,7 +15249,7 @@ var Vc = {
15157
15249
  let n = ws({
15158
15250
  source: t.source,
15159
15251
  frame: t.frame
15160
- }), r = Cs({ source: t.source }), i = -r.width / 2, a = -r.height / 2, o = r.width / 2, s = r.height / 2;
15252
+ }), r = Z({ source: t.source }), i = -r.width / 2, a = -r.height / 2, o = r.width / 2, s = r.height / 2;
15161
15253
  return n.left < i || n.top < a || n.left + n.width > o || n.top + n.height > s;
15162
15254
  }
15163
15255
  startCanvasCrop(e = {}) {
@@ -15182,8 +15274,8 @@ var Vc = {
15182
15274
  setAspectRatio({ aspectRatio: e }) {
15183
15275
  let { _session: t } = this;
15184
15276
  if (!t) return null;
15185
- let n = Ss({
15186
- sourceSize: Cs({ source: t.source }),
15277
+ let n = Cs({
15278
+ sourceSize: Z({ source: t.source }),
15187
15279
  aspectRatio: e ?? void 0,
15188
15280
  allowOverflow: t.options.allowFrameOverflow
15189
15281
  });
@@ -15195,8 +15287,8 @@ var Vc = {
15195
15287
  setSize({ size: e }) {
15196
15288
  let { _session: t } = this;
15197
15289
  if (!t) return null;
15198
- let n = Ss({
15199
- sourceSize: Cs({ source: t.source }),
15290
+ let n = Cs({
15291
+ sourceSize: Z({ source: t.source }),
15200
15292
  size: e,
15201
15293
  allowOverflow: t.options.allowFrameOverflow
15202
15294
  });
@@ -15215,7 +15307,7 @@ var Vc = {
15215
15307
  resetFrameToSource({ target: e }) {
15216
15308
  let { _session: t } = this;
15217
15309
  if (!t || t.frame !== e) return null;
15218
- let n = Cs({ source: t.source });
15310
+ let n = Z({ source: t.source });
15219
15311
  return this._applyFrameSize({
15220
15312
  session: t,
15221
15313
  size: n
@@ -15250,7 +15342,8 @@ var Vc = {
15250
15342
  }),
15251
15343
  options: n,
15252
15344
  previousActiveObject: this.editor.canvas.getActiveObject() ?? null,
15253
- interactivity: []
15345
+ interactivity: [],
15346
+ sourceBoundFrameState: null
15254
15347
  };
15255
15348
  }
15256
15349
  _createImageSession({ target: e, options: t }) {
@@ -15266,67 +15359,87 @@ var Vc = {
15266
15359
  }),
15267
15360
  options: n,
15268
15361
  previousActiveObject: this.editor.canvas.getActiveObject() ?? null,
15269
- interactivity: []
15362
+ interactivity: [],
15363
+ sourceBoundFrameState: null
15270
15364
  };
15271
15365
  }
15272
15366
  _resolveSessionOptions({ options: e }) {
15273
15367
  return {
15274
- allowFrameOverflow: e.allowFrameOverflow ?? Vc.allowFrameOverflow,
15275
- showGrid: e.showGrid ?? Vc.showGrid,
15276
- cancelOnSelectionClear: e.cancelOnSelectionClear ?? Vc.cancelOnSelectionClear,
15277
- preserveAspectRatio: e.preserveAspectRatio ?? Vc.preserveAspectRatio
15368
+ allowFrameOverflow: e.allowFrameOverflow ?? Xc.allowFrameOverflow,
15369
+ showGrid: e.showGrid ?? Xc.showGrid,
15370
+ cancelOnSelectionClear: e.cancelOnSelectionClear ?? Xc.cancelOnSelectionClear,
15371
+ preserveAspectRatio: e.preserveAspectRatio ?? Xc.preserveAspectRatio
15278
15372
  };
15279
15373
  }
15280
15374
  _createCropFrameForSource({ source: e, options: t, sessionOptions: n }) {
15281
- return xc({
15375
+ return Ac({
15282
15376
  source: e,
15283
- cropSize: Ss({
15284
- sourceSize: Cs({ source: e }),
15377
+ cropSize: Cs({
15378
+ sourceSize: Z({ source: e }),
15285
15379
  size: t.size,
15286
15380
  aspectRatio: t.aspectRatio,
15287
15381
  allowOverflow: n.allowFrameOverflow
15288
15382
  }),
15289
15383
  showGrid: n.showGrid,
15384
+ allowFrameOverflow: n.allowFrameOverflow,
15290
15385
  preserveAspectRatio: n.preserveAspectRatio
15291
15386
  });
15292
15387
  }
15293
15388
  _setFramePreserveAspectRatio({ frame: e, preserveAspectRatio: t }) {
15294
- let n = e;
15295
- n.preserveAspectRatio = t;
15389
+ if (!(e instanceof kc)) throw Error("Crop session frame должен быть CropFrame");
15390
+ e.preserveAspectRatio = t;
15296
15391
  }
15297
15392
  _activateSession({ session: e }) {
15298
15393
  let { canvas: t, historyManager: n } = this.editor;
15299
15394
  n.suspendHistory(), this.editor.toolbar.hideTemporarily(), e.interactivity = this._disableSceneObjects(), this._session = e, this._bindCropFrameEvents({ frame: e.frame }), t.add(e.frame), t.bringObjectToFront(e.frame), t.setActiveObject(e.frame), this._clampFrameIfNeeded({ session: e }), this._bindCanvasSelectionEvents({ session: e }), t.requestRenderAll(), t.fire("editor:crop:started", this.getState());
15300
15395
  }
15301
15396
  _bindCropFrameEvents({ frame: e }) {
15302
- e.on("moving", this._handleCropFrameChangedBound), e.on("scaling", this._handleCropFrameChangedBound), e.on("modified", this._handleCropFrameChangedBound);
15397
+ e.on("moving", this._handleCropFrameChanged), e.on("scaling", this._handleCropFrameChanged), e.on("modified", this._handleCropFrameChanged);
15303
15398
  }
15304
15399
  _unbindCropFrameEvents({ frame: e }) {
15305
- e.off("moving", this._handleCropFrameChangedBound), e.off("scaling", this._handleCropFrameChangedBound), e.off("modified", this._handleCropFrameChangedBound);
15400
+ e.off("moving", this._handleCropFrameChanged), e.off("scaling", this._handleCropFrameChanged), e.off("modified", this._handleCropFrameChanged);
15306
15401
  }
15307
15402
  _bindCanvasSelectionEvents({ session: e }) {
15308
- e.options.cancelOnSelectionClear && (this.editor.canvas.on("mouse:down:before", this._handleCanvasMouseDownBeforeBound), this.editor.canvas.on("selection:cleared", this._handleCanvasSelectionChangedBound), this.editor.canvas.on("selection:updated", this._handleCanvasSelectionChangedBound));
15403
+ e.options.cancelOnSelectionClear && (this.editor.canvas.on("mouse:down:before", this._handleCanvasMouseDownBefore), this.editor.canvas.on("selection:cleared", this._handleCanvasSelectionChanged), this.editor.canvas.on("selection:updated", this._handleCanvasSelectionChanged));
15309
15404
  }
15310
15405
  _unbindCanvasSelectionEvents() {
15311
- this.editor.canvas.off("mouse:down:before", this._handleCanvasMouseDownBeforeBound), this.editor.canvas.off("selection:cleared", this._handleCanvasSelectionChangedBound), this.editor.canvas.off("selection:updated", this._handleCanvasSelectionChangedBound);
15406
+ this.editor.canvas.off("mouse:down:before", this._handleCanvasMouseDownBefore), this.editor.canvas.off("selection:cleared", this._handleCanvasSelectionChanged), this.editor.canvas.off("selection:updated", this._handleCanvasSelectionChanged);
15312
15407
  }
15313
- _handleCropFrameChanged() {
15314
- let { _session: e } = this;
15315
- e && (this._clampFrameIfNeeded({ session: e }), this.editor.canvas.fire("editor:crop:changed", this.getState()), this.editor.canvas.requestRenderAll());
15408
+ _restoreSourceBoundFrameIfNeeded({ session: e, event: t }) {
15409
+ return this._isSourceScaleClamped({ event: t }) ? e.sourceBoundFrameState ? (this._applyFrameTransformState({
15410
+ session: e,
15411
+ state: e.sourceBoundFrameState
15412
+ }), !0) : !1 : (e.sourceBoundFrameState = null, !1);
15316
15413
  }
15317
- _handleCanvasSelectionChanged() {
15318
- let { _session: e } = this;
15319
- e && e.options.cancelOnSelectionClear && (this._isSpacePanActive() || this.editor.canvas.getActiveObject() !== e.frame && this.cancel());
15414
+ _rememberSourceBoundFrameIfNeeded({ session: e, event: t }) {
15415
+ if (!this._isSourceScaleClamped({ event: t })) {
15416
+ e.sourceBoundFrameState = null;
15417
+ return;
15418
+ }
15419
+ e.sourceBoundFrameState = this._getFrameTransformState({ session: e });
15420
+ }
15421
+ _isSourceScaleClamped({ event: e }) {
15422
+ return e?.transform?.cropSourceScaleClamped === !0;
15423
+ }
15424
+ _getFrameTransformState({ session: e }) {
15425
+ return {
15426
+ left: e.frame.left,
15427
+ top: e.frame.top,
15428
+ scaleX: e.frame.scaleX ?? 1,
15429
+ scaleY: e.frame.scaleY ?? 1
15430
+ };
15431
+ }
15432
+ _applyFrameTransformState({ session: e, state: t }) {
15433
+ e.frame.set({
15434
+ left: t.left,
15435
+ top: t.top,
15436
+ scaleX: t.scaleX,
15437
+ scaleY: t.scaleY
15438
+ }), e.frame.setCoords();
15320
15439
  }
15321
15440
  _isSpacePanActive() {
15322
15441
  return !!this.editor.listeners?.isSpacePressed;
15323
15442
  }
15324
- _handleCanvasMouseDownBefore({ target: e }) {
15325
- let { _session: t } = this;
15326
- if (!t || !t.options.cancelOnSelectionClear || this._isSpacePanActive() || e === t.frame) return;
15327
- let n = t.mode === "image" ? t.target : null;
15328
- this._cancelFromPointerDown({ nextActiveObject: n });
15329
- }
15330
15443
  _cancelFromPointerDown({ nextActiveObject: e }) {
15331
15444
  let { _session: t } = this;
15332
15445
  if (!t) return;
@@ -15361,19 +15474,28 @@ var Vc = {
15361
15474
  scaleY: e.source.scaleY ?? 1
15362
15475
  }), e.frame.setCoords(), this._clampFrameIfNeeded({ session: e }), this.editor.canvas.requestRenderAll();
15363
15476
  }
15364
- _clampFrameIfNeeded({ session: e }) {
15365
- e.options.allowFrameOverflow || Ts({
15366
- source: e.source,
15367
- frame: e.frame
15368
- });
15477
+ _clampFrameIfNeeded({ session: e, preserveAspectRatio: t = !1 }) {
15478
+ if (!e.options.allowFrameOverflow) {
15479
+ if (t) {
15480
+ Es({
15481
+ source: e.source,
15482
+ frame: e.frame
15483
+ });
15484
+ return;
15485
+ }
15486
+ Ts({
15487
+ source: e.source,
15488
+ frame: e.frame
15489
+ });
15490
+ }
15369
15491
  }
15370
15492
  _applySessionCrop({ session: e }) {
15371
- let t = Oc({ rect: Dc({ session: e }) });
15372
- return e.mode === "canvas" ? Mc({
15493
+ let t = Lc({ rect: Ic({ session: e }) });
15494
+ return e.mode === "canvas" ? Vc({
15373
15495
  editor: this.editor,
15374
15496
  frame: e.frame,
15375
15497
  rect: t
15376
- }) : Nc({
15498
+ }) : Hc({
15377
15499
  editor: this.editor,
15378
15500
  target: e.target,
15379
15501
  frame: e.frame,
@@ -15421,7 +15543,7 @@ var Vc = {
15421
15543
  this.editor.errorManager.emitError({
15422
15544
  origin: "CropManager",
15423
15545
  method: "startImageCrop",
15424
- code: Ka.CROP_MANAGER.INVALID_IMAGE_TARGET,
15546
+ code: qa.CROP_MANAGER.INVALID_IMAGE_TARGET,
15425
15547
  message: "Для кропа изображения нужно выбрать raster image объект.",
15426
15548
  data: {
15427
15549
  targetType: e?.type,
@@ -15433,7 +15555,7 @@ var Vc = {
15433
15555
  this.editor.errorManager.emitError({
15434
15556
  origin: "CropManager",
15435
15557
  method: "startImageCrop",
15436
- code: Ka.CROP_MANAGER.LOCKED_IMAGE_TARGET,
15558
+ code: qa.CROP_MANAGER.LOCKED_IMAGE_TARGET,
15437
15559
  message: "Заблокированное изображение нельзя обрезать.",
15438
15560
  data: {
15439
15561
  targetType: e.type,
@@ -15441,13 +15563,13 @@ var Vc = {
15441
15563
  }
15442
15564
  });
15443
15565
  }
15444
- }, Uc = class e {
15566
+ }, Qc = class e {
15445
15567
  constructor(e, t) {
15446
15568
  this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
15447
15569
  }
15448
15570
  async init() {
15449
15571
  let { editorContainerWidth: e, editorContainerHeight: n, canvasWrapperWidth: r, canvasWrapperHeight: i, canvasCSSWidth: a, canvasCSSHeight: o, initialImage: s, initialState: c, scaleType: l, showRotationAngle: u, showObjectSizeOnScale: d, showViewportScrollbars: f, _onReadyCallback: p } = this.options;
15450
- if (_e.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new I(), this.workerManager = new te(), this.errorManager = new qa({ editor: this }), this.historyManager = new Ht({ editor: this }), this.toolbar = new it({ editor: this }), this.transformManager = new $t({ editor: this }), this.zoomManager = new en({ editor: this }), this.canvasManager = new Qt({ editor: this }), this.imageManager = new Jt({ editor: this }), this.layerManager = new Bn({ editor: this }), this.shapeManager = new za({ editor: this }), this.interactionBlocker = new Rn({ editor: this }), this.backgroundManager = new zn({ editor: this }), this.clipboardManager = new Va({ editor: this }), this.objectLockManager = new Ha({ editor: this }), this.groupingManager = new Ua({ editor: this }), this.selectionManager = new Wa({ editor: this }), this.deletionManager = new Ga({ editor: this }), this.panConstraintManager = new Ya({ editor: this }), this.snappingManager = new ms({ editor: this }), this.measurementManager = new gs({ editor: this }), this.fontManager = new ve(this.options.fonts ?? []), this.textManager = new go({ editor: this }), this.templateManager = new xo({ editor: this }), this.cropManager = new Hc({ editor: this }), u && (this.angleIndicator = new ct({ editor: this })), d && (this.objectSizeIndicator = new ut({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new F({
15572
+ if (_e.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new I(), this.workerManager = new te(), this.errorManager = new Ja({ editor: this }), this.historyManager = new Ht({ editor: this }), this.toolbar = new it({ editor: this }), this.transformManager = new $t({ editor: this }), this.zoomManager = new en({ editor: this }), this.canvasManager = new Qt({ editor: this }), this.imageManager = new Jt({ editor: this }), this.layerManager = new Bn({ editor: this }), this.shapeManager = new Ba({ editor: this }), this.interactionBlocker = new Rn({ editor: this }), this.backgroundManager = new zn({ editor: this }), this.clipboardManager = new Ha({ editor: this }), this.objectLockManager = new Ua({ editor: this }), this.groupingManager = new Wa({ editor: this }), this.selectionManager = new Ga({ editor: this }), this.deletionManager = new Ka({ editor: this }), this.panConstraintManager = new Xa({ editor: this }), this.snappingManager = new hs({ editor: this }), this.measurementManager = new _s({ editor: this }), this.fontManager = new ve(this.options.fonts ?? []), this.textManager = new _o({ editor: this }), this.templateManager = new So({ editor: this }), this.cropManager = new Zc({ editor: this }), u && (this.angleIndicator = new ct({ editor: this })), d && (this.objectSizeIndicator = new ut({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new F({
15451
15573
  editor: this,
15452
15574
  options: this.options
15453
15575
  }), 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(), f && (this.viewportScrollbars = new gt({ editor: this })), await this.fontManager.loadFonts(), c) {
@@ -15555,7 +15677,7 @@ var Vc = {
15555
15677
  "U+A640-A69F",
15556
15678
  "U+FE2E-FE2F",
15557
15679
  "U+2116"
15558
- ].join(", "), Wc = {
15680
+ ].join(", "), $c = {
15559
15681
  preserveObjectStacking: !0,
15560
15682
  controlsAboveOverlay: !0,
15561
15683
  centeredRotation: !0,
@@ -16413,20 +16535,20 @@ var Vc = {
16413
16535
  };
16414
16536
  //#endregion
16415
16537
  //#region src/main.ts
16416
- function Gc(e, t = {}) {
16538
+ function el(e, t = {}) {
16417
16539
  let n = {
16418
- ...Wc,
16540
+ ...$c,
16419
16541
  ...t
16420
16542
  }, r = document.getElementById(e);
16421
16543
  if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
16422
16544
  let i = document.createElement("canvas");
16423
16545
  return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
16424
16546
  n._onReadyCallback = t;
16425
- let r = new Uc(i.id, n);
16547
+ let r = new Qc(i.id, n);
16426
16548
  window[e] = r;
16427
16549
  });
16428
16550
  }
16429
16551
  //#endregion
16430
- export { Gc as default };
16552
+ export { el as default };
16431
16553
 
16432
16554
  //# sourceMappingURL=main.js.map