@labelbee/lb-annotation 1.14.0-alpha.3 → 1.14.0-alpha.6

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 (189) hide show
  1. package/dist/_virtual/MathUtilsWorker.js +1 -8
  2. package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -35
  3. package/dist/_virtual/filterBoxWorker.js +1 -8
  4. package/dist/_virtual/highlightWorker.js +1 -8
  5. package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -5
  6. package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -5
  7. package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -5
  8. package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -5
  9. package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -5
  10. package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -5
  11. package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -5
  12. package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -5
  13. package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -5
  14. package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -5
  15. package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
  16. package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -5
  17. package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -5
  18. package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -5
  19. package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +12 -5
  20. package/dist/assets/attributeIcon/icon_editFEN.svg.js +1 -5
  21. package/dist/assets/attributeIcon/icon_editHUANG.svg.js +1 -5
  22. package/dist/assets/attributeIcon/icon_editLAN.svg.js +1 -5
  23. package/dist/assets/attributeIcon/icon_editLV.svg.js +1 -5
  24. package/dist/assets/attributeIcon/icon_editQING.svg.js +1 -5
  25. package/dist/constant/annotation.js +1 -127
  26. package/dist/constant/annotationTask.js +1 -30
  27. package/dist/constant/defaultConfig.js +1 -266
  28. package/dist/constant/keyCode.js +1 -38
  29. package/dist/constant/style.js +1 -98
  30. package/dist/constant/tool.js +1 -236
  31. package/dist/core/index.js +1 -150
  32. package/dist/core/pointCloud/OrbitControls.js +1 -665
  33. package/dist/core/pointCloud/PCDLoader.js +2 -260
  34. package/dist/core/pointCloud/annotation.js +1 -215
  35. package/dist/core/pointCloud/cache.js +1 -53
  36. package/dist/core/pointCloud/index.js +5 -991
  37. package/dist/core/pointCloud/matrix.js +1 -138
  38. package/dist/core/scheduler.js +1 -233
  39. package/dist/core/toolOperation/LineToolOperation.js +1 -1434
  40. package/dist/core/toolOperation/ScribbleTool.js +1 -292
  41. package/dist/core/toolOperation/TextToolOperation.js +1 -131
  42. package/dist/core/toolOperation/ViewOperation.js +1 -556
  43. package/dist/core/toolOperation/basicToolOperation.js +1 -881
  44. package/dist/core/toolOperation/checkOperation.js +1 -208
  45. package/dist/core/toolOperation/cuboidOperation.js +1 -754
  46. package/dist/core/toolOperation/cuboidToggleButtonClass.js +7 -152
  47. package/dist/core/toolOperation/eventListener.js +1 -37
  48. package/dist/core/toolOperation/measureOperation.js +1 -41
  49. package/dist/core/toolOperation/pointCloud2dOperation.js +1 -365
  50. package/dist/core/toolOperation/pointOperation.js +1 -696
  51. package/dist/core/toolOperation/polygonOperation.js +1 -1251
  52. package/dist/core/toolOperation/rectOperation.js +1 -1233
  53. package/dist/core/toolOperation/segmentByRect.js +1 -174
  54. package/dist/core/toolOperation/tagOperation.js +3 -201
  55. package/dist/core/toolOperation/textAttributeClass.js +16 -182
  56. package/dist/index.js +1 -185
  57. package/dist/locales/constants.js +1 -24
  58. package/dist/locales/en_US/message.js +1 -25
  59. package/dist/locales/index.js +1 -19
  60. package/dist/locales/zh_CN/message.js +1 -25
  61. package/dist/newCore/CanvasScheduler.js +1 -35
  62. package/dist/types/core/pointCloud/index.d.ts +2 -2
  63. package/dist/utils/ActionsHistory.js +1 -84
  64. package/dist/utils/ImgUtils.js +1 -23
  65. package/dist/utils/MathUtils.js +2 -385
  66. package/dist/utils/VectorUtils.js +1 -25
  67. package/dist/utils/tool/AttributeUtils.js +1 -218
  68. package/dist/utils/tool/AxisUtils.js +1 -340
  69. package/dist/utils/tool/CanvasUtils.js +1 -62
  70. package/dist/utils/tool/CommonToolUtils.js +1 -174
  71. package/dist/utils/tool/CuboidUtils.js +1 -704
  72. package/dist/utils/tool/DblClickEventListener.js +1 -102
  73. package/dist/utils/tool/DrawUtils.js +3 -492
  74. package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -53
  75. package/dist/utils/tool/ImgPosUtils.js +1 -58
  76. package/dist/utils/tool/LineToolUtils.js +1 -261
  77. package/dist/utils/tool/MarkerUtils.js +1 -56
  78. package/dist/utils/tool/PolygonUtils.js +1 -460
  79. package/dist/utils/tool/RectUtils.js +1 -155
  80. package/dist/utils/tool/RenderDomClass.js +7 -57
  81. package/dist/utils/tool/RenderDomUtils.js +4 -21
  82. package/dist/utils/tool/StyleUtils.js +1 -31
  83. package/dist/utils/tool/TagUtils.js +1 -129
  84. package/dist/utils/tool/UnitUtils.js +1 -12
  85. package/dist/utils/tool/ZoomUtils.js +1 -72
  86. package/dist/utils/tool/polygonTool.js +1 -133
  87. package/dist/utils/uuid.js +1 -26
  88. package/es/_virtual/MathUtilsWorker.js +1 -6
  89. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -31
  90. package/es/_virtual/filterBoxWorker.js +1 -6
  91. package/es/_virtual/highlightWorker.js +1 -6
  92. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -3
  93. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -3
  94. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -3
  95. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -3
  96. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -3
  97. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -3
  98. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -3
  99. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -3
  100. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -3
  101. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -3
  102. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -3
  103. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -3
  104. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -3
  105. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -3
  106. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -3
  107. package/es/assets/attributeIcon/icon_editFEN.svg.js +1 -3
  108. package/es/assets/attributeIcon/icon_editHUANG.svg.js +1 -3
  109. package/es/assets/attributeIcon/icon_editLAN.svg.js +1 -3
  110. package/es/assets/attributeIcon/icon_editLV.svg.js +1 -3
  111. package/es/assets/attributeIcon/icon_editQING.svg.js +1 -3
  112. package/es/constant/annotation.js +1 -113
  113. package/es/constant/annotationTask.js +1 -25
  114. package/es/constant/defaultConfig.js +1 -260
  115. package/es/constant/keyCode.js +1 -36
  116. package/es/constant/style.js +1 -74
  117. package/es/constant/tool.js +1 -220
  118. package/es/core/index.js +1 -148
  119. package/es/core/pointCloud/OrbitControls.js +1 -661
  120. package/es/core/pointCloud/PCDLoader.js +2 -256
  121. package/es/core/pointCloud/annotation.js +1 -211
  122. package/es/core/pointCloud/cache.js +1 -49
  123. package/es/core/pointCloud/index.js +5 -962
  124. package/es/core/pointCloud/matrix.js +1 -109
  125. package/es/core/scheduler.js +1 -228
  126. package/es/core/toolOperation/LineToolOperation.js +1 -1421
  127. package/es/core/toolOperation/ScribbleTool.js +1 -290
  128. package/es/core/toolOperation/TextToolOperation.js +1 -129
  129. package/es/core/toolOperation/ViewOperation.js +1 -549
  130. package/es/core/toolOperation/basicToolOperation.js +1 -877
  131. package/es/core/toolOperation/checkOperation.js +1 -206
  132. package/es/core/toolOperation/cuboidOperation.js +1 -752
  133. package/es/core/toolOperation/cuboidToggleButtonClass.js +7 -150
  134. package/es/core/toolOperation/eventListener.js +1 -35
  135. package/es/core/toolOperation/measureOperation.js +1 -39
  136. package/es/core/toolOperation/pointCloud2dOperation.js +1 -359
  137. package/es/core/toolOperation/pointOperation.js +1 -690
  138. package/es/core/toolOperation/polygonOperation.js +1 -1245
  139. package/es/core/toolOperation/rectOperation.js +1 -1228
  140. package/es/core/toolOperation/segmentByRect.js +1 -172
  141. package/es/core/toolOperation/tagOperation.js +3 -199
  142. package/es/core/toolOperation/textAttributeClass.js +16 -180
  143. package/es/index.js +1 -46
  144. package/es/locales/constants.js +1 -22
  145. package/es/locales/en_US/message.js +1 -23
  146. package/es/locales/index.js +1 -17
  147. package/es/locales/zh_CN/message.js +1 -23
  148. package/es/newCore/CanvasScheduler.js +1 -31
  149. package/es/utils/ActionsHistory.js +1 -78
  150. package/es/utils/ImgUtils.js +1 -21
  151. package/es/utils/MathUtils.js +2 -380
  152. package/es/utils/VectorUtils.js +1 -23
  153. package/es/utils/tool/AttributeUtils.js +1 -212
  154. package/es/utils/tool/AxisUtils.js +1 -335
  155. package/es/utils/tool/CanvasUtils.js +1 -60
  156. package/es/utils/tool/CommonToolUtils.js +1 -172
  157. package/es/utils/tool/CuboidUtils.js +1 -680
  158. package/es/utils/tool/DblClickEventListener.js +1 -100
  159. package/es/utils/tool/DrawUtils.js +3 -490
  160. package/es/utils/tool/EnhanceCommonToolUtils.js +1 -48
  161. package/es/utils/tool/ImgPosUtils.js +1 -56
  162. package/es/utils/tool/LineToolUtils.js +1 -255
  163. package/es/utils/tool/MarkerUtils.js +1 -54
  164. package/es/utils/tool/PolygonUtils.js +1 -458
  165. package/es/utils/tool/RectUtils.js +1 -153
  166. package/es/utils/tool/RenderDomClass.js +7 -55
  167. package/es/utils/tool/RenderDomUtils.js +4 -19
  168. package/es/utils/tool/StyleUtils.js +1 -29
  169. package/es/utils/tool/TagUtils.js +1 -127
  170. package/es/utils/tool/UnitUtils.js +1 -10
  171. package/es/utils/tool/ZoomUtils.js +1 -70
  172. package/es/utils/tool/polygonTool.js +1 -126
  173. package/es/utils/uuid.js +1 -24
  174. package/package.json +3 -4
  175. package/LICENSE +0 -203
  176. package/dist/core/pointCloud/segmentation.js +0 -144
  177. package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +0 -26
  178. package/dist/core/pointCloud/selector/Sse3dSelector.js +0 -16
  179. package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
  180. package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
  181. package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
  182. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -12
  183. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -7
  184. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
  185. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -18
  186. package/es/core/pointCloud/segmentation.js +0 -120
  187. package/es/core/pointCloud/selector/Sse3dLassoSelector.js +0 -24
  188. package/es/core/pointCloud/selector/Sse3dSelector.js +0 -14
  189. package/es/core/toolOperation/scribbleTool2.js +0 -249
@@ -1,385 +1,2 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var MathUtilsWorker = require('../_virtual/MathUtilsWorker.js');
6
- var tool = require('../constant/tool.js');
7
- var polygonTool = require('./tool/polygonTool.js');
8
- var PolygonUtils = require('./tool/PolygonUtils.js');
9
- var VectorUtils = require('./VectorUtils.js');
10
-
11
- var __defProp = Object.defineProperty;
12
- var __defProps = Object.defineProperties;
13
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
14
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
17
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
18
- var __spreadValues = (a, b) => {
19
- for (var prop in b || (b = {}))
20
- if (__hasOwnProp.call(b, prop))
21
- __defNormalProp(a, prop, b[prop]);
22
- if (__getOwnPropSymbols)
23
- for (var prop of __getOwnPropSymbols(b)) {
24
- if (__propIsEnum.call(b, prop))
25
- __defNormalProp(a, prop, b[prop]);
26
- }
27
- return a;
28
- };
29
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
30
- class Trigonometric {
31
- static tanAPlusB(tanA, tanB) {
32
- return (tanA + tanB) / (1 - tanA * tanB);
33
- }
34
- static sinAPlusB(sinA, cosA, sinB, cosB) {
35
- return cosB * sinA + cosA * sinB;
36
- }
37
- static cosAPlusB(sinA, cosA, sinB, cosB) {
38
- return cosA * cosB - sinA * sinB;
39
- }
40
- }
41
- const _MathUtils = class {
42
- static getRotate(rotate) {
43
- if (rotate + 90 >= 360) {
44
- return rotate + 90 - 360;
45
- }
46
- return rotate + 90;
47
- }
48
- static getLineLength(point1, point2) {
49
- return Math.sqrt(Math.pow(point2.y - point1.y, 2) + Math.pow(point2.x - point1.x, 2));
50
- }
51
- static getTextArea(canvas, text, maxWidth = tool.DEFAULT_TEXT_MAX_WIDTH, font = tool.DEFAULT_FONT, lineHeight) {
52
- if (typeof text !== "string") {
53
- return {
54
- width: 0,
55
- height: 0
56
- };
57
- }
58
- const context = canvas.getContext("2d");
59
- context.font = font;
60
- let height = 0;
61
- if (typeof lineHeight === "undefined") {
62
- lineHeight = canvas && parseInt(window.getComputedStyle(canvas).lineHeight, 10) || parseInt(window.getComputedStyle(document.body).lineHeight, 10);
63
- }
64
- const fontHeight = canvas && parseInt(window.getComputedStyle(canvas).fontSize, 10) || parseInt(window.getComputedStyle(document.body).fontSize, 10) || 0;
65
- const arrParagraph = text.split("\n");
66
- let lineWidth = 0;
67
- for (let i = 0; i < arrParagraph.length; i++) {
68
- const arrText = arrParagraph[i].split("");
69
- let line = "";
70
- for (let n = 0; n < arrText.length; n++) {
71
- const testLine = line + arrText[n];
72
- const metrics = context.measureText(testLine);
73
- const textWidth = metrics.width;
74
- if (textWidth > maxWidth && n > 0) {
75
- line = arrText[n];
76
- height += lineHeight;
77
- lineWidth = maxWidth;
78
- } else {
79
- line = testLine;
80
- if (textWidth > lineWidth) {
81
- lineWidth = textWidth;
82
- }
83
- }
84
- }
85
- if (i !== arrParagraph.length - 1) {
86
- height += lineHeight;
87
- }
88
- }
89
- return {
90
- width: lineWidth,
91
- height: height + fontHeight,
92
- lineHeight,
93
- fontHeight
94
- };
95
- }
96
- static getLineCenterPoint(line) {
97
- const [p1, p2] = line;
98
- const vector = VectorUtils.getVector(p1, p2);
99
- return {
100
- x: p1.x + vector.x / 2,
101
- y: p1.y + vector.y / 2
102
- };
103
- }
104
- static getPerpendicularLine(line) {
105
- if (line.length !== 2) {
106
- return void 0;
107
- }
108
- const [p1, p2] = line;
109
- const p3 = {
110
- x: p2.x + p2.y - p1.y,
111
- y: p2.y - (p2.x - p1.x)
112
- };
113
- return [p2, p3];
114
- }
115
- static getPerpendicularFootOfLine(line, coordinate) {
116
- if (line.length !== 2) {
117
- return line;
118
- }
119
- const perpendicularLine = this.getPerpendicularLine(line);
120
- if (!perpendicularLine) {
121
- return line;
122
- }
123
- const [begin, end] = perpendicularLine;
124
- return this.getFootOfPerpendicular(coordinate, begin, end).footPoint;
125
- }
126
- static getQuadrangleFromTriangle(triangle) {
127
- if (triangle.length !== 3) {
128
- return triangle;
129
- }
130
- const [p1, p2, p3] = triangle;
131
- const p4 = {
132
- x: p3.x + p1.x - p2.x,
133
- y: p3.y + p1.y - p2.y
134
- };
135
- return [p1, p2, p3, p4];
136
- }
137
- static getRectPerpendicularOffset(dragStartCoord, currentCoord, basicLine) {
138
- const [p1, p2] = basicLine;
139
- const footer1 = this.getFootOfPerpendicular(dragStartCoord, p1, p2).footPoint;
140
- const footer2 = this.getFootOfPerpendicular(currentCoord, p1, p2).footPoint;
141
- const offset = {
142
- x: footer1.x - footer2.x,
143
- y: footer1.y - footer2.y
144
- };
145
- const newPoint = VectorUtils.add(currentCoord, offset);
146
- const vector3 = VectorUtils.getVector(dragStartCoord, newPoint);
147
- return vector3;
148
- }
149
- static getArrayIndex(index, len) {
150
- if (index < 0) {
151
- return len + index;
152
- }
153
- if (index >= len) {
154
- return index - len;
155
- }
156
- return index;
157
- }
158
- static getPointListFromPointOffset(pointList, changePointIndex, offset) {
159
- const prePointIndex = this.getArrayIndex(changePointIndex - 1, pointList.length);
160
- const nextPointIndex = this.getArrayIndex(changePointIndex + 1, pointList.length);
161
- const originIndex = this.getArrayIndex(changePointIndex - 2, pointList.length);
162
- const newPointList = [...pointList];
163
- newPointList[changePointIndex] = VectorUtils.add(newPointList[changePointIndex], offset);
164
- const newFooter1 = this.getFootOfPerpendicular(newPointList[changePointIndex], newPointList[originIndex], newPointList[prePointIndex]).footPoint;
165
- const newFooter2 = this.getFootOfPerpendicular(newPointList[changePointIndex], newPointList[nextPointIndex], newPointList[originIndex]).footPoint;
166
- newPointList[prePointIndex] = newFooter1;
167
- newPointList[nextPointIndex] = newFooter2;
168
- return newPointList;
169
- }
170
- static getRectCenterPoint(rectPointList) {
171
- const [p1, , p3] = rectPointList;
172
- return {
173
- x: (p1.x + p3.x) / 2,
174
- y: (p1.y + p3.y) / 2
175
- };
176
- }
177
- static rotateRectPointList(angle = 5, rectPointList) {
178
- const centerPoint = this.getRectCenterPoint(rectPointList);
179
- const {PI} = Math;
180
- const sinB = Math.sin(angle * PI / 180);
181
- const cosB = Math.cos(angle * PI / 180);
182
- return rectPointList.map((point) => {
183
- const vector = VectorUtils.getVector(centerPoint, point);
184
- const len = VectorUtils.len(vector);
185
- const sinA = vector.y / len;
186
- const cosA = vector.x / len;
187
- return {
188
- x: len * Trigonometric.cosAPlusB(sinA, cosA, sinB, cosB) + centerPoint.x,
189
- y: len * Trigonometric.sinAPlusB(sinA, cosA, sinB, cosB) + centerPoint.y
190
- };
191
- });
192
- }
193
- static getRectangleByRightAngle(coordinate, pointList) {
194
- if (pointList.length !== 2) {
195
- return pointList;
196
- }
197
- const newPoint = _MathUtils.getPerpendicularFootOfLine(pointList, coordinate);
198
- return _MathUtils.getQuadrangleFromTriangle([...pointList, newPoint]);
199
- }
200
- static getRadiusFromQuadrangle(points) {
201
- const [, point2, point3] = points;
202
- const y = point3.y - point2.y;
203
- const x = point2.x - point3.x;
204
- const len = this.getLineLength(point2, point3);
205
- const cosX = y / len;
206
- const radius = Math.acos(cosX);
207
- if (x > 0) {
208
- return Math.PI * 2 - radius;
209
- }
210
- return radius;
211
- }
212
- static getCollectionPointByAnnotationDataPromise(annotations) {
213
- const points = annotations.filter((v) => v.type === "point").map((v) => v.annotation);
214
- const backgroundList = annotations.filter((v) => {
215
- if (["polygon", "line"].includes(v.type)) {
216
- return true;
217
- }
218
- return false;
219
- }).map((v) => {
220
- if (v.type === "polygon") {
221
- return __spreadProps(__spreadValues({}, v.annotation), {
222
- pointList: PolygonUtils.concatBeginAndEnd(v.annotation.pointList)
223
- });
224
- }
225
- return v.annotation;
226
- });
227
- const mathUtilsWorker = new MathUtilsWorker();
228
- return {
229
- promise: new Promise(function collectionPromise(resolve) {
230
- mathUtilsWorker.postMessage({points, backgroundList});
231
- mathUtilsWorker.onmessage = (e) => {
232
- resolve(e.data);
233
- mathUtilsWorker.terminate();
234
- };
235
- }),
236
- close: () => {
237
- mathUtilsWorker.terminate();
238
- }
239
- };
240
- }
241
- static getCollectionPointByAnnotationData(annotations) {
242
- const connectionPoints = [];
243
- const cacheSet = new Set();
244
- const points = annotations.filter((v) => v.type === "point").map((v) => v.annotation);
245
- const backgroundList = annotations.filter((v) => {
246
- if (["polygon", "line"].includes(v.type)) {
247
- return true;
248
- }
249
- return false;
250
- }).map((v) => {
251
- if (v.type === "polygon") {
252
- return __spreadProps(__spreadValues({}, v.annotation), {
253
- pointList: PolygonUtils.concatBeginAndEnd(v.annotation.pointList)
254
- });
255
- }
256
- return v.annotation;
257
- });
258
- const judgeIsConnectPoint = (point, polygonList) => {
259
- const {dropFoot} = PolygonUtils.getClosestPoint(point, polygonList, tool.ELineTypes.Line, 1, {isClose: false});
260
- if (dropFoot !== point) {
261
- const s = `${dropFoot.x} + ${dropFoot.y}`;
262
- if (!cacheSet.has(s)) {
263
- connectionPoints.push(point);
264
- }
265
- cacheSet.add(s);
266
- }
267
- };
268
- points.forEach((point) => {
269
- judgeIsConnectPoint(point, backgroundList);
270
- });
271
- backgroundList.forEach((v) => {
272
- let traverseID = "";
273
- traverseID = v.id;
274
- backgroundList.forEach((annotation, i) => {
275
- if (annotation.id === traverseID) {
276
- return;
277
- }
278
- const newPolygonList = [...backgroundList];
279
- newPolygonList.splice(i, 1);
280
- annotation.pointList.forEach((point) => {
281
- judgeIsConnectPoint(point, newPolygonList);
282
- });
283
- });
284
- });
285
- return {connectionPoints};
286
- }
287
- };
288
- let MathUtils = _MathUtils;
289
- MathUtils.isInRange = (value, range) => {
290
- const min = Math.min(...range);
291
- const max = Math.max(...range);
292
- const inRange = (v) => v <= max && v >= min;
293
- const values = Array.isArray(value) ? value : [value];
294
- return values.every((v) => inRange(v));
295
- };
296
- MathUtils.withinRange = (value, range) => {
297
- const min = Math.min(...range);
298
- const max = Math.max(...range);
299
- if (value > max) {
300
- return max;
301
- }
302
- if (value < min) {
303
- return min;
304
- }
305
- return value;
306
- };
307
- MathUtils.calcViewportBoundaries = (array, isCurve = false, numberOfSegments = tool.SEGMENT_NUMBER, zoom = 1) => {
308
- if (!array) {
309
- return {
310
- top: 0,
311
- bottom: 0,
312
- left: 0,
313
- right: 0
314
- };
315
- }
316
- const MIN_LENGTH = 20 / zoom;
317
- const xAxis = [];
318
- const yAxis = [];
319
- let points = array;
320
- if (isCurve) {
321
- points = polygonTool.createSmoothCurvePointsFromPointList(array, numberOfSegments);
322
- }
323
- points.forEach(({x, y}) => {
324
- xAxis.push(x);
325
- yAxis.push(y);
326
- });
327
- let minX = Math.min(...xAxis);
328
- let maxX = Math.max(...xAxis);
329
- let minY = Math.min(...yAxis);
330
- let maxY = Math.max(...yAxis);
331
- const diffX = maxX - minX;
332
- const diffY = maxY - minY;
333
- if (diffX < MIN_LENGTH) {
334
- const addLen = (MIN_LENGTH - diffX) / 2;
335
- minX -= addLen;
336
- maxX += addLen;
337
- }
338
- if (diffY < MIN_LENGTH) {
339
- const addLen = (MIN_LENGTH - diffY) / 2;
340
- minY -= addLen;
341
- maxY += addLen;
342
- }
343
- return {
344
- top: minY,
345
- bottom: maxY,
346
- left: minX,
347
- right: maxX
348
- };
349
- };
350
- MathUtils.getFootOfPerpendicular = (pt, begin, end, useAxisRange = false, allowOverRange = false) => {
351
- let retVal = {x: 0, y: 0};
352
- const dx = begin.x - end.x;
353
- const dy = begin.y - end.y;
354
- if (Math.abs(dx) < 1e-8 && Math.abs(dy) < 1e-8) {
355
- retVal = begin;
356
- return retVal;
357
- }
358
- let u = (pt.x - begin.x) * (begin.x - end.x) + (pt.y - begin.y) * (begin.y - end.y);
359
- u /= dx * dx + dy * dy;
360
- retVal.x = begin.x + u * dx;
361
- retVal.y = begin.y + u * dy;
362
- const length = _MathUtils.getLineLength(pt, retVal);
363
- const ratio = 2;
364
- const fromX = Math.min(begin.x, end.x);
365
- const toX = Math.max(begin.x, end.x);
366
- const fromY = Math.min(begin.y, end.y);
367
- const toY = Math.max(begin.y, end.y);
368
- const allAxisOverRange = !(_MathUtils.isInRange(pt.x, [fromX, toX]) || _MathUtils.isInRange(pt.y, [fromY, toY]));
369
- const someAxisOverRange = pt.x > toX + ratio || pt.x < fromX - ratio || pt.y > toY + ratio || pt.y < fromY - ratio;
370
- const isOverRange = useAxisRange ? allAxisOverRange : someAxisOverRange;
371
- if (!allowOverRange && isOverRange) {
372
- return {
373
- footPoint: retVal,
374
- length: Infinity
375
- };
376
- }
377
- return {
378
- footPoint: retVal,
379
- length
380
- };
381
- };
382
- var MathUtils$1 = MathUtils;
383
-
384
- exports.Trigonometric = Trigonometric;
385
- exports["default"] = MathUtils$1;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var MathUtilsWorker=require("../_virtual/MathUtilsWorker.js"),tool=require("../constant/tool.js"),polygonTool=require("./tool/polygonTool.js"),PolygonUtils=require("./tool/PolygonUtils.js"),VectorUtils=require("./VectorUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__spreadValues=(e,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(e,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(e,o,t[o]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));class Trigonometric{static tanAPlusB(t,o){return(t+o)/(1-t*o)}static sinAPlusB(t,o,s,r){return r*t+o*s}static cosAPlusB(t,o,s,r){return o*r-t*s}}const _MathUtils=class{static getRotate(e){return e+90>=360?e+90-360:e+90}static getLineLength(e,t){return Math.sqrt(Math.pow(t.y-e.y,2)+Math.pow(t.x-e.x,2))}static getTextArea(e,t,o=tool.DEFAULT_TEXT_MAX_WIDTH,s=tool.DEFAULT_FONT,r){if(typeof t!="string")return{width:0,height:0};const i=e.getContext("2d");i.font=s;let n=0;typeof r=="undefined"&&(r=e&&parseInt(window.getComputedStyle(e).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const a=e&&parseInt(window.getComputedStyle(e).fontSize,10)||parseInt(window.getComputedStyle(document.body).fontSize,10)||0,c=t.split(`
2
+ `);let l=0;for(let u=0;u<c.length;u++){const p=c[u].split("");let g="";for(let y=0;y<p.length;y++){const f=g+p[y],h=i.measureText(f).width;h>o&&y>0?(g=p[y],n+=r,l=o):(g=f,h>l&&(l=h))}u!==c.length-1&&(n+=r)}return{width:l,height:n+a,lineHeight:r,fontHeight:a}}static getLineCenterPoint(e){const[t,o]=e,s=VectorUtils.getVector(t,o);return{x:t.x+s.x/2,y:t.y+s.y/2}}static getPerpendicularLine(e){if(e.length!==2)return;const[t,o]=e,s={x:o.x+o.y-t.y,y:o.y-(o.x-t.x)};return[o,s]}static getPerpendicularFootOfLine(e,t){if(e.length!==2)return e;const o=this.getPerpendicularLine(e);if(!o)return e;const[s,r]=o;return this.getFootOfPerpendicular(t,s,r).footPoint}static getQuadrangleFromTriangle(e){if(e.length!==3)return e;const[t,o,s]=e,r={x:s.x+t.x-o.x,y:s.y+t.y-o.y};return[t,o,s,r]}static getRectPerpendicularOffset(e,t,o){const[s,r]=o,i=this.getFootOfPerpendicular(e,s,r).footPoint,n=this.getFootOfPerpendicular(t,s,r).footPoint,a={x:i.x-n.x,y:i.y-n.y},c=VectorUtils.add(t,a);return VectorUtils.getVector(e,c)}static getArrayIndex(e,t){return e<0?t+e:e>=t?e-t:e}static getPointListFromPointOffset(e,t,o){const s=this.getArrayIndex(t-1,e.length),r=this.getArrayIndex(t+1,e.length),i=this.getArrayIndex(t-2,e.length),n=[...e];n[t]=VectorUtils.add(n[t],o);const a=this.getFootOfPerpendicular(n[t],n[i],n[s]).footPoint,c=this.getFootOfPerpendicular(n[t],n[r],n[i]).footPoint;return n[s]=a,n[r]=c,n}static getRectCenterPoint(e){const[t,,o]=e;return{x:(t.x+o.x)/2,y:(t.y+o.y)/2}}static rotateRectPointList(e=5,t){const o=this.getRectCenterPoint(t),{PI:s}=Math,r=Math.sin(e*s/180),i=Math.cos(e*s/180);return t.map(n=>{const a=VectorUtils.getVector(o,n),c=VectorUtils.len(a),l=a.y/c,u=a.x/c;return{x:c*Trigonometric.cosAPlusB(l,u,r,i)+o.x,y:c*Trigonometric.sinAPlusB(l,u,r,i)+o.y}})}static getRectangleByRightAngle(e,t){if(t.length!==2)return t;const o=_MathUtils.getPerpendicularFootOfLine(t,e);return _MathUtils.getQuadrangleFromTriangle([...t,o])}static getRadiusFromQuadrangle(e){const[,t,o]=e,s=o.y-t.y,r=t.x-o.x,i=this.getLineLength(t,o),n=s/i,a=Math.acos(n);return r>0?Math.PI*2-a:a}static getCollectionPointByAnnotationDataPromise(e){const t=e.filter(r=>r.type==="point").map(r=>r.annotation),o=e.filter(r=>!!["polygon","line"].includes(r.type)).map(r=>r.type==="polygon"?__spreadProps(__spreadValues({},r.annotation),{pointList:PolygonUtils.concatBeginAndEnd(r.annotation.pointList)}):r.annotation),s=new MathUtilsWorker;return{promise:new Promise(function(i){s.postMessage({points:t,backgroundList:o}),s.onmessage=n=>{i(n.data),s.terminate()}}),close:()=>{s.terminate()}}}static getCollectionPointByAnnotationData(e){const t=[],o=new Set,s=e.filter(n=>n.type==="point").map(n=>n.annotation),r=e.filter(n=>!!["polygon","line"].includes(n.type)).map(n=>n.type==="polygon"?__spreadProps(__spreadValues({},n.annotation),{pointList:PolygonUtils.concatBeginAndEnd(n.annotation.pointList)}):n.annotation),i=(n,a)=>{const{dropFoot:c}=PolygonUtils.getClosestPoint(n,a,tool.ELineTypes.Line,1,{isClose:!1});if(c!==n){const l=`${c.x} + ${c.y}`;o.has(l)||t.push(n),o.add(l)}};return s.forEach(n=>{i(n,r)}),r.forEach(n=>{let a="";a=n.id,r.forEach((c,l)=>{if(c.id===a)return;const u=[...r];u.splice(l,1),c.pointList.forEach(p=>{i(p,u)})})}),{connectionPoints:t}}};let MathUtils=_MathUtils;MathUtils.isInRange=(e,t)=>{const o=Math.min(...t),s=Math.max(...t),r=n=>n<=s&&n>=o;return(Array.isArray(e)?e:[e]).every(n=>r(n))},MathUtils.withinRange=(e,t)=>{const o=Math.min(...t),s=Math.max(...t);return e>s?s:e<o?o:e},MathUtils.calcViewportBoundaries=(e,t=!1,o=tool.SEGMENT_NUMBER,s=1)=>{if(!e)return{top:0,bottom:0,left:0,right:0};const r=20/s,i=[],n=[];let a=e;t&&(a=polygonTool.createSmoothCurvePointsFromPointList(e,o)),a.forEach(({x:f,y:d})=>{i.push(f),n.push(d)});let c=Math.min(...i),l=Math.max(...i),u=Math.min(...n),p=Math.max(...n);const g=l-c,y=p-u;if(g<r){const f=(r-g)/2;c-=f,l+=f}if(y<r){const f=(r-y)/2;u-=f,p+=f}return{top:u,bottom:p,left:c,right:l}},MathUtils.getFootOfPerpendicular=(e,t,o,s=!1,r=!1)=>{let i={x:0,y:0};const n=t.x-o.x,a=t.y-o.y;if(Math.abs(n)<1e-8&&Math.abs(a)<1e-8)return i=t,i;let c=(e.x-t.x)*(t.x-o.x)+(e.y-t.y)*(t.y-o.y);c/=n*n+a*a,i.x=t.x+c*n,i.y=t.y+c*a;const l=_MathUtils.getLineLength(e,i),u=2,p=Math.min(t.x,o.x),g=Math.max(t.x,o.x),y=Math.min(t.y,o.y),f=Math.max(t.y,o.y),d=!(_MathUtils.isInRange(e.x,[p,g])||_MathUtils.isInRange(e.y,[y,f])),h=e.x>g+u||e.x<p-u||e.y>f+u||e.y<y-u;return!r&&(s?d:h)?{footPoint:i,length:Infinity}:{footPoint:i,length:l}};var MathUtils$1=MathUtils;exports.Trigonometric=Trigonometric,exports.default=MathUtils$1;
@@ -1,25 +1 @@
1
- 'use strict';
2
-
3
- var __pow = Math.pow;
4
- class Vector {
5
- static add(vector1, vector2) {
6
- return {
7
- x: vector1.x + vector2.x,
8
- y: vector1.y + vector2.y
9
- };
10
- }
11
- static getVector(point1, point2) {
12
- return {
13
- x: point2.x - point1.x,
14
- y: point2.y - point1.y
15
- };
16
- }
17
- static len(vector) {
18
- return Math.sqrt(__pow(vector.x, 2) + __pow(vector.y, 2));
19
- }
20
- static dotProduct(vector1, vector2) {
21
- return vector1.x * vector2.x + vector1.y + vector2.y;
22
- }
23
- }
24
-
25
- module.exports = Vector;
1
+ "use strict";var __pow=Math.pow;class Vector{static add(t,r){return{x:t.x+r.x,y:t.y+r.y}}static getVector(t,r){return{x:r.x-t.x,y:r.y-t.y}}static len(t){return Math.sqrt(__pow(t.x,2)+__pow(t.y,2))}static dotProduct(t,r){return t.x*r.x+t.y+r.y}}module.exports=Vector;
@@ -1,218 +1 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _ = require('lodash');
6
- var lbUtils = require('@labelbee/lb-utils');
7
- var style = require('../../constant/style.js');
8
- var tool = require('../../constant/tool.js');
9
- var index = require('../../locales/index.js');
10
- var constants = require('../../locales/constants.js');
11
- var MathUtils = require('../MathUtils.js');
12
- var icon_canvasEdit_miss = require('../../assets/attributeIcon/icon_canvasEdit_miss.svg.js');
13
-
14
- var __defProp = Object.defineProperty;
15
- var __defProps = Object.defineProperties;
16
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
17
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
18
- var __hasOwnProp = Object.prototype.hasOwnProperty;
19
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
20
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
21
- var __spreadValues = (a, b) => {
22
- for (var prop in b || (b = {}))
23
- if (__hasOwnProp.call(b, prop))
24
- __defNormalProp(a, prop, b[prop]);
25
- if (__getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(b)) {
27
- if (__propIsEnum.call(b, prop))
28
- __defNormalProp(a, prop, b[prop]);
29
- }
30
- return a;
31
- };
32
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
33
- const REGEXP_NUMBER = "^[0-9]+$";
34
- const REGEXP_ENGLISH = "^[A-Za-z]+$";
35
- class AttributeUtils {
36
- static getAttributeIcon(attribute, attributeList, valid = true) {
37
- var _a;
38
- const attributeIndex = attributeList.findIndex((i) => i.value === attribute);
39
- let src = (_a = style.ICON_ARRAY[attributeIndex % style.ICON_ARRAY.length]) != null ? _a : style.NULL_ICON;
40
- if (!valid) {
41
- src = icon_canvasEdit_miss;
42
- }
43
- src = "";
44
- const img = new Image();
45
- img.src = src;
46
- return img;
47
- }
48
- static checkString(textCheckType, customFormat) {
49
- let regExpString = "";
50
- switch (textCheckType) {
51
- case tool.ETextType.Order:
52
- case tool.ETextType.NumberOnly:
53
- regExpString = REGEXP_NUMBER;
54
- break;
55
- case tool.ETextType.EnglishOnly:
56
- regExpString = REGEXP_ENGLISH;
57
- break;
58
- case tool.ETextType.CustomFormat:
59
- regExpString = customFormat;
60
- break;
61
- }
62
- return regExpString;
63
- }
64
- static checkTextAttibute(value, checkStrings) {
65
- if (value === void 0 || value === "") {
66
- return true;
67
- }
68
- try {
69
- return new RegExp(checkStrings).test(value);
70
- } catch (error) {
71
- return false;
72
- }
73
- }
74
- static getAttributeShowText(attribute, attributeList = []) {
75
- var _a, _b;
76
- try {
77
- const attributeIndex = attributeList.findIndex((i) => i.value === attribute);
78
- return (_b = (_a = attributeList[attributeIndex]) == null ? void 0 : _a.key) != null ? _b : attribute;
79
- } catch (error) {
80
- return attribute;
81
- }
82
- }
83
- static getAttributeIndex(attribute, attributeList) {
84
- try {
85
- const attributeIndex = attributeList.findIndex((i) => i.value === attribute);
86
- if (attributeIndex >= 8) {
87
- return attributeIndex % 8;
88
- }
89
- return attributeIndex;
90
- } catch (error) {
91
- return -1;
92
- }
93
- }
94
- static getAttributeColor(attribute, attributeList) {
95
- try {
96
- const attributeIndex = this.getAttributeIndex(attribute, attributeList);
97
- if (attributeIndex === -1) {
98
- return style.NULL_COLOR;
99
- }
100
- return style.COLORS_ARRAY[attributeIndex % style.COLORS_ARRAY.length];
101
- } catch (error) {
102
- return style.NULL_COLOR;
103
- }
104
- }
105
- static getTextAttribute(toolResultList, textCheckType) {
106
- try {
107
- if (textCheckType === tool.ETextType.Order) {
108
- const textAttributeList = toolResultList.map((i) => parseInt(i.textAttribute, 10)).filter((order) => {
109
- return _.isNumber(order) && order < Number.MAX_SAFE_INTEGER && order >= 0;
110
- });
111
- textAttributeList.sort((a, b) => a - b);
112
- const maxOrder = textAttributeList.pop();
113
- return `${(maxOrder || 0) + 1}`;
114
- }
115
- return "";
116
- } catch (error) {
117
- return "";
118
- }
119
- }
120
- static textChange(value, selectedID, toolList) {
121
- return toolList.map((item) => {
122
- if (item.id === selectedID) {
123
- return __spreadProps(__spreadValues({}, item), {
124
- textAttribute: value
125
- });
126
- }
127
- return item;
128
- });
129
- }
130
- static getErrorNotice(textCheckType, lang) {
131
- switch (textCheckType) {
132
- case tool.ETextType.Order:
133
- case tool.ETextType.NumberOnly:
134
- return index.getMessagesByLocale(constants.EMessage.TextCheckNumberErrorNotice, lang);
135
- case tool.ETextType.EnglishOnly:
136
- return index.getMessagesByLocale(constants.EMessage.TextCheckEnglishErrorNotice, lang);
137
- case tool.ETextType.CustomFormat:
138
- return index.getMessagesByLocale(constants.EMessage.TextCheckCustomErrorNotice, lang);
139
- default:
140
- return "";
141
- }
142
- }
143
- static textAttributeValidate(textCheckType, customFormat, text) {
144
- try {
145
- const reg = new RegExp(this.checkString(textCheckType, customFormat));
146
- return reg.test(text);
147
- } catch (error) {
148
- }
149
- }
150
- static checkTextAttribute(textCheckType, customFormat, resultList, selectedID) {
151
- let error = false;
152
- resultList.forEach((item) => {
153
- if ((item == null ? void 0 : item.textAttribute) === void 0 || (item == null ? void 0 : item.textAttribute) === "") {
154
- return;
155
- }
156
- if ((selectedID ? item.id === selectedID : true) && !this.textAttributeValidate(textCheckType, customFormat, item.textAttribute)) {
157
- error = true;
158
- }
159
- });
160
- if (error) {
161
- return true;
162
- }
163
- return false;
164
- }
165
- static changeTextAttributeInLog(toolLog, toolList) {
166
- return toolLog == null ? void 0 : toolLog.map((item) => {
167
- return item == null ? void 0 : item.map((info) => {
168
- if ((toolList == null ? void 0 : toolList.findIndex((i) => (i == null ? void 0 : i.id) === (info == null ? void 0 : info.id))) > -1) {
169
- const changeRect = toolList == null ? void 0 : toolList.find((i) => (i == null ? void 0 : i.id) === (info == null ? void 0 : info.id));
170
- return __spreadProps(__spreadValues({}, info), {
171
- textAttribute: changeRect == null ? void 0 : changeRect.textAttribute
172
- });
173
- }
174
- return info;
175
- });
176
- });
177
- }
178
- static getTextIconSvg(attribute = "", attributeList, attributeConfigurable = false, baseIcon) {
179
- var _a;
180
- if (attributeConfigurable === true) {
181
- const attributeIndex = (attributeList == null ? void 0 : attributeList.findIndex((i) => (i == null ? void 0 : i.value) === attribute)) % style.COLORS_ARRAY.length + 1;
182
- const color = (_a = attributeList == null ? void 0 : attributeList.find((i) => i.value === attribute)) == null ? void 0 : _a.color;
183
- if (color) {
184
- const getHexColor = lbUtils.ToolStyleUtils.rgbaStringToHex(color);
185
- return this.generateIconAttribute({fill: getHexColor});
186
- }
187
- return style.ICON_ARRAY[attributeIndex];
188
- }
189
- return baseIcon;
190
- }
191
- static generateIconAttribute({
192
- fill,
193
- width = 16,
194
- height = 16,
195
- xmlns = "http://www.w3.org/2000/svg",
196
- xlink = "http://www.w3.org/1999/xlink"
197
- }) {
198
- return `<span style={color:${fill}}><svg xmlns=${xmlns} xmlns:xlink=${xlink} width=${width} height=${height} viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill='currentColor'/></g></g></svg></span>`;
199
- }
200
- static getAttributeByKeycode(keyCode, attributeList) {
201
- var _a;
202
- let num;
203
- if (MathUtils["default"].isInRange(keyCode, [48, 57])) {
204
- num = keyCode - 48;
205
- }
206
- if (MathUtils["default"].isInRange(keyCode, [96, 105])) {
207
- num = keyCode - 96;
208
- }
209
- if (num === 0) {
210
- return "";
211
- }
212
- return num ? (_a = attributeList[num - 1]) == null ? void 0 : _a.value : void 0;
213
- }
214
- }
215
-
216
- exports.REGEXP_ENGLISH = REGEXP_ENGLISH;
217
- exports.REGEXP_NUMBER = REGEXP_NUMBER;
218
- exports["default"] = AttributeUtils;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),lbUtils=require("@labelbee/lb-utils"),style=require("../../constant/style.js"),tool=require("../../constant/tool.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),MathUtils=require("../MathUtils.js"),icon_canvasEdit_miss=require("../../assets/attributeIcon/icon_canvasEdit_miss.svg.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(s,t,e)=>t in s?__defProp(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,__spreadValues=(s,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(s,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(s,e,t[e]);return s},__spreadProps=(s,t)=>__defProps(s,__getOwnPropDescs(t));const REGEXP_NUMBER="^[0-9]+$",REGEXP_ENGLISH="^[A-Za-z]+$";class AttributeUtils{static getAttributeIcon(t,e,r=!0){var n;const a=e.findIndex(l=>l.value===t);let i=(n=style.ICON_ARRAY[a%style.ICON_ARRAY.length])!=null?n:style.NULL_ICON;r||(i=icon_canvasEdit_miss),i="";const u=new Image;return u.src=i,u}static checkString(t,e){let r="";switch(t){case tool.ETextType.Order:case tool.ETextType.NumberOnly:r=REGEXP_NUMBER;break;case tool.ETextType.EnglishOnly:r=REGEXP_ENGLISH;break;case tool.ETextType.CustomFormat:r=e;break}return r}static checkTextAttibute(t,e){if(t===void 0||t==="")return!0;try{return new RegExp(e).test(t)}catch(r){return!1}}static getAttributeShowText(t,e=[]){var r,n;try{const a=e.findIndex(i=>i.value===t);return(n=(r=e[a])==null?void 0:r.key)!=null?n:t}catch(a){return t}}static getAttributeIndex(t,e){try{const r=e.findIndex(n=>n.value===t);return r>=8?r%8:r}catch(r){return-1}}static getAttributeColor(t,e){try{const r=this.getAttributeIndex(t,e);return r===-1?style.NULL_COLOR:style.COLORS_ARRAY[r%style.COLORS_ARRAY.length]}catch(r){return style.NULL_COLOR}}static getTextAttribute(t,e){try{if(e===tool.ETextType.Order){const r=t.map(a=>parseInt(a.textAttribute,10)).filter(a=>_.isNumber(a)&&a<Number.MAX_SAFE_INTEGER&&a>=0);return r.sort((a,i)=>a-i),`${(r.pop()||0)+1}`}return""}catch(r){return""}}static textChange(t,e,r){return r.map(n=>n.id===e?__spreadProps(__spreadValues({},n),{textAttribute:t}):n)}static getErrorNotice(t,e){switch(t){case tool.ETextType.Order:case tool.ETextType.NumberOnly:return index.getMessagesByLocale(constants.EMessage.TextCheckNumberErrorNotice,e);case tool.ETextType.EnglishOnly:return index.getMessagesByLocale(constants.EMessage.TextCheckEnglishErrorNotice,e);case tool.ETextType.CustomFormat:return index.getMessagesByLocale(constants.EMessage.TextCheckCustomErrorNotice,e);default:return""}}static textAttributeValidate(t,e,r){try{return new RegExp(this.checkString(t,e)).test(r)}catch(n){}}static checkTextAttribute(t,e,r,n){let a=!1;return r.forEach(i=>{(i==null?void 0:i.textAttribute)===void 0||(i==null?void 0:i.textAttribute)===""||(n?i.id===n:!0)&&!this.textAttributeValidate(t,e,i.textAttribute)&&(a=!0)}),!!a}static changeTextAttributeInLog(t,e){return t==null?void 0:t.map(r=>r==null?void 0:r.map(n=>{if((e==null?void 0:e.findIndex(a=>(a==null?void 0:a.id)===(n==null?void 0:n.id)))>-1){const a=e==null?void 0:e.find(i=>(i==null?void 0:i.id)===(n==null?void 0:n.id));return __spreadProps(__spreadValues({},n),{textAttribute:a==null?void 0:a.textAttribute})}return n}))}static getTextIconSvg(t="",e,r=!1,n){var a;if(r===!0){const i=(e==null?void 0:e.findIndex(l=>(l==null?void 0:l.value)===t))%style.COLORS_ARRAY.length+1,u=(a=e==null?void 0:e.find(l=>l.value===t))==null?void 0:a.color;if(u){const l=lbUtils.ToolStyleUtils.rgbaStringToHex(u);return this.generateIconAttribute({fill:l})}return style.ICON_ARRAY[i]}return n}static generateIconAttribute({fill:t,width:e=16,height:r=16,xmlns:n="http://www.w3.org/2000/svg",xlink:a="http://www.w3.org/1999/xlink"}){return`<span style={color:${t}}><svg xmlns=${n} xmlns:xlink=${a} width=${e} height=${r} viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill='currentColor'/></g></g></svg></span>`}static getAttributeByKeycode(t,e){var r;let n;return MathUtils.default.isInRange(t,[48,57])&&(n=t-48),MathUtils.default.isInRange(t,[96,105])&&(n=t-96),n===0?"":n?(r=e[n-1])==null?void 0:r.value:void 0}}exports.REGEXP_ENGLISH=REGEXP_ENGLISH,exports.REGEXP_NUMBER=REGEXP_NUMBER,exports.default=AttributeUtils;