@aivex/ui 1.2.0-dev.24 → 1.2.0-dev.25
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/ShapeViewer.d.ts +3 -1
- package/dist/components/ShapeEditor/_components/ImageStateOverlay.d.ts +6 -2
- package/dist/components/ShapeEditor/_model/imageDiagnosis.d.ts +23 -0
- package/dist/components/ShapeEditor/_model/imageDiagnosis.test.d.ts +1 -0
- package/dist/components/ShapeEditor/_model/imageLoad.d.ts +13 -0
- package/dist/components/ShapeEditor/_model/imageLoad.test.d.ts +1 -0
- package/dist/components/ShapeEditor/_model/props.d.ts +3 -1
- package/dist/components/ShapeEditor/_model/strings.d.ts +3 -0
- package/dist/components/ShapeEditor/_renderers/KonvaRenderer.d.ts +1 -1
- package/dist/components/ShapeEditor/_renderers/PixiRenderer.d.ts +3 -1
- package/dist/components/ShapeEditor/_renderers/types.d.ts +3 -1
- package/dist/components/ShapeEditor/_state/useEngineLifecycle.d.ts +9 -2
- package/dist/components/ShapeEditor/index.d.ts +1 -0
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +1454 -1226
- package/dist/shape-editor.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/ShapeEditor/_model/imageFetch.d.ts +0 -9
package/dist/shape-editor.js
CHANGED
|
@@ -5,9 +5,10 @@ import { a as p, n as m, r as h, t as g } from "./Switch-rIEhz2pk.js";
|
|
|
5
5
|
import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
6
6
|
import { memo as b, useCallback as x, useEffect as S, useId as C, useImperativeHandle as w, useLayoutEffect as T, useMemo as E, useReducer as D, useRef as O, useState as k } from "react";
|
|
7
7
|
import A from "konva";
|
|
8
|
-
import
|
|
8
|
+
import "pixi.js/unsafe-eval";
|
|
9
|
+
import { Application as j, ColorMatrixFilter as M, Container as N, Graphics as P, Polygon as F, Rectangle as ee, Sprite as te, Texture as I } from "pixi.js";
|
|
9
10
|
//#region src/components/ShapeEditor/_model/geometry.ts
|
|
10
|
-
var
|
|
11
|
+
var L = {
|
|
11
12
|
POINT: "POINT",
|
|
12
13
|
RECTANGLE: "RECTANGLE",
|
|
13
14
|
ROTATED_RECTANGLE: "ROTATED_RECTANGLE",
|
|
@@ -15,22 +16,22 @@ var F = {
|
|
|
15
16
|
ELLIPSE: "ELLIPSE",
|
|
16
17
|
LINE: "LINE"
|
|
17
18
|
};
|
|
18
|
-
function
|
|
19
|
+
function ne(e) {
|
|
19
20
|
return e.interaction?.visible !== !1;
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
22
|
+
function re(e) {
|
|
23
|
+
return ne(e) && e.interaction?.hitTestDisabled !== !0;
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
25
|
+
function R(e) {
|
|
26
|
+
return re(e) && e.interaction?.selectable !== !1;
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
28
|
+
function ie(e) {
|
|
29
|
+
return R(e) && !e.readOnly && e.interaction?.editable !== !1;
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
return
|
|
31
|
+
function z(e) {
|
|
32
|
+
return ie(e) && e.interaction?.draggable !== !1;
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
+
function ae(e) {
|
|
34
35
|
return e.map((e, t) => ({
|
|
35
36
|
shape: e,
|
|
36
37
|
index: t
|
|
@@ -39,10 +40,10 @@ function R(e) {
|
|
|
39
40
|
return n === r ? e.index - t.index : n - r;
|
|
40
41
|
}).map((e) => e.shape);
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function oe() {
|
|
43
44
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `id_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
44
45
|
}
|
|
45
|
-
var
|
|
46
|
+
var B = [
|
|
46
47
|
"tl",
|
|
47
48
|
"t",
|
|
48
49
|
"tr",
|
|
@@ -52,7 +53,7 @@ var z = [
|
|
|
52
53
|
"bl",
|
|
53
54
|
"l"
|
|
54
55
|
];
|
|
55
|
-
function
|
|
56
|
+
function V(e) {
|
|
56
57
|
let t = e.map((e) => e.x), n = e.map((e) => e.y);
|
|
57
58
|
return {
|
|
58
59
|
minX: Math.min(...t),
|
|
@@ -61,33 +62,33 @@ function B(e) {
|
|
|
61
62
|
maxY: Math.max(...n)
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
|
-
function
|
|
65
|
+
function se(e, t) {
|
|
65
66
|
let n = (t.minX + t.maxX) / 2, r = (t.minY + t.maxY) / 2;
|
|
66
67
|
return {
|
|
67
68
|
x: e.includes("l") ? t.minX : e.includes("r") ? t.maxX : n,
|
|
68
69
|
y: e.includes("t") ? t.minY : e.includes("b") ? t.maxY : r
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
|
-
function
|
|
72
|
+
function H(e, t, n, r) {
|
|
72
73
|
let i = { ...t };
|
|
73
74
|
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
75
|
}
|
|
75
|
-
function
|
|
76
|
+
function ce(e, t) {
|
|
76
77
|
let n = t.x - e.x, r = t.y - e.y, i = Math.max(Math.abs(n), Math.abs(r));
|
|
77
78
|
return {
|
|
78
79
|
x: e.x + (n < 0 ? -i : i),
|
|
79
80
|
y: e.y + (r < 0 ? -i : i)
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function le(e, t, n) {
|
|
83
84
|
let r = Math.cos(n), i = Math.sin(n), a = e.x - t.x, o = e.y - t.y;
|
|
84
85
|
return {
|
|
85
86
|
x: t.x + a * r - o * i,
|
|
86
87
|
y: t.y + a * i + o * r
|
|
87
88
|
};
|
|
88
89
|
}
|
|
89
|
-
function
|
|
90
|
-
let t =
|
|
90
|
+
function ue(e) {
|
|
91
|
+
let t = V(e);
|
|
91
92
|
return [
|
|
92
93
|
{
|
|
93
94
|
x: t.minX,
|
|
@@ -107,7 +108,7 @@ function de(e) {
|
|
|
107
108
|
}
|
|
108
109
|
];
|
|
109
110
|
}
|
|
110
|
-
function
|
|
111
|
+
function de(e, t, n = 32) {
|
|
111
112
|
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
113
|
return Array.from({ length: n }, (e, t) => {
|
|
113
114
|
let s = t / n * 2 * Math.PI;
|
|
@@ -117,7 +118,7 @@ function fe(e, t, n = 32) {
|
|
|
117
118
|
};
|
|
118
119
|
});
|
|
119
120
|
}
|
|
120
|
-
function
|
|
121
|
+
function fe(e) {
|
|
121
122
|
let t = [...e].sort((e, t) => e.x - t.x || e.y - t.y);
|
|
122
123
|
if (t.length <= 2) return t;
|
|
123
124
|
let n = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), r = [];
|
|
@@ -133,10 +134,10 @@ function pe(e) {
|
|
|
133
134
|
}
|
|
134
135
|
return r.pop(), i.pop(), r.concat(i);
|
|
135
136
|
}
|
|
136
|
-
function
|
|
137
|
-
let t =
|
|
138
|
-
if (t.length < 3) return
|
|
139
|
-
let n = Infinity, r =
|
|
137
|
+
function pe(e) {
|
|
138
|
+
let t = fe(e);
|
|
139
|
+
if (t.length < 3) return ue(e);
|
|
140
|
+
let n = Infinity, r = ue(e);
|
|
140
141
|
for (let e = 0; e < t.length; e++) {
|
|
141
142
|
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
143
|
for (let e of t) {
|
|
@@ -160,19 +161,19 @@ function me(e) {
|
|
|
160
161
|
}
|
|
161
162
|
return r;
|
|
162
163
|
}
|
|
163
|
-
var
|
|
164
|
+
var me = (e, t) => ({
|
|
164
165
|
x: e.x - t.x,
|
|
165
166
|
y: e.y - t.y
|
|
166
|
-
}),
|
|
167
|
-
let t =
|
|
167
|
+
}), he = (e, t) => e.x * t.x + e.y * t.y, ge = (e) => Math.hypot(e.x, e.y), _e = (e) => {
|
|
168
|
+
let t = ge(e) || 1;
|
|
168
169
|
return {
|
|
169
170
|
x: e.x / t,
|
|
170
171
|
y: e.y / t
|
|
171
172
|
};
|
|
172
|
-
},
|
|
173
|
+
}, ve = (e, t) => ({
|
|
173
174
|
x: (e.x + t.x) / 2,
|
|
174
175
|
y: (e.y + t.y) / 2
|
|
175
|
-
}),
|
|
176
|
+
}), ye = (e) => {
|
|
176
177
|
let t = e.reduce((e, t) => ({
|
|
177
178
|
x: e.x + t.x,
|
|
178
179
|
y: e.y + t.y
|
|
@@ -185,26 +186,26 @@ var he = (e, t) => ({
|
|
|
185
186
|
y: t.y / e.length
|
|
186
187
|
};
|
|
187
188
|
};
|
|
188
|
-
function
|
|
189
|
+
function be(e) {
|
|
189
190
|
return [
|
|
190
191
|
e[0],
|
|
191
|
-
|
|
192
|
+
ve(e[0], e[1]),
|
|
192
193
|
e[1],
|
|
193
|
-
|
|
194
|
+
ve(e[1], e[2]),
|
|
194
195
|
e[2],
|
|
195
|
-
|
|
196
|
+
ve(e[2], e[3]),
|
|
196
197
|
e[3],
|
|
197
|
-
|
|
198
|
+
ve(e[3], e[0])
|
|
198
199
|
];
|
|
199
200
|
}
|
|
200
|
-
function
|
|
201
|
-
let n =
|
|
201
|
+
function xe(e, t) {
|
|
202
|
+
let n = ve(e[0], e[1]), r = _e(me(e[0], e[3]));
|
|
202
203
|
return {
|
|
203
204
|
x: n.x + r.x * t,
|
|
204
205
|
y: n.y + r.y * t
|
|
205
206
|
};
|
|
206
207
|
}
|
|
207
|
-
function
|
|
208
|
+
function Se(e, t, n, r) {
|
|
208
209
|
let i = (e, i) => ({
|
|
209
210
|
x: t.x + e * n.x + i * r.x,
|
|
210
211
|
y: t.y + e * n.y + i * r.y
|
|
@@ -216,37 +217,37 @@ function Ce(e, t, n, r) {
|
|
|
216
217
|
i(e.minX, e.maxY)
|
|
217
218
|
];
|
|
218
219
|
}
|
|
219
|
-
function
|
|
220
|
+
function Ce(e, t, n) {
|
|
220
221
|
if (e.length < 4) return e;
|
|
221
|
-
let r = e[0], i =
|
|
222
|
-
return
|
|
222
|
+
let r = e[0], i = _e(me(e[1], e[0])), a = _e(me(e[3], e[0])), o = he(me(e[1], r), i), s = he(me(e[3], r), a), c = me(n, r);
|
|
223
|
+
return Se(H(t, {
|
|
223
224
|
minX: 0,
|
|
224
225
|
minY: 0,
|
|
225
226
|
maxX: o,
|
|
226
227
|
maxY: s
|
|
227
|
-
},
|
|
228
|
+
}, he(c, i), he(c, a)), r, i, a);
|
|
228
229
|
}
|
|
229
|
-
function
|
|
230
|
+
function we(e, t, n) {
|
|
230
231
|
let r = t.maxX - t.minX || 1, i = t.maxY - t.minY || 1, a = n.maxX - n.minX, o = n.maxY - n.minY;
|
|
231
232
|
return e.map((e) => ({
|
|
232
233
|
x: n.minX + (e.x - t.minX) / r * a,
|
|
233
234
|
y: n.minY + (e.y - t.minY) / i * o
|
|
234
235
|
}));
|
|
235
236
|
}
|
|
236
|
-
function
|
|
237
|
+
function Te(e, t, n, r) {
|
|
237
238
|
let i = (e, t, n) => Math.sign((t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x)), a = i(e, t, n), o = i(e, t, r), s = i(n, r, e), c = i(n, r, t);
|
|
238
239
|
return a !== o && s !== c && !(a === 0 && o === 0);
|
|
239
240
|
}
|
|
240
|
-
function
|
|
241
|
+
function U(e, t = 256) {
|
|
241
242
|
let n = e.length;
|
|
242
243
|
if (n < 4 || n > t) return !1;
|
|
243
244
|
for (let t = 0; t < n; t++) {
|
|
244
245
|
let r = e[t], i = e[(t + 1) % n];
|
|
245
|
-
for (let a = t + 2; a < n; a++) if (!(t === 0 && a === n - 1) &&
|
|
246
|
+
for (let a = t + 2; a < n; a++) if (!(t === 0 && a === n - 1) && Te(r, i, e[a], e[(a + 1) % n])) return !0;
|
|
246
247
|
}
|
|
247
248
|
return !1;
|
|
248
249
|
}
|
|
249
|
-
function
|
|
250
|
+
function Ee(e, t, n, r) {
|
|
250
251
|
let i = t.x - e.x, a = t.y - e.y, o = r.x - n.x, s = r.y - n.y, c = i * s - a * o;
|
|
251
252
|
if (!c) return null;
|
|
252
253
|
let l = ((n.x - e.x) * s - (n.y - e.y) * o) / c, u = ((n.x - e.x) * a - (n.y - e.y) * i) / c, d = 1e-9;
|
|
@@ -255,15 +256,15 @@ function De(e, t, n, r) {
|
|
|
255
256
|
tj: u
|
|
256
257
|
};
|
|
257
258
|
}
|
|
258
|
-
function
|
|
259
|
+
function De(e, t = 256) {
|
|
259
260
|
let n = e.length;
|
|
260
|
-
if (n < 4 || n > t || !
|
|
261
|
+
if (n < 4 || n > t || !U(e, t)) return [e];
|
|
261
262
|
let r = Array.from({ length: n }, () => []), i = 0;
|
|
262
263
|
for (let t = 0; t < n; t++) {
|
|
263
264
|
let a = e[t], o = e[(t + 1) % n];
|
|
264
265
|
for (let s = t + 2; s < n; s++) {
|
|
265
266
|
if (t === 0 && s === n - 1) continue;
|
|
266
|
-
let c =
|
|
267
|
+
let c = Ee(a, o, e[s], e[(s + 1) % n]);
|
|
267
268
|
c && (r[t].push({
|
|
268
269
|
t: c.ti,
|
|
269
270
|
id: i
|
|
@@ -318,7 +319,7 @@ function Oe(e, t = 256) {
|
|
|
318
319
|
}
|
|
319
320
|
//#endregion
|
|
320
321
|
//#region src/components/ShapeEditor/_model/strings.ts
|
|
321
|
-
var
|
|
322
|
+
var W = {
|
|
322
323
|
contextMenu: {
|
|
323
324
|
copy: "복사",
|
|
324
325
|
paste: "붙여넣기",
|
|
@@ -359,29 +360,51 @@ var U = {
|
|
|
359
360
|
toggleMinimap: "미니맵 접기/펼치기"
|
|
360
361
|
},
|
|
361
362
|
imageLoading: "이미지를 불러오는 중…",
|
|
362
|
-
imageLoadError: "이미지를 불러올 수 없습니다"
|
|
363
|
+
imageLoadError: "이미지를 불러올 수 없습니다",
|
|
364
|
+
imageErrorHints: {
|
|
365
|
+
"mixed-content": "HTTPS 페이지에서 HTTP 이미지 요청은 혼합 콘텐츠 정책에 따라 차단됩니다. 이미지 스토리지의 HTTPS 전환이 필요합니다.",
|
|
366
|
+
cors: "이미지 스토리지 응답에 Access-Control-Allow-Origin 헤더가 없습니다. 스토리지 또는 프록시의 CORS 설정이 필요합니다.",
|
|
367
|
+
auth: "이미지 서버가 세션 인증(쿠키)을 요구합니다. 에디터의 이미지 요청은 자격 증명 없이 전송되므로 스토리지 인증 방식 검토가 필요합니다.",
|
|
368
|
+
forbidden: "이미지 접근이 거부되었습니다. 서명 URL(presigned) 만료 또는 접근 권한 설정 점검이 필요합니다.",
|
|
369
|
+
"not-found": "요청한 이미지가 서버에 존재하지 않습니다. 파일 삭제·이동 여부 확인이 필요합니다.",
|
|
370
|
+
"server-error": "이미지 서버가 내부 오류를 반환했습니다. 스토리지 서버 상태 점검이 필요합니다.",
|
|
371
|
+
http: "이미지 서버가 오류 상태 코드를 반환했습니다.",
|
|
372
|
+
offline: "네트워크 연결이 감지되지 않습니다. 클라이언트 네트워크 상태 확인이 필요합니다.",
|
|
373
|
+
network: "이미지 서버에 도달할 수 없습니다. 네트워크 경로·방화벽·DNS 구성 점검이 필요합니다.",
|
|
374
|
+
"unexpected-content": "이미지 대신 다른 형식의 응답이 수신되었습니다. 게이트웨이의 인증 리다이렉트 여부 확인이 필요합니다.",
|
|
375
|
+
decode: "전송은 정상이나 이미지 디코딩에 실패했습니다. 파일 손상 또는 미지원 형식일 수 있습니다.",
|
|
376
|
+
"csp-img": "콘텐츠 보안 정책(CSP)의 img-src 지시어가 이미지 표시를 차단하고 있습니다. 정책에 이미지 스토리지 출처 추가가 필요합니다.",
|
|
377
|
+
"csp-eval": "콘텐츠 보안 정책(CSP)이 동적 스크립트 실행(unsafe-eval)을 차단하여 렌더러 초기화에 실패했습니다.",
|
|
378
|
+
webgl: "WebGL 컨텍스트를 생성할 수 없습니다. 하드웨어 가속 설정 또는 브라우저 보안 정책(Edge 보안 강화 모드 등) 점검이 필요합니다.",
|
|
379
|
+
"renderer-init": "캔버스 렌더러 초기화 또는 렌더링 중 오류가 발생했습니다.",
|
|
380
|
+
unknown: "원인이 특정되지 않은 오류입니다. 아래 상세 정보와 함께 기술 지원에 문의하시기 바랍니다."
|
|
381
|
+
}
|
|
363
382
|
};
|
|
364
|
-
function
|
|
383
|
+
function Oe(e) {
|
|
365
384
|
return e ? {
|
|
366
385
|
contextMenu: {
|
|
367
|
-
...
|
|
386
|
+
...W.contextMenu,
|
|
368
387
|
...e.contextMenu
|
|
369
388
|
},
|
|
370
389
|
viewSettings: {
|
|
371
|
-
...
|
|
390
|
+
...W.viewSettings,
|
|
372
391
|
...e.viewSettings
|
|
373
392
|
},
|
|
374
393
|
minimap: {
|
|
375
|
-
...
|
|
394
|
+
...W.minimap,
|
|
376
395
|
...e.minimap
|
|
377
396
|
},
|
|
378
|
-
imageLoading: e.imageLoading ??
|
|
379
|
-
imageLoadError: e.imageLoadError ??
|
|
380
|
-
|
|
397
|
+
imageLoading: e.imageLoading ?? W.imageLoading,
|
|
398
|
+
imageLoadError: e.imageLoadError ?? W.imageLoadError,
|
|
399
|
+
imageErrorHints: {
|
|
400
|
+
...W.imageErrorHints,
|
|
401
|
+
...e.imageErrorHints
|
|
402
|
+
}
|
|
403
|
+
} : W;
|
|
381
404
|
}
|
|
382
405
|
//#endregion
|
|
383
406
|
//#region src/components/ShapeEditor/_model/tools.ts
|
|
384
|
-
var
|
|
407
|
+
var G = {
|
|
385
408
|
SELECT: "SELECT",
|
|
386
409
|
POLYGON: "POLYGON",
|
|
387
410
|
PATH: "PATH",
|
|
@@ -393,7 +416,7 @@ var W = {
|
|
|
393
416
|
ASSISTANT_POLYGON: "ASSISTANT_POLYGON",
|
|
394
417
|
ASSISTANT_RECT: "ASSISTANT_RECT",
|
|
395
418
|
ASSISTANT_POINT: "ASSISTANT_POINT"
|
|
396
|
-
},
|
|
419
|
+
}, ke = {
|
|
397
420
|
brightness: 1,
|
|
398
421
|
contrast: 1,
|
|
399
422
|
showCursorGuide: !1,
|
|
@@ -405,9 +428,9 @@ var W = {
|
|
|
405
428
|
keepZoomOnImageChange: !1,
|
|
406
429
|
wheelZoom: !0,
|
|
407
430
|
zoomSensitivity: 1
|
|
408
|
-
},
|
|
409
|
-
function
|
|
410
|
-
let t = e.positive ?
|
|
431
|
+
}, Ae = "var(--editor-overlay-inverse-scale, 1)", K = "#377be2", je = "#e23c3c";
|
|
432
|
+
function Me({ point: e }) {
|
|
433
|
+
let t = e.positive ? K : je;
|
|
411
434
|
return /* @__PURE__ */ v("div", {
|
|
412
435
|
style: {
|
|
413
436
|
position: "absolute",
|
|
@@ -428,13 +451,13 @@ function Ne({ point: e }) {
|
|
|
428
451
|
display: "flex",
|
|
429
452
|
alignItems: "center",
|
|
430
453
|
justifyContent: "center",
|
|
431
|
-
transform: `scale(${
|
|
454
|
+
transform: `scale(${Ae})`,
|
|
432
455
|
transformOrigin: "center"
|
|
433
456
|
},
|
|
434
457
|
children: e.positive ? "+" : "−"
|
|
435
458
|
});
|
|
436
459
|
}
|
|
437
|
-
function
|
|
460
|
+
function Ne({ image: e, points: t, boxes: n, status: r }) {
|
|
438
461
|
return /* @__PURE__ */ y("div", {
|
|
439
462
|
style: {
|
|
440
463
|
position: "absolute",
|
|
@@ -458,13 +481,13 @@ function Pe({ image: e, points: t, boxes: n, status: r }) {
|
|
|
458
481
|
backgroundSize: "200% 100%",
|
|
459
482
|
animation: "editorv2-assistant-shimmer 1.4s linear infinite"
|
|
460
483
|
} }, `box-${t}-${e.x}-${e.y}-${e.width}-${e.height}`)),
|
|
461
|
-
r === "loading" && t.map((e, t) => /* @__PURE__ */ v(
|
|
484
|
+
r === "loading" && t.map((e, t) => /* @__PURE__ */ v(Me, { point: e }, `pt-${t}-${e.x}-${e.y}`))
|
|
462
485
|
]
|
|
463
486
|
});
|
|
464
487
|
}
|
|
465
488
|
//#endregion
|
|
466
489
|
//#region src/components/ShapeEditor/_components/ContextMenu.tsx
|
|
467
|
-
function
|
|
490
|
+
function Pe(e) {
|
|
468
491
|
let t = [];
|
|
469
492
|
for (let n of e) if ("separator" in n) {
|
|
470
493
|
if (!t.length || "separator" in t[t.length - 1]) continue;
|
|
@@ -473,8 +496,8 @@ function Fe(e) {
|
|
|
473
496
|
for (; t.length && "separator" in t[t.length - 1];) t.pop();
|
|
474
497
|
return t;
|
|
475
498
|
}
|
|
476
|
-
function
|
|
477
|
-
let i =
|
|
499
|
+
function Fe({ x: e, y: t, items: n, onClose: r }) {
|
|
500
|
+
let i = Pe(n);
|
|
478
501
|
return /* @__PURE__ */ y(p, {
|
|
479
502
|
open: !0,
|
|
480
503
|
modal: !1,
|
|
@@ -525,7 +548,7 @@ function Ie({ x: e, y: t, items: n, onClose: r }) {
|
|
|
525
548
|
}
|
|
526
549
|
//#endregion
|
|
527
550
|
//#region src/components/ShapeEditor/_components/CursorGuide.tsx
|
|
528
|
-
function
|
|
551
|
+
function Ie({ color: e = "#1e88e5" }) {
|
|
529
552
|
let t = O(null), n = O(null), r = O(null);
|
|
530
553
|
return S(() => {
|
|
531
554
|
let e = t.current, i = n.current, a = r.current;
|
|
@@ -575,7 +598,8 @@ function Le({ color: e = "#1e88e5" }) {
|
|
|
575
598
|
}
|
|
576
599
|
//#endregion
|
|
577
600
|
//#region src/components/ShapeEditor/_components/ImageStateOverlay.tsx
|
|
578
|
-
function
|
|
601
|
+
function Le({ status: e, error: t, render: n, loadingLabel: r = W.imageLoading, errorLabel: i = W.imageLoadError, errorHints: a = W.imageErrorHints }) {
|
|
602
|
+
let o = n?.(e, t) ?? null;
|
|
579
603
|
return /* @__PURE__ */ v("div", {
|
|
580
604
|
"data-track-id": e === "loading" ? "editor-image-loading-wrap" : "editor-image-error-wrap",
|
|
581
605
|
style: {
|
|
@@ -590,7 +614,7 @@ function Re({ status: e, render: t, loadingLabel: n = U.imageLoading, errorLabel
|
|
|
590
614
|
fontFamily: "Pretendard, sans-serif",
|
|
591
615
|
pointerEvents: e === "error" ? "auto" : "none"
|
|
592
616
|
},
|
|
593
|
-
children:
|
|
617
|
+
children: o === null ? e === "loading" ? /* @__PURE__ */ y("div", {
|
|
594
618
|
style: {
|
|
595
619
|
display: "flex",
|
|
596
620
|
alignItems: "center",
|
|
@@ -606,29 +630,52 @@ function Re({ status: e, render: t, loadingLabel: n = U.imageLoading, errorLabel
|
|
|
606
630
|
borderTopColor: "#fff",
|
|
607
631
|
animation: "editorv2-image-spin 0.7s linear infinite"
|
|
608
632
|
} }),
|
|
609
|
-
|
|
633
|
+
r,
|
|
610
634
|
/* @__PURE__ */ v("style", { children: "@keyframes editorv2-image-spin{to{transform:rotate(360deg)}}" })
|
|
611
635
|
]
|
|
612
636
|
}) : /* @__PURE__ */ y("div", {
|
|
613
637
|
style: {
|
|
614
638
|
textAlign: "center",
|
|
615
|
-
opacity: .85
|
|
639
|
+
opacity: .85,
|
|
640
|
+
maxWidth: 420,
|
|
641
|
+
padding: "0 16px"
|
|
616
642
|
},
|
|
617
|
-
children: [
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
643
|
+
children: [
|
|
644
|
+
/* @__PURE__ */ v("div", {
|
|
645
|
+
style: {
|
|
646
|
+
fontSize: 28,
|
|
647
|
+
marginBottom: 6
|
|
648
|
+
},
|
|
649
|
+
children: "⚠"
|
|
650
|
+
}),
|
|
651
|
+
/* @__PURE__ */ v("div", {
|
|
652
|
+
style: { fontSize: 13 },
|
|
653
|
+
children: i
|
|
654
|
+
}),
|
|
655
|
+
t && /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("div", {
|
|
656
|
+
style: {
|
|
657
|
+
fontSize: 12,
|
|
658
|
+
marginTop: 8,
|
|
659
|
+
opacity: .8,
|
|
660
|
+
lineHeight: 1.5
|
|
661
|
+
},
|
|
662
|
+
children: a[t.kind]
|
|
663
|
+
}), /* @__PURE__ */ v("div", {
|
|
664
|
+
style: {
|
|
665
|
+
fontSize: 11,
|
|
666
|
+
marginTop: 6,
|
|
667
|
+
opacity: .55,
|
|
668
|
+
fontFamily: "ui-monospace, monospace",
|
|
669
|
+
wordBreak: "break-all"
|
|
670
|
+
},
|
|
671
|
+
children: t.detail
|
|
672
|
+
})] })
|
|
673
|
+
]
|
|
674
|
+
}) : o
|
|
628
675
|
});
|
|
629
676
|
}
|
|
630
677
|
Math.PI / 12;
|
|
631
|
-
var
|
|
678
|
+
var Re = "#00ff00", ze = "rgba(0, 255, 0, 0.1)", Be = "#669DEF", Ve = .1, He = [3, 3];
|
|
632
679
|
//#endregion
|
|
633
680
|
//#region src/components/ShapeEditor/_model/shapeRenderStyle.ts
|
|
634
681
|
function Ue(e, t = {}) {
|
|
@@ -660,11 +707,11 @@ var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
660
707
|
strokeWidth: a.strokeWidth,
|
|
661
708
|
strokeDasharray: a.dash?.join(" "),
|
|
662
709
|
opacity: a.opacity,
|
|
663
|
-
fill: a.fillVisible && r !==
|
|
710
|
+
fill: a.fillVisible && r !== L.LINE ? a.color : "none",
|
|
664
711
|
fillOpacity: a.fillAlpha,
|
|
665
712
|
vectorEffect: "non-scaling-stroke"
|
|
666
713
|
};
|
|
667
|
-
if (r ===
|
|
714
|
+
if (r === L.POINT) return /* @__PURE__ */ v("circle", {
|
|
668
715
|
ref: o,
|
|
669
716
|
cx: i[0].x,
|
|
670
717
|
cy: i[0].y,
|
|
@@ -672,9 +719,9 @@ var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
672
719
|
fill: a.color,
|
|
673
720
|
opacity: a.opacity
|
|
674
721
|
});
|
|
675
|
-
if (r ===
|
|
676
|
-
let e =
|
|
677
|
-
return r ===
|
|
722
|
+
if (r === L.RECTANGLE || r === L.ELLIPSE) {
|
|
723
|
+
let e = V(i);
|
|
724
|
+
return r === L.ELLIPSE ? /* @__PURE__ */ v("ellipse", {
|
|
678
725
|
cx: (e.minX + e.maxX) / 2,
|
|
679
726
|
cy: (e.minY + e.maxY) / 2,
|
|
680
727
|
rx: (e.maxX - e.minX) / 2,
|
|
@@ -689,7 +736,7 @@ var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
689
736
|
});
|
|
690
737
|
}
|
|
691
738
|
let c = i.map((e) => `${e.x},${e.y}`).join(" ");
|
|
692
|
-
return r ===
|
|
739
|
+
return r === L.LINE ? /* @__PURE__ */ v("polyline", {
|
|
693
740
|
points: c,
|
|
694
741
|
...s
|
|
695
742
|
}) : /* @__PURE__ */ v("polygon", {
|
|
@@ -753,7 +800,7 @@ function Ke({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth:
|
|
|
753
800
|
}
|
|
754
801
|
//#endregion
|
|
755
802
|
//#region src/components/ShapeEditor/_components/SettingsPanel.tsx
|
|
756
|
-
function qe({ value: i, defaults: o, onChange: s, onClose: c, labels: d =
|
|
803
|
+
function qe({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.viewSettings, openDown: f = !1, alignEnd: p = !1 }) {
|
|
757
804
|
return S(() => {
|
|
758
805
|
let e = (e) => {
|
|
759
806
|
e.key === "Escape" && c();
|
|
@@ -928,15 +975,15 @@ var Xe = {
|
|
|
928
975
|
"bottom-right": "aivex:bottom-2 aivex:right-2",
|
|
929
976
|
"top-left": "aivex:top-2 aivex:left-2",
|
|
930
977
|
"top-right": "aivex:top-2 aivex:right-2"
|
|
931
|
-
}, Ze = b(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r = !1, maskDataUrl: a, region: o, roiMaskId: l, shapes: p, view: m, viewDefaults: h, onChangeView: g, nav: _, registerShape: b, rectRef: x, zoomLabelRef: S, onZoom100: C, open: w, onToggleOpen: T, position: E = "bottom-left", showSettings: D = !0, settingsOpen: O, onToggleSettings: k, onCloseSettings: A, labels: j =
|
|
932
|
-
let { offX:
|
|
978
|
+
}, Ze = b(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r = !1, maskDataUrl: a, region: o, roiMaskId: l, shapes: p, view: m, viewDefaults: h, onChangeView: g, nav: _, registerShape: b, rectRef: x, zoomLabelRef: S, onZoom100: C, open: w, onToggleOpen: T, position: E = "bottom-left", showSettings: D = !0, settingsOpen: O, onToggleSettings: k, onCloseSettings: A, labels: j = W.minimap, settingsLabels: M }) {
|
|
979
|
+
let { offX: N, offY: P, dispW: F, dispH: ee, zoomCentered: te } = _, I = E.startsWith("top"), L = {
|
|
933
980
|
position: "absolute",
|
|
934
|
-
left:
|
|
935
|
-
top:
|
|
936
|
-
width:
|
|
937
|
-
height:
|
|
938
|
-
},
|
|
939
|
-
className: `aivex:overflow-hidden aivex:rounded-sm aivex:transition-all aivex:duration-200 aivex:ease-in-out ${w ? `${
|
|
981
|
+
left: N,
|
|
982
|
+
top: P,
|
|
983
|
+
width: F,
|
|
984
|
+
height: ee
|
|
985
|
+
}, re = /* @__PURE__ */ v("div", {
|
|
986
|
+
className: `aivex:overflow-hidden aivex:rounded-sm aivex:transition-all aivex:duration-200 aivex:ease-in-out ${w ? `${I ? "aivex:mt-md" : "aivex:mb-md"} aivex:opacity-100` : "aivex:opacity-0"}`,
|
|
940
987
|
style: { maxHeight: w ? 204 : 0 },
|
|
941
988
|
children: /* @__PURE__ */ v("div", {
|
|
942
989
|
style: {
|
|
@@ -961,15 +1008,16 @@ var Xe = {
|
|
|
961
1008
|
t && /* @__PURE__ */ v("img", {
|
|
962
1009
|
src: t,
|
|
963
1010
|
alt: "",
|
|
1011
|
+
crossOrigin: "anonymous",
|
|
964
1012
|
draggable: !1,
|
|
965
|
-
style:
|
|
1013
|
+
style: L
|
|
966
1014
|
}),
|
|
967
1015
|
a && m.showGuide && /* @__PURE__ */ v("img", {
|
|
968
1016
|
src: a,
|
|
969
1017
|
alt: "",
|
|
970
1018
|
draggable: !1,
|
|
971
1019
|
style: {
|
|
972
|
-
...
|
|
1020
|
+
...L,
|
|
973
1021
|
opacity: .55,
|
|
974
1022
|
imageRendering: "pixelated",
|
|
975
1023
|
pointerEvents: "none"
|
|
@@ -979,29 +1027,29 @@ var Xe = {
|
|
|
979
1027
|
image: e,
|
|
980
1028
|
region: o,
|
|
981
1029
|
maskId: l,
|
|
982
|
-
width:
|
|
983
|
-
height:
|
|
1030
|
+
width: F,
|
|
1031
|
+
height: ee,
|
|
984
1032
|
strokeWidth: 1,
|
|
985
1033
|
strokeDasharray: "4 4",
|
|
986
1034
|
style: {
|
|
987
1035
|
position: "absolute",
|
|
988
|
-
left:
|
|
989
|
-
top:
|
|
1036
|
+
left: N,
|
|
1037
|
+
top: P,
|
|
990
1038
|
pointerEvents: "none"
|
|
991
1039
|
}
|
|
992
1040
|
}),
|
|
993
1041
|
/* @__PURE__ */ v("svg", {
|
|
994
1042
|
viewBox: `0 0 ${e.w} ${e.h}`,
|
|
995
|
-
width:
|
|
996
|
-
height:
|
|
1043
|
+
width: F,
|
|
1044
|
+
height: ee,
|
|
997
1045
|
style: {
|
|
998
1046
|
position: "absolute",
|
|
999
|
-
left:
|
|
1000
|
-
top:
|
|
1047
|
+
left: N,
|
|
1048
|
+
top: P,
|
|
1001
1049
|
pointerEvents: "none"
|
|
1002
1050
|
},
|
|
1003
1051
|
"aria-hidden": !0,
|
|
1004
|
-
children:
|
|
1052
|
+
children: ae(p).filter(ne).map((e) => /* @__PURE__ */ v(Ge, {
|
|
1005
1053
|
shape: e,
|
|
1006
1054
|
strokeSize: m.strokeSize,
|
|
1007
1055
|
register: b
|
|
@@ -1011,7 +1059,7 @@ var Xe = {
|
|
|
1011
1059
|
ref: x,
|
|
1012
1060
|
style: {
|
|
1013
1061
|
position: "absolute",
|
|
1014
|
-
border: `1px solid ${
|
|
1062
|
+
border: `1px solid ${Re}`,
|
|
1015
1063
|
background: ze,
|
|
1016
1064
|
boxSizing: "border-box",
|
|
1017
1065
|
pointerEvents: "none"
|
|
@@ -1020,14 +1068,14 @@ var Xe = {
|
|
|
1020
1068
|
]
|
|
1021
1069
|
})
|
|
1022
1070
|
})
|
|
1023
|
-
}),
|
|
1071
|
+
}), R = /* @__PURE__ */ y("div", {
|
|
1024
1072
|
className: "aivex:relative aivex:flex aivex:items-center aivex:gap-xs",
|
|
1025
1073
|
children: [
|
|
1026
1074
|
/* @__PURE__ */ v(u, {
|
|
1027
1075
|
variant: "ghost",
|
|
1028
1076
|
size: "icon-md",
|
|
1029
1077
|
"aria-label": j.zoomOut,
|
|
1030
|
-
onClick: () =>
|
|
1078
|
+
onClick: () => te(1 / 1.2),
|
|
1031
1079
|
disabled: r,
|
|
1032
1080
|
children: /* @__PURE__ */ v(f, { size: 20 })
|
|
1033
1081
|
}),
|
|
@@ -1047,7 +1095,7 @@ var Xe = {
|
|
|
1047
1095
|
variant: "ghost",
|
|
1048
1096
|
size: "icon-md",
|
|
1049
1097
|
"aria-label": j.zoomIn,
|
|
1050
|
-
onClick: () =>
|
|
1098
|
+
onClick: () => te(1.2),
|
|
1051
1099
|
disabled: r,
|
|
1052
1100
|
children: /* @__PURE__ */ v(i, { size: 20 })
|
|
1053
1101
|
}),
|
|
@@ -1066,8 +1114,8 @@ var Xe = {
|
|
|
1066
1114
|
defaults: h,
|
|
1067
1115
|
onChange: g,
|
|
1068
1116
|
onClose: A,
|
|
1069
|
-
labels:
|
|
1070
|
-
openDown:
|
|
1117
|
+
labels: M,
|
|
1118
|
+
openDown: I,
|
|
1071
1119
|
alignEnd: E.endsWith("right")
|
|
1072
1120
|
})]
|
|
1073
1121
|
}),
|
|
@@ -1079,14 +1127,14 @@ var Xe = {
|
|
|
1079
1127
|
onClick: T,
|
|
1080
1128
|
children: w ? /* @__PURE__ */ v(c, {
|
|
1081
1129
|
size: 20,
|
|
1082
|
-
className:
|
|
1130
|
+
className: I ? "aivex:rotate-180" : void 0
|
|
1083
1131
|
}) : /* @__PURE__ */ v(s, { size: 20 })
|
|
1084
1132
|
})
|
|
1085
1133
|
]
|
|
1086
1134
|
});
|
|
1087
1135
|
return /* @__PURE__ */ y("div", {
|
|
1088
1136
|
className: `aivex:absolute ${Xe[E]} aivex:w-[220px] aivex:rounded-[12px] aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:p-md aivex:shadow-[0_4px_12px_rgba(13,13,18,0.24)]`,
|
|
1089
|
-
children: [
|
|
1137
|
+
children: [I ? R : re, I ? re : R]
|
|
1090
1138
|
});
|
|
1091
1139
|
}), Qe = "var(--editor-overlay-inverse-scale, 1)", $e = 6, et = {
|
|
1092
1140
|
fontFamily: "Pretendard, sans-serif",
|
|
@@ -1098,7 +1146,7 @@ var Xe = {
|
|
|
1098
1146
|
whiteSpace: "nowrap"
|
|
1099
1147
|
};
|
|
1100
1148
|
function tt(e) {
|
|
1101
|
-
let t =
|
|
1149
|
+
let t = V(e);
|
|
1102
1150
|
return {
|
|
1103
1151
|
x: t.minX,
|
|
1104
1152
|
y: t.minY,
|
|
@@ -1138,7 +1186,7 @@ function ot({ color: e, striped: t }) {
|
|
|
1138
1186
|
}
|
|
1139
1187
|
function st({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
|
|
1140
1188
|
return /* @__PURE__ */ v(_, { children: e.map((e) => {
|
|
1141
|
-
let a = tt(e.points), o = e.type ===
|
|
1189
|
+
let a = tt(e.points), o = e.type === L.POINT, s = o ? void 0 : t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.style?.dashed || !!e.style?.dash, u = it(e, e.points), d = r ? r(u) : at(u);
|
|
1142
1190
|
return /* @__PURE__ */ y("div", {
|
|
1143
1191
|
ref: (t) => i(e.id, t),
|
|
1144
1192
|
style: {
|
|
@@ -1183,8 +1231,8 @@ function st({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1183
1231
|
}
|
|
1184
1232
|
//#endregion
|
|
1185
1233
|
//#region src/components/ShapeEditor/_model/clipboard.ts
|
|
1186
|
-
var
|
|
1187
|
-
function
|
|
1234
|
+
var ct = "AIVEX_SHAPE_EDITOR:", lt = 1, ut = new Set(Object.values(L)), q = null, dt = "unavailable", ft = 0;
|
|
1235
|
+
function J(e) {
|
|
1188
1236
|
if (!e || typeof e != "object") return !1;
|
|
1189
1237
|
let t = e;
|
|
1190
1238
|
return Number.isFinite(t.x) && Number.isFinite(t.y);
|
|
@@ -1192,12 +1240,12 @@ function ft(e) {
|
|
|
1192
1240
|
function pt(e) {
|
|
1193
1241
|
if (!e || typeof e != "object") return !1;
|
|
1194
1242
|
let t = e;
|
|
1195
|
-
return typeof t.type == "string" &&
|
|
1243
|
+
return typeof t.type == "string" && ut.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(J);
|
|
1196
1244
|
}
|
|
1197
1245
|
function mt(e, t, n) {
|
|
1198
1246
|
return {
|
|
1199
1247
|
kind: "aivex-shape-editor",
|
|
1200
|
-
version:
|
|
1248
|
+
version: lt,
|
|
1201
1249
|
scope: n,
|
|
1202
1250
|
documentId: t,
|
|
1203
1251
|
shapes: e
|
|
@@ -1209,53 +1257,53 @@ function ht(e) {
|
|
|
1209
1257
|
return `fnv1a:${(t >>> 0).toString(36)}`;
|
|
1210
1258
|
}
|
|
1211
1259
|
function gt(e) {
|
|
1212
|
-
return `${
|
|
1260
|
+
return `${ct}${JSON.stringify(e)}`;
|
|
1213
1261
|
}
|
|
1214
|
-
function
|
|
1215
|
-
if (!e.startsWith(
|
|
1262
|
+
function _t(e) {
|
|
1263
|
+
if (!e.startsWith(ct)) return null;
|
|
1216
1264
|
try {
|
|
1217
1265
|
let t = JSON.parse(e.slice(19));
|
|
1218
|
-
return t.kind !== "aivex-shape-editor" || t.version !==
|
|
1266
|
+
return t.kind !== "aivex-shape-editor" || t.version !== lt || !Array.isArray(t.shapes) || t.shapes.length === 0 || !t.shapes.every(pt) || t.scope !== void 0 && typeof t.scope != "string" || t.documentId !== void 0 && typeof t.documentId != "string" ? null : t;
|
|
1219
1267
|
} catch {
|
|
1220
1268
|
return null;
|
|
1221
1269
|
}
|
|
1222
1270
|
}
|
|
1223
|
-
function
|
|
1224
|
-
|
|
1225
|
-
let t = ++
|
|
1271
|
+
function vt(e) {
|
|
1272
|
+
q = e;
|
|
1273
|
+
let t = ++ft;
|
|
1226
1274
|
if (typeof navigator > "u" || !navigator.clipboard?.writeText) {
|
|
1227
|
-
|
|
1275
|
+
dt = "unavailable";
|
|
1228
1276
|
return;
|
|
1229
1277
|
}
|
|
1230
1278
|
let n;
|
|
1231
1279
|
try {
|
|
1232
1280
|
n = gt(e);
|
|
1233
1281
|
} catch {
|
|
1234
|
-
|
|
1282
|
+
dt = "unavailable";
|
|
1235
1283
|
return;
|
|
1236
1284
|
}
|
|
1237
|
-
|
|
1238
|
-
t ===
|
|
1285
|
+
dt = "pending", navigator.clipboard.writeText(n).then(() => {
|
|
1286
|
+
t === ft && (dt = "written");
|
|
1239
1287
|
}, () => {
|
|
1240
|
-
t ===
|
|
1288
|
+
t === ft && (dt = "unavailable");
|
|
1241
1289
|
});
|
|
1242
1290
|
}
|
|
1243
|
-
function
|
|
1291
|
+
function yt(e, t) {
|
|
1244
1292
|
return !!e && e.scope === t;
|
|
1245
1293
|
}
|
|
1246
|
-
function
|
|
1247
|
-
return
|
|
1294
|
+
function Y(e) {
|
|
1295
|
+
return yt(q, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
|
|
1248
1296
|
}
|
|
1249
|
-
async function
|
|
1250
|
-
let t =
|
|
1251
|
-
if (t &&
|
|
1297
|
+
async function bt(e) {
|
|
1298
|
+
let t = yt(q, e) ? q : null;
|
|
1299
|
+
if (t && dt !== "written") return t;
|
|
1252
1300
|
if (typeof navigator < "u" && navigator.clipboard?.readText) try {
|
|
1253
|
-
let t =
|
|
1254
|
-
return t?.scope === e ? (
|
|
1301
|
+
let t = _t(await navigator.clipboard.readText());
|
|
1302
|
+
return t?.scope === e ? (q = t, t) : null;
|
|
1255
1303
|
} catch {}
|
|
1256
1304
|
return t;
|
|
1257
1305
|
}
|
|
1258
|
-
function
|
|
1306
|
+
function xt(e, t, n) {
|
|
1259
1307
|
return {
|
|
1260
1308
|
offset: n * (t ? e : e + 1),
|
|
1261
1309
|
nextPasteCount: e + 1
|
|
@@ -1263,17 +1311,17 @@ function bt(e, t, n) {
|
|
|
1263
1311
|
}
|
|
1264
1312
|
//#endregion
|
|
1265
1313
|
//#region src/components/ShapeEditor/_model/cursors.ts
|
|
1266
|
-
var
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1314
|
+
var X = new Set([
|
|
1315
|
+
G.RECTANGLE,
|
|
1316
|
+
G.ROTATED_RECTANGLE,
|
|
1317
|
+
G.CIRCLE,
|
|
1318
|
+
G.POLYGON,
|
|
1319
|
+
G.PATH,
|
|
1320
|
+
G.BRUSH,
|
|
1321
|
+
G.POINT,
|
|
1322
|
+
G.ASSISTANT_POLYGON,
|
|
1323
|
+
G.ASSISTANT_RECT,
|
|
1324
|
+
G.ASSISTANT_POINT
|
|
1277
1325
|
]), St = {
|
|
1278
1326
|
tl: -135,
|
|
1279
1327
|
t: -90,
|
|
@@ -1294,10 +1342,10 @@ function wt(e, t = 0) {
|
|
|
1294
1342
|
return Ct[Math.round(n / 45) % 4];
|
|
1295
1343
|
}
|
|
1296
1344
|
function Tt({ tool: e, externalToolCursor: t, isSpacePressed: n, isPolygonDrawing: r }) {
|
|
1297
|
-
return n ? "grab" : t || (e ===
|
|
1345
|
+
return n ? "grab" : t || (e === G.SELECT ? "default" : X.has(e) ? r ? "default" : "crosshair" : "default");
|
|
1298
1346
|
}
|
|
1299
1347
|
function Et({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
|
|
1300
|
-
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e ===
|
|
1348
|
+
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === G.SELECT && i ? i : Tt({
|
|
1301
1349
|
tool: e,
|
|
1302
1350
|
externalToolCursor: t,
|
|
1303
1351
|
isSpacePressed: n,
|
|
@@ -1454,22 +1502,22 @@ function Lt(e) {
|
|
|
1454
1502
|
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]]);
|
|
1455
1503
|
return t;
|
|
1456
1504
|
}
|
|
1457
|
-
var
|
|
1505
|
+
var Rt = {
|
|
1458
1506
|
color: "#000000",
|
|
1459
1507
|
opacity: .5
|
|
1460
|
-
},
|
|
1508
|
+
}, zt = {
|
|
1461
1509
|
color: "#ffffff",
|
|
1462
1510
|
opacity: 1,
|
|
1463
1511
|
width: 2,
|
|
1464
1512
|
dash: [6, 6],
|
|
1465
1513
|
underlayColor: "#000000"
|
|
1466
|
-
},
|
|
1514
|
+
}, Bt = {
|
|
1467
1515
|
color: "#dc2626",
|
|
1468
1516
|
opacity: .8,
|
|
1469
1517
|
width: 2,
|
|
1470
1518
|
dash: [6, 6],
|
|
1471
1519
|
underlayColor: "#000000"
|
|
1472
|
-
},
|
|
1520
|
+
}, Vt = (e, t, n) => {
|
|
1473
1521
|
let r = e.occludedAreas?.filter((e) => e.points.length >= 3) ?? [];
|
|
1474
1522
|
if (!t || !n || !e.visibleAreas.length && !r.length) return null;
|
|
1475
1523
|
let i = e.visibleAreas, a = i.length ? i : [{
|
|
@@ -1478,7 +1526,7 @@ var Z = {
|
|
|
1478
1526
|
w: t,
|
|
1479
1527
|
h: n
|
|
1480
1528
|
}], o = Ft(a), s = {
|
|
1481
|
-
...
|
|
1529
|
+
...Rt,
|
|
1482
1530
|
...e.dim
|
|
1483
1531
|
}, c = e.outline;
|
|
1484
1532
|
if (c === !1) return {
|
|
@@ -1492,11 +1540,11 @@ var Z = {
|
|
|
1492
1540
|
};
|
|
1493
1541
|
let l = {
|
|
1494
1542
|
visible: {
|
|
1495
|
-
...
|
|
1543
|
+
...zt,
|
|
1496
1544
|
...c?.visibleStyle
|
|
1497
1545
|
},
|
|
1498
1546
|
occluded: {
|
|
1499
|
-
...
|
|
1547
|
+
...Bt,
|
|
1500
1548
|
...c?.occludedStyle
|
|
1501
1549
|
}
|
|
1502
1550
|
}, u = i.map(jt), d = a.map(jt), f = r.map((e) => e.points);
|
|
@@ -1517,7 +1565,7 @@ var Z = {
|
|
|
1517
1565
|
occludedOutline: [],
|
|
1518
1566
|
outlineStyles: l
|
|
1519
1567
|
};
|
|
1520
|
-
},
|
|
1568
|
+
}, Z = .3, Ht = .05;
|
|
1521
1569
|
function Ut(e) {
|
|
1522
1570
|
return 1 - (1 - e) ** 3;
|
|
1523
1571
|
}
|
|
@@ -1531,7 +1579,7 @@ function Wt(e) {
|
|
|
1531
1579
|
}
|
|
1532
1580
|
function Gt(e, t) {
|
|
1533
1581
|
if (!t.length) return null;
|
|
1534
|
-
if (e ===
|
|
1582
|
+
if (e === L.POINT) {
|
|
1535
1583
|
let e = t[0];
|
|
1536
1584
|
return {
|
|
1537
1585
|
x: e.x - 8,
|
|
@@ -1540,7 +1588,7 @@ function Gt(e, t) {
|
|
|
1540
1588
|
height: 16
|
|
1541
1589
|
};
|
|
1542
1590
|
}
|
|
1543
|
-
let n =
|
|
1591
|
+
let n = V(t), r = Math.max(1, n.maxX - n.minX), i = Math.max(1, n.maxY - n.minY);
|
|
1544
1592
|
return {
|
|
1545
1593
|
x: n.minX,
|
|
1546
1594
|
y: n.minY,
|
|
@@ -1551,7 +1599,7 @@ function Gt(e, t) {
|
|
|
1551
1599
|
function Kt(e) {
|
|
1552
1600
|
if (!e.length) return null;
|
|
1553
1601
|
let t = e.map((e) => Gt(e.type, e.points)).filter((e) => e !== null);
|
|
1554
|
-
return t.length ? Wt(
|
|
1602
|
+
return t.length ? Wt(V(t.flatMap((e) => [{
|
|
1555
1603
|
x: e.x,
|
|
1556
1604
|
y: e.y
|
|
1557
1605
|
}, {
|
|
@@ -1560,7 +1608,7 @@ function Kt(e) {
|
|
|
1560
1608
|
}]))) : null;
|
|
1561
1609
|
}
|
|
1562
1610
|
function qt(e, t, n, r = {}) {
|
|
1563
|
-
let { containerRatio: i =
|
|
1611
|
+
let { containerRatio: i = Z, minScale: a = Ht, maxScale: o = 20 } = r;
|
|
1564
1612
|
if (!t || !n || e.width <= 0 || e.height <= 0) return null;
|
|
1565
1613
|
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;
|
|
1566
1614
|
return {
|
|
@@ -1592,10 +1640,10 @@ function Yt(e, t, n, r = 300) {
|
|
|
1592
1640
|
//#endregion
|
|
1593
1641
|
//#region src/components/ShapeEditor/_state/createInteractionController.ts
|
|
1594
1642
|
function Xt(e) {
|
|
1595
|
-
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, editingIdRef: g, drawSessionRef: _, assistantRef: v, setCursorHint: y, setInteractionMode: b, syncMinimap: x, onTransformPreview: S, onDrawPreview: C } = e, w = () => _.current, T = () => v.current, E = null, D = null, O = null, k = null, A = null, j = null,
|
|
1643
|
+
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, editingIdRef: g, drawSessionRef: _, assistantRef: v, setCursorHint: y, setInteractionMode: b, syncMinimap: x, onTransformPreview: S, onDrawPreview: C } = e, w = () => _.current, T = () => v.current, E = null, D = null, O = null, k = null, A = null, j = null, M = "", N = null, P = null, F = (e) => e === G.RECTANGLE || e === G.ROTATED_RECTANGLE || e === G.CIRCLE, ee = (e) => e === G.ASSISTANT_POLYGON || e === G.ASSISTANT_RECT, te = (e) => e === G.POLYGON, I = (e, t) => {
|
|
1596
1644
|
let n = !1;
|
|
1597
|
-
D && !
|
|
1598
|
-
},
|
|
1645
|
+
D && !F(t) && !ee(t) && (D = null, e.clearPreview(), C(null), n = !0), (O === "path" && t !== G.PATH || O === "scalar" && t !== G.BRUSH) && (O = null, n = !0), k && !te(t) && (k = null, n = !0), A && t !== G.SELECT && (A = null, j = null, e.clearMarquee(), n = !0), N && t !== G.POINT && (N = null, n = !0), n && b("idle");
|
|
1646
|
+
}, ne = () => r.current.get(n.current), re = (e, t, n, r) => ({
|
|
1599
1647
|
point: t,
|
|
1600
1648
|
targetId: r,
|
|
1601
1649
|
event: n,
|
|
@@ -1609,41 +1657,41 @@ function Xt(e) {
|
|
|
1609
1657
|
let p = t.current;
|
|
1610
1658
|
if (!p) return;
|
|
1611
1659
|
let _ = n.current;
|
|
1612
|
-
if (
|
|
1660
|
+
if (N = null, I(p, _), u.button === 1 || i.current) {
|
|
1613
1661
|
b("panning"), y(null), E = {
|
|
1614
1662
|
px: u.global.x,
|
|
1615
1663
|
py: u.global.y
|
|
1616
1664
|
};
|
|
1617
1665
|
return;
|
|
1618
1666
|
}
|
|
1619
|
-
if (u.button === 2 && !(_ ===
|
|
1667
|
+
if (u.button === 2 && !(_ === G.ASSISTANT_POINT && u.altKey)) {
|
|
1620
1668
|
if (r && !s.current.includes(r)) {
|
|
1621
1669
|
let e = o.current.getShapes().find((e) => e.id === r);
|
|
1622
|
-
e &&
|
|
1670
|
+
e && R(e) && m.current([r]);
|
|
1623
1671
|
}
|
|
1624
1672
|
return;
|
|
1625
1673
|
}
|
|
1626
|
-
let v =
|
|
1674
|
+
let v = ne();
|
|
1627
1675
|
if (v) {
|
|
1628
|
-
w().reset(), m.current([]), v.onPointerDown?.(
|
|
1676
|
+
w().reset(), m.current([]), v.onPointerDown?.(re(p, e, u, r));
|
|
1629
1677
|
return;
|
|
1630
1678
|
}
|
|
1631
1679
|
if (d.current) {
|
|
1632
1680
|
f();
|
|
1633
1681
|
return;
|
|
1634
1682
|
}
|
|
1635
|
-
if (_ ===
|
|
1683
|
+
if (_ === G.ASSISTANT_POINT) {
|
|
1636
1684
|
u.altKey ? T().addPoint(e, u.button !== 2) : T().newPolygon(e);
|
|
1637
1685
|
return;
|
|
1638
1686
|
}
|
|
1639
|
-
if (
|
|
1687
|
+
if (ee(_) && c.current) {
|
|
1640
1688
|
D = e, b("drawing");
|
|
1641
1689
|
return;
|
|
1642
1690
|
}
|
|
1643
|
-
if (_ ===
|
|
1644
|
-
let t =
|
|
1645
|
-
if (!
|
|
1646
|
-
let n =
|
|
1691
|
+
if (_ === G.SELECT && u.altKey) {
|
|
1692
|
+
let t = ae(o.current.getShapes()).filter((t) => {
|
|
1693
|
+
if (!R(t)) return !1;
|
|
1694
|
+
let n = V(t.points);
|
|
1647
1695
|
return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
|
|
1648
1696
|
});
|
|
1649
1697
|
if (t.length) {
|
|
@@ -1652,15 +1700,15 @@ function Xt(e) {
|
|
|
1652
1700
|
return;
|
|
1653
1701
|
}
|
|
1654
1702
|
}
|
|
1655
|
-
if (r && _ ===
|
|
1703
|
+
if (r && _ === G.SELECT) {
|
|
1656
1704
|
let t = o.current.getShapes().find((e) => e.id === r);
|
|
1657
|
-
if (!t || !
|
|
1658
|
-
let n = typeof performance < "u" ? performance.now() : 0, i = !!
|
|
1659
|
-
|
|
1705
|
+
if (!t || !R(t)) return;
|
|
1706
|
+
let n = typeof performance < "u" ? performance.now() : 0, i = !!P && P.id === r && n - P.t < 300;
|
|
1707
|
+
P = {
|
|
1660
1708
|
id: r,
|
|
1661
1709
|
t: n
|
|
1662
1710
|
};
|
|
1663
|
-
let c = (t.type ===
|
|
1711
|
+
let c = (t.type === L.POLYGON || t.type === L.LINE) && !l.current && t.interaction?.editable !== !1 && !t.readOnly;
|
|
1664
1712
|
if (i && c) {
|
|
1665
1713
|
m.current([r]), h.current(r);
|
|
1666
1714
|
return;
|
|
@@ -1670,14 +1718,14 @@ function Xt(e) {
|
|
|
1670
1718
|
let e = new Set(u);
|
|
1671
1719
|
e.has(r) ? e.delete(r) : e.add(r), u = [...e];
|
|
1672
1720
|
} else u.includes(r) || (u = [r]);
|
|
1673
|
-
m.current(u), !l.current &&
|
|
1721
|
+
m.current(u), !l.current && z(t) && p.beginMove(e, u);
|
|
1674
1722
|
return;
|
|
1675
1723
|
}
|
|
1676
|
-
if (
|
|
1724
|
+
if (F(_) && c.current) {
|
|
1677
1725
|
D = e, b("drawing");
|
|
1678
1726
|
return;
|
|
1679
1727
|
}
|
|
1680
|
-
if (
|
|
1728
|
+
if (te(_) && c.current) {
|
|
1681
1729
|
if (!w().getDraftPointsSnapshot().length && s.current.length && m.current([]), w().tryClosePolygon(e, 12 / p.viewport.scale)) return;
|
|
1682
1730
|
let t = w().hitDraftPoint(e);
|
|
1683
1731
|
if (t >= 0) {
|
|
@@ -1698,40 +1746,40 @@ function Xt(e) {
|
|
|
1698
1746
|
w().appendPolygonPoint(e);
|
|
1699
1747
|
return;
|
|
1700
1748
|
}
|
|
1701
|
-
if (_ ===
|
|
1749
|
+
if (_ === G.PATH && c.current) {
|
|
1702
1750
|
s.current.length && m.current([]), O = "path", b("drawing"), w().beginStroke(e);
|
|
1703
1751
|
return;
|
|
1704
1752
|
}
|
|
1705
|
-
if (_ ===
|
|
1753
|
+
if (_ === G.BRUSH && c.current && !l.current) {
|
|
1706
1754
|
O = "scalar", b("drawing"), w().beginStroke(e);
|
|
1707
1755
|
return;
|
|
1708
1756
|
}
|
|
1709
|
-
if (_ ===
|
|
1710
|
-
|
|
1757
|
+
if (_ === G.POINT && c.current && u.button === 0) {
|
|
1758
|
+
N = {
|
|
1711
1759
|
pointerId: u.pointerId,
|
|
1712
1760
|
global: u.global,
|
|
1713
1761
|
cancelled: !1
|
|
1714
1762
|
};
|
|
1715
1763
|
return;
|
|
1716
1764
|
}
|
|
1717
|
-
if (_ ===
|
|
1765
|
+
if (_ === G.SELECT) {
|
|
1718
1766
|
if (j = g.current ? a.current ? p.getVertexSelection() : [] : null, !a.current && !l.current && s.current.length >= 2) {
|
|
1719
|
-
let t = o.current.getShapes().filter((e) => s.current.includes(e.id) &&
|
|
1767
|
+
let t = o.current.getShapes().filter((e) => s.current.includes(e.id) && z(e));
|
|
1720
1768
|
if (t.length) {
|
|
1721
|
-
let n =
|
|
1769
|
+
let n = V(t.flatMap((e) => e.points));
|
|
1722
1770
|
if (e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY) {
|
|
1723
1771
|
p.beginMove(e, s.current);
|
|
1724
1772
|
return;
|
|
1725
1773
|
}
|
|
1726
1774
|
}
|
|
1727
1775
|
}
|
|
1728
|
-
A = e,
|
|
1776
|
+
A = e, M = "", b("marquee"), y(null);
|
|
1729
1777
|
}
|
|
1730
1778
|
},
|
|
1731
1779
|
onPointerMove: (e, r) => {
|
|
1732
1780
|
let i = t.current;
|
|
1733
1781
|
if (!i) return;
|
|
1734
|
-
if (
|
|
1782
|
+
if (N && N.pointerId === r.pointerId && Math.hypot(r.global.x - N.global.x, r.global.y - N.global.y) > 4 && (N.cancelled = !0), E) {
|
|
1735
1783
|
i.applyViewport({
|
|
1736
1784
|
scale: i.viewport.scale,
|
|
1737
1785
|
x: i.viewport.x + (r.global.x - E.px),
|
|
@@ -1740,10 +1788,10 @@ function Xt(e) {
|
|
|
1740
1788
|
return;
|
|
1741
1789
|
}
|
|
1742
1790
|
let s = n.current;
|
|
1743
|
-
|
|
1744
|
-
let l =
|
|
1791
|
+
I(i, s);
|
|
1792
|
+
let l = ne();
|
|
1745
1793
|
if (l) {
|
|
1746
|
-
l.onPointerMove?.(
|
|
1794
|
+
l.onPointerMove?.(re(i, e, r));
|
|
1747
1795
|
return;
|
|
1748
1796
|
}
|
|
1749
1797
|
if (k) {
|
|
@@ -1751,13 +1799,13 @@ function Xt(e) {
|
|
|
1751
1799
|
k.moved = k.moved || Math.hypot(t, n) > .5, w().moveDraftPoints(k.base, k.indices, t, n);
|
|
1752
1800
|
return;
|
|
1753
1801
|
}
|
|
1754
|
-
if (D && (
|
|
1755
|
-
let t = a.current ?
|
|
1756
|
-
i.previewBox(s ===
|
|
1802
|
+
if (D && (F(s) || ee(s))) {
|
|
1803
|
+
let t = a.current ? ce(D, e) : e;
|
|
1804
|
+
i.previewBox(s === G.CIRCLE ? "ellipse" : "rect", D, t, {
|
|
1757
1805
|
...c.current,
|
|
1758
1806
|
color: c.current?.color ?? "#00e5ff"
|
|
1759
|
-
}),
|
|
1760
|
-
type: s ===
|
|
1807
|
+
}), F(s) && C({
|
|
1808
|
+
type: s === G.CIRCLE ? L.ELLIPSE : L.RECTANGLE,
|
|
1761
1809
|
points: [D, t]
|
|
1762
1810
|
});
|
|
1763
1811
|
return;
|
|
@@ -1766,7 +1814,7 @@ function Xt(e) {
|
|
|
1766
1814
|
w().appendStrokePoint(e, 2 / i.viewport.scale);
|
|
1767
1815
|
return;
|
|
1768
1816
|
}
|
|
1769
|
-
if (
|
|
1817
|
+
if (te(s) && w().hasDraftPoints()) {
|
|
1770
1818
|
w().setDraftCursor(e);
|
|
1771
1819
|
return;
|
|
1772
1820
|
}
|
|
@@ -1780,34 +1828,34 @@ function Xt(e) {
|
|
|
1780
1828
|
};
|
|
1781
1829
|
if (i.previewMarquee(A, e), j) {
|
|
1782
1830
|
let e = (o.current.getShapes().find((e) => e.id === g.current)?.points ?? []).flatMap((e, n) => e.x >= t.minX && e.x <= t.maxX && e.y >= t.minY && e.y <= t.maxY ? [n] : []), n = [...new Set([...j, ...e])].sort((e, t) => e - t), r = n.join(",");
|
|
1783
|
-
r !==
|
|
1831
|
+
r !== M && (M = r, i.setVertexSelection(n));
|
|
1784
1832
|
return;
|
|
1785
1833
|
}
|
|
1786
1834
|
let n = i.shapesIntersecting(t), r = n.join(",");
|
|
1787
|
-
r !==
|
|
1835
|
+
r !== M && (M = r, m.current(n));
|
|
1788
1836
|
}
|
|
1789
1837
|
},
|
|
1790
1838
|
onPointerUp: (e, r) => {
|
|
1791
1839
|
let i = t.current;
|
|
1792
1840
|
if (!i) return;
|
|
1793
|
-
let o =
|
|
1794
|
-
if (
|
|
1841
|
+
let o = N;
|
|
1842
|
+
if (N = null, E) {
|
|
1795
1843
|
E = null, b("idle");
|
|
1796
1844
|
return;
|
|
1797
1845
|
}
|
|
1798
1846
|
let l = n.current;
|
|
1799
|
-
if (
|
|
1847
|
+
if (I(i, l), k) {
|
|
1800
1848
|
w().commitDraftPointDrag(k.moved), k = null, b("idle");
|
|
1801
1849
|
return;
|
|
1802
1850
|
}
|
|
1803
|
-
let u =
|
|
1851
|
+
let u = ne();
|
|
1804
1852
|
if (u) {
|
|
1805
|
-
u.onPointerUp?.(
|
|
1853
|
+
u.onPointerUp?.(re(i, e, r));
|
|
1806
1854
|
return;
|
|
1807
1855
|
}
|
|
1808
1856
|
let d = o ? Math.hypot(r.global.x - o.global.x, r.global.y - o.global.y) : Infinity;
|
|
1809
|
-
if (l ===
|
|
1810
|
-
p.current(
|
|
1857
|
+
if (l === G.POINT && c.current && o && !o.cancelled && o.pointerId === r.pointerId && r.insideCanvas && d <= 4) {
|
|
1858
|
+
p.current(L.POINT, [e]);
|
|
1811
1859
|
return;
|
|
1812
1860
|
}
|
|
1813
1861
|
if (O) {
|
|
@@ -1815,7 +1863,7 @@ function Xt(e) {
|
|
|
1815
1863
|
O = null, b("idle"), e === "path" ? w().completeFreehandStroke() : w().finishScalarStroke();
|
|
1816
1864
|
return;
|
|
1817
1865
|
}
|
|
1818
|
-
if (D &&
|
|
1866
|
+
if (D && ee(l)) {
|
|
1819
1867
|
let t = D;
|
|
1820
1868
|
D = null, b("idle"), i.clearPreview();
|
|
1821
1869
|
let n = {
|
|
@@ -1824,12 +1872,12 @@ function Xt(e) {
|
|
|
1824
1872
|
width: Math.abs(e.x - t.x),
|
|
1825
1873
|
height: Math.abs(e.y - t.y)
|
|
1826
1874
|
};
|
|
1827
|
-
n.width > 2 && n.height > 2 && T().beginBox(n, l ===
|
|
1875
|
+
n.width > 2 && n.height > 2 && T().beginBox(n, l === G.ASSISTANT_RECT ? "rect" : "polygon");
|
|
1828
1876
|
return;
|
|
1829
1877
|
}
|
|
1830
|
-
if (D &&
|
|
1831
|
-
let t = a.current ?
|
|
1832
|
-
D = null, b("idle"), i.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (l ===
|
|
1878
|
+
if (D && F(l)) {
|
|
1879
|
+
let t = a.current ? ce(D, e) : e, n = D;
|
|
1880
|
+
D = null, b("idle"), i.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (l === G.ROTATED_RECTANGLE ? p.current(L.ROTATED_RECTANGLE, ue([n, t])) : l === G.CIRCLE ? p.current(L.POLYGON, de(n, t)) : p.current(L.RECTANGLE, [n, t]));
|
|
1833
1881
|
return;
|
|
1834
1882
|
}
|
|
1835
1883
|
if (A) {
|
|
@@ -1863,17 +1911,17 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1863
1911
|
let a = i.current?.rectResult === "rotatedRect";
|
|
1864
1912
|
return e.map((e) => {
|
|
1865
1913
|
if (t === "rect" && a) return {
|
|
1866
|
-
id:
|
|
1867
|
-
type:
|
|
1868
|
-
points:
|
|
1914
|
+
id: oe(),
|
|
1915
|
+
type: L.ROTATED_RECTANGLE,
|
|
1916
|
+
points: pe(e),
|
|
1869
1917
|
style: r,
|
|
1870
1918
|
meta: n
|
|
1871
1919
|
};
|
|
1872
1920
|
if (t === "rect") {
|
|
1873
|
-
let t =
|
|
1921
|
+
let t = V(e);
|
|
1874
1922
|
return {
|
|
1875
|
-
id:
|
|
1876
|
-
type:
|
|
1923
|
+
id: oe(),
|
|
1924
|
+
type: L.RECTANGLE,
|
|
1877
1925
|
points: [{
|
|
1878
1926
|
x: t.minX,
|
|
1879
1927
|
y: t.minY
|
|
@@ -1886,8 +1934,8 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1886
1934
|
};
|
|
1887
1935
|
}
|
|
1888
1936
|
return {
|
|
1889
|
-
id:
|
|
1890
|
-
type:
|
|
1937
|
+
id: oe(),
|
|
1938
|
+
type: L.POLYGON,
|
|
1891
1939
|
points: e,
|
|
1892
1940
|
style: r,
|
|
1893
1941
|
meta: n
|
|
@@ -2140,13 +2188,13 @@ function un(e, t) {
|
|
|
2140
2188
|
}
|
|
2141
2189
|
function dn(e) {
|
|
2142
2190
|
switch (e.type) {
|
|
2143
|
-
case
|
|
2144
|
-
case
|
|
2145
|
-
case
|
|
2146
|
-
case
|
|
2147
|
-
case
|
|
2191
|
+
case L.RECTANGLE: return e.points.length < 2 ? null : ue(e.points);
|
|
2192
|
+
case L.POLYGON:
|
|
2193
|
+
case L.ROTATED_RECTANGLE:
|
|
2194
|
+
case L.ELLIPSE: return e.points.length >= 3 ? e.points : null;
|
|
2195
|
+
case L.POINT: {
|
|
2148
2196
|
let t = e.points[0];
|
|
2149
|
-
return t ?
|
|
2197
|
+
return t ? de({
|
|
2150
2198
|
x: t.x - 6,
|
|
2151
2199
|
y: t.y - 6
|
|
2152
2200
|
}, {
|
|
@@ -2164,7 +2212,7 @@ function pn(e, t, n = []) {
|
|
|
2164
2212
|
if (t <= 0 || !e.length && !n.length) return null;
|
|
2165
2213
|
let r = un(e, n);
|
|
2166
2214
|
if (!r.length) return null;
|
|
2167
|
-
let i = t + 4, a =
|
|
2215
|
+
let i = t + 4, a = V(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1, en / Math.max(o, s, 1));
|
|
2168
2216
|
o = Math.max(1, Math.ceil(o * c)), s = Math.max(1, Math.ceil(s * c));
|
|
2169
2217
|
let l = a.minX - i, u = a.minY - i, d = (e) => ({
|
|
2170
2218
|
x: (e.x - l) * c,
|
|
@@ -2256,21 +2304,21 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2256
2304
|
h.current = s;
|
|
2257
2305
|
let g = O(f);
|
|
2258
2306
|
g.current = f;
|
|
2259
|
-
let _ = O(null), v = O([]), y = O(null), b = O(/* @__PURE__ */ new Set()), S = O([[]]), C = O(0), w = O(null), T = O([]), E = O([]), D = O([]), k = O([[]]), A = O(0), j = O("draw"),
|
|
2307
|
+
let _ = O(null), v = O([]), y = O(null), b = O(/* @__PURE__ */ new Set()), S = O([[]]), C = O(0), w = O(null), T = O([]), E = O([]), D = O([]), k = O([[]]), A = O(0), j = O("draw"), M = () => j.current === "erase" ? "erase" : "add", N = () => D.current.length > 0 || T.current.length > 0 || e.current === G.BRUSH && v.current.length > 0, P = () => {
|
|
2260
2308
|
let t = e.current;
|
|
2261
|
-
return t ===
|
|
2262
|
-
},
|
|
2309
|
+
return t === G.BRUSH && N() ? "brush" : t === G.POLYGON && v.current.length > 0 ? "polygon" : t === G.PATH && v.current.length > 0 ? "path" : "none";
|
|
2310
|
+
}, F = () => v.current.length > 0 || A.current > 0, ee = () => v.current.length === 0 && A.current < k.current.length - 1, te = () => C.current > 0, I = () => C.current < S.current.length - 1, ne = () => {
|
|
2263
2311
|
let t = e.current;
|
|
2264
|
-
return t ===
|
|
2265
|
-
},
|
|
2312
|
+
return t === G.BRUSH ? F() : t === G.POLYGON || t === G.PATH ? te() : !1;
|
|
2313
|
+
}, re = () => {
|
|
2266
2314
|
let t = e.current;
|
|
2267
|
-
return t ===
|
|
2268
|
-
},
|
|
2269
|
-
let e =
|
|
2315
|
+
return t === G.BRUSH ? ee() : t === G.POLYGON || t === G.PATH ? I() : !1;
|
|
2316
|
+
}, R = () => P() !== "none", z = x(() => {
|
|
2317
|
+
let e = P(), t = {
|
|
2270
2318
|
active: e !== "none",
|
|
2271
2319
|
kind: e,
|
|
2272
|
-
canUndo:
|
|
2273
|
-
canRedo:
|
|
2320
|
+
canUndo: ne(),
|
|
2321
|
+
canRedo: re(),
|
|
2274
2322
|
brush: e === "brush" ? {
|
|
2275
2323
|
mode: j.current,
|
|
2276
2324
|
editing: D.current.length > 0,
|
|
@@ -2278,17 +2326,17 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2278
2326
|
} : void 0
|
|
2279
2327
|
}, n = _.current;
|
|
2280
2328
|
n && xn(n, t) || (_.current = t, p.current?.(t));
|
|
2281
|
-
}, []),
|
|
2329
|
+
}, []), ae = x(() => {
|
|
2282
2330
|
k.current = [[]], A.current = 0;
|
|
2283
|
-
}, []),
|
|
2331
|
+
}, []), B = x(() => {
|
|
2284
2332
|
let t = c.current;
|
|
2285
2333
|
if (!t) return;
|
|
2286
2334
|
let n = e.current;
|
|
2287
|
-
if (n ===
|
|
2335
|
+
if (n === G.BRUSH) {
|
|
2288
2336
|
let e = [...T.current];
|
|
2289
2337
|
if (v.current.length && e.push({
|
|
2290
2338
|
points: v.current,
|
|
2291
|
-
mode:
|
|
2339
|
+
mode: M()
|
|
2292
2340
|
}), !e.length && !E.current.length) {
|
|
2293
2341
|
t.clearPreview();
|
|
2294
2342
|
return;
|
|
@@ -2310,11 +2358,11 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2310
2358
|
let o = {
|
|
2311
2359
|
...i.current,
|
|
2312
2360
|
color: i.current?.color ?? "#00e5ff"
|
|
2313
|
-
}, s = Array.from(b.current), l = n !==
|
|
2314
|
-
if (t.previewPoly(r, y.current, o, !1, s, l), n ===
|
|
2361
|
+
}, s = Array.from(b.current), l = n !== G.PATH;
|
|
2362
|
+
if (t.previewPoly(r, y.current, o, !1, s, l), n === G.POLYGON || n === G.PATH) {
|
|
2315
2363
|
let e = m.current;
|
|
2316
2364
|
e && r !== w.current && (w.current = r, e({
|
|
2317
|
-
type:
|
|
2365
|
+
type: L.POLYGON,
|
|
2318
2366
|
points: vn(r),
|
|
2319
2367
|
meta: h.current
|
|
2320
2368
|
}));
|
|
@@ -2324,96 +2372,96 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2324
2372
|
i,
|
|
2325
2373
|
c,
|
|
2326
2374
|
e
|
|
2327
|
-
]),
|
|
2375
|
+
]), V = x((e) => {
|
|
2328
2376
|
let t = gn(e), n = k.current, r = A.current, i = n[r];
|
|
2329
|
-
i && _n(i, t) || (k.current = [...n.slice(0, r + 1), t], A.current += 1,
|
|
2330
|
-
}, [
|
|
2377
|
+
i && _n(i, t) || (k.current = [...n.slice(0, r + 1), t], A.current += 1, z());
|
|
2378
|
+
}, [z]), se = x((e) => {
|
|
2331
2379
|
let t = S.current, n = C.current, r = t[n];
|
|
2332
2380
|
r && yn(r, e) || (S.current = [...t.slice(0, n + 1), vn(e)], C.current += 1);
|
|
2333
|
-
}, []),
|
|
2334
|
-
v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), S.current = [[]], C.current = 0, w.current = null,
|
|
2381
|
+
}, []), H = x(() => {
|
|
2382
|
+
v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), S.current = [[]], C.current = 0, w.current = null, ae(), c.current?.clearPreview(), m.current?.(null), z();
|
|
2335
2383
|
}, [
|
|
2336
2384
|
c,
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
]),
|
|
2340
|
-
v.current = e, b.current = new Set(Array.from(b.current).filter((t) => t >= 0 && t < e.length)), t &&
|
|
2385
|
+
z,
|
|
2386
|
+
ae
|
|
2387
|
+
]), ce = x((e, t) => {
|
|
2388
|
+
v.current = e, b.current = new Set(Array.from(b.current).filter((t) => t >= 0 && t < e.length)), t && se(e), B(), z();
|
|
2341
2389
|
}, [
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
]),
|
|
2346
|
-
if (e.current !==
|
|
2390
|
+
z,
|
|
2391
|
+
se,
|
|
2392
|
+
B
|
|
2393
|
+
]), le = x(() => vn(v.current), []), ue = x(() => v.current.length > 0, []), de = x((t, n) => {
|
|
2394
|
+
if (e.current !== G.POLYGON) return !1;
|
|
2347
2395
|
let r = v.current;
|
|
2348
2396
|
if (r.length < 3) return !1;
|
|
2349
2397
|
let i = r[0];
|
|
2350
|
-
return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (g.current(
|
|
2351
|
-
}, [
|
|
2398
|
+
return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (g.current(L.POLYGON, r), H(), !0);
|
|
2399
|
+
}, [H, e]), fe = x((e) => {
|
|
2352
2400
|
let t = v.current;
|
|
2353
|
-
return e < 0 || e >= t.length ? !1 : (
|
|
2354
|
-
}, [
|
|
2401
|
+
return e < 0 || e >= t.length ? !1 : (ce(t.filter((t, n) => n !== e), !0), !0);
|
|
2402
|
+
}, [ce]), pe = x((e, t) => {
|
|
2355
2403
|
let n = v.current;
|
|
2356
2404
|
if (e < 0 || e >= n.length) return null;
|
|
2357
2405
|
let r = new Set(b.current);
|
|
2358
|
-
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), b.current = r, y.current = null,
|
|
2406
|
+
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), b.current = r, y.current = null, B(), z(), {
|
|
2359
2407
|
base: vn(n),
|
|
2360
2408
|
indices: Array.from(r)
|
|
2361
2409
|
};
|
|
2362
|
-
}, [
|
|
2363
|
-
b.current = /* @__PURE__ */ new Set(), y.current = e,
|
|
2364
|
-
}, [
|
|
2365
|
-
y.current = null, b.current = /* @__PURE__ */ new Set(), v.current = [{ ...e }],
|
|
2366
|
-
}, [
|
|
2410
|
+
}, [z, B]), me = x((e) => {
|
|
2411
|
+
b.current = /* @__PURE__ */ new Set(), y.current = e, ce([...v.current, e], !0);
|
|
2412
|
+
}, [ce]), he = x((e) => {
|
|
2413
|
+
y.current = null, b.current = /* @__PURE__ */ new Set(), v.current = [{ ...e }], B(), z();
|
|
2414
|
+
}, [z, B]), ge = x((e, t) => {
|
|
2367
2415
|
let n = v.current[v.current.length - 1];
|
|
2368
|
-
return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (v.current = [...v.current, { ...e }], y.current = null,
|
|
2369
|
-
}, [
|
|
2416
|
+
return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (v.current = [...v.current, { ...e }], y.current = null, B(), z(), !0);
|
|
2417
|
+
}, [z, B]), _e = x((e, t, n, r) => {
|
|
2370
2418
|
let i = new Set(t);
|
|
2371
2419
|
v.current = e.map((e, t) => i.has(t) ? {
|
|
2372
2420
|
x: e.x + n,
|
|
2373
2421
|
y: e.y + r
|
|
2374
|
-
} : { ...e }), y.current = null,
|
|
2375
|
-
}, [
|
|
2376
|
-
e && (
|
|
2422
|
+
} : { ...e }), y.current = null, B(), z();
|
|
2423
|
+
}, [z, B]), ve = x((e) => {
|
|
2424
|
+
e && (se(v.current), B(), z());
|
|
2377
2425
|
}, [
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
]),
|
|
2382
|
-
y.current = e ? { ...e } : null,
|
|
2383
|
-
}, [
|
|
2426
|
+
z,
|
|
2427
|
+
se,
|
|
2428
|
+
B
|
|
2429
|
+
]), ye = x((e) => {
|
|
2430
|
+
y.current = e ? { ...e } : null, B();
|
|
2431
|
+
}, [B]), be = x(() => v.current.length > 0 ? (v.current = [], B(), z(), !0) : A.current <= 0 ? !1 : (--A.current, T.current = gn(k.current[A.current]), B(), z(), !0), [z, B]), xe = x(() => v.current.length > 0 || A.current >= k.current.length - 1 ? !1 : (A.current += 1, T.current = gn(k.current[A.current]), B(), z(), !0), [z, B]), Se = x(() => C.current <= 0 ? !1 : (--C.current, v.current = vn(S.current[C.current]), b.current = /* @__PURE__ */ new Set(), B(), z(), !0), [z, B]), Ce = x(() => C.current >= S.current.length - 1 ? !1 : (C.current += 1, v.current = vn(S.current[C.current]), b.current = /* @__PURE__ */ new Set(), B(), z(), !0), [z, B]), we = x(() => {
|
|
2384
2432
|
let t = e.current;
|
|
2385
|
-
return t ===
|
|
2433
|
+
return t === G.BRUSH ? be() : t === G.POLYGON || t === G.PATH ? Se() : !1;
|
|
2386
2434
|
}, [
|
|
2387
2435
|
e,
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
]),
|
|
2436
|
+
be,
|
|
2437
|
+
Se
|
|
2438
|
+
]), Te = x(() => {
|
|
2391
2439
|
let t = e.current;
|
|
2392
|
-
return t ===
|
|
2440
|
+
return t === G.BRUSH ? xe() : t === G.POLYGON || t === G.PATH ? Ce() : !1;
|
|
2393
2441
|
}, [
|
|
2394
|
-
|
|
2395
|
-
|
|
2442
|
+
xe,
|
|
2443
|
+
Ce,
|
|
2396
2444
|
e
|
|
2397
|
-
]),
|
|
2445
|
+
]), U = x(() => {
|
|
2398
2446
|
let e = t.current;
|
|
2399
2447
|
if (!e.length) return D.current.length > 0;
|
|
2400
|
-
let r = n.current.getShapes().filter((t) => e.includes(t.id) &&
|
|
2448
|
+
let r = n.current.getShapes().filter((t) => e.includes(t.id) && ie(t)), i = fn(r);
|
|
2401
2449
|
return i.length ? (D.current = r.map((e) => e.id), E.current = i, !0) : (D.current = [], E.current = [], !1);
|
|
2402
|
-
}, [n, t]),
|
|
2450
|
+
}, [n, t]), Ee = x(() => {
|
|
2403
2451
|
if (r.current) return !1;
|
|
2404
2452
|
let e = [...T.current];
|
|
2405
2453
|
v.current.length && e.push({
|
|
2406
2454
|
points: vn(v.current),
|
|
2407
|
-
mode:
|
|
2455
|
+
mode: M()
|
|
2408
2456
|
});
|
|
2409
2457
|
let t = E.current, c = [...D.current];
|
|
2410
2458
|
if (!e.length && !t.length) return !1;
|
|
2411
2459
|
let l = pn(e, a.current, t);
|
|
2412
|
-
if (!l) return
|
|
2460
|
+
if (!l) return H(), !1;
|
|
2413
2461
|
let u = mn(l, o.current);
|
|
2414
2462
|
if (c.length) {
|
|
2415
2463
|
let e = n.current.getShapes().filter((e) => c.includes(e.id));
|
|
2416
|
-
if (!u.length) return n.current.remove(c),
|
|
2464
|
+
if (!u.length) return n.current.remove(c), H(), d([]), !0;
|
|
2417
2465
|
u.sort((e, t) => nn(t) - nn(e));
|
|
2418
2466
|
let t = [], r = [], i = [];
|
|
2419
2467
|
for (let n = 0; n < u.length; n++) {
|
|
@@ -2422,33 +2470,33 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2422
2470
|
let r = e[n];
|
|
2423
2471
|
t.push({
|
|
2424
2472
|
...r,
|
|
2425
|
-
type:
|
|
2473
|
+
type: L.POLYGON,
|
|
2426
2474
|
points: a
|
|
2427
2475
|
}), i.push(r.id);
|
|
2428
2476
|
} else {
|
|
2429
|
-
let t = e[0], n =
|
|
2477
|
+
let t = e[0], n = oe();
|
|
2430
2478
|
r.push({
|
|
2431
2479
|
...t,
|
|
2432
2480
|
id: n,
|
|
2433
|
-
type:
|
|
2481
|
+
type: L.POLYGON,
|
|
2434
2482
|
points: a
|
|
2435
2483
|
}), i.push(n);
|
|
2436
2484
|
}
|
|
2437
2485
|
}
|
|
2438
2486
|
let a = e.slice(u.length).map((e) => e.id);
|
|
2439
|
-
return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a),
|
|
2487
|
+
return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a), H(), d(i), !0;
|
|
2440
2488
|
}
|
|
2441
|
-
if (!u.length) return
|
|
2489
|
+
if (!u.length) return H(), !1;
|
|
2442
2490
|
let f = i.current;
|
|
2443
2491
|
if (!f) return !1;
|
|
2444
2492
|
let p = u.map((e) => ({
|
|
2445
|
-
id:
|
|
2446
|
-
type:
|
|
2493
|
+
id: oe(),
|
|
2494
|
+
type: L.POLYGON,
|
|
2447
2495
|
points: e,
|
|
2448
2496
|
style: f,
|
|
2449
2497
|
meta: s
|
|
2450
2498
|
}));
|
|
2451
|
-
return n.current.create(p), d(p.map((e) => e.id)),
|
|
2499
|
+
return n.current.create(p), d(p.map((e) => e.id)), H(), !0;
|
|
2452
2500
|
}, [
|
|
2453
2501
|
a,
|
|
2454
2502
|
d,
|
|
@@ -2456,43 +2504,43 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2456
2504
|
s,
|
|
2457
2505
|
i,
|
|
2458
2506
|
r,
|
|
2459
|
-
|
|
2460
|
-
]),
|
|
2507
|
+
H
|
|
2508
|
+
]), De = x(() => {
|
|
2461
2509
|
let t = e.current;
|
|
2462
|
-
if (t ===
|
|
2510
|
+
if (t === G.BRUSH) return Ee();
|
|
2463
2511
|
let n = v.current;
|
|
2464
|
-
return t ===
|
|
2512
|
+
return t === G.POLYGON && n.length >= 3 ? (g.current(L.POLYGON, n), H(), !0) : !1;
|
|
2465
2513
|
}, [
|
|
2466
|
-
|
|
2467
|
-
|
|
2514
|
+
Ee,
|
|
2515
|
+
H,
|
|
2468
2516
|
e
|
|
2469
|
-
]),
|
|
2517
|
+
]), W = x(() => {
|
|
2470
2518
|
let t = v.current;
|
|
2471
|
-
if (e.current ===
|
|
2519
|
+
if (e.current === G.PATH && t.length >= 3) {
|
|
2472
2520
|
let e = $t(t, o.current);
|
|
2473
|
-
e.length >= 3 && g.current(
|
|
2521
|
+
e.length >= 3 && g.current(L.POLYGON, e);
|
|
2474
2522
|
}
|
|
2475
|
-
|
|
2476
|
-
}, [
|
|
2477
|
-
j.current = e,
|
|
2478
|
-
}, [
|
|
2479
|
-
if (r.current || e.current !==
|
|
2480
|
-
T.current = [], v.current = [],
|
|
2481
|
-
let t =
|
|
2482
|
-
return
|
|
2523
|
+
H();
|
|
2524
|
+
}, [H, e]), Oe = x((e) => {
|
|
2525
|
+
j.current = e, z(), B();
|
|
2526
|
+
}, [z, B]), ke = x(() => {
|
|
2527
|
+
if (r.current || e.current !== G.BRUSH) return !1;
|
|
2528
|
+
T.current = [], v.current = [], ae();
|
|
2529
|
+
let t = U();
|
|
2530
|
+
return z(), B(), t;
|
|
2483
2531
|
}, [
|
|
2484
|
-
L,
|
|
2485
|
-
r,
|
|
2486
2532
|
z,
|
|
2487
|
-
|
|
2488
|
-
|
|
2533
|
+
r,
|
|
2534
|
+
B,
|
|
2535
|
+
ae,
|
|
2536
|
+
U,
|
|
2489
2537
|
e
|
|
2490
|
-
]),
|
|
2538
|
+
]), Ae = x(() => {
|
|
2491
2539
|
let e = b.current;
|
|
2492
2540
|
if (!e.size) return !1;
|
|
2493
2541
|
let t = v.current.filter((t, n) => !e.has(n));
|
|
2494
|
-
return b.current = /* @__PURE__ */ new Set(),
|
|
2495
|
-
}, [
|
|
2542
|
+
return b.current = /* @__PURE__ */ new Set(), ce(t, !0), !0;
|
|
2543
|
+
}, [ce]), K = x((e) => {
|
|
2496
2544
|
let t = c.current, n = v.current;
|
|
2497
2545
|
if (!t || !n.length) return -1;
|
|
2498
2546
|
let r = bn / (t.viewport.scale || 1);
|
|
@@ -2501,77 +2549,77 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2501
2549
|
if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
|
|
2502
2550
|
}
|
|
2503
2551
|
return -1;
|
|
2504
|
-
}, [c]),
|
|
2552
|
+
}, [c]), je = x(() => {
|
|
2505
2553
|
v.current.length >= 1 && (T.current.push({
|
|
2506
2554
|
points: vn(v.current),
|
|
2507
|
-
mode:
|
|
2508
|
-
}), v.current = [],
|
|
2555
|
+
mode: M()
|
|
2556
|
+
}), v.current = [], V(T.current)), B(), z();
|
|
2509
2557
|
}, [
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2558
|
+
z,
|
|
2559
|
+
V,
|
|
2560
|
+
B
|
|
2513
2561
|
]);
|
|
2514
2562
|
return {
|
|
2515
|
-
reset:
|
|
2516
|
-
undoSession:
|
|
2517
|
-
redoSession:
|
|
2518
|
-
canUndoSession:
|
|
2519
|
-
canRedoSession:
|
|
2520
|
-
hasDraftSession:
|
|
2521
|
-
hasDraftPoints:
|
|
2522
|
-
commitDraftSession:
|
|
2523
|
-
completeFreehandStroke:
|
|
2524
|
-
setBrushScalarMode:
|
|
2563
|
+
reset: H,
|
|
2564
|
+
undoSession: we,
|
|
2565
|
+
redoSession: Te,
|
|
2566
|
+
canUndoSession: ne,
|
|
2567
|
+
canRedoSession: re,
|
|
2568
|
+
hasDraftSession: R,
|
|
2569
|
+
hasDraftPoints: ue,
|
|
2570
|
+
commitDraftSession: De,
|
|
2571
|
+
completeFreehandStroke: W,
|
|
2572
|
+
setBrushScalarMode: Oe,
|
|
2525
2573
|
getBrushScalarMode: () => j.current,
|
|
2526
|
-
hasBrushSession:
|
|
2527
|
-
commitBrush:
|
|
2574
|
+
hasBrushSession: N,
|
|
2575
|
+
commitBrush: Ee,
|
|
2528
2576
|
cancelBrush: x(() => {
|
|
2529
|
-
e.current ===
|
|
2530
|
-
}, [
|
|
2531
|
-
beginBrushEditFromSelection:
|
|
2532
|
-
deleteDraftSelectedPoints:
|
|
2533
|
-
hitDraftPoint:
|
|
2534
|
-
getDraftPointsSnapshot:
|
|
2535
|
-
tryClosePolygon:
|
|
2536
|
-
removeDraftPoint:
|
|
2537
|
-
selectDraftPointForDrag:
|
|
2538
|
-
appendPolygonPoint:
|
|
2539
|
-
beginStroke:
|
|
2540
|
-
appendStrokePoint:
|
|
2541
|
-
moveDraftPoints:
|
|
2542
|
-
commitDraftPointDrag:
|
|
2543
|
-
setDraftCursor:
|
|
2544
|
-
finishScalarStroke:
|
|
2577
|
+
e.current === G.BRUSH && H();
|
|
2578
|
+
}, [H, e]),
|
|
2579
|
+
beginBrushEditFromSelection: ke,
|
|
2580
|
+
deleteDraftSelectedPoints: Ae,
|
|
2581
|
+
hitDraftPoint: K,
|
|
2582
|
+
getDraftPointsSnapshot: le,
|
|
2583
|
+
tryClosePolygon: de,
|
|
2584
|
+
removeDraftPoint: fe,
|
|
2585
|
+
selectDraftPointForDrag: pe,
|
|
2586
|
+
appendPolygonPoint: me,
|
|
2587
|
+
beginStroke: he,
|
|
2588
|
+
appendStrokePoint: ge,
|
|
2589
|
+
moveDraftPoints: _e,
|
|
2590
|
+
commitDraftPointDrag: ve,
|
|
2591
|
+
setDraftCursor: ye,
|
|
2592
|
+
finishScalarStroke: je,
|
|
2545
2593
|
handleToolChange: x((e, t) => {
|
|
2546
2594
|
if (t) {
|
|
2547
|
-
|
|
2595
|
+
H(), j.current = "draw";
|
|
2548
2596
|
return;
|
|
2549
2597
|
}
|
|
2550
|
-
if (e !==
|
|
2551
|
-
|
|
2598
|
+
if (e !== G.BRUSH) {
|
|
2599
|
+
H(), j.current = "draw";
|
|
2552
2600
|
return;
|
|
2553
2601
|
}
|
|
2554
|
-
j.current = "draw", T.current = [], v.current = [],
|
|
2602
|
+
j.current = "draw", T.current = [], v.current = [], ae(), U(), z(), B();
|
|
2555
2603
|
}, [
|
|
2556
|
-
L,
|
|
2557
2604
|
z,
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2605
|
+
B,
|
|
2606
|
+
H,
|
|
2607
|
+
ae,
|
|
2608
|
+
U
|
|
2561
2609
|
]),
|
|
2562
2610
|
handleBrushSelectionChange: x((t, n) => {
|
|
2563
|
-
if (!(e.current !==
|
|
2611
|
+
if (!(e.current !== G.BRUSH || n)) {
|
|
2564
2612
|
if (!t.length) {
|
|
2565
|
-
|
|
2613
|
+
z();
|
|
2566
2614
|
return;
|
|
2567
2615
|
}
|
|
2568
|
-
[...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [],
|
|
2616
|
+
[...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [], ae(), U(), z(), B()));
|
|
2569
2617
|
}
|
|
2570
2618
|
}, [
|
|
2571
|
-
L,
|
|
2572
2619
|
z,
|
|
2573
|
-
|
|
2574
|
-
|
|
2620
|
+
B,
|
|
2621
|
+
ae,
|
|
2622
|
+
U,
|
|
2575
2623
|
e
|
|
2576
2624
|
])
|
|
2577
2625
|
};
|
|
@@ -2812,22 +2860,166 @@ function Fn(e) {
|
|
|
2812
2860
|
}, [t, n]);
|
|
2813
2861
|
}
|
|
2814
2862
|
//#endregion
|
|
2815
|
-
//#region src/components/ShapeEditor/_model/
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
let
|
|
2863
|
+
//#region src/components/ShapeEditor/_model/imageLoad.ts
|
|
2864
|
+
function In(e, t) {
|
|
2865
|
+
return new Promise((n) => {
|
|
2866
|
+
let r = new Image();
|
|
2867
|
+
t?.crossOrigin && (r.crossOrigin = "anonymous"), r.onload = () => n(r), r.onerror = () => n(null), r.src = e;
|
|
2868
|
+
});
|
|
2869
|
+
}
|
|
2870
|
+
async function Ln(e) {
|
|
2871
|
+
let t = await In(e, { crossOrigin: !0 });
|
|
2872
|
+
if (t) return t;
|
|
2873
|
+
try {
|
|
2874
|
+
let t = await fetch(e, {
|
|
2819
2875
|
mode: "cors",
|
|
2820
2876
|
credentials: "omit",
|
|
2821
|
-
cache:
|
|
2877
|
+
cache: "reload"
|
|
2878
|
+
});
|
|
2879
|
+
if (!t.ok) return null;
|
|
2880
|
+
await t.blob();
|
|
2881
|
+
} catch {
|
|
2882
|
+
return null;
|
|
2883
|
+
}
|
|
2884
|
+
return In(e, { crossOrigin: !0 });
|
|
2885
|
+
}
|
|
2886
|
+
//#endregion
|
|
2887
|
+
//#region src/components/ShapeEditor/_model/imageDiagnosis.ts
|
|
2888
|
+
function Rn(e) {
|
|
2889
|
+
return new Promise((t) => {
|
|
2890
|
+
let n = null, r = !1, i = () => {
|
|
2891
|
+
r || (r = !0, clearTimeout(o), document.removeEventListener("securitypolicyviolation", a), t(n));
|
|
2892
|
+
}, a = (t) => {
|
|
2893
|
+
let r = t.effectiveDirective ?? t.violatedDirective ?? "";
|
|
2894
|
+
r.includes("img-src") && (n = `CSP ${r} blocked ${t.blockedURI || e}`);
|
|
2895
|
+
}, o = setTimeout(i, 1e4);
|
|
2896
|
+
document.addEventListener("securitypolicyviolation", a), In(e, { crossOrigin: !0 }).then(() => {
|
|
2897
|
+
setTimeout(i, 0);
|
|
2822
2898
|
});
|
|
2823
|
-
|
|
2899
|
+
});
|
|
2900
|
+
}
|
|
2901
|
+
var zn = 3e4, Bn = 200, Vn = /* @__PURE__ */ new Map();
|
|
2902
|
+
function Hn(e) {
|
|
2903
|
+
let t = Vn.get(e), n = Date.now();
|
|
2904
|
+
if (t && n - t.at < zn) return t.result;
|
|
2905
|
+
let r = Un(e).catch((t) => (Vn.delete(e), {
|
|
2906
|
+
kind: "unknown",
|
|
2907
|
+
detail: t instanceof Error ? t.message : String(t)
|
|
2908
|
+
}));
|
|
2909
|
+
if (Vn.set(e, {
|
|
2910
|
+
at: n,
|
|
2911
|
+
result: r
|
|
2912
|
+
}), Vn.size > Bn) {
|
|
2913
|
+
let e = Vn.keys().next().value;
|
|
2914
|
+
e !== void 0 && Vn.delete(e);
|
|
2915
|
+
}
|
|
2916
|
+
return r;
|
|
2917
|
+
}
|
|
2918
|
+
async function Un(e) {
|
|
2919
|
+
let t = e;
|
|
2920
|
+
try {
|
|
2921
|
+
t = new URL(e, location.href).origin;
|
|
2824
2922
|
} catch {}
|
|
2825
|
-
return
|
|
2923
|
+
if (location.protocol === "https:" && e.startsWith("http:")) return {
|
|
2924
|
+
kind: "mixed-content",
|
|
2925
|
+
detail: `http image on https page (${t})`
|
|
2926
|
+
};
|
|
2927
|
+
let n;
|
|
2928
|
+
try {
|
|
2929
|
+
n = await fetch(e, {
|
|
2930
|
+
mode: "cors",
|
|
2931
|
+
credentials: "omit",
|
|
2932
|
+
cache: "no-store"
|
|
2933
|
+
});
|
|
2934
|
+
} catch {
|
|
2935
|
+
if (!navigator.onLine) return {
|
|
2936
|
+
kind: "offline",
|
|
2937
|
+
detail: "navigator.onLine=false"
|
|
2938
|
+
};
|
|
2939
|
+
try {
|
|
2940
|
+
return await fetch(e, {
|
|
2941
|
+
mode: "no-cors",
|
|
2942
|
+
cache: "no-store"
|
|
2943
|
+
}), {
|
|
2944
|
+
kind: "cors",
|
|
2945
|
+
detail: `no Access-Control-Allow-Origin from ${t}`
|
|
2946
|
+
};
|
|
2947
|
+
} catch {
|
|
2948
|
+
return {
|
|
2949
|
+
kind: "network",
|
|
2950
|
+
detail: `fetch failed: ${t}`
|
|
2951
|
+
};
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
let { status: r } = n;
|
|
2955
|
+
if (n.ok) {
|
|
2956
|
+
let t = n.headers.get("content-type") ?? "";
|
|
2957
|
+
if (t && !t.startsWith("image/")) return {
|
|
2958
|
+
kind: "unexpected-content",
|
|
2959
|
+
detail: `HTTP ${r} (${t})${n.redirected ? " via redirect" : ""}`
|
|
2960
|
+
};
|
|
2961
|
+
let i = await Rn(e);
|
|
2962
|
+
return i ? {
|
|
2963
|
+
kind: "csp-img",
|
|
2964
|
+
detail: i
|
|
2965
|
+
} : {
|
|
2966
|
+
kind: "decode",
|
|
2967
|
+
detail: `HTTP ${r}${t ? ` (${t})` : ""}`
|
|
2968
|
+
};
|
|
2969
|
+
}
|
|
2970
|
+
if (r === 401 || r === 403) {
|
|
2971
|
+
try {
|
|
2972
|
+
let t = await fetch(e, {
|
|
2973
|
+
mode: "cors",
|
|
2974
|
+
credentials: "include",
|
|
2975
|
+
cache: "no-store"
|
|
2976
|
+
});
|
|
2977
|
+
if (t.ok) return {
|
|
2978
|
+
kind: "auth",
|
|
2979
|
+
detail: `HTTP ${r} without cookies, ${t.status} with cookies`
|
|
2980
|
+
};
|
|
2981
|
+
} catch {}
|
|
2982
|
+
return {
|
|
2983
|
+
kind: "forbidden",
|
|
2984
|
+
detail: `HTTP ${r}`
|
|
2985
|
+
};
|
|
2986
|
+
}
|
|
2987
|
+
return r === 404 || r === 410 ? {
|
|
2988
|
+
kind: "not-found",
|
|
2989
|
+
detail: `HTTP ${r}`
|
|
2990
|
+
} : r >= 500 ? {
|
|
2991
|
+
kind: "server-error",
|
|
2992
|
+
detail: `HTTP ${r}`
|
|
2993
|
+
} : {
|
|
2994
|
+
kind: "http",
|
|
2995
|
+
detail: `HTTP ${r}`
|
|
2996
|
+
};
|
|
2997
|
+
}
|
|
2998
|
+
function Wn() {
|
|
2999
|
+
try {
|
|
3000
|
+
let e = document.createElement("canvas");
|
|
3001
|
+
return !!(e.getContext("webgl2") ?? e.getContext("webgl"));
|
|
3002
|
+
} catch {
|
|
3003
|
+
return !1;
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
function Gn(e) {
|
|
3007
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
3008
|
+
return /unsafe-eval/i.test(t) ? {
|
|
3009
|
+
kind: "csp-eval",
|
|
3010
|
+
detail: t
|
|
3011
|
+
} : Wn() ? {
|
|
3012
|
+
kind: "renderer-init",
|
|
3013
|
+
detail: t || "renderer init failed"
|
|
3014
|
+
} : {
|
|
3015
|
+
kind: "webgl",
|
|
3016
|
+
detail: t || "WebGL context unavailable"
|
|
3017
|
+
};
|
|
2826
3018
|
}
|
|
2827
3019
|
//#endregion
|
|
2828
3020
|
//#region src/components/ShapeEditor/_model/imageTiles.ts
|
|
2829
|
-
var
|
|
2830
|
-
function
|
|
3021
|
+
var Kn = 4e3;
|
|
3022
|
+
function qn(e, t, n = Kn) {
|
|
2831
3023
|
if (e <= 0 || t <= 0) return [];
|
|
2832
3024
|
let r = Math.ceil(e / n), i = Math.ceil(t / n);
|
|
2833
3025
|
return Array.from({ length: i }, (a, o) => Array.from({ length: r }, (a, s) => {
|
|
@@ -2842,7 +3034,7 @@ function Rn(e, t, n = Ln) {
|
|
|
2842
3034
|
};
|
|
2843
3035
|
})).flat();
|
|
2844
3036
|
}
|
|
2845
|
-
function
|
|
3037
|
+
function Jn(e, t) {
|
|
2846
3038
|
let n = document.createElement("canvas");
|
|
2847
3039
|
n.width = t.width, n.height = t.height;
|
|
2848
3040
|
let r = n.getContext("2d");
|
|
@@ -2850,15 +3042,15 @@ function zn(e, t) {
|
|
|
2850
3042
|
}
|
|
2851
3043
|
//#endregion
|
|
2852
3044
|
//#region src/components/ShapeEditor/_model/konva.ts
|
|
2853
|
-
function
|
|
2854
|
-
if (t ===
|
|
3045
|
+
function Yn(e, t, n) {
|
|
3046
|
+
if (t === L.POINT) {
|
|
2855
3047
|
e.setAttrs({
|
|
2856
3048
|
x: n[0].x,
|
|
2857
3049
|
y: n[0].y
|
|
2858
3050
|
});
|
|
2859
3051
|
return;
|
|
2860
3052
|
}
|
|
2861
|
-
if (t ===
|
|
3053
|
+
if (t === L.RECTANGLE) {
|
|
2862
3054
|
let [t, r] = n;
|
|
2863
3055
|
e.setAttrs({
|
|
2864
3056
|
x: Math.min(t.x, r.x),
|
|
@@ -2868,8 +3060,8 @@ function Bn(e, t, n) {
|
|
|
2868
3060
|
});
|
|
2869
3061
|
return;
|
|
2870
3062
|
}
|
|
2871
|
-
if (t ===
|
|
2872
|
-
let t =
|
|
3063
|
+
if (t === L.ELLIPSE) {
|
|
3064
|
+
let t = V(n);
|
|
2873
3065
|
e.setAttrs({
|
|
2874
3066
|
x: (t.minX + t.maxX) / 2,
|
|
2875
3067
|
y: (t.minY + t.maxY) / 2,
|
|
@@ -2886,23 +3078,23 @@ function Bn(e, t, n) {
|
|
|
2886
3078
|
}
|
|
2887
3079
|
//#endregion
|
|
2888
3080
|
//#region src/components/ShapeEditor/_model/pinIcon.ts
|
|
2889
|
-
var
|
|
2890
|
-
function
|
|
2891
|
-
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${
|
|
3081
|
+
var Q = "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", Xn = "#ffffff", Zn = 1.5;
|
|
3082
|
+
function Qn(e) {
|
|
3083
|
+
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${Q}" fill="${e}" stroke="${Xn}" stroke-width="${Zn}"/></svg>`;
|
|
2892
3084
|
}
|
|
2893
3085
|
//#endregion
|
|
2894
3086
|
//#region src/components/ShapeEditor/_renderers/transformSession.ts
|
|
2895
|
-
var
|
|
2896
|
-
function
|
|
2897
|
-
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type ===
|
|
3087
|
+
var $n = Math.PI / 12;
|
|
3088
|
+
function er(e, t) {
|
|
3089
|
+
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === L.ROTATED_RECTANGLE;
|
|
2898
3090
|
}
|
|
2899
|
-
function
|
|
3091
|
+
function tr(e, t, n) {
|
|
2900
3092
|
if (e.kind === "resize") {
|
|
2901
|
-
let r = n ? e.box :
|
|
3093
|
+
let r = n ? e.box : H(e.anchor, e.box, t.x, t.y);
|
|
2902
3094
|
return {
|
|
2903
3095
|
updates: e.shapes.map((i) => ({
|
|
2904
3096
|
id: i.id,
|
|
2905
|
-
points: n ?
|
|
3097
|
+
points: n ? Ce(i.points, e.anchor, t) : we(i.points, e.box, r)
|
|
2906
3098
|
})),
|
|
2907
3099
|
box: r
|
|
2908
3100
|
};
|
|
@@ -2927,10 +3119,10 @@ function Q(e, t, n) {
|
|
|
2927
3119
|
}
|
|
2928
3120
|
if (e.kind === "rotate") {
|
|
2929
3121
|
let n = Math.atan2(t.y - e.center.y, t.x - e.center.x) - e.startAngle;
|
|
2930
|
-
return e.shiftKey && (n = Math.round(n /
|
|
3122
|
+
return e.shiftKey && (n = Math.round(n / $n) * $n), {
|
|
2931
3123
|
updates: [{
|
|
2932
3124
|
id: e.id,
|
|
2933
|
-
points: e.points.map((t) =>
|
|
3125
|
+
points: e.points.map((t) => le(t, e.center, n))
|
|
2934
3126
|
}],
|
|
2935
3127
|
box: null
|
|
2936
3128
|
};
|
|
@@ -2944,48 +3136,48 @@ function Q(e, t, n) {
|
|
|
2944
3136
|
id: e.id,
|
|
2945
3137
|
points: a
|
|
2946
3138
|
}],
|
|
2947
|
-
box:
|
|
3139
|
+
box: V(a)
|
|
2948
3140
|
};
|
|
2949
3141
|
}
|
|
2950
|
-
function
|
|
3142
|
+
function nr(e, t) {
|
|
2951
3143
|
return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
|
|
2952
3144
|
x: t.center.x + Math.cos(t.startAngle),
|
|
2953
3145
|
y: t.center.y + Math.sin(t.startAngle)
|
|
2954
|
-
} :
|
|
3146
|
+
} : er(e, t) ? be(t.shapes[0].points)[B.indexOf(t.anchor)] : se(t.anchor, t.box);
|
|
2955
3147
|
}
|
|
2956
|
-
function
|
|
2957
|
-
let r = e.filter((e) => t.includes(e.id) &&
|
|
3148
|
+
function rr(e, t, n) {
|
|
3149
|
+
let r = e.filter((e) => t.includes(e.id) && z(e)).map((e) => ({
|
|
2958
3150
|
id: e.id,
|
|
2959
3151
|
points: e.points
|
|
2960
3152
|
}));
|
|
2961
3153
|
return r.length ? {
|
|
2962
3154
|
kind: "move",
|
|
2963
3155
|
start: n,
|
|
2964
|
-
box:
|
|
3156
|
+
box: V(r.flatMap((e) => e.points)),
|
|
2965
3157
|
shapes: r
|
|
2966
3158
|
} : null;
|
|
2967
3159
|
}
|
|
2968
|
-
function
|
|
3160
|
+
function ir(e) {
|
|
2969
3161
|
return e.map((e) => ({
|
|
2970
3162
|
...e,
|
|
2971
3163
|
points: e.points.map((e) => ({ ...e }))
|
|
2972
3164
|
}));
|
|
2973
3165
|
}
|
|
2974
|
-
function
|
|
3166
|
+
function ar(e, t) {
|
|
2975
3167
|
let n = new Set(t);
|
|
2976
|
-
return e.filter((e) => n.has(e.id) &&
|
|
3168
|
+
return e.filter((e) => n.has(e.id) && ie(e));
|
|
2977
3169
|
}
|
|
2978
|
-
function
|
|
3170
|
+
function or(e, t) {
|
|
2979
3171
|
return e.filter((e) => {
|
|
2980
|
-
if (!
|
|
2981
|
-
let n =
|
|
3172
|
+
if (!R(e)) return !1;
|
|
3173
|
+
let n = V(e.points);
|
|
2982
3174
|
return n.minX <= t.maxX && n.maxX >= t.minX && n.minY <= t.maxY && n.maxY >= t.minY;
|
|
2983
3175
|
}).map((e) => e.id);
|
|
2984
3176
|
}
|
|
2985
|
-
function
|
|
3177
|
+
function sr(e, t, n) {
|
|
2986
3178
|
return (e ? Ue(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
|
|
2987
3179
|
}
|
|
2988
|
-
function
|
|
3180
|
+
function cr(e, t) {
|
|
2989
3181
|
return {
|
|
2990
3182
|
minX: e.x - t,
|
|
2991
3183
|
minY: e.y - t,
|
|
@@ -2993,10 +3185,10 @@ function $n(e, t) {
|
|
|
2993
3185
|
maxY: e.y + t
|
|
2994
3186
|
};
|
|
2995
3187
|
}
|
|
2996
|
-
function
|
|
2997
|
-
if (e.type ===
|
|
2998
|
-
let r = e.type ===
|
|
2999
|
-
return
|
|
3188
|
+
function lr(e, t, n) {
|
|
3189
|
+
if (e.type === L.ROTATED_RECTANGLE) return t;
|
|
3190
|
+
let r = e.type === L.POINT ? cr(t[0], n) : V(t);
|
|
3191
|
+
return ue([{
|
|
3000
3192
|
x: r.minX,
|
|
3001
3193
|
y: r.minY
|
|
3002
3194
|
}, {
|
|
@@ -3004,17 +3196,17 @@ function er(e, t, n) {
|
|
|
3004
3196
|
y: r.maxY
|
|
3005
3197
|
}]);
|
|
3006
3198
|
}
|
|
3007
|
-
function
|
|
3199
|
+
function ur(e) {
|
|
3008
3200
|
return 24 / (e || 1);
|
|
3009
3201
|
}
|
|
3010
|
-
function
|
|
3202
|
+
function dr(e, t) {
|
|
3011
3203
|
return Math.atan2(t.y - e.y, t.x - e.x);
|
|
3012
3204
|
}
|
|
3013
3205
|
//#endregion
|
|
3014
3206
|
//#region src/components/ShapeEditor/_renderers/KonvaRenderer.ts
|
|
3015
|
-
var
|
|
3207
|
+
var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
|
|
3016
3208
|
constructor(e, t) {
|
|
3017
|
-
this.layer = new A.Layer(), this.world = new A.Group(), this.bgGroup = new A.Group(), this.overlayGroup = new A.Group({ listening: !1 }), this.guideOverlayGroup = new A.Group({ listening: !1 }), this.regionOverlayGroup = new A.Group({ listening: !1 }), this.dimOverlayGroup = new A.Group({ listening: !1 }), this.shapeGroup = new A.Group(), this.selGroup = new A.Group(), this.previewGroup = new A.Group(), this.handleGroup = new A.Group(), this.baseCursor = "default", this.strokeSize =
|
|
3209
|
+
this.layer = new A.Layer(), this.world = new A.Group(), this.bgGroup = new A.Group(), this.overlayGroup = new A.Group({ listening: !1 }), this.guideOverlayGroup = new A.Group({ listening: !1 }), this.regionOverlayGroup = new A.Group({ listening: !1 }), this.dimOverlayGroup = new A.Group({ listening: !1 }), this.shapeGroup = new A.Group(), this.selGroup = new A.Group(), this.previewGroup = new A.Group(), this.handleGroup = new A.Group(), this.baseCursor = "default", this.strokeSize = fr, 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 = {
|
|
3018
3210
|
x: 0,
|
|
3019
3211
|
y: 0
|
|
3020
3212
|
}, this.lastDragImg = null, this.ro = null, this.activeDrag = null, this.midNodes = [], this.ghostNode = null, this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorders = [], this.upCleanup = null, this.lastPreviewPoly = null, this.preview = null, this.marquee = null, this.host = e, this.cb = t, this.stage = new A.Stage({
|
|
@@ -3124,36 +3316,30 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3124
3316
|
return this.world.getAbsoluteTransform().point(e);
|
|
3125
3317
|
}
|
|
3126
3318
|
async setImage(e, t, n) {
|
|
3127
|
-
let r = ++this.imageLoadToken, i = await
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
}));
|
|
3152
|
-
this.layer.batchDraw(), a();
|
|
3153
|
-
}, o.onerror = () => {
|
|
3154
|
-
i && URL.revokeObjectURL(i), this.imageWidth ||= 800, this.imageHeight ||= 600, a();
|
|
3155
|
-
}, o.src = i ?? e;
|
|
3156
|
-
});
|
|
3319
|
+
let r = ++this.imageLoadToken, i = await Ln(e);
|
|
3320
|
+
if (r !== this.imageLoadToken) return !0;
|
|
3321
|
+
if (!i) return this.imageWidth ||= 800, this.imageHeight ||= 600, !1;
|
|
3322
|
+
this.imageWidth = t?.width ?? i.naturalWidth, this.imageHeight = t?.height ?? i.naturalHeight;
|
|
3323
|
+
let a = n?.width ?? this.imageWidth, o = n?.height ?? this.imageHeight;
|
|
3324
|
+
this.bgGroup.scale({
|
|
3325
|
+
x: a / i.naturalWidth,
|
|
3326
|
+
y: o / i.naturalHeight
|
|
3327
|
+
}), this.bgGroup.destroyChildren();
|
|
3328
|
+
for (let e of qn(i.naturalWidth, i.naturalHeight)) this.bgGroup.add(new A.Image({
|
|
3329
|
+
image: i,
|
|
3330
|
+
x: e.x,
|
|
3331
|
+
y: e.y,
|
|
3332
|
+
width: e.width,
|
|
3333
|
+
height: e.height,
|
|
3334
|
+
crop: {
|
|
3335
|
+
x: e.srcX,
|
|
3336
|
+
y: e.srcY,
|
|
3337
|
+
width: e.width,
|
|
3338
|
+
height: e.height
|
|
3339
|
+
},
|
|
3340
|
+
listening: !1
|
|
3341
|
+
}));
|
|
3342
|
+
return this.layer.batchDraw(), !0;
|
|
3157
3343
|
}
|
|
3158
3344
|
clearImage() {
|
|
3159
3345
|
this.imageLoadToken++, this.bgGroup.destroyChildren(), this.layer.batchDraw();
|
|
@@ -3250,7 +3436,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3250
3436
|
let e = this.lastPreviewPoly;
|
|
3251
3437
|
e && this.previewPoly(e.points, e.cursor, e.style, e.closed, e.selectedPointIndices, e.showVertices);
|
|
3252
3438
|
}
|
|
3253
|
-
this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
3439
|
+
this.activeDrag ? this.dragTransform(this.lastDragImg ?? nr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
|
|
3254
3440
|
}
|
|
3255
3441
|
fit() {
|
|
3256
3442
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -3279,11 +3465,11 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3279
3465
|
});
|
|
3280
3466
|
}
|
|
3281
3467
|
setShapes(e, t) {
|
|
3282
|
-
if (this.shapes =
|
|
3468
|
+
if (this.shapes = ir(e), this.selected = t, !this.activeDrag) {
|
|
3283
3469
|
this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
|
|
3284
|
-
for (let t of
|
|
3470
|
+
for (let t of ae(e).filter(ne)) {
|
|
3285
3471
|
let e = this.makeNode(t), n = Ue(t, { strokeWidth: this.strokeSize });
|
|
3286
|
-
if (t.style?.alternateColor && n.dash?.length && t.type !==
|
|
3472
|
+
if (t.style?.alternateColor && n.dash?.length && t.type !== L.POINT) {
|
|
3287
3473
|
let n = e.clone({
|
|
3288
3474
|
id: `${t.id}__alt`,
|
|
3289
3475
|
stroke: t.style.alternateColor,
|
|
@@ -3313,7 +3499,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3313
3499
|
t.size === this.selectedVertices.size && [...t].every((e) => this.selectedVertices.has(e)) || (this.selectedVertices = t, this.activeDrag || (this.drawTransformer(), this.layer.batchDraw()));
|
|
3314
3500
|
}
|
|
3315
3501
|
makeNode(e) {
|
|
3316
|
-
let { type: t, points: n } = e, r = Ue(e, { strokeWidth: this.strokeSize }), i =
|
|
3502
|
+
let { type: t, points: n } = e, r = Ue(e, { strokeWidth: this.strokeSize }), i = R(e), a = {
|
|
3317
3503
|
id: e.id,
|
|
3318
3504
|
stroke: r.color,
|
|
3319
3505
|
strokeWidth: r.strokeWidth,
|
|
@@ -3322,10 +3508,10 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3322
3508
|
strokeScaleEnabled: !1,
|
|
3323
3509
|
listening: i
|
|
3324
3510
|
}, o = r.fillVisible ? We(r.color, r.fillAlpha) : void 0;
|
|
3325
|
-
if (t ===
|
|
3511
|
+
if (t === L.POINT) {
|
|
3326
3512
|
let t = 1 / (this.world.scaleX() || 1), a = new A.Path({
|
|
3327
3513
|
id: e.id,
|
|
3328
|
-
data:
|
|
3514
|
+
data: Q,
|
|
3329
3515
|
x: n[0].x,
|
|
3330
3516
|
y: n[0].y,
|
|
3331
3517
|
offsetX: 16 / 2,
|
|
@@ -3333,8 +3519,8 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3333
3519
|
scaleX: t,
|
|
3334
3520
|
scaleY: t,
|
|
3335
3521
|
fill: r.color,
|
|
3336
|
-
stroke:
|
|
3337
|
-
strokeWidth:
|
|
3522
|
+
stroke: Xn,
|
|
3523
|
+
strokeWidth: Zn,
|
|
3338
3524
|
strokeScaleEnabled: !1,
|
|
3339
3525
|
shadowColor: "#000",
|
|
3340
3526
|
shadowBlur: 2,
|
|
@@ -3343,10 +3529,10 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3343
3529
|
opacity: r.opacity,
|
|
3344
3530
|
listening: i
|
|
3345
3531
|
});
|
|
3346
|
-
return this.bindCursor(a,
|
|
3532
|
+
return this.bindCursor(a, z(e) ? "grab" : "default"), a;
|
|
3347
3533
|
}
|
|
3348
|
-
if (t ===
|
|
3349
|
-
let t =
|
|
3534
|
+
if (t === L.RECTANGLE) {
|
|
3535
|
+
let t = V(n), r = new A.Rect({
|
|
3350
3536
|
x: t.minX,
|
|
3351
3537
|
y: t.minY,
|
|
3352
3538
|
width: t.maxX - t.minX,
|
|
@@ -3354,10 +3540,10 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3354
3540
|
fill: o,
|
|
3355
3541
|
...a
|
|
3356
3542
|
});
|
|
3357
|
-
return this.bindCursor(r,
|
|
3543
|
+
return this.bindCursor(r, z(e) ? "grab" : "default"), r;
|
|
3358
3544
|
}
|
|
3359
|
-
if (t ===
|
|
3360
|
-
let t =
|
|
3545
|
+
if (t === L.ELLIPSE) {
|
|
3546
|
+
let t = V(n), r = new A.Ellipse({
|
|
3361
3547
|
x: (t.minX + t.maxX) / 2,
|
|
3362
3548
|
y: (t.minY + t.maxY) / 2,
|
|
3363
3549
|
radiusX: (t.maxX - t.minX) / 2,
|
|
@@ -3365,27 +3551,27 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3365
3551
|
fill: o,
|
|
3366
3552
|
...a
|
|
3367
3553
|
});
|
|
3368
|
-
return this.bindCursor(r,
|
|
3554
|
+
return this.bindCursor(r, z(e) ? "grab" : "default"), r;
|
|
3369
3555
|
}
|
|
3370
|
-
let s = n.flatMap((e) => [e.x, e.y]), c = t !==
|
|
3556
|
+
let s = n.flatMap((e) => [e.x, e.y]), c = t !== L.LINE, l = new A.Line({
|
|
3371
3557
|
points: s,
|
|
3372
3558
|
closed: c,
|
|
3373
3559
|
fill: c ? o : void 0,
|
|
3374
3560
|
lineJoin: "round",
|
|
3375
3561
|
...a
|
|
3376
3562
|
});
|
|
3377
|
-
return this.bindCursor(l,
|
|
3563
|
+
return this.bindCursor(l, z(e) ? "grab" : "default"), l;
|
|
3378
3564
|
}
|
|
3379
3565
|
liveUpdateShape(e, t) {
|
|
3380
3566
|
let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
|
|
3381
3567
|
if (n && r) {
|
|
3382
|
-
|
|
3568
|
+
Yn(n, r.type, t);
|
|
3383
3569
|
let i = this.altNodes.get(e);
|
|
3384
|
-
i &&
|
|
3570
|
+
i && Yn(i, r.type, t), r.type === L.POINT && n instanceof A.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
|
|
3385
3571
|
}
|
|
3386
3572
|
}
|
|
3387
3573
|
pointRadius(e) {
|
|
3388
|
-
return
|
|
3574
|
+
return sr(e, this.strokeSize, this.world.scaleX() || 1);
|
|
3389
3575
|
}
|
|
3390
3576
|
scaledDash(e) {
|
|
3391
3577
|
return e;
|
|
@@ -3394,7 +3580,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3394
3580
|
let e = 1 / (this.world.scaleX() || 1);
|
|
3395
3581
|
for (let t of this.shapes) {
|
|
3396
3582
|
let n = this.nodes.get(t.id);
|
|
3397
|
-
if (t.type ===
|
|
3583
|
+
if (t.type === L.POINT) {
|
|
3398
3584
|
n?.scale({
|
|
3399
3585
|
x: e,
|
|
3400
3586
|
y: e
|
|
@@ -3405,16 +3591,16 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3405
3591
|
}
|
|
3406
3592
|
}
|
|
3407
3593
|
shapesIntersecting(e) {
|
|
3408
|
-
return
|
|
3594
|
+
return or(this.shapes, e);
|
|
3409
3595
|
}
|
|
3410
3596
|
drawSelectionBorders() {
|
|
3411
|
-
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) &&
|
|
3597
|
+
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && R(t)) : [];
|
|
3412
3598
|
if (this.selectionBorders.length !== t.length) {
|
|
3413
3599
|
for (let e of this.selectionBorders) e.destroy();
|
|
3414
3600
|
this.selectionBorders = t.map(() => {
|
|
3415
3601
|
let e = new A.Line({
|
|
3416
3602
|
closed: !0,
|
|
3417
|
-
stroke:
|
|
3603
|
+
stroke: mr,
|
|
3418
3604
|
strokeWidth: 1.5,
|
|
3419
3605
|
strokeScaleEnabled: !1,
|
|
3420
3606
|
listening: !1
|
|
@@ -3429,13 +3615,13 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3429
3615
|
updateSelectionBordersLive(e) {
|
|
3430
3616
|
let t = new Set(this.selected), n = 0;
|
|
3431
3617
|
for (let r of this.shapes) {
|
|
3432
|
-
if (!t.has(r.id) || !
|
|
3618
|
+
if (!t.has(r.id) || !R(r)) continue;
|
|
3433
3619
|
let i = this.selectionOutlinePoints(r, e(r)), a = this.selectionBorders[n++];
|
|
3434
3620
|
a && a.points(i.flatMap((e) => [e.x, e.y]));
|
|
3435
3621
|
}
|
|
3436
3622
|
}
|
|
3437
3623
|
selectionOutlinePoints(e, t) {
|
|
3438
|
-
return
|
|
3624
|
+
return lr(e, t, this.pointRadius(e));
|
|
3439
3625
|
}
|
|
3440
3626
|
clearPreview() {
|
|
3441
3627
|
this.lastPreviewPoly = null, this.previewGroup.destroyChildren(), this.layer.batchDraw();
|
|
@@ -3498,8 +3684,8 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3498
3684
|
x: n.x,
|
|
3499
3685
|
y: n.y,
|
|
3500
3686
|
radius: (r ? 6 : 5) / l,
|
|
3501
|
-
fill: r ?
|
|
3502
|
-
stroke: r ? "#ffffff" :
|
|
3687
|
+
fill: r ? pr : "#ffffff",
|
|
3688
|
+
stroke: r ? "#ffffff" : pr,
|
|
3503
3689
|
strokeWidth: 1.5,
|
|
3504
3690
|
strokeScaleEnabled: !1,
|
|
3505
3691
|
listening: !1
|
|
@@ -3542,7 +3728,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3542
3728
|
}
|
|
3543
3729
|
setTransformerOutline(e) {
|
|
3544
3730
|
let t = Math.max(0, e.maxX - e.minX), n = Math.max(0, e.maxY - e.minY);
|
|
3545
|
-
!t && !n || this.setTransformerOutlinePoints(
|
|
3731
|
+
!t && !n || this.setTransformerOutlinePoints(ue([{
|
|
3546
3732
|
x: e.minX,
|
|
3547
3733
|
y: e.minY
|
|
3548
3734
|
}, {
|
|
@@ -3553,20 +3739,20 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3553
3739
|
setTransformerOutlinePoints(e) {
|
|
3554
3740
|
e.length < 2 || (this.transformerOutline || (this.transformerOutline = new A.Line({
|
|
3555
3741
|
closed: !0,
|
|
3556
|
-
stroke:
|
|
3742
|
+
stroke: pr,
|
|
3557
3743
|
strokeWidth: 1,
|
|
3558
3744
|
strokeScaleEnabled: !1,
|
|
3559
3745
|
listening: !1
|
|
3560
3746
|
}), this.selGroup.add(this.transformerOutline)), this.transformerOutline.points(e.flatMap((e) => [e.x, e.y])));
|
|
3561
3747
|
}
|
|
3562
3748
|
rotationHandleGap() {
|
|
3563
|
-
return
|
|
3749
|
+
return ur(this.viewport.scale);
|
|
3564
3750
|
}
|
|
3565
3751
|
rotationHandleScreenPoint(e) {
|
|
3566
|
-
return this.imgToScreen(
|
|
3752
|
+
return this.imgToScreen(xe(e, this.rotationHandleGap()));
|
|
3567
3753
|
}
|
|
3568
3754
|
setRotationConnector(e) {
|
|
3569
|
-
let t = this.imgToScreen(
|
|
3755
|
+
let t = this.imgToScreen(ve(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
|
|
3570
3756
|
this.rotLineNode ? this.rotLineNode.points([
|
|
3571
3757
|
t.x,
|
|
3572
3758
|
t.y,
|
|
@@ -3579,7 +3765,7 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3579
3765
|
n.x,
|
|
3580
3766
|
n.y
|
|
3581
3767
|
],
|
|
3582
|
-
stroke:
|
|
3768
|
+
stroke: pr,
|
|
3583
3769
|
strokeWidth: 1,
|
|
3584
3770
|
listening: !1
|
|
3585
3771
|
}), this.handleGroup.add(this.rotLineNode));
|
|
@@ -3594,11 +3780,11 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3594
3780
|
}), e.rotation(n * 180 / Math.PI);
|
|
3595
3781
|
}
|
|
3596
3782
|
orientedHandleAngle(e) {
|
|
3597
|
-
return
|
|
3783
|
+
return dr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
3598
3784
|
}
|
|
3599
3785
|
repositionOrientedHandles(e) {
|
|
3600
3786
|
let t = this.orientedHandleAngle(e);
|
|
3601
|
-
if (
|
|
3787
|
+
if (be(e).forEach((e, n) => {
|
|
3602
3788
|
let r = this.imgToScreen(e), i = this.handleNodes[n];
|
|
3603
3789
|
i && this.layoutResizeHandle(i, r, t);
|
|
3604
3790
|
}), this.setTransformerOutlinePoints(e), this.rotNode) {
|
|
@@ -3616,13 +3802,13 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3616
3802
|
for (let e of this.vertexNodes) e.destroy();
|
|
3617
3803
|
for (let e of this.midNodes) e.destroy();
|
|
3618
3804
|
if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
3619
|
-
let e =
|
|
3620
|
-
if (!e.length || e.length === 1 && e[0].type ===
|
|
3621
|
-
let t = e.length === 1 && (e[0].type ===
|
|
3805
|
+
let e = ar(this.shapes, this.selected);
|
|
3806
|
+
if (!e.length || e.length === 1 && e[0].type === L.POINT) return;
|
|
3807
|
+
let t = e.length === 1 && (e[0].type === L.POLYGON || e[0].type === L.LINE) && this.editingId === e[0].id ? e[0] : null, n = V(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === L.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : B.map((e) => se(e, n));
|
|
3622
3808
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
3623
3809
|
let a = r ? this.orientedHandleAngle(r.points) : 0;
|
|
3624
|
-
for (let e of t ? [] :
|
|
3625
|
-
let t = this.imgToScreen(i[
|
|
3810
|
+
for (let e of t ? [] : B) {
|
|
3811
|
+
let t = this.imgToScreen(i[B.indexOf(e)]), n = new A.Rect({
|
|
3626
3812
|
x: t.x,
|
|
3627
3813
|
y: t.y,
|
|
3628
3814
|
width: 8,
|
|
@@ -3631,16 +3817,16 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3631
3817
|
offsetY: 4,
|
|
3632
3818
|
rotation: a * 180 / Math.PI,
|
|
3633
3819
|
fill: "#ffffff",
|
|
3634
|
-
stroke:
|
|
3820
|
+
stroke: pr,
|
|
3635
3821
|
strokeWidth: 1
|
|
3636
3822
|
}), r = wt(e, a);
|
|
3637
3823
|
this.bindCursor(n, r), n.on("mousedown", (t) => {
|
|
3638
3824
|
t.cancelBubble = !0, this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
3639
|
-
let n =
|
|
3825
|
+
let n = ar(this.shapes, this.selected);
|
|
3640
3826
|
this.activeDrag = {
|
|
3641
3827
|
kind: "resize",
|
|
3642
3828
|
anchor: e,
|
|
3643
|
-
box:
|
|
3829
|
+
box: V(n.flatMap((e) => e.points)),
|
|
3644
3830
|
shapes: n.map((e) => ({
|
|
3645
3831
|
id: e.id,
|
|
3646
3832
|
points: e.points
|
|
@@ -3649,11 +3835,11 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3649
3835
|
}), this.handleGroup.add(n), this.handleNodes.push(n);
|
|
3650
3836
|
}
|
|
3651
3837
|
if (t) {
|
|
3652
|
-
let e = t, n = e.points, r = e.type ===
|
|
3838
|
+
let e = t, n = e.points, r = e.type === L.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new A.Circle({
|
|
3653
3839
|
radius: i * .8,
|
|
3654
3840
|
fill: "#ffffff",
|
|
3655
3841
|
opacity: .6,
|
|
3656
|
-
stroke:
|
|
3842
|
+
stroke: pr,
|
|
3657
3843
|
strokeWidth: 1,
|
|
3658
3844
|
visible: !1,
|
|
3659
3845
|
listening: !1
|
|
@@ -3713,8 +3899,8 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3713
3899
|
x: a.x,
|
|
3714
3900
|
y: a.y,
|
|
3715
3901
|
radius: i,
|
|
3716
|
-
fill: o ?
|
|
3717
|
-
stroke: o ? "#ffffff" :
|
|
3902
|
+
fill: o ? pr : "#ffffff",
|
|
3903
|
+
stroke: o ? "#ffffff" : pr,
|
|
3718
3904
|
strokeWidth: Math.max(1.5, i * .3)
|
|
3719
3905
|
});
|
|
3720
3906
|
this.bindCursor(s, "pointer"), s.on("mousedown", (t) => {
|
|
@@ -3733,13 +3919,13 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3733
3919
|
}), this.handleGroup.add(s), this.vertexNodes.push(s);
|
|
3734
3920
|
});
|
|
3735
3921
|
}
|
|
3736
|
-
if (e.length === 1 && e[0].type ===
|
|
3737
|
-
let t = e[0], n =
|
|
3922
|
+
if (e.length === 1 && e[0].type === L.ROTATED_RECTANGLE) {
|
|
3923
|
+
let t = e[0], n = ye(t.points), r = this.rotationHandleScreenPoint(t.points), i = new A.Circle({
|
|
3738
3924
|
x: r.x,
|
|
3739
3925
|
y: r.y,
|
|
3740
3926
|
radius: 6,
|
|
3741
3927
|
fill: "#ffffff",
|
|
3742
|
-
stroke:
|
|
3928
|
+
stroke: pr,
|
|
3743
3929
|
strokeWidth: 1.5
|
|
3744
3930
|
});
|
|
3745
3931
|
this.bindCursor(i, "grab"), i.on("mousedown", (e) => {
|
|
@@ -3758,12 +3944,12 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3758
3944
|
this.layer.batchDraw();
|
|
3759
3945
|
}
|
|
3760
3946
|
beginMove(e, t) {
|
|
3761
|
-
let n =
|
|
3762
|
-
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 ===
|
|
3947
|
+
let n = rr(this.shapes, t, e);
|
|
3948
|
+
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === L.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
3763
3949
|
}
|
|
3764
3950
|
repositionHandles(e) {
|
|
3765
|
-
|
|
3766
|
-
let r = this.imgToScreen(
|
|
3951
|
+
B.forEach((t, n) => {
|
|
3952
|
+
let r = this.imgToScreen(se(t, e)), i = this.handleNodes[n];
|
|
3767
3953
|
i && this.layoutResizeHandle(i, r, 0);
|
|
3768
3954
|
}), this.setTransformerOutline(e);
|
|
3769
3955
|
}
|
|
@@ -3800,20 +3986,20 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3800
3986
|
let t = this.activeDrag;
|
|
3801
3987
|
if (!t) return;
|
|
3802
3988
|
this.applyCursor();
|
|
3803
|
-
let n =
|
|
3989
|
+
let n = er(this.shapes, t), { updates: r, box: i } = tr(t, e, n);
|
|
3804
3990
|
for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
3805
3991
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
3806
3992
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
|
|
3807
|
-
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type ===
|
|
3808
|
-
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
3993
|
+
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === L.POLYGON || e?.type === L.LINE;
|
|
3994
|
+
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
|
|
3809
3995
|
} else if (t.kind === "rotate") {
|
|
3810
3996
|
this.repositionOrientedHandles(r[0].points);
|
|
3811
3997
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
3812
|
-
e && (e.type ===
|
|
3998
|
+
e && (e.type === L.POLYGON || e.type === L.LINE) && this.repositionPolygonHandles(r[0].points, e.type === L.POLYGON);
|
|
3813
3999
|
} else {
|
|
3814
4000
|
i && this.repositionHandles(i);
|
|
3815
4001
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
3816
|
-
this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
4002
|
+
this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
|
|
3817
4003
|
}
|
|
3818
4004
|
this.layer.batchDraw();
|
|
3819
4005
|
}
|
|
@@ -3827,18 +4013,18 @@ var rr = 2, ir = "#1e88e5", ar = "#669def", or = class {
|
|
|
3827
4013
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
3828
4014
|
return;
|
|
3829
4015
|
}
|
|
3830
|
-
let { updates: n } =
|
|
4016
|
+
let { updates: n } = tr(e, t, er(this.shapes, e));
|
|
3831
4017
|
this.commitTransformUpdates(n);
|
|
3832
4018
|
}
|
|
3833
|
-
},
|
|
4019
|
+
}, gr = 2, _r = 58879, vr = 6725103;
|
|
3834
4020
|
function $(e) {
|
|
3835
|
-
if (!e) return
|
|
4021
|
+
if (!e) return _r;
|
|
3836
4022
|
let t = e.replace("#", "");
|
|
3837
4023
|
return Number.parseInt(t.length === 3 ? t.replace(/./g, "$&$&") : t, 16);
|
|
3838
4024
|
}
|
|
3839
|
-
var
|
|
4025
|
+
var yr = class {
|
|
3840
4026
|
constructor(e, t) {
|
|
3841
|
-
this.app = new j(), this.world = new
|
|
4027
|
+
this.app = new j(), this.world = new N(), this.bgLayer = new N(), this.overlayLayer = new N(), this.guideOverlayLayer = new N(), this.regionOverlayLayer = new N(), this.dimOverlayLayer = new N(), this.shapeLayer = new N(), this.selLayer = new N(), this.previewLayer = new N(), this.handleLayer = new N(), this.filter = new M(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.tileSize = Kn, this.overlayTextures = [], this.region = null, this.regionDimMaskG = new P(), this.regionDimG = new P(), this.regionZoneMaskG = new P(), this.regionZoneG = new P(), this.regionOutlineG = new P(), this.baseCursor = "default", this.strokeSize = gr, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.brightness = 1, this.contrast = 1, this.imageSmoothing = !0, this.destroyed = !1, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastDragImg = null, this.activeDrag = null, this.midNodes = [], this.ghostNode = null, this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorderGfx = [], this.previewG = new P(), this.marqueeG = new P(), this.previewMaskSprite = null, this.previewMaskTexture = null, this.previewReady = !1, this.lastPreview = null, this.host = e, this.cb = t;
|
|
3842
4028
|
}
|
|
3843
4029
|
ev(e) {
|
|
3844
4030
|
return {
|
|
@@ -3866,7 +4052,9 @@ var ur = class {
|
|
|
3866
4052
|
this.app.destroy(!0);
|
|
3867
4053
|
return;
|
|
3868
4054
|
}
|
|
3869
|
-
this.host.appendChild(this.app.canvas)
|
|
4055
|
+
this.host.appendChild(this.app.canvas);
|
|
4056
|
+
let e = this.app.renderer.gl, t = e?.getParameter(e.MAX_TEXTURE_SIZE);
|
|
4057
|
+
typeof t == "number" && t > 1 && (this.tileSize = Math.min(Kn, t - 1)), this.applyCursor(), this.overlayLayer.addChild(this.guideOverlayLayer, this.regionOverlayLayer, this.dimOverlayLayer), this.regionOverlayLayer.addChild(this.regionDimMaskG, this.regionDimG, this.regionZoneMaskG, this.regionZoneG, this.regionOutlineG), this.regionDimG.setMask({
|
|
3870
4058
|
mask: this.regionDimMaskG,
|
|
3871
4059
|
inverse: !0
|
|
3872
4060
|
}), this.regionZoneG.setMask({ mask: this.regionZoneMaskG }), this.world.addChild(this.bgLayer, this.overlayLayer, this.shapeLayer, this.selLayer, this.previewLayer), this.app.stage.addChild(this.world, this.handleLayer), this.world.visible = !1, this.app.stage.eventMode = "static", this.syncHitArea(), this.app.stage.on("pointerdown", (e) => {
|
|
@@ -3878,7 +4066,7 @@ var ur = class {
|
|
|
3878
4066
|
}
|
|
3879
4067
|
this.cb.onPointerMove(this.toImage(e), this.ev(e));
|
|
3880
4068
|
});
|
|
3881
|
-
let
|
|
4069
|
+
let n = (e, t) => {
|
|
3882
4070
|
if (this.activeDrag) {
|
|
3883
4071
|
this.endTransform();
|
|
3884
4072
|
return;
|
|
@@ -3892,11 +4080,11 @@ var ur = class {
|
|
|
3892
4080
|
insideCanvas: t
|
|
3893
4081
|
});
|
|
3894
4082
|
};
|
|
3895
|
-
this.app.stage.on("pointerup", (
|
|
4083
|
+
this.app.stage.on("pointerup", (e) => n(e, !0)), this.app.stage.on("pointerupoutside", (e) => n(e, !1)), this.app.renderer.on("resize", () => this.syncHitArea());
|
|
3896
4084
|
}
|
|
3897
4085
|
syncHitArea() {
|
|
3898
4086
|
let { w: e, h: t } = this.screenSize;
|
|
3899
|
-
this.app.stage.hitArea = new
|
|
4087
|
+
this.app.stage.hitArea = new ee(0, 0, e, t);
|
|
3900
4088
|
}
|
|
3901
4089
|
destroy() {
|
|
3902
4090
|
this.destroyed = !0, this.clearImageTiles();
|
|
@@ -3944,29 +4132,19 @@ var ur = class {
|
|
|
3944
4132
|
};
|
|
3945
4133
|
}
|
|
3946
4134
|
async setImage(e, t, n) {
|
|
3947
|
-
let r = ++this.imageLoadToken, i = await
|
|
3948
|
-
if (this.destroyed)
|
|
3949
|
-
|
|
3950
|
-
|
|
4135
|
+
let r = ++this.imageLoadToken, i = await Ln(e);
|
|
4136
|
+
if (this.destroyed || r !== this.imageLoadToken) return !0;
|
|
4137
|
+
if (!i) return this.imageWidth ||= t?.width ?? 800, this.imageHeight ||= t?.height ?? 600, !1;
|
|
4138
|
+
this.imageWidth = t?.width ?? i.naturalWidth, this.imageHeight = t?.height ?? i.naturalHeight;
|
|
4139
|
+
let a = n?.width ?? this.imageWidth, o = n?.height ?? this.imageHeight;
|
|
4140
|
+
this.bgLayer.scale.set(a / i.naturalWidth, o / i.naturalHeight), this.clearImageTiles();
|
|
4141
|
+
for (let e of qn(i.naturalWidth, i.naturalHeight, this.tileSize)) {
|
|
4142
|
+
let t = I.from(Jn(i, e));
|
|
4143
|
+
t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
|
|
4144
|
+
let n = new te(t);
|
|
4145
|
+
n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
|
|
3951
4146
|
}
|
|
3952
|
-
|
|
3953
|
-
let o = new Image();
|
|
3954
|
-
i || (o.crossOrigin = "anonymous"), o.onload = () => {
|
|
3955
|
-
if (i && URL.revokeObjectURL(i), this.destroyed || r !== this.imageLoadToken) return a();
|
|
3956
|
-
this.imageWidth = t?.width ?? o.naturalWidth, this.imageHeight = t?.height ?? o.naturalHeight;
|
|
3957
|
-
let e = n?.width ?? this.imageWidth, s = n?.height ?? this.imageHeight;
|
|
3958
|
-
this.bgLayer.scale.set(e / o.naturalWidth, s / o.naturalHeight), this.clearImageTiles();
|
|
3959
|
-
for (let e of Rn(o.naturalWidth, o.naturalHeight)) {
|
|
3960
|
-
let t = P.from(zn(o, e));
|
|
3961
|
-
t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
|
|
3962
|
-
let n = new re(t);
|
|
3963
|
-
n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
|
|
3964
|
-
}
|
|
3965
|
-
this.applySpriteFilter(), a();
|
|
3966
|
-
}, o.onerror = () => {
|
|
3967
|
-
i && URL.revokeObjectURL(i), this.imageWidth ||= t?.width ?? 800, this.imageHeight ||= t?.height ?? 600, a();
|
|
3968
|
-
}, o.src = i ?? e;
|
|
3969
|
-
});
|
|
4147
|
+
return this.applySpriteFilter(), !0;
|
|
3970
4148
|
}
|
|
3971
4149
|
setFilter(e, t) {
|
|
3972
4150
|
this.brightness = e, this.contrast = t, this.applySpriteFilter();
|
|
@@ -4006,14 +4184,14 @@ var ur = class {
|
|
|
4006
4184
|
for (let e of this.guideOverlayLayer.removeChildren()) e.destroy();
|
|
4007
4185
|
for (let e of this.overlayTextures) e.destroy(!0);
|
|
4008
4186
|
if (this.overlayTextures = [], e) {
|
|
4009
|
-
let t =
|
|
4187
|
+
let t = I.from(e);
|
|
4010
4188
|
t.source.scaleMode = "nearest", this.overlayTextures.push(t);
|
|
4011
|
-
let n = new
|
|
4189
|
+
let n = new te(t);
|
|
4012
4190
|
n.alpha = .55, this.guideOverlayLayer.addChild(n);
|
|
4013
4191
|
}
|
|
4014
4192
|
this.setRegionOverlay(t);
|
|
4015
4193
|
for (let e of this.dimOverlayLayer.removeChildren()) e.destroy();
|
|
4016
|
-
n && this.imageWidth && this.dimOverlayLayer.addChild(new
|
|
4194
|
+
n && this.imageWidth && this.dimOverlayLayer.addChild(new P().rect(0, 0, this.imageWidth, this.imageHeight).fill({
|
|
4017
4195
|
color: 855314,
|
|
4018
4196
|
alpha: .3
|
|
4019
4197
|
})), !this.destroyed && this.app.renderer && this.app.render();
|
|
@@ -4041,7 +4219,7 @@ var ur = class {
|
|
|
4041
4219
|
}
|
|
4042
4220
|
applyViewport(e) {
|
|
4043
4221
|
let t = e.scale !== this.lastAppliedScale;
|
|
4044
|
-
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 ??
|
|
4222
|
+
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 ?? nr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.cb.onViewportChange?.();
|
|
4045
4223
|
}
|
|
4046
4224
|
fit() {
|
|
4047
4225
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -4077,7 +4255,7 @@ var ur = class {
|
|
|
4077
4255
|
});
|
|
4078
4256
|
}
|
|
4079
4257
|
setShapes(e, t) {
|
|
4080
|
-
this.shapes =
|
|
4258
|
+
this.shapes = ir(e), this.selected = t, !this.activeDrag && (this.drawShapes(), this.drawSelectionBorders(), this.drawTransformer());
|
|
4081
4259
|
}
|
|
4082
4260
|
setSelection(e) {
|
|
4083
4261
|
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());
|
|
@@ -4100,10 +4278,10 @@ var ur = class {
|
|
|
4100
4278
|
this.handleLayer.interactiveChildren = !e;
|
|
4101
4279
|
}
|
|
4102
4280
|
strokeW(e) {
|
|
4103
|
-
return (e ? Ue(e, { strokeWidth: this.strokeSize }).strokeWidth :
|
|
4281
|
+
return (e ? Ue(e, { strokeWidth: this.strokeSize }).strokeWidth : gr) / this.world.scale.x;
|
|
4104
4282
|
}
|
|
4105
4283
|
pointRadius(e) {
|
|
4106
|
-
return
|
|
4284
|
+
return sr(e, this.strokeSize, this.world.scale.x);
|
|
4107
4285
|
}
|
|
4108
4286
|
dashForShape(e) {
|
|
4109
4287
|
let t = Ue(e, { strokeWidth: this.strokeSize }).dash;
|
|
@@ -4115,9 +4293,9 @@ var ur = class {
|
|
|
4115
4293
|
this.shapeLayer.removeChildren();
|
|
4116
4294
|
for (let e of this.nodes.values()) e.destroy();
|
|
4117
4295
|
this.nodes.clear();
|
|
4118
|
-
for (let e of
|
|
4119
|
-
let t = new
|
|
4120
|
-
this.paintShape(t, e), t.eventMode =
|
|
4296
|
+
for (let e of ae(this.shapes).filter(ne)) {
|
|
4297
|
+
let t = new P();
|
|
4298
|
+
this.paintShape(t, e), t.eventMode = R(e) ? "static" : "none", t.cursor = void 0, R(e) && z(e) && (t.on("pointerover", () => {
|
|
4121
4299
|
!this.activeDrag && this.transformEnabled && this.emitCursorHint("grab");
|
|
4122
4300
|
}), t.on("pointerout", () => {
|
|
4123
4301
|
this.activeDrag || this.emitCursorHint(null);
|
|
@@ -4129,14 +4307,14 @@ var ur = class {
|
|
|
4129
4307
|
paintShape(e, t) {
|
|
4130
4308
|
e.clear();
|
|
4131
4309
|
let n = Ue(t, { strokeWidth: this.strokeSize }), r = $(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
|
|
4132
|
-
if (t.type ===
|
|
4133
|
-
e.svg(
|
|
4310
|
+
if (t.type === L.POINT) {
|
|
4311
|
+
e.svg(Qn(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
|
|
4134
4312
|
let r = 1 / (this.world.scale.x || 1);
|
|
4135
4313
|
e.scale.set(r, r), e.alpha = a;
|
|
4136
4314
|
return;
|
|
4137
4315
|
}
|
|
4138
|
-
if (n.fillVisible && t.type !==
|
|
4139
|
-
let i = t.type ===
|
|
4316
|
+
if (n.fillVisible && t.type !== L.LINE) {
|
|
4317
|
+
let i = t.type === L.POLYGON ? De(t.points) : null;
|
|
4140
4318
|
if (i && i.length > 1) for (let t of i) e.poly(t.flatMap((e) => [e.x, e.y]), !0), e.fill({
|
|
4141
4319
|
color: r,
|
|
4142
4320
|
alpha: n.fillAlpha * a
|
|
@@ -4145,7 +4323,7 @@ var ur = class {
|
|
|
4145
4323
|
color: r,
|
|
4146
4324
|
alpha: n.fillAlpha * a
|
|
4147
4325
|
});
|
|
4148
|
-
} else t.type !==
|
|
4326
|
+
} else t.type !== L.LINE && (this.path(e, t), e.fill({
|
|
4149
4327
|
color: r,
|
|
4150
4328
|
alpha: 0
|
|
4151
4329
|
}));
|
|
@@ -4171,11 +4349,11 @@ var ur = class {
|
|
|
4171
4349
|
});
|
|
4172
4350
|
}
|
|
4173
4351
|
shapesIntersecting(e) {
|
|
4174
|
-
return
|
|
4352
|
+
return or(this.shapes, e);
|
|
4175
4353
|
}
|
|
4176
4354
|
shapesAt(e) {
|
|
4177
4355
|
return this.shapes.filter((t) => {
|
|
4178
|
-
let n =
|
|
4356
|
+
let n = V(t.points);
|
|
4179
4357
|
return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
|
|
4180
4358
|
}).map((e) => e.id);
|
|
4181
4359
|
}
|
|
@@ -4202,7 +4380,7 @@ var ur = class {
|
|
|
4202
4380
|
}, this.ensurePreview(), this.previewG.clear();
|
|
4203
4381
|
let i = {
|
|
4204
4382
|
id: "__preview__",
|
|
4205
|
-
type: e === "ellipse" ?
|
|
4383
|
+
type: e === "ellipse" ? L.ELLIPSE : L.RECTANGLE,
|
|
4206
4384
|
points: [t, n],
|
|
4207
4385
|
style: r
|
|
4208
4386
|
}, a = this.strokeW(i);
|
|
@@ -4233,7 +4411,7 @@ var ur = class {
|
|
|
4233
4411
|
}, this.ensurePreview(), this.previewG.clear(), !e.length) return;
|
|
4234
4412
|
let o = t ? [...e, t] : e, s = {
|
|
4235
4413
|
id: "__preview__",
|
|
4236
|
-
type: r ?
|
|
4414
|
+
type: r ? L.POLYGON : L.LINE,
|
|
4237
4415
|
points: o,
|
|
4238
4416
|
style: n
|
|
4239
4417
|
}, c = this.strokeW(s);
|
|
@@ -4259,7 +4437,7 @@ var ur = class {
|
|
|
4259
4437
|
previewScalarMask(e, t) {
|
|
4260
4438
|
this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
|
|
4261
4439
|
let n = hn(e, t.length === 7 ? `${t}99` : t);
|
|
4262
|
-
this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture =
|
|
4440
|
+
this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture = I.from(n), this.previewMaskSprite ? (this.previewMaskSprite.texture = this.previewMaskTexture, this.previewMaskSprite.visible = !0) : (this.previewMaskSprite = new te(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;
|
|
4263
4441
|
}
|
|
4264
4442
|
previewMarquee(e, t) {
|
|
4265
4443
|
this.ensurePreview(), this.marqueeG.clear();
|
|
@@ -4304,27 +4482,27 @@ var ur = class {
|
|
|
4304
4482
|
}
|
|
4305
4483
|
path(e, t) {
|
|
4306
4484
|
let { type: n, points: r } = t;
|
|
4307
|
-
if (n ===
|
|
4485
|
+
if (n === L.POINT) {
|
|
4308
4486
|
e.circle(r[0].x, r[0].y, this.pointRadius(t));
|
|
4309
4487
|
return;
|
|
4310
4488
|
}
|
|
4311
|
-
if (n ===
|
|
4312
|
-
let t =
|
|
4489
|
+
if (n === L.RECTANGLE) {
|
|
4490
|
+
let t = V(r);
|
|
4313
4491
|
e.rect(t.minX, t.minY, t.maxX - t.minX, t.maxY - t.minY);
|
|
4314
4492
|
return;
|
|
4315
4493
|
}
|
|
4316
|
-
if (n ===
|
|
4317
|
-
let t =
|
|
4494
|
+
if (n === L.ELLIPSE) {
|
|
4495
|
+
let t = V(r);
|
|
4318
4496
|
e.ellipse((t.minX + t.maxX) / 2, (t.minY + t.maxY) / 2, (t.maxX - t.minX) / 2, (t.maxY - t.minY) / 2);
|
|
4319
4497
|
return;
|
|
4320
4498
|
}
|
|
4321
4499
|
let i = r.flatMap((e) => [e.x, e.y]);
|
|
4322
|
-
e.poly(i, n !==
|
|
4500
|
+
e.poly(i, n !== L.LINE);
|
|
4323
4501
|
}
|
|
4324
4502
|
dashedStrokeShape(e, t, n, r, i, a) {
|
|
4325
4503
|
let { type: o, points: s } = t;
|
|
4326
|
-
if (o ===
|
|
4327
|
-
let t =
|
|
4504
|
+
if (o === L.RECTANGLE) {
|
|
4505
|
+
let t = V(s);
|
|
4328
4506
|
this.strokeDashedPolyline(e, [
|
|
4329
4507
|
{
|
|
4330
4508
|
x: t.minX,
|
|
@@ -4345,8 +4523,8 @@ var ur = class {
|
|
|
4345
4523
|
], !0, n, r, i, a);
|
|
4346
4524
|
return;
|
|
4347
4525
|
}
|
|
4348
|
-
if (o ===
|
|
4349
|
-
let t =
|
|
4526
|
+
if (o === L.ELLIPSE) {
|
|
4527
|
+
let t = V(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) => {
|
|
4350
4528
|
let n = t / 96 * Math.PI * 2;
|
|
4351
4529
|
return {
|
|
4352
4530
|
x: o + Math.cos(n) * l,
|
|
@@ -4356,7 +4534,7 @@ var ur = class {
|
|
|
4356
4534
|
this.strokeDashedPolyline(e, d, !0, n, r, i, a);
|
|
4357
4535
|
return;
|
|
4358
4536
|
}
|
|
4359
|
-
this.strokeDashedPolyline(e, s, o !==
|
|
4537
|
+
this.strokeDashedPolyline(e, s, o !== L.LINE, n, r, i, a);
|
|
4360
4538
|
}
|
|
4361
4539
|
strokeDashedPolyline(e, t, n, r, i, a, o) {
|
|
4362
4540
|
if (t.length < 2) return;
|
|
@@ -4397,11 +4575,11 @@ var ur = class {
|
|
|
4397
4575
|
}
|
|
4398
4576
|
drawSelectionBorders() {
|
|
4399
4577
|
this.selLayer.position.set(0, 0);
|
|
4400
|
-
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) &&
|
|
4578
|
+
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && R(t)) : [];
|
|
4401
4579
|
if (this.selectionBorderGfx.length !== t.length) {
|
|
4402
4580
|
for (let e of this.selectionBorderGfx) e.destroy();
|
|
4403
4581
|
this.selectionBorderGfx = t.map(() => {
|
|
4404
|
-
let e = new
|
|
4582
|
+
let e = new P();
|
|
4405
4583
|
return this.selLayer.addChild(e), e;
|
|
4406
4584
|
});
|
|
4407
4585
|
}
|
|
@@ -4410,23 +4588,23 @@ var ur = class {
|
|
|
4410
4588
|
let r = this.selectionBorderGfx[t];
|
|
4411
4589
|
r.clear(), r.poly(this.selectionOutlinePoints(e, e.points).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4412
4590
|
width: n,
|
|
4413
|
-
color:
|
|
4591
|
+
color: vr
|
|
4414
4592
|
});
|
|
4415
4593
|
});
|
|
4416
4594
|
}
|
|
4417
4595
|
updateSelectionBordersLive(e) {
|
|
4418
4596
|
let t = new Set(this.selected), n = 1.5 / this.world.scale.x, r = 0;
|
|
4419
4597
|
for (let i of this.shapes) {
|
|
4420
|
-
if (!t.has(i.id) || !
|
|
4598
|
+
if (!t.has(i.id) || !R(i)) continue;
|
|
4421
4599
|
let a = this.selectionBorderGfx[r++];
|
|
4422
4600
|
a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4423
4601
|
width: n,
|
|
4424
|
-
color:
|
|
4602
|
+
color: vr
|
|
4425
4603
|
}));
|
|
4426
4604
|
}
|
|
4427
4605
|
}
|
|
4428
4606
|
selectionOutlinePoints(e, t) {
|
|
4429
|
-
return
|
|
4607
|
+
return lr(e, t, this.pointRadius(e));
|
|
4430
4608
|
}
|
|
4431
4609
|
imgToScreen(e) {
|
|
4432
4610
|
let t = this.world.toGlobal({
|
|
@@ -4440,7 +4618,7 @@ var ur = class {
|
|
|
4440
4618
|
}
|
|
4441
4619
|
setTransformerOutline(e) {
|
|
4442
4620
|
let t = e.maxX - e.minX, n = e.maxY - e.minY;
|
|
4443
|
-
t <= 0 && n <= 0 || this.setTransformerOutlinePoints(
|
|
4621
|
+
t <= 0 && n <= 0 || this.setTransformerOutlinePoints(ue([{
|
|
4444
4622
|
x: e.minX,
|
|
4445
4623
|
y: e.minY
|
|
4446
4624
|
}, {
|
|
@@ -4449,20 +4627,20 @@ var ur = class {
|
|
|
4449
4627
|
}]));
|
|
4450
4628
|
}
|
|
4451
4629
|
setTransformerOutlinePoints(e) {
|
|
4452
|
-
e.length < 2 || (this.transformerOutline || (this.transformerOutline = new
|
|
4630
|
+
e.length < 2 || (this.transformerOutline || (this.transformerOutline = new P(), this.selLayer.addChild(this.transformerOutline)), this.transformerOutline.clear(), this.transformerOutline.poly(e.flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4453
4631
|
width: 1 / this.world.scale.x,
|
|
4454
4632
|
color: 2001125
|
|
4455
4633
|
}));
|
|
4456
4634
|
}
|
|
4457
4635
|
rotationHandleGap() {
|
|
4458
|
-
return
|
|
4636
|
+
return ur(this.viewport.scale);
|
|
4459
4637
|
}
|
|
4460
4638
|
rotationHandleScreenPoint(e) {
|
|
4461
|
-
return this.imgToScreen(
|
|
4639
|
+
return this.imgToScreen(xe(e, this.rotationHandleGap()));
|
|
4462
4640
|
}
|
|
4463
4641
|
setRotationConnector(e) {
|
|
4464
|
-
let t = this.imgToScreen(
|
|
4465
|
-
this.rotLineNode || (this.rotLineNode = new
|
|
4642
|
+
let t = this.imgToScreen(ve(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
|
|
4643
|
+
this.rotLineNode || (this.rotLineNode = new P(), 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({
|
|
4466
4644
|
width: 1,
|
|
4467
4645
|
color: 2001125
|
|
4468
4646
|
});
|
|
@@ -4471,7 +4649,7 @@ var ur = class {
|
|
|
4471
4649
|
e.position.set(t.x, t.y), e.rotation = n;
|
|
4472
4650
|
}
|
|
4473
4651
|
orientedHandleAngle(e) {
|
|
4474
|
-
return
|
|
4652
|
+
return dr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
4475
4653
|
}
|
|
4476
4654
|
drawTransformer() {
|
|
4477
4655
|
if (this.activeDrag) return;
|
|
@@ -4479,13 +4657,13 @@ var ur = class {
|
|
|
4479
4657
|
for (let e of this.vertexNodes) e.destroy();
|
|
4480
4658
|
for (let e of this.midNodes) e.destroy();
|
|
4481
4659
|
if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
4482
|
-
let e =
|
|
4483
|
-
if (e.length === 0 || e.length === 1 && e[0].type ===
|
|
4484
|
-
let t = e.length === 1 && (e[0].type ===
|
|
4660
|
+
let e = ar(this.shapes, this.selected);
|
|
4661
|
+
if (e.length === 0 || e.length === 1 && e[0].type === L.POINT) return;
|
|
4662
|
+
let t = e.length === 1 && (e[0].type === L.POLYGON || e[0].type === L.LINE) && this.editingId === e[0].id ? e[0] : null, n = V(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === L.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : B.map((e) => se(e, n));
|
|
4485
4663
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
4486
4664
|
let a = r ? this.orientedHandleAngle(r.points) : 0;
|
|
4487
|
-
for (let e of t ? [] :
|
|
4488
|
-
let t = this.imgToScreen(i[
|
|
4665
|
+
for (let e of t ? [] : B) {
|
|
4666
|
+
let t = this.imgToScreen(i[B.indexOf(e)]), n = new P();
|
|
4489
4667
|
n.rect(-4, -4, 8, 8).fill({ color: 16777215 }).stroke({
|
|
4490
4668
|
width: 1,
|
|
4491
4669
|
color: 2001125
|
|
@@ -4493,11 +4671,11 @@ var ur = class {
|
|
|
4493
4671
|
let r = wt(e, a);
|
|
4494
4672
|
this.bindCursor(n, r), n.on("pointerdown", (t) => {
|
|
4495
4673
|
t.stopPropagation(), this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
4496
|
-
let n =
|
|
4674
|
+
let n = ar(this.shapes, this.selected);
|
|
4497
4675
|
this.activeDrag = {
|
|
4498
4676
|
kind: "resize",
|
|
4499
4677
|
anchor: e,
|
|
4500
|
-
box:
|
|
4678
|
+
box: V(n.flatMap((e) => e.points)),
|
|
4501
4679
|
shapes: n.map((e) => ({
|
|
4502
4680
|
id: e.id,
|
|
4503
4681
|
points: e.points
|
|
@@ -4506,7 +4684,7 @@ var ur = class {
|
|
|
4506
4684
|
}), this.handleLayer.addChild(n), this.handleNodes.push(n);
|
|
4507
4685
|
}
|
|
4508
4686
|
if (t) {
|
|
4509
|
-
let e = t, n = e.points, r = e.type ===
|
|
4687
|
+
let e = t, n = e.points, r = e.type === L.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new P();
|
|
4510
4688
|
a.circle(0, 0, i * .8).fill({
|
|
4511
4689
|
color: 16777215,
|
|
4512
4690
|
alpha: .6
|
|
@@ -4515,7 +4693,7 @@ var ur = class {
|
|
|
4515
4693
|
color: 2001125
|
|
4516
4694
|
}), a.visible = !1, a.eventMode = "none", this.handleLayer.addChild(a), this.ghostNode = a;
|
|
4517
4695
|
for (let t = 0; t < r; t++) {
|
|
4518
|
-
let r = n[t], i = n[(t + 1) % n.length], o = new
|
|
4696
|
+
let r = n[t], i = n[(t + 1) % n.length], o = new P();
|
|
4519
4697
|
o.hitArea = this.edgeHitQuad(r, i), o.eventMode = "static", this.bindCursor(o, "copy");
|
|
4520
4698
|
let s = (e) => {
|
|
4521
4699
|
let t = this.toImage(e), n = i.x - r.x, a = i.y - r.y, o = n * n + a * a, s = o ? Math.max(0, Math.min(1, ((t.x - r.x) * n + (t.y - r.y) * a) / o)) : 0;
|
|
@@ -4550,7 +4728,7 @@ var ur = class {
|
|
|
4550
4728
|
}), this.handleLayer.addChild(o), this.midNodes.push(o);
|
|
4551
4729
|
}
|
|
4552
4730
|
this.vertexPolygonId !== e.id && (this.vertexPolygonId = e.id, this.selectedVertices.clear()), n.forEach((t, r) => {
|
|
4553
|
-
let a = this.imgToScreen(t), o = this.selectedVertices.has(r), s = new
|
|
4731
|
+
let a = this.imgToScreen(t), o = this.selectedVertices.has(r), s = new P();
|
|
4554
4732
|
s.circle(0, 0, i).fill({ color: o ? 2001125 : 16777215 }).stroke({
|
|
4555
4733
|
width: Math.max(1.5, i * .3),
|
|
4556
4734
|
color: o ? 16777215 : 2001125
|
|
@@ -4570,8 +4748,8 @@ var ur = class {
|
|
|
4570
4748
|
}), this.handleLayer.addChild(s), this.vertexNodes.push(s);
|
|
4571
4749
|
});
|
|
4572
4750
|
}
|
|
4573
|
-
if (e.length === 1 && e[0].type ===
|
|
4574
|
-
let t = e[0], n =
|
|
4751
|
+
if (e.length === 1 && e[0].type === L.ROTATED_RECTANGLE) {
|
|
4752
|
+
let t = e[0], n = ye(t.points), r = this.rotationHandleScreenPoint(t.points), i = new P();
|
|
4575
4753
|
i.circle(0, 0, 6).fill({ color: 16777215 }).stroke({
|
|
4576
4754
|
width: 1.5,
|
|
4577
4755
|
color: 2001125
|
|
@@ -4590,18 +4768,18 @@ var ur = class {
|
|
|
4590
4768
|
}
|
|
4591
4769
|
}
|
|
4592
4770
|
beginMove(e, t) {
|
|
4593
|
-
let n =
|
|
4594
|
-
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 ===
|
|
4771
|
+
let n = rr(this.shapes, t, e);
|
|
4772
|
+
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === L.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4595
4773
|
}
|
|
4596
4774
|
repositionHandlesForBox(e) {
|
|
4597
|
-
|
|
4598
|
-
let r = this.imgToScreen(
|
|
4775
|
+
B.forEach((t, n) => {
|
|
4776
|
+
let r = this.imgToScreen(se(t, e)), i = this.handleNodes[n];
|
|
4599
4777
|
i && this.layoutResizeHandle(i, r, 0);
|
|
4600
4778
|
}), this.setTransformerOutline(e);
|
|
4601
4779
|
}
|
|
4602
4780
|
repositionOrientedHandles(e) {
|
|
4603
4781
|
let t = this.orientedHandleAngle(e);
|
|
4604
|
-
if (
|
|
4782
|
+
if (be(e).forEach((e, n) => {
|
|
4605
4783
|
let r = this.imgToScreen(e), i = this.handleNodes[n];
|
|
4606
4784
|
i && this.layoutResizeHandle(i, r, t);
|
|
4607
4785
|
}), this.setTransformerOutlinePoints(e), this.rotNode) {
|
|
@@ -4624,7 +4802,7 @@ var ur = class {
|
|
|
4624
4802
|
}
|
|
4625
4803
|
edgeHitQuad(e, t) {
|
|
4626
4804
|
let n = Math.max(7, this.vertexHandleRadius() + 2), r = this.imgToScreen(e), i = this.imgToScreen(t), a = i.x - r.x, o = i.y - r.y, s = Math.hypot(a, o) || 1, c = -o / s * n, l = a / s * n;
|
|
4627
|
-
return new
|
|
4805
|
+
return new F([
|
|
4628
4806
|
r.x + c,
|
|
4629
4807
|
r.y + l,
|
|
4630
4808
|
i.x + c,
|
|
@@ -4636,7 +4814,7 @@ var ur = class {
|
|
|
4636
4814
|
]);
|
|
4637
4815
|
}
|
|
4638
4816
|
resetMoveOffsets() {
|
|
4639
|
-
for (let [e, t] of this.nodes) this.shapes.find((t) => t.id === e)?.type !==
|
|
4817
|
+
for (let [e, t] of this.nodes) this.shapes.find((t) => t.id === e)?.type !== L.POINT && t.position.set(0, 0);
|
|
4640
4818
|
this.selLayer.position.set(0, 0);
|
|
4641
4819
|
}
|
|
4642
4820
|
commitTransformUpdates(e) {
|
|
@@ -4658,26 +4836,26 @@ var ur = class {
|
|
|
4658
4836
|
let t = this.activeDrag;
|
|
4659
4837
|
if (!t) return;
|
|
4660
4838
|
this.applyCursor();
|
|
4661
|
-
let n =
|
|
4839
|
+
let n = er(this.shapes, t), { updates: r, box: i } = tr(t, e, n);
|
|
4662
4840
|
if (t.kind === "move") {
|
|
4663
4841
|
let n = e.x - t.start.x, r = e.y - t.start.y;
|
|
4664
4842
|
for (let e of t.shapes) {
|
|
4665
4843
|
let t = this.nodes.get(e.id);
|
|
4666
|
-
t && (this.shapes.find((t) => t.id === e.id)?.type ===
|
|
4844
|
+
t && (this.shapes.find((t) => t.id === e.id)?.type === L.POINT ? t.position.set(e.points[0].x + n, e.points[0].y + r) : t.position.set(n, r));
|
|
4667
4845
|
}
|
|
4668
4846
|
} else for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
4669
4847
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
4670
4848
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandlesForBox(i);
|
|
4671
|
-
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type ===
|
|
4672
|
-
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
4849
|
+
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === L.POLYGON || e?.type === L.LINE;
|
|
4850
|
+
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
|
|
4673
4851
|
} else if (t.kind === "rotate") {
|
|
4674
4852
|
this.repositionOrientedHandles(r[0].points);
|
|
4675
4853
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
4676
|
-
e && (e.type ===
|
|
4854
|
+
e && (e.type === L.POLYGON || e.type === L.LINE) && this.repositionPolygonHandles(r[0].points, e.type === L.POLYGON);
|
|
4677
4855
|
} else {
|
|
4678
4856
|
i && this.repositionHandlesForBox(i);
|
|
4679
4857
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
4680
|
-
this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
4858
|
+
this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
|
|
4681
4859
|
}
|
|
4682
4860
|
}
|
|
4683
4861
|
endTransform() {
|
|
@@ -4690,13 +4868,13 @@ var ur = class {
|
|
|
4690
4868
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
4691
4869
|
return;
|
|
4692
4870
|
}
|
|
4693
|
-
let { updates: n } =
|
|
4871
|
+
let { updates: n } = tr(e, t, er(this.shapes, e));
|
|
4694
4872
|
e.kind === "move" && this.resetMoveOffsets(), this.commitTransformUpdates(n);
|
|
4695
4873
|
}
|
|
4696
4874
|
};
|
|
4697
4875
|
//#endregion
|
|
4698
4876
|
//#region src/components/ShapeEditor/_state/useEngineLifecycle.ts
|
|
4699
|
-
function
|
|
4877
|
+
function br({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r }) {
|
|
4700
4878
|
if (!r) return e !== null || n !== null ? { kind: "clear" } : { kind: "none" };
|
|
4701
4879
|
let i = e !== t;
|
|
4702
4880
|
return !i && n === r ? { kind: "none" } : {
|
|
@@ -4704,7 +4882,7 @@ function dr({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r
|
|
|
4704
4882
|
docChange: i
|
|
4705
4883
|
};
|
|
4706
4884
|
}
|
|
4707
|
-
function
|
|
4885
|
+
function xr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImageUrl: i, makeCallbacks: a, viewRef: o, readOnlyRef: s, toolRef: c, renderShapesRef: l, coordinateSizeRef: u, imageSizeRef: d, selRef: f, maskCanvasRef: p, regionOverlayRef: m, dimmedRef: h, syncMinimap: g, setImage: _, setImageVisible: v, setReady: y, setImageStatus: b, onContextMenuRequest: x }) {
|
|
4708
4886
|
let C = O(i);
|
|
4709
4887
|
C.current = i;
|
|
4710
4888
|
let w = O(r);
|
|
@@ -4715,39 +4893,59 @@ function fr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
4715
4893
|
j.current = x, S(() => {
|
|
4716
4894
|
let r = t.current;
|
|
4717
4895
|
if (!r) return;
|
|
4718
|
-
let i = !1, a = null,
|
|
4719
|
-
return n.current =
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4896
|
+
let i = !1, a = null, x = null, S = A.current(), O = e === "konva" ? new hr(r, S) : new yr(r, S);
|
|
4897
|
+
return n.current = O, (async () => {
|
|
4898
|
+
try {
|
|
4899
|
+
await O.init();
|
|
4900
|
+
} catch (e) {
|
|
4901
|
+
i || b("error", Gn(e));
|
|
4902
|
+
return;
|
|
4903
|
+
}
|
|
4904
|
+
if (i) return;
|
|
4905
|
+
if (O.setFilter(o.current.brightness, o.current.contrast), O.setRenderDefaults({ strokeWidth: o.current.strokeSize }), O.setImageSmoothing(o.current.imageSmoothing), O.setTransformEnabled(!s.current), D.current = !0, C.current) {
|
|
4906
|
+
let e = C.current, t = w.current;
|
|
4907
|
+
b("loading");
|
|
4908
|
+
let n = null;
|
|
4909
|
+
try {
|
|
4910
|
+
n = await O.setImage(e, u.current, d.current);
|
|
4911
|
+
} catch (t) {
|
|
4912
|
+
!i && C.current === e && b("error", Gn(t));
|
|
4913
|
+
}
|
|
4914
|
+
if (i) return;
|
|
4915
|
+
if (n !== null) {
|
|
4916
|
+
T.current = e, E.current = t, _({
|
|
4917
|
+
w: O.imageWidth,
|
|
4918
|
+
h: O.imageHeight
|
|
4919
|
+
}), v(!0), O.setShapes(l.current, f.current), O.setOverlays(o.current.showGuide ? p.current : null, o.current.showRegionMask ? m.current : null, h.current);
|
|
4920
|
+
let r = k.current;
|
|
4921
|
+
r?.viewport && (r.imageUrl === T.current || o.current.keepZoomOnImageChange) ? O.applyViewport(r.viewport) : O.fit(), g(), y(!0);
|
|
4922
|
+
let a = () => C.current === e;
|
|
4923
|
+
n ? a() && b("ready") : Hn(e).then((e) => {
|
|
4924
|
+
!i && a() && b("error", e);
|
|
4925
|
+
});
|
|
4926
|
+
}
|
|
4729
4927
|
}
|
|
4730
4928
|
let e = (e, t) => Math.exp(-Math.sign(e) * Math.min(Math.abs(e) * .01, .1) * t);
|
|
4731
4929
|
a = (t) => {
|
|
4732
4930
|
t.preventDefault();
|
|
4733
|
-
let n =
|
|
4931
|
+
let n = O.dom.getBoundingClientRect(), r = o.current.zoomSensitivity ?? 1;
|
|
4734
4932
|
if (t.ctrlKey || t.metaKey) {
|
|
4735
|
-
|
|
4933
|
+
O.zoomAt(t.clientX - n.left, t.clientY - n.top, e(t.deltaY, r));
|
|
4736
4934
|
return;
|
|
4737
4935
|
}
|
|
4738
4936
|
if (!o.current.wheelZoom) {
|
|
4739
|
-
let e =
|
|
4740
|
-
|
|
4937
|
+
let e = O.viewport;
|
|
4938
|
+
O.applyViewport({
|
|
4741
4939
|
scale: e.scale,
|
|
4742
4940
|
x: e.x - t.deltaX,
|
|
4743
4941
|
y: e.y - t.deltaY
|
|
4744
4942
|
});
|
|
4745
4943
|
return;
|
|
4746
4944
|
}
|
|
4747
|
-
|
|
4748
|
-
},
|
|
4749
|
-
if (e.preventDefault(), c.current ===
|
|
4750
|
-
let t = r.getBoundingClientRect(), n = e.clientX - t.left, i = e.clientY - t.top, a =
|
|
4945
|
+
O.zoomAt(t.clientX - n.left, t.clientY - n.top, e(t.deltaY, r));
|
|
4946
|
+
}, O.dom.addEventListener("wheel", a, { passive: !1 }), x = (e) => {
|
|
4947
|
+
if (e.preventDefault(), c.current === G.ASSISTANT_POINT && e.altKey) return;
|
|
4948
|
+
let t = r.getBoundingClientRect(), n = e.clientX - t.left, i = e.clientY - t.top, a = O.viewport;
|
|
4751
4949
|
j.current({
|
|
4752
4950
|
x: n,
|
|
4753
4951
|
y: i,
|
|
@@ -4756,17 +4954,17 @@ function fr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
4756
4954
|
y: (i - a.y) / a.scale
|
|
4757
4955
|
}
|
|
4758
4956
|
});
|
|
4759
|
-
},
|
|
4957
|
+
}, O.dom.addEventListener("contextmenu", x);
|
|
4760
4958
|
})(), () => {
|
|
4761
4959
|
i = !0, D.current = !1, k.current = {
|
|
4762
4960
|
imageUrl: T.current ?? "",
|
|
4763
|
-
viewport:
|
|
4764
|
-
}, n.current = null, a &&
|
|
4961
|
+
viewport: O.viewport
|
|
4962
|
+
}, n.current = null, a && O.dom && O.dom.removeEventListener("wheel", a), x && O.dom && O.dom.removeEventListener("contextmenu", x), O.destroy();
|
|
4765
4963
|
};
|
|
4766
4964
|
}, [e]), S(() => {
|
|
4767
4965
|
let e = n.current;
|
|
4768
4966
|
if (!e || !D.current) return;
|
|
4769
|
-
let t =
|
|
4967
|
+
let t = br({
|
|
4770
4968
|
currentDocId: E.current,
|
|
4771
4969
|
documentId: r,
|
|
4772
4970
|
loadedUrl: T.current,
|
|
@@ -4777,52 +4975,60 @@ function fr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
4777
4975
|
y(!1), v(!1), e.clearImage(), e.setShapes([], []), e.setOverlays(null, null, !1);
|
|
4778
4976
|
};
|
|
4779
4977
|
if (t.kind === "clear") {
|
|
4780
|
-
T.current = null, E.current = null, a();
|
|
4978
|
+
T.current = null, E.current = null, a(), b("loading");
|
|
4781
4979
|
return;
|
|
4782
4980
|
}
|
|
4783
4981
|
let s = i;
|
|
4784
4982
|
t.docChange && (E.current = null, a());
|
|
4785
4983
|
let c = !1;
|
|
4786
4984
|
return (async () => {
|
|
4787
|
-
|
|
4985
|
+
b("loading");
|
|
4986
|
+
let i = !1;
|
|
4987
|
+
try {
|
|
4988
|
+
i = await e.setImage(s, u.current, d.current);
|
|
4989
|
+
} catch (t) {
|
|
4990
|
+
!c && n.current === e && b("error", Gn(t));
|
|
4991
|
+
return;
|
|
4992
|
+
}
|
|
4993
|
+
if (c || n.current !== e) return;
|
|
4994
|
+
T.current = s;
|
|
4995
|
+
let a = () => {
|
|
4996
|
+
if (i) {
|
|
4997
|
+
b("ready");
|
|
4998
|
+
return;
|
|
4999
|
+
}
|
|
5000
|
+
Hn(s).then((e) => {
|
|
5001
|
+
c || b("error", e);
|
|
5002
|
+
});
|
|
5003
|
+
};
|
|
5004
|
+
if (!t.docChange) {
|
|
5005
|
+
a();
|
|
5006
|
+
return;
|
|
5007
|
+
}
|
|
5008
|
+
E.current = r, _({
|
|
4788
5009
|
w: e.imageWidth,
|
|
4789
5010
|
h: e.imageHeight
|
|
4790
|
-
}), v(!0), e.setShapes(l.current, f.current), e.setOverlays(o.current.showGuide ? p.current : null, o.current.showRegionMask ? m.current : null, h.current), o.current.keepZoomOnImageChange || e.fit(), g(), y(!0))
|
|
5011
|
+
}), v(!0), e.setShapes(l.current, f.current), e.setOverlays(o.current.showGuide ? p.current : null, o.current.showRegionMask ? m.current : null, h.current), o.current.keepZoomOnImageChange || e.fit(), g(), y(!0), a();
|
|
4791
5012
|
})(), () => {
|
|
4792
5013
|
c = !0;
|
|
4793
5014
|
};
|
|
4794
|
-
}, [r, i])
|
|
4795
|
-
let e = !1;
|
|
4796
|
-
if (!i) {
|
|
4797
|
-
b("loading");
|
|
4798
|
-
return;
|
|
4799
|
-
}
|
|
4800
|
-
b("loading");
|
|
4801
|
-
let t = new Image();
|
|
4802
|
-
return t.onload = () => {
|
|
4803
|
-
e || b("ready");
|
|
4804
|
-
}, t.onerror = () => {
|
|
4805
|
-
e || b("error");
|
|
4806
|
-
}, t.src = i, () => {
|
|
4807
|
-
e = !0;
|
|
4808
|
-
};
|
|
4809
|
-
}, [i]);
|
|
5015
|
+
}, [r, i]);
|
|
4810
5016
|
}
|
|
4811
5017
|
//#endregion
|
|
4812
5018
|
//#region src/components/ShapeEditor/_state/useMinimapNavigation.ts
|
|
4813
|
-
var
|
|
4814
|
-
function
|
|
5019
|
+
var Sr = .05, Cr = 20;
|
|
5020
|
+
function wr(e) {
|
|
4815
5021
|
let { deltaY: t, deltaX: n, deltaMode: r } = e;
|
|
4816
5022
|
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);
|
|
4817
5023
|
}
|
|
4818
|
-
function
|
|
5024
|
+
function Tr(e) {
|
|
4819
5025
|
let t = e.currentTarget.getBoundingClientRect();
|
|
4820
5026
|
return {
|
|
4821
5027
|
x: e.clientX - t.left,
|
|
4822
5028
|
y: e.clientY - t.top
|
|
4823
5029
|
};
|
|
4824
5030
|
}
|
|
4825
|
-
function
|
|
5031
|
+
function Er({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
4826
5032
|
let i = O(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 = x(() => {
|
|
4827
5033
|
let t = e.current;
|
|
4828
5034
|
if (!t) return null;
|
|
@@ -4860,7 +5066,7 @@ function _r({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4860
5066
|
let n = e.current, r = d();
|
|
4861
5067
|
if (!n || !r) return;
|
|
4862
5068
|
t.preventDefault(), t.stopPropagation();
|
|
4863
|
-
let a =
|
|
5069
|
+
let a = Tr(t), o = a.x >= r.x && a.x <= r.x + r.width && a.y >= r.y && a.y <= r.y + r.height ? {
|
|
4864
5070
|
offsetX: a.x - r.x,
|
|
4865
5071
|
offsetY: a.y - r.y
|
|
4866
5072
|
} : {
|
|
@@ -4877,7 +5083,7 @@ function _r({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4877
5083
|
d
|
|
4878
5084
|
]), m = x((t) => {
|
|
4879
5085
|
let n = i.current, r = e.current;
|
|
4880
|
-
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(
|
|
5086
|
+
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(Tr(t), r.viewport.scale, n));
|
|
4881
5087
|
}, [f, e]), h = x((e) => {
|
|
4882
5088
|
let t = i.current;
|
|
4883
5089
|
!t || t.pointerId !== e.pointerId || (i.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId));
|
|
@@ -4885,8 +5091,8 @@ function _r({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4885
5091
|
let r = e.current;
|
|
4886
5092
|
if (!r || !n) return;
|
|
4887
5093
|
t.preventDefault(), t.stopPropagation();
|
|
4888
|
-
let i =
|
|
4889
|
-
f(
|
|
5094
|
+
let i = wr(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(Sr, Math.min(Cr, s));
|
|
5095
|
+
f(Tr(t), c);
|
|
4890
5096
|
}, [
|
|
4891
5097
|
f,
|
|
4892
5098
|
e,
|
|
@@ -4923,15 +5129,15 @@ function _r({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4923
5129
|
}
|
|
4924
5130
|
//#endregion
|
|
4925
5131
|
//#region src/components/ShapeEditor/_state/useMinimapSync.ts
|
|
4926
|
-
function
|
|
5132
|
+
function Dr(e, t, n) {
|
|
4927
5133
|
if (!(!e || !n.length)) {
|
|
4928
|
-
if (t.type ===
|
|
5134
|
+
if (t.type === L.POINT) {
|
|
4929
5135
|
e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
|
|
4930
5136
|
return;
|
|
4931
5137
|
}
|
|
4932
|
-
if (t.type ===
|
|
4933
|
-
let r =
|
|
4934
|
-
if (t.type ===
|
|
5138
|
+
if (t.type === L.RECTANGLE || t.type === L.ELLIPSE) {
|
|
5139
|
+
let r = V(n);
|
|
5140
|
+
if (t.type === L.ELLIPSE) {
|
|
4935
5141
|
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));
|
|
4936
5142
|
return;
|
|
4937
5143
|
}
|
|
@@ -4941,7 +5147,7 @@ function vr(e, t, n) {
|
|
|
4941
5147
|
e.setAttribute("points", n.map((e) => `${e.x},${e.y}`).join(" "));
|
|
4942
5148
|
}
|
|
4943
5149
|
}
|
|
4944
|
-
function
|
|
5150
|
+
function Or({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o }) {
|
|
4945
5151
|
let s = O(/* @__PURE__ */ new Map());
|
|
4946
5152
|
return {
|
|
4947
5153
|
registerMinimapShape: x((e, t) => {
|
|
@@ -4950,13 +5156,13 @@ function yr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
4950
5156
|
applyMinimapPreview: x((e) => {
|
|
4951
5157
|
let n = t.current.getShapes();
|
|
4952
5158
|
if (!e.length) {
|
|
4953
|
-
for (let e of n)
|
|
5159
|
+
for (let e of n) Dr(s.current.get(e.id), e, e.points);
|
|
4954
5160
|
return;
|
|
4955
5161
|
}
|
|
4956
5162
|
let r = new Map(n.map((e) => [e.id, e]));
|
|
4957
5163
|
for (let t of e) {
|
|
4958
5164
|
let e = r.get(t.id);
|
|
4959
|
-
e &&
|
|
5165
|
+
e && Dr(s.current.get(e.id), e, t.points);
|
|
4960
5166
|
}
|
|
4961
5167
|
}, [t]),
|
|
4962
5168
|
syncMinimap: x(() => {
|
|
@@ -4985,15 +5191,15 @@ function yr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
4985
5191
|
}
|
|
4986
5192
|
//#endregion
|
|
4987
5193
|
//#region src/components/ShapeEditor/_state/useSelectionActions.ts
|
|
4988
|
-
var
|
|
4989
|
-
function
|
|
5194
|
+
var kr = 12;
|
|
5195
|
+
function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
|
|
4990
5196
|
let s = O(0), c = O(!0), l = O(n), u = O(a), d = O(o);
|
|
4991
5197
|
l.current = n, u.current = a, d.current = o, S(() => (c.current = !0, () => {
|
|
4992
5198
|
c.current = !1;
|
|
4993
5199
|
}), []), S(() => {
|
|
4994
5200
|
s.current = 0;
|
|
4995
5201
|
}, [a]);
|
|
4996
|
-
let f = x(() => r(e.getShapes().filter((e) =>
|
|
5202
|
+
let f = x(() => r(e.getShapes().filter((e) => R(e)).map((e) => e.id)), [e, r]), p = x(() => r([]), [r]), m = x(() => e.getShapes().filter((e) => t.current.includes(e.id) && ie(e)), [e, t]), h = x(() => {
|
|
4997
5203
|
if (n || !t.current.length) return;
|
|
4998
5204
|
let i = m().map((e) => e.id);
|
|
4999
5205
|
i.length && (e.remove(i), r([]));
|
|
@@ -5005,27 +5211,27 @@ function xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5005
5211
|
t
|
|
5006
5212
|
]), g = x(() => {
|
|
5007
5213
|
let e = m();
|
|
5008
|
-
e.length && (s.current = 0,
|
|
5214
|
+
e.length && (s.current = 0, vt(mt(e, a, o)));
|
|
5009
5215
|
}, [
|
|
5010
5216
|
a,
|
|
5011
5217
|
o,
|
|
5012
5218
|
m
|
|
5013
|
-
]), _ = x(() =>
|
|
5219
|
+
]), _ = x(() => Y(o), [o]), v = x((t) => {
|
|
5014
5220
|
if (n) return;
|
|
5015
5221
|
let i = a;
|
|
5016
|
-
|
|
5222
|
+
bt(o).then((n) => {
|
|
5017
5223
|
if (!c.current || l.current || u.current !== i || d.current !== o || !n?.shapes.length) return;
|
|
5018
5224
|
let f, p, m = n.shapes.flatMap((e) => e.points);
|
|
5019
5225
|
if (t && m.length) {
|
|
5020
|
-
let e =
|
|
5226
|
+
let e = V(m);
|
|
5021
5227
|
f = t.x - (e.minX + e.maxX) / 2, p = t.y - (e.minY + e.maxY) / 2;
|
|
5022
5228
|
} else {
|
|
5023
|
-
let e = !!n.documentId && n.documentId !== a, t =
|
|
5229
|
+
let e = !!n.documentId && n.documentId !== a, t = xt(s.current, e, kr);
|
|
5024
5230
|
f = t.offset, s.current = t.nextPasteCount, p = f;
|
|
5025
5231
|
}
|
|
5026
5232
|
let h = n.shapes.map((e) => ({
|
|
5027
5233
|
...e,
|
|
5028
|
-
id:
|
|
5234
|
+
id: oe(),
|
|
5029
5235
|
points: e.points.map((e) => ({
|
|
5030
5236
|
x: e.x + f,
|
|
5031
5237
|
y: e.y + p
|
|
@@ -5043,10 +5249,10 @@ function xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5043
5249
|
if (n || !t.current.length) return;
|
|
5044
5250
|
let i = m().map((e) => ({
|
|
5045
5251
|
...e,
|
|
5046
|
-
id:
|
|
5252
|
+
id: oe(),
|
|
5047
5253
|
points: e.points.map((e) => ({
|
|
5048
|
-
x: e.x +
|
|
5049
|
-
y: e.y +
|
|
5254
|
+
x: e.x + kr,
|
|
5255
|
+
y: e.y + kr
|
|
5050
5256
|
}))
|
|
5051
5257
|
}));
|
|
5052
5258
|
i.length && (e.create(i), r(i.map((e) => e.id)));
|
|
@@ -5074,7 +5280,7 @@ function xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5074
5280
|
m
|
|
5075
5281
|
]), w = x((r, i) => {
|
|
5076
5282
|
if (n || !t.current.length) return;
|
|
5077
|
-
let a = e.getShapes().filter((e) => t.current.includes(e.id) &&
|
|
5283
|
+
let a = e.getShapes().filter((e) => t.current.includes(e.id) && ie(e));
|
|
5078
5284
|
a.length && e.update(a.map((e) => ({
|
|
5079
5285
|
...e,
|
|
5080
5286
|
points: e.points.map((e) => ({
|
|
@@ -5086,7 +5292,7 @@ function xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5086
5292
|
e,
|
|
5087
5293
|
n,
|
|
5088
5294
|
t
|
|
5089
|
-
]), T = x(() => m().filter((e) => e.type ===
|
|
5295
|
+
]), T = x(() => m().filter((e) => e.type === L.POLYGON || e.type === L.RECTANGLE || e.type === L.ROTATED_RECTANGLE || e.type === L.ELLIPSE), [m]);
|
|
5090
5296
|
return {
|
|
5091
5297
|
selectAll: f,
|
|
5092
5298
|
clearSelection: p,
|
|
@@ -5109,8 +5315,8 @@ function xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5109
5315
|
let o = mn(a, 1);
|
|
5110
5316
|
if (!o.length) return;
|
|
5111
5317
|
let s = t[0], c = o.map((e) => ({
|
|
5112
|
-
id:
|
|
5113
|
-
type:
|
|
5318
|
+
id: oe(),
|
|
5319
|
+
type: L.POLYGON,
|
|
5114
5320
|
points: e,
|
|
5115
5321
|
style: s.style,
|
|
5116
5322
|
meta: s.meta
|
|
@@ -5127,7 +5333,7 @@ function xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5127
5333
|
}
|
|
5128
5334
|
//#endregion
|
|
5129
5335
|
//#region src/components/ShapeEditor/_state/useViewportControls.ts
|
|
5130
|
-
function
|
|
5336
|
+
function jr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
|
|
5131
5337
|
let o = O(null), s = O(null), c = x(() => {
|
|
5132
5338
|
o.current?.(), o.current = null;
|
|
5133
5339
|
}, []), l = x((t, n = r) => {
|
|
@@ -5158,7 +5364,7 @@ function Sr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5158
5364
|
if (!r.length) return;
|
|
5159
5365
|
let i = e.current;
|
|
5160
5366
|
if (!i) return;
|
|
5161
|
-
let a = Jt(
|
|
5367
|
+
let a = Jt(V(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
|
|
5162
5368
|
a && l(a);
|
|
5163
5369
|
}, [
|
|
5164
5370
|
t,
|
|
@@ -5199,45 +5405,47 @@ function Sr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5199
5405
|
}
|
|
5200
5406
|
//#endregion
|
|
5201
5407
|
//#region src/components/ShapeEditor/ShapeEditor.tsx
|
|
5202
|
-
var
|
|
5408
|
+
var Mr = "__draft_preview__", Nr = new Set([
|
|
5203
5409
|
"copy",
|
|
5204
5410
|
"selectAll",
|
|
5205
5411
|
"clearSelection",
|
|
5206
5412
|
"zoomToSelection"
|
|
5207
5413
|
]);
|
|
5208
|
-
function
|
|
5414
|
+
function Pr(e, t) {
|
|
5209
5415
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
5210
5416
|
}
|
|
5211
|
-
function
|
|
5212
|
-
let
|
|
5417
|
+
function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !1, selectedIds: i, activeTool: a, draftStyle: s, draftMeta: c, readOnly: l, disableMarquee: u, locked: d, onLockedInteraction: f, onIdleEscape: p, overrideShapeInteraction: m, defaultViewSettings: h, viewSettings: g, onViewSettingsChange: _, showMinimap: b = !0, minimapPosition: D = "bottom-left", showViewSettings: A = !0, getContextMenuItems: j, strings: M, canMergeSelection: N, brushSize: P = 20, zoomBound: F, zoomAnimationDuration: ee = 300, decorationShapes: te, regionMask: I, guideMask: re, maskPalette: z, overlayMarkers: ae, renderOverlayMarker: B, onOverlayMarkerClick: V, renderImageOverlay: se, getSelectionLabel: H, hideSelectionLabelDot: ce, formatSelectionInfo: le, externalTools: ue, assistant: de, keymap: fe, handleRef: pe, backend: me = "pixi", onActiveToolChange: he, onSelectionChange: ge, onEditingChange: _e, onShapesCreated: ve, onShapesUpdated: ye, onShapesDeleted: be, onDrawSessionChange: xe, onDraftShapeChange: Se, onViewportChange: Ce, onShapesTransformPreview: we }) {
|
|
5418
|
+
let Te = O(null), U = O(null), Ee = O(null), De = O(null), W = O(null), Ae = `${C()}-minimap`, [K, je] = k(null), [Me, Pe] = k(!1), [Re, ze] = k(!1), [Be, Ve] = k(null), [He, Ue] = k({
|
|
5213
5419
|
active: !1,
|
|
5214
5420
|
kind: "none",
|
|
5215
5421
|
canUndo: !1,
|
|
5216
5422
|
canRedo: !1
|
|
5217
|
-
}), [We, Ge] = k(!0), [Ke, qe] = k(!1), Je = e?.id ?? "", Ye = e?.imageUrl ?? "", Xe = e?.displayImageUrl, Qe = e?.coordinateSize, $e = e?.initialShapes, et = e?.initialSelectedIds, tt = Xe ?? Ye, [nt, ot] = k("loading"),
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5423
|
+
}), [We, Ge] = k(!0), [Ke, qe] = k(!1), Je = e?.id ?? "", Ye = e?.imageUrl ?? "", Xe = e?.displayImageUrl, Qe = e?.coordinateSize, $e = e?.initialShapes, et = e?.initialSelectedIds, tt = Xe ?? Ye, [nt, ot] = k("loading"), [ct, lt] = k(null), ut = x((e, t) => {
|
|
5424
|
+
ot(e), lt(e === "error" ? t ?? null : null);
|
|
5425
|
+
}, []), q = Tn({
|
|
5426
|
+
onShapesCreated: ve,
|
|
5427
|
+
onShapesUpdated: ye,
|
|
5428
|
+
onShapesDeleted: be
|
|
5429
|
+
}), [dt, ft] = k([]), J = i ?? dt, pt = i !== void 0, mt = E(() => new Map((ue ?? []).map((e) => [e.id, e])), [ue]), gt = O(mt);
|
|
5222
5430
|
T(() => {
|
|
5223
|
-
|
|
5224
|
-
}, [
|
|
5225
|
-
let
|
|
5226
|
-
|
|
5227
|
-
let
|
|
5431
|
+
gt.current = mt;
|
|
5432
|
+
}, [mt]);
|
|
5433
|
+
let _t = O(He);
|
|
5434
|
+
_t.current = He;
|
|
5435
|
+
let vt = E(() => {
|
|
5228
5436
|
let e = Object.fromEntries(Object.entries(h ?? {}).filter(([, e]) => e !== void 0));
|
|
5229
5437
|
return {
|
|
5230
|
-
...
|
|
5438
|
+
...ke,
|
|
5231
5439
|
...e
|
|
5232
5440
|
};
|
|
5233
|
-
}, [h]),
|
|
5234
|
-
|
|
5235
|
-
let [Y,
|
|
5441
|
+
}, [h]), yt = O(vt);
|
|
5442
|
+
yt.current = vt;
|
|
5443
|
+
let [Y, bt] = k(() => yt.current), xt = x((e) => bt((t) => ({
|
|
5236
5444
|
...t,
|
|
5237
5445
|
...e
|
|
5238
|
-
})), []), X = E(() =>
|
|
5446
|
+
})), []), X = E(() => Oe(M), [M]);
|
|
5239
5447
|
S(() => {
|
|
5240
|
-
g &&
|
|
5448
|
+
g && bt((e) => {
|
|
5241
5449
|
let t = Object.entries(g).filter(([t, n]) => n !== void 0 && e[t] !== n);
|
|
5242
5450
|
return t.length ? {
|
|
5243
5451
|
...e,
|
|
@@ -5245,79 +5453,79 @@ function Er({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5245
5453
|
} : e;
|
|
5246
5454
|
});
|
|
5247
5455
|
}, [g]);
|
|
5248
|
-
let
|
|
5249
|
-
|
|
5250
|
-
let
|
|
5456
|
+
let St = O(_);
|
|
5457
|
+
St.current = _;
|
|
5458
|
+
let Ct = O(!1);
|
|
5251
5459
|
S(() => {
|
|
5252
|
-
if (!
|
|
5253
|
-
|
|
5460
|
+
if (!Ct.current) {
|
|
5461
|
+
Ct.current = !0;
|
|
5254
5462
|
return;
|
|
5255
5463
|
}
|
|
5256
|
-
|
|
5464
|
+
St.current?.(Y);
|
|
5257
5465
|
}, [Y]);
|
|
5258
|
-
let
|
|
5259
|
-
|
|
5260
|
-
let
|
|
5261
|
-
|
|
5262
|
-
let
|
|
5263
|
-
|
|
5264
|
-
let
|
|
5265
|
-
|
|
5266
|
-
let
|
|
5267
|
-
|
|
5268
|
-
let
|
|
5269
|
-
|
|
5270
|
-
let
|
|
5466
|
+
let wt = E(() => !re || !z ? null : kt(re, z), [re, z]), Tt = E(() => wt?.toDataURL() ?? null, [wt]), Dt = E(() => !K || !I ? null : Vt(I, K.w, K.h), [K, I]), Ot = O(wt);
|
|
5467
|
+
Ot.current = wt;
|
|
5468
|
+
let At = O(Dt);
|
|
5469
|
+
At.current = Dt;
|
|
5470
|
+
let jt = O(r);
|
|
5471
|
+
jt.current = r;
|
|
5472
|
+
let Mt = O(K);
|
|
5473
|
+
Mt.current = K;
|
|
5474
|
+
let Nt = O(Qe);
|
|
5475
|
+
Nt.current = Qe;
|
|
5476
|
+
let Pt = O(Qe?.imageSize);
|
|
5477
|
+
Pt.current = Qe?.imageSize;
|
|
5478
|
+
let Ft = O(J);
|
|
5271
5479
|
T(() => {
|
|
5272
|
-
|
|
5480
|
+
Ft.current = J;
|
|
5273
5481
|
}, [J]);
|
|
5274
|
-
let
|
|
5275
|
-
|
|
5276
|
-
let
|
|
5277
|
-
|
|
5278
|
-
let
|
|
5279
|
-
|
|
5280
|
-
let
|
|
5281
|
-
|
|
5282
|
-
let
|
|
5283
|
-
|
|
5284
|
-
let Z = !!l || !!d,
|
|
5285
|
-
|
|
5286
|
-
let
|
|
5287
|
-
|
|
5288
|
-
let
|
|
5289
|
-
|
|
5290
|
-
let
|
|
5291
|
-
|
|
5292
|
-
let
|
|
5293
|
-
|
|
5294
|
-
let
|
|
5295
|
-
|
|
5296
|
-
let
|
|
5297
|
-
let e =
|
|
5482
|
+
let It = O(a);
|
|
5483
|
+
It.current = a;
|
|
5484
|
+
let Lt = O(s);
|
|
5485
|
+
Lt.current = s;
|
|
5486
|
+
let Rt = O(c);
|
|
5487
|
+
Rt.current = c;
|
|
5488
|
+
let zt = O(P);
|
|
5489
|
+
zt.current = P;
|
|
5490
|
+
let Bt = O(Y.simplifyStrength);
|
|
5491
|
+
Bt.current = Y.simplifyStrength;
|
|
5492
|
+
let Z = !!l || !!d, Ht = O(Z);
|
|
5493
|
+
Ht.current = Z;
|
|
5494
|
+
let Ut = O(u);
|
|
5495
|
+
Ut.current = u;
|
|
5496
|
+
let Wt = O(d);
|
|
5497
|
+
Wt.current = d;
|
|
5498
|
+
let Gt = O(f);
|
|
5499
|
+
Gt.current = f;
|
|
5500
|
+
let Kt = O(m);
|
|
5501
|
+
Kt.current = m;
|
|
5502
|
+
let qt = O(q);
|
|
5503
|
+
qt.current = q;
|
|
5504
|
+
let Jt = O(!1), Yt = O(!1), Qt = O("idle"), $t = O(null), en = x(() => {
|
|
5505
|
+
let e = U.current;
|
|
5298
5506
|
if (!e) return;
|
|
5299
|
-
let t =
|
|
5507
|
+
let t = It.current, n = gt.current.get(t), r = _t.current;
|
|
5300
5508
|
e.setCursor(Et({
|
|
5301
5509
|
tool: t,
|
|
5302
5510
|
externalToolCursor: n?.cursor,
|
|
5303
|
-
isSpacePressed:
|
|
5304
|
-
interactionMode:
|
|
5305
|
-
rendererCursorHint:
|
|
5511
|
+
isSpacePressed: Jt.current,
|
|
5512
|
+
interactionMode: Qt.current,
|
|
5513
|
+
rendererCursorHint: $t.current,
|
|
5306
5514
|
isPolygonDrawing: r.kind === "polygon" && r.active
|
|
5307
5515
|
}));
|
|
5308
|
-
}, []),
|
|
5309
|
-
|
|
5310
|
-
}, [
|
|
5311
|
-
|
|
5312
|
-
}, [
|
|
5313
|
-
let t = /* @__PURE__ */ new Set(), n = new Map(
|
|
5516
|
+
}, []), tn = x((e) => {
|
|
5517
|
+
Qt.current !== e && (Qt.current = e, en());
|
|
5518
|
+
}, [en]), nn = x((e) => {
|
|
5519
|
+
$t.current !== e && ($t.current = e, en());
|
|
5520
|
+
}, [en]), rn = x((e) => {
|
|
5521
|
+
let t = /* @__PURE__ */ new Set(), n = new Map(qt.current.getShapes().map((e) => [e.id, e]));
|
|
5314
5522
|
return e.filter((e) => {
|
|
5315
5523
|
if (t.has(e)) return !1;
|
|
5316
5524
|
t.add(e);
|
|
5317
5525
|
let r = n.get(e);
|
|
5318
5526
|
if (!r) return !1;
|
|
5319
|
-
let i =
|
|
5320
|
-
return
|
|
5527
|
+
let i = Kt.current?.(r);
|
|
5528
|
+
return R(i ? {
|
|
5321
5529
|
...r,
|
|
5322
5530
|
interaction: {
|
|
5323
5531
|
...r.interaction,
|
|
@@ -5325,283 +5533,283 @@ function Er({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5325
5533
|
}
|
|
5326
5534
|
} : r);
|
|
5327
5535
|
});
|
|
5328
|
-
}, []),
|
|
5329
|
-
let t =
|
|
5330
|
-
|
|
5536
|
+
}, []), an = x((e) => {
|
|
5537
|
+
let t = rn(e);
|
|
5538
|
+
Pr(Ft.current, t) || (pt || ft(t), U.current?.setSelection(t), ge?.(t));
|
|
5331
5539
|
}, [
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
]),
|
|
5336
|
-
|
|
5337
|
-
let [
|
|
5338
|
-
|
|
5339
|
-
let
|
|
5340
|
-
|
|
5341
|
-
if (!
|
|
5342
|
-
let e =
|
|
5343
|
-
|
|
5540
|
+
rn,
|
|
5541
|
+
ge,
|
|
5542
|
+
pt
|
|
5543
|
+
]), on = O(an);
|
|
5544
|
+
on.current = an;
|
|
5545
|
+
let [sn, cn] = k(null), ln = x((e) => cn(e), []), un = O(ln);
|
|
5546
|
+
un.current = ln;
|
|
5547
|
+
let dn = O(null);
|
|
5548
|
+
dn.current = sn, S(() => {
|
|
5549
|
+
if (!pt) return;
|
|
5550
|
+
let e = rn(i);
|
|
5551
|
+
Pr(i, e) || ge?.(e);
|
|
5344
5552
|
}, [
|
|
5345
5553
|
i,
|
|
5346
5554
|
q.shapes,
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5555
|
+
rn,
|
|
5556
|
+
ge,
|
|
5557
|
+
pt
|
|
5350
5558
|
]);
|
|
5351
|
-
let
|
|
5352
|
-
|
|
5353
|
-
let { registerMinimapShape:
|
|
5354
|
-
engineRef:
|
|
5355
|
-
docRef:
|
|
5356
|
-
overlayRef:
|
|
5357
|
-
zoomLabelRef:
|
|
5358
|
-
minimapRectRef:
|
|
5559
|
+
let fn = O(Ce);
|
|
5560
|
+
fn.current = Ce;
|
|
5561
|
+
let { registerMinimapShape: pn, applyMinimapPreview: mn, syncMinimap: hn } = Or({
|
|
5562
|
+
engineRef: U,
|
|
5563
|
+
docRef: qt,
|
|
5564
|
+
overlayRef: De,
|
|
5565
|
+
zoomLabelRef: W,
|
|
5566
|
+
minimapRectRef: Ee,
|
|
5359
5567
|
minimapSize: 204,
|
|
5360
|
-
onViewportChangeRef:
|
|
5361
|
-
}),
|
|
5362
|
-
|
|
5363
|
-
let
|
|
5364
|
-
t ?
|
|
5365
|
-
}, []),
|
|
5568
|
+
onViewportChangeRef: fn
|
|
5569
|
+
}), gn = O(/* @__PURE__ */ new Map()), _n = O(le);
|
|
5570
|
+
_n.current = le;
|
|
5571
|
+
let vn = x((e, t) => {
|
|
5572
|
+
t ? gn.current.set(e, t) : gn.current.delete(e);
|
|
5573
|
+
}, []), yn = O(null), [bn, xn] = k(null), Cn = x((e) => {
|
|
5366
5574
|
if (!e.length) return;
|
|
5367
|
-
let t = new Map(
|
|
5368
|
-
|
|
5575
|
+
let t = new Map(qt.current.getShapes().map((e) => [e.id, e]));
|
|
5576
|
+
yn.current && t.set(yn.current.id, yn.current);
|
|
5369
5577
|
for (let { id: n, points: r } of e) {
|
|
5370
|
-
let e =
|
|
5578
|
+
let e = gn.current.get(n), i = t.get(n);
|
|
5371
5579
|
if (!e || !i) continue;
|
|
5372
5580
|
let a = rt(e, r);
|
|
5373
5581
|
if (a) {
|
|
5374
5582
|
let e = it(i, r);
|
|
5375
|
-
a.textContent =
|
|
5583
|
+
a.textContent = _n.current?.(e) ?? at(e);
|
|
5376
5584
|
}
|
|
5377
5585
|
}
|
|
5378
|
-
}, []),
|
|
5379
|
-
|
|
5586
|
+
}, []), wn = x((e) => {
|
|
5587
|
+
mn(e), Cn(e), we?.(e);
|
|
5380
5588
|
}, [
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
]),
|
|
5385
|
-
if (
|
|
5589
|
+
mn,
|
|
5590
|
+
Cn,
|
|
5591
|
+
we
|
|
5592
|
+
]), En = x((e) => {
|
|
5593
|
+
if (Se?.(e ? {
|
|
5386
5594
|
...e,
|
|
5387
|
-
meta:
|
|
5388
|
-
} : null), !e || !
|
|
5389
|
-
|
|
5595
|
+
meta: Rt.current
|
|
5596
|
+
} : null), !e || !Lt.current) {
|
|
5597
|
+
yn.current && (yn.current = null, xn(null));
|
|
5390
5598
|
return;
|
|
5391
5599
|
}
|
|
5392
5600
|
let t = {
|
|
5393
|
-
id:
|
|
5601
|
+
id: Mr,
|
|
5394
5602
|
type: e.type,
|
|
5395
5603
|
points: e.points,
|
|
5396
|
-
style:
|
|
5397
|
-
meta:
|
|
5398
|
-
}, n =
|
|
5399
|
-
|
|
5400
|
-
id:
|
|
5604
|
+
style: Lt.current,
|
|
5605
|
+
meta: Rt.current
|
|
5606
|
+
}, n = yn.current !== null;
|
|
5607
|
+
yn.current = t, n ? Cn([{
|
|
5608
|
+
id: Mr,
|
|
5401
5609
|
points: e.points
|
|
5402
|
-
}]) :
|
|
5403
|
-
}, [
|
|
5404
|
-
let n =
|
|
5405
|
-
if (!n ||
|
|
5406
|
-
let r =
|
|
5407
|
-
|
|
5610
|
+
}]) : xn(t);
|
|
5611
|
+
}, [Cn, Se]), Dn = x((e, t) => {
|
|
5612
|
+
let n = Lt.current;
|
|
5613
|
+
if (!n || Ht.current) return;
|
|
5614
|
+
let r = oe();
|
|
5615
|
+
qt.current.create({
|
|
5408
5616
|
id: r,
|
|
5409
5617
|
type: e,
|
|
5410
5618
|
points: t,
|
|
5411
5619
|
style: n,
|
|
5412
5620
|
meta: c
|
|
5413
|
-
}),
|
|
5414
|
-
}, [c]),
|
|
5415
|
-
|
|
5416
|
-
let
|
|
5417
|
-
toolRef:
|
|
5418
|
-
selRef:
|
|
5419
|
-
docRef:
|
|
5420
|
-
readOnlyRef:
|
|
5421
|
-
draftRef:
|
|
5422
|
-
brushSizeRef:
|
|
5423
|
-
simplifyEpsilonRef:
|
|
5621
|
+
}), on.current([r]);
|
|
5622
|
+
}, [c]), On = O(Dn);
|
|
5623
|
+
On.current = Dn;
|
|
5624
|
+
let kn = Sn({
|
|
5625
|
+
toolRef: It,
|
|
5626
|
+
selRef: Ft,
|
|
5627
|
+
docRef: qt,
|
|
5628
|
+
readOnlyRef: Ht,
|
|
5629
|
+
draftRef: Lt,
|
|
5630
|
+
brushSizeRef: zt,
|
|
5631
|
+
simplifyEpsilonRef: Bt,
|
|
5424
5632
|
draftMeta: c,
|
|
5425
|
-
engineRef:
|
|
5633
|
+
engineRef: U,
|
|
5426
5634
|
onDrawSessionChange: x((e) => {
|
|
5427
|
-
Ue(e),
|
|
5428
|
-
}, [
|
|
5429
|
-
onDraftShapeChange:
|
|
5430
|
-
changeSelection:
|
|
5431
|
-
createShape:
|
|
5432
|
-
}),
|
|
5433
|
-
|
|
5434
|
-
let { reset:
|
|
5435
|
-
|
|
5635
|
+
Ue(e), xe?.(e);
|
|
5636
|
+
}, [xe]),
|
|
5637
|
+
onDraftShapeChange: Se,
|
|
5638
|
+
changeSelection: an,
|
|
5639
|
+
createShape: Dn
|
|
5640
|
+
}), An = O(kn);
|
|
5641
|
+
An.current = kn;
|
|
5642
|
+
let { reset: jn, undoSession: Mn, redoSession: Nn, canUndoSession: Pn, canRedoSession: In, hasDraftSession: Ln, hasDraftPoints: Rn, commitDraftSession: zn, setBrushScalarMode: Bn, getBrushScalarMode: Vn, hasBrushSession: Hn, commitBrush: Un, cancelBrush: Wn, beginBrushEditFromSelection: Gn, deleteDraftSelectedPoints: Kn, handleToolChange: qn, handleBrushSelectionChange: Jn } = kn, Yn = O(de);
|
|
5643
|
+
Yn.current = de;
|
|
5436
5644
|
let Q = Zt({
|
|
5437
|
-
docRef:
|
|
5438
|
-
draftRef:
|
|
5645
|
+
docRef: qt,
|
|
5646
|
+
draftRef: Lt,
|
|
5439
5647
|
draftMeta: c,
|
|
5440
|
-
changeSelection:
|
|
5441
|
-
assistantRef:
|
|
5442
|
-
}),
|
|
5443
|
-
|
|
5444
|
-
let
|
|
5648
|
+
changeSelection: an,
|
|
5649
|
+
assistantRef: Yn
|
|
5650
|
+
}), Xn = O(Q);
|
|
5651
|
+
Xn.current = Q;
|
|
5652
|
+
let Zn = E(() => ht(Je), [Je]), { selectAll: Qn, clearSelection: $n, deleteSelection: er, copySelection: tr, canPaste: nr, paste: rr, duplicate: ir, bringToFront: ar, sendToBack: or, nudgeSelection: sr, getMergeTargets: cr, mergeSelection: lr } = Ar({
|
|
5445
5653
|
doc: q,
|
|
5446
|
-
selRef:
|
|
5654
|
+
selRef: Ft,
|
|
5447
5655
|
effectiveReadOnly: Z,
|
|
5448
|
-
changeSelection:
|
|
5449
|
-
canMergeSelection:
|
|
5450
|
-
clipboardDocumentId:
|
|
5451
|
-
clipboardScope: t ??
|
|
5452
|
-
}), { zoomToBounds:
|
|
5453
|
-
engineRef:
|
|
5656
|
+
changeSelection: an,
|
|
5657
|
+
canMergeSelection: N,
|
|
5658
|
+
clipboardDocumentId: Zn,
|
|
5659
|
+
clipboardScope: t ?? Zn
|
|
5660
|
+
}), { zoomToBounds: ur, zoomToShapes: dr, zoomToSelection: fr, zoomAtCenter: pr } = jr({
|
|
5661
|
+
engineRef: U,
|
|
5454
5662
|
doc: q,
|
|
5455
|
-
selRef:
|
|
5456
|
-
zoomAnimationDuration:
|
|
5457
|
-
zoomBound:
|
|
5458
|
-
ready:
|
|
5663
|
+
selRef: Ft,
|
|
5664
|
+
zoomAnimationDuration: ee,
|
|
5665
|
+
zoomBound: F,
|
|
5666
|
+
ready: Re
|
|
5459
5667
|
});
|
|
5460
|
-
w(
|
|
5668
|
+
w(pe, () => ({
|
|
5461
5669
|
previewRegionMask: (e) => {
|
|
5462
|
-
let t =
|
|
5670
|
+
let t = Mt.current;
|
|
5463
5671
|
if (!t) return;
|
|
5464
|
-
let n = e ?
|
|
5465
|
-
|
|
5672
|
+
let n = e ? Vt(e, t.w, t.h) : At.current;
|
|
5673
|
+
U.current?.setRegionOverlay(mr.current.showRegionMask ? n : null);
|
|
5466
5674
|
},
|
|
5467
5675
|
undo: () => {
|
|
5468
|
-
|
|
5676
|
+
Mn() || q.undo();
|
|
5469
5677
|
},
|
|
5470
5678
|
redo: () => {
|
|
5471
|
-
|
|
5679
|
+
Nn() || q.redo();
|
|
5472
5680
|
},
|
|
5473
|
-
canUndo: () =>
|
|
5474
|
-
canRedo: () =>
|
|
5475
|
-
undoSession:
|
|
5476
|
-
redoSession:
|
|
5477
|
-
canUndoSession:
|
|
5478
|
-
canRedoSession:
|
|
5479
|
-
hasDraftSession:
|
|
5480
|
-
cancelDraftSession:
|
|
5481
|
-
commitDraftSession:
|
|
5482
|
-
setSelection:
|
|
5681
|
+
canUndo: () => Pn() || q.canUndo(),
|
|
5682
|
+
canRedo: () => In() || q.canRedo(),
|
|
5683
|
+
undoSession: Mn,
|
|
5684
|
+
redoSession: Nn,
|
|
5685
|
+
canUndoSession: Pn,
|
|
5686
|
+
canRedoSession: In,
|
|
5687
|
+
hasDraftSession: Ln,
|
|
5688
|
+
cancelDraftSession: jn,
|
|
5689
|
+
commitDraftSession: zn,
|
|
5690
|
+
setSelection: an,
|
|
5483
5691
|
createShapes: (e) => {
|
|
5484
|
-
e.length && (q.create(e),
|
|
5692
|
+
e.length && (q.create(e), an(e.map((e) => e.id)));
|
|
5485
5693
|
},
|
|
5486
5694
|
updateShapes: q.update,
|
|
5487
5695
|
deleteShapes: q.remove,
|
|
5488
5696
|
getShapes: q.getShapes,
|
|
5489
|
-
selectAll:
|
|
5490
|
-
clearSelection:
|
|
5491
|
-
deleteSelection:
|
|
5492
|
-
copySelection:
|
|
5493
|
-
paste:
|
|
5494
|
-
duplicate:
|
|
5495
|
-
bringToFront:
|
|
5496
|
-
sendToBack:
|
|
5497
|
-
zoomFit: () =>
|
|
5498
|
-
zoom100: () =>
|
|
5697
|
+
selectAll: Qn,
|
|
5698
|
+
clearSelection: $n,
|
|
5699
|
+
deleteSelection: er,
|
|
5700
|
+
copySelection: tr,
|
|
5701
|
+
paste: rr,
|
|
5702
|
+
duplicate: ir,
|
|
5703
|
+
bringToFront: ar,
|
|
5704
|
+
sendToBack: or,
|
|
5705
|
+
zoomFit: () => U.current?.fit(),
|
|
5706
|
+
zoom100: () => U.current?.zoom100(),
|
|
5499
5707
|
zoomIn: () => {
|
|
5500
|
-
let e =
|
|
5708
|
+
let e = U.current;
|
|
5501
5709
|
if (!e) return;
|
|
5502
5710
|
let { w: t, h: n } = e.screenSize;
|
|
5503
5711
|
e.zoomAt(t / 2, n / 2, 1.2);
|
|
5504
5712
|
},
|
|
5505
5713
|
zoomOut: () => {
|
|
5506
|
-
let e =
|
|
5714
|
+
let e = U.current;
|
|
5507
5715
|
if (!e) return;
|
|
5508
5716
|
let { w: t, h: n } = e.screenSize;
|
|
5509
5717
|
e.zoomAt(t / 2, n / 2, 1 / 1.2);
|
|
5510
5718
|
},
|
|
5511
|
-
zoomToSelection:
|
|
5512
|
-
zoomToShapes:
|
|
5513
|
-
zoomToBounds:
|
|
5719
|
+
zoomToSelection: fr,
|
|
5720
|
+
zoomToShapes: dr,
|
|
5721
|
+
zoomToBounds: ur,
|
|
5514
5722
|
brush: {
|
|
5515
|
-
setScalarMode:
|
|
5516
|
-
getScalarMode:
|
|
5517
|
-
hasSession:
|
|
5518
|
-
commit:
|
|
5519
|
-
cancel:
|
|
5520
|
-
beginEditFromSelection:
|
|
5723
|
+
setScalarMode: Bn,
|
|
5724
|
+
getScalarMode: Vn,
|
|
5725
|
+
hasSession: Hn,
|
|
5726
|
+
commit: Un,
|
|
5727
|
+
cancel: Wn,
|
|
5728
|
+
beginEditFromSelection: Gn
|
|
5521
5729
|
}
|
|
5522
5730
|
}), [
|
|
5523
5731
|
q,
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
Yn,
|
|
5532
|
-
Xn,
|
|
5533
|
-
Zn,
|
|
5732
|
+
an,
|
|
5733
|
+
Mn,
|
|
5734
|
+
Nn,
|
|
5735
|
+
zn,
|
|
5736
|
+
jn,
|
|
5737
|
+
Un,
|
|
5738
|
+
Wn,
|
|
5534
5739
|
Qn,
|
|
5740
|
+
$n,
|
|
5535
5741
|
er,
|
|
5536
5742
|
tr,
|
|
5537
|
-
nr,
|
|
5538
5743
|
rr,
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5744
|
+
ir,
|
|
5745
|
+
ar,
|
|
5746
|
+
or,
|
|
5747
|
+
fr,
|
|
5748
|
+
dr,
|
|
5749
|
+
ur,
|
|
5750
|
+
Bn,
|
|
5751
|
+
Vn,
|
|
5752
|
+
Hn,
|
|
5753
|
+
Gn
|
|
5546
5754
|
]);
|
|
5547
|
-
let
|
|
5548
|
-
|
|
5549
|
-
let
|
|
5550
|
-
engineRef:
|
|
5551
|
-
toolRef:
|
|
5552
|
-
externalToolMapRef:
|
|
5553
|
-
spaceRef:
|
|
5554
|
-
shiftRef:
|
|
5555
|
-
docRef:
|
|
5556
|
-
selRef:
|
|
5557
|
-
draftRef:
|
|
5558
|
-
readOnlyRef:
|
|
5559
|
-
disableMarqueeRef:
|
|
5560
|
-
lockedRef:
|
|
5561
|
-
onLockedInteraction: () =>
|
|
5562
|
-
createRef:
|
|
5563
|
-
selectRef:
|
|
5564
|
-
enterEditRef:
|
|
5565
|
-
editingIdRef:
|
|
5566
|
-
drawSessionRef:
|
|
5567
|
-
assistantRef:
|
|
5568
|
-
setCursorHint:
|
|
5569
|
-
setInteractionMode:
|
|
5570
|
-
syncMinimap:
|
|
5571
|
-
onTransformPreview:
|
|
5572
|
-
onDrawPreview:
|
|
5755
|
+
let mr = O(Y);
|
|
5756
|
+
mr.current = Y;
|
|
5757
|
+
let hr = x(() => Xt({
|
|
5758
|
+
engineRef: U,
|
|
5759
|
+
toolRef: It,
|
|
5760
|
+
externalToolMapRef: gt,
|
|
5761
|
+
spaceRef: Jt,
|
|
5762
|
+
shiftRef: Yt,
|
|
5763
|
+
docRef: qt,
|
|
5764
|
+
selRef: Ft,
|
|
5765
|
+
draftRef: Lt,
|
|
5766
|
+
readOnlyRef: Ht,
|
|
5767
|
+
disableMarqueeRef: Ut,
|
|
5768
|
+
lockedRef: Wt,
|
|
5769
|
+
onLockedInteraction: () => Gt.current?.(),
|
|
5770
|
+
createRef: On,
|
|
5771
|
+
selectRef: on,
|
|
5772
|
+
enterEditRef: un,
|
|
5773
|
+
editingIdRef: dn,
|
|
5774
|
+
drawSessionRef: An,
|
|
5775
|
+
assistantRef: Xn,
|
|
5776
|
+
setCursorHint: nn,
|
|
5777
|
+
setInteractionMode: tn,
|
|
5778
|
+
syncMinimap: hn,
|
|
5779
|
+
onTransformPreview: wn,
|
|
5780
|
+
onDrawPreview: En
|
|
5573
5781
|
}), [
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
]),
|
|
5580
|
-
|
|
5581
|
-
backend:
|
|
5582
|
-
hostRef:
|
|
5583
|
-
engineRef:
|
|
5782
|
+
nn,
|
|
5783
|
+
tn,
|
|
5784
|
+
hn,
|
|
5785
|
+
wn,
|
|
5786
|
+
En
|
|
5787
|
+
]), gr = O([]);
|
|
5788
|
+
xr({
|
|
5789
|
+
backend: me,
|
|
5790
|
+
hostRef: Te,
|
|
5791
|
+
engineRef: U,
|
|
5584
5792
|
documentId: Je,
|
|
5585
5793
|
renderedImageUrl: tt,
|
|
5586
|
-
makeCallbacks:
|
|
5587
|
-
viewRef:
|
|
5588
|
-
readOnlyRef:
|
|
5589
|
-
toolRef:
|
|
5590
|
-
renderShapesRef:
|
|
5591
|
-
coordinateSizeRef:
|
|
5592
|
-
imageSizeRef:
|
|
5593
|
-
selRef:
|
|
5594
|
-
maskCanvasRef:
|
|
5595
|
-
regionOverlayRef:
|
|
5596
|
-
dimmedRef:
|
|
5597
|
-
syncMinimap:
|
|
5598
|
-
setImage:
|
|
5599
|
-
setImageVisible:
|
|
5794
|
+
makeCallbacks: hr,
|
|
5795
|
+
viewRef: mr,
|
|
5796
|
+
readOnlyRef: Ht,
|
|
5797
|
+
toolRef: It,
|
|
5798
|
+
renderShapesRef: gr,
|
|
5799
|
+
coordinateSizeRef: Nt,
|
|
5800
|
+
imageSizeRef: Pt,
|
|
5801
|
+
selRef: Ft,
|
|
5802
|
+
maskCanvasRef: Ot,
|
|
5803
|
+
regionOverlayRef: At,
|
|
5804
|
+
dimmedRef: jt,
|
|
5805
|
+
syncMinimap: hn,
|
|
5806
|
+
setImage: je,
|
|
5807
|
+
setImageVisible: Pe,
|
|
5600
5808
|
setReady: ze,
|
|
5601
|
-
setImageStatus:
|
|
5809
|
+
setImageStatus: ut,
|
|
5602
5810
|
onContextMenuRequest: Ve
|
|
5603
5811
|
});
|
|
5604
|
-
let
|
|
5812
|
+
let _r = E(() => {
|
|
5605
5813
|
let e = m ? q.shapes.map((e) => {
|
|
5606
5814
|
let t = m(e);
|
|
5607
5815
|
return t ? {
|
|
@@ -5612,7 +5820,7 @@ function Er({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5612
5820
|
}
|
|
5613
5821
|
} : e;
|
|
5614
5822
|
}) : q.shapes;
|
|
5615
|
-
return
|
|
5823
|
+
return te?.length ? [...te.map((e) => ({
|
|
5616
5824
|
...e,
|
|
5617
5825
|
interaction: {
|
|
5618
5826
|
...e.interaction,
|
|
@@ -5625,150 +5833,150 @@ function Er({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5625
5833
|
}, [
|
|
5626
5834
|
q.shapes,
|
|
5627
5835
|
m,
|
|
5628
|
-
|
|
5836
|
+
te
|
|
5629
5837
|
]);
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
}, [
|
|
5633
|
-
|
|
5838
|
+
gr.current = _r, S(() => {
|
|
5839
|
+
U.current?.setShapes(_r, Ft.current), hn();
|
|
5840
|
+
}, [_r, hn]), S(() => {
|
|
5841
|
+
U.current?.setSelection(J);
|
|
5634
5842
|
}, [J]), S(() => {
|
|
5635
|
-
|
|
5636
|
-
}, [
|
|
5637
|
-
let
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
}, [
|
|
5641
|
-
|
|
5843
|
+
U.current?.setEditing(sn);
|
|
5844
|
+
}, [sn, Re]);
|
|
5845
|
+
let vr = O(_e);
|
|
5846
|
+
vr.current = _e, S(() => {
|
|
5847
|
+
vr.current?.(sn);
|
|
5848
|
+
}, [sn]), S(() => {
|
|
5849
|
+
cn(null);
|
|
5642
5850
|
}, [a]), S(() => {
|
|
5643
|
-
|
|
5644
|
-
}, [J,
|
|
5645
|
-
let e =
|
|
5646
|
-
e && (e.setFilter(Y.brightness, Y.contrast), e.setRenderDefaults({ strokeWidth: Y.strokeSize }), e.setImageSmoothing(Y.imageSmoothing),
|
|
5851
|
+
sn && (J.length !== 1 || J[0] !== sn) && cn(null);
|
|
5852
|
+
}, [J, sn]), S(() => {
|
|
5853
|
+
let e = U.current;
|
|
5854
|
+
e && (e.setFilter(Y.brightness, Y.contrast), e.setRenderDefaults({ strokeWidth: Y.strokeSize }), e.setImageSmoothing(Y.imageSmoothing), hn());
|
|
5647
5855
|
}, [
|
|
5648
5856
|
Y.brightness,
|
|
5649
5857
|
Y.contrast,
|
|
5650
5858
|
Y.strokeSize,
|
|
5651
5859
|
Y.imageSmoothing,
|
|
5652
|
-
|
|
5860
|
+
hn
|
|
5653
5861
|
]), T(() => {
|
|
5654
|
-
|
|
5862
|
+
Re && U.current?.setOverlays(Y.showGuide ? wt : null, Y.showRegionMask ? Dt : null, r);
|
|
5655
5863
|
}, [
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5864
|
+
Re,
|
|
5865
|
+
wt,
|
|
5866
|
+
Dt,
|
|
5659
5867
|
Y.showGuide,
|
|
5660
5868
|
Y.showRegionMask,
|
|
5661
5869
|
r
|
|
5662
5870
|
]), S(() => {
|
|
5663
|
-
!
|
|
5871
|
+
!Re || !K || hn();
|
|
5664
5872
|
}, [
|
|
5873
|
+
Re,
|
|
5665
5874
|
K,
|
|
5666
|
-
|
|
5667
|
-
St,
|
|
5875
|
+
Tt,
|
|
5668
5876
|
Y.showGuide,
|
|
5669
5877
|
Y.showRegionMask,
|
|
5670
|
-
|
|
5671
|
-
|
|
5878
|
+
I,
|
|
5879
|
+
hn
|
|
5672
5880
|
]), S(() => {
|
|
5673
|
-
|
|
5881
|
+
Re && U.current?.setTransformEnabled(!Z && a !== G.BRUSH);
|
|
5674
5882
|
}, [
|
|
5675
5883
|
Z,
|
|
5676
|
-
|
|
5884
|
+
Re,
|
|
5677
5885
|
a
|
|
5678
5886
|
]), S(() => {
|
|
5679
|
-
|
|
5680
|
-
}, [a,
|
|
5681
|
-
let
|
|
5887
|
+
qn(a, gt.current.has(a));
|
|
5888
|
+
}, [a, qn]);
|
|
5889
|
+
let $ = Q.finalize;
|
|
5682
5890
|
S(() => {
|
|
5683
|
-
|
|
5684
|
-
}, [a,
|
|
5685
|
-
|
|
5891
|
+
$();
|
|
5892
|
+
}, [a, $]), S(() => {
|
|
5893
|
+
Qt.current = "idle", $t.current = null, en();
|
|
5686
5894
|
}, [
|
|
5687
5895
|
a,
|
|
5688
|
-
|
|
5689
|
-
|
|
5896
|
+
me,
|
|
5897
|
+
en
|
|
5690
5898
|
]), S(() => {
|
|
5691
|
-
|
|
5899
|
+
Jn(J, Z);
|
|
5692
5900
|
}, [
|
|
5693
5901
|
J,
|
|
5694
5902
|
a,
|
|
5695
5903
|
Z,
|
|
5696
|
-
|
|
5904
|
+
Jn
|
|
5697
5905
|
]), S(() => {
|
|
5698
|
-
|
|
5906
|
+
Re && en();
|
|
5699
5907
|
}, [
|
|
5700
5908
|
a,
|
|
5701
5909
|
He,
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5910
|
+
mt,
|
|
5911
|
+
Re,
|
|
5912
|
+
en
|
|
5705
5913
|
]);
|
|
5706
|
-
let
|
|
5707
|
-
|
|
5708
|
-
let br = e !== null,
|
|
5914
|
+
let yr = O(et);
|
|
5915
|
+
yr.current = et;
|
|
5916
|
+
let br = e !== null, Sr = O(null);
|
|
5709
5917
|
S(() => {
|
|
5710
5918
|
let e = br ? Je : null;
|
|
5711
|
-
|
|
5919
|
+
Sr.current !== e && (Sr.current = e, Ve(null), cn(null), Qt.current = "idle", $t.current = null, q.reset(br ? $e ?? [] : []), an(br ? yr.current ?? [] : []), jn(), $(), en());
|
|
5712
5920
|
}, [
|
|
5713
5921
|
br,
|
|
5714
5922
|
Je,
|
|
5715
5923
|
$e,
|
|
5716
5924
|
q.reset,
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5925
|
+
an,
|
|
5926
|
+
jn,
|
|
5927
|
+
$,
|
|
5928
|
+
en
|
|
5721
5929
|
]);
|
|
5722
|
-
let
|
|
5723
|
-
let e =
|
|
5930
|
+
let Cr = x(() => {
|
|
5931
|
+
let e = dn.current;
|
|
5724
5932
|
if (!e || Z) return !1;
|
|
5725
|
-
let t =
|
|
5933
|
+
let t = U.current, n = new Set(t?.getVertexSelection() ?? []);
|
|
5726
5934
|
if (!n.size) return !1;
|
|
5727
|
-
let r =
|
|
5935
|
+
let r = qt.current.getShapes().find((t) => t.id === e);
|
|
5728
5936
|
if (!r) return !1;
|
|
5729
|
-
let i = r.points.filter((e, t) => !n.has(t)), a = r.type ===
|
|
5730
|
-
return i.length < a ? !1 : (
|
|
5937
|
+
let i = r.points.filter((e, t) => !n.has(t)), a = r.type === L.LINE ? 2 : 3;
|
|
5938
|
+
return i.length < a ? !1 : (qt.current.update([{
|
|
5731
5939
|
...r,
|
|
5732
5940
|
points: i
|
|
5733
5941
|
}]), t?.setVertexSelection([]), !0);
|
|
5734
5942
|
}, [Z]);
|
|
5735
5943
|
Fn({
|
|
5736
|
-
keymap:
|
|
5737
|
-
hostRef:
|
|
5944
|
+
keymap: fe,
|
|
5945
|
+
hostRef: Te,
|
|
5738
5946
|
actions: {
|
|
5739
5947
|
undo: () => {
|
|
5740
|
-
Z ||
|
|
5948
|
+
Z || Mn() || q.undo();
|
|
5741
5949
|
},
|
|
5742
5950
|
redo: () => {
|
|
5743
|
-
Z ||
|
|
5951
|
+
Z || Nn() || q.redo();
|
|
5744
5952
|
},
|
|
5745
|
-
selectAll:
|
|
5746
|
-
copy:
|
|
5953
|
+
selectAll: Qn,
|
|
5954
|
+
copy: tr,
|
|
5747
5955
|
cut: () => {
|
|
5748
|
-
|
|
5956
|
+
tr(), er();
|
|
5749
5957
|
},
|
|
5750
|
-
paste:
|
|
5751
|
-
duplicate:
|
|
5958
|
+
paste: rr,
|
|
5959
|
+
duplicate: ir,
|
|
5752
5960
|
delete: () => {
|
|
5753
|
-
|
|
5961
|
+
Rn() && Kn() || Cr() || er();
|
|
5754
5962
|
},
|
|
5755
5963
|
cancel: () => {
|
|
5756
|
-
let e =
|
|
5964
|
+
let e = gt.current.get(It.current);
|
|
5757
5965
|
if (!(e?.onCancel && e.onCancel() !== !1)) {
|
|
5758
5966
|
if (Q.isActive()) {
|
|
5759
5967
|
Q.cancel();
|
|
5760
5968
|
return;
|
|
5761
5969
|
}
|
|
5762
|
-
if (
|
|
5763
|
-
|
|
5970
|
+
if (Ln()) {
|
|
5971
|
+
jn();
|
|
5764
5972
|
return;
|
|
5765
5973
|
}
|
|
5766
|
-
if (
|
|
5767
|
-
|
|
5974
|
+
if (sn) {
|
|
5975
|
+
cn(null);
|
|
5768
5976
|
return;
|
|
5769
5977
|
}
|
|
5770
|
-
if (
|
|
5771
|
-
|
|
5978
|
+
if (Ft.current.length) {
|
|
5979
|
+
$n();
|
|
5772
5980
|
return;
|
|
5773
5981
|
}
|
|
5774
5982
|
p?.();
|
|
@@ -5779,150 +5987,150 @@ function Er({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5779
5987
|
Q.finalize();
|
|
5780
5988
|
return;
|
|
5781
5989
|
}
|
|
5782
|
-
if (
|
|
5783
|
-
|
|
5990
|
+
if (Ln()) {
|
|
5991
|
+
zn();
|
|
5784
5992
|
return;
|
|
5785
5993
|
}
|
|
5786
5994
|
if (Z) return;
|
|
5787
|
-
if (
|
|
5788
|
-
|
|
5995
|
+
if (sn) {
|
|
5996
|
+
cn(null);
|
|
5789
5997
|
return;
|
|
5790
5998
|
}
|
|
5791
|
-
let e =
|
|
5999
|
+
let e = Ft.current;
|
|
5792
6000
|
if (e.length !== 1) return;
|
|
5793
|
-
let t =
|
|
5794
|
-
t && (t.type ===
|
|
6001
|
+
let t = qt.current.getShapes().find((t) => t.id === e[0]);
|
|
6002
|
+
t && (t.type === L.POLYGON || t.type === L.LINE) && t.interaction?.editable !== !1 && !t.readOnly && cn(e[0]);
|
|
5795
6003
|
},
|
|
5796
|
-
bringToFront:
|
|
5797
|
-
sendToBack:
|
|
5798
|
-
zoomIn: () =>
|
|
5799
|
-
zoomOut: () =>
|
|
5800
|
-
zoom100: () =>
|
|
5801
|
-
zoomFit: () =>
|
|
6004
|
+
bringToFront: ar,
|
|
6005
|
+
sendToBack: or,
|
|
6006
|
+
zoomIn: () => pr(1.2),
|
|
6007
|
+
zoomOut: () => pr(1 / 1.2),
|
|
6008
|
+
zoom100: () => U.current?.zoom100(),
|
|
6009
|
+
zoomFit: () => U.current?.fit(),
|
|
5802
6010
|
toggleMinimap: () => Ge((e) => !e),
|
|
5803
|
-
toggleCursorGuide: () =>
|
|
6011
|
+
toggleCursorGuide: () => bt((e) => ({
|
|
5804
6012
|
...e,
|
|
5805
6013
|
showCursorGuide: !e.showCursorGuide
|
|
5806
6014
|
})),
|
|
5807
|
-
togglePixelation: () =>
|
|
6015
|
+
togglePixelation: () => bt((e) => ({
|
|
5808
6016
|
...e,
|
|
5809
6017
|
imageSmoothing: !e.imageSmoothing
|
|
5810
6018
|
})),
|
|
5811
|
-
selectTool: () =>
|
|
5812
|
-
rectangleTool: () =>
|
|
5813
|
-
rotatedRectangleTool: () =>
|
|
5814
|
-
circleTool: () =>
|
|
5815
|
-
polygonTool: () =>
|
|
5816
|
-
pathTool: () =>
|
|
5817
|
-
brushTool: () =>
|
|
5818
|
-
pointTool: () =>
|
|
6019
|
+
selectTool: () => he?.(G.SELECT),
|
|
6020
|
+
rectangleTool: () => he?.(G.RECTANGLE),
|
|
6021
|
+
rotatedRectangleTool: () => he?.(G.ROTATED_RECTANGLE),
|
|
6022
|
+
circleTool: () => he?.(G.CIRCLE),
|
|
6023
|
+
polygonTool: () => he?.(G.POLYGON),
|
|
6024
|
+
pathTool: () => he?.(G.PATH),
|
|
6025
|
+
brushTool: () => he?.(G.BRUSH),
|
|
6026
|
+
pointTool: () => he?.(G.POINT)
|
|
5819
6027
|
},
|
|
5820
|
-
spaceRef:
|
|
5821
|
-
shiftRef:
|
|
6028
|
+
spaceRef: Jt,
|
|
6029
|
+
shiftRef: Yt,
|
|
5822
6030
|
onSpaceDown: () => {
|
|
5823
|
-
|
|
6031
|
+
U.current?.setPanMode(!0), en();
|
|
5824
6032
|
},
|
|
5825
6033
|
onSpaceUp: () => {
|
|
5826
|
-
|
|
6034
|
+
U.current?.setPanMode(!1), Qt.current === "panning" ? tn("idle") : en();
|
|
5827
6035
|
},
|
|
5828
|
-
nudge:
|
|
6036
|
+
nudge: sr
|
|
5829
6037
|
});
|
|
5830
|
-
let
|
|
6038
|
+
let wr = E(() => _r.filter((e) => J.includes(e.id) && ne(e)), [_r, J]), Tr = E(() => bn ? [...wr, bn] : wr, [wr, bn]), Dr = J.length > 0, kr = q.shapes.some((e) => J.includes(e.id) && ie(e)), Fr = !Z && J.length === 1 && (() => {
|
|
5831
6039
|
let e = q.shapes.find((e) => e.id === J[0]);
|
|
5832
|
-
return !!e && (e.type ===
|
|
5833
|
-
})(),
|
|
6040
|
+
return !!e && (e.type === L.POLYGON || e.type === L.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
|
|
6041
|
+
})(), Ir = cr(), Lr = Z || Ir.length < 2 || (N ? !N(Ir) : !1), Rr = !!de && !Z, zr = Rr && J.length === 1 ? (() => {
|
|
5834
6042
|
let e = q.shapes.find((e) => e.id === J[0]);
|
|
5835
|
-
return e && e.type ===
|
|
5836
|
-
})() : null,
|
|
6043
|
+
return e && e.type === L.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
|
|
6044
|
+
})() : null, Br = [
|
|
5837
6045
|
{
|
|
5838
6046
|
id: "copy",
|
|
5839
6047
|
label: X.contextMenu.copy,
|
|
5840
6048
|
shortcut: "⌘C",
|
|
5841
|
-
disabled: !
|
|
5842
|
-
onClick:
|
|
6049
|
+
disabled: !kr,
|
|
6050
|
+
onClick: tr
|
|
5843
6051
|
},
|
|
5844
6052
|
{
|
|
5845
6053
|
id: "paste",
|
|
5846
6054
|
label: X.contextMenu.paste,
|
|
5847
6055
|
shortcut: "⌘V",
|
|
5848
|
-
disabled: Z ||
|
|
5849
|
-
onClick: () =>
|
|
6056
|
+
disabled: Z || !nr(),
|
|
6057
|
+
onClick: () => rr(Be?.img)
|
|
5850
6058
|
},
|
|
5851
6059
|
{
|
|
5852
6060
|
id: "duplicate",
|
|
5853
6061
|
label: X.contextMenu.duplicate,
|
|
5854
6062
|
shortcut: "⌘D",
|
|
5855
|
-
disabled: !
|
|
5856
|
-
onClick:
|
|
6063
|
+
disabled: !kr || Z,
|
|
6064
|
+
onClick: ir
|
|
5857
6065
|
},
|
|
5858
6066
|
{
|
|
5859
6067
|
id: "delete",
|
|
5860
6068
|
label: X.contextMenu.delete,
|
|
5861
6069
|
shortcut: "Del",
|
|
5862
6070
|
danger: !0,
|
|
5863
|
-
disabled: !
|
|
5864
|
-
onClick:
|
|
6071
|
+
disabled: !kr || Z,
|
|
6072
|
+
onClick: er
|
|
5865
6073
|
},
|
|
5866
6074
|
{ separator: !0 },
|
|
5867
6075
|
{
|
|
5868
6076
|
id: "editVertices",
|
|
5869
6077
|
label: X.contextMenu.editVertices,
|
|
5870
6078
|
shortcut: "Enter",
|
|
5871
|
-
disabled: !
|
|
5872
|
-
onClick: () =>
|
|
6079
|
+
disabled: !Fr,
|
|
6080
|
+
onClick: () => cn(J[0])
|
|
5873
6081
|
},
|
|
5874
6082
|
{
|
|
5875
6083
|
id: "merge",
|
|
5876
6084
|
label: X.contextMenu.merge,
|
|
5877
|
-
disabled:
|
|
5878
|
-
onClick:
|
|
6085
|
+
disabled: Lr,
|
|
6086
|
+
onClick: lr
|
|
5879
6087
|
},
|
|
5880
|
-
...
|
|
6088
|
+
...Rr ? [{
|
|
5881
6089
|
id: "assistExpand",
|
|
5882
6090
|
label: X.contextMenu.assistExpand,
|
|
5883
6091
|
icon: /* @__PURE__ */ v(o, { size: 14 }),
|
|
5884
|
-
disabled: !
|
|
6092
|
+
disabled: !zr,
|
|
5885
6093
|
onClick: () => {
|
|
5886
|
-
Be &&
|
|
6094
|
+
Be && zr && Q.refineShape(zr, Be.img, !0);
|
|
5887
6095
|
}
|
|
5888
6096
|
}, {
|
|
5889
6097
|
id: "assistExclude",
|
|
5890
6098
|
label: X.contextMenu.assistExclude,
|
|
5891
6099
|
icon: /* @__PURE__ */ v(o, { size: 14 }),
|
|
5892
|
-
disabled: !
|
|
6100
|
+
disabled: !zr,
|
|
5893
6101
|
onClick: () => {
|
|
5894
|
-
Be &&
|
|
6102
|
+
Be && zr && Q.refineShape(zr, Be.img, !1);
|
|
5895
6103
|
}
|
|
5896
6104
|
}] : [],
|
|
5897
6105
|
{
|
|
5898
6106
|
id: "bringToFront",
|
|
5899
6107
|
label: X.contextMenu.bringToFront,
|
|
5900
|
-
disabled: !
|
|
5901
|
-
onClick:
|
|
6108
|
+
disabled: !kr || Z,
|
|
6109
|
+
onClick: ar
|
|
5902
6110
|
},
|
|
5903
6111
|
{
|
|
5904
6112
|
id: "sendToBack",
|
|
5905
6113
|
label: X.contextMenu.sendToBack,
|
|
5906
|
-
disabled: !
|
|
5907
|
-
onClick:
|
|
6114
|
+
disabled: !kr || Z,
|
|
6115
|
+
onClick: or
|
|
5908
6116
|
},
|
|
5909
6117
|
{ separator: !0 },
|
|
5910
6118
|
{
|
|
5911
6119
|
id: "undo",
|
|
5912
6120
|
label: X.contextMenu.undo,
|
|
5913
6121
|
shortcut: "⌘Z",
|
|
5914
|
-
disabled: Z || !
|
|
6122
|
+
disabled: Z || !Pn() && !q.canUndo(),
|
|
5915
6123
|
onClick: () => {
|
|
5916
|
-
|
|
6124
|
+
Mn() || q.undo();
|
|
5917
6125
|
}
|
|
5918
6126
|
},
|
|
5919
6127
|
{
|
|
5920
6128
|
id: "redo",
|
|
5921
6129
|
label: X.contextMenu.redo,
|
|
5922
6130
|
shortcut: "⇧⌘Z",
|
|
5923
|
-
disabled: Z || !
|
|
6131
|
+
disabled: Z || !In() && !q.canRedo(),
|
|
5924
6132
|
onClick: () => {
|
|
5925
|
-
|
|
6133
|
+
Nn() || q.redo();
|
|
5926
6134
|
}
|
|
5927
6135
|
},
|
|
5928
6136
|
{ separator: !0 },
|
|
@@ -5930,86 +6138,88 @@ function Er({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5930
6138
|
id: "selectAll",
|
|
5931
6139
|
label: X.contextMenu.selectAll,
|
|
5932
6140
|
shortcut: "⌘A",
|
|
5933
|
-
onClick:
|
|
6141
|
+
onClick: Qn
|
|
5934
6142
|
},
|
|
5935
6143
|
{
|
|
5936
6144
|
id: "clearSelection",
|
|
5937
6145
|
label: X.contextMenu.clearSelection,
|
|
5938
|
-
disabled: !
|
|
5939
|
-
onClick:
|
|
6146
|
+
disabled: !Dr,
|
|
6147
|
+
onClick: $n
|
|
5940
6148
|
},
|
|
5941
6149
|
{
|
|
5942
6150
|
id: "zoomToSelection",
|
|
5943
6151
|
label: X.contextMenu.zoomToSelection,
|
|
5944
|
-
disabled: !
|
|
5945
|
-
onClick:
|
|
6152
|
+
disabled: !Dr,
|
|
6153
|
+
onClick: fr
|
|
5946
6154
|
}
|
|
5947
|
-
],
|
|
6155
|
+
], Vr = l ? Br.filter((e) => "separator" in e || !!e.id && Nr.has(e.id)) : Br, Hr = j ? j(Vr, {
|
|
5948
6156
|
selectedIds: J,
|
|
5949
6157
|
readOnly: Z
|
|
5950
|
-
}) :
|
|
5951
|
-
engineRef:
|
|
5952
|
-
image:
|
|
6158
|
+
}) : Vr, Ur = Er({
|
|
6159
|
+
engineRef: U,
|
|
6160
|
+
image: K,
|
|
5953
6161
|
wheelZoom: Y.wheelZoom,
|
|
5954
6162
|
minimapSize: 204
|
|
5955
|
-
}),
|
|
5956
|
-
|
|
5957
|
-
}, []),
|
|
6163
|
+
}), Wr = x(() => {
|
|
6164
|
+
U.current?.zoom100();
|
|
6165
|
+
}, []), Gr = x(() => {
|
|
5958
6166
|
Ge((e) => !e);
|
|
5959
|
-
}, []),
|
|
6167
|
+
}, []), Kr = x(() => {
|
|
5960
6168
|
qe((e) => !e);
|
|
5961
|
-
}, []),
|
|
6169
|
+
}, []), qr = x(() => {
|
|
5962
6170
|
qe(!1);
|
|
5963
6171
|
}, []);
|
|
5964
6172
|
return /* @__PURE__ */ y("div", {
|
|
5965
6173
|
className: "aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black",
|
|
5966
6174
|
children: [
|
|
5967
6175
|
/* @__PURE__ */ v("div", {
|
|
5968
|
-
ref:
|
|
6176
|
+
ref: Te,
|
|
5969
6177
|
className: "aivex:h-full aivex:w-full",
|
|
5970
6178
|
style: {
|
|
5971
|
-
opacity: +!!
|
|
5972
|
-
transition:
|
|
6179
|
+
opacity: +!!Me,
|
|
6180
|
+
transition: Me ? "opacity 0.3s ease" : "none"
|
|
5973
6181
|
}
|
|
5974
6182
|
}),
|
|
5975
|
-
nt !== "ready" && /* @__PURE__ */ v(
|
|
6183
|
+
nt !== "ready" && /* @__PURE__ */ v(Le, {
|
|
5976
6184
|
status: nt,
|
|
6185
|
+
error: ct,
|
|
5977
6186
|
render: n,
|
|
5978
6187
|
loadingLabel: X.imageLoading,
|
|
5979
|
-
errorLabel: X.imageLoadError
|
|
6188
|
+
errorLabel: X.imageLoadError,
|
|
6189
|
+
errorHints: X.imageErrorHints
|
|
5980
6190
|
}),
|
|
5981
|
-
|
|
6191
|
+
Re && K && /* @__PURE__ */ v("div", {
|
|
5982
6192
|
className: "aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden",
|
|
5983
6193
|
children: /* @__PURE__ */ y("div", {
|
|
5984
|
-
ref:
|
|
6194
|
+
ref: De,
|
|
5985
6195
|
style: {
|
|
5986
6196
|
position: "absolute",
|
|
5987
6197
|
top: 0,
|
|
5988
6198
|
left: 0,
|
|
5989
|
-
width:
|
|
5990
|
-
height:
|
|
6199
|
+
width: K.w,
|
|
6200
|
+
height: K.h,
|
|
5991
6201
|
transformOrigin: "0 0"
|
|
5992
6202
|
},
|
|
5993
6203
|
children: [
|
|
5994
|
-
!!
|
|
6204
|
+
!!ae?.length && B && /* @__PURE__ */ v("div", {
|
|
5995
6205
|
style: {
|
|
5996
6206
|
position: "absolute",
|
|
5997
6207
|
left: 0,
|
|
5998
6208
|
top: 0,
|
|
5999
|
-
width:
|
|
6000
|
-
height:
|
|
6209
|
+
width: K.w,
|
|
6210
|
+
height: K.h,
|
|
6001
6211
|
pointerEvents: "none"
|
|
6002
6212
|
},
|
|
6003
|
-
children:
|
|
6213
|
+
children: ae.map((e) => /* @__PURE__ */ v("div", {
|
|
6004
6214
|
role: e.disabled ? void 0 : "button",
|
|
6005
6215
|
tabIndex: e.disabled ? void 0 : 0,
|
|
6006
6216
|
"aria-pressed": e.selected || void 0,
|
|
6007
6217
|
onPointerDown: (e) => e.stopPropagation(),
|
|
6008
6218
|
onClick: (t) => {
|
|
6009
|
-
t.stopPropagation(), e.disabled ||
|
|
6219
|
+
t.stopPropagation(), e.disabled || V?.(e);
|
|
6010
6220
|
},
|
|
6011
6221
|
onKeyDown: (t) => {
|
|
6012
|
-
e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(),
|
|
6222
|
+
e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), V?.(e));
|
|
6013
6223
|
},
|
|
6014
6224
|
style: {
|
|
6015
6225
|
position: "absolute",
|
|
@@ -6021,26 +6231,26 @@ function Er({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6021
6231
|
pointerEvents: e.disabled ? "none" : "auto",
|
|
6022
6232
|
cursor: e.disabled ? "default" : "pointer"
|
|
6023
6233
|
},
|
|
6024
|
-
children:
|
|
6234
|
+
children: B(e)
|
|
6025
6235
|
}, e.id))
|
|
6026
6236
|
}),
|
|
6027
|
-
|
|
6028
|
-
image:
|
|
6029
|
-
viewport:
|
|
6237
|
+
se?.({
|
|
6238
|
+
image: K,
|
|
6239
|
+
viewport: U.current?.viewport ?? {
|
|
6030
6240
|
scale: 1,
|
|
6031
6241
|
x: 0,
|
|
6032
6242
|
y: 0
|
|
6033
6243
|
}
|
|
6034
6244
|
}),
|
|
6035
|
-
|
|
6036
|
-
shapes:
|
|
6037
|
-
getLabel:
|
|
6038
|
-
hideDot:
|
|
6039
|
-
formatInfo:
|
|
6040
|
-
register:
|
|
6245
|
+
Tr.length > 0 && /* @__PURE__ */ v(st, {
|
|
6246
|
+
shapes: Tr,
|
|
6247
|
+
getLabel: H,
|
|
6248
|
+
hideDot: ce,
|
|
6249
|
+
formatInfo: le,
|
|
6250
|
+
register: vn
|
|
6041
6251
|
}),
|
|
6042
|
-
|
|
6043
|
-
image:
|
|
6252
|
+
de && (Q.status === "loading" || Q.boxes.length > 0) && /* @__PURE__ */ v(Ne, {
|
|
6253
|
+
image: K,
|
|
6044
6254
|
points: Q.points,
|
|
6045
6255
|
boxes: Q.boxes,
|
|
6046
6256
|
status: Q.status
|
|
@@ -6048,38 +6258,38 @@ function Er({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6048
6258
|
]
|
|
6049
6259
|
})
|
|
6050
6260
|
}),
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
image:
|
|
6261
|
+
Re && Y.showCursorGuide && /* @__PURE__ */ v(Ie, { color: "#1e88e5" }),
|
|
6262
|
+
K && b && /* @__PURE__ */ v(Ze, {
|
|
6263
|
+
image: K,
|
|
6054
6264
|
imageUrl: tt,
|
|
6055
|
-
imageVisible:
|
|
6056
|
-
loading: !
|
|
6057
|
-
maskDataUrl:
|
|
6058
|
-
region:
|
|
6059
|
-
roiMaskId:
|
|
6060
|
-
shapes:
|
|
6265
|
+
imageVisible: Me,
|
|
6266
|
+
loading: !Re,
|
|
6267
|
+
maskDataUrl: Tt,
|
|
6268
|
+
region: Dt,
|
|
6269
|
+
roiMaskId: Ae,
|
|
6270
|
+
shapes: _r,
|
|
6061
6271
|
view: Y,
|
|
6062
|
-
viewDefaults:
|
|
6063
|
-
onChangeView:
|
|
6064
|
-
nav:
|
|
6065
|
-
registerShape:
|
|
6066
|
-
rectRef:
|
|
6067
|
-
zoomLabelRef:
|
|
6068
|
-
onZoom100:
|
|
6272
|
+
viewDefaults: vt,
|
|
6273
|
+
onChangeView: xt,
|
|
6274
|
+
nav: Ur,
|
|
6275
|
+
registerShape: pn,
|
|
6276
|
+
rectRef: Ee,
|
|
6277
|
+
zoomLabelRef: W,
|
|
6278
|
+
onZoom100: Wr,
|
|
6069
6279
|
open: We,
|
|
6070
|
-
onToggleOpen:
|
|
6280
|
+
onToggleOpen: Gr,
|
|
6071
6281
|
position: D,
|
|
6072
6282
|
labels: X.minimap,
|
|
6073
6283
|
settingsLabels: X.viewSettings,
|
|
6074
6284
|
showSettings: A,
|
|
6075
6285
|
settingsOpen: Ke,
|
|
6076
|
-
onToggleSettings:
|
|
6077
|
-
onCloseSettings:
|
|
6286
|
+
onToggleSettings: Kr,
|
|
6287
|
+
onCloseSettings: qr
|
|
6078
6288
|
}),
|
|
6079
|
-
Be && /* @__PURE__ */ v(
|
|
6289
|
+
Be && /* @__PURE__ */ v(Fe, {
|
|
6080
6290
|
x: Be.x,
|
|
6081
6291
|
y: Be.y,
|
|
6082
|
-
items:
|
|
6292
|
+
items: Hr,
|
|
6083
6293
|
onClose: () => Ve(null)
|
|
6084
6294
|
})
|
|
6085
6295
|
]
|
|
@@ -6087,47 +6297,35 @@ function Er({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6087
6297
|
}
|
|
6088
6298
|
//#endregion
|
|
6089
6299
|
//#region src/components/ShapeEditor/ShapeViewer.tsx
|
|
6090
|
-
|
|
6091
|
-
let t = await In(e);
|
|
6092
|
-
return await new Promise((n, r) => {
|
|
6093
|
-
let i = new Image();
|
|
6094
|
-
t || (i.crossOrigin = "anonymous"), i.onload = () => n({
|
|
6095
|
-
image: i,
|
|
6096
|
-
revoke: t ? () => URL.revokeObjectURL(t) : null
|
|
6097
|
-
}), i.onerror = () => {
|
|
6098
|
-
t && URL.revokeObjectURL(t), r(/* @__PURE__ */ Error("Failed to load image"));
|
|
6099
|
-
}, i.src = t ?? e;
|
|
6100
|
-
});
|
|
6101
|
-
}
|
|
6102
|
-
function Or(e, t, n) {
|
|
6300
|
+
function Ir(e, t, n) {
|
|
6103
6301
|
if (t.length !== 0) {
|
|
6104
6302
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
6105
6303
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
6106
6304
|
n && e.closePath();
|
|
6107
6305
|
}
|
|
6108
6306
|
}
|
|
6109
|
-
function
|
|
6307
|
+
function Lr(e, t, n, r) {
|
|
6110
6308
|
if (t.interaction?.visible === !1) return;
|
|
6111
6309
|
let i = Ue(t, {
|
|
6112
6310
|
strokeWidth: r,
|
|
6113
6311
|
pointRadius: 2
|
|
6114
6312
|
});
|
|
6115
|
-
if (e.save(), e.globalAlpha = i.opacity, e.lineWidth = i.strokeWidth / n, e.lineJoin = "round", e.lineCap = "round", t.type ===
|
|
6313
|
+
if (e.save(), e.globalAlpha = i.opacity, e.lineWidth = i.strokeWidth / n, e.lineJoin = "round", e.lineCap = "round", t.type === L.POINT) {
|
|
6116
6314
|
let r = t.points[0];
|
|
6117
6315
|
r && (e.fillStyle = i.color, e.beginPath(), e.arc(r.x, r.y, i.pointRadius / n, 0, Math.PI * 2), e.fill()), e.restore();
|
|
6118
6316
|
return;
|
|
6119
6317
|
}
|
|
6120
|
-
if (t.type ===
|
|
6318
|
+
if (t.type === L.RECTANGLE || t.type === L.ELLIPSE) {
|
|
6121
6319
|
let [n, r] = t.points;
|
|
6122
6320
|
if (n && r) {
|
|
6123
6321
|
let i = Math.min(n.x, r.x), a = Math.min(n.y, r.y), o = Math.abs(r.x - n.x), s = Math.abs(r.y - n.y);
|
|
6124
|
-
e.beginPath(), t.type ===
|
|
6322
|
+
e.beginPath(), t.type === L.ELLIPSE ? e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2) : e.rect(i, a, o, s);
|
|
6125
6323
|
}
|
|
6126
|
-
} else
|
|
6324
|
+
} else Ir(e, t.points, t.type !== L.LINE);
|
|
6127
6325
|
i.fillVisible && (e.save(), e.fillStyle = i.color, e.globalAlpha *= i.fillAlpha, e.fill(), e.restore()), t.style?.alternateColor && i.dash?.length && (e.setLineDash([]), e.strokeStyle = t.style.alternateColor, e.stroke()), e.setLineDash((i.dash ?? []).map((e) => e / n)), e.strokeStyle = i.color, e.stroke(), e.restore();
|
|
6128
6326
|
}
|
|
6129
|
-
function
|
|
6130
|
-
let b = O(null), x = O(null), C = O(null), [w, T] = k(!m), [D, A] = k("loading"), [j,
|
|
6327
|
+
function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes: r = [], regionMask: i, guideMask: a, maskPalette: o, focusedShapeId: s, focusFit: c = "contain", zoomPadding: l = .3, strokeSize: u = 1, brightness: d = 1, contrast: f = 1, imageSmoothing: p = !0, lazy: m = !0, className: h, style: g, renderImageState: _ }) {
|
|
6328
|
+
let b = O(null), x = O(null), C = O(null), [w, T] = k(!m), [D, A] = k("loading"), [j, M] = k(null), [N, P] = k(0);
|
|
6131
6329
|
S(() => {
|
|
6132
6330
|
if (!m || w) return;
|
|
6133
6331
|
let e = b.current;
|
|
@@ -6139,29 +6337,30 @@ function Ar({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6139
6337
|
}, [m, w]), S(() => {
|
|
6140
6338
|
let e = b.current;
|
|
6141
6339
|
if (!e) return;
|
|
6142
|
-
let t = new ResizeObserver(() =>
|
|
6340
|
+
let t = new ResizeObserver(() => P((e) => e + 1));
|
|
6143
6341
|
return t.observe(e), () => t.disconnect();
|
|
6144
6342
|
}, []), S(() => {
|
|
6145
6343
|
if (!w || !e) {
|
|
6146
|
-
A(e ? "loading" : "error");
|
|
6344
|
+
A(e ? "loading" : "error"), M(null);
|
|
6147
6345
|
return;
|
|
6148
6346
|
}
|
|
6149
6347
|
let t = !0;
|
|
6150
|
-
return A("loading"),
|
|
6151
|
-
if (!t)
|
|
6152
|
-
|
|
6348
|
+
return A("loading"), M(null), Ln(e).then(async (n) => {
|
|
6349
|
+
if (!t) return;
|
|
6350
|
+
if (n) {
|
|
6351
|
+
C.current = n, A("ready");
|
|
6153
6352
|
return;
|
|
6154
6353
|
}
|
|
6155
|
-
C.current
|
|
6156
|
-
|
|
6157
|
-
t && (
|
|
6354
|
+
C.current = null, A("error");
|
|
6355
|
+
let r = await Hn(e);
|
|
6356
|
+
t && M(r);
|
|
6158
6357
|
}), () => {
|
|
6159
6358
|
t = !1;
|
|
6160
6359
|
};
|
|
6161
6360
|
}, [e, w]), S(() => () => {
|
|
6162
|
-
C.current
|
|
6361
|
+
C.current = null;
|
|
6163
6362
|
}, []);
|
|
6164
|
-
let
|
|
6363
|
+
let F = E(() => r.find((e) => e.id === s), [s, r]), ee = E(() => a && o ? kt(a, o) : null, [a, o]);
|
|
6165
6364
|
return S(() => {
|
|
6166
6365
|
if (D === "error") {
|
|
6167
6366
|
let e = x.current;
|
|
@@ -6176,40 +6375,40 @@ function Ar({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6176
6375
|
t.width = Math.max(1, Math.round(o * m)), t.height = Math.max(1, Math.round(s * m)), t.style.width = `${o}px`, t.style.height = `${s}px`;
|
|
6177
6376
|
let h = t.getContext("2d");
|
|
6178
6377
|
if (!h) return;
|
|
6179
|
-
let g = n?.width ?? a.
|
|
6378
|
+
let g = n?.width ?? a.naturalWidth, _ = n?.height ?? a.naturalHeight;
|
|
6180
6379
|
if (!g || !_) return;
|
|
6181
6380
|
let v = Math.min(o / g, s / _), y = (o - g * v) / 2, S = (s - _ * v) / 2;
|
|
6182
|
-
if (
|
|
6183
|
-
let e =
|
|
6381
|
+
if (F && F.points.length > 0) {
|
|
6382
|
+
let e = V(F.points), t = Math.max(e.maxX - e.minX, 50), n = Math.max(e.maxY - e.minY, 50), r = Math.min(t, n) * l;
|
|
6184
6383
|
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, S = s / 2 - (e.minY + e.maxY) / 2 * v, c === "cover" && (y = Math.min(0, Math.max(y, o - g * v)), S = Math.min(0, Math.max(S, s - _ * v)));
|
|
6185
6384
|
}
|
|
6186
|
-
h.setTransform(m, 0, 0, m, 0, 0), h.clearRect(0, 0, o, s), h.save(), h.translate(y, S), h.scale(v, v), h.imageSmoothingEnabled = p, h.filter = `brightness(${d}) contrast(${f})`, h.drawImage(a
|
|
6187
|
-
let w = i ?
|
|
6385
|
+
h.setTransform(m, 0, 0, m, 0, 0), h.clearRect(0, 0, o, s), h.save(), h.translate(y, S), h.scale(v, v), h.imageSmoothingEnabled = p, h.filter = `brightness(${d}) contrast(${f})`, h.drawImage(a, 0, 0, g, _), h.filter = "none", ee && (h.save(), h.globalAlpha = .55, h.drawImage(ee, 0, 0, g, _), h.restore());
|
|
6386
|
+
let w = i ? Vt(i, g, _) : null;
|
|
6188
6387
|
if (w && (It(h, w, g, _), w.outlineStyles)) {
|
|
6189
6388
|
let e = (e, t) => {
|
|
6190
6389
|
if (h.lineWidth = t.width / v, t.underlayColor) {
|
|
6191
6390
|
h.setLineDash([]), h.strokeStyle = t.underlayColor;
|
|
6192
|
-
for (let [t, n] of e)
|
|
6391
|
+
for (let [t, n] of e) Ir(h, [t, n], !1), h.stroke();
|
|
6193
6392
|
}
|
|
6194
6393
|
h.save(), h.globalAlpha *= t.opacity, h.setLineDash(t.dash.map((e) => e / v)), h.strokeStyle = t.color;
|
|
6195
|
-
for (let [t, n] of e)
|
|
6394
|
+
for (let [t, n] of e) Ir(h, [t, n], !1), h.stroke();
|
|
6196
6395
|
h.restore();
|
|
6197
6396
|
};
|
|
6198
6397
|
e(w.visibleOutline, w.outlineStyles.visible), e(w.occludedOutline, w.outlineStyles.occluded);
|
|
6199
6398
|
}
|
|
6200
|
-
for (let e of
|
|
6399
|
+
for (let e of ae(r)) Lr(h, e, v, u);
|
|
6201
6400
|
h.restore();
|
|
6202
6401
|
}, [
|
|
6203
6402
|
d,
|
|
6204
6403
|
f,
|
|
6205
6404
|
n,
|
|
6206
|
-
|
|
6405
|
+
F,
|
|
6207
6406
|
c,
|
|
6208
6407
|
p,
|
|
6209
|
-
|
|
6408
|
+
ee,
|
|
6210
6409
|
i,
|
|
6211
6410
|
r,
|
|
6212
|
-
|
|
6411
|
+
N,
|
|
6213
6412
|
D,
|
|
6214
6413
|
u,
|
|
6215
6414
|
l
|
|
@@ -6227,16 +6426,45 @@ function Ar({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6227
6426
|
role: "img",
|
|
6228
6427
|
"aria-label": t,
|
|
6229
6428
|
style: { display: "block" }
|
|
6230
|
-
}), D !== "ready" &&
|
|
6429
|
+
}), D !== "ready" && /* @__PURE__ */ v("div", {
|
|
6231
6430
|
style: {
|
|
6232
6431
|
position: "absolute",
|
|
6233
6432
|
inset: 0
|
|
6234
6433
|
},
|
|
6235
|
-
children: _(D === "error" ? "error" : "loading")
|
|
6434
|
+
children: _?.(D === "error" ? "error" : "loading", j) ?? (D === "error" ? /* @__PURE__ */ y("div", {
|
|
6435
|
+
style: {
|
|
6436
|
+
display: "flex",
|
|
6437
|
+
flexDirection: "column",
|
|
6438
|
+
alignItems: "center",
|
|
6439
|
+
justifyContent: "center",
|
|
6440
|
+
height: "100%",
|
|
6441
|
+
gap: 4,
|
|
6442
|
+
padding: 8,
|
|
6443
|
+
textAlign: "center",
|
|
6444
|
+
color: "rgba(255,255,255,0.85)",
|
|
6445
|
+
background: "rgba(13,13,18,0.85)",
|
|
6446
|
+
fontSize: 12
|
|
6447
|
+
},
|
|
6448
|
+
children: [
|
|
6449
|
+
/* @__PURE__ */ v("span", {
|
|
6450
|
+
"aria-hidden": !0,
|
|
6451
|
+
children: "⚠"
|
|
6452
|
+
}),
|
|
6453
|
+
/* @__PURE__ */ v("span", { children: W.imageLoadError }),
|
|
6454
|
+
j && /* @__PURE__ */ v("span", {
|
|
6455
|
+
style: {
|
|
6456
|
+
fontSize: 11,
|
|
6457
|
+
opacity: .7,
|
|
6458
|
+
wordBreak: "break-all"
|
|
6459
|
+
},
|
|
6460
|
+
children: W.imageErrorHints[j.kind]
|
|
6461
|
+
})
|
|
6462
|
+
]
|
|
6463
|
+
}) : null)
|
|
6236
6464
|
})]
|
|
6237
6465
|
});
|
|
6238
6466
|
}
|
|
6239
6467
|
//#endregion
|
|
6240
|
-
export {
|
|
6468
|
+
export { W as DEFAULT_EDITOR_STRINGS, ke as DEFAULT_VIEW_SETTINGS, L as SHAPE_TYPE, Fr as ShapeEditor, Fr as default, Rr as ShapeViewer, G as TOOL, oe as generateId };
|
|
6241
6469
|
|
|
6242
6470
|
//# sourceMappingURL=shape-editor.js.map
|