luo-image-annotator 0.0.12 → 0.0.13

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,19 +1,19 @@
1
1
  var Jt = Object.defineProperty;
2
- var jt = (u, t, i) => t in u ? Jt(u, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : u[t] = i;
3
- var S = (u, t, i) => jt(u, typeof t != "symbol" ? t + "" : t, i);
4
- import { defineComponent as Z, ref as M, watchEffect as Yt, openBlock as y, createElementBlock as p, normalizeClass as W, computed as D, onMounted as Xt, watch as X, createElementVNode as g, toDisplayString as P, Fragment as B, renderList as U, normalizeStyle as O, createCommentVNode as T, createVNode as L, withModifiers as qt, createTextVNode as q, withDirectives as lt, vModelText as rt, createBlock as ft, nextTick as Gt } from "vue";
5
- const ct = (u, t) => Math.sqrt(Math.pow(u.x - t.x, 2) + Math.pow(u.y - t.y, 2)), Kt = (u, t) => {
2
+ var jt = (f, t, i) => t in f ? Jt(f, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : f[t] = i;
3
+ var S = (f, t, i) => jt(f, typeof t != "symbol" ? t + "" : t, i);
4
+ import { defineComponent as tt, ref as M, watchEffect as Yt, openBlock as y, createElementBlock as x, normalizeClass as J, computed as D, onMounted as Xt, watch as Y, createElementVNode as g, toDisplayString as P, Fragment as B, renderList as F, normalizeStyle as V, createCommentVNode as T, createVNode as L, withModifiers as qt, createTextVNode as K, withDirectives as lt, vModelText as rt, createBlock as yt, nextTick as Gt } from "vue";
5
+ const ct = (f, t) => Math.sqrt(Math.pow(f.x - t.x, 2) + Math.pow(f.y - t.y, 2)), Kt = (f, t) => {
6
6
  let i = !1;
7
- for (let e = 0, a = t.length - 1; e < t.length; a = e++) {
8
- const r = t[e].x, c = t[e].y, o = t[a].x, d = t[a].y;
9
- c > u.y != d > u.y && u.x < (o - r) * (u.y - c) / (d - c) + r && (i = !i);
7
+ for (let e = 0, o = t.length - 1; e < t.length; o = e++) {
8
+ const c = t[e].x, r = t[e].y, a = t[o].x, d = t[o].y;
9
+ r > f.y != d > f.y && f.x < (a - c) * (f.y - r) / (d - r) + c && (i = !i);
10
10
  }
11
11
  return i;
12
- }, yt = (u, t, i) => {
13
- const e = i * (Math.PI / 180), a = Math.cos(e), r = Math.sin(e), c = u.x - t.x, o = u.y - t.y;
12
+ }, pt = (f, t, i) => {
13
+ const e = i * (Math.PI / 180), o = Math.cos(e), c = Math.sin(e), r = f.x - t.x, a = f.y - t.y;
14
14
  return {
15
- x: t.x + (c * a - o * r),
16
- y: t.y + (c * r + o * a)
15
+ x: t.x + (r * o - a * c),
16
+ y: t.y + (r * c + a * o)
17
17
  };
18
18
  };
19
19
  class Zt {
@@ -89,8 +89,8 @@ class Zt {
89
89
  zoom(t) {
90
90
  const e = t > 0 ? this.scale * 1.1 : this.scale / 1.1;
91
91
  if (e < 0.1 || e > 10) return;
92
- const a = this.canvas.width / 2, r = this.canvas.height / 2, c = this.toImageCoords(a, r);
93
- this.scale = e, this.offset.x = a - c.x * this.scale, this.offset.y = r - c.y * this.scale, this.clampViewportOffset(), this.render();
92
+ const o = this.canvas.width / 2, c = this.canvas.height / 2, r = this.toImageCoords(o, c);
93
+ this.scale = e, this.offset.x = o - r.x * this.scale, this.offset.y = c - r.y * this.scale, this.clampViewportOffset(), this.render();
94
94
  }
95
95
  resize() {
96
96
  this.fitImageToCanvas(), this.render();
@@ -122,14 +122,14 @@ class Zt {
122
122
  if (t <= this.canvas.width)
123
123
  this.offset.x = (this.canvas.width - t) / 2;
124
124
  else {
125
- const e = this.canvas.width - t, a = 0;
126
- this.offset.x = Math.min(a, Math.max(e, this.offset.x));
125
+ const e = this.canvas.width - t, o = 0;
126
+ this.offset.x = Math.min(o, Math.max(e, this.offset.x));
127
127
  }
128
128
  if (i <= this.canvas.height)
129
129
  this.offset.y = (this.canvas.height - i) / 2;
130
130
  else {
131
- const e = this.canvas.height - i, a = 0;
132
- this.offset.y = Math.min(a, Math.max(e, this.offset.y));
131
+ const e = this.canvas.height - i, o = 0;
132
+ this.offset.y = Math.min(o, Math.max(e, this.offset.y));
133
133
  }
134
134
  }
135
135
  // --- 事件处理 ---
@@ -151,28 +151,28 @@ class Zt {
151
151
  }
152
152
  }
153
153
  handleMouseDown(t) {
154
- const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left, a = t.clientY - i.top, r = this.toImageCoords(e, a);
154
+ const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left, o = t.clientY - i.top, c = this.toImageCoords(e, o);
155
155
  if (this.canvas.style.cursor === "grab" || this.canvas.style.cursor === "grabbing") {
156
- this.isPanning = !0, this.panStartPoint = { x: e, y: a }, this.canvas.style.cursor = "grabbing";
156
+ this.isPanning = !0, this.panStartPoint = { x: e, y: o }, this.canvas.style.cursor = "grabbing";
157
157
  return;
158
158
  }
159
159
  if (this.interactionMode === "select" && this.activeAnnotation) {
160
- const d = this.getHitHandle(e, a, this.activeAnnotation);
160
+ const d = this.getHitHandle(e, o, this.activeAnnotation);
161
161
  if (d !== -100) {
162
- this.isDragging = !0, this.dragStartPoint = r, this.selectedHandleIndex = d, this.dragStartAnnotation = JSON.parse(JSON.stringify(this.activeAnnotation));
162
+ this.isDragging = !0, this.dragStartPoint = c, this.selectedHandleIndex = d, this.dragStartAnnotation = JSON.parse(JSON.stringify(this.activeAnnotation));
163
163
  return;
164
164
  }
165
165
  }
166
- const c = this.interactionMode === "select" ? this.getHitCategory(e, a) : null;
167
- if (c) {
168
- this.activeAnnotation = c, this.isDragging = !1, this.selectedHandleIndex = -1, this.emit("annotationChange", { action: "select", changedItem: c, imageUrl: this.imageUrl }), this.render();
166
+ const r = this.interactionMode === "select" ? this.getHitCategory(e, o) : null;
167
+ if (r) {
168
+ this.activeAnnotation = r, this.isDragging = !1, this.selectedHandleIndex = -1, this.emit("annotationChange", { action: "select", changedItem: r, imageUrl: this.imageUrl }), this.render();
169
169
  return;
170
170
  }
171
- const o = this.getHitAnnotation(r);
171
+ const a = this.getHitAnnotation(c);
172
172
  if (this.interactionMode === "select") {
173
- if (o) {
174
- if (!(this.visibleLabels.size > 0 && !this.visibleLabels.has(o.label))) {
175
- this.activeAnnotation = o, this.isDragging = !0, this.dragStartPoint = r, this.selectedHandleIndex = -1, this.dragStartAnnotation = JSON.parse(JSON.stringify(o)), this.emit("annotationChange", { action: "select", changedItem: o, imageUrl: this.imageUrl }), this.render();
173
+ if (a) {
174
+ if (!(this.visibleLabels.size > 0 && !this.visibleLabels.has(a.label))) {
175
+ this.activeAnnotation = a, this.isDragging = !0, this.dragStartPoint = c, this.selectedHandleIndex = -1, this.dragStartAnnotation = JSON.parse(JSON.stringify(a)), this.emit("annotationChange", { action: "select", changedItem: a, imageUrl: this.imageUrl }), this.render();
176
176
  return;
177
177
  }
178
178
  } else
@@ -182,42 +182,42 @@ class Zt {
182
182
  if (this.interactionMode === "draw") {
183
183
  if (this.isDrawing && this.currentTool === "polygon" && this.activeAnnotation) {
184
184
  const d = this.activeAnnotation.coordinates;
185
- if (d.points.length > 2 && ct(r, d.points[0]) < 20 / this.scale) {
185
+ if (d.points.length > 2 && ct(c, d.points[0]) < 20 / this.scale) {
186
186
  this.finishDrawing();
187
187
  return;
188
188
  }
189
- this.startDrawing(r);
189
+ this.startDrawing(c);
190
190
  return;
191
191
  }
192
192
  if (this.currentTool) {
193
193
  if (this.currentTool === "polygon" && !this.isDrawing) {
194
- this.startDrawing(r);
194
+ this.startDrawing(c);
195
195
  return;
196
196
  }
197
- this.startDrawing(r);
197
+ this.startDrawing(c);
198
198
  }
199
199
  return;
200
200
  }
201
201
  this.activeAnnotation = null, this.render();
202
202
  }
203
203
  handleMouseMove(t) {
204
- const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left, a = t.clientY - i.top, r = this.toImageCoords(e, a);
204
+ const i = this.canvas.getBoundingClientRect(), e = t.clientX - i.left, o = t.clientY - i.top, c = this.toImageCoords(e, o);
205
205
  if (this.isPanning && this.panStartPoint) {
206
- const c = e - this.panStartPoint.x, o = a - this.panStartPoint.y;
207
- this.offset.x += c, this.offset.y += o, this.clampViewportOffset(), this.panStartPoint = { x: e, y: a }, this.render();
206
+ const r = e - this.panStartPoint.x, a = o - this.panStartPoint.y;
207
+ this.offset.x += r, this.offset.y += a, this.clampViewportOffset(), this.panStartPoint = { x: e, y: o }, this.render();
208
208
  return;
209
209
  }
210
- if (this.lastMouseMovePoint = r, this.isDrawing) {
210
+ if (this.lastMouseMovePoint = c, this.isDrawing) {
211
211
  if (this.currentTool === "polygon" && this.activeAnnotation) {
212
- const c = this.activeAnnotation.coordinates;
213
- if (c.points.length > 2) {
214
- const o = c.points[0], d = ct(r, o);
212
+ const r = this.activeAnnotation.coordinates;
213
+ if (r.points.length > 2) {
214
+ const a = r.points[0], d = ct(c, a);
215
215
  this.isHoveringStartPoint = d < 20 / this.scale;
216
216
  } else
217
217
  this.isHoveringStartPoint = !1;
218
218
  }
219
- this.updateDrawing(r);
220
- } else this.isDragging && this.activeAnnotation && this.dragStartPoint ? this.updateDragging(r) : this.checkHover(e, a, r);
219
+ this.updateDrawing(c);
220
+ } else this.isDragging && this.activeAnnotation && this.dragStartPoint ? this.updateDragging(c) : this.checkHover(e, o, c);
221
221
  this.render();
222
222
  }
223
223
  handleMouseUp(t) {
@@ -242,8 +242,8 @@ class Zt {
242
242
  // 辅助函数:将 hex 转换为 rgba
243
243
  hexToRgba(t, i) {
244
244
  if (!t.startsWith("#")) return t;
245
- const e = parseInt(t.slice(1, 3), 16), a = parseInt(t.slice(3, 5), 16), r = parseInt(t.slice(5, 7), 16);
246
- return `rgba(${e}, ${a}, ${r}, ${i})`;
245
+ const e = parseInt(t.slice(1, 3), 16), o = parseInt(t.slice(3, 5), 16), c = parseInt(t.slice(5, 7), 16);
246
+ return `rgba(${e}, ${o}, ${c}, ${i})`;
247
247
  }
248
248
  startDrawing(t) {
249
249
  if (!this.currentTool) return;
@@ -299,8 +299,8 @@ class Zt {
299
299
  const i = this.activeAnnotation.coordinates;
300
300
  i.x2 = t.x, i.y2 = t.y;
301
301
  } else if (this.activeAnnotation.type === "rotatedRect" && this.dragStartPoint) {
302
- const i = this.activeAnnotation.coordinates, e = Math.abs(t.x - this.dragStartPoint.x), a = Math.abs(t.y - this.dragStartPoint.y);
303
- i.width = e * 2, i.height = a * 2;
302
+ const i = this.activeAnnotation.coordinates, e = Math.abs(t.x - this.dragStartPoint.x), o = Math.abs(t.y - this.dragStartPoint.y);
303
+ i.width = e * 2, i.height = o * 2;
304
304
  } else this.activeAnnotation.type;
305
305
  }
306
306
  finishDrawing() {
@@ -311,8 +311,8 @@ class Zt {
311
311
  this.activeAnnotation = null, this.isDrawing = !1;
312
312
  return;
313
313
  }
314
- const i = Math.min(t.x1, t.x2), e = Math.max(t.x1, t.x2), a = Math.min(t.y1, t.y2), r = Math.max(t.y1, t.y2);
315
- t.x1 = i, t.x2 = e, t.y1 = a, t.y2 = r, this.annotations.push(this.activeAnnotation), this.emit("annotationChange", { action: "add", changedItem: this.activeAnnotation, imageUrl: this.imageUrl });
314
+ const i = Math.min(t.x1, t.x2), e = Math.max(t.x1, t.x2), o = Math.min(t.y1, t.y2), c = Math.max(t.y1, t.y2);
315
+ t.x1 = i, t.x2 = e, t.y1 = o, t.y2 = c, this.annotations.push(this.activeAnnotation), this.emit("annotationChange", { action: "add", changedItem: this.activeAnnotation, imageUrl: this.imageUrl });
316
316
  } else if (this.activeAnnotation.type === "polygon") {
317
317
  if (this.activeAnnotation.coordinates.points.length < 3) {
318
318
  this.activeAnnotation = null, this.isDrawing = !1;
@@ -336,40 +336,40 @@ class Zt {
336
336
  const i = t.x - this.dragStartPoint.x, e = t.y - this.dragStartPoint.y;
337
337
  this.selectedHandleIndex === -1 ? this.moveAnnotation(this.activeAnnotation, this.dragStartAnnotation, i, e) : this.resizeAnnotation(this.activeAnnotation, this.dragStartAnnotation, this.selectedHandleIndex, t);
338
338
  }
339
- moveAnnotation(t, i, e, a) {
339
+ moveAnnotation(t, i, e, o) {
340
340
  if (t.type === "rectangle") {
341
- const r = i.coordinates, c = t.coordinates;
342
- c.x1 = r.x1 + e, c.x2 = r.x2 + e, c.y1 = r.y1 + a, c.y2 = r.y2 + a;
341
+ const c = i.coordinates, r = t.coordinates;
342
+ r.x1 = c.x1 + e, r.x2 = c.x2 + e, r.y1 = c.y1 + o, r.y2 = c.y2 + o;
343
343
  } else if (t.type === "point") {
344
- const r = i.coordinates, c = t.coordinates;
345
- c.points = r.points.map((o) => ({ x: o.x + e, y: o.y + a }));
344
+ const c = i.coordinates, r = t.coordinates;
345
+ r.points = c.points.map((a) => ({ x: a.x + e, y: a.y + o }));
346
346
  } else if (t.type === "rotatedRect") {
347
- const r = i.coordinates, c = t.coordinates;
348
- c.x = r.x + e, c.y = r.y + a;
347
+ const c = i.coordinates, r = t.coordinates;
348
+ r.x = c.x + e, r.y = c.y + o;
349
349
  } else if (t.type === "polygon") {
350
- const r = i.coordinates, c = t.coordinates;
351
- c.points = r.points.map((o) => ({ x: o.x + e, y: o.y + a }));
350
+ const c = i.coordinates, r = t.coordinates;
351
+ r.points = c.points.map((a) => ({ x: a.x + e, y: a.y + o }));
352
352
  }
353
353
  }
354
- resizeAnnotation(t, i, e, a) {
354
+ resizeAnnotation(t, i, e, o) {
355
355
  if (t.type === "rectangle") {
356
- const r = t.coordinates;
357
- e === 0 && (r.x1 = a.x, r.y1 = a.y), e === 1 && (r.x2 = a.x, r.y1 = a.y), e === 2 && (r.x2 = a.x, r.y2 = a.y), e === 3 && (r.x1 = a.x, r.y2 = a.y);
356
+ const c = t.coordinates;
357
+ e === 0 && (c.x1 = o.x, c.y1 = o.y), e === 1 && (c.x2 = o.x, c.y1 = o.y), e === 2 && (c.x2 = o.x, c.y2 = o.y), e === 3 && (c.x1 = o.x, c.y2 = o.y);
358
358
  } else if (t.type === "polygon") {
359
- const r = t.coordinates;
360
- e >= 0 && e < r.points.length && (r.points[e] = a);
359
+ const c = t.coordinates;
360
+ e >= 0 && e < c.points.length && (c.points[e] = o);
361
361
  } else if (t.type === "point") {
362
- const r = t.coordinates;
363
- e >= 0 && e < r.points.length && (r.points[e] = a);
362
+ const c = t.coordinates;
363
+ e >= 0 && e < c.points.length && (c.points[e] = o);
364
364
  } else if (t.type === "rotatedRect") {
365
- const r = t.coordinates;
365
+ const c = t.coordinates;
366
366
  if (e === -2) {
367
- const c = r.x, o = r.y, d = a.x - c, f = a.y - o;
368
- let w = Math.atan2(f, d) * 180 / Math.PI;
369
- w += 90, r.angle = w;
367
+ const r = c.x, a = c.y, d = o.x - r, u = o.y - a;
368
+ let w = Math.atan2(u, d) * 180 / Math.PI;
369
+ w += 90, c.angle = w;
370
370
  } else {
371
- const c = r.angle * Math.PI / 180, o = Math.cos(-c), d = Math.sin(-c), f = a.x - r.x, w = a.y - r.y, m = f * o - w * d, _ = f * d + w * o;
372
- (e === 0 || e === 3) && (r.width / 2, r.width = Math.abs(m) * 2), (e === 1 || e === 2) && (r.width = Math.abs(m) * 2), (e === 0 || e === 1) && (r.height = Math.abs(_) * 2), (e === 2 || e === 3) && (r.height = Math.abs(_) * 2);
371
+ const r = c.angle * Math.PI / 180, a = Math.cos(-r), d = Math.sin(-r), u = o.x - c.x, w = o.y - c.y, m = u * a - w * d, _ = u * d + w * a;
372
+ (e === 0 || e === 3) && (c.width / 2, c.width = Math.abs(m) * 2), (e === 1 || e === 2) && (c.width = Math.abs(m) * 2), (e === 0 || e === 1) && (c.height = Math.abs(_) * 2), (e === 2 || e === 3) && (c.height = Math.abs(_) * 2);
373
373
  }
374
374
  }
375
375
  }
@@ -390,18 +390,18 @@ class Zt {
390
390
  const e = i.coordinates;
391
391
  return Kt(t, e.points);
392
392
  } else if (i.type === "rotatedRect") {
393
- const e = i.coordinates, a = yt(t, { x: e.x, y: e.y }, -e.angle), r = e.width / 2, c = e.height / 2;
394
- return a.x >= e.x - r && a.x <= e.x + r && a.y >= e.y - c && a.y <= e.y + c;
393
+ const e = i.coordinates, o = pt(t, { x: e.x, y: e.y }, -e.angle), c = e.width / 2, r = e.height / 2;
394
+ return o.x >= e.x - c && o.x <= e.x + c && o.y >= e.y - r && o.y <= e.y + r;
395
395
  } else if (i.type === "point")
396
- return i.coordinates.points.some((a) => ct(t, a) < 10 / this.scale);
396
+ return i.coordinates.points.some((o) => ct(t, o) < 10 / this.scale);
397
397
  return !1;
398
398
  }
399
399
  getHitHandle(t, i, e) {
400
- const a = this.getAnnotationHandles(e), r = 6;
401
- for (let c = 0; c < a.length; c++) {
402
- const o = a[c], d = this.toScreenCoords(o.x, o.y);
403
- if (Math.abs(t - d.x) < r && Math.abs(i - d.y) < r)
404
- return e.type === "rotatedRect" && c === 4 ? -2 : c;
400
+ const o = this.getAnnotationHandles(e), c = 6;
401
+ for (let r = 0; r < o.length; r++) {
402
+ const a = o[r], d = this.toScreenCoords(a.x, a.y);
403
+ if (Math.abs(t - d.x) < c && Math.abs(i - d.y) < c)
404
+ return e.type === "rotatedRect" && r === 4 ? -2 : r;
405
405
  }
406
406
  return -100;
407
407
  }
@@ -424,24 +424,24 @@ class Zt {
424
424
  if (t.type === "point")
425
425
  return t.coordinates.points;
426
426
  if (t.type === "rotatedRect") {
427
- const i = t.coordinates, e = { x: i.x, y: i.y }, a = i.width / 2, r = i.height / 2, c = { x: i.x - a, y: i.y - r }, o = { x: i.x + a, y: i.y - r }, d = { x: i.x + a, y: i.y + r }, f = { x: i.x - a, y: i.y + r }, w = { x: i.x, y: i.y - r - 20 / this.scale };
428
- return [c, o, d, f, w].map((m) => yt(m, e, i.angle));
427
+ const i = t.coordinates, e = { x: i.x, y: i.y }, o = i.width / 2, c = i.height / 2, r = { x: i.x - o, y: i.y - c }, a = { x: i.x + o, y: i.y - c }, d = { x: i.x + o, y: i.y + c }, u = { x: i.x - o, y: i.y + c }, w = { x: i.x, y: i.y - c - 20 / this.scale };
428
+ return [r, a, d, u, w].map((m) => pt(m, e, i.angle));
429
429
  }
430
430
  }
431
431
  return [];
432
432
  }
433
433
  checkHover(t, i, e) {
434
- const a = this.getHitCategory(t, i);
435
- if (a) {
436
- this.canvas.style.cursor = "pointer", this.hoverAnnotation = a;
434
+ const o = this.getHitCategory(t, i);
435
+ if (o) {
436
+ this.canvas.style.cursor = "pointer", this.hoverAnnotation = o;
437
437
  return;
438
438
  }
439
439
  if (this.activeAnnotation && this.getHitHandle(t, i, this.activeAnnotation) !== -100) {
440
440
  this.canvas.style.cursor = "pointer";
441
441
  return;
442
442
  }
443
- const r = this.getHitAnnotation(e);
444
- r ? (this.canvas.style.cursor = "move", this.hoverAnnotation = r) : (this.canvas.style.cursor = "default", this.hoverAnnotation = null);
443
+ const c = this.getHitAnnotation(e);
444
+ c ? (this.canvas.style.cursor = "move", this.hoverAnnotation = c) : (this.canvas.style.cursor = "default", this.hoverAnnotation = null);
445
445
  }
446
446
  render() {
447
447
  this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.img.complete && this.img.width > 0 && this.ctx.drawImage(this.img, this.offset.x, this.offset.y, this.img.width * this.scale, this.img.height * this.scale), this.annotations.forEach((t) => {
@@ -453,71 +453,71 @@ class Zt {
453
453
  if (t.length === 0) return;
454
454
  this.ctx.save(), this.ctx.font = "14px sans-serif", this.ctx.textBaseline = "top";
455
455
  let i = 10;
456
- const e = 10, a = 8, r = 4, c = 24, o = 8;
456
+ const e = 10, o = 8, c = 4, r = 24, a = 8;
457
457
  t.forEach((d) => {
458
- const f = d.label || "Unlabeled", w = this.ctx.measureText(f).width + a * 2, m = this.activeAnnotation === d, _ = this.hoverAnnotation === d;
459
- this.ctx.fillStyle = m ? "#E3F2FD" : _ ? "#F5F5F5" : "rgba(255, 255, 255, 0.9)", this.ctx.strokeStyle = m ? "#2196F3" : "#666", this.ctx.lineWidth = m ? 2 : 1, this.ctx.beginPath(), this.ctx.rect(i, e, w, c), this.ctx.fill(), this.ctx.stroke(), this.ctx.fillStyle = m ? "#1976D2" : "#333", this.ctx.fillText(f, i + a, e + r), i += w + o;
458
+ const u = d.label || "Unlabeled", w = this.ctx.measureText(u).width + o * 2, m = this.activeAnnotation === d, _ = this.hoverAnnotation === d;
459
+ this.ctx.fillStyle = m ? "#E3F2FD" : _ ? "#F5F5F5" : "rgba(255, 255, 255, 0.9)", this.ctx.strokeStyle = m ? "#2196F3" : "#666", this.ctx.lineWidth = m ? 2 : 1, this.ctx.beginPath(), this.ctx.rect(i, e, w, r), this.ctx.fill(), this.ctx.stroke(), this.ctx.fillStyle = m ? "#1976D2" : "#333", this.ctx.fillText(u, i + o, e + c), i += w + a;
460
460
  }), this.ctx.restore();
461
461
  }
462
462
  getHitCategory(t, i) {
463
463
  const e = this.annotations.filter((w) => w.type === "category");
464
464
  if (e.length === 0) return null;
465
465
  this.ctx.save(), this.ctx.font = "14px sans-serif";
466
- let a = 10;
467
- const r = 10, c = 8, o = 24, d = 8;
468
- let f = null;
466
+ let o = 10;
467
+ const c = 10, r = 8, a = 24, d = 8;
468
+ let u = null;
469
469
  for (const w of e) {
470
- const m = w.label || "Unlabeled", _ = this.ctx.measureText(m).width + c * 2;
471
- if (t >= a && t <= a + _ && i >= r && i <= r + o) {
472
- f = w;
470
+ const m = w.label || "Unlabeled", _ = this.ctx.measureText(m).width + r * 2;
471
+ if (t >= o && t <= o + _ && i >= c && i <= c + a) {
472
+ u = w;
473
473
  break;
474
474
  }
475
- a += _ + d;
475
+ o += _ + d;
476
476
  }
477
- return this.ctx.restore(), f;
477
+ return this.ctx.restore(), u;
478
478
  }
479
479
  drawItem(t, i) {
480
- var r;
480
+ var c;
481
481
  if (this.visibleLabels.size > 0 && !this.visibleLabels.has(t.label) && !i)
482
482
  return;
483
483
  this.ctx.save();
484
- const e = ((r = t.style) == null ? void 0 : r.strokeColor) || "#FF4081", a = i ? "#00E5FF" : e;
485
- if (this.ctx.strokeStyle = a, this.ctx.lineWidth = 2, i ? this.ctx.fillStyle = "rgba(0, 229, 255, 0.2)" : this.ctx.fillStyle = this.hexToRgba(e, 0.2), t.type === "rectangle") {
486
- const c = t.coordinates, o = this.toScreenCoords(c.x1, c.y1), d = this.toScreenCoords(c.x2, c.y2), f = Math.min(o.x, d.x), w = Math.min(o.y, d.y), m = Math.abs(o.x - d.x), _ = Math.abs(o.y - d.y);
487
- this.ctx.strokeRect(f, w, m, _), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fillRect(f, w, m, _), i && this.drawHandles(this.getAnnotationHandles(t));
484
+ const e = ((c = t.style) == null ? void 0 : c.strokeColor) || "#FF4081", o = i ? "#00E5FF" : e;
485
+ if (this.ctx.strokeStyle = o, this.ctx.lineWidth = 2, i ? this.ctx.fillStyle = "rgba(0, 229, 255, 0.2)" : this.ctx.fillStyle = this.hexToRgba(e, 0.2), t.type === "rectangle") {
486
+ const r = t.coordinates, a = this.toScreenCoords(r.x1, r.y1), d = this.toScreenCoords(r.x2, r.y2), u = Math.min(a.x, d.x), w = Math.min(a.y, d.y), m = Math.abs(a.x - d.x), _ = Math.abs(a.y - d.y);
487
+ this.ctx.strokeRect(u, w, m, _), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fillRect(u, w, m, _), i && this.drawHandles(this.getAnnotationHandles(t));
488
488
  } else if (t.type === "polygon") {
489
- const c = t.coordinates;
490
- if (c.points.length === 0) {
489
+ const r = t.coordinates;
490
+ if (r.points.length === 0) {
491
491
  this.ctx.restore();
492
492
  return;
493
493
  }
494
494
  this.ctx.beginPath();
495
- const o = this.toScreenCoords(c.points[0].x, c.points[0].y);
496
- this.ctx.moveTo(o.x, o.y);
497
- for (let d = 1; d < c.points.length; d++) {
498
- const f = this.toScreenCoords(c.points[d].x, c.points[d].y);
499
- this.ctx.lineTo(f.x, f.y);
495
+ const a = this.toScreenCoords(r.points[0].x, r.points[0].y);
496
+ this.ctx.moveTo(a.x, a.y);
497
+ for (let d = 1; d < r.points.length; d++) {
498
+ const u = this.toScreenCoords(r.points[d].x, r.points[d].y);
499
+ this.ctx.lineTo(u.x, u.y);
500
500
  }
501
501
  if (!this.isDrawing || t !== this.activeAnnotation)
502
502
  this.ctx.closePath();
503
503
  else if (this.lastMouseMovePoint) {
504
504
  let d = this.lastMouseMovePoint;
505
- if (this.isHoveringStartPoint && c.points.length > 0) {
506
- d = c.points[0];
507
- const w = this.toScreenCoords(c.points[0].x, c.points[0].y);
505
+ if (this.isHoveringStartPoint && r.points.length > 0) {
506
+ d = r.points[0];
507
+ const w = this.toScreenCoords(r.points[0].x, r.points[0].y);
508
508
  this.ctx.save(), this.ctx.beginPath(), this.ctx.arc(w.x, w.y, 10, 0, Math.PI * 2), this.ctx.fillStyle = "rgba(255, 215, 0, 0.6)", this.ctx.strokeStyle = "#FFFFFF", this.ctx.lineWidth = 2, this.ctx.fill(), this.ctx.stroke(), this.ctx.restore();
509
509
  }
510
- const f = this.toScreenCoords(d.x, d.y);
511
- this.ctx.lineTo(f.x, f.y);
510
+ const u = this.toScreenCoords(d.x, d.y);
511
+ this.ctx.lineTo(u.x, u.y);
512
512
  }
513
513
  this.ctx.stroke(), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fill(), i && this.drawHandles(this.getAnnotationHandles(t));
514
514
  } else if (t.type === "rotatedRect") {
515
- const c = t.coordinates;
516
- this.ctx.translate(this.toScreenCoords(c.x, c.y).x, this.toScreenCoords(c.x, c.y).y), this.ctx.rotate(c.angle * Math.PI / 180);
517
- const o = c.width * this.scale, d = c.height * this.scale;
518
- this.ctx.strokeRect(-o / 2, -d / 2, o, d), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fillRect(-o / 2, -d / 2, o, d), this.ctx.rotate(-c.angle * Math.PI / 180), this.ctx.translate(-this.toScreenCoords(c.x, c.y).x, -this.toScreenCoords(c.x, c.y).y), i && this.drawHandles(this.getAnnotationHandles(t));
519
- } else t.type === "point" && t.coordinates.points.forEach((o) => {
520
- const d = this.toScreenCoords(o.x, o.y);
515
+ const r = t.coordinates;
516
+ this.ctx.translate(this.toScreenCoords(r.x, r.y).x, this.toScreenCoords(r.x, r.y).y), this.ctx.rotate(r.angle * Math.PI / 180);
517
+ const a = r.width * this.scale, d = r.height * this.scale;
518
+ this.ctx.strokeRect(-a / 2, -d / 2, a, d), this.ctx.fillStyle = i ? "rgba(0, 229, 255, 0.2)" : "rgba(255, 64, 129, 0.2)", this.ctx.fillRect(-a / 2, -d / 2, a, d), this.ctx.rotate(-r.angle * Math.PI / 180), this.ctx.translate(-this.toScreenCoords(r.x, r.y).x, -this.toScreenCoords(r.x, r.y).y), i && this.drawHandles(this.getAnnotationHandles(t));
519
+ } else t.type === "point" && t.coordinates.points.forEach((a) => {
520
+ const d = this.toScreenCoords(a.x, a.y);
521
521
  this.ctx.beginPath(), this.ctx.arc(d.x, d.y, 5, 0, Math.PI * 2), this.ctx.fillStyle = i ? "#00E5FF" : e, this.ctx.fill(), this.ctx.stroke();
522
522
  });
523
523
  this.ctx.restore();
@@ -561,28 +561,28 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
561
561
  <path d="M637.12 693.376l182.208 182.208a32 32 0 1 1-45.248 45.248L591.872 738.624a352 352 0 1 1 45.248-45.248z m-45.248-45.248A288 288 0 1 0 183.872 240.128a288 288 0 0 0 408 408zM416 448h96a32 32 0 0 1 0 64h-96v96a32 32 0 0 1-64 0v-96h-96a32 32 0 0 1 0-64h96v-96a32 32 0 0 1 64 0v96z" fill="currentColor"/>\r
562
562
  </svg>`, ve = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" width="1em" height="1em">\r
563
563
  <path d="M637.12 693.376l182.208 182.208a32 32 0 1 1-45.248 45.248L591.872 738.624a352 352 0 1 1 45.248-45.248z m-45.248-45.248A288 288 0 1 0 183.872 240.128a288 288 0 0 0 408 408zM256 448h320a32 32 0 1 1 0 64H256a32 32 0 1 1 0-64z" fill="currentColor"/>\r
564
- </svg>`, me = ["innerHTML"], fe = /* @__PURE__ */ Z({
564
+ </svg>`, me = ["innerHTML"], fe = /* @__PURE__ */ tt({
565
565
  __name: "SvgIcon",
566
566
  props: {
567
567
  name: {},
568
568
  size: {}
569
569
  },
570
- setup(u) {
571
- const t = u, i = M(""), e = /* @__PURE__ */ Object.assign({ "../assets/svg/aim.svg": Qt, "../assets/svg/back.svg": te, "../assets/svg/connection.svg": ee, "../assets/svg/crop.svg": ne, "../assets/svg/delete.svg": se, "../assets/svg/download.svg": ie, "../assets/svg/edit.svg": oe, "../assets/svg/hide.svg": ae, "../assets/svg/pointer.svg": le, "../assets/svg/price-tag.svg": re, "../assets/svg/rank.svg": ce, "../assets/svg/refresh-right.svg": he, "../assets/svg/right.svg": de, "../assets/svg/view.svg": ge, "../assets/svg/zoom-in.svg": ue, "../assets/svg/zoom-out.svg": ve });
570
+ setup(f) {
571
+ const t = f, i = M(""), e = /* @__PURE__ */ Object.assign({ "../assets/svg/aim.svg": Qt, "../assets/svg/back.svg": te, "../assets/svg/connection.svg": ee, "../assets/svg/crop.svg": ne, "../assets/svg/delete.svg": se, "../assets/svg/download.svg": ie, "../assets/svg/edit.svg": oe, "../assets/svg/hide.svg": ae, "../assets/svg/pointer.svg": le, "../assets/svg/price-tag.svg": re, "../assets/svg/rank.svg": ce, "../assets/svg/refresh-right.svg": he, "../assets/svg/right.svg": de, "../assets/svg/view.svg": ge, "../assets/svg/zoom-in.svg": ue, "../assets/svg/zoom-out.svg": ve });
572
572
  return Yt(() => {
573
- const a = `../assets/svg/${t.name}.svg`, r = e[a];
574
- r ? i.value = r : (console.warn(`Icon ${t.name} not found at path ${a}`), i.value = "");
575
- }), (a, r) => (y(), p("i", {
576
- class: W(["svg-icon", [u.size ? `size-${u.size}` : ""]]),
573
+ const o = `../assets/svg/${t.name}.svg`, c = e[o];
574
+ c ? i.value = c : (console.warn(`Icon ${t.name} not found at path ${o}`), i.value = "");
575
+ }), (o, c) => (y(), x("i", {
576
+ class: J(["svg-icon", [f.size ? `size-${f.size}` : ""]]),
577
577
  innerHTML: i.value
578
578
  }, null, 10, me));
579
579
  }
580
- }), Q = (u, t) => {
581
- const i = u.__vccOpts || u;
582
- for (const [e, a] of t)
583
- i[e] = a;
580
+ }), et = (f, t) => {
581
+ const i = f.__vccOpts || f;
582
+ for (const [e, o] of t)
583
+ i[e] = o;
584
584
  return i;
585
- }, H = /* @__PURE__ */ Q(fe, [["__scopeId", "data-v-3928607b"]]), ye = {
585
+ }, H = /* @__PURE__ */ et(fe, [["__scopeId", "data-v-3928607b"]]), ye = {
586
586
  key: 0,
587
587
  class: "image-list-sidebar"
588
588
  }, pe = { class: "image-list-title" }, xe = { class: "image-list-scroll" }, be = ["onClick"], we = { class: "image-list-stage" }, Ce = ["src", "alt"], Ae = {
@@ -608,10 +608,10 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
608
608
  }, Be = ["disabled"], De = ["disabled"], Ue = {
609
609
  key: 2,
610
610
  class: "right-sidebar"
611
- }, Fe = { class: "label-list" }, Ee = { class: "label-row" }, Oe = ["onUpdate:modelValue", "onChange"], Ve = ["title"], We = ["onClick"], Ne = { class: "action-icon more-actions" }, Je = ["onClick"], je = {
611
+ }, Fe = { class: "label-list" }, Oe = { class: "label-row" }, Ee = ["onUpdate:modelValue", "onChange"], Ve = ["title"], Ne = ["onClick"], We = { class: "action-icon more-actions" }, Je = ["onClick"], je = {
612
612
  key: 3,
613
613
  class: "modal-overlay"
614
- }, Ye = { class: "modal-content" }, Xe = { class: "form-group" }, qe = { class: "form-group" }, Ge = { class: "color-input-wrapper" }, Ke = /* @__PURE__ */ Z({
614
+ }, Ye = { class: "modal-content" }, Xe = { class: "form-group" }, qe = { class: "form-group" }, Ge = { class: "color-input-wrapper" }, Ke = /* @__PURE__ */ tt({
615
615
  __name: "ImageAnnotator",
616
616
  props: {
617
617
  annotationTypes: { default: () => ["rectangle", "polygon", "point", "rotatedRect"] },
@@ -628,8 +628,8 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
628
628
  maxZoom: {}
629
629
  },
630
630
  emits: ["annotationChange", "batchChange", "labelChange", "ready", "error", "tool:change", "viewport:change", "annotation:add", "annotation:update", "annotation:delete", "annotation:select", "prediction:loaded", "prediction:apply", "prediction:reject"],
631
- setup(u, { expose: t, emit: i }) {
632
- const e = u, a = i, r = M(null), c = M(null), o = M(null), d = M(null), f = M(0), w = M(""), m = M([]), _ = M(""), F = M(!1), k = M({ name: "", color: "#FF0000" }), I = M("none"), C = M([]), R = M({}), j = D(() => d.value === "select" && !!w.value), V = (n) => {
631
+ setup(f, { expose: t, emit: i }) {
632
+ const e = f, o = i, c = M(null), r = M(null), a = M(null), d = M(null), u = M(0), w = M(""), m = M([]), _ = M(""), U = M(!1), k = M({ name: "", color: "#FF0000" }), I = M("none"), C = M([]), R = M({}), N = D(() => d.value === "select" && !!w.value), j = (n) => {
633
633
  if (!n || R.value[n]) return;
634
634
  const s = new Image();
635
635
  s.onload = () => {
@@ -639,13 +639,13 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
639
639
  [n]: { width: l, height: h }
640
640
  };
641
641
  }, s.src = n;
642
- }, tt = () => {
642
+ }, X = () => {
643
643
  e.batchImages.forEach((n) => {
644
- V(n.imageUrl);
644
+ j(n.imageUrl);
645
645
  });
646
- }, E = () => {
646
+ }, O = () => {
647
647
  var l, h, v, A;
648
- const n = e.batchImages[f.value], s = (n == null ? void 0 : n.imageUrl) || ((l = e.image) == null ? void 0 : l.url);
648
+ const n = e.batchImages[u.value], s = (n == null ? void 0 : n.imageUrl) || ((l = e.image) == null ? void 0 : l.url);
649
649
  return {
650
650
  eventId: `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`,
651
651
  timestamp: Date.now(),
@@ -654,17 +654,17 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
654
654
  imageId: ((v = e.image) == null ? void 0 : v.id) || s,
655
655
  operator: (A = e.session) == null ? void 0 : A.userId
656
656
  };
657
- }, et = (n) => {
657
+ }, ht = (n) => {
658
658
  var h;
659
659
  const s = n == null ? void 0 : n.action;
660
660
  if (!s) return;
661
661
  const l = {
662
- meta: E(),
662
+ meta: O(),
663
663
  action: s,
664
664
  current: n == null ? void 0 : n.changedItem,
665
665
  source: (h = n == null ? void 0 : n.changedItem) != null && h.predictionId ? "prediction" : "manual"
666
666
  };
667
- s === "add" && a("annotation:add", l), s === "update" && a("annotation:update", l), s === "delete" && a("annotation:delete", l), s === "select" && a("annotation:select", l);
667
+ s === "add" && o("annotation:add", l), s === "update" && o("annotation:update", l), s === "delete" && o("annotation:delete", l), s === "select" && o("annotation:select", l);
668
668
  }, nt = D(() => e.annotationTypes.filter((n) => n !== "category")), st = (n) => ({
669
669
  rectangle: "crop",
670
670
  polygon: "connection",
@@ -679,64 +679,64 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
679
679
  category: "分类标签"
680
680
  })[n] || n;
681
681
  Xt(() => {
682
- if (tt(), r.value) {
683
- o.value = new Zt(r.value), o.value.on("annotationChange", (s) => {
682
+ if (X(), c.value) {
683
+ a.value = new Zt(c.value), a.value.on("annotationChange", (s) => {
684
684
  var l, h;
685
685
  if (s.action === "add" && s.changedItem) {
686
686
  const v = m.value.find((A) => A.id === _.value);
687
687
  v && (s.changedItem.label = v.name, s.changedItem.labelId = v.id);
688
688
  }
689
- s.action === "select" ? w.value = ((l = s.changedItem) == null ? void 0 : l.id) || "" : s.action === "delete" && ((h = s.changedItem) == null ? void 0 : h.id) === w.value && (w.value = ""), a("annotationChange", s), et(s);
690
- }), x(), N();
689
+ s.action === "select" ? w.value = ((l = s.changedItem) == null ? void 0 : l.id) || "" : s.action === "delete" && ((h = s.changedItem) == null ? void 0 : h.id) === w.value && (w.value = ""), o("annotationChange", s), ht(s);
690
+ }), W(), E();
691
691
  const n = new ResizeObserver(() => {
692
692
  var s;
693
- (s = o.value) == null || s.resize();
693
+ (s = a.value) == null || s.resize();
694
694
  });
695
- c.value && n.observe(c.value), e.defaultActiveType && b(e.defaultActiveType), a("ready", { meta: E() });
695
+ r.value && n.observe(r.value), e.defaultActiveType && p(e.defaultActiveType), o("ready", { meta: O() });
696
696
  }
697
697
  });
698
- const N = () => {
699
- if (!o.value) return;
698
+ const E = () => {
699
+ if (!a.value) return;
700
700
  const n = m.value.find((l) => l.id === _.value);
701
- n && o.value.setLabelStyle(n.color);
701
+ n && a.value.setLabelStyle(n.color);
702
702
  const s = m.value.filter((l) => l.visible).map((l) => l.name);
703
- o.value.setVisibleLabels(s);
704
- }, x = () => {
703
+ a.value.setVisibleLabels(s);
704
+ }, W = () => {
705
705
  var n;
706
- if (o.value)
706
+ if (a.value)
707
707
  if (w.value = "", requestAnimationFrame(() => {
708
708
  var s;
709
- (s = o.value) == null || s.resize();
709
+ (s = a.value) == null || s.resize();
710
710
  }), e.batchImages.length > 0) {
711
- const s = e.batchImages[f.value];
712
- o.value.loadImage(s.imageUrl), s.annotations ? o.value.setAnnotations(s.annotations) : o.value.setAnnotations([]);
713
- } else (n = e.image) != null && n.url && o.value.loadImage(e.image.url);
714
- }, b = (n) => {
711
+ const s = e.batchImages[u.value];
712
+ a.value.loadImage(s.imageUrl), s.annotations ? a.value.setAnnotations(s.annotations) : a.value.setAnnotations([]);
713
+ } else (n = e.image) != null && n.url && a.value.loadImage(e.image.url);
714
+ }, p = (n) => {
715
715
  var s, l;
716
716
  if (d.value = n, w.value = "", n !== "pan" && n !== "select" && m.value.length === 0) {
717
717
  alert("请先创建标签!");
718
718
  return;
719
719
  }
720
- n === "pan" || n === "select" ? (s = o.value) == null || s.setTool(n) : (l = o.value) == null || l.setTool(n), a("tool:change", { meta: E(), tool: n });
721
- }, z = () => {
720
+ n === "pan" || n === "select" ? (s = a.value) == null || s.setTool(n) : (l = a.value) == null || l.setTool(n), o("tool:change", { meta: O(), tool: n });
721
+ }, b = () => {
722
722
  var n;
723
- (n = o.value) != null && n.activeAnnotation && o.value.deleteAnnotation(o.value.activeAnnotation.id);
724
- }, J = () => {
725
- o.value && a("viewport:change", {
726
- meta: E(),
727
- scale: o.value.scale,
728
- offset: { ...o.value.offset }
723
+ (n = a.value) != null && n.activeAnnotation && a.value.deleteAnnotation(a.value.activeAnnotation.id);
724
+ }, z = () => {
725
+ a.value && o("viewport:change", {
726
+ meta: O(),
727
+ scale: a.value.scale,
728
+ offset: { ...a.value.offset }
729
729
  });
730
- }, ht = () => {
730
+ }, q = () => {
731
731
  var n;
732
- (n = o.value) == null || n.zoom(1), J();
733
- }, pt = () => {
732
+ (n = a.value) == null || n.zoom(1), z();
733
+ }, dt = () => {
734
734
  var n;
735
- (n = o.value) == null || n.zoom(-1), J();
735
+ (n = a.value) == null || n.zoom(-1), z();
736
736
  }, xt = () => {
737
- k.value = { name: "", color: "#2196F3" }, F.value = !0;
738
- }, dt = () => {
739
- F.value = !1;
737
+ k.value = { name: "", color: "#2196F3" }, U.value = !0;
738
+ }, gt = () => {
739
+ U.value = !1;
740
740
  }, bt = () => {
741
741
  if (!k.value.name.trim()) {
742
742
  alert("请输入标签名称");
@@ -748,167 +748,167 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
748
748
  color: k.value.color,
749
749
  visible: !0
750
750
  };
751
- m.value.push(s), a("labelChange", m.value), m.value.length === 1 && Y(s), dt();
752
- }, Y = (n) => {
751
+ m.value.push(s), o("labelChange", m.value), E(), m.value.length === 1 && G(s), gt();
752
+ }, G = (n) => {
753
753
  var s;
754
- _.value = n.id, (s = o.value) == null || s.setLabelStyle(n.color);
754
+ _.value = n.id, (s = a.value) == null || s.setLabelStyle(n.color);
755
755
  }, wt = (n, s) => {
756
756
  if (!n.startsWith("#")) return n;
757
757
  let l = 0, h = 0, v = 0;
758
758
  return n.length === 4 ? (l = parseInt(n[1] + n[1], 16), h = parseInt(n[2] + n[2], 16), v = parseInt(n[3] + n[3], 16)) : n.length === 7 && (l = parseInt(n.slice(1, 3), 16), h = parseInt(n.slice(3, 5), 16), v = parseInt(n.slice(5, 7), 16)), `rgba(${l}, ${h}, ${v}, ${s})`;
759
759
  }, Ct = (n) => {
760
760
  var s;
761
- if (n.id === _.value && ((s = o.value) == null || s.setLabelStyle(n.color)), o.value) {
762
- const l = o.value.getAnnotations();
761
+ if (n.id === _.value && ((s = a.value) == null || s.setLabelStyle(n.color)), a.value) {
762
+ const l = a.value.getAnnotations();
763
763
  let h = !1;
764
764
  l.forEach((v) => {
765
765
  v.label === n.name && (v.style || (v.style = {}), v.style.strokeColor = n.color, v.style.fillColor = wt(n.color, 0.2), h = !0);
766
- }), h && o.value.render();
766
+ }), h && a.value.render();
767
767
  }
768
- a("labelChange", m.value);
768
+ o("labelChange", m.value), E();
769
769
  }, At = (n) => {
770
- n.visible = !n.visible, N();
770
+ n.visible = !n.visible, E();
771
771
  }, _t = (n) => {
772
772
  const s = m.value.findIndex((l) => l.id === n);
773
- s > -1 && (m.value.splice(s, 1), a("labelChange", m.value), _.value === n && (_.value = m.value.length > 0 ? m.value[0].id : "", _.value && Y(m.value[0])), N());
773
+ s > -1 && (m.value.splice(s, 1), o("labelChange", m.value), _.value === n && (_.value = m.value.length > 0 ? m.value[0].id : "", _.value && G(m.value[0])), E());
774
774
  };
775
- X(() => e.labels, (n) => {
775
+ Y(() => e.labels, (n) => {
776
776
  const s = JSON.parse(JSON.stringify(n || []));
777
777
  if (m.value = s, m.value.length > 0)
778
778
  if (!_.value || !m.value.find((l) => l.id === _.value))
779
- Y(m.value[0]);
779
+ G(m.value[0]);
780
780
  else {
781
781
  const l = m.value.find((h) => h.id === _.value);
782
- l && Y(l);
782
+ l && G(l);
783
783
  }
784
784
  else
785
785
  _.value = "";
786
- N();
786
+ E();
787
787
  }, { immediate: !0, deep: !0 });
788
788
  const It = () => {
789
- f.value > 0 && (ot(), f.value--, x(), at());
789
+ u.value > 0 && (ot(), u.value--, W(), at());
790
790
  }, kt = () => {
791
- f.value < e.batchImages.length - 1 && (ot(), f.value++, x(), at());
791
+ u.value < e.batchImages.length - 1 && (ot(), u.value++, W(), at());
792
792
  }, ot = () => {
793
- if (o.value) {
794
- const n = o.value.getAnnotations();
795
- e.batchImages[f.value].annotations = n;
793
+ if (a.value) {
794
+ const n = a.value.getAnnotations();
795
+ e.batchImages[u.value].annotations = n;
796
796
  }
797
797
  }, at = () => {
798
- const n = e.batchImages[f.value];
799
- a("batchChange", {
800
- currentIndex: f.value,
798
+ const n = e.batchImages[u.value];
799
+ o("batchChange", {
800
+ currentIndex: u.value,
801
801
  total: e.batchImages.length,
802
802
  currentImageUrl: n.imageUrl,
803
803
  currentAnnotations: n.annotations || []
804
804
  });
805
- }, gt = (n = []) => {
805
+ }, ut = (n = []) => {
806
806
  var v;
807
- if (!o.value) return;
807
+ if (!a.value) return;
808
808
  if (C.value = JSON.parse(JSON.stringify(n)), C.value.length === 0) {
809
809
  I.value = "none";
810
810
  return;
811
811
  }
812
812
  I.value = "loaded";
813
- const l = (o.value.getAnnotations() || []).filter((A) => !A.predictionId), h = C.value.map((A) => {
813
+ const l = (a.value.getAnnotations() || []).filter((A) => !A.predictionId), h = C.value.map((A) => {
814
814
  const $ = JSON.parse(JSON.stringify(A.annotation));
815
815
  return $.id = $.id || `pred-${A.id}`, $.predictionId = A.id, $.modelRunId = A.modelRunId || $.modelRunId, $.confidence = A.confidence ?? $.confidence, $.reviewStatus = $.reviewStatus || "draft", $;
816
816
  });
817
- o.value.setAnnotations([...l, ...h]), a("prediction:loaded", {
818
- meta: E(),
817
+ a.value.setAnnotations([...l, ...h]), o("prediction:loaded", {
818
+ meta: O(),
819
819
  modelRunId: (v = C.value[0]) == null ? void 0 : v.modelRunId,
820
820
  candidates: C.value
821
821
  });
822
822
  }, St = (n, s) => {
823
823
  var v;
824
- if (!o.value) return [];
824
+ if (!a.value) return [];
825
825
  I.value = "applying";
826
- const h = (o.value.getAnnotations() || []).filter((A) => A.predictionId && n.includes(A.predictionId));
826
+ const h = (a.value.getAnnotations() || []).filter((A) => A.predictionId && n.includes(A.predictionId));
827
827
  return h.forEach((A) => {
828
828
  A.reviewStatus = "accepted";
829
- }), I.value = "applied", a("prediction:apply", {
830
- meta: E(),
829
+ }), I.value = "applied", o("prediction:apply", {
830
+ meta: O(),
831
831
  modelRunId: (v = h[0]) == null ? void 0 : v.modelRunId,
832
832
  candidateIds: n,
833
833
  threshold: s,
834
834
  acceptedAnnotations: h
835
- }), o.value.render(), h;
835
+ }), a.value.render(), h;
836
836
  }, Mt = (n, s) => {
837
837
  var v;
838
- if (!o.value) return;
839
- const l = o.value.getAnnotations() || [], h = l.filter((A) => !(A.predictionId && n.includes(A.predictionId)));
840
- o.value.setAnnotations(h), a("prediction:reject", {
841
- meta: E(),
838
+ if (!a.value) return;
839
+ const l = a.value.getAnnotations() || [], h = l.filter((A) => !(A.predictionId && n.includes(A.predictionId)));
840
+ a.value.setAnnotations(h), o("prediction:reject", {
841
+ meta: O(),
842
842
  modelRunId: (v = l.find((A) => A.predictionId && n.includes(A.predictionId))) == null ? void 0 : v.modelRunId,
843
843
  candidateIds: n,
844
844
  reason: s
845
845
  });
846
846
  }, zt = (n, s = []) => {
847
- o.value && (o.value.loadImage(n.url), o.value.setAnnotations(s));
847
+ a.value && (a.value.loadImage(n.url), a.value.setAnnotations(s));
848
848
  }, $t = (n) => {
849
849
  var s;
850
- (s = o.value) == null || s.setAnnotations(n);
851
- }, ut = () => {
850
+ (s = a.value) == null || s.setAnnotations(n);
851
+ }, vt = () => {
852
852
  var n;
853
- return ((n = o.value) == null ? void 0 : n.getAnnotations()) || [];
853
+ return ((n = a.value) == null ? void 0 : n.getAnnotations()) || [];
854
854
  }, Tt = (n = "json") => {
855
855
  var l, h;
856
- const s = ut();
856
+ const s = vt();
857
857
  return {
858
858
  format: n,
859
- image: ((l = e.batchImages[f.value]) == null ? void 0 : l.imageUrl) || ((h = e.image) == null ? void 0 : h.url) || "",
859
+ image: ((l = e.batchImages[u.value]) == null ? void 0 : l.imageUrl) || ((h = e.image) == null ? void 0 : h.url) || "",
860
860
  annotations: s
861
861
  };
862
- }, vt = (n) => {
863
- n >= 0 && n < e.batchImages.length && (ot(), f.value = n, x(), at());
862
+ }, mt = (n) => {
863
+ n >= 0 && n < e.batchImages.length && (ot(), u.value = n, W(), at());
864
864
  }, Pt = (n) => {
865
865
  var s;
866
- return n === f.value && o.value ? o.value.getAnnotations() || [] : ((s = e.batchImages[n]) == null ? void 0 : s.annotations) || [];
867
- }, Ht = (n) => n.type === "rectangle", Lt = (n) => n.type === "polygon", Rt = (n) => n.type === "point", Bt = (n) => n.type === "rotatedRect", G = (n) => {
866
+ return n === u.value && a.value ? a.value.getAnnotations() || [] : ((s = e.batchImages[n]) == null ? void 0 : s.annotations) || [];
867
+ }, Ht = (n) => n.type === "rectangle", Lt = (n) => n.type === "polygon", Rt = (n) => n.type === "point", Bt = (n) => n.type === "rotatedRect", Z = (n) => {
868
868
  var l, h;
869
869
  const s = (l = m.value.find((v) => v.name === n.label)) == null ? void 0 : l.color;
870
870
  return ((h = n.style) == null ? void 0 : h.strokeColor) || s || "#409eff";
871
- }, mt = (n) => {
871
+ }, ft = (n) => {
872
872
  const s = n.coordinates;
873
873
  return (s == null ? void 0 : s.points) || [];
874
- }, K = (n) => {
874
+ }, Q = (n) => {
875
875
  const s = e.batchImages[n];
876
876
  if (s != null && s.width && (s != null && s.height))
877
877
  return { width: s.width, height: s.height };
878
878
  const l = s != null && s.imageUrl ? R.value[s.imageUrl] : void 0;
879
- return l || (s != null && s.imageUrl && V(s.imageUrl), { width: 1, height: 1 });
879
+ return l || (s != null && s.imageUrl && j(s.imageUrl), { width: 1, height: 1 });
880
880
  }, Dt = (n) => {
881
881
  const s = e.batchImages[n];
882
882
  return s != null && s.width && (s != null && s.height) ? !0 : s != null && s.imageUrl ? !!R.value[s.imageUrl] : !1;
883
883
  }, Ut = (n, s) => {
884
- const l = s.coordinates, h = K(n), v = G(s), A = Math.min(l.x1, l.x2), $ = Math.min(l.y1, l.y2), Wt = Math.max(l.x1, l.x2), Nt = Math.max(l.y1, l.y2);
884
+ const l = s.coordinates, h = Q(n), v = Z(s), A = Math.min(l.x1, l.x2), $ = Math.min(l.y1, l.y2), Nt = Math.max(l.x1, l.x2), Wt = Math.max(l.y1, l.y2);
885
885
  return {
886
886
  left: `${A / h.width * 100}%`,
887
887
  top: `${$ / h.height * 100}%`,
888
- width: `${(Wt - A) / h.width * 100}%`,
889
- height: `${(Nt - $) / h.height * 100}%`,
888
+ width: `${(Nt - A) / h.width * 100}%`,
889
+ height: `${(Wt - $) / h.height * 100}%`,
890
890
  borderColor: v,
891
891
  backgroundColor: `${v}22`
892
892
  };
893
893
  }, Ft = (n, s) => {
894
- const l = K(n);
895
- return mt(s).map((h) => `${h.x / l.width * 100},${h.y / l.height * 100}`).join(" ");
896
- }, Et = (n) => {
897
- const s = G(n);
894
+ const l = Q(n);
895
+ return ft(s).map((h) => `${h.x / l.width * 100},${h.y / l.height * 100}`).join(" ");
896
+ }, Ot = (n) => {
897
+ const s = Z(n);
898
898
  return {
899
899
  fill: `${s}33`,
900
900
  stroke: s,
901
901
  strokeWidth: "1.4"
902
902
  };
903
- }, Ot = (n, s, l) => {
904
- const h = K(n), v = G(l);
903
+ }, Et = (n, s, l) => {
904
+ const h = Q(n), v = Z(l);
905
905
  return {
906
906
  left: `${s.x / h.width * 100}%`,
907
907
  top: `${s.y / h.height * 100}%`,
908
908
  backgroundColor: v
909
909
  };
910
910
  }, Vt = (n, s) => {
911
- const l = s.coordinates, h = K(n), v = G(s), A = Math.abs(l.width), $ = Math.abs(l.height);
911
+ const l = s.coordinates, h = Q(n), v = Z(s), A = Math.abs(l.width), $ = Math.abs(l.height);
912
912
  return {
913
913
  left: `${(l.x - A / 2) / h.width * 100}%`,
914
914
  top: `${(l.y - $ / 2) / h.height * 100}%`,
@@ -920,12 +920,12 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
920
920
  };
921
921
  };
922
922
  return t({
923
- jumpTo: vt,
923
+ jumpTo: mt,
924
924
  setImage: zt,
925
925
  setAnnotations: $t,
926
- getAnnotations: ut,
927
- selectTool: b,
928
- loadPredictionCandidates: gt,
926
+ getAnnotations: vt,
927
+ selectTool: p,
928
+ loadPredictionCandidates: ut,
929
929
  applyPredictions: St,
930
930
  rejectPredictions: Mt,
931
931
  exportAnnotations: Tt,
@@ -933,40 +933,40 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
933
933
  var n, s;
934
934
  return e.batchImages.length > 0 ? e.batchImages : [{
935
935
  imageUrl: ((n = e.image) == null ? void 0 : n.url) || "",
936
- annotations: ((s = o.value) == null ? void 0 : s.getAnnotations()) || []
936
+ annotations: ((s = a.value) == null ? void 0 : s.getAnnotations()) || []
937
937
  }];
938
938
  },
939
939
  getCurrentAnnotation: () => {
940
940
  var n, s, l;
941
941
  return {
942
- imageUrl: ((n = e.batchImages[f.value]) == null ? void 0 : n.imageUrl) || ((s = e.image) == null ? void 0 : s.url) || "",
943
- annotations: ((l = o.value) == null ? void 0 : l.getAnnotations()) || []
942
+ imageUrl: ((n = e.batchImages[u.value]) == null ? void 0 : n.imageUrl) || ((s = e.image) == null ? void 0 : s.url) || "",
943
+ annotations: ((l = a.value) == null ? void 0 : l.getAnnotations()) || []
944
944
  };
945
945
  }
946
- }), X(() => {
946
+ }), Y(() => {
947
947
  var n;
948
948
  return (n = e.image) == null ? void 0 : n.url;
949
949
  }, () => {
950
950
  var n;
951
- e.batchImages.length === 0 && ((n = e.image) != null && n.url) && x();
952
- }), X(() => e.predictionCandidates, (n) => {
953
- n && gt(n);
954
- }, { immediate: !0, deep: !0 }), X(
951
+ e.batchImages.length === 0 && ((n = e.image) != null && n.url) && W();
952
+ }), Y(() => e.predictionCandidates, (n) => {
953
+ n && ut(n);
954
+ }, { immediate: !0, deep: !0 }), Y(
955
955
  () => e.batchImages.map((n) => `${n.imageUrl}:${n.width || ""}x${n.height || ""}`),
956
956
  () => {
957
- tt();
957
+ X();
958
958
  },
959
959
  { immediate: !0 }
960
- ), (n, s) => (y(), p("div", {
961
- class: W(["annotation-container", u.theme])
960
+ ), (n, s) => (y(), x("div", {
961
+ class: J(["annotation-container", f.theme])
962
962
  }, [
963
- u.batchImages && u.batchImages.length > 0 ? (y(), p("div", ye, [
964
- g("div", pe, "批量图片(" + P(u.batchImages.length) + ")", 1),
963
+ f.batchImages && f.batchImages.length > 0 ? (y(), x("div", ye, [
964
+ g("div", pe, "批量图片(" + P(f.batchImages.length) + ")", 1),
965
965
  g("div", xe, [
966
- (y(!0), p(B, null, U(u.batchImages, (l, h) => (y(), p("button", {
966
+ (y(!0), x(B, null, F(f.batchImages, (l, h) => (y(), x("button", {
967
967
  key: `${l.imageUrl}-${h}`,
968
- class: W(["image-list-item", { active: h === f.value }]),
969
- onClick: (v) => vt(h)
968
+ class: J(["image-list-item", { active: h === u.value }]),
969
+ onClick: (v) => mt(h)
970
970
  }, [
971
971
  g("div", we, [
972
972
  g("img", {
@@ -974,27 +974,27 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
974
974
  alt: `第${h + 1}张`,
975
975
  class: "image-list-thumb"
976
976
  }, null, 8, Ce),
977
- Dt(h) ? (y(), p("div", Ae, [
978
- (y(!0), p(B, null, U(Pt(h), (v) => (y(), p(B, {
977
+ Dt(h) ? (y(), x("div", Ae, [
978
+ (y(!0), x(B, null, F(Pt(h), (v) => (y(), x(B, {
979
979
  key: v.id
980
980
  }, [
981
- Ht(v) ? (y(), p("div", {
981
+ Ht(v) ? (y(), x("div", {
982
982
  key: 0,
983
983
  class: "thumb-overlay-rect",
984
- style: O(Ut(h, v))
985
- }, null, 4)) : Lt(v) ? (y(), p("svg", _e, [
984
+ style: V(Ut(h, v))
985
+ }, null, 4)) : Lt(v) ? (y(), x("svg", _e, [
986
986
  g("polygon", {
987
987
  points: Ft(h, v),
988
- style: O(Et(v))
988
+ style: V(Ot(v))
989
989
  }, null, 12, Ie)
990
- ])) : Rt(v) ? (y(!0), p(B, { key: 2 }, U(mt(v), (A, $) => (y(), p("div", {
990
+ ])) : Rt(v) ? (y(!0), x(B, { key: 2 }, F(ft(v), (A, $) => (y(), x("div", {
991
991
  key: `${v.id}-${$}`,
992
992
  class: "thumb-overlay-point",
993
- style: O(Ot(h, A, v))
994
- }, null, 4))), 128)) : Bt(v) ? (y(), p("div", {
993
+ style: V(Et(h, A, v))
994
+ }, null, 4))), 128)) : Bt(v) ? (y(), x("div", {
995
995
  key: 3,
996
996
  class: "thumb-overlay-rotated",
997
- style: O(Vt(h, v))
997
+ style: V(Vt(h, v))
998
998
  }, null, 4)) : T("", !0)
999
999
  ], 64))), 128))
1000
1000
  ])) : T("", !0)
@@ -1003,26 +1003,26 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1003
1003
  ], 10, be))), 128))
1004
1004
  ])
1005
1005
  ])) : T("", !0),
1006
- u.readOnly ? T("", !0) : (y(), p("div", Se, [
1006
+ f.readOnly ? T("", !0) : (y(), x("div", Se, [
1007
1007
  g("div", {
1008
- class: W(["tool-btn", { active: d.value === "pan" }]),
1009
- onClick: s[0] || (s[0] = (l) => b("pan")),
1008
+ class: J(["tool-btn", { active: d.value === "pan" }]),
1009
+ onClick: s[0] || (s[0] = (l) => p("pan")),
1010
1010
  title: "拖动"
1011
1011
  }, [
1012
1012
  L(H, { name: "rank" })
1013
1013
  ], 2),
1014
1014
  g("div", {
1015
- class: W(["tool-btn", { active: d.value === "select" }]),
1016
- onClick: s[1] || (s[1] = (l) => b("select")),
1015
+ class: J(["tool-btn", { active: d.value === "select" }]),
1016
+ onClick: s[1] || (s[1] = (l) => p("select")),
1017
1017
  title: "选择"
1018
1018
  }, [
1019
1019
  L(H, { name: "pointer" })
1020
1020
  ], 2),
1021
1021
  s[5] || (s[5] = g("div", { class: "divider" }, null, -1)),
1022
- (y(!0), p(B, null, U(nt.value, (l) => (y(), p("div", {
1022
+ (y(!0), x(B, null, F(nt.value, (l) => (y(), x("div", {
1023
1023
  key: l,
1024
- class: W(["tool-btn", { active: d.value === l }]),
1025
- onClick: (h) => b(l),
1024
+ class: J(["tool-btn", { active: d.value === l }]),
1025
+ onClick: (h) => p(l),
1026
1026
  title: it(l)
1027
1027
  }, [
1028
1028
  L(H, {
@@ -1032,74 +1032,74 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1032
1032
  s[6] || (s[6] = g("div", { class: "divider" }, null, -1)),
1033
1033
  g("div", {
1034
1034
  class: "tool-btn",
1035
- onClick: ht,
1035
+ onClick: q,
1036
1036
  title: "放大"
1037
1037
  }, [
1038
1038
  L(H, { name: "zoom-in" })
1039
1039
  ]),
1040
1040
  g("div", {
1041
1041
  class: "tool-btn",
1042
- onClick: pt,
1042
+ onClick: dt,
1043
1043
  title: "缩小"
1044
1044
  }, [
1045
1045
  L(H, { name: "zoom-out" })
1046
1046
  ]),
1047
1047
  s[7] || (s[7] = g("div", { class: "divider" }, null, -1)),
1048
- j.value ? (y(), p("div", {
1048
+ N.value ? (y(), x("div", {
1049
1049
  key: 0,
1050
1050
  class: "tool-btn",
1051
- onClick: z,
1051
+ onClick: b,
1052
1052
  title: "删除选中"
1053
1053
  }, [
1054
1054
  L(H, { name: "delete" })
1055
1055
  ])) : T("", !0)
1056
1056
  ])),
1057
1057
  g("div", ze, [
1058
- u.readOnly ? T("", !0) : (y(), p("div", $e, [
1058
+ f.readOnly ? T("", !0) : (y(), x("div", $e, [
1059
1059
  g("div", Te, [
1060
1060
  s[8] || (s[8] = g("span", { class: "label-text" }, "当前标签:", -1)),
1061
1061
  g("div", Pe, [
1062
- (y(!0), p(B, null, U(m.value, (l) => (y(), p("div", {
1062
+ (y(!0), x(B, null, F(m.value, (l) => (y(), x("div", {
1063
1063
  key: l.id,
1064
- class: W(["tag-chip", { active: _.value === l.id }]),
1065
- style: O({ backgroundColor: l.color, borderColor: l.color }),
1066
- onClick: (h) => Y(l)
1064
+ class: J(["tag-chip", { active: _.value === l.id }]),
1065
+ style: V({ backgroundColor: l.color, borderColor: l.color }),
1066
+ onClick: (h) => G(l)
1067
1067
  }, P(l.name), 15, He))), 128)),
1068
- m.value.length === 0 ? (y(), p("div", Le, "请在右侧创建标签")) : T("", !0)
1068
+ m.value.length === 0 ? (y(), x("div", Le, "请在右侧创建标签")) : T("", !0)
1069
1069
  ])
1070
1070
  ])
1071
1071
  ])),
1072
1072
  g("div", {
1073
1073
  class: "canvas-wrapper",
1074
1074
  ref_key: "canvasWrapper",
1075
- ref: c,
1075
+ ref: r,
1076
1076
  onWheel: s[2] || (s[2] = qt(() => {
1077
1077
  }, ["prevent"]))
1078
1078
  }, [
1079
1079
  g("canvas", {
1080
1080
  ref_key: "canvasRef",
1081
- ref: r
1081
+ ref: c
1082
1082
  }, null, 512)
1083
1083
  ], 544),
1084
- u.batchImages && u.batchImages.length > 0 ? (y(), p("div", Re, [
1084
+ f.batchImages && f.batchImages.length > 0 ? (y(), x("div", Re, [
1085
1085
  g("button", {
1086
1086
  onClick: It,
1087
- disabled: f.value <= 0
1087
+ disabled: u.value <= 0
1088
1088
  }, [
1089
1089
  L(H, { name: "back" }),
1090
- s[9] || (s[9] = q(" 上一张 ", -1))
1090
+ s[9] || (s[9] = K(" 上一张 ", -1))
1091
1091
  ], 8, Be),
1092
- g("span", null, P(f.value + 1) + " / " + P(u.batchImages.length), 1),
1092
+ g("span", null, P(u.value + 1) + " / " + P(f.batchImages.length), 1),
1093
1093
  g("button", {
1094
1094
  onClick: kt,
1095
- disabled: f.value >= u.batchImages.length - 1
1095
+ disabled: u.value >= f.batchImages.length - 1
1096
1096
  }, [
1097
- s[10] || (s[10] = q(" 下一张 ", -1)),
1097
+ s[10] || (s[10] = K(" 下一张 ", -1)),
1098
1098
  L(H, { name: "right" })
1099
1099
  ], 8, De)
1100
1100
  ])) : T("", !0)
1101
1101
  ]),
1102
- u.readOnly ? T("", !0) : (y(), p("div", Ue, [
1102
+ f.readOnly ? T("", !0) : (y(), x("div", Ue, [
1103
1103
  g("div", { class: "sidebar-header" }, [
1104
1104
  s[11] || (s[11] = g("h3", null, "标签管理", -1)),
1105
1105
  g("button", {
@@ -1108,21 +1108,21 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1108
1108
  }, "添加标签")
1109
1109
  ]),
1110
1110
  g("div", Fe, [
1111
- (y(!0), p(B, null, U(m.value, (l) => (y(), p("div", {
1111
+ (y(!0), x(B, null, F(m.value, (l) => (y(), x("div", {
1112
1112
  key: l.id,
1113
1113
  class: "label-item"
1114
1114
  }, [
1115
- g("div", Ee, [
1115
+ g("div", Oe, [
1116
1116
  g("label", {
1117
1117
  class: "color-wrapper",
1118
- style: O({ backgroundColor: l.color })
1118
+ style: V({ backgroundColor: l.color })
1119
1119
  }, [
1120
1120
  lt(g("input", {
1121
1121
  type: "color",
1122
1122
  "onUpdate:modelValue": (h) => l.color = h,
1123
1123
  onChange: (h) => Ct(l),
1124
1124
  style: { visibility: "hidden", width: "0", height: "0" }
1125
- }, null, 40, Oe), [
1125
+ }, null, 40, Ee), [
1126
1126
  [rt, l.color]
1127
1127
  ])
1128
1128
  ], 4),
@@ -1134,15 +1134,15 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1134
1134
  class: "action-icon eye",
1135
1135
  onClick: (h) => At(l)
1136
1136
  }, [
1137
- l.visible ? (y(), ft(H, {
1137
+ l.visible ? (y(), yt(H, {
1138
1138
  key: 0,
1139
1139
  name: "view"
1140
- })) : (y(), ft(H, {
1140
+ })) : (y(), yt(H, {
1141
1141
  key: 1,
1142
1142
  name: "hide"
1143
1143
  }))
1144
- ], 8, We),
1145
- g("div", Ne, [
1144
+ ], 8, Ne),
1145
+ g("div", We, [
1146
1146
  s[12] || (s[12] = g("span", { class: "dots" }, "•••", -1)),
1147
1147
  g("span", {
1148
1148
  class: "delete-btn",
@@ -1156,7 +1156,7 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1156
1156
  ]))), 128))
1157
1157
  ])
1158
1158
  ])),
1159
- F.value ? (y(), p("div", je, [
1159
+ U.value ? (y(), x("div", je, [
1160
1160
  g("div", Ye, [
1161
1161
  s[15] || (s[15] = g("h3", null, "新增标签", -1)),
1162
1162
  g("div", Xe, [
@@ -1184,7 +1184,7 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1184
1184
  ]),
1185
1185
  g("div", { class: "modal-actions" }, [
1186
1186
  g("button", {
1187
- onClick: dt,
1187
+ onClick: gt,
1188
1188
  class: "cancel-btn"
1189
1189
  }, "取消"),
1190
1190
  g("button", {
@@ -1196,13 +1196,13 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1196
1196
  ])) : T("", !0)
1197
1197
  ], 2));
1198
1198
  }
1199
- }), Ze = /* @__PURE__ */ Q(Ke, [["__scopeId", "data-v-79777e6e"]]), Qe = {
1199
+ }), Ze = /* @__PURE__ */ et(Ke, [["__scopeId", "data-v-ccc538f3"]]), Qe = {
1200
1200
  class: "thumbnail-wrapper",
1201
1201
  ref: "wrapper"
1202
1202
  }, tn = ["src", "alt"], en = ["viewBox", "preserveAspectRatio"], nn = ["x", "y", "width", "height", "stroke", "stroke-width"], sn = ["points", "stroke", "stroke-width"], on = ["x", "y", "fill", "font-size"], an = {
1203
1203
  key: 1,
1204
1204
  class: "loading-placeholder"
1205
- }, ln = /* @__PURE__ */ Z({
1205
+ }, ln = /* @__PURE__ */ tt({
1206
1206
  __name: "AnnotationThumbnail",
1207
1207
  props: {
1208
1208
  src: {},
@@ -1213,10 +1213,10 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1213
1213
  strokeWidth: {},
1214
1214
  fontSize: {}
1215
1215
  },
1216
- setup(u) {
1217
- const t = u, i = M(null), e = M(!1), a = M(0), r = M(0), c = () => {
1218
- i.value && (a.value = i.value.naturalWidth, r.value = i.value.naturalHeight, e.value = !0);
1219
- }, o = D(() => t.fit === "contain" ? "xMidYMid meet" : "xMidYMid slice"), d = D(() => t.strokeWidth ?? 10), f = D(() => t.fontSize ?? 30), w = (k) => {
1216
+ setup(f) {
1217
+ const t = f, i = M(null), e = M(!1), o = M(0), c = M(0), r = () => {
1218
+ i.value && (o.value = i.value.naturalWidth, c.value = i.value.naturalHeight, e.value = !0);
1219
+ }, a = D(() => t.fit === "contain" ? "xMidYMid meet" : "xMidYMid slice"), d = D(() => t.strokeWidth ?? 10), u = D(() => t.fontSize ?? 30), w = (k) => {
1220
1220
  var I;
1221
1221
  if ((I = k.style) != null && I.strokeColor) return k.style.strokeColor;
1222
1222
  if (t.labels) {
@@ -1225,9 +1225,9 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1225
1225
  }
1226
1226
  return "#FF0000";
1227
1227
  }, m = (k) => {
1228
- const I = k.coordinates, C = Math.min(I.x1, I.x2), R = Math.min(I.y1, I.y2), j = Math.abs(I.x1 - I.x2), V = Math.abs(I.y1 - I.y2);
1229
- return { x: C, y: R, width: j, height: V };
1230
- }, _ = (k) => k.coordinates.points.map((C) => `${C.x},${C.y}`).join(" "), F = (k) => {
1228
+ const I = k.coordinates, C = Math.min(I.x1, I.x2), R = Math.min(I.y1, I.y2), N = Math.abs(I.x1 - I.x2), j = Math.abs(I.y1 - I.y2);
1229
+ return { x: C, y: R, width: N, height: j };
1230
+ }, _ = (k) => k.coordinates.points.map((C) => `${C.x},${C.y}`).join(" "), U = (k) => {
1231
1231
  if (k.type === "rectangle") {
1232
1232
  const I = m(k);
1233
1233
  return { x: I.x, y: I.y - 5 };
@@ -1237,26 +1237,26 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1237
1237
  }
1238
1238
  return { x: 0, y: 0 };
1239
1239
  };
1240
- return (k, I) => (y(), p("div", Qe, [
1240
+ return (k, I) => (y(), x("div", Qe, [
1241
1241
  g("img", {
1242
1242
  ref_key: "img",
1243
1243
  ref: i,
1244
- src: u.src,
1244
+ src: f.src,
1245
1245
  class: "thumbnail-image",
1246
- style: O({ objectFit: u.fit }),
1247
- onLoad: c,
1248
- alt: u.alt
1246
+ style: V({ objectFit: f.fit }),
1247
+ onLoad: r,
1248
+ alt: f.alt
1249
1249
  }, null, 44, tn),
1250
- e.value ? (y(), p("svg", {
1250
+ e.value ? (y(), x("svg", {
1251
1251
  key: 0,
1252
1252
  class: "annotation-overlay",
1253
- viewBox: `0 0 ${a.value} ${r.value}`,
1254
- preserveAspectRatio: o.value
1253
+ viewBox: `0 0 ${o.value} ${c.value}`,
1254
+ preserveAspectRatio: a.value
1255
1255
  }, [
1256
- (y(!0), p(B, null, U(u.annotations, (C) => (y(), p(B, {
1256
+ (y(!0), x(B, null, F(f.annotations, (C) => (y(), x(B, {
1257
1257
  key: C.id
1258
1258
  }, [
1259
- C.type === "rectangle" ? (y(), p("rect", {
1259
+ C.type === "rectangle" ? (y(), x("rect", {
1260
1260
  key: 0,
1261
1261
  x: m(C).x,
1262
1262
  y: m(C).y,
@@ -1266,27 +1266,27 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1266
1266
  "stroke-width": d.value,
1267
1267
  fill: "transparent"
1268
1268
  }, null, 8, nn)) : T("", !0),
1269
- C.type === "polygon" ? (y(), p("polygon", {
1269
+ C.type === "polygon" ? (y(), x("polygon", {
1270
1270
  key: 1,
1271
1271
  points: _(C),
1272
1272
  stroke: w(C),
1273
1273
  "stroke-width": d.value,
1274
1274
  fill: "transparent"
1275
1275
  }, null, 8, sn)) : T("", !0),
1276
- C.label ? (y(), p("text", {
1276
+ C.label ? (y(), x("text", {
1277
1277
  key: 2,
1278
- x: F(C).x,
1279
- y: F(C).y,
1278
+ x: U(C).x,
1279
+ y: U(C).y,
1280
1280
  fill: w(C),
1281
- "font-size": f.value,
1281
+ "font-size": u.value,
1282
1282
  "font-weight": "bold",
1283
1283
  class: "anno-label"
1284
1284
  }, P(C.label), 9, on)) : T("", !0)
1285
1285
  ], 64))), 128))
1286
- ], 8, en)) : (y(), p("div", an, "Loading..."))
1286
+ ], 8, en)) : (y(), x("div", an, "Loading..."))
1287
1287
  ], 512));
1288
1288
  }
1289
- }), rn = /* @__PURE__ */ Q(ln, [["__scopeId", "data-v-d2fd08ec"]]), cn = {
1289
+ }), rn = /* @__PURE__ */ et(ln, [["__scopeId", "data-v-d2fd08ec"]]), cn = {
1290
1290
  key: 0,
1291
1291
  class: "gallery-view"
1292
1292
  }, hn = { class: "gallery-header" }, dn = { class: "label-summary" }, gn = ["onClick"], un = { class: "thumbnail-wrapper" }, vn = { class: "img-meta" }, mn = { class: "img-index" }, fn = { class: "anno-count" }, yn = {
@@ -1295,7 +1295,7 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1295
1295
  }, pn = {
1296
1296
  key: 1,
1297
1297
  class: "editor-view"
1298
- }, xn = { class: "editor-header" }, bn = { class: "header-left" }, wn = { class: "editor-title" }, Cn = { class: "editor-content" }, An = /* @__PURE__ */ Z({
1298
+ }, xn = { class: "editor-header" }, bn = { class: "header-left" }, wn = { class: "editor-title" }, Cn = { class: "editor-content" }, An = /* @__PURE__ */ tt({
1299
1299
  __name: "BatchAnnotator",
1300
1300
  props: {
1301
1301
  images: {},
@@ -1305,157 +1305,164 @@ const Qt = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" widt
1305
1305
  thumbStrokeWidth: {},
1306
1306
  thumbFontSize: {}
1307
1307
  },
1308
- emits: ["export", "update:images", "imageClick"],
1309
- setup(u, { expose: t, emit: i }) {
1310
- const e = u, a = i, r = M("gallery"), c = M([]), o = M(0), d = M(null), f = M(null), w = M(null), m = D(() => {
1311
- var x, b;
1312
- return ((b = (x = e.actionBar) == null ? void 0 : x.annotateButton) == null ? void 0 : b.show) === !0;
1313
- }), _ = D(() => {
1314
- var x, b;
1315
- return ((b = (x = e.actionBar) == null ? void 0 : x.exportButton) == null ? void 0 : b.show) === !0;
1316
- }), F = D(() => m.value || _.value), k = D(() => {
1317
- var x, b;
1318
- return ((b = (x = e.actionBar) == null ? void 0 : x.annotateButton) == null ? void 0 : b.text) || "手动标注";
1319
- }), I = D(() => {
1320
- var x, b;
1321
- return ((b = (x = e.actionBar) == null ? void 0 : x.exportButton) == null ? void 0 : b.text) || "导出";
1322
- }), C = D(() => e.clickToEnterEditor !== !1);
1323
- X(() => e.images, (x) => {
1324
- c.value = JSON.parse(JSON.stringify(x));
1308
+ emits: ["export", "update:images", "imageClick", "update:labels"],
1309
+ setup(f, { expose: t, emit: i }) {
1310
+ const e = f, o = i, c = M("gallery"), r = M([]), a = M([]), d = M(0), u = M(null), w = M(null), m = M(null), _ = D(() => {
1311
+ var p, b;
1312
+ return ((b = (p = e.actionBar) == null ? void 0 : p.annotateButton) == null ? void 0 : b.show) === !0;
1313
+ }), U = D(() => {
1314
+ var p, b;
1315
+ return ((b = (p = e.actionBar) == null ? void 0 : p.exportButton) == null ? void 0 : b.show) === !0;
1316
+ }), k = D(() => _.value || U.value), I = D(() => {
1317
+ var p, b;
1318
+ return ((b = (p = e.actionBar) == null ? void 0 : p.annotateButton) == null ? void 0 : b.text) || "手动标注";
1319
+ }), C = D(() => {
1320
+ var p, b;
1321
+ return ((b = (p = e.actionBar) == null ? void 0 : p.exportButton) == null ? void 0 : b.text) || "导出";
1322
+ }), R = D(() => e.clickToEnterEditor !== !1);
1323
+ Y(() => e.images, (p) => {
1324
+ r.value = JSON.parse(JSON.stringify(p));
1325
+ }, { immediate: !0, deep: !0 }), Y(() => e.labels, (p) => {
1326
+ a.value = JSON.parse(JSON.stringify(p || []));
1325
1327
  }, { immediate: !0, deep: !0 });
1326
- const R = (x) => {
1327
- o.value = x, r.value = "editor", w.value && (w.value.scrollTop = 0), Gt(() => {
1328
- f.value && (f.value.scrollTop = 0), window.scrollTo(0, 0), requestAnimationFrame(() => {
1328
+ const N = (p) => {
1329
+ d.value = p, c.value = "editor", m.value && (m.value.scrollTop = 0), Gt(() => {
1330
+ w.value && (w.value.scrollTop = 0), window.scrollTo(0, 0), requestAnimationFrame(() => {
1329
1331
  var b, z;
1330
- (z = (b = d.value) == null ? void 0 : b.jumpTo) == null || z.call(b, x);
1332
+ (z = (b = u.value) == null ? void 0 : b.jumpTo) == null || z.call(b, p);
1331
1333
  });
1332
1334
  });
1333
- }, j = (x, b) => {
1334
- if (C.value) {
1335
- R(x);
1335
+ }, j = (p, b) => {
1336
+ if (R.value) {
1337
+ N(p);
1336
1338
  return;
1337
1339
  }
1338
- a("imageClick", { index: x, imageId: b.id, image: b });
1339
- }, V = (x) => c.value.findIndex((b) => b.id === x);
1340
+ o("imageClick", { index: p, imageId: b.id, image: b });
1341
+ }, X = (p) => r.value.findIndex((b) => b.id === p);
1340
1342
  t({
1341
- openImageById: (x) => {
1342
- const b = V(x);
1343
- return b < 0 ? !1 : (R(b), !0);
1343
+ openImageById: (p) => {
1344
+ const b = X(p);
1345
+ return b < 0 ? !1 : (N(b), !0);
1344
1346
  },
1345
- triggerImageClickById: (x) => {
1346
- const b = V(x);
1347
+ triggerImageClickById: (p) => {
1348
+ const b = X(p);
1347
1349
  if (b < 0)
1348
1350
  return !1;
1349
- const z = c.value[b];
1350
- return z ? (a("imageClick", { index: b, imageId: z.id, image: z }), !0) : !1;
1351
- }
1351
+ const z = r.value[b];
1352
+ return z ? (o("imageClick", { index: b, imageId: z.id, image: z }), !0) : !1;
1353
+ },
1354
+ getFinalData: () => ({
1355
+ images: JSON.parse(JSON.stringify(r.value)),
1356
+ labels: JSON.parse(JSON.stringify(a.value))
1357
+ })
1352
1358
  });
1353
- const et = () => {
1354
- if (d.value && d.value.getCurrentAnnotation) {
1355
- const x = d.value.getCurrentAnnotation();
1356
- c.value[o.value] && (c.value[o.value].annotations = x.annotations);
1359
+ const nt = () => {
1360
+ if (u.value && u.value.getCurrentAnnotation) {
1361
+ const p = u.value.getCurrentAnnotation();
1362
+ r.value[d.value] && (r.value[d.value].annotations = p.annotations);
1357
1363
  }
1358
- r.value = "gallery";
1359
- }, nt = () => {
1360
- a("export", c.value);
1361
- }, st = (x) => {
1362
- o.value = x.currentIndex, c.value[x.currentIndex] && (c.value[x.currentIndex].annotations = x.currentAnnotations);
1363
- }, it = (x) => {
1364
- if (d.value && d.value.getCurrentAnnotation) {
1365
- const b = d.value.getCurrentAnnotation();
1366
- c.value[o.value] && (c.value[o.value].annotations = b.annotations, a("update:images", c.value));
1364
+ c.value = "gallery";
1365
+ }, st = () => {
1366
+ o("export", r.value);
1367
+ }, it = (p) => {
1368
+ d.value = p.currentIndex, r.value[p.currentIndex] && (r.value[p.currentIndex].annotations = p.currentAnnotations);
1369
+ }, E = (p) => {
1370
+ if (u.value && u.value.getCurrentAnnotation) {
1371
+ const b = u.value.getCurrentAnnotation();
1372
+ r.value[d.value] && (r.value[d.value].annotations = b.annotations, o("update:images", r.value));
1367
1373
  }
1368
- }, N = (x) => {
1374
+ }, W = (p) => {
1375
+ a.value = JSON.parse(JSON.stringify(p || [])), o("update:labels", a.value);
1369
1376
  };
1370
- return (x, b) => (y(), p("div", {
1377
+ return (p, b) => (y(), x("div", {
1371
1378
  ref_key: "batchRootRef",
1372
- ref: f,
1379
+ ref: w,
1373
1380
  class: "batch-annotator"
1374
1381
  }, [
1375
- r.value === "gallery" ? (y(), p("div", cn, [
1382
+ c.value === "gallery" ? (y(), x("div", cn, [
1376
1383
  g("div", hn, [
1377
- g("h3", null, "批量查看与标注 (" + P(c.value.length) + " 张)", 1),
1384
+ g("h3", null, "批量查看与标注 (" + P(r.value.length) + " 张)", 1),
1378
1385
  g("div", dn, [
1379
- (y(!0), p(B, null, U(u.labels, (z) => (y(), p("span", {
1386
+ (y(!0), x(B, null, F(a.value, (z) => (y(), x("span", {
1380
1387
  key: z.id,
1381
1388
  class: "label-badge",
1382
- style: O({ backgroundColor: z.color })
1389
+ style: V({ backgroundColor: z.color })
1383
1390
  }, P(z.name), 5))), 128))
1384
1391
  ])
1385
1392
  ]),
1386
1393
  g("div", {
1387
1394
  ref_key: "galleryGridRef",
1388
- ref: w,
1395
+ ref: m,
1389
1396
  class: "gallery-grid"
1390
1397
  }, [
1391
- (y(!0), p(B, null, U(c.value, (z, J) => (y(), p("div", {
1392
- key: J,
1398
+ (y(!0), x(B, null, F(r.value, (z, q) => (y(), x("div", {
1399
+ key: q,
1393
1400
  class: "gallery-item",
1394
- onClick: (ht) => j(J, z)
1401
+ onClick: (dt) => j(q, z)
1395
1402
  }, [
1396
1403
  g("div", un, [
1397
1404
  L(rn, {
1398
1405
  src: z.imageUrl,
1399
1406
  annotations: z.annotations || [],
1400
- labels: u.labels,
1407
+ labels: a.value,
1401
1408
  fit: "cover",
1402
1409
  strokeWidth: e.thumbStrokeWidth,
1403
1410
  fontSize: e.thumbFontSize
1404
1411
  }, null, 8, ["src", "annotations", "labels", "strokeWidth", "fontSize"])
1405
1412
  ]),
1406
1413
  g("div", vn, [
1407
- g("span", mn, "#" + P(J + 1), 1),
1414
+ g("span", mn, "#" + P(q + 1), 1),
1408
1415
  g("span", fn, P((z.annotations || []).length) + " 标注", 1)
1409
1416
  ])
1410
1417
  ], 8, gn))), 128))
1411
1418
  ], 512),
1412
- F.value ? (y(), p("div", yn, [
1413
- m.value ? (y(), p("button", {
1419
+ k.value ? (y(), x("div", yn, [
1420
+ _.value ? (y(), x("button", {
1414
1421
  key: 0,
1415
1422
  class: "action-btn primary",
1416
- onClick: b[0] || (b[0] = (z) => R(0))
1423
+ onClick: b[0] || (b[0] = (z) => N(0))
1417
1424
  }, [
1418
1425
  L(H, { name: "edit" }),
1419
- q(" " + P(k.value), 1)
1426
+ K(" " + P(I.value), 1)
1420
1427
  ])) : T("", !0),
1421
- _.value ? (y(), p("button", {
1428
+ U.value ? (y(), x("button", {
1422
1429
  key: 1,
1423
1430
  class: "action-btn success",
1424
- onClick: nt
1431
+ onClick: st
1425
1432
  }, [
1426
1433
  L(H, { name: "download" }),
1427
- q(" " + P(I.value), 1)
1434
+ K(" " + P(C.value), 1)
1428
1435
  ])) : T("", !0)
1429
1436
  ])) : T("", !0)
1430
- ])) : (y(), p("div", pn, [
1437
+ ])) : (y(), x("div", pn, [
1431
1438
  g("div", xn, [
1432
1439
  g("div", bn, [
1433
1440
  g("button", {
1434
1441
  class: "back-btn",
1435
- onClick: et
1442
+ onClick: nt
1436
1443
  }, [
1437
1444
  L(H, { name: "back" }),
1438
- b[1] || (b[1] = q(" 返回列表 ", -1))
1445
+ b[1] || (b[1] = K(" 返回列表 ", -1))
1439
1446
  ]),
1440
- g("span", wn, "正在标注: " + P(o.value + 1) + " / " + P(c.value.length), 1)
1447
+ g("span", wn, "正在标注: " + P(d.value + 1) + " / " + P(r.value.length), 1)
1441
1448
  ])
1442
1449
  ]),
1443
1450
  g("div", Cn, [
1444
1451
  L(Ze, {
1445
1452
  ref_key: "annotatorRef",
1446
- ref: d,
1447
- batchImages: c.value,
1448
- labels: u.labels,
1453
+ ref: u,
1454
+ batchImages: r.value,
1455
+ labels: a.value,
1449
1456
  annotationTypes: ["rectangle", "polygon", "point", "rotatedRect"],
1450
- onBatchChange: st,
1451
- onAnnotationChange: it,
1452
- onLabelChange: N
1457
+ onBatchChange: it,
1458
+ onAnnotationChange: E,
1459
+ onLabelChange: W
1453
1460
  }, null, 8, ["batchImages", "labels"])
1454
1461
  ])
1455
1462
  ]))
1456
1463
  ], 512));
1457
1464
  }
1458
- }), kn = /* @__PURE__ */ Q(An, [["__scopeId", "data-v-02216921"]]);
1465
+ }), kn = /* @__PURE__ */ et(An, [["__scopeId", "data-v-0ae1040a"]]);
1459
1466
  export {
1460
1467
  kn as BatchAnnotator,
1461
1468
  Ze as ImageAnnotator,