@glodon-aiot/dataset-annotation 3.24.0-alpha.6 → 3.25.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/es/components/ClassificationAnnotation/index.mjs +374 -325
  2. package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +82 -78
  3. package/dist/es/components/DetectionAnnotation/components/ImageModal/index.mjs +28 -26
  4. package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +173 -166
  5. package/dist/es/components/DetectionAnnotation/index.mjs +478 -473
  6. package/dist/es/components/OcrAnnotation/OCRBoxDetail/index.mjs +249 -230
  7. package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +103 -98
  8. package/dist/es/components/OcrAnnotation/index.mjs +281 -248
  9. package/dist/es/components/VLMAnnotationDetail/VLMDetail/index.mjs +277 -272
  10. package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +42 -40
  11. package/dist/es/components/VLMAnnotationDetail/index.mjs +331 -278
  12. package/dist/es/index.mjs +1 -1
  13. package/dist/es/utils/checkVlmSampleLabeled.mjs +7 -0
  14. package/dist/es/utils/scrollSampleIntoView.mjs +16 -0
  15. package/dist/lib/index.js +4 -4
  16. package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +2 -0
  17. package/dist/src/components/DetectionAnnotation/components/ImageModal/index.d.ts +2 -0
  18. package/dist/src/components/OcrAnnotation/OCRBoxDetail/index.d.ts +2 -0
  19. package/dist/src/components/OcrAnnotation/OcrModal/index.d.ts +1 -0
  20. package/dist/src/components/VLMAnnotationDetail/VLMDetail/index.d.ts +6 -0
  21. package/dist/src/components/VLMAnnotationDetail/VlmModal/index.d.ts +5 -0
  22. package/dist/src/utils/checkVlmSampleLabeled.d.ts +8 -0
  23. package/dist/src/utils/scrollSampleIntoView.d.ts +9 -0
  24. package/package.json +2 -2
@@ -1,17 +1,17 @@
1
- var oe = Math.pow;
2
- import { jsx as u, jsxs as ne } from "react/jsx-runtime";
3
- import { useRef as re, useState as I, useEffect as p } from "react";
4
- import { fabric as G } from "fabric";
1
+ var re = Math.pow;
2
+ import { jsx as u, jsxs as ce } from "react/jsx-runtime";
3
+ import { useRef as G, useState as C, useEffect as p } from "react";
4
+ import { fabric as J } from "fabric";
5
5
  import { useKeyPress as N } from "ahooks";
6
6
  import "./style.less.mjs";
7
- import ue from "react-dom";
8
- import { Spin as he, Space as me, Tooltip as U, Button as z } from "antd";
9
- import ce from "./RectLabel.mjs";
10
- import { drawable as ge } from "./Drawable.mjs";
11
- import { ZoomInOutlined as be, ZoomOutOutlined as pe, DragOutlined as ye, ClearOutlined as xe } from "@ant-design/icons";
7
+ import he from "react-dom";
8
+ import { Spin as me, Space as ge, Tooltip as U, Button as z } from "antd";
9
+ import ie from "./RectLabel.mjs";
10
+ import { drawable as be } from "./Drawable.mjs";
11
+ import { ZoomInOutlined as pe, ZoomOutOutlined as ye, DragOutlined as xe, ClearOutlined as De } from "@ant-design/icons";
12
12
  import ve from "classnames";
13
13
  import { approxeq as Y } from "../../../../utils/index.mjs";
14
- const T = (l) => {
14
+ const R = (l) => {
15
15
  l.off("mouse:down"), l.off("mouse:up");
16
16
  }, A = (l) => {
17
17
  var f, P, k;
@@ -30,8 +30,8 @@ const T = (l) => {
30
30
  color: l.config.color,
31
31
  box: (h == null ? void 0 : h.map((a) => [Y(a.x - g.x, 0) ? 0 : Y(a.x - g.x, y.width) ? y.width : a.x - g.x, Y(a.y - g.y, 0) ? 0 : Y(a.y - g.y, y.height) ? y.height : a.y - g.y])) || []
32
32
  };
33
- }, Ue = (l) => {
34
- const h = re(null), {
33
+ }, ze = (l) => {
34
+ const h = G(null), {
35
35
  labels: g,
36
36
  imageUrl: y,
37
37
  pen: f,
@@ -41,61 +41,61 @@ const T = (l) => {
41
41
  isPreLabel: _,
42
42
  disabled: w,
43
43
  renderLabelItem: X
44
- } = l, [B, W] = I(!0), [e, J] = I(), [De, ie] = I({}), [j, Q] = I(), [Z, se] = I({
44
+ } = l, [B, W] = C(!0), [e, Q] = C(), [je, se] = C({}), [j, $] = C(), [Z, ae] = C({
45
45
  left: 0,
46
46
  top: 0
47
- }), [ae, K] = I([1, 1]), [R, $] = I(), [C, v] = I([]), D = re(/* @__PURE__ */ new Set()), [x, L] = I(w || !1), s = (o) => {
48
- if (!o)
47
+ }), [le, K] = C([1, 1]), [T, V] = C(), [I, D] = C([]), v = G(/* @__PURE__ */ new Set()), ee = G(0), [x, L] = C(w || !1), s = (n) => {
48
+ if (!n)
49
49
  return !1;
50
50
  try {
51
- return !!o.getContext();
51
+ return !!n.getContext();
52
52
  } catch (t) {
53
53
  return !1;
54
54
  }
55
- }, H = (o, t) => {
55
+ }, H = (n, t) => {
56
56
  if (!e || !s(e))
57
57
  return;
58
58
  t || (t = {
59
59
  x: e.getCenter().left,
60
60
  y: e.getCenter().top
61
61
  });
62
- let n = e.getZoom();
63
- n *= oe(0.999, o), n > 20 && (n = 20), n < 0.01 && (n = 0.01);
62
+ let o = e.getZoom();
63
+ o *= re(0.999, n), o > 20 && (o = 20), o < 0.01 && (o = 0.01);
64
64
  try {
65
65
  e.zoomToPoint(
66
66
  t,
67
- n
67
+ o
68
68
  // 传入修改后的缩放级别
69
- ), K([n, n]);
69
+ ), K([o, o]);
70
70
  } catch (r) {
71
71
  }
72
72
  };
73
73
  p(() => {
74
- !e || !s(e) || C.forEach((o) => {
74
+ !e || !s(e) || I.forEach((n) => {
75
75
  try {
76
- o.renderLabel();
76
+ n.renderLabel();
77
77
  } catch (t) {
78
78
  }
79
79
  });
80
- }, [ae, C, e]);
81
- const V = (o) => {
82
- var n;
83
- if (((n = o.target) == null ? void 0 : n.tagName) === "INPUT" || !e || !s(e))
80
+ }, [le, I, e]);
81
+ const te = (n) => {
82
+ var o;
83
+ if (((o = n.target) == null ? void 0 : o.tagName) === "INPUT" || !e || !s(e))
84
84
  return;
85
85
  const t = e == null ? void 0 : e.getActiveObject();
86
- t && v((r) => {
86
+ t && D((r) => {
87
87
  let d = r.findIndex((i) => i.object === t);
88
88
  if (d === -1 && t && (d = r.findIndex((i) => {
89
89
  const c = i._fabricRect;
90
90
  return c && c === t;
91
91
  })), d >= 0 && r[d]) {
92
92
  const i = r[d];
93
- D.current.add(i.config.id);
93
+ v.current.add(i.config.id);
94
94
  const c = i.handlers.onDelete;
95
95
  i.handlers.onDelete = void 0, i.destroy(), i.handlers.onDelete = c, r.splice(d, 1);
96
96
  const m = r.map(A);
97
97
  a && a(m), setTimeout(() => {
98
- D.current.delete(i.config.id);
98
+ v.current.delete(i.config.id);
99
99
  }, 100);
100
100
  } else if (t && e) {
101
101
  const i = r.findIndex((c) => {
@@ -104,12 +104,12 @@ const T = (l) => {
104
104
  });
105
105
  if (i >= 0 && r[i]) {
106
106
  const c = r[i];
107
- D.current.add(c.config.id);
107
+ v.current.add(c.config.id);
108
108
  const m = c.handlers.onDelete;
109
109
  c.handlers.onDelete = void 0, c.destroy(), c.handlers.onDelete = m, r.splice(i, 1);
110
110
  const S = r.map(A);
111
111
  a && a(S), setTimeout(() => {
112
- D.current.delete(c.config.id);
112
+ v.current.delete(c.config.id);
113
113
  }, 100);
114
114
  } else
115
115
  e.remove(t), e.discardActiveObject(), e.renderAll();
@@ -117,7 +117,7 @@ const T = (l) => {
117
117
  return [...r];
118
118
  });
119
119
  };
120
- N("Delete", V), N("Backspace", V), N("ctrl", () => {
120
+ N("Delete", te), N("Backspace", te), N("ctrl", () => {
121
121
  L(!0);
122
122
  }, {
123
123
  events: ["keydown"]
@@ -128,20 +128,20 @@ const T = (l) => {
128
128
  }), p(() => {
129
129
  L(w || !1);
130
130
  }, [w]);
131
- const ee = (o) => {
132
- e && T(e), v((t) => {
133
- const n = t.findIndex((r) => r === o);
134
- if (n > -1) {
135
- t.splice(n, 1);
131
+ const oe = (n) => {
132
+ e && R(e), D((t) => {
133
+ const o = t.findIndex((r) => r === n);
134
+ if (o > -1) {
135
+ t.splice(o, 1);
136
136
  const r = t.map(A);
137
137
  a && a(r), M();
138
138
  }
139
139
  return [...t];
140
140
  });
141
- }, te = (o) => {
142
- v((t) => {
143
- const n = t.findIndex((r) => r === o);
144
- return n > -1 && (t[n] = o, a && a(t.map(A))), [...t];
141
+ }, ne = (n) => {
142
+ D((t) => {
143
+ const o = t.findIndex((r) => r === n);
144
+ return o > -1 && (t[o] = n, a && a(t.map(A))), [...t];
145
145
  });
146
146
  };
147
147
  p(() => {
@@ -155,49 +155,52 @@ const T = (l) => {
155
155
  }
156
156
  if (!j)
157
157
  return;
158
- const o = [];
158
+ const n = [];
159
159
  return g.filter((t) => t.color).forEach((t) => {
160
- o.push(new ce({
160
+ n.push(new ie({
161
161
  id: t.id,
162
162
  name: t.label,
163
163
  color: t.color,
164
- points: t.box.map((n) => [n[0] + Z.left, n[1] + Z.top]),
164
+ points: t.box.map((o) => [o[0] + Z.left, o[1] + Z.top]),
165
165
  hideDelete: _
166
166
  }, e, {
167
- onChange: te,
168
- onDelete: ee,
169
- renderLabelItem: X ? (n) => X ? X(t) : n.name : void 0
167
+ onChange: ne,
168
+ onDelete: oe,
169
+ renderLabelItem: X ? (o) => X ? X(t) : o.name : void 0
170
170
  }));
171
- }), v(o), o.forEach((t) => {
171
+ }), D(n), n.forEach((t) => {
172
172
  try {
173
173
  t.render(e);
174
- } catch (n) {
174
+ } catch (o) {
175
175
  }
176
176
  }), () => {
177
- o.forEach((t) => {
177
+ n.forEach((t) => {
178
178
  try {
179
- t.canvas !== e && t.destroy();
180
- } catch (n) {
179
+ if (t.canvas !== e) {
180
+ const o = t.handlers.onDelete;
181
+ t.handlers.onDelete = void 0, t.destroy(), t.handlers.onDelete = o;
182
+ }
183
+ } catch (o) {
181
184
  }
182
185
  });
183
186
  };
184
187
  }, [e, y, j, Z]);
185
188
  const M = () => {
186
- !e || !s(e) || ge(e, (o) => {
189
+ !e || !s(e) || be(e, (n) => {
187
190
  if (!e || !s(e))
188
191
  return;
189
- const t = new ce({
190
- id: (f == null ? void 0 : f.id) || o.id,
191
- name: (f == null ? void 0 : f.label) || o.label,
192
- color: (f == null ? void 0 : f.color) || o.color,
193
- points: o.box.map((n) => [n[0], n[1]]),
192
+ const t = new ie({
193
+ id: (f == null ? void 0 : f.id) || n.id,
194
+ name: (f == null ? void 0 : f.label) || n.label,
195
+ color: (f == null ? void 0 : f.color) || n.color,
196
+ points: n.box.map((o) => [o[0], o[1]]),
194
197
  hideDelete: _
195
198
  }, e, {
196
- onChange: te,
197
- onDelete: ee
199
+ onChange: ne,
200
+ onDelete: oe
198
201
  });
199
- t.active = !0, v((n) => {
200
- const r = [...n, t];
202
+ t.active = !0, D((o) => {
203
+ const r = [...o, t];
201
204
  return a && a(r.map(A)), setTimeout(() => {
202
205
  if (t.object && e && s(e))
203
206
  try {
@@ -208,28 +211,28 @@ const T = (l) => {
208
211
  }, 0), r;
209
212
  });
210
213
  }, _);
211
- }, le = () => {
212
- let o = !1;
214
+ }, fe = () => {
215
+ let n = !1;
213
216
  e && (e.on("mouse:down", (t) => {
214
- o = !0, e.selection = !1;
217
+ n = !0, e.selection = !1;
215
218
  }), e.on("mouse:move", (t) => {
216
- if (o && t && t.e) {
217
- const n = new G.Point(t.e.movementX, t.e.movementY);
218
- e.relativePan(n);
219
+ if (n && t && t.e) {
220
+ const o = new J.Point(t.e.movementX, t.e.movementY);
221
+ e.relativePan(o);
219
222
  }
220
223
  }), e.on("mouse:up", (t) => {
221
- o = !1, e.selection = !0;
224
+ n = !1, e.selection = !0;
222
225
  }));
223
- }, fe = () => {
226
+ }, de = () => {
224
227
  e && (e.off("mouse:down"), e.off("mouse:move"), e.off("mouse:up"));
225
228
  };
226
229
  p(() => {
227
230
  if (!e || !s(e))
228
231
  return;
229
- const o = (t) => {
232
+ const n = (t) => {
230
233
  if (!s(e))
231
234
  return;
232
- const n = e, r = n == null ? void 0 : n._currentTransform;
235
+ const o = e, r = o == null ? void 0 : o._currentTransform;
233
236
  if (!r)
234
237
  return;
235
238
  const d = r.action;
@@ -240,146 +243,150 @@ const T = (l) => {
240
243
  try {
241
244
  const m = e.getPointer(t.e);
242
245
  if (m.x < c.tl.x || m.x > c.br.x || m.y < c.tl.y || m.y > c.br.y) {
243
- const O = n == null ? void 0 : n._onMouseUp;
246
+ const O = o == null ? void 0 : o._onMouseUp;
244
247
  typeof O == "function" && O(t.e);
245
248
  }
246
249
  } catch (m) {
247
250
  }
248
251
  };
249
- return e.on("mouse:move", o), () => {
252
+ return e.on("mouse:move", n), () => {
250
253
  if (e && s(e))
251
254
  try {
252
- e.off("mouse:move", o);
255
+ e.off("mouse:move", n);
253
256
  } catch (t) {
254
257
  }
255
258
  };
256
259
  }, [e]), p(() => {
257
260
  if (!e || !s(e))
258
261
  return;
259
- const o = (t) => {
262
+ const n = (t) => {
260
263
  if (!s(e))
261
264
  return;
262
- const n = e;
263
- if (!!!(n != null && n._currentTransform))
265
+ const o = e;
266
+ if (!!!(o != null && o._currentTransform))
264
267
  return;
265
- const d = n == null ? void 0 : n._onMouseUp;
268
+ const d = o == null ? void 0 : o._onMouseUp;
266
269
  typeof d == "function" && d(t.e);
267
270
  };
268
- return e.on("mouse:out", o), () => {
271
+ return e.on("mouse:out", n), () => {
269
272
  if (e && s(e))
270
273
  try {
271
- e.off("mouse:out", o);
274
+ e.off("mouse:out", n);
272
275
  } catch (t) {
273
276
  }
274
277
  };
275
278
  }, [e]), p(() => {
276
279
  if (!(!e || !s(e))) {
277
280
  if (x) {
278
- le();
281
+ fe();
279
282
  try {
280
283
  e.defaultCursor = "grab";
281
- const o = () => {
284
+ const n = () => {
282
285
  s(e) && e.setCursor("grabbing");
283
286
  }, t = () => {
284
287
  s(e) && (e.defaultCursor = "grab");
285
288
  };
286
- e.on("mouse:down:before", o), e.on("mouse:up", t);
287
- const n = e.getObjects();
288
- v((r) => (r.forEach((d) => {
289
+ e.on("mouse:down:before", n), e.on("mouse:up", t);
290
+ const o = e.getObjects();
291
+ D((r) => (r.forEach((d) => {
289
292
  var i;
290
293
  try {
291
294
  (i = d.object) == null || i.set("evented", !1);
292
295
  } catch (c) {
293
296
  }
294
297
  }), r));
295
- } catch (o) {
298
+ } catch (n) {
296
299
  }
297
300
  } else
298
301
  try {
299
- e.defaultCursor = "default", e.off("mouse:down:before"), e.off("mouse:up"), e.setCursor("default"), v((o) => (o.forEach((t) => {
300
- var n;
302
+ e.defaultCursor = "default", e.off("mouse:down:before"), e.off("mouse:up"), e.setCursor("default"), D((n) => (n.forEach((t) => {
303
+ var o;
301
304
  try {
302
- (n = t.object) == null || n.set("evented", !0);
305
+ (o = t.object) == null || o.set("evented", !0);
303
306
  } catch (r) {
304
307
  }
305
- }), o)), M();
306
- } catch (o) {
308
+ }), n)), M();
309
+ } catch (n) {
307
310
  }
308
311
  return () => {
309
- fe();
312
+ de();
310
313
  };
311
314
  }
312
315
  }, [e, x]), p(() => {
313
316
  if (!e || !s(e))
314
317
  return;
315
- const o = (t) => {
318
+ const n = (t) => {
316
319
  if (!s(e))
317
320
  return;
318
- const n = t.e.deltaY;
319
- H(n, {
321
+ const o = t.e.deltaY;
322
+ H(o, {
320
323
  x: t.e.offsetX,
321
324
  y: t.e.offsetY
322
- }), C.forEach((r) => {
325
+ }), I.forEach((r) => {
323
326
  try {
324
327
  r.renderLabel();
325
328
  } catch (d) {
326
329
  }
327
330
  });
328
331
  };
329
- return e.on("mouse:wheel", o), x ? () => {
332
+ return e.on("mouse:wheel", n), x ? () => {
330
333
  if (e && s(e))
331
334
  try {
332
- e.off("mouse:wheel", o);
335
+ e.off("mouse:wheel", n);
333
336
  } catch (t) {
334
337
  }
335
338
  } : (M(), () => {
336
339
  if (e && s(e))
337
340
  try {
338
- T(e), e.off("mouse:wheel", o);
341
+ R(e), e.off("mouse:wheel", n);
339
342
  } catch (t) {
340
343
  }
341
344
  });
342
- }, [e, f, C, x]);
343
- const de = () => {
345
+ }, [e, f, I, x]);
346
+ const ue = () => {
344
347
  if (e)
345
348
  try {
346
- T(e), e.discardActiveObject();
347
- } catch (o) {
349
+ R(e), e.discardActiveObject();
350
+ } catch (n) {
348
351
  }
349
- if (v((o) => (o.forEach((t) => {
352
+ if (D((n) => (n.forEach((t) => {
350
353
  try {
351
- D.current.add(t.config.id);
352
- const n = t.handlers.onDelete;
353
- t.handlers.onDelete = void 0, t.destroy(), t.handlers.onDelete = n;
354
- } catch (n) {
354
+ v.current.add(t.config.id);
355
+ const o = t.handlers.onDelete;
356
+ t.handlers.onDelete = void 0, t.destroy(), t.handlers.onDelete = o;
357
+ } catch (o) {
355
358
  }
356
359
  }), setTimeout(() => {
357
- D.current.clear();
358
- }, 100), [])), ie({}), Q(void 0), K([1, 1]), e)
360
+ v.current.clear();
361
+ }, 100), [])), se({}), $(void 0), K([1, 1]), e)
359
362
  try {
360
363
  e.getObjects().forEach((t) => {
361
364
  try {
362
365
  e.remove(t);
363
- } catch (n) {
366
+ } catch (o) {
364
367
  }
365
368
  }), e.dispose();
366
- } catch (o) {
369
+ } catch (n) {
367
370
  }
368
- J(void 0);
371
+ Q(void 0);
369
372
  };
370
373
  return p(() => {
371
- W(!0), de(), !(!h.current || !y) && G.Image.fromURL(
374
+ W(!0), ue();
375
+ const n = ++ee.current;
376
+ !h.current || !y || J.Image.fromURL(
372
377
  y,
373
378
  // @types/fabric 的回调签名缺少第二个参数 isError,运行时确实存在,用 any 规避类型错误
374
- (o, t) => {
375
- if (t) {
376
- W(!1), k == null || k();
377
- return;
379
+ (t, o) => {
380
+ if (n === ee.current) {
381
+ if (o) {
382
+ W(!1), k == null || k();
383
+ return;
384
+ }
385
+ t.set({
386
+ originX: "center",
387
+ originY: "center"
388
+ }), $(t), W(!1);
378
389
  }
379
- o.set({
380
- originX: "center",
381
- originY: "center"
382
- }), Q(o), W(!1);
383
390
  },
384
391
  {
385
392
  crossOrigin: "anonymous"
@@ -395,12 +402,12 @@ const T = (l) => {
395
402
  }
396
403
  if (!h.current || !h.current.parentElement)
397
404
  return;
398
- const o = j == null ? void 0 : j.getElement();
399
- if (!(o != null && o.width) || !(o != null && o.height))
405
+ const n = j == null ? void 0 : j.getElement();
406
+ if (!(n != null && n.width) || !(n != null && n.height))
400
407
  return;
401
408
  if (e)
402
409
  try {
403
- e.getContext() && (T(e), e.discardActiveObject(), e.getObjects().forEach((F) => {
410
+ e.getContext() && (R(e), e.discardActiveObject(), e.getObjects().forEach((F) => {
404
411
  try {
405
412
  e.remove(F);
406
413
  } catch (Ce) {
@@ -408,28 +415,28 @@ const T = (l) => {
408
415
  }), e.dispose());
409
416
  } catch (E) {
410
417
  }
411
- const t = o.width / o.height, n = h.current.parentElement.offsetWidth, r = h.current.parentElement.offsetHeight, d = n / o.width, i = r / o.height;
412
- let c = [n, r];
413
- d > i ? c = [r * t, r] : c = [n, n / t];
414
- const m = c[0] / o.width, S = c[1] / o.height, O = Math.min(m, S);
418
+ const t = n.width / n.height, o = h.current.parentElement.offsetWidth, r = h.current.parentElement.offsetHeight, d = o / n.width, i = r / n.height;
419
+ let c = [o, r];
420
+ d > i ? c = [r * t, r] : c = [o, o / t];
421
+ const m = c[0] / n.width, S = c[1] / n.height, O = Math.min(m, S);
415
422
  K([O, O]);
416
- const b = new G.Canvas(h.current, {
423
+ const b = new J.Canvas(h.current, {
417
424
  containerClass: "marking-canvas",
418
- width: n,
425
+ width: o,
419
426
  height: r
420
427
  });
421
428
  if (b.uniScaleKey = "", b.uniformScaling = !1, b == null || b.setZoom(O), b == null || b.renderAll(), b && j) {
422
- const E = (n - c[0]) / O / 2, q = (r - c[1]) / O / 2;
429
+ const E = (o - c[0]) / O / 2, q = (r - c[1]) / O / 2;
423
430
  b.setBackgroundImage(
424
431
  j,
425
432
  () => {
426
433
  try {
427
434
  if (!b.getContext())
428
435
  return;
429
- b.renderAll(), se({
436
+ b.renderAll(), ae({
430
437
  left: E,
431
438
  top: q
432
- }), J(b), P && P();
439
+ }), Q(b), P && P();
433
440
  } catch (F) {
434
441
  }
435
442
  },
@@ -443,35 +450,35 @@ const T = (l) => {
443
450
  );
444
451
  }
445
452
  }, [j]), p(() => {
446
- if (C.length > g.length) {
447
- if (D.current.size > 0)
453
+ if (I.length > g.length) {
454
+ if (v.current.size > 0)
448
455
  return;
449
- C.forEach((t) => {
450
- const n = D.current.has(t.config.id), r = t._isDestroying;
451
- !g.find((i) => i.id === t.config.id) && !r && !n && t.destroy();
456
+ I.forEach((t) => {
457
+ const o = v.current.has(t.config.id), r = t._isDestroying;
458
+ !g.find((i) => i.id === t.config.id) && !r && !o && t.destroy();
452
459
  });
453
460
  }
454
461
  }, [g.length]), p(() => {
455
- !e || !s(e) || x || v((o) => {
462
+ !e || !s(e) || x || D((n) => {
456
463
  try {
457
- const t = e == null ? void 0 : e.getActiveObject(), n = o.find((r) => r.object === t);
458
- n && f && (n.labelConfig = {
464
+ const t = e == null ? void 0 : e.getActiveObject(), o = n.find((r) => r.object === t);
465
+ o && f && (o.labelConfig = {
459
466
  id: f.id,
460
467
  name: f.label,
461
468
  color: f.color
462
- }, a && a(o.map(A))), e && s(e) && (f ? e.defaultCursor = "copy" : e.defaultCursor = "default");
469
+ }, a && a(n.map(A))), e && s(e) && (f ? e.defaultCursor = "copy" : e.defaultCursor = "default");
463
470
  } catch (t) {
464
471
  }
465
- return [...o];
472
+ return [...n];
466
473
  });
467
474
  }, [f, e, x]), p(() => {
468
- var o;
469
- if (B && h.current && !R) {
475
+ var n;
476
+ if (B && h.current && !T) {
470
477
  const t = document.createElement("div");
471
- t.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (o = h.current.parentElement) == null || o.appendChild(t), ue.render(/* @__PURE__ */ u(he, {}), t), $(t);
478
+ t.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (n = h.current.parentElement) == null || n.appendChild(t), he.render(/* @__PURE__ */ u(me, {}), t), V(t);
472
479
  } else
473
- !B && R && (R.remove(), $(null));
474
- }, [B, h.current, R]), /* @__PURE__ */ ne("div", {
480
+ !B && T && (T.remove(), V(null));
481
+ }, [B, h.current, T]), /* @__PURE__ */ ce("div", {
475
482
  style: {
476
483
  width: "100%",
477
484
  height: "100%",
@@ -481,14 +488,14 @@ const T = (l) => {
481
488
  className: "marker-toolbar",
482
489
  children: /* @__PURE__ */ u("div", {
483
490
  className: "create-mode-select",
484
- children: /* @__PURE__ */ ne(me, {
491
+ children: /* @__PURE__ */ ce(ge, {
485
492
  direction: "vertical",
486
493
  size: 16,
487
494
  children: [/* @__PURE__ */ u(U, {
488
495
  title: "放大-鼠标滚轮前滑",
489
496
  placement: "right",
490
497
  children: /* @__PURE__ */ u(z, {
491
- icon: /* @__PURE__ */ u(be, {}),
498
+ icon: /* @__PURE__ */ u(pe, {}),
492
499
  onClick: () => {
493
500
  H(-100);
494
501
  }
@@ -497,7 +504,7 @@ const T = (l) => {
497
504
  title: "缩小-鼠标滚轮后滑",
498
505
  placement: "right",
499
506
  children: /* @__PURE__ */ u(z, {
500
- icon: /* @__PURE__ */ u(pe, {}),
507
+ icon: /* @__PURE__ */ u(ye, {}),
501
508
  onClick: () => {
502
509
  H(100);
503
510
  }
@@ -507,7 +514,7 @@ const T = (l) => {
507
514
  placement: "right",
508
515
  children: /* @__PURE__ */ u(z, {
509
516
  disabled: w,
510
- icon: /* @__PURE__ */ u(ye, {}),
517
+ icon: /* @__PURE__ */ u(xe, {}),
511
518
  className: x ? "active" : "",
512
519
  onClick: () => {
513
520
  L(!x);
@@ -517,23 +524,23 @@ const T = (l) => {
517
524
  title: "一键清空全部标注",
518
525
  placement: "right",
519
526
  children: /* @__PURE__ */ u(z, {
520
- icon: /* @__PURE__ */ u(xe, {}),
521
- disabled: !(C != null && C.length),
527
+ icon: /* @__PURE__ */ u(De, {}),
528
+ disabled: !(I != null && I.length),
522
529
  onClick: () => {
523
530
  if (!(!e || !s(e)))
524
531
  try {
525
- T(e), e.discardActiveObject(), v((t) => (t.forEach((n) => {
526
- D.current.add(n.config.id);
527
- const r = n.handlers.onDelete;
528
- n.handlers.onDelete = void 0, n.destroy(), n.handlers.onDelete = r;
532
+ R(e), e.discardActiveObject(), D((t) => (t.forEach((o) => {
533
+ v.current.add(o.config.id);
534
+ const r = o.handlers.onDelete;
535
+ o.handlers.onDelete = void 0, o.destroy(), o.handlers.onDelete = r;
529
536
  }), setTimeout(() => {
530
- D.current.clear();
537
+ v.current.clear();
531
538
  }, 100), [])), e.getObjects().forEach((t) => {
532
539
  t !== e.backgroundImage && e.remove(t);
533
540
  }), a && a([]), s(e) && (e.renderAll(), setTimeout(() => {
534
541
  e && s(e) && !x && M();
535
542
  }, 0));
536
- } catch (o) {
543
+ } catch (n) {
537
544
  }
538
545
  }
539
546
  })
@@ -545,8 +552,8 @@ const T = (l) => {
545
552
  "label-maker-wrap": !0,
546
553
  draggable: x
547
554
  }),
548
- onContextMenu: (o) => {
549
- o.preventDefault();
555
+ onContextMenu: (n) => {
556
+ n.preventDefault();
550
557
  },
551
558
  children: /* @__PURE__ */ u("canvas", {
552
559
  className: "label-maker-canvas",
@@ -556,5 +563,5 @@ const T = (l) => {
556
563
  });
557
564
  };
558
565
  export {
559
- Ue as default
566
+ ze as default
560
567
  };