@anu3ev/fabric-image-editor 0.1.72 → 0.1.73

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 +980 -683
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,46 +1,46 @@
1
- var ye = Object.defineProperty, Ie = Object.defineProperties;
2
- var ve = Object.getOwnPropertyDescriptors;
1
+ var Ie = Object.defineProperty, ve = Object.defineProperties;
2
+ var Ae = Object.getOwnPropertyDescriptors;
3
3
  var Y = Object.getOwnPropertySymbols;
4
- var le = Object.prototype.hasOwnProperty, he = Object.prototype.propertyIsEnumerable;
5
- var de = (r, e, t) => e in r ? ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e) => {
4
+ var he = Object.prototype.hasOwnProperty, ge = Object.prototype.propertyIsEnumerable;
5
+ var le = (r, e, t) => e in r ? Ie(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e) => {
6
6
  for (var t in e || (e = {}))
7
- le.call(e, t) && de(r, t, e[t]);
7
+ he.call(e, t) && le(r, t, e[t]);
8
8
  if (Y)
9
9
  for (var t of Y(e))
10
- he.call(e, t) && de(r, t, e[t]);
10
+ ge.call(e, t) && le(r, t, e[t]);
11
11
  return r;
12
- }, ge = (r, e) => Ie(r, ve(e));
13
- var P = (r, e) => {
12
+ }, ue = (r, e) => ve(r, Ae(e));
13
+ var W = (r, e) => {
14
14
  var t = {};
15
15
  for (var s in r)
16
- le.call(r, s) && e.indexOf(s) < 0 && (t[s] = r[s]);
16
+ he.call(r, s) && e.indexOf(s) < 0 && (t[s] = r[s]);
17
17
  if (r != null && Y)
18
18
  for (var s of Y(r))
19
- e.indexOf(s) < 0 && he.call(r, s) && (t[s] = r[s]);
19
+ e.indexOf(s) < 0 && ge.call(r, s) && (t[s] = r[s]);
20
20
  return t;
21
21
  };
22
- var j = (r, e, t) => new Promise((s, n) => {
23
- var i = (d) => {
22
+ var b = (r, e, t) => new Promise((s, a) => {
23
+ var n = (c) => {
24
24
  try {
25
- o(t.next(d));
26
- } catch (c) {
27
- n(c);
25
+ i(t.next(c));
26
+ } catch (d) {
27
+ a(d);
28
28
  }
29
- }, a = (d) => {
29
+ }, o = (c) => {
30
30
  try {
31
- o(t.throw(d));
32
- } catch (c) {
33
- n(c);
31
+ i(t.throw(c));
32
+ } catch (d) {
33
+ a(d);
34
34
  }
35
- }, o = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(i, a);
36
- o((t = t.apply(r, e)).next());
35
+ }, i = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(n, o);
36
+ i((t = t.apply(r, e)).next());
37
37
  });
38
- import { ActiveSelection as y, util as H, controlsUtils as Ae, InteractiveFabricObject as Se, loadSVGFromURL as Ce, FabricImage as U, Point as F, Rect as De, Circle as Ne, Triangle as Ee, Group as J, Canvas as Le, Pattern as we } from "fabric";
39
- import { create as Te } from "jsondiffpatch";
40
- import Oe from "diff-match-patch";
41
- var ke = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", D = function() {
38
+ import { ActiveSelection as y, util as P, controlsUtils as Ce, InteractiveFabricObject as Se, loadSVGFromURL as Ee, FabricImage as x, Point as V, Gradient as De, Rect as Ne, Circle as Oe, Triangle as Le, Group as J, Canvas as Te, Pattern as we } from "fabric";
39
+ import { create as ke } from "jsondiffpatch";
40
+ import Be from "diff-match-patch";
41
+ var _e = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", v = function() {
42
42
  for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", s = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
43
- t += ke[s[e] & 63];
43
+ t += _e[s[e] & 63];
44
44
  return t;
45
45
  };
46
46
  class Z {
@@ -61,7 +61,7 @@ class Z {
61
61
  * @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
62
62
  */
63
63
  constructor({ editor: e, options: t = {} }) {
64
- this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], 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 = Z.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 = Z.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = Z.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();
64
+ this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], 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 = Z.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 = Z.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = Z.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.handleBackgroundUpdateBound = this.handleBackgroundUpdate.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();
65
65
  }
66
66
  /**
67
67
  * Инициализация всех обработчиков согласно опциям.
@@ -71,15 +71,15 @@ class Z {
71
71
  adaptCanvasToContainerOnResize: e,
72
72
  canvasDragging: t,
73
73
  mouseWheelZooming: s,
74
- bringToFrontOnSelection: n,
75
- copyObjectsByHotkey: i,
76
- pasteImageFromClipboard: a,
77
- undoRedoByHotKeys: o,
78
- selectAllByHotkey: d,
79
- deleteObjectsByHotkey: c,
74
+ bringToFrontOnSelection: a,
75
+ copyObjectsByHotkey: n,
76
+ pasteImageFromClipboard: o,
77
+ undoRedoByHotKeys: i,
78
+ selectAllByHotkey: c,
79
+ deleteObjectsByHotkey: d,
80
80
  resetObjectFitByDoubleClick: h
81
81
  } = this.options;
82
- 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 })), s && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), n && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), h && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), e && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), i && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), a && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), o && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), d && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), c && 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);
82
+ 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 })), s && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), a && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), h && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), e && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), n && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), o && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), i && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), c && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), d && 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), this.canvas.on("object:added", this.handleBackgroundUpdateBound), this.canvas.on("selection:created", this.handleBackgroundUpdateBound);
83
83
  }
84
84
  /**
85
85
  * При массовом выделении объектов удаляем из него залоченные.
@@ -89,31 +89,31 @@ class Z {
89
89
  */
90
90
  _filterLockedSelection({ selected: e, e: t }) {
91
91
  if (!(e != null && e.length) || !(t instanceof MouseEvent) || e.length === 1) return;
92
- const { lockedObjects: s, unlockedObjects: n } = e.reduce(
93
- (a, o) => o.locked ? (a.lockedObjects.push(o), a) : (a.unlockedObjects.push(o), a),
92
+ const { lockedObjects: s, unlockedObjects: a } = e.reduce(
93
+ (o, i) => i.locked ? (o.lockedObjects.push(i), o) : (o.unlockedObjects.push(i), o),
94
94
  { lockedObjects: [], unlockedObjects: [] }
95
95
  );
96
96
  if (s.length === 0) return;
97
- if (n.length > 0) {
98
- if (n.length === 1)
99
- this.canvas.setActiveObject(n[0]);
97
+ if (a.length > 0) {
98
+ if (a.length === 1)
99
+ this.canvas.setActiveObject(a[0]);
100
100
  else {
101
- const a = new y(n, {
101
+ const o = new y(a, {
102
102
  canvas: this.canvas
103
103
  });
104
- this.canvas.setActiveObject(a);
104
+ this.canvas.setActiveObject(o);
105
105
  }
106
106
  this.canvas.requestRenderAll();
107
107
  return;
108
108
  }
109
- const i = new y(e, {
109
+ const n = new y(e, {
110
110
  canvas: this.canvas
111
111
  });
112
112
  this.editor.objectLockManager.lockObject({
113
- object: i,
113
+ object: n,
114
114
  skipInnerObjects: !0,
115
115
  withoutSave: !0
116
- }), this.canvas.setActiveObject(i), this.canvas.requestRenderAll();
116
+ }), this.canvas.setActiveObject(n), this.canvas.requestRenderAll();
117
117
  }
118
118
  /**
119
119
  * Обработчики для сохранения состояния редактора в истории.
@@ -138,13 +138,16 @@ class Z {
138
138
  const { interactionBlocker: e } = this.editor;
139
139
  !e.isBlocked || !e.overlayMask || this.editor.interactionBlocker.refresh();
140
140
  }
141
+ handleBackgroundUpdate() {
142
+ this.editor.historyManager.skipHistory || this.editor.backgroundManager.refresh();
143
+ }
141
144
  // --- Глобальные DOM-обработчики ---
142
145
  /**
143
146
  * Обработчик изменения размеров окна браузера.
144
147
  * Адаптирует канвас к размерам контейнера, сохраняя позиции объектов.
145
148
  */
146
149
  handleContainerResize() {
147
- this.editor.canvasManager.updateCanvas();
150
+ this.editor.canvasManager.updateCanvas(), this.editor.backgroundManager.refresh();
148
151
  }
149
152
  /**
150
153
  * Обработчик для Ctrl+C (копирование).
@@ -154,8 +157,8 @@ class Z {
154
157
  * @param event.code — код клавиши
155
158
  */
156
159
  handleCopyEvent(e) {
157
- const { ctrlKey: t, metaKey: s, code: n } = e;
158
- this._shouldIgnoreKeyboardEvent(e) || !t && !s || n !== "KeyC" || (e.preventDefault(), this.editor.clipboardManager.copy());
160
+ const { ctrlKey: t, metaKey: s, code: a } = e;
161
+ this._shouldIgnoreKeyboardEvent(e) || !t && !s || a !== "KeyC" || (e.preventDefault(), this.editor.clipboardManager.copy());
159
162
  }
160
163
  /**
161
164
  * Обработчик вставки объекта или изображения из буфера обмена.
@@ -172,9 +175,9 @@ class Z {
172
175
  * @param event.code — код клавиши
173
176
  */
174
177
  handleUndoRedoEvent(e) {
175
- return j(this, null, function* () {
176
- const { ctrlKey: t, metaKey: s, code: n, repeat: i } = e;
177
- this._shouldIgnoreKeyboardEvent(e) || !t && !s || 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()));
178
+ return b(this, null, function* () {
179
+ const { ctrlKey: t, metaKey: s, code: a, repeat: n } = e;
180
+ this._shouldIgnoreKeyboardEvent(e) || !t && !s || n || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (a === "KeyZ" ? (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : a === "KeyY" && (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
178
181
  });
179
182
  }
180
183
  /**
@@ -194,8 +197,8 @@ class Z {
194
197
  */
195
198
  handleSelectAllEvent(e) {
196
199
  if (this._shouldIgnoreKeyboardEvent(e)) return;
197
- const { ctrlKey: t, metaKey: s, code: n } = e;
198
- !t && !s || n !== "KeyA" || (e.preventDefault(), this.editor.selectionManager.selectAll());
200
+ const { ctrlKey: t, metaKey: s, code: a } = e;
201
+ !t && !s || a !== "KeyA" || (e.preventDefault(), this.editor.selectionManager.selectAll());
199
202
  }
200
203
  /**
201
204
  * Обработчик для удаления объектов (Delete или Backspace).
@@ -213,15 +216,15 @@ class Z {
213
216
  */
214
217
  handleSpaceKeyDown(e) {
215
218
  if (e.code !== "Space" || this._shouldIgnoreKeyboardEvent(e)) return;
216
- const { canvas: t, editor: s, isSpacePressed: n, isDragging: i } = this;
217
- if (n || i) return;
219
+ const { canvas: t, editor: s, isSpacePressed: a, isDragging: n } = this;
220
+ if (a || n) return;
218
221
  this.isSpacePressed = !0, e.preventDefault();
219
- const a = t.getActiveObject() || null;
220
- a instanceof y ? this.savedSelection = a.getObjects().slice() : a && (this.savedSelection = [a]), t.discardActiveObject(), t.set({
222
+ const o = t.getActiveObject() || null;
223
+ o instanceof y ? this.savedSelection = o.getObjects().slice() : o && (this.savedSelection = [o]), t.discardActiveObject(), t.set({
221
224
  selection: !1,
222
225
  defaultCursor: "grab"
223
- }), t.setCursor("grab"), s.canvasManager.getObjects().forEach((o) => {
224
- o.set({
226
+ }), t.setCursor("grab"), s.canvasManager.getObjects().forEach((i) => {
227
+ i.set({
225
228
  selectable: !1,
226
229
  evented: !1
227
230
  });
@@ -256,8 +259,8 @@ class Z {
256
259
  t.setActiveObject(e[0]);
257
260
  return;
258
261
  }
259
- const n = e.filter((a) => s.canvasManager.getObjects().includes(a)), i = new y(n, { canvas: t });
260
- t.setActiveObject(i);
262
+ const a = e.filter((o) => s.canvasManager.getObjects().includes(o)), n = new y(a, { canvas: t });
263
+ t.setActiveObject(n);
261
264
  }
262
265
  // --- Обработчики для событий canvas (Fabric) ---
263
266
  /**
@@ -322,24 +325,24 @@ class Z {
322
325
  * @returns true если событие должно быть проигнорировано
323
326
  */
324
327
  _shouldIgnoreKeyboardEvent(e) {
325
- const t = document.activeElement, s = e.target, n = ["input", "textarea", "select"];
328
+ const t = document.activeElement, s = e.target, a = ["input", "textarea", "select"];
326
329
  if (s) {
327
- const a = s.tagName.toLowerCase();
328
- if (n.includes(a) || s.contentEditable === "true") return !0;
330
+ const o = s.tagName.toLowerCase();
331
+ if (a.includes(o) || s.contentEditable === "true") return !0;
329
332
  }
330
333
  if (t && t !== s) {
331
- const a = t.tagName.toLowerCase();
332
- if (n.includes(a) || t.contentEditable === "true") return !0;
334
+ const o = t.tagName.toLowerCase();
335
+ if (a.includes(o) || t.contentEditable === "true") return !0;
333
336
  }
334
- const i = window.getSelection();
335
- if (i && !i.isCollapsed && i.rangeCount > 0) {
336
- let d = i.getRangeAt(0).commonAncestorContainer;
337
- d.nodeType === Node.TEXT_NODE && (d = d.parentElement);
338
- const { keyboardIgnoreSelectors: c } = this.options;
339
- if (c != null && c.length && d)
340
- for (const h of c)
337
+ const n = window.getSelection();
338
+ if (n && !n.isCollapsed && n.rangeCount > 0) {
339
+ let c = n.getRangeAt(0).commonAncestorContainer;
340
+ c.nodeType === Node.TEXT_NODE && (c = c.parentElement);
341
+ const { keyboardIgnoreSelectors: d } = this.options;
342
+ if (d != null && d.length && c)
343
+ for (const h of d)
341
344
  try {
342
- const l = d;
345
+ const l = c;
343
346
  if (l.matches && l.matches(h) || l.closest && l.closest(h))
344
347
  return !0;
345
348
  } catch (l) {
@@ -352,7 +355,7 @@ class Z {
352
355
  * Метод для удаления всех слушателей
353
356
  */
354
357
  destroy() {
355
- window.removeEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), document.removeEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), document.removeEventListener("paste", this.handlePasteEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.removeEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 }), document.removeEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.options.canvasDragging && (this.canvas.off("mouse:down", this.handleCanvasDragStartBound), this.canvas.off("mouse:move", this.handleCanvasDraggingBound), this.canvas.off("mouse:up", this.handleCanvasDragEndBound), document.removeEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.removeEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), this.options.mouseWheelZooming && this.canvas.off("mouse:wheel", this.handleMouseWheelZoomBound), this.options.bringToFrontOnSelection && (this.canvas.off("selection:created", this.handleBringToFrontBound), this.canvas.off("selection:updated", this.handleBringToFrontBound)), this.options.resetObjectFitByDoubleClick && this.canvas.off("mouse:dblclick", this.handleResetObjectFitBound), this.canvas.off("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.off("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.off("object:added", this.handleObjectAddedHistoryBound), this.canvas.off("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.off("object:added", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleLockedSelectionBound), this.canvas.off("selection:updated", this.handleLockedSelectionBound);
358
+ window.removeEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), document.removeEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), document.removeEventListener("paste", this.handlePasteEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.removeEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 }), document.removeEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.options.canvasDragging && (this.canvas.off("mouse:down", this.handleCanvasDragStartBound), this.canvas.off("mouse:move", this.handleCanvasDraggingBound), this.canvas.off("mouse:up", this.handleCanvasDragEndBound), document.removeEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.removeEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), this.options.mouseWheelZooming && this.canvas.off("mouse:wheel", this.handleMouseWheelZoomBound), this.options.bringToFrontOnSelection && (this.canvas.off("selection:created", this.handleBringToFrontBound), this.canvas.off("selection:updated", this.handleBringToFrontBound)), this.options.resetObjectFitByDoubleClick && this.canvas.off("mouse:dblclick", this.handleResetObjectFitBound), this.canvas.off("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.off("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.off("object:added", this.handleObjectAddedHistoryBound), this.canvas.off("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.off("object:added", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleOverlayUpdateBound), this.canvas.off("object:added", this.handleBackgroundUpdateBound), this.canvas.off("selection:created", this.handleBackgroundUpdateBound), this.canvas.off("selection:created", this.handleLockedSelectionBound), this.canvas.off("selection:updated", this.handleLockedSelectionBound);
356
359
  }
357
360
  /**
358
361
  * Дебаунс для снижения частоты вызова функции.
@@ -362,9 +365,9 @@ class Z {
362
365
  */
363
366
  static debounce(e, t) {
364
367
  let s = null;
365
- return function(...n) {
368
+ return function(...a) {
366
369
  s !== null && clearTimeout(s), s = setTimeout(() => {
367
- e.apply(this, n);
370
+ e.apply(this, a);
368
371
  }, t);
369
372
  };
370
373
  }
@@ -387,7 +390,7 @@ class xe {
387
390
  return this.loaders[e] ? (this.cache.has(e) || this.cache.set(e, this.loaders[e]()), this.cache.get(e)) : Promise.reject(new Error(`Unknown module "${e}"`));
388
391
  }
389
392
  }
390
- function Be(r) {
393
+ function Re(r) {
391
394
  return new Worker(
392
395
  "" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
393
396
  {
@@ -395,13 +398,13 @@ function Be(r) {
395
398
  }
396
399
  );
397
400
  }
398
- class _e {
401
+ class Ue {
399
402
  /**
400
403
  * @param scriptUrl — URL скрипта воркера.
401
404
  * По-умолчанию использует DefaultWorker из соседнего файла
402
405
  */
403
406
  constructor(e) {
404
- e ? this.worker = new Worker(e, { type: "module" }) : this.worker = new Be(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
407
+ e ? this.worker = new Worker(e, { type: "module" }) : this.worker = new Re(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
405
408
  }
406
409
  /**
407
410
  * Обработчик сообщений от воркера
@@ -414,12 +417,12 @@ class _e {
414
417
  * @returns
415
418
  */
416
419
  _handleMessage({ data: e }) {
417
- const { requestId: t, success: s, data: n, error: i } = e, a = this._callbacks.get(t);
418
- if (!a) {
420
+ const { requestId: t, success: s, data: a, error: n } = e, o = this._callbacks.get(t);
421
+ if (!o) {
419
422
  console.warn(`No callback found for requestId: ${t}`);
420
423
  return;
421
424
  }
422
- s ? a.resolve(n) : a.reject(new Error(i)), this._callbacks.delete(t);
425
+ s ? o.resolve(a) : o.reject(new Error(n)), this._callbacks.delete(t);
423
426
  }
424
427
  /**
425
428
  * Универсальный метод отправки команды в воркер
@@ -429,9 +432,9 @@ class _e {
429
432
  * @returns Promise, который будет выполнен, когда воркер вернет ответ
430
433
  */
431
434
  post(e, t, s = []) {
432
- const n = `${e}:${D(8)}`;
433
- return new Promise((i, a) => {
434
- this._callbacks.set(n, { resolve: i, reject: a }), this.worker.postMessage({ action: e, payload: t, requestId: n }, s);
435
+ const a = `${e}:${v(8)}`;
436
+ return new Promise((n, o) => {
437
+ this._callbacks.set(a, { resolve: n, reject: o }), this.worker.postMessage({ action: e, payload: t, requestId: a }, s);
435
438
  });
436
439
  }
437
440
  /**
@@ -441,112 +444,112 @@ class _e {
441
444
  this.worker.terminate();
442
445
  }
443
446
  }
444
- const E = 12, Re = 2, K = 8, q = 20, Ue = 100, ee = 20, te = 8, ze = 100, V = 32, se = 1, Ze = "#2B2D33", ne = "#3D8BF4", ie = "#FFFFFF";
445
- function W(r, e, t, s, n) {
446
- const i = E, a = Re;
447
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ie, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-i / 2, -i / 2, i, i, a), r.fill(), r.stroke(), r.restore();
447
+ const N = 12, He = 2, q = 8, ee = 20, ze = 100, te = 20, se = 8, Ze = 100, G = 32, ae = 1, Pe = "#2B2D33", ne = "#3D8BF4", oe = "#FFFFFF";
448
+ function F(r, e, t, s, a) {
449
+ const n = N, o = He;
450
+ r.save(), r.translate(e, t), r.rotate(P.degreesToRadians(a.angle)), r.fillStyle = oe, r.strokeStyle = ne, r.lineWidth = ae, r.beginPath(), r.roundRect(-n / 2, -n / 2, n, n, o), r.fill(), r.stroke(), r.restore();
448
451
  }
449
- function ue(r, e, t, s, n) {
450
- const i = K, a = q, o = Ue;
451
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ie, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-i / 2, -a / 2, i, a, o), r.fill(), r.stroke(), r.restore();
452
+ function Me(r, e, t, s, a) {
453
+ const n = q, o = ee, i = ze;
454
+ r.save(), r.translate(e, t), r.rotate(P.degreesToRadians(a.angle)), r.fillStyle = oe, r.strokeStyle = ne, r.lineWidth = ae, r.beginPath(), r.roundRect(-n / 2, -o / 2, n, o, i), r.fill(), r.stroke(), r.restore();
452
455
  }
453
- function Me(r, e, t, s, n) {
454
- const i = ee, a = te, o = ze;
455
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ie, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-i / 2, -a / 2, i, a, o), r.fill(), r.stroke(), r.restore();
456
+ function fe(r, e, t, s, a) {
457
+ const n = te, o = se, i = Ze;
458
+ r.save(), r.translate(e, t), r.rotate(P.degreesToRadians(a.angle)), r.fillStyle = oe, r.strokeStyle = ne, r.lineWidth = ae, r.beginPath(), r.roundRect(-n / 2, -o / 2, n, o, i), r.fill(), r.stroke(), r.restore();
456
459
  }
457
- const He = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", je = new Image();
458
- je.src = He;
459
- function Ye(r, e, t, s, n) {
460
- const a = V / 2;
461
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = Ze, r.beginPath(), r.arc(0, 0, a, 0, 2 * Math.PI), r.fill(), r.drawImage(je, -a / 2, -a / 2, a, a), r.restore();
460
+ const Ye = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", je = new Image();
461
+ je.src = Ye;
462
+ function We(r, e, t, s, a) {
463
+ const o = G / 2;
464
+ r.save(), r.translate(e, t), r.rotate(P.degreesToRadians(a.angle)), r.fillStyle = Pe, r.beginPath(), r.arc(0, 0, o, 0, 2 * Math.PI), r.fill(), r.drawImage(je, -o / 2, -o / 2, o, o), r.restore();
462
465
  }
463
- const Pe = {
466
+ const Fe = {
464
467
  // Угловые точки
465
468
  tl: {
466
- render: W,
467
- sizeX: E,
468
- sizeY: E,
469
+ render: F,
470
+ sizeX: N,
471
+ sizeY: N,
469
472
  offsetX: 0,
470
473
  offsetY: 0
471
474
  },
472
475
  tr: {
473
- render: W,
474
- sizeX: E,
475
- sizeY: E,
476
+ render: F,
477
+ sizeX: N,
478
+ sizeY: N,
476
479
  offsetX: 0,
477
480
  offsetY: 0
478
481
  },
479
482
  bl: {
480
- render: W,
481
- sizeX: E,
482
- sizeY: E,
483
+ render: F,
484
+ sizeX: N,
485
+ sizeY: N,
483
486
  offsetX: 0,
484
487
  offsetY: 0
485
488
  },
486
489
  br: {
487
- render: W,
488
- sizeX: E,
489
- sizeY: E,
490
+ render: F,
491
+ sizeX: N,
492
+ sizeY: N,
490
493
  offsetX: 0,
491
494
  offsetY: 0
492
495
  },
493
496
  // Середина вертикалей
494
497
  ml: {
495
- render: ue,
496
- sizeX: K,
497
- sizeY: q,
498
+ render: Me,
499
+ sizeX: q,
500
+ sizeY: ee,
498
501
  offsetX: 0,
499
502
  offsetY: 0
500
503
  },
501
504
  mr: {
502
- render: ue,
503
- sizeX: K,
504
- sizeY: q,
505
+ render: Me,
506
+ sizeX: q,
507
+ sizeY: ee,
505
508
  offsetX: 0,
506
509
  offsetY: 0
507
510
  },
508
511
  // Середина горизонталей
509
512
  mt: {
510
- render: Me,
511
- sizeX: ee,
512
- sizeY: te,
513
+ render: fe,
514
+ sizeX: te,
515
+ sizeY: se,
513
516
  offsetX: 0,
514
517
  offsetY: 0
515
518
  },
516
519
  mb: {
517
- render: Me,
518
- sizeX: ee,
519
- sizeY: te,
520
+ render: fe,
521
+ sizeX: te,
522
+ sizeY: se,
520
523
  offsetX: 0,
521
524
  offsetY: 0
522
525
  },
523
526
  // Специальный «rotate» контрол
524
527
  mtr: {
525
- render: Ye,
526
- sizeX: V,
527
- sizeY: V,
528
+ render: We,
529
+ sizeX: G,
530
+ sizeY: G,
528
531
  offsetX: 0,
529
- offsetY: -V
532
+ offsetY: -G
530
533
  }
531
534
  };
532
- class We {
535
+ class Ve {
533
536
  static apply() {
534
- const e = Ae.createObjectDefaultControls();
535
- Object.entries(Pe).forEach(([t, s]) => {
537
+ const e = Ce.createObjectDefaultControls();
538
+ Object.entries(Fe).forEach(([t, s]) => {
536
539
  Object.assign(e[t], {
537
540
  render: s.render,
538
541
  sizeX: s.sizeX,
539
542
  sizeY: s.sizeY,
540
543
  offsetX: s.offsetX,
541
544
  offsetY: s.offsetY
542
- }), t === "mtr" && (e[t].cursorStyle = "grab", e[t].mouseDownHandler = (i, a, o, d) => {
545
+ }), t === "mtr" && (e[t].cursorStyle = "grab", e[t].mouseDownHandler = (n, o, i, c) => {
543
546
  var h;
544
- (h = a.target.canvas) == null || h.setCursor("grabbing");
547
+ (h = o.target.canvas) == null || h.setCursor("grabbing");
545
548
  });
546
549
  }), Se.ownDefaults.controls = e;
547
550
  }
548
551
  }
549
- const Fe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2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NOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", z = {
550
553
  style: {
551
554
  position: "absolute",
552
555
  display: "none",
@@ -613,17 +616,17 @@ const Fe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
613
616
  ],
614
617
  offsetTop: 50,
615
618
  icons: {
616
- copyPaste: Fe,
617
- delete: Ke,
618
- lock: Ve,
619
- unlock: Ge,
620
- bringToFront: $e,
621
- sendToBack: Je,
622
- bringForward: Xe,
623
- sendBackwards: Qe
619
+ copyPaste: Ge,
620
+ delete: et,
621
+ lock: Xe,
622
+ unlock: Qe,
623
+ bringToFront: Je,
624
+ sendToBack: qe,
625
+ bringForward: Ke,
626
+ sendBackwards: $e
624
627
  },
625
628
  handlers: {
626
- copyPaste: (r) => j(null, null, function* () {
629
+ copyPaste: (r) => b(null, null, function* () {
627
630
  r.clipboardManager.copyPaste();
628
631
  }),
629
632
  delete: (r) => {
@@ -649,14 +652,14 @@ const Fe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
649
652
  }
650
653
  }
651
654
  };
652
- class qe {
655
+ class tt {
653
656
  constructor({ editor: e }) {
654
657
  this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._initToolbar();
655
658
  }
656
659
  _initToolbar() {
657
660
  if (!this.options.showToolbar) return;
658
661
  const e = this.options.toolbar || {};
659
- this.config = ge(p(p({}, z), e), {
662
+ this.config = ue(p(p({}, z), e), {
660
663
  style: p(p({}, z.style), e.style || {}),
661
664
  btnStyle: p(p({}, z.btnStyle), e.btnStyle || {}),
662
665
  icons: p(p({}, z.icons), e.icons || {}),
@@ -671,11 +674,11 @@ class qe {
671
674
  _createDOM() {
672
675
  const { style: e } = this.config;
673
676
  this.el = document.createElement("div"), Object.assign(this.el.style, e), this.canvas.wrapperEl.appendChild(this.el), this._onBtnOver = (t) => {
674
- const n = t.target.closest("button");
675
- n && Object.assign(n.style, this.config.btnHover);
677
+ const a = t.target.closest("button");
678
+ a && Object.assign(a.style, this.config.btnHover);
676
679
  }, this._onBtnOut = (t) => {
677
- const n = t.target.closest("button");
678
- n && Object.assign(n.style, this.config.btnStyle);
680
+ const a = t.target.closest("button");
681
+ a && Object.assign(a.style, this.config.btnStyle);
679
682
  }, this.el.addEventListener("mouseover", this._onBtnOver), this.el.addEventListener("mouseout", this._onBtnOut);
680
683
  }
681
684
  /**
@@ -687,13 +690,13 @@ class qe {
687
690
  _renderButtons(e) {
688
691
  this.el.innerHTML = "";
689
692
  for (const t of e) {
690
- const { name: s, handle: n } = t, { icons: i = {}, btnStyle: a, handlers: o = {} } = this.config, d = document.createElement("button");
691
- d.innerHTML = i[n] ? `<img src="${i[n]}" title="${s}" />` : s, Object.assign(d.style, a), d.onclick = () => {
692
- var c;
693
- return (c = o[n]) == null ? void 0 : c.call(o, this.editor);
694
- }, d.onmousedown = (c) => {
695
- c.stopPropagation(), c.preventDefault();
696
- }, d.ondragstart = (c) => c.preventDefault(), this.el.appendChild(d);
693
+ const { name: s, handle: a } = t, { icons: n = {}, btnStyle: o, handlers: i = {} } = this.config, c = document.createElement("button");
694
+ c.innerHTML = n[a] ? `<img src="${n[a]}" title="${s}" />` : s, Object.assign(c.style, o), c.onclick = () => {
695
+ var d;
696
+ return (d = i[a]) == null ? void 0 : d.call(i, this.editor);
697
+ }, c.onmousedown = (d) => {
698
+ d.stopPropagation(), d.preventDefault();
699
+ }, c.ondragstart = (d) => d.preventDefault(), this.el.appendChild(c);
697
700
  }
698
701
  }
699
702
  /**
@@ -749,12 +752,12 @@ class qe {
749
752
  this.el.style.display = "none";
750
753
  return;
751
754
  }
752
- const { el: t, config: s, canvas: n } = this;
755
+ const { el: t, config: s, canvas: a } = this;
753
756
  e.setCoords();
754
- const i = n.getZoom(), [, , , , a, o] = n.viewportTransform, { x: d } = e.getCenterPoint(), { top: c, height: h } = e.getBoundingRect(), g = d * i + a - t.offsetWidth / 2, M = s.offsetTop || 0, f = (c + h) * i + o + M;
757
+ const n = a.getZoom(), [, , , , o, i] = a.viewportTransform, { x: c } = e.getCenterPoint(), { top: d, height: h } = e.getBoundingRect(), g = c * n + o - t.offsetWidth / 2, M = s.offsetTop || 0, m = (d + h) * n + i + M;
755
758
  Object.assign(t.style, {
756
759
  left: `${g}px`,
757
- top: `${f}px`,
760
+ top: `${m}px`,
758
761
  display: "flex"
759
762
  });
760
763
  }
@@ -765,7 +768,7 @@ class qe {
765
768
  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("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
766
769
  }
767
770
  }
768
- class et {
771
+ class st {
769
772
  constructor({ editor: e }) {
770
773
  this.editor = e, this.canvas = e.canvas, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = e.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
771
774
  }
@@ -777,11 +780,12 @@ class et {
777
780
  return this.patches[this.currentIndex - 1] || null;
778
781
  }
779
782
  _createDiffPatcher() {
780
- this.diffPatcher = Te({
783
+ this.diffPatcher = ke({
781
784
  objectHash(e) {
782
785
  const t = e;
783
786
  return [
784
787
  t.id,
788
+ t.backgroundId,
785
789
  t.format,
786
790
  t.locked,
787
791
  t.left,
@@ -801,7 +805,7 @@ class et {
801
805
  includeValueOnMove: !1
802
806
  },
803
807
  textDiff: {
804
- diffMatchPatch: Oe,
808
+ diffMatchPatch: Be,
805
809
  minLength: 60
806
810
  }
807
811
  });
@@ -831,10 +835,10 @@ class et {
831
835
  */
832
836
  getFullState() {
833
837
  const { baseState: e, currentIndex: t, patches: s } = this;
834
- let n = JSON.parse(JSON.stringify(e));
835
- for (let i = 0; i < t; i += 1)
836
- n = this.diffPatcher.patch(n, s[i].diff);
837
- return console.log("getFullState state", n), n;
838
+ let a = JSON.parse(JSON.stringify(e));
839
+ for (let n = 0; n < t; n += 1)
840
+ a = this.diffPatcher.patch(a, s[n].diff);
841
+ return console.log("getFullState state", a), a;
838
842
  }
839
843
  /**
840
844
  * Сохраняем текущее состояние в виде диффа от последнего сохранённого полного состояния.
@@ -846,6 +850,8 @@ class et {
846
850
  "selectable",
847
851
  "evented",
848
852
  "id",
853
+ "backgroundId",
854
+ "backgroundType",
849
855
  "format",
850
856
  "width",
851
857
  "height",
@@ -867,7 +873,7 @@ class et {
867
873
  console.log("Нет изменений для сохранения.");
868
874
  return;
869
875
  }
870
- console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id: D(), diff: s }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
876
+ console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", s), this.totalChangesCount += 1, this.patches.push({ id: v(), diff: s }), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
871
877
  }
872
878
  /**
873
879
  * Функция загрузки состояния в канвас.
@@ -875,15 +881,17 @@ class et {
875
881
  * @fires editor:history-state-loaded
876
882
  */
877
883
  loadStateFromFullState(e) {
878
- return j(this, null, function* () {
884
+ return b(this, null, function* () {
879
885
  if (!e) return;
880
886
  console.log("loadStateFromFullState fullState", e);
881
- const { canvas: t, canvasManager: s, interactionBlocker: n } = this.editor, { width: i, height: a } = t;
887
+ const { canvas: t, canvasManager: s, interactionBlocker: a, backgroundManager: n } = this.editor, { width: o, height: i } = t;
882
888
  yield t.loadFromJSON(e);
883
- const o = t.getObjects().find((c) => c.id === "montage-area");
884
- o && (this.editor.montageArea = o, (i !== t.getWidth() || a !== t.getHeight()) && s.updateCanvas());
885
- const d = t.getObjects().find((c) => c.id === "overlay-mask");
886
- d && (n.overlayMask = d, n.overlayMask.visible = !1), t.renderAll(), t.fire("editor:history-state-loaded", {
889
+ const c = t.getObjects().find((l) => l.id === "montage-area");
890
+ c && (this.editor.montageArea = c, (o !== t.getWidth() || i !== t.getHeight()) && s.updateCanvas());
891
+ const d = t.getObjects().find((l) => l.id === "overlay-mask");
892
+ d && (a.overlayMask = d, a.overlayMask.visible = !1);
893
+ const h = t.getObjects().find((l) => l.id === "background");
894
+ h ? n.backgroundObject = h : n.removeBackground({ withoutSave: !0 }), t.renderAll(), t.fire("editor:history-state-loaded", {
887
895
  fullState: e,
888
896
  currentIndex: this.currentIndex,
889
897
  totalChangesCount: this.totalChangesCount,
@@ -898,7 +906,7 @@ class et {
898
906
  * @fires editor:undo
899
907
  */
900
908
  undo() {
901
- return j(this, null, function* () {
909
+ return b(this, null, function* () {
902
910
  if (!this.skipHistory) {
903
911
  if (this.currentIndex <= 0) {
904
912
  console.log("Нет предыдущих состояний для отмены.");
@@ -935,7 +943,7 @@ class et {
935
943
  * @fires editor:redo
936
944
  */
937
945
  redo() {
938
- return j(this, null, function* () {
946
+ return b(this, null, function* () {
939
947
  if (!this.skipHistory) {
940
948
  if (this.currentIndex >= this.patches.length) {
941
949
  console.log("Нет состояний для повтора.");
@@ -968,8 +976,8 @@ class et {
968
976
  });
969
977
  }
970
978
  }
971
- const tt = 0.1, st = 2, nt = 0.1, it = 90, _ = 16, R = 16, T = 4096, O = 4096, me = "application/image-editor:";
972
- class L {
979
+ const at = 0.1, nt = 2, ot = 0.1, it = 90, U = 16, H = 16, T = 4096, w = 4096, me = "application/image-editor:";
980
+ class O {
973
981
  constructor({ editor: e }) {
974
982
  this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
975
983
  }
@@ -986,83 +994,83 @@ class L {
986
994
  * @returns возвращает Promise с объектом изображения или null в случае ошибки
987
995
  */
988
996
  importImage(e) {
989
- return j(this, null, function* () {
997
+ return b(this, null, function* () {
990
998
  const {
991
999
  source: t,
992
1000
  scale: s = `image-${this.options.scaleType}`,
993
- withoutSave: n = !1,
994
- fromClipboard: i = !1
1001
+ withoutSave: a = !1,
1002
+ fromClipboard: n = !1
995
1003
  } = e;
996
1004
  if (!t) return null;
997
- const { canvas: a, montageArea: o, transformManager: d, historyManager: c, errorManager: h } = this.editor, l = yield this.getContentType(t), g = L.getFormatFromContentType(l), { acceptContentTypes: M, acceptFormats: f } = this;
1005
+ const { canvas: o, montageArea: i, transformManager: c, historyManager: d, errorManager: h } = this.editor, l = yield this.getContentType(t), g = O.getFormatFromContentType(l), { acceptContentTypes: M, acceptFormats: m } = this;
998
1006
  if (!this.isAllowedContentType(l)) {
999
- const m = `Неверный contentType для изображения: ${l}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
1007
+ const f = `Неверный contentType для изображения: ${l}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
1000
1008
  return h.emitError({
1001
1009
  origin: "ImageManager",
1002
1010
  method: "importImage",
1003
1011
  code: "INVALID_CONTENT_TYPE",
1004
- message: m,
1005
- data: { source: t, format: g, contentType: l, acceptContentTypes: M, acceptFormats: f, fromClipboard: i }
1012
+ message: f,
1013
+ data: { source: t, format: g, contentType: l, acceptContentTypes: M, acceptFormats: m, fromClipboard: n }
1006
1014
  }), null;
1007
1015
  }
1008
- c.suspendHistory();
1016
+ d.suspendHistory();
1009
1017
  try {
1010
- let m, u;
1018
+ let f, u;
1011
1019
  if (t instanceof File)
1012
- m = URL.createObjectURL(t);
1020
+ f = URL.createObjectURL(t);
1013
1021
  else if (typeof t == "string") {
1014
- const C = yield (yield fetch(t, { mode: "cors" })).blob();
1015
- m = URL.createObjectURL(C);
1022
+ const E = yield (yield fetch(t, { mode: "cors" })).blob();
1023
+ f = URL.createObjectURL(E);
1016
1024
  } else
1017
1025
  return h.emitError({
1018
1026
  origin: "ImageManager",
1019
1027
  method: "importImage",
1020
1028
  code: "INVALID_SOURCE_TYPE",
1021
1029
  message: "Неверный тип источника изображения. Ожидается URL или объект File.",
1022
- data: { source: t, format: g, contentType: l, acceptContentTypes: M, acceptFormats: f, fromClipboard: i }
1030
+ data: { source: t, format: g, contentType: l, acceptContentTypes: M, acceptFormats: m, fromClipboard: n }
1023
1031
  }), null;
1024
- if (this._createdBlobUrls.push(m), g === "svg") {
1025
- const v = yield Ce(m);
1026
- u = H.groupSVGElements(v.objects, v.options);
1032
+ if (this._createdBlobUrls.push(f), g === "svg") {
1033
+ const A = yield Ee(f);
1034
+ u = P.groupSVGElements(A.objects, A.options);
1027
1035
  } else
1028
- u = yield U.fromURL(m, { crossOrigin: "anonymous" });
1029
- const { width: b, height: A } = u;
1030
- if (u instanceof U) {
1031
- const v = u.getElement();
1032
- let C = "";
1033
- if (v instanceof HTMLImageElement ? C = v.src : v instanceof HTMLCanvasElement && (C = v.toDataURL()), A > O || b > T) {
1034
- const w = yield this.resizeImageToBoundaries(C, "max"), k = URL.createObjectURL(w);
1035
- this._createdBlobUrls.push(k), u = yield U.fromURL(k, { crossOrigin: "anonymous" });
1036
- } else if (A < R || b < _) {
1037
- const w = yield this.resizeImageToBoundaries(C, "min"), k = URL.createObjectURL(w);
1038
- this._createdBlobUrls.push(k), u = yield U.fromURL(k, { crossOrigin: "anonymous" });
1036
+ u = yield x.fromURL(f, { crossOrigin: "anonymous" });
1037
+ const { width: j, height: C } = u;
1038
+ if (u instanceof x) {
1039
+ const A = u.getElement();
1040
+ let E = "";
1041
+ if (A instanceof HTMLImageElement ? E = A.src : A instanceof HTMLCanvasElement && (E = A.toDataURL()), C > w || j > T) {
1042
+ const L = yield this.resizeImageToBoundaries(E, "max"), k = URL.createObjectURL(L);
1043
+ this._createdBlobUrls.push(k), u = yield x.fromURL(k, { crossOrigin: "anonymous" });
1044
+ } else if (C < H || j < U) {
1045
+ const L = yield this.resizeImageToBoundaries(E, "min"), k = URL.createObjectURL(L);
1046
+ this._createdBlobUrls.push(k), u = yield x.fromURL(k, { crossOrigin: "anonymous" });
1039
1047
  }
1040
1048
  }
1041
- if (u.set("id", `${u.type}-${D()}`), u.set("format", g), s === "scale-montage")
1049
+ if (u.set("id", `${u.type}-${v()}`), u.set("format", g), s === "scale-montage")
1042
1050
  this.editor.canvasManager.scaleMontageAreaToImage({ object: u, withoutSave: !0 });
1043
1051
  else {
1044
- const { width: v, height: C } = o, w = this.calculateScaleFactor({ imageObject: u, scaleType: s });
1045
- s === "image-contain" && w < 1 ? d.fitObject({ object: u, type: "contain", withoutSave: !0 }) : s === "image-cover" && (b > v || A > C) && d.fitObject({ object: u, type: "cover", withoutSave: !0 });
1052
+ const { width: A, height: E } = i, L = this.calculateScaleFactor({ imageObject: u, scaleType: s });
1053
+ s === "image-contain" && L < 1 ? c.fitObject({ object: u, type: "contain", withoutSave: !0 }) : s === "image-cover" && (j > A || C > E) && c.fitObject({ object: u, type: "cover", withoutSave: !0 });
1046
1054
  }
1047
- a.add(u), a.centerObject(u), a.setActiveObject(u), a.renderAll(), c.resumeHistory(), n || c.saveState();
1055
+ o.add(u), o.centerObject(u), o.setActiveObject(u), o.renderAll(), d.resumeHistory(), a || d.saveState();
1048
1056
  const S = {
1049
1057
  image: u,
1050
1058
  format: g,
1051
1059
  contentType: l,
1052
1060
  scale: s,
1053
- withoutSave: n,
1061
+ withoutSave: a,
1054
1062
  source: t,
1055
- fromClipboard: i
1063
+ fromClipboard: n
1056
1064
  };
1057
- return a.fire("editor:image-imported", S), S;
1058
- } catch (m) {
1065
+ return o.fire("editor:image-imported", S), S;
1066
+ } catch (f) {
1059
1067
  return h.emitError({
1060
1068
  origin: "ImageManager",
1061
1069
  method: "importImage",
1062
1070
  code: "IMPORT_FAILED",
1063
- message: `Ошибка импорта изображения: ${m.message}`,
1064
- data: { source: t, format: g, contentType: l, scale: s, withoutSave: n, fromClipboard: i }
1065
- }), c.resumeHistory(), null;
1071
+ message: `Ошибка импорта изображения: ${f.message}`,
1072
+ data: { source: t, format: g, contentType: l, scale: s, withoutSave: a, fromClipboard: n }
1073
+ }), d.resumeHistory(), null;
1066
1074
  }
1067
1075
  });
1068
1076
  }
@@ -1075,24 +1083,24 @@ class L {
1075
1083
  * @returns возвращает Promise с Blob-объектом уменьшенного изображения
1076
1084
  */
1077
1085
  resizeImageToBoundaries(e, t = "max") {
1078
- return j(this, null, function* () {
1079
- let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${T}x${O}`;
1080
- t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${_}x${R}`);
1081
- const n = {
1086
+ return b(this, null, function* () {
1087
+ let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${T}x${w}`;
1088
+ t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${U}x${H}`);
1089
+ const a = {
1082
1090
  dataURL: e,
1083
1091
  sizeType: t,
1084
1092
  maxWidth: T,
1085
- maxHeight: O,
1086
- minWidth: _,
1087
- minHeight: R
1093
+ maxHeight: w,
1094
+ minWidth: U,
1095
+ minHeight: H
1088
1096
  };
1089
1097
  return this.editor.errorManager.emitWarning({
1090
1098
  origin: "ImageManager",
1091
1099
  method: "resizeImageToBoundaries",
1092
1100
  code: "IMAGE_RESIZE_WARNING",
1093
1101
  message: s,
1094
- data: n
1095
- }), this.editor.workerManager.post("resizeImage", n);
1102
+ data: a
1103
+ }), this.editor.workerManager.post("resizeImage", a);
1096
1104
  });
1097
1105
  }
1098
1106
  /**
@@ -1107,101 +1115,101 @@ class L {
1107
1115
  * @fires editor:canvas-exported
1108
1116
  */
1109
1117
  exportCanvasAsImageFile() {
1110
- return j(this, arguments, function* (e = {}) {
1118
+ return b(this, arguments, function* (e = {}) {
1111
1119
  const {
1112
1120
  fileName: t = "image.png",
1113
1121
  contentType: s = "image/png",
1114
- exportAsBase64: n = !1,
1115
- exportAsBlob: i = !1
1116
- } = e, { canvas: a, montageArea: o, workerManager: d } = this.editor;
1122
+ exportAsBase64: a = !1,
1123
+ exportAsBlob: n = !1
1124
+ } = e, { canvas: o, montageArea: i, workerManager: c } = this.editor;
1117
1125
  try {
1118
- const c = s === "application/pdf", h = c ? "image/jpg" : s, l = L.getFormatFromContentType(h);
1119
- o.setCoords();
1120
- const { left: g, top: M, width: f, height: m } = o.getBoundingRect(), u = yield a.clone(["id", "format", "locked"]);
1126
+ const d = s === "application/pdf", h = d ? "image/jpg" : s, l = O.getFormatFromContentType(h);
1127
+ i.setCoords();
1128
+ const { left: g, top: M, width: m, height: f } = i.getBoundingRect(), u = yield o.clone(["id", "format", "locked"]);
1121
1129
  u.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(h) && (u.backgroundColor = "#ffffff");
1122
- const b = u.getObjects().find((I) => I.id === o.id);
1123
- b && (b.visible = !1), u.viewportTransform = [1, 0, 0, 1, -g, -M], u.setDimensions({ width: f, height: m }, { backstoreOnly: !0 }), u.renderAll();
1124
- const A = u.getObjects().filter((I) => I.format).every((I) => I.format === "svg");
1125
- if (l === "svg" && A) {
1130
+ const j = u.getObjects().find((I) => I.id === i.id);
1131
+ j && (j.visible = !1), u.viewportTransform = [1, 0, 0, 1, -g, -M], u.setDimensions({ width: m, height: f }, { backstoreOnly: !0 }), u.renderAll();
1132
+ const C = u.getObjects().filter((I) => I.format).every((I) => I.format === "svg");
1133
+ if (l === "svg" && C) {
1126
1134
  const I = u.toSVG();
1127
1135
  u.dispose();
1128
- const N = {
1129
- image: L._exportSVGStringAsFile(I, {
1130
- exportAsBase64: n,
1131
- exportAsBlob: i,
1136
+ const D = {
1137
+ image: O._exportSVGStringAsFile(I, {
1138
+ exportAsBase64: a,
1139
+ exportAsBlob: n,
1132
1140
  fileName: t
1133
1141
  }),
1134
1142
  format: "svg",
1135
1143
  contentType: "image/svg+xml",
1136
1144
  fileName: t.replace(/\.[^/.]+$/, ".svg")
1137
1145
  };
1138
- return a.fire("editor:canvas-exported", N), N;
1146
+ return o.fire("editor:canvas-exported", D), D;
1139
1147
  }
1140
- const S = yield new Promise((I, x) => {
1141
- u.getElement().toBlob((N) => {
1142
- N ? I(N) : x(new Error("Failed to create Blob from canvas"));
1148
+ const S = yield new Promise((I, B) => {
1149
+ u.getElement().toBlob((D) => {
1150
+ D ? I(D) : B(new Error("Failed to create Blob from canvas"));
1143
1151
  });
1144
1152
  });
1145
- if (u.dispose(), i) {
1153
+ if (u.dispose(), n) {
1146
1154
  const I = {
1147
1155
  image: S,
1148
1156
  format: l,
1149
1157
  contentType: h,
1150
1158
  fileName: t
1151
1159
  };
1152
- return a.fire("editor:canvas-exported", I), I;
1160
+ return o.fire("editor:canvas-exported", I), I;
1153
1161
  }
1154
- const v = yield createImageBitmap(S), C = yield d.post(
1162
+ const A = yield createImageBitmap(S), E = yield c.post(
1155
1163
  "toDataURL",
1156
- { format: l, quality: 1, bitmap: v },
1157
- [v]
1164
+ { format: l, quality: 1, bitmap: A },
1165
+ [A]
1158
1166
  );
1159
- if (c) {
1160
- const x = f * 0.264583, N = m * 0.264583, be = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, $ = new be({
1161
- orientation: x > N ? "landscape" : "portrait",
1167
+ if (d) {
1168
+ const B = m * 0.264583, D = f * 0.264583, pe = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, $ = new pe({
1169
+ orientation: B > D ? "landscape" : "portrait",
1162
1170
  unit: "mm",
1163
- format: [x, N]
1171
+ format: [B, D]
1164
1172
  });
1165
- if ($.addImage(String(C), "JPG", 0, 0, x, N), n) {
1166
- const ce = {
1173
+ if ($.addImage(String(E), "JPG", 0, 0, B, D), a) {
1174
+ const de = {
1167
1175
  image: $.output("datauristring"),
1168
1176
  format: "pdf",
1169
1177
  contentType: "application/pdf",
1170
1178
  fileName: t
1171
1179
  };
1172
- return a.fire("editor:canvas-exported", ce), ce;
1180
+ return o.fire("editor:canvas-exported", de), de;
1173
1181
  }
1174
- const pe = $.output("blob"), re = {
1175
- image: new File([pe], t, { type: "application/pdf" }),
1182
+ const ye = $.output("blob"), ce = {
1183
+ image: new File([ye], t, { type: "application/pdf" }),
1176
1184
  format: "pdf",
1177
1185
  contentType: "application/pdf",
1178
1186
  fileName: t
1179
1187
  };
1180
- return a.fire("editor:canvas-exported", re), re;
1188
+ return o.fire("editor:canvas-exported", ce), ce;
1181
1189
  }
1182
- if (n) {
1190
+ if (a) {
1183
1191
  const I = {
1184
- image: C,
1192
+ image: E,
1185
1193
  format: l,
1186
1194
  contentType: h,
1187
1195
  fileName: t
1188
1196
  };
1189
- return a.fire("editor:canvas-exported", I), I;
1197
+ return o.fire("editor:canvas-exported", I), I;
1190
1198
  }
1191
- const w = l === "svg" && !A ? t.replace(/\.[^/.]+$/, ".png") : t, oe = {
1192
- image: new File([S], w, { type: h }),
1199
+ const L = l === "svg" && !C ? t.replace(/\.[^/.]+$/, ".png") : t, re = {
1200
+ image: new File([S], L, { type: h }),
1193
1201
  format: l,
1194
1202
  contentType: h,
1195
- fileName: w
1203
+ fileName: L
1196
1204
  };
1197
- return a.fire("editor:canvas-exported", oe), oe;
1198
- } catch (c) {
1205
+ return o.fire("editor:canvas-exported", re), re;
1206
+ } catch (d) {
1199
1207
  return this.editor.errorManager.emitError({
1200
1208
  origin: "ImageManager",
1201
1209
  method: "exportCanvasAsImageFile",
1202
1210
  code: "IMAGE_EXPORT_FAILED",
1203
- message: `Ошибка экспорта изображения: ${c.message}`,
1204
- data: { contentType: s, fileName: t, exportAsBase64: n, exportAsBlob: i }
1211
+ message: `Ошибка экспорта изображения: ${d.message}`,
1212
+ data: { contentType: s, fileName: t, exportAsBase64: a, exportAsBlob: n }
1205
1213
  }), null;
1206
1214
  }
1207
1215
  });
@@ -1218,88 +1226,88 @@ class L {
1218
1226
  * @fires editor:object-exported
1219
1227
  */
1220
1228
  exportObjectAsImageFile() {
1221
- return j(this, arguments, function* (e = {}) {
1229
+ return b(this, arguments, function* (e = {}) {
1222
1230
  const {
1223
1231
  object: t,
1224
1232
  fileName: s = "image.png",
1225
- contentType: n = "image/png",
1226
- exportAsBase64: i = !1,
1227
- exportAsBlob: a = !1
1228
- } = e, { canvas: o, workerManager: d } = this.editor, c = t || o.getActiveObject();
1229
- if (!c)
1233
+ contentType: a = "image/png",
1234
+ exportAsBase64: n = !1,
1235
+ exportAsBlob: o = !1
1236
+ } = e, { canvas: i, workerManager: c } = this.editor, d = t || i.getActiveObject();
1237
+ if (!d)
1230
1238
  return this.editor.errorManager.emitError({
1231
1239
  origin: "ImageManager",
1232
1240
  method: "exportObjectAsImageFile",
1233
1241
  code: "NO_OBJECT_SELECTED",
1234
1242
  message: "Не выбран объект для экспорта",
1235
- data: { contentType: n, fileName: s, exportAsBase64: i, exportAsBlob: a }
1243
+ data: { contentType: a, fileName: s, exportAsBase64: n, exportAsBlob: o }
1236
1244
  }), null;
1237
1245
  try {
1238
- const h = L.getFormatFromContentType(n);
1246
+ const h = O.getFormatFromContentType(a);
1239
1247
  if (h === "svg") {
1240
- const m = c.toSVG(), u = L._exportSVGStringAsFile(m, {
1241
- exportAsBase64: i,
1242
- exportAsBlob: a,
1248
+ const f = d.toSVG(), u = O._exportSVGStringAsFile(f, {
1249
+ exportAsBase64: n,
1250
+ exportAsBlob: o,
1243
1251
  fileName: s
1244
- }), b = {
1245
- object: c,
1252
+ }), j = {
1253
+ object: d,
1246
1254
  image: u,
1247
1255
  format: h,
1248
1256
  contentType: "image/svg+xml",
1249
1257
  fileName: s.replace(/\.[^/.]+$/, ".svg")
1250
1258
  };
1251
- return o.fire("editor:object-exported", b), b;
1259
+ return i.fire("editor:object-exported", j), j;
1252
1260
  }
1253
- if (i && c instanceof U) {
1254
- const m = yield createImageBitmap(c.getElement()), u = yield d.post(
1261
+ if (n && d instanceof x) {
1262
+ const f = yield createImageBitmap(d.getElement()), u = yield c.post(
1255
1263
  "toDataURL",
1256
1264
  {
1257
1265
  format: h,
1258
1266
  quality: 1,
1259
- bitmap: m
1267
+ bitmap: f
1260
1268
  },
1261
- [m]
1262
- ), b = {
1263
- object: c,
1269
+ [f]
1270
+ ), j = {
1271
+ object: d,
1264
1272
  image: u,
1265
1273
  format: h,
1266
- contentType: n,
1274
+ contentType: a,
1267
1275
  fileName: s
1268
1276
  };
1269
- return o.fire("editor:object-exported", b), b;
1277
+ return i.fire("editor:object-exported", j), j;
1270
1278
  }
1271
- const l = c.toCanvasElement({
1279
+ const l = d.toCanvasElement({
1272
1280
  enableRetinaScaling: !1
1273
- }), g = yield new Promise((m, u) => {
1274
- l.toBlob((b) => {
1275
- b ? m(b) : u(new Error("Failed to create Blob from canvas"));
1281
+ }), g = yield new Promise((f, u) => {
1282
+ l.toBlob((j) => {
1283
+ j ? f(j) : u(new Error("Failed to create Blob from canvas"));
1276
1284
  });
1277
1285
  });
1278
- if (a) {
1279
- const m = {
1280
- object: c,
1286
+ if (o) {
1287
+ const f = {
1288
+ object: d,
1281
1289
  image: g,
1282
1290
  format: h,
1283
- contentType: n,
1291
+ contentType: a,
1284
1292
  fileName: s
1285
1293
  };
1286
- return o.fire("editor:object-exported", m), m;
1294
+ return i.fire("editor:object-exported", f), f;
1287
1295
  }
1288
- const M = new File([g], s, { type: n }), f = {
1289
- object: c,
1296
+ const M = new File([g], s, { type: a }), m = {
1297
+ object: d,
1290
1298
  image: M,
1291
1299
  format: h,
1292
- contentType: n,
1300
+ contentType: a,
1293
1301
  fileName: s
1294
1302
  };
1295
- return o.fire("editor:object-exported", f), f;
1303
+ return i.fire("editor:object-exported", m), m;
1296
1304
  } catch (h) {
1297
1305
  return this.editor.errorManager.emitError({
1298
1306
  origin: "ImageManager",
1299
1307
  method: "exportObjectAsImageFile",
1300
1308
  code: "IMAGE_EXPORT_FAILED",
1301
1309
  message: `Ошибка экспорта объекта: ${h.message}`,
1302
- data: { contentType: n, fileName: s, exportAsBase64: i, exportAsBlob: a }
1310
+ data: { contentType: a, fileName: s, exportAsBase64: n, exportAsBlob: o }
1303
1311
  }), null;
1304
1312
  }
1305
1313
  });
@@ -1315,7 +1323,7 @@ class L {
1315
1323
  * @returns массив допустимых форматов изображений
1316
1324
  */
1317
1325
  getAllowedFormatsFromContentTypes() {
1318
- return this.acceptContentTypes.map((e) => L.getFormatFromContentType(e)).filter((e) => e);
1326
+ return this.acceptContentTypes.map((e) => O.getFormatFromContentType(e)).filter((e) => e);
1319
1327
  }
1320
1328
  /**
1321
1329
  * Проверяет, является ли contentType допустимым типом изображения.
@@ -1331,7 +1339,7 @@ class L {
1331
1339
  * @public
1332
1340
  */
1333
1341
  getContentType(e) {
1334
- return j(this, null, function* () {
1342
+ return b(this, null, function* () {
1335
1343
  return typeof e == "string" ? this.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
1336
1344
  });
1337
1345
  }
@@ -1342,7 +1350,7 @@ class L {
1342
1350
  * @public
1343
1351
  */
1344
1352
  getContentTypeFromUrl(e) {
1345
- return j(this, null, function* () {
1353
+ return b(this, null, function* () {
1346
1354
  if (e.startsWith("data:")) {
1347
1355
  const t = e.match(/^data:([^;]+)/);
1348
1356
  return t ? t[1] : "application/octet-stream";
@@ -1366,11 +1374,11 @@ class L {
1366
1374
  getContentTypeFromExtension(e) {
1367
1375
  var t;
1368
1376
  try {
1369
- const n = (t = new URL(e).pathname.split(".").pop()) == null ? void 0 : t.toLowerCase(), i = {};
1370
- return this.acceptContentTypes.forEach((a) => {
1371
- const o = L.getFormatFromContentType(a);
1372
- o && (i[o] = a);
1373
- }), n && i[n] || "application/octet-stream";
1377
+ const a = (t = new URL(e).pathname.split(".").pop()) == null ? void 0 : t.toLowerCase(), n = {};
1378
+ return this.acceptContentTypes.forEach((o) => {
1379
+ const i = O.getFormatFromContentType(o);
1380
+ i && (n[i] = o);
1381
+ }), a && n[a] || "application/octet-stream";
1374
1382
  } catch (s) {
1375
1383
  return console.warn("Не удалось определить расширение из URL:", e, s), "application/octet-stream";
1376
1384
  }
@@ -1388,8 +1396,8 @@ class L {
1388
1396
  }) {
1389
1397
  const { montageArea: s } = this.editor;
1390
1398
  if (!s || !e) return 1;
1391
- const n = s.width, i = s.height, { width: a, height: o } = e;
1392
- return t === "contain" || t === "image-contain" ? Math.min(n / a, i / o) : t === "cover" || t === "image-cover" ? Math.max(n / a, i / o) : 1;
1399
+ const a = s.width, n = s.height, { width: o, height: i } = e;
1400
+ return t === "contain" || t === "image-contain" ? Math.min(a / o, n / i) : t === "cover" || t === "image-cover" ? Math.max(a / o, n / i) : 1;
1393
1401
  }
1394
1402
  /**
1395
1403
  * Преобразует SVG-строку в Blob, файл, или base64
@@ -1405,9 +1413,9 @@ class L {
1405
1413
  static _exportSVGStringAsFile(e, {
1406
1414
  exportAsBase64: t,
1407
1415
  exportAsBlob: s,
1408
- fileName: n = "image.svg"
1416
+ fileName: a = "image.svg"
1409
1417
  } = {}) {
1410
- return s ? new Blob([e], { type: "image/svg+xml" }) : t ? `data:image/svg+xml;base64,${window.btoa(encodeURIComponent(e))}` : new File([e], n.replace(/\.[^/.]+$/, ".svg"), { type: "image/svg+xml" });
1418
+ return s ? new Blob([e], { type: "image/svg+xml" }) : t ? `data:image/svg+xml;base64,${window.btoa(encodeURIComponent(e))}` : new File([e], a.replace(/\.[^/.]+$/, ".svg"), { type: "image/svg+xml" });
1411
1419
  }
1412
1420
  /**
1413
1421
  * Извлекает чистый формат (subtype) из contentType,
@@ -1421,11 +1429,11 @@ class L {
1421
1429
  return t ? t[1] : "";
1422
1430
  }
1423
1431
  }
1424
- const B = (r, e, t) => Math.max(Math.min(r, t), e), fe = (r, e) => r * e, at = (r, e) => new F(r / 2, e / 2);
1425
- function ot(r) {
1432
+ const _ = (r, e, t) => Math.max(Math.min(r, t), e), be = (r, e) => r * e, rt = (r, e) => new V(r / 2, e / 2);
1433
+ function ct(r) {
1426
1434
  return ((r == null ? void 0 : r.type) === "image" || (r == null ? void 0 : r.format) === "svg") && typeof (r == null ? void 0 : r.width) == "number" && typeof (r == null ? void 0 : r.height) == "number";
1427
1435
  }
1428
- class rt {
1436
+ class dt {
1429
1437
  /**
1430
1438
  * @param options
1431
1439
  * @param options.editor – экземпляр редактора
@@ -1449,25 +1457,25 @@ class rt {
1449
1457
  * @param options.adaptCanvasToContainer - Адаптировать канвас к контейнеру
1450
1458
  * @fires editor:resolution-width-changed
1451
1459
  */
1452
- setResolutionWidth(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: n } = {}) {
1453
- var f;
1460
+ setResolutionWidth(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: a } = {}) {
1461
+ var m;
1454
1462
  if (!e) return;
1455
1463
  const {
1456
- canvas: i,
1457
- montageArea: a,
1458
- options: { canvasBackstoreWidth: o }
1459
- } = this.editor, { width: d, height: c } = a, h = B(Number(e), _, T);
1460
- if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreWidth(Number(o)) : this.setCanvasBackstoreWidth(h), a.set({ width: h }), (f = i.clipPath) == null || f.set({ width: h }), t) {
1461
- const m = h / d, u = fe(c, m);
1464
+ canvas: n,
1465
+ montageArea: o,
1466
+ options: { canvasBackstoreWidth: i }
1467
+ } = this.editor, { width: c, height: d } = o, h = _(Number(e), U, T);
1468
+ if (!i || i === "auto" || a ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreWidth(Number(i)) : this.setCanvasBackstoreWidth(h), o.set({ width: h }), (m = n.clipPath) == null || m.set({ width: h }), t) {
1469
+ const f = h / c, u = be(d, f);
1462
1470
  this.setResolutionHeight(u);
1463
1471
  return;
1464
1472
  }
1465
- const { left: l, top: g } = this.getObjectDefaultCoords(a), M = i.getZoom();
1466
- i.setViewportTransform([M, 0, 0, M, l, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), i.fire("editor:resolution-width-changed", {
1473
+ const { left: l, top: g } = this.getObjectDefaultCoords(o), M = n.getZoom();
1474
+ n.setViewportTransform([M, 0, 0, M, l, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-width-changed", {
1467
1475
  width: h,
1468
1476
  preserveProportional: t,
1469
1477
  withoutSave: s,
1470
- adaptCanvasToContainer: n
1478
+ adaptCanvasToContainer: a
1471
1479
  });
1472
1480
  }
1473
1481
  /**
@@ -1479,25 +1487,25 @@ class rt {
1479
1487
  * @param options.adaptCanvasToContainer - Адаптировать канвас к контейнеру
1480
1488
  * @fires editor:resolution-height-changed
1481
1489
  */
1482
- setResolutionHeight(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: n } = {}) {
1483
- var f;
1490
+ setResolutionHeight(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: a } = {}) {
1491
+ var m;
1484
1492
  if (!e) return;
1485
1493
  const {
1486
- canvas: i,
1487
- montageArea: a,
1488
- options: { canvasBackstoreHeight: o }
1489
- } = this.editor, { width: d, height: c } = a, h = B(Number(e), R, O);
1490
- if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreHeight(Number(o)) : this.setCanvasBackstoreHeight(h), a.set({ height: h }), (f = i.clipPath) == null || f.set({ height: h }), t) {
1491
- const m = h / c, u = fe(d, m);
1494
+ canvas: n,
1495
+ montageArea: o,
1496
+ options: { canvasBackstoreHeight: i }
1497
+ } = this.editor, { width: c, height: d } = o, h = _(Number(e), H, w);
1498
+ if (!i || i === "auto" || a ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreHeight(Number(i)) : this.setCanvasBackstoreHeight(h), o.set({ height: h }), (m = n.clipPath) == null || m.set({ height: h }), t) {
1499
+ const f = h / d, u = be(c, f);
1492
1500
  this.setResolutionWidth(u);
1493
1501
  return;
1494
1502
  }
1495
- const { left: l, top: g } = this.getObjectDefaultCoords(a), M = i.getZoom();
1496
- i.setViewportTransform([M, 0, 0, M, l, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), i.fire("editor:resolution-height-changed", {
1503
+ const { left: l, top: g } = this.getObjectDefaultCoords(o), M = n.getZoom();
1504
+ n.setViewportTransform([M, 0, 0, M, l, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), n.fire("editor:resolution-height-changed", {
1497
1505
  height: h,
1498
1506
  preserveProportional: t,
1499
1507
  withoutSave: s,
1500
- adaptCanvasToContainer: n
1508
+ adaptCanvasToContainer: a
1501
1509
  });
1502
1510
  }
1503
1511
  /**
@@ -1505,17 +1513,17 @@ class rt {
1505
1513
  * и устанавливает правильный viewportTransform.
1506
1514
  */
1507
1515
  centerMontageArea() {
1508
- var d;
1509
- const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), n = e.getHeight(), i = e.getZoom(), a = at(s, n);
1516
+ var c;
1517
+ const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), a = e.getHeight(), n = e.getZoom(), o = rt(s, a);
1510
1518
  t.set({
1511
1519
  left: s / 2,
1512
- top: n / 2
1513
- }), (d = e.clipPath) == null || d.set({
1520
+ top: a / 2
1521
+ }), (c = e.clipPath) == null || c.set({
1514
1522
  left: s / 2,
1515
- top: n / 2
1523
+ top: a / 2
1516
1524
  }), e.renderAll();
1517
- const o = e.viewportTransform;
1518
- o[4] = s / 2 - a.x * i, o[5] = n / 2 - a.y * i, e.setViewportTransform(o), e.renderAll();
1525
+ const i = e.viewportTransform;
1526
+ i[4] = s / 2 - o.x * n, i[5] = a / 2 - o.y * n, e.setViewportTransform(i), e.renderAll();
1519
1527
  }
1520
1528
  /**
1521
1529
  * Метод для получения координат объекта с учетом текущего зума
@@ -1531,15 +1539,15 @@ class rt {
1531
1539
  code: "NO_ACTIVE_OBJECT",
1532
1540
  message: "Не выбран объект для получения координат"
1533
1541
  }), { left: 0, top: 0 };
1534
- const { width: n, height: i } = s, a = t.getZoom(), o = (n - n * a) / 2, d = (i - i * a) / 2;
1535
- return { left: o, top: d };
1542
+ const { width: a, height: n } = s, o = t.getZoom(), i = (a - a * o) / 2, c = (n - n * o) / 2;
1543
+ return { left: i, top: c };
1536
1544
  }
1537
1545
  /**
1538
1546
  * Устанавливаем ширину канваса в backstore (для экспорта)
1539
1547
  */
1540
1548
  setCanvasBackstoreWidth(e) {
1541
1549
  if (!e || typeof e != "number") return;
1542
- const t = B(e, _, T);
1550
+ const t = _(e, U, T);
1543
1551
  this.editor.canvas.setDimensions({ width: t }, { backstoreOnly: !0 });
1544
1552
  }
1545
1553
  /**
@@ -1548,7 +1556,7 @@ class rt {
1548
1556
  */
1549
1557
  setCanvasBackstoreHeight(e) {
1550
1558
  if (!e || typeof e != "number") return;
1551
- const t = B(e, R, O);
1559
+ const t = _(e, H, w);
1552
1560
  this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
1553
1561
  }
1554
1562
  /**
@@ -1557,8 +1565,8 @@ class rt {
1557
1565
  * с учётом минимальных и максимальных значений.
1558
1566
  */
1559
1567
  adaptCanvasToContainer() {
1560
- const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, n = t.clientHeight, i = B(s, _, T), a = B(n, R, O);
1561
- e.setDimensions({ width: i, height: a }, { backstoreOnly: !0 });
1568
+ const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, a = t.clientHeight, n = _(s, U, T), o = _(a, H, w);
1569
+ e.setDimensions({ width: n, height: o }, { backstoreOnly: !0 });
1562
1570
  }
1563
1571
  /**
1564
1572
  * Обновляет размеры канваса без изменения позиций объектов.
@@ -1571,21 +1579,21 @@ class rt {
1571
1579
  montageArea: t,
1572
1580
  montageArea: {
1573
1581
  width: s,
1574
- height: n
1582
+ height: a
1575
1583
  }
1576
- } = this.editor, i = t.left, a = t.top;
1577
- this.setResolutionWidth(s, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(n, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea();
1578
- const o = t.left - i, d = t.top - a;
1579
- if (o !== 0 || d !== 0) {
1580
- const c = e.getActiveObject(), h = [];
1581
- if ((c == null ? void 0 : c.type) === "activeselection") {
1582
- const l = c;
1584
+ } = this.editor, n = t.left, o = t.top;
1585
+ this.setResolutionWidth(s, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(a, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea();
1586
+ const i = t.left - n, c = t.top - o;
1587
+ if (i !== 0 || c !== 0) {
1588
+ const d = e.getActiveObject(), h = [];
1589
+ if ((d == null ? void 0 : d.type) === "activeselection") {
1590
+ const l = d;
1583
1591
  h.push(...l.getObjects()), e.discardActiveObject();
1584
1592
  }
1585
1593
  if (e.getObjects().forEach((l) => {
1586
- l.id === "montage-area" || l.id === "overlay-mask" || (l.set({
1587
- left: l.left + o,
1588
- top: l.top + d
1594
+ l.id === "montage-area" || l.id === "overlay-mask" || l.id === "background" || (l.set({
1595
+ left: l.left + i,
1596
+ top: l.top + c
1589
1597
  }), l.setCoords());
1590
1598
  }), h.length > 0)
1591
1599
  if (h.length === 1)
@@ -1599,7 +1607,7 @@ class rt {
1599
1607
  }
1600
1608
  e.renderAll(), e.fire("editor:canvas-updated", {
1601
1609
  width: s,
1602
- height: n
1610
+ height: a
1603
1611
  });
1604
1612
  }
1605
1613
  /**
@@ -1709,32 +1717,32 @@ class rt {
1709
1717
  */
1710
1718
  setDisplayDimension({ element: e = "canvas", dimension: t, value: s } = {}) {
1711
1719
  if (!s) return;
1712
- const { canvas: n } = this.editor, i = [];
1720
+ const { canvas: a } = this.editor, n = [];
1713
1721
  switch (e) {
1714
1722
  case "canvas":
1715
- i.push(n.lowerCanvasEl, n.upperCanvasEl);
1723
+ n.push(a.lowerCanvasEl, a.upperCanvasEl);
1716
1724
  break;
1717
1725
  case "wrapper":
1718
- i.push(n.wrapperEl);
1726
+ n.push(a.wrapperEl);
1719
1727
  break;
1720
1728
  case "container":
1721
- i.push(this.getEditorContainer());
1729
+ n.push(this.getEditorContainer());
1722
1730
  break;
1723
1731
  default:
1724
- i.push(n.lowerCanvasEl, n.upperCanvasEl);
1732
+ n.push(a.lowerCanvasEl, a.upperCanvasEl);
1725
1733
  }
1726
- const a = t === "width" ? "width" : "height";
1734
+ const o = t === "width" ? "width" : "height";
1727
1735
  if (typeof s == "string") {
1728
- i.forEach((d) => {
1729
- d.style[a] = s;
1736
+ n.forEach((c) => {
1737
+ c.style[o] = s;
1730
1738
  });
1731
1739
  return;
1732
1740
  }
1733
1741
  if (isNaN(s)) return;
1734
- const o = `${s}px`;
1735
- i.forEach((d) => {
1736
- d.style[a] = o;
1737
- }), n.fire(`editor:display-${e}-${a}-changed`, {
1742
+ const i = `${s}px`;
1743
+ n.forEach((c) => {
1744
+ c.style[o] = i;
1745
+ }), a.fire(`editor:display-${e}-${o}-changed`, {
1738
1746
  element: e,
1739
1747
  value: s
1740
1748
  });
@@ -1749,26 +1757,26 @@ class rt {
1749
1757
  */
1750
1758
  scaleMontageAreaToImage({ object: e, preserveAspectRatio: t, withoutSave: s } = {}) {
1751
1759
  const {
1752
- canvas: n,
1753
- montageArea: i,
1754
- transformManager: a,
1760
+ canvas: a,
1761
+ montageArea: n,
1762
+ transformManager: o,
1755
1763
  options: {
1756
- montageAreaWidth: o,
1757
- montageAreaHeight: d
1764
+ montageAreaWidth: i,
1765
+ montageAreaHeight: c
1758
1766
  }
1759
- } = this.editor, c = e || n.getActiveObject();
1760
- if (!ot(c)) return;
1761
- const { width: h, height: l } = c;
1762
- let g = Math.min(h, T), M = Math.min(l, O);
1767
+ } = this.editor, d = e || a.getActiveObject();
1768
+ if (!ct(d)) return;
1769
+ const { width: h, height: l } = d;
1770
+ let g = Math.min(h, T), M = Math.min(l, w);
1763
1771
  if (t) {
1764
1772
  const {
1765
- width: f,
1766
- height: m
1767
- } = i, u = h / f, b = l / m, A = Math.max(u, b);
1768
- g = f * A, M = m * A;
1773
+ width: m,
1774
+ height: f
1775
+ } = n, u = h / m, j = l / f, C = Math.max(u, j);
1776
+ g = m * C, M = f * C;
1769
1777
  }
1770
- this.setResolutionWidth(g, { withoutSave: !0 }), this.setResolutionHeight(M, { withoutSave: !0 }), (h > o || l > d) && a.calculateAndApplyDefaultZoom(), a.resetObject({ object: c, withoutSave: !0 }), n.centerObject(c), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
1771
- object: c,
1778
+ this.setResolutionWidth(g, { withoutSave: !0 }), this.setResolutionHeight(M, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (h > i || l > c) && o.calculateAndApplyDefaultZoom(), o.resetObject({ object: d, withoutSave: !0 }), a.centerObject(d), a.renderAll(), s || this.editor.historyManager.saveState(), a.fire("editor:montage-area-scaled-to-image", {
1779
+ object: d,
1772
1780
  width: g,
1773
1781
  height: M,
1774
1782
  preserveAspectRatio: t,
@@ -1793,26 +1801,33 @@ class rt {
1793
1801
  const {
1794
1802
  canvas: t,
1795
1803
  transformManager: s,
1796
- historyManager: n,
1804
+ historyManager: a,
1797
1805
  options: {
1798
- montageAreaWidth: i,
1799
- montageAreaHeight: a
1806
+ montageAreaWidth: n,
1807
+ montageAreaHeight: o
1800
1808
  }
1801
1809
  } = this.editor;
1802
- s.resetZoom(), this.setResolutionWidth(i, { withoutSave: !0 }), this.setResolutionHeight(a, { withoutSave: !0 }), t.renderAll(), s.resetObjects(), e || n.saveState(), t.fire("editor:default-scale-set");
1810
+ s.resetZoom(), this.setResolutionWidth(n, { withoutSave: !0 }), this.setResolutionHeight(o, { withoutSave: !0 }), t.renderAll(), s.resetObjects(), e || a.saveState(), t.fire("editor:default-scale-set");
1803
1811
  }
1804
1812
  /**
1805
1813
  * Получение всех объектов внутри монтажной области редактора
1806
1814
  * @returns массив объектов
1807
1815
  */
1808
1816
  getObjects() {
1809
- const { canvas: e, montageArea: t, interactionBlocker: { overlayMask: s } } = this.editor;
1810
- return e.getObjects().filter((i) => i.id !== t.id && i.id !== (s == null ? void 0 : s.id));
1817
+ const {
1818
+ canvas: e,
1819
+ montageArea: t,
1820
+ interactionBlocker: { overlayMask: s },
1821
+ backgroundManager: { backgroundObject: a }
1822
+ } = this.editor;
1823
+ return e.getObjects().filter(
1824
+ (o) => o.id !== t.id && o.id !== (s == null ? void 0 : s.id) && o.id !== (a == null ? void 0 : a.id)
1825
+ );
1811
1826
  }
1812
1827
  }
1813
- class ct {
1828
+ class lt {
1814
1829
  constructor({ editor: e }) {
1815
- this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom || tt, this.maxZoom = this.options.maxZoom || st, this.defaultZoom = this.options.defaultScale;
1830
+ this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom || at, this.maxZoom = this.options.maxZoom || nt, this.defaultZoom = this.options.defaultScale;
1816
1831
  }
1817
1832
  /**
1818
1833
  * Метод рассчитывает и применяет зум по умолчанию для монтажной области редактора.
@@ -1822,8 +1837,8 @@ class ct {
1822
1837
  * @param scale - Желаемый масштаб относительно размеров контейнера редактора.
1823
1838
  */
1824
1839
  calculateAndApplyDefaultZoom(e = this.options.defaultScale) {
1825
- const { canvas: t } = this.editor, s = t.editorContainer, n = s.clientWidth, i = s.clientHeight, { width: a, height: o } = this.editor.montageArea, d = n / a * e, c = i / o * e;
1826
- this.defaultZoom = Math.min(d, c), this.setZoom();
1840
+ const { canvas: t } = this.editor, s = t.editorContainer, a = s.clientWidth, n = s.clientHeight, { width: o, height: i } = this.editor.montageArea, c = a / o * e, d = n / i * e;
1841
+ this.defaultZoom = Math.min(c, d), this.setZoom();
1827
1842
  }
1828
1843
  /**
1829
1844
  * Увеличение/уменьшение масштаба
@@ -1834,13 +1849,13 @@ class ct {
1834
1849
  * @fires editor:zoom-changed
1835
1850
  * Если передавать координаты курсора, то нужно быть аккуратнее, так как юзер может выйти за пределы рабочей области
1836
1851
  */
1837
- zoom(e = nt, t = {}) {
1852
+ zoom(e = ot, t = {}) {
1838
1853
  var g, M;
1839
1854
  if (!e) return;
1840
- const { minZoom: s, maxZoom: n } = this, { canvas: i } = this.editor, a = i.getZoom(), o = i.getCenterPoint(), d = (g = t.pointX) != null ? g : o.x, c = (M = t.pointY) != null ? M : o.y, h = new F(d, c);
1841
- let l = Number((a + Number(e)).toFixed(2));
1842
- l > n && (l = n), l < s && (l = s), i.zoomToPoint(h, l), i.fire("editor:zoom-changed", {
1843
- currentZoom: i.getZoom(),
1855
+ const { minZoom: s, maxZoom: a } = this, { canvas: n } = this.editor, o = n.getZoom(), i = n.getCenterPoint(), c = (g = t.pointX) != null ? g : i.x, d = (M = t.pointY) != null ? M : i.y, h = new V(c, d);
1856
+ let l = Number((o + Number(e)).toFixed(2));
1857
+ l > a && (l = a), l < s && (l = s), n.zoomToPoint(h, l), n.fire("editor:zoom-changed", {
1858
+ currentZoom: n.getZoom(),
1844
1859
  zoom: l,
1845
1860
  point: h
1846
1861
  });
@@ -1851,12 +1866,12 @@ class ct {
1851
1866
  * @fires editor:zoom-changed
1852
1867
  */
1853
1868
  setZoom(e = this.defaultZoom) {
1854
- const { minZoom: t, maxZoom: s } = this, { canvas: n } = this.editor, i = new F(n.getCenterPoint());
1855
- let a = e;
1856
- e > s && (a = s), e < t && (a = t), n.zoomToPoint(i, a), n.fire("editor:zoom-changed", {
1857
- currentZoom: n.getZoom(),
1858
- zoom: a,
1859
- point: i
1869
+ const { minZoom: t, maxZoom: s } = this, { canvas: a } = this.editor, n = new V(a.getCenterPoint());
1870
+ let o = e;
1871
+ e > s && (o = s), e < t && (o = t), a.zoomToPoint(n, o), a.fire("editor:zoom-changed", {
1872
+ currentZoom: a.getZoom(),
1873
+ zoom: o,
1874
+ point: n
1860
1875
  });
1861
1876
  }
1862
1877
  /**
@@ -1864,7 +1879,7 @@ class ct {
1864
1879
  * @fires editor:zoom-changed
1865
1880
  */
1866
1881
  resetZoom() {
1867
- const { canvas: e } = this.editor, t = new F(e.getCenterPoint());
1882
+ const { canvas: e } = this.editor, t = new V(e.getCenterPoint());
1868
1883
  e.zoomToPoint(t, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
1869
1884
  currentZoom: e.getZoom(),
1870
1885
  point: t
@@ -1878,13 +1893,13 @@ class ct {
1878
1893
  * @fires editor:object-rotated
1879
1894
  */
1880
1895
  rotate(e = it, { withoutSave: t } = {}) {
1881
- const { canvas: s, historyManager: n } = this.editor, i = s.getActiveObject();
1882
- if (!i) return;
1883
- const a = i.angle + e;
1884
- i.rotate(a), i.setCoords(), s.renderAll(), t || n.saveState(), s.fire("editor:object-rotated", {
1885
- object: i,
1896
+ const { canvas: s, historyManager: a } = this.editor, n = s.getActiveObject();
1897
+ if (!n) return;
1898
+ const o = n.angle + e;
1899
+ n.rotate(o), n.setCoords(), s.renderAll(), t || a.saveState(), s.fire("editor:object-rotated", {
1900
+ object: n,
1886
1901
  withoutSave: t,
1887
- angle: a
1902
+ angle: o
1888
1903
  });
1889
1904
  }
1890
1905
  /**
@@ -1894,9 +1909,9 @@ class ct {
1894
1909
  * @fires editor:object-flipped-x
1895
1910
  */
1896
1911
  flipX({ withoutSave: e } = {}) {
1897
- const { canvas: t, historyManager: s } = this.editor, n = t.getActiveObject();
1898
- n && (n.flipX = !n.flipX, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-x", {
1899
- object: n,
1912
+ const { canvas: t, historyManager: s } = this.editor, a = t.getActiveObject();
1913
+ a && (a.flipX = !a.flipX, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-x", {
1914
+ object: a,
1900
1915
  withoutSave: e
1901
1916
  }));
1902
1917
  }
@@ -1907,9 +1922,9 @@ class ct {
1907
1922
  * @fires editor:object-flipped-y
1908
1923
  */
1909
1924
  flipY({ withoutSave: e } = {}) {
1910
- const { canvas: t, historyManager: s } = this.editor, n = t.getActiveObject();
1911
- n && (n.flipY = !n.flipY, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-y", {
1912
- object: n,
1925
+ const { canvas: t, historyManager: s } = this.editor, a = t.getActiveObject();
1926
+ a && (a.flipY = !a.flipY, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-y", {
1927
+ object: a,
1913
1928
  withoutSave: e
1914
1929
  }));
1915
1930
  }
@@ -1926,11 +1941,11 @@ class ct {
1926
1941
  opacity: t = 1,
1927
1942
  withoutSave: s
1928
1943
  } = {}) {
1929
- const { canvas: n, historyManager: i } = this.editor, a = e || n.getActiveObject();
1930
- a && (a instanceof y ? a.getObjects().forEach((o) => {
1931
- o.set("opacity", t);
1932
- }) : a.set("opacity", t), n.renderAll(), s || i.saveState(), n.fire("editor:object-opacity-changed", {
1933
- object: a,
1944
+ const { canvas: a, historyManager: n } = this.editor, o = e || a.getActiveObject();
1945
+ o && (o instanceof y ? o.getObjects().forEach((i) => {
1946
+ i.set("opacity", t);
1947
+ }) : o.set("opacity", t), a.renderAll(), s || n.saveState(), a.fire("editor:object-opacity-changed", {
1948
+ object: o,
1934
1949
  opacity: t,
1935
1950
  withoutSave: s
1936
1951
  }));
@@ -1950,24 +1965,24 @@ class ct {
1950
1965
  object: e,
1951
1966
  type: t = this.options.scaleType,
1952
1967
  withoutSave: s,
1953
- fitAsOneObject: n
1968
+ fitAsOneObject: a
1954
1969
  } = {}) {
1955
- const { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject();
1956
- if (o) {
1957
- if (o instanceof y && !n) {
1958
- const d = o.getObjects();
1959
- i.discardActiveObject(), d.forEach((h) => {
1970
+ const { canvas: n, historyManager: o } = this.editor, i = e || n.getActiveObject();
1971
+ if (i) {
1972
+ if (i instanceof y && !a) {
1973
+ const c = i.getObjects();
1974
+ n.discardActiveObject(), c.forEach((h) => {
1960
1975
  this._fitSingleObject(h, t);
1961
1976
  });
1962
- const c = new y(d, { canvas: i });
1963
- i.setActiveObject(c);
1977
+ const d = new y(c, { canvas: n });
1978
+ n.setActiveObject(d);
1964
1979
  } else
1965
- this._fitSingleObject(o, t);
1966
- i.renderAll(), s || a.saveState(), i.fire("editor:object-fitted", {
1967
- object: o,
1980
+ this._fitSingleObject(i, t);
1981
+ n.renderAll(), s || o.saveState(), n.fire("editor:object-fitted", {
1982
+ object: i,
1968
1983
  type: t,
1969
1984
  withoutSave: s,
1970
- fitAsOneObject: n
1985
+ fitAsOneObject: a
1971
1986
  });
1972
1987
  }
1973
1988
  }
@@ -1978,11 +1993,11 @@ class ct {
1978
1993
  * @private
1979
1994
  */
1980
1995
  _fitSingleObject(e, t) {
1981
- const { canvas: s, montageArea: n } = this.editor, { width: i, height: a, scaleX: o = 1, scaleY: d = 1, angle: c = 0 } = e, h = i * Math.abs(o), l = a * Math.abs(d), g = c * Math.PI / 180, M = Math.abs(Math.cos(g)), f = Math.abs(Math.sin(g)), m = h * M + l * f, u = h * f + l * M, b = n.width, A = n.height;
1996
+ const { canvas: s, montageArea: a } = this.editor, { width: n, height: o, scaleX: i = 1, scaleY: c = 1, angle: d = 0 } = e, h = n * Math.abs(i), l = o * Math.abs(c), g = d * Math.PI / 180, M = Math.abs(Math.cos(g)), m = Math.abs(Math.sin(g)), f = h * M + l * m, u = h * m + l * M, j = a.width, C = a.height;
1982
1997
  let S;
1983
- t === "contain" ? S = Math.min(b / m, A / u) : S = Math.max(b / m, A / u), e.set({
1984
- scaleX: o * S,
1985
- scaleY: d * S
1998
+ t === "contain" ? S = Math.min(j / f, C / u) : S = Math.max(j / f, C / u), e.set({
1999
+ scaleX: i * S,
2000
+ scaleY: c * S
1986
2001
  }), s.centerObject(e);
1987
2002
  }
1988
2003
  /**
@@ -2003,36 +2018,36 @@ class ct {
2003
2018
  */
2004
2019
  resetObject({ object: e, alwaysFitObject: t = !1, withoutSave: s = !1 } = {}) {
2005
2020
  const {
2006
- canvas: n,
2007
- montageArea: i,
2008
- imageManager: a,
2009
- historyManager: o,
2010
- options: { scaleType: d }
2011
- } = this.editor, c = e || n.getActiveObject();
2012
- if (!c || c.locked) return;
2013
- if (o.suspendHistory(), c.type === "image" || c.format === "svg" || c.set({
2021
+ canvas: a,
2022
+ montageArea: n,
2023
+ imageManager: o,
2024
+ historyManager: i,
2025
+ options: { scaleType: c }
2026
+ } = this.editor, d = e || a.getActiveObject();
2027
+ if (!d || d.locked) return;
2028
+ if (i.suspendHistory(), d.type === "image" || d.format === "svg" || d.set({
2014
2029
  scaleX: 1,
2015
2030
  scaleY: 1,
2016
2031
  flipX: !1,
2017
2032
  flipY: !1,
2018
2033
  angle: 0
2019
2034
  }), t)
2020
- this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 });
2035
+ this.fitObject({ object: d, withoutSave: !0, fitAsOneObject: !0 });
2021
2036
  else {
2022
- const { width: l, height: g } = i, { width: M, height: f } = c, m = a.calculateScaleFactor({
2023
- imageObject: c,
2024
- scaleType: d
2037
+ const { width: l, height: g } = n, { width: M, height: m } = d, f = o.calculateScaleFactor({
2038
+ imageObject: d,
2039
+ scaleType: c
2025
2040
  });
2026
- d === "contain" && m < 1 || d === "cover" && (M > l || f > g) ? this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 }) : c.set({ scaleX: 1, scaleY: 1 });
2041
+ c === "contain" && f < 1 || c === "cover" && (M > l || m > g) ? this.fitObject({ object: d, withoutSave: !0, fitAsOneObject: !0 }) : d.set({ scaleX: 1, scaleY: 1 });
2027
2042
  }
2028
- c.set({ flipX: !1, flipY: !1, angle: 0 }), n.centerObject(c), n.renderAll(), o.resumeHistory(), s || o.saveState(), n.fire("editor:object-reset", {
2029
- object: c,
2043
+ d.set({ flipX: !1, flipY: !1, angle: 0 }), a.centerObject(d), a.renderAll(), i.resumeHistory(), s || i.saveState(), a.fire("editor:object-reset", {
2044
+ object: d,
2030
2045
  withoutSave: s,
2031
2046
  alwaysFitObject: t
2032
2047
  });
2033
2048
  }
2034
2049
  }
2035
- class dt {
2050
+ class ht {
2036
2051
  constructor({ editor: e }) {
2037
2052
  this.editor = e, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
2038
2053
  }
@@ -2062,8 +2077,8 @@ class dt {
2062
2077
  const { canvas: e, montageArea: t, historyManager: s } = this.editor;
2063
2078
  if (!t || !this.overlayMask) return;
2064
2079
  s.suspendHistory(), t.setCoords();
2065
- const { left: n, top: i, width: a, height: o } = t.getBoundingRect();
2066
- this.overlayMask.set({ left: n, top: i, width: a, height: o }), e.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, { withoutSave: !0 }), s.resumeHistory();
2080
+ const { left: a, top: n, width: o, height: i } = t.getBoundingRect();
2081
+ this.overlayMask.set({ left: a, top: n, width: o, height: i }), e.discardActiveObject(), this.editor.layerManager.bringToFront(this.overlayMask, { withoutSave: !0 }), s.resumeHistory();
2067
2082
  }
2068
2083
  /**
2069
2084
  * Выключает редактор:
@@ -2074,8 +2089,8 @@ class dt {
2074
2089
  block() {
2075
2090
  if (this.isBlocked || !this.overlayMask) return;
2076
2091
  const { canvas: e, canvasManager: t, historyManager: s } = this.editor;
2077
- s.suspendHistory(), this.isBlocked = !0, e.discardActiveObject(), e.selection = !1, e.skipTargetFind = !0, t.getObjects().forEach((n) => {
2078
- n.evented = !1, n.selectable = !1;
2092
+ s.suspendHistory(), this.isBlocked = !0, e.discardActiveObject(), e.selection = !1, e.skipTargetFind = !0, t.getObjects().forEach((a) => {
2093
+ a.evented = !1, a.selectable = !1;
2079
2094
  }), e.upperCanvasEl.style.pointerEvents = "none", e.lowerCanvasEl.style.pointerEvents = "none", this.overlayMask.visible = !0, this.refresh(), e.fire("editor:disabled"), s.resumeHistory();
2080
2095
  }
2081
2096
  /**
@@ -2084,12 +2099,271 @@ class dt {
2084
2099
  unblock() {
2085
2100
  if (!this.isBlocked || !this.overlayMask) return;
2086
2101
  const { canvas: e, canvasManager: t, historyManager: s } = this.editor;
2087
- s.suspendHistory(), this.isBlocked = !1, e.selection = !0, e.skipTargetFind = !1, t.getObjects().forEach((n) => {
2088
- n.evented = !0, n.selectable = !0;
2102
+ s.suspendHistory(), this.isBlocked = !1, e.selection = !0, e.skipTargetFind = !1, t.getObjects().forEach((a) => {
2103
+ a.evented = !0, a.selectable = !0;
2089
2104
  }), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), s.resumeHistory();
2090
2105
  }
2091
2106
  }
2092
- class G {
2107
+ class R {
2108
+ constructor({ editor: e }) {
2109
+ this.editor = e, this.backgroundObject = null;
2110
+ }
2111
+ /**
2112
+ * Устанавливает фон сплошного цвета.
2113
+ * @param options - Опции для установки цвета фона
2114
+ * @param options.color - Цвет фона в формате HEX (например, "#FF0000")
2115
+ * @param options.withoutSave - Если true, не сохранять состояние в историю
2116
+ */
2117
+ setColorBackground({
2118
+ color: e,
2119
+ withoutSave: t = !1
2120
+ }) {
2121
+ try {
2122
+ const { historyManager: s } = this.editor, { backgroundObject: a } = this;
2123
+ if (s.suspendHistory(), a && a.backgroundType === "color") {
2124
+ if (a.fill === e) {
2125
+ s.resumeHistory();
2126
+ return;
2127
+ }
2128
+ a.set({ fill: e }), a.set("backgroundId", `background-${v()}`), this.editor.canvas.requestRenderAll();
2129
+ } else
2130
+ this._removeCurrentBackground(), this._createColorBackground(e);
2131
+ this.editor.canvas.fire("background:changed", { type: "color", color: e }), s.resumeHistory(), t || s.saveState();
2132
+ } catch (s) {
2133
+ this.editor.errorManager.emitError({
2134
+ code: "BACKGROUND_CREATION_FAILED",
2135
+ origin: "BackgroundManager",
2136
+ method: "setColorBackground",
2137
+ message: "Не удалось установить цветовой фон",
2138
+ data: { error: s }
2139
+ });
2140
+ }
2141
+ }
2142
+ /**
2143
+ * Устанавливает градиентный фон.
2144
+ * @param options - Опции для установки градиентного фона
2145
+ * @param options.gradient - Объект с параметрами градиента
2146
+ * @param options.withoutSave - Если true, не сохранять состояние в историю
2147
+ */
2148
+ setGradientBackground({
2149
+ gradient: e,
2150
+ withoutSave: t = !1
2151
+ }) {
2152
+ try {
2153
+ const { historyManager: s } = this.editor, { backgroundObject: a } = this;
2154
+ if (s.suspendHistory(), a && a.backgroundType === "gradient") {
2155
+ const n = R._createFabricGradient(e);
2156
+ if (R._isGradientEqual(a.fill, n)) {
2157
+ s.resumeHistory();
2158
+ return;
2159
+ }
2160
+ a.set({ fill: n }), a.set("backgroundId", `background-${v()}`), this.editor.canvas.requestRenderAll();
2161
+ } else
2162
+ this._removeCurrentBackground(), this._createGradientBackground(e);
2163
+ this.editor.canvas.fire("background:changed", {
2164
+ type: "gradient",
2165
+ gradientParams: e
2166
+ }), s.resumeHistory(), t || s.saveState();
2167
+ } catch (s) {
2168
+ this.editor.errorManager.emitError({
2169
+ code: "BACKGROUND_CREATION_FAILED",
2170
+ origin: "BackgroundManager",
2171
+ method: "setGradientBackground",
2172
+ message: "Не удалось установить градиентный фон",
2173
+ data: { error: s }
2174
+ });
2175
+ }
2176
+ }
2177
+ /**
2178
+ * Устанавливает фон из изображения.
2179
+ * @param options - Опции для установки фонового изображения
2180
+ * @param options.imageUrl - URL изображения
2181
+ * @param options.withoutSave - Если true, не сохранять состояние в историю
2182
+ */
2183
+ setImageBackground(s) {
2184
+ return b(this, arguments, function* ({
2185
+ imageUrl: e,
2186
+ withoutSave: t = !1
2187
+ }) {
2188
+ try {
2189
+ const { historyManager: a } = this.editor;
2190
+ a.suspendHistory(), this._removeCurrentBackground(), yield this._createImageBackground(e), this.editor.canvas.fire("background:changed", { type: "image", imageUrl: e }), a.resumeHistory(), t || a.saveState();
2191
+ } catch (a) {
2192
+ this.editor.errorManager.emitError({
2193
+ code: "BACKGROUND_CREATION_FAILED",
2194
+ origin: "BackgroundManager",
2195
+ method: "setImageBackground",
2196
+ message: "Не удалось установить изображение в качестве фона",
2197
+ data: { error: a }
2198
+ });
2199
+ }
2200
+ });
2201
+ }
2202
+ /**
2203
+ * Удаляет текущий фон.
2204
+ * @param options - Опции для удаления фона
2205
+ * @param options.withoutSave - Если true, не сохранять состояние в историю
2206
+ */
2207
+ removeBackground({ withoutSave: e = !1 } = {}) {
2208
+ try {
2209
+ const { historyManager: t } = this.editor;
2210
+ if (!this.backgroundObject) {
2211
+ this.editor.errorManager.emitWarning({
2212
+ code: "NO_BACKGROUND_TO_REMOVE",
2213
+ origin: "BackgroundManager",
2214
+ method: "removeBackground",
2215
+ message: "Нет фона для удаления"
2216
+ });
2217
+ return;
2218
+ }
2219
+ t.suspendHistory(), this._removeCurrentBackground(), this.editor.canvas.fire("background:removed"), t.resumeHistory(), e || t.saveState();
2220
+ } catch (t) {
2221
+ this.editor.errorManager.emitError({
2222
+ code: "BACKGROUND_REMOVAL_FAILED",
2223
+ origin: "BackgroundManager",
2224
+ method: "removeBackground",
2225
+ message: "Не удалось удалить фон",
2226
+ data: { error: t }
2227
+ });
2228
+ }
2229
+ }
2230
+ /**
2231
+ * Обновляет размеры и позицию фона согласно монтажной области.
2232
+ */
2233
+ refresh() {
2234
+ const { canvas: e, montageArea: t, historyManager: s } = this.editor;
2235
+ if (!t || !this.backgroundObject) return;
2236
+ s.suspendHistory(), t.setCoords();
2237
+ const { left: a, top: n, width: o, height: i } = t.getBoundingRect();
2238
+ this.backgroundObject.set({ left: a, top: n, width: o, height: i });
2239
+ const c = e.getObjects(), d = c.indexOf(t), h = c.indexOf(this.backgroundObject);
2240
+ this.backgroundObject && h !== d + 1 && e.moveObjectTo(this.backgroundObject, d + 1), e.requestRenderAll(), s.resumeHistory();
2241
+ }
2242
+ /**
2243
+ * Создает цветовой фон.
2244
+ * @param color - Цвет фона в формате HEX (например, "#FF0000")
2245
+ */
2246
+ _createColorBackground(e) {
2247
+ this.backgroundObject = this.editor.shapeManager.addRectangle({
2248
+ fill: e,
2249
+ selectable: !1,
2250
+ evented: !1,
2251
+ hasBorders: !1,
2252
+ hasControls: !1,
2253
+ id: "background",
2254
+ backgroundType: "color",
2255
+ backgroundId: `background-${v()}`
2256
+ }, { withoutSelection: !0 }), this._setupBackgroundPosition();
2257
+ }
2258
+ /**
2259
+ * Создает градиентный фон.
2260
+ * @param gradient - Объект с параметрами градиента
2261
+ */
2262
+ _createGradientBackground(e) {
2263
+ this.backgroundObject = this.editor.shapeManager.addRectangle({
2264
+ fill: "#ffffff",
2265
+ // временный цвет
2266
+ selectable: !1,
2267
+ evented: !1,
2268
+ hasBorders: !1,
2269
+ hasControls: !1,
2270
+ id: "background",
2271
+ backgroundType: "gradient",
2272
+ backgroundId: `background-${v()}`
2273
+ }, { withoutSelection: !0 }), this._setupBackgroundPosition();
2274
+ const t = R._createFabricGradient(e);
2275
+ this.backgroundObject.set("fill", t), this.editor.canvas.requestRenderAll();
2276
+ }
2277
+ /**
2278
+ * Создает фон из изображения.
2279
+ * @param imageUrl - URL изображения
2280
+ */
2281
+ _createImageBackground(e) {
2282
+ return b(this, null, function* () {
2283
+ return new Promise((t, s) => {
2284
+ x.fromURL(e, {
2285
+ crossOrigin: "anonymous"
2286
+ }).then((a) => {
2287
+ if (!a) {
2288
+ s(new Error("Не удалось загрузить изображение"));
2289
+ return;
2290
+ }
2291
+ a.set({
2292
+ selectable: !1,
2293
+ evented: !1,
2294
+ hasBorders: !1,
2295
+ hasControls: !1,
2296
+ id: "background",
2297
+ backgroundType: "image",
2298
+ backgroundId: `background-${v()}`
2299
+ }), this.editor.canvas.add(a), this.backgroundObject = a, this._setupBackgroundPosition(), t();
2300
+ }).catch(s);
2301
+ });
2302
+ });
2303
+ }
2304
+ /**
2305
+ * Настраивает позицию и размеры фона.
2306
+ */
2307
+ _setupBackgroundPosition() {
2308
+ this.backgroundObject && this.refresh();
2309
+ }
2310
+ /**
2311
+ * Удаляет текущий фон.
2312
+ */
2313
+ _removeCurrentBackground() {
2314
+ this.backgroundObject && (this.editor.canvas.remove(this.backgroundObject), this.backgroundObject = null, this.editor.canvas.renderAll());
2315
+ }
2316
+ /**
2317
+ * Создает Fabric.js градиент из параметров.
2318
+ * @param gradient - Объект с параметрами градиента
2319
+ */
2320
+ static _createFabricGradient(e) {
2321
+ const {
2322
+ angle: t,
2323
+ startColor: s,
2324
+ endColor: a,
2325
+ startPosition: n = 0,
2326
+ endPosition: o = 100
2327
+ } = e, i = t * Math.PI / 180, c = R._angleToCoords(i), d = [
2328
+ { offset: n / 100, color: s },
2329
+ { offset: o / 100, color: a }
2330
+ ];
2331
+ return new De({
2332
+ type: "linear",
2333
+ gradientUnits: "percentage",
2334
+ coords: c,
2335
+ colorStops: d
2336
+ });
2337
+ }
2338
+ /**
2339
+ * Конвертирует угол в координаты для линейного градиента.
2340
+ * @param angle - Угол в радианах
2341
+ */
2342
+ static _angleToCoords(e) {
2343
+ const t = Math.cos(e), s = Math.sin(e);
2344
+ return {
2345
+ x1: 0.5 - t * 0.5,
2346
+ y1: 0.5 - s * 0.5,
2347
+ x2: 0.5 + t * 0.5,
2348
+ y2: 0.5 + s * 0.5
2349
+ };
2350
+ }
2351
+ /**
2352
+ * Сравнивает два градиента на равенство
2353
+ * @param gradient1 - Первый градиент
2354
+ * @param gradient2 - Второй градиент
2355
+ * @returns true если градиенты одинаковые
2356
+ */
2357
+ static _isGradientEqual(e, t) {
2358
+ if (!e || !t || e.type !== "linear" || t.type !== "linear" || !(Math.abs(e.coords.x1 - t.coords.x1) < 1e-4 && Math.abs(e.coords.y1 - t.coords.y1) < 1e-4 && Math.abs(e.coords.x2 - t.coords.x2) < 1e-4 && Math.abs(e.coords.y2 - t.coords.y2) < 1e-4)) return !1;
2359
+ const a = e.colorStops || [], n = t.colorStops || [];
2360
+ return a.length !== n.length ? !1 : a.every((o, i) => {
2361
+ const c = n[i];
2362
+ return o.color === c.color && Math.abs(o.offset - c.offset) < 1e-4;
2363
+ });
2364
+ }
2365
+ }
2366
+ class X {
2093
2367
  constructor({ editor: e }) {
2094
2368
  this.editor = e;
2095
2369
  }
@@ -2101,13 +2375,13 @@ class G {
2101
2375
  * @fires editor:object-bring-to-front
2102
2376
  */
2103
2377
  bringToFront(e, { withoutSave: t } = {}) {
2104
- const { canvas: s, historyManager: n } = this.editor;
2105
- n.suspendHistory();
2106
- const i = e || s.getActiveObject();
2107
- i && (i instanceof y ? i.getObjects().forEach((a) => {
2108
- s.bringObjectToFront(a);
2109
- }) : s.bringObjectToFront(i), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-to-front", {
2110
- object: i,
2378
+ const { canvas: s, historyManager: a } = this.editor;
2379
+ a.suspendHistory();
2380
+ const n = e || s.getActiveObject();
2381
+ n && (n instanceof y ? n.getObjects().forEach((o) => {
2382
+ s.bringObjectToFront(o);
2383
+ }) : s.bringObjectToFront(n), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:object-bring-to-front", {
2384
+ object: n,
2111
2385
  withoutSave: t
2112
2386
  }));
2113
2387
  }
@@ -2119,11 +2393,11 @@ class G {
2119
2393
  * @fires editor:object-bring-forward
2120
2394
  */
2121
2395
  bringForward(e, { withoutSave: t } = {}) {
2122
- const { canvas: s, historyManager: n } = this.editor;
2123
- n.suspendHistory();
2124
- const i = e || s.getActiveObject();
2125
- i && (i instanceof y ? G._moveSelectionForward(s, i) : s.bringObjectForward(i), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-forward", {
2126
- object: i,
2396
+ const { canvas: s, historyManager: a } = this.editor;
2397
+ a.suspendHistory();
2398
+ const n = e || s.getActiveObject();
2399
+ n && (n instanceof y ? X._moveSelectionForward(s, n) : s.bringObjectForward(n), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:object-bring-forward", {
2400
+ object: n,
2127
2401
  withoutSave: t
2128
2402
  }));
2129
2403
  }
@@ -2137,21 +2411,22 @@ class G {
2137
2411
  sendToBack(e, { withoutSave: t } = {}) {
2138
2412
  const {
2139
2413
  canvas: s,
2140
- montageArea: n,
2141
- historyManager: i,
2142
- interactionBlocker: { overlayMask: a }
2414
+ montageArea: a,
2415
+ historyManager: n,
2416
+ interactionBlocker: { overlayMask: o },
2417
+ backgroundManager: { backgroundObject: i }
2143
2418
  } = this.editor;
2144
- i.suspendHistory();
2145
- const o = e || s.getActiveObject();
2146
- if (o) {
2147
- if (o instanceof y) {
2148
- const d = o.getObjects();
2149
- for (let c = d.length - 1; c >= 0; c -= 1)
2150
- s.sendObjectToBack(d[c]);
2419
+ n.suspendHistory();
2420
+ const c = e || s.getActiveObject();
2421
+ if (c) {
2422
+ if (c instanceof y) {
2423
+ const d = c.getObjects();
2424
+ for (let h = d.length - 1; h >= 0; h -= 1)
2425
+ s.sendObjectToBack(d[h]);
2151
2426
  } else
2152
- s.sendObjectToBack(o);
2153
- s.sendObjectToBack(n), a && s.sendObjectToBack(a), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:object-send-to-back", {
2154
- object: o,
2427
+ s.sendObjectToBack(c);
2428
+ i && s.sendObjectToBack(i), s.sendObjectToBack(a), o && s.sendObjectToBack(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-send-to-back", {
2429
+ object: c,
2155
2430
  withoutSave: t
2156
2431
  });
2157
2432
  }
@@ -2165,14 +2440,15 @@ class G {
2165
2440
  sendBackwards(e, { withoutSave: t } = {}) {
2166
2441
  const {
2167
2442
  canvas: s,
2168
- montageArea: n,
2169
- historyManager: i,
2170
- interactionBlocker: { overlayMask: a }
2443
+ montageArea: a,
2444
+ historyManager: n,
2445
+ interactionBlocker: { overlayMask: o },
2446
+ backgroundManager: { backgroundObject: i }
2171
2447
  } = this.editor;
2172
- i.suspendHistory();
2173
- const o = e || s.getActiveObject();
2174
- o && (o instanceof y ? G._moveSelectionBackwards(s, o) : s.sendObjectBackwards(o), s.sendObjectToBack(n), a && s.sendObjectToBack(a), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:object-send-backwards", {
2175
- object: o,
2448
+ n.suspendHistory();
2449
+ const c = e || s.getActiveObject();
2450
+ c && (c instanceof y ? X._moveSelectionBackwards(s, c) : s.sendObjectBackwards(c), i && s.sendObjectToBack(i), s.sendObjectToBack(a), o && s.sendObjectToBack(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-send-backwards", {
2451
+ object: c,
2176
2452
  withoutSave: t
2177
2453
  }));
2178
2454
  }
@@ -2183,16 +2459,16 @@ class G {
2183
2459
  * @param activeSelection - активное выделение
2184
2460
  */
2185
2461
  static _moveSelectionForward(e, t) {
2186
- const s = e.getObjects(), n = t.getObjects();
2187
- if (!n.some((o) => {
2188
- const d = s.indexOf(o);
2189
- for (let c = d + 1; c < s.length; c += 1)
2190
- if (!n.includes(s[c]))
2462
+ const s = e.getObjects(), a = t.getObjects();
2463
+ if (!a.some((i) => {
2464
+ const c = s.indexOf(i);
2465
+ for (let d = c + 1; d < s.length; d += 1)
2466
+ if (!a.includes(s[d]))
2191
2467
  return !0;
2192
2468
  return !1;
2193
2469
  })) return;
2194
- n.map((o) => ({ obj: o, index: s.indexOf(o) })).sort((o, d) => d.index - o.index).forEach((o) => {
2195
- e.bringObjectForward(o.obj);
2470
+ a.map((i) => ({ obj: i, index: s.indexOf(i) })).sort((i, c) => c.index - i.index).forEach((i) => {
2471
+ e.bringObjectForward(i.obj);
2196
2472
  });
2197
2473
  }
2198
2474
  /**
@@ -2202,20 +2478,20 @@ class G {
2202
2478
  * @param activeSelection - активное выделение
2203
2479
  */
2204
2480
  static _moveSelectionBackwards(e, t) {
2205
- const s = e.getObjects(), n = t.getObjects();
2206
- if (!n.some((o) => {
2207
- const d = s.indexOf(o);
2208
- for (let c = d - 1; c >= 0; c -= 1)
2209
- if (!n.includes(s[c]))
2481
+ const s = e.getObjects(), a = t.getObjects();
2482
+ if (!a.some((i) => {
2483
+ const c = s.indexOf(i);
2484
+ for (let d = c - 1; d >= 0; d -= 1)
2485
+ if (!a.includes(s[d]))
2210
2486
  return !0;
2211
2487
  return !1;
2212
2488
  })) return;
2213
- n.map((o) => ({ obj: o, index: s.indexOf(o) })).sort((o, d) => o.index - d.index).forEach((o) => {
2214
- e.sendObjectBackwards(o.obj);
2489
+ a.map((i) => ({ obj: i, index: s.indexOf(i) })).sort((i, c) => i.index - c.index).forEach((i) => {
2490
+ e.sendObjectBackwards(i.obj);
2215
2491
  });
2216
2492
  }
2217
2493
  }
2218
- class lt {
2494
+ class gt {
2219
2495
  /**
2220
2496
  * Менеджер фигур для редактора.
2221
2497
  * @param options - Опции и настройки менеджера фигур.
@@ -2239,15 +2515,15 @@ class lt {
2239
2515
  * @param flags.withoutSelection - Не выделять объект
2240
2516
  * @param flags.withoutAdding - Не добавлять объект в canvas
2241
2517
  */
2242
- addRectangle(h = {}, { withoutSelection: d, withoutAdding: c } = {}) {
2518
+ addRectangle(h = {}, { withoutSelection: c, withoutAdding: d } = {}) {
2243
2519
  var l = h, {
2244
- id: e = `rect-${D()}`,
2520
+ id: e = `rect-${v()}`,
2245
2521
  left: t,
2246
2522
  top: s,
2247
- width: n = 100,
2248
- height: i = 100,
2249
- fill: a = "blue"
2250
- } = l, o = P(l, [
2523
+ width: a = 100,
2524
+ height: n = 100,
2525
+ fill: o = "blue"
2526
+ } = l, i = W(l, [
2251
2527
  "id",
2252
2528
  "left",
2253
2529
  "top",
@@ -2255,15 +2531,15 @@ class lt {
2255
2531
  "height",
2256
2532
  "fill"
2257
2533
  ]);
2258
- const { canvas: g } = this.editor, M = new De(p({
2534
+ const { canvas: g } = this.editor, M = new Ne(p({
2259
2535
  id: e,
2260
2536
  left: t,
2261
2537
  top: s,
2262
- width: n,
2263
- height: i,
2264
- fill: a
2265
- }, o));
2266
- return !t && !s && g.centerObject(M), c || (g.add(M), d || g.setActiveObject(M), g.renderAll()), M;
2538
+ width: a,
2539
+ height: n,
2540
+ fill: o
2541
+ }, i));
2542
+ return !t && !s && g.centerObject(M), d || (g.add(M), c || g.setActiveObject(M), g.renderAll()), M;
2267
2543
  }
2268
2544
  /**
2269
2545
  * Добавление круга
@@ -2281,28 +2557,28 @@ class lt {
2281
2557
  * @param flags.withoutSelection - Не выделять объект
2282
2558
  * @param flags.withoutAdding - Не добавлять объект в canvas
2283
2559
  */
2284
- addCircle(c = {}, { withoutSelection: o, withoutAdding: d } = {}) {
2285
- var h = c, {
2286
- id: e = `circle-${D()}`,
2560
+ addCircle(d = {}, { withoutSelection: i, withoutAdding: c } = {}) {
2561
+ var h = d, {
2562
+ id: e = `circle-${v()}`,
2287
2563
  left: t,
2288
2564
  top: s,
2289
- radius: n = 50,
2290
- fill: i = "green"
2291
- } = h, a = P(h, [
2565
+ radius: a = 50,
2566
+ fill: n = "green"
2567
+ } = h, o = W(h, [
2292
2568
  "id",
2293
2569
  "left",
2294
2570
  "top",
2295
2571
  "radius",
2296
2572
  "fill"
2297
2573
  ]);
2298
- const { canvas: l } = this.editor, g = new Ne(p({
2574
+ const { canvas: l } = this.editor, g = new Oe(p({
2299
2575
  id: e,
2300
2576
  left: t,
2301
2577
  top: s,
2302
- fill: i,
2303
- radius: n
2304
- }, a));
2305
- return !t && !s && l.centerObject(g), d || (l.add(g), o || l.setActiveObject(g), l.renderAll()), g;
2578
+ fill: n,
2579
+ radius: a
2580
+ }, o));
2581
+ return !t && !s && l.centerObject(g), c || (l.add(g), i || l.setActiveObject(g), l.renderAll()), g;
2306
2582
  }
2307
2583
  /**
2308
2584
  * Добавление треугольника
@@ -2321,15 +2597,15 @@ class lt {
2321
2597
  * @param flags.withoutSelection - Не выделять объект
2322
2598
  * @param flags.withoutAdding - Не добавлять объект в canvas
2323
2599
  */
2324
- addTriangle(h = {}, { withoutSelection: d, withoutAdding: c } = {}) {
2600
+ addTriangle(h = {}, { withoutSelection: c, withoutAdding: d } = {}) {
2325
2601
  var l = h, {
2326
- id: e = `triangle-${D()}`,
2602
+ id: e = `triangle-${v()}`,
2327
2603
  left: t,
2328
2604
  top: s,
2329
- width: n = 100,
2330
- height: i = 100,
2331
- fill: a = "yellow"
2332
- } = l, o = P(l, [
2605
+ width: a = 100,
2606
+ height: n = 100,
2607
+ fill: o = "yellow"
2608
+ } = l, i = W(l, [
2333
2609
  "id",
2334
2610
  "left",
2335
2611
  "top",
@@ -2337,18 +2613,18 @@ class lt {
2337
2613
  "height",
2338
2614
  "fill"
2339
2615
  ]);
2340
- const { canvas: g } = this.editor, M = new Ee(p({
2616
+ const { canvas: g } = this.editor, M = new Le(p({
2341
2617
  id: e,
2342
2618
  left: t,
2343
2619
  top: s,
2344
- fill: a,
2345
- width: n,
2346
- height: i
2347
- }, o));
2348
- return !t && !s && g.centerObject(M), c || (g.add(M), d || g.setActiveObject(M), g.renderAll()), M;
2620
+ fill: o,
2621
+ width: a,
2622
+ height: n
2623
+ }, i));
2624
+ return !t && !s && g.centerObject(M), d || (g.add(M), c || g.setActiveObject(M), g.renderAll()), M;
2349
2625
  }
2350
2626
  }
2351
- class ht {
2627
+ class ut {
2352
2628
  /**
2353
2629
  * @param options
2354
2630
  * @param options.editor - экземпляр редактора с доступом к canvas
@@ -2376,18 +2652,18 @@ class ht {
2376
2652
  * Асинхронное клонирование для внутреннего буфера
2377
2653
  */
2378
2654
  _cloneToInternalClipboard(e) {
2379
- return j(this, null, function* () {
2655
+ return b(this, null, function* () {
2380
2656
  const { canvas: t, errorManager: s } = this.editor;
2381
2657
  try {
2382
- const n = yield e.clone(["format"]);
2383
- this.clipboard = n, t.fire("editor:object-copied", { object: n });
2384
- } catch (n) {
2658
+ const a = yield e.clone(["format"]);
2659
+ this.clipboard = a, t.fire("editor:object-copied", { object: a });
2660
+ } catch (a) {
2385
2661
  s.emitError({
2386
2662
  origin: "ClipboardManager",
2387
2663
  method: "_cloneToInternalClipboard",
2388
2664
  code: "CLONE_FAILED",
2389
2665
  message: "Ошибка клонирования объекта для внутреннего буфера",
2390
- data: n
2666
+ data: a
2391
2667
  });
2392
2668
  }
2393
2669
  });
@@ -2396,7 +2672,7 @@ class ht {
2396
2672
  * Копирование в системный буфер обмена
2397
2673
  */
2398
2674
  _copyToSystemClipboard(e) {
2399
- return j(this, null, function* () {
2675
+ return b(this, null, function* () {
2400
2676
  const { errorManager: t } = this.editor;
2401
2677
  if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
2402
2678
  return t.emitWarning({
@@ -2406,8 +2682,8 @@ class ht {
2406
2682
  message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
2407
2683
  }), !1;
2408
2684
  try {
2409
- const s = e.toObject(["format"]), n = JSON.stringify(s);
2410
- return e.type === "image" ? this._copyImageToClipboard(e, n) : this._copyTextToClipboard(n);
2685
+ const s = e.toObject(["format"]), a = JSON.stringify(s);
2686
+ return e.type === "image" ? this._copyImageToClipboard(e, a) : this._copyTextToClipboard(a);
2411
2687
  } catch (s) {
2412
2688
  return t.emitError({
2413
2689
  origin: "ClipboardManager",
@@ -2423,12 +2699,12 @@ class ht {
2423
2699
  * Копирование изображения в буфер обмена
2424
2700
  */
2425
2701
  _copyImageToClipboard(e, t) {
2426
- return j(this, null, function* () {
2702
+ return b(this, null, function* () {
2427
2703
  try {
2428
- const n = e.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), i = n.slice(5).split(";")[0], a = n.split(",")[1], o = atob(a), d = new Uint8Array(o.length);
2429
- for (let l = 0; l < o.length; l += 1)
2430
- d[l] = o.charCodeAt(l);
2431
- const c = new Blob([d.buffer], { type: i }), h = new ClipboardItem({ [i]: c });
2704
+ const a = e.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), n = a.slice(5).split(";")[0], o = a.split(",")[1], i = atob(o), c = new Uint8Array(i.length);
2705
+ for (let l = 0; l < i.length; l += 1)
2706
+ c[l] = i.charCodeAt(l);
2707
+ const d = new Blob([c.buffer], { type: n }), h = new ClipboardItem({ [n]: d });
2432
2708
  return yield navigator.clipboard.write([h]), console.info("Image copied to clipboard successfully"), !0;
2433
2709
  } catch (s) {
2434
2710
  return this.editor.errorManager.emitWarning({
@@ -2445,7 +2721,7 @@ class ht {
2445
2721
  * Копирование текста в буфер обмена
2446
2722
  */
2447
2723
  _copyTextToClipboard(e) {
2448
- return j(this, null, function* () {
2724
+ return b(this, null, function* () {
2449
2725
  try {
2450
2726
  const t = `${me}${e}`;
2451
2727
  return yield navigator.clipboard.writeText(t), console.info("Text copied to clipboard successfully"), !0;
@@ -2468,8 +2744,8 @@ class ht {
2468
2744
  _addClonedObjectToCanvas(e) {
2469
2745
  const { canvas: t, historyManager: s } = this.editor;
2470
2746
  if (t.discardActiveObject(), e instanceof y) {
2471
- s.suspendHistory(), e.canvas = t, e.forEachObject((n) => {
2472
- t.add(n);
2747
+ s.suspendHistory(), e.canvas = t, e.forEachObject((a) => {
2748
+ t.add(a);
2473
2749
  }), t.setActiveObject(e), t.requestRenderAll(), s.resumeHistory(), s.saveState();
2474
2750
  return;
2475
2751
  }
@@ -2480,7 +2756,7 @@ class ht {
2480
2756
  * @param source - источник изображения (data URL или URL)
2481
2757
  */
2482
2758
  _handleImageImport(e) {
2483
- return j(this, null, function* () {
2759
+ return b(this, null, function* () {
2484
2760
  var s;
2485
2761
  const { image: t } = (s = yield this.editor.imageManager.importImage({
2486
2762
  source: e,
@@ -2496,25 +2772,25 @@ class ht {
2496
2772
  * @fires editor:object-pasted
2497
2773
  */
2498
2774
  copyPaste(e) {
2499
- return j(this, null, function* () {
2775
+ return b(this, null, function* () {
2500
2776
  const { canvas: t } = this.editor, s = e || t.getActiveObject();
2501
2777
  if (!s || s.locked) return !1;
2502
2778
  try {
2503
- const n = yield s.clone(["format"]);
2504
- return n.set({
2505
- id: `${n.type}-${D()}`,
2506
- left: n.left + 10,
2507
- top: n.top + 10,
2779
+ const a = yield s.clone(["format"]);
2780
+ return a.set({
2781
+ id: `${a.type}-${v()}`,
2782
+ left: a.left + 10,
2783
+ top: a.top + 10,
2508
2784
  evented: !0
2509
- }), this._addClonedObjectToCanvas(n), t.fire("editor:object-duplicated", { object: n }), !0;
2510
- } catch (n) {
2511
- const { errorManager: i } = this.editor;
2512
- return i.emitError({
2785
+ }), this._addClonedObjectToCanvas(a), t.fire("editor:object-duplicated", { object: a }), !0;
2786
+ } catch (a) {
2787
+ const { errorManager: n } = this.editor;
2788
+ return n.emitError({
2513
2789
  origin: "ClipboardManager",
2514
2790
  method: "copyPaste",
2515
2791
  code: "COPY_PASTE_FAILED",
2516
2792
  message: "Ошибка создания копии объекта",
2517
- data: n
2793
+ data: a
2518
2794
  }), !1;
2519
2795
  }
2520
2796
  });
@@ -2526,9 +2802,9 @@ class ht {
2526
2802
  * @param event.clipboardData.items — элементы буфера обмена
2527
2803
  */
2528
2804
  handlePasteEvent(t) {
2529
- return j(this, arguments, function* ({ clipboardData: e }) {
2530
- var d;
2531
- if (!((d = e == null ? void 0 : e.items) != null && d.length)) {
2805
+ return b(this, arguments, function* ({ clipboardData: e }) {
2806
+ var c;
2807
+ if (!((c = e == null ? void 0 : e.items) != null && c.length)) {
2532
2808
  this.paste();
2533
2809
  return;
2534
2810
  }
@@ -2537,10 +2813,10 @@ class ht {
2537
2813
  this.paste();
2538
2814
  return;
2539
2815
  }
2540
- const { items: n } = e, i = n[n.length - 1], a = i.getAsFile();
2541
- if (i.type !== "text/html" && a) {
2542
- const c = new FileReader();
2543
- c.onload = (h) => {
2816
+ const { items: a } = e, n = a[a.length - 1], o = n.getAsFile();
2817
+ if (n.type !== "text/html" && o) {
2818
+ const d = new FileReader();
2819
+ d.onload = (h) => {
2544
2820
  h.target && this._handleImageImport(h.target.result).catch((l) => {
2545
2821
  this.editor.errorManager.emitError({
2546
2822
  origin: "ClipboardManager",
@@ -2550,12 +2826,12 @@ class ht {
2550
2826
  data: l
2551
2827
  });
2552
2828
  });
2553
- }, c.readAsDataURL(a);
2829
+ }, d.readAsDataURL(o);
2554
2830
  return;
2555
2831
  }
2556
- const o = e.getData("text/html");
2557
- if (o) {
2558
- const l = new DOMParser().parseFromString(o, "text/html").querySelector("img");
2832
+ const i = e.getData("text/html");
2833
+ if (i) {
2834
+ const l = new DOMParser().parseFromString(i, "text/html").querySelector("img");
2559
2835
  if (l != null && l.src) {
2560
2836
  this._handleImageImport(l.src).catch((g) => {
2561
2837
  this.editor.errorManager.emitError({
@@ -2577,13 +2853,13 @@ class ht {
2577
2853
  * @fires editor:object-pasted
2578
2854
  */
2579
2855
  paste() {
2580
- return j(this, null, function* () {
2856
+ return b(this, null, function* () {
2581
2857
  const { canvas: e } = this.editor;
2582
2858
  if (!this.clipboard) return !1;
2583
2859
  try {
2584
2860
  const t = yield this.clipboard.clone(["format"]);
2585
2861
  return e.discardActiveObject(), t.set({
2586
- id: `${t.type}-${D()}`,
2862
+ id: `${t.type}-${v()}`,
2587
2863
  left: t.left + 10,
2588
2864
  top: t.top + 10,
2589
2865
  evented: !0
@@ -2601,7 +2877,7 @@ class ht {
2601
2877
  });
2602
2878
  }
2603
2879
  }
2604
- class X {
2880
+ class Q {
2605
2881
  constructor({ editor: e }) {
2606
2882
  this.editor = e;
2607
2883
  }
@@ -2614,9 +2890,9 @@ class X {
2614
2890
  * @fires editor:object-locked
2615
2891
  */
2616
2892
  lockObject({ object: e, skipInnerObjects: t, withoutSave: s } = {}) {
2617
- const { canvas: n, historyManager: i } = this.editor, a = e || n.getActiveObject();
2618
- if (!a || a.locked) return;
2619
- const o = {
2893
+ const { canvas: a, historyManager: n } = this.editor, o = e || a.getActiveObject();
2894
+ if (!o || o.locked) return;
2895
+ const i = {
2620
2896
  lockMovementX: !0,
2621
2897
  lockMovementY: !0,
2622
2898
  lockRotation: !0,
@@ -2626,10 +2902,10 @@ class X {
2626
2902
  lockSkewingY: !0,
2627
2903
  locked: !0
2628
2904
  };
2629
- a.set(o), !t && X._isGroupOrSelection(a) && a.getObjects().forEach((c) => {
2630
- c.set(o);
2631
- }), n.renderAll(), s || i.saveState(), n.fire("editor:object-locked", {
2632
- object: a,
2905
+ o.set(i), !t && Q._isGroupOrSelection(o) && o.getObjects().forEach((d) => {
2906
+ d.set(i);
2907
+ }), a.renderAll(), s || n.saveState(), a.fire("editor:object-locked", {
2908
+ object: o,
2633
2909
  skipInnerObjects: t,
2634
2910
  withoutSave: s
2635
2911
  });
@@ -2642,9 +2918,9 @@ class X {
2642
2918
  * @fires editor:object-unlocked
2643
2919
  */
2644
2920
  unlockObject({ object: e, withoutSave: t } = {}) {
2645
- const { canvas: s, historyManager: n } = this.editor, i = e || s.getActiveObject();
2646
- if (!i) return;
2647
- const a = {
2921
+ const { canvas: s, historyManager: a } = this.editor, n = e || s.getActiveObject();
2922
+ if (!n) return;
2923
+ const o = {
2648
2924
  lockMovementX: !1,
2649
2925
  lockMovementY: !1,
2650
2926
  lockRotation: !1,
@@ -2654,10 +2930,10 @@ class X {
2654
2930
  lockSkewingY: !1,
2655
2931
  locked: !1
2656
2932
  };
2657
- i.set(a), X._isGroupOrSelection(i) && i.getObjects().forEach((o) => {
2658
- o.set(a);
2659
- }), s.renderAll(), t || n.saveState(), s.fire("editor:object-unlocked", {
2660
- object: i,
2933
+ n.set(o), Q._isGroupOrSelection(n) && n.getObjects().forEach((i) => {
2934
+ i.set(o);
2935
+ }), s.renderAll(), t || a.saveState(), s.fire("editor:object-unlocked", {
2936
+ object: n,
2661
2937
  withoutSave: t
2662
2938
  });
2663
2939
  }
@@ -2665,7 +2941,7 @@ class X {
2665
2941
  return e instanceof y || e instanceof J;
2666
2942
  }
2667
2943
  }
2668
- class gt {
2944
+ class Mt {
2669
2945
  constructor({ editor: e }) {
2670
2946
  this.editor = e;
2671
2947
  }
@@ -2680,14 +2956,14 @@ class gt {
2680
2956
  object: e,
2681
2957
  withoutSave: t
2682
2958
  } = {}) {
2683
- const { canvas: s, historyManager: n } = this.editor;
2684
- n.suspendHistory();
2685
- const i = e || s.getActiveObject();
2686
- if (!i || !(i instanceof y)) return;
2687
- const a = i.getObjects(), o = new J(a);
2688
- a.forEach((d) => s.remove(d)), o.set("id", `${o.type}-${D()}`), s.add(o), s.setActiveObject(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-grouped", {
2689
- object: i,
2690
- group: o,
2959
+ const { canvas: s, historyManager: a } = this.editor;
2960
+ a.suspendHistory();
2961
+ const n = e || s.getActiveObject();
2962
+ if (!n || !(n instanceof y)) return;
2963
+ const o = n.getObjects(), i = new J(o);
2964
+ o.forEach((c) => s.remove(c)), i.set("id", `${i.type}-${v()}`), s.add(i), s.setActiveObject(i), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:objects-grouped", {
2965
+ object: n,
2966
+ group: i,
2691
2967
  withoutSave: t
2692
2968
  });
2693
2969
  }
@@ -2702,23 +2978,23 @@ class gt {
2702
2978
  object: e,
2703
2979
  withoutSave: t
2704
2980
  } = {}) {
2705
- const { canvas: s, historyManager: n } = this.editor;
2706
- n.suspendHistory();
2707
- const i = e || s.getActiveObject();
2708
- if (!(i instanceof J)) return;
2709
- const a = i.removeAll();
2710
- s.remove(i), a.forEach((d) => s.add(d));
2711
- const o = new y(a, {
2981
+ const { canvas: s, historyManager: a } = this.editor;
2982
+ a.suspendHistory();
2983
+ const n = e || s.getActiveObject();
2984
+ if (!(n instanceof J)) return;
2985
+ const o = n.removeAll();
2986
+ s.remove(n), o.forEach((c) => s.add(c));
2987
+ const i = new y(o, {
2712
2988
  canvas: s
2713
2989
  });
2714
- s.setActiveObject(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-ungrouped", {
2715
- object: i,
2716
- selection: o,
2990
+ s.setActiveObject(i), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:objects-ungrouped", {
2991
+ object: n,
2992
+ selection: i,
2717
2993
  withoutSave: t
2718
2994
  });
2719
2995
  }
2720
2996
  }
2721
- class ut {
2997
+ class ft {
2722
2998
  constructor({ editor: e }) {
2723
2999
  this.editor = e;
2724
3000
  }
@@ -2729,11 +3005,11 @@ class ut {
2729
3005
  selectAll() {
2730
3006
  const { canvas: e, canvasManager: t, objectLockManager: s } = this.editor;
2731
3007
  e.discardActiveObject();
2732
- const n = t.getObjects(), i = n.some((o) => o.locked), a = n.length > 1 ? new y(t.getObjects(), { canvas: e }) : n[0];
2733
- i && s.lockObject({ object: a, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(a), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: a });
3008
+ const a = t.getObjects(), n = a.some((i) => i.locked), o = a.length > 1 ? new y(t.getObjects(), { canvas: e }) : a[0];
3009
+ n && s.lockObject({ object: o, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(o), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: o });
2734
3010
  }
2735
3011
  }
2736
- class Mt {
3012
+ class mt {
2737
3013
  constructor({ editor: e }) {
2738
3014
  this.editor = e;
2739
3015
  }
@@ -2748,20 +3024,20 @@ class Mt {
2748
3024
  objects: e,
2749
3025
  withoutSave: t
2750
3026
  } = {}) {
2751
- const { canvas: s, historyManager: n, groupingManager: i } = this.editor, a = (e || s.getActiveObjects()).filter((o) => !o.locked);
2752
- a != null && a.length && (n.suspendHistory(), a.forEach((o) => {
2753
- if (o.type === "group" && o.format !== "svg") {
2754
- i.ungroup({ object: o, withoutSave: t }), this.deleteSelectedObjects();
3027
+ const { canvas: s, historyManager: a, groupingManager: n } = this.editor, o = (e || s.getActiveObjects()).filter((i) => !i.locked);
3028
+ o != null && o.length && (a.suspendHistory(), o.forEach((i) => {
3029
+ if (i.type === "group" && i.format !== "svg") {
3030
+ n.ungroup({ object: i, withoutSave: t }), this.deleteSelectedObjects();
2755
3031
  return;
2756
3032
  }
2757
- s.remove(o);
2758
- }), s.discardActiveObject(), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-deleted", {
2759
- objects: a,
3033
+ s.remove(i);
3034
+ }), s.discardActiveObject(), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:objects-deleted", {
3035
+ objects: o,
2760
3036
  withoutSave: t
2761
3037
  }));
2762
3038
  }
2763
3039
  }
2764
- const mt = {
3040
+ const bt = {
2765
3041
  IMAGE_MANAGER: {
2766
3042
  /**
2767
3043
  * Некорректный Content-Type изображения
@@ -2837,9 +3113,30 @@ const mt = {
2837
3113
  HISTORY_MANAGER: {
2838
3114
  UNDO_ERROR: "UNDO_ERROR",
2839
3115
  REDO_ERROR: "REDO_ERROR"
3116
+ },
3117
+ /**
3118
+ * Коды ошибок и предупреждений для BackgroundManager.
3119
+ */
3120
+ BACKGROUND_MANAGER: {
3121
+ /**
3122
+ * Ошибка создания фона.
3123
+ */
3124
+ BACKGROUND_CREATION_FAILED: "BACKGROUND_CREATION_FAILED",
3125
+ /**
3126
+ * Ошибка удаления фона.
3127
+ */
3128
+ BACKGROUND_REMOVAL_FAILED: "BACKGROUND_REMOVAL_FAILED",
3129
+ /**
3130
+ * Предупреждение об отсутствии фона для удаления.
3131
+ */
3132
+ NO_BACKGROUND_TO_REMOVE: "NO_BACKGROUND_TO_REMOVE",
3133
+ /**
3134
+ * Ошибка парсинга градиента.
3135
+ */
3136
+ INVALID_GRADIENT_FORMAT: "INVALID_GRADIENT_FORMAT"
2840
3137
  }
2841
3138
  };
2842
- class Q {
3139
+ class K {
2843
3140
  constructor({ editor: e }) {
2844
3141
  this._buffer = [], this.editor = e;
2845
3142
  }
@@ -2865,24 +3162,24 @@ class Q {
2865
3162
  * @param options.message — текст ошибки (опционально, если не передан, то используется код ошибки)
2866
3163
  * @fires editor:error
2867
3164
  */
2868
- emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: n, message: i }) {
2869
- if (!Q.isValidErrorCode(s)) {
3165
+ emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: a, message: n }) {
3166
+ if (!K.isValidErrorCode(s)) {
2870
3167
  console.warn("Неизвестный код ошибки: ", { code: s, origin: e, method: t });
2871
3168
  return;
2872
3169
  }
2873
3170
  if (!s) return;
2874
- const a = i || s;
2875
- console.error(`${e}. ${t}. ${s}. ${a}`, n);
2876
- const o = {
3171
+ const o = n || s;
3172
+ console.error(`${e}. ${t}. ${s}. ${o}`, a);
3173
+ const i = {
2877
3174
  code: s,
2878
3175
  origin: e,
2879
3176
  method: t,
2880
- message: a,
2881
- data: n
3177
+ message: o,
3178
+ data: a
2882
3179
  };
2883
3180
  this._buffer.push(p({
2884
3181
  type: "editor:error"
2885
- }, o)), this.editor.canvas.fire("editor:error", o);
3182
+ }, i)), this.editor.canvas.fire("editor:error", i);
2886
3183
  }
2887
3184
  /**
2888
3185
  * Эмитит предупреждение через fabricjs
@@ -2894,23 +3191,23 @@ class Q {
2894
3191
  * @param options.message — текст предупреждения (опционально, если не передан, то используется код предупреждения)
2895
3192
  * @fires editor:warning
2896
3193
  */
2897
- emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: n, data: i }) {
2898
- if (!Q.isValidErrorCode(s)) {
3194
+ emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: a, data: n }) {
3195
+ if (!K.isValidErrorCode(s)) {
2899
3196
  console.warn("Неизвестный код предупреждения: ", { code: s, origin: e, method: t });
2900
3197
  return;
2901
3198
  }
2902
- const a = n || s;
2903
- console.warn(`${e}. ${t}. ${s}. ${a}`, i);
2904
- const o = {
3199
+ const o = a || s;
3200
+ console.warn(`${e}. ${t}. ${s}. ${o}`, n);
3201
+ const i = {
2905
3202
  code: s,
2906
3203
  origin: e,
2907
3204
  method: t,
2908
- message: a,
2909
- data: i
3205
+ message: o,
3206
+ data: n
2910
3207
  };
2911
3208
  this._buffer.push(p({
2912
3209
  type: "editor:warning"
2913
- }, o)), this.editor.canvas.fire("editor:warning", o);
3210
+ }, i)), this.editor.canvas.fire("editor:warning", i);
2914
3211
  }
2915
3212
  /**
2916
3213
  * Проверяет, является ли код ошибки или предупреждения допустимым
@@ -2918,17 +3215,17 @@ class Q {
2918
3215
  * @returns true, если код допустим, иначе false
2919
3216
  */
2920
3217
  static isValidErrorCode(e) {
2921
- return e ? Object.values(mt).some((t) => Object.values(t).includes(e)) : !1;
3218
+ return e ? Object.values(bt).some((t) => Object.values(t).includes(e)) : !1;
2922
3219
  }
2923
3220
  }
2924
- class ae {
3221
+ class ie {
2925
3222
  /**
2926
3223
  * Конструктор класса ImageEditor.
2927
3224
  * @param canvasId - идентификатор канваса, в котором будет создан редактор
2928
3225
  * @param options - опции и настройки редактора
2929
3226
  */
2930
3227
  constructor(e, t) {
2931
- this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.clipboard = null, this.init();
3228
+ this.options = t, this.containerId = e, this.editorId = `${e}-${v()}`, this.clipboard = null, this.init();
2932
3229
  }
2933
3230
  /**
2934
3231
  * Инициализация редактора.
@@ -2936,29 +3233,29 @@ class ae {
2936
3233
  * @fires editor:ready
2937
3234
  */
2938
3235
  init() {
2939
- return j(this, null, function* () {
3236
+ return b(this, null, function* () {
2940
3237
  const {
2941
3238
  editorContainerWidth: e,
2942
3239
  editorContainerHeight: t,
2943
3240
  canvasWrapperWidth: s,
2944
- canvasWrapperHeight: n,
2945
- canvasCSSWidth: i,
2946
- canvasCSSHeight: a,
2947
- initialImage: o,
2948
- initialStateJSON: d,
2949
- scaleType: c,
3241
+ canvasWrapperHeight: a,
3242
+ canvasCSSWidth: n,
3243
+ canvasCSSHeight: o,
3244
+ initialImage: i,
3245
+ initialStateJSON: c,
3246
+ scaleType: d,
2950
3247
  _onReadyCallback: h
2951
3248
  } = this.options;
2952
- if (We.apply(), this.canvas = new Le(this.containerId, this.options), this.moduleLoader = new xe(), this.workerManager = new _e(), this.errorManager = new Q({ editor: this }), this.historyManager = new et({ editor: this }), this.toolbar = new qe({ editor: this }), this.transformManager = new ct({ editor: this }), this.canvasManager = new rt({ editor: this }), this.imageManager = new L({ editor: this }), this.layerManager = new G({ editor: this }), this.shapeManager = new lt({ editor: this }), this.interactionBlocker = new dt({ editor: this }), this.clipboardManager = new ht({ editor: this }), this.objectLockManager = new X({ editor: this }), this.groupingManager = new gt({ editor: this }), this.selectionManager = new ut({ editor: this }), this.deletionManager = new Mt({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new Z({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(i), this.canvasManager.setCanvasCSSHeight(a), o != null && o.source) {
3249
+ if (Ve.apply(), this.canvas = new Te(this.containerId, this.options), this.moduleLoader = new xe(), this.workerManager = new Ue(), this.errorManager = new K({ editor: this }), this.historyManager = new st({ editor: this }), this.toolbar = new tt({ editor: this }), this.transformManager = new lt({ editor: this }), this.canvasManager = new dt({ editor: this }), this.imageManager = new O({ editor: this }), this.layerManager = new X({ editor: this }), this.shapeManager = new gt({ editor: this }), this.interactionBlocker = new ht({ editor: this }), this.backgroundManager = new R({ editor: this }), this.clipboardManager = new ut({ editor: this }), this.objectLockManager = new Q({ editor: this }), this.groupingManager = new Mt({ editor: this }), this.selectionManager = new ft({ editor: this }), this.deletionManager = new mt({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new Z({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(a), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(o), i != null && i.source) {
2953
3250
  const {
2954
3251
  source: l,
2955
- scale: g = `image-${c}`,
3252
+ scale: g = `image-${d}`,
2956
3253
  withoutSave: M = !0
2957
- } = o;
3254
+ } = i;
2958
3255
  yield this.imageManager.importImage({ source: l, scale: g, withoutSave: M });
2959
3256
  } else
2960
3257
  this.canvasManager.setDefaultScale({ withoutSave: !0 });
2961
- d && this.historyManager.loadStateFromFullState(d), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof h == "function" && h(this);
3258
+ c && this.historyManager.loadStateFromFullState(c), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof h == "function" && h(this);
2962
3259
  });
2963
3260
  }
2964
3261
  /**
@@ -2972,7 +3269,7 @@ class ae {
2972
3269
  this.montageArea = this.shapeManager.addRectangle({
2973
3270
  width: e,
2974
3271
  height: t,
2975
- fill: ae._createMosaicPattern(),
3272
+ fill: ie._createMosaicPattern(),
2976
3273
  stroke: null,
2977
3274
  strokeWidth: 0,
2978
3275
  selectable: !1,
@@ -3028,7 +3325,7 @@ class ae {
3028
3325
  });
3029
3326
  }
3030
3327
  }
3031
- const ft = {
3328
+ const jt = {
3032
3329
  /**
3033
3330
  * Опции редактора
3034
3331
  */
@@ -3117,18 +3414,18 @@ const ft = {
3117
3414
  resetObjectFitByDoubleClick: !0,
3118
3415
  keyboardIgnoreSelectors: []
3119
3416
  };
3120
- function At(r, e = {}) {
3121
- const t = p(p({}, ft), e), s = document.getElementById(r);
3417
+ function St(r, e = {}) {
3418
+ const t = p(p({}, jt), e), s = document.getElementById(r);
3122
3419
  if (!s)
3123
3420
  return Promise.reject(new Error(`Контейнер с ID "${r}" не найден.`));
3124
- const n = document.createElement("canvas");
3125
- return n.id = `${r}-canvas`, s.appendChild(n), t.editorContainer = s, new Promise((i) => {
3126
- t._onReadyCallback = i;
3127
- const a = new ae(n.id, t);
3128
- window[r] = a;
3421
+ const a = document.createElement("canvas");
3422
+ return a.id = `${r}-canvas`, s.appendChild(a), t.editorContainer = s, new Promise((n) => {
3423
+ t._onReadyCallback = n;
3424
+ const o = new ie(a.id, t);
3425
+ window[r] = o;
3129
3426
  });
3130
3427
  }
3131
3428
  export {
3132
- At as default
3429
+ St as default
3133
3430
  };
3134
3431
  //# sourceMappingURL=main.js.map