@glodon-aiot/dataset-annotation 3.13.0-alpha.29 → 3.14.0-alpha.31

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 (33) hide show
  1. package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +151 -135
  2. package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +244 -218
  3. package/dist/es/components/VLMAnnotation/RegionItem.mjs +135 -59
  4. package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +73 -62
  5. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +55 -40
  6. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +291 -162
  7. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.mjs +100 -0
  8. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +88 -55
  9. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.mjs +103 -0
  10. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +123 -91
  11. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +42 -39
  12. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +55 -60
  13. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/ai.svg.mjs +4 -0
  14. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/error.svg.mjs +4 -0
  15. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/loading.svg.mjs +4 -0
  16. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/star.svg.mjs +4 -0
  17. package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +512 -387
  18. package/dist/es/components/VLMAnnotation/constants.mjs +39 -32
  19. package/dist/es/components/VLMAnnotation/index.mjs +187 -150
  20. package/dist/es/index.mjs +1 -1
  21. package/dist/lib/index.js +4 -4
  22. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +1 -0
  23. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +3 -1
  24. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.d.ts +16 -0
  25. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +3 -2
  26. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.d.ts +31 -0
  27. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +5 -1
  28. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +2 -1
  29. package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +2 -2
  30. package/dist/src/components/VLMAnnotation/constants.d.ts +19 -3
  31. package/dist/src/components/VLMAnnotation/index.d.ts +1 -1
  32. package/dist/src/components/VLMAnnotation/types.d.ts +15 -0
  33. package/package.json +2 -2
@@ -1,50 +1,57 @@
1
- const _ = 20, E = 0.1, O = 0.999, T = 0.01, L = 100, R = 2, C = "#EAD4FF", A = "rgba(156, 36, 242, 0.1)", I = "rgba(156, 36, 242, 0.05)", n = "transparent", s = "rgba(0, 0, 0, 0)", N = [5, 5], t = "vlm-label-maker-canvas", c = 300, o = 0.7, S = 0.05, F = 0.95, M = "rect", D = "区域", a = "区域1", P = "Arial, sans-serif", r = 12, U = 4, G = 3, X = 3, g = 1.5, H = 0.5, b = 8e-3, Y = "rgba(156, 36, 242, 0.2)", K = "rgba(156, 36, 242, 0.5)", e = "#9C24F2", Z = "rgba(156, 36, 242, 0.2)", B = "rgba(156, 36, 242, 0.2)", l = "rgba(156, 36, 242, 0.5)", W = "rgba(0, 255, 0, 0.2)", i = 300, m = "#9C24F2", p = 6, V = 36, v = 20, f = 24, k = "#9C24F2", x = "image/png", d = "确认删除", h = "确定要删除此标注区域吗?", j = "确定", q = "取消";
1
+ const _ = 8, E = 0.1, O = 0.999, T = 0.01, R = 100, L = 2, C = "#EAD4FF", A = "#9C24F2", I = "rgba(156, 36, 242, 0.1)", n = "rgba(156, 36, 242, 0.05)", s = "transparent", t = "rgba(0, 0, 0, 0)", N = [5, 5], c = "vlm-label-maker-canvas", o = 300, S = 0.7, F = 0.05, D = 0.95, M = "rect", a = "区域", r = "区域1", P = "Arial, sans-serif", H = 12, U = 4, X = 3, G = 3, g = 1.5, Y = 0.5, b = 3e-3, K = "rgba(156, 36, 242, 0.2)", Z = "rgba(156, 36, 242, 0.5)", e = "#9C24F2", B = "rgba(156, 36, 242, 0.2)", W = "rgba(156, 36, 242, 0.2)", l = "rgba(156, 36, 242, 0.5)", V = "rgba(0, 255, 0, 0.2)", i = 300, m = "#9C24F2", p = 6, v = 24, f = 20, k = 24, x = 24, d = 20, h = 24, j = "#9C24F2", q = "image/png", u = "确认删除", w = "确定要删除此标注区域吗?", y = "确定", z = "取消", J = "rgba(156, 36, 242, 0.5)", Q = 1, $ = [5, 5];
2
2
  export {
3
- R as BASE_STROKE_WIDTH,
4
- t as CANVAS_CONTAINER_CLASS,
3
+ A as ACTIVE_RECT_STROKE_COLOR,
4
+ d as AI_CONTROL_OFFSET_X,
5
+ h as AI_CONTROL_OFFSET_Y,
6
+ x as AI_ICON_SIZE,
7
+ L as BASE_STROKE_WIDTH,
8
+ c as CANVAS_CONTAINER_CLASS,
5
9
  m as CONTROL_POINT_COLOR,
6
10
  p as CONTROL_POINT_SIZE,
7
- o as DEFAULT_LEFT_RATIO,
8
- F as DEFAULT_MAX_RATIO,
9
- c as DEFAULT_MIN_LEFT_WIDTH,
10
- S as DEFAULT_MIN_RATIO,
11
- a as DEFAULT_REGION_NAME,
11
+ J as CROSSHAIR_LINE_COLOR,
12
+ $ as CROSSHAIR_LINE_DASH_ARRAY,
13
+ Q as CROSSHAIR_LINE_WIDTH,
14
+ S as DEFAULT_LEFT_RATIO,
15
+ D as DEFAULT_MAX_RATIO,
16
+ o as DEFAULT_MIN_LEFT_WIDTH,
17
+ F as DEFAULT_MIN_RATIO,
18
+ r as DEFAULT_REGION_NAME,
12
19
  M as DEFAULT_SHAPE_TYPE,
13
- v as DELETE_CONTROL_OFFSET_X,
14
- f as DELETE_CONTROL_OFFSET_Y,
15
- V as DELETE_ICON_SIZE,
16
- q as DELETE_MODAL_CANCEL_TEXT,
17
- h as DELETE_MODAL_CONTENT,
18
- j as DELETE_MODAL_OK_TEXT,
19
- d as DELETE_MODAL_TITLE,
20
- I as HOVER_RECT_FILL_COLOR,
21
- x as IMAGE_EXPORT_FORMAT,
20
+ f as DELETE_CONTROL_OFFSET_X,
21
+ k as DELETE_CONTROL_OFFSET_Y,
22
+ v as DELETE_ICON_SIZE,
23
+ z as DELETE_MODAL_CANCEL_TEXT,
24
+ w as DELETE_MODAL_CONTENT,
25
+ y as DELETE_MODAL_OK_TEXT,
26
+ u as DELETE_MODAL_TITLE,
27
+ n as HOVER_RECT_FILL_COLOR,
28
+ q as IMAGE_EXPORT_FORMAT,
22
29
  _ as MAX_ZOOM,
23
30
  E as MIN_ZOOM,
24
31
  b as OCR_SCAN_ANIMATION_SPEED,
25
- G as OCR_SCAN_LINE_BASE_HEIGHT,
26
- K as OCR_SCAN_LINE_BRIGHT_COLOR,
32
+ X as OCR_SCAN_LINE_BASE_HEIGHT,
33
+ Z as OCR_SCAN_LINE_BRIGHT_COLOR,
27
34
  e as OCR_SCAN_LINE_CORE_COLOR,
28
- H as OCR_SCAN_LINE_CORE_HEIGHT_MULTIPLIER,
35
+ Y as OCR_SCAN_LINE_CORE_HEIGHT_MULTIPLIER,
29
36
  g as OCR_SCAN_LINE_CORE_POSITION_MULTIPLIER,
30
- Y as OCR_SCAN_LINE_GLOW_COLOR,
31
- X as OCR_SCAN_LINE_GLOW_MULTIPLIER,
37
+ K as OCR_SCAN_LINE_GLOW_COLOR,
38
+ G as OCR_SCAN_LINE_GLOW_MULTIPLIER,
32
39
  C as RECT_STROKE_COLOR,
33
40
  P as REGION_NAME_FONT_FAMILY,
34
- r as REGION_NAME_FONT_SIZE,
41
+ H as REGION_NAME_FONT_SIZE,
35
42
  U as REGION_NAME_PADDING,
36
- D as REGION_NAME_PREFIX,
37
- k as REGION_NAME_TEXT_COLOR,
38
- A as SELECTED_RECT_FILL_COLOR,
39
- s as TEMP_RECT_FILL_COLOR,
43
+ a as REGION_NAME_PREFIX,
44
+ j as REGION_NAME_TEXT_COLOR,
45
+ I as SELECTED_RECT_FILL_COLOR,
46
+ t as TEMP_RECT_FILL_COLOR,
40
47
  N as TEMP_RECT_STROKE_DASH_ARRAY,
41
- W as TEXT_LAYOUT_RECT_CLICK_FEEDBACK_COLOR,
48
+ V as TEXT_LAYOUT_RECT_CLICK_FEEDBACK_COLOR,
42
49
  i as TEXT_LAYOUT_RECT_FEEDBACK_DELAY,
43
- Z as TEXT_LAYOUT_RECT_FILL_COLOR,
50
+ B as TEXT_LAYOUT_RECT_FILL_COLOR,
44
51
  l as TEXT_LAYOUT_RECT_HOVER_STROKE_COLOR,
45
- B as TEXT_LAYOUT_RECT_STROKE_COLOR,
46
- n as TRANSPARENT_FILL,
52
+ W as TEXT_LAYOUT_RECT_STROKE_COLOR,
53
+ s as TRANSPARENT_FILL,
47
54
  O as ZOOM_FACTOR,
48
55
  T as ZOOM_PRECISION_ERROR,
49
- L as ZOOM_STEP
56
+ R as ZOOM_STEP
50
57
  };
@@ -1,242 +1,279 @@
1
- var le = Object.defineProperty, ce = Object.defineProperties;
2
- var ae = Object.getOwnPropertyDescriptors;
3
- var G = Object.getOwnPropertySymbols;
4
- var ue = Object.prototype.hasOwnProperty, ie = Object.prototype.propertyIsEnumerable;
5
- var J = (r, o, s) => o in r ? le(r, o, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[o] = s, a = (r, o) => {
6
- for (var s in o || (o = {}))
7
- ue.call(o, s) && J(r, s, o[s]);
8
- if (G)
9
- for (var s of G(o))
10
- ie.call(o, s) && J(r, s, o[s]);
11
- return r;
12
- }, u = (r, o) => ce(r, ae(o));
13
- import { jsxs as de, jsx as M } from "react/jsx-runtime";
14
- import { useMemo as me, useState as y, useRef as K, useEffect as T } from "react";
1
+ var me = Object.defineProperty, fe = Object.defineProperties;
2
+ var pe = Object.getOwnPropertyDescriptors;
3
+ var ee = Object.getOwnPropertySymbols;
4
+ var ve = Object.prototype.hasOwnProperty, be = Object.prototype.propertyIsEnumerable;
5
+ var te = (l, o, r) => o in l ? me(l, o, { enumerable: !0, configurable: !0, writable: !0, value: r }) : l[o] = r, u = (l, o) => {
6
+ for (var r in o || (o = {}))
7
+ ve.call(o, r) && te(l, r, o[r]);
8
+ if (ee)
9
+ for (var r of ee(o))
10
+ be.call(o, r) && te(l, r, o[r]);
11
+ return l;
12
+ }, a = (l, o) => fe(l, pe(o));
13
+ import { jsxs as Ee, jsx as g } from "react/jsx-runtime";
14
+ import { useMemo as Te, useState as b, useRef as S, useEffect as w } from "react";
15
+ import { Modal as Ae } from "antd";
15
16
  import "./style.less.mjs";
16
- import pe from "./TextAnnotationPanel.mjs";
17
- import ve from "./VLMLabelMaker/index.mjs";
18
- import { DEFAULT_SHAPE_TYPE as fe, DEFAULT_MIN_LEFT_WIDTH as be, DEFAULT_MAX_RATIO as P, DEFAULT_MIN_RATIO as Q, DEFAULT_LEFT_RATIO as ye } from "./constants.mjs";
19
- const k = (r) => {
20
- var o, s;
21
- return u(a({}, r), {
22
- labels: (s = (o = r.labels) == null ? void 0 : o.map((l) => {
23
- if (l.shape.name === "rect") {
17
+ import ye from "./TextAnnotationPanel.mjs";
18
+ import Le from "./VLMLabelMaker/index.mjs";
19
+ import { DEFAULT_SHAPE_TYPE as Re, DELETE_MODAL_TITLE as Me, DELETE_MODAL_CONTENT as we, DELETE_MODAL_OK_TEXT as _e, DELETE_MODAL_CANCEL_TEXT as he, DEFAULT_MIN_LEFT_WIDTH as ge, DEFAULT_MAX_RATIO as F, DEFAULT_MIN_RATIO as ne, DEFAULT_LEFT_RATIO as De } from "./constants.mjs";
20
+ const V = (l) => {
21
+ var o, r;
22
+ return a(u({}, l), {
23
+ labels: (r = (o = l.labels) == null ? void 0 : o.map((c) => {
24
+ if (c.shape.name === "rect") {
24
25
  const {
25
- x: A,
26
- y: p,
27
- width: v,
28
- height: d
29
- } = l.shape;
30
- return u(a({}, l), {
31
- shape: u(a({}, l.shape), {
32
- x: A + v / 2,
33
- y: p + d / 2
26
+ x: L,
27
+ y: E,
28
+ width: T,
29
+ height: f
30
+ } = c.shape;
31
+ return a(u({}, c), {
32
+ shape: a(u({}, c.shape), {
33
+ x: L + T / 2,
34
+ y: E + f / 2
34
35
  })
35
36
  });
36
37
  }
37
- return l;
38
- })) != null ? s : []
38
+ return c;
39
+ })) != null ? r : []
39
40
  });
40
- }, Ae = (r) => {
41
- var o, s;
42
- return u(a({}, r), {
43
- labels: (s = (o = r.labels) == null ? void 0 : o.map((l) => {
44
- if (l.shape.name === "rect") {
41
+ }, Oe = (l) => {
42
+ var o, r;
43
+ return a(u({}, l), {
44
+ labels: (r = (o = l.labels) == null ? void 0 : o.map((c) => {
45
+ if (c.shape.name === "rect") {
45
46
  const {
46
- x: A,
47
- y: p,
48
- width: v,
49
- height: d
50
- } = l.shape;
51
- return u(a({}, l), {
52
- shape: u(a({}, l.shape), {
53
- x: A - v / 2,
54
- y: p - d / 2
47
+ x: L,
48
+ y: E,
49
+ width: T,
50
+ height: f
51
+ } = c.shape;
52
+ return a(u({}, c), {
53
+ shape: a(u({}, c.shape), {
54
+ x: L - T / 2,
55
+ y: E - f / 2
55
56
  })
56
57
  });
57
58
  }
58
- return l;
59
- })) != null ? s : []
59
+ return c;
60
+ })) != null ? r : []
60
61
  });
61
- }, Fe = ({
62
- sample: r,
62
+ }, Be = ({
63
+ sample: l,
63
64
  labelDefinitions: o,
64
- onChange: s,
65
- leftRatio: l,
66
- resizable: A = !0,
67
- minLeftRatio: p,
68
- maxLeftRatio: v,
69
- minLeftWidth: d = be,
70
- onRatioChange: B,
71
- ocrRecognize: Z,
72
- coordinateType: L = "top-left",
73
- hideRightSide: E,
74
- readOnly: C
65
+ onChange: r,
66
+ leftRatio: c,
67
+ resizable: L = !0,
68
+ minLeftRatio: E,
69
+ maxLeftRatio: T,
70
+ minLeftWidth: f = ge,
71
+ onRatioChange: U,
72
+ ocrRecognize: re,
73
+ coordinateType: R = "top-left",
74
+ hideRightSide: D,
75
+ readOnly: B
75
76
  }) => {
76
- var H, q;
77
- const i = me(() => L === "center" ? Ae(r) : r, [r, L]), [f, R] = y((H = i == null ? void 0 : i.labels) != null ? H : []), [b, m] = y(null), [g, w] = y(null), [_, x] = y(null);
78
- y(fe);
79
- const z = Math.min(P, Math.max(Q, p != null ? p : Q)), O = Math.min(P, Math.max(z, v != null ? v : P)), F = K(null), N = K(!1), V = (t, e) => {
80
- let n = z;
81
- return typeof d == "number" && d >= 0 && e && e > 0 && (n = Math.max(n, Math.min(P, d / e))), Math.min(O, Math.max(n, t));
82
- }, U = typeof l == "number", [W, S] = y(V(l != null ? l : ye));
83
- T(() => {
84
- U || S((t) => V(t));
85
- }, [z, O]);
86
- const ee = (q = F.current) == null ? void 0 : q.clientWidth, te = V(U ? l : W, ee), X = E ? 1 : te, ne = E ? 0 : 1 - X, oe = E ? !1 : A, [, $] = y(0);
87
- T(() => {
88
- const t = F.current;
77
+ var K, Y, G, J, Q, Z;
78
+ const i = Te(() => R === "center" ? Oe(l) : l, [l, R]), [d, _] = b((K = i == null ? void 0 : i.labels) != null ? K : []), [m, p] = b(null), [O, v] = b(null), [A, y] = b(null);
79
+ b(Re);
80
+ const h = S(null), [Ne, oe] = b(0);
81
+ w(() => {
82
+ const t = setInterval(() => {
83
+ h.current && oe((e) => e + 1);
84
+ }, 100);
85
+ return () => clearInterval(t);
86
+ }, []);
87
+ const I = Math.min(F, Math.max(ne, E != null ? E : ne)), X = Math.min(F, Math.max(I, T != null ? T : F)), N = S(null), P = S(!1), x = (t, e) => {
88
+ let n = I;
89
+ return typeof f == "number" && f >= 0 && e && e > 0 && (n = Math.max(n, Math.min(F, f / e))), Math.min(X, Math.max(n, t));
90
+ }, k = typeof c == "number", [se, $] = b(x(c != null ? c : De));
91
+ w(() => {
92
+ k || $((t) => x(t));
93
+ }, [I, X]);
94
+ const le = (Y = N.current) == null ? void 0 : Y.clientWidth, ce = x(k ? c : se, le), j = D ? 1 : ce, ue = D ? 0 : 1 - j, ae = D ? !1 : L, [, H] = b(0);
95
+ w(() => {
96
+ const t = N.current;
89
97
  if (!t)
90
98
  return;
91
99
  let e = null, n = 0;
92
100
  if (typeof ResizeObserver != "undefined")
93
101
  e = new ResizeObserver(() => {
94
102
  cancelAnimationFrame(n), n = requestAnimationFrame(() => {
95
- $((c) => c + 1);
103
+ H((s) => s + 1);
96
104
  });
97
105
  }), e.observe(t);
98
106
  else {
99
- const c = () => $((h) => h + 1);
100
- return window.addEventListener("resize", c), () => {
101
- window.removeEventListener("resize", c);
107
+ const s = () => H((M) => M + 1);
108
+ return window.addEventListener("resize", s), () => {
109
+ window.removeEventListener("resize", s);
102
110
  };
103
111
  }
104
112
  return () => {
105
113
  e && e.disconnect(), cancelAnimationFrame(n);
106
114
  };
107
- }, []), T(() => {
115
+ }, []), w(() => {
108
116
  var t;
109
- R((t = i == null ? void 0 : i.labels) != null ? t : []), m(null), w(null), x(null);
110
- }, [i]), T(() => {
111
- _ && m(null);
112
- }, [_]), T(() => {
113
- b !== null && x(null);
114
- }, [b]);
115
- const j = (t) => {
116
- const e = F.current;
117
+ _((t = i == null ? void 0 : i.labels) != null ? t : []), p(null), v(null), y(null);
118
+ }, [i]), w(() => {
119
+ A && (p(null), v(null));
120
+ }, [A]), w(() => {
121
+ m !== null && y(null);
122
+ }, [m]);
123
+ const q = (t) => {
124
+ const e = N.current;
117
125
  if (!e)
118
126
  return;
119
- const n = e.getBoundingClientRect(), c = V((t - n.left) / n.width, n.width);
120
- B && B(c), U || S(c);
121
- }, se = (t) => {
122
- if (!A)
127
+ const n = e.getBoundingClientRect(), s = x((t - n.left) / n.width, n.width);
128
+ U && U(s), k || $(s);
129
+ }, ie = (t) => {
130
+ if (!L)
123
131
  return;
124
- t.preventDefault(), N.current = !0, document.body.style.userSelect = "none", document.body.style.setProperty("-webkit-user-select", "none"), document.body.style.setProperty("-moz-user-select", "none"), document.body.style.setProperty("-ms-user-select", "none"), j(t.clientX);
125
- const e = (c) => {
126
- N.current && (c.preventDefault(), j(c.clientX));
132
+ t.preventDefault(), P.current = !0, document.body.style.userSelect = "none", document.body.style.setProperty("-webkit-user-select", "none"), document.body.style.setProperty("-moz-user-select", "none"), document.body.style.setProperty("-ms-user-select", "none"), q(t.clientX);
133
+ const e = (s) => {
134
+ P.current && (s.preventDefault(), q(s.clientX));
127
135
  }, n = () => {
128
- N.current = !1, document.body.style.userSelect = "", document.body.style.setProperty("-webkit-user-select", ""), document.body.style.setProperty("-moz-user-select", ""), document.body.style.setProperty("-ms-user-select", ""), window.removeEventListener("mousemove", e), window.removeEventListener("mouseup", n);
136
+ P.current = !1, document.body.style.userSelect = "", document.body.style.setProperty("-webkit-user-select", ""), document.body.style.setProperty("-moz-user-select", ""), document.body.style.setProperty("-ms-user-select", ""), window.removeEventListener("mousemove", e), window.removeEventListener("mouseup", n);
129
137
  };
130
138
  window.addEventListener("mousemove", e), window.addEventListener("mouseup", n);
131
139
  };
132
- return /* @__PURE__ */ de("div", {
140
+ return /* @__PURE__ */ Ee("div", {
133
141
  className: "vlm-annotation-wrap",
134
- ref: F,
135
- children: [/* @__PURE__ */ M("div", {
142
+ ref: N,
143
+ children: [/* @__PURE__ */ g("div", {
136
144
  className: "vlm-annotation-left",
137
145
  style: {
138
- flex: `${X} 1 0%`,
139
- minWidth: typeof d == "number" ? `${d}px` : void 0
146
+ flex: `${j} 1 0%`,
147
+ minWidth: typeof f == "number" ? `${f}px` : void 0
140
148
  },
141
- children: /* @__PURE__ */ M(ve, {
149
+ children: /* @__PURE__ */ g(Le, {
150
+ ref: h,
142
151
  sample: i,
143
152
  labelDefinitions: o,
144
- labels: f,
153
+ labels: d,
145
154
  onChange: (t) => {
146
- if (s) {
147
- const e = u(a({}, i), {
155
+ if (r) {
156
+ const e = a(u({}, i), {
148
157
  labels: t
149
158
  });
150
- s(L === "center" ? k(e) : e);
159
+ r(R === "center" ? V(e) : e);
151
160
  }
152
- R(t);
161
+ _(t);
153
162
  },
154
- onRegionSelect: x,
163
+ onRegionSelect: y,
155
164
  onRegionChange: (t, e) => {
156
165
  },
157
- ocrRecognize: Z,
158
- activeLabelValue: b,
166
+ ocrRecognize: re,
167
+ activeLabelValue: m,
159
168
  onClearActive: () => {
160
- m(null), w(null);
169
+ p(null), v(null);
161
170
  },
162
- selectedRegion: _,
171
+ selectedRegion: A,
163
172
  onAppendTextToActive: (t) => {
164
- if (!b || g === null)
173
+ if (!m || O === null)
165
174
  return;
166
- const e = f[g];
175
+ const e = d[O];
167
176
  if (!e)
168
177
  return;
169
- const n = b.label.id, h = (e.content[n] || "") + t, D = [...f], Y = u(a({}, e), {
170
- content: u(a({}, e.content), {
171
- [n]: h
178
+ const n = m.label.id, M = (e.content[n] || "") + t, C = [...d], W = a(u({}, e), {
179
+ content: a(u({}, e.content), {
180
+ [n]: M
172
181
  })
173
182
  });
174
- D[g] = Y, R(D);
175
- const re = u(a({}, b), {
176
- region: Y
183
+ C[O] = W, _(C);
184
+ const de = a(u({}, m), {
185
+ region: W
177
186
  });
178
- if (m(re), (o == null ? void 0 : o.find((I) => I.id === n)) && setTimeout(() => {
179
- }, 0), s) {
180
- const I = u(a({}, i), {
181
- labels: D
187
+ if (p(de), (o == null ? void 0 : o.find((z) => z.id === n)) && setTimeout(() => {
188
+ }, 0), r) {
189
+ const z = a(u({}, i), {
190
+ labels: C
182
191
  });
183
- s(L === "center" ? k(I) : I);
192
+ r(R === "center" ? V(z) : z);
184
193
  }
185
194
  },
186
- readOnly: C
195
+ readOnly: B
187
196
  })
188
- }), oe ? /* @__PURE__ */ M("div", {
197
+ }), ae ? /* @__PURE__ */ g("div", {
189
198
  className: "vlm-annotation-resizer",
190
199
  role: "separator",
191
200
  "aria-orientation": "vertical",
192
- onMouseDown: se
193
- }) : null, !E && /* @__PURE__ */ M("div", {
201
+ onMouseDown: ie
202
+ }) : null, !D && /* @__PURE__ */ g("div", {
194
203
  className: "vlm-annotation-right",
195
204
  style: {
196
- flex: `${ne} 1 0%`
205
+ flex: `${ue} 1 0%`
197
206
  },
198
- children: /* @__PURE__ */ M(pe, {
207
+ children: /* @__PURE__ */ g(ye, {
199
208
  labelDefinitions: o,
200
- labels: f,
201
- selectedRegion: _,
202
- activeLabelValue: b,
203
- activeRegionNumber: g,
204
- readOnly: C,
209
+ labels: d,
210
+ selectedRegion: A,
211
+ activeLabelValue: m,
212
+ activeRegionNumber: O,
213
+ readOnly: B,
214
+ onRegionClick: (t) => {
215
+ y(t);
216
+ },
217
+ onOCR: (t) => {
218
+ var n;
219
+ const e = d.find((s) => s.id === t);
220
+ e && y(e), (n = h.current) == null || n.performOCRById(t);
221
+ },
222
+ ocrRecognizing: (J = (G = h.current) == null ? void 0 : G.ocrRecognizingRef) == null ? void 0 : J.current,
223
+ ocrErrors: (Z = (Q = h.current) == null ? void 0 : Q.ocrErrorRef) == null ? void 0 : Z.current,
224
+ onDelete: (t) => {
225
+ const e = d.find((n) => n.id === t);
226
+ e && y(e), Ae.confirm({
227
+ title: Me,
228
+ content: we,
229
+ okText: _e,
230
+ cancelText: he,
231
+ onOk: () => {
232
+ const n = d.filter((s) => s.id !== t);
233
+ if (_(n), (A == null ? void 0 : A.id) === t && y(null), (m == null ? void 0 : m.region.id) === t && (p(null), v(null)), r) {
234
+ const s = a(u({}, i), {
235
+ labels: n
236
+ });
237
+ r(R === "center" ? V(s) : s);
238
+ }
239
+ }
240
+ });
241
+ },
205
242
  onInputActive: (t, e) => {
206
- if (e !== void 0 && f[e]) {
207
- const n = f[e], c = {
243
+ if (e !== void 0 && d[e]) {
244
+ const n = d[e], s = {
208
245
  label: t.label,
209
246
  // 使用传入的 label,确保 label 字段被更新
210
- region: a({}, n)
247
+ region: u({}, n)
211
248
  };
212
- m(c), w(e);
249
+ p(s), v(e);
213
250
  } else
214
- m(t), e !== void 0 && w(e);
251
+ p(t), e !== void 0 && v(e);
215
252
  },
216
253
  onChange: (t, e) => {
217
254
  if (t !== null && e !== void 0) {
218
- const n = [...f];
219
- n[e] = t.region, R(n);
220
- const c = {
255
+ const n = [...d];
256
+ n[e] = t.region, _(n);
257
+ const s = {
221
258
  label: t.label,
222
259
  // 确保使用传入的 label
223
260
  region: n[e]
224
261
  // 使用更新后的 region
225
262
  };
226
- if (m(c), w(e), s) {
227
- const h = u(a({}, i), {
263
+ if (p(s), v(e), r) {
264
+ const M = a(u({}, i), {
228
265
  labels: n
229
266
  });
230
- s(L === "center" ? k(h) : h);
267
+ r(R === "center" ? V(M) : M);
231
268
  }
232
269
  } else
233
- m(null), w(null);
270
+ p(null), v(null);
234
271
  }
235
272
  })
236
273
  })]
237
274
  });
238
275
  };
239
276
  export {
240
- k as convertTopLeftToCenter,
241
- Fe as default
277
+ V as convertTopLeftToCenter,
278
+ Be as default
242
279
  };