@glodon-aiot/dataset-annotation 3.2.2-beta.2 → 3.2.2-beta.4

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 (138) hide show
  1. package/dist/es/Common/Page/index.mjs +29 -0
  2. package/dist/es/Common/Page/style.less.mjs +4 -0
  3. package/dist/es/Common/PageContent/index.mjs +18 -0
  4. package/dist/es/Common/PageHeader/index.mjs +39 -0
  5. package/dist/es/Common/PageHeader/style.less.mjs +4 -0
  6. package/dist/es/DatasetContext/index.mjs +11 -0
  7. package/dist/es/_virtual/_commonjsHelpers.mjs +4 -0
  8. package/dist/es/_virtual/minio.mjs +4 -0
  9. package/dist/es/access/images/data_empty.svg.mjs +4 -0
  10. package/dist/es/components/CompositionInput/index.mjs +53 -0
  11. package/dist/es/components/DataEmpty/index.mjs +51 -0
  12. package/dist/es/components/DataEmpty/style.less.mjs +4 -0
  13. package/dist/es/components/DetectionAnnotation/PreSamplesPage/index.mjs +292 -0
  14. package/dist/es/components/DetectionAnnotation/PreSamplesPage/style.less.mjs +4 -0
  15. package/dist/es/components/DetectionAnnotation/components/DisabledTooltip/index.mjs +23 -0
  16. package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +166 -0
  17. package/dist/es/components/DetectionAnnotation/components/ImageDetail/style.less.mjs +4 -0
  18. package/dist/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +51 -0
  19. package/dist/es/components/DetectionAnnotation/components/LabelMaker/FabricCustomize.mjs +42 -0
  20. package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +283 -0
  21. package/dist/es/components/DetectionAnnotation/components/LabelMaker/icons/delete-icon.svg.mjs +4 -0
  22. package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +315 -0
  23. package/dist/es/components/DetectionAnnotation/components/LabelMaker/style.less.mjs +4 -0
  24. package/dist/es/components/DetectionAnnotation/components/Labels/index.mjs +201 -0
  25. package/dist/es/components/DetectionAnnotation/components/Labels/style.less.mjs +4 -0
  26. package/dist/es/components/DetectionAnnotation/components/TagItem/index.mjs +144 -0
  27. package/dist/es/components/DetectionAnnotation/components/TagItem/style.less.mjs +4 -0
  28. package/dist/es/components/DetectionAnnotation/icon_item_empty.svg.mjs +4 -0
  29. package/dist/es/components/DetectionAnnotation/index.mjs +713 -0
  30. package/dist/es/components/DetectionAnnotation/style.less.mjs +4 -0
  31. package/dist/es/components/DetectionImageAnnotation/index.mjs +62 -0
  32. package/dist/es/components/DetectionImageAnnotation/style.less.mjs +4 -0
  33. package/dist/es/components/Iconfont/index.mjs +16 -0
  34. package/dist/es/components/MarkDescriptions/index.mjs +66 -0
  35. package/dist/es/components/MarkDescriptions/style.less.mjs +4 -0
  36. package/dist/es/components/OCRImageViewer/index.mjs +213 -0
  37. package/dist/es/components/OCRImageViewer/style.less.mjs +4 -0
  38. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/CategoryDrawer.mjs +136 -0
  39. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorInput.mjs +57 -0
  40. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorItem.mjs +73 -0
  41. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LableEditor.mjs +55 -0
  42. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/index.mjs +366 -0
  43. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/style.less.mjs +4 -0
  44. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/index.mjs +255 -0
  45. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/style.less.mjs +4 -0
  46. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/ImageDetail/index.mjs +101 -0
  47. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/ImageDetail/style.less.mjs +4 -0
  48. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/images/delete.png.mjs +4 -0
  49. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.mjs +756 -0
  50. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/style.less.mjs +4 -0
  51. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/index.mjs +231 -0
  52. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/style.less.mjs +4 -0
  53. package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +180 -0
  54. package/dist/es/components/OcrAnnotation/OcrModal/style.less.mjs +4 -0
  55. package/dist/es/components/OcrAnnotation/PreLabelOCR/PreLabelModal.mjs +281 -0
  56. package/dist/es/components/OcrAnnotation/PreLabelOCR/index.mjs +44 -0
  57. package/dist/es/components/OcrAnnotation/PreLabelOCR/style.less.mjs +4 -0
  58. package/dist/es/components/OcrAnnotation/constant.mjs +5 -0
  59. package/dist/es/components/OcrAnnotation/index.mjs +382 -0
  60. package/dist/es/components/OcrAnnotation/style.less.mjs +4 -0
  61. package/dist/es/components/OcrImageAnnotation/index.mjs +40 -0
  62. package/dist/es/components/OcrImageAnnotation/style.less.mjs +4 -0
  63. package/dist/es/components/PageNav/index.mjs +30 -0
  64. package/dist/es/components/PageNav/style.less.mjs +4 -0
  65. package/dist/es/components/PicZipImportModal/index.mjs +584 -0
  66. package/dist/es/components/PicZipImportModal/pic_zip.svg.mjs +4 -0
  67. package/dist/es/components/PicZipImportModal/pic_zip_json.svg.mjs +4 -0
  68. package/dist/es/components/PicZipImportModal/style.less.mjs +4 -0
  69. package/dist/es/components/PreLabelOCR/PreLabelModal.mjs +276 -0
  70. package/dist/es/components/PreLabelOCR/index.mjs +44 -0
  71. package/dist/es/components/PreLabelOCR/style.less.mjs +4 -0
  72. package/dist/es/components/ScanTable/index.mjs +97 -0
  73. package/dist/es/components/ScanTable/style.less.mjs +4 -0
  74. package/dist/es/components/Thumbnail/default.png.mjs +4 -0
  75. package/dist/es/components/Thumbnail/index.mjs +31 -0
  76. package/dist/es/components/Thumbnail/style.less.mjs +4 -0
  77. package/dist/es/components/hooks/Prompt.mjs +33 -0
  78. package/dist/es/constant.mjs +13 -0
  79. package/dist/es/createDatasetAnnotation/index.mjs +133 -0
  80. package/dist/es/createDetectionDatasetAnnotation/index.mjs +129 -0
  81. package/dist/es/createDetectionImageAnnotation/index.mjs +31 -0
  82. package/dist/es/createOcrDatasetAnnotation/index.mjs +129 -0
  83. package/dist/es/createOcrImageAnnotation/index.mjs +33 -0
  84. package/dist/es/featuresConfig.mjs +79 -0
  85. package/dist/es/index.mjs +13 -0
  86. package/dist/es/node_modules/@glodon-aiot/minio/dist/minio.mjs +28463 -0
  87. package/dist/es/utils/color.mjs +30 -0
  88. package/dist/es/utils/index.mjs +22 -0
  89. package/dist/es/utils/sign.mjs +33 -0
  90. package/dist/lib/index.js +130 -0
  91. package/dist/src/Common/Page/index.d.ts +1 -2
  92. package/dist/src/Common/PageHeader/index.d.ts +0 -1
  93. package/dist/src/DatasetContext/index.d.ts +3 -4
  94. package/dist/src/components/CompositionInput/index.d.ts +2 -2
  95. package/dist/src/components/DataEmpty/index.d.ts +1 -2
  96. package/dist/src/components/DetectionAnnotation/PreSamplesPage/index.d.ts +1 -2
  97. package/dist/src/components/DetectionAnnotation/components/DisabledTooltip/index.d.ts +2 -2
  98. package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +1 -2
  99. package/dist/src/components/DetectionAnnotation/components/LabelMaker/Drawable.d.ts +2 -2
  100. package/dist/src/components/DetectionAnnotation/components/LabelMaker/RectLabel.d.ts +6 -5
  101. package/dist/src/components/DetectionAnnotation/components/LabelMaker/index.d.ts +0 -1
  102. package/dist/src/components/DetectionAnnotation/components/Labels/index.d.ts +0 -1
  103. package/dist/src/components/DetectionAnnotation/components/TagItem/index.d.ts +1 -2
  104. package/dist/src/components/DetectionAnnotation/index.d.ts +1 -2
  105. package/dist/src/components/DetectionImageAnnotation/index.d.ts +0 -2
  106. package/dist/src/components/Iconfont/font_3140028_iptomfpgyu.d.ts +0 -0
  107. package/dist/src/components/Iconfont/font_3454453_gu5ijeufyng.d.ts +0 -0
  108. package/dist/src/components/Iconfont/font_4108228_3slzqhoow93.d.ts +0 -0
  109. package/dist/src/components/Iconfont/font_4439177_k3mjwv7kzfd.d.ts +0 -0
  110. package/dist/src/components/Iconfont/index.d.ts +1 -2
  111. package/dist/src/components/MarkDescriptions/index.d.ts +0 -1
  112. package/dist/src/components/OCRImageViewer/index.d.ts +1 -2
  113. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorInput.d.ts +2 -2
  114. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LabelEditorItem.d.ts +1 -2
  115. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/LableEditor.d.ts +0 -1
  116. package/dist/src/components/OcrAnnotation/MarkKVOCRModal/index.d.ts +0 -1
  117. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/ImageDetail/index.d.ts +1 -2
  118. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LabelEditorInput.d.ts +2 -2
  119. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LabelEditorItem.d.ts +0 -1
  120. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/LableEditor.d.ts +0 -1
  121. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.d.ts +0 -1
  122. package/dist/src/components/OcrAnnotation/MarkOCRBoxModal/index.d.ts +0 -1
  123. package/dist/src/components/OcrAnnotation/OcrModal/index.d.ts +1 -2
  124. package/dist/src/components/OcrAnnotation/PreLabelOCR/PreLabelModal.d.ts +1 -2
  125. package/dist/src/components/OcrAnnotation/PreLabelOCR/index.d.ts +1 -2
  126. package/dist/src/components/OcrAnnotation/index.d.ts +1 -2
  127. package/dist/src/components/OcrImageAnnotation/index.d.ts +0 -2
  128. package/dist/src/components/PageNav/index.d.ts +1 -2
  129. package/dist/src/components/PicZipImportModal/index.d.ts +1 -2
  130. package/dist/src/components/PreLabelOCR/PreLabelModal.d.ts +1 -2
  131. package/dist/src/components/PreLabelOCR/index.d.ts +1 -2
  132. package/dist/src/components/ScanTable/index.d.ts +1 -2
  133. package/dist/src/components/Thumbnail/index.d.ts +1 -2
  134. package/dist/src/components/hooks/Prompt.d.ts +0 -1
  135. package/dist/src/components/hooks/useBlocker.d.ts +1 -1
  136. package/dist/src/featuresConfig.d.ts +1 -1
  137. package/dist/src/utils/sign.d.ts +1 -1
  138. package/package.json +15 -6
@@ -0,0 +1,756 @@
1
+ var Re = Object.defineProperty, ve = Object.defineProperties;
2
+ var Ue = Object.getOwnPropertyDescriptors;
3
+ var fe = Object.getOwnPropertySymbols;
4
+ var Ce = Object.prototype.hasOwnProperty, Ye = Object.prototype.propertyIsEnumerable;
5
+ var Ee = Math.pow, ke = (r, m, s) => m in r ? Re(r, m, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[m] = s, Q = (r, m) => {
6
+ for (var s in m || (m = {}))
7
+ Ce.call(m, s) && ke(r, s, m[s]);
8
+ if (fe)
9
+ for (var s of fe(m))
10
+ Ye.call(m, s) && ke(r, s, m[s]);
11
+ return r;
12
+ }, re = (r, m) => ve(r, Ue(m));
13
+ var ge = (r, m) => {
14
+ var s = {};
15
+ for (var p in r)
16
+ Ce.call(r, p) && m.indexOf(p) < 0 && (s[p] = r[p]);
17
+ if (r != null && fe)
18
+ for (var p of fe(r))
19
+ m.indexOf(p) < 0 && Ye.call(r, p) && (s[p] = r[p]);
20
+ return s;
21
+ };
22
+ import { jsx as S, jsxs as Xe } from "react/jsx-runtime";
23
+ import { useState as U, useEffect as F } from "react";
24
+ import { fabric as z } from "fabric";
25
+ import le from "ahooks/lib/useKeyPress";
26
+ import { Spin as $e, Space as Ie, Radio as me, Tooltip as se, Button as he } from "antd";
27
+ import Me from "react-dom";
28
+ import "./style.less.mjs";
29
+ import Fe from "./images/delete.png.mjs";
30
+ import { ZoomInOutlined as Ne, ZoomOutOutlined as Le, DragOutlined as We } from "@ant-design/icons";
31
+ import Ae from "../../../Iconfont/index.mjs";
32
+ import { getUuid as Te } from "../../../../utils/index.mjs";
33
+ const Pe = (r) => {
34
+ const m = r.calcTransformMatrix(), s = r.canvas.backgroundImage;
35
+ return r.get("points").map(function(g) {
36
+ return new z.Point(g.x - r.pathOffset.x, g.y - r.pathOffset.y);
37
+ }).map(function(g) {
38
+ return z.util.transformPoint(g, m);
39
+ }).map((g) => {
40
+ let f, w;
41
+ return g.x <= s.left ? f = s.left : g.x > s.left + s.width ? f = s.left + s.width : f = g.x, g.y <= s.top ? w = s.top : g.y > s.top + s.height ? w = s.top + s.height : w = g.y, {
42
+ x: f,
43
+ y: w
44
+ };
45
+ });
46
+ }, ze = (r, m) => {
47
+ const s = r.backgroundImage;
48
+ return !(s && typeof s != "string" && s.top !== void 0 && s.height !== void 0 && s.left !== void 0 && s.width !== void 0 && (m.x < s.left || m.y < s.top || m.x > s.left + s.width || m.y > s.top + s.height));
49
+ };
50
+ function Se(r, m) {
51
+ let s = -1, p = -1, a = 0, g = 0, f, w, X = !1;
52
+ r.on("mouse:down", (e) => {
53
+ X = !0;
54
+ const I = r.getZoom(), h = r.viewportTransform ? r.viewportTransform[4] / I : 0, T = r.viewportTransform ? r.viewportTransform[5] / I : 0;
55
+ p = e.e.offsetX / I - h, s = e.e.offsetY / I - T;
56
+ }), r.on("mouse:up", (e) => {
57
+ if (X = !1, p === -1 && s === -1)
58
+ return;
59
+ const I = r.getZoom(), h = r.viewportTransform ? r.viewportTransform[4] / I : 0, T = r.viewportTransform ? r.viewportTransform[5] / I : 0, P = (e.e.offsetX > r.getWidth() ? r.getWidth() / I : e.e.offsetX / I) - h, Z = (e.e.offsetY > r.getHeight() ? r.getHeight() / I : e.e.offsetY / I) - T;
60
+ if (a = Math.abs(P - p), g = Math.abs(Z - s), a === 0 || g === 0)
61
+ return;
62
+ const k = s > Z ? Z : s, D = p > P ? P : p, C = a, L = g, W = [{
63
+ x: D,
64
+ y: k
65
+ }, {
66
+ x: D + C,
67
+ y: k
68
+ }, {
69
+ x: D + C,
70
+ y: k + L
71
+ }, {
72
+ x: D,
73
+ y: k + L
74
+ }];
75
+ W.every((_) => ze(r, _)) && (f = new z.Polygon(W, {
76
+ fill: "rgba(255, 69, 0, 0.45)",
77
+ stroke: "rgb(255, 69, 0)",
78
+ strokeWidth: 1
79
+ }), f.set("strokeUniform", !0), r.add(f), r.setActiveObject(f), m && m(f, w), r.skipTargetFind = !1);
80
+ }), r.on("mouse:move", (e) => {
81
+ e.target;
82
+ });
83
+ }
84
+ function pe(r, m, s) {
85
+ const p = {
86
+ type: "roof",
87
+ background: "",
88
+ border: ""
89
+ };
90
+ let a, g = [], f = [], w = [], X = [], e = 0, I = null, h, T, P, Z = !1, k, D, C;
91
+ const L = r.getZoom(), W = 2 / L, _ = [7 / L, 10 / L];
92
+ r.on("mouse:down", (l) => {
93
+ var G;
94
+ const u = r.getZoom(), x = r.viewportTransform ? r.viewportTransform[4] / u : 0, B = r.viewportTransform ? r.viewportTransform[5] / u : 0;
95
+ if (a && l.e.offsetX / u - x === a.x - x)
96
+ return;
97
+ X = [], a = {
98
+ x: l.e.offsetX / u - x,
99
+ y: l.e.offsetY / u - B
100
+ }, e || (h = l.e.offsetX / u - x, T = l.e.offsetY / u - B);
101
+ const R = {
102
+ x: a.x,
103
+ y: a.y
104
+ };
105
+ g.push(R);
106
+ const O = [R.x, R.y, R.x, R.y], j = [h, T, R.x, R.y];
107
+ if ((G = f[f.length - 1]) == null || G.set({
108
+ strokeDashArray: []
109
+ }), f.push(new z.Line(O, {
110
+ strokeWidth: W,
111
+ selectable: !1,
112
+ stroke: "#508BEE",
113
+ strokeUniform: !0
114
+ })), w.push(new z.Line(j, {
115
+ strokeWidth: W,
116
+ strokeDashArray: _,
117
+ selectable: !1,
118
+ stroke: "#508BEE",
119
+ strokeUniform: !0
120
+ })), X.push(new z.Line(j, {
121
+ strokeWidth: W,
122
+ selectable: !1,
123
+ stroke: "#508BEE",
124
+ strokeUniform: !0
125
+ })), e > 1) {
126
+ if (s && e >= s - 1) {
127
+ b();
128
+ return;
129
+ }
130
+ const N = f.length - 2;
131
+ if (P = f.some((K) => V(K, f[N])), Z = f.some((K) => V(K, X[0])), P || Z) {
132
+ e--, P = !1, g.splice(g.length - 1, 1), r.remove(f[N]), f.splice(N, 2);
133
+ const K = [f[f.length - 1].x2, f[f.length - 1].y2, f[f.length - 1].x2, f[f.length - 1].y2];
134
+ f.push(new z.Line(K, {
135
+ strokeWidth: W,
136
+ selectable: !1,
137
+ stroke: "#508BEE"
138
+ })), w[0].set({
139
+ x2: f[f.length - 1].x2,
140
+ y2: f[f.length - 1].y2
141
+ });
142
+ }
143
+ const te = w.splice(0, 1);
144
+ w = [], w.push(...te), r.add(f[e]);
145
+ } else
146
+ e !== 1 ? r.add(f[e], w[e]) : r.add(f[e]);
147
+ e++;
148
+ }), r.on("mouse:move", (l) => {
149
+ const u = r.getZoom(), x = r.viewportTransform ? r.viewportTransform[4] / u : 0, B = r.viewportTransform ? r.viewportTransform[5] / u : 0;
150
+ f[0] !== null && f[0] !== void 0 && p.type == "roof" && (k = l.e.offsetX / u - x, D = l.e.offsetY / u - B, f[e - 1].set({
151
+ x2: k,
152
+ y2: D,
153
+ strokeDashArray: _
154
+ }), w[0].set({
155
+ x2: k,
156
+ y2: D
157
+ }), r.renderAll());
158
+ });
159
+ const b = () => {
160
+ r.off("mouse:down"), f.forEach((l) => r.remove(l)), w.forEach((l) => r.remove(l)), d(), I && r.add(I), r.renderAll(), g = [], f = [], w = [], e = 0;
161
+ }, q = () => {
162
+ [...f, ...w, ...X].forEach((l) => r.remove(l)), r.renderAll(), g = [], f = [], w = [], e = 0;
163
+ };
164
+ r.on("selection:created", q), document.addEventListener("keydown", (l) => {
165
+ l.key === "Escape" && q();
166
+ });
167
+ const d = () => {
168
+ const l = oe(g), u = J(g), x = Q({}, g[0]);
169
+ g.push(x), g.some((B, R) => {
170
+ var O, j;
171
+ ((j = (O = f[f.length - 1]) == null ? void 0 : O.aCoords) == null ? void 0 : j.bl.x) == B.x && g.splice(R, 1);
172
+ }), g.every((B) => ze(r, B)) ? (I = new z.Polyline(g, {
173
+ fill: "rgba(80, 139, 238, 0.45)",
174
+ strokeWidth: W,
175
+ stroke: "#508BEE",
176
+ left: l,
177
+ top: u
178
+ }), q(), m && m(I, C)) : pe(r, m, 4);
179
+ }, J = (l) => {
180
+ let u = 999999;
181
+ for (let x = 0; x < e; x++)
182
+ l[x].y < u && (u = l[x].y);
183
+ return Math.abs(u);
184
+ }, oe = (l) => {
185
+ let u = 999999;
186
+ for (let x = 0; x < e; x++)
187
+ l[x].x < u && (u = l[x].x);
188
+ return Math.abs(u);
189
+ }, V = (l, u) => {
190
+ const x = l.y2 - l.y1, B = l.x1 - l.x2, R = x * l.x1 + B * l.y1, O = u.y2 - u.y1, j = u.x1 - u.x2, G = O * u.x1 + j * u.y1, N = x * j - O * B;
191
+ if (N == 0)
192
+ return !1;
193
+ {
194
+ const te = (j * R - B * G) / N, K = (x * G - O * R) / N;
195
+ if ((y(l.x1, te, l.x2) || y(l.y1, K, l.y2)) && (y(u.x1, te, u.x2) || y(u.y1, K, u.y2)))
196
+ return !0;
197
+ }
198
+ return !1;
199
+ }, y = (l, u, x) => Math.abs(l - u) < 1e-6 || Math.abs(u - x) < 1e-6 ? !1 : l < u && u < x || x < u && u < l;
200
+ }
201
+ const de = (r) => {
202
+ r.off("mouse:down"), r.off("mouse:up"), r.off("mouse:move");
203
+ }, je = (r, [m, s, p], a, g) => {
204
+ const f = new z.Polygon(r, {
205
+ fill: `rgba(${m},${s}, ${p}, 0.45)`,
206
+ stroke: `rgba(${m},${s}, ${p}, 1)`,
207
+ strokeWidth: 0
208
+ });
209
+ a == null || a.add(f);
210
+ const w = () => {
211
+ if (!g || !a)
212
+ return;
213
+ const h = new z.Text(g(), {
214
+ fill: "#FFFFFF",
215
+ fontSize: 12,
216
+ selectable: !1,
217
+ top: 4,
218
+ left: 8
219
+ }), T = new z.Rect({
220
+ selectable: !1,
221
+ strokeWidth: 0,
222
+ fill: `rgb(${m},${s},${p})`,
223
+ rx: 2,
224
+ ry: 2,
225
+ width: (h.width || 0) + 16,
226
+ height: (h.height || 0) + 8,
227
+ left: 0,
228
+ top: 0
229
+ });
230
+ return new z.Group([T, h], {
231
+ selectable: !1,
232
+ // lockScalingX: false,
233
+ // lockScalingY: false,
234
+ scaleX: 1 / a.getZoom(),
235
+ scaleY: 1 / a.getZoom()
236
+ });
237
+ };
238
+ let X;
239
+ const e = () => {
240
+ var h, T;
241
+ if (!(!f || !g || !a)) {
242
+ if (X || (X = w(), I()), X.canvas === a) {
243
+ const P = X.getObjects().find((k) => k.type === "rect"), Z = X.getObjects().find((k) => k.type === "text");
244
+ if (Z && g) {
245
+ Z.set({
246
+ text: g(),
247
+ left: 8
248
+ // fontSize: this.scaledNumber(12),
249
+ });
250
+ const k = (Z.getBoundingRect().width || 0) + 16;
251
+ P == null || P.set({
252
+ fill: `rgba(${m},${s}, ${p}, 1)`,
253
+ width: k,
254
+ left: -k / 2
255
+ }), Z.set({
256
+ left: -k / 2 + 8
257
+ });
258
+ const D = ((h = f.aCoords) == null ? void 0 : h.tl.x) !== void 0 ? (T = f.aCoords) == null ? void 0 : T.tl.x : void 0;
259
+ X.set({
260
+ left: D,
261
+ width: k
262
+ });
263
+ }
264
+ } else
265
+ a == null || a.add(X);
266
+ I();
267
+ }
268
+ }, I = () => {
269
+ var D, C, L, W;
270
+ if (!f || !X || !a)
271
+ return;
272
+ const h = X.getObjects().find((_) => _.type === "rect");
273
+ if (!h)
274
+ return;
275
+ const T = h.height ? h.height : void 0, P = h.width ? h.width : void 0, Z = ((D = f.aCoords) == null ? void 0 : D.tl.y) !== void 0 && T !== void 0 && h.scaleY ? ((C = f.aCoords) == null ? void 0 : C.tl.y) - T / a.getZoom() : void 0, k = ((L = f.aCoords) == null ? void 0 : L.tl.x) !== void 0 ? (W = f.aCoords) == null ? void 0 : W.tl.x : void 0;
276
+ X.set({
277
+ top: Z,
278
+ left: k,
279
+ height: T,
280
+ width: P,
281
+ scaleX: 1 / a.getZoom(),
282
+ scaleY: 1 / a.getZoom()
283
+ });
284
+ };
285
+ return e(), [f, X];
286
+ }, He = (r, m, s, p) => {
287
+ if (!r) {
288
+ console.error("canvas is not exist");
289
+ return;
290
+ }
291
+ try {
292
+ r.remove(m), p && r.remove(p), s.canvas !== r && r.add(s);
293
+ } catch (a) {
294
+ console.error(a);
295
+ }
296
+ }, ut = (r) => {
297
+ const {
298
+ imageUrl: m,
299
+ canvasElement: s,
300
+ labels: p = [],
301
+ onChange: a,
302
+ disabled: g,
303
+ renderLabelItem: f
304
+ } = r, [w, X] = U(!0), [e, I] = U(), [h, T] = U({}), [P, Z] = U({}), [k, D] = U(), [C, L] = U({
305
+ left: 0,
306
+ top: 0
307
+ }), [W, _] = U([1, 1]), [b, q] = U(), [d, J] = U(null), [oe, V] = U(), [y, l] = U([]), [u, x] = U(!0), [B, R] = U(), [O, j] = U("rect"), [G, N] = U(g || !1);
308
+ F(() => {
309
+ var i;
310
+ y.forEach((n) => {
311
+ p.find((t) => t.uuid === n.uuid) || e == null || e.remove(h[n.uuid]);
312
+ }), l((i = p == null ? void 0 : p.filter((n) => !!n)) == null ? void 0 : i.map((n) => {
313
+ var M, A;
314
+ const v = n, {
315
+ uuid: t,
316
+ box: o,
317
+ words: c,
318
+ type: Y,
319
+ catagoryId: E
320
+ } = v, $ = ge(v, [
321
+ "uuid",
322
+ "box",
323
+ "words",
324
+ "type",
325
+ "catagoryId"
326
+ ]);
327
+ return Q({
328
+ uuid: n.uuid,
329
+ box: ((M = n.box) == null ? void 0 : M.map((H) => [H[0] + C.left, H[1] + C.top])) || [],
330
+ words: n.words,
331
+ type: (A = n.type) == null ? void 0 : A.toLowerCase(),
332
+ catagoryId: n.catagoryId
333
+ }, $);
334
+ }));
335
+ }, [p, C]), F(() => {
336
+ if (e && u) {
337
+ const i = e.getActiveObject();
338
+ if (i) {
339
+ i === (b == null ? void 0 : b.polygon) && (e == null || e.remove(b == null ? void 0 : b.text), q(void 0)), e.remove(i), e.renderAll();
340
+ const n = y.findIndex((t) => h[t.uuid] === i);
341
+ n > -1 && (h[y[n].uuid] && (e == null || e.remove(h[y[n].uuid])), y.splice(n, 1), l([...y]), a([...y.map((t) => re(Q({}, t), {
342
+ box: t.box.map((o) => [o[0] - C.left, o[1] - C.top])
343
+ }))]));
344
+ } else
345
+ console.log("no active object", e.selection), e.discardActiveObject(), e.requestRenderAll();
346
+ x(!1);
347
+ }
348
+ }, [e, u, y]);
349
+ const te = (i) => {
350
+ var n;
351
+ ((n = i.target) == null ? void 0 : n.tagName) !== "INPUT" && x(!0);
352
+ };
353
+ le("Delete", te), le("Backspace", te), le("ctrl", () => {
354
+ N(!0);
355
+ }, {
356
+ events: ["keydown"]
357
+ }), le("ctrl", () => {
358
+ N(!1);
359
+ }, {
360
+ events: ["keyup"]
361
+ });
362
+ const K = () => {
363
+ T({}), Z({}), D(void 0), _([1, 1]), q(void 0), V(void 0), J(null), l([]), L({
364
+ left: 0,
365
+ top: 0
366
+ }), e == null || e.dispose(), I(void 0);
367
+ };
368
+ F(() => {
369
+ X(!0), K(), !(!s || !m) && z.Image.fromURL(m, (i) => {
370
+ i.set({
371
+ originX: "center",
372
+ originY: "center"
373
+ }), D(i), X(!1);
374
+ }, {
375
+ crossOrigin: "anonymous"
376
+ });
377
+ }, [s, m]), F(() => {
378
+ var H;
379
+ if (!s || !s.parentElement)
380
+ return;
381
+ if (!k && e) {
382
+ e.clear();
383
+ return;
384
+ }
385
+ const i = k == null ? void 0 : k.getElement();
386
+ if (!(i != null && i.width) || !(i != null && i.height))
387
+ return;
388
+ const n = i.width / i.height, t = s.parentElement.offsetWidth, o = s.parentElement.offsetHeight, c = t / i.width, Y = o / i.height;
389
+ let E = [t, o];
390
+ c > Y ? E = [o * n, o] : E = [t, t / n];
391
+ const $ = E[0] / i.width, v = E[1] / i.height, M = Math.min($, v);
392
+ _([M, M]);
393
+ const A = new z.Canvas(s, {
394
+ containerClass: "marking-canvas",
395
+ width: t,
396
+ height: o
397
+ });
398
+ if (A == null || A.setZoom(M), A == null || A.renderAll(), A && k) {
399
+ const ne = (t - E[0]) / M / 2, ae = (o - E[1]) / M / 2;
400
+ A.setBackgroundImage(
401
+ k,
402
+ A.renderAll.bind(A),
403
+ // 刷新画布
404
+ {
405
+ originX: "left",
406
+ originY: "top",
407
+ left: ne,
408
+ top: ae
409
+ }
410
+ ), L({
411
+ left: ne,
412
+ top: ae
413
+ }), J(null), l((H = p == null ? void 0 : p.filter((ee) => !!ee)) == null ? void 0 : H.map((ee) => {
414
+ var xe, we;
415
+ const ye = ee, {
416
+ uuid: qe,
417
+ box: Ge,
418
+ words: Ke,
419
+ type: _e,
420
+ catagoryId: Je
421
+ } = ye, Oe = ge(ye, [
422
+ "uuid",
423
+ "box",
424
+ "words",
425
+ "type",
426
+ "catagoryId"
427
+ ]);
428
+ return Q({
429
+ uuid: ee.uuid,
430
+ box: ((xe = ee.box) == null ? void 0 : xe.map((be) => [be[0] + C.left, be[1] + C.top])) || [],
431
+ words: ee.words,
432
+ type: (we = ee.type) == null ? void 0 : we.toLowerCase(),
433
+ catagoryId: ee.catagoryId
434
+ }, Oe);
435
+ })), I(A);
436
+ }
437
+ }, [k]), F(() => {
438
+ w || !e || (ue(e, y, oe), N((i) => (i ? e.getObjects().forEach((n) => n.set("evented", !1)) : e.getObjects().forEach((n) => n.set("evented", !0)), i)));
439
+ }, [y, e, oe, w]), F(() => {
440
+ oe || a([...y.map((i) => re(Q({}, i), {
441
+ box: i.box.map((n) => [n[0] - C.left, n[1] - C.top])
442
+ }))]);
443
+ }, [oe]);
444
+ const ue = (i, n, t = "") => {
445
+ T((o) => {
446
+ if (n == null || n.map((c) => {
447
+ var $, v;
448
+ const [Y, E] = je(($ = c.box) == null ? void 0 : $.map((M) => ({
449
+ x: M[0],
450
+ y: M[1]
451
+ })), ((v = c.type) == null ? void 0 : v.toLowerCase()) === "key" ? [255, 193, 0] : [80, 139, 238], i, f ? () => (console.log(c), f(c)) : void 0);
452
+ o[c.uuid] ? He(i, o[c.uuid], Y, P[c.uuid]) : Y.canvas !== i && (i.add(Y), i.add(E)), o[c.uuid] = Y, T(() => o), P[c.uuid] = E, Z(() => P);
453
+ }), t && (!d || d !== i.getActiveObject()))
454
+ try {
455
+ i == null || i.setActiveObject(o[t]), J(o[t]);
456
+ } catch (c) {
457
+ J(null), console.error(c);
458
+ }
459
+ return o;
460
+ });
461
+ };
462
+ F(() => {
463
+ const n = document.createElement("img");
464
+ n.src = Fe, n.setAttribute("style", "background: rgba(0, 0, 0, 0.45)");
465
+ function t(c, Y, E, $, v) {
466
+ c.save(), c.translate(Y, E), c.rotate(z.util.degreesToRadians(v.angle)), c.beginPath(), c.arc(0, 0, 12, 0, 2 * Math.PI), c.fillStyle = "rgba(0, 0, 0, 0.45)", c.fill(), c.strokeStyle = "rgba(0, 0, 0, 0)", c.stroke(), c.drawImage(n, -24 / 2, -24 / 2, 24, 24), c.restore();
467
+ }
468
+ const o = (c, Y, E, $) => {
469
+ var M;
470
+ const v = Y.target;
471
+ if (v) {
472
+ v === (b == null ? void 0 : b.polygon) && q(void 0), e == null || e.remove(v), e == null || e.renderAll();
473
+ const A = y.findIndex((H) => h[H.uuid].left === v.left && h[H.uuid].top === v.top);
474
+ console.log(e), A > -1 && (h[y[A].uuid] && (e == null || e.remove(h[y[A].uuid]), (M = P[y[A].uuid]) == null || M.remove()), y.splice(A, 1), a([...y.map((H) => re(Q({}, H), {
475
+ box: H.box.map((ne) => [ne[0] - C.left, ne[1] - C.top])
476
+ }))]));
477
+ }
478
+ return !1;
479
+ };
480
+ z.Object.prototype.controls.deleteControl = new z.Control({
481
+ x: 0.5,
482
+ y: -0.5,
483
+ offsetX: 16,
484
+ cursorStyle: "pointer",
485
+ mouseUpHandler: o,
486
+ render: t,
487
+ sizeX: 24,
488
+ sizeY: 24
489
+ });
490
+ }, [d, e]), F(() => {
491
+ var i;
492
+ if (w && s && !B) {
493
+ const n = document.createElement("div");
494
+ n.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (i = s.parentElement) == null || i.appendChild(n), Me.render(/* @__PURE__ */ S($e, {}), n), R(n);
495
+ } else
496
+ !w && B && (B.remove(), R(null));
497
+ }, [w, s, B]), F(() => {
498
+ var i, n;
499
+ b && (l([...y, {
500
+ uuid: b.uuid,
501
+ box: ((i = b.polygon.points) == null ? void 0 : i.map((t) => [t.x, t.y])) || [],
502
+ words: b.value || ""
503
+ }]), a([...y.map((t) => re(Q({}, t), {
504
+ box: t.box.map((o) => [o[0] - C.left, o[1] - C.top])
505
+ })), {
506
+ uuid: b.uuid,
507
+ box: ((n = b.polygon.points) == null ? void 0 : n.map((t) => [t.x - C.left, t.y - C.top])) || [],
508
+ words: b.value || ""
509
+ }]), e == null || e.remove(b.text), e == null || e.remove(b.polygon), q(void 0), V(b.uuid));
510
+ }, [b]);
511
+ const Be = () => {
512
+ let i = !1;
513
+ e && (e.on("mouse:down", (n) => {
514
+ i = !0, e.selection = !1;
515
+ }), e.on("mouse:move", (n) => {
516
+ if (i && n && n.e) {
517
+ const t = new z.Point(n.e.movementX, n.e.movementY);
518
+ e.relativePan(t);
519
+ }
520
+ }), e.on("mouse:up", (n) => {
521
+ i = !1, e.selection = !0;
522
+ }));
523
+ };
524
+ F(() => {
525
+ if (w && e && (ue(e, []), e.renderAll()), w || !e)
526
+ return;
527
+ if (ue(e, []), e.renderAll(), de(e), G) {
528
+ Be(), e.defaultCursor = "grab", e.on("mouse:down", () => e.setCursor("grabbing")), e.on("mouse:up", () => e.setCursor("grab")), console.log("evented", !1, e.getObjects()), e.getObjects().forEach((c) => c.set("evented", !1));
529
+ return;
530
+ }
531
+ console.log("evented", !0, e.getObjects()), e.getObjects().forEach((c) => c.set("evented", !0)), e.defaultCursor = "default", e.setCursor("default");
532
+ const i = (c, Y) => {
533
+ b && (e == null || e.remove(b.text), e == null || e.remove(b.polygon)), q({
534
+ polygon: c,
535
+ text: Y,
536
+ uuid: Te()
537
+ });
538
+ };
539
+ O === "rect" ? Se(e, i) : O === "quadri" && pe(e, i, 4);
540
+ const n = (c) => {
541
+ var E;
542
+ J(e.getActiveObject());
543
+ const Y = e.getActiveObject();
544
+ Y == null || Y.set({
545
+ borderColor: "#508BEE",
546
+ cornerColor: "white",
547
+ cornerSize: 7,
548
+ transparentCorners: !1,
549
+ cornerStrokeColor: "#508BEE"
550
+ }), (E = Object.keys(h)) == null || E.map(($) => {
551
+ Y === h[$] && V($);
552
+ });
553
+ }, t = (c) => {
554
+ var E;
555
+ de(e), J(e.getActiveObject());
556
+ const Y = e.getActiveObject();
557
+ (E = Object.keys(h)) == null || E.map(($) => {
558
+ Y === h[$] && V($);
559
+ });
560
+ }, o = () => {
561
+ J(null), V(void 0);
562
+ };
563
+ return e.on("selection:created", n), e.on("selection:updated", t), e.on("selection:cleared", o), () => {
564
+ e.off("selection:created", n), e.off("selection:updated", t), e.off("selection:cleared", o), e.off("mouse:down"), e.off("mouse:up"), e.off("mouse:move");
565
+ };
566
+ }, [e, O, G]), F(() => {
567
+ if (e)
568
+ return e.on("mouse:wheel", (i) => {
569
+ const n = i.e.deltaY;
570
+ ce(n, {
571
+ x: i.e.offsetX,
572
+ y: i.e.offsetY
573
+ });
574
+ }), () => {
575
+ e == null || e.off("mouse:wheel");
576
+ };
577
+ }, [e]), F(() => {
578
+ if (e)
579
+ return d == null || d.on("mousedown", () => {
580
+ e && de(e);
581
+ }), d == null || d.on("mouseup:before", () => {
582
+ var n;
583
+ if (!e)
584
+ return;
585
+ const i = d;
586
+ (n = Object.keys(h)) == null || n.map((t) => {
587
+ if (i === h[t]) {
588
+ const o = y.findIndex((c) => c.uuid === t);
589
+ if (o > -1) {
590
+ const c = Pe(i);
591
+ y[o].box = (c == null ? void 0 : c.map((Y) => [Y.x, Y.y])) || [];
592
+ }
593
+ }
594
+ }), l([...y]), a([...y.map((t) => re(Q({}, t), {
595
+ box: t.box.map((o) => [o[0] - C.left < 1e-11 ? 0 : o[0] - C.left, o[1] - C.top < 1e-11 ? 0 : o[1] - C.top])
596
+ }))]);
597
+ }), d == null || d.on("moving", (i) => {
598
+ var t;
599
+ if (!e)
600
+ return;
601
+ const n = d;
602
+ e.getZoom(), (t = Object.keys(h)) == null || t.map((o) => {
603
+ if (n === h[o]) {
604
+ const c = y.findIndex((E) => E.uuid === o), Y = Pe(n);
605
+ y[c].box = (Y == null ? void 0 : Y.map((E) => [E.x, E.y])) || [];
606
+ }
607
+ });
608
+ }), () => {
609
+ d == null || d.off("mousedown"), d == null || d.off("mouseup:before"), d == null || d.off("moving");
610
+ };
611
+ }, [d, y, O]), F(() => {
612
+ if (e) {
613
+ if (!d) {
614
+ const i = (n, t) => {
615
+ b && (e == null || e.remove(b.text), e == null || e.remove(b.polygon)), q({
616
+ polygon: n,
617
+ text: t,
618
+ uuid: Te()
619
+ });
620
+ };
621
+ de(e), O === "rect" ? Se(e, i) : O === "quadri" && pe(e, i, 4);
622
+ }
623
+ d == null || d.on("moving", ie), d == null || d.on("scaling", ie), d == null || d.on("rotating", ie), d == null || d.on("skewing", ie), d == null || d.on("resizing", ie);
624
+ }
625
+ }, [d]);
626
+ const ie = (i) => {
627
+ Ze(i);
628
+ }, Ze = (i) => {
629
+ if (!e)
630
+ return;
631
+ const n = i.transform.action;
632
+ i.transform.corner;
633
+ const t = i.transform.target, o = i.transform.target.canvas.backgroundImage;
634
+ i.transform.original, o && (t.top < o.top && t.set({
635
+ top: o.top
636
+ }), t.left < o.left && t.set({
637
+ left: o.left
638
+ }), (n === "drag" || n === "rotate") && (t.top + t.height > o.top + o.height && t.set({
639
+ top: o.height + o.top - t.height * t.scaleY
640
+ }), t.left + t.width > o.left + o.width && t.set({
641
+ left: o.width + o.left - t.width * t.scaleX
642
+ })), n === "rotate" && (t.aCoords.bl.x < o.left && t.set({
643
+ left: t.left + (o.left - t.aCoords.bl.x)
644
+ }), t.aCoords.tr.y < o.top && t.set({
645
+ top: t.top + (o.top - t.aCoords.tr.y)
646
+ }), t.aCoords.br.x > o.left + o.width && t.set({
647
+ left: t.left - (t.aCoords.br.x - (o.left + o.width))
648
+ }), t.aCoords.br.y > o.top + o.height && t.set({
649
+ top: t.top - (t.aCoords.br.y - (o.top + o.height))
650
+ })), n === "scale" && (t.top + t.height * t.scaleY > o.top + o.height && t.set({
651
+ top: t.height * t.scaleY > o.height ? o.top : o.top + o.height - t.height * t.scaleY,
652
+ height: t.height * t.scaleY > o.height ? o.height : t.height
653
+ }), t.left + t.width * t.scaleX > o.left + o.width && t.set({
654
+ left: o.width + o.left - t.width * t.scaleX
655
+ })), n === "scaleX" && (t.left + t.width * t.scaleX > o.left + o.width && t.set({
656
+ left: t.left - (t.left + t.width * t.scaleX - (o.left + o.width))
657
+ }), t.left < o.left && t.set({
658
+ left: o.left
659
+ })), n === "scaleY" && (t.top + t.height * t.scaleY > o.top + o.height && t.set({
660
+ top: t.top - (t.top + t.height * t.scaleY - (o.top + o.height))
661
+ }), t.top < o.top && t.set({
662
+ top: o.top
663
+ })), t.width * t.scaleX >= o.width && t.set({
664
+ left: o.left,
665
+ width: o.width / t.scaleX
666
+ }), t.height * t.scaleY >= o.height && t.set({
667
+ top: o.top,
668
+ height: o.height / t.scaleY
669
+ })), e.renderAll();
670
+ }, ce = (i, n) => {
671
+ if (!e)
672
+ return;
673
+ n || (n = {
674
+ x: e.getCenter().left,
675
+ y: e.getCenter().top
676
+ });
677
+ let t = e.getZoom();
678
+ t *= Ee(0.999, i), t > 20 && (t = 20), t < 0.01 && (t = 0.01), e.zoomToPoint(
679
+ n,
680
+ t
681
+ // 传入修改后的缩放级别
682
+ );
683
+ }, De = () => {
684
+ N(!G);
685
+ };
686
+ return F(() => {
687
+ N(g || !1);
688
+ }, [g]), /* @__PURE__ */ S("div", {
689
+ className: "marker-toolbar",
690
+ children: /* @__PURE__ */ S("div", {
691
+ className: "create-mode-select",
692
+ children: /* @__PURE__ */ Xe(Ie, {
693
+ direction: "vertical",
694
+ size: 16,
695
+ children: [!g && /* @__PURE__ */ S(me.Group, {
696
+ value: O,
697
+ buttonStyle: "solid",
698
+ onChange: (i) => j(i.target.value),
699
+ children: /* @__PURE__ */ Xe(Ie, {
700
+ direction: "vertical",
701
+ size: 16,
702
+ children: [/* @__PURE__ */ S(se, {
703
+ title: "矩形标注",
704
+ placement: "right",
705
+ children: /* @__PURE__ */ S(me.Button, {
706
+ value: "rect",
707
+ type: "icon",
708
+ children: /* @__PURE__ */ S(Ae, {
709
+ type: "icon-biaozhu-juxingkuang"
710
+ })
711
+ })
712
+ }), /* @__PURE__ */ S(se, {
713
+ title: "四边形标注",
714
+ placement: "right",
715
+ children: /* @__PURE__ */ S(me.Button, {
716
+ value: "quadri",
717
+ children: /* @__PURE__ */ S(Ae, {
718
+ type: "icon-biaozhu-sibianxing"
719
+ })
720
+ })
721
+ })]
722
+ })
723
+ }), /* @__PURE__ */ S(se, {
724
+ title: "放大-鼠标滚轮前滑",
725
+ placement: "right",
726
+ children: /* @__PURE__ */ S(he, {
727
+ icon: /* @__PURE__ */ S(Ne, {}),
728
+ onClick: () => {
729
+ ce(-100);
730
+ }
731
+ })
732
+ }), /* @__PURE__ */ S(se, {
733
+ title: "缩小-鼠标滚轮后滑",
734
+ placement: "right",
735
+ children: /* @__PURE__ */ S(he, {
736
+ icon: /* @__PURE__ */ S(Le, {}),
737
+ onClick: () => {
738
+ ce(100);
739
+ }
740
+ })
741
+ }), !g && /* @__PURE__ */ S(se, {
742
+ title: "拖动-按住ctrl",
743
+ placement: "right",
744
+ children: /* @__PURE__ */ S(he, {
745
+ icon: /* @__PURE__ */ S(We, {}),
746
+ className: G ? "active" : "",
747
+ onClick: De
748
+ })
749
+ })]
750
+ })
751
+ })
752
+ });
753
+ };
754
+ export {
755
+ ut as default
756
+ };