@anu3ev/fabric-image-editor 0.1.42 → 0.1.43

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 +627 -714
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,12 +1,12 @@
1
- var Ee = Object.defineProperty;
1
+ var we = Object.defineProperty;
2
2
  var G = Object.getOwnPropertySymbols;
3
3
  var fe = Object.prototype.hasOwnProperty, je = Object.prototype.propertyIsEnumerable;
4
- var Me = (o, e, t) => e in o ? Ee(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, C = (o, e) => {
4
+ var me = (o, e, t) => e in o ? we(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, C = (o, e) => {
5
5
  for (var t in e || (e = {}))
6
- fe.call(e, t) && Me(o, t, e[t]);
6
+ fe.call(e, t) && me(o, t, e[t]);
7
7
  if (G)
8
8
  for (var t of G(e))
9
- je.call(e, t) && Me(o, t, e[t]);
9
+ je.call(e, t) && me(o, t, e[t]);
10
10
  return o;
11
11
  };
12
12
  var X = (o, e) => {
@@ -18,30 +18,30 @@ var X = (o, e) => {
18
18
  e.indexOf(a) < 0 && je.call(o, a) && (t[a] = o[a]);
19
19
  return t;
20
20
  };
21
- var Q = (o, e, t) => new Promise((a, r) => {
22
- var n = (c) => {
21
+ var Q = (o, e, t) => new Promise((a, n) => {
22
+ var i = (c) => {
23
23
  try {
24
24
  s(t.next(c));
25
25
  } catch (u) {
26
- r(u);
26
+ n(u);
27
27
  }
28
- }, i = (c) => {
28
+ }, r = (c) => {
29
29
  try {
30
30
  s(t.throw(c));
31
31
  } catch (u) {
32
- r(u);
32
+ n(u);
33
33
  }
34
- }, s = (c) => c.done ? a(c.value) : Promise.resolve(c.value).then(n, i);
34
+ }, s = (c) => c.done ? a(c.value) : Promise.resolve(c.value).then(i, r);
35
35
  s((t = t.apply(o, e)).next());
36
36
  });
37
- import { ActiveSelection as R, util as P, controlsUtils as Oe, InteractiveFabricObject as Te, loadSVGFromURL as ke, FabricImage as ee, Point as K, Rect as xe, Circle as Be, Triangle as Ze, Group as ze, Canvas as Ue, Pattern as Ye } from "fabric";
38
- import { create as _e } from "jsondiffpatch";
39
- var He = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", A = function() {
37
+ import { ActiveSelection as T, util as P, controlsUtils as Oe, InteractiveFabricObject as Te, loadSVGFromURL as ke, FabricImage as ee, Point as K, Rect as xe, Circle as Be, Triangle as Ze, Group as ze, Canvas as Ue, Pattern as _e } from "fabric";
38
+ import { create as He } from "jsondiffpatch";
39
+ var Ye = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", A = function() {
40
40
  for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", a = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
41
- t += He[a[e] & 63];
41
+ t += Ye[a[e] & 63];
42
42
  return t;
43
43
  };
44
- class H {
44
+ class R {
45
45
  /**
46
46
  * Конструктор принимает редактор и опции.
47
47
  * @param {Object} params
@@ -58,7 +58,7 @@ class H {
58
58
  * @param {Boolean} [params.options.resetObjectFitByDoubleClick] — сброс фита объекта по двойному клику
59
59
  */
60
60
  constructor({ editor: e, options: t = {} }) {
61
- this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound = H.debounce(this.handleContainerResize.bind(this), 500), this.handleCopyEventBound = this.handleCopyEvent.bind(this), this.handlePasteEventBound = this.handlePasteEvent.bind(this), this.handleUndoRedoEventBound = this.handleUndoRedoEvent.bind(this), this.handleUndoRedoKeyUpBound = this.handleUndoRedoKeyUp.bind(this), this.handleSelectAllEventBound = this.handleSelectAllEvent.bind(this), this.handleDeleteObjectsEventBound = this.handleDeleteObjectsEvent.bind(this), this.handleSpaceKeyDownBound = this.handleSpaceKeyDown.bind(this), this.handleSpaceKeyUpBound = this.handleSpaceKeyUp.bind(this), this.handleObjectModifiedHistoryBound = H.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = H.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
61
+ this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound = R.debounce(this.handleContainerResize.bind(this), 500), this.handleCopyEventBound = this.handleCopyEvent.bind(this), this.handlePasteEventBound = this.handlePasteEvent.bind(this), this.handleUndoRedoEventBound = this.handleUndoRedoEvent.bind(this), this.handleUndoRedoKeyUpBound = this.handleUndoRedoKeyUp.bind(this), this.handleSelectAllEventBound = this.handleSelectAllEvent.bind(this), this.handleDeleteObjectsEventBound = this.handleDeleteObjectsEvent.bind(this), this.handleSpaceKeyDownBound = this.handleSpaceKeyDown.bind(this), this.handleSpaceKeyUpBound = this.handleSpaceKeyUp.bind(this), this.handleObjectModifiedHistoryBound = R.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = R.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
62
62
  }
63
63
  /**
64
64
  * Инициализация всех обработчиков согласно опциям.
@@ -68,15 +68,15 @@ class H {
68
68
  adaptCanvasToContainerOnResize: e,
69
69
  canvasDragging: t,
70
70
  mouseWheelZooming: a,
71
- bringToFrontOnSelection: r,
72
- copyObjectsByHotkey: n,
73
- pasteImageFromClipboard: i,
71
+ bringToFrontOnSelection: n,
72
+ copyObjectsByHotkey: i,
73
+ pasteImageFromClipboard: r,
74
74
  undoRedoByHotKeys: s,
75
75
  selectAllByHotkey: c,
76
76
  deleteObjectsByHotkey: u,
77
77
  resetObjectFitByDoubleClick: l
78
78
  } = this.options;
79
- t && (this.canvas.on("mouse:down", this.handleCanvasDragStartBound), this.canvas.on("mouse:move", this.handleCanvasDraggingBound), this.canvas.on("mouse:up", this.handleCanvasDragEndBound), document.addEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.addEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), a && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), r && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), l && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), e && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), n && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), i && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), s && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), c && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), u && document.addEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.canvas.on("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.on("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.on("object:added", this.handleObjectAddedHistoryBound), this.canvas.on("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.on("object:added", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleLockedSelectionBound), this.canvas.on("selection:updated", this.handleLockedSelectionBound);
79
+ t && (this.canvas.on("mouse:down", this.handleCanvasDragStartBound), this.canvas.on("mouse:move", this.handleCanvasDraggingBound), this.canvas.on("mouse:up", this.handleCanvasDragEndBound), document.addEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.addEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), a && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), n && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), l && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), e && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), i && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), r && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), s && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), c && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), u && document.addEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.canvas.on("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.on("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.on("object:added", this.handleObjectAddedHistoryBound), this.canvas.on("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.on("object:added", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleLockedSelectionBound), this.canvas.on("selection:updated", this.handleLockedSelectionBound);
80
80
  }
81
81
  /**
82
82
  * При массовом выделении объектов удаляем из него залоченные.
@@ -85,20 +85,20 @@ class H {
85
85
  * @param {TPointerEvent} [params.e] - событие указателя (опционально)
86
86
  */
87
87
  _filterLockedSelection({ selected: e, e: t }) {
88
- if (!(e != null && e.length) || !(t instanceof MouseEvent) || e.length === 1 || !e.some((i) => i.locked)) return;
89
- const r = e.filter((i) => !i.locked);
90
- if (r.length === 0) {
88
+ if (!(e != null && e.length) || !(t instanceof MouseEvent) || e.length === 1 || !e.some((r) => r.locked)) return;
89
+ const n = e.filter((r) => !r.locked);
90
+ if (n.length === 0) {
91
91
  this.canvas.discardActiveObject();
92
92
  return;
93
93
  }
94
- if (r.length === 1) {
95
- this.canvas.setActiveObject(r[0]);
94
+ if (n.length === 1) {
95
+ this.canvas.setActiveObject(n[0]);
96
96
  return;
97
97
  }
98
- const n = new R(r, {
98
+ const i = new T(n, {
99
99
  canvas: this.canvas
100
100
  });
101
- this.canvas.setActiveObject(n), this.canvas.requestRenderAll();
101
+ this.canvas.setActiveObject(i), this.canvas.requestRenderAll();
102
102
  }
103
103
  /**
104
104
  * Обработчики для сохранения состояния редактора в истории.
@@ -139,8 +139,8 @@ class H {
139
139
  * @param {String} event.code — код клавиши
140
140
  */
141
141
  handleCopyEvent(e) {
142
- const { ctrlKey: t, metaKey: a, code: r } = e;
143
- !t && !a || r !== "KeyC" || (e.preventDefault(), this.editor.clipboardManager.copy());
142
+ const { ctrlKey: t, metaKey: a, code: n } = e;
143
+ !t && !a || n !== "KeyC" || (e.preventDefault(), this.editor.clipboardManager.copy());
144
144
  }
145
145
  /**
146
146
  * Обработчик вставки объекта или изображения из буфера обмена.
@@ -158,8 +158,8 @@ class H {
158
158
  */
159
159
  handleUndoRedoEvent(e) {
160
160
  return Q(this, null, function* () {
161
- const { ctrlKey: t, metaKey: a, code: r, repeat: n } = e;
162
- !t && !a || n || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (r === "KeyZ" ? (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : r === "KeyY" && (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
161
+ const { ctrlKey: t, metaKey: a, code: n, repeat: i } = e;
162
+ !t && !a || i || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (n === "KeyZ" ? (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : n === "KeyY" && (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
163
163
  });
164
164
  }
165
165
  /**
@@ -178,8 +178,8 @@ class H {
178
178
  * @param {String} event.code — код клавиши
179
179
  */
180
180
  handleSelectAllEvent(e) {
181
- const { ctrlKey: t, metaKey: a, code: r } = e;
182
- !t && !a || r !== "KeyA" || (e.preventDefault(), this.editor.selectionManager.selectAll());
181
+ const { ctrlKey: t, metaKey: a, code: n } = e;
182
+ !t && !a || n !== "KeyA" || (e.preventDefault(), this.editor.selectionManager.selectAll());
183
183
  }
184
184
  /**
185
185
  * Обработчик для удаления объектов (Delete).
@@ -197,12 +197,12 @@ class H {
197
197
  */
198
198
  handleSpaceKeyDown(e) {
199
199
  if (e.code !== "Space") return;
200
- const { canvas: t, editor: a, isSpacePressed: r, isDragging: n } = this;
201
- r || n || (this.isSpacePressed = !0, e.preventDefault(), t.set({
200
+ const { canvas: t, editor: a, isSpacePressed: n, isDragging: i } = this;
201
+ n || i || (this.isSpacePressed = !0, e.preventDefault(), t.set({
202
202
  selection: !1,
203
203
  defaultCursor: "grab"
204
- }), t.setCursor("grab"), a.canvasManager.getObjects().forEach((i) => {
205
- i.set({
204
+ }), t.setCursor("grab"), a.canvasManager.getObjects().forEach((r) => {
205
+ r.set({
206
206
  selectable: !1,
207
207
  evented: !1
208
208
  });
@@ -296,10 +296,10 @@ class H {
296
296
  */
297
297
  static debounce(e, t) {
298
298
  let a = null;
299
- return function(...r) {
300
- const n = this;
299
+ return function(...n) {
300
+ const i = this;
301
301
  a && clearTimeout(a), a = setTimeout(() => {
302
- e.apply(n, r);
302
+ e.apply(i, n);
303
303
  }, t);
304
304
  };
305
305
  }
@@ -348,11 +348,11 @@ class Pe {
348
348
  data: t
349
349
  } = e, {
350
350
  requestId: a,
351
- success: r,
352
- data: n,
353
- error: i
351
+ success: n,
352
+ data: i,
353
+ error: r
354
354
  } = t, s = this._callbacks.get(a);
355
- s && (r ? s.resolve(n) : s.reject(new Error(i)), this._callbacks.delete(a));
355
+ s && (n ? s.resolve(i) : s.reject(new Error(r)), this._callbacks.delete(a));
356
356
  }
357
357
  /**
358
358
  * Универсальный метод отправки команды в воркер
@@ -362,15 +362,15 @@ class Pe {
362
362
  * @returns {Promise<any>}
363
363
  */
364
364
  post(e, t) {
365
- var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], r = "".concat(e, ":").concat(A(8));
366
- return new Promise((n, i) => {
367
- this._callbacks.set(r, {
368
- resolve: n,
369
- reject: i
365
+ var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], n = "".concat(e, ":").concat(A(8));
366
+ return new Promise((i, r) => {
367
+ this._callbacks.set(n, {
368
+ resolve: i,
369
+ reject: r
370
370
  }), this.worker.postMessage({
371
371
  action: e,
372
372
  payload: t,
373
- requestId: r
373
+ requestId: n
374
374
  }, a);
375
375
  });
376
376
  }
@@ -381,24 +381,24 @@ class Pe {
381
381
  this.worker.terminate();
382
382
  }
383
383
  }
384
- var I = 12, Fe = 2, ae = 8, re = 20, We = 100, ne = 20, ie = 8, Ve = 100, se = 32, oe = 1, Ge = "#2B2D33", ce = "#3D8BF4", ue = "#FFFFFF";
385
- function J(o, e, t, a, r) {
386
- var n = I, i = Fe;
387
- o.save(), o.translate(e, t), o.rotate(P.degreesToRadians(r.angle)), o.fillStyle = ue, o.strokeStyle = ce, o.lineWidth = oe, o.beginPath(), o.roundRect(-12 / 2, -12 / 2, n, n, i), o.fill(), o.stroke(), o.restore();
384
+ var I = 12, We = 2, ae = 8, ne = 20, Fe = 100, ie = 20, re = 8, Ve = 100, se = 32, oe = 1, Ge = "#2B2D33", ce = "#3D8BF4", ue = "#FFFFFF";
385
+ function J(o, e, t, a, n) {
386
+ var i = I, r = We;
387
+ o.save(), o.translate(e, t), o.rotate(P.degreesToRadians(n.angle)), o.fillStyle = ue, o.strokeStyle = ce, o.lineWidth = oe, o.beginPath(), o.roundRect(-12 / 2, -12 / 2, i, i, r), o.fill(), o.stroke(), o.restore();
388
388
  }
389
- function ye(o, e, t, a, r) {
390
- var n = ae, i = re, s = We;
391
- o.save(), o.translate(e, t), o.rotate(P.degreesToRadians(r.angle)), o.fillStyle = ue, o.strokeStyle = ce, o.lineWidth = oe, o.beginPath(), o.roundRect(-8 / 2, -20 / 2, n, i, s), o.fill(), o.stroke(), o.restore();
389
+ function ye(o, e, t, a, n) {
390
+ var i = ae, r = ne, s = Fe;
391
+ o.save(), o.translate(e, t), o.rotate(P.degreesToRadians(n.angle)), o.fillStyle = ue, o.strokeStyle = ce, o.lineWidth = oe, o.beginPath(), o.roundRect(-8 / 2, -20 / 2, i, r, s), o.fill(), o.stroke(), o.restore();
392
392
  }
393
- function pe(o, e, t, a, r) {
394
- var n = ne, i = ie, s = Ve;
395
- o.save(), o.translate(e, t), o.rotate(P.degreesToRadians(r.angle)), o.fillStyle = ue, o.strokeStyle = ce, o.lineWidth = oe, o.beginPath(), o.roundRect(-20 / 2, -8 / 2, n, i, s), o.fill(), o.stroke(), o.restore();
393
+ function be(o, e, t, a, n) {
394
+ var i = ie, r = re, s = Ve;
395
+ o.save(), o.translate(e, t), o.rotate(P.degreesToRadians(n.angle)), o.fillStyle = ue, o.strokeStyle = ce, o.lineWidth = oe, o.beginPath(), o.roundRect(-20 / 2, -8 / 2, i, r, s), o.fill(), o.stroke(), o.restore();
396
396
  }
397
397
  var Xe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", Ce = new Image();
398
398
  Ce.src = Xe;
399
- function Qe(o, e, t, a, r) {
400
- var n = se, i = n / 2;
401
- o.save(), o.translate(e, t), o.rotate(P.degreesToRadians(r.angle)), o.fillStyle = Ge, o.beginPath(), o.arc(0, 0, i, 0, 2 * Math.PI), o.fill(), o.drawImage(Ce, -16 / 2, -16 / 2, i, i), o.restore();
399
+ function Qe(o, e, t, a, n) {
400
+ var i = se, r = i / 2;
401
+ o.save(), o.translate(e, t), o.rotate(P.degreesToRadians(n.angle)), o.fillStyle = Ge, o.beginPath(), o.arc(0, 0, r, 0, 2 * Math.PI), o.fill(), o.drawImage(Ce, -16 / 2, -16 / 2, r, r), o.restore();
402
402
  }
403
403
  var Je = {
404
404
  // Угловые точки
@@ -434,29 +434,29 @@ var Je = {
434
434
  ml: {
435
435
  render: ye,
436
436
  sizeX: ae,
437
- sizeY: re,
437
+ sizeY: ne,
438
438
  offsetX: 0,
439
439
  offsetY: 0
440
440
  },
441
441
  mr: {
442
442
  render: ye,
443
443
  sizeX: ae,
444
- sizeY: re,
444
+ sizeY: ne,
445
445
  offsetX: 0,
446
446
  offsetY: 0
447
447
  },
448
448
  // Середина горизонталей
449
449
  mt: {
450
- render: pe,
451
- sizeX: ne,
452
- sizeY: ie,
450
+ render: be,
451
+ sizeX: ie,
452
+ sizeY: re,
453
453
  offsetX: 0,
454
454
  offsetY: 0
455
455
  },
456
456
  mb: {
457
- render: pe,
458
- sizeX: ne,
459
- sizeY: ie,
457
+ render: be,
458
+ sizeX: ie,
459
+ sizeY: re,
460
460
  offsetX: 0,
461
461
  offsetY: 0
462
462
  },
@@ -473,45 +473,45 @@ class Ke {
473
473
  static apply() {
474
474
  var e = Oe.createObjectDefaultControls();
475
475
  Object.entries(Je).forEach((t) => {
476
- var [a, r] = t;
476
+ var [a, n] = t;
477
477
  Object.assign(e[a], {
478
- render: r.render,
479
- sizeX: r.sizeX,
480
- sizeY: r.sizeY,
481
- offsetX: r.offsetX,
482
- offsetY: r.offsetY
483
- }), a === "mtr" && (e[a].cursorStyle = "grab", e[a].mouseDownHandler = (n, i, s, c) => {
484
- var u = i.target;
478
+ render: n.render,
479
+ sizeX: n.sizeX,
480
+ sizeY: n.sizeY,
481
+ offsetX: n.offsetX,
482
+ offsetY: n.offsetY
483
+ }), a === "mtr" && (e[a].cursorStyle = "grab", e[a].mouseDownHandler = (i, r, s, c) => {
484
+ var u = r.target;
485
485
  u.canvas.setCursor("grabbing");
486
486
  });
487
487
  }), Te.ownDefaults.controls = e;
488
488
  }
489
489
  }
490
- var $e = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", qe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42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Tc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", rt = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==";
491
+ function pe(o, e, t, a, n, i, r) {
492
492
  try {
493
- var s = o[n](i), c = s.value;
493
+ var s = o[i](r), c = s.value;
494
494
  } catch (u) {
495
495
  return void t(u);
496
496
  }
497
- s.done ? e(c) : Promise.resolve(c).then(a, r);
497
+ s.done ? e(c) : Promise.resolve(c).then(a, n);
498
498
  }
499
499
  function st(o) {
500
500
  return function() {
501
501
  var e = this, t = arguments;
502
- return new Promise(function(a, r) {
503
- var n = o.apply(e, t);
504
- function i(c) {
505
- be(n, a, r, i, s, "next", c);
502
+ return new Promise(function(a, n) {
503
+ var i = o.apply(e, t);
504
+ function r(c) {
505
+ pe(i, a, n, r, s, "next", c);
506
506
  }
507
507
  function s(c) {
508
- be(n, a, r, i, s, "throw", c);
508
+ pe(i, a, n, r, s, "throw", c);
509
509
  }
510
- i(void 0);
510
+ r(void 0);
511
511
  });
512
512
  };
513
513
  }
514
- const _ = {
514
+ const Y = {
515
515
  style: {
516
516
  position: "absolute",
517
517
  display: "none",
@@ -571,11 +571,11 @@ const _ = {
571
571
  offsetTop: 50,
572
572
  icons: {
573
573
  copyPaste: $e,
574
- delete: it,
574
+ delete: rt,
575
575
  lock: qe,
576
576
  unlock: et,
577
- bringToFront: rt,
578
- sendToBack: nt,
577
+ bringToFront: nt,
578
+ sendToBack: it,
579
579
  bringForward: tt,
580
580
  sendBackwards: at
581
581
  },
@@ -616,8 +616,8 @@ function Ie(o, e) {
616
616
  var t = Object.keys(o);
617
617
  if (Object.getOwnPropertySymbols) {
618
618
  var a = Object.getOwnPropertySymbols(o);
619
- e && (a = a.filter(function(r) {
620
- return Object.getOwnPropertyDescriptor(o, r).enumerable;
619
+ e && (a = a.filter(function(n) {
620
+ return Object.getOwnPropertyDescriptor(o, n).enumerable;
621
621
  })), t.push.apply(t, a);
622
622
  }
623
623
  return t;
@@ -662,11 +662,11 @@ class dt {
662
662
  if (this.options = t.options, !!this.options.showToolbar) {
663
663
  this.editor = t, this.canvas = t.canvas;
664
664
  var a = this.options.toolbar || {};
665
- this.config = j(j(j({}, _), a), {}, {
666
- style: j(j({}, _.style), a.style || {}),
667
- btnStyle: j(j({}, _.btnStyle), a.btnStyle || {}),
668
- icons: j(j({}, _.icons), a.icons || {}),
669
- handlers: j(j({}, _.handlers), a.handlers || {})
665
+ this.config = j(j(j({}, Y), a), {}, {
666
+ style: j(j({}, Y.style), a.style || {}),
667
+ btnStyle: j(j({}, Y.btnStyle), a.btnStyle || {}),
668
+ icons: j(j({}, Y.icons), a.icons || {}),
669
+ handlers: j(j({}, Y.handlers), a.handlers || {})
670
670
  }), this.currentTarget = null, this.currentLocked = null, this.isTransforming = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
671
671
  this.el.style.display = "none";
672
672
  }, this._createDOM(), this._bindEvents();
@@ -700,19 +700,19 @@ class dt {
700
700
  this.el.innerHTML = "";
701
701
  var a = function() {
702
702
  var {
703
- name: i,
703
+ name: r,
704
704
  handle: s
705
- } = r, {
705
+ } = n, {
706
706
  icons: c,
707
707
  btnStyle: u,
708
708
  handlers: l
709
709
  } = t.config, d = document.createElement("button");
710
- d.innerHTML = c[s] ? '<img src="'.concat(c[s], '" title="').concat(i, '" />') : i, Object.assign(d.style, u), d.onclick = () => {
710
+ d.innerHTML = c[s] ? '<img src="'.concat(c[s], '" title="').concat(r, '" />') : r, Object.assign(d.style, u), d.onclick = () => {
711
711
  var h;
712
712
  return (h = l[s]) === null || h === void 0 ? void 0 : h.call(l, t.editor);
713
713
  }, t.el.appendChild(d);
714
714
  };
715
- for (var r of e)
715
+ for (var n of e)
716
716
  a();
717
717
  }
718
718
  /**
@@ -779,15 +779,15 @@ class dt {
779
779
  var {
780
780
  el: t,
781
781
  config: a,
782
- canvas: r
782
+ canvas: n
783
783
  } = this;
784
784
  e.setCoords();
785
- var n = r.getZoom(), [, , , , i, s] = r.viewportTransform, {
785
+ var i = n.getZoom(), [, , , , r, s] = n.viewportTransform, {
786
786
  x: c
787
787
  } = e.getCenterPoint(), {
788
788
  top: u,
789
789
  height: l
790
- } = e.getBoundingRect(!1, !0), d = c * n + i, h = d - t.offsetWidth / 2, g = (u + l) * n + s + a.offsetTop;
790
+ } = e.getBoundingRect(!1, !0), d = c * i + r, h = d - t.offsetWidth / 2, g = (u + l) * i + s + a.offsetTop;
791
791
  Object.assign(t.style, {
792
792
  left: "".concat(h, "px"),
793
793
  top: "".concat(g, "px"),
@@ -802,26 +802,26 @@ class dt {
802
802
  this.el.removeEventListener("mouseover", this._onBtnOver), this.el.removeEventListener("mouseout", this._onBtnOut), this.canvas.off("mouse:down", this._onMouseDown), this.canvas.off("object:moving", this._onObjectMoving), this.canvas.off("object:scaling", this._onObjectScaling), this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:created", this._onSelectionChange), this.canvas.off("selection:updated", this._onSelectionChange), this.canvas.off("selection:changed", this._onSelectionChange), this.canvas.off("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
803
803
  }
804
804
  }
805
- function Ae(o, e, t, a, r, n, i) {
805
+ function Ae(o, e, t, a, n, i, r) {
806
806
  try {
807
- var s = o[n](i), c = s.value;
807
+ var s = o[i](r), c = s.value;
808
808
  } catch (u) {
809
809
  return void t(u);
810
810
  }
811
- s.done ? e(c) : Promise.resolve(c).then(a, r);
811
+ s.done ? e(c) : Promise.resolve(c).then(a, n);
812
812
  }
813
813
  function te(o) {
814
814
  return function() {
815
815
  var e = this, t = arguments;
816
- return new Promise(function(a, r) {
817
- var n = o.apply(e, t);
818
- function i(c) {
819
- Ae(n, a, r, i, s, "next", c);
816
+ return new Promise(function(a, n) {
817
+ var i = o.apply(e, t);
818
+ function r(c) {
819
+ Ae(i, a, n, r, s, "next", c);
820
820
  }
821
821
  function s(c) {
822
- Ae(n, a, r, i, s, "throw", c);
822
+ Ae(i, a, n, r, s, "throw", c);
823
823
  }
824
- i(void 0);
824
+ r(void 0);
825
825
  });
826
826
  };
827
827
  }
@@ -844,7 +844,7 @@ class lt {
844
844
  return this.patches[this.currentIndex - 1] || null;
845
845
  }
846
846
  _createDiffPatcher() {
847
- this.diffPatcher = _e({
847
+ this.diffPatcher = He({
848
848
  objectHash(e) {
849
849
  return [e.id, e.format, e.locked, e.left, e.top, e.width, e.height, e.flipX, e.flipY, e.scaleX, e.scaleY, e.angle, e.opacity].join("-");
850
850
  },
@@ -887,9 +887,9 @@ class lt {
887
887
  baseState: e,
888
888
  currentIndex: t,
889
889
  patches: a
890
- } = this, r = JSON.parse(JSON.stringify(e)), n = 0; n < t; n += 1)
891
- r = this.diffPatcher.patch(r, a[n].diff);
892
- return console.log("getFullState state", r), r;
890
+ } = this, n = JSON.parse(JSON.stringify(e)), i = 0; i < t; i += 1)
891
+ n = this.diffPatcher.patch(n, a[i].diff);
892
+ return console.log("getFullState state", n), n;
893
893
  }
894
894
  /**
895
895
  * Сохраняем текущее состояние в виде диффа от последнего сохранённого полного состояния.
@@ -925,17 +925,17 @@ class lt {
925
925
  console.log("loadStateFromFullState fullState", e);
926
926
  var {
927
927
  canvas: a,
928
- canvasManager: r,
929
- interactionBlocker: n
928
+ canvasManager: n,
929
+ interactionBlocker: i
930
930
  } = t.editor, {
931
- width: i,
931
+ width: r,
932
932
  height: s
933
933
  } = a;
934
934
  yield a.loadFromJSON(e);
935
935
  var c = a.getObjects().find((l) => l.id === "montage-area");
936
- c && (t.editor.montageArea = c, (i !== e.width || s !== e.height) && r.updateCanvasAndFitObjects());
936
+ c && (t.editor.montageArea = c, (r !== e.width || s !== e.height) && n.updateCanvasAndFitObjects());
937
937
  var u = a.getObjects().find((l) => l.id === "overlay-mask");
938
- u && (n.overlayMask = u, n.overlayMask.visible = !1), a.renderAll(), a.fire("editor:history-state-loaded", {
938
+ u && (i.overlayMask = u, i.overlayMask.visible = !1), a.renderAll(), a.fire("editor:history-state-loaded", {
939
939
  fullState: e,
940
940
  currentIndex: t.currentIndex,
941
941
  totalChangesCount: t.totalChangesCount,
@@ -1015,27 +1015,27 @@ class lt {
1015
1015
  })();
1016
1016
  }
1017
1017
  }
1018
- const ht = 0.1, gt = 2, vt = 0.1, mt = 90, k = 16, x = 16, E = 4096, O = 4096;
1019
- function Se(o, e, t, a, r, n, i) {
1018
+ const ht = 0.1, gt = 2, vt = 0.1, Mt = 90, x = 16, B = 16, w = 4096, O = 4096;
1019
+ function Se(o, e, t, a, n, i, r) {
1020
1020
  try {
1021
- var s = o[n](i), c = s.value;
1021
+ var s = o[i](r), c = s.value;
1022
1022
  } catch (u) {
1023
1023
  return void t(u);
1024
1024
  }
1025
- s.done ? e(c) : Promise.resolve(c).then(a, r);
1025
+ s.done ? e(c) : Promise.resolve(c).then(a, n);
1026
1026
  }
1027
- function T(o) {
1027
+ function k(o) {
1028
1028
  return function() {
1029
1029
  var e = this, t = arguments;
1030
- return new Promise(function(a, r) {
1031
- var n = o.apply(e, t);
1032
- function i(c) {
1033
- Se(n, a, r, i, s, "next", c);
1030
+ return new Promise(function(a, n) {
1031
+ var i = o.apply(e, t);
1032
+ function r(c) {
1033
+ Se(i, a, n, r, s, "next", c);
1034
1034
  }
1035
1035
  function s(c) {
1036
- Se(n, a, r, i, s, "throw", c);
1036
+ Se(i, a, n, r, s, "throw", c);
1037
1037
  }
1038
- i(void 0);
1038
+ r(void 0);
1039
1039
  });
1040
1040
  };
1041
1041
  }
@@ -1064,15 +1064,15 @@ class D {
1064
1064
  */
1065
1065
  importImage(e) {
1066
1066
  var t = this;
1067
- return T(function* () {
1067
+ return k(function* () {
1068
1068
  var {
1069
1069
  source: a,
1070
- scale: r = "image-".concat(t.options.scaleType),
1071
- withoutSave: n = !1
1070
+ scale: n = "image-".concat(t.options.scaleType),
1071
+ withoutSave: i = !1
1072
1072
  } = e;
1073
1073
  if (!a) return null;
1074
1074
  var {
1075
- canvas: i,
1075
+ canvas: r,
1076
1076
  montageArea: s,
1077
1077
  transformManager: c,
1078
1078
  historyManager: u,
@@ -1082,12 +1082,12 @@ class D {
1082
1082
  acceptFormats: M
1083
1083
  } = t;
1084
1084
  if (!t.isAllowedContentType(d)) {
1085
- var m = "Неверный contentType для изображения: ".concat(d, ". Ожидается один из: ").concat(t.acceptContentTypes.join(", "), ".");
1085
+ var f = "Неверный contentType для изображения: ".concat(d, ". Ожидается один из: ").concat(t.acceptContentTypes.join(", "), ".");
1086
1086
  return l.emitError({
1087
1087
  origin: "ImageManager",
1088
1088
  method: "importImage",
1089
1089
  code: "INVALID_CONTENT_TYPE",
1090
- message: m,
1090
+ message: f,
1091
1091
  data: {
1092
1092
  source: a,
1093
1093
  format: h,
@@ -1099,9 +1099,9 @@ class D {
1099
1099
  }
1100
1100
  u.suspendHistory();
1101
1101
  try {
1102
- var f, v;
1102
+ var m, v;
1103
1103
  if (a instanceof File)
1104
- f = URL.createObjectURL(a);
1104
+ m = URL.createObjectURL(a);
1105
1105
  else if (typeof a == "string") {
1106
1106
  var S = yield fetch(a, {
1107
1107
  mode: "cors"
@@ -1109,7 +1109,7 @@ class D {
1109
1109
  type: d,
1110
1110
  quality: 1
1111
1111
  });
1112
- f = URL.createObjectURL(N);
1112
+ m = URL.createObjectURL(N);
1113
1113
  } else
1114
1114
  return l.emitError({
1115
1115
  origin: "ImageManager",
@@ -1124,73 +1124,73 @@ class D {
1124
1124
  acceptFormats: M
1125
1125
  }
1126
1126
  }), null;
1127
- if (t._createdBlobUrls.push(f), h === "svg") {
1128
- var L = yield ke(f);
1129
- v = P.groupSVGElements(L.objects, L.options);
1127
+ if (t._createdBlobUrls.push(m), h === "svg") {
1128
+ var E = yield ke(m);
1129
+ v = P.groupSVGElements(E.objects, E.options);
1130
1130
  } else
1131
- v = yield ee.fromURL(f, {
1131
+ v = yield ee.fromURL(m, {
1132
1132
  crossOrigin: "anonymous"
1133
1133
  });
1134
1134
  var {
1135
- width: w,
1135
+ width: L,
1136
1136
  height: y
1137
1137
  } = v;
1138
- if (y > O || w > E) {
1139
- var p = yield t.resizeImageToBoundaries(v._element.src, "max"), B = URL.createObjectURL(p);
1140
- t._createdBlobUrls.push(B), v = yield ee.fromURL(B, {
1138
+ if (y > O || L > w) {
1139
+ var b = yield t.resizeImageToBoundaries(v._element.src, "max"), Z = URL.createObjectURL(b);
1140
+ t._createdBlobUrls.push(Z), v = yield ee.fromURL(Z, {
1141
1141
  crossOrigin: "anonymous"
1142
1142
  });
1143
- } else if (y < x || w < k) {
1144
- var F = yield t.resizeImageToBoundaries(v._element.src, "min"), Z = URL.createObjectURL(F);
1145
- t._createdBlobUrls.push(Z), v = yield ee.fromURL(Z, {
1143
+ } else if (y < B || L < x) {
1144
+ var W = yield t.resizeImageToBoundaries(v._element.src, "min"), z = URL.createObjectURL(W);
1145
+ t._createdBlobUrls.push(z), v = yield ee.fromURL(z, {
1146
1146
  crossOrigin: "anonymous"
1147
1147
  });
1148
1148
  }
1149
- if (v.set("id", "".concat(v.type, "-").concat(A())), v.set("format", h), r === "scale-montage")
1149
+ if (v.set("id", "".concat(v.type, "-").concat(A())), v.set("format", h), n === "scale-montage")
1150
1150
  t.editor.canvasManager.scaleMontageAreaToImage({
1151
1151
  object: v,
1152
1152
  withoutSave: !0
1153
1153
  });
1154
1154
  else {
1155
1155
  var {
1156
- width: W,
1157
- height: z
1158
- } = s, U = t.calculateScaleFactor({
1156
+ width: F,
1157
+ height: U
1158
+ } = s, _ = t.calculateScaleFactor({
1159
1159
  imageObject: v,
1160
- scaleType: r
1160
+ scaleType: n
1161
1161
  });
1162
- r === "image-contain" && U < 1 ? c.fitObject({
1162
+ n === "image-contain" && _ < 1 ? c.fitObject({
1163
1163
  object: v,
1164
1164
  type: "contain",
1165
1165
  withoutSave: !0
1166
- }) : r === "image-cover" && (w > W || y > z) && c.fitObject({
1166
+ }) : n === "image-cover" && (L > F || y > U) && c.fitObject({
1167
1167
  object: v,
1168
1168
  type: "cover",
1169
1169
  withoutSave: !0
1170
1170
  });
1171
1171
  }
1172
- i.add(v), i.centerObject(v), i.setActiveObject(v), i.renderAll(), u.resumeHistory(), n || u.saveState();
1172
+ r.add(v), r.centerObject(v), r.setActiveObject(v), r.renderAll(), u.resumeHistory(), i || u.saveState();
1173
1173
  var V = {
1174
1174
  image: v,
1175
1175
  format: h,
1176
1176
  contentType: d,
1177
- scale: r,
1178
- withoutSave: n,
1177
+ scale: n,
1178
+ withoutSave: i,
1179
1179
  source: a
1180
1180
  };
1181
- return i.fire("editor:image-imported", V), V;
1182
- } catch (Y) {
1181
+ return r.fire("editor:image-imported", V), V;
1182
+ } catch (H) {
1183
1183
  return l.emitError({
1184
1184
  origin: "ImageManager",
1185
1185
  method: "importImage",
1186
1186
  code: "IMPORT_FAILED",
1187
- message: "Ошибка импорта изображения: ".concat(Y.message),
1187
+ message: "Ошибка импорта изображения: ".concat(H.message),
1188
1188
  data: {
1189
1189
  source: a,
1190
1190
  format: h,
1191
1191
  contentType: d,
1192
- scale: r,
1193
- withoutSave: n
1192
+ scale: n,
1193
+ withoutSave: i
1194
1194
  }
1195
1195
  }), u.resumeHistory(), null;
1196
1196
  }
@@ -1206,24 +1206,24 @@ class D {
1206
1206
  */
1207
1207
  resizeImageToBoundaries(e) {
1208
1208
  var t = arguments, a = this;
1209
- return T(function* () {
1210
- var r = t.length > 1 && t[1] !== void 0 ? t[1] : "max", n = "Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ".concat(E, "x").concat(O);
1211
- r === "min" && (n = "Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ".concat(k, "x").concat(x));
1212
- var i = {
1209
+ return k(function* () {
1210
+ var n = t.length > 1 && t[1] !== void 0 ? t[1] : "max", i = "Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ".concat(w, "x").concat(O);
1211
+ n === "min" && (i = "Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ".concat(x, "x").concat(B));
1212
+ var r = {
1213
1213
  dataURL: e,
1214
- sizeType: r,
1215
- maxWidth: E,
1214
+ sizeType: n,
1215
+ maxWidth: w,
1216
1216
  maxHeight: O,
1217
- minWidth: k,
1218
- minHeight: x
1217
+ minWidth: x,
1218
+ minHeight: B
1219
1219
  };
1220
1220
  return a.editor.errorManager.emitWarning({
1221
1221
  origin: "ImageManager",
1222
1222
  method: "resizeImageToBoundaries",
1223
1223
  code: "IMAGE_RESIZE_WARNING",
1224
- message: n,
1225
- data: i
1226
- }), a.editor.workerManager.post("resizeImage", i);
1224
+ message: i,
1225
+ data: r
1226
+ }), a.editor.workerManager.post("resizeImage", r);
1227
1227
  })();
1228
1228
  }
1229
1229
  /**
@@ -1239,75 +1239,75 @@ class D {
1239
1239
  */
1240
1240
  exportCanvasAsImageFile() {
1241
1241
  var e = arguments, t = this;
1242
- return T(function* () {
1242
+ return k(function* () {
1243
1243
  var {
1244
1244
  fileName: a = "image.png",
1245
- contentType: r = "image/png",
1246
- exportAsBase64: n = !1,
1247
- exportAsBlob: i = !1
1245
+ contentType: n = "image/png",
1246
+ exportAsBase64: i = !1,
1247
+ exportAsBlob: r = !1
1248
1248
  } = e.length > 0 && e[0] !== void 0 ? e[0] : {}, {
1249
1249
  canvas: s,
1250
1250
  montageArea: c,
1251
1251
  workerManager: u
1252
1252
  } = t.editor;
1253
1253
  try {
1254
- var l = r === "application/pdf", d = l ? "image/jpg" : r, h = D.getFormatFromContentType(d);
1254
+ var l = n === "application/pdf", d = l ? "image/jpg" : n, h = D.getFormatFromContentType(d);
1255
1255
  c.setCoords();
1256
1256
  var {
1257
1257
  left: g,
1258
1258
  top: M,
1259
- width: m,
1260
- height: f
1259
+ width: f,
1260
+ height: m
1261
1261
  } = c.getBoundingRect(), v = yield s.clone(["id", "format", "locked"]);
1262
1262
  ["image/jpg", "image/jpeg"].includes(d) && (v.backgroundColor = "#ffffff");
1263
- var S = v.getObjects().find((b) => b.id === c.id);
1263
+ var S = v.getObjects().find((p) => p.id === c.id);
1264
1264
  S.visible = !1, v.viewportTransform = [1, 0, 0, 1, -g, -M], v.setDimensions({
1265
- width: m,
1266
- height: f
1265
+ width: f,
1266
+ height: m
1267
1267
  }, {
1268
1268
  backstoreOnly: !0
1269
1269
  }), v.renderAll();
1270
- var N = v.getObjects().filter((b) => b.format).every((b) => b.format === "svg");
1270
+ var N = v.getObjects().filter((p) => p.format).every((p) => p.format === "svg");
1271
1271
  if (h === "svg" && N) {
1272
- var L = v.toSVG();
1272
+ var E = v.toSVG();
1273
1273
  v.dispose();
1274
- var w = D._exportSVGStringAsFile(L, {
1275
- exportAsBase64: n,
1276
- exportAsBlob: i,
1274
+ var L = D._exportSVGStringAsFile(E, {
1275
+ exportAsBase64: i,
1276
+ exportAsBlob: r,
1277
1277
  fileName: a
1278
1278
  }), y = {
1279
- image: w,
1279
+ image: L,
1280
1280
  format: "svg",
1281
1281
  contentType: "image/svg+xml",
1282
1282
  fileName: a.replace(/\.[^/.]+$/, ".svg")
1283
1283
  };
1284
1284
  return s.fire("editor:canvas-exported", y), y;
1285
1285
  }
1286
- var p = yield new Promise((b) => {
1287
- v.getElement().toBlob(b);
1286
+ var b = yield new Promise((p) => {
1287
+ v.getElement().toBlob(p);
1288
1288
  });
1289
- if (v.dispose(), i) {
1290
- var B = {
1291
- image: p,
1289
+ if (v.dispose(), r) {
1290
+ var Z = {
1291
+ image: b,
1292
1292
  format: h,
1293
1293
  contentType: d,
1294
1294
  fileName: a
1295
1295
  };
1296
- return s.fire("editor:canvas-exported", B), B;
1296
+ return s.fire("editor:canvas-exported", Z), Z;
1297
1297
  }
1298
- var F = yield createImageBitmap(p), Z = yield u.post("toDataURL", {
1298
+ var W = yield createImageBitmap(b), z = yield u.post("toDataURL", {
1299
1299
  format: h,
1300
1300
  quality: 1,
1301
- bitmap: F
1302
- }, [F]);
1301
+ bitmap: W
1302
+ }, [W]);
1303
1303
  if (l) {
1304
- var W = 0.264583, z = m * W, U = f * W, V = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, Y = new V({
1305
- orientation: z > U ? "landscape" : "portrait",
1304
+ var F = 0.264583, U = f * F, _ = m * F, V = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, H = new V({
1305
+ orientation: U > _ ? "landscape" : "portrait",
1306
1306
  unit: "mm",
1307
- format: [z, U]
1307
+ format: [U, _]
1308
1308
  });
1309
- if (Y.addImage(Z, "JPG", 0, 0, z, U), n) {
1310
- var De = Y.output("datauristring"), le = {
1309
+ if (H.addImage(z, "JPG", 0, 0, U, _), i) {
1310
+ var De = H.output("datauristring"), le = {
1311
1311
  image: De,
1312
1312
  format: "pdf",
1313
1313
  contentType: "application/pdf",
@@ -1315,45 +1315,45 @@ class D {
1315
1315
  };
1316
1316
  return s.fire("editor:canvas-exported", le), le;
1317
1317
  }
1318
- var Ne = Y.output("blob"), Le = new File([Ne], a, {
1318
+ var Ne = H.output("blob"), Ee = new File([Ne], a, {
1319
1319
  type: "application/pdf"
1320
1320
  }), he = {
1321
- image: Le,
1321
+ image: Ee,
1322
1322
  format: "pdf",
1323
1323
  contentType: "application/pdf",
1324
1324
  fileName: a
1325
1325
  };
1326
1326
  return s.fire("editor:canvas-exported", he), he;
1327
1327
  }
1328
- if (n) {
1328
+ if (i) {
1329
1329
  var ge = {
1330
- image: Z,
1330
+ image: z,
1331
1331
  format: h,
1332
1332
  contentType: d,
1333
1333
  fileName: a
1334
1334
  };
1335
1335
  return s.fire("editor:canvas-exported", ge), ge;
1336
1336
  }
1337
- var ve = h === "svg" && !N ? a.replace(/\.[^/.]+$/, ".png") : a, we = new File([p], ve, {
1337
+ var ve = h === "svg" && !N ? a.replace(/\.[^/.]+$/, ".png") : a, Le = new File([b], ve, {
1338
1338
  type: d
1339
- }), me = {
1340
- image: we,
1339
+ }), Me = {
1340
+ image: Le,
1341
1341
  format: h,
1342
1342
  contentType: d,
1343
1343
  fileName: ve
1344
1344
  };
1345
- return s.fire("editor:canvas-exported", me), me;
1346
- } catch (b) {
1345
+ return s.fire("editor:canvas-exported", Me), Me;
1346
+ } catch (p) {
1347
1347
  return t.editor.errorManager.emitError({
1348
1348
  origin: "ImageManager",
1349
1349
  method: "exportCanvasAsImageFile",
1350
1350
  code: "IMAGE_EXPORT_FAILED",
1351
- message: "Ошибка экспорта изображения: ".concat(b.message),
1351
+ message: "Ошибка экспорта изображения: ".concat(p.message),
1352
1352
  data: {
1353
- contentType: r,
1353
+ contentType: n,
1354
1354
  fileName: a,
1355
- exportAsBase64: n,
1356
- exportAsBlob: i
1355
+ exportAsBase64: i,
1356
+ exportAsBlob: r
1357
1357
  }
1358
1358
  }), "";
1359
1359
  }
@@ -1372,12 +1372,12 @@ class D {
1372
1372
  */
1373
1373
  exportObjectAsImageFile() {
1374
1374
  var e = arguments, t = this;
1375
- return T(function* () {
1375
+ return k(function* () {
1376
1376
  var {
1377
1377
  object: a,
1378
- fileName: r = "image.png",
1379
- contentType: n = "image/png",
1380
- exportAsBase64: i = !1,
1378
+ fileName: n = "image.png",
1379
+ contentType: i = "image/png",
1380
+ exportAsBase64: r = !1,
1381
1381
  exportAsBlob: s = !1
1382
1382
  } = e.length > 0 && e[0] !== void 0 ? e[0] : {}, {
1383
1383
  canvas: c,
@@ -1390,71 +1390,71 @@ class D {
1390
1390
  code: "NO_OBJECT_SELECTED",
1391
1391
  message: "Не выбран объект для экспорта",
1392
1392
  data: {
1393
- contentType: n,
1394
- fileName: r,
1395
- exportAsBase64: i,
1393
+ contentType: i,
1394
+ fileName: n,
1395
+ exportAsBase64: r,
1396
1396
  exportAsBlob: s
1397
1397
  }
1398
1398
  }), "";
1399
1399
  try {
1400
- var d = D.getFormatFromContentType(n);
1400
+ var d = D.getFormatFromContentType(i);
1401
1401
  if (d === "svg") {
1402
1402
  var h = l.toSVG(), g = t._exportSVGStringAsFile(h, {
1403
- exportAsBase64: i,
1403
+ exportAsBase64: r,
1404
1404
  exportAsBlob: s,
1405
- fileName: r
1405
+ fileName: n
1406
1406
  }), M = {
1407
1407
  image: g,
1408
1408
  format: d,
1409
1409
  contentType: "image/svg+xml",
1410
- fileName: r.replace(/\.[^/.]+$/, ".svg")
1410
+ fileName: n.replace(/\.[^/.]+$/, ".svg")
1411
1411
  };
1412
1412
  return c.fire("editor:object-exported", M), M;
1413
1413
  }
1414
- if (i) {
1415
- var m = yield createImageBitmap(l._element), f = yield u.post("toDataURL", {
1414
+ if (r) {
1415
+ var f = yield createImageBitmap(l._element), m = yield u.post("toDataURL", {
1416
1416
  format: d,
1417
1417
  quality: 1,
1418
- bitmap: m
1419
- }, [m]), v = {
1420
- image: f,
1418
+ bitmap: f
1419
+ }, [f]), v = {
1420
+ image: m,
1421
1421
  format: d,
1422
- contentType: n,
1423
- fileName: r
1422
+ contentType: i,
1423
+ fileName: n
1424
1424
  };
1425
1425
  return c.fire("editor:object-exported", v), v;
1426
1426
  }
1427
- var S = l.toCanvasElement(), N = yield new Promise((p) => {
1428
- S.toBlob(p);
1427
+ var S = l.toCanvasElement(), N = yield new Promise((b) => {
1428
+ S.toBlob(b);
1429
1429
  });
1430
1430
  if (s) {
1431
- var L = {
1431
+ var E = {
1432
1432
  image: N,
1433
1433
  format: d,
1434
- contentType: n,
1435
- fileName: r
1434
+ contentType: i,
1435
+ fileName: n
1436
1436
  };
1437
- return c.fire("editor:object-exported", L), L;
1437
+ return c.fire("editor:object-exported", E), E;
1438
1438
  }
1439
- var w = new File([N], r, {
1440
- type: n
1439
+ var L = new File([N], n, {
1440
+ type: i
1441
1441
  }), y = {
1442
- image: w,
1442
+ image: L,
1443
1443
  format: d,
1444
- contentType: n,
1445
- fileName: r
1444
+ contentType: i,
1445
+ fileName: n
1446
1446
  };
1447
1447
  return c.fire("editor:object-exported", y), y;
1448
- } catch (p) {
1448
+ } catch (b) {
1449
1449
  return t.editor.errorManager.emitError({
1450
1450
  origin: "ImageManager",
1451
1451
  method: "exportObjectAsImageFile",
1452
1452
  code: "IMAGE_EXPORT_FAILED",
1453
- message: "Ошибка экспорта объекта: ".concat(p.message),
1453
+ message: "Ошибка экспорта объекта: ".concat(b.message),
1454
1454
  data: {
1455
- contentType: n,
1456
- fileName: r,
1457
- exportAsBase64: i,
1455
+ contentType: i,
1456
+ fileName: n,
1457
+ exportAsBase64: r,
1458
1458
  exportAsBlob: s
1459
1459
  }
1460
1460
  }), "";
@@ -1483,11 +1483,11 @@ class D {
1483
1483
  var {
1484
1484
  exportAsBase64: t,
1485
1485
  exportAsBlob: a,
1486
- fileName: r
1486
+ fileName: n
1487
1487
  } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1488
1488
  return a ? new Blob([e], {
1489
1489
  type: "image/svg+xml"
1490
- }) : t ? "data:image/svg+xml;base64,".concat(btoa(e)) : new File([e], r.replace(/\.[^/.]+$/, ".svg"), {
1490
+ }) : t ? "data:image/svg+xml;base64,".concat(btoa(e)) : new File([e], n.replace(/\.[^/.]+$/, ".svg"), {
1491
1491
  type: "image/svg+xml"
1492
1492
  });
1493
1493
  }
@@ -1526,7 +1526,7 @@ class D {
1526
1526
  */
1527
1527
  getContentType(e) {
1528
1528
  var t = this;
1529
- return T(function* () {
1529
+ return k(function* () {
1530
1530
  return typeof e == "string" ? t.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
1531
1531
  })();
1532
1532
  }
@@ -1538,19 +1538,19 @@ class D {
1538
1538
  */
1539
1539
  getContentTypeFromUrl(e) {
1540
1540
  var t = this;
1541
- return T(function* () {
1541
+ return k(function* () {
1542
1542
  if (e.startsWith("data:")) {
1543
1543
  var a = e.match(/^data:([^;]+)/);
1544
1544
  return a ? a[1] : "application/octet-stream";
1545
1545
  }
1546
1546
  try {
1547
- var r = yield fetch(e, {
1547
+ var n = yield fetch(e, {
1548
1548
  method: "HEAD"
1549
- }), n = r.headers.get("content-type");
1550
- if (n && n.startsWith("image/"))
1551
- return n.split(";")[0];
1552
- } catch (i) {
1553
- console.warn("HEAD запрос неудачен, определяем тип по расширению:", i);
1549
+ }), i = n.headers.get("content-type");
1550
+ if (i && i.startsWith("image/"))
1551
+ return i.split(";")[0];
1552
+ } catch (r) {
1553
+ console.warn("HEAD запрос неудачен, определяем тип по расширению:", r);
1554
1554
  }
1555
1555
  return t.getContentTypeFromExtension(e);
1556
1556
  })();
@@ -1563,13 +1563,13 @@ class D {
1563
1563
  */
1564
1564
  getContentTypeFromExtension(e) {
1565
1565
  try {
1566
- var t, a = new URL(e), r = (t = a.pathname.split(".").pop()) === null || t === void 0 ? void 0 : t.toLowerCase(), n = {};
1567
- return this.acceptContentTypes.forEach((i) => {
1568
- var s = D.getFormatFromContentType(i);
1569
- s && (n[s] = i);
1570
- }), n[r] || "application/octet-stream";
1571
- } catch (i) {
1572
- return console.warn("Не удалось определить расширение из URL:", e, i), "application/octet-stream";
1566
+ var t, a = new URL(e), n = (t = a.pathname.split(".").pop()) === null || t === void 0 ? void 0 : t.toLowerCase(), i = {};
1567
+ return this.acceptContentTypes.forEach((r) => {
1568
+ var s = D.getFormatFromContentType(r);
1569
+ s && (i[s] = r);
1570
+ }), i[n] || "application/octet-stream";
1571
+ } catch (r) {
1572
+ return console.warn("Не удалось определить расширение из URL:", e, r), "application/octet-stream";
1573
1573
  }
1574
1574
  }
1575
1575
  /**
@@ -1583,26 +1583,23 @@ class D {
1583
1583
  imageObject: t,
1584
1584
  scaleType: a = "contain"
1585
1585
  } = e, {
1586
- montageArea: r
1586
+ montageArea: n
1587
1587
  } = this.editor;
1588
- if (!r || !t) return 1;
1589
- var n = r.width, i = r.height, {
1588
+ if (!n || !t) return 1;
1589
+ var i = n.width, r = n.height, {
1590
1590
  width: s,
1591
1591
  height: c
1592
1592
  } = t;
1593
- return a === "contain" || a === "image-contain" ? Math.min(n / s, i / c) : a === "cover" || a === "image-cover" ? Math.max(n / s, i / c) : 1;
1593
+ return a === "contain" || a === "image-contain" ? Math.min(i / s, r / c) : a === "cover" || a === "image-cover" ? Math.max(i / s, r / c) : 1;
1594
1594
  }
1595
1595
  }
1596
- class Mt {
1596
+ class mt {
1597
1597
  /**
1598
1598
  * @param {object} options
1599
1599
  * @param {ImageEditor} options.editor – экземпляр редактора
1600
1600
  */
1601
- constructor(e) {
1602
- var {
1603
- editor: t
1604
- } = e;
1605
- this.editor = t;
1601
+ constructor({ editor: e }) {
1602
+ this.editor = e;
1606
1603
  }
1607
1604
  /**
1608
1605
  * Устанавливаем внутреннюю ширину канваса (для экспорта)
@@ -1613,40 +1610,26 @@ class Mt {
1613
1610
  * @param {Boolean} [options.adaptCanvasToContainer] - Адаптировать канвас к контейнеру
1614
1611
  * @fires editor:resolution-width-changed
1615
1612
  */
1616
- setResolutionWidth(e) {
1617
- var {
1613
+ setResolutionWidth(e, { preserveProportional: t, withoutSave: a, adaptCanvasToContainer: n } = {}) {
1614
+ var M;
1615
+ if (!e) return;
1616
+ const {
1617
+ canvas: i,
1618
+ montageArea: r,
1619
+ options: { canvasBackstoreWidth: s }
1620
+ } = this.editor, { width: c, height: u } = r, l = Math.max(Math.min(Number(e), w), x);
1621
+ if (!s || s === "auto" || n ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreWidth(Number(s)) : this.setCanvasBackstoreWidth(l), r.set({ width: l }), (M = i.clipPath) == null || M.set({ width: l }), t) {
1622
+ const f = l / c, m = u * f;
1623
+ this.setResolutionHeight(m);
1624
+ return;
1625
+ }
1626
+ const { left: d, top: h } = this.getObjectDefaultCoords(r), g = i.getZoom();
1627
+ i.setViewportTransform([g, 0, 0, g, d, h]), this.centerMontageArea(), a || this.editor.historyManager.saveState(), i.fire("editor:resolution-width-changed", {
1628
+ width: l,
1618
1629
  preserveProportional: t,
1619
1630
  withoutSave: a,
1620
- adaptCanvasToContainer: r
1621
- } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1622
- if (e) {
1623
- var {
1624
- canvas: n,
1625
- montageArea: i,
1626
- options: {
1627
- canvasBackstoreWidth: s
1628
- }
1629
- } = this.editor, {
1630
- width: c,
1631
- height: u
1632
- } = i, l = Number(Math.max(Math.min(e, E), k));
1633
- if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreWidth(s) : this.setCanvasBackstoreWidth(l), i.set({
1634
- width: l
1635
- }), n.clipPath.set({
1636
- width: l
1637
- }), t) {
1638
- var d = l / c, h = u * d;
1639
- this.setResolutionHeight(h);
1640
- return;
1641
- }
1642
- var {
1643
- left: g,
1644
- top: M
1645
- } = this.getObjectDefaultCoords(i), m = n.getZoom();
1646
- n.setViewportTransform([m, 0, 0, m, g, M]), this.centerMontageArea(), a || this.editor.historyManager.saveState(), n == null || n.fire("editor:resolution-width-changed", {
1647
- width: e
1648
- });
1649
- }
1631
+ adaptCanvasToContainer: n
1632
+ });
1650
1633
  }
1651
1634
  /**
1652
1635
  * Устанавливаем внутреннюю высоту канваса (для экспорта)
@@ -1657,59 +1640,43 @@ class Mt {
1657
1640
  * @param {Boolean} [options.adaptCanvasToContainer] - Адаптировать канвас к контейнеру
1658
1641
  * @fires editor:resolution-height-changed
1659
1642
  */
1660
- setResolutionHeight(e) {
1661
- var {
1643
+ setResolutionHeight(e, { preserveProportional: t, withoutSave: a, adaptCanvasToContainer: n } = {}) {
1644
+ var M;
1645
+ if (!e) return;
1646
+ const {
1647
+ canvas: i,
1648
+ montageArea: r,
1649
+ options: { canvasBackstoreHeight: s }
1650
+ } = this.editor, { width: c, height: u } = r, l = Math.max(Math.min(Number(e), O), B);
1651
+ if (!s || s === "auto" || n ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreHeight(Number(s)) : this.setCanvasBackstoreHeight(l), r.set({ height: l }), (M = i.clipPath) == null || M.set({ height: l }), t) {
1652
+ const f = l / u, m = c * f;
1653
+ this.setResolutionWidth(m);
1654
+ return;
1655
+ }
1656
+ const { left: d, top: h } = this.getObjectDefaultCoords(r), g = i.getZoom();
1657
+ i.setViewportTransform([g, 0, 0, g, d, h]), this.centerMontageArea(), a || this.editor.historyManager.saveState(), i.fire("editor:resolution-height-changed", {
1658
+ height: l,
1662
1659
  preserveProportional: t,
1663
1660
  withoutSave: a,
1664
- adaptCanvasToContainer: r
1665
- } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1666
- if (e) {
1667
- var {
1668
- canvas: n,
1669
- montageArea: i,
1670
- options: {
1671
- canvasBackstoreHeight: s
1672
- }
1673
- } = this.editor, {
1674
- width: c,
1675
- height: u
1676
- } = i, l = Number(Math.max(Math.min(e, O), x));
1677
- if (!s || s === "auto" || r ? this.adaptCanvasToContainer() : s ? this.setCanvasBackstoreHeight(s) : this.setCanvasBackstoreHeight(l), i.set({
1678
- height: l
1679
- }), n.clipPath.set({
1680
- height: l
1681
- }), t) {
1682
- var d = l / u, h = c * d;
1683
- this.setResolutionWidth(h);
1684
- return;
1685
- }
1686
- var {
1687
- left: g,
1688
- top: M
1689
- } = this.getObjectDefaultCoords(i), m = n.getZoom();
1690
- n.setViewportTransform([m, 0, 0, m, g, M]), this.centerMontageArea(), a || this.editor.historyManager.saveState(), n == null || n.fire("editor:resolution-height-changed", {
1691
- height: e
1692
- });
1693
- }
1661
+ adaptCanvasToContainer: n
1662
+ });
1694
1663
  }
1695
1664
  /**
1696
1665
  * Центрирует монтажную область и ClipPath точно по центру канваса
1697
1666
  * и устанавливает правильный viewportTransform.
1698
1667
  */
1699
1668
  centerMontageArea() {
1700
- var {
1701
- canvas: e,
1702
- montageArea: t
1703
- } = this.editor, a = e.getWidth(), r = e.getHeight(), n = e.getZoom(), i = new K(a / 2, r / 2);
1669
+ var c;
1670
+ const { canvas: e, montageArea: t } = this.editor, a = e.getWidth(), n = e.getHeight(), i = e.getZoom(), r = new K(a / 2, n / 2);
1704
1671
  t.set({
1705
1672
  left: a / 2,
1706
- top: r / 2
1707
- }), e.clipPath.set({
1673
+ top: n / 2
1674
+ }), (c = e.clipPath) == null || c.set({
1708
1675
  left: a / 2,
1709
- top: r / 2
1676
+ top: n / 2
1710
1677
  }), e.renderAll();
1711
- var s = e.viewportTransform;
1712
- s[4] = a / 2 - i.x * n, s[5] = r / 2 - i.y * n, e.setViewportTransform(s), e.renderAll();
1678
+ const s = e.viewportTransform;
1679
+ s[4] = a / 2 - r.x * i, s[5] = n / 2 - r.y * i, e.setViewportTransform(s), e.renderAll();
1713
1680
  }
1714
1681
  /**
1715
1682
  * Метод для получения координат объекта с учетом текущего зума
@@ -1717,52 +1684,43 @@ class Mt {
1717
1684
  * @returns {Object} координаты объекта
1718
1685
  */
1719
1686
  getObjectDefaultCoords(e) {
1720
- var {
1721
- canvas: t
1722
- } = this.editor, a = e || t.getActiveObject();
1687
+ const { canvas: t } = this.editor, a = e || t.getActiveObject();
1723
1688
  if (!a)
1724
- return console.error("getObjectDefaultCoords. Не выбран объект"), this.editor.canvas.fire("editor:error", {
1689
+ return this.editor.errorManager.emitError({
1690
+ origin: "CanvasManager",
1691
+ method: "getObjectDefaultCoords",
1692
+ code: "NO_ACTIVE_OBJECT",
1725
1693
  message: "Не выбран объект для получения координат"
1726
- }), {};
1727
- var {
1728
- width: r,
1729
- height: n
1730
- } = a, i = t.getZoom(), s = (r - r * i) / 2, c = (n - n * i) / 2;
1731
- return {
1732
- left: s,
1733
- top: c
1734
- };
1694
+ }), { left: 0, top: 0 };
1695
+ const { width: n, height: i } = a, r = t.getZoom(), s = (n - n * r) / 2, c = (i - i * r) / 2;
1696
+ return { left: s, top: c };
1735
1697
  }
1698
+ /**
1699
+ * Устанавливаем ширину канваса в backstore (для экспорта)
1700
+ * @param {Number} width
1701
+ */
1736
1702
  setCanvasBackstoreWidth(e) {
1737
- if (!(!e || typeof e != "number")) {
1738
- var t = Math.max(Math.min(e, E), k);
1739
- this.editor.canvas.setDimensions({
1740
- width: t
1741
- }, {
1742
- backstoreOnly: !0
1743
- });
1744
- }
1703
+ if (!e || typeof e != "number") return;
1704
+ const t = Math.max(Math.min(e, w), x);
1705
+ this.editor.canvas.setDimensions({ width: t }, { backstoreOnly: !0 });
1745
1706
  }
1707
+ /**
1708
+ * Устанавливаем высоту канваса в backstore (для экспорта)
1709
+ * @param {Number} height
1710
+ */
1746
1711
  setCanvasBackstoreHeight(e) {
1747
- if (!(!e || typeof e != "number")) {
1748
- var t = Math.max(Math.min(e, O), x);
1749
- this.editor.canvas.setDimensions({
1750
- height: t
1751
- }, {
1752
- backstoreOnly: !0
1753
- });
1754
- }
1712
+ if (!e || typeof e != "number") return;
1713
+ const t = Math.max(Math.min(e, O), B);
1714
+ this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
1755
1715
  }
1716
+ /**
1717
+ * Адаптирует размеры канваса к размерам контейнера редактора.
1718
+ * Устанавливает ширину и высоту канваса в зависимости от размеров контейнера
1719
+ * с учётом минимальных и максимальных значений.
1720
+ */
1756
1721
  adaptCanvasToContainer() {
1757
- var {
1758
- canvas: e
1759
- } = this.editor, t = e.editorContainer, a = t.clientWidth, r = t.clientHeight, n = Math.max(Math.min(a, E), k), i = Math.max(Math.min(r, O), x);
1760
- console.log("adaptCanvasToContainer newWidth", n), console.log("adaptCanvasToContainer newHeight", i), e.setDimensions({
1761
- width: n,
1762
- height: i
1763
- }, {
1764
- backstoreOnly: !0
1765
- });
1722
+ const { canvas: e } = this.editor, t = e.editorContainer, a = t.clientWidth, n = t.clientHeight, i = Math.max(Math.min(a, w), x), r = Math.max(Math.min(n, O), B);
1723
+ console.log("adaptCanvasToContainer newWidth", i), console.log("adaptCanvasToContainer newHeight", r), e.setDimensions({ width: i, height: r }, { backstoreOnly: !0 });
1766
1724
  }
1767
1725
  /**
1768
1726
  * Обновляет размеры канваса и вписывает объекты в монтажную область.
@@ -1770,27 +1728,18 @@ class Mt {
1770
1728
  * @fires editor:canvas-updated
1771
1729
  */
1772
1730
  updateCanvasAndFitObjects() {
1773
- var {
1731
+ const {
1774
1732
  canvas: e,
1775
1733
  selectionManager: t,
1776
1734
  transformManager: a,
1777
1735
  montageArea: {
1778
- width: r,
1779
- height: n
1736
+ width: n,
1737
+ height: i
1780
1738
  }
1781
1739
  } = this.editor;
1782
- this.setResolutionWidth(r, {
1783
- adaptCanvasToContainer: !0,
1784
- withoutSave: !0
1785
- }), this.setResolutionHeight(n, {
1786
- adaptCanvasToContainer: !0,
1787
- withoutSave: !0
1788
- }), this.centerMontageArea(), t.selectAll(), a.fitObject({
1789
- fitAsOneObject: !0,
1790
- withoutSave: !0
1791
- }), e.fire("editor:canvas-updated", {
1792
- width: r,
1793
- height: n
1740
+ this.setResolutionWidth(n, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(i, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea(), t.selectAll(), a.fitObject({ fitAsOneObject: !0, withoutSave: !0 }), e.fire("editor:canvas-updated", {
1741
+ width: n,
1742
+ height: i
1794
1743
  });
1795
1744
  }
1796
1745
  /**
@@ -1805,16 +1754,13 @@ class Mt {
1805
1754
  * @param {Number} zoom — текущее значение zoom (например, 1, 1.2, 2 и т.д.)
1806
1755
  */
1807
1756
  updateCssDimensionsForZoom(e) {
1808
- var {
1809
- canvas: t,
1810
- montageArea: a
1811
- } = this.editor, r = a.width * e, n = a.height * e, i = t.wrapperEl.parentNode, s = r <= i.clientWidth ? "100%" : r, c = n <= i.clientHeight ? "100%" : n;
1812
- t.setDimensions({
1813
- width: s,
1814
- height: c
1815
- }, {
1816
- cssOnly: !0
1817
- });
1757
+ const { canvas: t, montageArea: a } = this.editor, n = a.width * e, i = a.height * e, r = t.wrapperEl.parentNode;
1758
+ if (!(r instanceof HTMLElement)) return;
1759
+ const s = n <= r.clientWidth ? "100%" : n, c = i <= r.clientHeight ? "100%" : i;
1760
+ t.setDimensions(
1761
+ { width: s, height: c },
1762
+ { cssOnly: !0 }
1763
+ );
1818
1764
  }
1819
1765
  /**
1820
1766
  * Устанавливаем CSS ширину канваса для отображения
@@ -1897,50 +1843,37 @@ class Mt {
1897
1843
  * @param {string|number} [options.value]
1898
1844
  * @fires editor:display-{element}-{dimension}-changed
1899
1845
  */
1900
- setDisplayDimension() {
1901
- var {
1846
+ setDisplayDimension({ element: e = "canvas", dimension: t, value: a } = {}) {
1847
+ if (!a) return;
1848
+ const { canvas: n, options: { editorContainer: i } } = this.editor, r = [];
1849
+ switch (e) {
1850
+ case "canvas":
1851
+ r.push(n.lowerCanvasEl, n.upperCanvasEl);
1852
+ break;
1853
+ case "wrapper":
1854
+ r.push(n.wrapperEl);
1855
+ break;
1856
+ case "container":
1857
+ r.push(i);
1858
+ break;
1859
+ default:
1860
+ r.push(n.lowerCanvasEl, n.upperCanvasEl);
1861
+ }
1862
+ const s = t === "width" ? "width" : "height";
1863
+ if (typeof a == "string") {
1864
+ r.forEach((u) => {
1865
+ u.style[s] = a;
1866
+ });
1867
+ return;
1868
+ }
1869
+ if (isNaN(a)) return;
1870
+ const c = `${a}px`;
1871
+ r.forEach((u) => {
1872
+ u.style[s] = c;
1873
+ }), n.fire(`editor:display-${e}-${s}-changed`, {
1902
1874
  element: e,
1903
- dimension: t,
1904
1875
  value: a
1905
- } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1906
- if (a) {
1907
- var {
1908
- canvas: r,
1909
- options: {
1910
- editorContainer: n
1911
- }
1912
- } = this.editor, i = [];
1913
- switch (e) {
1914
- case "canvas":
1915
- i.push(r.lowerCanvasEl, r.upperCanvasEl);
1916
- break;
1917
- case "wrapper":
1918
- i.push(r.wrapperEl);
1919
- break;
1920
- case "container":
1921
- i.push(n);
1922
- break;
1923
- default:
1924
- i.push(r.lowerCanvasEl, r.upperCanvasEl);
1925
- }
1926
- var s = t === "width" ? "width" : "height";
1927
- if (typeof a == "string") {
1928
- i.forEach((l) => {
1929
- l.style[s] = a;
1930
- });
1931
- return;
1932
- }
1933
- var c = parseFloat(a);
1934
- if (!isNaN(c)) {
1935
- var u = "".concat(c, "px");
1936
- i.forEach((l) => {
1937
- l.style[s] = u;
1938
- }), r.fire("editor:display-".concat(e, "-").concat(s, "-changed"), {
1939
- element: e,
1940
- value: a
1941
- });
1942
- }
1943
- }
1876
+ });
1944
1877
  }
1945
1878
  /**
1946
1879
  * Если изображение вписывается в допустимые значения, то масштабируем под него канвас
@@ -1950,57 +1883,40 @@ class Mt {
1950
1883
  * @param {Boolean} [options.preserveAspectRatio] - Сохранять изначальные пропорции монтажной области
1951
1884
  * @fires editor:montage-area-scaled-to-image
1952
1885
  */
1953
- scaleMontageAreaToImage() {
1954
- var {
1955
- object: e,
1956
- preserveAspectRatio: t,
1957
- withoutSave: a
1958
- } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
1959
- canvas: r,
1960
- montageArea: n,
1961
- transformManager: i,
1886
+ scaleMontageAreaToImage({ object: e, preserveAspectRatio: t, withoutSave: a } = {}) {
1887
+ const {
1888
+ canvas: n,
1889
+ montageArea: i,
1890
+ transformManager: r,
1962
1891
  options: {
1963
1892
  montageAreaWidth: s,
1964
1893
  montageAreaHeight: c
1965
1894
  }
1966
- } = this.editor, u = e || r.getActiveObject();
1967
- if (!(!u || u.type !== "image" && u.format !== "svg")) {
1968
- var {
1969
- width: l,
1970
- height: d
1971
- } = u, h = Math.min(l, E), g = Math.min(d, O);
1972
- if (t) {
1973
- var {
1974
- width: M,
1975
- height: m
1976
- } = n, f = l / M, v = d / m, S = Math.max(f, v);
1977
- h = M * S, g = m * S;
1978
- }
1979
- this.setResolutionWidth(h, {
1980
- withoutSave: !0
1981
- }), this.setResolutionHeight(g, {
1982
- withoutSave: !0
1983
- }), (l > s || d > c) && i.calculateAndApplyDefaultZoom(), i.resetObject(u, {
1984
- withoutSave: !0
1985
- }), r.centerObject(u), r.renderAll(), a || this.editor.historyManager.saveState(), r.fire("editor:montage-area-scaled-to-image", {
1986
- object: u,
1987
- width: h,
1988
- height: g,
1989
- preserveAspectRatio: t,
1990
- withoutSave: a
1991
- });
1895
+ } = this.editor, u = e || n.getActiveObject();
1896
+ if (!u || u.type !== "image" && u.format !== "svg") return;
1897
+ const { width: l, height: d } = u;
1898
+ let h = Math.min(l, w), g = Math.min(d, O);
1899
+ if (t) {
1900
+ const {
1901
+ width: M,
1902
+ height: f
1903
+ } = i, m = l / M, v = d / f, S = Math.max(m, v);
1904
+ h = M * S, g = f * S;
1992
1905
  }
1906
+ this.setResolutionWidth(h, { withoutSave: !0 }), this.setResolutionHeight(g, { withoutSave: !0 }), (l > s || d > c) && r.calculateAndApplyDefaultZoom(), r.resetObject(u, { withoutSave: !0 }), n.centerObject(u), n.renderAll(), a || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
1907
+ object: u,
1908
+ width: h,
1909
+ height: g,
1910
+ preserveAspectRatio: t,
1911
+ withoutSave: a
1912
+ });
1993
1913
  }
1994
1914
  /**
1995
1915
  * Очистка холста
1996
1916
  * @fires editor:cleared
1997
1917
  */
1998
1918
  clearCanvas() {
1999
- var {
2000
- canvas: e,
2001
- montageArea: t,
2002
- historyManager: a
2003
- } = this.editor;
1919
+ const { canvas: e, montageArea: t, historyManager: a } = this.editor;
2004
1920
  a.suspendHistory(), e.clear(), e.add(t), e.renderAll(), a.resumeHistory(), a.saveState(), e == null || e.fire("editor:cleared");
2005
1921
  }
2006
1922
  /**
@@ -2009,37 +1925,25 @@ class Mt {
2009
1925
  * @param {Boolean} options.withoutSave - Не сохранять состояние
2010
1926
  * @fires editor:default-scale-set
2011
1927
  */
2012
- setDefaultScale() {
2013
- var {
2014
- withoutSave: e
2015
- } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
1928
+ setDefaultScale({ withoutSave: e } = {}) {
1929
+ const {
2016
1930
  canvas: t,
2017
1931
  transformManager: a,
2018
- historyManager: r,
1932
+ historyManager: n,
2019
1933
  options: {
2020
- montageAreaWidth: n,
2021
- montageAreaHeight: i
1934
+ montageAreaWidth: i,
1935
+ montageAreaHeight: r
2022
1936
  }
2023
1937
  } = this.editor;
2024
- a.resetZoom(), this.setResolutionWidth(n, {
2025
- withoutSave: !0
2026
- }), this.setResolutionHeight(i, {
2027
- withoutSave: !0
2028
- }), t.renderAll(), a.resetObjects(), e || r.saveState(), t.fire("editor:default-scale-set");
1938
+ a.resetZoom(), this.setResolutionWidth(i, { withoutSave: !0 }), this.setResolutionHeight(r, { withoutSave: !0 }), t.renderAll(), a.resetObjects(), e || n.saveState(), t.fire("editor:default-scale-set");
2029
1939
  }
2030
1940
  /**
2031
1941
  * Получение всех объектов внутри монтажной области редактора
2032
1942
  * @returns {Array} массив объектов
2033
1943
  */
2034
1944
  getObjects() {
2035
- var {
2036
- canvas: e,
2037
- montageArea: t,
2038
- interactionBlocker: {
2039
- overlayMask: a
2040
- }
2041
- } = this.editor, r = e.getObjects();
2042
- return r.filter((n) => n.id !== t.id && n.id !== a.id);
1945
+ const { canvas: e, montageArea: t, interactionBlocker: { overlayMask: a } } = this.editor;
1946
+ return e.getObjects().filter((i) => i.id !== t.id && i.id !== a.id);
2043
1947
  }
2044
1948
  }
2045
1949
  class ft {
@@ -2054,7 +1958,7 @@ class ft {
2054
1958
  * @param {Number} [scale] - Желаемый масштаб относительно размеров контейнера редактора.
2055
1959
  */
2056
1960
  calculateAndApplyDefaultZoom(e = this.options.defaultScale) {
2057
- const { canvas: t } = this.editor, a = t.editorContainer, r = a.clientWidth, n = a.clientHeight, { width: i, height: s } = this.editor.montageArea, c = r / i * e, u = n / s * e;
1961
+ const { canvas: t } = this.editor, a = t.editorContainer, n = a.clientWidth, i = a.clientHeight, { width: r, height: s } = this.editor.montageArea, c = n / r * e, u = i / s * e;
2058
1962
  this.defaultZoom = Math.min(c, u);
2059
1963
  const { defaultZoom: l, maxZoomFactor: d, minZoom: h, maxZoom: g } = this;
2060
1964
  this.minZoom = Math.min(l / d, h), this.maxZoom = Math.max(l * d, g), this.setZoom();
@@ -2071,14 +1975,14 @@ class ft {
2071
1975
  zoom(e = vt, t = {}) {
2072
1976
  var h, g;
2073
1977
  if (!e) return;
2074
- const { minZoom: a, maxZoom: r } = this, { canvas: n } = this.editor, i = n.getZoom(), s = n.getCenterPoint(), c = (h = t.pointX) != null ? h : s.x, u = (g = t.pointY) != null ? g : s.y, l = new K(c, u);
2075
- let d = Number((i + Number(e)).toFixed(2));
2076
- d > r && (d = r), d < a && (d = a), n.zoomToPoint(l, d), console.log({
2077
- currentZoom: i,
1978
+ const { minZoom: a, maxZoom: n } = this, { canvas: i } = this.editor, r = i.getZoom(), s = i.getCenterPoint(), c = (h = t.pointX) != null ? h : s.x, u = (g = t.pointY) != null ? g : s.y, l = new K(c, u);
1979
+ let d = Number((r + Number(e)).toFixed(2));
1980
+ d > n && (d = n), d < a && (d = a), i.zoomToPoint(l, d), console.log({
1981
+ currentZoom: r,
2078
1982
  zoom: d,
2079
1983
  point: l
2080
- }), n.fire("editor:zoom-changed", {
2081
- currentZoom: n.getZoom(),
1984
+ }), i.fire("editor:zoom-changed", {
1985
+ currentZoom: i.getZoom(),
2082
1986
  zoom: d,
2083
1987
  point: l
2084
1988
  });
@@ -2089,12 +1993,12 @@ class ft {
2089
1993
  * @fires editor:zoom-changed
2090
1994
  */
2091
1995
  setZoom(e = this.defaultZoom) {
2092
- const { minZoom: t, maxZoom: a } = this, { canvas: r } = this.editor, n = new K(r.getCenterPoint());
2093
- let i = e;
2094
- e > a && (i = a), e < t && (i = t), r.zoomToPoint(n, i), r.fire("editor:zoom-changed", {
2095
- currentZoom: r.getZoom(),
2096
- zoom: i,
2097
- point: n
1996
+ const { minZoom: t, maxZoom: a } = this, { canvas: n } = this.editor, i = new K(n.getCenterPoint());
1997
+ let r = e;
1998
+ e > a && (r = a), e < t && (r = t), n.zoomToPoint(i, r), n.fire("editor:zoom-changed", {
1999
+ currentZoom: n.getZoom(),
2000
+ zoom: r,
2001
+ point: i
2098
2002
  });
2099
2003
  }
2100
2004
  /**
@@ -2115,14 +2019,14 @@ class ft {
2115
2019
  * @param {Boolean} options.withoutSave - Не сохранять состояние
2116
2020
  * @fires editor:object-rotated
2117
2021
  */
2118
- rotate(e = mt, { withoutSave: t } = {}) {
2119
- const { canvas: a, historyManager: r } = this.editor, n = a.getActiveObject();
2120
- if (!n) return;
2121
- const i = n.angle + e;
2122
- n.rotate(i), n.setCoords(), a.renderAll(), t || r.saveState(), a.fire("editor:object-rotated", {
2123
- object: n,
2022
+ rotate(e = Mt, { withoutSave: t } = {}) {
2023
+ const { canvas: a, historyManager: n } = this.editor, i = a.getActiveObject();
2024
+ if (!i) return;
2025
+ const r = i.angle + e;
2026
+ i.rotate(r), i.setCoords(), a.renderAll(), t || n.saveState(), a.fire("editor:object-rotated", {
2027
+ object: i,
2124
2028
  withoutSave: t,
2125
- angle: i
2029
+ angle: r
2126
2030
  });
2127
2031
  }
2128
2032
  /**
@@ -2132,9 +2036,9 @@ class ft {
2132
2036
  * @fires editor:object-flipped-x
2133
2037
  */
2134
2038
  flipX({ withoutSave: e } = {}) {
2135
- const { canvas: t, historyManager: a } = this.editor, r = t.getActiveObject();
2136
- r && (r.flipX = !r.flipX, t.renderAll(), e || a.saveState(), t.fire("editor:object-flipped-x", {
2137
- object: r,
2039
+ const { canvas: t, historyManager: a } = this.editor, n = t.getActiveObject();
2040
+ n && (n.flipX = !n.flipX, t.renderAll(), e || a.saveState(), t.fire("editor:object-flipped-x", {
2041
+ object: n,
2138
2042
  withoutSave: e
2139
2043
  }));
2140
2044
  }
@@ -2145,9 +2049,9 @@ class ft {
2145
2049
  * @fires editor:object-flipped-y
2146
2050
  */
2147
2051
  flipY({ withoutSave: e } = {}) {
2148
- const { canvas: t, historyManager: a } = this.editor, r = t.getActiveObject();
2149
- r && (r.flipY = !r.flipY, t.renderAll(), e || a.saveState(), t.fire("editor:object-flipped-y", {
2150
- object: r,
2052
+ const { canvas: t, historyManager: a } = this.editor, n = t.getActiveObject();
2053
+ n && (n.flipY = !n.flipY, t.renderAll(), e || a.saveState(), t.fire("editor:object-flipped-y", {
2054
+ object: n,
2151
2055
  withoutSave: e
2152
2056
  }));
2153
2057
  }
@@ -2161,11 +2065,11 @@ class ft {
2161
2065
  opacity: t = 1,
2162
2066
  withoutSave: a
2163
2067
  } = {}) {
2164
- const { canvas: r, historyManager: n } = this.editor, i = e || r.getActiveObject();
2165
- i && (i.type === "activeselection" ? i.getObjects().forEach((s) => {
2068
+ const { canvas: n, historyManager: i } = this.editor, r = e || n.getActiveObject();
2069
+ r && (r instanceof T ? r.getObjects().forEach((s) => {
2166
2070
  s.set("opacity", t);
2167
- }) : i.set("opacity", t), r.renderAll(), a || n.saveState(), r.fire("editor:object-opacity-changed", {
2168
- object: i,
2071
+ }) : r.set("opacity", t), n.renderAll(), a || i.saveState(), n.fire("editor:object-opacity-changed", {
2072
+ object: r,
2169
2073
  opacity: t,
2170
2074
  withoutSave: a
2171
2075
  }));
@@ -2185,30 +2089,30 @@ class ft {
2185
2089
  object: e,
2186
2090
  type: t = this.options.scaleType,
2187
2091
  withoutSave: a,
2188
- fitAsOneObject: r
2092
+ fitAsOneObject: n
2189
2093
  } = {}) {
2190
- const { canvas: n, imageManager: i, historyManager: s } = this.editor, c = e || n.getActiveObject();
2094
+ const { canvas: i, imageManager: r, historyManager: s } = this.editor, c = e || i.getActiveObject();
2191
2095
  if (c) {
2192
- if (c.set("angle", 0), ["activeselection"].includes(c.type) && !r) {
2096
+ if (c.set("angle", 0), c instanceof T && !n) {
2193
2097
  const u = c.getObjects();
2194
- n.discardActiveObject(), u.forEach((d) => {
2195
- const h = i.calculateScaleFactor({ imageObject: d, scaleType: t });
2196
- d.scale(h), n.centerObject(d);
2098
+ i.discardActiveObject(), u.forEach((d) => {
2099
+ const h = r.calculateScaleFactor({ imageObject: d, scaleType: t });
2100
+ d.scale(h), i.centerObject(d);
2197
2101
  });
2198
- const l = new R(u, { canvas: n });
2199
- n.setActiveObject(l);
2102
+ const l = new T(u, { canvas: i });
2103
+ i.setActiveObject(l);
2200
2104
  } else {
2201
- const u = i.calculateScaleFactor({
2105
+ const u = r.calculateScaleFactor({
2202
2106
  imageObject: c,
2203
2107
  scaleType: t
2204
2108
  });
2205
- c.scale(u), n.centerObject(c);
2109
+ c.scale(u), i.centerObject(c);
2206
2110
  }
2207
- n.renderAll(), a || s.saveState(), n.fire("editor:object-fitted", {
2111
+ i.renderAll(), a || s.saveState(), i.fire("editor:object-fitted", {
2208
2112
  object: c,
2209
2113
  type: t,
2210
2114
  withoutSave: a,
2211
- fitAsOneObject: r
2115
+ fitAsOneObject: n
2212
2116
  });
2213
2117
  }
2214
2118
  }
@@ -2231,12 +2135,12 @@ class ft {
2231
2135
  */
2232
2136
  resetObject(e, { alwaysFitObject: t = !1, withoutSave: a = !1 } = {}) {
2233
2137
  const {
2234
- canvas: r,
2235
- montageArea: n,
2236
- imageManager: i,
2138
+ canvas: n,
2139
+ montageArea: i,
2140
+ imageManager: r,
2237
2141
  historyManager: s,
2238
2142
  options: { scaleType: c }
2239
- } = this.editor, u = e || r.getActiveObject();
2143
+ } = this.editor, u = e || n.getActiveObject();
2240
2144
  if (!u || u.locked) return;
2241
2145
  if (s.suspendHistory(), u.type === "image" || u.format === "svg" || u.set({
2242
2146
  scaleX: 1,
@@ -2247,13 +2151,13 @@ class ft {
2247
2151
  }), t)
2248
2152
  this.fitObject({ object: u, withoutSave: !0, fitAsOneObject: !0 });
2249
2153
  else {
2250
- const { width: d, height: h } = n, { width: g, height: M } = u, m = i.calculateScaleFactor({
2154
+ const { width: d, height: h } = i, { width: g, height: M } = u, f = r.calculateScaleFactor({
2251
2155
  imageObject: u,
2252
2156
  scaleType: c
2253
2157
  });
2254
- c === "contain" && m < 1 || c === "cover" && (g > d || M > h) ? this.fitObject({ object: u, withoutSave: !0, fitAsOneObject: !0 }) : u.set({ scaleX: 1, scaleY: 1 });
2158
+ c === "contain" && f < 1 || c === "cover" && (g > d || M > h) ? this.fitObject({ object: u, withoutSave: !0, fitAsOneObject: !0 }) : u.set({ scaleX: 1, scaleY: 1 });
2255
2159
  }
2256
- u.set({ flipX: !1, flipY: !1, angle: 0 }), r.centerObject(u), r.renderAll(), s.resumeHistory(), a || s.saveState(), r.fire("editor:object-reset", {
2160
+ u.set({ flipX: !1, flipY: !1, angle: 0 }), n.centerObject(u), n.renderAll(), s.resumeHistory(), a || s.saveState(), n.fire("editor:object-reset", {
2257
2161
  object: u,
2258
2162
  withoutSave: a,
2259
2163
  alwaysFitObject: t
@@ -2309,15 +2213,15 @@ class jt {
2309
2213
  if (!(!t || !this.overlayMask)) {
2310
2214
  a.suspendHistory(), t.setCoords();
2311
2215
  var {
2312
- left: r,
2313
- top: n,
2314
- width: i,
2216
+ left: n,
2217
+ top: i,
2218
+ width: r,
2315
2219
  height: s
2316
2220
  } = t.getBoundingRect();
2317
2221
  this.overlayMask.set({
2318
- left: r,
2319
- top: n,
2320
- width: i,
2222
+ left: n,
2223
+ top: i,
2224
+ width: r,
2321
2225
  height: s
2322
2226
  }), e.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, {
2323
2227
  withoutSave: !0
@@ -2338,8 +2242,8 @@ class jt {
2338
2242
  canvasManager: t,
2339
2243
  historyManager: a
2340
2244
  } = this.editor;
2341
- a.suspendHistory(), this.isBlocked = !0, e.discardActiveObject(), e.selection = !1, e.skipTargetFind = !0, t.getObjects().forEach((r) => {
2342
- r.evented = !1, r.selectable = !1;
2245
+ a.suspendHistory(), this.isBlocked = !0, e.discardActiveObject(), e.selection = !1, e.skipTargetFind = !0, t.getObjects().forEach((n) => {
2246
+ n.evented = !1, n.selectable = !1;
2343
2247
  }), e.upperCanvasEl.style.pointerEvents = "none", e.lowerCanvasEl.style.pointerEvents = "none", this.overlayMask.visible = !0, this.refresh(), e.fire("editor:disabled"), a.resumeHistory();
2344
2248
  }
2345
2249
  }
@@ -2354,8 +2258,8 @@ class jt {
2354
2258
  canvasManager: t,
2355
2259
  historyManager: a
2356
2260
  } = this.editor;
2357
- a.suspendHistory(), this.isBlocked = !1, e.selection = !0, e.skipTargetFind = !1, t.getObjects().forEach((r) => {
2358
- r.evented = !0, r.selectable = !0;
2261
+ a.suspendHistory(), this.isBlocked = !1, e.selection = !0, e.skipTargetFind = !1, t.getObjects().forEach((n) => {
2262
+ n.evented = !0, n.selectable = !0;
2359
2263
  }), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), a.resumeHistory();
2360
2264
  }
2361
2265
  }
@@ -2383,14 +2287,14 @@ class $ {
2383
2287
  withoutSave: t
2384
2288
  } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
2385
2289
  canvas: a,
2386
- historyManager: r
2290
+ historyManager: n
2387
2291
  } = this.editor;
2388
- r.suspendHistory();
2389
- var n = e || a.getActiveObject();
2390
- n && (n.type === "activeselection" ? n.getObjects().forEach((i) => {
2391
- a.bringObjectToFront(i);
2392
- }) : a.bringObjectToFront(n), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:object-bring-to-front", {
2393
- object: n,
2292
+ n.suspendHistory();
2293
+ var i = e || a.getActiveObject();
2294
+ i && (i.type === "activeselection" ? i.getObjects().forEach((r) => {
2295
+ a.bringObjectToFront(r);
2296
+ }) : a.bringObjectToFront(i), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:object-bring-to-front", {
2297
+ object: i,
2394
2298
  withoutSave: t
2395
2299
  }));
2396
2300
  }
@@ -2406,12 +2310,12 @@ class $ {
2406
2310
  withoutSave: t
2407
2311
  } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
2408
2312
  canvas: a,
2409
- historyManager: r
2313
+ historyManager: n
2410
2314
  } = this.editor;
2411
- r.suspendHistory();
2412
- var n = e || a.getActiveObject();
2413
- n && (n.type === "activeselection" ? $._moveSelectionForward(a, n) : a.bringObjectForward(n), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:object-bring-forward", {
2414
- object: n,
2315
+ n.suspendHistory();
2316
+ var i = e || a.getActiveObject();
2317
+ i && (i.type === "activeselection" ? $._moveSelectionForward(a, i) : a.bringObjectForward(i), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:object-bring-forward", {
2318
+ object: i,
2415
2319
  withoutSave: t
2416
2320
  }));
2417
2321
  }
@@ -2427,13 +2331,13 @@ class $ {
2427
2331
  withoutSave: t
2428
2332
  } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
2429
2333
  canvas: a,
2430
- montageArea: r,
2431
- historyManager: n,
2334
+ montageArea: n,
2335
+ historyManager: i,
2432
2336
  interactionBlocker: {
2433
- overlayMask: i
2337
+ overlayMask: r
2434
2338
  }
2435
2339
  } = this.editor;
2436
- n.suspendHistory();
2340
+ i.suspendHistory();
2437
2341
  var s = e || a.getActiveObject();
2438
2342
  if (s) {
2439
2343
  if (s.type === "activeselection")
@@ -2441,7 +2345,7 @@ class $ {
2441
2345
  a.sendObjectToBack(c[u]);
2442
2346
  else
2443
2347
  a.sendObjectToBack(s);
2444
- a.sendObjectToBack(r), a.sendObjectToBack(i), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:object-send-to-back", {
2348
+ a.sendObjectToBack(n), a.sendObjectToBack(r), a.renderAll(), i.resumeHistory(), t || i.saveState(), a.fire("editor:object-send-to-back", {
2445
2349
  object: s,
2446
2350
  withoutSave: t
2447
2351
  });
@@ -2458,15 +2362,15 @@ class $ {
2458
2362
  withoutSave: t
2459
2363
  } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, {
2460
2364
  canvas: a,
2461
- montageArea: r,
2462
- historyManager: n,
2365
+ montageArea: n,
2366
+ historyManager: i,
2463
2367
  interactionBlocker: {
2464
- overlayMask: i
2368
+ overlayMask: r
2465
2369
  }
2466
2370
  } = this.editor;
2467
- n.suspendHistory();
2371
+ i.suspendHistory();
2468
2372
  var s = e || a.getActiveObject();
2469
- s && (s.type === "activeselection" ? $._moveSelectionBackwards(a, s) : a.sendObjectBackwards(s), a.sendObjectToBack(r), a.sendObjectToBack(i), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:object-send-backwards", {
2373
+ s && (s.type === "activeselection" ? $._moveSelectionBackwards(a, s) : a.sendObjectBackwards(s), a.sendObjectToBack(n), a.sendObjectToBack(r), a.renderAll(), i.resumeHistory(), t || i.saveState(), a.fire("editor:object-send-backwards", {
2470
2374
  object: s,
2471
2375
  withoutSave: t
2472
2376
  }));
@@ -2479,20 +2383,20 @@ class $ {
2479
2383
  * @private
2480
2384
  */
2481
2385
  static _moveSelectionForward(e, t) {
2482
- for (var a = e.getObjects(), r = t.getObjects(), n = r.map((l) => a.indexOf(l)), i = -1, s = function(d) {
2386
+ for (var a = e.getObjects(), n = t.getObjects(), i = n.map((l) => a.indexOf(l)), r = -1, s = function(d) {
2483
2387
  var h = a[d];
2484
- if (!r.includes(h) && n.some((g) => d > g))
2485
- return i = d, 1;
2388
+ if (!n.includes(h) && i.some((g) => d > g))
2389
+ return r = d, 1;
2486
2390
  }, c = 0; c < a.length && !s(c); c += 1)
2487
2391
  ;
2488
- if (i !== -1) {
2489
- var u = r.map((l) => ({
2392
+ if (r !== -1) {
2393
+ var u = n.map((l) => ({
2490
2394
  obj: l,
2491
2395
  index: a.indexOf(l)
2492
2396
  })).sort((l, d) => d.index - l.index);
2493
2397
  u.forEach((l) => {
2494
2398
  var d = a.indexOf(l.obj);
2495
- d < i && (e.moveObjectTo(l.obj, i), i = d);
2399
+ d < r && (e.moveObjectTo(l.obj, r), r = d);
2496
2400
  });
2497
2401
  }
2498
2402
  }
@@ -2504,8 +2408,8 @@ class $ {
2504
2408
  * @private
2505
2409
  */
2506
2410
  static _moveSelectionBackwards(e, t) {
2507
- for (var a = e.getObjects(), r = t.getObjects(), n = Math.min(...r.map((s) => a.indexOf(s))), i = r.length - 1; i >= 0; i -= 1)
2508
- e.moveObjectTo(r[i], n - 1);
2411
+ for (var a = e.getObjects(), n = t.getObjects(), i = Math.min(...n.map((s) => a.indexOf(s))), r = n.length - 1; r >= 0; r -= 1)
2412
+ e.moveObjectTo(n[r], i - 1);
2509
2413
  }
2510
2414
  }
2511
2415
  class yt {
@@ -2537,9 +2441,9 @@ class yt {
2537
2441
  id: e = `rect-${A()}`,
2538
2442
  left: t,
2539
2443
  top: a,
2540
- width: r = 100,
2541
- height: n = 100,
2542
- fill: i = "blue"
2444
+ width: n = 100,
2445
+ height: i = 100,
2446
+ fill: r = "blue"
2543
2447
  } = d, s = X(d, [
2544
2448
  "id",
2545
2449
  "left",
@@ -2552,9 +2456,9 @@ class yt {
2552
2456
  id: e,
2553
2457
  left: t,
2554
2458
  top: a,
2555
- width: r,
2556
- height: n,
2557
- fill: i
2459
+ width: n,
2460
+ height: i,
2461
+ fill: r
2558
2462
  }, s));
2559
2463
  return !t && !a && h.centerObject(g), u || (h.add(g), c || h.setActiveObject(g), h.renderAll()), g;
2560
2464
  }
@@ -2579,9 +2483,9 @@ class yt {
2579
2483
  id: e = `circle-${A()}`,
2580
2484
  left: t,
2581
2485
  top: a,
2582
- radius: r = 50,
2583
- fill: n = "green"
2584
- } = l, i = X(l, [
2486
+ radius: n = 50,
2487
+ fill: i = "green"
2488
+ } = l, r = X(l, [
2585
2489
  "id",
2586
2490
  "left",
2587
2491
  "top",
@@ -2592,9 +2496,9 @@ class yt {
2592
2496
  id: e,
2593
2497
  left: t,
2594
2498
  top: a,
2595
- fill: n,
2596
- radius: r
2597
- }, i));
2499
+ fill: i,
2500
+ radius: n
2501
+ }, r));
2598
2502
  return !t && !a && d.centerObject(h), c || (d.add(h), s || d.setActiveObject(h), d.renderAll()), h;
2599
2503
  }
2600
2504
  /**
@@ -2619,9 +2523,9 @@ class yt {
2619
2523
  id: e = `triangle-${A()}`,
2620
2524
  left: t,
2621
2525
  top: a,
2622
- width: r = 100,
2623
- height: n = 100,
2624
- fill: i = "yellow"
2526
+ width: n = 100,
2527
+ height: i = 100,
2528
+ fill: r = "yellow"
2625
2529
  } = d, s = X(d, [
2626
2530
  "id",
2627
2531
  "left",
@@ -2634,14 +2538,14 @@ class yt {
2634
2538
  id: e,
2635
2539
  left: t,
2636
2540
  top: a,
2637
- fill: i,
2638
- width: r,
2639
- height: n
2541
+ fill: r,
2542
+ width: n,
2543
+ height: i
2640
2544
  }, s));
2641
2545
  return !t && !a && h.centerObject(g), u || (h.add(g), c || h.setActiveObject(g), h.renderAll()), g;
2642
2546
  }
2643
2547
  }
2644
- class pt {
2548
+ class bt {
2645
2549
  /**
2646
2550
  * @param {object} options
2647
2551
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -2675,10 +2579,10 @@ class pt {
2675
2579
  });
2676
2580
  }), this._cloneAndFire(e, a);
2677
2581
  }
2678
- const n = a.toCanvasElement().toDataURL(), i = n.slice(5).split(";")[0], s = n.split(",")[1], c = atob(s), u = new Uint8Array(c.length);
2582
+ const i = a.toCanvasElement().toDataURL(), r = i.slice(5).split(";")[0], s = i.split(",")[1], c = atob(s), u = new Uint8Array(c.length);
2679
2583
  for (let h = 0; h < c.length; h++)
2680
2584
  u[h] = c.charCodeAt(h);
2681
- const l = new Blob([u.buffer], { type: i }), d = new ClipboardItem({ [i]: l });
2585
+ const l = new Blob([u.buffer], { type: r }), d = new ClipboardItem({ [r]: l });
2682
2586
  navigator.clipboard.write([d]).catch((h) => {
2683
2587
  t.emitWarning({
2684
2588
  origin: "ClipboardManager",
@@ -2713,11 +2617,11 @@ class pt {
2713
2617
  * @param {Array} event.clipboardData.items — элементы буфера обмена
2714
2618
  */
2715
2619
  handlePasteEvent({ clipboardData: e }) {
2716
- var i;
2717
- if (!((i = e == null ? void 0 : e.items) != null && i.length)) return;
2718
- const { imageManager: t } = this.editor, { items: a } = e, r = a[a.length - 1];
2719
- if (r.type !== "text/html") {
2720
- const s = r.getAsFile();
2620
+ var r;
2621
+ if (!((r = e == null ? void 0 : e.items) != null && r.length)) return;
2622
+ const { imageManager: t } = this.editor, { items: a } = e, n = a[a.length - 1];
2623
+ if (n.type !== "text/html") {
2624
+ const s = n.getAsFile();
2721
2625
  if (!s) return;
2722
2626
  const c = new FileReader();
2723
2627
  c.onload = (u) => {
@@ -2725,9 +2629,9 @@ class pt {
2725
2629
  }, c.readAsDataURL(s);
2726
2630
  return;
2727
2631
  }
2728
- const n = e.getData("text/html");
2729
- if (n) {
2730
- const u = new DOMParser().parseFromString(n, "text/html").querySelector("img");
2632
+ const i = e.getData("text/html");
2633
+ if (i) {
2634
+ const u = new DOMParser().parseFromString(i, "text/html").querySelector("img");
2731
2635
  if (u != null && u.src) {
2732
2636
  t.importImage({ source: u.src });
2733
2637
  return;
@@ -2749,13 +2653,13 @@ class pt {
2749
2653
  left: t.left + 10,
2750
2654
  top: t.top + 10,
2751
2655
  evented: !0
2752
- }), t instanceof R ? (t.canvas = e, t.forEachObject((a) => {
2656
+ }), t instanceof T ? (t.canvas = e, t.forEachObject((a) => {
2753
2657
  e.add(a);
2754
2658
  })) : e.add(t), e.setActiveObject(t), e.requestRenderAll(), e.fire("editor:object-pasted", { object: t });
2755
2659
  });
2756
2660
  }
2757
2661
  }
2758
- class bt {
2662
+ class pt {
2759
2663
  /**
2760
2664
  * @param {object} options
2761
2665
  * @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
@@ -2780,10 +2684,10 @@ class bt {
2780
2684
  skipInnerObjects: t,
2781
2685
  withoutSave: a
2782
2686
  } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
2783
- canvas: r,
2784
- historyManager: n
2785
- } = this.editor, i = e || r.getActiveObject();
2786
- if (!(!i || i.locked)) {
2687
+ canvas: n,
2688
+ historyManager: i
2689
+ } = this.editor, r = e || n.getActiveObject();
2690
+ if (!(!r || r.locked)) {
2787
2691
  var s = {
2788
2692
  lockMovementX: !0,
2789
2693
  lockMovementY: !0,
@@ -2794,12 +2698,12 @@ class bt {
2794
2698
  lockSkewingY: !0,
2795
2699
  locked: !0
2796
2700
  };
2797
- i.set(s);
2798
- var c = !t && ["activeselection", "group"].includes(i.type);
2799
- c && i.getObjects().forEach((u) => {
2701
+ r.set(s);
2702
+ var c = !t && ["activeselection", "group"].includes(r.type);
2703
+ c && r.getObjects().forEach((u) => {
2800
2704
  u.set(s);
2801
- }), r.renderAll(), a || n.saveState(), r.fire("editor:object-locked", {
2802
- object: i,
2705
+ }), n.renderAll(), a || i.saveState(), n.fire("editor:object-locked", {
2706
+ object: r,
2803
2707
  skipInnerObjects: t,
2804
2708
  withoutSave: a
2805
2709
  });
@@ -2819,10 +2723,10 @@ class bt {
2819
2723
  withoutSave: t
2820
2724
  } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
2821
2725
  canvas: a,
2822
- historyManager: r
2823
- } = this.editor, n = e || a.getActiveObject();
2824
- if (n) {
2825
- var i = {
2726
+ historyManager: n
2727
+ } = this.editor, i = e || a.getActiveObject();
2728
+ if (i) {
2729
+ var r = {
2826
2730
  lockMovementX: !1,
2827
2731
  lockMovementY: !1,
2828
2732
  lockRotation: !1,
@@ -2832,10 +2736,10 @@ class bt {
2832
2736
  lockSkewingY: !1,
2833
2737
  locked: !1
2834
2738
  };
2835
- n.set(i), ["activeselection", "group"].includes(n.type) && n.getObjects().forEach((s) => {
2836
- s.set(i);
2837
- }), a.renderAll(), t || r.saveState(), a.fire("editor:object-unlocked", {
2838
- object: n,
2739
+ i.set(r), ["activeselection", "group"].includes(i.type) && i.getObjects().forEach((s) => {
2740
+ s.set(r);
2741
+ }), a.renderAll(), t || n.saveState(), a.fire("editor:object-unlocked", {
2742
+ object: i,
2839
2743
  withoutSave: t
2840
2744
  });
2841
2745
  }
@@ -2865,14 +2769,14 @@ class It {
2865
2769
  withoutSave: t
2866
2770
  } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
2867
2771
  canvas: a,
2868
- historyManager: r
2772
+ historyManager: n
2869
2773
  } = this.editor;
2870
- r.suspendHistory();
2871
- var n = e || a.getActiveObject();
2872
- if (n && n.type === "activeselection") {
2873
- var i = n.getObjects(), s = new ze(i);
2874
- i.forEach((c) => a.remove(c)), s.set("id", "".concat(s.type, "-").concat(A())), a.add(s), a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-grouped", {
2875
- object: n,
2774
+ n.suspendHistory();
2775
+ var i = e || a.getActiveObject();
2776
+ if (i && i.type === "activeselection") {
2777
+ var r = i.getObjects(), s = new ze(r);
2778
+ r.forEach((c) => a.remove(c)), s.set("id", "".concat(s.type, "-").concat(A())), a.add(s), a.setActiveObject(s), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:objects-grouped", {
2779
+ object: i,
2876
2780
  group: s,
2877
2781
  withoutSave: t
2878
2782
  });
@@ -2891,18 +2795,18 @@ class It {
2891
2795
  withoutSave: t
2892
2796
  } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
2893
2797
  canvas: a,
2894
- historyManager: r
2798
+ historyManager: n
2895
2799
  } = this.editor;
2896
- r.suspendHistory();
2897
- var n = e || a.getActiveObject();
2898
- if (!(!n || n.type !== "group")) {
2899
- var i = n.removeAll();
2900
- a.remove(n), i.forEach((c) => a.add(c));
2901
- var s = new R(i, {
2800
+ n.suspendHistory();
2801
+ var i = e || a.getActiveObject();
2802
+ if (!(!i || i.type !== "group")) {
2803
+ var r = i.removeAll();
2804
+ a.remove(i), r.forEach((c) => a.add(c));
2805
+ var s = new T(r, {
2902
2806
  canvas: a
2903
2807
  });
2904
- a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-ungrouped", {
2905
- object: n,
2808
+ a.setActiveObject(s), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:objects-ungrouped", {
2809
+ object: i,
2906
2810
  selection: s,
2907
2811
  withoutSave: t
2908
2812
  });
@@ -2931,15 +2835,15 @@ class At {
2931
2835
  objectLockManager: a
2932
2836
  } = this.editor;
2933
2837
  e.discardActiveObject();
2934
- var r = t.getObjects(), n = r.some((s) => s.locked), i = r.length > 1 ? new R(t.getObjects(), {
2838
+ var n = t.getObjects(), i = n.some((s) => s.locked), r = n.length > 1 ? new T(t.getObjects(), {
2935
2839
  canvas: e
2936
- }) : r[0];
2937
- n && a.lockObject({
2938
- object: i,
2840
+ }) : n[0];
2841
+ i && a.lockObject({
2842
+ object: r,
2939
2843
  skipInnerObjects: !0,
2940
2844
  withoutSave: !0
2941
- }), e.setActiveObject(i), e.requestRenderAll(), e.fire("editor:all-objects-selected", {
2942
- selected: i
2845
+ }), e.setActiveObject(r), e.requestRenderAll(), e.fire("editor:all-objects-selected", {
2846
+ selected: r
2943
2847
  });
2944
2848
  }
2945
2849
  }
@@ -2967,22 +2871,22 @@ class St {
2967
2871
  withoutSave: t
2968
2872
  } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
2969
2873
  canvas: a,
2970
- historyManager: r,
2971
- groupingManager: n
2972
- } = this.editor, i = (e || a.getActiveObjects()).filter((s) => !s.locked);
2973
- i != null && i.length && (r.suspendHistory(), i.forEach((s) => {
2874
+ historyManager: n,
2875
+ groupingManager: i
2876
+ } = this.editor, r = (e || a.getActiveObjects()).filter((s) => !s.locked);
2877
+ r != null && r.length && (n.suspendHistory(), r.forEach((s) => {
2974
2878
  if (s.type === "group" && s.format !== "svg") {
2975
- n.ungroup(s), this.deleteSelectedObjects();
2879
+ i.ungroup(s), this.deleteSelectedObjects();
2976
2880
  return;
2977
2881
  }
2978
2882
  a.remove(s);
2979
- }), a.discardActiveObject(), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-deleted", {
2980
- objects: i,
2883
+ }), a.discardActiveObject(), a.renderAll(), n.resumeHistory(), t || n.saveState(), a.fire("editor:objects-deleted", {
2884
+ objects: r,
2981
2885
  withoutSave: t
2982
2886
  }));
2983
2887
  }
2984
2888
  }
2985
- var Ct = {
2889
+ const Ct = {
2986
2890
  IMAGE_MANAGER: {
2987
2891
  /**
2988
2892
  * Некорректный Content-Type изображения
@@ -3012,7 +2916,7 @@ var Ct = {
3012
2916
  /**
3013
2917
  * Коды ошибок и предупреждений для ClipboardManager.
3014
2918
  */
3015
- CLIPBOARD_CODES: {
2919
+ CLIPBOARD_MANAGER: {
3016
2920
  /**
3017
2921
  * Буфер обмена не поддерживается в браузере или отсутствует HTTPS-соединение.
3018
2922
  */
@@ -3029,6 +2933,15 @@ var Ct = {
3029
2933
  * Ошибка клонирования объекта.
3030
2934
  */
3031
2935
  CLONE_FAILED: "CLONE_FAILED"
2936
+ },
2937
+ /**
2938
+ * Коды ошибок и предупреждений для CanvasManager.
2939
+ */
2940
+ CANVAS_MANAGER: {
2941
+ /**
2942
+ * Ошибка при получении активного объекта.
2943
+ */
2944
+ NO_ACTIVE_OBJECT: "NO_ACTIVE_OBJECT"
3032
2945
  }
3033
2946
  };
3034
2947
  class q {
@@ -3051,20 +2964,20 @@ class q {
3051
2964
  * @param {string} [options.message] — текст ошибки (опционально, если не передан, то используется код ошибки)
3052
2965
  * @fires editor:error
3053
2966
  */
3054
- emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: a, data: r, message: n }) {
2967
+ emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: a, data: n, message: i }) {
3055
2968
  if (!q.isValidErrorCode(a)) {
3056
2969
  console.warn("Неизвестный код ошибки: ", { code: a, origin: e, method: t });
3057
2970
  return;
3058
2971
  }
3059
2972
  if (!a) return;
3060
- const i = n || a;
3061
- console.error(`${e}. ${t}. ${a}. ${i}`, r);
2973
+ const r = i || a;
2974
+ console.error(`${e}. ${t}. ${a}. ${r}`, n);
3062
2975
  const s = {
3063
2976
  code: a,
3064
2977
  origin: e,
3065
2978
  method: t,
3066
- message: i,
3067
- data: r
2979
+ message: r,
2980
+ data: n
3068
2981
  };
3069
2982
  this._buffer.push(C({
3070
2983
  type: "editor:error"
@@ -3080,19 +2993,19 @@ class q {
3080
2993
  * @param {string} [options.message] — текст предупреждения (опционально, если не передан, то используется код предупреждения)
3081
2994
  * @fires editor:warning
3082
2995
  */
3083
- emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: a, message: r, data: n }) {
2996
+ emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: a, message: n, data: i }) {
3084
2997
  if (!q.isValidErrorCode(a)) {
3085
2998
  console.warn("Неизвестный код предупреждения: ", { code: a, origin: e, method: t });
3086
2999
  return;
3087
3000
  }
3088
- const i = r || a;
3089
- console.warn(`${e}. ${t}. ${a}. ${i}`, n);
3001
+ const r = n || a;
3002
+ console.warn(`${e}. ${t}. ${a}. ${r}`, i);
3090
3003
  const s = {
3091
3004
  code: a,
3092
3005
  origin: e,
3093
3006
  method: t,
3094
- message: i,
3095
- data: n
3007
+ message: r,
3008
+ data: i
3096
3009
  };
3097
3010
  this._buffer.push(C({
3098
3011
  type: "editor:warning"
@@ -3117,15 +3030,15 @@ class de {
3117
3030
  editorContainerWidth: e,
3118
3031
  editorContainerHeight: t,
3119
3032
  canvasWrapperWidth: a,
3120
- canvasWrapperHeight: r,
3121
- canvasCSSWidth: n,
3122
- canvasCSSHeight: i,
3033
+ canvasWrapperHeight: n,
3034
+ canvasCSSWidth: i,
3035
+ canvasCSSHeight: r,
3123
3036
  initialImage: s,
3124
3037
  initialStateJSON: c,
3125
3038
  scaleType: u,
3126
3039
  _onReadyCallback: l
3127
3040
  } = this.options;
3128
- if (Ke.apply(), this.canvas = new Ue(this.containerId, this.options), this.moduleLoader = new Re(), this.workerManager = new Pe(), this.errorManager = new q({ editor: this }), this.historyManager = new lt({ editor: this }), this.toolbar = new dt({ editor: this }), this.transformManager = new ft({ editor: this }), this.canvasManager = new Mt({ editor: this }), this.imageManager = new D({ editor: this }), this.layerManager = new $({ editor: this }), this.shapeManager = new yt({ editor: this }), this.interactionBlocker = new jt({ editor: this }), this.clipboardManager = new pt({ editor: this }), this.objectLockManager = new bt({ editor: this }), this.groupingManager = new It({ editor: this }), this.selectionManager = new At({ editor: this }), this.deletionManager = new St({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new H({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(a), this.canvasManager.setCanvasWrapperHeight(r), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(i), s != null && s.source) {
3041
+ if (Ke.apply(), this.canvas = new Ue(this.containerId, this.options), this.moduleLoader = new Re(), this.workerManager = new Pe(), this.errorManager = new q({ editor: this }), this.historyManager = new lt({ editor: this }), this.toolbar = new dt({ editor: this }), this.transformManager = new ft({ editor: this }), this.canvasManager = new mt({ editor: this }), this.imageManager = new D({ editor: this }), this.layerManager = new $({ editor: this }), this.shapeManager = new yt({ editor: this }), this.interactionBlocker = new jt({ editor: this }), this.clipboardManager = new bt({ editor: this }), this.objectLockManager = new pt({ editor: this }), this.groupingManager = new It({ editor: this }), this.selectionManager = new At({ editor: this }), this.deletionManager = new St({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new R({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(a), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(i), this.canvasManager.setCanvasCSSHeight(r), s != null && s.source) {
3129
3042
  const {
3130
3043
  source: d,
3131
3044
  scale: h = `image-${u}`,
@@ -3189,7 +3102,7 @@ class de {
3189
3102
  const e = document.createElement("canvas");
3190
3103
  e.width = 20, e.height = 20;
3191
3104
  const t = e.getContext("2d");
3192
- return t.fillStyle = "#ddd", t.fillRect(0, 0, 40, 40), t.fillStyle = "#ccc", t.fillRect(0, 0, 10, 10), t.fillRect(10, 10, 10, 10), new Ye({
3105
+ return t.fillStyle = "#ddd", t.fillRect(0, 0, 40, 40), t.fillStyle = "#ccc", t.fillRect(0, 0, 10, 10), t.fillRect(10, 10, 10, 10), new _e({
3193
3106
  source: e,
3194
3107
  repeat: "repeat"
3195
3108
  });
@@ -3283,18 +3196,18 @@ const Dt = {
3283
3196
  deleteObjectsByHotkey: !0,
3284
3197
  resetObjectFitByDoubleClick: !0
3285
3198
  };
3286
- function Et(o, e = {}) {
3199
+ function wt(o, e = {}) {
3287
3200
  const t = C(C({}, Dt), e), a = document.getElementById(o);
3288
3201
  if (!a)
3289
3202
  return Promise.reject(new Error(`Контейнер с ID "${o}" не найден.`));
3290
- const r = document.createElement("canvas");
3291
- return r.id = `${o}-canvas`, a.appendChild(r), t.editorContainer = a, new Promise((n) => {
3292
- t._onReadyCallback = n;
3293
- const i = new de(r.id, t);
3294
- window[o] = i;
3203
+ const n = document.createElement("canvas");
3204
+ return n.id = `${o}-canvas`, a.appendChild(n), t.editorContainer = a, new Promise((i) => {
3205
+ t._onReadyCallback = i;
3206
+ const r = new de(n.id, t);
3207
+ window[o] = r;
3295
3208
  });
3296
3209
  }
3297
3210
  export {
3298
- Et as default
3211
+ wt as default
3299
3212
  };
3300
3213
  //# sourceMappingURL=main.js.map