vuedit-image-editor 0.2.0 → 0.3.0

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.
@@ -1,5 +1,5 @@
1
- import { reactive as je, ref as H, shallowRef as Be, computed as V, readonly as qe, provide as We, inject as Q, toRaw as Xe, markRaw as Ye, defineComponent as Y, openBlock as M, createElementBlock as z, normalizeClass as U, renderSlot as Ue, createCommentVNode as Z, toDisplayString as q, createElementVNode as g, createVNode as j, unref as S, withCtx as J, onMounted as ue, watch as ne, onBeforeUnmount as re, withModifiers as ce, createBlock as le, resolveDynamicComponent as be, onUpdated as Ne, Fragment as X, renderList as N, Transition as _e, normalizeStyle as se, onUnmounted as Ze, nextTick as Je, Teleport as Ge, withKeys as Se } from "vue";
2
- function ge() {
1
+ import { reactive as rt, ref as H, shallowRef as ct, computed as j, readonly as ut, provide as Ze, inject as ie, toRaw as dt, markRaw as ht, defineComponent as J, openBlock as S, createElementBlock as z, normalizeClass as N, renderSlot as vt, createCommentVNode as G, toDisplayString as q, createElementVNode as y, createVNode as X, unref as I, withCtx as ne, onMounted as ge, watch as re, onBeforeUnmount as he, withModifiers as ve, createBlock as pe, resolveDynamicComponent as Pe, onUpdated as ft, Fragment as Y, renderList as Z, Transition as Te, normalizeStyle as le, onUnmounted as pt, withKeys as Me, nextTick as Se, Teleport as mt } from "vue";
2
+ function $e() {
3
3
  return {
4
4
  crop: {
5
5
  x: 0,
@@ -26,6 +26,7 @@ function ge() {
26
26
  intensity: 1
27
27
  },
28
28
  stickers: [],
29
+ annotations: [],
29
30
  frame: {
30
31
  style: null,
31
32
  size: 0.025,
@@ -39,28 +40,28 @@ function ge() {
39
40
  backgroundColor: [0, 0, 0, 1]
40
41
  };
41
42
  }
42
- function de(s) {
43
- return JSON.parse(JSON.stringify(s));
43
+ function ye(o) {
44
+ return JSON.parse(JSON.stringify(o));
44
45
  }
45
- class Qe {
46
+ class gt {
46
47
  constructor(e = 50) {
47
48
  this.states = [], this.pointer = -1, this.maxSize = e;
48
49
  }
49
50
  /** Push a new state snapshot. Truncates any future (redo) states. */
50
51
  push(e) {
51
- this.states = this.states.slice(0, this.pointer + 1), this.states.push(de(e)), this.states.length > this.maxSize && this.states.shift(), this.pointer = this.states.length - 1;
52
+ this.states = this.states.slice(0, this.pointer + 1), this.states.push(ye(e)), this.states.length > this.maxSize && this.states.shift(), this.pointer = this.states.length - 1;
52
53
  }
53
54
  /** Undo: return the previous state, or null if at the beginning. */
54
55
  undo() {
55
- return this.pointer <= 0 ? null : (this.pointer--, de(this.states[this.pointer]));
56
+ return this.pointer <= 0 ? null : (this.pointer--, ye(this.states[this.pointer]));
56
57
  }
57
58
  /** Redo: return the next state, or null if at the end. */
58
59
  redo() {
59
- return this.pointer >= this.states.length - 1 ? null : (this.pointer++, de(this.states[this.pointer]));
60
+ return this.pointer >= this.states.length - 1 ? null : (this.pointer++, ye(this.states[this.pointer]));
60
61
  }
61
62
  /** Reset history with a single initial state. */
62
63
  reset(e) {
63
- this.states = [de(e)], this.pointer = 0;
64
+ this.states = [ye(e)], this.pointer = 0;
64
65
  }
65
66
  get canUndo() {
66
67
  return this.pointer > 0;
@@ -75,122 +76,172 @@ class Qe {
75
76
  return this.states.length;
76
77
  }
77
78
  }
78
- async function et(s) {
79
- const e = await tt(s);
79
+ async function yt(o) {
80
+ const e = await wt(o);
80
81
  return new Promise((n, t) => {
81
- const o = new Image();
82
- o.crossOrigin = "anonymous", o.onload = () => {
83
- typeof s != "string" && URL.revokeObjectURL(e), n(o);
84
- }, o.onerror = () => {
85
- typeof s != "string" && URL.revokeObjectURL(e), t(new Error(`Failed to load image: ${typeof s == "string" ? s : "Blob/File"}`));
86
- }, o.src = e;
82
+ const a = new Image();
83
+ a.crossOrigin = "anonymous", a.onload = () => {
84
+ typeof o != "string" && URL.revokeObjectURL(e), n(a);
85
+ }, a.onerror = () => {
86
+ typeof o != "string" && URL.revokeObjectURL(e), t(new Error(`Failed to load image: ${typeof o == "string" ? o : "Blob/File"}`));
87
+ }, a.src = e;
87
88
  });
88
89
  }
89
- async function tt(s) {
90
- return typeof s == "string" ? s : URL.createObjectURL(s);
90
+ async function wt(o) {
91
+ return typeof o == "string" ? o : URL.createObjectURL(o);
91
92
  }
92
- const Ke = Symbol("vuedit-image-editor"), ee = Symbol("vuedit-locale");
93
- function he(s) {
94
- return JSON.parse(JSON.stringify(Xe(s)));
93
+ const Je = Symbol("vuedit-image-editor"), oe = Symbol("vuedit-locale");
94
+ function we(o) {
95
+ return JSON.parse(JSON.stringify(dt(o)));
95
96
  }
96
- function nt(s) {
97
- const e = je(
98
- s.initialState ? { ...ge(), ...JSON.parse(JSON.stringify(s.initialState)) } : ge()
99
- ), n = he(e), t = new Qe(50);
100
- t.reset(he(e));
101
- const o = H(null), d = H(!1), u = H(null);
102
- let r = 0;
103
- const i = Be([]), h = H(null), a = H(1), c = H(null), y = H({ x: 0, y: 0 }), v = H(0), w = V(() => h.value && i.value.find((P) => P.id === h.value) || null), b = V(() => (v.value, t.canUndo)), $ = V(() => (v.value, t.canRedo)), m = V(() => (v.value, t.currentIndex > 0));
104
- async function l(P) {
105
- const O = ++r;
106
- d.value = !0, u.value = null;
97
+ function kt(o) {
98
+ const e = rt(
99
+ o.initialState ? { ...$e(), ...JSON.parse(JSON.stringify(o.initialState)) } : $e()
100
+ ), n = we(e), t = new gt(50);
101
+ t.reset(we(e));
102
+ const a = H(null), h = H(!1), r = H(null);
103
+ let s = 0;
104
+ const i = ct([]), v = H(null), l = H(1), c = H(null), m = H({ x: 0, y: 0 }), d = H(0), x = j(() => v.value && i.value.find((E) => E.id === v.value) || null), _ = j(() => (d.value, t.canUndo)), $ = j(() => (d.value, t.canRedo)), w = j(() => (d.value, t.currentIndex > 0));
105
+ async function u(E) {
106
+ const O = ++s;
107
+ h.value = !0, r.value = null;
107
108
  try {
108
- const _ = await et(P);
109
- if (O !== r) return;
110
- o.value = _, W();
111
- } catch (_) {
112
- if (O !== r) return;
113
- u.value = _ instanceof Error ? _.message : "Failed to load image";
109
+ const M = await yt(E);
110
+ if (O !== s) return;
111
+ a.value = M, L();
112
+ } catch (M) {
113
+ if (O !== s) return;
114
+ r.value = M instanceof Error ? M.message : "Failed to load image";
114
115
  } finally {
115
- O === r && (d.value = !1);
116
+ O === s && (h.value = !1);
116
117
  }
117
118
  }
118
- function p(P) {
119
- if (!P.id || !P.controls) {
120
- console.warn("[VueditImageEditor] Plugin missing required fields (id, controls):", P);
119
+ function g(E) {
120
+ if (!E.id || !E.controls) {
121
+ console.warn("[VueditImageEditor] Plugin missing required fields (id, controls):", E);
121
122
  return;
122
123
  }
123
- i.value.some((O) => O.id === P.id) || (i.value = [...i.value, Ye(P)], h.value || (h.value = P.id));
124
+ i.value.some((O) => O.id === E.id) || (i.value = [...i.value, ht(E)], v.value || (v.value = E.id));
124
125
  }
125
- function f(P) {
126
+ function k(E) {
126
127
  var O;
127
- i.value = i.value.filter((_) => _.id !== P), h.value === P && (h.value = ((O = i.value[0]) == null ? void 0 : O.id) || null);
128
+ i.value = i.value.filter((M) => M.id !== E), v.value === E && (v.value = ((O = i.value[0]) == null ? void 0 : O.id) || null);
128
129
  }
129
- function k(P) {
130
- const O = w.value;
131
- O != null && O.onDeactivate && O.onDeactivate(), h.value = P;
132
- const _ = i.value.find((A) => A.id === P);
133
- _ != null && _.onActivate && _.onActivate(), W();
130
+ function C(E) {
131
+ const O = x.value;
132
+ O != null && O.onDeactivate && O.onDeactivate(), v.value = E;
133
+ const M = i.value.find((F) => F.id === E);
134
+ M != null && M.onActivate && M.onActivate(), L();
134
135
  }
135
- function x(P) {
136
- P(e), t.push(he(e)), v.value++, W();
136
+ function P(E) {
137
+ E(e), t.push(we(e)), d.value++, L();
137
138
  }
138
- function D() {
139
- const P = t.undo();
140
- P && (Object.assign(e, P), v.value++, W());
139
+ function V() {
140
+ const E = t.undo();
141
+ E && (Object.assign(e, E), d.value++, L());
141
142
  }
142
- function T() {
143
- const P = t.redo();
144
- P && (Object.assign(e, P), v.value++, W());
143
+ function A() {
144
+ const E = t.redo();
145
+ E && (Object.assign(e, E), d.value++, L());
145
146
  }
146
- function K() {
147
- const P = w.value;
148
- P != null && P.onDeactivate && P.onDeactivate(), Object.assign(e, JSON.parse(JSON.stringify(n))), t.reset(he(e)), v.value++, P != null && P.onActivate && P.onActivate(), W();
147
+ function D() {
148
+ const E = x.value;
149
+ E != null && E.onDeactivate && E.onDeactivate(), Object.assign(e, JSON.parse(JSON.stringify(n))), t.reset(we(e)), d.value++, E != null && E.onActivate && E.onActivate(), L();
149
150
  }
150
- function L(P) {
151
- a.value = Math.max(0.1, Math.min(10, P)), W();
151
+ function K(E) {
152
+ l.value = Math.max(0.1, Math.min(10, E)), L();
152
153
  }
153
- function W() {
154
- c.value && c.value();
154
+ function L(E = !1) {
155
+ c.value && c.value(E);
155
156
  }
156
157
  return {
157
158
  state: e,
158
- readonlyState: qe(e),
159
- sourceImage: o,
160
- loading: d,
161
- error: u,
159
+ readonlyState: ut(e),
160
+ sourceImage: a,
161
+ loading: h,
162
+ error: r,
162
163
  plugins: i,
163
- activePluginId: h,
164
- activePlugin: w,
165
- hasEdits: m,
166
- canUndo: b,
164
+ activePluginId: v,
165
+ activePlugin: x,
166
+ hasEdits: w,
167
+ canUndo: _,
167
168
  canRedo: $,
168
- zoom: a,
169
- options: s,
170
- load: l,
171
- registerPlugin: p,
172
- unregisterPlugin: f,
173
- setActivePlugin: k,
174
- updateState: x,
175
- undo: D,
176
- redo: T,
177
- revert: K,
178
- setZoom: L,
179
- requestRender: W,
169
+ zoom: l,
170
+ options: o,
171
+ load: u,
172
+ registerPlugin: g,
173
+ unregisterPlugin: k,
174
+ setActivePlugin: C,
175
+ updateState: P,
176
+ undo: V,
177
+ redo: A,
178
+ revert: D,
179
+ setZoom: K,
180
+ requestRender: L,
180
181
  onRender: c,
181
- cropDragPan: y
182
+ cropDragPan: m
182
183
  };
183
184
  }
184
- function it(s) {
185
- We(Ke, s);
185
+ function bt(o) {
186
+ Ze(Je, o);
186
187
  }
187
- function G() {
188
- const s = Q(Ke);
189
- if (!s)
188
+ function ee() {
189
+ const o = ie(Je);
190
+ if (!o)
190
191
  throw new Error("[VueditImageEditor] useEditor() called outside of editor context. Make sure to use it inside <EditorShell> or <ImageEditorModal>.");
191
- return s;
192
+ return o;
192
193
  }
193
- const xe = [
194
+ function De(o) {
195
+ return `rgba(${Math.round(o[0] * 255)}, ${Math.round(o[1] * 255)}, ${Math.round(o[2] * 255)}, ${o[3]})`;
196
+ }
197
+ function Ee(o, e, n, t, a, h) {
198
+ const r = n + e.x * a, s = t + e.y * h, i = e.width * a, v = e.height * h, l = e.strokeWidth * Math.max(a, h);
199
+ if (o.save(), o.globalAlpha = e.opacity, e.rotation !== 0) {
200
+ const w = r + i / 2, u = s + v / 2;
201
+ o.translate(w, u), o.rotate(e.rotation), o.translate(-w, -u);
202
+ }
203
+ const c = e.fontSize * h, m = e.fontStyle === "italic" ? "italic " : "", d = e.fontWeight === "bold" ? "bold " : "";
204
+ o.font = `${m}${d}${c}px ${e.fontFamily}`, o.fillStyle = De(e.fillColor), o.textAlign = e.textAlign, o.textBaseline = "top", o.save(), o.beginPath(), o.rect(r, s, i, v), o.clip();
205
+ let x = r;
206
+ e.textAlign === "center" ? x = r + i / 2 : e.textAlign === "right" && (x = r + i);
207
+ const _ = Ct(o, e.text, i), $ = c * 1.2;
208
+ for (let w = 0; w < _.length; w++)
209
+ o.fillText(_[w], x, s + w * $);
210
+ o.restore(), e.strokeColor[3] > 0 && l > 0.5 && (o.strokeStyle = De(e.strokeColor), o.lineWidth = l * 0.5, o.strokeRect(r, s, i, v)), o.restore();
211
+ }
212
+ function xt(o, e, n, t, a, h, r) {
213
+ if (n.width <= 0 || n.height <= 0) return;
214
+ const s = _t(e, n);
215
+ s && Ee(o, s, t, a, h, r);
216
+ }
217
+ function _t(o, e) {
218
+ const n = (o.x - e.x) / e.width, t = (o.y - e.y) / e.height, a = o.width / e.width, h = o.height / e.height;
219
+ return n + a < 0 || n > 1 || t + h < 0 || t > 1 ? null : {
220
+ ...o,
221
+ x: n,
222
+ y: t,
223
+ width: a,
224
+ height: h,
225
+ strokeWidth: o.strokeWidth / Math.max(e.width, e.height),
226
+ fontSize: o.fontSize / e.height
227
+ };
228
+ }
229
+ function Ct(o, e, n) {
230
+ if (!e) return [""];
231
+ const t = e.split(`
232
+ `), a = [];
233
+ for (const h of t) {
234
+ const r = h.split(" ");
235
+ let s = "";
236
+ for (const i of r) {
237
+ const v = s ? `${s} ${i}` : i;
238
+ o.measureText(v).width > n && s ? (a.push(s), s = i) : s = v;
239
+ }
240
+ a.push(s);
241
+ }
242
+ return a;
243
+ }
244
+ const We = [
194
245
  1,
195
246
  0,
196
247
  0,
@@ -212,41 +263,41 @@ const xe = [
212
263
  1,
213
264
  0
214
265
  ];
215
- function ot(s, e) {
266
+ function Mt(o, e) {
216
267
  const n = new Array(20).fill(0);
217
268
  for (let t = 0; t < 4; t++)
218
- for (let o = 0; o < 5; o++) {
219
- let d = 0;
220
- for (let u = 0; u < 4; u++)
221
- d += s[t * 5 + u] * e[u * 5 + o];
222
- o === 4 && (d += s[t * 5 + 4]), n[t * 5 + o] = d;
269
+ for (let a = 0; a < 5; a++) {
270
+ let h = 0;
271
+ for (let r = 0; r < 4; r++)
272
+ h += o[t * 5 + r] * e[r * 5 + a];
273
+ a === 4 && (h += o[t * 5 + 4]), n[t * 5 + a] = h;
223
274
  }
224
275
  return n;
225
276
  }
226
- function De(...s) {
227
- if (s.length === 0) return [...xe];
228
- let e = s[0];
229
- for (let n = 1; n < s.length; n++)
230
- e = ot(s[n], e);
277
+ function Ge(...o) {
278
+ if (o.length === 0) return [...We];
279
+ let e = o[0];
280
+ for (let n = 1; n < o.length; n++)
281
+ e = Mt(o[n], e);
231
282
  return e;
232
283
  }
233
- function Le(s) {
284
+ function Qe(o) {
234
285
  return [
235
286
  1,
236
287
  0,
237
288
  0,
238
289
  0,
239
- s,
290
+ o,
240
291
  0,
241
292
  1,
242
293
  0,
243
294
  0,
244
- s,
295
+ o,
245
296
  0,
246
297
  0,
247
298
  1,
248
299
  0,
249
- s,
300
+ o,
250
301
  0,
251
302
  0,
252
303
  0,
@@ -254,8 +305,8 @@ function Le(s) {
254
305
  0
255
306
  ];
256
307
  }
257
- function Ae(s) {
258
- const e = s + 1, n = -0.5 * e + 0.5;
308
+ function et(o) {
309
+ const e = o + 1, n = -0.5 * e + 0.5;
259
310
  return [
260
311
  e,
261
312
  0,
@@ -279,22 +330,22 @@ function Ae(s) {
279
330
  0
280
331
  ];
281
332
  }
282
- function Fe(s) {
283
- const e = s + 1, n = 1 - e, t = 0.2126 * n, o = 0.7152 * n, d = 0.0722 * n;
333
+ function tt(o) {
334
+ const e = o + 1, n = 1 - e, t = 0.2126 * n, a = 0.7152 * n, h = 0.0722 * n;
284
335
  return [
285
336
  t + e,
286
- o,
287
- d,
337
+ a,
338
+ h,
288
339
  0,
289
340
  0,
290
341
  t,
291
- o + e,
292
- d,
342
+ a + e,
343
+ h,
293
344
  0,
294
345
  0,
295
346
  t,
296
- o,
297
- d + e,
347
+ a,
348
+ h + e,
298
349
  0,
299
350
  0,
300
351
  0,
@@ -304,8 +355,8 @@ function Fe(s) {
304
355
  0
305
356
  ];
306
357
  }
307
- function He(s) {
308
- const e = Math.pow(2, s);
358
+ function nt(o) {
359
+ const e = Math.pow(2, o);
309
360
  return [
310
361
  e,
311
362
  0,
@@ -329,9 +380,9 @@ function He(s) {
329
380
  0
330
381
  ];
331
382
  }
332
- function Ve(s) {
383
+ function it(o) {
333
384
  return [
334
- 1 + s,
385
+ 1 + o,
335
386
  0,
336
387
  0,
337
388
  0,
@@ -343,7 +394,7 @@ function Ve(s) {
343
394
  0,
344
395
  0,
345
396
  0,
346
- 1 - s,
397
+ 1 - o,
347
398
  0,
348
399
  0,
349
400
  0,
@@ -353,194 +404,196 @@ function Ve(s) {
353
404
  0
354
405
  ];
355
406
  }
356
- function Ce(s, e) {
357
- const n = s.data, t = n.length, o = e[0], d = e[1], u = e[2], r = e[3], i = e[4] * 255, h = e[5], a = e[6], c = e[7], y = e[8], v = e[9] * 255, w = e[10], b = e[11], $ = e[12], m = e[13], l = e[14] * 255, p = e[15], f = e[16], k = e[17], x = e[18], D = e[19] * 255;
358
- for (let T = 0; T < t; T += 4) {
359
- const K = n[T], L = n[T + 1], W = n[T + 2], P = n[T + 3];
360
- n[T] = ie(K * o + L * d + W * u + P * r + i), n[T + 1] = ie(K * h + L * a + W * c + P * y + v), n[T + 2] = ie(K * w + L * b + W * $ + P * m + l), n[T + 3] = ie(K * p + L * f + W * k + P * x + D);
407
+ function Ae(o, e) {
408
+ const n = o.data, t = n.length, a = e[0], h = e[1], r = e[2], s = e[3], i = e[4] * 255, v = e[5], l = e[6], c = e[7], m = e[8], d = e[9] * 255, x = e[10], _ = e[11], $ = e[12], w = e[13], u = e[14] * 255, g = e[15], k = e[16], C = e[17], P = e[18], V = e[19] * 255;
409
+ for (let A = 0; A < t; A += 4) {
410
+ const D = n[A], K = n[A + 1], L = n[A + 2], E = n[A + 3];
411
+ n[A] = ce(D * a + K * h + L * r + E * s + i), n[A + 1] = ce(D * v + K * l + L * c + E * m + d), n[A + 2] = ce(D * x + K * _ + L * $ + E * w + u), n[A + 3] = ce(D * g + K * k + L * C + E * P + V);
361
412
  }
362
413
  }
363
- function ye(s, e) {
414
+ function Re(o, e) {
364
415
  if (e === 1) return;
365
- const n = s.data, t = 1 / e, o = new Uint8Array(256);
366
- for (let d = 0; d < 256; d++)
367
- o[d] = ie(Math.pow(d / 255, t) * 255);
368
- for (let d = 0; d < n.length; d += 4)
369
- n[d] = o[n[d]], n[d + 1] = o[n[d + 1]], n[d + 2] = o[n[d + 2]];
416
+ const n = o.data, t = 1 / e, a = new Uint8Array(256);
417
+ for (let h = 0; h < 256; h++)
418
+ a[h] = ce(Math.pow(h / 255, t) * 255);
419
+ for (let h = 0; h < n.length; h += 4)
420
+ n[h] = a[n[h]], n[h + 1] = a[n[h + 1]], n[h + 2] = a[n[h + 2]];
370
421
  }
371
- function we(s, e, n, t) {
422
+ function ze(o, e, n, t) {
372
423
  if (e === 0) return;
373
- const o = s.data, d = n / 2, u = t / 2, r = Math.sqrt(d * d + u * u);
424
+ const a = o.data, h = n / 2, r = t / 2, s = Math.sqrt(h * h + r * r);
374
425
  for (let i = 0; i < t; i++)
375
- for (let h = 0; h < n; h++) {
376
- const a = (i * n + h) * 4, c = h - d, y = i - u, v = Math.sqrt(c * c + y * y) / r, w = 1 - e * v * v;
377
- o[a] = ie(o[a] * w), o[a + 1] = ie(o[a + 1] * w), o[a + 2] = ie(o[a + 2] * w);
426
+ for (let v = 0; v < n; v++) {
427
+ const l = (i * n + v) * 4, c = v - h, m = i - r, d = Math.sqrt(c * c + m * m) / s, x = 1 - e * d * d;
428
+ a[l] = ce(a[l] * x), a[l + 1] = ce(a[l + 1] * x), a[l + 2] = ce(a[l + 2] * x);
378
429
  }
379
430
  }
380
- function ke(s, e) {
431
+ function Ie(o, e) {
381
432
  if (e === 0) return;
382
- const { data: n, width: t, height: o } = s, d = e * 4, u = new Uint8ClampedArray(n);
383
- for (let r = 1; r < o - 1; r++)
433
+ const { data: n, width: t, height: a } = o, h = e * 4, r = new Uint8ClampedArray(n);
434
+ for (let s = 1; s < a - 1; s++)
384
435
  for (let i = 1; i < t - 1; i++) {
385
- const h = (r * t + i) * 4;
386
- for (let a = 0; a < 3; a++) {
387
- const c = u[h + a], y = c * 4 - u[((r - 1) * t + i) * 4 + a] - u[((r + 1) * t + i) * 4 + a] - u[(r * t + (i - 1)) * 4 + a] - u[(r * t + (i + 1)) * 4 + a], v = c + d * y;
388
- n[h + a] = v < 0 ? 0 : v > 255 ? 255 : v + 0.5 | 0;
436
+ const v = (s * t + i) * 4;
437
+ for (let l = 0; l < 3; l++) {
438
+ const c = r[v + l], m = c * 4 - r[((s - 1) * t + i) * 4 + l] - r[((s + 1) * t + i) * 4 + l] - r[(s * t + (i - 1)) * 4 + l] - r[(s * t + (i + 1)) * 4 + l], d = c + h * m;
439
+ n[v + l] = d < 0 ? 0 : d > 255 ? 255 : d + 0.5 | 0;
389
440
  }
390
441
  }
391
442
  }
392
- function ie(s) {
393
- return s < 0 ? 0 : s > 255 ? 255 : s + 0.5 | 0;
443
+ function ce(o) {
444
+ return o < 0 ? 0 : o > 255 ? 255 : o + 0.5 | 0;
394
445
  }
395
- const at = 16777216;
396
- class st {
446
+ const St = 16777216;
447
+ class $t {
397
448
  /**
398
449
  * Process image at FULL RESOLUTION.
399
450
  * Applies all transformations and exports as Blob.
400
451
  */
401
452
  async process(e, n, t = {}) {
402
453
  const {
403
- mimeType: o = "image/jpeg",
404
- quality: d = 0.92,
405
- maxCanvasPixels: u = at
406
- } = t, r = n.crop, i = n.finetune;
407
- let h = Math.round(r.x * e.naturalWidth), a = Math.round(r.y * e.naturalHeight), c = Math.round(r.width * e.naturalWidth), y = Math.round(r.height * e.naturalHeight);
408
- h = Math.max(0, Math.min(h, e.naturalWidth)), a = Math.max(0, Math.min(a, e.naturalHeight)), c = Math.min(c, e.naturalWidth - h), y = Math.min(y, e.naturalHeight - a);
409
- let v = c, w = y;
454
+ mimeType: a = "image/jpeg",
455
+ quality: h = 0.92,
456
+ maxCanvasPixels: r = St
457
+ } = t, s = n.crop, i = n.finetune;
458
+ let v = Math.round(s.x * e.naturalWidth), l = Math.round(s.y * e.naturalHeight), c = Math.round(s.width * e.naturalWidth), m = Math.round(s.height * e.naturalHeight);
459
+ v = Math.max(0, Math.min(v, e.naturalWidth)), l = Math.max(0, Math.min(l, e.naturalHeight)), c = Math.min(c, e.naturalWidth - v), m = Math.min(m, e.naturalHeight - l);
460
+ let d = c, x = m;
410
461
  if (n.resize.width || n.resize.height) {
411
- const T = n.resize.width, K = n.resize.height, L = n.resize.fit;
412
- if (T && K)
413
- if (L === "force")
414
- v = T, w = K;
415
- else if (L === "cover") {
416
- const W = Math.max(T / c, K / y);
417
- v = Math.round(c * W), w = Math.round(y * W);
462
+ const A = n.resize.width, D = n.resize.height, K = n.resize.fit;
463
+ if (A && D)
464
+ if (K === "force")
465
+ d = A, x = D;
466
+ else if (K === "cover") {
467
+ const L = Math.max(A / c, D / m);
468
+ d = Math.round(c * L), x = Math.round(m * L);
418
469
  } else {
419
- const W = Math.min(T / c, K / y);
420
- v = Math.round(c * W), w = Math.round(y * W);
470
+ const L = Math.min(A / c, D / m);
471
+ d = Math.round(c * L), x = Math.round(m * L);
421
472
  }
422
- else if (T) {
423
- const W = T / c;
424
- v = T, w = Math.round(y * W);
425
- } else if (K) {
426
- const W = K / y;
427
- v = Math.round(c * W), w = K;
473
+ else if (A) {
474
+ const L = A / c;
475
+ d = A, x = Math.round(m * L);
476
+ } else if (D) {
477
+ const L = D / m;
478
+ d = Math.round(c * L), x = D;
428
479
  }
429
- n.resize.upscale || (v = Math.min(v, c), w = Math.min(w, y));
480
+ n.resize.upscale || (d = Math.min(d, c), x = Math.min(x, m));
430
481
  }
431
- const b = v * w;
432
- if (b > u) {
433
- const T = Math.sqrt(u / b);
434
- v = Math.floor(v * T), w = Math.floor(w * T);
482
+ const _ = d * x;
483
+ if (_ > r) {
484
+ const A = Math.sqrt(r / _);
485
+ d = Math.floor(d * A), x = Math.floor(x * A);
435
486
  }
436
- v = Math.max(1, v), w = Math.max(1, w);
437
- const $ = Math.abs(r.rotation);
438
- let m = v, l = w;
487
+ d = Math.max(1, d), x = Math.max(1, x);
488
+ const $ = Math.abs(s.rotation);
489
+ let w = d, u = x;
439
490
  if ($ > 1e-3) {
440
- const T = Math.abs(Math.cos(r.rotation)), K = Math.abs(Math.sin(r.rotation));
441
- m = Math.ceil(v * T + w * K), l = Math.ceil(v * K + w * T);
491
+ const A = Math.abs(Math.cos(s.rotation)), D = Math.abs(Math.sin(s.rotation));
492
+ w = Math.ceil(d * A + x * D), u = Math.ceil(d * D + x * A);
442
493
  }
443
- const p = document.createElement("canvas");
444
- p.width = m, p.height = l;
445
- const f = p.getContext("2d"), k = n.backgroundColor;
446
- k[3] > 0 && (f.fillStyle = `rgba(${Math.round(k[0] * 255)}, ${Math.round(k[1] * 255)}, ${Math.round(k[2] * 255)}, ${k[3]})`, f.fillRect(0, 0, m, l)), f.save(), f.translate(m / 2, l / 2), f.rotate(r.rotation), f.scale(r.flipX ? -1 : 1, r.flipY ? -1 : 1), f.drawImage(
494
+ const g = document.createElement("canvas");
495
+ g.width = w, g.height = u;
496
+ const k = g.getContext("2d"), C = n.backgroundColor;
497
+ C[3] > 0 && (k.fillStyle = `rgba(${Math.round(C[0] * 255)}, ${Math.round(C[1] * 255)}, ${Math.round(C[2] * 255)}, ${C[3]})`, k.fillRect(0, 0, w, u)), k.save(), k.translate(w / 2, u / 2), k.rotate(s.rotation), k.scale(s.flipX ? -1 : 1, s.flipY ? -1 : 1), k.drawImage(
447
498
  e,
448
- h,
449
- a,
450
- c,
451
- y,
452
- -v / 2,
453
- -w / 2,
454
499
  v,
455
- w
456
- ), f.restore();
457
- const x = [];
458
- if (i.brightness !== 0 && x.push(Le(i.brightness)), i.contrast !== 0 && x.push(Ae(i.contrast)), i.saturation !== 0 && x.push(Fe(i.saturation)), i.exposure !== 0 && x.push(He(i.exposure)), i.temperature !== 0 && x.push(Ve(i.temperature)), n.filter.matrix)
500
+ l,
501
+ c,
502
+ m,
503
+ -d / 2,
504
+ -x / 2,
505
+ d,
506
+ x
507
+ ), k.restore();
508
+ const P = [];
509
+ if (i.brightness !== 0 && P.push(Qe(i.brightness)), i.contrast !== 0 && P.push(et(i.contrast)), i.saturation !== 0 && P.push(tt(i.saturation)), i.exposure !== 0 && P.push(nt(i.exposure)), i.temperature !== 0 && P.push(it(i.temperature)), n.filter.matrix)
459
510
  if (n.filter.intensity < 1) {
460
- const T = n.filter.matrix, K = n.filter.intensity, L = xe.map((W, P) => W * (1 - K) + T[P] * K);
461
- x.push(L);
511
+ const A = n.filter.matrix, D = n.filter.intensity, K = We.map((L, E) => L * (1 - D) + A[E] * D);
512
+ P.push(K);
462
513
  } else
463
- x.push(n.filter.matrix);
464
- if (x.length > 0) {
465
- const T = De(...x), K = f.getImageData(0, 0, m, l);
466
- Ce(K, T), i.gamma !== 1 && ye(K, i.gamma), i.clarity !== 0 && ke(K, i.clarity), i.vignette !== 0 && we(K, i.vignette, m, l), f.putImageData(K, 0, 0);
514
+ P.push(n.filter.matrix);
515
+ if (P.length > 0) {
516
+ const A = Ge(...P), D = k.getImageData(0, 0, w, u);
517
+ Ae(D, A), i.gamma !== 1 && Re(D, i.gamma), i.clarity !== 0 && Ie(D, i.clarity), i.vignette !== 0 && ze(D, i.vignette, w, u), k.putImageData(D, 0, 0);
467
518
  } else if (i.gamma !== 1 || i.clarity !== 0 || i.vignette !== 0) {
468
- const T = f.getImageData(0, 0, m, l);
469
- i.gamma !== 1 && ye(T, i.gamma), i.clarity !== 0 && ke(T, i.clarity), i.vignette !== 0 && we(T, i.vignette, m, l), f.putImageData(T, 0, 0);
470
- }
471
- n.frame.style && rt(f, n.frame.style, n.frame.size, n.frame.color, n.frame.radius, m, l);
472
- for (const T of n.stickers)
473
- await ct(f, T, m, l);
519
+ const A = k.getImageData(0, 0, w, u);
520
+ i.gamma !== 1 && Re(A, i.gamma), i.clarity !== 0 && Ie(A, i.clarity), i.vignette !== 0 && ze(A, i.vignette, w, u), k.putImageData(A, 0, 0);
521
+ }
522
+ n.frame.style && Rt(k, n.frame.style, n.frame.size, n.frame.color, n.frame.radius, w, u);
523
+ for (const A of n.stickers)
524
+ await It(k, A, w, u);
525
+ for (const A of n.annotations)
526
+ Ee(k, A, 0, 0, w, u);
474
527
  return {
475
- blob: await new Promise((T, K) => {
476
- p.toBlob(
477
- (L) => L ? T(L) : K(new Error("Failed to encode image")),
478
- o,
479
- d
528
+ blob: await new Promise((A, D) => {
529
+ g.toBlob(
530
+ (K) => K ? A(K) : D(new Error("Failed to encode image")),
531
+ a,
532
+ h
480
533
  );
481
534
  }),
482
535
  imageState: JSON.parse(JSON.stringify(n))
483
536
  };
484
537
  }
485
538
  }
486
- function rt(s, e, n, t, o, d, u) {
487
- const r = Math.round(Math.max(d, u) * n), i = Math.round(o), h = `rgba(${Math.round(t[0] * 255)}, ${Math.round(t[1] * 255)}, ${Math.round(t[2] * 255)}, ${t[3]})`;
488
- switch (s.strokeStyle = h, s.fillStyle = h, e) {
539
+ function Rt(o, e, n, t, a, h, r) {
540
+ const s = Math.round(Math.max(h, r) * n), i = Math.round(a), v = `rgba(${Math.round(t[0] * 255)}, ${Math.round(t[1] * 255)}, ${Math.round(t[2] * 255)}, ${t[3]})`;
541
+ switch (o.strokeStyle = v, o.fillStyle = v, e) {
489
542
  case "solidSharp":
490
- s.lineWidth = r, s.strokeRect(r / 2, r / 2, d - r, u - r);
543
+ o.lineWidth = s, o.strokeRect(s / 2, s / 2, h - s, r - s);
491
544
  break;
492
545
  case "solidRound":
493
- s.lineWidth = r, lt(s, r / 2, r / 2, d - r, u - r, i + r / 2), s.stroke();
546
+ o.lineWidth = s, zt(o, s / 2, s / 2, h - s, r - s, i + s / 2), o.stroke();
494
547
  break;
495
548
  case "lineSingle": {
496
- const a = r * 2;
497
- s.lineWidth = 1, s.strokeRect(a, a, d - a * 2, u - a * 2);
549
+ const l = s * 2;
550
+ o.lineWidth = 1, o.strokeRect(l, l, h - l * 2, r - l * 2);
498
551
  break;
499
552
  }
500
553
  case "lineMultiple": {
501
- s.lineWidth = 1;
502
- for (let a = 1; a <= 3; a++) {
503
- const c = r * a;
504
- s.strokeRect(c, c, d - c * 2, u - c * 2);
554
+ o.lineWidth = 1;
555
+ for (let l = 1; l <= 3; l++) {
556
+ const c = s * l;
557
+ o.strokeRect(c, c, h - c * 2, r - c * 2);
505
558
  }
506
559
  break;
507
560
  }
508
561
  case "hook": {
509
- const a = Math.min(d, u) * 0.1;
510
- s.lineWidth = r * 0.5;
511
- const c = r;
512
- s.beginPath(), s.moveTo(c, c + a), s.lineTo(c, c), s.lineTo(c + a, c), s.stroke(), s.beginPath(), s.moveTo(d - c - a, c), s.lineTo(d - c, c), s.lineTo(d - c, c + a), s.stroke(), s.beginPath(), s.moveTo(c, u - c - a), s.lineTo(c, u - c), s.lineTo(c + a, u - c), s.stroke(), s.beginPath(), s.moveTo(d - c - a, u - c), s.lineTo(d - c, u - c), s.lineTo(d - c, u - c - a), s.stroke();
562
+ const l = Math.min(h, r) * 0.1;
563
+ o.lineWidth = s * 0.5;
564
+ const c = s;
565
+ o.beginPath(), o.moveTo(c, c + l), o.lineTo(c, c), o.lineTo(c + l, c), o.stroke(), o.beginPath(), o.moveTo(h - c - l, c), o.lineTo(h - c, c), o.lineTo(h - c, c + l), o.stroke(), o.beginPath(), o.moveTo(c, r - c - l), o.lineTo(c, r - c), o.lineTo(c + l, r - c), o.stroke(), o.beginPath(), o.moveTo(h - c - l, r - c), o.lineTo(h - c, r - c), o.lineTo(h - c, r - c - l), o.stroke();
513
566
  break;
514
567
  }
515
568
  case "polaroid": {
516
- const a = r, c = r * 4;
517
- s.fillRect(0, 0, d, a), s.fillRect(0, 0, a, u), s.fillRect(d - a, 0, a, u), s.fillRect(0, u - c, d, c);
569
+ const l = s, c = s * 4;
570
+ o.fillRect(0, 0, h, l), o.fillRect(0, 0, l, r), o.fillRect(h - l, 0, l, r), o.fillRect(0, r - c, h, c);
518
571
  break;
519
572
  }
520
573
  default:
521
- s.lineWidth = r * 0.5, s.strokeRect(r, r, d - r * 2, u - r * 2);
574
+ o.lineWidth = s * 0.5, o.strokeRect(s, s, h - s * 2, r - s * 2);
522
575
  break;
523
576
  }
524
577
  }
525
- function lt(s, e, n, t, o, d) {
526
- s.beginPath(), s.moveTo(e + d, n), s.lineTo(e + t - d, n), s.arcTo(e + t, n, e + t, n + d, d), s.lineTo(e + t, n + o - d), s.arcTo(e + t, n + o, e + t - d, n + o, d), s.lineTo(e + d, n + o), s.arcTo(e, n + o, e, n + o - d, d), s.lineTo(e, n + d), s.arcTo(e, n, e + d, n, d), s.closePath();
578
+ function zt(o, e, n, t, a, h) {
579
+ o.beginPath(), o.moveTo(e + h, n), o.lineTo(e + t - h, n), o.arcTo(e + t, n, e + t, n + h, h), o.lineTo(e + t, n + a - h), o.arcTo(e + t, n + a, e + t - h, n + a, h), o.lineTo(e + h, n + a), o.arcTo(e, n + a, e, n + a - h, h), o.lineTo(e, n + h), o.arcTo(e, n, e + h, n, h), o.closePath();
527
580
  }
528
- async function ct(s, e, n, t) {
529
- const o = e.x * n, d = e.y * t, u = e.width * n, r = e.height * t;
530
- if (s.save(), s.globalAlpha = e.opacity, s.translate(o + u / 2, d + r / 2), s.rotate(e.rotation), s.scale(e.flipX ? -1 : 1, e.flipY ? -1 : 1), !e.src.startsWith("http") && !e.src.startsWith("data:") && !e.src.startsWith("blob:") && !e.src.startsWith("/") && !e.src.startsWith(".")) {
531
- const i = Math.min(u, r) * 0.8;
532
- s.font = `${i}px sans-serif`, s.textAlign = "center", s.textBaseline = "middle", s.fillText(e.src, 0, 0);
581
+ async function It(o, e, n, t) {
582
+ const a = e.x * n, h = e.y * t, r = e.width * n, s = e.height * t;
583
+ if (o.save(), o.globalAlpha = e.opacity, o.translate(a + r / 2, h + s / 2), o.rotate(e.rotation), o.scale(e.flipX ? -1 : 1, e.flipY ? -1 : 1), !e.src.startsWith("http") && !e.src.startsWith("data:") && !e.src.startsWith("blob:") && !e.src.startsWith("/") && !e.src.startsWith(".")) {
584
+ const i = Math.min(r, s) * 0.8;
585
+ o.font = `${i}px sans-serif`, o.textAlign = "center", o.textBaseline = "middle", o.fillText(e.src, 0, 0);
533
586
  } else
534
587
  try {
535
588
  const i = new Image();
536
- i.crossOrigin = "anonymous", await new Promise((h, a) => {
537
- i.onload = () => h(), i.onerror = () => a(), i.src = e.src;
538
- }), s.drawImage(i, -u / 2, -r / 2, u, r);
589
+ i.crossOrigin = "anonymous", await new Promise((v, l) => {
590
+ i.onload = () => v(), i.onerror = () => l(), i.src = e.src;
591
+ }), o.drawImage(i, -r / 2, -s / 2, r, s);
539
592
  } catch {
540
593
  }
541
- s.restore();
594
+ o.restore();
542
595
  }
543
- const ut = {
596
+ const Pt = {
544
597
  // Toolbar
545
598
  undo: "Undo",
546
599
  redo: "Redo",
@@ -627,10 +680,20 @@ const ut = {
627
680
  processing: "Processing...",
628
681
  // Crop overlay
629
682
  cropApply: "Apply",
683
+ // Text annotation labels
684
+ text: "Text",
685
+ fillColor: "Fill Color",
686
+ fontSize: "Font Size",
687
+ fontFamily: "Font Family",
688
+ bold: "Bold",
689
+ italic: "Italic",
690
+ textAlign: "Text Align",
691
+ delete: "Delete",
692
+ opacity: "Opacity",
630
693
  // Confirmation
631
694
  unsavedChanges: "You have unsaved changes. Are you sure you want to close?",
632
695
  confirm: "Confirm"
633
- }, dt = {
696
+ }, Tt = {
634
697
  // Toolbar
635
698
  undo: "تراجع",
636
699
  redo: "إعادة",
@@ -717,16 +780,26 @@ const ut = {
717
780
  processing: "جاري المعالجة...",
718
781
  // Crop overlay
719
782
  cropApply: "تطبيق",
783
+ // Text annotation labels
784
+ text: "نص",
785
+ fillColor: "لون التعبئة",
786
+ fontSize: "حجم الخط",
787
+ fontFamily: "نوع الخط",
788
+ bold: "عريض",
789
+ italic: "مائل",
790
+ textAlign: "محاذاة النص",
791
+ delete: "حذف",
792
+ opacity: "الشفافية",
720
793
  // Confirmation
721
794
  unsavedChanges: "لديك تغييرات غير محفوظة. هل أنت متأكد أنك تريد الإغلاق؟",
722
795
  confirm: "تأكيد"
723
- }, ht = ["disabled", "title"], vt = {
796
+ }, Et = ["disabled", "title"], Wt = {
724
797
  key: 0,
725
798
  class: "vie-icon-btn__icon"
726
- }, pt = {
799
+ }, At = {
727
800
  key: 1,
728
801
  class: "vie-icon-btn__label"
729
- }, te = /* @__PURE__ */ Y({
802
+ }, se = /* @__PURE__ */ J({
730
803
  __name: "IconButton",
731
804
  props: {
732
805
  title: {},
@@ -735,27 +808,27 @@ const ut = {
735
808
  variant: {}
736
809
  },
737
810
  emits: ["click"],
738
- setup(s) {
739
- return (e, n) => (M(), z("button", {
740
- class: U([
811
+ setup(o) {
812
+ return (e, n) => (S(), z("button", {
813
+ class: N([
741
814
  "vie-icon-btn",
742
- { "vie-icon-btn--accent": s.variant === "accent" }
815
+ { "vie-icon-btn--accent": o.variant === "accent" }
743
816
  ]),
744
- disabled: s.disabled,
745
- title: s.title,
817
+ disabled: o.disabled,
818
+ title: o.title,
746
819
  onClick: n[0] || (n[0] = (t) => e.$emit("click", t))
747
820
  }, [
748
- e.$slots.default ? (M(), z("span", vt, [
749
- Ue(e.$slots, "default")
750
- ])) : Z("", !0),
751
- s.label ? (M(), z("span", pt, q(s.label), 1)) : Z("", !0)
752
- ], 10, ht));
821
+ e.$slots.default ? (S(), z("span", Wt, [
822
+ vt(e.$slots, "default")
823
+ ])) : G("", !0),
824
+ o.label ? (S(), z("span", At, q(o.label), 1)) : G("", !0)
825
+ ], 10, Et));
753
826
  }
754
- }), ft = { class: "vie-toolbar" }, mt = { class: "vie-toolbar-group" }, gt = { class: "vie-toolbar-group" }, yt = ["title"], wt = { class: "vie-toolbar-group" }, kt = {
827
+ }), Ft = { class: "vie-toolbar" }, Dt = { class: "vie-toolbar-group" }, Lt = { class: "vie-toolbar-group" }, Kt = ["title"], Ht = { class: "vie-toolbar-group" }, Vt = {
755
828
  key: 0,
756
829
  class: "vie-spinner",
757
830
  style: { width: "16px", height: "16px", "border-width": "2px" }
758
- }, bt = {
831
+ }, Bt = {
759
832
  key: 1,
760
833
  viewBox: "0 0 24 24",
761
834
  fill: "none",
@@ -763,23 +836,23 @@ const ut = {
763
836
  "stroke-width": "2.5",
764
837
  "stroke-linecap": "round",
765
838
  "stroke-linejoin": "round"
766
- }, $e = /* @__PURE__ */ Y({
839
+ }, Le = /* @__PURE__ */ J({
767
840
  __name: "EditorToolbar",
768
841
  props: {
769
842
  processing: { type: Boolean }
770
843
  },
771
844
  emits: ["done"],
772
- setup(s) {
773
- const e = Q(ee, (t) => t), n = G();
774
- return (t, o) => (M(), z("div", ft, [
775
- g("div", mt, [
776
- j(te, {
777
- title: S(e)("undo"),
778
- disabled: !S(n).canUndo.value,
779
- onClick: o[0] || (o[0] = (d) => S(n).undo())
845
+ setup(o) {
846
+ const e = ie(oe, (t) => t), n = ee();
847
+ return (t, a) => (S(), z("div", Ft, [
848
+ y("div", Dt, [
849
+ X(se, {
850
+ title: I(e)("undo"),
851
+ disabled: !I(n).canUndo.value,
852
+ onClick: a[0] || (a[0] = (h) => I(n).undo())
780
853
  }, {
781
- default: J(() => [...o[7] || (o[7] = [
782
- g("svg", {
854
+ default: ne(() => [...a[7] || (a[7] = [
855
+ y("svg", {
783
856
  viewBox: "0 0 24 24",
784
857
  fill: "none",
785
858
  stroke: "currentColor",
@@ -787,20 +860,20 @@ const ut = {
787
860
  "stroke-linecap": "round",
788
861
  "stroke-linejoin": "round"
789
862
  }, [
790
- g("path", { d: "M3 10h10a5 5 0 0 1 0 10H9" }),
791
- g("path", { d: "M3 10l4-4" }),
792
- g("path", { d: "M3 10l4 4" })
863
+ y("path", { d: "M3 10h10a5 5 0 0 1 0 10H9" }),
864
+ y("path", { d: "M3 10l4-4" }),
865
+ y("path", { d: "M3 10l4 4" })
793
866
  ], -1)
794
867
  ])]),
795
868
  _: 1
796
869
  }, 8, ["title", "disabled"]),
797
- j(te, {
798
- title: S(e)("redo"),
799
- disabled: !S(n).canRedo.value,
800
- onClick: o[1] || (o[1] = (d) => S(n).redo())
870
+ X(se, {
871
+ title: I(e)("redo"),
872
+ disabled: !I(n).canRedo.value,
873
+ onClick: a[1] || (a[1] = (h) => I(n).redo())
801
874
  }, {
802
- default: J(() => [...o[8] || (o[8] = [
803
- g("svg", {
875
+ default: ne(() => [...a[8] || (a[8] = [
876
+ y("svg", {
804
877
  viewBox: "0 0 24 24",
805
878
  fill: "none",
806
879
  stroke: "currentColor",
@@ -808,20 +881,20 @@ const ut = {
808
881
  "stroke-linecap": "round",
809
882
  "stroke-linejoin": "round"
810
883
  }, [
811
- g("path", { d: "M21 10H11a5 5 0 0 0 0 10h4" }),
812
- g("path", { d: "M21 10l-4-4" }),
813
- g("path", { d: "M21 10l-4 4" })
884
+ y("path", { d: "M21 10H11a5 5 0 0 0 0 10h4" }),
885
+ y("path", { d: "M21 10l-4-4" }),
886
+ y("path", { d: "M21 10l-4 4" })
814
887
  ], -1)
815
888
  ])]),
816
889
  _: 1
817
890
  }, 8, ["title", "disabled"]),
818
- j(te, {
819
- title: S(e)("revert"),
820
- disabled: !S(n).hasEdits.value,
821
- onClick: o[2] || (o[2] = (d) => S(n).revert())
891
+ X(se, {
892
+ title: I(e)("revert"),
893
+ disabled: !I(n).hasEdits.value,
894
+ onClick: a[2] || (a[2] = (h) => I(n).revert())
822
895
  }, {
823
- default: J(() => [...o[9] || (o[9] = [
824
- g("svg", {
896
+ default: ne(() => [...a[9] || (a[9] = [
897
+ y("svg", {
825
898
  viewBox: "0 0 24 24",
826
899
  fill: "none",
827
900
  stroke: "currentColor",
@@ -829,75 +902,75 @@ const ut = {
829
902
  "stroke-linecap": "round",
830
903
  "stroke-linejoin": "round"
831
904
  }, [
832
- g("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
833
- g("path", { d: "M3 3v5h5" })
905
+ y("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
906
+ y("path", { d: "M3 3v5h5" })
834
907
  ], -1)
835
908
  ])]),
836
909
  _: 1
837
910
  }, 8, ["title", "disabled"])
838
911
  ]),
839
- g("div", gt, [
840
- j(te, {
841
- title: S(e)("zoomOut"),
842
- onClick: o[3] || (o[3] = (d) => S(n).setZoom(S(n).zoom.value - 0.1))
912
+ y("div", Lt, [
913
+ X(se, {
914
+ title: I(e)("zoomOut"),
915
+ onClick: a[3] || (a[3] = (h) => I(n).setZoom(I(n).zoom.value - 0.1))
843
916
  }, {
844
- default: J(() => [...o[10] || (o[10] = [
845
- g("svg", {
917
+ default: ne(() => [...a[10] || (a[10] = [
918
+ y("svg", {
846
919
  viewBox: "0 0 24 24",
847
920
  fill: "none",
848
921
  stroke: "currentColor",
849
922
  "stroke-width": "2",
850
923
  "stroke-linecap": "round"
851
924
  }, [
852
- g("circle", {
925
+ y("circle", {
853
926
  cx: "11",
854
927
  cy: "11",
855
928
  r: "8"
856
929
  }),
857
- g("path", { d: "M8 11h6" })
930
+ y("path", { d: "M8 11h6" })
858
931
  ], -1)
859
932
  ])]),
860
933
  _: 1
861
934
  }, 8, ["title"]),
862
- g("button", {
935
+ y("button", {
863
936
  class: "vie-zoom-label",
864
- title: S(e)("zoomToFit"),
865
- onClick: o[4] || (o[4] = (d) => S(n).setZoom(1))
866
- }, q(Math.round(S(n).zoom.value * 100)) + "% ", 9, yt),
867
- j(te, {
868
- title: S(e)("zoomIn"),
869
- onClick: o[5] || (o[5] = (d) => S(n).setZoom(S(n).zoom.value + 0.1))
937
+ title: I(e)("zoomToFit"),
938
+ onClick: a[4] || (a[4] = (h) => I(n).setZoom(1))
939
+ }, q(Math.round(I(n).zoom.value * 100)) + "% ", 9, Kt),
940
+ X(se, {
941
+ title: I(e)("zoomIn"),
942
+ onClick: a[5] || (a[5] = (h) => I(n).setZoom(I(n).zoom.value + 0.1))
870
943
  }, {
871
- default: J(() => [...o[11] || (o[11] = [
872
- g("svg", {
944
+ default: ne(() => [...a[11] || (a[11] = [
945
+ y("svg", {
873
946
  viewBox: "0 0 24 24",
874
947
  fill: "none",
875
948
  stroke: "currentColor",
876
949
  "stroke-width": "2",
877
950
  "stroke-linecap": "round"
878
951
  }, [
879
- g("circle", {
952
+ y("circle", {
880
953
  cx: "11",
881
954
  cy: "11",
882
955
  r: "8"
883
956
  }),
884
- g("path", { d: "M8 11h6" }),
885
- g("path", { d: "M11 8v6" })
957
+ y("path", { d: "M8 11h6" }),
958
+ y("path", { d: "M11 8v6" })
886
959
  ], -1)
887
960
  ])]),
888
961
  _: 1
889
962
  }, 8, ["title"])
890
963
  ]),
891
- g("div", wt, [
892
- j(te, {
964
+ y("div", Ht, [
965
+ X(se, {
893
966
  variant: "accent",
894
- label: s.processing ? S(e)("processing") : S(e)("done"),
895
- disabled: s.processing,
896
- onClick: o[6] || (o[6] = (d) => t.$emit("done"))
967
+ label: o.processing ? I(e)("processing") : I(e)("done"),
968
+ disabled: o.processing,
969
+ onClick: a[6] || (a[6] = (h) => t.$emit("done"))
897
970
  }, {
898
- default: J(() => [
899
- s.processing ? (M(), z("span", kt)) : (M(), z("svg", bt, [...o[12] || (o[12] = [
900
- g("polyline", { points: "20 6 9 17 4 12" }, null, -1)
971
+ default: ne(() => [
972
+ o.processing ? (S(), z("span", Vt)) : (S(), z("svg", Bt, [...a[12] || (a[12] = [
973
+ y("polyline", { points: "20 6 9 17 4 12" }, null, -1)
901
974
  ])]))
902
975
  ]),
903
976
  _: 1
@@ -906,7 +979,7 @@ const ut = {
906
979
  ]));
907
980
  }
908
981
  });
909
- class _t {
982
+ class jt {
910
983
  constructor(e) {
911
984
  this.sourceImage = null, this.animFrameId = null, this.needsRender = !0, this.viewport = { zoom: 1, panX: 0, panY: 0 }, this.activePluginId = null, this.fullImageRect = { x: 0, y: 0, width: 0, height: 0 }, this.previewCanvas = null, this.previewCtx = null, this.previewCacheKey = "", this.previewMaxSize = 1024, this.stickerImageCache = /* @__PURE__ */ new Map(), this.afterRender = null, this.getState = null, this.canvas = e;
912
985
  const n = e.getContext("2d");
@@ -921,9 +994,13 @@ class _t {
921
994
  const t = window.devicePixelRatio || 1;
922
995
  this.canvas.width = e * t, this.canvas.height = n * t, this.canvas.style.width = `${e}px`, this.canvas.style.height = `${n}px`, this.ctx.setTransform(t, 0, 0, t, 0, 0), this.needsRender = !0;
923
996
  }
924
- /** Request a render on the next animation frame */
925
- requestRender() {
926
- this.needsRender = !0, this.scheduleRender();
997
+ /** Request a render on the next animation frame, or immediately if `immediate` is true */
998
+ requestRender(e = !1) {
999
+ this.needsRender = !0, e ? this.renderNow() : this.scheduleRender();
1000
+ }
1001
+ /** Render synchronously (cancels pending RAF). Used during drag for zero-lag updates. */
1002
+ renderNow() {
1003
+ this.animFrameId !== null && (cancelAnimationFrame(this.animFrameId), this.animFrameId = null), this.needsRender && this.getState && (this.render(this.getState()), this.needsRender = !1);
927
1004
  }
928
1005
  /** Start the render loop */
929
1006
  startRenderLoop(e) {
@@ -958,29 +1035,29 @@ class _t {
958
1035
  * otherwise returns a cached offscreen canvas with effects applied.
959
1036
  */
960
1037
  getPreviewSource(e) {
961
- const n = this.sourceImage, { finetune: t, filter: o } = e;
962
- if (!this.hasColorEffects(t, o))
1038
+ const n = this.sourceImage, { finetune: t, filter: a } = e;
1039
+ if (!this.hasColorEffects(t, a))
963
1040
  return n;
964
- const d = this.buildEffectsCacheKey(t, o);
965
- if (d === this.previewCacheKey && this.previewCanvas)
1041
+ const h = this.buildEffectsCacheKey(t, a);
1042
+ if (h === this.previewCacheKey && this.previewCanvas)
966
1043
  return this.previewCanvas;
967
- const u = Math.min(
1044
+ const r = Math.min(
968
1045
  this.previewMaxSize / n.naturalWidth,
969
1046
  this.previewMaxSize / n.naturalHeight,
970
1047
  1
971
- ), r = Math.round(n.naturalWidth * u), i = Math.round(n.naturalHeight * u);
972
- (!this.previewCanvas || this.previewCanvas.width !== r || this.previewCanvas.height !== i) && (this.previewCanvas = document.createElement("canvas"), this.previewCanvas.width = r, this.previewCanvas.height = i, this.previewCtx = this.previewCanvas.getContext("2d"));
973
- const h = this.previewCtx;
974
- h.drawImage(n, 0, 0, r, i);
975
- const a = [];
976
- if (t.brightness !== 0 && a.push(Le(t.brightness)), t.contrast !== 0 && a.push(Ae(t.contrast)), t.saturation !== 0 && a.push(Fe(t.saturation)), t.exposure !== 0 && a.push(He(t.exposure)), t.temperature !== 0 && a.push(Ve(t.temperature)), o.matrix)
977
- if (o.intensity < 1) {
978
- const y = o.matrix, v = o.intensity;
979
- a.push(xe.map((w, b) => w * (1 - v) + y[b] * v));
1048
+ ), s = Math.round(n.naturalWidth * r), i = Math.round(n.naturalHeight * r);
1049
+ (!this.previewCanvas || this.previewCanvas.width !== s || this.previewCanvas.height !== i) && (this.previewCanvas = document.createElement("canvas"), this.previewCanvas.width = s, this.previewCanvas.height = i, this.previewCtx = this.previewCanvas.getContext("2d"));
1050
+ const v = this.previewCtx;
1051
+ v.drawImage(n, 0, 0, s, i);
1052
+ const l = [];
1053
+ if (t.brightness !== 0 && l.push(Qe(t.brightness)), t.contrast !== 0 && l.push(et(t.contrast)), t.saturation !== 0 && l.push(tt(t.saturation)), t.exposure !== 0 && l.push(nt(t.exposure)), t.temperature !== 0 && l.push(it(t.temperature)), a.matrix)
1054
+ if (a.intensity < 1) {
1055
+ const m = a.matrix, d = a.intensity;
1056
+ l.push(We.map((x, _) => x * (1 - d) + m[_] * d));
980
1057
  } else
981
- a.push(o.matrix);
982
- const c = h.getImageData(0, 0, r, i);
983
- return a.length > 0 && Ce(c, De(...a)), t.gamma !== 1 && ye(c, t.gamma), t.clarity !== 0 && ke(c, t.clarity), t.vignette !== 0 && we(c, t.vignette, r, i), h.putImageData(c, 0, 0), this.previewCacheKey = d, this.previewCanvas;
1058
+ l.push(a.matrix);
1059
+ const c = v.getImageData(0, 0, s, i);
1060
+ return l.length > 0 && Ae(c, Ge(...l)), t.gamma !== 1 && Re(c, t.gamma), t.clarity !== 0 && Ie(c, t.clarity), t.vignette !== 0 && ze(c, t.vignette, s, i), v.putImageData(c, 0, 0), this.previewCacheKey = h, this.previewCanvas;
984
1061
  }
985
1062
  /** Check if crop is not at full-image defaults */
986
1063
  isCropActive(e) {
@@ -993,102 +1070,108 @@ class _t {
993
1070
  * On other tabs: renders only the cropped region fitted to canvas.
994
1071
  */
995
1072
  render(e) {
996
- const n = this.ctx, t = this.canvas, o = window.devicePixelRatio || 1, d = t.width / o, u = t.height / o;
997
- if (n.clearRect(0, 0, d, u), !this.sourceImage) return;
998
- const r = this.sourceImage, i = e.crop, h = 40, a = d - h * 2, c = u - h * 2, y = this.activePluginId !== "crop" && this.isCropActive(i), v = this.getPreviewSource(e);
999
- y ? this.renderCroppedView(n, e, v, d, u, a, c) : this.renderFullView(n, e, v, r, d, u, a, c), this.afterRender && this.afterRender(n, e, this.fullImageRect);
1073
+ const n = this.ctx, t = this.canvas, a = window.devicePixelRatio || 1, h = t.width / a, r = t.height / a;
1074
+ if (n.clearRect(0, 0, h, r), !this.sourceImage) return;
1075
+ const s = this.sourceImage, i = e.crop, v = 40, l = h - v * 2, c = r - v * 2, m = this.activePluginId !== "crop" && this.isCropActive(i), d = this.getPreviewSource(e);
1076
+ m ? this.renderCroppedView(n, e, d, h, r, l, c) : this.renderFullView(n, e, d, s, h, r, l, c), this.afterRender && this.afterRender(n, e, this.fullImageRect);
1000
1077
  }
1001
1078
  /**
1002
1079
  * Render full image view (used on the crop tab).
1003
1080
  */
1004
- renderFullView(e, n, t, o, d, u, r, i) {
1005
- const h = n.crop, a = Math.min(r / o.naturalWidth, i / o.naturalHeight), c = o.naturalWidth * a, y = o.naturalHeight * a, v = (d - c) / 2, w = (u - y) / 2;
1006
- this.fullImageRect = { x: v, y: w, width: c, height: y }, e.save();
1007
- const b = this.viewport;
1008
- e.translate(d / 2 + b.panX, u / 2 + b.panY), e.scale(b.zoom, b.zoom), e.translate(-d / 2, -u / 2);
1009
- const $ = v + c / 2, m = w + y / 2;
1010
- e.translate($, m), e.rotate(h.rotation), e.scale(h.flipX ? -1 : 1, h.flipY ? -1 : 1), e.translate(-$, -m);
1011
- const l = n.backgroundColor;
1012
- l[3] > 0 && (e.fillStyle = `rgba(${Math.round(l[0] * 255)}, ${Math.round(l[1] * 255)}, ${Math.round(l[2] * 255)}, ${l[3]})`, e.fillRect(v, w, c, y)), e.drawImage(t, v, w, c, y), n.frame.style && this.renderFramePreview(e, n, v, w, c, y), n.stickers.length > 0 && this.renderStickers(e, n.stickers, v, w, c, y), e.restore();
1081
+ renderFullView(e, n, t, a, h, r, s, i) {
1082
+ const v = n.crop, l = Math.min(s / a.naturalWidth, i / a.naturalHeight), c = a.naturalWidth * l, m = a.naturalHeight * l, d = (h - c) / 2, x = (r - m) / 2;
1083
+ this.fullImageRect = { x: d, y: x, width: c, height: m }, e.save();
1084
+ const _ = this.viewport;
1085
+ e.translate(h / 2 + _.panX, r / 2 + _.panY), e.scale(_.zoom, _.zoom), e.translate(-h / 2, -r / 2);
1086
+ const $ = d + c / 2, w = x + m / 2;
1087
+ e.translate($, w), e.rotate(v.rotation), e.scale(v.flipX ? -1 : 1, v.flipY ? -1 : 1), e.translate(-$, -w);
1088
+ const u = n.backgroundColor;
1089
+ if (u[3] > 0 && (e.fillStyle = `rgba(${Math.round(u[0] * 255)}, ${Math.round(u[1] * 255)}, ${Math.round(u[2] * 255)}, ${u[3]})`, e.fillRect(d, x, c, m)), e.drawImage(t, d, x, c, m), n.frame.style && this.renderFramePreview(e, n, d, x, c, m), n.stickers.length > 0 && this.renderStickers(e, n.stickers, d, x, c, m), n.annotations.length > 0)
1090
+ for (const g of n.annotations)
1091
+ Ee(e, g, d, x, c, m);
1092
+ e.restore();
1013
1093
  }
1014
1094
  /**
1015
1095
  * Render cropped view (used on non-crop tabs).
1016
1096
  * Shows only the crop region fitted to the canvas.
1017
1097
  */
1018
- renderCroppedView(e, n, t, o, d, u, r) {
1019
- const i = this.sourceImage, h = n.crop, a = i.naturalWidth * h.width, c = i.naturalHeight * h.height, y = Math.min(u / a, r / c);
1020
- let v = 1;
1098
+ renderCroppedView(e, n, t, a, h, r, s) {
1099
+ const i = this.sourceImage, v = n.crop, l = i.naturalWidth * v.width, c = i.naturalHeight * v.height, m = Math.min(r / l, s / c);
1100
+ let d = 1;
1021
1101
  if (this.activePluginId === "resize" && (n.resize.width || n.resize.height)) {
1022
- const K = n.resize.width || Math.round(a * (n.resize.height / c)), L = n.resize.height || Math.round(c * (n.resize.width / a));
1023
- v = Math.min(K / a, L / c), !n.resize.upscale && v > 1 && (v = 1), v > 1 && (v = Math.min(v, u / (a * y), r / (c * y)));
1102
+ const D = n.resize.width || Math.round(l * (n.resize.height / c)), K = n.resize.height || Math.round(c * (n.resize.width / l));
1103
+ d = Math.min(D / l, K / c), !n.resize.upscale && d > 1 && (d = 1), d > 1 && (d = Math.min(d, r / (l * m), s / (c * m)));
1024
1104
  }
1025
- const w = y * v, b = a * w, $ = c * w, m = (o - b) / 2, l = (d - $) / 2;
1026
- this.fullImageRect = { x: m, y: l, width: b, height: $ };
1027
- const p = t instanceof HTMLImageElement ? t.naturalWidth : t.width, f = t instanceof HTMLImageElement ? t.naturalHeight : t.height;
1105
+ const x = m * d, _ = l * x, $ = c * x, w = (a - _) / 2, u = (h - $) / 2;
1106
+ this.fullImageRect = { x: w, y: u, width: _, height: $ };
1107
+ const g = t instanceof HTMLImageElement ? t.naturalWidth : t.width, k = t instanceof HTMLImageElement ? t.naturalHeight : t.height;
1028
1108
  e.save();
1029
- const k = this.viewport;
1030
- e.translate(o / 2 + k.panX, d / 2 + k.panY), e.scale(k.zoom, k.zoom), e.translate(-o / 2, -d / 2);
1031
- const x = m + b / 2, D = l + $ / 2;
1032
- e.translate(x, D), e.rotate(h.rotation), e.scale(h.flipX ? -1 : 1, h.flipY ? -1 : 1), e.translate(-x, -D);
1033
- const T = n.backgroundColor;
1034
- if (T[3] > 0 && (e.fillStyle = `rgba(${Math.round(T[0] * 255)}, ${Math.round(T[1] * 255)}, ${Math.round(T[2] * 255)}, ${T[3]})`, e.fillRect(m, l, b, $)), e.drawImage(
1109
+ const C = this.viewport;
1110
+ e.translate(a / 2 + C.panX, h / 2 + C.panY), e.scale(C.zoom, C.zoom), e.translate(-a / 2, -h / 2);
1111
+ const P = w + _ / 2, V = u + $ / 2;
1112
+ e.translate(P, V), e.rotate(v.rotation), e.scale(v.flipX ? -1 : 1, v.flipY ? -1 : 1), e.translate(-P, -V);
1113
+ const A = n.backgroundColor;
1114
+ if (A[3] > 0 && (e.fillStyle = `rgba(${Math.round(A[0] * 255)}, ${Math.round(A[1] * 255)}, ${Math.round(A[2] * 255)}, ${A[3]})`, e.fillRect(w, u, _, $)), e.drawImage(
1035
1115
  t,
1036
- h.x * p,
1037
- h.y * f,
1116
+ v.x * g,
1117
+ v.y * k,
1038
1118
  // source x, y
1039
- h.width * p,
1040
- h.height * f,
1119
+ v.width * g,
1120
+ v.height * k,
1041
1121
  // source w, h
1042
- m,
1043
- l,
1044
- b,
1122
+ w,
1123
+ u,
1124
+ _,
1045
1125
  $
1046
1126
  // dest x, y, w, h
1047
- ), n.frame.style && this.renderFramePreview(e, n, m, l, b, $), n.stickers.length > 0 && this.renderStickersInCrop(e, n.stickers, h, m, l, b, $), e.restore(), this.activePluginId === "resize" && (n.resize.width || n.resize.height)) {
1048
- const K = n.resize.width || Math.round(a * (n.resize.height / c)), L = n.resize.height || Math.round(c * (n.resize.width / a)), W = `${K} × ${L} px`;
1127
+ ), n.frame.style && this.renderFramePreview(e, n, w, u, _, $), n.stickers.length > 0 && this.renderStickersInCrop(e, n.stickers, v, w, u, _, $), n.annotations.length > 0)
1128
+ for (const D of n.annotations)
1129
+ xt(e, D, v, w, u, _, $);
1130
+ if (e.restore(), this.activePluginId === "resize" && (n.resize.width || n.resize.height)) {
1131
+ const D = n.resize.width || Math.round(l * (n.resize.height / c)), K = n.resize.height || Math.round(c * (n.resize.width / l)), L = `${D} × ${K} px`;
1049
1132
  e.save(), e.font = '12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', e.textAlign = "center", e.textBaseline = "top";
1050
- const P = o / 2, O = l + $ + 8, A = e.measureText(W).width + 16, R = 22;
1051
- e.fillStyle = "rgba(0, 0, 0, 0.6)", e.beginPath(), e.roundRect(P - A / 2, O, A, R, 4), e.fill(), e.fillStyle = "#fff", e.fillText(W, P, O + 4), e.restore();
1133
+ const E = a / 2, O = u + $ + 8, F = e.measureText(L).width + 16, f = 22;
1134
+ e.fillStyle = "rgba(0, 0, 0, 0.6)", e.beginPath(), e.roundRect(E - F / 2, O, F, f, 4), e.fill(), e.fillStyle = "#fff", e.fillText(L, E, O + 4), e.restore();
1052
1135
  }
1053
1136
  }
1054
1137
  /**
1055
1138
  * Render frame preview overlay on the canvas.
1056
1139
  */
1057
- renderFramePreview(e, n, t, o, d, u) {
1058
- const r = n.frame, i = Math.round(Math.max(d, u) * r.size), h = r.color, a = `rgba(${Math.round(h[0] * 255)}, ${Math.round(h[1] * 255)}, ${Math.round(h[2] * 255)}, ${h[3]})`, c = Math.round(r.radius);
1059
- switch (e.strokeStyle = a, e.fillStyle = a, r.style) {
1140
+ renderFramePreview(e, n, t, a, h, r) {
1141
+ const s = n.frame, i = Math.round(Math.max(h, r) * s.size), v = s.color, l = `rgba(${Math.round(v[0] * 255)}, ${Math.round(v[1] * 255)}, ${Math.round(v[2] * 255)}, ${v[3]})`, c = Math.round(s.radius);
1142
+ switch (e.strokeStyle = l, e.fillStyle = l, s.style) {
1060
1143
  case "solidSharp":
1061
- e.lineWidth = i, e.strokeRect(t + i / 2, o + i / 2, d - i, u - i);
1144
+ e.lineWidth = i, e.strokeRect(t + i / 2, a + i / 2, h - i, r - i);
1062
1145
  break;
1063
1146
  case "solidRound":
1064
- e.lineWidth = i, e.beginPath(), e.roundRect(t + i / 2, o + i / 2, d - i, u - i, c + i / 2), e.stroke();
1147
+ e.lineWidth = i, e.beginPath(), e.roundRect(t + i / 2, a + i / 2, h - i, r - i, c + i / 2), e.stroke();
1065
1148
  break;
1066
1149
  case "lineSingle": {
1067
- const y = i * 2;
1068
- e.lineWidth = 1, e.strokeRect(t + y, o + y, d - y * 2, u - y * 2);
1150
+ const m = i * 2;
1151
+ e.lineWidth = 1, e.strokeRect(t + m, a + m, h - m * 2, r - m * 2);
1069
1152
  break;
1070
1153
  }
1071
1154
  case "lineMultiple":
1072
1155
  e.lineWidth = 1;
1073
- for (let y = 1; y <= 3; y++) {
1074
- const v = i * y;
1075
- e.strokeRect(t + v, o + v, d - v * 2, u - v * 2);
1156
+ for (let m = 1; m <= 3; m++) {
1157
+ const d = i * m;
1158
+ e.strokeRect(t + d, a + d, h - d * 2, r - d * 2);
1076
1159
  }
1077
1160
  break;
1078
1161
  case "hook": {
1079
- const y = Math.min(d, u) * 0.1;
1162
+ const m = Math.min(h, r) * 0.1;
1080
1163
  e.lineWidth = i * 0.5;
1081
- const v = i;
1082
- e.beginPath(), e.moveTo(t + v, o + v + y), e.lineTo(t + v, o + v), e.lineTo(t + v + y, o + v), e.stroke(), e.beginPath(), e.moveTo(t + d - v - y, o + v), e.lineTo(t + d - v, o + v), e.lineTo(t + d - v, o + v + y), e.stroke(), e.beginPath(), e.moveTo(t + v, o + u - v - y), e.lineTo(t + v, o + u - v), e.lineTo(t + v + y, o + u - v), e.stroke(), e.beginPath(), e.moveTo(t + d - v - y, o + u - v), e.lineTo(t + d - v, o + u - v), e.lineTo(t + d - v, o + u - v - y), e.stroke();
1164
+ const d = i;
1165
+ e.beginPath(), e.moveTo(t + d, a + d + m), e.lineTo(t + d, a + d), e.lineTo(t + d + m, a + d), e.stroke(), e.beginPath(), e.moveTo(t + h - d - m, a + d), e.lineTo(t + h - d, a + d), e.lineTo(t + h - d, a + d + m), e.stroke(), e.beginPath(), e.moveTo(t + d, a + r - d - m), e.lineTo(t + d, a + r - d), e.lineTo(t + d + m, a + r - d), e.stroke(), e.beginPath(), e.moveTo(t + h - d - m, a + r - d), e.lineTo(t + h - d, a + r - d), e.lineTo(t + h - d, a + r - d - m), e.stroke();
1083
1166
  break;
1084
1167
  }
1085
1168
  case "polaroid": {
1086
- const y = i, v = i * 4;
1087
- e.fillRect(t, o, d, y), e.fillRect(t, o, y, u), e.fillRect(t + d - y, o, y, u), e.fillRect(t, o + u - v, d, v);
1169
+ const m = i, d = i * 4;
1170
+ e.fillRect(t, a, h, m), e.fillRect(t, a, m, r), e.fillRect(t + h - m, a, m, r), e.fillRect(t, a + r - d, h, d);
1088
1171
  break;
1089
1172
  }
1090
1173
  default:
1091
- e.lineWidth = i * 0.5, e.strokeRect(t + i, o + i, d - i * 2, u - i * 2);
1174
+ e.lineWidth = i * 0.5, e.strokeRect(t + i, a + i, h - i * 2, r - i * 2);
1092
1175
  break;
1093
1176
  }
1094
1177
  }
@@ -1102,26 +1185,26 @@ class _t {
1102
1185
  /**
1103
1186
  * Render stickers on the canvas viewport.
1104
1187
  */
1105
- renderStickers(e, n, t, o, d, u) {
1106
- for (const r of n) {
1107
- const i = t + r.x * d, h = o + r.y * u, a = r.width * d, c = r.height * u;
1108
- if (e.save(), e.globalAlpha = r.opacity, e.translate(i + a / 2, h + c / 2), e.rotate(r.rotation), e.scale(r.flipX ? -1 : 1, r.flipY ? -1 : 1), !r.src.startsWith("http") && !r.src.startsWith("data:") && !r.src.startsWith("blob:") && !r.src.startsWith("/") && !r.src.startsWith(".")) {
1109
- const v = Math.max(8, Math.min(a, c) * 0.8);
1110
- e.font = `${v}px sans-serif`, e.textAlign = "center", e.textBaseline = "middle", e.fillText(r.src, 0, 0);
1188
+ renderStickers(e, n, t, a, h, r) {
1189
+ for (const s of n) {
1190
+ const i = t + s.x * h, v = a + s.y * r, l = s.width * h, c = s.height * r;
1191
+ if (e.save(), e.globalAlpha = s.opacity, e.translate(i + l / 2, v + c / 2), e.rotate(s.rotation), e.scale(s.flipX ? -1 : 1, s.flipY ? -1 : 1), !s.src.startsWith("http") && !s.src.startsWith("data:") && !s.src.startsWith("blob:") && !s.src.startsWith("/") && !s.src.startsWith(".")) {
1192
+ const d = Math.max(8, Math.min(l, c) * 0.8);
1193
+ e.font = `${d}px sans-serif`, e.textAlign = "center", e.textBaseline = "middle", e.fillText(s.src, 0, 0);
1111
1194
  } else {
1112
- let v = this.stickerImageCache.get(r.src);
1113
- if (!v) {
1195
+ let d = this.stickerImageCache.get(s.src);
1196
+ if (!d) {
1114
1197
  if (this.stickerImageCache.size >= 50) {
1115
- const w = this.stickerImageCache.keys().next().value;
1116
- w !== void 0 && this.stickerImageCache.delete(w);
1198
+ const x = this.stickerImageCache.keys().next().value;
1199
+ x !== void 0 && this.stickerImageCache.delete(x);
1117
1200
  }
1118
- v = new Image(), v.crossOrigin = "anonymous", v.src = r.src, this.stickerImageCache.set(r.src, v), v.onload = () => {
1201
+ d = new Image(), d.crossOrigin = "anonymous", d.src = s.src, this.stickerImageCache.set(s.src, d), d.onload = () => {
1119
1202
  this.requestRender();
1120
- }, v.onerror = () => {
1121
- this.stickerImageCache.delete(r.src);
1203
+ }, d.onerror = () => {
1204
+ this.stickerImageCache.delete(s.src);
1122
1205
  };
1123
1206
  }
1124
- v.complete && v.naturalWidth > 0 && e.drawImage(v, -a / 2, -c / 2, a, c);
1207
+ d.complete && d.naturalWidth > 0 && e.drawImage(d, -l / 2, -c / 2, l, c);
1125
1208
  }
1126
1209
  e.restore();
1127
1210
  }
@@ -1129,29 +1212,29 @@ class _t {
1129
1212
  /**
1130
1213
  * Render stickers with positions remapped relative to the crop region.
1131
1214
  */
1132
- renderStickersInCrop(e, n, t, o, d, u, r) {
1215
+ renderStickersInCrop(e, n, t, a, h, r, s) {
1133
1216
  if (!(t.width <= 0 || t.height <= 0))
1134
1217
  for (const i of n) {
1135
- const h = (i.x - t.x) / t.width, a = (i.y - t.y) / t.height, c = i.width / t.width, y = i.height / t.height;
1136
- if (h + c < 0 || h > 1 || a + y < 0 || a > 1) continue;
1137
- const v = o + h * u, w = d + a * r, b = c * u, $ = y * r;
1138
- if (e.save(), e.globalAlpha = i.opacity, e.translate(v + b / 2, w + $ / 2), e.rotate(i.rotation), e.scale(i.flipX ? -1 : 1, i.flipY ? -1 : 1), !i.src.startsWith("http") && !i.src.startsWith("data:") && !i.src.startsWith("blob:") && !i.src.startsWith("/") && !i.src.startsWith(".")) {
1139
- const l = Math.max(8, Math.min(b, $) * 0.8);
1140
- e.font = `${l}px sans-serif`, e.textAlign = "center", e.textBaseline = "middle", e.fillText(i.src, 0, 0);
1218
+ const v = (i.x - t.x) / t.width, l = (i.y - t.y) / t.height, c = i.width / t.width, m = i.height / t.height;
1219
+ if (v + c < 0 || v > 1 || l + m < 0 || l > 1) continue;
1220
+ const d = a + v * r, x = h + l * s, _ = c * r, $ = m * s;
1221
+ if (e.save(), e.globalAlpha = i.opacity, e.translate(d + _ / 2, x + $ / 2), e.rotate(i.rotation), e.scale(i.flipX ? -1 : 1, i.flipY ? -1 : 1), !i.src.startsWith("http") && !i.src.startsWith("data:") && !i.src.startsWith("blob:") && !i.src.startsWith("/") && !i.src.startsWith(".")) {
1222
+ const u = Math.max(8, Math.min(_, $) * 0.8);
1223
+ e.font = `${u}px sans-serif`, e.textAlign = "center", e.textBaseline = "middle", e.fillText(i.src, 0, 0);
1141
1224
  } else {
1142
- let l = this.stickerImageCache.get(i.src);
1143
- if (!l) {
1225
+ let u = this.stickerImageCache.get(i.src);
1226
+ if (!u) {
1144
1227
  if (this.stickerImageCache.size >= 50) {
1145
- const p = this.stickerImageCache.keys().next().value;
1146
- p !== void 0 && this.stickerImageCache.delete(p);
1228
+ const g = this.stickerImageCache.keys().next().value;
1229
+ g !== void 0 && this.stickerImageCache.delete(g);
1147
1230
  }
1148
- l = new Image(), l.crossOrigin = "anonymous", l.src = i.src, this.stickerImageCache.set(i.src, l), l.onload = () => {
1231
+ u = new Image(), u.crossOrigin = "anonymous", u.src = i.src, this.stickerImageCache.set(i.src, u), u.onload = () => {
1149
1232
  this.requestRender();
1150
- }, l.onerror = () => {
1233
+ }, u.onerror = () => {
1151
1234
  this.stickerImageCache.delete(i.src);
1152
1235
  };
1153
1236
  }
1154
- l.complete && l.naturalWidth > 0 && e.drawImage(l, -b / 2, -$ / 2, b, $);
1237
+ u.complete && u.naturalWidth > 0 && e.drawImage(u, -_ / 2, -$ / 2, _, $);
1155
1238
  }
1156
1239
  e.restore();
1157
1240
  }
@@ -1160,147 +1243,147 @@ class _t {
1160
1243
  this.stopRenderLoop(), this.sourceImage = null, this.previewCanvas = null, this.previewCtx = null, this.stickerImageCache.clear();
1161
1244
  }
1162
1245
  }
1163
- const xt = {
1246
+ const Ot = {
1164
1247
  key: 0,
1165
1248
  class: "vie-canvas-overlay vie-canvas-overlay--interactive"
1166
- }, Ct = {
1249
+ }, Xt = {
1167
1250
  key: 1,
1168
1251
  class: "vie-canvas-loading"
1169
- }, Mt = {
1252
+ }, qt = {
1170
1253
  key: 2,
1171
1254
  class: "vie-canvas-loading",
1172
1255
  style: { color: "var(--vie-danger)" }
1173
- }, Re = /* @__PURE__ */ Y({
1256
+ }, Ke = /* @__PURE__ */ J({
1174
1257
  __name: "EditorCanvas",
1175
- setup(s, { expose: e }) {
1176
- const n = Q(ee, (R) => R), t = G(), o = H(null), d = H(null), u = H({ x: 0, y: 0, width: 0, height: 0 }), r = H({ width: 0, height: 0 });
1177
- let i = null, h = null, a = null, c = null;
1178
- function y() {
1179
- i && (u.value = i.getImageRect());
1180
- }
1181
- ue(() => {
1182
- if (!d.value || !o.value) return;
1183
- i = new _t(d.value), h = new ResizeObserver((C) => {
1184
- for (const E of C) {
1185
- const { width: F, height: B } = E.contentRect;
1186
- F > 0 && B > 0 && (r.value = { width: F, height: B }, i == null || i.resize(F, B), i == null || i.requestRender(), requestAnimationFrame(y));
1258
+ setup(o, { expose: e }) {
1259
+ const n = ie(oe, (f) => f), t = ee(), a = H(null), h = H(null), r = H({ x: 0, y: 0, width: 0, height: 0 }), s = H({ width: 0, height: 0 });
1260
+ let i = null, v = null, l = null, c = null;
1261
+ function m() {
1262
+ i && (r.value = i.getImageRect());
1263
+ }
1264
+ ge(() => {
1265
+ if (!h.value || !a.value) return;
1266
+ i = new jt(h.value), v = new ResizeObserver((b) => {
1267
+ for (const R of b) {
1268
+ const { width: T, height: W } = R.contentRect;
1269
+ T > 0 && W > 0 && (s.value = { width: T, height: W }, i == null || i.resize(T, W), i == null || i.requestRender(), requestAnimationFrame(m));
1187
1270
  }
1188
- }), h.observe(o.value);
1189
- function R() {
1190
- a == null || a.removeEventListener("change", c);
1191
- const C = window.devicePixelRatio || 1;
1192
- a = window.matchMedia(`(resolution: ${C}dppx)`), c = () => {
1193
- const { width: E, height: F } = r.value;
1194
- E > 0 && F > 0 && (i == null || i.resize(E, F), i == null || i.requestRender()), R();
1195
- }, a.addEventListener("change", c);
1271
+ }), v.observe(a.value);
1272
+ function f() {
1273
+ l == null || l.removeEventListener("change", c);
1274
+ const b = window.devicePixelRatio || 1;
1275
+ l = window.matchMedia(`(resolution: ${b}dppx)`), c = () => {
1276
+ const { width: R, height: T } = s.value;
1277
+ R > 0 && T > 0 && (i == null || i.resize(R, T), i == null || i.requestRender()), f();
1278
+ }, l.addEventListener("change", c);
1196
1279
  }
1197
- R();
1198
- const I = o.value.getBoundingClientRect();
1199
- r.value = { width: I.width, height: I.height }, i.resize(I.width, I.height), i.startRenderLoop(() => t.state), i.afterRender = (C, E, F) => {
1200
- const B = t.activePlugin.value;
1201
- B != null && B.onRender && B.onRender({ ctx: C, state: E, imageRect: F });
1202
- }, t.onRender.value = () => {
1203
- i == null || i.requestRender(), requestAnimationFrame(y);
1204
- }, i.activePluginId = t.activePluginId.value, v = t.zoom.value, w = t.zoom.value, $ = 0, m = 0, l = 0, p = 0, t.options.src && t.load(t.options.src);
1205
- }), ne(() => t.sourceImage.value, (R) => {
1206
- i && R && (i.setSource(R), i.requestRender(), requestAnimationFrame(() => requestAnimationFrame(y)));
1207
- }), ne(() => t.zoom.value, (R) => {
1208
- i && (i.viewport.zoom = R, i.requestRender(), requestAnimationFrame(y)), b || (v = R, w = R, R <= 1.005 && ($ = 0, m = 0, l = 0, p = 0, f()));
1209
- }), ne(() => t.activePluginId.value, (R) => {
1210
- i && (i.activePluginId = R, i.requestRender(), requestAnimationFrame(y));
1211
- }), ne(() => t.cropDragPan.value, (R) => {
1212
- i && (i.viewport.panX = l + R.x, i.viewport.panY = p + R.y, i.requestRender());
1280
+ f();
1281
+ const p = a.value.getBoundingClientRect();
1282
+ s.value = { width: p.width, height: p.height }, i.resize(p.width, p.height), i.startRenderLoop(() => t.state), i.afterRender = (b, R, T) => {
1283
+ const W = t.activePlugin.value;
1284
+ W != null && W.onRender && W.onRender({ ctx: b, state: R, imageRect: T });
1285
+ }, t.onRender.value = (b) => {
1286
+ i == null || i.requestRender(b), requestAnimationFrame(m);
1287
+ }, i.activePluginId = t.activePluginId.value, d = t.zoom.value, x = t.zoom.value, $ = 0, w = 0, u = 0, g = 0, t.options.src && t.load(t.options.src);
1288
+ }), re(() => t.sourceImage.value, (f) => {
1289
+ i && f && (i.setSource(f), i.requestRender(), requestAnimationFrame(() => requestAnimationFrame(m)));
1290
+ }), re(() => t.zoom.value, (f) => {
1291
+ i && (i.viewport.zoom = f, i.requestRender(), requestAnimationFrame(m)), _ || (d = f, x = f, f <= 1.005 && ($ = 0, w = 0, u = 0, g = 0, k()));
1292
+ }), re(() => t.activePluginId.value, (f) => {
1293
+ i && (i.activePluginId = f, i.requestRender(), requestAnimationFrame(m));
1294
+ }), re(() => t.cropDragPan.value, (f) => {
1295
+ i && (i.viewport.panX = u + f.x, i.viewport.panY = g + f.y, i.requestRender());
1213
1296
  }, { deep: !0 });
1214
- let v = 1, w = 1, b = !1, $ = 0, m = 0, l = 0, p = 0;
1215
- function f() {
1216
- i && (i.viewport.panX = l, i.viewport.panY = p, i.requestRender(), requestAnimationFrame(y));
1217
- }
1218
- function k(R) {
1219
- const I = R.deltaY > 0 ? 0.95 : 1.05, C = Math.max(0.1, Math.min(10, v * I)), E = o.value.getBoundingClientRect(), F = R.clientX - E.left - E.width / 2, B = R.clientY - E.top - E.height / 2, oe = C / v;
1220
- $ = F - (F - $) * oe, m = B - (B - m) * oe, v = C, v <= 1.005 && ($ = 0, m = 0), b || (b = !0, x());
1221
- }
1222
- function x() {
1223
- const R = v - w, I = $ - l, C = m - p;
1224
- if (Math.abs(R) < 1e-3 && Math.abs(I) < 0.5 && Math.abs(C) < 0.5) {
1225
- w = v, l = $, p = m, t.setZoom(w), f(), b = !1;
1297
+ let d = 1, x = 1, _ = !1, $ = 0, w = 0, u = 0, g = 0;
1298
+ function k() {
1299
+ i && (i.viewport.panX = u, i.viewport.panY = g, i.requestRender(), requestAnimationFrame(m));
1300
+ }
1301
+ function C(f) {
1302
+ const p = f.deltaY > 0 ? 0.95 : 1.05, b = Math.max(0.1, Math.min(10, d * p)), R = a.value.getBoundingClientRect(), T = f.clientX - R.left - R.width / 2, W = f.clientY - R.top - R.height / 2, B = b / d;
1303
+ $ = T - (T - $) * B, w = W - (W - w) * B, d = b, d <= 1.005 && ($ = 0, w = 0), _ || (_ = !0, P());
1304
+ }
1305
+ function P() {
1306
+ const f = d - x, p = $ - u, b = w - g;
1307
+ if (Math.abs(f) < 1e-3 && Math.abs(p) < 0.5 && Math.abs(b) < 0.5) {
1308
+ x = d, u = $, g = w, t.setZoom(x), k(), _ = !1;
1226
1309
  return;
1227
1310
  }
1228
- const F = 0.15;
1229
- w += R * F, l += I * F, p += C * F, t.setZoom(w), f(), requestAnimationFrame(x);
1230
- }
1231
- const D = H(!1), T = V(() => t.zoom.value > 1.005 && t.activePluginId.value !== "crop");
1232
- function K(R) {
1233
- if (R.button !== 0 || !T.value || R.target !== o.value && R.target !== d.value) return;
1234
- R.preventDefault(), D.value = !0;
1235
- const I = R.clientX, C = R.clientY, E = $, F = m, B = (Me) => {
1236
- $ = E + (Me.clientX - I), m = F + (Me.clientY - C), l = $, p = m, f();
1237
- }, oe = () => {
1238
- D.value = !1, window.removeEventListener("mousemove", B), window.removeEventListener("mouseup", oe);
1311
+ const T = 0.15;
1312
+ x += f * T, u += p * T, g += b * T, t.setZoom(x), k(), requestAnimationFrame(P);
1313
+ }
1314
+ const V = H(!1), A = j(() => t.zoom.value > 1.005 && t.activePluginId.value !== "crop");
1315
+ function D(f) {
1316
+ if (f.button !== 0 || !A.value || f.target !== a.value && f.target !== h.value) return;
1317
+ f.preventDefault(), V.value = !0;
1318
+ const p = f.clientX, b = f.clientY, R = $, T = w, W = (U) => {
1319
+ $ = R + (U.clientX - p), w = T + (U.clientY - b), u = $, g = w, k();
1320
+ }, B = () => {
1321
+ V.value = !1, window.removeEventListener("mousemove", W), window.removeEventListener("mouseup", B);
1239
1322
  };
1240
- window.addEventListener("mousemove", B), window.addEventListener("mouseup", oe);
1241
- }
1242
- let L = 0, W = 1;
1243
- function P(R, I) {
1244
- const C = R.clientX - I.clientX, E = R.clientY - I.clientY;
1245
- return Math.sqrt(C * C + E * E);
1246
- }
1247
- function O(R) {
1248
- R.touches.length === 2 && (L = P(R.touches[0], R.touches[1]), W = t.zoom.value);
1249
- }
1250
- function _(R) {
1251
- if (R.touches.length === 2) {
1252
- const I = P(R.touches[0], R.touches[1]);
1253
- if (L > 0) {
1254
- const C = I / L;
1255
- t.setZoom(W * C);
1323
+ window.addEventListener("mousemove", W), window.addEventListener("mouseup", B);
1324
+ }
1325
+ let K = 0, L = 1;
1326
+ function E(f, p) {
1327
+ const b = f.clientX - p.clientX, R = f.clientY - p.clientY;
1328
+ return Math.sqrt(b * b + R * R);
1329
+ }
1330
+ function O(f) {
1331
+ f.touches.length === 2 && (K = E(f.touches[0], f.touches[1]), L = t.zoom.value);
1332
+ }
1333
+ function M(f) {
1334
+ if (f.touches.length === 2) {
1335
+ const p = E(f.touches[0], f.touches[1]);
1336
+ if (K > 0) {
1337
+ const b = p / K;
1338
+ t.setZoom(L * b);
1256
1339
  }
1257
1340
  }
1258
1341
  }
1259
- function A(R) {
1260
- L = 0;
1342
+ function F(f) {
1343
+ K = 0;
1261
1344
  }
1262
- return re(() => {
1263
- h == null || h.disconnect(), a == null || a.removeEventListener("change", c), a = null, i == null || i.destroy(), i = null, t.onRender.value = null;
1345
+ return he(() => {
1346
+ v == null || v.disconnect(), l == null || l.removeEventListener("change", c), l = null, i == null || i.destroy(), i = null, t.onRender.value = null;
1264
1347
  }), e({
1265
1348
  getRenderer: () => i
1266
- }), (R, I) => {
1267
- var C;
1268
- return M(), z("div", {
1269
- class: U(["vie-canvas-wrapper", { "vie-canvas-wrapper--grab": T.value, "vie-canvas-wrapper--grabbing": D.value }]),
1349
+ }), (f, p) => {
1350
+ var b;
1351
+ return S(), z("div", {
1352
+ class: N(["vie-canvas-wrapper", { "vie-canvas-wrapper--grab": A.value, "vie-canvas-wrapper--grabbing": V.value }]),
1270
1353
  ref_key: "wrapperRef",
1271
- ref: o,
1272
- onWheel: ce(k, ["prevent"]),
1273
- onMousedown: K,
1354
+ ref: a,
1355
+ onWheel: ve(C, ["prevent"]),
1356
+ onMousedown: D,
1274
1357
  onTouchstartPassive: O,
1275
- onTouchmove: ce(_, ["prevent"]),
1276
- onTouchendPassive: A
1358
+ onTouchmove: ve(M, ["prevent"]),
1359
+ onTouchendPassive: F
1277
1360
  }, [
1278
- g("canvas", {
1361
+ y("canvas", {
1279
1362
  ref_key: "canvasRef",
1280
- ref: d,
1363
+ ref: h,
1281
1364
  class: "vie-canvas"
1282
1365
  }, null, 512),
1283
- (C = S(t).activePlugin.value) != null && C.overlay ? (M(), z("div", xt, [
1284
- (M(), le(be(S(t).activePlugin.value.overlay), {
1285
- "canvas-rect": u.value,
1286
- "wrapper-size": r.value
1366
+ (b = I(t).activePlugin.value) != null && b.overlay ? (S(), z("div", Ot, [
1367
+ (S(), pe(Pe(I(t).activePlugin.value.overlay), {
1368
+ "canvas-rect": r.value,
1369
+ "wrapper-size": s.value
1287
1370
  }, null, 8, ["canvas-rect", "wrapper-size"]))
1288
- ])) : Z("", !0),
1289
- S(t).loading.value ? (M(), z("div", Ct, [
1290
- I[0] || (I[0] = g("span", { class: "vie-spinner" }, null, -1)),
1291
- g("span", null, q(S(n)("loading")), 1)
1292
- ])) : Z("", !0),
1293
- S(t).error.value ? (M(), z("div", Mt, q(S(n)("loadError")), 1)) : Z("", !0)
1371
+ ])) : G("", !0),
1372
+ I(t).loading.value ? (S(), z("div", Xt, [
1373
+ p[0] || (p[0] = y("span", { class: "vie-spinner" }, null, -1)),
1374
+ y("span", null, q(I(n)("loading")), 1)
1375
+ ])) : G("", !0),
1376
+ I(t).error.value ? (S(), z("div", qt, q(I(n)("loadError")), 1)) : G("", !0)
1294
1377
  ], 34);
1295
1378
  };
1296
1379
  }
1297
- }), St = {
1380
+ }), Yt = {
1298
1381
  class: "vie-tab-bar",
1299
1382
  role: "tablist"
1300
- }, $t = ["aria-selected", "onClick"], Rt = { class: "vie-tab__label" }, ze = /* @__PURE__ */ Y({
1383
+ }, Ut = ["aria-selected", "onClick"], Nt = { class: "vie-tab__label" }, He = /* @__PURE__ */ J({
1301
1384
  __name: "EditorTabs",
1302
- setup(s) {
1303
- const e = Q(ee, (i) => i), n = G(), t = H([]), o = /* @__PURE__ */ new Set([
1385
+ setup(o) {
1386
+ const e = ie(oe, (i) => i), n = ee(), t = H([]), a = /* @__PURE__ */ new Set([
1304
1387
  "svg",
1305
1388
  "path",
1306
1389
  "circle",
@@ -1316,7 +1399,7 @@ const xt = {
1316
1399
  "use",
1317
1400
  "text",
1318
1401
  "tspan"
1319
- ]), d = /* @__PURE__ */ new Set([
1402
+ ]), h = /* @__PURE__ */ new Set([
1320
1403
  "viewbox",
1321
1404
  "width",
1322
1405
  "height",
@@ -1350,80 +1433,80 @@ const xt = {
1350
1433
  "stroke-dasharray",
1351
1434
  "stroke-dashoffset"
1352
1435
  ]);
1353
- function u(i) {
1436
+ function r(i) {
1354
1437
  const c = new DOMParser().parseFromString(i, "image/svg+xml").documentElement;
1355
- function y(v) {
1356
- const w = Array.from(v.children);
1357
- for (const b of w)
1358
- if (!o.has(b.tagName.toLowerCase()))
1359
- b.remove();
1438
+ function m(d) {
1439
+ const x = Array.from(d.children);
1440
+ for (const _ of x)
1441
+ if (!a.has(_.tagName.toLowerCase()))
1442
+ _.remove();
1360
1443
  else {
1361
- for (const $ of Array.from(b.attributes))
1362
- d.has($.name.toLowerCase()) || b.removeAttribute($.name);
1363
- y(b);
1444
+ for (const $ of Array.from(_.attributes))
1445
+ h.has($.name.toLowerCase()) || _.removeAttribute($.name);
1446
+ m(_);
1364
1447
  }
1365
1448
  }
1366
- return y(c), c.outerHTML;
1449
+ return m(c), c.outerHTML;
1367
1450
  }
1368
- function r() {
1369
- const i = n.plugins.value.filter((h) => typeof h.icon == "string");
1370
- t.value.forEach((h, a) => {
1371
- h && i[a] && (h.innerHTML = u(i[a].icon));
1451
+ function s() {
1452
+ const i = n.plugins.value.filter((v) => typeof v.icon == "string");
1453
+ t.value.forEach((v, l) => {
1454
+ v && i[l] && (v.innerHTML = r(i[l].icon));
1372
1455
  });
1373
1456
  }
1374
- return ue(r), Ne(r), (i, h) => (M(), z("div", St, [
1375
- (M(!0), z(X, null, N(S(n).plugins.value, (a) => (M(), z("button", {
1376
- key: a.id,
1457
+ return ge(s), ft(s), (i, v) => (S(), z("div", Yt, [
1458
+ (S(!0), z(Y, null, Z(I(n).plugins.value, (l) => (S(), z("button", {
1459
+ key: l.id,
1377
1460
  role: "tab",
1378
- "aria-selected": a.id === S(n).activePluginId.value,
1379
- class: U([
1461
+ "aria-selected": l.id === I(n).activePluginId.value,
1462
+ class: N([
1380
1463
  "vie-tab",
1381
- { "vie-tab--active": a.id === S(n).activePluginId.value }
1464
+ { "vie-tab--active": l.id === I(n).activePluginId.value }
1382
1465
  ]),
1383
- onClick: (c) => S(n).setActivePlugin(a.id)
1466
+ onClick: (c) => I(n).setActivePlugin(l.id)
1384
1467
  }, [
1385
- typeof a.icon == "string" ? (M(), z("span", {
1468
+ typeof l.icon == "string" ? (S(), z("span", {
1386
1469
  key: 0,
1387
1470
  class: "vie-tab__icon",
1388
1471
  ref_for: !0,
1389
1472
  ref_key: "iconRefs",
1390
1473
  ref: t
1391
- }, null, 512)) : (M(), le(be(a.icon), {
1474
+ }, null, 512)) : (S(), pe(Pe(l.icon), {
1392
1475
  key: 1,
1393
1476
  class: "vie-tab__icon"
1394
1477
  })),
1395
- g("span", Rt, q(S(e)(a.labelKey)), 1)
1396
- ], 10, $t))), 128))
1478
+ y("span", Nt, q(I(e)(l.labelKey)), 1)
1479
+ ], 10, Ut))), 128))
1397
1480
  ]));
1398
1481
  }
1399
- }), zt = {
1482
+ }), Zt = {
1400
1483
  key: 0,
1401
1484
  class: "vie-control-panel"
1402
- }, Ie = /* @__PURE__ */ Y({
1485
+ }, Ve = /* @__PURE__ */ J({
1403
1486
  __name: "EditorControlPanel",
1404
- setup(s) {
1405
- const e = G();
1487
+ setup(o) {
1488
+ const e = ee();
1406
1489
  return (n, t) => {
1407
- var o;
1408
- return (o = S(e).activePlugin.value) != null && o.controls ? (M(), z("div", zt, [
1409
- j(_e, {
1490
+ var a;
1491
+ return (a = I(e).activePlugin.value) != null && a.controls ? (S(), z("div", Zt, [
1492
+ X(Te, {
1410
1493
  name: "vie-panel",
1411
1494
  mode: "out-in"
1412
1495
  }, {
1413
- default: J(() => [
1414
- (M(), le(be(S(e).activePlugin.value.controls), {
1415
- key: S(e).activePluginId.value
1496
+ default: ne(() => [
1497
+ (S(), pe(Pe(I(e).activePlugin.value.controls), {
1498
+ key: I(e).activePluginId.value
1416
1499
  }))
1417
1500
  ]),
1418
1501
  _: 1
1419
1502
  })
1420
- ])) : Z("", !0);
1503
+ ])) : G("", !0);
1421
1504
  };
1422
1505
  }
1423
- }), It = ["aria-valuemin", "aria-valuemax", "aria-valuenow", "aria-labelledby"], Pt = { class: "vie-slider__track" }, Tt = {
1506
+ }), Jt = ["aria-valuemin", "aria-valuemax", "aria-valuenow", "aria-labelledby"], Gt = { class: "vie-slider__track" }, Qt = {
1424
1507
  key: 0,
1425
1508
  class: "vie-slider__tooltip"
1426
- }, Et = { class: "vie-slider__value" }, ve = /* @__PURE__ */ Y({
1509
+ }, en = { class: "vie-slider__value" }, fe = /* @__PURE__ */ J({
1427
1510
  __name: "Slider",
1428
1511
  props: {
1429
1512
  modelValue: {},
@@ -1436,174 +1519,179 @@ const xt = {
1436
1519
  ticks: {}
1437
1520
  },
1438
1521
  emits: ["update:modelValue"],
1439
- setup(s, { emit: e }) {
1440
- const n = `vie-slider-${Math.random().toString(36).slice(2, 9)}`, t = s, o = e, d = H(null), u = H(!1), r = V(() => (t.modelValue - t.min) / (t.max - t.min)), i = V(() => (t.base - t.min) / (t.max - t.min)), h = V(() => t.ticks ? t.ticks.map((m) => (m - t.min) / (t.max - t.min)) : []), a = V(() => Math.max(0, Math.min(100, r.value * 100))), c = V(() => {
1441
- const m = Math.max(0, Math.min(1, Math.min(i.value, r.value))), l = Math.max(0, Math.min(1, Math.max(i.value, r.value)));
1522
+ setup(o, { emit: e }) {
1523
+ const n = `vie-slider-${Math.random().toString(36).slice(2, 9)}`, t = o, a = e, h = H(null), r = H(!1), s = j(() => (t.modelValue - t.min) / (t.max - t.min)), i = j(() => (t.base - t.min) / (t.max - t.min)), v = j(() => t.ticks ? t.ticks.map((w) => (w - t.min) / (t.max - t.min)) : []), l = j(() => Math.max(0, Math.min(100, s.value * 100))), c = j(() => {
1524
+ const w = Math.max(0, Math.min(1, Math.min(i.value, s.value))), u = Math.max(0, Math.min(1, Math.max(i.value, s.value)));
1442
1525
  return {
1443
- left: m * 100 + "%",
1444
- width: (l - m) * 100 + "%"
1526
+ insetInlineStart: w * 100 + "%",
1527
+ insetInlineEnd: (1 - u) * 100 + "%"
1445
1528
  };
1446
- }), y = V(() => t.format === "percent" ? Math.round(t.modelValue * 100) + "%" : t.modelValue.toFixed(2));
1447
- function v(m) {
1448
- if (!d.value) return t.modelValue;
1449
- const l = d.value.getBoundingClientRect(), p = getComputedStyle(d.value).direction === "rtl";
1450
- let f;
1451
- p ? f = (l.right - m.clientX) / l.width : f = (m.clientX - l.left) / l.width, f = Math.max(0, Math.min(1, f));
1452
- let k = t.min + f * (t.max - t.min);
1453
- return k = Math.round(k / t.step) * t.step, Math.max(t.min, Math.min(t.max, k));
1454
- }
1455
- function w(m) {
1456
- if (m.button !== 0) return;
1457
- u.value = !0, o("update:modelValue", v(m));
1458
- const l = (f) => {
1459
- o("update:modelValue", v(f));
1460
- }, p = () => {
1461
- u.value = !1, window.removeEventListener("pointermove", l), window.removeEventListener("pointerup", p);
1529
+ }), m = j(() => t.format === "percent" ? Math.round(t.modelValue * 100) + "%" : t.modelValue.toFixed(2));
1530
+ function d(w) {
1531
+ if (!h.value) return t.modelValue;
1532
+ const u = h.value.getBoundingClientRect(), g = getComputedStyle(h.value).direction === "rtl";
1533
+ let k;
1534
+ g ? k = (u.right - w.clientX) / u.width : k = (w.clientX - u.left) / u.width, k = Math.max(0, Math.min(1, k));
1535
+ let C = t.min + k * (t.max - t.min);
1536
+ return C = Math.round(C / t.step) * t.step, Math.max(t.min, Math.min(t.max, C));
1537
+ }
1538
+ function x(w) {
1539
+ if (w.button !== 0) return;
1540
+ r.value = !0, a("update:modelValue", d(w));
1541
+ const u = (k) => {
1542
+ a("update:modelValue", d(k));
1543
+ }, g = () => {
1544
+ r.value = !1, window.removeEventListener("pointermove", u), window.removeEventListener("pointerup", g);
1462
1545
  };
1463
- window.addEventListener("pointermove", l), window.addEventListener("pointerup", p);
1546
+ window.addEventListener("pointermove", u), window.addEventListener("pointerup", g);
1464
1547
  }
1465
- function b() {
1466
- o("update:modelValue", t.base);
1548
+ function _() {
1549
+ a("update:modelValue", t.base);
1467
1550
  }
1468
- function $(m) {
1469
- let l = t.modelValue;
1470
- switch (m.key) {
1551
+ function $(w) {
1552
+ let u = t.modelValue;
1553
+ const k = (h.value ? getComputedStyle(h.value).direction === "rtl" : !1) ? -t.step : t.step;
1554
+ switch (w.key) {
1471
1555
  case "ArrowRight":
1472
- case "ArrowUp":
1473
- l = Math.min(t.max, t.modelValue + t.step);
1556
+ u = t.modelValue + k;
1474
1557
  break;
1475
1558
  case "ArrowLeft":
1559
+ u = t.modelValue - k;
1560
+ break;
1561
+ case "ArrowUp":
1562
+ u = t.modelValue + t.step;
1563
+ break;
1476
1564
  case "ArrowDown":
1477
- l = Math.max(t.min, t.modelValue - t.step);
1565
+ u = t.modelValue - t.step;
1478
1566
  break;
1479
1567
  case "Home":
1480
- l = t.min;
1568
+ u = t.min;
1481
1569
  break;
1482
1570
  case "End":
1483
- l = t.max;
1571
+ u = t.max;
1484
1572
  break;
1485
1573
  default:
1486
1574
  return;
1487
1575
  }
1488
- m.preventDefault(), o("update:modelValue", Math.round(l / t.step) * t.step);
1576
+ w.preventDefault(), u = Math.max(t.min, Math.min(t.max, u)), a("update:modelValue", Math.round(u / t.step) * t.step);
1489
1577
  }
1490
- return (m, l) => (M(), z("div", {
1491
- class: U(["vie-slider", { "vie-slider--dragging": u.value }])
1578
+ return (w, u) => (S(), z("div", {
1579
+ class: N(["vie-slider", { "vie-slider--dragging": r.value }])
1492
1580
  }, [
1493
- s.label ? (M(), z("span", {
1581
+ o.label ? (S(), z("span", {
1494
1582
  key: 0,
1495
1583
  class: "vie-slider__label",
1496
1584
  id: n
1497
- }, q(s.label), 1)) : Z("", !0),
1498
- g("div", {
1585
+ }, q(o.label), 1)) : G("", !0),
1586
+ y("div", {
1499
1587
  ref_key: "trackRef",
1500
- ref: d,
1588
+ ref: h,
1501
1589
  class: "vie-slider__track-wrapper",
1502
1590
  role: "slider",
1503
1591
  tabindex: "0",
1504
- "aria-valuemin": s.min,
1505
- "aria-valuemax": s.max,
1506
- "aria-valuenow": s.modelValue,
1507
- "aria-labelledby": s.label ? n : void 0,
1508
- onPointerdown: w,
1509
- onDblclick: b,
1592
+ "aria-valuemin": o.min,
1593
+ "aria-valuemax": o.max,
1594
+ "aria-valuenow": o.modelValue,
1595
+ "aria-labelledby": o.label ? n : void 0,
1596
+ onPointerdown: x,
1597
+ onDblclick: _,
1510
1598
  onKeydown: $
1511
1599
  }, [
1512
- g("div", Pt, [
1513
- g("div", {
1600
+ y("div", Gt, [
1601
+ y("div", {
1514
1602
  class: "vie-slider__base-mark",
1515
- style: se({ left: i.value * 100 + "%" })
1603
+ style: le({ insetInlineStart: i.value * 100 + "%" })
1516
1604
  }, null, 4),
1517
- (M(!0), z(X, null, N(h.value, (p, f) => (M(), z("div", {
1518
- key: f,
1605
+ (S(!0), z(Y, null, Z(v.value, (g, k) => (S(), z("div", {
1606
+ key: k,
1519
1607
  class: "vie-slider__tick",
1520
- style: se({ left: p * 100 + "%" })
1608
+ style: le({ insetInlineStart: g * 100 + "%" })
1521
1609
  }, null, 4))), 128)),
1522
- g("div", {
1610
+ y("div", {
1523
1611
  class: "vie-slider__fill",
1524
- style: se(c.value)
1612
+ style: le(c.value)
1525
1613
  }, null, 4),
1526
- g("div", {
1614
+ y("div", {
1527
1615
  class: "vie-slider__thumb",
1528
- style: se({ left: a.value + "%" })
1616
+ style: le({ insetInlineStart: l.value + "%" })
1529
1617
  }, [
1530
- l[0] || (l[0] = g("span", { class: "vie-slider__thumb-dot" }, null, -1)),
1531
- u.value ? (M(), z("span", Tt, q(y.value), 1)) : Z("", !0)
1618
+ u[0] || (u[0] = y("span", { class: "vie-slider__thumb-dot" }, null, -1)),
1619
+ r.value ? (S(), z("span", Qt, q(m.value), 1)) : G("", !0)
1532
1620
  ], 4)
1533
1621
  ])
1534
- ], 40, It),
1535
- g("span", Et, q(y.value), 1)
1622
+ ], 40, Jt),
1623
+ y("span", en, q(m.value), 1)
1536
1624
  ], 2));
1537
1625
  }
1538
- }), Wt = ["aria-expanded"], Kt = {
1626
+ }), tn = ["aria-expanded"], nn = {
1539
1627
  key: 0,
1540
1628
  class: "vie-dropdown__menu",
1541
1629
  role: "listbox"
1542
- }, Dt = ["aria-selected", "onClick"], Lt = /* @__PURE__ */ Y({
1630
+ }, on = ["aria-selected", "onClick"], an = /* @__PURE__ */ J({
1543
1631
  __name: "Dropdown",
1544
1632
  props: {
1545
1633
  modelValue: {},
1546
1634
  options: {}
1547
1635
  },
1548
1636
  emits: ["update:modelValue"],
1549
- setup(s, { emit: e }) {
1550
- const n = s, t = e, o = H(!1), d = H(null), u = V(() => {
1551
- const h = n.options.find((a) => a.value === n.modelValue);
1552
- return h ? h.label : "";
1637
+ setup(o, { emit: e }) {
1638
+ const n = o, t = e, a = H(!1), h = H(null), r = j(() => {
1639
+ const v = n.options.find((l) => l.value === n.modelValue);
1640
+ return v ? v.label : "";
1553
1641
  });
1554
- function r(h) {
1555
- t("update:modelValue", h), o.value = !1;
1642
+ function s(v) {
1643
+ t("update:modelValue", v), a.value = !1;
1556
1644
  }
1557
- function i(h) {
1558
- d.value && !d.value.contains(h.target) && (o.value = !1);
1645
+ function i(v) {
1646
+ h.value && !h.value.contains(v.target) && (a.value = !1);
1559
1647
  }
1560
- return ne(o, (h) => {
1561
- h ? document.addEventListener("click", i) : document.removeEventListener("click", i);
1562
- }), re(() => {
1648
+ return re(a, (v) => {
1649
+ v ? document.addEventListener("click", i) : document.removeEventListener("click", i);
1650
+ }), he(() => {
1563
1651
  document.removeEventListener("click", i);
1564
- }), (h, a) => (M(), z("div", {
1652
+ }), (v, l) => (S(), z("div", {
1565
1653
  class: "vie-dropdown",
1566
1654
  ref_key: "dropdownRef",
1567
- ref: d
1655
+ ref: h
1568
1656
  }, [
1569
- g("button", {
1657
+ y("button", {
1570
1658
  class: "vie-dropdown__trigger",
1571
1659
  role: "combobox",
1572
- "aria-expanded": o.value,
1660
+ "aria-expanded": a.value,
1573
1661
  "aria-haspopup": "listbox",
1574
- onClick: a[0] || (a[0] = (c) => o.value = !o.value)
1662
+ onClick: l[0] || (l[0] = (c) => a.value = !a.value)
1575
1663
  }, [
1576
- g("span", null, q(u.value), 1),
1577
- a[1] || (a[1] = g("svg", {
1664
+ y("span", null, q(r.value), 1),
1665
+ l[1] || (l[1] = y("svg", {
1578
1666
  class: "vie-dropdown__chevron",
1579
1667
  viewBox: "0 0 24 24",
1580
1668
  fill: "none",
1581
1669
  stroke: "currentColor",
1582
1670
  "stroke-width": "2"
1583
1671
  }, [
1584
- g("path", { d: "M6 9l6 6 6-6" })
1672
+ y("path", { d: "M6 9l6 6 6-6" })
1585
1673
  ], -1))
1586
- ], 8, Wt),
1587
- j(_e, { name: "vie-dropdown" }, {
1588
- default: J(() => [
1589
- o.value ? (M(), z("div", Kt, [
1590
- (M(!0), z(X, null, N(s.options, (c) => (M(), z("button", {
1674
+ ], 8, tn),
1675
+ X(Te, { name: "vie-dropdown" }, {
1676
+ default: ne(() => [
1677
+ a.value ? (S(), z("div", nn, [
1678
+ (S(!0), z(Y, null, Z(o.options, (c) => (S(), z("button", {
1591
1679
  key: c.value,
1592
1680
  role: "option",
1593
- "aria-selected": c.value === s.modelValue,
1594
- class: U([
1681
+ "aria-selected": c.value === o.modelValue,
1682
+ class: N([
1595
1683
  "vie-dropdown__item",
1596
- { "vie-dropdown__item--active": c.value === s.modelValue }
1684
+ { "vie-dropdown__item--active": c.value === o.modelValue }
1597
1685
  ]),
1598
- onClick: (y) => r(c.value)
1599
- }, q(c.label), 11, Dt))), 128))
1600
- ])) : Z("", !0)
1686
+ onClick: (m) => s(c.value)
1687
+ }, q(c.label), 11, on))), 128))
1688
+ ])) : G("", !0)
1601
1689
  ]),
1602
1690
  _: 1
1603
1691
  })
1604
1692
  ], 512));
1605
1693
  }
1606
- }), At = [
1694
+ }), sn = [
1607
1695
  { labelKey: "custom", value: null },
1608
1696
  { labelKey: "square", value: 1 },
1609
1697
  { labelKey: "landscape", value: 4 / 3 },
@@ -1611,113 +1699,113 @@ const xt = {
1611
1699
  { labelKey: "portrait", value: 3 / 4 },
1612
1700
  { labelKey: "portrait", value: 9 / 16 }
1613
1701
  ];
1614
- function Ft(s, e) {
1615
- if (s.value === null) return e("custom");
1616
- if (s.value === 1) return e("square") + " 1:1";
1702
+ function ln(o, e) {
1703
+ if (o.value === null) return e("custom");
1704
+ if (o.value === 1) return e("square") + " 1:1";
1617
1705
  const t = {
1618
1706
  [4 / 3]: "4:3",
1619
1707
  [16 / 9]: "16:9",
1620
1708
  [3 / 4]: "3:4",
1621
1709
  [9 / 16]: "9:16"
1622
- }[s.value] || `${s.value.toFixed(2)}`, o = s.value > 1 ? "landscape" : "portrait";
1623
- return `${e(o)} ${t}`;
1710
+ }[o.value] || `${o.value.toFixed(2)}`, a = o.value > 1 ? "landscape" : "portrait";
1711
+ return `${e(a)} ${t}`;
1624
1712
  }
1625
- const Ht = { class: "vie-crop-controls" }, Vt = { class: "vie-crop-controls__section" }, Ot = { class: "vie-crop-controls__section" }, jt = { class: "vie-crop-controls__section" }, Bt = { class: "vie-crop-controls__rotation" }, qt = /* @__PURE__ */ Y({
1713
+ const rn = { class: "vie-crop-controls" }, cn = { class: "vie-crop-controls__section" }, un = { class: "vie-crop-controls__section" }, dn = { class: "vie-crop-controls__section" }, hn = { class: "vie-crop-controls__rotation" }, vn = /* @__PURE__ */ J({
1626
1714
  __name: "CropControls",
1627
- setup(s) {
1628
- const e = Q(ee, (m) => m), n = G();
1715
+ setup(o) {
1716
+ const e = ie(oe, (w) => w), n = ee();
1629
1717
  let t = !1;
1630
- ne(() => n.sourceImage.value, (m) => {
1631
- if (!m || t) return;
1632
- const l = n.state.crop;
1633
- if (!(l.x === 0 && l.y === 0 && l.width === 1 && l.height === 1 && l.aspectRatio === null && l.rotation === 0 && !l.flipX && !l.flipY)) return;
1718
+ re(() => n.sourceImage.value, (w) => {
1719
+ if (!w || t) return;
1720
+ const u = n.state.crop;
1721
+ if (!(u.x === 0 && u.y === 0 && u.width === 1 && u.height === 1 && u.aspectRatio === null && u.rotation === 0 && !u.flipX && !u.flipY)) return;
1634
1722
  t = !0;
1635
- const f = m.naturalWidth / m.naturalHeight;
1636
- if (f >= 1) {
1637
- const k = 1 / f;
1638
- n.updateState((x) => {
1639
- x.crop.x = (1 - k) / 2, x.crop.y = 0, x.crop.width = k, x.crop.height = 1, x.crop.aspectRatio = 1;
1723
+ const k = w.naturalWidth / w.naturalHeight;
1724
+ if (k >= 1) {
1725
+ const C = 1 / k;
1726
+ n.updateState((P) => {
1727
+ P.crop.x = (1 - C) / 2, P.crop.y = 0, P.crop.width = C, P.crop.height = 1, P.crop.aspectRatio = 1;
1640
1728
  });
1641
1729
  } else {
1642
- const k = f;
1643
- n.updateState((x) => {
1644
- x.crop.x = 0, x.crop.y = (1 - k) / 2, x.crop.width = 1, x.crop.height = k, x.crop.aspectRatio = 1;
1730
+ const C = k;
1731
+ n.updateState((P) => {
1732
+ P.crop.x = 0, P.crop.y = (1 - C) / 2, P.crop.width = 1, P.crop.height = C, P.crop.aspectRatio = 1;
1645
1733
  });
1646
1734
  }
1647
1735
  }, { immediate: !0 });
1648
- const o = V(
1649
- () => At.map((m) => ({
1650
- label: Ft(m, e),
1651
- value: m.value == null ? "custom" : m.value
1736
+ const a = j(
1737
+ () => sn.map((w) => ({
1738
+ label: ln(w, e),
1739
+ value: w.value == null ? "custom" : w.value
1652
1740
  }))
1653
- ), d = V(() => {
1654
- const m = n.state.crop.aspectRatio;
1655
- return m === null ? "custom" : m;
1741
+ ), h = j(() => {
1742
+ const w = n.state.crop.aspectRatio;
1743
+ return w === null ? "custom" : w;
1656
1744
  });
1657
- function u(m) {
1658
- const l = m === "custom" ? null : Number(m);
1659
- n.updateState((p) => {
1660
- if (p.crop.aspectRatio = l, l !== null) {
1661
- const f = p.crop.width, k = p.crop.height;
1662
- if (f / k > l) {
1663
- const D = k * l;
1664
- p.crop.x += (f - D) / 2, p.crop.width = D;
1745
+ function r(w) {
1746
+ const u = w === "custom" ? null : Number(w);
1747
+ n.updateState((g) => {
1748
+ if (g.crop.aspectRatio = u, u !== null) {
1749
+ const k = g.crop.width, C = g.crop.height;
1750
+ if (k / C > u) {
1751
+ const V = C * u;
1752
+ g.crop.x += (k - V) / 2, g.crop.width = V;
1665
1753
  } else {
1666
- const D = f / l;
1667
- p.crop.y += (k - D) / 2, p.crop.height = D;
1754
+ const V = k / u;
1755
+ g.crop.y += (C - V) / 2, g.crop.height = V;
1668
1756
  }
1669
1757
  }
1670
1758
  });
1671
1759
  }
1672
- const r = H(0), i = n.state.crop.rotation, h = Math.round(i / (Math.PI / 2));
1673
- r.value = (h % 4 + 4) % 4;
1674
- function a() {
1675
- return n.state.crop.rotation - r.value * (Math.PI / 2);
1760
+ const s = H(0), i = n.state.crop.rotation, v = Math.round(i / (Math.PI / 2));
1761
+ s.value = (v % 4 + 4) % 4;
1762
+ function l() {
1763
+ return n.state.crop.rotation - s.value * (Math.PI / 2);
1676
1764
  }
1677
- const c = V(() => a() * 180 / Math.PI);
1678
- function y(m) {
1679
- n.updateState((l) => {
1680
- l.crop.rotation = r.value * (Math.PI / 2) + m * Math.PI / 180;
1765
+ const c = j(() => l() * 180 / Math.PI);
1766
+ function m(w) {
1767
+ n.updateState((u) => {
1768
+ u.crop.rotation = s.value * (Math.PI / 2) + w * Math.PI / 180;
1681
1769
  });
1682
1770
  }
1683
- function v() {
1684
- const m = a();
1685
- r.value = ((r.value - 1) % 4 + 4) % 4, n.updateState((l) => {
1686
- l.crop.rotation = r.value * (Math.PI / 2) + m;
1771
+ function d() {
1772
+ const w = l();
1773
+ s.value = ((s.value - 1) % 4 + 4) % 4, n.updateState((u) => {
1774
+ u.crop.rotation = s.value * (Math.PI / 2) + w;
1687
1775
  });
1688
1776
  }
1689
- function w() {
1690
- const m = a();
1691
- r.value = (r.value + 1) % 4, n.updateState((l) => {
1692
- l.crop.rotation = r.value * (Math.PI / 2) + m;
1777
+ function x() {
1778
+ const w = l();
1779
+ s.value = (s.value + 1) % 4, n.updateState((u) => {
1780
+ u.crop.rotation = s.value * (Math.PI / 2) + w;
1693
1781
  });
1694
1782
  }
1695
- function b() {
1696
- n.updateState((m) => {
1697
- m.crop.flipX = !m.crop.flipX;
1783
+ function _() {
1784
+ n.updateState((w) => {
1785
+ w.crop.flipX = !w.crop.flipX;
1698
1786
  });
1699
1787
  }
1700
1788
  function $() {
1701
- n.updateState((m) => {
1702
- m.crop.flipY = !m.crop.flipY;
1789
+ n.updateState((w) => {
1790
+ w.crop.flipY = !w.crop.flipY;
1703
1791
  });
1704
1792
  }
1705
- return (m, l) => (M(), z("div", Ht, [
1706
- g("div", Vt, [
1707
- j(Lt, {
1708
- "model-value": d.value,
1709
- options: o.value,
1710
- "onUpdate:modelValue": u
1793
+ return (w, u) => (S(), z("div", rn, [
1794
+ y("div", cn, [
1795
+ X(an, {
1796
+ "model-value": h.value,
1797
+ options: a.value,
1798
+ "onUpdate:modelValue": r
1711
1799
  }, null, 8, ["model-value", "options"])
1712
1800
  ]),
1713
- l[4] || (l[4] = g("div", { class: "vie-crop-controls__divider" }, null, -1)),
1714
- g("div", Ot, [
1715
- j(te, {
1716
- title: S(e)("rotateLeft"),
1717
- onClick: v
1801
+ u[4] || (u[4] = y("div", { class: "vie-crop-controls__divider" }, null, -1)),
1802
+ y("div", un, [
1803
+ X(se, {
1804
+ title: I(e)("rotateLeft"),
1805
+ onClick: d
1718
1806
  }, {
1719
- default: J(() => [...l[0] || (l[0] = [
1720
- g("svg", {
1807
+ default: ne(() => [...u[0] || (u[0] = [
1808
+ y("svg", {
1721
1809
  viewBox: "0 0 24 24",
1722
1810
  fill: "none",
1723
1811
  stroke: "currentColor",
@@ -1725,18 +1813,18 @@ const Ht = { class: "vie-crop-controls" }, Vt = { class: "vie-crop-controls__sec
1725
1813
  "stroke-linecap": "round",
1726
1814
  "stroke-linejoin": "round"
1727
1815
  }, [
1728
- g("path", { d: "M2.5 2v6h6" }),
1729
- g("path", { d: "M2.5 8C5 4 9 2 13 2a9 9 0 1 1-6 15.7" })
1816
+ y("path", { d: "M2.5 2v6h6" }),
1817
+ y("path", { d: "M2.5 8C5 4 9 2 13 2a9 9 0 1 1-6 15.7" })
1730
1818
  ], -1)
1731
1819
  ])]),
1732
1820
  _: 1
1733
1821
  }, 8, ["title"]),
1734
- j(te, {
1735
- title: S(e)("rotateRight"),
1736
- onClick: w
1822
+ X(se, {
1823
+ title: I(e)("rotateRight"),
1824
+ onClick: x
1737
1825
  }, {
1738
- default: J(() => [...l[1] || (l[1] = [
1739
- g("svg", {
1826
+ default: ne(() => [...u[1] || (u[1] = [
1827
+ y("svg", {
1740
1828
  viewBox: "0 0 24 24",
1741
1829
  fill: "none",
1742
1830
  stroke: "currentColor",
@@ -1744,58 +1832,58 @@ const Ht = { class: "vie-crop-controls" }, Vt = { class: "vie-crop-controls__sec
1744
1832
  "stroke-linecap": "round",
1745
1833
  "stroke-linejoin": "round"
1746
1834
  }, [
1747
- g("path", { d: "M21.5 2v6h-6" }),
1748
- g("path", { d: "M21.5 8C19 4 15 2 11 2a9 9 0 1 0 6 15.7" })
1835
+ y("path", { d: "M21.5 2v6h-6" }),
1836
+ y("path", { d: "M21.5 8C19 4 15 2 11 2a9 9 0 1 0 6 15.7" })
1749
1837
  ], -1)
1750
1838
  ])]),
1751
1839
  _: 1
1752
1840
  }, 8, ["title"])
1753
1841
  ]),
1754
- l[5] || (l[5] = g("div", { class: "vie-crop-controls__divider" }, null, -1)),
1755
- g("div", jt, [
1756
- j(te, {
1757
- title: S(e)("flipHorizontal"),
1758
- onClick: b
1842
+ u[5] || (u[5] = y("div", { class: "vie-crop-controls__divider" }, null, -1)),
1843
+ y("div", dn, [
1844
+ X(se, {
1845
+ title: I(e)("flipHorizontal"),
1846
+ onClick: _
1759
1847
  }, {
1760
- default: J(() => [...l[2] || (l[2] = [
1761
- g("svg", {
1848
+ default: ne(() => [...u[2] || (u[2] = [
1849
+ y("svg", {
1762
1850
  viewBox: "0 0 24 24",
1763
1851
  fill: "none",
1764
1852
  stroke: "currentColor",
1765
1853
  "stroke-width": "2",
1766
1854
  "stroke-linecap": "round"
1767
1855
  }, [
1768
- g("path", { d: "M12 3v18" }),
1769
- g("path", { d: "M16 7l4 5-4 5" }),
1770
- g("path", { d: "M8 7L4 12l4 5" })
1856
+ y("path", { d: "M12 3v18" }),
1857
+ y("path", { d: "M16 7l4 5-4 5" }),
1858
+ y("path", { d: "M8 7L4 12l4 5" })
1771
1859
  ], -1)
1772
1860
  ])]),
1773
1861
  _: 1
1774
1862
  }, 8, ["title"]),
1775
- j(te, {
1776
- title: S(e)("flipVertical"),
1863
+ X(se, {
1864
+ title: I(e)("flipVertical"),
1777
1865
  onClick: $
1778
1866
  }, {
1779
- default: J(() => [...l[3] || (l[3] = [
1780
- g("svg", {
1867
+ default: ne(() => [...u[3] || (u[3] = [
1868
+ y("svg", {
1781
1869
  viewBox: "0 0 24 24",
1782
1870
  fill: "none",
1783
1871
  stroke: "currentColor",
1784
1872
  "stroke-width": "2",
1785
1873
  "stroke-linecap": "round"
1786
1874
  }, [
1787
- g("path", { d: "M3 12h18" }),
1788
- g("path", { d: "M7 8L12 4l5 4" }),
1789
- g("path", { d: "M7 16l5 4 5-4" })
1875
+ y("path", { d: "M3 12h18" }),
1876
+ y("path", { d: "M7 8L12 4l5 4" }),
1877
+ y("path", { d: "M7 16l5 4 5-4" })
1790
1878
  ], -1)
1791
1879
  ])]),
1792
1880
  _: 1
1793
1881
  }, 8, ["title"])
1794
1882
  ]),
1795
- l[6] || (l[6] = g("div", { class: "vie-crop-controls__divider" }, null, -1)),
1796
- g("div", Bt, [
1797
- j(ve, {
1798
- label: S(e)("rotation"),
1883
+ u[6] || (u[6] = y("div", { class: "vie-crop-controls__divider" }, null, -1)),
1884
+ y("div", hn, [
1885
+ X(fe, {
1886
+ label: I(e)("rotation"),
1799
1887
  "model-value": c.value,
1800
1888
  min: -45,
1801
1889
  max: 45,
@@ -1803,262 +1891,262 @@ const Ht = { class: "vie-crop-controls" }, Vt = { class: "vie-crop-controls__sec
1803
1891
  base: 0,
1804
1892
  format: "number",
1805
1893
  ticks: [-45, -30, -15, 0, 15, 30, 45],
1806
- "onUpdate:modelValue": y
1894
+ "onUpdate:modelValue": m
1807
1895
  }, null, 8, ["label", "model-value"])
1808
1896
  ])
1809
1897
  ]));
1810
1898
  }
1811
- }), Xt = ["viewBox", "width", "height"], Yt = ["width", "height"], Ut = ["x", "y", "width", "height"], Nt = ["width", "height", "mask"], Zt = ["x", "y", "width", "height"], Jt = {
1899
+ }), fn = ["viewBox", "width", "height"], pn = ["width", "height"], mn = ["x", "y", "width", "height"], gn = ["width", "height", "mask"], yn = ["x", "y", "width", "height"], wn = {
1812
1900
  key: 0,
1813
1901
  class: "vie-crop-grid"
1814
- }, Gt = ["x1", "y1", "x2", "y2"], Qt = ["x1", "y1", "x2", "y2"], en = ["x", "y", "width", "height"], tn = ["x", "y", "data-handle"], nn = ["x", "y", "width", "height", "data-handle"], on = ["x", "y"], an = {
1902
+ }, kn = ["x1", "y1", "x2", "y2"], bn = ["x1", "y1", "x2", "y2"], xn = ["x", "y", "width", "height"], _n = ["x", "y", "data-handle"], Cn = ["x", "y", "width", "height", "data-handle"], Mn = ["x", "y"], Sn = {
1815
1903
  xmlns: "http://www.w3.org/1999/xhtml",
1816
1904
  style: { display: "flex", "justify-content": "center", "pointer-events": "none" }
1817
- }, ae = 12, sn = 8, rn = 32, ln = /* @__PURE__ */ Y({
1905
+ }, de = 12, $n = 8, Rn = 32, zn = /* @__PURE__ */ J({
1818
1906
  __name: "CropOverlay",
1819
1907
  props: {
1820
1908
  canvasRect: {},
1821
1909
  wrapperSize: {}
1822
1910
  },
1823
- setup(s) {
1824
- const e = `vie-crop-mask-${Math.random().toString(36).slice(2, 9)}`, n = s, t = G(), o = Q(ee, (p) => p), d = V(() => n.wrapperSize.width || 800), u = V(() => n.wrapperSize.height || 600), r = V(() => {
1825
- const p = n.canvasRect, f = t.state.crop;
1911
+ setup(o) {
1912
+ const e = `vie-crop-mask-${Math.random().toString(36).slice(2, 9)}`, n = o, t = ee(), a = ie(oe, (g) => g), h = j(() => n.wrapperSize.width || 800), r = j(() => n.wrapperSize.height || 600), s = j(() => {
1913
+ const g = n.canvasRect, k = t.state.crop;
1826
1914
  return {
1827
- x: p.x + f.x * p.width,
1828
- y: p.y + f.y * p.height,
1829
- width: f.width * p.width,
1830
- height: f.height * p.height
1915
+ x: g.x + k.x * g.width,
1916
+ y: g.y + k.y * g.height,
1917
+ width: k.width * g.width,
1918
+ height: k.height * g.height
1831
1919
  };
1832
- }), i = V(() => {
1833
- const p = r.value, k = ae / 2;
1920
+ }), i = j(() => {
1921
+ const g = s.value, C = de / 2;
1834
1922
  return [
1835
- { id: "nw", x: p.x - k, y: p.y - k },
1836
- { id: "ne", x: p.x + p.width - k, y: p.y - k },
1837
- { id: "sw", x: p.x - k, y: p.y + p.height - k },
1838
- { id: "se", x: p.x + p.width - k, y: p.y + p.height - k }
1923
+ { id: "nw", x: g.x - C, y: g.y - C },
1924
+ { id: "ne", x: g.x + g.width - C, y: g.y - C },
1925
+ { id: "sw", x: g.x - C, y: g.y + g.height - C },
1926
+ { id: "se", x: g.x + g.width - C, y: g.y + g.height - C }
1839
1927
  ];
1840
- }), h = V(() => {
1841
- const p = r.value, f = Math.min(rn, p.width * 0.3, p.height * 0.3), k = sn;
1928
+ }), v = j(() => {
1929
+ const g = s.value, k = Math.min(Rn, g.width * 0.3, g.height * 0.3), C = $n;
1842
1930
  return [
1843
- { id: "n", x: p.x + (p.width - f) / 2, y: p.y - k / 2, w: f, h: k },
1844
- { id: "s", x: p.x + (p.width - f) / 2, y: p.y + p.height - k / 2, w: f, h: k },
1845
- { id: "w", x: p.x - k / 2, y: p.y + (p.height - f) / 2, w: k, h: f },
1846
- { id: "e", x: p.x + p.width - k / 2, y: p.y + (p.height - f) / 2, w: k, h: f }
1931
+ { id: "n", x: g.x + (g.width - k) / 2, y: g.y - C / 2, w: k, h: C },
1932
+ { id: "s", x: g.x + (g.width - k) / 2, y: g.y + g.height - C / 2, w: k, h: C },
1933
+ { id: "w", x: g.x - C / 2, y: g.y + (g.height - k) / 2, w: C, h: k },
1934
+ { id: "e", x: g.x + g.width - C / 2, y: g.y + (g.height - k) / 2, w: C, h: k }
1847
1935
  ];
1848
- }), a = H(null), c = H({ x: 0, y: 0 }), y = H({ x: 0, y: 0, width: 0, height: 0 }), v = H(!1);
1849
- let w = null;
1850
- function b(p) {
1851
- const f = p.target, k = f.getAttribute("data-handle");
1852
- if (!k) return;
1853
- p.preventDefault();
1854
- const x = f.ownerSVGElement || f;
1855
- x.setPointerCapture(p.pointerId), a.value = k, c.value = { x: p.clientX, y: p.clientY }, y.value = { ...t.state.crop };
1856
- const D = (L) => {
1857
- if (!a.value) return;
1858
- const W = n.canvasRect;
1859
- if (W.width === 0 || W.height === 0) return;
1860
- const P = (L.clientX - c.value.x) / W.width, O = (L.clientY - c.value.y) / W.height, _ = y.value, A = t.state.crop, R = A.aspectRatio;
1861
- switch (a.value) {
1936
+ }), l = H(null), c = H({ x: 0, y: 0 }), m = H({ x: 0, y: 0, width: 0, height: 0 }), d = H(!1);
1937
+ let x = null;
1938
+ function _(g) {
1939
+ const k = g.target, C = k.getAttribute("data-handle");
1940
+ if (!C) return;
1941
+ g.preventDefault();
1942
+ const P = k.ownerSVGElement || k;
1943
+ P.setPointerCapture(g.pointerId), l.value = C, c.value = { x: g.clientX, y: g.clientY }, m.value = { ...t.state.crop };
1944
+ const V = (K) => {
1945
+ if (!l.value) return;
1946
+ const L = n.canvasRect;
1947
+ if (L.width === 0 || L.height === 0) return;
1948
+ const E = (K.clientX - c.value.x) / L.width, O = (K.clientY - c.value.y) / L.height, M = m.value, F = t.state.crop, f = F.aspectRatio;
1949
+ switch (l.value) {
1862
1950
  case "move": {
1863
- const I = L.clientX - c.value.x, C = L.clientY - c.value.y, E = l(_.x - I / W.width, 0, 1 - A.width), F = l(_.y - C / W.height, 0, 1 - A.height), B = (_.x - E) * W.width, oe = (_.y - F) * W.height;
1864
- t.cropDragPan.value = { x: B, y: oe };
1951
+ const p = K.clientX - c.value.x, b = K.clientY - c.value.y, R = u(M.x - p / L.width, 0, 1 - F.width), T = u(M.y - b / L.height, 0, 1 - F.height), W = (M.x - R) * L.width, B = (M.y - T) * L.height;
1952
+ t.cropDragPan.value = { x: W, y: B };
1865
1953
  break;
1866
1954
  }
1867
1955
  case "nw": {
1868
- let I = l(_.x + P), C = l(_.y + O), E = _.x + _.width - I, F = _.y + _.height - C;
1869
- R && (F = E / R, C = _.y + _.height - F, C < 0 && (C = 0, F = _.y + _.height, E = F * R, I = _.x + _.width - E)), E > 0.02 && F > 0.02 && I >= 0 && C >= 0 && (A.x = I, A.y = C, A.width = E, A.height = F);
1956
+ let p = u(M.x + E), b = u(M.y + O), R = M.x + M.width - p, T = M.y + M.height - b;
1957
+ f && (T = R / f, b = M.y + M.height - T, b < 0 && (b = 0, T = M.y + M.height, R = T * f, p = M.x + M.width - R)), R > 0.02 && T > 0.02 && p >= 0 && b >= 0 && (F.x = p, F.y = b, F.width = R, F.height = T);
1870
1958
  break;
1871
1959
  }
1872
1960
  case "ne": {
1873
- let I = l(_.width + P, 0.02, 1 - _.x), C = _.y + O, E = _.y + _.height - C;
1874
- R && (E = I / R, C = _.y + _.height - E, C < 0 && (C = 0, E = _.y + _.height, I = E * R)), I > 0.02 && E > 0.02 && C >= 0 && _.x + I <= 1 && (A.y = C, A.width = I, A.height = E);
1961
+ let p = u(M.width + E, 0.02, 1 - M.x), b = M.y + O, R = M.y + M.height - b;
1962
+ f && (R = p / f, b = M.y + M.height - R, b < 0 && (b = 0, R = M.y + M.height, p = R * f)), p > 0.02 && R > 0.02 && b >= 0 && M.x + p <= 1 && (F.y = b, F.width = p, F.height = R);
1875
1963
  break;
1876
1964
  }
1877
1965
  case "sw": {
1878
- let I = l(_.x + P), C = _.x + _.width - I, E = l(_.height + O, 0.02, 1 - _.y);
1879
- R && (C = E * R, I = _.x + _.width - C, I < 0 && (I = 0, C = _.x + _.width, E = C / R)), C > 0.02 && E > 0.02 && I >= 0 && _.y + E <= 1 && (A.x = I, A.width = C, A.height = E);
1966
+ let p = u(M.x + E), b = M.x + M.width - p, R = u(M.height + O, 0.02, 1 - M.y);
1967
+ f && (b = R * f, p = M.x + M.width - b, p < 0 && (p = 0, b = M.x + M.width, R = b / f)), b > 0.02 && R > 0.02 && p >= 0 && M.y + R <= 1 && (F.x = p, F.width = b, F.height = R);
1880
1968
  break;
1881
1969
  }
1882
1970
  case "se": {
1883
- let I = l(_.width + P, 0.02, 1 - _.x), C = l(_.height + O, 0.02, 1 - _.y);
1884
- R && (C = I / R, _.y + C > 1 && (C = 1 - _.y, I = C * R)), I > 0.02 && C > 0.02 && _.x + I <= 1 && _.y + C <= 1 && (A.width = I, A.height = C);
1971
+ let p = u(M.width + E, 0.02, 1 - M.x), b = u(M.height + O, 0.02, 1 - M.y);
1972
+ f && (b = p / f, M.y + b > 1 && (b = 1 - M.y, p = b * f)), p > 0.02 && b > 0.02 && M.x + p <= 1 && M.y + b <= 1 && (F.width = p, F.height = b);
1885
1973
  break;
1886
1974
  }
1887
1975
  case "n": {
1888
- let I = l(_.y + O), C = _.y + _.height - I;
1889
- if (R) {
1890
- const E = C * R, F = E - _.width, B = l(_.x - F / 2, 0, 1 - E);
1891
- E > 0.02 && B >= 0 && B + E <= 1 && (A.x = B, A.width = E);
1976
+ let p = u(M.y + O), b = M.y + M.height - p;
1977
+ if (f) {
1978
+ const R = b * f, T = R - M.width, W = u(M.x - T / 2, 0, 1 - R);
1979
+ R > 0.02 && W >= 0 && W + R <= 1 && (F.x = W, F.width = R);
1892
1980
  }
1893
- C > 0.02 && I >= 0 && (A.y = I, A.height = C);
1981
+ b > 0.02 && p >= 0 && (F.y = p, F.height = b);
1894
1982
  break;
1895
1983
  }
1896
1984
  case "s": {
1897
- let I = l(_.height + O, 0.02, 1 - _.y);
1898
- if (R) {
1899
- const C = I * R, E = C - _.width, F = l(_.x - E / 2, 0, 1 - C);
1900
- C > 0.02 && F >= 0 && F + C <= 1 && (A.x = F, A.width = C);
1985
+ let p = u(M.height + O, 0.02, 1 - M.y);
1986
+ if (f) {
1987
+ const b = p * f, R = b - M.width, T = u(M.x - R / 2, 0, 1 - b);
1988
+ b > 0.02 && T >= 0 && T + b <= 1 && (F.x = T, F.width = b);
1901
1989
  }
1902
- I > 0.02 && _.y + I <= 1 && (A.height = I);
1990
+ p > 0.02 && M.y + p <= 1 && (F.height = p);
1903
1991
  break;
1904
1992
  }
1905
1993
  case "w": {
1906
- let I = l(_.x + P), C = _.x + _.width - I;
1907
- if (R) {
1908
- const E = C / R, F = E - _.height, B = l(_.y - F / 2, 0, 1 - E);
1909
- E > 0.02 && B >= 0 && B + E <= 1 && (A.y = B, A.height = E);
1994
+ let p = u(M.x + E), b = M.x + M.width - p;
1995
+ if (f) {
1996
+ const R = b / f, T = R - M.height, W = u(M.y - T / 2, 0, 1 - R);
1997
+ R > 0.02 && W >= 0 && W + R <= 1 && (F.y = W, F.height = R);
1910
1998
  }
1911
- C > 0.02 && I >= 0 && (A.x = I, A.width = C);
1999
+ b > 0.02 && p >= 0 && (F.x = p, F.width = b);
1912
2000
  break;
1913
2001
  }
1914
2002
  case "e": {
1915
- let I = l(_.width + P, 0.02, 1 - _.x);
1916
- if (R) {
1917
- const C = I / R, E = C - _.height, F = l(_.y - E / 2, 0, 1 - C);
1918
- C > 0.02 && F >= 0 && F + C <= 1 && (A.y = F, A.height = C);
2003
+ let p = u(M.width + E, 0.02, 1 - M.x);
2004
+ if (f) {
2005
+ const b = p / f, R = b - M.height, T = u(M.y - R / 2, 0, 1 - b);
2006
+ b > 0.02 && T >= 0 && T + b <= 1 && (F.y = T, F.height = b);
1919
2007
  }
1920
- I > 0.02 && _.x + I <= 1 && (A.width = I);
2008
+ p > 0.02 && M.x + p <= 1 && (F.width = p);
1921
2009
  break;
1922
2010
  }
1923
2011
  }
1924
2012
  t.requestRender();
1925
- }, T = () => {
1926
- window.removeEventListener("pointermove", D), window.removeEventListener("pointerup", K), w = null;
1927
- }, K = (L) => {
1928
- if (a.value === "move") {
1929
- const W = L.clientX - c.value.x, P = L.clientY - c.value.y, O = n.canvasRect, _ = y.value, A = t.state.crop;
1930
- A.x = l(_.x - W / O.width, 0, 1 - A.width), A.y = l(_.y - P / O.height, 0, 1 - A.height), t.cropDragPan.value = { x: 0, y: 0 };
2013
+ }, A = () => {
2014
+ window.removeEventListener("pointermove", V), window.removeEventListener("pointerup", D), x = null;
2015
+ }, D = (K) => {
2016
+ if (l.value === "move") {
2017
+ const L = K.clientX - c.value.x, E = K.clientY - c.value.y, O = n.canvasRect, M = m.value, F = t.state.crop;
2018
+ F.x = u(M.x - L / O.width, 0, 1 - F.width), F.y = u(M.y - E / O.height, 0, 1 - F.height), t.cropDragPan.value = { x: 0, y: 0 };
1931
2019
  }
1932
- a.value && (a.value !== "move" && (v.value = !0), t.updateState(() => {
1933
- })), a.value = null;
2020
+ l.value && (l.value !== "move" && (d.value = !0), t.updateState(() => {
2021
+ })), l.value = null;
1934
2022
  try {
1935
- x.releasePointerCapture(L.pointerId);
2023
+ P.releasePointerCapture(K.pointerId);
1936
2024
  } catch {
1937
2025
  }
1938
- T();
2026
+ A();
1939
2027
  };
1940
- window.addEventListener("pointermove", D), window.addEventListener("pointerup", K), w = T;
2028
+ window.addEventListener("pointermove", V), window.addEventListener("pointerup", D), x = A;
1941
2029
  }
1942
- re(() => {
1943
- w == null || w(), t.cropDragPan.value = { x: 0, y: 0 };
2030
+ he(() => {
2031
+ x == null || x(), t.cropDragPan.value = { x: 0, y: 0 };
1944
2032
  });
1945
- const $ = V(() => {
1946
- const p = t.state.crop;
1947
- return v.value && !a.value && r.value.width > 60 && r.value.height > 60 && (p.x > 1e-3 || p.y > 1e-3 || p.width < 0.999 || p.height < 0.999);
2033
+ const $ = j(() => {
2034
+ const g = t.state.crop;
2035
+ return d.value && !l.value && s.value.width > 60 && s.value.height > 60 && (g.x > 1e-3 || g.y > 1e-3 || g.width < 0.999 || g.height < 0.999);
1948
2036
  });
1949
- ne(() => t.state.crop.aspectRatio, () => {
1950
- v.value = !1;
2037
+ re(() => t.state.crop.aspectRatio, () => {
2038
+ d.value = !1;
1951
2039
  });
1952
- function m() {
1953
- const p = t.plugins.value, f = p.findIndex((k) => k.id === t.activePluginId.value);
1954
- f >= 0 && f < p.length - 1 && t.setActivePlugin(p[f + 1].id);
2040
+ function w() {
2041
+ const g = t.plugins.value, k = g.findIndex((C) => C.id === t.activePluginId.value);
2042
+ k >= 0 && k < g.length - 1 && t.setActivePlugin(g[k + 1].id);
1955
2043
  }
1956
- function l(p, f = 0, k = 1) {
1957
- return Math.max(f, Math.min(k, p));
2044
+ function u(g, k = 0, C = 1) {
2045
+ return Math.max(k, Math.min(C, g));
1958
2046
  }
1959
- return (p, f) => (M(), z("svg", {
1960
- class: U(["vie-crop-overlay", { "vie-crop-overlay--dragging": a.value }]),
2047
+ return (g, k) => (S(), z("svg", {
2048
+ class: N(["vie-crop-overlay", { "vie-crop-overlay--dragging": l.value }]),
1961
2049
  role: "application",
1962
2050
  "aria-label": "Crop region",
1963
- viewBox: `0 0 ${d.value} ${u.value}`,
1964
- width: d.value,
1965
- height: u.value,
2051
+ viewBox: `0 0 ${h.value} ${r.value}`,
2052
+ width: h.value,
2053
+ height: r.value,
1966
2054
  style: { "touch-action": "none" },
1967
- onPointerdown: b
2055
+ onPointerdown: _
1968
2056
  }, [
1969
- g("defs", null, [
1970
- g("mask", { id: e }, [
1971
- g("rect", {
2057
+ y("defs", null, [
2058
+ y("mask", { id: e }, [
2059
+ y("rect", {
1972
2060
  x: "0",
1973
2061
  y: "0",
1974
- width: d.value,
1975
- height: u.value,
2062
+ width: h.value,
2063
+ height: r.value,
1976
2064
  fill: "white"
1977
- }, null, 8, Yt),
1978
- g("rect", {
1979
- x: r.value.x,
1980
- y: r.value.y,
1981
- width: Math.max(0, r.value.width),
1982
- height: Math.max(0, r.value.height),
2065
+ }, null, 8, pn),
2066
+ y("rect", {
2067
+ x: s.value.x,
2068
+ y: s.value.y,
2069
+ width: Math.max(0, s.value.width),
2070
+ height: Math.max(0, s.value.height),
1983
2071
  fill: "black"
1984
- }, null, 8, Ut)
2072
+ }, null, 8, mn)
1985
2073
  ])
1986
2074
  ]),
1987
- g("rect", {
2075
+ y("rect", {
1988
2076
  x: "0",
1989
2077
  y: "0",
1990
- width: d.value,
1991
- height: u.value,
2078
+ width: h.value,
2079
+ height: r.value,
1992
2080
  class: "vie-crop-mask",
1993
2081
  mask: `url(#${e})`
1994
- }, null, 8, Nt),
1995
- g("rect", {
1996
- x: r.value.x,
1997
- y: r.value.y,
1998
- width: Math.max(0, r.value.width),
1999
- height: Math.max(0, r.value.height),
2082
+ }, null, 8, gn),
2083
+ y("rect", {
2084
+ x: s.value.x,
2085
+ y: s.value.y,
2086
+ width: Math.max(0, s.value.width),
2087
+ height: Math.max(0, s.value.height),
2000
2088
  class: "vie-crop-border"
2001
- }, null, 8, Zt),
2002
- r.value.width > 10 && r.value.height > 10 ? (M(), z("g", Jt, [
2003
- (M(), z(X, null, N(2, (k) => g("line", {
2004
- key: "h" + k,
2005
- x1: r.value.x,
2006
- y1: r.value.y + r.value.height * (k / 3),
2007
- x2: r.value.x + r.value.width,
2008
- y2: r.value.y + r.value.height * (k / 3)
2009
- }, null, 8, Gt)), 64)),
2010
- (M(), z(X, null, N(2, (k) => g("line", {
2011
- key: "v" + k,
2012
- x1: r.value.x + r.value.width * (k / 3),
2013
- y1: r.value.y,
2014
- x2: r.value.x + r.value.width * (k / 3),
2015
- y2: r.value.y + r.value.height
2016
- }, null, 8, Qt)), 64))
2017
- ])) : Z("", !0),
2018
- g("rect", {
2019
- x: r.value.x + ae,
2020
- y: r.value.y + ae,
2021
- width: Math.max(0, r.value.width - ae * 2),
2022
- height: Math.max(0, r.value.height - ae * 2),
2089
+ }, null, 8, yn),
2090
+ s.value.width > 10 && s.value.height > 10 ? (S(), z("g", wn, [
2091
+ (S(), z(Y, null, Z(2, (C) => y("line", {
2092
+ key: "h" + C,
2093
+ x1: s.value.x,
2094
+ y1: s.value.y + s.value.height * (C / 3),
2095
+ x2: s.value.x + s.value.width,
2096
+ y2: s.value.y + s.value.height * (C / 3)
2097
+ }, null, 8, kn)), 64)),
2098
+ (S(), z(Y, null, Z(2, (C) => y("line", {
2099
+ key: "v" + C,
2100
+ x1: s.value.x + s.value.width * (C / 3),
2101
+ y1: s.value.y,
2102
+ x2: s.value.x + s.value.width * (C / 3),
2103
+ y2: s.value.y + s.value.height
2104
+ }, null, 8, bn)), 64))
2105
+ ])) : G("", !0),
2106
+ y("rect", {
2107
+ x: s.value.x + de,
2108
+ y: s.value.y + de,
2109
+ width: Math.max(0, s.value.width - de * 2),
2110
+ height: Math.max(0, s.value.height - de * 2),
2023
2111
  class: "vie-crop-move",
2024
2112
  "data-handle": "move"
2025
- }, null, 8, en),
2026
- (M(!0), z(X, null, N(i.value, (k) => (M(), z("rect", {
2027
- key: k.id,
2028
- x: k.x,
2029
- y: k.y,
2030
- width: ae,
2031
- height: ae,
2032
- class: U(["vie-crop-handle", `vie-crop-handle--${k.id}`]),
2033
- "data-handle": k.id,
2113
+ }, null, 8, xn),
2114
+ (S(!0), z(Y, null, Z(i.value, (C) => (S(), z("rect", {
2115
+ key: C.id,
2116
+ x: C.x,
2117
+ y: C.y,
2118
+ width: de,
2119
+ height: de,
2120
+ class: N(["vie-crop-handle", `vie-crop-handle--${C.id}`]),
2121
+ "data-handle": C.id,
2034
2122
  rx: "2"
2035
- }, null, 10, tn))), 128)),
2036
- (M(!0), z(X, null, N(h.value, (k) => (M(), z("rect", {
2037
- key: k.id,
2038
- x: k.x,
2039
- y: k.y,
2040
- width: k.w,
2041
- height: k.h,
2042
- class: U(["vie-crop-handle", `vie-crop-handle--${k.id}`]),
2043
- "data-handle": k.id,
2123
+ }, null, 10, _n))), 128)),
2124
+ (S(!0), z(Y, null, Z(v.value, (C) => (S(), z("rect", {
2125
+ key: C.id,
2126
+ x: C.x,
2127
+ y: C.y,
2128
+ width: C.w,
2129
+ height: C.h,
2130
+ class: N(["vie-crop-handle", `vie-crop-handle--${C.id}`]),
2131
+ "data-handle": C.id,
2044
2132
  rx: "2"
2045
- }, null, 10, nn))), 128)),
2046
- $.value ? (M(), z("foreignObject", {
2133
+ }, null, 10, Cn))), 128)),
2134
+ $.value ? (S(), z("foreignObject", {
2047
2135
  key: 1,
2048
- x: r.value.x + (r.value.width - 100) / 2,
2049
- y: r.value.y + r.value.height - 14,
2136
+ x: s.value.x + (s.value.width - 100) / 2,
2137
+ y: s.value.y + s.value.height - 14,
2050
2138
  width: "100",
2051
2139
  height: "36",
2052
2140
  style: { "pointer-events": "none", overflow: "visible" }
2053
2141
  }, [
2054
- g("div", an, [
2055
- g("button", {
2142
+ y("div", Sn, [
2143
+ y("button", {
2056
2144
  class: "vie-crop-confirm-pill",
2057
- onPointerdown: f[0] || (f[0] = ce(() => {
2145
+ onPointerdown: k[0] || (k[0] = ve(() => {
2058
2146
  }, ["stop"])),
2059
- onClick: ce(m, ["stop"])
2147
+ onClick: ve(w, ["stop"])
2060
2148
  }, [
2061
- f[1] || (f[1] = g("svg", {
2149
+ k[1] || (k[1] = y("svg", {
2062
2150
  viewBox: "0 0 24 24",
2063
2151
  width: "14",
2064
2152
  height: "14",
@@ -2068,30 +2156,30 @@ const Ht = { class: "vie-crop-controls" }, Vt = { class: "vie-crop-controls__sec
2068
2156
  "stroke-linecap": "round",
2069
2157
  "stroke-linejoin": "round"
2070
2158
  }, [
2071
- g("polyline", { points: "20 6 9 17 4 12" })
2159
+ y("polyline", { points: "20 6 9 17 4 12" })
2072
2160
  ], -1)),
2073
- g("span", null, q(S(o)("cropApply")), 1)
2161
+ y("span", null, q(I(a)("cropApply")), 1)
2074
2162
  ], 32)
2075
2163
  ])
2076
- ], 8, on)) : Z("", !0)
2077
- ], 42, Xt));
2164
+ ], 8, Mn)) : G("", !0)
2165
+ ], 42, fn));
2078
2166
  }
2079
- }), cn = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2167
+ }), In = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2080
2168
  <path d="M6 2v4" />
2081
2169
  <path d="M6 6h12a2 2 0 0 1 2 2v8" />
2082
2170
  <path d="M18 22v-4" />
2083
2171
  <path d="M18 18H6a2 2 0 0 1-2-2V8" />
2084
2172
  </svg>`;
2085
- function un() {
2173
+ function Pn() {
2086
2174
  return {
2087
2175
  id: "crop",
2088
- icon: cn,
2176
+ icon: In,
2089
2177
  labelKey: "crop",
2090
- controls: qt,
2091
- overlay: ln
2178
+ controls: vn,
2179
+ overlay: zn
2092
2180
  };
2093
2181
  }
2094
- const dn = [
2182
+ const Tn = [
2095
2183
  { key: "brightness", labelKey: "brightness", min: -0.25, max: 0.25, base: 0, step: 0.01 },
2096
2184
  { key: "contrast", labelKey: "contrast", min: -0.25, max: 0.25, base: 0, step: 0.01 },
2097
2185
  { key: "saturation", labelKey: "saturation", min: -0.25, max: 0.25, base: 0, step: 0.01 },
@@ -2100,30 +2188,30 @@ const dn = [
2100
2188
  { key: "gamma", labelKey: "gamma", min: 0.2, max: 5, base: 1, step: 0.05 },
2101
2189
  { key: "clarity", labelKey: "clarity", min: -0.25, max: 0.25, base: 0, step: 0.01 },
2102
2190
  { key: "vignette", labelKey: "vignette", min: -1, max: 1, base: 0, step: 0.05 }
2103
- ], hn = { class: "vie-finetune-controls" }, vn = /* @__PURE__ */ Y({
2191
+ ], En = { class: "vie-finetune-controls" }, Wn = /* @__PURE__ */ J({
2104
2192
  __name: "FinetuneControls",
2105
- setup(s) {
2106
- const e = G(), n = Q(ee, (o) => o);
2107
- function t(o, d) {
2108
- e.updateState((u) => {
2109
- u.finetune[o] = d;
2193
+ setup(o) {
2194
+ const e = ee(), n = ie(oe, (a) => a);
2195
+ function t(a, h) {
2196
+ e.updateState((r) => {
2197
+ r.finetune[a] = h;
2110
2198
  });
2111
2199
  }
2112
- return (o, d) => (M(), z("div", hn, [
2113
- (M(!0), z(X, null, N(S(dn), (u) => (M(), le(ve, {
2114
- key: u.key,
2115
- modelValue: S(e).state.finetune[u.key],
2116
- min: u.min,
2117
- max: u.max,
2118
- step: u.step,
2119
- base: u.base,
2120
- label: S(n)(u.labelKey),
2121
- format: u.key === "gamma" ? "number" : "percent",
2122
- "onUpdate:modelValue": (r) => t(u.key, r)
2200
+ return (a, h) => (S(), z("div", En, [
2201
+ (S(!0), z(Y, null, Z(I(Tn), (r) => (S(), pe(fe, {
2202
+ key: r.key,
2203
+ modelValue: I(e).state.finetune[r.key],
2204
+ min: r.min,
2205
+ max: r.max,
2206
+ step: r.step,
2207
+ base: r.base,
2208
+ label: I(n)(r.labelKey),
2209
+ format: r.key === "gamma" ? "number" : "percent",
2210
+ "onUpdate:modelValue": (s) => t(r.key, s)
2123
2211
  }, null, 8, ["modelValue", "min", "max", "step", "base", "label", "format", "onUpdate:modelValue"]))), 128))
2124
2212
  ]));
2125
2213
  }
2126
- }), pn = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2214
+ }), An = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2127
2215
  <line x1="4" y1="21" x2="4" y2="14" />
2128
2216
  <line x1="4" y1="10" x2="4" y2="3" />
2129
2217
  <line x1="12" y1="21" x2="12" y2="12" />
@@ -2134,15 +2222,15 @@ const dn = [
2134
2222
  <line x1="9" y1="8" x2="15" y2="8" />
2135
2223
  <line x1="17" y1="16" x2="23" y2="16" />
2136
2224
  </svg>`;
2137
- function fn() {
2225
+ function Fn() {
2138
2226
  return {
2139
2227
  id: "finetune",
2140
- icon: pn,
2228
+ icon: An,
2141
2229
  labelKey: "finetune",
2142
- controls: vn
2230
+ controls: Wn
2143
2231
  };
2144
2232
  }
2145
- const pe = [
2233
+ const be = [
2146
2234
  {
2147
2235
  id: "chrome",
2148
2236
  labelKey: "chrome",
@@ -2481,122 +2569,122 @@ const pe = [
2481
2569
  0
2482
2570
  ]
2483
2571
  }
2484
- ], mn = { class: "vie-filter-controls" }, gn = { class: "vie-filter-strip" }, yn = { class: "vie-filter-thumb__label" }, wn = ["onClick"], kn = { class: "vie-filter-thumb__label" }, bn = /* @__PURE__ */ Y({
2572
+ ], Dn = { class: "vie-filter-controls" }, Ln = { class: "vie-filter-strip" }, Kn = { class: "vie-filter-thumb__label" }, Hn = ["onClick"], Vn = { class: "vie-filter-thumb__label" }, Bn = /* @__PURE__ */ J({
2485
2573
  __name: "FilterControls",
2486
- setup(s) {
2487
- const e = G(), n = Q(ee, (w) => w), t = H(null), o = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Set();
2488
- let u = null;
2489
- function r(w, b) {
2490
- b && (o.set(w, b), u == null || u.observe(b));
2491
- }
2492
- function i(w) {
2493
- e.updateState((b) => {
2494
- w ? (b.filter.id = w.id, b.filter.matrix = [...w.matrix]) : (b.filter.id = null, b.filter.matrix = void 0);
2574
+ setup(o) {
2575
+ const e = ee(), n = ie(oe, (x) => x), t = H(null), a = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Set();
2576
+ let r = null;
2577
+ function s(x, _) {
2578
+ _ && (a.set(x, _), r == null || r.observe(_));
2579
+ }
2580
+ function i(x) {
2581
+ e.updateState((_) => {
2582
+ x ? (_.filter.id = x.id, _.filter.matrix = [...x.matrix]) : (_.filter.id = null, _.filter.matrix = void 0);
2495
2583
  });
2496
2584
  }
2497
- function h(w) {
2498
- e.updateState((b) => {
2499
- b.filter.intensity = w;
2585
+ function v(x) {
2586
+ e.updateState((_) => {
2587
+ _.filter.intensity = x;
2500
2588
  });
2501
2589
  }
2502
- function a(w, b) {
2590
+ function l(x, _) {
2503
2591
  const $ = e.sourceImage.value;
2504
2592
  if (!$) return;
2505
- const m = 96, l = w.getContext("2d");
2506
- l.drawImage($, 0, 0, m, m);
2507
- const p = l.getImageData(0, 0, m, m);
2508
- Ce(p, b.matrix), l.putImageData(p, 0, 0), d.add(b.id);
2593
+ const w = 96, u = x.getContext("2d");
2594
+ u.drawImage($, 0, 0, w, w);
2595
+ const g = u.getImageData(0, 0, w, w);
2596
+ Ae(g, _.matrix), u.putImageData(g, 0, 0), h.add(_.id);
2509
2597
  }
2510
2598
  function c() {
2511
- const w = e.sourceImage.value;
2512
- if (!w || !t.value) return;
2513
- t.value.getContext("2d").drawImage(w, 0, 0, 96, 96);
2514
- }
2515
- function y() {
2516
- u = new IntersectionObserver((w) => {
2517
- for (const b of w) {
2518
- if (!b.isIntersecting) continue;
2519
- const $ = b.target, m = pe.find((l) => o.get(l.id) === $);
2520
- m && !d.has(m.id) && a($, m);
2599
+ const x = e.sourceImage.value;
2600
+ if (!x || !t.value) return;
2601
+ t.value.getContext("2d").drawImage(x, 0, 0, 96, 96);
2602
+ }
2603
+ function m() {
2604
+ r = new IntersectionObserver((x) => {
2605
+ for (const _ of x) {
2606
+ if (!_.isIntersecting) continue;
2607
+ const $ = _.target, w = be.find((u) => a.get(u.id) === $);
2608
+ w && !h.has(w.id) && l($, w);
2521
2609
  }
2522
2610
  }, { threshold: 0.1 });
2523
- for (const w of o.values())
2524
- u.observe(w);
2525
- }
2526
- function v() {
2527
- d.clear(), c();
2528
- for (const w of pe) {
2529
- const b = o.get(w.id);
2530
- b && (u == null || u.unobserve(b));
2611
+ for (const x of a.values())
2612
+ r.observe(x);
2613
+ }
2614
+ function d() {
2615
+ h.clear(), c();
2616
+ for (const x of be) {
2617
+ const _ = a.get(x.id);
2618
+ _ && (r == null || r.unobserve(_));
2531
2619
  }
2532
- for (const w of o.values())
2533
- u == null || u.observe(w);
2620
+ for (const x of a.values())
2621
+ r == null || r.observe(x);
2534
2622
  }
2535
- return ne(() => e.sourceImage.value, () => {
2536
- setTimeout(v, 50);
2537
- }), ue(() => {
2538
- y(), setTimeout(() => {
2623
+ return re(() => e.sourceImage.value, () => {
2624
+ setTimeout(d, 50);
2625
+ }), ge(() => {
2626
+ m(), setTimeout(() => {
2539
2627
  c();
2540
2628
  }, 50);
2541
- }), Ze(() => {
2542
- u == null || u.disconnect(), u = null;
2543
- }), (w, b) => (M(), z("div", mn, [
2544
- g("div", gn, [
2545
- g("button", {
2546
- class: U(["vie-filter-thumb", { "vie-filter-thumb--active": !S(e).state.filter.id }]),
2547
- onClick: b[0] || (b[0] = ($) => i(null))
2629
+ }), pt(() => {
2630
+ r == null || r.disconnect(), r = null;
2631
+ }), (x, _) => (S(), z("div", Dn, [
2632
+ y("div", Ln, [
2633
+ y("button", {
2634
+ class: N(["vie-filter-thumb", { "vie-filter-thumb--active": !I(e).state.filter.id }]),
2635
+ onClick: _[0] || (_[0] = ($) => i(null))
2548
2636
  }, [
2549
- g("canvas", {
2637
+ y("canvas", {
2550
2638
  ref_key: "originalThumbRef",
2551
2639
  ref: t,
2552
2640
  width: "96",
2553
2641
  height: "96",
2554
2642
  class: "vie-filter-thumb__canvas"
2555
2643
  }, null, 512),
2556
- g("span", yn, q(S(n)("original")), 1)
2644
+ y("span", Kn, q(I(n)("original")), 1)
2557
2645
  ], 2),
2558
- (M(!0), z(X, null, N(S(pe), ($) => (M(), z("button", {
2646
+ (S(!0), z(Y, null, Z(I(be), ($) => (S(), z("button", {
2559
2647
  key: $.id,
2560
- class: U(["vie-filter-thumb", { "vie-filter-thumb--active": S(e).state.filter.id === $.id }]),
2561
- onClick: (m) => i($)
2648
+ class: N(["vie-filter-thumb", { "vie-filter-thumb--active": I(e).state.filter.id === $.id }]),
2649
+ onClick: (w) => i($)
2562
2650
  }, [
2563
- g("canvas", {
2651
+ y("canvas", {
2564
2652
  ref_for: !0,
2565
- ref: (m) => r($.id, m),
2653
+ ref: (w) => s($.id, w),
2566
2654
  width: "96",
2567
2655
  height: "96",
2568
2656
  class: "vie-filter-thumb__canvas"
2569
2657
  }, null, 512),
2570
- g("span", kn, q(S(n)($.labelKey) || $.labelKey), 1)
2571
- ], 10, wn))), 128))
2658
+ y("span", Vn, q(I(n)($.labelKey) || $.labelKey), 1)
2659
+ ], 10, Hn))), 128))
2572
2660
  ]),
2573
- S(e).state.filter.id ? (M(), le(ve, {
2661
+ I(e).state.filter.id ? (S(), pe(fe, {
2574
2662
  key: 0,
2575
- modelValue: S(e).state.filter.intensity,
2663
+ modelValue: I(e).state.filter.intensity,
2576
2664
  min: 0,
2577
2665
  max: 1,
2578
2666
  step: 0.01,
2579
2667
  base: 1,
2580
- label: S(n)("intensity"),
2668
+ label: I(n)("intensity"),
2581
2669
  format: "percent",
2582
- "onUpdate:modelValue": h
2583
- }, null, 8, ["modelValue", "label"])) : Z("", !0)
2670
+ "onUpdate:modelValue": v
2671
+ }, null, 8, ["modelValue", "label"])) : G("", !0)
2584
2672
  ]));
2585
2673
  }
2586
- }), _n = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2674
+ }), jn = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2587
2675
  <path d="M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z" />
2588
2676
  <path d="M12 20a8 8 0 1 0 0-16" fill="currentColor" opacity="0.3" />
2589
2677
  <path d="M12 4v16" />
2590
2678
  </svg>`;
2591
- function xn() {
2679
+ function On() {
2592
2680
  return {
2593
2681
  id: "filter",
2594
- icon: _n,
2682
+ icon: jn,
2595
2683
  labelKey: "filter",
2596
- controls: bn
2684
+ controls: Bn
2597
2685
  };
2598
2686
  }
2599
- const fe = [
2687
+ const xe = [
2600
2688
  {
2601
2689
  id: "emoji",
2602
2690
  labelKey: "emoji",
@@ -2649,25 +2737,25 @@ const fe = [
2649
2737
  "♦️"
2650
2738
  ]
2651
2739
  }
2652
- ], Pe = /* @__PURE__ */ new WeakMap();
2653
- function Oe(s) {
2654
- let e = Pe.get(s);
2655
- return e || (e = H(null), Pe.set(s, e)), e;
2740
+ ], Be = /* @__PURE__ */ new WeakMap();
2741
+ function ot(o) {
2742
+ let e = Be.get(o);
2743
+ return e || (e = H(null), Be.set(o, e)), e;
2656
2744
  }
2657
- const Cn = { class: "vie-sticker-controls" }, Mn = { class: "vie-sticker-tabs" }, Sn = ["onClick"], $n = { class: "vie-sticker-grid" }, Rn = ["onClick"], zn = /* @__PURE__ */ Y({
2745
+ const Xn = { class: "vie-sticker-controls" }, qn = { class: "vie-sticker-tabs" }, Yn = ["onClick"], Un = { class: "vie-sticker-grid" }, Nn = ["onClick"], Zn = /* @__PURE__ */ J({
2658
2746
  __name: "StickerControls",
2659
- setup(s) {
2747
+ setup(o) {
2660
2748
  var i;
2661
- const e = G(), n = Q(ee, (h) => h), t = Oe(e.state), o = H(((i = fe[0]) == null ? void 0 : i.id) || "emoji"), d = V(() => {
2662
- const h = fe.find((a) => a.id === o.value);
2663
- return (h == null ? void 0 : h.stickers) || [];
2749
+ const e = ee(), n = ie(oe, (v) => v), t = ot(e.state), a = H(((i = xe[0]) == null ? void 0 : i.id) || "emoji"), h = j(() => {
2750
+ const v = xe.find((l) => l.id === a.value);
2751
+ return (v == null ? void 0 : v.stickers) || [];
2664
2752
  });
2665
- function u(h) {
2666
- const a = `sticker-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`, c = e.state.stickers.length % 5 * 0.03;
2667
- e.updateState((y) => {
2668
- y.stickers.push({
2669
- id: a,
2670
- src: h,
2753
+ function r(v) {
2754
+ const l = `sticker-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`, c = e.state.stickers.length % 5 * 0.03;
2755
+ e.updateState((m) => {
2756
+ m.stickers.push({
2757
+ id: l,
2758
+ src: v,
2671
2759
  x: 0.35 + c,
2672
2760
  y: 0.35 + c,
2673
2761
  width: 0.15,
@@ -2677,230 +2765,230 @@ const Cn = { class: "vie-sticker-controls" }, Mn = { class: "vie-sticker-tabs" }
2677
2765
  flipY: !1,
2678
2766
  opacity: 1
2679
2767
  });
2680
- }), t.value = a;
2768
+ }), t.value = l;
2681
2769
  }
2682
- function r() {
2770
+ function s() {
2683
2771
  if (!t.value) return;
2684
- const h = t.value;
2685
- e.updateState((a) => {
2686
- const c = a.stickers.findIndex((y) => y.id === h);
2687
- c >= 0 && a.stickers.splice(c, 1);
2772
+ const v = t.value;
2773
+ e.updateState((l) => {
2774
+ const c = l.stickers.findIndex((m) => m.id === v);
2775
+ c >= 0 && l.stickers.splice(c, 1);
2688
2776
  }), t.value = null;
2689
2777
  }
2690
- return (h, a) => (M(), z("div", Cn, [
2691
- g("div", Mn, [
2692
- (M(!0), z(X, null, N(S(fe), (c) => (M(), z("button", {
2778
+ return (v, l) => (S(), z("div", Xn, [
2779
+ y("div", qn, [
2780
+ (S(!0), z(Y, null, Z(I(xe), (c) => (S(), z("button", {
2693
2781
  key: c.id,
2694
- class: U(["vie-sticker-tab", { "vie-sticker-tab--active": o.value === c.id }]),
2695
- onClick: (y) => o.value = c.id
2696
- }, q(S(n)(c.labelKey) || c.labelKey), 11, Sn))), 128)),
2697
- S(t) ? (M(), z("button", {
2782
+ class: N(["vie-sticker-tab", { "vie-sticker-tab--active": a.value === c.id }]),
2783
+ onClick: (m) => a.value = c.id
2784
+ }, q(I(n)(c.labelKey) || c.labelKey), 11, Yn))), 128)),
2785
+ I(t) ? (S(), z("button", {
2698
2786
  key: 0,
2699
2787
  class: "vie-sticker-tab vie-sticker-tab--delete",
2700
- onClick: r
2701
- }, q(S(n)("delete") || "Delete"), 1)) : Z("", !0)
2788
+ onClick: s
2789
+ }, q(I(n)("delete") || "Delete"), 1)) : G("", !0)
2702
2790
  ]),
2703
- g("div", $n, [
2704
- (M(!0), z(X, null, N(d.value, (c) => (M(), z("button", {
2791
+ y("div", Un, [
2792
+ (S(!0), z(Y, null, Z(h.value, (c) => (S(), z("button", {
2705
2793
  key: c,
2706
2794
  class: "vie-sticker-item",
2707
- onClick: (y) => u(c)
2708
- }, q(c), 9, Rn))), 128))
2795
+ onClick: (m) => r(c)
2796
+ }, q(c), 9, Nn))), 128))
2709
2797
  ])
2710
2798
  ]));
2711
2799
  }
2712
- }), In = ["viewBox", "width", "height"], Pn = ["x", "y", "width", "height", "data-sticker-id"], Tn = ["x", "y", "width", "height"], En = ["x", "y", "data-handle"], Wn = ["x1", "y1", "x2", "y2"], Kn = ["cx", "cy"], me = 10, Te = 20, Ee = 6, Dn = /* @__PURE__ */ Y({
2800
+ }), Jn = ["viewBox", "width", "height"], Gn = ["x", "y", "width", "height", "data-sticker-id"], Qn = ["x", "y", "width", "height"], ei = ["x", "y", "data-handle"], ti = ["x1", "y1", "x2", "y2"], ni = ["cx", "cy"], _e = 10, je = 20, Oe = 6, ii = /* @__PURE__ */ J({
2713
2801
  __name: "StickerOverlay",
2714
2802
  props: {
2715
2803
  canvasRect: {},
2716
2804
  wrapperSize: {}
2717
2805
  },
2718
- setup(s) {
2719
- const e = s, n = G(), t = H(null), o = Oe(n.state);
2720
- re(() => {
2806
+ setup(o) {
2807
+ const e = o, n = ee(), t = H(null), a = ot(n.state);
2808
+ he(() => {
2721
2809
  i.value && (n.updateState(() => {
2722
- }), i.value = null, h.value = null), window.removeEventListener("pointermove", w), window.removeEventListener("pointerup", b);
2810
+ }), i.value = null, v.value = null), window.removeEventListener("pointermove", x), window.removeEventListener("pointerup", _);
2723
2811
  });
2724
- const d = V(() => {
2725
- const l = e.canvasRect;
2726
- return n.state.stickers.map((p) => ({
2727
- id: p.id,
2728
- x: l.x + p.x * l.width,
2729
- y: l.y + p.y * l.height,
2730
- w: p.width * l.width,
2731
- h: p.height * l.height
2812
+ const h = j(() => {
2813
+ const u = e.canvasRect;
2814
+ return n.state.stickers.map((g) => ({
2815
+ id: g.id,
2816
+ x: u.x + g.x * u.width,
2817
+ y: u.y + g.y * u.height,
2818
+ w: g.width * u.width,
2819
+ h: g.height * u.height
2732
2820
  }));
2733
- }), u = V(() => o.value && d.value.find((l) => l.id === o.value) || null), r = V(() => {
2734
- if (!u.value) return [];
2735
- const l = u.value, f = me / 2;
2821
+ }), r = j(() => a.value && h.value.find((u) => u.id === a.value) || null), s = j(() => {
2822
+ if (!r.value) return [];
2823
+ const u = r.value, k = _e / 2;
2736
2824
  return [
2737
- { id: "nw", x: l.x - f, y: l.y - f },
2738
- { id: "ne", x: l.x + l.w - f, y: l.y - f },
2739
- { id: "sw", x: l.x - f, y: l.y + l.h - f },
2740
- { id: "se", x: l.x + l.w - f, y: l.y + l.h - f }
2825
+ { id: "nw", x: u.x - k, y: u.y - k },
2826
+ { id: "ne", x: u.x + u.w - k, y: u.y - k },
2827
+ { id: "sw", x: u.x - k, y: u.y + u.h - k },
2828
+ { id: "se", x: u.x + u.w - k, y: u.y + u.h - k }
2741
2829
  ];
2742
- }), i = H(null), h = H(null), a = H({ x: 0, y: 0 }), c = H({ x: 0, y: 0, width: 0, height: 0, rotation: 0 });
2743
- function y(l) {
2744
- var x;
2745
- const p = l.target, f = p.getAttribute("data-handle");
2746
- if (f === "rotate" && o.value) {
2747
- l.preventDefault(), v(l, "rotate", f);
2830
+ }), i = H(null), v = H(null), l = H({ x: 0, y: 0 }), c = H({ x: 0, y: 0, width: 0, height: 0, rotation: 0 });
2831
+ function m(u) {
2832
+ var P;
2833
+ const g = u.target, k = g.getAttribute("data-handle");
2834
+ if (k === "rotate" && a.value) {
2835
+ u.preventDefault(), d(u, "rotate", k);
2748
2836
  return;
2749
2837
  }
2750
- if (f && ["nw", "ne", "sw", "se"].includes(f) && o.value) {
2751
- l.preventDefault(), v(l, "resize", f);
2838
+ if (k && ["nw", "ne", "sw", "se"].includes(k) && a.value) {
2839
+ u.preventDefault(), d(u, "resize", k);
2752
2840
  return;
2753
2841
  }
2754
- const k = p.getAttribute("data-sticker-id");
2755
- if (k) {
2756
- l.preventDefault(), o.value = k, v(l, "move", null), (x = t.value) == null || x.focus();
2842
+ const C = g.getAttribute("data-sticker-id");
2843
+ if (C) {
2844
+ u.preventDefault(), a.value = C, d(u, "move", null), (P = t.value) == null || P.focus();
2757
2845
  return;
2758
2846
  }
2759
- o.value = null;
2760
- }
2761
- function v(l, p, f) {
2762
- i.value = p, h.value = f, a.value = { x: l.clientX, y: l.clientY };
2763
- const k = n.state.stickers.find((x) => x.id === o.value);
2764
- k && (c.value = {
2765
- x: k.x,
2766
- y: k.y,
2767
- width: k.width,
2768
- height: k.height,
2769
- rotation: k.rotation
2770
- }), window.addEventListener("pointermove", w), window.addEventListener("pointerup", b);
2771
- }
2772
- function w(l) {
2773
- if (!i.value || !o.value) return;
2774
- const p = e.canvasRect;
2775
- if (p.width === 0 || p.height === 0) return;
2776
- const f = (l.clientX - a.value.x) / p.width, k = (l.clientY - a.value.y) / p.height, x = c.value, D = n.state.stickers.find((T) => T.id === o.value);
2777
- if (D) {
2847
+ a.value = null;
2848
+ }
2849
+ function d(u, g, k) {
2850
+ i.value = g, v.value = k, l.value = { x: u.clientX, y: u.clientY };
2851
+ const C = n.state.stickers.find((P) => P.id === a.value);
2852
+ C && (c.value = {
2853
+ x: C.x,
2854
+ y: C.y,
2855
+ width: C.width,
2856
+ height: C.height,
2857
+ rotation: C.rotation
2858
+ }), window.addEventListener("pointermove", x), window.addEventListener("pointerup", _);
2859
+ }
2860
+ function x(u) {
2861
+ if (!i.value || !a.value) return;
2862
+ const g = e.canvasRect;
2863
+ if (g.width === 0 || g.height === 0) return;
2864
+ const k = (u.clientX - l.value.x) / g.width, C = (u.clientY - l.value.y) / g.height, P = c.value, V = n.state.stickers.find((A) => A.id === a.value);
2865
+ if (V) {
2778
2866
  switch (i.value) {
2779
2867
  case "move": {
2780
- D.x = m(x.x + f, 0, 1 - D.width), D.y = m(x.y + k, 0, 1 - D.height);
2868
+ V.x = w(P.x + k, 0, 1 - V.width), V.y = w(P.y + C, 0, 1 - V.height);
2781
2869
  break;
2782
2870
  }
2783
2871
  case "resize": {
2784
- switch (h.value) {
2872
+ switch (v.value) {
2785
2873
  case "se": {
2786
- D.width = m(x.width + f, 0.03, 1 - x.x), D.height = m(x.height + k, 0.03, 1 - x.y);
2874
+ V.width = w(P.width + k, 0.03, 1 - P.x), V.height = w(P.height + C, 0.03, 1 - P.y);
2787
2875
  break;
2788
2876
  }
2789
2877
  case "ne": {
2790
- const K = m(x.width + f, 0.03, 1 - x.x), L = m(x.height - k, 0.03, x.y + x.height), W = x.y + x.height - L;
2791
- D.width = K, D.height = L, D.y = W;
2878
+ const D = w(P.width + k, 0.03, 1 - P.x), K = w(P.height - C, 0.03, P.y + P.height), L = P.y + P.height - K;
2879
+ V.width = D, V.height = K, V.y = L;
2792
2880
  break;
2793
2881
  }
2794
2882
  case "sw": {
2795
- const K = m(x.width - f, 0.03, x.x + x.width), L = m(x.height + k, 0.03, 1 - x.y), W = x.x + x.width - K;
2796
- D.width = K, D.height = L, D.x = W;
2883
+ const D = w(P.width - k, 0.03, P.x + P.width), K = w(P.height + C, 0.03, 1 - P.y), L = P.x + P.width - D;
2884
+ V.width = D, V.height = K, V.x = L;
2797
2885
  break;
2798
2886
  }
2799
2887
  case "nw": {
2800
- const K = m(x.width - f, 0.03, x.x + x.width), L = m(x.height - k, 0.03, x.y + x.height), W = x.x + x.width - K, P = x.y + x.height - L;
2801
- D.width = K, D.height = L, D.x = W, D.y = P;
2888
+ const D = w(P.width - k, 0.03, P.x + P.width), K = w(P.height - C, 0.03, P.y + P.height), L = P.x + P.width - D, E = P.y + P.height - K;
2889
+ V.width = D, V.height = K, V.x = L, V.y = E;
2802
2890
  break;
2803
2891
  }
2804
2892
  }
2805
2893
  break;
2806
2894
  }
2807
2895
  case "rotate": {
2808
- const T = p.x + D.x * p.width + D.width * p.width / 2, K = p.y + D.y * p.height + D.height * p.height / 2, L = Math.atan2(l.clientX - T, -(l.clientY - K));
2809
- D.rotation = L;
2896
+ const A = g.x + V.x * g.width + V.width * g.width / 2, D = g.y + V.y * g.height + V.height * g.height / 2, K = Math.atan2(u.clientX - A, -(u.clientY - D));
2897
+ V.rotation = K;
2810
2898
  break;
2811
2899
  }
2812
2900
  }
2813
2901
  n.requestRender();
2814
2902
  }
2815
2903
  }
2816
- function b() {
2904
+ function _() {
2817
2905
  i.value && n.updateState(() => {
2818
- }), i.value = null, h.value = null, window.removeEventListener("pointermove", w), window.removeEventListener("pointerup", b);
2819
- }
2820
- function $(l) {
2821
- if ((l.key === "Delete" || l.key === "Backspace") && o.value) {
2822
- l.preventDefault();
2823
- const p = o.value;
2824
- n.updateState((f) => {
2825
- const k = f.stickers.findIndex((x) => x.id === p);
2826
- k >= 0 && f.stickers.splice(k, 1);
2827
- }), o.value = null;
2906
+ }), i.value = null, v.value = null, window.removeEventListener("pointermove", x), window.removeEventListener("pointerup", _);
2907
+ }
2908
+ function $(u) {
2909
+ if ((u.key === "Delete" || u.key === "Backspace") && a.value) {
2910
+ u.preventDefault();
2911
+ const g = a.value;
2912
+ n.updateState((k) => {
2913
+ const C = k.stickers.findIndex((P) => P.id === g);
2914
+ C >= 0 && k.stickers.splice(C, 1);
2915
+ }), a.value = null;
2828
2916
  }
2829
2917
  }
2830
- function m(l, p, f) {
2831
- return Math.max(p, Math.min(f, l));
2918
+ function w(u, g, k) {
2919
+ return Math.max(g, Math.min(k, u));
2832
2920
  }
2833
- return (l, p) => (M(), z("svg", {
2921
+ return (u, g) => (S(), z("svg", {
2834
2922
  ref_key: "svgRef",
2835
2923
  ref: t,
2836
2924
  class: "vie-sticker-overlay",
2837
- viewBox: `0 0 ${s.wrapperSize.width} ${s.wrapperSize.height}`,
2838
- width: s.wrapperSize.width,
2839
- height: s.wrapperSize.height,
2840
- onPointerdown: y,
2925
+ viewBox: `0 0 ${o.wrapperSize.width} ${o.wrapperSize.height}`,
2926
+ width: o.wrapperSize.width,
2927
+ height: o.wrapperSize.height,
2928
+ onPointerdown: m,
2841
2929
  onKeydown: $,
2842
2930
  tabindex: "0"
2843
2931
  }, [
2844
- (M(!0), z(X, null, N(d.value, (f) => (M(), z("rect", {
2845
- key: f.id,
2846
- x: f.x,
2847
- y: f.y,
2848
- width: f.w,
2849
- height: f.h,
2932
+ (S(!0), z(Y, null, Z(h.value, (k) => (S(), z("rect", {
2933
+ key: k.id,
2934
+ x: k.x,
2935
+ y: k.y,
2936
+ width: k.w,
2937
+ height: k.h,
2850
2938
  fill: "transparent",
2851
2939
  class: "vie-sticker-hitarea",
2852
- "data-sticker-id": f.id
2853
- }, null, 8, Pn))), 128)),
2854
- u.value ? (M(), z(X, { key: 0 }, [
2855
- g("rect", {
2856
- x: u.value.x,
2857
- y: u.value.y,
2858
- width: u.value.w,
2859
- height: u.value.h,
2940
+ "data-sticker-id": k.id
2941
+ }, null, 8, Gn))), 128)),
2942
+ r.value ? (S(), z(Y, { key: 0 }, [
2943
+ y("rect", {
2944
+ x: r.value.x,
2945
+ y: r.value.y,
2946
+ width: r.value.w,
2947
+ height: r.value.h,
2860
2948
  class: "vie-sticker-selection"
2861
- }, null, 8, Tn),
2862
- (M(!0), z(X, null, N(r.value, (f) => (M(), z("rect", {
2863
- key: f.id,
2864
- x: f.x,
2865
- y: f.y,
2866
- width: me,
2867
- height: me,
2949
+ }, null, 8, Qn),
2950
+ (S(!0), z(Y, null, Z(s.value, (k) => (S(), z("rect", {
2951
+ key: k.id,
2952
+ x: k.x,
2953
+ y: k.y,
2954
+ width: _e,
2955
+ height: _e,
2868
2956
  class: "vie-sticker-handle",
2869
- "data-handle": f.id
2870
- }, null, 8, En))), 128)),
2871
- g("line", {
2872
- x1: u.value.x + u.value.w / 2,
2873
- y1: u.value.y - Te,
2874
- x2: u.value.x + u.value.w / 2,
2875
- y2: u.value.y,
2957
+ "data-handle": k.id
2958
+ }, null, 8, ei))), 128)),
2959
+ y("line", {
2960
+ x1: r.value.x + r.value.w / 2,
2961
+ y1: r.value.y - je,
2962
+ x2: r.value.x + r.value.w / 2,
2963
+ y2: r.value.y,
2876
2964
  class: "vie-sticker-rotate-line"
2877
- }, null, 8, Wn),
2878
- g("circle", {
2879
- cx: u.value.x + u.value.w / 2,
2880
- cy: u.value.y - Te - Ee,
2881
- r: Ee,
2965
+ }, null, 8, ti),
2966
+ y("circle", {
2967
+ cx: r.value.x + r.value.w / 2,
2968
+ cy: r.value.y - je - Oe,
2969
+ r: Oe,
2882
2970
  class: "vie-sticker-rotate-handle",
2883
2971
  "data-handle": "rotate"
2884
- }, null, 8, Kn)
2885
- ], 64)) : Z("", !0)
2886
- ], 40, In));
2972
+ }, null, 8, ni)
2973
+ ], 64)) : G("", !0)
2974
+ ], 40, Jn));
2887
2975
  }
2888
- }), Ln = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2976
+ }), oi = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2889
2977
  <circle cx="12" cy="12" r="10" />
2890
2978
  <path d="M8 14s1.5 2 4 2 4-2 4-2" />
2891
2979
  <line x1="9" y1="9" x2="9.01" y2="9" />
2892
2980
  <line x1="15" y1="9" x2="15.01" y2="9" />
2893
2981
  </svg>`;
2894
- function An() {
2982
+ function ai() {
2895
2983
  return {
2896
2984
  id: "sticker",
2897
- icon: Ln,
2985
+ icon: oi,
2898
2986
  labelKey: "sticker",
2899
- controls: zn,
2900
- overlay: Dn
2987
+ controls: Zn,
2988
+ overlay: ii
2901
2989
  };
2902
2990
  }
2903
- const Fn = [
2991
+ const si = [
2904
2992
  { id: "solidSharp", labelKey: "solidSharp" },
2905
2993
  { id: "solidRound", labelKey: "solidRound" },
2906
2994
  { id: "lineSingle", labelKey: "lineSingle" },
@@ -2910,7 +2998,7 @@ const Fn = [
2910
2998
  { id: "edgeSeparate", labelKey: "edgeSeparate" },
2911
2999
  { id: "edgeCross", labelKey: "edgeCross" },
2912
3000
  { id: "edgeOverlap", labelKey: "edgeOverlap" }
2913
- ], Hn = [
3001
+ ], li = [
2914
3002
  [1, 1, 1, 1],
2915
3003
  // White
2916
3004
  [0, 0, 0, 1],
@@ -2923,89 +3011,89 @@ const Fn = [
2923
3011
  // Navy
2924
3012
  [0.8, 0.2, 0.2, 1]
2925
3013
  // Red
2926
- ], Vn = { class: "vie-frame-controls" }, On = { class: "vie-frame-strip" }, jn = { class: "vie-frame-style__label" }, Bn = ["onClick"], qn = { class: "vie-frame-style__label" }, Xn = { class: "vie-frame-colors" }, Yn = { class: "vie-frame-colors__label" }, Un = { class: "vie-frame-colors__swatches" }, Nn = ["onClick"], Zn = /* @__PURE__ */ Y({
3014
+ ], ri = { class: "vie-frame-controls" }, ci = { class: "vie-frame-strip" }, ui = { class: "vie-frame-style__label" }, di = ["onClick"], hi = { class: "vie-frame-style__label" }, vi = { class: "vie-frame-colors" }, fi = { class: "vie-frame-colors__label" }, pi = { class: "vie-frame-colors__swatches" }, mi = ["onClick"], gi = /* @__PURE__ */ J({
2927
3015
  __name: "FrameControls",
2928
- setup(s) {
2929
- const e = G(), n = Q(ee, (i) => i);
3016
+ setup(o) {
3017
+ const e = ee(), n = ie(oe, (i) => i);
2930
3018
  function t(i) {
2931
- e.updateState((h) => {
2932
- h.frame.style = i;
3019
+ e.updateState((v) => {
3020
+ v.frame.style = i;
2933
3021
  });
2934
3022
  }
2935
- function o(i) {
2936
- e.updateState((h) => {
2937
- h.frame.size = i;
3023
+ function a(i) {
3024
+ e.updateState((v) => {
3025
+ v.frame.size = i;
2938
3026
  });
2939
3027
  }
2940
- function d(i) {
2941
- e.updateState((h) => {
2942
- h.frame.color = [...i];
3028
+ function h(i) {
3029
+ e.updateState((v) => {
3030
+ v.frame.color = [...i];
2943
3031
  });
2944
3032
  }
2945
- function u(i) {
2946
- const h = e.state.frame.color;
2947
- return h[0] === i[0] && h[1] === i[1] && h[2] === i[2] && h[3] === i[3];
2948
- }
2949
3033
  function r(i) {
3034
+ const v = e.state.frame.color;
3035
+ return v[0] === i[0] && v[1] === i[1] && v[2] === i[2] && v[3] === i[3];
3036
+ }
3037
+ function s(i) {
2950
3038
  return `rgba(${Math.round(i[0] * 255)}, ${Math.round(i[1] * 255)}, ${Math.round(i[2] * 255)}, ${i[3]})`;
2951
3039
  }
2952
- return (i, h) => (M(), z("div", Vn, [
2953
- g("div", On, [
2954
- g("button", {
2955
- class: U(["vie-frame-style", { "vie-frame-style--active": !S(e).state.frame.style }]),
2956
- onClick: h[0] || (h[0] = (a) => t(null))
3040
+ return (i, v) => (S(), z("div", ri, [
3041
+ y("div", ci, [
3042
+ y("button", {
3043
+ class: N(["vie-frame-style", { "vie-frame-style--active": !I(e).state.frame.style }]),
3044
+ onClick: v[0] || (v[0] = (l) => t(null))
2957
3045
  }, [
2958
- g("span", jn, q(S(n)("none")), 1)
3046
+ y("span", ui, q(I(n)("none")), 1)
2959
3047
  ], 2),
2960
- (M(!0), z(X, null, N(S(Fn), (a) => (M(), z("button", {
2961
- key: a.id,
2962
- class: U(["vie-frame-style", { "vie-frame-style--active": S(e).state.frame.style === a.id }]),
2963
- onClick: (c) => t(a.id)
3048
+ (S(!0), z(Y, null, Z(I(si), (l) => (S(), z("button", {
3049
+ key: l.id,
3050
+ class: N(["vie-frame-style", { "vie-frame-style--active": I(e).state.frame.style === l.id }]),
3051
+ onClick: (c) => t(l.id)
2964
3052
  }, [
2965
- g("span", qn, q(S(n)(a.labelKey)), 1)
2966
- ], 10, Bn))), 128))
3053
+ y("span", hi, q(I(n)(l.labelKey)), 1)
3054
+ ], 10, di))), 128))
2967
3055
  ]),
2968
- S(e).state.frame.style ? (M(), z(X, { key: 0 }, [
2969
- j(ve, {
2970
- modelValue: S(e).state.frame.size,
3056
+ I(e).state.frame.style ? (S(), z(Y, { key: 0 }, [
3057
+ X(fe, {
3058
+ modelValue: I(e).state.frame.size,
2971
3059
  min: 5e-3,
2972
3060
  max: 0.15,
2973
3061
  step: 5e-3,
2974
3062
  base: 0.025,
2975
- label: S(n)("frameSize"),
3063
+ label: I(n)("frameSize"),
2976
3064
  format: "percent",
2977
- "onUpdate:modelValue": o
3065
+ "onUpdate:modelValue": a
2978
3066
  }, null, 8, ["modelValue", "label"]),
2979
- g("div", Xn, [
2980
- g("span", Yn, q(S(n)("frameColor")), 1),
2981
- g("div", Un, [
2982
- (M(!0), z(X, null, N(S(Hn), (a, c) => (M(), z("button", {
3067
+ y("div", vi, [
3068
+ y("span", fi, q(I(n)("frameColor")), 1),
3069
+ y("div", pi, [
3070
+ (S(!0), z(Y, null, Z(I(li), (l, c) => (S(), z("button", {
2983
3071
  key: c,
2984
- class: U(["vie-frame-color-swatch", { "vie-frame-color-swatch--active": u(a) }]),
2985
- style: se({ backgroundColor: r(a) }),
2986
- onClick: (y) => d(a)
2987
- }, null, 14, Nn))), 128))
3072
+ class: N(["vie-frame-color-swatch", { "vie-frame-color-swatch--active": r(l) }]),
3073
+ style: le({ backgroundColor: s(l) }),
3074
+ onClick: (m) => h(l)
3075
+ }, null, 14, mi))), 128))
2988
3076
  ])
2989
3077
  ])
2990
- ], 64)) : Z("", !0)
3078
+ ], 64)) : G("", !0)
2991
3079
  ]));
2992
3080
  }
2993
- }), Jn = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
3081
+ }), yi = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2994
3082
  <rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
2995
3083
  <rect x="7" y="7" width="10" height="10" />
2996
3084
  </svg>`;
2997
- function Gn() {
3085
+ function wi() {
2998
3086
  return {
2999
3087
  id: "frame",
3000
- icon: Jn,
3088
+ icon: yi,
3001
3089
  labelKey: "frame",
3002
- controls: Zn
3090
+ controls: gi
3003
3091
  };
3004
3092
  }
3005
- const Qn = { class: "vie-fill-controls" }, ei = { class: "vie-fill-strip" }, ti = ["title", "onClick"], ni = /* @__PURE__ */ Y({
3093
+ const ki = { class: "vie-fill-controls" }, bi = { class: "vie-fill-strip" }, xi = ["title", "onClick"], _i = /* @__PURE__ */ J({
3006
3094
  __name: "FillControls",
3007
- setup(s) {
3008
- const e = G(), n = Q(ee, (r) => r), t = [
3095
+ setup(o) {
3096
+ const e = ee(), n = ie(oe, (s) => s), t = [
3009
3097
  [0, 0, 0, 0],
3010
3098
  // Transparent
3011
3099
  [1, 1, 1, 1],
@@ -3041,109 +3129,109 @@ const Qn = { class: "vie-fill-controls" }, ei = { class: "vie-fill-strip" }, ti
3041
3129
  [0.61, 0.15, 0.69, 1]
3042
3130
  // Purple
3043
3131
  ];
3044
- function o(r) {
3132
+ function a(s) {
3045
3133
  e.updateState((i) => {
3046
- i.backgroundColor = [...r];
3134
+ i.backgroundColor = [...s];
3047
3135
  });
3048
3136
  }
3049
- function d(r) {
3137
+ function h(s) {
3050
3138
  const i = e.state.backgroundColor;
3051
- return i[0] === r[0] && i[1] === r[1] && i[2] === r[2] && i[3] === r[3];
3052
- }
3053
- function u(r) {
3054
- return `rgba(${Math.round(r[0] * 255)}, ${Math.round(r[1] * 255)}, ${Math.round(r[2] * 255)}, ${r[3]})`;
3055
- }
3056
- return (r, i) => (M(), z("div", Qn, [
3057
- g("div", ei, [
3058
- (M(), z(X, null, N(t, (h, a) => g("button", {
3059
- key: a,
3060
- class: U(["vie-fill-swatch", {
3061
- "vie-fill-swatch--active": d(h),
3062
- "vie-fill-swatch--transparent": h[3] === 0
3139
+ return i[0] === s[0] && i[1] === s[1] && i[2] === s[2] && i[3] === s[3];
3140
+ }
3141
+ function r(s) {
3142
+ return `rgba(${Math.round(s[0] * 255)}, ${Math.round(s[1] * 255)}, ${Math.round(s[2] * 255)}, ${s[3]})`;
3143
+ }
3144
+ return (s, i) => (S(), z("div", ki, [
3145
+ y("div", bi, [
3146
+ (S(), z(Y, null, Z(t, (v, l) => y("button", {
3147
+ key: l,
3148
+ class: N(["vie-fill-swatch", {
3149
+ "vie-fill-swatch--active": h(v),
3150
+ "vie-fill-swatch--transparent": v[3] === 0
3063
3151
  }]),
3064
- style: se(h[3] > 0 ? { backgroundColor: u(h) } : void 0),
3065
- title: a === 0 ? S(n)("transparent") : void 0,
3066
- onClick: (c) => o(h)
3067
- }, null, 14, ti)), 64))
3152
+ style: le(v[3] > 0 ? { backgroundColor: r(v) } : void 0),
3153
+ title: l === 0 ? I(n)("transparent") : void 0,
3154
+ onClick: (c) => a(v)
3155
+ }, null, 14, xi)), 64))
3068
3156
  ])
3069
3157
  ]));
3070
3158
  }
3071
- }), ii = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
3159
+ }), Ci = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
3072
3160
  <path d="M12 2.69l5.66 5.66a8 8 0 1 1-11.31 0z" />
3073
3161
  </svg>`;
3074
- function oi() {
3162
+ function Mi() {
3075
3163
  return {
3076
3164
  id: "fill",
3077
- icon: ii,
3165
+ icon: Ci,
3078
3166
  labelKey: "fill",
3079
- controls: ni
3167
+ controls: _i
3080
3168
  };
3081
3169
  }
3082
- const ai = { class: "vie-resize-controls" }, si = { class: "vie-resize-title" }, ri = { class: "vie-resize-dimensions" }, li = { class: "vie-resize-input" }, ci = { class: "vie-resize-input__label" }, ui = { class: "vie-resize-input__field-wrapper" }, di = ["value"], hi = ["title"], vi = {
3170
+ const Si = { class: "vie-resize-controls" }, $i = { class: "vie-resize-title" }, Ri = { class: "vie-resize-dimensions" }, zi = { class: "vie-resize-input" }, Ii = { class: "vie-resize-input__label" }, Pi = { class: "vie-resize-input__field-wrapper" }, Ti = ["value"], Ei = ["title"], Wi = {
3083
3171
  viewBox: "0 0 24 24",
3084
3172
  width: "16",
3085
3173
  height: "16",
3086
3174
  fill: "none",
3087
3175
  stroke: "currentColor",
3088
3176
  "stroke-width": "2"
3089
- }, pi = {
3177
+ }, Ai = {
3090
3178
  key: 0,
3091
3179
  d: "M7 11V7a5 5 0 0 1 10 0v4"
3092
- }, fi = {
3180
+ }, Fi = {
3093
3181
  key: 1,
3094
3182
  d: "M7 11V7a5 5 0 0 1 9.9-1"
3095
- }, mi = { class: "vie-resize-input" }, gi = { class: "vie-resize-input__label" }, yi = { class: "vie-resize-input__field-wrapper" }, wi = ["value"], ki = { class: "vie-resize-hint" }, bi = /* @__PURE__ */ Y({
3183
+ }, Di = { class: "vie-resize-input" }, Li = { class: "vie-resize-input__label" }, Ki = { class: "vie-resize-input__field-wrapper" }, Hi = ["value"], Vi = { class: "vie-resize-hint" }, Bi = /* @__PURE__ */ J({
3096
3184
  __name: "ResizeControls",
3097
- setup(s) {
3098
- const e = G(), n = Q(ee, (h) => h), t = H(!0), o = V(() => {
3099
- const h = e.sourceImage.value;
3100
- if (!h) return 1;
3101
- const a = e.state.crop;
3102
- return h.naturalWidth * a.width / (h.naturalHeight * a.height);
3103
- }), d = V(() => {
3185
+ setup(o) {
3186
+ const e = ee(), n = ie(oe, (v) => v), t = H(!0), a = j(() => {
3187
+ const v = e.sourceImage.value;
3188
+ if (!v) return 1;
3189
+ const l = e.state.crop;
3190
+ return v.naturalWidth * l.width / (v.naturalHeight * l.height);
3191
+ }), h = j(() => {
3104
3192
  if (e.state.resize.width) return e.state.resize.width;
3105
- const h = e.sourceImage.value;
3106
- return h ? Math.round(h.naturalWidth * e.state.crop.width) : 0;
3107
- }), u = V(() => {
3193
+ const v = e.sourceImage.value;
3194
+ return v ? Math.round(v.naturalWidth * e.state.crop.width) : 0;
3195
+ }), r = j(() => {
3108
3196
  if (e.state.resize.height) return e.state.resize.height;
3109
- const h = e.sourceImage.value;
3110
- return h ? Math.round(h.naturalHeight * e.state.crop.height) : 0;
3197
+ const v = e.sourceImage.value;
3198
+ return v ? Math.round(v.naturalHeight * e.state.crop.height) : 0;
3111
3199
  });
3112
- function r(h) {
3113
- const a = parseInt(h, 10);
3114
- !a || a < 1 || e.updateState((c) => {
3115
- c.resize.width = a, t.value && (c.resize.height = Math.round(a / o.value));
3200
+ function s(v) {
3201
+ const l = parseInt(v, 10);
3202
+ !l || l < 1 || e.updateState((c) => {
3203
+ c.resize.width = l, t.value && (c.resize.height = Math.round(l / a.value));
3116
3204
  });
3117
3205
  }
3118
- function i(h) {
3119
- const a = parseInt(h, 10);
3120
- !a || a < 1 || e.updateState((c) => {
3121
- c.resize.height = a, t.value && (c.resize.width = Math.round(a * o.value));
3206
+ function i(v) {
3207
+ const l = parseInt(v, 10);
3208
+ !l || l < 1 || e.updateState((c) => {
3209
+ c.resize.height = l, t.value && (c.resize.width = Math.round(l * a.value));
3122
3210
  });
3123
3211
  }
3124
- return (h, a) => (M(), z("div", ai, [
3125
- g("p", si, q(S(n)("imageOutputSize")), 1),
3126
- g("div", ri, [
3127
- g("div", li, [
3128
- g("label", ci, q(S(n)("width")), 1),
3129
- g("div", ui, [
3130
- g("input", {
3212
+ return (v, l) => (S(), z("div", Si, [
3213
+ y("p", $i, q(I(n)("imageOutputSize")), 1),
3214
+ y("div", Ri, [
3215
+ y("div", zi, [
3216
+ y("label", Ii, q(I(n)("width")), 1),
3217
+ y("div", Pi, [
3218
+ y("input", {
3131
3219
  type: "number",
3132
3220
  class: "vie-resize-input__field",
3133
- value: d.value,
3221
+ value: h.value,
3134
3222
  min: "1",
3135
- onInput: a[0] || (a[0] = (c) => r(c.target.value))
3136
- }, null, 40, di),
3137
- a[3] || (a[3] = g("span", { class: "vie-resize-input__unit" }, "px", -1))
3223
+ onInput: l[0] || (l[0] = (c) => s(c.target.value))
3224
+ }, null, 40, Ti),
3225
+ l[3] || (l[3] = y("span", { class: "vie-resize-input__unit" }, "px", -1))
3138
3226
  ])
3139
3227
  ]),
3140
- g("button", {
3141
- class: U(["vie-resize-lock", { "vie-resize-lock--active": t.value }]),
3142
- onClick: a[1] || (a[1] = (c) => t.value = !t.value),
3143
- title: S(n)("lockAspectRatio")
3228
+ y("button", {
3229
+ class: N(["vie-resize-lock", { "vie-resize-lock--active": t.value }]),
3230
+ onClick: l[1] || (l[1] = (c) => t.value = !t.value),
3231
+ title: I(n)("lockAspectRatio")
3144
3232
  }, [
3145
- (M(), z("svg", vi, [
3146
- a[4] || (a[4] = g("rect", {
3233
+ (S(), z("svg", Wi, [
3234
+ l[4] || (l[4] = y("rect", {
3147
3235
  x: "3",
3148
3236
  y: "11",
3149
3237
  width: "18",
@@ -3151,94 +3239,589 @@ const ai = { class: "vie-resize-controls" }, si = { class: "vie-resize-title" },
3151
3239
  rx: "2",
3152
3240
  ry: "2"
3153
3241
  }, null, -1)),
3154
- t.value ? (M(), z("path", pi)) : (M(), z("path", fi))
3242
+ t.value ? (S(), z("path", Ai)) : (S(), z("path", Fi))
3155
3243
  ]))
3156
- ], 10, hi),
3157
- g("div", mi, [
3158
- g("label", gi, q(S(n)("height")), 1),
3159
- g("div", yi, [
3160
- g("input", {
3244
+ ], 10, Ei),
3245
+ y("div", Di, [
3246
+ y("label", Li, q(I(n)("height")), 1),
3247
+ y("div", Ki, [
3248
+ y("input", {
3161
3249
  type: "number",
3162
3250
  class: "vie-resize-input__field",
3163
- value: u.value,
3251
+ value: r.value,
3164
3252
  min: "1",
3165
- onInput: a[2] || (a[2] = (c) => i(c.target.value))
3166
- }, null, 40, wi),
3167
- a[5] || (a[5] = g("span", { class: "vie-resize-input__unit" }, "px", -1))
3253
+ onInput: l[2] || (l[2] = (c) => i(c.target.value))
3254
+ }, null, 40, Hi),
3255
+ l[5] || (l[5] = y("span", { class: "vie-resize-input__unit" }, "px", -1))
3168
3256
  ])
3169
3257
  ])
3170
3258
  ]),
3171
- g("p", ki, q(S(n)("resizeHint")), 1)
3259
+ y("p", Vi, q(I(n)("resizeHint")), 1)
3172
3260
  ]));
3173
3261
  }
3174
- }), _i = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
3262
+ }), ji = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
3175
3263
  <polyline points="15 3 21 3 21 9" />
3176
3264
  <polyline points="9 21 3 21 3 15" />
3177
3265
  <line x1="21" y1="3" x2="14" y2="10" />
3178
3266
  <line x1="3" y1="21" x2="10" y2="14" />
3179
3267
  </svg>`;
3180
- function xi() {
3268
+ function Oi() {
3181
3269
  return {
3182
3270
  id: "resize",
3183
- icon: _i,
3271
+ icon: ji,
3184
3272
  labelKey: "resize",
3185
- controls: bi
3273
+ controls: Bi
3274
+ };
3275
+ }
3276
+ const Xe = /* @__PURE__ */ new WeakMap();
3277
+ function at(o) {
3278
+ let e = Xe.get(o);
3279
+ return e || (e = H(null), Xe.set(o, e)), e;
3280
+ }
3281
+ const Xi = { class: "vie-annotate-controls" }, qi = {
3282
+ key: 0,
3283
+ class: "vie-annotate-toolbar"
3284
+ }, Yi = ["title"], Ui = {
3285
+ key: 1,
3286
+ class: "vie-annotate-props"
3287
+ }, Ni = { class: "vie-annotate-prop-row" }, Zi = { class: "vie-annotate-prop-label" }, Ji = { class: "vie-annotate-color-picker" }, Gi = ["title", "onClick"], Qi = { class: "vie-annotate-prop-row" }, eo = { class: "vie-annotate-prop-label" }, to = { class: "vie-annotate-font-buttons" }, no = ["onClick"], io = { class: "vie-annotate-prop-row" }, oo = /* @__PURE__ */ J({
3288
+ __name: "AnnotateControls",
3289
+ setup(o) {
3290
+ const e = ee(), n = ie(oe, (c) => c), t = at(e.state), a = j(() => t.value && e.state.annotations.find((c) => c.id === t.value) || null), h = [
3291
+ { label: "Black", value: [0, 0, 0, 1] },
3292
+ { label: "White", value: [1, 1, 1, 1] },
3293
+ { label: "Red", value: [0.9, 0.15, 0.15, 1] },
3294
+ { label: "Orange", value: [0.95, 0.55, 0.1, 1] },
3295
+ { label: "Yellow", value: [0.95, 0.85, 0.1, 1] },
3296
+ { label: "Green", value: [0.2, 0.75, 0.3, 1] },
3297
+ { label: "Blue", value: [0.2, 0.45, 0.85, 1] },
3298
+ { label: "Purple", value: [0.55, 0.25, 0.8, 1] },
3299
+ { label: "Accent", value: [0.106, 0.286, 0.396, 1] }
3300
+ ], r = [
3301
+ { label: "Sans", value: "sans-serif" },
3302
+ { label: "Serif", value: "serif" },
3303
+ { label: "Mono", value: "monospace" }
3304
+ ];
3305
+ function s(c) {
3306
+ return `rgba(${Math.round(c[0] * 255)}, ${Math.round(c[1] * 255)}, ${Math.round(c[2] * 255)}, ${c[3]})`;
3307
+ }
3308
+ function i(c, m) {
3309
+ return Math.abs(c[0] - m[0]) < 0.01 && Math.abs(c[1] - m[1]) < 0.01 && Math.abs(c[2] - m[2]) < 0.01 && Math.abs(c[3] - m[3]) < 0.01;
3310
+ }
3311
+ function v(c, m) {
3312
+ if (!t.value) return;
3313
+ const d = t.value;
3314
+ e.updateState((x) => {
3315
+ const _ = x.annotations.find(($) => $.id === d);
3316
+ _ && (_[c] = m);
3317
+ });
3318
+ }
3319
+ function l() {
3320
+ if (!t.value) return;
3321
+ const c = t.value;
3322
+ e.updateState((m) => {
3323
+ const d = m.annotations.findIndex((x) => x.id === c);
3324
+ d >= 0 && m.annotations.splice(d, 1);
3325
+ }), t.value = null;
3326
+ }
3327
+ return (c, m) => (S(), z("div", Xi, [
3328
+ I(t) ? (S(), z("div", qi, [
3329
+ y("button", {
3330
+ class: "vie-annotate-tool vie-annotate-tool--delete",
3331
+ title: I(n)("delete"),
3332
+ onClick: l
3333
+ }, [...m[4] || (m[4] = [
3334
+ y("svg", {
3335
+ viewBox: "0 0 24 24",
3336
+ fill: "none",
3337
+ stroke: "currentColor",
3338
+ "stroke-width": "2",
3339
+ "stroke-linecap": "round",
3340
+ "stroke-linejoin": "round"
3341
+ }, [
3342
+ y("polyline", { points: "3 6 5 6 21 6" }),
3343
+ y("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
3344
+ ], -1)
3345
+ ])], 8, Yi)
3346
+ ])) : G("", !0),
3347
+ a.value ? (S(), z("div", Ui, [
3348
+ y("div", Ni, [
3349
+ y("span", Zi, q(I(n)("fillColor")), 1),
3350
+ y("div", Ji, [
3351
+ (S(), z(Y, null, Z(h, (d) => y("button", {
3352
+ key: "text-" + d.label,
3353
+ class: N(["vie-annotate-color-swatch", { "vie-annotate-color-swatch--active": i(a.value.fillColor, d.value) }]),
3354
+ style: le({ backgroundColor: s(d.value) }),
3355
+ title: d.label,
3356
+ onClick: (x) => v("fillColor", [...d.value])
3357
+ }, null, 14, Gi)), 64))
3358
+ ])
3359
+ ]),
3360
+ X(fe, {
3361
+ label: I(n)("fontSize"),
3362
+ modelValue: a.value.fontSize * 1e3,
3363
+ min: 15,
3364
+ max: 120,
3365
+ step: 1,
3366
+ base: 40,
3367
+ format: "number",
3368
+ "onUpdate:modelValue": m[0] || (m[0] = (d) => v("fontSize", d / 1e3))
3369
+ }, null, 8, ["label", "modelValue"]),
3370
+ y("div", Qi, [
3371
+ y("span", eo, q(I(n)("fontFamily")), 1),
3372
+ y("div", to, [
3373
+ (S(), z(Y, null, Z(r, (d) => y("button", {
3374
+ key: d.value,
3375
+ class: N(["vie-annotate-font-btn", { "vie-annotate-font-btn--active": a.value.fontFamily === d.value }]),
3376
+ style: le({ fontFamily: d.value }),
3377
+ onClick: (x) => v("fontFamily", d.value)
3378
+ }, q(d.label), 15, no)), 64))
3379
+ ])
3380
+ ]),
3381
+ y("div", io, [
3382
+ y("button", {
3383
+ class: N(["vie-annotate-toggle", { "vie-annotate-toggle--active": a.value.fontWeight === "bold" }]),
3384
+ onClick: m[1] || (m[1] = (d) => v("fontWeight", a.value.fontWeight === "bold" ? "normal" : "bold"))
3385
+ }, [...m[5] || (m[5] = [
3386
+ y("strong", null, "B", -1)
3387
+ ])], 2),
3388
+ y("button", {
3389
+ class: N(["vie-annotate-toggle", { "vie-annotate-toggle--active": a.value.fontStyle === "italic" }]),
3390
+ onClick: m[2] || (m[2] = (d) => v("fontStyle", a.value.fontStyle === "italic" ? "normal" : "italic"))
3391
+ }, [...m[6] || (m[6] = [
3392
+ y("em", null, "I", -1)
3393
+ ])], 2)
3394
+ ]),
3395
+ X(fe, {
3396
+ label: I(n)("opacity"),
3397
+ modelValue: a.value.opacity,
3398
+ min: 0.1,
3399
+ max: 1,
3400
+ step: 0.05,
3401
+ base: 1,
3402
+ format: "percent",
3403
+ "onUpdate:modelValue": m[3] || (m[3] = (d) => v("opacity", d))
3404
+ }, null, 8, ["label", "modelValue"])
3405
+ ])) : G("", !0)
3406
+ ]));
3407
+ }
3408
+ });
3409
+ let ao = 0;
3410
+ function so() {
3411
+ return `ann-${Date.now()}-${++ao}-${Math.random().toString(36).slice(2, 6)}`;
3412
+ }
3413
+ const lo = [1, 1, 1, 1];
3414
+ function ro(o, e, n, t) {
3415
+ return {
3416
+ id: so(),
3417
+ x: o,
3418
+ y: e,
3419
+ width: n,
3420
+ height: t,
3421
+ rotation: 0,
3422
+ strokeColor: [0, 0, 0, 0],
3423
+ strokeWidth: 0,
3424
+ opacity: 1,
3425
+ type: "text",
3426
+ text: "",
3427
+ fontSize: 0.04,
3428
+ fontFamily: "sans-serif",
3429
+ fontWeight: "normal",
3430
+ fontStyle: "normal",
3431
+ fillColor: [...lo],
3432
+ textAlign: "left"
3186
3433
  };
3187
3434
  }
3188
- const Ci = ["dir"], Mi = { class: "vie-main" }, Si = /* @__PURE__ */ Y({
3435
+ const co = ["viewBox", "width", "height"], uo = ["x", "y", "width", "height", "data-annotation-id"], ho = ["transform"], vo = ["x", "y", "width", "height"], fo = ["x", "y", "data-handle"], po = ["x1", "y1", "x2", "y2"], mo = ["cx", "cy"], go = ["x", "y", "width", "height"], yo = ["value", "onKeydown"], Ce = 10, qe = 20, Ye = 6, Ue = 6, Ne = 4, wo = /* @__PURE__ */ J({
3436
+ __name: "AnnotateOverlay",
3437
+ props: {
3438
+ canvasRect: {},
3439
+ wrapperSize: {}
3440
+ },
3441
+ setup(o) {
3442
+ function e(f, p, b, R, T, W) {
3443
+ const U = document.createElement("canvas").getContext("2d");
3444
+ U.font = `${T} ${R} ${p}px ${b}`;
3445
+ const Q = p * 1.2, te = f.split(`
3446
+ `);
3447
+ let ae = 0, me = 0;
3448
+ for (const st of te) {
3449
+ const lt = st.split(" ");
3450
+ let ue = "";
3451
+ for (const ke of lt) {
3452
+ const Fe = ue ? `${ue} ${ke}` : ke;
3453
+ U.measureText(Fe).width > W && ue ? (ae = Math.max(ae, U.measureText(ue).width), me++, ue = ke) : ue = Fe;
3454
+ }
3455
+ ae = Math.max(ae, U.measureText(ue).width), me++;
3456
+ }
3457
+ return { width: ae, height: me * Q };
3458
+ }
3459
+ const n = o, t = ee(), a = H(null), h = H(null), r = at(t.state), s = H(!1), i = H(""), v = H(null), l = H({
3460
+ size: 14,
3461
+ family: "sans-serif",
3462
+ weight: "normal",
3463
+ style: "normal",
3464
+ color: "#ffffff"
3465
+ }), c = j(() => ({
3466
+ fontSize: l.value.size + "px",
3467
+ fontFamily: l.value.family,
3468
+ fontWeight: l.value.weight,
3469
+ fontStyle: l.value.style,
3470
+ color: l.value.color
3471
+ }));
3472
+ he(() => {
3473
+ $.value && (t.updateState(() => {
3474
+ }), $.value = null, w.value = null), window.removeEventListener("pointermove", E), window.removeEventListener("pointerup", O);
3475
+ });
3476
+ const m = j(() => {
3477
+ const f = n.canvasRect;
3478
+ return t.state.annotations.map((p) => ({
3479
+ id: p.id,
3480
+ dx: f.x + p.x * f.width,
3481
+ dy: f.y + p.y * f.height,
3482
+ dw: p.width * f.width,
3483
+ dh: p.height * f.height
3484
+ }));
3485
+ }), d = j(() => r.value && m.value.find((f) => f.id === r.value) || null), x = j(() => {
3486
+ if (!r.value || !d.value) return "";
3487
+ const f = t.state.annotations.find((T) => T.id === r.value);
3488
+ if (!f || f.rotation === 0) return "";
3489
+ const p = d.value.dx + d.value.dw / 2, b = d.value.dy + d.value.dh / 2;
3490
+ return `rotate(${f.rotation * 180 / Math.PI} ${p} ${b})`;
3491
+ }), _ = j(() => {
3492
+ if (!d.value) return [];
3493
+ const f = d.value, p = Ce / 2;
3494
+ return [
3495
+ { id: "nw", x: f.dx - p, y: f.dy - p },
3496
+ { id: "ne", x: f.dx + f.dw - p, y: f.dy - p },
3497
+ { id: "sw", x: f.dx - p, y: f.dy + f.dh - p },
3498
+ { id: "se", x: f.dx + f.dw - p, y: f.dy + f.dh - p }
3499
+ ];
3500
+ }), $ = H(null), w = H(null), u = H({ x: 0, y: 0 }), g = H({ x: 0, y: 0, width: 0, height: 0, rotation: 0 });
3501
+ function k(f) {
3502
+ var b;
3503
+ const p = (b = a.value) == null ? void 0 : b.getBoundingClientRect();
3504
+ return p ? { x: f.clientX - p.left, y: f.clientY - p.top } : { x: f.clientX, y: f.clientY };
3505
+ }
3506
+ function C(f) {
3507
+ var te;
3508
+ const p = f.target, b = p.getAttribute("data-handle");
3509
+ if (b === "rotate" && r.value) {
3510
+ f.preventDefault(), L(f, "rotate", b);
3511
+ return;
3512
+ }
3513
+ if (b && ["nw", "ne", "sw", "se"].includes(b) && r.value) {
3514
+ f.preventDefault(), L(f, "resize", b);
3515
+ return;
3516
+ }
3517
+ const R = p.getAttribute("data-annotation-id");
3518
+ if (R) {
3519
+ f.preventDefault(), r.value = R, s.value = !1;
3520
+ const ae = t.state.annotations.find((me) => me.id === R);
3521
+ if (ae && f.detail >= 2) {
3522
+ V(ae);
3523
+ return;
3524
+ }
3525
+ L(f, "move", null), (te = a.value) == null || te.focus();
3526
+ return;
3527
+ }
3528
+ if (f.preventDefault(), s.value) {
3529
+ K(), r.value = null;
3530
+ return;
3531
+ }
3532
+ r.value = null;
3533
+ const T = n.canvasRect, W = k(f), B = (W.x - T.x) / T.width, U = (W.y - T.y) / T.height, Q = ro(F(B, 0, 0.9), F(U, 0, 0.9), 0.25, 0.06);
3534
+ t.updateState((ae) => ae.annotations.push(Q)), r.value = Q.id, Se(() => V(Q));
3535
+ }
3536
+ function P(f) {
3537
+ return `rgba(${Math.round(f[0] * 255)}, ${Math.round(f[1] * 255)}, ${Math.round(f[2] * 255)}, ${f[3]})`;
3538
+ }
3539
+ function V(f) {
3540
+ s.value = !0, i.value = f.text;
3541
+ const p = n.canvasRect, b = f.fontSize * p.height;
3542
+ v.value = {
3543
+ x: p.x + f.x * p.width - Ue,
3544
+ y: p.y + f.y * p.height - Ne,
3545
+ w: Math.max(120, f.width * p.width + Ue * 2),
3546
+ h: Math.max(b * 1.6, f.height * p.height + Ne * 2)
3547
+ }, l.value = {
3548
+ size: b,
3549
+ family: f.fontFamily,
3550
+ weight: f.fontWeight,
3551
+ style: f.fontStyle,
3552
+ color: P(f.fillColor)
3553
+ }, Se(() => {
3554
+ h.value && (h.value.focus(), D());
3555
+ });
3556
+ }
3557
+ function A(f) {
3558
+ i.value = f.target.value, D();
3559
+ }
3560
+ function D() {
3561
+ const f = h.value;
3562
+ if (!f || !v.value) return;
3563
+ f.style.height = "0";
3564
+ const p = f.scrollHeight + 4;
3565
+ f.style.height = "100%", p > v.value.h && (v.value.h = p);
3566
+ }
3567
+ function K() {
3568
+ if (r.value) {
3569
+ const f = t.state.annotations.find((p) => p.id === r.value);
3570
+ f && (f.text = i.value);
3571
+ }
3572
+ if (r.value) {
3573
+ const f = n.canvasRect, p = t.state.annotations.find((b) => b.id === r.value);
3574
+ if (p && p.text.trim() && f.width > 0 && f.height > 0) {
3575
+ const b = p.fontSize * f.height, R = p.width * f.width, T = e(
3576
+ p.text,
3577
+ b,
3578
+ p.fontFamily,
3579
+ p.fontWeight,
3580
+ p.fontStyle,
3581
+ R
3582
+ );
3583
+ p.width = T.width / f.width, p.height = T.height / f.height;
3584
+ }
3585
+ }
3586
+ if (s.value = !1, v.value = null, r.value) {
3587
+ const f = t.state.annotations.find((p) => p.id === r.value);
3588
+ if (f && !f.text.trim()) {
3589
+ const p = r.value;
3590
+ t.updateState((b) => {
3591
+ const R = b.annotations.findIndex((T) => T.id === p);
3592
+ R >= 0 && b.annotations.splice(R, 1);
3593
+ }), r.value = null;
3594
+ } else f && t.updateState(() => {
3595
+ });
3596
+ }
3597
+ }
3598
+ function L(f, p, b) {
3599
+ $.value = p, w.value = b;
3600
+ const R = k(f);
3601
+ u.value = { x: R.x, y: R.y };
3602
+ const T = t.state.annotations.find((W) => W.id === r.value);
3603
+ T && (g.value = {
3604
+ x: T.x,
3605
+ y: T.y,
3606
+ width: T.width,
3607
+ height: T.height,
3608
+ rotation: T.rotation
3609
+ }), window.addEventListener("pointermove", E), window.addEventListener("pointerup", O);
3610
+ }
3611
+ function E(f) {
3612
+ if (!$.value) return;
3613
+ const p = n.canvasRect;
3614
+ if (p.width === 0 || p.height === 0) return;
3615
+ const b = k(f), R = (b.x - u.value.x) / p.width, T = (b.y - u.value.y) / p.height, W = g.value;
3616
+ switch ($.value) {
3617
+ case "move": {
3618
+ if (!r.value) break;
3619
+ const B = t.state.annotations.find((U) => U.id === r.value);
3620
+ if (!B) break;
3621
+ B.x = F(W.x + R, 0, 1 - B.width), B.y = F(W.y + T, 0, 1 - B.height), t.requestRender(!0);
3622
+ break;
3623
+ }
3624
+ case "resize": {
3625
+ if (!r.value) break;
3626
+ const B = t.state.annotations.find((Q) => Q.id === r.value);
3627
+ if (!B) break;
3628
+ const U = 0.01;
3629
+ switch (w.value) {
3630
+ case "se":
3631
+ B.width = F(W.width + R, U, 1 - W.x), B.height = F(W.height + T, U, 1 - W.y);
3632
+ break;
3633
+ case "ne": {
3634
+ const Q = F(W.width + R, U, 1 - W.x), te = F(W.height - T, U, W.y + W.height);
3635
+ B.width = Q, B.height = te, B.y = W.y + W.height - te;
3636
+ break;
3637
+ }
3638
+ case "sw": {
3639
+ const Q = F(W.width - R, U, W.x + W.width), te = F(W.height + T, U, 1 - W.y);
3640
+ B.width = Q, B.height = te, B.x = W.x + W.width - Q;
3641
+ break;
3642
+ }
3643
+ case "nw": {
3644
+ const Q = F(W.width - R, U, W.x + W.width), te = F(W.height - T, U, W.y + W.height);
3645
+ B.width = Q, B.height = te, B.x = W.x + W.width - Q, B.y = W.y + W.height - te;
3646
+ break;
3647
+ }
3648
+ }
3649
+ t.requestRender(!0);
3650
+ break;
3651
+ }
3652
+ case "rotate": {
3653
+ if (!r.value) break;
3654
+ const B = t.state.annotations.find((ae) => ae.id === r.value);
3655
+ if (!B) break;
3656
+ const U = p.x + B.x * p.width + B.width * p.width / 2, Q = p.y + B.y * p.height + B.height * p.height / 2, te = Math.atan2(b.x - U, -(b.y - Q));
3657
+ B.rotation = te, t.requestRender(!0);
3658
+ break;
3659
+ }
3660
+ }
3661
+ }
3662
+ function O() {
3663
+ $.value && t.updateState(() => {
3664
+ }), $.value = null, w.value = null, window.removeEventListener("pointermove", E), window.removeEventListener("pointerup", O);
3665
+ }
3666
+ function M(f) {
3667
+ if ((f.key === "Delete" || f.key === "Backspace") && r.value && !s.value) {
3668
+ f.preventDefault();
3669
+ const p = r.value;
3670
+ t.updateState((b) => {
3671
+ const R = b.annotations.findIndex((T) => T.id === p);
3672
+ R >= 0 && b.annotations.splice(R, 1);
3673
+ }), r.value = null;
3674
+ }
3675
+ f.key === "Escape" && (s.value ? K() : r.value = null);
3676
+ }
3677
+ function F(f, p, b) {
3678
+ return Math.max(p, Math.min(b, f));
3679
+ }
3680
+ return (f, p) => (S(), z("svg", {
3681
+ ref_key: "svgRef",
3682
+ ref: a,
3683
+ class: "vie-annotate-overlay",
3684
+ viewBox: `0 0 ${o.wrapperSize.width} ${o.wrapperSize.height}`,
3685
+ width: o.wrapperSize.width,
3686
+ height: o.wrapperSize.height,
3687
+ onPointerdown: C,
3688
+ onKeydown: M,
3689
+ tabindex: "0"
3690
+ }, [
3691
+ (S(!0), z(Y, null, Z(m.value, (b) => (S(), z("rect", {
3692
+ key: b.id,
3693
+ x: b.dx,
3694
+ y: b.dy,
3695
+ width: b.dw,
3696
+ height: b.dh,
3697
+ fill: "transparent",
3698
+ class: "vie-annotate-hitarea",
3699
+ "data-annotation-id": b.id
3700
+ }, null, 8, uo))), 128)),
3701
+ d.value ? (S(), z("g", {
3702
+ key: 0,
3703
+ transform: x.value
3704
+ }, [
3705
+ y("rect", {
3706
+ x: d.value.dx,
3707
+ y: d.value.dy,
3708
+ width: d.value.dw,
3709
+ height: d.value.dh,
3710
+ class: "vie-annotate-selection"
3711
+ }, null, 8, vo),
3712
+ (S(!0), z(Y, null, Z(_.value, (b) => (S(), z("rect", {
3713
+ key: b.id,
3714
+ x: b.x,
3715
+ y: b.y,
3716
+ width: Ce,
3717
+ height: Ce,
3718
+ class: "vie-annotate-handle",
3719
+ "data-handle": b.id
3720
+ }, null, 8, fo))), 128)),
3721
+ y("line", {
3722
+ x1: d.value.dx + d.value.dw / 2,
3723
+ y1: d.value.dy - qe,
3724
+ x2: d.value.dx + d.value.dw / 2,
3725
+ y2: d.value.dy,
3726
+ class: "vie-annotate-rotate-line"
3727
+ }, null, 8, po),
3728
+ y("circle", {
3729
+ cx: d.value.dx + d.value.dw / 2,
3730
+ cy: d.value.dy - qe - Ye,
3731
+ r: Ye,
3732
+ class: "vie-annotate-rotate-handle",
3733
+ "data-handle": "rotate"
3734
+ }, null, 8, mo)
3735
+ ], 8, ho)) : G("", !0),
3736
+ s.value && v.value ? (S(), z("foreignObject", {
3737
+ key: 1,
3738
+ x: v.value.x,
3739
+ y: v.value.y,
3740
+ width: v.value.w,
3741
+ height: v.value.h
3742
+ }, [
3743
+ y("textarea", {
3744
+ ref_key: "textareaRef",
3745
+ ref: h,
3746
+ class: "vie-annotate-text-input",
3747
+ style: le(c.value),
3748
+ value: i.value,
3749
+ onInput: A,
3750
+ onBlur: K,
3751
+ onKeydown: Me(ve(K, ["prevent"]), ["escape"])
3752
+ }, null, 44, yo)
3753
+ ], 8, go)) : G("", !0)
3754
+ ], 40, co));
3755
+ }
3756
+ }), ko = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
3757
+ <polyline points="4 7 4 4 20 4 20 7"/>
3758
+ <line x1="9.5" y1="20" x2="14.5" y2="20"/>
3759
+ <line x1="12" y1="4" x2="12" y2="20"/>
3760
+ </svg>`;
3761
+ function bo() {
3762
+ return {
3763
+ id: "text",
3764
+ icon: ko,
3765
+ labelKey: "text",
3766
+ controls: oo,
3767
+ overlay: wo
3768
+ };
3769
+ }
3770
+ const xo = ["dir"], _o = { class: "vie-main" }, Co = /* @__PURE__ */ J({
3189
3771
  __name: "EditorShell",
3190
3772
  props: {
3191
3773
  options: {}
3192
3774
  },
3193
3775
  emits: ["process", "close"],
3194
- setup(s, { emit: e }) {
3195
- const n = s, t = e, o = nt(n.options);
3196
- it(o);
3197
- const d = { en: ut, ar: dt }, u = V(() => {
3198
- const b = n.options.locale || "en";
3776
+ setup(o, { emit: e }) {
3777
+ const n = o, t = e, a = kt(n.options);
3778
+ bt(a);
3779
+ const h = { en: Pt, ar: Tt }, r = j(() => {
3780
+ const _ = n.options.locale || "en";
3199
3781
  return ($) => {
3200
- var m;
3201
- return ((m = d[b]) == null ? void 0 : m[$]) || d.en[$] || $;
3782
+ var w;
3783
+ return ((w = h[_]) == null ? void 0 : w[$]) || h.en[$] || $;
3202
3784
  };
3203
3785
  });
3204
- We(ee, (b) => u.value(b));
3205
- const r = {
3206
- crop: () => o.registerPlugin(un()),
3207
- finetune: () => o.registerPlugin(fn()),
3208
- filter: () => o.registerPlugin(xn()),
3209
- sticker: () => o.registerPlugin(An()),
3210
- frame: () => o.registerPlugin(Gn()),
3211
- fill: () => o.registerPlugin(oi()),
3212
- resize: () => o.registerPlugin(xi())
3213
- }, i = n.options.plugins || ["crop", "finetune", "filter", "sticker", "frame", "resize"];
3214
- for (const b of i)
3215
- r[b] && r[b]();
3786
+ Ze(oe, (_) => r.value(_));
3787
+ const s = {
3788
+ crop: () => a.registerPlugin(Pn()),
3789
+ finetune: () => a.registerPlugin(Fn()),
3790
+ filter: () => a.registerPlugin(On()),
3791
+ sticker: () => a.registerPlugin(ai()),
3792
+ frame: () => a.registerPlugin(wi()),
3793
+ fill: () => a.registerPlugin(Mi()),
3794
+ resize: () => a.registerPlugin(Oi()),
3795
+ text: () => a.registerPlugin(bo())
3796
+ }, i = n.options.plugins || ["crop", "finetune", "filter", "text", "sticker", "frame", "resize"];
3797
+ for (const _ of i)
3798
+ s[_] && s[_]();
3216
3799
  if (n.options.customPlugins)
3217
- for (const b of n.options.customPlugins)
3218
- o.registerPlugin(b);
3219
- const h = H(null), a = H(!1);
3800
+ for (const _ of n.options.customPlugins)
3801
+ a.registerPlugin(_);
3802
+ const v = H(null), l = H(!1);
3220
3803
  let c = null;
3221
- ue(() => {
3222
- h.value && (c = new ResizeObserver((b) => {
3223
- for (const $ of b) {
3224
- const { width: m, height: l } = $.contentRect;
3225
- a.value = m > l && m > 700;
3804
+ ge(() => {
3805
+ v.value && (c = new ResizeObserver((_) => {
3806
+ for (const $ of _) {
3807
+ const { width: w, height: u } = $.contentRect;
3808
+ l.value = w > u && w > 700;
3226
3809
  }
3227
- }), c.observe(h.value), h.value.focus());
3228
- }), re(() => {
3810
+ }), c.observe(v.value), v.value.focus());
3811
+ }), he(() => {
3229
3812
  c == null || c.disconnect();
3230
3813
  });
3231
- function y(b) {
3232
- b.ctrlKey || b.metaKey ? b.key === "z" && !b.shiftKey ? (b.preventDefault(), o.undo()) : (b.key === "z" && b.shiftKey || b.key === "y") && (b.preventDefault(), o.redo()) : b.key === "Escape" && t("close");
3814
+ function m(_) {
3815
+ _.ctrlKey || _.metaKey ? _.key === "z" && !_.shiftKey ? (_.preventDefault(), a.undo()) : (_.key === "z" && _.shiftKey || _.key === "y") && (_.preventDefault(), a.redo()) : _.key === "Escape" && t("close");
3233
3816
  }
3234
- const v = H(!1);
3235
- async function w() {
3236
- if (!(!o.sourceImage.value || v.value)) {
3237
- v.value = !0;
3817
+ const d = H(!1);
3818
+ async function x() {
3819
+ if (!(!a.sourceImage.value || d.value)) {
3820
+ d.value = !0;
3238
3821
  try {
3239
- const $ = await new st().process(
3240
- o.sourceImage.value,
3241
- o.state,
3822
+ const $ = await new $t().process(
3823
+ a.sourceImage.value,
3824
+ a.state,
3242
3825
  {
3243
3826
  mimeType: n.options.outputMimeType || "image/jpeg",
3244
3827
  quality: n.options.outputQuality ?? 0.92,
@@ -3247,45 +3830,45 @@ const Ci = ["dir"], Mi = { class: "vie-main" }, Si = /* @__PURE__ */ Y({
3247
3830
  );
3248
3831
  t("process", $);
3249
3832
  } finally {
3250
- v.value = !1;
3833
+ d.value = !1;
3251
3834
  }
3252
3835
  }
3253
3836
  }
3254
- return (b, $) => (M(), z("div", {
3837
+ return (_, $) => (S(), z("div", {
3255
3838
  ref_key: "shellRef",
3256
- ref: h,
3257
- class: U([
3839
+ ref: v,
3840
+ class: N([
3258
3841
  "vie-editor",
3259
3842
  "vie-shell",
3260
- a.value ? "vie-shell--horizontal" : "",
3261
- s.options.theme === "dark" ? "vie-theme-dark" : ""
3843
+ l.value ? "vie-shell--horizontal" : "",
3844
+ o.options.theme === "dark" ? "vie-theme-dark" : ""
3262
3845
  ]),
3263
- dir: s.options.dir || "ltr",
3264
- onKeydown: y,
3846
+ dir: o.options.dir || "ltr",
3847
+ onKeydown: m,
3265
3848
  tabindex: "0"
3266
3849
  }, [
3267
- a.value ? (M(), z(X, { key: 0 }, [
3268
- j(ze),
3269
- g("div", Mi, [
3270
- j($e, {
3271
- onDone: w,
3272
- processing: v.value
3850
+ l.value ? (S(), z(Y, { key: 0 }, [
3851
+ X(He),
3852
+ y("div", _o, [
3853
+ X(Le, {
3854
+ onDone: x,
3855
+ processing: d.value
3273
3856
  }, null, 8, ["processing"]),
3274
- j(Re),
3275
- j(Ie)
3857
+ X(Ke),
3858
+ X(Ve)
3276
3859
  ])
3277
- ], 64)) : (M(), z(X, { key: 1 }, [
3278
- j($e, {
3279
- onDone: w,
3280
- processing: v.value
3860
+ ], 64)) : (S(), z(Y, { key: 1 }, [
3861
+ X(Le, {
3862
+ onDone: x,
3863
+ processing: d.value
3281
3864
  }, null, 8, ["processing"]),
3282
- j(Re),
3283
- j(Ie),
3284
- j(ze)
3865
+ X(Ke),
3866
+ X(Ve),
3867
+ X(He)
3285
3868
  ], 64))
3286
- ], 42, Ci));
3869
+ ], 42, xo));
3287
3870
  }
3288
- }), $i = { class: "vie-modal-container" }, Ri = /* @__PURE__ */ Y({
3871
+ }), Mo = { class: "vie-modal-container" }, So = /* @__PURE__ */ J({
3289
3872
  __name: "EditorModal",
3290
3873
  props: {
3291
3874
  src: {},
@@ -3299,8 +3882,8 @@ const Ci = ["dir"], Mi = { class: "vie-main" }, Si = /* @__PURE__ */ Y({
3299
3882
  initialState: {}
3300
3883
  },
3301
3884
  emits: ["process", "close"],
3302
- setup(s, { emit: e }) {
3303
- const n = s, t = e, o = H(null), d = V(() => ({
3885
+ setup(o, { emit: e }) {
3886
+ const n = o, t = e, a = H(null), h = j(() => ({
3304
3887
  src: n.src,
3305
3888
  plugins: n.plugins,
3306
3889
  locale: n.locale,
@@ -3311,48 +3894,48 @@ const Ci = ["dir"], Mi = { class: "vie-main" }, Si = /* @__PURE__ */ Y({
3311
3894
  maxCanvasPixels: n.maxCanvasPixels,
3312
3895
  initialState: n.initialState
3313
3896
  }));
3314
- function u() {
3897
+ function r() {
3315
3898
  t("close");
3316
3899
  }
3317
- function r() {
3318
- window.confirm("Close editor? Unsaved changes will be lost.") && u();
3900
+ function s() {
3901
+ window.confirm("Close editor? Unsaved changes will be lost.") && r();
3319
3902
  }
3320
- function i(a) {
3321
- const c = o.value;
3903
+ function i(l) {
3904
+ const c = a.value;
3322
3905
  if (!c) return;
3323
- const y = c.querySelectorAll(
3906
+ const m = c.querySelectorAll(
3324
3907
  'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
3325
3908
  );
3326
- if (y.length === 0) return;
3327
- const v = y[0], w = y[y.length - 1];
3328
- a.shiftKey ? document.activeElement === v && (a.preventDefault(), w.focus()) : document.activeElement === w && (a.preventDefault(), v.focus());
3329
- }
3330
- let h = "";
3331
- return ue(async () => {
3332
- var a, c;
3333
- h = document.body.style.overflow, document.body.style.overflow = "hidden", await Je(), (c = (a = o.value) == null ? void 0 : a.querySelector('[tabindex="0"]')) == null || c.focus();
3334
- }), re(() => {
3335
- document.body.style.overflow = h;
3336
- }), (a, c) => (M(), le(Ge, { to: "body" }, [
3337
- j(_e, { name: "vie-modal" }, {
3338
- default: J(() => [
3339
- g("div", {
3909
+ if (m.length === 0) return;
3910
+ const d = m[0], x = m[m.length - 1];
3911
+ l.shiftKey ? document.activeElement === d && (l.preventDefault(), x.focus()) : document.activeElement === x && (l.preventDefault(), d.focus());
3912
+ }
3913
+ let v = "";
3914
+ return ge(async () => {
3915
+ var l, c;
3916
+ v = document.body.style.overflow, document.body.style.overflow = "hidden", await Se(), (c = (l = a.value) == null ? void 0 : l.querySelector('[tabindex="0"]')) == null || c.focus();
3917
+ }), he(() => {
3918
+ document.body.style.overflow = v;
3919
+ }), (l, c) => (S(), pe(mt, { to: "body" }, [
3920
+ X(Te, { name: "vie-modal" }, {
3921
+ default: ne(() => [
3922
+ y("div", {
3340
3923
  class: "vie-modal-backdrop",
3341
3924
  role: "dialog",
3342
3925
  "aria-modal": "true",
3343
- onClick: ce(r, ["self"]),
3926
+ onClick: ve(s, ["self"]),
3344
3927
  onKeydown: [
3345
- Se(u, ["esc"]),
3346
- Se(i, ["tab"])
3928
+ Me(r, ["esc"]),
3929
+ Me(i, ["tab"])
3347
3930
  ],
3348
3931
  ref_key: "backdropRef",
3349
- ref: o
3932
+ ref: a
3350
3933
  }, [
3351
- g("div", $i, [
3352
- j(Si, {
3353
- options: d.value,
3354
- onProcess: c[0] || (c[0] = (y) => a.$emit("process", y)),
3355
- onClose: u
3934
+ y("div", Mo, [
3935
+ X(Co, {
3936
+ options: h.value,
3937
+ onProcess: c[0] || (c[0] = (m) => l.$emit("process", m)),
3938
+ onClose: r
3356
3939
  }, null, 8, ["options"])
3357
3940
  ])
3358
3941
  ], 544)
@@ -3362,11 +3945,11 @@ const Ci = ["dir"], Mi = { class: "vie-main" }, Si = /* @__PURE__ */ Y({
3362
3945
  ]));
3363
3946
  }
3364
3947
  });
3365
- function Pi(s) {
3366
- return JSON.stringify(s);
3948
+ function zo(o) {
3949
+ return JSON.stringify(o);
3367
3950
  }
3368
- function Ti(s) {
3369
- const e = JSON.parse(s);
3951
+ function Io(o) {
3952
+ const e = JSON.parse(o);
3370
3953
  if (typeof e != "object" || e === null || Array.isArray(e))
3371
3954
  throw new Error("Invalid state: expected an object");
3372
3955
  if (Array.isArray(e.stickers)) {
@@ -3378,64 +3961,66 @@ function Ti(s) {
3378
3961
  }
3379
3962
  return e;
3380
3963
  }
3381
- function Ei(s) {
3382
- const e = ge();
3964
+ function Po(o) {
3965
+ const e = $e();
3383
3966
  return {
3384
3967
  ...e,
3385
- ...s,
3386
- crop: { ...e.crop, ...s.crop || {} },
3387
- finetune: { ...e.finetune, ...s.finetune || {} },
3388
- filter: { ...e.filter, ...s.filter || {} },
3389
- frame: { ...e.frame, ...s.frame || {} },
3390
- resize: { ...e.resize, ...s.resize || {} },
3391
- stickers: s.stickers || e.stickers,
3392
- backgroundColor: s.backgroundColor || e.backgroundColor
3968
+ ...o,
3969
+ crop: { ...e.crop, ...o.crop || {} },
3970
+ finetune: { ...e.finetune, ...o.finetune || {} },
3971
+ filter: { ...e.filter, ...o.filter || {} },
3972
+ frame: { ...e.frame, ...o.frame || {} },
3973
+ resize: { ...e.resize, ...o.resize || {} },
3974
+ stickers: o.stickers || e.stickers,
3975
+ backgroundColor: o.backgroundColor || e.backgroundColor
3393
3976
  };
3394
3977
  }
3395
- function zi(s) {
3396
- s.component("ImageEditorModal", Ri);
3978
+ function $o(o) {
3979
+ o.component("ImageEditorModal", So);
3397
3980
  }
3398
- const Wi = { install: zi };
3981
+ const To = { install: $o };
3399
3982
  export {
3400
- _t as CanvasRenderer,
3401
- un as CropPlugin,
3402
- oi as FillPlugin,
3403
- xn as FilterPlugin,
3404
- fn as FinetunePlugin,
3405
- Gn as FramePlugin,
3406
- Qe as History,
3407
- xe as IDENTITY_MATRIX,
3408
- Ri as ImageEditorModal,
3409
- Si as ImageEditorShell,
3410
- st as ImageProcessor,
3411
- ee as LOCALE_KEY,
3412
- xi as ResizePlugin,
3413
- An as StickerPlugin,
3414
- ke as applyClarity,
3415
- Ce as applyColorMatrix,
3416
- ye as applyGamma,
3417
- we as applyVignette,
3418
- dt as ar,
3419
- Le as brightnessMatrix,
3420
- De as composeMatrices,
3421
- Ae as contrastMatrix,
3422
- ge as createDefaultImageState,
3423
- nt as createEditorEngine,
3424
- Wi as default,
3425
- fe as defaultStickerCategories,
3426
- Ti as deserializeState,
3427
- ut as en,
3428
- He as exposureMatrix,
3429
- pe as filterPresets,
3430
- dn as finetuneEffects,
3431
- Fn as frameStyles,
3432
- zi as install,
3433
- et as loadImage,
3434
- Ei as mergeWithDefaults,
3435
- ot as multiplyMatrices,
3436
- Fe as saturationMatrix,
3437
- Pi as serializeState,
3438
- Ve as temperatureMatrix,
3439
- G as useEditor
3983
+ bo as AnnotatePlugin,
3984
+ jt as CanvasRenderer,
3985
+ Pn as CropPlugin,
3986
+ Mi as FillPlugin,
3987
+ On as FilterPlugin,
3988
+ Fn as FinetunePlugin,
3989
+ wi as FramePlugin,
3990
+ gt as History,
3991
+ We as IDENTITY_MATRIX,
3992
+ So as ImageEditorModal,
3993
+ Co as ImageEditorShell,
3994
+ $t as ImageProcessor,
3995
+ oe as LOCALE_KEY,
3996
+ Oi as ResizePlugin,
3997
+ ai as StickerPlugin,
3998
+ bo as TextPlugin,
3999
+ Ie as applyClarity,
4000
+ Ae as applyColorMatrix,
4001
+ Re as applyGamma,
4002
+ ze as applyVignette,
4003
+ Tt as ar,
4004
+ Qe as brightnessMatrix,
4005
+ Ge as composeMatrices,
4006
+ et as contrastMatrix,
4007
+ $e as createDefaultImageState,
4008
+ kt as createEditorEngine,
4009
+ To as default,
4010
+ xe as defaultStickerCategories,
4011
+ Io as deserializeState,
4012
+ Pt as en,
4013
+ nt as exposureMatrix,
4014
+ be as filterPresets,
4015
+ Tn as finetuneEffects,
4016
+ si as frameStyles,
4017
+ $o as install,
4018
+ yt as loadImage,
4019
+ Po as mergeWithDefaults,
4020
+ Mt as multiplyMatrices,
4021
+ tt as saturationMatrix,
4022
+ zo as serializeState,
4023
+ it as temperatureMatrix,
4024
+ ee as useEditor
3440
4025
  };
3441
4026
  //# sourceMappingURL=vuedit-image-editor.es.js.map