@aivex/ui 1.2.0-dev.39 → 1.2.0-dev.40

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.
@@ -6,9 +6,9 @@ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
6
6
  import { memo as C, useCallback as w, useEffect as T, useId as E, useImperativeHandle as D, useLayoutEffect as O, useMemo as k, useReducer as A, useRef as j, useState as M } from "react";
7
7
  import N from "konva";
8
8
  import "pixi.js/unsafe-eval";
9
- import { Application as P, ColorMatrixFilter as ee, Container as F, Graphics as I, Polygon as te, Rectangle as ne, Sprite as re, Texture as ie } from "pixi.js";
9
+ import { Application as P, ColorMatrixFilter as F, Container as I, Graphics as L, Polygon as ee, Rectangle as te, Sprite as ne, Texture as re } from "pixi.js";
10
10
  //#region src/components/ShapeEditor/_model/geometry.ts
11
- var L = {
11
+ var R = {
12
12
  POINT: "POINT",
13
13
  RECTANGLE: "RECTANGLE",
14
14
  ROTATED_RECTANGLE: "ROTATED_RECTANGLE",
@@ -16,22 +16,22 @@ var L = {
16
16
  ELLIPSE: "ELLIPSE",
17
17
  LINE: "LINE"
18
18
  };
19
- function R(e) {
19
+ function z(e) {
20
20
  return e.interaction?.visible !== !1;
21
21
  }
22
- function ae(e) {
23
- return R(e) && e.interaction?.hitTestDisabled !== !0;
22
+ function ie(e) {
23
+ return z(e) && e.interaction?.hitTestDisabled !== !0;
24
24
  }
25
- function z(e) {
26
- return ae(e) && e.interaction?.selectable !== !1;
25
+ function B(e) {
26
+ return ie(e) && e.interaction?.selectable !== !1;
27
+ }
28
+ function ae(e) {
29
+ return B(e) && !e.readOnly && e.interaction?.editable !== !1;
27
30
  }
28
31
  function oe(e) {
29
- return z(e) && !e.readOnly && e.interaction?.editable !== !1;
32
+ return ae(e) && e.interaction?.draggable !== !1;
30
33
  }
31
34
  function se(e) {
32
- return oe(e) && e.interaction?.draggable !== !1;
33
- }
34
- function ce(e) {
35
35
  return e.map((e, t) => ({
36
36
  shape: e,
37
37
  index: t
@@ -40,13 +40,13 @@ function ce(e) {
40
40
  return n === r ? e.index - t.index : n - r;
41
41
  }).map((e) => e.shape);
42
42
  }
43
- function B(e, t, n) {
43
+ function V(e, t, n) {
44
44
  return Math.max(t, Math.min(n, e));
45
45
  }
46
- function le() {
46
+ function ce() {
47
47
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `id_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
48
48
  }
49
- var V = [
49
+ var H = [
50
50
  "tl",
51
51
  "t",
52
52
  "tr",
@@ -56,7 +56,7 @@ var V = [
56
56
  "bl",
57
57
  "l"
58
58
  ];
59
- function H(e) {
59
+ function U(e) {
60
60
  let t = e.map((e) => e.x), n = e.map((e) => e.y);
61
61
  return {
62
62
  minX: Math.min(...t),
@@ -65,33 +65,33 @@ function H(e) {
65
65
  maxY: Math.max(...n)
66
66
  };
67
67
  }
68
- function ue(e, t) {
68
+ function le(e, t) {
69
69
  let n = (t.minX + t.maxX) / 2, r = (t.minY + t.maxY) / 2;
70
70
  return {
71
71
  x: e.includes("l") ? t.minX : e.includes("r") ? t.maxX : n,
72
72
  y: e.includes("t") ? t.minY : e.includes("b") ? t.maxY : r
73
73
  };
74
74
  }
75
- function de(e, t, n, r) {
75
+ function ue(e, t, n, r) {
76
76
  let i = { ...t };
77
77
  return e.includes("l") && (i.minX = n), e.includes("r") && (i.maxX = n), e.includes("t") && (i.minY = r), e.includes("b") && (i.maxY = r), i;
78
78
  }
79
- function fe(e, t) {
79
+ function de(e, t) {
80
80
  let n = t.x - e.x, r = t.y - e.y, i = Math.max(Math.abs(n), Math.abs(r));
81
81
  return {
82
82
  x: e.x + (n < 0 ? -i : i),
83
83
  y: e.y + (r < 0 ? -i : i)
84
84
  };
85
85
  }
86
- function pe(e, t, n) {
86
+ function fe(e, t, n) {
87
87
  let r = Math.cos(n), i = Math.sin(n), a = e.x - t.x, o = e.y - t.y;
88
88
  return {
89
89
  x: t.x + a * r - o * i,
90
90
  y: t.y + a * i + o * r
91
91
  };
92
92
  }
93
- function me(e) {
94
- let t = H(e);
93
+ function pe(e) {
94
+ let t = U(e);
95
95
  return [
96
96
  {
97
97
  x: t.minX,
@@ -111,7 +111,7 @@ function me(e) {
111
111
  }
112
112
  ];
113
113
  }
114
- function he(e, t, n = 32) {
114
+ function me(e, t, n = 32) {
115
115
  let r = (e.x + t.x) / 2, i = (e.y + t.y) / 2, a = Math.abs(t.x - e.x) / 2, o = Math.abs(t.y - e.y) / 2;
116
116
  return Array.from({ length: n }, (e, t) => {
117
117
  let s = t / n * 2 * Math.PI;
@@ -121,7 +121,7 @@ function he(e, t, n = 32) {
121
121
  };
122
122
  });
123
123
  }
124
- function ge(e) {
124
+ function he(e) {
125
125
  let t = [...e].sort((e, t) => e.x - t.x || e.y - t.y);
126
126
  if (t.length <= 2) return t;
127
127
  let n = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), r = [];
@@ -137,10 +137,10 @@ function ge(e) {
137
137
  }
138
138
  return r.pop(), i.pop(), r.concat(i);
139
139
  }
140
- function _e(e) {
141
- let t = ge(e);
142
- if (t.length < 3) return me(e);
143
- let n = Infinity, r = me(e);
140
+ function ge(e) {
141
+ let t = he(e);
142
+ if (t.length < 3) return pe(e);
143
+ let n = Infinity, r = pe(e);
144
144
  for (let e = 0; e < t.length; e++) {
145
145
  let i = t[e], a = t[(e + 1) % t.length], o = Math.hypot(a.x - i.x, a.y - i.y) || 1, s = (a.x - i.x) / o, c = (a.y - i.y) / o, l = Infinity, u = -Infinity, d = Infinity, f = -Infinity;
146
146
  for (let e of t) {
@@ -164,19 +164,19 @@ function _e(e) {
164
164
  }
165
165
  return r;
166
166
  }
167
- var ve = (e, t) => ({
167
+ var _e = (e, t) => ({
168
168
  x: e.x - t.x,
169
169
  y: e.y - t.y
170
- }), ye = (e, t) => e.x * t.x + e.y * t.y, be = (e) => Math.hypot(e.x, e.y), xe = (e) => {
171
- let t = be(e) || 1;
170
+ }), ve = (e, t) => e.x * t.x + e.y * t.y, ye = (e) => Math.hypot(e.x, e.y), be = (e) => {
171
+ let t = ye(e) || 1;
172
172
  return {
173
173
  x: e.x / t,
174
174
  y: e.y / t
175
175
  };
176
- }, Se = (e, t) => ({
176
+ }, xe = (e, t) => ({
177
177
  x: (e.x + t.x) / 2,
178
178
  y: (e.y + t.y) / 2
179
- }), Ce = (e) => {
179
+ }), Se = (e) => {
180
180
  let t = e.reduce((e, t) => ({
181
181
  x: e.x + t.x,
182
182
  y: e.y + t.y
@@ -189,26 +189,26 @@ var ve = (e, t) => ({
189
189
  y: t.y / e.length
190
190
  };
191
191
  };
192
- function we(e) {
192
+ function Ce(e) {
193
193
  return [
194
194
  e[0],
195
- Se(e[0], e[1]),
195
+ xe(e[0], e[1]),
196
196
  e[1],
197
- Se(e[1], e[2]),
197
+ xe(e[1], e[2]),
198
198
  e[2],
199
- Se(e[2], e[3]),
199
+ xe(e[2], e[3]),
200
200
  e[3],
201
- Se(e[3], e[0])
201
+ xe(e[3], e[0])
202
202
  ];
203
203
  }
204
- function Te(e, t) {
205
- let n = Se(e[0], e[1]), r = xe(ve(e[0], e[3]));
204
+ function we(e, t) {
205
+ let n = xe(e[0], e[1]), r = be(_e(e[0], e[3]));
206
206
  return {
207
207
  x: n.x + r.x * t,
208
208
  y: n.y + r.y * t
209
209
  };
210
210
  }
211
- function U(e, t, n, r) {
211
+ function W(e, t, n, r) {
212
212
  let i = (e, i) => ({
213
213
  x: t.x + e * n.x + i * r.x,
214
214
  y: t.y + e * n.y + i * r.y
@@ -220,24 +220,24 @@ function U(e, t, n, r) {
220
220
  i(e.minX, e.maxY)
221
221
  ];
222
222
  }
223
- function Ee(e, t, n) {
223
+ function Te(e, t, n) {
224
224
  if (e.length < 4) return e;
225
- let r = e[0], i = xe(ve(e[1], e[0])), a = xe(ve(e[3], e[0])), o = ye(ve(e[1], r), i), s = ye(ve(e[3], r), a), c = ve(n, r);
226
- return U(de(t, {
225
+ let r = e[0], i = be(_e(e[1], e[0])), a = be(_e(e[3], e[0])), o = ve(_e(e[1], r), i), s = ve(_e(e[3], r), a), c = _e(n, r);
226
+ return W(ue(t, {
227
227
  minX: 0,
228
228
  minY: 0,
229
229
  maxX: o,
230
230
  maxY: s
231
- }, ye(c, i), ye(c, a)), r, i, a);
231
+ }, ve(c, i), ve(c, a)), r, i, a);
232
232
  }
233
- function De(e, t, n) {
233
+ function Ee(e, t, n) {
234
234
  let r = t.maxX - t.minX || 1, i = t.maxY - t.minY || 1, a = n.maxX - n.minX, o = n.maxY - n.minY;
235
235
  return e.map((e) => ({
236
236
  x: n.minX + (e.x - t.minX) / r * a,
237
237
  y: n.minY + (e.y - t.minY) / i * o
238
238
  }));
239
239
  }
240
- function Oe(e) {
240
+ function De(e) {
241
241
  let t = e.length, n = Array.from({ length: t }, (n, r) => {
242
242
  let i = e[r], a = e[(r + 1) % t];
243
243
  return {
@@ -255,7 +255,7 @@ function Oe(e) {
255
255
  if (i.minY > a.maxY || i.maxY < a.minY) continue;
256
256
  let s = Math.min(a.i, i.i), c = Math.max(a.i, i.i);
257
257
  if (c === s + 1 || s === 0 && c === t - 1) continue;
258
- let l = ke(e[s], e[(s + 1) % t], e[c], e[(c + 1) % t]);
258
+ let l = Oe(e[s], e[(s + 1) % t], e[c], e[(c + 1) % t]);
259
259
  l && r.push({
260
260
  i: s,
261
261
  j: c,
@@ -266,7 +266,7 @@ function Oe(e) {
266
266
  }
267
267
  return r;
268
268
  }
269
- function ke(e, t, n, r) {
269
+ function Oe(e, t, n, r) {
270
270
  let i = t.x - e.x, a = t.y - e.y, o = r.x - n.x, s = r.y - n.y, c = i * s - a * o;
271
271
  if (!c) return null;
272
272
  let l = ((n.x - e.x) * s - (n.y - e.y) * o) / c, u = ((n.x - e.x) * a - (n.y - e.y) * i) / c, d = 1e-9;
@@ -275,13 +275,13 @@ function ke(e, t, n, r) {
275
275
  tj: u
276
276
  };
277
277
  }
278
- var W = (e, t) => e.x >= t.minX && e.x <= t.maxX && e.y >= t.minY && e.y <= t.maxY, Ae = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), je = (e, t, n) => Ae(e, t, n) === 0 && Math.min(e.x, t.x) <= n.x && n.x <= Math.max(e.x, t.x) && Math.min(e.y, t.y) <= n.y && n.y <= Math.max(e.y, t.y);
279
- function Me(e, t, n, r) {
280
- let i = Ae(n, r, e), a = Ae(n, r, t), o = Ae(e, t, n), s = Ae(e, t, r);
281
- return (i > 0 && a < 0 || i < 0 && a > 0) && (o > 0 && s < 0 || o < 0 && s > 0) ? !0 : je(n, r, e) || je(n, r, t) || je(e, t, n) || je(e, t, r);
278
+ var G = (e, t) => e.x >= t.minX && e.x <= t.maxX && e.y >= t.minY && e.y <= t.maxY, ke = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), Ae = (e, t, n) => ke(e, t, n) === 0 && Math.min(e.x, t.x) <= n.x && n.x <= Math.max(e.x, t.x) && Math.min(e.y, t.y) <= n.y && n.y <= Math.max(e.y, t.y);
279
+ function je(e, t, n, r) {
280
+ let i = ke(n, r, e), a = ke(n, r, t), o = ke(e, t, n), s = ke(e, t, r);
281
+ return (i > 0 && a < 0 || i < 0 && a > 0) && (o > 0 && s < 0 || o < 0 && s > 0) ? !0 : Ae(n, r, e) || Ae(n, r, t) || Ae(e, t, n) || Ae(e, t, r);
282
282
  }
283
- function G(e, t, n) {
284
- if (W(e, n) || W(t, n)) return !0;
283
+ function Me(e, t, n) {
284
+ if (G(e, n) || G(t, n)) return !0;
285
285
  let r = {
286
286
  x: n.minX,
287
287
  y: n.minY
@@ -295,7 +295,7 @@ function G(e, t, n) {
295
295
  x: n.minX,
296
296
  y: n.maxY
297
297
  };
298
- return Me(e, t, r, i) || Me(e, t, i, a) || Me(e, t, a, o) || Me(e, t, o, r);
298
+ return je(e, t, r, i) || je(e, t, i, a) || je(e, t, a, o) || je(e, t, o, r);
299
299
  }
300
300
  function Ne(e, t) {
301
301
  let n = !1;
@@ -306,28 +306,28 @@ function Ne(e, t) {
306
306
  return n;
307
307
  }
308
308
  function Pe(e, t, n) {
309
- if (e.some((e) => W(e, t))) return !0;
309
+ if (e.some((e) => G(e, t))) return !0;
310
310
  let r = n ? e.length : e.length - 1;
311
- for (let n = 0; n < r; n += 1) if (G(e[n], e[(n + 1) % e.length], t)) return !0;
311
+ for (let n = 0; n < r; n += 1) if (Me(e[n], e[(n + 1) % e.length], t)) return !0;
312
312
  return !1;
313
313
  }
314
314
  function Fe(e, t) {
315
315
  let n = e.points;
316
316
  if (!n.length) return !1;
317
- let r = H(n);
317
+ let r = U(n);
318
318
  if (r.minX > t.maxX || r.maxX < t.minX || r.minY > t.maxY || r.maxY < t.minY) return !1;
319
319
  switch (e.type) {
320
- case L.POINT: return W(n[0], t);
321
- case L.RECTANGLE: return !0;
322
- case L.ELLIPSE: {
320
+ case R.POINT: return G(n[0], t);
321
+ case R.RECTANGLE: return !0;
322
+ case R.ELLIPSE: {
323
323
  let e = (r.maxX - r.minX) / 2, n = (r.maxY - r.minY) / 2;
324
324
  if (e <= 0 || n <= 0) return !0;
325
- let i = (r.minX + r.maxX) / 2, a = (r.minY + r.maxY) / 2, o = B(i, t.minX, t.maxX), s = B(a, t.minY, t.maxY);
325
+ let i = (r.minX + r.maxX) / 2, a = (r.minY + r.maxY) / 2, o = V(i, t.minX, t.maxX), s = V(a, t.minY, t.maxY);
326
326
  return ((o - i) / e) ** 2 + ((s - a) / n) ** 2 <= 1;
327
327
  }
328
- case L.LINE: return Pe(n, t, !1);
329
- case L.POLYGON:
330
- case L.ROTATED_RECTANGLE: return Pe(n, t, !0) || n.length >= 3 && Ne({
328
+ case R.LINE: return Pe(n, t, !1);
329
+ case R.POLYGON:
330
+ case R.ROTATED_RECTANGLE: return Pe(n, t, !0) || n.length >= 3 && Ne({
331
331
  x: t.minX,
332
332
  y: t.minY
333
333
  }, n);
@@ -365,7 +365,7 @@ function ze(e, t = 4096) {
365
365
  layers: 1
366
366
  }], r = e.length;
367
367
  if (r < 4 || r > t) return n;
368
- let i = Oe(e);
368
+ let i = De(e);
369
369
  if (!i.length) return n;
370
370
  let a = Array.from({ length: r }, () => []);
371
371
  for (let t of i) {
@@ -421,7 +421,7 @@ function ze(e, t = 4096) {
421
421
  for (let t of x) {
422
422
  let n = Re(v[t]);
423
423
  if (!n) continue;
424
- let r = v[t][0], i = v[t][1], a = 1e-9 * (Math.abs(r.x - i.x) + Math.abs(r.y - i.y) + 1), o = Math.abs(Le(Se(r, i), n, e, a));
424
+ let r = v[t][0], i = v[t][1], a = 1e-9 * (Math.abs(r.x - i.x) + Math.abs(r.y - i.y) + 1), o = Math.abs(Le(xe(r, i), n, e, a));
425
425
  o % 2 == 0 && C(v[t]) === 1 || w.push({
426
426
  outline: v[t],
427
427
  holes: [],
@@ -870,11 +870,11 @@ var J = C(function({ shape: e, strokeSize: t, register: n }) {
870
870
  strokeWidth: a.strokeWidth,
871
871
  strokeDasharray: a.dash?.join(" "),
872
872
  opacity: a.opacity,
873
- fill: a.fillVisible && r !== L.LINE ? a.color : "none",
873
+ fill: a.fillVisible && r !== R.LINE ? a.color : "none",
874
874
  fillOpacity: a.fillAlpha,
875
875
  vectorEffect: "non-scaling-stroke"
876
876
  };
877
- if (r === L.POINT) return /* @__PURE__ */ x("circle", {
877
+ if (r === R.POINT) return /* @__PURE__ */ x("circle", {
878
878
  ref: o,
879
879
  cx: i[0].x,
880
880
  cy: i[0].y,
@@ -882,9 +882,9 @@ var J = C(function({ shape: e, strokeSize: t, register: n }) {
882
882
  fill: a.color,
883
883
  opacity: a.opacity
884
884
  });
885
- if (r === L.RECTANGLE || r === L.ELLIPSE) {
886
- let e = H(i);
887
- return r === L.ELLIPSE ? /* @__PURE__ */ x("ellipse", {
885
+ if (r === R.RECTANGLE || r === R.ELLIPSE) {
886
+ let e = U(i);
887
+ return r === R.ELLIPSE ? /* @__PURE__ */ x("ellipse", {
888
888
  cx: (e.minX + e.maxX) / 2,
889
889
  cy: (e.minY + e.maxY) / 2,
890
890
  rx: (e.maxX - e.minX) / 2,
@@ -899,7 +899,7 @@ var J = C(function({ shape: e, strokeSize: t, register: n }) {
899
899
  });
900
900
  }
901
901
  let c = i.map((e) => `${e.x},${e.y}`).join(" ");
902
- return r === L.LINE ? /* @__PURE__ */ x("polyline", {
902
+ return r === R.LINE ? /* @__PURE__ */ x("polyline", {
903
903
  points: c,
904
904
  ...s
905
905
  }) : /* @__PURE__ */ x("polygon", {
@@ -1129,14 +1129,14 @@ var X = {
1129
1129
  "top-left": "aivex:top-2 aivex:left-2",
1130
1130
  "top-right": "aivex:top-2 aivex:right-2"
1131
1131
  }, ht = C(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r = !1, region: i, roiMaskId: s, shapes: d, view: p, viewDefaults: m, onChangeView: h, nav: g, registerShape: _, rectRef: y, zoomLabelRef: b, onZoom100: C, open: w, onToggleOpen: T, position: E = "bottom-left", showSettings: D = !0, settingsOpen: O, onToggleSettings: k, onCloseSettings: A, labels: j = K.minimap, settingsLabels: M, settingsItems: N }) {
1132
- let { offX: P, offY: ee, dispW: F, dispH: I, zoomCentered: te } = g, ne = E.startsWith("top"), re = {
1132
+ let { offX: P, offY: F, dispW: I, dispH: L, zoomCentered: ee } = g, te = E.startsWith("top"), ne = {
1133
1133
  position: "absolute",
1134
1134
  left: P,
1135
- top: ee,
1136
- width: F,
1137
- height: I
1138
- }, ie = /* @__PURE__ */ x("div", {
1139
- className: `aivex:overflow-hidden aivex:rounded-sm aivex:transition-all aivex:duration-200 aivex:ease-in-out ${w ? `${ne ? "aivex:mt-md" : "aivex:mb-md"} aivex:opacity-100` : "aivex:opacity-0"}`,
1135
+ top: F,
1136
+ width: I,
1137
+ height: L
1138
+ }, re = /* @__PURE__ */ x("div", {
1139
+ className: `aivex:overflow-hidden aivex:rounded-sm aivex:transition-all aivex:duration-200 aivex:ease-in-out ${w ? `${te ? "aivex:mt-md" : "aivex:mb-md"} aivex:opacity-100` : "aivex:opacity-0"}`,
1140
1140
  style: { maxHeight: w ? 204 : 0 },
1141
1141
  children: /* @__PURE__ */ x("div", {
1142
1142
  style: {
@@ -1163,35 +1163,35 @@ var X = {
1163
1163
  alt: "",
1164
1164
  crossOrigin: "anonymous",
1165
1165
  draggable: !1,
1166
- style: re
1166
+ style: ne
1167
1167
  }),
1168
1168
  p.showRegionMask && i && i.rects.length > 0 && /* @__PURE__ */ x(st, {
1169
1169
  image: e,
1170
1170
  region: i,
1171
1171
  maskId: s,
1172
- width: F,
1173
- height: I,
1172
+ width: I,
1173
+ height: L,
1174
1174
  strokeWidth: 1,
1175
1175
  strokeDasharray: "4 4",
1176
1176
  style: {
1177
1177
  position: "absolute",
1178
1178
  left: P,
1179
- top: ee,
1179
+ top: F,
1180
1180
  pointerEvents: "none"
1181
1181
  }
1182
1182
  }),
1183
1183
  /* @__PURE__ */ x("svg", {
1184
1184
  viewBox: `0 0 ${e.w} ${e.h}`,
1185
- width: F,
1186
- height: I,
1185
+ width: I,
1186
+ height: L,
1187
1187
  style: {
1188
1188
  position: "absolute",
1189
1189
  left: P,
1190
- top: ee,
1190
+ top: F,
1191
1191
  pointerEvents: "none"
1192
1192
  },
1193
1193
  "aria-hidden": !0,
1194
- children: ce(d).filter(R).map((e) => /* @__PURE__ */ x(J, {
1194
+ children: se(d).filter(z).map((e) => /* @__PURE__ */ x(J, {
1195
1195
  shape: e,
1196
1196
  strokeSize: p.strokeSize,
1197
1197
  register: _
@@ -1210,14 +1210,14 @@ var X = {
1210
1210
  ]
1211
1211
  })
1212
1212
  })
1213
- }), L = /* @__PURE__ */ S("div", {
1213
+ }), R = /* @__PURE__ */ S("div", {
1214
1214
  className: "aivex:relative aivex:flex aivex:items-center aivex:gap-xs",
1215
1215
  children: [
1216
1216
  /* @__PURE__ */ x(f, {
1217
1217
  variant: "ghost",
1218
1218
  size: "icon-md",
1219
1219
  "aria-label": j.zoomOut,
1220
- onClick: () => te(1 / 1.2),
1220
+ onClick: () => ee(1 / 1.2),
1221
1221
  disabled: r,
1222
1222
  children: /* @__PURE__ */ x(u, { size: 20 })
1223
1223
  }),
@@ -1237,7 +1237,7 @@ var X = {
1237
1237
  variant: "ghost",
1238
1238
  size: "icon-md",
1239
1239
  "aria-label": j.zoomIn,
1240
- onClick: () => te(1.2),
1240
+ onClick: () => ee(1.2),
1241
1241
  disabled: r,
1242
1242
  children: /* @__PURE__ */ x(a, { size: 20 })
1243
1243
  }),
@@ -1259,7 +1259,7 @@ var X = {
1259
1259
  onChange: h,
1260
1260
  labels: M,
1261
1261
  items: N,
1262
- openDown: ne,
1262
+ openDown: te,
1263
1263
  alignEnd: E.endsWith("right")
1264
1264
  })]
1265
1265
  }),
@@ -1271,14 +1271,14 @@ var X = {
1271
1271
  onClick: T,
1272
1272
  children: w ? /* @__PURE__ */ x(c, {
1273
1273
  size: 20,
1274
- className: ne ? "aivex:rotate-180" : void 0
1274
+ className: te ? "aivex:rotate-180" : void 0
1275
1275
  }) : /* @__PURE__ */ x(o, { size: 20 })
1276
1276
  })
1277
1277
  ]
1278
1278
  });
1279
1279
  return /* @__PURE__ */ S("div", {
1280
1280
  className: `aivex:absolute ${X[E]} aivex:w-[220px] aivex:rounded-[12px] aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:p-md aivex:shadow-[0_4px_12px_rgba(13,13,18,0.24)]`,
1281
- children: [ne ? L : ie, ne ? ie : L]
1281
+ children: [te ? R : re, te ? re : R]
1282
1282
  });
1283
1283
  }), gt = "var(--editor-overlay-inverse-scale, 1)", _t = 6, Z = {
1284
1284
  fontFamily: "Pretendard, sans-serif",
@@ -1290,7 +1290,7 @@ var X = {
1290
1290
  whiteSpace: "nowrap"
1291
1291
  };
1292
1292
  function vt(e) {
1293
- let t = H(e);
1293
+ let t = U(e);
1294
1294
  return {
1295
1295
  x: t.minX,
1296
1296
  y: t.minY,
@@ -1330,7 +1330,7 @@ function Ct({ color: e, striped: t }) {
1330
1330
  }
1331
1331
  function wt({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
1332
1332
  return /* @__PURE__ */ x(b, { children: e.map((e) => {
1333
- let a = vt(e.points), o = e.type === L.POINT, s = o ? void 0 : t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.style?.dashed || !!e.style?.dash, u = xt(e, e.points), d = r ? r(u) : St(u);
1333
+ let a = vt(e.points), o = e.type === R.POINT, s = o ? void 0 : t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.style?.dashed || !!e.style?.dash, u = xt(e, e.points), d = r ? r(u) : St(u);
1334
1334
  return /* @__PURE__ */ S("div", {
1335
1335
  ref: (t) => i(e.id, t),
1336
1336
  style: {
@@ -1375,7 +1375,7 @@ function wt({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
1375
1375
  }
1376
1376
  //#endregion
1377
1377
  //#region src/components/ShapeEditor/_model/clipboard.ts
1378
- var Tt = "AIVEX_SHAPE_EDITOR:", Et = 1, Dt = new Set(Object.values(L)), Ot = null, kt = "unavailable", At = 0;
1378
+ var Tt = "AIVEX_SHAPE_EDITOR:", Et = 1, Dt = new Set(Object.values(R)), Ot = null, kt = "unavailable", At = 0;
1379
1379
  function jt(e) {
1380
1380
  if (!e || typeof e != "object") return !1;
1381
1381
  let t = e;
@@ -1695,7 +1695,7 @@ function fn(e) {
1695
1695
  }
1696
1696
  function pn(e, t) {
1697
1697
  if (!t.length) return null;
1698
- if (e === L.POINT) {
1698
+ if (e === R.POINT) {
1699
1699
  let e = t[0];
1700
1700
  return {
1701
1701
  x: e.x - 8,
@@ -1704,7 +1704,7 @@ function pn(e, t) {
1704
1704
  height: 16
1705
1705
  };
1706
1706
  }
1707
- let n = H(t), r = Math.max(1, n.maxX - n.minX), i = Math.max(1, n.maxY - n.minY);
1707
+ let n = U(t), r = Math.max(1, n.maxX - n.minX), i = Math.max(1, n.maxY - n.minY);
1708
1708
  return {
1709
1709
  x: n.minX,
1710
1710
  y: n.minY,
@@ -1715,7 +1715,7 @@ function pn(e, t) {
1715
1715
  function mn(e) {
1716
1716
  if (!e.length) return null;
1717
1717
  let t = e.map((e) => pn(e.type, e.points)).filter((e) => e !== null);
1718
- return t.length ? fn(H(t.flatMap((e) => [{
1718
+ return t.length ? fn(U(t.flatMap((e) => [{
1719
1719
  x: e.x,
1720
1720
  y: e.y
1721
1721
  }, {
@@ -1756,10 +1756,10 @@ function _n(e, t, n, r = 300) {
1756
1756
  //#endregion
1757
1757
  //#region src/components/ShapeEditor/_state/createInteractionController.ts
1758
1758
  function vn(e) {
1759
- let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, docRef: a, selRef: o, draftRef: s, readOnlyRef: c, disableMarqueeRef: l, lockedRef: u, onLockedInteraction: d, onDrawAttemptWithoutDraft: f, createRef: p, selectRef: m, enterEditRef: h, editingIdRef: g, drawSessionRef: _, assistantRef: v, setCursorHint: y, setInteractionMode: b, syncMinimap: x, onTransformPreview: S, onDrawPreview: C } = e, w = () => _.current, T = () => v.current, E = null, D = null, O = null, k = null, A = null, j = null, M = !1, N = "", P = null, ee = null, F = (e) => e === q.RECTANGLE || e === q.ROTATED_RECTANGLE || e === q.CIRCLE, I = (e) => e === q.ASSISTANT_POLYGON || e === q.ASSISTANT_RECT, te = (e) => e === q.POLYGON, ne = (e) => F(e) || I(e) || te(e) || e === q.PATH || e === q.BRUSH || e === q.POINT, re = (e, t) => {
1759
+ let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, docRef: a, selRef: o, draftRef: s, readOnlyRef: c, disableMarqueeRef: l, lockedRef: u, onLockedInteraction: d, onDrawAttemptWithoutDraft: f, createRef: p, selectRef: m, enterEditRef: h, editingIdRef: g, drawSessionRef: _, assistantRef: v, setCursorHint: y, setInteractionMode: b, syncMinimap: x, onTransformPreview: S, onDrawPreview: C } = e, w = () => _.current, T = () => v.current, E = null, D = null, O = null, k = null, A = null, j = null, M = !1, N = "", P = null, F = null, I = null, L = (e) => e === q.RECTANGLE || e === q.ROTATED_RECTANGLE || e === q.CIRCLE, ee = (e) => e === q.ASSISTANT_POLYGON || e === q.ASSISTANT_RECT, te = (e) => e === q.POLYGON, ne = (e) => L(e) || ee(e) || te(e) || e === q.PATH || e === q.BRUSH || e === q.POINT, re = (e, t) => {
1760
1760
  let n = !1;
1761
- D && !F(t) && !I(t) && (D = null, e.clearPreview(), C(null), n = !0), (O === "path" && t !== q.PATH || O === "scalar" && t !== q.BRUSH) && (O = null, n = !0), k && !te(t) && (k = null, n = !0), A && t !== q.SELECT && (A = null, j = null, M = !1, e.clearMarquee(), n = !0), P && t !== q.POINT && (P = null, n = !0), n && b("idle");
1762
- }, ie = () => r.current.get(n.current), R = (e, t, n, r) => ({
1761
+ D && !L(t) && !ee(t) && (D = null, e.clearPreview(), C(null), n = !0), (O === "path" && t !== q.PATH || O === "scalar" && t !== q.BRUSH) && (O = null, n = !0), k && !te(t) && (k = null, n = !0), A && t !== q.SELECT && (A = null, j = null, M = !1, e.clearMarquee(), n = !0), P && t !== q.POINT && (P = null, n = !0), n && b("idle");
1762
+ }, z = () => r.current.get(n.current), ie = (e, t, n, r) => ({
1763
1763
  point: t,
1764
1764
  targetId: r,
1765
1765
  event: n,
@@ -1773,7 +1773,7 @@ function vn(e) {
1773
1773
  let p = t.current;
1774
1774
  if (!p) return;
1775
1775
  let _ = n.current;
1776
- if (P = null, re(p, _), l.button === 1 || i.current) {
1776
+ if (P = null, F = null, re(p, _), l.button === 1 || i.current) {
1777
1777
  b("panning"), y(null), E = {
1778
1778
  px: l.global.x,
1779
1779
  py: l.global.y
@@ -1783,22 +1783,22 @@ function vn(e) {
1783
1783
  if (l.button === 2 && !(_ === q.ASSISTANT_POINT && l.altKey)) {
1784
1784
  if (r && !o.current.includes(r)) {
1785
1785
  let e = a.current.getShapes().find((e) => e.id === r);
1786
- e && z(e) && m.current([r]);
1786
+ e && B(e) && m.current([r]);
1787
1787
  }
1788
1788
  return;
1789
1789
  }
1790
- let v = ie();
1790
+ let v = z();
1791
1791
  if (v) {
1792
- w().reset(), m.current([]), v.onPointerDown?.(R(p, e, l, r));
1792
+ w().reset(), m.current([]), v.onPointerDown?.(ie(p, e, l, r));
1793
1793
  return;
1794
1794
  }
1795
1795
  if (u.current && _ !== q.SELECT) {
1796
1796
  d();
1797
1797
  return;
1798
1798
  }
1799
- if (F(_) && r && o.current.includes(r) && !c.current) {
1799
+ if (L(_) && r && o.current.includes(r) && !c.current) {
1800
1800
  let t = a.current.getShapes().find((e) => e.id === r);
1801
- if (t && se(t)) {
1801
+ if (t && oe(t)) {
1802
1802
  p.beginMove(e, o.current);
1803
1803
  return;
1804
1804
  }
@@ -1811,7 +1811,7 @@ function vn(e) {
1811
1811
  l.altKey ? T().addPoint(e, l.button !== 2) : T().newPolygon(e);
1812
1812
  return;
1813
1813
  }
1814
- if (I(_) && s.current) {
1814
+ if (ee(_) && s.current) {
1815
1815
  D = e, b("drawing");
1816
1816
  return;
1817
1817
  }
@@ -1820,9 +1820,9 @@ function vn(e) {
1820
1820
  return;
1821
1821
  }
1822
1822
  if (_ === q.SELECT && l.altKey) {
1823
- let t = ce(a.current.getShapes()).filter((t) => {
1824
- if (!z(t)) return !1;
1825
- let n = H(t.points);
1823
+ let t = se(a.current.getShapes()).filter((t) => {
1824
+ if (!B(t)) return !1;
1825
+ let n = U(t.points);
1826
1826
  return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
1827
1827
  });
1828
1828
  if (t.length) {
@@ -1833,26 +1833,30 @@ function vn(e) {
1833
1833
  }
1834
1834
  if (r && _ === q.SELECT) {
1835
1835
  let t = a.current.getShapes().find((e) => e.id === r);
1836
- if (!t || !z(t)) return;
1837
- let n = typeof performance < "u" ? performance.now() : 0, i = !!ee && ee.id === r && n - ee.t < 300;
1838
- ee = {
1836
+ if (!t || !B(t)) return;
1837
+ let n = typeof performance < "u" ? performance.now() : 0, i = !!I && I.id === r && n - I.t < 300;
1838
+ I = {
1839
1839
  id: r,
1840
1840
  t: n
1841
1841
  };
1842
- let s = (t.type === L.POLYGON || t.type === L.LINE) && !c.current && t.interaction?.editable !== !1 && !t.readOnly;
1843
- if (i && s) {
1842
+ let s = (t.type === R.POLYGON || t.type === R.LINE) && t.interaction?.editable !== !1 && !t.readOnly;
1843
+ if (i && s && u.current) {
1844
+ m.current([r]), d();
1845
+ return;
1846
+ }
1847
+ if (i && s && !c.current) {
1844
1848
  m.current([r]), h.current(r);
1845
1849
  return;
1846
1850
  }
1847
- let u = o.current;
1851
+ let f = o.current;
1848
1852
  if (l.shiftKey) {
1849
- let e = new Set(u);
1850
- e.has(r) ? e.delete(r) : e.add(r), u = [...e];
1851
- } else u.includes(r) || (u = [r]);
1852
- m.current(u), !c.current && se(t) && p.beginMove(e, u);
1853
+ let e = new Set(f);
1854
+ e.has(r) ? e.delete(r) : e.add(r), f = [...e];
1855
+ } else f.includes(r) || (f = [r]);
1856
+ m.current(f), oe(t) && (u.current ? F = l.global : c.current || p.beginMove(e, f));
1853
1857
  return;
1854
1858
  }
1855
- if (F(_) && s.current) {
1859
+ if (L(_) && s.current) {
1856
1860
  D = e, b("drawing");
1857
1861
  return;
1858
1862
  }
@@ -1894,12 +1898,14 @@ function vn(e) {
1894
1898
  return;
1895
1899
  }
1896
1900
  if (_ === q.SELECT) {
1897
- if (j = null, M = !1, !l.shiftKey && !c.current && o.current.length >= 2) {
1898
- let t = a.current.getShapes().filter((e) => o.current.includes(e.id) && se(e));
1901
+ j = null, M = !1;
1902
+ let t = !c.current || u.current;
1903
+ if (!l.shiftKey && t && o.current.length >= 2) {
1904
+ let t = a.current.getShapes().filter((e) => o.current.includes(e.id) && oe(e));
1899
1905
  if (t.length) {
1900
- let n = H(t.flatMap((e) => e.points));
1906
+ let n = U(t.flatMap((e) => e.points));
1901
1907
  if (e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY) {
1902
- p.beginMove(e, o.current);
1908
+ u.current ? F = l.global : p.beginMove(e, o.current);
1903
1909
  return;
1904
1910
  }
1905
1911
  }
@@ -1910,7 +1916,11 @@ function vn(e) {
1910
1916
  onPointerMove: (e, r) => {
1911
1917
  let i = t.current;
1912
1918
  if (!i) return;
1913
- if (P && P.pointerId === r.pointerId && Math.hypot(r.global.x - P.global.x, r.global.y - P.global.y) > 4 && (P.cancelled = !0), E) {
1919
+ if (P && P.pointerId === r.pointerId && Math.hypot(r.global.x - P.global.x, r.global.y - P.global.y) > 4 && (P.cancelled = !0), F && Math.hypot(r.global.x - F.x, r.global.y - F.y) > 4) {
1920
+ F = null, d();
1921
+ return;
1922
+ }
1923
+ if (E) {
1914
1924
  i.applyViewport({
1915
1925
  scale: i.viewport.scale,
1916
1926
  x: i.viewport.x + (r.global.x - E.px),
@@ -1920,9 +1930,9 @@ function vn(e) {
1920
1930
  }
1921
1931
  let o = n.current;
1922
1932
  re(i, o);
1923
- let c = ie();
1933
+ let c = z();
1924
1934
  if (c) {
1925
- c.onPointerMove?.(R(i, e, r));
1935
+ c.onPointerMove?.(ie(i, e, r));
1926
1936
  return;
1927
1937
  }
1928
1938
  if (k) {
@@ -1930,13 +1940,13 @@ function vn(e) {
1930
1940
  k.moved = k.moved || Math.hypot(t, n) > .5, w().moveDraftPoints(k.base, k.indices, t, n);
1931
1941
  return;
1932
1942
  }
1933
- if (D && (F(o) || I(o))) {
1934
- let t = r.shiftKey ? fe(D, e) : e;
1943
+ if (D && (L(o) || ee(o))) {
1944
+ let t = r.shiftKey ? de(D, e) : e;
1935
1945
  i.previewBox(o === q.CIRCLE ? "ellipse" : "rect", D, t, {
1936
1946
  ...s.current,
1937
1947
  color: s.current?.color ?? "#00e5ff"
1938
- }), F(o) && C({
1939
- type: o === q.CIRCLE ? L.ELLIPSE : L.RECTANGLE,
1948
+ }), L(o) && C({
1949
+ type: o === q.CIRCLE ? R.ELLIPSE : R.RECTANGLE,
1940
1950
  points: [D, t]
1941
1951
  });
1942
1952
  return;
@@ -1970,7 +1980,7 @@ function vn(e) {
1970
1980
  let i = t.current;
1971
1981
  if (!i) return;
1972
1982
  let a = P;
1973
- if (P = null, E) {
1983
+ if (P = null, F = null, E) {
1974
1984
  E = null, b("idle");
1975
1985
  return;
1976
1986
  }
@@ -1979,14 +1989,14 @@ function vn(e) {
1979
1989
  w().commitDraftPointDrag(k.moved), k = null, b("idle");
1980
1990
  return;
1981
1991
  }
1982
- let l = ie();
1992
+ let l = z();
1983
1993
  if (l) {
1984
- l.onPointerUp?.(R(i, e, r));
1994
+ l.onPointerUp?.(ie(i, e, r));
1985
1995
  return;
1986
1996
  }
1987
1997
  let u = a ? Math.hypot(r.global.x - a.global.x, r.global.y - a.global.y) : Infinity;
1988
1998
  if (c === q.POINT && s.current && a && !a.cancelled && a.pointerId === r.pointerId && r.insideCanvas && u <= 4) {
1989
- p.current(L.POINT, [e]);
1999
+ p.current(R.POINT, [e]);
1990
2000
  return;
1991
2001
  }
1992
2002
  if (O) {
@@ -1994,10 +2004,10 @@ function vn(e) {
1994
2004
  O = null, b("idle"), e === "path" ? w().completeFreehandStroke() : w().finishScalarStroke();
1995
2005
  return;
1996
2006
  }
1997
- if (D && I(c)) {
2007
+ if (D && ee(c)) {
1998
2008
  let t = D;
1999
2009
  D = null, b("idle"), i.clearPreview();
2000
- let n = r.shiftKey ? fe(t, e) : e, a = {
2010
+ let n = r.shiftKey ? de(t, e) : e, a = {
2001
2011
  x: Math.min(t.x, n.x),
2002
2012
  y: Math.min(t.y, n.y),
2003
2013
  width: Math.abs(n.x - t.x),
@@ -2006,9 +2016,9 @@ function vn(e) {
2006
2016
  a.width > 2 && a.height > 2 && T().beginBox(a, c === q.ASSISTANT_RECT ? "rect" : "polygon");
2007
2017
  return;
2008
2018
  }
2009
- if (D && F(c)) {
2010
- let t = r.shiftKey ? fe(D, e) : e, n = D;
2011
- D = null, b("idle"), i.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (c === q.ROTATED_RECTANGLE ? p.current(L.ROTATED_RECTANGLE, me([n, t])) : c === q.CIRCLE ? p.current(L.POLYGON, he(n, t)) : p.current(L.RECTANGLE, [n, t]));
2019
+ if (D && L(c)) {
2020
+ let t = r.shiftKey ? de(D, e) : e, n = D;
2021
+ D = null, b("idle"), i.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (c === q.ROTATED_RECTANGLE ? p.current(R.ROTATED_RECTANGLE, pe([n, t])) : c === q.CIRCLE ? p.current(R.POLYGON, me(n, t)) : p.current(R.RECTANGLE, [n, t]));
2012
2022
  return;
2013
2023
  }
2014
2024
  if (A) {
@@ -2046,17 +2056,17 @@ function yn({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
2046
2056
  let a = i.current?.rectResult === "rotatedRect";
2047
2057
  return e.map((e) => {
2048
2058
  if (t === "rect" && a) return {
2049
- id: le(),
2050
- type: L.ROTATED_RECTANGLE,
2051
- points: _e(e),
2059
+ id: ce(),
2060
+ type: R.ROTATED_RECTANGLE,
2061
+ points: ge(e),
2052
2062
  style: r,
2053
2063
  meta: n
2054
2064
  };
2055
2065
  if (t === "rect") {
2056
- let t = H(e);
2066
+ let t = U(e);
2057
2067
  return {
2058
- id: le(),
2059
- type: L.RECTANGLE,
2068
+ id: ce(),
2069
+ type: R.RECTANGLE,
2060
2070
  points: [{
2061
2071
  x: t.minX,
2062
2072
  y: t.minY
@@ -2069,8 +2079,8 @@ function yn({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
2069
2079
  };
2070
2080
  }
2071
2081
  return {
2072
- id: le(),
2073
- type: L.POLYGON,
2082
+ id: ce(),
2083
+ type: R.POLYGON,
2074
2084
  points: e,
2075
2085
  style: r,
2076
2086
  meta: n
@@ -2323,13 +2333,13 @@ function jn(e, t) {
2323
2333
  }
2324
2334
  function Mn(e) {
2325
2335
  switch (e.type) {
2326
- case L.RECTANGLE: return e.points.length < 2 ? null : me(e.points);
2327
- case L.POLYGON:
2328
- case L.ROTATED_RECTANGLE:
2329
- case L.ELLIPSE: return e.points.length >= 3 ? e.points : null;
2330
- case L.POINT: {
2336
+ case R.RECTANGLE: return e.points.length < 2 ? null : pe(e.points);
2337
+ case R.POLYGON:
2338
+ case R.ROTATED_RECTANGLE:
2339
+ case R.ELLIPSE: return e.points.length >= 3 ? e.points : null;
2340
+ case R.POINT: {
2331
2341
  let t = e.points[0];
2332
- return t ? he({
2342
+ return t ? me({
2333
2343
  x: t.x - 6,
2334
2344
  y: t.y - 6
2335
2345
  }, {
@@ -2347,7 +2357,7 @@ function Pn(e, t, n = []) {
2347
2357
  if (t <= 0 || !e.length && !n.length) return null;
2348
2358
  let r = jn(e, n);
2349
2359
  if (!r.length) return null;
2350
- let i = t + 4, a = H(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1, Sn / Math.max(o, s, 1));
2360
+ let i = t + 4, a = U(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1, Sn / Math.max(o, s, 1));
2351
2361
  o = Math.max(1, Math.ceil(o * c)), s = Math.max(1, Math.ceil(s * c));
2352
2362
  let l = a.minX - i, u = a.minY - i, d = (e) => ({
2353
2363
  x: (e.x - l) * c,
@@ -2442,18 +2452,18 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2442
2452
  let _ = j(null), v = j([]), y = j(null), b = j(/* @__PURE__ */ new Set()), x = j([[]]), S = j(0), C = j(null), T = j([]), E = j([]), D = j([]), O = j([[]]), k = j(0), A = j("draw"), M = () => A.current === "erase" ? "erase" : "add", N = () => D.current.length > 0 || T.current.length > 0 || e.current === q.BRUSH && v.current.length > 0, P = () => {
2443
2453
  let t = e.current;
2444
2454
  return t === q.BRUSH && N() ? "brush" : t === q.POLYGON && v.current.length > 0 ? "polygon" : t === q.PATH && v.current.length > 0 ? "path" : "none";
2445
- }, ee = () => v.current.length > 0 || k.current > 0, F = () => v.current.length === 0 && k.current < O.current.length - 1, I = () => S.current > 0, te = () => S.current < x.current.length - 1, ne = () => {
2455
+ }, F = () => v.current.length > 0 || k.current > 0, I = () => v.current.length === 0 && k.current < O.current.length - 1, L = () => S.current > 0, ee = () => S.current < x.current.length - 1, te = () => {
2446
2456
  let t = e.current;
2447
- return t === q.BRUSH ? ee() : t === q.POLYGON || t === q.PATH ? I() : !1;
2448
- }, re = () => {
2457
+ return t === q.BRUSH ? F() : t === q.POLYGON || t === q.PATH ? L() : !1;
2458
+ }, ne = () => {
2449
2459
  let t = e.current;
2450
- return t === q.BRUSH ? F() : t === q.POLYGON || t === q.PATH ? te() : !1;
2451
- }, ie = () => P() !== "none", R = w(() => {
2460
+ return t === q.BRUSH ? I() : t === q.POLYGON || t === q.PATH ? ee() : !1;
2461
+ }, re = () => P() !== "none", z = w(() => {
2452
2462
  let e = P(), t = {
2453
2463
  active: e !== "none",
2454
2464
  kind: e,
2455
- canUndo: ne(),
2456
- canRedo: re(),
2465
+ canUndo: te(),
2466
+ canRedo: ne(),
2457
2467
  brush: e === "brush" ? {
2458
2468
  mode: A.current,
2459
2469
  editing: D.current.length > 0,
@@ -2461,9 +2471,9 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2461
2471
  } : void 0
2462
2472
  }, n = _.current;
2463
2473
  n && Hn(n, t) || (_.current = t, p.current?.(t));
2464
- }, []), ae = w(() => {
2474
+ }, []), ie = w(() => {
2465
2475
  O.current = [[]], k.current = 0;
2466
- }, []), z = w(() => {
2476
+ }, []), B = w(() => {
2467
2477
  let t = c.current;
2468
2478
  if (!t) return;
2469
2479
  let n = e.current;
@@ -2497,7 +2507,7 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2497
2507
  if (t.previewPoly(r, y.current, o, !1, s, l), n === q.POLYGON || n === q.PATH) {
2498
2508
  let e = m.current;
2499
2509
  e && r !== C.current && (C.current = r, e({
2500
- type: L.POLYGON,
2510
+ type: R.POLYGON,
2501
2511
  points: zn(r),
2502
2512
  meta: h.current
2503
2513
  }));
@@ -2507,82 +2517,82 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2507
2517
  i,
2508
2518
  c,
2509
2519
  e
2510
- ]), se = w((e) => {
2520
+ ]), oe = w((e) => {
2511
2521
  let t = Ln(e), n = O.current, r = k.current, i = n[r];
2512
- i && Rn(i, t) || (O.current = [...n.slice(0, r + 1), t], k.current += 1, R());
2513
- }, [R]), ce = w((e) => {
2522
+ i && Rn(i, t) || (O.current = [...n.slice(0, r + 1), t], k.current += 1, z());
2523
+ }, [z]), se = w((e) => {
2514
2524
  let t = x.current, n = S.current, r = t[n];
2515
2525
  r && Bn(r, e) || (x.current = [...t.slice(0, n + 1), zn(e)], S.current += 1);
2516
- }, []), B = w(() => {
2517
- v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), x.current = [[]], S.current = 0, C.current = null, ae(), c.current?.clearPreview(), m.current?.(null), R();
2526
+ }, []), V = w(() => {
2527
+ v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), x.current = [[]], S.current = 0, C.current = null, ie(), c.current?.clearPreview(), m.current?.(null), z();
2518
2528
  }, [
2519
2529
  c,
2520
- R,
2521
- ae
2522
- ]), V = w((e, t) => {
2523
- v.current = e, b.current = new Set(Array.from(b.current).filter((t) => t >= 0 && t < e.length)), t && ce(e), z(), R();
2530
+ z,
2531
+ ie
2532
+ ]), H = w((e, t) => {
2533
+ v.current = e, b.current = new Set(Array.from(b.current).filter((t) => t >= 0 && t < e.length)), t && se(e), B(), z();
2524
2534
  }, [
2525
- R,
2526
- ce,
2527
- z
2528
- ]), H = w(() => zn(v.current), []), ue = w(() => v.current.length > 0, []), de = w((t, n) => {
2535
+ z,
2536
+ se,
2537
+ B
2538
+ ]), U = w(() => zn(v.current), []), le = w(() => v.current.length > 0, []), ue = w((t, n) => {
2529
2539
  if (e.current !== q.POLYGON) return !1;
2530
2540
  let r = v.current;
2531
2541
  if (r.length < 3) return !1;
2532
2542
  let i = r[0];
2533
- return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (g.current(L.POLYGON, r), B(), !0);
2534
- }, [B, e]), fe = w((e) => {
2543
+ return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (g.current(R.POLYGON, r), V(), !0);
2544
+ }, [V, e]), de = w((e) => {
2535
2545
  let t = v.current;
2536
- return e < 0 || e >= t.length ? !1 : (V(t.filter((t, n) => n !== e), !0), !0);
2537
- }, [V]), pe = w((e, t) => {
2546
+ return e < 0 || e >= t.length ? !1 : (H(t.filter((t, n) => n !== e), !0), !0);
2547
+ }, [H]), fe = w((e, t) => {
2538
2548
  let n = v.current;
2539
2549
  if (e < 0 || e >= n.length) return null;
2540
2550
  let r = new Set(b.current);
2541
- return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), b.current = r, y.current = null, z(), R(), {
2551
+ return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), b.current = r, y.current = null, B(), z(), {
2542
2552
  base: zn(n),
2543
2553
  indices: Array.from(r)
2544
2554
  };
2545
- }, [R, z]), me = w((e) => {
2546
- b.current = /* @__PURE__ */ new Set(), y.current = e, V([...v.current, e], !0);
2547
- }, [V]), he = w((e) => {
2548
- y.current = null, b.current = /* @__PURE__ */ new Set(), v.current = [{ ...e }], z(), R();
2549
- }, [R, z]), ge = w((e, t) => {
2555
+ }, [z, B]), pe = w((e) => {
2556
+ b.current = /* @__PURE__ */ new Set(), y.current = e, H([...v.current, e], !0);
2557
+ }, [H]), me = w((e) => {
2558
+ y.current = null, b.current = /* @__PURE__ */ new Set(), v.current = [{ ...e }], B(), z();
2559
+ }, [z, B]), he = w((e, t) => {
2550
2560
  let n = v.current[v.current.length - 1];
2551
- return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (v.current = [...v.current, { ...e }], y.current = null, z(), R(), !0);
2552
- }, [R, z]), _e = w((e, t, n, r) => {
2561
+ return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (v.current = [...v.current, { ...e }], y.current = null, B(), z(), !0);
2562
+ }, [z, B]), ge = w((e, t, n, r) => {
2553
2563
  let i = new Set(t);
2554
2564
  v.current = e.map((e, t) => i.has(t) ? {
2555
2565
  x: e.x + n,
2556
2566
  y: e.y + r
2557
- } : { ...e }), y.current = null, z(), R();
2558
- }, [R, z]), ve = w((e) => {
2559
- e && (ce(v.current), z(), R());
2567
+ } : { ...e }), y.current = null, B(), z();
2568
+ }, [z, B]), _e = w((e) => {
2569
+ e && (se(v.current), B(), z());
2560
2570
  }, [
2561
- R,
2562
- ce,
2563
- z
2564
- ]), ye = w((e) => {
2565
- y.current = e ? { ...e } : null, z();
2566
- }, [z]), be = w(() => v.current.length > 0 ? (v.current = [], z(), R(), !0) : k.current <= 0 ? !1 : (--k.current, T.current = Ln(O.current[k.current]), z(), R(), !0), [R, z]), xe = w(() => v.current.length > 0 || k.current >= O.current.length - 1 ? !1 : (k.current += 1, T.current = Ln(O.current[k.current]), z(), R(), !0), [R, z]), Se = w(() => S.current <= 0 ? !1 : (--S.current, v.current = zn(x.current[S.current]), b.current = /* @__PURE__ */ new Set(), z(), R(), !0), [R, z]), Ce = w(() => S.current >= x.current.length - 1 ? !1 : (S.current += 1, v.current = zn(x.current[S.current]), b.current = /* @__PURE__ */ new Set(), z(), R(), !0), [R, z]), we = w(() => {
2571
+ z,
2572
+ se,
2573
+ B
2574
+ ]), ve = w((e) => {
2575
+ y.current = e ? { ...e } : null, B();
2576
+ }, [B]), ye = w(() => v.current.length > 0 ? (v.current = [], B(), z(), !0) : k.current <= 0 ? !1 : (--k.current, T.current = Ln(O.current[k.current]), B(), z(), !0), [z, B]), be = w(() => v.current.length > 0 || k.current >= O.current.length - 1 ? !1 : (k.current += 1, T.current = Ln(O.current[k.current]), B(), z(), !0), [z, B]), xe = w(() => S.current <= 0 ? !1 : (--S.current, v.current = zn(x.current[S.current]), b.current = /* @__PURE__ */ new Set(), B(), z(), !0), [z, B]), Se = w(() => S.current >= x.current.length - 1 ? !1 : (S.current += 1, v.current = zn(x.current[S.current]), b.current = /* @__PURE__ */ new Set(), B(), z(), !0), [z, B]), Ce = w(() => {
2567
2577
  let t = e.current;
2568
- return t === q.BRUSH ? be() : t === q.POLYGON || t === q.PATH ? Se() : !1;
2578
+ return t === q.BRUSH ? ye() : t === q.POLYGON || t === q.PATH ? xe() : !1;
2569
2579
  }, [
2570
2580
  e,
2571
- be,
2572
- Se
2573
- ]), Te = w(() => {
2581
+ ye,
2582
+ xe
2583
+ ]), we = w(() => {
2574
2584
  let t = e.current;
2575
- return t === q.BRUSH ? xe() : t === q.POLYGON || t === q.PATH ? Ce() : !1;
2585
+ return t === q.BRUSH ? be() : t === q.POLYGON || t === q.PATH ? Se() : !1;
2576
2586
  }, [
2577
- xe,
2578
- Ce,
2587
+ be,
2588
+ Se,
2579
2589
  e
2580
- ]), U = w(() => {
2590
+ ]), W = w(() => {
2581
2591
  let e = t.current;
2582
2592
  if (!e.length) return D.current.length > 0;
2583
- let r = n.current.getShapes().filter((t) => e.includes(t.id) && oe(t)), i = Nn(r);
2593
+ let r = n.current.getShapes().filter((t) => e.includes(t.id) && ae(t)), i = Nn(r);
2584
2594
  return i.length ? (D.current = r.map((e) => e.id), E.current = i, !0) : (D.current = [], E.current = [], !1);
2585
- }, [n, t]), Ee = w(() => {
2595
+ }, [n, t]), Te = w(() => {
2586
2596
  if (r.current) return !1;
2587
2597
  let e = [...T.current];
2588
2598
  v.current.length && e.push({
@@ -2592,11 +2602,11 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2592
2602
  let t = E.current, c = [...D.current];
2593
2603
  if (!e.length && !t.length) return !1;
2594
2604
  let l = Pn(e, a.current, t);
2595
- if (!l) return B(), !1;
2605
+ if (!l) return V(), !1;
2596
2606
  let u = Fn(l, o.current);
2597
2607
  if (c.length) {
2598
2608
  let e = n.current.getShapes().filter((e) => c.includes(e.id));
2599
- if (!u.length) return n.current.remove(c), B(), d([]), !0;
2609
+ if (!u.length) return n.current.remove(c), V(), d([]), !0;
2600
2610
  u.sort((e, t) => wn(t) - wn(e));
2601
2611
  let t = [], r = [], i = [];
2602
2612
  for (let n = 0; n < u.length; n++) {
@@ -2605,33 +2615,33 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2605
2615
  let r = e[n];
2606
2616
  t.push({
2607
2617
  ...r,
2608
- type: L.POLYGON,
2618
+ type: R.POLYGON,
2609
2619
  points: a
2610
2620
  }), i.push(r.id);
2611
2621
  } else {
2612
- let t = e[0], n = le();
2622
+ let t = e[0], n = ce();
2613
2623
  r.push({
2614
2624
  ...t,
2615
2625
  id: n,
2616
- type: L.POLYGON,
2626
+ type: R.POLYGON,
2617
2627
  points: a
2618
2628
  }), i.push(n);
2619
2629
  }
2620
2630
  }
2621
2631
  let a = e.slice(u.length).map((e) => e.id);
2622
- return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a), B(), d(i), !0;
2632
+ return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a), V(), d(i), !0;
2623
2633
  }
2624
- if (!u.length) return B(), !1;
2634
+ if (!u.length) return V(), !1;
2625
2635
  let f = i.current;
2626
2636
  if (!f) return !1;
2627
2637
  let p = u.map((e) => ({
2628
- id: le(),
2629
- type: L.POLYGON,
2638
+ id: ce(),
2639
+ type: R.POLYGON,
2630
2640
  points: e,
2631
2641
  style: f,
2632
2642
  meta: s
2633
2643
  }));
2634
- return n.current.create(p), d(p.map((e) => e.id)), B(), !0;
2644
+ return n.current.create(p), d(p.map((e) => e.id)), V(), !0;
2635
2645
  }, [
2636
2646
  a,
2637
2647
  d,
@@ -2639,43 +2649,43 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2639
2649
  s,
2640
2650
  i,
2641
2651
  r,
2642
- B
2643
- ]), De = w(() => {
2652
+ V
2653
+ ]), Ee = w(() => {
2644
2654
  let t = e.current;
2645
- if (t === q.BRUSH) return Ee();
2655
+ if (t === q.BRUSH) return Te();
2646
2656
  let n = v.current;
2647
- return t === q.POLYGON && n.length >= 3 ? (g.current(L.POLYGON, n), B(), !0) : !1;
2657
+ return t === q.POLYGON && n.length >= 3 ? (g.current(R.POLYGON, n), V(), !0) : !1;
2648
2658
  }, [
2649
- Ee,
2650
- B,
2659
+ Te,
2660
+ V,
2651
2661
  e
2652
- ]), Oe = w(() => {
2662
+ ]), De = w(() => {
2653
2663
  let t = v.current;
2654
2664
  if (e.current === q.PATH && t.length >= 3) {
2655
2665
  let e = xn(t, o.current);
2656
- e.length >= 3 && g.current(L.POLYGON, e);
2666
+ e.length >= 3 && g.current(R.POLYGON, e);
2657
2667
  }
2658
- B();
2659
- }, [B, e]), ke = w((e) => {
2660
- A.current = e, R(), z();
2661
- }, [R, z]), W = w(() => {
2668
+ V();
2669
+ }, [V, e]), Oe = w((e) => {
2670
+ A.current = e, z(), B();
2671
+ }, [z, B]), G = w(() => {
2662
2672
  if (r.current || e.current !== q.BRUSH) return !1;
2663
- T.current = [], v.current = [], ae();
2664
- let t = U();
2665
- return R(), z(), t;
2673
+ T.current = [], v.current = [], ie();
2674
+ let t = W();
2675
+ return z(), B(), t;
2666
2676
  }, [
2667
- R,
2668
- r,
2669
2677
  z,
2670
- ae,
2671
- U,
2678
+ r,
2679
+ B,
2680
+ ie,
2681
+ W,
2672
2682
  e
2673
- ]), Ae = w(() => {
2683
+ ]), ke = w(() => {
2674
2684
  let e = b.current;
2675
2685
  if (!e.size) return !1;
2676
2686
  let t = v.current.filter((t, n) => !e.has(n));
2677
- return b.current = /* @__PURE__ */ new Set(), V(t, !0), !0;
2678
- }, [V]), je = w((e) => {
2687
+ return b.current = /* @__PURE__ */ new Set(), H(t, !0), !0;
2688
+ }, [H]), Ae = w((e) => {
2679
2689
  let t = c.current, n = v.current;
2680
2690
  if (!t || !n.length) return -1;
2681
2691
  let r = Vn / (t.viewport.scale || 1);
@@ -2684,77 +2694,77 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2684
2694
  if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
2685
2695
  }
2686
2696
  return -1;
2687
- }, [c]), Me = w(() => {
2697
+ }, [c]), je = w(() => {
2688
2698
  v.current.length >= 1 && (T.current.push({
2689
2699
  points: zn(v.current),
2690
2700
  mode: M()
2691
- }), v.current = [], se(T.current)), z(), R();
2701
+ }), v.current = [], oe(T.current)), B(), z();
2692
2702
  }, [
2693
- R,
2694
- se,
2695
- z
2703
+ z,
2704
+ oe,
2705
+ B
2696
2706
  ]);
2697
2707
  return {
2698
- reset: B,
2699
- undoSession: we,
2700
- redoSession: Te,
2701
- canUndoSession: ne,
2702
- canRedoSession: re,
2703
- hasDraftSession: ie,
2704
- hasDraftPoints: ue,
2705
- commitDraftSession: De,
2706
- completeFreehandStroke: Oe,
2707
- setBrushScalarMode: ke,
2708
+ reset: V,
2709
+ undoSession: Ce,
2710
+ redoSession: we,
2711
+ canUndoSession: te,
2712
+ canRedoSession: ne,
2713
+ hasDraftSession: re,
2714
+ hasDraftPoints: le,
2715
+ commitDraftSession: Ee,
2716
+ completeFreehandStroke: De,
2717
+ setBrushScalarMode: Oe,
2708
2718
  getBrushScalarMode: () => A.current,
2709
2719
  hasBrushSession: N,
2710
- commitBrush: Ee,
2720
+ commitBrush: Te,
2711
2721
  cancelBrush: w(() => {
2712
- e.current === q.BRUSH && B();
2713
- }, [B, e]),
2714
- beginBrushEditFromSelection: W,
2715
- deleteDraftSelectedPoints: Ae,
2716
- hitDraftPoint: je,
2717
- getDraftPointsSnapshot: H,
2718
- tryClosePolygon: de,
2719
- removeDraftPoint: fe,
2720
- selectDraftPointForDrag: pe,
2721
- appendPolygonPoint: me,
2722
- beginStroke: he,
2723
- appendStrokePoint: ge,
2724
- moveDraftPoints: _e,
2725
- commitDraftPointDrag: ve,
2726
- setDraftCursor: ye,
2727
- finishScalarStroke: Me,
2722
+ e.current === q.BRUSH && V();
2723
+ }, [V, e]),
2724
+ beginBrushEditFromSelection: G,
2725
+ deleteDraftSelectedPoints: ke,
2726
+ hitDraftPoint: Ae,
2727
+ getDraftPointsSnapshot: U,
2728
+ tryClosePolygon: ue,
2729
+ removeDraftPoint: de,
2730
+ selectDraftPointForDrag: fe,
2731
+ appendPolygonPoint: pe,
2732
+ beginStroke: me,
2733
+ appendStrokePoint: he,
2734
+ moveDraftPoints: ge,
2735
+ commitDraftPointDrag: _e,
2736
+ setDraftCursor: ve,
2737
+ finishScalarStroke: je,
2728
2738
  handleToolChange: w((e, t) => {
2729
2739
  if (t) {
2730
- B(), A.current = "draw";
2740
+ V(), A.current = "draw";
2731
2741
  return;
2732
2742
  }
2733
2743
  if (e !== q.BRUSH) {
2734
- B(), A.current = "draw";
2744
+ V(), A.current = "draw";
2735
2745
  return;
2736
2746
  }
2737
- A.current = "draw", T.current = [], v.current = [], ae(), U(), R(), z();
2747
+ A.current = "draw", T.current = [], v.current = [], ie(), W(), z(), B();
2738
2748
  }, [
2739
- R,
2740
2749
  z,
2741
2750
  B,
2742
- ae,
2743
- U
2751
+ V,
2752
+ ie,
2753
+ W
2744
2754
  ]),
2745
2755
  handleBrushSelectionChange: w((t, n) => {
2746
2756
  if (!(e.current !== q.BRUSH || n)) {
2747
2757
  if (!t.length) {
2748
- R();
2758
+ z();
2749
2759
  return;
2750
2760
  }
2751
- [...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [], ae(), U(), R(), z()));
2761
+ [...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [], ie(), W(), z(), B()));
2752
2762
  }
2753
2763
  }, [
2754
- R,
2755
2764
  z,
2756
- ae,
2757
- U,
2765
+ B,
2766
+ ie,
2767
+ W,
2758
2768
  e
2759
2769
  ])
2760
2770
  };
@@ -2768,7 +2778,7 @@ function Wn(e, t) {
2768
2778
  future: []
2769
2779
  };
2770
2780
  }
2771
- function $(e, t) {
2781
+ function Gn(e, t) {
2772
2782
  switch (t.type) {
2773
2783
  case "CREATE": return Wn(e, [...e.shapes, ...t.shapes]);
2774
2784
  case "UPDATE": {
@@ -2805,15 +2815,15 @@ function $(e, t) {
2805
2815
  default: return e;
2806
2816
  }
2807
2817
  }
2808
- function Gn(e) {
2809
- let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = A($, {
2818
+ function Kn(e) {
2819
+ let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = A(Gn, {
2810
2820
  shapes: [],
2811
2821
  past: [],
2812
2822
  future: []
2813
2823
  }), o = j(i);
2814
2824
  o.current = i;
2815
2825
  let s = w((e) => {
2816
- o.current = $(o.current, e), a(e);
2826
+ o.current = Gn(o.current, e), a(e);
2817
2827
  }, []), c = w((e, i) => {
2818
2828
  let a = new Map(e.map((e) => [e.id, e])), o = new Map(i.map((e) => [e.id, e])), s = i.filter((e) => !a.has(e.id));
2819
2829
  s.length && t?.(s);
@@ -2882,7 +2892,7 @@ function Gn(e) {
2882
2892
  }
2883
2893
  //#endregion
2884
2894
  //#region src/components/ShapeEditor/_model/keymap.ts
2885
- var Kn = {
2895
+ var qn = {
2886
2896
  undo: ["mod+z"],
2887
2897
  redo: ["mod+shift+z"],
2888
2898
  selectAll: ["mod+a"],
@@ -2910,7 +2920,7 @@ var Kn = {
2910
2920
  pathTool: ["g"],
2911
2921
  brushTool: ["b"],
2912
2922
  pointTool: ["i"]
2913
- }, qn = {
2923
+ }, $ = {
2914
2924
  Equal: "=",
2915
2925
  Minus: "-",
2916
2926
  BracketLeft: "[",
@@ -2935,7 +2945,7 @@ function Yn(e) {
2935
2945
  let t = e.code, n = /^Key([A-Z])$/.exec(t);
2936
2946
  if (n) return n[1].toLowerCase();
2937
2947
  let r = /^Digit([0-9])$/.exec(t);
2938
- return r ? r[1] : qn[t] ? qn[t] : Jn[e.key] ? Jn[e.key] : null;
2948
+ return r ? r[1] : $[t] ? $[t] : Jn[e.key] ? Jn[e.key] : null;
2939
2949
  }
2940
2950
  function Xn(e) {
2941
2951
  let t = Yn(e);
@@ -2945,8 +2955,8 @@ function Xn(e) {
2945
2955
  }
2946
2956
  function Zn(e) {
2947
2957
  let t = /* @__PURE__ */ new Map();
2948
- for (let n of Object.keys(Kn)) {
2949
- let r = e?.[n], i = r === void 0 ? Kn[n] : r === null ? [] : Array.isArray(r) ? r : [r];
2958
+ for (let n of Object.keys(qn)) {
2959
+ let r = e?.[n], i = r === void 0 ? qn[n] : r === null ? [] : Array.isArray(r) ? r : [r];
2950
2960
  for (let e of i) t.set(e.toLowerCase(), n);
2951
2961
  }
2952
2962
  return t;
@@ -3173,14 +3183,14 @@ function fr(e, t) {
3173
3183
  //#endregion
3174
3184
  //#region src/components/ShapeEditor/_model/konva.ts
3175
3185
  function pr(e, t, n) {
3176
- if (t === L.POINT) {
3186
+ if (t === R.POINT) {
3177
3187
  e.setAttrs({
3178
3188
  x: n[0].x,
3179
3189
  y: n[0].y
3180
3190
  });
3181
3191
  return;
3182
3192
  }
3183
- if (t === L.RECTANGLE) {
3193
+ if (t === R.RECTANGLE) {
3184
3194
  let [t, r] = n;
3185
3195
  e.setAttrs({
3186
3196
  x: Math.min(t.x, r.x),
@@ -3190,8 +3200,8 @@ function pr(e, t, n) {
3190
3200
  });
3191
3201
  return;
3192
3202
  }
3193
- if (t === L.ELLIPSE) {
3194
- let t = H(n);
3203
+ if (t === R.ELLIPSE) {
3204
+ let t = U(n);
3195
3205
  e.setAttrs({
3196
3206
  x: (t.minX + t.maxX) / 2,
3197
3207
  y: (t.minY + t.maxY) / 2,
@@ -3216,15 +3226,15 @@ function _r(e) {
3216
3226
  //#region src/components/ShapeEditor/_renderers/transformSession.ts
3217
3227
  var vr = Math.PI / 12;
3218
3228
  function yr(e, t) {
3219
- return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === L.ROTATED_RECTANGLE;
3229
+ return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === R.ROTATED_RECTANGLE;
3220
3230
  }
3221
3231
  function br(e, t, n) {
3222
3232
  if (e.kind === "resize") {
3223
- let r = n ? e.box : de(e.anchor, e.box, t.x, t.y);
3233
+ let r = n ? e.box : ue(e.anchor, e.box, t.x, t.y);
3224
3234
  return {
3225
3235
  updates: e.shapes.map((i) => ({
3226
3236
  id: i.id,
3227
- points: n ? Ee(i.points, e.anchor, t) : De(i.points, e.box, r)
3237
+ points: n ? Te(i.points, e.anchor, t) : Ee(i.points, e.box, r)
3228
3238
  })),
3229
3239
  box: r
3230
3240
  };
@@ -3252,7 +3262,7 @@ function br(e, t, n) {
3252
3262
  return e.shiftKey && (n = Math.round(n / vr) * vr), {
3253
3263
  updates: [{
3254
3264
  id: e.id,
3255
- points: e.points.map((t) => pe(t, e.center, n))
3265
+ points: e.points.map((t) => fe(t, e.center, n))
3256
3266
  }],
3257
3267
  box: null
3258
3268
  };
@@ -3266,24 +3276,24 @@ function br(e, t, n) {
3266
3276
  id: e.id,
3267
3277
  points: a
3268
3278
  }],
3269
- box: H(a)
3279
+ box: U(a)
3270
3280
  };
3271
3281
  }
3272
3282
  function xr(e, t) {
3273
3283
  return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
3274
3284
  x: t.center.x + Math.cos(t.startAngle),
3275
3285
  y: t.center.y + Math.sin(t.startAngle)
3276
- } : yr(e, t) ? we(t.shapes[0].points)[V.indexOf(t.anchor)] : ue(t.anchor, t.box);
3286
+ } : yr(e, t) ? Ce(t.shapes[0].points)[H.indexOf(t.anchor)] : le(t.anchor, t.box);
3277
3287
  }
3278
3288
  function Sr(e, t, n) {
3279
- let r = e.filter((e) => t.includes(e.id) && se(e)).map((e) => ({
3289
+ let r = e.filter((e) => t.includes(e.id) && oe(e)).map((e) => ({
3280
3290
  id: e.id,
3281
3291
  points: e.points
3282
3292
  }));
3283
3293
  return r.length ? {
3284
3294
  kind: "move",
3285
3295
  start: n,
3286
- box: H(r.flatMap((e) => e.points)),
3296
+ box: U(r.flatMap((e) => e.points)),
3287
3297
  shapes: r
3288
3298
  } : null;
3289
3299
  }
@@ -3295,10 +3305,10 @@ function Cr(e) {
3295
3305
  }
3296
3306
  function wr(e, t) {
3297
3307
  let n = new Set(t);
3298
- return e.filter((e) => n.has(e.id) && oe(e));
3308
+ return e.filter((e) => n.has(e.id) && ae(e));
3299
3309
  }
3300
3310
  function Tr(e, t) {
3301
- return e.filter((e) => z(e) && Fe(e, t)).map((e) => e.id);
3311
+ return e.filter((e) => B(e) && Fe(e, t)).map((e) => e.id);
3302
3312
  }
3303
3313
  function Er(e, t, n) {
3304
3314
  return (e ? at(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
@@ -3312,9 +3322,9 @@ function Dr(e, t) {
3312
3322
  };
3313
3323
  }
3314
3324
  function Or(e, t, n) {
3315
- if (e.type === L.ROTATED_RECTANGLE) return t;
3316
- let r = e.type === L.POINT ? Dr(t[0], n) : H(t);
3317
- return me([{
3325
+ if (e.type === R.ROTATED_RECTANGLE) return t;
3326
+ let r = e.type === R.POINT ? Dr(t[0], n) : U(t);
3327
+ return pe([{
3318
3328
  x: r.minX,
3319
3329
  y: r.minY
3320
3330
  }, {
@@ -3426,7 +3436,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3426
3436
  for (let e of this.stage.container().querySelectorAll("canvas")) e.style.cursor = this.baseCursor;
3427
3437
  }
3428
3438
  bindShapeCursor(e, t) {
3429
- if (!se(t)) return this.bindCursor(e, "default");
3439
+ if (!oe(t)) return this.bindCursor(e, "default");
3430
3440
  this.bindCursor(e, () => this.selected.includes(t.id) ? "grab" : Wt);
3431
3441
  }
3432
3442
  bindCursor(e, t) {
@@ -3600,9 +3610,9 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3600
3610
  setShapes(e, t) {
3601
3611
  if (this.shapes = Cr(e), this.selected = t, !this.activeDrag) {
3602
3612
  this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
3603
- for (let t of ce(e).filter(R)) {
3613
+ for (let t of se(e).filter(z)) {
3604
3614
  let e = this.makeNode(t), n = at(t, { strokeWidth: this.strokeSize });
3605
- if (t.style?.alternateColor && n.dash?.length && t.type !== L.POINT) {
3615
+ if (t.style?.alternateColor && n.dash?.length && t.type !== R.POINT) {
3606
3616
  let n = e.clone({
3607
3617
  id: `${t.id}__alt`,
3608
3618
  stroke: t.style.alternateColor,
@@ -3632,7 +3642,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3632
3642
  t.size === this.selectedVertices.size && [...t].every((e) => this.selectedVertices.has(e)) || (this.selectedVertices = t, this.activeDrag || (this.drawTransformer(), this.layer.batchDraw()));
3633
3643
  }
3634
3644
  makeNode(e) {
3635
- let { type: t, points: n } = e, r = at(e, { strokeWidth: this.strokeSize }), i = z(e), a = {
3645
+ let { type: t, points: n } = e, r = at(e, { strokeWidth: this.strokeSize }), i = B(e), a = {
3636
3646
  id: e.id,
3637
3647
  stroke: r.color,
3638
3648
  strokeWidth: r.strokeWidth,
@@ -3641,7 +3651,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3641
3651
  strokeScaleEnabled: !1,
3642
3652
  listening: i
3643
3653
  }, o = r.fillVisible ? ot(r.color, r.fillAlpha) : void 0;
3644
- if (t === L.POINT) {
3654
+ if (t === R.POINT) {
3645
3655
  let t = 1 / (this.world.scaleX() || 1), a = new N.Path({
3646
3656
  id: e.id,
3647
3657
  data: mr,
@@ -3664,8 +3674,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3664
3674
  });
3665
3675
  return this.bindShapeCursor(a, e), a;
3666
3676
  }
3667
- if (t === L.RECTANGLE) {
3668
- let t = H(n), r = new N.Rect({
3677
+ if (t === R.RECTANGLE) {
3678
+ let t = U(n), r = new N.Rect({
3669
3679
  x: t.minX,
3670
3680
  y: t.minY,
3671
3681
  width: t.maxX - t.minX,
@@ -3675,8 +3685,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3675
3685
  });
3676
3686
  return this.bindShapeCursor(r, e), r;
3677
3687
  }
3678
- if (t === L.ELLIPSE) {
3679
- let t = H(n), r = new N.Ellipse({
3688
+ if (t === R.ELLIPSE) {
3689
+ let t = U(n), r = new N.Ellipse({
3680
3690
  x: (t.minX + t.maxX) / 2,
3681
3691
  y: (t.minY + t.maxY) / 2,
3682
3692
  radiusX: (t.maxX - t.minX) / 2,
@@ -3686,7 +3696,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3686
3696
  });
3687
3697
  return this.bindShapeCursor(r, e), r;
3688
3698
  }
3689
- let s = n.flatMap((e) => [e.x, e.y]), c = t !== L.LINE, l = new N.Line({
3699
+ let s = n.flatMap((e) => [e.x, e.y]), c = t !== R.LINE, l = new N.Line({
3690
3700
  points: s,
3691
3701
  closed: c,
3692
3702
  fill: c ? o : void 0,
@@ -3701,7 +3711,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3701
3711
  if (n && r) {
3702
3712
  pr(n, r.type, t);
3703
3713
  let i = this.altNodes.get(e);
3704
- i && pr(i, r.type, t), r.type === L.POINT && n instanceof N.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
3714
+ i && pr(i, r.type, t), r.type === R.POINT && n instanceof N.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
3705
3715
  }
3706
3716
  }
3707
3717
  pointRadius(e) {
@@ -3714,7 +3724,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3714
3724
  let e = 1 / (this.world.scaleX() || 1);
3715
3725
  for (let t of this.shapes) {
3716
3726
  let n = this.nodes.get(t.id);
3717
- if (t.type === L.POINT) {
3727
+ if (t.type === R.POINT) {
3718
3728
  n?.scale({
3719
3729
  x: e,
3720
3730
  y: e
@@ -3728,7 +3738,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3728
3738
  return Tr(this.shapes, e);
3729
3739
  }
3730
3740
  drawSelectionBorders() {
3731
- let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && z(t)) : [];
3741
+ let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && B(t)) : [];
3732
3742
  if (this.selectionBorders.length !== t.length) {
3733
3743
  for (let e of this.selectionBorders) e.destroy();
3734
3744
  this.selectionBorders = t.map(() => {
@@ -3749,7 +3759,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3749
3759
  updateSelectionBordersLive(e) {
3750
3760
  let t = new Set(this.selected), n = 0;
3751
3761
  for (let r of this.shapes) {
3752
- if (!t.has(r.id) || !z(r)) continue;
3762
+ if (!t.has(r.id) || !B(r)) continue;
3753
3763
  let i = this.selectionOutlinePoints(r, e(r)), a = this.selectionBorders[n++];
3754
3764
  a && a.points(i.flatMap((e) => [e.x, e.y]));
3755
3765
  }
@@ -3862,7 +3872,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3862
3872
  }
3863
3873
  setTransformerOutline(e) {
3864
3874
  let t = Math.max(0, e.maxX - e.minX), n = Math.max(0, e.maxY - e.minY);
3865
- !t && !n || this.setTransformerOutlinePoints(me([{
3875
+ !t && !n || this.setTransformerOutlinePoints(pe([{
3866
3876
  x: e.minX,
3867
3877
  y: e.minY
3868
3878
  }, {
@@ -3883,10 +3893,10 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3883
3893
  return kr(this.viewport.scale);
3884
3894
  }
3885
3895
  rotationHandleScreenPoint(e) {
3886
- return this.imgToScreen(Te(e, this.rotationHandleGap()));
3896
+ return this.imgToScreen(we(e, this.rotationHandleGap()));
3887
3897
  }
3888
3898
  setRotationConnector(e) {
3889
- let t = this.imgToScreen(Se(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
3899
+ let t = this.imgToScreen(xe(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
3890
3900
  this.rotLineNode ? this.rotLineNode.points([
3891
3901
  t.x,
3892
3902
  t.y,
@@ -3918,7 +3928,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3918
3928
  }
3919
3929
  repositionOrientedHandles(e) {
3920
3930
  let t = this.orientedHandleAngle(e);
3921
- if (we(e).forEach((e, n) => {
3931
+ if (Ce(e).forEach((e, n) => {
3922
3932
  let r = this.imgToScreen(e), i = this.handleNodes[n];
3923
3933
  i && this.layoutResizeHandle(i, r, t);
3924
3934
  }), this.setTransformerOutlinePoints(e), this.rotNode) {
@@ -3937,12 +3947,12 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3937
3947
  for (let e of this.midNodes) e.destroy();
3938
3948
  if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
3939
3949
  let e = wr(this.shapes, this.selected);
3940
- if (!e.length || e.length === 1 && e[0].type === L.POINT) return;
3941
- let t = e.length === 1 && (e[0].type === L.POLYGON || e[0].type === L.LINE) && this.editingId === e[0].id ? e[0] : null, n = H(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === L.ROTATED_RECTANGLE ? e[0] : null, i = r ? we(r.points) : V.map((e) => ue(e, n));
3950
+ if (!e.length || e.length === 1 && e[0].type === R.POINT) return;
3951
+ let t = e.length === 1 && (e[0].type === R.POLYGON || e[0].type === R.LINE) && this.editingId === e[0].id ? e[0] : null, n = U(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === R.ROTATED_RECTANGLE ? e[0] : null, i = r ? Ce(r.points) : H.map((e) => le(e, n));
3942
3952
  r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
3943
3953
  let a = r ? this.orientedHandleAngle(r.points) : 0;
3944
- for (let e of t ? [] : V) {
3945
- let t = this.imgToScreen(i[V.indexOf(e)]), n = new N.Rect({
3954
+ for (let e of t ? [] : H) {
3955
+ let t = this.imgToScreen(i[H.indexOf(e)]), n = new N.Rect({
3946
3956
  x: t.x,
3947
3957
  y: t.y,
3948
3958
  width: 8,
@@ -3960,7 +3970,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3960
3970
  this.activeDrag = {
3961
3971
  kind: "resize",
3962
3972
  anchor: e,
3963
- box: H(n.flatMap((e) => e.points)),
3973
+ box: U(n.flatMap((e) => e.points)),
3964
3974
  shapes: n.map((e) => ({
3965
3975
  id: e.id,
3966
3976
  points: e.points
@@ -3969,7 +3979,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
3969
3979
  }), this.handleGroup.add(n), this.handleNodes.push(n);
3970
3980
  }
3971
3981
  if (t) {
3972
- let e = t, n = e.points, r = e.type === L.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new N.Circle({
3982
+ let e = t, n = e.points, r = e.type === R.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new N.Circle({
3973
3983
  radius: i * .8,
3974
3984
  fill: "#ffffff",
3975
3985
  opacity: .6,
@@ -4053,8 +4063,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
4053
4063
  }), this.handleGroup.add(s), this.vertexNodes.push(s);
4054
4064
  });
4055
4065
  }
4056
- if (e.length === 1 && e[0].type === L.ROTATED_RECTANGLE) {
4057
- let t = e[0], n = Ce(t.points), r = this.rotationHandleScreenPoint(t.points), i = new N.Circle({
4066
+ if (e.length === 1 && e[0].type === R.ROTATED_RECTANGLE) {
4067
+ let t = e[0], n = Se(t.points), r = this.rotationHandleScreenPoint(t.points), i = new N.Circle({
4058
4068
  x: r.x,
4059
4069
  y: r.y,
4060
4070
  radius: 6,
@@ -4079,11 +4089,11 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
4079
4089
  }
4080
4090
  beginMove(e, t) {
4081
4091
  let n = Sr(this.shapes, t, e);
4082
- n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === L.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
4092
+ n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === R.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
4083
4093
  }
4084
4094
  repositionHandles(e) {
4085
- V.forEach((t, n) => {
4086
- let r = this.imgToScreen(ue(t, e)), i = this.handleNodes[n];
4095
+ H.forEach((t, n) => {
4096
+ let r = this.imgToScreen(le(t, e)), i = this.handleNodes[n];
4087
4097
  i && this.layoutResizeHandle(i, r, 0);
4088
4098
  }), this.setTransformerOutline(e);
4089
4099
  }
@@ -4124,16 +4134,16 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
4124
4134
  for (let e of r) this.liveUpdateShape(e.id, e.points);
4125
4135
  if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
4126
4136
  n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
4127
- let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === L.POLYGON || e?.type === L.LINE;
4128
- (t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
4137
+ let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === R.POLYGON || e?.type === R.LINE;
4138
+ (t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === R.POLYGON);
4129
4139
  } else if (t.kind === "rotate") {
4130
4140
  this.repositionOrientedHandles(r[0].points);
4131
4141
  let e = this.shapes.find((e) => e.id === t.id);
4132
- e && (e.type === L.POLYGON || e.type === L.LINE) && this.repositionPolygonHandles(r[0].points, e.type === L.POLYGON);
4142
+ e && (e.type === R.POLYGON || e.type === R.LINE) && this.repositionPolygonHandles(r[0].points, e.type === R.POLYGON);
4133
4143
  } else {
4134
4144
  i && this.repositionHandles(i);
4135
4145
  let e = this.shapes.find((e) => e.id === t.id);
4136
- this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
4146
+ this.repositionPolygonHandles(r[0].points, e?.type === R.POLYGON);
4137
4147
  }
4138
4148
  this.layer.batchDraw();
4139
4149
  }
@@ -4168,7 +4178,7 @@ function Rr(e) {
4168
4178
  }
4169
4179
  var zr = class {
4170
4180
  constructor(e, t) {
4171
- this.app = new P(), this.world = new F(), this.bgLayer = new F(), this.overlayLayer = new F(), this.regionOverlayLayer = new F(), this.dimOverlayLayer = new F(), this.shapeLayer = new F(), this.selLayer = new F(), this.previewLayer = new F(), this.handleLayer = new F(), this.filter = new ee(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.tileSize = ur, this.region = null, this.regionDimMaskG = new I(), this.regionDimG = new I(), this.regionZoneMaskG = new I(), this.regionZoneG = new I(), this.regionOutlineG = new I(), this.baseCursor = "default", this.strokeSize = Fr, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.brightness = 1, this.contrast = 1, this.imageSmoothing = !0, this.destroyed = !1, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastDragImg = null, this.activeDrag = null, this.midNodes = [], this.ghostNode = null, this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorderGfx = [], this.previewG = new I(), this.marqueeG = new I(), this.previewMaskSprite = null, this.previewMaskTexture = null, this.previewReady = !1, this.lastPreview = null, this.host = e, this.cb = t;
4181
+ this.app = new P(), this.world = new I(), this.bgLayer = new I(), this.overlayLayer = new I(), this.regionOverlayLayer = new I(), this.dimOverlayLayer = new I(), this.shapeLayer = new I(), this.selLayer = new I(), this.previewLayer = new I(), this.handleLayer = new I(), this.filter = new F(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.tileSize = ur, this.region = null, this.regionDimMaskG = new L(), this.regionDimG = new L(), this.regionZoneMaskG = new L(), this.regionZoneG = new L(), this.regionOutlineG = new L(), this.baseCursor = "default", this.strokeSize = Fr, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.brightness = 1, this.contrast = 1, this.imageSmoothing = !0, this.destroyed = !1, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastDragImg = null, this.activeDrag = null, this.midNodes = [], this.ghostNode = null, this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorderGfx = [], this.previewG = new L(), this.marqueeG = new L(), this.previewMaskSprite = null, this.previewMaskTexture = null, this.previewReady = !1, this.lastPreview = null, this.host = e, this.cb = t;
4172
4182
  }
4173
4183
  ev(e) {
4174
4184
  return {
@@ -4229,7 +4239,7 @@ var zr = class {
4229
4239
  }
4230
4240
  syncHitArea() {
4231
4241
  let { w: e, h: t } = this.screenSize;
4232
- this.app.stage.hitArea = new ne(0, 0, e, t);
4242
+ this.app.stage.hitArea = new te(0, 0, e, t);
4233
4243
  }
4234
4244
  destroy() {
4235
4245
  this.destroyed = !0, this.clearImageTiles(), this.app.renderer && this.app.destroy(!0, { children: !0 });
@@ -4282,9 +4292,9 @@ var zr = class {
4282
4292
  let a = n?.width ?? this.imageWidth, o = n?.height ?? this.imageHeight;
4283
4293
  this.bgLayer.scale.set(a / i.naturalWidth, o / i.naturalHeight), this.clearImageTiles();
4284
4294
  for (let e of dr(i.naturalWidth, i.naturalHeight, this.tileSize)) {
4285
- let t = ie.from(fr(i, e));
4295
+ let t = re.from(fr(i, e));
4286
4296
  t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
4287
- let n = new re(t);
4297
+ let n = new ne(t);
4288
4298
  n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
4289
4299
  }
4290
4300
  return this.applySpriteFilter(), !0;
@@ -4328,7 +4338,7 @@ var zr = class {
4328
4338
  for (let e of this.dimOverlayLayer.removeChildren()) e.destroy();
4329
4339
  if (t && this.imageWidth) {
4330
4340
  let e = nn(this.host);
4331
- this.dimOverlayLayer.addChild(new I().rect(0, 0, this.imageWidth, this.imageHeight).fill({
4341
+ this.dimOverlayLayer.addChild(new L().rect(0, 0, this.imageWidth, this.imageHeight).fill({
4332
4342
  color: Rr(e.color),
4333
4343
  alpha: e.opacity
4334
4344
  }));
@@ -4432,9 +4442,9 @@ var zr = class {
4432
4442
  this.shapeLayer.removeChildren();
4433
4443
  for (let e of this.nodes.values()) e.destroy();
4434
4444
  this.nodes.clear();
4435
- for (let e of ce(this.shapes).filter(R)) {
4436
- let t = new I();
4437
- this.paintShape(t, e), t.eventMode = z(e) ? "static" : "none", t.cursor = void 0, z(e) && se(e) && (t.on("pointerover", () => {
4445
+ for (let e of se(this.shapes).filter(z)) {
4446
+ let t = new L();
4447
+ this.paintShape(t, e), t.eventMode = B(e) ? "static" : "none", t.cursor = void 0, B(e) && oe(e) && (t.on("pointerover", () => {
4438
4448
  this.activeDrag || !this.transformEnabled || this.emitCursorHint(this.selected.includes(e.id) ? "grab" : Wt);
4439
4449
  }), t.on("pointerout", () => {
4440
4450
  this.activeDrag || this.emitCursorHint(null);
@@ -4446,14 +4456,14 @@ var zr = class {
4446
4456
  paintShape(e, t) {
4447
4457
  e.clear();
4448
4458
  let n = at(t, { strokeWidth: this.strokeSize }), r = Rr(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
4449
- if (t.type === L.POINT) {
4459
+ if (t.type === R.POINT) {
4450
4460
  e.svg(_r(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
4451
4461
  let r = 1 / (this.world.scale.x || 1);
4452
4462
  e.scale.set(r, r), e.alpha = a;
4453
4463
  return;
4454
4464
  }
4455
- if (n.fillVisible && t.type !== L.LINE) {
4456
- let i = t.type === L.POLYGON ? ze(t.points) : null;
4465
+ if (n.fillVisible && t.type !== R.LINE) {
4466
+ let i = t.type === R.POLYGON ? ze(t.points) : null;
4457
4467
  if (i && (i.length > 1 || i[0].holes.length > 0)) for (let t of i) for (let i = 0; i < Math.min(t.layers, 4); i++) {
4458
4468
  e.poly(t.outline.flatMap((e) => [e.x, e.y]), !0), e.fill({
4459
4469
  color: r,
@@ -4465,7 +4475,7 @@ var zr = class {
4465
4475
  color: r,
4466
4476
  alpha: n.fillAlpha * a
4467
4477
  });
4468
- } else t.type !== L.LINE && (this.path(e, t), e.fill({
4478
+ } else t.type !== R.LINE && (this.path(e, t), e.fill({
4469
4479
  color: r,
4470
4480
  alpha: 0
4471
4481
  }));
@@ -4495,7 +4505,7 @@ var zr = class {
4495
4505
  }
4496
4506
  shapesAt(e) {
4497
4507
  return this.shapes.filter((t) => {
4498
- let n = H(t.points);
4508
+ let n = U(t.points);
4499
4509
  return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
4500
4510
  }).map((e) => e.id);
4501
4511
  }
@@ -4522,7 +4532,7 @@ var zr = class {
4522
4532
  }, this.ensurePreview(), this.previewG.clear();
4523
4533
  let i = {
4524
4534
  id: "__preview__",
4525
- type: e === "ellipse" ? L.ELLIPSE : L.RECTANGLE,
4535
+ type: e === "ellipse" ? R.ELLIPSE : R.RECTANGLE,
4526
4536
  points: [t, n],
4527
4537
  style: r
4528
4538
  }, a = this.strokeW(i);
@@ -4553,7 +4563,7 @@ var zr = class {
4553
4563
  }, this.ensurePreview(), this.previewG.clear(), !e.length) return;
4554
4564
  let o = t ? [...e, t] : e, s = {
4555
4565
  id: "__preview__",
4556
- type: r ? L.POLYGON : L.LINE,
4566
+ type: r ? R.POLYGON : R.LINE,
4557
4567
  points: o,
4558
4568
  style: n
4559
4569
  }, c = this.strokeW(s);
@@ -4579,7 +4589,7 @@ var zr = class {
4579
4589
  previewScalarMask(e, t) {
4580
4590
  this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
4581
4591
  let n = In(e, t.length === 7 ? `${t}99` : t);
4582
- this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture = ie.from(n), this.previewMaskSprite ? (this.previewMaskSprite.texture = this.previewMaskTexture, this.previewMaskSprite.visible = !0) : (this.previewMaskSprite = new re(this.previewMaskTexture), this.previewLayer.addChildAt(this.previewMaskSprite, 0)), this.previewMaskSprite.x = e.ox, this.previewMaskSprite.y = e.oy, this.previewMaskSprite.width = n.width / e.scale, this.previewMaskSprite.height = n.height / e.scale;
4592
+ this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture = re.from(n), this.previewMaskSprite ? (this.previewMaskSprite.texture = this.previewMaskTexture, this.previewMaskSprite.visible = !0) : (this.previewMaskSprite = new ne(this.previewMaskTexture), this.previewLayer.addChildAt(this.previewMaskSprite, 0)), this.previewMaskSprite.x = e.ox, this.previewMaskSprite.y = e.oy, this.previewMaskSprite.width = n.width / e.scale, this.previewMaskSprite.height = n.height / e.scale;
4583
4593
  }
4584
4594
  previewMarquee(e, t) {
4585
4595
  this.ensurePreview(), this.marqueeG.clear();
@@ -4624,27 +4634,27 @@ var zr = class {
4624
4634
  }
4625
4635
  path(e, t) {
4626
4636
  let { type: n, points: r } = t;
4627
- if (n === L.POINT) {
4637
+ if (n === R.POINT) {
4628
4638
  e.circle(r[0].x, r[0].y, this.pointRadius(t));
4629
4639
  return;
4630
4640
  }
4631
- if (n === L.RECTANGLE) {
4632
- let t = H(r);
4641
+ if (n === R.RECTANGLE) {
4642
+ let t = U(r);
4633
4643
  e.rect(t.minX, t.minY, t.maxX - t.minX, t.maxY - t.minY);
4634
4644
  return;
4635
4645
  }
4636
- if (n === L.ELLIPSE) {
4637
- let t = H(r);
4646
+ if (n === R.ELLIPSE) {
4647
+ let t = U(r);
4638
4648
  e.ellipse((t.minX + t.maxX) / 2, (t.minY + t.maxY) / 2, (t.maxX - t.minX) / 2, (t.maxY - t.minY) / 2);
4639
4649
  return;
4640
4650
  }
4641
4651
  let i = r.flatMap((e) => [e.x, e.y]);
4642
- e.poly(i, n !== L.LINE);
4652
+ e.poly(i, n !== R.LINE);
4643
4653
  }
4644
4654
  dashedStrokeShape(e, t, n, r, i, a) {
4645
4655
  let { type: o, points: s } = t;
4646
- if (o === L.RECTANGLE) {
4647
- let t = H(s);
4656
+ if (o === R.RECTANGLE) {
4657
+ let t = U(s);
4648
4658
  this.strokeDashedPolyline(e, [
4649
4659
  {
4650
4660
  x: t.minX,
@@ -4665,8 +4675,8 @@ var zr = class {
4665
4675
  ], !0, n, r, i, a);
4666
4676
  return;
4667
4677
  }
4668
- if (o === L.ELLIPSE) {
4669
- let t = H(s), o = (t.minX + t.maxX) / 2, c = (t.minY + t.maxY) / 2, l = (t.maxX - t.minX) / 2, u = (t.maxY - t.minY) / 2, d = Array.from({ length: 96 }, (e, t) => {
4678
+ if (o === R.ELLIPSE) {
4679
+ let t = U(s), o = (t.minX + t.maxX) / 2, c = (t.minY + t.maxY) / 2, l = (t.maxX - t.minX) / 2, u = (t.maxY - t.minY) / 2, d = Array.from({ length: 96 }, (e, t) => {
4670
4680
  let n = t / 96 * Math.PI * 2;
4671
4681
  return {
4672
4682
  x: o + Math.cos(n) * l,
@@ -4676,7 +4686,7 @@ var zr = class {
4676
4686
  this.strokeDashedPolyline(e, d, !0, n, r, i, a);
4677
4687
  return;
4678
4688
  }
4679
- this.strokeDashedPolyline(e, s, o !== L.LINE, n, r, i, a);
4689
+ this.strokeDashedPolyline(e, s, o !== R.LINE, n, r, i, a);
4680
4690
  }
4681
4691
  strokeDashedPolyline(e, t, n, r, i, a, o) {
4682
4692
  if (t.length < 2) return;
@@ -4717,11 +4727,11 @@ var zr = class {
4717
4727
  }
4718
4728
  drawSelectionBorders() {
4719
4729
  this.selLayer.position.set(0, 0);
4720
- let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && z(t)) : [];
4730
+ let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && B(t)) : [];
4721
4731
  if (this.selectionBorderGfx.length !== t.length) {
4722
4732
  for (let e of this.selectionBorderGfx) e.destroy();
4723
4733
  this.selectionBorderGfx = t.map(() => {
4724
- let e = new I();
4734
+ let e = new L();
4725
4735
  return this.selLayer.addChild(e), e;
4726
4736
  });
4727
4737
  }
@@ -4737,7 +4747,7 @@ var zr = class {
4737
4747
  updateSelectionBordersLive(e) {
4738
4748
  let t = new Set(this.selected), n = 1.5 / this.world.scale.x, r = 0;
4739
4749
  for (let i of this.shapes) {
4740
- if (!t.has(i.id) || !z(i)) continue;
4750
+ if (!t.has(i.id) || !B(i)) continue;
4741
4751
  let a = this.selectionBorderGfx[r++];
4742
4752
  a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
4743
4753
  width: n,
@@ -4760,7 +4770,7 @@ var zr = class {
4760
4770
  }
4761
4771
  setTransformerOutline(e) {
4762
4772
  let t = e.maxX - e.minX, n = e.maxY - e.minY;
4763
- t <= 0 && n <= 0 || this.setTransformerOutlinePoints(me([{
4773
+ t <= 0 && n <= 0 || this.setTransformerOutlinePoints(pe([{
4764
4774
  x: e.minX,
4765
4775
  y: e.minY
4766
4776
  }, {
@@ -4769,7 +4779,7 @@ var zr = class {
4769
4779
  }]));
4770
4780
  }
4771
4781
  setTransformerOutlinePoints(e) {
4772
- e.length < 2 || (this.transformerOutline || (this.transformerOutline = new I(), this.selLayer.addChild(this.transformerOutline)), this.transformerOutline.clear(), this.transformerOutline.poly(e.flatMap((e) => [e.x, e.y]), !0).stroke({
4782
+ e.length < 2 || (this.transformerOutline || (this.transformerOutline = new L(), this.selLayer.addChild(this.transformerOutline)), this.transformerOutline.clear(), this.transformerOutline.poly(e.flatMap((e) => [e.x, e.y]), !0).stroke({
4773
4783
  width: 1 / this.world.scale.x,
4774
4784
  color: 2001125
4775
4785
  }));
@@ -4778,11 +4788,11 @@ var zr = class {
4778
4788
  return kr(this.viewport.scale);
4779
4789
  }
4780
4790
  rotationHandleScreenPoint(e) {
4781
- return this.imgToScreen(Te(e, this.rotationHandleGap()));
4791
+ return this.imgToScreen(we(e, this.rotationHandleGap()));
4782
4792
  }
4783
4793
  setRotationConnector(e) {
4784
- let t = this.imgToScreen(Se(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
4785
- this.rotLineNode || (this.rotLineNode = new I(), this.rotLineNode.eventMode = "none", this.handleLayer.addChild(this.rotLineNode)), this.rotLineNode.clear(), this.rotLineNode.moveTo(t.x, t.y).lineTo(n.x, n.y).stroke({
4794
+ let t = this.imgToScreen(xe(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
4795
+ this.rotLineNode || (this.rotLineNode = new L(), this.rotLineNode.eventMode = "none", this.handleLayer.addChild(this.rotLineNode)), this.rotLineNode.clear(), this.rotLineNode.moveTo(t.x, t.y).lineTo(n.x, n.y).stroke({
4786
4796
  width: 1,
4787
4797
  color: 2001125
4788
4798
  });
@@ -4800,12 +4810,12 @@ var zr = class {
4800
4810
  for (let e of this.midNodes) e.destroy();
4801
4811
  if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
4802
4812
  let e = wr(this.shapes, this.selected);
4803
- if (e.length === 0 || e.length === 1 && e[0].type === L.POINT) return;
4804
- let t = e.length === 1 && (e[0].type === L.POLYGON || e[0].type === L.LINE) && this.editingId === e[0].id ? e[0] : null, n = H(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === L.ROTATED_RECTANGLE ? e[0] : null, i = r ? we(r.points) : V.map((e) => ue(e, n));
4813
+ if (e.length === 0 || e.length === 1 && e[0].type === R.POINT) return;
4814
+ let t = e.length === 1 && (e[0].type === R.POLYGON || e[0].type === R.LINE) && this.editingId === e[0].id ? e[0] : null, n = U(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === R.ROTATED_RECTANGLE ? e[0] : null, i = r ? Ce(r.points) : H.map((e) => le(e, n));
4805
4815
  r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
4806
4816
  let a = r ? this.orientedHandleAngle(r.points) : 0;
4807
- for (let e of t ? [] : V) {
4808
- let t = this.imgToScreen(i[V.indexOf(e)]), n = new I();
4817
+ for (let e of t ? [] : H) {
4818
+ let t = this.imgToScreen(i[H.indexOf(e)]), n = new L();
4809
4819
  n.rect(-4, -4, 8, 8).fill({ color: 16777215 }).stroke({
4810
4820
  width: 1,
4811
4821
  color: 2001125
@@ -4817,7 +4827,7 @@ var zr = class {
4817
4827
  this.activeDrag = {
4818
4828
  kind: "resize",
4819
4829
  anchor: e,
4820
- box: H(n.flatMap((e) => e.points)),
4830
+ box: U(n.flatMap((e) => e.points)),
4821
4831
  shapes: n.map((e) => ({
4822
4832
  id: e.id,
4823
4833
  points: e.points
@@ -4826,7 +4836,7 @@ var zr = class {
4826
4836
  }), this.handleLayer.addChild(n), this.handleNodes.push(n);
4827
4837
  }
4828
4838
  if (t) {
4829
- let e = t, n = e.points, r = e.type === L.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new I();
4839
+ let e = t, n = e.points, r = e.type === R.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new L();
4830
4840
  a.circle(0, 0, i * .8).fill({
4831
4841
  color: 16777215,
4832
4842
  alpha: .6
@@ -4835,7 +4845,7 @@ var zr = class {
4835
4845
  color: 2001125
4836
4846
  }), a.visible = !1, a.eventMode = "none", this.handleLayer.addChild(a), this.ghostNode = a;
4837
4847
  for (let t = 0; t < r; t++) {
4838
- let r = n[t], i = n[(t + 1) % n.length], o = new I();
4848
+ let r = n[t], i = n[(t + 1) % n.length], o = new L();
4839
4849
  o.hitArea = this.edgeHitQuad(r, i), o.eventMode = "static", this.bindCursor(o, "copy");
4840
4850
  let s = (e) => {
4841
4851
  let t = this.toImage(e), n = i.x - r.x, a = i.y - r.y, o = n * n + a * a, s = o ? Math.max(0, Math.min(1, ((t.x - r.x) * n + (t.y - r.y) * a) / o)) : 0;
@@ -4870,7 +4880,7 @@ var zr = class {
4870
4880
  }), this.handleLayer.addChild(o), this.midNodes.push(o);
4871
4881
  }
4872
4882
  this.vertexPolygonId !== e.id && (this.vertexPolygonId = e.id, this.selectedVertices.clear()), n.forEach((t, r) => {
4873
- let a = this.imgToScreen(t), o = this.selectedVertices.has(r), s = new I();
4883
+ let a = this.imgToScreen(t), o = this.selectedVertices.has(r), s = new L();
4874
4884
  s.circle(0, 0, i).fill({ color: o ? 2001125 : 16777215 }).stroke({
4875
4885
  width: Math.max(1.5, i * .3),
4876
4886
  color: o ? 16777215 : 2001125
@@ -4890,8 +4900,8 @@ var zr = class {
4890
4900
  }), this.handleLayer.addChild(s), this.vertexNodes.push(s);
4891
4901
  });
4892
4902
  }
4893
- if (e.length === 1 && e[0].type === L.ROTATED_RECTANGLE) {
4894
- let t = e[0], n = Ce(t.points), r = this.rotationHandleScreenPoint(t.points), i = new I();
4903
+ if (e.length === 1 && e[0].type === R.ROTATED_RECTANGLE) {
4904
+ let t = e[0], n = Se(t.points), r = this.rotationHandleScreenPoint(t.points), i = new L();
4895
4905
  i.circle(0, 0, 6).fill({ color: 16777215 }).stroke({
4896
4906
  width: 1.5,
4897
4907
  color: 2001125
@@ -4911,17 +4921,17 @@ var zr = class {
4911
4921
  }
4912
4922
  beginMove(e, t) {
4913
4923
  let n = Sr(this.shapes, t, e);
4914
- n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === L.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
4924
+ n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === R.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
4915
4925
  }
4916
4926
  repositionHandlesForBox(e) {
4917
- V.forEach((t, n) => {
4918
- let r = this.imgToScreen(ue(t, e)), i = this.handleNodes[n];
4927
+ H.forEach((t, n) => {
4928
+ let r = this.imgToScreen(le(t, e)), i = this.handleNodes[n];
4919
4929
  i && this.layoutResizeHandle(i, r, 0);
4920
4930
  }), this.setTransformerOutline(e);
4921
4931
  }
4922
4932
  repositionOrientedHandles(e) {
4923
4933
  let t = this.orientedHandleAngle(e);
4924
- if (we(e).forEach((e, n) => {
4934
+ if (Ce(e).forEach((e, n) => {
4925
4935
  let r = this.imgToScreen(e), i = this.handleNodes[n];
4926
4936
  i && this.layoutResizeHandle(i, r, t);
4927
4937
  }), this.setTransformerOutlinePoints(e), this.rotNode) {
@@ -4944,7 +4954,7 @@ var zr = class {
4944
4954
  }
4945
4955
  edgeHitQuad(e, t) {
4946
4956
  let n = Math.max(7, this.vertexHandleRadius() + 2), r = this.imgToScreen(e), i = this.imgToScreen(t), a = i.x - r.x, o = i.y - r.y, s = Math.hypot(a, o) || 1, c = -o / s * n, l = a / s * n;
4947
- return new te([
4957
+ return new ee([
4948
4958
  r.x + c,
4949
4959
  r.y + l,
4950
4960
  i.x + c,
@@ -4956,7 +4966,7 @@ var zr = class {
4956
4966
  ]);
4957
4967
  }
4958
4968
  resetMoveOffsets() {
4959
- for (let [e, t] of this.nodes) this.shapes.find((t) => t.id === e)?.type !== L.POINT && t.position.set(0, 0);
4969
+ for (let [e, t] of this.nodes) this.shapes.find((t) => t.id === e)?.type !== R.POINT && t.position.set(0, 0);
4960
4970
  this.selLayer.position.set(0, 0);
4961
4971
  }
4962
4972
  commitTransformUpdates(e) {
@@ -4983,21 +4993,21 @@ var zr = class {
4983
4993
  let n = e.x - t.start.x, r = e.y - t.start.y;
4984
4994
  for (let e of t.shapes) {
4985
4995
  let t = this.nodes.get(e.id);
4986
- t && (this.shapes.find((t) => t.id === e.id)?.type === L.POINT ? t.position.set(e.points[0].x + n, e.points[0].y + r) : t.position.set(n, r));
4996
+ t && (this.shapes.find((t) => t.id === e.id)?.type === R.POINT ? t.position.set(e.points[0].x + n, e.points[0].y + r) : t.position.set(n, r));
4987
4997
  }
4988
4998
  } else for (let e of r) this.liveUpdateShape(e.id, e.points);
4989
4999
  if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
4990
5000
  n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandlesForBox(i);
4991
- let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === L.POLYGON || e?.type === L.LINE;
4992
- (t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
5001
+ let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === R.POLYGON || e?.type === R.LINE;
5002
+ (t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === R.POLYGON);
4993
5003
  } else if (t.kind === "rotate") {
4994
5004
  this.repositionOrientedHandles(r[0].points);
4995
5005
  let e = this.shapes.find((e) => e.id === t.id);
4996
- e && (e.type === L.POLYGON || e.type === L.LINE) && this.repositionPolygonHandles(r[0].points, e.type === L.POLYGON);
5006
+ e && (e.type === R.POLYGON || e.type === R.LINE) && this.repositionPolygonHandles(r[0].points, e.type === R.POLYGON);
4997
5007
  } else {
4998
5008
  i && this.repositionHandlesForBox(i);
4999
5009
  let e = this.shapes.find((e) => e.id === t.id);
5000
- this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
5010
+ this.repositionPolygonHandles(r[0].points, e?.type === R.POLYGON);
5001
5011
  }
5002
5012
  }
5003
5013
  cancelTransform() {
@@ -5289,13 +5299,13 @@ function qr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5289
5299
  //#region src/components/ShapeEditor/_state/useMinimapSync.ts
5290
5300
  function Jr(e, t, n) {
5291
5301
  if (!(!e || !n.length)) {
5292
- if (t.type === L.POINT) {
5302
+ if (t.type === R.POINT) {
5293
5303
  e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
5294
5304
  return;
5295
5305
  }
5296
- if (t.type === L.RECTANGLE || t.type === L.ELLIPSE) {
5297
- let r = H(n);
5298
- if (t.type === L.ELLIPSE) {
5306
+ if (t.type === R.RECTANGLE || t.type === R.ELLIPSE) {
5307
+ let r = U(n);
5308
+ if (t.type === R.ELLIPSE) {
5299
5309
  e.setAttribute("cx", String((r.minX + r.maxX) / 2)), e.setAttribute("cy", String((r.minY + r.maxY) / 2)), e.setAttribute("rx", String((r.maxX - r.minX) / 2)), e.setAttribute("ry", String((r.maxY - r.minY) / 2));
5300
5310
  return;
5301
5311
  }
@@ -5357,7 +5367,7 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5357
5367
  }), []), T(() => {
5358
5368
  s.current = 0;
5359
5369
  }, [a]);
5360
- let f = w(() => r(e.getShapes().filter((e) => z(e)).map((e) => e.id)), [e, r]), p = w(() => r([]), [r]), m = w(() => e.getShapes().filter((e) => t.current.includes(e.id) && oe(e)), [e, t]), h = w(() => {
5370
+ let f = w(() => r(e.getShapes().filter((e) => B(e)).map((e) => e.id)), [e, r]), p = w(() => r([]), [r]), m = w(() => e.getShapes().filter((e) => t.current.includes(e.id) && ae(e)), [e, t]), h = w(() => {
5361
5371
  if (n || !t.current.length) return;
5362
5372
  let i = m().map((e) => e.id);
5363
5373
  i.length && (e.remove(i), r([]));
@@ -5381,7 +5391,7 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5381
5391
  if (!c.current || l.current || u.current !== i || d.current !== o || !n?.shapes.length) return;
5382
5392
  let f, p, m = n.shapes.flatMap((e) => e.points);
5383
5393
  if (t && m.length) {
5384
- let e = H(m);
5394
+ let e = U(m);
5385
5395
  f = t.x - (e.minX + e.maxX) / 2, p = t.y - (e.minY + e.maxY) / 2;
5386
5396
  } else {
5387
5397
  let e = !!n.documentId && n.documentId !== a, t = Bt(s.current, e, Xr);
@@ -5389,7 +5399,7 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5389
5399
  }
5390
5400
  let h = n.shapes.map((e) => ({
5391
5401
  ...e,
5392
- id: le(),
5402
+ id: ce(),
5393
5403
  points: e.points.map((e) => ({
5394
5404
  x: e.x + f,
5395
5405
  y: e.y + p
@@ -5407,7 +5417,7 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5407
5417
  if (n || !t.current.length) return;
5408
5418
  let i = m().map((e) => ({
5409
5419
  ...e,
5410
- id: le(),
5420
+ id: ce(),
5411
5421
  points: e.points.map((e) => ({
5412
5422
  x: e.x + Xr,
5413
5423
  y: e.y + Xr
@@ -5438,7 +5448,7 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5438
5448
  m
5439
5449
  ]), S = w((r, i) => {
5440
5450
  if (n || !t.current.length) return !1;
5441
- let a = e.getShapes().filter((e) => t.current.includes(e.id) && oe(e));
5451
+ let a = e.getShapes().filter((e) => t.current.includes(e.id) && ae(e));
5442
5452
  return a.length ? (e.update(a.map((e) => ({
5443
5453
  ...e,
5444
5454
  points: e.points.map((e) => ({
@@ -5450,7 +5460,7 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5450
5460
  e,
5451
5461
  n,
5452
5462
  t
5453
- ]), C = w(() => m().filter((e) => e.type === L.POLYGON || e.type === L.RECTANGLE || e.type === L.ROTATED_RECTANGLE || e.type === L.ELLIPSE), [m]);
5463
+ ]), C = w(() => m().filter((e) => e.type === R.POLYGON || e.type === R.RECTANGLE || e.type === R.ROTATED_RECTANGLE || e.type === R.ELLIPSE), [m]);
5454
5464
  return {
5455
5465
  selectAll: f,
5456
5466
  clearSelection: p,
@@ -5473,8 +5483,8 @@ function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5473
5483
  let o = Fn(a, 1);
5474
5484
  if (!o.length) return;
5475
5485
  let s = t[0], c = o.map((e) => ({
5476
- id: le(),
5477
- type: L.POLYGON,
5486
+ id: ce(),
5487
+ type: R.POLYGON,
5478
5488
  points: e,
5479
5489
  style: s.style,
5480
5490
  meta: s.meta
@@ -5522,7 +5532,7 @@ function Qr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
5522
5532
  if (!r.length) return;
5523
5533
  let i = e.current;
5524
5534
  if (!i) return;
5525
- let a = gn(H(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
5535
+ let a = gn(U(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
5526
5536
  a && l(a);
5527
5537
  }, [
5528
5538
  t,
@@ -5572,19 +5582,19 @@ var $r = "__draft_preview__", ei = new Set([
5572
5582
  function ti(e, t) {
5573
5583
  return e.length === t.length && e.every((e, n) => e === t[n]);
5574
5584
  }
5575
- function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !1, selectedIds: i, activeTool: a, draftStyle: o, draftMeta: s, readOnly: c, disableMarquee: l, locked: u, onLockedInteraction: f, onDrawAttemptWithoutDraft: p, onIdleEscape: m, overrideShapeInteraction: h, defaultViewSettings: g, viewSettings: _, onViewSettingsChange: v, showMinimap: y = !0, minimapPosition: b = "bottom-left", showViewSettings: C = !0, getContextMenuItems: A, strings: N, viewSettingItems: P, canMergeSelection: ee, brushSize: F = 20, zoomBound: I, zoomAnimationDuration: te = 300, decorationShapes: ne, regionMask: re, overlayMarkers: ie, renderOverlayMarker: ae, onOverlayMarkerClick: se, renderImageOverlay: ce, getSelectionLabel: B, hideSelectionLabelDot: V, formatSelectionInfo: H, externalTools: ue, assistant: de, keymap: fe, handleRef: pe, backend: me = "pixi", onActiveToolChange: he, onSelectionChange: ge, onEditingChange: _e, onShapesCreated: ve, onShapesUpdated: ye, onShapesDeleted: be, onDrawSessionChange: xe, onDraftShapeChange: Se, onViewportChange: Ce, onShapesTransformPreview: we }) {
5576
- let Te = j(null), U = j(null), Ee = j(null), De = j(null), Oe = j(null), ke = `${E()}-minimap`, [W, Ae] = M(null), [je, Me] = M(!1), [G, Ne] = M(!1), [Pe, Fe] = M(null), [Ie, Le] = M({
5585
+ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !1, selectedIds: i, activeTool: a, draftStyle: o, draftMeta: s, readOnly: c, disableMarquee: l, locked: u, onLockedInteraction: f, onDrawAttemptWithoutDraft: p, onIdleEscape: m, overrideShapeInteraction: h, defaultViewSettings: g, viewSettings: _, onViewSettingsChange: v, showMinimap: y = !0, minimapPosition: b = "bottom-left", showViewSettings: C = !0, getContextMenuItems: A, strings: N, viewSettingItems: P, canMergeSelection: F, brushSize: I = 20, zoomBound: L, zoomAnimationDuration: ee = 300, decorationShapes: te, regionMask: ne, overlayMarkers: re, renderOverlayMarker: ie, onOverlayMarkerClick: oe, renderImageOverlay: se, getSelectionLabel: V, hideSelectionLabelDot: H, formatSelectionInfo: U, externalTools: le, assistant: ue, keymap: de, handleRef: fe, backend: pe = "pixi", onActiveToolChange: me, onSelectionChange: he, onEditingChange: ge, onShapesCreated: _e, onShapesUpdated: ve, onShapesDeleted: ye, onDrawSessionChange: be, onDraftShapeChange: xe, onViewportChange: Se, onShapesTransformPreview: Ce }) {
5586
+ let we = j(null), W = j(null), Te = j(null), Ee = j(null), De = j(null), Oe = `${E()}-minimap`, [G, ke] = M(null), [Ae, je] = M(!1), [Me, Ne] = M(!1), [Pe, Fe] = M(null), [Ie, Le] = M({
5577
5587
  active: !1,
5578
5588
  kind: "none",
5579
5589
  canUndo: !1,
5580
5590
  canRedo: !1
5581
5591
  }), [Re, ze] = M(!0), [K, He] = M(!1), Ue = e?.id ?? "", Ge = e?.imageUrl ?? "", Ke = e?.displayImageUrl, qe = e?.coordinateSize, Je = e?.initialShapes, Xe = e?.initialSelectedIds, et = Ke ?? Ge, [tt, nt] = M("loading"), rt = tt === "loading" && e !== null && !et ? "missing" : tt, [it, at] = M(null), ot = w((e, t) => {
5582
5592
  nt(e), at(e === "error" ? t ?? null : null);
5583
- }, []), J = Gn({
5584
- onShapesCreated: ve,
5585
- onShapesUpdated: ye,
5586
- onShapesDeleted: be
5587
- }), [st, ct] = M([]), Y = i ?? st, lt = i !== void 0, ut = k(() => new Map((ue ?? []).map((e) => [e.id, e])), [ue]), dt = j(ut);
5593
+ }, []), J = Kn({
5594
+ onShapesCreated: _e,
5595
+ onShapesUpdated: ve,
5596
+ onShapesDeleted: ye
5597
+ }), [st, ct] = M([]), Y = i ?? st, lt = i !== void 0, ut = k(() => new Map((le ?? []).map((e) => [e.id, e])), [le]), dt = j(ut);
5588
5598
  O(() => {
5589
5599
  dt.current = ut;
5590
5600
  }, [ut]);
@@ -5623,12 +5633,12 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5623
5633
  }
5624
5634
  vt.current?.(X);
5625
5635
  }, [X]);
5626
- let Ct = k(() => !W || !re ? null : cn(re, W.w, W.h), [W, re]), Tt = j(Ct);
5636
+ let Ct = k(() => !G || !ne ? null : cn(ne, G.w, G.h), [G, ne]), Tt = j(Ct);
5627
5637
  Tt.current = Ct;
5628
5638
  let Et = j(r);
5629
5639
  Et.current = r;
5630
- let Dt = j(W);
5631
- Dt.current = W;
5640
+ let Dt = j(G);
5641
+ Dt.current = G;
5632
5642
  let Ot = j(qe);
5633
5643
  Ot.current = qe;
5634
5644
  let kt = j(qe?.imageSize);
@@ -5643,8 +5653,8 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5643
5653
  Mt.current = o;
5644
5654
  let Nt = j(s);
5645
5655
  Nt.current = s;
5646
- let Ft = j(F);
5647
- Ft.current = F;
5656
+ let Ft = j(I);
5657
+ Ft.current = I;
5648
5658
  let It = j(X.simplifyStrength);
5649
5659
  It.current = X.simplifyStrength;
5650
5660
  let Q = !!c || !!u, Lt = j(Q);
@@ -5655,37 +5665,39 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5655
5665
  zt.current = u;
5656
5666
  let Bt = j(f);
5657
5667
  Bt.current = f;
5658
- let Vt = j(p);
5659
- Vt.current = p;
5660
- let Ht = j(h);
5661
- Ht.current = h;
5662
- let Ut = j(J);
5663
- Ut.current = J;
5664
- let Wt = j(!1), Gt = j("idle"), Kt = j(null), qt = w(() => {
5665
- let e = U.current;
5668
+ let Vt = j(c);
5669
+ Vt.current = c;
5670
+ let Ht = w((e = !0) => Vt.current || !zt.current || !e ? !1 : (Bt.current?.(), !0), []), Ut = j(p);
5671
+ Ut.current = p;
5672
+ let Wt = j(h);
5673
+ Wt.current = h;
5674
+ let Gt = j(J);
5675
+ Gt.current = J;
5676
+ let Kt = j(!1), qt = j("idle"), Yt = j(null), Xt = w(() => {
5677
+ let e = W.current;
5666
5678
  if (!e) return;
5667
5679
  let t = jt.current, n = dt.current.get(t), r = ft.current;
5668
5680
  e.setCursor(Jt({
5669
5681
  tool: t,
5670
5682
  externalToolCursor: n?.cursor,
5671
- isSpacePressed: Wt.current,
5672
- interactionMode: Gt.current,
5673
- rendererCursorHint: Kt.current,
5683
+ isSpacePressed: Kt.current,
5684
+ interactionMode: qt.current,
5685
+ rendererCursorHint: Yt.current,
5674
5686
  isPolygonDrawing: r.kind === "polygon" && r.active
5675
5687
  }));
5676
- }, []), Yt = w((e) => {
5677
- Gt.current !== e && (Gt.current = e, qt());
5678
- }, [qt]), Xt = w((e) => {
5679
- Kt.current !== e && (Kt.current = e, qt());
5680
- }, [qt]), Zt = w((e) => {
5681
- let t = /* @__PURE__ */ new Set(), n = new Map(Ut.current.getShapes().map((e) => [e.id, e]));
5688
+ }, []), Zt = w((e) => {
5689
+ qt.current !== e && (qt.current = e, Xt());
5690
+ }, [Xt]), Qt = w((e) => {
5691
+ Yt.current !== e && (Yt.current = e, Xt());
5692
+ }, [Xt]), $t = w((e) => {
5693
+ let t = /* @__PURE__ */ new Set(), n = new Map(Gt.current.getShapes().map((e) => [e.id, e]));
5682
5694
  return e.filter((e) => {
5683
5695
  if (t.has(e)) return !1;
5684
5696
  t.add(e);
5685
5697
  let r = n.get(e);
5686
5698
  if (!r) return !1;
5687
- let i = Ht.current?.(r);
5688
- return z(i ? {
5699
+ let i = Wt.current?.(r);
5700
+ return B(i ? {
5689
5701
  ...r,
5690
5702
  interaction: {
5691
5703
  ...r.interaction,
@@ -5693,68 +5705,68 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5693
5705
  }
5694
5706
  } : r);
5695
5707
  });
5696
- }, []), Qt = w((e) => {
5697
- let t = Zt(e);
5698
- ti(At.current, t) || (lt || ct(t), U.current?.setSelection(t), ge?.(t));
5708
+ }, []), en = w((e) => {
5709
+ let t = $t(e);
5710
+ ti(At.current, t) || (lt || ct(t), W.current?.setSelection(t), he?.(t));
5699
5711
  }, [
5700
- Zt,
5701
- ge,
5712
+ $t,
5713
+ he,
5702
5714
  lt
5703
- ]), $t = j(Qt);
5704
- $t.current = Qt;
5705
- let [en, tn] = M(null), nn = w((e) => tn(e), []), rn = j(nn);
5706
- rn.current = nn;
5707
- let an = j(null);
5708
- an.current = en, T(() => {
5715
+ ]), tn = j(en);
5716
+ tn.current = en;
5717
+ let [nn, rn] = M(null), an = w((e) => rn(e), []), on = j(an);
5718
+ on.current = an;
5719
+ let sn = j(null);
5720
+ sn.current = nn, T(() => {
5709
5721
  if (!lt) return;
5710
- let e = Zt(i);
5711
- ti(i, e) || ge?.(e);
5722
+ let e = $t(i);
5723
+ ti(i, e) || he?.(e);
5712
5724
  }, [
5713
5725
  i,
5714
5726
  J.shapes,
5715
- Zt,
5716
- ge,
5727
+ $t,
5728
+ he,
5717
5729
  lt
5718
5730
  ]);
5719
- let on = j(Ce);
5720
- on.current = Ce;
5721
- let { registerMinimapShape: sn, applyMinimapPreview: ln, syncMinimap: un } = Yr({
5722
- engineRef: U,
5723
- docRef: Ut,
5724
- overlayRef: De,
5725
- zoomLabelRef: Oe,
5726
- minimapRectRef: Ee,
5731
+ let ln = j(Se);
5732
+ ln.current = Se;
5733
+ let { registerMinimapShape: un, applyMinimapPreview: dn, syncMinimap: fn } = Yr({
5734
+ engineRef: W,
5735
+ docRef: Gt,
5736
+ overlayRef: Ee,
5737
+ zoomLabelRef: De,
5738
+ minimapRectRef: Te,
5727
5739
  minimapSize: 204,
5728
- onViewportChangeRef: on
5729
- }), dn = j(/* @__PURE__ */ new Map()), fn = j(H);
5730
- fn.current = H;
5731
- let pn = w((e, t) => {
5732
- t ? dn.current.set(e, t) : dn.current.delete(e);
5733
- }, []), mn = j(null), [hn, gn] = M(null), _n = w((e) => {
5740
+ onViewportChangeRef: ln
5741
+ }), pn = j(/* @__PURE__ */ new Map()), mn = j(U);
5742
+ mn.current = U;
5743
+ let hn = w((e, t) => {
5744
+ t ? pn.current.set(e, t) : pn.current.delete(e);
5745
+ }, []), gn = j(null), [_n, bn] = M(null), xn = w((e) => {
5734
5746
  if (!e.length) return;
5735
- let t = new Map(Ut.current.getShapes().map((e) => [e.id, e]));
5736
- mn.current && t.set(mn.current.id, mn.current);
5747
+ let t = new Map(Gt.current.getShapes().map((e) => [e.id, e]));
5748
+ gn.current && t.set(gn.current.id, gn.current);
5737
5749
  for (let { id: n, points: r } of e) {
5738
- let e = dn.current.get(n), i = t.get(n);
5750
+ let e = pn.current.get(n), i = t.get(n);
5739
5751
  if (!e || !i) continue;
5740
5752
  let a = bt(e, r);
5741
5753
  if (a) {
5742
5754
  let e = xt(i, r);
5743
- a.textContent = fn.current?.(e) ?? St(e);
5755
+ a.textContent = mn.current?.(e) ?? St(e);
5744
5756
  }
5745
5757
  }
5746
- }, []), bn = w((e) => {
5747
- ln(e), _n(e), we?.(e);
5758
+ }, []), Sn = w((e) => {
5759
+ dn(e), xn(e), Ce?.(e);
5748
5760
  }, [
5749
- ln,
5750
- _n,
5751
- we
5752
- ]), xn = w((e) => {
5753
- if (Se?.(e ? {
5761
+ dn,
5762
+ xn,
5763
+ Ce
5764
+ ]), Cn = w((e) => {
5765
+ if (xe?.(e ? {
5754
5766
  ...e,
5755
5767
  meta: Nt.current
5756
5768
  } : null), !e || !Mt.current) {
5757
- mn.current && (mn.current = null, gn(null));
5769
+ gn.current && (gn.current = null, bn(null));
5758
5770
  return;
5759
5771
  }
5760
5772
  let t = {
@@ -5763,212 +5775,217 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5763
5775
  points: e.points,
5764
5776
  style: Mt.current,
5765
5777
  meta: Nt.current
5766
- }, n = mn.current !== null;
5767
- mn.current = t, n ? _n([{
5778
+ }, n = gn.current !== null;
5779
+ gn.current = t, n ? xn([{
5768
5780
  id: $r,
5769
5781
  points: e.points
5770
- }]) : gn(t);
5771
- }, [_n, Se]), Sn = w((e, t) => {
5782
+ }]) : bn(t);
5783
+ }, [xn, xe]), wn = w((e, t) => {
5772
5784
  let n = Mt.current;
5773
5785
  if (!n || Lt.current) return;
5774
- let r = le();
5775
- Ut.current.create({
5786
+ let r = ce();
5787
+ Gt.current.create({
5776
5788
  id: r,
5777
5789
  type: e,
5778
5790
  points: t,
5779
5791
  style: n,
5780
5792
  meta: s
5781
- }), $t.current([r]);
5782
- }, [s]), Cn = j(Sn);
5783
- Cn.current = Sn;
5784
- let wn = Un({
5793
+ }), tn.current([r]);
5794
+ }, [s]), Tn = j(wn);
5795
+ Tn.current = wn;
5796
+ let En = Un({
5785
5797
  toolRef: jt,
5786
5798
  selRef: At,
5787
- docRef: Ut,
5799
+ docRef: Gt,
5788
5800
  readOnlyRef: Lt,
5789
5801
  draftRef: Mt,
5790
5802
  brushSizeRef: Ft,
5791
5803
  simplifyEpsilonRef: It,
5792
5804
  draftMeta: s,
5793
- engineRef: U,
5805
+ engineRef: W,
5794
5806
  onDrawSessionChange: w((e) => {
5795
- Le(e), xe?.(e);
5796
- }, [xe]),
5797
- onDraftShapeChange: Se,
5798
- changeSelection: Qt,
5799
- createShape: Sn
5800
- }), Tn = j(wn);
5801
- Tn.current = wn;
5802
- let { reset: En, undoSession: Dn, redoSession: On, canUndoSession: kn, canRedoSession: An, hasDraftSession: jn, hasDraftPoints: Mn, commitDraftSession: Nn, setBrushScalarMode: Pn, getBrushScalarMode: Fn, hasBrushSession: In, commitBrush: Ln, cancelBrush: Rn, beginBrushEditFromSelection: zn, deleteDraftSelectedPoints: Bn, handleToolChange: Vn, handleBrushSelectionChange: Hn } = wn, Wn = j(de);
5803
- Wn.current = de;
5807
+ Le(e), be?.(e);
5808
+ }, [be]),
5809
+ onDraftShapeChange: xe,
5810
+ changeSelection: en,
5811
+ createShape: wn
5812
+ }), Dn = j(En);
5813
+ Dn.current = En;
5814
+ let { reset: On, undoSession: kn, redoSession: An, canUndoSession: jn, canRedoSession: Mn, hasDraftSession: Nn, hasDraftPoints: Pn, commitDraftSession: Fn, setBrushScalarMode: In, getBrushScalarMode: Ln, hasBrushSession: Rn, commitBrush: zn, cancelBrush: Bn, beginBrushEditFromSelection: Vn, deleteDraftSelectedPoints: Hn, handleToolChange: Wn, handleBrushSelectionChange: Gn } = En, qn = j(ue);
5815
+ qn.current = ue;
5804
5816
  let $ = yn({
5805
- docRef: Ut,
5817
+ docRef: Gt,
5806
5818
  draftRef: Mt,
5807
5819
  draftMeta: s,
5808
- changeSelection: Qt,
5809
- assistantRef: Wn
5810
- }), Kn = j($);
5811
- Kn.current = $;
5812
- let qn = k(() => Pt(Ue), [Ue]), { selectAll: Jn, clearSelection: Yn, deleteSelection: Xn, copySelection: Zn, canPaste: Qn, paste: er, duplicate: tr, bringToFront: nr, sendToBack: rr, nudgeSelection: ir, getMergeTargets: ar, mergeSelection: or } = Zr({
5820
+ changeSelection: en,
5821
+ assistantRef: qn
5822
+ }), Jn = j($);
5823
+ Jn.current = $;
5824
+ let Yn = k(() => Pt(Ue), [Ue]), { selectAll: Xn, clearSelection: Zn, deleteSelection: Qn, copySelection: er, canPaste: tr, paste: nr, duplicate: rr, bringToFront: ir, sendToBack: ar, nudgeSelection: or, getMergeTargets: sr, mergeSelection: cr } = Zr({
5813
5825
  doc: J,
5814
5826
  selRef: At,
5815
5827
  effectiveReadOnly: Q,
5816
- changeSelection: Qt,
5817
- canMergeSelection: ee,
5818
- clipboardDocumentId: qn,
5819
- clipboardScope: t ?? qn
5820
- }), { zoomToBounds: sr, zoomToShapes: cr, zoomToSelection: lr, zoomAtCenter: ur } = Qr({
5821
- engineRef: U,
5828
+ changeSelection: en,
5829
+ canMergeSelection: F,
5830
+ clipboardDocumentId: Yn,
5831
+ clipboardScope: t ?? Yn
5832
+ }), { zoomToBounds: lr, zoomToShapes: ur, zoomToSelection: dr, zoomAtCenter: fr } = Qr({
5833
+ engineRef: W,
5822
5834
  doc: J,
5823
5835
  selRef: At,
5824
- zoomAnimationDuration: te,
5825
- zoomBound: I,
5826
- ready: G
5836
+ zoomAnimationDuration: ee,
5837
+ zoomBound: L,
5838
+ ready: Me
5827
5839
  });
5828
- D(pe, () => ({
5840
+ D(fe, () => ({
5829
5841
  previewRegionMask: (e) => {
5830
5842
  let t = Dt.current;
5831
5843
  if (!t) return;
5832
5844
  let n = e ? cn(e, t.w, t.h) : Tt.current;
5833
- U.current?.setRegionOverlay(dr.current.showRegionMask ? n : null);
5845
+ W.current?.setRegionOverlay(pr.current.showRegionMask ? n : null);
5834
5846
  },
5835
5847
  undo: () => {
5836
- Dn() || J.undo();
5848
+ Lt.current || kn() || J.undo();
5837
5849
  },
5838
5850
  redo: () => {
5839
- On() || J.redo();
5851
+ Lt.current || An() || J.redo();
5840
5852
  },
5841
- canUndo: () => kn() || J.canUndo(),
5842
- canRedo: () => An() || J.canRedo(),
5843
- undoSession: Dn,
5844
- redoSession: On,
5845
- canUndoSession: kn,
5846
- canRedoSession: An,
5847
- hasDraftSession: jn,
5848
- cancelDraftSession: En,
5849
- commitDraftSession: Nn,
5850
- setSelection: Qt,
5853
+ canUndo: () => jn() || J.canUndo(),
5854
+ canRedo: () => Mn() || J.canRedo(),
5855
+ undoSession: kn,
5856
+ redoSession: An,
5857
+ canUndoSession: jn,
5858
+ canRedoSession: Mn,
5859
+ hasDraftSession: Nn,
5860
+ cancelDraftSession: On,
5861
+ commitDraftSession: Fn,
5862
+ setSelection: en,
5851
5863
  createShapes: (e) => {
5852
- e.length && (J.create(e), Qt(e.map((e) => e.id)));
5864
+ !e.length || Ht() || (J.create(e), en(e.map((e) => e.id)));
5865
+ },
5866
+ updateShapes: (e) => {
5867
+ !e.length || Ht() || J.update(e);
5868
+ },
5869
+ deleteShapes: (e) => {
5870
+ !e.length || Ht() || J.remove(e);
5853
5871
  },
5854
- updateShapes: J.update,
5855
- deleteShapes: J.remove,
5856
5872
  getShapes: J.getShapes,
5857
- selectAll: Jn,
5858
- clearSelection: Yn,
5859
- deleteSelection: Xn,
5860
- copySelection: Zn,
5861
- paste: er,
5862
- duplicate: tr,
5863
- bringToFront: nr,
5864
- sendToBack: rr,
5865
- zoomFit: () => U.current?.fit(),
5866
- zoom100: () => U.current?.zoom100(),
5873
+ selectAll: Xn,
5874
+ clearSelection: Zn,
5875
+ deleteSelection: Qn,
5876
+ copySelection: er,
5877
+ paste: nr,
5878
+ duplicate: rr,
5879
+ bringToFront: ir,
5880
+ sendToBack: ar,
5881
+ zoomFit: () => W.current?.fit(),
5882
+ zoom100: () => W.current?.zoom100(),
5867
5883
  zoomIn: () => {
5868
- let e = U.current;
5884
+ let e = W.current;
5869
5885
  if (!e) return;
5870
5886
  let { w: t, h: n } = e.screenSize;
5871
5887
  e.zoomAt(t / 2, n / 2, 1.2);
5872
5888
  },
5873
5889
  zoomOut: () => {
5874
- let e = U.current;
5890
+ let e = W.current;
5875
5891
  if (!e) return;
5876
5892
  let { w: t, h: n } = e.screenSize;
5877
5893
  e.zoomAt(t / 2, n / 2, 1 / 1.2);
5878
5894
  },
5879
- zoomToSelection: lr,
5880
- zoomToShapes: cr,
5881
- zoomToBounds: sr,
5895
+ zoomToSelection: dr,
5896
+ zoomToShapes: ur,
5897
+ zoomToBounds: lr,
5882
5898
  brush: {
5883
- setScalarMode: Pn,
5884
- getScalarMode: Fn,
5885
- hasSession: In,
5886
- commit: Ln,
5887
- cancel: Rn,
5888
- beginEditFromSelection: zn
5899
+ setScalarMode: In,
5900
+ getScalarMode: Ln,
5901
+ hasSession: Rn,
5902
+ commit: zn,
5903
+ cancel: Bn,
5904
+ beginEditFromSelection: Vn
5889
5905
  }
5890
5906
  }), [
5891
5907
  J,
5892
- Qt,
5893
- Dn,
5908
+ en,
5909
+ Ht,
5910
+ kn,
5911
+ An,
5912
+ Fn,
5894
5913
  On,
5895
- Nn,
5896
- En,
5897
- Ln,
5898
- Rn,
5899
- Jn,
5900
- Yn,
5914
+ zn,
5915
+ Bn,
5901
5916
  Xn,
5902
5917
  Zn,
5918
+ Qn,
5903
5919
  er,
5904
- tr,
5905
5920
  nr,
5906
5921
  rr,
5922
+ ir,
5923
+ ar,
5924
+ dr,
5925
+ ur,
5907
5926
  lr,
5908
- cr,
5909
- sr,
5910
- Pn,
5911
- Fn,
5912
5927
  In,
5913
- zn
5928
+ Ln,
5929
+ Rn,
5930
+ Vn
5914
5931
  ]);
5915
- let dr = j(X);
5916
- dr.current = X;
5917
- let fr = w(() => vn({
5918
- engineRef: U,
5932
+ let pr = j(X);
5933
+ pr.current = X;
5934
+ let mr = w(() => vn({
5935
+ engineRef: W,
5919
5936
  toolRef: jt,
5920
5937
  externalToolMapRef: dt,
5921
- spaceRef: Wt,
5922
- docRef: Ut,
5938
+ spaceRef: Kt,
5939
+ docRef: Gt,
5923
5940
  selRef: At,
5924
5941
  draftRef: Mt,
5925
5942
  readOnlyRef: Lt,
5926
5943
  disableMarqueeRef: Rt,
5927
5944
  lockedRef: zt,
5928
5945
  onLockedInteraction: () => Bt.current?.(),
5929
- onDrawAttemptWithoutDraft: () => Vt.current?.(),
5930
- createRef: Cn,
5931
- selectRef: $t,
5932
- enterEditRef: rn,
5933
- editingIdRef: an,
5934
- drawSessionRef: Tn,
5935
- assistantRef: Kn,
5936
- setCursorHint: Xt,
5937
- setInteractionMode: Yt,
5938
- syncMinimap: un,
5939
- onTransformPreview: bn,
5940
- onDrawPreview: xn
5946
+ onDrawAttemptWithoutDraft: () => Ut.current?.(),
5947
+ createRef: Tn,
5948
+ selectRef: tn,
5949
+ enterEditRef: on,
5950
+ editingIdRef: sn,
5951
+ drawSessionRef: Dn,
5952
+ assistantRef: Jn,
5953
+ setCursorHint: Qt,
5954
+ setInteractionMode: Zt,
5955
+ syncMinimap: fn,
5956
+ onTransformPreview: Sn,
5957
+ onDrawPreview: Cn
5941
5958
  }), [
5942
- Xt,
5943
- Yt,
5944
- un,
5945
- bn,
5946
- xn
5947
- ]), pr = j([]);
5959
+ Qt,
5960
+ Zt,
5961
+ fn,
5962
+ Sn,
5963
+ Cn
5964
+ ]), hr = j([]);
5948
5965
  Hr({
5949
- backend: me,
5950
- hostRef: Te,
5951
- engineRef: U,
5966
+ backend: pe,
5967
+ hostRef: we,
5968
+ engineRef: W,
5952
5969
  documentId: Ue,
5953
5970
  renderedImageUrl: et,
5954
- makeCallbacks: fr,
5955
- viewRef: dr,
5971
+ makeCallbacks: mr,
5972
+ viewRef: pr,
5956
5973
  readOnlyRef: Lt,
5957
5974
  toolRef: jt,
5958
- renderShapesRef: pr,
5975
+ renderShapesRef: hr,
5959
5976
  coordinateSizeRef: Ot,
5960
5977
  imageSizeRef: kt,
5961
5978
  selRef: At,
5962
5979
  regionOverlayRef: Tt,
5963
5980
  dimmedRef: Et,
5964
- syncMinimap: un,
5965
- setImage: Ae,
5966
- setImageVisible: Me,
5981
+ syncMinimap: fn,
5982
+ setImage: ke,
5983
+ setImageVisible: je,
5967
5984
  setReady: Ne,
5968
5985
  setImageStatus: ot,
5969
5986
  onContextMenuRequest: Fe
5970
5987
  });
5971
- let mr = k(() => {
5988
+ let gr = k(() => {
5972
5989
  let e = h ? J.shapes.map((e) => {
5973
5990
  let t = h(e);
5974
5991
  return t ? {
@@ -5979,7 +5996,7 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5979
5996
  }
5980
5997
  } : e;
5981
5998
  }) : J.shapes;
5982
- return ne?.length ? [...ne.map((e) => ({
5999
+ return te?.length ? [...te.map((e) => ({
5983
6000
  ...e,
5984
6001
  interaction: {
5985
6002
  ...e.interaction,
@@ -5992,128 +6009,134 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5992
6009
  }, [
5993
6010
  J.shapes,
5994
6011
  h,
5995
- ne
6012
+ te
5996
6013
  ]);
5997
- pr.current = mr, T(() => {
5998
- U.current?.setShapes(mr, At.current), un();
5999
- }, [mr, un]), T(() => {
6000
- U.current?.setSelection(Y);
6014
+ hr.current = gr, T(() => {
6015
+ W.current?.setShapes(gr, At.current), fn();
6016
+ }, [gr, fn]), T(() => {
6017
+ W.current?.setSelection(Y);
6001
6018
  }, [Y]), T(() => {
6002
- U.current?.setEditing(en);
6003
- }, [en, G]);
6004
- let hr = j(_e);
6005
- hr.current = _e, T(() => {
6006
- hr.current?.(en);
6007
- }, [en]), T(() => {
6008
- tn(null);
6019
+ W.current?.setEditing(nn);
6020
+ }, [nn, Me]);
6021
+ let _r = j(ge);
6022
+ _r.current = ge, T(() => {
6023
+ _r.current?.(nn);
6024
+ }, [nn]), T(() => {
6025
+ rn(null);
6009
6026
  }, [a]), T(() => {
6010
- en && (Y.length !== 1 || Y[0] !== en) && tn(null);
6011
- }, [Y, en]), T(() => {
6012
- let e = U.current;
6013
- e && (e.setFilter(X.brightness, X.contrast), e.setRenderDefaults({ strokeWidth: X.strokeSize }), e.setImageSmoothing(X.imageSmoothing), un());
6027
+ nn && (Y.length !== 1 || Y[0] !== nn) && rn(null);
6028
+ }, [Y, nn]), T(() => {
6029
+ let e = W.current;
6030
+ e && (e.setFilter(X.brightness, X.contrast), e.setRenderDefaults({ strokeWidth: X.strokeSize }), e.setImageSmoothing(X.imageSmoothing), fn());
6014
6031
  }, [
6015
6032
  X.brightness,
6016
6033
  X.contrast,
6017
6034
  X.strokeSize,
6018
6035
  X.imageSmoothing,
6019
- un
6036
+ fn
6020
6037
  ]), O(() => {
6021
- G && U.current?.setOverlays(X.showRegionMask ? Ct : null, r);
6038
+ Me && W.current?.setOverlays(X.showRegionMask ? Ct : null, r);
6022
6039
  }, [
6023
- G,
6040
+ Me,
6024
6041
  Ct,
6025
6042
  X.showRegionMask,
6026
6043
  r
6027
6044
  ]), T(() => {
6028
- !G || !W || un();
6045
+ !Me || !G || fn();
6029
6046
  }, [
6047
+ Me,
6030
6048
  G,
6031
- W,
6032
6049
  X.showRegionMask,
6033
- re,
6034
- un
6050
+ ne,
6051
+ fn
6035
6052
  ]), T(() => {
6036
- G && U.current?.setTransformEnabled(!Q && a !== q.BRUSH);
6053
+ Me && W.current?.setTransformEnabled(!Q && a !== q.BRUSH);
6037
6054
  }, [
6038
6055
  Q,
6039
- G,
6056
+ Me,
6040
6057
  a
6041
6058
  ]), T(() => {
6042
- Vn(a, dt.current.has(a));
6043
- }, [a, Vn]);
6044
- let gr = $.finalize;
6059
+ u && rn(null);
6060
+ }, [u]), T(() => {
6061
+ Wn(a, dt.current.has(a));
6062
+ }, [a, Wn]);
6063
+ let vr = $.finalize;
6045
6064
  T(() => {
6046
- gr();
6047
- }, [a, gr]), T(() => {
6048
- Gt.current = "idle", Kt.current = null, qt();
6065
+ vr();
6066
+ }, [a, vr]), T(() => {
6067
+ qt.current = "idle", Yt.current = null, Xt();
6049
6068
  }, [
6050
6069
  a,
6051
- me,
6052
- qt
6070
+ pe,
6071
+ Xt
6053
6072
  ]), T(() => {
6054
- Hn(Y, Q);
6073
+ Gn(Y, Q);
6055
6074
  }, [
6056
6075
  Y,
6057
6076
  a,
6058
6077
  Q,
6059
- Hn
6078
+ Gn
6060
6079
  ]), T(() => {
6061
- G && qt();
6080
+ Me && Xt();
6062
6081
  }, [
6063
6082
  a,
6064
6083
  Ie,
6065
6084
  ut,
6066
- G,
6067
- qt
6085
+ Me,
6086
+ Xt
6068
6087
  ]);
6069
- let _r = j(Xe);
6070
- _r.current = Xe;
6071
- let vr = e !== null, yr = j(null);
6088
+ let yr = j(Xe);
6089
+ yr.current = Xe;
6090
+ let br = e !== null, xr = j(null);
6072
6091
  T(() => {
6073
- let e = vr ? Ue : null;
6074
- yr.current !== e && (yr.current = e, Fe(null), tn(null), Gt.current = "idle", Kt.current = null, J.reset(vr ? Je ?? [] : []), Qt(vr ? _r.current ?? [] : []), En(), gr(), qt());
6092
+ let e = br ? Ue : null;
6093
+ xr.current !== e && (xr.current = e, Fe(null), rn(null), qt.current = "idle", Yt.current = null, J.reset(br ? Je ?? [] : []), en(br ? yr.current ?? [] : []), On(), vr(), Xt());
6075
6094
  }, [
6076
- vr,
6095
+ br,
6077
6096
  Ue,
6078
6097
  Je,
6079
6098
  J.reset,
6080
- Qt,
6081
- En,
6082
- gr,
6083
- qt
6099
+ en,
6100
+ On,
6101
+ vr,
6102
+ Xt
6084
6103
  ]);
6085
- let br = w(() => {
6086
- let e = an.current;
6104
+ let Sr = w(() => {
6105
+ let e = sn.current;
6087
6106
  if (!e || Q) return !1;
6088
- let t = U.current, n = new Set(t?.getVertexSelection() ?? []);
6107
+ let t = W.current, n = new Set(t?.getVertexSelection() ?? []);
6089
6108
  if (!n.size) return !1;
6090
- let r = Ut.current.getShapes().find((t) => t.id === e);
6109
+ let r = Gt.current.getShapes().find((t) => t.id === e);
6091
6110
  if (!r) return !1;
6092
- let i = r.points.filter((e, t) => !n.has(t)), a = r.type === L.LINE ? 2 : 3;
6093
- return i.length < a ? !1 : (Ut.current.update([{
6111
+ let i = r.points.filter((e, t) => !n.has(t)), a = r.type === R.LINE ? 2 : 3;
6112
+ return i.length < a ? !1 : (Gt.current.update([{
6094
6113
  ...r,
6095
6114
  points: i
6096
6115
  }]), t?.setVertexSelection([]), !0);
6097
- }, [Q]);
6116
+ }, [Q]), Cr = () => J.getShapes().some((e) => At.current.includes(e.id) && ae(e));
6098
6117
  $n({
6099
- keymap: fe,
6100
- hostRef: Te,
6118
+ keymap: de,
6119
+ hostRef: we,
6101
6120
  actions: {
6102
6121
  undo: () => {
6103
- Q || Dn() || J.undo();
6122
+ Q || kn() || J.undo();
6104
6123
  },
6105
6124
  redo: () => {
6106
- Q || On() || J.redo();
6125
+ Q || An() || J.redo();
6107
6126
  },
6108
- selectAll: Jn,
6109
- copy: Zn,
6127
+ selectAll: Xn,
6128
+ copy: er,
6110
6129
  cut: () => {
6111
- Zn(), Xn();
6130
+ Ht(Cr()) || (er(), Qn());
6131
+ },
6132
+ paste: () => {
6133
+ Ht(tr()) || nr();
6134
+ },
6135
+ duplicate: () => {
6136
+ Ht(Cr()) || rr();
6112
6137
  },
6113
- paste: er,
6114
- duplicate: tr,
6115
6138
  delete: () => {
6116
- Mn() && Bn() || br() || Xn();
6139
+ Ht(Cr()) || Pn() && Hn() || Sr() || Qn();
6117
6140
  },
6118
6141
  cancel: () => {
6119
6142
  let e = dt.current.get(jt.current);
@@ -6122,16 +6145,16 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6122
6145
  $.cancel();
6123
6146
  return;
6124
6147
  }
6125
- if (jn()) {
6126
- En();
6148
+ if (Nn()) {
6149
+ On();
6127
6150
  return;
6128
6151
  }
6129
- if (en) {
6130
- tn(null);
6152
+ if (nn) {
6153
+ rn(null);
6131
6154
  return;
6132
6155
  }
6133
6156
  if (At.current.length) {
6134
- Yn();
6157
+ Zn();
6135
6158
  return;
6136
6159
  }
6137
6160
  m?.();
@@ -6142,26 +6165,26 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6142
6165
  $.finalize();
6143
6166
  return;
6144
6167
  }
6145
- if (jn()) {
6146
- Nn();
6168
+ if (Nn()) {
6169
+ Fn();
6147
6170
  return;
6148
6171
  }
6149
6172
  if (Q) return;
6150
- if (en) {
6151
- tn(null);
6173
+ if (nn) {
6174
+ rn(null);
6152
6175
  return;
6153
6176
  }
6154
6177
  let e = At.current;
6155
6178
  if (e.length !== 1) return;
6156
- let t = Ut.current.getShapes().find((t) => t.id === e[0]);
6157
- t && (t.type === L.POLYGON || t.type === L.LINE) && t.interaction?.editable !== !1 && !t.readOnly && tn(e[0]);
6179
+ let t = Gt.current.getShapes().find((t) => t.id === e[0]);
6180
+ t && (t.type === R.POLYGON || t.type === R.LINE) && t.interaction?.editable !== !1 && !t.readOnly && rn(e[0]);
6158
6181
  },
6159
- bringToFront: nr,
6160
- sendToBack: rr,
6161
- zoomIn: () => ur(1.2),
6162
- zoomOut: () => ur(1 / 1.2),
6163
- zoom100: () => U.current?.zoom100(),
6164
- zoomFit: () => U.current?.fit(),
6182
+ bringToFront: ir,
6183
+ sendToBack: ar,
6184
+ zoomIn: () => fr(1.2),
6185
+ zoomOut: () => fr(1 / 1.2),
6186
+ zoom100: () => W.current?.zoom100(),
6187
+ zoomFit: () => W.current?.fit(),
6165
6188
  toggleMinimap: () => ze((e) => !e),
6166
6189
  toggleCursorGuide: () => gt((e) => ({
6167
6190
  ...e,
@@ -6171,120 +6194,120 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6171
6194
  ...e,
6172
6195
  imageSmoothing: !e.imageSmoothing
6173
6196
  })),
6174
- selectTool: () => he?.(q.SELECT),
6175
- rectangleTool: () => he?.(q.RECTANGLE),
6176
- rotatedRectangleTool: () => he?.(q.ROTATED_RECTANGLE),
6177
- circleTool: () => he?.(q.CIRCLE),
6178
- polygonTool: () => he?.(q.POLYGON),
6179
- pathTool: () => he?.(q.PATH),
6180
- brushTool: () => he?.(q.BRUSH),
6181
- pointTool: () => he?.(q.POINT)
6197
+ selectTool: () => me?.(q.SELECT),
6198
+ rectangleTool: () => me?.(q.RECTANGLE),
6199
+ rotatedRectangleTool: () => me?.(q.ROTATED_RECTANGLE),
6200
+ circleTool: () => me?.(q.CIRCLE),
6201
+ polygonTool: () => me?.(q.POLYGON),
6202
+ pathTool: () => me?.(q.PATH),
6203
+ brushTool: () => me?.(q.BRUSH),
6204
+ pointTool: () => me?.(q.POINT)
6182
6205
  },
6183
- spaceRef: Wt,
6206
+ spaceRef: Kt,
6184
6207
  onSpaceDown: () => {
6185
- U.current?.setPanMode(!0), qt();
6208
+ W.current?.setPanMode(!0), Xt();
6186
6209
  },
6187
6210
  onSpaceUp: () => {
6188
- U.current?.setPanMode(!1), Gt.current === "panning" ? Yt("idle") : qt();
6211
+ W.current?.setPanMode(!1), qt.current === "panning" ? Zt("idle") : Xt();
6189
6212
  },
6190
- nudge: ir
6213
+ nudge: (e, t) => Ht(Cr()) || or(e, t)
6191
6214
  });
6192
- let xr = k(() => mr.filter((e) => Y.includes(e.id) && R(e)), [mr, Y]), Sr = k(() => hn ? [...xr, hn] : xr, [xr, hn]), Cr = Y.length > 0, wr = J.shapes.some((e) => Y.includes(e.id) && oe(e)), Tr = !Q && Y.length === 1 && (() => {
6215
+ let wr = k(() => gr.filter((e) => Y.includes(e.id) && z(e)), [gr, Y]), Tr = k(() => _n ? [...wr, _n] : wr, [wr, _n]), Er = Y.length > 0, Dr = J.shapes.some((e) => Y.includes(e.id) && ae(e)), Or = !Q && Y.length === 1 && (() => {
6193
6216
  let e = J.shapes.find((e) => e.id === Y[0]);
6194
- return !!e && (e.type === L.POLYGON || e.type === L.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
6195
- })(), Er = ar(), Dr = Q || Er.length < 2 || (ee ? !ee(Er) : !1), Or = !!de && !Q, kr = Or && Y.length === 1 ? (() => {
6217
+ return !!e && (e.type === R.POLYGON || e.type === R.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
6218
+ })(), kr = sr(), Ar = Q || kr.length < 2 || (F ? !F(kr) : !1), jr = !!ue && !Q, Mr = jr && Y.length === 1 ? (() => {
6196
6219
  let e = J.shapes.find((e) => e.id === Y[0]);
6197
- return e && e.type === L.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
6198
- })() : null, Ar = [
6220
+ return e && e.type === R.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
6221
+ })() : null, Nr = [
6199
6222
  {
6200
6223
  id: "copy",
6201
6224
  label: Z.contextMenu.copy,
6202
6225
  shortcut: "⌘C",
6203
- disabled: !wr,
6204
- onClick: Zn
6226
+ disabled: !Dr,
6227
+ onClick: er
6205
6228
  },
6206
6229
  {
6207
6230
  id: "paste",
6208
6231
  label: Z.contextMenu.paste,
6209
6232
  shortcut: "⌘V",
6210
- disabled: Q || !Qn(),
6211
- onClick: () => er(Pe?.img)
6233
+ disabled: Q || !tr(),
6234
+ onClick: () => nr(Pe?.img)
6212
6235
  },
6213
6236
  {
6214
6237
  id: "duplicate",
6215
6238
  label: Z.contextMenu.duplicate,
6216
6239
  shortcut: "⌘D",
6217
- disabled: !wr || Q,
6218
- onClick: tr
6240
+ disabled: !Dr || Q,
6241
+ onClick: rr
6219
6242
  },
6220
6243
  {
6221
6244
  id: "delete",
6222
6245
  label: Z.contextMenu.delete,
6223
6246
  shortcut: "Del",
6224
6247
  danger: !0,
6225
- disabled: !wr || Q,
6226
- onClick: Xn
6248
+ disabled: !Dr || Q,
6249
+ onClick: Qn
6227
6250
  },
6228
6251
  { separator: !0 },
6229
6252
  {
6230
6253
  id: "editVertices",
6231
6254
  label: Z.contextMenu.editVertices,
6232
6255
  shortcut: "Enter",
6233
- disabled: !Tr,
6234
- onClick: () => tn(Y[0])
6256
+ disabled: !Or,
6257
+ onClick: () => rn(Y[0])
6235
6258
  },
6236
6259
  {
6237
6260
  id: "merge",
6238
6261
  label: Z.contextMenu.merge,
6239
- disabled: Dr,
6240
- onClick: or
6262
+ disabled: Ar,
6263
+ onClick: cr
6241
6264
  },
6242
- ...Or ? [{
6265
+ ...jr ? [{
6243
6266
  id: "assistExpand",
6244
6267
  label: Z.contextMenu.assistExpand,
6245
6268
  icon: /* @__PURE__ */ x(d, { size: 14 }),
6246
- disabled: !kr,
6269
+ disabled: !Mr,
6247
6270
  onClick: () => {
6248
- Pe && kr && $.refineShape(kr, Pe.img, !0);
6271
+ Pe && Mr && $.refineShape(Mr, Pe.img, !0);
6249
6272
  }
6250
6273
  }, {
6251
6274
  id: "assistExclude",
6252
6275
  label: Z.contextMenu.assistExclude,
6253
6276
  icon: /* @__PURE__ */ x(d, { size: 14 }),
6254
- disabled: !kr,
6277
+ disabled: !Mr,
6255
6278
  onClick: () => {
6256
- Pe && kr && $.refineShape(kr, Pe.img, !1);
6279
+ Pe && Mr && $.refineShape(Mr, Pe.img, !1);
6257
6280
  }
6258
6281
  }] : [],
6259
6282
  {
6260
6283
  id: "bringToFront",
6261
6284
  label: Z.contextMenu.bringToFront,
6262
- disabled: !wr || Q,
6263
- onClick: nr
6285
+ disabled: !Dr || Q,
6286
+ onClick: ir
6264
6287
  },
6265
6288
  {
6266
6289
  id: "sendToBack",
6267
6290
  label: Z.contextMenu.sendToBack,
6268
- disabled: !wr || Q,
6269
- onClick: rr
6291
+ disabled: !Dr || Q,
6292
+ onClick: ar
6270
6293
  },
6271
6294
  { separator: !0 },
6272
6295
  {
6273
6296
  id: "undo",
6274
6297
  label: Z.contextMenu.undo,
6275
6298
  shortcut: "⌘Z",
6276
- disabled: Q || !kn() && !J.canUndo(),
6299
+ disabled: Q || !jn() && !J.canUndo(),
6277
6300
  onClick: () => {
6278
- Dn() || J.undo();
6301
+ kn() || J.undo();
6279
6302
  }
6280
6303
  },
6281
6304
  {
6282
6305
  id: "redo",
6283
6306
  label: Z.contextMenu.redo,
6284
6307
  shortcut: "⇧⌘Z",
6285
- disabled: Q || !An() && !J.canRedo(),
6308
+ disabled: Q || !Mn() && !J.canRedo(),
6286
6309
  onClick: () => {
6287
- On() || J.redo();
6310
+ An() || J.redo();
6288
6311
  }
6289
6312
  },
6290
6313
  { separator: !0 },
@@ -6292,50 +6315,50 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6292
6315
  id: "selectAll",
6293
6316
  label: Z.contextMenu.selectAll,
6294
6317
  shortcut: "⌘A",
6295
- onClick: Jn
6318
+ onClick: Xn
6296
6319
  },
6297
6320
  {
6298
6321
  id: "clearSelection",
6299
6322
  label: Z.contextMenu.clearSelection,
6300
- disabled: !Cr,
6301
- onClick: Yn
6323
+ disabled: !Er,
6324
+ onClick: Zn
6302
6325
  },
6303
6326
  {
6304
6327
  id: "zoomToSelection",
6305
6328
  label: Z.contextMenu.zoomToSelection,
6306
- disabled: !Cr,
6307
- onClick: lr
6329
+ disabled: !Er,
6330
+ onClick: dr
6308
6331
  }
6309
- ], jr = c ? Ar.filter((e) => "separator" in e || !!e.id && ei.has(e.id)) : Ar, Mr = A ? A(jr, {
6332
+ ], Pr = c ? Nr.filter((e) => "separator" in e || !!e.id && ei.has(e.id)) : Nr, Fr = A ? A(Pr, {
6310
6333
  selectedIds: Y,
6311
6334
  readOnly: Q
6312
- }) : jr, Nr = qr({
6313
- engineRef: U,
6314
- image: W,
6335
+ }) : Pr, Ir = qr({
6336
+ engineRef: W,
6337
+ image: G,
6315
6338
  wheelZoom: X.wheelZoom,
6316
6339
  minimapSize: 204
6317
- }), Pr = w(() => {
6318
- U.current?.zoom100();
6319
- }, []), Fr = w(() => {
6340
+ }), Lr = w(() => {
6341
+ W.current?.zoom100();
6342
+ }, []), Rr = w(() => {
6320
6343
  ze((e) => !e);
6321
- }, []), Ir = w(() => {
6344
+ }, []), zr = w(() => {
6322
6345
  He((e) => !e);
6323
- }, []), Lr = w(() => {
6346
+ }, []), Br = w(() => {
6324
6347
  He(!1);
6325
6348
  }, []);
6326
6349
  return /* @__PURE__ */ S("div", {
6327
6350
  className: "aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black",
6328
6351
  children: [
6329
6352
  /* @__PURE__ */ x("div", {
6330
- ref: Te,
6353
+ ref: we,
6331
6354
  role: "application",
6332
6355
  "aria-label": Z.canvasLabel,
6333
6356
  tabIndex: 0,
6334
6357
  onPointerDownCapture: (e) => e.currentTarget.focus({ preventScroll: !0 }),
6335
6358
  className: "aivex:h-full aivex:w-full",
6336
6359
  style: {
6337
- opacity: +!!je,
6338
- transition: je ? "opacity 0.3s ease" : "none"
6360
+ opacity: +!!Ae,
6361
+ transition: Ae ? "opacity 0.3s ease" : "none"
6339
6362
  }
6340
6363
  }),
6341
6364
  rt !== "ready" && /* @__PURE__ */ x($e, {
@@ -6347,37 +6370,37 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6347
6370
  errorLabel: Z.imageLoadError,
6348
6371
  errorHints: Z.imageErrorHints
6349
6372
  }),
6350
- G && W && /* @__PURE__ */ x("div", {
6373
+ Me && G && /* @__PURE__ */ x("div", {
6351
6374
  className: "aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden",
6352
6375
  children: /* @__PURE__ */ S("div", {
6353
- ref: De,
6376
+ ref: Ee,
6354
6377
  style: {
6355
6378
  position: "absolute",
6356
6379
  top: 0,
6357
6380
  left: 0,
6358
- width: W.w,
6359
- height: W.h,
6381
+ width: G.w,
6382
+ height: G.h,
6360
6383
  transformOrigin: "0 0"
6361
6384
  },
6362
6385
  children: [
6363
- !!ie?.length && ae && /* @__PURE__ */ x("div", {
6386
+ !!re?.length && ie && /* @__PURE__ */ x("div", {
6364
6387
  style: {
6365
6388
  position: "absolute",
6366
6389
  left: 0,
6367
6390
  top: 0,
6368
- width: W.w,
6369
- height: W.h,
6391
+ width: G.w,
6392
+ height: G.h,
6370
6393
  pointerEvents: "none"
6371
6394
  },
6372
- children: ie.map((e) => /* @__PURE__ */ x("div", {
6395
+ children: re.map((e) => /* @__PURE__ */ x("div", {
6373
6396
  role: e.disabled ? void 0 : "button",
6374
6397
  tabIndex: e.disabled ? void 0 : 0,
6375
6398
  "aria-pressed": e.selected || void 0,
6376
6399
  onClick: (t) => {
6377
- t.stopPropagation(), e.disabled || se?.(e);
6400
+ t.stopPropagation(), e.disabled || oe?.(e);
6378
6401
  },
6379
6402
  onKeyDown: (t) => {
6380
- e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), se?.(e));
6403
+ e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), oe?.(e));
6381
6404
  },
6382
6405
  style: {
6383
6406
  position: "absolute",
@@ -6389,26 +6412,26 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6389
6412
  pointerEvents: e.disabled ? "none" : "auto",
6390
6413
  cursor: e.disabled ? "default" : "pointer"
6391
6414
  },
6392
- children: ae(e)
6415
+ children: ie(e)
6393
6416
  }, e.id))
6394
6417
  }),
6395
- ce?.({
6396
- image: W,
6397
- viewport: U.current?.viewport ?? {
6418
+ se?.({
6419
+ image: G,
6420
+ viewport: W.current?.viewport ?? {
6398
6421
  scale: 1,
6399
6422
  x: 0,
6400
6423
  y: 0
6401
6424
  }
6402
6425
  }),
6403
- Sr.length > 0 && /* @__PURE__ */ x(wt, {
6404
- shapes: Sr,
6405
- getLabel: B,
6406
- hideDot: V,
6407
- formatInfo: H,
6408
- register: pn
6426
+ Tr.length > 0 && /* @__PURE__ */ x(wt, {
6427
+ shapes: Tr,
6428
+ getLabel: V,
6429
+ hideDot: H,
6430
+ formatInfo: U,
6431
+ register: hn
6409
6432
  }),
6410
- de && ($.status === "loading" || $.boxes.length > 0) && /* @__PURE__ */ x(Ye, {
6411
- image: W,
6433
+ ue && ($.status === "loading" || $.boxes.length > 0) && /* @__PURE__ */ x(Ye, {
6434
+ image: G,
6412
6435
  points: $.points,
6413
6436
  boxes: $.boxes,
6414
6437
  status: $.status
@@ -6416,38 +6439,38 @@ function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6416
6439
  ]
6417
6440
  })
6418
6441
  }),
6419
- G && X.showCursorGuide && /* @__PURE__ */ x(Qe, { color: "#1e88e5" }),
6420
- W && y && /* @__PURE__ */ x(ht, {
6421
- image: W,
6442
+ Me && X.showCursorGuide && /* @__PURE__ */ x(Qe, { color: "#1e88e5" }),
6443
+ G && y && /* @__PURE__ */ x(ht, {
6444
+ image: G,
6422
6445
  imageUrl: et,
6423
- imageVisible: je,
6424
- loading: !G,
6446
+ imageVisible: Ae,
6447
+ loading: !Me,
6425
6448
  region: Ct,
6426
- roiMaskId: ke,
6427
- shapes: mr,
6449
+ roiMaskId: Oe,
6450
+ shapes: gr,
6428
6451
  view: X,
6429
6452
  viewDefaults: pt,
6430
6453
  onChangeView: _t,
6431
- nav: Nr,
6432
- registerShape: sn,
6433
- rectRef: Ee,
6434
- zoomLabelRef: Oe,
6435
- onZoom100: Pr,
6454
+ nav: Ir,
6455
+ registerShape: un,
6456
+ rectRef: Te,
6457
+ zoomLabelRef: De,
6458
+ onZoom100: Lr,
6436
6459
  open: Re,
6437
- onToggleOpen: Fr,
6460
+ onToggleOpen: Rr,
6438
6461
  position: b,
6439
6462
  labels: Z.minimap,
6440
6463
  settingsLabels: Z.viewSettings,
6441
6464
  settingsItems: P,
6442
6465
  showSettings: C,
6443
6466
  settingsOpen: K,
6444
- onToggleSettings: Ir,
6445
- onCloseSettings: Lr
6467
+ onToggleSettings: zr,
6468
+ onCloseSettings: Br
6446
6469
  }),
6447
6470
  Pe && /* @__PURE__ */ x(Ze, {
6448
6471
  x: Pe.x,
6449
6472
  y: Pe.y,
6450
- items: Mr,
6473
+ items: Fr,
6451
6474
  onClose: () => Fe(null)
6452
6475
  })
6453
6476
  ]
@@ -6468,18 +6491,18 @@ function ii(e, t, n, r) {
6468
6491
  strokeWidth: r,
6469
6492
  pointRadius: 2
6470
6493
  });
6471
- if (e.save(), e.globalAlpha = i.opacity, e.lineWidth = i.strokeWidth / n, e.lineJoin = "round", e.lineCap = "round", t.type === L.POINT) {
6494
+ if (e.save(), e.globalAlpha = i.opacity, e.lineWidth = i.strokeWidth / n, e.lineJoin = "round", e.lineCap = "round", t.type === R.POINT) {
6472
6495
  let r = t.points[0];
6473
6496
  r && (e.fillStyle = i.color, e.beginPath(), e.arc(r.x, r.y, i.pointRadius / n, 0, Math.PI * 2), e.fill()), e.restore();
6474
6497
  return;
6475
6498
  }
6476
- if (t.type === L.RECTANGLE || t.type === L.ELLIPSE) {
6499
+ if (t.type === R.RECTANGLE || t.type === R.ELLIPSE) {
6477
6500
  let [n, r] = t.points;
6478
6501
  if (n && r) {
6479
6502
  let i = Math.min(n.x, r.x), a = Math.min(n.y, r.y), o = Math.abs(r.x - n.x), s = Math.abs(r.y - n.y);
6480
- e.beginPath(), t.type === L.ELLIPSE ? e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2) : e.rect(i, a, o, s);
6503
+ e.beginPath(), t.type === R.ELLIPSE ? e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2) : e.rect(i, a, o, s);
6481
6504
  }
6482
- } else ri(e, t.points, t.type !== L.LINE);
6505
+ } else ri(e, t.points, t.type !== R.LINE);
6483
6506
  i.fillVisible && (e.save(), e.fillStyle = i.color, e.globalAlpha *= i.fillAlpha, e.fill("evenodd"), e.restore()), t.style?.alternateColor && i.dash?.length && (e.setLineDash([]), e.strokeStyle = t.style.alternateColor, e.stroke()), e.setLineDash((i.dash ?? []).map((e) => e / n)), e.strokeStyle = i.color, e.stroke(), e.restore();
6484
6507
  }
6485
6508
  function ai({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes: r = [], regionMask: i, focusedShapeId: a, focusFit: o = "contain", zoomPadding: s = .3, strokeSize: c = 1, brightness: l = 1, contrast: u = 1, imageSmoothing: d = !0, lazy: f = !0, className: p, style: m, renderImageState: h }) {
@@ -6537,7 +6560,7 @@ function ai({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6537
6560
  if (!y || !b) return;
6538
6561
  let x = Math.min(f / y, p / b), S = (f - y * x) / 2, w = (p - b * x) / 2;
6539
6562
  if (N && N.points.length > 0) {
6540
- let e = H(N.points), t = Math.max(e.maxX - e.minX, 50), n = Math.max(e.maxY - e.minY, 50), r = Math.min(t, n) * s;
6563
+ let e = U(N.points), t = Math.max(e.maxX - e.minX, 50), n = Math.max(e.maxY - e.minY, 50), r = Math.min(t, n) * s;
6541
6564
  x = Math.min(f / (t + r * 2), p / (n + r * 2)), o === "cover" && (x = Math.max(x, Math.max(f / y, p / b))), S = f / 2 - (e.minX + e.maxX) / 2 * x, w = p / 2 - (e.minY + e.maxY) / 2 * x, o === "cover" && (S = Math.min(0, Math.max(S, f - y * x)), w = Math.min(0, Math.max(w, p - b * x)));
6542
6565
  }
6543
6566
  h.setTransform(m, 0, 0, m, 0, 0), h.clearRect(0, 0, f, p), h.save(), h.translate(S, w), h.scale(x, x), h.imageSmoothingEnabled = d;
@@ -6559,7 +6582,7 @@ function ai({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6559
6582
  };
6560
6583
  e(E.visibleOutline, E.outlineStyles.visible), e(E.occludedOutline, E.outlineStyles.occluded);
6561
6584
  }
6562
- for (let e of ce(r)) ii(h, e, x, c);
6585
+ for (let e of se(r)) ii(h, e, x, c);
6563
6586
  h.restore();
6564
6587
  }, [
6565
6588
  l,
@@ -6640,6 +6663,6 @@ function ai({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6640
6663
  });
6641
6664
  }
6642
6665
  //#endregion
6643
- export { K as DEFAULT_EDITOR_STRINGS, Ve as DEFAULT_VIEW_SETTINGS, L as SHAPE_TYPE, ni as ShapeEditor, ni as default, ai as ShapeViewer, q as TOOL, He as VIEW_SETTING_RANGES, We as clampViewSettings, le as generateId };
6666
+ export { K as DEFAULT_EDITOR_STRINGS, Ve as DEFAULT_VIEW_SETTINGS, R as SHAPE_TYPE, ni as ShapeEditor, ni as default, ai as ShapeViewer, q as TOOL, He as VIEW_SETTING_RANGES, We as clampViewSettings, ce as generateId };
6644
6667
 
6645
6668
  //# sourceMappingURL=shape-editor.js.map