@aivex/ui 1.2.0-dev.4 → 1.2.0-dev.5
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.
- package/dist/components/ShapeEditor/ShapeEditor.d.ts +1 -1
- package/dist/components/ShapeEditor/_model/keymap.d.ts +1 -1
- package/dist/components/ShapeEditor/_model/props.d.ts +22 -6
- package/dist/components/ShapeEditor/_model/strings.d.ts +0 -2
- package/dist/components/ShapeEditor/_renderers/KonvaRenderer.d.ts +7 -1
- package/dist/components/ShapeEditor/_renderers/PixiRenderer.d.ts +7 -1
- package/dist/components/ShapeEditor/_renderers/types.d.ts +13 -1
- package/dist/components/ShapeEditor/_state/useEngineLifecycle.d.ts +11 -1
- package/dist/components/ShapeEditor/_state/useSelectionActions.d.ts +1 -2
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +1199 -1225
- package/dist/shape-editor.js.map +1 -1
- package/package.json +1 -1
package/dist/shape-editor.js
CHANGED
|
@@ -27,10 +27,10 @@ function P(e) {
|
|
|
27
27
|
function ee(e) {
|
|
28
28
|
return P(e) && !e.readOnly && e.interaction?.editable !== !1;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function te(e) {
|
|
31
31
|
return ee(e) && e.interaction?.draggable !== !1;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function ne(e) {
|
|
34
34
|
return e.map((e, t) => ({
|
|
35
35
|
shape: e,
|
|
36
36
|
index: t
|
|
@@ -39,10 +39,10 @@ function te(e) {
|
|
|
39
39
|
return n === r ? e.index - t.index : n - r;
|
|
40
40
|
}).map((e) => e.shape);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function re() {
|
|
43
43
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `id_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
44
44
|
}
|
|
45
|
-
var
|
|
45
|
+
var F = [
|
|
46
46
|
"tl",
|
|
47
47
|
"t",
|
|
48
48
|
"tr",
|
|
@@ -52,7 +52,7 @@ var I = [
|
|
|
52
52
|
"bl",
|
|
53
53
|
"l"
|
|
54
54
|
];
|
|
55
|
-
function
|
|
55
|
+
function I(e) {
|
|
56
56
|
let t = e.map((e) => e.x), n = e.map((e) => e.y);
|
|
57
57
|
return {
|
|
58
58
|
minX: Math.min(...t),
|
|
@@ -61,33 +61,33 @@ function L(e) {
|
|
|
61
61
|
maxY: Math.max(...n)
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function ie(e, t) {
|
|
65
65
|
let n = (t.minX + t.maxX) / 2, r = (t.minY + t.maxY) / 2;
|
|
66
66
|
return {
|
|
67
67
|
x: e.includes("l") ? t.minX : e.includes("r") ? t.maxX : n,
|
|
68
68
|
y: e.includes("t") ? t.minY : e.includes("b") ? t.maxY : r
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function ae(e, t, n, r) {
|
|
72
72
|
let i = { ...t };
|
|
73
73
|
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;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function oe(e, t) {
|
|
76
76
|
let n = t.x - e.x, r = t.y - e.y, i = Math.max(Math.abs(n), Math.abs(r));
|
|
77
77
|
return {
|
|
78
78
|
x: e.x + (n < 0 ? -i : i),
|
|
79
79
|
y: e.y + (r < 0 ? -i : i)
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function L(e, t, n) {
|
|
83
83
|
let r = Math.cos(n), i = Math.sin(n), a = e.x - t.x, o = e.y - t.y;
|
|
84
84
|
return {
|
|
85
85
|
x: t.x + a * r - o * i,
|
|
86
86
|
y: t.y + a * i + o * r
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
let t =
|
|
89
|
+
function R(e) {
|
|
90
|
+
let t = I(e);
|
|
91
91
|
return [
|
|
92
92
|
{
|
|
93
93
|
x: t.minX,
|
|
@@ -107,7 +107,7 @@ function z(e) {
|
|
|
107
107
|
}
|
|
108
108
|
];
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function z(e, t, n = 32) {
|
|
111
111
|
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;
|
|
112
112
|
return Array.from({ length: n }, (e, t) => {
|
|
113
113
|
let s = t / n * 2 * Math.PI;
|
|
@@ -117,7 +117,7 @@ function B(e, t, n = 32) {
|
|
|
117
117
|
};
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function se(e) {
|
|
121
121
|
let t = [...e].sort((e, t) => e.x - t.x || e.y - t.y);
|
|
122
122
|
if (t.length <= 2) return t;
|
|
123
123
|
let n = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), r = [];
|
|
@@ -133,10 +133,10 @@ function oe(e) {
|
|
|
133
133
|
}
|
|
134
134
|
return r.pop(), i.pop(), r.concat(i);
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
let t =
|
|
138
|
-
if (t.length < 3) return
|
|
139
|
-
let n = Infinity, r =
|
|
136
|
+
function ce(e) {
|
|
137
|
+
let t = se(e);
|
|
138
|
+
if (t.length < 3) return R(e);
|
|
139
|
+
let n = Infinity, r = R(e);
|
|
140
140
|
for (let e = 0; e < t.length; e++) {
|
|
141
141
|
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;
|
|
142
142
|
for (let e of t) {
|
|
@@ -160,19 +160,19 @@ function se(e) {
|
|
|
160
160
|
}
|
|
161
161
|
return r;
|
|
162
162
|
}
|
|
163
|
-
var
|
|
163
|
+
var B = (e, t) => ({
|
|
164
164
|
x: e.x - t.x,
|
|
165
165
|
y: e.y - t.y
|
|
166
|
-
}),
|
|
167
|
-
let t =
|
|
166
|
+
}), le = (e, t) => e.x * t.x + e.y * t.y, ue = (e) => Math.hypot(e.x, e.y), de = (e) => {
|
|
167
|
+
let t = ue(e) || 1;
|
|
168
168
|
return {
|
|
169
169
|
x: e.x / t,
|
|
170
170
|
y: e.y / t
|
|
171
171
|
};
|
|
172
|
-
},
|
|
172
|
+
}, fe = (e, t) => ({
|
|
173
173
|
x: (e.x + t.x) / 2,
|
|
174
174
|
y: (e.y + t.y) / 2
|
|
175
|
-
}),
|
|
175
|
+
}), pe = (e) => {
|
|
176
176
|
let t = e.reduce((e, t) => ({
|
|
177
177
|
x: e.x + t.x,
|
|
178
178
|
y: e.y + t.y
|
|
@@ -185,26 +185,26 @@ var V = (e, t) => ({
|
|
|
185
185
|
y: t.y / e.length
|
|
186
186
|
};
|
|
187
187
|
};
|
|
188
|
-
function
|
|
188
|
+
function me(e) {
|
|
189
189
|
return [
|
|
190
190
|
e[0],
|
|
191
|
-
|
|
191
|
+
fe(e[0], e[1]),
|
|
192
192
|
e[1],
|
|
193
|
-
|
|
193
|
+
fe(e[1], e[2]),
|
|
194
194
|
e[2],
|
|
195
|
-
|
|
195
|
+
fe(e[2], e[3]),
|
|
196
196
|
e[3],
|
|
197
|
-
|
|
197
|
+
fe(e[3], e[0])
|
|
198
198
|
];
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
let n =
|
|
200
|
+
function he(e, t) {
|
|
201
|
+
let n = fe(e[0], e[1]), r = de(B(e[0], e[3]));
|
|
202
202
|
return {
|
|
203
203
|
x: n.x + r.x * t,
|
|
204
204
|
y: n.y + r.y * t
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function ge(e, t, n, r) {
|
|
208
208
|
let i = (e, i) => ({
|
|
209
209
|
x: t.x + e * n.x + i * r.x,
|
|
210
210
|
y: t.y + e * n.y + i * r.y
|
|
@@ -216,17 +216,17 @@ function he(e, t, n, r) {
|
|
|
216
216
|
i(e.minX, e.maxY)
|
|
217
217
|
];
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function _e(e, t, n) {
|
|
220
220
|
if (e.length < 4) return e;
|
|
221
|
-
let r = e[0], i =
|
|
222
|
-
return
|
|
221
|
+
let r = e[0], i = de(B(e[1], e[0])), a = de(B(e[3], e[0])), o = le(B(e[1], r), i), s = le(B(e[3], r), a), c = B(n, r);
|
|
222
|
+
return ge(ae(t, {
|
|
223
223
|
minX: 0,
|
|
224
224
|
minY: 0,
|
|
225
225
|
maxX: o,
|
|
226
226
|
maxY: s
|
|
227
|
-
},
|
|
227
|
+
}, le(c, i), le(c, a)), r, i, a);
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function ve(e, t, n) {
|
|
230
230
|
let r = t.maxX - t.minX || 1, i = t.maxY - t.minY || 1, a = n.maxX - n.minX, o = n.maxY - n.minY;
|
|
231
231
|
return e.map((e) => ({
|
|
232
232
|
x: n.minX + (e.x - t.minX) / r * a,
|
|
@@ -235,7 +235,7 @@ function _e(e, t, n) {
|
|
|
235
235
|
}
|
|
236
236
|
//#endregion
|
|
237
237
|
//#region src/components/ShapeEditor/_model/strings.ts
|
|
238
|
-
var
|
|
238
|
+
var V = {
|
|
239
239
|
contextMenu: {
|
|
240
240
|
copy: "복사",
|
|
241
241
|
paste: "붙여넣기",
|
|
@@ -243,8 +243,6 @@ var H = {
|
|
|
243
243
|
delete: "삭제",
|
|
244
244
|
bringToFront: "맨 앞으로",
|
|
245
245
|
sendToBack: "맨 뒤로",
|
|
246
|
-
flipHorizontal: "좌우 반전",
|
|
247
|
-
flipVertical: "상하 반전",
|
|
248
246
|
editVertices: "정점 편집",
|
|
249
247
|
merge: "레이블 합치기",
|
|
250
248
|
assistExpand: "이 지점 포함하기",
|
|
@@ -279,27 +277,27 @@ var H = {
|
|
|
279
277
|
imageLoading: "이미지를 불러오는 중…",
|
|
280
278
|
imageLoadError: "이미지를 불러올 수 없습니다"
|
|
281
279
|
};
|
|
282
|
-
function
|
|
280
|
+
function ye(e) {
|
|
283
281
|
return e ? {
|
|
284
282
|
contextMenu: {
|
|
285
|
-
...
|
|
283
|
+
...V.contextMenu,
|
|
286
284
|
...e.contextMenu
|
|
287
285
|
},
|
|
288
286
|
viewSettings: {
|
|
289
|
-
...
|
|
287
|
+
...V.viewSettings,
|
|
290
288
|
...e.viewSettings
|
|
291
289
|
},
|
|
292
290
|
minimap: {
|
|
293
|
-
...
|
|
291
|
+
...V.minimap,
|
|
294
292
|
...e.minimap
|
|
295
293
|
},
|
|
296
|
-
imageLoading: e.imageLoading ??
|
|
297
|
-
imageLoadError: e.imageLoadError ??
|
|
298
|
-
} :
|
|
294
|
+
imageLoading: e.imageLoading ?? V.imageLoading,
|
|
295
|
+
imageLoadError: e.imageLoadError ?? V.imageLoadError
|
|
296
|
+
} : V;
|
|
299
297
|
}
|
|
300
298
|
//#endregion
|
|
301
299
|
//#region src/components/ShapeEditor/_model/tools.ts
|
|
302
|
-
var
|
|
300
|
+
var H = {
|
|
303
301
|
SELECT: "SELECT",
|
|
304
302
|
POLYGON: "POLYGON",
|
|
305
303
|
PATH: "PATH",
|
|
@@ -311,7 +309,7 @@ var U = {
|
|
|
311
309
|
ASSISTANT_POLYGON: "ASSISTANT_POLYGON",
|
|
312
310
|
ASSISTANT_RECT: "ASSISTANT_RECT",
|
|
313
311
|
ASSISTANT_POINT: "ASSISTANT_POINT"
|
|
314
|
-
},
|
|
312
|
+
}, be = {
|
|
315
313
|
brightness: 1,
|
|
316
314
|
contrast: 1,
|
|
317
315
|
showCursorGuide: !1,
|
|
@@ -322,9 +320,9 @@ var U = {
|
|
|
322
320
|
showRegionMask: !0,
|
|
323
321
|
keepZoomOnImageChange: !1,
|
|
324
322
|
wheelZoom: !0
|
|
325
|
-
},
|
|
326
|
-
function
|
|
327
|
-
let t = e.positive ?
|
|
323
|
+
}, xe = "var(--editor-overlay-inverse-scale, 1)", Se = "#377be2", Ce = "#e23c3c";
|
|
324
|
+
function we({ point: e }) {
|
|
325
|
+
let t = e.positive ? Se : Ce;
|
|
328
326
|
return /* @__PURE__ */ x("div", {
|
|
329
327
|
style: {
|
|
330
328
|
position: "absolute",
|
|
@@ -345,13 +343,13 @@ function Ce({ point: e }) {
|
|
|
345
343
|
display: "flex",
|
|
346
344
|
alignItems: "center",
|
|
347
345
|
justifyContent: "center",
|
|
348
|
-
transform: `scale(${
|
|
346
|
+
transform: `scale(${xe})`,
|
|
349
347
|
transformOrigin: "center"
|
|
350
348
|
},
|
|
351
349
|
children: e.positive ? "+" : "−"
|
|
352
350
|
});
|
|
353
351
|
}
|
|
354
|
-
function
|
|
352
|
+
function Te({ image: e, points: t, boxes: n, status: r }) {
|
|
355
353
|
return /* @__PURE__ */ S("div", {
|
|
356
354
|
style: {
|
|
357
355
|
position: "absolute",
|
|
@@ -375,13 +373,13 @@ function we({ image: e, points: t, boxes: n, status: r }) {
|
|
|
375
373
|
backgroundSize: "200% 100%",
|
|
376
374
|
animation: "editorv2-assistant-shimmer 1.4s linear infinite"
|
|
377
375
|
} }, `box-${t}-${e.x}-${e.y}-${e.width}-${e.height}`)),
|
|
378
|
-
r === "loading" && t.map((e, t) => /* @__PURE__ */ x(
|
|
376
|
+
r === "loading" && t.map((e, t) => /* @__PURE__ */ x(we, { point: e }, `pt-${t}-${e.x}-${e.y}`))
|
|
379
377
|
]
|
|
380
378
|
});
|
|
381
379
|
}
|
|
382
380
|
//#endregion
|
|
383
381
|
//#region src/components/ShapeEditor/_components/ContextMenu.tsx
|
|
384
|
-
function
|
|
382
|
+
function Ee(e) {
|
|
385
383
|
let t = [];
|
|
386
384
|
for (let n of e) if ("separator" in n) {
|
|
387
385
|
if (!t.length || "separator" in t[t.length - 1]) continue;
|
|
@@ -390,8 +388,8 @@ function Te(e) {
|
|
|
390
388
|
for (; t.length && "separator" in t[t.length - 1];) t.pop();
|
|
391
389
|
return t;
|
|
392
390
|
}
|
|
393
|
-
function
|
|
394
|
-
let i =
|
|
391
|
+
function De({ x: e, y: t, items: n, onClose: r }) {
|
|
392
|
+
let i = Ee(n);
|
|
395
393
|
return /* @__PURE__ */ S(c, {
|
|
396
394
|
open: !0,
|
|
397
395
|
modal: !1,
|
|
@@ -442,7 +440,7 @@ function Ee({ x: e, y: t, items: n, onClose: r }) {
|
|
|
442
440
|
}
|
|
443
441
|
//#endregion
|
|
444
442
|
//#region src/components/ShapeEditor/_components/CursorGuide.tsx
|
|
445
|
-
function
|
|
443
|
+
function Oe({ color: e = "#1e88e5" }) {
|
|
446
444
|
let t = v(null), n = v(null), r = v(null);
|
|
447
445
|
return f(() => {
|
|
448
446
|
let e = t.current, i = n.current, a = r.current;
|
|
@@ -492,7 +490,7 @@ function De({ color: e = "#1e88e5" }) {
|
|
|
492
490
|
}
|
|
493
491
|
//#endregion
|
|
494
492
|
//#region src/components/ShapeEditor/_components/ImageStateOverlay.tsx
|
|
495
|
-
function
|
|
493
|
+
function ke({ status: e, render: t, loadingLabel: n = V.imageLoading, errorLabel: r = V.imageLoadError }) {
|
|
496
494
|
return /* @__PURE__ */ x("div", {
|
|
497
495
|
"data-track-id": e === "loading" ? "editor-image-loading-wrap" : "editor-image-error-wrap",
|
|
498
496
|
style: {
|
|
@@ -545,11 +543,11 @@ function Oe({ status: e, render: t, loadingLabel: n = H.imageLoading, errorLabel
|
|
|
545
543
|
});
|
|
546
544
|
}
|
|
547
545
|
Math.PI / 12;
|
|
548
|
-
var
|
|
546
|
+
var Ae = "#669DEF", je = .1, Me = .7, Ne = 2.5;
|
|
549
547
|
//#endregion
|
|
550
548
|
//#region src/components/ShapeEditor/_model/shapeRenderStyle.ts
|
|
551
|
-
function
|
|
552
|
-
let n = e.style?.color ?? "#00e5ff", r = !!e.readOnly, i = e.style?.strokeWidth ?? t.strokeWidth ?? 2, a = r ? i *
|
|
549
|
+
function Pe(e, t = {}) {
|
|
550
|
+
let n = e.style?.color ?? "#00e5ff", r = !!e.readOnly, i = e.style?.strokeWidth ?? t.strokeWidth ?? 2, a = r ? i * Ne : i, o = r ? Me : e.style?.opacity ?? 1, s = e.style?.fillOpacity ?? .12549019607843137, c = e.style?.dash ?? (r ? [a, a * 2] : void 0);
|
|
553
551
|
return {
|
|
554
552
|
color: n,
|
|
555
553
|
strokeWidth: a,
|
|
@@ -560,7 +558,7 @@ function W(e, t = {}) {
|
|
|
560
558
|
pointRadius: e.style?.pointRadius ?? t.pointRadius ?? 5
|
|
561
559
|
};
|
|
562
560
|
}
|
|
563
|
-
function
|
|
561
|
+
function U(e, t) {
|
|
564
562
|
let n = Math.max(0, Math.min(1, t)), r = e.trim().replace("#", "");
|
|
565
563
|
if (r.length === 3 || r.length === 6) {
|
|
566
564
|
let e = r.length === 3 ? r.replace(/./g, (e) => e + e) : r, t = Number.parseInt(e, 16);
|
|
@@ -570,8 +568,8 @@ function Ne(e, t) {
|
|
|
570
568
|
}
|
|
571
569
|
//#endregion
|
|
572
570
|
//#region src/components/ShapeEditor/_components/MinimapShape.tsx
|
|
573
|
-
function
|
|
574
|
-
let { type: r, points: i } = e, a =
|
|
571
|
+
function Fe({ shape: e, strokeSize: t, register: n }) {
|
|
572
|
+
let { type: r, points: i } = e, a = Pe(e, { strokeWidth: t }), o = (t) => n?.(e.id, t), s = {
|
|
575
573
|
ref: o,
|
|
576
574
|
stroke: a.color,
|
|
577
575
|
strokeWidth: a.strokeWidth,
|
|
@@ -590,7 +588,7 @@ function Pe({ shape: e, strokeSize: t, register: n }) {
|
|
|
590
588
|
opacity: a.opacity
|
|
591
589
|
});
|
|
592
590
|
if (r === j.RECTANGLE || r === j.ELLIPSE) {
|
|
593
|
-
let e =
|
|
591
|
+
let e = I(i);
|
|
594
592
|
return r === j.ELLIPSE ? /* @__PURE__ */ x("ellipse", {
|
|
595
593
|
cx: (e.minX + e.maxX) / 2,
|
|
596
594
|
cy: (e.minY + e.maxY) / 2,
|
|
@@ -616,7 +614,7 @@ function Pe({ shape: e, strokeSize: t, register: n }) {
|
|
|
616
614
|
}
|
|
617
615
|
//#endregion
|
|
618
616
|
//#region src/components/ShapeEditor/_components/RegionOverlay.tsx
|
|
619
|
-
function
|
|
617
|
+
function Ie({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth: a, strokeDasharray: o, style: s }) {
|
|
620
618
|
let c = [...t.visibleOutline, ...t.occludedOutline];
|
|
621
619
|
return /* @__PURE__ */ S("svg", {
|
|
622
620
|
width: r,
|
|
@@ -670,11 +668,11 @@ function Fe({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth:
|
|
|
670
668
|
}
|
|
671
669
|
//#endregion
|
|
672
670
|
//#region src/components/ShapeEditor/_components/SettingsPanel.tsx
|
|
673
|
-
var
|
|
671
|
+
var Le = {
|
|
674
672
|
trackRootClassName: "aivex:h-1.5",
|
|
675
673
|
thumbClassName: "aivex:h-4 aivex:w-4 aivex:border"
|
|
676
674
|
};
|
|
677
|
-
function
|
|
675
|
+
function Re({ value: e, onChange: t, onClose: n, labels: r = V.viewSettings }) {
|
|
678
676
|
return f(() => {
|
|
679
677
|
let e = (e) => {
|
|
680
678
|
e.key === "Escape" && n();
|
|
@@ -694,11 +692,11 @@ function G({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
694
692
|
}), /* @__PURE__ */ x(a, {
|
|
695
693
|
variant: "ghost",
|
|
696
694
|
size: "sm",
|
|
697
|
-
onClick: () => t({ ...
|
|
695
|
+
onClick: () => t({ ...be }),
|
|
698
696
|
children: r.reset
|
|
699
697
|
})]
|
|
700
698
|
}),
|
|
701
|
-
/* @__PURE__ */ x(
|
|
699
|
+
/* @__PURE__ */ x(W, {
|
|
702
700
|
label: `${r.brightness} ${e.brightness.toFixed(2)}`,
|
|
703
701
|
children: /* @__PURE__ */ x(l, {
|
|
704
702
|
min: 0,
|
|
@@ -706,10 +704,10 @@ function G({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
706
704
|
step: .05,
|
|
707
705
|
value: [e.brightness],
|
|
708
706
|
onValueChange: ([e]) => t({ brightness: e }),
|
|
709
|
-
...
|
|
707
|
+
...Le
|
|
710
708
|
})
|
|
711
709
|
}),
|
|
712
|
-
/* @__PURE__ */ x(
|
|
710
|
+
/* @__PURE__ */ x(W, {
|
|
713
711
|
label: `${r.contrast} ${e.contrast.toFixed(2)}`,
|
|
714
712
|
children: /* @__PURE__ */ x(l, {
|
|
715
713
|
min: 0,
|
|
@@ -717,10 +715,10 @@ function G({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
717
715
|
step: .05,
|
|
718
716
|
value: [e.contrast],
|
|
719
717
|
onValueChange: ([e]) => t({ contrast: e }),
|
|
720
|
-
...
|
|
718
|
+
...Le
|
|
721
719
|
})
|
|
722
720
|
}),
|
|
723
|
-
/* @__PURE__ */ x(
|
|
721
|
+
/* @__PURE__ */ x(W, {
|
|
724
722
|
label: `${r.strokeSize} ${e.strokeSize}`,
|
|
725
723
|
children: /* @__PURE__ */ x(l, {
|
|
726
724
|
min: 1,
|
|
@@ -728,10 +726,10 @@ function G({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
728
726
|
step: .5,
|
|
729
727
|
value: [e.strokeSize],
|
|
730
728
|
onValueChange: ([e]) => t({ strokeSize: e }),
|
|
731
|
-
...
|
|
729
|
+
...Le
|
|
732
730
|
})
|
|
733
731
|
}),
|
|
734
|
-
/* @__PURE__ */ x(
|
|
732
|
+
/* @__PURE__ */ x(W, {
|
|
735
733
|
label: `${r.simplifyStrength} ${e.simplifyStrength}`,
|
|
736
734
|
children: /* @__PURE__ */ x(l, {
|
|
737
735
|
min: .5,
|
|
@@ -739,39 +737,39 @@ function G({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
739
737
|
step: .5,
|
|
740
738
|
value: [e.simplifyStrength],
|
|
741
739
|
onValueChange: ([e]) => t({ simplifyStrength: e }),
|
|
742
|
-
...
|
|
740
|
+
...Le
|
|
743
741
|
})
|
|
744
742
|
}),
|
|
745
743
|
/* @__PURE__ */ x("div", {
|
|
746
744
|
className: "aivex:my-2",
|
|
747
745
|
children: /* @__PURE__ */ x(s, {})
|
|
748
746
|
}),
|
|
749
|
-
/* @__PURE__ */ x(
|
|
747
|
+
/* @__PURE__ */ x(ze, {
|
|
750
748
|
label: r.pixelation,
|
|
751
749
|
checked: !e.imageSmoothing,
|
|
752
750
|
onChange: (e) => t({ imageSmoothing: !e })
|
|
753
751
|
}),
|
|
754
|
-
/* @__PURE__ */ x(
|
|
752
|
+
/* @__PURE__ */ x(ze, {
|
|
755
753
|
label: r.cursorGuide,
|
|
756
754
|
checked: e.showCursorGuide,
|
|
757
755
|
onChange: (e) => t({ showCursorGuide: e })
|
|
758
756
|
}),
|
|
759
|
-
/* @__PURE__ */ x(
|
|
757
|
+
/* @__PURE__ */ x(ze, {
|
|
760
758
|
label: r.guideMask,
|
|
761
759
|
checked: e.showGuide,
|
|
762
760
|
onChange: (e) => t({ showGuide: e })
|
|
763
761
|
}),
|
|
764
|
-
/* @__PURE__ */ x(
|
|
762
|
+
/* @__PURE__ */ x(ze, {
|
|
765
763
|
label: r.regionMask,
|
|
766
764
|
checked: e.showRegionMask,
|
|
767
765
|
onChange: (e) => t({ showRegionMask: e })
|
|
768
766
|
}),
|
|
769
|
-
/* @__PURE__ */ x(
|
|
767
|
+
/* @__PURE__ */ x(ze, {
|
|
770
768
|
label: r.keepZoomOnImageChange,
|
|
771
769
|
checked: e.keepZoomOnImageChange,
|
|
772
770
|
onChange: (e) => t({ keepZoomOnImageChange: e })
|
|
773
771
|
}),
|
|
774
|
-
/* @__PURE__ */ x(
|
|
772
|
+
/* @__PURE__ */ x(ze, {
|
|
775
773
|
label: r.wheelZoom,
|
|
776
774
|
checked: e.wheelZoom,
|
|
777
775
|
onChange: (e) => t({ wheelZoom: e })
|
|
@@ -779,7 +777,7 @@ function G({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
779
777
|
]
|
|
780
778
|
});
|
|
781
779
|
}
|
|
782
|
-
function
|
|
780
|
+
function W({ label: e, children: t }) {
|
|
783
781
|
return /* @__PURE__ */ S("div", {
|
|
784
782
|
className: "aivex:mb-2 aivex:block",
|
|
785
783
|
children: [/* @__PURE__ */ x("span", {
|
|
@@ -788,7 +786,7 @@ function Le({ label: e, children: t }) {
|
|
|
788
786
|
}), t]
|
|
789
787
|
});
|
|
790
788
|
}
|
|
791
|
-
function
|
|
789
|
+
function ze({ label: e, checked: t, onChange: n }) {
|
|
792
790
|
return /* @__PURE__ */ S("div", {
|
|
793
791
|
className: "aivex:flex aivex:items-center aivex:justify-between aivex:py-1",
|
|
794
792
|
children: [/* @__PURE__ */ x("span", { children: e }), /* @__PURE__ */ x(u, {
|
|
@@ -800,8 +798,8 @@ function Re({ label: e, checked: t, onChange: n }) {
|
|
|
800
798
|
}
|
|
801
799
|
//#endregion
|
|
802
800
|
//#region src/components/ShapeEditor/_components/Minimap.tsx
|
|
803
|
-
function
|
|
804
|
-
let { offX: A, offY: j, dispW: N, dispH: P, zoomCentered: ee } = h,
|
|
801
|
+
function Be({ image: e, imageUrl: s, imageVisible: c = !0, maskDataUrl: l, region: u, roiMaskId: d, shapes: f, view: p, onChangeView: m, nav: h, registerShape: g, rectRef: _, zoomLabelRef: v, onZoom100: y, open: b, onToggleOpen: C, showSettings: w = !0, settingsOpen: T, onToggleSettings: E, onCloseSettings: D, labels: O = V.minimap, settingsLabels: k }) {
|
|
802
|
+
let { offX: A, offY: j, dispW: N, dispH: P, zoomCentered: ee } = h, te = {
|
|
805
803
|
position: "absolute",
|
|
806
804
|
left: A,
|
|
807
805
|
top: j,
|
|
@@ -831,20 +829,20 @@ function ze({ image: e, imageUrl: s, imageVisible: c = !0, maskDataUrl: l, regio
|
|
|
831
829
|
src: s,
|
|
832
830
|
alt: "",
|
|
833
831
|
draggable: !1,
|
|
834
|
-
style:
|
|
832
|
+
style: te
|
|
835
833
|
}),
|
|
836
834
|
l && p.showGuide && /* @__PURE__ */ x("img", {
|
|
837
835
|
src: l,
|
|
838
836
|
alt: "",
|
|
839
837
|
draggable: !1,
|
|
840
838
|
style: {
|
|
841
|
-
...
|
|
839
|
+
...te,
|
|
842
840
|
opacity: .55,
|
|
843
841
|
imageRendering: "pixelated",
|
|
844
842
|
pointerEvents: "none"
|
|
845
843
|
}
|
|
846
844
|
}),
|
|
847
|
-
p.showRegionMask && u && u.rects.length > 0 && /* @__PURE__ */ x(
|
|
845
|
+
p.showRegionMask && u && u.rects.length > 0 && /* @__PURE__ */ x(Ie, {
|
|
848
846
|
image: e,
|
|
849
847
|
region: u,
|
|
850
848
|
maskId: d,
|
|
@@ -870,7 +868,7 @@ function ze({ image: e, imageUrl: s, imageVisible: c = !0, maskDataUrl: l, regio
|
|
|
870
868
|
pointerEvents: "none"
|
|
871
869
|
},
|
|
872
870
|
"aria-hidden": !0,
|
|
873
|
-
children:
|
|
871
|
+
children: ne(f).filter(M).map((e) => /* @__PURE__ */ x(Fe, {
|
|
874
872
|
shape: e,
|
|
875
873
|
strokeSize: p.strokeSize,
|
|
876
874
|
register: g
|
|
@@ -940,7 +938,7 @@ function ze({ image: e, imageUrl: s, imageVisible: c = !0, maskDataUrl: l, regio
|
|
|
940
938
|
onClick: C,
|
|
941
939
|
children: x(b ? i : t, { size: 16 })
|
|
942
940
|
}),
|
|
943
|
-
w && T && /* @__PURE__ */ x(
|
|
941
|
+
w && T && /* @__PURE__ */ x(Re, {
|
|
944
942
|
value: p,
|
|
945
943
|
onChange: m,
|
|
946
944
|
onClose: D,
|
|
@@ -953,7 +951,7 @@ function ze({ image: e, imageUrl: s, imageVisible: c = !0, maskDataUrl: l, regio
|
|
|
953
951
|
}
|
|
954
952
|
//#endregion
|
|
955
953
|
//#region src/components/ShapeEditor/_components/SelectionInfo.tsx
|
|
956
|
-
var
|
|
954
|
+
var Ve = "var(--editor-overlay-inverse-scale, 1)", He = 6, G = {
|
|
957
955
|
fontFamily: "Pretendard, sans-serif",
|
|
958
956
|
fontSize: 12,
|
|
959
957
|
fontWeight: 500,
|
|
@@ -962,8 +960,8 @@ var Be = "var(--editor-overlay-inverse-scale, 1)", K = 6, Ve = {
|
|
|
962
960
|
textShadow: "0 0 4px #000, 0 0 4px #000",
|
|
963
961
|
whiteSpace: "nowrap"
|
|
964
962
|
};
|
|
965
|
-
function
|
|
966
|
-
let n =
|
|
963
|
+
function Ue(e, t) {
|
|
964
|
+
let n = I(t);
|
|
967
965
|
return {
|
|
968
966
|
shape: e,
|
|
969
967
|
x: n.minX,
|
|
@@ -972,10 +970,10 @@ function He(e, t) {
|
|
|
972
970
|
height: n.maxY - n.minY
|
|
973
971
|
};
|
|
974
972
|
}
|
|
975
|
-
function
|
|
973
|
+
function We(e) {
|
|
976
974
|
return `${Math.round(e.width)} x ${Math.round(e.height)} px`;
|
|
977
975
|
}
|
|
978
|
-
function
|
|
976
|
+
function Ge({ color: e, striped: t }) {
|
|
979
977
|
return /* @__PURE__ */ x("span", { style: {
|
|
980
978
|
display: "inline-block",
|
|
981
979
|
width: 12,
|
|
@@ -987,9 +985,9 @@ function We({ color: e, striped: t }) {
|
|
|
987
985
|
} : { background: e }
|
|
988
986
|
} });
|
|
989
987
|
}
|
|
990
|
-
function
|
|
988
|
+
function Ke({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
|
|
991
989
|
return /* @__PURE__ */ x(b, { children: e.map((e) => {
|
|
992
|
-
let a =
|
|
990
|
+
let a = I(e.points), o = e.type === j.POINT, s = t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.readOnly || !!e.style?.dash, u = Ue(e, e.points), d = r ? r(u) : We(u);
|
|
993
991
|
return /* @__PURE__ */ S("div", {
|
|
994
992
|
ref: (t) => i(e.id, t),
|
|
995
993
|
style: {
|
|
@@ -1008,11 +1006,11 @@ function Ge({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1008
1006
|
display: "flex",
|
|
1009
1007
|
alignItems: "center",
|
|
1010
1008
|
gap: 4,
|
|
1011
|
-
transform: `scale(${
|
|
1009
|
+
transform: `scale(${Ve}) translateY(calc(-100% - ${He}px))`,
|
|
1012
1010
|
transformOrigin: "left top",
|
|
1013
|
-
...
|
|
1011
|
+
...G
|
|
1014
1012
|
},
|
|
1015
|
-
children: [!n && /* @__PURE__ */ x(
|
|
1013
|
+
children: [!n && /* @__PURE__ */ x(Ge, {
|
|
1016
1014
|
color: c,
|
|
1017
1015
|
striped: l
|
|
1018
1016
|
}), /* @__PURE__ */ x("span", { children: s })]
|
|
@@ -1022,9 +1020,9 @@ function Ge({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1022
1020
|
position: "absolute",
|
|
1023
1021
|
right: 0,
|
|
1024
1022
|
top: "100%",
|
|
1025
|
-
transform: `scale(${
|
|
1023
|
+
transform: `scale(${Ve}) translateY(${He}px)`,
|
|
1026
1024
|
transformOrigin: "right top",
|
|
1027
|
-
...
|
|
1025
|
+
...G
|
|
1028
1026
|
},
|
|
1029
1027
|
children: d
|
|
1030
1028
|
})]
|
|
@@ -1033,18 +1031,18 @@ function Ge({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1033
1031
|
}
|
|
1034
1032
|
//#endregion
|
|
1035
1033
|
//#region src/components/ShapeEditor/_model/cursors.ts
|
|
1036
|
-
var
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
]),
|
|
1034
|
+
var qe = new Set([
|
|
1035
|
+
H.RECTANGLE,
|
|
1036
|
+
H.ROTATED_RECTANGLE,
|
|
1037
|
+
H.CIRCLE,
|
|
1038
|
+
H.POLYGON,
|
|
1039
|
+
H.PATH,
|
|
1040
|
+
H.BRUSH,
|
|
1041
|
+
H.POINT,
|
|
1042
|
+
H.ASSISTANT_POLYGON,
|
|
1043
|
+
H.ASSISTANT_RECT,
|
|
1044
|
+
H.ASSISTANT_POINT
|
|
1045
|
+
]), Je = {
|
|
1048
1046
|
tl: -135,
|
|
1049
1047
|
t: -90,
|
|
1050
1048
|
tr: -45,
|
|
@@ -1053,21 +1051,21 @@ var Ke = new Set([
|
|
|
1053
1051
|
b: 90,
|
|
1054
1052
|
bl: 135,
|
|
1055
1053
|
l: 180
|
|
1056
|
-
},
|
|
1054
|
+
}, Ye = [
|
|
1057
1055
|
"ew-resize",
|
|
1058
1056
|
"nwse-resize",
|
|
1059
1057
|
"ns-resize",
|
|
1060
1058
|
"nesw-resize"
|
|
1061
1059
|
];
|
|
1062
|
-
function
|
|
1063
|
-
let n = ((
|
|
1064
|
-
return
|
|
1060
|
+
function Xe(e, t = 0) {
|
|
1061
|
+
let n = ((Je[e] + t * 180 / Math.PI) % 180 + 180) % 180;
|
|
1062
|
+
return Ye[Math.round(n / 45) % 4];
|
|
1065
1063
|
}
|
|
1066
|
-
function
|
|
1067
|
-
return n ? "grab" : t || (e ===
|
|
1064
|
+
function Ze({ tool: e, externalToolCursor: t, isSpacePressed: n, isPolygonDrawing: r }) {
|
|
1065
|
+
return n ? "grab" : t || (e === H.SELECT ? "default" : qe.has(e) ? r ? "default" : "crosshair" : "default");
|
|
1068
1066
|
}
|
|
1069
|
-
function
|
|
1070
|
-
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e ===
|
|
1067
|
+
function Qe({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
|
|
1068
|
+
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === H.SELECT && i ? i : Ze({
|
|
1071
1069
|
tool: e,
|
|
1072
1070
|
externalToolCursor: t,
|
|
1073
1071
|
isSpacePressed: n,
|
|
@@ -1076,7 +1074,7 @@ function Ze({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode
|
|
|
1076
1074
|
}
|
|
1077
1075
|
//#endregion
|
|
1078
1076
|
//#region src/components/ShapeEditor/_model/overlays.ts
|
|
1079
|
-
var
|
|
1077
|
+
var $e = (e) => Math.min(255, Math.max(0, e)), et = (e) => {
|
|
1080
1078
|
let t = e.replace("#", "").trim();
|
|
1081
1079
|
if (![
|
|
1082
1080
|
3,
|
|
@@ -1090,13 +1088,13 @@ var Qe = (e) => Math.min(255, Math.max(0, e)), $e = (e) => {
|
|
|
1090
1088
|
c(o),
|
|
1091
1089
|
c(s)
|
|
1092
1090
|
];
|
|
1093
|
-
return l.some((e) => Number.isNaN(e)) ? null : l.map(
|
|
1094
|
-
},
|
|
1091
|
+
return l.some((e) => Number.isNaN(e)) ? null : l.map($e);
|
|
1092
|
+
}, tt = (e, t) => {
|
|
1095
1093
|
let { width: n, height: r, indices: i, transparent: a } = e;
|
|
1096
1094
|
if (!n || !r || i.length < n * r) return null;
|
|
1097
1095
|
let o = {};
|
|
1098
1096
|
for (let [e, n] of Object.entries(t)) {
|
|
1099
|
-
let t =
|
|
1097
|
+
let t = et(n);
|
|
1100
1098
|
t && (o[Number(e)] = t);
|
|
1101
1099
|
}
|
|
1102
1100
|
if (!Object.keys(o).length) return null;
|
|
@@ -1115,12 +1113,12 @@ var Qe = (e) => Math.min(255, Math.max(0, e)), $e = (e) => {
|
|
|
1115
1113
|
}
|
|
1116
1114
|
return c.putImageData(new ImageData(l, n, r), 0, 0), s;
|
|
1117
1115
|
};
|
|
1118
|
-
function
|
|
1116
|
+
function nt(e, t) {
|
|
1119
1117
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
1120
1118
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
1121
1119
|
e.closePath();
|
|
1122
1120
|
}
|
|
1123
|
-
var
|
|
1121
|
+
var rt = (e) => [
|
|
1124
1122
|
{
|
|
1125
1123
|
x: e.x,
|
|
1126
1124
|
y: e.y
|
|
@@ -1138,7 +1136,7 @@ var nt = (e) => [
|
|
|
1138
1136
|
y: e.y + e.h
|
|
1139
1137
|
}
|
|
1140
1138
|
];
|
|
1141
|
-
function
|
|
1139
|
+
function it(e, t) {
|
|
1142
1140
|
let n = !1;
|
|
1143
1141
|
for (let r = 0, i = t.length - 1; r < t.length; i = r, r += 1) {
|
|
1144
1142
|
let a = t[r], o = t[i];
|
|
@@ -1149,7 +1147,7 @@ function rt(e, t) {
|
|
|
1149
1147
|
}
|
|
1150
1148
|
return n;
|
|
1151
1149
|
}
|
|
1152
|
-
function
|
|
1150
|
+
function at(e, t, n) {
|
|
1153
1151
|
let r = [], i = t.x - e.x, a = t.y - e.y;
|
|
1154
1152
|
for (let t = 0; t < n.length; t += 1) {
|
|
1155
1153
|
let o = n[t], s = n[(t + 1) % n.length], c = s.x - o.x, l = s.y - o.y, u = i * l - a * c;
|
|
@@ -1159,15 +1157,15 @@ function q(e, t, n) {
|
|
|
1159
1157
|
}
|
|
1160
1158
|
return r;
|
|
1161
1159
|
}
|
|
1162
|
-
function
|
|
1160
|
+
function K(e, t, n) {
|
|
1163
1161
|
let r = .001, i = [], a = (e, t, n) => ({
|
|
1164
1162
|
x: e.x + (t.x - e.x) * n,
|
|
1165
1163
|
y: e.y + (t.y - e.y) * n
|
|
1166
1164
|
});
|
|
1167
1165
|
for (let o of e) if (!(o.length < 2)) for (let e = 0; e < o.length; e += 1) {
|
|
1168
1166
|
let s = o[e], c = o[(e + 1) % o.length], l = [0, 1];
|
|
1169
|
-
for (let e of t) e !== o && l.push(...
|
|
1170
|
-
if (n) for (let e of n) l.push(...
|
|
1167
|
+
for (let e of t) e !== o && l.push(...at(s, c, e));
|
|
1168
|
+
if (n) for (let e of n) l.push(...at(s, c, e));
|
|
1171
1169
|
let u = Math.hypot(c.x - s.x, c.y - s.y);
|
|
1172
1170
|
if (!u) continue;
|
|
1173
1171
|
let d = -(c.y - s.y) / u * r, f = (c.x - s.x) / u * r;
|
|
@@ -1181,13 +1179,13 @@ function it(e, t, n) {
|
|
|
1181
1179
|
}, h = {
|
|
1182
1180
|
x: p.x - d,
|
|
1183
1181
|
y: p.y - f
|
|
1184
|
-
}, g =
|
|
1185
|
-
t.some((e) => e !== o &&
|
|
1182
|
+
}, g = it(m, o) ? m : h, _ = g === m ? h : m;
|
|
1183
|
+
t.some((e) => e !== o && it(_, e)) || n && !n.some((e) => it(g, e)) || i.push([a(s, c, r), a(s, c, u)]);
|
|
1186
1184
|
}
|
|
1187
1185
|
}
|
|
1188
1186
|
return i;
|
|
1189
1187
|
}
|
|
1190
|
-
function
|
|
1188
|
+
function ot(e) {
|
|
1191
1189
|
let t = [...new Set(e.flatMap((e) => [e.x, e.x + e.w]))].sort((e, t) => e - t), n = [];
|
|
1192
1190
|
for (let r = 0; r + 1 < t.length; r += 1) {
|
|
1193
1191
|
let i = t[r], a = t[r + 1];
|
|
@@ -1208,38 +1206,38 @@ function at(e) {
|
|
|
1208
1206
|
}
|
|
1209
1207
|
return n;
|
|
1210
1208
|
}
|
|
1211
|
-
function
|
|
1209
|
+
function st(e, t, n, r) {
|
|
1212
1210
|
e.save(), e.globalAlpha *= t.dim.opacity, e.fillStyle = t.dim.color, e.beginPath(), e.rect(0, 0, n, r);
|
|
1213
1211
|
for (let n of t.dimHoles) e.moveTo(n.x, n.y), e.lineTo(n.x, n.y + n.h), e.lineTo(n.x + n.w, n.y + n.h), e.lineTo(n.x + n.w, n.y), e.closePath();
|
|
1214
1212
|
if (e.fill(), t.zones.length) {
|
|
1215
1213
|
e.beginPath();
|
|
1216
1214
|
for (let n of t.rects) e.rect(n.x, n.y, n.w, n.h);
|
|
1217
1215
|
e.clip();
|
|
1218
|
-
for (let n of t.zones)
|
|
1216
|
+
for (let n of t.zones) nt(e, n.points), e.fill();
|
|
1219
1217
|
}
|
|
1220
1218
|
e.restore();
|
|
1221
1219
|
}
|
|
1222
|
-
function
|
|
1220
|
+
function q(e) {
|
|
1223
1221
|
let t = [];
|
|
1224
1222
|
for (let n of e) if (!(n.length < 2)) for (let e = 0; e < n.length; e += 1) t.push([n[e], n[(e + 1) % n.length]]);
|
|
1225
1223
|
return t;
|
|
1226
1224
|
}
|
|
1227
|
-
var
|
|
1225
|
+
var ct = {
|
|
1228
1226
|
color: "#000000",
|
|
1229
1227
|
opacity: .5
|
|
1230
|
-
},
|
|
1228
|
+
}, lt = {
|
|
1231
1229
|
color: "#ffffff",
|
|
1232
1230
|
opacity: 1,
|
|
1233
1231
|
width: 2,
|
|
1234
1232
|
dash: [6, 6],
|
|
1235
1233
|
underlayColor: "#000000"
|
|
1236
|
-
},
|
|
1234
|
+
}, ut = {
|
|
1237
1235
|
color: "#dc2626",
|
|
1238
1236
|
opacity: .8,
|
|
1239
1237
|
width: 2,
|
|
1240
1238
|
dash: [6, 6],
|
|
1241
1239
|
underlayColor: "#000000"
|
|
1242
|
-
},
|
|
1240
|
+
}, dt = (e, t, n) => {
|
|
1243
1241
|
let r = e.occludedAreas?.filter((e) => e.points.length >= 3) ?? [];
|
|
1244
1242
|
if (!t || !n || !e.visibleAreas.length && !r.length) return null;
|
|
1245
1243
|
let i = e.visibleAreas, a = i.length ? i : [{
|
|
@@ -1247,8 +1245,8 @@ var st = {
|
|
|
1247
1245
|
y: 0,
|
|
1248
1246
|
w: t,
|
|
1249
1247
|
h: n
|
|
1250
|
-
}], o =
|
|
1251
|
-
...
|
|
1248
|
+
}], o = ot(a), s = {
|
|
1249
|
+
...ct,
|
|
1252
1250
|
...e.dim
|
|
1253
1251
|
}, c = e.outline;
|
|
1254
1252
|
if (c === !1) return {
|
|
@@ -1262,36 +1260,36 @@ var st = {
|
|
|
1262
1260
|
};
|
|
1263
1261
|
let l = {
|
|
1264
1262
|
visible: {
|
|
1265
|
-
...
|
|
1263
|
+
...lt,
|
|
1266
1264
|
...c?.visibleStyle
|
|
1267
1265
|
},
|
|
1268
1266
|
occluded: {
|
|
1269
|
-
...
|
|
1267
|
+
...ut,
|
|
1270
1268
|
...c?.occludedStyle
|
|
1271
1269
|
}
|
|
1272
|
-
}, u = i.map(
|
|
1270
|
+
}, u = i.map(rt), d = a.map(rt), f = r.map((e) => e.points);
|
|
1273
1271
|
return c?.mode === "separate" ? {
|
|
1274
1272
|
rects: a,
|
|
1275
1273
|
zones: r,
|
|
1276
1274
|
dimHoles: o,
|
|
1277
1275
|
dim: s,
|
|
1278
|
-
visibleOutline:
|
|
1279
|
-
occludedOutline:
|
|
1276
|
+
visibleOutline: q(u),
|
|
1277
|
+
occludedOutline: q(f),
|
|
1280
1278
|
outlineStyles: l
|
|
1281
1279
|
} : {
|
|
1282
1280
|
rects: a,
|
|
1283
1281
|
zones: r,
|
|
1284
1282
|
dimHoles: o,
|
|
1285
1283
|
dim: s,
|
|
1286
|
-
visibleOutline: [...
|
|
1284
|
+
visibleOutline: [...K(u, [...u, ...f], null), ...K(f, f, d)],
|
|
1287
1285
|
occludedOutline: [],
|
|
1288
1286
|
outlineStyles: l
|
|
1289
1287
|
};
|
|
1290
|
-
},
|
|
1291
|
-
function
|
|
1288
|
+
}, ft = .3, J = .05;
|
|
1289
|
+
function pt(e) {
|
|
1292
1290
|
return 1 - (1 - e) ** 3;
|
|
1293
1291
|
}
|
|
1294
|
-
function
|
|
1292
|
+
function mt(e) {
|
|
1295
1293
|
return {
|
|
1296
1294
|
x: e.minX,
|
|
1297
1295
|
y: e.minY,
|
|
@@ -1299,7 +1297,7 @@ function X(e) {
|
|
|
1299
1297
|
height: Math.max(0, e.maxY - e.minY)
|
|
1300
1298
|
};
|
|
1301
1299
|
}
|
|
1302
|
-
function
|
|
1300
|
+
function Y(e, t) {
|
|
1303
1301
|
if (!t.length) return null;
|
|
1304
1302
|
if (e === j.POINT) {
|
|
1305
1303
|
let e = t[0];
|
|
@@ -1310,7 +1308,7 @@ function pt(e, t) {
|
|
|
1310
1308
|
height: 16
|
|
1311
1309
|
};
|
|
1312
1310
|
}
|
|
1313
|
-
let n =
|
|
1311
|
+
let n = I(t), r = Math.max(1, n.maxX - n.minX), i = Math.max(1, n.maxY - n.minY);
|
|
1314
1312
|
return {
|
|
1315
1313
|
x: n.minX,
|
|
1316
1314
|
y: n.minY,
|
|
@@ -1318,10 +1316,10 @@ function pt(e, t) {
|
|
|
1318
1316
|
height: i
|
|
1319
1317
|
};
|
|
1320
1318
|
}
|
|
1321
|
-
function
|
|
1319
|
+
function ht(e) {
|
|
1322
1320
|
if (!e.length) return null;
|
|
1323
|
-
let t = e.map((e) =>
|
|
1324
|
-
return t.length ?
|
|
1321
|
+
let t = e.map((e) => Y(e.type, e.points)).filter((e) => e !== null);
|
|
1322
|
+
return t.length ? mt(I(t.flatMap((e) => [{
|
|
1325
1323
|
x: e.x,
|
|
1326
1324
|
y: e.y
|
|
1327
1325
|
}, {
|
|
@@ -1329,8 +1327,8 @@ function mt(e) {
|
|
|
1329
1327
|
y: e.y + e.height
|
|
1330
1328
|
}]))) : null;
|
|
1331
1329
|
}
|
|
1332
|
-
function
|
|
1333
|
-
let { containerRatio: i =
|
|
1330
|
+
function gt(e, t, n, r = {}) {
|
|
1331
|
+
let { containerRatio: i = ft, minScale: a = J, maxScale: o = 20 } = r;
|
|
1334
1332
|
if (!t || !n || e.width <= 0 || e.height <= 0) return null;
|
|
1335
1333
|
let s = Math.min(t * i / e.width, n * i / e.height), c = Math.max(a, Math.min(o, s)), l = e.x + e.width / 2, u = e.y + e.height / 2;
|
|
1336
1334
|
return {
|
|
@@ -1339,18 +1337,18 @@ function ht(e, t, n, r = {}) {
|
|
|
1339
1337
|
y: n / 2 - u * c
|
|
1340
1338
|
};
|
|
1341
1339
|
}
|
|
1342
|
-
function
|
|
1340
|
+
function _t(e, t, n, r = 80) {
|
|
1343
1341
|
if (!t || !n) return null;
|
|
1344
|
-
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(
|
|
1342
|
+
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(J, Math.min(20, Math.min((t - r) / i, (n - r) / a))), s = (e.minX + e.maxX) / 2, c = (e.minY + e.maxY) / 2;
|
|
1345
1343
|
return {
|
|
1346
1344
|
scale: o,
|
|
1347
1345
|
x: t / 2 - s * o,
|
|
1348
1346
|
y: n / 2 - c * o
|
|
1349
1347
|
};
|
|
1350
1348
|
}
|
|
1351
|
-
function
|
|
1349
|
+
function vt(e, t, n, r = 300) {
|
|
1352
1350
|
let i = Date.now(), a = 0, o = () => {
|
|
1353
|
-
let s = Date.now() - i, c = Math.min(s / r, 1), l =
|
|
1351
|
+
let s = Date.now() - i, c = Math.min(s / r, 1), l = pt(c);
|
|
1354
1352
|
n({
|
|
1355
1353
|
scale: e.scale + (t.scale - e.scale) * l,
|
|
1356
1354
|
x: e.x + (t.x - e.x) * l,
|
|
@@ -1361,8 +1359,8 @@ function _t(e, t, n, r = 300) {
|
|
|
1361
1359
|
}
|
|
1362
1360
|
//#endregion
|
|
1363
1361
|
//#region src/components/ShapeEditor/_state/createInteractionController.ts
|
|
1364
|
-
function
|
|
1365
|
-
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: f, createRef: p, selectRef: m, enterEditRef: h, drawSessionRef: g, assistantRef: _, setCursorHint: v, setInteractionMode: y, syncMinimap: b, onTransformPreview: x, onDrawPreview: S } = e, C = () => g.current, w = () => _.current, T = null, E = null, D = null, O = null, k = null, A = "", M = null, N = (e) => e ===
|
|
1362
|
+
function yt(e) {
|
|
1363
|
+
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: f, createRef: p, selectRef: m, enterEditRef: h, drawSessionRef: g, assistantRef: _, setCursorHint: v, setInteractionMode: y, syncMinimap: b, onTransformPreview: x, onDrawPreview: S } = e, C = () => g.current, w = () => _.current, T = null, E = null, D = null, O = null, k = null, A = "", M = null, N = (e) => e === H.RECTANGLE || e === H.ROTATED_RECTANGLE || e === H.CIRCLE, ee = (e) => e === H.ASSISTANT_POLYGON || e === H.ASSISTANT_RECT, re = (e) => e === H.POLYGON, F = () => r.current.get(n.current), ie = (e, t, n, r) => ({
|
|
1366
1364
|
point: t,
|
|
1367
1365
|
targetId: r,
|
|
1368
1366
|
event: n,
|
|
@@ -1385,17 +1383,17 @@ function vt(e) {
|
|
|
1385
1383
|
};
|
|
1386
1384
|
return;
|
|
1387
1385
|
}
|
|
1388
|
-
if (u.button === 2 && !(g ===
|
|
1389
|
-
let _ =
|
|
1386
|
+
if (u.button === 2 && !(g === H.ASSISTANT_POINT && u.altKey)) return;
|
|
1387
|
+
let _ = F();
|
|
1390
1388
|
if (_) {
|
|
1391
|
-
C().reset(), m.current([]), _.onPointerDown?.(
|
|
1389
|
+
C().reset(), m.current([]), _.onPointerDown?.(ie(p, e, u, r));
|
|
1392
1390
|
return;
|
|
1393
1391
|
}
|
|
1394
1392
|
if (d.current) {
|
|
1395
1393
|
f();
|
|
1396
1394
|
return;
|
|
1397
1395
|
}
|
|
1398
|
-
if (g ===
|
|
1396
|
+
if (g === H.ASSISTANT_POINT) {
|
|
1399
1397
|
u.altKey ? w().addPoint(e, u.button !== 2) : w().newPolygon(e);
|
|
1400
1398
|
return;
|
|
1401
1399
|
}
|
|
@@ -1403,10 +1401,10 @@ function vt(e) {
|
|
|
1403
1401
|
E = e, y("drawing");
|
|
1404
1402
|
return;
|
|
1405
1403
|
}
|
|
1406
|
-
if (g ===
|
|
1407
|
-
let t =
|
|
1404
|
+
if (g === H.SELECT && u.altKey) {
|
|
1405
|
+
let t = ne(o.current.getShapes()).filter((t) => {
|
|
1408
1406
|
if (!P(t)) return !1;
|
|
1409
|
-
let n =
|
|
1407
|
+
let n = I(t.points);
|
|
1410
1408
|
return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
|
|
1411
1409
|
});
|
|
1412
1410
|
if (t.length) {
|
|
@@ -1415,7 +1413,7 @@ function vt(e) {
|
|
|
1415
1413
|
return;
|
|
1416
1414
|
}
|
|
1417
1415
|
}
|
|
1418
|
-
if (r && g ===
|
|
1416
|
+
if (r && g === H.SELECT) {
|
|
1419
1417
|
let t = o.current.getShapes().find((e) => e.id === r);
|
|
1420
1418
|
if (!t || !P(t)) return;
|
|
1421
1419
|
let n = typeof performance < "u" ? performance.now() : 0, i = !!M && M.id === r && n - M.t < 300;
|
|
@@ -1433,14 +1431,14 @@ function vt(e) {
|
|
|
1433
1431
|
let e = new Set(u);
|
|
1434
1432
|
e.has(r) ? e.delete(r) : e.add(r), u = [...e];
|
|
1435
1433
|
} else u.includes(r) || (u = [r]);
|
|
1436
|
-
m.current(u), !l.current &&
|
|
1434
|
+
m.current(u), !l.current && te(t) && p.beginMove(e, u);
|
|
1437
1435
|
return;
|
|
1438
1436
|
}
|
|
1439
1437
|
if (N(g) && c.current) {
|
|
1440
1438
|
E = e, y("drawing");
|
|
1441
1439
|
return;
|
|
1442
1440
|
}
|
|
1443
|
-
if (
|
|
1441
|
+
if (re(g) && c.current) {
|
|
1444
1442
|
if (!C().getDraftPointsSnapshot().length && s.current.length && m.current([]), C().tryClosePolygon(e, 12 / p.viewport.scale)) return;
|
|
1445
1443
|
let t = C().hitDraftPoint(e);
|
|
1446
1444
|
if (t >= 0) {
|
|
@@ -1461,19 +1459,19 @@ function vt(e) {
|
|
|
1461
1459
|
C().appendPolygonPoint(e);
|
|
1462
1460
|
return;
|
|
1463
1461
|
}
|
|
1464
|
-
if (g ===
|
|
1462
|
+
if (g === H.PATH && c.current) {
|
|
1465
1463
|
s.current.length && m.current([]), D = "path", y("drawing"), C().beginStroke(e);
|
|
1466
1464
|
return;
|
|
1467
1465
|
}
|
|
1468
|
-
if (g ===
|
|
1466
|
+
if (g === H.BRUSH && c.current && !l.current) {
|
|
1469
1467
|
D = "scalar", y("drawing"), C().beginStroke(e);
|
|
1470
1468
|
return;
|
|
1471
1469
|
}
|
|
1472
|
-
if (g ===
|
|
1470
|
+
if (g === H.SELECT) {
|
|
1473
1471
|
if (!a.current && !l.current && s.current.length >= 2) {
|
|
1474
|
-
let t = o.current.getShapes().filter((e) => s.current.includes(e.id) &&
|
|
1472
|
+
let t = o.current.getShapes().filter((e) => s.current.includes(e.id) && te(e));
|
|
1475
1473
|
if (t.length) {
|
|
1476
|
-
let n =
|
|
1474
|
+
let n = I(t.flatMap((e) => e.points));
|
|
1477
1475
|
if (e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY) {
|
|
1478
1476
|
p.beginMove(e, s.current);
|
|
1479
1477
|
return;
|
|
@@ -1494,9 +1492,9 @@ function vt(e) {
|
|
|
1494
1492
|
});
|
|
1495
1493
|
return;
|
|
1496
1494
|
}
|
|
1497
|
-
let o = n.current, s =
|
|
1495
|
+
let o = n.current, s = F();
|
|
1498
1496
|
if (s) {
|
|
1499
|
-
s.onPointerMove?.(
|
|
1497
|
+
s.onPointerMove?.(ie(i, e, r));
|
|
1500
1498
|
return;
|
|
1501
1499
|
}
|
|
1502
1500
|
if (O) {
|
|
@@ -1505,12 +1503,12 @@ function vt(e) {
|
|
|
1505
1503
|
return;
|
|
1506
1504
|
}
|
|
1507
1505
|
if (E && (N(o) || ee(o))) {
|
|
1508
|
-
let t = a.current ?
|
|
1509
|
-
i.previewBox(o ===
|
|
1506
|
+
let t = a.current ? oe(E, e) : e;
|
|
1507
|
+
i.previewBox(o === H.CIRCLE ? "ellipse" : "rect", E, t, {
|
|
1510
1508
|
...c.current,
|
|
1511
1509
|
color: c.current?.color ?? "#00e5ff"
|
|
1512
1510
|
}), N(o) && S({
|
|
1513
|
-
type: o ===
|
|
1511
|
+
type: o === H.CIRCLE ? j.ELLIPSE : j.RECTANGLE,
|
|
1514
1512
|
points: [E, t]
|
|
1515
1513
|
});
|
|
1516
1514
|
return;
|
|
@@ -1519,7 +1517,7 @@ function vt(e) {
|
|
|
1519
1517
|
C().appendStrokePoint(e, 2 / i.viewport.scale);
|
|
1520
1518
|
return;
|
|
1521
1519
|
}
|
|
1522
|
-
if (
|
|
1520
|
+
if (re(o) && C().hasDraftPoints()) {
|
|
1523
1521
|
C().setDraftCursor(e);
|
|
1524
1522
|
return;
|
|
1525
1523
|
}
|
|
@@ -1547,12 +1545,12 @@ function vt(e) {
|
|
|
1547
1545
|
C().commitDraftPointDrag(O.moved), O = null, y("idle");
|
|
1548
1546
|
return;
|
|
1549
1547
|
}
|
|
1550
|
-
let i = n.current, o =
|
|
1548
|
+
let i = n.current, o = F();
|
|
1551
1549
|
if (o) {
|
|
1552
|
-
o.onPointerUp?.(
|
|
1550
|
+
o.onPointerUp?.(ie(r, e, {}));
|
|
1553
1551
|
return;
|
|
1554
1552
|
}
|
|
1555
|
-
if (i ===
|
|
1553
|
+
if (i === H.POINT && c.current) {
|
|
1556
1554
|
p.current(j.POINT, [e]);
|
|
1557
1555
|
return;
|
|
1558
1556
|
}
|
|
@@ -1570,12 +1568,12 @@ function vt(e) {
|
|
|
1570
1568
|
width: Math.abs(e.x - t.x),
|
|
1571
1569
|
height: Math.abs(e.y - t.y)
|
|
1572
1570
|
};
|
|
1573
|
-
n.width > 2 && n.height > 2 && w().beginBox(n, i ===
|
|
1571
|
+
n.width > 2 && n.height > 2 && w().beginBox(n, i === H.ASSISTANT_RECT ? "rect" : "polygon");
|
|
1574
1572
|
return;
|
|
1575
1573
|
}
|
|
1576
1574
|
if (E && N(i)) {
|
|
1577
|
-
let t = a.current ?
|
|
1578
|
-
E = null, y("idle"), r.clearPreview(), S(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (i ===
|
|
1575
|
+
let t = a.current ? oe(E, e) : e, n = E;
|
|
1576
|
+
E = null, y("idle"), r.clearPreview(), S(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (i === H.ROTATED_RECTANGLE ? p.current(j.ROTATED_RECTANGLE, R([n, t])) : i === H.CIRCLE ? p.current(j.POLYGON, z(n, t)) : p.current(j.RECTANGLE, [n, t]));
|
|
1579
1577
|
return;
|
|
1580
1578
|
}
|
|
1581
1579
|
if (k) {
|
|
@@ -1599,7 +1597,7 @@ function vt(e) {
|
|
|
1599
1597
|
}
|
|
1600
1598
|
//#endregion
|
|
1601
1599
|
//#region src/components/ShapeEditor/_state/useAssistant.ts
|
|
1602
|
-
function
|
|
1600
|
+
function bt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistantRef: i }) {
|
|
1603
1601
|
let [a, o] = y("idle"), [s, c] = y([]), [l, u] = y([]), f = v([]), p = v([]), m = v([]), h = v("idle"), g = v(0), _ = v(null), b = v(null), x = v(0), S = d((e) => {
|
|
1604
1602
|
f.current = e(f.current), u(f.current);
|
|
1605
1603
|
}, []), C = d((e) => {
|
|
@@ -1608,16 +1606,16 @@ function yt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1608
1606
|
let a = i.current?.rectResult === "rotatedRect";
|
|
1609
1607
|
return e.map((e) => {
|
|
1610
1608
|
if (t === "rect" && a) return {
|
|
1611
|
-
id:
|
|
1609
|
+
id: re(),
|
|
1612
1610
|
type: j.ROTATED_RECTANGLE,
|
|
1613
|
-
points:
|
|
1611
|
+
points: ce(e),
|
|
1614
1612
|
style: r,
|
|
1615
1613
|
meta: n
|
|
1616
1614
|
};
|
|
1617
1615
|
if (t === "rect") {
|
|
1618
|
-
let t =
|
|
1616
|
+
let t = I(e);
|
|
1619
1617
|
return {
|
|
1620
|
-
id:
|
|
1618
|
+
id: re(),
|
|
1621
1619
|
type: j.RECTANGLE,
|
|
1622
1620
|
points: [{
|
|
1623
1621
|
x: t.minX,
|
|
@@ -1631,7 +1629,7 @@ function yt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1631
1629
|
};
|
|
1632
1630
|
}
|
|
1633
1631
|
return {
|
|
1634
|
-
id:
|
|
1632
|
+
id: re(),
|
|
1635
1633
|
type: j.POLYGON,
|
|
1636
1634
|
points: e,
|
|
1637
1635
|
style: r,
|
|
@@ -1764,17 +1762,17 @@ function yt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1764
1762
|
}
|
|
1765
1763
|
//#endregion
|
|
1766
1764
|
//#region src/components/ShapeEditor/_model/brush.ts
|
|
1767
|
-
function
|
|
1765
|
+
function xt(e, t, n) {
|
|
1768
1766
|
let r = Math.abs(.5 * (t.x * n.y + n.x * e.y + e.x * t.y - n.x * t.y - e.x * n.y - t.x * e.y)), i = Math.hypot(t.x - n.x, t.y - n.y);
|
|
1769
1767
|
return i === 0 ? 0 : r * 2 / i;
|
|
1770
1768
|
}
|
|
1771
|
-
function
|
|
1769
|
+
function St(e, t = 1.5) {
|
|
1772
1770
|
if (e.length <= 2) return e;
|
|
1773
1771
|
let n = (e, t) => {
|
|
1774
1772
|
if (e.length < 3) return e;
|
|
1775
1773
|
let r = 0, i = 0, a = e.length - 1;
|
|
1776
1774
|
for (let t = 1; t < a; t++) {
|
|
1777
|
-
let n =
|
|
1775
|
+
let n = xt(e[t], e[0], e[a]);
|
|
1778
1776
|
n > r && (i = t, r = n);
|
|
1779
1777
|
}
|
|
1780
1778
|
if (r > t) {
|
|
@@ -1787,8 +1785,8 @@ function xt(e, t = 1.5) {
|
|
|
1787
1785
|
}
|
|
1788
1786
|
//#endregion
|
|
1789
1787
|
//#region src/components/ShapeEditor/_model/scalarMask.ts
|
|
1790
|
-
var
|
|
1791
|
-
function
|
|
1788
|
+
var Ct = 4096, wt = 4;
|
|
1789
|
+
function Tt(e) {
|
|
1792
1790
|
let t = 0;
|
|
1793
1791
|
for (let n = 0; n < e.length; n++) {
|
|
1794
1792
|
let r = e[n], i = e[(n + 1) % e.length];
|
|
@@ -1796,17 +1794,17 @@ function wt(e) {
|
|
|
1796
1794
|
}
|
|
1797
1795
|
return Math.abs(t / 2);
|
|
1798
1796
|
}
|
|
1799
|
-
function
|
|
1797
|
+
function Et(e, t, n) {
|
|
1800
1798
|
let r = new Uint8Array(t * n);
|
|
1801
1799
|
for (let i = 0; i < t * n; i++) r[i] = e[i * 4 + 3] > 128 ? 255 : 0;
|
|
1802
1800
|
return r;
|
|
1803
1801
|
}
|
|
1804
|
-
function
|
|
1802
|
+
function Dt(e) {
|
|
1805
1803
|
let t = new Uint8ClampedArray(e.length * 4);
|
|
1806
1804
|
for (let n = 0; n < e.length; n++) e[n] > 128 && (t[n * 4 + 3] = 255);
|
|
1807
1805
|
return t;
|
|
1808
1806
|
}
|
|
1809
|
-
function
|
|
1807
|
+
function Ot(e, t, n, r, i) {
|
|
1810
1808
|
let a = new Uint8Array(t * n), o = [[r, i]];
|
|
1811
1809
|
for (; o.length;) {
|
|
1812
1810
|
let [r, i] = o.pop(), s = i * t + r;
|
|
@@ -1814,8 +1812,8 @@ function Dt(e, t, n, r, i) {
|
|
|
1814
1812
|
}
|
|
1815
1813
|
return a;
|
|
1816
1814
|
}
|
|
1817
|
-
function
|
|
1818
|
-
let r =
|
|
1815
|
+
function kt(e, t, n) {
|
|
1816
|
+
let r = Et(e, t, n), i = [];
|
|
1819
1817
|
for (;;) {
|
|
1820
1818
|
let e = -1, a = -1;
|
|
1821
1819
|
outer: for (let i = 0; i < n; i++) for (let n = 0; n < t; n++) if (r[i * t + n] > 128) {
|
|
@@ -1823,17 +1821,17 @@ function Ot(e, t, n) {
|
|
|
1823
1821
|
break outer;
|
|
1824
1822
|
}
|
|
1825
1823
|
if (e < 0) break;
|
|
1826
|
-
let o =
|
|
1824
|
+
let o = jt(Dt(Ot(r, t, n, e, a)), t, n);
|
|
1827
1825
|
o.length >= 3 && i.push(o);
|
|
1828
1826
|
}
|
|
1829
1827
|
return i;
|
|
1830
1828
|
}
|
|
1831
|
-
function
|
|
1829
|
+
function At(e, t, n, r, i) {
|
|
1832
1830
|
return r < 0 || i < 0 || r >= t || i >= n ? !1 : e[(i * t + r) * 4 + 3] > 128;
|
|
1833
1831
|
}
|
|
1834
|
-
function
|
|
1832
|
+
function jt(e, t, n) {
|
|
1835
1833
|
let r = -1, i = -1;
|
|
1836
|
-
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (
|
|
1834
|
+
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (At(e, t, n, o, a)) {
|
|
1837
1835
|
r = o, i = a;
|
|
1838
1836
|
break outer;
|
|
1839
1837
|
}
|
|
@@ -1868,7 +1866,7 @@ function Z(e, t, n) {
|
|
|
1868
1866
|
let r = !1;
|
|
1869
1867
|
for (let i = 0; i < 8; i++) {
|
|
1870
1868
|
let s = (u + i) % 8, d = c + a[s], f = l + o[s];
|
|
1871
|
-
if (
|
|
1869
|
+
if (At(e, t, n, d, f)) {
|
|
1872
1870
|
c = d, l = f, u = (s + 6) % 8, r = !0;
|
|
1873
1871
|
break;
|
|
1874
1872
|
}
|
|
@@ -1877,21 +1875,21 @@ function Z(e, t, n) {
|
|
|
1877
1875
|
} while (c !== d.x || l !== d.y || s.length === 1);
|
|
1878
1876
|
return s;
|
|
1879
1877
|
}
|
|
1880
|
-
function
|
|
1878
|
+
function Mt(e, t) {
|
|
1881
1879
|
let n = [];
|
|
1882
1880
|
for (let t of e) for (let e of t.points) n.push(e);
|
|
1883
1881
|
for (let e of t) for (let t of e) n.push(t);
|
|
1884
1882
|
return n;
|
|
1885
1883
|
}
|
|
1886
|
-
function
|
|
1884
|
+
function Nt(e) {
|
|
1887
1885
|
switch (e.type) {
|
|
1888
|
-
case j.RECTANGLE: return e.points.length < 2 ? null :
|
|
1886
|
+
case j.RECTANGLE: return e.points.length < 2 ? null : R(e.points);
|
|
1889
1887
|
case j.POLYGON:
|
|
1890
1888
|
case j.ROTATED_RECTANGLE:
|
|
1891
1889
|
case j.ELLIPSE: return e.points.length >= 3 ? e.points : null;
|
|
1892
1890
|
case j.POINT: {
|
|
1893
1891
|
let t = e.points[0];
|
|
1894
|
-
return t ?
|
|
1892
|
+
return t ? z({
|
|
1895
1893
|
x: t.x - 6,
|
|
1896
1894
|
y: t.y - 6
|
|
1897
1895
|
}, {
|
|
@@ -1902,14 +1900,14 @@ function jt(e) {
|
|
|
1902
1900
|
default: return null;
|
|
1903
1901
|
}
|
|
1904
1902
|
}
|
|
1905
|
-
function
|
|
1906
|
-
return e.map(
|
|
1903
|
+
function X(e) {
|
|
1904
|
+
return e.map(Nt).filter((e) => !!e && e.length >= 3);
|
|
1907
1905
|
}
|
|
1908
|
-
function
|
|
1906
|
+
function Pt(e, t, n = []) {
|
|
1909
1907
|
if (t <= 0 || !e.length && !n.length) return null;
|
|
1910
|
-
let r =
|
|
1908
|
+
let r = Mt(e, n);
|
|
1911
1909
|
if (!r.length) return null;
|
|
1912
|
-
let i = t + 4, a =
|
|
1910
|
+
let i = t + 4, a = I(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1, Ct / Math.max(o, s, 1));
|
|
1913
1911
|
o = Math.max(1, Math.ceil(o * c)), s = Math.max(1, Math.ceil(s * c));
|
|
1914
1912
|
let l = a.minX - i, u = a.minY - i, d = (e) => ({
|
|
1915
1913
|
x: (e.x - l) * c,
|
|
@@ -1948,20 +1946,20 @@ function Nt(e, t, n = []) {
|
|
|
1948
1946
|
scale: c
|
|
1949
1947
|
};
|
|
1950
1948
|
}
|
|
1951
|
-
function
|
|
1952
|
-
let { canvas: n, ox: r, oy: i, scale: a } = e, o =
|
|
1949
|
+
function Ft(e, t = 1.5) {
|
|
1950
|
+
let { canvas: n, ox: r, oy: i, scale: a } = e, o = kt(n.getContext("2d").getImageData(0, 0, n.width, n.height).data, n.width, n.height);
|
|
1953
1951
|
if (!o.length) return [];
|
|
1954
1952
|
let s = (e) => ({
|
|
1955
1953
|
x: e.x / a + r,
|
|
1956
1954
|
y: e.y / a + i
|
|
1957
1955
|
}), c = [];
|
|
1958
1956
|
for (let e of o) {
|
|
1959
|
-
let n = e.map(s), r =
|
|
1960
|
-
i.length >= 3 &&
|
|
1957
|
+
let n = e.map(s), r = St(n, t), i = r.length >= 3 ? r : n;
|
|
1958
|
+
i.length >= 3 && Tt(i) >= wt && c.push(i);
|
|
1961
1959
|
}
|
|
1962
1960
|
return c;
|
|
1963
1961
|
}
|
|
1964
|
-
function
|
|
1962
|
+
function It(e, t) {
|
|
1965
1963
|
let { canvas: n } = e, r = document.createElement("canvas");
|
|
1966
1964
|
r.width = n.width, r.height = n.height;
|
|
1967
1965
|
let i = r.getContext("2d");
|
|
@@ -1969,25 +1967,25 @@ function Ft(e, t) {
|
|
|
1969
1967
|
}
|
|
1970
1968
|
//#endregion
|
|
1971
1969
|
//#region src/components/ShapeEditor/_state/drawSessionState.ts
|
|
1972
|
-
function
|
|
1970
|
+
function Lt(e) {
|
|
1973
1971
|
return e.map((e) => ({
|
|
1974
1972
|
mode: e.mode,
|
|
1975
1973
|
points: e.points.map((e) => ({ ...e }))
|
|
1976
1974
|
}));
|
|
1977
1975
|
}
|
|
1978
|
-
function
|
|
1976
|
+
function Rt(e, t) {
|
|
1979
1977
|
return e.length === t.length && e.every((e, n) => e.mode === t[n].mode && e.points.length === t[n].points.length && e.points.every((e, r) => e.x === t[n].points[r].x && e.y === t[n].points[r].y));
|
|
1980
1978
|
}
|
|
1981
|
-
function
|
|
1979
|
+
function Z(e) {
|
|
1982
1980
|
return e.map((e) => ({ ...e }));
|
|
1983
1981
|
}
|
|
1984
|
-
function
|
|
1982
|
+
function zt(e, t) {
|
|
1985
1983
|
return e.length === t.length && e.every((e, n) => e.x === t[n].x && e.y === t[n].y);
|
|
1986
1984
|
}
|
|
1987
1985
|
//#endregion
|
|
1988
1986
|
//#region src/components/ShapeEditor/_state/useDrawSession.ts
|
|
1989
|
-
var
|
|
1990
|
-
function
|
|
1987
|
+
var Bt = 10;
|
|
1988
|
+
function Vt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, brushSizeRef: a, simplifyEpsilonRef: o, draftMeta: s, engineRef: c, onDrawSessionChange: l, onDraftShapeChange: u, changeSelection: f, createShape: p }) {
|
|
1991
1989
|
let m = v(l);
|
|
1992
1990
|
m.current = l;
|
|
1993
1991
|
let h = v(u);
|
|
@@ -1996,35 +1994,35 @@ function Bt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
1996
1994
|
g.current = s;
|
|
1997
1995
|
let _ = v(p);
|
|
1998
1996
|
_.current = p;
|
|
1999
|
-
let y = v([]), b = v(null), x = v(/* @__PURE__ */ new Set()), S = v([[]]), C = v(0), w = v(""), T = v([]), E = v([]), D = v([]), O = v([[]]), k = v(0), A = v("draw"), M = () => A.current === "erase" ? "erase" : "add", N = () => D.current.length > 0 || T.current.length > 0 || e.current ===
|
|
1997
|
+
let y = v([]), b = v(null), x = v(/* @__PURE__ */ new Set()), S = v([[]]), C = v(0), w = v(""), T = v([]), E = v([]), D = v([]), O = v([[]]), k = v(0), A = v("draw"), M = () => A.current === "erase" ? "erase" : "add", N = () => D.current.length > 0 || T.current.length > 0 || e.current === H.BRUSH && y.current.length > 0, P = () => {
|
|
2000
1998
|
let t = e.current;
|
|
2001
|
-
return t ===
|
|
2002
|
-
},
|
|
1999
|
+
return t === H.BRUSH && N() ? "brush" : t === H.POLYGON && y.current.length > 0 ? "polygon" : t === H.PATH && y.current.length > 0 ? "path" : "none";
|
|
2000
|
+
}, te = () => y.current.length > 0 || k.current > 0, ne = () => y.current.length === 0 && k.current < O.current.length - 1, F = () => C.current > 0, I = () => C.current < S.current.length - 1, ie = () => {
|
|
2003
2001
|
let t = e.current;
|
|
2004
|
-
return t ===
|
|
2005
|
-
},
|
|
2002
|
+
return t === H.BRUSH ? te() : t === H.POLYGON || t === H.PATH ? F() : !1;
|
|
2003
|
+
}, ae = () => {
|
|
2006
2004
|
let t = e.current;
|
|
2007
|
-
return t ===
|
|
2008
|
-
},
|
|
2005
|
+
return t === H.BRUSH ? ne() : t === H.POLYGON || t === H.PATH ? I() : !1;
|
|
2006
|
+
}, oe = () => P() !== "none", L = d(() => {
|
|
2009
2007
|
let e = P();
|
|
2010
2008
|
m.current?.({
|
|
2011
2009
|
active: e !== "none",
|
|
2012
2010
|
kind: e,
|
|
2013
|
-
canUndo:
|
|
2014
|
-
canRedo:
|
|
2011
|
+
canUndo: ie(),
|
|
2012
|
+
canRedo: ae(),
|
|
2015
2013
|
brush: e === "brush" ? {
|
|
2016
2014
|
mode: A.current,
|
|
2017
2015
|
editing: D.current.length > 0,
|
|
2018
2016
|
editTargetIds: [...D.current]
|
|
2019
2017
|
} : void 0
|
|
2020
2018
|
});
|
|
2021
|
-
}, []),
|
|
2019
|
+
}, []), R = d(() => {
|
|
2022
2020
|
O.current = [[]], k.current = 0;
|
|
2023
|
-
}, []),
|
|
2021
|
+
}, []), z = d(() => {
|
|
2024
2022
|
let t = c.current;
|
|
2025
2023
|
if (!t) return;
|
|
2026
2024
|
let n = e.current;
|
|
2027
|
-
if (n ===
|
|
2025
|
+
if (n === H.BRUSH) {
|
|
2028
2026
|
let e = [...T.current];
|
|
2029
2027
|
if (y.current.length && e.push({
|
|
2030
2028
|
points: y.current,
|
|
@@ -2033,7 +2031,7 @@ function Bt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2033
2031
|
t.clearPreview();
|
|
2034
2032
|
return;
|
|
2035
2033
|
}
|
|
2036
|
-
let n =
|
|
2034
|
+
let n = Pt(e, a.current, E.current);
|
|
2037
2035
|
if (!n) {
|
|
2038
2036
|
t.clearPreview();
|
|
2039
2037
|
return;
|
|
@@ -2044,18 +2042,18 @@ function Bt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2044
2042
|
}
|
|
2045
2043
|
let r = y.current;
|
|
2046
2044
|
if (!r.length) {
|
|
2047
|
-
t.clearPreview(), n ===
|
|
2045
|
+
t.clearPreview(), n === H.POLYGON && w.current && (w.current = "", h.current?.(null));
|
|
2048
2046
|
return;
|
|
2049
2047
|
}
|
|
2050
2048
|
let o = {
|
|
2051
2049
|
...i.current,
|
|
2052
2050
|
color: i.current?.color ?? "#00e5ff"
|
|
2053
|
-
}, s = Array.from(x.current), l = n !==
|
|
2054
|
-
if (t.previewPoly(r, b.current, o, !1, s, l), n ===
|
|
2051
|
+
}, s = Array.from(x.current), l = n !== H.PATH;
|
|
2052
|
+
if (t.previewPoly(r, b.current, o, !1, s, l), n === H.POLYGON) {
|
|
2055
2053
|
let e = r.map((e) => `${e.x},${e.y}`).join(";");
|
|
2056
2054
|
e !== w.current && (w.current = e, h.current?.({
|
|
2057
2055
|
type: j.POLYGON,
|
|
2058
|
-
points:
|
|
2056
|
+
points: Z(r),
|
|
2059
2057
|
meta: g.current
|
|
2060
2058
|
}));
|
|
2061
2059
|
}
|
|
@@ -2064,97 +2062,97 @@ function Bt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2064
2062
|
i,
|
|
2065
2063
|
c,
|
|
2066
2064
|
e
|
|
2067
|
-
]),
|
|
2068
|
-
let t =
|
|
2069
|
-
i &&
|
|
2070
|
-
}, [
|
|
2065
|
+
]), se = d((e) => {
|
|
2066
|
+
let t = Lt(e), n = O.current, r = k.current, i = n[r];
|
|
2067
|
+
i && Rt(i, t) || (O.current = [...n.slice(0, r + 1), t], k.current += 1, L());
|
|
2068
|
+
}, [L]), ce = d((e) => {
|
|
2071
2069
|
let t = S.current, n = C.current, r = t[n];
|
|
2072
|
-
r &&
|
|
2073
|
-
}, []),
|
|
2074
|
-
y.current = [], T.current = [], E.current = [], D.current = [], b.current = null, x.current = /* @__PURE__ */ new Set(), S.current = [[]], C.current = 0, w.current = "",
|
|
2070
|
+
r && zt(r, e) || (S.current = [...t.slice(0, n + 1), Z(e)], C.current += 1);
|
|
2071
|
+
}, []), B = d(() => {
|
|
2072
|
+
y.current = [], T.current = [], E.current = [], D.current = [], b.current = null, x.current = /* @__PURE__ */ new Set(), S.current = [[]], C.current = 0, w.current = "", R(), c.current?.clearPreview(), h.current?.(null), L();
|
|
2075
2073
|
}, [
|
|
2076
2074
|
c,
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
]),
|
|
2080
|
-
y.current = e, x.current = new Set(Array.from(x.current).filter((t) => t >= 0 && t < e.length)), t &&
|
|
2075
|
+
L,
|
|
2076
|
+
R
|
|
2077
|
+
]), le = d((e, t) => {
|
|
2078
|
+
y.current = e, x.current = new Set(Array.from(x.current).filter((t) => t >= 0 && t < e.length)), t && ce(e), z(), L();
|
|
2081
2079
|
}, [
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
]),
|
|
2086
|
-
if (e.current !==
|
|
2080
|
+
L,
|
|
2081
|
+
ce,
|
|
2082
|
+
z
|
|
2083
|
+
]), ue = d(() => Z(y.current), []), de = d(() => y.current.length > 0, []), fe = d((t, n) => {
|
|
2084
|
+
if (e.current !== H.POLYGON) return !1;
|
|
2087
2085
|
let r = y.current;
|
|
2088
2086
|
if (r.length < 3) return !1;
|
|
2089
2087
|
let i = r[0];
|
|
2090
|
-
return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (_.current(j.POLYGON, r),
|
|
2091
|
-
}, [
|
|
2088
|
+
return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (_.current(j.POLYGON, r), B(), !0);
|
|
2089
|
+
}, [B, e]), pe = d((e) => {
|
|
2092
2090
|
let t = y.current;
|
|
2093
|
-
return e < 0 || e >= t.length ? !1 : (
|
|
2094
|
-
}, [
|
|
2091
|
+
return e < 0 || e >= t.length ? !1 : (le(t.filter((t, n) => n !== e), !0), !0);
|
|
2092
|
+
}, [le]), me = d((e, t) => {
|
|
2095
2093
|
let n = y.current;
|
|
2096
2094
|
if (e < 0 || e >= n.length) return null;
|
|
2097
2095
|
let r = new Set(x.current);
|
|
2098
|
-
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), x.current = r, b.current = null,
|
|
2099
|
-
base:
|
|
2096
|
+
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), x.current = r, b.current = null, z(), L(), {
|
|
2097
|
+
base: Z(n),
|
|
2100
2098
|
indices: Array.from(r)
|
|
2101
2099
|
};
|
|
2102
|
-
}, [
|
|
2103
|
-
x.current = /* @__PURE__ */ new Set(), b.current = e,
|
|
2104
|
-
}, [
|
|
2105
|
-
b.current = null, x.current = /* @__PURE__ */ new Set(), y.current = [{ ...e }],
|
|
2106
|
-
}, [
|
|
2100
|
+
}, [L, z]), he = d((e) => {
|
|
2101
|
+
x.current = /* @__PURE__ */ new Set(), b.current = e, le([...y.current, e], !0);
|
|
2102
|
+
}, [le]), ge = d((e) => {
|
|
2103
|
+
b.current = null, x.current = /* @__PURE__ */ new Set(), y.current = [{ ...e }], z(), L();
|
|
2104
|
+
}, [L, z]), _e = d((e, t) => {
|
|
2107
2105
|
let n = y.current[y.current.length - 1];
|
|
2108
|
-
return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (y.current = [...y.current, { ...e }], b.current = null,
|
|
2109
|
-
}, [
|
|
2106
|
+
return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (y.current = [...y.current, { ...e }], b.current = null, z(), L(), !0);
|
|
2107
|
+
}, [L, z]), ve = d((e, t, n, r) => {
|
|
2110
2108
|
let i = new Set(t);
|
|
2111
2109
|
y.current = e.map((e, t) => i.has(t) ? {
|
|
2112
2110
|
x: e.x + n,
|
|
2113
2111
|
y: e.y + r
|
|
2114
|
-
} : { ...e }), b.current = null,
|
|
2115
|
-
}, [
|
|
2116
|
-
e && (
|
|
2112
|
+
} : { ...e }), b.current = null, z(), L();
|
|
2113
|
+
}, [L, z]), V = d((e) => {
|
|
2114
|
+
e && (ce(y.current), z(), L());
|
|
2117
2115
|
}, [
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
]),
|
|
2122
|
-
b.current = e ? { ...e } : null,
|
|
2123
|
-
}, [
|
|
2116
|
+
L,
|
|
2117
|
+
ce,
|
|
2118
|
+
z
|
|
2119
|
+
]), ye = d((e) => {
|
|
2120
|
+
b.current = e ? { ...e } : null, z(), L();
|
|
2121
|
+
}, [L, z]), be = d(() => y.current.length > 0 ? (y.current = [], z(), L(), !0) : k.current <= 0 ? !1 : (--k.current, T.current = Lt(O.current[k.current]), z(), L(), !0), [L, z]), xe = d(() => y.current.length > 0 || k.current >= O.current.length - 1 ? !1 : (k.current += 1, T.current = Lt(O.current[k.current]), z(), L(), !0), [L, z]), Se = d(() => C.current <= 0 ? !1 : (--C.current, y.current = Z(S.current[C.current]), x.current = /* @__PURE__ */ new Set(), z(), L(), !0), [L, z]), Ce = d(() => C.current >= S.current.length - 1 ? !1 : (C.current += 1, y.current = Z(S.current[C.current]), x.current = /* @__PURE__ */ new Set(), z(), L(), !0), [L, z]), we = d(() => {
|
|
2124
2122
|
let t = e.current;
|
|
2125
|
-
return t ===
|
|
2123
|
+
return t === H.BRUSH ? be() : t === H.POLYGON || t === H.PATH ? Se() : !1;
|
|
2126
2124
|
}, [
|
|
2127
2125
|
e,
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
]),
|
|
2126
|
+
be,
|
|
2127
|
+
Se
|
|
2128
|
+
]), Te = d(() => {
|
|
2131
2129
|
let t = e.current;
|
|
2132
|
-
return t ===
|
|
2130
|
+
return t === H.BRUSH ? xe() : t === H.POLYGON || t === H.PATH ? Ce() : !1;
|
|
2133
2131
|
}, [
|
|
2134
|
-
|
|
2135
|
-
|
|
2132
|
+
xe,
|
|
2133
|
+
Ce,
|
|
2136
2134
|
e
|
|
2137
|
-
]),
|
|
2135
|
+
]), Ee = d(() => {
|
|
2138
2136
|
let e = t.current;
|
|
2139
2137
|
if (!e.length) return D.current.length > 0;
|
|
2140
|
-
let r = n.current.getShapes().filter((t) => e.includes(t.id) && ee(t)), i =
|
|
2138
|
+
let r = n.current.getShapes().filter((t) => e.includes(t.id) && ee(t)), i = X(r);
|
|
2141
2139
|
return i.length ? (D.current = r.map((e) => e.id), E.current = i, !0) : (D.current = [], E.current = [], !1);
|
|
2142
|
-
}, [n, t]),
|
|
2140
|
+
}, [n, t]), De = d(() => {
|
|
2143
2141
|
if (r.current) return !1;
|
|
2144
2142
|
let e = [...T.current];
|
|
2145
2143
|
y.current.length && e.push({
|
|
2146
|
-
points:
|
|
2144
|
+
points: Z(y.current),
|
|
2147
2145
|
mode: M()
|
|
2148
2146
|
});
|
|
2149
2147
|
let t = E.current, c = [...D.current];
|
|
2150
2148
|
if (!e.length && !t.length) return !1;
|
|
2151
|
-
let l =
|
|
2152
|
-
if (!l) return
|
|
2153
|
-
let u =
|
|
2149
|
+
let l = Pt(e, a.current, t);
|
|
2150
|
+
if (!l) return B(), !1;
|
|
2151
|
+
let u = Ft(l, o.current);
|
|
2154
2152
|
if (c.length) {
|
|
2155
2153
|
let e = n.current.getShapes().filter((e) => c.includes(e.id));
|
|
2156
|
-
if (!u.length) return n.current.remove(c),
|
|
2157
|
-
u.sort((e, t) =>
|
|
2154
|
+
if (!u.length) return n.current.remove(c), B(), f([]), !0;
|
|
2155
|
+
u.sort((e, t) => Tt(t) - Tt(e));
|
|
2158
2156
|
let t = [], r = [], i = [];
|
|
2159
2157
|
for (let n = 0; n < u.length; n++) {
|
|
2160
2158
|
let a = u[n];
|
|
@@ -2166,7 +2164,7 @@ function Bt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2166
2164
|
points: a
|
|
2167
2165
|
}), i.push(r.id);
|
|
2168
2166
|
} else {
|
|
2169
|
-
let t = e[0], n =
|
|
2167
|
+
let t = e[0], n = re();
|
|
2170
2168
|
r.push({
|
|
2171
2169
|
...t,
|
|
2172
2170
|
id: n,
|
|
@@ -2176,19 +2174,19 @@ function Bt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2176
2174
|
}
|
|
2177
2175
|
}
|
|
2178
2176
|
let a = e.slice(u.length).map((e) => e.id);
|
|
2179
|
-
return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a),
|
|
2177
|
+
return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a), B(), f(i), !0;
|
|
2180
2178
|
}
|
|
2181
|
-
if (!u.length) return
|
|
2179
|
+
if (!u.length) return B(), !1;
|
|
2182
2180
|
let d = i.current;
|
|
2183
2181
|
if (!d) return !1;
|
|
2184
2182
|
let p = u.map((e) => ({
|
|
2185
|
-
id:
|
|
2183
|
+
id: re(),
|
|
2186
2184
|
type: j.POLYGON,
|
|
2187
2185
|
points: e,
|
|
2188
2186
|
style: d,
|
|
2189
2187
|
meta: s
|
|
2190
2188
|
}));
|
|
2191
|
-
return n.current.create(p), f(p.map((e) => e.id)),
|
|
2189
|
+
return n.current.create(p), f(p.map((e) => e.id)), B(), !0;
|
|
2192
2190
|
}, [
|
|
2193
2191
|
a,
|
|
2194
2192
|
f,
|
|
@@ -2196,153 +2194,153 @@ function Bt({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2196
2194
|
s,
|
|
2197
2195
|
i,
|
|
2198
2196
|
r,
|
|
2199
|
-
|
|
2200
|
-
]),
|
|
2197
|
+
B
|
|
2198
|
+
]), Oe = d(() => {
|
|
2201
2199
|
let t = e.current;
|
|
2202
|
-
if (t ===
|
|
2200
|
+
if (t === H.BRUSH) return De();
|
|
2203
2201
|
let n = y.current;
|
|
2204
|
-
return t ===
|
|
2202
|
+
return t === H.POLYGON && n.length >= 3 ? (_.current(j.POLYGON, n), B(), !0) : !1;
|
|
2205
2203
|
}, [
|
|
2206
|
-
|
|
2207
|
-
|
|
2204
|
+
De,
|
|
2205
|
+
B,
|
|
2208
2206
|
e
|
|
2209
|
-
]),
|
|
2207
|
+
]), ke = d(() => {
|
|
2210
2208
|
let t = y.current;
|
|
2211
|
-
if (e.current ===
|
|
2212
|
-
let e =
|
|
2209
|
+
if (e.current === H.PATH && t.length >= 3) {
|
|
2210
|
+
let e = St(t, o.current);
|
|
2213
2211
|
e.length >= 3 && _.current(j.POLYGON, e);
|
|
2214
2212
|
}
|
|
2215
|
-
|
|
2216
|
-
}, [
|
|
2217
|
-
A.current = e,
|
|
2218
|
-
}, [
|
|
2219
|
-
if (r.current || e.current !==
|
|
2220
|
-
T.current = [], y.current = [],
|
|
2221
|
-
let t =
|
|
2222
|
-
return
|
|
2213
|
+
B();
|
|
2214
|
+
}, [B, e]), Ae = d((e) => {
|
|
2215
|
+
A.current = e, L(), z();
|
|
2216
|
+
}, [L, z]), je = d(() => {
|
|
2217
|
+
if (r.current || e.current !== H.BRUSH) return !1;
|
|
2218
|
+
T.current = [], y.current = [], R();
|
|
2219
|
+
let t = Ee();
|
|
2220
|
+
return L(), z(), t;
|
|
2223
2221
|
}, [
|
|
2224
|
-
|
|
2222
|
+
L,
|
|
2225
2223
|
r,
|
|
2226
|
-
B,
|
|
2227
2224
|
z,
|
|
2228
|
-
|
|
2225
|
+
R,
|
|
2226
|
+
Ee,
|
|
2229
2227
|
e
|
|
2230
|
-
]),
|
|
2228
|
+
]), Me = d(() => {
|
|
2231
2229
|
let e = x.current;
|
|
2232
2230
|
if (!e.size) return !1;
|
|
2233
2231
|
let t = y.current.filter((t, n) => !e.has(n));
|
|
2234
|
-
return x.current = /* @__PURE__ */ new Set(),
|
|
2235
|
-
}, [
|
|
2232
|
+
return x.current = /* @__PURE__ */ new Set(), le(t, !0), !0;
|
|
2233
|
+
}, [le]), Ne = d((e) => {
|
|
2236
2234
|
let t = c.current, n = y.current;
|
|
2237
2235
|
if (!t || !n.length) return -1;
|
|
2238
|
-
let r =
|
|
2236
|
+
let r = Bt / (t.viewport.scale || 1);
|
|
2239
2237
|
for (let t = n.length - 1; t >= 0; t--) {
|
|
2240
2238
|
let i = n[t];
|
|
2241
2239
|
if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
|
|
2242
2240
|
}
|
|
2243
2241
|
return -1;
|
|
2244
|
-
}, [c]),
|
|
2242
|
+
}, [c]), Pe = d(() => {
|
|
2245
2243
|
y.current.length >= 1 && (T.current.push({
|
|
2246
|
-
points:
|
|
2244
|
+
points: Z(y.current),
|
|
2247
2245
|
mode: M()
|
|
2248
|
-
}), y.current = [],
|
|
2246
|
+
}), y.current = [], se(T.current)), z(), L();
|
|
2249
2247
|
}, [
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2248
|
+
L,
|
|
2249
|
+
se,
|
|
2250
|
+
z
|
|
2253
2251
|
]);
|
|
2254
2252
|
return {
|
|
2255
|
-
reset:
|
|
2256
|
-
undoSession:
|
|
2257
|
-
redoSession:
|
|
2258
|
-
canUndoSession:
|
|
2259
|
-
canRedoSession:
|
|
2260
|
-
hasDraftSession:
|
|
2261
|
-
hasDraftPoints:
|
|
2262
|
-
commitDraftSession:
|
|
2263
|
-
completeFreehandStroke:
|
|
2264
|
-
setBrushScalarMode:
|
|
2253
|
+
reset: B,
|
|
2254
|
+
undoSession: we,
|
|
2255
|
+
redoSession: Te,
|
|
2256
|
+
canUndoSession: ie,
|
|
2257
|
+
canRedoSession: ae,
|
|
2258
|
+
hasDraftSession: oe,
|
|
2259
|
+
hasDraftPoints: de,
|
|
2260
|
+
commitDraftSession: Oe,
|
|
2261
|
+
completeFreehandStroke: ke,
|
|
2262
|
+
setBrushScalarMode: Ae,
|
|
2265
2263
|
getBrushScalarMode: () => A.current,
|
|
2266
2264
|
hasBrushSession: N,
|
|
2267
|
-
commitBrush:
|
|
2265
|
+
commitBrush: De,
|
|
2268
2266
|
cancelBrush: d(() => {
|
|
2269
|
-
e.current ===
|
|
2270
|
-
}, [
|
|
2271
|
-
beginBrushEditFromSelection:
|
|
2272
|
-
deleteDraftSelectedPoints:
|
|
2273
|
-
hitDraftPoint:
|
|
2274
|
-
getDraftPointsSnapshot:
|
|
2275
|
-
tryClosePolygon:
|
|
2276
|
-
removeDraftPoint:
|
|
2277
|
-
selectDraftPointForDrag:
|
|
2278
|
-
appendPolygonPoint:
|
|
2279
|
-
beginStroke:
|
|
2280
|
-
appendStrokePoint:
|
|
2281
|
-
moveDraftPoints:
|
|
2282
|
-
commitDraftPointDrag:
|
|
2283
|
-
setDraftCursor:
|
|
2284
|
-
finishScalarStroke:
|
|
2267
|
+
e.current === H.BRUSH && B();
|
|
2268
|
+
}, [B, e]),
|
|
2269
|
+
beginBrushEditFromSelection: je,
|
|
2270
|
+
deleteDraftSelectedPoints: Me,
|
|
2271
|
+
hitDraftPoint: Ne,
|
|
2272
|
+
getDraftPointsSnapshot: ue,
|
|
2273
|
+
tryClosePolygon: fe,
|
|
2274
|
+
removeDraftPoint: pe,
|
|
2275
|
+
selectDraftPointForDrag: me,
|
|
2276
|
+
appendPolygonPoint: he,
|
|
2277
|
+
beginStroke: ge,
|
|
2278
|
+
appendStrokePoint: _e,
|
|
2279
|
+
moveDraftPoints: ve,
|
|
2280
|
+
commitDraftPointDrag: V,
|
|
2281
|
+
setDraftCursor: ye,
|
|
2282
|
+
finishScalarStroke: Pe,
|
|
2285
2283
|
handleToolChange: d((e, t) => {
|
|
2286
2284
|
if (t) {
|
|
2287
|
-
|
|
2285
|
+
B(), A.current = "draw";
|
|
2288
2286
|
return;
|
|
2289
2287
|
}
|
|
2290
|
-
if (e !==
|
|
2291
|
-
|
|
2288
|
+
if (e !== H.BRUSH) {
|
|
2289
|
+
B(), A.current = "draw";
|
|
2292
2290
|
return;
|
|
2293
2291
|
}
|
|
2294
|
-
A.current = "draw", T.current = [], y.current = [],
|
|
2292
|
+
A.current = "draw", T.current = [], y.current = [], R(), Ee(), L(), z();
|
|
2295
2293
|
}, [
|
|
2296
|
-
|
|
2297
|
-
B,
|
|
2298
|
-
V,
|
|
2294
|
+
L,
|
|
2299
2295
|
z,
|
|
2300
|
-
|
|
2296
|
+
B,
|
|
2297
|
+
R,
|
|
2298
|
+
Ee
|
|
2301
2299
|
]),
|
|
2302
2300
|
handleBrushSelectionChange: d((t, n) => {
|
|
2303
|
-
if (!(e.current !==
|
|
2301
|
+
if (!(e.current !== H.BRUSH || n)) {
|
|
2304
2302
|
if (!t.length) {
|
|
2305
|
-
|
|
2303
|
+
L();
|
|
2306
2304
|
return;
|
|
2307
2305
|
}
|
|
2308
|
-
[...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || y.current.length || (T.current = [], y.current = [],
|
|
2306
|
+
[...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || y.current.length || (T.current = [], y.current = [], R(), Ee(), L(), z()));
|
|
2309
2307
|
}
|
|
2310
2308
|
}, [
|
|
2311
|
-
|
|
2312
|
-
B,
|
|
2309
|
+
L,
|
|
2313
2310
|
z,
|
|
2314
|
-
|
|
2311
|
+
R,
|
|
2312
|
+
Ee,
|
|
2315
2313
|
e
|
|
2316
2314
|
])
|
|
2317
2315
|
};
|
|
2318
2316
|
}
|
|
2319
2317
|
//#endregion
|
|
2320
2318
|
//#region src/components/ShapeEditor/_state/useEditorDocument.ts
|
|
2321
|
-
function
|
|
2319
|
+
function Ht(e, t) {
|
|
2322
2320
|
return {
|
|
2323
2321
|
shapes: t,
|
|
2324
2322
|
past: [...e.past, e.shapes],
|
|
2325
2323
|
future: []
|
|
2326
2324
|
};
|
|
2327
2325
|
}
|
|
2328
|
-
function
|
|
2326
|
+
function Ut(e, t) {
|
|
2329
2327
|
switch (t.type) {
|
|
2330
|
-
case "CREATE": return
|
|
2328
|
+
case "CREATE": return Ht(e, [...e.shapes, ...t.shapes]);
|
|
2331
2329
|
case "UPDATE": {
|
|
2332
2330
|
let n = new Map(t.shapes.map((e) => [e.id, e]));
|
|
2333
|
-
return
|
|
2331
|
+
return Ht(e, e.shapes.map((e) => n.get(e.id) ?? e));
|
|
2334
2332
|
}
|
|
2335
2333
|
case "DELETE": {
|
|
2336
2334
|
let n = new Set(t.ids);
|
|
2337
|
-
return
|
|
2335
|
+
return Ht(e, e.shapes.filter((e) => !n.has(e.id)));
|
|
2338
2336
|
}
|
|
2339
2337
|
case "REPLACE": {
|
|
2340
2338
|
let n = new Set(t.removeIds);
|
|
2341
|
-
return
|
|
2339
|
+
return Ht(e, [...e.shapes.filter((e) => !n.has(e.id)), ...t.shapes]);
|
|
2342
2340
|
}
|
|
2343
2341
|
case "REORDER": {
|
|
2344
2342
|
let n = new Set(t.ids), r = e.shapes.filter((e) => n.has(e.id)), i = e.shapes.filter((e) => !n.has(e.id));
|
|
2345
|
-
return r.length === 0 ? e :
|
|
2343
|
+
return r.length === 0 ? e : Ht(e, t.edge === "front" ? [...i, ...r] : [...r, ...i]);
|
|
2346
2344
|
}
|
|
2347
2345
|
case "RESET": return {
|
|
2348
2346
|
shapes: t.shapes,
|
|
@@ -2362,15 +2360,15 @@ function Ht(e, t) {
|
|
|
2362
2360
|
default: return e;
|
|
2363
2361
|
}
|
|
2364
2362
|
}
|
|
2365
|
-
function
|
|
2366
|
-
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = _(
|
|
2363
|
+
function Wt(e) {
|
|
2364
|
+
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = _(Ut, {
|
|
2367
2365
|
shapes: [],
|
|
2368
2366
|
past: [],
|
|
2369
2367
|
future: []
|
|
2370
2368
|
}), o = v(i);
|
|
2371
2369
|
o.current = i;
|
|
2372
2370
|
let s = d((e) => {
|
|
2373
|
-
o.current =
|
|
2371
|
+
o.current = Ut(o.current, e), a(e);
|
|
2374
2372
|
}, []), c = d((e, i) => {
|
|
2375
2373
|
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));
|
|
2376
2374
|
s.length && t?.(s);
|
|
@@ -2439,7 +2437,7 @@ function Ut(e) {
|
|
|
2439
2437
|
}
|
|
2440
2438
|
//#endregion
|
|
2441
2439
|
//#region src/components/ShapeEditor/_model/keymap.ts
|
|
2442
|
-
var
|
|
2440
|
+
var Gt = {
|
|
2443
2441
|
undo: ["mod+z"],
|
|
2444
2442
|
redo: ["mod+shift+z"],
|
|
2445
2443
|
selectAll: ["mod+a"],
|
|
@@ -2452,8 +2450,6 @@ var Wt = {
|
|
|
2452
2450
|
commitDraft: ["enter"],
|
|
2453
2451
|
bringToFront: ["mod+]"],
|
|
2454
2452
|
sendToBack: ["mod+["],
|
|
2455
|
-
flipHorizontal: ["shift+h"],
|
|
2456
|
-
flipVertical: ["shift+v"],
|
|
2457
2453
|
zoomIn: ["mod+=", "mod+shift+="],
|
|
2458
2454
|
zoomOut: ["mod+-"],
|
|
2459
2455
|
zoom100: ["shift+1"],
|
|
@@ -2469,7 +2465,7 @@ var Wt = {
|
|
|
2469
2465
|
pathTool: ["g"],
|
|
2470
2466
|
brushTool: ["b"],
|
|
2471
2467
|
pointTool: ["i"]
|
|
2472
|
-
},
|
|
2468
|
+
}, Kt = {
|
|
2473
2469
|
Equal: "=",
|
|
2474
2470
|
Minus: "-",
|
|
2475
2471
|
BracketLeft: "[",
|
|
@@ -2479,7 +2475,7 @@ var Wt = {
|
|
|
2479
2475
|
Comma: ",",
|
|
2480
2476
|
Slash: "/",
|
|
2481
2477
|
Backquote: "`"
|
|
2482
|
-
},
|
|
2478
|
+
}, qt = {
|
|
2483
2479
|
Escape: "escape",
|
|
2484
2480
|
Enter: "enter",
|
|
2485
2481
|
Backspace: "backspace",
|
|
@@ -2490,58 +2486,58 @@ var Wt = {
|
|
|
2490
2486
|
ArrowLeft: "arrowleft",
|
|
2491
2487
|
ArrowRight: "arrowright"
|
|
2492
2488
|
};
|
|
2493
|
-
function
|
|
2489
|
+
function Jt(e) {
|
|
2494
2490
|
let t = e.code, n = /^Key([A-Z])$/.exec(t);
|
|
2495
2491
|
if (n) return n[1].toLowerCase();
|
|
2496
2492
|
let r = /^Digit([0-9])$/.exec(t);
|
|
2497
|
-
return r ? r[1] :
|
|
2493
|
+
return r ? r[1] : Kt[t] ? Kt[t] : qt[e.key] ? qt[e.key] : null;
|
|
2498
2494
|
}
|
|
2499
|
-
function
|
|
2500
|
-
let t =
|
|
2495
|
+
function Yt(e) {
|
|
2496
|
+
let t = Jt(e);
|
|
2501
2497
|
if (!t) return null;
|
|
2502
2498
|
let n = [];
|
|
2503
2499
|
return (e.metaKey || e.ctrlKey) && n.push("mod"), e.shiftKey && n.push("shift"), e.altKey && n.push("alt"), n.push(t), n.join("+");
|
|
2504
2500
|
}
|
|
2505
|
-
function
|
|
2501
|
+
function Xt(e) {
|
|
2506
2502
|
let t = /* @__PURE__ */ new Map();
|
|
2507
|
-
for (let n of Object.keys(
|
|
2508
|
-
let r = e?.[n], i = r === void 0 ?
|
|
2503
|
+
for (let n of Object.keys(Gt)) {
|
|
2504
|
+
let r = e?.[n], i = r === void 0 ? Gt[n] : r === null ? [] : Array.isArray(r) ? r : [r];
|
|
2509
2505
|
for (let e of i) t.set(e.toLowerCase(), n);
|
|
2510
2506
|
}
|
|
2511
2507
|
return t;
|
|
2512
2508
|
}
|
|
2513
2509
|
//#endregion
|
|
2514
2510
|
//#region src/components/ShapeEditor/_state/useEditorHotkeys.ts
|
|
2515
|
-
var
|
|
2511
|
+
var Zt = {
|
|
2516
2512
|
ArrowUp: [0, -1],
|
|
2517
2513
|
ArrowDown: [0, 1],
|
|
2518
2514
|
ArrowLeft: [-1, 0],
|
|
2519
2515
|
ArrowRight: [1, 0]
|
|
2520
2516
|
};
|
|
2521
|
-
function
|
|
2517
|
+
function Qt() {
|
|
2522
2518
|
let e = document.activeElement;
|
|
2523
2519
|
return !!e && (e.tagName === "INPUT" || e.tagName === "TEXTAREA" || e.isContentEditable);
|
|
2524
2520
|
}
|
|
2525
|
-
function
|
|
2521
|
+
function $t(e, t) {
|
|
2526
2522
|
if (!t || !(e instanceof Element)) return !1;
|
|
2527
2523
|
let n = e.closest("[role=\"dialog\"],[aria-modal=\"true\"]");
|
|
2528
2524
|
return !!n && !n.contains(t);
|
|
2529
2525
|
}
|
|
2530
|
-
function
|
|
2531
|
-
let { spaceRef: t, shiftRef: n } = e, r = g(() =>
|
|
2526
|
+
function en(e) {
|
|
2527
|
+
let { spaceRef: t, shiftRef: n } = e, r = g(() => Xt(e.keymap), [e.keymap]), i = v(e);
|
|
2532
2528
|
i.current = e;
|
|
2533
2529
|
let a = v(r);
|
|
2534
2530
|
a.current = r, f(() => {
|
|
2535
2531
|
let e = (e) => {
|
|
2536
|
-
if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0),
|
|
2537
|
-
let r =
|
|
2532
|
+
if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0), Qt() || $t(e.target, i.current.hostRef.current)) return;
|
|
2533
|
+
let r = Zt[e.key];
|
|
2538
2534
|
if (r) {
|
|
2539
2535
|
e.preventDefault();
|
|
2540
2536
|
let t = e.shiftKey ? 10 : 1;
|
|
2541
2537
|
i.current.nudge(r[0] * t, r[1] * t);
|
|
2542
2538
|
return;
|
|
2543
2539
|
}
|
|
2544
|
-
let o =
|
|
2540
|
+
let o = Yt(e);
|
|
2545
2541
|
if (!o) return;
|
|
2546
2542
|
let s = a.current.get(o);
|
|
2547
2543
|
s && i.current.actions[s]?.() !== !1 && e.preventDefault();
|
|
@@ -2555,7 +2551,7 @@ function $t(e) {
|
|
|
2555
2551
|
}
|
|
2556
2552
|
//#endregion
|
|
2557
2553
|
//#region src/components/ShapeEditor/_model/imageFetch.ts
|
|
2558
|
-
async function
|
|
2554
|
+
async function tn(e) {
|
|
2559
2555
|
for (let t of ["default", "reload"]) try {
|
|
2560
2556
|
let n = await fetch(e, {
|
|
2561
2557
|
mode: "cors",
|
|
@@ -2568,8 +2564,8 @@ async function en(e) {
|
|
|
2568
2564
|
}
|
|
2569
2565
|
//#endregion
|
|
2570
2566
|
//#region src/components/ShapeEditor/_model/imageTiles.ts
|
|
2571
|
-
var
|
|
2572
|
-
function
|
|
2567
|
+
var nn = 4e3;
|
|
2568
|
+
function rn(e, t, n = nn) {
|
|
2573
2569
|
if (e <= 0 || t <= 0) return [];
|
|
2574
2570
|
let r = Math.ceil(e / n), i = Math.ceil(t / n);
|
|
2575
2571
|
return Array.from({ length: i }, (a, o) => Array.from({ length: r }, (a, s) => {
|
|
@@ -2584,7 +2580,7 @@ function nn(e, t, n = tn) {
|
|
|
2584
2580
|
};
|
|
2585
2581
|
})).flat();
|
|
2586
2582
|
}
|
|
2587
|
-
function
|
|
2583
|
+
function an(e, t) {
|
|
2588
2584
|
let n = document.createElement("canvas");
|
|
2589
2585
|
n.width = t.width, n.height = t.height;
|
|
2590
2586
|
let r = n.getContext("2d");
|
|
@@ -2592,7 +2588,7 @@ function rn(e, t) {
|
|
|
2592
2588
|
}
|
|
2593
2589
|
//#endregion
|
|
2594
2590
|
//#region src/components/ShapeEditor/_model/konva.ts
|
|
2595
|
-
function
|
|
2591
|
+
function on(e, t, n) {
|
|
2596
2592
|
if (t === j.POINT) {
|
|
2597
2593
|
e.setAttrs({
|
|
2598
2594
|
x: n[0].x,
|
|
@@ -2611,7 +2607,7 @@ function an(e, t, n) {
|
|
|
2611
2607
|
return;
|
|
2612
2608
|
}
|
|
2613
2609
|
if (t === j.ELLIPSE) {
|
|
2614
|
-
let t =
|
|
2610
|
+
let t = I(n);
|
|
2615
2611
|
e.setAttrs({
|
|
2616
2612
|
x: (t.minX + t.maxX) / 2,
|
|
2617
2613
|
y: (t.minY + t.maxY) / 2,
|
|
@@ -2628,23 +2624,23 @@ function an(e, t, n) {
|
|
|
2628
2624
|
}
|
|
2629
2625
|
//#endregion
|
|
2630
2626
|
//#region src/components/ShapeEditor/_model/pinIcon.ts
|
|
2631
|
-
var
|
|
2632
|
-
function
|
|
2633
|
-
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${
|
|
2627
|
+
var sn = "M8 0C12.4183 0 16 3.58172 16 8C16 11.5323 13.71 14.5277 10.5342 15.5879L10.166 20.0068C10.0721 21.1334 9.13046 22 8 22C6.86954 22 5.92786 21.1334 5.83398 20.0068L5.46484 15.5879C2.28949 14.5275 0 11.532 0 8C0 3.58172 3.58172 0 8 0Z", cn = "#ffffff", ln = 1.5;
|
|
2628
|
+
function un(e) {
|
|
2629
|
+
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${sn}" fill="${e}" stroke="${cn}" stroke-width="${ln}"/></svg>`;
|
|
2634
2630
|
}
|
|
2635
2631
|
//#endregion
|
|
2636
2632
|
//#region src/components/ShapeEditor/_renderers/transformSession.ts
|
|
2637
|
-
var
|
|
2638
|
-
function
|
|
2633
|
+
var dn = Math.PI / 12;
|
|
2634
|
+
function fn(e, t) {
|
|
2639
2635
|
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === j.ROTATED_RECTANGLE;
|
|
2640
2636
|
}
|
|
2641
|
-
function
|
|
2637
|
+
function pn(e, t, n) {
|
|
2642
2638
|
if (e.kind === "resize") {
|
|
2643
|
-
let r = n ? e.box :
|
|
2639
|
+
let r = n ? e.box : ae(e.anchor, e.box, t.x, t.y);
|
|
2644
2640
|
return {
|
|
2645
2641
|
updates: e.shapes.map((i) => ({
|
|
2646
2642
|
id: i.id,
|
|
2647
|
-
points: n ?
|
|
2643
|
+
points: n ? _e(i.points, e.anchor, t) : ve(i.points, e.box, r)
|
|
2648
2644
|
})),
|
|
2649
2645
|
box: r
|
|
2650
2646
|
};
|
|
@@ -2669,10 +2665,10 @@ function fn(e, t, n) {
|
|
|
2669
2665
|
}
|
|
2670
2666
|
if (e.kind === "rotate") {
|
|
2671
2667
|
let n = Math.atan2(t.y - e.center.y, t.x - e.center.x) - e.startAngle;
|
|
2672
|
-
return e.shiftKey && (n = Math.round(n /
|
|
2668
|
+
return e.shiftKey && (n = Math.round(n / dn) * dn), {
|
|
2673
2669
|
updates: [{
|
|
2674
2670
|
id: e.id,
|
|
2675
|
-
points: e.points.map((t) =>
|
|
2671
|
+
points: e.points.map((t) => L(t, e.center, n))
|
|
2676
2672
|
}],
|
|
2677
2673
|
box: null
|
|
2678
2674
|
};
|
|
@@ -2686,48 +2682,48 @@ function fn(e, t, n) {
|
|
|
2686
2682
|
id: e.id,
|
|
2687
2683
|
points: a
|
|
2688
2684
|
}],
|
|
2689
|
-
box:
|
|
2685
|
+
box: I(a)
|
|
2690
2686
|
};
|
|
2691
2687
|
}
|
|
2692
|
-
function
|
|
2688
|
+
function mn(e, t) {
|
|
2693
2689
|
return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
|
|
2694
2690
|
x: t.center.x + Math.cos(t.startAngle),
|
|
2695
2691
|
y: t.center.y + Math.sin(t.startAngle)
|
|
2696
|
-
} :
|
|
2692
|
+
} : fn(e, t) ? me(t.shapes[0].points)[F.indexOf(t.anchor)] : ie(t.anchor, t.box);
|
|
2697
2693
|
}
|
|
2698
|
-
function
|
|
2699
|
-
let r = e.filter((e) => t.includes(e.id) &&
|
|
2694
|
+
function hn(e, t, n) {
|
|
2695
|
+
let r = e.filter((e) => t.includes(e.id) && te(e)).map((e) => ({
|
|
2700
2696
|
id: e.id,
|
|
2701
2697
|
points: e.points
|
|
2702
2698
|
}));
|
|
2703
2699
|
return r.length ? {
|
|
2704
2700
|
kind: "move",
|
|
2705
2701
|
start: n,
|
|
2706
|
-
box:
|
|
2702
|
+
box: I(r.flatMap((e) => e.points)),
|
|
2707
2703
|
shapes: r
|
|
2708
2704
|
} : null;
|
|
2709
2705
|
}
|
|
2710
|
-
function
|
|
2706
|
+
function gn(e) {
|
|
2711
2707
|
return e.map((e) => ({
|
|
2712
2708
|
...e,
|
|
2713
2709
|
points: e.points.map((e) => ({ ...e }))
|
|
2714
2710
|
}));
|
|
2715
2711
|
}
|
|
2716
|
-
function
|
|
2712
|
+
function _n(e, t) {
|
|
2717
2713
|
let n = new Set(t);
|
|
2718
2714
|
return e.filter((e) => n.has(e.id) && ee(e));
|
|
2719
2715
|
}
|
|
2720
|
-
function
|
|
2716
|
+
function vn(e, t) {
|
|
2721
2717
|
return e.filter((e) => {
|
|
2722
2718
|
if (!P(e)) return !1;
|
|
2723
|
-
let n =
|
|
2719
|
+
let n = I(e.points);
|
|
2724
2720
|
return n.minX <= t.maxX && n.maxX >= t.minX && n.minY <= t.maxY && n.maxY >= t.minY;
|
|
2725
2721
|
}).map((e) => e.id);
|
|
2726
2722
|
}
|
|
2727
|
-
function
|
|
2728
|
-
return (e ?
|
|
2723
|
+
function yn(e, t, n) {
|
|
2724
|
+
return (e ? Pe(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
|
|
2729
2725
|
}
|
|
2730
|
-
function
|
|
2726
|
+
function bn(e, t) {
|
|
2731
2727
|
return {
|
|
2732
2728
|
minX: e.x - t,
|
|
2733
2729
|
minY: e.y - t,
|
|
@@ -2735,10 +2731,10 @@ function yn(e, t) {
|
|
|
2735
2731
|
maxY: e.y + t
|
|
2736
2732
|
};
|
|
2737
2733
|
}
|
|
2738
|
-
function
|
|
2734
|
+
function xn(e, t, n) {
|
|
2739
2735
|
if (e.type === j.ROTATED_RECTANGLE) return t;
|
|
2740
|
-
let r = e.type === j.POINT ?
|
|
2741
|
-
return
|
|
2736
|
+
let r = e.type === j.POINT ? bn(t[0], n) : I(t);
|
|
2737
|
+
return R([{
|
|
2742
2738
|
x: r.minX,
|
|
2743
2739
|
y: r.minY
|
|
2744
2740
|
}, {
|
|
@@ -2746,17 +2742,17 @@ function bn(e, t, n) {
|
|
|
2746
2742
|
y: r.maxY
|
|
2747
2743
|
}]);
|
|
2748
2744
|
}
|
|
2749
|
-
function
|
|
2745
|
+
function Sn(e) {
|
|
2750
2746
|
return 24 / (e || 1);
|
|
2751
2747
|
}
|
|
2752
|
-
function
|
|
2748
|
+
function Cn(e, t) {
|
|
2753
2749
|
return Math.atan2(t.y - e.y, t.x - e.x);
|
|
2754
2750
|
}
|
|
2755
2751
|
//#endregion
|
|
2756
2752
|
//#region src/components/ShapeEditor/_renderers/KonvaRenderer.ts
|
|
2757
|
-
var
|
|
2753
|
+
var wn = 2, Tn = "#1e88e5", En = "#669def", Dn = class {
|
|
2758
2754
|
constructor(e, t) {
|
|
2759
|
-
this.layer = new C.Layer(), this.world = new C.Group(), this.bgGroup = new C.Group(), this.overlayGroup = new C.Group({ listening: !1 }), this.shapeGroup = new C.Group(), this.selGroup = new C.Group(), this.previewGroup = new C.Group(), this.handleGroup = new C.Group(), this.baseCursor = "default", this.strokeSize =
|
|
2755
|
+
this.layer = new C.Layer(), this.world = new C.Group(), this.bgGroup = new C.Group(), this.overlayGroup = new C.Group({ listening: !1 }), this.shapeGroup = new C.Group(), this.selGroup = new C.Group(), this.previewGroup = new C.Group(), this.handleGroup = new C.Group(), this.baseCursor = "default", this.strokeSize = wn, this.imageSmoothing = !0, this.imageWidth = 0, this.imageHeight = 0, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.altNodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.imageLoadToken = 0, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastImg = {
|
|
2760
2756
|
x: 0,
|
|
2761
2757
|
y: 0
|
|
2762
2758
|
}, this.lastDragImg = null, this.ro = null, this.activeDrag = null, this.midNodes = [], this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorders = [], this.upCleanup = null, this.lastPreviewPoly = null, this.preview = null, this.marquee = null, this.host = e, this.cb = t, this.stage = new C.Stage({
|
|
@@ -2847,15 +2843,20 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
2847
2843
|
imgToScreen(e) {
|
|
2848
2844
|
return this.world.getAbsoluteTransform().point(e);
|
|
2849
2845
|
}
|
|
2850
|
-
async setImage(e) {
|
|
2851
|
-
let
|
|
2852
|
-
await new Promise((
|
|
2853
|
-
let
|
|
2854
|
-
|
|
2855
|
-
if (
|
|
2856
|
-
this.imageWidth =
|
|
2857
|
-
|
|
2858
|
-
|
|
2846
|
+
async setImage(e, t, n) {
|
|
2847
|
+
let r = ++this.imageLoadToken, i = await tn(e);
|
|
2848
|
+
await new Promise((a) => {
|
|
2849
|
+
let o = new Image();
|
|
2850
|
+
i || (o.crossOrigin = "anonymous"), o.onload = () => {
|
|
2851
|
+
if (i && URL.revokeObjectURL(i), r !== this.imageLoadToken) return a();
|
|
2852
|
+
this.imageWidth = t?.width ?? o.naturalWidth, this.imageHeight = t?.height ?? o.naturalHeight;
|
|
2853
|
+
let e = n?.width ?? this.imageWidth, s = n?.height ?? this.imageHeight;
|
|
2854
|
+
this.bgGroup.scale({
|
|
2855
|
+
x: e / o.naturalWidth,
|
|
2856
|
+
y: s / o.naturalHeight
|
|
2857
|
+
}), this.bgGroup.destroyChildren();
|
|
2858
|
+
for (let e of rn(o.naturalWidth, o.naturalHeight)) this.bgGroup.add(new C.Image({
|
|
2859
|
+
image: o,
|
|
2859
2860
|
x: e.x,
|
|
2860
2861
|
y: e.y,
|
|
2861
2862
|
width: e.width,
|
|
@@ -2868,10 +2869,10 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
2868
2869
|
},
|
|
2869
2870
|
listening: !1
|
|
2870
2871
|
}));
|
|
2871
|
-
this.layer.batchDraw(),
|
|
2872
|
-
},
|
|
2873
|
-
|
|
2874
|
-
},
|
|
2872
|
+
this.layer.batchDraw(), a();
|
|
2873
|
+
}, o.onerror = () => {
|
|
2874
|
+
i && URL.revokeObjectURL(i), this.imageWidth ||= 800, this.imageHeight ||= 600, a();
|
|
2875
|
+
}, o.src = i ?? e;
|
|
2875
2876
|
});
|
|
2876
2877
|
}
|
|
2877
2878
|
clearImage() {
|
|
@@ -2898,7 +2899,7 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
2898
2899
|
if (this.overlayGroup.add(new C.Shape({
|
|
2899
2900
|
listening: !1,
|
|
2900
2901
|
sceneFunc: (r) => {
|
|
2901
|
-
|
|
2902
|
+
st(r._context, t, e, n);
|
|
2902
2903
|
}
|
|
2903
2904
|
})), t.outlineStyles) {
|
|
2904
2905
|
let e = (e, t) => {
|
|
@@ -2962,7 +2963,7 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
2962
2963
|
let e = this.lastPreviewPoly;
|
|
2963
2964
|
e && this.previewPoly(e.points, e.cursor, e.style, e.closed, e.selectedPointIndices, e.showVertices);
|
|
2964
2965
|
}
|
|
2965
|
-
this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
2966
|
+
this.activeDrag ? this.dragTransform(this.lastDragImg ?? mn(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
|
|
2966
2967
|
}
|
|
2967
2968
|
fit() {
|
|
2968
2969
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -2991,10 +2992,10 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
2991
2992
|
});
|
|
2992
2993
|
}
|
|
2993
2994
|
setShapes(e, t) {
|
|
2994
|
-
if (this.shapes =
|
|
2995
|
+
if (this.shapes = gn(e), this.selected = t, !this.activeDrag) {
|
|
2995
2996
|
this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
|
|
2996
|
-
for (let t of
|
|
2997
|
-
let e = this.makeNode(t), n =
|
|
2997
|
+
for (let t of ne(e).filter(M)) {
|
|
2998
|
+
let e = this.makeNode(t), n = Pe(t, { strokeWidth: this.strokeSize });
|
|
2998
2999
|
if (t.style?.alternateColor && n.dash?.length && t.type !== j.POINT) {
|
|
2999
3000
|
let n = e.clone({
|
|
3000
3001
|
id: `${t.id}__alt`,
|
|
@@ -3017,7 +3018,7 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3017
3018
|
this.editingId !== e && (this.editingId = e, this.selectedVertices.clear(), this.activeDrag || (this.drawTransformer(), this.layer.batchDraw()));
|
|
3018
3019
|
}
|
|
3019
3020
|
makeNode(e) {
|
|
3020
|
-
let { type: t, points: n } = e, r =
|
|
3021
|
+
let { type: t, points: n } = e, r = Pe(e, { strokeWidth: this.strokeSize }), i = P(e), a = {
|
|
3021
3022
|
id: e.id,
|
|
3022
3023
|
stroke: r.color,
|
|
3023
3024
|
strokeWidth: r.strokeWidth,
|
|
@@ -3025,11 +3026,11 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3025
3026
|
opacity: r.opacity,
|
|
3026
3027
|
strokeScaleEnabled: !1,
|
|
3027
3028
|
listening: i
|
|
3028
|
-
}, o = r.fillVisible ?
|
|
3029
|
+
}, o = r.fillVisible ? U(r.color, r.fillAlpha) : void 0;
|
|
3029
3030
|
if (t === j.POINT) {
|
|
3030
3031
|
let t = 1 / (this.world.scaleX() || 1), a = new C.Path({
|
|
3031
3032
|
id: e.id,
|
|
3032
|
-
data:
|
|
3033
|
+
data: sn,
|
|
3033
3034
|
x: n[0].x,
|
|
3034
3035
|
y: n[0].y,
|
|
3035
3036
|
offsetX: 16 / 2,
|
|
@@ -3037,8 +3038,8 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3037
3038
|
scaleX: t,
|
|
3038
3039
|
scaleY: t,
|
|
3039
3040
|
fill: r.color,
|
|
3040
|
-
stroke:
|
|
3041
|
-
strokeWidth:
|
|
3041
|
+
stroke: cn,
|
|
3042
|
+
strokeWidth: ln,
|
|
3042
3043
|
strokeScaleEnabled: !1,
|
|
3043
3044
|
shadowColor: "#000",
|
|
3044
3045
|
shadowBlur: 2,
|
|
@@ -3047,10 +3048,10 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3047
3048
|
opacity: r.opacity,
|
|
3048
3049
|
listening: i
|
|
3049
3050
|
});
|
|
3050
|
-
return this.bindCursor(a,
|
|
3051
|
+
return this.bindCursor(a, te(e) ? "grab" : "default"), a;
|
|
3051
3052
|
}
|
|
3052
3053
|
if (t === j.RECTANGLE) {
|
|
3053
|
-
let t =
|
|
3054
|
+
let t = I(n), r = new C.Rect({
|
|
3054
3055
|
x: t.minX,
|
|
3055
3056
|
y: t.minY,
|
|
3056
3057
|
width: t.maxX - t.minX,
|
|
@@ -3058,10 +3059,10 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3058
3059
|
fill: o,
|
|
3059
3060
|
...a
|
|
3060
3061
|
});
|
|
3061
|
-
return this.bindCursor(r,
|
|
3062
|
+
return this.bindCursor(r, te(e) ? "grab" : "default"), r;
|
|
3062
3063
|
}
|
|
3063
3064
|
if (t === j.ELLIPSE) {
|
|
3064
|
-
let t =
|
|
3065
|
+
let t = I(n), r = new C.Ellipse({
|
|
3065
3066
|
x: (t.minX + t.maxX) / 2,
|
|
3066
3067
|
y: (t.minY + t.maxY) / 2,
|
|
3067
3068
|
radiusX: (t.maxX - t.minX) / 2,
|
|
@@ -3069,7 +3070,7 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3069
3070
|
fill: o,
|
|
3070
3071
|
...a
|
|
3071
3072
|
});
|
|
3072
|
-
return this.bindCursor(r,
|
|
3073
|
+
return this.bindCursor(r, te(e) ? "grab" : "default"), r;
|
|
3073
3074
|
}
|
|
3074
3075
|
let s = n.flatMap((e) => [e.x, e.y]), c = t !== j.LINE, l = new C.Line({
|
|
3075
3076
|
points: s,
|
|
@@ -3078,18 +3079,18 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3078
3079
|
lineJoin: "round",
|
|
3079
3080
|
...a
|
|
3080
3081
|
});
|
|
3081
|
-
return this.bindCursor(l,
|
|
3082
|
+
return this.bindCursor(l, te(e) ? "grab" : "default"), l;
|
|
3082
3083
|
}
|
|
3083
3084
|
liveUpdateShape(e, t) {
|
|
3084
3085
|
let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
|
|
3085
3086
|
if (n && r) {
|
|
3086
|
-
|
|
3087
|
+
on(n, r.type, t);
|
|
3087
3088
|
let i = this.altNodes.get(e);
|
|
3088
|
-
i &&
|
|
3089
|
+
i && on(i, r.type, t), r.type === j.POINT && n instanceof C.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
|
|
3089
3090
|
}
|
|
3090
3091
|
}
|
|
3091
3092
|
pointRadius(e) {
|
|
3092
|
-
return
|
|
3093
|
+
return yn(e, this.strokeSize, this.world.scaleX() || 1);
|
|
3093
3094
|
}
|
|
3094
3095
|
scaledDash(e) {
|
|
3095
3096
|
return e;
|
|
@@ -3105,11 +3106,11 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3105
3106
|
});
|
|
3106
3107
|
continue;
|
|
3107
3108
|
}
|
|
3108
|
-
n?.dash(this.scaledDash(
|
|
3109
|
+
n?.dash(this.scaledDash(Pe(t, { strokeWidth: this.strokeSize }).dash));
|
|
3109
3110
|
}
|
|
3110
3111
|
}
|
|
3111
3112
|
shapesIntersecting(e) {
|
|
3112
|
-
return
|
|
3113
|
+
return vn(this.shapes, e);
|
|
3113
3114
|
}
|
|
3114
3115
|
drawSelectionBorders() {
|
|
3115
3116
|
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && P(t)) : [];
|
|
@@ -3118,7 +3119,7 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3118
3119
|
this.selectionBorders = t.map(() => {
|
|
3119
3120
|
let e = new C.Line({
|
|
3120
3121
|
closed: !0,
|
|
3121
|
-
stroke:
|
|
3122
|
+
stroke: En,
|
|
3122
3123
|
strokeWidth: 1.5,
|
|
3123
3124
|
strokeScaleEnabled: !1,
|
|
3124
3125
|
listening: !1
|
|
@@ -3139,7 +3140,7 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3139
3140
|
}
|
|
3140
3141
|
}
|
|
3141
3142
|
selectionOutlinePoints(e, t) {
|
|
3142
|
-
return
|
|
3143
|
+
return xn(e, t, this.pointRadius(e));
|
|
3143
3144
|
}
|
|
3144
3145
|
clearPreview() {
|
|
3145
3146
|
this.lastPreviewPoly = null, this.previewGroup.destroyChildren(), this.layer.batchDraw();
|
|
@@ -3202,8 +3203,8 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3202
3203
|
x: n.x,
|
|
3203
3204
|
y: n.y,
|
|
3204
3205
|
radius: (r ? 6 : 5) / l,
|
|
3205
|
-
fill: r ?
|
|
3206
|
-
stroke: r ? "#ffffff" :
|
|
3206
|
+
fill: r ? Tn : "#ffffff",
|
|
3207
|
+
stroke: r ? "#ffffff" : Tn,
|
|
3207
3208
|
strokeWidth: 1.5,
|
|
3208
3209
|
strokeScaleEnabled: !1,
|
|
3209
3210
|
listening: !1
|
|
@@ -3213,7 +3214,7 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3213
3214
|
}
|
|
3214
3215
|
previewScalarMask(e, t) {
|
|
3215
3216
|
this.previewGroup.destroyChildren();
|
|
3216
|
-
let n =
|
|
3217
|
+
let n = It(e, t.length === 7 ? `${t}99` : t);
|
|
3217
3218
|
this.previewGroup.add(new C.Image({
|
|
3218
3219
|
image: n,
|
|
3219
3220
|
x: e.ox,
|
|
@@ -3225,8 +3226,8 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3225
3226
|
}
|
|
3226
3227
|
previewMarquee(e, t) {
|
|
3227
3228
|
this.marquee || (this.marquee = new C.Rect({
|
|
3228
|
-
fill:
|
|
3229
|
-
stroke:
|
|
3229
|
+
fill: U(Ae, je),
|
|
3230
|
+
stroke: Ae,
|
|
3230
3231
|
strokeWidth: 1,
|
|
3231
3232
|
strokeScaleEnabled: !1,
|
|
3232
3233
|
listening: !1,
|
|
@@ -3246,7 +3247,7 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3246
3247
|
}
|
|
3247
3248
|
setTransformerOutline(e) {
|
|
3248
3249
|
let t = Math.max(0, e.maxX - e.minX), n = Math.max(0, e.maxY - e.minY);
|
|
3249
|
-
!t && !n || this.setTransformerOutlinePoints(
|
|
3250
|
+
!t && !n || this.setTransformerOutlinePoints(R([{
|
|
3250
3251
|
x: e.minX,
|
|
3251
3252
|
y: e.minY
|
|
3252
3253
|
}, {
|
|
@@ -3257,20 +3258,20 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3257
3258
|
setTransformerOutlinePoints(e) {
|
|
3258
3259
|
e.length < 2 || (this.transformerOutline || (this.transformerOutline = new C.Line({
|
|
3259
3260
|
closed: !0,
|
|
3260
|
-
stroke:
|
|
3261
|
+
stroke: Tn,
|
|
3261
3262
|
strokeWidth: 1,
|
|
3262
3263
|
strokeScaleEnabled: !1,
|
|
3263
3264
|
listening: !1
|
|
3264
3265
|
}), this.selGroup.add(this.transformerOutline)), this.transformerOutline.points(e.flatMap((e) => [e.x, e.y])));
|
|
3265
3266
|
}
|
|
3266
3267
|
rotationHandleGap() {
|
|
3267
|
-
return
|
|
3268
|
+
return Sn(this.viewport.scale);
|
|
3268
3269
|
}
|
|
3269
3270
|
rotationHandleScreenPoint(e) {
|
|
3270
|
-
return this.imgToScreen(
|
|
3271
|
+
return this.imgToScreen(he(e, this.rotationHandleGap()));
|
|
3271
3272
|
}
|
|
3272
3273
|
setRotationConnector(e) {
|
|
3273
|
-
let t = this.imgToScreen(
|
|
3274
|
+
let t = this.imgToScreen(fe(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
|
|
3274
3275
|
this.rotLineNode ? this.rotLineNode.points([
|
|
3275
3276
|
t.x,
|
|
3276
3277
|
t.y,
|
|
@@ -3283,7 +3284,7 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3283
3284
|
n.x,
|
|
3284
3285
|
n.y
|
|
3285
3286
|
],
|
|
3286
|
-
stroke:
|
|
3287
|
+
stroke: Tn,
|
|
3287
3288
|
strokeWidth: 1,
|
|
3288
3289
|
listening: !1
|
|
3289
3290
|
}), this.handleGroup.add(this.rotLineNode));
|
|
@@ -3298,11 +3299,11 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3298
3299
|
}), e.rotation(n * 180 / Math.PI);
|
|
3299
3300
|
}
|
|
3300
3301
|
orientedHandleAngle(e) {
|
|
3301
|
-
return
|
|
3302
|
+
return Cn(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
3302
3303
|
}
|
|
3303
3304
|
repositionOrientedHandles(e) {
|
|
3304
3305
|
let t = this.orientedHandleAngle(e);
|
|
3305
|
-
if (
|
|
3306
|
+
if (me(e).forEach((e, n) => {
|
|
3306
3307
|
let r = this.imgToScreen(e), i = this.handleNodes[n];
|
|
3307
3308
|
i && this.layoutResizeHandle(i, r, t);
|
|
3308
3309
|
}), this.setTransformerOutlinePoints(e), this.rotNode) {
|
|
@@ -3320,13 +3321,13 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3320
3321
|
for (let e of this.vertexNodes) e.destroy();
|
|
3321
3322
|
for (let e of this.midNodes) e.destroy();
|
|
3322
3323
|
if (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;
|
|
3323
|
-
let e =
|
|
3324
|
+
let e = _n(this.shapes, this.selected);
|
|
3324
3325
|
if (!e.length || e.length === 1 && e[0].type === j.POINT) return;
|
|
3325
|
-
let t = e.length === 1 && (e[0].type === j.POLYGON || e[0].type === j.LINE) && this.editingId === e[0].id ? e[0] : null, n =
|
|
3326
|
+
let t = e.length === 1 && (e[0].type === j.POLYGON || e[0].type === j.LINE) && this.editingId === e[0].id ? e[0] : null, n = I(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === j.ROTATED_RECTANGLE ? e[0] : null, i = r ? me(r.points) : F.map((e) => ie(e, n));
|
|
3326
3327
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
3327
3328
|
let a = r ? this.orientedHandleAngle(r.points) : 0;
|
|
3328
|
-
for (let e of t ? [] :
|
|
3329
|
-
let t = this.imgToScreen(i[
|
|
3329
|
+
for (let e of t ? [] : F) {
|
|
3330
|
+
let t = this.imgToScreen(i[F.indexOf(e)]), n = new C.Rect({
|
|
3330
3331
|
x: t.x,
|
|
3331
3332
|
y: t.y,
|
|
3332
3333
|
width: 8,
|
|
@@ -3335,16 +3336,16 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3335
3336
|
offsetY: 4,
|
|
3336
3337
|
rotation: a * 180 / Math.PI,
|
|
3337
3338
|
fill: "#ffffff",
|
|
3338
|
-
stroke:
|
|
3339
|
+
stroke: Tn,
|
|
3339
3340
|
strokeWidth: 1
|
|
3340
|
-
}), r =
|
|
3341
|
+
}), r = Xe(e, a);
|
|
3341
3342
|
this.bindCursor(n, r), n.on("mousedown", (t) => {
|
|
3342
3343
|
t.cancelBubble = !0, this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
3343
|
-
let n =
|
|
3344
|
+
let n = _n(this.shapes, this.selected);
|
|
3344
3345
|
this.activeDrag = {
|
|
3345
3346
|
kind: "resize",
|
|
3346
3347
|
anchor: e,
|
|
3347
|
-
box:
|
|
3348
|
+
box: I(n.flatMap((e) => e.points)),
|
|
3348
3349
|
shapes: n.map((e) => ({
|
|
3349
3350
|
id: e.id,
|
|
3350
3351
|
points: e.points
|
|
@@ -3364,7 +3365,7 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3364
3365
|
radius: 4,
|
|
3365
3366
|
fill: "#ffffff",
|
|
3366
3367
|
opacity: .6,
|
|
3367
|
-
stroke:
|
|
3368
|
+
stroke: Tn,
|
|
3368
3369
|
strokeWidth: 1
|
|
3369
3370
|
});
|
|
3370
3371
|
this.bindCursor(s, "copy"), s.on("mousedown", (r) => {
|
|
@@ -3385,8 +3386,8 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3385
3386
|
x: i.x,
|
|
3386
3387
|
y: i.y,
|
|
3387
3388
|
radius: 5,
|
|
3388
|
-
fill: a ?
|
|
3389
|
-
stroke: a ? "#ffffff" :
|
|
3389
|
+
fill: a ? Tn : "#ffffff",
|
|
3390
|
+
stroke: a ? "#ffffff" : Tn,
|
|
3390
3391
|
strokeWidth: 1.5
|
|
3391
3392
|
});
|
|
3392
3393
|
this.bindCursor(o, "pointer"), o.on("mousedown", (t) => {
|
|
@@ -3406,12 +3407,12 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3406
3407
|
});
|
|
3407
3408
|
}
|
|
3408
3409
|
if (e.length === 1 && e[0].type === j.ROTATED_RECTANGLE) {
|
|
3409
|
-
let t = e[0], n =
|
|
3410
|
+
let t = e[0], n = pe(t.points), r = this.rotationHandleScreenPoint(t.points), i = new C.Circle({
|
|
3410
3411
|
x: r.x,
|
|
3411
3412
|
y: r.y,
|
|
3412
3413
|
radius: 6,
|
|
3413
3414
|
fill: "#ffffff",
|
|
3414
|
-
stroke:
|
|
3415
|
+
stroke: Tn,
|
|
3415
3416
|
strokeWidth: 1.5
|
|
3416
3417
|
});
|
|
3417
3418
|
this.bindCursor(i, "grab"), i.on("mousedown", (e) => {
|
|
@@ -3430,12 +3431,12 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3430
3431
|
this.layer.batchDraw();
|
|
3431
3432
|
}
|
|
3432
3433
|
beginMove(e, t) {
|
|
3433
|
-
let n =
|
|
3434
|
+
let n = hn(this.shapes, t, e);
|
|
3434
3435
|
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 === j.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
3435
3436
|
}
|
|
3436
3437
|
repositionHandles(e) {
|
|
3437
|
-
|
|
3438
|
-
let r = this.imgToScreen(
|
|
3438
|
+
F.forEach((t, n) => {
|
|
3439
|
+
let r = this.imgToScreen(ie(t, e)), i = this.handleNodes[n];
|
|
3439
3440
|
i && this.layoutResizeHandle(i, r, 0);
|
|
3440
3441
|
}), this.setTransformerOutline(e);
|
|
3441
3442
|
}
|
|
@@ -3473,7 +3474,7 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3473
3474
|
let t = this.activeDrag;
|
|
3474
3475
|
if (!t) return;
|
|
3475
3476
|
this.applyCursor();
|
|
3476
|
-
let n =
|
|
3477
|
+
let n = fn(this.shapes, t), { updates: r, box: i } = pn(t, e, n);
|
|
3477
3478
|
for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
3478
3479
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
3479
3480
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
|
|
@@ -3500,18 +3501,18 @@ var Cn = 2, wn = "#1e88e5", Tn = "#669def", En = class {
|
|
|
3500
3501
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
3501
3502
|
return;
|
|
3502
3503
|
}
|
|
3503
|
-
let { updates: n } =
|
|
3504
|
+
let { updates: n } = pn(e, t, fn(this.shapes, e));
|
|
3504
3505
|
this.commitTransformUpdates(n);
|
|
3505
3506
|
}
|
|
3506
|
-
},
|
|
3507
|
-
function
|
|
3508
|
-
if (!e) return
|
|
3507
|
+
}, On = 2, kn = 58879, An = 6725103;
|
|
3508
|
+
function Q(e) {
|
|
3509
|
+
if (!e) return kn;
|
|
3509
3510
|
let t = e.replace("#", "");
|
|
3510
3511
|
return Number.parseInt(t.length === 3 ? t.replace(/./g, "$&$&") : t, 16);
|
|
3511
3512
|
}
|
|
3512
3513
|
var jn = class {
|
|
3513
3514
|
constructor(e, t) {
|
|
3514
|
-
this.app = new w(), this.world = new E(), this.bgLayer = new E(), this.overlayLayer = new E(), this.shapeLayer = new E(), this.selLayer = new E(), this.previewLayer = new E(), this.handleLayer = new E(), this.filter = new T(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.overlayTextures = [], this.region = null, this.regionOutlineG = null, this.baseCursor = "default", this.strokeSize =
|
|
3515
|
+
this.app = new w(), this.world = new E(), this.bgLayer = new E(), this.overlayLayer = new E(), this.shapeLayer = new E(), this.selLayer = new E(), this.previewLayer = new E(), this.handleLayer = new E(), this.filter = new T(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.overlayTextures = [], this.region = null, this.regionOutlineG = null, this.baseCursor = "default", this.strokeSize = On, 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.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorderGfx = [], this.previewG = new D(), this.marqueeG = new D(), this.previewMaskSprite = null, this.previewMaskTexture = null, this.previewReady = !1, this.lastPreview = null, this.host = e, this.cb = t;
|
|
3515
3516
|
}
|
|
3516
3517
|
ev(e) {
|
|
3517
3518
|
return {
|
|
@@ -3605,27 +3606,29 @@ var jn = class {
|
|
|
3605
3606
|
y: t.y
|
|
3606
3607
|
};
|
|
3607
3608
|
}
|
|
3608
|
-
async setImage(e) {
|
|
3609
|
-
let
|
|
3609
|
+
async setImage(e, t, n) {
|
|
3610
|
+
let r = ++this.imageLoadToken, i = await tn(e);
|
|
3610
3611
|
if (this.destroyed) {
|
|
3611
|
-
|
|
3612
|
+
i && URL.revokeObjectURL(i);
|
|
3612
3613
|
return;
|
|
3613
3614
|
}
|
|
3614
|
-
await new Promise((
|
|
3615
|
-
let
|
|
3616
|
-
|
|
3617
|
-
if (
|
|
3618
|
-
this.imageWidth =
|
|
3619
|
-
|
|
3620
|
-
|
|
3615
|
+
await new Promise((a) => {
|
|
3616
|
+
let o = new Image();
|
|
3617
|
+
i || (o.crossOrigin = "anonymous"), o.onload = () => {
|
|
3618
|
+
if (i && URL.revokeObjectURL(i), this.destroyed || r !== this.imageLoadToken) return a();
|
|
3619
|
+
this.imageWidth = t?.width ?? o.naturalWidth, this.imageHeight = t?.height ?? o.naturalHeight;
|
|
3620
|
+
let e = n?.width ?? this.imageWidth, s = n?.height ?? this.imageHeight;
|
|
3621
|
+
this.bgLayer.scale.set(e / o.naturalWidth, s / o.naturalHeight), this.clearImageTiles();
|
|
3622
|
+
for (let e of rn(o.naturalWidth, o.naturalHeight)) {
|
|
3623
|
+
let t = A.from(an(o, e));
|
|
3621
3624
|
t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
|
|
3622
3625
|
let n = new k(t);
|
|
3623
3626
|
n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
|
|
3624
3627
|
}
|
|
3625
|
-
this.applySpriteFilter(),
|
|
3626
|
-
},
|
|
3627
|
-
|
|
3628
|
-
},
|
|
3628
|
+
this.applySpriteFilter(), a();
|
|
3629
|
+
}, o.onerror = () => {
|
|
3630
|
+
i && URL.revokeObjectURL(i), this.imageWidth ||= t?.width ?? 800, this.imageHeight ||= t?.height ?? 600, a();
|
|
3631
|
+
}, o.src = i ?? e;
|
|
3629
3632
|
});
|
|
3630
3633
|
}
|
|
3631
3634
|
setFilter(e, t) {
|
|
@@ -3669,7 +3672,7 @@ var jn = class {
|
|
|
3669
3672
|
n.alpha = .55, this.overlayLayer.addChild(n);
|
|
3670
3673
|
}
|
|
3671
3674
|
if (t) {
|
|
3672
|
-
let e =
|
|
3675
|
+
let e = Q(t.dim.color), n = () => {
|
|
3673
3676
|
let e = new D();
|
|
3674
3677
|
for (let n of t.rects) e.rect(n.x, n.y, n.w, n.h).fill(16777215);
|
|
3675
3678
|
return e;
|
|
@@ -3705,7 +3708,7 @@ var jn = class {
|
|
|
3705
3708
|
}
|
|
3706
3709
|
applyViewport(e) {
|
|
3707
3710
|
let t = e.scale !== this.lastAppliedScale;
|
|
3708
|
-
this.lastAppliedScale = e.scale, this.world.scale.set(e.scale), this.world.position.set(e.x, e.y), this.world.visible = !0, t && this.restrokeShapes(), this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
3711
|
+
this.lastAppliedScale = e.scale, this.world.scale.set(e.scale), this.world.position.set(e.x, e.y), this.world.visible = !0, t && this.restrokeShapes(), this.activeDrag ? this.dragTransform(this.lastDragImg ?? mn(this.shapes, this.activeDrag)) : this.drawTransformer(), this.cb.onViewportChange?.();
|
|
3709
3712
|
}
|
|
3710
3713
|
fit() {
|
|
3711
3714
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -3741,7 +3744,7 @@ var jn = class {
|
|
|
3741
3744
|
});
|
|
3742
3745
|
}
|
|
3743
3746
|
setShapes(e, t) {
|
|
3744
|
-
this.shapes =
|
|
3747
|
+
this.shapes = gn(e), this.selected = t, !this.activeDrag && (this.drawShapes(), this.drawSelectionBorders(), this.drawTransformer());
|
|
3745
3748
|
}
|
|
3746
3749
|
setSelection(e) {
|
|
3747
3750
|
this.selected = e, (e.length !== 1 || e[0] !== this.vertexPolygonId) && (this.vertexPolygonId = null, this.selectedVertices.clear()), this.editingId && (e.length !== 1 || e[0] !== this.editingId) && (this.editingId = null), !this.activeDrag && (this.drawSelectionBorders(), this.drawTransformer());
|
|
@@ -3756,13 +3759,13 @@ var jn = class {
|
|
|
3756
3759
|
this.handleLayer.interactiveChildren = !e;
|
|
3757
3760
|
}
|
|
3758
3761
|
strokeW(e) {
|
|
3759
|
-
return (e ?
|
|
3762
|
+
return (e ? Pe(e, { strokeWidth: this.strokeSize }).strokeWidth : On) / this.world.scale.x;
|
|
3760
3763
|
}
|
|
3761
3764
|
pointRadius(e) {
|
|
3762
|
-
return
|
|
3765
|
+
return yn(e, this.strokeSize, this.world.scale.x);
|
|
3763
3766
|
}
|
|
3764
3767
|
dashForShape(e) {
|
|
3765
|
-
let t =
|
|
3768
|
+
let t = Pe(e, { strokeWidth: this.strokeSize }).dash;
|
|
3766
3769
|
if (!t?.length) return null;
|
|
3767
3770
|
let n = this.world.scale.x || 1;
|
|
3768
3771
|
return [t[0] / n, (t[1] ?? t[0]) / n];
|
|
@@ -3771,9 +3774,9 @@ var jn = class {
|
|
|
3771
3774
|
this.shapeLayer.removeChildren();
|
|
3772
3775
|
for (let e of this.nodes.values()) e.destroy();
|
|
3773
3776
|
this.nodes.clear();
|
|
3774
|
-
for (let e of
|
|
3777
|
+
for (let e of ne(this.shapes).filter(M)) {
|
|
3775
3778
|
let t = new D();
|
|
3776
|
-
this.paintShape(t, e), t.eventMode = P(e) ? "static" : "none", t.cursor = void 0, P(e) &&
|
|
3779
|
+
this.paintShape(t, e), t.eventMode = P(e) ? "static" : "none", t.cursor = void 0, P(e) && te(e) && (t.on("pointerover", () => {
|
|
3777
3780
|
!this.activeDrag && this.transformEnabled && this.emitCursorHint("grab");
|
|
3778
3781
|
}), t.on("pointerout", () => {
|
|
3779
3782
|
this.activeDrag || this.emitCursorHint(null);
|
|
@@ -3784,9 +3787,9 @@ var jn = class {
|
|
|
3784
3787
|
}
|
|
3785
3788
|
paintShape(e, t) {
|
|
3786
3789
|
e.clear();
|
|
3787
|
-
let n =
|
|
3790
|
+
let n = Pe(t, { strokeWidth: this.strokeSize }), r = Q(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
|
|
3788
3791
|
if (t.type === j.POINT) {
|
|
3789
|
-
e.svg(
|
|
3792
|
+
e.svg(un(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
|
|
3790
3793
|
let r = 1 / (this.world.scale.x || 1);
|
|
3791
3794
|
e.scale.set(r, r), e.alpha = a;
|
|
3792
3795
|
return;
|
|
@@ -3800,7 +3803,7 @@ var jn = class {
|
|
|
3800
3803
|
})), o) {
|
|
3801
3804
|
t.style?.alternateColor && (this.path(e, t), e.stroke({
|
|
3802
3805
|
width: i,
|
|
3803
|
-
color:
|
|
3806
|
+
color: Q(t.style.alternateColor),
|
|
3804
3807
|
alpha: a
|
|
3805
3808
|
})), this.dashedStrokeShape(e, t, i, r, a, o);
|
|
3806
3809
|
return;
|
|
@@ -3819,11 +3822,11 @@ var jn = class {
|
|
|
3819
3822
|
});
|
|
3820
3823
|
}
|
|
3821
3824
|
shapesIntersecting(e) {
|
|
3822
|
-
return
|
|
3825
|
+
return vn(this.shapes, e);
|
|
3823
3826
|
}
|
|
3824
3827
|
shapesAt(e) {
|
|
3825
3828
|
return this.shapes.filter((t) => {
|
|
3826
|
-
let n =
|
|
3829
|
+
let n = I(t.points);
|
|
3827
3830
|
return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
|
|
3828
3831
|
}).map((e) => e.id);
|
|
3829
3832
|
}
|
|
@@ -3856,16 +3859,16 @@ var jn = class {
|
|
|
3856
3859
|
}, a = this.strokeW(i);
|
|
3857
3860
|
r.alternateColor && (this.path(this.previewG, i), this.previewG.stroke({
|
|
3858
3861
|
width: a,
|
|
3859
|
-
color:
|
|
3862
|
+
color: Q(r.alternateColor)
|
|
3860
3863
|
}));
|
|
3861
3864
|
let o = this.dashForShape(i);
|
|
3862
3865
|
if (o) {
|
|
3863
|
-
this.dashedStrokeShape(this.previewG, i, a,
|
|
3866
|
+
this.dashedStrokeShape(this.previewG, i, a, Q(r.color ?? "#00e5ff"), r.opacity ?? 1, o);
|
|
3864
3867
|
return;
|
|
3865
3868
|
}
|
|
3866
3869
|
this.path(this.previewG, i), this.previewG.stroke({
|
|
3867
3870
|
width: a,
|
|
3868
|
-
color:
|
|
3871
|
+
color: Q(r.color ?? "#00e5ff"),
|
|
3869
3872
|
alpha: r.opacity ?? 1
|
|
3870
3873
|
});
|
|
3871
3874
|
}
|
|
@@ -3887,12 +3890,12 @@ var jn = class {
|
|
|
3887
3890
|
}, c = this.strokeW(s);
|
|
3888
3891
|
n.alternateColor && (this.path(this.previewG, s), this.previewG.stroke({
|
|
3889
3892
|
width: c,
|
|
3890
|
-
color:
|
|
3893
|
+
color: Q(n.alternateColor)
|
|
3891
3894
|
}));
|
|
3892
3895
|
let l = this.dashForShape(s);
|
|
3893
|
-
if (l ? this.dashedStrokeShape(this.previewG, s, c,
|
|
3896
|
+
if (l ? this.dashedStrokeShape(this.previewG, s, c, Q(n.color ?? "#00e5ff"), n.opacity ?? 1, l) : (this.path(this.previewG, s), this.previewG.stroke({
|
|
3894
3897
|
width: c,
|
|
3895
|
-
color:
|
|
3898
|
+
color: Q(n.color ?? "#00e5ff"),
|
|
3896
3899
|
alpha: n.opacity ?? 1
|
|
3897
3900
|
})), !a) return;
|
|
3898
3901
|
let u = new Set(i), d = 5 / this.world.scale.x, f = 6 / this.world.scale.x;
|
|
@@ -3906,15 +3909,15 @@ var jn = class {
|
|
|
3906
3909
|
}
|
|
3907
3910
|
previewScalarMask(e, t) {
|
|
3908
3911
|
this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
|
|
3909
|
-
let n =
|
|
3912
|
+
let n = It(e, t.length === 7 ? `${t}99` : t);
|
|
3910
3913
|
this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture = A.from(n), this.previewMaskSprite ? (this.previewMaskSprite.texture = this.previewMaskTexture, this.previewMaskSprite.visible = !0) : (this.previewMaskSprite = new k(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;
|
|
3911
3914
|
}
|
|
3912
3915
|
previewMarquee(e, t) {
|
|
3913
3916
|
this.ensurePreview(), this.marqueeG.clear();
|
|
3914
|
-
let n = Math.min(e.x, t.x), r = Math.min(e.y, t.y), i = Math.abs(t.x - e.x), a = Math.abs(t.y - e.y), o =
|
|
3917
|
+
let n = Math.min(e.x, t.x), r = Math.min(e.y, t.y), i = Math.abs(t.x - e.x), a = Math.abs(t.y - e.y), o = Q(Ae);
|
|
3915
3918
|
this.marqueeG.rect(n, r, i, a).fill({
|
|
3916
3919
|
color: o,
|
|
3917
|
-
alpha:
|
|
3920
|
+
alpha: je
|
|
3918
3921
|
}).stroke({
|
|
3919
3922
|
width: 1 / this.world.scale.x,
|
|
3920
3923
|
color: o
|
|
@@ -3946,8 +3949,8 @@ var jn = class {
|
|
|
3946
3949
|
o.y
|
|
3947
3950
|
], !1).stroke({
|
|
3948
3951
|
width: i,
|
|
3949
|
-
color:
|
|
3950
|
-
}), this.strokeDashedPolyline(e, [n, o], !1, i,
|
|
3952
|
+
color: Q(r.underlayColor)
|
|
3953
|
+
}), this.strokeDashedPolyline(e, [n, o], !1, i, Q(r.color), r.opacity, a);
|
|
3951
3954
|
};
|
|
3952
3955
|
r(this.region.visibleOutline, t.visible), r(this.region.occludedOutline, t.occluded);
|
|
3953
3956
|
}
|
|
@@ -3958,12 +3961,12 @@ var jn = class {
|
|
|
3958
3961
|
return;
|
|
3959
3962
|
}
|
|
3960
3963
|
if (n === j.RECTANGLE) {
|
|
3961
|
-
let t =
|
|
3964
|
+
let t = I(r);
|
|
3962
3965
|
e.rect(t.minX, t.minY, t.maxX - t.minX, t.maxY - t.minY);
|
|
3963
3966
|
return;
|
|
3964
3967
|
}
|
|
3965
3968
|
if (n === j.ELLIPSE) {
|
|
3966
|
-
let t =
|
|
3969
|
+
let t = I(r);
|
|
3967
3970
|
e.ellipse((t.minX + t.maxX) / 2, (t.minY + t.maxY) / 2, (t.maxX - t.minX) / 2, (t.maxY - t.minY) / 2);
|
|
3968
3971
|
return;
|
|
3969
3972
|
}
|
|
@@ -3973,7 +3976,7 @@ var jn = class {
|
|
|
3973
3976
|
dashedStrokeShape(e, t, n, r, i, a) {
|
|
3974
3977
|
let { type: o, points: s } = t;
|
|
3975
3978
|
if (o === j.RECTANGLE) {
|
|
3976
|
-
let t =
|
|
3979
|
+
let t = I(s);
|
|
3977
3980
|
this.strokeDashedPolyline(e, [
|
|
3978
3981
|
{
|
|
3979
3982
|
x: t.minX,
|
|
@@ -3995,7 +3998,7 @@ var jn = class {
|
|
|
3995
3998
|
return;
|
|
3996
3999
|
}
|
|
3997
4000
|
if (o === j.ELLIPSE) {
|
|
3998
|
-
let t =
|
|
4001
|
+
let t = I(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) => {
|
|
3999
4002
|
let n = t / 96 * Math.PI * 2;
|
|
4000
4003
|
return {
|
|
4001
4004
|
x: o + Math.cos(n) * l,
|
|
@@ -4043,7 +4046,7 @@ var jn = class {
|
|
|
4043
4046
|
let r = this.selectionBorderGfx[t];
|
|
4044
4047
|
r.clear(), r.poly(this.selectionOutlinePoints(e, e.points).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4045
4048
|
width: n,
|
|
4046
|
-
color:
|
|
4049
|
+
color: An
|
|
4047
4050
|
});
|
|
4048
4051
|
});
|
|
4049
4052
|
}
|
|
@@ -4054,12 +4057,12 @@ var jn = class {
|
|
|
4054
4057
|
let a = this.selectionBorderGfx[r++];
|
|
4055
4058
|
a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4056
4059
|
width: n,
|
|
4057
|
-
color:
|
|
4060
|
+
color: An
|
|
4058
4061
|
}));
|
|
4059
4062
|
}
|
|
4060
4063
|
}
|
|
4061
4064
|
selectionOutlinePoints(e, t) {
|
|
4062
|
-
return
|
|
4065
|
+
return xn(e, t, this.pointRadius(e));
|
|
4063
4066
|
}
|
|
4064
4067
|
imgToScreen(e) {
|
|
4065
4068
|
let t = this.world.toGlobal({
|
|
@@ -4073,7 +4076,7 @@ var jn = class {
|
|
|
4073
4076
|
}
|
|
4074
4077
|
setTransformerOutline(e) {
|
|
4075
4078
|
let t = e.maxX - e.minX, n = e.maxY - e.minY;
|
|
4076
|
-
t <= 0 && n <= 0 || this.setTransformerOutlinePoints(
|
|
4079
|
+
t <= 0 && n <= 0 || this.setTransformerOutlinePoints(R([{
|
|
4077
4080
|
x: e.minX,
|
|
4078
4081
|
y: e.minY
|
|
4079
4082
|
}, {
|
|
@@ -4088,13 +4091,13 @@ var jn = class {
|
|
|
4088
4091
|
}));
|
|
4089
4092
|
}
|
|
4090
4093
|
rotationHandleGap() {
|
|
4091
|
-
return
|
|
4094
|
+
return Sn(this.viewport.scale);
|
|
4092
4095
|
}
|
|
4093
4096
|
rotationHandleScreenPoint(e) {
|
|
4094
|
-
return this.imgToScreen(
|
|
4097
|
+
return this.imgToScreen(he(e, this.rotationHandleGap()));
|
|
4095
4098
|
}
|
|
4096
4099
|
setRotationConnector(e) {
|
|
4097
|
-
let t = this.imgToScreen(
|
|
4100
|
+
let t = this.imgToScreen(fe(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
|
|
4098
4101
|
this.rotLineNode || (this.rotLineNode = new D(), 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({
|
|
4099
4102
|
width: 1,
|
|
4100
4103
|
color: 2001125
|
|
@@ -4104,7 +4107,7 @@ var jn = class {
|
|
|
4104
4107
|
e.position.set(t.x, t.y), e.rotation = n;
|
|
4105
4108
|
}
|
|
4106
4109
|
orientedHandleAngle(e) {
|
|
4107
|
-
return
|
|
4110
|
+
return Cn(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
4108
4111
|
}
|
|
4109
4112
|
drawTransformer() {
|
|
4110
4113
|
if (this.activeDrag) return;
|
|
@@ -4112,25 +4115,25 @@ var jn = class {
|
|
|
4112
4115
|
for (let e of this.vertexNodes) e.destroy();
|
|
4113
4116
|
for (let e of this.midNodes) e.destroy();
|
|
4114
4117
|
if (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;
|
|
4115
|
-
let e =
|
|
4118
|
+
let e = _n(this.shapes, this.selected);
|
|
4116
4119
|
if (e.length === 0 || e.length === 1 && e[0].type === j.POINT) return;
|
|
4117
|
-
let t = e.length === 1 && (e[0].type === j.POLYGON || e[0].type === j.LINE) && this.editingId === e[0].id ? e[0] : null, n =
|
|
4120
|
+
let t = e.length === 1 && (e[0].type === j.POLYGON || e[0].type === j.LINE) && this.editingId === e[0].id ? e[0] : null, n = I(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === j.ROTATED_RECTANGLE ? e[0] : null, i = r ? me(r.points) : F.map((e) => ie(e, n));
|
|
4118
4121
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
4119
4122
|
let a = r ? this.orientedHandleAngle(r.points) : 0;
|
|
4120
|
-
for (let e of t ? [] :
|
|
4121
|
-
let t = this.imgToScreen(i[
|
|
4123
|
+
for (let e of t ? [] : F) {
|
|
4124
|
+
let t = this.imgToScreen(i[F.indexOf(e)]), n = new D();
|
|
4122
4125
|
n.rect(-4, -4, 8, 8).fill({ color: 16777215 }).stroke({
|
|
4123
4126
|
width: 1,
|
|
4124
4127
|
color: 2001125
|
|
4125
4128
|
}), this.layoutResizeHandle(n, t, a), n.eventMode = "static";
|
|
4126
|
-
let r =
|
|
4129
|
+
let r = Xe(e, a);
|
|
4127
4130
|
this.bindCursor(n, r), n.on("pointerdown", (t) => {
|
|
4128
4131
|
t.stopPropagation(), this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
4129
|
-
let n =
|
|
4132
|
+
let n = _n(this.shapes, this.selected);
|
|
4130
4133
|
this.activeDrag = {
|
|
4131
4134
|
kind: "resize",
|
|
4132
4135
|
anchor: e,
|
|
4133
|
-
box:
|
|
4136
|
+
box: I(n.flatMap((e) => e.points)),
|
|
4134
4137
|
shapes: n.map((e) => ({
|
|
4135
4138
|
id: e.id,
|
|
4136
4139
|
points: e.points
|
|
@@ -4186,7 +4189,7 @@ var jn = class {
|
|
|
4186
4189
|
});
|
|
4187
4190
|
}
|
|
4188
4191
|
if (e.length === 1 && e[0].type === j.ROTATED_RECTANGLE) {
|
|
4189
|
-
let t = e[0], n =
|
|
4192
|
+
let t = e[0], n = pe(t.points), r = this.rotationHandleScreenPoint(t.points), i = new D();
|
|
4190
4193
|
i.circle(0, 0, 6).fill({ color: 16777215 }).stroke({
|
|
4191
4194
|
width: 1.5,
|
|
4192
4195
|
color: 2001125
|
|
@@ -4205,18 +4208,18 @@ var jn = class {
|
|
|
4205
4208
|
}
|
|
4206
4209
|
}
|
|
4207
4210
|
beginMove(e, t) {
|
|
4208
|
-
let n =
|
|
4211
|
+
let n = hn(this.shapes, t, e);
|
|
4209
4212
|
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 === j.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4210
4213
|
}
|
|
4211
4214
|
repositionHandlesForBox(e) {
|
|
4212
|
-
|
|
4213
|
-
let r = this.imgToScreen(
|
|
4215
|
+
F.forEach((t, n) => {
|
|
4216
|
+
let r = this.imgToScreen(ie(t, e)), i = this.handleNodes[n];
|
|
4214
4217
|
i && this.layoutResizeHandle(i, r, 0);
|
|
4215
4218
|
}), this.setTransformerOutline(e);
|
|
4216
4219
|
}
|
|
4217
4220
|
repositionOrientedHandles(e) {
|
|
4218
4221
|
let t = this.orientedHandleAngle(e);
|
|
4219
|
-
if (
|
|
4222
|
+
if (me(e).forEach((e, n) => {
|
|
4220
4223
|
let r = this.imgToScreen(e), i = this.handleNodes[n];
|
|
4221
4224
|
i && this.layoutResizeHandle(i, r, t);
|
|
4222
4225
|
}), this.setTransformerOutlinePoints(e), this.rotNode) {
|
|
@@ -4263,7 +4266,7 @@ var jn = class {
|
|
|
4263
4266
|
let t = this.activeDrag;
|
|
4264
4267
|
if (!t) return;
|
|
4265
4268
|
this.applyCursor();
|
|
4266
|
-
let n =
|
|
4269
|
+
let n = fn(this.shapes, t), { updates: r, box: i } = pn(t, e, n);
|
|
4267
4270
|
if (t.kind === "move") {
|
|
4268
4271
|
let n = e.x - t.start.x, r = e.y - t.start.y;
|
|
4269
4272
|
for (let e of t.shapes) {
|
|
@@ -4295,56 +4298,56 @@ var jn = class {
|
|
|
4295
4298
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
4296
4299
|
return;
|
|
4297
4300
|
}
|
|
4298
|
-
let { updates: n } =
|
|
4301
|
+
let { updates: n } = pn(e, t, fn(this.shapes, e));
|
|
4299
4302
|
e.kind === "move" && this.resetMoveOffsets(), this.commitTransformUpdates(n);
|
|
4300
4303
|
}
|
|
4301
4304
|
};
|
|
4302
4305
|
//#endregion
|
|
4303
4306
|
//#region src/components/ShapeEditor/_state/useEngineLifecycle.ts
|
|
4304
|
-
function Mn({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUrl: i, makeCallbacks: a, viewRef: o, readOnlyRef: s, toolRef: c, renderShapesRef: l,
|
|
4305
|
-
let
|
|
4306
|
-
|
|
4307
|
-
let
|
|
4308
|
-
|
|
4309
|
-
let
|
|
4310
|
-
|
|
4311
|
-
let
|
|
4312
|
-
|
|
4307
|
+
function Mn({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUrl: i, makeCallbacks: a, viewRef: o, readOnlyRef: s, toolRef: c, renderShapesRef: l, coordinateSizeRef: u, imageSizeRef: d, selRef: p, maskCanvasRef: m, regionOverlayRef: h, dimmedRef: g, syncMinimap: _, setImage: y, setImageVisible: b, setReady: x, setImageStatus: S, onContextMenuRequest: C }) {
|
|
4308
|
+
let w = v(i);
|
|
4309
|
+
w.current = i;
|
|
4310
|
+
let T = v(r);
|
|
4311
|
+
T.current = r;
|
|
4312
|
+
let E = v(null), D = v(null), O = v(!1), k = v(null), A = v(a);
|
|
4313
|
+
A.current = a;
|
|
4314
|
+
let j = v(C);
|
|
4315
|
+
j.current = C, f(() => {
|
|
4313
4316
|
let r = t.current;
|
|
4314
4317
|
if (!r) return;
|
|
4315
|
-
let i = !1, a = null, f = null, v =
|
|
4316
|
-
return n.current =
|
|
4317
|
-
if (await
|
|
4318
|
-
if (
|
|
4319
|
-
if (await
|
|
4320
|
-
|
|
4321
|
-
w:
|
|
4322
|
-
h:
|
|
4323
|
-
}),
|
|
4324
|
-
let e =
|
|
4325
|
-
e?.viewport && (e.imageUrl ===
|
|
4318
|
+
let i = !1, a = null, f = null, v = A.current(), S = e === "konva" ? new Dn(r, v) : new jn(r, v);
|
|
4319
|
+
return n.current = S, (async () => {
|
|
4320
|
+
if (await S.init(), !i) {
|
|
4321
|
+
if (S.setFilter(o.current.brightness, o.current.contrast), S.setStrokeSize(o.current.strokeSize), S.setImageSmoothing(o.current.imageSmoothing), S.setTransformEnabled(!s.current), O.current = !0, w.current) {
|
|
4322
|
+
if (await S.setImage(w.current, u.current, d.current), i) return;
|
|
4323
|
+
E.current = w.current, D.current = T.current, y({
|
|
4324
|
+
w: S.imageWidth,
|
|
4325
|
+
h: S.imageHeight
|
|
4326
|
+
}), b(!0), S.setShapes(l.current, p.current), S.setOverlays(o.current.showGuide ? m.current : null, o.current.showRegionMask ? h.current : null, g.current);
|
|
4327
|
+
let e = k.current;
|
|
4328
|
+
e?.viewport && (e.imageUrl === E.current || o.current.keepZoomOnImageChange) ? S.applyViewport(e.viewport) : S.fit(), _(), x(!0);
|
|
4326
4329
|
}
|
|
4327
4330
|
a = (e) => {
|
|
4328
4331
|
e.preventDefault();
|
|
4329
|
-
let t =
|
|
4332
|
+
let t = S.dom.getBoundingClientRect();
|
|
4330
4333
|
if (e.ctrlKey || e.metaKey) {
|
|
4331
|
-
|
|
4334
|
+
S.zoomAt(e.clientX - t.left, e.clientY - t.top, Math.exp(-e.deltaY * .01));
|
|
4332
4335
|
return;
|
|
4333
4336
|
}
|
|
4334
4337
|
if (!o.current.wheelZoom) {
|
|
4335
|
-
let t =
|
|
4336
|
-
|
|
4338
|
+
let t = S.viewport;
|
|
4339
|
+
S.applyViewport({
|
|
4337
4340
|
scale: t.scale,
|
|
4338
4341
|
x: t.x - e.deltaX,
|
|
4339
4342
|
y: t.y - e.deltaY
|
|
4340
4343
|
});
|
|
4341
4344
|
return;
|
|
4342
4345
|
}
|
|
4343
|
-
|
|
4344
|
-
},
|
|
4345
|
-
if (e.preventDefault(), c.current ===
|
|
4346
|
-
let t = r.getBoundingClientRect(), n = e.clientX - t.left, i = e.clientY - t.top, a =
|
|
4347
|
-
|
|
4346
|
+
S.zoomAt(e.clientX - t.left, e.clientY - t.top, e.deltaY < 0 ? 1.1 : 1 / 1.1);
|
|
4347
|
+
}, S.dom.addEventListener("wheel", a, { passive: !1 }), f = (e) => {
|
|
4348
|
+
if (e.preventDefault(), c.current === H.ASSISTANT_POINT && e.altKey) return;
|
|
4349
|
+
let t = r.getBoundingClientRect(), n = e.clientX - t.left, i = e.clientY - t.top, a = S.viewport;
|
|
4350
|
+
j.current({
|
|
4348
4351
|
x: n,
|
|
4349
4352
|
y: i,
|
|
4350
4353
|
img: {
|
|
@@ -4352,40 +4355,40 @@ function Mn({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUr
|
|
|
4352
4355
|
y: (i - a.y) / a.scale
|
|
4353
4356
|
}
|
|
4354
4357
|
});
|
|
4355
|
-
},
|
|
4358
|
+
}, S.dom.addEventListener("contextmenu", f);
|
|
4356
4359
|
}
|
|
4357
4360
|
})(), () => {
|
|
4358
|
-
i = !0,
|
|
4359
|
-
imageUrl:
|
|
4360
|
-
viewport:
|
|
4361
|
-
}, n.current = null, a &&
|
|
4361
|
+
i = !0, O.current = !1, k.current = {
|
|
4362
|
+
imageUrl: E.current ?? "",
|
|
4363
|
+
viewport: S.viewport
|
|
4364
|
+
}, n.current = null, a && S.dom && S.dom.removeEventListener("wheel", a), f && S.dom && S.dom.removeEventListener("contextmenu", f), S.destroy();
|
|
4362
4365
|
};
|
|
4363
4366
|
}, [e]), f(() => {
|
|
4364
4367
|
let e = n.current;
|
|
4365
|
-
if (!e || !
|
|
4366
|
-
let t = i, a =
|
|
4367
|
-
a && (e.clearImage(), e.setShapes([], []), e.setOverlays(null, null, !1),
|
|
4368
|
+
if (!e || !O.current || !i || E.current === i) return;
|
|
4369
|
+
let t = i, a = D.current !== r;
|
|
4370
|
+
a && (e.clearImage(), e.setShapes([], []), e.setOverlays(null, null, !1), b(!1));
|
|
4368
4371
|
let s = !1;
|
|
4369
4372
|
return (async () => {
|
|
4370
|
-
await e.setImage(t), !(s || n.current !== e) && (
|
|
4373
|
+
await e.setImage(t, u.current, d.current), !(s || n.current !== e) && (E.current = t, a && (D.current = r, y({
|
|
4371
4374
|
w: e.imageWidth,
|
|
4372
4375
|
h: e.imageHeight
|
|
4373
|
-
}),
|
|
4376
|
+
}), b(!0), e.setShapes(l.current, p.current), e.setOverlays(o.current.showGuide ? m.current : null, o.current.showRegionMask ? h.current : null, g.current), o.current.keepZoomOnImageChange || e.fit(), _(), x(!0)));
|
|
4374
4377
|
})(), () => {
|
|
4375
4378
|
s = !0;
|
|
4376
4379
|
};
|
|
4377
4380
|
}, [i]), f(() => {
|
|
4378
4381
|
let e = !1;
|
|
4379
4382
|
if (!i) {
|
|
4380
|
-
|
|
4383
|
+
S("loading");
|
|
4381
4384
|
return;
|
|
4382
4385
|
}
|
|
4383
|
-
|
|
4386
|
+
S("loading");
|
|
4384
4387
|
let t = new Image();
|
|
4385
4388
|
return t.onload = () => {
|
|
4386
|
-
e ||
|
|
4389
|
+
e || S("ready");
|
|
4387
4390
|
}, t.onerror = () => {
|
|
4388
|
-
e ||
|
|
4391
|
+
e || S("error");
|
|
4389
4392
|
}, t.src = i, () => {
|
|
4390
4393
|
e = !0;
|
|
4391
4394
|
};
|
|
@@ -4394,11 +4397,11 @@ function Mn({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUr
|
|
|
4394
4397
|
//#endregion
|
|
4395
4398
|
//#region src/components/ShapeEditor/_state/useMinimapNavigation.ts
|
|
4396
4399
|
var Nn = .05, Pn = 20;
|
|
4397
|
-
function
|
|
4400
|
+
function Fn(e) {
|
|
4398
4401
|
let { deltaY: t, deltaX: n, deltaMode: r } = e;
|
|
4399
4402
|
return r === 0 ? Math.abs(t) < 10 || Math.abs(n) < 10 || !Number.isInteger(t) || !Number.isInteger(n) : r === 1 ? !1 : !Number.isInteger(t) || !Number.isInteger(n);
|
|
4400
4403
|
}
|
|
4401
|
-
function
|
|
4404
|
+
function In({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
4402
4405
|
let i = v(null), a = !!t && t.w > 0 && t.h > 0, o = a ? Math.min(r / t.w, r / t.h) : 1, s = a ? t.w * o : 0, c = a ? t.h * o : 0, l = a ? (r - s) / 2 : 0, u = a ? (r - c) / 2 : 0, d = (e) => {
|
|
4403
4406
|
let t = e.currentTarget.getBoundingClientRect();
|
|
4404
4407
|
return {
|
|
@@ -4461,7 +4464,7 @@ function Fn({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4461
4464
|
let r = e.current;
|
|
4462
4465
|
if (!r || !n) return;
|
|
4463
4466
|
t.preventDefault(), t.stopPropagation();
|
|
4464
|
-
let i =
|
|
4467
|
+
let i = Fn(t.nativeEvent) ? 2.5 : 1, a = t.deltaY * i, o = 1.05, s = a > 0 ? r.viewport.scale / o : r.viewport.scale * o, c = Math.max(Nn, Math.min(Pn, s));
|
|
4465
4468
|
p(d(t), c);
|
|
4466
4469
|
},
|
|
4467
4470
|
zoomCentered: (t) => {
|
|
@@ -4474,14 +4477,14 @@ function Fn({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4474
4477
|
}
|
|
4475
4478
|
//#endregion
|
|
4476
4479
|
//#region src/components/ShapeEditor/_state/useMinimapSync.ts
|
|
4477
|
-
function
|
|
4480
|
+
function Ln(e, t, n) {
|
|
4478
4481
|
if (!(!e || !n.length)) {
|
|
4479
4482
|
if (t.type === j.POINT) {
|
|
4480
4483
|
e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
|
|
4481
4484
|
return;
|
|
4482
4485
|
}
|
|
4483
4486
|
if (t.type === j.RECTANGLE || t.type === j.ELLIPSE) {
|
|
4484
|
-
let r =
|
|
4487
|
+
let r = I(n);
|
|
4485
4488
|
if (t.type === j.ELLIPSE) {
|
|
4486
4489
|
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));
|
|
4487
4490
|
return;
|
|
@@ -4492,7 +4495,7 @@ function In(e, t, n) {
|
|
|
4492
4495
|
e.setAttribute("points", n.map((e) => `${e.x},${e.y}`).join(" "));
|
|
4493
4496
|
}
|
|
4494
4497
|
}
|
|
4495
|
-
function
|
|
4498
|
+
function Rn({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o }) {
|
|
4496
4499
|
let s = v(/* @__PURE__ */ new Map());
|
|
4497
4500
|
return {
|
|
4498
4501
|
registerMinimapShape: d((e, t) => {
|
|
@@ -4501,13 +4504,13 @@ function Ln({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
4501
4504
|
applyMinimapPreview: d((e) => {
|
|
4502
4505
|
let n = t.current.getShapes();
|
|
4503
4506
|
if (!e.length) {
|
|
4504
|
-
for (let e of n)
|
|
4507
|
+
for (let e of n) Ln(s.current.get(e.id), e, e.points);
|
|
4505
4508
|
return;
|
|
4506
4509
|
}
|
|
4507
4510
|
let r = new Map(n.map((e) => [e.id, e]));
|
|
4508
4511
|
for (let t of e) {
|
|
4509
4512
|
let e = r.get(t.id);
|
|
4510
|
-
e &&
|
|
4513
|
+
e && Ln(s.current.get(e.id), e, t.points);
|
|
4511
4514
|
}
|
|
4512
4515
|
}, [t]),
|
|
4513
4516
|
syncMinimap: d(() => {
|
|
@@ -4536,8 +4539,8 @@ function Ln({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
4536
4539
|
}
|
|
4537
4540
|
//#endregion
|
|
4538
4541
|
//#region src/components/ShapeEditor/_state/useSelectionActions.ts
|
|
4539
|
-
var
|
|
4540
|
-
function
|
|
4542
|
+
var zn = 12;
|
|
4543
|
+
function Bn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i }) {
|
|
4541
4544
|
let a = v([]), o = v(0), s = d(() => r(e.getShapes().filter((e) => P(e)).map((e) => e.id)), [e, r]), c = d(() => r([]), [r]), l = d(() => e.getShapes().filter((e) => t.current.includes(e.id) && ee(e)), [e, t]), u = d(() => {
|
|
4542
4545
|
if (n || !t.current.length) return;
|
|
4543
4546
|
let i = l().map((e) => e.id);
|
|
@@ -4553,9 +4556,9 @@ function zn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4553
4556
|
}, [l]), p = d(() => a.current.length > 0, []), m = d(() => {
|
|
4554
4557
|
if (n || !a.current.length) return;
|
|
4555
4558
|
o.current += 1;
|
|
4556
|
-
let t =
|
|
4559
|
+
let t = zn * o.current, i = a.current.map((e) => ({
|
|
4557
4560
|
...e,
|
|
4558
|
-
id:
|
|
4561
|
+
id: re(),
|
|
4559
4562
|
points: e.points.map((e) => ({
|
|
4560
4563
|
x: e.x + t,
|
|
4561
4564
|
y: e.y + t
|
|
@@ -4570,10 +4573,10 @@ function zn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4570
4573
|
if (n || !t.current.length) return;
|
|
4571
4574
|
let i = l().map((e) => ({
|
|
4572
4575
|
...e,
|
|
4573
|
-
id:
|
|
4576
|
+
id: re(),
|
|
4574
4577
|
points: e.points.map((e) => ({
|
|
4575
|
-
x: e.x +
|
|
4576
|
-
y: e.y +
|
|
4578
|
+
x: e.x + zn,
|
|
4579
|
+
y: e.y + zn
|
|
4577
4580
|
}))
|
|
4578
4581
|
}));
|
|
4579
4582
|
i.length && (e.create(i), r(i.map((e) => e.id)));
|
|
@@ -4599,24 +4602,7 @@ function zn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4599
4602
|
e,
|
|
4600
4603
|
n,
|
|
4601
4604
|
l
|
|
4602
|
-
]), y = d((r) => {
|
|
4603
|
-
if (n || !t.current.length) return;
|
|
4604
|
-
let i = l();
|
|
4605
|
-
if (!i.length) return;
|
|
4606
|
-
let a = L(i.flatMap((e) => e.points)), o = (a.minX + a.maxX) / 2, s = (a.minY + a.maxY) / 2;
|
|
4607
|
-
e.update(i.map((e) => ({
|
|
4608
|
-
...e,
|
|
4609
|
-
points: e.points.map((e) => ({
|
|
4610
|
-
x: r ? 2 * o - e.x : e.x,
|
|
4611
|
-
y: r ? e.y : 2 * s - e.y
|
|
4612
|
-
}))
|
|
4613
|
-
})));
|
|
4614
|
-
}, [
|
|
4615
|
-
e,
|
|
4616
|
-
n,
|
|
4617
|
-
l,
|
|
4618
|
-
t
|
|
4619
|
-
]), b = d((r, i) => {
|
|
4605
|
+
]), y = d((r, i) => {
|
|
4620
4606
|
if (n || !t.current.length) return;
|
|
4621
4607
|
let a = e.getShapes().filter((e) => t.current.includes(e.id) && ee(e));
|
|
4622
4608
|
a.length && e.update(a.map((e) => ({
|
|
@@ -4630,7 +4616,7 @@ function zn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4630
4616
|
e,
|
|
4631
4617
|
n,
|
|
4632
4618
|
t
|
|
4633
|
-
]),
|
|
4619
|
+
]), b = d(() => l().filter((e) => e.type === j.POLYGON || e.type === j.RECTANGLE || e.type === j.ROTATED_RECTANGLE || e.type === j.ELLIPSE), [l]);
|
|
4634
4620
|
return {
|
|
4635
4621
|
selectAll: s,
|
|
4636
4622
|
clearSelection: c,
|
|
@@ -4642,19 +4628,18 @@ function zn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4642
4628
|
duplicate: h,
|
|
4643
4629
|
bringToFront: g,
|
|
4644
4630
|
sendToBack: _,
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
getMergeTargets: x,
|
|
4631
|
+
nudgeSelection: y,
|
|
4632
|
+
getMergeTargets: b,
|
|
4648
4633
|
mergeSelection: d(() => {
|
|
4649
4634
|
if (n) return;
|
|
4650
|
-
let t =
|
|
4635
|
+
let t = b();
|
|
4651
4636
|
if (t.length < 2 || i && !i(t)) return;
|
|
4652
|
-
let a =
|
|
4637
|
+
let a = Pt([], 1, X(t));
|
|
4653
4638
|
if (!a) return;
|
|
4654
|
-
let o =
|
|
4639
|
+
let o = Ft(a, 1);
|
|
4655
4640
|
if (!o.length) return;
|
|
4656
4641
|
let s = t[0], c = o.map((e) => ({
|
|
4657
|
-
id:
|
|
4642
|
+
id: re(),
|
|
4658
4643
|
type: j.POLYGON,
|
|
4659
4644
|
points: e,
|
|
4660
4645
|
style: s.style,
|
|
@@ -4664,7 +4649,7 @@ function zn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4664
4649
|
}, [
|
|
4665
4650
|
e,
|
|
4666
4651
|
n,
|
|
4667
|
-
|
|
4652
|
+
b,
|
|
4668
4653
|
i,
|
|
4669
4654
|
r
|
|
4670
4655
|
])
|
|
@@ -4672,12 +4657,12 @@ function zn({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4672
4657
|
}
|
|
4673
4658
|
//#endregion
|
|
4674
4659
|
//#region src/components/ShapeEditor/_state/useViewportControls.ts
|
|
4675
|
-
function
|
|
4660
|
+
function Vn({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
|
|
4676
4661
|
let o = v(null), s = v(null), c = d(() => {
|
|
4677
4662
|
o.current?.(), o.current = null;
|
|
4678
4663
|
}, []), l = d((t, n = r) => {
|
|
4679
4664
|
let i = e.current;
|
|
4680
|
-
i && (c(), o.current =
|
|
4665
|
+
i && (c(), o.current = vt(i.viewport, t, (e) => i.applyViewport(e), n));
|
|
4681
4666
|
}, [
|
|
4682
4667
|
c,
|
|
4683
4668
|
r,
|
|
@@ -4685,14 +4670,14 @@ function Bn({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
4685
4670
|
]), u = d((t, n = r) => {
|
|
4686
4671
|
let i = e.current;
|
|
4687
4672
|
if (!i) return;
|
|
4688
|
-
let a =
|
|
4673
|
+
let a = gt(t, i.screenSize.w, i.screenSize.h);
|
|
4689
4674
|
a && l(a, n);
|
|
4690
4675
|
}, [
|
|
4691
4676
|
l,
|
|
4692
4677
|
r,
|
|
4693
4678
|
e
|
|
4694
4679
|
]), p = d((e, n = r) => {
|
|
4695
|
-
let i =
|
|
4680
|
+
let i = ht(t.getShapes().filter((t) => e.includes(t.id)));
|
|
4696
4681
|
i && u(i, n);
|
|
4697
4682
|
}, [
|
|
4698
4683
|
t,
|
|
@@ -4703,7 +4688,7 @@ function Bn({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
4703
4688
|
if (!r.length) return;
|
|
4704
4689
|
let i = e.current;
|
|
4705
4690
|
if (!i) return;
|
|
4706
|
-
let a =
|
|
4691
|
+
let a = _t(I(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
|
|
4707
4692
|
a && l(a);
|
|
4708
4693
|
}, [
|
|
4709
4694
|
t,
|
|
@@ -4744,109 +4729,113 @@ function Bn({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
4744
4729
|
}
|
|
4745
4730
|
//#endregion
|
|
4746
4731
|
//#region src/components/ShapeEditor/ShapeEditor.tsx
|
|
4747
|
-
var
|
|
4748
|
-
function
|
|
4732
|
+
var Hn = 180, Un = "__draft_preview__";
|
|
4733
|
+
function Wn(e, t) {
|
|
4749
4734
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
4750
4735
|
}
|
|
4751
|
-
function
|
|
4752
|
-
let
|
|
4736
|
+
function $({ imageUrl: t, displayImageUrl: n, coordinateSize: r, renderImageState: i, dimmed: a = !1, initialShapes: o, selectedIds: s, activeTool: c, draftStyle: l, draftMeta: u, readOnly: _, disableMarquee: b, locked: C, onLockedInteraction: w, onIdleEscape: T, overrideShapeInteraction: E, defaultViewSettings: D, viewSettings: O, onViewSettingsChange: k, showMinimap: A = !0, showViewSettings: N = !0, getContextMenuItems: te, strings: ne, canMergeSelection: F, brushSize: ie = 20, zoomBound: ae, zoomAnimationDuration: oe = 300, decorationShapes: L, regionMask: R, guideMask: z, maskPalette: se, overlayMarkers: ce, renderOverlayMarker: B, onOverlayMarkerClick: le, renderImageOverlay: ue, getSelectionLabel: de, hideSelectionLabelDot: fe, formatSelectionInfo: pe, externalTools: me, assistant: he, keymap: ge, handleRef: _e, backend: ve = "pixi", onActiveToolChange: V, onSelectionChange: xe, onEditingChange: Se, onShapesCreated: Ce, onShapesUpdated: we, onShapesDeleted: Ee, onDrawSessionChange: Ae, onDraftShapeChange: je, onViewportChange: Me, onShapesTransformPreview: Ne }) {
|
|
4737
|
+
let Pe = v(null), U = v(null), Fe = v(null), Ie = v(null), Le = v(null), Re = `${p()}-minimap`, [W, ze] = y(null), [Ve, He] = y(!1), [G, Ge] = y(!1), [qe, Je] = y(null), [Ye, Xe] = y({
|
|
4753
4738
|
active: !1,
|
|
4754
4739
|
kind: "none",
|
|
4755
4740
|
canUndo: !1,
|
|
4756
4741
|
canRedo: !1
|
|
4757
|
-
}), [
|
|
4758
|
-
onShapesCreated:
|
|
4759
|
-
onShapesUpdated:
|
|
4760
|
-
onShapesDeleted:
|
|
4761
|
-
}), [
|
|
4762
|
-
|
|
4763
|
-
let
|
|
4764
|
-
|
|
4765
|
-
let [
|
|
4766
|
-
let e = Object.fromEntries(Object.entries(
|
|
4742
|
+
}), [Ze, $e] = y(!0), [et, nt] = y(!1), rt = n ?? t, [it, at] = y("loading"), K = Wt({
|
|
4743
|
+
onShapesCreated: Ce,
|
|
4744
|
+
onShapesUpdated: we,
|
|
4745
|
+
onShapesDeleted: Ee
|
|
4746
|
+
}), [ot, st] = y([]), q = s ?? ot, ct = s !== void 0, lt = g(() => new Map((me ?? []).map((e) => [e.id, e])), [me]), ut = v(lt);
|
|
4747
|
+
ut.current = lt;
|
|
4748
|
+
let ft = v(Ye);
|
|
4749
|
+
ft.current = Ye;
|
|
4750
|
+
let [J, pt] = y(() => {
|
|
4751
|
+
let e = Object.fromEntries(Object.entries(D ?? {}).filter(([, e]) => e !== void 0));
|
|
4767
4752
|
return {
|
|
4768
|
-
...
|
|
4753
|
+
...be,
|
|
4769
4754
|
...e
|
|
4770
4755
|
};
|
|
4771
|
-
}),
|
|
4756
|
+
}), mt = d((e) => pt((t) => ({
|
|
4772
4757
|
...t,
|
|
4773
4758
|
...e
|
|
4774
|
-
})), []),
|
|
4759
|
+
})), []), Y = g(() => ye(ne), [ne]);
|
|
4775
4760
|
f(() => {
|
|
4776
|
-
|
|
4777
|
-
let t = Object.entries(
|
|
4761
|
+
O && pt((e) => {
|
|
4762
|
+
let t = Object.entries(O).filter(([t, n]) => n !== void 0 && e[t] !== n);
|
|
4778
4763
|
return t.length ? {
|
|
4779
4764
|
...e,
|
|
4780
4765
|
...Object.fromEntries(t)
|
|
4781
4766
|
} : e;
|
|
4782
4767
|
});
|
|
4783
|
-
}, [
|
|
4784
|
-
let
|
|
4785
|
-
|
|
4786
|
-
let
|
|
4768
|
+
}, [O]);
|
|
4769
|
+
let ht = v(k);
|
|
4770
|
+
ht.current = k;
|
|
4771
|
+
let gt = v(!1);
|
|
4787
4772
|
f(() => {
|
|
4788
|
-
if (!
|
|
4789
|
-
|
|
4773
|
+
if (!gt.current) {
|
|
4774
|
+
gt.current = !0;
|
|
4790
4775
|
return;
|
|
4791
4776
|
}
|
|
4792
|
-
|
|
4793
|
-
}, [
|
|
4794
|
-
let
|
|
4795
|
-
|
|
4796
|
-
let
|
|
4797
|
-
|
|
4798
|
-
let
|
|
4799
|
-
|
|
4800
|
-
let
|
|
4801
|
-
|
|
4802
|
-
let
|
|
4803
|
-
|
|
4804
|
-
let
|
|
4805
|
-
|
|
4806
|
-
let
|
|
4807
|
-
|
|
4808
|
-
let
|
|
4809
|
-
|
|
4810
|
-
let
|
|
4811
|
-
|
|
4812
|
-
let
|
|
4813
|
-
|
|
4814
|
-
let
|
|
4815
|
-
|
|
4816
|
-
let
|
|
4817
|
-
|
|
4818
|
-
let
|
|
4819
|
-
|
|
4820
|
-
let
|
|
4821
|
-
|
|
4822
|
-
let
|
|
4823
|
-
|
|
4824
|
-
let
|
|
4825
|
-
|
|
4826
|
-
let
|
|
4827
|
-
|
|
4777
|
+
ht.current?.(J);
|
|
4778
|
+
}, [J]);
|
|
4779
|
+
let _t = g(() => !z || !se ? null : tt(z, se), [z, se]), vt = g(() => _t?.toDataURL() ?? null, [_t]), xt = g(() => !W || !R ? null : dt(R, W.w, W.h), [W, R]), St = v(_t);
|
|
4780
|
+
St.current = _t;
|
|
4781
|
+
let Ct = v(xt);
|
|
4782
|
+
Ct.current = xt;
|
|
4783
|
+
let wt = v(a);
|
|
4784
|
+
wt.current = a;
|
|
4785
|
+
let Tt = v(W);
|
|
4786
|
+
Tt.current = W;
|
|
4787
|
+
let Et = v(r);
|
|
4788
|
+
Et.current = r;
|
|
4789
|
+
let Dt = v(r?.imageSize);
|
|
4790
|
+
Dt.current = r?.imageSize;
|
|
4791
|
+
let Ot = v([]);
|
|
4792
|
+
Ot.current = q;
|
|
4793
|
+
let kt = v(c);
|
|
4794
|
+
kt.current = c;
|
|
4795
|
+
let At = v(l);
|
|
4796
|
+
At.current = l;
|
|
4797
|
+
let jt = v(u);
|
|
4798
|
+
jt.current = u;
|
|
4799
|
+
let Mt = v(ie);
|
|
4800
|
+
Mt.current = ie;
|
|
4801
|
+
let Nt = v(J.simplifyStrength);
|
|
4802
|
+
Nt.current = J.simplifyStrength;
|
|
4803
|
+
let X = !!_ || !!C, Pt = v(X);
|
|
4804
|
+
Pt.current = X;
|
|
4805
|
+
let Ft = v(b);
|
|
4806
|
+
Ft.current = b;
|
|
4807
|
+
let It = v(C);
|
|
4808
|
+
It.current = C;
|
|
4809
|
+
let Lt = v(w);
|
|
4810
|
+
Lt.current = w;
|
|
4811
|
+
let Rt = v(E);
|
|
4812
|
+
Rt.current = E;
|
|
4813
|
+
let Z = v(K);
|
|
4814
|
+
Z.current = K;
|
|
4815
|
+
let zt = v(!1), Bt = v(!1), Ht = v("idle"), Ut = v(null), Gt = d(() => {
|
|
4816
|
+
let e = U.current;
|
|
4828
4817
|
if (!e) return;
|
|
4829
|
-
let t =
|
|
4830
|
-
e.setCursor(
|
|
4818
|
+
let t = kt.current, n = ut.current.get(t), r = ft.current;
|
|
4819
|
+
e.setCursor(Qe({
|
|
4831
4820
|
tool: t,
|
|
4832
4821
|
externalToolCursor: n?.cursor,
|
|
4833
|
-
isSpacePressed:
|
|
4834
|
-
interactionMode:
|
|
4835
|
-
rendererCursorHint:
|
|
4822
|
+
isSpacePressed: zt.current,
|
|
4823
|
+
interactionMode: Ht.current,
|
|
4824
|
+
rendererCursorHint: Ut.current,
|
|
4836
4825
|
isPolygonDrawing: r.kind === "polygon" && r.active
|
|
4837
4826
|
}));
|
|
4838
|
-
}, []),
|
|
4839
|
-
|
|
4840
|
-
}, [
|
|
4841
|
-
|
|
4842
|
-
}, [
|
|
4843
|
-
let t = /* @__PURE__ */ new Set(), n = new Map(
|
|
4827
|
+
}, []), Kt = d((e) => {
|
|
4828
|
+
Ht.current !== e && (Ht.current = e, Gt());
|
|
4829
|
+
}, [Gt]), qt = d((e) => {
|
|
4830
|
+
Ut.current !== e && (Ut.current = e, Gt());
|
|
4831
|
+
}, [Gt]), Jt = d((e) => {
|
|
4832
|
+
let t = /* @__PURE__ */ new Set(), n = new Map(Z.current.getShapes().map((e) => [e.id, e]));
|
|
4844
4833
|
return e.filter((e) => {
|
|
4845
4834
|
if (t.has(e)) return !1;
|
|
4846
4835
|
t.add(e);
|
|
4847
4836
|
let r = n.get(e);
|
|
4848
4837
|
if (!r) return !1;
|
|
4849
|
-
let i =
|
|
4838
|
+
let i = Rt.current?.(r);
|
|
4850
4839
|
return P(i ? {
|
|
4851
4840
|
...r,
|
|
4852
4841
|
interaction: {
|
|
@@ -4855,283 +4844,282 @@ function Wn({ imageUrl: t, displayImageUrl: n, renderImageState: r, dimmed: i =
|
|
|
4855
4844
|
}
|
|
4856
4845
|
} : r);
|
|
4857
4846
|
});
|
|
4858
|
-
}, []),
|
|
4859
|
-
let t =
|
|
4860
|
-
|
|
4847
|
+
}, []), Yt = d((e) => {
|
|
4848
|
+
let t = Jt(e);
|
|
4849
|
+
Wn(Ot.current, t) || (ct || st(t), U.current?.setSelection(t), xe?.(t));
|
|
4861
4850
|
}, [
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
]),
|
|
4866
|
-
|
|
4867
|
-
let [
|
|
4868
|
-
|
|
4869
|
-
if (!
|
|
4870
|
-
let e =
|
|
4871
|
-
|
|
4851
|
+
Jt,
|
|
4852
|
+
xe,
|
|
4853
|
+
ct
|
|
4854
|
+
]), Xt = v(Yt);
|
|
4855
|
+
Xt.current = Yt;
|
|
4856
|
+
let [Zt, Qt] = y(null), $t = d((e) => Qt(e), []), tn = v($t);
|
|
4857
|
+
tn.current = $t, f(() => {
|
|
4858
|
+
if (!ct) return;
|
|
4859
|
+
let e = Jt(s);
|
|
4860
|
+
Wn(s, e) || xe?.(e);
|
|
4872
4861
|
}, [
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4862
|
+
s,
|
|
4863
|
+
K.shapes,
|
|
4864
|
+
Jt,
|
|
4865
|
+
xe,
|
|
4866
|
+
ct
|
|
4878
4867
|
]);
|
|
4879
|
-
let
|
|
4880
|
-
|
|
4881
|
-
let { registerMinimapShape:
|
|
4882
|
-
engineRef:
|
|
4883
|
-
docRef:
|
|
4884
|
-
overlayRef:
|
|
4885
|
-
zoomLabelRef:
|
|
4886
|
-
minimapRectRef:
|
|
4887
|
-
minimapSize:
|
|
4888
|
-
onViewportChangeRef:
|
|
4889
|
-
}),
|
|
4890
|
-
|
|
4891
|
-
let
|
|
4892
|
-
t ?
|
|
4893
|
-
}, []),
|
|
4868
|
+
let nn = v(Me);
|
|
4869
|
+
nn.current = Me;
|
|
4870
|
+
let { registerMinimapShape: rn, applyMinimapPreview: an, syncMinimap: on } = Rn({
|
|
4871
|
+
engineRef: U,
|
|
4872
|
+
docRef: Z,
|
|
4873
|
+
overlayRef: Ie,
|
|
4874
|
+
zoomLabelRef: Le,
|
|
4875
|
+
minimapRectRef: Fe,
|
|
4876
|
+
minimapSize: Hn,
|
|
4877
|
+
onViewportChangeRef: nn
|
|
4878
|
+
}), sn = v(/* @__PURE__ */ new Map()), cn = v(pe);
|
|
4879
|
+
cn.current = pe;
|
|
4880
|
+
let ln = d((e, t) => {
|
|
4881
|
+
t ? sn.current.set(e, t) : sn.current.delete(e);
|
|
4882
|
+
}, []), un = v(null), [dn, fn] = y(null), pn = d((e) => {
|
|
4894
4883
|
if (!e.length) return;
|
|
4895
|
-
let t = new Map(
|
|
4896
|
-
|
|
4884
|
+
let t = new Map(Z.current.getShapes().map((e) => [e.id, e]));
|
|
4885
|
+
un.current && t.set(un.current.id, un.current);
|
|
4897
4886
|
for (let { id: n, points: r } of e) {
|
|
4898
|
-
let e =
|
|
4887
|
+
let e = sn.current.get(n), i = t.get(n);
|
|
4899
4888
|
if (!e || !i) continue;
|
|
4900
|
-
let a =
|
|
4889
|
+
let a = I(r);
|
|
4901
4890
|
e.style.left = `${a.minX}px`, e.style.top = `${a.minY}px`, e.style.width = `${a.maxX - a.minX}px`, e.style.height = `${a.maxY - a.minY}px`;
|
|
4902
4891
|
let o = e.querySelector("[data-selinfo-dim]");
|
|
4903
4892
|
if (o) {
|
|
4904
|
-
let e =
|
|
4905
|
-
o.textContent =
|
|
4893
|
+
let e = Ue(i, r);
|
|
4894
|
+
o.textContent = cn.current?.(e) ?? We(e);
|
|
4906
4895
|
}
|
|
4907
4896
|
}
|
|
4908
|
-
}, []),
|
|
4909
|
-
|
|
4897
|
+
}, []), mn = d((e) => {
|
|
4898
|
+
an(e), pn(e), Ne?.(e);
|
|
4910
4899
|
}, [
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
]),
|
|
4915
|
-
if (
|
|
4900
|
+
an,
|
|
4901
|
+
pn,
|
|
4902
|
+
Ne
|
|
4903
|
+
]), hn = d((e) => {
|
|
4904
|
+
if (je?.(e ? {
|
|
4916
4905
|
...e,
|
|
4917
|
-
meta:
|
|
4918
|
-
} : null), !e || !
|
|
4919
|
-
|
|
4906
|
+
meta: jt.current
|
|
4907
|
+
} : null), !e || !At.current) {
|
|
4908
|
+
un.current && (un.current = null, fn(null));
|
|
4920
4909
|
return;
|
|
4921
4910
|
}
|
|
4922
4911
|
let t = {
|
|
4923
|
-
id:
|
|
4912
|
+
id: Un,
|
|
4924
4913
|
type: e.type,
|
|
4925
4914
|
points: e.points,
|
|
4926
|
-
style:
|
|
4927
|
-
meta:
|
|
4928
|
-
}, n =
|
|
4929
|
-
|
|
4930
|
-
id:
|
|
4915
|
+
style: At.current,
|
|
4916
|
+
meta: jt.current
|
|
4917
|
+
}, n = un.current !== null;
|
|
4918
|
+
un.current = t, n ? pn([{
|
|
4919
|
+
id: Un,
|
|
4931
4920
|
points: e.points
|
|
4932
|
-
}]) :
|
|
4933
|
-
}, [
|
|
4934
|
-
let n =
|
|
4935
|
-
if (!n ||
|
|
4936
|
-
let r =
|
|
4937
|
-
|
|
4921
|
+
}]) : fn(t);
|
|
4922
|
+
}, [pn, je]), gn = d((e, t) => {
|
|
4923
|
+
let n = At.current;
|
|
4924
|
+
if (!n || Pt.current) return;
|
|
4925
|
+
let r = re();
|
|
4926
|
+
Z.current.create({
|
|
4938
4927
|
id: r,
|
|
4939
4928
|
type: e,
|
|
4940
4929
|
points: t,
|
|
4941
4930
|
style: n,
|
|
4942
|
-
meta:
|
|
4943
|
-
}),
|
|
4944
|
-
}, [
|
|
4945
|
-
|
|
4946
|
-
let
|
|
4947
|
-
toolRef:
|
|
4948
|
-
selRef:
|
|
4949
|
-
docRef:
|
|
4950
|
-
readOnlyRef:
|
|
4951
|
-
draftRef:
|
|
4952
|
-
brushSizeRef:
|
|
4953
|
-
simplifyEpsilonRef:
|
|
4954
|
-
draftMeta:
|
|
4955
|
-
engineRef:
|
|
4931
|
+
meta: u
|
|
4932
|
+
}), Xt.current([r]);
|
|
4933
|
+
}, [u]), _n = v(gn);
|
|
4934
|
+
_n.current = gn;
|
|
4935
|
+
let vn = Vt({
|
|
4936
|
+
toolRef: kt,
|
|
4937
|
+
selRef: Ot,
|
|
4938
|
+
docRef: Z,
|
|
4939
|
+
readOnlyRef: Pt,
|
|
4940
|
+
draftRef: At,
|
|
4941
|
+
brushSizeRef: Mt,
|
|
4942
|
+
simplifyEpsilonRef: Nt,
|
|
4943
|
+
draftMeta: u,
|
|
4944
|
+
engineRef: U,
|
|
4956
4945
|
onDrawSessionChange: d((e) => {
|
|
4957
|
-
|
|
4958
|
-
}, [
|
|
4959
|
-
onDraftShapeChange:
|
|
4960
|
-
changeSelection:
|
|
4961
|
-
createShape:
|
|
4962
|
-
}),
|
|
4963
|
-
|
|
4964
|
-
let { reset:
|
|
4965
|
-
|
|
4966
|
-
let $ =
|
|
4967
|
-
docRef:
|
|
4968
|
-
draftRef:
|
|
4969
|
-
draftMeta:
|
|
4970
|
-
changeSelection:
|
|
4971
|
-
assistantRef:
|
|
4972
|
-
}),
|
|
4973
|
-
|
|
4974
|
-
let { selectAll:
|
|
4975
|
-
doc:
|
|
4976
|
-
selRef:
|
|
4977
|
-
effectiveReadOnly:
|
|
4978
|
-
changeSelection:
|
|
4979
|
-
canMergeSelection:
|
|
4980
|
-
}), { zoomToBounds:
|
|
4981
|
-
engineRef:
|
|
4982
|
-
doc:
|
|
4983
|
-
selRef:
|
|
4984
|
-
zoomAnimationDuration:
|
|
4985
|
-
zoomBound:
|
|
4986
|
-
ready:
|
|
4946
|
+
Xe(e), Ae?.(e);
|
|
4947
|
+
}, [Ae]),
|
|
4948
|
+
onDraftShapeChange: je,
|
|
4949
|
+
changeSelection: Yt,
|
|
4950
|
+
createShape: gn
|
|
4951
|
+
}), yn = v(vn);
|
|
4952
|
+
yn.current = vn;
|
|
4953
|
+
let { reset: bn, undoSession: xn, redoSession: Sn, canUndoSession: Cn, canRedoSession: wn, hasDraftSession: Tn, hasDraftPoints: En, commitDraftSession: Dn, setBrushScalarMode: On, getBrushScalarMode: kn, hasBrushSession: An, commitBrush: Q, cancelBrush: jn, beginBrushEditFromSelection: Nn, deleteDraftSelectedPoints: Pn, handleToolChange: Fn, handleBrushSelectionChange: Ln } = vn, zn = v(he);
|
|
4954
|
+
zn.current = he;
|
|
4955
|
+
let $ = bt({
|
|
4956
|
+
docRef: Z,
|
|
4957
|
+
draftRef: At,
|
|
4958
|
+
draftMeta: u,
|
|
4959
|
+
changeSelection: Yt,
|
|
4960
|
+
assistantRef: zn
|
|
4961
|
+
}), Gn = v($);
|
|
4962
|
+
Gn.current = $;
|
|
4963
|
+
let { selectAll: Kn, clearSelection: qn, deleteSelection: Jn, copySelection: Yn, canPaste: Xn, paste: Zn, duplicate: Qn, bringToFront: $n, sendToBack: er, nudgeSelection: tr, getMergeTargets: nr, mergeSelection: rr } = Bn({
|
|
4964
|
+
doc: K,
|
|
4965
|
+
selRef: Ot,
|
|
4966
|
+
effectiveReadOnly: X,
|
|
4967
|
+
changeSelection: Yt,
|
|
4968
|
+
canMergeSelection: F
|
|
4969
|
+
}), { zoomToBounds: ir, zoomToShapes: ar, zoomToSelection: or, zoomAtCenter: sr } = Vn({
|
|
4970
|
+
engineRef: U,
|
|
4971
|
+
doc: K,
|
|
4972
|
+
selRef: Ot,
|
|
4973
|
+
zoomAnimationDuration: oe,
|
|
4974
|
+
zoomBound: ae,
|
|
4975
|
+
ready: G
|
|
4987
4976
|
});
|
|
4988
|
-
m(
|
|
4977
|
+
m(_e, () => ({
|
|
4989
4978
|
previewRegionMask: (e) => {
|
|
4990
|
-
let t =
|
|
4979
|
+
let t = Tt.current;
|
|
4991
4980
|
if (!t) return;
|
|
4992
|
-
let n = e ?
|
|
4993
|
-
|
|
4981
|
+
let n = e ? dt(e, t.w, t.h) : Ct.current;
|
|
4982
|
+
U.current?.setOverlays(cr.current.showGuide ? St.current : null, cr.current.showRegionMask ? n : null, wt.current);
|
|
4994
4983
|
},
|
|
4995
4984
|
undo: () => {
|
|
4996
|
-
|
|
4985
|
+
xn() || K.undo();
|
|
4997
4986
|
},
|
|
4998
4987
|
redo: () => {
|
|
4999
|
-
|
|
4988
|
+
Sn() || K.redo();
|
|
5000
4989
|
},
|
|
5001
|
-
canUndo: () =>
|
|
5002
|
-
canRedo: () =>
|
|
5003
|
-
undoSession:
|
|
5004
|
-
redoSession:
|
|
5005
|
-
canUndoSession:
|
|
5006
|
-
canRedoSession:
|
|
5007
|
-
hasDraftSession:
|
|
5008
|
-
cancelDraftSession:
|
|
5009
|
-
commitDraftSession:
|
|
5010
|
-
setSelection:
|
|
4990
|
+
canUndo: () => Cn() || K.canUndo(),
|
|
4991
|
+
canRedo: () => wn() || K.canRedo(),
|
|
4992
|
+
undoSession: xn,
|
|
4993
|
+
redoSession: Sn,
|
|
4994
|
+
canUndoSession: Cn,
|
|
4995
|
+
canRedoSession: wn,
|
|
4996
|
+
hasDraftSession: Tn,
|
|
4997
|
+
cancelDraftSession: bn,
|
|
4998
|
+
commitDraftSession: Dn,
|
|
4999
|
+
setSelection: Yt,
|
|
5011
5000
|
createShapes: (e) => {
|
|
5012
|
-
e.length && (
|
|
5001
|
+
e.length && (K.create(e), Yt(e.map((e) => e.id)));
|
|
5013
5002
|
},
|
|
5014
|
-
updateShapes:
|
|
5015
|
-
deleteShapes:
|
|
5016
|
-
getShapes:
|
|
5017
|
-
selectAll:
|
|
5018
|
-
clearSelection:
|
|
5019
|
-
deleteSelection:
|
|
5020
|
-
copySelection:
|
|
5021
|
-
paste:
|
|
5022
|
-
duplicate:
|
|
5023
|
-
bringToFront:
|
|
5024
|
-
sendToBack:
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
zoomFit: () => W.current?.fit(),
|
|
5028
|
-
zoom100: () => W.current?.zoom100(),
|
|
5003
|
+
updateShapes: K.update,
|
|
5004
|
+
deleteShapes: K.remove,
|
|
5005
|
+
getShapes: K.getShapes,
|
|
5006
|
+
selectAll: Kn,
|
|
5007
|
+
clearSelection: qn,
|
|
5008
|
+
deleteSelection: Jn,
|
|
5009
|
+
copySelection: Yn,
|
|
5010
|
+
paste: Zn,
|
|
5011
|
+
duplicate: Qn,
|
|
5012
|
+
bringToFront: $n,
|
|
5013
|
+
sendToBack: er,
|
|
5014
|
+
zoomFit: () => U.current?.fit(),
|
|
5015
|
+
zoom100: () => U.current?.zoom100(),
|
|
5029
5016
|
zoomIn: () => {
|
|
5030
|
-
let e =
|
|
5017
|
+
let e = U.current;
|
|
5031
5018
|
if (!e) return;
|
|
5032
5019
|
let { w: t, h: n } = e.screenSize;
|
|
5033
5020
|
e.zoomAt(t / 2, n / 2, 1.2);
|
|
5034
5021
|
},
|
|
5035
5022
|
zoomOut: () => {
|
|
5036
|
-
let e =
|
|
5023
|
+
let e = U.current;
|
|
5037
5024
|
if (!e) return;
|
|
5038
5025
|
let { w: t, h: n } = e.screenSize;
|
|
5039
5026
|
e.zoomAt(t / 2, n / 2, 1 / 1.2);
|
|
5040
5027
|
},
|
|
5041
|
-
zoomToSelection:
|
|
5042
|
-
zoomToShapes:
|
|
5043
|
-
zoomToBounds:
|
|
5028
|
+
zoomToSelection: or,
|
|
5029
|
+
zoomToShapes: ar,
|
|
5030
|
+
zoomToBounds: ir,
|
|
5044
5031
|
brush: {
|
|
5045
|
-
setScalarMode:
|
|
5046
|
-
getScalarMode:
|
|
5047
|
-
hasSession:
|
|
5048
|
-
commit:
|
|
5049
|
-
cancel:
|
|
5050
|
-
beginEditFromSelection:
|
|
5032
|
+
setScalarMode: On,
|
|
5033
|
+
getScalarMode: kn,
|
|
5034
|
+
hasSession: An,
|
|
5035
|
+
commit: Q,
|
|
5036
|
+
cancel: jn,
|
|
5037
|
+
beginEditFromSelection: Nn
|
|
5051
5038
|
}
|
|
5052
5039
|
}), [
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
Cn,
|
|
5058
|
-
gn,
|
|
5040
|
+
K,
|
|
5041
|
+
Yt,
|
|
5042
|
+
xn,
|
|
5043
|
+
Sn,
|
|
5059
5044
|
Dn,
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
Gn,
|
|
5045
|
+
bn,
|
|
5046
|
+
Q,
|
|
5047
|
+
jn,
|
|
5064
5048
|
Kn,
|
|
5049
|
+
qn,
|
|
5065
5050
|
Jn,
|
|
5066
5051
|
Yn,
|
|
5067
|
-
Xn,
|
|
5068
5052
|
Zn,
|
|
5069
5053
|
Qn,
|
|
5054
|
+
$n,
|
|
5055
|
+
er,
|
|
5056
|
+
or,
|
|
5057
|
+
ar,
|
|
5070
5058
|
ir,
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
En,
|
|
5076
|
-
kn
|
|
5059
|
+
On,
|
|
5060
|
+
kn,
|
|
5061
|
+
An,
|
|
5062
|
+
Nn
|
|
5077
5063
|
]);
|
|
5078
|
-
let
|
|
5079
|
-
|
|
5080
|
-
let
|
|
5081
|
-
engineRef:
|
|
5082
|
-
toolRef:
|
|
5083
|
-
externalToolMapRef:
|
|
5084
|
-
spaceRef:
|
|
5085
|
-
shiftRef:
|
|
5086
|
-
docRef:
|
|
5087
|
-
selRef:
|
|
5088
|
-
draftRef:
|
|
5089
|
-
readOnlyRef:
|
|
5090
|
-
disableMarqueeRef:
|
|
5091
|
-
lockedRef:
|
|
5092
|
-
onLockedInteraction: () =>
|
|
5093
|
-
createRef:
|
|
5094
|
-
selectRef:
|
|
5095
|
-
enterEditRef:
|
|
5096
|
-
drawSessionRef:
|
|
5097
|
-
assistantRef:
|
|
5098
|
-
setCursorHint:
|
|
5099
|
-
setInteractionMode:
|
|
5100
|
-
syncMinimap:
|
|
5101
|
-
onTransformPreview:
|
|
5102
|
-
onDrawPreview:
|
|
5064
|
+
let cr = v(J);
|
|
5065
|
+
cr.current = J;
|
|
5066
|
+
let lr = d(() => yt({
|
|
5067
|
+
engineRef: U,
|
|
5068
|
+
toolRef: kt,
|
|
5069
|
+
externalToolMapRef: ut,
|
|
5070
|
+
spaceRef: zt,
|
|
5071
|
+
shiftRef: Bt,
|
|
5072
|
+
docRef: Z,
|
|
5073
|
+
selRef: Ot,
|
|
5074
|
+
draftRef: At,
|
|
5075
|
+
readOnlyRef: Pt,
|
|
5076
|
+
disableMarqueeRef: Ft,
|
|
5077
|
+
lockedRef: It,
|
|
5078
|
+
onLockedInteraction: () => Lt.current?.(),
|
|
5079
|
+
createRef: _n,
|
|
5080
|
+
selectRef: Xt,
|
|
5081
|
+
enterEditRef: tn,
|
|
5082
|
+
drawSessionRef: yn,
|
|
5083
|
+
assistantRef: Gn,
|
|
5084
|
+
setCursorHint: qt,
|
|
5085
|
+
setInteractionMode: Kt,
|
|
5086
|
+
syncMinimap: on,
|
|
5087
|
+
onTransformPreview: mn,
|
|
5088
|
+
onDrawPreview: hn
|
|
5103
5089
|
}), [
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
]),
|
|
5090
|
+
qt,
|
|
5091
|
+
Kt,
|
|
5092
|
+
on,
|
|
5093
|
+
mn,
|
|
5094
|
+
hn
|
|
5095
|
+
]), ur = v([]);
|
|
5110
5096
|
Mn({
|
|
5111
|
-
backend:
|
|
5112
|
-
hostRef:
|
|
5113
|
-
engineRef:
|
|
5097
|
+
backend: ve,
|
|
5098
|
+
hostRef: Pe,
|
|
5099
|
+
engineRef: U,
|
|
5114
5100
|
imageUrl: t,
|
|
5115
|
-
renderedImageUrl:
|
|
5116
|
-
makeCallbacks:
|
|
5117
|
-
viewRef:
|
|
5118
|
-
readOnlyRef:
|
|
5119
|
-
toolRef:
|
|
5120
|
-
renderShapesRef:
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5101
|
+
renderedImageUrl: rt,
|
|
5102
|
+
makeCallbacks: lr,
|
|
5103
|
+
viewRef: cr,
|
|
5104
|
+
readOnlyRef: Pt,
|
|
5105
|
+
toolRef: kt,
|
|
5106
|
+
renderShapesRef: ur,
|
|
5107
|
+
coordinateSizeRef: Et,
|
|
5108
|
+
imageSizeRef: Dt,
|
|
5109
|
+
selRef: Ot,
|
|
5110
|
+
maskCanvasRef: St,
|
|
5111
|
+
regionOverlayRef: Ct,
|
|
5112
|
+
dimmedRef: wt,
|
|
5113
|
+
syncMinimap: on,
|
|
5114
|
+
setImage: ze,
|
|
5115
|
+
setImageVisible: He,
|
|
5116
|
+
setReady: Ge,
|
|
5117
|
+
setImageStatus: at,
|
|
5118
|
+
onContextMenuRequest: Je
|
|
5131
5119
|
});
|
|
5132
|
-
let
|
|
5133
|
-
let e =
|
|
5134
|
-
let t =
|
|
5120
|
+
let dr = g(() => {
|
|
5121
|
+
let e = E ? K.shapes.map((e) => {
|
|
5122
|
+
let t = E(e);
|
|
5135
5123
|
return t ? {
|
|
5136
5124
|
...e,
|
|
5137
5125
|
interaction: {
|
|
@@ -5139,8 +5127,8 @@ function Wn({ imageUrl: t, displayImageUrl: n, renderImageState: r, dimmed: i =
|
|
|
5139
5127
|
...t
|
|
5140
5128
|
}
|
|
5141
5129
|
} : e;
|
|
5142
|
-
}) :
|
|
5143
|
-
return
|
|
5130
|
+
}) : K.shapes;
|
|
5131
|
+
return L?.length ? [...L.map((e) => ({
|
|
5144
5132
|
...e,
|
|
5145
5133
|
interaction: {
|
|
5146
5134
|
...e.interaction,
|
|
@@ -5151,142 +5139,142 @@ function Wn({ imageUrl: t, displayImageUrl: n, renderImageState: r, dimmed: i =
|
|
|
5151
5139
|
}
|
|
5152
5140
|
})), ...e] : e;
|
|
5153
5141
|
}, [
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5142
|
+
K.shapes,
|
|
5143
|
+
E,
|
|
5144
|
+
L
|
|
5157
5145
|
]);
|
|
5158
|
-
|
|
5159
|
-
|
|
5146
|
+
ur.current = dr, f(() => {
|
|
5147
|
+
U.current?.setShapes(dr, q), on();
|
|
5160
5148
|
}, [
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5149
|
+
dr,
|
|
5150
|
+
q,
|
|
5151
|
+
on
|
|
5164
5152
|
]), f(() => {
|
|
5165
|
-
|
|
5166
|
-
}, [
|
|
5167
|
-
let
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
}, [
|
|
5171
|
-
|
|
5172
|
-
}, [
|
|
5173
|
-
|
|
5174
|
-
}, [
|
|
5175
|
-
let e =
|
|
5176
|
-
e && (e.setFilter(
|
|
5153
|
+
U.current?.setEditing(Zt);
|
|
5154
|
+
}, [Zt, G]);
|
|
5155
|
+
let fr = v(Se);
|
|
5156
|
+
fr.current = Se, f(() => {
|
|
5157
|
+
fr.current?.(Zt);
|
|
5158
|
+
}, [Zt]), f(() => {
|
|
5159
|
+
Qt(null);
|
|
5160
|
+
}, [c]), f(() => {
|
|
5161
|
+
Zt && (q.length !== 1 || q[0] !== Zt) && Qt(null);
|
|
5162
|
+
}, [q, Zt]), f(() => {
|
|
5163
|
+
let e = U.current;
|
|
5164
|
+
e && (e.setFilter(J.brightness, J.contrast), e.setStrokeSize(J.strokeSize), e.setImageSmoothing(J.imageSmoothing), on());
|
|
5177
5165
|
}, [
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5166
|
+
J.brightness,
|
|
5167
|
+
J.contrast,
|
|
5168
|
+
J.strokeSize,
|
|
5169
|
+
J.imageSmoothing,
|
|
5170
|
+
on
|
|
5183
5171
|
]), h(() => {
|
|
5184
|
-
|
|
5172
|
+
G && U.current?.setOverlays(J.showGuide ? _t : null, J.showRegionMask ? xt : null, a);
|
|
5185
5173
|
}, [
|
|
5186
|
-
|
|
5187
|
-
ht,
|
|
5174
|
+
G,
|
|
5188
5175
|
_t,
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5176
|
+
xt,
|
|
5177
|
+
J.showGuide,
|
|
5178
|
+
J.showRegionMask,
|
|
5179
|
+
a
|
|
5192
5180
|
]), f(() => {
|
|
5193
|
-
!
|
|
5181
|
+
!G || !W || on();
|
|
5194
5182
|
}, [
|
|
5195
|
-
K,
|
|
5196
5183
|
G,
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5184
|
+
W,
|
|
5185
|
+
vt,
|
|
5186
|
+
J.showGuide,
|
|
5187
|
+
J.showRegionMask,
|
|
5200
5188
|
R,
|
|
5201
|
-
|
|
5189
|
+
on
|
|
5202
5190
|
]), f(() => {
|
|
5203
|
-
|
|
5191
|
+
G && U.current?.setTransformEnabled(!X && c !== H.BRUSH);
|
|
5204
5192
|
}, [
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5193
|
+
X,
|
|
5194
|
+
G,
|
|
5195
|
+
c
|
|
5208
5196
|
]), f(() => {
|
|
5209
|
-
|
|
5197
|
+
Fn(c, lt.has(c));
|
|
5210
5198
|
}, [
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5199
|
+
c,
|
|
5200
|
+
lt,
|
|
5201
|
+
Fn
|
|
5214
5202
|
]);
|
|
5215
|
-
let
|
|
5203
|
+
let pr = $.finalize;
|
|
5216
5204
|
f(() => {
|
|
5217
|
-
|
|
5218
|
-
}, [
|
|
5219
|
-
|
|
5205
|
+
pr();
|
|
5206
|
+
}, [c, pr]), f(() => {
|
|
5207
|
+
Ht.current = "idle", Ut.current = null, Gt();
|
|
5220
5208
|
}, [
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5209
|
+
c,
|
|
5210
|
+
ve,
|
|
5211
|
+
Gt
|
|
5224
5212
|
]), f(() => {
|
|
5225
|
-
|
|
5213
|
+
Ln(q, X);
|
|
5226
5214
|
}, [
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5215
|
+
q,
|
|
5216
|
+
c,
|
|
5217
|
+
X,
|
|
5218
|
+
Ln
|
|
5231
5219
|
]), f(() => {
|
|
5232
|
-
|
|
5220
|
+
G && Gt();
|
|
5233
5221
|
}, [
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5222
|
+
c,
|
|
5223
|
+
Ye,
|
|
5224
|
+
lt,
|
|
5225
|
+
G,
|
|
5226
|
+
Gt
|
|
5239
5227
|
]);
|
|
5240
|
-
let
|
|
5228
|
+
let mr = v(null);
|
|
5241
5229
|
f(() => {
|
|
5242
|
-
|
|
5230
|
+
mr.current !== t && (mr.current = t, K.reset(o ?? []), Yt([]), bn(), pr());
|
|
5243
5231
|
}, [
|
|
5244
5232
|
t,
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
]),
|
|
5251
|
-
keymap:
|
|
5252
|
-
hostRef:
|
|
5233
|
+
o,
|
|
5234
|
+
K.reset,
|
|
5235
|
+
Yt,
|
|
5236
|
+
bn,
|
|
5237
|
+
pr
|
|
5238
|
+
]), en({
|
|
5239
|
+
keymap: ge,
|
|
5240
|
+
hostRef: Pe,
|
|
5253
5241
|
actions: {
|
|
5254
5242
|
undo: () => {
|
|
5255
|
-
|
|
5243
|
+
X || xn() || K.undo();
|
|
5256
5244
|
},
|
|
5257
5245
|
redo: () => {
|
|
5258
|
-
|
|
5246
|
+
X || Sn() || K.redo();
|
|
5259
5247
|
},
|
|
5260
|
-
selectAll:
|
|
5261
|
-
copy:
|
|
5248
|
+
selectAll: Kn,
|
|
5249
|
+
copy: Yn,
|
|
5262
5250
|
cut: () => {
|
|
5263
|
-
|
|
5251
|
+
Yn(), Jn();
|
|
5264
5252
|
},
|
|
5265
|
-
paste:
|
|
5266
|
-
duplicate:
|
|
5253
|
+
paste: Zn,
|
|
5254
|
+
duplicate: Qn,
|
|
5267
5255
|
delete: () => {
|
|
5268
|
-
|
|
5256
|
+
En() && Pn() || Jn();
|
|
5269
5257
|
},
|
|
5270
5258
|
cancel: () => {
|
|
5271
|
-
let e =
|
|
5259
|
+
let e = ut.current.get(kt.current);
|
|
5272
5260
|
if (!(e?.onCancel && e.onCancel() !== !1)) {
|
|
5273
5261
|
if ($.isActive()) {
|
|
5274
5262
|
$.cancel();
|
|
5275
5263
|
return;
|
|
5276
5264
|
}
|
|
5277
|
-
if (
|
|
5278
|
-
|
|
5265
|
+
if (Tn()) {
|
|
5266
|
+
bn();
|
|
5279
5267
|
return;
|
|
5280
5268
|
}
|
|
5281
|
-
if (
|
|
5282
|
-
|
|
5269
|
+
if (Zt) {
|
|
5270
|
+
Qt(null);
|
|
5283
5271
|
return;
|
|
5284
5272
|
}
|
|
5285
|
-
if (
|
|
5286
|
-
|
|
5273
|
+
if (Ot.current.length) {
|
|
5274
|
+
qn();
|
|
5287
5275
|
return;
|
|
5288
5276
|
}
|
|
5289
|
-
|
|
5277
|
+
T?.();
|
|
5290
5278
|
}
|
|
5291
5279
|
},
|
|
5292
5280
|
commitDraft: () => {
|
|
@@ -5294,244 +5282,230 @@ function Wn({ imageUrl: t, displayImageUrl: n, renderImageState: r, dimmed: i =
|
|
|
5294
5282
|
$.finalize();
|
|
5295
5283
|
return;
|
|
5296
5284
|
}
|
|
5297
|
-
if (
|
|
5298
|
-
|
|
5285
|
+
if (Tn()) {
|
|
5286
|
+
Dn();
|
|
5299
5287
|
return;
|
|
5300
5288
|
}
|
|
5301
|
-
if (
|
|
5302
|
-
if (
|
|
5303
|
-
|
|
5289
|
+
if (X) return;
|
|
5290
|
+
if (Zt) {
|
|
5291
|
+
Qt(null);
|
|
5304
5292
|
return;
|
|
5305
5293
|
}
|
|
5306
|
-
let e =
|
|
5294
|
+
let e = Ot.current;
|
|
5307
5295
|
if (e.length !== 1) return;
|
|
5308
|
-
let t =
|
|
5309
|
-
t && (t.type === j.POLYGON || t.type === j.LINE) && t.interaction?.editable !== !1 && !t.readOnly &&
|
|
5296
|
+
let t = Z.current.getShapes().find((t) => t.id === e[0]);
|
|
5297
|
+
t && (t.type === j.POLYGON || t.type === j.LINE) && t.interaction?.editable !== !1 && !t.readOnly && Qt(e[0]);
|
|
5310
5298
|
},
|
|
5311
|
-
bringToFront:
|
|
5312
|
-
sendToBack:
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
toggleMinimap: () => Xe((e) => !e),
|
|
5320
|
-
toggleCursorGuide: () => dt((e) => ({
|
|
5299
|
+
bringToFront: $n,
|
|
5300
|
+
sendToBack: er,
|
|
5301
|
+
zoomIn: () => sr(1.2),
|
|
5302
|
+
zoomOut: () => sr(1 / 1.2),
|
|
5303
|
+
zoom100: () => U.current?.zoom100(),
|
|
5304
|
+
zoomFit: () => U.current?.fit(),
|
|
5305
|
+
toggleMinimap: () => $e((e) => !e),
|
|
5306
|
+
toggleCursorGuide: () => pt((e) => ({
|
|
5321
5307
|
...e,
|
|
5322
5308
|
showCursorGuide: !e.showCursorGuide
|
|
5323
5309
|
})),
|
|
5324
|
-
togglePixelation: () =>
|
|
5310
|
+
togglePixelation: () => pt((e) => ({
|
|
5325
5311
|
...e,
|
|
5326
5312
|
imageSmoothing: !e.imageSmoothing
|
|
5327
5313
|
})),
|
|
5328
|
-
selectTool: () =>
|
|
5329
|
-
rectangleTool: () =>
|
|
5330
|
-
rotatedRectangleTool: () =>
|
|
5331
|
-
circleTool: () =>
|
|
5332
|
-
polygonTool: () =>
|
|
5333
|
-
pathTool: () =>
|
|
5334
|
-
brushTool: () =>
|
|
5335
|
-
pointTool: () =>
|
|
5314
|
+
selectTool: () => V?.(H.SELECT),
|
|
5315
|
+
rectangleTool: () => V?.(H.RECTANGLE),
|
|
5316
|
+
rotatedRectangleTool: () => V?.(H.ROTATED_RECTANGLE),
|
|
5317
|
+
circleTool: () => V?.(H.CIRCLE),
|
|
5318
|
+
polygonTool: () => V?.(H.POLYGON),
|
|
5319
|
+
pathTool: () => V?.(H.PATH),
|
|
5320
|
+
brushTool: () => V?.(H.BRUSH),
|
|
5321
|
+
pointTool: () => V?.(H.POINT)
|
|
5336
5322
|
},
|
|
5337
|
-
spaceRef:
|
|
5338
|
-
shiftRef:
|
|
5323
|
+
spaceRef: zt,
|
|
5324
|
+
shiftRef: Bt,
|
|
5339
5325
|
onSpaceDown: () => {
|
|
5340
|
-
|
|
5326
|
+
U.current?.setPanMode(!0), Gt();
|
|
5341
5327
|
},
|
|
5342
5328
|
onSpaceUp: () => {
|
|
5343
|
-
|
|
5329
|
+
U.current?.setPanMode(!1), Ht.current === "panning" ? Kt("idle") : Gt();
|
|
5344
5330
|
},
|
|
5345
|
-
nudge:
|
|
5331
|
+
nudge: tr
|
|
5346
5332
|
});
|
|
5347
|
-
let
|
|
5348
|
-
let e =
|
|
5333
|
+
let hr = g(() => dr.filter((e) => q.includes(e.id) && M(e)), [dr, q]), gr = g(() => dn ? [...hr, dn] : hr, [hr, dn]), _r = q.length > 0, vr = K.shapes.some((e) => q.includes(e.id) && ee(e)), yr = !X && q.length === 1 && (() => {
|
|
5334
|
+
let e = K.shapes.find((e) => e.id === q[0]);
|
|
5349
5335
|
return !!e && (e.type === j.POLYGON || e.type === j.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
|
|
5350
|
-
})(),
|
|
5351
|
-
let e =
|
|
5336
|
+
})(), br = nr(), xr = X || br.length < 2 || (F ? !F(br) : !1), Sr = he && !X && q.length === 1 ? (() => {
|
|
5337
|
+
let e = K.shapes.find((e) => e.id === q[0]);
|
|
5352
5338
|
return e && e.type === j.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
|
|
5353
|
-
})() : null,
|
|
5339
|
+
})() : null, Cr = [
|
|
5354
5340
|
{
|
|
5355
5341
|
id: "copy",
|
|
5356
|
-
label:
|
|
5342
|
+
label: Y.contextMenu.copy,
|
|
5357
5343
|
shortcut: "⌘C",
|
|
5358
|
-
disabled: !
|
|
5359
|
-
onClick:
|
|
5344
|
+
disabled: !_r,
|
|
5345
|
+
onClick: Yn
|
|
5360
5346
|
},
|
|
5361
5347
|
{
|
|
5362
5348
|
id: "paste",
|
|
5363
|
-
label:
|
|
5349
|
+
label: Y.contextMenu.paste,
|
|
5364
5350
|
shortcut: "⌘V",
|
|
5365
|
-
disabled:
|
|
5366
|
-
onClick:
|
|
5351
|
+
disabled: X || !Xn(),
|
|
5352
|
+
onClick: Zn
|
|
5367
5353
|
},
|
|
5368
5354
|
{
|
|
5369
5355
|
id: "duplicate",
|
|
5370
|
-
label:
|
|
5356
|
+
label: Y.contextMenu.duplicate,
|
|
5371
5357
|
shortcut: "⌘D",
|
|
5372
|
-
disabled: !
|
|
5373
|
-
onClick:
|
|
5358
|
+
disabled: !vr || X,
|
|
5359
|
+
onClick: Qn
|
|
5374
5360
|
},
|
|
5375
5361
|
{
|
|
5376
5362
|
id: "delete",
|
|
5377
|
-
label:
|
|
5363
|
+
label: Y.contextMenu.delete,
|
|
5378
5364
|
shortcut: "Del",
|
|
5379
5365
|
danger: !0,
|
|
5380
|
-
disabled: !
|
|
5381
|
-
onClick:
|
|
5366
|
+
disabled: !vr || X,
|
|
5367
|
+
onClick: Jn
|
|
5382
5368
|
},
|
|
5383
5369
|
{ separator: !0 },
|
|
5384
5370
|
{
|
|
5385
5371
|
id: "editVertices",
|
|
5386
|
-
label:
|
|
5372
|
+
label: Y.contextMenu.editVertices,
|
|
5387
5373
|
shortcut: "Enter",
|
|
5388
|
-
disabled: !
|
|
5389
|
-
onClick: () =>
|
|
5374
|
+
disabled: !yr,
|
|
5375
|
+
onClick: () => Qt(q[0])
|
|
5390
5376
|
},
|
|
5391
5377
|
{
|
|
5392
5378
|
id: "merge",
|
|
5393
|
-
label:
|
|
5394
|
-
disabled:
|
|
5395
|
-
onClick:
|
|
5379
|
+
label: Y.contextMenu.merge,
|
|
5380
|
+
disabled: xr,
|
|
5381
|
+
onClick: rr
|
|
5396
5382
|
},
|
|
5397
5383
|
{
|
|
5398
5384
|
id: "assistExpand",
|
|
5399
|
-
label:
|
|
5385
|
+
label: Y.contextMenu.assistExpand,
|
|
5400
5386
|
icon: /* @__PURE__ */ x(e, { size: 14 }),
|
|
5401
|
-
disabled: !
|
|
5387
|
+
disabled: !Sr,
|
|
5402
5388
|
onClick: () => {
|
|
5403
|
-
|
|
5389
|
+
qe && Sr && $.refineShape(Sr, qe.img, !0);
|
|
5404
5390
|
}
|
|
5405
5391
|
},
|
|
5406
5392
|
{
|
|
5407
5393
|
id: "assistExclude",
|
|
5408
|
-
label:
|
|
5394
|
+
label: Y.contextMenu.assistExclude,
|
|
5409
5395
|
icon: /* @__PURE__ */ x(e, { size: 14 }),
|
|
5410
|
-
disabled: !
|
|
5396
|
+
disabled: !Sr,
|
|
5411
5397
|
onClick: () => {
|
|
5412
|
-
|
|
5398
|
+
qe && Sr && $.refineShape(Sr, qe.img, !1);
|
|
5413
5399
|
}
|
|
5414
5400
|
},
|
|
5415
5401
|
{
|
|
5416
5402
|
id: "bringToFront",
|
|
5417
|
-
label:
|
|
5418
|
-
disabled: !
|
|
5419
|
-
onClick:
|
|
5403
|
+
label: Y.contextMenu.bringToFront,
|
|
5404
|
+
disabled: !vr || X,
|
|
5405
|
+
onClick: $n
|
|
5420
5406
|
},
|
|
5421
5407
|
{
|
|
5422
5408
|
id: "sendToBack",
|
|
5423
|
-
label:
|
|
5424
|
-
disabled: !
|
|
5425
|
-
onClick:
|
|
5426
|
-
},
|
|
5427
|
-
{
|
|
5428
|
-
id: "flipHorizontal",
|
|
5429
|
-
label: X.contextMenu.flipHorizontal,
|
|
5430
|
-
disabled: !gr || Z,
|
|
5431
|
-
onClick: () => Qn(!0)
|
|
5432
|
-
},
|
|
5433
|
-
{
|
|
5434
|
-
id: "flipVertical",
|
|
5435
|
-
label: X.contextMenu.flipVertical,
|
|
5436
|
-
disabled: !gr || Z,
|
|
5437
|
-
onClick: () => Qn(!1)
|
|
5409
|
+
label: Y.contextMenu.sendToBack,
|
|
5410
|
+
disabled: !vr || X,
|
|
5411
|
+
onClick: er
|
|
5438
5412
|
},
|
|
5439
5413
|
{ separator: !0 },
|
|
5440
5414
|
{
|
|
5441
5415
|
id: "undo",
|
|
5442
|
-
label:
|
|
5416
|
+
label: Y.contextMenu.undo,
|
|
5443
5417
|
shortcut: "⌘Z",
|
|
5444
|
-
disabled:
|
|
5418
|
+
disabled: X || !Cn() && !K.canUndo(),
|
|
5445
5419
|
onClick: () => {
|
|
5446
|
-
|
|
5420
|
+
xn() || K.undo();
|
|
5447
5421
|
}
|
|
5448
5422
|
},
|
|
5449
5423
|
{
|
|
5450
5424
|
id: "redo",
|
|
5451
|
-
label:
|
|
5425
|
+
label: Y.contextMenu.redo,
|
|
5452
5426
|
shortcut: "⇧⌘Z",
|
|
5453
|
-
disabled:
|
|
5427
|
+
disabled: X || !wn() && !K.canRedo(),
|
|
5454
5428
|
onClick: () => {
|
|
5455
|
-
|
|
5429
|
+
Sn() || K.redo();
|
|
5456
5430
|
}
|
|
5457
5431
|
},
|
|
5458
5432
|
{ separator: !0 },
|
|
5459
5433
|
{
|
|
5460
5434
|
id: "selectAll",
|
|
5461
|
-
label:
|
|
5435
|
+
label: Y.contextMenu.selectAll,
|
|
5462
5436
|
shortcut: "⌘A",
|
|
5463
|
-
onClick:
|
|
5437
|
+
onClick: Kn
|
|
5464
5438
|
},
|
|
5465
5439
|
{
|
|
5466
5440
|
id: "clearSelection",
|
|
5467
|
-
label:
|
|
5468
|
-
disabled: !
|
|
5469
|
-
onClick:
|
|
5441
|
+
label: Y.contextMenu.clearSelection,
|
|
5442
|
+
disabled: !_r,
|
|
5443
|
+
onClick: qn
|
|
5470
5444
|
},
|
|
5471
5445
|
{
|
|
5472
5446
|
id: "zoomToSelection",
|
|
5473
|
-
label:
|
|
5474
|
-
disabled: !
|
|
5475
|
-
onClick:
|
|
5447
|
+
label: Y.contextMenu.zoomToSelection,
|
|
5448
|
+
disabled: !_r,
|
|
5449
|
+
onClick: or
|
|
5476
5450
|
}
|
|
5477
|
-
],
|
|
5478
|
-
selectedIds:
|
|
5479
|
-
readOnly:
|
|
5480
|
-
}) :
|
|
5481
|
-
engineRef:
|
|
5482
|
-
image:
|
|
5483
|
-
wheelZoom:
|
|
5484
|
-
minimapSize:
|
|
5451
|
+
], wr = te ? te(Cr, {
|
|
5452
|
+
selectedIds: q,
|
|
5453
|
+
readOnly: X
|
|
5454
|
+
}) : Cr, Tr = In({
|
|
5455
|
+
engineRef: U,
|
|
5456
|
+
image: W,
|
|
5457
|
+
wheelZoom: J.wheelZoom,
|
|
5458
|
+
minimapSize: Hn
|
|
5485
5459
|
});
|
|
5486
5460
|
return /* @__PURE__ */ S("div", {
|
|
5487
5461
|
className: "aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black",
|
|
5488
5462
|
children: [
|
|
5489
5463
|
/* @__PURE__ */ x("div", {
|
|
5490
|
-
ref:
|
|
5464
|
+
ref: Pe,
|
|
5491
5465
|
className: "aivex:h-full aivex:w-full",
|
|
5492
5466
|
style: {
|
|
5493
|
-
opacity: +!!
|
|
5494
|
-
transition:
|
|
5467
|
+
opacity: +!!Ve,
|
|
5468
|
+
transition: Ve ? "opacity 0.3s ease" : "none"
|
|
5495
5469
|
}
|
|
5496
5470
|
}),
|
|
5497
|
-
|
|
5498
|
-
status:
|
|
5499
|
-
render:
|
|
5500
|
-
loadingLabel:
|
|
5501
|
-
errorLabel:
|
|
5471
|
+
it !== "ready" && /* @__PURE__ */ x(ke, {
|
|
5472
|
+
status: it,
|
|
5473
|
+
render: i,
|
|
5474
|
+
loadingLabel: Y.imageLoading,
|
|
5475
|
+
errorLabel: Y.imageLoadError
|
|
5502
5476
|
}),
|
|
5503
|
-
|
|
5477
|
+
G && W && /* @__PURE__ */ x("div", {
|
|
5504
5478
|
className: "aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden",
|
|
5505
5479
|
children: /* @__PURE__ */ S("div", {
|
|
5506
|
-
ref:
|
|
5480
|
+
ref: Ie,
|
|
5507
5481
|
style: {
|
|
5508
5482
|
position: "absolute",
|
|
5509
5483
|
top: 0,
|
|
5510
5484
|
left: 0,
|
|
5511
|
-
width:
|
|
5512
|
-
height:
|
|
5485
|
+
width: W.w,
|
|
5486
|
+
height: W.h,
|
|
5513
5487
|
transformOrigin: "0 0"
|
|
5514
5488
|
},
|
|
5515
5489
|
children: [
|
|
5516
|
-
!!
|
|
5490
|
+
!!ce?.length && B && /* @__PURE__ */ x("div", {
|
|
5517
5491
|
style: {
|
|
5518
5492
|
position: "absolute",
|
|
5519
5493
|
left: 0,
|
|
5520
5494
|
top: 0,
|
|
5521
|
-
width:
|
|
5522
|
-
height:
|
|
5495
|
+
width: W.w,
|
|
5496
|
+
height: W.h,
|
|
5523
5497
|
pointerEvents: "none"
|
|
5524
5498
|
},
|
|
5525
|
-
children:
|
|
5499
|
+
children: ce.map((e) => /* @__PURE__ */ x("div", {
|
|
5526
5500
|
role: e.disabled ? void 0 : "button",
|
|
5527
5501
|
tabIndex: e.disabled ? void 0 : 0,
|
|
5528
5502
|
"aria-pressed": e.selected || void 0,
|
|
5529
5503
|
onPointerDown: (e) => e.stopPropagation(),
|
|
5530
5504
|
onClick: (t) => {
|
|
5531
|
-
t.stopPropagation(), e.disabled ||
|
|
5505
|
+
t.stopPropagation(), e.disabled || le?.(e);
|
|
5532
5506
|
},
|
|
5533
5507
|
onKeyDown: (t) => {
|
|
5534
|
-
e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(),
|
|
5508
|
+
e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), le?.(e));
|
|
5535
5509
|
},
|
|
5536
5510
|
style: {
|
|
5537
5511
|
position: "absolute",
|
|
@@ -5543,26 +5517,26 @@ function Wn({ imageUrl: t, displayImageUrl: n, renderImageState: r, dimmed: i =
|
|
|
5543
5517
|
pointerEvents: e.disabled ? "none" : "auto",
|
|
5544
5518
|
cursor: e.disabled ? "default" : "pointer"
|
|
5545
5519
|
},
|
|
5546
|
-
children:
|
|
5520
|
+
children: B(e)
|
|
5547
5521
|
}, e.id))
|
|
5548
5522
|
}),
|
|
5549
|
-
|
|
5550
|
-
image:
|
|
5551
|
-
viewport:
|
|
5523
|
+
ue?.({
|
|
5524
|
+
image: W,
|
|
5525
|
+
viewport: U.current?.viewport ?? {
|
|
5552
5526
|
scale: 1,
|
|
5553
5527
|
x: 0,
|
|
5554
5528
|
y: 0
|
|
5555
5529
|
}
|
|
5556
5530
|
}),
|
|
5557
|
-
|
|
5558
|
-
shapes:
|
|
5559
|
-
getLabel:
|
|
5560
|
-
hideDot:
|
|
5561
|
-
formatInfo:
|
|
5562
|
-
register:
|
|
5531
|
+
gr.length > 0 && /* @__PURE__ */ x(Ke, {
|
|
5532
|
+
shapes: gr,
|
|
5533
|
+
getLabel: de,
|
|
5534
|
+
hideDot: fe,
|
|
5535
|
+
formatInfo: pe,
|
|
5536
|
+
register: ln
|
|
5563
5537
|
}),
|
|
5564
|
-
|
|
5565
|
-
image:
|
|
5538
|
+
he && ($.status === "loading" || $.boxes.length > 0) && /* @__PURE__ */ x(Te, {
|
|
5539
|
+
image: W,
|
|
5566
5540
|
points: $.points,
|
|
5567
5541
|
boxes: $.boxes,
|
|
5568
5542
|
status: $.status
|
|
@@ -5570,36 +5544,36 @@ function Wn({ imageUrl: t, displayImageUrl: n, renderImageState: r, dimmed: i =
|
|
|
5570
5544
|
]
|
|
5571
5545
|
})
|
|
5572
5546
|
}),
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
image:
|
|
5576
|
-
imageUrl:
|
|
5577
|
-
imageVisible:
|
|
5578
|
-
maskDataUrl:
|
|
5579
|
-
region:
|
|
5580
|
-
roiMaskId:
|
|
5581
|
-
shapes:
|
|
5582
|
-
view:
|
|
5583
|
-
onChangeView:
|
|
5584
|
-
nav:
|
|
5585
|
-
registerShape:
|
|
5586
|
-
rectRef:
|
|
5587
|
-
zoomLabelRef:
|
|
5588
|
-
onZoom100: () =>
|
|
5589
|
-
open:
|
|
5590
|
-
onToggleOpen: () =>
|
|
5591
|
-
labels:
|
|
5592
|
-
settingsLabels:
|
|
5593
|
-
showSettings:
|
|
5594
|
-
settingsOpen:
|
|
5595
|
-
onToggleSettings: () =>
|
|
5596
|
-
onCloseSettings: () =>
|
|
5547
|
+
G && J.showCursorGuide && /* @__PURE__ */ x(Oe, { color: "#1e88e5" }),
|
|
5548
|
+
G && W && A && /* @__PURE__ */ x(Be, {
|
|
5549
|
+
image: W,
|
|
5550
|
+
imageUrl: rt,
|
|
5551
|
+
imageVisible: Ve,
|
|
5552
|
+
maskDataUrl: vt,
|
|
5553
|
+
region: xt,
|
|
5554
|
+
roiMaskId: Re,
|
|
5555
|
+
shapes: dr,
|
|
5556
|
+
view: J,
|
|
5557
|
+
onChangeView: mt,
|
|
5558
|
+
nav: Tr,
|
|
5559
|
+
registerShape: rn,
|
|
5560
|
+
rectRef: Fe,
|
|
5561
|
+
zoomLabelRef: Le,
|
|
5562
|
+
onZoom100: () => U.current?.zoom100(),
|
|
5563
|
+
open: Ze,
|
|
5564
|
+
onToggleOpen: () => $e((e) => !e),
|
|
5565
|
+
labels: Y.minimap,
|
|
5566
|
+
settingsLabels: Y.viewSettings,
|
|
5567
|
+
showSettings: N,
|
|
5568
|
+
settingsOpen: et,
|
|
5569
|
+
onToggleSettings: () => nt((e) => !e),
|
|
5570
|
+
onCloseSettings: () => nt(!1)
|
|
5597
5571
|
}),
|
|
5598
|
-
|
|
5599
|
-
x:
|
|
5600
|
-
y:
|
|
5601
|
-
items:
|
|
5602
|
-
onClose: () =>
|
|
5572
|
+
qe && /* @__PURE__ */ x(De, {
|
|
5573
|
+
x: qe.x,
|
|
5574
|
+
y: qe.y,
|
|
5575
|
+
items: wr,
|
|
5576
|
+
onClose: () => Je(null)
|
|
5603
5577
|
})
|
|
5604
5578
|
]
|
|
5605
5579
|
});
|
|
@@ -5607,7 +5581,7 @@ function Wn({ imageUrl: t, displayImageUrl: n, renderImageState: r, dimmed: i =
|
|
|
5607
5581
|
//#endregion
|
|
5608
5582
|
//#region src/components/ShapeEditor/ShapeViewer.tsx
|
|
5609
5583
|
async function Gn(e) {
|
|
5610
|
-
let t = await
|
|
5584
|
+
let t = await tn(e);
|
|
5611
5585
|
return await new Promise((n, r) => {
|
|
5612
5586
|
let i = new Image();
|
|
5613
5587
|
t || (i.crossOrigin = "anonymous"), i.onload = () => n({
|
|
@@ -5627,7 +5601,7 @@ function Kn(e, t, n) {
|
|
|
5627
5601
|
}
|
|
5628
5602
|
function qn(e, t, n, r) {
|
|
5629
5603
|
if (t.interaction?.visible === !1) return;
|
|
5630
|
-
let i =
|
|
5604
|
+
let i = Pe(t, {
|
|
5631
5605
|
strokeWidth: r,
|
|
5632
5606
|
pointRadius: 2
|
|
5633
5607
|
});
|
|
@@ -5680,7 +5654,7 @@ function Jn({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
5680
5654
|
}, [e, D]), f(() => () => {
|
|
5681
5655
|
E.current?.revoke?.(), E.current = null;
|
|
5682
5656
|
}, []);
|
|
5683
|
-
let N = g(() => r.find((e) => e.id === s), [s, r]), P = g(() => a && o ?
|
|
5657
|
+
let N = g(() => r.find((e) => e.id === s), [s, r]), P = g(() => a && o ? tt(a, o) : null, [a, o]);
|
|
5684
5658
|
return f(() => {
|
|
5685
5659
|
if (k === "error") {
|
|
5686
5660
|
let e = T.current;
|
|
@@ -5699,12 +5673,12 @@ function Jn({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
5699
5673
|
if (!g || !_) return;
|
|
5700
5674
|
let v = Math.min(o / g, s / _), y = (o - g * v) / 2, b = (s - _ * v) / 2;
|
|
5701
5675
|
if (N && N.points.length > 0) {
|
|
5702
|
-
let e =
|
|
5676
|
+
let e = I(N.points), t = Math.max(e.maxX - e.minX, 50), n = Math.max(e.maxY - e.minY, 50), r = Math.min(t, n) * l;
|
|
5703
5677
|
v = Math.min(o / (t + r * 2), s / (n + r * 2)), c === "cover" && (v = Math.max(v, Math.max(o / g, s / _))), y = o / 2 - (e.minX + e.maxX) / 2 * v, b = s / 2 - (e.minY + e.maxY) / 2 * v, c === "cover" && (y = Math.min(0, Math.max(y, o - g * v)), b = Math.min(0, Math.max(b, s - _ * v)));
|
|
5704
5678
|
}
|
|
5705
5679
|
h.setTransform(f, 0, 0, f, 0, 0), h.clearRect(0, 0, o, s), h.save(), h.translate(y, b), h.scale(v, v), h.imageSmoothingEnabled = m, h.filter = `brightness(${d}) contrast(${p})`, h.drawImage(a.image, 0, 0, g, _), h.filter = "none", P && (h.save(), h.globalAlpha = .55, h.drawImage(P, 0, 0, g, _), h.restore());
|
|
5706
|
-
let x = i ?
|
|
5707
|
-
if (x && (
|
|
5680
|
+
let x = i ? dt(i, g, _) : null;
|
|
5681
|
+
if (x && (st(h, x, g, _), x.outlineStyles)) {
|
|
5708
5682
|
let e = (e, t) => {
|
|
5709
5683
|
if (h.lineWidth = t.width / v, t.underlayColor) {
|
|
5710
5684
|
h.setLineDash([]), h.strokeStyle = t.underlayColor;
|
|
@@ -5716,7 +5690,7 @@ function Jn({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
5716
5690
|
};
|
|
5717
5691
|
e(x.visibleOutline, x.outlineStyles.visible), e(x.occludedOutline, x.outlineStyles.occluded);
|
|
5718
5692
|
}
|
|
5719
|
-
for (let e of
|
|
5693
|
+
for (let e of ne(r)) qn(h, e, v, u);
|
|
5720
5694
|
h.restore();
|
|
5721
5695
|
}, [
|
|
5722
5696
|
d,
|
|
@@ -5756,6 +5730,6 @@ function Jn({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
5756
5730
|
});
|
|
5757
5731
|
}
|
|
5758
5732
|
//#endregion
|
|
5759
|
-
export {
|
|
5733
|
+
export { V as DEFAULT_EDITOR_STRINGS, be as DEFAULT_VIEW_SETTINGS, j as SHAPE_TYPE, $ as ShapeEditor, $ as default, Jn as ShapeViewer, H as TOOL, re as generateId };
|
|
5760
5734
|
|
|
5761
5735
|
//# sourceMappingURL=shape-editor.js.map
|