@templatical/editor 0.39.1 → 0.39.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/MediaEditModal-D4GEq2md.js +3545 -0
  2. package/dist/{MediaPanels-Cc4UkfG1.js → MediaPanels-sapgKtxu.js} +1 -1
  3. package/dist/bundle-stats.json +7 -7
  4. package/dist/{cdn/chunks/ca-Jx2CDwtn.js → ca-BTf1Zbqb.js} +9 -2
  5. package/dist/cdn/chunks/MediaEditModal-BBZRcYKe.js +3529 -0
  6. package/dist/cdn/chunks/MediaEditModal-BBZRcYKe.js.map +1 -0
  7. package/dist/cdn/chunks/{MediaPanels-kX9AZQ7K.js → MediaPanels-CSBCsFwT.js} +2 -2
  8. package/dist/cdn/chunks/{MediaPanels-kX9AZQ7K.js.map → MediaPanels-CSBCsFwT.js.map} +1 -1
  9. package/dist/{ca-Jx2CDwtn.js → cdn/chunks/ca-BTf1Zbqb.js} +11 -0
  10. package/dist/cdn/chunks/{ca-Jx2CDwtn.js.map → ca-BTf1Zbqb.js.map} +1 -1
  11. package/dist/cdn/chunks/{de-Ck0pBGHu.js → de-xzrh9PA3.js} +10 -1
  12. package/dist/cdn/chunks/{de-Ck0pBGHu.js.map → de-xzrh9PA3.js.map} +1 -1
  13. package/dist/cdn/chunks/editor-modal-C-yBlj2C.js +2700 -0
  14. package/dist/cdn/chunks/editor-modal-C-yBlj2C.js.map +1 -0
  15. package/dist/cdn/chunks/en-DYtFUE2l.js +2 -0
  16. package/dist/cdn/chunks/{es-lagTvUfX.js → es-BT4LSpE2.js} +10 -1
  17. package/dist/cdn/chunks/{es-lagTvUfX.js.map → es-BT4LSpE2.js.map} +1 -1
  18. package/dist/cdn/chunks/{fr-C4hVl5Lk.js → fr-CI7OJoql.js} +10 -1
  19. package/dist/cdn/chunks/{fr-C4hVl5Lk.js.map → fr-CI7OJoql.js.map} +1 -1
  20. package/dist/{nl-CReD7Apd.js → cdn/chunks/nl-D8y5OWGB.js} +11 -0
  21. package/dist/cdn/chunks/{nl-CReD7Apd.js.map → nl-D8y5OWGB.js.map} +1 -1
  22. package/dist/cdn/chunks/{pt-BR-BRA0-vGP.js → pt-BR-DMCbUBvJ.js} +10 -1
  23. package/dist/cdn/chunks/{pt-BR-BRA0-vGP.js.map → pt-BR-DMCbUBvJ.js.map} +1 -1
  24. package/dist/cdn/chunks/{src-CZ-W8YBa.js → src-O5Sp_qJ7.js} +2 -2
  25. package/dist/cdn/chunks/{src-CZ-W8YBa.js.map → src-O5Sp_qJ7.js.map} +1 -1
  26. package/dist/cdn/editor.css +1 -1
  27. package/dist/cdn/editor.js +3 -3
  28. package/dist/{de-Ck0pBGHu.js → de-xzrh9PA3.js} +9 -0
  29. package/dist/editor-modal-oD1qNz_P.js +2773 -0
  30. package/dist/en-CM5fTFSo.js +2 -0
  31. package/dist/{es-lagTvUfX.js → es-BT4LSpE2.js} +9 -0
  32. package/dist/{fr-C4hVl5Lk.js → fr-CI7OJoql.js} +9 -0
  33. package/dist/{cdn/chunks/nl-CReD7Apd.js → nl-D8y5OWGB.js} +9 -2
  34. package/dist/{pt-BR-BRA0-vGP.js → pt-BR-DMCbUBvJ.js} +9 -0
  35. package/dist/style.css +1 -1
  36. package/dist/templatical-editor.js +2 -2
  37. package/package.json +7 -7
  38. package/dist/cdn/chunks/editor-modal-C_xYN_66.js +0 -5908
  39. package/dist/cdn/chunks/editor-modal-C_xYN_66.js.map +0 -1
  40. package/dist/cdn/chunks/en-BwfjKb4M.js +0 -2
  41. package/dist/editor-modal-OPhP71YO.js +0 -5998
  42. package/dist/en-CjNopehs.js +0 -2
@@ -0,0 +1,3529 @@
1
+ import { B as e, E as t, F as n, H as r, I as i, L as a, N as o, O as s, Q as c, R as l, S as u, U as d, at as f, b as p, ct as m, d as h, f as g, g as _, h as v, l as y, lt as ee, m as b, n as te, o as ne, p as x, s as re, u as ie, ut as S, y as ae } from "./draggable-IB4x6w2O.js";
2
+ import { t as oe } from "./_plugin-vue_export-helper-B3ysoDQm.js";
3
+ import { a as se, n as ce, o as le, r as ue, t as de } from "./editor-modal-C-yBlj2C.js";
4
+ //#region ../media-library/src/composables/useImageCrop.ts
5
+ var fe = {
6
+ free: void 0,
7
+ square: 1,
8
+ landscape43: 4 / 3,
9
+ landscape169: 16 / 9,
10
+ original: void 0
11
+ };
12
+ function pe(e) {
13
+ return e === "image/png" || e === "image/gif" ? {
14
+ mimeType: "image/png",
15
+ quality: 1
16
+ } : e === "image/webp" ? {
17
+ mimeType: "image/webp",
18
+ quality: .92
19
+ } : {
20
+ mimeType: "image/jpeg",
21
+ quality: .92
22
+ };
23
+ }
24
+ function me(e, t, n) {
25
+ let r = e.width, i = e.height;
26
+ if (!t && !n) return e;
27
+ let a = r, o = i;
28
+ if (t && r > t && (a = t, o = Math.round(t / r * i)), n && o > n) {
29
+ let e = n / o;
30
+ a = Math.round(a * e), o = n;
31
+ }
32
+ if (a === r && o === i) return e;
33
+ let s = document.createElement("canvas");
34
+ s.width = a, s.height = o;
35
+ let c = s.getContext("2d");
36
+ return c && (c.imageSmoothingEnabled = !0, c.imageSmoothingQuality = "high", c.drawImage(e, 0, 0, a, o)), s;
37
+ }
38
+ function he(e, t, n) {
39
+ return new Promise((r, i) => {
40
+ e.toBlob((e) => {
41
+ if (!e) {
42
+ i(/* @__PURE__ */ Error("Failed to create blob from canvas"));
43
+ return;
44
+ }
45
+ let a = n.mimeType.split("/")[1], o = `${t.replace(/\.[^.]+$/, "")}.${a}`;
46
+ r(new File([e], o, { type: n.mimeType }));
47
+ }, n.mimeType, n.quality);
48
+ });
49
+ }
50
+ function ge(e, t, n, r) {
51
+ let i = e, a = t;
52
+ if (n && i > n) {
53
+ let e = n / i;
54
+ i = n, a = Math.round(a * e);
55
+ }
56
+ if (r && a > r) {
57
+ let e = r / a;
58
+ a = r, i = Math.round(i * e);
59
+ }
60
+ return {
61
+ width: i,
62
+ height: a
63
+ };
64
+ }
65
+ //#endregion
66
+ //#region ../../node_modules/.pnpm/vue-advanced-cropper@2.8.9_vue@3.5.43_typescript@6.0.3_/node_modules/vue-advanced-cropper/dist/index.esm-bundler.js
67
+ function _e(e, t) {
68
+ var n = Object.keys(e);
69
+ if (Object.getOwnPropertySymbols) {
70
+ var r = Object.getOwnPropertySymbols(e);
71
+ t && (r = r.filter((function(t) {
72
+ return Object.getOwnPropertyDescriptor(e, t).enumerable;
73
+ }))), n.push.apply(n, r);
74
+ }
75
+ return n;
76
+ }
77
+ function C(e) {
78
+ for (var t = 1; t < arguments.length; t++) {
79
+ var n = arguments[t] == null ? {} : arguments[t];
80
+ t % 2 ? _e(Object(n), !0).forEach((function(t) {
81
+ w(e, t, n[t]);
82
+ })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : _e(Object(n)).forEach((function(t) {
83
+ Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
84
+ }));
85
+ }
86
+ return e;
87
+ }
88
+ function w(e, t, n) {
89
+ return t in e ? Object.defineProperty(e, t, {
90
+ value: n,
91
+ enumerable: !0,
92
+ configurable: !0,
93
+ writable: !0
94
+ }) : e[t] = n, e;
95
+ }
96
+ function ve(e, t) {
97
+ if (e == null) return {};
98
+ var n, r, i = function(e, t) {
99
+ if (e == null) return {};
100
+ var n, r, i = {}, a = Object.keys(e);
101
+ for (r = 0; r < a.length; r++) n = a[r], t.indexOf(n) >= 0 || (i[n] = e[n]);
102
+ return i;
103
+ }(e, t);
104
+ if (Object.getOwnPropertySymbols) {
105
+ var a = Object.getOwnPropertySymbols(e);
106
+ for (r = 0; r < a.length; r++) n = a[r], t.indexOf(n) >= 0 || Object.prototype.propertyIsEnumerable.call(e, n) && (i[n] = e[n]);
107
+ }
108
+ return i;
109
+ }
110
+ function T(e) {
111
+ return function(e) {
112
+ if (Array.isArray(e)) return E(e);
113
+ }(e) || function(e) {
114
+ if (typeof Symbol < "u" && e[Symbol.iterator] != null || e["@@iterator"] != null) return Array.from(e);
115
+ }(e) || function(e, t) {
116
+ if (e) {
117
+ if (typeof e == "string") return E(e, t);
118
+ var n = Object.prototype.toString.call(e).slice(8, -1);
119
+ if (n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set") return Array.from(e);
120
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return E(e, t);
121
+ }
122
+ }(e) || function() {
123
+ throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
124
+ }();
125
+ }
126
+ function E(e, t) {
127
+ (t == null || t > e.length) && (t = e.length);
128
+ for (var n = 0, r = Array(t); n < t; n++) r[n] = e[n];
129
+ return r;
130
+ }
131
+ var ye = function(e) {
132
+ (function() {
133
+ var t = {}.hasOwnProperty;
134
+ function n() {
135
+ for (var e = [], r = 0; r < arguments.length; r++) {
136
+ var i = arguments[r];
137
+ if (i) {
138
+ var a = typeof i;
139
+ if (a === "string" || a === "number") e.push(i);
140
+ else if (Array.isArray(i)) {
141
+ if (i.length) {
142
+ var o = n.apply(null, i);
143
+ o && e.push(o);
144
+ }
145
+ } else if (a === "object") {
146
+ if (i.toString === Object.prototype.toString) for (var s in i) t.call(i, s) && i[s] && e.push(s);
147
+ else e.push(i.toString());
148
+ }
149
+ }
150
+ }
151
+ return e.join(" ");
152
+ }
153
+ e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
154
+ })();
155
+ }, be, D, O = (ye(D = {
156
+ path: be,
157
+ exports: {},
158
+ require: function(e, t) {
159
+ return function() {
160
+ throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs");
161
+ }(t == null && D.path);
162
+ }
163
+ }, D.exports), D.exports), k = function(e) {
164
+ return function(t, n) {
165
+ if (!t) return e;
166
+ var r;
167
+ typeof t == "string" ? r = t : n = t;
168
+ var i = e;
169
+ return r && (i += "__" + r), i + (n ? Object.keys(n).reduce((function(e, t) {
170
+ var r = n[t];
171
+ return r && (e += " " + (typeof r == "boolean" ? i + "--" + t : i + "--" + t + "_" + r)), e;
172
+ }), "") : "");
173
+ };
174
+ };
175
+ function A(e, t, n) {
176
+ var r, i, a, o, s;
177
+ function c() {
178
+ var l = Date.now() - o;
179
+ l < t && l >= 0 ? r = setTimeout(c, t - l) : (r = null, n || (s = e.apply(a, i), a = i = null));
180
+ }
181
+ t ??= 100;
182
+ var l = function() {
183
+ a = this, i = arguments, o = Date.now();
184
+ var l = n && !r;
185
+ return r ||= setTimeout(c, t), l && (s = e.apply(a, i), a = i = null), s;
186
+ };
187
+ return l.clear = function() {
188
+ r &&= (clearTimeout(r), null);
189
+ }, l.flush = function() {
190
+ r &&= (s = e.apply(a, i), a = i = null, clearTimeout(r), null);
191
+ }, l;
192
+ }
193
+ A.debounce = A;
194
+ var j = A, M = function() {
195
+ return M = Object.assign || function(e) {
196
+ for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
197
+ return e;
198
+ }, M.apply(this, arguments);
199
+ };
200
+ function N(e, t) {
201
+ var n, r;
202
+ return e && t ? (n = "" + e + t[0].toUpperCase() + t.slice(1), r = e + "-" + t) : (n = e || t, r = e || t), {
203
+ name: n,
204
+ classname: r
205
+ };
206
+ }
207
+ function P(e) {
208
+ return /^blob:/.test(e);
209
+ }
210
+ function xe(e) {
211
+ return P(e) || function(e) {
212
+ return /^data:/.test(e);
213
+ }(e);
214
+ }
215
+ function F(e) {
216
+ return !!(e && e.constructor && e.call && e.apply);
217
+ }
218
+ function I(e) {
219
+ return e === void 0;
220
+ }
221
+ function L(e) {
222
+ return typeof e == "object" && !!e;
223
+ }
224
+ function Se(e, t, n) {
225
+ var r = {};
226
+ return L(e) ? (Object.keys(t).forEach((function(i) {
227
+ r[i] = I(e[i]) ? t[i] : L(t[i]) ? L(e[i]) ? Se(e[i], t[i], n[i]) : e[i] ? t[i] : n[i] : !0 === t[i] || !1 === t[i] ? !!e[i] : e[i];
228
+ })), r) : e ? t : n;
229
+ }
230
+ function R(e) {
231
+ var t = Number(e);
232
+ return Number.isNaN(t) ? e : t;
233
+ }
234
+ function Ce(e) {
235
+ return typeof (e == "number" || function(e) {
236
+ return typeof e == "object" && !!e;
237
+ }(e) && toString.call(e) == "[object Number]") && !we(e);
238
+ }
239
+ function we(e) {
240
+ return e != e;
241
+ }
242
+ function Te(e, t) {
243
+ return Math.sqrt((e.x - t.x) ** 2 + (e.y - t.y) ** 2);
244
+ }
245
+ var z = function(e, t) {
246
+ e === void 0 && (e = {}), t === void 0 && (t = {}), this.type = "manipulateImage", this.move = e, this.scale = t;
247
+ }, Ee = function(e, t) {
248
+ t === void 0 && (t = {}), this.type = "resize", this.directions = e, this.params = t;
249
+ }, De = function(e) {
250
+ this.type = "move", this.directions = e;
251
+ }, Oe = function() {
252
+ function e(e, t, n, r, i) {
253
+ this.type = "drag", this.nativeEvent = e, this.position = n, this.previousPosition = r, this.element = t, this.anchor = i;
254
+ }
255
+ return e.prototype.shift = function() {
256
+ var e = this, t = e.element, n = e.anchor, r = e.position;
257
+ if (t) {
258
+ var i = t.getBoundingClientRect(), a = i.left, o = i.top;
259
+ return {
260
+ left: r.left - a - n.left,
261
+ top: r.top - o - n.top
262
+ };
263
+ }
264
+ return {
265
+ left: 0,
266
+ top: 0
267
+ };
268
+ }, e;
269
+ }(), ke = {
270
+ name: "DraggableElement",
271
+ props: { classname: { type: String } },
272
+ beforeMount: function() {
273
+ window.addEventListener("mouseup", this.onMouseUp, { passive: !1 }), window.addEventListener("mousemove", this.onMouseMove, { passive: !1 }), window.addEventListener("touchmove", this.onTouchMove, { passive: !1 }), window.addEventListener("touchend", this.onTouchEnd, { passive: !1 });
274
+ },
275
+ beforeUnmount: function() {
276
+ window.removeEventListener("mouseup", this.onMouseUp), window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("touchmove", this.onTouchMove), window.removeEventListener("touchend", this.onTouchEnd);
277
+ },
278
+ mounted: function() {
279
+ if (!this.$refs.draggable) throw Error("You should add ref \"draggable\" to your root element to use draggable mixin");
280
+ this.touches = [], this.hovered = !1;
281
+ },
282
+ methods: {
283
+ onMouseOver: function() {
284
+ this.hovered || (this.hovered = !0, this.$emit("enter"));
285
+ },
286
+ onMouseLeave: function() {
287
+ this.hovered && !this.touches.length && (this.hovered = !1, this.$emit("leave"));
288
+ },
289
+ onTouchStart: function(e) {
290
+ e.cancelable && !this.disabled && e.touches.length === 1 && (this.touches = T(e.touches), this.hovered ||= (this.$emit("enter"), !0), e.touches.length && this.initAnchor(this.touches.reduce((function(t, n) {
291
+ return {
292
+ clientX: t.clientX + n.clientX / e.touches.length,
293
+ clientY: t.clientY + n.clientY / e.touches.length
294
+ };
295
+ }), {
296
+ clientX: 0,
297
+ clientY: 0
298
+ })), e.preventDefault && e.preventDefault(), e.stopPropagation());
299
+ },
300
+ onTouchEnd: function() {
301
+ this.processEnd();
302
+ },
303
+ onTouchMove: function(e) {
304
+ this.touches.length && (this.processMove(e, e.touches), e.preventDefault && e.preventDefault(), e.stopPropagation && e.stopPropagation());
305
+ },
306
+ onMouseDown: function(e) {
307
+ if (!this.disabled) {
308
+ var t = {
309
+ fake: !0,
310
+ clientX: e.clientX,
311
+ clientY: e.clientY
312
+ };
313
+ this.touches = [t], this.initAnchor(t), e.stopPropagation();
314
+ }
315
+ },
316
+ onMouseMove: function(e) {
317
+ this.touches.length && (this.processMove(e, [{
318
+ fake: !0,
319
+ clientX: e.clientX,
320
+ clientY: e.clientY
321
+ }]), e.preventDefault && e.preventDefault());
322
+ },
323
+ onMouseUp: function() {
324
+ this.processEnd();
325
+ },
326
+ initAnchor: function(e) {
327
+ var t = this.$refs.draggable.getBoundingClientRect(), n = t.left, r = t.right, i = t.bottom, a = t.top;
328
+ this.anchor = {
329
+ left: e.clientX - n,
330
+ top: e.clientY - a,
331
+ bottom: i - e.clientY,
332
+ right: r - e.clientX
333
+ };
334
+ },
335
+ processMove: function(e, t) {
336
+ var n = T(t);
337
+ if (this.touches.length) {
338
+ if (this.touches.length === 1 && n.length === 1) {
339
+ var r = this.$refs.draggable;
340
+ this.$emit("drag", new Oe(e, r, {
341
+ left: n[0].clientX,
342
+ top: n[0].clientY
343
+ }, {
344
+ left: this.touches[0].clientX,
345
+ top: this.touches[0].clientY
346
+ }, this.anchor));
347
+ }
348
+ this.touches = n;
349
+ }
350
+ },
351
+ processEnd: function() {
352
+ this.touches.length && this.$emit("drag-end"), this.hovered &&= (this.$emit("leave"), !1), this.touches = [];
353
+ }
354
+ },
355
+ emits: [
356
+ "drag",
357
+ "drag-end",
358
+ "leave",
359
+ "enter"
360
+ ]
361
+ };
362
+ ke.render = function(e, t, n, r, a, s) {
363
+ return o(), b("div", {
364
+ ref: "draggable",
365
+ class: n.classname,
366
+ onTouchstart: t[1] ||= function() {
367
+ return s.onTouchStart && s.onTouchStart.apply(s, arguments);
368
+ },
369
+ onMousedown: t[2] ||= function() {
370
+ return s.onMouseDown && s.onMouseDown.apply(s, arguments);
371
+ },
372
+ onMouseover: t[3] ||= function() {
373
+ return s.onMouseOver && s.onMouseOver.apply(s, arguments);
374
+ },
375
+ onMouseleave: t[4] ||= function() {
376
+ return s.onMouseLeave && s.onMouseLeave.apply(s, arguments);
377
+ }
378
+ }, [i(e.$slots, "default")], 34);
379
+ };
380
+ var Ae = k("vue-handler-wrapper"), je = {
381
+ name: "HandlerWrapper",
382
+ components: { DraggableElement: ke },
383
+ props: {
384
+ horizontalPosition: { type: String },
385
+ verticalPosition: { type: String },
386
+ disabled: {
387
+ type: Boolean,
388
+ default: !1
389
+ }
390
+ },
391
+ computed: { classes: function() {
392
+ var e;
393
+ if (this.horizontalPosition || this.verticalPosition) {
394
+ var t, n = N(this.horizontalPosition, this.verticalPosition);
395
+ e = Ae((w(t = {}, n.classname, !0), w(t, "disabled", this.disabled), t));
396
+ } else e = Ae({ disabled: this.disabled });
397
+ return {
398
+ root: e,
399
+ draggable: Ae("draggable")
400
+ };
401
+ } },
402
+ emits: [
403
+ "leave",
404
+ "enter",
405
+ "drag",
406
+ "drag-end"
407
+ ]
408
+ };
409
+ je.render = function(e, t, n, s, c, l) {
410
+ var u = a("DraggableElement");
411
+ return o(), b("div", { class: l.classes.root }, [p(u, {
412
+ class: l.classes.draggable,
413
+ onDrag: t[1] ||= function(t) {
414
+ return e.$emit("drag", t);
415
+ },
416
+ onDragEnd: t[2] ||= function(t) {
417
+ return e.$emit("drag-end");
418
+ },
419
+ onLeave: t[3] ||= function(t) {
420
+ return e.$emit("leave");
421
+ },
422
+ onEnter: t[4] ||= function(t) {
423
+ return e.$emit("enter");
424
+ }
425
+ }, {
426
+ default: r((function() {
427
+ return [i(e.$slots, "default")];
428
+ })),
429
+ _: 3
430
+ }, 8, ["class"])], 2);
431
+ };
432
+ var Me = k("vue-line-wrapper"), Ne = {
433
+ name: "LineWrapper",
434
+ components: { DraggableElement: ke },
435
+ props: {
436
+ position: {
437
+ type: String,
438
+ required: !0
439
+ },
440
+ disabled: {
441
+ type: Boolean,
442
+ default: !1
443
+ }
444
+ },
445
+ computed: { classname: function() {
446
+ var e;
447
+ return Me((w(e = {}, this.position, !0), w(e, "disabled", this.disabled), e));
448
+ } },
449
+ emits: [
450
+ "leave",
451
+ "enter",
452
+ "drag",
453
+ "drag-end"
454
+ ]
455
+ };
456
+ Ne.render = function(e, t, n, s, c, l) {
457
+ var u = a("DraggableElement");
458
+ return o(), b(u, {
459
+ class: l.classname,
460
+ onDrag: t[1] ||= function(t) {
461
+ return e.$emit("drag", t);
462
+ },
463
+ onDragEnd: t[2] ||= function(t) {
464
+ return e.$emit("drag-end");
465
+ },
466
+ onLeave: t[3] ||= function(t) {
467
+ return e.$emit("leave");
468
+ },
469
+ onEnter: t[4] ||= function(t) {
470
+ return e.$emit("enter");
471
+ }
472
+ }, {
473
+ default: r((function() {
474
+ return [i(e.$slots, "default")];
475
+ })),
476
+ _: 3
477
+ }, 8, ["class"]);
478
+ };
479
+ var B = [
480
+ "left",
481
+ "right",
482
+ "top",
483
+ "bottom"
484
+ ], Pe = ["left", "right"], Fe = ["top", "bottom"], Ie = ["left", "top"], Le = [
485
+ "fill-area",
486
+ "fit-area",
487
+ "stencil",
488
+ "none"
489
+ ], Re = {
490
+ left: 0,
491
+ top: 0,
492
+ width: 0,
493
+ height: 0
494
+ };
495
+ function ze(e, t, n) {
496
+ return !(n ||= [
497
+ "width",
498
+ "height",
499
+ "left",
500
+ "top"
501
+ ]).some((function(n) {
502
+ return e[n] !== t[n];
503
+ }));
504
+ }
505
+ function V(e) {
506
+ return {
507
+ left: e.left,
508
+ top: e.top,
509
+ right: e.left + e.width,
510
+ bottom: e.top + e.height
511
+ };
512
+ }
513
+ function H(e, t) {
514
+ return {
515
+ left: e.left - t.left,
516
+ top: e.top - t.top
517
+ };
518
+ }
519
+ function U(e) {
520
+ return {
521
+ left: e.left + e.width / 2,
522
+ top: e.top + e.height / 2
523
+ };
524
+ }
525
+ function Be(e, t) {
526
+ var n = {
527
+ left: 0,
528
+ top: 0,
529
+ right: 0,
530
+ bottom: 0
531
+ };
532
+ return B.forEach((function(r) {
533
+ var i = t[r], a = V(e)[r];
534
+ n[r] = i !== void 0 && a !== void 0 ? r === "left" || r === "top" ? Math.max(0, i - a) : Math.max(0, a - i) : 0;
535
+ })), n;
536
+ }
537
+ function W(e, t) {
538
+ return {
539
+ left: e.left - t.left,
540
+ top: e.top - t.top,
541
+ width: e.width + t.left + t.right,
542
+ height: e.height + t.top + t.bottom
543
+ };
544
+ }
545
+ function Ve(e) {
546
+ return {
547
+ left: -e.left,
548
+ top: -e.top
549
+ };
550
+ }
551
+ function G(e, t) {
552
+ return M(M({}, e), {
553
+ left: e.left + t.left,
554
+ top: e.top + t.top
555
+ });
556
+ }
557
+ function K(e, t, n, r) {
558
+ if (t !== 1) {
559
+ if (n) {
560
+ var i = U(e);
561
+ return {
562
+ width: e.width * t,
563
+ height: e.height * t,
564
+ left: e.left + e.width * (1 - t) / 2 + (n.left - i.left) * (r || 1 - t),
565
+ top: e.top + e.height * (1 - t) / 2 + (n.top - i.top) * (r || 1 - t)
566
+ };
567
+ }
568
+ return {
569
+ width: e.width * t,
570
+ height: e.height * t,
571
+ left: e.left + e.width * (1 - t) / 2,
572
+ top: e.top + e.height * (1 - t) / 2
573
+ };
574
+ }
575
+ return e;
576
+ }
577
+ function q(e) {
578
+ return e.width / e.height;
579
+ }
580
+ function J(e, t) {
581
+ return Math.min(t.right !== void 0 && t.left !== void 0 ? (t.right - t.left) / e.width : 1 / 0, t.bottom !== void 0 && t.top !== void 0 ? (t.bottom - t.top) / e.height : 1 / 0);
582
+ }
583
+ function Y(e, t) {
584
+ var n = {
585
+ left: 0,
586
+ top: 0
587
+ }, r = Be(e, t);
588
+ return r.left && r.left > 0 ? n.left = r.left : r.right && r.right > 0 && (n.left = -r.right), r.top && r.top > 0 ? n.top = r.top : r.bottom && r.bottom > 0 && (n.top = -r.bottom), n;
589
+ }
590
+ function He(e, t) {
591
+ var n;
592
+ return t.minimum && e < t.minimum ? n = t.minimum : t.maximum && e > t.maximum && (n = t.maximum), n;
593
+ }
594
+ function Ue(e, t) {
595
+ var n = q(e), r = q(t);
596
+ return t.width < 1 / 0 && t.height < 1 / 0 ? n > r ? {
597
+ width: t.width,
598
+ height: t.width / n
599
+ } : {
600
+ width: t.height * n,
601
+ height: t.height
602
+ } : t.width < 1 / 0 ? {
603
+ width: t.width,
604
+ height: t.width / n
605
+ } : t.height < 1 / 0 ? {
606
+ width: t.height * n,
607
+ height: t.height
608
+ } : e;
609
+ }
610
+ function We(e, t) {
611
+ var n = t * Math.PI / 180;
612
+ return {
613
+ width: Math.abs(e.width * Math.cos(n)) + Math.abs(e.height * Math.sin(n)),
614
+ height: Math.abs(e.width * Math.sin(n)) + Math.abs(e.height * Math.cos(n))
615
+ };
616
+ }
617
+ function X(e, t) {
618
+ var n = t * Math.PI / 180;
619
+ return {
620
+ left: e.left * Math.cos(n) - e.top * Math.sin(n),
621
+ top: e.left * Math.sin(n) + e.top * Math.cos(n)
622
+ };
623
+ }
624
+ function Ge(e, t) {
625
+ var n = Be(Z(e, t), t);
626
+ return n.left + n.right + n.top + n.bottom ? n.left + n.right > n.top + n.bottom ? Math.min((e.width + n.left + n.right) / e.width, J(e, t)) : Math.min((e.height + n.top + n.bottom) / e.height, J(e, t)) : 1;
627
+ }
628
+ function Z(e, t, n) {
629
+ n === void 0 && (n = !1);
630
+ var r = Y(e, t);
631
+ return G(e, n ? Ve(r) : r);
632
+ }
633
+ function Ke(e) {
634
+ return {
635
+ width: e.right !== void 0 && e.left !== void 0 ? e.right - e.left : 1 / 0,
636
+ height: e.bottom !== void 0 && e.top !== void 0 ? e.bottom - e.top : 1 / 0
637
+ };
638
+ }
639
+ function qe(e, t) {
640
+ return M(M({}, e), {
641
+ minWidth: Math.min(t.width, e.minWidth),
642
+ minHeight: Math.min(t.height, e.minHeight),
643
+ maxWidth: Math.min(t.width, e.maxWidth),
644
+ maxHeight: Math.min(t.height, e.maxHeight)
645
+ });
646
+ }
647
+ function Je(e, t, n) {
648
+ n === void 0 && (n = !0);
649
+ var r = {};
650
+ return B.forEach((function(i) {
651
+ var a = e[i], o = t[i];
652
+ a !== void 0 && o !== void 0 ? r[i] = i === "left" || i === "top" ? n ? Math.max(a, o) : Math.min(a, o) : n ? Math.min(a, o) : Math.max(a, o) : o === void 0 ? a !== void 0 && (r[i] = a) : r[i] = o;
653
+ })), r;
654
+ }
655
+ function Ye(e, t) {
656
+ return Je(e, t, !0);
657
+ }
658
+ function Xe(e) {
659
+ var t = e.size, n = e.aspectRatio, r = e.ignoreMinimum, i = e.sizeRestrictions;
660
+ return !!((t.correctRatio || q(t) >= n.minimum && q(t) <= n.maximum) && t.height <= i.maxHeight && t.width <= i.maxWidth && t.width && t.height && (r || t.height >= i.minHeight && t.width >= i.minWidth));
661
+ }
662
+ function Ze(e, t) {
663
+ return (e.width - t.width) ** 2 + (e.height - t.height) ** 2;
664
+ }
665
+ function Q(e) {
666
+ var t = e.width, n = e.height, r = e.sizeRestrictions, i = {
667
+ minimum: e.aspectRatio && e.aspectRatio.minimum || 0,
668
+ maximum: e.aspectRatio && e.aspectRatio.maximum || 1 / 0
669
+ }, a = {
670
+ width: Math.max(r.minWidth, Math.min(r.maxWidth, t)),
671
+ height: Math.max(r.minHeight, Math.min(r.maxHeight, n))
672
+ };
673
+ function o(e, a) {
674
+ return a === void 0 && (a = !1), e.reduce((function(e, o) {
675
+ return Xe({
676
+ size: o,
677
+ aspectRatio: i,
678
+ sizeRestrictions: r,
679
+ ignoreMinimum: a
680
+ }) && (!e || Ze(o, {
681
+ width: t,
682
+ height: n
683
+ }) < Ze(e, {
684
+ width: t,
685
+ height: n
686
+ })) ? o : e;
687
+ }), null);
688
+ }
689
+ var s = [];
690
+ i && [i.minimum, i.maximum].forEach((function(e) {
691
+ e && s.push({
692
+ width: a.width,
693
+ height: a.width / e,
694
+ correctRatio: !0
695
+ }, {
696
+ width: a.height * e,
697
+ height: a.height,
698
+ correctRatio: !0
699
+ });
700
+ })), Xe({
701
+ size: a,
702
+ aspectRatio: i,
703
+ sizeRestrictions: r
704
+ }) && s.push(a);
705
+ var c = o(s) || o(s, !0);
706
+ return c && {
707
+ width: c.width,
708
+ height: c.height
709
+ };
710
+ }
711
+ function Qe(e) {
712
+ var t = e.event, n = e.coordinates, r = e.positionRestrictions, i = r === void 0 ? {} : r, a = G(n, t.directions);
713
+ return G(a, Y(a, i));
714
+ }
715
+ function $e(e) {
716
+ var t = e.coordinates, n = e.transform, r = e.imageSize, i = e.sizeRestrictions, a = e.positionRestrictions, o = e.aspectRatio, s = e.visibleArea, c = function(e, t) {
717
+ return Qe({
718
+ coordinates: e,
719
+ positionRestrictions: a,
720
+ event: new De({
721
+ left: t.left - e.left,
722
+ top: t.top - e.top
723
+ })
724
+ });
725
+ }, l = M({}, t);
726
+ return (Array.isArray(n) ? n : [n]).forEach((function(e) {
727
+ var t = {};
728
+ I((t = typeof e == "function" ? e({
729
+ coordinates: l,
730
+ imageSize: r,
731
+ visibleArea: s
732
+ }) : e).width) && I(t.height) || (l = function(e, t) {
733
+ return c(M(M(M({}, e), Q({
734
+ width: t.width,
735
+ height: t.height,
736
+ sizeRestrictions: i,
737
+ aspectRatio: o
738
+ })), {
739
+ left: 0,
740
+ top: 0
741
+ }), {
742
+ left: e.left,
743
+ top: e.top
744
+ });
745
+ }(l, M(M({}, l), t))), I(t.left) && I(t.top) || (l = c(l, M(M({}, l), t)));
746
+ })), l;
747
+ }
748
+ function et(e) {
749
+ var t = e.getAreaRestrictions, n = e.boundaries, r = e.coordinates, i = e.visibleArea, a = e.stencilSize, o = e.sizeRestrictions, s = e.positionRestrictions, c, l, u, d = M({}, r), f = M({}, i), p = M({}, a);
750
+ c = q(p), l = q(d), u === void 0 && (u = .001), (c === 0 || l === 0 ? Math.abs(l - c) < u : Math.abs(l / c) < 1 + u && Math.abs(l / c) > 1 - u) || (d = M(M({}, d), Q({
751
+ sizeRestrictions: o,
752
+ width: d.width,
753
+ height: d.height,
754
+ aspectRatio: {
755
+ minimum: q(p),
756
+ maximum: q(p)
757
+ }
758
+ })));
759
+ var m = Ge(f = K(f, d.width * n.width / (f.width * p.width)), t({
760
+ visibleArea: f,
761
+ type: "resize"
762
+ }));
763
+ return m !== 1 && (f = K(f, m), d = K(d, m)), f = Z(f = G(f, H(U(d), U(f))), t({
764
+ visibleArea: f,
765
+ type: "move"
766
+ })), {
767
+ coordinates: d = Z(d, Ye(V(f), s)),
768
+ visibleArea: f
769
+ };
770
+ }
771
+ function tt(e) {
772
+ var t = e.event, n = e.getAreaRestrictions, r = e.boundaries, i = e.coordinates, a = e.visibleArea, o = e.positionRestrictions, s = M({}, i), c = M({}, a);
773
+ if (i && a && t.type !== "manipulateImage") {
774
+ var l = {
775
+ width: 0,
776
+ height: 0
777
+ };
778
+ q(r) > q(s) ? (l.height = .8 * r.height, l.width = l.height * q(s)) : (l.width = .8 * r.width, l.height = l.width * q(s));
779
+ var u = Ge(c = K(c, s.width * r.width / (c.width * l.width)), n({
780
+ visibleArea: c,
781
+ type: "resize"
782
+ }));
783
+ c = K(c, u), u !== 1 && (l.height /= u, l.width /= u), c = Z(c = G(c, H(U(s), U(c))), n({
784
+ visibleArea: c,
785
+ type: "move"
786
+ })), s = Z(s, Ye(V(c), o));
787
+ }
788
+ return {
789
+ coordinates: s,
790
+ visibleArea: c
791
+ };
792
+ }
793
+ function nt(e) {
794
+ var t = e.event, n = e.coordinates, r = e.visibleArea, i = e.getAreaRestrictions, a = M({}, r), o = M({}, n);
795
+ if (t.type === "setCoordinates") {
796
+ var s = Math.max(0, o.width - a.width), c = Math.max(0, o.height - a.height);
797
+ s > c ? a = K(a, Math.min(o.width / a.width, J(a, i({
798
+ visibleArea: a,
799
+ type: "resize"
800
+ })))) : c > s && (a = K(a, Math.min(o.height / a.height, J(a, i({
801
+ visibleArea: a,
802
+ type: "resize"
803
+ }))))), a = Z(a = G(a, Ve(Y(o, V(a)))), i({
804
+ visibleArea: a,
805
+ type: "move"
806
+ }));
807
+ }
808
+ return {
809
+ visibleArea: a,
810
+ coordinates: o
811
+ };
812
+ }
813
+ function rt(e) {
814
+ var t = e.imageSize, n = e.visibleArea, r = e.coordinates, i = n || t;
815
+ return {
816
+ left: (n ? n.left : 0) + i.width / 2 - r.width / 2,
817
+ top: (n ? n.top : 0) + i.height / 2 - r.height / 2
818
+ };
819
+ }
820
+ function it(e) {
821
+ var t = e.imageSize, n = e.visibleArea, r = e.aspectRatio, i = e.sizeRestrictions, a = n || t, o = Math.min(r.maximum || 1 / 0, Math.max(r.minimum || 0, q(a))), s = a.width < a.height ? {
822
+ width: .8 * a.width,
823
+ height: .8 * a.width / o
824
+ } : {
825
+ height: .8 * a.height,
826
+ width: .8 * a.height * o
827
+ };
828
+ return Q(M(M({}, s), {
829
+ aspectRatio: r,
830
+ sizeRestrictions: i
831
+ }));
832
+ }
833
+ function at(e) {
834
+ var t, n, r = e.imageSize, i = e.visibleArea, a = e.boundaries, o = e.aspectRatio, s = e.sizeRestrictions, c = e.stencilSize, l = i || r;
835
+ return q(l) > q(a) ? n = (t = c.height * l.height / a.height) * q(c) : t = (n = c.width * l.width / a.width) / q(c), Q({
836
+ width: n,
837
+ height: t,
838
+ aspectRatio: o,
839
+ sizeRestrictions: s
840
+ });
841
+ }
842
+ function ot(e) {
843
+ var t = e.getAreaRestrictions, n = e.coordinates, r = e.imageSize, i = q(e.boundaries);
844
+ if (n) {
845
+ var a = {
846
+ height: Math.max(n.height, r.height),
847
+ width: Math.max(n.width, r.width)
848
+ }, o = Ue({
849
+ width: q(a) > i ? a.width : a.height * i,
850
+ height: q(a) > i ? a.width / i : a.height
851
+ }, Ke(t())), s = {
852
+ left: n.left + n.width / 2 - o.width / 2,
853
+ top: n.top + n.height / 2 - o.height / 2,
854
+ width: o.width,
855
+ height: o.height
856
+ }, c = Be(n, V(M({
857
+ left: 0,
858
+ top: 0
859
+ }, r))), l = {};
860
+ return !c.left && !c.right && s.width <= r.width && (l.left = 0, l.right = r.width), !c.top && !c.bottom && s.height <= r.height && (l.top = 0, l.bottom = r.height), Z(s, l);
861
+ }
862
+ var u = q(r);
863
+ return o = {
864
+ height: u > i ? r.height : r.width / i,
865
+ width: u > i ? r.height * i : r.width
866
+ }, {
867
+ left: r.width / 2 - o.width / 2,
868
+ top: r.height / 2 - o.height / 2,
869
+ width: o.width,
870
+ height: o.height
871
+ };
872
+ }
873
+ function st(e, t) {
874
+ return Je(e, V(t));
875
+ }
876
+ function ct(e) {
877
+ var t = e.event, n = e.coordinates, r = e.visibleArea, i = e.sizeRestrictions, a = e.getAreaRestrictions, o = e.positionRestrictions, s = e.adjustStencil, c = t.scale, l = t.move, u = M({}, r), d = M({}, n), f = 1, p = 1, m = c.factor && Math.abs(c.factor - 1) > .001;
878
+ u = G(u, {
879
+ left: l.left || 0,
880
+ top: l.top || 0
881
+ });
882
+ var h = {
883
+ stencil: {
884
+ minimum: Math.max(i.minWidth ? i.minWidth / d.width : 0, i.minHeight ? i.minHeight / d.height : 0),
885
+ maximum: Math.min(i.maxWidth ? i.maxWidth / d.width : 1 / 0, i.maxHeight ? i.maxHeight / d.height : 1 / 0, J(d, o))
886
+ },
887
+ area: { maximum: J(u, a({
888
+ visibleArea: u,
889
+ type: "resize"
890
+ })) }
891
+ };
892
+ c.factor && m && (c.factor < 1 ? (p = Math.max(c.factor, h.stencil.minimum)) > 1 && (p = 1) : c.factor > 1 && (p = Math.min(c.factor, Math.min(h.area.maximum, h.stencil.maximum))) < 1 && (p = 1)), p && (u = K(u, p, c.center));
893
+ var g = n.left - r.left, _ = r.width + r.left - (n.width + n.left), v = n.top - r.top, y = r.height + r.top - (n.height + n.top);
894
+ return u = Z(u = G(u, Y(u, {
895
+ left: o.left === void 0 ? void 0 : o.left - g * p,
896
+ top: o.top === void 0 ? void 0 : o.top - v * p,
897
+ bottom: o.bottom === void 0 ? void 0 : o.bottom + y * p,
898
+ right: o.right === void 0 ? void 0 : o.right + _ * p
899
+ })), a({
900
+ visibleArea: u,
901
+ type: "move"
902
+ })), d.width *= p, d.height *= p, d.left = u.left + g * p, d.top = u.top + v * p, d = Z(d, Ye(V(u), o)), c.factor && m && s && (c.factor > 1 ? f = Math.min(h.area.maximum, c.factor) / p : c.factor < 1 && (f = Math.max(d.height / u.height, d.width / u.width, c.factor / p)), f !== 1 && (u = G(u = Z(u = K(u, f, c.factor > 1 ? c.center : U(d)), a({
903
+ visibleArea: u,
904
+ type: "move"
905
+ })), Ve(Y(d, V(u)))))), {
906
+ coordinates: d,
907
+ visibleArea: u
908
+ };
909
+ }
910
+ function lt(e) {
911
+ var t = e.aspectRatio, n = e.getAreaRestrictions, r = e.coordinates, i = e.visibleArea, a = e.sizeRestrictions, o = e.positionRestrictions, s = e.imageSize, c = e.previousImageSize, l = e.angle, u = M({}, r), d = M({}, i), f = X(U(M({
912
+ left: 0,
913
+ top: 0
914
+ }, c)), l);
915
+ return (u = M(M({}, Q({
916
+ sizeRestrictions: a,
917
+ aspectRatio: t,
918
+ width: u.width,
919
+ height: u.height
920
+ })), X(U(u), l))).left -= f.left - s.width / 2 + u.width / 2, u.top -= f.top - s.height / 2 + u.height / 2, d = K(d, Ge(d, n({
921
+ visibleArea: d,
922
+ type: "resize"
923
+ }))), {
924
+ coordinates: u = Z(u, o),
925
+ visibleArea: d = Z(d = G(d, H(U(u), U(r))), n({
926
+ visibleArea: d,
927
+ type: "move"
928
+ }))
929
+ };
930
+ }
931
+ function ut(e) {
932
+ var t = e.flip, n = e.previousFlip, r = e.rotate, i = e.getAreaRestrictions, a = e.coordinates, o = e.visibleArea, s = e.imageSize, c = M({}, a), l = M({}, o), u = n.horizontal !== t.horizontal, d = n.vertical !== t.vertical;
933
+ if (u || d) {
934
+ var f = X({
935
+ left: s.width / 2,
936
+ top: s.height / 2
937
+ }, -r), p = X(U(c), -r), m = X({
938
+ left: u ? f.left - (p.left - f.left) : p.left,
939
+ top: d ? f.top - (p.top - f.top) : p.top
940
+ }, r);
941
+ c = G(c, H(m, U(c))), p = X(U(l), -r), l = Z(l = G(l, H(m = X({
942
+ left: u ? f.left - (p.left - f.left) : p.left,
943
+ top: d ? f.top - (p.top - f.top) : p.top
944
+ }, r), U(l))), i({
945
+ visibleArea: l,
946
+ type: "move"
947
+ }));
948
+ }
949
+ return {
950
+ coordinates: c,
951
+ visibleArea: l
952
+ };
953
+ }
954
+ function dt(e) {
955
+ var t = e.directions, n = e.coordinates, r = e.positionRestrictions, i = r === void 0 ? {} : r, a = e.sizeRestrictions, o = e.preserveRatio, s = e.compensate, c = M({}, t), l = W(n, c).width, u = W(n, c).height;
956
+ l < 0 && (c.left < 0 && c.right < 0 ? (c.left = -(n.width - a.minWidth) / (c.left / c.right), c.right = -(n.width - a.minWidth) / (c.right / c.left)) : c.left < 0 ? c.left = -(n.width - a.minWidth) : c.right < 0 && (c.right = -(n.width - a.minWidth))), u < 0 && (c.top < 0 && c.bottom < 0 ? (c.top = -(n.height - a.minHeight) / (c.top / c.bottom), c.bottom = -(n.height - a.minHeight) / (c.bottom / c.top)) : c.top < 0 ? c.top = -(n.height - a.minHeight) : c.bottom < 0 && (c.bottom = -(n.height - a.minHeight)));
957
+ var d = Be(W(n, c), i);
958
+ s && (d.left && d.left > 0 && d.right === 0 ? (c.right += d.left, c.left -= d.left) : d.right && d.right > 0 && d.left === 0 && (c.left += d.right, c.right -= d.right), d.top && d.top > 0 && d.bottom === 0 ? (c.bottom += d.top, c.top -= d.top) : d.bottom && d.bottom > 0 && d.top === 0 && (c.top += d.bottom, c.bottom -= d.bottom), d = Be(W(n, c), i));
959
+ var f = {
960
+ width: 1 / 0,
961
+ height: 1 / 0,
962
+ left: 1 / 0,
963
+ right: 1 / 0,
964
+ top: 1 / 0,
965
+ bottom: 1 / 0
966
+ };
967
+ if (B.forEach((function(e) {
968
+ var t = d[e];
969
+ t && c[e] && (f[e] = Math.max(0, 1 - t / c[e]));
970
+ })), o) {
971
+ var p = Math.min.apply(null, B.map((function(e) {
972
+ return f[e];
973
+ })));
974
+ p !== 1 / 0 && B.forEach((function(e) {
975
+ c[e] *= p;
976
+ }));
977
+ } else B.forEach((function(e) {
978
+ f[e] !== 1 / 0 && (c[e] *= f[e]);
979
+ }));
980
+ if (l = W(n, c).width, u = W(n, c).height, c.right + c.left && (l > a.maxWidth ? f.width = (a.maxWidth - n.width) / (c.right + c.left) : l < a.minWidth && (f.width = (a.minWidth - n.width) / (c.right + c.left))), c.bottom + c.top && (u > a.maxHeight ? f.height = (a.maxHeight - n.height) / (c.bottom + c.top) : u < a.minHeight && (f.height = (a.minHeight - n.height) / (c.bottom + c.top))), o) {
981
+ var m = Math.min(f.width, f.height);
982
+ m !== 1 / 0 && B.forEach((function(e) {
983
+ c[e] *= m;
984
+ }));
985
+ } else f.width !== 1 / 0 && Pe.forEach((function(e) {
986
+ c[e] *= f.width;
987
+ })), f.height !== 1 / 0 && Fe.forEach((function(e) {
988
+ c[e] *= f.height;
989
+ }));
990
+ return c;
991
+ }
992
+ function ft(e, t, n) {
993
+ return t == 0 && n == 0 ? e / 2 : t == 0 ? 0 : n == 0 ? e : e * Math.abs(t / (t + n));
994
+ }
995
+ var pt = k("vue-simple-handler"), mt = k("vue-simple-handler-wrapper"), ht = {
996
+ name: "SimpleHandler",
997
+ components: { HandlerWrapper: je },
998
+ props: {
999
+ defaultClass: { type: String },
1000
+ hoverClass: { type: String },
1001
+ wrapperClass: { type: String },
1002
+ horizontalPosition: { type: String },
1003
+ verticalPosition: { type: String },
1004
+ disabled: {
1005
+ type: Boolean,
1006
+ default: !1
1007
+ }
1008
+ },
1009
+ data: function() {
1010
+ return { hover: !1 };
1011
+ },
1012
+ computed: { classes: function() {
1013
+ var e, t = (w(e = {}, this.horizontalPosition, !!this.horizontalPosition), w(e, this.verticalPosition, !!this.verticalPosition), w(e, `${this.horizontalPosition}-${this.verticalPosition}`, !!(this.verticalPosition && this.horizontalPosition)), w(e, "hover", this.hover), e);
1014
+ return {
1015
+ default: O(pt(t), this.defaultClass, this.hover && this.hoverClass),
1016
+ wrapper: O(mt(t), this.wrapperClass)
1017
+ };
1018
+ } },
1019
+ methods: {
1020
+ onDrag: function(e) {
1021
+ this.$emit("drag", e);
1022
+ },
1023
+ onEnter: function() {
1024
+ this.hover = !0;
1025
+ },
1026
+ onLeave: function() {
1027
+ this.hover = !1;
1028
+ },
1029
+ onDragEnd: function() {
1030
+ this.$emit("drag-end");
1031
+ }
1032
+ },
1033
+ emits: ["drag", "drag-end"]
1034
+ };
1035
+ ht.render = function(e, t, n, i, s, c) {
1036
+ var l = a("HandlerWrapper");
1037
+ return o(), b(l, {
1038
+ class: c.classes.wrapper,
1039
+ "vertical-position": n.verticalPosition,
1040
+ "horizontal-position": n.horizontalPosition,
1041
+ disabled: n.disabled,
1042
+ onDrag: c.onDrag,
1043
+ onDragEnd: c.onDragEnd,
1044
+ onEnter: c.onEnter,
1045
+ onLeave: c.onLeave
1046
+ }, {
1047
+ default: r((function() {
1048
+ return [p("div", { class: c.classes.default }, null, 2)];
1049
+ })),
1050
+ _: 1
1051
+ }, 8, [
1052
+ "class",
1053
+ "vertical-position",
1054
+ "horizontal-position",
1055
+ "disabled",
1056
+ "onDrag",
1057
+ "onDragEnd",
1058
+ "onEnter",
1059
+ "onLeave"
1060
+ ]);
1061
+ };
1062
+ var gt = k("vue-simple-line"), _t = k("vue-simple-line-wrapper"), vt = {
1063
+ name: "SimpleLine",
1064
+ components: { LineWrapper: Ne },
1065
+ props: {
1066
+ defaultClass: { type: String },
1067
+ hoverClass: { type: String },
1068
+ wrapperClass: { type: String },
1069
+ position: { type: String },
1070
+ disabled: {
1071
+ type: Boolean,
1072
+ default: !1
1073
+ }
1074
+ },
1075
+ data: function() {
1076
+ return { hover: !1 };
1077
+ },
1078
+ computed: { classes: function() {
1079
+ return {
1080
+ root: O(gt(w({}, this.position, !0)), this.defaultClass, this.hover && this.hoverClass),
1081
+ wrapper: O(_t(w({}, this.position, !0)), this.wrapperClass)
1082
+ };
1083
+ } },
1084
+ methods: {
1085
+ onDrag: function(e) {
1086
+ this.$emit("drag", e);
1087
+ },
1088
+ onEnter: function() {
1089
+ this.hover = !0;
1090
+ },
1091
+ onLeave: function() {
1092
+ this.hover = !1;
1093
+ },
1094
+ onDragEnd: function() {
1095
+ this.$emit("drag-end");
1096
+ }
1097
+ },
1098
+ emits: ["drag", "drag-end"]
1099
+ };
1100
+ vt.render = function(e, t, n, i, s, c) {
1101
+ var l = a("LineWrapper");
1102
+ return o(), b(l, {
1103
+ class: c.classes.wrapper,
1104
+ position: n.position,
1105
+ disabled: n.disabled,
1106
+ onDrag: c.onDrag,
1107
+ onDragEnd: c.onDragEnd,
1108
+ onEnter: c.onEnter,
1109
+ onLeave: c.onLeave
1110
+ }, {
1111
+ default: r((function() {
1112
+ return [p("div", { class: c.classes.root }, null, 2)];
1113
+ })),
1114
+ _: 1
1115
+ }, 8, [
1116
+ "class",
1117
+ "position",
1118
+ "disabled",
1119
+ "onDrag",
1120
+ "onDragEnd",
1121
+ "onEnter",
1122
+ "onLeave"
1123
+ ]);
1124
+ };
1125
+ var yt = k("vue-bounding-box"), bt = [
1126
+ "east",
1127
+ "west",
1128
+ null
1129
+ ], xt = [
1130
+ "south",
1131
+ "north",
1132
+ null
1133
+ ], St = {
1134
+ name: "BoundingBox",
1135
+ props: {
1136
+ width: { type: Number },
1137
+ height: { type: Number },
1138
+ transitions: { type: Object },
1139
+ handlers: {
1140
+ type: Object,
1141
+ default: function() {
1142
+ return {
1143
+ eastNorth: !0,
1144
+ north: !0,
1145
+ westNorth: !0,
1146
+ west: !0,
1147
+ westSouth: !0,
1148
+ south: !0,
1149
+ eastSouth: !0,
1150
+ east: !0
1151
+ };
1152
+ }
1153
+ },
1154
+ handlersComponent: {
1155
+ type: [Object, String],
1156
+ default: function() {
1157
+ return ht;
1158
+ }
1159
+ },
1160
+ handlersClasses: {
1161
+ type: Object,
1162
+ default: function() {
1163
+ return {};
1164
+ }
1165
+ },
1166
+ handlersWrappersClasses: {
1167
+ type: Object,
1168
+ default: function() {
1169
+ return {};
1170
+ }
1171
+ },
1172
+ lines: {
1173
+ type: Object,
1174
+ default: function() {
1175
+ return {
1176
+ west: !0,
1177
+ north: !0,
1178
+ east: !0,
1179
+ south: !0
1180
+ };
1181
+ }
1182
+ },
1183
+ linesComponent: {
1184
+ type: [Object, String],
1185
+ default: function() {
1186
+ return vt;
1187
+ }
1188
+ },
1189
+ linesClasses: {
1190
+ type: Object,
1191
+ default: function() {
1192
+ return {};
1193
+ }
1194
+ },
1195
+ linesWrappersClasses: {
1196
+ type: Object,
1197
+ default: function() {
1198
+ return {};
1199
+ }
1200
+ },
1201
+ resizable: {
1202
+ type: Boolean,
1203
+ default: !0
1204
+ }
1205
+ },
1206
+ data: function() {
1207
+ var e = [];
1208
+ return bt.forEach((function(t) {
1209
+ xt.forEach((function(n) {
1210
+ if (t !== n) {
1211
+ var r = N(t, n);
1212
+ e.push({
1213
+ name: r.name,
1214
+ classname: r.classname,
1215
+ verticalDirection: n,
1216
+ horizontalDirection: t
1217
+ });
1218
+ }
1219
+ }));
1220
+ })), { points: e };
1221
+ },
1222
+ computed: {
1223
+ style: function() {
1224
+ var e = {};
1225
+ return this.width && this.height && (e.width = `${this.width}px`, e.height = `${this.height}px`, this.transitions && this.transitions.enabled && (e.transition = `${this.transitions.time}ms ${this.transitions.timingFunction}`)), e;
1226
+ },
1227
+ classes: function() {
1228
+ var e = this.handlersClasses, t = this.handlersWrappersClasses, n = this.linesClasses, r = this.linesWrappersClasses;
1229
+ return {
1230
+ root: yt(),
1231
+ handlers: e,
1232
+ handlersWrappers: t,
1233
+ lines: n,
1234
+ linesWrappers: r
1235
+ };
1236
+ },
1237
+ lineNodes: function() {
1238
+ var e = this, t = [];
1239
+ return this.points.forEach((function(n) {
1240
+ n.horizontalDirection && n.verticalDirection || !e.lines[n.name] || t.push({
1241
+ name: n.name,
1242
+ component: e.linesComponent,
1243
+ class: O(e.classes.lines.default, e.classes.lines[n.name], !e.resizable && e.classes.lines.disabled),
1244
+ wrapperClass: O(e.classes.linesWrappers.default, e.classes.linesWrappers[n.name], !e.resizable && e.classes.linesWrappers.disabled),
1245
+ hoverClass: e.classes.lines.hover,
1246
+ verticalDirection: n.verticalDirection,
1247
+ horizontalDirection: n.horizontalDirection,
1248
+ disabled: !e.resizable
1249
+ });
1250
+ })), t;
1251
+ },
1252
+ handlerNodes: function() {
1253
+ var e = this, t = [], n = this.width, r = this.height;
1254
+ return this.points.forEach((function(i) {
1255
+ if (e.handlers[i.name]) {
1256
+ var a = {
1257
+ name: i.name,
1258
+ component: e.handlersComponent,
1259
+ class: O(e.classes.handlers.default, e.classes.handlers[i.name]),
1260
+ wrapperClass: O(e.classes.handlersWrappers.default, e.classes.handlersWrappers[i.name]),
1261
+ hoverClass: e.classes.handlers.hover,
1262
+ verticalDirection: i.verticalDirection,
1263
+ horizontalDirection: i.horizontalDirection,
1264
+ disabled: !e.resizable
1265
+ };
1266
+ if (n && r) {
1267
+ var o = i.horizontalDirection, s = i.verticalDirection, c = o === "east" ? n : o === "west" ? 0 : n / 2, l = s === "south" ? r : s === "north" ? 0 : r / 2;
1268
+ a.wrapperClass = yt("handler"), a.wrapperStyle = { transform: `translate(${c}px, ${l}px)` }, e.transitions && e.transitions.enabled && (a.wrapperStyle.transition = `${e.transitions.time}ms ${e.transitions.timingFunction}`);
1269
+ } else a.wrapperClass = yt("handler", w({}, i.classname, !0));
1270
+ t.push(a);
1271
+ }
1272
+ })), t;
1273
+ }
1274
+ },
1275
+ beforeMount: function() {
1276
+ window.addEventListener("mouseup", this.onMouseUp, { passive: !1 }), window.addEventListener("mousemove", this.onMouseMove, { passive: !1 }), window.addEventListener("touchmove", this.onTouchMove, { passive: !1 }), window.addEventListener("touchend", this.onTouchEnd, { passive: !1 });
1277
+ },
1278
+ beforeUnmount: function() {
1279
+ window.removeEventListener("mouseup", this.onMouseUp), window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("touchmove", this.onTouchMove), window.removeEventListener("touchend", this.onTouchEnd);
1280
+ },
1281
+ mounted: function() {
1282
+ this.touches = [];
1283
+ },
1284
+ methods: {
1285
+ onEnd: function() {
1286
+ this.$emit("resize-end");
1287
+ },
1288
+ onHandlerDrag: function(e, t, n) {
1289
+ var r, i = e.shift(), a = i.left, o = i.top, s = {
1290
+ left: 0,
1291
+ right: 0,
1292
+ top: 0,
1293
+ bottom: 0
1294
+ };
1295
+ t === "west" ? s.left -= a : t === "east" && (s.right += a), n === "north" ? s.top -= o : n === "south" && (s.bottom += o), !n && t ? r = "width" : n && !t && (r = "height"), this.resizable && this.$emit("resize", new Ee(s, {
1296
+ allowedDirections: {
1297
+ left: t === "west" || !t,
1298
+ right: t === "east" || !t,
1299
+ bottom: n === "south" || !n,
1300
+ top: n === "north" || !n
1301
+ },
1302
+ preserveAspectRatio: e.nativeEvent && e.nativeEvent.shiftKey,
1303
+ respectDirection: r
1304
+ }));
1305
+ }
1306
+ },
1307
+ emits: ["resize", "resize-end"]
1308
+ };
1309
+ St.render = function(e, t, r, a, s, c) {
1310
+ return o(), b("div", {
1311
+ ref: "box",
1312
+ class: c.classes.root,
1313
+ style: c.style
1314
+ }, [
1315
+ i(e.$slots, "default"),
1316
+ p("div", null, [(o(!0), b(ie, null, n(c.lineNodes, (function(e) {
1317
+ return o(), b(l(e.component), {
1318
+ key: e.name,
1319
+ "default-class": e.class,
1320
+ "hover-class": e.hoverClass,
1321
+ "wrapper-class": e.wrapperClass,
1322
+ position: e.name,
1323
+ disabled: e.disabled,
1324
+ onDrag: function(t) {
1325
+ return c.onHandlerDrag(t, e.horizontalDirection, e.verticalDirection);
1326
+ },
1327
+ onDragEnd: t[1] ||= function(e) {
1328
+ return c.onEnd();
1329
+ }
1330
+ }, null, 8, [
1331
+ "default-class",
1332
+ "hover-class",
1333
+ "wrapper-class",
1334
+ "position",
1335
+ "disabled",
1336
+ "onDrag"
1337
+ ]);
1338
+ })), 128))]),
1339
+ (o(!0), b(ie, null, n(c.handlerNodes, (function(e) {
1340
+ return o(), b("div", {
1341
+ key: e.name,
1342
+ style: e.wrapperStyle,
1343
+ class: e.wrapperClass
1344
+ }, [(o(), b(l(e.component), {
1345
+ "default-class": e.class,
1346
+ "hover-class": e.hoverClass,
1347
+ "wrapper-class": e.wrapperClass,
1348
+ "horizontal-position": e.horizontalDirection,
1349
+ "vertical-position": e.verticalDirection,
1350
+ disabled: e.disabled,
1351
+ onDrag: function(t) {
1352
+ return c.onHandlerDrag(t, e.horizontalDirection, e.verticalDirection);
1353
+ },
1354
+ onDragEnd: t[2] ||= function(e) {
1355
+ return c.onEnd();
1356
+ }
1357
+ }, null, 8, [
1358
+ "default-class",
1359
+ "hover-class",
1360
+ "wrapper-class",
1361
+ "horizontal-position",
1362
+ "vertical-position",
1363
+ "disabled",
1364
+ "onDrag"
1365
+ ]))], 6);
1366
+ })), 128))
1367
+ ], 6);
1368
+ };
1369
+ var Ct = k("vue-draggable-area"), wt = {
1370
+ name: "DraggableArea",
1371
+ props: {
1372
+ movable: {
1373
+ type: Boolean,
1374
+ default: !0
1375
+ },
1376
+ activationDistance: {
1377
+ type: Number,
1378
+ default: 20
1379
+ }
1380
+ },
1381
+ computed: { classnames: function() {
1382
+ return { default: Ct() };
1383
+ } },
1384
+ beforeMount: function() {
1385
+ window.addEventListener("mouseup", this.onMouseUp, { passive: !1 }), window.addEventListener("mousemove", this.onMouseMove, { passive: !1 }), window.addEventListener("touchmove", this.onTouchMove, { passive: !1 }), window.addEventListener("touchend", this.onTouchEnd, { passive: !1 });
1386
+ },
1387
+ beforeUnmount: function() {
1388
+ window.removeEventListener("mouseup", this.onMouseUp), window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("touchmove", this.onTouchMove), window.removeEventListener("touchend", this.onTouchEnd);
1389
+ },
1390
+ mounted: function() {
1391
+ this.touches = [], this.touchStarted = !1;
1392
+ },
1393
+ methods: {
1394
+ onTouchStart: function(e) {
1395
+ if (e.cancelable) {
1396
+ var t = this.movable && e.touches.length === 1;
1397
+ t && (this.touches = T(e.touches)), (this.touchStarted || t) && (e.preventDefault(), e.stopPropagation());
1398
+ }
1399
+ },
1400
+ onTouchEnd: function() {
1401
+ this.touchStarted = !1, this.processEnd();
1402
+ },
1403
+ onTouchMove: function(e) {
1404
+ this.touches.length >= 1 && (this.touchStarted ? (this.processMove(e, e.touches), e.preventDefault(), e.stopPropagation()) : Te({
1405
+ x: this.touches[0].clientX,
1406
+ y: this.touches[0].clientY
1407
+ }, {
1408
+ x: e.touches[0].clientX,
1409
+ y: e.touches[0].clientY
1410
+ }) > this.activationDistance && (this.initAnchor({
1411
+ clientX: e.touches[0].clientX,
1412
+ clientY: e.touches[0].clientY
1413
+ }), this.touchStarted = !0));
1414
+ },
1415
+ onMouseDown: function(e) {
1416
+ if (this.movable && e.button === 0) {
1417
+ var t = {
1418
+ fake: !0,
1419
+ clientX: e.clientX,
1420
+ clientY: e.clientY
1421
+ };
1422
+ this.touches = [t], this.initAnchor(t), e.stopPropagation();
1423
+ }
1424
+ },
1425
+ onMouseMove: function(e) {
1426
+ this.touches.length && (this.processMove(e, [{
1427
+ fake: !0,
1428
+ clientX: e.clientX,
1429
+ clientY: e.clientY
1430
+ }]), e.preventDefault && e.cancelable && e.preventDefault(), e.stopPropagation());
1431
+ },
1432
+ onMouseUp: function() {
1433
+ this.processEnd();
1434
+ },
1435
+ initAnchor: function(e) {
1436
+ var t = this.$refs.container.getBoundingClientRect(), n = t.left, r = t.top;
1437
+ this.anchor = {
1438
+ x: e.clientX - n,
1439
+ y: e.clientY - r
1440
+ };
1441
+ },
1442
+ processMove: function(e, t) {
1443
+ var n = T(t);
1444
+ if (this.touches.length) {
1445
+ var r = this.$refs.container.getBoundingClientRect(), i = r.left, a = r.top;
1446
+ this.touches.length === 1 && n.length === 1 && this.$emit("move", new De({
1447
+ left: n[0].clientX - (i + this.anchor.x),
1448
+ top: n[0].clientY - (a + this.anchor.y)
1449
+ }));
1450
+ }
1451
+ },
1452
+ processEnd: function() {
1453
+ this.touches.length && this.$emit("move-end"), this.touches = [];
1454
+ }
1455
+ },
1456
+ emits: ["move", "move-end"]
1457
+ };
1458
+ wt.render = function(e, t, n, r, a, s) {
1459
+ return o(), b("div", {
1460
+ ref: "container",
1461
+ onTouchstart: t[1] ||= function() {
1462
+ return s.onTouchStart && s.onTouchStart.apply(s, arguments);
1463
+ },
1464
+ onMousedown: t[2] ||= function() {
1465
+ return s.onMouseDown && s.onMouseDown.apply(s, arguments);
1466
+ }
1467
+ }, [i(e.$slots, "default")], 544);
1468
+ };
1469
+ function Tt(e) {
1470
+ return {
1471
+ rotate: e.rotate || 0,
1472
+ flip: {
1473
+ horizontal: e?.flip?.horizontal || !1,
1474
+ vertical: e?.flip?.vertical || !1
1475
+ }
1476
+ };
1477
+ }
1478
+ function Et(e) {
1479
+ return new Promise((function(t, n) {
1480
+ try {
1481
+ if (e) {
1482
+ if (/^data:/i.test(e)) t(function(e) {
1483
+ e = e.replace(/^data:([^;]+);base64,/gim, "");
1484
+ for (var t = atob(e), n = t.length, r = new ArrayBuffer(n), i = new Uint8Array(r), a = 0; a < n; a++) i[a] = t.charCodeAt(a);
1485
+ return r;
1486
+ }(e));
1487
+ else if (/^blob:/i.test(e)) {
1488
+ var r = new FileReader();
1489
+ r.onload = function(e) {
1490
+ t(e.target.result);
1491
+ }, a = e, o = function(e) {
1492
+ r.readAsArrayBuffer(e);
1493
+ }, (s = new XMLHttpRequest()).open("GET", a, !0), s.responseType = "blob", s.onload = function() {
1494
+ this.status != 200 && this.status !== 0 || o(this.response);
1495
+ }, s.send();
1496
+ } else {
1497
+ var i = new XMLHttpRequest();
1498
+ i.onreadystatechange = function() {
1499
+ i.readyState === 4 && (i.status === 200 || i.status === 0 ? t(i.response) : n("Warning: could not load an image to parse its orientation"), i = null);
1500
+ }, i.onprogress = function() {
1501
+ i.getResponseHeader("content-type") !== "image/jpeg" && i.abort();
1502
+ }, i.withCredentials = !1, i.open("GET", e, !0), i.responseType = "arraybuffer", i.send(null);
1503
+ }
1504
+ } else n("Error: the image is empty");
1505
+ } catch (e) {
1506
+ n(e);
1507
+ }
1508
+ var a, o, s;
1509
+ }));
1510
+ }
1511
+ function Dt(e) {
1512
+ var t = e.rotate, n = e.flip, r = e.scaleX, i = e.scaleY, a = "";
1513
+ return a += " rotate(" + t + "deg) ", a += " scaleX(" + r * (n.horizontal ? -1 : 1) + ") ", a += " scaleY(" + i * (n.vertical ? -1 : 1) + ") ";
1514
+ }
1515
+ function Ot(e) {
1516
+ try {
1517
+ var t, n = new DataView(e), r = void 0, i = void 0, a = void 0, o = void 0;
1518
+ if (n.getUint8(0) === 255 && n.getUint8(1) === 216) for (var s = n.byteLength, c = 2; c + 1 < s;) {
1519
+ if (n.getUint8(c) === 255 && n.getUint8(c + 1) === 225) {
1520
+ a = c;
1521
+ break;
1522
+ }
1523
+ c++;
1524
+ }
1525
+ if (a && (r = a + 10, function(e, t, n) {
1526
+ var r, i = "";
1527
+ for (r = t, n += t; r < n; r++) i += String.fromCharCode(e.getUint8(r));
1528
+ return i;
1529
+ }(n, a + 4, 4) === "Exif")) {
1530
+ var l = n.getUint16(r);
1531
+ if (((i = l === 18761) || l === 19789) && n.getUint16(r + 2, i) === 42) {
1532
+ var u = n.getUint32(r + 4, i);
1533
+ u >= 8 && (o = r + u);
1534
+ }
1535
+ }
1536
+ if (o) {
1537
+ for (var d = n.getUint16(o, i), f = 0; f < d; f++) if (c = o + 12 * f + 2, n.getUint16(c, i) === 274) {
1538
+ c += 8, t = n.getUint16(c, i), n.setUint16(c, 1, i);
1539
+ break;
1540
+ }
1541
+ }
1542
+ return t;
1543
+ } catch {
1544
+ return null;
1545
+ }
1546
+ }
1547
+ function kt(e, t) {
1548
+ var n = t.getBoundingClientRect(), r = n.left, i = n.top, a = {
1549
+ left: 0,
1550
+ top: 0
1551
+ }, o = 0;
1552
+ return e.forEach((function(t) {
1553
+ a.left += (t.clientX - r) / e.length, a.top += (t.clientY - i) / e.length;
1554
+ })), e.forEach((function(e) {
1555
+ o += Te({
1556
+ x: a.left,
1557
+ y: a.top
1558
+ }, {
1559
+ x: e.clientX - r,
1560
+ y: e.clientY - i
1561
+ });
1562
+ })), {
1563
+ centerMass: a,
1564
+ spread: o,
1565
+ count: e.length
1566
+ };
1567
+ }
1568
+ var At = {
1569
+ props: {
1570
+ touchMove: {
1571
+ type: Boolean,
1572
+ required: !0
1573
+ },
1574
+ mouseMove: {
1575
+ type: Boolean,
1576
+ required: !0
1577
+ },
1578
+ touchResize: {
1579
+ type: Boolean,
1580
+ required: !0
1581
+ },
1582
+ wheelResize: {
1583
+ type: [Boolean, Object],
1584
+ required: !0
1585
+ },
1586
+ eventsFilter: {
1587
+ type: Function,
1588
+ required: !1
1589
+ }
1590
+ },
1591
+ beforeMount: function() {
1592
+ window.addEventListener("mouseup", this.onMouseUp, { passive: !1 }), window.addEventListener("mousemove", this.onMouseMove, { passive: !1 }), window.addEventListener("touchmove", this.onTouchMove, { passive: !1 }), window.addEventListener("touchend", this.onTouchEnd, { passive: !1 });
1593
+ },
1594
+ beforeUnmount: function() {
1595
+ window.removeEventListener("mouseup", this.onMouseUp), window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("touchmove", this.onTouchMove), window.removeEventListener("touchend", this.onTouchEnd);
1596
+ },
1597
+ created: function() {
1598
+ this.transforming = !1, this.debouncedProcessEnd = j(this.processEnd), this.touches = [];
1599
+ },
1600
+ methods: {
1601
+ processMove: function(e, t) {
1602
+ if (this.touches.length) {
1603
+ if (this.touches.length === 1 && t.length === 1) this.$emit("move", new z({
1604
+ left: this.touches[0].clientX - t[0].clientX,
1605
+ top: this.touches[0].clientY - t[0].clientY
1606
+ }));
1607
+ else if (this.touches.length > 1 && this.touchResize) {
1608
+ var n = kt(t, this.$refs.container), r = this.oldGeometricProperties;
1609
+ r.count === n.count && r.count > 1 && this.$emit("resize", new z({
1610
+ left: r.centerMass.left - n.centerMass.left,
1611
+ top: r.centerMass.top - n.centerMass.top
1612
+ }, {
1613
+ factor: r.spread / n.spread,
1614
+ center: n.centerMass
1615
+ })), this.oldGeometricProperties = n;
1616
+ }
1617
+ this.touches = t;
1618
+ }
1619
+ },
1620
+ processEnd: function() {
1621
+ this.transforming && (this.transforming = !1, this.$emit("transform-end"));
1622
+ },
1623
+ processStart: function() {
1624
+ this.transforming = !0, this.debouncedProcessEnd.clear();
1625
+ },
1626
+ processEvent: function(e) {
1627
+ return this.eventsFilter ? !1 !== this.eventsFilter(e, this.transforming) : (e.preventDefault(), e.stopPropagation(), !0);
1628
+ },
1629
+ onTouchStart: function(e) {
1630
+ if (e.cancelable && (this.touchMove || this.touchResize && e.touches.length > 1) && this.processEvent(e)) {
1631
+ var t = this.$refs.container, n = t.getBoundingClientRect(), r = n.left, i = n.top, a = n.bottom, o = n.right;
1632
+ this.touches = T(e.touches).filter((function(e) {
1633
+ return e.clientX > r && e.clientX < o && e.clientY > i && e.clientY < a;
1634
+ })), this.oldGeometricProperties = kt(this.touches, t);
1635
+ }
1636
+ },
1637
+ onTouchEnd: function(e) {
1638
+ e.touches.length === 0 && (this.touches = [], this.processEnd());
1639
+ },
1640
+ onTouchMove: function(e) {
1641
+ var t = this;
1642
+ if (this.touches.length) {
1643
+ var n = T(e.touches).filter((function(e) {
1644
+ return !e.identifier || t.touches.find((function(t) {
1645
+ return t.identifier === e.identifier;
1646
+ }));
1647
+ }));
1648
+ this.processEvent(e) && (this.processMove(e, n), this.processStart());
1649
+ }
1650
+ },
1651
+ onMouseDown: function(e) {
1652
+ if (this.mouseMove && "buttons" in e && e.buttons === 1 && this.processEvent(e)) {
1653
+ var t = {
1654
+ fake: !0,
1655
+ clientX: e.clientX,
1656
+ clientY: e.clientY
1657
+ };
1658
+ this.touches = [t], this.processStart();
1659
+ }
1660
+ },
1661
+ onMouseMove: function(e) {
1662
+ this.touches.length && this.processEvent(e) && this.processMove(e, [{
1663
+ clientX: e.clientX,
1664
+ clientY: e.clientY
1665
+ }]);
1666
+ },
1667
+ onMouseUp: function() {
1668
+ this.touches = [], this.processEnd();
1669
+ },
1670
+ onWheel: function(e) {
1671
+ if (this.wheelResize && this.processEvent(e)) {
1672
+ var t = this.$refs.container.getBoundingClientRect(), n = t.left, r = t.top, i = 1 + this.wheelResize.ratio * (o = e.deltaY || e.detail || e.wheelDelta, (s = +o) == 0 || we(s) ? s : s > 0 ? 1 : -1), a = {
1673
+ left: e.clientX - n,
1674
+ top: e.clientY - r
1675
+ };
1676
+ this.$emit("resize", new z({}, {
1677
+ factor: i,
1678
+ center: a
1679
+ })), this.touches.length || this.debouncedProcessEnd();
1680
+ }
1681
+ var o, s;
1682
+ }
1683
+ },
1684
+ emits: [
1685
+ "resize",
1686
+ "move",
1687
+ "transform-end"
1688
+ ]
1689
+ };
1690
+ At.render = function(e, t, n, r, a, s) {
1691
+ return o(), b("div", {
1692
+ ref: "container",
1693
+ onTouchstart: t[1] ||= function() {
1694
+ return s.onTouchStart && s.onTouchStart.apply(s, arguments);
1695
+ },
1696
+ onMousedown: t[2] ||= function() {
1697
+ return s.onMouseDown && s.onMouseDown.apply(s, arguments);
1698
+ },
1699
+ onWheel: t[3] ||= function() {
1700
+ return s.onWheel && s.onWheel.apply(s, arguments);
1701
+ }
1702
+ }, [i(e.$slots, "default")], 544);
1703
+ };
1704
+ var jt = {
1705
+ components: { TransformableImage: At },
1706
+ props: {
1707
+ touchMove: {
1708
+ type: Boolean,
1709
+ required: !0
1710
+ },
1711
+ mouseMove: {
1712
+ type: Boolean,
1713
+ required: !0
1714
+ },
1715
+ touchResize: {
1716
+ type: Boolean,
1717
+ required: !0
1718
+ },
1719
+ wheelResize: {
1720
+ type: [Boolean, Object],
1721
+ required: !0
1722
+ }
1723
+ },
1724
+ emits: ["resize", "move"]
1725
+ };
1726
+ jt.render = function(e, t, n, s, c, l) {
1727
+ var u = a("transformable-image");
1728
+ return o(), b(u, {
1729
+ "touch-move": n.touchMove,
1730
+ "touch-resize": n.touchResize,
1731
+ "mouse-move": n.mouseMove,
1732
+ "wheel-resize": n.wheelResize,
1733
+ onMove: t[1] ||= function(t) {
1734
+ return e.$emit("move", t);
1735
+ },
1736
+ onResize: t[2] ||= function(t) {
1737
+ return e.$emit("resize", t);
1738
+ }
1739
+ }, {
1740
+ default: r((function() {
1741
+ return [i(e.$slots, "default")];
1742
+ })),
1743
+ _: 3
1744
+ }, 8, [
1745
+ "touch-move",
1746
+ "touch-resize",
1747
+ "mouse-move",
1748
+ "wheel-resize"
1749
+ ]);
1750
+ };
1751
+ var Mt = k("vue-preview"), Nt = {
1752
+ props: {
1753
+ coordinates: { type: Object },
1754
+ transitions: { type: Object },
1755
+ image: {
1756
+ type: Object,
1757
+ default: function() {
1758
+ return {};
1759
+ }
1760
+ },
1761
+ imageClass: { type: String },
1762
+ width: { type: Number },
1763
+ height: { type: Number },
1764
+ fill: { type: Boolean }
1765
+ },
1766
+ data: function() {
1767
+ return {
1768
+ calculatedImageSize: {
1769
+ width: 0,
1770
+ height: 0
1771
+ },
1772
+ calculatedSize: {
1773
+ width: 0,
1774
+ height: 0
1775
+ }
1776
+ };
1777
+ },
1778
+ computed: {
1779
+ classes: function() {
1780
+ return {
1781
+ root: Mt({ fill: this.fill }),
1782
+ wrapper: Mt("wrapper"),
1783
+ imageWrapper: Mt("image-wrapper"),
1784
+ image: O(Mt("image"), this.imageClass)
1785
+ };
1786
+ },
1787
+ style: function() {
1788
+ if (this.fill) return {};
1789
+ var e = {};
1790
+ return this.width && (e.width = `${this.size.width}px`), this.height && (e.height = `${this.size.height}px`), this.transitions && this.transitions.enabled && (e.transition = `${this.transitions.time}ms ${this.transitions.timingFunction}`), e;
1791
+ },
1792
+ wrapperStyle: function() {
1793
+ var e = {
1794
+ width: `${this.size.width}px`,
1795
+ height: `${this.size.height}px`,
1796
+ left: `calc(50% - ${this.size.width / 2}px)`,
1797
+ top: `calc(50% - ${this.size.height / 2}px)`
1798
+ };
1799
+ return this.transitions && this.transitions.enabled && (e.transition = `${this.transitions.time}ms ${this.transitions.timingFunction}`), e;
1800
+ },
1801
+ imageStyle: function() {
1802
+ if (this.coordinates && this.image) {
1803
+ var e = this.coordinates.width / this.size.width, t = C(C({
1804
+ rotate: 0,
1805
+ flip: {
1806
+ horizontal: !1,
1807
+ vertical: !1
1808
+ }
1809
+ }, this.image.transforms), {}, {
1810
+ scaleX: 1 / e,
1811
+ scaleY: 1 / e
1812
+ }), n = this.imageSize.width, r = this.imageSize.height, i = We({
1813
+ width: n,
1814
+ height: r
1815
+ }, t.rotate), a = {
1816
+ width: `${n}px`,
1817
+ height: `${r}px`,
1818
+ left: "0px",
1819
+ top: "0px"
1820
+ }, o = {
1821
+ rotate: {
1822
+ left: (n - i.width) * t.scaleX / 2,
1823
+ top: (r - i.height) * t.scaleY / 2
1824
+ },
1825
+ scale: {
1826
+ left: (1 - t.scaleX) * n / 2,
1827
+ top: (1 - t.scaleY) * r / 2
1828
+ }
1829
+ };
1830
+ return a.transform = `translate(
1831
+ ${-this.coordinates.left / e - o.rotate.left - o.scale.left}px,${-this.coordinates.top / e - o.rotate.top - o.scale.top}px) ` + Dt(t), this.transitions && this.transitions.enabled && (a.transition = `${this.transitions.time}ms ${this.transitions.timingFunction}`), a;
1832
+ }
1833
+ return {};
1834
+ },
1835
+ size: function() {
1836
+ return {
1837
+ width: this.width || this.calculatedSize.width,
1838
+ height: this.height || this.calculatedSize.height
1839
+ };
1840
+ },
1841
+ imageSize: function() {
1842
+ return {
1843
+ width: this.image.width || this.calculatedImageSize.width,
1844
+ height: this.image.height || this.calculatedImageSize.height
1845
+ };
1846
+ }
1847
+ },
1848
+ watch: { image: function(e) {
1849
+ (e.width || e.height) && this.onChangeImage();
1850
+ } },
1851
+ mounted: function() {
1852
+ var e = this;
1853
+ this.onChangeImage(), this.$refs.image.addEventListener("load", (function() {
1854
+ e.refreshImage();
1855
+ })), window.addEventListener("resize", this.refresh), window.addEventListener("orientationchange", this.refresh);
1856
+ },
1857
+ unmounted: function() {
1858
+ window.removeEventListener("resize", this.refresh), window.removeEventListener("orientationchange", this.refresh);
1859
+ },
1860
+ methods: {
1861
+ refreshImage: function() {
1862
+ var e = this.$refs.image;
1863
+ this.calculatedImageSize.height = e.naturalHeight, this.calculatedImageSize.width = e.naturalWidth;
1864
+ },
1865
+ refresh: function() {
1866
+ var e = this.$refs.root;
1867
+ this.width || (this.calculatedSize.width = e.clientWidth), this.height || (this.calculatedSize.height = e.clientHeight);
1868
+ },
1869
+ onChangeImage: function() {
1870
+ var e = this.$refs.image;
1871
+ e && e.complete && this.refreshImage(), this.refresh();
1872
+ }
1873
+ }
1874
+ };
1875
+ Nt.render = function(e, t, n, r, i, a) {
1876
+ return o(), b("div", {
1877
+ ref: "root",
1878
+ class: a.classes.root,
1879
+ style: a.style
1880
+ }, [p("div", {
1881
+ ref: "wrapper",
1882
+ class: a.classes.wrapper,
1883
+ style: a.wrapperStyle
1884
+ }, [d(p("img", {
1885
+ ref: "image",
1886
+ src: n.image && n.image.src,
1887
+ class: a.classes.image,
1888
+ style: a.imageStyle
1889
+ }, null, 14, ["src"]), [[re, n.image && n.image.src]])], 6)], 6);
1890
+ };
1891
+ var Pt = {
1892
+ components: { Preview: Nt },
1893
+ inheritAttrs: !1
1894
+ };
1895
+ Pt.render = function(e, t, n, r, i, c) {
1896
+ var l = a("preview");
1897
+ return o(), b(l, s(e.$attrs, { fill: !0 }), null, 16);
1898
+ };
1899
+ var Ft = k("vue-rectangle-stencil"), It = {
1900
+ name: "RectangleStencil",
1901
+ components: {
1902
+ StencilPreview: Pt,
1903
+ BoundingBox: St,
1904
+ DraggableArea: wt
1905
+ },
1906
+ props: {
1907
+ image: { type: Object },
1908
+ coordinates: { type: Object },
1909
+ stencilCoordinates: { type: Object },
1910
+ handlers: { type: Object },
1911
+ handlersComponent: {
1912
+ type: [Object, String],
1913
+ default: function() {
1914
+ return ht;
1915
+ }
1916
+ },
1917
+ lines: { type: Object },
1918
+ linesComponent: {
1919
+ type: [Object, String],
1920
+ default: function() {
1921
+ return vt;
1922
+ }
1923
+ },
1924
+ aspectRatio: { type: [Number, String] },
1925
+ minAspectRatio: { type: [Number, String] },
1926
+ maxAspectRatio: { type: [Number, String] },
1927
+ movable: {
1928
+ type: Boolean,
1929
+ default: !0
1930
+ },
1931
+ resizable: {
1932
+ type: Boolean,
1933
+ default: !0
1934
+ },
1935
+ transitions: { type: Object },
1936
+ movingClass: { type: String },
1937
+ resizingClass: { type: String },
1938
+ previewClass: { type: String },
1939
+ boundingBoxClass: { type: String },
1940
+ linesClasses: {
1941
+ type: Object,
1942
+ default: function() {
1943
+ return {};
1944
+ }
1945
+ },
1946
+ linesWrappersClasses: {
1947
+ type: Object,
1948
+ default: function() {
1949
+ return {};
1950
+ }
1951
+ },
1952
+ handlersClasses: {
1953
+ type: Object,
1954
+ default: function() {
1955
+ return {};
1956
+ }
1957
+ },
1958
+ handlersWrappersClasses: {
1959
+ type: Object,
1960
+ default: function() {
1961
+ return {};
1962
+ }
1963
+ }
1964
+ },
1965
+ data: function() {
1966
+ return {
1967
+ moving: !1,
1968
+ resizing: !1
1969
+ };
1970
+ },
1971
+ computed: {
1972
+ classes: function() {
1973
+ return {
1974
+ stencil: O(Ft({
1975
+ movable: this.movable,
1976
+ moving: this.moving,
1977
+ resizing: this.resizing
1978
+ }), this.moving && this.movingClass, this.resizing && this.resizingClass),
1979
+ preview: O(Ft("preview"), this.previewClass),
1980
+ boundingBox: O(Ft("bounding-box"), this.boundingBoxClass)
1981
+ };
1982
+ },
1983
+ style: function() {
1984
+ var e = this.stencilCoordinates, t = e.height, n = e.width, r = e.left, i = e.top, a = {
1985
+ width: `${n}px`,
1986
+ height: `${t}px`,
1987
+ transform: `translate(${r}px, ${i}px)`
1988
+ };
1989
+ return this.transitions && this.transitions.enabled && (a.transition = `${this.transitions.time}ms ${this.transitions.timingFunction}`), a;
1990
+ }
1991
+ },
1992
+ methods: {
1993
+ onMove: function(e) {
1994
+ this.$emit("move", e), this.moving = !0;
1995
+ },
1996
+ onMoveEnd: function() {
1997
+ this.$emit("move-end"), this.moving = !1;
1998
+ },
1999
+ onResize: function(e) {
2000
+ this.$emit("resize", e), this.resizing = !0;
2001
+ },
2002
+ onResizeEnd: function() {
2003
+ this.$emit("resize-end"), this.resizing = !1;
2004
+ },
2005
+ aspectRatios: function() {
2006
+ return {
2007
+ minimum: this.aspectRatio || this.minAspectRatio,
2008
+ maximum: this.aspectRatio || this.maxAspectRatio
2009
+ };
2010
+ }
2011
+ },
2012
+ emits: [
2013
+ "resize",
2014
+ "resize-end",
2015
+ "move",
2016
+ "move-end"
2017
+ ]
2018
+ };
2019
+ It.render = function(e, t, n, i, s, c) {
2020
+ var l = a("stencil-preview"), u = a("draggable-area"), d = a("bounding-box");
2021
+ return o(), b("div", {
2022
+ class: c.classes.stencil,
2023
+ style: c.style
2024
+ }, [p(d, {
2025
+ width: n.stencilCoordinates.width,
2026
+ height: n.stencilCoordinates.height,
2027
+ transitions: n.transitions,
2028
+ class: c.classes.boundingBox,
2029
+ handlers: n.handlers,
2030
+ "handlers-component": n.handlersComponent,
2031
+ "handlers-classes": n.handlersClasses,
2032
+ "handlers-wrappers-classes": n.handlersWrappersClasses,
2033
+ lines: n.lines,
2034
+ "lines-component": n.linesComponent,
2035
+ "lines-classes": n.linesClasses,
2036
+ "lines-wrappers-classes": n.linesWrappersClasses,
2037
+ resizable: n.resizable,
2038
+ onResize: c.onResize,
2039
+ onResizeEnd: c.onResizeEnd
2040
+ }, {
2041
+ default: r((function() {
2042
+ return [p(u, {
2043
+ movable: n.movable,
2044
+ onMove: c.onMove,
2045
+ onMoveEnd: c.onMoveEnd
2046
+ }, {
2047
+ default: r((function() {
2048
+ return [p(l, {
2049
+ image: n.image,
2050
+ coordinates: n.coordinates,
2051
+ width: n.stencilCoordinates.width,
2052
+ height: n.stencilCoordinates.height,
2053
+ class: c.classes.preview,
2054
+ transitions: n.transitions
2055
+ }, null, 8, [
2056
+ "image",
2057
+ "coordinates",
2058
+ "width",
2059
+ "height",
2060
+ "class",
2061
+ "transitions"
2062
+ ])];
2063
+ })),
2064
+ _: 1
2065
+ }, 8, [
2066
+ "movable",
2067
+ "onMove",
2068
+ "onMoveEnd"
2069
+ ])];
2070
+ })),
2071
+ _: 1
2072
+ }, 8, [
2073
+ "width",
2074
+ "height",
2075
+ "transitions",
2076
+ "class",
2077
+ "handlers",
2078
+ "handlers-component",
2079
+ "handlers-classes",
2080
+ "handlers-wrappers-classes",
2081
+ "lines",
2082
+ "lines-component",
2083
+ "lines-classes",
2084
+ "lines-wrappers-classes",
2085
+ "resizable",
2086
+ "onResize",
2087
+ "onResizeEnd"
2088
+ ])], 6);
2089
+ };
2090
+ var Lt = ["transitions"], $ = k("vue-advanced-cropper"), Rt = {
2091
+ name: "Cropper",
2092
+ components: { BackgroundWrapper: jt },
2093
+ props: {
2094
+ src: {
2095
+ type: String,
2096
+ default: null
2097
+ },
2098
+ stencilComponent: {
2099
+ type: [Object, String],
2100
+ default: function() {
2101
+ return It;
2102
+ }
2103
+ },
2104
+ backgroundWrapperComponent: {
2105
+ type: [Object, String],
2106
+ default: function() {
2107
+ return jt;
2108
+ }
2109
+ },
2110
+ stencilProps: {
2111
+ type: Object,
2112
+ default: function() {
2113
+ return {};
2114
+ }
2115
+ },
2116
+ autoZoom: {
2117
+ type: Boolean,
2118
+ default: !1
2119
+ },
2120
+ imageClass: { type: String },
2121
+ boundariesClass: { type: String },
2122
+ backgroundClass: { type: String },
2123
+ foregroundClass: { type: String },
2124
+ minWidth: { type: [Number, String] },
2125
+ minHeight: { type: [Number, String] },
2126
+ maxWidth: { type: [Number, String] },
2127
+ maxHeight: { type: [Number, String] },
2128
+ debounce: {
2129
+ type: [Boolean, Number],
2130
+ default: 500
2131
+ },
2132
+ transitions: {
2133
+ type: Boolean,
2134
+ default: !0
2135
+ },
2136
+ checkOrientation: {
2137
+ type: Boolean,
2138
+ default: !0
2139
+ },
2140
+ canvas: {
2141
+ type: [Object, Boolean],
2142
+ default: !0
2143
+ },
2144
+ crossOrigin: {
2145
+ type: [Boolean, String],
2146
+ default: void 0
2147
+ },
2148
+ transitionTime: {
2149
+ type: Number,
2150
+ default: 300
2151
+ },
2152
+ imageRestriction: {
2153
+ type: String,
2154
+ default: "fit-area",
2155
+ validator: function(e) {
2156
+ return Le.indexOf(e) !== -1;
2157
+ }
2158
+ },
2159
+ roundResult: {
2160
+ type: Boolean,
2161
+ default: !0
2162
+ },
2163
+ defaultSize: { type: [Function, Object] },
2164
+ defaultPosition: { type: [Function, Object] },
2165
+ defaultVisibleArea: { type: [Function, Object] },
2166
+ defaultTransforms: { type: [Function, Object] },
2167
+ defaultBoundaries: {
2168
+ type: [Function, String],
2169
+ validator: function(e) {
2170
+ return typeof e != "string" || e === "fill" || e === "fit";
2171
+ }
2172
+ },
2173
+ priority: {
2174
+ type: String,
2175
+ default: "coordinates"
2176
+ },
2177
+ stencilSize: { type: [Object, Function] },
2178
+ resizeImage: {
2179
+ type: [Boolean, Object],
2180
+ default: !0
2181
+ },
2182
+ moveImage: {
2183
+ type: [Boolean, Object],
2184
+ default: !0
2185
+ },
2186
+ autoZoomAlgorithm: { type: Function },
2187
+ resizeAlgorithm: {
2188
+ type: Function,
2189
+ default: function(e) {
2190
+ var t = e.event, n = e.coordinates, r = e.aspectRatio, i = e.positionRestrictions, a = e.sizeRestrictions, o = M(M({}, n), {
2191
+ right: n.left + n.width,
2192
+ bottom: n.top + n.height
2193
+ }), s = t.params || {}, c = M({}, t.directions), l = s.allowedDirections || {
2194
+ left: !0,
2195
+ right: !0,
2196
+ bottom: !0,
2197
+ top: !0
2198
+ };
2199
+ a.widthFrozen && (c.left = 0, c.right = 0), a.heightFrozen && (c.top = 0, c.bottom = 0), B.forEach((function(e) {
2200
+ l[e] || (c[e] = 0);
2201
+ }));
2202
+ var u = W(o, c = dt({
2203
+ coordinates: o,
2204
+ directions: c,
2205
+ sizeRestrictions: a,
2206
+ positionRestrictions: i
2207
+ })).width, d = W(o, c).height, f = s.preserveRatio ? q(o) : He(u / d, r);
2208
+ if (f) {
2209
+ var p = s.respectDirection;
2210
+ if (p ||= o.width >= o.height || f === 1 ? "width" : "height", p === "width") {
2211
+ var m = u / f - o.height;
2212
+ if (l.top && l.bottom) {
2213
+ var h = c.top, g = c.bottom;
2214
+ c.bottom = ft(m, g, h), c.top = ft(m, h, g);
2215
+ } else l.bottom ? c.bottom = m : l.top ? c.top = m : l.right ? c.right = 0 : l.left && (c.left = 0);
2216
+ } else if (p === "height") {
2217
+ var _ = o.width - d * f;
2218
+ if (l.left && l.right) {
2219
+ var v = c.left, y = c.right;
2220
+ c.left = -ft(_, v, y), c.right = -ft(_, y, v);
2221
+ } else l.left ? c.left = -_ : l.right ? c.right = -_ : l.top ? c.top = 0 : l.bottom && (c.bottom = 0);
2222
+ }
2223
+ c = dt({
2224
+ directions: c,
2225
+ coordinates: o,
2226
+ sizeRestrictions: a,
2227
+ positionRestrictions: i,
2228
+ preserveRatio: !0,
2229
+ compensate: s.compensate
2230
+ });
2231
+ }
2232
+ return u = W(o, c).width, d = W(o, c).height, (f = s.preserveRatio ? q(o) : He(u / d, r)) && Math.abs(f - u / d) > .001 && B.forEach((function(e) {
2233
+ l[e] || (c[e] = 0);
2234
+ })), Qe({
2235
+ event: new De({
2236
+ left: -c.left,
2237
+ top: -c.top
2238
+ }),
2239
+ coordinates: {
2240
+ width: n.width + c.right + c.left,
2241
+ height: n.height + c.top + c.bottom,
2242
+ left: n.left,
2243
+ top: n.top
2244
+ },
2245
+ positionRestrictions: i
2246
+ });
2247
+ }
2248
+ },
2249
+ moveAlgorithm: {
2250
+ type: Function,
2251
+ default: Qe
2252
+ },
2253
+ initStretcher: {
2254
+ type: Function,
2255
+ default: function(e) {
2256
+ var t = e.stretcher, n = e.imageSize, r = q(n);
2257
+ t.style.width = n.width + "px", t.style.height = t.clientWidth / r + "px", t.style.width = t.clientWidth + "px";
2258
+ }
2259
+ },
2260
+ fitCoordinates: {
2261
+ type: Function,
2262
+ default: function(e) {
2263
+ var t = e.visibleArea, n = e.coordinates, r = e.aspectRatio, i = e.sizeRestrictions, a = e.positionRestrictions, o = M(M({}, n), Q({
2264
+ width: n.width,
2265
+ height: n.height,
2266
+ aspectRatio: r,
2267
+ sizeRestrictions: {
2268
+ maxWidth: t.width,
2269
+ maxHeight: t.height,
2270
+ minHeight: Math.min(t.height, i.minHeight),
2271
+ minWidth: Math.min(t.width, i.minWidth)
2272
+ }
2273
+ }));
2274
+ return o = Z(o = G(o, H(U(n), U(o))), Ye(V(t), a));
2275
+ }
2276
+ },
2277
+ fitVisibleArea: {
2278
+ type: Function,
2279
+ default: function(e) {
2280
+ var t = e.visibleArea, n = e.boundaries, r = e.getAreaRestrictions, i = e.coordinates, a = M({}, t);
2281
+ a.height = a.width / q(n), a.top += (t.height - a.height) / 2, (i.height - a.height > 0 || i.width - a.width > 0) && (a = K(a, Math.max(i.height / a.height, i.width / a.width)));
2282
+ var o = Ve(Y(i, V(a = K(a, Ge(a, r({
2283
+ visibleArea: a,
2284
+ type: "resize"
2285
+ }))))));
2286
+ return a.width < i.width && (o.left = 0), a.height < i.height && (o.top = 0), a = Z(a = G(a, o), r({
2287
+ visibleArea: a,
2288
+ type: "move"
2289
+ }));
2290
+ }
2291
+ },
2292
+ areaRestrictionsAlgorithm: {
2293
+ type: Function,
2294
+ default: function(e) {
2295
+ var t = e.visibleArea, n = e.boundaries, r = e.imageSize, i = e.imageRestriction, a = e.type, o = {};
2296
+ return i === "fill-area" ? o = {
2297
+ left: 0,
2298
+ top: 0,
2299
+ right: r.width,
2300
+ bottom: r.height
2301
+ } : i === "fit-area" && (q(n) > q(r) ? (o = {
2302
+ top: 0,
2303
+ bottom: r.height
2304
+ }, t && a === "move" && (t.width > r.width ? (o.left = -(t.width - r.width) / 2, o.right = r.width - o.left) : (o.left = 0, o.right = r.width))) : (o = {
2305
+ left: 0,
2306
+ right: r.width
2307
+ }, t && a === "move" && (t.height > r.height ? (o.top = -(t.height - r.height) / 2, o.bottom = r.height - o.top) : (o.top = 0, o.bottom = r.height)))), o;
2308
+ }
2309
+ },
2310
+ sizeRestrictionsAlgorithm: {
2311
+ type: Function,
2312
+ default: function(e) {
2313
+ return {
2314
+ minWidth: e.minWidth,
2315
+ minHeight: e.minHeight,
2316
+ maxWidth: e.maxWidth,
2317
+ maxHeight: e.maxHeight
2318
+ };
2319
+ }
2320
+ },
2321
+ positionRestrictionsAlgorithm: {
2322
+ type: Function,
2323
+ default: function(e) {
2324
+ var t = e.imageSize, n = {};
2325
+ return e.imageRestriction !== "none" && (n = {
2326
+ left: 0,
2327
+ top: 0,
2328
+ right: t.width,
2329
+ bottom: t.height
2330
+ }), n;
2331
+ }
2332
+ }
2333
+ },
2334
+ data: function() {
2335
+ return {
2336
+ transitionsActive: !1,
2337
+ imageLoaded: !1,
2338
+ imageAttributes: {
2339
+ width: null,
2340
+ height: null,
2341
+ crossOrigin: null,
2342
+ src: null
2343
+ },
2344
+ defaultImageTransforms: {
2345
+ rotate: 0,
2346
+ flip: {
2347
+ horizontal: !1,
2348
+ vertical: !1
2349
+ }
2350
+ },
2351
+ appliedImageTransforms: {
2352
+ rotate: 0,
2353
+ flip: {
2354
+ horizontal: !1,
2355
+ vertical: !1
2356
+ }
2357
+ },
2358
+ boundaries: {
2359
+ width: 0,
2360
+ height: 0
2361
+ },
2362
+ visibleArea: null,
2363
+ coordinates: C({}, Re)
2364
+ };
2365
+ },
2366
+ computed: {
2367
+ image: function() {
2368
+ return {
2369
+ src: this.imageAttributes.src,
2370
+ width: this.imageAttributes.width,
2371
+ height: this.imageAttributes.height,
2372
+ transforms: this.imageTransforms
2373
+ };
2374
+ },
2375
+ imageTransforms: function() {
2376
+ return {
2377
+ rotate: this.appliedImageTransforms.rotate,
2378
+ flip: {
2379
+ horizontal: this.appliedImageTransforms.flip.horizontal,
2380
+ vertical: this.appliedImageTransforms.flip.vertical
2381
+ },
2382
+ translateX: this.visibleArea ? this.visibleArea.left / this.coefficient : 0,
2383
+ translateY: this.visibleArea ? this.visibleArea.top / this.coefficient : 0,
2384
+ scaleX: 1 / this.coefficient,
2385
+ scaleY: 1 / this.coefficient
2386
+ };
2387
+ },
2388
+ imageSize: function() {
2389
+ var e = function(e) {
2390
+ return e * Math.PI / 180;
2391
+ }(this.imageTransforms.rotate);
2392
+ return {
2393
+ width: Math.abs(this.imageAttributes.width * Math.cos(e)) + Math.abs(this.imageAttributes.height * Math.sin(e)),
2394
+ height: Math.abs(this.imageAttributes.width * Math.sin(e)) + Math.abs(this.imageAttributes.height * Math.cos(e))
2395
+ };
2396
+ },
2397
+ initialized: function() {
2398
+ return !!(this.visibleArea && this.imageLoaded);
2399
+ },
2400
+ settings: function() {
2401
+ var e = Se(this.resizeImage, {
2402
+ touch: !0,
2403
+ wheel: { ratio: .1 },
2404
+ adjustStencil: !0
2405
+ }, {
2406
+ touch: !1,
2407
+ wheel: !1,
2408
+ adjustStencil: !1
2409
+ });
2410
+ return {
2411
+ moveImage: Se(this.moveImage, {
2412
+ touch: !0,
2413
+ mouse: !0
2414
+ }, {
2415
+ touch: !1,
2416
+ mouse: !1
2417
+ }),
2418
+ resizeImage: e
2419
+ };
2420
+ },
2421
+ coefficient: function() {
2422
+ return this.visibleArea ? this.visibleArea.width / this.boundaries.width : 0;
2423
+ },
2424
+ areaRestrictions: function() {
2425
+ return this.imageLoaded ? this.areaRestrictionsAlgorithm({
2426
+ imageSize: this.imageSize,
2427
+ imageRestriction: this.imageRestriction,
2428
+ boundaries: this.boundaries
2429
+ }) : {};
2430
+ },
2431
+ transitionsOptions: function() {
2432
+ return {
2433
+ enabled: this.transitionsActive,
2434
+ timingFunction: "ease-in-out",
2435
+ time: 350
2436
+ };
2437
+ },
2438
+ sizeRestrictions: function() {
2439
+ if (this.boundaries.width && this.boundaries.height && this.imageSize.width && this.imageSize.height) {
2440
+ var e = this.sizeRestrictionsAlgorithm({
2441
+ imageSize: this.imageSize,
2442
+ minWidth: I(this.minWidth) ? 0 : R(this.minWidth),
2443
+ minHeight: I(this.minHeight) ? 0 : R(this.minHeight),
2444
+ maxWidth: I(this.maxWidth) ? 1 / 0 : R(this.maxWidth),
2445
+ maxHeight: I(this.maxHeight) ? 1 / 0 : R(this.maxHeight)
2446
+ });
2447
+ if (e = function(e) {
2448
+ var t = e.areaRestrictions, n = e.sizeRestrictions, r = e.boundaries, i = e.positionRestrictions, a = M(M({}, n), {
2449
+ minWidth: n.minWidth === void 0 ? 0 : n.minWidth,
2450
+ minHeight: n.minHeight === void 0 ? 0 : n.minHeight,
2451
+ maxWidth: n.maxWidth === void 0 ? 1 / 0 : n.maxWidth,
2452
+ maxHeight: n.maxHeight === void 0 ? 1 / 0 : n.maxHeight
2453
+ });
2454
+ i.left !== void 0 && i.right !== void 0 && (a.maxWidth = Math.min(a.maxWidth, i.right - i.left)), i.bottom !== void 0 && i.top !== void 0 && (a.maxHeight = Math.min(a.maxHeight, i.bottom - i.top));
2455
+ var o = Ke(t), s = Ue(r, o);
2456
+ return o.width < 1 / 0 && (!a.maxWidth || a.maxWidth > s.width) && (a.maxWidth = Math.min(a.maxWidth, s.width)), o.height < 1 / 0 && (!a.maxHeight || a.maxHeight > s.height) && (a.maxHeight = Math.min(a.maxHeight, s.height)), a.minWidth > a.maxWidth && (a.minWidth = a.maxWidth, a.widthFrozen = !0), a.minHeight > a.maxHeight && (a.minHeight = a.maxHeight, a.heightFrozen = !0), a;
2457
+ }({
2458
+ sizeRestrictions: e,
2459
+ areaRestrictions: this.getAreaRestrictions({
2460
+ visibleArea: this.visibleArea,
2461
+ type: "resize"
2462
+ }),
2463
+ imageSize: this.imageSize,
2464
+ boundaries: this.boundaries,
2465
+ positionRestrictions: this.positionRestrictions,
2466
+ imageRestriction: this.imageRestriction,
2467
+ visibleArea: this.visibleArea,
2468
+ stencilSize: this.getStencilSize()
2469
+ }), this.visibleArea && this.stencilSize) {
2470
+ var t = this.getStencilSize(), n = Ke(this.getAreaRestrictions({
2471
+ visibleArea: this.visibleArea,
2472
+ type: "resize"
2473
+ }));
2474
+ e.maxWidth = Math.min(e.maxWidth, n.width * t.width / this.boundaries.width), e.maxHeight = Math.min(e.maxHeight, n.height * t.height / this.boundaries.height), e.maxWidth < e.minWidth && (e.minWidth = e.maxWidth), e.maxHeight < e.minHeight && (e.minHeight = e.maxHeight);
2475
+ }
2476
+ return e;
2477
+ }
2478
+ return {
2479
+ minWidth: 0,
2480
+ minHeight: 0,
2481
+ maxWidth: 0,
2482
+ maxHeight: 0
2483
+ };
2484
+ },
2485
+ positionRestrictions: function() {
2486
+ return this.positionRestrictionsAlgorithm({
2487
+ imageSize: this.imageSize,
2488
+ imageRestriction: this.imageRestriction
2489
+ });
2490
+ },
2491
+ classes: function() {
2492
+ return {
2493
+ cropper: $(),
2494
+ image: O($("image"), this.imageClass),
2495
+ stencil: $("stencil"),
2496
+ boundaries: O($("boundaries"), this.boundariesClass),
2497
+ stretcher: O($("stretcher")),
2498
+ background: O($("background"), this.backgroundClass),
2499
+ foreground: O($("foreground"), this.foregroundClass),
2500
+ imageWrapper: O($("image-wrapper")),
2501
+ cropperWrapper: O($("cropper-wrapper"))
2502
+ };
2503
+ },
2504
+ stencilCoordinates: function() {
2505
+ if (this.initialized) {
2506
+ var e = this.coordinates, t = e.width, n = e.height, r = e.left, i = e.top;
2507
+ return {
2508
+ width: t / this.coefficient,
2509
+ height: n / this.coefficient,
2510
+ left: (r - this.visibleArea.left) / this.coefficient,
2511
+ top: (i - this.visibleArea.top) / this.coefficient
2512
+ };
2513
+ }
2514
+ return this.defaultCoordinates();
2515
+ },
2516
+ boundariesStyle: function() {
2517
+ var e = {
2518
+ width: this.boundaries.width ? `${Math.round(this.boundaries.width)}px` : "auto",
2519
+ height: this.boundaries.height ? `${Math.round(this.boundaries.height)}px` : "auto",
2520
+ transition: `opacity ${this.transitionTime}ms`,
2521
+ pointerEvents: this.imageLoaded ? "all" : "none"
2522
+ };
2523
+ return this.imageLoaded || (e.opacity = "0"), e;
2524
+ },
2525
+ imageStyle: function() {
2526
+ var e = this.imageAttributes.width > this.imageAttributes.height ? {
2527
+ width: Math.min(1024, this.imageAttributes.width),
2528
+ height: Math.min(1024, this.imageAttributes.width) / (this.imageAttributes.width / this.imageAttributes.height)
2529
+ } : {
2530
+ height: Math.min(1024, this.imageAttributes.height),
2531
+ width: Math.min(1024, this.imageAttributes.height) * (this.imageAttributes.width / this.imageAttributes.height)
2532
+ }, t = {
2533
+ left: (e.width - this.imageSize.width) / (2 * this.coefficient),
2534
+ top: (e.height - this.imageSize.height) / (2 * this.coefficient)
2535
+ }, n = {
2536
+ left: (1 - 1 / this.coefficient) * e.width / 2,
2537
+ top: (1 - 1 / this.coefficient) * e.height / 2
2538
+ }, r = C(C({}, this.imageTransforms), {}, {
2539
+ scaleX: this.imageTransforms.scaleX * (this.imageAttributes.width / e.width),
2540
+ scaleY: this.imageTransforms.scaleY * (this.imageAttributes.height / e.height)
2541
+ }), i = {
2542
+ width: `${e.width}px`,
2543
+ height: `${e.height}px`,
2544
+ left: "0px",
2545
+ top: "0px",
2546
+ transform: `translate(${-t.left - n.left - this.imageTransforms.translateX}px, ${-t.top - n.top - this.imageTransforms.translateY}px)` + Dt(r)
2547
+ };
2548
+ return this.transitionsOptions.enabled && (i.transition = `${this.transitionsOptions.time}ms ${this.transitionsOptions.timingFunction}`), i;
2549
+ }
2550
+ },
2551
+ watch: {
2552
+ src: function() {
2553
+ this.onChangeImage();
2554
+ },
2555
+ stencilComponent: function() {
2556
+ var e = this;
2557
+ this.$nextTick((function() {
2558
+ e.resetCoordinates(), e.runAutoZoom("setCoordinates"), e.onChange();
2559
+ }));
2560
+ },
2561
+ minWidth: function() {
2562
+ this.onPropsChange();
2563
+ },
2564
+ maxWidth: function() {
2565
+ this.onPropsChange();
2566
+ },
2567
+ minHeight: function() {
2568
+ this.onPropsChange();
2569
+ },
2570
+ maxHeight: function() {
2571
+ this.onPropsChange();
2572
+ },
2573
+ imageRestriction: function() {
2574
+ this.reset();
2575
+ },
2576
+ stencilProps: function(e, t) {
2577
+ [
2578
+ "aspectRatio",
2579
+ "minAspectRatio",
2580
+ "maxAspectRatio"
2581
+ ].find((function(n) {
2582
+ return e[n] !== t[n];
2583
+ })) && this.$nextTick(this.onPropsChange);
2584
+ }
2585
+ },
2586
+ created: function() {
2587
+ this.debouncedUpdate = j(this.update, this.debounce), this.debouncedDisableTransitions = j(this.disableTransitions, this.transitionsOptions.time), this.awaiting = !1;
2588
+ },
2589
+ mounted: function() {
2590
+ this.$refs.image.addEventListener("load", this.onSuccessLoadImage), this.$refs.image.addEventListener("error", this.onFailLoadImage), this.onChangeImage(), window.addEventListener("resize", this.refresh), window.addEventListener("orientationchange", this.refresh);
2591
+ },
2592
+ unmounted: function() {
2593
+ window.removeEventListener("resize", this.refresh), window.removeEventListener("orientationchange", this.refresh), this.imageAttributes.revoke && this.imageAttributes.src && URL.revokeObjectURL(this.imageAttributes.src), this.debouncedUpdate.clear(), this.debouncedDisableTransitions.clear();
2594
+ },
2595
+ methods: {
2596
+ getResult: function() {
2597
+ var e = this.initialized ? this.prepareResult(C({}, this.coordinates)) : this.defaultCoordinates(), t = {
2598
+ rotate: this.imageTransforms.rotate % 360,
2599
+ flip: C({}, this.imageTransforms.flip)
2600
+ };
2601
+ if (this.src && this.imageLoaded) {
2602
+ var n = this;
2603
+ return {
2604
+ image: this.image,
2605
+ coordinates: e,
2606
+ visibleArea: this.visibleArea ? C({}, this.visibleArea) : null,
2607
+ imageTransforms: t,
2608
+ get canvas() {
2609
+ return n.canvas ? n.getCanvas() : void 0;
2610
+ }
2611
+ };
2612
+ }
2613
+ return {
2614
+ image: this.image,
2615
+ coordinates: e,
2616
+ visibleArea: this.visibleArea ? C({}, this.visibleArea) : null,
2617
+ canvas: void 0,
2618
+ imageTransforms: t
2619
+ };
2620
+ },
2621
+ zoom: function(e, t) {
2622
+ var n = (arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}).transitions, r = n === void 0 || n;
2623
+ this.onManipulateImage(new z({}, {
2624
+ factor: 1 / e,
2625
+ center: t
2626
+ }), {
2627
+ normalize: !1,
2628
+ transitions: r
2629
+ });
2630
+ },
2631
+ move: function(e, t) {
2632
+ var n = (arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}).transitions, r = n === void 0 || n;
2633
+ this.onManipulateImage(new z({
2634
+ left: e || 0,
2635
+ top: t || 0
2636
+ }), {
2637
+ normalize: !1,
2638
+ transitions: r
2639
+ });
2640
+ },
2641
+ setCoordinates: function(e) {
2642
+ var t = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = n.autoZoom, i = r === void 0 || r, a = n.transitions, o = a === void 0 || a;
2643
+ this.$nextTick((function() {
2644
+ t.imageLoaded ? (t.transitionsActive || (o && t.enableTransitions(), t.coordinates = t.applyTransform(e), i && t.runAutoZoom("setCoordinates"), o && t.debouncedDisableTransitions()), t.onChange()) : t.delayedTransforms = e;
2645
+ }));
2646
+ },
2647
+ refresh: function() {
2648
+ var e = this, t = this.$refs.image;
2649
+ if (this.src && t) return this.initialized ? this.updateVisibleArea().then((function() {
2650
+ e.onChange();
2651
+ })) : this.resetVisibleArea().then((function() {
2652
+ e.onChange();
2653
+ }));
2654
+ },
2655
+ reset: function() {
2656
+ var e = this;
2657
+ return this.resetVisibleArea().then((function() {
2658
+ e.onChange(!1);
2659
+ }));
2660
+ },
2661
+ awaitRender: function(e) {
2662
+ var t = this;
2663
+ this.awaiting || (this.awaiting = !0, this.$nextTick((function() {
2664
+ e(), t.awaiting = !1;
2665
+ })));
2666
+ },
2667
+ prepareResult: function(e) {
2668
+ return this.roundResult ? function(e) {
2669
+ var t = e.coordinates, n = e.sizeRestrictions, r = e.positionRestrictions, i = {
2670
+ width: Math.round(t.width),
2671
+ height: Math.round(t.height),
2672
+ left: Math.round(t.left),
2673
+ top: Math.round(t.top)
2674
+ };
2675
+ return i.width > n.maxWidth ? i.width = Math.floor(t.width) : i.width < n.minWidth && (i.width = Math.ceil(t.width)), i.height > n.maxHeight ? i.height = Math.floor(t.height) : i.height < n.minHeight && (i.height = Math.ceil(t.height)), Z(i, r);
2676
+ }(C(C({}, this.getPublicProperties()), {}, {
2677
+ positionRestrictions: st(this.positionRestrictions, this.visibleArea),
2678
+ coordinates: e
2679
+ })) : e;
2680
+ },
2681
+ processAutoZoom: function(e, t, n, r) {
2682
+ var i = this.autoZoomAlgorithm;
2683
+ i ||= this.stencilSize ? et : this.autoZoom ? tt : nt;
2684
+ var a = i({
2685
+ event: {
2686
+ type: e,
2687
+ params: r
2688
+ },
2689
+ visibleArea: t,
2690
+ coordinates: n,
2691
+ boundaries: this.boundaries,
2692
+ aspectRatio: this.getAspectRatio(),
2693
+ positionRestrictions: this.positionRestrictions,
2694
+ getAreaRestrictions: this.getAreaRestrictions,
2695
+ sizeRestrictions: this.sizeRestrictions,
2696
+ stencilSize: this.getStencilSize()
2697
+ });
2698
+ return C(C({}, a), {}, { changed: !ze(a.visibleArea, t) || !ze(a.coordinates, n) });
2699
+ },
2700
+ runAutoZoom: function(e) {
2701
+ var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = t.transitions, r = n !== void 0 && n, i = ve(t, Lt), a = this.processAutoZoom(e, this.visibleArea, this.coordinates, i), o = a.visibleArea, s = a.coordinates, c = a.changed;
2702
+ r && c && this.enableTransitions(), this.visibleArea = o, this.coordinates = s, r && c && this.debouncedDisableTransitions();
2703
+ },
2704
+ normalizeEvent: function(e) {
2705
+ return function(e) {
2706
+ var t = e.event, n = e.visibleArea, r = e.coefficient;
2707
+ if (t.type === "manipulateImage") return M(M({}, t), {
2708
+ move: {
2709
+ left: t.move && t.move.left ? r * t.move.left : 0,
2710
+ top: t.move && t.move.top ? r * t.move.top : 0
2711
+ },
2712
+ scale: {
2713
+ factor: t.scale && t.scale.factor ? t.scale.factor : 1,
2714
+ center: t.scale && t.scale.center ? {
2715
+ left: t.scale.center.left * r + n.left,
2716
+ top: t.scale.center.top * r + n.top
2717
+ } : null
2718
+ }
2719
+ });
2720
+ if (t.type === "resize") {
2721
+ var i = M(M({}, t), { directions: M({}, t.directions) });
2722
+ return B.forEach((function(e) {
2723
+ i.directions[e] *= r;
2724
+ })), i;
2725
+ }
2726
+ if (t.type === "move") {
2727
+ var a = M(M({}, t), { directions: M({}, t.directions) });
2728
+ return Ie.forEach((function(e) {
2729
+ a.directions[e] *= r;
2730
+ })), a;
2731
+ }
2732
+ return t;
2733
+ }(C(C({}, this.getPublicProperties()), {}, { event: e }));
2734
+ },
2735
+ getCanvas: function() {
2736
+ if (this.$refs.canvas) {
2737
+ var e = this.$refs.canvas, t = this.$refs.image, n = this.imageTransforms.rotate !== 0 || this.imageTransforms.flip.horizontal || this.imageTransforms.flip.vertical ? function(e, t, n) {
2738
+ var r = n.rotate, i = n.flip, a = {
2739
+ width: t.naturalWidth,
2740
+ height: t.naturalHeight
2741
+ }, o = We(a, r), s = e.getContext("2d");
2742
+ e.height = o.height, e.width = o.width, s.save();
2743
+ var c = X(U(M({
2744
+ left: 0,
2745
+ top: 0
2746
+ }, a)), r);
2747
+ return s.translate(-(c.left - o.width / 2), -(c.top - o.height / 2)), s.rotate(r * Math.PI / 180), s.translate(i.horizontal ? a.width : 0, i.vertical ? a.height : 0), s.scale(i.horizontal ? -1 : 1, i.vertical ? -1 : 1), s.drawImage(t, 0, 0, a.width, a.height), s.restore(), e;
2748
+ }(this.$refs.sourceCanvas, t, this.imageTransforms) : t, r = C({
2749
+ minWidth: 0,
2750
+ minHeight: 0,
2751
+ maxWidth: 1 / 0,
2752
+ maxHeight: 1 / 0,
2753
+ maxArea: this.maxCanvasSize,
2754
+ imageSmoothingEnabled: !0,
2755
+ imageSmoothingQuality: "high",
2756
+ fillColor: "transparent"
2757
+ }, this.canvas), i = function(e) {
2758
+ return e.find((function(e) {
2759
+ return t = e, !Number.isNaN(parseFloat(t)) && isFinite(t);
2760
+ var t;
2761
+ }));
2762
+ }, a = Q({
2763
+ sizeRestrictions: {
2764
+ minWidth: i([r.width, r.minWidth]) || 0,
2765
+ minHeight: i([r.height, r.minHeight]) || 0,
2766
+ maxWidth: i([r.width, r.maxWidth]) || 1 / 0,
2767
+ maxHeight: i([r.height, r.maxHeight]) || 1 / 0
2768
+ },
2769
+ width: this.coordinates.width,
2770
+ height: this.coordinates.height,
2771
+ aspectRatio: {
2772
+ minimum: this.coordinates.width / this.coordinates.height,
2773
+ maximum: this.coordinates.width / this.coordinates.height
2774
+ }
2775
+ });
2776
+ if (r.maxArea && a.width * a.height > r.maxArea) {
2777
+ var o = Math.sqrt(r.maxArea / (a.width * a.height));
2778
+ a = {
2779
+ width: Math.round(o * a.width),
2780
+ height: Math.round(o * a.height)
2781
+ };
2782
+ }
2783
+ return function(e, t, n, r, i) {
2784
+ e.width = r ? r.width : n.width, e.height = r ? r.height : n.height;
2785
+ var a = e.getContext("2d");
2786
+ a.clearRect(0, 0, e.width, e.height), i && (i.imageSmoothingEnabled && (a.imageSmoothingEnabled = i.imageSmoothingEnabled), i.imageSmoothingQuality && (a.imageSmoothingQuality = i.imageSmoothingQuality), i.fillColor && (a.fillStyle = i.fillColor, a.fillRect(0, 0, e.width, e.height), a.save()));
2787
+ var o = n.left < 0 ? -n.left : 0, s = n.top < 0 ? -n.top : 0;
2788
+ a.drawImage(t, n.left + o, n.top + s, n.width, n.height, e.width / n.width * o, e.height / n.height * s, e.width, e.height);
2789
+ }(e, n, this.coordinates, a, r), e;
2790
+ }
2791
+ },
2792
+ update: function() {
2793
+ this.$emit("change", this.getResult());
2794
+ },
2795
+ applyTransform: function(e) {
2796
+ var t = arguments.length > 1 && arguments[1] !== void 0 && arguments[1], n = this.visibleArea && t ? qe(this.sizeRestrictions, this.visibleArea) : this.sizeRestrictions, r = this.visibleArea && t ? st(this.positionRestrictions, this.visibleArea) : this.positionRestrictions;
2797
+ return $e({
2798
+ transform: e,
2799
+ coordinates: this.coordinates,
2800
+ imageSize: this.imageSize,
2801
+ sizeRestrictions: n,
2802
+ positionRestrictions: r,
2803
+ aspectRatio: this.getAspectRatio(),
2804
+ visibleArea: this.visibleArea
2805
+ });
2806
+ },
2807
+ resetCoordinates: function() {
2808
+ var e = this;
2809
+ if (this.$refs.image) {
2810
+ this.$refs.cropper, this.$refs.image;
2811
+ var t = this.defaultSize;
2812
+ t ||= this.stencilSize ? at : it, this.sizeRestrictions;
2813
+ var n = F(t) ? t({
2814
+ boundaries: this.boundaries,
2815
+ imageSize: this.imageSize,
2816
+ aspectRatio: this.getAspectRatio(),
2817
+ sizeRestrictions: this.sizeRestrictions,
2818
+ stencilSize: this.getStencilSize(),
2819
+ visibleArea: this.visibleArea
2820
+ }) : t, r = this.defaultPosition || rt, i = [n, function(t) {
2821
+ var n = t.coordinates;
2822
+ return C({}, F(r) ? r({
2823
+ coordinates: n,
2824
+ imageSize: e.imageSize,
2825
+ visibleArea: e.visibleArea
2826
+ }) : e.defaultPosition);
2827
+ }];
2828
+ this.delayedTransforms && i.push.apply(i, T(Array.isArray(this.delayedTransforms) ? this.delayedTransforms : [this.delayedTransforms])), this.coordinates = this.applyTransform(i, !0), this.delayedTransforms = null;
2829
+ }
2830
+ },
2831
+ clearImage: function() {
2832
+ var e = this;
2833
+ this.imageLoaded = !1, setTimeout((function() {
2834
+ var t = e.$refs.stretcher;
2835
+ t && (t.style.height = "auto", t.style.width = "auto"), e.coordinates = e.defaultCoordinates(), e.boundaries = {
2836
+ width: 0,
2837
+ height: 0
2838
+ };
2839
+ }), this.transitionTime);
2840
+ },
2841
+ enableTransitions: function() {
2842
+ this.transitions && (this.transitionsActive = !0);
2843
+ },
2844
+ disableTransitions: function() {
2845
+ this.transitionsActive = !1;
2846
+ },
2847
+ updateBoundaries: function() {
2848
+ var e = this, t = this.$refs.stretcher, n = this.$refs.cropper;
2849
+ return this.initStretcher({
2850
+ cropper: n,
2851
+ stretcher: t,
2852
+ imageSize: this.imageSize
2853
+ }), this.$nextTick().then((function() {
2854
+ var t = {
2855
+ cropper: n,
2856
+ imageSize: e.imageSize
2857
+ };
2858
+ if (e.boundaries = F(e.defaultBoundaries) ? e.defaultBoundaries(t) : e.defaultBoundaries === "fit" ? function(e) {
2859
+ var t = e.cropper, n = e.imageSize, r = t.clientHeight, i = t.clientWidth, a = r, o = n.width * r / n.height;
2860
+ return o > i && (o = i, a = n.height * i / n.width), {
2861
+ width: o,
2862
+ height: a
2863
+ };
2864
+ }(t) : function(e) {
2865
+ var t = e.cropper;
2866
+ return {
2867
+ width: t.clientWidth,
2868
+ height: t.clientHeight
2869
+ };
2870
+ }(t), !e.boundaries.width || !e.boundaries.height) throw Error("It's impossible to fit the cropper in the current container");
2871
+ }));
2872
+ },
2873
+ resetVisibleArea: function() {
2874
+ var e = this;
2875
+ return this.appliedImageTransforms = C(C({}, this.defaultImageTransforms), {}, { flip: C({}, this.defaultImageTransforms.flip) }), this.updateBoundaries().then((function() {
2876
+ e.priority !== "visible-area" && (e.visibleArea = null, e.resetCoordinates());
2877
+ var t, n, r, i, a, o, s = e.defaultVisibleArea || ot;
2878
+ e.visibleArea = F(s) ? s({
2879
+ imageSize: e.imageSize,
2880
+ boundaries: e.boundaries,
2881
+ coordinates: e.priority === "visible-area" ? null : e.coordinates,
2882
+ getAreaRestrictions: e.getAreaRestrictions,
2883
+ stencilSize: e.getStencilSize()
2884
+ }) : e.defaultVisibleArea, e.visibleArea = (t = {
2885
+ visibleArea: e.visibleArea,
2886
+ boundaries: e.boundaries,
2887
+ getAreaRestrictions: e.getAreaRestrictions
2888
+ }, n = t.visibleArea, r = t.boundaries, i = t.getAreaRestrictions, a = M({}, n), o = q(r), a.width / a.height !== o && (a.height = a.width / o), Z(a, i({
2889
+ visibleArea: a,
2890
+ type: "move"
2891
+ }))), e.priority === "visible-area" ? e.resetCoordinates() : e.coordinates = e.fitCoordinates({
2892
+ visibleArea: e.visibleArea,
2893
+ coordinates: e.coordinates,
2894
+ aspectRatio: e.getAspectRatio(),
2895
+ positionRestrictions: e.positionRestrictions,
2896
+ sizeRestrictions: e.sizeRestrictions
2897
+ }), e.runAutoZoom("resetVisibleArea");
2898
+ })).catch((function() {
2899
+ e.visibleArea = null;
2900
+ }));
2901
+ },
2902
+ updateVisibleArea: function() {
2903
+ var e = this;
2904
+ return this.updateBoundaries().then((function() {
2905
+ e.visibleArea = e.fitVisibleArea({
2906
+ imageSize: e.imageSize,
2907
+ boundaries: e.boundaries,
2908
+ visibleArea: e.visibleArea,
2909
+ coordinates: e.coordinates,
2910
+ getAreaRestrictions: e.getAreaRestrictions
2911
+ }), e.coordinates = e.fitCoordinates({
2912
+ visibleArea: e.visibleArea,
2913
+ coordinates: e.coordinates,
2914
+ aspectRatio: e.getAspectRatio(),
2915
+ positionRestrictions: e.positionRestrictions,
2916
+ sizeRestrictions: e.sizeRestrictions
2917
+ }), e.runAutoZoom("updateVisibleArea");
2918
+ })).catch((function() {
2919
+ e.visibleArea = null;
2920
+ }));
2921
+ },
2922
+ onChange: function() {
2923
+ (!(arguments.length > 0 && arguments[0] !== void 0) || arguments[0]) && this.debounce ? this.debouncedUpdate() : this.update();
2924
+ },
2925
+ onChangeImage: function() {
2926
+ var e, t = this;
2927
+ if (this.imageLoaded = !1, this.delayedTransforms = null, this.src) {
2928
+ if (function(e) {
2929
+ if (xe(e)) return !1;
2930
+ var t = window.location, n = /(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(e) || [], r = {
2931
+ protocol: n[1] || "",
2932
+ host: n[2] || "",
2933
+ port: n[3] || ""
2934
+ }, i = function(e) {
2935
+ return e.port || ((e.protocol || t.protocol) === "http" ? 80 : 433);
2936
+ };
2937
+ return !(!r.protocol && !r.host && !r.port || r.protocol && r.protocol == t.protocol && r.host && r.host == t.host && r.host && i(r) == i(t));
2938
+ }(this.src)) {
2939
+ var n = I(this.crossOrigin) ? this.canvas : this.crossOrigin;
2940
+ !0 === n && (n = "anonymous"), this.imageAttributes.crossOrigin = n || null;
2941
+ }
2942
+ if (this.checkOrientation) {
2943
+ var r = (e = this.src, new Promise((function(t) {
2944
+ Et(e).then((function(n) {
2945
+ var r = Ot(n);
2946
+ t(n ? {
2947
+ source: e,
2948
+ arrayBuffer: n,
2949
+ orientation: r
2950
+ } : {
2951
+ source: e,
2952
+ arrayBuffer: null,
2953
+ orientation: null
2954
+ });
2955
+ })).catch((function(n) {
2956
+ console.warn(n), t({
2957
+ source: e,
2958
+ arrayBuffer: null,
2959
+ orientation: null
2960
+ });
2961
+ }));
2962
+ })));
2963
+ setTimeout((function() {
2964
+ r.then(t.onParseImage);
2965
+ }), this.transitionTime);
2966
+ } else setTimeout((function() {
2967
+ t.onParseImage({ source: t.src });
2968
+ }), this.transitionTime);
2969
+ } else this.clearImage();
2970
+ },
2971
+ onFailLoadImage: function() {
2972
+ this.imageAttributes.src && (this.clearImage(), this.$emit("error"));
2973
+ },
2974
+ onSuccessLoadImage: function() {
2975
+ var e = this, t = this.$refs.image;
2976
+ t && !this.imageLoaded && (this.imageAttributes.height = t.naturalHeight, this.imageAttributes.width = t.naturalWidth, this.imageLoaded = !0, this.resetVisibleArea().then((function() {
2977
+ e.$emit("ready"), e.onChange(!1);
2978
+ })));
2979
+ },
2980
+ onParseImage: function(e) {
2981
+ var t = this, n = e.source, r = e.arrayBuffer, i = e.orientation;
2982
+ this.imageAttributes.revoke && this.imageAttributes.src && URL.revokeObjectURL(this.imageAttributes.src), this.imageAttributes.revoke = !1, r && i && i > 1 ? P(n) || !xe(n) ? (this.imageAttributes.src = URL.createObjectURL(new Blob([r])), this.imageAttributes.revoke = !0) : this.imageAttributes.src = function(e) {
2983
+ for (var t = [], n = new Uint8Array(e); n.length > 0;) {
2984
+ var r = n.subarray(0, 8192);
2985
+ t.push(String.fromCharCode.apply(null, Array.from ? Array.from(r) : r.slice())), n = n.subarray(8192);
2986
+ }
2987
+ return "data:image/jpeg;base64," + btoa(t.join(""));
2988
+ }(r) : this.imageAttributes.src = n, this.appliedImageTransforms = F(this.defaultTransforms) ? Tt(this.defaultTransforms()) : L(this.defaultTransforms) ? Tt(this.defaultTransforms) : function(e) {
2989
+ var t = Tt({});
2990
+ if (e) switch (e) {
2991
+ case 2:
2992
+ t.flip.horizontal = !0;
2993
+ break;
2994
+ case 3:
2995
+ t.rotate = -180;
2996
+ break;
2997
+ case 4:
2998
+ t.flip.vertical = !0;
2999
+ break;
3000
+ case 5:
3001
+ t.rotate = 90, t.flip.vertical = !0;
3002
+ break;
3003
+ case 6:
3004
+ t.rotate = 90;
3005
+ break;
3006
+ case 7:
3007
+ t.rotate = 90, t.flip.horizontal = !0;
3008
+ break;
3009
+ case 8: t.rotate = -90;
3010
+ }
3011
+ return t;
3012
+ }(i), this.defaultImageTransforms = C(C({}, this.appliedImageTransforms), {}, { flip: C({}, this.appliedImageTransforms.flip) }), this.$nextTick((function() {
3013
+ var e = t.$refs.image;
3014
+ e && e.complete && (function(e) {
3015
+ return !!e.naturalWidth;
3016
+ }(e) ? t.onSuccessLoadImage() : t.onFailLoadImage());
3017
+ }));
3018
+ },
3019
+ onResizeEnd: function() {
3020
+ this.runAutoZoom("resize", { transitions: !0 });
3021
+ },
3022
+ onMoveEnd: function() {
3023
+ this.runAutoZoom("move", { transitions: !0 });
3024
+ },
3025
+ onMove: function(e) {
3026
+ var t = this;
3027
+ this.transitionsOptions.enabled || this.awaitRender((function() {
3028
+ t.coordinates = t.moveAlgorithm(C(C({}, t.getPublicProperties()), {}, {
3029
+ positionRestrictions: st(t.positionRestrictions, t.visibleArea),
3030
+ coordinates: t.coordinates,
3031
+ event: t.normalizeEvent(e)
3032
+ })), t.onChange();
3033
+ }));
3034
+ },
3035
+ onResize: function(e) {
3036
+ var t = this;
3037
+ this.transitionsOptions.enabled || this.stencilSize && !this.autoZoom || this.awaitRender((function() {
3038
+ var n = t.sizeRestrictions, r = Math.min(t.coordinates.width, t.coordinates.height, 20 * t.coefficient);
3039
+ t.coordinates = t.resizeAlgorithm(C(C({}, t.getPublicProperties()), {}, {
3040
+ positionRestrictions: st(t.positionRestrictions, t.visibleArea),
3041
+ sizeRestrictions: {
3042
+ maxWidth: Math.min(n.maxWidth, t.visibleArea.width),
3043
+ maxHeight: Math.min(n.maxHeight, t.visibleArea.height),
3044
+ minWidth: Math.max(n.minWidth, r),
3045
+ minHeight: Math.max(n.minHeight, r)
3046
+ },
3047
+ event: t.normalizeEvent(e)
3048
+ })), t.onChange(), t.ticking = !1;
3049
+ }));
3050
+ },
3051
+ onManipulateImage: function(e) {
3052
+ var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3053
+ if (!this.transitionsOptions.enabled) {
3054
+ var n = t.transitions, r = n !== void 0 && n, i = t.normalize, a = i === void 0 || i;
3055
+ r && this.enableTransitions();
3056
+ var o = ct(C(C({}, this.getPublicProperties()), {}, {
3057
+ event: a ? this.normalizeEvent(e) : e,
3058
+ getAreaRestrictions: this.getAreaRestrictions,
3059
+ imageRestriction: this.imageRestriction,
3060
+ adjustStencil: !this.stencilSize && this.settings.resizeImage.adjustStencil
3061
+ })), s = o.visibleArea, c = o.coordinates;
3062
+ this.visibleArea = s, this.coordinates = c, this.runAutoZoom("manipulateImage"), this.onChange(), r && this.debouncedDisableTransitions();
3063
+ }
3064
+ },
3065
+ onPropsChange: function() {
3066
+ this.coordinates = this.applyTransform(this.coordinates, !0), this.onChange(!1);
3067
+ },
3068
+ getAreaRestrictions: function() {
3069
+ var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = e.visibleArea, n = e.type, r = n === void 0 ? "move" : n;
3070
+ return this.areaRestrictionsAlgorithm({
3071
+ boundaries: this.boundaries,
3072
+ imageSize: this.imageSize,
3073
+ imageRestriction: this.imageRestriction,
3074
+ visibleArea: t,
3075
+ type: r
3076
+ });
3077
+ },
3078
+ getAspectRatio: function(e) {
3079
+ var t, n, r = this.stencilProps, i = r.aspectRatio, a = r.minAspectRatio, o = r.maxAspectRatio;
3080
+ if (this.$refs.stencil && this.$refs.stencil.aspectRatios) {
3081
+ var s = this.$refs.stencil.aspectRatios();
3082
+ t = s.minimum, n = s.maximum;
3083
+ }
3084
+ if (I(t) && (t = I(i) ? a : i), I(n) && (n = I(i) ? o : i), !e && (I(t) || I(n))) {
3085
+ var c = this.getStencilSize(), l = c ? q(c) : null;
3086
+ I(t) && (t = Ce(l) ? l : void 0), I(n) && (n = Ce(l) ? l : void 0);
3087
+ }
3088
+ return {
3089
+ minimum: t,
3090
+ maximum: n
3091
+ };
3092
+ },
3093
+ getStencilSize: function() {
3094
+ if (this.stencilSize) return e = {
3095
+ currentStencilSize: {
3096
+ width: this.stencilCoordinates.width,
3097
+ height: this.stencilCoordinates.height
3098
+ },
3099
+ stencilSize: this.stencilSize,
3100
+ boundaries: this.boundaries,
3101
+ coefficient: this.coefficient,
3102
+ coordinates: this.coordinates,
3103
+ aspectRatio: this.getAspectRatio(!0)
3104
+ }, t = e.boundaries, n = e.stencilSize, r = e.aspectRatio, He(q(i = F(n) ? n({
3105
+ boundaries: t,
3106
+ aspectRatio: r
3107
+ }) : n), r) && (i = Q({
3108
+ sizeRestrictions: {
3109
+ maxWidth: t.width,
3110
+ maxHeight: t.height,
3111
+ minWidth: 0,
3112
+ minHeight: 0
3113
+ },
3114
+ width: i.width,
3115
+ height: i.height,
3116
+ aspectRatio: {
3117
+ minimum: r.minimum,
3118
+ maximum: r.maximum
3119
+ }
3120
+ })), (i.width > t.width || i.height > t.height) && (i = Q({
3121
+ sizeRestrictions: {
3122
+ maxWidth: t.width,
3123
+ maxHeight: t.height,
3124
+ minWidth: 0,
3125
+ minHeight: 0
3126
+ },
3127
+ width: i.width,
3128
+ height: i.height,
3129
+ aspectRatio: {
3130
+ minimum: q(i),
3131
+ maximum: q(i)
3132
+ }
3133
+ })), i;
3134
+ var e, t, n, r, i;
3135
+ },
3136
+ getPublicProperties: function() {
3137
+ return {
3138
+ coefficient: this.coefficient,
3139
+ visibleArea: this.visibleArea,
3140
+ coordinates: this.coordinates,
3141
+ boundaries: this.boundaries,
3142
+ sizeRestrictions: this.sizeRestrictions,
3143
+ positionRestrictions: this.positionRestrictions,
3144
+ aspectRatio: this.getAspectRatio(),
3145
+ imageRestriction: this.imageRestriction
3146
+ };
3147
+ },
3148
+ defaultCoordinates: function() {
3149
+ return C({}, Re);
3150
+ },
3151
+ flip: function(e, t) {
3152
+ var n = (arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}).transitions, r = n === void 0 || n;
3153
+ if (!this.transitionsActive) {
3154
+ r && this.enableTransitions();
3155
+ var i = C({}, this.imageTransforms.flip), a = ut({
3156
+ flip: {
3157
+ horizontal: e ? !i.horizontal : i.horizontal,
3158
+ vertical: t ? !i.vertical : i.vertical
3159
+ },
3160
+ previousFlip: i,
3161
+ rotate: this.imageTransforms.rotate,
3162
+ visibleArea: this.visibleArea,
3163
+ coordinates: this.coordinates,
3164
+ imageSize: this.imageSize,
3165
+ positionRestrictions: this.positionRestrictions,
3166
+ sizeRestrictions: this.sizeRestrictions,
3167
+ getAreaRestrictions: this.getAreaRestrictions,
3168
+ aspectRatio: this.getAspectRatio()
3169
+ }), o = a.visibleArea, s = a.coordinates;
3170
+ e && (this.appliedImageTransforms.flip.horizontal = !this.appliedImageTransforms.flip.horizontal), t && (this.appliedImageTransforms.flip.vertical = !this.appliedImageTransforms.flip.vertical), this.visibleArea = o, this.coordinates = s, this.onChange(), r && this.debouncedDisableTransitions();
3171
+ }
3172
+ },
3173
+ rotate: function(e) {
3174
+ var t = (arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}).transitions, n = t === void 0 || t;
3175
+ if (!this.transitionsActive) {
3176
+ n && this.enableTransitions();
3177
+ var r = C({}, this.imageSize);
3178
+ this.appliedImageTransforms.rotate += e;
3179
+ var i = lt({
3180
+ visibleArea: this.visibleArea,
3181
+ coordinates: this.coordinates,
3182
+ previousImageSize: r,
3183
+ imageSize: this.imageSize,
3184
+ angle: e,
3185
+ positionRestrictions: this.positionRestrictions,
3186
+ sizeRestrictions: this.sizeRestrictions,
3187
+ getAreaRestrictions: this.getAreaRestrictions,
3188
+ aspectRatio: this.getAspectRatio()
3189
+ }), a = i.visibleArea, o = i.coordinates, s = this.processAutoZoom("rotateImage", a, o);
3190
+ a = s.visibleArea, o = s.coordinates, this.visibleArea = a, this.coordinates = o, this.onChange(), n && this.debouncedDisableTransitions();
3191
+ }
3192
+ }
3193
+ },
3194
+ emits: [
3195
+ "change",
3196
+ "error",
3197
+ "ready"
3198
+ ]
3199
+ }, zt = {
3200
+ key: 0,
3201
+ ref: "canvas",
3202
+ style: { display: "none" }
3203
+ }, Bt = {
3204
+ key: 1,
3205
+ ref: "sourceCanvas",
3206
+ style: { display: "none" }
3207
+ };
3208
+ Rt.render = function(e, t, n, i, a, c) {
3209
+ return o(), b("div", {
3210
+ ref: "cropper",
3211
+ class: c.classes.cropper
3212
+ }, [p("div", {
3213
+ ref: "stretcher",
3214
+ class: c.classes.stretcher
3215
+ }, null, 2), p("div", {
3216
+ class: c.classes.boundaries,
3217
+ style: c.boundariesStyle
3218
+ }, [(o(), b(l(n.backgroundWrapperComponent), {
3219
+ class: c.classes.cropperWrapper,
3220
+ "wheel-resize": c.settings.resizeImage.wheel,
3221
+ "touch-resize": c.settings.resizeImage.touch,
3222
+ "touch-move": c.settings.moveImage.touch,
3223
+ "mouse-move": c.settings.moveImage.mouse,
3224
+ onMove: c.onManipulateImage,
3225
+ onResize: c.onManipulateImage
3226
+ }, {
3227
+ default: r((function() {
3228
+ return [
3229
+ p("div", {
3230
+ class: c.classes.background,
3231
+ style: c.boundariesStyle
3232
+ }, null, 6),
3233
+ p("div", { class: c.classes.imageWrapper }, [p("img", {
3234
+ ref: "image",
3235
+ crossorigin: a.imageAttributes.crossOrigin,
3236
+ src: a.imageAttributes.src,
3237
+ class: c.classes.image,
3238
+ style: c.imageStyle,
3239
+ onMousedown: t[1] ||= y((function() {}), ["prevent"])
3240
+ }, null, 46, ["crossorigin", "src"])], 2),
3241
+ p("div", {
3242
+ class: c.classes.foreground,
3243
+ style: c.boundariesStyle
3244
+ }, null, 6),
3245
+ d((o(), b(l(n.stencilComponent), s({
3246
+ ref: "stencil",
3247
+ image: c.image,
3248
+ coordinates: a.coordinates,
3249
+ "stencil-coordinates": c.stencilCoordinates,
3250
+ transitions: c.transitionsOptions
3251
+ }, n.stencilProps, {
3252
+ onResize: c.onResize,
3253
+ onResizeEnd: c.onResizeEnd,
3254
+ onMove: c.onMove,
3255
+ onMoveEnd: c.onMoveEnd
3256
+ }), null, 16, [
3257
+ "image",
3258
+ "coordinates",
3259
+ "stencil-coordinates",
3260
+ "transitions",
3261
+ "onResize",
3262
+ "onResizeEnd",
3263
+ "onMove",
3264
+ "onMoveEnd"
3265
+ ])), [[re, a.imageLoaded]]),
3266
+ n.canvas ? (o(), b("canvas", zt, null, 512)) : v("", !0),
3267
+ n.canvas ? (o(), b("canvas", Bt, null, 512)) : v("", !0)
3268
+ ];
3269
+ })),
3270
+ _: 1
3271
+ }, 8, [
3272
+ "class",
3273
+ "wheel-resize",
3274
+ "touch-resize",
3275
+ "touch-move",
3276
+ "mouse-move",
3277
+ "onMove",
3278
+ "onResize"
3279
+ ]))], 6)], 2);
3280
+ };
3281
+ //#endregion
3282
+ //#region ../media-library/src/components/media/MediaEditModal.vue?vue&type=script&setup=true&lang.ts
3283
+ var Vt = ["data-tpl-theme"], Ht = { class: "tpl:shrink-0 tpl:p-5 tpl:pb-4" }, Ut = {
3284
+ id: "tpl-media-edit-title",
3285
+ class: "tpl:text-sm tpl:font-semibold",
3286
+ style: { color: "var(--tpl-text)" }
3287
+ }, Wt = { class: "tpl:min-h-0 tpl:flex-1 tpl:overflow-y-auto tpl:px-5" }, Gt = {
3288
+ key: 0,
3289
+ class: "tpl:mb-4"
3290
+ }, Kt = {
3291
+ class: "tpl:relative tpl:mb-3 tpl:overflow-hidden tpl:rounded-md tpl:border",
3292
+ style: {
3293
+ "border-color": "var(--tpl-border)",
3294
+ height: "300px",
3295
+ "background-color": "var(--tpl-bg)"
3296
+ }
3297
+ }, qt = { class: "tpl:space-y-3" }, Jt = {
3298
+ class: "tpl:mb-1.5 tpl:block tpl:text-xs tpl:font-medium",
3299
+ style: { color: "var(--tpl-text-muted)" }
3300
+ }, Yt = { class: "tpl:flex tpl:flex-wrap tpl:gap-1.5" }, Xt = ["onClick"], Zt = { class: "tpl:flex tpl:gap-3" }, Qt = { class: "tpl:flex-1" }, $t = {
3301
+ class: "tpl:mb-1 tpl:block tpl:text-xs tpl:font-medium",
3302
+ style: { color: "var(--tpl-text-muted)" }
3303
+ }, en = {
3304
+ class: "tpl:font-normal",
3305
+ style: { color: "var(--tpl-text-dim)" }
3306
+ }, tn = { class: "tpl:relative" }, nn = ["value", "placeholder"], rn = {
3307
+ class: "tpl:absolute tpl:top-1/2 tpl:right-2.5 tpl:-translate-y-1/2 tpl:text-xs",
3308
+ style: { color: "var(--tpl-text-dim)" }
3309
+ }, an = { class: "tpl:flex-1" }, on = {
3310
+ class: "tpl:mb-1 tpl:block tpl:text-xs tpl:font-medium",
3311
+ style: { color: "var(--tpl-text-muted)" }
3312
+ }, sn = {
3313
+ class: "tpl:font-normal",
3314
+ style: { color: "var(--tpl-text-dim)" }
3315
+ }, cn = { class: "tpl:relative" }, ln = ["value", "placeholder"], un = {
3316
+ class: "tpl:absolute tpl:top-1/2 tpl:right-2.5 tpl:-translate-y-1/2 tpl:text-xs",
3317
+ style: { color: "var(--tpl-text-dim)" }
3318
+ }, dn = {
3319
+ key: 0,
3320
+ class: "tpl:flex tpl:items-center tpl:gap-1 tpl:text-xs",
3321
+ style: { color: "var(--tpl-text-muted)" }
3322
+ }, fn = {
3323
+ class: "tpl:font-medium",
3324
+ style: { color: "var(--tpl-text)" }
3325
+ }, pn = { class: "tpl:mb-3" }, mn = {
3326
+ for: "tpl-media-filename",
3327
+ class: "tpl:mb-1 tpl:block tpl:text-xs tpl:font-medium",
3328
+ style: { color: "var(--tpl-text-muted)" }
3329
+ }, hn = ["autofocus"], gn = {
3330
+ key: 1,
3331
+ class: "tpl:mb-4"
3332
+ }, _n = {
3333
+ for: "tpl-media-alt",
3334
+ class: "tpl:mb-1 tpl:block tpl:text-xs tpl:font-medium",
3335
+ style: { color: "var(--tpl-text-muted)" }
3336
+ }, vn = ["placeholder"], yn = { class: "tpl:flex tpl:shrink-0 tpl:justify-end tpl:gap-2 tpl:p-5 tpl:pt-4" }, bn = ["disabled"], xn = /*#__PURE__*/ oe(/* @__PURE__ */ u({
3337
+ __name: "MediaEditModal",
3338
+ props: {
3339
+ visible: { type: Boolean },
3340
+ item: {}
3341
+ },
3342
+ emits: ["save", "close"],
3343
+ setup(i, { emit: a }) {
3344
+ let s = i, l = a, { t: u } = ue(), re = t(le, null), oe = t(se, c(null)), _e = u.mediaLibrary, { isImageMimeType: C } = ce(), w = c(""), ve = c(""), T = c(null), E = c("free"), ye = c(void 0), be = c(void 0), D = c(""), O = c(""), k = c(void 0), A = c(null), j = c(!1), M = c(!1), N = c(!1), P = g(() => s.item ? [
3345
+ "image/jpeg",
3346
+ "image/png",
3347
+ "image/webp",
3348
+ "image/gif"
3349
+ ].includes(s.item.mimeType ?? "") : !1), xe = g(() => E.value === "original" ? k.value : fe[E.value]), F = g(() => A.value ? ge(A.value.width, A.value.height, ye.value, be.value) : null);
3350
+ e(() => s.visible, (e) => {
3351
+ e && s.item && (w.value = s.item.filename ?? "", ve.value = s.item.alt ?? "", E.value = "free", ye.value = void 0, be.value = void 0, D.value = "", O.value = "", k.value = void 0, A.value = null, j.value = !1, N.value = !1, s.item.width && s.item.height && (k.value = s.item.width / s.item.height));
3352
+ });
3353
+ function I(e) {
3354
+ e.coordinates && (A.value = {
3355
+ width: Math.round(e.coordinates.width),
3356
+ height: Math.round(e.coordinates.height)
3357
+ }, N.value = !0);
3358
+ }
3359
+ function L() {
3360
+ j.value = !0, !k.value && s.item?.width && s.item?.height && (k.value = s.item.width / s.item.height);
3361
+ }
3362
+ function Se(e) {
3363
+ let t = e.target.value;
3364
+ D.value = t, ye.value = t && parseInt(t, 10) || void 0;
3365
+ }
3366
+ function R(e) {
3367
+ let t = e.target.value;
3368
+ O.value = t, be.value = t && parseInt(t, 10) || void 0;
3369
+ }
3370
+ async function Ce() {
3371
+ let e = w.value.trim();
3372
+ if (!e || !s.item || M.value) return;
3373
+ let t = C(s.item.mimeType ?? ""), n;
3374
+ if (P.value && T.value && N.value) {
3375
+ M.value = !0;
3376
+ try {
3377
+ let { canvas: e } = T.value.getResult();
3378
+ if (e) {
3379
+ let t = me(e, ye.value, be.value), r = pe(s.item.mimeType ?? "");
3380
+ n = { file: await he(t, s.item.filename ?? "image", r) };
3381
+ }
3382
+ } catch {
3383
+ M.value = !1;
3384
+ return;
3385
+ }
3386
+ M.value = !1;
3387
+ }
3388
+ l("save", s.item.id, e, t ? ve.value : void 0, n), l("close");
3389
+ }
3390
+ let we = c(null), Te = g(() => s.visible && s.item !== null);
3391
+ de(we, Te);
3392
+ function z(e) {
3393
+ if (e.stopPropagation(), e.key === "Enter" && !M.value) {
3394
+ if (e.target?.closest("textarea, [contenteditable]")) return;
3395
+ e.preventDefault(), Ce();
3396
+ }
3397
+ e.key === "Escape" && l("close");
3398
+ }
3399
+ return (e, t) => (o(), b(h, { to: f(oe) || "body" }, [p(te, {
3400
+ "enter-active-class": "tpl:transition tpl:ease-out tpl:duration-150",
3401
+ "enter-from-class": "tpl:opacity-0",
3402
+ "enter-to-class": "tpl:opacity-100",
3403
+ "leave-active-class": "tpl:transition tpl:ease-in tpl:duration-100",
3404
+ "leave-from-class": "tpl:opacity-100",
3405
+ "leave-to-class": "tpl:opacity-0"
3406
+ }, {
3407
+ default: r(() => [i.visible && i.item ? (o(), _("div", {
3408
+ key: 0,
3409
+ "data-tpl-theme": f(re),
3410
+ class: m([f(oe) ? void 0 : "tpl", "tpl:fixed tpl:inset-0 tpl:z-10 tpl:flex tpl:items-center tpl:justify-center tpl:p-4"]),
3411
+ style: { "background-color": "var(--tpl-overlay)" },
3412
+ onClick: t[3] ||= y((e) => l("close"), ["self"]),
3413
+ onKeydown: z
3414
+ }, [x("div", {
3415
+ ref_key: "dialogRef",
3416
+ ref: we,
3417
+ role: "dialog",
3418
+ "aria-modal": "true",
3419
+ "aria-labelledby": "tpl-media-edit-title",
3420
+ class: m(["tpl:flex tpl:max-h-[90%] tpl:w-full tpl:flex-col tpl:overflow-hidden tpl:rounded-lg tpl:shadow-xl", P.value ? "tpl:max-w-2xl" : "tpl:max-w-sm"]),
3421
+ style: { "background-color": "var(--tpl-bg-elevated)" }
3422
+ }, [
3423
+ x("div", Ht, [x("h3", Ut, S(f(u).mediaLibrary.editFile), 1)]),
3424
+ x("div", Wt, [
3425
+ P.value ? (o(), _("div", Gt, [x("div", Kt, [p(f(Rt), {
3426
+ ref_key: "cropperRef",
3427
+ ref: T,
3428
+ src: i.item.url,
3429
+ "stencil-props": { aspectRatio: xe.value },
3430
+ class: "tpl:h-full tpl:w-full",
3431
+ "background-class": "tpl-cropper-background",
3432
+ onChange: I,
3433
+ onReady: L
3434
+ }, null, 8, ["src", "stencil-props"])]), x("div", qt, [
3435
+ x("div", null, [x("label", Jt, S(f(u).mediaLibrary.cropAspectRatio), 1), x("div", Yt, [(o(), _(ie, null, n([
3436
+ "free",
3437
+ "square",
3438
+ "landscape43",
3439
+ "landscape169",
3440
+ "original"
3441
+ ], (e) => x("button", {
3442
+ key: e,
3443
+ type: "button",
3444
+ class: "tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-2.5 tpl:py-1 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
3445
+ style: ee({
3446
+ borderColor: E.value === e ? "var(--tpl-primary)" : "var(--tpl-border)",
3447
+ backgroundColor: E.value === e ? "var(--tpl-primary-light)" : "var(--tpl-bg)",
3448
+ color: E.value === e ? "var(--tpl-primary)" : "var(--tpl-text)"
3449
+ }),
3450
+ onClick: (t) => E.value = e
3451
+ }, S(f(_e)[`crop${e.charAt(0).toUpperCase()}${e.slice(1)}`]), 13, Xt)), 64))])]),
3452
+ x("div", Zt, [x("div", Qt, [x("label", $t, [ae(S(f(u).mediaLibrary.cropMaxWidth) + " ", 1), x("span", en, S(f(u).mediaLibrary.cropOptional), 1)]), x("div", tn, [x("input", {
3453
+ value: D.value,
3454
+ type: "number",
3455
+ min: "1",
3456
+ class: "tpl:w-full tpl:rounded-md tpl:border tpl:py-1.5 tpl:pr-8 tpl:pl-3 tpl:text-xs tpl:outline-none",
3457
+ style: {
3458
+ "border-color": "var(--tpl-border)",
3459
+ "background-color": "var(--tpl-bg)",
3460
+ color: "var(--tpl-text)"
3461
+ },
3462
+ placeholder: A.value?.width?.toString() || "",
3463
+ onInput: Se
3464
+ }, null, 40, nn), x("span", rn, S(f(u).mediaLibrary.cropPixels), 1)])]), x("div", an, [x("label", on, [ae(S(f(u).mediaLibrary.cropMaxHeight) + " ", 1), x("span", sn, S(f(u).mediaLibrary.cropOptional), 1)]), x("div", cn, [x("input", {
3465
+ value: O.value,
3466
+ type: "number",
3467
+ min: "1",
3468
+ class: "tpl:w-full tpl:rounded-md tpl:border tpl:py-1.5 tpl:pr-8 tpl:pl-3 tpl:text-xs tpl:outline-none",
3469
+ style: {
3470
+ "border-color": "var(--tpl-border)",
3471
+ "background-color": "var(--tpl-bg)",
3472
+ color: "var(--tpl-text)"
3473
+ },
3474
+ placeholder: A.value?.height?.toString() || "",
3475
+ onInput: R
3476
+ }, null, 40, ln), x("span", un, S(f(u).mediaLibrary.cropPixels), 1)])])]),
3477
+ F.value ? (o(), _("div", dn, [x("span", null, S(f(u).mediaLibrary.cropOutputSize) + ": ", 1), x("span", fn, S(F.value.width) + " x " + S(F.value.height) + " " + S(f(u).mediaLibrary.cropPixels), 1)])) : v("", !0)
3478
+ ])])) : v("", !0),
3479
+ x("div", pn, [x("label", mn, S(f(u).mediaLibrary.fileName), 1), d(x("input", {
3480
+ id: "tpl-media-filename",
3481
+ "onUpdate:modelValue": t[0] ||= (e) => w.value = e,
3482
+ type: "text",
3483
+ class: "tpl:w-full tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:outline-none",
3484
+ style: {
3485
+ "border-color": "var(--tpl-border)",
3486
+ "background-color": "var(--tpl-bg)",
3487
+ color: "var(--tpl-text)"
3488
+ },
3489
+ autofocus: !P.value
3490
+ }, null, 8, hn), [[ne, w.value]])]),
3491
+ f(C)(i.item.mimeType ?? "") ? (o(), _("div", gn, [x("label", _n, S(f(u).mediaLibrary.altText), 1), d(x("input", {
3492
+ id: "tpl-media-alt",
3493
+ "onUpdate:modelValue": t[1] ||= (e) => ve.value = e,
3494
+ type: "text",
3495
+ class: "tpl:w-full tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:outline-none",
3496
+ style: {
3497
+ "border-color": "var(--tpl-border)",
3498
+ "background-color": "var(--tpl-bg)",
3499
+ color: "var(--tpl-text)"
3500
+ },
3501
+ placeholder: f(u).mediaLibrary.altTextPlaceholder
3502
+ }, null, 8, vn), [[ne, ve.value]])])) : v("", !0)
3503
+ ]),
3504
+ x("div", yn, [x("button", {
3505
+ class: "tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
3506
+ style: {
3507
+ "border-color": "var(--tpl-border)",
3508
+ color: "var(--tpl-text)",
3509
+ "background-color": "var(--tpl-bg)"
3510
+ },
3511
+ onClick: t[2] ||= (e) => l("close")
3512
+ }, S(f(u).mediaLibrary.cancel), 1), x("button", {
3513
+ class: "tpl:cursor-pointer tpl:rounded-md tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150 tpl:hover:bg-[var(--tpl-primary-hover)] tpl:disabled:cursor-not-allowed tpl:disabled:opacity-50",
3514
+ style: {
3515
+ "background-color": "var(--tpl-primary)",
3516
+ color: "var(--tpl-on-primary)"
3517
+ },
3518
+ disabled: M.value,
3519
+ onClick: Ce
3520
+ }, S(M.value ? f(u).mediaLibrary.saving : f(u).mediaLibrary.saveChanges), 9, bn)])
3521
+ ], 2)], 42, Vt)) : v("", !0)]),
3522
+ _: 1
3523
+ })], 8, ["to"]));
3524
+ }
3525
+ }), [["__scopeId", "data-v-6fc59551"]]);
3526
+ //#endregion
3527
+ export { xn as default };
3528
+
3529
+ //# sourceMappingURL=MediaEditModal-BBZRcYKe.js.map