@glodon-aiot/dataset-annotation 3.5.1 → 3.5.2-snapshot.0

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.
@@ -1,11 +1,11 @@
1
1
  var J = Math.pow;
2
2
  import { jsx as l, jsxs as Q } from "react/jsx-runtime";
3
3
  import { useRef as se, useState as b, useEffect as g } from "react";
4
- import { fabric as R } from "fabric";
4
+ import { fabric as X } from "fabric";
5
5
  import { useKeyPress as P } from "ahooks";
6
6
  import "./style.less.mjs";
7
- import le from "react-dom";
8
- import { Spin as ce, Space as fe, Tooltip as X, Button as Z } from "antd";
7
+ import { createRoot as le } from "react-dom/client";
8
+ import { Spin as ce, Space as fe, Tooltip as M, Button as Z } from "antd";
9
9
  import _ from "./RectLabel.mjs";
10
10
  import { drawable as de } from "./Drawable.mjs";
11
11
  import { ZoomInOutlined as ue, ZoomOutOutlined as me, DragOutlined as ge } from "@ant-design/icons";
@@ -13,7 +13,7 @@ import he from "classnames";
13
13
  import { approxeq as L } from "../../../../utils/index.mjs";
14
14
  const $ = (r) => {
15
15
  r.off("mouse:down"), r.off("mouse:up");
16
- }, k = (r) => {
16
+ }, j = (r) => {
17
17
  var a, w, f;
18
18
  let s = [];
19
19
  (a = r.object) != null && a.aCoords && (s = [r.object.aCoords.tl, r.object.aCoords.tr, r.object.aCoords.br, r.object.aCoords.bl]);
@@ -30,7 +30,7 @@ const $ = (r) => {
30
30
  color: r.config.color,
31
31
  box: (s == null ? void 0 : s.map((u) => [L(u.x - c.x, 0) ? 0 : L(u.x - c.x, d.width) ? d.width : u.x - c.x, L(u.y - c.y, 0) ? 0 : L(u.y - c.y, d.height) ? d.height : u.y - c.y])) || []
32
32
  };
33
- }, Ne = (r) => {
33
+ }, Oe = (r) => {
34
34
  const s = se(null), {
35
35
  labels: c,
36
36
  imageUrl: d,
@@ -39,11 +39,11 @@ const $ = (r) => {
39
39
  onChange: f,
40
40
  isPreLabel: u,
41
41
  disabled: x,
42
- renderLabelItem: O
43
- } = r, [N, B] = b(!0), [e, T] = b(), [pe, V] = b({}), [y, U] = b(), [H, ee] = b({
42
+ renderLabelItem: N
43
+ } = r, [O, B] = b(!0), [e, T] = b(), [pe, V] = b({}), [y, U] = b(), [H, ee] = b({
44
44
  left: 0,
45
45
  top: 0
46
- }), [te, S] = b([1, 1]), [j, K] = b(), [h, v] = b([]), [p, E] = b(x || !1), A = (t, o) => {
46
+ }), [te, S] = b([1, 1]), [I, K] = b(), [h, v] = b([]), [p, E] = b(x || !1), A = (t, o) => {
47
47
  if (!e)
48
48
  return;
49
49
  o || (o = {
@@ -68,8 +68,8 @@ const $ = (r) => {
68
68
  return;
69
69
  const o = e == null ? void 0 : e.getActiveObject();
70
70
  o && v((i) => {
71
- const I = i.findIndex((z) => z.object === o);
72
- return i[I] && (i[I].destroy(), i.splice(I, 1)), f && f(i.map(k)), [...i];
71
+ const k = i.findIndex((z) => z.object === o);
72
+ return i[k] && (i[k].destroy(), i.splice(k, 1)), f && f(i.map(j)), [...i];
73
73
  });
74
74
  };
75
75
  P("Delete", W), P("Backspace", W), P("ctrl", () => {
@@ -86,12 +86,12 @@ const $ = (r) => {
86
86
  const q = (t) => {
87
87
  e && $(e), v((o) => {
88
88
  const n = o.findIndex((i) => i === t);
89
- return n > -1 && (o.splice(n, 1), f && f(o.map(k)), Y()), [...o];
89
+ return n > -1 && (o.splice(n, 1), f && f(o.map(j)), Y()), [...o];
90
90
  });
91
91
  }, F = (t) => {
92
92
  v((o) => {
93
93
  const n = o.findIndex((i) => i === t);
94
- return n > -1 && (o[n] = t, f && f(o.map(k))), [...o];
94
+ return n > -1 && (o[n] = t, f && f(o.map(j))), [...o];
95
95
  });
96
96
  };
97
97
  g(() => {
@@ -108,7 +108,7 @@ const $ = (r) => {
108
108
  }, e, {
109
109
  onChange: F,
110
110
  onDelete: q,
111
- renderLabelItem: O ? (n) => O ? O(o) : n.name : void 0
111
+ renderLabelItem: N ? (n) => N ? N(o) : n.name : void 0
112
112
  }));
113
113
  }), v(t), t.forEach((o) => {
114
114
  o.render(e);
@@ -130,7 +130,7 @@ const $ = (r) => {
130
130
  onChange: F,
131
131
  onDelete: q
132
132
  });
133
- o.active = !0, h.push(o), f && f(h.map(k)), v([...h]);
133
+ o.active = !0, h.push(o), f && f(h.map(j)), v([...h]);
134
134
  }, u);
135
135
  }, oe = () => {
136
136
  let t = !1;
@@ -138,7 +138,7 @@ const $ = (r) => {
138
138
  t = !0, e.selection = !1;
139
139
  }), e.on("mouse:move", (o) => {
140
140
  if (t && o && o.e) {
141
- const n = new R.Point(o.e.movementX, o.e.movementY);
141
+ const n = new X.Point(o.e.movementX, o.e.movementY);
142
142
  e.relativePan(n);
143
143
  }
144
144
  }), e.on("mouse:up", (o) => {
@@ -180,7 +180,7 @@ const $ = (r) => {
180
180
  V({}), U(void 0), S([1, 1]), e == null || e.dispose(), T(void 0);
181
181
  };
182
182
  return g(() => {
183
- B(!0), re(), !(!s.current || !d) && R.Image.fromURL(d, (t) => {
183
+ B(!0), re(), !(!s.current || !d) && X.Image.fromURL(d, (t) => {
184
184
  t.set({
185
185
  originX: "center",
186
186
  originY: "center"
@@ -192,7 +192,7 @@ const $ = (r) => {
192
192
  if (!y && e) {
193
193
  try {
194
194
  e.clear();
195
- } catch (M) {
195
+ } catch (R) {
196
196
  }
197
197
  return;
198
198
  }
@@ -201,23 +201,23 @@ const $ = (r) => {
201
201
  const t = y == null ? void 0 : y.getElement();
202
202
  if (!(t != null && t.width) || !(t != null && t.height))
203
203
  return;
204
- const o = t.width / t.height, n = s.current.parentElement.offsetWidth, i = s.current.parentElement.offsetHeight, I = n / t.width, z = i / t.height;
204
+ const o = t.width / t.height, n = s.current.parentElement.offsetWidth, i = s.current.parentElement.offsetHeight, k = n / t.width, z = i / t.height;
205
205
  let C = [n, i];
206
- I > z ? C = [i * o, i] : C = [n, n / o];
206
+ k > z ? C = [i * o, i] : C = [n, n / o];
207
207
  const ae = C[0] / t.width, ie = C[1] / t.height, D = Math.min(ae, ie);
208
208
  S([D, D]);
209
- const m = new R.Canvas(s.current, {
209
+ const m = new X.Canvas(s.current, {
210
210
  containerClass: "marking-canvas",
211
211
  width: n,
212
212
  height: i
213
213
  });
214
214
  if (m == null || m.setZoom(D), m == null || m.renderAll(), m && y) {
215
- const M = (n - C[0]) / D / 2, G = (i - C[1]) / D / 2;
215
+ const R = (n - C[0]) / D / 2, G = (i - C[1]) / D / 2;
216
216
  m.setBackgroundImage(
217
217
  y,
218
218
  () => {
219
219
  m.renderAll(), ee({
220
- left: M,
220
+ left: R,
221
221
  top: G
222
222
  }), T(m), w && w();
223
223
  },
@@ -225,7 +225,7 @@ const $ = (r) => {
225
225
  {
226
226
  originX: "left",
227
227
  originY: "top",
228
- left: M,
228
+ left: R,
229
229
  top: G
230
230
  }
231
231
  );
@@ -241,16 +241,21 @@ const $ = (r) => {
241
241
  id: a.id,
242
242
  name: a.label,
243
243
  color: a.color
244
- }, f && f(t.map(k))), e && (a ? e.defaultCursor = "copy" : e.defaultCursor = "default"), [...t];
244
+ }, f && f(t.map(j))), e && (a ? e.defaultCursor = "copy" : e.defaultCursor = "default"), [...t];
245
245
  }));
246
246
  }, [a, e, p]), g(() => {
247
247
  var t;
248
- if (N && s.current && !j) {
248
+ if (O && s.current && !I) {
249
249
  const o = document.createElement("div");
250
- o.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (t = s.current.parentElement) == null || t.appendChild(o), le.render(/* @__PURE__ */ l(ce, {}), o), K(o);
250
+ o.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (t = s.current.parentElement) == null || t.appendChild(o);
251
+ const n = le(o);
252
+ n.render(/* @__PURE__ */ l(ce, {})), K({
253
+ element: o,
254
+ root: n
255
+ });
251
256
  } else
252
- !N && j && (j.remove(), K(null));
253
- }, [N, s.current, j]), /* @__PURE__ */ Q("div", {
257
+ !O && I && (I.root.unmount(), I.element.remove(), K(null));
258
+ }, [O, s.current, I]), /* @__PURE__ */ Q("div", {
254
259
  style: {
255
260
  width: "100%",
256
261
  height: "100%",
@@ -263,7 +268,7 @@ const $ = (r) => {
263
268
  children: /* @__PURE__ */ Q(fe, {
264
269
  direction: "vertical",
265
270
  size: 16,
266
- children: [/* @__PURE__ */ l(X, {
271
+ children: [/* @__PURE__ */ l(M, {
267
272
  title: "放大-鼠标滚轮前滑",
268
273
  placement: "right",
269
274
  children: /* @__PURE__ */ l(Z, {
@@ -272,7 +277,7 @@ const $ = (r) => {
272
277
  A(-100);
273
278
  }
274
279
  })
275
- }), /* @__PURE__ */ l(X, {
280
+ }), /* @__PURE__ */ l(M, {
276
281
  title: "缩小-鼠标滚轮后滑",
277
282
  placement: "right",
278
283
  children: /* @__PURE__ */ l(Z, {
@@ -281,7 +286,7 @@ const $ = (r) => {
281
286
  A(100);
282
287
  }
283
288
  })
284
- }), !x && /* @__PURE__ */ l(X, {
289
+ }), !x && /* @__PURE__ */ l(M, {
285
290
  title: "拖动-按住ctrl",
286
291
  placement: "right",
287
292
  children: /* @__PURE__ */ l(Z, {
@@ -311,5 +316,5 @@ const $ = (r) => {
311
316
  });
312
317
  };
313
318
  export {
314
- Ne as default
319
+ Oe as default
315
320
  };
@@ -2,40 +2,40 @@ var re = Object.defineProperty, de = Object.defineProperties;
2
2
  var ue = Object.getOwnPropertyDescriptors;
3
3
  var ee = Object.getOwnPropertySymbols;
4
4
  var fe = Object.prototype.hasOwnProperty, se = Object.prototype.propertyIsEnumerable;
5
- var te = (r, h, g) => h in r ? re(r, h, { enumerable: !0, configurable: !0, writable: !0, value: g }) : r[h] = g, L = (r, h) => {
5
+ var te = (r, h, g) => h in r ? re(r, h, { enumerable: !0, configurable: !0, writable: !0, value: g }) : r[h] = g, U = (r, h) => {
6
6
  for (var g in h || (h = {}))
7
7
  fe.call(h, g) && te(r, g, h[g]);
8
8
  if (ee)
9
9
  for (var g of ee(h))
10
10
  se.call(h, g) && te(r, g, h[g]);
11
11
  return r;
12
- }, U = (r, h) => de(r, ue(h));
13
- import { jsx as E } from "react/jsx-runtime";
12
+ }, X = (r, h) => de(r, ue(h));
13
+ import { jsx as $ } from "react/jsx-runtime";
14
14
  import { useState as I, useContext as ge, useEffect as B } from "react";
15
15
  import ce from "./LableEditor.mjs";
16
- import { fabric as X } from "fabric";
16
+ import { fabric as Y } from "fabric";
17
17
  import oe from "ahooks/lib/useKeyPress";
18
18
  import { Spin as le } from "antd";
19
- import he from "react-dom";
19
+ import { createRoot as he } from "react-dom/client";
20
20
  import { getUuid as K } from "../../../../utils/index.mjs";
21
21
  import me from "../../../../DatasetContext/index.mjs";
22
22
  import { OCRServiceId as pe } from "@glodon-aiot/apis";
23
23
  function T(r, h) {
24
24
  let g = -1, u = -1, x = 0, w = 0, a, m;
25
- function Y(e) {
26
- const i = e.target;
27
- i && (i.currentHeight > i.canvas.height || i.currentWidth > i.canvas.width || (i.setCoords(), (i.getBoundingRect().top < 0 || i.getBoundingRect().left < 0) && (i.top = Math.max(i.top, i.top - i.getBoundingRect().top), i.left = Math.max(i.left, i.left - i.getBoundingRect().left)), (i.getBoundingRect().top + i.getBoundingRect().height > i.canvas.height || i.getBoundingRect().left + i.getBoundingRect().width > i.canvas.width) && (i.top = Math.min(i.top, i.canvas.height - i.getBoundingRect().height + i.top - i.getBoundingRect().top), i.left = Math.min(i.left, i.canvas.width - i.getBoundingRect().width + i.left - i.getBoundingRect().left)), i && m && (m.left = i.left, m.top = i.top + i.getBoundingRect().height)));
25
+ function D(e) {
26
+ const n = e.target;
27
+ n && (n.currentHeight > n.canvas.height || n.currentWidth > n.canvas.width || (n.setCoords(), (n.getBoundingRect().top < 0 || n.getBoundingRect().left < 0) && (n.top = Math.max(n.top, n.top - n.getBoundingRect().top), n.left = Math.max(n.left, n.left - n.getBoundingRect().left)), (n.getBoundingRect().top + n.getBoundingRect().height > n.canvas.height || n.getBoundingRect().left + n.getBoundingRect().width > n.canvas.width) && (n.top = Math.min(n.top, n.canvas.height - n.getBoundingRect().height + n.top - n.getBoundingRect().top), n.left = Math.min(n.left, n.canvas.width - n.getBoundingRect().width + n.left - n.getBoundingRect().left)), n && m && (m.left = n.left, m.top = n.top + n.getBoundingRect().height)));
28
28
  }
29
29
  r.on("mouse:down", (e) => {
30
- const i = r.getZoom();
31
- u = e.e.offsetX / i, g = e.e.offsetY / i;
30
+ const n = r.getZoom();
31
+ u = e.e.offsetX / n, g = e.e.offsetY / n;
32
32
  }), r.on("mouse:up", (e) => {
33
33
  if (u === -1 && g === -1)
34
34
  return;
35
- const i = r.getZoom(), c = e.e.offsetX > r.getWidth() ? r.getWidth() / i : e.e.offsetX / i, P = e.e.offsetY > r.getHeight() ? r.getHeight() / i : e.e.offsetY / i;
36
- if (x = Math.abs(c - u), w = Math.abs(P - g), x === 0 || w === 0)
35
+ const n = r.getZoom(), c = e.e.offsetX > r.getWidth() ? r.getWidth() / n : e.e.offsetX / n, j = e.e.offsetY > r.getHeight() ? r.getHeight() / n : e.e.offsetY / n;
36
+ if (x = Math.abs(c - u), w = Math.abs(j - g), x === 0 || w === 0)
37
37
  return;
38
- const b = g > P ? P : g, k = u > c ? c : u, W = x, j = w, f = [{
38
+ const b = g > j ? j : g, k = u > c ? c : u, W = x, M = w, f = [{
39
39
  x: k,
40
40
  y: b
41
41
  }, {
@@ -43,30 +43,30 @@ function T(r, h) {
43
43
  y: b
44
44
  }, {
45
45
  x: k + W,
46
- y: b + j
46
+ y: b + M
47
47
  }, {
48
48
  x: k,
49
- y: b + j
49
+ y: b + M
50
50
  }];
51
- a = new X.Polygon(f, {
51
+ a = new Y.Polygon(f, {
52
52
  fill: "rgba(255, 69, 0, 0.45)",
53
53
  stroke: "rgb(255, 69, 0)",
54
54
  strokeWidth: 1
55
- }), a.set("strokeUniform", !0), r.add(a), m = new X.Text("请在右侧选择对应字段", {
56
- top: b + j,
55
+ }), a.set("strokeUniform", !0), r.add(a), m = new Y.Text("请在右侧选择对应字段", {
56
+ top: b + M,
57
57
  left: k,
58
- fontSize: 14 / i,
58
+ fontSize: 14 / n,
59
59
  backgroundColor: "rgba(0, 0, 0, 0.75)",
60
60
  fill: "#fff",
61
61
  selectable: !1
62
62
  }), r.add(m), r.setActiveObject(a), h && h(a, m), r.skipTargetFind = !1;
63
63
  }), r.on("mouse:move", (e) => {
64
- e.target && Y(e);
64
+ e.target && D(e);
65
65
  });
66
66
  }
67
67
  const Z = (r) => {
68
68
  r.off("mouse:down"), r.off("mouse:up");
69
- }, ae = (r, [h, g, u]) => new X.Polygon(r, {
69
+ }, ae = (r, [h, g, u]) => new Y.Polygon(r, {
70
70
  fill: `rgba(${h},${g}, ${u}, 0.45)`,
71
71
  stroke: `rgba(${h},${g}, ${u}, 1)`,
72
72
  strokeWidth: 0
@@ -89,7 +89,7 @@ const Z = (r) => {
89
89
  return;
90
90
  }
91
91
  m.drawImage(x, w.left * devicePixelRatio, w.top * devicePixelRatio, w.width * devicePixelRatio || 0, w.height * devicePixelRatio || 0, 0, 0, r.getScaledWidth() || 0, r.getScaledHeight() || 0), g(a.toDataURL());
92
- }), je = (r) => {
92
+ }), Me = (r) => {
93
93
  const {
94
94
  id: h,
95
95
  imageUrl: g,
@@ -97,16 +97,16 @@ const Z = (r) => {
97
97
  labels: x = [],
98
98
  categories: w,
99
99
  onChange: a
100
- } = r, [m, Y] = I(!0), [e, i] = I(), [c, P] = I({}), [b, k] = I(), [W, j] = I([1, 1]), [f, M] = I(), [p, H] = I(null), [D, O] = I(), [s, A] = I(x == null ? void 0 : x.filter((t) => !!t).map((t) => {
101
- var o, n;
100
+ } = r, [m, D] = I(!0), [e, n] = I(), [c, j] = I({}), [b, k] = I(), [W, M] = I([1, 1]), [f, P] = I(), [p, H] = I(null), [E, O] = I(), [s, A] = I(x == null ? void 0 : x.filter((t) => !!t).map((t) => {
101
+ var o, i;
102
102
  return {
103
103
  uuid: t.uuid,
104
104
  box: ((o = t.box) == null ? void 0 : o.map((d) => [d[0], d[1]])) || [],
105
105
  words: t.words,
106
- type: (n = t.type) == null ? void 0 : n.toLowerCase(),
106
+ type: (i = t.type) == null ? void 0 : i.toLowerCase(),
107
107
  catagoryId: t.catagoryId
108
108
  };
109
- })), [F, V] = I(!0), [$, q] = I(), {
109
+ })), [F, V] = I(!0), [L, q] = I(), {
110
110
  services: {
111
111
  aiShop: z
112
112
  },
@@ -120,8 +120,8 @@ const Z = (r) => {
120
120
  if (e && F) {
121
121
  const t = e.getActiveObject();
122
122
  if (t) {
123
- t === (f == null ? void 0 : f.polygon) && (e == null || e.remove(f == null ? void 0 : f.text), M(void 0)), e.remove(t), e.renderAll();
124
- const o = s.findIndex((n) => c[n.uuid] === t);
123
+ t === (f == null ? void 0 : f.polygon) && (e == null || e.remove(f == null ? void 0 : f.text), P(void 0)), e.remove(t), e.renderAll();
124
+ const o = s.findIndex((i) => c[i.uuid] === t);
125
125
  o > -1 && (c[s[o].uuid] && (e == null || e.remove(c[s[o].uuid])), s.splice(o, 1), A([...s]), a([...s]));
126
126
  } else
127
127
  console.log("no active object");
@@ -136,25 +136,25 @@ const Z = (r) => {
136
136
  s.forEach((t) => {
137
137
  x.find((o) => o.uuid === t.uuid) || e == null || e.remove(c[t.uuid]);
138
138
  }), A(x == null ? void 0 : x.filter((t) => !!t).map((t) => {
139
- var o, n;
139
+ var o, i;
140
140
  return {
141
141
  uuid: t.uuid,
142
142
  box: ((o = t.box) == null ? void 0 : o.map((d) => [d[0], d[1]])) || [],
143
143
  words: t.words,
144
- type: (n = t.type) == null ? void 0 : n.toLowerCase(),
144
+ type: (i = t.type) == null ? void 0 : i.toLowerCase(),
145
145
  catagoryId: t.catagoryId
146
146
  };
147
147
  }));
148
148
  }, [x]);
149
149
  const ne = () => {
150
- P({}), k(void 0), j([1, 1]), M(void 0), H(null), O(void 0), A([]), e == null || e.dispose(), i(void 0);
150
+ j({}), k(void 0), M([1, 1]), P(void 0), H(null), O(void 0), A([]), e == null || e.dispose(), n(void 0);
151
151
  };
152
152
  B(() => {
153
- Y(!0), ne(), !(!u || !g || !h) && X.Image.fromURL(g, (t) => {
153
+ D(!0), ne(), !(!u || !g || !h) && Y.Image.fromURL(g, (t) => {
154
154
  t.set({
155
155
  originX: "center",
156
156
  originY: "center"
157
- }), k(t), Y(!1);
157
+ }), k(t), D(!1);
158
158
  }, {
159
159
  crossOrigin: "anonymous"
160
160
  });
@@ -169,12 +169,12 @@ const Z = (r) => {
169
169
  const t = b == null ? void 0 : b.getElement();
170
170
  if (!(t != null && t.width) || !(t != null && t.height))
171
171
  return;
172
- const o = t.width / t.height, n = ((Q = u.parentElement) == null ? void 0 : Q.offsetWidth) || (u == null ? void 0 : u.offsetWidth), d = ((_ = u == null ? void 0 : u.parentElement) == null ? void 0 : _.offsetHeight) || (u == null ? void 0 : u.offsetHeight), y = n / t.width, R = d / t.height;
173
- y > R ? (u.width = d * o, u.height = d) : (u.width = n, u.height = n / o);
172
+ const o = t.width / t.height, i = ((Q = u.parentElement) == null ? void 0 : Q.offsetWidth) || (u == null ? void 0 : u.offsetWidth), d = ((_ = u == null ? void 0 : u.parentElement) == null ? void 0 : _.offsetHeight) || (u == null ? void 0 : u.offsetHeight), y = i / t.width, R = d / t.height;
173
+ y > R ? (u.width = d * o, u.height = d) : (u.width = i, u.height = i / o);
174
174
  const l = u.width / t.width, C = u.height / t.height, v = Math.min(l, C);
175
- j([v, v]);
175
+ M([v, v]);
176
176
  let S = e;
177
- e ? (e.clear(), e.setWidth(u.width), e.setHeight(u.height)) : S = new X.Canvas(u, {
177
+ e ? (e.clear(), e.setWidth(u.width), e.setHeight(u.height)) : S = new Y.Canvas(u, {
178
178
  containerClass: "marking-canvas",
179
179
  width: u.width,
180
180
  height: u.height
@@ -188,38 +188,43 @@ const Z = (r) => {
188
188
  left: 0,
189
189
  top: 0
190
190
  }
191
- ), i(S));
191
+ ), n(S));
192
192
  }, [b]), B(() => {
193
- m || !e || N(e, s, D);
194
- }, [s, e, D, m]), B(() => {
195
- D || a(s);
196
- }, [D]);
197
- const N = (t, o, n = "") => {
193
+ m || !e || N(e, s, E);
194
+ }, [s, e, E, m]), B(() => {
195
+ E || a(s);
196
+ }, [E]);
197
+ const N = (t, o, i = "") => {
198
198
  o == null || o.map((d) => {
199
199
  var R, l;
200
200
  const y = ae((R = d.box) == null ? void 0 : R.map((C) => ({
201
201
  x: C[0],
202
202
  y: C[1]
203
203
  })), ((l = d.type) == null ? void 0 : l.toLowerCase()) === "key" ? [255, 193, 0] : [80, 139, 238]);
204
- c[d.uuid] ? xe(t, c[d.uuid], y) : t.add(y), c[d.uuid] = y, P(() => c);
205
- }), n && (!p || p !== t.getActiveObject()) && (t == null || t.setActiveObject(c[n]), H(c[n]));
204
+ c[d.uuid] ? xe(t, c[d.uuid], y) : t.add(y), c[d.uuid] = y, j(() => c);
205
+ }), i && (!p || p !== t.getActiveObject()) && (t == null || t.setActiveObject(c[i]), H(c[i]));
206
206
  };
207
207
  B(() => {
208
208
  var t;
209
- if (m && u && !$) {
209
+ if (m && u && !L) {
210
210
  const o = document.createElement("div");
211
- o.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (t = u.parentElement) == null || t.appendChild(o), he.render(/* @__PURE__ */ E(le, {}), o), q(o);
211
+ o.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (t = u.parentElement) == null || t.appendChild(o);
212
+ const i = he(o);
213
+ i.render(/* @__PURE__ */ $(le, {})), q({
214
+ element: o,
215
+ root: i
216
+ });
212
217
  } else
213
- !m && $ && ($.remove(), q(null));
214
- }, [m, u, $]), B(() => {
218
+ !m && L && (L.root.unmount(), L.element.remove(), q(null));
219
+ }, [m, u, L]), B(() => {
215
220
  m && e && N(e, []), !(m || !e) && (N(e, []), T(e, (t, o) => {
216
- f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon)), M({
221
+ f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon)), P({
217
222
  polygon: t,
218
223
  text: o,
219
224
  uuid: K()
220
225
  });
221
226
  }), e.on("selection:created", (t) => {
222
- var n;
227
+ var i;
223
228
  Z(e), H(e.getActiveObject());
224
229
  const o = e.getActiveObject();
225
230
  o == null || o.set({
@@ -228,14 +233,14 @@ const Z = (r) => {
228
233
  cornerSize: 7,
229
234
  transparentCorners: !1,
230
235
  cornerStrokeColor: "rgba(109, 109, 109, 1)"
231
- }), (n = Object.keys(c)) == null || n.map((d) => {
236
+ }), (i = Object.keys(c)) == null || i.map((d) => {
232
237
  o === c[d] && O(d);
233
238
  });
234
239
  }), e.on("selection:updated", (t) => {
235
- var n;
240
+ var i;
236
241
  Z(e), H(e.getActiveObject());
237
242
  const o = e.getActiveObject();
238
- (n = Object.keys(c)) == null || n.map((d) => {
243
+ (i = Object.keys(c)) == null || i.map((d) => {
239
244
  o === c[d] && O(d);
240
245
  });
241
246
  }), e.on("selection:cleared", () => {
@@ -246,20 +251,20 @@ const Z = (r) => {
246
251
  image: t
247
252
  }).catch(() => [{
248
253
  words: ""
249
- }]).then((o) => o == null ? void 0 : o.map((n) => n.words).join(""));
254
+ }]).then((o) => o == null ? void 0 : o.map((i) => i.words).join(""));
250
255
  return B(() => {
251
256
  e && (f ? (Z(e), f.value === void 0 && (ie(f.polygon).then((t) => J(t)).then((t) => {
252
- M(U(L({}, f), {
257
+ P(X(U({}, f), {
253
258
  value: t
254
259
  }));
255
260
  }), e.on("event:moved", () => {
256
261
  ie(f.polygon).then((t) => J(t)).then((t) => {
257
- f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon)), M(U(L({}, f), {
262
+ f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon)), P(X(U({}, f), {
258
263
  value: t
259
264
  }));
260
265
  });
261
266
  }))) : p || T(e, (t, o) => {
262
- M({
267
+ P({
263
268
  polygon: t,
264
269
  text: o,
265
270
  uuid: K()
@@ -269,7 +274,7 @@ const Z = (r) => {
269
274
  if (e) {
270
275
  if (!p) {
271
276
  T(e, (t, o) => {
272
- f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon)), M({
277
+ f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon)), P({
273
278
  polygon: t,
274
279
  text: o,
275
280
  uuid: K()
@@ -280,11 +285,11 @@ const Z = (r) => {
280
285
  p == null || p.on("mousedown", () => {
281
286
  e && Z(e);
282
287
  }), p == null || p.on("mouseup:before", () => {
283
- var n;
288
+ var i;
284
289
  if (!e)
285
290
  return;
286
291
  const t = p, o = e.getZoom();
287
- (n = Object.keys(c)) == null || n.map((d) => {
292
+ (i = Object.keys(c)) == null || i.map((d) => {
288
293
  var y;
289
294
  if (t === c[d]) {
290
295
  const R = s.findIndex((l) => l.uuid === d);
@@ -292,11 +297,11 @@ const Z = (r) => {
292
297
  }
293
298
  }), A([...s]), a([...s]);
294
299
  }), p == null || p.on("moving", () => {
295
- var n;
300
+ var i;
296
301
  if (!e)
297
302
  return;
298
303
  const t = p, o = e.getZoom();
299
- (n = Object.keys(c)) == null || n.map((d) => {
304
+ (i = Object.keys(c)) == null || i.map((d) => {
300
305
  var y;
301
306
  if (t === c[d]) {
302
307
  const R = s.findIndex((l) => l.uuid === d);
@@ -305,30 +310,30 @@ const Z = (r) => {
305
310
  });
306
311
  });
307
312
  }
308
- }, [p]), /* @__PURE__ */ E("div", {
313
+ }, [p]), /* @__PURE__ */ $("div", {
309
314
  children: w.length ? w == null ? void 0 : w.map((t) => {
310
315
  var o;
311
- return /* @__PURE__ */ E(ce, {
312
- selectedLabel: s.find((n) => c[n.uuid] === p),
316
+ return /* @__PURE__ */ $(ce, {
317
+ selectedLabel: s.find((i) => c[i.uuid] === p),
313
318
  holdingLabel: f != null && f.polygon ? {
314
319
  uuid: f.uuid,
315
- box: (o = f.polygon.getCoords()) == null ? void 0 : o.map((n) => [n.x / W[0], n.y / W[1]]),
320
+ box: (o = f.polygon.getCoords()) == null ? void 0 : o.map((i) => [i.x / W[0], i.y / W[1]]),
316
321
  words: f.value || ""
317
322
  } : void 0,
318
- type: s.filter((n) => {
323
+ type: s.filter((i) => {
319
324
  var d;
320
- return n.catagoryId === t.id && ((d = n.type) == null ? void 0 : d.toLowerCase()) === "key";
325
+ return i.catagoryId === t.id && ((d = i.type) == null ? void 0 : d.toLowerCase()) === "key";
321
326
  }),
322
- value: s.filter((n) => {
327
+ value: s.filter((i) => {
323
328
  var d;
324
- return n.catagoryId === t.id && ((d = n.type) == null ? void 0 : d.toLowerCase()) === "value";
329
+ return i.catagoryId === t.id && ((d = i.type) == null ? void 0 : d.toLowerCase()) === "value";
325
330
  }),
326
331
  category: t,
327
- onChange: (n, d) => {
332
+ onChange: (i, d) => {
328
333
  var R;
329
- ((R = n.concat(d)) == null ? void 0 : R.map((l) => {
334
+ ((R = i.concat(d)) == null ? void 0 : R.map((l) => {
330
335
  var C;
331
- return U(L({}, l), {
336
+ return X(U({}, l), {
332
337
  box: (C = l.box) == null ? void 0 : C.map((v) => [v[0], v[1]])
333
338
  });
334
339
  })).forEach((l) => {
@@ -338,29 +343,29 @@ const Z = (r) => {
338
343
  // eslint-disable-next-line no-unsafe-optional-chaining
339
344
  ...s == null ? void 0 : s.map((l) => {
340
345
  var C;
341
- return U(L({}, l), {
346
+ return X(U({}, l), {
342
347
  box: (C = l.box) == null ? void 0 : C.map((v) => [v[0], v[1]])
343
348
  });
344
349
  })
345
350
  ]), a([...s]);
346
351
  },
347
- onRemove: (n) => {
348
- const d = s.findIndex((y) => y.uuid === n.uuid);
352
+ onRemove: (i) => {
353
+ const d = s.findIndex((y) => y.uuid === i.uuid);
349
354
  d > -1 && (c[s[d].uuid] && (e == null || e.remove(c[s[d].uuid])), s.splice(d, 1), A([...s]), a([...s]));
350
355
  },
351
356
  clearHoldingLabel: () => {
352
- f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon), M(void 0), O(f.uuid));
357
+ f && (e == null || e.remove(f.text), e == null || e.remove(f.polygon), P(void 0), O(f.uuid));
353
358
  },
354
- onSelect: (n) => {
355
- O(n == null ? void 0 : n.uuid);
359
+ onSelect: (i) => {
360
+ O(i == null ? void 0 : i.uuid);
356
361
  }
357
362
  }, t.id);
358
- }) : /* @__PURE__ */ E("div", {
363
+ }) : /* @__PURE__ */ $("div", {
359
364
  className: "empty",
360
365
  children: "暂无字段,请先在“字段管理”中进行添加"
361
366
  })
362
367
  });
363
368
  };
364
369
  export {
365
- je as default
370
+ Me as default
366
371
  };