@anu3ev/fabric-image-editor 0.1.71 → 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 +984 -682
  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 a = (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
- }, i = (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(a, i);
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 Le, Triangle as Ne, Group as J, Canvas as Ee, Pattern as we } from "fabric";
39
- import { create as Oe } from "jsondiffpatch";
40
- import Te 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: a,
76
- pasteImageFromClipboard: i,
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 }), a && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), i && 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
- (i, o) => o.locked ? (i.lockedObjects.push(o), i) : (i.unlockedObjects.push(o), i),
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 i = new y(n, {
101
+ const o = new y(a, {
102
102
  canvas: this.canvas
103
103
  });
104
- this.canvas.setActiveObject(i);
104
+ this.canvas.setActiveObject(o);
105
105
  }
106
106
  this.canvas.requestRenderAll();
107
107
  return;
108
108
  }
109
- const a = new y(e, {
109
+ const n = new y(e, {
110
110
  canvas: this.canvas
111
111
  });
112
112
  this.editor.objectLockManager.lockObject({
113
- object: a,
113
+ object: n,
114
114
  skipInnerObjects: !0,
115
115
  withoutSave: !0
116
- }), this.canvas.setActiveObject(a), 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,15 +157,15 @@ 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
  * Обработчик вставки объекта или изображения из буфера обмена.
162
165
  * @param event — объект события
163
166
  */
164
167
  handlePasteEvent(e) {
165
- this.editor.clipboardManager.handlePasteEvent(e);
168
+ this._shouldIgnoreKeyboardEvent(e) || this.editor.clipboardManager.handlePasteEvent(e);
166
169
  }
167
170
  /**
168
171
  * Обработчик для отмены/повтора (Ctrl+Z/Ctrl+Y).
@@ -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: a } = e;
177
- this._shouldIgnoreKeyboardEvent(e) || !t && !s || a || !/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: a } = this;
217
- if (n || a) 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 i = t.getActiveObject() || null;
220
- i instanceof y ? this.savedSelection = i.getObjects().slice() : i && (this.savedSelection = [i]), 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((i) => s.canvasManager.getObjects().includes(i)), a = new y(n, { canvas: t });
260
- t.setActiveObject(a);
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,32 +325,37 @@ class Z {
322
325
  * @returns true если событие должно быть проигнорировано
323
326
  */
324
327
  _shouldIgnoreKeyboardEvent(e) {
325
- const t = e.target;
326
- if (!t) return !1;
327
- const s = ["input", "textarea", "select"], n = t.tagName.toLowerCase();
328
- if (s.includes(n) || t.contentEditable === "true") return !0;
329
- const { keyboardIgnoreSelectors: a } = this.options;
330
- if (a != null && a.length)
331
- for (const i of a)
332
- try {
333
- if (t.matches && t.matches(i) || t.closest && t.closest(i))
334
- return !0;
335
- } catch (o) {
336
- this.editor.errorManager.emitWarning({
337
- origin: "Listeners",
338
- method: "_shouldIgnoreKeyboardEvent",
339
- code: "INVALID_SELECTOR",
340
- message: `Invalid keyboard ignore selector: "${i}". Error: ${o.message}`,
341
- data: o
342
- });
343
- }
328
+ const t = document.activeElement, s = e.target, a = ["input", "textarea", "select"];
329
+ if (s) {
330
+ const o = s.tagName.toLowerCase();
331
+ if (a.includes(o) || s.contentEditable === "true") return !0;
332
+ }
333
+ if (t && t !== s) {
334
+ const o = t.tagName.toLowerCase();
335
+ if (a.includes(o) || t.contentEditable === "true") return !0;
336
+ }
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)
344
+ try {
345
+ const l = c;
346
+ if (l.matches && l.matches(h) || l.closest && l.closest(h))
347
+ return !0;
348
+ } catch (l) {
349
+ console.warn(`Error checking selection container with selector "${h}":`, l);
350
+ }
351
+ }
344
352
  return !1;
345
353
  }
346
354
  /**
347
355
  * Метод для удаления всех слушателей
348
356
  */
349
357
  destroy() {
350
- 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);
351
359
  }
352
360
  /**
353
361
  * Дебаунс для снижения частоты вызова функции.
@@ -357,9 +365,9 @@ class Z {
357
365
  */
358
366
  static debounce(e, t) {
359
367
  let s = null;
360
- return function(...n) {
368
+ return function(...a) {
361
369
  s !== null && clearTimeout(s), s = setTimeout(() => {
362
- e.apply(this, n);
370
+ e.apply(this, a);
363
371
  }, t);
364
372
  };
365
373
  }
@@ -382,7 +390,7 @@ class xe {
382
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}"`));
383
391
  }
384
392
  }
385
- function Be(r) {
393
+ function Re(r) {
386
394
  return new Worker(
387
395
  "" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
388
396
  {
@@ -390,13 +398,13 @@ function Be(r) {
390
398
  }
391
399
  );
392
400
  }
393
- class _e {
401
+ class Ue {
394
402
  /**
395
403
  * @param scriptUrl — URL скрипта воркера.
396
404
  * По-умолчанию использует DefaultWorker из соседнего файла
397
405
  */
398
406
  constructor(e) {
399
- 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);
400
408
  }
401
409
  /**
402
410
  * Обработчик сообщений от воркера
@@ -409,12 +417,12 @@ class _e {
409
417
  * @returns
410
418
  */
411
419
  _handleMessage({ data: e }) {
412
- const { requestId: t, success: s, data: n, error: a } = e, i = this._callbacks.get(t);
413
- if (!i) {
420
+ const { requestId: t, success: s, data: a, error: n } = e, o = this._callbacks.get(t);
421
+ if (!o) {
414
422
  console.warn(`No callback found for requestId: ${t}`);
415
423
  return;
416
424
  }
417
- s ? i.resolve(n) : i.reject(new Error(a)), this._callbacks.delete(t);
425
+ s ? o.resolve(a) : o.reject(new Error(n)), this._callbacks.delete(t);
418
426
  }
419
427
  /**
420
428
  * Универсальный метод отправки команды в воркер
@@ -424,9 +432,9 @@ class _e {
424
432
  * @returns Promise, который будет выполнен, когда воркер вернет ответ
425
433
  */
426
434
  post(e, t, s = []) {
427
- const n = `${e}:${D(8)}`;
428
- return new Promise((a, i) => {
429
- this._callbacks.set(n, { resolve: a, reject: i }), 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);
430
438
  });
431
439
  }
432
440
  /**
@@ -436,50 +444,50 @@ class _e {
436
444
  this.worker.terminate();
437
445
  }
438
446
  }
439
- const N = 12, Re = 2, K = 8, q = 20, Ue = 100, ee = 20, te = 8, ze = 100, V = 32, se = 1, Ze = "#2B2D33", ne = "#3D8BF4", ae = "#FFFFFF";
440
- function W(r, e, t, s, n) {
441
- const a = N, i = Re;
442
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ae, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-a / 2, -a / 2, a, a, i), 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();
443
451
  }
444
- function ue(r, e, t, s, n) {
445
- const a = K, i = q, o = Ue;
446
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ae, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-a / 2, -i / 2, a, i, 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();
447
455
  }
448
- function Me(r, e, t, s, n) {
449
- const a = ee, i = te, o = ze;
450
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ae, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-a / 2, -i / 2, a, i, 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();
451
459
  }
452
- const He = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", je = new Image();
453
- je.src = He;
454
- function Ye(r, e, t, s, n) {
455
- const i = V / 2;
456
- r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = Ze, r.beginPath(), r.arc(0, 0, i, 0, 2 * Math.PI), r.fill(), r.drawImage(je, -i / 2, -i / 2, i, i), 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();
457
465
  }
458
- const Pe = {
466
+ const Fe = {
459
467
  // Угловые точки
460
468
  tl: {
461
- render: W,
469
+ render: F,
462
470
  sizeX: N,
463
471
  sizeY: N,
464
472
  offsetX: 0,
465
473
  offsetY: 0
466
474
  },
467
475
  tr: {
468
- render: W,
476
+ render: F,
469
477
  sizeX: N,
470
478
  sizeY: N,
471
479
  offsetX: 0,
472
480
  offsetY: 0
473
481
  },
474
482
  bl: {
475
- render: W,
483
+ render: F,
476
484
  sizeX: N,
477
485
  sizeY: N,
478
486
  offsetX: 0,
479
487
  offsetY: 0
480
488
  },
481
489
  br: {
482
- render: W,
490
+ render: F,
483
491
  sizeX: N,
484
492
  sizeY: N,
485
493
  offsetX: 0,
@@ -487,61 +495,61 @@ const Pe = {
487
495
  },
488
496
  // Середина вертикалей
489
497
  ml: {
490
- render: ue,
491
- sizeX: K,
492
- sizeY: q,
498
+ render: Me,
499
+ sizeX: q,
500
+ sizeY: ee,
493
501
  offsetX: 0,
494
502
  offsetY: 0
495
503
  },
496
504
  mr: {
497
- render: ue,
498
- sizeX: K,
499
- sizeY: q,
505
+ render: Me,
506
+ sizeX: q,
507
+ sizeY: ee,
500
508
  offsetX: 0,
501
509
  offsetY: 0
502
510
  },
503
511
  // Середина горизонталей
504
512
  mt: {
505
- render: Me,
506
- sizeX: ee,
507
- sizeY: te,
513
+ render: fe,
514
+ sizeX: te,
515
+ sizeY: se,
508
516
  offsetX: 0,
509
517
  offsetY: 0
510
518
  },
511
519
  mb: {
512
- render: Me,
513
- sizeX: ee,
514
- sizeY: te,
520
+ render: fe,
521
+ sizeX: te,
522
+ sizeY: se,
515
523
  offsetX: 0,
516
524
  offsetY: 0
517
525
  },
518
526
  // Специальный «rotate» контрол
519
527
  mtr: {
520
- render: Ye,
521
- sizeX: V,
522
- sizeY: V,
528
+ render: We,
529
+ sizeX: G,
530
+ sizeY: G,
523
531
  offsetX: 0,
524
- offsetY: -V
532
+ offsetY: -G
525
533
  }
526
534
  };
527
- class We {
535
+ class Ve {
528
536
  static apply() {
529
- const e = Ae.createObjectDefaultControls();
530
- Object.entries(Pe).forEach(([t, s]) => {
537
+ const e = Ce.createObjectDefaultControls();
538
+ Object.entries(Fe).forEach(([t, s]) => {
531
539
  Object.assign(e[t], {
532
540
  render: s.render,
533
541
  sizeX: s.sizeX,
534
542
  sizeY: s.sizeY,
535
543
  offsetX: s.offsetX,
536
544
  offsetY: s.offsetY
537
- }), t === "mtr" && (e[t].cursorStyle = "grab", e[t].mouseDownHandler = (a, i, o, d) => {
545
+ }), t === "mtr" && (e[t].cursorStyle = "grab", e[t].mouseDownHandler = (n, o, i, c) => {
538
546
  var h;
539
- (h = i.target.canvas) == null || h.setCursor("grabbing");
547
+ (h = o.target.canvas) == null || h.setCursor("grabbing");
540
548
  });
541
549
  }), Se.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image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", z = {
545
553
  style: {
546
554
  position: "absolute",
547
555
  display: "none",
@@ -608,17 +616,17 @@ const Fe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
608
616
  ],
609
617
  offsetTop: 50,
610
618
  icons: {
611
- copyPaste: Fe,
612
- delete: Ke,
613
- lock: Ve,
614
- unlock: Ge,
615
- bringToFront: $e,
616
- sendToBack: Je,
617
- bringForward: Xe,
618
- 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
619
627
  },
620
628
  handlers: {
621
- copyPaste: (r) => j(null, null, function* () {
629
+ copyPaste: (r) => b(null, null, function* () {
622
630
  r.clipboardManager.copyPaste();
623
631
  }),
624
632
  delete: (r) => {
@@ -644,14 +652,14 @@ const Fe = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
644
652
  }
645
653
  }
646
654
  };
647
- class qe {
655
+ class tt {
648
656
  constructor({ editor: e }) {
649
657
  this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._initToolbar();
650
658
  }
651
659
  _initToolbar() {
652
660
  if (!this.options.showToolbar) return;
653
661
  const e = this.options.toolbar || {};
654
- this.config = ge(p(p({}, z), e), {
662
+ this.config = ue(p(p({}, z), e), {
655
663
  style: p(p({}, z.style), e.style || {}),
656
664
  btnStyle: p(p({}, z.btnStyle), e.btnStyle || {}),
657
665
  icons: p(p({}, z.icons), e.icons || {}),
@@ -666,11 +674,11 @@ class qe {
666
674
  _createDOM() {
667
675
  const { style: e } = this.config;
668
676
  this.el = document.createElement("div"), Object.assign(this.el.style, e), this.canvas.wrapperEl.appendChild(this.el), this._onBtnOver = (t) => {
669
- const n = t.target.closest("button");
670
- n && Object.assign(n.style, this.config.btnHover);
677
+ const a = t.target.closest("button");
678
+ a && Object.assign(a.style, this.config.btnHover);
671
679
  }, this._onBtnOut = (t) => {
672
- const n = t.target.closest("button");
673
- n && Object.assign(n.style, this.config.btnStyle);
680
+ const a = t.target.closest("button");
681
+ a && Object.assign(a.style, this.config.btnStyle);
674
682
  }, this.el.addEventListener("mouseover", this._onBtnOver), this.el.addEventListener("mouseout", this._onBtnOut);
675
683
  }
676
684
  /**
@@ -682,13 +690,13 @@ class qe {
682
690
  _renderButtons(e) {
683
691
  this.el.innerHTML = "";
684
692
  for (const t of e) {
685
- const { name: s, handle: n } = t, { icons: a = {}, btnStyle: i, handlers: o = {} } = this.config, d = document.createElement("button");
686
- d.innerHTML = a[n] ? `<img src="${a[n]}" title="${s}" />` : s, Object.assign(d.style, i), d.onclick = () => {
687
- var c;
688
- return (c = o[n]) == null ? void 0 : c.call(o, this.editor);
689
- }, d.onmousedown = (c) => {
690
- c.stopPropagation(), c.preventDefault();
691
- }, 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);
692
700
  }
693
701
  }
694
702
  /**
@@ -744,12 +752,12 @@ class qe {
744
752
  this.el.style.display = "none";
745
753
  return;
746
754
  }
747
- const { el: t, config: s, canvas: n } = this;
755
+ const { el: t, config: s, canvas: a } = this;
748
756
  e.setCoords();
749
- const a = n.getZoom(), [, , , , i, o] = n.viewportTransform, { x: d } = e.getCenterPoint(), { top: c, height: h } = e.getBoundingRect(), g = d * a + i - t.offsetWidth / 2, M = s.offsetTop || 0, f = (c + h) * a + 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;
750
758
  Object.assign(t.style, {
751
759
  left: `${g}px`,
752
- top: `${f}px`,
760
+ top: `${m}px`,
753
761
  display: "flex"
754
762
  });
755
763
  }
@@ -760,7 +768,7 @@ class qe {
760
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();
761
769
  }
762
770
  }
763
- class et {
771
+ class st {
764
772
  constructor({ editor: e }) {
765
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();
766
774
  }
@@ -772,11 +780,12 @@ class et {
772
780
  return this.patches[this.currentIndex - 1] || null;
773
781
  }
774
782
  _createDiffPatcher() {
775
- this.diffPatcher = Oe({
783
+ this.diffPatcher = ke({
776
784
  objectHash(e) {
777
785
  const t = e;
778
786
  return [
779
787
  t.id,
788
+ t.backgroundId,
780
789
  t.format,
781
790
  t.locked,
782
791
  t.left,
@@ -796,7 +805,7 @@ class et {
796
805
  includeValueOnMove: !1
797
806
  },
798
807
  textDiff: {
799
- diffMatchPatch: Te,
808
+ diffMatchPatch: Be,
800
809
  minLength: 60
801
810
  }
802
811
  });
@@ -826,10 +835,10 @@ class et {
826
835
  */
827
836
  getFullState() {
828
837
  const { baseState: e, currentIndex: t, patches: s } = this;
829
- let n = JSON.parse(JSON.stringify(e));
830
- for (let a = 0; a < t; a += 1)
831
- n = this.diffPatcher.patch(n, s[a].diff);
832
- 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;
833
842
  }
834
843
  /**
835
844
  * Сохраняем текущее состояние в виде диффа от последнего сохранённого полного состояния.
@@ -841,6 +850,8 @@ class et {
841
850
  "selectable",
842
851
  "evented",
843
852
  "id",
853
+ "backgroundId",
854
+ "backgroundType",
844
855
  "format",
845
856
  "width",
846
857
  "height",
@@ -862,7 +873,7 @@ class et {
862
873
  console.log("Нет изменений для сохранения.");
863
874
  return;
864
875
  }
865
- 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);
866
877
  }
867
878
  /**
868
879
  * Функция загрузки состояния в канвас.
@@ -870,15 +881,17 @@ class et {
870
881
  * @fires editor:history-state-loaded
871
882
  */
872
883
  loadStateFromFullState(e) {
873
- return j(this, null, function* () {
884
+ return b(this, null, function* () {
874
885
  if (!e) return;
875
886
  console.log("loadStateFromFullState fullState", e);
876
- const { canvas: t, canvasManager: s, interactionBlocker: n } = this.editor, { width: a, height: i } = t;
887
+ const { canvas: t, canvasManager: s, interactionBlocker: a, backgroundManager: n } = this.editor, { width: o, height: i } = t;
877
888
  yield t.loadFromJSON(e);
878
- const o = t.getObjects().find((c) => c.id === "montage-area");
879
- o && (this.editor.montageArea = o, (a !== t.getWidth() || i !== t.getHeight()) && s.updateCanvas());
880
- const d = t.getObjects().find((c) => c.id === "overlay-mask");
881
- 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", {
882
895
  fullState: e,
883
896
  currentIndex: this.currentIndex,
884
897
  totalChangesCount: this.totalChangesCount,
@@ -893,7 +906,7 @@ class et {
893
906
  * @fires editor:undo
894
907
  */
895
908
  undo() {
896
- return j(this, null, function* () {
909
+ return b(this, null, function* () {
897
910
  if (!this.skipHistory) {
898
911
  if (this.currentIndex <= 0) {
899
912
  console.log("Нет предыдущих состояний для отмены.");
@@ -930,7 +943,7 @@ class et {
930
943
  * @fires editor:redo
931
944
  */
932
945
  redo() {
933
- return j(this, null, function* () {
946
+ return b(this, null, function* () {
934
947
  if (!this.skipHistory) {
935
948
  if (this.currentIndex >= this.patches.length) {
936
949
  console.log("Нет состояний для повтора.");
@@ -963,8 +976,8 @@ class et {
963
976
  });
964
977
  }
965
978
  }
966
- const tt = 0.1, st = 2, nt = 0.1, at = 90, _ = 16, R = 16, O = 4096, T = 4096, me = "application/image-editor:";
967
- class E {
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 {
968
981
  constructor({ editor: e }) {
969
982
  this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
970
983
  }
@@ -981,83 +994,83 @@ class E {
981
994
  * @returns возвращает Promise с объектом изображения или null в случае ошибки
982
995
  */
983
996
  importImage(e) {
984
- return j(this, null, function* () {
997
+ return b(this, null, function* () {
985
998
  const {
986
999
  source: t,
987
1000
  scale: s = `image-${this.options.scaleType}`,
988
- withoutSave: n = !1,
989
- fromClipboard: a = !1
1001
+ withoutSave: a = !1,
1002
+ fromClipboard: n = !1
990
1003
  } = e;
991
1004
  if (!t) return null;
992
- const { canvas: i, montageArea: o, transformManager: d, historyManager: c, errorManager: h } = this.editor, l = yield this.getContentType(t), g = E.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;
993
1006
  if (!this.isAllowedContentType(l)) {
994
- const m = `Неверный contentType для изображения: ${l}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
1007
+ const f = `Неверный contentType для изображения: ${l}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
995
1008
  return h.emitError({
996
1009
  origin: "ImageManager",
997
1010
  method: "importImage",
998
1011
  code: "INVALID_CONTENT_TYPE",
999
- message: m,
1000
- data: { source: t, format: g, contentType: l, acceptContentTypes: M, acceptFormats: f, fromClipboard: a }
1012
+ message: f,
1013
+ data: { source: t, format: g, contentType: l, acceptContentTypes: M, acceptFormats: m, fromClipboard: n }
1001
1014
  }), null;
1002
1015
  }
1003
- c.suspendHistory();
1016
+ d.suspendHistory();
1004
1017
  try {
1005
- let m, u;
1018
+ let f, u;
1006
1019
  if (t instanceof File)
1007
- m = URL.createObjectURL(t);
1020
+ f = URL.createObjectURL(t);
1008
1021
  else if (typeof t == "string") {
1009
- const C = yield (yield fetch(t, { mode: "cors" })).blob();
1010
- m = URL.createObjectURL(C);
1022
+ const E = yield (yield fetch(t, { mode: "cors" })).blob();
1023
+ f = URL.createObjectURL(E);
1011
1024
  } else
1012
1025
  return h.emitError({
1013
1026
  origin: "ImageManager",
1014
1027
  method: "importImage",
1015
1028
  code: "INVALID_SOURCE_TYPE",
1016
1029
  message: "Неверный тип источника изображения. Ожидается URL или объект File.",
1017
- data: { source: t, format: g, contentType: l, acceptContentTypes: M, acceptFormats: f, fromClipboard: a }
1030
+ data: { source: t, format: g, contentType: l, acceptContentTypes: M, acceptFormats: m, fromClipboard: n }
1018
1031
  }), null;
1019
- if (this._createdBlobUrls.push(m), g === "svg") {
1020
- const v = yield Ce(m);
1021
- 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);
1022
1035
  } else
1023
- u = yield U.fromURL(m, { crossOrigin: "anonymous" });
1024
- const { width: b, height: A } = u;
1025
- if (u instanceof U) {
1026
- const v = u.getElement();
1027
- let C = "";
1028
- if (v instanceof HTMLImageElement ? C = v.src : v instanceof HTMLCanvasElement && (C = v.toDataURL()), A > T || b > O) {
1029
- const w = yield this.resizeImageToBoundaries(C, "max"), k = URL.createObjectURL(w);
1030
- this._createdBlobUrls.push(k), u = yield U.fromURL(k, { crossOrigin: "anonymous" });
1031
- } else if (A < R || b < _) {
1032
- const w = yield this.resizeImageToBoundaries(C, "min"), k = URL.createObjectURL(w);
1033
- 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" });
1034
1047
  }
1035
1048
  }
1036
- 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")
1037
1050
  this.editor.canvasManager.scaleMontageAreaToImage({ object: u, withoutSave: !0 });
1038
1051
  else {
1039
- const { width: v, height: C } = o, w = this.calculateScaleFactor({ imageObject: u, scaleType: s });
1040
- 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 });
1041
1054
  }
1042
- i.add(u), i.centerObject(u), i.setActiveObject(u), i.renderAll(), c.resumeHistory(), n || c.saveState();
1055
+ o.add(u), o.centerObject(u), o.setActiveObject(u), o.renderAll(), d.resumeHistory(), a || d.saveState();
1043
1056
  const S = {
1044
1057
  image: u,
1045
1058
  format: g,
1046
1059
  contentType: l,
1047
1060
  scale: s,
1048
- withoutSave: n,
1061
+ withoutSave: a,
1049
1062
  source: t,
1050
- fromClipboard: a
1063
+ fromClipboard: n
1051
1064
  };
1052
- return i.fire("editor:image-imported", S), S;
1053
- } catch (m) {
1065
+ return o.fire("editor:image-imported", S), S;
1066
+ } catch (f) {
1054
1067
  return h.emitError({
1055
1068
  origin: "ImageManager",
1056
1069
  method: "importImage",
1057
1070
  code: "IMPORT_FAILED",
1058
- message: `Ошибка импорта изображения: ${m.message}`,
1059
- data: { source: t, format: g, contentType: l, scale: s, withoutSave: n, fromClipboard: a }
1060
- }), 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;
1061
1074
  }
1062
1075
  });
1063
1076
  }
@@ -1070,24 +1083,24 @@ class E {
1070
1083
  * @returns возвращает Promise с Blob-объектом уменьшенного изображения
1071
1084
  */
1072
1085
  resizeImageToBoundaries(e, t = "max") {
1073
- return j(this, null, function* () {
1074
- let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${O}x${T}`;
1075
- t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${_}x${R}`);
1076
- 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 = {
1077
1090
  dataURL: e,
1078
1091
  sizeType: t,
1079
- maxWidth: O,
1080
- maxHeight: T,
1081
- minWidth: _,
1082
- minHeight: R
1092
+ maxWidth: T,
1093
+ maxHeight: w,
1094
+ minWidth: U,
1095
+ minHeight: H
1083
1096
  };
1084
1097
  return this.editor.errorManager.emitWarning({
1085
1098
  origin: "ImageManager",
1086
1099
  method: "resizeImageToBoundaries",
1087
1100
  code: "IMAGE_RESIZE_WARNING",
1088
1101
  message: s,
1089
- data: n
1090
- }), this.editor.workerManager.post("resizeImage", n);
1102
+ data: a
1103
+ }), this.editor.workerManager.post("resizeImage", a);
1091
1104
  });
1092
1105
  }
1093
1106
  /**
@@ -1102,101 +1115,101 @@ class E {
1102
1115
  * @fires editor:canvas-exported
1103
1116
  */
1104
1117
  exportCanvasAsImageFile() {
1105
- return j(this, arguments, function* (e = {}) {
1118
+ return b(this, arguments, function* (e = {}) {
1106
1119
  const {
1107
1120
  fileName: t = "image.png",
1108
1121
  contentType: s = "image/png",
1109
- exportAsBase64: n = !1,
1110
- exportAsBlob: a = !1
1111
- } = e, { canvas: i, montageArea: o, workerManager: d } = this.editor;
1122
+ exportAsBase64: a = !1,
1123
+ exportAsBlob: n = !1
1124
+ } = e, { canvas: o, montageArea: i, workerManager: c } = this.editor;
1112
1125
  try {
1113
- const c = s === "application/pdf", h = c ? "image/jpg" : s, l = E.getFormatFromContentType(h);
1114
- o.setCoords();
1115
- const { left: g, top: M, width: f, height: m } = o.getBoundingRect(), u = yield i.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"]);
1116
1129
  u.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(h) && (u.backgroundColor = "#ffffff");
1117
- const b = u.getObjects().find((I) => I.id === o.id);
1118
- b && (b.visible = !1), u.viewportTransform = [1, 0, 0, 1, -g, -M], u.setDimensions({ width: f, height: m }, { backstoreOnly: !0 }), u.renderAll();
1119
- const A = u.getObjects().filter((I) => I.format).every((I) => I.format === "svg");
1120
- 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) {
1121
1134
  const I = u.toSVG();
1122
1135
  u.dispose();
1123
- const L = {
1124
- image: E._exportSVGStringAsFile(I, {
1125
- exportAsBase64: n,
1126
- exportAsBlob: a,
1136
+ const D = {
1137
+ image: O._exportSVGStringAsFile(I, {
1138
+ exportAsBase64: a,
1139
+ exportAsBlob: n,
1127
1140
  fileName: t
1128
1141
  }),
1129
1142
  format: "svg",
1130
1143
  contentType: "image/svg+xml",
1131
1144
  fileName: t.replace(/\.[^/.]+$/, ".svg")
1132
1145
  };
1133
- return i.fire("editor:canvas-exported", L), L;
1146
+ return o.fire("editor:canvas-exported", D), D;
1134
1147
  }
1135
- const S = yield new Promise((I, x) => {
1136
- u.getElement().toBlob((L) => {
1137
- L ? I(L) : 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"));
1138
1151
  });
1139
1152
  });
1140
- if (u.dispose(), a) {
1153
+ if (u.dispose(), n) {
1141
1154
  const I = {
1142
1155
  image: S,
1143
1156
  format: l,
1144
1157
  contentType: h,
1145
1158
  fileName: t
1146
1159
  };
1147
- return i.fire("editor:canvas-exported", I), I;
1160
+ return o.fire("editor:canvas-exported", I), I;
1148
1161
  }
1149
- const v = yield createImageBitmap(S), C = yield d.post(
1162
+ const A = yield createImageBitmap(S), E = yield c.post(
1150
1163
  "toDataURL",
1151
- { format: l, quality: 1, bitmap: v },
1152
- [v]
1164
+ { format: l, quality: 1, bitmap: A },
1165
+ [A]
1153
1166
  );
1154
- if (c) {
1155
- const x = f * 0.264583, L = m * 0.264583, be = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, $ = new be({
1156
- orientation: x > L ? "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",
1157
1170
  unit: "mm",
1158
- format: [x, L]
1171
+ format: [B, D]
1159
1172
  });
1160
- if ($.addImage(String(C), "JPG", 0, 0, x, L), n) {
1161
- const ce = {
1173
+ if ($.addImage(String(E), "JPG", 0, 0, B, D), a) {
1174
+ const de = {
1162
1175
  image: $.output("datauristring"),
1163
1176
  format: "pdf",
1164
1177
  contentType: "application/pdf",
1165
1178
  fileName: t
1166
1179
  };
1167
- return i.fire("editor:canvas-exported", ce), ce;
1180
+ return o.fire("editor:canvas-exported", de), de;
1168
1181
  }
1169
- const pe = $.output("blob"), re = {
1170
- image: new File([pe], t, { type: "application/pdf" }),
1182
+ const ye = $.output("blob"), ce = {
1183
+ image: new File([ye], t, { type: "application/pdf" }),
1171
1184
  format: "pdf",
1172
1185
  contentType: "application/pdf",
1173
1186
  fileName: t
1174
1187
  };
1175
- return i.fire("editor:canvas-exported", re), re;
1188
+ return o.fire("editor:canvas-exported", ce), ce;
1176
1189
  }
1177
- if (n) {
1190
+ if (a) {
1178
1191
  const I = {
1179
- image: C,
1192
+ image: E,
1180
1193
  format: l,
1181
1194
  contentType: h,
1182
1195
  fileName: t
1183
1196
  };
1184
- return i.fire("editor:canvas-exported", I), I;
1197
+ return o.fire("editor:canvas-exported", I), I;
1185
1198
  }
1186
- const w = l === "svg" && !A ? t.replace(/\.[^/.]+$/, ".png") : t, oe = {
1187
- 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 }),
1188
1201
  format: l,
1189
1202
  contentType: h,
1190
- fileName: w
1203
+ fileName: L
1191
1204
  };
1192
- return i.fire("editor:canvas-exported", oe), oe;
1193
- } catch (c) {
1205
+ return o.fire("editor:canvas-exported", re), re;
1206
+ } catch (d) {
1194
1207
  return this.editor.errorManager.emitError({
1195
1208
  origin: "ImageManager",
1196
1209
  method: "exportCanvasAsImageFile",
1197
1210
  code: "IMAGE_EXPORT_FAILED",
1198
- message: `Ошибка экспорта изображения: ${c.message}`,
1199
- data: { contentType: s, fileName: t, exportAsBase64: n, exportAsBlob: a }
1211
+ message: `Ошибка экспорта изображения: ${d.message}`,
1212
+ data: { contentType: s, fileName: t, exportAsBase64: a, exportAsBlob: n }
1200
1213
  }), null;
1201
1214
  }
1202
1215
  });
@@ -1213,88 +1226,88 @@ class E {
1213
1226
  * @fires editor:object-exported
1214
1227
  */
1215
1228
  exportObjectAsImageFile() {
1216
- return j(this, arguments, function* (e = {}) {
1229
+ return b(this, arguments, function* (e = {}) {
1217
1230
  const {
1218
1231
  object: t,
1219
1232
  fileName: s = "image.png",
1220
- contentType: n = "image/png",
1221
- exportAsBase64: a = !1,
1222
- exportAsBlob: i = !1
1223
- } = e, { canvas: o, workerManager: d } = this.editor, c = t || o.getActiveObject();
1224
- 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)
1225
1238
  return this.editor.errorManager.emitError({
1226
1239
  origin: "ImageManager",
1227
1240
  method: "exportObjectAsImageFile",
1228
1241
  code: "NO_OBJECT_SELECTED",
1229
1242
  message: "Не выбран объект для экспорта",
1230
- data: { contentType: n, fileName: s, exportAsBase64: a, exportAsBlob: i }
1243
+ data: { contentType: a, fileName: s, exportAsBase64: n, exportAsBlob: o }
1231
1244
  }), null;
1232
1245
  try {
1233
- const h = E.getFormatFromContentType(n);
1246
+ const h = O.getFormatFromContentType(a);
1234
1247
  if (h === "svg") {
1235
- const m = c.toSVG(), u = E._exportSVGStringAsFile(m, {
1236
- exportAsBase64: a,
1237
- exportAsBlob: i,
1248
+ const f = d.toSVG(), u = O._exportSVGStringAsFile(f, {
1249
+ exportAsBase64: n,
1250
+ exportAsBlob: o,
1238
1251
  fileName: s
1239
- }), b = {
1240
- object: c,
1252
+ }), j = {
1253
+ object: d,
1241
1254
  image: u,
1242
1255
  format: h,
1243
1256
  contentType: "image/svg+xml",
1244
1257
  fileName: s.replace(/\.[^/.]+$/, ".svg")
1245
1258
  };
1246
- return o.fire("editor:object-exported", b), b;
1259
+ return i.fire("editor:object-exported", j), j;
1247
1260
  }
1248
- if (a && c instanceof U) {
1249
- 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(
1250
1263
  "toDataURL",
1251
1264
  {
1252
1265
  format: h,
1253
1266
  quality: 1,
1254
- bitmap: m
1267
+ bitmap: f
1255
1268
  },
1256
- [m]
1257
- ), b = {
1258
- object: c,
1269
+ [f]
1270
+ ), j = {
1271
+ object: d,
1259
1272
  image: u,
1260
1273
  format: h,
1261
- contentType: n,
1274
+ contentType: a,
1262
1275
  fileName: s
1263
1276
  };
1264
- return o.fire("editor:object-exported", b), b;
1277
+ return i.fire("editor:object-exported", j), j;
1265
1278
  }
1266
- const l = c.toCanvasElement({
1279
+ const l = d.toCanvasElement({
1267
1280
  enableRetinaScaling: !1
1268
- }), g = yield new Promise((m, u) => {
1269
- l.toBlob((b) => {
1270
- 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"));
1271
1284
  });
1272
1285
  });
1273
- if (i) {
1274
- const m = {
1275
- object: c,
1286
+ if (o) {
1287
+ const f = {
1288
+ object: d,
1276
1289
  image: g,
1277
1290
  format: h,
1278
- contentType: n,
1291
+ contentType: a,
1279
1292
  fileName: s
1280
1293
  };
1281
- return o.fire("editor:object-exported", m), m;
1294
+ return i.fire("editor:object-exported", f), f;
1282
1295
  }
1283
- const M = new File([g], s, { type: n }), f = {
1284
- object: c,
1296
+ const M = new File([g], s, { type: a }), m = {
1297
+ object: d,
1285
1298
  image: M,
1286
1299
  format: h,
1287
- contentType: n,
1300
+ contentType: a,
1288
1301
  fileName: s
1289
1302
  };
1290
- return o.fire("editor:object-exported", f), f;
1303
+ return i.fire("editor:object-exported", m), m;
1291
1304
  } catch (h) {
1292
1305
  return this.editor.errorManager.emitError({
1293
1306
  origin: "ImageManager",
1294
1307
  method: "exportObjectAsImageFile",
1295
1308
  code: "IMAGE_EXPORT_FAILED",
1296
1309
  message: `Ошибка экспорта объекта: ${h.message}`,
1297
- data: { contentType: n, fileName: s, exportAsBase64: a, exportAsBlob: i }
1310
+ data: { contentType: a, fileName: s, exportAsBase64: n, exportAsBlob: o }
1298
1311
  }), null;
1299
1312
  }
1300
1313
  });
@@ -1310,7 +1323,7 @@ class E {
1310
1323
  * @returns массив допустимых форматов изображений
1311
1324
  */
1312
1325
  getAllowedFormatsFromContentTypes() {
1313
- return this.acceptContentTypes.map((e) => E.getFormatFromContentType(e)).filter((e) => e);
1326
+ return this.acceptContentTypes.map((e) => O.getFormatFromContentType(e)).filter((e) => e);
1314
1327
  }
1315
1328
  /**
1316
1329
  * Проверяет, является ли contentType допустимым типом изображения.
@@ -1326,7 +1339,7 @@ class E {
1326
1339
  * @public
1327
1340
  */
1328
1341
  getContentType(e) {
1329
- return j(this, null, function* () {
1342
+ return b(this, null, function* () {
1330
1343
  return typeof e == "string" ? this.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
1331
1344
  });
1332
1345
  }
@@ -1337,7 +1350,7 @@ class E {
1337
1350
  * @public
1338
1351
  */
1339
1352
  getContentTypeFromUrl(e) {
1340
- return j(this, null, function* () {
1353
+ return b(this, null, function* () {
1341
1354
  if (e.startsWith("data:")) {
1342
1355
  const t = e.match(/^data:([^;]+)/);
1343
1356
  return t ? t[1] : "application/octet-stream";
@@ -1361,11 +1374,11 @@ class E {
1361
1374
  getContentTypeFromExtension(e) {
1362
1375
  var t;
1363
1376
  try {
1364
- const n = (t = new URL(e).pathname.split(".").pop()) == null ? void 0 : t.toLowerCase(), a = {};
1365
- return this.acceptContentTypes.forEach((i) => {
1366
- const o = E.getFormatFromContentType(i);
1367
- o && (a[o] = i);
1368
- }), n && a[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";
1369
1382
  } catch (s) {
1370
1383
  return console.warn("Не удалось определить расширение из URL:", e, s), "application/octet-stream";
1371
1384
  }
@@ -1383,8 +1396,8 @@ class E {
1383
1396
  }) {
1384
1397
  const { montageArea: s } = this.editor;
1385
1398
  if (!s || !e) return 1;
1386
- const n = s.width, a = s.height, { width: i, height: o } = e;
1387
- return t === "contain" || t === "image-contain" ? Math.min(n / i, a / o) : t === "cover" || t === "image-cover" ? Math.max(n / i, a / 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;
1388
1401
  }
1389
1402
  /**
1390
1403
  * Преобразует SVG-строку в Blob, файл, или base64
@@ -1400,9 +1413,9 @@ class E {
1400
1413
  static _exportSVGStringAsFile(e, {
1401
1414
  exportAsBase64: t,
1402
1415
  exportAsBlob: s,
1403
- fileName: n = "image.svg"
1416
+ fileName: a = "image.svg"
1404
1417
  } = {}) {
1405
- 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" });
1406
1419
  }
1407
1420
  /**
1408
1421
  * Извлекает чистый формат (subtype) из contentType,
@@ -1416,11 +1429,11 @@ class E {
1416
1429
  return t ? t[1] : "";
1417
1430
  }
1418
1431
  }
1419
- const B = (r, e, t) => Math.max(Math.min(r, t), e), fe = (r, e) => r * e, it = (r, e) => new F(r / 2, e / 2);
1420
- 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) {
1421
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";
1422
1435
  }
1423
- class rt {
1436
+ class dt {
1424
1437
  /**
1425
1438
  * @param options
1426
1439
  * @param options.editor – экземпляр редактора
@@ -1444,25 +1457,25 @@ class rt {
1444
1457
  * @param options.adaptCanvasToContainer - Адаптировать канвас к контейнеру
1445
1458
  * @fires editor:resolution-width-changed
1446
1459
  */
1447
- setResolutionWidth(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: n } = {}) {
1448
- var f;
1460
+ setResolutionWidth(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: a } = {}) {
1461
+ var m;
1449
1462
  if (!e) return;
1450
1463
  const {
1451
- canvas: a,
1452
- montageArea: i,
1453
- options: { canvasBackstoreWidth: o }
1454
- } = this.editor, { width: d, height: c } = i, h = B(Number(e), _, O);
1455
- if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreWidth(Number(o)) : this.setCanvasBackstoreWidth(h), i.set({ width: h }), (f = a.clipPath) == null || f.set({ width: h }), t) {
1456
- 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);
1457
1470
  this.setResolutionHeight(u);
1458
1471
  return;
1459
1472
  }
1460
- const { left: l, top: g } = this.getObjectDefaultCoords(i), M = a.getZoom();
1461
- a.setViewportTransform([M, 0, 0, M, l, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), a.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", {
1462
1475
  width: h,
1463
1476
  preserveProportional: t,
1464
1477
  withoutSave: s,
1465
- adaptCanvasToContainer: n
1478
+ adaptCanvasToContainer: a
1466
1479
  });
1467
1480
  }
1468
1481
  /**
@@ -1474,25 +1487,25 @@ class rt {
1474
1487
  * @param options.adaptCanvasToContainer - Адаптировать канвас к контейнеру
1475
1488
  * @fires editor:resolution-height-changed
1476
1489
  */
1477
- setResolutionHeight(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: n } = {}) {
1478
- var f;
1490
+ setResolutionHeight(e, { preserveProportional: t, withoutSave: s, adaptCanvasToContainer: a } = {}) {
1491
+ var m;
1479
1492
  if (!e) return;
1480
1493
  const {
1481
- canvas: a,
1482
- montageArea: i,
1483
- options: { canvasBackstoreHeight: o }
1484
- } = this.editor, { width: d, height: c } = i, h = B(Number(e), R, T);
1485
- if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreHeight(Number(o)) : this.setCanvasBackstoreHeight(h), i.set({ height: h }), (f = a.clipPath) == null || f.set({ height: h }), t) {
1486
- 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);
1487
1500
  this.setResolutionWidth(u);
1488
1501
  return;
1489
1502
  }
1490
- const { left: l, top: g } = this.getObjectDefaultCoords(i), M = a.getZoom();
1491
- a.setViewportTransform([M, 0, 0, M, l, g]), this.centerMontageArea(), s || this.editor.historyManager.saveState(), a.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", {
1492
1505
  height: h,
1493
1506
  preserveProportional: t,
1494
1507
  withoutSave: s,
1495
- adaptCanvasToContainer: n
1508
+ adaptCanvasToContainer: a
1496
1509
  });
1497
1510
  }
1498
1511
  /**
@@ -1500,17 +1513,17 @@ class rt {
1500
1513
  * и устанавливает правильный viewportTransform.
1501
1514
  */
1502
1515
  centerMontageArea() {
1503
- var d;
1504
- const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), n = e.getHeight(), a = e.getZoom(), i = it(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);
1505
1518
  t.set({
1506
1519
  left: s / 2,
1507
- top: n / 2
1508
- }), (d = e.clipPath) == null || d.set({
1520
+ top: a / 2
1521
+ }), (c = e.clipPath) == null || c.set({
1509
1522
  left: s / 2,
1510
- top: n / 2
1523
+ top: a / 2
1511
1524
  }), e.renderAll();
1512
- const o = e.viewportTransform;
1513
- o[4] = s / 2 - i.x * a, o[5] = n / 2 - i.y * a, 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();
1514
1527
  }
1515
1528
  /**
1516
1529
  * Метод для получения координат объекта с учетом текущего зума
@@ -1526,15 +1539,15 @@ class rt {
1526
1539
  code: "NO_ACTIVE_OBJECT",
1527
1540
  message: "Не выбран объект для получения координат"
1528
1541
  }), { left: 0, top: 0 };
1529
- const { width: n, height: a } = s, i = t.getZoom(), o = (n - n * i) / 2, d = (a - a * i) / 2;
1530
- 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 };
1531
1544
  }
1532
1545
  /**
1533
1546
  * Устанавливаем ширину канваса в backstore (для экспорта)
1534
1547
  */
1535
1548
  setCanvasBackstoreWidth(e) {
1536
1549
  if (!e || typeof e != "number") return;
1537
- const t = B(e, _, O);
1550
+ const t = _(e, U, T);
1538
1551
  this.editor.canvas.setDimensions({ width: t }, { backstoreOnly: !0 });
1539
1552
  }
1540
1553
  /**
@@ -1543,7 +1556,7 @@ class rt {
1543
1556
  */
1544
1557
  setCanvasBackstoreHeight(e) {
1545
1558
  if (!e || typeof e != "number") return;
1546
- const t = B(e, R, T);
1559
+ const t = _(e, H, w);
1547
1560
  this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
1548
1561
  }
1549
1562
  /**
@@ -1552,8 +1565,8 @@ class rt {
1552
1565
  * с учётом минимальных и максимальных значений.
1553
1566
  */
1554
1567
  adaptCanvasToContainer() {
1555
- const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, n = t.clientHeight, a = B(s, _, O), i = B(n, R, T);
1556
- e.setDimensions({ width: a, height: i }, { 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 });
1557
1570
  }
1558
1571
  /**
1559
1572
  * Обновляет размеры канваса без изменения позиций объектов.
@@ -1566,21 +1579,21 @@ class rt {
1566
1579
  montageArea: t,
1567
1580
  montageArea: {
1568
1581
  width: s,
1569
- height: n
1582
+ height: a
1570
1583
  }
1571
- } = this.editor, a = t.left, i = t.top;
1572
- this.setResolutionWidth(s, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.setResolutionHeight(n, { adaptCanvasToContainer: !0, withoutSave: !0 }), this.centerMontageArea();
1573
- const o = t.left - a, d = t.top - i;
1574
- if (o !== 0 || d !== 0) {
1575
- const c = e.getActiveObject(), h = [];
1576
- if ((c == null ? void 0 : c.type) === "activeselection") {
1577
- 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;
1578
1591
  h.push(...l.getObjects()), e.discardActiveObject();
1579
1592
  }
1580
1593
  if (e.getObjects().forEach((l) => {
1581
- l.id === "montage-area" || l.id === "overlay-mask" || (l.set({
1582
- left: l.left + o,
1583
- 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
1584
1597
  }), l.setCoords());
1585
1598
  }), h.length > 0)
1586
1599
  if (h.length === 1)
@@ -1594,7 +1607,7 @@ class rt {
1594
1607
  }
1595
1608
  e.renderAll(), e.fire("editor:canvas-updated", {
1596
1609
  width: s,
1597
- height: n
1610
+ height: a
1598
1611
  });
1599
1612
  }
1600
1613
  /**
@@ -1704,32 +1717,32 @@ class rt {
1704
1717
  */
1705
1718
  setDisplayDimension({ element: e = "canvas", dimension: t, value: s } = {}) {
1706
1719
  if (!s) return;
1707
- const { canvas: n } = this.editor, a = [];
1720
+ const { canvas: a } = this.editor, n = [];
1708
1721
  switch (e) {
1709
1722
  case "canvas":
1710
- a.push(n.lowerCanvasEl, n.upperCanvasEl);
1723
+ n.push(a.lowerCanvasEl, a.upperCanvasEl);
1711
1724
  break;
1712
1725
  case "wrapper":
1713
- a.push(n.wrapperEl);
1726
+ n.push(a.wrapperEl);
1714
1727
  break;
1715
1728
  case "container":
1716
- a.push(this.getEditorContainer());
1729
+ n.push(this.getEditorContainer());
1717
1730
  break;
1718
1731
  default:
1719
- a.push(n.lowerCanvasEl, n.upperCanvasEl);
1732
+ n.push(a.lowerCanvasEl, a.upperCanvasEl);
1720
1733
  }
1721
- const i = t === "width" ? "width" : "height";
1734
+ const o = t === "width" ? "width" : "height";
1722
1735
  if (typeof s == "string") {
1723
- a.forEach((d) => {
1724
- d.style[i] = s;
1736
+ n.forEach((c) => {
1737
+ c.style[o] = s;
1725
1738
  });
1726
1739
  return;
1727
1740
  }
1728
1741
  if (isNaN(s)) return;
1729
- const o = `${s}px`;
1730
- a.forEach((d) => {
1731
- d.style[i] = o;
1732
- }), n.fire(`editor:display-${e}-${i}-changed`, {
1742
+ const i = `${s}px`;
1743
+ n.forEach((c) => {
1744
+ c.style[o] = i;
1745
+ }), a.fire(`editor:display-${e}-${o}-changed`, {
1733
1746
  element: e,
1734
1747
  value: s
1735
1748
  });
@@ -1744,26 +1757,26 @@ class rt {
1744
1757
  */
1745
1758
  scaleMontageAreaToImage({ object: e, preserveAspectRatio: t, withoutSave: s } = {}) {
1746
1759
  const {
1747
- canvas: n,
1748
- montageArea: a,
1749
- transformManager: i,
1760
+ canvas: a,
1761
+ montageArea: n,
1762
+ transformManager: o,
1750
1763
  options: {
1751
- montageAreaWidth: o,
1752
- montageAreaHeight: d
1764
+ montageAreaWidth: i,
1765
+ montageAreaHeight: c
1753
1766
  }
1754
- } = this.editor, c = e || n.getActiveObject();
1755
- if (!ot(c)) return;
1756
- const { width: h, height: l } = c;
1757
- let g = Math.min(h, O), M = Math.min(l, T);
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);
1758
1771
  if (t) {
1759
1772
  const {
1760
- width: f,
1761
- height: m
1762
- } = a, u = h / f, b = l / m, A = Math.max(u, b);
1763
- 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;
1764
1777
  }
1765
- this.setResolutionWidth(g, { withoutSave: !0 }), this.setResolutionHeight(M, { withoutSave: !0 }), (h > o || l > d) && i.calculateAndApplyDefaultZoom(), i.resetObject({ object: c, withoutSave: !0 }), n.centerObject(c), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
1766
- 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,
1767
1780
  width: g,
1768
1781
  height: M,
1769
1782
  preserveAspectRatio: t,
@@ -1788,26 +1801,33 @@ class rt {
1788
1801
  const {
1789
1802
  canvas: t,
1790
1803
  transformManager: s,
1791
- historyManager: n,
1804
+ historyManager: a,
1792
1805
  options: {
1793
- montageAreaWidth: a,
1794
- montageAreaHeight: i
1806
+ montageAreaWidth: n,
1807
+ montageAreaHeight: o
1795
1808
  }
1796
1809
  } = this.editor;
1797
- s.resetZoom(), this.setResolutionWidth(a, { withoutSave: !0 }), this.setResolutionHeight(i, { 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");
1798
1811
  }
1799
1812
  /**
1800
1813
  * Получение всех объектов внутри монтажной области редактора
1801
1814
  * @returns массив объектов
1802
1815
  */
1803
1816
  getObjects() {
1804
- const { canvas: e, montageArea: t, interactionBlocker: { overlayMask: s } } = this.editor;
1805
- return e.getObjects().filter((a) => a.id !== t.id && a.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
+ );
1806
1826
  }
1807
1827
  }
1808
- class ct {
1828
+ class lt {
1809
1829
  constructor({ editor: e }) {
1810
- 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;
1811
1831
  }
1812
1832
  /**
1813
1833
  * Метод рассчитывает и применяет зум по умолчанию для монтажной области редактора.
@@ -1817,8 +1837,8 @@ class ct {
1817
1837
  * @param scale - Желаемый масштаб относительно размеров контейнера редактора.
1818
1838
  */
1819
1839
  calculateAndApplyDefaultZoom(e = this.options.defaultScale) {
1820
- const { canvas: t } = this.editor, s = t.editorContainer, n = s.clientWidth, a = s.clientHeight, { width: i, height: o } = this.editor.montageArea, d = n / i * e, c = a / o * e;
1821
- 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();
1822
1842
  }
1823
1843
  /**
1824
1844
  * Увеличение/уменьшение масштаба
@@ -1829,13 +1849,13 @@ class ct {
1829
1849
  * @fires editor:zoom-changed
1830
1850
  * Если передавать координаты курсора, то нужно быть аккуратнее, так как юзер может выйти за пределы рабочей области
1831
1851
  */
1832
- zoom(e = nt, t = {}) {
1852
+ zoom(e = ot, t = {}) {
1833
1853
  var g, M;
1834
1854
  if (!e) return;
1835
- const { minZoom: s, maxZoom: n } = this, { canvas: a } = this.editor, i = a.getZoom(), o = a.getCenterPoint(), d = (g = t.pointX) != null ? g : o.x, c = (M = t.pointY) != null ? M : o.y, h = new F(d, c);
1836
- let l = Number((i + Number(e)).toFixed(2));
1837
- l > n && (l = n), l < s && (l = s), a.zoomToPoint(h, l), a.fire("editor:zoom-changed", {
1838
- currentZoom: a.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(),
1839
1859
  zoom: l,
1840
1860
  point: h
1841
1861
  });
@@ -1846,12 +1866,12 @@ class ct {
1846
1866
  * @fires editor:zoom-changed
1847
1867
  */
1848
1868
  setZoom(e = this.defaultZoom) {
1849
- const { minZoom: t, maxZoom: s } = this, { canvas: n } = this.editor, a = new F(n.getCenterPoint());
1850
- let i = e;
1851
- e > s && (i = s), e < t && (i = t), n.zoomToPoint(a, i), n.fire("editor:zoom-changed", {
1852
- currentZoom: n.getZoom(),
1853
- zoom: i,
1854
- point: a
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
1855
1875
  });
1856
1876
  }
1857
1877
  /**
@@ -1859,7 +1879,7 @@ class ct {
1859
1879
  * @fires editor:zoom-changed
1860
1880
  */
1861
1881
  resetZoom() {
1862
- const { canvas: e } = this.editor, t = new F(e.getCenterPoint());
1882
+ const { canvas: e } = this.editor, t = new V(e.getCenterPoint());
1863
1883
  e.zoomToPoint(t, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
1864
1884
  currentZoom: e.getZoom(),
1865
1885
  point: t
@@ -1872,14 +1892,14 @@ class ct {
1872
1892
  * @param options.withoutSave - Не сохранять состояние
1873
1893
  * @fires editor:object-rotated
1874
1894
  */
1875
- rotate(e = at, { withoutSave: t } = {}) {
1876
- const { canvas: s, historyManager: n } = this.editor, a = s.getActiveObject();
1877
- if (!a) return;
1878
- const i = a.angle + e;
1879
- a.rotate(i), a.setCoords(), s.renderAll(), t || n.saveState(), s.fire("editor:object-rotated", {
1880
- object: a,
1895
+ rotate(e = it, { withoutSave: t } = {}) {
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,
1881
1901
  withoutSave: t,
1882
- angle: i
1902
+ angle: o
1883
1903
  });
1884
1904
  }
1885
1905
  /**
@@ -1889,9 +1909,9 @@ class ct {
1889
1909
  * @fires editor:object-flipped-x
1890
1910
  */
1891
1911
  flipX({ withoutSave: e } = {}) {
1892
- const { canvas: t, historyManager: s } = this.editor, n = t.getActiveObject();
1893
- n && (n.flipX = !n.flipX, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-x", {
1894
- 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,
1895
1915
  withoutSave: e
1896
1916
  }));
1897
1917
  }
@@ -1902,9 +1922,9 @@ class ct {
1902
1922
  * @fires editor:object-flipped-y
1903
1923
  */
1904
1924
  flipY({ withoutSave: e } = {}) {
1905
- const { canvas: t, historyManager: s } = this.editor, n = t.getActiveObject();
1906
- n && (n.flipY = !n.flipY, t.renderAll(), e || s.saveState(), t.fire("editor:object-flipped-y", {
1907
- 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,
1908
1928
  withoutSave: e
1909
1929
  }));
1910
1930
  }
@@ -1921,11 +1941,11 @@ class ct {
1921
1941
  opacity: t = 1,
1922
1942
  withoutSave: s
1923
1943
  } = {}) {
1924
- const { canvas: n, historyManager: a } = this.editor, i = e || n.getActiveObject();
1925
- i && (i instanceof y ? i.getObjects().forEach((o) => {
1926
- o.set("opacity", t);
1927
- }) : i.set("opacity", t), n.renderAll(), s || a.saveState(), n.fire("editor:object-opacity-changed", {
1928
- object: i,
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,
1929
1949
  opacity: t,
1930
1950
  withoutSave: s
1931
1951
  }));
@@ -1945,24 +1965,24 @@ class ct {
1945
1965
  object: e,
1946
1966
  type: t = this.options.scaleType,
1947
1967
  withoutSave: s,
1948
- fitAsOneObject: n
1968
+ fitAsOneObject: a
1949
1969
  } = {}) {
1950
- const { canvas: a, historyManager: i } = this.editor, o = e || a.getActiveObject();
1951
- if (o) {
1952
- if (o instanceof y && !n) {
1953
- const d = o.getObjects();
1954
- a.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) => {
1955
1975
  this._fitSingleObject(h, t);
1956
1976
  });
1957
- const c = new y(d, { canvas: a });
1958
- a.setActiveObject(c);
1977
+ const d = new y(c, { canvas: n });
1978
+ n.setActiveObject(d);
1959
1979
  } else
1960
- this._fitSingleObject(o, t);
1961
- a.renderAll(), s || i.saveState(), a.fire("editor:object-fitted", {
1962
- object: o,
1980
+ this._fitSingleObject(i, t);
1981
+ n.renderAll(), s || o.saveState(), n.fire("editor:object-fitted", {
1982
+ object: i,
1963
1983
  type: t,
1964
1984
  withoutSave: s,
1965
- fitAsOneObject: n
1985
+ fitAsOneObject: a
1966
1986
  });
1967
1987
  }
1968
1988
  }
@@ -1973,11 +1993,11 @@ class ct {
1973
1993
  * @private
1974
1994
  */
1975
1995
  _fitSingleObject(e, t) {
1976
- const { canvas: s, montageArea: n } = this.editor, { width: a, height: i, scaleX: o = 1, scaleY: d = 1, angle: c = 0 } = e, h = a * Math.abs(o), l = i * 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;
1977
1997
  let S;
1978
- t === "contain" ? S = Math.min(b / m, A / u) : S = Math.max(b / m, A / u), e.set({
1979
- scaleX: o * S,
1980
- 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
1981
2001
  }), s.centerObject(e);
1982
2002
  }
1983
2003
  /**
@@ -1998,36 +2018,36 @@ class ct {
1998
2018
  */
1999
2019
  resetObject({ object: e, alwaysFitObject: t = !1, withoutSave: s = !1 } = {}) {
2000
2020
  const {
2001
- canvas: n,
2002
- montageArea: a,
2003
- imageManager: i,
2004
- historyManager: o,
2005
- options: { scaleType: d }
2006
- } = this.editor, c = e || n.getActiveObject();
2007
- if (!c || c.locked) return;
2008
- 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({
2009
2029
  scaleX: 1,
2010
2030
  scaleY: 1,
2011
2031
  flipX: !1,
2012
2032
  flipY: !1,
2013
2033
  angle: 0
2014
2034
  }), t)
2015
- this.fitObject({ object: c, withoutSave: !0, fitAsOneObject: !0 });
2035
+ this.fitObject({ object: d, withoutSave: !0, fitAsOneObject: !0 });
2016
2036
  else {
2017
- const { width: l, height: g } = a, { width: M, height: f } = c, m = i.calculateScaleFactor({
2018
- imageObject: c,
2019
- scaleType: d
2037
+ const { width: l, height: g } = n, { width: M, height: m } = d, f = o.calculateScaleFactor({
2038
+ imageObject: d,
2039
+ scaleType: c
2020
2040
  });
2021
- 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 });
2022
2042
  }
2023
- c.set({ flipX: !1, flipY: !1, angle: 0 }), n.centerObject(c), n.renderAll(), o.resumeHistory(), s || o.saveState(), n.fire("editor:object-reset", {
2024
- 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,
2025
2045
  withoutSave: s,
2026
2046
  alwaysFitObject: t
2027
2047
  });
2028
2048
  }
2029
2049
  }
2030
- class dt {
2050
+ class ht {
2031
2051
  constructor({ editor: e }) {
2032
2052
  this.editor = e, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
2033
2053
  }
@@ -2057,8 +2077,8 @@ class dt {
2057
2077
  const { canvas: e, montageArea: t, historyManager: s } = this.editor;
2058
2078
  if (!t || !this.overlayMask) return;
2059
2079
  s.suspendHistory(), t.setCoords();
2060
- const { left: n, top: a, width: i, height: o } = t.getBoundingRect();
2061
- this.overlayMask.set({ left: n, top: a, width: i, 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();
2062
2082
  }
2063
2083
  /**
2064
2084
  * Выключает редактор:
@@ -2069,8 +2089,8 @@ class dt {
2069
2089
  block() {
2070
2090
  if (this.isBlocked || !this.overlayMask) return;
2071
2091
  const { canvas: e, canvasManager: t, historyManager: s } = this.editor;
2072
- s.suspendHistory(), this.isBlocked = !0, e.discardActiveObject(), e.selection = !1, e.skipTargetFind = !0, t.getObjects().forEach((n) => {
2073
- 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;
2074
2094
  }), e.upperCanvasEl.style.pointerEvents = "none", e.lowerCanvasEl.style.pointerEvents = "none", this.overlayMask.visible = !0, this.refresh(), e.fire("editor:disabled"), s.resumeHistory();
2075
2095
  }
2076
2096
  /**
@@ -2079,12 +2099,271 @@ class dt {
2079
2099
  unblock() {
2080
2100
  if (!this.isBlocked || !this.overlayMask) return;
2081
2101
  const { canvas: e, canvasManager: t, historyManager: s } = this.editor;
2082
- s.suspendHistory(), this.isBlocked = !1, e.selection = !0, e.skipTargetFind = !1, t.getObjects().forEach((n) => {
2083
- 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;
2084
2104
  }), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), s.resumeHistory();
2085
2105
  }
2086
2106
  }
2087
- 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 {
2088
2367
  constructor({ editor: e }) {
2089
2368
  this.editor = e;
2090
2369
  }
@@ -2096,13 +2375,13 @@ class G {
2096
2375
  * @fires editor:object-bring-to-front
2097
2376
  */
2098
2377
  bringToFront(e, { withoutSave: t } = {}) {
2099
- const { canvas: s, historyManager: n } = this.editor;
2100
- n.suspendHistory();
2101
- const a = e || s.getActiveObject();
2102
- a && (a instanceof y ? a.getObjects().forEach((i) => {
2103
- s.bringObjectToFront(i);
2104
- }) : s.bringObjectToFront(a), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-to-front", {
2105
- object: a,
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,
2106
2385
  withoutSave: t
2107
2386
  }));
2108
2387
  }
@@ -2114,11 +2393,11 @@ class G {
2114
2393
  * @fires editor:object-bring-forward
2115
2394
  */
2116
2395
  bringForward(e, { withoutSave: t } = {}) {
2117
- const { canvas: s, historyManager: n } = this.editor;
2118
- n.suspendHistory();
2119
- const a = e || s.getActiveObject();
2120
- a && (a instanceof y ? G._moveSelectionForward(s, a) : s.bringObjectForward(a), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-forward", {
2121
- object: a,
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,
2122
2401
  withoutSave: t
2123
2402
  }));
2124
2403
  }
@@ -2132,21 +2411,22 @@ class G {
2132
2411
  sendToBack(e, { withoutSave: t } = {}) {
2133
2412
  const {
2134
2413
  canvas: s,
2135
- montageArea: n,
2136
- historyManager: a,
2137
- interactionBlocker: { overlayMask: i }
2414
+ montageArea: a,
2415
+ historyManager: n,
2416
+ interactionBlocker: { overlayMask: o },
2417
+ backgroundManager: { backgroundObject: i }
2138
2418
  } = this.editor;
2139
- a.suspendHistory();
2140
- const o = e || s.getActiveObject();
2141
- if (o) {
2142
- if (o instanceof y) {
2143
- const d = o.getObjects();
2144
- for (let c = d.length - 1; c >= 0; c -= 1)
2145
- 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]);
2146
2426
  } else
2147
- s.sendObjectToBack(o);
2148
- s.sendObjectToBack(n), i && s.sendObjectToBack(i), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:object-send-to-back", {
2149
- 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,
2150
2430
  withoutSave: t
2151
2431
  });
2152
2432
  }
@@ -2160,14 +2440,15 @@ class G {
2160
2440
  sendBackwards(e, { withoutSave: t } = {}) {
2161
2441
  const {
2162
2442
  canvas: s,
2163
- montageArea: n,
2164
- historyManager: a,
2165
- interactionBlocker: { overlayMask: i }
2443
+ montageArea: a,
2444
+ historyManager: n,
2445
+ interactionBlocker: { overlayMask: o },
2446
+ backgroundManager: { backgroundObject: i }
2166
2447
  } = this.editor;
2167
- a.suspendHistory();
2168
- const o = e || s.getActiveObject();
2169
- o && (o instanceof y ? G._moveSelectionBackwards(s, o) : s.sendObjectBackwards(o), s.sendObjectToBack(n), i && s.sendObjectToBack(i), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:object-send-backwards", {
2170
- 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,
2171
2452
  withoutSave: t
2172
2453
  }));
2173
2454
  }
@@ -2178,16 +2459,16 @@ class G {
2178
2459
  * @param activeSelection - активное выделение
2179
2460
  */
2180
2461
  static _moveSelectionForward(e, t) {
2181
- const s = e.getObjects(), n = t.getObjects();
2182
- if (!n.some((o) => {
2183
- const d = s.indexOf(o);
2184
- for (let c = d + 1; c < s.length; c += 1)
2185
- 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]))
2186
2467
  return !0;
2187
2468
  return !1;
2188
2469
  })) return;
2189
- n.map((o) => ({ obj: o, index: s.indexOf(o) })).sort((o, d) => d.index - o.index).forEach((o) => {
2190
- 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);
2191
2472
  });
2192
2473
  }
2193
2474
  /**
@@ -2197,20 +2478,20 @@ class G {
2197
2478
  * @param activeSelection - активное выделение
2198
2479
  */
2199
2480
  static _moveSelectionBackwards(e, t) {
2200
- const s = e.getObjects(), n = t.getObjects();
2201
- if (!n.some((o) => {
2202
- const d = s.indexOf(o);
2203
- for (let c = d - 1; c >= 0; c -= 1)
2204
- 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]))
2205
2486
  return !0;
2206
2487
  return !1;
2207
2488
  })) return;
2208
- n.map((o) => ({ obj: o, index: s.indexOf(o) })).sort((o, d) => o.index - d.index).forEach((o) => {
2209
- 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);
2210
2491
  });
2211
2492
  }
2212
2493
  }
2213
- class lt {
2494
+ class gt {
2214
2495
  /**
2215
2496
  * Менеджер фигур для редактора.
2216
2497
  * @param options - Опции и настройки менеджера фигур.
@@ -2234,15 +2515,15 @@ class lt {
2234
2515
  * @param flags.withoutSelection - Не выделять объект
2235
2516
  * @param flags.withoutAdding - Не добавлять объект в canvas
2236
2517
  */
2237
- addRectangle(h = {}, { withoutSelection: d, withoutAdding: c } = {}) {
2518
+ addRectangle(h = {}, { withoutSelection: c, withoutAdding: d } = {}) {
2238
2519
  var l = h, {
2239
- id: e = `rect-${D()}`,
2520
+ id: e = `rect-${v()}`,
2240
2521
  left: t,
2241
2522
  top: s,
2242
- width: n = 100,
2243
- height: a = 100,
2244
- fill: i = "blue"
2245
- } = l, o = P(l, [
2523
+ width: a = 100,
2524
+ height: n = 100,
2525
+ fill: o = "blue"
2526
+ } = l, i = W(l, [
2246
2527
  "id",
2247
2528
  "left",
2248
2529
  "top",
@@ -2250,15 +2531,15 @@ class lt {
2250
2531
  "height",
2251
2532
  "fill"
2252
2533
  ]);
2253
- const { canvas: g } = this.editor, M = new De(p({
2534
+ const { canvas: g } = this.editor, M = new Ne(p({
2254
2535
  id: e,
2255
2536
  left: t,
2256
2537
  top: s,
2257
- width: n,
2258
- height: a,
2259
- fill: i
2260
- }, o));
2261
- 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;
2262
2543
  }
2263
2544
  /**
2264
2545
  * Добавление круга
@@ -2276,28 +2557,28 @@ class lt {
2276
2557
  * @param flags.withoutSelection - Не выделять объект
2277
2558
  * @param flags.withoutAdding - Не добавлять объект в canvas
2278
2559
  */
2279
- addCircle(c = {}, { withoutSelection: o, withoutAdding: d } = {}) {
2280
- var h = c, {
2281
- id: e = `circle-${D()}`,
2560
+ addCircle(d = {}, { withoutSelection: i, withoutAdding: c } = {}) {
2561
+ var h = d, {
2562
+ id: e = `circle-${v()}`,
2282
2563
  left: t,
2283
2564
  top: s,
2284
- radius: n = 50,
2285
- fill: a = "green"
2286
- } = h, i = P(h, [
2565
+ radius: a = 50,
2566
+ fill: n = "green"
2567
+ } = h, o = W(h, [
2287
2568
  "id",
2288
2569
  "left",
2289
2570
  "top",
2290
2571
  "radius",
2291
2572
  "fill"
2292
2573
  ]);
2293
- const { canvas: l } = this.editor, g = new Le(p({
2574
+ const { canvas: l } = this.editor, g = new Oe(p({
2294
2575
  id: e,
2295
2576
  left: t,
2296
2577
  top: s,
2297
- fill: a,
2298
- radius: n
2299
- }, i));
2300
- 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;
2301
2582
  }
2302
2583
  /**
2303
2584
  * Добавление треугольника
@@ -2316,15 +2597,15 @@ class lt {
2316
2597
  * @param flags.withoutSelection - Не выделять объект
2317
2598
  * @param flags.withoutAdding - Не добавлять объект в canvas
2318
2599
  */
2319
- addTriangle(h = {}, { withoutSelection: d, withoutAdding: c } = {}) {
2600
+ addTriangle(h = {}, { withoutSelection: c, withoutAdding: d } = {}) {
2320
2601
  var l = h, {
2321
- id: e = `triangle-${D()}`,
2602
+ id: e = `triangle-${v()}`,
2322
2603
  left: t,
2323
2604
  top: s,
2324
- width: n = 100,
2325
- height: a = 100,
2326
- fill: i = "yellow"
2327
- } = l, o = P(l, [
2605
+ width: a = 100,
2606
+ height: n = 100,
2607
+ fill: o = "yellow"
2608
+ } = l, i = W(l, [
2328
2609
  "id",
2329
2610
  "left",
2330
2611
  "top",
@@ -2332,18 +2613,18 @@ class lt {
2332
2613
  "height",
2333
2614
  "fill"
2334
2615
  ]);
2335
- const { canvas: g } = this.editor, M = new Ne(p({
2616
+ const { canvas: g } = this.editor, M = new Le(p({
2336
2617
  id: e,
2337
2618
  left: t,
2338
2619
  top: s,
2339
- fill: i,
2340
- width: n,
2341
- height: a
2342
- }, o));
2343
- 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;
2344
2625
  }
2345
2626
  }
2346
- class ht {
2627
+ class ut {
2347
2628
  /**
2348
2629
  * @param options
2349
2630
  * @param options.editor - экземпляр редактора с доступом к canvas
@@ -2371,18 +2652,18 @@ class ht {
2371
2652
  * Асинхронное клонирование для внутреннего буфера
2372
2653
  */
2373
2654
  _cloneToInternalClipboard(e) {
2374
- return j(this, null, function* () {
2655
+ return b(this, null, function* () {
2375
2656
  const { canvas: t, errorManager: s } = this.editor;
2376
2657
  try {
2377
- const n = yield e.clone(["format"]);
2378
- this.clipboard = n, t.fire("editor:object-copied", { object: n });
2379
- } catch (n) {
2658
+ const a = yield e.clone(["format"]);
2659
+ this.clipboard = a, t.fire("editor:object-copied", { object: a });
2660
+ } catch (a) {
2380
2661
  s.emitError({
2381
2662
  origin: "ClipboardManager",
2382
2663
  method: "_cloneToInternalClipboard",
2383
2664
  code: "CLONE_FAILED",
2384
2665
  message: "Ошибка клонирования объекта для внутреннего буфера",
2385
- data: n
2666
+ data: a
2386
2667
  });
2387
2668
  }
2388
2669
  });
@@ -2391,7 +2672,7 @@ class ht {
2391
2672
  * Копирование в системный буфер обмена
2392
2673
  */
2393
2674
  _copyToSystemClipboard(e) {
2394
- return j(this, null, function* () {
2675
+ return b(this, null, function* () {
2395
2676
  const { errorManager: t } = this.editor;
2396
2677
  if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
2397
2678
  return t.emitWarning({
@@ -2401,8 +2682,8 @@ class ht {
2401
2682
  message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
2402
2683
  }), !1;
2403
2684
  try {
2404
- const s = e.toObject(["format"]), n = JSON.stringify(s);
2405
- 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);
2406
2687
  } catch (s) {
2407
2688
  return t.emitError({
2408
2689
  origin: "ClipboardManager",
@@ -2418,12 +2699,12 @@ class ht {
2418
2699
  * Копирование изображения в буфер обмена
2419
2700
  */
2420
2701
  _copyImageToClipboard(e, t) {
2421
- return j(this, null, function* () {
2702
+ return b(this, null, function* () {
2422
2703
  try {
2423
- const n = e.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), a = n.slice(5).split(";")[0], i = n.split(",")[1], o = atob(i), d = new Uint8Array(o.length);
2424
- for (let l = 0; l < o.length; l += 1)
2425
- d[l] = o.charCodeAt(l);
2426
- const c = new Blob([d.buffer], { type: a }), h = new ClipboardItem({ [a]: 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 });
2427
2708
  return yield navigator.clipboard.write([h]), console.info("Image copied to clipboard successfully"), !0;
2428
2709
  } catch (s) {
2429
2710
  return this.editor.errorManager.emitWarning({
@@ -2440,7 +2721,7 @@ class ht {
2440
2721
  * Копирование текста в буфер обмена
2441
2722
  */
2442
2723
  _copyTextToClipboard(e) {
2443
- return j(this, null, function* () {
2724
+ return b(this, null, function* () {
2444
2725
  try {
2445
2726
  const t = `${me}${e}`;
2446
2727
  return yield navigator.clipboard.writeText(t), console.info("Text copied to clipboard successfully"), !0;
@@ -2463,8 +2744,8 @@ class ht {
2463
2744
  _addClonedObjectToCanvas(e) {
2464
2745
  const { canvas: t, historyManager: s } = this.editor;
2465
2746
  if (t.discardActiveObject(), e instanceof y) {
2466
- s.suspendHistory(), e.canvas = t, e.forEachObject((n) => {
2467
- t.add(n);
2747
+ s.suspendHistory(), e.canvas = t, e.forEachObject((a) => {
2748
+ t.add(a);
2468
2749
  }), t.setActiveObject(e), t.requestRenderAll(), s.resumeHistory(), s.saveState();
2469
2750
  return;
2470
2751
  }
@@ -2475,7 +2756,7 @@ class ht {
2475
2756
  * @param source - источник изображения (data URL или URL)
2476
2757
  */
2477
2758
  _handleImageImport(e) {
2478
- return j(this, null, function* () {
2759
+ return b(this, null, function* () {
2479
2760
  var s;
2480
2761
  const { image: t } = (s = yield this.editor.imageManager.importImage({
2481
2762
  source: e,
@@ -2491,25 +2772,25 @@ class ht {
2491
2772
  * @fires editor:object-pasted
2492
2773
  */
2493
2774
  copyPaste(e) {
2494
- return j(this, null, function* () {
2775
+ return b(this, null, function* () {
2495
2776
  const { canvas: t } = this.editor, s = e || t.getActiveObject();
2496
2777
  if (!s || s.locked) return !1;
2497
2778
  try {
2498
- const n = yield s.clone(["format"]);
2499
- return n.set({
2500
- id: `${n.type}-${D()}`,
2501
- left: n.left + 10,
2502
- 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,
2503
2784
  evented: !0
2504
- }), this._addClonedObjectToCanvas(n), t.fire("editor:object-duplicated", { object: n }), !0;
2505
- } catch (n) {
2506
- const { errorManager: a } = this.editor;
2507
- return a.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({
2508
2789
  origin: "ClipboardManager",
2509
2790
  method: "copyPaste",
2510
2791
  code: "COPY_PASTE_FAILED",
2511
2792
  message: "Ошибка создания копии объекта",
2512
- data: n
2793
+ data: a
2513
2794
  }), !1;
2514
2795
  }
2515
2796
  });
@@ -2521,9 +2802,9 @@ class ht {
2521
2802
  * @param event.clipboardData.items — элементы буфера обмена
2522
2803
  */
2523
2804
  handlePasteEvent(t) {
2524
- return j(this, arguments, function* ({ clipboardData: e }) {
2525
- var d;
2526
- 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)) {
2527
2808
  this.paste();
2528
2809
  return;
2529
2810
  }
@@ -2532,10 +2813,10 @@ class ht {
2532
2813
  this.paste();
2533
2814
  return;
2534
2815
  }
2535
- const { items: n } = e, a = n[n.length - 1], i = a.getAsFile();
2536
- if (a.type !== "text/html" && i) {
2537
- const c = new FileReader();
2538
- 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) => {
2539
2820
  h.target && this._handleImageImport(h.target.result).catch((l) => {
2540
2821
  this.editor.errorManager.emitError({
2541
2822
  origin: "ClipboardManager",
@@ -2545,12 +2826,12 @@ class ht {
2545
2826
  data: l
2546
2827
  });
2547
2828
  });
2548
- }, c.readAsDataURL(i);
2829
+ }, d.readAsDataURL(o);
2549
2830
  return;
2550
2831
  }
2551
- const o = e.getData("text/html");
2552
- if (o) {
2553
- 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");
2554
2835
  if (l != null && l.src) {
2555
2836
  this._handleImageImport(l.src).catch((g) => {
2556
2837
  this.editor.errorManager.emitError({
@@ -2572,13 +2853,13 @@ class ht {
2572
2853
  * @fires editor:object-pasted
2573
2854
  */
2574
2855
  paste() {
2575
- return j(this, null, function* () {
2856
+ return b(this, null, function* () {
2576
2857
  const { canvas: e } = this.editor;
2577
2858
  if (!this.clipboard) return !1;
2578
2859
  try {
2579
2860
  const t = yield this.clipboard.clone(["format"]);
2580
2861
  return e.discardActiveObject(), t.set({
2581
- id: `${t.type}-${D()}`,
2862
+ id: `${t.type}-${v()}`,
2582
2863
  left: t.left + 10,
2583
2864
  top: t.top + 10,
2584
2865
  evented: !0
@@ -2596,7 +2877,7 @@ class ht {
2596
2877
  });
2597
2878
  }
2598
2879
  }
2599
- class X {
2880
+ class Q {
2600
2881
  constructor({ editor: e }) {
2601
2882
  this.editor = e;
2602
2883
  }
@@ -2609,9 +2890,9 @@ class X {
2609
2890
  * @fires editor:object-locked
2610
2891
  */
2611
2892
  lockObject({ object: e, skipInnerObjects: t, withoutSave: s } = {}) {
2612
- const { canvas: n, historyManager: a } = this.editor, i = e || n.getActiveObject();
2613
- if (!i || i.locked) return;
2614
- const o = {
2893
+ const { canvas: a, historyManager: n } = this.editor, o = e || a.getActiveObject();
2894
+ if (!o || o.locked) return;
2895
+ const i = {
2615
2896
  lockMovementX: !0,
2616
2897
  lockMovementY: !0,
2617
2898
  lockRotation: !0,
@@ -2621,10 +2902,10 @@ class X {
2621
2902
  lockSkewingY: !0,
2622
2903
  locked: !0
2623
2904
  };
2624
- i.set(o), !t && X._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
2625
- c.set(o);
2626
- }), n.renderAll(), s || a.saveState(), n.fire("editor:object-locked", {
2627
- object: i,
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,
2628
2909
  skipInnerObjects: t,
2629
2910
  withoutSave: s
2630
2911
  });
@@ -2637,9 +2918,9 @@ class X {
2637
2918
  * @fires editor:object-unlocked
2638
2919
  */
2639
2920
  unlockObject({ object: e, withoutSave: t } = {}) {
2640
- const { canvas: s, historyManager: n } = this.editor, a = e || s.getActiveObject();
2641
- if (!a) return;
2642
- const i = {
2921
+ const { canvas: s, historyManager: a } = this.editor, n = e || s.getActiveObject();
2922
+ if (!n) return;
2923
+ const o = {
2643
2924
  lockMovementX: !1,
2644
2925
  lockMovementY: !1,
2645
2926
  lockRotation: !1,
@@ -2649,10 +2930,10 @@ class X {
2649
2930
  lockSkewingY: !1,
2650
2931
  locked: !1
2651
2932
  };
2652
- a.set(i), X._isGroupOrSelection(a) && a.getObjects().forEach((o) => {
2653
- o.set(i);
2654
- }), s.renderAll(), t || n.saveState(), s.fire("editor:object-unlocked", {
2655
- object: a,
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,
2656
2937
  withoutSave: t
2657
2938
  });
2658
2939
  }
@@ -2660,7 +2941,7 @@ class X {
2660
2941
  return e instanceof y || e instanceof J;
2661
2942
  }
2662
2943
  }
2663
- class gt {
2944
+ class Mt {
2664
2945
  constructor({ editor: e }) {
2665
2946
  this.editor = e;
2666
2947
  }
@@ -2675,14 +2956,14 @@ class gt {
2675
2956
  object: e,
2676
2957
  withoutSave: t
2677
2958
  } = {}) {
2678
- const { canvas: s, historyManager: n } = this.editor;
2679
- n.suspendHistory();
2680
- const a = e || s.getActiveObject();
2681
- if (!a || !(a instanceof y)) return;
2682
- const i = a.getObjects(), o = new J(i);
2683
- i.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", {
2684
- object: a,
2685
- 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,
2686
2967
  withoutSave: t
2687
2968
  });
2688
2969
  }
@@ -2697,23 +2978,23 @@ class gt {
2697
2978
  object: e,
2698
2979
  withoutSave: t
2699
2980
  } = {}) {
2700
- const { canvas: s, historyManager: n } = this.editor;
2701
- n.suspendHistory();
2702
- const a = e || s.getActiveObject();
2703
- if (!(a instanceof J)) return;
2704
- const i = a.removeAll();
2705
- s.remove(a), i.forEach((d) => s.add(d));
2706
- const o = new y(i, {
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, {
2707
2988
  canvas: s
2708
2989
  });
2709
- s.setActiveObject(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-ungrouped", {
2710
- object: a,
2711
- selection: o,
2990
+ s.setActiveObject(i), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:objects-ungrouped", {
2991
+ object: n,
2992
+ selection: i,
2712
2993
  withoutSave: t
2713
2994
  });
2714
2995
  }
2715
2996
  }
2716
- class ut {
2997
+ class ft {
2717
2998
  constructor({ editor: e }) {
2718
2999
  this.editor = e;
2719
3000
  }
@@ -2724,11 +3005,11 @@ class ut {
2724
3005
  selectAll() {
2725
3006
  const { canvas: e, canvasManager: t, objectLockManager: s } = this.editor;
2726
3007
  e.discardActiveObject();
2727
- const n = t.getObjects(), a = n.some((o) => o.locked), i = n.length > 1 ? new y(t.getObjects(), { canvas: e }) : n[0];
2728
- a && s.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(i), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: i });
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 });
2729
3010
  }
2730
3011
  }
2731
- class Mt {
3012
+ class mt {
2732
3013
  constructor({ editor: e }) {
2733
3014
  this.editor = e;
2734
3015
  }
@@ -2743,20 +3024,20 @@ class Mt {
2743
3024
  objects: e,
2744
3025
  withoutSave: t
2745
3026
  } = {}) {
2746
- const { canvas: s, historyManager: n, groupingManager: a } = this.editor, i = (e || s.getActiveObjects()).filter((o) => !o.locked);
2747
- i != null && i.length && (n.suspendHistory(), i.forEach((o) => {
2748
- if (o.type === "group" && o.format !== "svg") {
2749
- a.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();
2750
3031
  return;
2751
3032
  }
2752
- s.remove(o);
2753
- }), s.discardActiveObject(), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-deleted", {
2754
- objects: i,
3033
+ s.remove(i);
3034
+ }), s.discardActiveObject(), s.renderAll(), a.resumeHistory(), t || a.saveState(), s.fire("editor:objects-deleted", {
3035
+ objects: o,
2755
3036
  withoutSave: t
2756
3037
  }));
2757
3038
  }
2758
3039
  }
2759
- const mt = {
3040
+ const bt = {
2760
3041
  IMAGE_MANAGER: {
2761
3042
  /**
2762
3043
  * Некорректный Content-Type изображения
@@ -2832,9 +3113,30 @@ const mt = {
2832
3113
  HISTORY_MANAGER: {
2833
3114
  UNDO_ERROR: "UNDO_ERROR",
2834
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"
2835
3137
  }
2836
3138
  };
2837
- class Q {
3139
+ class K {
2838
3140
  constructor({ editor: e }) {
2839
3141
  this._buffer = [], this.editor = e;
2840
3142
  }
@@ -2860,24 +3162,24 @@ class Q {
2860
3162
  * @param options.message — текст ошибки (опционально, если не передан, то используется код ошибки)
2861
3163
  * @fires editor:error
2862
3164
  */
2863
- emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: n, message: a }) {
2864
- if (!Q.isValidErrorCode(s)) {
3165
+ emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: a, message: n }) {
3166
+ if (!K.isValidErrorCode(s)) {
2865
3167
  console.warn("Неизвестный код ошибки: ", { code: s, origin: e, method: t });
2866
3168
  return;
2867
3169
  }
2868
3170
  if (!s) return;
2869
- const i = a || s;
2870
- console.error(`${e}. ${t}. ${s}. ${i}`, n);
2871
- const o = {
3171
+ const o = n || s;
3172
+ console.error(`${e}. ${t}. ${s}. ${o}`, a);
3173
+ const i = {
2872
3174
  code: s,
2873
3175
  origin: e,
2874
3176
  method: t,
2875
- message: i,
2876
- data: n
3177
+ message: o,
3178
+ data: a
2877
3179
  };
2878
3180
  this._buffer.push(p({
2879
3181
  type: "editor:error"
2880
- }, o)), this.editor.canvas.fire("editor:error", o);
3182
+ }, i)), this.editor.canvas.fire("editor:error", i);
2881
3183
  }
2882
3184
  /**
2883
3185
  * Эмитит предупреждение через fabricjs
@@ -2889,23 +3191,23 @@ class Q {
2889
3191
  * @param options.message — текст предупреждения (опционально, если не передан, то используется код предупреждения)
2890
3192
  * @fires editor:warning
2891
3193
  */
2892
- emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: n, data: a }) {
2893
- if (!Q.isValidErrorCode(s)) {
3194
+ emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: a, data: n }) {
3195
+ if (!K.isValidErrorCode(s)) {
2894
3196
  console.warn("Неизвестный код предупреждения: ", { code: s, origin: e, method: t });
2895
3197
  return;
2896
3198
  }
2897
- const i = n || s;
2898
- console.warn(`${e}. ${t}. ${s}. ${i}`, a);
2899
- const o = {
3199
+ const o = a || s;
3200
+ console.warn(`${e}. ${t}. ${s}. ${o}`, n);
3201
+ const i = {
2900
3202
  code: s,
2901
3203
  origin: e,
2902
3204
  method: t,
2903
- message: i,
2904
- data: a
3205
+ message: o,
3206
+ data: n
2905
3207
  };
2906
3208
  this._buffer.push(p({
2907
3209
  type: "editor:warning"
2908
- }, o)), this.editor.canvas.fire("editor:warning", o);
3210
+ }, i)), this.editor.canvas.fire("editor:warning", i);
2909
3211
  }
2910
3212
  /**
2911
3213
  * Проверяет, является ли код ошибки или предупреждения допустимым
@@ -2913,7 +3215,7 @@ class Q {
2913
3215
  * @returns true, если код допустим, иначе false
2914
3216
  */
2915
3217
  static isValidErrorCode(e) {
2916
- 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;
2917
3219
  }
2918
3220
  }
2919
3221
  class ie {
@@ -2923,7 +3225,7 @@ class ie {
2923
3225
  * @param options - опции и настройки редактора
2924
3226
  */
2925
3227
  constructor(e, t) {
2926
- 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();
2927
3229
  }
2928
3230
  /**
2929
3231
  * Инициализация редактора.
@@ -2931,29 +3233,29 @@ class ie {
2931
3233
  * @fires editor:ready
2932
3234
  */
2933
3235
  init() {
2934
- return j(this, null, function* () {
3236
+ return b(this, null, function* () {
2935
3237
  const {
2936
3238
  editorContainerWidth: e,
2937
3239
  editorContainerHeight: t,
2938
3240
  canvasWrapperWidth: s,
2939
- canvasWrapperHeight: n,
2940
- canvasCSSWidth: a,
2941
- canvasCSSHeight: i,
2942
- initialImage: o,
2943
- initialStateJSON: d,
2944
- scaleType: c,
3241
+ canvasWrapperHeight: a,
3242
+ canvasCSSWidth: n,
3243
+ canvasCSSHeight: o,
3244
+ initialImage: i,
3245
+ initialStateJSON: c,
3246
+ scaleType: d,
2945
3247
  _onReadyCallback: h
2946
3248
  } = this.options;
2947
- if (We.apply(), this.canvas = new Ee(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 E({ 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(a), this.canvasManager.setCanvasCSSHeight(i), 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) {
2948
3250
  const {
2949
3251
  source: l,
2950
- scale: g = `image-${c}`,
3252
+ scale: g = `image-${d}`,
2951
3253
  withoutSave: M = !0
2952
- } = o;
3254
+ } = i;
2953
3255
  yield this.imageManager.importImage({ source: l, scale: g, withoutSave: M });
2954
3256
  } else
2955
3257
  this.canvasManager.setDefaultScale({ withoutSave: !0 });
2956
- 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);
2957
3259
  });
2958
3260
  }
2959
3261
  /**
@@ -3023,7 +3325,7 @@ class ie {
3023
3325
  });
3024
3326
  }
3025
3327
  }
3026
- const ft = {
3328
+ const jt = {
3027
3329
  /**
3028
3330
  * Опции редактора
3029
3331
  */
@@ -3112,18 +3414,18 @@ const ft = {
3112
3414
  resetObjectFitByDoubleClick: !0,
3113
3415
  keyboardIgnoreSelectors: []
3114
3416
  };
3115
- function At(r, e = {}) {
3116
- 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);
3117
3419
  if (!s)
3118
3420
  return Promise.reject(new Error(`Контейнер с ID "${r}" не найден.`));
3119
- const n = document.createElement("canvas");
3120
- return n.id = `${r}-canvas`, s.appendChild(n), t.editorContainer = s, new Promise((a) => {
3121
- t._onReadyCallback = a;
3122
- const i = new ie(n.id, t);
3123
- window[r] = i;
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;
3124
3426
  });
3125
3427
  }
3126
3428
  export {
3127
- At as default
3429
+ St as default
3128
3430
  };
3129
3431
  //# sourceMappingURL=main.js.map