@anu3ev/fabric-image-editor 0.10.1 → 0.10.2

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 +749 -751
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -5016,6 +5016,35 @@ var Ur = class extends _ {
5016
5016
  });
5017
5017
  }
5018
5018
  }
5019
+ setPreparedImageBackground({ image: e, customData: t = {}, fromTemplate: n = !1, withoutSave: r = !1 }) {
5020
+ let { historyManager: i } = this.editor, a = !1;
5021
+ try {
5022
+ i.suspendHistory(), a = !0, this._setImageBackgroundObject({
5023
+ image: e,
5024
+ customData: t
5025
+ }), this.editor.canvas.fire("editor:background:changed", {
5026
+ type: "image",
5027
+ customData: t,
5028
+ fromTemplate: n,
5029
+ withoutSave: r,
5030
+ backgroundObject: this.backgroundObject
5031
+ }), i.resumeHistory(), a = !1, r || i.saveState();
5032
+ } catch (o) {
5033
+ a && i.resumeHistory(), this.editor.errorManager.emitError({
5034
+ code: "BACKGROUND_CREATION_FAILED",
5035
+ origin: "BackgroundManager",
5036
+ method: "setPreparedImageBackground",
5037
+ message: "Не удалось установить подготовленное изображение в качестве фона",
5038
+ data: {
5039
+ error: o,
5040
+ image: e,
5041
+ customData: t,
5042
+ fromTemplate: n,
5043
+ withoutSave: r
5044
+ }
5045
+ });
5046
+ }
5047
+ }
5019
5048
  removeBackground({ withoutSave: e = !1 } = {}) {
5020
5049
  try {
5021
5050
  let { historyManager: t } = this.editor;
@@ -5086,7 +5115,13 @@ var Ur = class extends _ {
5086
5115
  scale: "image-cover"
5087
5116
  }) ?? {};
5088
5117
  if (!n) throw Error("Не удалось загрузить изображение");
5089
- n.set({
5118
+ this._setImageBackgroundObject({
5119
+ image: n,
5120
+ customData: t
5121
+ });
5122
+ }
5123
+ _setImageBackgroundObject({ image: e, customData: t }) {
5124
+ e.set({
5090
5125
  selectable: !1,
5091
5126
  evented: !1,
5092
5127
  hasBorders: !1,
@@ -5095,7 +5130,7 @@ var Ur = class extends _ {
5095
5130
  backgroundType: "image",
5096
5131
  backgroundId: `background-${D()}`,
5097
5132
  customData: t
5098
- }), this._removeCurrentBackground(), this.backgroundObject = n, this.refresh();
5133
+ }), this._removeCurrentBackground(), e.canvas !== this.editor.canvas && this.editor.canvas.add(e), this.backgroundObject = e, this.refresh();
5099
5134
  }
5100
5135
  _removeCurrentBackground() {
5101
5136
  this.backgroundObject && (this.editor.canvas.remove(this.backgroundObject), this.backgroundObject = null, this.editor.canvas.renderAll());
@@ -12664,43 +12699,10 @@ function ks({ objects: e }) {
12664
12699
  contentObjects: e.filter((e, n) => n !== t)
12665
12700
  };
12666
12701
  }
12667
- function As({ source: e }) {
12668
- return e.startsWith("blob:");
12669
- }
12670
- function js(e) {
12671
- if (typeof e != "string") return null;
12672
- let t = e.trim();
12673
- return !t || As({ source: t }) ? null : t;
12674
- }
12675
- function Ms(e) {
12676
- let t = js(e);
12677
- if (t) return t;
12678
- if (!e || typeof e != "object") return null;
12679
- let n = e;
12680
- return js(n["4096x4096"]) || js(n["1920x1920"]) || Object.values(n).map((e) => js(e)).find((e) => !!e) || null;
12681
- }
12682
- function Ns(e) {
12683
- if (!e) return null;
12684
- let { customData: t } = e;
12685
- return js(e.src) || js(t?.originalUrl) || Ms(t?.src);
12686
- }
12687
- function Ps(e) {
12702
+ function As(e) {
12688
12703
  if (!(!e || typeof e != "object")) return { ...e };
12689
12704
  }
12690
- function Fs(e) {
12691
- let t = e;
12692
- if ("getSrc" in e && typeof t.getSrc == "function") {
12693
- let e = t.getSrc();
12694
- if (e) return e;
12695
- }
12696
- if ("getElement" in e && typeof t.getElement == "function") {
12697
- let e = t.getElement();
12698
- if (e instanceof HTMLImageElement) return e.currentSrc || e.src || null;
12699
- }
12700
- let n = e;
12701
- return typeof n.src == "string" ? n.src : null;
12702
- }
12703
- function Is({ fill: e, customData: t, backgroundManager: n }) {
12705
+ function js({ fill: e, customData: t, backgroundManager: n }) {
12704
12706
  return typeof e == "string" ? (n.setColorBackground({
12705
12707
  color: e,
12706
12708
  customData: t,
@@ -12708,7 +12710,7 @@ function Is({ fill: e, customData: t, backgroundManager: n }) {
12708
12710
  withoutSave: !0
12709
12711
  }), !0) : !1;
12710
12712
  }
12711
- function Ls({ fill: e, customData: t, backgroundManager: n }) {
12713
+ function Ms({ fill: e, customData: t, backgroundManager: n }) {
12712
12714
  let r = Os(e);
12713
12715
  return r ? (n.setGradientBackground({
12714
12716
  gradient: r,
@@ -12717,36 +12719,34 @@ function Ls({ fill: e, customData: t, backgroundManager: n }) {
12717
12719
  withoutSave: !0
12718
12720
  }), !0) : !1;
12719
12721
  }
12720
- async function Rs({ backgroundObject: e, serializedBackgroundObject: t, customData: n, backgroundManager: r }) {
12721
- let i = Ns(t) || Fs(e);
12722
- return i ? (await r.setImageBackground({
12723
- imageSource: i,
12724
- customData: n,
12722
+ function Ns({ backgroundObject: e, customData: t, backgroundManager: n }) {
12723
+ return n.setPreparedImageBackground({
12724
+ image: e,
12725
+ customData: t,
12725
12726
  fromTemplate: !0,
12726
12727
  withoutSave: !0
12727
- }), !0) : !1;
12728
+ }), !0;
12728
12729
  }
12729
- async function zs({ backgroundObject: e, serializedBackgroundObject: t, backgroundManager: n, errorManager: r }) {
12730
+ function Ps({ backgroundObject: e, backgroundManager: t, errorManager: n }) {
12730
12731
  try {
12731
- let { fill: r, customData: i } = e, { backgroundType: a } = e, o = Ps(i);
12732
- if (a === "color") return Is({
12733
- fill: r,
12734
- customData: o,
12735
- backgroundManager: n
12732
+ let { fill: n, customData: r } = e, { backgroundType: i } = e, a = As(r);
12733
+ if (i === "color") return js({
12734
+ fill: n,
12735
+ customData: a,
12736
+ backgroundManager: t
12736
12737
  });
12737
- if (a === "gradient") return Ls({
12738
- fill: r,
12739
- customData: o,
12740
- backgroundManager: n
12738
+ if (i === "gradient") return Ms({
12739
+ fill: n,
12740
+ customData: a,
12741
+ backgroundManager: t
12741
12742
  });
12742
- if (a === "image") return Rs({
12743
+ if (i === "image") return Ns({
12743
12744
  backgroundObject: e,
12744
- serializedBackgroundObject: t,
12745
- customData: o,
12746
- backgroundManager: n
12745
+ customData: a,
12746
+ backgroundManager: t
12747
12747
  });
12748
12748
  } catch (e) {
12749
- r.emitWarning({
12749
+ n.emitWarning({
12750
12750
  origin: "TemplateManager",
12751
12751
  method: "applyTemplate",
12752
12752
  code: rs.TEMPLATE_MANAGER.APPLY_FAILED,
@@ -12758,7 +12758,7 @@ async function zs({ backgroundObject: e, serializedBackgroundObject: t, backgrou
12758
12758
  }
12759
12759
  //#endregion
12760
12760
  //#region src/editor/template-manager/index.ts
12761
- var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
12761
+ var Fs = "_templateAnchorX", Is = "_templateAnchorY", Ls = class t {
12762
12762
  constructor({ editor: e }) {
12763
12763
  this.editor = e;
12764
12764
  }
@@ -12810,7 +12810,7 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
12810
12810
  errorManager: i
12811
12811
  });
12812
12812
  if (!n) return null;
12813
- let r = await this._applyPreparedTemplateObjects({
12813
+ let r = this._applyPreparedTemplateObjects({
12814
12814
  preparedTemplateObjects: n,
12815
12815
  template: e,
12816
12816
  backgroundManager: a,
@@ -12837,11 +12837,10 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
12837
12837
  r.resumeHistory(), p && r.saveState();
12838
12838
  }
12839
12839
  }
12840
- async _applyPreparedTemplateObjects({ preparedTemplateObjects: e, template: n, backgroundManager: r, errorManager: i, scale: a, montageBounds: o, baseWidth: s, baseHeight: c, useRelativePositions: l }) {
12840
+ _applyPreparedTemplateObjects({ preparedTemplateObjects: e, template: n, backgroundManager: r, errorManager: i, scale: a, montageBounds: o, baseWidth: s, baseHeight: c, useRelativePositions: l }) {
12841
12841
  let { canvas: u } = this.editor, d = !1;
12842
- e.backgroundObject && (d = await zs({
12842
+ e.backgroundObject && (d = Ps({
12843
12843
  backgroundObject: e.backgroundObject,
12844
- serializedBackgroundObject: e.serializedBackgroundObject,
12845
12844
  backgroundManager: r,
12846
12845
  errorManager: i
12847
12846
  }));
@@ -12959,23 +12958,22 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
12959
12958
  }))).filter((e) => !!e);
12960
12959
  }
12961
12960
  static async _prepareTemplateObjectsForApply({ template: e, imageManager: n, baseWidth: r, baseHeight: i, useRelativePositions: a, errorManager: o }) {
12962
- let { objects: s } = e, { backgroundObject: c } = ks({ objects: s }), l = await n.prepareSerializedImageSources({ state: e }), u = Array.isArray(l.objects) ? l.objects : [], d = await t._enlivenObjects({
12963
- objects: u,
12961
+ let s = await n.prepareSerializedImageSources({ state: e }), c = Array.isArray(s.objects) ? s.objects : [], l = await t._enlivenObjects({
12962
+ objects: c,
12964
12963
  baseWidth: r,
12965
12964
  baseHeight: i,
12966
12965
  useRelativePositions: a
12967
12966
  });
12968
- if (!d.length) return o.emitWarning({
12967
+ if (!l.length) return o.emitWarning({
12969
12968
  origin: "TemplateManager",
12970
12969
  method: "applyTemplate",
12971
12970
  code: rs.TEMPLATE_MANAGER.INVALID_TEMPLATE,
12972
12971
  message: "Не удалось создать объекты шаблона"
12973
12972
  }), null;
12974
- let { backgroundObject: f, contentObjects: p } = ks({ objects: d });
12973
+ let { backgroundObject: u, contentObjects: d } = ks({ objects: l });
12975
12974
  return {
12976
- backgroundObject: f,
12977
- serializedBackgroundObject: c,
12978
- contentObjects: p
12975
+ backgroundObject: u,
12976
+ contentObjects: d
12979
12977
  };
12980
12978
  }
12981
12979
  static _restoreImageScale({ revived: e, serialized: n, baseWidth: r, baseHeight: i, useRelativePositions: a }) {
@@ -13202,8 +13200,8 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13202
13200
  baseHeight: a,
13203
13201
  scale: n,
13204
13202
  useRelativePositions: o,
13205
- anchorX: t._resolveAnchor(s, Bs),
13206
- anchorY: t._resolveAnchor(s, Vs)
13203
+ anchorX: t._resolveAnchor(s, Fs),
13204
+ anchorY: t._resolveAnchor(s, Is)
13207
13205
  })
13208
13206
  }), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
13209
13207
  e.set({
@@ -13278,7 +13276,7 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13278
13276
  });
13279
13277
  if (!i || !a) return;
13280
13278
  e.setCoords();
13281
- let o = e, s = t._resolveAnchor(o, Bs), 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;
13279
+ let o = e, s = t._resolveAnchor(o, Fs), 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;
13282
13280
  e.set("width", i), e.initDimensions();
13283
13281
  let h = t._getLongestLineWidth({
13284
13282
  textbox: e,
@@ -13307,10 +13305,10 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13307
13305
  x: (p.left - o) / d,
13308
13306
  y: (p.top - s) / f
13309
13307
  }, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
13310
- return a[Bs] = t._detectAnchor({
13308
+ return a[Fs] = t._detectAnchor({
13311
13309
  start: h,
13312
13310
  end: _
13313
- }), a[Vs] = t._detectAnchor({
13311
+ }), a[Is] = t._detectAnchor({
13314
13312
  start: g,
13315
13313
  end: v
13316
13314
  }), a.left = m.x, a.top = m.y, a;
@@ -13328,29 +13326,29 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13328
13326
  enlivenObjectEnlivables(e) {
13329
13327
  return w.enlivenObjectEnlivables(e);
13330
13328
  }
13331
- }, Us = "#3D8BF4", Ws = .5, Gs = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, Ks = ({ firstDistance: e, secondDistance: t }) => {
13332
- let n = Gs({ distance: e }), r = Gs({ distance: t });
13329
+ }, Rs = "#3D8BF4", zs = .5, Bs = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, Vs = ({ firstDistance: e, secondDistance: t }) => {
13330
+ let n = Bs({ distance: e }), r = Bs({ distance: t });
13333
13331
  return {
13334
13332
  firstDisplayDistance: n,
13335
13333
  secondDisplayDistance: r,
13336
13334
  displayDistanceDiff: Math.abs(n - r),
13337
13335
  commonDisplayDistance: Math.max(n, r)
13338
13336
  };
13339
- }, qs = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), Js = ({ step: e }) => {
13337
+ }, Hs = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), Us = ({ step: e }) => {
13340
13338
  let t = Math.abs(e).toString(), n = t.indexOf(".");
13341
13339
  return n === -1 ? 0 : t.slice(n + 1).length;
13342
- }, Ys = ({ value: e, step: t }) => {
13340
+ }, Ws = ({ value: e, step: t }) => {
13343
13341
  if (t === 0) return e;
13344
- let n = Js({ step: t }), r = Math.round(e / t) * t;
13342
+ let n = Us({ step: t }), r = Math.round(e / t) * t;
13345
13343
  return Number(r.toFixed(n));
13346
- }, Xs = ({ value: e, step: t }) => {
13344
+ }, Gs = ({ value: e, step: t }) => {
13347
13345
  if (t === 0) return !0;
13348
- let n = Ys({
13346
+ let n = Ws({
13349
13347
  value: e,
13350
13348
  step: t
13351
- }), r = 10 ** -(Js({ step: t }) + 4);
13349
+ }), r = 10 ** -(Us({ step: t }) + 4);
13352
13350
  return Math.abs(n - e) <= r;
13353
- }, Zs = ({ bounds: e, axis: t }) => {
13351
+ }, Ks = ({ bounds: e, axis: t }) => {
13354
13352
  let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
13355
13353
  return t === "vertical" ? {
13356
13354
  start: i,
@@ -13359,7 +13357,7 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13359
13357
  start: n,
13360
13358
  end: r
13361
13359
  };
13362
- }, Qs = ({ items: e, axis: t }) => {
13360
+ }, qs = ({ items: e, axis: t }) => {
13363
13361
  for (let n = 1; n < e.length; n += 1) {
13364
13362
  let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
13365
13363
  for (; o >= 0;) {
@@ -13369,10 +13367,10 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13369
13367
  }
13370
13368
  e[o + 1] = r;
13371
13369
  }
13372
- }, $s = ({ items: e, index: t, axis: n, direction: r }) => {
13370
+ }, Js = ({ items: e, index: t, axis: n, direction: r }) => {
13373
13371
  let i = e[t];
13374
13372
  if (!i) return null;
13375
- let { bounds: a } = i, { start: o, end: s } = Zs({
13373
+ let { bounds: a } = i, { start: o, end: s } = Ks({
13376
13374
  bounds: a,
13377
13375
  axis: n
13378
13376
  });
@@ -13380,7 +13378,7 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13380
13378
  for (let r = t - 1; r >= 0; --r) {
13381
13379
  let t = e[r];
13382
13380
  if (!t) continue;
13383
- let { bounds: i } = t, { end: a } = Zs({
13381
+ let { bounds: i } = t, { end: a } = Ks({
13384
13382
  bounds: i,
13385
13383
  axis: n
13386
13384
  });
@@ -13391,26 +13389,26 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13391
13389
  for (let r = t + 1; r < e.length; r += 1) {
13392
13390
  let t = e[r];
13393
13391
  if (!t) continue;
13394
- let { bounds: i } = t, { start: a } = Zs({
13392
+ let { bounds: i } = t, { start: a } = Ks({
13395
13393
  bounds: i,
13396
13394
  axis: n
13397
13395
  });
13398
13396
  if (a - s >= 0) return r;
13399
13397
  }
13400
13398
  return null;
13401
- }, ec = ({ items: e }) => {
13399
+ }, Ys = ({ items: e }) => {
13402
13400
  for (let t = 0; t < e.length; t += 1) {
13403
13401
  let { isActive: n } = e[t];
13404
13402
  if (n) return t;
13405
13403
  }
13406
13404
  return -1;
13407
- }, tc = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
13405
+ }, Xs = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
13408
13406
  let i = Math.min(t, n), a = Math.max(t, n);
13409
13407
  return e >= i - r && e <= a + r;
13410
- }, nc = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, rc = ({ baseOption: e, candidateOption: t }) => {
13408
+ }, Zs = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Qs = ({ baseOption: e, candidateOption: t }) => {
13411
13409
  let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
13412
13410
  return n === i && r === a;
13413
- }, ic = ({ options: e }) => {
13411
+ }, $s = ({ options: e }) => {
13414
13412
  let t = e[0];
13415
13413
  for (let n = 1; n < e.length; n += 1) {
13416
13414
  let r = e[n];
@@ -13421,11 +13419,11 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13421
13419
  r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
13422
13420
  }
13423
13421
  return t;
13424
- }, ac = ({ currentOption: e, nextOption: t }) => {
13422
+ }, ec = ({ currentOption: e, nextOption: t }) => {
13425
13423
  if (!e) return !0;
13426
13424
  let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
13427
13425
  return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
13428
- }, oc = ({ options: e }) => {
13426
+ }, tc = ({ options: e }) => {
13429
13427
  let t = [], n = null, r = null;
13430
13428
  for (let i of e) {
13431
13429
  let { kind: e, side: a } = i;
@@ -13433,18 +13431,18 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13433
13431
  t.push(i);
13434
13432
  continue;
13435
13433
  }
13436
- a === "before" && ac({
13434
+ a === "before" && ec({
13437
13435
  currentOption: n,
13438
13436
  nextOption: i
13439
- }) && (n = i), a === "after" && ac({
13437
+ }) && (n = i), a === "after" && ec({
13440
13438
  currentOption: r,
13441
13439
  nextOption: i
13442
13440
  }) && (r = i);
13443
13441
  }
13444
13442
  return n && t.push(n), r && t.push(r), t;
13445
- }, sc = ({ options: e, side: t, baseOption: n }) => {
13443
+ }, nc = ({ options: e, side: t, baseOption: n }) => {
13446
13444
  let r = null;
13447
- for (let i of e) if (i.side === t && rc({
13445
+ for (let i of e) if (i.side === t && Qs({
13448
13446
  baseOption: n,
13449
13447
  candidateOption: i
13450
13448
  })) {
@@ -13455,63 +13453,63 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13455
13453
  !r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
13456
13454
  }
13457
13455
  return r;
13458
- }, cc = ({ option: e }) => {
13456
+ }, rc = ({ option: e }) => {
13459
13457
  let { side: t, kind: n, guide: { distance: r } } = e;
13460
13458
  return {
13461
13459
  side: t,
13462
13460
  kind: n,
13463
13461
  distance: r
13464
13462
  };
13465
- }, lc = ({ option: e, context: t }) => {
13463
+ }, ic = ({ option: e, context: t }) => {
13466
13464
  let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
13467
13465
  return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
13468
- }, uc = ({ options: e, context: t }) => {
13466
+ }, ac = ({ options: e, context: t }) => {
13469
13467
  if (!t) return null;
13470
- for (let n of e) if (lc({
13468
+ for (let n of e) if (ic({
13471
13469
  option: n,
13472
13470
  context: t
13473
13471
  })) return n;
13474
13472
  return null;
13475
- }, dc = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
13476
- let i = uc({
13473
+ }, oc = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
13474
+ let i = ac({
13477
13475
  options: e,
13478
13476
  context: n
13479
13477
  });
13480
13478
  if (!i) return t;
13481
13479
  let a = Math.max(0, r);
13482
13480
  return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
13483
- }, fc = ({ guides: e, seenGuideKeys: t, guide: n }) => {
13481
+ }, sc = ({ guides: e, seenGuideKeys: t, guide: n }) => {
13484
13482
  let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
13485
13483
  t.has(u) || (t.add(u), e.push(n));
13486
- }, pc = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
13484
+ }, cc = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
13487
13485
  if (!e.length) return {
13488
13486
  delta: 0,
13489
13487
  guides: [],
13490
13488
  context: null
13491
13489
  };
13492
- let r = oc({ options: e }), i = [];
13490
+ let r = tc({ options: e }), i = [];
13493
13491
  for (let e of r) e.kind === "reference" && i.push(e);
13494
- let a = i.length > 0, o = a ? i : r, s = dc({
13492
+ let a = i.length > 0, o = a ? i : r, s = oc({
13495
13493
  options: o,
13496
- bestOption: ic({ options: o }),
13494
+ bestOption: $s({ options: o }),
13497
13495
  previousContext: t,
13498
13496
  switchDistance: n
13499
- }), c = sc({
13497
+ }), c = nc({
13500
13498
  options: o,
13501
13499
  side: "before",
13502
13500
  baseOption: s
13503
- }), l = sc({
13501
+ }), l = nc({
13504
13502
  options: o,
13505
13503
  side: "after",
13506
13504
  baseOption: s
13507
- }), u = sc({
13505
+ }), u = nc({
13508
13506
  options: a ? r : o,
13509
13507
  side: "center",
13510
13508
  baseOption: s
13511
13509
  }), d = [];
13512
13510
  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);
13513
13511
  let f = [], p = /* @__PURE__ */ new Set();
13514
- for (let e of d) fc({
13512
+ for (let e of d) sc({
13515
13513
  guides: f,
13516
13514
  seenGuideKeys: p,
13517
13515
  guide: e.guide
@@ -13519,15 +13517,15 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13519
13517
  return {
13520
13518
  delta: s.delta,
13521
13519
  guides: f,
13522
- context: cc({ option: s })
13520
+ context: rc({ option: s })
13523
13521
  };
13524
- }, mc = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
13525
- let s = n - (e - r), c = Ys({
13522
+ }, lc = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
13523
+ let s = n - (e - r), c = Ws({
13526
13524
  value: s,
13527
13525
  step: o
13528
13526
  }), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
13529
13527
  for (let d = -l; d <= l; d += 1) {
13530
- let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = Ks({
13528
+ let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = Vs({
13531
13529
  firstDistance: m,
13532
13530
  secondDistance: h
13533
13531
  });
@@ -13542,13 +13540,13 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13542
13540
  });
13543
13541
  }
13544
13542
  return u;
13545
- }, hc = ({ currentGap: e, referenceGap: t }) => {
13546
- let { secondDisplayDistance: n, displayDistanceDiff: r } = Ks({
13543
+ }, uc = ({ currentGap: e, referenceGap: t }) => {
13544
+ let { secondDisplayDistance: n, displayDistanceDiff: r } = Vs({
13547
13545
  firstDistance: e,
13548
13546
  secondDistance: t
13549
13547
  });
13550
13548
  return r > 1 ? null : n;
13551
- }, gc = ({ anchors: e, positions: t, threshold: n }) => {
13549
+ }, dc = ({ anchors: e, positions: t, threshold: n }) => {
13552
13550
  let r = 0, i = n + 1, a = null;
13553
13551
  for (let o of t) for (let t of e) {
13554
13552
  let e = Math.abs(t - o);
@@ -13558,8 +13556,8 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13558
13556
  delta: r,
13559
13557
  guidePosition: a
13560
13558
  };
13561
- }, _c = ({ activeBounds: e, threshold: t, anchors: n }) => {
13562
- let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = gc({
13559
+ }, fc = ({ activeBounds: e, threshold: t, anchors: n }) => {
13560
+ let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = dc({
13563
13561
  anchors: n.vertical,
13564
13562
  positions: [
13565
13563
  r,
@@ -13567,7 +13565,7 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13567
13565
  i
13568
13566
  ],
13569
13567
  threshold: t
13570
- }), u = gc({
13568
+ }), u = dc({
13571
13569
  anchors: n.horizontal,
13572
13570
  positions: [
13573
13571
  o,
@@ -13587,11 +13585,11 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13587
13585
  deltaY: u.delta,
13588
13586
  guides: d
13589
13587
  };
13590
- }, vc = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
13588
+ }, pc = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
13591
13589
  let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
13592
13590
  for (let e of t) {
13593
13591
  let { left: t, right: n } = e;
13594
- qs({
13592
+ Hs({
13595
13593
  firstStart: t,
13596
13594
  firstEnd: n,
13597
13595
  secondStart: l,
@@ -13611,22 +13609,22 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13611
13609
  f.push({
13612
13610
  bounds: e,
13613
13611
  isActive: !0
13614
- }), Qs({
13612
+ }), qs({
13615
13613
  items: f,
13616
13614
  axis: "top"
13617
13615
  });
13618
- let p = ec({ items: f });
13616
+ let p = Ys({ items: f });
13619
13617
  if (p === -1) return {
13620
13618
  delta: 0,
13621
13619
  guides: [],
13622
13620
  context: null
13623
13621
  };
13624
- let m = [], h = c - s, g = $s({
13622
+ let m = [], h = c - s, g = Js({
13625
13623
  items: f,
13626
13624
  index: p,
13627
13625
  axis: "vertical",
13628
13626
  direction: "prev"
13629
- }), _ = $s({
13627
+ }), _ = Js({
13630
13628
  items: f,
13631
13629
  index: p,
13632
13630
  axis: "vertical",
@@ -13635,19 +13633,19 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13635
13633
  if (v && y) {
13636
13634
  let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
13637
13635
  if (a >= 0) {
13638
- let e = Ys({
13636
+ let e = Ws({
13639
13637
  value: a / 2,
13640
13638
  step: 1
13641
13639
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
13642
13640
  if (Math.max(u, d) <= n) {
13643
- let t = mc({
13641
+ let t = lc({
13644
13642
  activeStart: s,
13645
13643
  activeEnd: c,
13646
13644
  targetGap: e,
13647
13645
  beforeEdge: r,
13648
13646
  afterEdge: i,
13649
13647
  threshold: n,
13650
- step: Ws
13648
+ step: zs
13651
13649
  });
13652
13650
  if (t) {
13653
13651
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -13684,16 +13682,16 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13684
13682
  }
13685
13683
  for (let e of r) {
13686
13684
  let { axis: t, start: r, end: i, distance: a } = e;
13687
- if (!Xs({
13685
+ if (!Gs({
13688
13686
  value: a,
13689
13687
  step: .5
13690
- }) || !tc({
13688
+ }) || !Xs({
13691
13689
  patternAxis: t,
13692
13690
  activeRangeStart: l,
13693
13691
  activeRangeEnd: u,
13694
13692
  tolerance: n
13695
13693
  })) continue;
13696
- let d = nc({
13694
+ let d = Zs({
13697
13695
  patternStart: r,
13698
13696
  patternEnd: i,
13699
13697
  activeStart: s,
@@ -13701,12 +13699,12 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13701
13699
  });
13702
13700
  if (d) {
13703
13701
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
13704
- let e = Ys({
13702
+ let e = Ws({
13705
13703
  value: a - b,
13706
13704
  step: 1
13707
13705
  }), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
13708
13706
  if (u > n) continue;
13709
- let d = hc({
13707
+ let d = uc({
13710
13708
  currentGap: l,
13711
13709
  referenceGap: a
13712
13710
  });
@@ -13730,12 +13728,12 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13730
13728
  });
13731
13729
  }
13732
13730
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
13733
- let e = Ys({
13731
+ let e = Ws({
13734
13732
  value: x - a,
13735
13733
  step: 1
13736
13734
  }), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
13737
13735
  if (u > n) continue;
13738
- let d = hc({
13736
+ let d = uc({
13739
13737
  currentGap: l,
13740
13738
  referenceGap: a
13741
13739
  });
@@ -13760,16 +13758,16 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13760
13758
  }
13761
13759
  }
13762
13760
  }
13763
- return pc({
13761
+ return cc({
13764
13762
  options: m,
13765
13763
  previousContext: i,
13766
13764
  switchDistance: a
13767
13765
  });
13768
- }, yc = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
13766
+ }, mc = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
13769
13767
  let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
13770
13768
  for (let e of t) {
13771
13769
  let { top: t, bottom: n } = e;
13772
- qs({
13770
+ Hs({
13773
13771
  firstStart: t,
13774
13772
  firstEnd: n,
13775
13773
  secondStart: l,
@@ -13789,22 +13787,22 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13789
13787
  f.push({
13790
13788
  bounds: e,
13791
13789
  isActive: !0
13792
- }), Qs({
13790
+ }), qs({
13793
13791
  items: f,
13794
13792
  axis: "left"
13795
13793
  });
13796
- let p = ec({ items: f });
13794
+ let p = Ys({ items: f });
13797
13795
  if (p === -1) return {
13798
13796
  delta: 0,
13799
13797
  guides: [],
13800
13798
  context: null
13801
13799
  };
13802
- let m = [], h = c - s, g = $s({
13800
+ let m = [], h = c - s, g = Js({
13803
13801
  items: f,
13804
13802
  index: p,
13805
13803
  axis: "horizontal",
13806
13804
  direction: "prev"
13807
- }), _ = $s({
13805
+ }), _ = Js({
13808
13806
  items: f,
13809
13807
  index: p,
13810
13808
  axis: "horizontal",
@@ -13813,19 +13811,19 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13813
13811
  if (v && y) {
13814
13812
  let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
13815
13813
  if (a >= 0) {
13816
- let e = Ys({
13814
+ let e = Ws({
13817
13815
  value: a / 2,
13818
13816
  step: 1
13819
13817
  }), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
13820
13818
  if (Math.max(u, d) <= n) {
13821
- let t = mc({
13819
+ let t = lc({
13822
13820
  activeStart: s,
13823
13821
  activeEnd: c,
13824
13822
  targetGap: e,
13825
13823
  beforeEdge: r,
13826
13824
  afterEdge: i,
13827
13825
  threshold: n,
13828
- step: Ws
13826
+ step: zs
13829
13827
  });
13830
13828
  if (t) {
13831
13829
  let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
@@ -13862,16 +13860,16 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13862
13860
  }
13863
13861
  for (let e of r) {
13864
13862
  let { axis: t, start: r, end: i, distance: a } = e;
13865
- if (!Xs({
13863
+ if (!Gs({
13866
13864
  value: a,
13867
13865
  step: .5
13868
- }) || !tc({
13866
+ }) || !Xs({
13869
13867
  patternAxis: t,
13870
13868
  activeRangeStart: l,
13871
13869
  activeRangeEnd: u,
13872
13870
  tolerance: n
13873
13871
  })) continue;
13874
- let d = nc({
13872
+ let d = Zs({
13875
13873
  patternStart: r,
13876
13874
  patternEnd: i,
13877
13875
  activeStart: s,
@@ -13879,12 +13877,12 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13879
13877
  });
13880
13878
  if (d) {
13881
13879
  if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
13882
- let e = Ys({
13880
+ let e = Ws({
13883
13881
  value: a - b,
13884
13882
  step: 1
13885
13883
  }), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
13886
13884
  if (u > n) continue;
13887
- let d = hc({
13885
+ let d = uc({
13888
13886
  currentGap: l,
13889
13887
  referenceGap: a
13890
13888
  });
@@ -13908,12 +13906,12 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13908
13906
  });
13909
13907
  }
13910
13908
  if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
13911
- let e = Ys({
13909
+ let e = Ws({
13912
13910
  value: x - a,
13913
13911
  step: 1
13914
13912
  }), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
13915
13913
  if (u > n) continue;
13916
- let d = hc({
13914
+ let d = uc({
13917
13915
  currentGap: l,
13918
13916
  referenceGap: a
13919
13917
  });
@@ -13938,20 +13936,20 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13938
13936
  }
13939
13937
  }
13940
13938
  }
13941
- return pc({
13939
+ return cc({
13942
13940
  options: m,
13943
13941
  previousContext: i,
13944
13942
  switchDistance: a
13945
13943
  });
13946
- }, bc = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
13947
- let { vertical: o = null, horizontal: s = null } = i ?? {}, c = vc({
13944
+ }, hc = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
13945
+ let { vertical: o = null, horizontal: s = null } = i ?? {}, c = pc({
13948
13946
  activeBounds: e,
13949
13947
  candidates: t,
13950
13948
  threshold: n,
13951
13949
  patterns: r.vertical,
13952
13950
  previousContext: o,
13953
13951
  switchDistance: a
13954
- }), l = yc({
13952
+ }), l = mc({
13955
13953
  activeBounds: e,
13956
13954
  candidates: t,
13957
13955
  threshold: n,
@@ -13970,14 +13968,14 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13970
13968
  horizontal: l.context
13971
13969
  }
13972
13970
  };
13973
- }, xc = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
13971
+ }, gc = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
13974
13972
  let o = Math.min(a, r / 2, i / 2);
13975
13973
  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();
13976
- }, Sc = ({ 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 }) => {
13974
+ }, _c = ({ 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 }) => {
13977
13975
  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;
13978
13976
  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";
13979
13977
  let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
13980
- e.beginPath(), xc({
13978
+ e.beginPath(), gc({
13981
13979
  context: e,
13982
13980
  x: w,
13983
13981
  y: T,
@@ -13985,11 +13983,11 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13985
13983
  height: C,
13986
13984
  radius: v
13987
13985
  }), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
13988
- }, Cc = ({ context: e, guide: t, zoom: n }) => {
13989
- let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = Gs({ distance: l }).toString();
13986
+ }, vc = ({ context: e, guide: t, zoom: n }) => {
13987
+ let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = Bs({ distance: l }).toString();
13990
13988
  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();
13991
- let d = Us;
13992
- Sc({
13989
+ let d = Rs;
13990
+ _c({
13993
13991
  context: e,
13994
13992
  type: r,
13995
13993
  axis: i,
@@ -13999,7 +13997,7 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
13999
13997
  zoom: n,
14000
13998
  color: d,
14001
13999
  lineWidth: 1
14002
- }), Sc({
14000
+ }), _c({
14003
14001
  context: e,
14004
14002
  type: r,
14005
14003
  axis: i,
@@ -14010,26 +14008,26 @@ var Bs = "_templateAnchorX", Vs = "_templateAnchorY", Hs = class t {
14010
14008
  color: d,
14011
14009
  lineWidth: 1
14012
14010
  });
14013
- }, wc = .1;
14014
- function Tc({ bounds: e, snapGuard: t }) {
14011
+ }, yc = .1;
14012
+ function bc({ bounds: e, snapGuard: t }) {
14015
14013
  let { edge: n, position: r } = t;
14016
14014
  return Math.abs(n === "left" ? e.left - r : n === "right" ? e.right - r : n === "top" ? e.top - r : e.bottom - r);
14017
14015
  }
14018
- function Ec({ bounds: e, snapGuard: t }) {
14016
+ function xc({ bounds: e, snapGuard: t }) {
14019
14017
  let { edge: n, position: r } = t;
14020
- return n === "left" ? e.left >= r - wc : n === "right" ? e.right <= r + wc : n === "top" ? e.top >= r - wc : e.bottom <= r + wc;
14018
+ return n === "left" ? e.left >= r - yc : n === "right" ? e.right <= r + yc : n === "top" ? e.top >= r - yc : e.bottom <= r + yc;
14021
14019
  }
14022
- function Dc({ bounds: e, snapGuard: t }) {
14023
- return Tc({
14020
+ function Sc({ bounds: e, snapGuard: t }) {
14021
+ return bc({
14024
14022
  bounds: e,
14025
14023
  snapGuard: t
14026
- }) <= wc;
14024
+ }) <= yc;
14027
14025
  }
14028
14026
  //#endregion
14029
14027
  //#region src/editor/snapping-manager/scaling-step-snap-guards.ts
14030
- var Oc = .5, kc = 1e-6, Ac = .02, jc = 1e-6;
14031
- function Mc({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, fallbackScale: o, isUniform: s, preservePlacement: c, snapGuards: l }) {
14032
- return Nc({
14028
+ var Cc = .5, wc = 1e-6, Tc = .02, Ec = 1e-6;
14029
+ function Dc({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, fallbackScale: o, isUniform: s, preservePlacement: c, snapGuards: l }) {
14030
+ return Oc({
14033
14031
  target: e,
14034
14032
  transform: t,
14035
14033
  rawScaleX: n,
@@ -14038,13 +14036,13 @@ function Mc({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidt
14038
14036
  effectiveHeight: a,
14039
14037
  preservePlacement: c,
14040
14038
  snapGuards: l
14041
- }) || (Uc({
14039
+ }) || (Rc({
14042
14040
  target: e,
14043
14041
  rawScaleX: n,
14044
14042
  rawScaleY: r,
14045
14043
  effectiveWidth: i,
14046
14044
  effectiveHeight: a,
14047
- candidates: ul({
14045
+ candidates: al({
14048
14046
  rawScaleX: n,
14049
14047
  rawScaleY: r,
14050
14048
  effectiveWidth: i,
@@ -14052,28 +14050,28 @@ function Mc({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidt
14052
14050
  isUniform: s
14053
14051
  }),
14054
14052
  preservePlacement: c,
14055
- shouldPreferInsideCandidate: nl({
14053
+ shouldPreferInsideCandidate: Zc({
14056
14054
  target: e,
14057
14055
  snapGuards: l
14058
14056
  }),
14059
14057
  snapGuards: l
14060
14058
  }) ?? o);
14061
14059
  }
14062
- function Nc({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, preservePlacement: o, snapGuards: s }) {
14063
- return rl({
14060
+ function Oc({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, preservePlacement: o, snapGuards: s }) {
14061
+ return Qc({
14064
14062
  target: e,
14065
14063
  snapGuards: s
14066
14064
  }) ? {
14067
14065
  scaleX: n,
14068
14066
  scaleY: r
14069
- } : Fc({
14067
+ } : Ac({
14070
14068
  target: e,
14071
14069
  effectiveWidth: i,
14072
14070
  effectiveHeight: a,
14073
14071
  transform: t,
14074
14072
  preservePlacement: o,
14075
14073
  snapGuards: s
14076
- }) || Pc({
14074
+ }) || kc({
14077
14075
  target: e,
14078
14076
  rawScaleX: n,
14079
14077
  rawScaleY: r,
@@ -14083,11 +14081,11 @@ function Nc({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidt
14083
14081
  snapGuards: s
14084
14082
  });
14085
14083
  }
14086
- function Pc({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiveHeight: i, preservePlacement: a, snapGuards: o }) {
14087
- if (!il({
14084
+ function kc({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiveHeight: i, preservePlacement: a, snapGuards: o }) {
14085
+ if (!$c({
14088
14086
  target: e,
14089
14087
  snapGuards: o
14090
- }) || al({
14088
+ }) || el({
14091
14089
  target: e,
14092
14090
  snapGuards: o
14093
14091
  })) return null;
@@ -14095,13 +14093,13 @@ function Pc({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiv
14095
14093
  scaleX: t,
14096
14094
  scaleY: n
14097
14095
  };
14098
- return !Ic({
14096
+ return !jc({
14099
14097
  target: e,
14100
14098
  candidate: s,
14101
14099
  preservePlacement: a,
14102
- maxDistance: Oc,
14100
+ maxDistance: Cc,
14103
14101
  snapGuards: o
14104
- }) || !Rc({
14102
+ }) || !Nc({
14105
14103
  target: e,
14106
14104
  candidate: s,
14107
14105
  effectiveWidth: r,
@@ -14109,8 +14107,8 @@ function Pc({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiv
14109
14107
  snapGuards: o
14110
14108
  }) ? null : s;
14111
14109
  }
14112
- function Fc({ target: e, transform: t, effectiveWidth: n, effectiveHeight: r, preservePlacement: i, snapGuards: a }) {
14113
- if (!nl({
14110
+ function Ac({ target: e, transform: t, effectiveWidth: n, effectiveHeight: r, preservePlacement: i, snapGuards: a }) {
14111
+ if (!Zc({
14114
14112
  target: e,
14115
14113
  snapGuards: a
14116
14114
  })) return null;
@@ -14119,12 +14117,12 @@ function Fc({ target: e, transform: t, effectiveWidth: n, effectiveHeight: r, pr
14119
14117
  let c = {
14120
14118
  scaleX: o,
14121
14119
  scaleY: s
14122
- }, l = Ic({
14120
+ }, l = jc({
14123
14121
  target: e,
14124
14122
  candidate: c,
14125
14123
  preservePlacement: i,
14126
14124
  snapGuards: a
14127
- }), u = Lc({
14125
+ }), u = Mc({
14128
14126
  target: e,
14129
14127
  candidate: c,
14130
14128
  effectiveWidth: n,
@@ -14133,21 +14131,21 @@ function Fc({ target: e, transform: t, effectiveWidth: n, effectiveHeight: r, pr
14133
14131
  });
14134
14132
  return !l || !u ? null : c;
14135
14133
  }
14136
- function Ic({ target: e, candidate: t, preservePlacement: n, maxDistance: r = 1, snapGuards: i }) {
14137
- let a = gl({
14134
+ function jc({ target: e, candidate: t, preservePlacement: n, maxDistance: r = 1, snapGuards: i }) {
14135
+ let a = dl({
14138
14136
  target: e,
14139
14137
  candidate: t,
14140
14138
  preservePlacement: n
14141
14139
  });
14142
14140
  if (!a) return !1;
14143
- for (let e of i) if (Tc({
14141
+ for (let e of i) if (bc({
14144
14142
  bounds: a,
14145
14143
  snapGuard: e
14146
14144
  }) > r) return !1;
14147
14145
  return !0;
14148
14146
  }
14149
- function Lc({ target: e, candidate: t, effectiveWidth: n, effectiveHeight: r, snapGuards: i }) {
14150
- return zc({
14147
+ function Mc({ target: e, candidate: t, effectiveWidth: n, effectiveHeight: r, snapGuards: i }) {
14148
+ return Pc({
14151
14149
  target: e,
14152
14150
  candidate: t,
14153
14151
  effectiveWidth: n,
@@ -14156,8 +14154,8 @@ function Lc({ target: e, candidate: t, effectiveWidth: n, effectiveHeight: r, sn
14156
14154
  shouldRoundSourceLimit: !1
14157
14155
  });
14158
14156
  }
14159
- function Rc({ target: e, candidate: t, effectiveWidth: n, effectiveHeight: r, snapGuards: i }) {
14160
- return zc({
14157
+ function Nc({ target: e, candidate: t, effectiveWidth: n, effectiveHeight: r, snapGuards: i }) {
14158
+ return Pc({
14161
14159
  target: e,
14162
14160
  candidate: t,
14163
14161
  effectiveWidth: n,
@@ -14166,19 +14164,19 @@ function Rc({ target: e, candidate: t, effectiveWidth: n, effectiveHeight: r, sn
14166
14164
  shouldRoundSourceLimit: !0
14167
14165
  });
14168
14166
  }
14169
- function zc({ target: e, candidate: t, effectiveWidth: n, effectiveHeight: r, snapGuards: i, shouldRoundSourceLimit: a }) {
14167
+ function Pc({ target: e, candidate: t, effectiveWidth: n, effectiveHeight: r, snapGuards: i, shouldRoundSourceLimit: a }) {
14170
14168
  for (let o of i) {
14171
- let i = Bc({
14169
+ let i = Fc({
14172
14170
  candidate: t,
14173
14171
  effectiveWidth: n,
14174
14172
  effectiveHeight: r,
14175
14173
  snapGuard: o
14176
14174
  });
14177
- if (!(a ? Hc({
14175
+ if (!(a ? Lc({
14178
14176
  target: e,
14179
14177
  displaySize: i,
14180
14178
  snapGuard: o
14181
- }) : Qc({
14179
+ }) : qc({
14182
14180
  target: e,
14183
14181
  displaySize: i,
14184
14182
  snapGuard: o
@@ -14186,35 +14184,35 @@ function zc({ target: e, candidate: t, effectiveWidth: n, effectiveHeight: r, sn
14186
14184
  }
14187
14185
  return !0;
14188
14186
  }
14189
- function Bc({ candidate: e, effectiveWidth: t, effectiveHeight: n, snapGuard: r }) {
14187
+ function Fc({ candidate: e, effectiveWidth: t, effectiveHeight: n, snapGuard: r }) {
14190
14188
  return r.type === "vertical" ? Math.abs(e.scaleX) * t : Math.abs(e.scaleY) * n;
14191
14189
  }
14192
- function Vc({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r, snapGuard: i }) {
14190
+ function Ic({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r, snapGuard: i }) {
14193
14191
  return i.type === "vertical" ? Math.abs(e) * n : Math.abs(t) * r;
14194
14192
  }
14195
- function Hc({ target: e, displaySize: t, snapGuard: n }) {
14196
- let r = el({
14193
+ function Lc({ target: e, displaySize: t, snapGuard: n }) {
14194
+ let r = Yc({
14197
14195
  target: e,
14198
14196
  snapGuard: n
14199
14197
  });
14200
14198
  if (r === null) return !1;
14201
- let i = Math.round(r + kc);
14199
+ let i = Math.round(r + wc);
14202
14200
  return Math.round(t) <= i;
14203
14201
  }
14204
- function Uc({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiveHeight: i, candidates: a, preservePlacement: o, shouldPreferInsideCandidate: s, snapGuards: c }) {
14205
- if (!s) return Wc({
14202
+ function Rc({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiveHeight: i, candidates: a, preservePlacement: o, shouldPreferInsideCandidate: s, snapGuards: c }) {
14203
+ if (!s) return zc({
14206
14204
  target: e,
14207
14205
  candidates: a,
14208
14206
  preservePlacement: o,
14209
14207
  snapGuards: c
14210
14208
  });
14211
- let { insideCandidate: l, onGuideCandidate: u } = Gc({
14209
+ let { insideCandidate: l, onGuideCandidate: u } = Bc({
14212
14210
  target: e,
14213
14211
  candidates: a,
14214
14212
  preservePlacement: o,
14215
14213
  snapGuards: c
14216
14214
  });
14217
- return u && Jc({
14215
+ return u && Uc({
14218
14216
  target: e,
14219
14217
  candidate: u,
14220
14218
  rawScaleX: t,
@@ -14224,10 +14222,10 @@ function Uc({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiv
14224
14222
  snapGuards: c
14225
14223
  }) ? u : l || u || null;
14226
14224
  }
14227
- function Wc({ target: e, candidates: t, preservePlacement: n, snapGuards: r }) {
14225
+ function zc({ target: e, candidates: t, preservePlacement: n, snapGuards: r }) {
14228
14226
  let i = null;
14229
14227
  for (let a of t) {
14230
- let t = hl({
14228
+ let t = ul({
14231
14229
  target: e,
14232
14230
  candidate: a,
14233
14231
  preservePlacement: n,
@@ -14238,10 +14236,10 @@ function Wc({ target: e, candidates: t, preservePlacement: n, snapGuards: r }) {
14238
14236
  }
14239
14237
  return i;
14240
14238
  }
14241
- function Gc({ target: e, candidates: t, preservePlacement: n, snapGuards: r }) {
14239
+ function Bc({ target: e, candidates: t, preservePlacement: n, snapGuards: r }) {
14242
14240
  let i = t.map((t) => ({
14243
14241
  candidate: t,
14244
- snapMatch: hl({
14242
+ snapMatch: ul({
14245
14243
  target: e,
14246
14244
  candidate: t,
14247
14245
  preservePlacement: n,
@@ -14249,20 +14247,20 @@ function Gc({ target: e, candidates: t, preservePlacement: n, snapGuards: r }) {
14249
14247
  })
14250
14248
  }));
14251
14249
  return {
14252
- insideCandidate: qc({ matches: i }),
14253
- onGuideCandidate: Kc({ matches: i })
14250
+ insideCandidate: Hc({ matches: i }),
14251
+ onGuideCandidate: Vc({ matches: i })
14254
14252
  };
14255
14253
  }
14256
- function Kc({ matches: e }) {
14254
+ function Vc({ matches: e }) {
14257
14255
  return e.find((e) => e.snapMatch.state === "on-guide")?.candidate ?? null;
14258
14256
  }
14259
- function qc({ matches: e }) {
14257
+ function Hc({ matches: e }) {
14260
14258
  let t = null, n = Infinity;
14261
14259
  for (let { candidate: r, snapMatch: i } of e) i.state === "inside" && (i.distance >= n || (t = r, n = i.distance));
14262
14260
  return t;
14263
14261
  }
14264
- function Jc({ target: e, candidate: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, snapGuards: o }) {
14265
- for (let s of o) if (!Yc({
14262
+ function Uc({ target: e, candidate: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, snapGuards: o }) {
14263
+ for (let s of o) if (!Wc({
14266
14264
  target: e,
14267
14265
  candidate: t,
14268
14266
  rawScaleX: n,
@@ -14273,141 +14271,141 @@ function Jc({ target: e, candidate: t, rawScaleX: n, rawScaleY: r, effectiveWidt
14273
14271
  })) return !1;
14274
14272
  return !0;
14275
14273
  }
14276
- function Yc({ target: e, candidate: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, snapGuard: o }) {
14277
- let s = Bc({
14274
+ function Wc({ target: e, candidate: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, snapGuard: o }) {
14275
+ let s = Fc({
14278
14276
  candidate: t,
14279
14277
  effectiveWidth: i,
14280
14278
  effectiveHeight: a,
14281
14279
  snapGuard: o
14282
- }), c = Vc({
14280
+ }), c = Ic({
14283
14281
  rawScaleX: n,
14284
14282
  rawScaleY: r,
14285
14283
  effectiveWidth: i,
14286
14284
  effectiveHeight: a,
14287
14285
  snapGuard: o
14288
14286
  });
14289
- return !Xc({ displaySize: s }) || !Zc({
14287
+ return !Gc({ displaySize: s }) || !Kc({
14290
14288
  displaySize: s,
14291
14289
  rawDisplaySize: c
14292
- }) ? !1 : Qc({
14290
+ }) ? !1 : qc({
14293
14291
  target: e,
14294
14292
  displaySize: s,
14295
14293
  snapGuard: o
14296
14294
  });
14297
14295
  }
14298
- function Xc({ displaySize: e }) {
14299
- return Math.abs(e - Math.round(e)) <= kc;
14296
+ function Gc({ displaySize: e }) {
14297
+ return Math.abs(e - Math.round(e)) <= wc;
14300
14298
  }
14301
- function Zc({ displaySize: e, rawDisplaySize: t }) {
14302
- return Math.abs(e - t) <= Ac;
14299
+ function Kc({ displaySize: e, rawDisplaySize: t }) {
14300
+ return Math.abs(e - t) <= Tc;
14303
14301
  }
14304
- function Qc({ target: e, displaySize: t, snapGuard: n }) {
14305
- let r = $c({
14302
+ function qc({ target: e, displaySize: t, snapGuard: n }) {
14303
+ let r = Jc({
14306
14304
  target: e,
14307
14305
  snapGuard: n
14308
14306
  });
14309
14307
  return r === null ? !1 : Math.round(t) <= r;
14310
14308
  }
14311
- function $c({ target: e, snapGuard: t }) {
14312
- let n = el({
14309
+ function Jc({ target: e, snapGuard: t }) {
14310
+ let n = Yc({
14313
14311
  target: e,
14314
14312
  snapGuard: t
14315
14313
  });
14316
- return n === null ? null : Math.round(n + kc);
14314
+ return n === null ? null : Math.round(n + wc);
14317
14315
  }
14318
- function el({ target: e, snapGuard: t }) {
14316
+ function Yc({ target: e, snapGuard: t }) {
14319
14317
  let n = e, { cropSource: r } = n;
14320
14318
  if (!r) return null;
14321
14319
  let i = hr({ object: r });
14322
14320
  if (!i) return null;
14323
14321
  let a = t.type === "vertical" ? Math.abs(n.cropSourceScaleX ?? 1) : Math.abs(n.cropSourceScaleY ?? 1);
14324
14322
  if (!Number.isFinite(a) || a <= 0) return null;
14325
- let o = tl({
14323
+ let o = Xc({
14326
14324
  sourceBounds: i,
14327
14325
  snapGuard: t
14328
14326
  });
14329
14327
  return !Number.isFinite(o) || o <= 0 ? null : o / a;
14330
14328
  }
14331
- function tl({ sourceBounds: e, snapGuard: t }) {
14329
+ function Xc({ sourceBounds: e, snapGuard: t }) {
14332
14330
  let { edge: n, position: r } = t;
14333
14331
  return n === "left" ? e.right - r : n === "right" ? r - e.left : n === "top" ? e.bottom - r : r - e.top;
14334
14332
  }
14335
- function nl({ target: e, snapGuards: t }) {
14336
- return il({
14333
+ function Zc({ target: e, snapGuards: t }) {
14334
+ return $c({
14337
14335
  target: e,
14338
14336
  snapGuards: t
14339
- }) ? !al({
14337
+ }) ? !el({
14340
14338
  target: e,
14341
14339
  snapGuards: t
14342
14340
  }) : !1;
14343
14341
  }
14344
- function rl({ target: e, snapGuards: t }) {
14345
- if (il({
14342
+ function Qc({ target: e, snapGuards: t }) {
14343
+ if ($c({
14346
14344
  target: e,
14347
14345
  snapGuards: t
14348
14346
  })) return !1;
14349
14347
  let n = G({ object: e });
14350
14348
  if (!n) return !1;
14351
- for (let e of t) if (!Dc({
14349
+ for (let e of t) if (!Sc({
14352
14350
  bounds: n,
14353
14351
  snapGuard: e
14354
- }) || !ll({
14352
+ }) || !il({
14355
14353
  bounds: n,
14356
14354
  snapGuard: e
14357
14355
  })) return !1;
14358
14356
  return !0;
14359
14357
  }
14360
- function il({ target: e, snapGuards: t }) {
14358
+ function $c({ target: e, snapGuards: t }) {
14361
14359
  if (typeof e.getObjectDisplaySize != "function") return !1;
14362
- let n = e, r = t.some((e) => e.type === "vertical" && !cl({ scale: n.cropSourceScaleX })), i = t.some((e) => e.type === "horizontal" && !cl({ scale: n.cropSourceScaleY }));
14360
+ let n = e, r = t.some((e) => e.type === "vertical" && !rl({ scale: n.cropSourceScaleX })), i = t.some((e) => e.type === "horizontal" && !rl({ scale: n.cropSourceScaleY }));
14363
14361
  return r || i;
14364
14362
  }
14365
- function al({ target: e, snapGuards: t }) {
14363
+ function el({ target: e, snapGuards: t }) {
14366
14364
  let { cropSource: n } = e;
14367
14365
  if (!n) return !1;
14368
14366
  let r = G({ object: n });
14369
- return r ? t.some((e) => ol({
14367
+ return r ? t.some((e) => tl({
14370
14368
  snapGuard: e,
14371
14369
  sourceBounds: r
14372
14370
  })) : !1;
14373
14371
  }
14374
- function ol({ snapGuard: e, sourceBounds: t }) {
14372
+ function tl({ snapGuard: e, sourceBounds: t }) {
14375
14373
  let { edge: n, position: r } = e, i = t.bottom;
14376
- return n === "left" && (i = t.left), n === "right" && (i = t.right), n === "top" && (i = t.top), sl({
14374
+ return n === "left" && (i = t.left), n === "right" && (i = t.right), n === "top" && (i = t.top), nl({
14377
14375
  position: r,
14378
14376
  boundary: i
14379
14377
  });
14380
14378
  }
14381
- function sl({ position: e, boundary: t }) {
14382
- return Math.abs(e - t) <= wc;
14379
+ function nl({ position: e, boundary: t }) {
14380
+ return Math.abs(e - t) <= yc;
14383
14381
  }
14384
- function cl({ scale: e }) {
14385
- return Math.abs(Math.abs(e ?? 1) - 1) <= jc;
14382
+ function rl({ scale: e }) {
14383
+ return Math.abs(Math.abs(e ?? 1) - 1) <= Ec;
14386
14384
  }
14387
- function ll({ bounds: e, snapGuard: t }) {
14385
+ function il({ bounds: e, snapGuard: t }) {
14388
14386
  let n = t.type === "vertical" ? e.right - e.left : e.bottom - e.top;
14389
14387
  return !Number.isFinite(n) || n <= 0 ? !1 : Math.round(n) > 0;
14390
14388
  }
14391
- function ul({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r, isUniform: i }) {
14392
- let a = dl({
14389
+ function al({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r, isUniform: i }) {
14390
+ let a = ol({
14393
14391
  rawScale: e,
14394
14392
  effectiveSize: n
14395
- }), o = dl({
14393
+ }), o = ol({
14396
14394
  rawScale: t,
14397
14395
  effectiveSize: r
14398
14396
  });
14399
- return i ? pl({
14397
+ return i ? cl({
14400
14398
  scaleXCandidates: a,
14401
14399
  scaleYCandidates: o,
14402
14400
  rawScale: e
14403
- }) : ml({
14401
+ }) : ll({
14404
14402
  scaleXCandidates: a,
14405
14403
  scaleYCandidates: o,
14406
14404
  rawScaleX: e,
14407
14405
  rawScaleY: t
14408
14406
  });
14409
14407
  }
14410
- function dl({ rawScale: e, effectiveSize: t }) {
14408
+ function ol({ rawScale: e, effectiveSize: t }) {
14411
14409
  if (t <= 0) return [e];
14412
14410
  let n = e < 0 ? -1 : 1, r = Math.abs(e) * t, i = Math.round(r), a = Math.floor(r), o = Math.ceil(r), s = [
14413
14411
  i,
@@ -14416,18 +14414,18 @@ function dl({ rawScale: e, effectiveSize: t }) {
14416
14414
  a - 1,
14417
14415
  o + 1
14418
14416
  ], c = [];
14419
- for (let e of s) fl({
14417
+ for (let e of s) sl({
14420
14418
  candidates: c,
14421
14419
  scale: Math.max(1, e) / t * n
14422
14420
  });
14423
14421
  return c.sort((t, n) => Math.abs(t - e) - Math.abs(n - e)), c;
14424
14422
  }
14425
- function fl({ candidates: e, scale: t }) {
14423
+ function sl({ candidates: e, scale: t }) {
14426
14424
  Number.isFinite(t) && (e.includes(t) || e.push(t));
14427
14425
  }
14428
- function pl({ scaleXCandidates: e, scaleYCandidates: t, rawScale: n }) {
14426
+ function cl({ scaleXCandidates: e, scaleYCandidates: t, rawScale: n }) {
14429
14427
  let r = [...e];
14430
- for (let e of t) fl({
14428
+ for (let e of t) sl({
14431
14429
  candidates: r,
14432
14430
  scale: e
14433
14431
  });
@@ -14436,7 +14434,7 @@ function pl({ scaleXCandidates: e, scaleYCandidates: t, rawScale: n }) {
14436
14434
  scaleY: e
14437
14435
  }));
14438
14436
  }
14439
- function ml({ scaleXCandidates: e, scaleYCandidates: t, rawScaleX: n, rawScaleY: r }) {
14437
+ function ll({ scaleXCandidates: e, scaleYCandidates: t, rawScaleX: n, rawScaleY: r }) {
14440
14438
  let i = [];
14441
14439
  for (let n of e) for (let e of t) i.push({
14442
14440
  scaleX: n,
@@ -14444,13 +14442,13 @@ function ml({ scaleXCandidates: e, scaleYCandidates: t, rawScaleX: n, rawScaleY:
14444
14442
  });
14445
14443
  return i.sort((e, t) => Math.abs(e.scaleX - n) + Math.abs(e.scaleY - r) - (Math.abs(t.scaleX - n) + Math.abs(t.scaleY - r))), i;
14446
14444
  }
14447
- function hl({ target: e, candidate: t, preservePlacement: n, snapGuards: r }) {
14448
- let i = gl({
14445
+ function ul({ target: e, candidate: t, preservePlacement: n, snapGuards: r }) {
14446
+ let i = dl({
14449
14447
  target: e,
14450
14448
  candidate: t,
14451
14449
  preservePlacement: n
14452
14450
  });
14453
- return i ? _l({
14451
+ return i ? fl({
14454
14452
  bounds: i,
14455
14453
  snapGuards: r
14456
14454
  }) : {
@@ -14458,7 +14456,7 @@ function hl({ target: e, candidate: t, preservePlacement: n, snapGuards: r }) {
14458
14456
  distance: Infinity
14459
14457
  };
14460
14458
  }
14461
- function gl({ target: e, candidate: t, preservePlacement: n }) {
14459
+ function dl({ target: e, candidate: t, preservePlacement: n }) {
14462
14460
  let r = e.scaleX ?? 1, i = e.scaleY ?? 1, a = null;
14463
14461
  try {
14464
14462
  e.set({
@@ -14473,20 +14471,20 @@ function gl({ target: e, candidate: t, preservePlacement: n }) {
14473
14471
  }
14474
14472
  return a;
14475
14473
  }
14476
- function _l({ bounds: e, snapGuards: t }) {
14474
+ function fl({ bounds: e, snapGuards: t }) {
14477
14475
  let n = !0, r = 0;
14478
14476
  for (let i of t) {
14479
- if (!Ec({
14477
+ if (!xc({
14480
14478
  bounds: e,
14481
14479
  snapGuard: i
14482
14480
  })) return {
14483
14481
  state: "outside",
14484
14482
  distance: Infinity
14485
14483
  };
14486
- Dc({
14484
+ Sc({
14487
14485
  bounds: e,
14488
14486
  snapGuard: i
14489
- }) || (n = !1), r = Math.max(r, Tc({
14487
+ }) || (n = !1), r = Math.max(r, bc({
14490
14488
  bounds: e,
14491
14489
  snapGuard: i
14492
14490
  }));
@@ -14498,14 +14496,14 @@ function _l({ bounds: e, snapGuards: t }) {
14498
14496
  }
14499
14497
  //#endregion
14500
14498
  //#region src/editor/snapping-manager/pixel-grid.ts
14501
- function vl({ target: e }) {
14499
+ function pl({ target: e }) {
14502
14500
  let t = typeof e.type == "string" ? e.type.toLowerCase() : "", n = e instanceof v || t === "textbox" || t === "background-textbox";
14503
14501
  return !(e instanceof a) && !n;
14504
14502
  }
14505
- function yl({ target: e, transform: t, roundX: n = !0, roundY: r = !0 }) {
14503
+ function ml({ target: e, transform: t, roundX: n = !0, roundY: r = !0 }) {
14506
14504
  if (!n && !r) return;
14507
14505
  let { left: i = 0, top: a = 0 } = e, o = typeof t?.original?.left == "number" ? t.original.left : null, s = typeof t?.original?.top == "number" ? t.original.top : null;
14508
- bl({
14506
+ hl({
14509
14507
  target: e,
14510
14508
  left: i,
14511
14509
  top: a,
@@ -14513,18 +14511,18 @@ function yl({ target: e, transform: t, roundX: n = !0, roundY: r = !0 }) {
14513
14511
  shouldSnapY: r && (s === null || s !== a)
14514
14512
  });
14515
14513
  }
14516
- function bl({ target: e, left: t, top: n, shouldSnapX: r, shouldSnapY: i }) {
14514
+ function hl({ target: e, left: t, top: n, shouldSnapX: r, shouldSnapY: i }) {
14517
14515
  let a = Math.round(t / 1) * 1, o = Math.round(n / 1) * 1, s = {};
14518
14516
  r && a !== t && (s.left = a), i && o !== n && (s.top = o), !(!("left" in s) && !("top" in s)) && (e.set(s), e.setCoords());
14519
14517
  }
14520
- function xl({ target: e }) {
14518
+ function gl({ target: e }) {
14521
14519
  let { width: t = 0, height: n = 0, paddingTop: r = 0, paddingRight: i = 0, paddingBottom: a = 0, paddingLeft: o = 0, strokeWidth: s = 0 } = e;
14522
14520
  return {
14523
14521
  width: t + o + i + s,
14524
14522
  height: n + r + a + s
14525
14523
  };
14526
14524
  }
14527
- function Sl({ target: e, scaleX: t, scaleY: n }) {
14525
+ function _l({ target: e, scaleX: t, scaleY: n }) {
14528
14526
  let r = e.getObjectDisplaySize?.();
14529
14527
  if (!r) return null;
14530
14528
  let i = Math.abs(t), a = Math.abs(n);
@@ -14533,35 +14531,35 @@ function Sl({ target: e, scaleX: t, scaleY: n }) {
14533
14531
  height: r.height / a
14534
14532
  };
14535
14533
  }
14536
- function Cl({ target: e, scaleX: t, scaleY: n }) {
14537
- let r = Sl({
14534
+ function vl({ target: e, scaleX: t, scaleY: n }) {
14535
+ let r = _l({
14538
14536
  target: e,
14539
14537
  scaleX: t,
14540
14538
  scaleY: n
14541
14539
  });
14542
14540
  if (r) return r;
14543
- if (e instanceof v) return xl({ target: e });
14541
+ if (e instanceof v) return gl({ target: e });
14544
14542
  let { width: i = 0, height: a = 0, strokeWidth: o = 0, strokeUniform: s = !1 } = e, c = s ? 0 : o;
14545
14543
  return {
14546
14544
  width: i + c,
14547
14545
  height: a + c
14548
14546
  };
14549
14547
  }
14550
- function wl({ target: e, transform: t, preservePlacement: n, snapGuards: r = [] }) {
14551
- let { scaleX: i = 1, scaleY: a = 1 } = e, o = Tl({
14548
+ function yl({ target: e, transform: t, preservePlacement: n, snapGuards: r = [] }) {
14549
+ let { scaleX: i = 1, scaleY: a = 1 } = e, o = bl({
14552
14550
  transform: t,
14553
14551
  rawScaleX: i,
14554
14552
  rawScaleY: a
14555
14553
  });
14556
14554
  if (!o.shouldRoundScaleX && !o.shouldRoundScaleY) return;
14557
- let { width: s, height: c } = Cl({
14555
+ let { width: s, height: c } = vl({
14558
14556
  target: e,
14559
14557
  scaleX: i,
14560
14558
  scaleY: a
14561
- }), l = El({
14559
+ }), l = xl({
14562
14560
  rawScaleX: i,
14563
14561
  rawScaleY: a,
14564
- snappedScale: kl({
14562
+ snappedScale: wl({
14565
14563
  target: e,
14566
14564
  transform: t,
14567
14565
  rawScaleX: i,
@@ -14573,50 +14571,50 @@ function wl({ target: e, transform: t, preservePlacement: n, snapGuards: r = []
14573
14571
  }),
14574
14572
  roundingState: o
14575
14573
  });
14576
- l.scaleX === i && l.scaleY === a || Dl({
14574
+ l.scaleX === i && l.scaleY === a || Sl({
14577
14575
  target: e,
14578
14576
  transform: t,
14579
14577
  preservePlacement: n,
14580
14578
  scale: l
14581
14579
  });
14582
14580
  }
14583
- function Tl({ transform: e, rawScaleX: t, rawScaleY: n }) {
14581
+ function bl({ transform: e, rawScaleX: t, rawScaleY: n }) {
14584
14582
  return {
14585
- shouldRoundScaleX: Ol({
14583
+ shouldRoundScaleX: Cl({
14586
14584
  transform: e,
14587
14585
  axis: "x",
14588
14586
  rawScale: t
14589
14587
  }),
14590
- shouldRoundScaleY: Ol({
14588
+ shouldRoundScaleY: Cl({
14591
14589
  transform: e,
14592
14590
  axis: "y",
14593
14591
  rawScale: n
14594
14592
  })
14595
14593
  };
14596
14594
  }
14597
- function El({ rawScaleX: e, rawScaleY: t, snappedScale: n, roundingState: r }) {
14595
+ function xl({ rawScaleX: e, rawScaleY: t, snappedScale: n, roundingState: r }) {
14598
14596
  let i = { ...n };
14599
14597
  return r.shouldRoundScaleX || (i.scaleX = e), r.shouldRoundScaleY || (i.scaleY = t), i;
14600
14598
  }
14601
- function Dl({ target: e, transform: t, preservePlacement: n, scale: r }) {
14599
+ function Sl({ target: e, transform: t, preservePlacement: n, scale: r }) {
14602
14600
  e.set({
14603
14601
  scaleX: r.scaleX,
14604
14602
  scaleY: r.scaleY
14605
14603
  }), n && n.applyPlacement(n.placement), t && (t.scaleX = r.scaleX, t.scaleY = r.scaleY), e.setCoords();
14606
14604
  }
14607
- function Ol({ transform: e, axis: t, rawScale: n }) {
14605
+ function Cl({ transform: e, axis: t, rawScale: n }) {
14608
14606
  if (!e) return !0;
14609
14607
  let r = t === "x" ? e.original?.scaleX : e.original?.scaleY;
14610
14608
  return typeof r == "number" ? r !== n : !0;
14611
14609
  }
14612
- function kl({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, preservePlacement: o, snapGuards: s }) {
14613
- let c = Al({
14610
+ function wl({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, preservePlacement: o, snapGuards: s }) {
14611
+ let c = Tl({
14614
14612
  rawScaleX: n,
14615
14613
  rawScaleY: r,
14616
14614
  effectiveWidth: i,
14617
14615
  effectiveHeight: a
14618
14616
  });
14619
- return s.length === 0 ? c : Mc({
14617
+ return s.length === 0 ? c : Dc({
14620
14618
  target: e,
14621
14619
  transform: t,
14622
14620
  rawScaleX: n,
@@ -14629,27 +14627,27 @@ function kl({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidt
14629
14627
  snapGuards: s
14630
14628
  });
14631
14629
  }
14632
- function Al({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r }) {
14633
- return e === t ? jl({
14630
+ function Tl({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r }) {
14631
+ return e === t ? El({
14634
14632
  rawScale: e,
14635
14633
  effectiveWidth: n,
14636
14634
  effectiveHeight: r
14637
14635
  }) : {
14638
- scaleX: Ml({
14636
+ scaleX: Dl({
14639
14637
  rawScale: e,
14640
14638
  effectiveSize: n
14641
14639
  }),
14642
- scaleY: Ml({
14640
+ scaleY: Dl({
14643
14641
  rawScale: t,
14644
14642
  effectiveSize: r
14645
14643
  })
14646
14644
  };
14647
14645
  }
14648
- function jl({ rawScale: e, effectiveWidth: t, effectiveHeight: n }) {
14649
- let r = Ml({
14646
+ function El({ rawScale: e, effectiveWidth: t, effectiveHeight: n }) {
14647
+ let r = Dl({
14650
14648
  rawScale: e,
14651
14649
  effectiveSize: t
14652
- }), i = Ml({
14650
+ }), i = Dl({
14653
14651
  rawScale: e,
14654
14652
  effectiveSize: n
14655
14653
  }), a = Math.abs(r - e) <= Math.abs(i - e) ? r : i;
@@ -14658,16 +14656,16 @@ function jl({ rawScale: e, effectiveWidth: t, effectiveHeight: n }) {
14658
14656
  scaleY: a
14659
14657
  };
14660
14658
  }
14661
- function Ml({ rawScale: e, effectiveSize: t }) {
14659
+ function Dl({ rawScale: e, effectiveSize: t }) {
14662
14660
  return t <= 0 ? e : Math.max(1, Math.round(t * e)) / t;
14663
14661
  }
14664
14662
  //#endregion
14665
14663
  //#region src/editor/crop-manager/domain/crop-resize-mode.ts
14666
- var Nl = [
14664
+ var Ol = [
14667
14665
  "scale",
14668
14666
  "scaleX",
14669
14667
  "scaleY"
14670
- ], Pl = [
14668
+ ], kl = [
14671
14669
  "tl",
14672
14670
  "tr",
14673
14671
  "bl",
@@ -14677,21 +14675,21 @@ var Nl = [
14677
14675
  "mt",
14678
14676
  "mb"
14679
14677
  ];
14680
- function Fl({ target: e, shiftKey: t = !1 }) {
14678
+ function Al({ target: e, shiftKey: t = !1 }) {
14681
14679
  let n = e, r = n.cropActiveResizePreserveAspectRatio;
14682
14680
  if (typeof r == "boolean") return r;
14683
14681
  let i = n.preserveAspectRatio ?? !0;
14684
14682
  return t ? !i : i;
14685
14683
  }
14686
- function Il({ transform: e }) {
14684
+ function jl({ transform: e }) {
14687
14685
  if (!e) return !1;
14688
14686
  let { action: t, corner: n } = e;
14689
- return !!(t && Nl.includes(t) || n && Pl.includes(n));
14687
+ return !!(t && Ol.includes(t) || n && kl.includes(n));
14690
14688
  }
14691
14689
  //#endregion
14692
14690
  //#region src/editor/snapping-manager/scaling.ts
14693
- var Ll = 1e-6;
14694
- function Rl({ transform: e }) {
14691
+ var Ml = 1e-6;
14692
+ function Nl({ transform: e }) {
14695
14693
  let { corner: t = "", action: n = "" } = e, r = t === "ml" || t === "mr" || n === "scaleX", i = t === "mt" || t === "mb" || n === "scaleY", a = t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale";
14696
14694
  return {
14697
14695
  isCornerHandle: a,
@@ -14699,7 +14697,7 @@ function Rl({ transform: e }) {
14699
14697
  shouldSnapY: i || a
14700
14698
  };
14701
14699
  }
14702
- function zl({ target: e, transform: t }) {
14700
+ function Pl({ target: e, transform: t }) {
14703
14701
  let { originX: n, originY: r } = t, { originX: i = "left", originY: a = "top", scaleX: o = 1, scaleY: s = 1 } = e;
14704
14702
  return {
14705
14703
  originX: n ?? i,
@@ -14708,28 +14706,28 @@ function zl({ target: e, transform: t }) {
14708
14706
  scaleY: s
14709
14707
  };
14710
14708
  }
14711
- function Bl({ target: e, event: t, isCornerHandle: n }) {
14712
- return e.cropSource ? Fl({
14709
+ function Fl({ target: e, event: t, isCornerHandle: n }) {
14710
+ return e.cropSource ? Al({
14713
14711
  target: e,
14714
14712
  shiftKey: t.e?.shiftKey
14715
14713
  }) : n;
14716
14714
  }
14717
- function Vl({ bounds: e, corner: t, originX: n, originY: r, shouldSnapX: i, shouldSnapY: a, threshold: o, anchors: s }) {
14718
- let c = iu({
14715
+ function Il({ bounds: e, corner: t, originX: n, originY: r, shouldSnapX: i, shouldSnapY: a, threshold: o, anchors: s }) {
14716
+ let c = $l({
14719
14717
  bounds: e,
14720
14718
  corner: t,
14721
14719
  originX: n,
14722
14720
  shouldSnapX: i
14723
- }), l = au({
14721
+ }), l = eu({
14724
14722
  bounds: e,
14725
14723
  corner: t,
14726
14724
  originY: r,
14727
14725
  shouldSnapY: a
14728
- }), u = cu({
14726
+ }), u = ru({
14729
14727
  anchors: s.vertical,
14730
14728
  candidates: c,
14731
14729
  threshold: o
14732
- }), d = cu({
14730
+ }), d = ru({
14733
14731
  anchors: s.horizontal,
14734
14732
  candidates: l,
14735
14733
  threshold: o
@@ -14739,13 +14737,13 @@ function Vl({ bounds: e, corner: t, originX: n, originY: r, shouldSnapX: i, shou
14739
14737
  horizontalSnap: d
14740
14738
  };
14741
14739
  }
14742
- function Hl(e) {
14743
- return e.shouldUseUniformScaleSnap ? Wl(e) : tu(e);
14740
+ function Ll(e) {
14741
+ return e.shouldUseUniformScaleSnap ? zl(e) : Xl(e);
14744
14742
  }
14745
- function Ul({ target: e, bounds: t, originX: n, verticalAnchors: r, threshold: i }) {
14746
- let a = cu({
14743
+ function Rl({ target: e, bounds: t, originX: n, verticalAnchors: r, threshold: i }) {
14744
+ let a = ru({
14747
14745
  anchors: r,
14748
- candidates: iu({
14746
+ candidates: $l({
14749
14747
  bounds: t,
14750
14748
  originX: n,
14751
14749
  shouldSnapX: !0
@@ -14753,13 +14751,13 @@ function Ul({ target: e, bounds: t, originX: n, verticalAnchors: r, threshold: i
14753
14751
  threshold: i
14754
14752
  }), { guidePosition: o } = a;
14755
14753
  if (o === null) return null;
14756
- let s = _u({
14754
+ let s = fu({
14757
14755
  bounds: t,
14758
14756
  originX: n,
14759
14757
  snap: a
14760
14758
  });
14761
14759
  if (s === null) return null;
14762
- let c = Cu({
14760
+ let c = vu({
14763
14761
  target: e,
14764
14762
  boundsWidth: s
14765
14763
  });
@@ -14771,8 +14769,8 @@ function Ul({ target: e, bounds: t, originX: n, verticalAnchors: r, threshold: i
14771
14769
  }
14772
14770
  };
14773
14771
  }
14774
- function Wl({ target: e, bounds: t, originX: n, originY: r, scaleX: i, scaleY: a, originalScaleX: o, originalScaleY: s, verticalSnap: c, horizontalSnap: l }) {
14775
- let u = lu({
14772
+ function zl({ target: e, bounds: t, originX: n, originY: r, scaleX: i, scaleY: a, originalScaleX: o, originalScaleY: s, verticalSnap: c, horizontalSnap: l }) {
14773
+ let u = iu({
14776
14774
  bounds: t,
14777
14775
  originX: n,
14778
14776
  originY: r,
@@ -14780,7 +14778,7 @@ function Wl({ target: e, bounds: t, originX: n, originY: r, scaleX: i, scaleY: a
14780
14778
  horizontalSnap: l
14781
14779
  });
14782
14780
  if (!u) return null;
14783
- let { guide: d, scaleFactor: f, snapGuards: p } = u, m = Gl({
14781
+ let { guide: d, scaleFactor: f, snapGuards: p } = u, m = Bl({
14784
14782
  target: e,
14785
14783
  bounds: t,
14786
14784
  originX: n,
@@ -14798,17 +14796,17 @@ function Wl({ target: e, bounds: t, originX: n, originY: r, scaleX: i, scaleY: a
14798
14796
  nextScaleY: a * m
14799
14797
  };
14800
14798
  }
14801
- function Gl({ target: e, bounds: t, originX: n, originY: r, scaleX: i, scaleY: a, originalScaleX: o, originalScaleY: s, snapGuards: c }) {
14802
- if (!Kl({ target: e })) return null;
14803
- let l = ql({
14799
+ function Bl({ target: e, bounds: t, originX: n, originY: r, scaleX: i, scaleY: a, originalScaleX: o, originalScaleY: s, snapGuards: c }) {
14800
+ if (!Vl({ target: e })) return null;
14801
+ let l = Hl({
14804
14802
  scaleX: i,
14805
14803
  scaleY: a,
14806
14804
  originalScaleX: o,
14807
14805
  originalScaleY: s,
14808
14806
  snapGuards: c
14809
14807
  });
14810
- return l === null || !eu({
14811
- bounds: Yl({
14808
+ return l === null || !Yl({
14809
+ bounds: Wl({
14812
14810
  bounds: t,
14813
14811
  originX: n,
14814
14812
  originY: r,
@@ -14817,13 +14815,13 @@ function Gl({ target: e, bounds: t, originX: n, originY: r, scaleX: i, scaleY: a
14817
14815
  snapGuards: c
14818
14816
  }) ? null : l;
14819
14817
  }
14820
- function Kl({ target: e }) {
14818
+ function Vl({ target: e }) {
14821
14819
  return !!e.cropSource;
14822
14820
  }
14823
- function ql({ scaleX: e, scaleY: t, originalScaleX: n, originalScaleY: r, snapGuards: i }) {
14821
+ function Hl({ scaleX: e, scaleY: t, originalScaleX: n, originalScaleY: r, snapGuards: i }) {
14824
14822
  let a = [];
14825
14823
  for (let o of i) {
14826
- let i = Jl({
14824
+ let i = Ul({
14827
14825
  snapGuard: o,
14828
14826
  scaleX: e,
14829
14827
  scaleY: t,
@@ -14835,19 +14833,19 @@ function ql({ scaleX: e, scaleY: t, originalScaleX: n, originalScaleY: r, snapGu
14835
14833
  }
14836
14834
  let [o] = a;
14837
14835
  if (o === void 0 || !Number.isFinite(o) || o <= 0) return null;
14838
- for (let e of a) if (Math.abs(e - o) > Ll) return null;
14836
+ for (let e of a) if (Math.abs(e - o) > Ml) return null;
14839
14837
  return o;
14840
14838
  }
14841
- function Jl({ snapGuard: e, scaleX: t, scaleY: n, originalScaleX: r, originalScaleY: i }) {
14839
+ function Ul({ snapGuard: e, scaleX: t, scaleY: n, originalScaleX: r, originalScaleY: i }) {
14842
14840
  let a = e.type === "vertical" ? t : n, o = e.type === "vertical" ? r : i;
14843
- return typeof o != "number" || !Number.isFinite(o) || !Number.isFinite(a) || Math.abs(a) <= Ll ? null : o / a;
14841
+ return typeof o != "number" || !Number.isFinite(o) || !Number.isFinite(a) || Math.abs(a) <= Ml ? null : o / a;
14844
14842
  }
14845
- function Yl({ bounds: e, originX: t, originY: n, scaleFactor: r }) {
14846
- let i = Xl({
14843
+ function Wl({ bounds: e, originX: t, originY: n, scaleFactor: r }) {
14844
+ let i = Gl({
14847
14845
  bounds: e,
14848
14846
  originX: t,
14849
14847
  scaleFactor: r
14850
- }), a = Zl({
14848
+ }), a = Kl({
14851
14849
  bounds: e,
14852
14850
  originY: n,
14853
14851
  scaleFactor: r
@@ -14859,8 +14857,8 @@ function Yl({ bounds: e, originX: t, originY: n, scaleFactor: r }) {
14859
14857
  centerY: a.top + (a.bottom - a.top) / 2
14860
14858
  };
14861
14859
  }
14862
- function Xl({ bounds: e, originX: t, scaleFactor: n }) {
14863
- let { left: r, right: i, centerX: a } = e, o = (i - r) * n, s = Ql({ originX: t });
14860
+ function Gl({ bounds: e, originX: t, scaleFactor: n }) {
14861
+ let { left: r, right: i, centerX: a } = e, o = (i - r) * n, s = ql({ originX: t });
14864
14862
  return s === "right" ? {
14865
14863
  left: i - o,
14866
14864
  right: i
@@ -14872,8 +14870,8 @@ function Xl({ bounds: e, originX: t, scaleFactor: n }) {
14872
14870
  right: r + o
14873
14871
  };
14874
14872
  }
14875
- function Zl({ bounds: e, originY: t, scaleFactor: n }) {
14876
- let { top: r, bottom: i, centerY: a } = e, o = (i - r) * n, s = $l({ originY: t });
14873
+ function Kl({ bounds: e, originY: t, scaleFactor: n }) {
14874
+ let { top: r, bottom: i, centerY: a } = e, o = (i - r) * n, s = Jl({ originY: t });
14877
14875
  return s === "bottom" ? {
14878
14876
  top: i - o,
14879
14877
  bottom: i
@@ -14885,21 +14883,21 @@ function Zl({ bounds: e, originY: t, scaleFactor: n }) {
14885
14883
  bottom: r + o
14886
14884
  };
14887
14885
  }
14888
- function Ql({ originX: e }) {
14886
+ function ql({ originX: e }) {
14889
14887
  return e === "center" || e === "right" ? e : "left";
14890
14888
  }
14891
- function $l({ originY: e }) {
14889
+ function Jl({ originY: e }) {
14892
14890
  return e === "center" || e === "bottom" ? e : "top";
14893
14891
  }
14894
- function eu({ bounds: e, snapGuards: t }) {
14895
- for (let n of t) if (Tc({
14892
+ function Yl({ bounds: e, snapGuards: t }) {
14893
+ for (let n of t) if (bc({
14896
14894
  bounds: e,
14897
14895
  snapGuard: n
14898
14896
  }) > 1) return !1;
14899
14897
  return !0;
14900
14898
  }
14901
- function tu(e) {
14902
- let t = nu(e), n = ru(e);
14899
+ function Xl(e) {
14900
+ let t = Zl(e), n = Ql(e);
14903
14901
  if (!t && !n) return null;
14904
14902
  let r = [], i = [], a = null, o = null;
14905
14903
  return t && (r.push(t.guide), i.push(t.snapGuard), a = t.nextScale), n && (r.push(n.guide), i.push(n.snapGuard), o = n.nextScale), {
@@ -14909,16 +14907,16 @@ function tu(e) {
14909
14907
  nextScaleY: o
14910
14908
  };
14911
14909
  }
14912
- function nu({ target: e, bounds: t, originX: n, scaleX: r, scaleY: i, verticalSnap: a }) {
14910
+ function Zl({ target: e, bounds: t, originX: n, scaleX: r, scaleY: i, verticalSnap: a }) {
14913
14911
  let { guidePosition: o } = a;
14914
14912
  if (o === null) return null;
14915
- let s = _u({
14913
+ let s = fu({
14916
14914
  bounds: t,
14917
14915
  originX: n,
14918
14916
  snap: a
14919
14917
  });
14920
14918
  if (s === null) return null;
14921
- let { angle: c = 0 } = e, { width: l, height: u } = yu({ target: e }), d = bu({
14919
+ let { angle: c = 0 } = e, { width: l, height: u } = mu({ target: e }), d = hu({
14922
14920
  desiredWidth: s,
14923
14921
  baseWidth: l,
14924
14922
  baseHeight: u,
@@ -14926,7 +14924,7 @@ function nu({ target: e, bounds: t, originX: n, scaleX: r, scaleY: i, verticalSn
14926
14924
  angle: c
14927
14925
  });
14928
14926
  if (d === null) return null;
14929
- let f = pu({
14927
+ let f = cu({
14930
14928
  type: "vertical",
14931
14929
  snap: a
14932
14930
  });
@@ -14939,16 +14937,16 @@ function nu({ target: e, bounds: t, originX: n, scaleX: r, scaleY: i, verticalSn
14939
14937
  }
14940
14938
  } : null;
14941
14939
  }
14942
- function ru({ target: e, bounds: t, originY: n, scaleX: r, scaleY: i, horizontalSnap: a }) {
14940
+ function Ql({ target: e, bounds: t, originY: n, scaleX: r, scaleY: i, horizontalSnap: a }) {
14943
14941
  let { guidePosition: o } = a;
14944
14942
  if (o === null) return null;
14945
- let s = vu({
14943
+ let s = pu({
14946
14944
  bounds: t,
14947
14945
  originY: n,
14948
14946
  snap: a
14949
14947
  });
14950
14948
  if (s === null) return null;
14951
- let { angle: c = 0 } = e, { width: l, height: u } = yu({ target: e }), d = xu({
14949
+ let { angle: c = 0 } = e, { width: l, height: u } = mu({ target: e }), d = gu({
14952
14950
  desiredHeight: s,
14953
14951
  baseWidth: l,
14954
14952
  baseHeight: u,
@@ -14956,7 +14954,7 @@ function ru({ target: e, bounds: t, originY: n, scaleX: r, scaleY: i, horizontal
14956
14954
  angle: c
14957
14955
  });
14958
14956
  if (d === null) return null;
14959
- let f = pu({
14957
+ let f = cu({
14960
14958
  type: "horizontal",
14961
14959
  snap: a
14962
14960
  });
@@ -14969,12 +14967,12 @@ function ru({ target: e, bounds: t, originY: n, scaleX: r, scaleY: i, horizontal
14969
14967
  }
14970
14968
  } : null;
14971
14969
  }
14972
- function iu({ bounds: e, corner: t = "", originX: n, shouldSnapX: r }) {
14970
+ function $l({ bounds: e, corner: t = "", originX: n, shouldSnapX: r }) {
14973
14971
  let i = [];
14974
14972
  if (!r) return i;
14975
14973
  let { left: a, right: o } = e, s = "left";
14976
14974
  (n === "center" || n === "right") && (s = n);
14977
- let c = ou({ controlKey: t });
14975
+ let c = tu({ controlKey: t });
14978
14976
  return c && s !== "center" ? (i.push({
14979
14977
  edge: c,
14980
14978
  position: c === "left" ? a : o
@@ -14992,12 +14990,12 @@ function iu({ bounds: e, corner: t = "", originX: n, shouldSnapX: r }) {
14992
14990
  position: o
14993
14991
  })), i);
14994
14992
  }
14995
- function au({ bounds: e, corner: t = "", originY: n, shouldSnapY: r }) {
14993
+ function eu({ bounds: e, corner: t = "", originY: n, shouldSnapY: r }) {
14996
14994
  let i = [];
14997
14995
  if (!r) return i;
14998
14996
  let { top: a, bottom: o } = e, s = "top";
14999
14997
  (n === "center" || n === "bottom") && (s = n);
15000
- let c = su({ controlKey: t });
14998
+ let c = nu({ controlKey: t });
15001
14999
  return c && s !== "center" ? (i.push({
15002
15000
  edge: c,
15003
15001
  position: c === "top" ? a : o
@@ -15015,13 +15013,13 @@ function au({ bounds: e, corner: t = "", originY: n, shouldSnapY: r }) {
15015
15013
  position: o
15016
15014
  })), i);
15017
15015
  }
15018
- function ou({ controlKey: e }) {
15016
+ function tu({ controlKey: e }) {
15019
15017
  return e === "tl" || e === "bl" || e === "ml" ? "left" : e === "tr" || e === "br" || e === "mr" ? "right" : null;
15020
15018
  }
15021
- function su({ controlKey: e }) {
15019
+ function nu({ controlKey: e }) {
15022
15020
  return e === "tl" || e === "tr" || e === "mt" ? "top" : e === "bl" || e === "br" || e === "mb" ? "bottom" : null;
15023
15021
  }
15024
- function cu({ anchors: e, candidates: t, threshold: n }) {
15022
+ function ru({ anchors: e, candidates: t, threshold: n }) {
15025
15023
  let r = 0, i = n + 1, a = null, o = null;
15026
15024
  for (let s of t) {
15027
15025
  let { position: t } = s;
@@ -15036,31 +15034,31 @@ function cu({ anchors: e, candidates: t, threshold: n }) {
15036
15034
  candidate: o
15037
15035
  };
15038
15036
  }
15039
- function lu({ bounds: e, originX: t, originY: n, verticalSnap: r, horizontalSnap: i }) {
15040
- let a = mu({
15037
+ function iu({ bounds: e, originX: t, originY: n, verticalSnap: r, horizontalSnap: i }) {
15038
+ let a = lu({
15041
15039
  bounds: e,
15042
15040
  originX: t,
15043
15041
  snap: r
15044
- }), o = hu({
15042
+ }), o = uu({
15045
15043
  bounds: e,
15046
15044
  originY: n,
15047
15045
  snap: i
15048
- }), s = gu({
15046
+ }), s = du({
15049
15047
  scaleFactorX: a,
15050
15048
  scaleFactorY: o,
15051
15049
  verticalSnap: r,
15052
15050
  horizontalSnap: i
15053
15051
  }), c = null;
15054
- if (s === "x" && (c = uu({
15052
+ if (s === "x" && (c = au({
15055
15053
  type: "vertical",
15056
15054
  scaleFactor: a,
15057
15055
  snap: r
15058
- })), s === "y" && (c = uu({
15056
+ })), s === "y" && (c = au({
15059
15057
  type: "horizontal",
15060
15058
  scaleFactor: o,
15061
15059
  snap: i
15062
15060
  })), !c) return null;
15063
- let l = du({
15061
+ let l = ou({
15064
15062
  scaleFactor: c.scaleFactor,
15065
15063
  scaleFactorX: a,
15066
15064
  scaleFactorY: o,
@@ -15073,10 +15071,10 @@ function lu({ bounds: e, originX: t, originY: n, verticalSnap: r, horizontalSnap
15073
15071
  scaleFactor: c.scaleFactor
15074
15072
  };
15075
15073
  }
15076
- function uu({ type: e, scaleFactor: t, snap: n }) {
15074
+ function au({ type: e, scaleFactor: t, snap: n }) {
15077
15075
  let { guidePosition: r } = n;
15078
15076
  if (t === null || r === null) return null;
15079
- let i = pu({
15077
+ let i = cu({
15080
15078
  type: e,
15081
15079
  snap: n
15082
15080
  });
@@ -15089,15 +15087,15 @@ function uu({ type: e, scaleFactor: t, snap: n }) {
15089
15087
  }
15090
15088
  } : null;
15091
15089
  }
15092
- function du({ scaleFactor: e, scaleFactorX: t, scaleFactorY: n, verticalSnap: r, horizontalSnap: i }) {
15090
+ function ou({ scaleFactor: e, scaleFactorX: t, scaleFactorY: n, verticalSnap: r, horizontalSnap: i }) {
15093
15091
  let a = [];
15094
- return fu({
15092
+ return su({
15095
15093
  snapGuards: a,
15096
15094
  scaleFactor: e,
15097
15095
  axisScaleFactor: t,
15098
15096
  type: "vertical",
15099
15097
  snap: r
15100
- }), fu({
15098
+ }), su({
15101
15099
  snapGuards: a,
15102
15100
  scaleFactor: e,
15103
15101
  axisScaleFactor: n,
@@ -15105,15 +15103,15 @@ function du({ scaleFactor: e, scaleFactorX: t, scaleFactorY: n, verticalSnap: r,
15105
15103
  snap: i
15106
15104
  }), a;
15107
15105
  }
15108
- function fu({ snapGuards: e, scaleFactor: t, axisScaleFactor: n, type: r, snap: i }) {
15109
- if (n === null || Math.abs(n - t) > Ll) return;
15110
- let a = pu({
15106
+ function su({ snapGuards: e, scaleFactor: t, axisScaleFactor: n, type: r, snap: i }) {
15107
+ if (n === null || Math.abs(n - t) > Ml) return;
15108
+ let a = cu({
15111
15109
  type: r,
15112
15110
  snap: i
15113
15111
  });
15114
15112
  a && e.push(a);
15115
15113
  }
15116
- function pu({ type: e, snap: t }) {
15114
+ function cu({ type: e, snap: t }) {
15117
15115
  let { candidate: n, guidePosition: r } = t;
15118
15116
  return !n || r === null ? null : {
15119
15117
  type: e,
@@ -15121,10 +15119,10 @@ function pu({ type: e, snap: t }) {
15121
15119
  position: r
15122
15120
  };
15123
15121
  }
15124
- function mu({ bounds: e, originX: t, snap: n }) {
15122
+ function lu({ bounds: e, originX: t, snap: n }) {
15125
15123
  let { left: r, right: i } = e, a = i - r;
15126
15124
  if (n.guidePosition === null || a <= 0) return null;
15127
- let o = _u({
15125
+ let o = fu({
15128
15126
  bounds: e,
15129
15127
  originX: t,
15130
15128
  snap: n
@@ -15133,10 +15131,10 @@ function mu({ bounds: e, originX: t, snap: n }) {
15133
15131
  let s = o / a;
15134
15132
  return !Number.isFinite(s) || s <= 0 ? null : s;
15135
15133
  }
15136
- function hu({ bounds: e, originY: t, snap: n }) {
15134
+ function uu({ bounds: e, originY: t, snap: n }) {
15137
15135
  let { top: r, bottom: i } = e, a = i - r;
15138
15136
  if (n.guidePosition === null || a <= 0) return null;
15139
- let o = vu({
15137
+ let o = pu({
15140
15138
  bounds: e,
15141
15139
  originY: t,
15142
15140
  snap: n
@@ -15145,10 +15143,10 @@ function hu({ bounds: e, originY: t, snap: n }) {
15145
15143
  let s = o / a;
15146
15144
  return !Number.isFinite(s) || s <= 0 ? null : s;
15147
15145
  }
15148
- function gu({ scaleFactorX: e, scaleFactorY: t, verticalSnap: n, horizontalSnap: r }) {
15146
+ function du({ scaleFactorX: e, scaleFactorY: t, verticalSnap: n, horizontalSnap: r }) {
15149
15147
  return e !== null && t === null ? "x" : t !== null && e === null ? "y" : e === null || t === null ? null : Math.abs(n.delta) <= Math.abs(r.delta) ? "x" : "y";
15150
15148
  }
15151
- function _u({ bounds: e, originX: t, snap: n }) {
15149
+ function fu({ bounds: e, originX: t, snap: n }) {
15152
15150
  let { left: r, right: i, centerX: a } = e, { candidate: o, guidePosition: s } = n;
15153
15151
  if (!o || s === null) return null;
15154
15152
  let c = "left";
@@ -15156,7 +15154,7 @@ function _u({ bounds: e, originX: t, snap: n }) {
15156
15154
  let { edge: l } = o, u = null;
15157
15155
  return c !== "center" && l === "left" && (u = i - s), c !== "center" && l === "right" && (u = s - r), c === "center" && l === "left" && (u = (a - s) * 2), c === "center" && l === "right" && (u = (s - a) * 2), u === null || !Number.isFinite(u) || u <= 0 ? null : u;
15158
15156
  }
15159
- function vu({ bounds: e, originY: t, snap: n }) {
15157
+ function pu({ bounds: e, originY: t, snap: n }) {
15160
15158
  let { top: r, bottom: i, centerY: a } = e, { candidate: o, guidePosition: s } = n;
15161
15159
  if (!o || s === null) return null;
15162
15160
  let c = "top";
@@ -15164,7 +15162,7 @@ function vu({ bounds: e, originY: t, snap: n }) {
15164
15162
  let { edge: l } = o, u = null;
15165
15163
  return c !== "center" && l === "top" && (u = i - s), c !== "center" && l === "bottom" && (u = s - r), c === "center" && l === "top" && (u = (a - s) * 2), c === "center" && l === "bottom" && (u = (s - a) * 2), u === null || !Number.isFinite(u) || u <= 0 ? null : u;
15166
15164
  }
15167
- function yu({ target: e }) {
15165
+ function mu({ target: e }) {
15168
15166
  let { width: t = 0, height: n = 0 } = e, r = t, i = n;
15169
15167
  if (e instanceof v) {
15170
15168
  let { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0, strokeWidth: l = 0 } = e;
@@ -15175,38 +15173,38 @@ function yu({ target: e }) {
15175
15173
  height: i
15176
15174
  };
15177
15175
  }
15178
- function bu({ desiredWidth: e, baseWidth: t, baseHeight: n, scaleY: r, angle: i }) {
15179
- return Su({
15176
+ function hu({ desiredWidth: e, baseWidth: t, baseHeight: n, scaleY: r, angle: i }) {
15177
+ return _u({
15180
15178
  desiredSize: e,
15181
15179
  baseAxisSize: t,
15182
15180
  scaledCrossAxisSize: n * r,
15183
15181
  angle: i
15184
15182
  });
15185
15183
  }
15186
- function xu({ desiredHeight: e, baseWidth: t, baseHeight: n, scaleX: r, angle: i }) {
15187
- return Su({
15184
+ function gu({ desiredHeight: e, baseWidth: t, baseHeight: n, scaleX: r, angle: i }) {
15185
+ return _u({
15188
15186
  desiredSize: e,
15189
15187
  baseAxisSize: n,
15190
15188
  scaledCrossAxisSize: t * r,
15191
15189
  angle: i
15192
15190
  });
15193
15191
  }
15194
- function Su({ desiredSize: e, baseAxisSize: t, scaledCrossAxisSize: n, angle: r }) {
15192
+ function _u({ desiredSize: e, baseAxisSize: t, scaledCrossAxisSize: n, angle: r }) {
15195
15193
  let i = r * Math.PI / 180, a = Math.abs(Math.cos(i)), o = Math.abs(Math.sin(i)), s = t * a, c = n * o;
15196
15194
  if (s <= 0) return null;
15197
15195
  let l = (e - c) / s;
15198
15196
  return !Number.isFinite(l) || l <= 0 ? null : l;
15199
15197
  }
15200
- function Cu({ target: e, boundsWidth: t }) {
15198
+ function vu({ target: e, boundsWidth: t }) {
15201
15199
  let { paddingLeft: n = 0, paddingRight: r = 0, strokeWidth: i = 0 } = e, a = t - n - r - i;
15202
15200
  return !Number.isFinite(a) || a <= 0 ? null : Math.max(1, Math.round(a));
15203
15201
  }
15204
15202
  //#endregion
15205
15203
  //#region src/editor/snapping-manager/utils.ts
15206
- var wu = ({ anchors: e, bounds: t }) => {
15204
+ var yu = ({ anchors: e, bounds: t }) => {
15207
15205
  let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
15208
15206
  e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
15209
- }, Tu = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
15207
+ }, bu = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
15210
15208
  let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
15211
15209
  for (let e = 0; e < s.length; e += 1) {
15212
15210
  let c = s[e], l = null, u = Infinity;
@@ -15227,33 +15225,33 @@ var wu = ({ anchors: e, bounds: t }) => {
15227
15225
  });
15228
15226
  }
15229
15227
  return i;
15230
- }, Eu = ({ bounds: e }) => ({
15231
- vertical: Tu({
15228
+ }, xu = ({ bounds: e }) => ({
15229
+ vertical: bu({
15232
15230
  bounds: e,
15233
15231
  type: "vertical",
15234
15232
  primaryStart: "top",
15235
15233
  primaryEnd: "bottom"
15236
15234
  }),
15237
- horizontal: Tu({
15235
+ horizontal: bu({
15238
15236
  bounds: e,
15239
15237
  type: "horizontal",
15240
15238
  primaryStart: "left",
15241
15239
  primaryEnd: "right"
15242
15240
  })
15243
- }), Du = [
15241
+ }), Su = [
15244
15242
  "montage-area",
15245
15243
  "background",
15246
15244
  "interaction-blocker"
15247
- ], Ou = ({ activeObject: t }) => {
15245
+ ], Cu = ({ activeObject: t }) => {
15248
15246
  let n = /* @__PURE__ */ new Set();
15249
15247
  return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
15250
- }, ku = ({ object: e, excluded: t, ignoredIds: n = Du }) => {
15248
+ }, wu = ({ object: e, excluded: t, ignoredIds: n = Su }) => {
15251
15249
  if (t.has(e)) return !0;
15252
15250
  let { visible: r = !0 } = e;
15253
15251
  if (!r) return !0;
15254
15252
  let { id: i } = e;
15255
15253
  return !!(i && n.includes(i));
15256
- }, Au = class {
15254
+ }, Tu = class {
15257
15255
  constructor({ editor: e }) {
15258
15256
  this.anchors = {
15259
15257
  vertical: [],
@@ -15297,7 +15295,7 @@ var wu = ({ anchors: e, bounds: t }) => {
15297
15295
  target: t,
15298
15296
  event: e
15299
15297
  })) return;
15300
- yl({
15298
+ ml({
15301
15299
  target: t,
15302
15300
  transform: n
15303
15301
  }), !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: t });
@@ -15306,7 +15304,7 @@ var wu = ({ anchors: e, bounds: t }) => {
15306
15304
  this._clearSpacingContexts(), this._clearGuides();
15307
15305
  return;
15308
15306
  }
15309
- let i = 5 / (this.canvas.getZoom() || 1), a = _c({
15307
+ let i = 5 / (this.canvas.getZoom() || 1), a = fc({
15310
15308
  activeBounds: r,
15311
15309
  threshold: i,
15312
15310
  anchors: this.anchors
@@ -15329,7 +15327,7 @@ var wu = ({ anchors: e, bounds: t }) => {
15329
15327
  activeBounds: r,
15330
15328
  deltaX: l.deltaX,
15331
15329
  deltaY: l.deltaY
15332
- }), u || yl({
15330
+ }), u || ml({
15333
15331
  target: t,
15334
15332
  transform: n,
15335
15333
  roundX: !o,
@@ -15351,7 +15349,7 @@ var wu = ({ anchors: e, bounds: t }) => {
15351
15349
  _resolveObjectScalingTargetContext({ event: e }) {
15352
15350
  let { target: t, transform: n } = e;
15353
15351
  if (!t || !n) return this._clearGuides(), null;
15354
- let r = vl({ target: t });
15352
+ let r = pl({ target: t });
15355
15353
  if (this._shouldAbortObjectScaling({
15356
15354
  target: t,
15357
15355
  transform: n,
@@ -15361,7 +15359,7 @@ var wu = ({ anchors: e, bounds: t }) => {
15361
15359
  target: t,
15362
15360
  transform: n
15363
15361
  })) return this._clearGuides(), null;
15364
- let { shouldSnapX: i, shouldSnapY: a, isCornerHandle: o } = Rl({ transform: n });
15362
+ let { shouldSnapX: i, shouldSnapY: a, isCornerHandle: o } = Nl({ transform: n });
15365
15363
  if (!i && !a) return this._finishObjectScalingWithoutSnap({
15366
15364
  target: t,
15367
15365
  transform: n,
@@ -15385,10 +15383,10 @@ var wu = ({ anchors: e, bounds: t }) => {
15385
15383
  transform: r,
15386
15384
  canApplyPixelScalingStep: i
15387
15385
  }), null;
15388
- let l = 5 / (this.canvas.getZoom() || 1), { originX: u, originY: d, scaleX: f, scaleY: p } = zl({
15386
+ let l = 5 / (this.canvas.getZoom() || 1), { originX: u, originY: d, scaleX: f, scaleY: p } = Pl({
15389
15387
  target: n,
15390
15388
  transform: r
15391
- }), m = Vl({
15389
+ }), m = Il({
15392
15390
  bounds: c,
15393
15391
  corner: r.corner,
15394
15392
  originX: u,
@@ -15403,11 +15401,11 @@ var wu = ({ anchors: e, bounds: t }) => {
15403
15401
  transform: r,
15404
15402
  canApplyPixelScalingStep: i
15405
15403
  }), null;
15406
- let h = Bl({
15404
+ let h = Fl({
15407
15405
  target: n,
15408
15406
  event: t,
15409
15407
  isCornerHandle: a
15410
- }), g = Hl({
15408
+ }), g = Ll({
15411
15409
  target: n,
15412
15410
  bounds: c,
15413
15411
  originX: u,
@@ -15460,7 +15458,7 @@ var wu = ({ anchors: e, bounds: t }) => {
15460
15458
  });
15461
15459
  }
15462
15460
  _applyObjectScalingPixelStep({ target: e, transform: t, originX: n, originY: r, snapGuards: i }) {
15463
- wl({
15461
+ yl({
15464
15462
  target: e,
15465
15463
  transform: t,
15466
15464
  preservePlacement: {
@@ -15486,13 +15484,13 @@ var wu = ({ anchors: e, bounds: t }) => {
15486
15484
  });
15487
15485
  }
15488
15486
  _shouldAbortObjectScaling({ target: e, transform: t, event: n, canApplyPixelScalingStep: r }) {
15489
- return n.e?.ctrlKey ? (this._clearGuides(), r && wl({
15487
+ return n.e?.ctrlKey ? (this._clearGuides(), r && yl({
15490
15488
  target: e,
15491
15489
  transform: t
15492
15490
  }), !0) : !1;
15493
15491
  }
15494
15492
  _finishObjectScalingWithoutSnap({ target: e, transform: t, canApplyPixelScalingStep: n }) {
15495
- n && wl({
15493
+ n && yl({
15496
15494
  target: e,
15497
15495
  transform: t
15498
15496
  }), this._clearGuides();
@@ -15513,7 +15511,7 @@ var wu = ({ anchors: e, bounds: t }) => {
15513
15511
  }), e.setCoords(), G({ object: e }) ?? t;
15514
15512
  }
15515
15513
  _calculateSpacingResult({ activeBounds: e, candidateBounds: t, threshold: n }) {
15516
- return bc({
15514
+ return hc({
15517
15515
  activeBounds: e,
15518
15516
  candidates: t,
15519
15517
  threshold: this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / (this.canvas.getZoom() || 1) : n,
@@ -15523,11 +15521,11 @@ var wu = ({ anchors: e, bounds: t }) => {
15523
15521
  });
15524
15522
  }
15525
15523
  _applyMovementVisualGuides({ activeBounds: e, candidateBounds: t, threshold: n }) {
15526
- let r = _c({
15524
+ let r = fc({
15527
15525
  activeBounds: e,
15528
15526
  threshold: n,
15529
15527
  anchors: this.anchors
15530
- }), i = bc({
15528
+ }), i = hc({
15531
15529
  activeBounds: e,
15532
15530
  candidates: t,
15533
15531
  threshold: n,
@@ -15577,7 +15575,7 @@ var wu = ({ anchors: e, bounds: t }) => {
15577
15575
  this._clearGuides();
15578
15576
  return;
15579
15577
  }
15580
- let { canvas: c } = this, l = 5 / (c.getZoom() || 1), { originX: u, originY: d } = t, { originX: f = "left", originY: p = "top" } = e, m = u ?? f, h = d ?? p, g = Ul({
15578
+ let { canvas: c } = this, l = 5 / (c.getZoom() || 1), { originX: u, originY: d } = t, { originX: f = "left", originY: p = "top" } = e, m = u ?? f, h = d ?? p, g = Rl({
15581
15579
  target: e,
15582
15580
  bounds: s,
15583
15581
  originX: m,
@@ -15617,9 +15615,9 @@ var wu = ({ anchors: e, bounds: t }) => {
15617
15615
  let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
15618
15616
  if (!n) return;
15619
15617
  let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
15620
- n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = Us, n.setLineDash([4, 4]);
15618
+ n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = Rs, n.setLineDash([4, 4]);
15621
15619
  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();
15622
- for (let e of this.activeSpacingGuides) Cc({
15620
+ for (let e of this.activeSpacingGuides) vc({
15623
15621
  context: n,
15624
15622
  guide: e,
15625
15623
  zoom: c
@@ -15661,14 +15659,14 @@ var wu = ({ anchors: e, bounds: t }) => {
15661
15659
  object: i,
15662
15660
  activeObject: e
15663
15661
  });
15664
- t && (wu({
15662
+ t && (yu({
15665
15663
  anchors: n,
15666
15664
  bounds: t
15667
15665
  }), r.push(t));
15668
15666
  }
15669
15667
  let { montageArea: i } = this.editor, a = G({ object: i });
15670
15668
  if (a) {
15671
- wu({
15669
+ yu({
15672
15670
  anchors: n,
15673
15671
  bounds: a
15674
15672
  });
@@ -15680,12 +15678,12 @@ var wu = ({ anchors: e, bounds: t }) => {
15680
15678
  bottom: i
15681
15679
  };
15682
15680
  } else this.guideBounds = this._calculateViewportBounds();
15683
- this.anchors = n, this.spacingPatterns = Eu({ bounds: r }), this.cachedTargetBounds = r;
15681
+ this.anchors = n, this.spacingPatterns = xu({ bounds: r }), this.cachedTargetBounds = r;
15684
15682
  }
15685
15683
  _collectTargets({ activeObject: e }) {
15686
- let t = Ou({ activeObject: e }), n = [];
15684
+ let t = Cu({ activeObject: e }), n = [];
15687
15685
  return this.canvas.forEachObject((e) => {
15688
- ku({
15686
+ wu({
15689
15687
  object: e,
15690
15688
  excluded: t
15691
15689
  }) || n.push(e);
@@ -15720,7 +15718,7 @@ var wu = ({ anchors: e, bounds: t }) => {
15720
15718
  bottom: (r - s) / a
15721
15719
  };
15722
15720
  }
15723
- }, ju = "#3D8BF4", Mu = class e {
15721
+ }, Eu = "#3D8BF4", Du = class e {
15724
15722
  constructor({ editor: e }) {
15725
15723
  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();
15726
15724
  }
@@ -15813,8 +15811,8 @@ var wu = ({ anchors: e, bounds: t }) => {
15813
15811
  this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
15814
15812
  }
15815
15813
  static _resolveTarget({ event: e, activeObject: t }) {
15816
- let { target: n } = e, r = Ou({ activeObject: t });
15817
- return n && !ku({
15814
+ let { target: n } = e, r = Cu({ activeObject: t });
15815
+ return n && !wu({
15818
15816
  object: n,
15819
15817
  excluded: r
15820
15818
  }) ? n : null;
@@ -15931,18 +15929,18 @@ var wu = ({ anchors: e, bounds: t }) => {
15931
15929
  let { canvas: e } = this, t = e.getSelectionContext();
15932
15930
  if (!t) return;
15933
15931
  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;
15934
- t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = ju, t.setLineDash([]);
15932
+ t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Eu, t.setLineDash([]);
15935
15933
  for (let e of this.activeGuides) {
15936
15934
  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;
15937
- t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Sc({
15935
+ t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), _c({
15938
15936
  context: t,
15939
15937
  type: n,
15940
15938
  axis: i,
15941
15939
  start: a,
15942
15940
  end: c,
15943
- text: Gs({ distance: l }).toString(),
15941
+ text: Bs({ distance: l }).toString(),
15944
15942
  zoom: r,
15945
- color: ju,
15943
+ color: Eu,
15946
15944
  lineWidth: 1,
15947
15945
  offsetAlongAxis: d,
15948
15946
  offsetPerpendicular: 0
@@ -15960,13 +15958,13 @@ var wu = ({ anchors: e, bounds: t }) => {
15960
15958
  let { toolbar: e } = this.editor;
15961
15959
  e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
15962
15960
  }
15963
- }, Nu = 16, Pu = 16, Fu = bn, Iu = xn, Lu = Nu;
15964
- function Ru({ sourceSize: e, size: t, aspectRatio: n, allowOverflow: r }) {
15965
- return t ? Gu({
15961
+ }, Ou = 16, ku = 16, Au = bn, ju = xn, Mu = Ou;
15962
+ function Nu({ sourceSize: e, size: t, aspectRatio: n, allowOverflow: r }) {
15963
+ return t ? Bu({
15966
15964
  size: t,
15967
15965
  sourceSize: e,
15968
15966
  allowOverflow: r
15969
- }) : n ? Wu({
15967
+ }) : n ? zu({
15970
15968
  aspectRatio: n,
15971
15969
  sourceSize: e
15972
15970
  }) : {
@@ -15980,29 +15978,29 @@ function Z({ source: e }) {
15980
15978
  height: e.height
15981
15979
  };
15982
15980
  }
15983
- function zu({ source: e, frame: t }) {
15981
+ function Pu({ source: e, frame: t }) {
15984
15982
  let n = e.calcTransformMatrix(), r = w.invertTransform(n), i = t.calcTransformMatrix();
15985
- return Hu({ points: Uu({ frame: t }).map((e) => e.transform(i).transform(r)) });
15983
+ return Lu({ points: Ru({ frame: t }).map((e) => e.transform(i).transform(r)) });
15986
15984
  }
15987
- function Bu({ source: e, frame: t }) {
15988
- Ku({
15985
+ function Fu({ source: e, frame: t }) {
15986
+ Vu({
15989
15987
  source: e,
15990
15988
  frame: t
15991
- }), Ju({
15989
+ }), Uu({
15992
15990
  source: e,
15993
15991
  frame: t
15994
15992
  });
15995
15993
  }
15996
- function Vu({ source: e, frame: t }) {
15997
- qu({
15994
+ function Iu({ source: e, frame: t }) {
15995
+ Hu({
15998
15996
  source: e,
15999
15997
  frame: t
16000
- }), Ju({
15998
+ }), Uu({
16001
15999
  source: e,
16002
16000
  frame: t
16003
16001
  });
16004
16002
  }
16005
- function Hu({ points: e }) {
16003
+ function Lu({ points: e }) {
16006
16004
  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));
16007
16005
  return {
16008
16006
  left: t,
@@ -16011,7 +16009,7 @@ function Hu({ points: e }) {
16011
16009
  height: i - n
16012
16010
  };
16013
16011
  }
16014
- function Uu({ frame: e }) {
16012
+ function Ru({ frame: e }) {
16015
16013
  let t = e.width / 2, n = e.height / 2;
16016
16014
  return [
16017
16015
  new m(-t, -n),
@@ -16020,7 +16018,7 @@ function Uu({ frame: e }) {
16020
16018
  new m(-t, n)
16021
16019
  ];
16022
16020
  }
16023
- function Wu({ sourceSize: e, aspectRatio: t }) {
16021
+ function zu({ sourceSize: e, aspectRatio: t }) {
16024
16022
  let n = e.width / e.height, r = t.width / t.height;
16025
16023
  return r >= n ? {
16026
16024
  width: e.width,
@@ -16030,49 +16028,49 @@ function Wu({ sourceSize: e, aspectRatio: t }) {
16030
16028
  height: e.height
16031
16029
  };
16032
16030
  }
16033
- function Gu({ size: e, sourceSize: t, allowOverflow: n }) {
16034
- let r = n ? Fu : Math.min(t.width, Fu), i = n ? Iu : Math.min(t.height, Iu);
16031
+ function Bu({ size: e, sourceSize: t, allowOverflow: n }) {
16032
+ let r = n ? Au : Math.min(t.width, Au), i = n ? ju : Math.min(t.height, ju);
16035
16033
  return {
16036
- width: Qu({
16034
+ width: qu({
16037
16035
  value: e.width,
16038
- min: Nu,
16036
+ min: Ou,
16039
16037
  max: r
16040
16038
  }),
16041
- height: Qu({
16039
+ height: qu({
16042
16040
  value: e.height,
16043
- min: Pu,
16041
+ min: ku,
16044
16042
  max: i
16045
16043
  })
16046
16044
  };
16047
16045
  }
16048
- function Ku({ source: e, frame: t }) {
16049
- let n = zu({
16046
+ function Vu({ source: e, frame: t }) {
16047
+ let n = Pu({
16050
16048
  source: e,
16051
16049
  frame: t
16052
- }), r = Z({ source: e }), i = r.width / Math.max(n.width, Nu), a = r.height / Math.max(n.height, Pu);
16050
+ }), r = Z({ source: e }), i = r.width / Math.max(n.width, Ou), a = r.height / Math.max(n.height, ku);
16053
16051
  i < 1 && t.set({ scaleX: (t.scaleX ?? 1) * i }), a < 1 && t.set({ scaleY: (t.scaleY ?? 1) * a }), t.setCoords();
16054
16052
  }
16055
- function qu({ source: e, frame: t }) {
16056
- let n = zu({
16053
+ function Hu({ source: e, frame: t }) {
16054
+ let n = Pu({
16057
16055
  source: e,
16058
16056
  frame: t
16059
- }), r = Z({ source: e }), i = r.width / Math.max(n.width, Nu), a = r.height / Math.max(n.height, Pu), o = Math.min(i, a);
16057
+ }), r = Z({ source: e }), i = r.width / Math.max(n.width, Ou), a = r.height / Math.max(n.height, ku), o = Math.min(i, a);
16060
16058
  o < 1 && t.set({
16061
16059
  scaleX: (t.scaleX ?? 1) * o,
16062
16060
  scaleY: (t.scaleY ?? 1) * o
16063
16061
  }), t.setCoords();
16064
16062
  }
16065
- function Ju({ source: e, frame: t }) {
16066
- let n = zu({
16063
+ function Uu({ source: e, frame: t }) {
16064
+ let n = Pu({
16067
16065
  source: e,
16068
16066
  frame: t
16069
- }), r = Yu({ sourceSize: Z({ source: e }) }), i = Xu({ rect: n }), a = Zu({
16067
+ }), r = Wu({ sourceSize: Z({ source: e }) }), i = Gu({ rect: n }), a = Ku({
16070
16068
  rect: n,
16071
16069
  sourceBounds: r
16072
16070
  }), o = new m(i.x + a.x, i.y + a.y).transform(e.calcTransformMatrix());
16073
16071
  t.setPositionByOrigin(o, "center", "center"), t.setCoords();
16074
16072
  }
16075
- function Yu({ sourceSize: e }) {
16073
+ function Wu({ sourceSize: e }) {
16076
16074
  return {
16077
16075
  left: -e.width / 2,
16078
16076
  top: -e.height / 2,
@@ -16080,68 +16078,68 @@ function Yu({ sourceSize: e }) {
16080
16078
  height: e.height
16081
16079
  };
16082
16080
  }
16083
- function Xu({ rect: e }) {
16081
+ function Gu({ rect: e }) {
16084
16082
  return new m(e.left + e.width / 2, e.top + e.height / 2);
16085
16083
  }
16086
- function Zu({ rect: e, sourceBounds: t }) {
16084
+ function Ku({ rect: e, sourceBounds: t }) {
16087
16085
  let n = t.left + t.width, r = t.top + t.height, i = 0, a = 0;
16088
16086
  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);
16089
16087
  }
16090
- function Qu({ value: e, min: t, max: n }) {
16088
+ function qu({ value: e, min: t, max: n }) {
16091
16089
  return Math.max(t, Math.min(n, e));
16092
16090
  }
16093
16091
  //#endregion
16094
16092
  //#region src/editor/crop-manager/domain/crop-source-scale.ts
16095
- var $u = 1, ed = 1e-9;
16096
- function td({ sourceSize: e, startRect: t, anchorX: n, anchorY: r }) {
16093
+ var Ju = 1, Yu = 1e-9;
16094
+ function Xu({ sourceSize: e, startRect: t, anchorX: n, anchorY: r }) {
16097
16095
  let i = Math.max(1, t.width), a = Math.max(1, t.height);
16098
- if (ld({
16096
+ if (id({
16099
16097
  sourceSize: e,
16100
16098
  rect: t,
16101
16099
  axis: "x"
16102
- }) || ld({
16100
+ }) || id({
16103
16101
  sourceSize: e,
16104
16102
  rect: t,
16105
16103
  axis: "y"
16106
16104
  })) return 1;
16107
- let o = fd({
16105
+ let o = sd({
16108
16106
  sourceSize: e,
16109
16107
  rect: t,
16110
16108
  axis: "x",
16111
16109
  anchor: n
16112
- }), s = fd({
16110
+ }), s = sd({
16113
16111
  sourceSize: e,
16114
16112
  rect: t,
16115
16113
  axis: "y",
16116
16114
  anchor: r
16117
16115
  }), c = Math.min(o / i, s / a), l = Math.min(e.width / i, e.height / a), u = Math.min(c, l);
16118
- return (u - 1) * Math.min(i, a) <= $u ? 1 : Math.max(1, u);
16116
+ return (u - 1) * Math.min(i, a) <= Ju ? 1 : Math.max(1, u);
16119
16117
  }
16120
- function nd({ sourceSize: e, startRect: t, anchorX: n, anchorY: r }) {
16118
+ function Zu({ sourceSize: e, startRect: t, anchorX: n, anchorY: r }) {
16121
16119
  let i = Math.max(1, t.width), a = Math.max(1, t.height);
16122
- if (ld({
16120
+ if (id({
16123
16121
  sourceSize: e,
16124
16122
  rect: t,
16125
16123
  axis: "x"
16126
- }) || ld({
16124
+ }) || id({
16127
16125
  sourceSize: e,
16128
16126
  rect: t,
16129
16127
  axis: "y"
16130
16128
  })) return null;
16131
- let o = id({
16129
+ let o = $u({
16132
16130
  sourceSize: e,
16133
16131
  startRect: t,
16134
16132
  axis: "x",
16135
16133
  anchor: n
16136
- }), s = id({
16134
+ }), s = $u({
16137
16135
  sourceSize: e,
16138
16136
  startRect: t,
16139
16137
  axis: "y",
16140
16138
  anchor: r
16141
16139
  }), c = Math.max(1, Math.min(o.scale, s.scale));
16142
- return (c - 1) * Math.min(i, a) <= $u ? null : {
16140
+ return (c - 1) * Math.min(i, a) <= Ju ? null : {
16143
16141
  scale: c,
16144
- rect: ad({
16142
+ rect: ed({
16145
16143
  sourceSize: e,
16146
16144
  startRect: t,
16147
16145
  anchorX: n,
@@ -16152,35 +16150,35 @@ function nd({ sourceSize: e, startRect: t, anchorX: n, anchorY: r }) {
16152
16150
  })
16153
16151
  };
16154
16152
  }
16155
- function rd({ sourceSize: e, startRect: t, axis: n, anchor: r }) {
16156
- let i = Math.max(1, dd({
16153
+ function Qu({ sourceSize: e, startRect: t, axis: n, anchor: r }) {
16154
+ let i = Math.max(1, od({
16157
16155
  rect: t,
16158
16156
  axis: n
16159
16157
  }));
16160
- if (ld({
16158
+ if (id({
16161
16159
  sourceSize: e,
16162
16160
  rect: t,
16163
16161
  axis: n
16164
16162
  })) return 1;
16165
- let a = fd({
16163
+ let a = sd({
16166
16164
  sourceSize: e,
16167
16165
  rect: t,
16168
16166
  axis: n,
16169
16167
  anchor: r
16170
- }), o = ud({
16168
+ }), o = ad({
16171
16169
  sourceSize: e,
16172
16170
  axis: n
16173
16171
  }), s = Math.min(a, o) / i;
16174
- return (s - 1) * i <= $u ? 1 : Math.max(1, s);
16172
+ return (s - 1) * i <= Ju ? 1 : Math.max(1, s);
16175
16173
  }
16176
- function id({ sourceSize: e, startRect: t, axis: n, anchor: r }) {
16177
- let i = ud({
16174
+ function $u({ sourceSize: e, startRect: t, axis: n, anchor: r }) {
16175
+ let i = ad({
16178
16176
  sourceSize: e,
16179
16177
  axis: n
16180
- }), a = Math.max(1, dd({
16178
+ }), a = Math.max(1, od({
16181
16179
  rect: t,
16182
16180
  axis: n
16183
- })), o = fd({
16181
+ })), o = sd({
16184
16182
  sourceSize: e,
16185
16183
  rect: t,
16186
16184
  axis: n,
@@ -16191,27 +16189,27 @@ function id({ sourceSize: e, startRect: t, axis: n, anchor: r }) {
16191
16189
  scale: s / a
16192
16190
  };
16193
16191
  }
16194
- function ad({ sourceSize: e, startRect: t, anchorX: n, anchorY: r, widthLimit: i, heightLimit: a, scale: o }) {
16192
+ function ed({ sourceSize: e, startRect: t, anchorX: n, anchorY: r, widthLimit: i, heightLimit: a, scale: o }) {
16195
16193
  let s = t.width * o, c = t.height * o;
16196
16194
  return {
16197
- left: od({
16195
+ left: td({
16198
16196
  sourceSize: e,
16199
16197
  startRect: t,
16200
16198
  axis: "x",
16201
16199
  anchor: n,
16202
16200
  nextLength: s,
16203
- shouldSnapToSource: sd({
16201
+ shouldSnapToSource: nd({
16204
16202
  scale: o,
16205
16203
  limit: i.scale
16206
16204
  })
16207
16205
  }),
16208
- top: od({
16206
+ top: td({
16209
16207
  sourceSize: e,
16210
16208
  startRect: t,
16211
16209
  axis: "y",
16212
16210
  anchor: r,
16213
16211
  nextLength: c,
16214
- shouldSnapToSource: sd({
16212
+ shouldSnapToSource: nd({
16215
16213
  scale: o,
16216
16214
  limit: a.scale
16217
16215
  })
@@ -16220,59 +16218,59 @@ function ad({ sourceSize: e, startRect: t, anchorX: n, anchorY: r, widthLimit: i
16220
16218
  height: c
16221
16219
  };
16222
16220
  }
16223
- function od({ sourceSize: e, startRect: t, axis: n, anchor: r, nextLength: i, shouldSnapToSource: a }) {
16224
- let o = ud({
16221
+ function td({ sourceSize: e, startRect: t, axis: n, anchor: r, nextLength: i, shouldSnapToSource: a }) {
16222
+ let o = ad({
16225
16223
  sourceSize: e,
16226
16224
  axis: n
16227
- }), s = -o / 2, c = o / 2, l = n === "x" ? t.left : t.top, u = dd({
16225
+ }), s = -o / 2, c = o / 2, l = n === "x" ? t.left : t.top, u = od({
16228
16226
  rect: t,
16229
16227
  axis: n
16230
16228
  });
16231
- return a ? r === "min" ? c - i : r === "max" ? s : s + (o - i) / 2 : cd({
16229
+ return a ? r === "min" ? c - i : r === "max" ? s : s + (o - i) / 2 : rd({
16232
16230
  start: l,
16233
16231
  length: u,
16234
16232
  nextLength: i,
16235
16233
  anchor: r
16236
16234
  });
16237
16235
  }
16238
- function sd({ scale: e, limit: t }) {
16239
- return Math.abs(e - t) <= ed;
16236
+ function nd({ scale: e, limit: t }) {
16237
+ return Math.abs(e - t) <= Yu;
16240
16238
  }
16241
- function cd({ start: e, length: t, nextLength: n, anchor: r }) {
16239
+ function rd({ start: e, length: t, nextLength: n, anchor: r }) {
16242
16240
  return r === "min" ? e : r === "max" ? e + t - n : e + (t - n) / 2;
16243
16241
  }
16244
- function ld({ sourceSize: e, rect: t, axis: n }) {
16245
- let r = ud({
16242
+ function id({ sourceSize: e, rect: t, axis: n }) {
16243
+ let r = ad({
16246
16244
  sourceSize: e,
16247
16245
  axis: n
16248
- }), i = dd({
16246
+ }), i = od({
16249
16247
  rect: t,
16250
16248
  axis: n
16251
16249
  });
16252
16250
  return Math.round(i) >= Math.round(r);
16253
16251
  }
16254
- function ud({ sourceSize: e, axis: t }) {
16252
+ function ad({ sourceSize: e, axis: t }) {
16255
16253
  return t === "x" ? e.width : e.height;
16256
16254
  }
16257
- function dd({ rect: e, axis: t }) {
16255
+ function od({ rect: e, axis: t }) {
16258
16256
  return t === "x" ? e.width : e.height;
16259
16257
  }
16260
- function fd({ sourceSize: e, rect: t, axis: n, anchor: r }) {
16258
+ function sd({ sourceSize: e, rect: t, axis: n, anchor: r }) {
16261
16259
  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;
16262
- return r === "min" ? c - pd({
16260
+ return r === "min" ? c - cd({
16263
16261
  value: a,
16264
16262
  boundary: s
16265
- }) : r === "max" ? pd({
16263
+ }) : r === "max" ? cd({
16266
16264
  value: l,
16267
16265
  boundary: c
16268
16266
  }) - s : Math.min(u - s, c - u) * 2;
16269
16267
  }
16270
- function pd({ value: e, boundary: t }) {
16271
- return Math.abs(e - t) <= $u ? t : e;
16268
+ function cd({ value: e, boundary: t }) {
16269
+ return Math.abs(e - t) <= Ju ? t : e;
16272
16270
  }
16273
16271
  //#endregion
16274
16272
  //#region src/editor/crop-manager/domain/crop-frame-size.ts
16275
- function md({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 }) {
16273
+ function ld({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 }) {
16276
16274
  let r = Math.abs(e.cropSourceScaleX ?? 1) || 1, i = Math.abs(e.cropSourceScaleY ?? 1) || 1;
16277
16275
  return {
16278
16276
  width: Math.max(1, e.width * Math.abs(t) / r),
@@ -16281,159 +16279,159 @@ function md({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 })
16281
16279
  }
16282
16280
  //#endregion
16283
16281
  //#region src/editor/crop-manager/interaction/crop-controls.ts
16284
- var hd = .001, gd = 1, _d = 1e-6, vd = 1e-9, yd = [
16282
+ var ud = .001, dd = 1, fd = 1e-6, pd = 1e-9, md = [
16285
16283
  "tl",
16286
16284
  "tr",
16287
16285
  "bl",
16288
16286
  "br"
16289
- ], bd = [
16287
+ ], hd = [
16290
16288
  "ml",
16291
16289
  "mr",
16292
16290
  "mt",
16293
16291
  "mb"
16294
- ], xd = {
16292
+ ], gd = {
16295
16293
  ml: "w-resize",
16296
16294
  mr: "e-resize",
16297
16295
  mt: "n-resize",
16298
16296
  mb: "s-resize"
16299
16297
  };
16300
- function Sd({ transform: e }) {
16298
+ function _d({ transform: e }) {
16301
16299
  let { originX: t, originY: n } = e;
16302
16300
  return (t === "center" || t === .5) && (n === "center" || n === .5);
16303
16301
  }
16304
- function Cd({ transform: e, x: t, y: n }) {
16302
+ function vd({ transform: e, x: t, y: n }) {
16305
16303
  let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i;
16306
- if (Dd({
16304
+ if (Sd({
16307
16305
  transform: r,
16308
16306
  x: t,
16309
16307
  y: n
16310
- })) return Od({ transform: r }), !0;
16308
+ })) return Cd({ transform: r }), !0;
16311
16309
  let s = x.getLocalPoint(r, r.originX, r.originY, t, n);
16312
- return Ad({ transform: r }), Pd({
16310
+ return Td({ transform: r }), kd({
16313
16311
  transform: r,
16314
16312
  localPoint: s
16315
16313
  }), a !== i.scaleX || o !== i.scaleY;
16316
16314
  }
16317
- function wd({ transform: e, x: t, y: n }) {
16315
+ function yd({ transform: e, x: t, y: n }) {
16318
16316
  let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i;
16319
- if (Dd({
16317
+ if (Sd({
16320
16318
  transform: r,
16321
16319
  x: t,
16322
16320
  y: n
16323
- })) return Od({ transform: r }), !0;
16321
+ })) return Cd({ transform: r }), !0;
16324
16322
  let s = x.getLocalPoint(r, r.originX, r.originY, t, n);
16325
- return Ad({ transform: r }), Gd({
16323
+ return Td({ transform: r }), Bd({
16326
16324
  transform: r,
16327
16325
  localPoint: s
16328
16326
  }), a !== i.scaleX || o !== i.scaleY;
16329
16327
  }
16330
- function Td({ transform: e, axis: t, x: n, y: r }) {
16328
+ function bd({ transform: e, axis: t, x: n, y: r }) {
16331
16329
  let i = e, { target: a } = i, o = t === "x" ? a.scaleX ?? 1 : a.scaleY ?? 1;
16332
- if (Dd({
16330
+ if (Sd({
16333
16331
  transform: i,
16334
16332
  x: n,
16335
16333
  y: r
16336
- })) return kd({
16334
+ })) return wd({
16337
16335
  transform: i,
16338
16336
  axis: t
16339
16337
  }), !0;
16340
16338
  let s = x.getLocalPoint(i, i.originX, i.originY, n, r);
16341
- return Ad({ transform: i }), Fd({
16339
+ return Td({ transform: i }), Ad({
16342
16340
  transform: i,
16343
16341
  axis: t,
16344
16342
  localPoint: s
16345
16343
  }), t === "x" ? o !== a.scaleX : o !== a.scaleY;
16346
16344
  }
16347
- function Ed({ transform: e, axis: t, x: n, y: r }) {
16345
+ function xd({ transform: e, axis: t, x: n, y: r }) {
16348
16346
  let i = e, { target: a } = i, { scaleX: o = 1, scaleY: s = 1 } = a;
16349
- if (Dd({
16347
+ if (Sd({
16350
16348
  transform: i,
16351
16349
  x: n,
16352
16350
  y: r
16353
- })) return Od({ transform: i }), !0;
16351
+ })) return Cd({ transform: i }), !0;
16354
16352
  let c = x.getLocalPoint(i, i.originX, i.originY, n, r);
16355
- return Ad({ transform: i }), Id({
16353
+ return Td({ transform: i }), jd({
16356
16354
  transform: i,
16357
16355
  axis: t,
16358
16356
  localPoint: c
16359
16357
  }), o !== a.scaleX || s !== a.scaleY;
16360
16358
  }
16361
- function Dd({ transform: e, x: t, y: n }) {
16362
- return Math.abs(t - e.ex) <= hd && Math.abs(n - e.ey) <= hd;
16359
+ function Sd({ transform: e, x: t, y: n }) {
16360
+ return Math.abs(t - e.ex) <= ud && Math.abs(n - e.ey) <= ud;
16363
16361
  }
16364
- function Od({ transform: e }) {
16362
+ function Cd({ transform: e }) {
16365
16363
  e.target.set({
16366
16364
  scaleX: e.original.scaleX,
16367
16365
  scaleY: e.original.scaleY
16368
16366
  });
16369
16367
  }
16370
- function kd({ transform: e, axis: t }) {
16368
+ function wd({ transform: e, axis: t }) {
16371
16369
  if (t === "x") {
16372
16370
  e.target.set("scaleX", e.original.scaleX);
16373
16371
  return;
16374
16372
  }
16375
16373
  e.target.set("scaleY", e.original.scaleY);
16376
16374
  }
16377
- function Ad({ transform: e }) {
16378
- let { signX: t, signY: n } = jd({ controlKey: e.corner });
16375
+ function Td({ transform: e }) {
16376
+ let { signX: t, signY: n } = Ed({ controlKey: e.corner });
16379
16377
  e.signX === void 0 && (e.signX = t), e.signY === void 0 && (e.signY = n);
16380
16378
  }
16381
- function jd({ controlKey: e }) {
16379
+ function Ed({ controlKey: e }) {
16382
16380
  return {
16383
- signX: Md({ controlKey: e }),
16384
- signY: Nd({ controlKey: e })
16381
+ signX: Dd({ controlKey: e }),
16382
+ signY: Od({ controlKey: e })
16385
16383
  };
16386
16384
  }
16387
- function Md({ controlKey: e }) {
16385
+ function Dd({ controlKey: e }) {
16388
16386
  return e === "tl" || e === "bl" || e === "ml" ? -1 : 1;
16389
16387
  }
16390
- function Nd({ controlKey: e }) {
16388
+ function Od({ controlKey: e }) {
16391
16389
  return e === "tl" || e === "tr" || e === "mt" ? -1 : 1;
16392
16390
  }
16393
- function Pd({ transform: e, localPoint: t }) {
16391
+ function kd({ transform: e, localPoint: t }) {
16394
16392
  let { target: n } = e;
16395
- Rd({ transform: e });
16396
- let r = Ld({
16393
+ Nd({ transform: e });
16394
+ let r = Md({
16397
16395
  transform: e,
16398
16396
  axis: "x",
16399
16397
  localPoint: t
16400
- }), i = Ld({
16398
+ }), i = Md({
16401
16399
  transform: e,
16402
16400
  axis: "y",
16403
16401
  localPoint: t
16404
16402
  });
16405
- n.lockScalingX || n.set("scaleX", r.scale), n.lockScalingY || n.set("scaleY", i.scale), (r.sourceClamped || i.sourceClamped) && zd({
16403
+ n.lockScalingX || n.set("scaleX", r.scale), n.lockScalingY || n.set("scaleY", i.scale), (r.sourceClamped || i.sourceClamped) && Pd({
16406
16404
  transform: e,
16407
16405
  preserveAspectRatio: !1
16408
16406
  });
16409
16407
  }
16410
- function Fd({ transform: e, axis: t, localPoint: n }) {
16408
+ function Ad({ transform: e, axis: t, localPoint: n }) {
16411
16409
  let { target: r } = e;
16412
16410
  if (t === "x" && r.lockScalingX || t === "y" && r.lockScalingY) return;
16413
- Rd({ transform: e });
16414
- let i = Ld({
16411
+ Nd({ transform: e });
16412
+ let i = Md({
16415
16413
  transform: e,
16416
16414
  axis: t,
16417
16415
  localPoint: n
16418
16416
  });
16419
- t === "x" ? r.set("scaleX", i.scale) : r.set("scaleY", i.scale), i.sourceClamped && zd({
16417
+ t === "x" ? r.set("scaleX", i.scale) : r.set("scaleY", i.scale), i.sourceClamped && Pd({
16420
16418
  transform: e,
16421
16419
  preserveAspectRatio: !1
16422
16420
  });
16423
16421
  }
16424
- function Id({ transform: e, axis: t, localPoint: n }) {
16422
+ function jd({ transform: e, axis: t, localPoint: n }) {
16425
16423
  let { target: r } = e;
16426
16424
  if (r.lockScalingX || r.lockScalingY) return;
16427
- let i = Ld({
16425
+ let i = Md({
16428
16426
  transform: e,
16429
16427
  axis: t,
16430
16428
  localPoint: n,
16431
16429
  constrainToSource: !1
16432
- }), a = t === "x" ? e.original.scaleX : e.original.scaleY, o = Yd({
16430
+ }), a = t === "x" ? e.original.scaleX : e.original.scaleY, o = Wd({
16433
16431
  target: r,
16434
16432
  transform: e,
16435
16433
  scale: a > 0 ? i.scale / a : 1,
16436
- forceMinimum: nf({
16434
+ forceMinimum: Zd({
16437
16435
  transform: e,
16438
16436
  axis: t,
16439
16437
  localPoint: n
@@ -16441,17 +16439,17 @@ function Id({ transform: e, axis: t, localPoint: n }) {
16441
16439
  });
16442
16440
  r.set("scaleX", o.scaleX), r.set("scaleY", o.scaleY);
16443
16441
  }
16444
- function Ld({ transform: e, axis: t, localPoint: n, constrainToSource: r = !0 }) {
16445
- let { target: i } = e, a = Jd({ target: i }), o = tf({ target: i }), s = t === "x" ? i.scaleX ?? 1 : i.scaleY ?? 1, c = t === "x" ? e.original.scaleX : e.original.scaleY, l = t === "x" ? n.x : n.y, u = t === "x" ? a.x : a.y, d = t === "x" ? o.minScaleX : o.minScaleY, f = r ? Ud({
16442
+ function Md({ transform: e, axis: t, localPoint: n, constrainToSource: r = !0 }) {
16443
+ let { target: i } = e, a = Ud({ target: i }), o = Xd({ target: i }), s = t === "x" ? i.scaleX ?? 1 : i.scaleY ?? 1, c = t === "x" ? e.original.scaleX : e.original.scaleY, l = t === "x" ? n.x : n.y, u = t === "x" ? a.x : a.y, d = t === "x" ? o.minScaleX : o.minScaleY, f = r ? Rd({
16446
16444
  target: i,
16447
16445
  transform: e,
16448
16446
  axis: t
16449
- }) : null, p = Hd({
16447
+ }) : null, p = Ld({
16450
16448
  axis: t,
16451
16449
  limits: o,
16452
16450
  sourceMaximumScale: f
16453
16451
  });
16454
- if (nf({
16452
+ if (Zd({
16455
16453
  transform: e,
16456
16454
  axis: t,
16457
16455
  localPoint: n
@@ -16460,11 +16458,11 @@ function Ld({ transform: e, axis: t, localPoint: n, constrainToSource: r = !0 })
16460
16458
  sourceClamped: !1
16461
16459
  };
16462
16460
  let m = Math.abs((l || 0) * s / u);
16463
- Sd({ transform: e }) && (m *= 2);
16464
- let h = Vd({
16461
+ _d({ transform: e }) && (m *= 2);
16462
+ let h = Id({
16465
16463
  target: i,
16466
16464
  axis: t,
16467
- scale: cf({
16465
+ scale: nf({
16468
16466
  value: m,
16469
16467
  min: d,
16470
16468
  max: p
@@ -16474,7 +16472,7 @@ function Ld({ transform: e, axis: t, localPoint: n, constrainToSource: r = !0 })
16474
16472
  });
16475
16473
  return {
16476
16474
  scale: h,
16477
- sourceClamped: Bd({
16475
+ sourceClamped: Fd({
16478
16476
  scale: h,
16479
16477
  maximumScale: p,
16480
16478
  sourceMaximumScale: f,
@@ -16482,108 +16480,108 @@ function Ld({ transform: e, axis: t, localPoint: n, constrainToSource: r = !0 })
16482
16480
  })
16483
16481
  };
16484
16482
  }
16485
- function Rd({ transform: e }) {
16483
+ function Nd({ transform: e }) {
16486
16484
  e.cropSourceScaleClamped = !1, e.cropSourceBoundScale = null, e.cropSourceScaleAnchorX = void 0, e.cropSourceScaleAnchorY = void 0, e.cropSourceScalePreserveAspectRatio = void 0;
16487
16485
  }
16488
- function zd({ transform: e, preserveAspectRatio: t }) {
16486
+ function Pd({ transform: e, preserveAspectRatio: t }) {
16489
16487
  let { target: n } = e;
16490
- e.cropSourceScaleClamped = !0, e.cropSourceScalePreserveAspectRatio = t, e.cropSourceScaleAnchorX = $d({ transform: e }), e.cropSourceScaleAnchorY = ef({ transform: e }), e.cropSourceBoundScale = {
16488
+ e.cropSourceScaleClamped = !0, e.cropSourceScalePreserveAspectRatio = t, e.cropSourceScaleAnchorX = Jd({ transform: e }), e.cropSourceScaleAnchorY = Yd({ transform: e }), e.cropSourceBoundScale = {
16491
16489
  scaleX: n.scaleX ?? 1,
16492
16490
  scaleY: n.scaleY ?? 1
16493
16491
  };
16494
16492
  }
16495
- function Bd({ scale: e, maximumScale: t, sourceMaximumScale: n, originalScale: r }) {
16496
- return n === null || Math.abs(t - n) > vd || Math.abs(e - n) > vd ? !1 : Math.abs(Math.abs(r) - n) > vd;
16493
+ function Fd({ scale: e, maximumScale: t, sourceMaximumScale: n, originalScale: r }) {
16494
+ return n === null || Math.abs(t - n) > pd || Math.abs(e - n) > pd ? !1 : Math.abs(Math.abs(r) - n) > pd;
16497
16495
  }
16498
- function Vd({ target: e, axis: t, scale: n, maximumScale: r, sourceMaximumScale: i }) {
16499
- return i === null || Math.abs(r - i) > vd ? n : Wd({
16496
+ function Id({ target: e, axis: t, scale: n, maximumScale: r, sourceMaximumScale: i }) {
16497
+ return i === null || Math.abs(r - i) > pd ? n : zd({
16500
16498
  target: e,
16501
16499
  axis: t,
16502
16500
  fromScale: n,
16503
16501
  toScale: i
16504
- }) <= gd + _d ? i : n;
16502
+ }) <= dd + fd ? i : n;
16505
16503
  }
16506
- function Hd({ axis: e, limits: t, sourceMaximumScale: n }) {
16504
+ function Ld({ axis: e, limits: t, sourceMaximumScale: n }) {
16507
16505
  let r = e === "x" ? t.minScaleX : t.minScaleY, i = e === "x" ? t.maxScaleX : t.maxScaleY;
16508
16506
  return n === null ? i : Math.max(r, Math.min(i, n));
16509
16507
  }
16510
- function Ud({ target: e, transform: t, axis: n }) {
16511
- let r = Zd({
16508
+ function Rd({ target: e, transform: t, axis: n }) {
16509
+ let r = Kd({
16512
16510
  target: e,
16513
16511
  transform: t
16514
16512
  });
16515
16513
  if (!r) return null;
16516
- let i = n === "x" ? t.original.scaleX : t.original.scaleY, a = rd({
16514
+ let i = n === "x" ? t.original.scaleX : t.original.scaleY, a = Qu({
16517
16515
  sourceSize: r.sourceSize,
16518
16516
  startRect: r.startRect,
16519
16517
  axis: n,
16520
- anchor: Qd({
16518
+ anchor: qd({
16521
16519
  transform: t,
16522
16520
  axis: n
16523
16521
  })
16524
16522
  });
16525
16523
  return Math.abs(i) * a;
16526
16524
  }
16527
- function Wd({ target: e, axis: t, fromScale: n, toScale: r }) {
16525
+ function zd({ target: e, axis: t, fromScale: n, toScale: r }) {
16528
16526
  let i = e, a = t === "x" ? Math.abs(i.cropSourceScaleX ?? 1) || 1 : Math.abs(i.cropSourceScaleY ?? 1) || 1, o = t === "x" ? e.width : e.height;
16529
16527
  return Math.abs(r - n) * Math.max(1, o) / a;
16530
16528
  }
16531
- function Gd({ transform: e, localPoint: t }) {
16529
+ function Bd({ transform: e, localPoint: t }) {
16532
16530
  let { target: n } = e;
16533
16531
  if (n.lockScalingX || n.lockScalingY) return;
16534
- let r = Yd({
16532
+ let r = Wd({
16535
16533
  target: n,
16536
16534
  transform: e,
16537
- scale: Kd({
16535
+ scale: Vd({
16538
16536
  transform: e,
16539
16537
  localPoint: t,
16540
- dimensions: Jd({ target: n })
16538
+ dimensions: Ud({ target: n })
16541
16539
  }),
16542
- forceMinimum: rf({
16540
+ forceMinimum: Qd({
16543
16541
  transform: e,
16544
16542
  localPoint: t
16545
16543
  })
16546
16544
  });
16547
16545
  n.set("scaleX", r.scaleX), n.set("scaleY", r.scaleY);
16548
16546
  }
16549
- function Kd({ transform: e, localPoint: t, dimensions: n }) {
16547
+ function Vd({ transform: e, localPoint: t, dimensions: n }) {
16550
16548
  let r = "gestureScale" in e && typeof e.gestureScale == "number" ? e.gestureScale : null;
16551
16549
  if (r !== null) return r;
16552
- let i = Math.abs(t.x) + Math.abs(t.y), a = qd({
16550
+ let i = Math.abs(t.x) + Math.abs(t.y), a = Hd({
16553
16551
  transform: e,
16554
16552
  dimensions: n
16555
16553
  }), o = a > 0 ? i / a : 1;
16556
- return Sd({ transform: e }) && (o *= 2), o;
16554
+ return _d({ transform: e }) && (o *= 2), o;
16557
16555
  }
16558
- function qd({ transform: e, dimensions: t }) {
16556
+ function Hd({ transform: e, dimensions: t }) {
16559
16557
  let { target: n, original: r } = e, i = n.scaleX ?? 1, a = n.scaleY ?? 1;
16560
16558
  return Math.abs(t.x * r.scaleX / i) + Math.abs(t.y * r.scaleY / a);
16561
16559
  }
16562
- function Jd({ target: e }) {
16560
+ function Ud({ target: e }) {
16563
16561
  let t = Math.abs(e.scaleX ?? 1), n = Math.abs(e.scaleY ?? 1);
16564
16562
  return {
16565
16563
  x: Math.max(1, e.width * t),
16566
16564
  y: Math.max(1, e.height * n)
16567
16565
  };
16568
16566
  }
16569
- function Yd({ target: e, transform: t, scale: n, forceMinimum: r }) {
16570
- let i = md({
16567
+ function Wd({ target: e, transform: t, scale: n, forceMinimum: r }) {
16568
+ let i = ld({
16571
16569
  frame: e,
16572
16570
  scaleX: t.original.scaleX,
16573
16571
  scaleY: t.original.scaleY
16574
- }), a = Math.max(Nu / i.width, Pu / i.height), o = Math.min(Fu / i.width, Iu / i.height), s = Xd({
16572
+ }), a = Math.max(Ou / i.width, ku / i.height), o = Math.min(Au / i.width, ju / i.height), s = Gd({
16575
16573
  target: e,
16576
16574
  transform: t
16577
16575
  }), c = Math.max(a, Math.min(o, s ?? o));
16578
16576
  t.cropSourceScaleClamped = !r && n > c, t.cropSourceScalePreserveAspectRatio = t.cropSourceScaleClamped;
16579
16577
  let l = a;
16580
- r || (l = cf({
16578
+ r || (l = nf({
16581
16579
  value: n,
16582
16580
  min: a,
16583
16581
  max: c
16584
16582
  }));
16585
16583
  let u = t.original.scaleX * l, d = t.original.scaleY * l;
16586
- return t.cropSourceScaleClamped ? (t.cropSourceScaleAnchorX = $d({ transform: t }), t.cropSourceScaleAnchorY = ef({ transform: t }), t.cropSourceBoundScale = {
16584
+ return t.cropSourceScaleClamped ? (t.cropSourceScaleAnchorX = Jd({ transform: t }), t.cropSourceScaleAnchorY = Yd({ transform: t }), t.cropSourceBoundScale = {
16587
16585
  scaleX: u,
16588
16586
  scaleY: d
16589
16587
  }) : (t.cropSourceBoundScale = null, t.cropSourceScaleAnchorX = void 0, t.cropSourceScaleAnchorY = void 0, t.cropSourceScalePreserveAspectRatio = void 0), {
@@ -16591,106 +16589,106 @@ function Yd({ target: e, transform: t, scale: n, forceMinimum: r }) {
16591
16589
  scaleY: d
16592
16590
  };
16593
16591
  }
16594
- function Xd({ target: e, transform: t }) {
16595
- let n = Zd({
16592
+ function Gd({ target: e, transform: t }) {
16593
+ let n = Kd({
16596
16594
  target: e,
16597
16595
  transform: t
16598
16596
  });
16599
- return n ? td({
16597
+ return n ? Xu({
16600
16598
  sourceSize: n.sourceSize,
16601
16599
  startRect: n.startRect,
16602
- anchorX: $d({ transform: t }),
16603
- anchorY: ef({ transform: t })
16600
+ anchorX: Jd({ transform: t }),
16601
+ anchorY: Yd({ transform: t })
16604
16602
  }) : null;
16605
16603
  }
16606
- function Zd({ target: e, transform: t }) {
16604
+ function Kd({ target: e, transform: t }) {
16607
16605
  if (t.cropSourceScaleBounds !== void 0) return t.cropSourceScaleBounds;
16608
16606
  let n = e;
16609
16607
  return n.cropAllowFrameOverflow !== !1 || !n.cropSource ? (t.cropSourceScaleBounds = null, null) : (t.cropSourceScaleBounds = {
16610
16608
  sourceSize: Z({ source: n.cropSource }),
16611
- startRect: zu({
16609
+ startRect: Pu({
16612
16610
  source: n.cropSource,
16613
16611
  frame: n
16614
16612
  })
16615
16613
  }, t.cropSourceScaleBounds);
16616
16614
  }
16617
- function Qd({ transform: e, axis: t }) {
16618
- return t === "x" ? $d({ transform: e }) : ef({ transform: e });
16615
+ function qd({ transform: e, axis: t }) {
16616
+ return t === "x" ? Jd({ transform: e }) : Yd({ transform: e });
16619
16617
  }
16620
- function $d({ transform: e }) {
16618
+ function Jd({ transform: e }) {
16621
16619
  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";
16622
16620
  }
16623
- function ef({ transform: e }) {
16621
+ function Yd({ transform: e }) {
16624
16622
  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";
16625
16623
  }
16626
- function tf({ target: e }) {
16624
+ function Xd({ target: e }) {
16627
16625
  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);
16628
16626
  return {
16629
- minScaleX: Nu * n / i,
16630
- maxScaleX: Fu * n / i,
16631
- minScaleY: Pu * r / a,
16632
- maxScaleY: Iu * r / a
16627
+ minScaleX: Ou * n / i,
16628
+ maxScaleX: Au * n / i,
16629
+ minScaleY: ku * r / a,
16630
+ maxScaleY: ju * r / a
16633
16631
  };
16634
16632
  }
16635
- function nf({ transform: e, axis: t, localPoint: n }) {
16633
+ function Zd({ transform: e, axis: t, localPoint: n }) {
16636
16634
  let { target: r } = e;
16637
16635
  if (!r.lockScalingFlip) return !1;
16638
16636
  let i = t === "x" ? e.signX ?? 1 : e.signY ?? 1, a = t === "x" ? n.x : n.y;
16639
16637
  return i !== Math.sign(a || i);
16640
16638
  }
16641
- function rf({ transform: e, localPoint: t }) {
16642
- return nf({
16639
+ function Qd({ transform: e, localPoint: t }) {
16640
+ return Zd({
16643
16641
  transform: e,
16644
16642
  axis: "x",
16645
16643
  localPoint: t
16646
- }) || nf({
16644
+ }) || Zd({
16647
16645
  transform: e,
16648
16646
  axis: "y",
16649
16647
  localPoint: t
16650
16648
  });
16651
16649
  }
16652
- function af({ eventData: e, target: t }) {
16653
- return Fl({
16650
+ function $d({ eventData: e, target: t }) {
16651
+ return Al({
16654
16652
  target: t,
16655
16653
  shiftKey: e.shiftKey
16656
16654
  });
16657
16655
  }
16658
- function of() {
16659
- let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => Cd({
16656
+ function ef() {
16657
+ let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => vd({
16660
16658
  transform: t,
16661
16659
  x: n,
16662
16660
  y: r
16663
- }))), t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => wd({
16661
+ }))), t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => yd({
16664
16662
  transform: t,
16665
16663
  x: n,
16666
16664
  y: r
16667
16665
  })));
16668
- return (n, r, i, a) => af({
16666
+ return (n, r, i, a) => $d({
16669
16667
  eventData: n,
16670
16668
  target: r.target
16671
16669
  }) ? t(n, r, i, a) : e(n, r, i, a);
16672
16670
  }
16673
- function sf({ axis: e }) {
16674
- let t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => Td({
16671
+ function tf({ axis: e }) {
16672
+ let t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => bd({
16675
16673
  transform: n,
16676
16674
  axis: e,
16677
16675
  x: r,
16678
16676
  y: i
16679
- }))), n = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => Ed({
16677
+ }))), n = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => xd({
16680
16678
  transform: n,
16681
16679
  axis: e,
16682
16680
  x: r,
16683
16681
  y: i
16684
16682
  })));
16685
- return (e, r, i, a) => af({
16683
+ return (e, r, i, a) => $d({
16686
16684
  eventData: e,
16687
16685
  target: r.target
16688
16686
  }) ? n(e, r, i, a) : t(e, r, i, a);
16689
16687
  }
16690
- function cf({ value: e, min: t, max: n }) {
16688
+ function nf({ value: e, min: t, max: n }) {
16691
16689
  return Math.max(t, Math.min(n, e));
16692
16690
  }
16693
- function lf({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName: i }) {
16691
+ function rf({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName: i }) {
16694
16692
  let a = {
16695
16693
  ...e,
16696
16694
  actionHandler: t
@@ -16699,55 +16697,55 @@ function lf({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName
16699
16697
  let o = new r(a);
16700
16698
  return o.cropResizeControl = !0, o;
16701
16699
  }
16702
- function uf({ controlKey: e }) {
16703
- return xd[e];
16700
+ function af({ controlKey: e }) {
16701
+ return gd[e];
16704
16702
  }
16705
- function df({ axis: e }) {
16703
+ function of({ axis: e }) {
16706
16704
  return e === "x" ? "scaleX" : "scaleY";
16707
16705
  }
16708
- function ff({ target: e }) {
16709
- let t = { ...e.controls }, n = !1, r = of(), i = sf({ axis: "x" }), a = sf({ axis: "y" });
16710
- yd.forEach((i) => {
16706
+ function sf({ target: e }) {
16707
+ let t = { ...e.controls }, n = !1, r = ef(), i = tf({ axis: "x" }), a = tf({ axis: "y" });
16708
+ md.forEach((i) => {
16711
16709
  let a = e.controls[i];
16712
- a && (a.cropResizeControl || (t[i] = lf({
16710
+ a && (a.cropResizeControl || (t[i] = rf({
16713
16711
  control: a,
16714
16712
  actionHandler: r
16715
16713
  }), n = !0));
16716
- }), bd.forEach((r) => {
16714
+ }), hd.forEach((r) => {
16717
16715
  let o = e.controls[r];
16718
16716
  if (!o || o.cropResizeControl) return;
16719
16717
  let s = r === "ml" || r === "mr", c = s ? i : a, l = s ? "x" : "y";
16720
- t[r] = lf({
16718
+ t[r] = rf({
16721
16719
  control: o,
16722
16720
  actionHandler: c,
16723
- cursorStyleHandler: () => uf({ controlKey: r }),
16724
- getActionName: () => df({ axis: l })
16721
+ cursorStyleHandler: () => af({ controlKey: r }),
16722
+ getActionName: () => of({ axis: l })
16725
16723
  }), n = !0;
16726
16724
  }), n && (e.controls = t);
16727
16725
  }
16728
16726
  //#endregion
16729
16727
  //#region src/editor/crop-manager/domain/crop-frame.ts
16730
- var pf = "rgba(47, 128, 237, 0.42)", mf = class extends _ {
16728
+ var cf = "rgba(47, 128, 237, 0.42)", lf = class extends _ {
16731
16729
  constructor(e) {
16732
16730
  let { showGrid: t, source: n = null, allowFrameOverflow: r = !0, sourceScaleX: i = 1, sourceScaleY: a = 1, preserveAspectRatio: o = !0, ...s } = e;
16733
16731
  super(s), this._showGrid = t, this.cropSource = n, this.cropAllowFrameOverflow = r, this.cropSourceScaleX = i, this.cropSourceScaleY = a, this.preserveAspectRatio = o, this.cropActiveResizePreserveAspectRatio = null;
16734
16732
  }
16735
16733
  _render(e) {
16736
- super._render(e), this._showGrid && _f({
16734
+ super._render(e), this._showGrid && ff({
16737
16735
  ctx: e,
16738
16736
  width: this.width,
16739
16737
  height: this.height
16740
16738
  });
16741
16739
  }
16742
16740
  getObjectDisplaySize() {
16743
- return md({ frame: this });
16741
+ return ld({ frame: this });
16744
16742
  }
16745
16743
  getObjectSnappingBounds() {
16746
- return yf({ frame: this });
16744
+ return mf({ frame: this });
16747
16745
  }
16748
16746
  };
16749
- function hf({ source: e, cropSize: t, showGrid: n, allowFrameOverflow: r, preserveAspectRatio: i }) {
16750
- let a = e.getCenterPoint(), o = e.scaleX ?? 1, s = e.scaleY ?? 1, c = new mf({
16747
+ function uf({ source: e, cropSize: t, showGrid: n, allowFrameOverflow: r, preserveAspectRatio: i }) {
16748
+ let a = e.getCenterPoint(), o = e.scaleX ?? 1, s = e.scaleY ?? 1, c = new lf({
16751
16749
  id: `crop-frame-${D()}`,
16752
16750
  left: a.x,
16753
16751
  top: a.y,
@@ -16779,22 +16777,22 @@ function hf({ source: e, cropSize: t, showGrid: n, allowFrameOverflow: r, preser
16779
16777
  sourceScaleX: o,
16780
16778
  sourceScaleY: s
16781
16779
  });
16782
- return c.setControlsVisibility({ mtr: !1 }), ff({ target: c }), c;
16780
+ return c.setControlsVisibility({ mtr: !1 }), sf({ target: c }), c;
16783
16781
  }
16784
- function gf({ frame: e, preserveAspectRatio: t }) {
16785
- if (!(e instanceof mf)) throw Error("Crop session frame должен быть CropFrame");
16782
+ function df({ frame: e, preserveAspectRatio: t }) {
16783
+ if (!(e instanceof lf)) throw Error("Crop session frame должен быть CropFrame");
16786
16784
  e.cropActiveResizePreserveAspectRatio = t;
16787
16785
  }
16788
- function _f({ ctx: e, width: t, height: n }) {
16786
+ function ff({ ctx: e, width: t, height: n }) {
16789
16787
  if (!(t <= 0 || n <= 0)) {
16790
- e.save(), e.strokeStyle = pf, e.lineWidth = 1, e.setLineDash([]);
16788
+ e.save(), e.strokeStyle = cf, e.lineWidth = 1, e.setLineDash([]);
16791
16789
  for (let r = 1; r <= 2; r += 1) {
16792
16790
  let i = -t / 2 + t * r / 3, a = -n / 2 + n * r / 3;
16793
- vf({
16791
+ pf({
16794
16792
  ctx: e,
16795
16793
  x: i,
16796
16794
  height: n
16797
- }), xf({
16795
+ }), gf({
16798
16796
  ctx: e,
16799
16797
  y: a,
16800
16798
  width: t
@@ -16803,19 +16801,19 @@ function _f({ ctx: e, width: t, height: n }) {
16803
16801
  e.restore();
16804
16802
  }
16805
16803
  }
16806
- function vf({ ctx: e, x: t, height: n }) {
16804
+ function pf({ ctx: e, x: t, height: n }) {
16807
16805
  e.beginPath(), e.moveTo(t, -n / 2), e.lineTo(t, n / 2), e.stroke();
16808
16806
  }
16809
- function yf({ frame: e }) {
16807
+ function mf({ frame: e }) {
16810
16808
  let t = e.calcTransformMatrix(), n = e.width / 2, r = e.height / 2;
16811
- return bf({ points: [
16809
+ return hf({ points: [
16812
16810
  new m(-n, -r),
16813
16811
  new m(n, -r),
16814
16812
  new m(n, r),
16815
16813
  new m(-n, r)
16816
16814
  ].map((e) => e.transform(t)) });
16817
16815
  }
16818
- function bf({ points: e }) {
16816
+ function hf({ points: e }) {
16819
16817
  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));
16820
16818
  return {
16821
16819
  left: t,
@@ -16826,12 +16824,12 @@ function bf({ points: e }) {
16826
16824
  centerY: r + (i - r) / 2
16827
16825
  };
16828
16826
  }
16829
- function xf({ ctx: e, y: t, width: n }) {
16827
+ function gf({ ctx: e, y: t, width: n }) {
16830
16828
  e.beginPath(), e.moveTo(-n / 2, t), e.lineTo(n / 2, t), e.stroke();
16831
16829
  }
16832
16830
  //#endregion
16833
16831
  //#region src/editor/crop-manager/domain/crop-frame-transform-state.ts
16834
- function Sf({ source: e, frame: t, rect: n, scale: r }) {
16832
+ function _f({ source: e, frame: t, rect: n, scale: r }) {
16835
16833
  let i = new m(n.left + n.width / 2, n.top + n.height / 2).transform(e.calcTransformMatrix()), a = t.translateToOriginPoint(i, t.originX, t.originY);
16836
16834
  return {
16837
16835
  left: a.x,
@@ -16840,7 +16838,7 @@ function Sf({ source: e, frame: t, rect: n, scale: r }) {
16840
16838
  scaleY: r.scaleY
16841
16839
  };
16842
16840
  }
16843
- function Cf({ frame: e }) {
16841
+ function vf({ frame: e }) {
16844
16842
  return {
16845
16843
  left: e.left,
16846
16844
  top: e.top,
@@ -16848,7 +16846,7 @@ function Cf({ frame: e }) {
16848
16846
  scaleY: e.scaleY ?? 1
16849
16847
  };
16850
16848
  }
16851
- function wf({ frame: e, state: t }) {
16849
+ function yf({ frame: e, state: t }) {
16852
16850
  e.set({
16853
16851
  left: t.left,
16854
16852
  top: t.top,
@@ -16858,22 +16856,22 @@ function wf({ frame: e, state: t }) {
16858
16856
  }
16859
16857
  //#endregion
16860
16858
  //#region src/editor/crop-manager/domain/crop-result.ts
16861
- var Tf = 1e-6;
16862
- function Ef({ session: e }) {
16863
- return e.mode === "canvas" ? jf({ session: e }) : Mf({
16859
+ var bf = 1e-6;
16860
+ function xf({ session: e }) {
16861
+ return e.mode === "canvas" ? Ef({ session: e }) : Df({
16864
16862
  target: e.target,
16865
16863
  frame: e.frame
16866
16864
  });
16867
16865
  }
16868
- function Df({ rect: e, sourceSize: t }) {
16869
- let n = Math.max(0, Of({ value: e.width })), r = Math.max(0, Of({ value: e.height }));
16866
+ function Sf({ rect: e, sourceSize: t }) {
16867
+ let n = Math.max(0, Cf({ value: e.width })), r = Math.max(0, Cf({ value: e.height }));
16870
16868
  return {
16871
- left: kf({
16869
+ left: wf({
16872
16870
  start: e.left,
16873
16871
  length: n,
16874
16872
  sourceLength: t?.width
16875
16873
  }),
16876
- top: kf({
16874
+ top: wf({
16877
16875
  start: e.top,
16878
16876
  length: r,
16879
16877
  sourceLength: t?.height
@@ -16882,20 +16880,20 @@ function Df({ rect: e, sourceSize: t }) {
16882
16880
  height: r
16883
16881
  };
16884
16882
  }
16885
- function Of({ value: e }) {
16886
- return Math.round(e + Tf);
16883
+ function Cf({ value: e }) {
16884
+ return Math.round(e + bf);
16887
16885
  }
16888
- function kf({ start: e, length: t, sourceLength: n }) {
16889
- let r = Of({ value: e });
16886
+ function wf({ start: e, length: t, sourceLength: n }) {
16887
+ let r = Cf({ value: e });
16890
16888
  if (n === void 0) return r;
16891
- let i = Math.max(0, Of({ value: n })), a = Math.max(0, i - t);
16889
+ let i = Math.max(0, Cf({ value: n })), a = Math.max(0, i - t);
16892
16890
  return Math.min(Math.max(0, r), a);
16893
16891
  }
16894
- function Af({ rect: e }) {
16895
- return e.width >= Lu && e.height >= Lu;
16892
+ function Tf({ rect: e }) {
16893
+ return e.width >= Mu && e.height >= Mu;
16896
16894
  }
16897
- function jf({ session: e }) {
16898
- let t = zu({
16895
+ function Ef({ session: e }) {
16896
+ let t = Pu({
16899
16897
  source: e.source,
16900
16898
  frame: e.frame
16901
16899
  }), n = Z({ source: e.source });
@@ -16906,8 +16904,8 @@ function jf({ session: e }) {
16906
16904
  height: t.height
16907
16905
  };
16908
16906
  }
16909
- function Mf({ target: e, frame: t }) {
16910
- let n = zu({
16907
+ function Df({ target: e, frame: t }) {
16908
+ let n = Pu({
16911
16909
  source: e,
16912
16910
  frame: t
16913
16911
  }), r = -e.width / 2, i = -e.height / 2;
@@ -16920,8 +16918,8 @@ function Mf({ target: e, frame: t }) {
16920
16918
  }
16921
16919
  //#endregion
16922
16920
  //#region src/editor/crop-manager/mutation/crop-apply.ts
16923
- function Nf({ editor: e, frame: t, rect: n }) {
16924
- return Af({ rect: n }) ? (Vf({
16921
+ function Of({ editor: e, frame: t, rect: n }) {
16922
+ return Tf({ rect: n }) ? (If({
16925
16923
  editor: e,
16926
16924
  frame: t,
16927
16925
  offset: new m(-n.left, -n.top)
@@ -16931,9 +16929,9 @@ function Nf({ editor: e, frame: t, rect: n }) {
16931
16929
  rect: n
16932
16930
  }) : null;
16933
16931
  }
16934
- function Pf({ editor: e, target: t, frame: n, rect: r }) {
16935
- if (!Af({ rect: r })) return null;
16936
- let i = Ff({
16932
+ function kf({ editor: e, target: t, frame: n, rect: r }) {
16933
+ if (!Tf({ rect: r })) return null;
16934
+ let i = Af({
16937
16935
  target: t,
16938
16936
  frame: n,
16939
16937
  rect: r
@@ -16944,21 +16942,21 @@ function Pf({ editor: e, target: t, frame: n, rect: r }) {
16944
16942
  rect: i
16945
16943
  }) : null;
16946
16944
  }
16947
- function Ff({ target: e, frame: t, rect: n }) {
16948
- let r = Math.max(Lu, n.width), i = Math.max(Lu, n.height), a = {
16945
+ function Af({ target: e, frame: t, rect: n }) {
16946
+ let r = Math.max(Mu, n.width), i = Math.max(Mu, n.height), a = {
16949
16947
  width: r,
16950
16948
  height: i
16951
16949
  };
16952
- if (If({
16950
+ if (jf({
16953
16951
  target: e,
16954
16952
  rect: n
16955
- })) Lf({
16953
+ })) Mf({
16956
16954
  target: e,
16957
16955
  size: a,
16958
16956
  rect: n
16959
16957
  });
16960
16958
  else {
16961
- let t = Rf({
16959
+ let t = Nf({
16962
16960
  target: e,
16963
16961
  size: a,
16964
16962
  rect: n
@@ -16978,10 +16976,10 @@ function Ff({ target: e, frame: t, rect: n }) {
16978
16976
  height: i
16979
16977
  };
16980
16978
  }
16981
- function If({ target: e, rect: t }) {
16979
+ function jf({ target: e, rect: t }) {
16982
16980
  return t.left >= 0 && t.top >= 0 && t.left + t.width <= e.width && t.top + t.height <= e.height;
16983
16981
  }
16984
- function Lf({ target: e, size: t, rect: n }) {
16982
+ function Mf({ target: e, size: t, rect: n }) {
16985
16983
  let r = (e.cropX ?? 0) + n.left, i = (e.cropY ?? 0) + n.top;
16986
16984
  e.set({
16987
16985
  cropX: r,
@@ -16990,25 +16988,25 @@ function Lf({ target: e, size: t, rect: n }) {
16990
16988
  height: t.height
16991
16989
  });
16992
16990
  }
16993
- function Rf({ target: e, size: t, rect: n }) {
16994
- let r = e.getElement(), i = zf({ target: e });
16991
+ function Nf({ target: e, size: t, rect: n }) {
16992
+ let r = e.getElement(), i = Pf({ target: e });
16995
16993
  if (!r || !i) return null;
16996
16994
  let a = i.createElement("canvas");
16997
16995
  a.width = Math.round(t.width), a.height = Math.round(t.height);
16998
16996
  let o = a.getContext("2d");
16999
16997
  if (!o) return null;
17000
- let s = Bf({
16998
+ let s = Ff({
17001
16999
  target: e,
17002
17000
  size: t,
17003
17001
  rect: n
17004
17002
  });
17005
17003
  return s && o.drawImage(r, s.sourceX, s.sourceY, s.sourceWidth, s.sourceHeight, s.destinationX, s.destinationY, s.sourceWidth, s.sourceHeight), a;
17006
17004
  }
17007
- function zf({ target: e }) {
17005
+ function Pf({ target: e }) {
17008
17006
  let t = e.canvas?.getElement();
17009
17007
  return t?.ownerDocument ? t.ownerDocument : typeof document < "u" ? document : null;
17010
17008
  }
17011
- function Bf({ target: e, size: t, rect: n }) {
17009
+ function Ff({ target: e, size: t, rect: n }) {
17012
17010
  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;
17013
17011
  return s <= 0 || c <= 0 ? null : {
17014
17012
  sourceX: (e.cropX ?? 0) + r,
@@ -17019,7 +17017,7 @@ function Bf({ target: e, size: t, rect: n }) {
17019
17017
  destinationY: i - n.top
17020
17018
  };
17021
17019
  }
17022
- function Vf({ editor: e, frame: t, offset: n }) {
17020
+ function If({ editor: e, frame: t, offset: n }) {
17023
17021
  e.canvasManager.getObjects().forEach((e) => {
17024
17022
  e !== t && (e.set({
17025
17023
  left: (e.left ?? 0) + n.x,
@@ -17029,12 +17027,12 @@ function Vf({ editor: e, frame: t, offset: n }) {
17029
17027
  }
17030
17028
  //#endregion
17031
17029
  //#region src/editor/crop-manager/index.ts
17032
- var Hf = {
17030
+ var Lf = {
17033
17031
  allowFrameOverflow: !0,
17034
17032
  showGrid: !0,
17035
17033
  cancelOnSelectionClear: !0,
17036
17034
  preserveAspectRatio: !0
17037
- }, Uf = .5, Wf = 1e-9, Gf = 1, Kf = class {
17035
+ }, Rf = .5, zf = 1e-9, Bf = 1, Vf = class {
17038
17036
  constructor({ editor: e }) {
17039
17037
  this._handleCropFrameChanged = (e) => {
17040
17038
  let { _session: t } = this;
@@ -17053,11 +17051,11 @@ var Hf = {
17053
17051
  }), n || this._rememberSourceBoundFrameIfNeeded({
17054
17052
  session: t,
17055
17053
  event: e
17056
- }), Il({ transform: e?.transform }) && (this._activeResizePreserveAspectRatio = t.effectivePreserveAspectRatio), this.editor.canvas.fire("editor:crop:changed", this.getState()), this.editor.canvas.requestRenderAll();
17054
+ }), jl({ transform: e?.transform }) && (this._activeResizePreserveAspectRatio = t.effectivePreserveAspectRatio), this.editor.canvas.fire("editor:crop:changed", this.getState()), this.editor.canvas.requestRenderAll();
17057
17055
  }, this._handleCropFrameModified = (e) => {
17058
17056
  this._handleCropFrameChanged(e);
17059
17057
  let { _session: t } = this;
17060
- t && (gf({
17058
+ t && (df({
17061
17059
  frame: t.frame,
17062
17060
  preserveAspectRatio: null
17063
17061
  }), this._activeResizePreserveAspectRatio = null, t.effectivePreserveAspectRatio = t.options.preserveAspectRatio);
@@ -17077,14 +17075,14 @@ var Hf = {
17077
17075
  getState() {
17078
17076
  let { _session: e } = this;
17079
17077
  if (!e) return null;
17080
- let t = Ef({ session: e }), n = e.options.allowFrameOverflow ? void 0 : Z({ source: e.source });
17078
+ let t = xf({ session: e }), n = e.options.allowFrameOverflow ? void 0 : Z({ source: e.source });
17081
17079
  return {
17082
17080
  mode: e.mode,
17083
17081
  frame: e.frame,
17084
17082
  options: e.options,
17085
17083
  target: e.target,
17086
17084
  effectivePreserveAspectRatio: e.effectivePreserveAspectRatio,
17087
- rect: Df({
17085
+ rect: Sf({
17088
17086
  rect: t,
17089
17087
  sourceSize: n
17090
17088
  })
@@ -17095,7 +17093,7 @@ var Hf = {
17095
17093
  }
17096
17094
  _getEffectivePreserveAspectRatio(e) {
17097
17095
  let { _session: t } = this;
17098
- return t ? this._isSourceScaleClamped({ event: e }) ? e?.transform?.cropSourceScalePreserveAspectRatio ?? !0 : Fl({
17096
+ return t ? this._isSourceScaleClamped({ event: e }) ? e?.transform?.cropSourceScalePreserveAspectRatio ?? !0 : Al({
17099
17097
  target: t.frame,
17100
17098
  shiftKey: e?.e?.shiftKey
17101
17099
  }) : !0;
@@ -17103,10 +17101,10 @@ var Hf = {
17103
17101
  isFrameOverflowingSource({ target: e }) {
17104
17102
  let { _session: t } = this;
17105
17103
  if (!t || !e || t.options.allowFrameOverflow || t.frame !== e) return !1;
17106
- let n = zu({
17104
+ let n = Pu({
17107
17105
  source: t.source,
17108
17106
  frame: t.frame
17109
- }), r = Z({ source: t.source }), i = -r.width / 2 - Uf, a = -r.height / 2 - Uf, o = r.width / 2 + Uf, s = r.height / 2 + Uf;
17107
+ }), r = Z({ source: t.source }), i = -r.width / 2 - Rf, a = -r.height / 2 - Rf, o = r.width / 2 + Rf, s = r.height / 2 + Rf;
17110
17108
  return n.left < i || n.top < a || n.left + n.width > o || n.top + n.height > s;
17111
17109
  }
17112
17110
  isFrameSourceScaleClamped({ target: e, transform: t }) {
@@ -17125,9 +17123,9 @@ var Hf = {
17125
17123
  return a ? (this._markSourceBoundScalePlan({
17126
17124
  transform: t,
17127
17125
  plan: a
17128
- }), wf({
17126
+ }), yf({
17129
17127
  frame: i.frame,
17130
- state: Sf({
17128
+ state: _f({
17131
17129
  source: i.source,
17132
17130
  frame: i.frame,
17133
17131
  rect: a.rect,
@@ -17164,7 +17162,7 @@ var Hf = {
17164
17162
  setAspectRatio({ aspectRatio: e }) {
17165
17163
  let { _session: t } = this;
17166
17164
  if (!t) return null;
17167
- let n = Ru({
17165
+ let n = Nu({
17168
17166
  sourceSize: Z({ source: t.source }),
17169
17167
  aspectRatio: e ?? void 0,
17170
17168
  allowOverflow: t.options.allowFrameOverflow
@@ -17177,7 +17175,7 @@ var Hf = {
17177
17175
  setSize({ size: e }) {
17178
17176
  let { _session: t } = this;
17179
17177
  if (!t) return null;
17180
- let n = Ru({
17178
+ let n = Nu({
17181
17179
  sourceSize: Z({ source: t.source }),
17182
17180
  size: e,
17183
17181
  allowOverflow: t.options.allowFrameOverflow
@@ -17194,10 +17192,10 @@ var Hf = {
17194
17192
  return n.options.preserveAspectRatio = e, this._setFramePreserveAspectRatio({
17195
17193
  frame: n.frame,
17196
17194
  preserveAspectRatio: e
17197
- }), gf({
17195
+ }), df({
17198
17196
  frame: n.frame,
17199
17197
  preserveAspectRatio: null
17200
- }), n.effectivePreserveAspectRatio = e, t && r !== null && (n.effectivePreserveAspectRatio = r, gf({
17198
+ }), n.effectivePreserveAspectRatio = e, t && r !== null && (n.effectivePreserveAspectRatio = r, df({
17201
17199
  frame: n.frame,
17202
17200
  preserveAspectRatio: r
17203
17201
  })), this.editor.canvas.requestRenderAll(), this.getState();
@@ -17280,16 +17278,16 @@ var Hf = {
17280
17278
  }
17281
17279
  _resolveSessionOptions({ options: e }) {
17282
17280
  return {
17283
- allowFrameOverflow: e.allowFrameOverflow ?? Hf.allowFrameOverflow,
17284
- showGrid: e.showGrid ?? Hf.showGrid,
17285
- cancelOnSelectionClear: e.cancelOnSelectionClear ?? Hf.cancelOnSelectionClear,
17286
- preserveAspectRatio: e.preserveAspectRatio ?? Hf.preserveAspectRatio
17281
+ allowFrameOverflow: e.allowFrameOverflow ?? Lf.allowFrameOverflow,
17282
+ showGrid: e.showGrid ?? Lf.showGrid,
17283
+ cancelOnSelectionClear: e.cancelOnSelectionClear ?? Lf.cancelOnSelectionClear,
17284
+ preserveAspectRatio: e.preserveAspectRatio ?? Lf.preserveAspectRatio
17287
17285
  };
17288
17286
  }
17289
17287
  _createCropFrameForSource({ source: e, options: t, sessionOptions: n }) {
17290
- return hf({
17288
+ return uf({
17291
17289
  source: e,
17292
- cropSize: Ru({
17290
+ cropSize: Nu({
17293
17291
  sourceSize: Z({ source: e }),
17294
17292
  size: t.size,
17295
17293
  aspectRatio: t.aspectRatio,
@@ -17301,7 +17299,7 @@ var Hf = {
17301
17299
  });
17302
17300
  }
17303
17301
  _setFramePreserveAspectRatio({ frame: e, preserveAspectRatio: t }) {
17304
- if (!(e instanceof mf)) throw Error("Crop session frame должен быть CropFrame");
17302
+ if (!(e instanceof lf)) throw Error("Crop session frame должен быть CropFrame");
17305
17303
  e.preserveAspectRatio = t;
17306
17304
  }
17307
17305
  _activateSession({ session: e }) {
@@ -17326,7 +17324,7 @@ var Hf = {
17326
17324
  session: e,
17327
17325
  event: t
17328
17326
  }) ?? e.sourceBoundFrameState;
17329
- return n ? (wf({
17327
+ return n ? (yf({
17330
17328
  frame: e.frame,
17331
17329
  state: n
17332
17330
  }), !0) : !1;
@@ -17335,7 +17333,7 @@ var Hf = {
17335
17333
  let n = t?.transform?.cropSourceBoundScale;
17336
17334
  if (!n || !Number.isFinite(n.scaleX) || !Number.isFinite(n.scaleY)) return null;
17337
17335
  let r = this._getSourceBoundRectFromEvent({ event: t });
17338
- return r ? Sf({
17336
+ return r ? _f({
17339
17337
  source: e.source,
17340
17338
  frame: e.frame,
17341
17339
  rect: r,
@@ -17365,16 +17363,16 @@ var Hf = {
17365
17363
  }) : !1;
17366
17364
  }
17367
17365
  _restoreFrameScaleAnchorFromTransform({ session: e, transform: t }) {
17368
- let n = Ef({ session: e }), r = this._getAnchoredSourceBoundRectFromTransform({
17366
+ let n = xf({ session: e }), r = this._getAnchoredSourceBoundRectFromTransform({
17369
17367
  transform: t,
17370
17368
  size: {
17371
17369
  width: n.width,
17372
17370
  height: n.height
17373
17371
  }
17374
17372
  });
17375
- return r ? (wf({
17373
+ return r ? (yf({
17376
17374
  frame: e.frame,
17377
- state: Sf({
17375
+ state: _f({
17378
17376
  source: e.source,
17379
17377
  frame: e.frame,
17380
17378
  rect: r,
@@ -17427,7 +17425,7 @@ var Hf = {
17427
17425
  e.sourceBoundFrameState = null;
17428
17426
  return;
17429
17427
  }
17430
- e.sourceBoundFrameState = Cf({ frame: e.frame });
17428
+ e.sourceBoundFrameState = vf({ frame: e.frame });
17431
17429
  }
17432
17430
  _isSourceScaleClamped({ event: e }) {
17433
17431
  return e?.transform?.cropSourceScaleClamped === !0;
@@ -17437,7 +17435,7 @@ var Hf = {
17437
17435
  if (!i || typeof a != "number" || typeof o != "number" || a === 0 || o === 0) return null;
17438
17436
  let s = n ?? e.scaleX ?? a, c = r ?? e.scaleY ?? o;
17439
17437
  if (!Number.isFinite(s) || !Number.isFinite(c)) return null;
17440
- let l = t.cropSourceScaleAnchorX ?? this._getTransformAnchorX({ transform: t }), u = t.cropSourceScaleAnchorY ?? this._getTransformAnchorY({ transform: t }), d = nd({
17438
+ let l = t.cropSourceScaleAnchorX ?? this._getTransformAnchorX({ transform: t }), u = t.cropSourceScaleAnchorY ?? this._getTransformAnchorY({ transform: t }), d = Zu({
17441
17439
  sourceSize: i.sourceSize,
17442
17440
  startRect: i.startRect,
17443
17441
  anchorX: l,
@@ -17445,7 +17443,7 @@ var Hf = {
17445
17443
  });
17446
17444
  if (!d) return null;
17447
17445
  let f = Math.max(Math.abs(s / a), Math.abs(c / o)), p = Math.max(0, d.scale - f) * Math.min(i.startRect.width, i.startRect.height);
17448
- if (f <= d.scale + Wf && p > Gf) return null;
17446
+ if (f <= d.scale + zf && p > Bf) return null;
17449
17447
  let m = {
17450
17448
  scaleX: a * d.scale,
17451
17449
  scaleY: o * d.scale
@@ -17506,28 +17504,28 @@ var Hf = {
17506
17504
  _clampFrameIfNeeded({ session: e, preserveAspectRatio: t = !1 }) {
17507
17505
  if (!e.options.allowFrameOverflow) {
17508
17506
  if (t) {
17509
- Vu({
17507
+ Iu({
17510
17508
  source: e.source,
17511
17509
  frame: e.frame
17512
17510
  });
17513
17511
  return;
17514
17512
  }
17515
- Bu({
17513
+ Fu({
17516
17514
  source: e.source,
17517
17515
  frame: e.frame
17518
17516
  });
17519
17517
  }
17520
17518
  }
17521
17519
  _applySessionCrop({ session: e }) {
17522
- let t = e.options.allowFrameOverflow ? void 0 : Z({ source: e.source }), n = Df({
17523
- rect: Ef({ session: e }),
17520
+ let t = e.options.allowFrameOverflow ? void 0 : Z({ source: e.source }), n = Sf({
17521
+ rect: xf({ session: e }),
17524
17522
  sourceSize: t
17525
17523
  });
17526
- return e.mode === "canvas" ? Nf({
17524
+ return e.mode === "canvas" ? Of({
17527
17525
  editor: this.editor,
17528
17526
  frame: e.frame,
17529
17527
  rect: n
17530
- }) : Pf({
17528
+ }) : kf({
17531
17529
  editor: this.editor,
17532
17530
  target: e.target,
17533
17531
  frame: e.frame,
@@ -17595,13 +17593,13 @@ var Hf = {
17595
17593
  }
17596
17594
  });
17597
17595
  }
17598
- }, qf = class e {
17596
+ }, Hf = class e {
17599
17597
  constructor(e, t) {
17600
17598
  this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
17601
17599
  }
17602
17600
  async init() {
17603
17601
  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;
17604
- if (_e.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new I(), this.workerManager = new te(), this.errorManager = new is({ editor: this }), this.historyManager = new Ut({ editor: this }), this.toolbar = new it({ editor: this }), this.transformManager = new sr({ editor: this }), this.zoomManager = new cr({ editor: this }), this.canvasManager = new or({ editor: this }), this.imageManager = new nr({ editor: this }), this.layerManager = new Yr({ editor: this }), this.shapeManager = new Xo({ editor: this }), this.interactionBlocker = new qr({ editor: this }), this.backgroundManager = new Jr({ editor: this }), this.clipboardManager = new Qo({ editor: this }), this.objectLockManager = new $o({ editor: this }), this.groupingManager = new es({ editor: this }), this.selectionManager = new ts({ editor: this }), this.deletionManager = new ns({ editor: this }), this.panConstraintManager = new os({ editor: this }), this.snappingManager = new Au({ editor: this }), this.measurementManager = new Mu({ editor: this }), this.fontManager = new ve(this.options.fonts ?? []), this.textManager = new Es({ editor: this }), this.templateManager = new Hs({ editor: this }), this.cropManager = new Kf({ editor: this }), u && (this.angleIndicator = new ct({ editor: this })), d && (this.objectSizeIndicator = new dt({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new F({
17602
+ if (_e.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new I(), this.workerManager = new te(), this.errorManager = new is({ editor: this }), this.historyManager = new Ut({ editor: this }), this.toolbar = new it({ editor: this }), this.transformManager = new sr({ editor: this }), this.zoomManager = new cr({ editor: this }), this.canvasManager = new or({ editor: this }), this.imageManager = new nr({ editor: this }), this.layerManager = new Yr({ editor: this }), this.shapeManager = new Xo({ editor: this }), this.interactionBlocker = new qr({ editor: this }), this.backgroundManager = new Jr({ editor: this }), this.clipboardManager = new Qo({ editor: this }), this.objectLockManager = new $o({ editor: this }), this.groupingManager = new es({ editor: this }), this.selectionManager = new ts({ editor: this }), this.deletionManager = new ns({ editor: this }), this.panConstraintManager = new os({ editor: this }), this.snappingManager = new Tu({ editor: this }), this.measurementManager = new Du({ editor: this }), this.fontManager = new ve(this.options.fonts ?? []), this.textManager = new Es({ editor: this }), this.templateManager = new Ls({ editor: this }), this.cropManager = new Vf({ editor: this }), u && (this.angleIndicator = new ct({ editor: this })), d && (this.objectSizeIndicator = new dt({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new F({
17605
17603
  editor: this,
17606
17604
  options: this.options
17607
17605
  }), 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 _t({ editor: this })), await this.fontManager.loadFonts(), c) {
@@ -17709,7 +17707,7 @@ var Hf = {
17709
17707
  "U+A640-A69F",
17710
17708
  "U+FE2E-FE2F",
17711
17709
  "U+2116"
17712
- ].join(", "), Jf = {
17710
+ ].join(", "), Uf = {
17713
17711
  preserveObjectStacking: !0,
17714
17712
  controlsAboveOverlay: !0,
17715
17713
  centeredRotation: !0,
@@ -18567,20 +18565,20 @@ var Hf = {
18567
18565
  };
18568
18566
  //#endregion
18569
18567
  //#region src/main.ts
18570
- function Yf(e, t = {}) {
18568
+ function Wf(e, t = {}) {
18571
18569
  let n = {
18572
- ...Jf,
18570
+ ...Uf,
18573
18571
  ...t
18574
18572
  }, r = document.getElementById(e);
18575
18573
  if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
18576
18574
  let i = document.createElement("canvas");
18577
18575
  return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
18578
18576
  n._onReadyCallback = t;
18579
- let r = new qf(i.id, n);
18577
+ let r = new Hf(i.id, n);
18580
18578
  window[e] = r;
18581
18579
  });
18582
18580
  }
18583
18581
  //#endregion
18584
- export { Yf as default };
18582
+ export { Wf as default };
18585
18583
 
18586
18584
  //# sourceMappingURL=main.js.map